@useinsider/guido 3.1.1-beta.f3b45b9 → 3.1.1-beta.f9482a3

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 (43) hide show
  1. package/dist/@types/config/schemas.js +61 -69
  2. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  3. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +20 -12
  4. package/dist/composables/useHtmlCompiler.js +20 -20
  5. package/dist/composables/usePreviewMode.js +16 -20
  6. package/dist/composables/useSave.js +13 -15
  7. package/dist/config/compiler/recommendationCompilerRules.js +152 -44
  8. package/dist/config/compiler/utils/recommendationCompilerUtils.js +59 -58
  9. package/dist/config/migrator/checkboxMigrator.js +3 -5
  10. package/dist/config/migrator/radioButtonMigrator.js +12 -14
  11. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  12. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -27
  13. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +172 -185
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +93 -95
  15. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +73 -75
  16. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +5 -7
  17. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +29 -30
  18. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  19. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +1 -3
  20. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
  21. package/dist/extensions/Blocks/Recommendation/templates/utils.js +50 -57
  22. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  23. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +17 -16
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +218 -324
  26. package/dist/package.json.js +1 -1
  27. package/dist/src/@types/config/index.d.ts +1 -1
  28. package/dist/src/@types/config/schemas.d.ts +0 -20
  29. package/dist/src/@types/config/types.d.ts +1 -3
  30. package/dist/src/composables/useConfig.d.ts +0 -8
  31. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  32. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -5
  33. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -5
  34. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  35. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  36. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +3 -20
  37. package/dist/src/stores/config.d.ts +0 -72
  38. package/dist/src/stores/preview.d.ts +0 -3
  39. package/dist/src/utils/htmlCompiler.d.ts +1 -2
  40. package/dist/stores/preview.js +3 -4
  41. package/dist/utils/htmlCompiler.js +41 -48
  42. package/dist/utils/templatePreparation.js +20 -20
  43. package/package.json +3 -3
