@useinsider/guido 3.8.1-beta.bc12f34 → 3.8.1-beta.f1e1757

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 (45) hide show
  1. package/dist/@types/config/schemas.js +66 -70
  2. package/dist/composables/useHtmlCompiler.js +13 -10
  3. package/dist/composables/usePreviewMode.js +14 -15
  4. package/dist/config/compiler/htmlCompilerRules.js +38 -10
  5. package/dist/config/compiler/recommendationCompilerRules.js +84 -109
  6. package/dist/config/compiler/utils/recommendationCompilerUtils.js +80 -88
  7. package/dist/config/migrator/recommendation/htmlBuilder.js +52 -53
  8. package/dist/config/migrator/recommendation/settingsMapper.js +33 -38
  9. package/dist/extensions/Blocks/Recommendation/block.js +41 -60
  10. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +32 -41
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +264 -345
  12. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +87 -99
  13. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +160 -162
  14. package/dist/extensions/Blocks/Recommendation/extension.js +29 -30
  15. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +7 -21
  16. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -64
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +1 -3
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +96 -130
  19. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +54 -43
  20. package/dist/extensions/Blocks/Recommendation/templates/index.js +14 -17
  21. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +80 -86
  22. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +40 -31
  23. package/dist/extensions/Blocks/Recommendation/templates/utils.js +102 -155
  24. package/dist/src/@types/config/schemas.d.ts +0 -16
  25. package/dist/src/composables/useConfig.d.ts +0 -4
  26. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
  28. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -29
  29. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
  31. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -2
  32. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +1 -13
  33. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  34. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  35. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +1 -10
  36. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  37. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -51
  38. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -15
  39. package/dist/src/stores/config.d.ts +0 -36
  40. package/package.json +1 -1
  41. package/dist/composables/useRecommendationPreview.js +0 -100
  42. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +0 -16
  43. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +0 -133
  44. package/dist/src/composables/useRecommendationPreview.d.ts +0 -10
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +0 -59
@@ -1,16 +1,16 @@
1
- import { useRecommendation as h } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as N, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as y, HTML as C } from "../../enums/recommendation.js";
3
- import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
4
- const w = [
1
+ import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as M, REGEX as d, VerticalOrientation as $, CSS as n, ATTRIBUTES as p, CONDITIONS as T, HTML as g } from "../../enums/recommendation.js";
3
+ import { prepareRecommendationBlocks as O } from "./utils/recommendationCompilerUtils.js";
4
+ const U = [
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: (c) => {
10
- let e = c;
11
- return Object.entries(N).forEach(([, l]) => {
12
- Object.entries(l).forEach(([n, s]) => {
13
- e = e.replaceAll(s, `{{${n}}}`);
9
+ processor: (o) => {
10
+ let e = o;
11
+ return Object.entries(M).forEach(([, r]) => {
12
+ Object.entries(r).forEach(([t, i]) => {
13
+ e = e.replaceAll(i, `{{${t}}}`);
14
14
  });
15
15
  }), e;
16
16
  },
@@ -41,21 +41,21 @@ const w = [
41
41
  id: "add-recommendation-unresponsive-css",
42
42
  description: "Adding recommendation unresponsive css",
43
43
  type: "custom",
44
- processor: (c) => {
45
- const { calculateCardWidth: e, getRecommendationCampaignData: l } = h();
46
- let n = c;
47
- const s = n.match(T.ID);
48
- if (s) {
49
- const a = [];
50
- if (s.forEach((i) => {
51
- const u = /recommendation-id="(.*?)"/i.exec(i), _ = u ? u[1].trim() : "", R = l(_);
52
- R.textTrimming && R.orientation === M && a.push(e(R));
53
- }), a.length) {
54
- const i = `width:${Math.min(...a)}px!important;`;
55
- n = n.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
44
+ processor: (o) => {
45
+ const { calculateCardWidth: e, getRecommendationCampaignData: r } = N();
46
+ let t = o;
47
+ const i = t.match(d.ID);
48
+ if (i) {
49
+ const s = [];
50
+ if (i.forEach((c) => {
51
+ const m = /recommendation-id="(.*?)"/i.exec(c), E = m ? m[1].trim() : "", u = r(E);
52
+ u.textTrimming && u.orientation === $ && s.push(e(u));
53
+ }), s.length) {
54
+ const c = `width:${Math.min(...s)}px!important;`;
55
+ t = t.replace(n.REGULAR_NAME_HEIGHT, `${n.TRIMMED_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.REGULAR_NAME_CONTAINER_HEIGHT, n.TRIMMED_NAME_CONTAINER_CSS).replace(n.RESPONSIVE_NAME_SIZE, `${n.RESPONSIVE_NAME_HEIGHT} ${c} ${n.ELLIPSIS}`).replace(n.RESPONSIVE_NAME_CONTAINER_HEIGHT, n.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
56
56
  }
57
57
  }
58
- return n;
58
+ return t;
59
59
  },
60
60
  priority: 52
61
61
  },
@@ -63,34 +63,34 @@ const w = [
63
63
  id: "prepare-recommendations",
64
64
  description: "Replacing product data with template variables in recommendation blocks",
65
65
  type: "custom",
66
- processor: (c) => x(c),
66
+ processor: (o) => O(o),
67
67
  priority: 48
68
68
  },
69
69
  {
70
70
  id: "add-discount-conditions",
71
71
  description: "Adding discount conditions to the recommendation block",
72
72
  type: "custom",
73
- processor: (c) => {
74
- let e = c;
75
- const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = h();
76
- return l !== null && l.forEach((s) => {
77
- const a = s.match(T.CUSTOM_FIELD);
78
- if (!a)
73
+ processor: (o) => {
74
+ let e = o;
75
+ const r = e.match(d.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: t } = N();
76
+ return r !== null && r.forEach((i) => {
77
+ const s = i.match(d.CUSTOM_FIELD);
78
+ if (!s)
79
79
  return;
80
- const [i] = a, u = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
81
- if (!u || !_ || !R)
80
+ const [c] = s, m = c.match(d.CUSTOM_FIELD_INDEXES_PART), E = c.match(d.CUSTOM_FIELD_NAME_PART), u = i.match(d.ATTRIBUTE_PARAGRAPH_START_TAG);
81
+ if (!m || !E || !u)
82
82
  return;
83
- const [b] = u, [I] = _, [d] = R, o = I.substring(1, I.length - 2), r = d.match(T.COMPOSITION) !== null;
84
- let t = i;
85
- if (r) {
86
- const S = b.substring(2, b.length - 3), m = n(S);
87
- o === A.OMNIBUS_PRICE && (m.priceBeforeTextValue && (t = `${m.priceBeforeTextValue}${t}`), m.priceAfterTextValue && (t = `${t}${m.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (m.discountBeforeTextValue && (t = `${m.discountBeforeTextValue}${t}`), m.discountAfterTextValue && (t = `${t}${m.discountAfterTextValue}`));
83
+ const [A] = m, [I] = E, [R] = u, b = I.substring(1, I.length - 2), S = R.match(d.COMPOSITION) !== null;
84
+ let a = c;
85
+ if (S) {
86
+ const f = A.substring(2, A.length - 3), l = t(f);
87
+ b === p.OMNIBUS_PRICE && (l.priceBeforeTextValue && (a = `${l.priceBeforeTextValue}${a}`), l.priceAfterTextValue && (a = `${a}${l.priceAfterTextValue}`)), b === p.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (a = `${l.discountBeforeTextValue}${a}`), l.discountAfterTextValue && (a = `${a}${l.discountAfterTextValue}`));
88
88
  }
89
- const p = b.substring(2);
90
- let f = "";
91
- o in y.IF && (f = y.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${p}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${p}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${p}${A.OMNIBUS_PRICE}`));
92
- const g = `${d}${t}${C.PARAGRAPH_END_TAG}`, $ = `${f}${r ? g : s}${y.ELSE}${d}${C.PARAGRAPH_END_TAG}${y.END_IF}`;
93
- e = e.replace(s, $);
89
+ const _ = A.substring(2);
90
+ let y = "";
91
+ b in T.IF && (y = T.IF[b].replaceAll(`{${p.DISCOUNT}}`, `${_}${p.DISCOUNT}`).replaceAll(`{${p.OMNIBUS_DISCOUNT}}`, `${_}${p.OMNIBUS_DISCOUNT}`).replaceAll(`{${p.OMNIBUS_PRICE}}`, `${_}${p.OMNIBUS_PRICE}`));
92
+ const C = `${R}${a}${g.PARAGRAPH_END_TAG}`, h = `${y}${S ? C : i}${T.ELSE}${R}${g.PARAGRAPH_END_TAG}${T.END_IF}`;
93
+ e = e.replace(i, h);
94
94
  }), e;
95
95
  },
96
96
  priority: 53
@@ -110,11 +110,11 @@ const w = [
110
110
  type: "custom",
111
111
  // Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
112
112
  // from Items block elements, which the items compiler rule depends on.
113
- processor: (c) => {
114
- const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|data-same-price|product-attr|composition)="[^"]*"/g;
115
- return c.replace(
113
+ processor: (o) => {
114
+ const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
115
+ return o.replace(
116
116
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
117
- (l, n) => `<!--REC_START-->${n.replace(e, "")}<!--REC_END-->`
117
+ (r, t) => `<!--REC_START-->${t.replace(e, "")}<!--REC_END-->`
118
118
  );
119
119
  },
120
120
  priority: 55
@@ -123,8 +123,8 @@ const w = [
123
123
  id: "strip-unused-recommendation-classes",
124
124
  description: "Remove CSS classes not referenced by any style rule from recommendation elements",
125
125
  type: "custom",
126
- processor: (c) => {
127
- let e = c.replace(
126
+ processor: (o) => {
127
+ let e = o.replace(
128
128
  / 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,
129
129
  ""
130
130
  );
@@ -136,8 +136,8 @@ const w = [
136
136
  id: "remove-empty-mobile-layout-artifacts",
137
137
  description: "Remove empty mobile container rows and unused mobile layout CSS",
138
138
  type: "custom",
139
- processor: (c) => {
140
- let e = c;
139
+ processor: (o) => {
140
+ let e = o;
141
141
  return e = e.replace(
142
142
  /<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
143
143
  ""
@@ -146,75 +146,50 @@ const w = [
146
146
  ""
147
147
  ), e = e.replace(
148
148
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
149
- (l, n) => {
150
- const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
151
- return s.every((u) => a.test(u)) ? "" : l;
149
+ (r, t) => {
150
+ const i = t.match(/[^{}]+\{[^{}]*\}/g) || [], s = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
151
+ return i.every((m) => s.test(m)) ? "" : r;
152
152
  }
153
153
  )), e;
154
154
  },
155
155
  priority: 57
156
156
  },
157
157
  {
158
- id: "deduplicate-inline-styles",
159
- description: "Replace repeated inline styles with CSS class references within recommendation blocks",
158
+ id: "protect-gmail-button-link-color",
159
+ // Gmail overrides link colors with `.ii a[href] { color: #15c }`. Force
160
+ // `!important` on es-button anchor colors so the intended button text color
161
+ // wins. Kept INLINE (never moved into a <style> class) so it survives Gmail's
162
+ // clipping — "view entire message" strips <style> blocks but keeps inline styles.
163
+ // (SD-142395: split out of the removed deduplicate-inline-styles rule.)
164
+ description: "Force !important on es-button link color to defeat Gmail link-color override",
160
165
  type: "custom",
161
- processor: (c) => {
162
- const e = c.replace(
163
- /<a\b[^>]*\bes-button\b[^>]*>/g,
164
- (o) => o.replace(
165
- /([;"]color:)([^;"]+)/g,
166
- (r, t, p) => p.includes("!important") ? r : `${t}${p} !important`
167
- )
168
- ), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
169
- let a = l.exec(e);
170
- for (; a !== null; ) {
171
- let o = n.exec(a[1]);
172
- for (; o !== null; ) {
173
- const [, r] = o;
174
- s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
175
- }
176
- n.lastIndex = 0, a = l.exec(e);
177
- }
178
- const i = /* @__PURE__ */ new Map(), u = [];
179
- let _ = 0;
180
- if (s.forEach((o, r) => {
181
- if (!r.includes("v-text-anchor") && o >= 6) {
182
- const t = `rc${_++}`, p = r.endsWith(";") ? r : `${r};`;
183
- i.set(r, t), u.push(`.${t}{${p}}`);
184
- }
185
- }), i.size === 0) {
186
- let o = e;
187
- return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
188
- }
189
- const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = (o, r) => `${o.slice(0, -1)} ${r}"`, I = /* @__PURE__ */ new Map();
190
- i.forEach((o, r) => {
191
- const t = R(r);
192
- I.set(r, {
193
- caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
194
- caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
195
- });
196
- });
197
- let d = e.replace("</style>", `${u.join("")}</style>`);
198
- return d = d.replace(
199
- /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
200
- (o, r) => {
201
- let t = r;
202
- return i.forEach((p, f) => {
203
- const g = I.get(f);
204
- t = t.replace(
205
- g.caseA,
206
- ($, S, m) => b(S, p) + m
207
- ), t = t.replace(
208
- g.caseB,
209
- ($, S, m) => S + b(m, p)
210
- ), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
211
- }), t;
212
- }
213
- ), d = d.replaceAll("<!--REC_START-->", ""), d = d.replaceAll("<!--REC_END-->", ""), d;
214
- },
166
+ processor: (o) => o.replace(
167
+ /<a\b[^>]*\bes-button\b[^>]*>/g,
168
+ (e) => e.replace(
169
+ /([;"]color:)([^;"]+)/g,
170
+ (r, t, i) => i.includes("!important") ? r : `${t}${i} !important`
171
+ )
172
+ ),
215
173
  priority: 58
174
+ },
175
+ {
176
+ id: "minify-recommendation-whitespace",
177
+ // SD-142395: shrink the compiled recommendation block to keep emails under
178
+ // Gmail's ~102KB clip threshold. The editor templates emit deeply-indented
179
+ // markup that the P48 DOMParser round-trip preserves, and nothing else in the
180
+ // pipeline minifies it. Scoped to REC_START/REC_END so it only touches
181
+ // recommendation markup, and strips those markers last (relocated here from the
182
+ // removed deduplicate-inline-styles rule). Render-critical styles are left inline
183
+ // rather than classed, so they survive Gmail clipping.
184
+ description: "Collapse whitespace inside recommendation blocks and strip boundary markers",
185
+ type: "custom",
186
+ processor: (o) => {
187
+ const e = (r) => r.replace(/>\s+</g, "><").replace(/<[^>]+>/g, (t) => t.replace(/\s+/g, " "));
188
+ return o.replace(/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, (r, t) => e(t)).replaceAll("<!--REC_START-->", "").replaceAll("<!--REC_END-->", "");
189
+ },
190
+ priority: 99
216
191
  }
217
192
  ];
218
193
  export {
219
- w as recommendationCompilerRules
194
+ U as recommendationCompilerRules
220
195
  };
@@ -3,179 +3,171 @@ import { useRecommendation as g } from "../../../composables/useRecommendation.j
3
3
  import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
5
  import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
- function b(e, n, t, o, c = "") {
7
- const i = `{{${c}${e}_${n}_${t}}}`, r = `{{${c}${e}_${n}_currency}}`;
8
- return o === "before" ? `${r} ${i}` : `${i} ${r}`;
6
+ function h(r, n, e, o, c = "") {
7
+ const i = `{{${c}${r}_${n}_${e}}}`, t = `{{${c}${r}_${n}_currency}}`;
8
+ return o === "before" ? `${t} ${i}` : `${i} ${t}`;
9
9
  }
10
- function m(e) {
11
- let n = e;
10
+ function f(r) {
11
+ let n = r;
12
12
  for (; n.children.length === 1; )
13
13
  [n] = n.children;
14
14
  return n;
15
15
  }
16
- function h(e, n, t, o, c, i) {
16
+ function A(r, n, e, o, c, i) {
17
17
  switch (n) {
18
18
  case "productImage": {
19
- const r = e.querySelector("img");
20
- r && (r.setAttribute("src", `{{${i}${t}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${o}_name}}`));
21
- const s = e.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${t}_${o}_url}}`), s.classList.add(q));
19
+ const t = r.querySelector("img");
20
+ t && (t.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
+ const s = r.querySelector("a");
22
+ s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const r = e.querySelector("p");
27
- r && (m(r).textContent = `{{${i}${t}_${o}_name}}`);
26
+ const t = r.querySelector("p");
27
+ t && (f(t).textContent = `{{${i}${e}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  case "productPrice": {
31
- const r = e.querySelector(".product-price p") ?? e.querySelector("p");
32
- r && (m(r).textContent = b(
33
- t,
31
+ const t = r.querySelector("p");
32
+ t && (f(t).textContent = h(
33
+ e,
34
34
  o,
35
35
  "price",
36
36
  c,
37
37
  i
38
38
  ));
39
- const s = e.querySelector(".product-old-price p");
40
- s && (m(s).textContent = b(
41
- t,
42
- o,
43
- "original_price",
44
- c,
45
- i
46
- ));
47
39
  break;
48
40
  }
49
41
  case "productOldPrice": {
50
- const r = e.querySelector("p");
51
- r && (m(r).textContent = b(
52
- t,
42
+ const t = r.querySelector("p");
43
+ t && (f(t).textContent = h(
44
+ e,
53
45
  o,
54
46
  "original_price",
55
47
  c,
56
48
  i
57
- ));
49
+ ), t.setAttribute("product-attr", "discount"));
58
50
  break;
59
51
  }
60
52
  case "productButton": {
61
- const r = e.querySelector("a");
62
- r && r.setAttribute("href", `{{${i}${t}_${o}_url}}`);
53
+ const t = r.querySelector("a");
54
+ t && t.setAttribute("href", `{{${i}${e}_${o}_url}}`);
63
55
  break;
64
56
  }
65
57
  case "productOmnibusPrice": {
66
- const r = e.querySelector(".omnibus-price-value");
67
- if (r) {
68
- r.textContent = `{{${i}${t}_${o}_omnibus_price}}`;
69
- const s = r.closest("p");
58
+ const t = r.querySelector(".omnibus-price-value");
59
+ if (t) {
60
+ t.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
61
+ const s = t.closest("p");
70
62
  s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
71
63
  }
72
64
  break;
73
65
  }
74
66
  case "productOmnibusDiscount": {
75
- const r = e.querySelector(".omnibus-discount-value");
76
- if (r) {
77
- r.textContent = `{{${i}${t}_${o}_omnibus_discount}}`;
78
- const s = r.closest("p");
67
+ const t = r.querySelector(".omnibus-discount-value");
68
+ if (t) {
69
+ t.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
70
+ const s = t.closest("p");
79
71
  s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
80
72
  }
81
73
  break;
82
74
  }
83
75
  default: {
84
- const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
85
- if (r) {
86
- const s = r.getAttribute("product-attr"), a = r.querySelector("p");
87
- a && (m(a).textContent = `{{${i}${t}_${o}_${s}}}`);
76
+ const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
77
+ if (t) {
78
+ const s = t.getAttribute("product-attr"), a = t.querySelector("p");
79
+ a && (f(a).textContent = `{{${i}${e}_${o}_${s}}}`);
88
80
  }
89
81
  break;
90
82
  }
91
83
  }
92
84
  }
93
- function E(e, n, t, o) {
94
- e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
85
+ function E(r, n, e, o) {
86
+ r.querySelectorAll(".recommendation-product-row").forEach((i, t) => {
95
87
  i.querySelectorAll("[data-attribute-type]").forEach((a) => {
96
88
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
97
89
  p.length > 0 ? p.forEach((l) => {
98
- h(l, u, n, r, t, o);
99
- }) : h(a, u, n, r, t, o);
90
+ A(l, u, n, t, e, o);
91
+ }) : A(a, u, n, t, e, o);
100
92
  });
101
93
  });
102
94
  }
103
- function P(e, n, t, o) {
104
- const c = e.querySelectorAll(".recommendation-product-row");
95
+ function R(r, n, e, o) {
96
+ const c = r.querySelectorAll(".recommendation-product-row");
105
97
  if (!c.length)
106
98
  return;
107
- const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
99
+ const [i] = c, t = i.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
108
100
  c.forEach((a, u) => {
109
101
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
110
- const d = l.getAttribute("data-attribute-type") || "";
111
- l.querySelectorAll(".attribute-cell").forEach((A, $) => {
102
+ const m = l.getAttribute("data-attribute-type") || "";
103
+ l.querySelectorAll(".attribute-cell").forEach((y, $) => {
112
104
  const S = u * s + $;
113
- h(A, d, n, S, t, o);
105
+ A(y, m, n, S, e, o);
114
106
  });
115
107
  });
116
108
  });
117
109
  }
118
- function R(e, n, t, o) {
119
- e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
- P(i, n, t, o);
110
+ function P(r, n, e, o) {
111
+ r.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
112
+ R(i, n, e, o);
121
113
  });
122
114
  }
123
- function O(e, n, t) {
124
- const o = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
125
- o === "list" ? E(e, n, c, t) : R(e, n, c, t);
115
+ function T(r, n, e) {
116
+ const o = r.getAttribute("data-layout") || "grid", c = r.getAttribute("currency-alignment") || "after";
117
+ o === "list" ? E(r, n, c, e) : P(r, n, c, e);
126
118
  }
127
- function y(e, n, t) {
128
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(o);
129
- return c ? parseInt(c[1]) : t;
119
+ function b(r, n, e) {
120
+ const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = r.match(o);
121
+ return c ? parseInt(c[1]) : e;
130
122
  }
131
- function T(e, n) {
132
- let t = e.parentElement;
133
- for (; t && t !== n; ) {
134
- if (t.tagName === "TD") {
135
- const o = t.getAttribute("width");
123
+ function v(r, n) {
124
+ let e = r.parentElement;
125
+ for (; e && e !== n; ) {
126
+ if (e.tagName === "TD") {
127
+ const o = e.getAttribute("width");
136
128
  if (o && o.endsWith("%") && parseFloat(o) < 100)
137
- return t;
129
+ return e;
138
130
  }
139
- t = t.parentElement;
131
+ e = e.parentElement;
140
132
  }
141
133
  return null;
142
134
  }
143
- function v(e) {
144
- const n = e.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, c = Math.max(0, t - o);
145
- c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
135
+ function O(r) {
136
+ const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, c = Math.max(0, e - o);
137
+ c !== 0 && r.querySelectorAll("img.adapt-img").forEach((i) => {
146
138
  if (i.hasAttribute("width"))
147
139
  return;
148
- const r = T(i, e);
149
- if (!r)
140
+ const t = v(i, r);
141
+ if (!t)
150
142
  return;
151
- const s = r.getAttribute("width"), a = parseFloat(s), u = y(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
143
+ const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
152
144
  i.setAttribute("width", String(l));
153
- const d = i.getAttribute("style") || "";
154
- if (!/\bwidth\s*:\s*\d/i.test(d)) {
155
- const f = d && !d.trim().endsWith(";") ? "; " : "";
156
- i.setAttribute("style", `${d}${f}width: ${l}px`);
145
+ const m = i.getAttribute("style") || "";
146
+ if (!/\bwidth\s*:\s*\d/i.test(m)) {
147
+ const d = m && !m.trim().endsWith(";") ? "; " : "";
148
+ i.setAttribute("style", `${m}${d}width: ${l}px`);
157
149
  }
158
150
  });
159
151
  }
160
- function W(e, n) {
161
- const t = e.match(/<!DOCTYPE[^>]*>/i);
162
- return (t ? `${t[0]}
152
+ function W(r, n) {
153
+ const e = r.match(/<!DOCTYPE[^>]*>/i);
154
+ return (e ? `${e[0]}
163
155
  ` : "") + n.documentElement.outerHTML;
164
156
  }
165
- function F(e) {
166
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
157
+ function F(r) {
158
+ const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
167
159
  if (!o.length)
168
- return e;
160
+ return r;
169
161
  const { buildCampaignUrl: c } = g(), i = C();
170
162
  i.recommendationCampaignUrls = {};
171
- const { isFeatureEnabled: r } = _(), s = r("liquidSyntax") ? "reco_" : "";
163
+ const { isFeatureEnabled: t } = _(), s = t("liquidSyntax") ? "reco_" : "";
172
164
  return o.forEach((u) => {
173
- var l, d;
165
+ var l, m;
174
166
  const p = u.getAttribute("recommendation-id");
175
- p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || O(u, p, s), v(u));
176
- }), W(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
167
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), c(p), w(u) || T(u, p, s), O(u));
168
+ }), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
177
169
  }
178
170
  export {
179
- b as formatPriceVariable,
171
+ h as formatPriceVariable,
180
172
  F as prepareRecommendationBlocks
181
173
  };