@useinsider/guido 3.1.1 → 3.2.0-beta.080341b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/README.md +117 -0
  2. package/dist/@types/config/schemas.js +166 -96
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +92 -80
  5. package/dist/components/organisms/AutoSaveController.vue.js +17 -0
  6. package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  9. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  10. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  11. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  12. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  13. package/dist/components/organisms/header/RightSlot.vue.js +11 -11
  14. package/dist/components/organisms/header/RightSlot.vue2.js +17 -13
  15. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  16. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  17. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  18. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  19. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  20. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  21. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  22. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  23. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  24. package/dist/composables/useActionsApi.js +4 -4
  25. package/dist/composables/useAutoSave.js +71 -0
  26. package/dist/composables/useFullStoryBridge.js +14 -0
  27. package/dist/composables/useHtmlCompiler.js +23 -21
  28. package/dist/composables/useHtmlValidator.js +40 -38
  29. package/dist/composables/usePreviewMode.js +20 -16
  30. package/dist/composables/useRecommendation.js +46 -26
  31. package/dist/composables/useRibbonOffset.js +21 -0
  32. package/dist/composables/useSave.js +26 -15
  33. package/dist/composables/useStripo.js +48 -45
  34. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  35. package/dist/composables/validators/useLiquidValidator.js +42 -0
  36. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  37. package/dist/config/compiler/recommendationCompilerRules.js +162 -43
  38. package/dist/config/compiler/unsubscribeCompilerRules.js +48 -45
  39. package/dist/config/compiler/utils/recommendationCompilerUtils.js +110 -71
  40. package/dist/config/i18n/en/tooltips.json.js +2 -1
  41. package/dist/config/migrator/checkboxMigrator.js +5 -3
  42. package/dist/config/migrator/index.js +9 -9
  43. package/dist/config/migrator/radioButtonMigrator.js +66 -44
  44. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  45. package/dist/config/migrator/recommendation/extractors.js +27 -0
  46. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  47. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  48. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  49. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  50. package/dist/config/migrator/recommendationMigrator.js +74 -290
  51. package/dist/enums/extensions/recommendationBlock.js +16 -12
  52. package/dist/enums/onboarding.js +7 -2
  53. package/dist/enums/recommendation.js +2 -2
  54. package/dist/enums/unsubscribe.js +34 -27
  55. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  56. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  57. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  58. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  59. package/dist/extensions/Blocks/Recommendation/block.js +60 -50
  60. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  61. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  62. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  63. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  64. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  65. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  66. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +27 -26
  67. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  68. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +211 -162
  69. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  70. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  71. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  72. package/dist/extensions/Blocks/Recommendation/services/configService.js +76 -33
  73. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  74. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
  75. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +24 -13
  76. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  77. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  78. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +27 -15
  79. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
  80. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  81. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
  82. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  83. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  84. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  85. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  86. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  87. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  88. package/dist/guido.css +1 -1
  89. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
  90. package/dist/node_modules/valibot/dist/index.js +450 -235
  91. package/dist/package.json.js +1 -1
  92. package/dist/services/recommendationApi.js +15 -15
  93. package/dist/services/stripoApi.js +9 -9
  94. package/dist/services/templateLibraryApi.js +49 -46
  95. package/dist/src/@types/config/defaults.d.ts +5 -1
  96. package/dist/src/@types/config/index.d.ts +3 -3
  97. package/dist/src/@types/config/schemas.d.ts +245 -0
  98. package/dist/src/@types/config/types.d.ts +11 -1
  99. package/dist/src/@types/generic.d.ts +0 -1
  100. package/dist/src/@types/save-as-template.d.ts +1 -0
  101. package/dist/src/components/Guido.vue.d.ts +1 -1
  102. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
  103. package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
  104. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  105. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  106. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  107. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  108. package/dist/src/composables/useActionsApi.d.ts +1 -1
  109. package/dist/src/composables/useAutoSave.d.ts +3 -0
  110. package/dist/src/composables/useConfig.d.ts +70 -0
  111. package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
  112. package/dist/src/composables/useRecommendation.d.ts +10 -1
  113. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  114. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  115. package/dist/src/composables/useSave.d.ts +1 -1
  116. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  117. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  118. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  119. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
  120. package/dist/src/config/migrator/index.d.ts +2 -1
  121. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  122. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  123. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  124. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  125. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  126. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  127. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  128. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  129. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  130. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  131. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  132. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  133. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  134. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  135. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  136. package/dist/src/enums/onboarding.d.ts +6 -0
  137. package/dist/src/enums/unsubscribe.d.ts +5 -0
  138. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  139. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  140. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  141. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  142. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  143. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  144. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  145. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  146. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  147. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  148. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  149. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +21 -3
  150. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  151. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  152. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  153. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  154. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  155. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  156. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  157. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  158. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  159. package/dist/src/library.d.ts +1 -1
  160. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  161. package/dist/src/stores/autosave.d.ts +12 -0
  162. package/dist/src/stores/config.d.ts +630 -0
  163. package/dist/src/stores/editor.d.ts +23 -0
  164. package/dist/src/stores/onboarding.d.ts +4 -0
  165. package/dist/src/stores/preview.d.ts +3 -0
  166. package/dist/src/utils/genericUtil.d.ts +1 -1
  167. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  168. package/dist/src/utils/htmlEscape.d.ts +5 -0
  169. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  170. package/dist/src/utils/timeUtil.d.ts +8 -0
  171. package/dist/static/styles/base.css.js +7 -2
  172. package/dist/static/styles/components/button.css.js +16 -9
  173. package/dist/static/styles/components/loader.css.js +4 -0
  174. package/dist/static/styles/components/narrow-panel.css.js +52 -0
  175. package/dist/stores/autosave.js +17 -0
  176. package/dist/stores/editor.js +3 -1
  177. package/dist/stores/onboarding.js +4 -0
  178. package/dist/stores/preview.js +4 -3
  179. package/dist/utils/genericUtil.js +42 -20
  180. package/dist/utils/htmlCompiler.js +48 -41
  181. package/dist/utils/htmlEscape.js +13 -0
  182. package/dist/utils/pairProductVariables.js +89 -88
  183. package/dist/utils/templatePreparation.js +75 -24
  184. package/dist/utils/timeUtil.js +19 -0
  185. package/dist/utils/tooltipUtils.js +4 -5
  186. package/package.json +8 -4
  187. package/dist/enums/displayConditions.js +0 -80
  188. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  189. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -0,0 +1,71 @@
