@useinsider/guido 3.19.0 → 3.20.0-beta.0849ec7

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 (148) hide show
  1. package/README.md +22 -3
  2. package/dist/@types/config/schemas.js +76 -53
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +102 -86
  5. package/dist/components/organisms/AutoSaveController.vue2.js +9 -8
  6. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  7. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  8. package/dist/components/organisms/base/Toaster.vue2.js +13 -12
  9. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
  10. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
  11. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  12. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  13. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
  14. package/dist/components/organisms/header/EditorActions.vue.js +5 -5
  15. package/dist/components/organisms/header/EditorActions.vue2.js +90 -57
  16. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  17. package/dist/components/organisms/header/LeftSlot.vue2.js +16 -12
  18. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
  19. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  20. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  21. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
  22. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
  23. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +20 -0
  24. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +49 -0
  25. package/dist/components/wrappers/WpDrawer.vue.js +9 -7
  26. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  27. package/dist/components/wrappers/WpModal.vue.js +1 -1
  28. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  29. package/dist/composables/useActionsApi.js +52 -47
  30. package/dist/composables/useAuthError.js +52 -0
  31. package/dist/composables/useAutoSave.js +11 -11
  32. package/dist/composables/useCodeEditorApi.js +23 -9
  33. package/dist/composables/useCortexBlueprintBridge.js +122 -54
  34. package/dist/composables/useCustomInterfaceAppearance.js +65 -51
  35. package/dist/composables/useEmailTemplateApplier.js +111 -50
  36. package/dist/composables/useHtmlCompiler.js +37 -26
  37. package/dist/composables/useHtmlValidator.js +89 -82
  38. package/dist/composables/useHttp.js +64 -54
  39. package/dist/composables/useLegacyStrategyConversion.js +65 -0
  40. package/dist/composables/useRecommendation.js +40 -35
  41. package/dist/composables/useSave.js +90 -45
  42. package/dist/composables/useSaveValidation.js +282 -0
  43. package/dist/composables/useSaveValidationRollout.js +9 -0
  44. package/dist/composables/useStripo.js +43 -39
  45. package/dist/composables/useToaster.js +18 -22
  46. package/dist/composables/useTranslations.js +3 -2
  47. package/dist/composables/useVersionHistoryApi.js +33 -24
  48. package/dist/composables/validators/useCouponBlockValidator.js +24 -21
  49. package/dist/composables/validators/useLiquidValidator.js +15 -15
  50. package/dist/composables/validators/useUnsubscribeBlockValidator.js +34 -27
  51. package/dist/config/migrator/index.js +14 -13
  52. package/dist/config/migrator/itemsBlockMigrator.js +236 -248
  53. package/dist/config/migrator/recommendationMigrator.js +28 -21
  54. package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
  55. package/dist/enums/extensions/recommendationBlock.js +51 -34
  56. package/dist/enums/save-validation.js +4 -0
  57. package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
  58. package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
  59. package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
  60. package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
  61. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
  62. package/dist/extensions/Blocks/Items/template.js +219 -204
  63. package/dist/extensions/Blocks/Recommendation/block.js +65 -45
  64. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
  65. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +103 -90
  66. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +150 -52
  67. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
  68. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +274 -92
  69. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  70. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
  71. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
  72. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  73. package/dist/extensions/Blocks/Recommendation/utils/productIds.js +5 -3
  74. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
  75. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
  76. package/dist/guido.css +1 -1
  77. package/dist/services/recommendationApi.js +46 -37
  78. package/dist/src/@types/config/schemas.d.ts +36 -0
  79. package/dist/src/@types/save-validation.d.ts +19 -0
  80. package/dist/src/components/Guido.vue.d.ts +17 -1
  81. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  82. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  83. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +17 -1
  84. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +17 -1
  85. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +17 -1
  86. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  87. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
  88. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +2 -0
  89. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +4 -3
  90. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  91. package/dist/src/composables/useAuthError.d.ts +12 -0
  92. package/dist/src/composables/useConfig.d.ts +8 -0
  93. package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
  94. package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
  95. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  96. package/dist/src/composables/useHtmlValidator.d.ts +21 -0
  97. package/dist/src/composables/useHttp.d.ts +2 -0
  98. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  99. package/dist/src/composables/useSave.d.ts +6 -1
  100. package/dist/src/composables/useSaveValidation.d.ts +6 -0
  101. package/dist/src/composables/useSaveValidationRollout.d.ts +3 -0
  102. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  103. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +10 -0
  104. package/dist/src/config/migrator/index.d.ts +2 -1
  105. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  106. package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
  107. package/dist/src/enums/save-validation.d.ts +27 -0
  108. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
  109. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  110. package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
  111. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  112. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
  113. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  114. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
  115. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
  116. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
  117. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
  118. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  119. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  120. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  121. package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +2 -0
  122. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
  123. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
  124. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  125. package/dist/src/services/recommendationApi.d.ts +2 -1
  126. package/dist/src/stores/config.d.ts +374 -0
  127. package/dist/src/stores/guido-email-editor.d.ts +20 -10
  128. package/dist/src/stores/onboarding.d.ts +812 -10
  129. package/dist/src/stores/recommendation.d.ts +5 -0
  130. package/dist/src/stores/save-validation.d.ts +22 -0
  131. package/dist/src/utils/dateUtil.d.ts +10 -0
  132. package/dist/src/utils/genericUtil.d.ts +3 -0
  133. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  134. package/dist/src/utils/templatePreparation.d.ts +30 -0
  135. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  136. package/dist/static/assets/icons/line-info.svg.js +5 -0
  137. package/dist/static/styles/components/recommendation-strategy.css.js +113 -9
  138. package/dist/static/styles/components/skeleton.css.js +23 -0
  139. package/dist/static/styles/components/version-history.css.js +2 -6
  140. package/dist/stores/config.js +55 -24
  141. package/dist/stores/guido-email-editor.js +3 -1
  142. package/dist/stores/onboarding.js +50 -36
  143. package/dist/stores/save-validation.js +30 -0
  144. package/dist/stores/unsubscribe.js +3 -3
  145. package/dist/utils/pairProductVariables.js +71 -71
  146. package/dist/utils/stripoEditorApi.js +11 -0
  147. package/dist/utils/templatePreparation.js +54 -51
  148. package/package.json +2 -1
