@useinsider/guido 3.1.1-beta.6b60896 → 3.1.1-beta.7145c7d

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 (68) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +69 -61
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +91 -81
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
  6. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
  7. package/dist/components/organisms/header/EditorActions.vue.js +2 -2
  8. package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
  9. package/dist/components/organisms/header/RightSlot.vue.js +10 -10
  10. package/dist/components/organisms/header/RightSlot.vue2.js +16 -13
  11. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
  12. package/dist/composables/useHtmlCompiler.js +23 -21
  13. package/dist/composables/usePreviewMode.js +20 -16
  14. package/dist/composables/useSave.js +23 -15
  15. package/dist/composables/useStripo.js +44 -41
  16. package/dist/composables/validators/useLiquidValidator.js +42 -0
  17. package/dist/config/compiler/liquidCompilerRules.js +15 -0
  18. package/dist/config/compiler/recommendationCompilerRules.js +158 -44
  19. package/dist/config/compiler/utils/recommendationCompilerUtils.js +37 -36
  20. package/dist/config/migrator/checkboxMigrator.js +5 -3
  21. package/dist/config/migrator/radioButtonMigrator.js +14 -12
  22. package/dist/enums/extensions/recommendationBlock.js +14 -11
  23. package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
  24. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  25. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
  26. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
  27. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +95 -93
  28. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +75 -73
  29. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
  30. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
  31. package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
  32. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
  33. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +20 -20
  34. package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
  35. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +6 -6
  36. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +16 -17
  37. package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
  38. package/dist/guido.css +1 -1
  39. package/dist/services/recommendationApi.js +15 -15
  40. package/dist/services/templateLibraryApi.js +48 -46
  41. package/dist/src/@types/config/index.d.ts +1 -1
  42. package/dist/src/@types/config/schemas.d.ts +20 -0
  43. package/dist/src/@types/config/types.d.ts +3 -1
  44. package/dist/src/@types/generic.d.ts +0 -1
  45. package/dist/src/@types/save-as-template.d.ts +1 -0
  46. package/dist/src/composables/useConfig.d.ts +8 -0
  47. package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
  48. package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
  49. package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
  50. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
  51. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
  53. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
  54. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  55. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  56. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
  57. package/dist/src/services/templateLibraryApi.d.ts +1 -1
  58. package/dist/src/stores/config.d.ts +72 -0
  59. package/dist/src/stores/preview.d.ts +3 -0
  60. package/dist/src/utils/genericUtil.d.ts +1 -1
  61. package/dist/src/utils/htmlCompiler.d.ts +2 -1
  62. package/dist/static/styles/base.css.js +7 -2
  63. package/dist/stores/preview.js +4 -3
  64. package/dist/utils/genericUtil.js +42 -20
  65. package/dist/utils/htmlCompiler.js +48 -41
  66. package/dist/utils/templatePreparation.js +35 -26
  67. package/dist/utils/tooltipUtils.js +4 -5
  68. package/package.json +3 -2
