@templatical/editor 0.20.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +1 -0
  2. package/dist/{AiChatSidebar-ChrE6pUq.js → AiChatSidebar-K_AehWc-.js} +9 -9
  3. package/dist/{AiFeatureMenu-DkQ9HhQ6.js → AiFeatureMenu-CcqQDHzJ.js} +6 -6
  4. package/dist/{BlockIssueBadge-B4QjePax.js → BlockIssueBadge-Dmj9rVra.js} +4 -4
  5. package/dist/{CloudEditor-CfX-aMiV.js → CloudEditor-Dnww6og-.js} +263 -315
  6. package/dist/{CollaboratorBar-DTibhQ1j.js → CollaboratorBar-Bj4NZiie.js} +3 -3
  7. package/dist/{ColorPicker-4vDYhdGe.js → ColorPicker-s9GHXjZs.js} +4 -4
  8. package/dist/CommentsSidebar-DvNEdugN.js +435 -0
  9. package/dist/CountdownBlock-J_Q9JRQM.js +91 -0
  10. package/dist/{CountdownToolbar-D7yQqnA2.js → CountdownToolbar-DPRcv3Fu.js} +3 -4
  11. package/dist/{DesignReferenceSidebar-DnO6ZdwS.js → DesignReferenceSidebar-DNmK3dxp.js} +8 -8
  12. package/dist/{IssuesPanel-X_vkNGrs.js → IssuesPanel-CEnEGFtd.js} +7 -7
  13. package/dist/{MergeTagSuggestion-DCuaSOPQ.js → MergeTagSuggestion-DMe4rqn0.js} +2 -2
  14. package/dist/NumberWithSuffix-CCPN_oCh.js +121 -0
  15. package/dist/{ParagraphEditor-C5ixOIYb.js → ParagraphEditor--_zWfxps.js} +47 -47
  16. package/dist/{RichTextEditorContent-DwhDnMsG.js → RichTextEditorContent-FbnWsh46.js} +6 -6
  17. package/dist/SaveBlockDialog-CYIEHABH.js +264 -0
  18. package/dist/SavedBlockPreviewCanvas-2-mzAnZE.js +109 -0
  19. package/dist/SavedBlocksBrowserModal-D5V5yF_3.js +323 -0
  20. package/dist/SavedBlocksPanels-Dff38YXu.js +36 -0
  21. package/dist/SavedBlocksPickBar-rB6iyji6.js +52 -0
  22. package/dist/{SnapshotHistory-DaVueFv6.js → SnapshotHistory-FtzDq8f0.js} +8 -8
  23. package/dist/{TemplateScoringPanel-B0UHoTLx.js → TemplateScoringPanel-ifGGGWs5.js} +14 -14
  24. package/dist/{TestEmailModal-BkauxF7j.js → TestEmailModal-DL2O1H8M.js} +4 -4
  25. package/dist/{TitleEditor-n6WDVDjW.js → TitleEditor-CPda5lh-.js} +11 -11
  26. package/dist/{TplModal-BDDyvT-C.js → TplModal-C7Koj5gM.js} +3 -3
  27. package/dist/{blockTypeIcons-4D0aFXNg.js → blockTypeIcons-CgwECCut.js} +6 -6
  28. package/dist/bundle-stats.json +8 -8
  29. package/dist/{cdn/chunks/ca-DbWoy4rG.js → ca-BBgad6y5.js} +50 -5
  30. package/dist/cdn/chunks/AiChatSidebar-A1CuWGY0.js +203 -0
  31. package/dist/cdn/chunks/AiChatSidebar-A1CuWGY0.js.map +1 -0
  32. package/dist/cdn/chunks/{AiFeatureMenu-CIBHAGSz.js → AiFeatureMenu-Duwg413F.js} +12 -8
  33. package/dist/cdn/chunks/{AiFeatureMenu-CIBHAGSz.js.map → AiFeatureMenu-Duwg413F.js.map} +1 -1
  34. package/dist/cdn/chunks/{BlockIssueBadge-CxMiLo3p.js → BlockIssueBadge-Da4yR-mh.js} +7 -5
  35. package/dist/cdn/chunks/{BlockIssueBadge-CxMiLo3p.js.map → BlockIssueBadge-Da4yR-mh.js.map} +1 -1
  36. package/dist/cdn/chunks/{CloudEditor-CEa3Xgqh.js → CloudEditor-B3hqbwfP.js} +275 -318
  37. package/dist/cdn/chunks/CloudEditor-B3hqbwfP.js.map +1 -0
  38. package/dist/cdn/chunks/{CollaboratorBar-Bk1gD02G.js → CollaboratorBar-BS3rJy6-.js} +7 -6
  39. package/dist/cdn/chunks/{CollaboratorBar-Bk1gD02G.js.map → CollaboratorBar-BS3rJy6-.js.map} +1 -1
  40. package/dist/cdn/chunks/{ColorPicker-ll8pynws.js → ColorPicker-DZSzZ5ZP.js} +168 -164
  41. package/dist/cdn/chunks/{ColorPicker-ll8pynws.js.map → ColorPicker-DZSzZ5ZP.js.map} +1 -1
  42. package/dist/cdn/chunks/CommentsSidebar-DHdRiGPX.js +412 -0
  43. package/dist/cdn/chunks/CommentsSidebar-DHdRiGPX.js.map +1 -0
  44. package/dist/cdn/chunks/CountdownBlock-Bffpoppw.js +93 -0
  45. package/dist/cdn/chunks/{CountdownBlock-eGUE7hhw.js.map → CountdownBlock-Bffpoppw.js.map} +1 -1
  46. package/dist/cdn/chunks/{CountdownToolbar-C1bkSjUR.js → CountdownToolbar-DAnmIZjq.js} +4 -5
  47. package/dist/cdn/chunks/{CountdownToolbar-C1bkSjUR.js.map → CountdownToolbar-DAnmIZjq.js.map} +1 -1
  48. package/dist/cdn/chunks/DesignReferenceSidebar-Dre99DTH.js +223 -0
  49. package/dist/cdn/chunks/DesignReferenceSidebar-Dre99DTH.js.map +1 -0
  50. package/dist/cdn/chunks/{IssuesPanel-Csasylf_.js → IssuesPanel-D80JedOj.js} +11 -10
  51. package/dist/cdn/chunks/{IssuesPanel-Csasylf_.js.map → IssuesPanel-D80JedOj.js.map} +1 -1
  52. package/dist/cdn/chunks/LoadingTrack-D-CW2tUa.js +12 -0
  53. package/dist/cdn/chunks/LoadingTrack-D-CW2tUa.js.map +1 -0
  54. package/dist/cdn/chunks/{MergeTagSuggestion-BmMmdcRg.js → MergeTagSuggestion-D7TsECll.js} +2 -2
  55. package/dist/cdn/chunks/{MergeTagSuggestion-BmMmdcRg.js.map → MergeTagSuggestion-D7TsECll.js.map} +1 -1
  56. package/dist/cdn/chunks/NumberWithSuffix-CjlVNIEe.js +123 -0
  57. package/dist/cdn/chunks/NumberWithSuffix-CjlVNIEe.js.map +1 -0
  58. package/dist/cdn/chunks/{ParagraphEditor-v0_XEL-v.js → ParagraphEditor-CtaRa1vr.js} +90 -85
  59. package/dist/cdn/chunks/{ParagraphEditor-v0_XEL-v.js.map → ParagraphEditor-CtaRa1vr.js.map} +1 -1
  60. package/dist/cdn/chunks/{RichTextEditorContent-NQExNsaV.js → RichTextEditorContent-BbdgJqWM.js} +9 -6
  61. package/dist/cdn/chunks/{RichTextEditorContent-NQExNsaV.js.map → RichTextEditorContent-BbdgJqWM.js.map} +1 -1
  62. package/dist/cdn/chunks/SaveBlockDialog-Bb3fdUEZ.js +263 -0
  63. package/dist/cdn/chunks/SaveBlockDialog-Bb3fdUEZ.js.map +1 -0
  64. package/dist/cdn/chunks/SavedBlockPreviewCanvas-DZOMgNsz.js +111 -0
  65. package/dist/cdn/chunks/SavedBlockPreviewCanvas-DZOMgNsz.js.map +1 -0
  66. package/dist/cdn/chunks/SavedBlocksBrowserModal-CeUWcPv0.js +322 -0
  67. package/dist/cdn/chunks/SavedBlocksBrowserModal-CeUWcPv0.js.map +1 -0
  68. package/dist/cdn/chunks/SavedBlocksPanels-D-pA_wfk.js +38 -0
  69. package/dist/cdn/chunks/SavedBlocksPanels-D-pA_wfk.js.map +1 -0
  70. package/dist/cdn/chunks/SavedBlocksPickBar-1rf1KpqS.js +54 -0
  71. package/dist/cdn/chunks/SavedBlocksPickBar-1rf1KpqS.js.map +1 -0
  72. package/dist/cdn/chunks/SnapshotHistory-Bf1uovti.js +121 -0
  73. package/dist/cdn/chunks/SnapshotHistory-Bf1uovti.js.map +1 -0
  74. package/dist/cdn/chunks/TemplateScoringPanel-CTk8WwxU.js +231 -0
  75. package/dist/cdn/chunks/TemplateScoringPanel-CTk8WwxU.js.map +1 -0
  76. package/dist/cdn/chunks/TestEmailModal-BJTDxFHh.js +96 -0
  77. package/dist/cdn/chunks/TestEmailModal-BJTDxFHh.js.map +1 -0
  78. package/dist/cdn/chunks/{TitleEditor-CS-_MzYs.js → TitleEditor-BJ7LFykI.js} +18 -15
  79. package/dist/cdn/chunks/{TitleEditor-CS-_MzYs.js.map → TitleEditor-BJ7LFykI.js.map} +1 -1
  80. package/dist/cdn/chunks/TplModal-CH9RzKF7.js +50 -0
  81. package/dist/cdn/chunks/TplModal-CH9RzKF7.js.map +1 -0
  82. package/dist/cdn/chunks/_plugin-vue_export-helper-B3ysoDQm.js +8 -0
  83. package/dist/cdn/chunks/blockTypeIcons-etMMQoVv.js +21 -0
  84. package/dist/cdn/chunks/{blockTypeIcons-B0Hjh42a.js.map → blockTypeIcons-etMMQoVv.js.map} +1 -1
  85. package/dist/{ca-DbWoy4rG.js → cdn/chunks/ca-BBgad6y5.js} +52 -3
  86. package/dist/cdn/chunks/ca-BBgad6y5.js.map +1 -0
  87. package/dist/cdn/chunks/cloud-BJlbXGTJ.js +1787 -0
  88. package/dist/cdn/chunks/cloud-BJlbXGTJ.js.map +1 -0
  89. package/dist/{de-CTYXVU9v.js → cdn/chunks/de-Bw6fB5JU.js} +2 -24
  90. package/dist/cdn/chunks/{de-CTYXVU9v.js.map → de-Bw6fB5JU.js.map} +1 -1
  91. package/dist/cdn/chunks/{de-CgGOnerg.js → de-D7WbpFBR.js} +50 -3
  92. package/dist/cdn/chunks/de-D7WbpFBR.js.map +1 -0
  93. package/dist/cdn/chunks/dist-CiBEt0VR.js +163 -0
  94. package/dist/cdn/chunks/dist-CiBEt0VR.js.map +1 -0
  95. package/dist/cdn/chunks/dist-CxTt8FRE.js +403 -0
  96. package/dist/cdn/chunks/dist-CxTt8FRE.js.map +1 -0
  97. package/dist/{en-DrUV9xth.js → cdn/chunks/en-BrZ0uGK2.js} +51 -2
  98. package/dist/cdn/chunks/en-BrZ0uGK2.js.map +1 -0
  99. package/dist/{en-BtmIaJeb.js → cdn/chunks/en-DAdHJz7h.js} +2 -24
  100. package/dist/cdn/chunks/{en-BtmIaJeb.js.map → en-DAdHJz7h.js.map} +1 -1
  101. package/dist/{es-DwbKjU7q.js → cdn/chunks/es-tLSLysPs.js} +51 -2
  102. package/dist/cdn/chunks/es-tLSLysPs.js.map +1 -0
  103. package/dist/cdn/chunks/{extensions-Di3hdIRT.js → extensions-ZX2oarW6.js} +28 -26
  104. package/dist/cdn/chunks/{extensions-Di3hdIRT.js.map → extensions-ZX2oarW6.js.map} +1 -1
  105. package/dist/cdn/chunks/formatRelativeTime-CtUU-QZ8.js +12 -0
  106. package/dist/cdn/chunks/formatRelativeTime-CtUU-QZ8.js.map +1 -0
  107. package/dist/cdn/chunks/htmlparser-CZa2V5cF.js +1008 -0
  108. package/dist/cdn/chunks/htmlparser-CZa2V5cF.js.map +1 -0
  109. package/dist/cdn/chunks/icons-CYWw8Xfp.js +1190 -0
  110. package/dist/cdn/chunks/icons-CYWw8Xfp.js.map +1 -0
  111. package/dist/cdn/chunks/keys-D7kUmfpE.js +12 -0
  112. package/dist/cdn/chunks/keys-D7kUmfpE.js.map +1 -0
  113. package/dist/cdn/chunks/{pt-BR-Bcc5Tjed.js → pt-BR-BWFokdTU.js} +50 -3
  114. package/dist/cdn/chunks/pt-BR-BWFokdTU.js.map +1 -0
  115. package/dist/{pt-BR-B2ZvFlRL.js → cdn/chunks/pt-BR-w2sGzHNX.js} +2 -24
  116. package/dist/cdn/chunks/{pt-BR-B2ZvFlRL.js.map → pt-BR-w2sGzHNX.js.map} +1 -1
  117. package/dist/cdn/chunks/src-BKI1x1k7.js +546 -0
  118. package/dist/cdn/chunks/src-BKI1x1k7.js.map +1 -0
  119. package/dist/cdn/chunks/src-CM0gCvAS.js +1176 -0
  120. package/dist/cdn/chunks/src-CM0gCvAS.js.map +1 -0
  121. package/dist/cdn/chunks/{media-library-yYAkAagU.js → src-D6F_3XkE.js} +1754 -1252
  122. package/dist/cdn/chunks/src-D6F_3XkE.js.map +1 -0
  123. package/dist/cdn/chunks/{renderer-DpBGiXOg.js → src-DYji-wXB.js} +117 -133
  124. package/dist/cdn/chunks/src-DYji-wXB.js.map +1 -0
  125. package/dist/cdn/chunks/{styles-DHSmjlpX.js → styles-DMOEiSX9.js} +1448 -1354
  126. package/dist/cdn/chunks/styles-DMOEiSX9.js.map +1 -0
  127. package/dist/cdn/chunks/timeouts-Bmi_yePw.js +6 -0
  128. package/dist/cdn/chunks/timeouts-Bmi_yePw.js.map +1 -0
  129. package/dist/cdn/chunks/{tiptap-C2indasq.js → tiptap-BMZ-OENR.js} +2012 -1863
  130. package/dist/cdn/chunks/tiptap-BMZ-OENR.js.map +1 -0
  131. package/dist/cdn/chunks/useAliveFlag-aanU8uqB.js +12 -0
  132. package/dist/cdn/chunks/useAliveFlag-aanU8uqB.js.map +1 -0
  133. package/dist/cdn/chunks/useCloudI18n-BjNENqkM.js +25 -0
  134. package/dist/cdn/chunks/useCloudI18n-BjNENqkM.js.map +1 -0
  135. package/dist/cdn/chunks/useEditorCore-BA6mspzD.js +3019 -0
  136. package/dist/cdn/chunks/useEditorCore-BA6mspzD.js.map +1 -0
  137. package/dist/cdn/chunks/useI18n-8Wd7G-cq.js +19 -0
  138. package/dist/cdn/chunks/useI18n-8Wd7G-cq.js.map +1 -0
  139. package/dist/cdn/chunks/useMergeTag-C7G31KV-.js +46 -0
  140. package/dist/cdn/chunks/useMergeTag-C7G31KV-.js.map +1 -0
  141. package/dist/cdn/chunks/usePopoverPosition-Bx0QewTv.js +61 -0
  142. package/dist/cdn/chunks/usePopoverPosition-Bx0QewTv.js.map +1 -0
  143. package/dist/cdn/editor.css +1 -1
  144. package/dist/cdn/editor.js +132 -120
  145. package/dist/cdn/editor.js.map +1 -1
  146. package/dist/{check-Bl4J_tYV.js → check-BpQDKiPz.js} +1 -1
  147. package/dist/{chevron-down-COEcl2iP.js → chevron-down-j8GrdTyz.js} +1 -1
  148. package/dist/chevron-up-BACyVhyC.js +7 -0
  149. package/dist/{circle-alert-CvHi5etc.js → circle-alert-CgtE46ND.js} +1 -1
  150. package/dist/{clock-CZZw62e8.js → clock-BzKLLW5L.js} +1 -1
  151. package/dist/{cloud-B-RebwxI.js → cloud-Du7mnkz2.js} +19 -47
  152. package/dist/{createLucideIcon-_peTZQtY.js → createLucideIcon-JWHwTI6N.js} +2 -2
  153. package/dist/{cdn/chunks/de-CTYXVU9v.js → de-Bw6fB5JU.js} +0 -26
  154. package/dist/{de-CgGOnerg.js → de-D7WbpFBR.js} +49 -2
  155. package/dist/{dist-CgTKuIUN.js → dist-BEpCh2mG.js} +1158 -1125
  156. package/dist/{dist-Cx7IUM7J.js → dist-BgPYC_8-.js} +14 -6
  157. package/dist/{dist-BKKo5wPC.js → dist-BkM8A17N.js} +2 -2
  158. package/dist/{dist-CcX5sLpz.js → dist-BuNDAAVp.js} +361 -256
  159. package/dist/{dist-COSN3oDJ.js → dist-CBzCU-a-.js} +2 -2
  160. package/dist/{dist-YSCPD13F.js → dist-CDO52Rxy.js} +2 -2
  161. package/dist/{dist-Dk5AdwoQ.js → dist-CrjzhIxB.js} +2 -2
  162. package/dist/{dist-DXAZUjj3.js → dist-CtcgoC_R.js} +2 -2
  163. package/dist/{dist-D6M5FAY7.js → dist-CuXha2_7.js} +2 -2
  164. package/dist/dist-CweLDZrs.js +5 -0
  165. package/dist/dist-DOsdqAEZ.js +5 -0
  166. package/dist/{dist-8TKf-Jpg.js → dist-DYClLqy8.js} +6 -3
  167. package/dist/{cdn/chunks/en-DrUV9xth.js → en-BrZ0uGK2.js} +49 -4
  168. package/dist/{cdn/chunks/en-BtmIaJeb.js → en-DAdHJz7h.js} +0 -26
  169. package/dist/{cdn/chunks/es-DwbKjU7q.js → es-tLSLysPs.js} +49 -4
  170. package/dist/{extensions-BCA9pyer.js → extensions-ClY5Sh7S.js} +5 -5
  171. package/dist/{image-up-D26rNdfX.js → image-up-CQdtq8ge.js} +1 -1
  172. package/dist/index.d.ts +81 -4
  173. package/dist/{info-CE3JSTqk.js → info-BUJBXoE6.js} +1 -1
  174. package/dist/{keys-DFaIbGR8.js → keys-CHPcp-Nz.js} +2 -2
  175. package/dist/{list-checks-BQsLrtBB.js → list-checks-BGHaCSD5.js} +1 -1
  176. package/dist/{loader-circle-s9Rh5lLd.js → loader-circle-C-Z6kgI6.js} +1 -1
  177. package/dist/{message-circle-CI62d690.js → message-circle-CEm5qckV.js} +1 -1
  178. package/dist/pencil-DdwmkKLb.js +10 -0
  179. package/dist/{pt-BR-Bcc5Tjed.js → pt-BR-BWFokdTU.js} +49 -2
  180. package/dist/{cdn/chunks/pt-BR-B2ZvFlRL.js → pt-BR-w2sGzHNX.js} +0 -26
  181. package/dist/{refresh-cw-DlYfl65Y.js → refresh-cw-maKlg0dl.js} +1 -1
  182. package/dist/{scan-line-CHadrYVb.js → scan-line-BFgesTOY.js} +1 -1
  183. package/dist/{send-CbP40otC.js → send-B70aQDrA.js} +1 -1
  184. package/dist/{shield-check-Bnj9aRoJ.js → shield-check-B7x5OKt5.js} +1 -1
  185. package/dist/{sparkles-CncWT57a.js → sparkles-DVlm1Ipp.js} +1 -1
  186. package/dist/style.css +1 -1
  187. package/dist/{styles-DkF_-uX8.js → styles-PcOPXvLO.js} +1235 -1151
  188. package/dist/templatical-editor.js +134 -125
  189. package/dist/{text-align-start-B458vzYw.js → text-align-start-Vay3Kvo2.js} +1 -1
  190. package/dist/{trash-2-DO0yjSU1.js → trash-2-DE8CmxAG.js} +1 -1
  191. package/dist/{triangle-alert-C18_ima6.js → triangle-alert-Djg6IG8N.js} +1 -1
  192. package/dist/{upload-DsCd2zTR.js → upload-BwwE0U6G.js} +1 -1
  193. package/dist/{useCloudI18n-PCDOC2kz.js → useCloudI18n-BmiygEM4.js} +1 -1
  194. package/dist/{useEditorCore-kKUemYY6.js → useEditorCore-CT1slufs.js} +997 -817
  195. package/dist/{useI18n-BNMzZTM5.js → useI18n-D2L9Mkik.js} +1 -1
  196. package/dist/{useMergeTag-DfEY0eK5.js → useMergeTag-BTdDq5DC.js} +1 -1
  197. package/dist/{usePopoverPosition-F9STHRIr.js → usePopoverPosition-BO2LNy5n.js} +1 -1
  198. package/dist/{x-BCFQuE_q.js → x-CkD6A1iB.js} +1 -1
  199. package/package.json +21 -21
  200. package/dist/CommentsSidebar-D-o5Stlg.js +0 -442
  201. package/dist/CountdownBlock-Bn5w7C-p.js +0 -92
  202. package/dist/ModuleBrowserModal-AJt--JPh.js +0 -202
  203. package/dist/ModulePreviewCanvas-BKYOcVCh.js +0 -106
  204. package/dist/NumberWithSuffix-Bf3rNxza.js +0 -89
  205. package/dist/SaveModuleDialog-B4QX9eiv.js +0 -125
  206. package/dist/ToggleSwitch-DUNuUPsZ.js +0 -37
  207. package/dist/cdn/chunks/CloudEditor-CEa3Xgqh.js.map +0 -1
  208. package/dist/cdn/chunks/CountdownBlock-eGUE7hhw.js +0 -93
  209. package/dist/cdn/chunks/ModuleBrowserModal-DznWWtBI.js +0 -198
  210. package/dist/cdn/chunks/ModuleBrowserModal-DznWWtBI.js.map +0 -1
  211. package/dist/cdn/chunks/ModulePreviewCanvas-D-h7fr87.js +0 -107
  212. package/dist/cdn/chunks/ModulePreviewCanvas-D-h7fr87.js.map +0 -1
  213. package/dist/cdn/chunks/NumberWithSuffix-Dt-0odUN.js +0 -91
  214. package/dist/cdn/chunks/NumberWithSuffix-Dt-0odUN.js.map +0 -1
  215. package/dist/cdn/chunks/SaveModuleDialog-BpFhTi-k.js +0 -120
  216. package/dist/cdn/chunks/SaveModuleDialog-BpFhTi-k.js.map +0 -1
  217. package/dist/cdn/chunks/ToggleSwitch-OrmX_w18.js +0 -39
  218. package/dist/cdn/chunks/ToggleSwitch-OrmX_w18.js.map +0 -1
  219. package/dist/cdn/chunks/blockTypeIcons-B0Hjh42a.js +0 -22
  220. package/dist/cdn/chunks/ca-DbWoy4rG.js.map +0 -1
  221. package/dist/cdn/chunks/de-CgGOnerg.js.map +0 -1
  222. package/dist/cdn/chunks/en-DrUV9xth.js.map +0 -1
  223. package/dist/cdn/chunks/es-DwbKjU7q.js.map +0 -1
  224. package/dist/cdn/chunks/features-CLIZ7Q-Y.js +0 -7657
  225. package/dist/cdn/chunks/features-CLIZ7Q-Y.js.map +0 -1
  226. package/dist/cdn/chunks/icons-GX40Qm2W.js +0 -690
  227. package/dist/cdn/chunks/icons-GX40Qm2W.js.map +0 -1
  228. package/dist/cdn/chunks/media-library-yYAkAagU.js.map +0 -1
  229. package/dist/cdn/chunks/pt-BR-Bcc5Tjed.js.map +0 -1
  230. package/dist/cdn/chunks/quality-DffYv9j5.js +0 -2180
  231. package/dist/cdn/chunks/quality-DffYv9j5.js.map +0 -1
  232. package/dist/cdn/chunks/renderer-DpBGiXOg.js.map +0 -1
  233. package/dist/cdn/chunks/src-9K6uFiuK.js +0 -509
  234. package/dist/cdn/chunks/src-9K6uFiuK.js.map +0 -1
  235. package/dist/cdn/chunks/styles-DHSmjlpX.js.map +0 -1
  236. package/dist/cdn/chunks/tiptap-C2indasq.js.map +0 -1
  237. package/dist/dist-BDVm2MrW.js +0 -5
  238. package/dist/dist-DbekZDmJ.js +0 -5