@@ -1,18 +1,18 @@
1
- import { useRecommendation as f } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as P, REGEX as m, VerticalOrientation as g, CSS as e, ATTRIBUTES as a, CONDITIONS as A, HTML as h } from "../../enums/recommendation.js";
3
- import { prepareRecommendationBlocks as D } from "./utils/recommendationCompilerUtils.js";
4
- const G = [
1
+ import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as M, REGEX as _, VerticalOrientation as h, CSS as d, ATTRIBUTES as R, CONDITIONS as y, HTML as C } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
4
+ const w = [
5
5
  {
6
6
  id: "replace-images-with-variable-names",
7
7
  description: "Replacing dummy images with variable names in recommendation module",
8
8
  type: "custom",
9
- processor: (s) => {
10
- let t = s;
11
- return Object.entries(P).forEach(([, l]) => {
12
- Object.entries(l).forEach(([n, o]) => {
13
- t = t.replaceAll(o, `{{${n}}}`);
9
+ processor: (n) => {
10
+ let e = n;
11
+ return Object.entries(M).forEach(([, l]) => {
12
+ Object.entries(l).forEach(([s, r]) => {
13
+ e = e.replaceAll(r, `{{${s}}}`);
14
14
  });
15
- }), t;
15
+ }), e;
16
16
  },
17
17
  priority: 50
18
18
  },
@@ -29,21 +29,21 @@ const G = [
29
29
  id: "add-recommendation-unresponsive-css",
30
30
  description: "Adding recommendation unresponsive css",
31
31
  type: "custom",
32
- processor: (s) => {
33
- const { calculateCardWidth: t, getRecommendationCampaignData: l } = f();
34
- let n = s;
35
- const o = n.match(m.ID);
36
- if (o) {
37
- const d = [];
38
- if (o.forEach((c) => {
39
- const E = /recommendation-id="(.*?)"/i.exec(c), I = E ? E[1].trim() : "", p = l(I);
40
- p.textTrimming && p.orientation === g && d.push(t(p));
41
- }), d.length) {
42
- const c = `width:${Math.min(...d)}px!important;`;
43
- n = n.replace(e.REGULAR_NAME_HEIGHT, `${e.TRIMMED_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.REGULAR_NAME_CONTAINER_HEIGHT, e.TRIMMED_NAME_CONTAINER_CSS).replace(e.RESPONSIVE_NAME_SIZE, `${e.RESPONSIVE_NAME_HEIGHT} ${c} ${e.ELLIPSIS}`).replace(e.RESPONSIVE_NAME_CONTAINER_HEIGHT, e.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
32
+ processor: (n) => {
33
+ const { calculateCardWidth: e, getRecommendationCampaignData: l } = N();
34
+ let s = n;
35
+ const r = s.match(_.ID);
36
+ if (r) {
37
+ const i = [];
38
+ if (r.forEach((p) => {
39
+ const u = /recommendation-id="(.*?)"/i.exec(p), I = u ? u[1].trim() : "", E = l(I);
40
+ E.textTrimming && E.orientation === h && i.push(e(E));
41
+ }), i.length) {
42
+ const p = `width:${Math.min(...i)}px!important;`;
43
+ s = s.replace(d.REGULAR_NAME_HEIGHT, `${d.TRIMMED_NAME_HEIGHT} ${p} ${d.ELLIPSIS}`).replace(d.REGULAR_NAME_CONTAINER_HEIGHT, d.TRIMMED_NAME_CONTAINER_CSS).replace(d.RESPONSIVE_NAME_SIZE, `${d.RESPONSIVE_NAME_HEIGHT} ${p} ${d.ELLIPSIS}`).replace(d.RESPONSIVE_NAME_CONTAINER_HEIGHT, d.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
44
44
  }
45
45
  }
46
- return n;
46
+ return s;
47
47
  },
48
48
  priority: 52
49
49
  },
@@ -51,39 +51,147 @@ const G = [
51
51
  id: "prepare-recommendations",
52
52
  description: "Replacing product data with template variables in recommendation blocks",
53
53
  type: "custom",
54
- processor: (s) => D(s),
54
+ processor: (n) => x(n),
55
55
  priority: 48
56
56
  },
57
57
  {
58
58
  id: "add-discount-conditions",
59
59
  description: "Adding discount conditions to the recommendation block",
60
60
  type: "custom",
61
- processor: (s) => {
62
- let t = s;
63
- const l = t.match(m.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = f();
64
- return l !== null && l.forEach((o) => {
65
- const d = o.match(m.CUSTOM_FIELD);
66
- if (!d)
61
+ processor: (n) => {
62
+ let e = n;
63
+ const l = e.match(_.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: s } = N();
64
+ return l !== null && l.forEach((r) => {
65
+ const i = r.match(_.CUSTOM_FIELD);
66
+ if (!i)
67
67
  return;
68
- const [c] = d, E = c.match(m.CUSTOM_FIELD_INDEXES_PART), I = c.match(m.CUSTOM_FIELD_NAME_PART), p = o.match(m.ATTRIBUTE_PARAGRAPH_START_TAG);
69
- if (!E || !I || !p)
68
+ const [p] = i, u = p.match(_.CUSTOM_FIELD_INDEXES_PART), I = p.match(_.CUSTOM_FIELD_NAME_PART), E = r.match(_.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!u || !I || !E)
70
70
  return;
71
- const [u] = E, [R] = I, [_] = p, T = R.substring(1, R.length - 2), S = _.match(m.COMPOSITION) !== null;
72
- let i = c;
73
- if (S) {
74
- const $ = u.substring(2, u.length - 3), r = n($);
75
- T === a.OMNIBUS_PRICE && (r.priceBeforeTextValue && (i = `${r.priceBeforeTextValue}${i}`), r.priceAfterTextValue && (i = `${i}${r.priceAfterTextValue}`)), T === a.OMNIBUS_DISCOUNT && (r.discountBeforeTextValue && (i = `${r.discountBeforeTextValue}${i}`), r.discountAfterTextValue && (i = `${i}${r.discountAfterTextValue}`));
71
+ const [S] = u, [m] = I, [t] = E, o = m.substring(1, m.length - 2), c = t.match(_.COMPOSITION) !== null;
72
+ let a = p;
73
+ if (c) {
74
+ const b = S.substring(2, S.length - 3), A = s(b);
75
+ o === R.OMNIBUS_PRICE && (A.priceBeforeTextValue && (a = `${A.priceBeforeTextValue}${a}`), A.priceAfterTextValue && (a = `${a}${A.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (A.discountBeforeTextValue && (a = `${A.discountBeforeTextValue}${a}`), A.discountAfterTextValue && (a = `${a}${A.discountAfterTextValue}`));
76
76
  }
77
- const N = u.substring(2);
78
- let M = "";
79
- T in A.IF && (M = A.IF[T].replaceAll(`{${a.DISCOUNT}}`, `${N}${a.DISCOUNT}`).replaceAll(`{${a.OMNIBUS_DISCOUNT}}`, `${N}${a.OMNIBUS_DISCOUNT}`).replaceAll(`{${a.OMNIBUS_PRICE}}`, `${N}${a.OMNIBUS_PRICE}`));
80
- const O = `${_}${i}${h.PARAGRAPH_END_TAG}`, C = `${M}${S ? O : o}${A.ELSE}${_}${h.PARAGRAPH_END_TAG}${A.END_IF}`;
81
- t = t.replace(o, C);
82
- }), t;
77
+ const f = S.substring(2);
78
+ let T = "";
79
+ o in y.IF && (T = y.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${f}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${f}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${f}${R.OMNIBUS_PRICE}`));
80
+ const $ = `${t}${a}${C.PARAGRAPH_END_TAG}`, g = `${T}${c ? $ : r}${y.ELSE}${t}${C.PARAGRAPH_END_TAG}${y.END_IF}`;
81
+ e = e.replace(r, g);
82
+ }), e;
83
83
  },
84
84
  priority: 53
85
+ },
86
+ {
87
+ id: "strip-empty-omnibus-spans",
88
+ description: "Remove empty omnibus text-before and text-after span elements",
89
+ type: "regex",
90
+ pattern: '<span class="omnibus-text-(?:before|after)">\\s*</span>',
91
+ replacement: "",
92
+ flags: "g",
93
+ priority: 54
94
+ },
95
+ {
96
+ id: "strip-recommendation-editor-attributes",
97
+ description: "Strip editor-only attributes from compiled recommendation output",
98
+ type: "regex",
99
+ // eslint-disable-next-line @stylistic/max-len
100
+ pattern: '\\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"',
101
+ replacement: "",
102
+ flags: "g",
103
+ priority: 55
104
+ },
105
+ {
106
+ id: "strip-unused-recommendation-classes",
107
+ description: "Remove CSS classes not referenced by any style rule from recommendation elements",
108
+ type: "custom",
109
+ processor: (n) => {
110
+ let e = n.replace(
111
+ / class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
112
+ ""
113
+ );
114
+ return e = e.replaceAll("es-button buy-button", "es-button"), e = e.replaceAll("ins-recommendation-product-container ", ""), e;
115
+ },
116
+ priority: 56
117
+ },
118
+ {
119
+ id: "remove-empty-mobile-layout-artifacts",
120
+ description: "Remove empty mobile container rows and unused mobile layout CSS",
121
+ type: "custom",
122
+ processor: (n) => {
123
+ let e = n;
124
+ return e = e.replace(
125
+ /<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
126
+ ""
127
+ ), /class="[^"]*ins-recommendation-mobile-container/.test(e) || (e = e.replace(
128
+ /\.ins-recommendation-mobile-container\s*\{\s*display\s*:\s*none\s*;?\s*\}/g,
129
+ ""
130
+ ), e = e.replace(
131
+ /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
132
+ (l, s) => {
133
+ const r = s.match(/[^{}]+\{[^{}]*\}/g) || [], i = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
134
+ return r.every((u) => i.test(u)) ? "" : l;
135
+ }
136
+ )), e;
137
+ },
138
+ priority: 57
139
+ },
140
+ {
141
+ id: "deduplicate-inline-styles",
142
+ description: "Replace repeated inline styles with CSS class references within recommendation blocks",
143
+ type: "custom",
144
+ processor: (n) => {
145
+ const e = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, l = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
146
+ let r = e.exec(n);
147
+ for (; r !== null; ) {
148
+ let t = l.exec(r[1]);
149
+ for (; t !== null; ) {
150
+ const [, o] = t;
151
+ s.set(o, (s.get(o) || 0) + 1), t = l.exec(r[1]);
152
+ }
153
+ l.lastIndex = 0, r = e.exec(n);
154
+ }
155
+ const i = /* @__PURE__ */ new Map(), p = [];
156
+ let u = 0;
157
+ if (s.forEach((t, o) => {
158
+ if (t >= 6) {
159
+ const c = `rc${u++}`;
160
+ i.set(o, c), p.push(`.${c}{${o}}`);
161
+ }
162
+ }), i.size === 0) {
163
+ let t = n;
164
+ return t = t.replaceAll("<!--REC_START-->", ""), t = t.replaceAll("<!--REC_END-->", ""), t;
165
+ }
166
+ const I = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), E = (t, o) => `${t.slice(0, -1)} ${o}"`, S = /* @__PURE__ */ new Map();
167
+ i.forEach((t, o) => {
168
+ const c = I(o);
169
+ S.set(o, {
170
+ caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${c}"`, "g"),
171
+ caseB: new RegExp(` style="${c}"((?:[^>]*?))(class="[^"]*")`, "g")
172
+ });
173
+ });
174
+ let m = n.replace("</style>", `${p.join("")}</style>`);
175
+ return m = m.replace(
176
+ /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
177
+ (t, o) => {
178
+ let c = o;
179
+ return i.forEach((a, f) => {
180
+ const T = S.get(f);
181
+ T.caseA.lastIndex = 0, c = c.replace(
182
+ T.caseA,
183
+ ($, g, b) => E(g, a) + b
184
+ ), T.caseB.lastIndex = 0, c = c.replace(
185
+ T.caseB,
186
+ ($, g, b) => g + E(b, a)
187
+ ), c = c.replaceAll(` style="${f}"`, ` class="${a}"`);
188
+ }), c;
189
+ }
190
+ ), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
191
+ },
192
+ priority: 58
85
193
  }
86
194
  ];
87
195
  export {
88
- G as recommendationCompilerRules
196
+ w as recommendationCompilerRules
89
197
  };
@@ -1,130 +1,131 @@
1
- import { useRecommendation as $ } from "../../../composables/useRecommendation.js";
2
- function b(e, u, r, o) {
3
- const n = `{{${e}_${u}_${r}}}`, t = `{{${e}_${u}_currency}}`;
4
- return o === "before" ? `${t} ${n}` : `${n} ${t}`;
1
+ import { useRecommendation as S } from "../../../composables/useRecommendation.js";
2
+ function b(e, n, r, c) {
3
+ const u = `{{${e}_${n}_${r}}}`, t = `{{${e}_${n}_currency}}`;
4
+ return c === "before" ? `${t} ${u}` : `${u} ${t}`;
5
5
  }
6
- function p(e, u, r, o, n) {
7
- switch (u) {
6
+ function p(e, n, r, c, u) {
7
+ switch (n) {
8
8
  case "productImage": {
9
9
  const t = e.querySelector("img");
10
- t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
11
- const c = e.querySelector("a");
12
- c && c.setAttribute("href", `{{${r}_${o}_url}}`);
10
+ t && (t.setAttribute("src", `{{${r}_${c}_image_url}}`), t.setAttribute("alt", `{{${r}_${c}_name}}`));
11
+ const o = e.querySelector("a");
12
+ o && o.setAttribute("href", `{{${r}_${c}_url}}`);
13
13
  break;
14
14
  }
15
15
  case "productName": {
16
16
  const t = e.querySelector("p");
17
17
  if (t) {
18
- const c = t.querySelector("strong") || t;
19
- c.textContent = `{{${r}_${o}_name}}`;
18
+ const o = t.querySelector("strong") || t;
19
+ o.textContent = `{{${r}_${c}_name}}`;
20
20
  }
21
21
  break;
22
22
  }
23
23
  case "productPrice": {
24
24
  const t = e.querySelector("p");
25
25
  if (t) {
26
- const c = t.querySelector("strong") || t;
27
- c.textContent = b(r, o, "price", n);
26
+ const o = t.querySelector("strong") || t;
27
+ o.textContent = b(r, c, "price", u);
28
28
  }
29
29
  break;
30
30
  }
31
31
  case "productOldPrice": {
32
32
  const t = e.querySelector("p");
33
33
  if (t) {
34
- const c = t.querySelector("strong") || t;
35
- c.textContent = b(
34
+ const o = t.querySelector("strong") || t;
35
+ o.textContent = b(
36
36
  r,
37
- o,
37
+ c,
38
38
  "original_price",
39
- n
39
+ u
40
40
  ), t.setAttribute("product-attr", "discount");
41
41
  }
42
42
  break;
43
43
  }
44
44
  case "productButton": {
45
45
  const t = e.querySelector("a");
46
- t && t.setAttribute("href", `{{${r}_${o}_url}}`);
46
+ t && t.setAttribute("href", `{{${r}_${c}_url}}`);
47
47
  break;
48
48
  }
49
49
  case "productOmnibusPrice": {
50
50
  const t = e.querySelector(".omnibus-price-value");
51
51
  if (t) {
52
- t.textContent = `{{${r}_${o}_omnibus_price}}`;
53
- const c = t.closest("p");
54
- c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
52
+ t.textContent = `{{${r}_${c}_omnibus_price}}`;
53
+ const o = t.closest("p");
54
+ o && (o.setAttribute("product-attr", "omnibus_price"), o.setAttribute("composition", "true"));
55
55
  }
56
56
  break;
57
57
  }
58
58
  case "productOmnibusDiscount": {
59
59
  const t = e.querySelector(".omnibus-discount-value");
60
60
  if (t) {
61
- t.textContent = `{{${r}_${o}_omnibus_discount}}`;
62
- const c = t.closest("p");
63
- c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
61
+ t.textContent = `{{${r}_${c}_omnibus_discount}}`;
62
+ const o = t.closest("p");
63
+ o && (o.setAttribute("product-attr", "omnibus_discount"), o.setAttribute("composition", "true"));
64
64
  }
65
65
  break;
66
66
  }
67
67
  default: {
68
68
  const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
69
69
  if (t) {
70
- const c = t.getAttribute("product-attr"), s = t.querySelector("p");
70
+ const o = t.getAttribute("product-attr"), s = t.querySelector("p");
71
71
  if (s) {
72
72
  const i = s.querySelector("strong") || s;
73
- i.textContent = `{{${r}_${o}_${c}}}`;
73
+ i.textContent = `{{${r}_${c}_${o}}}`;
74
74
  }
75
75
  }
76
76
  break;
77
77
  }
78
78
  }
79
79
  }
80
- function S(e, u, r) {
81
- e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
82
- n.querySelectorAll("[data-attribute-type]").forEach((s) => {
83
- const i = s.getAttribute("data-attribute-type") || "", l = s.querySelectorAll(".attribute-cell");
84
- l.length > 0 ? l.forEach((a) => {
85
- p(a, i, u, t, r);
86
- }) : p(s, i, u, t, r);
80
+ function _(e, n, r) {
81
+ e.querySelectorAll(".recommendation-product-row").forEach((u, t) => {
82
+ u.querySelectorAll("[data-attribute-type]").forEach((s) => {
83
+ const i = s.getAttribute("data-attribute-type") || "", a = s.querySelectorAll(".attribute-cell");
84
+ a.length > 0 ? a.forEach((l) => {
85
+ p(l, i, n, t, r);
86
+ }) : p(s, i, n, t, r);
87
87
  });
88
88
  });
89
89
  }
90
- function _(e, u, r) {
91
- const o = e.querySelectorAll(".recommendation-product-row");
92
- if (!o.length)
90
+ function $(e, n, r) {
91
+ const c = e.querySelectorAll(".recommendation-product-row");
92
+ if (!c.length)
93
93
  return;
94
- const [n] = o, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
95
- o.forEach((s, i) => {
96
- s.querySelectorAll("[data-attribute-type]").forEach((a) => {
97
- const f = a.getAttribute("data-attribute-type") || "";
98
- a.querySelectorAll(".attribute-cell").forEach((y, A) => {
99
- const m = i * c + A;
100
- p(y, f, u, m, r);
94
+ const [u] = c, t = u.querySelector("[data-attribute-type]"), o = t ? t.querySelectorAll(".attribute-cell").length : 1;
95
+ c.forEach((s, i) => {
96
+ s.querySelectorAll("[data-attribute-type]").forEach((l) => {
97
+ const f = l.getAttribute("data-attribute-type") || "";
98
+ l.querySelectorAll(".attribute-cell").forEach((y, m) => {
99
+ const A = i * o + m;
100
+ p(y, f, n, A, r);
101
101
  });
102
102
  });
103
103
  });
104
104
  }
105
- function q(e, u, r) {
106
- e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
107
- _(n, u, r);
105
+ function d(e, n, r) {
106
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((u) => {
107
+ $(u, n, r);
108
108
  });
109
109
  }
110
- function d(e, u) {
111
- const r = e.getAttribute("data-layout") || "grid", o = e.getAttribute("currency-alignment") || "after";
112
- r === "list" ? S(e, u, o) : q(e, u, o);
110
+ function q(e, n) {
111
+ const r = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
112
+ r === "list" ? _(e, n, c) : d(e, n, c);
113
113
  }
114
- function g(e, u) {
114
+ function g(e, n) {
115
115
  const r = e.match(/<!DOCTYPE[^>]*>/i);
116
116
  return (r ? `${r[0]}
117
- ` : "") + u.documentElement.outerHTML;
117
+ ` : "") + n.documentElement.outerHTML;
118
118
  }
119
119
  function E(e) {
120
- const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
121
- if (!o.length)
120
+ const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html"), c = r.querySelectorAll(".recommendation-block-v2");
121
+ if (!c.length)
122
122
  return e;
123
- const { buildCampaignUrl: n } = $();
124
- return o.forEach((c) => {
125
- const s = c.getAttribute("recommendation-id");
126
- s && (n(s), d(c, s));
127
- }), g(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
123
+ const { buildCampaignUrl: u } = S();
124
+ return c.forEach((o) => {
125
+ var i, a;
126
+ const s = o.getAttribute("recommendation-id");
127
+ s && ((i = o.parentNode) == null || i.insertBefore(r.createComment("REC_START"), o), (a = o.parentNode) == null || a.insertBefore(r.createComment("REC_END"), o.nextSibling), u(s), q(o, s));
128
+ }), g(n, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
128
129
  }
129
130
  export {
130
131
  b as formatPriceVariable,
@@ -11,8 +11,6 @@ class f {
11
11
  try {
12
12
  const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
13
13
  return i.length === 0 ? t : (i.forEach((r) => {
14
- if (r.classList.contains("checkbox-block-v2"))
15
- return;
16
14
  const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
17
15
  `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
18
16
  "text/html"
@@ -24,7 +22,7 @@ class f {
24
22
  }
25
23
  }
26
24
  extractTextFromElement(t, e) {
27
- var o, d;
25
+ var o, u;
28
26
  const i = t.querySelector(`.${e}`);
29
27
  if (!i)
30
28
  return {
@@ -43,13 +41,13 @@ class f {
43
41
  align: i.getAttribute("align") || "left",
44
42
  styles: ""
45
43
  };
46
- const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
44
+ const n = ((u = r.textContent) == null ? void 0 : u.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), d = this.convertInlineToBlock(g);
47
45
  return {
48
46
  text: n,
49
47
  isBold: a,
50
48
  isItalic: p,
51
49
  align: c,
52
- styles: u
50
+ styles: d
53
51
  };
54
52
  }
55
53
  buildTextBlock(t) {
@@ -1,30 +1,28 @@
1
- var x = Object.defineProperty;
2
- var f = (r, t, e) => t in r ? x(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var b = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
1
+ var b = Object.defineProperty;
2
+ var f = (r, t, e) => t in r ? b(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var x = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
4
4
  import h from "../../extensions/Blocks/RadioButton/template.js";
5
5
  class T {
6
6
  constructor() {
7
- b(this, "parser");
7
+ x(this, "parser");
8
8
  this.parser = new DOMParser();
9
9
  }
10
10
  migrate(t) {
11
11
  try {
12
12
  const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
13
13
  return i.length === 0 ? t : (i.forEach((s) => {
14
- if (s.classList.contains("radio-button-v2"))
15
- return;
16
- const n = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), d = this.buildTextBlock(l), g = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), o = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", g).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", o), y = this.parser.parseFromString(
14
+ const o = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), d = this.buildTextBlock(l), g = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), n = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", g).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", n), y = this.parser.parseFromString(
17
15
  `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
18
16
  "text/html"
19
17
  ).querySelector(".radio-button-v2");
20
- y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
18
+ y && s.parentNode && (y.setAttribute("id", o || ""), s.parentNode.replaceChild(y, s));
21
19
  }), e.documentElement.outerHTML);
22
20
  } catch (e) {
23
21
  return console.error("RadioButtonMigrator failed:", e), t;
24
22
  }
25
23
  }
26
24
  extractTextFromElement(t, e) {
27
- var o, c;
25
+ var n, c;
28
26
  const i = t.querySelector(`.${e}`);
29
27
  if (!i)
30
28
  return {
@@ -38,16 +36,16 @@ class T {
38
36
  const s = i.querySelector("p");
39
37
  if (!s)
40
38
  return {
41
- text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
39
+ text: ((n = i.textContent) == null ? void 0 : n.trim()) || (e === "ins-title" ? "Title" : "Description"),
42
40
  isBold: !1,
43
41
  isItalic: !1,
44
42
  align: i.getAttribute("align") || "left",
45
43
  styles: "",
46
44
  classList: ""
47
45
  };
48
- const n = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), d = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(d), m = i.getAttribute("class") || "";
46
+ const o = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), d = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(d), m = i.getAttribute("class") || "";
49
47
  return {
50
- text: n,
48
+ text: o,
51
49
  isBold: p,
52
50
  isItalic: u,
53
51
  align: a,
@@ -68,8 +66,8 @@ class T {
68
66
  `;
69
67
  }
70
68
  removeStyleProperties(t, e) {
71
- return t ? e.reduce((s, n) => {
72
- const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
69
+ return t ? e.reduce((s, o) => {
70
+ const l = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
73
71
  return s.replace(l, "");
74
72
  }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
75
73
  }
@@ -169,7 +169,7 @@ class q extends b {
169
169
  if (e && e.includes(a))
170
170
  return t;
171
171
  }
172
- return "querySelector" in t ? t.querySelector(`.${a}`) ?? null : null;
172
+ return "querySelector" in t ? t.querySelector(`.${a}`) : null;
173
173
  }
174
174
  /**
175
175
  * Migrate configuration from legacy format
@@ -1,42 +1,26 @@
1
- const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", n = ".ins-recommendation-mobile-container", t = ".ins-recommendation-mobile-row", r = {
1
+ const T = ".recommendation-block-v2", c = ".ins-recommendation-product-container", o = ".ins-recommendation-desktop-container", t = ".ins-recommendation-mobile-container", n = ".ins-recommendation-mobile-row", R = {
2
2
  CURRENCY: "currency",
3
3
  SYMBOL: "currency-symbol",
4
4
  ALIGNMENT: "currency-alignment",
5
5
  THOUSAND_SEPARATOR: "currency-thousand-separator",
6
6
  DECIMAL_SEPARATOR: "currency-decimal-separator",
7
7
  DECIMAL_COUNT: "currency-decimal-count"
8
- }, R = "productImage", _ = "productName", e = "productPrice", O = "productOldPrice", s = "productOmnibusPrice", i = "productOmnibusDiscount", E = "productButton", A = "customAttr:", C = "data-custom-attributes", u = "product-attr", m = /* @__PURE__ */ new Set([
9
- "name",
10
- // productName
11
- "price",
12
- // productPrice
13
- "original_price",
14
- // productOldPrice
15
- "image_url",
16
- // productImage
17
- "url",
18
- // productButton
19
- "omnibus_price",
20
- // productOmnibusPrice
21
- "omnibus_discount"
22
- // productOmnibusDiscount
23
- ]);
8
+ }, r = "productImage", O = "productName", _ = "productPrice", e = "productOldPrice", s = "productOmnibusPrice", C = "productOmnibusDiscount", E = "productButton", A = "customAttr:", i = "data-custom-attributes", u = "product-attr";
24
9
  export {
25
10
  A as ATTR_CUSTOM_PREFIX,
26
- C as ATTR_DATA_CUSTOM_ATTRIBUTES,
11
+ i as ATTR_DATA_CUSTOM_ATTRIBUTES,
27
12
  u as ATTR_PRODUCT_ATTR,
28
13
  E as ATTR_PRODUCT_BUTTON,
29
- R as ATTR_PRODUCT_IMAGE,
30
- _ as ATTR_PRODUCT_NAME,
31
- O as ATTR_PRODUCT_OLD_PRICE,
32
- i as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
14
+ r as ATTR_PRODUCT_IMAGE,
15
+ O as ATTR_PRODUCT_NAME,
16
+ e as ATTR_PRODUCT_OLD_PRICE,
17
+ C as ATTR_PRODUCT_OMNIBUS_DISCOUNT,
33
18
  s as ATTR_PRODUCT_OMNIBUS_PRICE,
34
- e as ATTR_PRODUCT_PRICE,
19
+ _ as ATTR_PRODUCT_PRICE,
35
20
  T as BLOCK_ROOT_SELECTOR,
36
- m as BUILT_IN_DEFAULT_ATTRIBUTES,
37
21
  c as CONTAINER_SELECTOR,
38
- r as CURRENCY_ATTR,
22
+ R as CURRENCY_ATTR,
39
23
  o as DESKTOP_CONTAINER_SELECTOR,
40
- n as MOBILE_CONTAINER_SELECTOR,
41
- t as MOBILE_ROW_SELECTOR
24
+ t as MOBILE_CONTAINER_SELECTOR,
25
+ n as MOBILE_ROW_SELECTOR
42
26
  };