@@ -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 C, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as R, CONDITIONS as $, HTML as h } 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: (i) => {
10
+ let e = i;
11
+ return Object.entries(C).forEach(([, p]) => {
12
+ Object.entries(p).forEach(([c, n]) => {
13
+ e = e.replaceAll(n, `{{${c}}}`);
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: (i) => {
33
+ const { calculateCardWidth: e, getRecommendationCampaignData: p } = N();
34
+ let c = i;
35
+ const n = c.match(T.ID);
36
+ if (n) {
37
+ const a = [];
38
+ if (n.forEach((s) => {
39
+ const d = /recommendation-id="(.*?)"/i.exec(s), _ = d ? d[1].trim() : "", A = p(_);
40
+ A.textTrimming && A.orientation === M && a.push(e(A));
41
+ }), a.length) {
42
+ const s = `width:${Math.min(...a)}px!important;`;
43
+ c = c.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
44
44
  }
45
45
  }
46
- return n;
46
+ return c;
47
47
  },
48
48
  priority: 52
49
49
  },
@@ -51,39 +51,153 @@ 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: (i) => x(i),
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: (i) => {
62
+ let e = i;
63
+ const p = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: c } = N();
64
+ return p !== null && p.forEach((n) => {
65
+ const a = n.match(T.CUSTOM_FIELD);
66
+ if (!a)
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 [s] = a, d = s.match(T.CUSTOM_FIELD_INDEXES_PART), _ = s.match(T.CUSTOM_FIELD_NAME_PART), A = n.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
69
+ if (!d || !_ || !A)
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 [I] = d, [S] = _, [m] = A, o = S.substring(1, S.length - 2), r = m.match(T.COMPOSITION) !== null;
72
+ let t = s;
73
+ if (r) {
74
+ const b = I.substring(2, I.length - 3), l = c(b);
75
+ o === R.OMNIBUS_PRICE && (l.priceBeforeTextValue && (t = `${l.priceBeforeTextValue}${t}`), l.priceAfterTextValue && (t = `${t}${l.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (t = `${l.discountBeforeTextValue}${t}`), l.discountAfterTextValue && (t = `${t}${l.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 u = I.substring(2);
78
+ let f = "";
79
+ o in $.IF && (f = $.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${u}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${u}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${u}${R.OMNIBUS_PRICE}`));
80
+ const g = `${m}${t}${h.PARAGRAPH_END_TAG}`, y = `${f}${r ? g : n}${$.ELSE}${m}${h.PARAGRAPH_END_TAG}${$.END_IF}`;
81
+ e = e.replace(n, y);
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: (i) => {
110
+ let e = i.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: (i) => {
123
+ let e = i;
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
+ (p, c) => {
133
+ const n = c.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
134
+ return n.every((d) => a.test(d)) ? "" : p;
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: (i) => {
145
+ const e = i.replace(
146
+ /<a\b[^>]*\bes-button\b[^>]*>/g,
147
+ (o) => o.replace(
148
+ /([;"]color:)([^;"]+)/g,
149
+ (r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
150
+ )
151
+ ), p = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, c = / style="([^"]*)"/g, n = /* @__PURE__ */ new Map();
152
+ let a = p.exec(e);
153
+ for (; a !== null; ) {
154
+ let o = c.exec(a[1]);
155
+ for (; o !== null; ) {
156
+ const [, r] = o;
157
+ n.set(r, (n.get(r) || 0) + 1), o = c.exec(a[1]);
158
+ }
159
+ c.lastIndex = 0, a = p.exec(e);
160
+ }
161
+ const s = /* @__PURE__ */ new Map(), d = [];
162
+ let _ = 0;
163
+ if (n.forEach((o, r) => {
164
+ if (o >= 6) {
165
+ const t = `rc${_++}`;
166
+ s.set(r, t), d.push(`.${t}{${r}}`);
167
+ }
168
+ }), s.size === 0) {
169
+ let o = e;
170
+ return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
171
+ }
172
+ const A = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), I = (o, r) => `${o.slice(0, -1)} ${r}"`, S = /* @__PURE__ */ new Map();
173
+ s.forEach((o, r) => {
174
+ const t = A(r);
175
+ S.set(r, {
176
+ caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
177
+ caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
178
+ });
179
+ });
180
+ let m = e.replace("</style>", `${d.join("")}</style>`);
181
+ return m = m.replace(
182
+ /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
183
+ (o, r) => {
184
+ let t = r;
185
+ return s.forEach((u, f) => {
186
+ const g = S.get(f);
187
+ t = t.replace(
188
+ g.caseA,
189
+ (y, b, l) => I(b, u) + l
190
+ ), t = t.replace(
191
+ g.caseB,
192
+ (y, b, l) => b + I(l, u)
193
+ ), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
194
+ }), t;
195
+ }
196
+ ), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
197
+ },
198
+ priority: 58
85
199
  }
86
200
  ];
87
201
  export {
88
- G as recommendationCompilerRules
202
+ w as recommendationCompilerRules
89
203
  };
@@ -1,23 +1,23 @@
1
1
  import { useConfig as S } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
- function y(e, n, r, o, s = "") {
4
- const u = `{{${s}${e}_${n}_${r}}}`, t = `{{${s}${e}_${n}_currency}}`;
5
- return o === "before" ? `${t} ${u}` : `${u} ${t}`;
3
+ function y(e, u, r, o, s = "") {
4
+ const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
5
+ return o === "before" ? `${t} ${n}` : `${n} ${t}`;
6
6
  }
7
- function p(e, n, r, o, s, u) {
8
- switch (n) {
7
+ function p(e, u, r, o, s, n) {
8
+ switch (u) {
9
9
  case "productImage": {
10
10
  const t = e.querySelector("img");
11
- t && (t.setAttribute("src", `{{${u}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${u}${r}_${o}_name}}`));
11
+ t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
12
12
  const c = e.querySelector("a");
13
- c && c.setAttribute("href", `{{${u}${r}_${o}_url}}`);
13
+ c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
14
14
  break;
15
15
  }
16
16
  case "productName": {
17
17
  const t = e.querySelector("p");
18
18
  if (t) {
19
19
  const c = t.querySelector("strong") || t;
20
- c.textContent = `{{${u}${r}_${o}_name}}`;
20
+ c.textContent = `{{${n}${r}_${o}_name}}`;
21
21
  }
22
22
  break;
23
23
  }
@@ -25,7 +25,7 @@ function p(e, n, r, o, s, u) {
25
25
  const t = e.querySelector("p");
26
26
  if (t) {
27
27
  const c = t.querySelector("strong") || t;
28
- c.textContent = y(r, o, "price", s, u);
28
+ c.textContent = y(r, o, "price", s, n);
29
29
  }
30
30
  break;
31
31
  }
@@ -38,20 +38,20 @@ function p(e, n, r, o, s, u) {
38
38
  o,
39
39
  "original_price",
40
40
  s,
41
- u
41
+ n
42
42
  ), t.setAttribute("product-attr", "discount");
43
43
  }
44
44
  break;
45
45
  }
46
46
  case "productButton": {
47
47
  const t = e.querySelector("a");
48
- t && t.setAttribute("href", `{{${u}${r}_${o}_url}}`);
48
+ t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
49
49
  break;
50
50
  }
51
51
  case "productOmnibusPrice": {
52
52
  const t = e.querySelector(".omnibus-price-value");
53
53
  if (t) {
54
- t.textContent = `{{${u}${r}_${o}_omnibus_price}}`;
54
+ t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
55
55
  const c = t.closest("p");
56
56
  c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
57
57
  }
@@ -60,7 +60,7 @@ function p(e, n, r, o, s, u) {
60
60
  case "productOmnibusDiscount": {
61
61
  const t = e.querySelector(".omnibus-discount-value");
62
62
  if (t) {
63
- t.textContent = `{{${u}${r}_${o}_omnibus_discount}}`;
63
+ t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
64
64
  const c = t.closest("p");
65
65
  c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
66
66
  }
@@ -72,61 +72,62 @@ function p(e, n, r, o, s, u) {
72
72
  const c = t.getAttribute("product-attr"), i = t.querySelector("p");
73
73
  if (i) {
74
74
  const a = i.querySelector("strong") || i;
75
- a.textContent = `{{${u}${r}_${o}_${c}}}`;
75
+ a.textContent = `{{${n}${r}_${o}_${c}}}`;
76
76
  }
77
77
  }
78
78
  break;
79
79
  }
80
80
  }
81
81
  }
82
- function q(e, n, r, o) {
83
- e.querySelectorAll(".recommendation-product-row").forEach((u, t) => {
84
- u.querySelectorAll("[data-attribute-type]").forEach((i) => {
82
+ function d(e, u, r, o) {
83
+ e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
84
+ n.querySelectorAll("[data-attribute-type]").forEach((i) => {
85
85
  const a = i.getAttribute("data-attribute-type") || "", b = i.querySelectorAll(".attribute-cell");
86
86
  b.length > 0 ? b.forEach((l) => {
87
- p(l, a, n, t, r, o);
88
- }) : p(i, a, n, t, r, o);
87
+ p(l, a, u, t, r, o);
88
+ }) : p(i, a, u, t, r, o);
89
89
  });
90
90
  });
91
91
  }
92
- function d(e, n, r, o) {
92
+ function q(e, u, r, o) {
93
93
  const s = e.querySelectorAll(".recommendation-product-row");
94
94
  if (!s.length)
95
95
  return;
96
- const [u] = s, t = u.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
96
+ const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
97
97
  s.forEach((i, a) => {
98
98
  i.querySelectorAll("[data-attribute-type]").forEach((l) => {
99
- const $ = l.getAttribute("data-attribute-type") || "";
100
- l.querySelectorAll(".attribute-cell").forEach((A, f) => {
101
- const m = a * c + f;
102
- p(A, $, n, m, r, o);
99
+ const m = l.getAttribute("data-attribute-type") || "";
100
+ l.querySelectorAll(".attribute-cell").forEach(($, f) => {
101
+ const A = a * c + f;
102
+ p($, m, u, A, r, o);
103
103
  });
104
104
  });
105
105
  });
106
106
  }
107
- function g(e, n, r, o) {
108
- e.querySelectorAll(".ins-recommendation-product-container").forEach((u) => {
109
- d(u, n, r, o);
107
+ function g(e, u, r, o) {
108
+ e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
109
+ q(n, u, r, o);
110
110
  });
111
111
  }
112
- function h(e, n, r) {
112
+ function h(e, u, r) {
113
113
  const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
114
- o === "list" ? q(e, n, s, r) : g(e, n, s, r);
114
+ o === "list" ? d(e, u, s, r) : g(e, u, s, r);
115
115
  }
116
- function C(e, n) {
116
+ function C(e, u) {
117
117
  const r = e.match(/<!DOCTYPE[^>]*>/i);
118
118
  return (r ? `${r[0]}
119
- ` : "") + n.documentElement.outerHTML;
119
+ ` : "") + u.documentElement.outerHTML;
120
120
  }
121
121
  function P(e) {
122
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(n, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
122
+ const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
123
123
  if (!o.length)
124
124
  return e;
125
- const { buildCampaignUrl: s } = _(), { isFeatureEnabled: u } = S(), t = u("liquidSyntax") ? "reco_" : "";
125
+ const { buildCampaignUrl: s } = _(), { isFeatureEnabled: n } = S(), t = n("liquidSyntax") ? "reco_" : "";
126
126
  return o.forEach((i) => {
127
+ var b, l;
127
128
  const a = i.getAttribute("recommendation-id");
128
- a && (s(a), h(i, a, t));
129
- }), C(n, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
129
+ a && ((b = i.parentNode) == null || b.insertBefore(r.createComment("REC_START"), i), (l = i.parentNode) == null || l.insertBefore(r.createComment("REC_END"), i.nextSibling), s(a), h(i, a, t));
130
+ }), C(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
130
131
  }
131
132
  export {
132
133
  y as formatPriceVariable,
@@ -11,6 +11,8 @@ 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;
14
16
  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(
15
17
  `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
16
18
  "text/html"
@@ -22,7 +24,7 @@ class f {
22
24
  }
23
25
  }
24
26
  extractTextFromElement(t, e) {
25
- var o, u;
27
+ var o, d;
26
28
  const i = t.querySelector(`.${e}`);
27
29
  if (!i)
28
30
  return {
@@ -41,13 +43,13 @@ class f {
41
43
  align: i.getAttribute("align") || "left",
42
44
  styles: ""
43
45
  };
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);
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);
45
47
  return {
46
48
  text: n,
47
49
  isBold: a,
48
50
  isItalic: p,
49
51
  align: c,
50
- styles: d
52
+ styles: u
51
53
  };
52
54
  }
53
55
  buildTextBlock(t) {
@@ -1,28 +1,30 @@
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);
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);
4
4
  import h from "../../extensions/Blocks/RadioButton/template.js";
5
5
  class T {
6
6
  constructor() {
7
- x(this, "parser");
7
+ b(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
- 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(
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(
15
17
  `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
16
18
  "text/html"
17
19
  ).querySelector(".radio-button-v2");
18
- y && s.parentNode && (y.setAttribute("id", o || ""), s.parentNode.replaceChild(y, s));
20
+ y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
19
21
  }), e.documentElement.outerHTML);
20
22
  } catch (e) {
21
23
  return console.error("RadioButtonMigrator failed:", e), t;
22
24
  }
23
25
  }
24
26
  extractTextFromElement(t, e) {
25
- var n, c;
27
+ var o, c;
26
28
  const i = t.querySelector(`.${e}`);
27
29
  if (!i)
28
30
  return {
@@ -36,16 +38,16 @@ class T {
36
38
  const s = i.querySelector("p");
37
39
  if (!s)
38
40
  return {
39
- text: ((n = i.textContent) == null ? void 0 : n.trim()) || (e === "ins-title" ? "Title" : "Description"),
41
+ text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
40
42
  isBold: !1,
41
43
  isItalic: !1,
42
44
  align: i.getAttribute("align") || "left",
43
45
  styles: "",
44
46
  classList: ""
45
47
  };
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") || "";
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") || "";
47
49
  return {
48
- text: o,
50
+ text: n,
49
51
  isBold: p,
50
52
  isItalic: u,
51
53
  align: a,
@@ -66,8 +68,8 @@ class T {
66
68
  `;
67
69
  }
68
70
  removeStyleProperties(t, e) {
69
- return t ? e.reduce((s, o) => {
70
- const l = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
71
+ return t ? e.reduce((s, n) => {
72
+ const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
71
73
  return s.replace(l, "");
72
74
  }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
73
75
  }
@@ -1,6 +1,8 @@
1
1
  const s = {
2
2
  RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com"
3
- }, i = [
3
+ }, i = {
4
+ CLIENT_ID: "clientId"
5
+ }, u = [
4
6
  { id: 11, key: "similarViewed", name: "Viewed Together", path: "viewed-together" },
5
7
  { id: 12, key: "similarBought", name: "Purchased Together", path: "purchased-together" },
6
8
  { id: 13, key: "userBased", name: "User Based", path: "user-based" },
@@ -11,13 +13,13 @@ const s = {
11
13
  { id: 46, key: "mostValuableOfPartner", name: "Most Valuable Products", path: "most-valuable" },
12
14
  { id: 61, key: "mostPopular", name: "Most Popular Items", path: "most-popular" },
13
15
  { id: 62, key: "mostPurchased", name: "Top Sellers", path: "top-sellers" }
14
- ], u = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], l = [
16
+ ], l = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], c = [
15
17
  { text: "before the amount", value: "0" },
16
18
  { text: "after the amount", value: "1" }
17
- ], c = [
19
+ ], d = [
18
20
  { text: "dot(.)", value: "." },
19
21
  { text: "comma(,)", value: "," }
20
- ], d = [
22
+ ], p = [
21
23
  { text: "0", value: "0" },
22
24
  { text: "1", value: "1" },
23
25
  { text: "2", value: "2" },
@@ -46,7 +48,7 @@ const s = {
46
48
  ], n = [
47
49
  { text: "true", value: "==" },
48
50
  { text: "false", value: "!=" }
49
- ], p = (t) => {
51
+ ], m = (t) => {
50
52
  if (!t)
51
53
  return e;
52
54
  switch (t) {
@@ -65,13 +67,14 @@ const s = {
65
67
  }
66
68
  };
67
69
  export {
68
- u as PriceAttributes,
69
- i as RecommendationFeedSourceMaps,
70
+ l as PriceAttributes,
71
+ i as QUERY_PARAMS,
72
+ u as RecommendationFeedSourceMaps,
70
73
  s as URLS,
71
- d as currencyDecimalCounts,
72
- l as currencyLocationMaps,
73
- c as currencyOperators,
74
- p as getOperatorOptions,
74
+ p as currencyDecimalCounts,
75
+ c as currencyLocationMaps,
76
+ d as currencyOperators,
77
+ m as getOperatorOptions,
75
78
  a as operatorOptionsForArrayOfStrings,
76
79
  n as operatorOptionsForBooleans,
77
80
  o as operatorOptionsForDates,
@@ -1,29 +1,40 @@
1
- import { BlockType as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { COUPON_BLOCK_ID as e } from "./block.js";
3
- const t = `
4
- <${o.BLOCK_TEXT}
1
+ import { useConfig as n } from "../../../composables/useConfig.js";
2
+ import { BlockType as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { COUPON_BLOCK_ID as t } from "./block.js";
4
+ const c = "{@COUPON_CODE}", s = "{{ins_coupon_code}}";
5
+ function l() {
6
+ const { isFeatureEnabled: o } = n();
7
+ return o("liquidSyntax") ? s : c;
8
+ }
9
+ function i(o) {
10
+ return `
11
+ <${e.BLOCK_TEXT}
5
12
  class="coupon-block ins-coupon-code coupon-block-v2 es-p10"
6
13
  align="center"
7
- esd-extension-block-id="${e}">
14
+ esd-extension-block-id="${t}">
8
15
  <p
9
16
  path="1"
10
17
  contenteditable="false"
11
18
  style="font-size: 16px; color: #333333;">
12
- <strong path="1,0">{@COUPON_CODE}</strong>
19
+ <strong path="1,0">${o}</strong>
13
20
  </p>
14
- </${o.BLOCK_TEXT}>
15
- `, l = `
21
+ </${e.BLOCK_TEXT}>
22
+ `;
23
+ }
24
+ const u = `
16
25
  <td
17
26
  class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"
18
- esd-extension-block-id="${e}"
27
+ esd-extension-block-id="${t}"
19
28
  >
20
29
  <p class="ins-title" contenteditable="false">{@COUPON_CODE}</p>
21
30
  </td>
22
31
  `;
23
- function s() {
24
- return t;
32
+ function d() {
33
+ return i(l());
25
34
  }
26
35
  export {
27
- l as default,
28
- s as getDefaultTemplate
36
+ c as COUPON_PLACEHOLDER_DEFAULT,
37
+ s as COUPON_PLACEHOLDER_LIQUID,
38
+ u as default,
39
+ d as getDefaultTemplate
29
40
  };
@@ -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;
172
+ return "querySelector" in t ? t.querySelector(`.${a}`) ?? null : null;
173
173
  }
174
174
  /**
175
175
  * Migrate configuration from legacy format