@useinsider/guido 3.23.0-beta.86bed27 → 3.23.0-beta.95af882

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 (118) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +41 -39
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +6 -6
  5. package/dist/components/Guido.vue2.js +89 -83
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +75 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +54 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  14. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +11 -11
  15. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +9 -9
  16. package/dist/composables/useBlocksConfig.js +31 -20
  17. package/dist/composables/useDisplayConditions.js +116 -0
  18. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  19. package/dist/config/compiler/utils/recommendationCompilerUtils.js +78 -75
  20. package/dist/config/migrator/recommendation/compositionMapper.js +56 -49
  21. package/dist/config/migrator/recommendation/extractors.js +100 -40
  22. package/dist/config/migrator/recommendation/htmlBuilder.js +285 -207
  23. package/dist/config/migrator/recommendation/settingsMapper.js +37 -36
  24. package/dist/config/migrator/recommendation/themeMapper.js +53 -41
  25. package/dist/config/migrator/recommendationMigrator.js +68 -61
  26. package/dist/enums/academy.js +1 -0
  27. package/dist/enums/display-condition.js +12 -0
  28. package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
  29. package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
  30. package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
  31. package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
  32. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  33. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
  34. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
  35. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
  36. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
  37. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
  38. package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
  39. package/dist/extensions/Blocks/Recommendation/block.js +33 -24
  40. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
  41. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +27 -26
  42. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
  43. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +165 -175
  44. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
  46. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
  47. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
  48. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
  49. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
  50. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +23 -22
  51. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +19 -18
  52. package/dist/extensions/Blocks/Recommendation/templates/utils.js +82 -91
  53. package/dist/extensions/Blocks/Recommendation/utils/inlinePriceOrder.js +12 -0
  54. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +3 -2
  55. package/dist/extensions/Blocks/common-control.js +62 -55
  56. package/dist/extensions/DisplayConditions/bridge.js +23 -0
  57. package/dist/extensions/DisplayConditions/constants.js +17 -0
  58. package/dist/extensions/DisplayConditions/control.js +189 -0
  59. package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
  60. package/dist/extensions/DisplayConditions/extension.js +28 -0
  61. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  62. package/dist/extensions/DisplayConditions/library.js +28 -0
  63. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  64. package/dist/extensions/LinkTracking/extension.js +17 -0
  65. package/dist/extensions/LinkTracking/writer.js +35 -0
  66. package/dist/guido.css +1 -1
  67. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  68. package/dist/node_modules/valibot/dist/index.js +297 -261
  69. package/dist/package.json.js +2 -2
  70. package/dist/services/displayConditionApi.js +39 -0
  71. package/dist/src/@types/config/schemas.d.ts +4 -0
  72. package/dist/src/@types/display-condition.d.ts +59 -0
  73. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  74. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  75. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  76. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  77. package/dist/src/composables/useConfig.d.ts +2 -0
  78. package/dist/src/composables/useDisplayConditions.d.ts +17 -0
  79. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +3 -1
  80. package/dist/src/config/migrator/recommendation/extractors.d.ts +35 -6
  81. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +3 -1
  82. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +3 -1
  83. package/dist/src/config/migrator/recommendation/types.d.ts +11 -1
  84. package/dist/src/enums/academy.d.ts +1 -0
  85. package/dist/src/enums/display-condition.d.ts +15 -0
  86. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
  87. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  88. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -10
  89. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -13
  90. package/dist/src/extensions/Blocks/Recommendation/utils/inlinePriceOrder.d.ts +9 -0
  91. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -19
  92. package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
  93. package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
  94. package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
  95. package/dist/src/extensions/DisplayConditions/control.d.ts +24 -0
  96. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  97. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  98. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  99. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  100. package/dist/src/extensions/LinkTracking/extension.d.ts +2 -0
  101. package/dist/src/extensions/LinkTracking/writer.d.ts +13 -0
  102. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  103. package/dist/src/services/displayConditionApi.d.ts +8 -0
  104. package/dist/src/stores/config.d.ts +166 -0
  105. package/dist/src/stores/display-condition.d.ts +84 -0
  106. package/dist/src/stores/unsubscribe.d.ts +10 -0
  107. package/dist/src/utils/displayCondition.d.ts +11 -0
  108. package/dist/src/utils/linkTrackingIds.d.ts +20 -5
  109. package/dist/src/utils/protectTableText.d.ts +2 -0
  110. package/dist/stores/config.js +13 -6
  111. package/dist/stores/display-condition.js +29 -0
  112. package/dist/stores/unsubscribe.js +33 -29
  113. package/dist/utils/displayCondition.js +26 -0
  114. package/dist/utils/linkTrackingIds.js +80 -47
  115. package/dist/utils/pairProductVariables.js +30 -29
  116. package/dist/utils/protectTableText.js +22 -0
  117. package/dist/utils/templatePreparation.js +55 -51
  118. package/package.json +2 -2
