@useinsider/guido 3.17.0-beta.bc6e089 → 3.17.0-beta.c93afa9

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 (24) hide show
  1. package/dist/composables/useModuleRepair.js +33 -0
  2. package/dist/composables/useStripo.js +1 -1
  3. package/dist/config/migrator/itemsBlockMigrator.js +156 -204
  4. package/dist/extensions/Blocks/Items/block.js +118 -49
  5. package/dist/extensions/Blocks/Items/constants/currency.js +25 -0
  6. package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
  7. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +25 -24
  8. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -11
  9. package/dist/extensions/Blocks/Items/controls/settingsControl.js +55 -58
  10. package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
  11. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
  12. package/dist/extensions/Blocks/Items/template.js +236 -243
  13. package/dist/src/composables/useModuleRepair.d.ts +18 -0
  14. package/dist/src/extensions/Blocks/Items/block.d.ts +35 -0
  15. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +43 -0
  16. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
  17. package/dist/src/utils/itemsCurrencyRepair.d.ts +17 -0
  18. package/dist/utils/itemsCurrencyRepair.js +39 -0
  19. package/dist/utils/pairProductVariables.js +66 -66
  20. package/package.json +1 -1
  21. package/dist/composables/useModuleDynamicContentRepair.js +0 -37
  22. package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
  23. package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -13
  24. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
