@useinsider/guido 3.2.0-beta.2e5aafb → 3.2.0-beta.31dade2

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 (123) hide show
  1. package/README.md +92 -0
  2. package/dist/@types/config/schemas.js +150 -94
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +88 -87
  5. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  6. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  7. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  8. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  9. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  10. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  11. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  12. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  13. package/dist/composables/useActionsApi.js +4 -4
  14. package/dist/composables/useFullStoryBridge.js +14 -0
  15. package/dist/composables/useRecommendation.js +46 -26
  16. package/dist/composables/useRibbonOffset.js +21 -0
  17. package/dist/composables/useSave.js +21 -18
  18. package/dist/composables/useStripo.js +40 -40
  19. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  20. package/dist/config/compiler/recommendationCompilerRules.js +79 -74
  21. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  22. package/dist/config/compiler/utils/recommendationCompilerUtils.js +107 -71
  23. package/dist/config/migrator/index.js +9 -9
  24. package/dist/config/migrator/radioButtonMigrator.js +50 -41
  25. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  26. package/dist/config/migrator/recommendation/extractors.js +27 -0
  27. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  28. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  29. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  30. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  31. package/dist/config/migrator/recommendationMigrator.js +74 -290
  32. package/dist/enums/extensions/recommendationBlock.js +2 -1
  33. package/dist/enums/onboarding.js +7 -2
  34. package/dist/enums/unsubscribe.js +34 -27
  35. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  36. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  37. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  38. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  39. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  40. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  41. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  42. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  43. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +27 -26
  44. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  45. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  46. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  47. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  48. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  49. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  50. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
  51. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
  52. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  53. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
  54. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
  55. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  56. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
  57. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  58. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  59. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  60. package/dist/guido.css +1 -1
  61. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
  62. package/dist/node_modules/valibot/dist/index.js +450 -235
  63. package/dist/package.json.js +1 -1
  64. package/dist/services/templateLibraryApi.js +5 -4
  65. package/dist/src/@types/config/defaults.d.ts +5 -1
  66. package/dist/src/@types/config/index.d.ts +3 -3
  67. package/dist/src/@types/config/schemas.d.ts +213 -0
  68. package/dist/src/@types/config/types.d.ts +9 -1
  69. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  70. package/dist/src/composables/useActionsApi.d.ts +1 -1
  71. package/dist/src/composables/useConfig.d.ts +56 -0
  72. package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
  73. package/dist/src/composables/useRecommendation.d.ts +10 -1
  74. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  75. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  76. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  77. package/dist/src/config/migrator/index.d.ts +2 -1
  78. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  79. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  80. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  81. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  82. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  83. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  84. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  85. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  86. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  87. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  88. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  89. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  90. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  91. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  92. package/dist/src/enums/onboarding.d.ts +6 -0
  93. package/dist/src/enums/unsubscribe.d.ts +5 -0
  94. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  95. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  96. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  97. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  98. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  99. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  100. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  101. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  102. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  103. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  104. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  105. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  106. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  107. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  108. package/dist/src/library.d.ts +1 -1
  109. package/dist/src/stores/config.d.ts +504 -0
  110. package/dist/src/stores/onboarding.d.ts +4 -0
  111. package/dist/src/utils/htmlEscape.d.ts +5 -0
  112. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  113. package/dist/static/styles/components/button.css.js +16 -9
  114. package/dist/static/styles/components/loader.css.js +4 -0
  115. package/dist/static/styles/components/narrow-panel.css.js +52 -0
  116. package/dist/stores/onboarding.js +4 -0
  117. package/dist/utils/htmlEscape.js +13 -0
  118. package/dist/utils/pairProductVariables.js +89 -88
  119. package/dist/utils/templatePreparation.js +72 -32
  120. package/package.json +7 -3
  121. package/dist/enums/displayConditions.js +0 -80
  122. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  123. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -1,16 +1,16 @@
