@useinsider/guido 3.24.0-beta.2ad6e30 → 3.24.0-beta.468d41f

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/@types/config/schemas.js +16 -16
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +79 -77
  5. package/dist/composables/useModuleRepair.js +14 -12
  6. package/dist/composables/useSave.js +52 -57
  7. package/dist/composables/useSaveValidation.js +110 -118
  8. package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
  9. package/dist/config/migrator/index.js +16 -15
  10. package/dist/config/migrator/itemsPriceFormatMigrator.js +20 -0
  11. package/dist/enums/save-validation.js +1 -1
  12. package/dist/extensions/Blocks/Items/block.js +115 -77
  13. package/dist/extensions/Blocks/Items/constants/currency.js +59 -14
  14. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +33 -22
  15. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +62 -51
  16. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +18 -17
  17. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -31
  18. package/dist/extensions/Blocks/Items/controls/priceFormat.js +145 -0
  19. package/dist/extensions/Blocks/Items/controls/settingsControl.js +141 -120
  20. package/dist/extensions/Blocks/Items/enums/controlEnums.js +1 -1
  21. package/dist/extensions/Blocks/Items/extension.js +9 -8
  22. package/dist/extensions/Blocks/Items/items.css.js +19 -0
  23. package/dist/extensions/Blocks/Items/settingsPanel.js +34 -25
  24. package/dist/extensions/Blocks/Items/template.js +250 -212
  25. package/dist/extensions/Blocks/Items/utils/priceFormatOps.js +185 -0
  26. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +1 -0
  27. package/dist/guido.css +1 -1
  28. package/dist/package.json.js +2 -2
  29. package/dist/src/@types/config/schemas.d.ts +4 -4
  30. package/dist/src/composables/useConfig.d.ts +2 -2
  31. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  32. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
  33. package/dist/src/config/migrator/index.d.ts +4 -1
  34. package/dist/src/config/migrator/itemsPriceFormatMigrator.d.ts +1 -0
  35. package/dist/src/enums/save-validation.d.ts +1 -2
  36. package/dist/src/extensions/Blocks/Items/block.d.ts +6 -9
  37. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +32 -0
  38. package/dist/src/extensions/Blocks/Items/controls/priceFormat.d.ts +23 -0
  39. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +1 -0
  40. package/dist/src/extensions/Blocks/Items/enums/controlEnums.d.ts +1 -0
  41. package/dist/src/extensions/Blocks/Items/template.d.ts +4 -1
  42. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +3 -0
  43. package/dist/src/extensions/Blocks/Items/utils/priceFormatOps.d.ts +61 -0
  44. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +12 -0
  45. package/dist/src/stores/config.d.ts +20 -20
  46. package/dist/src/utils/itemsCurrencyRepair.d.ts +5 -1
  47. package/dist/utils/itemsCurrencyRepair.js +29 -24
  48. package/dist/utils/pairProductVariables.js +119 -99
  49. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
1
  import { getIgnoredRecommendationBlockIds as Y } from "../config/compiler/utils/recommendationIgnoreUtils.js";
2
- import { CanNotMakeAnyChangesForRunningKey as k, DISPLAY_CONDITIONS_REGEX as U, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M } from "../enums/html-validator.js";
2
+ import { CanNotMakeAnyChangesForRunningKey as k, DISPLAY_CONDITIONS_REGEX as x, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M } from "../enums/html-validator.js";
3
3
  import { SaveValidationRule as o } from "../enums/save-validation.js";
4
4
  import { ToasterTypeOptions as r } from "../enums/toaster.js";
5
- import { BLOCK_ROOT_SELECTOR as x } from "../extensions/Blocks/Checkbox/constants/selectors.js";
6
- import { itemsBlockDynamicVariables as W } from "../extensions/Blocks/Items/enums/productEnums.js";
7
- import { BLOCK_ROOT_SELECTOR as G } from "../extensions/Blocks/RadioButton/constants/selectors.js";
8
- import { useRecommendationExtensionStore as P } from "../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { BLOCK_ROOT_SELECTOR as U } from "../extensions/Blocks/Checkbox/constants/selectors.js";
6
+ import { itemsBlockDynamicVariables as P } from "../extensions/Blocks/Items/enums/productEnums.js";
7
+ import { BLOCK_ROOT_SELECTOR as W } from "../extensions/Blocks/RadioButton/constants/selectors.js";
8
+ import { useRecommendationExtensionStore as G } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
9
  import { getInvalidFields as q, STRATEGY_FIELD_KEY as H, RecommendationAssignStrategyKey as V, RecommendationRequiredFieldsKey as X } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
