@useinsider/guido 3.9.0-beta.ba394b1 → 3.9.0-beta.c84fcd0

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.
@@ -4,20 +4,21 @@ import e from "../static/styles/components/amp-block.css.js";
4
4
  import i from "../static/styles/components/base-input.css.js";
5
5
  import p from "../static/styles/components/button-group.css.js";
6
6
  import n from "../static/styles/components/button.css.js";
7
- import s from "../static/styles/components/combobox.css.js";
8
- import C from "../static/styles/components/counter.css.js";
7
+ import C from "../static/styles/components/combobox.css.js";
8
+ import s from "../static/styles/components/counter.css.js";
9
9
  import f from "../static/styles/components/dropdown-menu.css.js";
10
10
  import a from "../static/styles/components/loader.css.js";
11
11
  import u from "../static/styles/components/narrow-panel.css.js";
12
- import c from "../static/styles/components/popup.css.js";
13
- import d from "../static/styles/components/switcher.css.js";
14
- import l from "../static/styles/components/tabs.css.js";
15
- import h from "../static/styles/components/tools.css.js";
16
- import w from "../static/styles/components/version-history.css.js";
17
- import y from "../static/styles/components/wide-panel.css.js";
18
- import B from "../static/styles/variables.css.js";
19
- const b = [
20
- B,
12
+ import c from "../static/styles/components/notification.css.js";
13
+ import d from "../static/styles/components/popup.css.js";
14
+ import l from "../static/styles/components/switcher.css.js";
15
+ import h from "../static/styles/components/tabs.css.js";
16
+ import w from "../static/styles/components/tools.css.js";
17
+ import y from "../static/styles/components/version-history.css.js";
18
+ import B from "../static/styles/components/wide-panel.css.js";
19
+ import b from "../static/styles/variables.css.js";
20
+ const A = [
21
+ b,
21
22
  // Must be on top
22
23
  S,
23
24
  // Must be on top
@@ -26,8 +27,8 @@ const b = [
26
27
  i,
27
28
  p,
28
29
  n,
29
- s,
30
30
  C,
31
+ s,
31
32
  f,
32
33
  a,
33
34
  u,
@@ -36,12 +37,13 @@ const b = [
36
37
  l,
37
38
  h,
38
39
  w,
39
- y
40
+ y,
41
+ B
40
42
  ].join(`
41
43
 
42
- `), v = () => ({ importCss: () => {
44
+ `), F = () => ({ importCss: () => {
43
45
  const o = new CSSStyleSheet();
44
- o.replaceSync(b);
46
+ o.replaceSync(A);
45
47
  const r = document.querySelector("ui-editor");
46
48
  if (!r)
47
49
  return;
@@ -49,5 +51,5 @@ const b = [
49
51
  t && (t.adoptedStyleSheets = [o]);
50
52
  } });
51
53
  export {
52
- v as useCustomInterfaceAppearance
54
+ F as useCustomInterfaceAppearance
53
55
  };
@@ -1,30 +1,29 @@
1
- import { useActionsApi as U } from "./useActionsApi.js";
2
- import { useBlocksConfig as R } from "./useBlocksConfig.js";
3
- import { useConfig as x } from "./useConfig.js";
4
- import { useCustomInterfaceAppearance as O } from "./useCustomInterfaceAppearance.js";
5
- import { useFullStoryBridge as q } from "./useFullStoryBridge.js";
6
- import { useStripoEventHandler as H } from "./useStripoEventHandler.js";
7
- import { useStripoNotifications as N } from "./useStripoNotifications.js";
8
- import { useToaster as z } from "./useToaster.js";
9
- import { localePatch as L } from "../config/i18n/index.js";
1
+ import { useActionsApi as I } from "./useActionsApi.js";
2
+ import { useBlocksConfig as U } from "./useBlocksConfig.js";
3
+ import { useConfig as R } from "./useConfig.js";
4
+ import { useCustomInterfaceAppearance as x } from "./useCustomInterfaceAppearance.js";
5
+ import { useFullStoryBridge as O } from "./useFullStoryBridge.js";
6
+ import { useStripoEventHandler as q } from "./useStripoEventHandler.js";
7
+ import { useToaster as H } from "./useToaster.js";
8
+ import { localePatch as z } from "../config/i18n/index.js";
10
9
  import { en as h } from "../config/i18n/en/index.js";
11
- import { ToasterTypeOptions as $ } from "../enums/toaster.js";
12
- import { useStripoApi as G } from "../services/stripoApi.js";
13
- import J from "../static/styles/customEditorStyle.css.js";
10
+ import { ToasterTypeOptions as L } from "../enums/toaster.js";
11
+ import { useStripoApi as $ } from "../services/stripoApi.js";
12
+ import G from "../static/styles/customEditorStyle.css.js";
14
13
  import { useEditorStore as C } from "../stores/editor.js";
15
- import { dynamicContentToMergeTags as X } from "../utils/genericUtil.js";
16
- import j from "../package.json.js";
17
- const pe = (E, l) => {
18
- const { features: c, template: w, isFeatureEnabled: u } = x(), { handleError: m, showToaster: b } = z(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = G(), { handleEvent: F } = H(), { getStripoBlocksConfig: v } = R(), { getStripoNotifications: V } = N(), _ = async (s, i = [], r = !1) => {
14
+ import { dynamicContentToMergeTags as J } from "../utils/genericUtil.js";
15
+ import N from "../package.json.js";
16
+ const ce = (E, l) => {
17
+ const { features: c, template: w, isFeatureEnabled: u } = R(), { handleError: m, showToaster: b } = H(), { getToken: T, getCustomFonts: k, getSyncModulesStatus: B } = $(), { handleEvent: F } = q(), { getStripoBlocksConfig: v } = U(), V = async (s, r = [], i = !1) => {
19
18
  var g, S, y;
20
- const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, M = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, P = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
19
+ const e = C(), { html: p, css: a } = s, { baseBlocks: t, extensions: d } = await v(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, A = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, M = ((y = w.value) == null ? void 0 : y.forceRecreate) ?? !1;
21
20
  await window.UIEditor.initEditor(
22
21
  document.querySelector("#guido-editor"),
23
22
  {
24
23
  metadata: E,
25
24
  html: p,
26
25
  css: a,
27
- forceRecreate: P,
26
+ forceRecreate: M,
28
27
  locale: "en",
29
28
  undoButtonSelector: "#guido__undo-button",
30
29
  redoButtonSelector: "#guido__redo-button",
@@ -34,12 +33,12 @@ const pe = (E, l) => {
34
33
  customAppearanceMergetags: !u("liquidSyntax"),
35
34
  customAppearanceMergetagsBorderColor: "#f1f3fe",
36
35
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
37
- customViewStyles: J,
36
+ customViewStyles: G,
38
37
  conditionsEnabled: f,
39
38
  customConditionsEnabled: f,
40
39
  enableXSSSecurity: !0,
41
- modulesDisabled: M,
42
- syncModulesEnabled: r,
40
+ modulesDisabled: A,
41
+ syncModulesEnabled: i,
43
42
  messageSettingsEnabled: !0,
44
43
  displayGmailAnnotations: !0,
45
44
  displayHiddenPreheader: !1,
@@ -52,11 +51,11 @@ const pe = (E, l) => {
52
51
  editorFonts: {
53
52
  showDefaultStandardFonts: !0,
54
53
  showDefaultNotStandardFonts: !0,
55
- customFonts: i
54
+ customFonts: r
56
55
  },
57
56
  mergeTags: [
58
57
  {
59
- entries: X(
58
+ entries: J(
60
59
  l.preselectedDynamicContentList,
61
60
  u("liquidSyntax")
62
61
  )
@@ -72,8 +71,8 @@ const pe = (E, l) => {
72
71
  },
73
72
  onTemplateLoaded() {
74
73
  try {
75
- const { importCss: o } = O(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: D } = U(), { injectFullStory: I } = q();
76
- o(), n(), I(), D(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
74
+ const { importCss: o } = x(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: P } = I(), { injectFullStory: D } = O();
75
+ o(), n(), D(), P(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
77
76
  e.hasChanges = !1;
78
77
  }, 1e3);
79
78
  } catch (o) {
@@ -93,42 +92,41 @@ const pe = (E, l) => {
93
92
  e.hasChanges = !0;
94
93
  },
95
94
  onEvent: F,
96
- notifications: V(),
97
95
  ignoreClickOutsideSelectors: [
98
96
  "#guido-dynamic-content-modal",
99
97
  ".in-on-board-wrapper",
100
98
  ".in-drawer__container"
101
99
  ],
102
100
  extensions: d,
103
- localePatch: L
101
+ localePatch: z
104
102
  }
105
103
  );
106
- }, A = (s) => new Promise((i, r) => {
104
+ }, _ = (s) => new Promise((r, i) => {
107
105
  var d;
108
106
  if (document.getElementById("UiEditorScript")) {
109
- Promise.resolve(s()).then(i, r);
107
+ Promise.resolve(s()).then(r, i);
110
108
  return;
111
109
  }
112
- const e = j.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
110
+ const e = N.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, t = document.createElement("script");
113
111
  t.id = "UiEditorScript", t.type = "module", t.src = a, t.onload = () => {
114
- Promise.resolve(s()).then(i, r);
112
+ Promise.resolve(s()).then(r, i);
115
113
  }, t.onerror = () => {
116
- r(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
114
+ i(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
117
115
  }, document.body.appendChild(t);
118
116
  });
119
117
  return { initPlugin: async (s) => {
120
- const i = C();
118
+ const r = C();
121
119
  try {
122
- await A(async () => {
123
- const [r, e] = await Promise.all([
120
+ await _(async () => {
121
+ const [i, e] = await Promise.all([
124
122
  k(),
125
123
  B()
126
124
  ]);
127
- i.syncModulesEnabled = e, await _(s, r, e);
125
+ r.syncModulesEnabled = e, await V(s, i, e);
128
126
  });
129
127
  } catch {
130
- i.loadingStatus = !1, b({
131
- type: $.Alert,
128
+ r.loadingStatus = !1, b({
129
+ type: L.Alert,
132
130
  message: h["An error has occurred. Please report the error code to support."],
133
131
  actionButton: {
134
132
  text: h["Reload page"],
@@ -139,5 +137,5 @@ const pe = (E, l) => {
139
137
  } };
140
138
  };
141
139
  export {
142
- pe as useStripo
140
+ ce as useStripo
143
141
  };
@@ -1,12 +1,12 @@
1
- var B = Object.defineProperty;
2
- var v = (r, t, o) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
3
- var M = (r, t, o) => v(r, typeof t != "symbol" ? t + "" : t, o);
4
- import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
1
+ var v = Object.defineProperty;
2
+ var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
+ var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
4
+ import { BLOCK_ID as w } from "../../extensions/Blocks/Items/block.js";
5
5
  import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
- import { ItemInCartOptions as T, DefaultConfigValues as g, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
- import { getDefaultTemplate as w } from "../../extensions/Blocks/Items/template.js";
8
- import { useTemplateStore as F } from "../../stores/template.js";
9
- const q = {
6
+ import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as q } from "../../stores/template.js";
9
+ const x = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
12
12
  defaultKey: "DEFAULT",
@@ -76,77 +76,77 @@ const q = {
76
76
  function O() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function $(r) {
80
- return r ? {
81
- CartItems: s.ITEMS_TYPE.CART_ITEMS,
82
- BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
83
- PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
84
- CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
85
- BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
86
- PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
87
- }[r] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
79
+ function k(o) {
80
+ return o ? {
81
+ CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
+ BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
83
+ PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
84
+ CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
85
+ BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
86
+ PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
+ }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
88
88
  }
89
- function R(r) {
89
+ function h(o) {
90
90
  var e;
91
- const t = (c, _) => c == null ? _ : c === "1" || c === "true", o = (c, _) => c || _, l = r["data-type"] || r["data-source"], a = $(l), n = T[a];
92
- let i = r["data-cart_items_select_control_value"] || ((e = n == null ? void 0 : n[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
- if (i && !i.includes("{{") && /^\d+$/.test(i)) {
94
- const c = parseInt(i) - 1, _ = T[a];
95
- _ && _[c] && (i = _[c].value);
91
+ const t = (c, u) => c == null ? u : c === "1" || c === "true", r = (c, u) => c || u, l = o["data-type"] || o["data-source"], a = k(l), i = I[a];
92
+ let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
+ if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
+ const c = parseInt(n) - 1, u = I[a];
95
+ u && u[c] && (n = u[c].value);
96
96
  }
97
97
  return {
98
98
  initialized: !0,
99
- blockInstanceId: o(r["data-block-instance-id"], O()),
99
+ blockInstanceId: r(o["data-block-instance-id"], O()),
100
100
  source: a,
101
101
  type: a,
102
- itemsSelectValue: i,
103
- orientation: r["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
104
- nameTrimming: t(r["data-product_name_control_trim"], !0),
105
- priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
106
- priceFormatted: t(r["data-product_price_control_formated"], !0),
107
- priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
108
- priceCurrencySymbol: o(
109
- r["data-product_price_control_currency_symbol"],
102
+ itemsSelectValue: n,
103
+ orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
104
+ nameTrimming: t(o["data-product_name_control_trim"], !0),
105
+ priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
106
+ priceFormatted: t(o["data-product_price_control_formated"], !0),
107
+ priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
108
+ priceCurrencySymbol: r(
109
+ o["data-product_price_control_currency_symbol"],
110
110
  g.productPriceCurrencySymbolControlValue
111
111
  ),
112
- priceCurrencyLocation: o(
113
- r["data-product_price_currency_location"],
112
+ priceCurrencyLocation: r(
113
+ o["data-product_price_currency_location"],
114
114
  g.productPriceCurrencyLocationControlValue
115
115
  ),
116
- priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
117
- quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
118
- buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
119
- imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
120
- buttonLabel: o(r["data-product_button_control_label"], "Buy"),
121
- buttonFullWidth: t(r["data-product_button_control_atw"], !0),
122
- imageVisible: t(r["data-product_image_control_enabled"], !0),
123
- nameVisible: t(r["data-product_name_control_enabled"], !0),
124
- quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
125
- priceVisible: t(r["data-product_price_control_enabled"], !0),
126
- originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
127
- buttonVisible: t(r["data-product_button_control_enabled"], !0)
116
+ priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
117
+ quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
118
+ buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
119
+ imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
120
+ buttonLabel: r(o["data-product_button_control_label"], "Buy"),
121
+ buttonFullWidth: t(o["data-product_button_control_atw"], !0),
122
+ imageVisible: t(o["data-product_image_control_enabled"], !0),
123
+ nameVisible: t(o["data-product_name_control_enabled"], !0),
124
+ quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
125
+ priceVisible: t(o["data-product_price_control_enabled"], !0),
126
+ originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
127
+ buttonVisible: t(o["data-product_button_control_enabled"], !0)
128
128
  };
129
129
  }
130
- const x = {
130
+ const V = {
131
131
  ins_apr: "CART_ITEMS",
132
132
  browsed_item: "BROWSED_ITEMS",
133
133
  purchased_item: "PURCHASED_ITEMS"
134
134
  };
135
- function V(r, t) {
136
- const o = {
135
+ function $(o, t) {
136
+ const r = {
137
137
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
138
138
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
139
139
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
140
140
  };
141
- return o[r] || o.CART_ITEMS;
141
+ return r[o] || r.CART_ITEMS;
142
142
  }
143
- function N(r, t) {
144
- const o = {
143
+ function N(o, t) {
144
+ const r = {
145
145
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
146
146
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
147
147
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
148
148
  };
149
- return o[r] || o.CART_ITEMS;
149
+ return r[o] || r.CART_ITEMS;
150
150
  }
151
151
  class z {
152
152
  constructor() {
@@ -156,16 +156,16 @@ class z {
156
156
  migrate(t) {
157
157
  try {
158
158
  if (!this.containsItemsBlock(t))
159
- return t;
160
- let o = this.removeJinjaConditionals(t);
161
- o = this.replaceTemplateVariables(o);
162
- const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
159
+ return this.backfillV2ProductTdAttributes(t);
160
+ let r = this.removeJinjaConditionals(t);
161
+ r = this.replaceTemplateVariables(r);
162
+ const l = this.parser.parseFromString(r, "text/html"), a = l.querySelectorAll(
163
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
164
  );
165
- return F().$patch((i) => {
166
- i.migrations = { ...i.migrations, [U]: a.length };
167
- }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (a.forEach((i) => {
168
- const e = this.extractConfiguration(i), c = w({
165
+ return q().$patch((n) => {
166
+ n.migrations = { ...n.migrations, [w]: a.length };
167
+ }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
168
+ const e = this.extractConfiguration(n), c = F({
169
169
  orientation: e.orientation,
170
170
  itemsType: e.itemsType,
171
171
  itemId: e.itemId,
@@ -179,20 +179,20 @@ class z {
179
179
  priceStyles: e.priceStyles,
180
180
  originalPriceStyles: e.originalPriceStyles,
181
181
  quantityStyles: e.quantityStyles,
182
- nodeConfig: R(e.configBlockAttributes)
183
- }), u = this.parser.parseFromString(
182
+ nodeConfig: h(e.configBlockAttributes)
183
+ }), s = this.parser.parseFromString(
184
184
  `<table><tbody><tr>${c}</tr></tbody></table>`,
185
185
  "text/html"
186
186
  ).querySelector("td");
187
- if (u && i.parentNode) {
188
- const p = R(e.configBlockAttributes);
189
- u.setAttribute("esd-ext-config", JSON.stringify(p));
190
- const d = u.querySelector("esd-config-block");
191
- d && d.remove(), i.parentNode.replaceChild(u, i);
187
+ if (s && n.parentNode) {
188
+ const _ = h(e.configBlockAttributes);
189
+ s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
190
+ const d = s.querySelector("esd-config-block");
191
+ d && d.remove(), n.parentNode.replaceChild(s, n);
192
192
  }
193
193
  }), l.documentElement.outerHTML);
194
- } catch (o) {
195
- return console.error("ItemsBlockMigrator failed:", o), t;
194
+ } catch (r) {
195
+ return console.error("ItemsBlockMigrator failed:", r), t;
196
196
  }
197
197
  }
198
198
  /**
@@ -203,23 +203,25 @@ class z {
203
203
  */
204
204
  extractConfiguration(t) {
205
205
  var C, D, P;
206
- const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
207
- let b;
208
- S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
209
- const y = t.querySelector('a[product-attr="name"]'), I = (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, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
206
+ const r = k(
207
+ ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
+ ), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, l), b = d["data-card_orientation_control_value"];
209
+ let S;
210
+ b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
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, T = t.querySelector("p.original-price"), L = (T == null ? void 0 : T.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
210
212
  return {
211
- orientation: b,
212
- itemsType: o,
213
- itemId: i,
213
+ orientation: S,
214
+ itemsType: r,
215
+ itemId: n,
214
216
  currencySymbol: c,
215
- currencyLocation: u,
216
- formattedPrice: p,
217
+ currencyLocation: s,
218
+ formattedPrice: _,
217
219
  configBlockAttributes: d,
218
- nameStyles: I,
220
+ nameStyles: A,
219
221
  buttonStyles: m,
220
- priceStyles: k,
221
- originalPriceStyles: h,
222
- quantityStyles: L
222
+ priceStyles: R,
223
+ originalPriceStyles: L,
224
+ quantityStyles: B
223
225
  };
224
226
  }
225
227
  /**
@@ -229,27 +231,27 @@ class z {
229
231
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
230
232
  * @param itemNumber - The item number (1-based index)
231
233
  */
232
- extractConfigBlockAttributes(t, o, l) {
233
- const a = t.querySelector("esd-config-block"), n = {};
234
+ extractConfigBlockAttributes(t, r, l) {
235
+ const a = t.querySelector("esd-config-block"), i = {};
234
236
  if (!a)
235
237
  return this.getDefaultConfigBlockAttributes();
236
238
  if (Array.from(a.attributes).forEach((e) => {
237
- e.name.startsWith("data-") && (n[e.name] = e.value);
238
- }), n["data-cart_items_select_control_value"]) {
239
- const e = n["data-cart_items_select_control_value"];
239
+ e.name.startsWith("data-") && (i[e.name] = e.value);
240
+ }), i["data-cart_items_select_control_value"]) {
241
+ const e = i["data-cart_items_select_control_value"];
240
242
  if (/^\d+$/.test(e)) {
241
- const c = parseInt(e) - 1, _ = T[o];
242
- _ && _[c] && (n["data-cart_items_select_control_value"] = _[c].value);
243
+ const c = parseInt(e) - 1, u = I[r];
244
+ u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
243
245
  }
244
246
  }
245
- if (n["data-product_price_control_curency"]) {
246
- const e = n["data-product_price_control_curency"];
247
+ if (i["data-product_price_control_curency"]) {
248
+ const e = i["data-product_price_control_curency"];
247
249
  let c = e;
248
- e === "before" ? c = "0" : e === "after" && (c = "1"), n["data-product_price_control_curency"] = c, n["data-product_price_currency_location"] = c;
250
+ e === "before" ? c = "0" : e === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
249
251
  }
250
- (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
251
- const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
252
- return i["data-type"] = o, i["data-source"] = o, i["data-product_image_link"] = V(o, l), i["data-product_button_link"] = N(o, l), i;
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, l), n["data-product_button_link"] = N(r, l), n;
253
255
  }
254
256
  /**
255
257
  * Returns default esd-config-block attributes based on the old template structure
@@ -298,6 +300,49 @@ class z {
298
300
  "data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
299
301
  };
300
302
  }
303
+ /**
304
+ * Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
305
+ * from their persisted `esd-ext-config` nodeConfig, and strips the legacy
306
+ * static `width` that older builds baked onto the product-td.
307
+ *
308
+ * Why (data-type): templates migrated and saved by an older build can carry the
309
+ * correct product type in `esd-ext-config` while the `.ins-product-td` is missing
310
+ * the `data-type` DOM attribute. Stripo strips `esd-*` attributes during compile,
311
+ * so by save time only `data-type` survives for `pairProductVariables` to read
312
+ * when choosing the merge-tag namespace. Restoring it here (at load, before the
313
+ * editor compiles) makes the namespace resolve to the real source
314
+ * (browsed_item_ / purchased_item_) instead of defaulting to ins_apr_ (Cart).
315
+ *
316
+ * Why (width): the migrate output used to hardcode `width="560"` on the product-td,
317
+ * which made the block overflow narrow (33%/50%) columns and wrap. The generator
318
+ * no longer emits it; here we heal already-saved templates by removing it so the
319
+ * cell inherits its column width. width="560" was only ever written alongside
320
+ * esd-ext-config, so the guard below still catches every affected template.
321
+ *
322
+ * Only re-serializes when something actually changed, so healthy templates
323
+ * (data-type present, no static width) pass through byte-for-byte.
324
+ */
325
+ backfillV2ProductTdAttributes(t) {
326
+ if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
+ return t;
328
+ const r = this.parser.parseFromString(t, "text/html");
329
+ let l = !1;
330
+ return r.querySelectorAll(".ins-product-td").forEach((a) => {
331
+ if (a.hasAttribute("width") && (a.removeAttribute("width"), l = !0), a.getAttribute("data-type"))
332
+ return;
333
+ const i = a.getAttribute("esd-ext-config");
334
+ if (i)
335
+ try {
336
+ const n = JSON.parse(i), e = n.type || n.source;
337
+ if (!e)
338
+ return;
339
+ a.setAttribute("data-type", e), l = !0;
340
+ const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
341
+ c && a.getAttribute("data-number") !== c[1] && a.setAttribute("data-number", c[1]);
342
+ } catch {
343
+ }
344
+ }), l ? r.documentElement.outerHTML : t;
345
+ }
301
346
  /**
302
347
  * Fast check for the presence of any items block (cart / browsed / purchased)
303
348
  * in the raw HTML. Used to gate the migration pipeline so non-items templates
@@ -317,15 +362,15 @@ class z {
317
362
  * contains display condition Jinja scripts that should NOT be removed.
318
363
  */
319
364
  removeJinjaConditionals(t) {
320
- const o = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
321
- let a = l ? t.replace(l[0], o) : t;
365
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
366
+ let a = l ? t.replace(l[0], r) : t;
322
367
  return a = a.replace(
323
368
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
324
369
  ""
325
370
  ), a = a.replace(
326
371
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
327
372
  ""
328
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(o, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
373
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(r, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
329
374
 
330
375
  `), a;
331
376
  }
@@ -339,31 +384,31 @@ class z {
339
384
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
340
385
  */
341
386
  replaceTemplateVariables(t) {
342
- const { PAIRS_FOR_EXTENSION: o } = K;
387
+ const { PAIRS_FOR_EXTENSION: r } = K;
343
388
  return t.replace(/{{([^}]+)}}/g, (l, a) => {
344
- const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
345
- if (!n)
389
+ const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
390
+ if (!i)
346
391
  return l;
347
- const [, i, e, c] = n, _ = x[i];
348
- if (!_)
349
- return console.warn(`Unknown variable prefix: ${i}`), l;
350
- const u = q[e];
392
+ const [, n, e, c] = i, u = V[n];
351
393
  if (!u)
394
+ return console.warn(`Unknown variable prefix: ${n}`), l;
395
+ const s = x[e];
396
+ if (!s)
352
397
  return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
353
- const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
398
+ const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
354
399
  if (!y)
355
- return console.warn(`No data found for: ${p}.${_}`), l;
356
- if (S) {
400
+ return console.warn(`No data found for: ${_}.${u}`), l;
401
+ if (b) {
357
402
  const f = parseInt(c) - 1, m = y[d];
358
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
403
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), l);
359
404
  }
360
- const I = y[d];
361
- return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
405
+ const A = y[d];
406
+ return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), l);
362
407
  });
363
408
  }
364
409
  }
365
- function Q(r) {
366
- return new z().migrate(r);
410
+ function Q(o) {
411
+ return new z().migrate(o);
367
412
  }
368
413
  export {
369
414
  Q as migrateItemsBlock
@@ -1,4 +1,4 @@
1
- var n = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "error", r.Info = "information", r))(n || {});
1
+ var c = /* @__PURE__ */ ((r) => (r.Success = "success", r.Warning = "warning", r.Alert = "alert", r.Dark = "dark", r))(c || {});
2
2
  export {
3
- n as ToasterTypeOptions
3
+ c as ToasterTypeOptions
4
4
  };