@useinsider/guido 3.2.0-beta.78d83bd → 3.2.0-beta.7fb9b70

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 +117 -1
  2. package/dist/@types/config/schemas.js +153 -95
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +90 -88
  5. package/dist/components/organisms/AutoSaveController.vue.js +17 -0
  6. package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
  7. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  8. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  9. package/dist/components/organisms/header/RightSlot.vue.js +8 -8
  10. package/dist/components/organisms/header/RightSlot.vue2.js +9 -8
  11. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  12. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  13. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  14. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  15. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  16. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  17. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  18. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  19. package/dist/composables/useAutoSave.js +71 -0
  20. package/dist/composables/useRecommendation.js +46 -26
  21. package/dist/composables/useRibbonOffset.js +21 -0
  22. package/dist/composables/useSave.js +19 -16
  23. package/dist/composables/useStripo.js +14 -16
  24. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  25. package/dist/config/compiler/recommendationCompilerRules.js +25 -25
  26. package/dist/config/compiler/utils/recommendationCompilerUtils.js +104 -71
  27. package/dist/config/migrator/index.js +9 -9
  28. package/dist/config/migrator/radioButtonMigrator.js +64 -44
  29. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  30. package/dist/config/migrator/recommendation/extractors.js +27 -0
  31. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  32. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  33. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  34. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  35. package/dist/config/migrator/recommendationMigrator.js +74 -290
  36. package/dist/enums/extensions/recommendationBlock.js +2 -1
  37. package/dist/enums/onboarding.js +7 -2
  38. package/dist/extensions/Blocks/Items/template.js +48 -46
  39. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  40. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  41. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  42. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +25 -24
  43. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  44. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  45. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +130 -90
  46. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
  47. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  48. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
  49. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  50. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  51. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  52. package/dist/guido.css +1 -1
  53. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +259 -235
  54. package/dist/node_modules/valibot/dist/index.js +450 -235
  55. package/dist/package.json.js +1 -1
  56. package/dist/services/templateLibraryApi.js +5 -4
  57. package/dist/src/@types/config/defaults.d.ts +5 -1
  58. package/dist/src/@types/config/index.d.ts +3 -3
  59. package/dist/src/@types/config/schemas.d.ts +217 -0
  60. package/dist/src/@types/config/types.d.ts +9 -1
  61. package/dist/src/components/Guido.vue.d.ts +1 -1
  62. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
  63. package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
  64. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  65. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  66. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  67. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  68. package/dist/src/composables/useAutoSave.d.ts +3 -0
  69. package/dist/src/composables/useConfig.d.ts +58 -0
  70. package/dist/src/composables/useRecommendation.d.ts +10 -1
  71. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  72. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  73. package/dist/src/composables/useSave.d.ts +1 -1
  74. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  75. package/dist/src/config/migrator/index.d.ts +2 -1
  76. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  77. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  78. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  79. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  80. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  81. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  82. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  83. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  84. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  85. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  86. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  87. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  88. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  89. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  90. package/dist/src/enums/onboarding.d.ts +6 -0
  91. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  92. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  93. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  94. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  95. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  96. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  97. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  98. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  99. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  100. package/dist/src/library.d.ts +1 -1
  101. package/dist/src/stores/autosave.d.ts +12 -0
  102. package/dist/src/stores/config.d.ts +522 -0
  103. package/dist/src/stores/editor.d.ts +23 -0
  104. package/dist/src/stores/onboarding.d.ts +4 -0
  105. package/dist/src/utils/htmlEscape.d.ts +5 -0
  106. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  107. package/dist/src/utils/timeUtil.d.ts +8 -0
  108. package/dist/stores/autosave.js +17 -0
  109. package/dist/stores/editor.js +3 -1
  110. package/dist/stores/onboarding.js +4 -0
  111. package/dist/utils/htmlEscape.js +13 -0
  112. package/dist/utils/pairProductVariables.js +89 -88
  113. package/dist/utils/templatePreparation.js +72 -32
  114. package/dist/utils/timeUtil.js +19 -0
  115. package/package.json +7 -3
  116. package/dist/enums/displayConditions.js +0 -80
  117. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  118. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -1,5 +1,5 @@
