@useinsider/guido 2.0.0-beta.bf65edd → 2.0.0-beta.c0d8594

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 (61) hide show
  1. package/README.md +2 -0
  2. package/dist/@types/config/schemas.js +3 -1
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +57 -61
  5. package/dist/components/organisms/base/Toaster.vue.js +6 -6
  6. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +2 -2
  7. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +6 -6
  8. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  9. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  10. package/dist/components/organisms/header/LeftSlot.vue.js +12 -12
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +6 -6
  12. package/dist/composables/useStripo.js +40 -40
  13. package/dist/config/migrator/index.js +9 -8
  14. package/dist/config/migrator/itemsBlockMigrator.js +283 -0
  15. package/dist/extensions/Blocks/CouponBlock/constants.js +4 -0
  16. package/dist/extensions/Blocks/CouponBlock/controls/index.js +29 -0
  17. package/dist/extensions/Blocks/CouponBlock/extension.js +5 -4
  18. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +20 -14
  19. package/dist/extensions/Blocks/CouponBlock/template.js +22 -11
  20. package/dist/extensions/Blocks/Items/block.js +39 -40
  21. package/dist/extensions/Blocks/Items/controls/button/link.js +22 -29
  22. package/dist/extensions/Blocks/Items/controls/cardComposition.js +46 -49
  23. package/dist/extensions/Blocks/Items/controls/image/link.js +23 -30
  24. package/dist/extensions/Blocks/Items/controls/name/trimming.js +13 -15
  25. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +1 -1
  26. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
  27. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +15 -17
  28. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -15
  29. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +29 -27
  30. package/dist/extensions/Blocks/Items/controls/settingsControl.js +145 -136
  31. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +2 -2
  32. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +58 -48
  33. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +48 -58
  34. package/dist/extensions/Blocks/Items/settingsPanel.js +4 -4
  35. package/dist/extensions/Blocks/Items/store/items-block.js +2 -2
  36. package/dist/extensions/Blocks/Items/template.js +312 -125
  37. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +172 -0
  38. package/dist/extensions/Blocks/Items/utils/syncAttributesFromConfigBlock.js +17 -44
  39. package/dist/extensions/Blocks/Recommendation/control.js +1 -1
  40. package/dist/extensions/Blocks/common-control.js +64 -53
  41. package/dist/extensions/Blocks/controlFactories.js +139 -118
  42. package/dist/guido.css +1 -1
  43. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +370 -286
  44. package/dist/package.json.js +1 -1
  45. package/dist/services/stripoApi.js +6 -10
  46. package/dist/src/@types/config/schemas.d.ts +4 -0
  47. package/dist/src/composables/useConfig.d.ts +2 -0
  48. package/dist/src/config/migrator/itemsBlockMigrator.d.ts +6 -0
  49. package/dist/src/extensions/Blocks/CouponBlock/constants.d.ts +14 -0
  50. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +108 -0
  51. package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -2
  53. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -2
  54. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +0 -4
  56. package/dist/src/extensions/Blocks/Items/template.d.ts +20 -1
  57. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +71 -0
  58. package/dist/src/extensions/Blocks/common-control.d.ts +13 -8
  59. package/dist/src/extensions/Blocks/controlFactories.d.ts +30 -7
  60. package/dist/src/stores/config.d.ts +17 -0
  61. package/package.json +3 -3