@@ -0,0 +1,1787 @@
1
+ import { r as e } from "./rolldown-runtime-Dqa2HsxW.js";
2
+ import { J as t, X as n, Y as r, Z as i, f as a, z as o } from "./draggable-D840DIZB.js";
3
+ import { j as s, t as c } from "./src-BKI1x1k7.js";
4
+ //#region ../core/src/cloud/auth.ts
5
+ var l = class e {
6
+ static DEFAULT_BASE_URL = "https://templatical.com";
7
+ accessToken = null;
8
+ expiresAt = null;
9
+ _projectId = null;
10
+ _tenantId = null;
11
+ _tenantSlug = null;
12
+ _testEmailConfig = null;
13
+ _userConfig = null;
14
+ url;
15
+ baseUrl;
16
+ requestOptions;
17
+ onError;
18
+ refreshPromise = null;
19
+ static REFRESH_THRESHOLD_MS = 60 * 1e3;
20
+ constructor(t) {
21
+ this.url = t.url, this.baseUrl = (t.baseUrl ?? e.DEFAULT_BASE_URL).replace(/\/$/, ""), this.requestOptions = t.requestOptions ?? {}, this.onError = t.onError;
22
+ }
23
+ resolveUrl(e) {
24
+ if (e.startsWith("http://") || e.startsWith("https://")) return e;
25
+ let t = e.startsWith("/") ? e : `/${e}`;
26
+ return `${this.baseUrl}${t}`;
27
+ }
28
+ get projectId() {
29
+ if (!this._projectId) throw Error("Project ID not available. Call initialize() first.");
30
+ return this._projectId;
31
+ }
32
+ get tenantId() {
33
+ if (!this._tenantId) throw Error("Tenant ID not available. Call initialize() first.");
34
+ return this._tenantId;
35
+ }
36
+ get tenantSlug() {
37
+ if (!this._tenantSlug) throw Error("Tenant slug not available. Call initialize() first.");
38
+ return this._tenantSlug;
39
+ }
40
+ get testEmailConfig() {
41
+ return this._testEmailConfig;
42
+ }
43
+ get userConfig() {
44
+ return this._userConfig;
45
+ }
46
+ get accessTokenValue() {
47
+ return this.accessToken;
48
+ }
49
+ async initialize() {
50
+ await this.ensureToken();
51
+ }
52
+ async ensureToken() {
53
+ return this.accessToken && !this.isTokenExpiringSoon() ? this.accessToken : this.refreshToken();
54
+ }
55
+ isTokenExpiringSoon() {
56
+ return !this.expiresAt || this.expiresAt.getTime() - Date.now() < e.REFRESH_THRESHOLD_MS;
57
+ }
58
+ async refreshToken() {
59
+ if (this.refreshPromise) return this.refreshPromise;
60
+ this.refreshPromise = this.performRefresh();
61
+ try {
62
+ return await this.refreshPromise;
63
+ } finally {
64
+ this.refreshPromise = null;
65
+ }
66
+ }
67
+ async performRefresh() {
68
+ try {
69
+ let e = this.requestOptions.method ?? "POST", t = {
70
+ Accept: "application/json",
71
+ ...this.requestOptions.headers
72
+ }, n = {
73
+ method: e,
74
+ headers: t,
75
+ credentials: this.requestOptions.credentials ?? "include"
76
+ };
77
+ e === "POST" && this.requestOptions.body && (t["Content-Type"] = "application/json", n.body = JSON.stringify(this.requestOptions.body));
78
+ let r = await fetch(this.url, n);
79
+ if (!r.ok) throw new c(`Token refresh failed: ${r.status}`, r.status);
80
+ let i = await r.json();
81
+ if (!i.token || !i.expires_at || !i.project_id || !i.tenant) throw Error("Invalid token response: missing token, expires_at, project_id, or tenant");
82
+ return this.accessToken = i.token, this.expiresAt = /* @__PURE__ */ new Date(i.expires_at * 1e3), this._projectId = i.project_id, this._tenantSlug = i.tenant, i.test_email?.allowed_emails && i.test_email?.signature ? this._testEmailConfig = {
83
+ allowedEmails: i.test_email.allowed_emails,
84
+ signature: i.test_email.signature
85
+ } : this._testEmailConfig = null, i.user?.id && i.user?.name && i.user?.signature ? this._userConfig = {
86
+ id: i.user.id,
87
+ name: i.user.name,
88
+ signature: i.user.signature
89
+ } : this._userConfig = null, this.accessToken;
90
+ } catch (e) {
91
+ let t = e instanceof Error ? e : Error("Token refresh failed", { cause: e });
92
+ throw this.onError?.(t), t;
93
+ }
94
+ }
95
+ async authenticatedFetch(e, t = {}) {
96
+ let n = await this.ensureToken(), r = this.resolveUrl(e), i = async (e) => fetch(r, {
97
+ ...t,
98
+ headers: {
99
+ ...t.headers,
100
+ Authorization: `Bearer ${e}`
101
+ }
102
+ }), a = await i(n);
103
+ return a.status === 401 && (a = await i(await this.refreshToken())), a;
104
+ }
105
+ };
106
+ function u(e, t) {
107
+ return e.mode === "direct" ? new l({
108
+ url: `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}/api/v1/auth/token`,
109
+ baseUrl: e.baseUrl,
110
+ requestOptions: {
111
+ method: "POST",
112
+ headers: { "Content-Type": "application/json" },
113
+ body: {
114
+ client_id: e.clientId,
115
+ client_secret: e.clientSecret,
116
+ tenant: e.tenant,
117
+ client_type: "sdk"
118
+ }
119
+ },
120
+ onError: t
121
+ }) : new l({
122
+ url: e.url,
123
+ baseUrl: e.baseUrl,
124
+ requestOptions: e.requestOptions,
125
+ onError: t
126
+ });
127
+ }
128
+ //#endregion
129
+ //#region ../core/src/cloud/url-builder.ts
130
+ function d(e, t) {
131
+ return e.replace(/\{(\w+)\}/g, (e, n) => encodeURIComponent(t[n] ?? ""));
132
+ }
133
+ var f = "/api/v1/projects/{project}/tenants/{tenant}", p = `${f}/templates/{template}`, m = `${p}/ai`, h = `${f}/media`, g = `${h}/folders`, _ = `${f}/saved-modules`, v = {
134
+ health: "/api/v1/health",
135
+ "projects.config": `${f}/config`,
136
+ "broadcasting.auth": `${f}/broadcasting/auth`,
137
+ "templates.store": `${f}/templates`,
138
+ "templates.show": `${p}`,
139
+ "templates.update": `${p}`,
140
+ "templates.destroy": `${p}`,
141
+ "templates.export": `${p}/export`,
142
+ "templates.importFromBeefree": `${f}/templates/import/from-beefree`,
143
+ "templates.sendTestEmail": `${p}/send-test-email`,
144
+ "snapshots.index": `${p}/snapshots`,
145
+ "snapshots.store": `${p}/snapshots`,
146
+ "snapshots.show": `${p}/snapshots/{snapshot}`,
147
+ "snapshots.restore": `${p}/snapshots/{snapshot}/restore`,
148
+ "comments.index": `${p}/comments`,
149
+ "comments.store": `${p}/comments`,
150
+ "comments.update": `${p}/comments/{comment}`,
151
+ "comments.destroy": `${p}/comments/{comment}`,
152
+ "comments.resolve": `${p}/comments/{comment}/resolve`,
153
+ "ai.generate": `${m}/generate`,
154
+ "ai.conversationMessages": `${m}/conversation-messages`,
155
+ "ai.suggestions": `${m}/suggestions`,
156
+ "ai.rewriteText": `${m}/rewrite-text`,
157
+ "ai.score": `${m}/score`,
158
+ "ai.fixFinding": `${m}/fix-finding`,
159
+ "ai.generateFromDesign": `${m}/generate-from-design`,
160
+ "media.upload": `${h}/upload`,
161
+ "media.browse": `${h}/browse`,
162
+ "media.delete": `${h}/delete`,
163
+ "media.move": `${h}/move`,
164
+ "media.update": `${h}/{media}`,
165
+ "media.replace": `${h}/{media}/replace`,
166
+ "media.checkUsage": `${h}/check-usage`,
167
+ "media.frequentlyUsed": `${h}/frequently-used`,
168
+ "media.importFromUrl": `${h}/import-from-url`,
169
+ "folders.index": `${g}`,
170
+ "folders.store": `${g}`,
171
+ "folders.update": `${g}/{mediaFolder}`,
172
+ "folders.destroy": `${g}/{mediaFolder}`,
173
+ "savedModules.index": `${_}`,
174
+ "savedModules.store": `${_}`,
175
+ "savedModules.update": `${_}/{savedModule}`,
176
+ "savedModules.destroy": `${_}/{savedModule}`
177
+ }, y = class {
178
+ authManager;
179
+ constructor(e) {
180
+ this.authManager = e;
181
+ }
182
+ get projectId() {
183
+ return this.authManager.projectId;
184
+ }
185
+ get tenantSlug() {
186
+ return this.authManager.tenantSlug;
187
+ }
188
+ get baseParams() {
189
+ return {
190
+ project: this.projectId,
191
+ tenant: this.tenantSlug
192
+ };
193
+ }
194
+ async request(e, t = {}) {
195
+ let n = await this.authManager.authenticatedFetch(e, {
196
+ ...t,
197
+ headers: {
198
+ "Content-Type": "application/json",
199
+ Accept: "application/json",
200
+ ...t.headers
201
+ }
202
+ });
203
+ if (!n.ok) {
204
+ let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` }));
205
+ throw new c(this.extractFirstValidationError(e), n.status);
206
+ }
207
+ if (n.status !== 204) return (await n.json()).data;
208
+ }
209
+ extractFirstValidationError(e) {
210
+ if (e.errors) {
211
+ let t = Object.keys(e.errors)[0];
212
+ if (t && e.errors[t]?.length > 0) return e.errors[t][0];
213
+ }
214
+ return e.message;
215
+ }
216
+ async createTemplate(e) {
217
+ return this.request(d(v["templates.store"], this.baseParams), {
218
+ method: "POST",
219
+ body: JSON.stringify({ content: e })
220
+ });
221
+ }
222
+ async getTemplate(e) {
223
+ return this.request(d(v["templates.show"], {
224
+ ...this.baseParams,
225
+ template: e
226
+ }));
227
+ }
228
+ async updateTemplate(e, t) {
229
+ return this.request(d(v["templates.update"], {
230
+ ...this.baseParams,
231
+ template: e
232
+ }), {
233
+ method: "PUT",
234
+ body: JSON.stringify({ content: t })
235
+ });
236
+ }
237
+ async createSnapshot(e, t) {
238
+ return this.request(d(v["snapshots.store"], {
239
+ ...this.baseParams,
240
+ template: e
241
+ }), {
242
+ method: "POST",
243
+ body: JSON.stringify({ content: t })
244
+ });
245
+ }
246
+ async deleteTemplate(e) {
247
+ return this.request(d(v["templates.destroy"], {
248
+ ...this.baseParams,
249
+ template: e
250
+ }), { method: "DELETE" });
251
+ }
252
+ async getSnapshots(e) {
253
+ return this.request(d(v["snapshots.index"], {
254
+ ...this.baseParams,
255
+ template: e
256
+ }));
257
+ }
258
+ async restoreSnapshot(e, t) {
259
+ return this.request(d(v["snapshots.restore"], {
260
+ ...this.baseParams,
261
+ template: e,
262
+ snapshot: t
263
+ }), { method: "POST" });
264
+ }
265
+ async exportTemplate(e, t) {
266
+ let n = t ? JSON.stringify({
267
+ custom_fonts: t.customFonts,
268
+ default_fallback: t.defaultFallback
269
+ }) : void 0;
270
+ return this.request(d(v["templates.export"], {
271
+ ...this.baseParams,
272
+ template: e
273
+ }), {
274
+ method: "POST",
275
+ body: n
276
+ });
277
+ }
278
+ async sendTestEmail(e, t) {
279
+ await this.request(d(v["templates.sendTestEmail"], {
280
+ ...this.baseParams,
281
+ template: e
282
+ }), {
283
+ method: "POST",
284
+ body: JSON.stringify(t)
285
+ });
286
+ }
287
+ commentsUrl(e, t) {
288
+ return t ? d(v["comments.update"], {
289
+ ...this.baseParams,
290
+ template: e,
291
+ comment: t
292
+ }) : d(v["comments.index"], {
293
+ ...this.baseParams,
294
+ template: e
295
+ });
296
+ }
297
+ async getComments(e) {
298
+ return this.request(this.commentsUrl(e));
299
+ }
300
+ async createComment(e, t, n) {
301
+ return this.request(this.commentsUrl(e), {
302
+ method: "POST",
303
+ body: JSON.stringify(t),
304
+ headers: n
305
+ });
306
+ }
307
+ async updateComment(e, t, n, r) {
308
+ return this.request(this.commentsUrl(e, t), {
309
+ method: "PUT",
310
+ body: JSON.stringify(n),
311
+ headers: r
312
+ });
313
+ }
314
+ async deleteComment(e, t, n, r) {
315
+ return this.request(this.commentsUrl(e, t), {
316
+ method: "DELETE",
317
+ body: JSON.stringify(n),
318
+ headers: r
319
+ });
320
+ }
321
+ async resolveComment(e, t, n, r) {
322
+ return this.request(d(v["comments.resolve"], {
323
+ ...this.baseParams,
324
+ template: e,
325
+ comment: t
326
+ }), {
327
+ method: "POST",
328
+ body: JSON.stringify(n),
329
+ headers: r
330
+ });
331
+ }
332
+ async fetchConfig() {
333
+ return this.request(d(v["projects.config"], this.baseParams));
334
+ }
335
+ async listModules(e, t) {
336
+ let n = d(v["savedModules.index"], this.baseParams), r = new URLSearchParams();
337
+ e && r.set("search", e), t && r.set("category", t);
338
+ let i = r.size > 0 ? `?${r}` : "";
339
+ return this.request(`${n}${i}`);
340
+ }
341
+ async createModule(e) {
342
+ return this.request(d(v["savedModules.store"], this.baseParams), {
343
+ method: "POST",
344
+ body: JSON.stringify(e)
345
+ });
346
+ }
347
+ async updateModule(e, t) {
348
+ return this.request(d(v["savedModules.update"], {
349
+ ...this.baseParams,
350
+ savedModule: e
351
+ }), {
352
+ method: "PUT",
353
+ body: JSON.stringify(t)
354
+ });
355
+ }
356
+ async deleteModule(e) {
357
+ return this.request(d(v["savedModules.destroy"], {
358
+ ...this.baseParams,
359
+ savedModule: e
360
+ }), { method: "DELETE" });
361
+ }
362
+ };
363
+ //#endregion
364
+ //#region ../core/src/cloud/websocket-client.ts
365
+ function b(e) {
366
+ return {
367
+ host: e.host,
368
+ port: e.port,
369
+ appKey: e.app_key
370
+ };
371
+ }
372
+ var x = class {
373
+ pusher = null;
374
+ authManager;
375
+ config;
376
+ onError;
377
+ constructor(e) {
378
+ this.authManager = e.authManager, this.config = e.config, this.onError = e.onError;
379
+ }
380
+ async connect() {
381
+ if (this.pusher) return;
382
+ let t;
383
+ try {
384
+ ({default: t} = await import("./pusher-R0v5p99W.js").then((t) => /* @__PURE__ */ e(t.t(), 1)));
385
+ } catch {
386
+ throw Error("Cloud features require the optional peer dependency 'pusher-js'. Install it with: npm install pusher-js");
387
+ }
388
+ let { host: n, port: r, appKey: i } = this.config, a = this.authManager.resolveUrl(d(v["broadcasting.auth"], {
389
+ project: this.authManager.projectId,
390
+ tenant: this.authManager.tenantSlug
391
+ }));
392
+ this.pusher = new t(i, {
393
+ wsHost: n,
394
+ wsPort: r,
395
+ wssPort: r,
396
+ forceTLS: !0,
397
+ disableStats: !0,
398
+ enabledTransports: ["ws", "wss"],
399
+ cluster: "",
400
+ channelAuthorization: {
401
+ transport: "ajax",
402
+ endpoint: a,
403
+ headers: {
404
+ Authorization: `Bearer ${this.authManager.accessTokenValue}`,
405
+ Accept: "application/json"
406
+ },
407
+ params: {
408
+ user_id: this.authManager.userConfig?.id ?? "",
409
+ user_name: this.authManager.userConfig?.name ?? "",
410
+ user_signature: this.authManager.userConfig?.signature ?? ""
411
+ }
412
+ }
413
+ }), this.pusher.connection.bind("error", (e) => {
414
+ this.onError?.(e instanceof Error ? e : /* @__PURE__ */ Error("WebSocket connection error"));
415
+ });
416
+ }
417
+ subscribePresence(e) {
418
+ if (!this.pusher) throw Error("WebSocketClient not connected. Call connect() first.");
419
+ return this.pusher.subscribe(e);
420
+ }
421
+ unsubscribe(e) {
422
+ this.pusher?.unsubscribe(e);
423
+ }
424
+ getChannel(e) {
425
+ return this.pusher?.channel(e);
426
+ }
427
+ disconnect() {
428
+ this.pusher &&= (this.pusher.disconnect(), null);
429
+ }
430
+ getSocketId() {
431
+ return this.pusher?.connection.socket_id ?? null;
432
+ }
433
+ get isConnected() {
434
+ return this.pusher?.connection.state === "connected";
435
+ }
436
+ };
437
+ //#endregion
438
+ //#region ../core/src/cloud/mcp-operation-handler.ts
439
+ function S(e, t) {
440
+ let { operation: n, data: r } = t;
441
+ switch (n) {
442
+ case "add_block":
443
+ e.addBlock(r.block, r.section_id, r.column_index, r.index);
444
+ break;
445
+ case "update_block":
446
+ e.updateBlock(r.block_id, r.updates);
447
+ break;
448
+ case "delete_block":
449
+ e.removeBlock(r.block_id);
450
+ break;
451
+ case "move_block":
452
+ e.moveBlock(r.block_id, r.index, r.section_id, r.column_index);
453
+ break;
454
+ case "update_settings":
455
+ e.updateSettings(r.updates);
456
+ break;
457
+ case "set_content":
458
+ e.setContent(r.content);
459
+ break;
460
+ case "update_block_style":
461
+ e.updateBlock(r.block_id, { styles: r.styles });
462
+ break;
463
+ }
464
+ }
465
+ //#endregion
466
+ //#region ../core/src/cloud/editor.ts
467
+ function C(e) {
468
+ return e === "1" ? 1 : e === "3" ? 3 : 2;
469
+ }
470
+ function w(e) {
471
+ let t = new y(e.authManager), i = r({
472
+ template: null,
473
+ content: s(e.defaultFontFamily, e.templateDefaults),
474
+ selectedBlockId: null,
475
+ viewport: "desktop",
476
+ darkMode: !1,
477
+ previewMode: !1,
478
+ isDirty: !1,
479
+ isSaving: !1,
480
+ isLoading: !1,
481
+ uiTheme: "auto"
482
+ }), o = a({
483
+ get: () => i.content,
484
+ set: (e) => {
485
+ i.content = e, i.isDirty = !0;
486
+ }
487
+ }), l = a(() => i.selectedBlockId ? d(i.content.blocks, i.selectedBlockId) : null), u = a(() => {
488
+ let e = /* @__PURE__ */ new Set(), t = i.template?.content?.blocks;
489
+ if (!t) return e;
490
+ for (let n of t) if (e.add(n.id), n.type === "section") for (let t of n.children) for (let n of t) e.add(n.id);
491
+ return e;
492
+ });
493
+ function d(e, t) {
494
+ for (let n of e) {
495
+ if (n.id === t) return n;
496
+ if (n.type === "section") for (let e of n.children) {
497
+ let n = d(e, t);
498
+ if (n) return n;
499
+ }
500
+ }
501
+ return null;
502
+ }
503
+ function f(e, t, n = { blocks: e }) {
504
+ for (let r = 0; r < e.length; r++) {
505
+ let i = e[r];
506
+ if (i.id === t) return n;
507
+ if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
508
+ let n = f(i.children[e], t, {
509
+ blocks: i.children[e],
510
+ sectionId: i.id,
511
+ columnIndex: e
512
+ });
513
+ if (n) return n;
514
+ }
515
+ }
516
+ return null;
517
+ }
518
+ function p(t) {
519
+ return e.lockedBlocks?.value.has(t) ?? !1;
520
+ }
521
+ function m(e, t = !0) {
522
+ i.content = e, t && (i.isDirty = !0);
523
+ }
524
+ function h(e) {
525
+ e && p(e) || (i.selectedBlockId = e);
526
+ }
527
+ function g(e) {
528
+ i.viewport = e;
529
+ }
530
+ function _(e) {
531
+ i.darkMode = e;
532
+ }
533
+ function v(e) {
534
+ i.uiTheme = e;
535
+ }
536
+ function b(e) {
537
+ i.previewMode = e, e && (i.selectedBlockId = null);
538
+ }
539
+ function x(e, t) {
540
+ if (p(e)) return;
541
+ let n = d(i.content.blocks, e);
542
+ n && (Object.assign(n, t), i.isDirty = !0);
543
+ }
544
+ function S(e) {
545
+ i.content.settings = {
546
+ ...i.content.settings,
547
+ ...e
548
+ }, i.isDirty = !0;
549
+ }
550
+ function w(e, t, n = 0, r) {
551
+ if (t) {
552
+ let a = d(i.content.blocks, t);
553
+ if (a && a.type === "section") {
554
+ a.children[n] = a.children[n] || [];
555
+ let t = a.children[n];
556
+ r !== void 0 && r < t.length ? t.splice(r, 0, e) : t.push(e);
557
+ }
558
+ } else r !== void 0 && r < i.content.blocks.length ? i.content.blocks.splice(r, 0, e) : i.content.blocks.push(e);
559
+ i.isDirty = !0;
560
+ }
561
+ function T(e) {
562
+ if (p(e)) return;
563
+ let t = f(i.content.blocks, e);
564
+ if (t) {
565
+ let n = t.blocks.findIndex((t) => t.id === e);
566
+ n !== -1 && (t.blocks.splice(n, 1), i.selectedBlockId === e && (i.selectedBlockId = null), i.isDirty = !0);
567
+ }
568
+ }
569
+ function E(e, t, n, r = 0) {
570
+ let a = f(i.content.blocks, e);
571
+ if (!a) return;
572
+ let o = a.blocks.findIndex((t) => t.id === e);
573
+ if (o === -1) return;
574
+ let s;
575
+ if (n) {
576
+ let e = d(i.content.blocks, n);
577
+ if (!e || e.type !== "section" || r < 0 || r >= C(e.columns)) return;
578
+ e.children[r] = e.children[r] || [], s = e.children[r];
579
+ } else s = i.content.blocks;
580
+ let [c] = a.blocks.splice(o, 1);
581
+ s.splice(t, 0, c), i.isDirty = !0;
582
+ }
583
+ async function D(n) {
584
+ i.isLoading = !0;
585
+ try {
586
+ n && (i.content = n);
587
+ let e = await t.createTemplate(i.content);
588
+ return i.template = e, i.isDirty = !1, e;
589
+ } catch (t) {
590
+ throw e.onError?.(t), t;
591
+ } finally {
592
+ i.isLoading = !1;
593
+ }
594
+ }
595
+ async function O(n) {
596
+ i.isLoading = !0;
597
+ try {
598
+ let e = await t.getTemplate(n);
599
+ return i.template = e, i.content = e.content, i.isDirty = !1, e;
600
+ } catch (t) {
601
+ throw e.onError?.(t), t;
602
+ } finally {
603
+ i.isLoading = !1;
604
+ }
605
+ }
606
+ async function k() {
607
+ if (!i.template?.id) throw new c("No template loaded. Call create() or load() before saving.");
608
+ i.isSaving = !0;
609
+ try {
610
+ let e = await t.updateTemplate(i.template.id, i.content);
611
+ return i.template = e, i.isDirty = !1, e;
612
+ } catch (t) {
613
+ throw e.onError?.(t), t;
614
+ } finally {
615
+ i.isSaving = !1;
616
+ }
617
+ }
618
+ async function A() {
619
+ if (i.template?.id) try {
620
+ await t.createSnapshot(i.template.id, i.content);
621
+ } catch (t) {
622
+ throw e.onError?.(t), t;
623
+ }
624
+ }
625
+ function j() {
626
+ return i.template?.id !== void 0;
627
+ }
628
+ function M() {
629
+ i.isDirty = !0;
630
+ }
631
+ function N(e) {
632
+ let t = f(i.content.blocks, e);
633
+ if (!t) return null;
634
+ let n = t.blocks.findIndex((t) => t.id === e);
635
+ return n === -1 ? null : {
636
+ targetSectionId: t.sectionId,
637
+ columnIndex: t.columnIndex,
638
+ index: n
639
+ };
640
+ }
641
+ return {
642
+ state: n(i),
643
+ content: o,
644
+ selectedBlock: l,
645
+ savedBlockIds: u,
646
+ isBlockLocked: p,
647
+ findBlockLocation: N,
648
+ setContent: m,
649
+ selectBlock: h,
650
+ setViewport: g,
651
+ setDarkMode: _,
652
+ setUiTheme: v,
653
+ setPreviewMode: b,
654
+ updateBlock: x,
655
+ updateSettings: S,
656
+ addBlock: w,
657
+ removeBlock: T,
658
+ moveBlock: E,
659
+ create: D,
660
+ load: O,
661
+ save: k,
662
+ createSnapshot: A,
663
+ hasTemplate: j,
664
+ markDirty: M
665
+ };
666
+ }
667
+ //#endregion
668
+ //#region ../core/src/cloud/ai-chat.ts
669
+ var T = 0;
670
+ function E() {
671
+ return `msg_${Date.now()}_${++T}`;
672
+ }
673
+ function D(e) {
674
+ let { authManager: t, getTemplateId: n, onApply: r, onError: a } = e, o = i([]), s = i(!1), c = i(!1), l = i(null), u = i(null), f = i(null), p = i(null), m = i(null), h = i(null), g = i(!1), _ = i([]), y = i(!1);
675
+ function b(e, t) {
676
+ let n = o.value.findIndex((t) => t.id === e);
677
+ if (n === -1) return;
678
+ let r = {
679
+ ...o.value[n],
680
+ ...t
681
+ };
682
+ o.value = [
683
+ ...o.value.slice(0, n),
684
+ r,
685
+ ...o.value.slice(n + 1)
686
+ ];
687
+ }
688
+ async function x() {
689
+ let e = n();
690
+ if (e) {
691
+ c.value = !0;
692
+ try {
693
+ let n = d(v["ai.conversationMessages"], {
694
+ project: t.projectId,
695
+ tenant: t.tenantSlug,
696
+ template: e
697
+ }), r = await t.authenticatedFetch(n, {
698
+ method: "GET",
699
+ headers: { Accept: "application/json" }
700
+ });
701
+ if (!r.ok) return;
702
+ let i = await r.json();
703
+ i.conversation_id && (f.value = i.conversation_id), Array.isArray(i.data) && i.data.length > 0 && (o.value = i.data.map((e) => ({
704
+ id: e.id,
705
+ role: e.role,
706
+ content: e.content,
707
+ timestamp: new Date(e.created_at).getTime()
708
+ })));
709
+ } catch {} finally {
710
+ c.value = !1;
711
+ }
712
+ }
713
+ }
714
+ async function S(e, r) {
715
+ let i = n();
716
+ if (i) {
717
+ y.value = !0;
718
+ try {
719
+ let n = d(v["ai.suggestions"], {
720
+ project: t.projectId,
721
+ tenant: t.tenantSlug,
722
+ template: i
723
+ }), a = await t.authenticatedFetch(n, {
724
+ method: "POST",
725
+ headers: {
726
+ "Content-Type": "application/json",
727
+ Accept: "text/event-stream"
728
+ },
729
+ body: JSON.stringify({
730
+ current_content: e,
731
+ merge_tags: r.map((e) => ({
732
+ label: e.label,
733
+ value: e.value
734
+ }))
735
+ })
736
+ });
737
+ if (!a.ok) return;
738
+ let o = a.body?.getReader();
739
+ if (!o) return;
740
+ let s = new TextDecoder(), c = "";
741
+ for (;;) {
742
+ let { done: e, value: t } = await o.read();
743
+ if (e) break;
744
+ c += s.decode(t, { stream: !0 });
745
+ let n = c.split("\n");
746
+ c = n.pop() ?? "";
747
+ for (let e of n) {
748
+ if (!e.startsWith("data: ")) continue;
749
+ let t;
750
+ try {
751
+ t = JSON.parse(e.slice(6));
752
+ } catch {
753
+ continue;
754
+ }
755
+ t.type === "done" && Array.isArray(t.suggestions) && (_.value = t.suggestions.slice(0, 3));
756
+ }
757
+ }
758
+ } catch {} finally {
759
+ y.value = !1;
760
+ }
761
+ }
762
+ }
763
+ async function C(e, i, c) {
764
+ let y = n();
765
+ if (!y) throw Error("Template must be saved before using AI generation");
766
+ s.value = !0, l.value = null, u.value = null, _.value = [];
767
+ let x = E();
768
+ o.value = [...o.value, {
769
+ id: x,
770
+ role: "user",
771
+ content: e,
772
+ timestamp: Date.now()
773
+ }];
774
+ let S = E();
775
+ o.value = [...o.value, {
776
+ id: S,
777
+ role: "assistant",
778
+ content: "",
779
+ timestamp: Date.now()
780
+ }];
781
+ try {
782
+ let n = d(v["ai.generate"], {
783
+ project: t.projectId,
784
+ tenant: t.tenantSlug,
785
+ template: y
786
+ }), a = await t.authenticatedFetch(n, {
787
+ method: "POST",
788
+ headers: {
789
+ "Content-Type": "application/json",
790
+ Accept: "text/event-stream"
791
+ },
792
+ body: JSON.stringify({
793
+ prompt: e,
794
+ current_content: i,
795
+ merge_tags: c.map((e) => ({
796
+ label: e.label,
797
+ value: e.value
798
+ })),
799
+ conversation_id: f.value
800
+ })
801
+ });
802
+ if (!a.ok) {
803
+ let e = await a.json().catch(() => null);
804
+ throw Error(a.status === 403 ? "ai_generation_not_available" : e?.message || "Failed to generate template");
805
+ }
806
+ let s = a.body?.getReader();
807
+ if (!s) throw Error("Failed to read stream");
808
+ let u = new TextDecoder(), _ = "", x = null;
809
+ try {
810
+ for (;;) {
811
+ let { done: e, value: t } = await s.read();
812
+ if (e) break;
813
+ _ += u.decode(t, { stream: !0 });
814
+ let n = _.split("\n");
815
+ _ = n.pop() ?? "";
816
+ for (let e of n) {
817
+ if (!e.startsWith("data: ")) continue;
818
+ let t = e.slice(6), n;
819
+ try {
820
+ n = JSON.parse(t);
821
+ } catch {
822
+ continue;
823
+ }
824
+ if (n.type === "text") b(S, { content: (o.value.find((e) => e.id === S)?.content ?? "") + n.text });
825
+ else if (n.type === "error") throw Error(n.message || "Failed to generate template");
826
+ else n.type === "done" && (n.conversation_id && (f.value = n.conversation_id), b(S, { content: n.text }), x = n.content ?? null, x ? (m.value = i, h.value = x, p.value = S, g.value = !1, r?.(x)) : l.value = "ai_apply_failed");
827
+ }
828
+ }
829
+ } finally {
830
+ s.cancel().catch(() => {});
831
+ }
832
+ return x;
833
+ } catch (t) {
834
+ let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
835
+ return l.value = n.message, u.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== x && e.id !== S), null;
836
+ } finally {
837
+ s.value = !1;
838
+ }
839
+ }
840
+ function w() {
841
+ g.value ? (h.value && r?.(h.value), g.value = !1) : (m.value && r?.(m.value), g.value = !0);
842
+ }
843
+ function T() {
844
+ o.value = [], f.value = null, l.value = null, p.value = null, m.value = null, h.value = null, g.value = !1;
845
+ }
846
+ return {
847
+ messages: o,
848
+ isGenerating: s,
849
+ isLoadingHistory: c,
850
+ isLastChangeReverted: g,
851
+ lastApplyMessageId: p,
852
+ error: l,
853
+ failedPrompt: u,
854
+ suggestions: _,
855
+ isLoadingSuggestions: y,
856
+ sendPrompt: C,
857
+ toggleLastRevert: w,
858
+ loadConversation: x,
859
+ loadSuggestions: S,
860
+ clearChat: T
861
+ };
862
+ }
863
+ //#endregion
864
+ //#region ../core/src/cloud/ai-config.ts
865
+ function O(e) {
866
+ function t(t) {
867
+ return e !== !1 && e?.[t] !== !1;
868
+ }
869
+ return {
870
+ isFeatureEnabled: t,
871
+ hasAnyMenuFeature: a(() => t("chat") || t("scoring") || t("designToTemplate"))
872
+ };
873
+ }
874
+ //#endregion
875
+ //#region ../core/src/cloud/template-scoring.ts
876
+ function k(e) {
877
+ let { authManager: t, getTemplateId: n } = e, r = i(!1), a = i(null), o = i(null), s = i(null), c = i(""), l = i(null);
878
+ async function u(e, i) {
879
+ let s = n();
880
+ if (!s) return null;
881
+ r.value = !0, o.value = null, a.value = null;
882
+ try {
883
+ let n = d(v["ai.score"], {
884
+ project: t.projectId,
885
+ tenant: t.tenantSlug,
886
+ template: s
887
+ }), r = await t.authenticatedFetch(n, {
888
+ method: "POST",
889
+ headers: {
890
+ "Content-Type": "application/json",
891
+ Accept: "text/event-stream"
892
+ },
893
+ body: JSON.stringify({
894
+ current_content: e,
895
+ merge_tags: i.map((e) => ({
896
+ label: e.label,
897
+ value: e.value
898
+ }))
899
+ })
900
+ });
901
+ if (!r.ok) {
902
+ if (r.status === 403) throw Error("ai_generation_not_available");
903
+ let e = await r.json().catch(() => null);
904
+ throw Error(e?.message || "Failed to score template");
905
+ }
906
+ let o = r.body?.getReader();
907
+ if (!o) throw Error("Failed to read stream");
908
+ let c = new TextDecoder(), l = "", u = null;
909
+ for (;;) {
910
+ let { done: e, value: t } = await o.read();
911
+ if (e) break;
912
+ l += c.decode(t, { stream: !0 });
913
+ let n = l.split("\n");
914
+ l = n.pop() ?? "";
915
+ for (let e of n) {
916
+ if (!e.startsWith("data: ")) continue;
917
+ let t;
918
+ try {
919
+ t = JSON.parse(e.slice(6));
920
+ } catch {
921
+ continue;
922
+ }
923
+ if (t.type === "error") throw Error(t.message || "Failed to score template");
924
+ t.type === "done" && (u = t.result ?? null);
925
+ }
926
+ }
927
+ if (u) for (let [e, t] of Object.entries(u.categories)) for (let n of t.findings) n.category = e;
928
+ return a.value = u, u;
929
+ } catch (e) {
930
+ return o.value = e instanceof Error ? e.message : "Failed to score template", null;
931
+ } finally {
932
+ r.value = !1;
933
+ }
934
+ }
935
+ async function f(e, r, i) {
936
+ let a = n();
937
+ if (!a) return null;
938
+ s.value = r.id, c.value = "", l.value = null;
939
+ try {
940
+ let n = d(v["ai.fixFinding"], {
941
+ project: t.projectId,
942
+ tenant: t.tenantSlug,
943
+ template: a
944
+ }), o = await t.authenticatedFetch(n, {
945
+ method: "POST",
946
+ headers: {
947
+ "Content-Type": "application/json",
948
+ Accept: "text/event-stream"
949
+ },
950
+ body: JSON.stringify({
951
+ content: e,
952
+ finding: {
953
+ id: r.id,
954
+ message: r.message,
955
+ suggestion: r.suggestion,
956
+ category: r.category
957
+ },
958
+ merge_tags: i.map((e) => ({
959
+ label: e.label,
960
+ value: e.value
961
+ }))
962
+ })
963
+ });
964
+ if (!o.ok) {
965
+ if (o.status === 403) throw Error("ai_generation_not_available");
966
+ let e = await o.json().catch(() => null);
967
+ throw Error(e?.message || "Failed to fix finding");
968
+ }
969
+ let s = o.body?.getReader();
970
+ if (!s) throw Error("Failed to read stream");
971
+ let l = new TextDecoder(), u = "", f = null;
972
+ for (;;) {
973
+ let { done: e, value: t } = await s.read();
974
+ if (e) break;
975
+ u += l.decode(t, { stream: !0 });
976
+ let n = u.split("\n");
977
+ u = n.pop() ?? "";
978
+ for (let e of n) {
979
+ if (!e.startsWith("data: ")) continue;
980
+ let t;
981
+ try {
982
+ t = JSON.parse(e.slice(6));
983
+ } catch {
984
+ continue;
985
+ }
986
+ if (t.type === "text") c.value += t.text;
987
+ else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
988
+ else t.type === "done" && (f = t.content ?? null);
989
+ }
990
+ }
991
+ return f;
992
+ } catch (e) {
993
+ return l.value = e instanceof Error ? e.message : "Failed to fix finding", null;
994
+ } finally {
995
+ s.value = null;
996
+ }
997
+ }
998
+ function p(e, t) {
999
+ if (!a.value) return;
1000
+ let n = a.value.categories[e];
1001
+ n && (n.findings = n.findings.filter((e) => e.id !== t));
1002
+ }
1003
+ function m() {
1004
+ r.value = !1, a.value = null, o.value = null, s.value = null, c.value = "", l.value = null;
1005
+ }
1006
+ return {
1007
+ isScoring: r,
1008
+ scoringResult: a,
1009
+ error: o,
1010
+ fixingFindingId: s,
1011
+ fixStreamingText: c,
1012
+ fixError: l,
1013
+ score: u,
1014
+ fixFinding: f,
1015
+ removeFinding: p,
1016
+ reset: m
1017
+ };
1018
+ }
1019
+ //#endregion
1020
+ //#region ../core/src/cloud/design-reference.ts
1021
+ function A(e) {
1022
+ let { authManager: t, getTemplateId: n, onApply: r, onError: a } = e, o = i(!1), s = i(null);
1023
+ async function c(e) {
1024
+ let i = n();
1025
+ if (!i) throw Error("Template must be saved before using design reference");
1026
+ o.value = !0, s.value = null;
1027
+ try {
1028
+ let n = new FormData();
1029
+ e.prompt && n.append("prompt", e.prompt), e.imageUpload && n.append("image_upload", e.imageUpload), e.pdfUpload && n.append("pdf_upload", e.pdfUpload);
1030
+ let a = d(v["ai.generateFromDesign"], {
1031
+ project: t.projectId,
1032
+ tenant: t.tenantSlug,
1033
+ template: i
1034
+ }), o = await t.authenticatedFetch(a, {
1035
+ method: "POST",
1036
+ headers: { Accept: "text/event-stream" },
1037
+ body: n
1038
+ });
1039
+ if (!o.ok) {
1040
+ let e = await o.json().catch(() => null);
1041
+ throw Error(o.status === 403 ? "ai_generation_not_available" : e?.message || "Failed to generate template from design");
1042
+ }
1043
+ let s = o.body?.getReader();
1044
+ if (!s) throw Error("Failed to read stream");
1045
+ let c = new TextDecoder(), l = "", u = null;
1046
+ for (;;) {
1047
+ let { done: e, value: t } = await s.read();
1048
+ if (e) break;
1049
+ l += c.decode(t, { stream: !0 });
1050
+ let n = l.split("\n");
1051
+ l = n.pop() ?? "";
1052
+ for (let e of n) {
1053
+ if (!e.startsWith("data: ")) continue;
1054
+ let t = e.slice(6), n;
1055
+ try {
1056
+ n = JSON.parse(t);
1057
+ } catch {
1058
+ continue;
1059
+ }
1060
+ if (n.type === "error") throw Error(n.message || "Failed to generate template from design");
1061
+ n.type === "done" && (u = n.content ?? null, u && r?.(u));
1062
+ }
1063
+ }
1064
+ return u;
1065
+ } catch (e) {
1066
+ let t = e instanceof Error ? e : Error("Failed to generate template from design", { cause: e });
1067
+ return s.value = t.message, a?.(t), null;
1068
+ } finally {
1069
+ o.value = !1;
1070
+ }
1071
+ }
1072
+ function l() {
1073
+ o.value = !1, s.value = null;
1074
+ }
1075
+ return {
1076
+ isGenerating: o,
1077
+ error: s,
1078
+ generate: c,
1079
+ reset: l
1080
+ };
1081
+ }
1082
+ //#endregion
1083
+ //#region ../core/src/cloud/comments.ts
1084
+ function j(e) {
1085
+ let { authManager: t, getTemplateId: n, getSocketId: r, onComment: o, onError: s, hasCommentingFeature: c } = e, l = new y(t), u = i([]), d = i(!1), f = i(!1), p = a(() => (c?.() ?? !1) && t.userConfig !== null), m = a(() => {
1086
+ let e = 0;
1087
+ for (let t of u.value) e += 1 + (t.replies?.length ?? 0);
1088
+ return e;
1089
+ }), h = a(() => u.value.filter((e) => !e.resolved_at).length), g = a(() => {
1090
+ let e = /* @__PURE__ */ new Map();
1091
+ for (let t of u.value) t.block_id && e.set(t.block_id, (e.get(t.block_id) ?? 0) + 1 + (t.replies?.length ?? 0));
1092
+ return e;
1093
+ });
1094
+ function _() {
1095
+ let e = t.userConfig;
1096
+ if (!e) throw Error("User config not available");
1097
+ return {
1098
+ user_id: e.id,
1099
+ user_name: e.name,
1100
+ user_signature: e.signature
1101
+ };
1102
+ }
1103
+ function v() {
1104
+ let e = r?.();
1105
+ if (e) return { "X-Socket-ID": e };
1106
+ }
1107
+ function b(e, t) {
1108
+ o?.({
1109
+ type: e,
1110
+ comment: t
1111
+ });
1112
+ }
1113
+ function x(e) {
1114
+ for (let t of u.value) {
1115
+ if (t.id === e) return t;
1116
+ for (let n of t.replies ?? []) if (n.id === e) return n;
1117
+ }
1118
+ return null;
1119
+ }
1120
+ async function S() {
1121
+ let e = n();
1122
+ if (e) {
1123
+ d.value = !0;
1124
+ try {
1125
+ u.value = await l.getComments(e);
1126
+ } catch (e) {
1127
+ let t = e instanceof Error ? e : Error("Failed to load comments", { cause: e });
1128
+ s?.(t);
1129
+ } finally {
1130
+ d.value = !1;
1131
+ }
1132
+ }
1133
+ }
1134
+ async function C(e, t, r) {
1135
+ let i = n();
1136
+ if (!i) return null;
1137
+ f.value = !0;
1138
+ try {
1139
+ let n = await l.createComment(i, {
1140
+ body: e,
1141
+ block_id: t,
1142
+ parent_id: r,
1143
+ ..._()
1144
+ }, v());
1145
+ if (r) {
1146
+ let e = x(r);
1147
+ e && (e.replies = [...e.replies ?? [], n]);
1148
+ } else u.value = [...u.value, n];
1149
+ return b("created", n), n;
1150
+ } catch (e) {
1151
+ let t = e instanceof Error ? e : Error("Failed to create comment", { cause: e });
1152
+ return s?.(t), null;
1153
+ } finally {
1154
+ f.value = !1;
1155
+ }
1156
+ }
1157
+ async function w(e, t) {
1158
+ let r = n();
1159
+ if (!r) return null;
1160
+ f.value = !0;
1161
+ try {
1162
+ let n = await l.updateComment(r, e, {
1163
+ body: t,
1164
+ ..._()
1165
+ }, v());
1166
+ return A(e, n), b("updated", n), n;
1167
+ } catch (e) {
1168
+ let t = e instanceof Error ? e : Error("Failed to update comment", { cause: e });
1169
+ return s?.(t), null;
1170
+ } finally {
1171
+ f.value = !1;
1172
+ }
1173
+ }
1174
+ async function T(e) {
1175
+ let t = n();
1176
+ if (!t) return !1;
1177
+ let r = x(e);
1178
+ if (!r) return !1;
1179
+ let i = {
1180
+ ...r,
1181
+ replies: [...r.replies ?? []]
1182
+ };
1183
+ f.value = !0;
1184
+ try {
1185
+ if (await l.deleteComment(t, e, _(), v()), r.parent_id) {
1186
+ let t = x(r.parent_id);
1187
+ t && (t.replies = (t.replies ?? []).filter((t) => t.id !== e));
1188
+ } else u.value = u.value.filter((t) => t.id !== e);
1189
+ return b("deleted", i), !0;
1190
+ } catch (e) {
1191
+ let t = e instanceof Error ? e : Error("Failed to delete comment", { cause: e });
1192
+ return s?.(t), !1;
1193
+ } finally {
1194
+ f.value = !1;
1195
+ }
1196
+ }
1197
+ async function E(e) {
1198
+ let t = n();
1199
+ if (!t) return null;
1200
+ f.value = !0;
1201
+ try {
1202
+ let n = await l.resolveComment(t, e, _(), v());
1203
+ return A(e, n), b(n.resolved_at ? "resolved" : "unresolved", n), n;
1204
+ } catch (e) {
1205
+ let t = e instanceof Error ? e : Error("Failed to toggle comment resolution", { cause: e });
1206
+ return s?.(t), null;
1207
+ } finally {
1208
+ f.value = !1;
1209
+ }
1210
+ }
1211
+ function D(e) {
1212
+ if (e.parent_id) {
1213
+ let t = x(e.parent_id);
1214
+ t && (t.replies = [...t.replies ?? [], e]);
1215
+ } else u.value = [...u.value, e];
1216
+ b("created", e);
1217
+ }
1218
+ function O(e) {
1219
+ A(e.id, e), b("updated", e);
1220
+ }
1221
+ function k(e, t) {
1222
+ let n = x(e), r = n ? {
1223
+ ...n,
1224
+ replies: [...n.replies ?? []]
1225
+ } : null;
1226
+ if (t) {
1227
+ let n = x(t);
1228
+ n && (n.replies = (n.replies ?? []).filter((t) => t.id !== e));
1229
+ } else u.value = u.value.filter((t) => t.id !== e);
1230
+ r && b("deleted", r);
1231
+ }
1232
+ function A(e, t) {
1233
+ for (let n = 0; n < u.value.length; n++) {
1234
+ if (u.value[n].id === e) {
1235
+ u.value = [
1236
+ ...u.value.slice(0, n),
1237
+ {
1238
+ ...t,
1239
+ replies: u.value[n].replies
1240
+ },
1241
+ ...u.value.slice(n + 1)
1242
+ ];
1243
+ return;
1244
+ }
1245
+ let r = u.value[n].replies ?? [];
1246
+ for (let i = 0; i < r.length; i++) if (r[i].id === e) {
1247
+ let e = [
1248
+ ...r.slice(0, i),
1249
+ t,
1250
+ ...r.slice(i + 1)
1251
+ ];
1252
+ u.value = [
1253
+ ...u.value.slice(0, n),
1254
+ {
1255
+ ...u.value[n],
1256
+ replies: e
1257
+ },
1258
+ ...u.value.slice(n + 1)
1259
+ ];
1260
+ return;
1261
+ }
1262
+ }
1263
+ }
1264
+ return {
1265
+ comments: u,
1266
+ isLoading: d,
1267
+ isSubmitting: f,
1268
+ isEnabled: p,
1269
+ commentCountByBlock: g,
1270
+ totalCount: m,
1271
+ unresolvedCount: h,
1272
+ loadComments: S,
1273
+ addComment: C,
1274
+ editComment: w,
1275
+ removeComment: T,
1276
+ toggleResolve: E,
1277
+ applyRemoteCreate: D,
1278
+ applyRemoteUpdate: O,
1279
+ applyRemoteDelete: k
1280
+ };
1281
+ }
1282
+ //#endregion
1283
+ //#region ../core/src/cloud/comment-listener.ts
1284
+ function M(e) {
1285
+ let { comments: n, channel: r } = e;
1286
+ o(r, (e, t) => {
1287
+ t && t.unbind("comment-broadcast"), e && e.bind("comment-broadcast", (e) => {
1288
+ N(n, e);
1289
+ });
1290
+ }), t(() => {
1291
+ r.value?.unbind("comment-broadcast");
1292
+ });
1293
+ }
1294
+ function N(e, t) {
1295
+ switch (t.action) {
1296
+ case "comment_created":
1297
+ e.applyRemoteCreate(t.comment);
1298
+ break;
1299
+ case "comment_updated":
1300
+ e.applyRemoteUpdate(t.comment);
1301
+ break;
1302
+ case "comment_deleted":
1303
+ e.applyRemoteDelete(t.comment.id, t.comment.parent_id);
1304
+ break;
1305
+ case "comment_resolved":
1306
+ case "comment_unresolved":
1307
+ e.applyRemoteUpdate(t.comment);
1308
+ break;
1309
+ }
1310
+ }
1311
+ //#endregion
1312
+ //#region ../core/src/cloud/collaboration.ts
1313
+ var P = [
1314
+ "pusher:member_added",
1315
+ "pusher:member_removed",
1316
+ "client-block_locked",
1317
+ "client-block_unlocked",
1318
+ "client-operation",
1319
+ "mcp-operation"
1320
+ ];
1321
+ function F(e) {
1322
+ for (let t of P) e.unbind(t);
1323
+ }
1324
+ var I = [
1325
+ "#3b82f6",
1326
+ "#ef4444",
1327
+ "#10b981",
1328
+ "#f59e0b",
1329
+ "#8b5cf6",
1330
+ "#ec4899",
1331
+ "#06b6d4",
1332
+ "#f97316",
1333
+ "#6366f1",
1334
+ "#14b8a6"
1335
+ ];
1336
+ function L(e) {
1337
+ let { authManager: n, editor: r, channel: s } = e, c = i([]), l = i(/* @__PURE__ */ new Map()), u = 0, d = !1, f = a(() => n.userConfig?.id ?? "");
1338
+ function p() {
1339
+ let e = I[u % I.length];
1340
+ return u++, e;
1341
+ }
1342
+ function m(e) {
1343
+ if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
1344
+ let t = {
1345
+ id: e.id,
1346
+ name: e.name,
1347
+ color: p(),
1348
+ selectedBlockId: null
1349
+ };
1350
+ return c.value = [...c.value, t], t;
1351
+ }
1352
+ function h(e) {
1353
+ let t = new Map(l.value);
1354
+ for (let [n, r] of t) r.id === e && t.delete(n);
1355
+ l.value = t, c.value = c.value.filter((t) => t.id !== e);
1356
+ }
1357
+ function g(e) {
1358
+ let t = c.value.find((t) => t.id === e.userId);
1359
+ if (!t) return;
1360
+ c.value = c.value.map((t) => t.id === e.userId ? {
1361
+ ...t,
1362
+ selectedBlockId: e.blockId
1363
+ } : t);
1364
+ let n = new Map(l.value);
1365
+ for (let [t, r] of n) r.id === e.userId && n.delete(t);
1366
+ n.set(e.blockId, {
1367
+ ...t,
1368
+ selectedBlockId: e.blockId
1369
+ }), l.value = n, r.state.selectedBlockId === e.blockId && r.selectBlock(null);
1370
+ }
1371
+ function _(e) {
1372
+ let t = new Map(l.value), n = t.get(e.blockId);
1373
+ t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1374
+ ...e,
1375
+ selectedBlockId: null
1376
+ } : e));
1377
+ }
1378
+ function v(e) {
1379
+ d = !0;
1380
+ try {
1381
+ S(r, e);
1382
+ } finally {
1383
+ d = !1;
1384
+ }
1385
+ }
1386
+ function y(e) {
1387
+ !s.value || d || s.value.trigger("client-operation", e);
1388
+ }
1389
+ function b(e) {
1390
+ s.value && s.value.trigger("client-block_locked", {
1391
+ blockId: e,
1392
+ userId: f.value
1393
+ });
1394
+ }
1395
+ function x(e) {
1396
+ s.value && s.value.trigger("client-block_unlocked", { blockId: e });
1397
+ }
1398
+ return o(() => r.state.selectedBlockId, (e, t) => {
1399
+ d || (t && x(t), e && b(e));
1400
+ }), o(s, (t, n) => {
1401
+ if (n && F(n), !t) {
1402
+ c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1403
+ return;
1404
+ }
1405
+ let r = t.members;
1406
+ r && r.each((e) => {
1407
+ m(e.info);
1408
+ }), t.bind("pusher:member_added", (t) => {
1409
+ let n = m(t.info);
1410
+ n && e.onCollaboratorJoined?.(n);
1411
+ }), t.bind("pusher:member_removed", (t) => {
1412
+ let n = c.value.find((e) => e.id === t.id);
1413
+ h(t.id), n && e.onCollaboratorLeft?.(n);
1414
+ }), t.bind("client-block_locked", (t) => {
1415
+ g(t);
1416
+ let n = c.value.find((e) => e.id === t.userId);
1417
+ n && e.onBlockLocked?.({
1418
+ blockId: t.blockId,
1419
+ collaborator: n
1420
+ });
1421
+ }), t.bind("client-block_unlocked", (t) => {
1422
+ let n = l.value.get(t.blockId);
1423
+ _(t), n && e.onBlockUnlocked?.({
1424
+ blockId: t.blockId,
1425
+ collaborator: n
1426
+ });
1427
+ }), t.bind("client-operation", (e) => {
1428
+ v(e);
1429
+ }), t.bind("mcp-operation", (e) => {
1430
+ v(e);
1431
+ });
1432
+ }), t(() => {
1433
+ s.value && F(s.value);
1434
+ }), {
1435
+ collaborators: c,
1436
+ lockedBlocks: l,
1437
+ _broadcastOperation: y,
1438
+ _isProcessingRemoteOperation: () => d
1439
+ };
1440
+ }
1441
+ //#endregion
1442
+ //#region ../core/src/cloud/collaboration-broadcast.ts
1443
+ function R(e, t) {
1444
+ let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1445
+ e.addBlock = (e, r, i, a) => {
1446
+ n(e, r, i, a), t._broadcastOperation({
1447
+ operation: "add_block",
1448
+ data: {
1449
+ block: e,
1450
+ section_id: r,
1451
+ column_index: i,
1452
+ index: a
1453
+ },
1454
+ timestamp: Date.now()
1455
+ });
1456
+ }, e.updateBlock = (e, n) => {
1457
+ r(e, n), t._broadcastOperation({
1458
+ operation: "update_block",
1459
+ data: {
1460
+ block_id: e,
1461
+ updates: n
1462
+ },
1463
+ timestamp: Date.now()
1464
+ });
1465
+ }, e.removeBlock = (e) => {
1466
+ i(e), t._broadcastOperation({
1467
+ operation: "delete_block",
1468
+ data: { block_id: e },
1469
+ timestamp: Date.now()
1470
+ });
1471
+ }, e.moveBlock = (e, n, r, i) => {
1472
+ a(e, n, r, i), t._broadcastOperation({
1473
+ operation: "move_block",
1474
+ data: {
1475
+ block_id: e,
1476
+ index: n,
1477
+ section_id: r,
1478
+ column_index: i
1479
+ },
1480
+ timestamp: Date.now()
1481
+ });
1482
+ }, e.updateSettings = (e) => {
1483
+ o(e), t._broadcastOperation({
1484
+ operation: "update_settings",
1485
+ data: { updates: e },
1486
+ timestamp: Date.now()
1487
+ });
1488
+ }, e.setContent = (e, n) => {
1489
+ s(e, n), t._broadcastOperation({
1490
+ operation: "set_content",
1491
+ data: { content: e },
1492
+ timestamp: Date.now()
1493
+ });
1494
+ };
1495
+ }
1496
+ //#endregion
1497
+ //#region ../core/src/cloud/web-socket.ts
1498
+ function z(e) {
1499
+ let { authManager: t, onError: n } = e, r = i(null), a = i(!1), o = null, s = null;
1500
+ async function c(e, i) {
1501
+ if (o) return;
1502
+ o = new x({
1503
+ authManager: t,
1504
+ config: i,
1505
+ onError: n
1506
+ }), await o.connect(), s = `presence-template.${e}`;
1507
+ let c = o.subscribePresence(s);
1508
+ c.bind("pusher:subscription_succeeded", () => {
1509
+ a.value = !0, r.value = c;
1510
+ }), c.bind("pusher:subscription_error", (e) => {
1511
+ a.value = !1, r.value = null, n?.(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to subscribe to template channel"));
1512
+ });
1513
+ }
1514
+ function l() {
1515
+ s && o && o.unsubscribe(s), o?.disconnect(), o = null, s = null, r.value = null, a.value = !1;
1516
+ }
1517
+ function u() {
1518
+ return o?.getSocketId() ?? null;
1519
+ }
1520
+ return {
1521
+ channel: r,
1522
+ isConnected: a,
1523
+ connect: c,
1524
+ disconnect: l,
1525
+ getSocketId: u
1526
+ };
1527
+ }
1528
+ //#endregion
1529
+ //#region ../core/src/cloud/saved-blocks-provider.ts
1530
+ function B(e) {
1531
+ let t = new y(e);
1532
+ return {
1533
+ list(e) {
1534
+ return t.listModules(e?.search, e?.category);
1535
+ },
1536
+ create(e) {
1537
+ return t.createModule(e);
1538
+ },
1539
+ update(e, n) {
1540
+ return t.updateModule(e, n);
1541
+ },
1542
+ delete(e) {
1543
+ return t.deleteModule(e);
1544
+ }
1545
+ };
1546
+ }
1547
+ //#endregion
1548
+ //#region ../core/src/cloud/snapshots.ts
1549
+ function V(e) {
1550
+ let t = new y(e.authManager), n = i([]), r = i(!1), a = i(!1);
1551
+ async function o() {
1552
+ r.value = !0;
1553
+ try {
1554
+ n.value = await t.getSnapshots(e.templateId);
1555
+ } catch (t) {
1556
+ throw e.onError?.(t), t;
1557
+ } finally {
1558
+ r.value = !1;
1559
+ }
1560
+ }
1561
+ async function s(n) {
1562
+ a.value = !0;
1563
+ try {
1564
+ let r = await t.restoreSnapshot(e.templateId, n);
1565
+ return e.onRestore?.(r), r;
1566
+ } catch (t) {
1567
+ throw e.onError?.(t), t;
1568
+ } finally {
1569
+ a.value = !1;
1570
+ }
1571
+ }
1572
+ return {
1573
+ snapshots: n,
1574
+ isLoading: r,
1575
+ isRestoring: a,
1576
+ loadSnapshots: o,
1577
+ restoreSnapshot: s
1578
+ };
1579
+ }
1580
+ //#endregion
1581
+ //#region ../core/src/cloud/test-email.ts
1582
+ function H(e) {
1583
+ let { authManager: t, getTemplateId: n, save: r, exportHtml: s, onError: c, isAuthReady: l, onBeforeTestEmail: u } = e, d = new y(t), f = i(!1), p = i(null), m = i(null);
1584
+ l && o(l, (e) => {
1585
+ e && (m.value = t.testEmailConfig);
1586
+ }, { immediate: !0 });
1587
+ let h = a(() => m.value !== null), g = a(() => m.value?.allowedEmails ?? []);
1588
+ async function _(e) {
1589
+ if (!m.value) throw Error("Test email is not enabled for this project");
1590
+ let t = n();
1591
+ if (!t) throw Error("Template must be saved before sending a test email");
1592
+ f.value = !0, p.value = null;
1593
+ try {
1594
+ await r();
1595
+ let { html: n } = await s(t);
1596
+ u && (n = await u(n)), await d.sendTestEmail(t, {
1597
+ recipient: e,
1598
+ html: n,
1599
+ allowed_emails: m.value.allowedEmails,
1600
+ signature: m.value.signature
1601
+ });
1602
+ } catch (e) {
1603
+ let t = e instanceof Error ? e : Error("Failed to send test email", { cause: e });
1604
+ throw p.value = t.message, c?.(t), t;
1605
+ } finally {
1606
+ f.value = !1;
1607
+ }
1608
+ }
1609
+ return {
1610
+ isEnabled: h,
1611
+ allowedEmails: g,
1612
+ isSending: f,
1613
+ error: p,
1614
+ sendTestEmail: _
1615
+ };
1616
+ }
1617
+ //#endregion
1618
+ //#region ../core/src/cloud/export.ts
1619
+ function U(e) {
1620
+ let { authManager: t, getFontsConfig: n, canUseCustomFonts: r } = e, i = new y(t);
1621
+ function a() {
1622
+ let e = n?.();
1623
+ return {
1624
+ customFonts: (r?.() ?? !0) && e?.customFonts ? e.customFonts : [],
1625
+ defaultFallback: e?.defaultFallback ?? "Arial, sans-serif"
1626
+ };
1627
+ }
1628
+ async function o(e) {
1629
+ let t = a(), n = await i.exportTemplate(e, t);
1630
+ return {
1631
+ html: n.html,
1632
+ mjml: n.mjml
1633
+ };
1634
+ }
1635
+ async function s(e) {
1636
+ let t = a();
1637
+ return (await i.exportTemplate(e, t)).mjml;
1638
+ }
1639
+ return {
1640
+ exportHtml: o,
1641
+ getMjmlSource: s
1642
+ };
1643
+ }
1644
+ //#endregion
1645
+ //#region ../core/src/cloud/plan-config.ts
1646
+ function W(e) {
1647
+ let { authManager: t, onError: n } = e, r = i(null), o = i(!1), s = new y(t), c = a(() => r.value?.features ?? null);
1648
+ function l(e) {
1649
+ return r.value?.features[e] ?? !1;
1650
+ }
1651
+ async function u() {
1652
+ if (!o.value) {
1653
+ o.value = !0;
1654
+ try {
1655
+ r.value = await s.fetchConfig();
1656
+ } catch (e) {
1657
+ n?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1658
+ } finally {
1659
+ o.value = !1;
1660
+ }
1661
+ }
1662
+ }
1663
+ return {
1664
+ config: r,
1665
+ isLoading: o,
1666
+ hasFeature: l,
1667
+ features: c,
1668
+ fetchConfig: u
1669
+ };
1670
+ }
1671
+ //#endregion
1672
+ //#region ../core/src/cloud/health-check.ts
1673
+ var G = 5e3;
1674
+ function K(e) {
1675
+ return e.authManager ? e.authManager.resolveUrl(v.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${v.health}`;
1676
+ }
1677
+ async function q(e, t) {
1678
+ let n = performance.now();
1679
+ try {
1680
+ let r = t ? await t.authenticatedFetch(v.health, {
1681
+ method: "GET",
1682
+ headers: { Accept: "application/json" }
1683
+ }) : await fetch(e, {
1684
+ method: "GET",
1685
+ headers: { Accept: "application/json" }
1686
+ }), i = Math.round(performance.now() - n);
1687
+ if (r.status === 401) return {
1688
+ api: {
1689
+ ok: !0,
1690
+ latency: i
1691
+ },
1692
+ auth: {
1693
+ ok: !1,
1694
+ error: "HTTP 401"
1695
+ }
1696
+ };
1697
+ if (!r.ok) return {
1698
+ api: {
1699
+ ok: !1,
1700
+ latency: i
1701
+ },
1702
+ auth: {
1703
+ ok: !t,
1704
+ error: t ? `HTTP ${r.status}` : void 0
1705
+ }
1706
+ };
1707
+ let a = await r.json();
1708
+ return {
1709
+ api: {
1710
+ ok: a.status === "ok",
1711
+ latency: i
1712
+ },
1713
+ auth: { ok: !0 },
1714
+ wsConfig: a.websocket
1715
+ };
1716
+ } catch (e) {
1717
+ return {
1718
+ api: {
1719
+ ok: !1,
1720
+ latency: Math.round(performance.now() - n)
1721
+ },
1722
+ auth: {
1723
+ ok: !t,
1724
+ error: t ? e instanceof Error ? e.message : "Authentication check failed" : void 0
1725
+ }
1726
+ };
1727
+ }
1728
+ }
1729
+ async function J(e) {
1730
+ if (!e?.host || !e?.app_key) return {
1731
+ ok: !1,
1732
+ error: "WebSocket configuration not available"
1733
+ };
1734
+ if (typeof WebSocket > "u") return {
1735
+ ok: !1,
1736
+ error: "WebSocket not supported in this environment"
1737
+ };
1738
+ let t = `${e.port === 443 ? "wss" : "ws"}://${e.host}:${e.port}/app/${e.app_key}?protocol=7&client=js&version=8.4.0-rc2&flash=false`;
1739
+ return new Promise((e) => {
1740
+ let n = null, r = setTimeout(() => {
1741
+ n?.close(), e({
1742
+ ok: !1,
1743
+ error: "WebSocket connection timed out"
1744
+ });
1745
+ }, G);
1746
+ try {
1747
+ n = new WebSocket(t);
1748
+ } catch (t) {
1749
+ clearTimeout(r), e({
1750
+ ok: !1,
1751
+ error: t instanceof Error ? t.message : "WebSocket connection failed"
1752
+ });
1753
+ return;
1754
+ }
1755
+ n.onopen = () => {
1756
+ clearTimeout(r), n?.close(), e({ ok: !0 });
1757
+ }, n.onerror = () => {
1758
+ clearTimeout(r), e({
1759
+ ok: !1,
1760
+ error: "WebSocket connection failed"
1761
+ });
1762
+ };
1763
+ });
1764
+ }
1765
+ async function Y(e = {}) {
1766
+ let t = await q(K(e), e.authManager), n = await J(t.wsConfig);
1767
+ return {
1768
+ api: t.api,
1769
+ websocket: n,
1770
+ auth: t.auth,
1771
+ overall: t.api.ok && t.auth.ok
1772
+ };
1773
+ }
1774
+ //#endregion
1775
+ //#region ../core/src/cloud/mcp-listener.ts
1776
+ function X(e) {
1777
+ let { editor: t, channel: n, onOperation: r } = e;
1778
+ o(n, (e, n) => {
1779
+ n && n.unbind("mcp-operation"), e && e.bind("mcp-operation", (e) => {
1780
+ S(t, e), r?.(e);
1781
+ });
1782
+ });
1783
+ }
1784
+ //#endregion
1785
+ export { u as C, l as S, w as _, H as a, v as b, z as c, M as d, j as f, D as g, O as h, U as i, R as l, k as m, Y as n, V as o, A as p, W as r, B as s, X as t, L as u, b as v, d as x, y };
1786
+
1787
+ //# sourceMappingURL=cloud-BJlbXGTJ.js.map