@useinsider/guido 3.24.0-beta.adaba3e → 3.24.0-beta.e4b6993

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +7 -2
  2. package/dist/@types/config/schemas.js +47 -47
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +92 -98
  5. package/dist/composables/useBlocksConfig.js +20 -31
  6. package/dist/composables/useHtmlCompiler.js +2 -0
  7. package/dist/composables/useSave.js +57 -52
  8. package/dist/composables/useSaveValidation.js +118 -110
  9. package/dist/composables/useStripo.js +70 -70
  10. package/dist/composables/useTranslations.js +1 -2
  11. package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
  12. package/dist/config/compiler/htmlCompilerRules.js +14 -6
  13. package/dist/config/compiler/utils/itemsCompilerUtils.js +42 -43
  14. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -67
  15. package/dist/enums/academy.js +0 -1
  16. package/dist/enums/save-validation.js +1 -1
  17. package/dist/guido.css +1 -1
  18. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +92 -93
  19. package/dist/node_modules/valibot/dist/index.js +261 -297
  20. package/dist/package.json.js +4 -4
  21. package/dist/src/@types/config/schemas.d.ts +4 -4
  22. package/dist/src/composables/useConfig.d.ts +2 -2
  23. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  24. package/dist/src/composables/useStripo.d.ts +1 -1
  25. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
  26. package/dist/src/enums/academy.d.ts +0 -1
  27. package/dist/src/enums/save-validation.d.ts +2 -1
  28. package/dist/src/stores/config.d.ts +20 -167
  29. package/dist/src/utils/linkTrackingIds.d.ts +5 -22
  30. package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
  31. package/dist/stores/config.js +6 -13
  32. package/dist/utils/linkTrackingIds.js +48 -82
  33. package/dist/utils/pairProductVariables.js +29 -30
  34. package/dist/utils/templatePreparation.js +57 -67
  35. package/dist/utils/trimHrefWhitespace.js +10 -0
  36. package/package.json +1 -1
  37. package/dist/@types/display-condition.js +0 -25
  38. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +0 -18
  39. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +0 -41
  40. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +0 -30
  41. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +0 -81
  42. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +0 -34
  43. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +0 -63
  44. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +0 -17
  45. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +0 -22
  46. package/dist/composables/useDisplayConditions.js +0 -117
  47. package/dist/enums/display-condition.js +0 -12
  48. package/dist/extensions/DisplayConditions/bridge.js +0 -25
  49. package/dist/extensions/DisplayConditions/constants.js +0 -17
  50. package/dist/extensions/DisplayConditions/control.js +0 -200
  51. package/dist/extensions/DisplayConditions/display-conditions.css.js +0 -201
  52. package/dist/extensions/DisplayConditions/extension.js +0 -28
  53. package/dist/extensions/DisplayConditions/iconsRegistry.js +0 -20
  54. package/dist/extensions/DisplayConditions/library.js +0 -30
  55. package/dist/extensions/DisplayConditions/settingsPanel.js +0 -17
  56. package/dist/extensions/LinkTracking/extension.js +0 -17
  57. package/dist/extensions/LinkTracking/writer.js +0 -41
  58. package/dist/services/displayConditionApi.js +0 -39
  59. package/dist/src/@types/display-condition.d.ts +0 -59
  60. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +0 -43
  61. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +0 -2
  62. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +0 -2
  63. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +0 -2
  64. package/dist/src/composables/useDisplayConditions.d.ts +0 -18
  65. package/dist/src/enums/display-condition.d.ts +0 -15
  66. package/dist/src/extensions/DisplayConditions/bridge.d.ts +0 -7
  67. package/dist/src/extensions/DisplayConditions/constants.d.ts +0 -14
  68. package/dist/src/extensions/DisplayConditions/control.d.ts +0 -25
  69. package/dist/src/extensions/DisplayConditions/extension.d.ts +0 -2
  70. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +0 -4
  71. package/dist/src/extensions/DisplayConditions/library.d.ts +0 -8
  72. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +0 -5
  73. package/dist/src/extensions/LinkTracking/extension.d.ts +0 -2
  74. package/dist/src/extensions/LinkTracking/writer.d.ts +0 -13
  75. package/dist/src/mock/api/display-conditions.d.ts +0 -2
  76. package/dist/src/services/displayConditionApi.d.ts +0 -8
  77. package/dist/src/stores/display-condition.d.ts +0 -84
  78. package/dist/src/utils/displayCondition.d.ts +0 -11
  79. package/dist/src/utils/protectTableText.d.ts +0 -2
  80. package/dist/stores/display-condition.js +0 -29
  81. package/dist/utils/displayCondition.js +0 -26
  82. package/dist/utils/protectTableText.js +0 -22
