@useinsider/guido 3.2.0-beta.e01b42a → 3.2.0-beta.ec6228c
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/README.md +24 -0
- package/dist/@types/config/schemas.js +82 -68
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +92 -81
- package/dist/components/organisms/AutoSaveController.vue.js +17 -0
- package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
- package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
- package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
- package/dist/components/organisms/header/RightSlot.vue.js +11 -11
- package/dist/components/organisms/header/RightSlot.vue2.js +17 -13
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useAutoSave.js +68 -0
- package/dist/composables/useFullStoryBridge.js +14 -0
- package/dist/composables/useHtmlCompiler.js +23 -21
- package/dist/composables/useHtmlValidator.js +40 -38
- package/dist/composables/usePreviewMode.js +20 -16
- package/dist/composables/useSave.js +23 -15
- package/dist/composables/useStripo.js +52 -47
- package/dist/composables/validators/useLiquidValidator.js +42 -0
- package/dist/config/compiler/liquidCompilerRules.js +15 -0
- package/dist/config/compiler/recommendationCompilerRules.js +162 -43
- package/dist/config/compiler/unsubscribeCompilerRules.js +37 -37
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +52 -46
- package/dist/config/migrator/checkboxMigrator.js +5 -3
- package/dist/config/migrator/radioButtonMigrator.js +14 -12
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/enums/extensions/recommendationBlock.js +14 -11
- package/dist/enums/recommendation.js +2 -2
- package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +94 -92
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +31 -31
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +29 -25
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +15 -15
- package/dist/services/stripoApi.js +9 -9
- package/dist/services/templateLibraryApi.js +48 -46
- package/dist/src/@types/config/index.d.ts +1 -1
- package/dist/src/@types/config/schemas.d.ts +32 -0
- package/dist/src/@types/config/types.d.ts +3 -1
- package/dist/src/@types/generic.d.ts +0 -1
- package/dist/src/@types/save-as-template.d.ts +1 -0
- package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
- package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useAutoSave.d.ts +3 -0
- package/dist/src/composables/useConfig.d.ts +14 -0
- package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
- package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
- package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +3 -3
- package/dist/src/services/templateLibraryApi.d.ts +1 -1
- package/dist/src/stores/autosave.d.ts +6 -0
- package/dist/src/stores/config.d.ts +126 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/genericUtil.d.ts +1 -1
- package/dist/src/utils/htmlCompiler.d.ts +2 -1
- package/dist/src/utils/timeUtil.d.ts +8 -0
- package/dist/static/styles/base.css.js +7 -2
- package/dist/static/styles/components/button.css.js +3 -2
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/stores/autosave.js +11 -0
- package/dist/stores/preview.js +4 -3
- package/dist/utils/genericUtil.js +42 -20
- package/dist/utils/htmlCompiler.js +48 -41
- package/dist/utils/templatePreparation.js +36 -25
- package/dist/utils/timeUtil.js +19 -0
- package/dist/utils/tooltipUtils.js +4 -5
- package/package.json +3 -3
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
3
|
-
import { prepareRecommendationBlocks as
|
|
4
|
-
const
|
|
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";
|
|
3
|
+
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
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: (
|
|
10
|
-
let
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(l).forEach(([n,
|
|
13
|
-
|
|
9
|
+
processor: (c) => {
|
|
10
|
+
let e = c;
|
|
11
|
+
return Object.entries(h).forEach(([, l]) => {
|
|
12
|
+
Object.entries(l).forEach(([n, s]) => {
|
|
13
|
+
e = e.replaceAll(s, `{{${n}}}`);
|
|
14
14
|
});
|
|
15
|
-
}),
|
|
15
|
+
}), e;
|
|
16
16
|
},
|
|
17
17
|
priority: 50
|
|
18
18
|
},
|
|
@@ -29,18 +29,18 @@ const G = [
|
|
|
29
29
|
id: "add-recommendation-unresponsive-css",
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
|
-
processor: (
|
|
33
|
-
const { calculateCardWidth:
|
|
34
|
-
let n =
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
}),
|
|
42
|
-
const
|
|
43
|
-
n = n.replace(
|
|
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
|
+
const a = [];
|
|
38
|
+
if (s.forEach((i) => {
|
|
39
|
+
const d = /recommendation-id="(.*?)"/i.exec(i), _ = d ? d[1].trim() : "", R = l(_);
|
|
40
|
+
R.textTrimming && R.orientation === M && a.push(e(R));
|
|
41
|
+
}), a.length) {
|
|
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
46
|
return n;
|
|
@@ -51,39 +51,158 @@ const G = [
|
|
|
51
51
|
id: "prepare-recommendations",
|
|
52
52
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
53
|
type: "custom",
|
|
54
|
-
processor: (
|
|
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: (
|
|
62
|
-
let
|
|
63
|
-
const l =
|
|
64
|
-
return l !== null && l.forEach((
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
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
|
+
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [
|
|
69
|
-
if (!
|
|
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)
|
|
70
70
|
return;
|
|
71
|
-
const [
|
|
72
|
-
let
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
71
|
+
const [S] = d, [b] = _, [m] = R, o = b.substring(1, b.length - 2), r = m.match(T.COMPOSITION) !== null;
|
|
72
|
+
let t = i;
|
|
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}`));
|
|
76
76
|
}
|
|
77
|
-
const
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
}),
|
|
77
|
+
const u = S.substring(2);
|
|
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);
|
|
82
|
+
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "strip-empty-omnibus-spans",
|
|
88
|
+
description: "Remove empty omnibus text-before and text-after span elements",
|
|
89
|
+
type: "regex",
|
|
90
|
+
pattern: '<span class="omnibus-text-(?:before|after)">\\s*</span>',
|
|
91
|
+
replacement: "",
|
|
92
|
+
flags: "g",
|
|
93
|
+
priority: 54
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "strip-recommendation-editor-attributes",
|
|
97
|
+
description: "Strip editor-only attributes from compiled recommendation output",
|
|
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
|
+
},
|
|
108
|
+
priority: 55
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "strip-unused-recommendation-classes",
|
|
112
|
+
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
113
|
+
type: "custom",
|
|
114
|
+
processor: (c) => {
|
|
115
|
+
let e = c.replace(
|
|
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,
|
|
117
|
+
""
|
|
118
|
+
);
|
|
119
|
+
return e = e.replaceAll("es-button buy-button", "es-button"), e = e.replaceAll("ins-recommendation-product-container ", ""), e;
|
|
120
|
+
},
|
|
121
|
+
priority: 56
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "remove-empty-mobile-layout-artifacts",
|
|
125
|
+
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
126
|
+
type: "custom",
|
|
127
|
+
processor: (c) => {
|
|
128
|
+
let e = c;
|
|
129
|
+
return e = e.replace(
|
|
130
|
+
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
131
|
+
""
|
|
132
|
+
), /class="[^"]*ins-recommendation-mobile-container/.test(e) || (e = e.replace(
|
|
133
|
+
/\.ins-recommendation-mobile-container\s*\{\s*display\s*:\s*none\s*;?\s*\}/g,
|
|
134
|
+
""
|
|
135
|
+
), e = e.replace(
|
|
136
|
+
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
137
|
+
(l, n) => {
|
|
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;
|
|
140
|
+
}
|
|
141
|
+
)), e;
|
|
142
|
+
},
|
|
143
|
+
priority: 57
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "deduplicate-inline-styles",
|
|
147
|
+
description: "Replace repeated inline styles with CSS class references within recommendation blocks",
|
|
148
|
+
type: "custom",
|
|
149
|
+
processor: (c) => {
|
|
150
|
+
const e = c.replace(
|
|
151
|
+
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
152
|
+
(o) => o.replace(
|
|
153
|
+
/([;"]color:)([^;"]+)/g,
|
|
154
|
+
(r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
|
|
155
|
+
)
|
|
156
|
+
), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
|
|
157
|
+
let a = l.exec(e);
|
|
158
|
+
for (; a !== null; ) {
|
|
159
|
+
let o = n.exec(a[1]);
|
|
160
|
+
for (; o !== null; ) {
|
|
161
|
+
const [, r] = o;
|
|
162
|
+
s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
|
|
163
|
+
}
|
|
164
|
+
n.lastIndex = 0, a = l.exec(e);
|
|
165
|
+
}
|
|
166
|
+
const i = /* @__PURE__ */ new Map(), d = [];
|
|
167
|
+
let _ = 0;
|
|
168
|
+
if (s.forEach((o, r) => {
|
|
169
|
+
if (o >= 6) {
|
|
170
|
+
const t = `rc${_++}`;
|
|
171
|
+
i.set(r, t), d.push(`.${t}{${r}}`);
|
|
172
|
+
}
|
|
173
|
+
}), i.size === 0) {
|
|
174
|
+
let o = e;
|
|
175
|
+
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
176
|
+
}
|
|
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, {
|
|
181
|
+
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
182
|
+
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
let m = e.replace("</style>", `${d.join("")}</style>`);
|
|
186
|
+
return m = m.replace(
|
|
187
|
+
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
188
|
+
(o, r) => {
|
|
189
|
+
let t = r;
|
|
190
|
+
return i.forEach((u, f) => {
|
|
191
|
+
const $ = b.get(f);
|
|
192
|
+
t = t.replace(
|
|
193
|
+
$.caseA,
|
|
194
|
+
(y, I, p) => S(I, u) + p
|
|
195
|
+
), t = t.replace(
|
|
196
|
+
$.caseB,
|
|
197
|
+
(y, I, p) => I + S(p, u)
|
|
198
|
+
), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
|
|
199
|
+
}), t;
|
|
200
|
+
}
|
|
201
|
+
), m = m.replaceAll("<!--REC_START-->", ""), m = m.replaceAll("<!--REC_END-->", ""), m;
|
|
202
|
+
},
|
|
203
|
+
priority: 58
|
|
85
204
|
}
|
|
86
205
|
];
|
|
87
206
|
export {
|
|
88
|
-
|
|
207
|
+
w as recommendationCompilerRules
|
|
89
208
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { usePartner as
|
|
2
|
-
import { LINK_REGEXES as
|
|
3
|
-
import { parsePageList as
|
|
4
|
-
import { useConfigStore as
|
|
5
|
-
import { useDynamicContentStore as
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
const
|
|
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 = [
|
|
8
8
|
{
|
|
9
9
|
id: "add-unsubscribe-link-values",
|
|
10
10
|
description: "Adding unsubscribe link values",
|
|
11
11
|
type: "custom",
|
|
12
12
|
processor: (t) => {
|
|
13
|
-
const { getPartnerName: i } =
|
|
13
|
+
const { getPartnerName: i } = y(), o = N(), s = U(), d = C(), a = o.variationId;
|
|
14
14
|
if (!a)
|
|
15
15
|
return t;
|
|
16
16
|
let e = t;
|
|
17
|
-
const r = `/${i()}/email/${a}?user={{iid}}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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");
|
|
22
|
+
if (!u)
|
|
22
23
|
return;
|
|
23
|
-
const
|
|
24
|
-
(
|
|
25
|
-
)) ?? []
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}), e;
|
|
24
|
+
const _ = I(u), g = ((b = d.templates) == null ? void 0 : b.filter(
|
|
25
|
+
(n) => _.includes(n.id)
|
|
26
|
+
)) ?? [];
|
|
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({
|
|
29
|
+
text: m,
|
|
30
|
+
value: m,
|
|
31
|
+
fallback: ""
|
|
32
|
+
})), c && (e = e.replace(
|
|
33
|
+
p.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
|
|
34
|
+
R.UNSUBSCRIBE_URL + r
|
|
35
|
+
)), l && (e = e.replace(
|
|
36
|
+
p.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
|
|
37
|
+
R.PREFERENCES_URL + r
|
|
38
|
+
)), E.length && (e = e.replace(p.UNSUBSCRIBE_LINK_REGEX, "")), e;
|
|
39
39
|
},
|
|
40
40
|
priority: 60
|
|
41
41
|
},
|
|
@@ -43,7 +43,7 @@ const D = [
|
|
|
43
43
|
id: "remove-data-ogsb-button-styles",
|
|
44
44
|
description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
|
|
45
45
|
type: "regex",
|
|
46
|
-
pattern:
|
|
46
|
+
pattern: p.DATA_OGSB_BUTTON_CSS_REGEX,
|
|
47
47
|
replacement: "",
|
|
48
48
|
flags: "g",
|
|
49
49
|
priority: 61
|
|
@@ -61,16 +61,16 @@ const D = [
|
|
|
61
61
|
type: "custom",
|
|
62
62
|
processor: (t) => {
|
|
63
63
|
let i = t;
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
if (
|
|
64
|
+
const o = i.match(/<a[^>]+>(.*?)<\/a>/gm);
|
|
65
|
+
return o && o.forEach((s) => {
|
|
66
|
+
if (s.includes("insEmail=1"))
|
|
67
67
|
return;
|
|
68
|
-
if (
|
|
69
|
-
const a =
|
|
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
70
|
const r = e.slice(6, e.length - 1).trim();
|
|
71
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`);
|
|
72
72
|
});
|
|
73
|
-
i = i.replace(
|
|
73
|
+
i = i.replace(s, a);
|
|
74
74
|
}
|
|
75
75
|
}), i;
|
|
76
76
|
},
|
|
@@ -78,5 +78,5 @@ const D = [
|
|
|
78
78
|
}
|
|
79
79
|
];
|
|
80
80
|
export {
|
|
81
|
-
|
|
81
|
+
G as unsubscribeCompilerRules
|
|
82
82
|
};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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}}`;
|
|
4
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
8
|
+
function m(e, u, r, o, s, n) {
|
|
7
9
|
switch (u) {
|
|
8
10
|
case "productImage": {
|
|
9
11
|
const t = e.querySelector("img");
|
|
10
|
-
t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
|
|
12
|
+
t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
|
|
11
13
|
const c = e.querySelector("a");
|
|
12
|
-
c && c.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
14
|
+
c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
13
15
|
break;
|
|
14
16
|
}
|
|
15
17
|
case "productName": {
|
|
16
18
|
const t = e.querySelector("p");
|
|
17
19
|
if (t) {
|
|
18
20
|
const c = t.querySelector("strong") || t;
|
|
19
|
-
c.textContent = `{{${r}_${o}_name}}`;
|
|
21
|
+
c.textContent = `{{${n}${r}_${o}_name}}`;
|
|
20
22
|
}
|
|
21
23
|
break;
|
|
22
24
|
}
|
|
@@ -24,7 +26,7 @@ function p(e, u, r, o, n) {
|
|
|
24
26
|
const t = e.querySelector("p");
|
|
25
27
|
if (t) {
|
|
26
28
|
const c = t.querySelector("strong") || t;
|
|
27
|
-
c.textContent =
|
|
29
|
+
c.textContent = y(r, o, "price", s, n);
|
|
28
30
|
}
|
|
29
31
|
break;
|
|
30
32
|
}
|
|
@@ -32,10 +34,11 @@ function p(e, u, r, o, n) {
|
|
|
32
34
|
const t = e.querySelector("p");
|
|
33
35
|
if (t) {
|
|
34
36
|
const c = t.querySelector("strong") || t;
|
|
35
|
-
c.textContent =
|
|
37
|
+
c.textContent = y(
|
|
36
38
|
r,
|
|
37
39
|
o,
|
|
38
40
|
"original_price",
|
|
41
|
+
s,
|
|
39
42
|
n
|
|
40
43
|
), t.setAttribute("product-attr", "discount");
|
|
41
44
|
}
|
|
@@ -43,13 +46,13 @@ function p(e, u, r, o, n) {
|
|
|
43
46
|
}
|
|
44
47
|
case "productButton": {
|
|
45
48
|
const t = e.querySelector("a");
|
|
46
|
-
t && t.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
49
|
+
t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
47
50
|
break;
|
|
48
51
|
}
|
|
49
52
|
case "productOmnibusPrice": {
|
|
50
53
|
const t = e.querySelector(".omnibus-price-value");
|
|
51
54
|
if (t) {
|
|
52
|
-
t.textContent = `{{${r}_${o}_omnibus_price}}`;
|
|
55
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
|
|
53
56
|
const c = t.closest("p");
|
|
54
57
|
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
55
58
|
}
|
|
@@ -58,7 +61,7 @@ function p(e, u, r, o, n) {
|
|
|
58
61
|
case "productOmnibusDiscount": {
|
|
59
62
|
const t = e.querySelector(".omnibus-discount-value");
|
|
60
63
|
if (t) {
|
|
61
|
-
t.textContent = `{{${r}_${o}_omnibus_discount}}`;
|
|
64
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
|
|
62
65
|
const c = t.closest("p");
|
|
63
66
|
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
64
67
|
}
|
|
@@ -67,66 +70,69 @@ function p(e, u, r, o, n) {
|
|
|
67
70
|
default: {
|
|
68
71
|
const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
|
|
69
72
|
if (t) {
|
|
70
|
-
const c = t.getAttribute("product-attr"),
|
|
71
|
-
if (
|
|
72
|
-
const i =
|
|
73
|
-
i.textContent = `{{${r}_${o}_${c}}}`;
|
|
73
|
+
const c = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
|
+
if (a) {
|
|
75
|
+
const i = a.querySelector("strong") || a;
|
|
76
|
+
i.textContent = `{{${n}${r}_${o}_${c}}}`;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
break;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
function
|
|
83
|
+
function q(e, u, r, o) {
|
|
81
84
|
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
82
|
-
n.querySelectorAll("[data-attribute-type]").forEach((
|
|
83
|
-
const i =
|
|
84
|
-
l.length > 0 ? l.forEach((
|
|
85
|
-
p
|
|
86
|
-
}) :
|
|
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);
|
|
87
90
|
});
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
93
|
+
function g(e, u, r, o) {
|
|
94
|
+
const s = e.querySelectorAll(".recommendation-product-row");
|
|
95
|
+
if (!s.length)
|
|
93
96
|
return;
|
|
94
|
-
const [n] =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
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);
|
|
101
104
|
});
|
|
102
105
|
});
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
|
-
function
|
|
108
|
+
function h(e, u, r, o) {
|
|
106
109
|
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
107
|
-
|
|
110
|
+
g(n, u, r, o);
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
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
116
|
}
|
|
114
|
-
function
|
|
117
|
+
function E(e, u) {
|
|
115
118
|
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
116
119
|
return (r ? `${r[0]}
|
|
117
120
|
` : "") + u.documentElement.outerHTML;
|
|
118
121
|
}
|
|
119
|
-
function
|
|
122
|
+
function T(e) {
|
|
120
123
|
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
|
|
121
124
|
if (!o.length)
|
|
122
125
|
return e;
|
|
123
|
-
const { buildCampaignUrl:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const { buildCampaignUrl: s } = _(), n = d();
|
|
127
|
+
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("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
128
134
|
}
|
|
129
135
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
y as formatPriceVariable,
|
|
137
|
+
T as prepareRecommendationBlocks
|
|
132
138
|
};
|
|
@@ -11,6 +11,8 @@ class f {
|
|
|
11
11
|
try {
|
|
12
12
|
const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
|
|
13
13
|
return i.length === 0 ? t : (i.forEach((r) => {
|
|
14
|
+
if (r.classList.contains("checkbox-block-v2"))
|
|
15
|
+
return;
|
|
14
16
|
const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
|
|
15
17
|
`<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
|
|
16
18
|
"text/html"
|
|
@@ -22,7 +24,7 @@ class f {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
extractTextFromElement(t, e) {
|
|
25
|
-
var o,
|
|
27
|
+
var o, d;
|
|
26
28
|
const i = t.querySelector(`.${e}`);
|
|
27
29
|
if (!i)
|
|
28
30
|
return {
|
|
@@ -41,13 +43,13 @@ class f {
|
|
|
41
43
|
align: i.getAttribute("align") || "left",
|
|
42
44
|
styles: ""
|
|
43
45
|
};
|
|
44
|
-
const n = ((
|
|
46
|
+
const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
|
|
45
47
|
return {
|
|
46
48
|
text: n,
|
|
47
49
|
isBold: a,
|
|
48
50
|
isItalic: p,
|
|
49
51
|
align: c,
|
|
50
|
-
styles:
|
|
52
|
+
styles: u
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
buildTextBlock(t) {
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var f = (r, t, e) => t in r ?
|
|
3
|
-
var
|
|
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
4
|
import h from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
5
|
class T {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
7
|
+
b(this, "parser");
|
|
8
8
|
this.parser = new DOMParser();
|
|
9
9
|
}
|
|
10
10
|
migrate(t) {
|
|
11
11
|
try {
|
|
12
12
|
const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
|
|
13
13
|
return i.length === 0 ? t : (i.forEach((s) => {
|
|
14
|
-
|
|
14
|
+
if (s.classList.contains("radio-button-v2"))
|
|
15
|
+
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(
|
|
15
17
|
`<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
|
|
16
18
|
"text/html"
|
|
17
19
|
).querySelector(".radio-button-v2");
|
|
18
|
-
y && s.parentNode && (y.setAttribute("id",
|
|
20
|
+
y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
|
|
19
21
|
}), e.documentElement.outerHTML);
|
|
20
22
|
} catch (e) {
|
|
21
23
|
return console.error("RadioButtonMigrator failed:", e), t;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
extractTextFromElement(t, e) {
|
|
25
|
-
var
|
|
27
|
+
var o, c;
|
|
26
28
|
const i = t.querySelector(`.${e}`);
|
|
27
29
|
if (!i)
|
|
28
30
|
return {
|
|
@@ -36,16 +38,16 @@ class T {
|
|
|
36
38
|
const s = i.querySelector("p");
|
|
37
39
|
if (!s)
|
|
38
40
|
return {
|
|
39
|
-
text: ((
|
|
41
|
+
text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
|
|
40
42
|
isBold: !1,
|
|
41
43
|
isItalic: !1,
|
|
42
44
|
align: i.getAttribute("align") || "left",
|
|
43
45
|
styles: "",
|
|
44
46
|
classList: ""
|
|
45
47
|
};
|
|
46
|
-
const
|
|
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") || "";
|
|
47
49
|
return {
|
|
48
|
-
text:
|
|
50
|
+
text: n,
|
|
49
51
|
isBold: p,
|
|
50
52
|
isItalic: u,
|
|
51
53
|
align: a,
|
|
@@ -66,8 +68,8 @@ class T {
|
|
|
66
68
|
`;
|
|
67
69
|
}
|
|
68
70
|
removeStyleProperties(t, e) {
|
|
69
|
-
return t ? e.reduce((s,
|
|
70
|
-
const l = new RegExp(`${
|
|
71
|
+
return t ? e.reduce((s, n) => {
|
|
72
|
+
const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
71
73
|
return s.replace(l, "");
|
|
72
74
|
}, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
73
75
|
}
|