@templatical/editor 0.26.2 → 0.27.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 (285) hide show
  1. package/README.md +3 -1
  2. package/dist/{AiChatSidebar-CMBz6Wix.js → AiChatSidebar-iVJDzqjr.js} +60 -60
  3. package/dist/AiFeatureMenu-DvrK-dzj.js +57 -0
  4. package/dist/{BlockIssueBadge-Buk3_6QF.js → BlockIssueBadge-BHysq7XQ.js} +11 -11
  5. package/dist/BlockPreviewCanvas-GZbr0ph5.js +121 -0
  6. package/dist/CloudHeaderExtras-Cx8gFWu2.js +59 -0
  7. package/dist/CloudPanels-D0X449DD.js +227 -0
  8. package/dist/{CollaboratorBar-zvfvE7f-.js → CollaboratorBar-DMSWCrX3.js} +21 -21
  9. package/dist/ColorPicker-DCjFQCAg.js +501 -0
  10. package/dist/CommentsPanel-D5wQB1Kf.js +18 -0
  11. package/dist/CommentsSidebar-BoTIxpLE.js +481 -0
  12. package/dist/{cdn/chunks/CountdownBlock-vLTkTI9e.js → CountdownBlock-BFX8iU90.js} +19 -21
  13. package/dist/{cdn/chunks/CountdownToolbar-DPjcgcVR.js → CountdownToolbar-CSftc9Ma.js} +52 -53
  14. package/dist/{DesignReferenceSidebar-Bx96XFmK.js → DesignReferenceSidebar-DKsx2TiL.js} +72 -71
  15. package/dist/{IssuesPanel-Do7RLXsP.js → IssuesPanel-flKKwKpM.js} +38 -38
  16. package/dist/{LoadingTrack-BexpNuTV.js → LoadingTrack-C2T8ixEL.js} +3 -3
  17. package/dist/{MergeTagModeToggle-P-UguQHc.js → MergeTagModeToggle-PKCoKAoF.js} +43 -43
  18. package/dist/{MergeTagSuggestion-BJ43ihWR.js → MergeTagSuggestion-DGha0WRp.js} +46 -46
  19. package/dist/{cdn/chunks/NumberWithSuffix-BXrRdfq1.js → NumberWithSuffix-DdPCXfKf.js} +42 -44
  20. package/dist/{ParagraphEditor-CLvv5Ija.js → ParagraphEditor-vDU-5y6r.js} +202 -199
  21. package/dist/RestoreVersionDialog-DIn1muFD.js +86 -0
  22. package/dist/{RichTextEditorContent-fbYJXAio.js → RichTextEditorContent-I83k5DtQ.js} +44 -44
  23. package/dist/SaveBlockDialog-C_QvYAeL.js +266 -0
  24. package/dist/{SavedBlocksBrowserModal-KWlaiLlr.js → SavedBlocksBrowserModal-CefWWcdT.js} +116 -115
  25. package/dist/{cdn/chunks/SavedBlocksPanels-e4HyTZ8v.js → SavedBlocksPanels-DnQwO-7O.js} +9 -11
  26. package/dist/{SavedBlocksPickBar-C3h8oL3r.js → SavedBlocksPickBar-BsFubArH.js} +17 -17
  27. package/dist/{TemplateScoringPanel-BZUsb3FD.js → TemplateScoringPanel-Bv_bBsJi.js} +87 -87
  28. package/dist/TestEmailModal-STPWDP79.js +206 -0
  29. package/dist/{cdn/chunks/TestEmailPanel-CZAG1gQE.js → TestEmailPanel-HYVjApKZ.js} +4 -6
  30. package/dist/TitleEditor-DnB0EJ_g.js +198 -0
  31. package/dist/TplModal-chvLhXmC.js +49 -0
  32. package/dist/VersionHistoryMenu-Cq4rH56t.js +155 -0
  33. package/dist/VersionHistoryPanels-D7k_F7-9.js +46 -0
  34. package/dist/VersionPreviewBanner-DthyHe6C.js +38 -0
  35. package/dist/{blockTypeIcons-2_85L_CL.js → blockTypeIcons-B8r4jMBn.js} +6 -6
  36. package/dist/bundle-stats.json +8 -8
  37. package/dist/{ca-D1zgI9fQ.js → ca-Cqg9O8mx.js} +69 -6
  38. package/dist/cdn/chunks/{AiChatSidebar-CQ8KUmNB.js → AiChatSidebar-DTUoBH5a.js} +54 -54
  39. package/dist/cdn/chunks/AiChatSidebar-DTUoBH5a.js.map +1 -0
  40. package/dist/cdn/chunks/AiFeatureMenu-Dyh7mUMB.js +57 -0
  41. package/dist/cdn/chunks/AiFeatureMenu-Dyh7mUMB.js.map +1 -0
  42. package/dist/cdn/chunks/{BlockIssueBadge-BEEY9o2o.js → BlockIssueBadge-UzSSOM_2.js} +13 -13
  43. package/dist/cdn/chunks/{BlockIssueBadge-BEEY9o2o.js.map → BlockIssueBadge-UzSSOM_2.js.map} +1 -1
  44. package/dist/cdn/chunks/{BlockPreviewCanvas-DPtiMsVz.js → BlockPreviewCanvas-DStQFo9P.js} +42 -42
  45. package/dist/cdn/chunks/{BlockPreviewCanvas-DPtiMsVz.js.map → BlockPreviewCanvas-DStQFo9P.js.map} +1 -1
  46. package/dist/cdn/chunks/CloudHeaderExtras-BZVu7dnO.js +60 -0
  47. package/dist/cdn/chunks/CloudHeaderExtras-BZVu7dnO.js.map +1 -0
  48. package/dist/cdn/chunks/CloudPanels-CXbaBKHQ.js +227 -0
  49. package/dist/cdn/chunks/CloudPanels-CXbaBKHQ.js.map +1 -0
  50. package/dist/cdn/chunks/{CollaboratorBar-BF469_AN.js → CollaboratorBar-BH_lZlat.js} +22 -22
  51. package/dist/cdn/chunks/CollaboratorBar-BH_lZlat.js.map +1 -0
  52. package/dist/cdn/chunks/ColorPicker-CStXen0Y.js +502 -0
  53. package/dist/cdn/chunks/ColorPicker-CStXen0Y.js.map +1 -0
  54. package/dist/cdn/chunks/CommentsPanel-jzZ2X0P4.js +20 -0
  55. package/dist/cdn/chunks/CommentsPanel-jzZ2X0P4.js.map +1 -0
  56. package/dist/cdn/chunks/CommentsSidebar-Dxke-vUP.js +460 -0
  57. package/dist/cdn/chunks/CommentsSidebar-Dxke-vUP.js.map +1 -0
  58. package/dist/{CountdownBlock-DuyvGcr8.js → cdn/chunks/CountdownBlock-BYSrJWxg.js} +25 -23
  59. package/dist/cdn/chunks/{CountdownBlock-vLTkTI9e.js.map → CountdownBlock-BYSrJWxg.js.map} +1 -1
  60. package/dist/{CountdownToolbar-CBE9wRaV.js → cdn/chunks/CountdownToolbar-CZPtQIb8.js} +66 -63
  61. package/dist/cdn/chunks/{CountdownToolbar-DPjcgcVR.js.map → CountdownToolbar-CZPtQIb8.js.map} +1 -1
  62. package/dist/cdn/chunks/{DesignReferenceSidebar-B-HFXV0W.js → DesignReferenceSidebar-sZWciECR.js} +64 -64
  63. package/dist/cdn/chunks/DesignReferenceSidebar-sZWciECR.js.map +1 -0
  64. package/dist/cdn/chunks/{IssuesPanel-DKTS4QVb.js → IssuesPanel-CHtetM9i.js} +36 -36
  65. package/dist/cdn/chunks/IssuesPanel-CHtetM9i.js.map +1 -0
  66. package/dist/cdn/chunks/{LoadingTrack-C52ZGL5q.js → LoadingTrack-Dp_QZvAK.js} +3 -3
  67. package/dist/cdn/chunks/{LoadingTrack-C52ZGL5q.js.map → LoadingTrack-Dp_QZvAK.js.map} +1 -1
  68. package/dist/cdn/chunks/{MergeTagModeToggle-DQ79SqQc.js → MergeTagModeToggle-ZwW-5EeN.js} +39 -39
  69. package/dist/cdn/chunks/{MergeTagModeToggle-DQ79SqQc.js.map → MergeTagModeToggle-ZwW-5EeN.js.map} +1 -1
  70. package/dist/cdn/chunks/{MergeTagSuggestion-Dn8dExNa.js → MergeTagSuggestion-DhllqTA3.js} +47 -47
  71. package/dist/cdn/chunks/MergeTagSuggestion-DhllqTA3.js.map +1 -0
  72. package/dist/{NumberWithSuffix-D37ZWiZh.js → cdn/chunks/NumberWithSuffix-yeQLcCyH.js} +37 -35
  73. package/dist/cdn/chunks/NumberWithSuffix-yeQLcCyH.js.map +1 -0
  74. package/dist/cdn/chunks/{ParagraphEditor-Bzcma_Lm.js → ParagraphEditor-BJJ925sx.js} +235 -233
  75. package/dist/cdn/chunks/ParagraphEditor-BJJ925sx.js.map +1 -0
  76. package/dist/cdn/chunks/RestoreVersionDialog-B0Jadu6F.js +87 -0
  77. package/dist/cdn/chunks/RestoreVersionDialog-B0Jadu6F.js.map +1 -0
  78. package/dist/cdn/chunks/{RichTextEditorContent-DtL49Jpo.js → RichTextEditorContent-CfSq2wPR.js} +44 -44
  79. package/dist/cdn/chunks/RichTextEditorContent-CfSq2wPR.js.map +1 -0
  80. package/dist/cdn/chunks/SaveBlockDialog-C1DXh6P9.js +265 -0
  81. package/dist/cdn/chunks/SaveBlockDialog-C1DXh6P9.js.map +1 -0
  82. package/dist/cdn/chunks/{SavedBlocksBrowserModal-C59D4G5C.js → SavedBlocksBrowserModal-BerMxAUt.js} +114 -113
  83. package/dist/cdn/chunks/SavedBlocksBrowserModal-BerMxAUt.js.map +1 -0
  84. package/dist/{SavedBlocksPanels-CQsZvWO_.js → cdn/chunks/SavedBlocksPanels-BUE4lzVP.js} +11 -9
  85. package/dist/cdn/chunks/{SavedBlocksPanels-e4HyTZ8v.js.map → SavedBlocksPanels-BUE4lzVP.js.map} +1 -1
  86. package/dist/cdn/chunks/{SavedBlocksPickBar-DMHxPCM4.js → SavedBlocksPickBar-4HrqQfvl.js} +17 -17
  87. package/dist/cdn/chunks/SavedBlocksPickBar-4HrqQfvl.js.map +1 -0
  88. package/dist/cdn/chunks/{TemplateScoringPanel-NucRtAP0.js → TemplateScoringPanel-Xdkp2EMY.js} +81 -81
  89. package/dist/cdn/chunks/TemplateScoringPanel-Xdkp2EMY.js.map +1 -0
  90. package/dist/cdn/chunks/TestEmailModal-yfmFiavR.js +206 -0
  91. package/dist/cdn/chunks/TestEmailModal-yfmFiavR.js.map +1 -0
  92. package/dist/{TestEmailPanel-B6goIAxT.js → cdn/chunks/TestEmailPanel-DqTDh5ri.js} +6 -4
  93. package/dist/cdn/chunks/{TestEmailPanel-CZAG1gQE.js.map → TestEmailPanel-DqTDh5ri.js.map} +1 -1
  94. package/dist/cdn/chunks/{TitleEditor-D0_LY2Ex.js → TitleEditor-nUAF7fKr.js} +85 -84
  95. package/dist/cdn/chunks/TitleEditor-nUAF7fKr.js.map +1 -0
  96. package/dist/cdn/chunks/TplModal-C0IqikoV.js +50 -0
  97. package/dist/cdn/chunks/TplModal-C0IqikoV.js.map +1 -0
  98. package/dist/cdn/chunks/VersionHistoryMenu-_MAj3qZj.js +148 -0
  99. package/dist/cdn/chunks/VersionHistoryMenu-_MAj3qZj.js.map +1 -0
  100. package/dist/cdn/chunks/VersionHistoryPanels-6Hz9w20W.js +48 -0
  101. package/dist/cdn/chunks/VersionHistoryPanels-6Hz9w20W.js.map +1 -0
  102. package/dist/cdn/chunks/VersionPreviewBanner-D098_6_I.js +40 -0
  103. package/dist/cdn/chunks/VersionPreviewBanner-D098_6_I.js.map +1 -0
  104. package/dist/cdn/chunks/{blockTypeIcons-FXlMM3PL.js → blockTypeIcons-hX_W4dqo.js} +2 -2
  105. package/dist/cdn/chunks/{blockTypeIcons-FXlMM3PL.js.map → blockTypeIcons-hX_W4dqo.js.map} +1 -1
  106. package/dist/cdn/chunks/{ca-D1zgI9fQ.js → ca-Cqg9O8mx.js} +70 -7
  107. package/dist/cdn/chunks/ca-Cqg9O8mx.js.map +1 -0
  108. package/dist/{cloud-qINCmQbn.js → cdn/chunks/cloud-BA0OpRh-.js} +400 -609
  109. package/dist/cdn/chunks/cloud-BA0OpRh-.js.map +1 -0
  110. package/dist/cdn/chunks/createCloudRuntime-DmzV7OnU.js +344 -0
  111. package/dist/cdn/chunks/createCloudRuntime-DmzV7OnU.js.map +1 -0
  112. package/dist/{de-DHra3lvx.js → cdn/chunks/de-BXmeeFbX.js} +71 -6
  113. package/dist/cdn/chunks/de-BXmeeFbX.js.map +1 -0
  114. package/dist/{de-uVoSP1xF.js → cdn/chunks/de-Dbwm2cON.js} +3 -54
  115. package/dist/cdn/chunks/de-Dbwm2cON.js.map +1 -0
  116. package/dist/cdn/chunks/{dist-B2HKGHnc.js → dist-CM8TB0VD.js} +136 -136
  117. package/dist/cdn/chunks/{dist-B2HKGHnc.js.map → dist-CM8TB0VD.js.map} +1 -1
  118. package/dist/cdn/chunks/{dist-C6z8AjBC.js → dist-CYLJiSiH.js} +63 -63
  119. package/dist/cdn/chunks/{dist-C6z8AjBC.js.map → dist-CYLJiSiH.js.map} +1 -1
  120. package/dist/cdn/chunks/{draggable-DCs9qL-b.js → draggable-BfpsXFg7.js} +916 -905
  121. package/dist/cdn/chunks/{draggable-DCs9qL-b.js.map → draggable-BfpsXFg7.js.map} +1 -1
  122. package/dist/cdn/chunks/{en-DlqX2YWZ.js → en-DbBNy67B.js} +70 -7
  123. package/dist/cdn/chunks/en-DbBNy67B.js.map +1 -0
  124. package/dist/{en-CjhsJxb-.js → cdn/chunks/en-Dzw4EqNI.js} +3 -54
  125. package/dist/cdn/chunks/en-Dzw4EqNI.js.map +1 -0
  126. package/dist/cdn/chunks/{es-Cuss2snv.js → es-JUsAjxWu.js} +70 -7
  127. package/dist/cdn/chunks/es-JUsAjxWu.js.map +1 -0
  128. package/dist/cdn/chunks/{extensions-C7h52yuk.js → extensions-CMcVw2uu.js} +81 -67
  129. package/dist/cdn/chunks/extensions-CMcVw2uu.js.map +1 -0
  130. package/dist/{fr-Cm85vB2g.js → cdn/chunks/fr-J3qgXH4h.js} +71 -6
  131. package/dist/cdn/chunks/fr-J3qgXH4h.js.map +1 -0
  132. package/dist/cdn/chunks/{icons-CvYN6zrM.js → icons-C36Ha5VU.js} +11 -11
  133. package/dist/cdn/chunks/{icons-CvYN6zrM.js.map → icons-C36Ha5VU.js.map} +1 -1
  134. package/dist/{keys-fwF3qZax.js → cdn/chunks/keys-CbQuRX85.js} +6 -4
  135. package/dist/cdn/chunks/keys-CbQuRX85.js.map +1 -0
  136. package/dist/cdn/chunks/logger-ByvdoAwq.js +23 -0
  137. package/dist/cdn/chunks/logger-ByvdoAwq.js.map +1 -0
  138. package/dist/cdn/chunks/{nl-dmiIX7oT.js → nl-D_4DkqOi.js} +70 -7
  139. package/dist/cdn/chunks/nl-D_4DkqOi.js.map +1 -0
  140. package/dist/cdn/chunks/preRenderCustomBlocks-CbA3RcAy.js +23 -0
  141. package/dist/cdn/chunks/preRenderCustomBlocks-CbA3RcAy.js.map +1 -0
  142. package/dist/{pt-BR-CTzHTqJD.js → cdn/chunks/pt-BR-BxzQzWGJ.js} +3 -54
  143. package/dist/cdn/chunks/pt-BR-BxzQzWGJ.js.map +1 -0
  144. package/dist/cdn/chunks/{pt-BR-CaIG-7EM.js → pt-BR-KGURyEEQ.js} +70 -7
  145. package/dist/cdn/chunks/pt-BR-KGURyEEQ.js.map +1 -0
  146. package/dist/cdn/chunks/{src-CUKUsRzX.js → src-BOjFLNf7.js} +148 -134
  147. package/dist/cdn/chunks/src-BOjFLNf7.js.map +1 -0
  148. package/dist/cdn/chunks/{src-xkGep9eN.js → src-Dq3fgSIx.js} +1448 -1458
  149. package/dist/cdn/chunks/src-Dq3fgSIx.js.map +1 -0
  150. package/dist/cdn/chunks/styleConstants-ByDqaYj_.js +61 -0
  151. package/dist/cdn/chunks/styleConstants-ByDqaYj_.js.map +1 -0
  152. package/dist/cdn/chunks/timeouts-DHPZQ0G3.js +6 -0
  153. package/dist/cdn/chunks/timeouts-DHPZQ0G3.js.map +1 -0
  154. package/dist/cdn/chunks/{tiptap-C44S1Cmh.js → tiptap-DmpGap5g.js} +40 -40
  155. package/dist/cdn/chunks/{tiptap-C44S1Cmh.js.map → tiptap-DmpGap5g.js.map} +1 -1
  156. package/dist/cdn/chunks/{useAliveFlag-Dxwgo6P4.js → useAliveFlag-Dtm174fG.js} +2 -2
  157. package/dist/cdn/chunks/{useAliveFlag-Dxwgo6P4.js.map → useAliveFlag-Dtm174fG.js.map} +1 -1
  158. package/dist/cdn/chunks/{useCloudI18n-8wkJtuJD.js → useCloudI18n-NVa1aeY8.js} +5 -5
  159. package/dist/cdn/chunks/{useCloudI18n-8wkJtuJD.js.map → useCloudI18n-NVa1aeY8.js.map} +1 -1
  160. package/dist/cdn/chunks/{useEditorCore-CKQ9gmoo.js → useEditorCore-CTu_qZ3W.js} +1434 -1147
  161. package/dist/cdn/chunks/useEditorCore-CTu_qZ3W.js.map +1 -0
  162. package/dist/cdn/chunks/{useI18n-UMs0F71x.js → useI18n-DVWCJJFH.js} +5 -5
  163. package/dist/cdn/chunks/{useI18n-UMs0F71x.js.map → useI18n-DVWCJJFH.js.map} +1 -1
  164. package/dist/cdn/chunks/{useMergeTag-JmXOtpln.js → useMergeTag-BfZBRPQp.js} +4 -4
  165. package/dist/cdn/chunks/{useMergeTag-JmXOtpln.js.map → useMergeTag-BfZBRPQp.js.map} +1 -1
  166. package/dist/cdn/chunks/{usePopoverPosition-cf8Y-ynK.js → usePopoverPosition-BC-HA7TK.js} +3 -3
  167. package/dist/cdn/chunks/{usePopoverPosition-cf8Y-ynK.js.map → usePopoverPosition-BC-HA7TK.js.map} +1 -1
  168. package/dist/cdn/editor.css +1 -1
  169. package/dist/cdn/editor.js +5103 -284
  170. package/dist/cdn/editor.js.map +1 -1
  171. package/dist/{check-On4TSac-.js → check-DZbmkMQe.js} +1 -1
  172. package/dist/{chevron-down-69EiBGoB.js → chevron-down-nYScOLeZ.js} +1 -1
  173. package/dist/{chevron-up-Dh3MG1Dw.js → chevron-up-CpYpDLnc.js} +1 -1
  174. package/dist/{circle-alert-cilwzafX.js → circle-alert-CuuK6thq.js} +1 -1
  175. package/dist/{clock-Dt0APH92.js → clock-DxkrtqOr.js} +1 -1
  176. package/dist/cloud-BAefVBb_.js +1444 -0
  177. package/dist/createCloudRuntime-Bt8W-ajI.js +342 -0
  178. package/dist/{createLucideIcon-C8WzBYCv.js → createLucideIcon-L-wQXW_R.js} +9 -9
  179. package/dist/{cdn/chunks/de-DHra3lvx.js → de-BXmeeFbX.js} +69 -8
  180. package/dist/{cdn/chunks/de-uVoSP1xF.js → de-Dbwm2cON.js} +1 -56
  181. package/dist/dist-B5iReTtK.js +251 -0
  182. package/dist/{dist-Cl8J0IES.js → dist-Ck9roB6K.js} +42 -42
  183. package/dist/{dist-BpKxrUi2.js → dist-CqcGTIiX.js} +46 -46
  184. package/dist/{en-DlqX2YWZ.js → en-DbBNy67B.js} +69 -6
  185. package/dist/{cdn/chunks/en-CjhsJxb-.js → en-Dzw4EqNI.js} +1 -56
  186. package/dist/{es-Cuss2snv.js → es-JUsAjxWu.js} +69 -6
  187. package/dist/{extensions-DzKNPITR.js → extensions-CX87G4aL.js} +71 -57
  188. package/dist/{cdn/chunks/fr-Cm85vB2g.js → fr-J3qgXH4h.js} +69 -8
  189. package/dist/{image-up-Ceggh_R3.js → image-up-DouZRGVt.js} +1 -1
  190. package/dist/index.d.ts +499 -23
  191. package/dist/{info-DO5odBcZ.js → info-puX5V6Iq.js} +1 -1
  192. package/dist/{cdn/chunks/keys-Cmc2Yl3D.js → keys-BxixS0TN.js} +4 -6
  193. package/dist/{list-checks-BSkPKbuI.js → list-checks-jw-ZlvWY.js} +1 -1
  194. package/dist/{loader-circle-bO7o7_HD.js → loader-circle-DqTxB7Kr.js} +1 -1
  195. package/dist/logger-BBlvSn6q.js +21 -0
  196. package/dist/{message-circle-BEkAk65X.js → message-circle-BZ7YpB22.js} +1 -1
  197. package/dist/{nl-dmiIX7oT.js → nl-D_4DkqOi.js} +69 -6
  198. package/dist/{pencil-t6m0EtKL.js → pencil-DmbRhTJu.js} +1 -1
  199. package/dist/preRenderCustomBlocks-BebjKtmw.js +21 -0
  200. package/dist/{cdn/chunks/pt-BR-CTzHTqJD.js → pt-BR-BxzQzWGJ.js} +1 -56
  201. package/dist/{pt-BR-CaIG-7EM.js → pt-BR-KGURyEEQ.js} +69 -6
  202. package/dist/{refresh-cw-CkOYVzK5.js → refresh-cw-OK_O-cL0.js} +1 -1
  203. package/dist/{runtime-dom.esm-bundler-CepEmvwF.js → runtime-dom.esm-bundler-BgKXIPLV.js} +144 -144
  204. package/dist/{scan-line-DwSVj25O.js → scan-line-DyaSTsJ5.js} +1 -1
  205. package/dist/{send-CWsWN8PQ.js → send-B-wasJJC.js} +1 -1
  206. package/dist/{shield-check-qje8Kufw.js → shield-check-DUIyRrTo.js} +1 -1
  207. package/dist/{sparkles-DumaWRW-.js → sparkles-DYEMATWC.js} +1 -1
  208. package/dist/style.css +1 -1
  209. package/dist/styleConstants-ByDqaYj_.js +59 -0
  210. package/dist/templatical-editor.js +5303 -289
  211. package/dist/{text-align-start-Ir8Ah4mT.js → text-align-start-CzjLeBLe.js} +1 -1
  212. package/dist/timeouts-DHPZQ0G3.js +4 -0
  213. package/dist/{trash-2-CklAFCmO.js → trash-2-C0shEPry.js} +1 -1
  214. package/dist/{triangle-alert-BBi4n93g.js → triangle-alert-Fw0ce8oQ.js} +1 -1
  215. package/dist/{upload-sVqqppuv.js → upload-D69C2CBx.js} +3 -4
  216. package/dist/{useAliveFlag-cvyBxHp7.js → useAliveFlag-BGIAZii_.js} +1 -1
  217. package/dist/{useCloudI18n-DKVm6PCa.js → useCloudI18n-CAZTZ9_a.js} +2 -2
  218. package/dist/{useEditorCore-idmPLUeb.js → useEditorCore-B-kONNRw.js} +1604 -1320
  219. package/dist/{useI18n-DoVKdCTH.js → useI18n-BfXff_Sy.js} +2 -2
  220. package/dist/{useMergeTag-CYZk7dZD.js → useMergeTag-Dd4I7kge.js} +3 -3
  221. package/dist/usePopoverPosition-CxhCX3SQ.js +59 -0
  222. package/dist/{vue.runtime.esm-bundler-D1diBMsm.js → vue.runtime.esm-bundler-DzEsDRtY.js} +447 -436
  223. package/dist/{x-Mby7KlhS.js → x-BjTlFqRv.js} +1 -1
  224. package/package.json +7 -7
  225. package/dist/AiFeatureMenu-BY6mubnR.js +0 -63
  226. package/dist/BlockPreviewCanvas-DbNOqSI1.js +0 -121
  227. package/dist/CloudEditor-DEnMNMbm.js +0 -1188
  228. package/dist/ColorPicker-ClETsjA3.js +0 -550
  229. package/dist/CommentsSidebar-CdRCCSDD.js +0 -435
  230. package/dist/SaveBlockDialog-fVp_PwZi.js +0 -265
  231. package/dist/SnapshotHistory-DjA3Ej_i.js +0 -128
  232. package/dist/TestEmailModal-EM0RP_9L.js +0 -205
  233. package/dist/TitleEditor-JEaP9jVF.js +0 -197
  234. package/dist/TplModal-DoneXIj_.js +0 -49
  235. package/dist/cdn/chunks/AiChatSidebar-CQ8KUmNB.js.map +0 -1
  236. package/dist/cdn/chunks/AiFeatureMenu-Cwj8afsi.js +0 -63
  237. package/dist/cdn/chunks/AiFeatureMenu-Cwj8afsi.js.map +0 -1
  238. package/dist/cdn/chunks/CloudEditor-CQ830jJt.js +0 -1166
  239. package/dist/cdn/chunks/CloudEditor-CQ830jJt.js.map +0 -1
  240. package/dist/cdn/chunks/CollaboratorBar-BF469_AN.js.map +0 -1
  241. package/dist/cdn/chunks/ColorPicker-W_UyiVGc.js +0 -552
  242. package/dist/cdn/chunks/ColorPicker-W_UyiVGc.js.map +0 -1
  243. package/dist/cdn/chunks/CommentsSidebar-BLRZRSSC.js +0 -412
  244. package/dist/cdn/chunks/CommentsSidebar-BLRZRSSC.js.map +0 -1
  245. package/dist/cdn/chunks/DesignReferenceSidebar-B-HFXV0W.js.map +0 -1
  246. package/dist/cdn/chunks/IssuesPanel-DKTS4QVb.js.map +0 -1
  247. package/dist/cdn/chunks/MergeTagSuggestion-Dn8dExNa.js.map +0 -1
  248. package/dist/cdn/chunks/NumberWithSuffix-BXrRdfq1.js.map +0 -1
  249. package/dist/cdn/chunks/ParagraphEditor-Bzcma_Lm.js.map +0 -1
  250. package/dist/cdn/chunks/RichTextEditorContent-DtL49Jpo.js.map +0 -1
  251. package/dist/cdn/chunks/SaveBlockDialog-BfNVeXXV.js +0 -264
  252. package/dist/cdn/chunks/SaveBlockDialog-BfNVeXXV.js.map +0 -1
  253. package/dist/cdn/chunks/SavedBlocksBrowserModal-C59D4G5C.js.map +0 -1
  254. package/dist/cdn/chunks/SavedBlocksPickBar-DMHxPCM4.js.map +0 -1
  255. package/dist/cdn/chunks/SnapshotHistory-80tAU_VX.js +0 -121
  256. package/dist/cdn/chunks/SnapshotHistory-80tAU_VX.js.map +0 -1
  257. package/dist/cdn/chunks/TemplateScoringPanel-NucRtAP0.js.map +0 -1
  258. package/dist/cdn/chunks/TestEmailModal-DdWfAGNe.js +0 -205
  259. package/dist/cdn/chunks/TestEmailModal-DdWfAGNe.js.map +0 -1
  260. package/dist/cdn/chunks/TitleEditor-D0_LY2Ex.js.map +0 -1
  261. package/dist/cdn/chunks/TplModal-iCmoKB2k.js +0 -50
  262. package/dist/cdn/chunks/TplModal-iCmoKB2k.js.map +0 -1
  263. package/dist/cdn/chunks/ca-D1zgI9fQ.js.map +0 -1
  264. package/dist/cdn/chunks/cloud-DcC8bPwn.js +0 -1787
  265. package/dist/cdn/chunks/cloud-DcC8bPwn.js.map +0 -1
  266. package/dist/cdn/chunks/de-DHra3lvx.js.map +0 -1
  267. package/dist/cdn/chunks/de-uVoSP1xF.js.map +0 -1
  268. package/dist/cdn/chunks/en-CjhsJxb-.js.map +0 -1
  269. package/dist/cdn/chunks/en-DlqX2YWZ.js.map +0 -1
  270. package/dist/cdn/chunks/es-Cuss2snv.js.map +0 -1
  271. package/dist/cdn/chunks/extensions-C7h52yuk.js.map +0 -1
  272. package/dist/cdn/chunks/fr-Cm85vB2g.js.map +0 -1
  273. package/dist/cdn/chunks/keys-Cmc2Yl3D.js.map +0 -1
  274. package/dist/cdn/chunks/nl-dmiIX7oT.js.map +0 -1
  275. package/dist/cdn/chunks/pt-BR-CTzHTqJD.js.map +0 -1
  276. package/dist/cdn/chunks/pt-BR-CaIG-7EM.js.map +0 -1
  277. package/dist/cdn/chunks/src-CUKUsRzX.js.map +0 -1
  278. package/dist/cdn/chunks/src-xkGep9eN.js.map +0 -1
  279. package/dist/cdn/chunks/styles-CND3ey2g.js +0 -4140
  280. package/dist/cdn/chunks/styles-CND3ey2g.js.map +0 -1
  281. package/dist/cdn/chunks/timeouts-SsLMC4a3.js +0 -6
  282. package/dist/cdn/chunks/timeouts-SsLMC4a3.js.map +0 -1
  283. package/dist/cdn/chunks/useEditorCore-CKQ9gmoo.js.map +0 -1
  284. package/dist/styles-BK36D1sy.js +0 -4318
  285. package/dist/usePopoverPosition-C0dPEF4X.js +0 -308
