@useinsider/guido 3.3.0-beta.0a507dd → 3.3.0-beta.1778fd7

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 (38) hide show
  1. package/dist/components/Guido.vue.js +1 -1
  2. package/dist/components/Guido.vue2.js +103 -89
  3. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +9 -11
  4. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +70 -35
  5. package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
  6. package/dist/composables/useCortexBlueprintBridge.js +66 -0
  7. package/dist/composables/useEmailTemplateApplier.js +41 -0
  8. package/dist/composables/useGuidoStateBridge.js +48 -0
  9. package/dist/composables/useHtmlValidator.js +41 -36
  10. package/dist/composables/useRecommendation.js +2 -2
  11. package/dist/composables/useStripo.js +66 -62
  12. package/dist/config/migrator/index.js +21 -10
  13. package/dist/config/migrator/radioButtonMigrator.js +72 -47
  14. package/dist/enums/extensions/recommendationBlock.js +101 -46
  15. package/dist/enums/unsubscribe.js +25 -24
  16. package/dist/extensions/Blocks/Checkbox/control.js +23 -23
  17. package/dist/extensions/Blocks/RadioButton/control.js +15 -15
  18. package/dist/extensions/Blocks/RadioButton/template.js +6 -6
  19. package/dist/extensions/Blocks/Recommendation/block.js +43 -36
  20. package/dist/extensions/Blocks/Recommendation/services/configService.js +33 -26
  21. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +35 -26
  22. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +25 -12
  23. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
  24. package/dist/guido.css +1 -1
  25. package/dist/src/composables/useCortexBlueprintBridge.d.ts +25 -0
  26. package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
  27. package/dist/src/composables/useGuidoStateBridge.d.ts +22 -0
  28. package/dist/src/enums/extensions/recommendationBlock.d.ts +6 -1
  29. package/dist/src/enums/unsubscribe.d.ts +8 -3
  30. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  31. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +11 -3
  32. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -1
  33. package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +2 -0
  34. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
  35. package/dist/src/stores/guido-email-editor.d.ts +41 -0
  36. package/dist/stores/guido-email-editor.js +20 -0
  37. package/dist/utils/templatePreparation.js +57 -50
  38. package/package.json +1 -1
@@ -1,35 +1,37 @@
1
- import { useConfig as L } from "./useConfig.js";
2
- import { TemplateTypes as V } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as _, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
1
+ import { useConfig as _ } from "./useConfig.js";
2
+ import { TemplateTypes as H } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as M } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationStore as $ } from "../stores/recommendation.js";
7
- import { base64EncodeWithSpecialChars as X } from "../utils/base64.js";
8
- import { useHttp as j } from "./useHttp.js";
9
- import { useToaster as q } from "./useToaster.js";
10
- import { useTranslations as z } from "./useTranslations.js";
11
- const K = /recommendation-id="(\d+)"/g;
12
- function U(a) {
13
- return [...a.matchAll(K)].map((u) => u[1]);
5
+ import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
+ import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
+ import { useRecommendationStore as K } from "../stores/recommendation.js";
9
+ import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
10
+ import { useHttp as U } from "./useHttp.js";
11
+ import { useToaster as Y } from "./useToaster.js";
12
+ import { useTranslations as Z } from "./useTranslations.js";
13
+ const J = /recommendation-id="(\d+)"/g;
14
+ function Q(a) {
15
+ return [...a.matchAll(J)].map((u) => u[1]);
14
16
  }
15
- function Y(a, u) {
17
+ function ee(a, u) {
16
18
  return u.some((d) => a.startsWith(`${d}_`));
17
19
  }
18
- const ce = () => {
20
+ const ge = () => {
19
21
  var y, h;
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) => {
22
+ const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
21
23
  const t = await u(
22
24
  "/newsletter/template-library/check-template-html-body",
23
- { html: X(e) }
25
+ { html: z(e) }
24
26
  ), { status: n, message: l } = t.data;
25
27
  return n || a({
26
28
  type: c.Alert,
27
29
  message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
28
- }), r(P), l === r(G) && a({
30
+ }), r(M), l === r($) && a({
29
31
  type: c.Alert,
30
32
  message: r("newsletter.already-in-progress")
31
33
  }), n;
32
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
34
+ }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
33
35
  const t = e.match(/({%(.*?)%})/g);
34
36
  let n = !0;
35
37
  return t !== null && !p && t.forEach((l) => {
@@ -42,13 +44,13 @@ const ce = () => {
42
44
  }), n = !1);
43
45
  }
44
46
  }), n;
