@templatical/editor 0.48.0 → 0.50.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 (396) hide show
  1. package/README.md +4 -2
  2. package/dist/AiAltTextPopover-BZQ95GXL.js +106 -0
  3. package/dist/AiAltTextReview-DoBEudnE.js +206 -0
  4. package/dist/AiChatPanel-Bs6sES3b.js +550 -0
  5. package/dist/AiHeaderMenu-BEaTazx4.js +36 -0
  6. package/dist/AiPanels-CfN7A-ZA.js +33 -0
  7. package/dist/AiRewriteMenu-C3ZfDDYy.js +276 -0
  8. package/dist/{BlockIssueBadge-BShkuJis.js → BlockIssueBadge-CKwZ1Vgn.js} +11 -11
  9. package/dist/{BlockPreviewCanvas-tzAtDkXH.js → BlockPreviewCanvas-BXNLLLYi.js} +33 -33
  10. package/dist/CloudHeaderExtras-CsJMEiyN.js +23 -0
  11. package/dist/CloudPanels-B4F5m7vy.js +168 -0
  12. package/dist/CollaborationNotices-CNuDp7Y2.js +76 -0
  13. package/dist/CollaboratorBar-BtHPiuHq.js +123 -0
  14. package/dist/{CommentsPanel-DiWzYtnZ.js → CommentsPanel-CyCM-BvT.js} +4 -4
  15. package/dist/CommentsSidebar-Ca3DyFOX.js +500 -0
  16. package/dist/{cdn/chunks/CountdownBlock-Dasj191h.js → CountdownBlock-DR4Xm2-T.js} +24 -26
  17. package/dist/{CountdownToolbar-C4y3Ft7H.js → CountdownToolbar-CEIMPojJ.js} +56 -56
  18. package/dist/IssuesPanel-C8nMUccy.js +360 -0
  19. package/dist/{LoadingTrack-6XsqodoY.js → LoadingTrack-B0RKQWq3.js} +2 -2
  20. package/dist/{LogicTagInsertButton-B1_Wy0AN.js → LogicTagInsertButton-CqfU52CO.js} +272 -267
  21. package/dist/{cdn/chunks/MediaEditModal-zXfcArr4.js → MediaEditModal-DHtkZ4OU.js} +202 -186
  22. package/dist/{MediaPanels-9mDBv4aL.js → MediaPanels-CGcOB2pR.js} +4 -4
  23. package/dist/{MergeTagInput-fOewuF27.js → MergeTagInput-YnEkorTZ.js} +26 -26
  24. package/dist/{MergeTagModeToggle-BXamLcv7.js → MergeTagModeToggle-Dhb1DAcQ.js} +40 -40
  25. package/dist/MergeTagTextarea-e4lnwtqZ.js +70 -0
  26. package/dist/ParagraphEditor-B6NK0ytw.js +799 -0
  27. package/dist/{RestoreVersionDialog-BEKXx9xk.js → RestoreVersionDialog-Bq_IGOLJ.js} +22 -22
  28. package/dist/{RichTextEditorContent-D7kp7iig.js → RichTextEditorContent-AOM6fylS.js} +48 -48
  29. package/dist/{SaveBlockDialog-SJu0lecx.js → SaveBlockDialog-C8GngfQx.js} +88 -88
  30. package/dist/{cdn/chunks/SavedBlocksBrowserModal-CtnB58p_.js → SavedBlocksBrowserModal-wnkvxpm_.js} +102 -99
  31. package/dist/{SavedBlocksPanels-Dr5Fxx9Z.js → SavedBlocksPanels-C2s3q0pJ.js} +9 -9
  32. package/dist/{SavedBlocksPickBar-DnEWBZJy.js → SavedBlocksPickBar-BjcTiV87.js} +14 -14
  33. package/dist/TemplateSettings-BVBWpiDU.js +237 -0
  34. package/dist/{TestEmailModal-CbRY8HQx.js → TestEmailModal-SyhO9bn3.js} +57 -57
  35. package/dist/{TestEmailPanel-NAOmt3xi.js → TestEmailPanel-BDd2Rtav.js} +4 -4
  36. package/dist/{TitleEditor-Cc3DHbuN.js → TitleEditor-pxD53y_l.js} +75 -75
  37. package/dist/ToggleSwitch-D51U9cmR.js +37 -0
  38. package/dist/Toolbar-CZSPZYbj.js +3153 -0
  39. package/dist/{TplModal-Bz4-IZ9R.js → TplModal-DCzBzicE.js} +19 -19
  40. package/dist/{VersionHistoryMenu-CjV1d1zk.js → VersionHistoryMenu-BQeWPT85.js} +35 -35
  41. package/dist/{VersionHistoryPanels-BtwxrKJn.js → VersionHistoryPanels-BBm7YbRQ.js} +5 -5
  42. package/dist/{VersionPreviewBanner-BLAei1kj.js → VersionPreviewBanner-DUGF0tUJ.js} +10 -10
  43. package/dist/WrapperBlock-BO619LAb.js +45 -0
  44. package/dist/aiErrors-D5UOoYOt.js +41 -0
  45. package/dist/aiImageContext-BH4Ss1h3.js +48 -0
  46. package/dist/aiRewritePreview-DLGM05Ge.js +44 -0
  47. package/dist/{blockTypeIcons-CEDZytqP.js → blockTypeIcons-NzaYvAI4.js} +15 -14
  48. package/dist/bundle-stats.json +8 -8
  49. package/dist/{cdn/chunks/ca-CbNzJM3I.js → ca-C7mTzW1r.js} +147 -8
  50. package/dist/cdn/chunks/AiAltTextPopover-CQu0Q_ZX.js +107 -0
  51. package/dist/cdn/chunks/AiAltTextPopover-CQu0Q_ZX.js.map +1 -0
  52. package/dist/cdn/chunks/AiAltTextReview-CI2HbWfn.js +207 -0
  53. package/dist/cdn/chunks/AiAltTextReview-CI2HbWfn.js.map +1 -0
  54. package/dist/cdn/chunks/AiChatPanel-BYqn1bKu.js +476 -0
  55. package/dist/cdn/chunks/AiChatPanel-BYqn1bKu.js.map +1 -0
  56. package/dist/cdn/chunks/AiHeaderMenu-oldAAFyL.js +37 -0
  57. package/dist/cdn/chunks/AiHeaderMenu-oldAAFyL.js.map +1 -0
  58. package/dist/cdn/chunks/AiPanels-CIFKQv8Y.js +34 -0
  59. package/dist/cdn/chunks/AiPanels-CIFKQv8Y.js.map +1 -0
  60. package/dist/cdn/chunks/AiRewriteMenu-Bhh71zcc.js +208 -0
  61. package/dist/cdn/chunks/AiRewriteMenu-Bhh71zcc.js.map +1 -0
  62. package/dist/cdn/chunks/{BlockIssueBadge-C7sdnkrF.js → BlockIssueBadge-DAn2vsMJ.js} +13 -13
  63. package/dist/cdn/chunks/{BlockIssueBadge-C7sdnkrF.js.map → BlockIssueBadge-DAn2vsMJ.js.map} +1 -1
  64. package/dist/cdn/chunks/{BlockPreviewCanvas-vK5tBazr.js → BlockPreviewCanvas-D0--EQkP.js} +39 -39
  65. package/dist/cdn/chunks/{BlockPreviewCanvas-vK5tBazr.js.map → BlockPreviewCanvas-D0--EQkP.js.map} +1 -1
  66. package/dist/cdn/chunks/CloudHeaderExtras-DaUU8P8R.js +25 -0
  67. package/dist/cdn/chunks/CloudHeaderExtras-DaUU8P8R.js.map +1 -0
  68. package/dist/cdn/chunks/{CloudPanels-awqHfJqC.js → CloudPanels-C3jsxo_f.js} +52 -100
  69. package/dist/cdn/chunks/CloudPanels-C3jsxo_f.js.map +1 -0
  70. package/dist/cdn/chunks/CollaborationNotices-DjRI8gvs.js +78 -0
  71. package/dist/cdn/chunks/CollaborationNotices-DjRI8gvs.js.map +1 -0
  72. package/dist/cdn/chunks/CollaboratorBar-Dfzm6A9A.js +72 -0
  73. package/dist/cdn/chunks/CollaboratorBar-Dfzm6A9A.js.map +1 -0
  74. package/dist/cdn/chunks/CommentsPanel-CSO79OeX.js +20 -0
  75. package/dist/cdn/chunks/{CommentsPanel-CbzxwsyI.js.map → CommentsPanel-CSO79OeX.js.map} +1 -1
  76. package/dist/cdn/chunks/CommentsSidebar-CCvplq1Z.js +470 -0
  77. package/dist/cdn/chunks/{CommentsSidebar-DWPHZuQm.js.map → CommentsSidebar-CCvplq1Z.js.map} +1 -1
  78. package/dist/{CountdownBlock-zx39Dyby.js → cdn/chunks/CountdownBlock-C6USdwk3.js} +19 -17
  79. package/dist/cdn/chunks/{CountdownBlock-Dasj191h.js.map → CountdownBlock-C6USdwk3.js.map} +1 -1
  80. package/dist/cdn/chunks/{CountdownToolbar-Cqg8FUH-.js → CountdownToolbar-Cjud2Tos.js} +71 -71
  81. package/dist/cdn/chunks/{CountdownToolbar-Cqg8FUH-.js.map → CountdownToolbar-Cjud2Tos.js.map} +1 -1
  82. package/dist/cdn/chunks/IssuesPanel-BaWHPDxZ.js +340 -0
  83. package/dist/cdn/chunks/IssuesPanel-BaWHPDxZ.js.map +1 -0
  84. package/dist/cdn/chunks/{LoadingTrack-DbH97JR9.js → LoadingTrack-BIcL4NiY.js} +2 -2
  85. package/dist/cdn/chunks/{LoadingTrack-DbH97JR9.js.map → LoadingTrack-BIcL4NiY.js.map} +1 -1
  86. package/dist/cdn/chunks/{LogicTagInsertButton-BMB9vShs.js → LogicTagInsertButton-CsL2JDOG.js} +374 -369
  87. package/dist/cdn/chunks/LogicTagInsertButton-CsL2JDOG.js.map +1 -0
  88. package/dist/{MediaEditModal-ByOvznRC.js → cdn/chunks/MediaEditModal-BuHCiyMu.js} +544 -560
  89. package/dist/cdn/chunks/MediaEditModal-BuHCiyMu.js.map +1 -0
  90. package/dist/cdn/chunks/MediaPanels-DAgUf_T1.js +45 -0
  91. package/dist/cdn/chunks/{MediaPanels-Cp4XB_dH.js.map → MediaPanels-DAgUf_T1.js.map} +1 -1
  92. package/dist/cdn/chunks/{MergeTagInput-DLqrA9co.js → MergeTagInput-C8U-7LxL.js} +34 -34
  93. package/dist/cdn/chunks/{MergeTagInput-DLqrA9co.js.map → MergeTagInput-C8U-7LxL.js.map} +1 -1
  94. package/dist/cdn/chunks/{MergeTagModeToggle-BRiJzzn5.js → MergeTagModeToggle-Mm-p0A52.js} +41 -41
  95. package/dist/cdn/chunks/{MergeTagModeToggle-BRiJzzn5.js.map → MergeTagModeToggle-Mm-p0A52.js.map} +1 -1
  96. package/dist/cdn/chunks/MergeTagTextarea-DuLScsWM.js +72 -0
  97. package/dist/cdn/chunks/MergeTagTextarea-DuLScsWM.js.map +1 -0
  98. package/dist/cdn/chunks/ParagraphEditor-CqSj6Ayz.js +634 -0
  99. package/dist/cdn/chunks/ParagraphEditor-CqSj6Ayz.js.map +1 -0
  100. package/dist/cdn/chunks/{RestoreVersionDialog-BgR6RXSb.js → RestoreVersionDialog-CdA5osuA.js} +26 -26
  101. package/dist/cdn/chunks/{RestoreVersionDialog-BgR6RXSb.js.map → RestoreVersionDialog-CdA5osuA.js.map} +1 -1
  102. package/dist/cdn/chunks/{RichTextEditorContent-C4DMAn0g.js → RichTextEditorContent-Q1d2xqBT.js} +46 -46
  103. package/dist/cdn/chunks/{RichTextEditorContent-C4DMAn0g.js.map → RichTextEditorContent-Q1d2xqBT.js.map} +1 -1
  104. package/dist/cdn/chunks/{SaveBlockDialog-BaIsQd09.js → SaveBlockDialog-CijargAy.js} +78 -78
  105. package/dist/cdn/chunks/{SaveBlockDialog-BaIsQd09.js.map → SaveBlockDialog-CijargAy.js.map} +1 -1
  106. package/dist/cdn/chunks/SavedBlocksBrowserModal-DtOz_X5S.js +357 -0
  107. package/dist/cdn/chunks/{SavedBlocksBrowserModal-CtnB58p_.js.map → SavedBlocksBrowserModal-DtOz_X5S.js.map} +1 -1
  108. package/dist/cdn/chunks/SavedBlocksPanels-BowyED5h.js +38 -0
  109. package/dist/cdn/chunks/{SavedBlocksPanels-BhEOMzEQ.js.map → SavedBlocksPanels-BowyED5h.js.map} +1 -1
  110. package/dist/cdn/chunks/{SavedBlocksPickBar-CcdqTEIp.js → SavedBlocksPickBar-BPRaJBv3.js} +19 -19
  111. package/dist/cdn/chunks/{SavedBlocksPickBar-CcdqTEIp.js.map → SavedBlocksPickBar-BPRaJBv3.js.map} +1 -1
  112. package/dist/cdn/chunks/TemplateSettings-ByZeBO34.js +209 -0
  113. package/dist/cdn/chunks/{TemplateSettings-BkkWTDHD.js.map → TemplateSettings-ByZeBO34.js.map} +1 -1
  114. package/dist/cdn/chunks/{TestEmailModal-V5mwHsUV.js → TestEmailModal-BUVTj3Ic.js} +54 -54
  115. package/dist/cdn/chunks/{TestEmailModal-V5mwHsUV.js.map → TestEmailModal-BUVTj3Ic.js.map} +1 -1
  116. package/dist/cdn/chunks/TestEmailPanel-BxutYoWg.js +35 -0
  117. package/dist/cdn/chunks/{TestEmailPanel-DxrKuctP.js.map → TestEmailPanel-BxutYoWg.js.map} +1 -1
  118. package/dist/cdn/chunks/TitleEditor-Ccv6uoTz.js +199 -0
  119. package/dist/cdn/chunks/{TitleEditor-CsZiG3TT.js.map → TitleEditor-Ccv6uoTz.js.map} +1 -1
  120. package/dist/cdn/chunks/ToggleSwitch-Ctdmj621.js +39 -0
  121. package/dist/cdn/chunks/ToggleSwitch-Ctdmj621.js.map +1 -0
  122. package/dist/cdn/chunks/{Toolbar-C_x2TfFk.js → Toolbar-DoprRgTn.js} +1097 -1101
  123. package/dist/cdn/chunks/Toolbar-DoprRgTn.js.map +1 -0
  124. package/dist/cdn/chunks/{TplModal-DC_eodTV.js → TplModal-BXQzmsJX.js} +21 -21
  125. package/dist/cdn/chunks/{TplModal-DC_eodTV.js.map → TplModal-BXQzmsJX.js.map} +1 -1
  126. package/dist/cdn/chunks/{VersionHistoryMenu-DXnM5Df2.js → VersionHistoryMenu-BF2fNCvq.js} +41 -41
  127. package/dist/cdn/chunks/{VersionHistoryMenu-DXnM5Df2.js.map → VersionHistoryMenu-BF2fNCvq.js.map} +1 -1
  128. package/dist/cdn/chunks/VersionHistoryPanels-Dal0Uk69.js +48 -0
  129. package/dist/cdn/chunks/{VersionHistoryPanels-DXSqmaLS.js.map → VersionHistoryPanels-Dal0Uk69.js.map} +1 -1
  130. package/dist/cdn/chunks/{VersionPreviewBanner-DKyN6BhO.js → VersionPreviewBanner-BaGcn-b1.js} +13 -13
  131. package/dist/cdn/chunks/{VersionPreviewBanner-DKyN6BhO.js.map → VersionPreviewBanner-BaGcn-b1.js.map} +1 -1
  132. package/dist/cdn/chunks/WrapperBlock-DkQJtLz0.js +47 -0
  133. package/dist/cdn/chunks/{WrapperBlock-gG_Bleug.js.map → WrapperBlock-DkQJtLz0.js.map} +1 -1
  134. package/dist/cdn/chunks/aiErrors-D5UOoYOt.js +43 -0
  135. package/dist/cdn/chunks/aiErrors-D5UOoYOt.js.map +1 -0
  136. package/dist/cdn/chunks/aiImageContext-BH4Ss1h3.js +50 -0
  137. package/dist/cdn/chunks/aiImageContext-BH4Ss1h3.js.map +1 -0
  138. package/dist/cdn/chunks/aiRewritePreview-DLGM05Ge.js +46 -0
  139. package/dist/cdn/chunks/aiRewritePreview-DLGM05Ge.js.map +1 -0
  140. package/dist/cdn/chunks/blockTypeIcons-ikZAmd6U.js +22 -0
  141. package/dist/cdn/chunks/{blockTypeIcons-HrMJDfVg.js.map → blockTypeIcons-ikZAmd6U.js.map} +1 -1
  142. package/dist/{ca-CbNzJM3I.js → cdn/chunks/ca-C7mTzW1r.js} +149 -6
  143. package/dist/cdn/chunks/ca-C7mTzW1r.js.map +1 -0
  144. package/dist/cdn/chunks/createCloudRuntime-DpBWhrv3.js +1408 -0
  145. package/dist/cdn/chunks/createCloudRuntime-DpBWhrv3.js.map +1 -0
  146. package/dist/cdn/chunks/de-DBOTcDj2.js +22 -0
  147. package/dist/cdn/chunks/de-DBOTcDj2.js.map +1 -0
  148. package/dist/{de-DMquBpZM.js → cdn/chunks/de-DNuYQTmS.js} +149 -6
  149. package/dist/cdn/chunks/de-DNuYQTmS.js.map +1 -0
  150. package/dist/{dist-CUWI-IvA.js → cdn/chunks/dist-Bo8Thh8v.js} +60 -58
  151. package/dist/cdn/chunks/{dist-CjL6JHML.js.map → dist-Bo8Thh8v.js.map} +1 -1
  152. package/dist/cdn/chunks/dist-S-rLGqax.js +406 -0
  153. package/dist/cdn/chunks/{dist-MNQYSEWU.js.map → dist-S-rLGqax.js.map} +1 -1
  154. package/dist/cdn/chunks/{draggable-DrsNwZuB.js → draggable-DZ0gwUJ6.js} +1359 -1266
  155. package/dist/cdn/chunks/draggable-DZ0gwUJ6.js.map +1 -0
  156. package/dist/cdn/chunks/{editor-modal-vEEmZ8Tu.js → editor-modal-CI6EfeMd.js} +881 -881
  157. package/dist/cdn/chunks/{editor-modal-vEEmZ8Tu.js.map → editor-modal-CI6EfeMd.js.map} +1 -1
  158. package/dist/cdn/chunks/en-CDhWRrF_.js +22 -0
  159. package/dist/cdn/chunks/en-CDhWRrF_.js.map +1 -0
  160. package/dist/{en-C8Mp71sO.js → cdn/chunks/en-CW71OK66.js} +149 -6
  161. package/dist/cdn/chunks/en-CW71OK66.js.map +1 -0
  162. package/dist/cdn/chunks/en-ifvu6oPv.js +1 -0
  163. package/dist/{es-Byq4tthI.js → cdn/chunks/es-DdK7zQfi.js} +149 -6
  164. package/dist/cdn/chunks/es-DdK7zQfi.js.map +1 -0
  165. package/dist/cdn/chunks/{extensions-hJ9VqzDc.js → extensions-taJTZlLK.js} +71 -71
  166. package/dist/cdn/chunks/{extensions-hJ9VqzDc.js.map → extensions-taJTZlLK.js.map} +1 -1
  167. package/dist/{fr-B3j35HEw.js → cdn/chunks/fr-Dz5Bgb7-.js} +149 -6
  168. package/dist/cdn/chunks/fr-Dz5Bgb7-.js.map +1 -0
  169. package/dist/cdn/chunks/{icons-aTYwH5-g.js → icons-DNX6StSs.js} +183 -150
  170. package/dist/cdn/chunks/icons-DNX6StSs.js.map +1 -0
  171. package/dist/{ja-D7txAuGS.js → cdn/chunks/ja-Di-zJiT8.js} +149 -6
  172. package/dist/cdn/chunks/ja-Di-zJiT8.js.map +1 -0
  173. package/dist/cdn/chunks/keys-BTpmg2Tt.js +12 -0
  174. package/dist/cdn/chunks/keys-BTpmg2Tt.js.map +1 -0
  175. package/dist/{logger-BBlvSn6q.js → cdn/chunks/logger-Tj0RPskW.js} +7 -1
  176. package/dist/cdn/chunks/logger-Tj0RPskW.js.map +1 -0
  177. package/dist/{nl-ClJ3BY3F.js → cdn/chunks/nl-CvVuHYFL.js} +149 -6
  178. package/dist/cdn/chunks/nl-CvVuHYFL.js.map +1 -0
  179. package/dist/cdn/chunks/normalizeMergeTagMarkup-DyePIGqu.js +199 -0
  180. package/dist/cdn/chunks/normalizeMergeTagMarkup-DyePIGqu.js.map +1 -0
  181. package/dist/cdn/chunks/{preRenderCustomBlocks-ByfuSjtL.js → preRenderCustomBlocks-Dc-QLntG.js} +4 -4
  182. package/dist/cdn/chunks/{preRenderCustomBlocks-ByfuSjtL.js.map → preRenderCustomBlocks-Dc-QLntG.js.map} +1 -1
  183. package/dist/cdn/chunks/pt-BR-CHM-ZKvE.js +22 -0
  184. package/dist/cdn/chunks/pt-BR-CHM-ZKvE.js.map +1 -0
  185. package/dist/{pt-BR-DibcXcmv.js → cdn/chunks/pt-BR-ZhO4vgyq.js} +149 -6
  186. package/dist/cdn/chunks/pt-BR-ZhO4vgyq.js.map +1 -0
  187. package/dist/cdn/chunks/{pusher-C8DeiO2X.js → pusher-Cs4GGEtd.js} +2 -2
  188. package/dist/cdn/chunks/pusher-Cs4GGEtd.js.map +1 -0
  189. package/dist/cdn/chunks/{rolldown-runtime-B0aSnxlc.js → rolldown-runtime-Y_bBpyJl.js} +1 -1
  190. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js +62 -0
  191. package/dist/cdn/chunks/sanitizeRichTextHtml-DeISfLFr.js.map +1 -0
  192. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js +2032 -0
  193. package/dist/cdn/chunks/socialIcons-BBvsTwCV.js.map +1 -0
  194. package/dist/cdn/chunks/{src-DYCDeBDM.js → src-BNFnxfrA.js} +694 -329
  195. package/dist/cdn/chunks/src-BNFnxfrA.js.map +1 -0
  196. package/dist/cdn/chunks/{src-dZ4D_tuP.js → src-BcTUmgLe.js} +181 -181
  197. package/dist/cdn/chunks/src-BcTUmgLe.js.map +1 -0
  198. package/dist/cdn/chunks/src-Bs_yxk3h.js +4392 -0
  199. package/dist/cdn/chunks/src-Bs_yxk3h.js.map +1 -0
  200. package/dist/cdn/chunks/{styleConstants-D1Jz-TFU.js → styleConstants-v1dNKgJf.js} +2 -4
  201. package/dist/cdn/chunks/{styleConstants-D1Jz-TFU.js.map → styleConstants-v1dNKgJf.js.map} +1 -1
  202. package/dist/cdn/chunks/{tiptap-BPigZk5G.js → tiptap-CtVrAViq.js} +44 -44
  203. package/dist/cdn/chunks/tiptap-CtVrAViq.js.map +1 -0
  204. package/dist/cdn/chunks/{useCloudI18n-BBF4waXO.js → useCloudI18n-AVXhzbhQ.js} +4 -4
  205. package/dist/cdn/chunks/{useCloudI18n-BBF4waXO.js.map → useCloudI18n-AVXhzbhQ.js.map} +1 -1
  206. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js +2586 -0
  207. package/dist/cdn/chunks/useEditorCore-CCVFi1YZ.js.map +1 -0
  208. package/dist/cdn/chunks/useEditorRoot-CR5GjJD6.js +10 -0
  209. package/dist/cdn/chunks/{useEditorRoot-CTc6O8al.js.map → useEditorRoot-CR5GjJD6.js.map} +1 -1
  210. package/dist/cdn/chunks/{useI18n-DUlyyIJJ.js → useI18n-CbVubQhM.js} +3 -3
  211. package/dist/cdn/chunks/{useI18n-DUlyyIJJ.js.map → useI18n-CbVubQhM.js.map} +1 -1
  212. package/dist/cdn/chunks/{useLogicTag-HsyUCQtl.js → useLogicTag-B49Nc53Y.js} +5 -5
  213. package/dist/cdn/chunks/{useLogicTag-HsyUCQtl.js.map → useLogicTag-B49Nc53Y.js.map} +1 -1
  214. package/dist/cdn/chunks/{useMergeTag-Dg9pE85U.js → useMergeTag-B0KryMj8.js} +7 -7
  215. package/dist/cdn/chunks/{useMergeTag-Dg9pE85U.js.map → useMergeTag-B0KryMj8.js.map} +1 -1
  216. package/dist/cdn/chunks/{usePopoverPosition-IbaW6-Ao.js → usePopoverPosition-C829ps5i.js} +4 -4
  217. package/dist/cdn/chunks/{usePopoverPosition-IbaW6-Ao.js.map → usePopoverPosition-C829ps5i.js.map} +1 -1
  218. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js +51 -0
  219. package/dist/cdn/chunks/useScrollToBlock-CAwvulog.js.map +1 -0
  220. package/dist/cdn/chunks/{withCurrentFont-oLcATrQ8.js → withCurrentFont-DFPXeVfG.js} +2 -2
  221. package/dist/cdn/chunks/{withCurrentFont-oLcATrQ8.js.map → withCurrentFont-DFPXeVfG.js.map} +1 -1
  222. package/dist/cdn/editor.css +1 -1
  223. package/dist/cdn/editor.js +2235 -1311
  224. package/dist/cdn/editor.js.map +1 -1
  225. package/dist/{check-ClwqRMgv.js → check-yYsp5Xpk.js} +1 -1
  226. package/dist/{chevron-down-te6qn-zE.js → chevron-down-DTmD06_j.js} +1 -1
  227. package/dist/{chevron-right-W2hbH1FM.js → chevron-right-BSeYZOxc.js} +1 -1
  228. package/dist/{chevron-up-Bf5Zo7o4.js → chevron-up-BOApwrxi.js} +1 -1
  229. package/dist/{circle-alert-CIEGV5DN.js → circle-alert-BMszY8im.js} +1 -1
  230. package/dist/{clock-Y4cx0gkJ.js → clock-HADxnl6-.js} +1 -1
  231. package/dist/createCloudRuntime-DVQI_ReU.js +1379 -0
  232. package/dist/{createLucideIcon-CYHXK9hn.js → createLucideIcon-0lYYH3EW.js} +6 -6
  233. package/dist/de-DBOTcDj2.js +20 -0
  234. package/dist/{cdn/chunks/de-DMquBpZM.js → de-DNuYQTmS.js} +147 -8
  235. package/dist/{cdn/chunks/dist-CjL6JHML.js → dist-C7EtxNCb.js} +49 -51
  236. package/dist/{dist-DuufrR8O.js → dist-C_dV9QAx.js} +130 -130
  237. package/dist/{cdn/chunks/dist-MNQYSEWU.js → dist-DI4_YSnG.js} +111 -110
  238. package/dist/{dist-tsmnQugO.js → dist-DtOF3bDW.js} +648 -294
  239. package/dist/{editor-modal-AlVLkU91.js → editor-modal-Bzhl-PgI.js} +832 -834
  240. package/dist/en-CDhWRrF_.js +20 -0
  241. package/dist/{cdn/chunks/en-C8Mp71sO.js → en-CW71OK66.js} +147 -8
  242. package/dist/en-DwV15ltA.js +1 -0
  243. package/dist/{cdn/chunks/es-Byq4tthI.js → es-DdK7zQfi.js} +147 -8
  244. package/dist/{extensions-pjO8VGkM.js → extensions-CdyweA50.js} +54 -54
  245. package/dist/{eye-Ddnz8nnm.js → eye-DWkSvYpj.js} +1 -1
  246. package/dist/{cdn/chunks/fr-B3j35HEw.js → fr-Dz5Bgb7-.js} +147 -8
  247. package/dist/image-DesWjcZ4.js +28 -0
  248. package/dist/index.d.ts +640 -48
  249. package/dist/{info-DXLmzoeY.js → info-ClWJGoZy.js} +1 -1
  250. package/dist/{cdn/chunks/ja-D7txAuGS.js → ja-Di-zJiT8.js} +147 -8
  251. package/dist/keys-Zd9KWRD1.js +10 -0
  252. package/dist/{link-Cel46wgo.js → link-BqRicFTA.js} +1 -1
  253. package/dist/{list-Cl0GwiV9.js → list-bojQr9bn.js} +1 -1
  254. package/dist/{loader-circle-uAwpvfys.js → loader-circle-B2B8LbUu.js} +1 -1
  255. package/dist/{cdn/chunks/logger-ByvdoAwq.js → logger-k9Nbj3Cp.js} +5 -3
  256. package/dist/{message-circle-DWU1pTM_.js → message-circle-BEuiNsyZ.js} +1 -1
  257. package/dist/{cdn/chunks/nl-ClJ3BY3F.js → nl-CvVuHYFL.js} +147 -8
  258. package/dist/normalizeMergeTagMarkup-P6SUBuPv.js +197 -0
  259. package/dist/{package-CbyG_yU_.js → package-DCROB4aM.js} +1 -1
  260. package/dist/{pencil-BzoDcwKu.js → pencil-CEotCKbf.js} +1 -1
  261. package/dist/{preRenderCustomBlocks-DMP5RuHl.js → preRenderCustomBlocks-D8rr61_z.js} +3 -3
  262. package/dist/pt-BR-CHM-ZKvE.js +20 -0
  263. package/dist/{cdn/chunks/pt-BR-DibcXcmv.js → pt-BR-ZhO4vgyq.js} +147 -8
  264. package/dist/{refresh-cw-9WinWixo.js → refresh-cw-C6M2mHNC.js} +12 -2
  265. package/dist/{runtime-dom.esm-bundler-lFF-QG3j.js → runtime-dom.esm-bundler-B8WCZWUm.js} +134 -134
  266. package/dist/sanitizeRichTextHtml-DeISfLFr.js +60 -0
  267. package/dist/{search-CqgGq1gG.js → search-Cy99zPYf.js} +1 -1
  268. package/dist/{send-Ceo3c9Db.js → send-BDLJFsf3.js} +1 -1
  269. package/dist/{smartphone-CcLaCpGK.js → smartphone-CVvQaNA4.js} +1 -1
  270. package/dist/socialIcons-Dd-jRiVe.js +2086 -0
  271. package/dist/{sparkles-Do9XjAuT.js → sparkles-Ce0Qz0ox.js} +1 -1
  272. package/dist/square-BWlolnXe.js +15 -0
  273. package/dist/style.css +1 -1
  274. package/dist/{styleConstants-D1Jz-TFU.js → styleConstants-v1dNKgJf.js} +1 -3
  275. package/dist/templatical-editor.js +2272 -1327
  276. package/dist/{text-align-start-DvzC0HQA.js → text-align-start-D1V5gPTy.js} +1 -1
  277. package/dist/{trash-vlINTx32.js → trash-CZfiUFmw.js} +1 -1
  278. package/dist/{triangle-alert-MRYSJ9T2.js → triangle-alert-CFDzyFC7.js} +1 -1
  279. package/dist/upload-BJfvdIrD.js +36 -0
  280. package/dist/{useCloudI18n-Nwqo7pI_.js → useCloudI18n-Dcjua65H.js} +5 -5
  281. package/dist/{useEditorCore-PvErWWsp.js → useEditorCore-BTLeAVlM.js} +1534 -1549
  282. package/dist/{useEditorRoot-BD3piYtD.js → useEditorRoot-DUy67lJu.js} +2 -2
  283. package/dist/{useI18n-CxVEpurs.js → useI18n-BdoY7xDE.js} +4 -4
  284. package/dist/{useLogicTag-BHn67tDd.js → useLogicTag-DKLZ1T9H.js} +3 -3
  285. package/dist/{useMergeTag-CRkm5Ig6.js → useMergeTag-Bhdx7AKk.js} +5 -5
  286. package/dist/{usePopoverPosition-CwnH1o5g.js → usePopoverPosition-BZea45XK.js} +2 -2
  287. package/dist/useScrollToBlock-FmNMALM_.js +74 -0
  288. package/dist/{vue.runtime.esm-bundler-CAzmrXdD.js → vue.runtime.esm-bundler-DgFJ6GPG.js} +1182 -1087
  289. package/dist/{withCurrentFont-CxRGeHO3.js → withCurrentFont-BATJHNve.js} +1 -1
  290. package/dist/{x-Cd6SFw8r.js → x-CZ0Js0hA.js} +1 -1
  291. package/package.json +17 -15
  292. package/dist/AiChatSidebar-DxPHFNoT.js +0 -230
  293. package/dist/AiFeatureMenu-C8GVqu1d.js +0 -57
  294. package/dist/CloudHeaderExtras-CUSftQdm.js +0 -59
  295. package/dist/CloudPanels-Dgw7tb4R.js +0 -216
  296. package/dist/CollaboratorBar-5rfopCPx.js +0 -103
  297. package/dist/CommentsSidebar-BOqj16Al.js +0 -500
  298. package/dist/DesignReferenceSidebar-BWAi3eQQ.js +0 -279
  299. package/dist/IssuesPanel-C-x3I012.js +0 -117
  300. package/dist/ParagraphEditor-BVjOwwHx.js +0 -797
  301. package/dist/SavedBlocksBrowserModal-DbmIS5uK.js +0 -360
  302. package/dist/TemplateScoringPanel-ynbGl-sr.js +0 -273
  303. package/dist/TemplateSettings-Bi01S3H3.js +0 -246
  304. package/dist/ToggleSwitch-Ozc7YU38.js +0 -102
  305. package/dist/Toolbar-B-2lO0I8.js +0 -3156
  306. package/dist/WrapperBlock-D0qgNqjD.js +0 -45
  307. package/dist/cdn/chunks/AiChatSidebar-Dk0rJBQN.js +0 -205
  308. package/dist/cdn/chunks/AiChatSidebar-Dk0rJBQN.js.map +0 -1
  309. package/dist/cdn/chunks/AiFeatureMenu-B7b0w8ZS.js +0 -57
  310. package/dist/cdn/chunks/AiFeatureMenu-B7b0w8ZS.js.map +0 -1
  311. package/dist/cdn/chunks/CloudHeaderExtras-B4fhuwc_.js +0 -60
  312. package/dist/cdn/chunks/CloudHeaderExtras-B4fhuwc_.js.map +0 -1
  313. package/dist/cdn/chunks/CloudPanels-awqHfJqC.js.map +0 -1
  314. package/dist/cdn/chunks/CollaboratorBar-CS0ivqkr.js +0 -52
  315. package/dist/cdn/chunks/CollaboratorBar-CS0ivqkr.js.map +0 -1
  316. package/dist/cdn/chunks/CommentsPanel-CbzxwsyI.js +0 -20
  317. package/dist/cdn/chunks/CommentsSidebar-DWPHZuQm.js +0 -470
  318. package/dist/cdn/chunks/DesignReferenceSidebar-BW9cHnA9.js +0 -229
  319. package/dist/cdn/chunks/DesignReferenceSidebar-BW9cHnA9.js.map +0 -1
  320. package/dist/cdn/chunks/IssuesPanel-cXf9ywA4.js +0 -100
  321. package/dist/cdn/chunks/IssuesPanel-cXf9ywA4.js.map +0 -1
  322. package/dist/cdn/chunks/LogicTagInsertButton-BMB9vShs.js.map +0 -1
  323. package/dist/cdn/chunks/MediaEditModal-zXfcArr4.js.map +0 -1
  324. package/dist/cdn/chunks/MediaPanels-Cp4XB_dH.js +0 -45
  325. package/dist/cdn/chunks/ParagraphEditor-D4aq9eeC.js +0 -632
  326. package/dist/cdn/chunks/ParagraphEditor-D4aq9eeC.js.map +0 -1
  327. package/dist/cdn/chunks/SavedBlocksPanels-BhEOMzEQ.js +0 -38
  328. package/dist/cdn/chunks/TemplateScoringPanel-BrWqJCSP.js +0 -237
  329. package/dist/cdn/chunks/TemplateScoringPanel-BrWqJCSP.js.map +0 -1
  330. package/dist/cdn/chunks/TemplateSettings-BkkWTDHD.js +0 -208
  331. package/dist/cdn/chunks/TestEmailPanel-DxrKuctP.js +0 -35
  332. package/dist/cdn/chunks/TitleEditor-CsZiG3TT.js +0 -199
  333. package/dist/cdn/chunks/ToggleSwitch-BB-bQADJ.js +0 -104
  334. package/dist/cdn/chunks/ToggleSwitch-BB-bQADJ.js.map +0 -1
  335. package/dist/cdn/chunks/Toolbar-C_x2TfFk.js.map +0 -1
  336. package/dist/cdn/chunks/VersionHistoryPanels-DXSqmaLS.js +0 -48
  337. package/dist/cdn/chunks/WrapperBlock-gG_Bleug.js +0 -47
  338. package/dist/cdn/chunks/blockTypeIcons-HrMJDfVg.js +0 -22
  339. package/dist/cdn/chunks/ca-CbNzJM3I.js.map +0 -1
  340. package/dist/cdn/chunks/cloud-BHClP3e2.js +0 -1736
  341. package/dist/cdn/chunks/cloud-BHClP3e2.js.map +0 -1
  342. package/dist/cdn/chunks/createCloudRuntime-Vd0N4elZ.js +0 -400
  343. package/dist/cdn/chunks/createCloudRuntime-Vd0N4elZ.js.map +0 -1
  344. package/dist/cdn/chunks/de-DMquBpZM.js.map +0 -1
  345. package/dist/cdn/chunks/de-mMY5yQJu.js +0 -93
  346. package/dist/cdn/chunks/de-mMY5yQJu.js.map +0 -1
  347. package/dist/cdn/chunks/draggable-DrsNwZuB.js.map +0 -1
  348. package/dist/cdn/chunks/en-C8Mp71sO.js.map +0 -1
  349. package/dist/cdn/chunks/en-ChVeGQBY.js +0 -93
  350. package/dist/cdn/chunks/en-ChVeGQBY.js.map +0 -1
  351. package/dist/cdn/chunks/en-eWpiXyZu.js +0 -1
  352. package/dist/cdn/chunks/es-Byq4tthI.js.map +0 -1
  353. package/dist/cdn/chunks/fr-B3j35HEw.js.map +0 -1
  354. package/dist/cdn/chunks/icons-aTYwH5-g.js.map +0 -1
  355. package/dist/cdn/chunks/ja-D7txAuGS.js.map +0 -1
  356. package/dist/cdn/chunks/keys-HI-INbkz.js +0 -12
  357. package/dist/cdn/chunks/keys-HI-INbkz.js.map +0 -1
  358. package/dist/cdn/chunks/logger-ByvdoAwq.js.map +0 -1
  359. package/dist/cdn/chunks/nl-ClJ3BY3F.js.map +0 -1
  360. package/dist/cdn/chunks/pt-BR-CoCwRUi0.js +0 -93
  361. package/dist/cdn/chunks/pt-BR-CoCwRUi0.js.map +0 -1
  362. package/dist/cdn/chunks/pt-BR-DibcXcmv.js.map +0 -1
  363. package/dist/cdn/chunks/pusher-C8DeiO2X.js.map +0 -1
  364. package/dist/cdn/chunks/socialIcons-C_lnkpG6.js +0 -1279
  365. package/dist/cdn/chunks/socialIcons-C_lnkpG6.js.map +0 -1
  366. package/dist/cdn/chunks/src-DYCDeBDM.js.map +0 -1
  367. package/dist/cdn/chunks/src-DlFlC9Tt.js +0 -1272
  368. package/dist/cdn/chunks/src-DlFlC9Tt.js.map +0 -1
  369. package/dist/cdn/chunks/src-dZ4D_tuP.js.map +0 -1
  370. package/dist/cdn/chunks/timeouts-Cv2jvusx.js +0 -6
  371. package/dist/cdn/chunks/timeouts-Cv2jvusx.js.map +0 -1
  372. package/dist/cdn/chunks/tiptap-BPigZk5G.js.map +0 -1
  373. package/dist/cdn/chunks/useAliveFlag-DCB96vzR.js +0 -12
  374. package/dist/cdn/chunks/useAliveFlag-DCB96vzR.js.map +0 -1
  375. package/dist/cdn/chunks/useEditorCore-Bb2UcB20.js +0 -2602
  376. package/dist/cdn/chunks/useEditorCore-Bb2UcB20.js.map +0 -1
  377. package/dist/cdn/chunks/useEditorRoot-CTc6O8al.js +0 -10
  378. package/dist/cdn/chunks/useScrollToBlock-uUa601I4.js +0 -21
  379. package/dist/cdn/chunks/useScrollToBlock-uUa601I4.js.map +0 -1
  380. package/dist/cloud-B5xwm_4X.js +0 -1689
  381. package/dist/copy-BEcsAlfB.js +0 -19
  382. package/dist/createCloudRuntime-zNPkF6T9.js +0 -398
  383. package/dist/de-mMY5yQJu.js +0 -91
  384. package/dist/dist-DAAJogrx.js +0 -407
  385. package/dist/en-B0FUfNwz.js +0 -1
  386. package/dist/en-ChVeGQBY.js +0 -91
  387. package/dist/image-up-CM_HC0Dx.js +0 -27
  388. package/dist/keys-BKFq19a2.js +0 -10
  389. package/dist/plus-8cDvoCjZ.js +0 -14
  390. package/dist/pt-BR-CoCwRUi0.js +0 -91
  391. package/dist/shield-check-uDAwur5D.js +0 -14
  392. package/dist/socialIcons-PTiwhLoC.js +0 -1359
  393. package/dist/timeouts-Cv2jvusx.js +0 -4
  394. package/dist/upload-CtNOI6J2.js +0 -21
  395. package/dist/useAliveFlag-Dd06mRxe.js +0 -10
  396. package/dist/useScrollToBlock-CXmcHQQN.js +0 -47