1
+ import { useConfig as m } from "./useConfig.js";
2
+ import { useAutosaveStore as A, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
3
+ import { useEditorStore as E } from "../stores/editor.js";
4
+ import { computed as f, watch as p, onUnmounted as y } from "vue";
5
+ const I = 18e4, r = 6e4, T = (b) => {
6
+ const { isFeatureEnabled: S } = m(), a = E(), t = A();
7
+ let i = null, c = 0;
8
+ const u = f(
9
+ () => S("autosave") && t.isOn
10
+ ), g = () => a.hasChanges && a.isInSaveableState, h = () => ({
11
+ hasChanges: a.hasChanges,
12
+ isInSaveableState: a.isInSaveableState
13
+ }), l = async (e) => {
14
+ if (!u.value) {
15
+ console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
16
+ return;
17
+ }
18
+ if (!g()) {
19
+ console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: h() });
20
+ return;
21
+ }
22
+ if (t.status === s.SAVING) {
23
+ console.debug("guido:autosave:skipped", { trigger: e, reason: "already-saving" });
24
+ return;
25
+ }
26
+ console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
27
+ try {
28
+ if (await b() === void 0) {
29
+ console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
30
+ return;
31
+ }
32
+ a.hasChanges = !1, t.status = s.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
33
+ } catch (o) {
34
+ console.debug("guido:autosave:error", { trigger: e, error: o }), t.status = s.ERROR;
35
+ }
36
+ }, n = () => {
37
+ const { visibilityState: e } = document;
38
+ if (console.debug("guido:autosave:visibility-change", {
39
+ visibilityState: e,
40
+ isActive: u.value
41
+ }), e !== "hidden")
42
+ return;
43
+ const o = Date.now() - c;
44
+ if (o < r) {
45
+ console.debug("guido:autosave:visibility-debounced", {
46
+ sinceLastMs: o,
47
+ debounceMs: r
48
+ });
49
+ return;
50
+ }
51
+ c = Date.now(), l("visibility");
52
+ }, d = () => {
53
+ i && (clearInterval(i), i = null);
54
+ }, v = () => {
55
+ document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
56
+ };
57
+ p(
58
+ u,
59
+ (e) => {
60
+ console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
61
+ console.debug("guido:autosave:interval-tick"), l("interval");
62
+ }, I), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), v(), t.status = s.IDLE);
63
+ },
64
+ { immediate: !0 }
65
+ ), y(() => {
66
+ d(), v(), t.status = s.IDLE, t.lastSavedAt = null;
67
+ });
68
+ };
69
+ export {
70
+ T as useAutoSave
71
+ };
@@ -0,0 +1,14 @@
1
+ const c = "https://email-static.useinsider.com/guido/guido-fs.js", u = () => ({ injectFullStory: () => {
2
+ var n;
3
+ const s = window;
4
+ if (typeof s._fs_org != "string" || !s._fs_org)
5
+ return;
6
+ const r = document.querySelector("ui-editor"), o = (n = r == null ? void 0 : r.shadowRoot) == null ? void 0 : n.querySelector("iframe"), e = o == null ? void 0 : o.contentDocument;
7
+ if (!e || e.querySelector('script[data-fullstory-bridge="true"]'))
8
+ return;
9
+ const t = e.createElement("script");
10
+ t.src = c, t.async = !0, t.crossOrigin = "anonymous", t.dataset.fullstoryBridge = "true", e.head.appendChild(t);
11
+ } });
12
+ export {
13
+ u as useFullStoryBridge
14
+ };
@@ -1,28 +1,30 @@
1
- import { defaultHtmlCompilerRules as p } from "../config/compiler/htmlCompilerRules.js";
2
- import { itemsCompilerRules as u } from "../config/compiler/itemsCompilerRules.js";
3
- import { outlookCompilerRules as c } from "../config/compiler/outlookCompilerRules.js";
4
- import { recommendationCompilerRules as n } from "../config/compiler/recommendationCompilerRules.js";
5
- import { socialCompilerRules as f } from "../config/compiler/socialCompilerRules.js";
6
- import { unsubscribeCompilerRules as R } from "../config/compiler/unsubscribeCompilerRules.js";
7
- import { createHtmlCompiler as a } from "../utils/htmlCompiler.js";
8
- import { useConfig as C } from "./useConfig.js";
9
- const B = () => {
10
- var m, l;
11
- const { compiler: e } = C(), r = ((m = e.value) == null ? void 0 : m.customRules) || [], t = [
12
- ...!!((l = e.value) != null && l.ignoreDefaultRules) ? [] : p,
13
- ...n,
14
- ...R,
15
- ...u,
16
- ...c,
1
+ import { defaultHtmlCompilerRules as c } from "../config/compiler/htmlCompilerRules.js";
2
+ import { itemsCompilerRules as f } from "../config/compiler/itemsCompilerRules.js";
3
+ import { liquidCompilerRules as R } from "../config/compiler/liquidCompilerRules.js";
4
+ import { outlookCompilerRules as C } from "../config/compiler/outlookCompilerRules.js";
5
+ import { recommendationCompilerRules as d } from "../config/compiler/recommendationCompilerRules.js";
6
+ import { socialCompilerRules as b } from "../config/compiler/socialCompilerRules.js";
7
+ import { unsubscribeCompilerRules as g } from "../config/compiler/unsubscribeCompilerRules.js";
8
+ import { createHtmlCompiler as H } from "../utils/htmlCompiler.js";
9
+ import { useConfig as v } from "./useConfig.js";
10
+ const w = () => {
11
+ var l, m, r;
12
+ const { compiler: e, isFeatureEnabled: t, partner: i } = v(), s = ((l = e.value) == null ? void 0 : l.customRules) || [], u = [
13
+ ...!!((m = e.value) != null && m.ignoreDefaultRules) ? [] : c,
14
+ ...d,
15
+ ...g,
17
16
  ...f,
18
- ...r.map((o, s) => ({
17
+ ...C,
18
+ ...b,
19
+ ...t("liquidSyntax") ? R : [],
20
+ ...s.map((o, a) => ({
19
21
  ...o,
20
- priority: o.priority + 1e3 + s
22
+ priority: o.priority + 1e3 + a
21
23
  // Ensure additional rules run after default rules
22
24
  }))
23
- ], i = a(t);
24
- return { compileHtml: (o) => i.compile(o) };
25
+ ], p = H(u), n = (r = i.value) == null ? void 0 : r.fallbackFont;
26
+ return { compileHtml: (o) => p.compile(o, void 0, n) };
25
27
  };
26
28
  export {
27
- B as useHtmlCompiler
29
+ w as useHtmlCompiler
28
30
  };
@@ -9,76 +9,76 @@ import { useHttp as j } from "./useHttp.js";
9
9
  import { useToaster as q } from "./useToaster.js";
10
10
  import { useTranslations as z } from "./useTranslations.js";
11
11
  const K = /recommendation-id="(\d+)"/g;
12
- function U(i) {
13
- return [...i.matchAll(K)].map((u) => u[1]);
12
+ function U(a) {
13
+ return [...a.matchAll(K)].map((u) => u[1]);
14
14
  }
15
- function Y(i, u) {
16
- return u.some((d) => i.startsWith(`${d}_`));
15
+ function Y(a, u) {
16
+ return u.some((d) => a.startsWith(`${d}_`));
17
17
  }
18
18
  const ce = () => {
19
19
  var y, h;
20
- const { showToaster: i } = q(), { post: u } = j(), { config: d } = L(), r = z(), g = $(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === V.transactional, w = async (e) => {
20
+ const { showToaster: a } = q(), { post: u } = j(), { config: d } = L(), r = z(), g = $(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === V.transactional, b = async (e) => {
21
21
  const t = await u(
22
22
  "/newsletter/template-library/check-template-html-body",
23
23
  { html: X(e) }
24
24
  ), { status: n, message: l } = t.data;
25
- return n || i({
25
+ return n || a({
26
26
  type: c.Alert,
27
27
  message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
28
- }), r(P), l === r(G) && i({
28
+ }), r(P), l === r(G) && a({
29
29
  type: c.Alert,
30
30
  message: r("newsletter.already-in-progress")
31
31
  }), n;
32
- }, b = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
32
+ }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
33
33
  const t = e.match(/({%(.*?)%})/g);
34
34
  let n = !0;
35
35
  return t !== null && !p && t.forEach((l) => {
36
36
  const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
37
37
  if (o && o.length > 0) {
38
- const [a] = o;
39
- b(a) && !s.includes(a) && (i({
38
+ const [i] = o;
39
+ w(i) && !s.includes(i) && (a({
40
40
  type: c.Warning,
41
41
  message: r("custom-fields.invalid-custom-fields")
42
42
  }), n = !1);
43
43
  }
44
44
  }), n;
45
45
  }, A = async (e, s, t) => {
46
- const n = t ? await w(e) : !0;
46
+ const n = t ? await b(e) : !0;
47
47
  return E(e, s) && n;
48
- }, I = (e) => e.length > 0 ? !0 : (i({
48
+ }, I = (e) => e.length > 0 ? !0 : (a({
49
49
  type: c.Warning,
50
50
  message: r("newsletter.html-content-is-empty")
51
51
  }), !1), k = (e) => {
52
52
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
53
- return s > t && i({
53
+ return s > t && a({
54
54
  type: c.Warning,
55
55
  message: r("custom-fields.missing-closing-braces")
56
- }), s < t && i({
56
+ }), s < t && a({
57
57
  type: c.Warning,
58
58
  message: r("custom-fields.missing-opening-braces")
59
59
  }), s === t;
60
60
  }, x = (e) => {
61
61
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
62
- return s || i({
62
+ return s || a({
63
63
  type: c.Warning,
64
64
  message: r("custom-fields.invalid-custom-fields")
65
65
  }), s;
66
66
  }, T = (e, s) => {
67
67
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
68
68
  if (t && !p) {
69
- const n = new Set(s.map((a) => a.toLowerCase())), l = U(e), o = [];
70
- if (t.forEach((a) => {
71
- const m = a.slice(2, -2).trim().toLowerCase();
69
+ const n = new Set(s.map((i) => i.toLowerCase())), l = U(e), o = [];
70
+ if (t.forEach((i) => {
71
+ const m = i.slice(2, -2).trim().toLowerCase();
72
72
  (!n.has(m) || m === "") && !Y(m, l) && o.push(m);
73
73
  }), o.length > 0) {
74
- const a = `
74
+ const i = `
75
75
  <ul>
76
76
  ${o.map((m) => `<li>${m}</li>`).join("")}
77
77
  </ul>
78
78
  `;
79
- return i({
79
+ return a({
80
80
  type: c.Alert,
81
- message: r("custom-fields.invalid-custom-fields") + a
81
+ message: r("custom-fields.invalid-custom-fields") + i
82
82
  }), !1;
83
83
  }
84
84
  }
@@ -87,12 +87,12 @@ const ce = () => {
87
87
  const s = e.match(/{%(.*?)%}/g), t = [];
88
88
  let n = !0;
89
89
  if (s && s.forEach((l) => {
90
- const o = l.match(_), a = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
91
- (!o || l !== m) && !a && (i({
90
+ const o = l.match(_), i = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
91
+ (!o || l !== m) && !i && (a({
92
92
  type: c.Alert,
93
93
  message: r("newsletter.display-conditions-invalid-syntax")
94
94
  }), n = !1), o && o.forEach((f) => {
95
- f.trim() === "=" && (i({
95
+ f.trim() === "=" && (a({
96
96
  type: c.Alert,
97
97
  message: r("custom-conditions.wrong-equality-operators")
98
98
  }), n = !1);
@@ -102,8 +102,8 @@ const ce = () => {
102
102
  });
103
103
  });
104
104
  }), t.length) {
105
- const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
106
- l.length !== o.length && (i({
105
+ const l = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
106
+ l.length !== o.length && (a({
107
107
  type: c.Alert,
108
108
  message: r("custom-conditions.missing-if-endif-tag")
109
109
  }), n = !1);
@@ -111,45 +111,47 @@ const ce = () => {
111
111
  return n;
112
112
  }, W = (e) => {
113
113
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
114
- return n || i({
114
+ return n || a({
115
115
  type: c.Warning,
116
116
  message: r("custom-conditions.no-space-after-braces")
117
117
  }), n;
118
- }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
118
+ }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
119
119
  type: c.Warning,
120
120
  message: r("custom-conditions.no-braces-inside-if-tag")
121
- }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
121
+ }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
122
122
  type: c.Alert,
123
123
  message: r("newsletter.fill-all-necessary-fields")
124
124
  }), !1) : !0, B = (e) => {
125
125
  const s = /src="[^"]*\.(svg|pst)"/gm;
126
- return e.match(s) === null ? !0 : (i({
126
+ return e.match(s) === null ? !0 : (a({
127
127
  type: c.Alert,
128
128
  message: r("newsletter.invalid-image-type")
129
129
  }), !1);
130
130
  }, R = (e) => {
131
131
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
132
132
  return Array.from(n).find((o) => {
133
- var a;
134
- return !((a = o.id) != null && a.trim());
135
- }) ? (i({
133
+ var i;
134
+ return !((i = o.id) != null && i.trim());
135
+ }) ? (a({
136
136
  type: c.Alert,
137
137
  message: r("unsubscribe-templates.select-checkbox-groups")
138
138
  }), !1) : !0;
139
139
  }, D = (e) => {
140
140
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
141
141
  return Array.from(n).find((o) => {
142
- var a;
143
- return !((a = o.id) != null && a.trim());
144
- }) ? (i({
142
+ var i;
143
+ return !((i = o.id) != null && i.trim());
144
+ }) ? (a({
145
145
  type: c.Alert,
146
146
  message: r("unsubscribe-templates.select-radio-button-groups")
147
147
  }), !1) : !0;
148
148
  };
149
149
  return { validateHtml: async (e, s, t = !1) => {
150
+ var o, i;
150
151
  const n = [
151
- ...s.map((o) => o.value),
152
- ...M
152
+ ...s.map((m) => m.value),
153
+ ...M,
154
+ ...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
153
155
  ];
154
156
  return await A(e, n, t) && I(e) && k(e) && x(e) && T(e, n) && F(e) && W(e) && N(e) && O() && B(e) && R(e) && D(e);
155
157
  } };
@@ -1,31 +1,35 @@
1
- import { useEditorStore as n } from "../stores/editor.js";
2
- import { usePreviewStore as l } from "../stores/preview.js";
3
- import { useActionsApi as m } from "./useActionsApi.js";
4
- import { useCodeEditorApi as p } from "./useCodeEditorApi.js";
5
- const E = () => {
6
- const o = n(), e = l(), { closeCodeEditor: a } = p(), { getPreviewData: s } = m(), r = () => {
7
- o.isPreviewModeOpen = !1, e.$reset();
1
+ import { useEditorStore as d } from "../stores/editor.js";
2
+ import { usePreviewStore as n } from "../stores/preview.js";
3
+ import { useActionsApi as p } from "./useActionsApi.js";
4
+ import { useCodeEditorApi as c } from "./useCodeEditorApi.js";
5
+ import { useHtmlCompiler as u } from "./useHtmlCompiler.js";
6
+ const g = () => {
7
+ const t = d(), e = n(), { closeCodeEditor: i } = c(), { getPreviewData: a, getCompiledEmail: s } = p(), { compileHtml: m } = u(), r = () => {
8
+ t.isPreviewModeOpen = !1, e.$reset();
8
9
  };
9
10
  return {
10
11
  closePreviewMode: r,
11
12
  openPreviewMode: () => {
12
- o.isCodeEditorOpen && a(), o.isPreviewModeOpen = !0;
13
+ t.isCodeEditorOpen && i(), t.isPreviewModeOpen = !0;
13
14
  },
14
15
  loadPreviewData: async () => {
15
- if (!(o.loadingStatus || e.isLoaded)) {
16
- o.loadingStatus = !0;
16
+ if (!(t.loadingStatus || e.isLoaded)) {
17
+ t.loadingStatus = !0;
17
18
  try {
18
- const { html: t, ampHtml: i, ampErrors: d } = await s();
19
- e.templateHtml = t || "", e.ampHtml = i || "", e.ampErrors = d || [], e.setEmailFormat(i ? "AMP" : "html"), e.isLoaded = !0;
20
- } catch (t) {
21
- console.error("Failed to load preview data:", t), r();
19
+ const [o, l] = await Promise.all([
20
+ a(),
21
+ s({ minimize: !0, resetDataSavedFlag: !1 })
22
+ ]);
23
+ e.templateHtml = o.html || "", e.ampHtml = o.ampHtml || "", e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = m(l.html).estimatedSizeKB, e.isLoaded = !0;
24
+ } catch (o) {
25
+ console.error("Failed to load preview data:", o), r();
22
26
  } finally {
23
- o.loadingStatus = !1;
27
+ t.loadingStatus = !1;
24
28
  }
25
29
  }
26
30
  }
27
31
  };
28
32
  };
29
33
  export {
30
- E as usePreviewMode
34
+ g as usePreviewMode
31
35
  };
@@ -1,21 +1,21 @@
1
- import { RecommendationFeedSourceMaps as g, URLS as p } from "../enums/extensions/recommendationBlock.js";
1
+ import { RecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
2
2
  import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
- import { useRecommendationExtensionStore as u } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { generateCompleteFilterQuery as x } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
- import { useConfigStore as I } from "../stores/config.js";
6
- const N = () => ({
3
+ import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { useConfigStore as x } from "../stores/config.js";
6
+ const w = () => ({
7
7
  calculateCardWidth: ({
8
- mobileLeftPadding: i,
9
- mobileRightPadding: n,
10
- cardsInRow: o,
11
- unresponsive: a
8
+ mobileLeftPadding: s,
9
+ mobileRightPadding: a,
10
+ cardsInRow: c,
11
+ unresponsive: n
12
12
  }) => {
13
- const r = a ? o : 1, e = i + n + (r - 1) * b;
13
+ const r = n ? c : 1, e = s + a + (r - 1) * b;
14
14
  return (R - e) / r;
15
15
  },
16
- getRecommendationCampaignData: (i) => {
17
- const n = u(), o = Number(i), a = n.blockStates[o];
18
- if (!a)
16
+ getRecommendationCampaignData: (s) => {
17
+ const a = m(), c = Number(s), n = a.blockStates[c];
18
+ if (!n)
19
19
  return {
20
20
  textTrimming: !1,
21
21
  orientation: "vertical",
@@ -28,7 +28,7 @@ const N = () => ({
28
28
  discountBeforeTextValue: "",
29
29
  discountAfterTextValue: ""
30
30
  };
31
- const { recommendationConfigs: r } = a, e = r.orientation === "grid" ? "vertical" : "horizontal";
31
+ const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
32
32
  return {
33
33
  textTrimming: r.textTrimming,
34
34
  orientation: e,
@@ -42,19 +42,39 @@ const N = () => ({
42
42
  discountAfterTextValue: ""
43
43
  };
44
44
  },
45
- buildCampaignUrl: (i) => {
46
- var m;
47
- const n = u(), o = I(), a = Number(i), r = n.blockStates[a];
48
- if (!r)
49
- return "";
50
- const { recommendationConfigs: e } = r, l = ((m = g.find((s) => s.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
51
- t.set("locale", e.language), t.set("currency", e.currencySettings.value), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
52
- const f = e.filters.filter((s) => s.isValid), c = x(f);
53
- c && t.set("filter", c), e.shuffleProducts && t.set("shuffle", "true");
54
- const d = `${p.RECOMMENDATION_API_URL}/v2/${l}?${t.toString()}`;
55
- return n.recommendationCampaignUrls[i] = d, d;
45
+ buildCampaignUrl: (s, a) => {
46
+ var l;
47
+ const c = m(), n = x(), r = Number(s);
48
+ let e;
49
+ if (a)
50
+ e = a;
51
+ else {
52
+ const i = c.blockStates[r];
53
+ if (!i)
54
+ return "";
55
+ const { recommendationConfigs: o } = i;
56
+ e = {
57
+ strategy: o.strategy,
58
+ language: o.language,
59
+ currencyCode: o.currencySettings.value,
60
+ size: o.size,
61
+ productIds: o.productIds,
62
+ filters: o.filters,
63
+ shuffleProducts: o.shuffleProducts
64
+ };
65
+ }
66
+ const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
+ if (t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising") {
68
+ const i = parseInt(e.size) || 6;
69
+ t.set("productId", e.productIds.slice(0, i).join(","));
70
+ } else e.strategy === "similarViewed" && t.set("productId", "{itemId}");
71
+ e.strategy === "userBased" && t.set("userId", "{user_id}");
72
+ const g = e.filters.filter((i) => i.isValid), d = h(g);
73
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true");
74
+ const p = decodeURIComponent(t.toString()), u = `${C.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
75
+ return c.recommendationCampaignUrls[s] = u, u;
56
76
  }
57
77
  });
58
78
  export {
59
- N as useRecommendation
79
+ w as useRecommendation
60
80
  };
@@ -0,0 +1,21 @@
1
+ import { RIBBON_SELECTOR as r } from "../enums/onboarding.js";
2
+ import { ref as f, onMounted as c, onBeforeUnmount as i } from "vue";
3
+ const m = () => {
4
+ const o = f(0);
5
+ let e = null;
6
+ const n = () => {
7
+ const t = document.querySelector(r), s = (t == null ? void 0 : t.offsetHeight) ?? 0;
8
+ o.value !== s && (o.value = s);
9
+ }, u = (t) => `${t + o.value}px`;
10
+ return c(() => {
11
+ n(), e = new MutationObserver(n), e.observe(document.body, {
12
+ childList: !0,
13
+ subtree: !0
14
+ });
15
+ }), i(() => {
16
+ e == null || e.disconnect();
17
+ }), { ribbonOffset: o, getTopPosition: u };
18
+ };
19
+ export {
20
+ m as useRibbonOffset
21
+ };
@@ -1,21 +1,32 @@
1
- import { useConfig as d } from "./useConfig.js";
2
- import { useSaveStart as p, useSaveComplete as f } from "./useGuidoActions.js";
3
- import { useSyncModuleExtractor as v } from "./useSyncModuleExtractor.js";
4
- import { useStripoApi as S } from "../services/stripoApi.js";
5
- import { useTemplatePreparation as x } from "../utils/templatePreparation.js";
6
- import { useHtmlValidator as V } from "./useHtmlValidator.js";
7
- const g = () => {
8
- const o = p(), s = f(), { validateHtml: i } = V(), { callbacks: a } = d(), { extractSyncModuleData: r } = v(), { setSyncModuleUnsubscriptionPages: n } = S();
9
- return { save: async (l = !1) => {
10
- var e;
1
+ import { useActionsApi as x } from "./useActionsApi.js";
2
+ import { useConfig as y } from "./useConfig.js";
3
+ import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
4
+ import { useSyncModuleExtractor as H } from "./useSyncModuleExtractor.js";
5
+ import { useStripoApi as b } from "../services/stripoApi.js";
6
+ import { useTemplatePreparation as q } from "../utils/templatePreparation.js";
7
+ import { useHtmlValidator as L } from "./useHtmlValidator.js";
8
+ import { useCouponBlockValidator as P } from "./validators/useCouponBlockValidator.js";
9
+ import { useLiquidValidator as E } from "./validators/useLiquidValidator.js";
10
+ const j = () => {
11
+ const o = w(), s = C(), { validateHtml: r } = L(), { validateLiquidSyntax: l } = E(), { validateCouponBlockTags: n } = P(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = H(), { setSyncModuleUnsubscriptionPages: c } = b(), { editorSave: m } = x();
12
+ return { save: async (p = !1, f = !1) => {
13
+ var i;
11
14
  o();
12
- const { prepareTemplateDetails: c } = x(), t = await c();
13
- if (!await i(t.compiledHtml, t.dynamicContentList, !0) || (e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t))
15
+ const { prepareTemplateDetails: v } = q(), t = await v();
16
+ if (!n(t.compiledHtml))
14
17
  return;
15
- const { unsubscribePayload: m, stripoModules: u } = r(t.rawHtml);
16
- return await n(m), t.modules = u, l || s(t), t;
18
+ if (d("liquidSyntax")) {
19
+ if (!await l(t.compiledHtml))
20
+ return;
21
+ } else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
22
+ return;
23
+ if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
24
+ return;
25
+ await m();
26
+ const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
27
+ return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
17
28
  } };
18
29
  };
19
30
  export {
20
- g as useSave
31
+ j as useSave
21
32
  };