@@ -1,70 +1,138 @@
1
- import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
2
- import { useToaster as I } from "./useToaster.js";
3
- import { useTranslations as P } from "./useTranslations.js";
4
- import { ToasterTypeOptions as S } from "../enums/toaster.js";
5
- import { getActivePinia as v } from "pinia";
6
- import { watch as B, onUnmounted as D } from "vue";
7
- const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
1
+ import { useEmailTemplateApplier as z, resetEmailTemplateApplier as J } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as Q } from "./useToaster.js";
3
+ import { useTranslations as V } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as Z } from "../enums/toaster.js";
5
+ import { useGuidoEmailEditorStore as W } from "../stores/guido-email-editor.js";
6
+ import { getActivePinia as k } from "pinia";
7
+ import { onUnmounted as tt, watch as et } from "vue";
8
+ const rt = "email_template", nt = "chat", ot = "guido:debug:ai", it = 2, lt = 500, ct = (b, p) => `${b}:${p ?? 1}`;
9
+ let S = null;
10
+ const at = () => {
8
11
  if (typeof window > "u")
9
12
  return !1;
10
13
  try {
11
- return window.localStorage.getItem(M) === "1";
14
+ return window.localStorage.getItem(ot) === "1";
12
15
  } catch {
13
16
  return !1;
14
17
  }
15
- }, H = () => {
16
- const c = v();
17
- if (!c)
18
+ }, bt = () => {
19
+ const b = k();
20
+ if (!b)
18
21
  return;
19
- const l = c._s, p = l == null ? void 0 : l.get(L);
20
- if (!p)
21
- return;
22
- const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: E } = I(), h = P(), y = (r, t) => {
23
- const e = h(r);
24
- return e === r ? t : e;
25
- }, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), A = (r, t) => {
26
- u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
27
- }, b = (r) => {
28
- if (r.blueprintType !== x)
22
+ const p = W(), M = Symbol("cortexBlueprintBridge");
23
+ S = M, p.$patch((t) => {
24
+ t.bridgeActive = !0;
25
+ });
26
+ const { markPending: F, applyTemplate: H, applyTemplateDebounced: O } = z(), { showToaster: C } = Q(), G = V(), E = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
27
+ let s = null;
28
+ const d = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), B = at();
29
+ let w = null, m = null, A;
30
+ const K = (t, r) => {
31
+ B && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
32
+ }, U = () => new Set((A == null ? void 0 : A.appliedBlueprintKeys) ?? []), Y = (t) => t instanceof Error ? t.message : String(t), D = (t, r, n, e) => {
33
+ if (S !== M)
34
+ return;
35
+ const o = p.applyAcks[t], c = Math.max(Date.now(), ((o == null ? void 0 : o.ackAt) ?? 0) + 1), a = { status: r, requestedAt: n, ackAt: c };
36
+ e !== void 0 && (a.error = Y(e)), p.$patch((l) => {
37
+ l.applyAcks = { ...l.applyAcks, [t]: a };
38
+ });
39
+ }, I = (t) => (d.get(t) ?? 0) > 0, P = (t) => (s == null ? void 0 : s.key) === t, v = async (t, r, n) => {
40
+ var a, l, h;
41
+ const e = ((a = r.blueprintData) == null ? void 0 : a.html) ?? "", o = ((l = r.blueprintData) == null ? void 0 : l.css) ?? "", c = r.applyRequestedAt ?? 0;
42
+ d.set(t, (d.get(t) ?? 0) + 1);
43
+ try {
44
+ const i = n === "debounced" ? await O(t, { html: e, css: o }) : await H(t, { html: e, css: o });
45
+ if (i.status === "superseded")
46
+ return;
47
+ if (i.status === "applied") {
48
+ E.set(t, e), u.delete(t), D(t, "applied", c);
49
+ return;
50
+ }
51
+ const y = u.get(t), j = (y == null ? void 0 : y.html) === e ? y.count + 1 : 1;
52
+ u.set(t, { html: e, count: j }), D(t, "failed", c, i.error);
53
+ } catch (i) {
54
+ console.error("[guido:apply] apply threw before it could settle", i), D(t, "failed", c, i);
55
+ } finally {
56
+ d.set(t, (d.get(t) ?? 1) - 1);
57
+ const i = T.get(t);
58
+ i && !I(t) && (T.delete(t), P(t) && (((h = i.blueprintData) == null ? void 0 : h.html) ?? "") !== e && v(t, i, n));
59
+ }
60
+ }, N = (t) => {
61
+ var h;
62
+ if (t.blueprintType !== rt)
29
63
  return;
30
- const t = r.blueprintId, e = r.blueprintData;
31
- if (!t || !(e != null && e.html))
64
+ const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
65
+ if (!r || !n)
32
66
  return;
33
- if (!r.applyRequested) {
34
- d(t);
67
+ const e = ct(r, t.version);
68
+ if (!t.applyRequested) {
69
+ F(e);
70
+ return;
71
+ }
72
+ const o = t.applyRequestedAt ?? 0, c = _.get(e);
73
+ if (c === void 0 || o > c) {
74
+ const i = c === void 0;
75
+ if (_.set(e, o), u.delete(e), (!s || o >= s.requestedAt) && (s = { key: e, requestedAt: o }), i && U().has(e)) {
76
+ E.set(e, n);
77
+ return;
78
+ }
79
+ v(e, t, "immediate");
80
+ return;
81
+ }
82
+ const a = E.get(e);
83
+ if (a === n || !P(e))
35
84
  return;
85
+ const l = u.get(e);
86
+ if (!((l == null ? void 0 : l.html) === n && l.count >= it)) {
87
+ if (a === void 0) {
88
+ if (I(e)) {
89
+ T.set(e, t);
90
+ return;
91
+ }
92
+ v(e, t, "immediate");
93
+ return;
94
+ }
95
+ f.get(e) !== n && (f.set(e, n), v(e, t, "debounced").finally(() => {
96
+ f.get(e) === n && f.delete(e);
97
+ }));
36
98
  }
37
- const o = i.get(t);
38
- o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
39
- }, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), E({
40
- type: S.Error,
41
- message: y("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
42
- }), !0), m = B(
43
- () => p.messages,
44
- (r) => {
45
- Array.isArray(r) && r.forEach((t) => {
46
- const e = t == null ? void 0 : t.id;
47
- (t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
48
- const o = t == null ? void 0 : t.segments;
49
- Array.isArray(o) && o.forEach((n) => {
50
- if (n)
51
- switch (A(e, n), n.type) {
52
- case "blueprint":
53
- b(n);
54
- break;
55
- case "error":
56
- s(e);
57
- break;
58
- }
59
- });
99
+ }, R = (t) => t === void 0 || g.has(t) ? !1 : (g.add(t), C({
100
+ type: Z.Error,
101
+ message: G("newsletter.ai-template-failed")
102
+ }), !0), X = (t) => {
103
+ Array.isArray(t) && t.forEach((r) => {
104
+ const n = r == null ? void 0 : r.id;
105
+ (r == null ? void 0 : r.isError) === !0 && R(n) && B && console.debug(`[guido:cortex] message-level error id=${n}`, r);
106
+ const e = r == null ? void 0 : r.segments;
107
+ Array.isArray(e) && e.forEach((o) => {
108
+ if (o)
109
+ switch (K(n, o), o.type) {
110
+ case "blueprint":
111
+ N(o);
112
+ break;
113
+ case "error":
114
+ R(n);
115
+ break;
116
+ }
60
117
  });
61
- },
62
- { deep: !0, immediate: !0 }
63
- );
64
- D(() => {
65
- m(), i.clear(), a.clear(), _();
118
+ });
119
+ }, $ = () => {
120
+ w !== null && (clearInterval(w), w = null);
121
+ }, q = () => {
122
+ var t;
123
+ return (t = b._s) == null ? void 0 : t.get(nt);
124
+ }, L = (t) => {
125
+ A = t, m = et(() => t.messages, X, { deep: !0, immediate: !0 });
126
+ }, x = q();
127
+ x ? L(x) : w = setInterval(() => {
128
+ const t = q();
129
+ t && ($(), L(t));
130
+ }, lt), tt(() => {
131
+ $(), m == null || m(), A = void 0, E.clear(), f.clear(), _.clear(), u.clear(), s = null, d.clear(), T.clear(), g.clear(), S === M && (S = null, p.$patch((t) => {
132
+ t.bridgeActive = !1, t.applyAcks = {};
133
+ }), J());
66
134
  });
67
135
  };
68
136
  export {
69
- H as useCortexBlueprintBridge
137
+ bt as useCortexBlueprintBridge
70
138
  };
@@ -1,67 +1,81 @@
1
- import S from "../static/assets/icons/line-change.svg.js";
2
- import i from "../static/assets/icons/line-delete.svg.js";
3
- import n from "../static/assets/icons/line-plus.svg.js";
4
- import p from "../static/styles/base.css.js";
5
- import s from "../static/styles/components/alert-message.css.js";
6
- import C from "../static/styles/components/amp-block.css.js";
7
- import a from "../static/styles/components/base-input.css.js";
8
- import f from "../static/styles/components/button-group.css.js";
9
- import c from "../static/styles/components/button.css.js";
10
- import u from "../static/styles/components/combobox.css.js";
11
- import l from "../static/styles/components/counter.css.js";
12
- import d from "../static/styles/components/dropdown-menu.css.js";
13
- import h from "../static/styles/components/loader.css.js";
14
- import g from "../static/styles/components/narrow-panel.css.js";
15
- import I from "../static/styles/components/popup.css.js";
16
- import w from "../static/styles/components/recommendation-strategy.css.js";
17
- import y from "../static/styles/components/switcher.css.js";
18
- import b from "../static/styles/components/tabs.css.js";
19
- import B from "../static/styles/components/tools.css.js";
20
- import $ from "../static/styles/components/version-history.css.js";
21
- import P from "../static/styles/components/wide-panel.css.js";
22
- import x from "../static/styles/variables.css.js";
23
- function r(t, o) {
24
- return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
1
+ import p from "../static/assets/icons/filled-arrow-rising.svg.js";
2
+ import s from "../static/assets/icons/line-change.svg.js";
3
+ import a from "../static/assets/icons/line-delete.svg.js";
4
+ import f from "../static/assets/icons/line-info.svg.js";
5
+ import c from "../static/assets/icons/line-plus.svg.js";
6
+ import l from "../static/styles/base.css.js";
7
+ import C from "../static/styles/components/alert-message.css.js";
8
+ import d from "../static/styles/components/amp-block.css.js";
9
+ import u from "../static/styles/components/base-input.css.js";
10
+ import h from "../static/styles/components/button-group.css.js";
11
+ import I from "../static/styles/components/button.css.js";
12
+ import g from "../static/styles/components/combobox.css.js";
13
+ import w from "../static/styles/components/counter.css.js";
14
+ import y from "../static/styles/components/dropdown-menu.css.js";
15
+ import A from "../static/styles/components/loader.css.js";
16
+ import $ from "../static/styles/components/narrow-panel.css.js";
17
+ import b from "../static/styles/components/popup.css.js";
18
+ import B from "../static/styles/components/recommendation-strategy.css.js";
19
+ import D from "../static/styles/components/skeleton.css.js";
20
+ import R from "../static/styles/components/switcher.css.js";
21
+ import P from "../static/styles/components/tabs.css.js";
22
+ import T from "../static/styles/components/tools.css.js";
23
+ import x from "../static/styles/components/version-history.css.js";
24
+ import M from "../static/styles/components/wide-panel.css.js";
25
+ import O from "../static/styles/variables.css.js";
26
+ function o(i, r) {
27
+ return `--guido-icon-${i}: url("data:image/svg+xml,${encodeURIComponent(r.trim())}");`;
25
28
  }
26
- const A = `:host {
27
- ${r("line-change", S)}
28
- ${r("line-delete", i)}
29
- ${r("line-plus", n)}
30
- }`, R = [
31
- x,
29
+ const V = `:host {
30
+ ${o("line-change", s)}
31
+ ${o("line-delete", a)}
32
+ ${o("filled-arrow-rising", p)}
33
+ ${o("line-info", f)}
34
+ ${o("line-plus", c)}
35
+ }`, W = [
36
+ O,
32
37
  // Must be on top
33
- A,
34
- p,
38
+ V,
39
+ l,
35
40
  // Must be on top
36
- s,
37
41
  C,
38
- a,
39
- f,
40
- c,
41
- u,
42
- l,
43
42
  d,
43
+ u,
44
44
  h,
45
- g,
46
45
  I,
46
+ g,
47
+ w,
47
48
  y,
48
- b,
49
- B,
49
+ A,
50
50
  $,
51
+ b,
52
+ D,
53
+ R,
51
54
  P,
52
- w
55
+ T,
56
+ x,
57
+ M,
58
+ B
53
59
  // Last: overrides button.css / wide-panel.css defaults
54
60
  ].join(`
55
61
 
56
- `), Y = () => ({ importCss: () => {
57
- const o = new CSSStyleSheet();
58
- o.replaceSync(R);
59
- const e = document.querySelector("ui-editor");
60
- if (!e)
61
- return;
62
- const m = e.shadowRoot;
63
- m && (m.adoptedStyleSheets = [o]);
62
+ `), _ = 3e4;
63
+ let e = null;
64
+ function k() {
65
+ return e || (e = new CSSStyleSheet(), e.replaceSync(W)), e;
66
+ }
67
+ const po = () => ({ importCss: () => {
68
+ const r = k(), S = Date.now() + _, n = () => {
69
+ var m;
70
+ const t = (m = document.querySelector("ui-editor")) == null ? void 0 : m.shadowRoot;
71
+ if (t) {
72
+ t.adoptedStyleSheets.includes(r) || (t.adoptedStyleSheets = [...t.adoptedStyleSheets, r]);
73
+ return;
74
+ }
75
+ Date.now() < S && requestAnimationFrame(n);
76
+ };
77
+ n();
64
78
  } });
65
79
  export {
66
- Y as useCustomInterfaceAppearance
80
+ po as useCustomInterfaceAppearance
67
81
  };
@@ -1,59 +1,120 @@
1
- import { useActionsApi as C } from "./useActionsApi.js";
2
- import { useConfig as h } from "./useConfig.js";
3
- import { useToaster as D } from "./useToaster.js";
4
- import { useTranslations as E } from "./useTranslations.js";
5
- import { ToasterTypeOptions as f } from "../enums/toaster.js";
6
- import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
7
- import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
8
- import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
9
- import { ref as O } from "vue";
10
- const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
- const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
12
- const a = y(e);
13
- return a === e ? t : a;
14
- }, v = (e) => {
15
- o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
16
- }, l = (e, t, a) => {
17
- var c;
18
- o.value = { ...o.value, [e]: "applying" };
1
+ import { useActionsApi as x } from "./useActionsApi.js";
2
+ import { useConfig as N } from "./useConfig.js";
3
+ import { useEditorLock as K } from "./useEditorLock.js";
4
+ import { useToaster as R } from "./useToaster.js";
5
+ import { useTranslations as F } from "./useTranslations.js";
6
+ import { ToasterTypeOptions as v } from "../enums/toaster.js";
7
+ import { useDynamicContentStore as G } from "../stores/dynamic-content.js";
8
+ import { useEditorStore as $ } from "../stores/editor.js";
9
+ import { flattenDynamicContentList as j } from "../utils/genericUtil.js";
10
+ import { extractUsedDynamicContent as J } from "../utils/registerUsedDynamicContent.js";
11
+ import { ref as V, watch as W } from "vue";
12
+ const X = 250, U = 12e4, Y = 1e3, p = { status: "superseded" }, M = { status: "failed", error: new Error("Blueprint has no html to apply") }, a = V({}), A = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
13
+ let d = null;
14
+ const T = () => {
15
+ d && (clearInterval(d), d = null);
16
+ }, me = () => {
17
+ const { updateHtmlAndCss: i } = x(), { runExclusive: O } = K(), { showToaster: P } = R(), _ = F(), { template: b } = N(), L = G(), w = $(), g = (e, t) => {
19
18
  try {
20
- r(t, a).catch((n) => {
21
- console.warn("Editor did not acknowledge the template apply.", n);
22
- }), o.value = { ...o.value, [e]: "applied" };
23
- try {
24
- const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
25
- i.length > 0 && d.registerDynamicContent(i);
26
- } catch {
27
- }
28
- u.get(e) !== t && (u.set(e, t), m({
29
- type: f.Success,
30
- message: g("newsletter.ai-template-applied", "Template applied to the editor")
31
- }));
19
+ P({ type: e, message: _(t) });
20
+ } catch (o) {
21
+ console.error("[guido:apply] could not show the apply toast", o);
22
+ }
23
+ }, y = (e, t) => {
24
+ m.get(e) !== t && (m.set(e, t), g(v.Error, "newsletter.ai-template-failed-apply"));
25
+ }, h = () => {
26
+ var e, t;
27
+ return w.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
28
+ }, Q = (e) => {
29
+ a.value[e] === void 0 && (a.value = { ...a.value, [e]: "pending" });
30
+ }, l = (e, t) => {
31
+ a.value = { ...a.value, [e]: t };
32
+ }, H = (e) => {
33
+ var t;
34
+ try {
35
+ const o = j((t = b.value) == null ? void 0 : t.dynamicContentList), r = J(e, o);
36
+ r.length > 0 && L.registerDynamicContent(r);
37
+ } catch {
38
+ }
39
+ }, I = (e, t) => {
40
+ m.delete(e), A.get(e) !== t && (A.set(e, t), g(v.Success, "newsletter.ai-template-applied"));
41
+ }, C = async (e, t, o) => {
42
+ const r = (u.get(e) ?? 0) + 1;
43
+ u.set(e, r), l(e, "applying");
44
+ try {
45
+ await O(() => i(t, o));
32
46
  } catch (n) {
33
- o.value = { ...o.value, [e]: "failed" }, m({
34
- type: f.Error,
35
- message: n instanceof Error ? n.message : "Failed to apply template"
36
- });
47
+ return u.get(e) !== r ? p : (console.error("[guido:apply] editor did not acknowledge the template apply", n), l(e, "failed"), y(e, t), { status: "failed", error: n });
37
48
  }
38
- }, p = (e) => {
39
- const t = s[e];
40
- t && (clearTimeout(t), delete s[e]);
41
- };
42
- return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
43
- t.html && (p(e), l(e, t.html, t.css ?? ""));
44
- }, applyTemplateDebounced: (e, t) => {
45
- if (!t.html)
49
+ return u.get(e) !== r ? p : (l(e, "applied"), H(t), I(e, t), { status: "applied" });
50
+ }, z = (e) => {
51
+ const t = s.get(e);
52
+ t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
53
+ }, D = (e) => {
54
+ const t = c.get(e);
55
+ t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
56
+ }, B = () => {
57
+ [...c.keys()].forEach(D);
58
+ }, f = async () => {
59
+ if (s.size === 0) {
60
+ T();
46
61
  return;
47
- p(e);
48
- const { html: a } = t, c = t.css ?? "";
49
- s[e] = setTimeout(() => {
50
- delete s[e], l(e, a, c);
62
+ }
63
+ if (!h())
64
+ return;
65
+ T();
66
+ const e = [...s.entries()];
67
+ s.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
68
+ const t = e.pop();
69
+ if (e.forEach(([n, E]) => {
70
+ l(n, "failed"), E.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
71
+ }), !t)
72
+ return;
73
+ const [o, r] = t;
74
+ r.settle(await C(o, r.html, r.css));
75
+ }, q = (e, t, o) => new Promise((r) => {
76
+ z(e);
77
+ const n = setTimeout(() => {
78
+ s.delete(e), l(e, "failed"), y(e, t), r({
79
+ status: "failed",
80
+ error: new Error(`Editor did not become ready within ${U}ms`)
81
+ });
51
82
  }, U);
83
+ s.set(e, { html: t, css: o, timer: n, settle: r }), l(e, "applying"), d ?? (d = setInterval(() => {
84
+ f();
85
+ }, Y));
86
+ }), S = (e, t, o) => {
87
+ if (h() && s.size === 0)
88
+ return C(e, t, o);
89
+ const r = q(e, t, o);
90
+ return f(), r;
91
+ };
92
+ return W(() => w.isStripoInitialized, (e) => {
93
+ e && f();
94
+ }, { immediate: !0 }), { applyStatus: a, markPending: Q, applyTemplate: (e, t) => {
95
+ const { html: o } = t;
96
+ return o ? (B(), S(e, o, t.css ?? "")) : Promise.resolve(M);
97
+ }, applyTemplateDebounced: (e, t) => {
98
+ const { html: o } = t;
99
+ if (!o)
100
+ return Promise.resolve(M);
101
+ const r = t.css ?? "";
102
+ return new Promise((n) => {
103
+ D(e);
104
+ const E = setTimeout(() => {
105
+ c.delete(e), S(e, o, r).then(n);
106
+ }, X);
107
+ c.set(e, { timer: E, settle: n });
108
+ });
52
109
  } };
53
- }, G = () => {
54
- Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
110
+ }, de = () => {
111
+ c.forEach((i) => {
112
+ clearTimeout(i.timer), i.settle(p);
113
+ }), c.clear(), s.forEach((i) => {
114
+ clearTimeout(i.timer), i.settle(p);
115
+ }), s.clear(), T(), m.clear(), a.value = {};
55
116
  };
56
117
  export {
57
- G as resetEmailTemplateApplier,
58
- z as useEmailTemplateApplier
118
+ de as resetEmailTemplateApplier,
119
+ me as useEmailTemplateApplier
59
120
  };
@@ -1,13 +1,14 @@
1
- import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
2
- import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
3
- import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
4
- import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
1
+ import { defaultHtmlCompilerRules as d } from "../config/compiler/htmlCompilerRules.js";
2
+ import { itemsCompilerRules as f } from "../config/compiler/itemsCompilerRules.js";
3
+ import { liquidCompilerRules as g } from "../config/compiler/liquidCompilerRules.js";
4
+ import { outlookCompilerRules as R } from "../config/compiler/outlookCompilerRules.js";
5
5
  import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
6
6
  import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
7
- import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
8
- import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
9
- import { useConfig as k } from "./useConfig.js";
10
- const y = /* @__PURE__ */ new Set([
7
+ import { unsubscribeCompilerRules as b } from "../config/compiler/unsubscribeCompilerRules.js";
8
+ import { createHtmlCompiler as n } from "../utils/htmlCompiler.js";
9
+ import { computed as p } from "vue";
10
+ import { useConfig as C } from "./useConfig.js";
11
+ const x = /* @__PURE__ */ new Set([
11
12
  // URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
12
13
  "fix-url-encoding-start",
13
14
  "fix-url-encoding-end",
@@ -30,24 +31,34 @@ const y = /* @__PURE__ */ new Set([
30
31
  // Editor-only attribute strip — AMP4EMAIL has no `contenteditable`, so leaving
31
32
  // it in narrows/breaks rendering. Pure attribute removal, emits nothing.
32
33
  "remove-contenteditable"
33
- ]), M = () => {
34
- var i, m, r;
35
- const { compiler: o, isFeatureEnabled: n, partner: a } = k(), p = ((i = o.value) == null ? void 0 : i.customRules) || [], l = [
36
- ...!!((m = o.value) != null && m.ignoreDefaultRules) ? [] : R,
37
- ...v,
38
- ...x,
39
- ...g,
40
- ...b,
41
- ...H,
42
- ...n("liquidSyntax") ? C : [],
43
- ...p.map((e, f) => ({
44
- ...e,
45
- priority: e.priority + 1e3 + f
46
- // Ensure additional rules run after default rules
47
- }))
48
- ], u = s(l), c = l.filter((e) => y.has(e.id)), d = s(c), t = (r = a.value) == null ? void 0 : r.fallbackFont;
49
- return { compileHtml: (e) => u.compile(e, void 0, t), compileAmpHtml: (e) => d.compile(e, void 0, t) };
34
+ ]), I = () => {
35
+ const { compiler: i, isFeatureEnabled: u, partner: a } = C(), c = p(() => {
36
+ var m, l;
37
+ const e = ((m = i.value) == null ? void 0 : m.customRules) || [];
38
+ return [
39
+ ...!!((l = i.value) != null && l.ignoreDefaultRules) ? [] : d,
40
+ ...v,
41
+ ...b,
42
+ ...f,
43
+ ...R,
44
+ ...H,
45
+ ...u("liquidSyntax") ? g : [],
46
+ ...e.map((t, o) => ({
47
+ ...t,
48
+ priority: t.priority + 1e3 + o
49
+ // Ensure additional rules run after default rules
50
+ }))
51
+ ];
52
+ }), r = p(() => {
53
+ var t;
54
+ const e = c.value, s = n(e), m = n(e.filter((o) => x.has(o.id))), l = (t = a.value) == null ? void 0 : t.fallbackFont;
55
+ return {
56
+ compileHtml: (o) => s.compile(o, void 0, l),
57
+ compileAmpHtml: (o) => m.compile(o, void 0, l)
58
+ };
59
+ });
60
+ return { compileHtml: (e) => r.value.compileHtml(e), compileAmpHtml: (e) => r.value.compileAmpHtml(e) };
50
61
  };
51
62
  export {
52
- M as useHtmlCompiler
63
+ I as useHtmlCompiler
53
64
  };