@@ -1,1689 +0,0 @@
1
- import { J as e, R as t, Z as n, s as r } from "./vue.runtime.esm-bundler-CAzmrXdD.js";
2
- import { d as i } from "./dist-tsmnQugO.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.expiresAt || !a.projectId || !a.tenant) throw Error("Invalid token response: missing token, expiresAt, projectId, or tenant");
85
- return this.accessToken = a.token, this.expiresAt = /* @__PURE__ */ new Date(a.expiresAt * 1e3), this._projectId = a.projectId, this._tenantSlug = a.tenant, this._testEmailConfig = a.testEmail?.allowedEmails && a.testEmail?.signature ? {
86
- allowedEmails: a.testEmail.allowedEmails,
87
- signature: a.testEmail.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
- }, g = class {
355
- authManager;
356
- constructor(e) {
357
- this.authManager = e;
358
- }
359
- get projectId() {
360
- return this.authManager.projectId;
361
- }
362
- get tenantSlug() {
363
- return this.authManager.tenantSlug;
364
- }
365
- get baseParams() {
366
- return {
367
- project: this.projectId,
368
- tenant: this.tenantSlug
369
- };
370
- }
371
- async request(e, t = {}) {
372
- let n = await this.authManager.authenticatedFetch(e, {
373
- ...t,
374
- headers: {
375
- "Content-Type": "application/json",
376
- Accept: "application/json",
377
- ...t.headers
378
- }
379
- });
380
- if (!n.ok) {
381
- let e = await n.json().catch(() => ({ message: `HTTP error ${n.status}` }));
382
- throw Error(e.message, { cause: e });
383
- }
384
- if (n.status !== 204) return (await n.json()).data;
385
- }
386
- async browseMedia(e) {
387
- let t = new URLSearchParams();
388
- e.folderId && t.set("folderId", e.folderId), e.search && t.set("search", e.search), e.category && t.set("category", e.category), e.sort && t.set("sort", e.sort), e.cursor && t.set("cursor", e.cursor);
389
- let n = t.toString(), r = `${s(m["media.browse"], this.baseParams)}${n ? `?${n}` : ""}`, i = await this.authManager.authenticatedFetch(r, { headers: { Accept: "application/json" } });
390
- if (!i.ok) {
391
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
392
- throw Error(e.message, { cause: e });
393
- }
394
- return i.json();
395
- }
396
- async uploadMedia(e, t) {
397
- let n = new FormData();
398
- n.append("file", e), t && n.append("folderId", t);
399
- let r = s(m["media.upload"], this.baseParams), i = await this.authManager.authenticatedFetch(r, {
400
- method: "POST",
401
- headers: { Accept: "application/json" },
402
- body: n
403
- });
404
- if (!i.ok) {
405
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
406
- throw Error(e.message, { cause: e });
407
- }
408
- return (await i.json()).data;
409
- }
410
- async updateMedia(e, t, n) {
411
- let r = {};
412
- return t !== void 0 && (r.filename = t), n !== void 0 && (r.alt = n), this.request(s(m["media.update"], {
413
- ...this.baseParams,
414
- media: e
415
- }), {
416
- method: "PUT",
417
- body: JSON.stringify(r)
418
- });
419
- }
420
- async deleteMedia(e) {
421
- return this.request(s(m["media.delete"], this.baseParams), {
422
- method: "POST",
423
- body: JSON.stringify({ ids: e })
424
- });
425
- }
426
- async moveMedia(e, t) {
427
- return this.request(s(m["media.move"], this.baseParams), {
428
- method: "POST",
429
- body: JSON.stringify({
430
- ids: e,
431
- folderId: t
432
- })
433
- });
434
- }
435
- async getMediaFolders() {
436
- return this.request(s(m["folders.index"], this.baseParams));
437
- }
438
- async createMediaFolder(e, t) {
439
- return this.request(s(m["folders.store"], this.baseParams), {
440
- method: "POST",
441
- body: JSON.stringify({
442
- name: e,
443
- parentId: t ?? null
444
- })
445
- });
446
- }
447
- async renameMediaFolder(e, t) {
448
- return this.request(s(m["folders.update"], {
449
- ...this.baseParams,
450
- mediaFolder: e
451
- }), {
452
- method: "PUT",
453
- body: JSON.stringify({ name: t })
454
- });
455
- }
456
- async deleteMediaFolder(e) {
457
- return this.request(s(m["folders.destroy"], {
458
- ...this.baseParams,
459
- mediaFolder: e
460
- }), { method: "DELETE" });
461
- }
462
- async checkMediaUsage(e) {
463
- let t = await this.authManager.authenticatedFetch(s(m["media.checkUsage"], this.baseParams), {
464
- method: "POST",
465
- headers: {
466
- "Content-Type": "application/json",
467
- Accept: "application/json"
468
- },
469
- body: JSON.stringify({ ids: e })
470
- });
471
- if (!t.ok) {
472
- let e = await t.json().catch(() => ({ message: `HTTP error ${t.status}` }));
473
- throw Error(e.message, { cause: e });
474
- }
475
- return t.json();
476
- }
477
- async getFrequentlyUsed() {
478
- return this.request(s(m["media.frequentlyUsed"], this.baseParams));
479
- }
480
- async importFromUrl(e, t) {
481
- return this.request(s(m["media.importFromUrl"], this.baseParams), {
482
- method: "POST",
483
- body: JSON.stringify({
484
- url: e,
485
- folderId: t ?? null
486
- })
487
- });
488
- }
489
- async replaceMedia(e, t) {
490
- let n = new FormData();
491
- n.append("file", t);
492
- let r = s(m["media.replace"], {
493
- ...this.baseParams,
494
- media: e
495
- }), i = await this.authManager.authenticatedFetch(r, {
496
- method: "POST",
497
- headers: { Accept: "application/json" },
498
- body: n
499
- });
500
- if (!i.ok) {
501
- let e = await i.json().catch(() => ({ message: `HTTP error ${i.status}` }));
502
- throw Error(e.message, { cause: e });
503
- }
504
- return (await i.json()).data;
505
- }
506
- };
507
- function _(e) {
508
- return {
509
- host: e.host,
510
- port: e.port,
511
- appKey: e.appKey
512
- };
513
- }
514
- var v = class {
515
- pusher = null;
516
- authManager;
517
- config;
518
- onError;
519
- constructor(e) {
520
- this.authManager = e.authManager, this.config = e.config, this.onError = e.onError;
521
- }
522
- async connect() {
523
- if (this.pusher) return;
524
- let e;
525
- try {
526
- ({default: e} = await import("pusher-js"));
527
- } catch {
528
- throw Error("[Templatical] Cloud features require the optional peer dependency 'pusher-js'. Please install it.");
529
- }
530
- let { host: t, port: n, appKey: r } = this.config, i = this.authManager.resolveUrl(s(m["broadcasting.auth"], {
531
- project: this.authManager.projectId,
532
- tenant: this.authManager.tenantSlug
533
- }));
534
- this.pusher = new e(r, {
535
- wsHost: t,
536
- wsPort: n,
537
- wssPort: n,
538
- forceTLS: !0,
539
- disableStats: !0,
540
- enabledTransports: ["ws", "wss"],
541
- cluster: "",
542
- channelAuthorization: {
543
- transport: "ajax",
544
- endpoint: i,
545
- headers: {
546
- Authorization: `Bearer ${this.authManager.accessTokenValue}`,
547
- Accept: "application/json"
548
- },
549
- params: {
550
- userId: this.authManager.userConfig?.id ?? "",
551
- userName: this.authManager.userConfig?.name ?? "",
552
- userSignature: this.authManager.userConfig?.signature ?? ""
553
- }
554
- }
555
- }), this.pusher.connection.bind("error", (e) => {
556
- this.onError?.(e instanceof Error ? e : /* @__PURE__ */ Error("WebSocket connection error"));
557
- });
558
- }
559
- subscribePresence(e) {
560
- if (!this.pusher) throw Error("WebSocketClient not connected. Call connect() first.");
561
- return this.pusher.subscribe(e);
562
- }
563
- unsubscribe(e) {
564
- this.pusher?.unsubscribe(e);
565
- }
566
- getChannel(e) {
567
- return this.pusher?.channel(e);
568
- }
569
- disconnect() {
570
- this.pusher &&= (this.pusher.disconnect(), null);
571
- }
572
- getSocketId() {
573
- return this.pusher?.connection.socket_id ?? null;
574
- }
575
- get isConnected() {
576
- return this.pusher?.connection.state === "connected";
577
- }
578
- };
579
- function y(e, t) {
580
- let { operation: n, data: r } = t;
581
- switch (n) {
582
- case "addBlock":
583
- e.addBlock(r.block, r.sectionId, r.columnIndex, r.index);
584
- break;
585
- case "updateBlock":
586
- e.updateBlock(r.blockId, r.updates);
587
- break;
588
- case "deleteBlock":
589
- e.removeBlock(r.blockId);
590
- break;
591
- case "moveBlock":
592
- e.moveBlock(r.blockId, r.index, r.sectionId, r.columnIndex);
593
- break;
594
- case "updateSettings":
595
- e.updateSettings(r.updates);
596
- break;
597
- case "setContent":
598
- e.setContent(r.content);
599
- break;
600
- case "updateBlockStyle": e.updateBlock(r.blockId, { styles: r.styles });
601
- }
602
- }
603
- var b = 0;
604
- function x() {
605
- return `msg_${Date.now()}_${++b}`;
606
- }
607
- function S(e) {
608
- let { authManager: t, getTemplateId: r, onApply: i, onError: a } = e, o = n([]), c = n(!1), l = n(!1), u = n(null), d = n(null), f = n(null), p = n(null), h = n(null), g = n(null), _ = n(!1), v = n([]), y = n(!1);
609
- function b(e, t) {
610
- let n = o.value.findIndex((t) => t.id === e);
611
- if (n === -1) return;
612
- let r = {
613
- ...o.value[n],
614
- ...t
615
- };
616
- o.value = [
617
- ...o.value.slice(0, n),
618
- r,
619
- ...o.value.slice(n + 1)
620
- ];
621
- }
622
- async function S() {
623
- let e = r();
624
- if (e) {
625
- l.value = !0;
626
- try {
627
- let n = s(m["ai.conversationMessages"], {
628
- project: t.projectId,
629
- tenant: t.tenantSlug,
630
- template: e
631
- }), r = await t.authenticatedFetch(n, {
632
- method: "GET",
633
- headers: { Accept: "application/json" }
634
- });
635
- if (!r.ok) return;
636
- let i = await r.json();
637
- i.conversationId && (f.value = i.conversationId), Array.isArray(i.data) && i.data.length > 0 && (o.value = i.data.map((e) => ({
638
- id: e.id,
639
- role: e.role,
640
- content: e.content,
641
- timestamp: new Date(e.createdAt).getTime()
642
- })));
643
- } catch {} finally {
644
- l.value = !1;
645
- }
646
- }
647
- }
648
- async function C(e, n) {
649
- let i = r();
650
- if (i) {
651
- y.value = !0;
652
- try {
653
- let r = s(m["ai.suggestions"], {
654
- project: t.projectId,
655
- tenant: t.tenantSlug,
656
- template: i
657
- }), a = await t.authenticatedFetch(r, {
658
- method: "POST",
659
- headers: {
660
- "Content-Type": "application/json",
661
- Accept: "text/event-stream"
662
- },
663
- body: JSON.stringify({
664
- currentContent: e,
665
- mergeTags: n.map((e) => ({
666
- label: e.label,
667
- value: e.value
668
- }))
669
- })
670
- });
671
- if (!a.ok) return;
672
- let o = a.body?.getReader();
673
- if (!o) return;
674
- let c = new TextDecoder(), l = "";
675
- for (;;) {
676
- let { done: e, value: t } = await o.read();
677
- if (e) break;
678
- l += c.decode(t, { stream: !0 });
679
- let n = l.split("\n");
680
- l = n.pop() ?? "";
681
- for (let e of n) {
682
- if (!e.startsWith("data: ")) continue;
683
- let t;
684
- try {
685
- t = JSON.parse(e.slice(6));
686
- } catch {
687
- continue;
688
- }
689
- t.type === "done" && Array.isArray(t.suggestions) && (v.value = t.suggestions.slice(0, 3));
690
- }
691
- }
692
- } catch {} finally {
693
- y.value = !1;
694
- }
695
- }
696
- }
697
- async function w(e, n, l) {
698
- let y = r();
699
- if (!y) throw Error("Template must be saved before using AI generation");
700
- c.value = !0, u.value = null, d.value = null, v.value = [];
701
- let S = x();
702
- o.value = [...o.value, {
703
- id: S,
704
- role: "user",
705
- content: e,
706
- timestamp: Date.now()
707
- }];
708
- let C = x();
709
- o.value = [...o.value, {
710
- id: C,
711
- role: "assistant",
712
- content: "",
713
- timestamp: Date.now()
714
- }];
715
- try {
716
- let r = s(m["ai.generate"], {
717
- project: t.projectId,
718
- tenant: t.tenantSlug,
719
- template: y
720
- }), a = await t.authenticatedFetch(r, {
721
- method: "POST",
722
- headers: {
723
- "Content-Type": "application/json",
724
- Accept: "text/event-stream"
725
- },
726
- body: JSON.stringify({
727
- prompt: e,
728
- currentContent: n,
729
- mergeTags: l.map((e) => ({
730
- label: e.label,
731
- value: e.value
732
- })),
733
- conversationId: f.value
734
- })
735
- });
736
- if (!a.ok) {
737
- let e = await a.json().catch(() => null);
738
- throw a.status === 403 ? Error("aiGenerationNotAvailable") : Error(e?.message || "Failed to generate template");
739
- }
740
- let c = a.body?.getReader();
741
- if (!c) throw Error("Failed to read stream");
742
- let d = new TextDecoder(), v = "", x = null;
743
- try {
744
- for (;;) {
745
- let { done: e, value: t } = await c.read();
746
- if (e) break;
747
- v += d.decode(t, { stream: !0 });
748
- let r = v.split("\n");
749
- v = r.pop() ?? "";
750
- for (let e of r) {
751
- if (!e.startsWith("data: ")) continue;
752
- let t = e.slice(6), r;
753
- try {
754
- r = JSON.parse(t);
755
- } catch {
756
- continue;
757
- }
758
- if (r.type === "text") b(C, { content: (o.value.find((e) => e.id === C)?.content ?? "") + r.text });
759
- else if (r.type === "error") throw Error(r.message || "Failed to generate template");
760
- else r.type === "done" && (r.conversationId && (f.value = r.conversationId), b(C, { content: r.text }), x = r.content ?? null, x ? (h.value = n, g.value = x, p.value = C, _.value = !1, i?.(x)) : u.value = "ai_apply_failed");
761
- }
762
- }
763
- } finally {
764
- c.cancel().catch(() => {});
765
- }
766
- return x;
767
- } catch (t) {
768
- let n = t instanceof Error ? t : Error("Failed to generate template", { cause: t });
769
- return u.value = n.message, d.value = e, a?.(n), o.value = o.value.filter((e) => e.id !== S && e.id !== C), null;
770
- } finally {
771
- c.value = !1;
772
- }
773
- }
774
- function T() {
775
- _.value ? (g.value && i?.(g.value), _.value = !1) : (h.value && i?.(h.value), _.value = !0);
776
- }
777
- function E() {
778
- o.value = [], f.value = null, u.value = null, p.value = null, h.value = null, g.value = null, _.value = !1;
779
- }
780
- return {
781
- messages: o,
782
- isGenerating: c,
783
- isLoadingHistory: l,
784
- isLastChangeReverted: _,
785
- lastApplyMessageId: p,
786
- error: u,
787
- failedPrompt: d,
788
- suggestions: v,
789
- isLoadingSuggestions: y,
790
- sendPrompt: w,
791
- toggleLastRevert: T,
792
- loadConversation: S,
793
- loadSuggestions: C,
794
- clearChat: E
795
- };
796
- }
797
- function C(e) {
798
- function t(t) {
799
- return e !== !1 && e?.[t] !== !1;
800
- }
801
- return {
802
- isFeatureEnabled: t,
803
- hasAnyMenuFeature: r(() => t("chat") || t("scoring") || t("designToTemplate"))
804
- };
805
- }
806
- function w(e) {
807
- let { authManager: t, getTemplateId: r } = e, i = n(!1), a = n(null), o = n(null), c = n(null), l = n(""), u = n(null);
808
- async function d(e, n) {
809
- let c = r();
810
- if (!c) return null;
811
- i.value = !0, o.value = null, a.value = null;
812
- try {
813
- let r = s(m["ai.score"], {
814
- project: t.projectId,
815
- tenant: t.tenantSlug,
816
- template: c
817
- }), i = await t.authenticatedFetch(r, {
818
- method: "POST",
819
- headers: {
820
- "Content-Type": "application/json",
821
- Accept: "text/event-stream"
822
- },
823
- body: JSON.stringify({
824
- currentContent: e,
825
- mergeTags: n.map((e) => ({
826
- label: e.label,
827
- value: e.value
828
- }))
829
- })
830
- });
831
- if (!i.ok) {
832
- if (i.status === 403) throw Error("aiGenerationNotAvailable");
833
- let e = await i.json().catch(() => null);
834
- throw Error(e?.message || "Failed to score template");
835
- }
836
- let o = i.body?.getReader();
837
- if (!o) throw Error("Failed to read stream");
838
- let l = new TextDecoder(), u = "", d = null;
839
- for (;;) {
840
- let { done: e, value: t } = await o.read();
841
- if (e) break;
842
- u += l.decode(t, { stream: !0 });
843
- let n = u.split("\n");
844
- u = n.pop() ?? "";
845
- for (let e of n) {
846
- if (!e.startsWith("data: ")) continue;
847
- let t;
848
- try {
849
- t = JSON.parse(e.slice(6));
850
- } catch {
851
- continue;
852
- }
853
- if (t.type === "error") throw Error(t.message || "Failed to score template");
854
- t.type === "done" && (d = t.result ?? null);
855
- }
856
- }
857
- if (d) for (let [e, t] of Object.entries(d.categories)) for (let n of t.findings) n.category = e;
858
- return a.value = d, d;
859
- } catch (e) {
860
- return o.value = e instanceof Error ? e.message : "Failed to score template", null;
861
- } finally {
862
- i.value = !1;
863
- }
864
- }
865
- async function f(e, n, i) {
866
- let a = r();
867
- if (!a) return null;
868
- c.value = n.id, l.value = "", u.value = null;
869
- try {
870
- let r = s(m["ai.fixFinding"], {
871
- project: t.projectId,
872
- tenant: t.tenantSlug,
873
- template: a
874
- }), o = await t.authenticatedFetch(r, {
875
- method: "POST",
876
- headers: {
877
- "Content-Type": "application/json",
878
- Accept: "text/event-stream"
879
- },
880
- body: JSON.stringify({
881
- content: e,
882
- finding: {
883
- id: n.id,
884
- message: n.message,
885
- suggestion: n.suggestion,
886
- category: n.category
887
- },
888
- mergeTags: i.map((e) => ({
889
- label: e.label,
890
- value: e.value
891
- }))
892
- })
893
- });
894
- if (!o.ok) {
895
- if (o.status === 403) throw Error("aiGenerationNotAvailable");
896
- let e = await o.json().catch(() => null);
897
- throw Error(e?.message || "Failed to fix finding");
898
- }
899
- let c = o.body?.getReader();
900
- if (!c) throw Error("Failed to read stream");
901
- let u = new TextDecoder(), d = "", f = null;
902
- for (;;) {
903
- let { done: e, value: t } = await c.read();
904
- if (e) break;
905
- d += u.decode(t, { stream: !0 });
906
- let n = d.split("\n");
907
- d = n.pop() ?? "";
908
- for (let e of n) {
909
- if (!e.startsWith("data: ")) continue;
910
- let t;
911
- try {
912
- t = JSON.parse(e.slice(6));
913
- } catch {
914
- continue;
915
- }
916
- if (t.type === "text") l.value += t.text;
917
- else if (t.type === "error") throw Error(t.message || "Failed to fix finding");
918
- else t.type === "done" && (f = t.content ?? null);
919
- }
920
- }
921
- return f;
922
- } catch (e) {
923
- return u.value = e instanceof Error ? e.message : "Failed to fix finding", null;
924
- } finally {
925
- c.value = null;
926
- }
927
- }
928
- function p(e, t) {
929
- if (!a.value) return;
930
- let n = a.value.categories[e];
931
- n && (n.findings = n.findings.filter((e) => e.id !== t));
932
- }
933
- function h() {
934
- i.value = !1, a.value = null, o.value = null, c.value = null, l.value = "", u.value = null;
935
- }
936
- return {
937
- isScoring: i,
938
- scoringResult: a,
939
- error: o,
940
- fixingFindingId: c,
941
- fixStreamingText: l,
942
- fixError: u,
943
- score: d,
944
- fixFinding: f,
945
- removeFinding: p,
946
- reset: h
947
- };
948
- }
949
- function T(e) {
950
- let { authManager: t, getTemplateId: r, onApply: i, onError: a } = e, o = n(!1), c = n(null);
951
- async function l(e) {
952
- let n = r();
953
- if (!n) throw Error("Template must be saved before using design reference");
954
- o.value = !0, c.value = null;
955
- try {
956
- let r = new FormData();
957
- e.prompt && r.append("prompt", e.prompt), e.imageUpload && r.append("image_upload", e.imageUpload), e.pdfUpload && r.append("pdf_upload", e.pdfUpload);
958
- let a = s(m["ai.generateFromDesign"], {
959
- project: t.projectId,
960
- tenant: t.tenantSlug,
961
- template: n
962
- }), o = await t.authenticatedFetch(a, {
963
- method: "POST",
964
- headers: { Accept: "text/event-stream" },
965
- body: r
966
- });
967
- if (!o.ok) {
968
- let e = await o.json().catch(() => null);
969
- throw o.status === 403 ? Error("aiGenerationNotAvailable") : Error(e?.message || "Failed to generate template from design");
970
- }
971
- let c = o.body?.getReader();
972
- if (!c) throw Error("Failed to read stream");
973
- let l = new TextDecoder(), u = "", d = null;
974
- for (;;) {
975
- let { done: e, value: t } = await c.read();
976
- if (e) break;
977
- u += l.decode(t, { stream: !0 });
978
- let n = u.split("\n");
979
- u = n.pop() ?? "";
980
- for (let e of n) {
981
- if (!e.startsWith("data: ")) continue;
982
- let t = e.slice(6), n;
983
- try {
984
- n = JSON.parse(t);
985
- } catch {
986
- continue;
987
- }
988
- if (n.type === "error") throw Error(n.message || "Failed to generate template from design");
989
- n.type === "done" && (d = n.content ?? null, d && i?.(d));
990
- }
991
- }
992
- return d;
993
- } catch (e) {
994
- let t = e instanceof Error ? e : Error("Failed to generate template from design", { cause: e });
995
- return c.value = t.message, a?.(t), null;
996
- } finally {
997
- o.value = !1;
998
- }
999
- }
1000
- function u() {
1001
- o.value = !1, c.value = null;
1002
- }
1003
- return {
1004
- isGenerating: o,
1005
- error: c,
1006
- generate: l,
1007
- reset: u
1008
- };
1009
- }
1010
- var E = "comment-broadcast";
1011
- function D(e) {
1012
- let t = {
1013
- id: e.id,
1014
- body: e.body,
1015
- author: e.author,
1016
- createdAt: e.createdAt,
1017
- blockId: e.blockId,
1018
- parentId: e.parentId,
1019
- resolvedAt: e.resolvedAt
1020
- };
1021
- return e.updatedAt !== e.createdAt && (t.updatedAt = e.updatedAt), e.resolvedBy && (t.resolvedBy = e.resolvedBy), e.replies?.length && (t.replies = e.replies.map(D)), t;
1022
- }
1023
- function O(e) {
1024
- let { authManager: n, channel: r, getSocketId: i } = e, a = new h(n);
1025
- function o() {
1026
- let e = n.userConfig;
1027
- 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.");
1028
- return {
1029
- userId: e.id,
1030
- userName: e.name,
1031
- userSignature: e.signature
1032
- };
1033
- }
1034
- function s() {
1035
- let e = i?.();
1036
- return e ? { "X-Socket-ID": e } : void 0;
1037
- }
1038
- return {
1039
- async list(e) {
1040
- return (await a.getComments(e)).map(D);
1041
- },
1042
- async create(e, t) {
1043
- return D(await a.createComment(e, {
1044
- body: t.body,
1045
- blockId: t.blockId,
1046
- parentId: t.parentId,
1047
- ...o()
1048
- }, s()));
1049
- },
1050
- async update(e, t, n) {
1051
- if (n.body === void 0) throw Error("[Templatical] Cloud comments: update() needs a `body` in the patch.");
1052
- return D(await a.updateComment(e, t, {
1053
- body: n.body,
1054
- ...o()
1055
- }, s()));
1056
- },
1057
- async delete(e, t) {
1058
- await a.deleteComment(e, t, o(), s());
1059
- },
1060
- async setResolved(e, t, n) {
1061
- return D(await a.resolveComment(e, t, o(), s()));
1062
- },
1063
- subscribe(e, n) {
1064
- function i(e) {
1065
- let t = D(e.comment);
1066
- switch (e.action) {
1067
- case "commentCreated":
1068
- n({
1069
- type: "created",
1070
- comment: t
1071
- });
1072
- break;
1073
- case "commentDeleted":
1074
- n({
1075
- type: "deleted",
1076
- commentId: t.id,
1077
- parentId: t.parentId
1078
- });
1079
- break;
1080
- case "commentUpdated":
1081
- case "commentResolved":
1082
- case "commentUnresolved": n({
1083
- type: "updated",
1084
- comment: t
1085
- });
1086
- }
1087
- }
1088
- let a = t(r, (e, t) => {
1089
- t?.unbind(E, i), e?.bind(E, i);
1090
- }, { immediate: !0 });
1091
- return () => {
1092
- a(), r.value?.unbind(E, i);
1093
- };
1094
- }
1095
- };
1096
- }
1097
- var k = [
1098
- "pusher:member_added",
1099
- "pusher:member_removed",
1100
- "client-blockLocked",
1101
- "client-blockUnlocked",
1102
- "client-operation",
1103
- "mcp-operation"
1104
- ];
1105
- function A(e) {
1106
- for (let t of k) e.unbind(t);
1107
- }
1108
- var j = [
1109
- "#3b82f6",
1110
- "#ef4444",
1111
- "#10b981",
1112
- "#f59e0b",
1113
- "#8b5cf6",
1114
- "#ec4899",
1115
- "#06b6d4",
1116
- "#f97316",
1117
- "#6366f1",
1118
- "#14b8a6"
1119
- ];
1120
- function M(i) {
1121
- let { authManager: a, editor: o, channel: s } = i, c = n([]), l = n(/* @__PURE__ */ new Map()), u = 0, d = !1, f = r(() => a.userConfig?.id ?? "");
1122
- function p() {
1123
- let e = j[u % j.length];
1124
- return u++, e;
1125
- }
1126
- function m(e) {
1127
- if (e.id === f.value || c.value.some((t) => t.id === e.id)) return;
1128
- let t = {
1129
- id: e.id,
1130
- name: e.name,
1131
- color: p(),
1132
- selectedBlockId: null
1133
- };
1134
- return c.value = [...c.value, t], t;
1135
- }
1136
- function h(e) {
1137
- let t = new Map(l.value);
1138
- for (let [n, r] of t) r.id === e && t.delete(n);
1139
- l.value = t, c.value = c.value.filter((t) => t.id !== e);
1140
- }
1141
- function g(e) {
1142
- let t = c.value.find((t) => t.id === e.userId);
1143
- if (!t) return;
1144
- c.value = c.value.map((t) => t.id === e.userId ? {
1145
- ...t,
1146
- selectedBlockId: e.blockId
1147
- } : t);
1148
- let n = new Map(l.value);
1149
- for (let [t, r] of n) r.id === e.userId && n.delete(t);
1150
- n.set(e.blockId, {
1151
- ...t,
1152
- selectedBlockId: e.blockId
1153
- }), l.value = n, o.state.selectedBlockId === e.blockId && o.selectBlock(null);
1154
- }
1155
- function _(e) {
1156
- let t = new Map(l.value), n = t.get(e.blockId);
1157
- t.delete(e.blockId), l.value = t, n && (c.value = c.value.map((e) => e.id === n.id ? {
1158
- ...e,
1159
- selectedBlockId: null
1160
- } : e));
1161
- }
1162
- function v(e) {
1163
- d = !0;
1164
- try {
1165
- y(o, e);
1166
- } finally {
1167
- d = !1;
1168
- }
1169
- }
1170
- function b(e) {
1171
- s.value && !d && s.value.trigger("client-operation", e);
1172
- }
1173
- function x(e) {
1174
- s.value && s.value.trigger("client-blockLocked", {
1175
- blockId: e,
1176
- userId: f.value
1177
- });
1178
- }
1179
- function S(e) {
1180
- s.value && s.value.trigger("client-blockUnlocked", { blockId: e });
1181
- }
1182
- return t(() => o.state.selectedBlockId, (e, t) => {
1183
- d || (t && S(t), e && x(e));
1184
- }), t(s, (e, t) => {
1185
- if (t && A(t), !e) {
1186
- c.value = [], l.value = /* @__PURE__ */ new Map(), u = 0;
1187
- return;
1188
- }
1189
- let n = e.members;
1190
- n && n.each((e) => {
1191
- m(e.info);
1192
- }), e.bind("pusher:member_added", (e) => {
1193
- let t = m(e.info);
1194
- t && i.onCollaboratorJoined?.(t);
1195
- }), e.bind("pusher:member_removed", (e) => {
1196
- let t = c.value.find((t) => t.id === e.id);
1197
- h(e.id), t && i.onCollaboratorLeft?.(t);
1198
- }), e.bind("client-blockLocked", (e) => {
1199
- g(e);
1200
- let t = c.value.find((t) => t.id === e.userId);
1201
- t && i.onBlockLocked?.({
1202
- blockId: e.blockId,
1203
- collaborator: t
1204
- });
1205
- }), e.bind("client-blockUnlocked", (e) => {
1206
- let t = l.value.get(e.blockId);
1207
- _(e), t && i.onBlockUnlocked?.({
1208
- blockId: e.blockId,
1209
- collaborator: t
1210
- });
1211
- }), e.bind("client-operation", (e) => {
1212
- v(e);
1213
- }), e.bind("mcp-operation", (e) => {
1214
- v(e);
1215
- });
1216
- }), e(() => {
1217
- s.value && A(s.value);
1218
- }), {
1219
- collaborators: c,
1220
- lockedBlocks: l,
1221
- _broadcastOperation: b,
1222
- _isProcessingRemoteOperation: () => d
1223
- };
1224
- }
1225
- function N(e, t) {
1226
- let n = e.addBlock, r = e.updateBlock, i = e.removeBlock, a = e.moveBlock, o = e.updateSettings, s = e.setContent;
1227
- e.addBlock = (e, r, i, a) => {
1228
- n(e, r, i, a), t._broadcastOperation({
1229
- operation: "addBlock",
1230
- data: {
1231
- block: e,
1232
- sectionId: r,
1233
- columnIndex: i,
1234
- index: a
1235
- },
1236
- timestamp: Date.now()
1237
- });
1238
- }, e.updateBlock = (e, n) => {
1239
- r(e, n), t._broadcastOperation({
1240
- operation: "updateBlock",
1241
- data: {
1242
- blockId: e,
1243
- updates: n
1244
- },
1245
- timestamp: Date.now()
1246
- });
1247
- }, e.removeBlock = (e) => {
1248
- i(e), t._broadcastOperation({
1249
- operation: "deleteBlock",
1250
- data: { blockId: e },
1251
- timestamp: Date.now()
1252
- });
1253
- }, e.moveBlock = (e, n, r, i) => {
1254
- a(e, n, r, i), t._broadcastOperation({
1255
- operation: "moveBlock",
1256
- data: {
1257
- blockId: e,
1258
- index: n,
1259
- sectionId: r,
1260
- columnIndex: i
1261
- },
1262
- timestamp: Date.now()
1263
- });
1264
- }, e.updateSettings = (e) => {
1265
- o(e), t._broadcastOperation({
1266
- operation: "updateSettings",
1267
- data: { updates: e },
1268
- timestamp: Date.now()
1269
- });
1270
- }, e.setContent = (e, n) => {
1271
- s(e, n), t._broadcastOperation({
1272
- operation: "setContent",
1273
- data: { content: e },
1274
- timestamp: Date.now()
1275
- });
1276
- };
1277
- }
1278
- function P(e) {
1279
- let { authManager: t, onError: r } = e, i = n(null), a = n(!1), o = null, s = null;
1280
- async function c(e, n) {
1281
- if (o) return;
1282
- o = new v({
1283
- authManager: t,
1284
- config: n,
1285
- onError: r
1286
- }), await o.connect(), s = `presence-template.${e}`;
1287
- let c = o.subscribePresence(s);
1288
- c.bind("pusher:subscription_succeeded", () => {
1289
- a.value = !0, i.value = c;
1290
- }), c.bind("pusher:subscription_error", (e) => {
1291
- a.value = !1, i.value = null, r?.(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to subscribe to template channel"));
1292
- });
1293
- }
1294
- function l() {
1295
- s && o && o.unsubscribe(s), o?.disconnect(), o = null, s = null, i.value = null, a.value = !1;
1296
- }
1297
- function u() {
1298
- return o?.getSocketId() ?? null;
1299
- }
1300
- return {
1301
- channel: i,
1302
- isConnected: a,
1303
- connect: c,
1304
- disconnect: l,
1305
- getSocketId: u
1306
- };
1307
- }
1308
- function F(e) {
1309
- let t = new h(e);
1310
- return {
1311
- list(e) {
1312
- return t.listModules(e?.search, e?.category);
1313
- },
1314
- create(e) {
1315
- return t.createModule(e);
1316
- },
1317
- update(e, n) {
1318
- return t.updateModule(e, n);
1319
- },
1320
- delete(e) {
1321
- return t.deleteModule(e);
1322
- }
1323
- };
1324
- }
1325
- function I(e) {
1326
- let t = {
1327
- id: e.id,
1328
- url: e.url,
1329
- filename: e.filename,
1330
- alt: e.alt,
1331
- mimeType: e.mimeType,
1332
- folderId: e.folderId,
1333
- createdAt: e.createdAt,
1334
- updatedAt: e.updatedAt,
1335
- size: e.size
1336
- };
1337
- return e.width != null && (t.width = e.width), e.height != null && (t.height = e.height), e.thumbnailUrl != null && (t.thumbnailUrl = e.thumbnailUrl), t;
1338
- }
1339
- function L(e, t = null) {
1340
- return {
1341
- id: e.id,
1342
- name: e.name,
1343
- parentId: e.parentId === void 0 ? t : e.parentId
1344
- };
1345
- }
1346
- function R(e, t = null) {
1347
- let n = [];
1348
- for (let r of e) n.push(L(r, t)), r.children?.length && n.push(...R(r.children, r.id));
1349
- return n;
1350
- }
1351
- function z(e) {
1352
- let t = e?.media?.categories;
1353
- if (!t) return;
1354
- let n = {};
1355
- for (let [e, r] of Object.entries(t)) n[e] = r.mimeTypes;
1356
- return n;
1357
- }
1358
- function B(e, t) {
1359
- let n = new g(e);
1360
- return {
1361
- async list(e) {
1362
- let t = await n.browseMedia({
1363
- search: e?.search,
1364
- cursor: e?.cursor,
1365
- folderId: e?.folderId,
1366
- category: e?.category
1367
- }), r = { items: t.data.map(I) };
1368
- return t.meta.nextCursor && (r.nextCursor = t.meta.nextCursor), r;
1369
- },
1370
- async create(e) {
1371
- return I(await n.uploadMedia(e.file, e.folderId));
1372
- },
1373
- async update(e, t) {
1374
- return I(await n.updateMedia(e, t.filename, t.alt));
1375
- },
1376
- delete(e) {
1377
- return n.deleteMedia(e);
1378
- },
1379
- folders: {
1380
- async list() {
1381
- return R(await n.getMediaFolders());
1382
- },
1383
- async create(e) {
1384
- return L(await n.createMediaFolder(e.name, e.parentId));
1385
- },
1386
- async update(e, t) {
1387
- return L(await n.renameMediaFolder(e, t.name));
1388
- },
1389
- delete(e) {
1390
- return n.deleteMediaFolder(e);
1391
- },
1392
- async move(e, t) {
1393
- return (await n.moveMedia(e, t)).map(I);
1394
- }
1395
- },
1396
- async replace(e, t) {
1397
- return I(await n.replaceMedia(e, t));
1398
- },
1399
- async importFromUrl(e, t) {
1400
- return I(await n.importFromUrl(e, t));
1401
- },
1402
- async checkUsage(e) {
1403
- let t = await n.checkMediaUsage(e), r = {};
1404
- for (let [e, n] of Object.entries(t.data)) r[e] = {
1405
- templateCount: n.templateCount,
1406
- templateNames: n.templateNames
1407
- };
1408
- return r;
1409
- },
1410
- async frequentlyUsed() {
1411
- return (await n.getFrequentlyUsed()).map(I);
1412
- },
1413
- async storage() {
1414
- return t?.()?.storage ?? null;
1415
- },
1416
- get maxFileSize() {
1417
- return t?.()?.media?.maxFileSize;
1418
- },
1419
- get mimeTypes() {
1420
- return z(t?.() ?? null);
1421
- }
1422
- };
1423
- }
1424
- var V = 6e4;
1425
- function H(e) {
1426
- let t = new h(e), n = 0;
1427
- function r(e, r) {
1428
- let i = Date.now();
1429
- i - n < V || (n = i, t.createVersion(e, r).catch((e) => {
1430
- console.warn("[Templatical] Automatic version not recorded — the save itself succeeded:", e);
1431
- }));
1432
- }
1433
- return {
1434
- load(e) {
1435
- return t.getTemplate(e);
1436
- },
1437
- create(e) {
1438
- return t.createTemplate(e.content, e.name);
1439
- },
1440
- async save(e, n) {
1441
- let i = await t.updateTemplate(e, n);
1442
- return n.content && r(e, n.content), i;
1443
- }
1444
- };
1445
- }
1446
- function U(e) {
1447
- return {
1448
- customFonts: e?.customFonts ?? [],
1449
- defaultFallback: e?.defaultFallback ?? "Arial, sans-serif"
1450
- };
1451
- }
1452
- function W(e) {
1453
- let t = new h(e.authManager);
1454
- async function n(e, n) {
1455
- let r = await t.exportTemplate(e, n);
1456
- return {
1457
- html: r.html,
1458
- mjml: r.mjml
1459
- };
1460
- }
1461
- async function r(e, n) {
1462
- return (await t.exportTemplate(e, n)).mjml;
1463
- }
1464
- return {
1465
- exportHtml: n,
1466
- getMjmlSource: r
1467
- };
1468
- }
1469
- function G(e) {
1470
- let t = W({ authManager: e.authManager });
1471
- function n(e) {
1472
- return {
1473
- customFonts: e.fonts?.customFonts ?? [],
1474
- defaultFallback: e.fonts?.defaultFallback ?? "Arial, sans-serif"
1475
- };
1476
- }
1477
- async function r() {
1478
- 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().");
1479
- return (await e.save()).id;
1480
- }
1481
- return {
1482
- async toMjml(e) {
1483
- let i = n(e), a = await r();
1484
- return t.getMjmlSource(a, i);
1485
- },
1486
- async toHtml(e) {
1487
- let i = n(e), a = await r(), { html: o } = await t.exportHtml(a, i);
1488
- return o;
1489
- }
1490
- };
1491
- }
1492
- function K(e) {
1493
- return {
1494
- id: e.id,
1495
- createdAt: e.createdAt,
1496
- isAutomatic: e.isAutomatic,
1497
- content: e.content
1498
- };
1499
- }
1500
- function q(e) {
1501
- let t = new h(e);
1502
- return {
1503
- async list(e) {
1504
- return { versions: (await t.getVersions(e)).map(K) };
1505
- },
1506
- async get(e, n) {
1507
- return (await t.getVersion(e, n)).content;
1508
- },
1509
- async create(e, n, r) {
1510
- return K(await t.createVersion(e, n, r?.label));
1511
- },
1512
- restore(e, n) {
1513
- return t.restoreVersion(e, n);
1514
- }
1515
- };
1516
- }
1517
- function J(e) {
1518
- let { authManager: i, isAuthReady: a } = e, o = n(null);
1519
- a && t(a, (e) => {
1520
- e && (o.value = i.testEmailConfig);
1521
- }, { immediate: !0 });
1522
- let s = r(() => o.value !== null), c = r(() => o.value?.allowedEmails ?? []);
1523
- function l() {
1524
- return o.value?.signature ?? null;
1525
- }
1526
- return {
1527
- isEnabled: s,
1528
- allowedEmails: c,
1529
- getSignature: l
1530
- };
1531
- }
1532
- function Y(e) {
1533
- let t = new h(e.authManager);
1534
- return {
1535
- get allowedRecipients() {
1536
- return e.allowedEmails.value;
1537
- },
1538
- async send({ recipient: n }) {
1539
- let r = e.getSignature();
1540
- if (r === null) throw Error("Test email is not enabled for this project");
1541
- let i = e.getTemplateId();
1542
- if (i === null) throw Error("Template must be saved before sending a test email");
1543
- await e.save();
1544
- let { html: a } = await e.exportHtml(i);
1545
- e.onBeforeTestEmail && (a = await e.onBeforeTestEmail(a)), await t.sendTestEmail(i, {
1546
- recipient: n,
1547
- html: a,
1548
- allowedEmails: e.allowedEmails.value,
1549
- signature: r
1550
- });
1551
- }
1552
- };
1553
- }
1554
- function X(e) {
1555
- let { authManager: t, onError: i } = e, a = n(null), o = n(!1), s = new h(t), c = r(() => a.value?.features ?? null);
1556
- function l(e) {
1557
- return a.value?.features[e] ?? !1;
1558
- }
1559
- async function u() {
1560
- if (!o.value) {
1561
- o.value = !0;
1562
- try {
1563
- a.value = await s.fetchConfig();
1564
- } catch (e) {
1565
- i?.(e instanceof Error ? e : Error("Failed to fetch config", { cause: e }));
1566
- } finally {
1567
- o.value = !1;
1568
- }
1569
- }
1570
- }
1571
- return {
1572
- config: a,
1573
- isLoading: o,
1574
- hasFeature: l,
1575
- features: c,
1576
- fetchConfig: u
1577
- };
1578
- }
1579
- var Z = 5e3;
1580
- function Q(e) {
1581
- return e.authManager ? e.authManager.resolveUrl(m.health) : `${(e.baseUrl ?? "https://templatical.com").replace(/\/$/, "")}${m.health}`;
1582
- }
1583
- async function $(e, t) {
1584
- let n = performance.now();
1585
- try {
1586
- let r = t ? await t.authenticatedFetch(m.health, {
1587
- method: "GET",
1588
- headers: { Accept: "application/json" }
1589
- }) : await fetch(e, {
1590
- method: "GET",
1591
- headers: { Accept: "application/json" }
1592
- }), i = Math.round(performance.now() - n);
1593
- if (r.status === 401) return {
1594
- api: {
1595
- ok: !0,
1596
- latency: i
1597
- },
1598
- auth: {
1599
- ok: !1,
1600
- error: "HTTP 401"
1601
- }
1602
- };
1603
- if (!r.ok) return {
1604
- api: {
1605
- ok: !1,
1606
- latency: i
1607
- },
1608
- auth: {
1609
- ok: !t,
1610
- error: t ? `HTTP ${r.status}` : void 0
1611
- }
1612
- };
1613
- let a = await r.json();
1614
- return {
1615
- api: {
1616
- ok: a.status === "ok",
1617
- latency: i
1618
- },
1619
- auth: { ok: !0 },
1620
- wsConfig: a.websocket
1621
- };
1622
- } catch (e) {
1623
- return {
1624
- api: {
1625
- ok: !1,
1626
- latency: Math.round(performance.now() - n)
1627
- },
1628
- auth: {
1629
- ok: !t,
1630
- error: t ? e instanceof Error ? e.message : "Authentication check failed" : void 0
1631
- }
1632
- };
1633
- }
1634
- }
1635
- async function ee(e) {
1636
- if (!e?.host || !e?.appKey) return {
1637
- ok: !1,
1638
- error: "WebSocket configuration not available"
1639
- };
1640
- if (typeof WebSocket > "u") return {
1641
- ok: !1,
1642
- error: "WebSocket not supported in this environment"
1643
- };
1644
- let t = `${e.port === 443 ? "wss" : "ws"}://${e.host}:${e.port}/app/${e.appKey}?protocol=7&client=js&version=8.4.0-rc2&flash=false`;
1645
- return new Promise((e) => {
1646
- let n = null, r = setTimeout(() => {
1647
- n?.close(), e({
1648
- ok: !1,
1649
- error: "WebSocket connection timed out"
1650
- });
1651
- }, Z);
1652
- try {
1653
- n = new WebSocket(t);
1654
- } catch (t) {
1655
- clearTimeout(r), e({
1656
- ok: !1,
1657
- error: t instanceof Error ? t.message : "WebSocket connection failed"
1658
- });
1659
- return;
1660
- }
1661
- n.onopen = () => {
1662
- clearTimeout(r), n?.close(), e({ ok: !0 });
1663
- }, n.onerror = () => {
1664
- clearTimeout(r), e({
1665
- ok: !1,
1666
- error: "WebSocket connection failed"
1667
- });
1668
- };
1669
- });
1670
- }
1671
- async function te(e = {}) {
1672
- let t = await $(Q(e), e.authManager), n = await ee(t.wsConfig);
1673
- return {
1674
- api: t.api,
1675
- websocket: n,
1676
- auth: t.auth,
1677
- overall: t.api.ok && t.auth.ok
1678
- };
1679
- }
1680
- function ne(e) {
1681
- let { editor: n, channel: r, onOperation: i } = e;
1682
- t(r, (e, t) => {
1683
- t && t.unbind("mcp-operation"), e && e.bind("mcp-operation", (e) => {
1684
- y(n, e), i?.(e);
1685
- });
1686
- });
1687
- }
1688
- //#endregion
1689
- export { P as C, J as S, T as _, F as a, X as b, q as c, U as d, _ as f, N as g, M as h, G as i, a as l, C as m, O as n, H as o, S as p, B as r, Y as s, o as t, te as u, W as v, w as x, ne as y };