@@ -1,29 +1,100 @@
1
- import { BlockType as l, BlockAttr as _ } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { ItemsBlockId as T } from "./enums/controlEnums.js";
3
- import { productPairs as i, templateFirstLine as N } from "./enums/productEnums.js";
4
- import { ItemInCartOptions as f, SETTINGS_ENUMS as O, DefaultConfigValues as P } from "./enums/settingsEnums.js";
5
- import B from "./layouts/horizontal.html.js";
6
- import g from "./layouts/vertical.html.js";
7
- let [C] = i.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [A] = i.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [p] = i.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [I] = i.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [u] = i.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
8
- const h = (a, t) => `
9
- <${l.BLOCK_IMAGE}
10
- ${_.BLOCK_IMAGE.src}="${C}"
11
- ${_.BLOCK_IMAGE.alt}="${A}"
12
- ${_.BLOCK_IMAGE.href}="#!"
13
- ${_.BLOCK_IMAGE.width}=${P.productImageWidth}
14
- esd-extension-block-id="${T.IMAGE}"
1
+ import { BlockType as u, BlockAttr as R } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { ItemsBlockId as O } from "./enums/controlEnums.js";
3
+ import { productPairs as d, templateFirstLine as z } from "./enums/productEnums.js";
4
+ import { ItemInCartOptions as K, SETTINGS_ENUMS as g, DefaultConfigValues as m } from "./enums/settingsEnums.js";
5
+ import G from "./layouts/horizontal.html.js";
6
+ import Q from "./layouts/vertical.html.js";
7
+ let [k] = d.PAIRS_FOR_EXTENSION.imageSrc.CART_ITEMS.DEFAULT, [A] = d.PAIRS_FOR_EXTENSION.name.CART_ITEMS.DEFAULT, [f] = d.PAIRS_FOR_EXTENSION.price.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [y] = d.PAIRS_FOR_EXTENSION.originalPrice.CART_ITEMS.DEFAULT_PRICE_FORMATTED, [P] = d.PAIRS_FOR_EXTENSION.quantity.CART_ITEMS.DEFAULT;
8
+ const V = (t, e) => t.split(";").map((n) => n.trim()).filter((n) => !n.toLowerCase().startsWith(e.toLowerCase())).join("; ").replace(/;\s*$/, ""), x = (t) => V(t, "text-align"), S = (t, e) => {
9
+ const n = new RegExp(`${e}\\s*:\\s*([^;]+)`, "i"), a = t.match(n);
10
+ return a ? a[1].trim() : null;
11
+ }, N = (t, e, n) => new RegExp(`(${e}\\s*:\\s*)[^;]+`, "gi").test(t) ? t.replace(
12
+ new RegExp(`(${e}\\s*:\\s*)[^;]+`, "gi"),
13
+ `$1${n}`
14
+ ) : t, W = (t, e, n) => {
15
+ const a = n || m.productImageWidth;
16
+ return `
17
+ <td class="esd-block-image document-node-component default-block-component selectable ng-star-inserted"
18
+ align="center"
19
+ esd-extension-block-id="items-block-image"
20
+ data-slot-1=""
21
+ product-attr="imageSrc"
22
+ data-type="${t}"
23
+ data-number="${e}"
24
+ style="font-size: 0px;">
25
+ <a class="document-node-component ng-star-inserted"
26
+ target="_blank"
27
+ href="#!">
28
+ <img class="adapt-img document-node-component ng-star-inserted"
29
+ src="${k}"
30
+ alt="${A}"
31
+ width="${a}">
32
+ </a>
33
+ </td>
34
+ `;
35
+ }, q = (t, e) => `
36
+ <${u.BLOCK_IMAGE}
37
+ ${R.BLOCK_IMAGE.src}="${k}"
38
+ ${R.BLOCK_IMAGE.alt}="${A}"
39
+ ${R.BLOCK_IMAGE.href}="#!"
40
+ ${R.BLOCK_IMAGE.width}="${m.productImageWidth}"
41
+ ${R.BLOCK_IMAGE.height}="${m.productImageWidth}"
42
+ esd-extension-block-id="${O.IMAGE}"
15
43
  data-slot-1
16
44
  product-attr="imageSrc"
17
- data-type="${a}"
18
- data-number="${t}"
45
+ data-type="${t}"
46
+ data-number="${e}"
19
47
  />
20
- `, F = (a) => `
21
- <${l.BLOCK_TEXT}
48
+ `, j = (t, e, n, a) => {
49
+ const l = `
50
+ text-decoration:none;
51
+ font-size: inherit;
52
+ font-weight: inherit;
53
+ line-height: inherit;
54
+ font-family: inherit;
55
+ color: inherit;
56
+ display: block;
57
+ word-wrap:break-word;
58
+ white-space: nowrap;
59
+ width: ${n === g.ORIENTATION.HORIZONTAL ? "130px" : "520px"};
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ `;
63
+ if (e) {
64
+ const o = x(a || l), c = S(o, "color"), s = S(o, "font-size"), p = [
65
+ c ? `color: ${c}` : "",
66
+ s ? `font-size: ${s}` : ""
67
+ ].filter(Boolean).join("; "), i = N(
68
+ N(o, "color", "inherit"),
69
+ "font-size",
70
+ "inherit"
71
+ );
72
+ return `
73
+ <td class="esd-block-text es-p10"
74
+ align="center"
75
+ width="100%"
76
+ data-type="${t}"
77
+ esd-extension-block-id="${O.NAME}"
78
+ style="display: table-cell;">
79
+ <p contenteditable="false" path="1"${p ? ` style="${p}"` : ""}>
80
+ <a
81
+ href="#!"
82
+ style="${i}"
83
+ product-attr="name"
84
+ data-slot-2
85
+ width="100%">
86
+ ${A}
87
+ </a>
88
+ </p>
89
+ </td>
90
+ `;
91
+ }
92
+ return `<${u.BLOCK_TEXT}
22
93
  width="100%"