@@ -1,8 +1,8 @@
1
- import { MessageType as a } from "../@types/config/schemas.js";
1
+ import { MessageType as r } from "../@types/config/schemas.js";
2
2
  import "../@types/config/defaults.js";
3
- import { parseConfig as o } from "../@types/config/validator.js";
4
- import { defineStore as l } from "pinia";
5
- const g = l("guido-config", {
3
+ import { parseConfig as a } from "../@types/config/validator.js";
4
+ import { defineStore as o } from "pinia";
5
+ const g = o("guido-config", {
6
6
  state: () => ({
7
7
  initialized: !1,
8
8
  config: null
@@ -132,7 +132,7 @@ const g = l("guido-config", {
132
132
  * consumers stay safe in setup where a raw config read snapshots null (SD-147945).
133
133
  */
134
134
  isTransactional() {
135
- return this.messageType === a.TRANSACTIONAL;
135
+ return this.messageType === r.TRANSACTIONAL;
136
136
  },
137
137
  /**
138
138
  * Soft-save policy: may the editor persist a template with validation errors?
@@ -158,13 +158,6 @@ const g = l("guido-config", {
158
158
  var e, t;
159
159
  return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
160
160
  },
161
- /**
162
- * Check if the Insider display-condition UI replaces Stripo's
163
- */
164
- externalDisplayConditions: (i) => {
165
- var e, t, n, r;
166
- return (((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.externalDisplayConditions) ?? !1) && (((r = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : r.displayConditions) ?? !0);
167
- },
168
161
  /**
169
162
  * Check if a specific feature is enabled.
170
163
  * Returns false before init (config null) so header controls don't
@@ -181,7 +174,7 @@ const g = l("guido-config", {
181
174
  * Initialize the config store with validated configuration
182
175
  */
183
176
  init(i) {
184
- const e = o(i);
177
+ const e = a(i);
185
178
  this.config = e, this.initialized = !0;
186
179
  },
187
180
  /**
@@ -1,90 +1,56 @@
1
- const A = "data-ins-track-id", E = "data-ins-track-seq", g = `(?:[^>"']|"[^"]*"|'[^']*')*`, R = new RegExp(`<a\\b${g}>`, "gi"), _ = new RegExp(`<body\\b${g}>`, "i"), l = new RegExp(`<html\\b${g}>`, "i"), m = new RegExp(`\\b${A}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), f = new RegExp(`\\b${E}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", d = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), I = /^[1-9][0-9]{0,14}$/, S = 999999999999999;
2
- function $(e) {
3
- const t = m.exec(e), n = t ? t[1] ?? t[2] ?? t[3] ?? "" : "";
4
- return { attrMatch: t, rawValue: n };
5
- }
6
- function k(e) {
7
- const t = Number(e);
8
- return Number.isSafeInteger(t) && t > 0 ? t : 0;
9
- }
10
- function N(e) {
11
- var s;
12
- const t = (o) => {
1
+ const g = "data-ins-track-id", $ = "data-ins-track-seq", E = `(?:[^>"']|"[^"]*"|'[^']*')*`, f = new RegExp(`<a\\b${E}>`, "gi"), b = new RegExp(`<body\\b${E}>`, "i"), N = new RegExp(`<html\\b${E}>`, "i"), I = new RegExp(`\\b${g}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"), S = new RegExp(`\\b${$}\\s*=\\s*(?:"(\\d+)"|'(\\d+)'|(\\d+))`, "i"), p = "ins-track-seq", _ = new RegExp(`<!--\\s*${p}:(\\d+)\\s*-->`, "i"), w = /^[1-9][0-9]{0,14}$/, k = 999999999999999;
2
+ function m(e) {
3
+ const n = Number(e);
4
+ return Number.isSafeInteger(n) && n > 0 ? n : 0;
5
+ }
6
+ function M(e) {
7
+ var a;
8
+ const n = (s) => {
13
9
  var r;
14
- const a = (r = o.exec(e)) == null ? void 0 : r[0];
15
- return a ? f.exec(a) : null;
16
- }, n = t(_) ?? t(l), c = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((s = d.exec(e)) == null ? void 0 : s[1]) ?? "";
17
- return k(c);
18
- }
19
- function K(e, t = 0) {
20
- let n = 0;
21
- [...e.matchAll(R)].forEach(([s]) => {
22
- const { rawValue: o } = $(s);
23
- I.test(o) && (n = Math.max(n, Number(o)));
10
+ const o = (r = s.exec(e)) == null ? void 0 : r[0];
11
+ return o ? S.exec(o) : null;
12
+ }, t = n(b) ?? n(N), c = (t == null ? void 0 : t[1]) ?? (t == null ? void 0 : t[2]) ?? (t == null ? void 0 : t[3]) ?? ((a = _.exec(e)) == null ? void 0 : a[1]) ?? "";
13
+ return m(c);
14
+ }
15
+ function P(e, n = 0) {
16
+ let t = 0;
17
+ [...e.matchAll(f)].forEach(([a]) => {
18
+ const s = I.exec(a), o = s ? s[1] ?? s[2] ?? s[3] ?? "" : "";
19
+ w.test(o) && (t = Math.max(t, Number(o)));
24
20
  });
25
- const c = Number.isSafeInteger(t) && t > 0 ? t : 0;
26
- return Math.max(N(e), n, c);
21
+ const c = Number.isSafeInteger(n) && n > 0 ? n : 0;
22
+ return Math.max(M(e), t, c);
27
23
  }
28
- function M(e, t) {
29
- const n = `${E}="${t}"`, c = _.exec(e) ?? l.exec(e);
24
+ function q(e, n) {
25
+ const t = `${$}="${n}"`, c = b.exec(e) ?? N.exec(e);
30
26
  if (c) {
31
- const [o] = c, a = f.exec(o), r = a ? o.replace(a[0], n) : o.replace(/\/?>$/, (i) => ` ${n}${i}`);
32
- return e.slice(0, c.index) + r + e.slice(c.index + o.length);
27
+ const [s] = c, o = S.exec(s), r = o ? s.replace(o[0], t) : s.replace(/\/?>$/, (T) => ` ${t}${T}`);
28
+ return e.slice(0, c.index) + r + e.slice(c.index + s.length);
33
29
  }
34
- const s = `<!--${p}:${t}-->`;
35
- return d.test(e) ? e.replace(d, s) : `${s}${e}`;
36
- }
37
- function q(e, t, n) {
38
- const c = `${A}="${n}"`;
39
- return t ? e.replace(t[0], c) : e.replace(/^<a\b/i, (s) => `${s} ${c}`);
40
- }
41
- function w(e, t, n = 0) {
42
- const c = /* @__PURE__ */ new Set();
43
- let s = 0;
44
- const o = e.map((u) => {
45
- if (u !== null && I.test(u) && !c.has(Number(u))) {
46
- const T = Number(u);
47
- return c.add(T), s = Math.max(s, T), T;
48
- }
49
- return null;
50
- }), a = Number.isSafeInteger(n) && n > 0 && n < S ? n : 0;
51
- let r = Math.max(t, s, a);
52
- const i = /* @__PURE__ */ new Map();
53
- o.forEach((u, T) => {
54
- u === null && (r += 1, i.set(T, r));
55
- });
56
- const x = r > 0 && t !== r;
57
- return { assignments: i, nextSeq: r, seqChanged: x, changed: i.size > 0 || x };
58
- }
59
- function b(e) {
60
- return [...e.matchAll(R)].map((t) => {
61
- const [n] = t;
62
- return { index: t.index, tag: n, ...$(n) };
63
- });
64
- }
65
- const C = /<!--[\s\S]*?-->/g;
66
- function P(e, t = 0) {
67
- const n = b(e), c = n.map((a) => a.rawValue), s = [...e.matchAll(C)].map((a) => [a.index, a.index + a[0].length]), o = n.map(({ index: a }) => s.some(([r, i]) => a > r && a < i));
68
- return { anchorIds: c, inComment: o, plan: w(c, N(e), t) };
69
- }
70
- function D(e, { plan: t }) {
71
- let n = "", c = 0;
72
- return b(e).forEach((s, o) => {
73
- const a = t.assignments.get(o);
74
- n += e.slice(c, s.index), n += a === void 0 ? s.tag : q(s.tag, s.attrMatch, a), c = s.index + s.tag.length;
75
- }), n += e.slice(c), t.seqChanged ? M(n, t.nextSeq) : n;
76
- }
77
- function O(e, t = 0) {
78
- const n = P(e, t), { changed: c, nextSeq: s } = n.plan;
79
- return { html: c ? D(e, n) : e, changed: c, nextSeq: s };
30
+ const a = `<!--${p}:${n}-->`;
31
+ return _.test(e) ? e.replace(_, a) : `${a}${e}`;
32
+ }
33
+ function D(e, n, t) {
34
+ const c = `${g}="${t}"`;
35
+ return n ? e.replace(n[0], c) : e.replace(/^<a\b/i, (a) => `${a} ${c}`);
36
+ }
37
+ function C(e, n = 0) {
38
+ const t = /* @__PURE__ */ new Set();
39
+ let c = 0;
40
+ const a = [...e.matchAll(f)].map((i) => {
41
+ const [l] = i, u = I.exec(l), R = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
42
+ let x = null;
43
+ return w.test(R) && !t.has(Number(R)) && (x = Number(R), t.add(x), c = Math.max(c, x)), { index: i.index, tag: l, attrMatch: u, id: x };
44
+ }), s = M(e), o = Number.isSafeInteger(n) && n > 0 && n < k ? n : 0;
45
+ let r = Math.max(s, c, o), T = "", d = 0, A = !1;
46
+ return a.forEach((i) => {
47
+ T += e.slice(d, i.index), i.id === null ? (r += 1, T += D(i.tag, i.attrMatch, r), A = !0) : T += i.tag, d = i.index + i.tag.length;
48
+ }), T += e.slice(d), r > 0 && s !== r && (T = q(T, r), A = !0), { html: T, changed: A, nextSeq: r };
80
49
  }
81
50
  export {
82
- A as TRACK_ID_ATTRIBUTE,
83
- E as TRACK_SEQ_ATTRIBUTE,
84
- O as assignTrackingIds,
85
- P as planDocumentTrackingIds,
86
- w as planTrackingIds,
87
- K as readTrackFloor,
88
- N as readTrackSeq,
89
- D as renderTrackingIdPlan
51
+ g as TRACK_ID_ATTRIBUTE,
52
+ $ as TRACK_SEQ_ATTRIBUTE,
53
+ C as assignTrackingIds,
54
+ P as readTrackFloor,
55
+ M as readTrackSeq
90
56
  };
@@ -2,35 +2,34 @@ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extens
2
2
  import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
3
3
  import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
4
4
  import { preserveTextStyles as L } from "./preserveTextStyles.js";
5
- import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
6
- import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
5
+ import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
7
6
  const q = {
8
7
  CART_ITEMS: "ins_apr",
9
8
  BROWSED_ITEMS: "browsed_item",
10
9
  PURCHASED_ITEMS: "purchased_item"
11
10
  }, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
12
- function Q($, C, A) {
11
+ function v($, C, A) {
13
12
  let d = C;
14
13
  for (; d > 0 && /\s/.test($[d - 1]); )
15
14
  d -= 1;
16
15
  return A.some((E) => $.endsWith(E, d));
17
16
  }
18
- const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
19
- function J($, C) {
17
+ const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
18
+ function Q($, C) {
20
19
  var d;
21
20
  const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
22
21
  for (let E = A.nextNode(); E; E = A.nextNode())
23
- (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
22
+ (d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(j, (k, P) => `${P}href="${C}"`));
24
23
  }
25
- function ot($) {
26
- const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
27
- j(A);
24
+ function et($) {
25
+ const C = W($), A = new DOMParser().parseFromString(C, "text/html");
26
+ X(A);
28
27
  const d = M.PAIRS_FOR_EXTENSION;
29
28
  Object.entries(d).forEach(([o, p]) => {
30
29
  A.querySelectorAll(".ins-product-td").forEach((r) => {
31
30
  const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
32
31
  r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
33
- var b, I, D, O;
32
+ var S, I, O, x;
34
33
  const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
35
34
  if (f)
36
35
  switch (o) {
@@ -46,12 +45,12 @@ function ot($) {
46
45
  return a.includes(g) || a.includes(u) || H === u;
47
46
  }) && (e.src = `{{${c}_${n}}}`);
48
47
  }
49
- const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
48
+ const i = (I = (S = d.name) == null ? void 0 : S[m]) == null ? void 0 : I.ATTR;
50
49
  if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
51
- const a = (D = d.itemLink) == null ? void 0 : D[m];
50
+ const a = (O = d.itemLink) == null ? void 0 : O[m];
52
51
  if (a) {
53
- const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
54
- (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
52
+ const b = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
53
+ (u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${b}_${n}}}`);
55
54
  }
56
55
  }
57
56
  break;
@@ -61,25 +60,25 @@ function ot($) {
61
60
  t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
62
61
  const i = t.closest("a") || (t.tagName === "A" ? t : null);
63
62
  if (i && c) {
64
- const a = i.href, S = `${window.location.href}${l}`;
65
- (a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
63
+ const a = i.href, b = `${window.location.href}${l}`;
64
+ (a === b || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
66
65
  }
67
66
  break;
68
67
  }
69
68
  case "price":
70
69
  case "originalPrice": {
71
70
  const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
72
- let S;
73
- i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
71
+ let b;
72
+ i ? b = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : b = c ? e.PRICE_FORMATTED : e.PRICE;
74
73
  const g = e.CURRENCY;
75
- let u = `{{${S}_${n}}}`;
74
+ let u = `{{${b}_${n}}}`;
76
75
  const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
77
76
  let F = "";
78
77
  G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
79
78
  break;
80
79
  }
81
80
  case "quantity": {
82
- const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
81
+ const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (x = t.textContent) == null ? void 0 : x.trim();
83
82
  c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
84
83
  break;
85
84
  }
@@ -89,7 +88,7 @@ function ot($) {
89
88
  const i = c.href || "", a = `${window.location.href}${l}`;
90
89
  (i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
91
90
  }
92
- J(t, `{{${s}_${n}}}`);
91
+ Q(t, `{{${s}_${n}}}`);
93
92
  break;
94
93
  }
95
94
  case "itemLink": {
@@ -130,30 +129,30 @@ function ot($) {
130
129
  h = h.replace(o, B(n));
131
130
  }
132
131
  });
133
- const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
132
+ const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set();
134
133
  return V.forEach((o) => {
135
134
  var t;
136
135
  const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
137
136
  if (!p || !q[T])
138
137
  return;
139
138
  const r = o.closest(".product-original-price-class");
140
- if (!r || x.has(r))
139
+ if (!r || D.has(r))
141
140
  return;
142
- x.add(r);
141
+ D.add(r);
143
142
  const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
144
143
  R.wrap.push(y !== "false"), w.set(_, R);
145
144
  }), w.forEach(({ number: o, type: p, wrap: T }, r) => {
146
145
  if (r.includes("{% if") || !T.some(Boolean))
147
146
  return;
148
147
  const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
149
- let m = "", n = 0, f = 0, b = h.indexOf(r);
150
- for (; b !== -1; ) {
151
- const I = T[f] === !0 && !Q(h, b, t);
152
- m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
148
+ let m = "", n = 0, f = 0, S = h.indexOf(r);
149
+ for (; S !== -1; ) {
150
+ const I = T[f] === !0 && !v(h, S, t);
151
+ m += h.slice(n, S) + (I ? `${R}${r}{% endif %}` : r), n = S + r.length, f += 1, S = h.indexOf(r, n);
153
152
  }
154
153
  h = m + h.slice(n);
155
- }), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}"));
154
+ }), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
156
155
  }
157
156
  export {
158
- ot as pairProductVariables
157
+ et as pairProductVariables
159
158
  };
@@ -1,45 +1,44 @@
1
1
  import { useActionsApi as E } from "../composables/useActionsApi.js";
2
- import { useConfig as R } from "../composables/useConfig.js";
3
- import { useHtmlCompiler as U } from "../composables/useHtmlCompiler.js";
4
- import { useRecommendationExtensionStore as k } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { toBlockUrlConfig as L } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
- import { DATA_ATTRIBUTES as b } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
- import { parsePageList as v } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
- import { writeTrackingIdsInPlace as N } from "../extensions/LinkTracking/writer.js";
9
- import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
10
- import { useEditorStore as q } from "../stores/editor.js";
11
- import { useUnsubscribeStore as M } from "../stores/unsubscribe.js";
12
- import { isPlainObject as O } from "./genericUtil.js";
13
- import { planDocumentTrackingIds as T, renderTrackingIdPlan as B } from "./linkTrackingIds.js";
14
- function _(c) {
15
- const i = new DOMParser().parseFromString(c, "text/html").querySelectorAll(`[${b.PAGE_LIST}]`), e = [];
16
- return i.forEach((s) => {
17
- const o = s.getAttribute(b.PAGE_LIST);
18
- o && e.push(...v(o));
2
+ import { useConfig as F } from "../composables/useConfig.js";
3
+ import { useHtmlCompiler as I } from "../composables/useHtmlCompiler.js";
4
+ import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { toBlockUrlConfig as R } from "../extensions/Blocks/Recommendation/utils/blockUrlConfig.js";
6
+ import { DATA_ATTRIBUTES as g } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
7
+ import { parsePageList as U } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
8
+ import { useDynamicContentStore as L } from "../stores/dynamic-content.js";
9
+ import { useEditorStore as N } from "../stores/editor.js";
10
+ import { useUnsubscribeStore as v } from "../stores/unsubscribe.js";
11
+ import { isPlainObject as z } from "./genericUtil.js";
12
+ import { assignTrackingIds as M } from "./linkTrackingIds.js";
13
+ function O(n) {
14
+ const r = new DOMParser().parseFromString(n, "text/html").querySelectorAll(`[${g.PAGE_LIST}]`), e = [];
15
+ return r.forEach((i) => {
16
+ const t = i.getAttribute(g.PAGE_LIST);
17
+ t && e.push(...U(t));
19
18
  }), [...new Set(e)];
20
19
  }
21
- async function w(c) {
22
- const a = new DOMParser().parseFromString(c, "text/html").querySelectorAll(".recommendation-block-v2");
23
- if (a.length === 0)
20
+ async function S(n) {
21
+ const o = new DOMParser().parseFromString(n, "text/html").querySelectorAll(".recommendation-block-v2");
22
+ if (o.length === 0)
24
23
  return;
25
- const i = k();
26
- a.forEach((e) => {
27
- const s = e.getAttribute("recommendation-id"), o = s ? Number(s) : NaN;
28
- if (!Number.isFinite(o))
24
+ const r = b();
25
+ o.forEach((e) => {
26
+ const i = e.getAttribute("recommendation-id"), t = i ? Number(i) : NaN;
27
+ if (!Number.isFinite(t))
29
28
  return;
30
- const l = e.getAttribute("esd-ext-config");
31
- if (!l)
29
+ const m = e.getAttribute("esd-ext-config");
30
+ if (!m)
32
31
  return;
33
- let m;
32
+ let a;
34
33
  try {
35
- m = JSON.parse(l);
34
+ a = JSON.parse(m);
36
35
  } catch {
37
36
  return;
38
37
  }
39
- O(m) && i.seedBlockUrlConfig(o, L(m));
38
+ z(a) && r.seedBlockUrlConfig(t, R(a));
40
39
  });
41
40
  try {
42
- await i.fetchRecommendationCreateData();
41
+ await r.fetchRecommendationCreateData();
43
42
  } catch (e) {
44
43
  console.warn(
45
44
  "Recommendation reference data pre-load failed; validator will skip the availability check.",
@@ -47,63 +46,54 @@ async function w(c) {
47
46
  );
48
47
  }
49
48
  }
50
- const oe = () => {
51
- const c = z(), n = q(), a = M(), { getCompiledEmail: i, getTemplateData: e, updateHtmlAndCss: s } = E(), { compileHtml: o, compileAmpHtml: l } = U(), { isFeatureEnabled: m } = R();
49
+ const Z = () => {
50
+ const n = L(), c = N(), o = v(), { getCompiledEmail: r, getTemplateData: e, updateHtmlAndCss: i } = E(), { compileHtml: t, compileAmpHtml: m } = I(), { isFeatureEnabled: a } = F();
52
51
  return {
53
- prepareTemplateDetails: async (y) => {
54
- let { html: r, css: u, syncModulesIds: g = [] } = y ?? await e();
55
- if (m("linkTrackingIds"))
52
+ prepareTemplateDetails: async (h) => {
53
+ let { html: s, css: u, syncModulesIds: y = [] } = h ?? await e();
54
+ if (a("linkTrackingIds"))
56
55
  try {
57
- let t = T(r, n.trackIdSessionFloor);
58
- n.trackIdSessionFloor = t.plan.nextSeq;
59
- let p = t.plan.changed;
60
- if (p && N(t)) {
61
- const h = await e().catch((x) => (console.warn(
62
- "Tracking-id re-read failed, saving the planned ids without a replacement:",
63
- x
64
- ), null));
65
- h ? ({ html: r, css: u, syncModulesIds: g = [] } = h, t = T(r, n.trackIdSessionFloor), n.trackIdSessionFloor = t.plan.nextSeq, p = t.plan.changed) : p = !1;
66
- }
67
- t.plan.changed && (r = B(r, t)), p && await s(r, u);
68
- } catch (t) {
69
- console.error("Tracking-id step failed, saving anyway:", t);
56
+ const { html: d, changed: x, nextSeq: D } = M(s, c.trackIdSessionFloor);
57
+ c.trackIdSessionFloor = D, x && (s = d, await i(d, u));
58
+ } catch (d) {
59
+ console.error("Tracking-id step failed, saving anyway:", d);
70
60
  }
71
- const { html: A, ampHtml: f = "", ampErrors: P = [] } = await i({
61
+ const { html: T, ampHtml: p = "", ampErrors: A = [] } = await r({
72
62
  minimize: !0,
73
63
  resetDataSavedFlag: !1
74
64
  });
75
- a.selectedUnsubscribePages.length && await a.fetchTemplates(), await w(r);
76
- const { compiledHtml: C, stats: d, appliedRules: I } = o(A), H = f && l(f).compiledHtml, D = c.getSelectedDynamicContentList, F = k(), S = _(r);
65
+ o.selectedUnsubscribePages.length && await o.fetchTemplates(), await S(s);
66
+ const { compiledHtml: w, stats: l, appliedRules: C } = t(T), H = p && m(p).compiledHtml, k = n.getSelectedDynamicContentList, P = b(), f = O(s);
77
67
  return console.debug("HTML Compilation Stats:", {
78
- originalSize: d.originalSize,
79
- compiledSize: d.compiledSize,
80
- reduction: `${d.reductionPercentage.toFixed(2)}%`,
81
- appliedRules: I,
82
- executionTime: `${d.executionTime.toFixed(2)}ms`
68
+ originalSize: l.originalSize,
69
+ compiledSize: l.compiledSize,
70
+ reduction: `${l.reductionPercentage.toFixed(2)}%`,
71
+ appliedRules: C,
72
+ executionTime: `${l.executionTime.toFixed(2)}ms`
83
73
  }), {
84
- dynamicContentList: D,
85
- compiledHtml: C,
86
- rawHtml: r,
74
+ dynamicContentList: k,
75
+ compiledHtml: w,
76
+ rawHtml: s,
87
77
  css: u,
88
78
  ampHtml: H,
89
- ampErrors: P,
90
- modules: g.map(Number),
79
+ ampErrors: A,
80
+ modules: y.map(Number),
91
81
  recommendation: {
92
- campaignUrls: F.recommendationCampaignUrls,
82
+ campaignUrls: P.recommendationCampaignUrls,
93
83
  configs: {}
94
84
  },
95
85
  unsubscribe: {
96
- status: S.length > 0,
97
- config: S
86
+ status: f.length > 0,
87
+ config: f
98
88
  }
99
89
  };
100
90
  },
101
91
  // Exposed so the back/test validate-only path can seed the reco store the
102
92
  // same way a full save does (required-field findings depend on it).
103
- hydrateRecommendationStore: w
93
+ hydrateRecommendationStore: S
104
94
  };
105
95
  };
106
96
  export {
107
- _ as getHtmlReferencedUnsubscribePages,
108
- oe as useTemplatePreparation
97
+ O as getHtmlReferencedUnsubscribePages,
98
+ Z as useTemplatePreparation
109
99
  };
@@ -0,0 +1,10 @@
1
+ const E = /(<[a-z][\w:-]*(?:\s[^>]*?)?\shref\s*=\s*)(["'])([\s\S]*?)\2/gi, c = /^(?:\s|&nbsp;|&#160;|&#xa0;)+|(?:\s|&nbsp;|&#160;|&#xa0;)+$/gi;
2
+ function a(e) {
3
+ return !e || !/href/i.test(e) ? e : e.replace(E, (i, s, r, n) => {
4
+ const t = n.replace(c, "");
5
+ return `${s}${r}${t}${r}`;
6
+ });
7
+ }
8
+ export {
9
+ a as trimHrefWhitespace
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.24.0-beta.adaba3e",
3
+ "version": "3.24.0-beta.e4b6993",
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",
@@ -1,25 +0,0 @@
1
- import { object as e, optional as a, string as o, nullish as i, number as t, picklist as n, array as c } from "../node_modules/valibot/dist/index.js";
2
- const s = n(["liquid", "pongo"]), d = n(["codeOnly", "logicBuilder"]), r = e({
3
- id: t(),
4
- name: o(),
5
- description: i(o(), ""),
6
- syntax: s,
7
- method: d,
8
- codeBefore: o(),
9
- codeAfter: i(o(), ""),
10
- createdAt: a(o())
11
- }), p = e({
12
- data: c(r),
13
- meta: e({
14
- totalCount: t(),
15
- perPage: t(),
16
- currentPage: t(),
17
- lastPage: t()
18
- })
19
- });
20
- export {
21
- p as DisplayConditionListResponseSchema,
22
- d as DisplayConditionMethodSchema,
23
- s as DisplayConditionSyntaxSchema,
24
- r as SavedDisplayConditionSchema
25
- };
@@ -1,18 +0,0 @@
1
- import t from "./CodeEditorField.vue2.js";
2
- /* empty css */
3
- import i from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var s = function() {
5
- var e = this, r = e._self._c, o = e._self._setupProxy;
6
- return r("div", { staticClass: "guido-code-editor-field", attrs: { id: e.id } }, [r("p", { staticClass: "guido-code-editor-field__label" }, [e._v(" " + e._s(e.label) + " ")]), r(o.InCodeSnippet, { attrs: { code: e.value, disable: e.disabled, "focus-editor": !1, invalid: !!e.error, "invalid-message": e.error, options: o.options, size: { height: e.error ? 196 : 216 }, "syntax-check": !1 }, on: { input: o.onInput, ready: o.onReady } })], 1);
7
- }, a = [], d = /* @__PURE__ */ i(
8
- t,
9
- s,
10
- a,
11
- !1,
12
- null,
13
- "c262cac4"
14
- );
15
- const p = d.exports;
16
- export {
17
- p as default
18
- };
@@ -1,41 +0,0 @@
1
- import { defineComponent as f, computed as m, nextTick as _ } from "vue";
2
- import { InCodeSnippet as I } from "@useinsider/design-system-vue";
3
- const S = /* @__PURE__ */ f({
4
- __name: "CodeEditorField",
5
- props: {
6
- id: null,
7
- label: null,
8
- value: null,
9
- placeholder: { default: "" },
10
- error: { default: "" },
11
- disabled: { type: Boolean, default: !1 }
12
- },
13
- emits: ["input"],
14
- setup(r, { expose: a, emit: n }) {
15
- const l = r, u = 700;
16
- let t = null, e = null;
17
- const d = m(() => ({
18
- mode: "liquid",
19
- lint: !1,
20
- foldGutter: !1,
21
- placeholder: l.placeholder
22
- })), p = (o) => {
23
- t = o;
24
- }, s = (o) => {
25
- n("input", o), e == null || e();
26
- }, i = () => new Promise((o) => {
27
- if (!t || t.state.doc.toString() === l.value) {
28
- o(l.value);
29
- return;
30
- }
31
- const c = setTimeout(() => e == null ? void 0 : e(), u);
32
- e = () => {
33
- clearTimeout(c), e = null, _(() => o(l.value));
34
- };
35
- });
36
- return a({ read: i }), { __sfc: !0, props: l, emit: n, SANITIZED_INPUT_WAIT_MS: u, view: t, settleRead: e, options: d, onReady: p, onInput: s, read: i, InCodeSnippet: I };
37
- }
38
- });
39
- export {
40
- S as default
41
- };