@templatical/editor 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AiChatSidebar-BlFWWhBv.js → AiChatSidebar-DGcH4Lyo.js} +1 -1
- package/dist/{AiFeatureMenu-CvWygUmC.js → AiFeatureMenu-B4q-0g1S.js} +1 -1
- package/dist/{BlockPreviewCanvas-DwxJOTzH.js → BlockPreviewCanvas-DIZ0KgUD.js} +3 -3
- package/dist/{CloudHeaderExtras-BzM1QU1r.js → CloudHeaderExtras-ehMYJP68.js} +1 -1
- package/dist/{CloudPanels-d36YXXyn.js → CloudPanels-BwOaAlKz.js} +2 -2
- package/dist/{CollaboratorBar-rwXe_Qd2.js → CollaboratorBar-qOZFRNPx.js} +1 -1
- package/dist/{CountdownToolbar-lbjCc8ik.js → CountdownToolbar-BeF21SeB.js} +4 -4
- package/dist/{DesignReferenceSidebar-zlJQsP0X.js → DesignReferenceSidebar-zH93uB15.js} +1 -1
- package/dist/{IssuesPanel-CHx3m8SP.js → IssuesPanel-Dltw9haP.js} +1 -1
- package/dist/{LogicTagInsertButton-BvftbkL4.js → LogicTagInsertButton-CHa-UD76.js} +12 -12
- package/dist/{MergeTagInput-CR1kcj8X.js → MergeTagInput-B3ntd4dN.js} +1 -1
- package/dist/{MergeTagModeToggle-DssKrVYb.js → MergeTagModeToggle-C_06ZL0Q.js} +1 -1
- package/dist/{ParagraphEditor-DFizsZRc.js → ParagraphEditor-CxuW3TV0.js} +6 -6
- package/dist/{RestoreVersionDialog-Cp3q2mU4.js → RestoreVersionDialog-B1n37M1Z.js} +1 -1
- package/dist/{RichTextEditorContent-Cj3oaPMk.js → RichTextEditorContent-CP_uULWB.js} +2 -2
- package/dist/{SaveBlockDialog-BR8vW_XF.js → SaveBlockDialog-BSKX_7_v.js} +5 -5
- package/dist/{SavedBlocksBrowserModal-DmwbmKxI.js → SavedBlocksBrowserModal-CHKrH1gO.js} +4 -4
- package/dist/{SavedBlocksPanels-D4XKrs-a.js → SavedBlocksPanels-B-xDqBcz.js} +1 -1
- package/dist/{SavedBlocksPickBar-gfc-o5sR.js → SavedBlocksPickBar-D2J-g82g.js} +1 -1
- package/dist/{TemplateSettings-D7aNrd0d.js → TemplateSettings-D07K_Y4m.js} +4 -4
- package/dist/{TestEmailModal-DUmtcSm-.js → TestEmailModal-BNPw_lID.js} +5 -5
- package/dist/{TestEmailPanel-s9gISTI8.js → TestEmailPanel-8klWo8hE.js} +1 -1
- package/dist/{TitleEditor-C-uHqtml.js → TitleEditor-CmC9OuhA.js} +4 -4
- package/dist/{ToggleSwitch-CTwwCIVA.js → ToggleSwitch-COeyWGfT.js} +1 -1
- package/dist/{Toolbar-CLpA36RO.js → Toolbar-CqhRb6EM.js} +36 -36
- package/dist/{TplModal-D6XtxusQ.js → TplModal-BGFawHY9.js} +1 -1
- package/dist/{VersionHistoryPanels-Dvowtt7V.js → VersionHistoryPanels-DdbGjEOR.js} +1 -1
- package/dist/{WrapperBlock-CzJa2Mxw.js → WrapperBlock-CTkmA887.js} +1 -1
- package/dist/{blockTypeIcons-D3aj5u_5.js → blockTypeIcons-CVKo6V_v.js} +1 -1
- package/dist/bundle-stats.json +6 -6
- package/dist/cdn/chunks/{AiChatSidebar-SRGBP-SL.js → AiChatSidebar-kCK4NZM9.js} +2 -2
- package/dist/cdn/chunks/{AiChatSidebar-SRGBP-SL.js.map → AiChatSidebar-kCK4NZM9.js.map} +1 -1
- package/dist/cdn/chunks/{AiFeatureMenu-oZhlgsGh.js → AiFeatureMenu-K1dLeDft.js} +2 -2
- package/dist/cdn/chunks/{AiFeatureMenu-oZhlgsGh.js.map → AiFeatureMenu-K1dLeDft.js.map} +1 -1
- package/dist/cdn/chunks/{BlockPreviewCanvas-hKxE6f-k.js → BlockPreviewCanvas-Djz9YAFx.js} +4 -4
- package/dist/cdn/chunks/{BlockPreviewCanvas-hKxE6f-k.js.map → BlockPreviewCanvas-Djz9YAFx.js.map} +1 -1
- package/dist/cdn/chunks/{CloudHeaderExtras-t-_ZlHwn.js → CloudHeaderExtras-5ONQ1RCa.js} +2 -2
- package/dist/cdn/chunks/{CloudHeaderExtras-t-_ZlHwn.js.map → CloudHeaderExtras-5ONQ1RCa.js.map} +1 -1
- package/dist/cdn/chunks/{CloudPanels-DR2eEcpX.js → CloudPanels-_irSdWbi.js} +3 -3
- package/dist/cdn/chunks/{CloudPanels-DR2eEcpX.js.map → CloudPanels-_irSdWbi.js.map} +1 -1
- package/dist/cdn/chunks/{CollaboratorBar-w8_2WPE0.js → CollaboratorBar-CZufI1On.js} +2 -2
- package/dist/cdn/chunks/{CollaboratorBar-w8_2WPE0.js.map → CollaboratorBar-CZufI1On.js.map} +1 -1
- package/dist/cdn/chunks/{CountdownToolbar-CvNuDR5Z.js → CountdownToolbar-BaXCefQM.js} +5 -5
- package/dist/cdn/chunks/{CountdownToolbar-CvNuDR5Z.js.map → CountdownToolbar-BaXCefQM.js.map} +1 -1
- package/dist/cdn/chunks/{DesignReferenceSidebar-CJg_5GXU.js → DesignReferenceSidebar-GjkpHylX.js} +2 -2
- package/dist/cdn/chunks/{DesignReferenceSidebar-CJg_5GXU.js.map → DesignReferenceSidebar-GjkpHylX.js.map} +1 -1
- package/dist/cdn/chunks/{IssuesPanel-DXqlRk19.js → IssuesPanel-C1Lv2y_O.js} +2 -2
- package/dist/cdn/chunks/{IssuesPanel-DXqlRk19.js.map → IssuesPanel-C1Lv2y_O.js.map} +1 -1
- package/dist/cdn/chunks/{LogicTagInsertButton-DnHghQHb.js → LogicTagInsertButton-BYjdrDnQ.js} +4 -4
- package/dist/cdn/chunks/{LogicTagInsertButton-DnHghQHb.js.map → LogicTagInsertButton-BYjdrDnQ.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagInput-heTX9P_k.js → MergeTagInput-Cx67J_vg.js} +2 -2
- package/dist/cdn/chunks/{MergeTagInput-heTX9P_k.js.map → MergeTagInput-Cx67J_vg.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagModeToggle-C9EfuZIP.js → MergeTagModeToggle-DZ4EuXVp.js} +2 -2
- package/dist/cdn/chunks/{MergeTagModeToggle-C9EfuZIP.js.map → MergeTagModeToggle-DZ4EuXVp.js.map} +1 -1
- package/dist/cdn/chunks/{ParagraphEditor-B5DN4Sy4.js → ParagraphEditor-DndEFXmR.js} +7 -7
- package/dist/cdn/chunks/{ParagraphEditor-B5DN4Sy4.js.map → ParagraphEditor-DndEFXmR.js.map} +1 -1
- package/dist/cdn/chunks/{RestoreVersionDialog-DBgJ-Nui.js → RestoreVersionDialog-CFYs13a4.js} +2 -2
- package/dist/cdn/chunks/{RestoreVersionDialog-DBgJ-Nui.js.map → RestoreVersionDialog-CFYs13a4.js.map} +1 -1
- package/dist/cdn/chunks/{RichTextEditorContent-LOas4rfU.js → RichTextEditorContent-DKkDQ0dc.js} +3 -3
- package/dist/cdn/chunks/{RichTextEditorContent-LOas4rfU.js.map → RichTextEditorContent-DKkDQ0dc.js.map} +1 -1
- package/dist/cdn/chunks/{SaveBlockDialog-Dx-QVQCX.js → SaveBlockDialog-BOA2RaC_.js} +6 -6
- package/dist/cdn/chunks/{SaveBlockDialog-Dx-QVQCX.js.map → SaveBlockDialog-BOA2RaC_.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-C2RQ-JCc.js → SavedBlocksBrowserModal-DQDVek3K.js} +4 -4
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-C2RQ-JCc.js.map → SavedBlocksBrowserModal-DQDVek3K.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPanels-BmRbvqqL.js → SavedBlocksPanels-Lu3tJ3QA.js} +2 -2
- package/dist/cdn/chunks/{SavedBlocksPanels-BmRbvqqL.js.map → SavedBlocksPanels-Lu3tJ3QA.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPickBar-BzwKojoJ.js → SavedBlocksPickBar-D7MtqG6r.js} +2 -2
- package/dist/cdn/chunks/{SavedBlocksPickBar-BzwKojoJ.js.map → SavedBlocksPickBar-D7MtqG6r.js.map} +1 -1
- package/dist/cdn/chunks/{TemplateSettings-G-yV7C1C.js → TemplateSettings-rZiHmq24.js} +5 -5
- package/dist/cdn/chunks/{TemplateSettings-G-yV7C1C.js.map → TemplateSettings-rZiHmq24.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailModal-lOeztfTN.js → TestEmailModal-DWEyHXH2.js} +6 -6
- package/dist/cdn/chunks/{TestEmailModal-lOeztfTN.js.map → TestEmailModal-DWEyHXH2.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailPanel-CZswVkk_.js → TestEmailPanel-XXMD-Lnr.js} +2 -2
- package/dist/cdn/chunks/{TestEmailPanel-CZswVkk_.js.map → TestEmailPanel-XXMD-Lnr.js.map} +1 -1
- package/dist/cdn/chunks/{TitleEditor-CnTT2Y3H.js → TitleEditor-D1F0YoE-.js} +4 -4
- package/dist/cdn/chunks/{TitleEditor-CnTT2Y3H.js.map → TitleEditor-D1F0YoE-.js.map} +1 -1
- package/dist/cdn/chunks/{ToggleSwitch-CLHteVMO.js → ToggleSwitch-B5U9cqhi.js} +2 -2
- package/dist/cdn/chunks/{ToggleSwitch-CLHteVMO.js.map → ToggleSwitch-B5U9cqhi.js.map} +1 -1
- package/dist/cdn/chunks/{Toolbar-K4tIkpG1.js → Toolbar-C_5HfUQq.js} +55 -55
- package/dist/cdn/chunks/{Toolbar-K4tIkpG1.js.map → Toolbar-C_5HfUQq.js.map} +1 -1
- package/dist/cdn/chunks/{TplModal-OOT36AjS.js → TplModal-CYBbPCHL.js} +2 -2
- package/dist/cdn/chunks/{TplModal-OOT36AjS.js.map → TplModal-CYBbPCHL.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryPanels-BrpYRSfW.js → VersionHistoryPanels-Dq12VsTX.js} +2 -2
- package/dist/cdn/chunks/{VersionHistoryPanels-BrpYRSfW.js.map → VersionHistoryPanels-Dq12VsTX.js.map} +1 -1
- package/dist/cdn/chunks/{WrapperBlock-DdrnwH80.js → WrapperBlock-CJ0CLqi2.js} +2 -2
- package/dist/cdn/chunks/{WrapperBlock-DdrnwH80.js.map → WrapperBlock-CJ0CLqi2.js.map} +1 -1
- package/dist/cdn/chunks/{cloud-bhW8qTnh.js → cloud-h1vaHp2p.js} +2 -2
- package/dist/cdn/chunks/{cloud-bhW8qTnh.js.map → cloud-h1vaHp2p.js.map} +1 -1
- package/dist/cdn/chunks/{createCloudRuntime-CeRJkLR2.js → createCloudRuntime-bJN9EM1H.js} +3 -3
- package/dist/cdn/chunks/{createCloudRuntime-CeRJkLR2.js.map → createCloudRuntime-bJN9EM1H.js.map} +1 -1
- package/dist/cdn/chunks/{extensions-xjRsIjMP.js → extensions-CrmXF4MW.js} +6 -6
- package/dist/cdn/chunks/extensions-CrmXF4MW.js.map +1 -0
- package/dist/{preRenderCustomBlocks-DAS48ZCp.js → cdn/chunks/preRenderCustomBlocks-CyGB3lZr.js} +5 -3
- package/dist/cdn/chunks/{preRenderCustomBlocks-CFwa7nP9.js.map → preRenderCustomBlocks-CyGB3lZr.js.map} +1 -1
- package/dist/cdn/chunks/{socialIcons-CsYnPPll.js → socialIcons-ClJVDZwt.js} +82 -101
- package/dist/cdn/chunks/socialIcons-ClJVDZwt.js.map +1 -0
- package/dist/cdn/chunks/{src-HA9F2kvk.js → src-B0pZeTYO.js} +200 -183
- package/dist/cdn/chunks/src-B0pZeTYO.js.map +1 -0
- package/dist/cdn/chunks/{src-CkXmV2I2.js → src-BMw3u-iV.js} +213 -215
- package/dist/cdn/chunks/src-BMw3u-iV.js.map +1 -0
- package/dist/cdn/chunks/{src-BcqNlDMe.js → src-Bh0MoJ67.js} +280 -187
- package/dist/cdn/chunks/src-Bh0MoJ67.js.map +1 -0
- package/dist/cdn/chunks/{useEditorCore-BF1ZhcGu.js → useEditorCore-DuC7kVti.js} +323 -319
- package/dist/cdn/chunks/useEditorCore-DuC7kVti.js.map +1 -0
- package/dist/cdn/chunks/{useLogicTag-91bO_SOi.js → useLogicTag-B3uV3XHG.js} +2 -2
- package/dist/cdn/chunks/{useLogicTag-91bO_SOi.js.map → useLogicTag-B3uV3XHG.js.map} +1 -1
- package/dist/cdn/chunks/{useMergeTag-hwifK582.js → useMergeTag-DJLM-7WQ.js} +2 -2
- package/dist/cdn/chunks/{useMergeTag-hwifK582.js.map → useMergeTag-DJLM-7WQ.js.map} +1 -1
- package/dist/cdn/chunks/{useScrollToBlock-BDNJ25X1.js → useScrollToBlock-CpmB5KxW.js} +2 -3
- package/dist/cdn/chunks/useScrollToBlock-CpmB5KxW.js.map +1 -0
- package/dist/cdn/chunks/withCurrentFont-isIyuezD.js +21 -0
- package/dist/cdn/chunks/withCurrentFont-isIyuezD.js.map +1 -0
- package/dist/cdn/editor.css +1 -1
- package/dist/cdn/editor.js +435 -417
- package/dist/cdn/editor.js.map +1 -1
- package/dist/{cloud-CVfwPu19.js → cloud-DPGjMGfv.js} +1 -1
- package/dist/{createCloudRuntime-GRv_TDb2.js → createCloudRuntime-D0RRgWab.js} +2 -2
- package/dist/{dist-CSaWqmWM.js → dist-BI_LeQGl.js} +271 -200
- package/dist/{extensions-B65sfZRk.js → extensions-CYigjb1g.js} +13 -13
- package/dist/index.d.ts +34 -12
- package/dist/{cdn/chunks/preRenderCustomBlocks-CFwa7nP9.js → preRenderCustomBlocks-DokBGA_M.js} +3 -5
- package/dist/{socialIcons-CvAixjj8.js → socialIcons-Ct_IoqPQ.js} +107 -126
- package/dist/style.css +1 -1
- package/dist/templatical-editor.js +456 -438
- package/dist/{useEditorCore-DQSeKPE9.js → useEditorCore-BJAQMvNW.js} +482 -478
- package/dist/{useLogicTag-BH87j1vZ.js → useLogicTag-B5gjcMzn.js} +1 -1
- package/dist/{useMergeTag-DfPKX2Tk.js → useMergeTag-BwsBIDzR.js} +3 -3
- package/dist/{useScrollToBlock-Dr7Sb6Tr.js → useScrollToBlock-JRxhT1u_.js} +1 -2
- package/dist/withCurrentFont-C9vqrduu.js +19 -0
- package/package.json +8 -8
- package/dist/cdn/chunks/extensions-xjRsIjMP.js.map +0 -1
- package/dist/cdn/chunks/socialIcons-CsYnPPll.js.map +0 -1
- package/dist/cdn/chunks/src-BcqNlDMe.js.map +0 -1
- package/dist/cdn/chunks/src-CkXmV2I2.js.map +0 -1
- package/dist/cdn/chunks/src-HA9F2kvk.js.map +0 -1
- package/dist/cdn/chunks/useEditorCore-BF1ZhcGu.js.map +0 -1
- package/dist/cdn/chunks/useScrollToBlock-BDNJ25X1.js.map +0 -1
- package/dist/cdn/chunks/withCurrentFont-DeCbPVaE.js +0 -32
- package/dist/cdn/chunks/withCurrentFont-DeCbPVaE.js.map +0 -1
- package/dist/withCurrentFont-DeCbPVaE.js +0 -30
|
@@ -4,8 +4,8 @@ import { t as a } from "./dist-C5nRd_ua.js";
|
|
|
4
4
|
import { W as o, i as s, t as c, u as l } from "./keys-BKu-LOk5.js";
|
|
5
5
|
import { t as u } from "./timeouts-DHPZQ0G3.js";
|
|
6
6
|
import { t as d } from "./logger-ByvdoAwq.js";
|
|
7
|
-
import { t as f } from "./preRenderCustomBlocks-
|
|
8
|
-
import { C as p, S as m, a as h, c as g, d as _, f as v, g as ee, h as te, i as ne, l as re, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as y, u as b, v as x, x as ue, y as de } from "./cloud-
|
|
7
|
+
import { t as f } from "./preRenderCustomBlocks-CyGB3lZr.js";
|
|
8
|
+
import { C as p, S as m, a as h, c as g, d as _, f as v, g as ee, h as te, i as ne, l as re, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as y, u as b, v as x, x as ue, y as de } from "./cloud-h1vaHp2p.js";
|
|
9
9
|
//#region src/cloud/composables/useCloudFeatureFlags.ts
|
|
10
10
|
function fe(e) {
|
|
11
11
|
let { planConfigInstance: t, aiConfig: n, getTemplateId: i } = e;
|
|
@@ -388,4 +388,4 @@ async function w(i) {
|
|
|
388
388
|
//#endregion
|
|
389
389
|
export { w as bootstrapCloud };
|
|
390
390
|
|
|
391
|
-
//# sourceMappingURL=createCloudRuntime-
|
|
391
|
+
//# sourceMappingURL=createCloudRuntime-bJN9EM1H.js.map
|
package/dist/cdn/chunks/{createCloudRuntime-CeRJkLR2.js.map → createCloudRuntime-bJN9EM1H.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCloudRuntime-CeRJkLR2.js","names":["watch","provide","ref","computed","useTimeoutFn","onClickOutside","SCORING_KEY","AUTH_MANAGER_KEY","AI_CONFIG_KEY","CLOUD_TRANSLATIONS_KEY","COLLAB_UNDO_WARNING_MS","logger","preRenderCustomBlocks","isFatalAuthError","AuthManager","useTestEmail","resolveExportFonts","createCloudMediaProvider","createCloudSavedBlocksProvider","createCloudCommentsProvider","useCollaboration","createCloudTestEmailProvider","useExport","useCollaborationBroadcast","performHealthCheck","createCloudVersionHistoryProvider","useWebSocket","usePlanConfig","createCloudRenderProvider","useMcpListener","createCloudTemplatesProvider","useTemplateScoring","resolveWebSocketConfig","useAiConfig","useCloudFeatureFlags","options","planConfigInstance","aiConfig","getTemplateId","useCloudPanelState","activePanel","aiChatOpen","v","scoringPanelOpen","designReferenceOpen","commentsOpen","aiMenuOpen","aiMenuRef","rightPanelOpen","activeAiFeature","p","aiButtonActive","toggleAiMenu","handleAiFeatureSelect","feature","useCloudSaveGate","modalOpen","pending","blockOnError","opts","blockingIssues","i","shouldBlock","tryRunSave","run","runUnlessBlocked","confirmAndSave","cancel","useCollabUndoWarning","collabUndoWarningFired","collabUndoWarningVisible","startCollabUndoWarningTimeout","showCollabUndoWarning","isCollaborationEnabled","getCollaboratorCount","canUndo","collectSavedBlockIds","ids","collectFromBlocks","template","blocks","block","column","eventsOf","value","onSaved","onCreated","onLoaded","commentEventsOf","onUpdated","onDeleted","onResolved","onUnresolved","savedBlocksEventsOf","testEmailEventsOf","onSent","defaultRecipient","mediaEventsOf","versionHistoryEventsOf","onRestored","joinWithAnd","items","bootstrapCloud","editorRef","coreRef","websocketRef","collaboration","collabWarning","saveGate","sessionError","lockedBlocks","commentChannel","requireEditor","authManager","config","error","healthResult","consumerTemplates","ignoredTemplateMethods","key","consumerVersionHistory","ignoredVersionHistoryMethods","consumerComments","ignoredCommentMethods","connectRealtime","websocketConfig","baseTemplates","baseCreate","baseSave","templates","id","input","patch","render","versionHistory","comments","cloudUser","consumerSavedBlocks","suppliedSavedBlocks","ignoredSavedBlocksMethods","savedBlocks","testEmailConfig","exporter","consumerTestEmail","suppliedTestEmail","ignoredTestEmailMembers","testEmail","templateId","consumerMedia","suppliedMedia","ignoredMediaMethods","ignoredMediaLimits","media","scoringInstance","featureFlags","attach","editor","context","cloudTranslations","websocket","channel","next","ready","core","blockId"],"sources":["../../../src/cloud/composables/useCloudFeatureFlags.ts","../../../src/cloud/composables/useCloudPanelState.ts","../../../src/cloud/composables/useCloudSaveGate.ts","../../../src/cloud/composables/useCollabUndoWarning.ts","../../../src/cloud/collectSavedBlockIds.ts","../../../src/cloud/createCloudRuntime.ts"],"sourcesContent":["import { computed, type ComputedRef } from \"vue\";\nimport type {\n UsePlanConfigReturn,\n UseAiConfigReturn,\n} from \"@templatical/core/cloud\";\n\nexport interface UseCloudFeatureFlagsOptions {\n planConfigInstance: UsePlanConfigReturn;\n aiConfig: UseAiConfigReturn;\n /** The loaded template's id, or `null` before one exists. */\n getTemplateId: () => string | null;\n}\n\nexport interface UseCloudFeatureFlagsReturn {\n canUseAiGeneration: ComputedRef<boolean>;\n canSendTestEmail: ComputedRef<boolean>;\n hasTemplateSaved: ComputedRef<boolean>;\n templateLimit: ComputedRef<number | null>;\n templateCount: ComputedRef<number>;\n}\n\n/**\n * Every entitlement check Cloud makes, in one place.\n *\n * The containment rule this exists for: entitlement checks go through here,\n * never inline in a component and never across a package boundary. With five\n * plan features left there is little excuse to break it.\n *\n * Save status is deliberately not here — it lives on `useTemplatesFeature`, which\n * the one shared header reads, and was never an entitlement. Footer branding is\n * likewise not gated: `config.branding !== false` decides it on any plan.\n */\nexport function useCloudFeatureFlags(\n options: UseCloudFeatureFlagsOptions,\n): UseCloudFeatureFlagsReturn {\n const { planConfigInstance, aiConfig, getTemplateId } = options;\n\n const canUseAiGeneration = computed(\n () =>\n planConfigInstance.hasFeature(\"aiGeneration\") &&\n aiConfig.hasAnyMenuFeature.value,\n );\n const canSendTestEmail = computed(() =>\n planConfigInstance.hasFeature(\"testEmail\"),\n );\n const hasTemplateSaved = computed(() => getTemplateId() !== null);\n const templateLimit = computed(\n () => planConfigInstance.config.value?.limits.maxTemplates ?? null,\n );\n const templateCount = computed(\n () => planConfigInstance.config.value?.templateCount ?? 0,\n );\n\n return {\n canUseAiGeneration,\n canSendTestEmail,\n hasTemplateSaved,\n templateLimit,\n templateCount,\n };\n}\n","import { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport { onClickOutside } from \"@vueuse/core\";\nimport type { AiFeature } from \"../components/AiFeatureMenu.vue\";\n\nexport interface UseCloudPanelStateReturn {\n activePanel: Ref<RightPanel | null>;\n aiChatOpen: ComputedRef<boolean> & { value: boolean };\n scoringPanelOpen: ComputedRef<boolean> & { value: boolean };\n designReferenceOpen: ComputedRef<boolean> & { value: boolean };\n commentsOpen: ComputedRef<boolean> & { value: boolean };\n aiMenuOpen: Ref<boolean>;\n aiMenuRef: Ref<HTMLElement | null>;\n rightPanelOpen: ComputedRef<boolean>;\n activeAiFeature: ComputedRef<AiFeature | null>;\n aiButtonActive: ComputedRef<boolean>;\n toggleAiMenu: () => void;\n handleAiFeatureSelect: (feature: AiFeature) => void;\n}\n\ntype RightPanel = \"ai-chat\" | \"scoring\" | \"design-reference\" | \"comments\";\n\nexport function useCloudPanelState(): UseCloudPanelStateReturn {\n const activePanel = ref<RightPanel | null>(null);\n\n const aiChatOpen = computed({\n get: () => activePanel.value === \"ai-chat\",\n set: (v) => (activePanel.value = v ? \"ai-chat\" : null),\n });\n const scoringPanelOpen = computed({\n get: () => activePanel.value === \"scoring\",\n set: (v) => (activePanel.value = v ? \"scoring\" : null),\n });\n const designReferenceOpen = computed({\n get: () => activePanel.value === \"design-reference\",\n set: (v) => (activePanel.value = v ? \"design-reference\" : null),\n });\n const commentsOpen = computed({\n get: () => activePanel.value === \"comments\",\n set: (v) => (activePanel.value = v ? \"comments\" : null),\n });\n\n const aiMenuOpen = ref(false);\n const aiMenuRef = ref<HTMLElement | null>(null);\n\n const rightPanelOpen = computed(() => activePanel.value !== null);\n\n const activeAiFeature = computed<AiFeature | null>(() => {\n const p = activePanel.value;\n if (p === \"ai-chat\" || p === \"design-reference\" || p === \"scoring\")\n return p;\n return null;\n });\n\n const aiButtonActive = computed(\n () =>\n aiMenuOpen.value ||\n activePanel.value === \"ai-chat\" ||\n activePanel.value === \"design-reference\" ||\n activePanel.value === \"scoring\",\n );\n\n function toggleAiMenu(): void {\n aiMenuOpen.value = !aiMenuOpen.value;\n }\n\n function handleAiFeatureSelect(feature: AiFeature): void {\n aiMenuOpen.value = false;\n activePanel.value = activePanel.value === feature ? null : feature;\n }\n\n onClickOutside(aiMenuRef, () => {\n aiMenuOpen.value = false;\n });\n\n return {\n activePanel,\n aiChatOpen,\n scoringPanelOpen,\n designReferenceOpen,\n commentsOpen,\n aiMenuOpen,\n aiMenuRef,\n rightPanelOpen,\n activeAiFeature,\n aiButtonActive,\n toggleAiMenu,\n handleAiFeatureSelect,\n };\n}\n","import { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport type { PlanConfig } from \"@templatical/types\";\nimport type { LintIssue } from \"../../composables/useTemplateLint\";\n\nexport interface UseCloudSaveGateOptions {\n /** Reactive accessibility issues from `useTemplateLint`. */\n issues: Ref<LintIssue[]>;\n /** Reactive plan config from the server. */\n planConfig: Ref<PlanConfig | null>;\n}\n\nexport interface UseCloudSaveGateReturn {\n /** True when the gate would block a save click given current state. */\n shouldBlock: ComputedRef<boolean>;\n /** Errors that would block the save. Empty when `shouldBlock` is false. */\n blockingIssues: ComputedRef<LintIssue[]>;\n /** Modal visibility — toggled by `tryRunSave` and `cancel`. */\n modalOpen: Ref<boolean>;\n /**\n * Wraps a save callback. Returns `true` when the save was invoked\n * (blocking disabled or no errors), `false` when the modal opened\n * instead. Caller can `await` the returned promise to know when the\n * save settled.\n */\n tryRunSave: (run: () => Promise<unknown> | unknown) => Promise<boolean>;\n /**\n * Runs the save only when the gate would not block, and does **nothing** when\n * it would — no modal, no save, nothing pending. Returns whether it ran.\n *\n * This is the autosave path. A modal on a debounce timer would interrupt\n * typing, but simply saving anyway would demote `blockOnError` from a server\n * policy to a manual-save-only speed bump. Skipping leaves the template dirty\n * and the header saying \"unsaved\", which is true, and the reason stays visible\n * in the Issues panel. The next edit re-arms the debounce, so fixing the issue\n * is what lets the save through — no retry timer needed.\n */\n runUnlessBlocked: (run: () => Promise<unknown> | unknown) => Promise<boolean>;\n /** Force-run the pending save, bypassing the gate. */\n confirmAndSave: () => Promise<void>;\n /** Dismiss the modal without saving. */\n cancel: () => void;\n}\n\n/**\n * Cloud-only save-gate. When `planConfig.accessibility.blockOnError === true`\n * and the linter reports any error-severity issues, intercept the save\n * click and surface a confirmation modal listing the blockers. The user\n * can dismiss to fix issues, or click \"Save anyway\" to bypass — the gate\n * does NOT enforce a hard block, it surfaces a deliberate choice.\n *\n * Server policy is the source of truth for `blockOnError`; consumer-side\n * `accessibility` options can't override it.\n */\nexport function useCloudSaveGate(\n opts: UseCloudSaveGateOptions,\n): UseCloudSaveGateReturn {\n const modalOpen = ref(false);\n let pending: (() => Promise<unknown> | unknown) | null = null;\n\n const blockOnError = computed(\n () => opts.planConfig.value?.accessibility?.blockOnError === true,\n );\n\n const blockingIssues = computed(() =>\n blockOnError.value\n ? opts.issues.value.filter((i) => i.severity === \"error\")\n : [],\n );\n\n const shouldBlock = computed(() => blockingIssues.value.length > 0);\n\n async function tryRunSave(\n run: () => Promise<unknown> | unknown,\n ): Promise<boolean> {\n if (!shouldBlock.value) {\n await run();\n return true;\n }\n pending = run;\n modalOpen.value = true;\n return false;\n }\n\n async function runUnlessBlocked(\n run: () => Promise<unknown> | unknown,\n ): Promise<boolean> {\n if (shouldBlock.value) return false;\n await run();\n return true;\n }\n\n async function confirmAndSave(): Promise<void> {\n const run = pending;\n pending = null;\n modalOpen.value = false;\n if (run) {\n await run();\n }\n }\n\n function cancel(): void {\n pending = null;\n modalOpen.value = false;\n }\n\n return {\n shouldBlock,\n blockingIssues,\n modalOpen,\n tryRunSave,\n runUnlessBlocked,\n confirmAndSave,\n cancel,\n };\n}\n","import { type ComputedRef, type Ref, ref } from \"vue\";\nimport { useTimeoutFn } from \"@vueuse/core\";\nimport { COLLAB_UNDO_WARNING_MS } from \"../../constants/timeouts\";\n\nexport interface UseCollabUndoWarningOptions {\n /** Whether collaboration is currently enabled (reactive). */\n isCollaborationEnabled: ComputedRef<boolean>;\n /** Returns the current list of collaborators. */\n getCollaboratorCount: () => number;\n /** Whether the history stack has entries to undo. */\n canUndo: ComputedRef<boolean>;\n}\n\nexport interface UseCollabUndoWarningReturn {\n collabUndoWarningVisible: Ref<boolean>;\n showCollabUndoWarning: () => void;\n}\n\nexport function useCollabUndoWarning(\n options: UseCollabUndoWarningOptions,\n): UseCollabUndoWarningReturn {\n const { isCollaborationEnabled, getCollaboratorCount, canUndo } = options;\n\n const collabUndoWarningFired = ref(false);\n const collabUndoWarningVisible = ref(false);\n\n const { start: startCollabUndoWarningTimeout } = useTimeoutFn(\n () => {\n collabUndoWarningVisible.value = false;\n },\n COLLAB_UNDO_WARNING_MS,\n { immediate: false },\n );\n\n function showCollabUndoWarning(): void {\n if (\n collabUndoWarningFired.value ||\n !isCollaborationEnabled.value ||\n getCollaboratorCount() === 0 ||\n !canUndo.value\n ) {\n return;\n }\n\n collabUndoWarningFired.value = true;\n collabUndoWarningVisible.value = true;\n startCollabUndoWarningTimeout();\n }\n\n return {\n collabUndoWarningVisible,\n showCollabUndoWarning,\n };\n}\n","/**\n * Just enough of a stored template to walk its ids — deliberately structural\n * rather than `Template`, because the caller reads `editor.state`, which is\n * `DeepReadonly` and so not assignable to the mutable contract type.\n *\n * `children` is a union: a section stores columns (`Block[][]`); a layout\n * `wrapper` stores a flat `Block[]`. Both appear on the `Block` union, so a\n * shape that only named the section form is not assignable from\n * `DeepReadonly<Template>`.\n */\ninterface SavedBlockIdNode {\n readonly id: string;\n readonly type: string;\n readonly children?:\n readonly SavedBlockIdNode[] | readonly (readonly SavedBlockIdNode[])[];\n}\n\ninterface SavedBlockIdSource {\n content?: {\n blocks?: readonly SavedBlockIdNode[];\n };\n}\n\n/**\n * Every block id present in the **stored** template, sections' children\n * included.\n *\n * This is the last thing the deleted Cloud editor core carried over the OSS one\n * (`savedBlockIds`), and it never belonged there: its only reader gates a\n * comment filter on whether the block exists server-side, which makes it a\n * *comments* dependency. It travels with that feature accordingly, and reaches\n * `CommentsSidebar` through `capabilities.comments.isBlockSaved`.\n *\n * Derived on demand rather than memoised: `state.template` only changes on a\n * create / load / save round-trip, and the one caller runs on a user filtering\n * the comments panel.\n */\nexport function collectSavedBlockIds(\n template: SavedBlockIdSource | null | undefined,\n): Set<string> {\n const ids = new Set<string>();\n collectFromBlocks(template?.content?.blocks, ids);\n return ids;\n}\n\nfunction collectFromBlocks(\n blocks: readonly SavedBlockIdNode[] | undefined,\n ids: Set<string>,\n): void {\n if (!blocks) return;\n for (const block of blocks) {\n ids.add(block.id);\n if (!block.children) continue;\n if (block.type === \"section\") {\n for (const column of block.children as readonly (readonly SavedBlockIdNode[])[]) {\n collectFromBlocks(column, ids);\n }\n continue;\n }\n if (block.type === \"wrapper\") {\n collectFromBlocks(block.children as readonly SavedBlockIdNode[], ids);\n }\n }\n}\n","import { computed, provide, ref, watch } from \"vue\";\nimport {\n AuthManager,\n isFatalAuthError,\n performHealthCheck,\n useAiConfig,\n useCollaboration,\n useCollaborationBroadcast,\n useExport,\n useMcpListener,\n usePlanConfig,\n resolveExportFonts,\n resolveWebSocketConfig,\n createCloudCommentsProvider,\n createCloudMediaProvider,\n createCloudRenderProvider,\n createCloudSavedBlocksProvider,\n createCloudTemplatesProvider,\n createCloudTestEmailProvider,\n createCloudVersionHistoryProvider,\n useTemplateScoring,\n useTestEmail,\n useWebSocket,\n type RealtimeChannel,\n} from \"@templatical/core/cloud\";\nimport type { UseEditorReturn } from \"@templatical/core\";\nimport type {\n CommentsOptions,\n CommentsProvider,\n EditorUser,\n MediaOptions,\n MediaProvider,\n RenderProvider,\n SavedBlocksOptions,\n SavedBlocksProvider,\n Template,\n TemplateContent,\n TemplatePatch,\n TemplatesOptions,\n TemplatesProvider,\n TestEmailOptions,\n TestEmailProvider,\n VersionHistoryOptions,\n VersionHistoryProvider,\n} from \"@templatical/types\";\n\nimport type { CloudTranslations } from \"../i18n\";\nimport { preRenderCustomBlocks } from \"../utils/preRenderCustomBlocks\";\nimport { logger } from \"../utils/logger\";\nimport type { UseEditorCoreReturn } from \"../composables/useEditorCore\";\nimport {\n AI_CONFIG_KEY,\n AUTH_MANAGER_KEY,\n CLOUD_TRANSLATIONS_KEY,\n SCORING_KEY,\n} from \"../keys\";\n\nimport { useCloudFeatureFlags } from \"./composables/useCloudFeatureFlags\";\nimport { useCloudPanelState } from \"./composables/useCloudPanelState\";\nimport {\n useCloudSaveGate,\n type UseCloudSaveGateReturn,\n} from \"./composables/useCloudSaveGate\";\nimport {\n useCollabUndoWarning,\n type UseCollabUndoWarningReturn,\n} from \"./composables/useCollabUndoWarning\";\nimport { collectSavedBlockIds } from \"./collectSavedBlockIds\";\nimport type {\n CloudAttachContext,\n CloudAttachment,\n CloudCollaborationInstance,\n CloudReady,\n CloudReadyContext,\n CloudRuntime,\n} from \"./runtime\";\nimport type { TemplaticalCloudEditorConfig } from \"./cloudConfig\";\n\nexport interface BootstrapCloudOptions {\n config: TemplaticalCloudEditorConfig;\n cloudTranslations: CloudTranslations;\n}\n\n/**\n * What {@link bootstrapCloud} hands back: a set of ordinary `init()` config\n * values, plus the runtime for the few things that must run inside the editor\n * component's `setup()`.\n */\nexport interface CloudBootstrap {\n runtime: CloudRuntime;\n providers: {\n templates: TemplatesProvider;\n render: RenderProvider;\n versionHistory: VersionHistoryProvider;\n /** Absent when `savedBlocks: false` — the feature is then off entirely. */\n savedBlocks?: SavedBlocksProvider;\n testEmail: TestEmailProvider;\n comments: CommentsProvider;\n /** Absent when `media: false` — Browse is then off unless `onRequestMedia` is set. */\n media?: MediaProvider;\n };\n /**\n * Who is editing, from the JWT — `init({ user })`'s value for a Cloud session.\n *\n * `undefined` when the project's token carries no `user` claim, which makes\n * comments unavailable rather than anonymous. Not a key `initCloud()` accepts:\n * Cloud's comment writes are signed against this same claim, so a\n * consumer-supplied identity would only be able to disagree with it.\n */\n user?: EditorUser;\n}\n\n/**\n * Pick only the event members off a consumer-supplied `templates` value.\n *\n * A whitelist, never a spread. The config type says `TemplatesOptions`, but a\n * JavaScript consumer is unchecked, so the object can carry anything —\n * `load`/`create`/`save` are already shadowed by the literal defining them\n * after the spread, and this drops everything else so the guarantee never\n * depends on that ordering surviving a later edit.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onSaved: \"yes\"` would otherwise reach core and throw at save time,\n * inside a call the consumer never made.\n */\nfunction eventsOf(value: TemplatesOptions | undefined): TemplatesOptions {\n if (!value) return {};\n const { onSaved, onCreated, onLoaded } = value;\n return {\n ...(typeof onSaved === \"function\" ? { onSaved } : {}),\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onLoaded === \"function\" ? { onLoaded } : {}),\n };\n}\n\n/**\n * Fails to compile when `TemplatesOptions` gains a member outside the six\n * named below. Cloud picks that object apart by name in two places —\n * `eventsOf` above and `initCloud`'s merge in `index.ts` — so a seventh\n * member forces a **deliberate decision** about which of the two forwards\n * it. The check cannot make that decision itself: adding the new name to the\n * `Exclude` list below satisfies the compiler on its own and forwards\n * nothing by itself, and it has no way to tell an event (belongs in\n * `eventsOf`) from config (belongs in the `index.ts` merge).\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the six named here.\n */\ntype _TemplatesOptionsForwarded =\n Exclude<\n keyof TemplatesOptions,\n | \"autoSave\"\n | \"unsavedChangesGuard\"\n | \"nameField\"\n | \"onSaved\"\n | \"onCreated\"\n | \"onLoaded\"\n > extends never\n ? true\n : never;\nconst _templatesOptionsForwarded: _TemplatesOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `comments` value.\n *\n * A whitelist, never a spread. The config type says `CommentsOptions`, but a\n * JavaScript consumer is unchecked, so the object can carry anything —\n * `list`/`create`/`update`/`delete`/`setResolved` are already shadowed by the\n * spread of Cloud's own adapter that follows this in the provider literal, and\n * this drops everything else so the guarantee never depends on that ordering\n * surviving a later edit.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onCreated: \"yes\"` would otherwise reach core and throw at\n * comment-creation time, inside a call the consumer never made.\n */\nfunction commentEventsOf(\n value: false | CommentsOptions | undefined,\n): CommentsOptions {\n if (!value) return {};\n const { onCreated, onUpdated, onDeleted, onResolved, onUnresolved } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n ...(typeof onResolved === \"function\" ? { onResolved } : {}),\n ...(typeof onUnresolved === \"function\" ? { onUnresolved } : {}),\n };\n}\n\n/**\n * Fails to compile when `CommentsOptions` gains a member outside the five\n * named below. Every member of `CommentsOptions` is an event, and\n * `commentEventsOf` above is the only place that forwards them — unlike\n * `TemplatesOptions`, there is no second merge in `index.ts`, since comments\n * carries no config booleans for that merge to combine. A sixth member has\n * exactly one place to be added: this list and `commentEventsOf`'s destructure,\n * together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below is\n * what forces the check — it fails to compile the moment a member falls\n * outside the five named here.\n */\ntype _CommentsOptionsForwarded =\n Exclude<\n keyof CommentsOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\" | \"onResolved\" | \"onUnresolved\"\n > extends never\n ? true\n : never;\nconst _commentsOptionsForwarded: _CommentsOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `savedBlocks` value.\n *\n * A whitelist, never a spread. `savedBlocks` accepts a boolean, an\n * events-only `SavedBlocksOptions`, or a full `SavedBlocksProvider` — this is\n * only ever called on the first two, since a full provider replaces Cloud's\n * adapter outright and is used as-is (see `consumerSavedBlocks` below). A\n * non-object value (`true`, `undefined`, `false`) carries no keys to pick, so\n * it returns `{}` rather than throwing on the destructure.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onCreated: \"yes\"` would otherwise reach core and throw at\n * saved-block-creation time, inside a call the consumer never made.\n */\nfunction savedBlocksEventsOf(\n value: TemplaticalCloudEditorConfig[\"savedBlocks\"],\n): SavedBlocksOptions {\n if (typeof value !== \"object\" || value === null) return {};\n const { onCreated, onUpdated, onDeleted } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n };\n}\n\n/**\n * Fails to compile when `SavedBlocksOptions` gains a member outside the three\n * named below. `savedBlocksEventsOf` above is the only place that forwards\n * them, so a fourth member has exactly one place to be added: this list and\n * that function's destructure, together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the three named here.\n */\ntype _SavedBlocksOptionsForwarded =\n Exclude<\n keyof SavedBlocksOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\"\n > extends never\n ? true\n : never;\nconst _savedBlocksOptionsForwarded: _SavedBlocksOptionsForwarded = true;\n\n/**\n * Pick `onSent` and `defaultRecipient` off a consumer-supplied `testEmail`\n * value.\n *\n * A whitelist, like `savedBlocksEventsOf` — but note what it does NOT pick:\n * `includeMjml` and `allowedRecipients` stay Cloud's own whenever Cloud's\n * sender is in play, so they are never read here even though\n * `TestEmailOptions` declares them (see `_TestEmailOptionsForwarded` below).\n * `defaultRecipient` has no such conflict — Cloud's provider never defines\n * it, and `useTestEmailFeature` already discards a value outside\n * `allowedRecipients`, so a consumer's choice can only ever pre-fill an\n * address already on Cloud's own signed list, never smuggle in one outside\n * it. `onSent` is a plain notification with no conflict either, so both\n * cross over.\n *\n * The result is assigned ONTO Cloud's own provider with `Object.assign`\n * (never spread together with it) at the call site — that provider's\n * `allowedRecipients` is a live getter over the JWT-derived allowlist, and a\n * spread reads every own property through `[[Get]]`, freezing the getter's\n * current value into a plain property on the new object. `Object.assign`\n * with the cloud provider as the *target* only ever writes the keys this\n * function returns, so the getter is never read and never disturbed.\n */\nfunction testEmailEventsOf(\n value: TemplaticalCloudEditorConfig[\"testEmail\"],\n): Pick<TestEmailOptions, \"onSent\" | \"defaultRecipient\"> {\n if (typeof value !== \"object\" || value === null) return {};\n const { onSent, defaultRecipient } = value;\n return {\n ...(typeof onSent === \"function\" ? { onSent } : {}),\n ...(typeof defaultRecipient === \"string\" ? { defaultRecipient } : {}),\n };\n}\n\n/**\n * Fails to compile when `TestEmailOptions` gains a member outside the four\n * named below. `onSent` and `defaultRecipient` are forwarded by\n * `testEmailEventsOf` above; `includeMjml` and `allowedRecipients` stay\n * Cloud's own whenever Cloud's sender is in play (Cloud renders server-side\n * rather than from a client MJML pass, and the allowlist is the signed one\n * from the project's JWT, not a client-supplied one). A fifth member still\n * forces a deliberate decision the same way a fourth `SavedBlocksOptions`\n * member does: whether it joins the forwarded pair or stays excluded for the\n * same reason as the other two.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the four named here.\n */\ntype _TestEmailOptionsForwarded =\n Exclude<\n keyof TestEmailOptions,\n \"includeMjml\" | \"allowedRecipients\" | \"defaultRecipient\" | \"onSent\"\n > extends never\n ? true\n : never;\nconst _testEmailOptionsForwarded: _TestEmailOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `media` value.\n *\n * A whitelist, never a spread. `media` accepts `false`, an events-only\n * {@link MediaOptions}, or a full {@link MediaProvider} — this is only ever\n * called on the first two, since a full provider replaces Cloud's adapter\n * outright and is used as-is (see `consumerMedia` below). A non-object\n * value (`undefined`, `false`) carries no keys to pick, so it returns `{}`\n * rather than throwing on the destructure.\n *\n * What it does NOT pick: `maxFileSize` and `mimeTypes` stay Cloud's own\n * whenever Cloud's store is in play (Cloud's plan owns those limits), so\n * they are never read here even though `MediaOptions` declares them (see\n * `_MediaOptionsForwarded` below).\n *\n * The result is assigned ONTO Cloud's own provider with `Object.assign`\n * (never spread together with it) at the call site — that provider's\n * `storage` / `maxFileSize` / `mimeTypes` read plan config live, and a\n * spread reads every own property through `[[Get]]`, freezing each\n * getter's current value into a plain property on the new object.\n * `Object.assign` with the cloud provider as the *target* only ever\n * writes the keys this function returns, so those getters are never\n * read and never disturbed.\n */\nfunction mediaEventsOf(\n value: TemplaticalCloudEditorConfig[\"media\"],\n): Pick<MediaOptions, \"onCreated\" | \"onUpdated\" | \"onDeleted\"> {\n if (typeof value !== \"object\" || value === null) return {};\n const { onCreated, onUpdated, onDeleted } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n };\n}\n\n/**\n * Fails to compile when `MediaOptions` gains a member outside the five\n * named below. `onCreated` / `onUpdated` / `onDeleted` are forwarded by\n * `mediaEventsOf` above; `maxFileSize` and `mimeTypes` stay Cloud's own\n * whenever Cloud's store is in play (Cloud's plan owns those limits). A\n * sixth member still forces a deliberate decision the same way a fifth\n * `TestEmailOptions` member does: whether it joins the forwarded trio or\n * stays excluded for the same reason as the other two.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias\n * nothing reads, so a `never` result would sit there silently. The\n * assignment below is what forces the check — it fails to compile the\n * moment a member falls outside the five named here.\n */\ntype _MediaOptionsForwarded =\n Exclude<\n keyof MediaOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\" | \"maxFileSize\" | \"mimeTypes\"\n > extends never\n ? true\n : never;\nconst _mediaOptionsForwarded: _MediaOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `versionHistory`\n * value.\n *\n * A whitelist, never a spread — the config type says `VersionHistoryOptions`,\n * but a JavaScript consumer is unchecked, so the object can carry anything.\n * `versionHistory` never accepts a full provider (see the rejected-keys block\n * below), so unlike `savedBlocksEventsOf` / `testEmailEventsOf` this is\n * always called on the whole config value.\n */\nfunction versionHistoryEventsOf(\n value: VersionHistoryOptions | undefined,\n): VersionHistoryOptions {\n if (!value) return {};\n const { onCreated, onRestored } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onRestored === \"function\" ? { onRestored } : {}),\n };\n}\n\n/**\n * Fails to compile when `VersionHistoryOptions` gains a member outside the\n * two named below. `versionHistoryEventsOf` above is the only place that\n * forwards them, so a third member has exactly one place to be added: this\n * list and that function's destructure, together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the two named here.\n */\ntype _VersionHistoryOptionsForwarded =\n Exclude<keyof VersionHistoryOptions, \"onCreated\" | \"onRestored\"> extends never\n ? true\n : never;\nconst _versionHistoryOptionsForwarded: _VersionHistoryOptionsForwarded = true;\n\n/**\n * A comma list with a final \"and\" — \"a\"; \"a and b\"; \"a, b and c\". The\n * ignored-methods warnings below each name however many storage methods a\n * consumer actually passed, and `Array.join(\" and \")` only reads correctly\n * for exactly two.\n */\nfunction joinWithAnd(items: string[]): string {\n if (items.length < 2) return items.join(\"\");\n if (items.length === 2) return items.join(\" and \");\n return `${items.slice(0, -1).join(\", \")} and ${items[items.length - 1]}`;\n}\n\n/**\n * Cloud's bootstrap and adapter wiring, in one place, run **before the editor\n * mounts**.\n *\n * This replaces `useCloudInitialization`, which owned a second `useEditor`, a\n * second `useEditorCore` and a post-mount async dance with its own loading and\n * error states. The dance is gone: auth, the health check and the plan fetch all\n * resolve here, and a failure rejects `initCloud()` rather than mounting an\n * editor that cannot work. What is left is adapter construction.\n *\n * Two things deliberately stay Cloud-only:\n *\n * - **Entitlements.** In an all-BYO world there are no plans, so `planConfig` is\n * Cloud's commercial layer above the provider set rather than a provider\n * itself. It is down to five booleans, each metering a resource Cloud buys.\n * - **Mid-session failure.** `init()` cannot fail after it mounts and should not\n * grow the ability, so the error overlay lives on this side of the seam.\n */\nexport async function bootstrapCloud(\n options: BootstrapCloudOptions,\n): Promise<CloudBootstrap> {\n const { config, cloudTranslations } = options;\n\n // --- Late-bound editor access ---------------------------------------------\n //\n // The providers below are built before there is an editor to read. Each\n // reaches it through these holders, filled by `attach()` / `ready()` — which is\n // what lets them be handed to `init()` as ordinary config keys.\n let editorRef: UseEditorReturn | null = null;\n let coreRef: UseEditorCoreReturn | null = null;\n let websocketRef: ReturnType<typeof useWebSocket> | null = null;\n let collaboration: CloudCollaborationInstance | null = null;\n let collabWarning: UseCollabUndoWarningReturn | null = null;\n let saveGate: UseCloudSaveGateReturn | null = null;\n\n const sessionError = ref<Error | null>(null);\n const lockedBlocks = ref<Map<string, unknown>>(new Map());\n /**\n * Cloud's presence channel, forward-declared for the comments adapter's\n * `subscribe`. `useWebSocket` can only be built in `attach()` (it needs the\n * editor), while the provider is handed to `init()` before that — so the adapter\n * watches this and rebinds when the real channel lands.\n */\n const commentChannel = ref<RealtimeChannel | null>(null);\n\n function requireEditor(): UseEditorReturn {\n if (!editorRef) {\n throw new Error(\"[Templatical] The Cloud editor is not mounted yet.\");\n }\n return editorRef;\n }\n\n function getTemplateId(): string | null {\n return editorRef?.state.template?.id ?? null;\n }\n\n // --- Auth + plan ----------------------------------------------------------\n\n const authManager = new AuthManager({\n ...config.auth,\n // Only a *fatal* refusal raises the overlay. A 4xx means the endpoint\n // rejected the credentials, so every subsequent request fails the same way\n // and the session really is over. A network blip or a 5xx resolves on its\n // own, and blanking a mounted editor over one interrupts someone mid-edit on\n // a template that is probably unsaved — a worse outcome than the blip.\n //\n // The consumer hears about both: `onError` fires either way, and\n // `AuthManager` re-throws regardless, so a caller that cannot proceed still\n // finds out.\n onError: (error: Error) => {\n if (isFatalAuthError(error)) {\n sessionError.value = error;\n }\n config.onError?.(error);\n },\n });\n\n const planConfigInstance = usePlanConfig({\n authManager,\n onError: config.onError,\n });\n\n await authManager.initialize();\n\n const healthResult = await performHealthCheck({ authManager });\n if (!healthResult.api.ok) {\n throw new Error(\"Health check failed: API is not reachable\");\n }\n if (!healthResult.auth.ok) {\n throw new Error(\n `Health check failed: authentication error${healthResult.auth.error ? ` - ${healthResult.auth.error}` : \"\"}`,\n );\n }\n if (!healthResult.websocket.ok) {\n logger.warn(\n \"WebSocket health check failed:\",\n healthResult.websocket.error ?? \"unknown error\",\n \"-- real-time features will be disabled.\",\n );\n }\n\n await planConfigInstance.fetchConfig();\n\n // The bootstrap itself is what the overlay would have covered, and it just\n // succeeded — so anything `onError` recorded on the way here is stale.\n sessionError.value = null;\n\n // --- Rejected consumer keys ----------------------------------------------\n //\n // `render` is not declared on `TemplaticalCloudEditorConfig`, so it only\n // fires for JavaScript consumers — warned rather than silently dropped,\n // because the symptom (a store that stays empty while Cloud's fills up)\n // reads as a broken provider rather than a rejected one. `templates`,\n // `comments` and `versionHistory` ARE declared, but typed narrowly as\n // `TemplatesOptions`, `CommentsOptions` and `VersionHistoryOptions` — a\n // JavaScript consumer can still hand over a full provider, so its storage\n // methods are named and ignored the same way, while any events they carry\n // reach `eventsOf` / `commentEventsOf` / `versionHistoryEventsOf` below\n // regardless of this check.\n const consumerTemplates = (config as { templates?: Record<string, unknown> })\n .templates;\n // Presence, not `typeof === \"function\"` — see the matching comment on\n // `ignoredCommentMethods` below: a stated-but-ignored decision like\n // `save: false` is as much a signal as a stray function override.\n const ignoredTemplateMethods = [\"load\", \"create\", \"save\"].filter(\n (key) => typeof consumerTemplates?.[key] !== \"undefined\",\n );\n if (ignoredTemplateMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredTemplateMethods.map((key) => `templates.${key}`),\n )} — the template id is the join key for collaboration, ` +\n \"version history, comments, AI rewrite, scoring and the server-side \" +\n \"export, so an id Cloud never issued would degrade all six. Your \" +\n \"event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n const consumerVersionHistory = (\n config as { versionHistory?: Record<string, unknown> }\n ).versionHistory;\n // Presence, not `typeof === \"function\"`: a stated-but-ignored decision like\n // `restore: false` is as much a signal as a stray function override, and\n // both must be named here or the consumer never learns it was dropped.\n const ignoredVersionHistoryMethods = [\n \"list\",\n \"get\",\n \"create\",\n \"restore\",\n ].filter((key) => typeof consumerVersionHistory?.[key] !== \"undefined\");\n if (ignoredVersionHistoryMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredVersionHistoryMethods.map((key) => `versionHistory.${key}`),\n )} — a version is keyed to a template id Cloud issued, so Cloud owns ` +\n \"its history. Your event handlers were kept. Use init() to bring \" +\n \"your own storage.\",\n );\n }\n const consumerComments = (config as { comments?: Record<string, unknown> })\n .comments;\n // Presence, not `typeof === \"function\"`: a stated-but-ignored decision like\n // `create: false` is as much a signal as a stray function override, and both\n // must be named here or the consumer never learns it was dropped.\n const ignoredCommentMethods = [\n \"list\",\n \"create\",\n \"update\",\n \"delete\",\n \"setResolved\",\n \"subscribe\",\n ].filter((key) => typeof consumerComments?.[key] !== \"undefined\");\n if (ignoredCommentMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredCommentMethods.map((key) => `comments.${key}`),\n )} — a comment is keyed to a template id Cloud issued, and its ` +\n \"author is signed by the auth token, so Cloud owns the conversation. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n // Rejected for a different reason than the three above: not the join key, but\n // because Cloud renders on its own for test email, scheduled sends and API\n // exports (`createCloudTestEmailProvider` calls `exportHtml` directly). A\n // consumer provider would have changed `toMjml()` / `toHtml()` and nothing\n // else, so what the user previewed and exported was not what Cloud delivered —\n // and Cloud's output is a deliberate superset (countdown GIFs, composited video\n // thumbnails), so the consumer's was also worse for those blocks.\n if ((config as { render?: unknown }).render) {\n logger.warn(\n \"initCloud does not accept a `render` provider — Cloud renders \" +\n \"server-side for test email, sends and exports, so a supplied renderer \" +\n \"would change only what you preview and export, never what Cloud \" +\n \"delivers. The supplied provider is ignored. For your own MJML, call \" +\n \"renderToMjml(editor.getContent()) from @templatical/renderer.\",\n );\n }\n\n // --- Providers ------------------------------------------------------------\n\n function connectRealtime(template: Template): void {\n const websocketConfig = planConfigInstance.config.value?.websocket;\n if (!websocketRef || !websocketConfig) return;\n websocketRef.connect(template.id, resolveWebSocketConfig(websocketConfig));\n }\n\n const baseTemplates = createCloudTemplatesProvider(authManager);\n const baseCreate = baseTemplates.create;\n const baseSave = baseTemplates.save;\n\n /**\n * Cloud's templates adapter plus the choreography the template id anchors:\n * the websocket joins the template's presence channel. The consumer's\n * `onSaved` / `onCreated` / `onLoaded` ride along via `eventsOf` — core calls\n * them once the editor has settled, so the adapter itself never invokes them.\n *\n * That choreography belongs in the adapter rather than in an editor-side\n * lifecycle composable, because it *is* adapter business — Cloud is what keys\n * realtime off the id it issued. `useCloudLifecycle` existed only to hold it.\n *\n * `save` pre-renders custom blocks, which is why it is wrapped too.\n */\n const templates: TemplatesProvider = {\n ...eventsOf(config.templates),\n load: async (id: string) => {\n const template = await baseTemplates.load(id);\n connectRealtime(template);\n return template;\n },\n create:\n typeof baseCreate === \"function\"\n ? async (input: { name?: string; content: TemplateContent }) => {\n const template = await baseCreate(input);\n connectRealtime(template);\n return template;\n }\n : false,\n save:\n typeof baseSave === \"function\"\n ? async (id: string, patch: TemplatePatch) => {\n if (coreRef && editorRef) {\n await preRenderCustomBlocks(\n editorRef.content.value,\n coreRef.registry,\n );\n }\n return baseSave(id, patch);\n }\n : false,\n };\n\n // Always Cloud's — see the rejected-keys block above. Cloud renders\n // independently for delivery, so a second renderer could only disagree with it.\n const render: RenderProvider = createCloudRenderProvider({\n authManager,\n getTemplateId,\n // Plain `editor.save()`: the templates adapter below already pre-renders\n // custom blocks on every save, which is exactly what the render endpoint\n // needs, since it exports from the stored copy rather than from\n // `payload.content`.\n save: () => requireEditor().save(),\n });\n\n // The consumer's `onCreated` / `onRestored` ride along via\n // `versionHistoryEventsOf` — core calls them once the editor has settled, so\n // the adapter itself never invokes them. `versionHistory` never accepts a\n // full provider (see the rejected-keys block above), so this always merges\n // onto Cloud's own adapter, never onto a consumer's.\n const versionHistory: VersionHistoryProvider = {\n ...versionHistoryEventsOf(config.versionHistory),\n ...createCloudVersionHistoryProvider(authManager),\n };\n\n // Realtime is the adapter's own business: `subscribe` binds the presence channel\n // above, so `useCommentListener` in `@templatical/core` never learns that Pusher\n // exists and a BYO provider with an SSE stream slots into the same seam. The\n // consumer's `onCreated` / `onUpdated` / `onDeleted` / `onResolved` /\n // `onUnresolved` ride along via `commentEventsOf` — core calls them once the\n // editor has settled, so the adapter itself never invokes them.\n const comments: CommentsProvider = {\n ...commentEventsOf(config.comments),\n ...createCloudCommentsProvider({\n authManager,\n channel: commentChannel,\n getSocketId: () => websocketRef?.getSocketId() ?? null,\n }),\n };\n\n // From the JWT, not from config. Cloud signs comment writes against this same\n // claim, so a consumer-supplied identity could only disagree with it — and a\n // token without the claim leaves comments unavailable rather than anonymous.\n const cloudUser: EditorUser | undefined = authManager.userConfig\n ? { id: authManager.userConfig.id, name: authManager.userConfig.name }\n : undefined;\n\n // A consumer may pass their own store instead of a boolean, in which case it\n // replaces Cloud's outright — discriminated on `list`, the one required\n // method every full provider carries, never on `typeof === \"object\"`: an\n // events-only `SavedBlocksOptions` (`{ onCreated }`) is an object too, and\n // reading it as the provider would leave `list` undefined and crash the\n // library on first browse. That path is deliberately NOT plan-gated:\n // `savedModules` licenses Cloud's *storage*, and someone else's backend\n // isn't Cloud's to sell — `isSavedBlocksAvailable` below keys off this same\n // discriminated value for that reason.\n const consumerSavedBlocks =\n typeof (config.savedBlocks as SavedBlocksProvider | undefined)?.list ===\n \"function\"\n ? (config.savedBlocks as SavedBlocksProvider)\n : null;\n // A malformed provider — e.g. `create` / `update` / `delete` with no\n // working `list` — fails the discriminator above and falls through to\n // Cloud's own store, so those methods are silently unused rather than\n // replacing anything. Named here the same way `templates` / `comments` /\n // `versionHistory` name their own ignored methods, so the drop isn't a\n // console-free mystery.\n if (\n consumerSavedBlocks === null &&\n typeof config.savedBlocks === \"object\" &&\n config.savedBlocks !== null\n ) {\n const suppliedSavedBlocks = config.savedBlocks as Record<string, unknown>;\n const ignoredSavedBlocksMethods = [\n \"list\",\n \"create\",\n \"update\",\n \"delete\",\n ].filter((key) => typeof suppliedSavedBlocks[key] !== \"undefined\");\n if (ignoredSavedBlocksMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredSavedBlocksMethods.map((key) => `savedBlocks.${key}`),\n )} — a provider needs a working list to replace Cloud's store, and ` +\n \"this value has none, so it configures Cloud's own store instead. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n }\n // The consumer's `onCreated` / `onUpdated` / `onDeleted` ride along via\n // `savedBlocksEventsOf` when Cloud's own adapter is used — core calls them\n // once the editor has settled, so the adapter itself never invokes them. A\n // full consumer provider carries its own events already and is used as-is,\n // so this merge only ever runs on Cloud's side of the `??`.\n const savedBlocks: SavedBlocksProvider | undefined =\n config.savedBlocks === false\n ? undefined\n : (consumerSavedBlocks ?? {\n ...savedBlocksEventsOf(config.savedBlocks),\n ...createCloudSavedBlocksProvider(authManager),\n });\n\n // Cloud's test-email *config* — plan enablement plus the signed allowlist, both\n // carried by the JWT `authManager.initialize()` already resolved above. Hence\n // the constant `isAuthReady`: there is no window where it is false.\n const testEmailConfig = useTestEmail({\n authManager,\n isAuthReady: ref(true),\n });\n\n // Cloud's own send path renders through the export endpoint directly: the\n // adapter derives HTML from the *saved* template and applies\n // `onBeforeTestEmail` to it, which is a narrower job than the render contract.\n const exporter = useExport({ authManager });\n\n // Discriminated on `send`, the one required method every full provider\n // carries — never on raw truthiness, which an events-only `TestEmailOptions`\n // (`{ onSent }`) also satisfies and would leave `send` undefined, crashing\n // the dialog on send. `isTestEmailAvailable` below keys off this same\n // discriminated value so an events-only value stays plan-gated rather than\n // reading as \"consumer's own sender\".\n const consumerTestEmail =\n typeof (config.testEmail as TestEmailProvider | undefined)?.send ===\n \"function\"\n ? (config.testEmail as TestEmailProvider)\n : null;\n // `send` reaching here means it failed the discriminator above — e.g.\n // `send: null` — so it is named the same way a malformed `savedBlocks`\n // value's storage methods are. `includeMjml` / `allowedRecipients` are\n // named for a different reason: they are not part of this key's options\n // arm (see `cloudConfig.ts`), but TypeScript does not actually refuse\n // them — both are valid members of the sibling `TestEmailProvider` arm, so\n // the union's excess-property check passes them through regardless of\n // which arm the caller intended. All three log a warning naming them\n // rather than dropping with no console trace.\n if (\n consumerTestEmail === null &&\n typeof config.testEmail === \"object\" &&\n config.testEmail !== null\n ) {\n const suppliedTestEmail = config.testEmail as Record<string, unknown>;\n const ignoredTestEmailMembers = [\n \"send\",\n \"includeMjml\",\n \"allowedRecipients\",\n ].filter((key) => typeof suppliedTestEmail[key] !== \"undefined\");\n if (ignoredTestEmailMembers.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredTestEmailMembers.map((key) => `testEmail.${key}`),\n )} — a provider needs a working send to replace Cloud's sender ` +\n \"outright, and Cloud renders server-side with the signed \" +\n \"allowlist from your project's JWT either way, so none of these \" +\n \"apply here. Your event handlers were kept.\",\n );\n }\n }\n const testEmail: TestEmailProvider =\n consumerTestEmail ??\n // `Object.assign`, not a spread: `createCloudTestEmailProvider`'s\n // `allowedRecipients` is a live getter (see `testEmailEventsOf`'s doc\n // comment for why a spread would freeze it). The cloud provider is the\n // assignment *target* here, so its getter is never read — only the keys\n // `testEmailEventsOf` returns are ever written onto it.\n //\n // Asymmetric with `savedBlocks` / `versionHistory` on purpose, not by\n // drift: those two spread Cloud's provider LAST, so even a whitelist that\n // let something unexpected through could never displace a Cloud method —\n // two lines of defence. Here `testEmailEventsOf`'s return type is the\n // only barrier, because Cloud is the assignment target rather than a\n // second spread source. Copying the sibling shape (`{ ...events,\n // ...createCloudTestEmailProvider(...) }`) would reintroduce the exact\n // getter-freezing bug this construction exists to avoid.\n Object.assign(\n createCloudTestEmailProvider({\n authManager,\n getTemplateId,\n save: () => requireEditor().save(),\n exportHtml: (templateId: string) =>\n exporter.exportHtml(templateId, resolveExportFonts(config.fonts)),\n allowedEmails: testEmailConfig.allowedEmails,\n getSignature: testEmailConfig.getSignature,\n onBeforeTestEmail: config.onBeforeTestEmail,\n }),\n testEmailEventsOf(config.testEmail),\n );\n\n // A consumer may pass their own store instead of omitting the key or\n // passing `false`, in which case it replaces Cloud's outright —\n // discriminated on `list`, the one required method every full provider\n // carries, never on `typeof === \"object\"`: an events-only `MediaOptions`\n // (`{ onCreated }`) is an object too, and reading it as the provider\n // would leave `list` undefined and crash the library on first browse.\n // That path is deliberately NOT plan-gated: there is no media plan\n // feature. The plan licenses Cloud's *storage*, and someone else's\n // backend isn't Cloud's to sell.\n const consumerMedia =\n typeof (config.media as MediaProvider | undefined)?.list === \"function\"\n ? (config.media as MediaProvider)\n : null;\n // A malformed provider — e.g. `create` / `update` / `delete` with no\n // working `list` — fails the discriminator above and falls through to\n // Cloud's own store, so those methods are silently unused rather than\n // replacing anything. Named here the same way `savedBlocks` names its\n // own ignored methods, so the drop isn't a console-free mystery.\n // `maxFileSize` / `mimeTypes` are named for a different reason: they\n // are valid `MediaOptions` members but Cloud's plan owns those limits\n // whenever Cloud's store is in play.\n if (\n consumerMedia === null &&\n typeof config.media === \"object\" &&\n config.media !== null\n ) {\n const suppliedMedia = config.media as Record<string, unknown>;\n const ignoredMediaMethods = [\"list\", \"create\", \"update\", \"delete\"].filter(\n (key) => typeof suppliedMedia[key] !== \"undefined\",\n );\n if (ignoredMediaMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredMediaMethods.map((key) => `media.${key}`),\n )} — a provider needs a working list to replace Cloud's store, and ` +\n \"this value has none, so it configures Cloud's own store instead. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n const ignoredMediaLimits = [\"maxFileSize\", \"mimeTypes\"].filter(\n (key) => typeof suppliedMedia[key] !== \"undefined\",\n );\n if (ignoredMediaLimits.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredMediaLimits.map((key) => `media.${key}`),\n )} — Cloud's plan owns those limits whenever Cloud's store is in ` +\n \"play. Your event handlers were kept.\",\n );\n }\n }\n const media: MediaProvider | undefined =\n config.media === false\n ? undefined\n : (consumerMedia ??\n // `Object.assign`, not a spread: `createCloudMediaProvider`'s\n // `storage` / `maxFileSize` / `mimeTypes` read plan config live\n // (see `mediaEventsOf`'s doc comment for why a spread would freeze\n // the getters). The cloud provider is the assignment *target*\n // here, so its getters are never read — only the keys\n // `mediaEventsOf` returns are ever written onto it.\n Object.assign(\n createCloudMediaProvider(\n authManager,\n () => planConfigInstance.config.value,\n ),\n mediaEventsOf(config.media),\n ));\n\n // --- Setup-time wiring ----------------------------------------------------\n\n const aiConfig = useAiConfig(config.ai);\n const scoringInstance = useTemplateScoring({ authManager, getTemplateId });\n\n const featureFlags = useCloudFeatureFlags({\n planConfigInstance,\n aiConfig,\n getTemplateId,\n });\n\n const isCollaborationEnabled = computed(\n () =>\n !!config.collaboration?.enabled &&\n planConfigInstance.hasFeature(\"collaboration\"),\n );\n\n function attach(context: CloudAttachContext): CloudAttachment {\n const editor = context.editor;\n editorRef = editor;\n\n provide(CLOUD_TRANSLATIONS_KEY, cloudTranslations);\n provide(AUTH_MANAGER_KEY, authManager);\n provide(AI_CONFIG_KEY, aiConfig);\n provide(SCORING_KEY, scoringInstance);\n\n const websocket = useWebSocket({ authManager, onError: config.onError });\n websocketRef = websocket;\n\n // Feeds the comments adapter's `subscribe`, which was handed to `init()` before\n // this socket existed.\n watch(\n websocket.channel,\n (channel) => {\n commentChannel.value = channel;\n },\n { immediate: true },\n );\n\n if (config.mcp?.enabled) {\n useMcpListener({\n editor,\n channel: websocket.channel,\n onOperation: config.mcp.onOperation,\n });\n }\n\n // Order matters: the broadcast wrapper replaces the editor's mutators so they\n // publish to peers, and `useEditorCore`'s history interceptor then wraps them\n // again to push history entries. Reversing it would push history for remote\n // operations and drift the two peers apart.\n if (config.collaboration?.enabled) {\n collaboration = useCollaboration({\n authManager,\n editor,\n channel: websocket.channel,\n onError: config.onError,\n onCollaboratorJoined: config.collaboration.onCollaboratorJoined,\n onCollaboratorLeft: config.collaboration.onCollaboratorLeft,\n onBlockLocked: config.collaboration.onBlockLocked,\n onBlockUnlocked: config.collaboration.onBlockUnlocked,\n }) as CloudCollaborationInstance;\n\n watch(\n () => collaboration!.lockedBlocks.value,\n (next) => {\n lockedBlocks.value = next;\n },\n { immediate: true },\n );\n\n useCollaborationBroadcast(editor, collaboration);\n }\n\n const panelState = useCloudPanelState();\n\n return {\n websocket,\n panelState,\n featureFlags,\n collaboration,\n isCollaborationEnabled,\n };\n }\n\n function ready(context: CloudReadyContext): CloudReady {\n const { core, capabilities } = context;\n coreRef = core;\n\n saveGate = useCloudSaveGate({\n issues: core.templateLint ? core.templateLint.issues : ref([]),\n planConfig: planConfigInstance.config,\n });\n\n collabWarning = useCollabUndoWarning({\n isCollaborationEnabled,\n getCollaboratorCount: () =>\n collaboration?.collaborators.value.length ?? 0,\n canUndo: core.history.canUndo,\n });\n\n // Mutated in place rather than re-provided: `useEditorCore` already provided\n // this exact object, so components injecting it see Cloud's entries on their\n // first render. Same pattern `versionHistory` uses in `Editor.vue`.\n //\n // `capabilities.comments` is *not* set here any more: comments became a shared\n // provider-backed feature, so `Editor.vue` builds the capability from\n // `useCommentsFeature` exactly as it does for saved blocks and test email, and\n // Cloud contributes only the two predicates below.\n capabilities.plan = planConfigInstance;\n capabilities.ai = aiConfig;\n\n // Registered unconditionally. `custom_blocks` and `theme_customization` used\n // to gate these — entitlements on editor capability the free editor grants,\n // and the only two things `applyPlanGates` would ever have had to do.\n if (config.customBlocks?.length) {\n core.registerCustomBlocks(config.customBlocks);\n }\n if (config.theme) {\n core.themeOverrides.value = config.theme;\n }\n\n return {\n saveGate,\n collabWarning,\n sessionError,\n retry: async () => {\n try {\n await authManager.initialize();\n sessionError.value = null;\n } catch (error) {\n sessionError.value =\n error instanceof Error ? error : new Error(\"Authentication failed\");\n }\n },\n };\n }\n\n const runtime: CloudRuntime = {\n lockedBlocks,\n isSavedBlocksAvailable: consumerSavedBlocks\n ? () => true\n : () =>\n config.savedBlocks !== false &&\n planConfigInstance.hasFeature(\"savedModules\"),\n isTestEmailAvailable: consumerTestEmail\n ? // Their sender, their rules — the `testEmail` plan feature licenses\n // Cloud's sending, and \"the template must be saved\" is a constraint of\n // Cloud's server-side render, not of an arbitrary backend.\n () => true\n : // All three matter and none implies another: the plan may grant the\n // feature while the project's token omits a recipient config, and Cloud\n // renders from the *saved* template so there must be one.\n () =>\n testEmailConfig.isEnabled.value &&\n featureFlags.canSendTestEmail.value &&\n featureFlags.hasTemplateSaved.value,\n // Three conditions, none implying another: the consumer may switch the feature\n // off, the plan meters comment storage and its realtime fan-out, and Cloud\n // anchors a comment to the *saved* template. (Whether a `user` exists is the\n // shared feature's own gate, not Cloud's.)\n isCommentsAvailable: () =>\n config.comments !== false &&\n planConfigInstance.hasFeature(\"commenting\") &&\n featureFlags.hasTemplateSaved.value,\n // A comment is anchored server-side, so a block that exists only on the canvas\n // has nothing stored to show. This is the last thing the deleted cloud editor\n // core carried (`savedBlockIds`), and it was always a comments concern rather\n // than an editor one.\n isBlockSaved: (blockId: string) =>\n collectSavedBlockIds(editorRef?.state.template ?? null).has(blockId),\n getSaveGate: () => saveGate,\n isRemoteOperation: () =>\n collaboration?._isProcessingRemoteOperation() ?? false,\n onBeforeUndo: () => collabWarning?.showCollabUndoWarning(),\n attach,\n ready,\n destroy() {\n websocketRef?.disconnect();\n config.onUnmount?.();\n },\n };\n\n return {\n runtime,\n providers: {\n templates,\n render,\n versionHistory,\n ...(savedBlocks ? { savedBlocks } : {}),\n testEmail,\n comments,\n ...(media ? { media } : {}),\n },\n user: cloudUser,\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAgBkC,GACd,GAC4B;CAC5B,IAAM,EAAE,uBAAoB,aAAU,qBAAkBC;CAkBxD,OAAO;EACL,oBAjByBhC,QAEvBiC,EAAmB,WAAW,cAAc,KAC5CC,EAAS,kBAAkB,KAc7B;EACA,kBAbuBlC,QACvBiC,EAAmB,WAAW,WAAW,CAYzC;EACA,kBAXuBjC,QAAemC,EAAc,MAAM,IAW1D;EACA,eAXoBnC,QACdiC,EAAmB,OAAO,OAAO,OAAO,gBAAgB,IAU9D;EACA,eAToBjC,QACdiC,EAAmB,OAAO,OAAO,iBAAiB,CAQxD;CACF;AACF;;;ACvCA,SAAgBG,KAA+C;CAC7D,IAAMC,IAActC,EAAuB,IAAI,GAEzCuC,IAAatC,EAAS;EAC1B,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,YAAY;CACnD,CAAC,GACKC,IAAmBxC,EAAS;EAChC,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,YAAY;CACnD,CAAC,GACKE,IAAsBzC,EAAS;EACnC,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,qBAAqB;CAC5D,CAAC,GACKG,IAAe1C,EAAS;EAC5B,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,aAAa;CACpD,CAAC,GAEKI,IAAa5C,EAAI,EAAK,GACtB6C,IAAY7C,EAAwB,IAAI,GAExC8C,IAAiB7C,QAAeqC,EAAY,UAAU,IAAI,GAE1DS,IAAkB9C,QAAiC;EACvD,IAAM+C,IAAIV,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,UAAU;IAER,AADAF,GAAc,WAAW,GACzBS,EAAO,YAAY;GACrB;EAIA;EACA,WAAW;GACT;GACA;GACA;GACA,GAAI0B,IAAc,EAAE,eAAY,IAAI,CAAC;GACrC;GACA;GACA,GAAIY,IAAQ,EAAE,SAAM,IAAI,CAAC;EAC3B;EACA,MAAMhB;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"createCloudRuntime-bJN9EM1H.js","names":["watch","provide","ref","computed","useTimeoutFn","onClickOutside","SCORING_KEY","AUTH_MANAGER_KEY","AI_CONFIG_KEY","CLOUD_TRANSLATIONS_KEY","COLLAB_UNDO_WARNING_MS","logger","preRenderCustomBlocks","isFatalAuthError","AuthManager","useTestEmail","resolveExportFonts","createCloudMediaProvider","createCloudSavedBlocksProvider","createCloudCommentsProvider","useCollaboration","createCloudTestEmailProvider","useExport","useCollaborationBroadcast","performHealthCheck","createCloudVersionHistoryProvider","useWebSocket","usePlanConfig","createCloudRenderProvider","useMcpListener","createCloudTemplatesProvider","useTemplateScoring","resolveWebSocketConfig","useAiConfig","useCloudFeatureFlags","options","planConfigInstance","aiConfig","getTemplateId","useCloudPanelState","activePanel","aiChatOpen","v","scoringPanelOpen","designReferenceOpen","commentsOpen","aiMenuOpen","aiMenuRef","rightPanelOpen","activeAiFeature","p","aiButtonActive","toggleAiMenu","handleAiFeatureSelect","feature","useCloudSaveGate","modalOpen","pending","blockOnError","opts","blockingIssues","i","shouldBlock","tryRunSave","run","runUnlessBlocked","confirmAndSave","cancel","useCollabUndoWarning","collabUndoWarningFired","collabUndoWarningVisible","startCollabUndoWarningTimeout","showCollabUndoWarning","isCollaborationEnabled","getCollaboratorCount","canUndo","collectSavedBlockIds","ids","collectFromBlocks","template","blocks","block","column","eventsOf","value","onSaved","onCreated","onLoaded","commentEventsOf","onUpdated","onDeleted","onResolved","onUnresolved","savedBlocksEventsOf","testEmailEventsOf","onSent","defaultRecipient","mediaEventsOf","versionHistoryEventsOf","onRestored","joinWithAnd","items","bootstrapCloud","editorRef","coreRef","websocketRef","collaboration","collabWarning","saveGate","sessionError","lockedBlocks","commentChannel","requireEditor","authManager","config","error","healthResult","consumerTemplates","ignoredTemplateMethods","key","consumerVersionHistory","ignoredVersionHistoryMethods","consumerComments","ignoredCommentMethods","connectRealtime","websocketConfig","baseTemplates","baseCreate","baseSave","templates","id","input","patch","render","versionHistory","comments","cloudUser","consumerSavedBlocks","suppliedSavedBlocks","ignoredSavedBlocksMethods","savedBlocks","testEmailConfig","exporter","consumerTestEmail","suppliedTestEmail","ignoredTestEmailMembers","testEmail","templateId","consumerMedia","suppliedMedia","ignoredMediaMethods","ignoredMediaLimits","media","scoringInstance","featureFlags","attach","editor","context","cloudTranslations","websocket","channel","next","ready","core","blockId"],"sources":["../../../src/cloud/composables/useCloudFeatureFlags.ts","../../../src/cloud/composables/useCloudPanelState.ts","../../../src/cloud/composables/useCloudSaveGate.ts","../../../src/cloud/composables/useCollabUndoWarning.ts","../../../src/cloud/collectSavedBlockIds.ts","../../../src/cloud/createCloudRuntime.ts"],"sourcesContent":["import { computed, type ComputedRef } from \"vue\";\nimport type {\n UsePlanConfigReturn,\n UseAiConfigReturn,\n} from \"@templatical/core/cloud\";\n\nexport interface UseCloudFeatureFlagsOptions {\n planConfigInstance: UsePlanConfigReturn;\n aiConfig: UseAiConfigReturn;\n /** The loaded template's id, or `null` before one exists. */\n getTemplateId: () => string | null;\n}\n\nexport interface UseCloudFeatureFlagsReturn {\n canUseAiGeneration: ComputedRef<boolean>;\n canSendTestEmail: ComputedRef<boolean>;\n hasTemplateSaved: ComputedRef<boolean>;\n templateLimit: ComputedRef<number | null>;\n templateCount: ComputedRef<number>;\n}\n\n/**\n * Every entitlement check Cloud makes, in one place.\n *\n * The containment rule this exists for: entitlement checks go through here,\n * never inline in a component and never across a package boundary. With five\n * plan features left there is little excuse to break it.\n *\n * Save status is deliberately not here — it lives on `useTemplatesFeature`, which\n * the one shared header reads, and was never an entitlement. Footer branding is\n * likewise not gated: `config.branding !== false` decides it on any plan.\n */\nexport function useCloudFeatureFlags(\n options: UseCloudFeatureFlagsOptions,\n): UseCloudFeatureFlagsReturn {\n const { planConfigInstance, aiConfig, getTemplateId } = options;\n\n const canUseAiGeneration = computed(\n () =>\n planConfigInstance.hasFeature(\"aiGeneration\") &&\n aiConfig.hasAnyMenuFeature.value,\n );\n const canSendTestEmail = computed(() =>\n planConfigInstance.hasFeature(\"testEmail\"),\n );\n const hasTemplateSaved = computed(() => getTemplateId() !== null);\n const templateLimit = computed(\n () => planConfigInstance.config.value?.limits.maxTemplates ?? null,\n );\n const templateCount = computed(\n () => planConfigInstance.config.value?.templateCount ?? 0,\n );\n\n return {\n canUseAiGeneration,\n canSendTestEmail,\n hasTemplateSaved,\n templateLimit,\n templateCount,\n };\n}\n","import { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport { onClickOutside } from \"@vueuse/core\";\nimport type { AiFeature } from \"../components/AiFeatureMenu.vue\";\n\nexport interface UseCloudPanelStateReturn {\n activePanel: Ref<RightPanel | null>;\n aiChatOpen: ComputedRef<boolean> & { value: boolean };\n scoringPanelOpen: ComputedRef<boolean> & { value: boolean };\n designReferenceOpen: ComputedRef<boolean> & { value: boolean };\n commentsOpen: ComputedRef<boolean> & { value: boolean };\n aiMenuOpen: Ref<boolean>;\n aiMenuRef: Ref<HTMLElement | null>;\n rightPanelOpen: ComputedRef<boolean>;\n activeAiFeature: ComputedRef<AiFeature | null>;\n aiButtonActive: ComputedRef<boolean>;\n toggleAiMenu: () => void;\n handleAiFeatureSelect: (feature: AiFeature) => void;\n}\n\ntype RightPanel = \"ai-chat\" | \"scoring\" | \"design-reference\" | \"comments\";\n\nexport function useCloudPanelState(): UseCloudPanelStateReturn {\n const activePanel = ref<RightPanel | null>(null);\n\n const aiChatOpen = computed({\n get: () => activePanel.value === \"ai-chat\",\n set: (v) => (activePanel.value = v ? \"ai-chat\" : null),\n });\n const scoringPanelOpen = computed({\n get: () => activePanel.value === \"scoring\",\n set: (v) => (activePanel.value = v ? \"scoring\" : null),\n });\n const designReferenceOpen = computed({\n get: () => activePanel.value === \"design-reference\",\n set: (v) => (activePanel.value = v ? \"design-reference\" : null),\n });\n const commentsOpen = computed({\n get: () => activePanel.value === \"comments\",\n set: (v) => (activePanel.value = v ? \"comments\" : null),\n });\n\n const aiMenuOpen = ref(false);\n const aiMenuRef = ref<HTMLElement | null>(null);\n\n const rightPanelOpen = computed(() => activePanel.value !== null);\n\n const activeAiFeature = computed<AiFeature | null>(() => {\n const p = activePanel.value;\n if (p === \"ai-chat\" || p === \"design-reference\" || p === \"scoring\")\n return p;\n return null;\n });\n\n const aiButtonActive = computed(\n () =>\n aiMenuOpen.value ||\n activePanel.value === \"ai-chat\" ||\n activePanel.value === \"design-reference\" ||\n activePanel.value === \"scoring\",\n );\n\n function toggleAiMenu(): void {\n aiMenuOpen.value = !aiMenuOpen.value;\n }\n\n function handleAiFeatureSelect(feature: AiFeature): void {\n aiMenuOpen.value = false;\n activePanel.value = activePanel.value === feature ? null : feature;\n }\n\n onClickOutside(aiMenuRef, () => {\n aiMenuOpen.value = false;\n });\n\n return {\n activePanel,\n aiChatOpen,\n scoringPanelOpen,\n designReferenceOpen,\n commentsOpen,\n aiMenuOpen,\n aiMenuRef,\n rightPanelOpen,\n activeAiFeature,\n aiButtonActive,\n toggleAiMenu,\n handleAiFeatureSelect,\n };\n}\n","import { computed, ref, type ComputedRef, type Ref } from \"vue\";\nimport type { PlanConfig } from \"@templatical/types\";\nimport type { LintIssue } from \"../../composables/useTemplateLint\";\n\nexport interface UseCloudSaveGateOptions {\n /** Reactive accessibility issues from `useTemplateLint`. */\n issues: Ref<LintIssue[]>;\n /** Reactive plan config from the server. */\n planConfig: Ref<PlanConfig | null>;\n}\n\nexport interface UseCloudSaveGateReturn {\n /** True when the gate would block a save click given current state. */\n shouldBlock: ComputedRef<boolean>;\n /** Errors that would block the save. Empty when `shouldBlock` is false. */\n blockingIssues: ComputedRef<LintIssue[]>;\n /** Modal visibility — toggled by `tryRunSave` and `cancel`. */\n modalOpen: Ref<boolean>;\n /**\n * Wraps a save callback. Returns `true` when the save was invoked\n * (blocking disabled or no errors), `false` when the modal opened\n * instead. Caller can `await` the returned promise to know when the\n * save settled.\n */\n tryRunSave: (run: () => Promise<unknown> | unknown) => Promise<boolean>;\n /**\n * Runs the save only when the gate would not block, and does **nothing** when\n * it would — no modal, no save, nothing pending. Returns whether it ran.\n *\n * This is the autosave path. A modal on a debounce timer would interrupt\n * typing, but simply saving anyway would demote `blockOnError` from a server\n * policy to a manual-save-only speed bump. Skipping leaves the template dirty\n * and the header saying \"unsaved\", which is true, and the reason stays visible\n * in the Issues panel. The next edit re-arms the debounce, so fixing the issue\n * is what lets the save through — no retry timer needed.\n */\n runUnlessBlocked: (run: () => Promise<unknown> | unknown) => Promise<boolean>;\n /** Force-run the pending save, bypassing the gate. */\n confirmAndSave: () => Promise<void>;\n /** Dismiss the modal without saving. */\n cancel: () => void;\n}\n\n/**\n * Cloud-only save-gate. When `planConfig.accessibility.blockOnError === true`\n * and the linter reports any error-severity issues, intercept the save\n * click and surface a confirmation modal listing the blockers. The user\n * can dismiss to fix issues, or click \"Save anyway\" to bypass — the gate\n * does NOT enforce a hard block, it surfaces a deliberate choice.\n *\n * Server policy is the source of truth for `blockOnError`; consumer-side\n * `accessibility` options can't override it.\n */\nexport function useCloudSaveGate(\n opts: UseCloudSaveGateOptions,\n): UseCloudSaveGateReturn {\n const modalOpen = ref(false);\n let pending: (() => Promise<unknown> | unknown) | null = null;\n\n const blockOnError = computed(\n () => opts.planConfig.value?.accessibility?.blockOnError === true,\n );\n\n const blockingIssues = computed(() =>\n blockOnError.value\n ? opts.issues.value.filter((i) => i.severity === \"error\")\n : [],\n );\n\n const shouldBlock = computed(() => blockingIssues.value.length > 0);\n\n async function tryRunSave(\n run: () => Promise<unknown> | unknown,\n ): Promise<boolean> {\n if (!shouldBlock.value) {\n await run();\n return true;\n }\n pending = run;\n modalOpen.value = true;\n return false;\n }\n\n async function runUnlessBlocked(\n run: () => Promise<unknown> | unknown,\n ): Promise<boolean> {\n if (shouldBlock.value) return false;\n await run();\n return true;\n }\n\n async function confirmAndSave(): Promise<void> {\n const run = pending;\n pending = null;\n modalOpen.value = false;\n if (run) {\n await run();\n }\n }\n\n function cancel(): void {\n pending = null;\n modalOpen.value = false;\n }\n\n return {\n shouldBlock,\n blockingIssues,\n modalOpen,\n tryRunSave,\n runUnlessBlocked,\n confirmAndSave,\n cancel,\n };\n}\n","import { type ComputedRef, type Ref, ref } from \"vue\";\nimport { useTimeoutFn } from \"@vueuse/core\";\nimport { COLLAB_UNDO_WARNING_MS } from \"../../constants/timeouts\";\n\nexport interface UseCollabUndoWarningOptions {\n /** Whether collaboration is currently enabled (reactive). */\n isCollaborationEnabled: ComputedRef<boolean>;\n /** Returns the current list of collaborators. */\n getCollaboratorCount: () => number;\n /** Whether the history stack has entries to undo. */\n canUndo: ComputedRef<boolean>;\n}\n\nexport interface UseCollabUndoWarningReturn {\n collabUndoWarningVisible: Ref<boolean>;\n showCollabUndoWarning: () => void;\n}\n\nexport function useCollabUndoWarning(\n options: UseCollabUndoWarningOptions,\n): UseCollabUndoWarningReturn {\n const { isCollaborationEnabled, getCollaboratorCount, canUndo } = options;\n\n const collabUndoWarningFired = ref(false);\n const collabUndoWarningVisible = ref(false);\n\n const { start: startCollabUndoWarningTimeout } = useTimeoutFn(\n () => {\n collabUndoWarningVisible.value = false;\n },\n COLLAB_UNDO_WARNING_MS,\n { immediate: false },\n );\n\n function showCollabUndoWarning(): void {\n if (\n collabUndoWarningFired.value ||\n !isCollaborationEnabled.value ||\n getCollaboratorCount() === 0 ||\n !canUndo.value\n ) {\n return;\n }\n\n collabUndoWarningFired.value = true;\n collabUndoWarningVisible.value = true;\n startCollabUndoWarningTimeout();\n }\n\n return {\n collabUndoWarningVisible,\n showCollabUndoWarning,\n };\n}\n","/**\n * Just enough of a stored template to walk its ids — deliberately structural\n * rather than `Template`, because the caller reads `editor.state`, which is\n * `DeepReadonly` and so not assignable to the mutable contract type.\n *\n * `children` is a union: a section stores columns (`Block[][]`); a layout\n * `wrapper` stores a flat `Block[]`. Both appear on the `Block` union, so a\n * shape that only named the section form is not assignable from\n * `DeepReadonly<Template>`.\n */\ninterface SavedBlockIdNode {\n readonly id: string;\n readonly type: string;\n readonly children?:\n readonly SavedBlockIdNode[] | readonly (readonly SavedBlockIdNode[])[];\n}\n\ninterface SavedBlockIdSource {\n content?: {\n blocks?: readonly SavedBlockIdNode[];\n };\n}\n\n/**\n * Every block id present in the **stored** template, sections' children\n * included.\n *\n * This is the last thing the deleted Cloud editor core carried over the OSS one\n * (`savedBlockIds`), and it never belonged there: its only reader gates a\n * comment filter on whether the block exists server-side, which makes it a\n * *comments* dependency. It travels with that feature accordingly, and reaches\n * `CommentsSidebar` through `capabilities.comments.isBlockSaved`.\n *\n * Derived on demand rather than memoised: `state.template` only changes on a\n * create / load / save round-trip, and the one caller runs on a user filtering\n * the comments panel.\n */\nexport function collectSavedBlockIds(\n template: SavedBlockIdSource | null | undefined,\n): Set<string> {\n const ids = new Set<string>();\n collectFromBlocks(template?.content?.blocks, ids);\n return ids;\n}\n\nfunction collectFromBlocks(\n blocks: readonly SavedBlockIdNode[] | undefined,\n ids: Set<string>,\n): void {\n if (!blocks) return;\n for (const block of blocks) {\n ids.add(block.id);\n if (!block.children) continue;\n if (block.type === \"section\") {\n for (const column of block.children as readonly (readonly SavedBlockIdNode[])[]) {\n collectFromBlocks(column, ids);\n }\n continue;\n }\n if (block.type === \"wrapper\") {\n collectFromBlocks(block.children as readonly SavedBlockIdNode[], ids);\n }\n }\n}\n","import { computed, provide, ref, watch } from \"vue\";\nimport {\n AuthManager,\n isFatalAuthError,\n performHealthCheck,\n useAiConfig,\n useCollaboration,\n useCollaborationBroadcast,\n useExport,\n useMcpListener,\n usePlanConfig,\n resolveExportFonts,\n resolveWebSocketConfig,\n createCloudCommentsProvider,\n createCloudMediaProvider,\n createCloudRenderProvider,\n createCloudSavedBlocksProvider,\n createCloudTemplatesProvider,\n createCloudTestEmailProvider,\n createCloudVersionHistoryProvider,\n useTemplateScoring,\n useTestEmail,\n useWebSocket,\n type RealtimeChannel,\n} from \"@templatical/core/cloud\";\nimport type { UseEditorReturn } from \"@templatical/core\";\nimport type {\n CommentsOptions,\n CommentsProvider,\n EditorUser,\n MediaOptions,\n MediaProvider,\n RenderProvider,\n SavedBlocksOptions,\n SavedBlocksProvider,\n Template,\n TemplateContent,\n TemplatePatch,\n TemplatesOptions,\n TemplatesProvider,\n TestEmailOptions,\n TestEmailProvider,\n VersionHistoryOptions,\n VersionHistoryProvider,\n} from \"@templatical/types\";\n\nimport type { CloudTranslations } from \"../i18n\";\nimport { preRenderCustomBlocks } from \"../utils/preRenderCustomBlocks\";\nimport { logger } from \"../utils/logger\";\nimport type { UseEditorCoreReturn } from \"../composables/useEditorCore\";\nimport {\n AI_CONFIG_KEY,\n AUTH_MANAGER_KEY,\n CLOUD_TRANSLATIONS_KEY,\n SCORING_KEY,\n} from \"../keys\";\n\nimport { useCloudFeatureFlags } from \"./composables/useCloudFeatureFlags\";\nimport { useCloudPanelState } from \"./composables/useCloudPanelState\";\nimport {\n useCloudSaveGate,\n type UseCloudSaveGateReturn,\n} from \"./composables/useCloudSaveGate\";\nimport {\n useCollabUndoWarning,\n type UseCollabUndoWarningReturn,\n} from \"./composables/useCollabUndoWarning\";\nimport { collectSavedBlockIds } from \"./collectSavedBlockIds\";\nimport type {\n CloudAttachContext,\n CloudAttachment,\n CloudCollaborationInstance,\n CloudReady,\n CloudReadyContext,\n CloudRuntime,\n} from \"./runtime\";\nimport type { TemplaticalCloudEditorConfig } from \"./cloudConfig\";\n\nexport interface BootstrapCloudOptions {\n config: TemplaticalCloudEditorConfig;\n cloudTranslations: CloudTranslations;\n}\n\n/**\n * What {@link bootstrapCloud} hands back: a set of ordinary `init()` config\n * values, plus the runtime for the few things that must run inside the editor\n * component's `setup()`.\n */\nexport interface CloudBootstrap {\n runtime: CloudRuntime;\n providers: {\n templates: TemplatesProvider;\n render: RenderProvider;\n versionHistory: VersionHistoryProvider;\n /** Absent when `savedBlocks: false` — the feature is then off entirely. */\n savedBlocks?: SavedBlocksProvider;\n testEmail: TestEmailProvider;\n comments: CommentsProvider;\n /** Absent when `media: false` — Browse is then off unless `onRequestMedia` is set. */\n media?: MediaProvider;\n };\n /**\n * Who is editing, from the JWT — `init({ user })`'s value for a Cloud session.\n *\n * `undefined` when the project's token carries no `user` claim, which makes\n * comments unavailable rather than anonymous. Not a key `initCloud()` accepts:\n * Cloud's comment writes are signed against this same claim, so a\n * consumer-supplied identity would only be able to disagree with it.\n */\n user?: EditorUser;\n}\n\n/**\n * Pick only the event members off a consumer-supplied `templates` value.\n *\n * A whitelist, never a spread. The config type says `TemplatesOptions`, but a\n * JavaScript consumer is unchecked, so the object can carry anything —\n * `load`/`create`/`save` are already shadowed by the literal defining them\n * after the spread, and this drops everything else so the guarantee never\n * depends on that ordering surviving a later edit.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onSaved: \"yes\"` would otherwise reach core and throw at save time,\n * inside a call the consumer never made.\n */\nfunction eventsOf(value: TemplatesOptions | undefined): TemplatesOptions {\n if (!value) return {};\n const { onSaved, onCreated, onLoaded } = value;\n return {\n ...(typeof onSaved === \"function\" ? { onSaved } : {}),\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onLoaded === \"function\" ? { onLoaded } : {}),\n };\n}\n\n/**\n * Fails to compile when `TemplatesOptions` gains a member outside the six\n * named below. Cloud picks that object apart by name in two places —\n * `eventsOf` above and `initCloud`'s merge in `index.ts` — so a seventh\n * member forces a **deliberate decision** about which of the two forwards\n * it. The check cannot make that decision itself: adding the new name to the\n * `Exclude` list below satisfies the compiler on its own and forwards\n * nothing by itself, and it has no way to tell an event (belongs in\n * `eventsOf`) from config (belongs in the `index.ts` merge).\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the six named here.\n */\ntype _TemplatesOptionsForwarded =\n Exclude<\n keyof TemplatesOptions,\n | \"autoSave\"\n | \"unsavedChangesGuard\"\n | \"nameField\"\n | \"onSaved\"\n | \"onCreated\"\n | \"onLoaded\"\n > extends never\n ? true\n : never;\nconst _templatesOptionsForwarded: _TemplatesOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `comments` value.\n *\n * A whitelist, never a spread. The config type says `CommentsOptions`, but a\n * JavaScript consumer is unchecked, so the object can carry anything —\n * `list`/`create`/`update`/`delete`/`setResolved` are already shadowed by the\n * spread of Cloud's own adapter that follows this in the provider literal, and\n * this drops everything else so the guarantee never depends on that ordering\n * surviving a later edit.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onCreated: \"yes\"` would otherwise reach core and throw at\n * comment-creation time, inside a call the consumer never made.\n */\nfunction commentEventsOf(\n value: false | CommentsOptions | undefined,\n): CommentsOptions {\n if (!value) return {};\n const { onCreated, onUpdated, onDeleted, onResolved, onUnresolved } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n ...(typeof onResolved === \"function\" ? { onResolved } : {}),\n ...(typeof onUnresolved === \"function\" ? { onUnresolved } : {}),\n };\n}\n\n/**\n * Fails to compile when `CommentsOptions` gains a member outside the five\n * named below. Every member of `CommentsOptions` is an event, and\n * `commentEventsOf` above is the only place that forwards them — unlike\n * `TemplatesOptions`, there is no second merge in `index.ts`, since comments\n * carries no config booleans for that merge to combine. A sixth member has\n * exactly one place to be added: this list and `commentEventsOf`'s destructure,\n * together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below is\n * what forces the check — it fails to compile the moment a member falls\n * outside the five named here.\n */\ntype _CommentsOptionsForwarded =\n Exclude<\n keyof CommentsOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\" | \"onResolved\" | \"onUnresolved\"\n > extends never\n ? true\n : never;\nconst _commentsOptionsForwarded: _CommentsOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `savedBlocks` value.\n *\n * A whitelist, never a spread. `savedBlocks` accepts a boolean, an\n * events-only `SavedBlocksOptions`, or a full `SavedBlocksProvider` — this is\n * only ever called on the first two, since a full provider replaces Cloud's\n * adapter outright and is used as-is (see `consumerSavedBlocks` below). A\n * non-object value (`true`, `undefined`, `false`) carries no keys to pick, so\n * it returns `{}` rather than throwing on the destructure.\n *\n * Each member is also type-checked, not merely truthiness-checked: a value\n * like `onCreated: \"yes\"` would otherwise reach core and throw at\n * saved-block-creation time, inside a call the consumer never made.\n */\nfunction savedBlocksEventsOf(\n value: TemplaticalCloudEditorConfig[\"savedBlocks\"],\n): SavedBlocksOptions {\n if (typeof value !== \"object\" || value === null) return {};\n const { onCreated, onUpdated, onDeleted } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n };\n}\n\n/**\n * Fails to compile when `SavedBlocksOptions` gains a member outside the three\n * named below. `savedBlocksEventsOf` above is the only place that forwards\n * them, so a fourth member has exactly one place to be added: this list and\n * that function's destructure, together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the three named here.\n */\ntype _SavedBlocksOptionsForwarded =\n Exclude<\n keyof SavedBlocksOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\"\n > extends never\n ? true\n : never;\nconst _savedBlocksOptionsForwarded: _SavedBlocksOptionsForwarded = true;\n\n/**\n * Pick `onSent` and `defaultRecipient` off a consumer-supplied `testEmail`\n * value.\n *\n * A whitelist, like `savedBlocksEventsOf` — but note what it does NOT pick:\n * `includeMjml` and `allowedRecipients` stay Cloud's own whenever Cloud's\n * sender is in play, so they are never read here even though\n * `TestEmailOptions` declares them (see `_TestEmailOptionsForwarded` below).\n * `defaultRecipient` has no such conflict — Cloud's provider never defines\n * it, and `useTestEmailFeature` already discards a value outside\n * `allowedRecipients`, so a consumer's choice can only ever pre-fill an\n * address already on Cloud's own signed list, never smuggle in one outside\n * it. `onSent` is a plain notification with no conflict either, so both\n * cross over.\n *\n * The result is assigned ONTO Cloud's own provider with `Object.assign`\n * (never spread together with it) at the call site — that provider's\n * `allowedRecipients` is a live getter over the JWT-derived allowlist, and a\n * spread reads every own property through `[[Get]]`, freezing the getter's\n * current value into a plain property on the new object. `Object.assign`\n * with the cloud provider as the *target* only ever writes the keys this\n * function returns, so the getter is never read and never disturbed.\n */\nfunction testEmailEventsOf(\n value: TemplaticalCloudEditorConfig[\"testEmail\"],\n): Pick<TestEmailOptions, \"onSent\" | \"defaultRecipient\"> {\n if (typeof value !== \"object\" || value === null) return {};\n const { onSent, defaultRecipient } = value;\n return {\n ...(typeof onSent === \"function\" ? { onSent } : {}),\n ...(typeof defaultRecipient === \"string\" ? { defaultRecipient } : {}),\n };\n}\n\n/**\n * Fails to compile when `TestEmailOptions` gains a member outside the four\n * named below. `onSent` and `defaultRecipient` are forwarded by\n * `testEmailEventsOf` above; `includeMjml` and `allowedRecipients` stay\n * Cloud's own whenever Cloud's sender is in play (Cloud renders server-side\n * rather than from a client MJML pass, and the allowlist is the signed one\n * from the project's JWT, not a client-supplied one). A fifth member still\n * forces a deliberate decision the same way a fourth `SavedBlocksOptions`\n * member does: whether it joins the forwarded pair or stays excluded for the\n * same reason as the other two.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the four named here.\n */\ntype _TestEmailOptionsForwarded =\n Exclude<\n keyof TestEmailOptions,\n \"includeMjml\" | \"allowedRecipients\" | \"defaultRecipient\" | \"onSent\"\n > extends never\n ? true\n : never;\nconst _testEmailOptionsForwarded: _TestEmailOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `media` value.\n *\n * A whitelist, never a spread. `media` accepts `false`, an events-only\n * {@link MediaOptions}, or a full {@link MediaProvider} — this is only ever\n * called on the first two, since a full provider replaces Cloud's adapter\n * outright and is used as-is (see `consumerMedia` below). A non-object\n * value (`undefined`, `false`) carries no keys to pick, so it returns `{}`\n * rather than throwing on the destructure.\n *\n * What it does NOT pick: `maxFileSize` and `mimeTypes` stay Cloud's own\n * whenever Cloud's store is in play (Cloud's plan owns those limits), so\n * they are never read here even though `MediaOptions` declares them (see\n * `_MediaOptionsForwarded` below).\n *\n * The result is assigned ONTO Cloud's own provider with `Object.assign`\n * (never spread together with it) at the call site — that provider's\n * `storage` / `maxFileSize` / `mimeTypes` read plan config live, and a\n * spread reads every own property through `[[Get]]`, freezing each\n * getter's current value into a plain property on the new object.\n * `Object.assign` with the cloud provider as the *target* only ever\n * writes the keys this function returns, so those getters are never\n * read and never disturbed.\n */\nfunction mediaEventsOf(\n value: TemplaticalCloudEditorConfig[\"media\"],\n): Pick<MediaOptions, \"onCreated\" | \"onUpdated\" | \"onDeleted\"> {\n if (typeof value !== \"object\" || value === null) return {};\n const { onCreated, onUpdated, onDeleted } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onUpdated === \"function\" ? { onUpdated } : {}),\n ...(typeof onDeleted === \"function\" ? { onDeleted } : {}),\n };\n}\n\n/**\n * Fails to compile when `MediaOptions` gains a member outside the five\n * named below. `onCreated` / `onUpdated` / `onDeleted` are forwarded by\n * `mediaEventsOf` above; `maxFileSize` and `mimeTypes` stay Cloud's own\n * whenever Cloud's store is in play (Cloud's plan owns those limits). A\n * sixth member still forces a deliberate decision the same way a fifth\n * `TestEmailOptions` member does: whether it joins the forwarded trio or\n * stays excluded for the same reason as the other two.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias\n * nothing reads, so a `never` result would sit there silently. The\n * assignment below is what forces the check — it fails to compile the\n * moment a member falls outside the five named here.\n */\ntype _MediaOptionsForwarded =\n Exclude<\n keyof MediaOptions,\n \"onCreated\" | \"onUpdated\" | \"onDeleted\" | \"maxFileSize\" | \"mimeTypes\"\n > extends never\n ? true\n : never;\nconst _mediaOptionsForwarded: _MediaOptionsForwarded = true;\n\n/**\n * Pick only the event members off a consumer-supplied `versionHistory`\n * value.\n *\n * A whitelist, never a spread — the config type says `VersionHistoryOptions`,\n * but a JavaScript consumer is unchecked, so the object can carry anything.\n * `versionHistory` never accepts a full provider (see the rejected-keys block\n * below), so unlike `savedBlocksEventsOf` / `testEmailEventsOf` this is\n * always called on the whole config value.\n */\nfunction versionHistoryEventsOf(\n value: VersionHistoryOptions | undefined,\n): VersionHistoryOptions {\n if (!value) return {};\n const { onCreated, onRestored } = value;\n return {\n ...(typeof onCreated === \"function\" ? { onCreated } : {}),\n ...(typeof onRestored === \"function\" ? { onRestored } : {}),\n };\n}\n\n/**\n * Fails to compile when `VersionHistoryOptions` gains a member outside the\n * two named below. `versionHistoryEventsOf` above is the only place that\n * forwards them, so a third member has exactly one place to be added: this\n * list and that function's destructure, together.\n *\n * The type alone checks nothing: TypeScript never evaluates an alias nothing\n * reads, so a `never` result would sit there silently. The assignment below\n * is what forces the check — it fails to compile the moment a member falls\n * outside the two named here.\n */\ntype _VersionHistoryOptionsForwarded =\n Exclude<keyof VersionHistoryOptions, \"onCreated\" | \"onRestored\"> extends never\n ? true\n : never;\nconst _versionHistoryOptionsForwarded: _VersionHistoryOptionsForwarded = true;\n\n/**\n * A comma list with a final \"and\" — \"a\"; \"a and b\"; \"a, b and c\". The\n * ignored-methods warnings below each name however many storage methods a\n * consumer actually passed, and `Array.join(\" and \")` only reads correctly\n * for exactly two.\n */\nfunction joinWithAnd(items: string[]): string {\n if (items.length < 2) return items.join(\"\");\n if (items.length === 2) return items.join(\" and \");\n return `${items.slice(0, -1).join(\", \")} and ${items[items.length - 1]}`;\n}\n\n/**\n * Cloud's bootstrap and adapter wiring, in one place, run **before the editor\n * mounts**.\n *\n * This replaces `useCloudInitialization`, which owned a second `useEditor`, a\n * second `useEditorCore` and a post-mount async dance with its own loading and\n * error states. The dance is gone: auth, the health check and the plan fetch all\n * resolve here, and a failure rejects `initCloud()` rather than mounting an\n * editor that cannot work. What is left is adapter construction.\n *\n * Two things deliberately stay Cloud-only:\n *\n * - **Entitlements.** In an all-BYO world there are no plans, so `planConfig` is\n * Cloud's commercial layer above the provider set rather than a provider\n * itself. It is down to five booleans, each metering a resource Cloud buys.\n * - **Mid-session failure.** `init()` cannot fail after it mounts and should not\n * grow the ability, so the error overlay lives on this side of the seam.\n */\nexport async function bootstrapCloud(\n options: BootstrapCloudOptions,\n): Promise<CloudBootstrap> {\n const { config, cloudTranslations } = options;\n\n // --- Late-bound editor access ---------------------------------------------\n //\n // The providers below are built before there is an editor to read. Each\n // reaches it through these holders, filled by `attach()` / `ready()` — which is\n // what lets them be handed to `init()` as ordinary config keys.\n let editorRef: UseEditorReturn | null = null;\n let coreRef: UseEditorCoreReturn | null = null;\n let websocketRef: ReturnType<typeof useWebSocket> | null = null;\n let collaboration: CloudCollaborationInstance | null = null;\n let collabWarning: UseCollabUndoWarningReturn | null = null;\n let saveGate: UseCloudSaveGateReturn | null = null;\n\n const sessionError = ref<Error | null>(null);\n const lockedBlocks = ref<Map<string, unknown>>(new Map());\n /**\n * Cloud's presence channel, forward-declared for the comments adapter's\n * `subscribe`. `useWebSocket` can only be built in `attach()` (it needs the\n * editor), while the provider is handed to `init()` before that — so the adapter\n * watches this and rebinds when the real channel lands.\n */\n const commentChannel = ref<RealtimeChannel | null>(null);\n\n function requireEditor(): UseEditorReturn {\n if (!editorRef) {\n throw new Error(\"[Templatical] The Cloud editor is not mounted yet.\");\n }\n return editorRef;\n }\n\n function getTemplateId(): string | null {\n return editorRef?.state.template?.id ?? null;\n }\n\n // --- Auth + plan ----------------------------------------------------------\n\n const authManager = new AuthManager({\n ...config.auth,\n // Only a *fatal* refusal raises the overlay. A 4xx means the endpoint\n // rejected the credentials, so every subsequent request fails the same way\n // and the session really is over. A network blip or a 5xx resolves on its\n // own, and blanking a mounted editor over one interrupts someone mid-edit on\n // a template that is probably unsaved — a worse outcome than the blip.\n //\n // The consumer hears about both: `onError` fires either way, and\n // `AuthManager` re-throws regardless, so a caller that cannot proceed still\n // finds out.\n onError: (error: Error) => {\n if (isFatalAuthError(error)) {\n sessionError.value = error;\n }\n config.onError?.(error);\n },\n });\n\n const planConfigInstance = usePlanConfig({\n authManager,\n onError: config.onError,\n });\n\n await authManager.initialize();\n\n const healthResult = await performHealthCheck({ authManager });\n if (!healthResult.api.ok) {\n throw new Error(\"Health check failed: API is not reachable\");\n }\n if (!healthResult.auth.ok) {\n throw new Error(\n `Health check failed: authentication error${healthResult.auth.error ? ` - ${healthResult.auth.error}` : \"\"}`,\n );\n }\n if (!healthResult.websocket.ok) {\n logger.warn(\n \"WebSocket health check failed:\",\n healthResult.websocket.error ?? \"unknown error\",\n \"-- real-time features will be disabled.\",\n );\n }\n\n await planConfigInstance.fetchConfig();\n\n // The bootstrap itself is what the overlay would have covered, and it just\n // succeeded — so anything `onError` recorded on the way here is stale.\n sessionError.value = null;\n\n // --- Rejected consumer keys ----------------------------------------------\n //\n // `render` is not declared on `TemplaticalCloudEditorConfig`, so it only\n // fires for JavaScript consumers — warned rather than silently dropped,\n // because the symptom (a store that stays empty while Cloud's fills up)\n // reads as a broken provider rather than a rejected one. `templates`,\n // `comments` and `versionHistory` ARE declared, but typed narrowly as\n // `TemplatesOptions`, `CommentsOptions` and `VersionHistoryOptions` — a\n // JavaScript consumer can still hand over a full provider, so its storage\n // methods are named and ignored the same way, while any events they carry\n // reach `eventsOf` / `commentEventsOf` / `versionHistoryEventsOf` below\n // regardless of this check.\n const consumerTemplates = (config as { templates?: Record<string, unknown> })\n .templates;\n // Presence, not `typeof === \"function\"` — see the matching comment on\n // `ignoredCommentMethods` below: a stated-but-ignored decision like\n // `save: false` is as much a signal as a stray function override.\n const ignoredTemplateMethods = [\"load\", \"create\", \"save\"].filter(\n (key) => typeof consumerTemplates?.[key] !== \"undefined\",\n );\n if (ignoredTemplateMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredTemplateMethods.map((key) => `templates.${key}`),\n )} — the template id is the join key for collaboration, ` +\n \"version history, comments, AI rewrite, scoring and the server-side \" +\n \"export, so an id Cloud never issued would degrade all six. Your \" +\n \"event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n const consumerVersionHistory = (\n config as { versionHistory?: Record<string, unknown> }\n ).versionHistory;\n // Presence, not `typeof === \"function\"`: a stated-but-ignored decision like\n // `restore: false` is as much a signal as a stray function override, and\n // both must be named here or the consumer never learns it was dropped.\n const ignoredVersionHistoryMethods = [\n \"list\",\n \"get\",\n \"create\",\n \"restore\",\n ].filter((key) => typeof consumerVersionHistory?.[key] !== \"undefined\");\n if (ignoredVersionHistoryMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredVersionHistoryMethods.map((key) => `versionHistory.${key}`),\n )} — a version is keyed to a template id Cloud issued, so Cloud owns ` +\n \"its history. Your event handlers were kept. Use init() to bring \" +\n \"your own storage.\",\n );\n }\n const consumerComments = (config as { comments?: Record<string, unknown> })\n .comments;\n // Presence, not `typeof === \"function\"`: a stated-but-ignored decision like\n // `create: false` is as much a signal as a stray function override, and both\n // must be named here or the consumer never learns it was dropped.\n const ignoredCommentMethods = [\n \"list\",\n \"create\",\n \"update\",\n \"delete\",\n \"setResolved\",\n \"subscribe\",\n ].filter((key) => typeof consumerComments?.[key] !== \"undefined\");\n if (ignoredCommentMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredCommentMethods.map((key) => `comments.${key}`),\n )} — a comment is keyed to a template id Cloud issued, and its ` +\n \"author is signed by the auth token, so Cloud owns the conversation. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n // Rejected for a different reason than the three above: not the join key, but\n // because Cloud renders on its own for test email, scheduled sends and API\n // exports (`createCloudTestEmailProvider` calls `exportHtml` directly). A\n // consumer provider would have changed `toMjml()` / `toHtml()` and nothing\n // else, so what the user previewed and exported was not what Cloud delivered —\n // and Cloud's output is a deliberate superset (countdown GIFs, composited video\n // thumbnails), so the consumer's was also worse for those blocks.\n if ((config as { render?: unknown }).render) {\n logger.warn(\n \"initCloud does not accept a `render` provider — Cloud renders \" +\n \"server-side for test email, sends and exports, so a supplied renderer \" +\n \"would change only what you preview and export, never what Cloud \" +\n \"delivers. The supplied provider is ignored. For your own MJML, call \" +\n \"renderToMjml(editor.getContent()) from @templatical/renderer.\",\n );\n }\n\n // --- Providers ------------------------------------------------------------\n\n function connectRealtime(template: Template): void {\n const websocketConfig = planConfigInstance.config.value?.websocket;\n if (!websocketRef || !websocketConfig) return;\n websocketRef.connect(template.id, resolveWebSocketConfig(websocketConfig));\n }\n\n const baseTemplates = createCloudTemplatesProvider(authManager);\n const baseCreate = baseTemplates.create;\n const baseSave = baseTemplates.save;\n\n /**\n * Cloud's templates adapter plus the choreography the template id anchors:\n * the websocket joins the template's presence channel. The consumer's\n * `onSaved` / `onCreated` / `onLoaded` ride along via `eventsOf` — core calls\n * them once the editor has settled, so the adapter itself never invokes them.\n *\n * That choreography belongs in the adapter rather than in an editor-side\n * lifecycle composable, because it *is* adapter business — Cloud is what keys\n * realtime off the id it issued. `useCloudLifecycle` existed only to hold it.\n *\n * `save` pre-renders custom blocks, which is why it is wrapped too.\n */\n const templates: TemplatesProvider = {\n ...eventsOf(config.templates),\n load: async (id: string) => {\n const template = await baseTemplates.load(id);\n connectRealtime(template);\n return template;\n },\n create:\n typeof baseCreate === \"function\"\n ? async (input: { name?: string; content: TemplateContent }) => {\n const template = await baseCreate(input);\n connectRealtime(template);\n return template;\n }\n : false,\n save:\n typeof baseSave === \"function\"\n ? async (id: string, patch: TemplatePatch) => {\n if (coreRef && editorRef) {\n await preRenderCustomBlocks(\n editorRef.content.value,\n coreRef.registry,\n );\n }\n return baseSave(id, patch);\n }\n : false,\n };\n\n // Always Cloud's — see the rejected-keys block above. Cloud renders\n // independently for delivery, so a second renderer could only disagree with it.\n const render: RenderProvider = createCloudRenderProvider({\n authManager,\n getTemplateId,\n // Plain `editor.save()`: the templates adapter below already pre-renders\n // custom blocks on every save, which is exactly what the render endpoint\n // needs, since it exports from the stored copy rather than from\n // `payload.content`.\n save: () => requireEditor().save(),\n });\n\n // The consumer's `onCreated` / `onRestored` ride along via\n // `versionHistoryEventsOf` — core calls them once the editor has settled, so\n // the adapter itself never invokes them. `versionHistory` never accepts a\n // full provider (see the rejected-keys block above), so this always merges\n // onto Cloud's own adapter, never onto a consumer's.\n const versionHistory: VersionHistoryProvider = {\n ...versionHistoryEventsOf(config.versionHistory),\n ...createCloudVersionHistoryProvider(authManager),\n };\n\n // Realtime is the adapter's own business: `subscribe` binds the presence channel\n // above, so `useCommentListener` in `@templatical/core` never learns that Pusher\n // exists and a BYO provider with an SSE stream slots into the same seam. The\n // consumer's `onCreated` / `onUpdated` / `onDeleted` / `onResolved` /\n // `onUnresolved` ride along via `commentEventsOf` — core calls them once the\n // editor has settled, so the adapter itself never invokes them.\n const comments: CommentsProvider = {\n ...commentEventsOf(config.comments),\n ...createCloudCommentsProvider({\n authManager,\n channel: commentChannel,\n getSocketId: () => websocketRef?.getSocketId() ?? null,\n }),\n };\n\n // From the JWT, not from config. Cloud signs comment writes against this same\n // claim, so a consumer-supplied identity could only disagree with it — and a\n // token without the claim leaves comments unavailable rather than anonymous.\n const cloudUser: EditorUser | undefined = authManager.userConfig\n ? { id: authManager.userConfig.id, name: authManager.userConfig.name }\n : undefined;\n\n // A consumer may pass their own store instead of a boolean, in which case it\n // replaces Cloud's outright — discriminated on `list`, the one required\n // method every full provider carries, never on `typeof === \"object\"`: an\n // events-only `SavedBlocksOptions` (`{ onCreated }`) is an object too, and\n // reading it as the provider would leave `list` undefined and crash the\n // library on first browse. That path is deliberately NOT plan-gated:\n // `savedModules` licenses Cloud's *storage*, and someone else's backend\n // isn't Cloud's to sell — `isSavedBlocksAvailable` below keys off this same\n // discriminated value for that reason.\n const consumerSavedBlocks =\n typeof (config.savedBlocks as SavedBlocksProvider | undefined)?.list ===\n \"function\"\n ? (config.savedBlocks as SavedBlocksProvider)\n : null;\n // A malformed provider — e.g. `create` / `update` / `delete` with no\n // working `list` — fails the discriminator above and falls through to\n // Cloud's own store, so those methods are silently unused rather than\n // replacing anything. Named here the same way `templates` / `comments` /\n // `versionHistory` name their own ignored methods, so the drop isn't a\n // console-free mystery.\n if (\n consumerSavedBlocks === null &&\n typeof config.savedBlocks === \"object\" &&\n config.savedBlocks !== null\n ) {\n const suppliedSavedBlocks = config.savedBlocks as Record<string, unknown>;\n const ignoredSavedBlocksMethods = [\n \"list\",\n \"create\",\n \"update\",\n \"delete\",\n ].filter((key) => typeof suppliedSavedBlocks[key] !== \"undefined\");\n if (ignoredSavedBlocksMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredSavedBlocksMethods.map((key) => `savedBlocks.${key}`),\n )} — a provider needs a working list to replace Cloud's store, and ` +\n \"this value has none, so it configures Cloud's own store instead. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n }\n // The consumer's `onCreated` / `onUpdated` / `onDeleted` ride along via\n // `savedBlocksEventsOf` when Cloud's own adapter is used — core calls them\n // once the editor has settled, so the adapter itself never invokes them. A\n // full consumer provider carries its own events already and is used as-is,\n // so this merge only ever runs on Cloud's side of the `??`.\n const savedBlocks: SavedBlocksProvider | undefined =\n config.savedBlocks === false\n ? undefined\n : (consumerSavedBlocks ?? {\n ...savedBlocksEventsOf(config.savedBlocks),\n ...createCloudSavedBlocksProvider(authManager),\n });\n\n // Cloud's test-email *config* — plan enablement plus the signed allowlist, both\n // carried by the JWT `authManager.initialize()` already resolved above. Hence\n // the constant `isAuthReady`: there is no window where it is false.\n const testEmailConfig = useTestEmail({\n authManager,\n isAuthReady: ref(true),\n });\n\n // Cloud's own send path renders through the export endpoint directly: the\n // adapter derives HTML from the *saved* template and applies\n // `onBeforeTestEmail` to it, which is a narrower job than the render contract.\n const exporter = useExport({ authManager });\n\n // Discriminated on `send`, the one required method every full provider\n // carries — never on raw truthiness, which an events-only `TestEmailOptions`\n // (`{ onSent }`) also satisfies and would leave `send` undefined, crashing\n // the dialog on send. `isTestEmailAvailable` below keys off this same\n // discriminated value so an events-only value stays plan-gated rather than\n // reading as \"consumer's own sender\".\n const consumerTestEmail =\n typeof (config.testEmail as TestEmailProvider | undefined)?.send ===\n \"function\"\n ? (config.testEmail as TestEmailProvider)\n : null;\n // `send` reaching here means it failed the discriminator above — e.g.\n // `send: null` — so it is named the same way a malformed `savedBlocks`\n // value's storage methods are. `includeMjml` / `allowedRecipients` are\n // named for a different reason: they are not part of this key's options\n // arm (see `cloudConfig.ts`), but TypeScript does not actually refuse\n // them — both are valid members of the sibling `TestEmailProvider` arm, so\n // the union's excess-property check passes them through regardless of\n // which arm the caller intended. All three log a warning naming them\n // rather than dropping with no console trace.\n if (\n consumerTestEmail === null &&\n typeof config.testEmail === \"object\" &&\n config.testEmail !== null\n ) {\n const suppliedTestEmail = config.testEmail as Record<string, unknown>;\n const ignoredTestEmailMembers = [\n \"send\",\n \"includeMjml\",\n \"allowedRecipients\",\n ].filter((key) => typeof suppliedTestEmail[key] !== \"undefined\");\n if (ignoredTestEmailMembers.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredTestEmailMembers.map((key) => `testEmail.${key}`),\n )} — a provider needs a working send to replace Cloud's sender ` +\n \"outright, and Cloud renders server-side with the signed \" +\n \"allowlist from your project's JWT either way, so none of these \" +\n \"apply here. Your event handlers were kept.\",\n );\n }\n }\n const testEmail: TestEmailProvider =\n consumerTestEmail ??\n // `Object.assign`, not a spread: `createCloudTestEmailProvider`'s\n // `allowedRecipients` is a live getter (see `testEmailEventsOf`'s doc\n // comment for why a spread would freeze it). The cloud provider is the\n // assignment *target* here, so its getter is never read — only the keys\n // `testEmailEventsOf` returns are ever written onto it.\n //\n // Asymmetric with `savedBlocks` / `versionHistory` on purpose, not by\n // drift: those two spread Cloud's provider LAST, so even a whitelist that\n // let something unexpected through could never displace a Cloud method —\n // two lines of defence. Here `testEmailEventsOf`'s return type is the\n // only barrier, because Cloud is the assignment target rather than a\n // second spread source. Copying the sibling shape (`{ ...events,\n // ...createCloudTestEmailProvider(...) }`) would reintroduce the exact\n // getter-freezing bug this construction exists to avoid.\n Object.assign(\n createCloudTestEmailProvider({\n authManager,\n getTemplateId,\n save: () => requireEditor().save(),\n exportHtml: (templateId: string) =>\n exporter.exportHtml(templateId, resolveExportFonts(config.fonts)),\n allowedEmails: testEmailConfig.allowedEmails,\n getSignature: testEmailConfig.getSignature,\n onBeforeTestEmail: config.onBeforeTestEmail,\n }),\n testEmailEventsOf(config.testEmail),\n );\n\n // A consumer may pass their own store instead of omitting the key or\n // passing `false`, in which case it replaces Cloud's outright —\n // discriminated on `list`, the one required method every full provider\n // carries, never on `typeof === \"object\"`: an events-only `MediaOptions`\n // (`{ onCreated }`) is an object too, and reading it as the provider\n // would leave `list` undefined and crash the library on first browse.\n // That path is deliberately NOT plan-gated: there is no media plan\n // feature. The plan licenses Cloud's *storage*, and someone else's\n // backend isn't Cloud's to sell.\n const consumerMedia =\n typeof (config.media as MediaProvider | undefined)?.list === \"function\"\n ? (config.media as MediaProvider)\n : null;\n // A malformed provider — e.g. `create` / `update` / `delete` with no\n // working `list` — fails the discriminator above and falls through to\n // Cloud's own store, so those methods are silently unused rather than\n // replacing anything. Named here the same way `savedBlocks` names its\n // own ignored methods, so the drop isn't a console-free mystery.\n // `maxFileSize` / `mimeTypes` are named for a different reason: they\n // are valid `MediaOptions` members but Cloud's plan owns those limits\n // whenever Cloud's store is in play.\n if (\n consumerMedia === null &&\n typeof config.media === \"object\" &&\n config.media !== null\n ) {\n const suppliedMedia = config.media as Record<string, unknown>;\n const ignoredMediaMethods = [\"list\", \"create\", \"update\", \"delete\"].filter(\n (key) => typeof suppliedMedia[key] !== \"undefined\",\n );\n if (ignoredMediaMethods.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredMediaMethods.map((key) => `media.${key}`),\n )} — a provider needs a working list to replace Cloud's store, and ` +\n \"this value has none, so it configures Cloud's own store instead. \" +\n \"Your event handlers were kept. Use init() to bring your own storage.\",\n );\n }\n const ignoredMediaLimits = [\"maxFileSize\", \"mimeTypes\"].filter(\n (key) => typeof suppliedMedia[key] !== \"undefined\",\n );\n if (ignoredMediaLimits.length > 0) {\n logger.warn(\n `initCloud ignores ${joinWithAnd(\n ignoredMediaLimits.map((key) => `media.${key}`),\n )} — Cloud's plan owns those limits whenever Cloud's store is in ` +\n \"play. Your event handlers were kept.\",\n );\n }\n }\n const media: MediaProvider | undefined =\n config.media === false\n ? undefined\n : (consumerMedia ??\n // `Object.assign`, not a spread: `createCloudMediaProvider`'s\n // `storage` / `maxFileSize` / `mimeTypes` read plan config live\n // (see `mediaEventsOf`'s doc comment for why a spread would freeze\n // the getters). The cloud provider is the assignment *target*\n // here, so its getters are never read — only the keys\n // `mediaEventsOf` returns are ever written onto it.\n Object.assign(\n createCloudMediaProvider(\n authManager,\n () => planConfigInstance.config.value,\n ),\n mediaEventsOf(config.media),\n ));\n\n // --- Setup-time wiring ----------------------------------------------------\n\n const aiConfig = useAiConfig(config.ai);\n const scoringInstance = useTemplateScoring({ authManager, getTemplateId });\n\n const featureFlags = useCloudFeatureFlags({\n planConfigInstance,\n aiConfig,\n getTemplateId,\n });\n\n const isCollaborationEnabled = computed(\n () =>\n !!config.collaboration?.enabled &&\n planConfigInstance.hasFeature(\"collaboration\"),\n );\n\n function attach(context: CloudAttachContext): CloudAttachment {\n const editor = context.editor;\n editorRef = editor;\n\n provide(CLOUD_TRANSLATIONS_KEY, cloudTranslations);\n provide(AUTH_MANAGER_KEY, authManager);\n provide(AI_CONFIG_KEY, aiConfig);\n provide(SCORING_KEY, scoringInstance);\n\n const websocket = useWebSocket({ authManager, onError: config.onError });\n websocketRef = websocket;\n\n // Feeds the comments adapter's `subscribe`, which was handed to `init()` before\n // this socket existed.\n watch(\n websocket.channel,\n (channel) => {\n commentChannel.value = channel;\n },\n { immediate: true },\n );\n\n if (config.mcp?.enabled) {\n useMcpListener({\n editor,\n channel: websocket.channel,\n onOperation: config.mcp.onOperation,\n });\n }\n\n // Order matters: the broadcast wrapper replaces the editor's mutators so they\n // publish to peers, and `useEditorCore`'s history interceptor then wraps them\n // again to push history entries. Reversing it would push history for remote\n // operations and drift the two peers apart.\n if (config.collaboration?.enabled) {\n collaboration = useCollaboration({\n authManager,\n editor,\n channel: websocket.channel,\n onError: config.onError,\n onCollaboratorJoined: config.collaboration.onCollaboratorJoined,\n onCollaboratorLeft: config.collaboration.onCollaboratorLeft,\n onBlockLocked: config.collaboration.onBlockLocked,\n onBlockUnlocked: config.collaboration.onBlockUnlocked,\n }) as CloudCollaborationInstance;\n\n watch(\n () => collaboration!.lockedBlocks.value,\n (next) => {\n lockedBlocks.value = next;\n },\n { immediate: true },\n );\n\n useCollaborationBroadcast(editor, collaboration);\n }\n\n const panelState = useCloudPanelState();\n\n return {\n websocket,\n panelState,\n featureFlags,\n collaboration,\n isCollaborationEnabled,\n };\n }\n\n function ready(context: CloudReadyContext): CloudReady {\n const { core, capabilities } = context;\n coreRef = core;\n\n saveGate = useCloudSaveGate({\n issues: core.templateLint ? core.templateLint.issues : ref([]),\n planConfig: planConfigInstance.config,\n });\n\n collabWarning = useCollabUndoWarning({\n isCollaborationEnabled,\n getCollaboratorCount: () =>\n collaboration?.collaborators.value.length ?? 0,\n canUndo: core.history.canUndo,\n });\n\n // Mutated in place rather than re-provided: `useEditorCore` already provided\n // this exact object, so components injecting it see Cloud's entries on their\n // first render. Same pattern `versionHistory` uses in `Editor.vue`.\n //\n // `capabilities.comments` is *not* set here any more: comments became a shared\n // provider-backed feature, so `Editor.vue` builds the capability from\n // `useCommentsFeature` exactly as it does for saved blocks and test email, and\n // Cloud contributes only the two predicates below.\n capabilities.plan = planConfigInstance;\n capabilities.ai = aiConfig;\n\n // Registered unconditionally. `custom_blocks` and `theme_customization` used\n // to gate these — entitlements on editor capability the free editor grants,\n // and the only two things `applyPlanGates` would ever have had to do.\n if (config.customBlocks?.length) {\n core.registerCustomBlocks(config.customBlocks);\n }\n if (config.theme) {\n core.themeOverrides.value = config.theme;\n }\n\n return {\n saveGate,\n collabWarning,\n sessionError,\n retry: async () => {\n try {\n await authManager.initialize();\n sessionError.value = null;\n } catch (error) {\n sessionError.value =\n error instanceof Error ? error : new Error(\"Authentication failed\");\n }\n },\n };\n }\n\n const runtime: CloudRuntime = {\n lockedBlocks,\n isSavedBlocksAvailable: consumerSavedBlocks\n ? () => true\n : () =>\n config.savedBlocks !== false &&\n planConfigInstance.hasFeature(\"savedModules\"),\n isTestEmailAvailable: consumerTestEmail\n ? // Their sender, their rules — the `testEmail` plan feature licenses\n // Cloud's sending, and \"the template must be saved\" is a constraint of\n // Cloud's server-side render, not of an arbitrary backend.\n () => true\n : // All three matter and none implies another: the plan may grant the\n // feature while the project's token omits a recipient config, and Cloud\n // renders from the *saved* template so there must be one.\n () =>\n testEmailConfig.isEnabled.value &&\n featureFlags.canSendTestEmail.value &&\n featureFlags.hasTemplateSaved.value,\n // Three conditions, none implying another: the consumer may switch the feature\n // off, the plan meters comment storage and its realtime fan-out, and Cloud\n // anchors a comment to the *saved* template. (Whether a `user` exists is the\n // shared feature's own gate, not Cloud's.)\n isCommentsAvailable: () =>\n config.comments !== false &&\n planConfigInstance.hasFeature(\"commenting\") &&\n featureFlags.hasTemplateSaved.value,\n // A comment is anchored server-side, so a block that exists only on the canvas\n // has nothing stored to show. This is the last thing the deleted cloud editor\n // core carried (`savedBlockIds`), and it was always a comments concern rather\n // than an editor one.\n isBlockSaved: (blockId: string) =>\n collectSavedBlockIds(editorRef?.state.template ?? null).has(blockId),\n getSaveGate: () => saveGate,\n isRemoteOperation: () =>\n collaboration?._isProcessingRemoteOperation() ?? false,\n onBeforeUndo: () => collabWarning?.showCollabUndoWarning(),\n attach,\n ready,\n destroy() {\n websocketRef?.disconnect();\n config.onUnmount?.();\n },\n };\n\n return {\n runtime,\n providers: {\n templates,\n render,\n versionHistory,\n ...(savedBlocks ? { savedBlocks } : {}),\n testEmail,\n comments,\n ...(media ? { media } : {}),\n },\n user: cloudUser,\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,SAAgBkC,GACd,GAC4B;CAC5B,IAAM,EAAE,uBAAoB,aAAU,qBAAkBC;CAkBxD,OAAO;EACL,oBAjByBhC,QAEvBiC,EAAmB,WAAW,cAAc,KAC5CC,EAAS,kBAAkB,KAc7B;EACA,kBAbuBlC,QACvBiC,EAAmB,WAAW,WAAW,CAYzC;EACA,kBAXuBjC,QAAemC,EAAc,MAAM,IAW1D;EACA,eAXoBnC,QACdiC,EAAmB,OAAO,OAAO,OAAO,gBAAgB,IAU9D;EACA,eAToBjC,QACdiC,EAAmB,OAAO,OAAO,iBAAiB,CAQxD;CACF;AACF;;;ACvCA,SAAgBG,KAA+C;CAC7D,IAAMC,IAActC,EAAuB,IAAI,GAEzCuC,IAAatC,EAAS;EAC1B,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,YAAY;CACnD,CAAC,GACKC,IAAmBxC,EAAS;EAChC,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,YAAY;CACnD,CAAC,GACKE,IAAsBzC,EAAS;EACnC,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,qBAAqB;CAC5D,CAAC,GACKG,IAAe1C,EAAS;EAC5B,WAAWqC,EAAY,UAAU;EACjC,MAAM,MAAO,EAAY,QAAQE,IAAI,aAAa;CACpD,CAAC,GAEKI,IAAa5C,EAAI,EAAK,GACtB6C,IAAY7C,EAAwB,IAAI,GAExC8C,IAAiB7C,QAAeqC,EAAY,UAAU,IAAI,GAE1DS,IAAkB9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C,GAAe,sBAAsB;GACzD;GACA;GACA,UAAU;IAER,AADAF,GAAc,WAAW,GACzBS,EAAO,YAAY;GACrB;EAIA;EACA,WAAW;GACT;GACA;GACA;GACA,GAAI0B,IAAc,EAAE,eAAY,IAAI,CAAC;GACrC;GACA;GACA,GAAIY,IAAQ,EAAE,SAAM,IAAI,CAAC;EAC3B;EACA,MAAMhB;CACR;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { H as e, N as t, Q as n, S as r, U as i, Y as a, at as o, c as s, ct as c, f as l, g as u, h as d, k as f, l as p, lt as m, m as h, o as g, p as _, ut as v } from "./draggable-BUTN5vZC.js";
|
|
2
|
-
import { a as y, d as b, o as x, r as S } from "./src-
|
|
2
|
+
import { a as y, d as b, o as x, r as S } from "./src-Bh0MoJ67.js";
|
|
3
3
|
import { t as C } from "./useI18n-DO4NTunW.js";
|
|
4
|
-
import { t as w } from "./useMergeTag-
|
|
4
|
+
import { t as w } from "./useMergeTag-DJLM-7WQ.js";
|
|
5
5
|
import { _ as T, g as E, h as D, n as O, r as k, t as A, v as j, y as M } from "./tiptap-CYDXLO17.js";
|
|
6
|
-
import { a as N, o as P, s as F } from "./LogicTagInsertButton-
|
|
6
|
+
import { a as N, o as P, s as F } from "./LogicTagInsertButton-BYjdrDnQ.js";
|
|
7
7
|
//#region src/extensions/FontSize.ts
|
|
8
8
|
var I = D.create({
|
|
9
9
|
name: "fontSize",
|
|
@@ -493,12 +493,12 @@ var $ = D.create({
|
|
|
493
493
|
};
|
|
494
494
|
},
|
|
495
495
|
addProseMirrorPlugins() {
|
|
496
|
-
let e = this.options.mergeTags
|
|
496
|
+
let e = this.options.mergeTags, t = this.options.emptyText, n = this.options.popoverRoot, r = {
|
|
497
497
|
char: this.options.char,
|
|
498
498
|
allowSpaces: !1,
|
|
499
499
|
startOfLine: !1,
|
|
500
500
|
allowedPrefixes: null,
|
|
501
|
-
items: ({ query: t }) => P(e, t),
|
|
501
|
+
items: ({ query: t }) => P(e(), t),
|
|
502
502
|
command: ({ editor: e, range: t, props: n }) => {
|
|
503
503
|
e.chain().focus().insertContentAt(t, {
|
|
504
504
|
type: "mergeTagNode",
|
|
@@ -519,4 +519,4 @@ var $ = D.create({
|
|
|
519
519
|
//#endregion
|
|
520
520
|
export { I as FontSize, L as LetterSpacing, R as LineBoundaryKeys, z as LineHeight, K as LogicMergeTagNode, Z as MergeTagNode, $ as MergeTagSuggestion, P as filterMergeTags, F as handleSuggestionKeyDown };
|
|
521
521
|
|
|
522
|
-
//# sourceMappingURL=extensions-
|
|
522
|
+
//# sourceMappingURL=extensions-CrmXF4MW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions-CrmXF4MW.js","names":["_hoisted_1","_hoisted_2","_hoisted_3","_openBlock","_createBlock","_unref","_normalizeClass","_normalizeStyle","_withCtx","_withDirectives","_createElementBlock","_vModelText","_withModifiers","_withKeys","_toDisplayString","_createElementVNode","_createCommentVNode","_sfc_main","LogicMergeTagNodeView","_openBlock","_createBlock","_unref","_withCtx","_withDirectives","_createElementBlock","_normalizeClass","_vModelText","_withModifiers","_withKeys","_toDisplayString","_createElementVNode","_sfc_main","MergeTagNodeView","Suggestion","withCtx","openBlock","ref","defineComponent","withDirectives","onScopeDispose","unref","withKeys","normalizeClass","computed","createElementBlock","createCommentVNode","nextTick","withModifiers","normalizeStyle","createBlock","vModelText","createBaseVNode","toDisplayString","getLogicMergeTagKeyword","isLogicMergeTagValue","getMergeTagLabel","SYNTAX_PRESETS","useI18n","useMergeTag","Node","InputRule","Extension","NodeViewWrapper","VueNodeViewRenderer","src_default","PasteRule","mergeAttributes","createMergeTagPopup","filterMergeTags","handleSuggestionKeyDown","FontSize","element","attributes","chain","size","LetterSpacing","spacing","LineBoundaryKeys","moveToLineBoundary","view","editor","selection","direction","LineHeight","commands","type","_hoisted_1$1","_hoisted_2$1","_hoisted_3$1","LogicMergeTagNodeView_default","props","__props","isValid","syntax","displayKeyword","isEditing","editValue","inputRef","handled","startEditing","finishEditing","newValue","handleKeydown","event","_cache","$event","t","args","isNodeSelected","$from","$to","nodeTypeName","renderVueNodeView","component","LogicMergeTagNode","node","keyword","HTMLAttributes","inputRegex","fullValue","match","range","pasteRegex","_hoisted_1","_hoisted_2","_hoisted_3","MergeTagNodeView_default","displayLabel","getMergeTagDisplayLabel","canRepick","canRepickMergeTag","disposed","isEditValueValid","isMergeTagValue","repick","replacement","requestMergeTag","findMergeTag","activate","format","showRawValue","MergeTagNode","label","attrs","createMergeTagSuggestionRenderer","popup","emptyText","popoverRootRef","item","MergeTagSuggestion","getMergeTags","config","query"],"sources":["../../../src/extensions/FontSize.ts","../../../src/extensions/LetterSpacing.ts","../../../src/extensions/LineBoundaryKeys.ts","../../../src/extensions/LineHeight.ts","../../../src/extensions/LogicMergeTagNodeView.vue","../../../src/extensions/LogicMergeTagNodeView.vue","../../../src/extensions/isNodeSelected.ts","../../../src/extensions/renderVueNodeView.ts","../../../src/extensions/LogicMergeTagNode.ts","../../../src/extensions/MergeTagNodeView.vue","../../../src/extensions/MergeTagNodeView.vue","../../../src/extensions/MergeTagNode.ts","../../../src/extensions/MergeTagSuggestion.ts"],"sourcesContent":["import { Extension } from \"@tiptap/core\";\n\nexport interface FontSizeOptions {\n types: string[];\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n fontSize: {\n setFontSize: (size: string) => ReturnType;\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create<FontSizeOptions>({\n name: \"fontSize\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize?.replace(/['\"]+/g, \"\") || null,\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (size: string) =>\n ({ chain }) => {\n return chain().setMark(\"textStyle\", { fontSize: size }).run();\n },\n unsetFontSize:\n () =>\n ({ chain }) => {\n return chain()\n .setMark(\"textStyle\", { fontSize: null })\n .removeEmptyTextStyle()\n .run();\n },\n };\n },\n});\n","import { Extension } from \"@tiptap/core\";\n\nexport interface LetterSpacingOptions {\n types: string[];\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n letterSpacing: {\n setLetterSpacing: (spacing: string) => ReturnType;\n unsetLetterSpacing: () => ReturnType;\n };\n }\n}\n\nexport const LetterSpacing = Extension.create<LetterSpacingOptions>({\n name: \"letterSpacing\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n letterSpacing: {\n default: null,\n parseHTML: (element) =>\n element.style.letterSpacing?.replace(/['\"]+/g, \"\") || null,\n renderHTML: (attributes) => {\n if (!attributes.letterSpacing) {\n return {};\n }\n return {\n style: `letter-spacing: ${attributes.letterSpacing}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setLetterSpacing:\n (spacing: string) =>\n ({ chain }) => {\n return chain().setMark(\"textStyle\", { letterSpacing: spacing }).run();\n },\n unsetLetterSpacing:\n () =>\n ({ chain }) => {\n return chain()\n .setMark(\"textStyle\", { letterSpacing: null })\n .removeEmptyTextStyle()\n .run();\n },\n };\n },\n});\n","import { Extension } from \"@tiptap/core\";\n\n/**\n * Routes plain End/Home through `Selection.modify` instead of the browser's\n * native caret movement.\n *\n * Chromium (verified 140–151, including stable Chrome) has a bug where a\n * native End or Home pressed while a triple-click selection is active puts\n * Blink's selection state into a mode where the next typed character\n * natively smooth-scrolls the nearest scrollable ancestor (the editor's\n * canvas, `.tpl-body`) to its very bottom (End) or top (Home), dragging the\n * caret out of view. The state cannot be repaired after the fact — clearing\n * or re-setting the DOM selection, blur/refocus, and preventDefault on the\n * clicks all fail — but a programmatic caret move never arms it.\n *\n * `Selection.modify(\"move\", direction, \"lineboundary\")` is the exact\n * equivalent of the native key (visual line boundary, bidi-aware via the\n * logical forward/backward directions), so behavior is unchanged for users.\n * Shift+End / Shift+Home extend selections natively and do not trigger the\n * bug, so only the plain keys are bound — a keymap entry without modifiers\n * never matches the shifted keys.\n */\nexport const LineBoundaryKeys = Extension.create({\n name: \"lineBoundaryKeys\",\n\n addKeyboardShortcuts() {\n const moveToLineBoundary =\n (direction: \"forward\" | \"backward\") =>\n ({ editor }: { editor: { view: unknown } }): boolean => {\n const view = editor.view as {\n composing: boolean;\n root: DocumentOrShadowRoot & {\n getSelection?: () => Selection | null;\n };\n dom: HTMLElement;\n };\n // During IME composition End/Home commit the composition; leave\n // that to the browser.\n if (!view || view.composing) return false;\n // `view.root` is the editable's Document or ShadowRoot, so the\n // selection resolves correctly in both mount modes. ShadowRoot's\n // getSelection is Chromium-only; elsewhere fall back to the owner\n // document (Chromium is also the only engine with the bug).\n const selection =\n typeof view.root?.getSelection === \"function\"\n ? view.root.getSelection()\n : (view.dom?.ownerDocument?.getSelection?.() ?? null);\n // `modify` is non-standard; without it, or with a selection that\n // is not ours, native handling is the safer default.\n if (!selection || typeof selection.modify !== \"function\") return false;\n if (!selection.anchorNode || !view.dom.contains(selection.anchorNode)) {\n return false;\n }\n selection.modify(\"move\", direction, \"lineboundary\");\n return true;\n };\n\n return {\n End: moveToLineBoundary(\"forward\"),\n Home: moveToLineBoundary(\"backward\"),\n };\n },\n});\n","import { Extension } from \"@tiptap/core\";\n\nexport interface LineHeightOptions {\n types: string[];\n defaultLineHeight: string;\n}\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n lineHeight: {\n setLineHeight: (lineHeight: string) => ReturnType;\n unsetLineHeight: () => ReturnType;\n };\n }\n}\n\nexport const LineHeight = Extension.create<LineHeightOptions>({\n name: \"lineHeight\",\n\n addOptions() {\n return {\n types: [\"paragraph\"],\n defaultLineHeight: \"1.5\",\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n lineHeight: {\n default: null,\n parseHTML: (element) => element.style.lineHeight || null,\n renderHTML: (attributes) => {\n if (!attributes.lineHeight) {\n return {};\n }\n return {\n style: `line-height: ${attributes.lineHeight}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setLineHeight:\n (lineHeight: string) =>\n ({ commands }) => {\n return this.options.types.every((type) =>\n commands.updateAttributes(type, { lineHeight }),\n );\n },\n unsetLineHeight:\n () =>\n ({ commands }) => {\n return this.options.types.every((type) =>\n commands.resetAttributes(type, \"lineHeight\"),\n );\n },\n };\n },\n});\n","<script setup lang=\"ts\">\nimport { useI18n } from \"../composables/useI18n\";\nimport { useMergeTag } from \"../composables/useMergeTag\";\nimport {\n getLogicMergeTagKeyword,\n isLogicMergeTagValue,\n} from \"@templatical/types\";\nimport type { Editor } from \"@tiptap/core\";\nimport { NodeViewWrapper } from \"@tiptap/vue-3\";\nimport { computed, nextTick, ref } from \"vue\";\n\nconst props = defineProps<{\n node: {\n attrs: {\n value: string;\n keyword: string;\n };\n };\n editor: Editor;\n getPos: () => number;\n deleteNode: () => void;\n updateAttributes: (attrs: Record<string, unknown>) => void;\n}>();\n\nconst { syntax } = useMergeTag();\nconst { t } = useI18n();\n\nconst isValid = computed(() =>\n isLogicMergeTagValue(props.node.attrs.value, syntax),\n);\nconst displayKeyword = computed(() =>\n getLogicMergeTagKeyword(props.node.attrs.value, syntax),\n);\n\nconst isEditing = ref(false);\nconst editValue = ref(\"\");\nconst inputRef = ref<HTMLInputElement | null>(null);\nlet handled = false;\n\nfunction startEditing(): void {\n editValue.value = props.node.attrs.value;\n handled = false;\n isEditing.value = true;\n nextTick(() => {\n inputRef.value?.focus();\n inputRef.value?.select();\n });\n}\n\nfunction finishEditing(): void {\n if (handled) {\n return;\n }\n handled = true;\n\n const newValue = editValue.value.trim();\n if (!newValue) {\n isEditing.value = false;\n return;\n }\n\n if (newValue !== props.node.attrs.value) {\n props.updateAttributes({\n value: newValue,\n keyword: isLogicMergeTagValue(newValue, syntax)\n ? getLogicMergeTagKeyword(newValue, syntax)\n : \"\",\n });\n }\n isEditing.value = false;\n}\n\nfunction handleKeydown(event: KeyboardEvent): void {\n if (event.key === \"Enter\") {\n event.preventDefault();\n finishEditing();\n } else if (event.key === \"Escape\") {\n isEditing.value = false;\n }\n}\n</script>\n\n<template>\n <NodeViewWrapper\n as=\"span\"\n :class=\"\n isValid\n ? 'tpl-logic-merge-tag-node tpl:group tpl:mx-0.5 tpl:inline-flex tpl:items-center tpl:gap-1 tpl:rounded tpl:px-1.5 tpl:py-0.5 tpl:text-[0.8em] tpl:font-bold tpl:tracking-wide tpl:uppercase tpl:select-none'\n : ''\n \"\n :style=\"\n isValid\n ? 'background-color: transparent; border: 1.5px solid color-mix(in srgb, var(--tpl-primary) 50%, transparent); color: var(--tpl-primary);'\n : ''\n \"\n contenteditable=\"false\"\n >\n <!-- Edit mode -->\n <input\n v-if=\"isEditing\"\n ref=\"inputRef\"\n v-model=\"editValue\"\n type=\"text\"\n class=\"tpl:w-40 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-0.5 tpl:py-0 tpl:text-[1em] tpl:font-medium tpl:normal-case tpl:outline-none tpl:text-[var(--tpl-primary)]\"\n @blur=\"finishEditing\"\n @keydown=\"handleKeydown\"\n />\n <!-- Display mode: valid merge tag -->\n <span\n v-else-if=\"isValid\"\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"t.mergeTag.editValue\"\n class=\"tpl-tooltip tpl:cursor-pointer\"\n :data-tooltip=\"node.attrs.value\"\n @click.stop=\"startEditing\"\n @keydown.enter.stop=\"startEditing\"\n @keydown.space.prevent.stop=\"startEditing\"\n >\n {{ displayKeyword }}\n </span>\n <!-- Display mode: invalid (plain text) -->\n <span\n v-else\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"t.mergeTag.editValue\"\n @click.stop=\"startEditing\"\n @keydown.enter.stop=\"startEditing\"\n @keydown.space.prevent.stop=\"startEditing\"\n >\n {{ node.attrs.value }}\n </span>\n <button\n v-if=\"isValid\"\n type=\"button\"\n :aria-label=\"t.mergeTag.deleteMergeTag\"\n class=\"tpl-merge-tag-delete tpl:flex tpl:size-5 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-full tpl:border-none tpl:bg-transparent tpl:p-0 tpl:opacity-60 tpl:transition-all tpl:hover:opacity-100 tpl:text-[var(--tpl-primary)]\"\n contenteditable=\"false\"\n @click.stop.prevent=\"deleteNode\"\n >\n <svg\n width=\"10\"\n height=\"10\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </NodeViewWrapper>\n</template>\n","<script setup lang=\"ts\">\nimport { useI18n } from \"../composables/useI18n\";\nimport { useMergeTag } from \"../composables/useMergeTag\";\nimport {\n getLogicMergeTagKeyword,\n isLogicMergeTagValue,\n} from \"@templatical/types\";\nimport type { Editor } from \"@tiptap/core\";\nimport { NodeViewWrapper } from \"@tiptap/vue-3\";\nimport { computed, nextTick, ref } from \"vue\";\n\nconst props = defineProps<{\n node: {\n attrs: {\n value: string;\n keyword: string;\n };\n };\n editor: Editor;\n getPos: () => number;\n deleteNode: () => void;\n updateAttributes: (attrs: Record<string, unknown>) => void;\n}>();\n\nconst { syntax } = useMergeTag();\nconst { t } = useI18n();\n\nconst isValid = computed(() =>\n isLogicMergeTagValue(props.node.attrs.value, syntax),\n);\nconst displayKeyword = computed(() =>\n getLogicMergeTagKeyword(props.node.attrs.value, syntax),\n);\n\nconst isEditing = ref(false);\nconst editValue = ref(\"\");\nconst inputRef = ref<HTMLInputElement | null>(null);\nlet handled = false;\n\nfunction startEditing(): void {\n editValue.value = props.node.attrs.value;\n handled = false;\n isEditing.value = true;\n nextTick(() => {\n inputRef.value?.focus();\n inputRef.value?.select();\n });\n}\n\nfunction finishEditing(): void {\n if (handled) {\n return;\n }\n handled = true;\n\n const newValue = editValue.value.trim();\n if (!newValue) {\n isEditing.value = false;\n return;\n }\n\n if (newValue !== props.node.attrs.value) {\n props.updateAttributes({\n value: newValue,\n keyword: isLogicMergeTagValue(newValue, syntax)\n ? getLogicMergeTagKeyword(newValue, syntax)\n : \"\",\n });\n }\n isEditing.value = false;\n}\n\nfunction handleKeydown(event: KeyboardEvent): void {\n if (event.key === \"Enter\") {\n event.preventDefault();\n finishEditing();\n } else if (event.key === \"Escape\") {\n isEditing.value = false;\n }\n}\n</script>\n\n<template>\n <NodeViewWrapper\n as=\"span\"\n :class=\"\n isValid\n ? 'tpl-logic-merge-tag-node tpl:group tpl:mx-0.5 tpl:inline-flex tpl:items-center tpl:gap-1 tpl:rounded tpl:px-1.5 tpl:py-0.5 tpl:text-[0.8em] tpl:font-bold tpl:tracking-wide tpl:uppercase tpl:select-none'\n : ''\n \"\n :style=\"\n isValid\n ? 'background-color: transparent; border: 1.5px solid color-mix(in srgb, var(--tpl-primary) 50%, transparent); color: var(--tpl-primary);'\n : ''\n \"\n contenteditable=\"false\"\n >\n <!-- Edit mode -->\n <input\n v-if=\"isEditing\"\n ref=\"inputRef\"\n v-model=\"editValue\"\n type=\"text\"\n class=\"tpl:w-40 tpl:rounded tpl:border-none tpl:bg-transparent tpl:px-0.5 tpl:py-0 tpl:text-[1em] tpl:font-medium tpl:normal-case tpl:outline-none tpl:text-[var(--tpl-primary)]\"\n @blur=\"finishEditing\"\n @keydown=\"handleKeydown\"\n />\n <!-- Display mode: valid merge tag -->\n <span\n v-else-if=\"isValid\"\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"t.mergeTag.editValue\"\n class=\"tpl-tooltip tpl:cursor-pointer\"\n :data-tooltip=\"node.attrs.value\"\n @click.stop=\"startEditing\"\n @keydown.enter.stop=\"startEditing\"\n @keydown.space.prevent.stop=\"startEditing\"\n >\n {{ displayKeyword }}\n </span>\n <!-- Display mode: invalid (plain text) -->\n <span\n v-else\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"t.mergeTag.editValue\"\n @click.stop=\"startEditing\"\n @keydown.enter.stop=\"startEditing\"\n @keydown.space.prevent.stop=\"startEditing\"\n >\n {{ node.attrs.value }}\n </span>\n <button\n v-if=\"isValid\"\n type=\"button\"\n :aria-label=\"t.mergeTag.deleteMergeTag\"\n class=\"tpl-merge-tag-delete tpl:flex tpl:size-5 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-full tpl:border-none tpl:bg-transparent tpl:p-0 tpl:opacity-60 tpl:transition-all tpl:hover:opacity-100 tpl:text-[var(--tpl-primary)]\"\n contenteditable=\"false\"\n @click.stop.prevent=\"deleteNode\"\n >\n <svg\n width=\"10\"\n height=\"10\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </NodeViewWrapper>\n</template>\n","import type { Editor } from \"@tiptap/core\";\n\n/**\n * Decides whether MergeTagNode / LogicMergeTagNode should swallow a\n * Backspace/Delete keystroke (returning `true` from a TipTap keymap\n * suppresses the default behavior).\n *\n * Only suppresses in the cursor-adjacent case so the \"first press\n * selects the atom, second press deletes it\" UX works. Range selections\n * (Cmd+A, drag-select, double-click-word) explicitly fall through —\n * default `replaceSelection` then deletes the entire range including\n * any merge-tag atoms inside it.\n *\n * Earlier revisions also returned `true` whenever `nodesBetween($from,\n * $to)` found a merge tag anywhere in the selection range — which\n * silently broke Cmd+A + Backspace for any paragraph containing a\n * merge tag (entire deletion was cancelled, nothing happened). The\n * cursor-adjacent protection is the only piece that should survive.\n */\nexport function isNodeSelected(editor: Editor, nodeTypeName: string): boolean {\n const { $from, $to } = editor.state.selection;\n\n // Range selection: let TipTap's default range-delete run. Even when\n // the range contains atom nodes, ProseMirror's replaceSelection\n // handles atomic deletion correctly.\n if ($from.pos !== $to.pos) return false;\n\n // Cursor-adjacent atom: protect from single-keystroke deletion.\n // (`$from.pos > 0` guards against reading `nodeBefore` at doc start\n // where ProseMirror's index would be undefined for nodeBefore.)\n if ($from.pos > 0 && $from.nodeBefore?.type.name === nodeTypeName) {\n return true;\n }\n if ($from.nodeAfter?.type.name === nodeTypeName) {\n return true;\n }\n\n return false;\n}\n","import type { Component } from \"vue\";\nimport { VueNodeViewRenderer } from \"@tiptap/vue-3\";\n\n/**\n * Typed wrapper for VueNodeViewRenderer that handles the known type mismatch\n * between Vue SFC default exports and TipTap's expected component type.\n */\nexport function renderVueNodeView(component: Component) {\n return VueNodeViewRenderer(\n component as Parameters<typeof VueNodeViewRenderer>[0],\n );\n}\n","import LogicMergeTagNodeView from \"./LogicMergeTagNodeView.vue\";\nimport type { SyntaxPreset } from \"@templatical/types\";\nimport {\n getLogicMergeTagKeyword,\n isLogicMergeTagValue,\n SYNTAX_PRESETS,\n} from \"@templatical/types\";\nimport { InputRule, mergeAttributes, Node, PasteRule } from \"@tiptap/core\";\nimport { isNodeSelected } from \"./isNodeSelected\";\nimport { renderVueNodeView } from \"./renderVueNodeView\";\n\nexport interface LogicMergeTagNodeOptions {\n syntax: SyntaxPreset;\n}\n\nexport const LogicMergeTagNode = Node.create<LogicMergeTagNodeOptions>({\n name: \"logicMergeTagNode\",\n\n group: \"inline\",\n\n inline: true,\n\n atom: true,\n\n addOptions() {\n return {\n syntax: SYNTAX_PRESETS.liquid,\n };\n },\n\n addAttributes() {\n return {\n // Both attributes are state, not markup, same as `MergeTagNode`:\n // `renderHTML()` emits the canonical `data-logic-merge-tag` /\n // `data-keyword` pair and `parseHTML` reads only those. `rendered: false`\n // keeps TipTap from also serializing each attribute under its own name,\n // which would put a write-only duplicate of the same data on every tag.\n value: {\n default: \"\",\n rendered: false,\n parseHTML: (element) =>\n element.getAttribute(\"data-logic-merge-tag\") || \"\",\n },\n keyword: {\n default: \"\",\n rendered: false,\n parseHTML: (element) =>\n element.getAttribute(\"data-keyword\") || element.textContent || \"\",\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-logic-merge-tag]\",\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n if (!isLogicMergeTagValue(node.attrs.value, this.options.syntax)) {\n return [\"span\", {}, node.attrs.value];\n }\n\n const keyword = getLogicMergeTagKeyword(\n node.attrs.value,\n this.options.syntax,\n );\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-logic-merge-tag\": node.attrs.value,\n \"data-keyword\": keyword,\n }),\n keyword,\n ];\n },\n\n addNodeView() {\n return renderVueNodeView(LogicMergeTagNodeView);\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => isNodeSelected(this.editor, this.name),\n Delete: () => isNodeSelected(this.editor, this.name),\n };\n },\n\n addInputRules() {\n const inputRegex = new RegExp(this.options.syntax.logic.source + \"$\", \"\");\n\n return [\n new InputRule({\n find: inputRegex,\n handler: ({ state, range, match }) => {\n const fullValue = match[0];\n if (!isLogicMergeTagValue(fullValue, this.options.syntax)) {\n return;\n }\n\n const keyword = getLogicMergeTagKeyword(\n fullValue,\n this.options.syntax,\n );\n\n const node = this.type.create({\n value: fullValue,\n keyword,\n });\n\n state.tr.replaceWith(range.from, range.to, node);\n },\n }),\n ];\n },\n\n addPasteRules() {\n const pasteRegex = new RegExp(this.options.syntax.logic.source, \"g\");\n\n return [\n new PasteRule({\n find: pasteRegex,\n handler: ({ state, range, match }) => {\n const fullValue = match[0];\n if (!isLogicMergeTagValue(fullValue, this.options.syntax)) {\n return;\n }\n\n const keyword = getLogicMergeTagKeyword(\n fullValue,\n this.options.syntax,\n );\n\n const node = this.type.create({\n value: fullValue,\n keyword,\n });\n\n state.tr.replaceWith(range.from, range.to, node);\n },\n }),\n ];\n },\n});\n","<script setup lang=\"ts\">\nimport { useI18n } from \"../composables/useI18n\";\nimport { useMergeTag } from \"../composables/useMergeTag\";\nimport { NodeViewWrapper } from \"@tiptap/vue-3\";\nimport { computed, nextTick, onScopeDispose, ref } from \"vue\";\n\nconst props = defineProps<{\n node: {\n attrs: {\n label: string;\n value: string;\n };\n };\n deleteNode: () => void;\n updateAttributes: (attrs: Record<string, unknown>) => void;\n}>();\n\nconst {\n getMergeTagLabel,\n getMergeTagDisplayLabel,\n findMergeTag,\n canRepickMergeTag,\n showRawValue,\n isMergeTagValue,\n requestMergeTag,\n} = useMergeTag();\nconst { t, format } = useI18n();\n\n// `node.attrs.label` is the label captured when the tag was inserted. It is\n// only ever a fallback — the configured tags win, which is what keeps a\n// relabelled tag from rendering its stale stored copy.\nconst displayLabel = computed(() =>\n getMergeTagDisplayLabel(props.node.attrs.value, props.node.attrs.label),\n);\nconst canRepick = computed(() => canRepickMergeTag(props.node.attrs.value));\n\nconst isEditing = ref(false);\nconst editValue = ref(\"\");\nconst inputRef = ref<HTMLInputElement | null>(null);\n\n// The chooser mounts in the popover root, outside this node view, so the node\n// can be torn down while it is open — a collaborator edit, a block change, the\n// editor unmounting. Writing attributes onto a destroyed node view throws.\nlet disposed = false;\nonScopeDispose(() => {\n disposed = true;\n});\n\n/** Whether the text currently in the raw input is a usable merge tag. */\nconst isEditValueValid = computed(\n () =>\n editValue.value.trim() === \"\" || isMergeTagValue(editValue.value.trim()),\n);\n\n/**\n * Swap this tag for another one, chosen through the same chooser insertion\n * uses. `requestMergeTag` sets the editor-wide requesting flag for the whole\n * await, which is what stops `useRichTextEditor`'s click-outside handler\n * finishing the block when the user clicks a row in the chooser — that would\n * dispose this node view and silently drop the update.\n */\nasync function repick(): Promise<void> {\n const replacement = await requestMergeTag({\n reason: \"edit\",\n current: findMergeTag(props.node.attrs.value),\n });\n if (disposed || !replacement) return;\n props.updateAttributes({\n value: replacement.value,\n label: replacement.label,\n });\n}\n\nfunction startEditing(): void {\n editValue.value = props.node.attrs.value;\n isEditing.value = true;\n nextTick(() => {\n inputRef.value?.focus();\n inputRef.value?.select();\n });\n}\n\n/**\n * Activating the chip opens the chooser when one can resolve this token, and\n * the raw input only when none can. Editing a token as free text is how a\n * chip ends up holding something that is not a merge tag at all, which the\n * renderer then emits verbatim into the sent email.\n */\nfunction activate(): void {\n if (canRepick.value) {\n void repick();\n return;\n }\n startEditing();\n}\n\nfunction finishEditing(): void {\n const newValue = editValue.value.trim();\n // Never commit something that isn't a merge tag: `renderHTML` writes the\n // value straight into `data-merge-tag`, and the renderer drops that into the\n // MJML unchanged, so a typo would ship as literal text in the email.\n if (\n newValue &&\n newValue !== props.node.attrs.value &&\n isMergeTagValue(newValue)\n ) {\n props.updateAttributes({\n // The honest resolution, not the display chain: this is written into the\n // document as `data-label`, so a placeholder would be persisted as if it\n // were the tag's name.\n value: newValue,\n label: getMergeTagLabel(newValue),\n });\n }\n isEditing.value = false;\n}\n\nfunction handleKeydown(event: KeyboardEvent): void {\n if (event.key === \"Enter\") {\n event.preventDefault();\n // Enter on an invalid value keeps the input open rather than discarding\n // what was typed — the border and `aria-invalid` already say why.\n if (!isEditValueValid.value) return;\n finishEditing();\n } else if (event.key === \"Escape\") {\n isEditing.value = false;\n }\n}\n</script>\n\n<template>\n <NodeViewWrapper\n as=\"span\"\n class=\"tpl-merge-tag-node tpl:group tpl:mx-0.5 tpl:inline-flex tpl:items-center tpl:gap-1 tpl:rounded tpl:px-1.5 tpl:py-0.5 tpl:text-[0.9em] tpl:font-medium tpl:select-none tpl:text-[var(--tpl-primary)]\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-primary) 20%, transparent);\n \"\n contenteditable=\"false\"\n >\n <!-- Edit mode -->\n <input\n v-if=\"isEditing\"\n ref=\"inputRef\"\n v-model=\"editValue\"\n type=\"text\"\n :aria-invalid=\"isEditValueValid ? undefined : 'true'\"\n class=\"tpl:w-32 tpl:rounded tpl:bg-transparent tpl:px-0.5 tpl:py-0 tpl:text-[1em] tpl:font-medium tpl:outline-none tpl:text-[var(--tpl-primary)]\"\n :class=\"\n isEditValueValid\n ? 'tpl:border-none'\n : 'tpl:border tpl:border-[var(--tpl-danger)]'\n \"\n @blur=\"finishEditing\"\n @keydown=\"handleKeydown\"\n />\n <!-- Display mode -->\n <span\n v-else\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"\n canRepick\n ? format(t.mergeTag.changeTag, { label: displayLabel })\n : t.mergeTag.editValue\n \"\n class=\"tpl:cursor-pointer\"\n :class=\"showRawValue ? 'tpl-tooltip' : ''\"\n :data-tooltip=\"showRawValue ? node.attrs.value : undefined\"\n @click.stop=\"activate\"\n @keydown.enter.stop=\"activate\"\n @keydown.space.prevent.stop=\"activate\"\n >\n {{ displayLabel }}\n </span>\n <button\n type=\"button\"\n :aria-label=\"t.mergeTag.deleteMergeTag\"\n class=\"tpl-merge-tag-delete tpl:flex tpl:size-5 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-full tpl:border-none tpl:bg-transparent tpl:p-0 tpl:opacity-60 tpl:transition-all tpl:hover:opacity-100 tpl:text-[var(--tpl-primary)]\"\n contenteditable=\"false\"\n @click.stop.prevent=\"deleteNode\"\n >\n <svg\n width=\"10\"\n height=\"10\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </NodeViewWrapper>\n</template>\n","<script setup lang=\"ts\">\nimport { useI18n } from \"../composables/useI18n\";\nimport { useMergeTag } from \"../composables/useMergeTag\";\nimport { NodeViewWrapper } from \"@tiptap/vue-3\";\nimport { computed, nextTick, onScopeDispose, ref } from \"vue\";\n\nconst props = defineProps<{\n node: {\n attrs: {\n label: string;\n value: string;\n };\n };\n deleteNode: () => void;\n updateAttributes: (attrs: Record<string, unknown>) => void;\n}>();\n\nconst {\n getMergeTagLabel,\n getMergeTagDisplayLabel,\n findMergeTag,\n canRepickMergeTag,\n showRawValue,\n isMergeTagValue,\n requestMergeTag,\n} = useMergeTag();\nconst { t, format } = useI18n();\n\n// `node.attrs.label` is the label captured when the tag was inserted. It is\n// only ever a fallback — the configured tags win, which is what keeps a\n// relabelled tag from rendering its stale stored copy.\nconst displayLabel = computed(() =>\n getMergeTagDisplayLabel(props.node.attrs.value, props.node.attrs.label),\n);\nconst canRepick = computed(() => canRepickMergeTag(props.node.attrs.value));\n\nconst isEditing = ref(false);\nconst editValue = ref(\"\");\nconst inputRef = ref<HTMLInputElement | null>(null);\n\n// The chooser mounts in the popover root, outside this node view, so the node\n// can be torn down while it is open — a collaborator edit, a block change, the\n// editor unmounting. Writing attributes onto a destroyed node view throws.\nlet disposed = false;\nonScopeDispose(() => {\n disposed = true;\n});\n\n/** Whether the text currently in the raw input is a usable merge tag. */\nconst isEditValueValid = computed(\n () =>\n editValue.value.trim() === \"\" || isMergeTagValue(editValue.value.trim()),\n);\n\n/**\n * Swap this tag for another one, chosen through the same chooser insertion\n * uses. `requestMergeTag` sets the editor-wide requesting flag for the whole\n * await, which is what stops `useRichTextEditor`'s click-outside handler\n * finishing the block when the user clicks a row in the chooser — that would\n * dispose this node view and silently drop the update.\n */\nasync function repick(): Promise<void> {\n const replacement = await requestMergeTag({\n reason: \"edit\",\n current: findMergeTag(props.node.attrs.value),\n });\n if (disposed || !replacement) return;\n props.updateAttributes({\n value: replacement.value,\n label: replacement.label,\n });\n}\n\nfunction startEditing(): void {\n editValue.value = props.node.attrs.value;\n isEditing.value = true;\n nextTick(() => {\n inputRef.value?.focus();\n inputRef.value?.select();\n });\n}\n\n/**\n * Activating the chip opens the chooser when one can resolve this token, and\n * the raw input only when none can. Editing a token as free text is how a\n * chip ends up holding something that is not a merge tag at all, which the\n * renderer then emits verbatim into the sent email.\n */\nfunction activate(): void {\n if (canRepick.value) {\n void repick();\n return;\n }\n startEditing();\n}\n\nfunction finishEditing(): void {\n const newValue = editValue.value.trim();\n // Never commit something that isn't a merge tag: `renderHTML` writes the\n // value straight into `data-merge-tag`, and the renderer drops that into the\n // MJML unchanged, so a typo would ship as literal text in the email.\n if (\n newValue &&\n newValue !== props.node.attrs.value &&\n isMergeTagValue(newValue)\n ) {\n props.updateAttributes({\n // The honest resolution, not the display chain: this is written into the\n // document as `data-label`, so a placeholder would be persisted as if it\n // were the tag's name.\n value: newValue,\n label: getMergeTagLabel(newValue),\n });\n }\n isEditing.value = false;\n}\n\nfunction handleKeydown(event: KeyboardEvent): void {\n if (event.key === \"Enter\") {\n event.preventDefault();\n // Enter on an invalid value keeps the input open rather than discarding\n // what was typed — the border and `aria-invalid` already say why.\n if (!isEditValueValid.value) return;\n finishEditing();\n } else if (event.key === \"Escape\") {\n isEditing.value = false;\n }\n}\n</script>\n\n<template>\n <NodeViewWrapper\n as=\"span\"\n class=\"tpl-merge-tag-node tpl:group tpl:mx-0.5 tpl:inline-flex tpl:items-center tpl:gap-1 tpl:rounded tpl:px-1.5 tpl:py-0.5 tpl:text-[0.9em] tpl:font-medium tpl:select-none tpl:text-[var(--tpl-primary)]\"\n style=\"\n background-color: color-mix(in srgb, var(--tpl-primary) 20%, transparent);\n \"\n contenteditable=\"false\"\n >\n <!-- Edit mode -->\n <input\n v-if=\"isEditing\"\n ref=\"inputRef\"\n v-model=\"editValue\"\n type=\"text\"\n :aria-invalid=\"isEditValueValid ? undefined : 'true'\"\n class=\"tpl:w-32 tpl:rounded tpl:bg-transparent tpl:px-0.5 tpl:py-0 tpl:text-[1em] tpl:font-medium tpl:outline-none tpl:text-[var(--tpl-primary)]\"\n :class=\"\n isEditValueValid\n ? 'tpl:border-none'\n : 'tpl:border tpl:border-[var(--tpl-danger)]'\n \"\n @blur=\"finishEditing\"\n @keydown=\"handleKeydown\"\n />\n <!-- Display mode -->\n <span\n v-else\n role=\"button\"\n tabindex=\"0\"\n :aria-label=\"\n canRepick\n ? format(t.mergeTag.changeTag, { label: displayLabel })\n : t.mergeTag.editValue\n \"\n class=\"tpl:cursor-pointer\"\n :class=\"showRawValue ? 'tpl-tooltip' : ''\"\n :data-tooltip=\"showRawValue ? node.attrs.value : undefined\"\n @click.stop=\"activate\"\n @keydown.enter.stop=\"activate\"\n @keydown.space.prevent.stop=\"activate\"\n >\n {{ displayLabel }}\n </span>\n <button\n type=\"button\"\n :aria-label=\"t.mergeTag.deleteMergeTag\"\n class=\"tpl-merge-tag-delete tpl:flex tpl:size-5 tpl:cursor-pointer tpl:items-center tpl:justify-center tpl:rounded-full tpl:border-none tpl:bg-transparent tpl:p-0 tpl:opacity-60 tpl:transition-all tpl:hover:opacity-100 tpl:text-[var(--tpl-primary)]\"\n contenteditable=\"false\"\n @click.stop.prevent=\"deleteNode\"\n >\n <svg\n width=\"10\"\n height=\"10\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </button>\n </NodeViewWrapper>\n</template>\n","import MergeTagNodeView from \"./MergeTagNodeView.vue\";\nimport type { MergeTag, SyntaxPreset } from \"@templatical/types\";\nimport { getMergeTagLabel, SYNTAX_PRESETS } from \"@templatical/types\";\nimport { InputRule, mergeAttributes, Node, PasteRule } from \"@tiptap/core\";\nimport { isNodeSelected } from \"./isNodeSelected\";\nimport { renderVueNodeView } from \"./renderVueNodeView\";\n\nexport interface MergeTagNodeOptions {\n /**\n * Read live, not captured. `renderHTML` and the input/paste rules resolve a\n * label every time they run, and `editor.setMergeTags` can replace the list\n * while a block is open for editing.\n */\n mergeTags: () => MergeTag[];\n syntax: SyntaxPreset;\n}\n\n/**\n * Inserted-node attrs are intentionally limited to `label` + `value`. The\n * `MergeTag` interface also carries optional `group` / `description` for\n * the built-in picker, but those are display-only and must NOT leak into\n * the document JSON — they would bloat templates and pollute serialized\n * state. `Pick<>` makes the constraint explicit at the type level.\n */\nexport type InsertMergeTagAttrs = Pick<MergeTag, \"label\" | \"value\">;\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n mergeTagNode: {\n insertMergeTag: (attrs: InsertMergeTagAttrs) => ReturnType;\n };\n }\n}\n\nexport const MergeTagNode = Node.create<MergeTagNodeOptions>({\n name: \"mergeTagNode\",\n\n group: \"inline\",\n\n inline: true,\n\n atom: true,\n\n addOptions() {\n return {\n mergeTags: () => [],\n syntax: SYNTAX_PRESETS.liquid,\n };\n },\n\n addAttributes() {\n return {\n // Both attributes are state, not markup: `renderHTML()` below emits the\n // canonical `data-merge-tag` / `data-label` pair and `parseHTML` reads\n // only those. `rendered: false` keeps TipTap from also serializing each\n // attribute under its own name, which would put a write-only duplicate\n // of the same data on every tag — invalid on a `<span>`, and paid again\n // through storage, autosave, snapshots and version history.\n label: {\n default: \"\",\n rendered: false,\n parseHTML: (element) =>\n element.getAttribute(\"data-label\") || element.textContent || \"\",\n },\n value: {\n default: \"\",\n rendered: false,\n parseHTML: (element) => element.getAttribute(\"data-merge-tag\") || \"\",\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: \"span[data-merge-tag]\",\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const label = getMergeTagLabel(node.attrs.value, this.options.mergeTags());\n\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-merge-tag\": node.attrs.value,\n \"data-label\": label,\n }),\n label,\n ];\n },\n\n addNodeView() {\n return renderVueNodeView(MergeTagNodeView);\n },\n\n addCommands() {\n return {\n insertMergeTag:\n (attrs: InsertMergeTagAttrs) =>\n ({ commands }) => {\n // Whitelist explicitly — even if a caller smuggles extra keys via\n // a wider type assertion, only label/value reach the node attrs.\n return commands.insertContent({\n type: this.name,\n attrs: { label: attrs.label, value: attrs.value },\n });\n },\n };\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => isNodeSelected(this.editor, this.name),\n Delete: () => isNodeSelected(this.editor, this.name),\n };\n },\n\n addInputRules() {\n const inputRegex = new RegExp(this.options.syntax.value.source + \"$\", \"\");\n\n return [\n new InputRule({\n find: inputRegex,\n handler: ({ state, range, match }) => {\n const fullValue = match[0];\n const label = getMergeTagLabel(fullValue, this.options.mergeTags());\n\n const node = this.type.create({\n label,\n value: fullValue,\n });\n\n state.tr.replaceWith(range.from, range.to, node);\n },\n }),\n ];\n },\n\n addPasteRules() {\n const pasteRegex = new RegExp(this.options.syntax.value.source, \"g\");\n\n return [\n new PasteRule({\n find: pasteRegex,\n handler: ({ state, range, match }) => {\n const fullValue = match[0];\n const label = getMergeTagLabel(fullValue, this.options.mergeTags());\n\n const node = this.type.create({\n label,\n value: fullValue,\n });\n\n state.tr.replaceWith(range.from, range.to, node);\n },\n }),\n ];\n },\n});\n","import type { MergeTag } from \"@templatical/types\";\nimport { Extension } from \"@tiptap/core\";\nimport Suggestion, {\n type SuggestionOptions,\n type SuggestionProps,\n type SuggestionKeyDownProps,\n} from \"@tiptap/suggestion\";\nimport type { Ref } from \"vue\";\nimport { createMergeTagPopup, filterMergeTags } from \"../utils/mergeTagPopup\";\n\nexport interface MergeTagSuggestionOptions {\n /** Available merge tags */\n /**\n * Read live, not captured: the list can be replaced while a block is being\n * edited (`editor.setMergeTags`), and a snapshot taken when the extension\n * was configured would keep suggesting the old tags.\n */\n mergeTags: () => MergeTag[];\n /** Trigger string (e.g. \"{{\", \"*|\", \"%%=\") */\n char: string;\n /** Localized empty-state label */\n emptyText: string;\n /**\n * Mount target for the suggestion popup. When provided with a non-null\n * `.value`, the popup attaches into that element instead of\n * `document.body` — keeping it inside the editor's effective DOM root\n * (shadow-aware). Pass the ref returned by `usePopoverRoot()`.\n *\n * Falls back to `document.body` when omitted or when the ref's value is\n * null at popup-open time (e.g. headless/test editors without an editor\n * shell). Preserves pre-Phase-3 behavior for callers that don't migrate.\n */\n popoverRoot?: Ref<HTMLElement | null> | null;\n}\n\n/**\n * Builds the `@tiptap/suggestion` `render` factory for the merge-tag popup.\n * A thin adapter over {@link createMergeTagPopup}: it maps ProseMirror's\n * `SuggestionProps` (items, `clientRect`, `view.dom`, `command`) onto the\n * controller. Exported as a standalone function so that mapping can be\n * unit-tested with mocked `SuggestionProps` instead of a full editor.\n */\nexport function createMergeTagSuggestionRenderer(\n emptyText: string,\n popoverRootRef?: Ref<HTMLElement | null> | null,\n): NonNullable<SuggestionOptions<MergeTag>[\"render\"]> {\n return () => {\n const popup = createMergeTagPopup(emptyText, popoverRootRef);\n\n return {\n onStart: (props: SuggestionProps<MergeTag>) => {\n // Use view.dom (ProseMirror contenteditable, actually\n // attached to the DOM) rather than options.element, which may\n // be a detached div when no `element` is passed to the editor\n // constructor (as is the case with @tiptap/vue-3 EditorContent).\n const viewDom = props.editor.view?.dom as HTMLElement | undefined;\n popup.open({\n items: props.items,\n getRect: props.clientRect ?? null,\n anchorEl: viewDom ?? null,\n onCommand: (item) => props.command(item),\n });\n },\n onUpdate: (props: SuggestionProps<MergeTag>) => {\n popup.update({\n items: props.items,\n getRect: props.clientRect ?? null,\n onCommand: (item) => props.command(item),\n });\n },\n onKeyDown: (props: SuggestionKeyDownProps): boolean => {\n // Escape closes via TipTap's suggestion plugin (→ onExit); report it\n // handled without selecting.\n if (props.event.key === \"Escape\") {\n return true;\n }\n return popup.handleKeyDown(props.event);\n },\n onExit: () => popup.close(),\n };\n };\n}\n\nexport const MergeTagSuggestion = Extension.create<MergeTagSuggestionOptions>({\n name: \"mergeTagSuggestion\",\n\n addOptions() {\n return {\n mergeTags: () => [],\n char: \"{{\",\n emptyText: \"No matching merge tags\",\n popoverRoot: null,\n };\n },\n\n addProseMirrorPlugins() {\n const getMergeTags = this.options.mergeTags;\n const emptyText = this.options.emptyText;\n const popoverRootRef = this.options.popoverRoot;\n\n const config: Omit<SuggestionOptions<MergeTag>, \"editor\"> = {\n char: this.options.char,\n allowSpaces: false,\n startOfLine: false,\n // Default is [\" \"] which requires whitespace/line-start before the\n // trigger char — so `.{{` would not fire. Allow any preceding char.\n allowedPrefixes: null,\n items: ({ query }: { query: string }) =>\n filterMergeTags(getMergeTags(), query),\n command: ({\n editor,\n range,\n props,\n }: {\n editor: SuggestionProps<MergeTag>[\"editor\"];\n range: { from: number; to: number };\n props: MergeTag;\n }) => {\n // Use insertContentAt for atomic replace (matches the canonical\n // @tiptap/suggestion + Mention pattern). Avoids edge cases where\n // chained deleteRange + insertMergeTag fails to insert when the\n // selection state shifts mid-chain.\n editor\n .chain()\n .focus()\n .insertContentAt(range, {\n type: \"mergeTagNode\",\n attrs: { label: props.label, value: props.value },\n })\n .run();\n },\n render: createMergeTagSuggestionRenderer(emptyText, popoverRootRef),\n };\n\n return [\n Suggestion({\n editor: this.editor,\n ...config,\n }),\n ];\n },\n});\n"],"mappings":";;;;;;;AAeA,IAAasE,IAAWT,EAAU,OAAwB;CACxD,MAAM;CAEN,aAAa;EACX,OAAO,EACL,OAAO,CAAC,WAAW,EACrB;CACF;CAEA,sBAAsB;EACpB,OAAO,CACL;GACE,OAAO,KAAK,QAAQ;GACpB,YAAY,EACV,UAAU;IACR,SAAS;IACT,YAAY,MACVU,EAAQ,MAAM,UAAU,QAAQ,UAAU,EAAE,KAAK;IACnD,aAAa,MACNC,EAAW,WAGT,EACL,OAAO,cAAcA,EAAW,WAClC,IAJS,CAAC;GAMd,EACF;EACF,CACF;CACF;CAEA,cAAc;EACZ,OAAO;GACL,cACG,OACA,EAAE,eACMC,EAAM,CAAC,CAAC,QAAQ,aAAa,EAAE,UAAUC,EAAK,CAAC,CAAC,CAAC,IAAI;GAEhE,sBAEG,EAAE,eACMD,EAAM,CAAC,CACX,QAAQ,aAAa,EAAE,UAAU,KAAK,CAAC,CAAC,CACxC,qBAAqB,CAAC,CACtB,IAAI;EAEb;CACF;AACF,CAAC,GCjDYE,IAAgBd,EAAU,OAA6B;CAClE,MAAM;CAEN,aAAa;EACX,OAAO,EACL,OAAO,CAAC,WAAW,EACrB;CACF;CAEA,sBAAsB;EACpB,OAAO,C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