1
- import { useRecommendation as N } from "../../composables/useRecommendation.js";
2
- import { DUMMY_IMAGE_MAPPINGS as C, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as R, CONDITIONS as $, HTML as h } from "../../enums/recommendation.js";
1
+ import { useRecommendation as C } from "../../composables/useRecommendation.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
  {
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: (i) => {
10
- let e = i;
11
- return Object.entries(C).forEach(([, p]) => {
12
- Object.entries(p).forEach(([c, n]) => {
13
- e = e.replaceAll(n, `{{${c}}}`);
9
+ processor: (c) => {
10
+ let e = c;
11
+ return Object.entries(y).forEach(([, l]) => {
12
+ Object.entries(l).forEach(([n, s]) => {
13
+ e = e.replaceAll(s, `{{${n}}}`);
14
14
  });
15
15
  }), e;
16
16
  },
@@ -29,21 +29,21 @@ const w = [
29
29
  id: "add-recommendation-unresponsive-css",
30
30
  description: "Adding recommendation unresponsive css",
31
31
  type: "custom",
32
- processor: (i) => {
33
- const { calculateCardWidth: e, getRecommendationCampaignData: p } = N();
34
- let c = i;
35
- const n = c.match(T.ID);
36
- if (n) {
32
+ processor: (c) => {
33
+ const { calculateCardWidth: e, getRecommendationCampaignData: l } = C();
34
+ let n = c;
35
+ const s = n.match(T.ID);
36
+ if (s) {
37
37
  const a = [];
38
- if (n.forEach((s) => {
39
- const d = /recommendation-id="(.*?)"/i.exec(s), _ = d ? d[1].trim() : "", A = p(_);
40
- A.textTrimming && A.orientation === M && a.push(e(A));
38
+ if (s.forEach((i) => {
39
+ const u = /recommendation-id="(.*?)"/i.exec(i), _ = u ? u[1].trim() : "", R = l(_);
40
+ R.textTrimming && R.orientation === M && a.push(e(R));
41
41
  }), a.length) {
42
- const s = `width:${Math.min(...a)}px!important;`;
43
- c = c.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${s} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
42
+ const i = `width:${Math.min(...a)}px!important;`;
43
+ 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
44
  }
45
45
  }
46
- return c;
46
+ return n;
47
47
  },
48
48
  priority: 52
49
49
  },
@@ -51,34 +51,34 @@ const w = [
51
51
  id: "prepare-recommendations",
52
52
  description: "Replacing product data with template variables in recommendation blocks",
53
53
  type: "custom",
54
- processor: (i) => x(i),
54
+ processor: (c) => x(c),
55
55
  priority: 48
56
56
  },
57
57
  {
58
58
  id: "add-discount-conditions",
59
59
  description: "Adding discount conditions to the recommendation block",
60
60
  type: "custom",
61
- processor: (i) => {
62
- let e = i;
63
- const p = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: c } = N();
64
- return p !== null && p.forEach((n) => {
65
- const a = n.match(T.CUSTOM_FIELD);
61
+ processor: (c) => {
62
+ let e = c;
63
+ const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = C();
64
+ return l !== null && l.forEach((s) => {
65
+ const a = s.match(T.CUSTOM_FIELD);
66
66
  if (!a)
67
67
  return;
68
- const [s] = a, d = s.match(T.CUSTOM_FIELD_INDEXES_PART), _ = s.match(T.CUSTOM_FIELD_NAME_PART), A = n.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
69
- if (!d || !_ || !A)
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 [I] = d, [S] = _, [m] = A, o = S.substring(1, S.length - 2), r = m.match(T.COMPOSITION) !== null;
72
- let t = s;
71
+ const [S] = u, [b] = _, [d] = R, o = b.substring(1, b.length - 2), r = d.match(T.COMPOSITION) !== null;
72
+ let t = i;
73
73
  if (r) {
74
- const b = I.substring(2, I.length - 3), l = c(b);
75
- o === R.OMNIBUS_PRICE && (l.priceBeforeTextValue && (t = `${l.priceBeforeTextValue}${t}`), l.priceAfterTextValue && (t = `${t}${l.priceAfterTextValue}`)), o === R.OMNIBUS_DISCOUNT && (l.discountBeforeTextValue && (t = `${l.discountBeforeTextValue}${t}`), l.discountAfterTextValue && (t = `${t}${l.discountAfterTextValue}`));
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 = I.substring(2);
77
+ const p = S.substring(2);
78
78
  let f = "";
79
- o in $.IF && (f = $.IF[o].replaceAll(`{${R.DISCOUNT}}`, `${u}${R.DISCOUNT}`).replaceAll(`{${R.OMNIBUS_DISCOUNT}}`, `${u}${R.OMNIBUS_DISCOUNT}`).replaceAll(`{${R.OMNIBUS_PRICE}}`, `${u}${R.OMNIBUS_PRICE}`));
80
- const g = `${m}${t}${h.PARAGRAPH_END_TAG}`, y = `${f}${r ? g : n}${$.ELSE}${m}${h.PARAGRAPH_END_TAG}${$.END_IF}`;
81
- e = e.replace(n, y);
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
@@ -95,19 +95,24 @@ const w = [
95
95
  {
96
96
  id: "strip-recommendation-editor-attributes",
97
97
  description: "Strip editor-only attributes from compiled recommendation output",
98
- type: "regex",
99
- // eslint-disable-next-line @stylistic/max-len
100
- pattern: '\\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"',
101
- replacement: "",
102
- flags: "g",
98
+ type: "custom",
99
+ // Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
100
+ // from Items block elements, which the items compiler rule depends on.
101
+ processor: (c) => {
102
+ const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
103
+ return c.replace(
104
+ /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
105
+ (l, n) => `<!--REC_START-->${n.replace(e, "")}<!--REC_END-->`
106
+ );
107
+ },
103
108
  priority: 55
104
109
  },
105
110
  {
106
111
  id: "strip-unused-recommendation-classes",
107
112
  description: "Remove CSS classes not referenced by any style rule from recommendation elements",
108
113
  type: "custom",
109
- processor: (i) => {
110
- let e = i.replace(
114
+ processor: (c) => {
115
+ let e = c.replace(
111
116
  / class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
112
117
  ""
113
118
  );
@@ -119,8 +124,8 @@ const w = [
119
124
  id: "remove-empty-mobile-layout-artifacts",
120
125
  description: "Remove empty mobile container rows and unused mobile layout CSS",
121
126
  type: "custom",
122
- processor: (i) => {
123
- let e = i;
127
+ processor: (c) => {
128
+ let e = c;
124
129
  return e = e.replace(
125
130
  /<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
126
131
  ""
@@ -129,9 +134,9 @@ const w = [
129
134
  ""
130
135
  ), e = e.replace(
131
136
  /@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
132
- (p, c) => {
133
- const n = c.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
134
- return n.every((d) => a.test(d)) ? "" : p;
137
+ (l, n) => {
138
+ const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
139
+ return s.every((u) => a.test(u)) ? "" : l;
135
140
  }
136
141
  )), e;
137
142
  },
@@ -141,59 +146,59 @@ const w = [
141
146
  id: "deduplicate-inline-styles",
142
147
  description: "Replace repeated inline styles with CSS class references within recommendation blocks",
143
148
  type: "custom",
144
- processor: (i) => {
145
- const e = i.replace(
149
+ processor: (c) => {
150
+ const e = c.replace(
146
151
  /<a\b[^>]*\bes-button\b[^>]*>/g,
147
152
  (o) => o.replace(
148
153
  /([;"]color:)([^;"]+)/g,
149
- (r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
154
+ (r, t, p) => p.includes("!important") ? r : `${t}${p} !important`
150
155
  )
151
- ), p = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, c = / style="([^"]*)"/g, n = /* @__PURE__ */ new Map();
152
- let a = p.exec(e);
156
+ ), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
157
+ let a = l.exec(e);
153
158
  for (; a !== null; ) {
154
- let o = c.exec(a[1]);
159
+ let o = n.exec(a[1]);
155
160
  for (; o !== null; ) {
156
161
  const [, r] = o;
157
- n.set(r, (n.get(r) || 0) + 1), o = c.exec(a[1]);
162
+ s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
158
163
  }
159
- c.lastIndex = 0, a = p.exec(e);
164
+ n.lastIndex = 0, a = l.exec(e);
160
165
  }
161
- const s = /* @__PURE__ */ new Map(), d = [];
166
+ const i = /* @__PURE__ */ new Map(), u = [];
162
167
  let _ = 0;
163
- if (n.forEach((o, r) => {
164
- if (o >= 6) {
165
- const t = `rc${_++}`;
166
- s.set(r, t), d.push(`.${t}{${r}}`);
168
+ if (s.forEach((o, 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}}`);
167
172
  }
168
- }), s.size === 0) {
173
+ }), i.size === 0) {
169
174
  let o = e;
170
175
  return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
171
176
  }
172
- const A = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), I = (o, r) => `${o.slice(0, -1)} ${r}"`, S = /* @__PURE__ */ new Map();
173
- s.forEach((o, r) => {
174
- const t = A(r);
175
- S.set(r, {
177
+ const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), S = (o, r) => `${o.slice(0, -1)} ${r}"`, b = /* @__PURE__ */ new Map();
178
+ i.forEach((o, r) => {
179
+ const t = R(r);
180
+ b.set(r, {
176
181
  caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
177
182
  caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
178
183
  });
179
184
  });
180
- let m = e.replace("</style>", `${d.join("")}</style>`);
181
- return m = m.replace(
185
+ let d = e.replace("</style>", `${u.join("")}</style>`);
186
+ return d = d.replace(
182
187
  /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
183
188
  (o, r) => {
184
189
  let t = r;
185
- return s.forEach((u, f) => {
186
- const g = S.get(f);
190
+ return i.forEach((p, f) => {
191
+ const $ = b.get(f);
187
192
  t = t.replace(
188
- g.caseA,
189
- (y, b, l) => I(b, u) + l
193
+ $.caseA,
194
+ (h, I, m) => S(I, p) + m
190
195
  ), t = t.replace(
191
- g.caseB,
192
- (y, b, l) => b + I(l, u)
193
- ), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
196
+ $.caseB,
197
+ (h, I, m) => I + S(m, p)
198
+ ), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
194
199
  }), t;
195
200
  }
196
- ), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
201
+ ), d = d.replaceAll("<!--REC_START-->", ""), d = d.replaceAll("<!--REC_END-->", ""), d;
197
202
  },
198
203
  priority: 58
199
204
  }
@@ -1,41 +1,44 @@
1
- import { usePartner as y } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as p, LINK_TYPES as S, INSIDER_ID as m, URLS as R } from "../../enums/unsubscribe.js";
3
- import { parsePageList as I } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
- import { useConfigStore as N } from "../../stores/config.js";
5
- import { useDynamicContentStore as U } from "../../stores/dynamic-content.js";
6
- import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
7
- const G = [
1
+ import { usePartner as U } from "../../composables/usePartner.js";
2
+ import { LINK_REGEXES as p, PRODUCT_TYPE_URL_SEGMENTS as R, LINK_TYPES as _, INSIDER_ID as m, URLS as y } from "../../enums/unsubscribe.js";
3
+ import { parsePageList as N } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
+ import { useConfigStore as C } from "../../stores/config.js";
5
+ import { useDynamicContentStore as L } from "../../stores/dynamic-content.js";
6
+ import { useUnsubscribeStore as P } from "../../stores/unsubscribe.js";
7
+ import { ProductType as B } from "../../@types/config/schemas.js";
8
+ import "../../@types/config/defaults.js";
9
+ const F = [
8
10
  {
9
11
  id: "add-unsubscribe-link-values",
10
12
  description: "Adding unsubscribe link values",
11
13
  type: "custom",
12
- processor: (t) => {
13
- const { getPartnerName: i } = y(), o = N(), s = U(), d = C(), a = o.variationId;
14
- if (!a)
15
- return t;
16
- let e = t;
17
- const r = `/${i()}/email/${a}?user={{iid}}`, E = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
18
- let c = !1, l = !1;
19
- return E.forEach((f) => {
20
- var b;
21
- const u = f.getAttribute("data-unsubscribe-page-list");
14
+ processor: (s) => {
15
+ const { getPartnerName: i } = U(), n = C(), t = L(), E = P(), c = n.variationId;
16
+ if (!c)
17
+ return s;
18
+ const r = R[n.productType] ?? R[B.EMAIL];
19
+ let e = s;
20
+ const d = `/${i()}/${r}/${c}?user={{iid}}`, f = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]");
21
+ let a = !1, l = !1;
22
+ return f.forEach((g) => {
23
+ var S;
24
+ const u = g.getAttribute("data-unsubscribe-page-list");
22
25
  if (!u)
23
26
  return;
24
- const _ = I(u), g = ((b = d.templates) == null ? void 0 : b.filter(
25
- (n) => _.includes(n.id)
27
+ const I = N(u), b = ((S = E.templates) == null ? void 0 : S.filter(
28
+ (o) => I.includes(o.id)
26
29
  )) ?? [];
27
- c = c || g.some((n) => n.type === S.UNSUBSCRIBE_LINK_TYPE), l = l || g.some((n) => n.type === S.PREFERENCES_LINK_TYPE);
28
- }), (c || l) && (s.selectedDynamicContentList.some((u) => u.value === m) || s.selectedDynamicContentList.push({
30
+ a = a || b.some((o) => o.type === _.UNSUBSCRIBE_LINK_TYPE), l = l || b.some((o) => o.type === _.PREFERENCES_LINK_TYPE);
31
+ }), (a || l) && (t.selectedDynamicContentList.some((u) => u.value === m) || t.selectedDynamicContentList.push({
29
32
  text: m,
30
33
  value: m,
31
34
  fallback: ""
32
- })), c && (e = e.replace(
35
+ })), a && (e = e.replace(
33
36
  p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
34
- R.UNSUBSCRIBE_URL + r
37
+ y.UNSUBSCRIBE_URL + d
35
38
  )), l && (e = e.replace(
36
39
  p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
37
- R.PREFERENCES_URL + r
38
- )), E.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
40
+ y.PREFERENCES_URL + d
41
+ )), f.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
39
42
  },
40
43
  priority: 60
41
44
  },
@@ -52,25 +55,25 @@ const G = [
52
55
  id: "format-comment-braces",
53
56
  description: "Adding spaces around comment braces for proper formatting",
54
57
  type: "custom",
55
- processor: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
58
+ processor: (s) => s.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
56
59
  priority: 62
57
60
  },
58
61
  {
59
62
  id: "add-universal-link-flags",
60
63
  description: "Adding universal link flags",
61
64
  type: "custom",
62
- processor: (t) => {
63
- let i = t;
64
- const o = i.match(/<a[^>]+>(.*?)<\/a>/gm);
65
- return o && o.forEach((s) => {
66
- if (s.includes("insEmail=1"))
65
+ processor: (s) => {
66
+ let i = s;
67
+ const n = i.match(/<a[^>]+>(.*?)<\/a>/gm);
68
+ return n && n.forEach((t) => {
69
+ if (t.includes("insEmail=1"))
67
70
  return;
68
- if (s.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
69
- const a = s.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
70
- const r = e.slice(6, e.length - 1).trim();
71
- return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
71
+ if (t.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
72
+ const c = t.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
73
+ const e = r.slice(6, r.length - 1).trim();
74
+ return r.includes("?") || r.includes("#") ? e.slice(-1) === "&" ? r.replace(e, `${e}insEmail=1`) : r.replace(e, `${e}&insEmail=1`) : r.replace(e, `${e}?insEmail=1`);
72
75
  });
73
- i = i.replace(s, a);
76
+ i = i.replace(t, c);
74
77
  }
75
78
  }), i;
76
79
  },
@@ -78,5 +81,5 @@ const G = [
78
81
  }
79
82
  ];
80
83
  export {
81
- G as unsubscribeCompilerRules
84
+ F as unsubscribeCompilerRules
82
85
  };
@@ -1,40 +1,41 @@
1
- import { useConfig as S } from "../../../composables/useConfig.js";
2
- import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
- function y(e, u, r, o, s = "") {
4
- 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}}`;
5
6
  return o === "before" ? `${t} ${n}` : `${n} ${t}`;
6
7
  }
7
- function p(e, u, r, o, s, n) {
8
- switch (u) {
8
+ function f(r, c, e, o, s, n) {
9
+ switch (c) {
9
10
  case "productImage": {
10
- const t = e.querySelector("img");
11
- t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
12
- const c = e.querySelector("a");
13
- 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}}`);
14
15
  break;
15
16
  }
16
17
  case "productName": {
17
- const t = e.querySelector("p");
18
+ const t = r.querySelector("p");
18
19
  if (t) {
19
- const c = t.querySelector("strong") || t;
20
- c.textContent = `{{${n}${r}_${o}_name}}`;
20
+ const i = t.querySelector("strong") || t;
21
+ i.textContent = `{{${n}${e}_${o}_name}}`;
21
22
  }
22
23
  break;
23
24
  }
24
25
  case "productPrice": {
25
- const t = e.querySelector("p");
26
+ const t = r.querySelector("p");
26
27
  if (t) {
27
- const c = t.querySelector("strong") || t;
28
- c.textContent = y(r, o, "price", s, n);
28
+ const i = t.querySelector("strong") || t;
29
+ i.textContent = y(e, o, "price", s, n);
29
30
  }
30
31
  break;
31
32
  }
32
33
  case "productOldPrice": {
33
- const t = e.querySelector("p");
34
+ const t = r.querySelector("p");
34
35
  if (t) {
35
- const c = t.querySelector("strong") || t;
36
- c.textContent = y(
37
- r,
36
+ const i = t.querySelector("strong") || t;
37
+ i.textContent = y(
38
+ e,
38
39
  o,
39
40
  "original_price",
40
41
  s,
@@ -44,92 +45,127 @@ function p(e, u, r, o, s, n) {
44
45
  break;
45
46
  }
46
47
  case "productButton": {
47
- const t = e.querySelector("a");
48
- t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
48
+ const t = r.querySelector("a");
49
+ t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
49
50
  break;
50
51
  }
51
52
  case "productOmnibusPrice": {
52
- const t = e.querySelector(".omnibus-price-value");
53
+ const t = r.querySelector(".omnibus-price-value");
53
54
  if (t) {
54
- t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
55
- const c = t.closest("p");
56
- 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"));
57
58
  }
58
59
  break;
59
60
  }
60
61
  case "productOmnibusDiscount": {
61
- const t = e.querySelector(".omnibus-discount-value");
62
+ const t = r.querySelector(".omnibus-discount-value");
62
63
  if (t) {
63
- t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
64
- const c = t.closest("p");
65
- 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"));
66
67
  }
67
68
  break;
68
69
  }
69
70
  default: {
70
- const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
71
+ const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
71
72
  if (t) {
72
- const c = t.getAttribute("product-attr"), i = t.querySelector("p");
73
- if (i) {
74
- const a = i.querySelector("strong") || i;
75
- a.textContent = `{{${n}${r}_${o}_${c}}}`;
73
+ const i = t.getAttribute("product-attr"), a = t.querySelector("p");
74
+ if (a) {
75
+ const u = a.querySelector("strong") || a;
76
+ u.textContent = `{{${n}${e}_${o}_${i}}}`;
76
77
  }
77
78
  }
78
79
  break;
79
80
  }
80
81
  }
81
82
  }
82
- function d(e, u, r, o) {
83
- e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
84
- n.querySelectorAll("[data-attribute-type]").forEach((i) => {
85
- const a = i.getAttribute("data-attribute-type") || "", b = i.querySelectorAll(".attribute-cell");
86
- b.length > 0 ? b.forEach((l) => {
87
- p(l, a, u, t, r, o);
88
- }) : p(i, a, u, t, r, o);
83
+ function q(r, c, e, o) {
84
+ r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
85
+ n.querySelectorAll("[data-attribute-type]").forEach((a) => {
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);
89
90
  });
90
91
  });
91
92
  }
92
- function q(e, u, r, o) {
93
- const s = e.querySelectorAll(".recommendation-product-row");
93
+ function w(r, c, e, o) {
94
+ const s = r.querySelectorAll(".recommendation-product-row");
94
95
  if (!s.length)
95
96
  return;
96
- const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
97
- s.forEach((i, a) => {
98
- i.querySelectorAll("[data-attribute-type]").forEach((l) => {
99
- const m = l.getAttribute("data-attribute-type") || "";
100
- l.querySelectorAll(".attribute-cell").forEach(($, f) => {
101
- const A = a * c + f;
102
- p($, m, u, A, r, o);
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);
103
104
  });
104
105
  });
105
106
  });
106
107
  }
107
- function g(e, u, r, o) {
108
- e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
109
- q(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);
110
111
  });
111
112
  }
112
- function h(e, u, r) {
113
- const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
114
- o === "list" ? d(e, u, s, r) : g(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);
115
116
  }
116
- function C(e, u) {
117
- const r = e.match(/<!DOCTYPE[^>]*>/i);
118
- return (r ? `${r[0]}
119
- ` : "") + 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;
120
120
  }
121
- function P(e) {
122
- 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");
123
157
  if (!o.length)
124
- return e;
125
- const { buildCampaignUrl: s } = _(), { isFeatureEnabled: n } = S(), t = n("liquidSyntax") ? "reco_" : "";
126
- return o.forEach((i) => {
127
- var b, l;
128
- const a = i.getAttribute("recommendation-id");
129
- a && ((b = i.parentNode) == null || b.insertBefore(r.createComment("REC_START"), i), (l = i.parentNode) == null || l.insertBefore(r.createComment("REC_END"), i.nextSibling), s(a), h(i, a, t));
130
- }), C(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
158
+ return r;
159
+ const { buildCampaignUrl: s } = S(), n = _();
160
+ n.recommendationCampaignUrls = {};
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;", "%}");
131
167
  }
132
168
  export {
133
169
  y as formatPriceVariable,
134
- P as prepareRecommendationBlocks
170
+ O as prepareRecommendationBlocks
135
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
  };