23
94
  align="center"
24
95
  class="es-p10"
25
- data-type="${a}"
26
- esd-extension-block-id="${T.NAME}"
96
+ data-type="${t}"
97
+ esd-extension-block-id="${O.NAME}"
27
98
  >
28
99
  <p contenteditable="false">
29
100
  <a
@@ -48,148 +119,264 @@ const h = (a, t) => `
48
119
  ${A}
49
120
  </a>
50
121
  </p>
51
- </${l.BLOCK_TEXT}>
52
- `, S = (a, t, o, e, c) => {
53
- let n = p;
54
- if (e && e.trim()) {
55
- const E = `&nbsp;${e.trim()}&nbsp;`;
56
- n = (c || "0") === "1" ? `${p}${E}` : `${E}${p}`;
122
+ </${u.BLOCK_TEXT}>
123
+ `;
124
+ }, H = (t, e, n, a, r, l, o) => {
125
+ let c = f;
126
+ if (a && a.trim()) {
127
+ const E = `&nbsp;${a.trim()}&nbsp;`;
128
+ c = (r || "0") === "1" ? `${f}${E}` : `${E}${f}`;
129
+ }
130
+ const s = r === "1" ? "after" : "before", p = `data-formated="${n ? "true" : "false"}"`, i = `data-curency="${s}"`, T = a ? `data-currency_symbol="${a}"` : "";
131
+ if (l) {
132
+ const $ = x(o || "color: #060606; white-space: nowrap; font-size: 20px;");
133
+ return `
134
+ <td class="esd-block-text items-block-price"
135
+ align="center"
136
+ esd-extension-block-id="items-block-price"
137
+ width="100%">
138
+ <p product-attr="price"
139
+ contenteditable="false"
140
+ data-slot-4
141
+ data-type="${t}"
142
+ data-number="${e}"
143
+ ${p}
144
+ ${i}
145
+ ${T}
146
+ style="${$}">
147
+ ${c}
148
+ </p>
149
+ </td>`;
57
150
  }
58
- const r = c === "1" ? "after" : "before", d = `data-formated="${o ? "true" : "false"}"`, s = `data-curency="${r}"`;
59
151
  return `
60
- <${l.BLOCK_TEXT}
61
- esd-extension-block-id="${T.PRICE}"
152
+ <${u.BLOCK_TEXT}
153
+ esd-extension-block-id="${O.PRICE}"
62
154
  class="items-block-price"
63
- width="100%"
64
- align="center"
155
+ width="100%"
156
+ align="center"
65
157
  >
66
- <p
158
+ <p
67
159
  product-attr="price"
68
160
  contenteditable="false"
69
161
  data-slot-4
70
- data-type="${a}"
71
- data-number="${t}"
72
- ${d}
73
- ${s}
74
- ${e ? `data-currency_symbol="${e}"` : ""}
162
+ data-type="${t}"
163
+ data-number="${e}"
164
+ ${p}
165
+ ${i}
166
+ ${a ? `data-currency_symbol="${a}"` : ""}
75
167
  >
76
- ${n}
168
+ ${c}
77
169
  </p>
78
- </${l.BLOCK_TEXT}>
170
+ </${u.BLOCK_TEXT}>
79
171
  `;
80
- }, L = (a, t, o, e, c) => {
81
- let n = I;
82
- if (e && e.trim()) {
83
- const E = `&nbsp;${e.trim()}&nbsp;`;
84
- n = (c || "0") === "1" ? `${I}${E}` : `${E}${I}`;
172
+ }, Y = (t, e, n, a, r, l, o = !0, c) => {
173
+ let s = y;
174
+ if (a && a.trim()) {
175
+ const $ = `&nbsp;${a.trim()}&nbsp;`;
176
+ s = (r || "0") === "1" ? `${y}${$}` : `${$}${y}`;
177
+ }
178
+ const p = r === "1" ? "after" : "before", i = `data-formated="${n ? "true" : "false"}"`, T = `data-curency="${p}"`, E = o ? "" : ' style="display: none;"';
179
+ if (l) {
180
+ const b = x(c || "color: #cc0000; white-space: nowrap; font-size: 19px;");
181
+ return `
182
+ <td class="esd-block-text items-block-price"
183
+ esd-extension-block-id="items-block-original-price"
184
+ width="100%"
185
+ align="center"${E}>
186
+ <p
187
+ product-attr="originalPrice"
188
+ contenteditable="false"
189
+ data-slot-5
190
+ data-type="${t}"
191
+ data-number="${e}"
192
+ ${i}
193
+ ${T}
194
+ ${a ? `data-currency_symbol="${a}"` : ""}
195
+ style="${b}">
196
+ <s>${s}</s>
197
+ </p>
198
+ </td>`;
85
199
  }
86
- const r = c === "1" ? "after" : "before", d = `data-formated="${o ? "true" : "false"}"`, s = `data-curency="${r}"`;
87
200
  return `
88
- <${l.BLOCK_TEXT}
201
+ <${u.BLOCK_TEXT}
89
202
  class="items-block-price"
90
- esd-extension-block-id="${T.ORIGINAL_PRICE}"
91
- width="100%"
92
- align="center"
203
+ esd-extension-block-id="${O.ORIGINAL_PRICE}"
204
+ width="100%"
205
+ align="center"
206
+ ${o ? "" : 'style="display: none;"'}
93
207
  >
94
208
  <p
95
209
  product-attr="originalPrice"
96
- contenteditable="false"
210
+ contenteditable="false"
97
211
  data-slot-5
98
212
  style="color: #cc0000"
99
- data-type="${a}"
100
- data-number="${t}"
101
- ${d}
102
- ${s}
103
- ${e ? `data-currency_symbol="${e}"` : ""}
213
+ data-type="${t}"
214
+ data-number="${e}"
215
+ ${i}
216
+ ${T}
217
+ ${a ? `data-currency_symbol="${a}"` : ""}
104
218
  >
105
- <s>${n}</s>
219
+ <s>${s}</s>
106
220
  </p>
107
- </${l.BLOCK_TEXT}>
221
+ </${u.BLOCK_TEXT}>
108
222
  `;
109
- }, b = () => `
110
- <${l.BLOCK_TEXT}
111
- width="100%"
112
- align="center"
113
- class="es-p10"
114
- esd-extension-block-id="${T.QUANTITY}"
115
- >
116
- <p
117
- product-attr="quantity"
118
- data-slot-3
119
- contenteditable="false"
120
- width="100%">
121
- ${u}
122
- </p>
123
- </${l.BLOCK_TEXT}>
124
- `, U = (a, t) => `
125
- <${l.BLOCK_BUTTON}
126
- width="100%"
127
- class="ins-button"
128
- name="buy-button"
129
- caption="Buy"
130
- align="center"
131
- esd-extension-block-id="${T.BUTTON}"
132
- product-attr="button"
133
- data-slot-6
134
- data-type="${a}"
135
- data-number="${t}"
136
- >Buy
137
- </${l.BLOCK_BUTTON}>
138
- `, D = () => `
139
- <esd-config-block style="display: none;"></esd-config-block>
140
- `, R = (a, t, o, e, c, n, r, d) => {
141
- const $ = `${`data-type="${t}" data-number="${o}"`} data-orientation="${e}"`;
142
- return a.replace(
223
+ }, Z = (t = !0, e, n) => {
224
+ const a = t ? "" : 'style="display: none;"';
225
+ return e ? `
226
+ <td class="esd-block-text es-p10 document-node-component default-block-component selectable"
227
+ width="100%" align="center" esd-extension-block-id="items-block-quantity" ${a}>
228
+ <div class="service-element text-block-input-area text-block-preview-area"
229
+ style="outline: none;" contenteditable="">
230
+ <p product-attr="quantity" data-slot-3="" contenteditable="false" width="100%" path="1"
231
+ style="${n || "text-align: center; font-size: 14px;"}">
232
+ ${P}
233
+ </p>
234
+ </div>
235
+ </td>` : `
236
+ <${u.BLOCK_TEXT}
237
+ width="100%"
238
+ align="center"
239
+ class="es-p10"
240
+ esd-extension-block-id="${O.QUANTITY}"
241
+ ${t ? "" : 'style="display: none;"'}
242
+ >
243
+ <p
244
+ product-attr="quantity"
245
+ data-slot-3
246
+ contenteditable="false"
247
+ width="100%">
248
+ ${P}
249
+ </p>
250
+ </${u.BLOCK_TEXT}>
251
+ `;
252
+ }, J = (t, e, n = "Buy", a, r) => a ? `
253
+ <td class="esd-block-button ins-button default-block-component selectable"
254
+ align="center" width="100%" name="buy-button" caption="${n}"
255
+ esd-extension-block-id="items-block-button"
256
+ product-attr="button" data-slot-6="" data-type="${t}" data-number="${e}">
257
+ <span class="es-button-border" style="border-width: 0px;">
258
+ <a class="es-button" href="#!" target="_blank" style="${r || ""}">
259
+ ${n}
260
+ </a>
261
+ </span>
262
+ </td>` : `
263
+ <${u.BLOCK_BUTTON}
264
+ width="100%"
265
+ class="ins-button"
266
+ name="buy-button"
267
+ caption="${n}"
268
+ align="center"
269
+ esd-extension-block-id="${O.BUTTON}"
270
+ product-attr="button"
271
+ data-slot-6
272
+ data-type="${t}"
273
+ data-number="${e}"
274
+ >${n}
275
+ </${u.BLOCK_BUTTON}>
276
+ `, tt = (t) => !t || Object.keys(t).length === 0 ? '<esd-config-block style="display: none;"></esd-config-block>' : `<esd-config-block style="display: none;" ${Object.entries(t).map(([n, a]) => `${n}="${a}"`).join(" ")}></esd-config-block>`, et = (t, e, n) => {
277
+ const a = e === g.ORIENTATION.VERTICAL, r = n === "horizontal";
278
+ return a ? r ? t : t.replace(
279
+ /<td\s+[^>]*class="[^"]*product-(?:original-)?price-class[^"]*"[^>]*>/gi,
280
+ (l) => l.replace(/width="50%"/gi, 'width="100%"').replace(/width:\s*50%;/gi, "width: 100%;")
281
+ ) : r ? t : t.replace(
282
+ /<td\s+[^>]*class="[^"]*horizontal-price[^"]*"[^>]*>/gi,
283
+ (l) => /style\s*=\s*"/i.test(l) ? l.replace(/style\s*=\s*"([^"]*)"/i, 'style="display: none; $1"') : l.replace(/>$/, ' style="display: none;">')
284
+ ).replace(
285
+ /<td\s+[^>]*class="[^"]*vertical-price[^"]*"[^>]*>/gi,
286
+ (l) => l.replace(/display:\s*none;?/gi, "display: table-cell;")
287
+ );
288
+ }, at = (t) => t ? `<td align="center"
289
+ esd-extension-block-id="items-block" width="560"
290
+ data-number="4"
291
+ class="ins-product-td items-block items-block-v2 esd-items-block esd-extension-block esd-container-frame">` : z, L = (t, e, n, a, r, l, o, c, s, p, i, T, E, $ = "horizontal", b, _, I) => {
292
+ const F = `${`data-type="${e}" data-number="${n}"`} data-orientation="${a}"`, C = t.replace(
143
293
  /<td([^>]*class="[^"]*ins-product-td[^"]*"[^>]*)>/,
144
- `<td$1 ${$}>`
145
- ).replace("{-{-TEMPLATE_FIRST_LINE-}-}", N).replace("{-{-PRODUCT_IMAGE-}-}", h(t, o)).replace("{-{-PRODUCT_NAME-}-}", F(t)).replaceAll(
294
+ `<td$1 ${F}>`
295
+ ), M = s == null ? void 0 : s["data-product_image_control_image-width"], U = l ? W(e, n, M) : q(e, n), B = (i == null ? void 0 : i.buttonLabel) || "Buy", D = (i == null ? void 0 : i.quantityControlEnabled) !== void 0 ? i.quantityControlEnabled : !0, X = (i == null ? void 0 : i.originalPriceVisible) !== void 0 ? i.originalPriceVisible : (s == null ? void 0 : s["data-product_original_price_control_enabled"]) !== "false", v = C.replace("{-{-TEMPLATE_FIRST_LINE-}-}", at(l)).replace("{-{-PRODUCT_IMAGE-}-}", U).replace("{-{-PRODUCT_NAME-}-}", j(e, l, a, T)).replaceAll(
146
296
  "{-{-PRODUCT_PRICE-}-}",
147
- S(t, o, c, n, r)
297
+ H(e, n, r, o, c, l, b)
148
298
  ).replaceAll(
149
299
  "{-{-PRODUCT_ORIGINAL_PRICE-}-}",
150
- L(
151
- t,
300
+ Y(
301
+ e,
302
+ n,
303
+ r,
152
304
  o,
153
305
  c,
154
- n,
155
- r
306
+ l,
307
+ X,
308
+ _
156
309
  )
157
- ).replace("{-{-PRODUCT_QUANTITY-}-}", b()).replace("{-{-PRODUCT_BUTTON-}-}", U(t, o)).replace("{-{-CONFIG_BLOCK-}-}", D());
310
+ ).replace("{-{-PRODUCT_QUANTITY-}-}", Z(D, l, I)).replace("{-{-PRODUCT_BUTTON-}-}", J(e, n, B, l, E)).replace("{-{-CONFIG_BLOCK-}-}", tt(s));
311
+ return et(v, a, $);
158
312
  };
159
- function G({
160
- orientation: a,
161
- itemsType: t = O.ITEMS_TYPE.CART_ITEMS,
162
- itemId: o,
163
- currencySymbol: e,
164
- currencyLocation: c,
165
- formattedPrice: n = !0
313
+ function ct({
314
+ orientation: t,
315
+ itemsType: e = g.ITEMS_TYPE.CART_ITEMS,
316
+ itemId: n,
317
+ currencySymbol: a,
318
+ currencyLocation: r,
319
+ migrate: l = !1,
320
+ formattedPrice: o = !0,
321
+ configBlockAttributes: c,
322
+ nodeConfig: s,
323
+ nameStyles: p,
324
+ buttonStyles: i,
325
+ priceStyles: T,
326
+ originalPriceStyles: E,
327
+ quantityStyles: $,
328
+ priceOrientation: b
166
329
  }) {
167
- const r = f[t].findIndex((s) => s.value === o);
168
- let d = "1";
169
- if (r >= 0)
170
- d = String(r + 1);
171
- else if (o) {
172
- const s = o.match(/\((\d+)\)/);
173
- s && s[1] && ([, d] = s);
330
+ const _ = K[e].findIndex((h) => h.value === n);
331
+ let I = "1";
332
+ if (_ >= 0)
333
+ I = String(_ + 1);
334
+ else if (n) {
335
+ const h = n.match(/\((\d+)\)/);
336
+ h && h[1] && ([, I] = h);
174
337
  }
175
- return C = i.PAIRS_FOR_EXTENSION.imageSrc[t].DEFAULT[r >= 0 ? r : 0], A = i.PAIRS_FOR_EXTENSION.name[t].DEFAULT[r >= 0 ? r : 0], p = n ? i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.price[t].DEFAULT_PRICE, I = n ? i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE_FORMATTED : i.PAIRS_FOR_EXTENSION.originalPrice[t].DEFAULT_PRICE, u = i.PAIRS_FOR_EXTENSION.quantity[t].DEFAULT, a === O.ORIENTATION.VERTICAL ? R(
176
- g,
338
+ k = d.PAIRS_FOR_EXTENSION.imageSrc[e].DEFAULT[_ >= 0 ? _ : 0], A = d.PAIRS_FOR_EXTENSION.name[e].DEFAULT[_ >= 0 ? _ : 0], f = o ? d.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE_FORMATTED : d.PAIRS_FOR_EXTENSION.price[e].DEFAULT_PRICE, y = o ? d.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE_FORMATTED : d.PAIRS_FOR_EXTENSION.originalPrice[e].DEFAULT_PRICE, P = d.PAIRS_FOR_EXTENSION.quantity[e].DEFAULT;
339
+ const w = b || (s == null ? void 0 : s.priceOrientation) || "horizontal";
340
+ return t === g.ORIENTATION.VERTICAL ? L(
341
+ Q,
342
+ e,
343
+ I,
177
344
  t,
178
- d,
345
+ o,
346
+ l,
179
347
  a,
180
- n,
348
+ r,
349
+ c,
350
+ void 0,
351
+ // nodup
352
+ s,
353
+ p,
354
+ i,
355
+ w,
356
+ T,
357
+ E,
358
+ $
359
+ ) : L(
360
+ G,
181
361
  e,
182
- c
183
- ) : R(
184
- B,
362
+ I,
185
363
  t,
186
- d,
364
+ o,
365
+ l,
187
366
  a,
188
- n,
189
- e,
190
- c
367
+ r,
368
+ c,
369
+ void 0,
370
+ // nodup
371
+ s,
372
+ p,
373
+ i,
374
+ w,
375
+ T,
376
+ E,
377
+ $
191
378
  );
192
379
  }
193
380
  export {
194
- G as getDefaultTemplate
381
+ ct as getDefaultTemplate
195
382
  };
@@ -0,0 +1,172 @@
1
+ import { ModificationDescription as _ } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { DefaultConfigValues as e, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
3
+ function d() {
4
+ return String(Date.now() + Math.floor(Math.random() * 1e3));
5
+ }
6
+ function f() {
7
+ return {
8
+ initialized: !0,
9
+ blockInstanceId: d(),
10
+ source: n.ITEMS_TYPE.CART_ITEMS,
11
+ type: n.ITEMS_TYPE.CART_ITEMS,
12
+ itemsSelectValue: e.cartItemsSelectControlValue,
13
+ orientation: n.ORIENTATION.VERTICAL,
14
+ nameTrimming: e.productNameTrimmingControlValue === "1",
15
+ nameControlEnabled: e.productNameControlEnabled === "1",
16
+ priceHideDiscount: e.productPriceHideDiscountControlValue === "1",
17
+ priceFormatted: e.productPriceFormattedControlValue === "1",
18
+ priceCurrencySymbol: e.productPriceCurrencySymbolControlValue,
19
+ priceCurrencyLocation: e.productPriceCurrencyLocationControlValue,
20
+ priceControlOpened: e.productPriceControlOpened === "1",
21
+ priceOrientation: "horizontal",
22
+ quantityControlEnabled: e.productQuantityControlEnabled === "1",
23
+ buttonLink: e.productButtonLinkControlValue,
24
+ imageLink: e.productImageLinkControlValue,
25
+ buttonLabel: "Buy",
26
+ imageVisible: e.productImageVisible === "1",
27
+ nameVisible: e.productNameVisible === "1",
28
+ quantityVisible: e.productQuantityVisible === "1",
29
+ priceVisible: e.productPriceVisible === "1",
30
+ originalPriceVisible: e.productOriginalPriceVisible === "1",
31
+ buttonVisible: e.productButtonVisible === "1"
32
+ };
33
+ }
34
+ function s(r) {
35
+ if (!r)
36
+ return null;
37
+ const t = r.closest(".items-block-v2");
38
+ return t || r.closest(".esd-cart-items-block");
39
+ }
40
+ function m(r) {
41
+ return r ? {
42
+ CartItems: n.ITEMS_TYPE.CART_ITEMS,
43
+ BrowsedItems: n.ITEMS_TYPE.BROWSED_ITEMS,
44
+ PurchasedItems: n.ITEMS_TYPE.PURCHASED_ITEMS,
45
+ // Also handle already correct formats
46
+ CART_ITEMS: n.ITEMS_TYPE.CART_ITEMS,
47
+ BROWSED_ITEMS: n.ITEMS_TYPE.BROWSED_ITEMS,
48
+ PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
49
+ }[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
50
+ }
51
+ function C(r, t) {
52
+ if (!r)
53
+ return e.cartItemsSelectControlValue;
54
+ if (r.includes("{{"))
55
+ return r;
56
+ if (/^\d+$/.test(r)) {
57
+ const i = parseInt(r) - 1, o = g[t];
58
+ if (o && o[i])
59
+ return o[i].value;
60
+ }
61
+ return e.cartItemsSelectControlValue;
62
+ }
63
+ function I(r) {
64
+ const t = r.querySelector("esd-config-block");
65
+ if (!t)
66
+ return null;
67
+ const i = (c, a) => c == null ? a : c === "1" || c === "true", o = (c, a) => c || a, l = t.getAttribute("data-type"), u = m(l), p = t.getAttribute("data-cart_items_select_control_value"), b = C(p, u);
68
+ return {
69
+ initialized: i(t.getAttribute("data-initialized"), !1),
70
+ blockInstanceId: o(
71
+ t.getAttribute("data-block-instance-id"),
72
+ d()
73
+ ),
74
+ source: u,
75
+ type: u,
76
+ itemsSelectValue: b,
77
+ orientation: t.getAttribute("data-card_orientation_control_value") || n.ORIENTATION.VERTICAL,
78
+ nameTrimming: i(
79
+ t.getAttribute("data-product_name_trimming"),
80
+ !0
81
+ ),
82
+ nameControlEnabled: i(
83
+ t.getAttribute("data-product_name_control_enabled"),
84
+ !0
85
+ ),
86
+ priceHideDiscount: i(
87
+ t.getAttribute("data-product_price_hide_discount"),
88
+ !0
89
+ ),
90
+ priceFormatted: i(
91
+ t.getAttribute("data-product_price_formatted"),
92
+ !0
93
+ ),
94
+ priceCurrencySymbol: o(
95
+ t.getAttribute("data-product_price_currency_symbol"),
96
+ e.productPriceCurrencySymbolControlValue
97
+ ),
98
+ priceCurrencyLocation: o(
99
+ t.getAttribute("data-product_price_currency_location"),
100
+ e.productPriceCurrencyLocationControlValue
101
+ ),
102
+ priceControlOpened: i(
103
+ t.getAttribute("data-product_price_control_opened"),
104
+ !0
105
+ ),
106
+ priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
107
+ quantityControlEnabled: i(
108
+ t.getAttribute("data-product_quantity_control_enabled"),
109
+ !0
110
+ ),
111
+ buttonLink: o(
112
+ t.getAttribute("data-product_button_link"),
113
+ e.productButtonLinkControlValue
114
+ ),
115
+ imageLink: o(
116
+ t.getAttribute("data-product_image_link"),
117
+ e.productImageLinkControlValue
118
+ ),
119
+ buttonLabel: o(
120
+ t.getAttribute("data-product_button_control_label"),
121
+ "Buy"
122
+ ),
123
+ imageVisible: i(
124
+ t.getAttribute("data-product_image_visible"),
125
+ !0
126
+ ),
127
+ nameVisible: i(
128
+ t.getAttribute("data-product_name_visible"),
129
+ !0
130
+ ),
131
+ quantityVisible: i(
132
+ t.getAttribute("data-product_quantity_visible"),
133
+ !0
134
+ ),
135
+ priceVisible: i(
136
+ t.getAttribute("data-product_price_visible"),
137
+ !0
138
+ ),
139
+ originalPriceVisible: i(
140
+ t.getAttribute("data-product_original_price_control_enabled"),
141
+ !0
142
+ ),
143
+ buttonVisible: i(
144
+ t.getAttribute("data-product_button_visible"),
145
+ !0
146
+ )
147
+ };
148
+ }
149
+ function S(r) {
150
+ const t = s(r);
151
+ if (!t)
152
+ return null;
153
+ const i = t.getNodeConfig();
154
+ if (i && i.initialized)
155
+ return i;
156
+ const o = I(t);
157
+ return o || null;
158
+ }
159
+ function y(r, t, i) {
160
+ const o = s(r);
161
+ if (!o)
162
+ return;
163
+ const u = { ...o.getNodeConfig() || {}, ...i };
164
+ t.getDocumentModifier().modifyHtml(o).setNodeConfig(u).apply(new _("Update Items block configuration"));
165
+ }
166
+ export {
167
+ d as generateBlockInstanceId,
168
+ f as getDefaultItemsBlockConfig,
169
+ S as getItemsBlockConfig,
170
+ s as getItemsBlockContainer,
171
+ y as setItemsBlockConfig
172
+ };