45
- }, A = async (e, s, t) => {
47
+ }, k = async (e, s, t) => {
46
48
  const n = t ? await b(e) : !0;
47
- return E(e, s) && n;
48
- }, I = (e) => e.length > 0 ? !0 : (a({
49
+ return A(e, s) && n;
50
+ }, x = (e) => e.length > 0 ? !0 : (a({
49
51
  type: c.Warning,
50
52
  message: r("newsletter.html-content-is-empty")
51
- }), !1), k = (e) => {
53
+ }), !1), I = (e) => {
52
54
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
53
55
  return s > t && a({
54
56
  type: c.Warning,
@@ -57,7 +59,7 @@ const ce = () => {
57
59
  type: c.Warning,
58
60
  message: r("custom-fields.missing-opening-braces")
59
61
  }), s === t;
60
- }, x = (e) => {
62
+ }, F = (e) => {
61
63
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
62
64
  return s || a({
63
65
  type: c.Warning,
@@ -66,10 +68,10 @@ const ce = () => {
66
68
  }, T = (e, s) => {
67
69
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
68
70
  if (t && !p) {
69
- const n = new Set(s.map((i) => i.toLowerCase())), l = U(e), o = [];
71
+ const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
70
72
  if (t.forEach((i) => {
71
73
  const m = i.slice(2, -2).trim().toLowerCase();
72
- (!n.has(m) || m === "") && !Y(m, l) && o.push(m);
74
+ (!n.has(m) || m === "") && !ee(m, l) && o.push(m);
73
75
  }), o.length > 0) {
74
76
  const i = `
75
77
  <ul>
@@ -83,11 +85,11 @@ const ce = () => {
83
85
  }
84
86
  }
85
87
  return !0;
86
- }, F = (e) => {
88
+ }, R = (e) => {
87
89
  const s = e.match(/{%(.*?)%}/g), t = [];
88
90
  let n = !0;
89
91
  if (s && s.forEach((l) => {
90
- const o = l.match(_), i = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
92
+ const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
91
93
  (!o || l !== m) && !i && (a({
92
94
  type: c.Alert,
93
95
  message: r("newsletter.display-conditions-invalid-syntax")
@@ -98,7 +100,7 @@ const ce = () => {
98
100
  }), n = !1);
99
101
  const v = f.match(/^[a-zA-Z]*$/g);
100
102
  v && v.forEach((C) => {
101
- S(C) && t.push(C);
103
+ E(C) && t.push(C);
102
104
  });
103
105
  });
104
106
  }), t.length) {
@@ -109,25 +111,28 @@ const ce = () => {
109
111
  }), n = !1);
110
112
  }
111
113
  return n;
112
- }, W = (e) => {
114
+ }, B = (e) => {
113
115
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
114
116
  return n || a({
115
117
  type: c.Warning,
116
118
  message: r("custom-conditions.no-space-after-braces")
117
119
  }), 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 ? (a({
120
+ }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
119
121
  type: c.Warning,
120
122
  message: r("custom-conditions.no-braces-inside-if-tag")
123
+ }), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
124
+ type: c.Alert,
125
+ message: r(j)
121
126
  }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
122
127
  type: c.Alert,
123
128
  message: r("newsletter.fill-all-necessary-fields")
124
- }), !1) : !0, B = (e) => {
129
+ }), !1) : !0, D = (e) => {
125
130
  const s = /src="[^"]*\.(svg|pst)"/gm;
126
131
  return e.match(s) === null ? !0 : (a({
127
132
  type: c.Alert,
128
133
  message: r("newsletter.invalid-image-type")
129
134
  }), !1);
130
- }, R = (e) => {
135
+ }, L = (e) => {
131
136
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
132
137
  return Array.from(n).find((o) => {
133
138
  var i;
@@ -136,7 +141,7 @@ const ce = () => {
136
141
  type: c.Alert,
137
142
  message: r("unsubscribe-templates.select-checkbox-groups")
138
143
  }), !1) : !0;
139
- }, D = (e) => {
144
+ }, V = (e) => {
140
145
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
141
146
  return Array.from(n).find((o) => {
142
147
  var i;
@@ -150,12 +155,12 @@ const ce = () => {
150
155
  var o, i;
151
156
  const n = [
152
157
  ...s.map((m) => m.value),
153
- ...M,
158
+ ...q,
154
159
  ...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
155
160
  ];
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);
161
+ return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
157
162
  } };
158
163
  };
159
164
  export {
160
- ce as useHtmlValidator
165
+ ge as useHtmlValidator
161
166
  };
@@ -1,4 +1,4 @@
1
- import { RecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
1
+ import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
2
2
  import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
@@ -63,7 +63,7 @@ const w = () => ({
63
63
  shuffleProducts: o.shuffleProducts
64
64
  };
65
65
  }
66
- const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
66
+ const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
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
68
  const i = parseInt(e.size) || 6;
69
69
  t.set("productId", e.productIds.slice(0, i).join(","));
@@ -1,126 +1,130 @@
1
- import { useActionsApi as D } from "./useActionsApi.js";
2
- import { useBlocksConfig as I } from "./useBlocksConfig.js";
3
- import { useConfig as P } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as U } from "./useCustomInterfaceAppearance.js";
5
- import { useFullStoryBridge as R } from "./useFullStoryBridge.js";
6
- import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
7
- import { useToaster as x } from "./useToaster.js";
8
- import { localePatch as H } from "../config/i18n/index.js";
9
- import { useStripoApi as O } from "../services/stripoApi.js";
10
- import j from "../static/styles/customEditorStyle.css.js";
11
- import { useEditorStore as E } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as L } from "../utils/genericUtil.js";
13
- import $ from "../package.json.js";
14
- const se = (C, l) => {
15
- const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = O(), { handleEvent: B } = q(), { getStripoBlocksConfig: T } = I(), V = async (i, r = [], s = !1) => {
16
- var g, S, y;
17
- const e = E(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, F = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, v = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1;
18
- window.UIEditor.initEditor(
1
+ import { useActionsApi as P } from "./useActionsApi.js";
2
+ import { useBlocksConfig as U } from "./useBlocksConfig.js";
3
+ import { useConfig as R } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as q } from "./useCustomInterfaceAppearance.js";
5
+ import { useFullStoryBridge as x } from "./useFullStoryBridge.js";
6
+ import { useStripoEventHandler as H } from "./useStripoEventHandler.js";
7
+ import { useToaster as O } from "./useToaster.js";
8
+ import { localePatch as j } from "../config/i18n/index.js";
9
+ import { useStripoApi as L } from "../services/stripoApi.js";
10
+ import $ from "../static/styles/customEditorStyle.css.js";
11
+ import { useEditorStore as b } from "../stores/editor.js";
12
+ import { dynamicContentToMergeTags as z } from "../utils/genericUtil.js";
13
+ import G from "../package.json.js";
14
+ const nt = (w, m) => {
15
+ const { features: p, template: k, isFeatureEnabled: g } = R(), { handleError: f } = O(), { getToken: B, getCustomFonts: T, getSyncModulesStatus: V } = L(), { handleEvent: _ } = H(), { getStripoBlocksConfig: v } = U(), F = async (i, s = [], n = !1) => {
16
+ var E, h, C;
17
+ const t = b(), { html: u, css: a } = i, { baseBlocks: o, extensions: d } = await v(), S = ((E = p.value) == null ? void 0 : E.displayConditions) ?? !0, A = ((h = p.value) == null ? void 0 : h.modulesDisabled) ?? !1, y = ((C = k.value) == null ? void 0 : C.forceRecreate) ?? !1, D = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com", I = (u.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((e) => {
18
+ var l;
19
+ const c = (((l = e.match(/class="([^"]*)"/)) == null ? void 0 : l[1]) ?? "").split(/\s+/).filter(Boolean);
20
+ return { hasBlock: c.includes("radio-button-block"), classes: c };
21
+ });
22
+ console.debug("[guido:radio-migrator] stripo:before-init", { forceRecreate: y, radioTds: I }), window.UIEditor.initEditor(
19
23
  document.querySelector("#guido-editor"),
20
24
  {
21
- metadata: C,
22
- html: p,
25
+ metadata: w,
26
+ html: u,
23
27
  css: a,
24
- forceRecreate: v,
28
+ forceRecreate: y,
25
29
  locale: "en",
26
30
  undoButtonSelector: "#guido__undo-button",
27
31
  redoButtonSelector: "#guido__redo-button",
28
32
  mobileViewButtonSelector: ".guido__view-option-selection-mobile",
29
33
  desktopViewButtonSelector: ".guido__view-option-selection-desktop",
30
34
  codeEditorButtonSelector: "#guido__code-button",
31
- customAppearanceMergetags: !u("liquidSyntax"),
35
+ customAppearanceMergetags: !g("liquidSyntax"),
32
36
  customAppearanceMergetagsBorderColor: "#f1f3fe",
33
37
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
34
- customViewStyles: j,
35
- conditionsEnabled: f,
36
- customConditionsEnabled: f,
38
+ customViewStyles: $,
39
+ conditionsEnabled: S,
40
+ customConditionsEnabled: S,
37
41
  enableXSSSecurity: !0,
38
- modulesDisabled: F,
39
- syncModulesEnabled: s,
42
+ modulesDisabled: A,
43
+ syncModulesEnabled: n,
40
44
  messageSettingsEnabled: !0,
41
45
  displayGmailAnnotations: !0,
42
46
  displayHiddenPreheader: !1,
43
47
  displayTitle: !1,
44
48
  displayUTM: !1,
45
49
  selectElementAfterDrop: !0,
46
- allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
50
+ allowedScriptSourceDomains: D,
47
51
  ...o ? { baseBlocks: o } : {},
48
52
  editorFonts: {
49
53
  showDefaultStandardFonts: !0,
50
54
  showDefaultNotStandardFonts: !0,
51
- customFonts: r
55
+ customFonts: s
52
56
  },
53
57
  mergeTags: [
54
58
  {
55
- entries: L(
56
- l.preselectedDynamicContentList,
57
- u("liquidSyntax")
59
+ entries: z(
60
+ m.preselectedDynamicContentList,
61
+ g("liquidSyntax")
58
62
  )
59
63
  }
60
64
  ],
61
- async onTokenRefreshRequest(t) {
65
+ async onTokenRefreshRequest(e) {
62
66
  try {
63
- const n = await w();
64
- t(n);
65
- } catch (n) {
66
- m(n, "Failed to refresh token");
67
+ const r = await B();
68
+ e(r);
69
+ } catch (r) {
70
+ f(r, "Failed to refresh token");
67
71
  }
68
72
  },
69
73
  onTemplateLoaded() {
70
74
  try {
71
- const { importCss: t } = U(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: M } = D(), { injectFullStory: A } = R();
72
- t(), n(), A(), M(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
73
- e.hasChanges = !1;
75
+ const { importCss: e } = q(), { activateCustomViewStyles: r, updateTimerInClonedTemplate: c } = P(), { injectFullStory: l } = x();
76
+ e(), r(), l(), c(), m.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
77
+ t.hasChanges = !1;
74
78
  }, 1e3);
75
- } catch (t) {
76
- m(t, "Failed to load custom interface appearance");
79
+ } catch (e) {
80
+ f(e, "Failed to load custom interface appearance");
77
81
  }
78
82
  },
79
- onCodeEditorVisibilityChanged(t) {
80
- e.isCodeEditorOpen = t;
83
+ onCodeEditorVisibilityChanged(e) {
84
+ t.isCodeEditorOpen = e;
81
85
  },
82
- onEditorVisualModeChanged(t) {
83
- e.editorVisualMode = t.toLowerCase();
86
+ onEditorVisualModeChanged(e) {
87
+ t.editorVisualMode = e.toLowerCase();
84
88
  },
85
- onVersionHistoryVisibilityChanged(t) {
86
- e.isVersionHistoryOpen = t;
89
+ onVersionHistoryVisibilityChanged(e) {
90
+ t.isVersionHistoryOpen = e;
87
91
  },
88
92
  onDataChanged() {
89
- e.hasChanges = !0;
93
+ t.hasChanges = !0;
90
94
  },
91
- onEvent: B,
95
+ onEvent: _,
92
96
  ignoreClickOutsideSelectors: [
93
97
  "#guido-dynamic-content-modal",
94
98
  ".in-on-board-wrapper",
95
99
  ".in-drawer__container"
96
100
  ],
97
101
  extensions: d,
98
- localePatch: H
102
+ localePatch: j
99
103
  }
100
104
  );
101
- }, _ = (i) => new Promise((r, s) => {
105
+ }, M = (i) => new Promise((s, n) => {
102
106
  var d;
103
107
  if (document.getElementById("UiEditorScript")) {
104
- i(), r();
108
+ i(), s();
105
109
  return;
106
110
  }
107
- const e = $.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
111
+ const t = G.guido, a = `https://email-static.useinsider.com/guido/${(d = t == null ? void 0 : t.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
108
112
  o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
109
- i(), r();
113
+ i(), s();
110
114
  }, o.onerror = () => {
111
- s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
115
+ n(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
112
116
  }, document.body.appendChild(o);
113
117
  });
114
118
  return { initPlugin: async (i) => {
115
- await _(async () => {
116
- const r = E(), [s, e] = await Promise.all([
117
- b(),
118
- k()
119
+ await M(async () => {
120
+ const s = b(), [n, t] = await Promise.all([
121
+ T(),
122
+ V()
119
123
  ]);
120
- r.syncModulesEnabled = e, await V(i, s, e);
124
+ s.syncModulesEnabled = t, await F(i, n, t);
121
125
  });
122
126
  } };
123
127
  };
124
128
  export {
125
- se as useStripo
129
+ nt as useStripo
126
130
  };
@@ -1,13 +1,24 @@
1
- import { migrateCheckbox as o } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
3
- import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
4
- import { migrateRadioButton as a } from "./radioButtonMigrator.js";
5
- import { migrateRecommendation as g } from "./recommendationMigrator.js";
6
- import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
7
- const b = async (r, t = {}) => {
8
- let m = r;
9
- return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
1
+ import { migrateCheckbox as m } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as n } from "./couponBlockMigrator.js";
3
+ import { migrateItemsBlock as s } from "./itemsBlockMigrator.js";
4
+ import { migrateRadioButton as c } from "./radioButtonMigrator.js";
5
+ import { migrateRecommendation as d } from "./recommendationMigrator.js";
6
+ import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
7
+ const a = (t) => (t.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((i) => {
8
+ var e;
9
+ const r = (((e = i.match(/class="([^"]*)"/)) == null ? void 0 : e[1]) ?? "").split(/\s+/).filter(Boolean);
10
+ return { hasBlock: r.includes("radio-button-block"), classes: r };
11
+ }), k = async (t, i = {}) => {
12
+ console.debug("[guido:radio-migrator] pipeline:start", {
13
+ inputLength: t.length,
14
+ radioTds: a(t)
15
+ });
16
+ let o = t;
17
+ return o = m(o), o = c(o), o = await g(o), o = n(o), o = d(o, i), o = s(o), console.debug("[guido:radio-migrator] pipeline:end", {
18
+ outputLength: o.length,
19
+ radioTds: a(o)
20
+ }), o;
10
21
  };
11
22
  export {
12
- b as migrate
23
+ k as migrate
13
24
  };
@@ -1,52 +1,77 @@
1
- var x = Object.defineProperty;
2
- var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
- import S from "../../extensions/Blocks/RadioButton/template.js";
5
- class B {
1
+ var k = Object.defineProperty;
2
+ var v = (a, e, t) => e in a ? k(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var f = (a, e, t) => v(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import A from "../../extensions/Blocks/RadioButton/template.js";
5
+ class C {
6
6
  constructor() {
7
- b(this, "parser");
7
+ f(this, "parser");
8
8
  this.parser = new DOMParser();
9
9
  }
10
10
  migrate(e) {
11
11
  try {
12
- const t = this.parser.parseFromString(e, "text/html"), i = t.querySelectorAll("td.radio-button-block"), s = t.querySelectorAll("td.radio-button-v2");
13
- if (i.length === 0 && s.length === 0)
14
- return e;
15
- let o = !1;
16
- return i.forEach((r) => {
12
+ const t = this.parser.parseFromString(e, "text/html"), o = t.querySelectorAll("td.radio-button-block"), s = t.querySelectorAll("td.radio-button-v2");
13
+ if (o.length === 0 && s.length === 0)
14
+ return console.debug("[guido:radio-migrator] skip", { reason: "no radio blocks" }), e;
15
+ console.debug("[guido:radio-migrator] entry", {
16
+ v1BlockCount: o.length,
17
+ v2BlockCount: s.length,
18
+ inputLength: e.length
19
+ });
20
+ let n = !1, i = 0;
21
+ o.forEach((r) => {
17
22
  if (r.classList.contains("radio-button-v2"))
18
23
  return;
19
- const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), d = this.buildTextBlock(a), p = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", p).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
20
- `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
24
+ const d = r.getAttribute("id"), g = this.extractTextFromElement(r, "ins-title"), p = this.extractTextFromElement(r, "ins-description"), m = this.extractTextFromElement(r, "ins-subscribe"), b = this.extractTextFromElement(r, "ins-unsubscribe"), y = this.buildTextBlock(g), x = this.buildTextBlock(p), T = this.buildTextBlock({ ...m, classList: "" }), B = this.buildTextBlock({ ...b, classList: "" }), S = A.replace("{-{-TITLE-}-}", y).replace("{-{-DESCRIPTION-}-}", x).replace("{-{-YES-}-}", T).replace("{-{-NO-}-}", B), h = this.parser.parseFromString(
25
+ `<table id="tempDoc"><tbody><tr>${S}</tr></tbody></table>`,
21
26
  "text/html"
22
27
  ).querySelector(".radio-button-v2");
23
- m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
- }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
28
+ h && r.parentNode && (h.setAttribute("id", d || ""), r.parentNode.replaceChild(h, r), n = !0, i++);
29
+ });
30
+ const l = this.healRadioButtonV2(t);
31
+ n = l || n;
32
+ const c = n ? t.documentElement.outerHTML : e, u = (c.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((r) => {
33
+ var g;
34
+ return (((g = r.match(/class="([^"]*)"/)) == null ? void 0 : g[1]) ?? "").split(/\s+/).filter(Boolean).includes("radio-button-block");
35
+ });
36
+ return console.debug("[guido:radio-migrator] exit", {
37
+ v1Converted: i,
38
+ healingMutated: l,
39
+ mutated: n,
40
+ finalV2HasBlock: u,
41
+ outputLength: c.length
42
+ }), c;
25
43
  } catch (t) {
26
- return console.error("RadioButtonMigrator failed:", t), e;
44
+ return console.error("[guido:radio-migrator] failed:", t), e;
27
45
  }
28
46
  }
29
47
  healRadioButtonV2(e) {
30
- let t = !1;
31
- return e.querySelectorAll("td.radio-button-v2").forEach((i) => {
32
- var p;
33
- const s = i.querySelector("input#radioYes"), o = i.querySelector("input#radioNo");
34
- if (!s || !o)
48
+ let t = !1, o = 0, s = 0;
49
+ const n = e.querySelectorAll("td.radio-button-v2");
50
+ return n.forEach((i) => {
51
+ var y;
52
+ i.classList.contains("radio-button-block") || (i.classList.add("radio-button-block"), o++, t = !0);
53
+ const l = i.querySelector("input#radioYes"), c = i.querySelector("input#radioNo");
54
+ if (!l || !c)
35
55
  return;
36
- const r = ((p = s.parentElement) == null ? void 0 : p.querySelector(":scope > p")) || null;
37
- if (!r && !s.hasAttribute("align"))
56
+ const u = ((y = l.parentElement) == null ? void 0 : y.querySelector(":scope > p")) || null;
57
+ if (!u && !l.hasAttribute("align"))
38
58
  return;
39
- const n = s.closest("tr"), a = o.closest("tr");
40
- if (!n || !a || n === a || !n.parentNode)
59
+ const r = l.closest("tr"), d = c.closest("tr");
60
+ if (!r || !d || r === d || !r.parentNode)
41
61
  return;
42
- const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), d = c.querySelector("p");
43
- u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), d && (d.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
62
+ const g = (u == null ? void 0 : u.innerHTML.trim()) || "Yes", p = d.cloneNode(!0), m = p.querySelector("input#radioNo"), b = p.querySelector("p");
63
+ m && (m.setAttribute("id", "radioYes"), m.removeAttribute("align")), b && (b.innerHTML = g), r.parentNode.replaceChild(p, r), s++, t = !0;
64
+ }), console.debug("[guido:radio-migrator] healing", {
65
+ v2BlockCount: n.length,
66
+ classAddedCount: o,
67
+ rowHealedCount: s,
68
+ mutated: t
44
69
  }), t;
45
70
  }
46
71
  extractTextFromElement(e, t) {
47
- var p, y;
48
- const i = e.querySelector(`.${t}`);
49
- if (!i)
72
+ var p, m;
73
+ const o = e.querySelector(`.${t}`);
74
+ if (!o)
50
75
  return {
51
76
  text: t === "ins-title" ? "Title" : "Description",
52
77
  isBold: !1,
@@ -55,32 +80,32 @@ class B {
55
80
  styles: "",
56
81
  classList: ""
57
82
  };
58
- const s = i.querySelector("p");
83
+ const s = o.querySelector("p");
59
84
  if (!s)
60
85
  return {
61
- text: ((p = i.textContent) == null ? void 0 : p.trim()) || (t === "ins-title" ? "Title" : "Description"),
86
+ text: ((p = o.textContent) == null ? void 0 : p.trim()) || (t === "ins-title" ? "Title" : "Description"),
62
87
  isBold: !1,
63
88
  isItalic: !1,
64
- align: i.getAttribute("align") || "left",
89
+ align: o.getAttribute("align") || "left",
65
90
  styles: "",
66
91
  classList: ""
67
92
  };
68
- const o = ((y = s.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = s.getAttribute("style") || "", n = i.getAttribute("align") || s.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!s.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!s.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), d = i.getAttribute("class") || "";
93
+ const n = ((m = s.textContent) == null ? void 0 : m.trim()) || (t === "ins-title" ? "Title" : "Description"), i = s.getAttribute("style") || "", l = o.getAttribute("align") || s.getAttribute("align") || "left", c = /font-weight\s*:\s*bold/i.test(i) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(i) || !!s.querySelector("i, em"), r = this.removeStyleProperties(i, ["font-weight", "font-style"]), d = this.convertInlineToBlock(r), g = o.getAttribute("class") || "";
69
94
  return {
70
- text: o,
71
- isBold: a,
72
- isItalic: g,
73
- align: n,
74
- styles: u,
75
- classList: d
95
+ text: n,
96
+ isBold: c,
97
+ isItalic: u,
98
+ align: l,
99
+ styles: d,
100
+ classList: g
76
101
  };
77
102
  }
78
103
  buildTextBlock(e) {
79
104
  let t = e.text;
80
105
  e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
81
- const i = e.align ? ` align="${e.align}"` : "", s = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
106
+ const o = e.align ? ` align="${e.align}"` : "", s = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
82
107
  return `
83
- <td class="esd-block-text ${e.classList}" ${i}>
108
+ <td class="esd-block-text ${e.classList}" ${o}>
84
109
  <p path="1" ${s}>
85
110
  ${t}
86
111
  </p>
@@ -88,9 +113,9 @@ class B {
88
113
  `;
89
114
  }
90
115
  removeStyleProperties(e, t) {
91
- return e ? t.reduce((s, o) => {
92
- const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
93
- return s.replace(r, "");
116
+ return e ? t.reduce((s, n) => {
117
+ const i = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
118
+ return s.replace(i, "");
94
119
  }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
95
120
  }
96
121
  convertInlineToBlock(e) {
@@ -100,8 +125,8 @@ class B {
100
125
  return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
101
126
  }
102
127
  }
103
- function q(l) {
104
- return new B().migrate(l);
128
+ function q(a) {
129
+ return new C().migrate(a);
105
130
  }
106
131
  export {
107
132
  q as migrateRadioButton