@@ -1,75 +1,76 @@
1
- import { PRODUCT_WRAPPER_SELECTOR as h, hasZeroWidthDeclaration as E, isZeroWidthValue as f, withWidthPin as T, PRODUCT_TD_SELECTOR as _, withoutZeroWidth as y } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
2
- import { DefaultConfigValues as D } from "../../../extensions/Blocks/Items/enums/settingsEnums.js";
3
- import { protectLiquid as p, restoreLiquid as A } from "../../../utils/liquidProtection.js";
4
- const m = "MSO_ITEMS_HIDE_START", S = "MSO_ITEMS_HIDE_END", M = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", I = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price", O = ".ins-product-td td.product-image-class img[width]", g = Number(D.productImageWidth);
5
- function C(t) {
1
+ import { PRODUCT_WRAPPER_SELECTOR as _, hasZeroWidthDeclaration as p, isZeroWidthValue as f, withWidthPin as y, PRODUCT_TD_SELECTOR as D, withoutZeroWidth as S } from "../../../extensions/Blocks/Items/constants/cardWidth.js";
2
+ import { DefaultConfigValues as M } from "../../../extensions/Blocks/Items/enums/settingsEnums.js";
3
+ import { protectLiquid as h, restoreLiquid as T } from "../../../utils/liquidProtection.js";
4
+ import { protectTableText as E, restoreTableText as m } from "../../../utils/protectTableText.js";
5
+ const A = "MSO_ITEMS_HIDE_START", b = "MSO_ITEMS_HIDE_END", I = "mso-hide:all; max-height:0; overflow:hidden; font-size:0; line-height:0;", O = ".ins-product-cart td.horizontal-price, .ins-product-cart td.vertical-price", g = ".ins-product-td td.product-image-class img[width]", H = Number(M.productImageWidth);
6
+ function P(t) {
6
7
  if (!t.includes("vertical-price") || !t.includes("ins-product-cart"))
7
8
  return t;
8
- const s = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
9
+ const s = E(t).replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), o = new DOMParser().parseFromString(s, "text/html");
9
10
  let n = !1;
10
- if (o.querySelectorAll(I).forEach((e) => {
11
+ if (o.querySelectorAll(O).forEach((e) => {
11
12
  var d, u;
12
- const r = e.getAttribute("style") || "";
13
- if (!/display\s*:\s*none/i.test(r))
13
+ const i = e.getAttribute("style") || "";
14
+ if (!/display\s*:\s*none/i.test(i))
14
15
  return;
15
16
  const l = e.previousSibling;
16
- if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== m) && ((d = e.parentNode) == null || d.insertBefore(o.createComment(m), e), (u = e.parentNode) == null || u.insertBefore(o.createComment(S), e.nextSibling)), !/mso-hide/i.test(r)) {
17
- const a = r.trim().endsWith(";") ? " " : "; ";
18
- e.setAttribute("style", `${r}${a}${M}`);
17
+ if (((l == null ? void 0 : l.nodeType) !== Node.COMMENT_NODE || l.data !== A) && ((d = e.parentNode) == null || d.insertBefore(o.createComment(A), e), (u = e.parentNode) == null || u.insertBefore(o.createComment(b), e.nextSibling)), !/mso-hide/i.test(i)) {
18
+ const a = i.trim().endsWith(";") ? " " : "; ";
19
+ e.setAttribute("style", `${i}${a}${I}`);
19
20
  }
20
21
  n = !0;
21
22
  }), !n)
22
23
  return t;
23
- const c = s.match(/<!DOCTYPE[^>]*>/i);
24
- return ((c ? `${c[0]}
25
- ` : "") + o.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
24
+ const c = s.match(/<!DOCTYPE[^>]*>/i), r = c ? `${c[0]}
25
+ ` : "";
26
+ return m((r + o.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
26
27
  }
27
- function N(t) {
28
+ function R(t) {
28
29
  if (!t.includes("ins-product-wrapper") && !t.includes("ins-product-td"))
29
30
  return t;
30
- const s = new DOMParser().parseFromString(p(t), "text/html");
31
+ const s = new DOMParser().parseFromString(h(E(t)), "text/html");
31
32
  let o = !1;
32
- if (s.querySelectorAll(h).forEach((i) => {
33
- const e = i.getAttribute("style") || "";
34
- if (!E(e) && !f(i.getAttribute("width")))
33
+ if (s.querySelectorAll(_).forEach((r) => {
34
+ const e = r.getAttribute("style") || "";
35
+ if (!p(e) && !f(r.getAttribute("width")))
35
36
  return;
36
- const r = T(e);
37
- r !== e && (i.setAttribute("style", r), o = !0), f(i.getAttribute("width")) && (i.setAttribute("width", "100%"), o = !0);
38
- }), s.querySelectorAll(_).forEach((i) => {
39
- const e = i.getAttribute("style") || "";
40
- if (E(e)) {
41
- const r = y(e);
42
- r ? i.setAttribute("style", r) : i.removeAttribute("style"), o = !0;
37
+ const i = y(e);
38
+ i !== e && (r.setAttribute("style", i), o = !0), f(r.getAttribute("width")) && (r.setAttribute("width", "100%"), o = !0);
39
+ }), s.querySelectorAll(D).forEach((r) => {
40
+ const e = r.getAttribute("style") || "";
41
+ if (p(e)) {
42
+ const i = S(e);
43
+ i ? r.setAttribute("style", i) : r.removeAttribute("style"), o = !0;
43
44
  }
44
- f(i.getAttribute("width")) && (i.removeAttribute("width"), o = !0);
45
+ f(r.getAttribute("width")) && (r.removeAttribute("width"), o = !0);
45
46
  }), !o)
46
47
  return t;
47
48
  const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
48
49
  ` : "";
49
- return A(c + s.documentElement.outerHTML);
50
+ return m(T(c + s.documentElement.outerHTML));
50
51
  }
51
- function L(t) {
52
+ function x(t) {
52
53
  if (!t.includes("product-image-class"))
53
54
  return t;
54
- const s = new DOMParser().parseFromString(p(t), "text/html");
55
+ const s = new DOMParser().parseFromString(h(E(t)), "text/html");
55
56
  let o = !1;
56
- if (s.querySelectorAll(O).forEach((i) => {
57
+ if (s.querySelectorAll(g).forEach((r) => {
57
58
  var u, a;
58
- const e = ((u = i.getAttribute("width")) == null ? void 0 : u.trim()) ?? "", r = ((a = i.getAttribute("style")) == null ? void 0 : a.trim()) ?? "";
59
- if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(r))
59
+ const e = ((u = r.getAttribute("width")) == null ? void 0 : u.trim()) ?? "", i = ((a = r.getAttribute("style")) == null ? void 0 : a.trim()) ?? "";
60
+ if (!/^\d+$/.test(e) || /(^|;)\s*min-width\s*:/i.test(i))
60
61
  return;
61
- const l = r && !r.endsWith(";") ? ";" : "", d = Math.min(Number(e), g);
62
- i.setAttribute("style", `${r}${l}min-width:${d}px;max-width:${e}px`), o = !0;
62
+ const l = i && !i.endsWith(";") ? ";" : "", d = Math.min(Number(e), H);
63
+ r.setAttribute("style", `${i}${l}min-width:${d}px;max-width:${e}px`), o = !0;
63
64
  }), !o)
64
65
  return t;
65
66
  const n = t.match(/<!DOCTYPE[^>]*>/i), c = n ? `${n[0]}
66
67
  ` : "";
67
- return A(c + s.documentElement.outerHTML);
68
+ return m(T(c + s.documentElement.outerHTML));
68
69
  }
69
70
  export {
70
- S as MSO_ITEMS_HIDE_END,
71
- m as MSO_ITEMS_HIDE_START,
72
- L as lockHorizontalItemImageWidths,
73
- N as normalizeItemsBlockWidths,
74
- C as wrapHiddenPriceTdsForOutlook
71
+ b as MSO_ITEMS_HIDE_END,
72
+ A as MSO_ITEMS_HIDE_START,
73
+ x as lockHorizontalItemImageWidths,
74
+ R as normalizeItemsBlockWidths,
75
+ P as wrapHiddenPriceTdsForOutlook
75
76
  };
@@ -1,30 +1,31 @@
1
- import { useConfig as g } from "../../../composables/useConfig.js";
1
+ import { useConfig as C } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as O } from "../../../composables/useRecommendation.js";
3
- import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { isIgnoredRecommendationBlock as T } from "./recommendationIgnoreUtils.js";
6
- function L(t, r, e, o, c = "") {
3
+ import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as T } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as B } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { protectTableText as N, restoreTableText as L } from "../../../utils/protectTableText.js";
6
+ import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
7
+ function R(t, r, e, o, c = "") {
7
8
  const i = `{{${c}${t}_${r}_${e}}}`, n = `{{${c}${t}_${r}_currency}}`;
8
9
  return o === "before" ? `${n} ${i}` : `${i} ${n}`;
9
10
  }
10
- function A(t) {
11
+ function b(t) {
11
12
  let r = t;
12
13
  for (; r.children.length === 1; )
13
14
  [r] = r.children;
14
15
  return r;
15
16
  }
16
- function y(t, r, e, o, c, i) {
17
+ function _(t, r, e, o, c, i) {
17
18
  switch (r) {
18
19
  case "productImage": {
19
20
  const n = t.querySelector("img");
20
21
  n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
22
  const s = t.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(B));
23
+ s && (s.setAttribute("href", `{{${i}${e}_${o}_url}}`), s.classList.add(T));
23
24
  break;
24
25
  }
25
26
  case "productName": {
26
27
  const n = t.querySelector("p");
27
- n && (A(n).textContent = `{{${i}${e}_${o}_name}}`);
28
+ n && (b(n).textContent = `{{${i}${e}_${o}_name}}`);
28
29
  break;
29
30
  }
30
31
  // Inline mode ("Move to next line" OFF) merges BOTH prices into one row
@@ -32,16 +33,16 @@ function y(t, r, e, o, c, i) {
32
33
  // substitute by cell content, not by the row's anchor (SD-145161).
33
34
  case "productPrice":
34
35
  case "productOldPrice": {
35
- const n = (a, l) => {
36
- a && (A(a).textContent = L(
36
+ const n = (l, d) => {
37
+ l && (b(l).textContent = R(
37
38
  e,
38
39
  o,
39
- l,
40
+ d,
40
41
  c,
41
42
  i
42
43
  ));
43
- }, s = t.querySelector(".product-price p"), d = t.querySelector(".product-old-price p"), u = !s && !d ? t.querySelector("p") : null;
44
- n(s ?? (r === "productPrice" ? u : null), "price"), n(d ?? (r === "productOldPrice" ? u : null), "original_price");
44
+ }, s = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !s && !a ? t.querySelector("p") : null;
45
+ n(s ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
45
46
  break;
46
47
  }
47
48
  case "productButton": {
@@ -70,72 +71,72 @@ function y(t, r, e, o, c, i) {
70
71
  default: {
71
72
  const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
73
  if (n) {
73
- const s = n.getAttribute("product-attr"), d = n.querySelector("p");
74
- d && (A(d).textContent = `{{${i}${e}_${o}_${s}}}`);
74
+ const s = n.getAttribute("product-attr"), a = n.querySelector("p");
75
+ a && (b(a).textContent = `{{${i}${e}_${o}_${s}}}`);
75
76
  }
76
77
  break;
77
78
  }
78
79
  }
79
80
  }
80
- const P = "name";
81
- function b(t, r, e, o) {
82
- const c = `${o}${r}_${e}_${P}`;
81
+ const w = "name";
82
+ function y(t, r, e, o) {
83
+ const c = `${o}${r}_${e}_${w}`;
83
84
  return {
84
85
  open: t.createComment(`{% if ${c} and ${c} != "" %}`),
85
86
  close: t.createComment("{% endif %}")
86
87
  };
87
88
  }
88
- function R(t, r, e) {
89
- return b(t, r, 0, e);
89
+ function D(t, r, e) {
90
+ return y(t, r, 0, e);
90
91
  }
91
- function w(t, r, e, o) {
92
+ function v(t, r, e, o) {
92
93
  if (!t.innerHTML.includes("{{"))
93
94
  return;
94
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
95
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
95
96
  t.insertBefore(c, t.firstChild), t.appendChild(i);
96
97
  }
97
- function D(t, r, e, o) {
98
+ function W(t, r, e, o) {
98
99
  var n, s;
99
100
  if (!t.innerHTML.includes("{{"))
100
101
  return;
101
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
102
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
102
103
  (n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
103
104
  }
104
- function v(t, r, e, o) {
105
+ function H(t, r, e, o) {
105
106
  t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
106
- i.querySelectorAll("[data-attribute-type]").forEach((d) => {
107
- const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
108
- a.length > 0 ? a.forEach((l) => {
109
- y(l, u, r, n, e, o);
110
- }) : y(d, u, r, n, e, o);
111
- }), D(i, r, n, o);
107
+ i.querySelectorAll("[data-attribute-type]").forEach((a) => {
108
+ const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
109
+ l.length > 0 ? l.forEach((d) => {
110
+ _(d, u, r, n, e, o);
111
+ }) : _(a, u, r, n, e, o);
112
+ }), W(i, r, n, o);
112
113
  });
113
114
  }
114
- function H(t, r, e, o) {
115
+ function x(t, r, e, o) {
115
116
  const c = t.querySelectorAll(".recommendation-product-row");
116
117
  if (!c.length)
117
118
  return;
118
119
  const [i] = c, n = i.querySelector("[data-attribute-type]"), s = n ? n.querySelectorAll(".attribute-cell").length : 1;
119
- c.forEach((d, u) => {
120
- d.querySelectorAll("[data-attribute-type]").forEach((l) => {
121
- const p = l.getAttribute("data-attribute-type") || "";
122
- l.querySelectorAll(".attribute-cell").forEach((f, h) => {
120
+ c.forEach((a, u) => {
121
+ a.querySelectorAll("[data-attribute-type]").forEach((d) => {
122
+ const p = d.getAttribute("data-attribute-type") || "";
123
+ d.querySelectorAll(".attribute-cell").forEach((m, h) => {
123
124
  const S = u * s + h;
124
- y(f, p, r, S, e, o), w(f, r, S, o);
125
+ _(m, p, r, S, e, o), v(m, r, S, o);
125
126
  });
126
127
  });
127
128
  });
128
129
  }
129
- function W(t, r, e, o) {
130
+ function F(t, r, e, o) {
130
131
  t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
131
- H(i, r, e, o);
132
+ x(i, r, e, o);
132
133
  });
133
134
  }
134
- function F(t, r, e) {
135
- const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
136
- o === "list" ? v(t, r, c, e) : W(t, r, c, e);
135
+ function G(t, r, e) {
136
+ const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
137
+ o === "list" ? H(t, r, i, e) : F(t, r, i, e);
137
138
  }
138
- function _(t, r, e) {
139
+ function A(t, r, e) {
139
140
  const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
140
141
  return c ? parseInt(c[1]) : e;
141
142
  }
@@ -143,78 +144,80 @@ function $(t) {
143
144
  const r = t.trim();
144
145
  return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
145
146
  }
146
- function C(t) {
147
+ function g(t) {
147
148
  const r = t.getAttribute("width");
148
149
  if (r && $(r))
149
150
  return r.trim();
150
151
  const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
151
152
  return e && $(e[1]) ? e[1] : null;
152
153
  }
153
- function x(t, r) {
154
+ function V(t, r) {
154
155
  let e = t.parentElement;
155
156
  for (; e && e !== r; ) {
156
- if (e.tagName === "TD" && C(e))
157
+ if (e.tagName === "TD" && g(e))
157
158
  return e;
158
159
  e = e.parentElement;
159
160
  }
160
161
  return null;
161
162
  }
162
- function G(t) {
163
- const r = t.getAttribute("style") || "", e = _(r, "width", 600), o = _(r, "padding", 0) * 2, c = Math.max(0, e - o);
163
+ function U(t) {
164
+ const r = t.getAttribute("style") || "", e = A(r, "width", 600), o = A(r, "padding", 0) * 2, c = Math.max(0, e - o);
164
165
  c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
165
166
  if (i.hasAttribute("width"))
166
167
  return;
167
- const n = x(i, t);
168
+ const n = V(i, t);
168
169
  if (!n)
169
170
  return;
170
- const s = C(n), d = _(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
171
+ const s = g(n), a = A(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), l = Math.max(1, u - a), d = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(d);
171
172
  if (p) {
172
- i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
173
+ i.setAttribute("width", String(Math.max(1, Math.min(l, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
173
174
  return;
174
175
  }
175
- if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
176
- const m = l && !l.trim().endsWith(";") ? "; " : "";
177
- i.setAttribute("style", `${l}${m}width: ${a}px`);
176
+ if (i.setAttribute("width", String(l)), !/\bwidth\s*:\s*\d/i.test(d)) {
177
+ const f = d && !d.trim().endsWith(";") ? "; " : "";
178
+ i.setAttribute("style", `${d}${f}width: ${l}px`);
178
179
  }
179
180
  });
180
181
  }
181
- const E = "MSO_MOBILE_HIDE_START", V = "MSO_MOBILE_HIDE_END";
182
- function U(t, r) {
182
+ const E = "MSO_MOBILE_HIDE_START", X = "MSO_MOBILE_HIDE_END";
183
+ function j(t, r) {
183
184
  t.querySelectorAll(q).forEach((e) => {
184
185
  var i, n;
185
186
  const o = e.querySelector(M);
186
187
  if (!o || o.children.length === 0)
187
188
  return;
188
189
  const c = e.previousSibling;
189
- (c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(V), e.nextSibling));
190
+ (c == null ? void 0 : c.nodeType) === Node.COMMENT_NODE && c.data === E || ((i = e.parentNode) == null || i.insertBefore(r.createComment(E), e), (n = e.parentNode) == null || n.insertBefore(r.createComment(X), e.nextSibling));
190
191
  });
191
192
  }
192
- function X(t, r) {
193
+ function Y(t, r) {
193
194
  const e = t.match(/<!DOCTYPE[^>]*>/i);
194
195
  return (e ? `${e[0]}
195
196
  ` : "") + r.documentElement.outerHTML;
196
197
  }
197
- function Q(t) {
198
- const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
198
+ function I(t) {
199
+ const r = N(t).replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
199
200
  if (!o.length)
200
201
  return t;
201
- const { buildCampaignUrl: c } = O(), i = N();
202
+ const { buildCampaignUrl: c } = O(), i = B();
202
203
  i.recommendationCampaignUrls = {};
203
- const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
204
- return o.forEach((u) => {
205
- var l, p, m, f;
206
- const a = u.getAttribute("recommendation-id");
207
- if (a) {
208
- if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
209
- F(u, a, s);
210
- const { open: h, close: S } = R(e, a, s);
211
- (m = u.parentNode) == null || m.insertBefore(h, u), (f = u.parentNode) == null || f.insertBefore(S, u.nextSibling);
204
+ const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
205
+ o.forEach((u) => {
206
+ var d, p, f, m;
207
+ const l = u.getAttribute("recommendation-id");
208
+ if (l) {
209
+ if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(l), j(u, e), !P(u)) {
210
+ G(u, l, s);
211
+ const { open: h, close: S } = D(e, l, s);
212
+ (f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
212
213
  }
213
- G(u);
214
+ U(u);
214
215
  }
215
- }), X(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
216
+ });
217
+ const a = Y(r, e);
218
+ return L(a.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
216
219
  }
217
220
  export {
218
- L as formatPriceVariable,
219
- Q as prepareRecommendationBlocks
221
+ R as formatPriceVariable,
222
+ I as prepareRecommendationBlocks
220
223
  };
@@ -1,101 +1,108 @@
1
- import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
- import { ATTR_RECOMMENDATION_TITLE as l, ATTR_CUSTOM_PREFIX as k, ATTR_PRODUCT_BUTTON as A, ATTR_PRODUCT_OMNIBUS_DISCOUNT as R, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as h, ATTR_PRODUCT_NAME as E, ATTR_PRODUCT_IMAGE as O } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
- import { mapTextTheme as b, mapButtonTheme as y, mapImageTheme as N } from "./themeMapper.js";
4
- const C = "__title__", T = "product_attribute.";
5
- function P(r) {
6
- const t = r.variable ?? "";
7
- switch (t) {
1
+ import { DEFAULT_COMPOSITION as k, DEFAULT_VISIBILITY as f } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { ATTR_RECOMMENDATION_TITLE as R, ATTR_CUSTOM_PREFIX as x, ATTR_PRODUCT_BUTTON as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as O, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as d, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_IMAGE as b } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
+ import { mapTextTheme as C, mapButtonTheme as N, mapImageTheme as P } from "./themeMapper.js";
4
+ const U = "__title__", _ = "product_attribute.";
5
+ function D(n) {
6
+ const s = n.variable ?? "";
7
+ switch (s) {
8
8
  case "p_recommendation_title":
9
- return { key: C, kind: "title" };
9
+ return { key: U, kind: "title" };
10
10
  case "p_image":
11
- return { key: O, kind: "image" };
11
+ return { key: b, kind: "image" };
12
12
  case "p_name":
13
- return { key: E, kind: "text" };
13
+ return { key: y, kind: "text" };
14
14
  case "p_price":
15
- return { key: h, kind: "text" };
15
+ return { key: d, kind: "text" };
16
16
  case "p_original_price":
17
- return { key: f, kind: "text" };
17
+ return { key: a, kind: "text" };
18
18
  case "p_omnibus_price":
19
- return { key: x, kind: "text" };
19
+ return { key: O, kind: "text" };
20
20
  case "p_omnibus_discount":
21
- return { key: R, kind: "text" };
21
+ return { key: h, kind: "text" };
22
22
  case "p_button":
23
- return { key: A, kind: "button" };
23
+ return { key: E, kind: "button" };
24
24
  default:
25
- if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const o = r.value ?? "", s = o.startsWith(T) ? o.slice(T.length) : o;
27
- if (!s)
25
+ if (n.variableType === "p_attribute" || s.startsWith("p_attribute_")) {
26
+ const t = n.value ?? "", o = t.startsWith(_) ? t.slice(_.length) : t;
27
+ if (!o)
28
28
  return null;
29
- const e = o || `${T}${s}`;
29
+ const u = t || `${_}${o}`;
30
30
  return {
31
- key: `${k}${e}`,
31
+ key: `${x}${u}`,
32
32
  kind: "custom",
33
- customAttrName: s,
34
- customAttrValue: e
33
+ customAttrName: o,
34
+ customAttrValue: u
35
35
  };
36
36
  }
37
37
  return null;
38
38
  }
39
39
  }
40
- function _(r) {
41
- const t = p.indexOf(r);
42
- return t === -1 ? Number.POSITIVE_INFINITY : t;
40
+ function I(n) {
41
+ const s = k.indexOf(n);
42
+ return s === -1 ? Number.POSITIVE_INFINITY : s;
43
+ }
44
+ const l = [d, a];
45
+ function S(n, s, t) {
46
+ return n === s || !l.includes(n) || !l.includes(s) ? 0 : n === (t ? a : d) ? -1 : 1;
43
47
  }
44
- function V(r) {
48
+ function F(n, { oldPriceFirst: s = !1 } = {}) {
45
49
  const t = {
46
50
  composition: [],
47
- visibility: { ...I },
51
+ visibility: { ...f },
48
52
  customAttributes: [],
49
53
  customAttrValues: {},
50
54
  perElementStyles: {},
51
55
  anyTextTrimming: !1
52
56
  };
53
- if (!r || r.length === 0)
54
- return t.composition = [...p], t;
57
+ if (!n || n.length === 0)
58
+ return t.composition = [...k], t;
55
59
  const o = [];
56
- r.forEach((e, i) => {
57
- const n = P(e);
58
- if (n) {
59
- if (n.kind === "title") {
60
- t.titleVariable = e, t.visibility[l] = e.hidden !== !0;
60
+ n.forEach((e, i) => {
61
+ const r = D(e);
62
+ if (r) {
63
+ if (r.kind === "title") {
64
+ t.titleVariable = e, t.visibility[R] = e.hidden !== !0;
61
65
  return;
62
66
  }
63
67
  o.push({
64
- key: n.key,
65
- kind: n.kind,
68
+ key: r.key,
69
+ kind: r.kind,
66
70
  hidden: e.hidden === !0,
67
71
  positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
68
72
  legacy: e,
69
- customAttrName: n.customAttrName,
70
- customAttrValue: n.customAttrValue,
73
+ customAttrName: r.customAttrName,
74
+ customAttrValue: r.customAttrValue,
71
75
  originalIndex: i
72
76
  });
73
77
  }
74
78
  }), o.sort((e, i) => {
75
79
  if (e.positionIdx !== i.positionIdx)
76
80
  return e.positionIdx - i.positionIdx;
77
- const n = _(e.key), u = _(i.key);
78
- return n !== u ? n - u : e.originalIndex - i.originalIndex;
81
+ const r = S(e.key, i.key, s);
82
+ if (r !== 0)
83
+ return r;
84
+ const m = I(e.key), c = I(i.key);
85
+ return m !== c ? m - c : e.originalIndex - i.originalIndex;
79
86
  });
80
- const s = {};
87
+ const u = {};
81
88
  return o.forEach((e) => {
82
- const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
- switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
89
+ const { key: i, kind: r, hidden: m, legacy: c, customAttrName: A, customAttrValue: T } = e;
90
+ switch (t.composition.push(i), t.visibility[i] = !m, r === "custom" && A && T && (t.customAttributes.includes(T) || t.customAttributes.push(T), t.customAttrValues[i] = T), r) {
84
91
  case "image":
85
- s[i] = N(c.theme);
92
+ u[i] = P(c.theme);
86
93
  break;
87
94
  case "button":
88
- s[i] = y(c.theme);
95
+ u[i] = N(c.theme);
89
96
  break;
90
97
  case "text":
91
98
  case "custom": {
92
- const a = b(c.theme);
93
- s[i] = a, a.textTrimming && (t.anyTextTrimming = !0);
99
+ const p = C(c.theme);
100
+ u[i] = p, p.textTrimming && (t.anyTextTrimming = !0);
94
101
  break;
95
102
  }
96
103
  }
97
- }), t.perElementStyles = s, t;
104
+ }), t.perElementStyles = u, t;
98
105
  }
99
106
  export {
100
- V as mapComposition
107
+ F as mapComposition
101
108
  };