@@ -1,20 +1,32 @@
1
- import { BlockId as g } from "../../../enums/block.js";
2
- import { useOnboardingStore as y } from "../../../stores/onboarding.js";
3
- import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
4
- import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
6
- import { getDefaultTemplate as h } from "./template.js";
7
- import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
- const p = g.Items;
9
- class E extends C {
1
+ var k = Object.defineProperty;
2
+ var D = (l, a, t) => a in l ? k(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
3
+ var y = (l, a, t) => D(l, typeof a != "symbol" ? a + "" : a, t);
4
+ import { BlockId as N } from "../../../enums/block.js";
5
+ import { useOnboardingStore as T } from "../../../stores/onboarding.js";
6
+ import { getMigrationBannerHtml as S } from "../../../utils/migrationBannerHtml.js";
7
+ import { Block as A, BlockCompositionType as M, ModificationDescription as u } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
+ import { currencyAttrTargets as H, ITEMS_CURRENCY_ATTR as m } from "./constants/currency.js";
9
+ import { ItemsBlockId as R } from "./enums/controlEnums.js";
10
+ import { SETTINGS_ENUMS as C, DefaultConfigValues as g } from "./enums/settingsEnums.js";
11
+ import { getDefaultTemplate as O } from "./template.js";
12
+ import { getItemsBlockContainer as b, getItemsBlockConfig as h, deriveItemNumber as B, generateBlockInstanceId as E, getDefaultItemsBlockConfig as w } from "./utils/nodeConfigUtils.js";
13
+ const _ = N.Items, P = "Reconcile Items currency DOM attributes";
14
+ class K extends A {
15
+ constructor() {
16
+ super(...arguments);
17
+ /** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
18
+ y(this, "_currencyHealed", /* @__PURE__ */ new Set());
19
+ /** blockInstanceIds already claimed by a live block this session (SD-147588 collision detection). */
20
+ y(this, "_seenInstanceIds", /* @__PURE__ */ new Set());
21
+ }
10
22
  getId() {
11
- return p;
23
+ return _;
12
24
  }
13
25
  getIcon() {
14
26
  return "items-icon";
15
27
  }
16
28
  getBlockCompositionType() {
17
- return b.CONTAINER;
29
+ return M.CONTAINER;
18
30
  }
19
31
  getName() {
20
32
  return this.api.translate("Items");
@@ -23,20 +35,20 @@ class E extends C {
23
35
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
36
  }
25
37
  getSettingsPanelTitleHtml() {
26
- return I(
27
- p,
38
+ return S(
39
+ _,
28
40
  this.api.translate("Items"),
29
41
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
30
42
  );
31
43
  }
32
44
  getTemplate() {
33
- return h({
34
- orientation: l.ORIENTATION.VERTICAL,
35
- itemsType: l.ITEMS_TYPE.CART_ITEMS,
45
+ return O({
46
+ orientation: C.ORIENTATION.VERTICAL,
47
+ itemsType: C.ITEMS_TYPE.CART_ITEMS,
36
48
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
- currencySymbol: d.productPriceCurrencySymbolControlValue,
38
- currencyLocation: d.productPriceCurrencyLocationControlValue,
39
- formattedPrice: d.productPriceFormattedControlValue === "1"
49
+ currencySymbol: g.productPriceCurrencySymbolControlValue,
50
+ currencyLocation: g.productPriceCurrencyLocationControlValue,
51
+ formattedPrice: g.productPriceFormattedControlValue === "1"
40
52
  });
41
53
  }
42
54
  allowInnerBlocksDND() {
@@ -45,24 +57,27 @@ class E extends C {
45
57
  canBeSavedAsModule() {
46
58
  return !0;
47
59
  }
48
- onCreated(n) {
49
- const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
50
- a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
- const e = u(n);
52
- if (!e)
60
+ onCreated(t) {
61
+ const o = this.api.getDocumentModifier(), c = this.api.getDocumentRootCssNode();
62
+ c.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(c).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
63
+ const i = b(t);
64
+ if (!i)
53
65
  return;
54
- const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
55
- if (i != null && i.initialized)
56
- if (r)
57
- i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
- else {
59
- const s = this.api.getDocumentModifier();
60
- s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
66
+ const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, e = h(t);
67
+ if (e != null && e.initialized) {
68
+ if (!s) {
69
+ const d = this.api.getDocumentModifier();
70
+ d.modifyHtml(i).setNodeConfig(e), this._stampProductTdDomAttributes(i, e, d), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(i, e, d), d.apply(new u("Migrate legacy config to nodeConfig")), this._markCurrencyHealed(e.blockInstanceId);
71
+ return;
61
72
  }
62
- else {
63
- const s = N(), m = this.api.getDocumentModifier();
64
- m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
73
+ } else {
74
+ const d = w(), p = this.api.getDocumentModifier();
75
+ p.modifyHtml(i).setNodeConfig(d), this._stampProductTdDomAttributes(i, d, p, !0), p.apply(new u("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
76
+ return;
65
77
  }
78
+ const n = this._resolveInstanceId(e.blockInstanceId), f = this.api.getDocumentModifier();
79
+ let I = !1;
80
+ n !== e.blockInstanceId && (f.modifyHtml(i).setNodeConfig({ ...e, blockInstanceId: n }), I = !0), !this._currencyHealed.has(n) && this._reconcileCurrencyDomAttributes(i, e, f) && (I = !0), I && f.apply(new u("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
66
81
  }
67
82
  /**
68
83
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -70,18 +85,24 @@ class E extends C {
70
85
  * into nodeConfig, so without this a reused module would reset to defaults.
71
86
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
87
  */
73
- onDocumentChanged(n) {
74
- const t = u(n);
75
- if (!t)
88
+ onDocumentChanged(t) {
89
+ const o = b(t);
90
+ if (!o)
76
91
  return;
77
- const a = t.getNodeConfig();
78
- if (a && Object.keys(a).length > 0)
92
+ const c = o.getNodeConfig();
93
+ if (c && Object.keys(c).length > 0) {
94
+ const e = h(t);
95
+ if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
96
+ const n = this.api.getDocumentModifier();
97
+ this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new u(P)), this._markCurrencyHealed(e.blockInstanceId);
98
+ }
79
99
  return;
80
- const o = f(n);
81
- if (!(o != null && o.initialized))
100
+ }
101
+ const r = h(t);
102
+ if (!(r != null && r.initialized))
82
103
  return;
83
- const r = this.api.getDocumentModifier();
84
- r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
104
+ const s = this.api.getDocumentModifier();
105
+ s.modifyHtml(o).setNodeConfig(r), this._stampProductTdDomAttributes(o, r, s), this._shouldReconcileCurrency(r) && this._reconcileCurrencyDomAttributes(o, r, s), s.apply(new u("Recover Items block config from saved module")), this._markCurrencyHealed(r.blockInstanceId);
85
106
  }
86
107
  /**
87
108
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -91,14 +112,62 @@ class E extends C {
91
112
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
113
  * relies on this td-level fallback in pairProductVariables.
93
114
  */
94
- _stampProductTdDomAttributes(n, t, a, e = !1) {
95
- const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
96
- e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
115
+ _stampProductTdDomAttributes(t, o, c, i = !1) {
116
+ const r = B(o.itemsSelectValue, o.type), s = (e, n) => {
117
+ i && t.getAttribute(e) || c.modifyHtml(t).setAttribute(e, n);
97
118
  };
98
- r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
119
+ s("data-type", o.type), s("data-number", r), s("data-nodup", String(o.priceHideDiscount));
120
+ }
121
+ /**
122
+ * Whether a currency self-heal pass should run for this block (SD-147588). The only gate here is
123
+ * once-per-session: heal each instance at most once, so the auto-fix can't fight undo (undo
124
+ * re-drifts the attr, which would otherwise re-trigger the heal forever). The position-vs-symbol
125
+ * authority split lives in `_reconcileCurrencyDomAttributes` — position is always authoritative,
126
+ * the symbol write alone is skipped for the 'USD' sentinel — so we must NOT gate the whole pass
127
+ * on symbol customization here, or a default-symbol block with a toggled location never heals.
128
+ */
129
+ _shouldReconcileCurrency(t) {
130
+ return !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
131
+ }
132
+ /** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
133
+ _markCurrencyHealed(t) {
134
+ t && this._currencyHealed.add(t);
135
+ }
136
+ /**
137
+ * Resolves the id for a just-created block to one that is unique per live instance.
138
+ * A saved module serializes its blockInstanceId, so every re-drop of the same module
139
+ * arrives with an id already owned by a live instance — reusing it collides both the
140
+ * currency heal guard and settings-panel switch detection. Mint a fresh id on absence
141
+ * or collision, otherwise keep the existing one. Registers the result as claimed.
142
+ */
143
+ _resolveInstanceId(t) {
144
+ let o = t;
145
+ if (!o || this._seenInstanceIds.has(o))
146
+ do
147
+ o = E();
148
+ while (this._seenInstanceIds.has(o));
149
+ return this._seenInstanceIds.add(o), o;
150
+ }
151
+ /**
152
+ * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
153
+ * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
154
+ * Config is the source of truth — never derive from visible text.
155
+ *
156
+ * Authority split lives in `currencyAttrTargets` (SD-147588) — position only when a location
157
+ * is recorded, symbol only when customized — so this heal and the module-drop repair can't drift.
158
+ *
159
+ * Returns true only when an attr actually changed, so the caller can skip an empty apply that
160
+ * would otherwise re-trigger onDocumentChanged and loop.
161
+ */
162
+ _reconcileCurrencyDomAttributes(t, o, c) {
163
+ const { position: i, symbol: r } = H(o), s = t.querySelectorAll(`.${R.PRICE} p`);
164
+ let e = !1;
165
+ return s.forEach((n) => {
166
+ i !== void 0 && n.getAttribute(m.POSITION) !== i && (c.modifyHtml(n).setAttribute(m.POSITION, i), e = !0), r !== void 0 && n.getAttribute(m.SYMBOL) !== r && (c.modifyHtml(n).setAttribute(m.SYMBOL, r), e = !0);
167
+ }), e;
99
168
  }
100
169
  }
101
170
  export {
102
- p as BLOCK_ID,
103
- E as ItemsBlock
171
+ _ as BLOCK_ID,
172
+ K as ItemsBlock
104
173
  };
@@ -0,0 +1,25 @@
1
+ import { DefaultConfigValues as c } from "../enums/settingsEnums.js";
2
+ const s = {
3
+ POSITION: "data-curency",
4
+ SYMBOL: "data-currency_symbol"
5
+ };
6
+ function e(r) {
7
+ return r === "1" ? "after" : "before";
8
+ }
9
+ function i(r) {
10
+ const o = (r ?? "").trim();
11
+ return o !== "" && o !== c.productPriceCurrencySymbolControlValue;
12
+ }
13
+ function a(r) {
14
+ const o = r.priceCurrencyLocation, n = typeof o == "string" && o.trim() !== "", t = (r.priceCurrencySymbol ?? "").trim();
15
+ return {
16
+ position: n ? e(o) : void 0,
17
+ symbol: i(t) ? t : void 0
18
+ };
19
+ }
20
+ export {
21
+ s as ITEMS_CURRENCY_ATTR,
22
+ a as currencyAttrTargets,
23
+ e as currencyPositionFromLocation,
24
+ i as isCustomCurrencySymbol
25
+ };
@@ -1,15 +1,14 @@
1
- import { ModificationDescription as d, UIElementType as s, UEAttr as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CommonControl as T } from "../../../common-control.js";
3
- import { nameMaxWidthFor as h } from "../../constants/cardLayout.js";
1
+ import { ModificationDescription as l, UIElementType as s, UEAttr as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CommonControl as p } from "../../../common-control.js";
4
3
  import { ItemsBlockControlId as a } from "../../enums/controlEnums.js";
5
- import { findNameTextNode as c } from "../../utils/nameNode.js";
6
- import { getItemsBlockConfig as r, setItemsBlockConfig as g } from "../../utils/nodeConfigUtils.js";
7
- const I = a.NAME_TRIMMING, n = {
4
+ import { findNameTextNode as T } from "../../utils/nameNode.js";
5
+ import { getItemsBlockConfig as r, setItemsBlockConfig as c } from "../../utils/nodeConfigUtils.js";
6
+ const g = a.NAME_TRIMMING, i = {
8
7
  TRIMMING: "trimming"
9
8
  };
10
- class E extends T {
9
+ class y extends p {
11
10
  getId() {
12
- return I;
11
+ return g;
13
12
  }
14
13
  getTemplate() {
15
14
  return `
@@ -20,39 +19,39 @@ class E extends T {
20
19
  }
21
20
  onRender() {
22
21
  const e = r(this.currentNode);
23
- this.api.updateValues({ [n.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(n.TRIMMING, (t) => {
22
+ this.api.updateValues({ [i.TRIMMING]: (e == null ? void 0 : e.nameTrimming) ?? !0 }), this.api.onValueChanged(i.TRIMMING, (t) => {
24
23
  this._onTrimmingChange(t);
25
24
  });
26
25
  }
27
26
  onTemplateNodeUpdated(e) {
28
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
29
28
  const t = r(this.currentNode);
30
- this.api.updateValues({ [n.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
29
+ this.api.updateValues({ [i.TRIMMING]: (t == null ? void 0 : t.nameTrimming) ?? !0 });
31
30
  });
32
31
  }
33
32
  _onTrimmingChange(e) {
34
- g(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [n.TRIMMING]: e }), this._applyTrimmingStyles(e);
33
+ c(this.currentNode, this.api, { nameTrimming: e }), this.api.updateValues({ [i.TRIMMING]: e }), this._applyTrimmingStyles(e);
35
34
  }
36
35
  _applyTrimmingStyles(e) {
37
- const t = c(this.currentNode);
36
+ const t = T(this.currentNode);
38
37
  if (!t)
39
38
  return;
40
- const i = r(this.currentNode), m = e !== void 0 ? e : (i == null ? void 0 : i.nameTrimming) ?? !0, l = h(i == null ? void 0 : i.orientation), o = this.api.getDocumentModifier().modifyHtml(t);
41
- m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", l).apply(new d(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
39
+ const n = r(this.currentNode), m = e !== void 0 ? e : (n == null ? void 0 : n.nameTrimming) ?? !0, o = this.api.getDocumentModifier().modifyHtml(t);
40
+ m ? o.setStyle("white-space", "nowrap").setStyle("overflow", "hidden").setStyle("text-overflow", "ellipsis") : o.removeStyle("white-space").removeStyle("overflow").removeStyle("text-overflow"), o.setStyle("max-width", "100%").apply(new l(`Text Trimming ${m ? "Enabled" : "Disabled"}`));
42
41
  }
43
42
  _getTextTrimming() {
44
43
  return `
45
44
  <div class="display-flex align-items-center justify-content-between">
46
45
  <${s.LABEL}
47
- ${p.LABEL.text}="${this.api.translate("Text Trimming")}"
46
+ ${d.LABEL.text}="${this.api.translate("Text Trimming")}"
48
47
  >
49
48
  </${s.LABEL}>
50
- ${this._GuToggle(n.TRIMMING)}
49
+ ${this._GuToggle(i.TRIMMING)}
51
50
  </div>
52
51
  `;
53
52
  }
54
53
  }
55
54
  export {
56
- I as CONTROL_BLOCK_ID,
57
- E as NameTrimmingControl
55
+ g as CONTROL_BLOCK_ID,
56
+ y as NameTrimmingControl
58
57
  };
@@ -1,14 +1,15 @@
1
- import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
2
- import { UEAttr as R, ModificationDescription as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { CommonControl as N } from "../../../common-control.js";
1
+ import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
2
+ import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { CommonControl as L } from "../../../common-control.js";
4
+ import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
4
5
  import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
5
- import { getItemsBlockConfig as C, setItemsBlockConfig as I, escapeReplacement as T } from "../../utils/nodeConfigUtils.js";
6
- const E = m.PRICE_CURRENCY_LOCATION, c = {
6
+ import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
7
+ const b = m.PRICE_CURRENCY_LOCATION, c = {
7
8
  CURRENCY_LOCATION: "currencyLocation"
8
9
  };
9
- class A extends N {
10
+ class Y extends L {
10
11
  getId() {
11
- return E;
12
+ return b;
12
13
  }
13
14
  getTemplate() {
14
15
  return `
@@ -18,32 +19,32 @@ class A extends N {
18
19
  `;
19
20
  }
20
21
  onRender() {
21
- const e = C(this.currentNode);
22
- this.api.setUIEAttribute(c.CURRENCY_LOCATION, R.SELECTPICKER.items, u), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
22
+ const e = l(this.currentNode);
23
+ this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
23
24
  this._onCurrencyLocationChange(t);
24
25
  });
25
26
  }
26
27
  onTemplateNodeUpdated(e) {
27
28
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
28
- const t = C(this.currentNode);
29
+ const t = l(this.currentNode);
29
30
  this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
30
31
  });
31
32
  }
32
33
  _onCurrencyLocationChange(e) {
33
- if (console.debug("Currency location changed to: ", e), I(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
+ if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
34
35
  return;
35
36
  const t = this._getPriceBlocks();
36
37
  if (!t || t.length === 0)
37
38
  return;
38
- const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = this.api.getDocumentModifier();
39
- t.forEach((a) => {
40
- const s = this._getParagraph(a);
41
- if (!s)
39
+ const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
40
+ t.forEach((h) => {
41
+ const a = this._getParagraph(h);
42
+ if (!a)
42
43
  return;
43
- const h = s.getInnerHTML().trim() || "", l = s.getInnerText().trim() || "", p = (o == null ? void 0 : o.trim()) || "", d = this._removeCurrencySymbol(l, p), g = this._detectSymbolInText(l) || p, _ = this._buildPriceContent(d, g, n), y = h.replace(l, T(_));
44
- i.modifyHtml(s).setInnerHtml(y);
45
- }), i.apply(new L(
46
- `Updated currency location to ${n === "1" ? "after" : "before"}`
44
+ const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
45
+ s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
46
+ }), s.apply(new I(
47
+ `Updated currency location to ${i}`
47
48
  ));
48
49
  }
49
50
  _getPriceBlocks() {
@@ -65,8 +66,8 @@ class A extends N {
65
66
  } else {
66
67
  const o = r.match(/([^0-9.,\s]+)/);
67
68
  if (o && o[1]) {
68
- const i = o[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
69
- n = r.replace(a, "").trim();
69
+ const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
70
+ n = r.replace(s, "").trim();
70
71
  }
71
72
  }
72
73
  return n;
@@ -85,13 +86,13 @@ class A extends N {
85
86
  this._GuSelect({
86
87
  name: c.CURRENCY_LOCATION,
87
88
  placeholder: "",
88
- options: u
89
+ options: p
89
90
  })
90
91
  ])}
91
92
  `;
92
93
  }
93
94
  }
94
95
  export {
95
- E as CONTROL_BLOCK_ID,
96
- A as PriceCurrencyLocationControl
96
+ b as CONTROL_BLOCK_ID,
97
+ Y as PriceCurrencyLocationControl
97
98
  };
@@ -1,20 +1,21 @@
1
1
  var R = Object.defineProperty;
2
2
  var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
3
3
  var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
4
- import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as E } from "../../../common-control.js";
4
+ import { ModificationDescription as E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as B } from "../../../common-control.js";
6
+ import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
6
7
  import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
7
- import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
8
- const I = y.PRICE_CURRENCY_SYMBOL, u = {
8
+ import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
9
+ const x = y.PRICE_CURRENCY_SYMBOL, u = {
9
10
  CURRENCY_SYMBOL: "currencySymbol"
10
11
  };
11
- class P extends E {
12
+ class $ extends B {
12
13
  constructor() {
13
14
  super(...arguments);
14
15
  h(this, "originalPriceContents", /* @__PURE__ */ new Map());
15
16
  }
16
17
  getId() {
17
- return I;
18
+ return x;
18
19
  }
19
20
  getTemplate() {
20
21
  return `
@@ -42,7 +43,7 @@ class P extends E {
42
43
  var a;
43
44
  console.debug("Currency symbol changed to: ", e);
44
45
  const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
45
- if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
46
+ if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
46
47
  return;
47
48
  const r = this._getPriceBlocks();
48
49
  if (!r || r.length === 0)
@@ -53,8 +54,8 @@ class P extends E {
53
54
  if (!m)
54
55
  return;
55
56
  const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
56
- i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
57
- }), i.apply(new B(
57
+ i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
58
+ }), i.apply(new E(
58
59
  `Updated currency symbol to ${n || "removed"}`
59
60
  ));
60
61
  }
@@ -115,6 +116,6 @@ class P extends E {
115
116
  }
116
117
  }
117
118
  export {
118
- I as CONTROL_BLOCK_ID,
119
- P as PriceCurrencySymbolControl
119
+ x as CONTROL_BLOCK_ID,
120
+ $ as PriceCurrencySymbolControl
120
121
  };