@useinsider/guido 3.9.1-beta.c521c3a → 3.9.1-beta.c64c39e

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.
@@ -1,30 +1,30 @@
1
- import { useConfig as _ } from "../../../composables/useConfig.js";
2
- import { useRecommendation as q } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as C } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as E } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
- function P(t, r, e, n, s = "") {
7
- const c = `{{${s}${t}_${r}_${e}}}`, o = `{{${s}${t}_${r}_currency}}`;
8
- return n === "before" ? `${o} ${c}` : `${c} ${o}`;
9
- }
10
- function m(t) {
1
+ import { useConfig as C } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as E } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as w } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
6
+ function R(t, r, e, o, s = "") {
7
+ const i = `{{${s}${t}_${r}_${e}}}`, n = `{{${s}${t}_${r}_currency}}`;
8
+ return o === "before" ? `${n} ${i}` : `${i} ${n}`;
9
+ }
10
+ function y(t) {
11
11
  let r = t;
12
12
  for (; r.children.length === 1; )
13
13
  [r] = r.children;
14
14
  return r;
15
15
  }
16
- function b(t, r, e, n, s, c) {
16
+ function A(t, r, e, o, s, i) {
17
17
  switch (r) {
18
18
  case "productImage": {
19
- const o = t.querySelector("img");
20
- o && (o.setAttribute("src", `{{${c}${e}_${n}_image_url}}`), o.setAttribute("alt", `{{${c}${e}_${n}_name}}`));
21
- const i = t.querySelector("a");
22
- i && (i.setAttribute("href", `{{${c}${e}_${n}_url}}`), i.classList.add(C));
19
+ const n = t.querySelector("img");
20
+ n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
+ const c = t.querySelector("a");
22
+ c && (c.setAttribute("href", `{{${i}${e}_${o}_url}}`), c.classList.add(q));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const o = t.querySelector("p");
27
- o && (m(o).textContent = `{{${c}${e}_${n}_name}}`);
26
+ const n = t.querySelector("p");
27
+ n && (y(n).textContent = `{{${i}${e}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  // Inline mode ("Move to next line" OFF) merges BOTH prices into one row
@@ -32,145 +32,176 @@ function b(t, r, e, n, s, c) {
32
32
  // substitute by cell content, not by the row's anchor (SD-145161).
33
33
  case "productPrice":
34
34
  case "productOldPrice": {
35
- const o = (d, l) => {
36
- d && (m(d).textContent = P(
35
+ const n = (l, d) => {
36
+ l && (y(l).textContent = R(
37
37
  e,
38
- n,
39
- l,
38
+ o,
39
+ d,
40
40
  s,
41
- c
41
+ i
42
42
  ));
43
- }, i = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !i && !a ? t.querySelector("p") : null;
44
- o(i ?? (r === "productPrice" ? u : null), "price"), o(a ?? (r === "productOldPrice" ? u : null), "original_price");
43
+ }, c = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !c && !a ? t.querySelector("p") : null;
44
+ n(c ?? (r === "productPrice" ? u : null), "price"), n(a ?? (r === "productOldPrice" ? u : null), "original_price");
45
45
  break;
46
46
  }
47
47
  case "productButton": {
48
- const o = t.querySelector("a");
49
- o && o.setAttribute("href", `{{${c}${e}_${n}_url}}`);
48
+ const n = t.querySelector("a");
49
+ n && n.setAttribute("href", `{{${i}${e}_${o}_url}}`);
50
50
  break;
51
51
  }
52
52
  case "productOmnibusPrice": {
53
- const o = t.querySelector(".omnibus-price-value");
54
- if (o) {
55
- o.textContent = `{{${c}${e}_${n}_omnibus_price}}`;
56
- const i = o.closest("p");
57
- i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
53
+ const n = t.querySelector(".omnibus-price-value");
54
+ if (n) {
55
+ n.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
56
+ const c = n.closest("p");
57
+ c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
58
58
  }
59
59
  break;
60
60
  }
61
61
  case "productOmnibusDiscount": {
62
- const o = t.querySelector(".omnibus-discount-value");
63
- if (o) {
64
- o.textContent = `{{${c}${e}_${n}_omnibus_discount}}`;
65
- const i = o.closest("p");
66
- i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
62
+ const n = t.querySelector(".omnibus-discount-value");
63
+ if (n) {
64
+ n.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
65
+ const c = n.closest("p");
66
+ c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
67
67
  }
68
68
  break;
69
69
  }
70
70
  default: {
71
- const o = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
- if (o) {
73
- const i = o.getAttribute("product-attr"), a = o.querySelector("p");
74
- a && (m(a).textContent = `{{${c}${e}_${n}_${i}}}`);
71
+ const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
72
+ if (n) {
73
+ const c = n.getAttribute("product-attr"), a = n.querySelector("p");
74
+ a && (y(a).textContent = `{{${i}${e}_${o}_${c}}}`);
75
75
  }
76
76
  break;
77
77
  }
78
78
  }
79
79
  }
80
- function R(t, r, e, n) {
81
- t.querySelectorAll(".recommendation-product-row").forEach((c, o) => {
82
- c.querySelectorAll("[data-attribute-type]").forEach((a) => {
83
- const u = a.getAttribute("data-attribute-type") || "", d = a.querySelectorAll(".attribute-cell");
84
- d.length > 0 ? d.forEach((l) => {
85
- b(l, u, r, o, e, n);
86
- }) : b(a, u, r, o, e, n);
87
- });
80
+ const B = "name";
81
+ function S(t, r, e, o) {
82
+ const s = `${o}${r}_${e}_${B}`;
83
+ return {
84
+ open: t.createComment(`{% if ${s} and ${s} != "" %}`),
85
+ close: t.createComment("{% endif %}")
86
+ };
87
+ }
88
+ function L(t, r, e) {
89
+ return S(t, r, 0, e);
90
+ }
91
+ function N(t, r, e, o) {
92
+ if (!t.innerHTML.includes("{{"))
93
+ return;
94
+ const { open: s, close: i } = S(t.ownerDocument, r, e, o);
95
+ t.insertBefore(s, t.firstChild), t.appendChild(i);
96
+ }
97
+ function T(t, r, e, o) {
98
+ var n, c;
99
+ if (!t.innerHTML.includes("{{"))
100
+ return;
101
+ const { open: s, close: i } = S(t.ownerDocument, r, e, o);
102
+ (n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
103
+ }
104
+ function v(t, r, e, o) {
105
+ t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
106
+ i.querySelectorAll("[data-attribute-type]").forEach((a) => {
107
+ const u = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
108
+ l.length > 0 ? l.forEach((d) => {
109
+ A(d, u, r, n, e, o);
110
+ }) : A(a, u, r, n, e, o);
111
+ }), T(i, r, n, o);
88
112
  });
89
113
  }
90
- function W(t, r, e, n) {
114
+ function O(t, r, e, o) {
91
115
  const s = t.querySelectorAll(".recommendation-product-row");
92
116
  if (!s.length)
93
117
  return;
94
- const [c] = s, o = c.querySelector("[data-attribute-type]"), i = o ? o.querySelectorAll(".attribute-cell").length : 1;
118
+ const [i] = s, n = i.querySelector("[data-attribute-type]"), c = n ? n.querySelectorAll(".attribute-cell").length : 1;
95
119
  s.forEach((a, u) => {
96
- a.querySelectorAll("[data-attribute-type]").forEach((l) => {
97
- const p = l.getAttribute("data-attribute-type") || "";
98
- l.querySelectorAll(".attribute-cell").forEach(($, S) => {
99
- const g = u * i + S;
100
- b($, p, r, g, e, n);
120
+ a.querySelectorAll("[data-attribute-type]").forEach((d) => {
121
+ const p = d.getAttribute("data-attribute-type") || "";
122
+ d.querySelectorAll(".attribute-cell").forEach((m, f) => {
123
+ const h = u * c + f;
124
+ A(m, p, r, h, e, o), N(m, r, h, o);
101
125
  });
102
126
  });
103
127
  });
104
128
  }
105
- function v(t, r, e, n) {
106
- t.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
107
- W(c, r, e, n);
129
+ function W(t, r, e, o) {
130
+ t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
131
+ O(i, r, e, o);
108
132
  });
109
133
  }
110
- function O(t, r, e) {
111
- const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
112
- n === "list" ? R(t, r, s, e) : v(t, r, s, e);
134
+ function D(t, r, e) {
135
+ const o = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
136
+ o === "list" ? v(t, r, s, e) : W(t, r, s, e);
113
137
  }
114
- function f(t, r, e) {
115
- const n = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
138
+ function $(t, r, e) {
139
+ const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(o);
116
140
  return s ? parseInt(s[1]) : e;
117
141
  }
118
- function y(t) {
142
+ function _(t) {
119
143
  const r = t.trim();
120
144
  return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
121
145
  }
122
- function A(t) {
146
+ function g(t) {
123
147
  const r = t.getAttribute("width");
124
- if (r && y(r))
148
+ if (r && _(r))
125
149
  return r.trim();
126
150
  const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
127
- return e && y(e[1]) ? e[1] : null;
151
+ return e && _(e[1]) ? e[1] : null;
128
152
  }
129
153
  function M(t, r) {
130
154
  let e = t.parentElement;
131
155
  for (; e && e !== r; ) {
132
- if (e.tagName === "TD" && A(e))
156
+ if (e.tagName === "TD" && g(e))
133
157
  return e;
134
158
  e = e.parentElement;
135
159
  }
136
160
  return null;
137
161
  }
138
- function T(t) {
139
- const r = t.getAttribute("style") || "", e = f(r, "width", 600), n = f(r, "padding", 0) * 2, s = Math.max(0, e - n);
140
- s !== 0 && t.querySelectorAll("img.adapt-img").forEach((c) => {
141
- if (c.hasAttribute("width"))
162
+ function G(t) {
163
+ const r = t.getAttribute("style") || "", e = $(r, "width", 600), o = $(r, "padding", 0) * 2, s = Math.max(0, e - o);
164
+ s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
165
+ if (i.hasAttribute("width"))
142
166
  return;
143
- const o = M(c, t);
144
- if (!o)
167
+ const n = M(i, t);
168
+ if (!n)
145
169
  return;
146
- const i = A(o), a = f(o.getAttribute("style") || "", "padding", 0) * 2, u = i.endsWith("%") ? Math.floor(s * parseFloat(i) / 100) : parseInt(i), d = Math.max(1, u - a);
147
- c.setAttribute("width", String(d));
148
- const l = c.getAttribute("style") || "";
149
- if (!/\bwidth\s*:\s*\d/i.test(l)) {
150
- const p = l && !l.trim().endsWith(";") ? "; " : "";
151
- c.setAttribute("style", `${l}${p}width: ${d}px`);
170
+ const c = g(n), a = $(n.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), l = Math.max(1, u - a);
171
+ i.setAttribute("width", String(l));
172
+ const d = i.getAttribute("style") || "";
173
+ if (!/\bwidth\s*:\s*\d/i.test(d)) {
174
+ const p = d && !d.trim().endsWith(";") ? "; " : "";
175
+ i.setAttribute("style", `${d}${p}width: ${l}px`);
152
176
  }
153
177
  });
154
178
  }
155
- function B(t, r) {
179
+ function H(t, r) {
156
180
  const e = t.match(/<!DOCTYPE[^>]*>/i);
157
181
  return (e ? `${e[0]}
158
182
  ` : "") + r.documentElement.outerHTML;
159
183
  }
160
- function G(t) {
161
- const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
162
- if (!n.length)
184
+ function Y(t) {
185
+ const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
186
+ if (!o.length)
163
187
  return t;
164
- const { buildCampaignUrl: s } = q(), c = E();
165
- c.recommendationCampaignUrls = {};
166
- const { isFeatureEnabled: o } = _(), i = o("liquidSyntax") ? "reco_" : "";
167
- return n.forEach((u) => {
168
- var l, p;
169
- const d = u.getAttribute("recommendation-id");
170
- d && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), s(d), w(u) || O(u, d, i), T(u));
171
- }), B(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
188
+ const { buildCampaignUrl: s } = E(), i = w();
189
+ i.recommendationCampaignUrls = {};
190
+ const { isFeatureEnabled: n } = C(), c = n("liquidSyntax") ? "reco_" : "";
191
+ return o.forEach((u) => {
192
+ var d, p, b, m;
193
+ const l = u.getAttribute("recommendation-id");
194
+ if (l) {
195
+ if ((d = u.parentNode) == null || d.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), s(l), !P(u)) {
196
+ D(u, l, c);
197
+ const { open: f, close: h } = L(e, l, c);
198
+ (b = u.parentNode) == null || b.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
199
+ }
200
+ G(u);
201
+ }
202
+ }), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
172
203
  }
173
204
  export {
174
- P as formatPriceVariable,
175
- G as prepareRecommendationBlocks
205
+ R as formatPriceVariable,
206
+ Y as prepareRecommendationBlocks
176
207
  };
@@ -53,7 +53,7 @@ class P extends E {
53
53
  if (!m)
54
54
  return;
55
55
  const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
56
- i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
56
+ i.modifyHtml(m).setInnerHtml(b);
57
57
  }), i.apply(new B(
58
58
  `Updated currency symbol to ${n || "removed"}`
59
59
  ));
@@ -1,4 +1,4 @@
1
- const l = [
1
+ const u = [
2
2
  {
3
3
  key: "locale",
4
4
  getValue: (e) => e.language,
@@ -7,28 +7,27 @@ const l = [
7
7
  {
8
8
  key: "currency",
9
9
  getValue: (e) => e.currencySettings.value,
10
- getAvailableOptions: (e) => e.currencyList.map((n) => n.text),
11
- canBeEmpty: !0
10
+ getAvailableOptions: (e) => e.currencyList.map((n) => n.text)
12
11
  }
13
- ], o = "newsletter.recommendation-fill-required-fields";
14
- function c(e, n, i = l) {
15
- return i.filter((t) => {
16
- var u;
12
+ ], s = "newsletter.recommendation-fill-required-fields";
13
+ function l(e, n, o = u) {
14
+ return o.filter((t) => {
15
+ var a;
17
16
  if (t.condition && !t.condition(e))
18
17
  return !1;
19
- const r = (u = t.getAvailableOptions) == null ? void 0 : u.call(t, n);
20
- if (t.canBeEmpty && (r == null ? void 0 : r.length) === 0)
21
- return !1;
22
- const a = t.getValue(e);
23
- return a ? r !== void 0 && !r.includes(a) : !0;
18
+ const i = t.getValue(e);
19
+ if (!i)
20
+ return !0;
21
+ const r = (a = t.getAvailableOptions) == null ? void 0 : a.call(t, n);
22
+ return r !== void 0 && !r.includes(i);
24
23
  }).map((t) => t.key);
25
24
  }
26
- function s(e, n) {
27
- return c(e, n).length === 0;
25
+ function c(e, n) {
26
+ return l(e, n).length === 0;
28
27
  }
29
28
  export {
30
- l as REQUIRED_RECOMMENDATION_FIELDS,
31
- o as RecommendationRequiredFieldsKey,
32
- c as getInvalidFields,
33
- s as isConfigValid
29
+ u as REQUIRED_RECOMMENDATION_FIELDS,
30
+ s as RecommendationRequiredFieldsKey,
31
+ l as getInvalidFields,
32
+ c as isConfigValid
34
33
  };
@@ -10,7 +10,6 @@ export interface ExtensionStoreSlice {
10
10
  }
11
11
  export interface RequiredField {
12
12
  key: string;
13
- canBeEmpty?: boolean;
14
13
  getValue: (config: PerBlockConfigs) => string;
15
14
  getAvailableOptions?: (store: ExtensionStoreSlice) => string[];
16
15
  condition?: (config: PerBlockConfigs) => boolean;
@@ -1,84 +1,85 @@
1
- import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
2
- import { DefaultConfigValues as N } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
- function W(M) {
4
- const S = M.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(S, "text/html"), m = q.PAIRS_FOR_EXTENSION;
5
- Object.entries(m).forEach(([r, f]) => {
6
- g.querySelectorAll(".ins-product-td").forEach((c) => {
7
- const A = c.getAttribute("data-number") || "1", C = c.getAttribute("data-type") || "CART_ITEMS";
8
- c.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
9
- var F, I, w;
10
- const $ = e.getAttribute("data-type") || C, u = e.getAttribute("data-number") || A, d = f[$];
11
- if (d)
1
+ import { productPairs as L } from "../extensions/Blocks/Items/enums/productEnums.js";
2
+ function q(w) {
3
+ const y = w.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(y, "text/html"), C = L.PAIRS_FOR_EXTENSION;
4
+ Object.entries(C).forEach(([r, f]) => {
5
+ T.querySelectorAll(".ins-product-td").forEach((o) => {
6
+ const A = o.getAttribute("data-number") || "1", b = o.getAttribute("data-type") || "CART_ITEMS";
7
+ o.querySelectorAll(`[product-attr="${r}"]`).forEach((e) => {
8
+ var k, F, I;
9
+ const $ = e.getAttribute("data-type") || b, d = e.getAttribute("data-number") || A, u = f[$];
10
+ if (u)
12
11
  switch (r) {
13
12
  case "imageSrc": {
14
13
  let t = null, i = null;
15
14
  if (e.tagName === "IMG" ? (t = e, i = t.closest("a")) : (t = e.querySelector("img"), i = e.querySelector("a") || e.closest("a")), !t)
16
15
  break;
17
- const a = d.DEFAULT, s = d.ATTR;
16
+ const a = u.DEFAULT, s = u.ATTR;
18
17
  if (a && t.src) {
19
- const o = t.src;
18
+ const c = t.src;
20
19
  a.some((h) => {
21
- const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
22
- return o.includes(h) || o.includes(l) || b === l;
23
- }) && (t.src = `{{${s}_${u}}}`);
20
+ const l = h.split("/").pop() || "", g = c.split("/").pop() || "";
21
+ return c.includes(h) || c.includes(l) || g === l;
22
+ }) && (t.src = `{{${s}_${d}}}`);
24
23
  }
25
- const n = (I = (F = m.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
26
- if (n && t.setAttribute("alt", `{{${n}_${u}}}`), i) {
27
- const o = (w = m.itemLink) == null ? void 0 : w[$];
28
- if (o) {
29
- const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
30
- (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
24
+ const n = (F = (k = C.name) == null ? void 0 : k[$]) == null ? void 0 : F.ATTR;
25
+ if (n && t.setAttribute("alt", `{{${n}_${d}}}`), i) {
26
+ const c = (I = C.itemLink) == null ? void 0 : I[$];
27
+ if (c) {
28
+ const E = c.HREF, h = c.DEFAULT_HREF || "#!", l = i.href;
29
+ (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${d}}}`);
31
30
  }
32
31
  }
33
32
  break;
34
33
  }
35
34
  case "name": {
36
- const t = d, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
37
- e.textContent && (e.textContent = `{{${i}_${u}}}`);
35
+ const t = u, i = t.ATTR, a = t.DEFAULT_HREF || "#!", s = t.HREF;
36
+ e.textContent && (e.textContent = `{{${i}_${d}}}`);
38
37
  const n = e.closest("a") || (e.tagName === "A" ? e : null);
39
38
  if (n && s) {
40
- const o = n.href, E = `${window.location.href}${a}`;
41
- (o === E || o.endsWith(a)) && (n.href = `{{${s}_${u}}}`);
39
+ const c = n.href, E = `${window.location.href}${a}`;
40
+ (c === E || c.endsWith(a)) && (n.href = `{{${s}_${d}}}`);
42
41
  }
43
42
  break;
44
43
  }
45
44
  case "price":
46
45
  case "originalPrice": {
47
- const t = d, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", o = e.getAttribute("data-curency") || "before";
46
+ const t = u, i = e.getAttribute("data-formated"), a = e.getAttribute("data-single_price"), s = i === "true", n = a === "true", c = e.getAttribute("data-curency") || "before";
48
47
  let E;
49
48
  n ? E = s ? t.SINGLE_PRICE_FORMATTED : t.SINGLE_PRICE : E = s ? t.PRICE_FORMATTED : t.PRICE;
50
49
  const h = t.CURRENCY;
51
- let l = `{{${E}_${u}}}`;
52
- const b = (e.getAttribute("data-currency_symbol") || "").trim(), x = b !== "" && b !== N.productPriceCurrencySymbolControlValue;
53
- let T = "";
54
- x ? T = b : h && (T = `{{${h}_${u}}}`), T && (l = o === "after" ? `${l} ${T}` : `${T} ${l}`), e.textContent = l;
50
+ let l = `{{${E}_${d}}}`;
51
+ if (h) {
52
+ const g = `{{${h}_${d}}}`;
53
+ l = c === "after" ? `${l} ${g}` : `${g} ${l}`;
54
+ }
55
+ e.textContent = l;
55
56
  break;
56
57
  }
57
58
  case "quantity": {
58
- const t = d, i = t.ATTR, a = t.DEFAULT;
59
- e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${u}}}`);
59
+ const t = u, i = t.ATTR, a = t.DEFAULT;
60
+ e.textContent && e.textContent.trim() === a && (e.textContent = `{{${i}_${d}}}`);
60
61
  break;
61
62
  }
62
63
  case "button": {
63
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
64
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e.tagName === "A" ? e : e.querySelector("a");
64
65
  if (s) {
65
- const n = s.href || "", o = `${window.location.href}${a}`;
66
- (n === "" || n === "#" || n === o || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${u}}}`);
66
+ const n = s.href || "", c = `${window.location.href}${a}`;
67
+ (n === "" || n === "#" || n === c || n.endsWith(a) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${i}_${d}}}`);
67
68
  }
68
69
  break;
69
70
  }
70
71
  case "itemLink": {
71
- const t = d, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
72
+ const t = u, i = t.HREF, a = t.DEFAULT_HREF || "#!", s = e;
72
73
  if (s.href) {
73
- const n = s.href, o = `${window.location.href}${a}`;
74
- (n === o || n.endsWith(a)) && (s.href = `{{${i}_${u}}}`);
74
+ const n = s.href, c = `${window.location.href}${a}`;
75
+ (n === c || n.endsWith(a)) && (s.href = `{{${i}_${d}}}`);
75
76
  }
76
77
  break;
77
78
  }
78
79
  default: {
79
- if ("ATTR" in d) {
80
- const t = d.ATTR;
81
- e.textContent && (e.textContent = `{{${t}_${u}}}`);
80
+ if ("ATTR" in u) {
81
+ const t = u.ATTR;
82
+ e.textContent && (e.textContent = `{{${t}_${d}}}`);
82
83
  }
83
84
  break;
84
85
  }
@@ -86,48 +87,48 @@ function W(M) {
86
87
  });
87
88
  });
88
89
  });
89
- const H = S.match(/<!DOCTYPE[^>]*>/i), P = H ? `${H[0]}
90
- ` : "", D = g.querySelectorAll(".ins-product-td"), k = [];
91
- D.forEach((r) => {
92
- const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
93
- k.push({
90
+ const S = y.match(/<!DOCTYPE[^>]*>/i), M = S ? `${S[0]}
91
+ ` : "", P = T.querySelectorAll(".ins-product-td"), H = [];
92
+ P.forEach((r) => {
93
+ const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", o = r.getAttribute("data-nodup"), A = r.outerHTML;
94
+ H.push({
94
95
  element: r,
95
96
  outerHtml: A,
96
97
  type: f,
97
98
  number: p,
98
- nodup: c || void 0
99
+ nodup: o || void 0
99
100
  });
100
101
  });
101
- let _ = P + g.documentElement.outerHTML;
102
- k.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
103
- let c = "";
102
+ let _ = M + T.documentElement.outerHTML;
103
+ H.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
104
+ let o = "";
104
105
  switch (f) {
105
106
  case "CART_ITEMS":
106
- c = "ins_apr_total_product_kind";
107
+ o = "ins_apr_total_product_kind";
107
108
  break;
108
109
  case "BROWSED_ITEMS":
109
- c = "browsed_item_total_product_kind";
110
+ o = "browsed_item_total_product_kind";
110
111
  break;
111
112
  case "PURCHASED_ITEMS":
112
- c = "purchased_item_total_product_kind";
113
+ o = "purchased_item_total_product_kind";
113
114
  break;
114
115
  }
115
- if (c) {
116
- const C = parseInt(p) - 1, $ = `${`{% if ${c} > ${C} %}`}${r}{% endif %}`;
116
+ if (o) {
117
+ const b = parseInt(p) - 1, $ = `${`{% if ${o} > ${b} %}`}${r}{% endif %}`;
117
118
  _ = _.replace(r, $);
118
119
  }
119
120
  });
120
- const L = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), y = [];
121
- return L.forEach((r) => {
121
+ const D = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
122
+ return D.forEach((r) => {
122
123
  const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
123
124
  if (!f || p !== "CART_ITEMS")
124
125
  return;
125
- const c = r.closest(".product-original-price-class");
126
- if (c) {
127
- const A = c.outerHTML;
128
- y.some((R) => R.tdOuterHtml === A) || y.push({ tdOuterHtml: A, number: f });
126
+ const o = r.closest(".product-original-price-class");
127
+ if (o) {
128
+ const A = o.outerHTML;
129
+ R.some((m) => m.tdOuterHtml === A) || R.push({ tdOuterHtml: A, number: f });
129
130
  }
130
- }), y.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
+ }), R.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
131
132
  const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
132
133
  if (!_.includes(p) && !r.includes("{% if")) {
133
134
  const A = `${p}${r}{% endif %}`;
@@ -136,5 +137,5 @@ function W(M) {
136
137
  }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
137
138
  }
138
139
  export {
139
- W as pairProductVariables
140
+ q as pairProductVariables
140
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.9.1-beta.c521c3a",
3
+ "version": "3.9.1-beta.c64c39e",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",