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