1
1
  import { useRecommendation as C } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as h, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as g, HTML as N } from "../../enums/recommendation.js";
2
+ import { DUMMY_IMAGE_MAPPINGS as y, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as g, HTML as N } from "../../enums/recommendation.js";
3
3
  import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
4
4
  const w = [
5
5
  {
@@ -8,7 +8,7 @@ const w = [
8
8
  type: "custom",
9
9
  processor: (c) => {
10
10
  let e = c;
11
- return Object.entries(h).forEach(([, l]) => {
11
+ return Object.entries(y).forEach(([, l]) => {
12
12
  Object.entries(l).forEach(([n, s]) => {
13
13
  e = e.replaceAll(s, `{{${n}}}`);
14
14
  });
@@ -36,7 +36,7 @@ const w = [
36
36
  if (s) {
37
37
  const a = [];
38
38
  if (s.forEach((i) => {
39
- const d = /recommendation-id="(.*?)"/i.exec(i), _ = d ? d[1].trim() : "", R = l(_);
39
+ const u = /recommendation-id="(.*?)"/i.exec(i), _ = u ? u[1].trim() : "", R = l(_);
40
40
  R.textTrimming && R.orientation === M && a.push(e(R));
41
41
  }), a.length) {
42
42
  const i = `width:${Math.min(...a)}px!important;`;
@@ -65,20 +65,20 @@ const w = [
65
65
  const a = s.match(T.CUSTOM_FIELD);
66
66
  if (!a)
67
67
  return;
68
- const [i] = a, d = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
69
- if (!d || !_ || !R)
68
+ 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);
69
+ if (!u || !_ || !R)
70
70
  return;
71
- const [S] = d, [b] = _, [m] = R, o = b.substring(1, b.length - 2), r = m.match(T.COMPOSITION) !== null;
71
+ const [S] = u, [b] = _, [d] = R, o = b.substring(1, b.length - 2), r = d.match(T.COMPOSITION) !== null;
72
72
  let t = i;
73
73
  if (r) {
74
- const I = S.substring(2, S.length - 3), p = n(I);
75
- o === A.OMNIBUS_PRICE && (p.priceBeforeTextValue && (t = `${p.priceBeforeTextValue}${t}`), p.priceAfterTextValue && (t = `${t}${p.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (p.discountBeforeTextValue && (t = `${p.discountBeforeTextValue}${t}`), p.discountAfterTextValue && (t = `${t}${p.discountAfterTextValue}`));
74
+ const I = S.substring(2, S.length - 3), m = n(I);
75
+ 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}`));
76
76
  }
77
- const u = S.substring(2);
77
+ const p = S.substring(2);
78
78
  let f = "";
79
- o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${u}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${u}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${u}${A.OMNIBUS_PRICE}`));
80
- const $ = `${m}${t}${N.PARAGRAPH_END_TAG}`, y = `${f}${r ? $ : s}${g.ELSE}${m}${N.PARAGRAPH_END_TAG}${g.END_IF}`;
81
- e = e.replace(s, y);
79
+ o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${p}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${p}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${p}${A.OMNIBUS_PRICE}`));
80
+ const $ = `${d}${t}${N.PARAGRAPH_END_TAG}`, h = `${f}${r ? $ : s}${g.ELSE}${d}${N.PARAGRAPH_END_TAG}${g.END_IF}`;
81
+ e = e.replace(s, h);
82
82
  }), e;
83
83
  },
84
84
  priority: 53
@@ -136,7 +136,7 @@ const w = [
136
136
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
137
137
  (l, n) => {
138
138
  const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
139
- return s.every((d) => a.test(d)) ? "" : l;
139
+ return s.every((u) => a.test(u)) ? "" : l;
140
140
  }
141
141
  )), e;
142
142
  },
@@ -151,7 +151,7 @@ const w = [
151
151
  /<a\b[^>]*\bes-button\b[^>]*>/g,
152
152
  (o) => o.replace(
153
153
  /([;"]color:)([^;"]+)/g,
154
- (r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
154
+ (r, t, p) => p.includes("!important") ? r : `${t}${p} !important`
155
155
  )
156
156
  ), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
157
157
  let a = l.exec(e);
@@ -163,12 +163,12 @@ const w = [
163
163
  }
164
164
  n.lastIndex = 0, a = l.exec(e);
165
165
  }
166
- const i = /* @__PURE__ */ new Map(), d = [];
166
+ const i = /* @__PURE__ */ new Map(), u = [];
167
167
  let _ = 0;
168
168
  if (s.forEach((o, r) => {
169
- if (o >= 6) {
170
- const t = `rc${_++}`;
171
- i.set(r, t), d.push(`.${t}{${r}}`);
169
+ if (!r.includes("v-text-anchor") && o >= 6) {
170
+ const t = `rc${_++}`, p = r.endsWith(";") ? r : `${r};`;
171
+ i.set(r, t), u.push(`.${t}{${p}}`);
172
172
  }
173
173
  }), i.size === 0) {
174
174
  let o = e;
@@ -182,23 +182,23 @@ const w = [
182
182
  caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
183
183
  });
184
184
  });
185
- let m = e.replace("</style>", `${d.join("")}</style>`);
186
- return m = m.replace(
185
+ let d = e.replace("</style>", `${u.join("")}</style>`);
186
+ return d = d.replace(
187
187
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
188
188
  (o, r) => {
189
189
  let t = r;
190
- return i.forEach((u, f) => {
190
+ return i.forEach((p, f) => {
191
191
  const $ = b.get(f);
192
192
  t = t.replace(
193
193
  $.caseA,
194
- (y, I, p) => S(I, u) + p
194
+ (h, I, m) => S(I, p) + m
195
195
  ), t = t.replace(
196
196
  $.caseB,
197
- (y, I, p) => I + S(p, u)
198
- ), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
197
+ (h, I, m) => I + S(m, p)
198
+ ), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
199
199
  }), t;
200
200
  }
201
- ), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
201
+ ), d = d.replaceAll("<!--REC_START-->", ""), d = d.replaceAll("<!--REC_END-->", ""), d;
202
202
  },
203
203
  priority: 58
204
204
  }
@@ -1,41 +1,41 @@
1
- import { useConfig as S } from "../../../composables/useConfig.js";
2
- import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
- import { useRecommendationExtensionStore as d } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
4
- function y(e, u, r, o, s = "") {
5
- const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
1
+ import { useConfig as g } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as S } from "../../../composables/useRecommendation.js";
3
+ import { useRecommendationExtensionStore as _ } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
4
+ function y(r, c, e, o, s = "") {
5
+ const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
6
6
  return o === "before" ? `${t} ${n}` : `${n} ${t}`;
7
7
  }
8
- function m(e, u, r, o, s, n) {
9
- switch (u) {
8
+ function f(r, c, e, o, s, n) {
9
+ switch (c) {
10
10
  case "productImage": {
11
- const t = e.querySelector("img");
12
- t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
13
- const c = e.querySelector("a");
14
- c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
11
+ const t = r.querySelector("img");
12
+ t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
13
+ const i = r.querySelector("a");
14
+ i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
15
15
  break;
16
16
  }
17
17
  case "productName": {
18
- const t = e.querySelector("p");
18
+ const t = r.querySelector("p");
19
19
  if (t) {
20
- const c = t.querySelector("strong") || t;
21
- c.textContent = `{{${n}${r}_${o}_name}}`;
20
+ const i = t.querySelector("strong") || t;
21
+ i.textContent = `{{${n}${e}_${o}_name}}`;
22
22
  }
23
23
  break;
24
24
  }
25
25
  case "productPrice": {
26
- const t = e.querySelector("p");
26
+ const t = r.querySelector("p");
27
27
  if (t) {
28
- const c = t.querySelector("strong") || t;
29
- c.textContent = y(r, o, "price", s, n);
28
+ const i = t.querySelector("strong") || t;
29
+ i.textContent = y(e, o, "price", s, n);
30
30
  }
31
31
  break;
32
32
  }
33
33
  case "productOldPrice": {
34
- const t = e.querySelector("p");
34
+ const t = r.querySelector("p");
35
35
  if (t) {
36
- const c = t.querySelector("strong") || t;
37
- c.textContent = y(
38
- r,
36
+ const i = t.querySelector("strong") || t;
37
+ i.textContent = y(
38
+ e,
39
39
  o,
40
40
  "original_price",
41
41
  s,
@@ -45,94 +45,127 @@ function m(e, u, r, o, s, n) {
45
45
  break;
46
46
  }
47
47
  case "productButton": {
48
- const t = e.querySelector("a");
49
- t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
48
+ const t = r.querySelector("a");
49
+ t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
50
50
  break;
51
51
  }
52
52
  case "productOmnibusPrice": {
53
- const t = e.querySelector(".omnibus-price-value");
53
+ const t = r.querySelector(".omnibus-price-value");
54
54
  if (t) {
55
- t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
56
- const c = t.closest("p");
57
- c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
55
+ t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
56
+ const i = t.closest("p");
57
+ i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
58
58
  }
59
59
  break;
60
60
  }
61
61
  case "productOmnibusDiscount": {
62
- const t = e.querySelector(".omnibus-discount-value");
62
+ const t = r.querySelector(".omnibus-discount-value");
63
63
  if (t) {
64
- t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
65
- const c = t.closest("p");
66
- c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
64
+ t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
65
+ const i = t.closest("p");
66
+ i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
67
67
  }
68
68
  break;
69
69
  }
70
70
  default: {
71
- const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
71
+ const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
72
72
  if (t) {
73
- const c = t.getAttribute("product-attr"), a = t.querySelector("p");
73
+ const i = t.getAttribute("product-attr"), a = t.querySelector("p");
74
74
  if (a) {
75
- const i = a.querySelector("strong") || a;
76
- i.textContent = `{{${n}${r}_${o}_${c}}}`;
75
+ const u = a.querySelector("strong") || a;
76
+ u.textContent = `{{${n}${e}_${o}_${i}}}`;
77
77
  }
78
78
  }
79
79
  break;
80
80
  }
81
81
  }
82
82
  }
83
- function q(e, u, r, o) {
84
- e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
83
+ function q(r, c, e, o) {
84
+ r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
85
85
  n.querySelectorAll("[data-attribute-type]").forEach((a) => {
86
- const i = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
87
- l.length > 0 ? l.forEach((p) => {
88
- m(p, i, u, t, r, o);
89
- }) : m(a, i, u, t, r, o);
86
+ const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
87
+ p.length > 0 ? p.forEach((l) => {
88
+ f(l, u, c, t, e, o);
89
+ }) : f(a, u, c, t, e, o);
90
90
  });
91
91
  });
92
92
  }
93
- function g(e, u, r, o) {
94
- const s = e.querySelectorAll(".recommendation-product-row");
93
+ function w(r, c, e, o) {
94
+ const s = r.querySelectorAll(".recommendation-product-row");
95
95
  if (!s.length)
96
96
  return;
97
- const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
98
- s.forEach((a, i) => {
99
- a.querySelectorAll("[data-attribute-type]").forEach((p) => {
100
- const b = p.getAttribute("data-attribute-type") || "";
101
- p.querySelectorAll(".attribute-cell").forEach((f, $) => {
102
- const A = i * c + $;
103
- m(f, b, u, A, r, o);
97
+ const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
98
+ s.forEach((a, u) => {
99
+ a.querySelectorAll("[data-attribute-type]").forEach((l) => {
100
+ const d = l.getAttribute("data-attribute-type") || "";
101
+ l.querySelectorAll(".attribute-cell").forEach((A, h) => {
102
+ const $ = u * i + h;
103
+ f(A, d, c, $, e, o);
104
104
  });
105
105
  });
106
106
  });
107
107
  }
108
- function h(e, u, r, o) {
109
- e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
110
- g(n, u, r, o);
108
+ function E(r, c, e, o) {
109
+ r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
110
+ w(n, c, e, o);
111
111
  });
112
112
  }
113
- function C(e, u, r) {
114
- const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
115
- o === "list" ? q(e, u, s, r) : h(e, u, s, r);
113
+ function C(r, c, e) {
114
+ const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
115
+ o === "list" ? q(r, c, s, e) : E(r, c, s, e);
116
116
  }
117
- function E(e, u) {
118
- const r = e.match(/<!DOCTYPE[^>]*>/i);
119
- return (r ? `${r[0]}
120
- ` : "") + u.documentElement.outerHTML;
117
+ function b(r, c, e) {
118
+ const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
119
+ return s ? parseInt(s[1]) : e;
121
120
  }
122
- function T(e) {
123
- const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
121
+ function P(r, c) {
122
+ let e = r.parentElement;
123
+ for (; e && e !== c; ) {
124
+ if (e.tagName === "TD") {
125
+ const o = e.getAttribute("width");
126
+ if (o && o.endsWith("%") && parseFloat(o) < 100)
127
+ return e;
128
+ }
129
+ e = e.parentElement;
130
+ }
131
+ return null;
132
+ }
133
+ function R(r) {
134
+ const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
135
+ s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
136
+ if (n.hasAttribute("width"))
137
+ return;
138
+ const t = P(n, r);
139
+ if (!t)
140
+ return;
141
+ const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
142
+ n.setAttribute("width", String(l));
143
+ const d = n.getAttribute("style") || "";
144
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
145
+ const m = d && !d.trim().endsWith(";") ? "; " : "";
146
+ n.setAttribute("style", `${d}${m}width: ${l}px`);
147
+ }
148
+ });
149
+ }
150
+ function v(r, c) {
151
+ const e = r.match(/<!DOCTYPE[^>]*>/i);
152
+ return (e ? `${e[0]}
153
+ ` : "") + c.documentElement.outerHTML;
154
+ }
155
+ function O(r) {
156
+ const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
124
157
  if (!o.length)
125
- return e;
126
- const { buildCampaignUrl: s } = _(), n = d();
158
+ return r;
159
+ const { buildCampaignUrl: s } = S(), n = _();
127
160
  n.recommendationCampaignUrls = {};
128
- const { isFeatureEnabled: t } = S(), c = t("liquidSyntax") ? "reco_" : "";
129
- return o.forEach((i) => {
130
- var p, b;
131
- const l = i.getAttribute("recommendation-id");
132
- l && ((p = i.parentNode) == null || p.insertBefore(r.createComment("REC_START"), i), (b = i.parentNode) == null || b.insertBefore(r.createComment("REC_END"), i.nextSibling), s(l), C(i, l, c));
133
- }), E(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
161
+ const { isFeatureEnabled: t } = g(), i = t("liquidSyntax") ? "reco_" : "";
162
+ return o.forEach((u) => {
163
+ var l, d;
164
+ const p = u.getAttribute("recommendation-id");
165
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), C(u, p, i), R(u));
166
+ }), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
134
167
  }
135
168
  export {
136
169
  y as formatPriceVariable,
137
- T as prepareRecommendationBlocks
170
+ O as prepareRecommendationBlocks
138
171
  };
@@ -1,13 +1,13 @@
1
- import { migrateCheckbox as t } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as o } from "./couponBlockMigrator.js";
3
- import { migrateItemsBlock as i } from "./itemsBlockMigrator.js";
4
- import { migrateRadioButton as e } from "./radioButtonMigrator.js";
5
- import { migrateRecommendation as a } from "./recommendationMigrator.js";
6
- import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
7
- const u = async (r) => {
1
+ import { migrateCheckbox as o } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
3
+ import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
4
+ import { migrateRadioButton as a } from "./radioButtonMigrator.js";
5
+ import { migrateRecommendation as g } from "./recommendationMigrator.js";
6
+ import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
7
+ const b = async (r, t = {}) => {
8
8
  let m = r;
9
- return m = t(m), m = e(m), m = await g(m), m = o(m), m = a(m), m = i(m), m;
9
+ return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
10
10
  };
11
11
  export {
12
- u as migrate
12
+ b as migrate
13
13
  };
@@ -1,34 +1,54 @@
1
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
- import h from "../../extensions/Blocks/RadioButton/template.js";
5
- class T {
2
+ var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
+ import S from "../../extensions/Blocks/RadioButton/template.js";
5
+ class B {
6
6
  constructor() {
7
7
  b(this, "parser");
8
8
  this.parser = new DOMParser();
9
9
  }
10
- migrate(t) {
10
+ migrate(e) {
11
11
  try {
12
- const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
13
- return i.length === 0 ? t : (i.forEach((s) => {
14
- if (s.classList.contains("radio-button-v2"))
12
+ const t = this.parser.parseFromString(e, "text/html"), i = t.querySelectorAll("td.radio-button-block"), s = t.querySelectorAll("td.radio-button-v2");
13
+ if (i.length === 0 && s.length === 0)
14
+ return e;
15
+ let o = !1;
16
+ return i.forEach((r) => {
17
+ if (r.classList.contains("radio-button-v2"))
15
18
  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(
17
- `<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
19
+ const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), d = this.buildTextBlock(a), p = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", p).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
20
+ `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
18
21
  "text/html"
19
22
  ).querySelector(".radio-button-v2");
20
- y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
21
- }), e.documentElement.outerHTML);
22
- } catch (e) {
23
- return console.error("RadioButtonMigrator failed:", e), t;
23
+ m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
+ }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
25
+ } catch (t) {
26
+ return console.error("RadioButtonMigrator failed:", t), e;
24
27
  }
25
28
  }
26
- extractTextFromElement(t, e) {
27
- var o, c;
28
- const i = t.querySelector(`.${e}`);
29
+ healRadioButtonV2(e) {
30
+ let t = !1;
31
+ return e.querySelectorAll("td.radio-button-v2").forEach((i) => {
32
+ var p;
33
+ const s = i.querySelector("input#radioYes"), o = i.querySelector("input#radioNo");
34
+ if (!s || !o)
35
+ return;
36
+ const r = ((p = s.parentElement) == null ? void 0 : p.querySelector(":scope > p")) || null;
37
+ if (!r && !s.hasAttribute("align"))
38
+ return;
39
+ const n = s.closest("tr"), a = o.closest("tr");
40
+ if (!n || !a || n === a || !n.parentNode)
41
+ return;
42
+ const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), d = c.querySelector("p");
43
+ u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), d && (d.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
44
+ }), t;
45
+ }
46
+ extractTextFromElement(e, t) {
47
+ var p, y;
48
+ const i = e.querySelector(`.${t}`);
29
49
  if (!i)
30
50
  return {
31
- text: e === "ins-title" ? "Title" : "Description",
51
+ text: t === "ins-title" ? "Title" : "Description",
32
52
  isBold: !1,
33
53
  isItalic: !1,
34
54
  align: "left",
@@ -38,51 +58,51 @@ class T {
38
58
  const s = i.querySelector("p");
39
59
  if (!s)
40
60
  return {
41
- text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
61
+ text: ((p = i.textContent) == null ? void 0 : p.trim()) || (t === "ins-title" ? "Title" : "Description"),
42
62
  isBold: !1,
43
63
  isItalic: !1,
44
64
  align: i.getAttribute("align") || "left",
45
65
  styles: "",
46
66
  classList: ""
47
67
  };
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") || "";
68
+ const o = ((y = s.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = s.getAttribute("style") || "", n = i.getAttribute("align") || s.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!s.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!s.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), d = i.getAttribute("class") || "";
49
69
  return {
50
- text: n,
51
- isBold: p,
52
- isItalic: u,
53
- align: a,
54
- styles: g,
55
- classList: m
70
+ text: o,
71
+ isBold: a,
72
+ isItalic: g,
73
+ align: n,
74
+ styles: u,
75
+ classList: d
56
76
  };
57
77
  }
58
- buildTextBlock(t) {
59
- let e = t.text;
60
- t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
61
- const i = t.align ? ` align="${t.align}"` : "", s = t.styles ? ` style="${t.styles.replaceAll('"', "'")}"` : "";
78
+ buildTextBlock(e) {
79
+ let t = e.text;
80
+ e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
81
+ const i = e.align ? ` align="${e.align}"` : "", s = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
62
82
  return `
63
- <td class="esd-block-text ${t.classList}" ${i}>
83
+ <td class="esd-block-text ${e.classList}" ${i}>
64
84
  <p path="1" ${s}>
65
- ${e}
85
+ ${t}
66
86
  </p>
67
87
  </td>
68
88
  `;
69
89
  }
70
- removeStyleProperties(t, e) {
71
- return t ? e.reduce((s, n) => {
72
- const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
73
- return s.replace(l, "");
74
- }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
90
+ removeStyleProperties(e, t) {
91
+ return e ? t.reduce((s, o) => {
92
+ const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
93
+ return s.replace(r, "");
94
+ }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
75
95
  }
76
- convertInlineToBlock(t) {
77
- if (!t)
96
+ convertInlineToBlock(e) {
97
+ if (!e)
78
98
  return "";
79
- let e = t.replace(/display\s*:\s*inline/gi, "display: block");
80
- return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
99
+ let t = e.replace(/display\s*:\s*inline/gi, "display: block");
100
+ return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
81
101
  }
82
102
  }
83
- function A(r) {
84
- return new T().migrate(r);
103
+ function q(l) {
104
+ return new B().migrate(l);
85
105
  }
86
106
  export {
87
- A as migrateRadioButton
107
+ q as migrateRadioButton
88
108
  };
@@ -0,0 +1,98 @@
1
+ import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
+ import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
4
+ const C = "__title__", a = "product_attribute.";
5
+ function N(r) {
6
+ const t = r.variable ?? "";
7
+ switch (t) {
8
+ case "p_recommendation_title":
9
+ return { key: C, kind: "title" };
10
+ case "p_image":
11
+ return { key: y, kind: "image" };
12
+ case "p_name":
13
+ return { key: h, kind: "text" };
14
+ case "p_price":
15
+ return { key: R, kind: "text" };
16
+ case "p_original_price":
17
+ return { key: f, kind: "text" };
18
+ case "p_omnibus_price":
19
+ return { key: x, kind: "text" };
20
+ case "p_omnibus_discount":
21
+ return { key: A, kind: "text" };
22
+ case "p_button":
23
+ return { key: k, kind: "button" };
24
+ default:
25
+ if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
+ const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
27
+ return o ? {
28
+ key: `${l}${o}`,
29
+ kind: "custom",
30
+ customAttrName: o,
31
+ customAttrValue: s || `${a}${o}`
32
+ } : null;
33
+ }
34
+ return null;
35
+ }
36
+ }
37
+ function p(r) {
38
+ const t = d.indexOf(r);
39
+ return t === -1 ? Number.POSITIVE_INFINITY : t;
40
+ }
41
+ function S(r) {
42
+ const t = {
43
+ composition: [],
44
+ visibility: { ...I },
45
+ customAttributes: [],
46
+ customAttrValues: {},
47
+ perElementStyles: {},
48
+ anyTextTrimming: !1
49
+ };
50
+ if (!r || r.length === 0)
51
+ return t.composition = [...d], t;
52
+ const s = [];
53
+ r.forEach((e, i) => {
54
+ const n = N(e);
55
+ if (n) {
56
+ if (n.kind === "title") {
57
+ t.titleVariable = e;
58
+ return;
59
+ }
60
+ s.push({
61
+ key: n.key,
62
+ kind: n.kind,
63
+ hidden: e.hidden === !0,
64
+ positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
65
+ legacy: e,
66
+ customAttrName: n.customAttrName,
67
+ customAttrValue: n.customAttrValue,
68
+ originalIndex: i
69
+ });
70
+ }
71
+ }), s.sort((e, i) => {
72
+ if (e.positionIdx !== i.positionIdx)
73
+ return e.positionIdx - i.positionIdx;
74
+ const n = p(e.key), u = p(i.key);
75
+ return n !== u ? n - u : e.originalIndex - i.originalIndex;
76
+ });
77
+ const o = {};
78
+ return s.forEach((e) => {
79
+ const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
80
+ switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
81
+ case "image":
82
+ o[i] = b(m.theme);
83
+ break;
84
+ case "button":
85
+ o[i] = O(m.theme);
86
+ break;
87
+ case "text":
88
+ case "custom": {
89
+ const _ = E(m.theme);
90
+ o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
91
+ break;
92
+ }
93
+ }
94
+ }), t.perElementStyles = o, t;
95
+ }
96
+ export {
97
+ S as mapComposition
98
+ };