@templatical/editor 0.43.3 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AiChatSidebar-BAAypLEP.js → AiChatSidebar-BUR5Jshu.js} +8 -8
- package/dist/{AiFeatureMenu-CQcrDR-J.js → AiFeatureMenu-CgfLFHJw.js} +4 -4
- package/dist/{BlockIssueBadge-DYI7ic1j.js → BlockIssueBadge-CWZEwMXX.js} +2 -2
- package/dist/{BlockPreviewCanvas-x5W-Sdhg.js → BlockPreviewCanvas-2vVu55yN.js} +3 -3
- package/dist/{CloudHeaderExtras-DnLaX4ea.js → CloudHeaderExtras-BZ62q1aS.js} +2 -2
- package/dist/{CloudPanels-BHPG3d1o.js → CloudPanels-sv4aCKKE.js} +4 -4
- package/dist/{CollaboratorBar-DG6KroMt.js → CollaboratorBar-CSEFL7uC.js} +2 -2
- package/dist/{CommentsPanel-Bzk6VhJg.js → CommentsPanel-CYMHfFcn.js} +1 -1
- package/dist/{CommentsSidebar-CaRC3c1b.js → CommentsSidebar-uvQyCMUe.js} +10 -10
- package/dist/{CountdownToolbar-B-pAigUh.js → CountdownToolbar-C052mx2P.js} +3 -3
- package/dist/{DesignReferenceSidebar-DfuJyDBz.js → DesignReferenceSidebar-ZKJ7y7-G.js} +6 -6
- package/dist/{IssuesPanel-vWhcDIvb.js → IssuesPanel-DAlNiJX_.js} +5 -5
- package/dist/{LogicTagInsertButton-D2Fjo444.js → LogicTagInsertButton-DMUfVsPr.js} +6 -6
- package/dist/{MediaEditModal-BuP8SJrv.js → MediaEditModal-Cmd9tQXZ.js} +1 -1
- package/dist/{MediaPanels-BkcF0r_r.js → MediaPanels-DoBhG5gg.js} +1 -1
- package/dist/{MergeTagInput-fEOOY7OU.js → MergeTagInput-DoQWMSW4.js} +1 -1
- package/dist/{MergeTagModeToggle-BOeEL52u.js → MergeTagModeToggle-DOHixe4G.js} +4 -4
- package/dist/{ParagraphEditor-BlJGeBRY.js → ParagraphEditor-C_p6yKLK.js} +10 -10
- package/dist/{RestoreVersionDialog-DYaoFk5G.js → RestoreVersionDialog-CKHeCPG2.js} +3 -3
- package/dist/{RichTextEditorContent-GacK8qwu.js → RichTextEditorContent-BedBVHXS.js} +4 -4
- package/dist/{SaveBlockDialog-DR1UCtQY.js → SaveBlockDialog-q3_fjb9t.js} +8 -8
- package/dist/{SavedBlocksBrowserModal-q_-qYW9a.js → SavedBlocksBrowserModal-DeUo5aFV.js} +87 -86
- package/dist/{SavedBlocksPanels-nTH8NTAT.js → SavedBlocksPanels-DNpnl5cO.js} +1 -1
- package/dist/{SavedBlocksPickBar-C7vHmc5c.js → SavedBlocksPickBar-Pq2bjpB_.js} +2 -2
- package/dist/{TemplateScoringPanel-D9jeQCYl.js → TemplateScoringPanel-DXsyp0_A.js} +11 -11
- package/dist/{TemplateSettings-ClfHwxUa.js → TemplateSettings-Bh10NFIN.js} +6 -6
- package/dist/{TestEmailModal-DEnvrv38.js → TestEmailModal-BYCKpH7g.js} +7 -7
- package/dist/{TestEmailPanel-Ca9t6KG7.js → TestEmailPanel-lUXAFsT5.js} +1 -1
- package/dist/{TitleEditor-D7mNs3s5.js → TitleEditor-CWPxXUp2.js} +6 -6
- package/dist/{ToggleSwitch-Z-rqEcig.js → ToggleSwitch-D7GLaT8s.js} +1 -1
- package/dist/{Toolbar-DUgyDBkz.js → Toolbar-CWxqqBHE.js} +21 -21
- package/dist/{TplModal-CYyFAScB.js → TplModal-D6lqrKls.js} +1 -1
- package/dist/{VersionHistoryMenu-D42tGKM6.js → VersionHistoryMenu-fLrx-Lvi.js} +5 -5
- package/dist/{VersionHistoryPanels-o0HGvQJX.js → VersionHistoryPanels-C3XhpQO_.js} +1 -1
- package/dist/{VersionPreviewBanner-D5RZtvUf.js → VersionPreviewBanner-CWuxq_bb.js} +1 -1
- package/dist/{WrapperBlock-B0_vSfSD.js → WrapperBlock-ox8TMS_p.js} +1 -1
- package/dist/{blockTypeIcons-CEk_GHmU.js → blockTypeIcons-DEvNVvBj.js} +2 -2
- package/dist/bundle-stats.json +6 -6
- package/dist/cdn/chunks/{AiChatSidebar-oFwacME4.js → AiChatSidebar-Cvp9beXR.js} +3 -3
- package/dist/cdn/chunks/{AiChatSidebar-oFwacME4.js.map → AiChatSidebar-Cvp9beXR.js.map} +1 -1
- package/dist/cdn/chunks/{AiFeatureMenu-BiHFJf9i.js → AiFeatureMenu-vOJtwdmT.js} +3 -3
- package/dist/cdn/chunks/{AiFeatureMenu-BiHFJf9i.js.map → AiFeatureMenu-vOJtwdmT.js.map} +1 -1
- package/dist/cdn/chunks/{BlockIssueBadge-CWlcDBFm.js → BlockIssueBadge-CKIrYROg.js} +2 -2
- package/dist/cdn/chunks/{BlockIssueBadge-CWlcDBFm.js.map → BlockIssueBadge-CKIrYROg.js.map} +1 -1
- package/dist/cdn/chunks/{BlockPreviewCanvas-CIwIA3zq.js → BlockPreviewCanvas-CB27Joyn.js} +4 -4
- package/dist/cdn/chunks/{BlockPreviewCanvas-CIwIA3zq.js.map → BlockPreviewCanvas-CB27Joyn.js.map} +1 -1
- package/dist/cdn/chunks/{CloudHeaderExtras-BgsjwWUQ.js → CloudHeaderExtras-9tKrhPm6.js} +3 -3
- package/dist/cdn/chunks/{CloudHeaderExtras-BgsjwWUQ.js.map → CloudHeaderExtras-9tKrhPm6.js.map} +1 -1
- package/dist/cdn/chunks/{CloudPanels-DFCwq8_J.js → CloudPanels-DTQ7zbEN.js} +4 -4
- package/dist/cdn/chunks/{CloudPanels-DFCwq8_J.js.map → CloudPanels-DTQ7zbEN.js.map} +1 -1
- package/dist/cdn/chunks/{CollaboratorBar-CiMZfMwN.js → CollaboratorBar-BKTkVMbz.js} +3 -3
- package/dist/cdn/chunks/{CollaboratorBar-CiMZfMwN.js.map → CollaboratorBar-BKTkVMbz.js.map} +1 -1
- package/dist/cdn/chunks/{CommentsPanel-CL4grbMp.js → CommentsPanel-BjHRj_Yw.js} +2 -2
- package/dist/cdn/chunks/{CommentsPanel-CL4grbMp.js.map → CommentsPanel-BjHRj_Yw.js.map} +1 -1
- package/dist/cdn/chunks/{CommentsSidebar-tWYYKv1s.js → CommentsSidebar-CpCfqSq4.js} +2 -2
- package/dist/cdn/chunks/{CommentsSidebar-tWYYKv1s.js.map → CommentsSidebar-CpCfqSq4.js.map} +1 -1
- package/dist/cdn/chunks/{CountdownToolbar-DfyqIppF.js → CountdownToolbar-C9QpHQcv.js} +4 -4
- package/dist/cdn/chunks/{CountdownToolbar-DfyqIppF.js.map → CountdownToolbar-C9QpHQcv.js.map} +1 -1
- package/dist/cdn/chunks/{DesignReferenceSidebar-C6O12hvt.js → DesignReferenceSidebar-BO0xz1wC.js} +3 -3
- package/dist/cdn/chunks/{DesignReferenceSidebar-C6O12hvt.js.map → DesignReferenceSidebar-BO0xz1wC.js.map} +1 -1
- package/dist/cdn/chunks/{IssuesPanel-DYJXIwnw.js → IssuesPanel--62qud8w.js} +2 -2
- package/dist/cdn/chunks/{IssuesPanel-DYJXIwnw.js.map → IssuesPanel--62qud8w.js.map} +1 -1
- package/dist/cdn/chunks/{LogicTagInsertButton-FNMVxm_V.js → LogicTagInsertButton-gc8ICURV.js} +5 -5
- package/dist/cdn/chunks/{LogicTagInsertButton-FNMVxm_V.js.map → LogicTagInsertButton-gc8ICURV.js.map} +1 -1
- package/dist/cdn/chunks/{MediaEditModal-C9yZ0AJv.js → MediaEditModal-BuDXKwx4.js} +2 -2
- package/dist/cdn/chunks/{MediaEditModal-C9yZ0AJv.js.map → MediaEditModal-BuDXKwx4.js.map} +1 -1
- package/dist/cdn/chunks/{MediaPanels-DiKU1r9P.js → MediaPanels-xFpaxFRH.js} +2 -2
- package/dist/cdn/chunks/{MediaPanels-DiKU1r9P.js.map → MediaPanels-xFpaxFRH.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagInput-CSC64xNL.js → MergeTagInput-DsPKWbWr.js} +2 -2
- package/dist/cdn/chunks/{MergeTagInput-CSC64xNL.js.map → MergeTagInput-DsPKWbWr.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagModeToggle-027RMXDP.js → MergeTagModeToggle-DU0WqgVH.js} +3 -3
- package/dist/cdn/chunks/{MergeTagModeToggle-027RMXDP.js.map → MergeTagModeToggle-DU0WqgVH.js.map} +1 -1
- package/dist/cdn/chunks/{ParagraphEditor-0Z26-N5u.js → ParagraphEditor-BSDGOsja.js} +10 -10
- package/dist/cdn/chunks/{ParagraphEditor-0Z26-N5u.js.map → ParagraphEditor-BSDGOsja.js.map} +1 -1
- package/dist/cdn/chunks/{RestoreVersionDialog-Dd1v1KLK.js → RestoreVersionDialog-DLe0Co57.js} +3 -3
- package/dist/cdn/chunks/{RestoreVersionDialog-Dd1v1KLK.js.map → RestoreVersionDialog-DLe0Co57.js.map} +1 -1
- package/dist/cdn/chunks/{RichTextEditorContent-BOZ_5I76.js → RichTextEditorContent-Dkcts8Vh.js} +4 -4
- package/dist/cdn/chunks/{RichTextEditorContent-BOZ_5I76.js.map → RichTextEditorContent-Dkcts8Vh.js.map} +1 -1
- package/dist/cdn/chunks/{SaveBlockDialog-B6WQwNJD.js → SaveBlockDialog-DQzaED8U.js} +7 -7
- package/dist/cdn/chunks/{SaveBlockDialog-B6WQwNJD.js.map → SaveBlockDialog-DQzaED8U.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-C015fVMV.js → SavedBlocksBrowserModal-CliZBxHo.js} +138 -137
- package/dist/cdn/chunks/SavedBlocksBrowserModal-CliZBxHo.js.map +1 -0
- package/dist/cdn/chunks/{SavedBlocksPanels-DZmfXW4x.js → SavedBlocksPanels-lW7PMvJN.js} +2 -2
- package/dist/cdn/chunks/{SavedBlocksPanels-DZmfXW4x.js.map → SavedBlocksPanels-lW7PMvJN.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPickBar-DtCQFCCW.js → SavedBlocksPickBar-DEL0r3Bv.js} +3 -3
- package/dist/cdn/chunks/{SavedBlocksPickBar-DtCQFCCW.js.map → SavedBlocksPickBar-DEL0r3Bv.js.map} +1 -1
- package/dist/cdn/chunks/{TemplateScoringPanel-CeCVyNV1.js → TemplateScoringPanel-BBRHCNcR.js} +2 -2
- package/dist/cdn/chunks/{TemplateScoringPanel-CeCVyNV1.js.map → TemplateScoringPanel-BBRHCNcR.js.map} +1 -1
- package/dist/cdn/chunks/{TemplateSettings-CuXwthI6.js → TemplateSettings-vsFOU0oA.js} +5 -5
- package/dist/cdn/chunks/{TemplateSettings-CuXwthI6.js.map → TemplateSettings-vsFOU0oA.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailModal-DV1XKWRh.js → TestEmailModal-B7Dr2eFa.js} +7 -7
- package/dist/cdn/chunks/{TestEmailModal-DV1XKWRh.js.map → TestEmailModal-B7Dr2eFa.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailPanel-CnVW00RI.js → TestEmailPanel-C3PTYDbT.js} +2 -2
- package/dist/cdn/chunks/{TestEmailPanel-CnVW00RI.js.map → TestEmailPanel-C3PTYDbT.js.map} +1 -1
- package/dist/cdn/chunks/{TitleEditor-B9sKbRd4.js → TitleEditor-gHTla_4I.js} +5 -5
- package/dist/cdn/chunks/{TitleEditor-B9sKbRd4.js.map → TitleEditor-gHTla_4I.js.map} +1 -1
- package/dist/cdn/chunks/{ToggleSwitch-eHkFBx4o.js → ToggleSwitch-DoUNcLPP.js} +2 -2
- package/dist/cdn/chunks/{ToggleSwitch-eHkFBx4o.js.map → ToggleSwitch-DoUNcLPP.js.map} +1 -1
- package/dist/cdn/chunks/{Toolbar-DeKbYejp.js → Toolbar-CnfNUkOY.js} +9 -9
- package/dist/cdn/chunks/{Toolbar-DeKbYejp.js.map → Toolbar-CnfNUkOY.js.map} +1 -1
- package/dist/cdn/chunks/{TplModal-Dqq-Ermd.js → TplModal-BVUBOEQL.js} +2 -2
- package/dist/cdn/chunks/{TplModal-Dqq-Ermd.js.map → TplModal-BVUBOEQL.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryMenu-Kf4QFm7m.js → VersionHistoryMenu-Cp3EHO_P.js} +2 -2
- package/dist/cdn/chunks/{VersionHistoryMenu-Kf4QFm7m.js.map → VersionHistoryMenu-Cp3EHO_P.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryPanels-Cz8rde-s.js → VersionHistoryPanels-Dcdy7ySA.js} +2 -2
- package/dist/cdn/chunks/{VersionHistoryPanels-Cz8rde-s.js.map → VersionHistoryPanels-Dcdy7ySA.js.map} +1 -1
- package/dist/cdn/chunks/{VersionPreviewBanner-DNYHqbj9.js → VersionPreviewBanner-BgkroXnG.js} +2 -2
- package/dist/cdn/chunks/{VersionPreviewBanner-DNYHqbj9.js.map → VersionPreviewBanner-BgkroXnG.js.map} +1 -1
- package/dist/cdn/chunks/{WrapperBlock-DIZHUwFn.js → WrapperBlock-23nAzweL.js} +2 -2
- package/dist/cdn/chunks/{WrapperBlock-DIZHUwFn.js.map → WrapperBlock-23nAzweL.js.map} +1 -1
- package/dist/cdn/chunks/{blockTypeIcons-hgzxMFWX.js → blockTypeIcons-BMZi7sdX.js} +2 -2
- package/dist/cdn/chunks/{blockTypeIcons-hgzxMFWX.js.map → blockTypeIcons-BMZi7sdX.js.map} +1 -1
- package/dist/cdn/chunks/{cloud-De-eh1u6.js → cloud-DLQU5l0Z.js} +2 -2
- package/dist/cdn/chunks/{cloud-De-eh1u6.js.map → cloud-DLQU5l0Z.js.map} +1 -1
- package/dist/cdn/chunks/{createCloudRuntime-DsaUaWvr.js → createCloudRuntime-Mnx8kV2W.js} +3 -3
- package/dist/cdn/chunks/{createCloudRuntime-DsaUaWvr.js.map → createCloudRuntime-Mnx8kV2W.js.map} +1 -1
- package/dist/cdn/chunks/{editor-modal-cKeJ4wC2.js → editor-modal-B7NNAFI5.js} +4 -4
- package/dist/cdn/chunks/{editor-modal-cKeJ4wC2.js.map → editor-modal-B7NNAFI5.js.map} +1 -1
- package/dist/cdn/chunks/en-C3n0qWte.js +2 -0
- package/dist/cdn/chunks/{extensions-rPP7qRRm.js → extensions-ClmkNA8R.js} +4 -4
- package/dist/cdn/chunks/{extensions-rPP7qRRm.js.map → extensions-ClmkNA8R.js.map} +1 -1
- package/dist/cdn/chunks/{icons-BF0mJX0V.js → icons-BjvraR-Y.js} +25 -25
- package/dist/cdn/chunks/{icons-BF0mJX0V.js.map → icons-BjvraR-Y.js.map} +1 -1
- package/dist/cdn/chunks/{preRenderCustomBlocks-h4ZFBKbD.js → preRenderCustomBlocks-Bg3rIgGJ.js} +2 -2
- package/dist/cdn/chunks/{preRenderCustomBlocks-h4ZFBKbD.js.map → preRenderCustomBlocks-Bg3rIgGJ.js.map} +1 -1
- package/dist/cdn/chunks/{socialIcons-ZOCwCCyn.js → socialIcons-CnUJBZTO.js} +2 -2
- package/dist/cdn/chunks/socialIcons-CnUJBZTO.js.map +1 -0
- package/dist/cdn/chunks/{src-fZSLjhjy.js → src-B5-VKcRQ.js} +2 -2
- package/dist/cdn/chunks/{src-fZSLjhjy.js.map → src-B5-VKcRQ.js.map} +1 -1
- package/dist/cdn/chunks/{src-V9_ODH_1.js → src-D_l1LAxs.js} +3 -3
- package/dist/cdn/chunks/{src-V9_ODH_1.js.map → src-D_l1LAxs.js.map} +1 -1
- package/dist/cdn/chunks/{src-BR3I3gOW.js → src-QIGNPFkl.js} +6 -8
- package/dist/cdn/chunks/src-QIGNPFkl.js.map +1 -0
- package/dist/cdn/chunks/{useEditorCore-DWvAia8X.js → useEditorCore-DjD7fJpq.js} +10 -10
- package/dist/cdn/chunks/{useEditorCore-DWvAia8X.js.map → useEditorCore-DjD7fJpq.js.map} +1 -1
- package/dist/cdn/chunks/{useLogicTag-J_i_hvZg.js → useLogicTag-D6lWY0bD.js} +2 -2
- package/dist/cdn/chunks/{useLogicTag-J_i_hvZg.js.map → useLogicTag-D6lWY0bD.js.map} +1 -1
- package/dist/cdn/chunks/{useMergeTag-C5MyHYxJ.js → useMergeTag-2iW-BKWW.js} +2 -2
- package/dist/cdn/chunks/{useMergeTag-C5MyHYxJ.js.map → useMergeTag-2iW-BKWW.js.map} +1 -1
- package/dist/cdn/editor.css +1 -1
- package/dist/cdn/editor.js +316 -286
- package/dist/cdn/editor.js.map +1 -1
- package/dist/{check-DEjsanPt.js → check-DNyj-E0y.js} +1 -1
- package/dist/{chevron-down-Cv11TeKQ.js → chevron-down-BYnhkMsA.js} +1 -1
- package/dist/{chevron-right-R8dOpzBZ.js → chevron-right-D9HGBqJo.js} +1 -1
- package/dist/{chevron-up-DsDEytX1.js → chevron-up-BnIR1-ma.js} +1 -1
- package/dist/{circle-alert-B_NqWETg.js → circle-alert-B6xl1B_M.js} +1 -1
- package/dist/{clock-CDGKPx_X.js → clock-Cs5Wd3dW.js} +1 -1
- package/dist/{cloud-AO_X8T9g.js → cloud-BNEL7bxL.js} +1 -1
- package/dist/{copy-Dv2VltLv.js → copy-6uKc-WBk.js} +1 -1
- package/dist/{createCloudRuntime-D641nhri.js → createCloudRuntime-CaZapQZ6.js} +2 -2
- package/dist/{createLucideIcon-MrFrvtkF.js → createLucideIcon-BVcoovvP.js} +5 -5
- package/dist/{dist-iLUVPysa.js → dist-HjILVdTA.js} +5 -7
- package/dist/{editor-modal-DmgxKgII.js → editor-modal-Co-rZGaf.js} +16 -16
- package/dist/en-B-xoKkWi.js +2 -0
- package/dist/{extensions-CkwL1oWn.js → extensions-DXSI8Dyj.js} +3 -3
- package/dist/{eye-BVxcDaZZ.js → eye-Nbtw_q05.js} +1 -1
- package/dist/{image-up-CnC4n-8q.js → image-up-C1jC7NzQ.js} +1 -1
- package/dist/index.d.ts +2431 -376
- package/dist/{info-q7gVjMBC.js → info-ClH66pKN.js} +1 -1
- package/dist/{link-B1-UqOP6.js → link-y47GNW0o.js} +1 -1
- package/dist/{list-BvlNrd6M.js → list-DiLMlMaE.js} +1 -1
- package/dist/{loader-circle-CJ8klGfl.js → loader-circle-BRdCPW5h.js} +1 -1
- package/dist/{message-circle-Bgepipq_.js → message-circle-CNgIpVJv.js} +1 -1
- package/dist/{package-BYIdon2Q.js → package-B9OWk-Kp.js} +1 -1
- package/dist/{pencil-Bhs9MNTT.js → pencil-BDnjo24u.js} +1 -1
- package/dist/{plus-C0eGj8vT.js → plus-BMgjN7lI.js} +1 -1
- package/dist/{preRenderCustomBlocks-CTstI3Q-.js → preRenderCustomBlocks-C_PIxBp7.js} +1 -1
- package/dist/{refresh-cw-BQTOIZKD.js → refresh-cw-CR5lenxl.js} +1 -1
- package/dist/{search-CeT7yRBa.js → search-CxRUiOSF.js} +1 -1
- package/dist/{send-D7ck2xEq.js → send-Bu2RysGL.js} +1 -1
- package/dist/{shield-check-CF_VbIbH.js → shield-check-Cg8f4LB0.js} +1 -1
- package/dist/{smartphone-CkVOj7Qn.js → smartphone-CHf-8lHp.js} +1 -1
- package/dist/{socialIcons-QYtdurnO.js → socialIcons-D1gkHc_i.js} +2 -2
- package/dist/{sparkles-Cfb-Kkgv.js → sparkles-_DQGv4ub.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/templatical-editor.js +491 -461
- package/dist/{text-align-start-CkFs2Zig.js → text-align-start-PHo-Ep5i.js} +1 -1
- package/dist/{trash-C2LPw5pa.js → trash-BxIzHAri.js} +1 -1
- package/dist/{triangle-alert-gaUz4rum.js → triangle-alert-fcb2KoA-.js} +1 -1
- package/dist/{upload-C_DYZD_p.js → upload-BxBtMPMv.js} +1 -1
- package/dist/{useEditorCore-Cmv5ll-D.js → useEditorCore-iuKC8yr5.js} +14 -14
- package/dist/{useLogicTag-BaH8gey0.js → useLogicTag-wqfdwYYR.js} +1 -1
- package/dist/{useMergeTag-Cyad1yBE.js → useMergeTag-D3XDE_58.js} +1 -1
- package/dist/{useScrollToBlock-BsPYYJ8h.js → useScrollToBlock-DA_aIJXS.js} +1 -1
- package/dist/{x-JhKma5YO.js → x-DrZO5tt0.js} +1 -1
- package/package.json +15 -11
- package/dist/cdn/chunks/SavedBlocksBrowserModal-C015fVMV.js.map +0 -1
- package/dist/cdn/chunks/en-CoNe1psX.js +0 -2
- package/dist/cdn/chunks/socialIcons-ZOCwCCyn.js.map +0 -1
- package/dist/cdn/chunks/src-BR3I3gOW.js.map +0 -1
- package/dist/en-DXYNty6E.js +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"socialIcons-ZOCwCCyn.js","names":["computed","DEFAULT_KEY","computed","computed","computed","watch$1","ref","computed","reactive","onScopeDispose","readonly","computed$1","watch","toValue","createBlock","createDefaultTemplateContent","assertNoWrapperInContent","safeClone","generateId","SOCIAL_ICON_GLYPHS","SdkError","assertNoSlotInContent","useDropZone","DEFAULT_RESOLVED_COLORS","resolveColorsConfig","wrapReportedError","error","notifyHandler","getColumnCount","layout","useEditor","seedContent","options","state","revision","touch","content","value","selectedBlock","findBlockById","block","blocks","id","column","found","collectBlockIds","ids","child","findBlockParent","i","parent","colIdx","result","isBlockLocked","blockId","findBlockLocation","index","b","setContent","newContent","markDirty","selectBlock","setViewport","viewport","setDarkMode","darkMode","setUiTheme","theme","setPreviewMode","previewMode","updateBlock","updates","updateSettings","addBlock","candidate","targetSectionId","section","columnIndex","targetArray","removeBlock","removed","removedIds","moveBlock","oldIndex","newIndex","refuse","action","reason","notify","run","requireProvider","templates","setName","create","provider","providerCreate","created","input","revisionAtRequest","load","loaded","templateId","save","providerSave","current","patch","saved","localName","hasTemplate","MAX_STACK_SIZE","DEBOUNCE_MS","NAVIGATE_IDLE_MS","useHistory","undoStack","redoStack","isNavigating","navigatingTimeoutId","pendingDebounce","canUndo","canRedo","cloneContent","pushToUndoStack","snapshot","maxSize","flushPendingDebounce","record","isRemoteOperation","recordDebounced","setNavigating","undo","redo","clear","destroy","regenerateNestedIds","row","cell","icon","item","useBlockActions","createAndAddBlock","defaults","type","duplicateBlock","cloned","clonedChild","sourceLocation","deleteBlock","updateBlockProperty","key","DEFAULT_AUTO_SAVE_DEBOUNCE_MS","useAutoSave","timeoutId","paused","isEnabled","enabled","pause","cancel","resume","flush","isDirty","onChange","scheduleOnChange","debounce","stopWatch","useConditionPreview","hiddenBlockIds","hasHiddenBlocks","isHidden","toggleBlock","editor","reset","useDataSourceFetch","isFetching","fetchError","hasDataSource","needsFetch","fetch","def","merged","useHistoryInterceptor","originalAddBlock","originalRemoveBlock","originalMoveBlock","originalUpdateBlock","originalUpdateSettings","history","useSavedBlocks","savedBlocks","isLoading","categories","seen","category","a","canCreate","canUpdate","canDelete","canUpdateBlock","canDeleteBlock","params","update","providerUpdate","local","updated","remove","providerDelete","DEFAULT_KEY$1","createLocalStorageSavedBlocksProvider","storageKey","getStorage","readAll","raw","parsed","writeAll","all","search","now","next","DEFAULT_KEY","PAGE_SIZE","createLocalStorageMediaProvider","assets","readFileAsDataURL","reader","file","filtered","filename","asset","alt","offset","items","page","nextOffset","url","useVersionHistory","versions","nextCursor","isRestoring","fetched","canRestore","requireTemplateId","getTemplateId","peekContent","version","resolveContent","known","meta","restore","providerRestore","restored","versionId","useComments","comments","isSubmitting","canResolve","totalCount","sum","thread","unresolvedCount","commentCountByBlock","map","requireUser","user","getUser","find","commentId","reply","isOwn","comment","report","wrapped","replaceAt","list","sameComment","upsert","changed","replies","at","drop","existing","parentId","r","c","setResolved","providerSetResolved","resolved","applyRemoteCreate","applyRemoteUpdate","applyRemoteDelete","useCommentListener","subscribe","unsubscribe","stop","change","getBlockTypeLabel","translations","blockType","getBlockLabel","customBlockDefinitions","d","customType","resolveFieldColors","own","field","presetsInherited","editorResolved","IMAGE_MIME_PREFIX","useImageDrop","target","images","files","onFiles","isOverDropZone","socialIcons","socialIconSizeMap","socialPlatformOptions"],"sources":["../../../../core/src/error-reporting.ts","../../../../core/src/editor.ts","../../../../core/src/history.ts","../../../../core/src/block-actions.ts","../../../../core/src/auto-save.ts","../../../../core/src/condition-preview.ts","../../../../core/src/data-source-fetch.ts","../../../../core/src/history-interceptor.ts","../../../../core/src/saved-blocks.ts","../../../../core/src/saved-blocks-local.ts","../../../../core/src/media-local.ts","../../../../core/src/version-history.ts","../../../../core/src/comments.ts","../../../src/utils/blockTypeLabels.ts","../../../src/utils/resolveFieldColors.ts","../../../src/composables/useImageDrop.ts","../../../src/constants/socialIcons.ts"],"sourcesContent":["/**\n * Turn a thrown value into an `Error`.\n *\n * A `catch` clause's binding is `unknown` — a provider or a consumer's event\n * handler can throw a string, an object, or anything else. `onError` callbacks\n * across this package are typed to take an `Error`, so this is what makes that\n * contract honest at the one place values actually cross it.\n */\nexport function wrapReportedError(error: unknown): Error {\n return error instanceof Error\n ? error\n : new Error(String(error), { cause: error });\n}\n\n/**\n * Run a consumer's event handler without letting it fail the operation it\n * followed.\n *\n * A handler that throws must not turn a completed write into a rejected one —\n * the caller has already succeeded by the time this runs. `onError` is taken\n * as a parameter rather than read from a shared reporter, so every feature\n * module keeps its own `options.onError` wiring and this stays reusable by\n * any module with the same fire-and-forget event shape.\n */\nexport function notifyHandler(\n onError: ((error: Error) => void) | undefined,\n run: () => void,\n): void {\n try {\n run();\n } catch (error) {\n onError?.(wrapReportedError(error));\n }\n}\n","import type {\n Block,\n ColumnLayout,\n Template,\n TemplateContent,\n TemplateDefaults,\n TemplatePatch,\n TemplateSaveTrigger,\n TemplateSettings,\n TemplatesProvider,\n UiTheme,\n ViewportSize,\n} from \"@templatical/types\";\nimport {\n assertNoSlotInContent,\n assertNoWrapperInContent,\n createDefaultTemplateContent,\n SdkError,\n} from \"@templatical/types\";\nimport { notifyHandler } from \"./error-reporting\";\n\nfunction getColumnCount(layout: ColumnLayout): number {\n if (layout === \"1\") return 1;\n if (layout === \"3\") return 3;\n return 2;\n}\nimport {\n computed,\n reactive,\n readonly,\n type DeepReadonly,\n type Ref,\n} from \"@vue/reactivity\";\n\nexport interface EditorState {\n /**\n * The template currently being edited, as the store last returned it — `null`\n * until `create()` or `load()` resolves, and always `null` without a\n * {@link TemplatesProvider}.\n *\n * Carries identity and name only for practical purposes: its `content` is the\n * store's copy from the last round-trip, whereas `state.content` is what the\n * user is editing.\n */\n template: Template | null;\n content: TemplateContent;\n selectedBlockId: string | null;\n viewport: ViewportSize;\n darkMode: boolean;\n previewMode: boolean;\n isDirty: boolean;\n /** True for the duration of a `save()` call. */\n isSaving: boolean;\n /** True for the duration of a `create()` or `load()` call. */\n isLoading: boolean;\n uiTheme: UiTheme;\n}\n\nexport interface UseEditorOptions {\n content: TemplateContent;\n defaultFontFamily?: string;\n templateDefaults?: TemplateDefaults;\n lockedBlocks?: Ref<Map<string, unknown>>;\n /**\n * Storage backend for the template's save/load lifecycle. Omit it and\n * `create()` / `load()` / `save()` reject — the editor keeps working as a\n * purely local editing surface.\n */\n templates?: TemplatesProvider;\n /**\n * Called with any error a provider call rejects with, before the rejection is\n * re-thrown to the caller.\n */\n onError?: (error: Error) => void;\n}\n\nexport interface UseEditorReturn {\n state: DeepReadonly<EditorState>;\n content: Ref<TemplateContent>;\n selectedBlock: Ref<Block | null>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n selectBlock: (blockId: string | null) => void;\n setViewport: (viewport: ViewportSize) => void;\n setDarkMode: (darkMode: boolean) => void;\n setPreviewMode: (previewMode: boolean) => void;\n setUiTheme: (theme: UiTheme) => void;\n updateBlock: (blockId: string, updates: Partial<Block>) => void;\n updateSettings: (updates: Partial<TemplateSettings>) => void;\n addBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n index?: number,\n ) => void;\n removeBlock: (blockId: string) => void;\n moveBlock: (\n blockId: string,\n newIndex: number,\n targetSectionId?: string,\n columnIndex?: number,\n ) => void;\n isBlockLocked: (blockId: string) => boolean;\n markDirty: () => void;\n findBlockLocation: (blockId: string) => {\n targetSectionId?: string;\n columnIndex?: number;\n index: number;\n } | null;\n /**\n * Rename the loaded template locally and mark the editor dirty. The new name\n * reaches the store on the next `save()`, in the same patch as the content —\n * a rename is an ordinary unsaved change, not a side channel.\n *\n * This method only stages it. The editor's inline rename field commits by\n * calling `setName()` and then saving immediately, because a rename reads as a\n * discrete action rather than an edit to be batched — so in the editor the\n * \"next `save()`\" is usually the one it triggers itself. A headless caller\n * decides its own moment.\n *\n * No-op when no template is loaded: there is nothing to name.\n */\n setName: (name: string) => void;\n /**\n * Persist the current content as a new template. `input.content`, when given,\n * replaces the editor's content first — so `create({ content })` both loads\n * and stores in one step.\n */\n create: (input?: {\n name?: string;\n content?: TemplateContent;\n }) => Promise<Template>;\n /** Fetch a template and make it the editor's content. */\n load: (templateId: string) => Promise<Template>;\n /**\n * Persist the loaded template's name + content as a patch.\n *\n * `trigger` is passed through to `TemplatesOptions.onSaved`. It defaults to\n * `\"api\"`, which is the honest answer for a direct call — the editor package\n * passes the value matching whichever affordance fired.\n */\n save: (trigger?: TemplateSaveTrigger) => Promise<Template>;\n /** Whether a template has been created or loaded. */\n hasTemplate: () => boolean;\n}\n\nexport function useEditor(options: UseEditorOptions): UseEditorReturn {\n const seedContent =\n options.content ??\n createDefaultTemplateContent(\n options.defaultFontFamily,\n options.templateDefaults,\n );\n // Layout-only; authored content must not contain slot or wrapper.\n assertNoSlotInContent(seedContent);\n assertNoWrapperInContent(seedContent);\n\n const state = reactive<EditorState>({\n template: null,\n content: seedContent,\n selectedBlockId: null,\n viewport: \"desktop\",\n darkMode: false,\n previewMode: false,\n isDirty: false,\n isSaving: false,\n isLoading: false,\n uiTheme: \"auto\",\n });\n\n /**\n * Bumped by every content mutation. `save()` captures it before awaiting the\n * provider and only clears `isDirty` if it is unchanged afterwards, so an edit\n * made while a save is in flight is not reported as persisted — which would\n * also make autosave skip it, since that decides dirtiness at debounce time.\n */\n let revision = 0;\n\n function touch(): void {\n state.isDirty = true;\n revision++;\n }\n\n const content = computed({\n get: () => state.content,\n set: (value: TemplateContent) => {\n state.content = value;\n touch();\n },\n });\n\n const selectedBlock = computed(() => {\n if (!state.selectedBlockId) return null;\n return findBlockById(state.content.blocks, state.selectedBlockId);\n });\n\n function findBlockById(blocks: Block[], id: string): Block | null {\n for (const block of blocks) {\n if (block.id === id) return block;\n if (block.type === \"section\") {\n for (const column of block.children) {\n const found = findBlockById(column, id);\n if (found) return found;\n }\n }\n }\n return null;\n }\n\n function collectBlockIds(block: Block, ids: Set<string>): void {\n ids.add(block.id);\n if (block.type === \"section\") {\n for (const column of block.children) {\n for (const child of column) {\n collectBlockIds(child, ids);\n }\n }\n }\n }\n\n function findBlockParent(\n blocks: Block[],\n id: string,\n parent: {\n blocks: Block[];\n sectionId?: string;\n columnIndex?: number;\n } = { blocks },\n ): { blocks: Block[]; sectionId?: string; columnIndex?: number } | null {\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n if (block.id === id) return parent;\n if (block.type === \"section\") {\n for (let colIdx = 0; colIdx < block.children.length; colIdx++) {\n const result = findBlockParent(block.children[colIdx], id, {\n blocks: block.children[colIdx],\n sectionId: block.id,\n columnIndex: colIdx,\n });\n if (result) return result;\n }\n }\n }\n return null;\n }\n\n function isBlockLocked(blockId: string): boolean {\n return options.lockedBlocks?.value.has(blockId) ?? false;\n }\n\n function findBlockLocation(blockId: string): {\n targetSectionId?: string;\n columnIndex?: number;\n index: number;\n } | null {\n const parent = findBlockParent(state.content.blocks, blockId);\n if (!parent) return null;\n const index = parent.blocks.findIndex((b) => b.id === blockId);\n if (index === -1) return null;\n return {\n targetSectionId: parent.sectionId,\n columnIndex: parent.columnIndex,\n index,\n };\n }\n\n // TODO(collab): the lock checks in addBlock/moveBlock/removeBlock/updateBlock\n // are shallow — they only consider the directly-targeted block id. A section\n // can still be removed, moved, or have its `children` array rewritten while a\n // peer is editing one of its descendants, which silently disrupts that peer's\n // edit. Add a `hasLockedDescendant(blockId)` helper and gate section-level\n // operations on it (and on the parent of each affected child) so cascades\n // through the tree are also blocked.\n\n function setContent(newContent: TemplateContent, markDirty = true): void {\n assertNoSlotInContent(newContent);\n assertNoWrapperInContent(newContent);\n state.content = newContent;\n if (markDirty) {\n touch();\n }\n }\n\n function selectBlock(blockId: string | null): void {\n if (blockId && isBlockLocked(blockId)) {\n return;\n }\n state.selectedBlockId = blockId;\n }\n\n function setViewport(viewport: ViewportSize): void {\n state.viewport = viewport;\n }\n\n function setDarkMode(darkMode: boolean): void {\n state.darkMode = darkMode;\n }\n\n function setUiTheme(theme: UiTheme): void {\n state.uiTheme = theme;\n }\n\n function setPreviewMode(previewMode: boolean): void {\n state.previewMode = previewMode;\n if (previewMode) {\n state.selectedBlockId = null;\n }\n }\n\n function updateBlock(blockId: string, updates: Partial<Block>): void {\n if (isBlockLocked(blockId)) {\n return;\n }\n const block = findBlockById(state.content.blocks, blockId);\n if (block) {\n Object.assign(block, updates);\n touch();\n }\n }\n\n function updateSettings(updates: Partial<TemplateSettings>): void {\n state.content.settings = { ...state.content.settings, ...updates };\n touch();\n }\n\n function addBlock(\n block: Block,\n targetSectionId?: string,\n columnIndex = 0,\n index?: number,\n ): void {\n const candidate = {\n settings: state.content.settings,\n blocks: [block],\n };\n assertNoSlotInContent(candidate);\n assertNoWrapperInContent(candidate);\n // Sections cannot be nested inside a column — MJML forbids `mj-section`\n // inside `mj-column`, so the renderer drops them on export (issue #292).\n // Reject the nest up front rather than lose the content silently later.\n if (targetSectionId && block.type === \"section\") {\n return;\n }\n if (targetSectionId) {\n if (isBlockLocked(targetSectionId)) {\n return;\n }\n const section = findBlockById(state.content.blocks, targetSectionId);\n if (section && section.type === \"section\") {\n if (columnIndex < 0 || columnIndex >= getColumnCount(section.columns)) {\n return;\n }\n section.children[columnIndex] = section.children[columnIndex] || [];\n const targetArray = section.children[columnIndex];\n if (index !== undefined && index < targetArray.length) {\n targetArray.splice(index, 0, block);\n } else {\n targetArray.push(block);\n }\n }\n } else {\n if (index !== undefined && index < state.content.blocks.length) {\n state.content.blocks.splice(index, 0, block);\n } else {\n state.content.blocks.push(block);\n }\n }\n touch();\n }\n\n function removeBlock(blockId: string): void {\n if (isBlockLocked(blockId)) {\n return;\n }\n const parent = findBlockParent(state.content.blocks, blockId);\n if (parent) {\n const index = parent.blocks.findIndex((b) => b.id === blockId);\n if (index !== -1) {\n const [removed] = parent.blocks.splice(index, 1);\n if (state.selectedBlockId) {\n const removedIds = new Set<string>();\n collectBlockIds(removed, removedIds);\n if (removedIds.has(state.selectedBlockId)) {\n state.selectedBlockId = null;\n }\n }\n touch();\n }\n }\n }\n\n function moveBlock(\n blockId: string,\n newIndex: number,\n targetSectionId?: string,\n columnIndex = 0,\n ): void {\n if (isBlockLocked(blockId)) {\n return;\n }\n if (targetSectionId && isBlockLocked(targetSectionId)) {\n return;\n }\n\n const parent = findBlockParent(state.content.blocks, blockId);\n if (!parent) return;\n\n const oldIndex = parent.blocks.findIndex((b) => b.id === blockId);\n if (oldIndex === -1) return;\n\n // Sections cannot be nested inside a column (issue #292) — refuse to move\n // a section into a section column; MJML would drop it on export.\n if (targetSectionId && parent.blocks[oldIndex].type === \"section\") {\n return;\n }\n\n // Resolve target before mutating the source — otherwise an invalid\n // targetSectionId leaves the block spliced-out and unrecoverable.\n let targetArray: Block[];\n if (targetSectionId) {\n const section = findBlockById(state.content.blocks, targetSectionId);\n if (!section || section.type !== \"section\") return;\n if (columnIndex < 0 || columnIndex >= getColumnCount(section.columns)) {\n return;\n }\n section.children[columnIndex] = section.children[columnIndex] || [];\n targetArray = section.children[columnIndex];\n } else {\n targetArray = state.content.blocks;\n }\n\n const [block] = parent.blocks.splice(oldIndex, 1);\n targetArray.splice(newIndex, 0, block);\n\n touch();\n }\n\n function markDirty(): void {\n touch();\n }\n\n // -------------------------------------------------------------------------\n // Template lifecycle (over an optional TemplatesProvider)\n // -------------------------------------------------------------------------\n\n /**\n * A refused call throws rather than resolving, because a resolved promise\n * would read as \"saved\" to whoever awaited it.\n *\n * The message names the provider key the consumer set, not an internal\n * capability flag: `EditorCapabilities` is type-only and its injection key is\n * unexported, so neither a core nor an editor consumer can read one. Note the\n * editor hides its own save controls when `save` is withheld but has no\n * create affordance to hide at all, so `create()` is reachable by definition.\n */\n function refuse(action: string, reason: string): never {\n throw new SdkError(`[Templatical] Templates: ${action} ${reason}`);\n }\n\n /**\n * Run a consumer's event handler without letting it fail the operation.\n *\n * A handler that throws must not turn a completed write into a rejected one —\n * the UI would report a failure for something that landed.\n */\n function notify(run: () => void): void {\n notifyHandler(options.onError, run);\n }\n\n function requireProvider(action: string): TemplatesProvider {\n const { templates } = options;\n if (!templates) {\n refuse(\n action,\n \"needs a templates provider. Pass one as `init({ templates })` to enable saving and loading.\",\n );\n }\n return templates;\n }\n\n function setName(name: string): void {\n if (!state.template) return;\n state.template = { ...state.template, name };\n touch();\n }\n\n async function create(input?: {\n name?: string;\n content?: TemplateContent;\n }): Promise<Template> {\n const provider = requireProvider(\"create()\");\n const { create: providerCreate } = provider;\n if (typeof providerCreate !== \"function\") {\n refuse(\n \"create()\",\n \"is disabled by the provider — its `create` is `false`.\",\n );\n }\n\n let created: Template;\n state.isLoading = true;\n try {\n if (input?.content) {\n state.content = input.content;\n }\n // Omit `name` entirely when unset rather than sending `undefined` — a\n // provider serialising the input to JSON would otherwise receive a key it\n // never asked for.\n const revisionAtRequest = revision;\n created = await providerCreate(\n input?.name !== undefined\n ? { name: input.name, content: state.content }\n : { content: state.content },\n );\n state.template = created;\n if (revision === revisionAtRequest) {\n state.isDirty = false;\n }\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n state.isLoading = false;\n }\n // Below the `finally` on purpose: `isLoading` is cleared there, so a handler\n // must not observe the editor still loading. Unreachable on failure — the\n // catch rethrows.\n notify(() => provider.onCreated?.(created));\n return created;\n }\n\n async function load(templateId: string): Promise<Template> {\n const provider = requireProvider(\"load()\");\n\n let loaded: Template;\n state.isLoading = true;\n try {\n loaded = await provider.load(templateId);\n assertNoSlotInContent(loaded.content);\n assertNoWrapperInContent(loaded.content);\n state.template = loaded;\n state.content = loaded.content;\n state.isDirty = false;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n state.isLoading = false;\n }\n // Below the `finally` on purpose: `isLoading` is cleared there, so a handler\n // must not observe the editor still loading. Unreachable on failure — the\n // catch rethrows.\n notify(() => provider.onLoaded?.(loaded));\n return loaded;\n }\n\n async function save(trigger: TemplateSaveTrigger = \"api\"): Promise<Template> {\n const provider = requireProvider(\"save()\");\n const { save: providerSave } = provider;\n if (typeof providerSave !== \"function\") {\n refuse(\"save()\", \"is disabled by the provider — its `save` is `false`.\");\n }\n const current = state.template;\n if (!current) {\n refuse(\n \"save()\",\n \"has no template loaded. Call create() or load() first.\",\n );\n }\n\n // The name rides the same patch as the content: a rename is an ordinary\n // unsaved change, so one round-trip persists both.\n const patch: TemplatePatch =\n current.name !== undefined\n ? { name: current.name, content: state.content }\n : { content: state.content };\n\n let saved: Template;\n state.isSaving = true;\n try {\n const revisionAtRequest = revision;\n saved = await providerSave(current.id, patch);\n // Adopt the response only while it still describes what is open. A\n // `load()` that landed mid-flight has already replaced the template, so\n // the response is stale.\n if (state.template?.id === current.id) {\n // The patch was built before the await, so a rename that landed during\n // it is absent from the response. Taking the response's name verbatim\n // reverts what the user typed — and because the next save reads the\n // name back off `state.template`, it would then persist the stale one,\n // losing the rename outright rather than merely on screen.\n const localName = state.template.name;\n state.template =\n localName !== current.name ? { ...saved, name: localName } : saved;\n }\n // Deliberately conditional. An edit landing while the request was in\n // flight is not persisted by it, and clearing the flag would both claim it\n // was and make autosave — which checks dirtiness at debounce time — skip\n // the follow-up save.\n if (revision === revisionAtRequest) {\n state.isDirty = false;\n }\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n state.isSaving = false;\n }\n // Below the `finally` on purpose: `isSaving` is cleared there, and a handler\n // that navigates must observe a settled editor or the consumer's own dirty\n // guard blocks their navigation. Unreachable on failure — the catch rethrows.\n notify(() => provider.onSaved?.(saved, { trigger }));\n return saved;\n }\n\n function hasTemplate(): boolean {\n return state.template?.id !== undefined;\n }\n\n return {\n state: readonly(state),\n content,\n selectedBlock,\n isBlockLocked,\n setContent,\n selectBlock,\n setViewport,\n setDarkMode,\n setUiTheme,\n setPreviewMode,\n updateBlock,\n updateSettings,\n addBlock,\n removeBlock,\n moveBlock,\n markDirty,\n findBlockLocation,\n setName,\n create,\n load,\n save,\n hasTemplate,\n };\n}\n","import { safeClone, type TemplateContent } from \"@templatical/types\";\nimport { computed, ref, type ComputedRef, type Ref } from \"@vue/reactivity\";\n\nexport interface UseHistoryOptions {\n content: Ref<TemplateContent>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n isRemoteOperation?: () => boolean;\n maxSize?: number;\n}\n\nexport interface UseHistoryReturn {\n canUndo: ComputedRef<boolean>;\n canRedo: ComputedRef<boolean>;\n isNavigating: Ref<boolean>;\n undo: () => void;\n redo: () => void;\n record: () => void;\n recordDebounced: (blockId: string) => void;\n clear: () => void;\n destroy: () => void;\n}\n\ninterface DebouncedSnapshot {\n blockId: string;\n timeoutId: ReturnType<typeof setTimeout>;\n}\n\nconst MAX_STACK_SIZE = 50;\nconst DEBOUNCE_MS = 300;\nconst NAVIGATE_IDLE_MS = 1500;\n\nexport function useHistory(options: UseHistoryOptions): UseHistoryReturn {\n const {\n content,\n setContent,\n isRemoteOperation,\n maxSize = MAX_STACK_SIZE,\n } = options;\n\n const undoStack = ref<TemplateContent[]>([]);\n const redoStack = ref<TemplateContent[]>([]);\n const isNavigating = ref(false);\n let navigatingTimeoutId: ReturnType<typeof setTimeout> | null = null;\n let pendingDebounce: DebouncedSnapshot | null = null;\n\n const canUndo = computed(() => undoStack.value.length > 0);\n const canRedo = computed(() => redoStack.value.length > 0);\n\n function cloneContent(): TemplateContent {\n // Cycle-safe deep clone (see `safeClone`). A naked JSON.stringify throws\n // `Converting circular structure to JSON` if a DOM element with a Sortable\n // expando back-ref ever sneaks into block data via a drag handler — which\n // would freeze the undo stack, since every subsequent mutation calls\n // `record()`. safeClone drops the back-ref instead of throwing.\n return safeClone(content.value);\n }\n\n function pushToUndoStack(snapshot: TemplateContent): void {\n undoStack.value.push(snapshot);\n if (undoStack.value.length > maxSize) {\n undoStack.value.splice(0, undoStack.value.length - maxSize);\n }\n }\n\n function flushPendingDebounce(): void {\n if (pendingDebounce) {\n clearTimeout(pendingDebounce.timeoutId);\n pendingDebounce = null;\n }\n }\n\n function record(): void {\n if (isRemoteOperation?.()) {\n return;\n }\n\n flushPendingDebounce();\n pushToUndoStack(cloneContent());\n redoStack.value = [];\n }\n\n function recordDebounced(blockId: string): void {\n if (isRemoteOperation?.()) {\n return;\n }\n\n if (pendingDebounce && pendingDebounce.blockId === blockId) {\n clearTimeout(pendingDebounce.timeoutId);\n pendingDebounce.timeoutId = setTimeout(() => {\n pendingDebounce = null;\n }, DEBOUNCE_MS);\n return;\n }\n\n flushPendingDebounce();\n\n pushToUndoStack(cloneContent());\n redoStack.value = [];\n\n pendingDebounce = {\n blockId,\n timeoutId: setTimeout(() => {\n pendingDebounce = null;\n }, DEBOUNCE_MS),\n };\n }\n\n function setNavigating(): void {\n isNavigating.value = true;\n if (navigatingTimeoutId) {\n clearTimeout(navigatingTimeoutId);\n }\n navigatingTimeoutId = setTimeout(() => {\n isNavigating.value = false;\n navigatingTimeoutId = null;\n }, NAVIGATE_IDLE_MS);\n }\n\n function undo(): void {\n if (undoStack.value.length === 0) {\n return;\n }\n\n flushPendingDebounce();\n\n const snapshot = undoStack.value.pop()!;\n redoStack.value.push(cloneContent());\n setContent(snapshot, true);\n setNavigating();\n }\n\n function redo(): void {\n if (redoStack.value.length === 0) {\n return;\n }\n\n flushPendingDebounce();\n\n const snapshot = redoStack.value.pop()!;\n undoStack.value.push(cloneContent());\n setContent(snapshot, true);\n setNavigating();\n }\n\n function clear(): void {\n undoStack.value = [];\n redoStack.value = [];\n flushPendingDebounce();\n }\n\n function destroy(): void {\n clear();\n if (navigatingTimeoutId) {\n clearTimeout(navigatingTimeoutId);\n navigatingTimeoutId = null;\n }\n }\n\n return {\n canUndo,\n canRedo,\n isNavigating,\n undo,\n redo,\n record,\n recordDebounced,\n clear,\n destroy,\n };\n}\n","import type { Block, BlockDefaults, BlockType } from \"@templatical/types\";\nimport { createBlock, generateId } from \"@templatical/types\";\n\nfunction regenerateNestedIds(block: Block): void {\n if (block.type === \"table\") {\n block.rows = block.rows.map((row) => ({\n ...row,\n id: generateId(),\n cells: row.cells.map((cell) => ({ ...cell, id: generateId() })),\n }));\n } else if (block.type === \"social\") {\n block.icons = block.icons.map((icon) => ({ ...icon, id: generateId() }));\n } else if (block.type === \"menu\") {\n block.items = block.items.map((item) => ({ ...item, id: generateId() }));\n }\n}\n\nexport interface UseBlockActionsOptions {\n addBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n index?: number,\n ) => void;\n removeBlock: (blockId: string) => void;\n updateBlock: (blockId: string, updates: Partial<Block>) => void;\n selectBlock: (blockId: string | null) => void;\n /** Locate a block in the tree — used by `duplicateBlock` to insert the\n * clone right after the source instead of appending to the end. */\n findBlockLocation?: (blockId: string) => {\n targetSectionId?: string;\n columnIndex?: number;\n index: number;\n } | null;\n /**\n * Defaults merged onto every block `createAndAddBlock` creates.\n *\n * A **getter** is re-read on each insert; a plain object is captured once.\n * The editor passes a getter because half of these defaults track the\n * template's own `settings.locale`, which the author can change mid-session\n * — a snapshot would pin every later insert to the value at mount.\n */\n blockDefaults?: BlockDefaults | (() => BlockDefaults);\n}\n\nexport interface UseBlockActionsReturn {\n createAndAddBlock: (\n type: BlockType,\n targetSectionId?: string,\n columnIndex?: number,\n ) => Block;\n duplicateBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n ) => Block;\n deleteBlock: (blockId: string) => void;\n updateBlockProperty: <K extends keyof Block>(\n blockId: string,\n key: K,\n value: Block[K],\n ) => void;\n}\n\nexport function useBlockActions(\n options: UseBlockActionsOptions,\n): UseBlockActionsReturn {\n const { addBlock, removeBlock, updateBlock, selectBlock, findBlockLocation } =\n options;\n\n function createAndAddBlock(\n type: BlockType,\n targetSectionId?: string,\n columnIndex?: number,\n ): Block {\n const defaults =\n typeof options.blockDefaults === \"function\"\n ? options.blockDefaults()\n : options.blockDefaults;\n const block = createBlock(type, defaults);\n addBlock(block, targetSectionId, columnIndex);\n selectBlock(block.id);\n return block;\n }\n\n function duplicateBlock(\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n ): Block {\n const cloned = JSON.parse(JSON.stringify(block)) as Block;\n cloned.id = generateId();\n regenerateNestedIds(cloned);\n\n if (cloned.type === \"section\") {\n cloned.children = cloned.children.map((column) =>\n column.map((child) => {\n const clonedChild = JSON.parse(JSON.stringify(child)) as Block;\n clonedChild.id = generateId();\n regenerateNestedIds(clonedChild);\n return clonedChild;\n }),\n );\n }\n\n // Insert directly after the source block. Explicit target args win;\n // otherwise, resolve the source's location and bump index by 1. Falls\n // back to appending at the end if location is unknown.\n if (targetSectionId !== undefined || columnIndex !== undefined) {\n addBlock(cloned, targetSectionId, columnIndex);\n } else {\n const sourceLocation = findBlockLocation?.(block.id) ?? null;\n if (sourceLocation) {\n addBlock(\n cloned,\n sourceLocation.targetSectionId,\n sourceLocation.columnIndex,\n sourceLocation.index + 1,\n );\n } else {\n addBlock(cloned, targetSectionId, columnIndex);\n }\n }\n selectBlock(cloned.id);\n return cloned;\n }\n\n function deleteBlock(blockId: string): void {\n removeBlock(blockId);\n }\n\n function updateBlockProperty<K extends keyof Block>(\n blockId: string,\n key: K,\n value: Block[K],\n ): void {\n updateBlock(blockId, { [key]: value } as Partial<Block>);\n }\n\n return {\n createAndAddBlock,\n duplicateBlock,\n deleteBlock,\n updateBlockProperty,\n };\n}\n","import type { TemplateContent } from \"@templatical/types\";\nimport { watch, type Ref } from \"@vue/reactivity\";\n\nexport interface UseAutoSaveOptions {\n content: Ref<TemplateContent>;\n isDirty: () => boolean;\n onChange: (content: TemplateContent) => void;\n debounce?: number;\n enabled?: boolean | (() => boolean);\n}\n\nexport interface UseAutoSaveReturn {\n flush: () => void;\n cancel: () => void;\n pause: () => void;\n resume: () => void;\n destroy: () => void;\n}\n\n/**\n * Trailing debounce, in ms, measured from the *last* content mutation.\n *\n * Typing is not debounced upstream — TipTap's `onUpdate` calls `updateBlock` per\n * keystroke — so this is the only thing between a keypress and a whole-document\n * write. 1000 was too eager: ordinary prose pauses for a second constantly\n * (word choice, re-reading, reaching for the mouse), so a single paragraph could\n * produce dozens of full-content saves. 2000 roughly halves that while still\n * landing well before a user wonders whether their work was kept.\n *\n * **The single default for both entry points.** Cloud imports this constant\n * rather than declaring its own — a second copy for one setting drifts silently,\n * since nothing links the two.\n */\nexport const DEFAULT_AUTO_SAVE_DEBOUNCE_MS = 2000;\n\nexport function useAutoSave(options: UseAutoSaveOptions): UseAutoSaveReturn {\n const {\n content,\n isDirty,\n onChange,\n debounce = DEFAULT_AUTO_SAVE_DEBOUNCE_MS,\n enabled = true,\n } = options;\n\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n let paused = false;\n\n function isEnabled(): boolean {\n return typeof enabled === \"function\" ? enabled() : enabled;\n }\n\n function pause(): void {\n paused = true;\n cancel();\n }\n\n function resume(): void {\n paused = false;\n }\n\n function cancel(): void {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n }\n\n function flush(): void {\n cancel();\n if (isDirty()) {\n onChange(JSON.parse(JSON.stringify(content.value)));\n }\n }\n\n function scheduleOnChange(): void {\n if (!isEnabled() || paused) return;\n\n cancel();\n timeoutId = setTimeout(() => {\n timeoutId = null;\n if (isEnabled() && !paused && isDirty()) {\n onChange(JSON.parse(JSON.stringify(content.value)));\n }\n }, debounce);\n }\n\n // `watch` from `@vue/reactivity` has no scheduler, so this callback runs\n // *synchronously inside the mutation* — before the editor's trailing\n // `state.isDirty = true`, and `isDirty` sits outside the watched `content`\n // subtree so setting it never re-triggers. An `isDirty()` guard here would\n // therefore drop the first edit after every dirty-flag reset (issue #522).\n // Dirtiness is decided at debounce time instead, where the flag is settled;\n // `scheduleOnChange` still checks `enabled`/`paused` up front.\n const stopWatch = watch(\n content,\n () => {\n scheduleOnChange();\n },\n { deep: true },\n );\n\n function destroy(): void {\n stopWatch();\n cancel();\n }\n\n return {\n flush,\n cancel,\n pause,\n resume,\n destroy,\n };\n}\n","import { computed, reactive, type ComputedRef } from \"@vue/reactivity\";\n\nexport interface UseConditionPreviewReturn {\n isHidden: (blockId: string) => boolean;\n toggleBlock: (blockId: string) => void;\n reset: () => void;\n hasHiddenBlocks: ComputedRef<boolean>;\n}\n\n/**\n * The slice of an editor this needs — deliberately structural, so both the OSS\n * and the Cloud `useEditor` satisfy it without either having to grow toward the\n * other.\n */\nexport interface ConditionPreviewEditor {\n state: { readonly selectedBlockId: string | null };\n selectBlock: (blockId: string | null) => void;\n}\n\nexport function useConditionPreview(\n editor: ConditionPreviewEditor,\n): UseConditionPreviewReturn {\n const hiddenBlockIds = reactive(new Set<string>());\n\n const hasHiddenBlocks = computed(() => hiddenBlockIds.size > 0);\n\n function isHidden(blockId: string): boolean {\n return hiddenBlockIds.has(blockId);\n }\n\n function toggleBlock(blockId: string): void {\n if (hiddenBlockIds.has(blockId)) {\n hiddenBlockIds.delete(blockId);\n } else {\n hiddenBlockIds.add(blockId);\n\n if (editor.state.selectedBlockId === blockId) {\n editor.selectBlock(null);\n }\n }\n }\n\n function reset(): void {\n hiddenBlockIds.clear();\n }\n\n return {\n isHidden,\n toggleBlock,\n reset,\n hasHiddenBlocks,\n };\n}\n","import type { CustomBlock, CustomBlockDefinition } from \"@templatical/types\";\nimport type { ComputedRef, Ref } from \"@vue/reactivity\";\nimport { computed, ref } from \"@vue/reactivity\";\n\nexport function useDataSourceFetch(options: {\n definition: ComputedRef<CustomBlockDefinition | undefined>;\n block: ComputedRef<CustomBlock>;\n onUpdate: (fieldValues: Record<string, unknown>, fetched: boolean) => void;\n}): {\n isFetching: Ref<boolean>;\n fetchError: Ref<boolean>;\n fetch: () => Promise<void>;\n hasDataSource: ComputedRef<boolean>;\n needsFetch: ComputedRef<boolean>;\n} {\n const isFetching = ref(false);\n const fetchError = ref(false);\n\n const hasDataSource = computed(() => !!options.definition.value?.dataSource);\n\n const needsFetch = computed(\n () => hasDataSource.value && !options.block.value.dataSourceFetched,\n );\n\n async function fetch(): Promise<void> {\n const def = options.definition.value;\n if (!def?.dataSource) {\n return;\n }\n\n isFetching.value = true;\n fetchError.value = false;\n\n try {\n const result = await def.dataSource.onFetch({\n fieldValues: { ...options.block.value.fieldValues },\n blockId: options.block.value.id,\n });\n\n if (result == null) {\n return;\n }\n\n const merged = { ...options.block.value.fieldValues };\n for (const key of Object.keys(merged)) {\n if (key in result) {\n merged[key] = result[key];\n }\n }\n\n options.onUpdate(merged, true);\n } catch (error) {\n console.warn(\"[Templatical] Data source fetch error:\", error);\n fetchError.value = true;\n } finally {\n isFetching.value = false;\n }\n }\n\n return {\n isFetching,\n fetchError,\n fetch,\n hasDataSource,\n needsFetch,\n };\n}\n","import type { Block, TemplateSettings } from \"@templatical/types\";\nimport type { UseHistoryReturn } from \"./history\";\n\n/**\n * The mutable slice of an editor this wraps — structural, so the OSS and Cloud\n * `useEditor` returns both satisfy it without either having to grow toward the\n * other. Not `Readonly`: the whole point is to replace these members in place.\n */\nexport interface HistoryInterceptorEditor {\n addBlock: (\n block: Block,\n targetSectionId?: string,\n columnIndex?: number,\n index?: number,\n ) => void;\n removeBlock: (blockId: string) => void;\n moveBlock: (\n blockId: string,\n newIndex: number,\n targetSectionId?: string,\n columnIndex?: number,\n ) => void;\n updateBlock: (blockId: string, updates: Partial<Block>) => void;\n updateSettings: (updates: Partial<TemplateSettings>) => void;\n isBlockLocked: (blockId: string) => boolean;\n}\n\n/**\n * Wraps editor mutation methods to record history snapshots before each\n * operation. Mutates the editor object in place.\n *\n * Must be applied **after** any collaboration broadcast wrapping so the\n * call chain is: history.record() → broadcast → original mutation.\n */\nexport function useHistoryInterceptor(\n editor: HistoryInterceptorEditor,\n history: UseHistoryReturn,\n): void {\n const originalAddBlock = editor.addBlock;\n const originalRemoveBlock = editor.removeBlock;\n const originalMoveBlock = editor.moveBlock;\n const originalUpdateBlock = editor.updateBlock;\n const originalUpdateSettings = editor.updateSettings;\n\n // Skip recording when the underlying op is a no-op (e.g., a peer-locked\n // block or section), otherwise the undo stack fills with snapshots that\n // are identical to current state and undo silently does nothing.\n editor.addBlock = (block, targetSectionId?, columnIndex?, index?) => {\n if (targetSectionId && editor.isBlockLocked(targetSectionId)) {\n return;\n }\n history.record();\n originalAddBlock(block, targetSectionId, columnIndex, index);\n };\n\n editor.removeBlock = (blockId) => {\n if (editor.isBlockLocked(blockId)) {\n return;\n }\n history.record();\n originalRemoveBlock(blockId);\n };\n\n editor.moveBlock = (blockId, newIndex, targetSectionId?, columnIndex?) => {\n if (editor.isBlockLocked(blockId)) {\n return;\n }\n if (targetSectionId && editor.isBlockLocked(targetSectionId)) {\n return;\n }\n history.record();\n originalMoveBlock(blockId, newIndex, targetSectionId, columnIndex);\n };\n\n editor.updateBlock = (blockId, updates) => {\n if (editor.isBlockLocked(blockId)) {\n return;\n }\n history.recordDebounced(blockId);\n originalUpdateBlock(blockId, updates);\n };\n\n editor.updateSettings = (updates) => {\n history.record();\n originalUpdateSettings(updates);\n };\n}\n","import type {\n Block,\n SavedBlock,\n SavedBlockPatch,\n SavedBlocksListParams,\n SavedBlocksProvider,\n} from \"@templatical/types\";\nimport { SdkError } from \"@templatical/types\";\nimport { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport { notifyHandler } from \"./error-reporting\";\n\nexport interface UseSavedBlocksOptions {\n /**\n * Storage backend. Supplied by the consumer via `init({ savedBlocks })`, or\n * by Cloud's own adapter — this composable is transport-agnostic and never\n * talks to a network itself.\n */\n provider: SavedBlocksProvider;\n onError?: (error: Error) => void;\n}\n\nexport interface UseSavedBlocksReturn {\n /** In-memory mirror of the provider's list, kept in sync after each call. */\n savedBlocks: Ref<SavedBlock[]>;\n isLoading: Ref<boolean>;\n /**\n * Distinct categories across the loaded entries, alphabetically sorted.\n *\n * Derived rather than stored: a category exists exactly as long as an entry\n * carries it. Sorting here is not a violation of \"the editor never re-sorts\"\n * — that rule protects the provider's ordering of *entries*, whereas these\n * are strings with no given order.\n */\n categories: ComputedRef<string[]>;\n /**\n * Whether the provider supplied each mutation at all — `false` on the\n * provider means the capability does not exist for this user, and the UI\n * hides the corresponding affordance entirely.\n *\n * Constant for the provider's lifetime, but exposed as computed refs so\n * consumers can bind them the same way as everything else here.\n */\n canCreate: ComputedRef<boolean>;\n canUpdate: ComputedRef<boolean>;\n canDelete: ComputedRef<boolean>;\n /**\n * Whether a *particular* entry may be edited / deleted: the capability must\n * exist AND the entry must not opt out via `canUpdate` / `canDelete`.\n *\n * Use these rather than reading the flags directly, so every surface asks the\n * question the same way and the \"absent means allowed\" default lives in one\n * place.\n */\n canUpdateBlock: (block: SavedBlock) => boolean;\n canDeleteBlock: (block: SavedBlock) => boolean;\n /**\n * Re-read from the provider. The editor always calls this bare and filters\n * in memory; `params` exists for headless callers that want the provider to\n * filter instead (see {@link SavedBlocksListParams}).\n */\n load: (params?: SavedBlocksListParams) => Promise<void>;\n /** Rejects with an {@link SdkError} when the provider disabled `create`. */\n create: (\n name: string,\n content: Block[],\n category?: string,\n ) => Promise<SavedBlock>;\n /** Rejects when `update` is disabled or the entry opts out of editing. */\n update: (id: string, patch: SavedBlockPatch) => Promise<SavedBlock>;\n /** Rejects when `delete` is disabled or the entry opts out of deletion. */\n remove: (id: string) => Promise<void>;\n}\n\n/**\n * Reactive state over a {@link SavedBlocksProvider}.\n *\n * Owns the list, the loading flag, and the local mutations that keep the list\n * consistent after each successful call, so a provider only has to implement\n * four promise-returning methods. Errors are reported through `onError` and\n * re-thrown, leaving the local list untouched on failure.\n */\nexport function useSavedBlocks(\n options: UseSavedBlocksOptions,\n): UseSavedBlocksReturn {\n const { provider } = options;\n\n const savedBlocks = ref<SavedBlock[]>([]);\n const isLoading = ref(false);\n\n const categories = computed(() => {\n const seen = new Set<string>();\n for (const block of savedBlocks.value) {\n const category = block.category?.trim();\n if (category) seen.add(category);\n }\n return [...seen].sort((a, b) => a.localeCompare(b));\n });\n\n const canCreate = computed(() => typeof provider.create === \"function\");\n const canUpdate = computed(() => typeof provider.update === \"function\");\n const canDelete = computed(() => typeof provider.delete === \"function\");\n\n /** Absent flag means allowed — the flags exist only to forbid. */\n function canUpdateBlock(block: SavedBlock): boolean {\n return canUpdate.value && block.canUpdate !== false;\n }\n\n function canDeleteBlock(block: SavedBlock): boolean {\n return canDelete.value && block.canDelete !== false;\n }\n\n /**\n * The UI hides disabled actions, so reaching one of these means a programmatic\n * caller went around it. Fail loudly rather than silently no-op: a resolved\n * promise would read as \"saved\" to whoever awaited it.\n */\n function refuse(action: string, reason: string): never {\n throw new SdkError(\n `[Templatical] Saved blocks: ${action} is ${reason}. Check the capability before calling — the editor's own UI hides the action.`,\n );\n }\n\n /**\n * Run a consumer's event handler without letting it fail the operation.\n *\n * A handler that throws must not turn a completed write into a rejected one —\n * the UI would report a failure for a saved block that was created.\n */\n function notify(run: () => void): void {\n notifyHandler(options.onError, run);\n }\n\n async function load(params?: SavedBlocksListParams): Promise<void> {\n isLoading.value = true;\n try {\n savedBlocks.value = await provider.list(params);\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n isLoading.value = false;\n }\n }\n\n async function create(\n name: string,\n content: Block[],\n category?: string,\n ): Promise<SavedBlock> {\n const { create: providerCreate } = provider;\n if (typeof providerCreate !== \"function\") {\n refuse(\"create\", \"disabled by the provider\");\n }\n try {\n // Omit the key entirely when unset, rather than sending `undefined` —\n // a provider serialising the input to JSON would otherwise be handed an\n // explicit null-ish field it never asked for.\n const created = await providerCreate(\n category ? { name, content, category } : { name, content },\n );\n savedBlocks.value = [created, ...savedBlocks.value];\n notify(() => provider.onCreated?.(created));\n return created;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n }\n }\n\n async function update(\n id: string,\n patch: SavedBlockPatch,\n ): Promise<SavedBlock> {\n const { update: providerUpdate } = provider;\n if (typeof providerUpdate !== \"function\") {\n refuse(\"update\", \"disabled by the provider\");\n }\n // An id absent from the local list isn't refused — a headless caller may\n // legitimately patch something it never loaded. Only a loaded entry that\n // explicitly opted out is blocked.\n const local = savedBlocks.value.find((b) => b.id === id);\n if (local && local.canUpdate === false) {\n refuse(\"update\", `not permitted for entry \"${id}\"`);\n }\n try {\n const updated = await providerUpdate(id, patch);\n savedBlocks.value = savedBlocks.value.map((b) =>\n b.id === id ? updated : b,\n );\n notify(() => provider.onUpdated?.(updated));\n return updated;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n }\n }\n\n async function remove(id: string): Promise<void> {\n const { delete: providerDelete } = provider;\n if (typeof providerDelete !== \"function\") {\n refuse(\"delete\", \"disabled by the provider\");\n }\n // Captured before the delete resolves: `onDeleted` carries the removed\n // entry itself, and there is nothing left to read once the list is\n // filtered.\n const removed = savedBlocks.value.find((b) => b.id === id) ?? null;\n if (removed && removed.canDelete === false) {\n refuse(\"delete\", `not permitted for entry \"${id}\"`);\n }\n try {\n await providerDelete(id);\n savedBlocks.value = savedBlocks.value.filter((b) => b.id !== id);\n if (removed) {\n notify(() => provider.onDeleted?.(removed));\n }\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n }\n }\n\n return {\n savedBlocks,\n isLoading,\n categories,\n canCreate,\n canUpdate,\n canDelete,\n canUpdateBlock,\n canDeleteBlock,\n load,\n create,\n update,\n remove,\n };\n}\n","import type {\n SavedBlock,\n SavedBlockInput,\n SavedBlockPatch,\n SavedBlocksListParams,\n SavedBlocksProvider,\n} from \"@templatical/types\";\nimport { generateId } from \"@templatical/types\";\n\nexport interface LocalStorageSavedBlocksOptions {\n /**\n * `localStorage` key holding the serialized array.\n *\n * @default \"templatical:saved-blocks\"\n */\n key?: string;\n}\n\nconst DEFAULT_KEY = \"templatical:saved-blocks\";\n\n/**\n * Browser-local {@link SavedBlocksProvider} backed by `localStorage`.\n *\n * Opt-in: pass it explicitly as `init({ savedBlocks: createLocalStorageSavedBlocksProvider() })`.\n * The editor never falls back to it, so consumers without a provider keep the\n * feature — and its UI — entirely off.\n *\n * Intended for demos, prototypes, and single-device use. Entries live in one\n * browser profile only: they don't sync across devices or users, and clearing\n * site data removes them. Back saved blocks with your own API for anything\n * that needs to outlive a browser profile.\n */\nexport function createLocalStorageSavedBlocksProvider(\n options: LocalStorageSavedBlocksOptions = {},\n): SavedBlocksProvider {\n const storageKey = options.key ?? DEFAULT_KEY;\n\n function getStorage(): Storage {\n // Core targets a neutral platform, so `localStorage` isn't guaranteed —\n // fail with an actionable message rather than a bare ReferenceError.\n if (typeof localStorage === \"undefined\") {\n throw new Error(\n \"[Templatical] createLocalStorageSavedBlocksProvider requires a browser environment with localStorage. Supply your own SavedBlocksProvider for server-side or non-browser use.\",\n );\n }\n return localStorage;\n }\n\n function readAll(): SavedBlock[] {\n const raw = getStorage().getItem(storageKey);\n if (!raw) return [];\n try {\n const parsed: unknown = JSON.parse(raw);\n // Tolerate a corrupted or hand-edited value rather than breaking the\n // editor: treat anything that isn't an array as \"no saved blocks\".\n return Array.isArray(parsed) ? (parsed as SavedBlock[]) : [];\n } catch {\n return [];\n }\n }\n\n function writeAll(blocks: SavedBlock[]): void {\n getStorage().setItem(storageKey, JSON.stringify(blocks));\n }\n\n // Every method is `async` so a synchronous failure (a missing\n // `localStorage`, a quota error from `setItem`) surfaces as a rejected\n // promise rather than a sync throw — callers of a `Promise`-returning\n // contract must be able to rely on `.catch()`.\n return {\n // The editor calls this bare and filters in memory; the params are honored\n // for headless callers that would rather the provider did the work.\n async list(params?: SavedBlocksListParams): Promise<SavedBlock[]> {\n const all = readAll();\n const search = params?.search?.trim().toLowerCase();\n const category = params?.category?.trim();\n return all.filter((b) => {\n if (search && !b.name.toLowerCase().includes(search)) return false;\n if (category && b.category !== category) return false;\n return true;\n });\n },\n\n // All three mutations are enabled: a browser-local store has no notion of\n // permissions, so there is nothing to forbid.\n async create(input: SavedBlockInput): Promise<SavedBlock> {\n const now = new Date().toISOString();\n const created: SavedBlock = {\n id: generateId(),\n name: input.name,\n content: input.content,\n ...(input.category ? { category: input.category } : {}),\n createdAt: now,\n updatedAt: now,\n };\n // Newest-first, matching the order the composable applies locally after\n // a create — so a reload preserves what the user just saw.\n writeAll([created, ...readAll()]);\n return created;\n },\n\n async update(id: string, patch: SavedBlockPatch): Promise<SavedBlock> {\n const all = readAll();\n const index = all.findIndex((b) => b.id === id);\n // Mirrors a REST 404 so provider behavior is consistent across adapters.\n if (index === -1) {\n throw new Error(`[Templatical] Saved block not found: ${id}`);\n }\n const updated: SavedBlock = {\n ...all[index],\n ...patch,\n updatedAt: new Date().toISOString(),\n };\n const next = [...all];\n next[index] = updated;\n writeAll(next);\n return updated;\n },\n\n async delete(id: string): Promise<void> {\n const all = readAll();\n if (!all.some((b) => b.id === id)) {\n throw new Error(`[Templatical] Saved block not found: ${id}`);\n }\n writeAll(all.filter((b) => b.id !== id));\n },\n };\n}\n","import type {\n MediaAsset,\n MediaAssetPatch,\n MediaCreateInput,\n MediaListPage,\n MediaListParams,\n MediaProvider,\n} from \"@templatical/types\";\nimport { generateId } from \"@templatical/types\";\n\nexport interface LocalStorageMediaProviderOptions {\n /**\n * `localStorage` key holding the serialized array.\n *\n * @default \"templatical:media\"\n */\n key?: string;\n}\n\nconst DEFAULT_KEY = \"templatical:media\";\nconst PAGE_SIZE = 50;\n\n/**\n * Browser-local {@link MediaProvider} backed by `localStorage`.\n *\n * Opt-in: pass it explicitly as `init({ media: createLocalStorageMediaProvider() })`.\n * The editor never falls back to it, so consumers without a provider keep\n * image fields URL-only.\n *\n * `create` stores the file as a data URL. That is a demo-sized persistence\n * model — `localStorage` quotas are typically ~5 MB, and a few large\n * images will fill it. Back a real gallery with your own API.\n *\n * Folders, replace, import, usage, frequently-used and quota are `false`:\n * this adapter is a flat list of assets.\n */\nexport function createLocalStorageMediaProvider(\n options: LocalStorageMediaProviderOptions = {},\n): MediaProvider {\n const storageKey = options.key ?? DEFAULT_KEY;\n\n function getStorage(): Storage {\n // Core targets a neutral platform, so `localStorage` isn't guaranteed —\n // fail with an actionable message rather than a bare ReferenceError.\n if (typeof localStorage === \"undefined\") {\n throw new Error(\n \"[Templatical] createLocalStorageMediaProvider requires a browser environment with localStorage. Supply your own MediaProvider for server-side or non-browser use.\",\n );\n }\n return localStorage;\n }\n\n function readAll(): MediaAsset[] {\n const raw = getStorage().getItem(storageKey);\n if (!raw) return [];\n try {\n const parsed: unknown = JSON.parse(raw);\n // Tolerate a corrupted or hand-edited value rather than breaking the\n // editor: treat anything that isn't an array as \"no assets\".\n return Array.isArray(parsed) ? (parsed as MediaAsset[]) : [];\n } catch {\n return [];\n }\n }\n\n function writeAll(assets: MediaAsset[]): void {\n getStorage().setItem(storageKey, JSON.stringify(assets));\n }\n\n function readFileAsDataURL(file: File): Promise<string> {\n if (typeof FileReader === \"undefined\") {\n return Promise.reject(\n new Error(\n \"[Templatical] createLocalStorageMediaProvider requires a browser environment with FileReader.\",\n ),\n );\n }\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => {\n if (typeof reader.result !== \"string\") {\n reject(new Error(\"[Templatical] Failed to read file as a data URL.\"));\n return;\n }\n resolve(reader.result);\n };\n reader.onerror = () => {\n reject(\n reader.error ??\n new Error(\"[Templatical] Failed to read file as a data URL.\"),\n );\n };\n reader.readAsDataURL(file);\n });\n }\n\n // Every method is `async` so a synchronous failure (a missing\n // `localStorage`, a quota error from `setItem`) surfaces as a rejected\n // promise rather than a sync throw — callers of a `Promise`-returning\n // contract must be able to rely on `.catch()`.\n return {\n async list(params?: MediaListParams): Promise<MediaListPage> {\n const all = readAll();\n const search = params?.search?.trim().toLowerCase();\n const filtered = search\n ? all.filter((asset) => {\n const filename = asset.filename?.toLowerCase() ?? \"\";\n const alt = asset.alt?.toLowerCase() ?? \"\";\n return filename.includes(search) || alt.includes(search);\n })\n : all;\n const parsed = params?.cursor ? Number.parseInt(params.cursor, 10) : 0;\n const offset = Number.isFinite(parsed) && parsed > 0 ? parsed : 0;\n const items = filtered.slice(offset, offset + PAGE_SIZE);\n const page: MediaListPage = { items };\n const nextOffset = offset + items.length;\n if (nextOffset < filtered.length) {\n page.nextCursor = String(nextOffset);\n }\n return page;\n },\n\n async create(input: MediaCreateInput): Promise<MediaAsset> {\n const url = await readFileAsDataURL(input.file);\n const now = new Date().toISOString();\n const created: MediaAsset = {\n id: generateId(),\n url,\n filename: input.filename || input.file.name,\n createdAt: now,\n updatedAt: now,\n size: input.file.size,\n };\n if (input.alt !== undefined) created.alt = input.alt;\n if (input.file.type) created.mimeType = input.file.type;\n if (input.folderId !== undefined) created.folderId = input.folderId;\n // Newest-first, matching the order the composable applies locally after\n // a create — so a reload preserves what the user just saw.\n writeAll([created, ...readAll()]);\n return created;\n },\n\n async update(id: string, patch: MediaAssetPatch): Promise<MediaAsset> {\n const all = readAll();\n const index = all.findIndex((asset) => asset.id === id);\n // Mirrors a REST 404 so provider behavior is consistent across adapters.\n if (index === -1) {\n throw new Error(`[Templatical] Media asset not found: ${id}`);\n }\n const current = all[index];\n const updated: MediaAsset = {\n ...current,\n ...patch,\n id: current.id,\n url: current.url,\n updatedAt: new Date().toISOString(),\n };\n const next = [...all];\n next[index] = updated;\n writeAll(next);\n return updated;\n },\n\n async delete(ids: string[]): Promise<void> {\n const all = readAll();\n for (const id of ids) {\n if (!all.some((asset) => asset.id === id)) {\n throw new Error(`[Templatical] Media asset not found: ${id}`);\n }\n }\n const remove = new Set(ids);\n writeAll(all.filter((asset) => !remove.has(asset.id)));\n },\n\n folders: false,\n replace: false,\n importFromUrl: false,\n checkUsage: false,\n frequentlyUsed: false,\n storage: false,\n };\n}\n","import type {\n Template,\n TemplateContent,\n TemplateVersion,\n VersionHistoryListParams,\n VersionHistoryProvider,\n} from \"@templatical/types\";\nimport { SdkError } from \"@templatical/types\";\nimport { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport { notifyHandler } from \"./error-reporting\";\n\nexport interface UseVersionHistoryOptions {\n /**\n * Storage backend. Supplied by the consumer via `init({ versionHistory })`,\n * or by Cloud's own adapter — this composable is transport-agnostic and never\n * talks to a network itself.\n */\n provider: VersionHistoryProvider;\n /**\n * Which template's history this is. A getter rather than a value because a\n * session can outlive the template: `initCloud()` constructs the feature at\n * setup and only learns the id once `create()` / `load()` resolves.\n */\n getTemplateId: () => string | null;\n onError?: (error: Error) => void;\n}\n\nexport interface UseVersionHistoryReturn {\n /** The provider's list, in the provider's order. Never re-sorted. */\n versions: Ref<TemplateVersion[]>;\n isLoading: Ref<boolean>;\n isRestoring: Ref<boolean>;\n /**\n * Cursor for the page after the one currently held, or `undefined` when the\n * provider signalled there is no more. The editor loads one page and ignores\n * this; it is here so a headless caller can page without reaching past the\n * composable.\n */\n nextCursor: Ref<string | undefined>;\n /** Whether the provider supplied each mutation at all. */\n canCreate: ComputedRef<boolean>;\n canRestore: ComputedRef<boolean>;\n /** Re-read the list. The editor calls this bare; `params` is for headless callers. */\n load: (params?: VersionHistoryListParams) => Promise<void>;\n /**\n * The version's content **if it is already in hand** — the provider's\n * `content` hint, or a previous `get` this composable cached. `null` means a\n * round-trip is required.\n *\n * Callers that must not block (scrubbing through history swaps the canvas in\n * the same tick) check this first and only await {@link resolveContent} when\n * it comes back null.\n */\n peekContent: (version: TemplateVersion) => TemplateContent | null;\n /**\n * `version.content ?? await provider.get(...)`, cached per version id, so a\n * lazily-loaded version costs one round-trip on its first visit and nothing\n * afterwards.\n */\n resolveContent: (version: TemplateVersion) => Promise<TemplateContent>;\n /** Rejects with an {@link SdkError} when the provider disabled `create`. */\n create: (\n content: TemplateContent,\n meta?: { label?: string },\n ) => Promise<TemplateVersion>;\n /** Rejects with an {@link SdkError} when the provider disabled `restore`. */\n restore: (versionId: string) => Promise<Template>;\n}\n\n/**\n * Reactive state over a {@link VersionHistoryProvider}.\n *\n * Owns the list, the loading flags and the per-version content cache that keeps\n * scrubbing synchronous. Errors are reported through `onError` and re-thrown,\n * leaving the list untouched on failure.\n *\n * It deliberately does **not** create versions of its own accord. The editor\n * never records a version on a save — whoever implements `TemplatesProvider.save`\n * decides that, because they are the side that pays for the storage.\n */\nexport function useVersionHistory(\n options: UseVersionHistoryOptions,\n): UseVersionHistoryReturn {\n const { provider, getTemplateId } = options;\n\n const versions = ref<TemplateVersion[]>([]);\n const isLoading = ref(false);\n const nextCursor = ref<string | undefined>(undefined);\n const isRestoring = ref(false);\n\n /**\n * Content fetched through `get`, keyed by version id. A version that carried\n * a `content` hint never lands here — the hint is read straight off the entry,\n * so a provider that eager-loads pays no second copy.\n */\n const fetched = new Map<string, TemplateContent>();\n\n const canCreate = computed(() => typeof provider.create === \"function\");\n const canRestore = computed(() => typeof provider.restore === \"function\");\n\n /**\n * The UI hides disabled actions and renders nothing before a template exists,\n * so reaching one of these means a programmatic caller went around it. Fail\n * loudly rather than silently no-op: a resolved promise reads as \"done\".\n */\n function requireTemplateId(action: string): string {\n const templateId = getTemplateId();\n if (!templateId) {\n throw new SdkError(\n `[Templatical] Version history: ${action} needs a template. Call create() or load() first.`,\n );\n }\n return templateId;\n }\n\n function refuse(action: string): never {\n throw new SdkError(\n `[Templatical] Version history: ${action} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`,\n );\n }\n\n /**\n * Run a consumer's event handler without letting it fail the operation.\n *\n * A handler that throws must not turn a completed write into a rejected one —\n * the UI would report a failure for a version that was recorded or restored.\n */\n function notify(run: () => void): void {\n notifyHandler(options.onError, run);\n }\n\n async function load(params?: VersionHistoryListParams): Promise<void> {\n const templateId = requireTemplateId(\"list\");\n isLoading.value = true;\n try {\n const page = await provider.list(templateId, params);\n versions.value = page.versions;\n nextCursor.value = page.nextCursor;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n isLoading.value = false;\n }\n }\n\n function peekContent(version: TemplateVersion): TemplateContent | null {\n return version.content ?? fetched.get(version.id) ?? null;\n }\n\n async function resolveContent(\n version: TemplateVersion,\n ): Promise<TemplateContent> {\n const known = peekContent(version);\n if (known) return known;\n\n const templateId = requireTemplateId(\"get\");\n try {\n const content = await provider.get(templateId, version.id);\n fetched.set(version.id, content);\n return content;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n }\n }\n\n async function create(\n content: TemplateContent,\n meta?: { label?: string },\n ): Promise<TemplateVersion> {\n const { create: providerCreate } = provider;\n if (typeof providerCreate !== \"function\") refuse(\"create\");\n const templateId = requireTemplateId(\"create\");\n try {\n const created = await providerCreate(templateId, content, meta);\n versions.value = [created, ...versions.value];\n notify(() => provider.onCreated?.(created));\n return created;\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n }\n }\n\n async function restore(versionId: string): Promise<Template> {\n const { restore: providerRestore } = provider;\n if (typeof providerRestore !== \"function\") refuse(\"restore\");\n const templateId = requireTemplateId(\"restore\");\n\n let restored: Template;\n isRestoring.value = true;\n try {\n restored = await providerRestore(templateId, versionId);\n } catch (error) {\n options.onError?.(error as Error);\n throw error;\n } finally {\n isRestoring.value = false;\n }\n // Below the `finally` on purpose: `isRestoring` is cleared there, so a\n // handler must not observe the composable still reporting itself\n // mid-restore. Unreachable on failure — the catch rethrows.\n notify(() => provider.onRestored?.(restored));\n return restored;\n }\n\n return {\n nextCursor,\n versions,\n isLoading,\n isRestoring,\n canCreate,\n canRestore,\n load,\n peekContent,\n resolveContent,\n create,\n restore,\n };\n}\n","import type {\n Comment,\n CommentAuthor,\n CommentChange,\n CommentInput,\n CommentPatch,\n CommentsListParams,\n CommentsProvider,\n} from \"@templatical/types\";\nimport { SdkError } from \"@templatical/types\";\nimport {\n computed,\n onScopeDispose,\n ref,\n watch,\n type ComputedRef,\n type Ref,\n} from \"vue\";\nimport { notifyHandler, wrapReportedError } from \"./error-reporting\";\n\nexport interface UseCommentsOptions {\n /**\n * Storage backend. Supplied by the consumer via `init({ comments })`, or by\n * Cloud's own adapter — this composable is transport-agnostic and never talks\n * to a network itself.\n */\n provider: CommentsProvider;\n /**\n * Which template's conversation this is. A getter rather than a value because a\n * session can outlive the template: `initCloud()` constructs the feature at\n * setup and only learns the id once `create()` / `load()` resolves.\n */\n getTemplateId: () => string | null;\n /**\n * Who is commenting, read at call time. `null` means the editor has no\n * identity, and every mutation refuses — an unattributable comment is worse\n * than no comment feature.\n */\n getUser: () => CommentAuthor | null;\n onError?: (error: Error) => void;\n}\n\nexport interface UseCommentsReturn {\n /** Thread roots in the provider's order. Never re-sorted. */\n comments: Ref<Comment[]>;\n isLoading: Ref<boolean>;\n isSubmitting: Ref<boolean>;\n /** Whether the provider supplied each mutation at all. */\n canCreate: ComputedRef<boolean>;\n canUpdate: ComputedRef<boolean>;\n canDelete: ComputedRef<boolean>;\n canResolve: ComputedRef<boolean>;\n /** Roots plus replies. */\n totalCount: ComputedRef<number>;\n /** Unresolved roots — the badge on the trigger. */\n unresolvedCount: ComputedRef<number>;\n /** Comments per anchored block id, roots plus their replies. */\n commentCountByBlock: ComputedRef<Map<string, number>>;\n /** Re-read the list. The editor calls this bare; `params` is for headless callers. */\n load: (params?: CommentsListParams) => Promise<void>;\n /** Rejects with an {@link SdkError} when `create` is disabled or there is no user. */\n create: (input: CommentInput) => Promise<Comment>;\n /** Rejects with an {@link SdkError} when `update` is disabled or there is no user. */\n update: (commentId: string, patch: CommentPatch) => Promise<Comment>;\n /** Rejects with an {@link SdkError} when `delete` is disabled or there is no user. */\n remove: (commentId: string) => Promise<void>;\n /** Rejects with an {@link SdkError} when `setResolved` is disabled or there is no user. */\n setResolved: (commentId: string, resolved: boolean) => Promise<Comment>;\n /** Look one up by id, root or reply. `null` when it isn't loaded. */\n find: (commentId: string) => Comment | null;\n /** Whether this comment was written by the current user. */\n isOwn: (comment: Comment) => boolean;\n /**\n * Apply a change that arrived from {@link CommentsProvider.subscribe}. Public\n * so a consumer driving this headlessly can push their own transport into it.\n */\n applyRemoteCreate: (comment: Comment) => void;\n applyRemoteUpdate: (comment: Comment) => void;\n applyRemoteDelete: (commentId: string, parentId?: string | null) => void;\n}\n\n/**\n * Reactive state over a {@link CommentsProvider}.\n *\n * Owns the thread list, the loading flags, the local mutations that keep the list\n * consistent, and the derived counts the chrome renders. Errors are reported\n * through `onError` and **re-thrown**, leaving the list untouched on failure —\n * the same discipline as `useSavedBlocks` and `useVersionHistory`.\n *\n * Mutations **reject** when the provider withheld them rather than resolving to\n * `null`: a resolved promise reads as \"saved\" to whoever awaited it. Ask through\n * `canCreate` / `canUpdate` / `canDelete` / `canResolve` first — which is what the\n * editor's own UI does, hiding each action rather than disabling it.\n */\nexport function useComments(options: UseCommentsOptions): UseCommentsReturn {\n const { provider, getTemplateId, getUser } = options;\n\n const comments = ref<Comment[]>([]);\n const isLoading = ref(false);\n const isSubmitting = ref(false);\n\n const canCreate = computed(() => typeof provider.create === \"function\");\n const canUpdate = computed(() => typeof provider.update === \"function\");\n const canDelete = computed(() => typeof provider.delete === \"function\");\n const canResolve = computed(() => typeof provider.setResolved === \"function\");\n\n const totalCount = computed(() =>\n comments.value.reduce(\n (sum, thread) => sum + 1 + (thread.replies?.length ?? 0),\n 0,\n ),\n );\n\n const unresolvedCount = computed(\n () => comments.value.filter((thread) => !thread.resolvedAt).length,\n );\n\n const commentCountByBlock = computed(() => {\n const map = new Map<string, number>();\n for (const thread of comments.value) {\n if (!thread.blockId) continue;\n map.set(\n thread.blockId,\n (map.get(thread.blockId) ?? 0) + 1 + (thread.replies?.length ?? 0),\n );\n }\n return map;\n });\n\n /**\n * The UI hides disabled actions and renders nothing before a template exists,\n * so reaching one of these means a programmatic caller went around it. Fail\n * loudly rather than silently no-op.\n */\n function requireTemplateId(action: string): string {\n const templateId = getTemplateId();\n if (!templateId) {\n throw new SdkError(\n `[Templatical] Comments: ${action} needs a template. Call create() or load() first.`,\n );\n }\n return templateId;\n }\n\n function requireUser(action: string): CommentAuthor {\n const user = getUser();\n if (!user) {\n throw new SdkError(\n `[Templatical] Comments: ${action} needs to know who is commenting. Pass init({ user: { id, name } }) — an unattributed comment is not written.`,\n );\n }\n return user;\n }\n\n function refuse(action: string): never {\n throw new SdkError(\n `[Templatical] Comments: ${action} is disabled by the provider. Check the capability before calling — the editor's own UI hides the action.`,\n );\n }\n\n function find(commentId: string): Comment | null {\n for (const thread of comments.value) {\n if (thread.id === commentId) return thread;\n for (const reply of thread.replies ?? []) {\n if (reply.id === commentId) return reply;\n }\n }\n return null;\n }\n\n function isOwn(comment: Comment): boolean {\n const user = getUser();\n return user !== null && comment.author.id === user.id;\n }\n\n function report(error: unknown): never {\n const wrapped = wrapReportedError(error);\n options.onError?.(wrapped);\n throw wrapped;\n }\n\n /**\n * Run a consumer's event handler without letting it fail the operation.\n *\n * A handler that throws must not turn a completed write into a rejected one —\n * the UI would report a failure for a comment that was created.\n */\n function notify(run: () => void): void {\n notifyHandler(options.onError, run);\n }\n\n function replaceAt<T>(list: T[], index: number, next: T): T[] {\n return [...list.slice(0, index), next, ...list.slice(index + 1)];\n }\n\n /**\n * Key-order sensitive: identical fields serialized in a different order\n * compare unequal, so an echo whose transport frame orders keys\n * differently than the mutation response it echoes would not be\n * suppressed. Accepted rather than a defect — not worth a deep-equal\n * dependency for it.\n */\n function sameComment(a: Comment | undefined, b: Comment): boolean {\n return a !== undefined && JSON.stringify(a) === JSON.stringify(b);\n }\n\n /**\n * Insert a comment, replacing an entry with the same id rather than\n * duplicating it, and report whether the list actually changed.\n *\n * The **remote** apply paths (`applyRemoteCreate` / `applyRemoteUpdate`)\n * emit their event only when this returns `true`. A transport's own\n * broadcast can come back to the sender — `CommentsProvider.subscribe`'s\n * contract permits it — and emitting unconditionally fires the handler\n * twice for one comment. The comparison below runs against the **merged**\n * result, never the raw payload: the root branch keeps already-loaded\n * `replies` when an update payload carries none, so comparing the payload\n * directly would report a change for an echo that altered nothing.\n * Deleting the `sameComment` check as a redundant no-op reinstates the\n * double-fire.\n */\n function upsert(comment: Comment): boolean {\n if (comment.parentId) {\n let changed = false;\n const next = comments.value.map((thread) => {\n if (thread.id !== comment.parentId) return thread;\n const replies = thread.replies ?? [];\n const at = replies.findIndex((reply) => reply.id === comment.id);\n if (at !== -1 && sameComment(replies[at], comment)) return thread;\n changed = true;\n return {\n ...thread,\n replies:\n at === -1 ? [...replies, comment] : replaceAt(replies, at, comment),\n };\n });\n // Assigned only when something actually changed: `.map()` always returns\n // a new array, and reassigning `comments.value` for a no-op echo would\n // still invalidate every computed reading it (`commentCountByBlock`\n // returns a new `Map` on each recompute) for nothing.\n if (changed) comments.value = next;\n return changed;\n }\n\n const at = comments.value.findIndex((thread) => thread.id === comment.id);\n if (at === -1) {\n comments.value = [...comments.value, comment];\n return true;\n }\n // A root arriving again keeps the replies already loaded: the update payload\n // for a body edit carries none, and dropping them would empty the thread.\n const next: Comment = {\n ...comment,\n replies: comment.replies ?? comments.value[at].replies,\n };\n if (sameComment(comments.value[at], next)) return false;\n comments.value = replaceAt(comments.value, at, next);\n return true;\n }\n\n function drop(commentId: string, parentId?: string | null): Comment | null {\n const existing = find(commentId);\n // `parentId` from the caller wins so a delete can be applied without the\n // comment being loaded — the subscribe path, on a thread never opened.\n const parent = parentId ?? existing?.parentId ?? null;\n\n if (parent) {\n comments.value = comments.value.map((thread) =>\n thread.id === parent\n ? {\n ...thread,\n replies: (thread.replies ?? []).filter((r) => r.id !== commentId),\n }\n : thread,\n );\n } else {\n comments.value = comments.value.filter((c) => c.id !== commentId);\n }\n return existing;\n }\n\n async function load(params?: CommentsListParams): Promise<void> {\n const templateId = requireTemplateId(\"list\");\n isLoading.value = true;\n try {\n comments.value = await provider.list(templateId, params);\n } catch (error) {\n report(error);\n } finally {\n isLoading.value = false;\n }\n }\n\n async function create(input: CommentInput): Promise<Comment> {\n const { create: providerCreate } = provider;\n if (typeof providerCreate !== \"function\") refuse(\"create\");\n const templateId = requireTemplateId(\"create\");\n requireUser(\"create\");\n isSubmitting.value = true;\n try {\n const created = await providerCreate(templateId, input);\n upsert(created);\n notify(() => provider.onCreated?.(created, { origin: \"local\" }));\n return created;\n } catch (error) {\n report(error);\n } finally {\n isSubmitting.value = false;\n }\n }\n\n async function update(\n commentId: string,\n patch: CommentPatch,\n ): Promise<Comment> {\n const { update: providerUpdate } = provider;\n if (typeof providerUpdate !== \"function\") refuse(\"update\");\n const templateId = requireTemplateId(\"update\");\n requireUser(\"update\");\n isSubmitting.value = true;\n try {\n const updated = await providerUpdate(templateId, commentId, patch);\n upsert(updated);\n notify(() => provider.onUpdated?.(updated, { origin: \"local\" }));\n return updated;\n } catch (error) {\n report(error);\n } finally {\n isSubmitting.value = false;\n }\n }\n\n async function remove(commentId: string): Promise<void> {\n const { delete: providerDelete } = provider;\n if (typeof providerDelete !== \"function\") refuse(\"delete\");\n const templateId = requireTemplateId(\"delete\");\n requireUser(\"delete\");\n // Snapshotted before the request: the event carries what was deleted, and\n // there is nothing to read afterwards.\n const existing = find(commentId);\n isSubmitting.value = true;\n try {\n await providerDelete(templateId, commentId);\n drop(commentId);\n if (existing) {\n notify(() => provider.onDeleted?.(existing, { origin: \"local\" }));\n }\n } catch (error) {\n report(error);\n } finally {\n isSubmitting.value = false;\n }\n }\n\n async function setResolved(\n commentId: string,\n resolved: boolean,\n ): Promise<Comment> {\n const { setResolved: providerSetResolved } = provider;\n if (typeof providerSetResolved !== \"function\") refuse(\"setResolved\");\n const templateId = requireTemplateId(\"setResolved\");\n requireUser(\"setResolved\");\n isSubmitting.value = true;\n try {\n const updated = await providerSetResolved(\n templateId,\n commentId,\n resolved,\n );\n upsert(updated);\n // The stored result decides which event fires, not the requested state: a\n // store may refuse to reopen, and the consumer should hear what happened.\n notify(() =>\n (updated.resolvedAt ? provider.onResolved : provider.onUnresolved)?.(\n updated,\n { origin: \"local\" },\n ),\n );\n return updated;\n } catch (error) {\n report(error);\n } finally {\n isSubmitting.value = false;\n }\n }\n\n function applyRemoteCreate(comment: Comment): void {\n // A reply whose parent thread isn't loaded reports nothing: `upsert`\n // finds no matching thread to attach it to, so the list doesn't change.\n if (upsert(comment)) {\n notify(() => provider.onCreated?.(comment, { origin: \"remote\" }));\n }\n }\n\n function applyRemoteUpdate(comment: Comment): void {\n if (!upsert(comment)) return;\n notify(() =>\n (comment.resolvedAt\n ? provider.onResolved\n : // An unresolve and a body edit are both \"not resolved\"; only a payload\n // that used to be resolved is an unresolve, and the transport doesn't\n // say. `updated` is the honest answer for a plain change.\n provider.onUpdated)?.(comment, { origin: \"remote\" }),\n );\n }\n\n function applyRemoteDelete(\n commentId: string,\n parentId?: string | null,\n ): void {\n const existing = drop(commentId, parentId);\n if (existing) {\n notify(() => provider.onDeleted?.(existing, { origin: \"remote\" }));\n }\n }\n\n return {\n comments,\n isLoading,\n isSubmitting,\n canCreate,\n canUpdate,\n canDelete,\n canResolve,\n totalCount,\n unresolvedCount,\n commentCountByBlock,\n load,\n create,\n update,\n remove,\n setResolved,\n find,\n isOwn,\n applyRemoteCreate,\n applyRemoteUpdate,\n applyRemoteDelete,\n };\n}\n\nexport interface UseCommentListenerOptions {\n comments: UseCommentsReturn;\n provider: CommentsProvider;\n getTemplateId: () => string | null;\n}\n\n/**\n * Wire {@link CommentsProvider.subscribe} into the three `applyRemote*` paths.\n *\n * A no-op when the provider has no `subscribe` — realtime is optional, and\n * comments without it work exactly the same except that a colleague's comment\n * only appears on the next read. Nothing here knows about a transport: Cloud's\n * Pusher channel lives inside `createCloudCommentsProvider`, and an SSE or\n * long-poll implementation is the same three lines on the consumer's side.\n *\n * Re-subscribes when the template id changes, and unsubscribes on scope dispose —\n * so a session that loads a second template does not keep receiving the first\n * one's comments.\n */\nexport function useCommentListener(options: UseCommentListenerOptions): void {\n const { comments, provider, getTemplateId } = options;\n const { subscribe } = provider;\n if (typeof subscribe !== \"function\") return;\n\n let unsubscribe: (() => void) | null = null;\n\n function stop(): void {\n unsubscribe?.();\n unsubscribe = null;\n }\n\n watch(\n () => getTemplateId(),\n (templateId) => {\n stop();\n if (!templateId) return;\n unsubscribe = subscribe(templateId, (change: CommentChange) => {\n switch (change.type) {\n case \"created\":\n comments.applyRemoteCreate(change.comment);\n break;\n case \"updated\":\n comments.applyRemoteUpdate(change.comment);\n break;\n case \"deleted\":\n comments.applyRemoteDelete(change.commentId, change.parentId);\n break;\n }\n });\n },\n { immediate: true },\n );\n\n onScopeDispose(stop);\n}\n","import type { Translations } from \"../i18n\";\nimport type {\n Block,\n CustomBlock,\n CustomBlockDefinition,\n} from \"@templatical/types\";\n\n/**\n * Returns the i18n label for a built-in block type.\n * Falls back to the raw type string for unknown types.\n */\nexport function getBlockTypeLabel(\n blockType: string,\n translations: Translations,\n): string {\n const labels = translations.blocks as Record<string, string>;\n return labels[blockType] ?? blockType;\n}\n\n/**\n * Display label for a block *instance*, which is what user-facing copy wants:\n * built-ins resolve to their i18n label, custom blocks to the consumer's own\n * name for them (\"Featured Article\"), not the literal type `\"custom\"`.\n *\n * `blocks` carries no `custom` key on purpose — one generic \"Custom\" would make\n * two different custom blocks indistinguishable in a list. The name comes from\n * the definition instead; it is consumer-supplied and therefore NOT localized,\n * which is already how the toolbar and the sidebar palette present it.\n *\n * Falls back to `customType` (the slug) when no definition matches — an\n * instance whose definition was never registered — mirroring `Toolbar.vue`.\n * Pass the array injected under `CUSTOM_BLOCK_DEFINITIONS_KEY`; omitting it\n * degrades to that same slug fallback rather than throwing.\n */\nexport function getBlockLabel(\n block: Block,\n translations: Translations,\n customBlockDefinitions: readonly CustomBlockDefinition[] = [],\n): string {\n if (block.type !== \"custom\") {\n return getBlockTypeLabel(block.type, translations);\n }\n const { customType } = block as CustomBlock;\n const definition = customBlockDefinitions.find((d) => d.type === customType);\n return definition?.name ?? customType;\n}\n","import type { CustomBlockColorField } from \"@templatical/types\";\nimport {\n DEFAULT_RESOLVED_COLORS,\n resolveColorsConfig,\n type ResolvedColors,\n} from \"./resolveColorsConfig\";\n\n/**\n * The palette one custom-block color field renders, plus the audit signals a\n * consumer needs to warn about a field config that could not be honoured.\n *\n * Pure — this util never logs. The warnings live at the definition-registration\n * site (`useEditorCore`, via `collectColorFieldIssues`), the same resolver /\n * consumer split `resolveColorsConfig` and `resolvePaletteBlocks` use.\n */\nexport interface ResolvedFieldColors {\n /** The preset grid this field's picker renders. */\n presets: string[];\n /** Whether the wheel + hex input are offered alongside the grid. */\n allowCustom: boolean;\n /**\n * Entries of the FIELD's own `presets` dropped as invalid hex. Never includes\n * anything inherited from the editor palette — those were already validated\n * (and already warned about) at the editor level, so they are not re-reported.\n */\n invalidPresets: string[];\n /** The field declared `presets: []` — an empty list cannot narrow anything. */\n emptyPresets: boolean;\n /**\n * The field contributed no usable presets (unset, empty, or all-invalid), so\n * {@link ResolvedFieldColors.presets} is the editor's palette.\n */\n presetsInherited: boolean;\n /**\n * The field asked for `allowCustom: true` while the editor is locked. A field\n * may only narrow, so the request is dropped and the field stays locked.\n */\n allowCustomIgnored: boolean;\n}\n\n/**\n * Resolve a custom-block color field's own `presets` / `allowCustom` against\n * the already-resolved editor-wide palette. A field narrows the author's\n * freedom, not the palette: it can lock this field or give it its own presets,\n * but never unlock what the editor locked — and its `presets` *replace* the\n * editor grid rather than intersecting it (a locked field may list colors\n * outside it):\n *\n * - `allowCustom` — locked stays locked. `editorResolved.allowCustom === false`\n * wins outright, so an explicit field `allowCustom: true` under a locked\n * editor is ignored (flagged via `allowCustomIgnored`). Otherwise the field's\n * value applies, falling back to the editor's.\n * - `presets` — the field's entries are validated by {@link resolveColorsConfig}\n * (against the unconfigured baseline, so the hex rule lives in exactly one\n * place and inheritance is decided here rather than by that util's generic\n * per-property precedence). A non-empty valid list replaces the editor's;\n * unset, `[]`, or all-invalid all inherit the editor's palette. This is why\n * `[]` cannot mean \"no chips\" — an empty grid on a locked field would leave\n * the picker with nothing to pick.\n *\n * One residual case is left to `ColorPicker`'s own guard rather than forced\n * here: a field locking itself (`allowCustom: false`) when neither it nor the\n * editor has presets resolves to `{ presets: [], allowCustom: false }`, and the\n * picker's `showFreeform = allowCustom || !hasPresets` still renders the wheel,\n * so the field is never left unable to set a color.\n */\nexport function resolveFieldColors(\n field: Pick<CustomBlockColorField, \"presets\" | \"allowCustom\">,\n editorResolved: ResolvedColors,\n): ResolvedFieldColors {\n // Validate the field's own presets through the shared resolver, against the\n // unconfigured baseline — NOT against `editorResolved`, whose per-property\n // precedence would inherit before we can tell \"field said nothing\" apart\n // from \"field said something unusable\".\n const own = resolveColorsConfig(\n { presets: field.presets },\n DEFAULT_RESOLVED_COLORS,\n );\n\n const presetsInherited = own.presets.length === 0;\n\n const requestedAllowCustom = field.allowCustom ?? editorResolved.allowCustom;\n\n return {\n presets: presetsInherited ? editorResolved.presets : own.presets,\n allowCustom:\n editorResolved.allowCustom === false ? false : requestedAllowCustom,\n invalidPresets: own.invalidPresets,\n emptyPresets: field.presets !== undefined && field.presets.length === 0,\n presetsInherited,\n allowCustomIgnored:\n field.allowCustom === true && editorResolved.allowCustom === false,\n };\n}\n","import {\n computed,\n toValue,\n type ComputedRef,\n type MaybeRefOrGetter,\n} from \"vue\";\nimport { useDropZone } from \"@vueuse/core\";\n\nexport interface UseImageDropOptions {\n /** The drop target element (a template ref). */\n target: MaybeRefOrGetter<HTMLElement | null | undefined>;\n /**\n * Called with the dropped image file(s). The editor acts on a single file\n * per drop (`files[0]`), but the array shape is kept for forward-compat.\n */\n onFiles: (files: File[]) => void;\n /**\n * Gate the zone. While falsy the drop is inert: no highlight, dropped files\n * are ignored. Components pass `canDropMedia && !isUploading` so a\n * read-only library (`create: false`) renders no affordance, a missing\n * media handler does the same, and a second drop can't race an in-flight\n * upload.\n */\n enabled?: MaybeRefOrGetter<boolean>;\n}\n\nexport interface UseImageDropReturn {\n /** True while an image drag hovers the (enabled) target — drive the highlight. */\n isOver: ComputedRef<boolean>;\n}\n\nconst IMAGE_MIME_PREFIX = \"image/\";\n\n/**\n * Drag-and-drop image upload onto an image block/field (#229). Wraps\n * `useDropZone`; filters dropped files to image MIME types client-side (the\n * authoritative size/type check stays server/plan-config side) and forwards\n * the first image to `onFiles`. The caller hands the file to `onRequestMedia`,\n * which uploads it and returns a `MediaResult` — identical to the Browse Media\n * path, only the input differs.\n *\n * `preventDefaultForUnhandled` keeps the browser from navigating to the dropped\n * file even for a non-image drop on the zone; the editor-root guard covers\n * drops that land outside any zone.\n */\nexport function useImageDrop(options: UseImageDropOptions): UseImageDropReturn {\n const { target, onFiles, enabled } = options;\n\n const isEnabled = (): boolean =>\n enabled === undefined ? true : toValue(enabled);\n\n const { isOverDropZone } = useDropZone(target, {\n preventDefaultForUnhandled: true,\n onDrop: (files) => {\n if (!isEnabled()) return;\n const images = (files ?? []).filter((file) =>\n file.type.startsWith(IMAGE_MIME_PREFIX),\n );\n if (images.length > 0) onFiles([images[0]]);\n },\n });\n\n const isOver = computed(() => isEnabled() && isOverDropZone.value);\n\n return { isOver };\n}\n","import { SOCIAL_ICON_GLYPHS, type SocialPlatform } from \"@templatical/types\";\n\n/**\n * Icon glyph (SVG path + brand color) per platform. Re-exported from the\n * shared kernel in `@templatical/types` so the editor's inline SVG and the\n * renderer's PNG rasterizer never drift. Platform display labels are NOT here\n * — they come from i18n (`t.social.platforms[platform]`).\n */\nexport const socialIcons = SOCIAL_ICON_GLYPHS;\n\nexport const socialIconSizeMap: Record<\"small\" | \"medium\" | \"large\", number> = {\n small: 24,\n medium: 32,\n large: 48,\n};\n\nexport const socialPlatformOptions: SocialPlatform[] = [\n \"facebook\",\n \"twitter\",\n \"instagram\",\n \"linkedin\",\n \"youtube\",\n \"tiktok\",\n \"pinterest\",\n \"email\",\n \"website\",\n \"whatsapp\",\n \"telegram\",\n \"discord\",\n \"snapchat\",\n \"reddit\",\n \"github\",\n \"dribbble\",\n \"behance\",\n];\n"],"mappings":";;;;;AAQA,SAAgByB,EAAkB,GAAuB;CACvD,OAAOC,aAAiB,QACpBA,IACI,MAAM,OAAOA,CAAK,GAAG,EAAE,OAAOA,EAAM,CAAC;AAC/C;AAYA,SAAgBC,EACd,GACA,GACM;CACN,IAAI;EACF,EAAI;CACN,SAASD,GAAO;EACd,IAAUD,EAAkBC,CAAK,CAAC;CACpC;AACF;;;ACZA,SAASE,EAAe,GAA8B;CAGpD,OAFIC,MAAW,MAAY,IACvBA,MAAW,MAAY,IACpB;AACT;AAwHA,SAAgBC,EAAU,GAA4C;CACpE,IAAMC,IACJC,EAAQ,WACRjB,EACEiB,EAAQ,mBACRA,EAAQ,gBACV;CAGF,AADAX,EAAsBU,CAAW,GACjCf,EAAyBe,CAAW;CAEpC,IAAME,IAAQzB,EAAsB;EAClC,UAAU;EACV,SAASuB;EACT,iBAAiB;EACjB,UAAU;EACV,UAAU;EACV,aAAa;EACb,SAA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F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-BR3I3gOW.js","names":["candidate","BORDER_SIDES","uniformBorder","side","toBorderCss","toBorderDeclarations","border","css","value","declarations","index","BORDER_CORNERS","cornerPx","toBorderRadiusCss","radius","corners","corner","HEADING_LEVEL_FONT_SIZE","RICH_TEXT_SPACING","SOCIAL_ICON_GLYPHS","isSection","block","isTitle","isParagraph","isImage","isButton","isDivider","isVideo","isSocialIcons","isSpacer","isHtml","isMenu","isTable","isCustomBlock","isSlot","isWrapper","TITLE_BLOCK_DEFAULTS","PARAGRAPH_BLOCK_DEFAULTS","IMAGE_BLOCK_DEFAULTS","BUTTON_BLOCK_DEFAULTS","DIVIDER_BLOCK_DEFAULTS","SECTION_BLOCK_DEFAULTS","VIDEO_BLOCK_DEFAULTS","SOCIAL_ICONS_BLOCK_DEFAULTS","SPACER_BLOCK_DEFAULTS","HTML_BLOCK_DEFAULTS","MENU_BLOCK_DEFAULTS","TABLE_BLOCK_DEFAULTS","COUNTDOWN_BLOCK_DEFAULTS","DEFAULT_BLOCK_DEFAULTS","DEFAULT_TEMPLATE_DEFAULTS","isPlainObject","deepMergeDefaults","result","base","key","overrides","baseVal","overrideVal","createDefaultTemplateContent","defaultFontFamily","templateDefaults","RTL_LANGUAGE_PRIMARY_SUBTAGS","isRtlLanguageTag","primary","tag","resolveContentDirection","settings","applyDefaults","partial","generateId","createDefaultSpacing","createDefaultStyles","padding","createTitleBlock","createParagraphBlock","createImageBlock","createButtonBlock","createDividerBlock","createSectionBlock","createVideoBlock","createSocialIconsBlock","createSpacerBlock","createHtmlBlock","createMenuBlock","createDefaultTableRows","rows","columns","createTableBlock","createCountdownBlock","getFieldDefault","field","createCustomBlock","fieldValues","definition","styles","createSlotBlock","createWrapperBlock","createBlock","type","blockDefaults","cloneBlock","cloned","column","child","c","safeClone","seen","val","EXACTLY_ONE_SLOT","SLOT_NESTED_IN_SECTION","WRAPPER_IN_WRAPPER","NESTED_MJ_WRAPPER","SLOT_IN_CONTENT","WRAPPER_IN_CONTENT","walkBlocks","blocks","visit","parent","insideSection","validateLayout","slotCount","layout","assertNoSlotInContent","content","assertNoWrapperInContent","layoutWrapsSlot","wrapped","cloneLayoutBlock","findSlotLocation","i","nested","emitsMjWrapper","applyLayout","location","QUOTES","findOpenTagEnd","quote","from","html","char","isAttrNameChar","isWhitespace","NAMED_ENTITIES","decodeAttrEntities","ref","code","match","getTagAttrValue","target","name","attrs","nameStart","attrName","valueStart","valueEnd","SYNTAX_PRESETS","SYNTAX_TRIGGER_CHARS","SYNTAX_CLOSING_CHARS","getSyntaxTriggerChar","syntax","getSyntaxClosingChar","resolveSyntax","anchoredRegex","source","pattern","flags","isMergeTagValue","trimmed","getMergeTagLabel","found","mergeTags","p","resolveHtmlMergeTagLabels","rewriteSpanByAttr","getMergeTagSample","substituteHtmlMergeTagSamples","escapeTagText","hasMergeTagSamples","substituteTextMergeTagSamples","text","out","containsMergeTag","valueRegex","logicRegex","isLogicMergeTagValue","getLogicMergeTagKeyword","regex","resolveHtmlLogicMergeTagLabels","open","afterTagName","openEnd","closeStart","newLabel","relabel","options","isRenderableTemplateContent","SdkError","message","statusCode"],"sources":["../../../../types/src/blocks.ts","../../../../types/src/social.ts","../../../../types/src/guards.ts","../../../../types/src/defaults.ts","../../../../types/src/template.ts","../../../../types/src/direction.ts","../../../../types/src/factory.ts","../../../../types/src/clone.ts","../../../../types/src/layout.ts","../../../../types/src/html-scan.ts","../../../../types/src/merge-tags.ts","../../../../types/src/preview-resolution.ts","../../../../types/src/config.ts"],"sourcesContent":["export interface SpacingValue {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface BlockStyles {\n padding: SpacingValue;\n backgroundColor?: string;\n}\n\nexport type BorderStyle = \"solid\" | \"dashed\" | \"dotted\";\n\nexport type BorderSide = \"top\" | \"right\" | \"bottom\" | \"left\";\n\nexport const BORDER_SIDES: readonly BorderSide[] = [\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n];\n\n/** One side of a border. A width of `0` leaves that side undrawn. */\nexport interface BorderSideValue {\n /** Width in px. `0` means no border on this side. */\n width: number;\n style: BorderStyle;\n color: string;\n}\n\n/**\n * A border described per side, like `SpacingValue`. Only elements MJML can\n * border natively carry one: sections, images and buttons.\n */\nexport interface BorderValue {\n top: BorderSideValue;\n right: BorderSideValue;\n bottom: BorderSideValue;\n left: BorderSideValue;\n}\n\n/** The same side value on all four sides. */\nexport function uniformBorder(side: BorderSideValue): BorderValue {\n return {\n top: { ...side },\n right: { ...side },\n bottom: { ...side },\n left: { ...side },\n };\n}\n\n/**\n * Convert one side of a border to a CSS `border` value like\n * `\"1px solid #cccccc\"`. Returns `null` when the side is absent or its width is\n * not a positive number, so callers emit nothing rather than a `0px` border.\n */\nexport function toBorderCss(side: BorderSideValue | undefined): string | null {\n if (\n !side ||\n typeof side.width !== \"number\" ||\n !Number.isFinite(side.width) ||\n side.width <= 0\n ) {\n return null;\n }\n\n return `${side.width}px ${side.style} ${side.color}`;\n}\n\n/**\n * Resolve a border to the CSS declarations that draw it, keyed by kebab-case\n * property: one `border` when all four sides are drawn identically, otherwise\n * one `border-<side>` per drawn side. Empty when there is nothing to draw.\n *\n * The keys double as MJML attribute names (`mj-section`, `mj-image` and\n * `mj-button` accept `border` and every `border-<side>`), so the renderer and\n * the editor canvas both go through this and can't disagree about a border.\n */\nexport function toBorderDeclarations(\n border: BorderValue | undefined,\n): Partial<Record<\"border\" | `border-${BorderSide}`, string>> {\n if (!border) {\n return {};\n }\n\n const css = BORDER_SIDES.map((side) => toBorderCss(border[side]));\n if (css[0] !== null && css.every((value) => value === css[0])) {\n return { border: css[0] };\n }\n\n const declarations: Partial<Record<`border-${BorderSide}`, string>> = {};\n BORDER_SIDES.forEach((side, index) => {\n const value = css[index];\n if (value !== null) {\n declarations[`border-${side}`] = value;\n }\n });\n return declarations;\n}\n\nexport type BorderCorner =\n \"topLeft\" | \"topRight\" | \"bottomRight\" | \"bottomLeft\";\n\n/** In CSS shorthand order: top-left, top-right, bottom-right, bottom-left. */\nexport const BORDER_CORNERS: readonly BorderCorner[] = [\n \"topLeft\",\n \"topRight\",\n \"bottomRight\",\n \"bottomLeft\",\n];\n\n/** A radius per corner, in px. */\nexport type CornerRadius = Record<BorderCorner, number>;\n\n/**\n * A corner radius in px: one number for all four corners, or a radius per\n * corner.\n */\nexport type BorderRadiusValue = number | CornerRadius;\n\nfunction cornerPx(value: unknown): number {\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value\n : 0;\n}\n\n/**\n * Convert a corner radius to a CSS `border-radius` value: `\"8px\"` when all\n * corners match, otherwise the four-value shorthand `\"8px 8px 0px 0px\"`\n * (top-left, top-right, bottom-right, bottom-left). Returns `null` when every\n * corner is square, so callers emit nothing.\n *\n * A non-finite or negative corner counts as square — hand-authored JSON is the\n * only way to produce one, and the export must not carry it.\n */\nexport function toBorderRadiusCss(\n radius: BorderRadiusValue | undefined,\n): string | null {\n if (radius === undefined || radius === null) {\n return null;\n }\n\n const corners =\n typeof radius === \"number\"\n ? BORDER_CORNERS.map(() => cornerPx(radius))\n : BORDER_CORNERS.map((corner) => cornerPx(radius[corner]));\n\n if (corners.every((value) => value === 0)) {\n return null;\n }\n if (corners.every((value) => value === corners[0])) {\n return `${corners[0]}px`;\n }\n return corners.map((value) => `${value}px`).join(\" \");\n}\n\nexport interface BlockVisibility {\n desktop: boolean;\n mobile: boolean;\n}\n\nexport interface BaseBlock {\n id: string;\n type: string;\n styles: BlockStyles;\n visibility?: BlockVisibility;\n displayCondition?: {\n label: string;\n before: string;\n after: string;\n group?: string;\n description?: string;\n };\n}\n\nexport type ColumnLayout = \"1\" | \"2\" | \"3\" | \"2-1\" | \"1-2\";\n\n/**\n * Optional outer frame for a section. When present, the section is rendered\n * inside an `mj-wrapper` — a full-width band (its own background + padding)\n * that frames the section, e.g. a white card sitting on a colored band.\n */\nexport interface SectionWrapper {\n backgroundColor?: string;\n padding?: SpacingValue;\n /**\n * Corner radius in px for the outer frame — one number, or a radius per\n * corner. Omitted/0 = square corners.\n */\n borderRadius?: BorderRadiusValue;\n}\n\nexport interface SectionBlock extends BaseBlock {\n type: \"section\";\n columns: ColumnLayout;\n children: Block[][];\n /**\n * Whether columns stack vertically on mobile. Absent or `true` keeps MJML's\n * default responsive behavior (columns stack below 480px). `false` renders\n * the columns inside an `<mj-group>` so they stay side-by-side on mobile,\n * proportionally shrunk to fit.\n */\n stackOnMobile?: boolean;\n /**\n * Corner radius in px — one number, or a radius per corner. Omitted/0 =\n * square corners.\n */\n borderRadius?: BorderRadiusValue;\n /**\n * Border around the section box, per side. Omitted = no border; a side with\n * width 0 is not drawn.\n */\n border?: BorderValue;\n /** Optional outer frame (rendered as an `mj-wrapper` around the section). */\n wrapper?: SectionWrapper;\n}\n\nexport type HeadingLevel = 1 | 2 | 3 | 4;\n\nexport const HEADING_LEVEL_FONT_SIZE: Record<HeadingLevel, number> = {\n 1: 36,\n 2: 28,\n 3: 22,\n 4: 18,\n};\n\n/**\n * Spacing (px) for the HTML a rich-text block stores — the `<p>`, `<ul>`,\n * `<ol>` and `<li>` elements TipTap produces.\n *\n * The editor canvas and the exported email must agree on these to the pixel,\n * so this is the one place they are stated. `@templatical/renderer` reads them\n * to build the global rule it emits; the editor's canvas CSS restates them as\n * literals (CSS cannot import a constant) and a parity test holds the two\n * together.\n *\n * Fixed px, never a `rem`- or base-size-derived scale: an email body is a\n * fixed-width document, so content spacing must not move when a consumer\n * scales the editor chrome.\n */\nexport const RICH_TEXT_SPACING = {\n /** Gap below every `<p>` except the last — the space between paragraphs. */\n paragraphGap: 8,\n /** Vertical margin on `<ul>` / `<ol>`. */\n listMarginY: 8,\n /** Left padding on `<ul>` / `<ol>` — the bullet indent. */\n listPaddingLeft: 24,\n /** Vertical margin on `<li>`. */\n listItemMarginY: 4,\n} as const;\n\nexport interface TitleBlock extends BaseBlock {\n type: \"title\";\n content: string;\n level: HeadingLevel;\n /** Text color. Unset = inherit the document-level `textColor`. */\n color?: string;\n textAlign: \"left\" | \"center\" | \"right\";\n fontFamily?: string;\n}\n\nexport interface ParagraphBlock extends BaseBlock {\n type: \"paragraph\";\n content: string;\n /**\n * Gap in px between this block's paragraphs — the space below every `<p>`\n * except the last. Absent means `RICH_TEXT_SPACING.paragraphGap`.\n *\n * Only affects a block holding more than one paragraph; a single `<p>` has no\n * internal gap, and the space around the block is `styles.padding`.\n *\n * `0` is a valid choice (paragraphs butted together) and is distinct from the\n * field being absent, so readers must test for `undefined` rather than\n * falsiness.\n */\n paragraphSpacing?: number;\n}\n\nexport interface ImageBlock extends BaseBlock {\n type: \"image\";\n src: string;\n alt: string;\n width: number | \"full\";\n /**\n * Height in pixels. Absent means the height is derived from the width, so the\n * image keeps its aspect ratio — setting both stretches it, since email\n * clients don't support `object-fit`.\n */\n height?: number;\n align: \"left\" | \"center\" | \"right\";\n /**\n * Corner radius in px. Omitted/0 = square corners. A radius of at least half\n * the rendered size rounds a square image to a circle, which is how avatar\n * and portrait layouts are built. A radius per corner is also accepted.\n */\n borderRadius?: BorderRadiusValue;\n /**\n * Border around the image itself, per side. Omitted = no border; a side with\n * width 0 is not drawn.\n */\n border?: BorderValue;\n linkUrl?: string;\n linkOpenInNewTab?: boolean;\n placeholderUrl?: string;\n decorative?: boolean;\n}\n\nexport interface ButtonBlock extends BaseBlock {\n type: \"button\";\n text: string;\n url: string;\n openInNewTab?: boolean;\n backgroundColor: string;\n textColor: string;\n /** Corner radius in px — one number, or a radius per corner. */\n borderRadius: BorderRadiusValue;\n /**\n * Border around the button itself, per side. Omitted = no border; a side\n * with width 0 is not drawn. For an outline (\"ghost\") button, set\n * `backgroundColor` to the keyword `\"transparent\"` (the background control\n * stores it) and set `textColor` too — a new button is `#333333` with white\n * text. An empty fill exports as `transparent`, because MJML paints\n * `#414141` when the attribute is omitted.\n */\n border?: BorderValue;\n fontSize: number;\n buttonPadding: SpacingValue;\n fontFamily?: string;\n width?: number | \"full\";\n /**\n * Placement of the button within its column. No visible effect when `width`\n * is `\"full\"`, since the button then spans the column.\n */\n align: \"left\" | \"center\" | \"right\";\n}\n\n/**\n * A share of the column, from `\"0%\"` to `\"100%\"`.\n * @pattern ^(?:100(?:\\.0+)?|\\d{1,2}(?:\\.\\d+)?)%$\n */\nexport type DividerPercentWidth = `${number}%`;\n\nexport interface DividerBlock extends BaseBlock {\n type: \"divider\";\n lineStyle: \"solid\" | \"dashed\" | \"dotted\";\n color: string;\n thickness: number;\n /**\n * `\"full\"` spans the column and a number is pixels. A percentage is a share\n * of the column: MJML renders it natively, and it shrinks with the column on\n * a phone where a pixel width would overflow.\n */\n width: number | \"full\" | DividerPercentWidth;\n}\n\nexport interface VideoBlock extends BaseBlock {\n type: \"video\";\n url: string;\n openInNewTab?: boolean;\n thumbnailUrl: string;\n alt: string;\n width: number | \"full\";\n /**\n * Height in pixels for the thumbnail. Absent means the height is derived from\n * the width, so the thumbnail keeps its aspect ratio — setting both stretches\n * it, since email clients don't support `object-fit`.\n */\n height?: number;\n align: \"left\" | \"center\" | \"right\";\n placeholderUrl?: string;\n}\n\nexport type SocialPlatform =\n | \"facebook\"\n | \"twitter\"\n | \"instagram\"\n | \"linkedin\"\n | \"youtube\"\n | \"tiktok\"\n | \"pinterest\"\n | \"email\"\n | \"whatsapp\"\n | \"telegram\"\n | \"discord\"\n | \"snapchat\"\n | \"reddit\"\n | \"github\"\n | \"dribbble\"\n | \"behance\"\n | \"website\";\n\nexport type SocialIconStyle =\n \"solid\" | \"outlined\" | \"rounded\" | \"square\" | \"circle\";\n\nexport type SocialIconSize = \"small\" | \"medium\" | \"large\";\n\nexport interface SocialIcon {\n id: string;\n platform: SocialPlatform;\n url: string;\n}\n\nexport interface SocialIconsBlock extends BaseBlock {\n type: \"social\";\n icons: SocialIcon[];\n iconStyle: SocialIconStyle;\n iconSize: SocialIconSize;\n spacing: number;\n align: \"left\" | \"center\" | \"right\";\n}\n\nexport interface SpacerBlock extends BaseBlock {\n type: \"spacer\";\n height: number;\n}\n\nexport interface HtmlBlock extends BaseBlock {\n type: \"html\";\n content: string;\n}\n\nexport interface MenuItemData {\n id: string;\n text: string;\n url: string;\n openInNewTab: boolean;\n bold: boolean;\n underline: boolean;\n color?: string;\n}\n\nexport interface MenuBlock extends BaseBlock {\n type: \"menu\";\n items: MenuItemData[];\n fontSize: number;\n fontFamily?: string;\n /** Base text/link color. Unset = inherit the document-level `textColor`. */\n color?: string;\n linkColor?: string;\n textAlign: \"left\" | \"center\" | \"right\";\n separator: string;\n separatorColor: string;\n spacing: number;\n}\n\nexport interface TableCellData {\n id: string;\n content: string;\n}\n\nexport interface TableRowData {\n id: string;\n cells: TableCellData[];\n}\n\nexport interface TableBlock extends BaseBlock {\n type: \"table\";\n rows: TableRowData[];\n hasHeaderRow: boolean;\n headerBackgroundColor?: string;\n borderColor: string;\n borderWidth: number;\n cellPadding: number;\n fontSize: number;\n fontFamily?: string;\n /** Text color. Unset = inherit the document-level `textColor`. */\n color?: string;\n textAlign: \"left\" | \"center\" | \"right\";\n}\n\nexport interface CountdownBlock extends BaseBlock {\n type: \"countdown\";\n targetDate: string;\n timezone: string;\n showDays: boolean;\n showHours: boolean;\n showMinutes: boolean;\n showSeconds: boolean;\n separator: \":\" | \"-\" | \" \";\n digitFontSize: number;\n digitColor: string;\n labelColor: string;\n labelFontSize: number;\n backgroundColor: string;\n fontFamily?: string;\n labelDays: string;\n labelHours: string;\n labelMinutes: string;\n labelSeconds: string;\n expiredMessage: string;\n expiredImageUrl: string;\n hideOnExpiry: boolean;\n}\n\nexport interface CustomBlock extends BaseBlock {\n type: \"custom\";\n customType: string;\n fieldValues: Record<string, unknown>;\n renderedHtml?: string;\n dataSourceFetched?: boolean;\n}\n\n/**\n * Layout-only hole where authored content is spliced in. Extends BaseBlock so\n * Block walkers stay typed (`styles` unused; spliced out before render).\n */\nexport interface SlotBlock extends BaseBlock {\n type: \"slot\";\n}\n\n/**\n * Layout-only band rendered as `mj-wrapper`. The block is the band:\n * `styles.backgroundColor` / `styles.padding` / `borderRadius` map to the\n * wrapper. Legal in layout only this ship.\n */\nexport interface WrapperBlock extends BaseBlock {\n type: \"wrapper\";\n children: Block[];\n borderRadius?: number;\n}\n\nexport type Block =\n | SectionBlock\n | TitleBlock\n | ParagraphBlock\n | ImageBlock\n | ButtonBlock\n | DividerBlock\n | VideoBlock\n | SocialIconsBlock\n | SpacerBlock\n | HtmlBlock\n | MenuBlock\n | TableBlock\n | CountdownBlock\n | CustomBlock\n | SlotBlock\n | WrapperBlock;\n\nexport type BlockType = Block[\"type\"];\n","import type { SocialPlatform } from \"./blocks\";\n\n/**\n * SVG glyph (24×24 path) + brand color for each social platform.\n *\n * Single source of truth shared by two consumers that render icons in\n * different formats: the editor draws them as inline SVG (`SocialIconSvg.vue`)\n * and `@templatical/renderer` rasterizes them to PNGs\n * (`scripts/rasterize-social.mjs`) because Outlook's Word engine has no SVG\n * support. Typing as `Record<SocialPlatform, ...>` makes adding a platform to\n * the union a compile error until its glyph is supplied here, keeping both\n * consumers in lockstep.\n */\nexport interface SocialIconGlyph {\n /** SVG path data on a 24×24 viewBox. */\n path: string;\n /** Brand color as a 6-digit hex string. */\n color: string;\n}\n\nexport const SOCIAL_ICON_GLYPHS: Record<SocialPlatform, SocialIconGlyph> = {\n facebook: {\n color: \"#1877F2\",\n path: \"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z\",\n },\n twitter: {\n color: \"#000000\",\n path: \"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z\",\n },\n instagram: {\n color: \"#E4405F\",\n path: \"M12 0C8.74 0 8.333.015 7.053.072 5.775.132 4.905.333 4.14.63c-.789.306-1.459.717-2.126 1.384S.935 3.35.63 4.14C.333 4.905.131 5.775.072 7.053.012 8.333 0 8.74 0 12s.015 3.667.072 4.947c.06 1.277.261 2.148.558 2.913.306.788.717 1.459 1.384 2.126.667.666 1.336 1.079 2.126 1.384.766.296 1.636.499 2.913.558C8.333 23.988 8.74 24 12 24s3.667-.015 4.947-.072c1.277-.06 2.148-.262 2.913-.558.788-.306 1.459-.718 2.126-1.384.666-.667 1.079-1.335 1.384-2.126.296-.765.499-1.636.558-2.913.06-1.28.072-1.687.072-4.947s-.015-3.667-.072-4.947c-.06-1.277-.262-2.149-.558-2.913-.306-.789-.718-1.459-1.384-2.126C21.319 1.347 20.651.935 19.86.63c-.765-.297-1.636-.499-2.913-.558C15.667.012 15.26 0 12 0zm0 2.16c3.203 0 3.585.016 4.85.071 1.17.055 1.805.249 2.227.415.562.217.96.477 1.382.896.419.42.679.819.896 1.381.164.422.36 1.057.413 2.227.057 1.266.07 1.646.07 4.85s-.015 3.585-.074 4.85c-.061 1.17-.256 1.805-.421 2.227-.224.562-.479.96-.899 1.382-.419.419-.824.679-1.38.896-.42.164-1.065.36-2.235.413-1.274.057-1.649.07-4.859.07-3.211 0-3.586-.015-4.859-.074-1.171-.061-1.816-.256-2.236-.421-.569-.224-.96-.479-1.379-.899-.421-.419-.69-.824-.9-1.38-.165-.42-.359-1.065-.42-2.235-.045-1.26-.061-1.649-.061-4.844 0-3.196.016-3.586.061-4.861.061-1.17.255-1.814.42-2.234.21-.57.479-.96.9-1.381.419-.419.81-.689 1.379-.898.42-.166 1.051-.361 2.221-.421 1.275-.045 1.65-.06 4.859-.06l.045.03zm0 3.678c-3.405 0-6.162 2.76-6.162 6.162 0 3.405 2.76 6.162 6.162 6.162 3.405 0 6.162-2.76 6.162-6.162 0-3.405-2.76-6.162-6.162-6.162zM12 16c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4zm7.846-10.405c0 .795-.646 1.44-1.44 1.44-.795 0-1.44-.646-1.44-1.44 0-.794.646-1.439 1.44-1.439.793-.001 1.44.645 1.44 1.439z\",\n },\n linkedin: {\n color: \"#0A66C2\",\n path: \"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z\",\n },\n youtube: {\n color: \"#FF0000\",\n path: \"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z\",\n },\n tiktok: {\n color: \"#000000\",\n path: \"M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z\",\n },\n pinterest: {\n color: \"#BD081C\",\n path: \"M12 0C5.373 0 0 5.372 0 12c0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.782c0-1.668.967-2.914 2.171-2.914 1.023 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.133 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.138.893 2.738.098.119.112.224.083.345l-.333 1.36c-.053.22-.174.267-.402.161-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.359-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146C9.57 23.812 10.763 24 12 24c6.627 0 12-5.373 12-12 0-6.628-5.373-12-12-12z\",\n },\n email: {\n color: \"#6B7280\",\n path: \"M1.5 8.67v8.58a3 3 0 003 3h15a3 3 0 003-3V8.67l-8.928 5.493a3 3 0 01-3.144 0L1.5 8.67z M22.5 6.908V6.75a3 3 0 00-3-3h-15a3 3 0 00-3 3v.158l9.714 5.978a1.5 1.5 0 001.572 0L22.5 6.908z\",\n },\n website: {\n color: \"#6B7280\",\n path: \"M21.721 12.752a9.711 9.711 0 0 0-.945-5.003 12.754 12.754 0 0 1-4.339 2.708 18.991 18.991 0 0 1-.214 4.772 17.165 17.165 0 0 0 5.498-2.477ZM14.634 15.55a17.324 17.324 0 0 0 .332-4.647c-.952.227-1.945.347-2.966.347-1.021 0-2.014-.12-2.966-.347a17.515 17.515 0 0 0 .332 4.647 17.385 17.385 0 0 0 5.268 0ZM9.772 17.119a18.963 18.963 0 0 0 4.456 0A17.182 17.182 0 0 1 12 21.724a17.18 17.18 0 0 1-2.228-4.605ZM7.777 15.23a18.87 18.87 0 0 1-.214-4.774 12.753 12.753 0 0 1-4.34-2.708 9.711 9.711 0 0 0-.944 5.004 17.165 17.165 0 0 0 5.498 2.477ZM21.356 14.752a9.765 9.765 0 0 1-7.478 6.817 18.64 18.64 0 0 0 1.988-4.718 18.627 18.627 0 0 0 5.49-2.098ZM2.644 14.752c1.682.971 3.53 1.688 5.49 2.099a18.64 18.64 0 0 0 1.988 4.718 9.765 9.765 0 0 1-7.478-6.816ZM13.878 2.43a9.755 9.755 0 0 1 6.116 3.986 11.267 11.267 0 0 1-3.746 2.504 18.63 18.63 0 0 0-2.37-6.49ZM12 2.276a17.152 17.152 0 0 1 2.805 7.121c-.897.23-1.837.353-2.805.353-.968 0-1.908-.122-2.805-.353A17.151 17.151 0 0 1 12 2.276ZM10.122 2.43a18.629 18.629 0 0 0-2.37 6.49 11.266 11.266 0 0 1-3.746-2.504 9.754 9.754 0 0 1 6.116-3.985Z\",\n },\n whatsapp: {\n color: \"#25D366\",\n path: \"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z\",\n },\n telegram: {\n color: \"#26A5E4\",\n path: \"M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z\",\n },\n discord: {\n color: \"#5865F2\",\n path: \"M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z\",\n },\n snapchat: {\n color: \"#FFFC00\",\n path: \"M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.162-.105-.949-.199-2.403.041-3.439.219-.937 1.406-5.957 1.406-5.957s-.359-.72-.359-1.781c0-1.668.967-2.914 2.171-2.914 1.023 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.133 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.138.893 2.738a.36.36 0 01.083.345l-.333 1.36c-.053.22-.174.267-.402.161-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.359-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146 1.124.347 2.317.535 3.554.535 6.627 0 12.017-5.373 12.017-12.001C24.034 5.367 18.644 0 12.017 0z\",\n },\n reddit: {\n color: \"#FF4500\",\n path: \"M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z\",\n },\n github: {\n color: \"#181717\",\n path: \"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\",\n },\n dribbble: {\n color: \"#EA4C89\",\n path: \"M12 24C5.385 24 0 18.615 0 12S5.385 0 12 0s12 5.385 12 12-5.385 12-12 12zm10.12-10.358c-.35-.11-3.17-.953-6.384-.438 1.34 3.684 1.887 6.684 1.992 7.308 2.3-1.555 3.936-4.02 4.392-6.87zm-6.115 7.808c-.153-.9-.75-4.032-2.19-7.77l-.066.02c-5.79 2.015-7.86 6.025-8.04 6.4 1.73 1.358 3.92 2.166 6.29 2.166 1.42 0 2.77-.29 4-.814zm-11.62-2.58c.232-.4 3.045-5.055 8.332-6.765.135-.045.27-.084.405-.12-.26-.585-.54-1.167-.832-1.74C7.17 11.775 2.206 11.71 1.756 11.7l-.004.312c0 2.633.998 5.037 2.634 6.855zm-2.42-8.955c.46.008 4.683.026 9.477-1.248-1.698-3.018-3.53-5.558-3.8-5.928-2.868 1.35-5.01 3.99-5.676 7.17zM9.6 2.052c.282.38 2.145 2.914 3.822 6 3.645-1.365 5.19-3.44 5.373-3.702-1.81-1.61-4.19-2.586-6.795-2.586-.825 0-1.63.1-2.4.285zm10.335 3.483c-.218.29-1.935 2.493-5.724 4.04.24.49.47.985.68 1.486.08.18.15.36.22.53 3.41-.43 6.8.26 7.14.33-.02-2.42-.88-4.64-2.31-6.38z\",\n },\n behance: {\n color: \"#1769FF\",\n path: \"M22 7h-7V5h7v2zm1.726 10c-.442 1.297-2.029 3-5.101 3-3.074 0-5.564-1.729-5.564-5.675 0-3.91 2.325-5.92 5.466-5.92 3.082 0 4.964 1.782 5.375 4.426.078.506.109 1.188.095 2.14H15.97c.13 3.211 3.483 3.312 4.588 2.029h3.168zm-7.686-4h4.965c-.105-1.547-1.136-2.219-2.477-2.219-1.466 0-2.277.768-2.488 2.219zm-9.574 6.988H0V5.021h6.953c5.476.081 5.58 5.444 2.72 6.906 3.461 1.26 3.577 8.061-3.207 8.061zM3 11h3.584c2.508 0 2.906-3-.312-3H3v3zm3.391 3H3v3.016h3.341c3.055 0 2.868-3.016.05-3.016z\",\n },\n};\n","import type {\n Block,\n ButtonBlock,\n CountdownBlock,\n CustomBlock,\n DividerBlock,\n HtmlBlock,\n ImageBlock,\n MenuBlock,\n ParagraphBlock,\n SectionBlock,\n SlotBlock,\n SocialIconsBlock,\n SpacerBlock,\n TableBlock,\n TitleBlock,\n VideoBlock,\n WrapperBlock,\n} from \"./blocks\";\n\nexport function isSection(block: Block): block is SectionBlock {\n return block.type === \"section\";\n}\n\nexport function isTitle(block: Block): block is TitleBlock {\n return block.type === \"title\";\n}\n\nexport function isParagraph(block: Block): block is ParagraphBlock {\n return block.type === \"paragraph\";\n}\n\nexport function isImage(block: Block): block is ImageBlock {\n return block.type === \"image\";\n}\n\nexport function isButton(block: Block): block is ButtonBlock {\n return block.type === \"button\";\n}\n\nexport function isDivider(block: Block): block is DividerBlock {\n return block.type === \"divider\";\n}\n\nexport function isVideo(block: Block): block is VideoBlock {\n return block.type === \"video\";\n}\n\nexport function isSocialIcons(block: Block): block is SocialIconsBlock {\n return block.type === \"social\";\n}\n\nexport function isSpacer(block: Block): block is SpacerBlock {\n return block.type === \"spacer\";\n}\n\nexport function isHtml(block: Block): block is HtmlBlock {\n return block.type === \"html\";\n}\n\nexport function isMenu(block: Block): block is MenuBlock {\n return block.type === \"menu\";\n}\n\nexport function isTable(block: Block): block is TableBlock {\n return block.type === \"table\";\n}\n\nexport function isCountdown(block: Block): block is CountdownBlock {\n return block.type === \"countdown\";\n}\n\nexport function isCustomBlock(block: Block): block is CustomBlock {\n return block.type === \"custom\";\n}\n\nexport function isSlot(block: Block): block is SlotBlock {\n return block.type === \"slot\";\n}\n\nexport function isWrapper(block: Block): block is WrapperBlock {\n return block.type === \"wrapper\";\n}\n","import type {\n ButtonBlock,\n CountdownBlock,\n DividerBlock,\n HtmlBlock,\n ImageBlock,\n MenuBlock,\n ParagraphBlock,\n SectionBlock,\n SocialIconsBlock,\n SpacerBlock,\n TableBlock,\n TitleBlock,\n VideoBlock,\n} from \"./blocks\";\nimport type { TemplateSettings } from \"./template\";\n\ntype BlockDefaultsFor<T> = Partial<Omit<T, \"id\" | \"type\">>;\n\nexport interface BlockDefaults {\n title?: BlockDefaultsFor<TitleBlock>;\n paragraph?: BlockDefaultsFor<ParagraphBlock>;\n image?: BlockDefaultsFor<ImageBlock>;\n button?: BlockDefaultsFor<ButtonBlock>;\n divider?: BlockDefaultsFor<DividerBlock>;\n section?: BlockDefaultsFor<SectionBlock>;\n video?: BlockDefaultsFor<VideoBlock>;\n social?: BlockDefaultsFor<SocialIconsBlock>;\n spacer?: BlockDefaultsFor<SpacerBlock>;\n html?: BlockDefaultsFor<HtmlBlock>;\n menu?: BlockDefaultsFor<MenuBlock>;\n table?: BlockDefaultsFor<TableBlock>;\n countdown?: BlockDefaultsFor<CountdownBlock>;\n}\n\nexport type TemplateDefaults = Partial<TemplateSettings>;\n\n// ---------------------------------------------------------------------------\n// Built-in default values — single source of truth for factories & consumers\n// ---------------------------------------------------------------------------\n\n// `color` is intentionally omitted: a new Title inherits the document\n// `textColor` (see `TemplateSettings`) unless the user sets a per-block color.\nexport const TITLE_BLOCK_DEFAULTS: BlockDefaultsFor<TitleBlock> = {\n content: \"<p>Enter your title</p>\",\n level: 2,\n textAlign: \"left\",\n};\n\nexport const PARAGRAPH_BLOCK_DEFAULTS: BlockDefaultsFor<ParagraphBlock> = {\n content: \"<p>Enter your text here</p>\",\n};\n\nexport const IMAGE_BLOCK_DEFAULTS: BlockDefaultsFor<ImageBlock> = {\n src: \"\",\n alt: \"\",\n width: \"full\",\n align: \"center\",\n};\n\nexport const BUTTON_BLOCK_DEFAULTS: BlockDefaultsFor<ButtonBlock> = {\n text: \"Click Here\",\n url: \"\",\n backgroundColor: \"#333333\",\n textColor: \"#ffffff\",\n borderRadius: 6,\n fontSize: 15,\n buttonPadding: { top: 12, right: 24, bottom: 12, left: 24 },\n align: \"center\",\n};\n\nexport const DIVIDER_BLOCK_DEFAULTS: BlockDefaultsFor<DividerBlock> = {\n lineStyle: \"solid\",\n color: \"#e0e0e0\",\n thickness: 1,\n width: \"full\",\n};\n\nexport const SECTION_BLOCK_DEFAULTS: BlockDefaultsFor<SectionBlock> = {\n columns: \"1\",\n};\n\nexport const VIDEO_BLOCK_DEFAULTS: BlockDefaultsFor<VideoBlock> = {\n url: \"\",\n thumbnailUrl: \"\",\n alt: \"Video\",\n width: \"full\",\n align: \"center\",\n};\n\nexport const SOCIAL_ICONS_BLOCK_DEFAULTS: BlockDefaultsFor<SocialIconsBlock> = {\n iconStyle: \"solid\",\n iconSize: \"medium\",\n spacing: 10,\n align: \"center\",\n};\n\nexport const SPACER_BLOCK_DEFAULTS: BlockDefaultsFor<SpacerBlock> = {\n height: 24,\n};\n\nexport const HTML_BLOCK_DEFAULTS: BlockDefaultsFor<HtmlBlock> = {\n content: \"\",\n};\n\n// `color` is intentionally omitted: a new Menu inherits the document\n// `textColor` unless the user sets a per-block color (or per-item `linkColor`).\nexport const MENU_BLOCK_DEFAULTS: BlockDefaultsFor<MenuBlock> = {\n fontSize: 15,\n textAlign: \"center\",\n separator: \"|\",\n separatorColor: \"#e0e0e0\",\n spacing: 10,\n};\n\n// `color` is intentionally omitted: a new Table inherits the document\n// `textColor` unless the user sets a per-block color.\nexport const TABLE_BLOCK_DEFAULTS: BlockDefaultsFor<TableBlock> = {\n hasHeaderRow: true,\n borderColor: \"#e0e0e0\",\n borderWidth: 1,\n cellPadding: 8,\n fontSize: 15,\n textAlign: \"left\",\n};\n\nexport const COUNTDOWN_BLOCK_DEFAULTS: BlockDefaultsFor<CountdownBlock> = {\n targetDate: \"\",\n timezone: \"UTC\",\n showDays: true,\n showHours: true,\n showMinutes: true,\n showSeconds: true,\n separator: \":\",\n digitFontSize: 32,\n digitColor: \"#1a1a1a\",\n labelColor: \"#6b7280\",\n labelFontSize: 12,\n backgroundColor: \"#ffffff\",\n labelDays: \"Days\",\n labelHours: \"Hours\",\n labelMinutes: \"Minutes\",\n labelSeconds: \"Seconds\",\n expiredMessage: \"This offer has expired\",\n expiredImageUrl: \"\",\n hideOnExpiry: false,\n};\n\nexport const DEFAULT_BLOCK_DEFAULTS: Required<BlockDefaults> = {\n title: TITLE_BLOCK_DEFAULTS,\n paragraph: PARAGRAPH_BLOCK_DEFAULTS,\n image: IMAGE_BLOCK_DEFAULTS,\n button: BUTTON_BLOCK_DEFAULTS,\n divider: DIVIDER_BLOCK_DEFAULTS,\n section: SECTION_BLOCK_DEFAULTS,\n video: VIDEO_BLOCK_DEFAULTS,\n social: SOCIAL_ICONS_BLOCK_DEFAULTS,\n spacer: SPACER_BLOCK_DEFAULTS,\n html: HTML_BLOCK_DEFAULTS,\n menu: MENU_BLOCK_DEFAULTS,\n table: TABLE_BLOCK_DEFAULTS,\n countdown: COUNTDOWN_BLOCK_DEFAULTS,\n};\n\nexport const DEFAULT_TEMPLATE_DEFAULTS: TemplateDefaults = {\n width: 600,\n backgroundColor: \"#ffffff\",\n textColor: \"#1a1a1a\",\n linkUnderline: true,\n fontFamily: \"Arial\",\n locale: \"en\",\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nexport function deepMergeDefaults<T extends object>(\n base: T,\n overrides: Partial<T>,\n): T {\n const result = { ...base };\n\n for (const key of Object.keys(overrides) as Array<keyof T>) {\n const baseVal = base[key];\n const overrideVal = overrides[key];\n\n if (overrideVal === undefined) {\n continue;\n }\n\n if (isPlainObject(baseVal) && isPlainObject(overrideVal)) {\n result[key] = deepMergeDefaults(\n baseVal,\n overrideVal as Partial<typeof baseVal>,\n ) as T[keyof T];\n } else {\n result[key] = overrideVal as T[keyof T];\n }\n }\n\n return result;\n}\n","import type { Block } from \"./blocks\";\nimport { DEFAULT_TEMPLATE_DEFAULTS } from \"./defaults\";\nimport type { TemplateDefaults } from \"./defaults\";\nimport type { ContentDirection } from \"./direction\";\n\nexport interface TemplateSettings {\n width: number;\n backgroundColor: string;\n /**\n * Document-level default text color: the `<mj-text>` default in the rendered\n * MJML, inherited by every text block (Title, Paragraph, Menu, Table) that\n * doesn't set its own `color`. Required, defaulting to `#1a1a1a` (see\n * `DEFAULT_TEMPLATE_DEFAULTS`); customize the default per-consumer via\n * `templateDefaults`. A block's explicit `color` or an inline text-color\n * mark overrides it.\n */\n textColor: string;\n /**\n * Document-level link color: emitted as the global `a { color }` rule in the\n * rendered MJML, so it cascades to every link — rich-text and menu alike.\n * Optional: when unset, links inherit the surrounding text color\n * (`color: inherit`), preserving the pre-#352 default. A per-block or\n * per-item color (a Menu item's `color`, `MenuBlock.linkColor`) still\n * overrides it.\n */\n linkColor?: string;\n /**\n * Whether links are underlined document-wide: drives the global\n * `a { text-decoration }` rule (`underline` when true, `none` when false).\n * Required, defaulting to `true` (see `DEFAULT_TEMPLATE_DEFAULTS`) — the\n * common, more accessible email default. Applies to body (rich-text) links;\n * buttons and menu items carry their own inline `text-decoration` and are\n * unaffected. Set `false` to render links without an underline.\n */\n linkUnderline: boolean;\n fontFamily: string;\n preheaderText?: string;\n /**\n * BCP-47 language code for the rendered email's `<html lang>`. Drives\n * screen-reader pronunciation. Default `'en'` via `DEFAULT_TEMPLATE_DEFAULTS`.\n */\n locale: string;\n /**\n * Writing direction of the delivered email: the canvas `dir` and the\n * rendered `<mjml dir>`. Independent of the editor chrome\n * (`init({ locale })`). Optional: when unset, `resolveContentDirection`\n * falls through to the content language (`ar` / `he` / `fa` / … → `\"rtl\"`,\n * otherwise `\"ltr\"`). An explicit `\"ltr\"` on an Arabic template is a\n * stated decision, not a missing value.\n */\n direction?: ContentDirection;\n}\n\nexport interface TemplateContent {\n blocks: Block[];\n settings: TemplateSettings;\n}\n\nexport function createDefaultTemplateContent(\n defaultFontFamily = \"Arial\",\n templateDefaults?: TemplateDefaults,\n): TemplateContent {\n return {\n blocks: [],\n settings: {\n ...DEFAULT_TEMPLATE_DEFAULTS,\n fontFamily: defaultFontFamily,\n ...templateDefaults,\n } as TemplateSettings,\n };\n}\n","/**\n * Writing direction of the delivered email — the canvas `dir` and the\n * rendered `<mjml dir>`. Independent of the editor chrome language\n * (`init({ locale })`).\n */\nexport type ContentDirection = \"ltr\" | \"rtl\";\n\n/**\n * Primary BCP-47 subtags whose default writing direction is right-to-left.\n * Region tags (`ar-SA`) resolve through the primary subtag. `\"iw\"` is the\n * legacy Hebrew tag. Not a CLDR dump — extend the list when a script is\n * needed; do not infer from `lang` at the call site.\n */\nexport const RTL_LANGUAGE_PRIMARY_SUBTAGS: readonly string[] = [\n \"ar\",\n \"he\",\n \"iw\",\n \"fa\",\n \"ur\",\n \"yi\",\n \"dv\",\n \"ps\",\n \"sd\",\n \"ug\",\n \"ckb\",\n \"ks\",\n];\n\n/**\n * Whether a BCP-47 (or underscore-separated) language tag is an RTL language\n * by primary subtag. Missing, empty, and unknown tags are not RTL.\n */\nexport function isRtlLanguageTag(tag: string | undefined): boolean {\n const primary = tag?.trim().replace(/_/g, \"-\").split(\"-\")[0]?.toLowerCase();\n return !!primary && RTL_LANGUAGE_PRIMARY_SUBTAGS.includes(primary);\n}\n\n/**\n * The email's writing direction. An explicit `settings.direction` of `\"ltr\"`\n * or `\"rtl\"` wins; anything else (unset, or a garbage JS value) falls through\n * to the content language, then to `\"ltr\"`.\n *\n * This is the single reader — renderer, canvas, and settings UI all go\n * through it, so a later per-block override can wrap it without forking the\n * locale table.\n */\nexport function resolveContentDirection(settings: {\n locale: string;\n direction?: ContentDirection;\n}): ContentDirection {\n if (settings.direction === \"ltr\" || settings.direction === \"rtl\") {\n return settings.direction;\n }\n return isRtlLanguageTag(settings.locale) ? \"rtl\" : \"ltr\";\n}\n","import type {\n Block,\n BlockStyles,\n BlockType,\n ButtonBlock,\n CountdownBlock,\n CustomBlock,\n DividerBlock,\n HtmlBlock,\n ImageBlock,\n MenuBlock,\n ParagraphBlock,\n SectionBlock,\n SlotBlock,\n SocialIconsBlock,\n SpacerBlock,\n SpacingValue,\n TableBlock,\n TableCellData,\n TableRowData,\n TitleBlock,\n VideoBlock,\n WrapperBlock,\n} from \"./blocks\";\nimport type { CustomBlockDefinition, CustomBlockField } from \"./custom-blocks\";\nimport type { BlockDefaults } from \"./defaults\";\nimport {\n BUTTON_BLOCK_DEFAULTS,\n COUNTDOWN_BLOCK_DEFAULTS,\n deepMergeDefaults,\n DIVIDER_BLOCK_DEFAULTS,\n HTML_BLOCK_DEFAULTS,\n IMAGE_BLOCK_DEFAULTS,\n MENU_BLOCK_DEFAULTS,\n PARAGRAPH_BLOCK_DEFAULTS,\n SECTION_BLOCK_DEFAULTS,\n SOCIAL_ICONS_BLOCK_DEFAULTS,\n SPACER_BLOCK_DEFAULTS,\n TABLE_BLOCK_DEFAULTS,\n TITLE_BLOCK_DEFAULTS,\n VIDEO_BLOCK_DEFAULTS,\n} from \"./defaults\";\n\nfunction applyDefaults<T extends object>(\n base: T,\n partial: Partial<T> | undefined,\n): T {\n if (!partial || Object.keys(partial).length === 0) return base;\n return deepMergeDefaults(base, partial);\n}\n\nexport function generateId(): string {\n return crypto.randomUUID();\n}\n\nfunction createDefaultSpacing(value = 0): SpacingValue {\n return { top: value, right: value, bottom: value, left: value };\n}\n\nfunction createDefaultStyles(padding = 10): BlockStyles {\n return {\n padding: createDefaultSpacing(padding),\n };\n}\n\nexport function createTitleBlock(\n partial: Partial<TitleBlock> = {},\n): TitleBlock {\n const base: TitleBlock = {\n id: generateId(),\n type: \"title\",\n ...TITLE_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as TitleBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createParagraphBlock(\n partial: Partial<ParagraphBlock> = {},\n): ParagraphBlock {\n const base: ParagraphBlock = {\n id: generateId(),\n type: \"paragraph\",\n ...PARAGRAPH_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as ParagraphBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createImageBlock(\n partial: Partial<ImageBlock> = {},\n): ImageBlock {\n const base: ImageBlock = {\n id: generateId(),\n type: \"image\",\n ...IMAGE_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as ImageBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createButtonBlock(\n partial: Partial<ButtonBlock> = {},\n): ButtonBlock {\n const base: ButtonBlock = {\n id: generateId(),\n type: \"button\",\n ...BUTTON_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as ButtonBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createDividerBlock(\n partial: Partial<DividerBlock> = {},\n): DividerBlock {\n const base: DividerBlock = {\n id: generateId(),\n type: \"divider\",\n ...DIVIDER_BLOCK_DEFAULTS,\n styles: createDefaultStyles(20),\n } as DividerBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createSectionBlock(\n partial: Partial<SectionBlock> = {},\n): SectionBlock {\n const base: SectionBlock = {\n id: generateId(),\n type: \"section\",\n ...SECTION_BLOCK_DEFAULTS,\n children: [[]],\n styles: createDefaultStyles(20),\n } as SectionBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createVideoBlock(\n partial: Partial<VideoBlock> = {},\n): VideoBlock {\n const base: VideoBlock = {\n id: generateId(),\n type: \"video\",\n ...VIDEO_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as VideoBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createSocialIconsBlock(\n partial: Partial<SocialIconsBlock> = {},\n): SocialIconsBlock {\n const base: SocialIconsBlock = {\n id: generateId(),\n type: \"social\",\n icons: [],\n ...SOCIAL_ICONS_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as SocialIconsBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createSpacerBlock(\n partial: Partial<SpacerBlock> = {},\n): SpacerBlock {\n const base: SpacerBlock = {\n id: generateId(),\n type: \"spacer\",\n ...SPACER_BLOCK_DEFAULTS,\n styles: createDefaultStyles(0),\n } as SpacerBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createHtmlBlock(partial: Partial<HtmlBlock> = {}): HtmlBlock {\n const base: HtmlBlock = {\n id: generateId(),\n type: \"html\",\n ...HTML_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as HtmlBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createMenuBlock(partial: Partial<MenuBlock> = {}): MenuBlock {\n const base: MenuBlock = {\n id: generateId(),\n type: \"menu\",\n items: [],\n ...MENU_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as MenuBlock;\n return applyDefaults(base, partial);\n}\n\nfunction createDefaultTableRows(columns: number, rows: number): TableRowData[] {\n return Array.from({ length: rows }, () => ({\n id: generateId(),\n cells: Array.from({ length: columns }, (): TableCellData => ({\n id: generateId(),\n content: \"\",\n })),\n }));\n}\n\nexport function createTableBlock(\n partial: Partial<TableBlock> = {},\n): TableBlock {\n const base: TableBlock = {\n id: generateId(),\n type: \"table\",\n rows: createDefaultTableRows(3, 3),\n ...TABLE_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as TableBlock;\n return applyDefaults(base, partial);\n}\n\nexport function createCountdownBlock(\n partial: Partial<CountdownBlock> = {},\n): CountdownBlock {\n const base: CountdownBlock = {\n id: generateId(),\n type: \"countdown\",\n ...COUNTDOWN_BLOCK_DEFAULTS,\n styles: createDefaultStyles(),\n } as CountdownBlock;\n return applyDefaults(base, partial);\n}\n\nfunction getFieldDefault(field: CustomBlockField): unknown {\n if (field.type === \"repeatable\") {\n return field.default ?? [];\n }\n if (field.type === \"boolean\") {\n return field.default ?? false;\n }\n if (field.type === \"number\") {\n return field.default ?? 0;\n }\n\n return field.default ?? \"\";\n}\n\nexport function createCustomBlock(\n definition: CustomBlockDefinition,\n): CustomBlock {\n const fieldValues: Record<string, unknown> = {};\n\n for (const field of definition.fields) {\n fieldValues[field.key] = getFieldDefault(field);\n }\n\n const styles = applyDefaults(createDefaultStyles(), definition.defaultStyles);\n\n return {\n id: generateId(),\n type: \"custom\",\n customType: definition.type,\n fieldValues,\n styles,\n ...(definition.dataSource ? { dataSourceFetched: false } : {}),\n };\n}\n\n/** Layout-only. Use this to build a layout; createBlock(\"slot\") throws. */\nexport function createSlotBlock(): SlotBlock {\n return {\n id: generateId(),\n type: \"slot\",\n styles: createDefaultStyles(0),\n };\n}\n\n/** Layout-only. Use this to build a layout; createBlock(\"wrapper\") throws. */\nexport function createWrapperBlock(\n partial: Partial<WrapperBlock> = {},\n): WrapperBlock {\n const base: WrapperBlock = {\n id: generateId(),\n type: \"wrapper\",\n children: [],\n styles: createDefaultStyles(0),\n };\n return applyDefaults(base, partial);\n}\n\nexport function createBlock(\n type: BlockType,\n blockDefaults?: BlockDefaults,\n): Block {\n switch (type) {\n case \"section\":\n return createSectionBlock(blockDefaults?.section);\n case \"title\":\n return createTitleBlock(blockDefaults?.title);\n case \"paragraph\":\n return createParagraphBlock(blockDefaults?.paragraph);\n case \"image\":\n return createImageBlock(blockDefaults?.image);\n case \"button\":\n return createButtonBlock(blockDefaults?.button);\n case \"divider\":\n return createDividerBlock(blockDefaults?.divider);\n case \"video\":\n return createVideoBlock(blockDefaults?.video);\n case \"social\":\n return createSocialIconsBlock(blockDefaults?.social);\n case \"spacer\":\n return createSpacerBlock(blockDefaults?.spacer);\n case \"html\":\n return createHtmlBlock(blockDefaults?.html);\n case \"menu\":\n return createMenuBlock(blockDefaults?.menu);\n case \"table\":\n return createTableBlock(blockDefaults?.table);\n case \"countdown\":\n return createCountdownBlock(blockDefaults?.countdown);\n case \"slot\":\n throw new Error(\n \"[Templatical] slot cannot be inserted into content. Use createSlotBlock() to build a layout.\",\n );\n case \"wrapper\":\n throw new Error(\n \"[Templatical] wrapper cannot be inserted into content. Use createWrapperBlock() to build a layout.\",\n );\n default:\n throw new Error(`Unknown block type: ${type}`);\n }\n}\n\nexport function cloneBlock(block: Block): Block {\n const cloned = JSON.parse(JSON.stringify(block)) as Block;\n cloned.id = generateId();\n\n if (cloned.type === \"section\") {\n cloned.children = cloned.children.map((column) =>\n column.map((child) => cloneBlock(child)),\n );\n }\n\n if (cloned.type === \"wrapper\") {\n cloned.children = cloned.children.map((c) => cloneBlock(c));\n }\n\n return cloned;\n}\n","/**\n * Cycle-safe deep clone via a JSON round-trip.\n *\n * A naked `JSON.stringify` throws `Converting circular structure to JSON`\n * if the tree is self-referencing — e.g. a DOM element carrying a Sortable\n * expando back-ref (`HTMLDivElement.SortableXXX -> instance -> el -> div`)\n * leaks into block data through a drag handler inside a section. Both the\n * editor's public `getContent()` export path and the history snapshot path\n * must tolerate that: we drop the offending back-ref from the clone rather\n * than throw. Losing a transient DOM expando is harmless; the block data is\n * intact.\n *\n * The `WeakSet` replacer omits any object already seen on the current path,\n * which covers every cyclic shape. Template content is tree-shaped (and is\n * serialized to JSON for storage anyway), so dropping repeated references\n * never costs real data.\n */\nexport function safeClone<T>(value: T): T {\n const seen = new WeakSet<object>();\n return JSON.parse(\n JSON.stringify(value, (_key, val) => {\n if (typeof val === \"object\" && val !== null) {\n if (seen.has(val)) return undefined;\n seen.add(val);\n }\n return val;\n }),\n ) as T;\n}\n","import type { Block, WrapperBlock } from \"./blocks\";\nimport { safeClone } from \"./clone\";\nimport { cloneBlock } from \"./factory\";\nimport { isSection, isSlot, isWrapper } from \"./guards\";\nimport type { TemplateContent } from \"./template\";\n\nconst EXACTLY_ONE_SLOT =\n \"[Templatical] layout: must contain exactly one slot block\";\nconst SLOT_NESTED_IN_SECTION =\n \"[Templatical] layout: slot must be a top-level or wrapper child, not nested in a section\";\nconst WRAPPER_IN_WRAPPER =\n \"[Templatical] layout: a wrapper cannot contain a wrapper\";\nconst NESTED_MJ_WRAPPER =\n \"[Templatical] layout: a wrapper around the slot cannot contain blocks that emit mj-wrapper (section.wrapper)\";\nconst SLOT_IN_CONTENT = \"[Templatical] slot is not a valid content block\";\nconst WRAPPER_IN_CONTENT = \"[Templatical] wrapper is not a valid content block\";\n\nfunction walkBlocks(\n blocks: Block[],\n visit: (block: Block, parent: Block | null, insideSection: boolean) => void,\n parent: Block | null = null,\n insideSection = false,\n): void {\n for (const block of blocks) {\n visit(block, parent, insideSection);\n if (isSection(block)) {\n for (const column of block.children) {\n walkBlocks(column, visit, block, true);\n }\n } else if (isWrapper(block)) {\n walkBlocks(block.children, visit, block, insideSection);\n }\n }\n}\n\n/** Throw if `layout` does not contain exactly one legal slot. */\nexport function validateLayout(layout: TemplateContent): void {\n let slotCount = 0;\n walkBlocks(layout.blocks, (block, _parent, insideSection) => {\n if (isSlot(block)) {\n slotCount += 1;\n if (insideSection) {\n throw new Error(SLOT_NESTED_IN_SECTION);\n }\n }\n if (isWrapper(block)) {\n if (insideSection) {\n throw new Error(SLOT_NESTED_IN_SECTION);\n }\n if (block.children.some(isWrapper)) {\n throw new Error(WRAPPER_IN_WRAPPER);\n }\n }\n });\n if (slotCount !== 1) {\n throw new Error(EXACTLY_ONE_SLOT);\n }\n}\n\nexport function assertNoSlotInContent(content: TemplateContent): void {\n walkBlocks(content.blocks, (block) => {\n if (isSlot(block)) {\n throw new Error(SLOT_IN_CONTENT);\n }\n });\n}\n\nexport function assertNoWrapperInContent(content: TemplateContent): void {\n walkBlocks(content.blocks, (block) => {\n if (isWrapper(block)) {\n throw new Error(WRAPPER_IN_CONTENT);\n }\n });\n}\n\n/** True iff the one slot is a direct child of a wrapper (the card). */\nexport function layoutWrapsSlot(layout: TemplateContent): boolean {\n let wrapped = false;\n walkBlocks(layout.blocks, (block, parent) => {\n if (isSlot(block) && parent !== null && isWrapper(parent)) {\n wrapped = true;\n }\n });\n return wrapped;\n}\n\nfunction cloneLayoutBlock(block: Block): Block {\n if (isSlot(block)) return block;\n if (isWrapper(block)) {\n const cloned = cloneBlock({ ...block, children: [] }) as WrapperBlock;\n cloned.children = block.children.map(cloneLayoutBlock);\n return cloned;\n }\n return cloneBlock(block);\n}\n\nfunction findSlotLocation(\n blocks: Block[],\n): { parent: Block[]; index: number } | null {\n for (let i = 0; i < blocks.length; i++) {\n const block = blocks[i];\n if (isSlot(block)) {\n return { parent: blocks, index: i };\n }\n if (isWrapper(block)) {\n const nested = findSlotLocation(block.children);\n if (nested) return nested;\n }\n }\n return null;\n}\n\nfunction emitsMjWrapper(blocks: Block[]): boolean {\n for (const block of blocks) {\n if (isSection(block)) {\n if (block.wrapper) return true;\n for (const column of block.children) {\n if (emitsMjWrapper(column)) return true;\n }\n }\n }\n return false;\n}\n\n/**\n * Overlay `layout` around `content`. Clones both; remints layout ids.\n * Layout wins only `settings.backgroundColor`.\n */\nexport function applyLayout(\n layout: TemplateContent,\n content: TemplateContent,\n): TemplateContent {\n validateLayout(layout);\n assertNoSlotInContent(content);\n assertNoWrapperInContent(content);\n\n if (layoutWrapsSlot(layout) && emitsMjWrapper(content.blocks)) {\n throw new Error(NESTED_MJ_WRAPPER);\n }\n\n const blocks = layout.blocks.map(cloneLayoutBlock);\n const location = findSlotLocation(blocks);\n if (!location) {\n throw new Error(EXACTLY_ONE_SLOT);\n }\n location.parent.splice(location.index, 1, ...safeClone(content.blocks));\n\n return {\n blocks,\n settings: {\n ...safeClone(content.settings),\n backgroundColor: layout.settings.backgroundColor,\n },\n };\n}\n","/**\n * Minimal, allocation-free primitives for reading an HTML open tag out of a\n * markup string. They exist because merge-tag markup is rewritten from a raw\n * string in two packages — `@templatical/types` (label / sample resolution for\n * the previews) and `@templatical/renderer` (converting spans back to tokens on\n * export) — and both need the same two answers: where does this open tag end,\n * and what is the value of one of its attributes.\n *\n * Both are hand-written character scans rather than regexes. A regex over an\n * attribute string with no closing quote backtracks across the whole input,\n * which is the ReDoS class the span scanners were rewritten to avoid; a scan\n * that only moves forward cannot.\n */\n\nconst QUOTES = new Set(['\"', \"'\"]);\n\n/**\n * Index of the `>` that closes the open tag whose name ends at `from`, or `-1`\n * when the tag never closes.\n *\n * Quote-aware: a `>` inside a quoted attribute value does not end the tag.\n * That matters because a consumer may configure a merge-tag syntax whose tag\n * values contain `<` / `>` — Smarty-style `<% $email %>` — and HTML attribute\n * serialization escapes only `&`, `\"` and U+00A0, so those characters reach the\n * markup literally. A plain `indexOf(\">\")` stops mid-attribute there and every\n * caller downstream sees a truncated attribute string.\n *\n * An unterminated quote yields `-1` rather than a guessed tag end: callers\n * treat that as \"not markup I can rewrite\" and emit the input untouched, which\n * is the safe answer for malformed HTML.\n */\nexport function findOpenTagEnd(html: string, from: number): number {\n let quote: string | null = null;\n for (let i = from; i < html.length; i++) {\n const char = html[i];\n if (quote !== null) {\n if (char === quote) quote = null;\n continue;\n }\n if (QUOTES.has(char)) {\n quote = char;\n continue;\n }\n if (char === \">\") return i;\n }\n return -1;\n}\n\nfunction isAttrNameChar(char: string): boolean {\n return (\n char !== \" \" &&\n char !== \"\\t\" &&\n char !== \"\\n\" &&\n char !== \"\\r\" &&\n char !== \"\\f\" &&\n char !== \"=\" &&\n char !== \">\" &&\n char !== \"/\"\n );\n}\n\nfunction isWhitespace(char: string): boolean {\n return (\n char === \" \" ||\n char === \"\\t\" ||\n char === \"\\n\" ||\n char === \"\\r\" ||\n char === \"\\f\"\n );\n}\n\nconst NAMED_ENTITIES: Record<string, string> = {\n amp: \"&\",\n lt: \"<\",\n gt: \">\",\n quot: '\"',\n apos: \"'\",\n nbsp: \" \",\n};\n\n/**\n * Decode the character references an HTML serializer writes into an attribute\n * value, so callers get the characters the author wrote.\n *\n * Deliberately small: the named set a serializer actually emits, plus numeric\n * references. An unknown or malformed reference is left as literal text, which\n * is what a browser does. Single-pass — `&lt;` decodes to the text `<`\n * and stops, never to `<`, so an escaped entity inside a consumer's tag value\n * survives as itself.\n */\nfunction decodeAttrEntities(value: string): string {\n if (!value.includes(\"&\")) return value;\n return value.replace(\n /&(#[0-9]+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/g,\n (match, ref: string) => {\n if (ref[0] === \"#\") {\n const code =\n ref[1] === \"x\" || ref[1] === \"X\"\n ? Number.parseInt(ref.slice(2), 16)\n : Number.parseInt(ref.slice(1), 10);\n // Surrogates and out-of-range code points would throw; leave them be.\n if (!Number.isFinite(code) || code < 1 || code > 0x10ffff) return match;\n if (code >= 0xd800 && code <= 0xdfff) return match;\n return String.fromCodePoint(code);\n }\n return NAMED_ENTITIES[ref.toLowerCase()] ?? match;\n },\n );\n}\n\n/**\n * The value of the `name` attribute within an open tag's attribute string (the\n * text between the tag name and its closing `>`), or `null` when the attribute\n * is absent or its quoted value is never closed.\n *\n * Handles double-quoted, single-quoted and unquoted values, and matches the\n * attribute name case-insensitively, as HTML does. The value is\n * entity-decoded, because that is what the attribute means: the editor\n * serializes a tag value of `<% $email %>` as\n * `data-merge-tag=\"<% $email %>\"`, and every caller compares the result\n * against a configured merge-tag token written in raw characters.\n */\nexport function getTagAttrValue(attrs: string, name: string): string | null {\n const target = name.toLowerCase();\n let i = 0;\n\n while (i < attrs.length) {\n while (i < attrs.length && (isWhitespace(attrs[i]) || attrs[i] === \"/\")) {\n i++;\n }\n if (i >= attrs.length) break;\n\n const nameStart = i;\n while (i < attrs.length && isAttrNameChar(attrs[i])) i++;\n const attrName = attrs.substring(nameStart, i).toLowerCase();\n if (attrName === \"\") {\n // Not a name character and not whitespace — e.g. a stray `=`. Step over\n // it so the scan always advances.\n i++;\n continue;\n }\n\n while (i < attrs.length && isWhitespace(attrs[i])) i++;\n if (attrs[i] !== \"=\") {\n // A boolean attribute (`hidden`); the cursor already sits on the next\n // attribute name, so don't consume anything here.\n continue;\n }\n i++; // past `=`\n while (i < attrs.length && isWhitespace(attrs[i])) i++;\n\n const quote = attrs[i];\n if (QUOTES.has(quote)) {\n const valueStart = i + 1;\n const valueEnd = attrs.indexOf(quote, valueStart);\n if (valueEnd === -1) return null; // unterminated value — nothing readable follows\n if (attrName === target)\n return decodeAttrEntities(attrs.substring(valueStart, valueEnd));\n i = valueEnd + 1;\n continue;\n }\n\n const valueStart = i;\n while (i < attrs.length && !isWhitespace(attrs[i]) && attrs[i] !== \">\") i++;\n if (attrName === target)\n return decodeAttrEntities(attrs.substring(valueStart, i));\n }\n\n return null;\n}\n","import type { MergeTag } from \"./config\";\nimport { findOpenTagEnd, getTagAttrValue } from \"./html-scan\";\n\n// --- Syntax Presets ---\n\nexport interface SyntaxPreset {\n value: RegExp;\n logic: RegExp;\n}\n\nexport type SyntaxPresetName =\n \"liquid\" | \"handlebars\" | \"mailchimp\" | \"ampscript\";\n\nexport const SYNTAX_PRESETS: Record<SyntaxPresetName, SyntaxPreset> = {\n liquid: { value: /\\{\\{.+?\\}\\}/g, logic: /\\{%-?\\s*(\\w+).*?-?%\\}/g },\n handlebars: {\n value: /\\{\\{\\{?.+?\\}?\\}\\}/g,\n logic: /\\{\\{[#/](\\w+).*?\\}\\}/g,\n },\n mailchimp: { value: /\\*\\|\\w+\\|\\*/g, logic: /\\*\\|(\\w+)[:|].*?\\|\\*/g },\n ampscript: { value: /%%=.+?=%%/g, logic: /%%\\[\\s*(\\w+).*?\\]%%/g },\n};\n\nconst SYNTAX_TRIGGER_CHARS: Record<SyntaxPresetName, string> = {\n liquid: \"{{\",\n handlebars: \"{{\",\n mailchimp: \"*|\",\n ampscript: \"%%=\",\n};\n\nconst SYNTAX_CLOSING_CHARS: Record<SyntaxPresetName, string> = {\n liquid: \"}}\",\n handlebars: \"}}\",\n mailchimp: \"|*\",\n ampscript: \"=%%\",\n};\n\n/**\n * Resolves the autocomplete trigger string for a syntax preset.\n * Returns null when the syntax doesn't match any built-in preset\n * (custom regex syntax — autocomplete cannot be enabled safely).\n */\nexport function getSyntaxTriggerChar(syntax: SyntaxPreset): string | null {\n for (const name of Object.keys(SYNTAX_PRESETS) as SyntaxPresetName[]) {\n if (SYNTAX_PRESETS[name].value.source === syntax.value.source) {\n return SYNTAX_TRIGGER_CHARS[name];\n }\n }\n return null;\n}\n\n/**\n * Resolves the closing delimiter for a syntax preset (e.g. `}}` for liquid,\n * `|*` for mailchimp). The autocomplete trigger detector uses it to tell an\n * open tag (`{{first`) from a completed one (`{{first_name}}`) so the popup\n * doesn't reappear over a finished tag. Returns null for custom syntaxes —\n * the same set for which `getSyntaxTriggerChar` returns null.\n */\nexport function getSyntaxClosingChar(syntax: SyntaxPreset): string | null {\n for (const name of Object.keys(SYNTAX_PRESETS) as SyntaxPresetName[]) {\n if (SYNTAX_PRESETS[name].value.source === syntax.value.source) {\n return SYNTAX_CLOSING_CHARS[name];\n }\n }\n return null;\n}\n\nexport function resolveSyntax(\n syntax?: SyntaxPresetName | SyntaxPreset,\n): SyntaxPreset {\n if (!syntax) {\n return SYNTAX_PRESETS.liquid;\n }\n\n if (typeof syntax === \"string\") {\n return SYNTAX_PRESETS[syntax] ?? SYNTAX_PRESETS.liquid;\n }\n\n return syntax;\n}\n\n// --- Merge Tag Utilities ---\n\nfunction anchoredRegex(pattern: RegExp): RegExp {\n const source = pattern.source;\n const flags = pattern.flags.replace(\"g\", \"\");\n return new RegExp(`^${source}$`, flags);\n}\n\nexport function isMergeTagValue(value: string, syntax: SyntaxPreset): boolean {\n const trimmed = value?.trim() || \"\";\n // Handlebars (and similar) value regex is liberal enough to also match\n // logic tags like `{{#each items}}`. Exclude logic-shaped tags so callers\n // that rely on this discriminator (UI segmentation, label rendering)\n // don't misclassify them.\n if (anchoredRegex(syntax.logic).test(trimmed)) {\n return false;\n }\n return anchoredRegex(syntax.value).test(trimmed);\n}\n\nexport function getMergeTagLabel(value: string, mergeTags: MergeTag[]): string {\n const found = mergeTags.find((p) => p.value === value);\n if (found) {\n return found.label;\n }\n return value;\n}\n\nexport function resolveHtmlMergeTagLabels(\n html: string,\n mergeTags: MergeTag[],\n): string {\n return rewriteSpanByAttr(html, \"data-merge-tag\", (value) =>\n getMergeTagLabel(value, mergeTags),\n );\n}\n\n/**\n * The example value configured for `value`, or `undefined` when the tag is\n * unknown or declares none. Unlike `getMergeTagLabel`, which falls back to the\n * raw token, absence is reported as `undefined` so callers can choose their own\n * fallback — Sample mode falls back to the label, never to a raw token.\n */\nexport function getMergeTagSample(\n value: string,\n mergeTags: MergeTag[],\n): string | undefined {\n return mergeTags.find((p) => p.value === value)?.sample;\n}\n\n/**\n * Rewrite rich-text HTML for the previews' Sample mode.\n *\n * A tag **with** a sample is replaced by that value as bare text, wrapper and\n * all — dropping the `<span>` is what removes the merge-tag highlight, so the\n * value reads as ordinary content. A tag **without** one keeps its span and\n * shows its label, so it stays visibly dynamic; that difference is deliberate,\n * and it doubles as a signal that a sample is still unset.\n *\n * The unwrapped output is inert — `data-merge-tag` is gone from it — so this\n * result must only ever reach a preview surface, never `getContent()`, an\n * export or a send.\n */\nexport function substituteHtmlMergeTagSamples(\n html: string,\n mergeTags: MergeTag[],\n): string {\n return rewriteSpanByAttr(\n html,\n \"data-merge-tag\",\n (value) =>\n escapeTagText(\n getMergeTagSample(value, mergeTags) ??\n getMergeTagLabel(value, mergeTags),\n ),\n { unwrap: (value) => getMergeTagSample(value, mergeTags) !== undefined },\n );\n}\n\n/**\n * Whether any configured tag declares a `sample`.\n *\n * Gates the whole feature: with no samples anywhere the previews' Sample view\n * would be identical to the Label view, so the editor defaults to Label and\n * renders no toggle. That keeps the feature invisible until a consumer opts in.\n */\nexport function hasMergeTagSamples(mergeTags: MergeTag[]): boolean {\n return mergeTags.some((tag) => tag.sample !== undefined);\n}\n\n/**\n * Replace declared tokens with their sample values in a plain string — used for\n * values that reach no label-resolving component, namely `html` block content\n * and custom-block field values.\n *\n * Matching is on the exact configured `value`, so consumer text cannot\n * false-positive and `href=\"{{link}}\"` resolves correctly. Tags without a\n * sample are left untouched, which is what keeps a missing sample visible.\n */\nexport function substituteTextMergeTagSamples(\n text: string,\n mergeTags: MergeTag[],\n): string {\n if (!text) return text;\n\n let out = text;\n for (const tag of mergeTags) {\n if (tag.sample === undefined) continue;\n // split/join rather than a RegExp: the token is a literal, so this needs no\n // escaping of regex metacharacters (`{`, `|`, `*` all appear in real syntaxes).\n out = out.split(tag.value).join(tag.sample);\n }\n return out;\n}\n\n/**\n * Escape a sample before it is inlined into rich-text HTML. Samples are\n * consumer-authored strings, so `<`, `&` and quotes would otherwise alter the\n * surrounding markup.\n */\nfunction escapeTagText(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\nexport function containsMergeTag(value: string, syntax: SyntaxPreset): boolean {\n if (!value) return false;\n\n const valueRegex = new RegExp(syntax.value.source, syntax.value.flags);\n const logicRegex = new RegExp(syntax.logic.source, syntax.logic.flags);\n\n return valueRegex.test(value) || logicRegex.test(value);\n}\n\nexport function isLogicMergeTagValue(\n value: string,\n syntax: SyntaxPreset,\n): boolean {\n return anchoredRegex(syntax.logic).test(value?.trim() || \"\");\n}\n\nexport function getLogicMergeTagKeyword(\n value: string,\n syntax: SyntaxPreset,\n): string {\n const regex = new RegExp(\n syntax.logic.source,\n syntax.logic.flags.replace(\"g\", \"\"),\n );\n const match = value.match(regex);\n return match && match[1] ? match[1].toUpperCase() : value;\n}\n\nexport function resolveHtmlLogicMergeTagLabels(\n html: string,\n syntax: SyntaxPreset,\n): string {\n return rewriteSpanByAttr(html, \"data-logic-merge-tag\", (value) =>\n getLogicMergeTagKeyword(value, syntax),\n );\n}\n\n/**\n * Walk `html` and rewrite the inner text of every `<span … {attrName}=\"…\">…</span>`\n * by passing the attribute value through `relabel`. Linear in `html.length`:\n * each `indexOf` advances the cursor monotonically, and no regex backtracking\n * can run over the whole string.\n *\n * Replaces the original `/<span[^>]*…[^>]*>(.*?)<\\/span>/g` pattern, which\n * was polynomial-ReDoS over inputs that contained many `<span` starts with\n * no closing `>`.\n *\n * Tag boundaries and attribute values are resolved by `findOpenTagEnd` /\n * `getTagAttrValue`, which are quote-aware. A merge-tag value may itself\n * contain `<` / `>` when the consumer configures a custom syntax — Smarty-style\n * `<% $email %>` — and those characters survive attribute serialization\n * verbatim, so anything that treats the first `>` as the tag end reads a\n * truncated attribute and resolves nothing.\n */\nfunction rewriteSpanByAttr(\n html: string,\n attrName: string,\n relabel: (value: string) => string,\n options?: { unwrap?: (value: string) => boolean },\n): string {\n let out = \"\";\n let i = 0;\n while (i < html.length) {\n const open = html.indexOf(\"<span\", i);\n if (open === -1) {\n out += html.substring(i);\n break;\n }\n const afterTagName = html[open + 5];\n if (\n afterTagName !== \">\" &&\n afterTagName !== \" \" &&\n afterTagName !== \"\\t\" &&\n afterTagName !== \"\\n\" &&\n afterTagName !== \"\\r\" &&\n afterTagName !== \"/\"\n ) {\n out += html.substring(i, open + 5);\n i = open + 5;\n continue;\n }\n const openEnd = findOpenTagEnd(html, open + 5);\n if (openEnd === -1) {\n out += html.substring(i);\n break;\n }\n const closeStart = html.indexOf(\"</span>\", openEnd + 1);\n if (closeStart === -1) {\n out += html.substring(i);\n break;\n }\n const attrs = html.substring(open + 5, openEnd);\n const value = getTagAttrValue(attrs, attrName);\n if (value === null) {\n // This `<span>` isn't the one we're looking for — emit up to and\n // including the `<span` literal and let the next iteration scan\n // inward. Skipping straight to the matching `</span>` would swallow\n // any nested merge-tag span in the same loop iteration.\n out += html.substring(i, open + 5);\n i = open + 5;\n continue;\n }\n const newLabel = relabel(value);\n if (options?.unwrap?.(value)) {\n // Emit the text before the span, then the replacement alone — the open\n // and close tags are dropped, so the span's styling (the merge-tag\n // highlight) no longer applies to it. Decided per tag, so a tag that\n // resolved to a sample loses the highlight while one that fell back to\n // its label keeps it.\n out += html.substring(i, open);\n out += newLabel;\n } else {\n out += html.substring(i, openEnd + 1);\n out += newLabel;\n out += \"</span>\";\n }\n i = closeStart + 7;\n }\n return out;\n}\n","import type { TemplateContent } from \"./template\";\n\n/**\n * Context handed to `resolvePreview`.\n *\n * `recipient` is present only on surfaces that have one — the test-email\n * dialog — and absent in the editor's own preview mode. Treat its absence as\n * \"no particular recipient\", not as an error: a resolver should still return\n * something renderable, typically its own default or sample data.\n */\nexport interface PreviewResolveContext {\n /**\n * The template as it currently stands. Already a copy — mutating it has no\n * effect on the editor, and returning it unchanged is a valid no-op.\n */\n content: TemplateContent;\n /** The address the preview is being shown for, when the surface has one. */\n recipient?: string;\n}\n\n/**\n * Resolves a template for display on preview surfaces — typically substituting\n * merge tags and **evaluating logic tags** against real data.\n *\n * Logic tags are the reason this hook exists. `MergeTag.sample` already covers\n * value tags client-side, but branching (`{% if %}` … `{% endif %}`) cannot be\n * evaluated in a browser for every supported syntax — mailchimp and ampscript\n * logic are server-side dialects — so only the consumer's own backend can do it.\n *\n * Display-only. The returned content reaches preview surfaces and nothing else:\n * it is never written to the editor's state, never returned from\n * `getContent()`, never sent, and never exported. Rejecting is safe — the\n * preview falls back to the unresolved template and says so.\n */\nexport type ResolvePreview = (\n context: PreviewResolveContext,\n) => Promise<TemplateContent>;\n\n/**\n * Whether `value` is shaped enough like `TemplateContent` to render.\n *\n * A resolver is consumer code returning data that often came from an HTTP\n * response, so the declared return type guarantees nothing at runtime. A\n * mis-shaped result is treated as a resolution failure — the preview degrades\n * to the unresolved template — rather than throwing inside the render.\n */\nexport function isRenderableTemplateContent(\n value: unknown,\n): value is TemplateContent {\n if (typeof value !== \"object\" || value === null) return false;\n const candidate = value as { blocks?: unknown };\n return Array.isArray(candidate.blocks);\n}\n","import type { SyntaxPreset, SyntaxPresetName } from \"./merge-tags\";\nimport type { TemplateSettings } from \"./template\";\n\nexport type ViewportSize = \"desktop\" | \"mobile\";\n\nexport type UiTheme = \"light\" | \"dark\" | \"auto\";\n\nexport interface CustomFont {\n name: string;\n url: string;\n fallback?: string;\n}\n\nexport interface FontsConfig {\n defaultFallback?: string;\n defaultFont?: string;\n customFonts?: CustomFont[];\n /**\n * Restrict which of the seven built-in fonts the font picker offers.\n *\n * - `true` / omitted — every built-in is offered (the default).\n * - `false` — no built-ins; the picker lists only `customFonts`. Use this to\n * keep authors on an embedded brand kit's typefaces.\n * - `string[]` — an allowlist of built-in names to keep, matched\n * case-insensitively (`['Georgia', 'arial']`). A name that isn't a built-in\n * is logged with a warning and skipped — consistent with how\n * `paletteBlocks` treats an unknown entry — so a typo narrows the list\n * rather than silently offering all seven.\n *\n * Independent of `customFonts`: excluding the built-ins never removes a custom\n * font, and a custom font can still be the `defaultFont` when every built-in\n * is excluded. Filtering the picker never affects rendering — content already\n * using an excluded built-in still resolves to its proper fallback stack.\n */\n builtIns?: boolean | string[];\n}\n\nexport interface ColorsConfig {\n /**\n * Preset colors rendered as a clickable grid inside every color picker\n * popover. Each entry is a hex string (`'#0b5cff'`); clicking one applies it,\n * and the preset matching the current value is marked selected (matched\n * case-insensitively). The grid supplements the wheel and hex input unless\n * `allowCustom` is `false`.\n */\n presets?: string[];\n /**\n * Allow free-form color entry — the wheel and hex input — alongside the\n * presets. Defaults to `true`.\n *\n * Set to `false` together with `presets` to lock authors to the preset\n * palette: the popover then offers only the preset grid, with no wheel or hex\n * field (a white-label / brand-kit constraint). Ignored with a warning when\n * no `presets` are configured — hiding the only inputs would leave the picker\n * with no way to choose a color.\n */\n allowCustom?: boolean;\n}\n\nexport interface TemplateSettingsConfig {\n /**\n * Which template settings the Settings panel exposes.\n *\n * - `true` / omitted — every setting is editable (the default).\n * - `false` — none; the Settings tab itself stops rendering.\n * - `Array<keyof TemplateSettings>` — an allowlist of settings to keep\n * (`['width', 'backgroundColor', 'fontFamily']`). A card renders when at\n * least one of its settings survives, so hiding `locale` removes the\n * Language card and hiding `preheaderText` removes the Preheader card. An\n * empty array means none, the same as `false`.\n *\n * The list narrows, it never reorders — settings sit in fixed cards, so\n * unlike `paletteBlocks` there is no order to express. An entry that isn't a\n * `TemplateSettings` member is a compile error for TypeScript callers, and is\n * logged with a warning and skipped at runtime, so a typo narrows the panel\n * rather than silently restoring every setting.\n *\n * Presentation only. Hiding a setting never changes its value: whatever the\n * loaded content carries keeps rendering and keeps round-tripping through\n * `getContent()`. Set the values you hide from the content you hand the\n * editor — `init({ content })`, or your own `templates.load`.\n */\n fields?: boolean | Array<keyof TemplateSettings>;\n}\n\nexport interface ExportResult {\n html: string;\n mjml: string;\n}\n\nexport interface MergeTag {\n label: string;\n value: string;\n /**\n * Optional grouping label used by the built-in merge tag picker to\n * section the list. When no tag in the configured array carries\n * `group`, the picker renders a plain flat list with no headers.\n * Ignored by the renderer and by typing-autocomplete.\n */\n group?: string;\n /**\n * Optional helper text shown beneath the tag in the built-in merge\n * tag picker. Not rendered anywhere else (toolbar, autocomplete,\n * MJML output) and not stored on the inserted document node.\n */\n description?: string;\n /**\n * Example value shown in place of this tag on preview surfaces — e.g.\n * `\"Ada\"` for `{{first_name}}` — so a preview reads like a delivered\n * email instead of a list of field names.\n *\n * Display-only, and only in the previews' Sample mode: never written to\n * the template, never sent, never present in MJML output. Setting it is\n * the whole opt-in; there is no accompanying flag. A tag without a\n * sample keeps showing its `label`.\n */\n sample?: string;\n}\n\nexport interface MediaResult {\n url: string;\n alt?: string;\n}\n\n/**\n * Why the merge-tag chooser opened, handed to {@link MergeTagsConfig.onRequest}.\n *\n * `\"insert\"` is a new tag at the caret. `\"edit\"` is the user activating a tag\n * that is already in the content, asking to swap it for another one.\n */\nexport interface MergeTagRequestContext {\n reason: \"insert\" | \"edit\";\n /**\n * The tag being replaced. Present only when `reason` is `\"edit\"` AND the\n * token in the content resolves against `tags` — a token that matches no\n * configured tag still opens the chooser, with nothing to preselect.\n */\n current?: MergeTag;\n}\n\nexport interface MergeTagsConfig {\n syntax?: SyntaxPresetName | SyntaxPreset;\n tags?: MergeTag[];\n /**\n * Consumer-owned chooser. Called both to insert a tag at the caret and to\n * replace one already in the content — `context.reason` says which. Return\n * the chosen tag, or `null` to cancel.\n *\n * The parameter is optional, so an existing zero-argument implementation\n * keeps working unchanged.\n */\n onRequest?: (context?: MergeTagRequestContext) => Promise<MergeTag | null>;\n /**\n * Whether a tag's tooltip reveals the raw token behind its label. Defaults\n * to `true`, which suits a readable syntax like `{{first_name}}` — the\n * tooltip tells an author which field they are looking at.\n *\n * Set `false` when `value` is an internal identifier (an opaque id resolved\n * by your backend) that an author should never see. Display-only: the token\n * is unchanged in stored content and in the rendered output.\n */\n showRawValue?: boolean;\n /**\n * Enables typing-based autocomplete in rich text blocks and in every\n * merge-tag-enabled input/textarea field (toolbars, template settings,\n * custom-block text fields). When the user types the syntax opener\n * (e.g. `{{`), a popup lists matching `tags`. Both surfaces share the\n * same popup, so behavior is identical.\n *\n * Defaults to `true`. Effective only when `tags` is non-empty AND\n * `syntax` matches a built-in preset (custom regex syntaxes cannot be\n * mapped to a trigger string and silently disable autocomplete).\n */\n autocomplete?: boolean;\n}\n\n/**\n * A standalone logic tag — a control-flow token (e.g. `{% else %}`) inserted\n * at the cursor. Distinct from data merge tags; rendered as a keyword badge.\n */\nexport interface LogicTag {\n label: string;\n value: string;\n /** Optional grouping label used to section the logic picker. */\n group?: string;\n /** Optional helper text shown beneath the tag in the picker. */\n description?: string;\n}\n\n/**\n * A paired logic construct — an opening tag (`before`) and its matching closer\n * (`after`), e.g. `{% if vip %}` … `{% endif %}`. Selecting one inserts both\n * pills at once, wrapping the selection (or with the caret placed between\n * them). Shares its `before`/`after` shape with `DisplayCondition`.\n */\nexport interface LogicPair {\n label: string;\n /** Opening logic tag, including delimiters (e.g. `{% if vip %}`). */\n before: string;\n /** Closing logic tag, including delimiters (e.g. `{% endif %}`). */\n after: string;\n /** Optional grouping label used to section the logic picker. */\n group?: string;\n /** Optional helper text shown beneath the pair in the picker. */\n description?: string;\n}\n\n/**\n * Standalone logic-tag configuration, independent of `mergeTags`. `tags` are\n * single control-flow tokens inserted at the cursor; `pairs` are open/close\n * constructs inserted around the selection. Both appear in the built-in logic\n * picker, grouped together by `group`. Typed/pasted logic highlighting is\n * always on regardless of this.\n */\nexport interface LogicTagsConfig {\n tags?: LogicTag[];\n pairs?: LogicPair[];\n /**\n * Consumer-owned picker. When set, the \"Insert logic\" affordance calls this\n * instead of the built-in logic picker — return the chosen tag/pair (or\n * `null` to cancel). Mirrors `MergeTagsConfig.onRequest`; lets consumers use\n * their own UI and custom syntax. Precedence: `onRequest` → built-in picker.\n */\n onRequest?: () => Promise<LogicTag | LogicPair | null>;\n}\n\nexport interface DisplayCondition {\n label: string;\n before: string;\n after: string;\n group?: string;\n description?: string;\n}\n\nexport interface DisplayConditionsConfig {\n conditions: DisplayCondition[];\n allowCustom?: boolean;\n}\n\nexport interface ThemeOverrides {\n bg?: string;\n bgElevated?: string;\n bgHover?: string;\n bgActive?: string;\n border?: string;\n borderLight?: string;\n text?: string;\n textMuted?: string;\n textDim?: string;\n primary?: string;\n primaryHover?: string;\n primaryLight?: string;\n secondary?: string;\n secondaryHover?: string;\n secondaryLight?: string;\n success?: string;\n successLight?: string;\n warning?: string;\n warningLight?: string;\n danger?: string;\n dangerLight?: string;\n canvasBg?: string;\n dark?: Omit<ThemeOverrides, \"dark\">;\n}\n\nexport class SdkError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n ) {\n super(message);\n this.name = \"SdkError\";\n }\n\n get isNotFound(): boolean {\n return this.statusCode === 404;\n }\n\n get isUnauthorized(): boolean {\n return this.statusCode === 401;\n }\n\n get isServerError(): boolean {\n return this.statusCode !== undefined && this.statusCode >= 500;\n }\n}\n"],"mappings":";AAgBA,IAAaC,IAAsC;CACjD;CACA;CACA;CACA;AACF;AAsBA,SAAgBC,EAAc,GAAoC;CAChE,OAAO;EACL,KAAK,EAAE,GAAGC,EAAK;EACf,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