@useinsider/guido 3.6.0-beta.0e98cf4 → 3.6.0-beta.177b0b7

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,42 +1,42 @@
1
- var J = Object.defineProperty;
2
- var Q = (p, _, t) => _ in p ? J(p, _, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[_] = t;
3
- var S = (p, _, t) => Q(p, typeof _ != "symbol" ? _ + "" : _, t);
4
- import { UIElementType as f, UEAttr as I, ModificationDescription as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as Z } from "../../../common-control.js";
6
- import { ATTR_PRODUCT_IMAGE as D, ATTR_PRODUCT_NAME as tt, ATTR_PRODUCT_PRICE as et, ATTR_PRODUCT_OLD_PRICE as rt, ATTR_PRODUCT_OMNIBUS_PRICE as ot, ATTR_PRODUCT_OMNIBUS_DISCOUNT as st, ATTR_PRODUCT_BUTTON as U, ATTR_DATA_CUSTOM_ATTRIBUTES as q, ATTR_CUSTOM_PREFIX as m, BUILT_IN_DEFAULT_ATTRIBUTES as it } from "../../constants/selectors.js";
7
- import { DEFAULT_COMPOSITION as P, DEFAULT_VISIBILITY as F } from "../../constants/defaultConfig.js";
8
- import { RecommendationConfigService as nt } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as lt } from "../../store/recommendation.js";
10
- import { ATTRIBUTE_CELL_CLASS as at, gridElementRenderer as ct, DEFAULT_CELL_PADDING as ut, buildFillerCell as dt } from "../../templates/grid/elementRenderer.js";
11
- import { listElementRenderer as mt } from "../../templates/list/elementRenderer.js";
12
- import { toDisplayName as ht, isDefaultAttribute as pt, toDisplayableAttributeValue as _t, buildElementRenderer as w } from "../../templates/utils.js";
13
- import { getTableDisplayValue as ft } from "../../utils/tagName.js";
14
- import { getCurrentLayout as gt } from "../main/utils.js";
15
- const bt = "ui-elements-recommendation-card-composition", C = ".recommendation-attribute-row", L = ".product-card-wrapper > tbody", M = ".product-info-cell > table > tbody", V = "data-card-composition", y = "data-attribute-type", v = "data-visibility", x = {
1
+ var X = Object.defineProperty;
2
+ var J = (p, _, t) => _ in p ? X(p, _, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[_] = t;
3
+ var C = (p, _, t) => J(p, typeof _ != "symbol" ? _ + "" : _, t);
4
+ import { UIElementType as f, UEAttr as $, ModificationDescription as A } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as Q } from "../../../common-control.js";
6
+ import { ATTR_PRODUCT_IMAGE as L, ATTR_PRODUCT_NAME as Z, ATTR_PRODUCT_PRICE as tt, ATTR_PRODUCT_OLD_PRICE as et, ATTR_PRODUCT_OMNIBUS_PRICE as rt, ATTR_PRODUCT_OMNIBUS_DISCOUNT as ot, ATTR_PRODUCT_BUTTON as D, ATTR_DATA_CUSTOM_ATTRIBUTES as k, ATTR_CUSTOM_PREFIX as m, BUILT_IN_DEFAULT_ATTRIBUTES as st } from "../../constants/selectors.js";
7
+ import { DEFAULT_COMPOSITION as q, DEFAULT_VISIBILITY as P } from "../../constants/defaultConfig.js";
8
+ import { RecommendationConfigService as it } from "../../services/configService.js";
9
+ import { useRecommendationExtensionStore as nt } from "../../store/recommendation.js";
10
+ import { ATTRIBUTE_CELL_CLASS as lt, gridElementRenderer as at, DEFAULT_CELL_PADDING as ct } from "../../templates/grid/elementRenderer.js";
11
+ import { listElementRenderer as ut } from "../../templates/list/elementRenderer.js";
12
+ import { toDisplayName as dt, isDefaultAttribute as mt, buildElementRenderer as F } from "../../templates/utils.js";
13
+ import { getTableDisplayValue as ht } from "../../utils/tagName.js";
14
+ import { getCurrentLayout as pt } from "../main/utils.js";
15
+ const _t = "ui-elements-recommendation-card-composition", S = ".recommendation-attribute-row", N = ".product-card-wrapper > tbody", w = ".product-info-cell > table > tbody", M = "data-card-composition", y = "data-attribute-type", I = "data-visibility", x = {
16
16
  ADD_ATTRIBUTE: "addAttribute"
17
- }, g = 5, E = "reorderIcon_", h = [
18
- { key: D, label: "Product Image" },
19
- { key: tt, label: "Product Name" },
20
- { key: et, label: "Product Price" },
21
- { key: rt, label: "Product Original Price" },
22
- { key: ot, label: "Omnibus Price" },
23
- { key: st, label: "Omnibus Discount" },
24
- { key: U, label: "Product Button" }
25
- ], yt = new Set(h.map((p) => p.key)), T = "customAttr_", R = "deleteAttr_";
26
- class Ut extends Z {
17
+ }, g = 5, v = "reorderIcon_", h = [
18
+ { key: L, label: "Product Image" },
19
+ { key: Z, label: "Product Name" },
20
+ { key: tt, label: "Product Price" },
21
+ { key: et, label: "Product Original Price" },
22
+ { key: rt, label: "Omnibus Price" },
23
+ { key: ot, label: "Omnibus Discount" },
24
+ { key: D, label: "Product Button" }
25
+ ], ft = new Set(h.map((p) => p.key)), T = "customAttr_", E = "deleteAttr_";
26
+ class Nt extends Q {
27
27
  constructor() {
28
28
  super(...arguments);
29
- S(this, "store", lt());
30
- S(this, "unsubscribeStore", null);
31
- S(this, "eventController", null);
29
+ C(this, "store", nt());
30
+ C(this, "unsubscribeStore", null);
31
+ C(this, "eventController", null);
32
32
  /**
33
33
  * Guard flag: when true, onTemplateNodeUpdated skips _initializeComposition.
34
34
  * Used during _onReorder to prevent multiple intermediate rebuilds.
35
35
  */
36
- S(this, "reorderInProgress", !1);
36
+ C(this, "reorderInProgress", !1);
37
37
  }
38
38
  getId() {
39
- return bt;
39
+ return _t;
40
40
  }
41
41
  // ========================================================================
42
42
  // Lifecycle
@@ -60,10 +60,10 @@ class Ut extends Z {
60
60
  ).join(""), e = h.length + g, o = Array.from(
61
61
  { length: e },
62
62
  (l, u) => `
63
- <div data-reorder-icon-key="${E}${u}" style="display: none;">
63
+ <div data-reorder-icon-key="${v}${u}" style="display: none;">
64
64
  <${f.BUTTON}
65
65
  class="drag-handle-btn flat-inline flat-white"
66
- ${I.BUTTON.name}="${E}${u}"
66
+ ${$.BUTTON.name}="${v}${u}"
67
67
  >
68
68
  <${f.ICON}
69
69
  src="reorder"
@@ -75,10 +75,10 @@ class Ut extends Z {
75
75
  ).join(""), s = Array.from(
76
76
  { length: g },
77
77
  (l, u) => `
78
- <div data-custom-delete-key="${R}${u}" style="display: none;">
78
+ <div data-custom-delete-key="${E}${u}" style="display: none;">
79
79
  <${f.BUTTON}
80
80
  class="custom-attr-delete flat-inline flat-white"
81
- ${I.BUTTON.name}="${R}${u}"
81
+ ${$.BUTTON.name}="${E}${u}"
82
82
  >
83
83
  <${f.ICON}
84
84
  src="delete"
@@ -89,15 +89,15 @@ class Ut extends Z {
89
89
  `
90
90
  ).join(""), i = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", n = this.api.translate(
91
91
  "Drag and drop the card elements to reorder them, adjust their visibility or add new attributes up to 5."
92
- ), a = this.api.translate("For more information, you can"), c = this.api.translate("visit Academy");
92
+ ), c = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
93
93
  return `
94
94
  <div class="recommendation-controls-container" data-card-composition-control>
95
95
  <div class="container">
96
96
  <p class="card-composition-description">
97
97
  ${n}
98
- ${a}
98
+ ${c}
99
99
  <!-- cspell:disable-next-line -->
100
- <a href="${i}" target="_blank" rel="noopener noreferrer">${c}</a>.
100
+ <a href="${i}" target="_blank" rel="noopener noreferrer">${a}</a>.
101
101
  </p>
102
102
  </div>
103
103
 
@@ -161,14 +161,14 @@ class Ut extends Z {
161
161
  // ========================================================================
162
162
  _readCompositionFromNode() {
163
163
  if (!this.currentNode || !("getAttribute" in this.currentNode))
164
- return [...P];
165
- const t = this.currentNode.getAttribute(V);
166
- return t ? t.split(",").filter(Boolean) : [...P];
164
+ return [...q];
165
+ const t = this.currentNode.getAttribute(M);
166
+ return t ? t.split(",").filter(Boolean) : [...q];
167
167
  }
168
168
  _readCustomAttributesFromNode() {
169
169
  if (!this.currentNode || !("getAttribute" in this.currentNode))
170
170
  return [];
171
- const t = this.currentNode.getAttribute(q);
171
+ const t = this.currentNode.getAttribute(k);
172
172
  if (!t)
173
173
  return [];
174
174
  try {
@@ -180,18 +180,18 @@ class Ut extends Z {
180
180
  _readVisibilityFromRows() {
181
181
  if (!this.currentNode)
182
182
  return this._getDefaultVisibilities();
183
- const t = Array.from(this.currentNode.querySelectorAll(C)), r = this._extractVisibilityFromRows(t);
183
+ const t = Array.from(this.currentNode.querySelectorAll(S)), r = this._extractVisibilityFromRows(t);
184
184
  return this._mergeWithDefaults(r);
185
185
  }
186
186
  _getDefaultVisibilities() {
187
- return { ...F };
187
+ return { ...P };
188
188
  }
189
189
  _extractVisibilityFromRows(t) {
190
190
  const r = {};
191
191
  return t.forEach((e) => {
192
192
  if (!("getAttribute" in e))
193
193
  return;
194
- const o = e.getAttribute(y), s = e.getAttribute(v);
194
+ const o = e.getAttribute(y), s = e.getAttribute(I);
195
195
  o && s !== null && (r[o] = this._parseVisibilityValue(s));
196
196
  }), r;
197
197
  }
@@ -199,7 +199,7 @@ class Ut extends Z {
199
199
  return t === "1" || t === "true";
200
200
  }
201
201
  _mergeWithDefaults(t) {
202
- return Object.entries(F).forEach(([r, e]) => {
202
+ return Object.entries(P).forEach(([r, e]) => {
203
203
  r in t || (t[r] = e);
204
204
  }), t;
205
205
  }
@@ -223,19 +223,19 @@ class Ut extends Z {
223
223
  return !1;
224
224
  const s = new Set(r);
225
225
  let i = 0, n = 0;
226
- const a = t.map((c) => {
227
- if (yt.has(c)) {
228
- const l = h.find((u) => u.key === c);
226
+ const c = t.map((a) => {
227
+ if (ft.has(a)) {
228
+ const l = h.find((u) => u.key === a);
229
229
  return this._createBuiltInItemHtml(l, n++);
230
230
  }
231
- if (c.startsWith(m)) {
232
- const l = c.substring(m.length);
231
+ if (a.startsWith(m)) {
232
+ const l = a.substring(m.length);
233
233
  if (s.has(l))
234
- return this._createCustomItemHtml(c, i++, n++);
234
+ return this._createCustomItemHtml(a, i++, n++);
235
235
  }
236
236
  return "";
237
237
  }).join("");
238
- return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML = a, this._moveTogglesIntoItems(e), this._moveSelectsIntoItems(e, r.length), this._moveDeleteButtonsIntoItems(e, r.length), this._moveReorderIconsIntoItems(e, n), !0;
238
+ return this._rescueTogglesToStore(e), this._rescueSelectsToStore(e), this._rescueDeleteButtonsToStore(e), this._rescueReorderIconsToStore(e), o.innerHTML = c, this._moveTogglesIntoItems(e), this._moveSelectsIntoItems(e, r.length), this._moveDeleteButtonsIntoItems(e, r.length), this._moveReorderIconsIntoItems(e, n), !0;
239
239
  }
240
240
  /**
241
241
  * Attempts to reorder existing orderable-item elements to match the composition order.
@@ -247,27 +247,27 @@ class Ut extends Z {
247
247
  const e = Array.from(t.querySelectorAll(".orderable-item"));
248
248
  if (e.length !== r.length)
249
249
  return !1;
250
- const o = e.map((c) => c.dataset.key).filter(Boolean);
250
+ const o = e.map((a) => a.dataset.key).filter(Boolean);
251
251
  if (o.length !== r.length)
252
252
  return !1;
253
253
  const s = [...o].sort().join(","), i = [...r].sort().join(",");
254
- if (s !== i || r.some((c) => c.startsWith(m)))
254
+ if (s !== i || r.some((a) => a.startsWith(m)))
255
255
  return !1;
256
256
  const n = /* @__PURE__ */ new Map();
257
- e.forEach((c) => {
258
- const { key: l } = c.dataset;
257
+ e.forEach((a) => {
258
+ const { key: l } = a.dataset;
259
259
  if (l) {
260
260
  const u = n.get(l) || [];
261
- u.push(c), n.set(l, u);
261
+ u.push(a), n.set(l, u);
262
262
  }
263
263
  });
264
- const a = /* @__PURE__ */ new Map();
265
- return r.forEach((c) => {
266
- const l = n.get(c);
264
+ const c = /* @__PURE__ */ new Map();
265
+ return r.forEach((a) => {
266
+ const l = n.get(a);
267
267
  if (!l)
268
268
  return;
269
- const u = a.get(c) || 0;
270
- a.set(c, u + 1), l[u] && t.appendChild(l[u]);
269
+ const u = c.get(a) || 0;
270
+ c.set(a, u + 1), l[u] && t.appendChild(l[u]);
271
271
  }), !0;
272
272
  }
273
273
  _createBuiltInItemHtml(t, r) {
@@ -316,7 +316,7 @@ class Ut extends Z {
316
316
  t.length !== 0 && setTimeout(() => {
317
317
  t.forEach((r, e) => {
318
318
  const o = `${T}${e}`, s = this._getSelectOptions(r, t);
319
- this.api.setUIEAttribute(o, I.SELECTPICKER.items, s), this.api.updateValues({ [o]: r });
319
+ this.api.setUIEAttribute(o, $.SELECTPICKER.items, s), this.api.updateValues({ [o]: r });
320
320
  });
321
321
  }, 0);
322
322
  }
@@ -380,7 +380,7 @@ class Ut extends Z {
380
380
  */
381
381
  _moveDeleteButtonsIntoItems(t, r) {
382
382
  for (let e = 0; e < r; e++) {
383
- const o = `${R}${e}`, s = t.querySelector(`[data-custom-delete-key="${o}"]`), i = t.querySelector(`[data-custom-delete-slot="${e}"]`);
383
+ const o = `${E}${e}`, s = t.querySelector(`[data-custom-delete-key="${o}"]`), i = t.querySelector(`[data-custom-delete-slot="${e}"]`);
384
384
  if (s && i) {
385
385
  const n = s.querySelector("ue-button");
386
386
  n && i.appendChild(n);
@@ -393,7 +393,7 @@ class Ut extends Z {
393
393
  */
394
394
  _rescueDeleteButtonsToStore(t) {
395
395
  for (let r = 0; r < g; r++) {
396
- const e = `${R}${r}`, o = t.querySelector(`[data-custom-delete-key="${e}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
396
+ const e = `${E}${r}`, o = t.querySelector(`[data-custom-delete-key="${e}"]`), s = t.querySelector(`[data-custom-delete-slot="${r}"]`);
397
397
  if (s) {
398
398
  const i = s.querySelector("ue-button");
399
399
  i && o && o.appendChild(i);
@@ -406,7 +406,7 @@ class Ut extends Z {
406
406
  */
407
407
  _moveReorderIconsIntoItems(t, r) {
408
408
  for (let e = 0; e < r; e++) {
409
- const o = `${E}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
409
+ const o = `${v}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
410
410
  if (s && i) {
411
411
  const n = s.querySelector("ue-button");
412
412
  n && i.appendChild(n);
@@ -420,7 +420,7 @@ class Ut extends Z {
420
420
  _rescueReorderIconsToStore(t) {
421
421
  const r = h.length + g;
422
422
  for (let e = 0; e < r; e++) {
423
- const o = `${E}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
423
+ const o = `${v}${e}`, s = t.querySelector(`[data-reorder-icon-key="${o}"]`), i = t.querySelector(`[data-reorder-icon-slot="${e}"]`);
424
424
  if (i) {
425
425
  const n = i.querySelector("ue-button");
426
426
  n && s && s.appendChild(n);
@@ -444,22 +444,22 @@ class Ut extends Z {
444
444
  _setupDragAndDrop(t, r) {
445
445
  let e = null, o = null;
446
446
  t.addEventListener("dragstart", (s) => {
447
- var a;
447
+ var c;
448
448
  const n = s.target.closest(".orderable-item");
449
- n && (e = n, n.classList.add("dragging"), (a = s.dataTransfer) == null || a.setData("text/plain", n.dataset.key || ""));
449
+ n && (e = n, n.classList.add("dragging"), (c = s.dataTransfer) == null || c.setData("text/plain", n.dataset.key || ""));
450
450
  }, { signal: r }), t.addEventListener("dragend", () => {
451
451
  e && e.classList.remove("dragging"), e = null, o == null || o.classList.remove("drag-over"), o = null;
452
452
  }, { signal: r }), t.addEventListener("dragover", (s) => {
453
453
  s.preventDefault();
454
- const n = s.target.closest(".orderable-item"), a = n && n !== e ? n : null;
455
- a !== o && (o == null || o.classList.remove("drag-over"), o = a, o == null || o.classList.add("drag-over"));
454
+ const n = s.target.closest(".orderable-item"), c = n && n !== e ? n : null;
455
+ c !== o && (o == null || o.classList.remove("drag-over"), o = c, o == null || o.classList.add("drag-over"));
456
456
  }, { signal: r }), t.addEventListener("drop", (s) => {
457
457
  s.preventDefault();
458
458
  const n = s.target.closest(".orderable-item");
459
459
  if (!n || !e || n === e)
460
460
  return;
461
- const a = n.getBoundingClientRect(), c = a.top + a.height / 2;
462
- s.clientY < c ? t.insertBefore(e, n) : t.insertBefore(e, n.nextSibling), o == null || o.classList.remove("drag-over"), o = null, e.classList.remove("dragging");
461
+ const c = n.getBoundingClientRect(), a = c.top + c.height / 2;
462
+ s.clientY < a ? t.insertBefore(e, n) : t.insertBefore(e, n.nextSibling), o == null || o.classList.remove("drag-over"), o = null, e.classList.remove("dragging");
463
463
  const u = t.querySelectorAll(".orderable-item"), d = Array.from(u).map((b) => b.dataset.key).filter(Boolean);
464
464
  this._onReorder(d), e = null;
465
465
  }, { signal: r });
@@ -490,7 +490,7 @@ class Ut extends Z {
490
490
  const r = this._readCustomAttributesFromNode();
491
491
  if (r[t] === void 0)
492
492
  return;
493
- const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((a, c) => c !== s), n = r.filter((a, c) => c !== t);
493
+ const o = this._readCompositionFromNode(), s = this._findNthCustomKeyIndex(o, t), i = o.filter((c, a) => a !== s), n = r.filter((c, a) => a !== t);
494
494
  this._updateBothAttributes(i, n), this._removeCustomAttributeHtml(i), this._renderOrderableItems(i, n), this._initializeCustomSelects(n), this._updateAddButtonState();
495
495
  }
496
496
  /**
@@ -503,8 +503,8 @@ class Ut extends Z {
503
503
  return;
504
504
  const s = `${m}${r}`, i = this._readCompositionFromNode(), n = this._findNthCustomKeyIndex(i, t);
505
505
  n !== -1 && (i[n] = s), e[t] = r;
506
- const a = this._getDisplayNameForAttribute(r);
507
- this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r, a, s, i), this._renderOrderableItems(i, e), this._initializeCustomSelects(e);
506
+ const c = this._getDisplayNameForAttribute(r);
507
+ this._updateBothAttributes(i, e), this._injectCustomAttributeHtml(r, c, s, i), this._renderOrderableItems(i, e), this._initializeCustomSelects(e);
508
508
  }
509
509
  _onReorder(t) {
510
510
  const r = t.filter((e) => e.startsWith(m)).map((e) => e.substring(m.length));
@@ -525,60 +525,56 @@ class Ut extends Z {
525
525
  this._getCurrentLayout() === "grid" ? this._injectGridAttributeRow(t, r, e, o) : this._injectListAttributeRow(t, r, e, o);
526
526
  }
527
527
  _injectGridAttributeRow(t, r, e, o) {
528
- const s = this.currentNode.querySelectorAll(L);
528
+ const s = this.currentNode.querySelectorAll(N);
529
529
  if (!(s != null && s.length))
530
530
  return;
531
- const i = nt.getConfig(this.currentNode), a = `0 ${Math.floor(i.columnSpacing / 2)}px`, c = this.api.getDocumentModifier(), l = this.store.recommendationProducts.length;
531
+ const i = it.getConfig(this.currentNode), c = `0 ${Math.floor(i.columnSpacing / 2)}px`, a = this.api.getDocumentModifier(), l = this.store.recommendationProducts.length;
532
532
  let u = 0;
533
533
  s.forEach((d) => {
534
- var H;
535
- const b = d.querySelector(C), $ = ((H = b == null ? void 0 : b.querySelectorAll(`.${at}`)) == null ? void 0 : H.length) || 1, B = (100 / $).toFixed(2), { bgStyle: j, bgAttr: W } = this._extractSegmentBgFromCard(d), O = l > 0 ? Math.min($, l - u) : $, K = o.map((k) => {
536
- if (k === e) {
534
+ var U;
535
+ const b = d.querySelector(S), R = ((U = b == null ? void 0 : b.querySelectorAll(`.${lt}`)) == null ? void 0 : U.length) || 1, V = (100 / R).toFixed(2), { bgStyle: j, bgAttr: W } = this._extractSegmentBgFromCard(d), K = o.map((B) => {
536
+ if (B === e) {
537
537
  const z = Array.from(
538
- { length: O },
539
- (At, Y) => {
540
- const X = this._resolveAttributeContent(
541
- t,
542
- r,
543
- u + Y
544
- );
538
+ { length: R },
539
+ (gt, H) => {
540
+ const G = l > 0 ? (u + H) % l : H, Y = this._resolveAttributeContent(t, r, G);
545
541
  return this._getGridCellHtml(
546
542
  t,
547
- X,
548
- B,
543
+ Y,
544
+ V,
549
545
  j,
550
546
  W,
551
- a
547
+ c
552
548
  );
553
549
  }
554
- ).join(""), G = dt(B, a).repeat($ - O);
555
- return `<tr class="recommendation-attribute-row" ${y}="${e}" ${v}="1">${z}${G}</tr>`;
550
+ ).join("");
551
+ return `<tr class="recommendation-attribute-row" ${y}="${e}" ${I}="1">${z}</tr>`;
556
552
  }
557
- const N = d.querySelector(
558
- `${C}[${y}="${k}"]`
553
+ const O = d.querySelector(
554
+ `${S}[${y}="${B}"]`
559
555
  );
560
- return N && "getOuterHTML" in N ? N.getOuterHTML() : "";
556
+ return O && "getOuterHTML" in O ? O.getOuterHTML() : "";
561
557
  }).join("");
562
- u += O, l > 0 && u >= l && (u = 0), c.modifyHtml(d).setInnerHtml(K);
563
- }), c.apply(new A(`${this.api.translate("Add custom attribute")}: ${r}`));
558
+ u += R, l > 0 && u >= l && (u = 0), a.modifyHtml(d).setInnerHtml(K);
559
+ }), a.apply(new A(`${this.api.translate("Add custom attribute")}: ${r}`));
564
560
  }
565
561
  _injectListAttributeRow(t, r, e, o) {
566
- const s = this.currentNode.querySelectorAll(M);
562
+ const s = this.currentNode.querySelectorAll(w);
567
563
  if (!(s != null && s.length))
568
564
  return;
569
- const i = o.filter((a) => a !== D && a !== U), n = this.api.getDocumentModifier();
570
- s.forEach((a, c) => {
565
+ const i = o.filter((c) => c !== L && c !== D), n = this.api.getDocumentModifier();
566
+ s.forEach((c, a) => {
571
567
  const l = i.map((u) => {
572
568
  if (u === e) {
573
- const b = this._resolveAttributeContent(t, r, c);
569
+ const b = this._resolveAttributeContent(t, r, a);
574
570
  return this._getListRowHtml(t, b, e);
575
571
  }
576
- const d = a.querySelector(
577
- `${C}[${y}="${u}"]`
572
+ const d = c.querySelector(
573
+ `${S}[${y}="${u}"]`
578
574
  );
579
575
  return d && "getOuterHTML" in d ? d.getOuterHTML() : "";
580
576
  }).join("");
581
- n.modifyHtml(a).setInnerHtml(l);
577
+ n.modifyHtml(c).setInnerHtml(l);
582
578
  }), n.apply(new A(`${this.api.translate("Add custom attribute")}: ${r}`));
583
579
  }
584
580
  /**
@@ -590,13 +586,13 @@ class Ut extends Z {
590
586
  return;
591
587
  const r = this._getCurrentLayout(), e = this.api.getDocumentModifier();
592
588
  if (r === "grid") {
593
- const o = this.currentNode.querySelectorAll(L);
589
+ const o = this.currentNode.querySelectorAll(N);
594
590
  o == null || o.forEach((s) => {
595
591
  const i = this._buildCompositionHtml(s, t);
596
592
  e.modifyHtml(s).setInnerHtml(i);
597
593
  });
598
594
  } else {
599
- const o = t.filter((i) => i !== D && i !== U), s = this.currentNode.querySelectorAll(M);
595
+ const o = t.filter((i) => i !== L && i !== D), s = this.currentNode.querySelectorAll(w);
600
596
  s == null || s.forEach((i) => {
601
597
  const n = this._buildCompositionHtml(i, o);
602
598
  e.modifyHtml(i).setInnerHtml(n);
@@ -615,7 +611,7 @@ class Ut extends Z {
615
611
  * producing a flicker on the custom attribute dropdowns.
616
612
  */
617
613
  _updateBothAttributes(t, r) {
618
- this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(V, t.join(",")).setAttribute(q, JSON.stringify(r)).apply(new A(this.api.translate("Update card composition")));
614
+ this.currentNode && this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(M, t.join(",")).setAttribute(k, JSON.stringify(r)).apply(new A(this.api.translate("Update card composition")));
619
615
  }
620
616
  /**
621
617
  * Reorders attribute rows within each product card based on composition order.
@@ -624,7 +620,7 @@ class Ut extends Z {
624
620
  _reorderProductAttributes(t) {
625
621
  if (!this.currentNode)
626
622
  return;
627
- const r = this.currentNode.querySelectorAll(L);
623
+ const r = this.currentNode.querySelectorAll(N);
628
624
  if (!(r != null && r.length))
629
625
  return;
630
626
  const e = this.api.getDocumentModifier();
@@ -639,7 +635,7 @@ class Ut extends Z {
639
635
  */
640
636
  _buildCompositionHtml(t, r) {
641
637
  return r.reduce((e, o) => {
642
- const s = t.querySelector(`${C}[${y}="${o}"]`);
638
+ const s = t.querySelector(`${S}[${y}="${o}"]`);
643
639
  return s && "getOuterHTML" in s ? e + s.getOuterHTML() : e;
644
640
  }, "");
645
641
  }
@@ -649,13 +645,13 @@ class Ut extends Z {
649
645
  _applyVisibilityToBlock(t, r) {
650
646
  if (!this.currentNode)
651
647
  return;
652
- const e = this.currentNode.querySelectorAll(`${C}[${y}="${t}"]`);
648
+ const e = this.currentNode.querySelectorAll(`${S}[${y}="${t}"]`);
653
649
  if (!(e != null && e.length))
654
650
  return;
655
651
  const o = r ? "1" : "0", s = r ? this.api.translate("visible") : this.api.translate("hidden"), i = `${this.api.translate("Set visibility")}: ${t} → ${s}`, n = this.api.getDocumentModifier();
656
- e.forEach((a) => {
657
- const c = ft(a), l = r ? c : "none";
658
- n.modifyHtml(a).setStyle("display", l).setAttribute(v, o);
652
+ e.forEach((c) => {
653
+ const a = ht(c), l = r ? a : "none";
654
+ n.modifyHtml(c).setStyle("display", l).setAttribute(I, o);
659
655
  }), n.apply(new A(i));
660
656
  }
661
657
  // ========================================================================
@@ -677,7 +673,7 @@ class Ut extends Z {
677
673
  return -1;
678
674
  }
679
675
  _getCurrentLayout() {
680
- return this.store.recommendationConfigs.orientation || gt(this.currentNode);
676
+ return this.store.recommendationConfigs.orientation || pt(this.currentNode);
681
677
  }
682
678
  /**
683
679
  * Extracts background color properties from existing card elements.
@@ -731,7 +727,7 @@ class Ut extends Z {
731
727
  const t = this._readCustomAttributesFromNode(), r = t.length >= g, e = new Set(t), o = this._getAddableFilters(), s = o.length > 0 && o.every((i) => e.has(i.attributeName));
732
728
  this.api.setUIEAttribute(
733
729
  x.ADD_ATTRIBUTE,
734
- I.BUTTON.disabled,
730
+ $.BUTTON.disabled,
735
731
  r || s ? "true" : "false"
736
732
  );
737
733
  }
@@ -754,7 +750,7 @@ class Ut extends Z {
754
750
  * excluding default attributes already covered by built-in toggle items.
755
751
  */
756
752
  _getAddableFilters() {
757
- return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" && it.has(t.attributeName)));
753
+ return Object.values(this.store.filterList).filter((t) => !(t.type === "defaultAttribute" && st.has(t.attributeName)));
758
754
  }
759
755
  /**
760
756
  * Looks up the display name for an attribute from the store's filterList.
@@ -762,7 +758,7 @@ class Ut extends Z {
762
758
  */
763
759
  _getDisplayNameForAttribute(t) {
764
760
  const r = Object.values(this.store.filterList).find((e) => e.attributeName === t);
765
- return r ? r.displayName : ht(t);
761
+ return r ? r.displayName : dt(t);
766
762
  }
767
763
  /**
768
764
  * Resolves the display content for a custom attribute cell.
@@ -770,29 +766,29 @@ class Ut extends Z {
770
766
  */
771
767
  _resolveAttributeContent(t, r, e) {
772
768
  var n;
773
- const s = this.store.recommendationProducts[e], i = pt(t, this.store.filterList) ? s == null ? void 0 : s[t] : (n = s == null ? void 0 : s.product_attributes) == null ? void 0 : n[t];
774
- return _t(i) ?? r;
769
+ const s = this.store.recommendationProducts[e], i = mt(t, this.store.filterList) ? s == null ? void 0 : s[t] : (n = s == null ? void 0 : s.product_attributes) == null ? void 0 : n[t];
770
+ return typeof i == "string" ? i : typeof i == "number" ? String(i) : r;
775
771
  }
776
772
  _getGridCellHtml(t, r, e, o = "", s = "", i = "") {
777
- const n = `${m}${t}`, a = w(ct, [n], this.store.filterList), c = {
773
+ const n = `${m}${t}`, c = F(at, [n], this.store.filterList), a = {
778
774
  [t]: r,
779
775
  product_attributes: { [t]: r }
780
776
  };
781
- let l = a[n](c);
777
+ let l = c[n](a);
782
778
  return l = l.replace("<td", `<td width="${e}%"`), i && (l = l.replace(
783
- `padding: ${ut}`,
779
+ `padding: ${ct}`,
784
780
  `padding: ${i}`
785
781
  )), o && (l = l.replace(/style="table-layout: fixed;"/, `style="table-layout: fixed; ${o}"`)), s && (l = l.replace(/border="0"/, `border="0" bgcolor="${s}"`)), l;
786
782
  }
787
783
  _getListRowHtml(t, r, e) {
788
- const o = w(mt, [e], this.store.filterList), s = {
784
+ const o = F(ut, [e], this.store.filterList), s = {
789
785
  [t]: r,
790
786
  product_attributes: { [t]: r }
791
787
  }, n = o[e](s).replace(/<tr>/, "").replace(/<\/tr>/, "");
792
- return `<tr class="recommendation-attribute-row" ${y}="${e}" ${v}="1">${n}</tr>`;
788
+ return `<tr class="recommendation-attribute-row" ${y}="${e}" ${I}="1">${n}</tr>`;
793
789
  }
794
790
  }
795
791
  export {
796
- bt as COMPOSITION_CONTROL_BLOCK_ID,
797
- Ut as RecommendationCardCompositionControl
792
+ _t as COMPOSITION_CONTROL_BLOCK_ID,
793
+ Nt as RecommendationCardCompositionControl
798
794
  };
@@ -1,6 +1,6 @@
1
- var O = Object.defineProperty;
2
- var p = (o, e, t) => e in o ? O(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var r = (o, e, t) => p(o, typeof e != "symbol" ? e + "" : e, t);
1
+ var p = Object.defineProperty;
2
+ var A = (o, e, t) => e in o ? p(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var r = (o, e, t) => A(o, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { ModificationDescription as h } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
5
  import { CommonControl as N } from "../../../common-control.js";
6
6
  import { ATTR_DATA_CUSTOM_ATTRIBUTES as L } from "../../constants/selectors.js";
@@ -9,9 +9,9 @@ import { DEFAULT_COMPOSITION as _ } from "../../constants/defaultConfig.js";
9
9
  import { RecommendationConfigService as s } from "../../services/configService.js";
10
10
  import { useRecommendationExtensionStore as f } from "../../store/recommendation.js";
11
11
  import { getCurrentLayout as C, getBlockElement as I, regenerateProductRowsWithStyles as S } from "./utils.js";
12
- const U = "recommendation-layout-orientation-control", A = "recommendationInfoBannerTest", a = {
12
+ const U = "recommendation-layout-orientation-control", O = "recommendationInfoBannerTest", a = {
13
13
  LAYOUT: "layout"
14
- }, y = "data-card-composition", i = {
14
+ }, y = "data-card-composition", n = {
15
15
  LAYOUT: "data-layout",
16
16
  COLUMN_SPACING: "data-column-spacing",
17
17
  ROW_SPACING: "data-row-spacing",
@@ -30,7 +30,7 @@ class Y extends N {
30
30
  getTemplate() {
31
31
  return `
32
32
  <div class="layout-control-container">
33
- ${this._GuOnPageMessage({ name: A })}
33
+ ${this._GuOnPageMessage({ name: O })}
34
34
 
35
35
  ${this._GuTwoColumns([
36
36
  this._GuLabel({ text: this.api.translate("Layout Orientation") }),
@@ -44,10 +44,11 @@ class Y extends N {
44
44
  }
45
45
  onRender() {
46
46
  this._setInfoMessageValue(
47
- A,
47
+ O,
48
48
  this.api.translate(
49
- `Note that updating the Layout Orientation, Number of Products and
50
- Products in One Row settings resets the style of your Recommendation block.`
49
+ `Note that updating the Layout Orientation, Number of Products,
50
+ Products in One Row and Mobile Layout Optimization settings
51
+ resets the style of your Recommendation block.`
51
52
  )
52
53
  ), this._setFormValues(), this._listenToFormUpdates();
53
54
  }
@@ -83,8 +84,8 @@ class Y extends N {
83
84
  },
84
85
  `Changed layout to ${t}`
85
86
  ), this.store.patchCurrentBlockConfig({ orientation: t });
86
- const n = this.api.getDocumentModifier().modifyHtml(c).setAttribute(i.LAYOUT, t).setAttribute(i.COLUMN_SPACING, g.toString()).setAttribute(i.ROW_SPACING, l.toString()).setAttribute(i.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(i.MOBILE_ROW_SPACING, m.toString());
87
- t === "list" ? (n.setClass("es-m-p0"), n.setClass("ins-recommendation-list-layout")) : (n.removeClass("es-m-p0"), n.removeClass("ins-recommendation-list-layout")), n.setAttribute(y, _.join(",")).setAttribute(L, "[]"), n.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
87
+ const i = this.api.getDocumentModifier().modifyHtml(c).setAttribute(n.LAYOUT, t).setAttribute(n.COLUMN_SPACING, g.toString()).setAttribute(n.ROW_SPACING, l.toString()).setAttribute(n.MOBILE_COLUMN_SPACING, d.toString()).setAttribute(n.MOBILE_ROW_SPACING, m.toString());
88
+ t === "list" ? (i.setClass("es-m-p0"), i.setClass("ins-recommendation-list-layout")) : (i.removeClass("es-m-p0"), i.removeClass("ins-recommendation-list-layout")), i.setAttribute(y, _.join(",")).setAttribute(L, "[]"), i.apply(new h(`Update layout to ${t}`)), this._regenerateProductRows(t);
88
89
  } finally {
89
90
  this.isChangingLayout = !1;
90
91
  }