@useinsider/guido 3.18.2-beta.eedafd2 → 3.18.2-beta.fc246a7
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 +0 -1
- package/dist/@types/config/schemas.js +26 -28
- package/dist/components/Guido.vue.js +8 -8
- package/dist/components/Guido.vue2.js +51 -53
- package/dist/components/organisms/AutoSaveController.vue2.js +8 -9
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +56 -86
- package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
- package/dist/components/organisms/header/LeftSlot.vue2.js +12 -16
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
- package/dist/components/wrappers/WpDrawer.vue.js +7 -9
- package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
- package/dist/composables/useHtmlCompiler.js +26 -37
- package/dist/composables/useHtmlValidator.js +0 -2
- package/dist/composables/useHttp.js +22 -24
- package/dist/composables/useSave.js +45 -90
- package/dist/composables/validators/useCouponBlockValidator.js +21 -24
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +27 -34
- package/dist/config/migrator/itemsBlockMigrator.js +257 -167
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +36 -43
- package/dist/guido.css +1 -1
- package/dist/services/templateLibraryApi.js +14 -17
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/components/Guido.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -17
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -17
- package/dist/src/components/wrappers/WpDrawer.vue.d.ts +3 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useHtmlValidator.d.ts +0 -21
- package/dist/src/composables/useSave.d.ts +1 -6
- package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -10
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
- package/dist/src/stores/config.d.ts +0 -30
- package/dist/src/utils/genericUtil.d.ts +0 -6
- package/dist/src/utils/templatePreparation.d.ts +0 -30
- package/dist/stores/config.js +22 -39
- package/dist/utils/genericUtil.js +54 -63
- package/dist/utils/pairProductVariables.js +71 -71
- package/dist/utils/templatePreparation.js +45 -49
- package/package.json +1 -1
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +0 -20
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +0 -48
- package/dist/composables/useSaveValidation.js +0 -279
- package/dist/composables/useSaveValidationRollout.js +0 -9
- package/dist/enums/save-validation.js +0 -4
- package/dist/src/@types/save-validation.d.ts +0 -19
- package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +0 -2
- package/dist/src/composables/useSaveValidation.d.ts +0 -6
- package/dist/src/composables/useSaveValidationRollout.d.ts +0 -3
- package/dist/src/enums/save-validation.d.ts +0 -27
- package/dist/src/stores/save-validation.d.ts +0 -22
- package/dist/src/utils/liquidDynamicContent.d.ts +0 -20
- package/dist/stores/save-validation.js +0 -30
- package/dist/utils/liquidDynamicContent.js +0 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ToasterTypeOptions as
|
|
1
|
+
import { ToasterTypeOptions as i } from "../../enums/toaster.js";
|
|
2
2
|
import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
|
|
3
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
4
|
-
import { useToaster as
|
|
5
|
-
import { useTranslations as
|
|
3
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
4
|
+
import { useToaster as E } from "../useToaster.js";
|
|
5
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
6
6
|
const T = [
|
|
7
7
|
{
|
|
8
8
|
pageType: u.GLOBAL_UNSUBSCRIBE,
|
|
@@ -12,37 +12,30 @@ const T = [
|
|
|
12
12
|
pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
|
|
13
13
|
messageKey: "unsubscription-preference.duplicate-pref-center"
|
|
14
14
|
}
|
|
15
|
-
], g = "unsubscription-preference.duplicate-both",
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return !n || !e;
|
|
28
|
-
}).length;
|
|
29
|
-
}
|
|
30
|
-
const y = () => {
|
|
31
|
-
const { showToaster: r } = p(), s = l();
|
|
32
|
-
return { validateUnsubscribeBlockUniqueness: (e) => {
|
|
33
|
-
const o = m(e);
|
|
34
|
-
return o.length ? (r({
|
|
35
|
-
type: c.Error,
|
|
36
|
-
message: s(o.length > 1 ? g : o[0].messageKey)
|
|
15
|
+
], g = "unsubscription-preference.duplicate-both", b = "unsubscription-preference.select-page-to-continue", P = () => {
|
|
16
|
+
const { showToaster: c } = E(), p = m();
|
|
17
|
+
return { validateUnsubscribeBlockUniqueness: (n) => {
|
|
18
|
+
const o = new DOMParser().parseFromString(n, "text/html"), r = /* @__PURE__ */ new Map();
|
|
19
|
+
o.querySelectorAll(l).forEach((e) => {
|
|
20
|
+
const s = Number(e.getAttribute(a.PAGE_TYPE));
|
|
21
|
+
r.set(s, (r.get(s) ?? 0) + 1);
|
|
22
|
+
});
|
|
23
|
+
const t = T.filter((e) => (r.get(e.pageType) ?? 0) > 1).map((e) => e.messageKey);
|
|
24
|
+
return t.length ? (c({
|
|
25
|
+
type: i.Error,
|
|
26
|
+
message: p(t.length > 1 ? g : t[0])
|
|
37
27
|
}), !1) : !0;
|
|
38
|
-
}, validateUnsubscribeBlockHasTemplate: (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
}, validateUnsubscribeBlockHasTemplate: (n) => {
|
|
29
|
+
const o = new DOMParser().parseFromString(n, "text/html");
|
|
30
|
+
return Array.from(o.querySelectorAll(l)).some((t) => {
|
|
31
|
+
const e = t.getAttribute(a.PAGE_TYPE), s = t.getAttribute(a.PAGE_LIST);
|
|
32
|
+
return !e || !s;
|
|
33
|
+
}) ? (c({
|
|
34
|
+
type: i.Warning,
|
|
35
|
+
message: p(b)
|
|
36
|
+
}), !1) : !0;
|
|
37
|
+
} };
|
|
42
38
|
};
|
|
43
39
|
export {
|
|
44
|
-
|
|
45
|
-
b as countUnsubBlocksWithoutPage,
|
|
46
|
-
m as findDuplicateUnsubPageTypes,
|
|
47
|
-
y as useUnsubscribeBlockValidator
|
|
40
|
+
P as useUnsubscribeBlockValidator
|
|
48
41
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { BLOCK_ID as
|
|
5
|
-
import { productPairs as
|
|
6
|
-
import { ItemInCartOptions as
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var B = (c, t, e) => t in c ? k(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var D = (c, t, e) => B(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { BLOCK_ID as q } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as E, DefaultConfigValues as I, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
7
|
import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
-
import { useTemplateStore as
|
|
9
|
-
const
|
|
8
|
+
import { useTemplateStore as U } from "../../stores/template.js";
|
|
9
|
+
const K = {
|
|
10
10
|
img: {
|
|
11
11
|
pairsKey: "imageSrc",
|
|
12
12
|
defaultKey: "DEFAULT",
|
|
@@ -73,126 +73,129 @@ const x = {
|
|
|
73
73
|
isArray: !1
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
function
|
|
76
|
+
function x() {
|
|
77
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
81
|
-
CartItems:
|
|
82
|
-
BrowsedItems:
|
|
83
|
-
PurchasedItems:
|
|
84
|
-
CART_ITEMS:
|
|
85
|
-
BROWSED_ITEMS:
|
|
86
|
-
PURCHASED_ITEMS:
|
|
87
|
-
}[
|
|
79
|
+
function M(c) {
|
|
80
|
+
return c ? {
|
|
81
|
+
CartItems: _.ITEMS_TYPE.CART_ITEMS,
|
|
82
|
+
BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
|
+
PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
|
+
CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
|
|
85
|
+
BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
|
+
PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
+
}[c] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
function O(c) {
|
|
90
|
+
return c.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : c.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
|
|
91
|
+
}
|
|
92
|
+
function P(c) {
|
|
93
|
+
var o;
|
|
94
|
+
const t = (u, n) => u == null ? n : u === "1" || u === "true", e = (u, n) => u || n, a = c["data-type"] || c["data-source"], r = M(a), l = E[r];
|
|
95
|
+
let i = c["data-cart_items_select_control_value"] || ((o = l == null ? void 0 : l[0]) == null ? void 0 : o.value) || I.cartItemsSelectControlValue;
|
|
96
|
+
if (i && !i.includes("{{") && /^\d+$/.test(i)) {
|
|
97
|
+
const u = parseInt(i) - 1, n = E[r];
|
|
98
|
+
n && n[u] && (i = n[u].value);
|
|
96
99
|
}
|
|
97
100
|
return {
|
|
98
101
|
initialized: !0,
|
|
99
|
-
blockInstanceId:
|
|
100
|
-
source:
|
|
101
|
-
type:
|
|
102
|
-
itemsSelectValue:
|
|
103
|
-
orientation:
|
|
104
|
-
nameTrimming: t(
|
|
105
|
-
priceHideDiscount: t(
|
|
106
|
-
priceFormatted: t(
|
|
107
|
-
priceSinglePrice: t(
|
|
108
|
-
priceCurrencySymbol:
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
blockInstanceId: e(c["data-block-instance-id"], x()),
|
|
103
|
+
source: r,
|
|
104
|
+
type: r,
|
|
105
|
+
itemsSelectValue: i,
|
|
106
|
+
orientation: c["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
|
|
107
|
+
nameTrimming: t(c["data-product_name_control_trim"], !0),
|
|
108
|
+
priceHideDiscount: t(c["data-product_price_control_nodup"], !0),
|
|
109
|
+
priceFormatted: t(c["data-product_price_control_formated"], !0),
|
|
110
|
+
priceSinglePrice: t(c["data-product_price_control_single_price"], !1),
|
|
111
|
+
priceCurrencySymbol: e(
|
|
112
|
+
c["data-product_price_control_currency_symbol"],
|
|
113
|
+
I.productPriceCurrencySymbolControlValue
|
|
111
114
|
),
|
|
112
|
-
priceCurrencyLocation:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
priceCurrencyLocation: e(
|
|
116
|
+
c["data-product_price_currency_location"],
|
|
117
|
+
I.productPriceCurrencyLocationControlValue
|
|
115
118
|
),
|
|
116
|
-
priceOrientation:
|
|
117
|
-
quantityControlEnabled: t(
|
|
118
|
-
buttonLink:
|
|
119
|
-
imageLink:
|
|
120
|
-
buttonLabel:
|
|
121
|
-
buttonFullWidth: t(
|
|
122
|
-
imageVisible: t(
|
|
123
|
-
nameVisible: t(
|
|
124
|
-
quantityVisible: t(
|
|
125
|
-
priceVisible: t(
|
|
126
|
-
originalPriceVisible: t(
|
|
127
|
-
buttonVisible: t(
|
|
119
|
+
priceOrientation: c["data-product_original_price_control_orientation"] || "horizontal",
|
|
120
|
+
quantityControlEnabled: t(c["data-product_quantity_control_enabled"], !0),
|
|
121
|
+
buttonLink: e(c["data-product_button_link"], I.productButtonLinkControlValue),
|
|
122
|
+
imageLink: e(c["data-product_image_link"], I.productImageLinkControlValue),
|
|
123
|
+
buttonLabel: e(c["data-product_button_control_label"], "Buy"),
|
|
124
|
+
buttonFullWidth: t(c["data-product_button_control_atw"], !0),
|
|
125
|
+
imageVisible: t(c["data-product_image_control_enabled"], !0),
|
|
126
|
+
nameVisible: t(c["data-product_name_control_enabled"], !0),
|
|
127
|
+
quantityVisible: t(c["data-product_quantity_control_enabled"], !0),
|
|
128
|
+
priceVisible: t(c["data-product_price_control_enabled"], !0),
|
|
129
|
+
originalPriceVisible: t(c["data-product_original_price_control_enabled"], !0),
|
|
130
|
+
buttonVisible: t(c["data-product_button_control_enabled"], !0)
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
|
-
const
|
|
133
|
+
const $ = {
|
|
131
134
|
ins_apr: "CART_ITEMS",
|
|
132
135
|
browsed_item: "BROWSED_ITEMS",
|
|
133
136
|
purchased_item: "PURCHASED_ITEMS"
|
|
134
137
|
};
|
|
135
|
-
function
|
|
136
|
-
const
|
|
138
|
+
function V(c, t) {
|
|
139
|
+
const e = {
|
|
137
140
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
138
141
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
139
142
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
140
143
|
};
|
|
141
|
-
return
|
|
144
|
+
return e[c] || e.CART_ITEMS;
|
|
142
145
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
146
|
+
function H(c, t) {
|
|
147
|
+
const e = {
|
|
145
148
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
146
149
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
147
150
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
148
151
|
};
|
|
149
|
-
return
|
|
152
|
+
return e[c] || e.CART_ITEMS;
|
|
150
153
|
}
|
|
151
|
-
class
|
|
154
|
+
class N {
|
|
152
155
|
constructor() {
|
|
153
|
-
|
|
156
|
+
D(this, "parser");
|
|
154
157
|
this.parser = new DOMParser();
|
|
155
158
|
}
|
|
156
159
|
migrate(t) {
|
|
157
160
|
try {
|
|
158
161
|
if (!this.containsItemsBlock(t))
|
|
159
162
|
return this.backfillV2ProductTdAttributes(t);
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
+
let e = this.removeJinjaConditionals(t);
|
|
164
|
+
e = this.replaceTemplateVariables(e);
|
|
165
|
+
const a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
|
|
163
166
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
164
167
|
);
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
}),
|
|
168
|
-
const
|
|
169
|
-
orientation:
|
|
170
|
-
itemsType:
|
|
171
|
-
itemId:
|
|
172
|
-
currencySymbol:
|
|
173
|
-
currencyLocation:
|
|
174
|
-
formattedPrice:
|
|
175
|
-
configBlockAttributes:
|
|
168
|
+
return U().$patch((i) => {
|
|
169
|
+
i.migrations = { ...i.migrations, [q]: r.length };
|
|
170
|
+
}), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (r.forEach((i) => {
|
|
171
|
+
const o = this.extractConfiguration(i), u = F({
|
|
172
|
+
orientation: o.orientation,
|
|
173
|
+
itemsType: o.itemsType,
|
|
174
|
+
itemId: o.itemId,
|
|
175
|
+
currencySymbol: o.currencySymbol,
|
|
176
|
+
currencyLocation: o.currencyLocation,
|
|
177
|
+
formattedPrice: o.formattedPrice,
|
|
178
|
+
configBlockAttributes: o.configBlockAttributes,
|
|
176
179
|
migrate: !0,
|
|
177
|
-
nameStyles:
|
|
178
|
-
buttonStyles:
|
|
179
|
-
priceStyles:
|
|
180
|
-
originalPriceStyles:
|
|
181
|
-
quantityStyles:
|
|
182
|
-
nodeConfig:
|
|
183
|
-
}),
|
|
184
|
-
`<table><tbody><tr>${
|
|
180
|
+
nameStyles: o.nameStyles,
|
|
181
|
+
buttonStyles: o.buttonStyles,
|
|
182
|
+
priceStyles: o.priceStyles,
|
|
183
|
+
originalPriceStyles: o.originalPriceStyles,
|
|
184
|
+
quantityStyles: o.quantityStyles,
|
|
185
|
+
nodeConfig: P(o.configBlockAttributes)
|
|
186
|
+
}), d = this.parser.parseFromString(
|
|
187
|
+
`<table><tbody><tr>${u}</tr></tbody></table>`,
|
|
185
188
|
"text/html"
|
|
186
189
|
).querySelector("td");
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
190
|
+
if (d && i.parentNode) {
|
|
191
|
+
const s = P(o.configBlockAttributes);
|
|
192
|
+
d.setAttribute("esd-ext-config", JSON.stringify(s)), d.setAttribute("data-type", s.type);
|
|
193
|
+
const p = d.querySelector("esd-config-block");
|
|
194
|
+
p && p.remove(), i.parentNode.replaceChild(d, i);
|
|
192
195
|
}
|
|
193
|
-
}),
|
|
194
|
-
} catch (
|
|
195
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
196
|
+
}), a.documentElement.outerHTML);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
return console.error("ItemsBlockMigrator failed:", e), t;
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
/**
|
|
@@ -202,28 +205,113 @@ class H {
|
|
|
202
205
|
* - UI styles from product elements (name, price, button, quantity, etc.)
|
|
203
206
|
*/
|
|
204
207
|
extractConfiguration(t) {
|
|
205
|
-
var C
|
|
206
|
-
const
|
|
207
|
-
(
|
|
208
|
-
),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
|
|
208
|
+
var C;
|
|
209
|
+
const e = M(
|
|
210
|
+
this.readSelfOrDescendantAttribute(t, "data-type") || O(t)
|
|
211
|
+
), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, l = E[e], i = ((C = l == null ? void 0 : l[r]) == null ? void 0 : C.value) || l[0].value, o = this.extractConfigBlockAttributes(t, e, a);
|
|
212
|
+
this.applyDomFallbacks(t, o);
|
|
213
|
+
const u = t.querySelector('[product-attr="price"]'), n = o["data-product_price_control_currency_symbol"], d = o["data-product_price_currency_location"] || "0", s = o["data-product_price_control_formated"], p = s !== "false" && s !== "0", S = o["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", y = t.querySelector('a[product-attr="name"]'), f = (y == null ? void 0 : y.getAttribute("style")) || void 0, m = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), A = (m == null ? void 0 : m.getAttribute("style")) || void 0, R = (u == null ? void 0 : u.getAttribute("style")) || void 0, g = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = g != null && g.getAttribute("style") ? g : (g == null ? void 0 : g.closest("p")) ?? g, w = (T == null ? void 0 : T.getAttribute("style")) || void 0, h = t.querySelector('[product-attr="quantity"]'), L = (h == null ? void 0 : h.getAttribute("style")) || void 0;
|
|
212
214
|
return {
|
|
213
215
|
orientation: S,
|
|
214
|
-
itemsType:
|
|
215
|
-
itemId:
|
|
216
|
-
currencySymbol:
|
|
217
|
-
currencyLocation:
|
|
218
|
-
formattedPrice:
|
|
219
|
-
configBlockAttributes:
|
|
220
|
-
nameStyles:
|
|
221
|
-
buttonStyles:
|
|
216
|
+
itemsType: e,
|
|
217
|
+
itemId: i,
|
|
218
|
+
currencySymbol: n,
|
|
219
|
+
currencyLocation: d,
|
|
220
|
+
formattedPrice: p,
|
|
221
|
+
configBlockAttributes: o,
|
|
222
|
+
nameStyles: f,
|
|
223
|
+
buttonStyles: A,
|
|
222
224
|
priceStyles: R,
|
|
223
|
-
originalPriceStyles:
|
|
224
|
-
quantityStyles:
|
|
225
|
+
originalPriceStyles: w,
|
|
226
|
+
quantityStyles: L
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
|
|
231
|
+
* the keys it ACTUALLY carries — every other key follows the live markup, whether the block
|
|
232
|
+
* was deleted outright or (far more common) survives carrying only a couple of `_opened`
|
|
233
|
+
* attributes. Without the per-key split, one such stub block shadows the whole DOM and the
|
|
234
|
+
* card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
|
|
235
|
+
*/
|
|
236
|
+
applyDomFallbacks(t, e) {
|
|
237
|
+
var b, S;
|
|
238
|
+
const a = t.querySelector("esd-config-block"), r = (...y) => !a || y.every((f) => !(a.getAttribute(f) ?? "").trim());
|
|
239
|
+
Object.entries({
|
|
240
|
+
image: '[product-attr="imageSrc"]',
|
|
241
|
+
name: '[product-attr="name"]',
|
|
242
|
+
price: '[product-attr="price"]',
|
|
243
|
+
original_price: '[product-attr="originalPrice"], p.original-price',
|
|
244
|
+
quantity: '[product-attr="quantity"]',
|
|
245
|
+
button: '[product-attr="button"]'
|
|
246
|
+
}).forEach(([y, f]) => {
|
|
247
|
+
const m = `data-product_${y}_control_enabled`;
|
|
248
|
+
r(m) && (e[m] = t.querySelector(f) ? "true" : "false");
|
|
249
|
+
}), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
|
|
250
|
+
const i = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (b = i == null ? void 0 : i.textContent) == null ? void 0 : b.replace(/\s+/g, " ").trim();
|
|
251
|
+
o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o), r("data-product_button_control_atw") && /display:\s*inline/.test((i == null ? void 0 : i.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
|
|
252
|
+
const u = t.querySelector('[product-attr="imageSrc"]'), n = u ? this.readImageSize(u) : null, d = (n == null ? void 0 : n.height) ?? (n == null ? void 0 : n.width), s = (n == null ? void 0 : n.width) ?? (n == null ? void 0 : n.height);
|
|
253
|
+
d && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = d), s && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = s), this.applyPriceDomFallbacks(t, e, r);
|
|
254
|
+
const p = ((S = t.querySelector('[product-attr="name"]')) == null ? void 0 : S.getAttribute("style")) || "";
|
|
255
|
+
r("data-product_name_control_trim") && /white-space:\s*normal/.test(p) && (e["data-product_name_control_trim"] = "0");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Carries the price cell's own currency/format attributes into the config attributes when
|
|
259
|
+
* the config block omits them. extractConfiguration used to read the cell separately for the
|
|
260
|
+
* rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
|
|
261
|
+
* ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
|
|
262
|
+
* the default back over the real value.
|
|
263
|
+
*/
|
|
264
|
+
applyPriceDomFallbacks(t, e, a) {
|
|
265
|
+
var n;
|
|
266
|
+
const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
|
|
267
|
+
if (!r)
|
|
268
|
+
return;
|
|
269
|
+
const l = (n = r.getAttribute("data-currency_symbol")) == null ? void 0 : n.trim();
|
|
270
|
+
l && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = l);
|
|
271
|
+
const i = r.getAttribute("data-curency");
|
|
272
|
+
if (i && a("data-product_price_currency_location", "data-product_price_control_curency")) {
|
|
273
|
+
const d = i === "after" ? "1" : "0";
|
|
274
|
+
e["data-product_price_currency_location"] = d, e["data-product_price_control_curency"] = d;
|
|
275
|
+
}
|
|
276
|
+
const o = r.getAttribute("data-formated");
|
|
277
|
+
o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
|
|
278
|
+
const u = r.getAttribute("data-single_price");
|
|
279
|
+
u && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = u);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Reads an attribute from the block element itself before falling back to a descendant.
|
|
283
|
+
* Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
|
|
284
|
+
* esd-config-block; when an author deletes the config block only the td's copy survives.
|
|
285
|
+
*/
|
|
286
|
+
readSelfOrDescendantAttribute(t, e) {
|
|
287
|
+
var a;
|
|
288
|
+
return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Reads the product image's pixel size — `width`/`height` attributes first, then px values
|
|
292
|
+
* in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
|
|
293
|
+
* upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
|
|
294
|
+
* be read from the property itself. Each side is null when it carries no pixel size.
|
|
295
|
+
*/
|
|
296
|
+
readImageSize(t) {
|
|
297
|
+
return {
|
|
298
|
+
width: this.readImageDimension(t, "width"),
|
|
299
|
+
height: this.readImageDimension(t, "height")
|
|
225
300
|
};
|
|
226
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* One side of readImageSize. `width="0"` is not a size — authors who override the real
|
|
304
|
+
* dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
|
|
305
|
+
* to nothing, so only a positive integer counts as an answer.
|
|
306
|
+
*/
|
|
307
|
+
readImageDimension(t, e) {
|
|
308
|
+
var n;
|
|
309
|
+
const a = (d) => !!d && /^\d+$/.test(d ?? "") && parseInt(d ?? "") > 0 ? d : null, r = a((n = t.getAttribute(e)) == null ? void 0 : n.trim());
|
|
310
|
+
if (r)
|
|
311
|
+
return r;
|
|
312
|
+
const l = t.getAttribute("style") || "", i = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+)px`), o = new RegExp(`max-${e}:\\s*(\\d+)px`), u = l.match(i) || l.match(o);
|
|
313
|
+
return a(u == null ? void 0 : u[1]);
|
|
314
|
+
}
|
|
227
315
|
/**
|
|
228
316
|
* Extracts all data-* attributes from the esd-config-block element
|
|
229
317
|
* Returns a key-value mapping of all configuration attributes
|
|
@@ -231,27 +319,27 @@ class H {
|
|
|
231
319
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
232
320
|
* @param itemNumber - The item number (1-based index)
|
|
233
321
|
*/
|
|
234
|
-
extractConfigBlockAttributes(t,
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
322
|
+
extractConfigBlockAttributes(t, e, a) {
|
|
323
|
+
const r = t.querySelector("esd-config-block"), l = {};
|
|
324
|
+
if (r) {
|
|
325
|
+
if (Array.from(r.attributes).forEach((o) => {
|
|
326
|
+
o.name.startsWith("data-") && (l[o.name] = o.value);
|
|
327
|
+
}), l["data-cart_items_select_control_value"]) {
|
|
328
|
+
const o = l["data-cart_items_select_control_value"];
|
|
329
|
+
if (/^\d+$/.test(o)) {
|
|
330
|
+
const u = parseInt(o) - 1, n = E[e];
|
|
331
|
+
n && n[u] && (l["data-cart_items_select_control_value"] = n[u].value);
|
|
332
|
+
}
|
|
245
333
|
}
|
|
334
|
+
if (l["data-product_price_control_curency"]) {
|
|
335
|
+
const o = l["data-product_price_control_curency"];
|
|
336
|
+
let u = o;
|
|
337
|
+
o === "before" ? u = "0" : o === "after" && (u = "1"), l["data-product_price_control_curency"] = u, l["data-product_price_currency_location"] = u;
|
|
338
|
+
}
|
|
339
|
+
(!l["data-product_price_control_currency_symbol"] || l["data-product_price_control_currency_symbol"].trim() === "") && (l["data-product_price_control_currency_symbol"] = "USD");
|
|
246
340
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
let l = e;
|
|
250
|
-
e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
|
|
251
|
-
}
|
|
252
|
-
(!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
|
|
253
|
-
const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
|
|
254
|
-
return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, c), n["data-product_button_link"] = N(r, c), n;
|
|
341
|
+
const i = { ...this.getDefaultConfigBlockAttributes(), ...l };
|
|
342
|
+
return i["data-type"] = e, i["data-source"] = e, i["data-product_image_link"] = V(e, a), i["data-product_button_link"] = H(e, a), i;
|
|
255
343
|
}
|
|
256
344
|
/**
|
|
257
345
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -325,25 +413,27 @@ class H {
|
|
|
325
413
|
backfillV2ProductTdAttributes(t) {
|
|
326
414
|
if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
|
|
327
415
|
return t;
|
|
328
|
-
const
|
|
329
|
-
let
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
416
|
+
const e = this.parser.parseFromString(t, "text/html");
|
|
417
|
+
let a = !1;
|
|
418
|
+
return e.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
419
|
+
r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0);
|
|
420
|
+
const l = r.querySelector("table.ins-product-wrapper");
|
|
421
|
+
l != null && l.hasAttribute("width") && l.getAttribute("width") !== "100%" && (l.setAttribute("width", "100%"), a = !0);
|
|
422
|
+
const i = r.getAttribute("esd-ext-config");
|
|
423
|
+
let o = null;
|
|
334
424
|
try {
|
|
335
|
-
|
|
425
|
+
o = i ? JSON.parse(i) : null;
|
|
336
426
|
} catch {
|
|
337
427
|
}
|
|
338
|
-
if (!
|
|
428
|
+
if (!o || (!r.getAttribute("data-nodup") && typeof o.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(o.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
|
|
339
429
|
return;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
430
|
+
const u = o.type || o.source;
|
|
431
|
+
if (!u)
|
|
342
432
|
return;
|
|
343
|
-
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
}),
|
|
433
|
+
r.setAttribute("data-type", u), a = !0;
|
|
434
|
+
const n = typeof o.itemsSelectValue == "string" ? o.itemsSelectValue.match(/\((\d+)\)/) : null;
|
|
435
|
+
n && r.getAttribute("data-number") !== n[1] && r.setAttribute("data-number", n[1]);
|
|
436
|
+
}), a ? e.documentElement.outerHTML : t;
|
|
347
437
|
}
|
|
348
438
|
/**
|
|
349
439
|
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
@@ -364,17 +454,17 @@ class H {
|
|
|
364
454
|
* contains display condition Jinja scripts that should NOT be removed.
|
|
365
455
|
*/
|
|
366
456
|
removeJinjaConditionals(t) {
|
|
367
|
-
const
|
|
368
|
-
let
|
|
369
|
-
return
|
|
457
|
+
const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
458
|
+
let r = a ? t.replace(a[0], e) : t;
|
|
459
|
+
return r = r.replace(
|
|
370
460
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
371
461
|
""
|
|
372
|
-
),
|
|
462
|
+
), r = r.replace(
|
|
373
463
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
374
464
|
""
|
|
375
|
-
),
|
|
465
|
+
), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
|
|
376
466
|
|
|
377
|
-
`),
|
|
467
|
+
`), r;
|
|
378
468
|
}
|
|
379
469
|
/**
|
|
380
470
|
* Replaces template variables with default values from productPairs
|
|
@@ -386,32 +476,32 @@ class H {
|
|
|
386
476
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
387
477
|
*/
|
|
388
478
|
replaceTemplateVariables(t) {
|
|
389
|
-
const { PAIRS_FOR_EXTENSION:
|
|
390
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
391
|
-
const
|
|
392
|
-
if (!
|
|
393
|
-
return
|
|
394
|
-
const [,
|
|
395
|
-
if (!
|
|
396
|
-
return console.warn(`Unknown variable prefix: ${
|
|
397
|
-
const
|
|
398
|
-
if (!
|
|
399
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
400
|
-
const { pairsKey:
|
|
479
|
+
const { PAIRS_FOR_EXTENSION: e } = v;
|
|
480
|
+
return t.replace(/{{([^}]+)}}/g, (a, r) => {
|
|
481
|
+
const l = r.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
482
|
+
if (!l)
|
|
483
|
+
return a;
|
|
484
|
+
const [, i, o, u] = l, n = $[i];
|
|
485
|
+
if (!n)
|
|
486
|
+
return console.warn(`Unknown variable prefix: ${i}`), a;
|
|
487
|
+
const d = K[o];
|
|
488
|
+
if (!d)
|
|
489
|
+
return console.warn(`Unknown variable suffix mapping for: ${o}`), a;
|
|
490
|
+
const { pairsKey: s, defaultKey: p, isArray: b } = d, y = e[s][n];
|
|
401
491
|
if (!y)
|
|
402
|
-
return console.warn(`No data found for: ${
|
|
492
|
+
return console.warn(`No data found for: ${s}.${n}`), a;
|
|
403
493
|
if (b) {
|
|
404
|
-
const
|
|
405
|
-
return Array.isArray(
|
|
494
|
+
const m = parseInt(u) - 1, A = y[p];
|
|
495
|
+
return Array.isArray(A) && A[m] ? A[m] : (console.warn(`Array value not found: ${s}.${n}.${p}[${m}]`), a);
|
|
406
496
|
}
|
|
407
|
-
const
|
|
408
|
-
return
|
|
497
|
+
const f = y[p];
|
|
498
|
+
return f !== void 0 ? String(f) : (console.warn(`Default value not found: ${s}.${n}.${p}`), a);
|
|
409
499
|
});
|
|
410
500
|
}
|
|
411
501
|
}
|
|
412
|
-
function
|
|
413
|
-
return new
|
|
502
|
+
function X(c) {
|
|
503
|
+
return new N().migrate(c);
|
|
414
504
|
}
|
|
415
505
|
export {
|
|
416
|
-
|
|
506
|
+
X as migrateItemsBlock
|
|
417
507
|
};
|