@@ -0,0 +1,1444 @@
1
+ import { L as e, X as t, q as n, s as r } from "./vue.runtime.esm-bundler-DzEsDRtY.js";
2
+ import { o as i } from "./dist-B1kLn1rs.js";
3
+ //#region ../core/dist/cloud/index.js
4
+ function a(e) {
5
+ let t = e instanceof i ? e.statusCode : void 0;
6
+ return t !== void 0 && t >= 400 && t < 500;
7
+ }
8
+ var o = class e {
9
+ static DEFAULT_BASE_URL = "https://templatical.com";
10
+ accessToken = null;
11
+ expiresAt = null;
12
+ _projectId = null;
13
+ _tenantId = null;
14
+ _tenantSlug = null;
15
+ _testEmailConfig = null;
16
+ _userConfig = null;
17
+ url;
18
+ baseUrl;
19
+ requestOptions;
20
+ onError;
21
+ refreshPromise = null;
22
+ static REFRESH_THRESHOLD_MS = 6e4;
23
+ constructor(t) {
24
+ this.url = t.url, this.baseUrl = (t.baseUrl ?? e.DEFAULT_BASE_URL).replace(/\/$/, ""), this.requestOptions = t.requestOptions ?? {}, this.onError = t.onError;
25
+ }
26
+ resolveUrl(e) {
27
+ if (e.startsWith("http://") || e.startsWith("https://")) return e;
28
+ let t = e.startsWith("/") ? e : `/${e}`;
29
+ return `${this.baseUrl}${t}`;
30
+ }
31
+ get projectId() {
32
+ if (!this._projectId) throw Error("Project ID not available. Call initialize() first.");
33
+ return this._projectId;
34
+ }
35
+ get tenantId() {
36
+ if (!this._tenantId) throw Error("Tenant ID not available. Call initialize() first.");
37
+ return this._tenantId;
38
+ }
39
+ get tenantSlug() {
40
+ if (!this._tenantSlug) throw Error("Tenant slug not available. Call initialize() first.");
41
+ return this._tenantSlug;
42
+ }
43
+ get testEmailConfig() {
44
+ return this._testEmailConfig;
45
+ }
46
+ get userConfig() {
47
+ return this._userConfig;
48
+ }
49
+ get accessTokenValue() {
50
+ return this.accessToken;
51
+ }
52
+ async initialize() {
53
+ await this.ensureToken();
54
+ }
55
+ async ensureToken() {
56
+ return this.accessToken && !this.isTokenExpiringSoon() ? this.accessToken : this.refreshToken();
57
+ }
58
+ isTokenExpiringSoon() {
59
+ return !this.expiresAt || this.expiresAt.getTime() - Date.now() < e.REFRESH_THRESHOLD_MS;
60
+ }
61
+ async refreshToken() {
62
+ if (this.refreshPromise) return this.refreshPromise;
63
+ this.refreshPromise = this.performRefresh();
64
+ try {
65
+ return await this.refreshPromise;
66
+ } finally {
67
+ this.refreshPromise = null;
68
+ }
69
+ }
70
+ async performRefresh() {
71
+ try {
72
+ let e = this.requestOptions.method ?? "POST", t = {
73
+ Accept: "application/json",
74
+ ...this.requestOptions.headers
75
+ }, n = {
76
+ method: e,
77
+ headers: t,
78
+ credentials: this.requestOptions.credentials ?? "include"
79
+ };
80
+ e === "POST" && this.requestOptions.body && (t["Content-Type"] = "application/json", n.body = JSON.stringify(this.requestOptions.body));
81
+ let r = await fetch(this.url, n);
82
+ if (!r.ok) throw new i(`Token refresh failed: ${r.status}`, r.status);
83
+ let a = await r.json();
84
+ if (!a.token || !a.expires_at || !a.project_id || !a.tenant) throw Error("Invalid token response: missing token, expires_at, project_id, or tenant");
85
+ return this.accessToken = a.token, this.expiresAt = /* @__PURE__ */ new Date(a.expires_at * 1e3), this._projectId = a.project_id, this._tenantSlug = a.tenant, this._testEmailConfig = a.test_email?.allowed_emails && a.test_email?.signature ? {
86
+ allowedEmails: a.test_email.allowed_emails,
87
+ signature: a.test_email.signature
88
+ } : null, this._userConfig = a.user?.id && a.user?.name && a.user?.signature ? {
89
+ id: a.user.id,
90
+ name: a.user.name,
91
+ signature: a.user.signature
92
+ } : null, this.accessToken;
93
+ } catch (e) {
94
+ let t = e instanceof Error ? e : Error("Token refresh failed", { cause: e });
95
+ throw this.onError?.(t), t;
96
+ }
97
+ }
98
+ async authenticatedFetch(e, t = {}) {
99
+ let n = await this.ensureToken(), r = this.resolveUrl(e), i = async (e) => fetch(r, {
100
+ ...t,
101
+ headers: {
102
+ ...t.headers,
103
+ Authorization: `Bearer ${e}`
104
+ }
105
+ }), a = await i(n);
106
+ return a.status === 401 && (a = await i(await this.refreshToken())), a;
107
+ }
108
+ };
109
+ function s(e, t) {
110
+ return e.replace(/\{(\w+)\}/g, (e, n) => encodeURIComponent(t[n] ?? ""));
111
+ }
112
+ var c = "/api/v1/projects/{project}/tenants/{tenant}", l = `${c}/templates/{template}`, u = `${l}/ai`, d = `${c}/media`, f = `${d}/folders`, p = `${c}/saved-modules`, m = {
113
+ health: "/api/v1/health",
114
+ "projects.config": `${c}/config`,
115
+ "broadcasting.auth": `${c}/broadcasting/auth`,
116
+ "templates.store": `${c}/templates`,
117
+ "templates.show": `${l}`,
118
+ "templates.update": `${l}`,
119
+ "templates.destroy": `${l}`,
120
+ "templates.export": `${l}/export`,
121
+ "templates.importFromBeefree": `${c}/templates/import/from-beefree`,
122
+ "templates.sendTestEmail": `${l}/send-test-email`,
123
+ "versions.index": `${l}/versions`,
124
+ "versions.store": `${l}/versions`,
125
+ "versions.show": `${l}/versions/{version}`,
126
+ "versions.restore": `${l}/versions/{version}/restore`,
127
+ "comments.index": `${l}/comments`,
128
+ "comments.store": `${l}/comments`,
129
+ "comments.update": `${l}/comments/{comment}`,
130
+ "comments.destroy": `${l}/comments/{comment}`,
131
+ "comments.resolve": `${l}/comments/{comment}/resolve`,
132
+ "ai.generate": `${u}/generate`,
133
+ "ai.conversationMessages": `${u}/conversation-messages`,
134
+ "ai.suggestions": `${u}/suggestions`,
135
+ "ai.rewriteText": `${u}/rewrite-text`,
136
+ "ai.score": `${u}/score`,
137
+ "ai.fixFinding": `${u}/fix-finding`,
138
+ "ai.generateFromDesign": `${u}/generate-from-design`,
139
+ "media.upload": `${d}/upload`,
140
+ "media.browse": `${d}/browse`,
141
+ "media.delete": `${d}/delete`,
142
+ "media.move": `${d}/move`,
143
+ "media.update": `${d}/{media}`,
144
+ "media.replace": `${d}/{media}/replace`,
145
+ "media.checkUsage": `${d}/check-usage`,
146
+ "media.frequentlyUsed": `${d}/frequently-used`,
147
+ "media.importFromUrl": `${d}/import-from-url`,
148
+ "folders.index": `${f}`,
149
+ "folders.store": `${f}`,
150
+ "folders.update": `${f}/{mediaFolder}`,
151
+ "folders.destroy": `${f}/{mediaFolder}`,
152
+ "savedModules.index": `${p}`,
153
+ "savedModules.store": `${p}`,
154
+ "savedModules.update": `${p}/{savedModule}`,
155
+ "savedModules.destroy": `${p}/{savedModule}`
156
+ }, h = class {
157
+ authManager;
158
+ constructor(e) {
159
+ this.authManager = e;
160
+ }
161
+ get projectId() {
162
+ return this.authManager.projectId;
163
+ }
164
+ get tenantSlug() {
165
+ return this.authManager.tenantSlug;
166
+ }
167
+ get baseParams() {
168
+ return {
169
+ project: this.projectId,
170
+ tenant: this.tenantSlug
171
+ };
172
+ }
173
+ async request(e, t = {}) {
174
+ let n = await this.authManager.authenticatedFetch(e, {
175
+ ...t,
176
+ headers: {
177
+ "Content-Type": "application/json",
178
+ Accept: "application/json",
179
+ ...t.headers
180
+ }
181
+ });
182
+ if (!n.ok) {
183
+ let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` })), t = this.extractFirstValidationError(e);
184
+ throw new i(t, n.status);
185
+ }
186
+ if (n.status !== 204) return (await n.json()).data;
187
+ }
188
+ extractFirstValidationError(e) {
189
+ if (e.errors) {
190
+ let t = Object.keys(e.errors)[0];
191
+ if (t && e.errors[t]?.length > 0) return e.errors[t][0];
192
+ }
193
+ return e.message;
194
+ }
195
+ async createTemplate(e, t) {
196
+ return this.request(s(m["templates.store"], this.baseParams), {
197
+ method: "POST",
198
+ body: JSON.stringify(t === void 0 ? { content: e } : {
199
+ content: e,
200
+ name: t
201
+ })
202
+ });
203
+ }
204
+ async getTemplate(e) {
205
+ return this.request(s(m["templates.show"], {
206
+ ...this.baseParams,
207
+ template: e
208
+ }));
209
+ }
210
+ async updateTemplate(e, t) {
211
+ return this.request(s(m["templates.update"], {
212
+ ...this.baseParams,
213
+ template: e
214
+ }), {
215
+ method: "PUT",
216
+ body: JSON.stringify(t)
217
+ });
218
+ }
219
+ async createVersion(e, t, n) {
220
+ return this.request(s(m["versions.store"], {
221
+ ...this.baseParams,
222
+ template: e
223
+ }), {
224
+ method: "POST",
225
+ body: JSON.stringify(n === void 0 ? { content: t } : {
226
+ content: t,
227
+ label: n
228
+ })
229
+ });
230
+ }
231
+ async deleteTemplate(e) {
232
+ return this.request(s(m["templates.destroy"], {
233
+ ...this.baseParams,
234
+ template: e
235
+ }), { method: "DELETE" });
236
+ }
237
+ async getVersions(e) {
238
+ return this.request(s(m["versions.index"], {
239
+ ...this.baseParams,
240
+ template: e
241
+ }));
242
+ }
243
+ async getVersion(e, t) {
244
+ return this.request(s(m["versions.show"], {
245
+ ...this.baseParams,
246
+ template: e,
247
+ version: t
248
+ }));
249
+ }
250
+ async restoreVersion(e, t) {
251
+ return this.request(s(m["versions.restore"], {
252
+ ...this.baseParams,
253
+ template: e,
254
+ version: t
255
+ }), { method: "POST" });
256
+ }
257
+ async exportTemplate(e, t) {
258
+ let n = t ? JSON.stringify({
259
+ custom_fonts: t.customFonts,
260
+ default_fallback: t.defaultFallback
261
+ }) : void 0;
262
+ return this.request(s(m["templates.export"], {
263
+ ...this.baseParams,
264
+ template: e
265
+ }), {
266
+ method: "POST",
267
+ body: n
268
+ });
269
+ }
270
+ async sendTestEmail(e, t) {
271
+ await this.request(s(m["templates.sendTestEmail"], {
272
+ ...this.baseParams,
273
+ template: e
274
+ }), {
275
+ method: "POST",
276
+ body: JSON.stringify(t)
277
+ });
278
+ }
279
+ commentsUrl(e, t) {
280
+ return t ? s(m["comments.update"], {
281
+ ...this.baseParams,
282
+ template: e,
283
+ comment: t
284
+ }) : s(m["comments.index"], {
285
+ ...this.baseParams,
286
+ template: e
287
+ });
288
+ }
289
+ async getComments(e) {
290
+ return this.request(this.commentsUrl(e));
291
+ }
292
+ async createComment(e, t, n) {
293
+ return this.request(this.commentsUrl(e), {
294
+ method: "POST",
295
+ body: JSON.stringify(t),
296
+ headers: n
297
+ });
298
+ }
299
+ async updateComment(e, t, n, r) {
300
+ return this.request(this.commentsUrl(e, t), {
301
+ method: "PUT",
302
+ body: JSON.stringify(n),
303
+ headers: r
304
+ });
305
+ }
306
+ async deleteComment(e, t, n, r) {
307
+ return this.request(this.commentsUrl(e, t), {
308
+ method: "DELETE",
309
+ body: JSON.stringify(n),
310
+ headers: r
311
+ });
312
+ }
313
+ async resolveComment(e, t, n, r) {
314
+ return this.request(s(m["comments.resolve"], {
315
+ ...this.baseParams,
316
+ template: e,
317
+ comment: t
318
+ }), {
319
+ method: "POST",
320
+ body: JSON.stringify(n),
321
+ headers: r
322
+ });
323
+ }
324
+ async fetchConfig() {
325
+ return this.request(s(m["projects.config"], this.baseParams));
326
+ }
327
+ async listModules(e, t) {
328
+ let n = s(m["savedModules.index"], this.baseParams), r = new URLSearchParams();
329
+ e && r.set("search", e), t && r.set("category", t);
330
+ let i = r.size > 0 ? `?${r}` : "";
331
+ return this.request(`${n}${i}`);
332
+ }
333
+ async createModule(e) {
334
+ return this.request(s(m["savedModules.store"], this.baseParams), {
335
+ method: "POST",
336
+ body: JSON.stringify(e)
337
+ });
338
+ }
339
+ async updateModule(e, t) {
340
+ return this.request(s(m["savedModules.update"], {
341
+ ...this.baseParams,
342
+ savedModule: e
343
+ }), {
344
+ method: "PUT",
345
+ body: JSON.stringify(t)
346
+ });
347
+ }
348
+ async deleteModule(e) {
349
+ return this.request(s(m["savedModules.destroy"], {
350
+ ...this.baseParams,
351
+ savedModule: e
352
+ }), { method: "DELETE" });
353
+ }
354
+ };
355
+ function g(e) {
356
+ return {
357
+ host: e.host,
358
+ port: e.port,
359
+ appKey: e.app_key
360
+ };
361
+ }
362
+ var _ = class {
363
+ pusher = null;
364
+ authManager;
365
+ config;
366
+ onError;
367
+ constructor(e) {
368
+ this.authManager = e.authManager, this.config = e.config, this.onError = e.onError;
369
+ }
370
+ async connect() {
371
+ if (this.pusher) return;
372
+ let e;
373
+ try {
374
+ ({default: e} = await import("pusher-js"));
375
+ } catch {
376
+ throw Error("[Templatical] Cloud features require the optional peer dependency 'pusher-js'. Please install it.");
377
+ }
378
+ let { host: t, port: n, appKey: r } = this.config, i = this.authManager.resolveUrl(s(m["broadcasting.auth"], {
379
+ project: this.authManager.projectId,
380
+ tenant: this.authManager.tenantSlug
381
+ }));
382
+ this.pusher = new e(r, {
383
+ wsHost: t,
384
+ wsPort: n,
385
+ wssPort: n,
386
+ forceTLS: !0,
387
+ disableStats: !0,
388
+ enabledTransports: ["ws", "wss"],
389
+ cluster: "",
390
+ channelAuthorization: {
391
+ transport: "ajax",
392
+ endpoint: i,
393
+ headers: {
394
+ Authorization: `Bearer ${this.authManager.accessTokenValue}`,
395
+ Accept: "application/json"
396
+ },
397
+ params: {
398
+ user_id: this.authManager.userConfig?.id ?? "",
399
+ user_name: this.authManager.userConfig?.name ?? "",
400
+ user_signature: this.authManager.userConfig?.signature ?? ""
401
+ }
402
+ }
403
+ }), this.pusher.connection.bind("error", (e) => {
404
+ this.onError?.(e instanceof Error ? e : /* @__PURE__ */ Error("WebSocket connection error"));
405
+ });
406
+ }
407
+ subscribePresence(e) {
408
+ if (!this.pusher) throw Error("WebSocketClient not connected. Call connect() first.");
409
+ return this.pusher.subscribe(e);
410
+ }
411
+ unsubscribe(e) {
412
+ this.pusher?.unsubscribe(e);
413
+ }
414
+ getChannel(e) {
415
+ return this.pusher?.channel(e);
416
+ }
417
+ disconnect() {
418
+ this.pusher &&= (this.pusher.disconnect(), null);
419
+ }
420
+ getSocketId() {
421
+ return this.pusher?.connection.socket_id ?? null;
422
+ }
423
+ get isConnected() {
424
+ return this.pusher?.connection.state === "connected";
425
+ }
426
+ };
427
+ function v(e, t) {
428
+ let { operation: n, data: r } = t;
429
+ switch (n) {
430
+ case "add_block":
431
+ e.addBlock(r.block, r.section_id, r.column_index, r.index);
432
+ break;
433
+ case "update_block":
434
+ e.updateBlock(r.block_id, r.updates);
435
+ break;
436
+ case "delete_block":
437
+ e.removeBlock(r.block_id);
438
+ break;
439
+ case "move_block":
440
+ e.moveBlock(r.block_id, r.index, r.section_id, r.column_index);
441
+ break;
442
+ case "update_settings":
443
+ e.updateSettings(r.updates);
444
+ break;
445
+ case "set_content":
446
+ e.setContent(r.content);
447
+ break;
448
+ case "update_block_style": e.updateBlock(r.block_id, { styles: r.styles });
449
+ }
450
+ }
451
+ var y = 0;
452
+ function b() {
453
+ return `msg_${Date.now()}_${++y}`;
454
+ }
455
+ function x(e) {
456
+ let { authManager: n, getTemplateId: r, onApply: i, onError: a } = e, o = t([]), c = t(!1), l = t(!1), u = t(null), d = t(null), f = t(null), p = t(null), h = t(null), g = t(null), _ = t(!1), v = t([]), y = t(!1);
457
+ function x(e, t) {
458
+ let n = o.value.findIndex((t) => t.id === e);
459
+ if (n === -1) return;
460
+ let r = {
461
+ ...o.value[n],
462
+ ...t
463
+ };
464
+ o.value = [
465
+ ...o.value.slice(0, n),
466
+ r,
467
+ ...o.value.slice(n + 1)
468
+ ];
469
+ }
470
+ async function S() {
471
+ let e = r();
472
+ if (e) {
473
+ l.value = !0;
474
+ try {
475
+ let t = s(m["ai.conversationMessages"], {
476
+ project: n.projectId,
477
+ tenant: n.tenantSlug,
478
+ template: e
479
+ }), r = await n.authenticatedFetch(t, {
480
+ method: "GET",
481
+ headers: { Accept: "application/json" }
482
+ });
483
+ if (!r.ok) return;
484
+ let i = await r.json();
485
+ i.conversation_id && (f.value = i.conversation_id), Array.isArray(i.data) && i.data.length > 0 && (o.value = i.data.map((e) => ({
486
+ id: e.id,
487
+ role: e.role,
488
+ content: e.content,
489
+ timestamp: new Date(e.created_at).getTime()
490
+ })));
491
+ } catch {} finally {
492
+ l.value = !1;
493
+ }
494
+ }
495
+ }
496
+ async function C(e, t) {
497
+ let i = r();
498
+ if (i) {
499
+ y.value = !0;
500
+ try {
501
+ let r = s(m["ai.suggestions"], {
502
+ project: n.projectId,
503
+ tenant: n.tenantSlug,
504
+ template: i
505
+ }), a = await n.authenticatedFetch(r, {
506
+ method: "POST",
507
+ headers: {
508
+ "Content-Type": "application/json",
509
+ Accept: "text/event-stream"
510
+ },
511
+ body: JSON.stringify({
512
+ current_content: e,
513
+ merge_tags: t.map((e) => ({
514
+ label: e.label,
515
+ value: e.value
516
+ }))
517
+ })
518
+ });
519
+ if (!a.ok) return;
520
+ let o = a.body?.getReader();
521
+ if (!o) return;
522
+ let c = new TextDecoder(), l = "";
523
+ for (;;) {
524
+ let { done: e, value: t } = await o.read();
525
+ if (e) break;
526
+ l += c.decode(t, { stream: !0 });
527
+ let n = l.split("\n");
528
+ l = n.pop() ?? "";
529
+ for (let e of n) {
530
+ if (!e.startsWith("data: ")) continue;
531
+ let t;
532
+ try {
533
+ t = JSON.parse(e.slice(6));
534
+ } catch {
535
+ continue;
536
+ }
537
+ t.type === "done" && Array.isArray(t.suggestions) && (v.value = t.suggestions.slice(0, 3));
538
+ }
539
+ }
540
+ } catch {} finally {
541
+ y.value = !1;
542
+ }
543
+ }
544
+ }
545
+ async function w(e, t, l) {
546
+ let y = r();
547
+ if (!y) throw Error("Template must be saved before using AI generation");
548
+ c.value = !0, u.value = null, d.value = null, v.value = [];
549
+ let S = b();
550
+ o.value = [...o.value, {
551
+ id: S,
552
+ role: "user",
553
+ content: e,
554
+ timestamp: Date.now()
555
+ }];
556
+ let C = b();
557
+ o.value = [...o.value, {
558
+ id: C,
559
+ role: "assistant",
560
+ content: "",
561
+ timestamp: Date.now()
562
+ }];
563
+ try {
564
+ let r = s(m["ai.generate"], {
565
+ project: n.projectId,
566
+ tenant: n.tenantSlug,
567
+ template: y
568
+ }), a = await n.authenticatedFetch(r, {
569
+ method: "POST",
570
+ headers: {
571
+ "Content-Type": "application/json",
572
+ Accept: "text/event-stream"
573
+ },
574
+ body: JSON.stringify({
575
+ prompt: e,
576
+ current_content: t,
577
+ merge_tags: l.map((e) => ({
578
+ label: e.label,
579
+ value: e.value
580
+ })),
581
+ conversation_id: f.value
582
+ })
583
+ });
584
+ if (!a.ok) {
585
+ let e = await a.json().catch(() => null);
586
+ throw a.status === 403 ? Error("ai_generation_not_available") : Error(e?.message || "Failed to generate template");
587
+ }
588
+ let c = a.body?.getReader();
589
+ if (!c) throw Error("Failed to read stream");
590
+ let d = new TextDecoder(), v = "", b = null;
591
+ try {
592
+ for (;;) {
593
+ let { done: e, value: n } = await c.read();
594
+ if (e) break;
595
+ v += d.decode(n, { stream: !0 });
596
+ let r = v.split("\n");
597
+ v = r.pop() ?? "";
598
+ for (let e of r) {
599
+ if (!e.startsWith("data: ")) continue;
600
+ let n = e.slice(6), r;
601
+ try {
602
+ r = JSON.parse(n);
603
+ } catch {
604
+ continue;
605
+ }
606
+ if (r.type === "text") x(C, { content: (o.value.find((e) => e.id === C)?.content ?? "") + r.text });
607
+ else if (r.type === "error") throw Error(r.message || "Failed to generate template");
608
+ else r.type === "done" && (r.conversation_id && (f.value = r.conversation_id), x(C, { content: r.text }), b = r.content ?? null, b ? (h.value = t, g.value = b, p.value = C, _.value = !1, i?.(b)) : u.value = "ai_apply_failed");
609
+ }
610
+ }
611
+ } finally {
612
+ c.cancel().catch(() => {});
613
+ }
614
+ return b;
615
+ } catch (t) {
616
+ let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
617
+ return u.value = n.message, d.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== S && e.id !== C), null;
618
+ } finally {
619
+ c.value = !1;
620
+ }
621
+ }
622
+ function T() {
623
+ _.value ? (g.value && i?.(g.value), _.value = !1) : (h.value && i?.(h.value), _.value = !0);
624
+ }
625
+ function E() {
626
+ o.value = [], f.value = null, u.value = null, p.value = null, h.value = null, g.value = null, _.value = !1;
627
+ }
628
+ return {
629
+ messages: o,
630
+ isGenerating: c,
631
+ isLoadingHistory: l,
632
+ isLastChangeReverted: _,
633
+ lastApplyMessageId: p,
634
+ error: u,
635
+ failedPrompt: d,
636
+ suggestions: v,
637
+ isLoadingSuggestions: y,
638
+ sendPrompt: w,
639
+ toggleLastRevert: T,
640
+ loadConversation: S,
641
+ loadSuggestions: C,
642
+ clearChat: E
643
+ };
644
+ }
645
+ function S(e) {
646
+ function t(t) {
647
+ return e !== !1 && e?.[t] !== !1;
648
+ }
649
+ return {
650
+ isFeatureEnabled: t,
651
+ hasAnyMenuFeature: r(() => t("chat") || t("scoring") || t("designToTemplate"))
652
+ };
653
+ }
654
+ function C(e) {
655
+ let { authManager: n, getTemplateId: r } = e, i = t(!1), a = t(null), o = t(null), c = t(null), l = t(""), u = t(null);
656
+ async function d(e, t) {
657
+ let c = r();
658
+ if (!c) return null;
659
+ i.value = !0, o.value = null, a.value = null;
660
+ try {
661
+ let r = s(m["ai.score"], {
662
+ project: n.projectId,
663
+ tenant: n.tenantSlug,
664
+ template: c
665
+ }), i = await n.authenticatedFetch(r, {
666
+ method: "POST",
667
+ headers: {
668
+ "Content-Type": "application/json",
669
+ Accept: "text/event-stream"
670
+ },
671
+ body: JSON.stringify({
672
+ current_content: e,
673
+ merge_tags: t.map((e) => ({
674
+ label: e.label,
675
+ value: e.value
676
+ }))
677
+ })
678
+ });
679
+ if (!i.ok) {
680
+ if (i.status === 403) throw Error("ai_generation_not_available");
681
+ let e = await i.json().catch(() => null);
682
+ throw Error(e?.message || "Failed to score template");
683
+ }
684
+ let o = i.body?.getReader();
685
+ if (!o) throw Error("Failed to read stream");
686
+ let l = new TextDecoder(), u = "", d = null;
687
+ for (;;) {
688
+ let { done: e, value: t } = await o.read();
689
+ if (e) break;
690
+ u += l.decode(t, { stream: !0 });
691
+ let n = u.split("\n");
692
+ u = n.pop() ?? "";
693
+ for (let e of n) {
694
+ if (!e.startsWith("data: ")) continue;
695
+ let t;
696
+ try {
697
+ t = JSON.parse(e.slice(6));
698
+ } catch {
699
+ continue;
700
+ }
701
+ if (t.type === "error") throw Error(t.message || "Failed to score template");
702
+ t.type === "done" && (d = t.result ?? null);
703
+ }
704
+ }
705
+ if (d) for (let [e, t] of Object.entries(d.categories)) for (let n of t.findings) n.category = e;
706
+ return a.value = d, d;
707
+ } catch (e) {
708
+ return o.value = e instanceof Error ? e.message : "Failed to score template", null;
709
+ } finally {
710
+ i.value = !1;
711
+ }
712
+ }
713
+ async function f(e, t, i) {
714
+ let a = r();
715
+ if (!a) return null;
716
+ c.value = t.id, l.value = "", u.value = null;
717
+ try {
718
+ let r = s(m["ai.fixFinding"], {
719
+ project: n.projectId,
720
+ tenant: n.tenantSlug,
721
+ template: a
722
+ }), o = await n.authenticatedFetch(r, {
723
+ method: "POST",
724
+ headers: {
725
+ "Content-Type": "application/json",
726
+ Accept: "text/event-stream"
727
+ },
728
+ body: JSON.stringify({
729
+ content: e,
730
+ finding: {
731
+ id: t.id,
732
+ message: t.message,
733
+ suggestion: t.suggestion,
734
+ category: t.category
735
+ },
736
+ merge_tags: i.map((e) => ({
737
+ label: e.label,
738
+ value: e.value
739
+ }))
740
+ })
741
+ });
742
+ if (!o.ok) {
743
+ if (o.status === 403) throw Error("ai_generation_not_available");
744
+ let e = await o.json().catch(() => null);
745
+ throw Error(e?.message || "Failed to fix finding");
746
+ }
747
+ let c = o.body?.getReader();
748
+ if (!c) throw Error("Failed to read stream");
749
+ let u = new TextDecoder(), d = "", f = null;
750
+ for (;;) {
751
+ let { done: e, value: t } = await c.read();
752
+ if (e) break;
753
+ d += u.decode(t, { stream: !0 });
754
+ let n = d.split("\n");
755
+ d = n.pop() ?? "";
756
+ for (let e of n) {
757
+ if (!e.startsWith("data: ")) continue;
758
+ let t;
759
+ try {
760
+ t = JSON.parse(e.slice(6));
761
+ } catch {
762
+ continue;
763
+ }
764
+ if (t.type === "text") l.value += t.text;
765
+ else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
766
+ else t.type === "done" && (f = t.content ?? null);
767
+ }
768
+ }
769
+ return f;
770
+ } catch (e) {
771
+ return u.value = e instanceof Error ? e.message : "Failed to fix finding", null;
772
+ } finally {
773
+ c.value = null;
774
+ }
775
+ }
776
+ function p(e, t) {
777
+ if (!a.value) return;
778
+ let n = a.value.categories[e];
779
+ n && (n.findings = n.findings.filter((e) => e.id !== t));
780
+ }
781
+ function h() {
782
+ i.value = !1, a.value = null, o.value = null, c.value = null, l.value = "", u.value = null;
783
+ }
784
+ return {
785
+ isScoring: i,
786
+ scoringResult: a,
787
+ error: o,
788
+ fixingFindingId: c,
789
+ fixStreamingText: l,
790
+ fixError: u,
791
+ score: d,
792
+ fixFinding: f,
793
+ removeFinding: p,
794
+ reset: h
795
+ };
796
+ }
797
+ function w(e) {
798
+ let { authManager: n, getTemplateId: r, onApply: i, onError: a } = e, o = t(!1), c = t(null);
799
+ async function l(e) {
800
+ let t = r();
801
+ if (!t) throw Error("Template must be saved before using design reference");
802
+ o.value = !0, c.value = null;
803
+ try {
804
+ let r = new FormData();
805
+ e.prompt && r.append("prompt", e.prompt), e.imageUpload && r.append("image_upload", e.imageUpload), e.pdfUpload && r.append("pdf_upload", e.pdfUpload);
806
+ let a = s(m["ai.generateFromDesign"], {
807
+ project: n.projectId,
808
+ tenant: n.tenantSlug,
809
+ template: t
810
+ }), o = await n.authenticatedFetch(a, {
811
+ method: "POST",
812
+ headers: { Accept: "text/event-stream" },
813
+ body: r
814
+ });
815
+ if (!o.ok) {
816
+ let e = await o.json().catch(() => null);
817
+ throw o.status === 403 ? Error("ai_generation_not_available") : Error(e?.message || "Failed to generate template from design");
818
+ }
819
+ let c = o.body?.getReader();
820
+ if (!c) throw Error("Failed to read stream");
821
+ let l = new TextDecoder(), u = "", d = null;
822
+ for (;;) {
823
+ let { done: e, value: t } = await c.read();
824
+ if (e) break;
825
+ u += l.decode(t, { stream: !0 });
826
+ let n = u.split("\n");
827
+ u = n.pop() ?? "";
828
+ for (let e of n) {
829
+ if (!e.startsWith("data: ")) continue;
830
+ let t = e.slice(6), n;
831
+ try {
832
+ n = JSON.parse(t);
833
+ } catch {
834
+ continue;
835
+ }
836
+ if (n.type === "error") throw Error(n.message || "Failed to generate template from design");
837
+ n.type === "done" && (d = n.content ?? null, d && i?.(d));
838
+ }
839
+ }
840
+ return d;
841
+ } catch (e) {
842
+ let t = e instanceof Error ? e : Error("Failed to generate template from design", { cause: e });
843
+ return c.value = t.message, a?.(t), null;
844
+ } finally {
845
+ o.value = !1;
846
+ }
847
+ }
848
+ function u() {
849
+ o.value = !1, c.value = null;
850
+ }
851
+ return {
852
+ isGenerating: o,
853
+ error: c,
854
+ generate: l,
855
+ reset: u
856
+ };
857
+ }
858
+ var T = "comment-broadcast";
859
+ function E(e) {
860
+ let t = {
861
+ id: e.id,
862
+ body: e.body,
863
+ author: {
864
+ id: e.author_identifier,
865
+ name: e.author_name
866
+ },
867
+ createdAt: e.created_at,
868
+ blockId: e.block_id,
869
+ parentId: e.parent_id,
870
+ resolvedAt: e.resolved_at
871
+ };
872
+ return e.updated_at !== e.created_at && (t.updatedAt = e.updated_at), e.resolved_by_identifier && (t.resolvedBy = {
873
+ id: e.resolved_by_identifier,
874
+ name: e.resolved_by_name ?? ""
875
+ }), e.replies?.length && (t.replies = e.replies.map(E)), t;
876
+ }
877
+ function D(t) {
878
+ let { authManager: n, channel: r, getSocketId: i } = t, a = new h(n);
879
+ function o() {
880
+ let e = n.userConfig;
881
+ if (!e) throw Error("[Templatical] Cloud comments need a signed user in the auth token. The project's token endpoint must include a `user` claim.");
882
+ return {
883
+ user_id: e.id,
884
+ user_name: e.name,
885
+ user_signature: e.signature
886
+ };
887
+ }
888
+ function s() {
889
+ let e = i?.();
890
+ return e ? { "X-Socket-ID": e } : void 0;
891
+ }
892
+ return {
893
+ async list(e) {
894
+ return (await a.getComments(e)).map(E);
895
+ },
896
+ async create(e, t) {
897
+ return E(await a.createComment(e, {
898
+ body: t.body,
899
+ block_id: t.blockId,
900
+ parent_id: t.parentId,
901
+ ...o()
902
+ }, s()));
903
+ },
904
+ async update(e, t, n) {
905
+ if (n.body === void 0) throw Error("[Templatical] Cloud comments: update() needs a `body` in the patch.");
906
+ return E(await a.updateComment(e, t, {
907
+ body: n.body,
908
+ ...o()
909
+ }, s()));
910
+ },
911
+ async delete(e, t) {
912
+ await a.deleteComment(e, t, o(), s());
913
+ },
914
+ async setResolved(e, t, n) {
915
+ return E(await a.resolveComment(e, t, o(), s()));
916
+ },
917
+ subscribe(t, n) {
918
+ function i(e) {
919
+ let t = E(e.comment);
920
+ switch (e.action) {
921
+ case "comment_created":
922
+ n({
923
+ type: "created",
924
+ comment: t
925
+ });
926
+ break;
927
+ case "comment_deleted":
928
+ n({
929
+ type: "deleted",
930
+ commentId: t.id,
931
+ parentId: t.parentId
932
+ });
933
+ break;
934
+ case "comment_updated":
935
+ case "comment_resolved":
936
+ case "comment_unresolved": n({
937
+ type: "updated",
938
+ comment: t
939
+ });
940
+ }
941
+ }
942
+ let a = e(r, (e, t) => {
943
+ t?.unbind(T, i), e?.bind(T, i);
944
+ }, { immediate: !0 });
945
+ return () => {
946
+ a(), r.value?.unbind(T, i);
947
+ };
948
+ }
949
+ };
950
+ }
951
+ var O = [
952
+ "pusher:member_added",
953
+ "pusher:member_removed",
954
+ "client-block_locked",
955
+ "client-block_unlocked",
956
+ "client-operation",
957
+ "mcp-operation"
958
+ ];
959
+ function k(e) {
960
+ for (let t of O) e.unbind(t);
961
+ }
962
+ var A = [
963
+ "#3b82f6",
964
+ "#ef4444",
965
+ "#10b981",
966
+ "#f59e0b",
967
+ "#8b5cf6",
968
+ "#ec4899",
969
+ "#06b6d4",
970
+ "#f97316",
971
+ "#6366f1",
972
+ "#14b8a6"
973
+ ];
974
+ function j(i) {
975
+ let { authManager: a, editor: o, channel: s } = i, c = t([]), l = t(/* @__PURE__ */ new Map()), u = 0, d = !1, f = r(() => a.userConfig?.id ?? "");
976
+ function p() {
977
+ let e = A[u % A.length];
978
+ return u++, e;
979
+ }
980
+ function m(e) {
981
+ if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
982
+ let t = {
983
+ id: e.id,
984
+ name: e.name,
985
+ color: p(),
986
+ selectedBlockId: null
987
+ };
988
+ return c.value = [...c.value, t], t;
989
+ }
990
+ function h(e) {
991
+ let t = new Map(l.value);
992
+ for (let [n, r] of t) r.id === e && t.delete(n);
993
+ l.value = t, c.value = c.value.filter((t) => t.id !== e);
994
+ }
995
+ function g(e) {
996
+ let t = c.value.find((t) => t.id === e.userId);
997
+ if (!t) return;
998
+ c.value = c.value.map((t) => t.id === e.userId ? {
999
+ ...t,
1000
+ selectedBlockId: e.blockId
1001
+ } : t);
1002
+ let n = new Map(l.value);
1003
+ for (let [t, r] of n) r.id === e.userId && n.delete(t);
1004
+ n.set(e.blockId, {
1005
+ ...t,
1006
+ selectedBlockId: e.blockId
1007
+ }), l.value = n, o.state.selectedBlockId === e.blockId && o.selectBlock(null);
1008
+ }
1009
+ function _(e) {
1010
+ let t = new Map(l.value), n = t.get(e.blockId);
1011
+ t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1012
+ ...e,
1013
+ selectedBlockId: null
1014
+ } : e));
1015
+ }
1016
+ function y(e) {
1017
+ d = !0;
1018
+ try {
1019
+ v(o, e);
1020
+ } finally {
1021
+ d = !1;
1022
+ }
1023
+ }
1024
+ function b(e) {
1025
+ !s.value || d || s.value.trigger("client-operation", e);
1026
+ }
1027
+ function x(e) {
1028
+ s.value && s.value.trigger("client-block_locked", {
1029
+ blockId: e,
1030
+ userId: f.value
1031
+ });
1032
+ }
1033
+ function S(e) {
1034
+ s.value && s.value.trigger("client-block_unlocked", { blockId: e });
1035
+ }
1036
+ return e(() => o.state.selectedBlockId, (e, t) => {
1037
+ d || (t && S(t), e && x(e));
1038
+ }), e(s, (e, t) => {
1039
+ if (t && k(t), !e) {
1040
+ c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1041
+ return;
1042
+ }
1043
+ let n = e.members;
1044
+ n && n.each((e) => {
1045
+ m(e.info);
1046
+ }), e.bind("pusher:member_added", (e) => {
1047
+ let t = m(e.info);
1048
+ t && i.onCollaboratorJoined?.(t);
1049
+ }), e.bind("pusher:member_removed", (e) => {
1050
+ let t = c.value.find((t) => t.id === e.id);
1051
+ h(e.id), t && i.onCollaboratorLeft?.(t);
1052
+ }), e.bind("client-block_locked", (e) => {
1053
+ g(e);
1054
+ let t = c.value.find((t) => t.id === e.userId);
1055
+ t && i.onBlockLocked?.({
1056
+ blockId: e.blockId,
1057
+ collaborator: t
1058
+ });
1059
+ }), e.bind("client-block_unlocked", (e) => {
1060
+ let t = l.value.get(e.blockId);
1061
+ _(e), t && i.onBlockUnlocked?.({
1062
+ blockId: e.blockId,
1063
+ collaborator: t
1064
+ });
1065
+ }), e.bind("client-operation", (e) => {
1066
+ y(e);
1067
+ }), e.bind("mcp-operation", (e) => {
1068
+ y(e);
1069
+ });
1070
+ }), n(() => {
1071
+ s.value && k(s.value);
1072
+ }), {
1073
+ collaborators: c,
1074
+ lockedBlocks: l,
1075
+ _broadcastOperation: b,
1076
+ _isProcessingRemoteOperation: () => d
1077
+ };
1078
+ }
1079
+ function M(e, t) {
1080
+ let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1081
+ e.addBlock = (e, r, i, a) => {
1082
+ n(e, r, i, a), t._broadcastOperation({
1083
+ operation: "add_block",
1084
+ data: {
1085
+ block: e,
1086
+ section_id: r,
1087
+ column_index: i,
1088
+ index: a
1089
+ },
1090
+ timestamp: Date.now()
1091
+ });
1092
+ }, e.updateBlock = (e, n) => {
1093
+ r(e, n), t._broadcastOperation({
1094
+ operation: "update_block",
1095
+ data: {
1096
+ block_id: e,
1097
+ updates: n
1098
+ },
1099
+ timestamp: Date.now()
1100
+ });
1101
+ }, e.removeBlock = (e) => {
1102
+ i(e), t._broadcastOperation({
1103
+ operation: "delete_block",
1104
+ data: { block_id: e },
1105
+ timestamp: Date.now()
1106
+ });
1107
+ }, e.moveBlock = (e, n, r, i) => {
1108
+ a(e, n, r, i), t._broadcastOperation({
1109
+ operation: "move_block",
1110
+ data: {
1111
+ block_id: e,
1112
+ index: n,
1113
+ section_id: r,
1114
+ column_index: i
1115
+ },
1116
+ timestamp: Date.now()
1117
+ });
1118
+ }, e.updateSettings = (e) => {
1119
+ o(e), t._broadcastOperation({
1120
+ operation: "update_settings",
1121
+ data: { updates: e },
1122
+ timestamp: Date.now()
1123
+ });
1124
+ }, e.setContent = (e, n) => {
1125
+ s(e, n), t._broadcastOperation({
1126
+ operation: "set_content",
1127
+ data: { content: e },
1128
+ timestamp: Date.now()
1129
+ });
1130
+ };
1131
+ }
1132
+ function N(e) {
1133
+ let { authManager: n, onError: r } = e, i = t(null), a = t(!1), o = null, s = null;
1134
+ async function c(e, t) {
1135
+ if (o) return;
1136
+ o = new _({
1137
+ authManager: n,
1138
+ config: t,
1139
+ onError: r
1140
+ }), await o.connect(), s = `presence-template.${e}`;
1141
+ let c = o.subscribePresence(s);
1142
+ c.bind("pusher:subscription_succeeded", () => {
1143
+ a.value = !0, i.value = c;
1144
+ }), c.bind("pusher:subscription_error", (e) => {
1145
+ a.value = !1, i.value = null, r?.(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to subscribe to template channel"));
1146
+ });
1147
+ }
1148
+ function l() {
1149
+ s && o && o.unsubscribe(s), o?.disconnect(), o = null, s = null, i.value = null, a.value = !1;
1150
+ }
1151
+ function u() {
1152
+ return o?.getSocketId() ?? null;
1153
+ }
1154
+ return {
1155
+ channel: i,
1156
+ isConnected: a,
1157
+ connect: c,
1158
+ disconnect: l,
1159
+ getSocketId: u
1160
+ };
1161
+ }
1162
+ function P(e) {
1163
+ let t = new h(e);
1164
+ return {
1165
+ list(e) {
1166
+ return t.listModules(e?.search, e?.category);
1167
+ },
1168
+ create(e) {
1169
+ return t.createModule(e);
1170
+ },
1171
+ update(e, n) {
1172
+ return t.updateModule(e, n);
1173
+ },
1174
+ delete(e) {
1175
+ return t.deleteModule(e);
1176
+ }
1177
+ };
1178
+ }
1179
+ var F = 6e4;
1180
+ function I(e) {
1181
+ let t = new h(e), n = 0;
1182
+ function r(e, r) {
1183
+ let i = Date.now();
1184
+ i - n < F || (n = i, t.createVersion(e, r).catch((e) => {
1185
+ console.warn("[Templatical] Automatic version not recorded — the save itself succeeded:", e);
1186
+ }));
1187
+ }
1188
+ return {
1189
+ load(e) {
1190
+ return t.getTemplate(e);
1191
+ },
1192
+ create(e) {
1193
+ return t.createTemplate(e.content, e.name);
1194
+ },
1195
+ async save(e, n) {
1196
+ let i = await t.updateTemplate(e, n);
1197
+ return n.content && r(e, n.content), i;
1198
+ }
1199
+ };
1200
+ }
1201
+ function L(e) {
1202
+ return {
1203
+ customFonts: e?.customFonts ?? [],
1204
+ defaultFallback: e?.defaultFallback ?? "Arial, sans-serif"
1205
+ };
1206
+ }
1207
+ function R(e) {
1208
+ let t = new h(e.authManager);
1209
+ async function n(e, n) {
1210
+ let r = await t.exportTemplate(e, n);
1211
+ return {
1212
+ html: r.html,
1213
+ mjml: r.mjml
1214
+ };
1215
+ }
1216
+ async function r(e, n) {
1217
+ return (await t.exportTemplate(e, n)).mjml;
1218
+ }
1219
+ return {
1220
+ exportHtml: n,
1221
+ getMjmlSource: r
1222
+ };
1223
+ }
1224
+ function z(e) {
1225
+ let t = R({ authManager: e.authManager });
1226
+ function n(e) {
1227
+ return {
1228
+ customFonts: e.fonts?.customFonts ?? [],
1229
+ defaultFallback: e.fonts?.defaultFallback ?? "Arial, sans-serif"
1230
+ };
1231
+ }
1232
+ async function r() {
1233
+ if (e.getTemplateId() === null) throw Error("[Templatical] Cloud renders from the saved template, so one must exist first. Call create() or load() before toMjml() / toHtml().");
1234
+ return (await e.save()).id;
1235
+ }
1236
+ return {
1237
+ async toMjml(e) {
1238
+ let i = n(e), a = await r();
1239
+ return t.getMjmlSource(a, i);
1240
+ },
1241
+ async toHtml(e) {
1242
+ let i = n(e), a = await r(), { html: o } = await t.exportHtml(a, i);
1243
+ return o;
1244
+ }
1245
+ };
1246
+ }
1247
+ function B(e) {
1248
+ return {
1249
+ id: e.id,
1250
+ createdAt: e.created_at,
1251
+ isAutomatic: e.is_autosave,
1252
+ content: e.content
1253
+ };
1254
+ }
1255
+ function V(e) {
1256
+ let t = new h(e);
1257
+ return {
1258
+ async list(e) {
1259
+ return { versions: (await t.getVersions(e)).map(B) };
1260
+ },
1261
+ async get(e, n) {
1262
+ return (await t.getVersion(e, n)).content;
1263
+ },
1264
+ async create(e, n, r) {
1265
+ return B(await t.createVersion(e, n, r?.label));
1266
+ },
1267
+ restore(e, n) {
1268
+ return t.restoreVersion(e, n);
1269
+ }
1270
+ };
1271
+ }
1272
+ function H(n) {
1273
+ let { authManager: i, isAuthReady: a } = n, o = t(null);
1274
+ a && e(a, (e) => {
1275
+ e && (o.value = i.testEmailConfig);
1276
+ }, { immediate: !0 });
1277
+ let s = r(() => o.value !== null), c = r(() => o.value?.allowedEmails ?? []);
1278
+ function l() {
1279
+ return o.value?.signature ?? null;
1280
+ }
1281
+ return {
1282
+ isEnabled: s,
1283
+ allowedEmails: c,
1284
+ getSignature: l
1285
+ };
1286
+ }
1287
+ function U(e) {
1288
+ let t = new h(e.authManager);
1289
+ return {
1290
+ get allowedRecipients() {
1291
+ return e.allowedEmails.value;
1292
+ },
1293
+ async send({ recipient: n }) {
1294
+ let r = e.getSignature();
1295
+ if (r === null) throw Error("Test email is not enabled for this project");
1296
+ let i = e.getTemplateId();
1297
+ if (i === null) throw Error("Template must be saved before sending a test email");
1298
+ await e.save();
1299
+ let { html: a } = await e.exportHtml(i);
1300
+ e.onBeforeTestEmail && (a = await e.onBeforeTestEmail(a)), await t.sendTestEmail(i, {
1301
+ recipient: n,
1302
+ html: a,
1303
+ allowed_emails: e.allowedEmails.value,
1304
+ signature: r
1305
+ });
1306
+ }
1307
+ };
1308
+ }
1309
+ function W(e) {
1310
+ let { authManager: n, onError: i } = e, a = t(null), o = t(!1), s = new h(n), c = r(() => a.value?.features ?? null);
1311
+ function l(e) {
1312
+ return a.value?.features[e] ?? !1;
1313
+ }
1314
+ async function u() {
1315
+ if (!o.value) {
1316
+ o.value = !0;
1317
+ try {
1318
+ a.value = await s.fetchConfig();
1319
+ } catch (e) {
1320
+ i?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1321
+ } finally {
1322
+ o.value = !1;
1323
+ }
1324
+ }
1325
+ }
1326
+ return {
1327
+ config: a,
1328
+ isLoading: o,
1329
+ hasFeature: l,
1330
+ features: c,
1331
+ fetchConfig: u
1332
+ };
1333
+ }
1334
+ var G = 5e3;
1335
+ function K(e) {
1336
+ return e.authManager ? e.authManager.resolveUrl(m.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${m.health}`;
1337
+ }
1338
+ async function q(e, t) {
1339
+ let n = performance.now();
1340
+ try {
1341
+ let r = t ? await t.authenticatedFetch(m.health, {
1342
+ method: "GET",
1343
+ headers: { Accept: "application/json" }
1344
+ }) : await fetch(e, {
1345
+ method: "GET",
1346
+ headers: { Accept: "application/json" }
1347
+ }), i = Math.round(performance.now() - n);
1348
+ if (r.status === 401) return {
1349
+ api: {
1350
+ ok: !0,
1351
+ latency: i
1352
+ },
1353
+ auth: {
1354
+ ok: !1,
1355
+ error: "HTTP 401"
1356
+ }
1357
+ };
1358
+ if (!r.ok) return {
1359
+ api: {
1360
+ ok: !1,
1361
+ latency: i
1362
+ },
1363
+ auth: {
1364
+ ok: !t,
1365
+ error: t ? `HTTP ${r.status}` : void 0
1366
+ }
1367
+ };
1368
+ let a = await r.json();
1369
+ return {
1370
+ api: {
1371
+ ok: a.status === "ok",
1372
+ latency: i
1373
+ },
1374
+ auth: { ok: !0 },
1375
+ wsConfig: a.websocket
1376
+ };
1377
+ } catch (e) {
1378
+ return {
1379
+ api: {
1380
+ ok: !1,
1381
+ latency: Math.round(performance.now() - n)
1382
+ },
1383
+ auth: {
1384
+ ok: !t,
1385
+ error: t ? e instanceof Error ? e.message : "Authentication check failed" : void 0
1386
+ }
1387
+ };
1388
+ }
1389
+ }
1390
+ async function J(e) {
1391
+ if (!e?.host || !e?.app_key) return {
1392
+ ok: !1,
1393
+ error: "WebSocket configuration not available"
1394
+ };
1395
+ if (typeof WebSocket > "u") return {
1396
+ ok: !1,
1397
+ error: "WebSocket not supported in this environment"
1398
+ };
1399
+ 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`;
1400
+ return new Promise((e) => {
1401
+ let n = null, r = setTimeout(() => {
1402
+ n?.close(), e({
1403
+ ok: !1,
1404
+ error: "WebSocket connection timed out"
1405
+ });
1406
+ }, G);
1407
+ try {
1408
+ n = new WebSocket(t);
1409
+ } catch (t) {
1410
+ clearTimeout(r), e({
1411
+ ok: !1,
1412
+ error: t instanceof Error ? t.message : "WebSocket connection failed"
1413
+ });
1414
+ return;
1415
+ }
1416
+ n.onopen = () => {
1417
+ clearTimeout(r), n?.close(), e({ ok: !0 });
1418
+ }, n.onerror = () => {
1419
+ clearTimeout(r), e({
1420
+ ok: !1,
1421
+ error: "WebSocket connection failed"
1422
+ });
1423
+ };
1424
+ });
1425
+ }
1426
+ async function Y(e = {}) {
1427
+ let t = await q(K(e), e.authManager), n = await J(t.wsConfig);
1428
+ return {
1429
+ api: t.api,
1430
+ websocket: n,
1431
+ auth: t.auth,
1432
+ overall: t.api.ok && t.auth.ok
1433
+ };
1434
+ }
1435
+ function X(t) {
1436
+ let { editor: n, channel: r, onOperation: i } = t;
1437
+ e(r, (e, t) => {
1438
+ t && t.unbind("mcp-operation"), e && e.bind("mcp-operation", (e) => {
1439
+ v(n, e), i?.(e);
1440
+ });
1441
+ });
1442
+ }
1443
+ //#endregion
1444
+ export { N as S, R as _, I as a, C as b, a as c, g as d, x as f, w as g, M as h, P as i, Y as l, j as m, D as n, U as o, S as p, z as r, V as s, o as t, L as u, X as v, H as x, W as y };