10
10
  import { useConfigStore as j } from "../stores/config.js";
11
11
  import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
@@ -20,9 +20,9 @@ import { buildPartnerAttributeNameSet as ne, getInvalidDynamicContentTags as ie,
20
20
  import { useHttp as se } from "./useHttp.js";
21
21
  import { useTranslations as ae } from "./useTranslations.js";
22
22
  import { findInvalidCouponBlocks as ce, COUPON_TAG_MODIFIED_KEY as le } from "./validators/useCouponBlockValidator.js";
23
- import { hasInsiderUnsubscribeCode as ue, EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY as me, findDuplicateUnsubPageTypes as de, countUnsubBlocksWithoutPage as pe, EMPTY_BLOCK_KEY as ge } from "./validators/useUnsubscribeBlockValidator.js";
24
- const fe = "newsletter.html-content-is-empty", ye = "custom-fields.missing-closing-braces", Ee = "custom-fields.missing-opening-braces", S = "custom-fields.invalid-custom-fields", Ie = "newsletter.display-conditions-invalid-syntax", Se = "custom-conditions.wrong-equality-operators", _e = "custom-conditions.missing-if-endif-tag", Ce = "custom-conditions.no-space-after-braces", he = "custom-conditions.no-braces-inside-if-tag", ke = "newsletter.fill-all-necessary-fields", Te = "newsletter.invalid-image-type", Fe = "unsubscribe-templates.select-checkbox-groups", be = "unsubscribe-templates.select-radio-button-groups", F = "newsletter.invalid-url-link-for-toaster", b = "journey-builder.liquid-validation-failed", Re = "/newsletter/template-library/check-template-html-body", Le = /src="[^"]*\.(svg|pst)"/gm, L = /({%(.*?)%})/g, Ne = ["if", "endif", "else", "elif", "now"], Oe = (t) => !Ne.includes(t.toLowerCase()), Ae = (t) => ["if", "endif"].includes(t.toLowerCase());
25
- function De(t) {
23
+ import { findDuplicateUnsubPageTypes as me, countUnsubBlocksWithoutPage as ue, EMPTY_BLOCK_KEY as de } from "./validators/useUnsubscribeBlockValidator.js";
24
+ const pe = "newsletter.html-content-is-empty", ge = "custom-fields.missing-closing-braces", fe = "custom-fields.missing-opening-braces", S = "custom-fields.invalid-custom-fields", ye = "newsletter.display-conditions-invalid-syntax", Ee = "custom-conditions.wrong-equality-operators", Ie = "custom-conditions.missing-if-endif-tag", Se = "custom-conditions.no-space-after-braces", _e = "custom-conditions.no-braces-inside-if-tag", Ce = "newsletter.fill-all-necessary-fields", he = "newsletter.invalid-image-type", ke = "unsubscribe-templates.select-checkbox-groups", Te = "unsubscribe-templates.select-radio-button-groups", F = "newsletter.invalid-url-link-for-toaster", R = "journey-builder.liquid-validation-failed", Fe = "/newsletter/template-library/check-template-html-body", Re = /src="[^"]*\.(svg|pst)"/gm, L = /({%(.*?)%})/g, Oe = ["if", "endif", "else", "elif", "now"], Le = (t) => !Oe.includes(t.toLowerCase()), Ne = (t) => ["if", "endif"].includes(t.toLowerCase());
25
+ function be(t) {
26
26
  return ce(t).map((i) => ({
27
27
  rule: o.CouponTagModified,
28
28
  type: r.Warning,
@@ -30,61 +30,54 @@ function De(t) {
30
30
  detail: i
31
31
  }));
32
32
  }
33
- function ve(t) {
34
- return de(t).map((i) => ({
33
+ function Ae(t) {
34
+ return me(t).map((i) => ({
35
35
  rule: o.DuplicateUnsubBlock,
36
36
  type: r.Error,
37
37
  key: i.messageKey
38
38
  }));
39
39
  }
40
- function Ke(t) {
41
- return Array.from({ length: pe(t) }, () => ({
40
+ function ve(t) {
41
+ return Array.from({ length: ue(t) }, () => ({
42
42
  rule: o.UnsubBlockMissingTemplate,
43
43
  type: r.Warning,
44
- key: ge
44
+ key: de
45
45
  }));
46
46
  }
47
- function Be(t) {
48
- return ue(t) ? [{
49
- rule: o.ExternallyManagedUnsubscribe,
50
- type: r.Warning,
51
- key: me
52
- }] : [];
53
- }
54
- function we(t, i) {
47
+ function De(t, i) {
55
48
  const n = t.match(L);
56
49
  if (!n)
57
50
  return [];
58
- const u = [];
59
- return n.forEach((m) => {
60
- const c = m.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
51
+ const l = [];
52
+ return n.forEach((u) => {
53
+ const c = u.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
61
54
  if (c && c.length > 0) {
62
55
  const [d] = c;
63
- Oe(d) && !i.includes(d) && u.push({
56
+ Le(d) && !i.includes(d) && l.push({
64
57
  rule: o.CustomFieldScript,
65
58
  type: r.Warning,
66
59
  key: S,
67
60
  detail: d
68
61
  });
69
62
  }
70
- }), u;
63
+ }), l;
71
64
  }
72
- function Ye(t) {
73
- return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: fe }];
65
+ function Ke(t) {
66
+ return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: pe }];
74
67
  }
75
- function Ue(t) {
68
+ function we(t) {
76
69
  const i = (t.match(/{/gm) || []).length, n = (t.match(/}/gm) || []).length;
77
70
  return i > n ? [{
78
71
  rule: o.MismatchedBraces,
79
72
  type: r.Warning,
80
- key: ye
73
+ key: ge
81
74
  }] : i < n ? [{
82
75
  rule: o.MismatchedBraces,
83
76
  type: r.Warning,
84
- key: Ee
77
+ key: fe
85
78
  }] : [];
86
79
  }
87
- function Me(t) {
80
+ function Be(t) {
88
81
  return ie(t).map((i) => ({
89
82
  rule: o.InvalidDynamicTag,
90
83
  type: r.Warning,
@@ -92,75 +85,75 @@ function Me(t) {
92
85
  detail: i
93
86
  }));
94
87
  }
95
- function xe(t, i, n, u) {
96
- const m = oe(t);
97
- return re(t, i, m, n, u).map((c) => ({
88
+ function Ye(t, i, n, l) {
89
+ const u = oe(t);
90
+ return re(t, i, u, n, l).map((c) => ({
98
91
  rule: o.InvalidCustomField,
99
92
  type: r.Error,
100
93
  key: S,
101
94
  detail: c
102
95
  }));
103
96
  }
104
- function We(t) {
105
- const i = t.match(/{%(.*?)%}/g), n = [], u = [];
106
- if (i && i.forEach((m) => {
107
- const c = m.match(U), d = m.match(M), I = (c == null ? void 0 : c.join("")) || "";
108
- (!c || m !== I) && !d && u.push({
97
+ function xe(t) {
98
+ const i = t.match(/{%(.*?)%}/g), n = [], l = [];
99
+ if (i && i.forEach((u) => {
100
+ const c = u.match(x), d = u.match(M), I = (c == null ? void 0 : c.join("")) || "";
101
+ (!c || u !== I) && !d && l.push({
109
102
  rule: o.ConditionsSyntax,
110
103
  type: r.Error,
111
- key: Ie,
112
- detail: m
104
+ key: ye,
105
+ detail: u
113
106
  }), c && c.forEach((g) => {
114
- g.trim() === "=" && u.push({
107
+ g.trim() === "=" && l.push({
115
108
  rule: o.WrongEqualityOperator,
116
109
  type: r.Error,
117
- key: Se
110
+ key: Ee
118
111
  }), (g.match(/^[a-zA-Z]*$/g) ?? []).forEach((f) => {
119
- Ae(f) && n.push(f);
112
+ Ne(f) && n.push(f);
120
113
  });
121
114
  });
122
115
  }), n.length) {
123
- const m = n.filter((d) => d === "if").length, c = n.filter((d) => d === "endif").length;
124
- m !== c && u.push({
116
+ const u = n.filter((d) => d === "if").length, c = n.filter((d) => d === "endif").length;
117
+ u !== c && l.push({
125
118
  rule: o.MissingIfEndif,
126
119
  type: r.Error,
127
- key: _e
120
+ key: Ie
128
121
  });
129
122
  }
130
- return u;
123
+ return l;
131
124
  }
132
- function Ge(t) {
125
+ function Me(t) {
133
126
  const i = (t.match(/{% /gm) || []).length, n = (t.match(/ %}/gm) || []).length;
134
127
  return i === n ? [] : [{
135
128
  rule: o.ConditionTagSpacing,
136
129
  type: r.Warning,
137
- key: Ce
130
+ key: Se
138
131
  }];
139
132
  }
140
- function Pe(t) {
141
- return (t.match(L) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, u) => n + u, 0) === 0 ? [] : [{
133
+ function Ue(t) {
134
+ return (t.match(L) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, l) => n + l, 0) === 0 ? [] : [{
142
135
  rule: o.BracesInsideIfTag,
143
136
  type: r.Warning,
144
- key: he
137
+ key: _e
145
138
  }];
146
139
  }
147
- function qe(t) {
148
- return (t.match(Le) ?? []).map((i) => ({
140
+ function Pe(t) {
141
+ return (t.match(Re) ?? []).map((i) => ({
149
142
  rule: o.InvalidImageType,
150
143
  type: r.Error,
151
- key: Te,
144
+ key: he,
152
145
  detail: i
153
146
  }));
154
147
  }
155
- function R(t, i, n, u) {
156
- const m = new DOMParser().parseFromString(t, "text/html");
157
- return Array.from(m.querySelectorAll(i)).filter((c) => {
148
+ function O(t, i, n, l) {
149
+ const u = new DOMParser().parseFromString(t, "text/html");
150
+ return Array.from(u.querySelectorAll(i)).filter((c) => {
158
151
  var d;
159
152
  return !((d = c.id) != null && d.trim());
160
- }).map(() => ({ rule: n, type: r.Error, key: u }));
153
+ }).map(() => ({ rule: n, type: r.Error, key: l }));
161
154
  }
162
- const ft = () => {
163
- const { config: t, isFeatureEnabled: i } = ee(), n = ae(), { post: u } = se(), { getCompiledEmail: m, getTemplateData: c } = J(), { compileHtml: d } = te(), { hydrateRecommendationStore: I } = Z(), g = z(), f = $(), y = P(), N = j(), O = (e) => ({
155
+ const dt = () => {
156
+ const { config: t, isFeatureEnabled: i } = ee(), n = ae(), { post: l } = se(), { getCompiledEmail: u, getTemplateData: c } = J(), { compileHtml: d } = te(), { hydrateRecommendationStore: I } = Z(), g = z(), f = $(), y = G(), N = j(), b = (e) => ({
164
157
  rule: e.rule,
165
158
  type: e.type,
166
159
  detail: e.detail,
@@ -174,24 +167,24 @@ const ft = () => {
174
167
  return null;
175
168
  }
176
169
  return ne(y.filterList);
177
- }, D = async (e) => {
170
+ }, v = async (e) => {
178
171
  try {
179
- const a = await u(Re, { html: T(e) }), { status: s, message: l } = a.data, p = [], E = s === void 0 && !!l && l !== n(F);
180
- return s || p.push({
172
+ const s = await l(Fe, { html: T(e) }), { status: a, message: m } = s.data, p = [], E = a === void 0 && !!m && m !== n(F);
173
+ return a || p.push({
181
174
  rule: o.InvalidLinks,
182
175
  type: r.Error,
183
- ...E ? { message: l } : { key: F }
184
- }), l === n(k) && p.push({
176
+ ...E ? { message: m } : { key: F }
177
+ }), m === n(k) && p.push({
185
178
  rule: o.LinkCheckInProgress,
186
179
  type: r.Error,
187
180
  key: k
188
181
  }), p;
189
- } catch (a) {
190
- return console.warn("Link-check collector failed; skipping the link rule.", a), [];
182
+ } catch (s) {
183
+ return console.warn("Link-check collector failed; skipping the link rule.", s), [];
191
184
  }
192
- }, v = async (e) => {
185
+ }, D = async (e) => {
193
186
  try {
194
- const a = await u("/newsletter/contents/validate-syntax", [{
187
+ const s = await l("/newsletter/contents/validate-syntax", [{
195
188
  identifier: "default",
196
189
  syntax: "liquid",
197
190
  contents: {
@@ -201,89 +194,88 @@ const ft = () => {
201
194
  ampHtml: null
202
195
  }
203
196
  }]);
204
- if (!Array.isArray(a.data)) {
205
- const l = a.data;
197
+ if (!Array.isArray(s.data)) {
198
+ const m = s.data;
206
199
  return [{
207
200
  rule: o.LiquidSyntax,
208
201
  type: r.Warning,
209
- message: l.message ?? n(b)
202
+ message: m.message ?? n(R)
210
203
  }];
211
204
  }
212
- const [s] = a.data;
213
- return Object.values((s == null ? void 0 : s.errors) ?? {}).map((l) => ({
205
+ const [a] = s.data;
206
+ return Object.values((a == null ? void 0 : a.errors) ?? {}).map((m) => ({
214
207
  rule: o.LiquidSyntax,
215
208
  type: r.Warning,
216
- message: l.replace(/^line \d+:\s*/, "")
209
+ message: m.replace(/^line \d+:\s*/, "")
217
210
  }));
218
- } catch (a) {
219
- if (a != null && a.authReported)
220
- throw a;
211
+ } catch (s) {
212
+ if (s != null && s.authReported)
213
+ throw s;
221
214
  return [{
222
215
  rule: o.LiquidSyntax,
223
216
  type: r.Error,
224
- message: n(b)
217
+ message: n(R)
225
218
  }];
226
219
  }
227
220
  }, K = () => {
228
- const e = Object.values(y.blockStates).map((s) => q(s.recommendationConfigs, y)).filter((s) => s.length > 0).map((s) => {
229
- const l = s.every((p) => p === H);
221
+ const e = Object.values(y.blockStates).map((a) => q(a.recommendationConfigs, y)).filter((a) => a.length > 0).map((a) => {
222
+ const m = a.every((p) => p === H);
230
223
  return {
231
224
  rule: o.RecommendationRequiredFields,
232
- type: l ? r.Warning : r.Error,
233
- key: l ? V : X
225
+ type: m ? r.Warning : r.Error,
226
+ key: m ? V : X
234
227
  };
235
- }), a = (f.recommendationConfigs ?? []).filter((s) => s.filters.some((l) => l.value === "")).map(() => ({
228
+ }), s = (f.recommendationConfigs ?? []).filter((a) => a.filters.some((m) => m.value === "")).map(() => ({
236
229
  rule: o.RecommendationFilters,
237
230
  type: r.Error,
238
- key: ke
231
+ key: Ce
239
232
  }));
240
- return [...e, ...a];
241
- }, B = async (e, a) => {
233
+ return [...e, ...s];
234
+ }, w = async (e, s) => {
242
235
  var C, h;
243
- const s = [
244
- ...a.map((w) => w.value),
245
- ...W,
236
+ const a = [
237
+ ...s.map((B) => B.value),
238
+ ...P,
246
239
  ...((h = (C = t.value) == null ? void 0 : C.template) == null ? void 0 : h.customFieldAttributes) ?? []
247
- ], l = Y(e), p = await A(l), { isTransactional: E } = N;
240
+ ], m = Y(e), p = await A(m), { isTransactional: E } = N;
248
241
  return [
249
- ...await D(e),
250
- ...E ? [] : we(e, s),
251
- ...Ye(e),
252
- ...Ue(e),
242
+ ...await v(e),
243
+ ...E ? [] : De(e, a),
244
+ ...Ke(e),
245
+ ...we(e),
246
+ ...Be(e),
247
+ ...E ? [] : Ye(e, a, m, p),
248
+ ...xe(e),
253
249
  ...Me(e),
254
- ...E ? [] : xe(e, s, l, p),
255
- ...We(e),
256
- ...Ge(e),
257
- ...Pe(e),
250
+ ...Ue(e),
258
251
  ...K(),
259
- ...qe(e),
260
- ...R(
252
+ ...Pe(e),
253
+ ...O(
261
254
  e,
262
- x,
255
+ U,
263
256
  o.CheckboxUnsubGroup,
264
- Fe
257
+ ke
265
258
  ),
266
- ...R(
259
+ ...O(
267
260
  e,
268
- G,
261
+ W,
269
262
  o.RadioButtonUnsubGroup,
270
- be
263
+ Te
271
264
  )
272
265
  ];
273
- }, _ = async (e, a, s) => [
274
- ...De(e),
275
- ...i("blockUnsubscribeLinks") ? Be(s) : [],
266
+ }, _ = async (e, s) => [
267
+ ...be(e),
268
+ ...Ae(e),
276
269
  ...ve(e),
277
- ...Ke(e),
278
- ...i("liquidSyntax") ? await v(e) : await B(e, a)
279
- ].map(O);
270
+ ...i("liquidSyntax") ? await D(e) : await w(e, s)
271
+ ].map(b);
280
272
  return { collectSaveValidationErrors: _, validateCurrentTemplate: async () => {
281
273
  const { html: e } = await c();
282
274
  await I(e);
283
- const { html: a } = await m({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: s } = d(a);
284
- return _(s, g.getSelectedDynamicContentList, e);
275
+ const { html: s } = await u({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: a } = d(s);
276
+ return _(a, g.getSelectedDynamicContentList);
285
277
  } };
286
278
  };
287
279
  export {
288
- ft as useSaveValidation
280
+ dt as useSaveValidation
289
281
  };
@@ -1,8 +1,8 @@
1
- import { ToasterTypeOptions as i } from "../../enums/toaster.js";
2
- import { MERGE_TAGS as p, PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
- import { UNSUBSCRIBE_BLOCK_SELECTOR as l, DATA_ATTRIBUTES as c } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
- import { useToaster as E } from "../useToaster.js";
5
- import { useTranslations as b } from "../useTranslations.js";
1
+ import { ToasterTypeOptions as c } from "../../enums/toaster.js";
2
+ import { PAGE_TYPES as u } from "../../enums/unsubscribe.js";
3
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as i, DATA_ATTRIBUTES as a } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
4
+ import { useToaster as p } from "../useToaster.js";
5
+ import { useTranslations as l } from "../useTranslations.js";
6
6
  const T = [
7
7
  {
8
8
  pageType: u.GLOBAL_UNSUBSCRIBE,
@@ -12,52 +12,37 @@ const T = [
12
12
  pageType: u.SUBSCRIPTION_PREFERENCE_CENTER,
13
13
  messageKey: "unsubscription-preference.duplicate-pref-center"
14
14
  }
15
- ], g = "unsubscription-preference.duplicate-both", _ = "unsubscription-preference.select-page-to-continue", m = "newsletter.sfmc-remove-unsubscribe-link", f = Object.values(p).map((e) => e.slice(2, -2).replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), U = new RegExp(
16
- `(?:{{|%7B%7B)(?:\\s|%20)*(?:${f})(?:\\s|%20)*(?:}}|%7D%7D)|(?:%|%25)(?:asm_[a-z_]+_raw_url|unsub)(?:%|%25)`,
17
- "i"
18
- );
19
- function B(e) {
20
- return U.test(e);
15
+ ], g = "unsubscription-preference.duplicate-both", E = "unsubscription-preference.select-page-to-continue";
16
+ function m(r) {
17
+ const s = new DOMParser().parseFromString(r, "text/html"), t = /* @__PURE__ */ new Map();
18
+ return s.querySelectorAll(i).forEach((n) => {
19
+ const e = Number(n.getAttribute(a.PAGE_TYPE));
20
+ t.set(e, (t.get(e) ?? 0) + 1);
21
+ }), T.filter((n) => (t.get(n.pageType) ?? 0) > 1);
21
22
  }
22
- function S(e) {
23
- const t = new DOMParser().parseFromString(e, "text/html"), s = /* @__PURE__ */ new Map();
24
- return t.querySelectorAll(l).forEach((r) => {
25
- const n = Number(r.getAttribute(c.PAGE_TYPE));
26
- s.set(n, (s.get(n) ?? 0) + 1);
27
- }), T.filter((r) => (s.get(r.pageType) ?? 0) > 1);
28
- }
29
- function A(e) {
30
- const t = new DOMParser().parseFromString(e, "text/html");
31
- return Array.from(t.querySelectorAll(l)).filter((s) => {
32
- const r = s.getAttribute(c.PAGE_TYPE), n = s.getAttribute(c.PAGE_LIST);
33
- return !r || !n;
23
+ function b(r) {
24
+ const s = new DOMParser().parseFromString(r, "text/html");
25
+ return Array.from(s.querySelectorAll(i)).filter((t) => {
26
+ const n = t.getAttribute(a.PAGE_TYPE), e = t.getAttribute(a.PAGE_LIST);
27
+ return !n || !e;
34
28
  }).length;
35
29
  }
36
- const I = () => {
37
- const { showToaster: e } = E(), t = b();
38
- return {
39
- validateUnsubscribeBlockUniqueness: (o) => {
40
- const a = S(o);
41
- return a.length ? (e({
42
- type: i.Error,
43
- message: t(a.length > 1 ? g : a[0].messageKey)
44
- }), !1) : !0;
45
- },
46
- validateUnsubscribeBlockHasTemplate: (o) => A(o) === 0 ? !0 : (e({
47
- type: i.Warning,
48
- message: t(_)
49
- }), !1),
50
- validateNoInsiderUnsubscribeCode: (o, a = !1) => B(o) ? (a || e({
51
- type: i.Warning,
52
- message: t(m)
53
- }), !1) : !0
54
- };
30
+ const y = () => {
31
+ const { showToaster: r } = p(), s = l();
32
+ return { validateUnsubscribeBlockUniqueness: (e) => {
33
+ const o = m(e);
34
+ return o.length ? (r({
35
+ type: c.Error,
36
+ message: s(o.length > 1 ? g : o[0].messageKey)
37
+ }), !1) : !0;
38
+ }, validateUnsubscribeBlockHasTemplate: (e) => b(e) === 0 ? !0 : (r({
39
+ type: c.Warning,
40
+ message: s(E)
41
+ }), !1) };
55
42
  };
56
43
  export {
57
- _ as EMPTY_BLOCK_KEY,
58
- m as EXTERNALLY_MANAGED_UNSUBSCRIBE_KEY,
59
- A as countUnsubBlocksWithoutPage,
60
- S as findDuplicateUnsubPageTypes,
61
- B as hasInsiderUnsubscribeCode,
62
- I as useUnsubscribeBlockValidator
44
+ E as EMPTY_BLOCK_KEY,
45
+ b as countUnsubBlocksWithoutPage,
46
+ m as findDuplicateUnsubPageTypes,
47
+ y as useUnsubscribeBlockValidator
63
48
  };
@@ -1,18 +1,19 @@
1
- import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
- import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
3
- import { migrateFullStoryScripts as a } from "./fullStoryScriptMigrator.js";
4
- import { migrateItemsBlock as n } from "./itemsBlockMigrator.js";
5
- import { migrateProductNameLink as c } from "./productNameLinkMigrator.js";
6
- import { migrateRadioButton as g } from "./radioButtonMigrator.js";
7
- import { migrateRecommendation as p } from "./recommendationMigrator.js";
8
- import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
9
- import { migrateRecommendationTitle as l } from "./recommendationTitleMigrator.js";
10
- import { migrateSocialIcons as s } from "./socialIconMigrator.js";
11
- import { migrateUnsubscribe as d } from "./unsubscribeMigrator.js";
12
- const h = async (o, t = {}, r) => {
13
- let m = o;
14
- return m = i(m), m = g(m), m = await d(m), m = e(m), m = p(m, t), r && (m = f(m, r)), m = l(m), m = n(m), m = c(m), m = s(m), m = a(m), m;
1
+ import { migrateCheckbox as e } from "./checkboxMigrator.js";
2
+ import { migrateCouponBlock as a } from "./couponBlockMigrator.js";
3
+ import { migrateFullStoryScripts as c } from "./fullStoryScriptMigrator.js";
4
+ import { migrateItemsBlock as g } from "./itemsBlockMigrator.js";
5
+ import { migrateItemsPriceFormat as n } from "./itemsPriceFormatMigrator.js";
6
+ import { migrateProductNameLink as p } from "./productNameLinkMigrator.js";
7
+ import { migrateRadioButton as f } from "./radioButtonMigrator.js";
8
+ import { migrateRecommendation as l } from "./recommendationMigrator.js";
9
+ import { migrateRecommendationPartnerScope as d } from "./recommendationPartnerMigrator.js";
10
+ import { migrateRecommendationTitle as s } from "./recommendationTitleMigrator.js";
11
+ import { migrateSocialIcons as k } from "./socialIconMigrator.js";
12
+ import { migrateUnsubscribe as P } from "./unsubscribeMigrator.js";
13
+ const H = async (t, i = {}, r, o) => {
14
+ let m = t;
15
+ return m = e(m), m = f(m), m = await P(m), m = a(m), m = l(m, i), r && (m = d(m, r)), m = s(m), m = g(m), o != null && o.itemsPriceFormatting && (m = n(m)), m = p(m), m = k(m), m = c(m), m;
15
16
  };
16
17
  export {
17
- h as migrate
18
+ H as migrate
18
19
  };
@@ -0,0 +1,20 @@
1
+ import { ITEMS_PRICE_FORMAT_ATTR as e } from "../../extensions/Blocks/Items/constants/currency.js";
2
+ import { applyPriceFormatOpsToElement as o, planPriceFormatOps as n, snapshotPriceFormatFromElement as c } from "../../extensions/Blocks/Items/utils/priceFormatOps.js";
3
+ import { protectLiquid as i, restoreLiquid as s } from "../../utils/liquidProtection.js";
4
+ const m = `td.ins-product-td.items-block-v2:not([${e.DECIMAL_COUNT}])`, a = (r) => o(
5
+ r,
6
+ n(c(r), { convertLegacy: !0 })
7
+ );
8
+ function T(r) {
9
+ if (typeof r != "string" || !r.includes("ins-product-td"))
10
+ return r;
11
+ try {
12
+ const t = new DOMParser().parseFromString(i(r), "text/html");
13
+ return Array.from(t.querySelectorAll(m)).map(a).includes(!0) ? s(t.documentElement.outerHTML) : r;
14
+ } catch (t) {
15
+ return console.error("ItemsPriceFormatMigrator failed:", t), r;
16
+ }
17
+ }
18
+ export {
19
+ T as migrateItemsPriceFormat
20
+ };
@@ -1,4 +1,4 @@
1
- var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s.ExternallyManagedUnsubscribe = "externally-managed-unsubscribe", s))(n || {});
1
+ var n = /* @__PURE__ */ ((s) => (s.CouponTagModified = "coupon-tag-modified", s.DuplicateUnsubBlock = "duplicate-unsub-block", s.UnsubBlockMissingTemplate = "unsub-block-missing-template", s.LiquidSyntax = "liquid-syntax", s.InvalidLinks = "invalid-links", s.LinkCheckInProgress = "link-check-in-progress", s.CustomFieldScript = "custom-field-script", s.EmptyHtml = "empty-html", s.MismatchedBraces = "mismatched-braces", s.InvalidDynamicTag = "invalid-dynamic-tag", s.InvalidCustomField = "invalid-custom-field", s.ConditionsSyntax = "conditions-syntax", s.WrongEqualityOperator = "wrong-equality-operator", s.MissingIfEndif = "missing-if-endif", s.ConditionTagSpacing = "condition-tag-spacing", s.BracesInsideIfTag = "braces-inside-if-tag", s.RecommendationRequiredFields = "recommendation-required-fields", s.RecommendationFilters = "recommendation-filters", s.InvalidImageType = "invalid-image-type", s.CheckboxUnsubGroup = "checkbox-unsub-group", s.RadioButtonUnsubGroup = "radio-button-unsub-group", s))(n || {});
2
2
  export {
3
3
  n as SaveValidationRule
4
4
  };