@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
@@ -1,1787 +0,0 @@
1
- import { r as e } from "./rolldown-runtime-B0aSnxlc.js";
2
- import { J as t, X as n, Y as r, Z as i, f as a, z as o } from "./draggable-DCs9qL-b.js";
3
- import { R as s, t as c } from "./src-B_QJduQD.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 = 6e4;
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, this._testEmailConfig = i.test_email?.allowed_emails && i.test_email?.signature ? {
83
- allowedEmails: i.test_email.allowed_emails,
84
- signature: i.test_email.signature
85
- } : null, this._userConfig = i.user?.id && i.user?.name && i.user?.signature ? {
86
- id: i.user.id,
87
- name: i.user.name,
88
- signature: i.user.signature
89
- } : 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}` })), t = this.extractFirstValidationError(e);
205
- throw new c(t, 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-BbIHJKf3.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": e.updateBlock(r.block_id, { styles: r.styles });
461
- }
462
- }
463
- //#endregion
464
- //#region ../core/src/cloud/editor.ts
465
- function C(e) {
466
- return e === "1" ? 1 : e === "3" ? 3 : 2;
467
- }
468
- function w(e) {
469
- let t = new y(e.authManager), i = r({
470
- template: null,
471
- content: s(e.defaultFontFamily, e.templateDefaults),
472
- selectedBlockId: null,
473
- viewport: "desktop",
474
- darkMode: !1,
475
- previewMode: !1,
476
- isDirty: !1,
477
- isSaving: !1,
478
- isLoading: !1,
479
- uiTheme: "auto"
480
- }), o = a({
481
- get: () => i.content,
482
- set: (e) => {
483
- i.content = e, i.isDirty = !0;
484
- }
485
- }), l = a(() => i.selectedBlockId ? d(i.content.blocks, i.selectedBlockId) : null), u = a(() => {
486
- let e = /* @__PURE__ */ new Set(), t = i.template?.content?.blocks;
487
- if (!t) return e;
488
- 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);
489
- return e;
490
- });
491
- function d(e, t) {
492
- for (let n of e) {
493
- if (n.id === t) return n;
494
- if (n.type === "section") for (let e of n.children) {
495
- let n = d(e, t);
496
- if (n) return n;
497
- }
498
- }
499
- return null;
500
- }
501
- function f(e, t, n = { blocks: e }) {
502
- for (let r = 0; r < e.length; r++) {
503
- let i = e[r];
504
- if (i.id === t) return n;
505
- if (i.type === "section") for (let e = 0; e < i.children.length; e++) {
506
- let n = f(i.children[e], t, {
507
- blocks: i.children[e],
508
- sectionId: i.id,
509
- columnIndex: e
510
- });
511
- if (n) return n;
512
- }
513
- }
514
- return null;
515
- }
516
- function p(t) {
517
- return e.lockedBlocks?.value.has(t) ?? !1;
518
- }
519
- function m(e, t = !0) {
520
- i.content = e, t && (i.isDirty = !0);
521
- }
522
- function h(e) {
523
- e && p(e) || (i.selectedBlockId = e);
524
- }
525
- function g(e) {
526
- i.viewport = e;
527
- }
528
- function _(e) {
529
- i.darkMode = e;
530
- }
531
- function v(e) {
532
- i.uiTheme = e;
533
- }
534
- function b(e) {
535
- i.previewMode = e, e && (i.selectedBlockId = null);
536
- }
537
- function x(e, t) {
538
- if (p(e)) return;
539
- let n = d(i.content.blocks, e);
540
- n && (Object.assign(n, t), i.isDirty = !0);
541
- }
542
- function S(e) {
543
- i.content.settings = {
544
- ...i.content.settings,
545
- ...e
546
- }, i.isDirty = !0;
547
- }
548
- function w(e, t, n = 0, r) {
549
- if (t) {
550
- let a = d(i.content.blocks, t);
551
- if (a && a.type === "section") {
552
- a.children[n] = a.children[n] || [];
553
- let t = a.children[n];
554
- r !== void 0 && r < t.length ? t.splice(r, 0, e) : t.push(e);
555
- }
556
- } else r !== void 0 && r < i.content.blocks.length ? i.content.blocks.splice(r, 0, e) : i.content.blocks.push(e);
557
- i.isDirty = !0;
558
- }
559
- function T(e) {
560
- if (p(e)) return;
561
- let t = f(i.content.blocks, e);
562
- if (t) {
563
- let n = t.blocks.findIndex((t) => t.id === e);
564
- n !== -1 && (t.blocks.splice(n, 1), i.selectedBlockId === e && (i.selectedBlockId = null), i.isDirty = !0);
565
- }
566
- }
567
- function E(e, t, n, r = 0) {
568
- let a = f(i.content.blocks, e);
569
- if (!a) return;
570
- let o = a.blocks.findIndex((t) => t.id === e);
571
- if (o === -1) return;
572
- let s;
573
- if (n) {
574
- let e = d(i.content.blocks, n);
575
- if (!e || e.type !== "section" || r < 0 || r >= C(e.columns)) return;
576
- e.children[r] = e.children[r] || [], s = e.children[r];
577
- } else s = i.content.blocks;
578
- let [c] = a.blocks.splice(o, 1);
579
- s.splice(t, 0, c), i.isDirty = !0;
580
- }
581
- async function D(n) {
582
- i.isLoading = !0;
583
- try {
584
- n && (i.content = n);
585
- let e = await t.createTemplate(i.content);
586
- return i.template = e, i.isDirty = !1, e;
587
- } catch (t) {
588
- throw e.onError?.(t), t;
589
- } finally {
590
- i.isLoading = !1;
591
- }
592
- }
593
- async function O(n) {
594
- i.isLoading = !0;
595
- try {
596
- let e = await t.getTemplate(n);
597
- return i.template = e, i.content = e.content, i.isDirty = !1, e;
598
- } catch (t) {
599
- throw e.onError?.(t), t;
600
- } finally {
601
- i.isLoading = !1;
602
- }
603
- }
604
- async function k() {
605
- if (!i.template?.id) throw new c("No template loaded. Call create() or load() before saving.");
606
- i.isSaving = !0;
607
- try {
608
- let e = await t.updateTemplate(i.template.id, i.content);
609
- return i.template = e, i.isDirty = !1, e;
610
- } catch (t) {
611
- throw e.onError?.(t), t;
612
- } finally {
613
- i.isSaving = !1;
614
- }
615
- }
616
- async function A() {
617
- if (i.template?.id) try {
618
- await t.createSnapshot(i.template.id, i.content);
619
- } catch (t) {
620
- throw e.onError?.(t), t;
621
- }
622
- }
623
- function j() {
624
- return i.template?.id !== void 0;
625
- }
626
- function M() {
627
- i.isDirty = !0;
628
- }
629
- function N(e) {
630
- let t = f(i.content.blocks, e);
631
- if (!t) return null;
632
- let n = t.blocks.findIndex((t) => t.id === e);
633
- return n === -1 ? null : {
634
- targetSectionId: t.sectionId,
635
- columnIndex: t.columnIndex,
636
- index: n
637
- };
638
- }
639
- return {
640
- state: n(i),
641
- content: o,
642
- selectedBlock: l,
643
- savedBlockIds: u,
644
- isBlockLocked: p,
645
- findBlockLocation: N,
646
- setContent: m,
647
- selectBlock: h,
648
- setViewport: g,
649
- setDarkMode: _,
650
- setUiTheme: v,
651
- setPreviewMode: b,
652
- updateBlock: x,
653
- updateSettings: S,
654
- addBlock: w,
655
- removeBlock: T,
656
- moveBlock: E,
657
- create: D,
658
- load: O,
659
- save: k,
660
- createSnapshot: A,
661
- hasTemplate: j,
662
- markDirty: M
663
- };
664
- }
665
- //#endregion
666
- //#region ../core/src/cloud/ai-chat.ts
667
- var T = 0;
668
- function E() {
669
- return `msg_${Date.now()}_${++T}`;
670
- }
671
- function D(e) {
672
- 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);
673
- function b(e, t) {
674
- let n = o.value.findIndex((t) => t.id === e);
675
- if (n === -1) return;
676
- let r = {
677
- ...o.value[n],
678
- ...t
679
- };
680
- o.value = [
681
- ...o.value.slice(0, n),
682
- r,
683
- ...o.value.slice(n + 1)
684
- ];
685
- }
686
- async function x() {
687
- let e = n();
688
- if (e) {
689
- c.value = !0;
690
- try {
691
- let n = d(v["ai.conversationMessages"], {
692
- project: t.projectId,
693
- tenant: t.tenantSlug,
694
- template: e
695
- }), r = await t.authenticatedFetch(n, {
696
- method: "GET",
697
- headers: { Accept: "application/json" }
698
- });
699
- if (!r.ok) return;
700
- let i = await r.json();
701
- i.conversation_id && (f.value = i.conversation_id), Array.isArray(i.data) && i.data.length > 0 && (o.value = i.data.map((e) => ({
702
- id: e.id,
703
- role: e.role,
704
- content: e.content,
705
- timestamp: new Date(e.created_at).getTime()
706
- })));
707
- } catch {} finally {
708
- c.value = !1;
709
- }
710
- }
711
- }
712
- async function S(e, r) {
713
- let i = n();
714
- if (i) {
715
- y.value = !0;
716
- try {
717
- let n = d(v["ai.suggestions"], {
718
- project: t.projectId,
719
- tenant: t.tenantSlug,
720
- template: i
721
- }), a = await t.authenticatedFetch(n, {
722
- method: "POST",
723
- headers: {
724
- "Content-Type": "application/json",
725
- Accept: "text/event-stream"
726
- },
727
- body: JSON.stringify({
728
- current_content: e,
729
- merge_tags: r.map((e) => ({
730
- label: e.label,
731
- value: e.value
732
- }))
733
- })
734
- });
735
- if (!a.ok) return;
736
- let o = a.body?.getReader();
737
- if (!o) return;
738
- let s = new TextDecoder(), c = "";
739
- for (;;) {
740
- let { done: e, value: t } = await o.read();
741
- if (e) break;
742
- c += s.decode(t, { stream: !0 });
743
- let n = c.split("\n");
744
- c = n.pop() ?? "";
745
- for (let e of n) {
746
- if (!e.startsWith("data: ")) continue;
747
- let t;
748
- try {
749
- t = JSON.parse(e.slice(6));
750
- } catch {
751
- continue;
752
- }
753
- t.type === "done" && Array.isArray(t.suggestions) && (_.value = t.suggestions.slice(0, 3));
754
- }
755
- }
756
- } catch {} finally {
757
- y.value = !1;
758
- }
759
- }
760
- }
761
- async function C(e, i, c) {
762
- let y = n();
763
- if (!y) throw Error("Template must be saved before using AI generation");
764
- s.value = !0, l.value = null, u.value = null, _.value = [];
765
- let x = E();
766
- o.value = [...o.value, {
767
- id: x,
768
- role: "user",
769
- content: e,
770
- timestamp: Date.now()
771
- }];
772
- let S = E();
773
- o.value = [...o.value, {
774
- id: S,
775
- role: "assistant",
776
- content: "",
777
- timestamp: Date.now()
778
- }];
779
- try {
780
- let n = d(v["ai.generate"], {
781
- project: t.projectId,
782
- tenant: t.tenantSlug,
783
- template: y
784
- }), a = await t.authenticatedFetch(n, {
785
- method: "POST",
786
- headers: {
787
- "Content-Type": "application/json",
788
- Accept: "text/event-stream"
789
- },
790
- body: JSON.stringify({
791
- prompt: e,
792
- current_content: i,
793
- merge_tags: c.map((e) => ({
794
- label: e.label,
795
- value: e.value
796
- })),
797
- conversation_id: f.value
798
- })
799
- });
800
- if (!a.ok) {
801
- let e = await a.json().catch(() => null);
802
- throw Error(a.status === 403 ? "ai_generation_not_available" : e?.message || "Failed to generate template");
803
- }
804
- let s = a.body?.getReader();
805
- if (!s) throw Error("Failed to read stream");
806
- let u = new TextDecoder(), _ = "", x = null;
807
- try {
808
- for (;;) {
809
- let { done: e, value: t } = await s.read();
810
- if (e) break;
811
- _ += u.decode(t, { stream: !0 });
812
- let n = _.split("\n");
813
- _ = n.pop() ?? "";
814
- for (let e of n) {
815
- if (!e.startsWith("data: ")) continue;
816
- let t = e.slice(6), n;
817
- try {
818
- n = JSON.parse(t);
819
- } catch {
820
- continue;
821
- }
822
- if (n.type === "text") b(S, { content: (o.value.find((e) => e.id === S)?.content ?? "") + n.text });
823
- else if (n.type === "error") throw Error(n.message || "Failed to generate template");
824
- 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");
825
- }
826
- }
827
- } finally {
828
- s.cancel().catch(() => {});
829
- }
830
- return x;
831
- } catch (t) {
832
- let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
833
- return l.value = n.message, u.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== x && e.id !== S), null;
834
- } finally {
835
- s.value = !1;
836
- }
837
- }
838
- function w() {
839
- g.value ? (h.value && r?.(h.value), g.value = !1) : (m.value && r?.(m.value), g.value = !0);
840
- }
841
- function T() {
842
- o.value = [], f.value = null, l.value = null, p.value = null, m.value = null, h.value = null, g.value = !1;
843
- }
844
- return {
845
- messages: o,
846
- isGenerating: s,
847
- isLoadingHistory: c,
848
- isLastChangeReverted: g,
849
- lastApplyMessageId: p,
850
- error: l,
851
- failedPrompt: u,
852
- suggestions: _,
853
- isLoadingSuggestions: y,
854
- sendPrompt: C,
855
- toggleLastRevert: w,
856
- loadConversation: x,
857
- loadSuggestions: S,
858
- clearChat: T
859
- };
860
- }
861
- //#endregion
862
- //#region ../core/src/cloud/ai-config.ts
863
- function O(e) {
864
- function t(t) {
865
- return e !== !1 && e?.[t] !== !1;
866
- }
867
- return {
868
- isFeatureEnabled: t,
869
- hasAnyMenuFeature: a(() => t("chat") || t("scoring") || t("designToTemplate"))
870
- };
871
- }
872
- //#endregion
873
- //#region ../core/src/cloud/template-scoring.ts
874
- function k(e) {
875
- let { authManager: t, getTemplateId: n } = e, r = i(!1), a = i(null), o = i(null), s = i(null), c = i(""), l = i(null);
876
- async function u(e, i) {
877
- let s = n();
878
- if (!s) return null;
879
- r.value = !0, o.value = null, a.value = null;
880
- try {
881
- let n = d(v["ai.score"], {
882
- project: t.projectId,
883
- tenant: t.tenantSlug,
884
- template: s
885
- }), r = await t.authenticatedFetch(n, {
886
- method: "POST",
887
- headers: {
888
- "Content-Type": "application/json",
889
- Accept: "text/event-stream"
890
- },
891
- body: JSON.stringify({
892
- current_content: e,
893
- merge_tags: i.map((e) => ({
894
- label: e.label,
895
- value: e.value
896
- }))
897
- })
898
- });
899
- if (!r.ok) {
900
- if (r.status === 403) throw Error("ai_generation_not_available");
901
- let e = await r.json().catch(() => null);
902
- throw Error(e?.message || "Failed to score template");
903
- }
904
- let o = r.body?.getReader();
905
- if (!o) throw Error("Failed to read stream");
906
- let c = new TextDecoder(), l = "", u = null;
907
- for (;;) {
908
- let { done: e, value: t } = await o.read();
909
- if (e) break;
910
- l += c.decode(t, { stream: !0 });
911
- let n = l.split("\n");
912
- l = n.pop() ?? "";
913
- for (let e of n) {
914
- if (!e.startsWith("data: ")) continue;
915
- let t;
916
- try {
917
- t = JSON.parse(e.slice(6));
918
- } catch {
919
- continue;
920
- }
921
- if (t.type === "error") throw Error(t.message || "Failed to score template");
922
- t.type === "done" && (u = t.result ?? null);
923
- }
924
- }
925
- if (u) for (let [e, t] of Object.entries(u.categories)) for (let n of t.findings) n.category = e;
926
- return a.value = u, u;
927
- } catch (e) {
928
- return o.value = e instanceof Error ? e.message : "Failed to score template", null;
929
- } finally {
930
- r.value = !1;
931
- }
932
- }
933
- async function f(e, r, i) {
934
- let a = n();
935
- if (!a) return null;
936
- s.value = r.id, c.value = "", l.value = null;
937
- try {
938
- let n = d(v["ai.fixFinding"], {
939
- project: t.projectId,
940
- tenant: t.tenantSlug,
941
- template: a
942
- }), o = await t.authenticatedFetch(n, {
943
- method: "POST",
944
- headers: {
945
- "Content-Type": "application/json",
946
- Accept: "text/event-stream"
947
- },
948
- body: JSON.stringify({
949
- content: e,
950
- finding: {
951
- id: r.id,
952
- message: r.message,
953
- suggestion: r.suggestion,
954
- category: r.category
955
- },
956
- merge_tags: i.map((e) => ({
957
- label: e.label,
958
- value: e.value
959
- }))
960
- })
961
- });
962
- if (!o.ok) {
963
- if (o.status === 403) throw Error("ai_generation_not_available");
964
- let e = await o.json().catch(() => null);
965
- throw Error(e?.message || "Failed to fix finding");
966
- }
967
- let s = o.body?.getReader();
968
- if (!s) throw Error("Failed to read stream");
969
- let l = new TextDecoder(), u = "", f = null;
970
- for (;;) {
971
- let { done: e, value: t } = await s.read();
972
- if (e) break;
973
- u += l.decode(t, { stream: !0 });
974
- let n = u.split("\n");
975
- u = n.pop() ?? "";
976
- for (let e of n) {
977
- if (!e.startsWith("data: ")) continue;
978
- let t;
979
- try {
980
- t = JSON.parse(e.slice(6));
981
- } catch {
982
- continue;
983
- }
984
- if (t.type === "text") c.value += t.text;
985
- else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
986
- else t.type === "done" && (f = t.content ?? null);
987
- }
988
- }
989
- return f;
990
- } catch (e) {
991
- return l.value = e instanceof Error ? e.message : "Failed to fix finding", null;
992
- } finally {
993
- s.value = null;
994
- }
995
- }
996
- function p(e, t) {
997
- if (!a.value) return;
998
- let n = a.value.categories[e];
999
- n && (n.findings = n.findings.filter((e) => e.id !== t));
1000
- }
1001
- function m() {
1002
- r.value = !1, a.value = null, o.value = null, s.value = null, c.value = "", l.value = null;
1003
- }
1004
- return {
1005
- isScoring: r,
1006
- scoringResult: a,
1007
- error: o,
1008
- fixingFindingId: s,
1009
- fixStreamingText: c,
1010
- fixError: l,
1011
- score: u,
1012
- fixFinding: f,
1013
- removeFinding: p,
1014
- reset: m
1015
- };
1016
- }
1017
- //#endregion
1018
- //#region ../core/src/cloud/design-reference.ts
1019
- function A(e) {
1020
- let { authManager: t, getTemplateId: n, onApply: r, onError: a } = e, o = i(!1), s = i(null);
1021
- async function c(e) {
1022
- let i = n();
1023
- if (!i) throw Error("Template must be saved before using design reference");
1024
- o.value = !0, s.value = null;
1025
- try {
1026
- let n = new FormData();
1027
- e.prompt && n.append("prompt", e.prompt), e.imageUpload && n.append("image_upload", e.imageUpload), e.pdfUpload && n.append("pdf_upload", e.pdfUpload);
1028
- let a = d(v["ai.generateFromDesign"], {
1029
- project: t.projectId,
1030
- tenant: t.tenantSlug,
1031
- template: i
1032
- }), o = await t.authenticatedFetch(a, {
1033
- method: "POST",
1034
- headers: { Accept: "text/event-stream" },
1035
- body: n
1036
- });
1037
- if (!o.ok) {
1038
- let e = await o.json().catch(() => null);
1039
- throw Error(o.status === 403 ? "ai_generation_not_available" : e?.message || "Failed to generate template from design");
1040
- }
1041
- let s = o.body?.getReader();
1042
- if (!s) throw Error("Failed to read stream");
1043
- let c = new TextDecoder(), l = "", u = null;
1044
- for (;;) {
1045
- let { done: e, value: t } = await s.read();
1046
- if (e) break;
1047
- l += c.decode(t, { stream: !0 });
1048
- let n = l.split("\n");
1049
- l = n.pop() ?? "";
1050
- for (let e of n) {
1051
- if (!e.startsWith("data: ")) continue;
1052
- let t = e.slice(6), n;
1053
- try {
1054
- n = JSON.parse(t);
1055
- } catch {
1056
- continue;
1057
- }
1058
- if (n.type === "error") throw Error(n.message || "Failed to generate template from design");
1059
- n.type === "done" && (u = n.content ?? null, u && r?.(u));
1060
- }
1061
- }
1062
- return u;
1063
- } catch (e) {
1064
- let t = e instanceof Error ? e : Error("Failed to generate template from design", { cause: e });
1065
- return s.value = t.message, a?.(t), null;
1066
- } finally {
1067
- o.value = !1;
1068
- }
1069
- }
1070
- function l() {
1071
- o.value = !1, s.value = null;
1072
- }
1073
- return {
1074
- isGenerating: o,
1075
- error: s,
1076
- generate: c,
1077
- reset: l
1078
- };
1079
- }
1080
- //#endregion
1081
- //#region ../core/src/cloud/comments.ts
1082
- function j(e) {
1083
- 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(() => {
1084
- let e = 0;
1085
- for (let t of u.value) e += 1 + (t.replies?.length ?? 0);
1086
- return e;
1087
- }), h = a(() => u.value.filter((e) => !e.resolved_at).length), g = a(() => {
1088
- let e = /* @__PURE__ */ new Map();
1089
- 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));
1090
- return e;
1091
- });
1092
- function _() {
1093
- let e = t.userConfig;
1094
- if (!e) throw Error("User config not available");
1095
- return {
1096
- user_id: e.id,
1097
- user_name: e.name,
1098
- user_signature: e.signature
1099
- };
1100
- }
1101
- function v() {
1102
- let e = r?.();
1103
- if (e) return { "X-Socket-ID": e };
1104
- }
1105
- function b(e, t) {
1106
- o?.({
1107
- type: e,
1108
- comment: t
1109
- });
1110
- }
1111
- function x(e) {
1112
- for (let t of u.value) {
1113
- if (t.id === e) return t;
1114
- for (let n of t.replies ?? []) if (n.id === e) return n;
1115
- }
1116
- return null;
1117
- }
1118
- async function S() {
1119
- let e = n();
1120
- if (e) {
1121
- d.value = !0;
1122
- try {
1123
- u.value = await l.getComments(e);
1124
- } catch (e) {
1125
- let t = e instanceof Error ? e : Error("Failed to load comments", { cause: e });
1126
- s?.(t);
1127
- } finally {
1128
- d.value = !1;
1129
- }
1130
- }
1131
- }
1132
- async function C(e, t, r) {
1133
- let i = n();
1134
- if (!i) return null;
1135
- f.value = !0;
1136
- try {
1137
- let n = await l.createComment(i, {
1138
- body: e,
1139
- block_id: t,
1140
- parent_id: r,
1141
- ..._()
1142
- }, v());
1143
- if (r) {
1144
- let e = x(r);
1145
- e && (e.replies = [...e.replies ?? [], n]);
1146
- } else u.value = [...u.value, n];
1147
- return b("created", n), n;
1148
- } catch (e) {
1149
- let t = e instanceof Error ? e : Error("Failed to create comment", { cause: e });
1150
- return s?.(t), null;
1151
- } finally {
1152
- f.value = !1;
1153
- }
1154
- }
1155
- async function w(e, t) {
1156
- let r = n();
1157
- if (!r) return null;
1158
- f.value = !0;
1159
- try {
1160
- let n = await l.updateComment(r, e, {
1161
- body: t,
1162
- ..._()
1163
- }, v());
1164
- return A(e, n), b("updated", n), n;
1165
- } catch (e) {
1166
- let t = e instanceof Error ? e : Error("Failed to update comment", { cause: e });
1167
- return s?.(t), null;
1168
- } finally {
1169
- f.value = !1;
1170
- }
1171
- }
1172
- async function T(e) {
1173
- let t = n();
1174
- if (!t) return !1;
1175
- let r = x(e);
1176
- if (!r) return !1;
1177
- let i = {
1178
- ...r,
1179
- replies: [...r.replies ?? []]
1180
- };
1181
- f.value = !0;
1182
- try {
1183
- if (await l.deleteComment(t, e, _(), v()), r.parent_id) {
1184
- let t = x(r.parent_id);
1185
- t && (t.replies = (t.replies ?? []).filter((t) => t.id !== e));
1186
- } else u.value = u.value.filter((t) => t.id !== e);
1187
- return b("deleted", i), !0;
1188
- } catch (e) {
1189
- let t = e instanceof Error ? e : Error("Failed to delete comment", { cause: e });
1190
- return s?.(t), !1;
1191
- } finally {
1192
- f.value = !1;
1193
- }
1194
- }
1195
- async function E(e) {
1196
- let t = n();
1197
- if (!t) return null;
1198
- f.value = !0;
1199
- try {
1200
- let n = await l.resolveComment(t, e, _(), v());
1201
- return A(e, n), b(n.resolved_at ? "resolved" : "unresolved", n), n;
1202
- } catch (e) {
1203
- let t = e instanceof Error ? e : Error("Failed to toggle comment resolution", { cause: e });
1204
- return s?.(t), null;
1205
- } finally {
1206
- f.value = !1;
1207
- }
1208
- }
1209
- function D(e) {
1210
- if (e.parent_id) {
1211
- let t = x(e.parent_id);
1212
- t && (t.replies = [...t.replies ?? [], e]);
1213
- } else u.value = [...u.value, e];
1214
- b("created", e);
1215
- }
1216
- function O(e) {
1217
- A(e.id, e), b("updated", e);
1218
- }
1219
- function k(e, t) {
1220
- let n = x(e), r = n ? {
1221
- ...n,
1222
- replies: [...n.replies ?? []]
1223
- } : null;
1224
- if (t) {
1225
- let n = x(t);
1226
- n && (n.replies = (n.replies ?? []).filter((t) => t.id !== e));
1227
- } else u.value = u.value.filter((t) => t.id !== e);
1228
- r && b("deleted", r);
1229
- }
1230
- function A(e, t) {
1231
- for (let n = 0; n < u.value.length; n++) {
1232
- if (u.value[n].id === e) {
1233
- u.value = [
1234
- ...u.value.slice(0, n),
1235
- {
1236
- ...t,
1237
- replies: u.value[n].replies
1238
- },
1239
- ...u.value.slice(n + 1)
1240
- ];
1241
- return;
1242
- }
1243
- let r = u.value[n].replies ?? [];
1244
- for (let i = 0; i < r.length; i++) if (r[i].id === e) {
1245
- let e = [
1246
- ...r.slice(0, i),
1247
- t,
1248
- ...r.slice(i + 1)
1249
- ];
1250
- u.value = [
1251
- ...u.value.slice(0, n),
1252
- {
1253
- ...u.value[n],
1254
- replies: e
1255
- },
1256
- ...u.value.slice(n + 1)
1257
- ];
1258
- return;
1259
- }
1260
- }
1261
- }
1262
- return {
1263
- comments: u,
1264
- isLoading: d,
1265
- isSubmitting: f,
1266
- isEnabled: p,
1267
- commentCountByBlock: g,
1268
- totalCount: m,
1269
- unresolvedCount: h,
1270
- loadComments: S,
1271
- addComment: C,
1272
- editComment: w,
1273
- removeComment: T,
1274
- toggleResolve: E,
1275
- applyRemoteCreate: D,
1276
- applyRemoteUpdate: O,
1277
- applyRemoteDelete: k
1278
- };
1279
- }
1280
- //#endregion
1281
- //#region ../core/src/cloud/comment-listener.ts
1282
- function M(e) {
1283
- let { comments: n, channel: r } = e;
1284
- o(r, (e, t) => {
1285
- t && t.unbind("comment-broadcast"), e && e.bind("comment-broadcast", (e) => {
1286
- N(n, e);
1287
- });
1288
- }), t(() => {
1289
- r.value?.unbind("comment-broadcast");
1290
- });
1291
- }
1292
- function N(e, t) {
1293
- switch (t.action) {
1294
- case "comment_created":
1295
- e.applyRemoteCreate(t.comment);
1296
- break;
1297
- case "comment_updated":
1298
- e.applyRemoteUpdate(t.comment);
1299
- break;
1300
- case "comment_deleted":
1301
- e.applyRemoteDelete(t.comment.id, t.comment.parent_id);
1302
- break;
1303
- case "comment_resolved":
1304
- case "comment_unresolved": e.applyRemoteUpdate(t.comment);
1305
- }
1306
- }
1307
- //#endregion
1308
- //#region ../core/src/cloud/collaboration.ts
1309
- var P = [
1310
- "pusher:member_added",
1311
- "pusher:member_removed",
1312
- "client-block_locked",
1313
- "client-block_unlocked",
1314
- "client-operation",
1315
- "mcp-operation"
1316
- ];
1317
- function F(e) {
1318
- for (let t of P) e.unbind(t);
1319
- }
1320
- var I = [
1321
- "#3b82f6",
1322
- "#ef4444",
1323
- "#10b981",
1324
- "#f59e0b",
1325
- "#8b5cf6",
1326
- "#ec4899",
1327
- "#06b6d4",
1328
- "#f97316",
1329
- "#6366f1",
1330
- "#14b8a6"
1331
- ];
1332
- function L(e) {
1333
- let { authManager: n, editor: r, channel: s } = e, c = i([]), l = i(/* @__PURE__ */ new Map()), u = 0, d = !1, f = a(() => n.userConfig?.id ?? "");
1334
- function p() {
1335
- let e = I[u % I.length];
1336
- return u++, e;
1337
- }
1338
- function m(e) {
1339
- if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
1340
- let t = {
1341
- id: e.id,
1342
- name: e.name,
1343
- color: p(),
1344
- selectedBlockId: null
1345
- };
1346
- return c.value = [...c.value, t], t;
1347
- }
1348
- function h(e) {
1349
- let t = new Map(l.value);
1350
- for (let [n, r] of t) r.id === e && t.delete(n);
1351
- l.value = t, c.value = c.value.filter((t) => t.id !== e);
1352
- }
1353
- function g(e) {
1354
- let t = c.value.find((t) => t.id === e.userId);
1355
- if (!t) return;
1356
- c.value = c.value.map((t) => t.id === e.userId ? {
1357
- ...t,
1358
- selectedBlockId: e.blockId
1359
- } : t);
1360
- let n = new Map(l.value);
1361
- for (let [t, r] of n) r.id === e.userId && n.delete(t);
1362
- n.set(e.blockId, {
1363
- ...t,
1364
- selectedBlockId: e.blockId
1365
- }), l.value = n, r.state.selectedBlockId === e.blockId && r.selectBlock(null);
1366
- }
1367
- function _(e) {
1368
- let t = new Map(l.value), n = t.get(e.blockId);
1369
- t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1370
- ...e,
1371
- selectedBlockId: null
1372
- } : e));
1373
- }
1374
- function v(e) {
1375
- d = !0;
1376
- try {
1377
- S(r, e);
1378
- } finally {
1379
- d = !1;
1380
- }
1381
- }
1382
- function y(e) {
1383
- !s.value || d || s.value.trigger("client-operation", e);
1384
- }
1385
- function b(e) {
1386
- s.value && s.value.trigger("client-block_locked", {
1387
- blockId: e,
1388
- userId: f.value
1389
- });
1390
- }
1391
- function x(e) {
1392
- s.value && s.value.trigger("client-block_unlocked", { blockId: e });
1393
- }
1394
- return o(() => r.state.selectedBlockId, (e, t) => {
1395
- d || (t && x(t), e && b(e));
1396
- }), o(s, (t, n) => {
1397
- if (n && F(n), !t) {
1398
- c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1399
- return;
1400
- }
1401
- let r = t.members;
1402
- r && r.each((e) => {
1403
- m(e.info);
1404
- }), t.bind("pusher:member_added", (t) => {
1405
- let n = m(t.info);
1406
- n && e.onCollaboratorJoined?.(n);
1407
- }), t.bind("pusher:member_removed", (t) => {
1408
- let n = c.value.find((e) => e.id === t.id);
1409
- h(t.id), n && e.onCollaboratorLeft?.(n);
1410
- }), t.bind("client-block_locked", (t) => {
1411
- g(t);
1412
- let n = c.value.find((e) => e.id === t.userId);
1413
- n && e.onBlockLocked?.({
1414
- blockId: t.blockId,
1415
- collaborator: n
1416
- });
1417
- }), t.bind("client-block_unlocked", (t) => {
1418
- let n = l.value.get(t.blockId);
1419
- _(t), n && e.onBlockUnlocked?.({
1420
- blockId: t.blockId,
1421
- collaborator: n
1422
- });
1423
- }), t.bind("client-operation", (e) => {
1424
- v(e);
1425
- }), t.bind("mcp-operation", (e) => {
1426
- v(e);
1427
- });
1428
- }), t(() => {
1429
- s.value && F(s.value);
1430
- }), {
1431
- collaborators: c,
1432
- lockedBlocks: l,
1433
- _broadcastOperation: y,
1434
- _isProcessingRemoteOperation: () => d
1435
- };
1436
- }
1437
- //#endregion
1438
- //#region ../core/src/cloud/collaboration-broadcast.ts
1439
- function R(e, t) {
1440
- let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1441
- e.addBlock = (e, r, i, a) => {
1442
- n(e, r, i, a), t._broadcastOperation({
1443
- operation: "add_block",
1444
- data: {
1445
- block: e,
1446
- section_id: r,
1447
- column_index: i,
1448
- index: a
1449
- },
1450
- timestamp: Date.now()
1451
- });
1452
- }, e.updateBlock = (e, n) => {
1453
- r(e, n), t._broadcastOperation({
1454
- operation: "update_block",
1455
- data: {
1456
- block_id: e,
1457
- updates: n
1458
- },
1459
- timestamp: Date.now()
1460
- });
1461
- }, e.removeBlock = (e) => {
1462
- i(e), t._broadcastOperation({
1463
- operation: "delete_block",
1464
- data: { block_id: e },
1465
- timestamp: Date.now()
1466
- });
1467
- }, e.moveBlock = (e, n, r, i) => {
1468
- a(e, n, r, i), t._broadcastOperation({
1469
- operation: "move_block",
1470
- data: {
1471
- block_id: e,
1472
- index: n,
1473
- section_id: r,
1474
- column_index: i
1475
- },
1476
- timestamp: Date.now()
1477
- });
1478
- }, e.updateSettings = (e) => {
1479
- o(e), t._broadcastOperation({
1480
- operation: "update_settings",
1481
- data: { updates: e },
1482
- timestamp: Date.now()
1483
- });
1484
- }, e.setContent = (e, n) => {
1485
- s(e, n), t._broadcastOperation({
1486
- operation: "set_content",
1487
- data: { content: e },
1488
- timestamp: Date.now()
1489
- });
1490
- };
1491
- }
1492
- //#endregion
1493
- //#region ../core/src/cloud/web-socket.ts
1494
- function z(e) {
1495
- let { authManager: t, onError: n } = e, r = i(null), a = i(!1), o = null, s = null;
1496
- async function c(e, i) {
1497
- if (o) return;
1498
- o = new x({
1499
- authManager: t,
1500
- config: i,
1501
- onError: n
1502
- }), await o.connect(), s = `presence-template.${e}`;
1503
- let c = o.subscribePresence(s);
1504
- c.bind("pusher:subscription_succeeded", () => {
1505
- a.value = !0, r.value = c;
1506
- }), c.bind("pusher:subscription_error", (e) => {
1507
- a.value = !1, r.value = null, n?.(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to subscribe to template channel"));
1508
- });
1509
- }
1510
- function l() {
1511
- s && o && o.unsubscribe(s), o?.disconnect(), o = null, s = null, r.value = null, a.value = !1;
1512
- }
1513
- function u() {
1514
- return o?.getSocketId() ?? null;
1515
- }
1516
- return {
1517
- channel: r,
1518
- isConnected: a,
1519
- connect: c,
1520
- disconnect: l,
1521
- getSocketId: u
1522
- };
1523
- }
1524
- //#endregion
1525
- //#region ../core/src/cloud/saved-blocks-provider.ts
1526
- function B(e) {
1527
- let t = new y(e);
1528
- return {
1529
- list(e) {
1530
- return t.listModules(e?.search, e?.category);
1531
- },
1532
- create(e) {
1533
- return t.createModule(e);
1534
- },
1535
- update(e, n) {
1536
- return t.updateModule(e, n);
1537
- },
1538
- delete(e) {
1539
- return t.deleteModule(e);
1540
- }
1541
- };
1542
- }
1543
- //#endregion
1544
- //#region ../core/src/cloud/snapshots.ts
1545
- function V(e) {
1546
- let t = new y(e.authManager), n = i([]), r = i(!1), a = i(!1);
1547
- async function o() {
1548
- r.value = !0;
1549
- try {
1550
- n.value = await t.getSnapshots(e.templateId);
1551
- } catch (t) {
1552
- throw e.onError?.(t), t;
1553
- } finally {
1554
- r.value = !1;
1555
- }
1556
- }
1557
- async function s(n) {
1558
- a.value = !0;
1559
- try {
1560
- let r = await t.restoreSnapshot(e.templateId, n);
1561
- return e.onRestore?.(r), r;
1562
- } catch (t) {
1563
- throw e.onError?.(t), t;
1564
- } finally {
1565
- a.value = !1;
1566
- }
1567
- }
1568
- return {
1569
- snapshots: n,
1570
- isLoading: r,
1571
- isRestoring: a,
1572
- loadSnapshots: o,
1573
- restoreSnapshot: s
1574
- };
1575
- }
1576
- //#endregion
1577
- //#region ../core/src/cloud/test-email.ts
1578
- function H(e) {
1579
- let { authManager: t, isAuthReady: n } = e, r = i(null);
1580
- n && o(n, (e) => {
1581
- e && (r.value = t.testEmailConfig);
1582
- }, { immediate: !0 });
1583
- let s = a(() => r.value !== null), c = a(() => r.value?.allowedEmails ?? []);
1584
- function l() {
1585
- return r.value?.signature ?? null;
1586
- }
1587
- return {
1588
- isEnabled: s,
1589
- allowedEmails: c,
1590
- getSignature: l
1591
- };
1592
- }
1593
- //#endregion
1594
- //#region ../core/src/cloud/test-email-provider.ts
1595
- function U(e) {
1596
- let t = new y(e.authManager);
1597
- return {
1598
- get allowedRecipients() {
1599
- return e.allowedEmails.value;
1600
- },
1601
- async send({ recipient: n }) {
1602
- let r = e.getSignature();
1603
- if (r === null) throw Error("Test email is not enabled for this project");
1604
- let i = e.getTemplateId();
1605
- if (i === null) throw Error("Template must be saved before sending a test email");
1606
- await e.save();
1607
- let { html: a } = await e.exportHtml(i);
1608
- e.onBeforeTestEmail && (a = await e.onBeforeTestEmail(a)), await t.sendTestEmail(i, {
1609
- recipient: n,
1610
- html: a,
1611
- allowed_emails: e.allowedEmails.value,
1612
- signature: r
1613
- });
1614
- }
1615
- };
1616
- }
1617
- //#endregion
1618
- //#region ../core/src/cloud/export.ts
1619
- function W(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 G(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 K = 5e3;
1674
- function q(e) {
1675
- return e.authManager ? e.authManager.resolveUrl(v.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${v.health}`;
1676
- }
1677
- async function J(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 Y(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
- }, K);
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 X(e = {}) {
1766
- let t = await J(q(e), e.authManager), n = await Y(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 Z(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 { l as C, d as S, D as _, U as a, y as b, B as c, L as d, M as f, O as g, k as h, W as i, z as l, A as m, X as n, H as o, j as p, G as r, V as s, Z as t, R as u, w as v, u as w, v as x, b as y };
1786
-
1787
- //# sourceMappingURL=cloud-DcC8bPwn.js.map