@useinsider/guido 3.25.0 → 3.26.0-beta.017ecf8

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 (86) hide show
  1. package/README.md +11 -0
  2. package/dist/@types/config/schemas.js +106 -100
  3. package/dist/@types/display-condition.js +25 -0
  4. package/dist/components/Guido.vue.js +7 -7
  5. package/dist/components/Guido.vue2.js +113 -104
  6. package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +17 -0
  7. package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +41 -0
  8. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
  9. package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +81 -0
  10. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue.js +17 -0
  11. package/dist/components/organisms/display-conditions/DisplayConditionListState.vue2.js +45 -0
  12. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +36 -0
  13. package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +63 -0
  14. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
  15. package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
  16. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
  17. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
  18. package/dist/composables/useBlocksConfig.js +29 -20
  19. package/dist/composables/useDisplayConditions.js +116 -0
  20. package/dist/composables/useModuleRepair.js +33 -24
  21. package/dist/composables/useSave.js +57 -52
  22. package/dist/composables/useSaveValidation.js +118 -110
  23. package/dist/composables/useTranslations.js +2 -1
  24. package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
  25. package/dist/config/compiler/utils/itemsCompilerUtils.js +43 -42
  26. package/dist/config/compiler/utils/recommendationCompilerUtils.js +67 -64
  27. package/dist/config/migrator/index.js +8 -7
  28. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
  29. package/dist/enums/academy.js +3 -1
  30. package/dist/enums/display-condition.js +12 -0
  31. package/dist/enums/save-validation.js +1 -1
  32. package/dist/extensions/DisplayConditions/bridge.js +25 -0
  33. package/dist/extensions/DisplayConditions/constants.js +26 -0
  34. package/dist/extensions/DisplayConditions/control.js +215 -0
  35. package/dist/extensions/DisplayConditions/display-conditions.css.js +226 -0
  36. package/dist/extensions/DisplayConditions/extension.js +28 -0
  37. package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
  38. package/dist/extensions/DisplayConditions/library.js +30 -0
  39. package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
  40. package/dist/guido.css +1 -1
  41. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
  42. package/dist/node_modules/valibot/dist/index.js +297 -261
  43. package/dist/package.json.js +2 -2
  44. package/dist/services/displayConditionApi.js +39 -0
  45. package/dist/src/@types/config/schemas.d.ts +12 -0
  46. package/dist/src/@types/display-condition.d.ts +61 -0
  47. package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
  48. package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
  49. package/dist/src/components/organisms/display-conditions/DisplayConditionListState.vue.d.ts +18 -0
  50. package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
  51. package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
  52. package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
  53. package/dist/src/composables/useConfig.d.ts +6 -0
  54. package/dist/src/composables/useDisplayConditions.d.ts +18 -0
  55. package/dist/src/composables/useModuleRepair.d.ts +2 -11
  56. package/dist/src/composables/useSaveValidation.d.ts +1 -1
  57. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
  58. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
  59. package/dist/src/enums/academy.d.ts +2 -0
  60. package/dist/src/enums/display-condition.d.ts +15 -0
  61. package/dist/src/enums/save-validation.d.ts +2 -1
  62. package/dist/src/extensions/DisplayConditions/bridge.d.ts +7 -0
  63. package/dist/src/extensions/DisplayConditions/constants.d.ts +23 -0
  64. package/dist/src/extensions/DisplayConditions/control.d.ts +25 -0
  65. package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
  66. package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
  67. package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
  68. package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
  69. package/dist/src/mock/api/display-conditions.d.ts +2 -0
  70. package/dist/src/services/displayConditionApi.d.ts +8 -0
  71. package/dist/src/stores/config.d.ts +210 -0
  72. package/dist/src/stores/display-condition.d.ts +86 -0
  73. package/dist/src/stores/editor.d.ts +27 -0
  74. package/dist/src/utils/displayCondition.d.ts +11 -0
  75. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
  76. package/dist/src/utils/protectTableText.d.ts +2 -0
  77. package/dist/static/stripo-runtime-manifest.json.js +1 -1
  78. package/dist/static/styles/variables.css.js +1 -0
  79. package/dist/stores/config.js +13 -6
  80. package/dist/stores/display-condition.js +29 -0
  81. package/dist/stores/editor.js +1 -0
  82. package/dist/utils/displayCondition.js +29 -0
  83. package/dist/utils/legacyUnsubscribeConversion.js +49 -0
  84. package/dist/utils/pairProductVariables.js +29 -28
  85. package/dist/utils/protectTableText.js +22 -0
  86. package/package.json +2 -2
@@ -0,0 +1,63 @@
1
+ import { defineComponent as T, ref as r, watch as I, computed as i } from "vue";
2
+ import O from "../../wrappers/WpDrawer.vue.js";
3
+ import B from "../../wrappers/WpModal.vue.js";
4
+ import { useDisplayConditions as L, DISPLAY_CONDITIONS_TRANS_KEY as s } from "../../../composables/useDisplayConditions.js";
5
+ import { useTranslations as M } from "../../../composables/useTranslations.js";
6
+ import { useDisplayConditionStore as h } from "../../../stores/display-condition.js";
7
+ import { getTooltipOptions as C } from "../../../utils/tooltipUtils.js";
8
+ import { InSkeleton as $, InDropdownMenu as E, InButtonV2 as b, InBasicTextInput as k } from "@useinsider/design-system-vue";
9
+ import w from "./DisplayConditionListState.vue.js";
10
+ const ee = /* @__PURE__ */ T({
11
+ __name: "DisplayConditionSelectDrawer",
12
+ setup(A) {
13
+ const g = [40, 76, 76, 76], l = M(), t = h(), { loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p } = L(), u = r(""), a = r(null), n = r(null), o = r(!1);
14
+ I(() => t.isSelectOpen, (e) => {
15
+ e && (u.value = "", a.value = null, n.value = null, c());
16
+ }, { immediate: !0 });
17
+ const f = i(() => {
18
+ const e = u.value.trim().toLocaleLowerCase();
19
+ return e ? t.list.filter((m) => `${m.name} ${m.description}`.toLocaleLowerCase().includes(e)) : t.list;
20
+ }), y = i(() => t.listStatus === "error" ? "error" : t.list.length ? f.value.length ? null : "no-result" : "empty"), _ = i(() => p("select-description")), S = i(() => ({
21
+ cancelOrBackButton: {
22
+ styling: "ghost",
23
+ type: "secondary",
24
+ labelText: l(`${s}.back`),
25
+ leftIcon: "line-arrow-left"
26
+ }
27
+ })), x = i(() => ({
28
+ cancelOrBackButton: {
29
+ type: "secondary",
30
+ styling: "ghost",
31
+ labelText: l(`${s}.cancel`),
32
+ disabledStatus: o.value
33
+ },
34
+ primaryButton: {
35
+ type: "danger",
36
+ labelText: l(`${s}.delete`),
37
+ loadingStatus: o.value
38
+ }
39
+ }));
40
+ return { __sfc: !0, SKELETON_HEIGHTS: g, trans: l, store: t, loadList: c, select: v, deleteSaved: d, cancel: D, describeWithAcademyLink: p, search: u, expandedId: a, menuId: n, isDeleting: o, filteredList: f, listState: y, descriptionText: _, footerButtonGroupOptions: S, deleteModalButtons: x, toggleExpanded: (e) => {
41
+ a.value = a.value === e.id ? null : e.id;
42
+ }, toggleMenu: (e) => {
43
+ n.value = n.value === e.id ? null : e.id;
44
+ }, closeMenu: (e) => {
45
+ n.value === e.id && (n.value = null);
46
+ }, expandTooltip: (e) => C(
47
+ `guido__display-condition-expand-tooltip-${e.id}`,
48
+ { staticPosition: "top right" }
49
+ ), menuOptions: (e) => [
50
+ { text: l(`${s}.delete`), value: `guido__display-condition-delete-${e.id}` }
51
+ ], requestDelete: (e) => {
52
+ n.value = null, t.pendingDelete = e;
53
+ }, confirmDelete: async () => {
54
+ !t.pendingDelete || o.value || (o.value = !0, await d(t.pendingDelete), o.value = !1);
55
+ }, closeDeleteModal: () => {
56
+ o.value || (t.pendingDelete = null);
57
+ }, codeOf: (e) => [e.codeBefore, e.codeAfter].filter(Boolean).join(`
58
+ `), WpDrawer: O, WpModal: B, KEY: s, InBasicTextInput: k, InButtonV2: b, InDropdownMenu: E, InSkeleton: $, DisplayConditionListState: w };
59
+ }
60
+ });
61
+ export {
62
+ ee as default
63
+ };
@@ -0,0 +1,17 @@
1
+ import e from "./DisplayConditionsHost.vue2.js";
2
+ import n from "../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var r = function() {
4
+ var s = this, o = s._self._c, t = s._self._setupProxy;
5
+ return o("div", { staticClass: "guido-display-conditions-host" }, [o(t.DisplayConditionCreateDrawer), o(t.DisplayConditionSelectDrawer)], 1);
6
+ }, i = [], a = /* @__PURE__ */ n(
7
+ e,
8
+ r,
9
+ i,
10
+ !1,
11
+ null,
12
+ null
13
+ );
14
+ const p = a.exports;
15
+ export {
16
+ p as default
17
+ };
@@ -0,0 +1,22 @@
1
+ import { defineComponent as i, onMounted as s, onBeforeUnmount as m } from "vue";
2
+ import { useDisplayConditions as p } from "../../../composables/useDisplayConditions.js";
3
+ import { DisplayConditionEvent as n } from "../../../enums/display-condition.js";
4
+ import { useDisplayConditionStore as a } from "../../../stores/display-condition.js";
5
+ import d from "./DisplayConditionCreateDrawer.vue.js";
6
+ import f from "./DisplayConditionSelectDrawer.vue.js";
7
+ const E = /* @__PURE__ */ i({
8
+ __name: "DisplayConditionsHost",
9
+ setup(l) {
10
+ const o = a(), { handleOpen: t } = p(), e = (r) => {
11
+ t(r.detail);
12
+ };
13
+ return s(() => {
14
+ o.$reset(), document.addEventListener(n.OPEN, e);
15
+ }), m(() => {
16
+ document.removeEventListener(n.OPEN, e), o.$reset();
17
+ }), { __sfc: !0, store: o, handleOpen: t, onOpen: e, DisplayConditionCreateDrawer: d, DisplayConditionSelectDrawer: f };
18
+ }
19
+ });
20
+ export {
21
+ E as default
22
+ };
@@ -0,0 +1,17 @@
1
+ import s from "./LegacyUnsubscribeConvertedModal.vue2.js";
2
+ import r from "../../../_virtual/_plugin-vue2_normalizer.js";
3
+ var n = function() {
4
+ var o = this, t = o._self._c, e = o._self._setupProxy;
5
+ return e.isVisible ? t(e.WpModal, { attrs: { id: "guido__legacy-unsubscribe-converted-modal", "close-on-outside-click": !1, "footer-button-options": e.footerButtonOptions, title: e.trans("email-editor.legacy-unsubscribe-converted-modal-title") }, on: { close: e.close, "primary-action": e.close, "secondary-action": e.openAcademy } }, [t("p", [o._v(o._s(e.trans("email-editor.legacy-unsubscribe-converted-modal-message")))])]) : o._e();
6
+ }, a = [], c = /* @__PURE__ */ r(
7
+ s,
8
+ n,
9
+ a,
10
+ !1,
11
+ null,
12
+ null
13
+ );
14
+ const d = c.exports;
15
+ export {
16
+ d as default
17
+ };
@@ -0,0 +1,30 @@
1
+ import { defineComponent as n, computed as t } from "vue";
2
+ import i from "../../wrappers/WpModal.vue.js";
3
+ import { useTranslations as a } from "../../../composables/useTranslations.js";
4
+ import { ACADEMY_LINKS as c } from "../../../enums/academy.js";
5
+ import { useEditorStore as p } from "../../../stores/editor.js";
6
+ const L = /* @__PURE__ */ n({
7
+ __name: "LegacyUnsubscribeConvertedModal",
8
+ setup(d) {
9
+ const o = a(), e = p(), r = t(
10
+ () => e.isLegacyUnsubscribeModalRequested && e.isStripoInitialized
11
+ ), s = t(() => ({
12
+ secondaryButton: {
13
+ type: "subtle-primary",
14
+ labelText: o("email-editor.legacy-unsubscribe-converted-modal-visit-academy")
15
+ },
16
+ primaryButton: {
17
+ type: "primary",
18
+ labelText: o("action-builder.ok")
19
+ }
20
+ }));
21
+ return { __sfc: !0, trans: o, editorStore: e, isVisible: r, footerButtonOptions: s, close: () => {
22
+ e.isLegacyUnsubscribeModalRequested = !1;
23
+ }, openAcademy: () => {
24
+ window.open(c.LEGACY_UNSUBSCRIBE_MODULE, "_blank", "noopener,noreferrer");
25
+ }, WpModal: i };
26
+ }
27
+ });
28
+ export {
29
+ L as default
30
+ };
@@ -1,6 +1,6 @@
1
- import r from "../extensions/ModulesTabIcons/extension.js";
2
- import { useConfigStore as l } from "../stores/config.js";
3
- const a = {
1
+ import l from "../extensions/ModulesTabIcons/extension.js";
2
+ import { useConfigStore as r } from "../stores/config.js";
3
+ const i = {
4
4
  "amp-accordion": "ampAccordionEnabled",
5
5
  "amp-carousel": "ampCarouselEnabled",
6
6
  "amp-form-controls": "ampFormControlsEnabled",
@@ -14,7 +14,7 @@ const a = {
14
14
  "text-block": "textEnabled",
15
15
  "timer-block": "timerEnabled",
16
16
  "video-block": "videoEnabled"
17
- }, s = {
17
+ }, c = {
18
18
  "dynamic-content": () => import("../extensions/DynamicContent/extension.js"),
19
19
  "checkbox-block": () => import("../extensions/Blocks/Checkbox/extension.js"),
20
20
  "radio-button-block": () => import("../extensions/Blocks/RadioButton/extension.js"),
@@ -22,40 +22,49 @@ const a = {
22
22
  "unsubscribe-block": () => import("../extensions/Blocks/Unsubscribe/extension.js"),
23
23
  "coupon-block": () => import("../extensions/Blocks/CouponBlock/extension.js"),
24
24
  "items-block": () => import("../extensions/Blocks/Items/extension.js")
25
- }, i = (n) => {
25
+ }, b = (n) => {
26
26
  if (!n || !n.length)
27
27
  return {};
28
28
  const t = {};
29
29
  return n.forEach((o) => {
30
- const e = a[o];
30
+ const e = i[o];
31
31
  e && (t[e] = !1);
32
32
  }), t;
33
- }, b = () => [r], m = async (n) => {
34
- const t = b();
33
+ }, m = async ({ externalDisplayConditions: n }) => {
34
+ const t = [l];
35
+ if (n) {
36
+ const o = await import("../extensions/DisplayConditions/extension.js");
37
+ t.push(o.default);
38
+ }
39
+ return t;
40
+ }, d = async (n, t = { externalDisplayConditions: !1 }) => {
41
+ const o = await m(t);
35
42
  if (!n || !n.length)
36
- return t;
37
- const o = await Promise.all(
38
- n.map(async (e) => {
39
- const c = s[e];
40
- return c ? (await c()).default : null;
43
+ return o;
44
+ const e = await Promise.all(
45
+ n.map(async (a) => {
46
+ const s = c[a];
47
+ return s ? (await s()).default : null;
41
48
  })
42
49
  );
43
50
  return [
44
- ...t,
45
- ...o.filter((e) => e !== null)
51
+ ...o,
52
+ ...e.filter((a) => a !== null)
46
53
  ];
47
- }, E = () => {
48
- const n = l();
54
+ }, k = () => {
55
+ const n = r();
49
56
  return {
50
57
  getStripoBlocksConfig: async () => {
51
58
  const o = n.blocks;
52
59
  return {
53
- baseBlocks: i(o == null ? void 0 : o.excludeDefaults),
54
- extensions: await m(o == null ? void 0 : o.includeCustoms)
60
+ baseBlocks: b(o == null ? void 0 : o.excludeDefaults),
61
+ extensions: await d(o == null ? void 0 : o.includeCustoms, {
62
+ externalDisplayConditions: n.externalDisplayConditions
63
+ })
55
64
  };
56
65
  }
57
66
  };
58
67
  };
59
68
  export {
60
- E as useBlocksConfig
69
+ k as useBlocksConfig
61
70
  };
@@ -0,0 +1,116 @@
1
+ import { useToaster as M } from "./useToaster.js";
2
+ import { useTranslations as x } from "./useTranslations.js";
3
+ import { ACADEMY_LINKS as L } from "../enums/academy.js";
4
+ import { DisplayConditionSourceType as y, DISPLAY_CONDITION_LIMITS as s, DisplayConditionEvent as I } from "../enums/display-condition.js";
5
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
6
+ import { useDisplayConditionApi as O } from "../services/displayConditionApi.js";
7
+ import { useConfigStore as q } from "../stores/config.js";
8
+ import { useDisplayConditionStore as P } from "../stores/display-condition.js";
9
+ import { findInvalidCodeFields as Y, nextConditionId as w } from "../utils/displayCondition.js";
10
+ import { escapeHtml as R } from "../utils/htmlEscape.js";
11
+ import { computed as b } from "vue";
12
+ const B = "email-editor.display-conditions", i = B, F = 409, S = (n, m, r) => ({
13
+ id: w(),
14
+ name: n.name.trim(),
15
+ description: n.description.trim(),
16
+ beforeScript: n.codeBefore,
17
+ afterScript: n.codeAfter,
18
+ extraData: JSON.stringify(r === void 0 ? { source: m } : { source: m, savedId: r })
19
+ }), v = (n) => ({
20
+ name: n.name,
21
+ description: n.description,
22
+ codeBefore: n.codeBefore,
23
+ codeAfter: n.codeAfter
24
+ }), ne = () => {
25
+ const n = P(), m = q(), r = O(), o = x(), { showToaster: p } = M(), u = b(
26
+ () => m.isFeatureEnabled("liquidSyntax") ? "liquid" : "pongo"
27
+ ), f = (e) => {
28
+ const t = { condition: e };
29
+ return document.dispatchEvent(new CustomEvent(I.APPLY, { detail: t })), n.close(), t.applied === !0;
30
+ }, D = () => {
31
+ n.view !== "none" && (document.dispatchEvent(new CustomEvent(I.CANCEL)), n.close());
32
+ }, N = (e) => {
33
+ if (e.mode === "select") {
34
+ n.openSelect();
35
+ return;
36
+ }
37
+ n.openCreate(e.mode === "edit" ? e.current : null);
38
+ }, $ = async () => {
39
+ const e = ++n.listRequest;
40
+ n.listStatus = "loading";
41
+ try {
42
+ const t = await r.list(u.value);
43
+ e === n.listRequest && (n.list = t, n.listStatus = "loaded");
44
+ } catch (t) {
45
+ console.warn("Display conditions could not be loaded.", t), e === n.listRequest && (n.listStatus = "error");
46
+ }
47
+ }, h = (e) => {
48
+ const t = {}, d = e.name.trim();
49
+ d ? d.length < s.NAME_MIN ? t.name = o(`${i}.error-name-min`, { min: s.NAME_MIN }) : d.length > s.NAME_MAX && (t.name = o(`${i}.error-name-max`, { max: s.NAME_MAX })) : t.name = o(`${i}.error-name-required`);
50
+ const { DESCRIPTION_MAX: C } = s;
51
+ e.description.trim().length > C && (t.description = o(`${i}.error-description-max`, { max: C }));
52
+ const g = Y(e.codeBefore, e.codeAfter, u.value);
53
+ return ["codeBefore", "codeAfter"].forEach((a) => {
54
+ e[a].trim() ? g.includes(a) ? t[a] = o(`${i}.error-code-invalid`) : e[a].length > s.CODE_MAX && (t[a] = o(`${i}.error-code-max`, { max: s.CODE_MAX })) : t[a] = o(`${i}.error-code-required`);
55
+ }), t;
56
+ }, A = (e, t) => {
57
+ p(e ? { type: l.Success, message: t } : { type: l.Error, message: o("products.something-went-wrong") });
58
+ }, T = (e) => o(
59
+ `${i}.${e}`,
60
+ {
61
+ academyLink: `<a href="${L.EMAIL_DISPLAY_CONDITIONS}" target="_blank" style="color: #0A2ECC; text-decoration: underline;">${o(`${i}.academy`)}</a>`
62
+ }
63
+ ), _ = () => {
64
+ p({ type: l.Error, message: o(`${i}.validation-failed`) });
65
+ }, c = (e) => ({ name: R(e) }), E = (e, t) => {
66
+ e != null && e.authReported || (console.warn(t, e), p({ type: l.Error, message: t }));
67
+ };
68
+ return {
69
+ syntax: u,
70
+ handleOpen: N,
71
+ cancel: D,
72
+ loadList: $,
73
+ validate: h,
74
+ notifyInvalid: _,
75
+ describeWithAcademyLink: T,
76
+ createInline: (e) => {
77
+ A(
78
+ f(S(e, y.INLINE)),
79
+ o(`${i}.created`, c(e.name.trim()))
80
+ );
81
+ },
82
+ createAndSave: async (e) => {
83
+ try {
84
+ const t = await r.create(e, u.value);
85
+ return n.list = [t, ...n.list.filter((d) => d.id !== t.id)], A(
86
+ f(S(v(t), y.SAVED, t.id)),
87
+ o(`${i}.created-and-saved`, c(t.name))
88
+ ), {};
89
+ } catch (t) {
90
+ return (t == null ? void 0 : t.status) === F ? { name: o(`${i}.error-name-exists`) } : (E(t, o(`${i}.save-failed`, c(e.name.trim()))), null);
91
+ }
92
+ },
93
+ select: (e) => {
94
+ A(
95
+ f(S(v(e), y.SAVED, e.id)),
96
+ o(`${i}.applied`, c(e.name))
97
+ );
98
+ },
99
+ deleteSaved: async (e) => {
100
+ try {
101
+ await r.remove(e.id), n.list = n.list.filter((t) => t.id !== e.id), p({
102
+ type: l.Success,
103
+ message: o(`${i}.deleted`, c(e.name))
104
+ });
105
+ } catch (t) {
106
+ E(t, o(`${i}.delete-failed`));
107
+ } finally {
108
+ n.pendingDelete = null;
109
+ }
110
+ }
111
+ };
112
+ };
113
+ export {
114
+ B as DISPLAY_CONDITIONS_TRANS_KEY,
115
+ ne as useDisplayConditions
116
+ };
@@ -1,35 +1,44 @@
1
- import { useConfig as T } from "./useConfig.js";
2
- import { useToaster as g } from "./useToaster.js";
1
+ import { useConfig as f } from "./useConfig.js";
2
+ import { useToaster as d } from "./useToaster.js";
3
3
  import { useTranslations as C } from "./useTranslations.js";
4
- import { ToasterTypeOptions as D } from "../enums/toaster.js";
5
- import { buildDynamicContentLookup as f, convertModuleDynamicContent as h } from "../utils/dynamicContentConverter.js";
6
- import { flattenDynamicContentList as O } from "../utils/genericUtil.js";
4
+ import { ToasterTypeOptions as T } from "../enums/toaster.js";
5
+ import { useEditorStore as h } from "../stores/editor.js";
6
+ import { buildDynamicContentLookup as v, convertModuleDynamicContent as D } from "../utils/dynamicContentConverter.js";
7
+ import { flattenDynamicContentList as L } from "../utils/genericUtil.js";
7
8
  import { repairItemsCurrencyAttributes as M } from "../utils/itemsCurrencyRepair.js";
8
- const N = "dynamic-content.unresolved-attributes-on-drop", d = () => {
9
- const { template: p, isFeatureEnabled: s } = T(), { showToaster: a } = g(), y = C();
10
- return { handleModuleAdd: (e, o) => {
11
- var c, l, i;
9
+ import { convertLegacyUnsubscribeInModuleHtml as O } from "../utils/legacyUnsubscribeConversion.js";
10
+ const E = "dynamic-content.unresolved-attributes-on-drop", S = () => {
11
+ const { template: p, isFeatureEnabled: n } = f(), { showToaster: y } = d(), b = C();
12
+ return { handleModuleAdd: (t, r) => {
13
+ var c, i, l;
12
14
  try {
13
- if ((e == null ? void 0 : e.action) !== "ADD" && (e == null ? void 0 : e.action) !== "COPY")
15
+ if ((t == null ? void 0 : t.action) !== "ADD" && (t == null ? void 0 : t.action) !== "COPY")
14
16
  return;
15
- const t = (c = o == null ? void 0 : o.getTargetNode) == null ? void 0 : c.call(o), r = (l = t == null ? void 0 : t.getOuterHTML) == null ? void 0 : l.call(t);
16
- if (!t || typeof r != "string")
17
+ const e = (c = r == null ? void 0 : r.getTargetNode) == null ? void 0 : c.call(r), s = (i = e == null ? void 0 : e.getOuterHTML) == null ? void 0 : i.call(e);
18
+ if (!e || typeof s != "string")
17
19
  return;
18
- let n = M(r, {
19
- convertToPriceFormat: s("itemsPriceFormatting")
20
+ let o = M(s, {
21
+ convertToPriceFormat: n("itemsPriceFormatting")
22
+ }), u = !1;
23
+ n("legacyUnsubscribeConversion") && ({ html: o, converted: u } = O(o));
24
+ const m = v(L((l = p.value) == null ? void 0 : l.dynamicContentList));
25
+ let a = [];
26
+ if (m.size > 0 && ({ html: o, unresolved: a } = D(o, m, n("liquidSyntax"))), o !== s && r.modifyHtml(e).replaceWith(o), u)
27
+ try {
28
+ h().isLegacyUnsubscribeModalRequested = !0;
29
+ } catch (g) {
30
+ console.error("Failed to request the legacy unsubscribe modal:", g);
31
+ }
32
+ a.length > 0 && y({
33
+ type: T.Warning,
34
+ message: b(E)
20
35
  });
21
- const u = f(O((i = p.value) == null ? void 0 : i.dynamicContentList));
22
- let m = [];
23
- u.size > 0 && ({ html: n, unresolved: m } = h(n, u, s("liquidSyntax"))), n !== r && o.modifyHtml(t).replaceWith(n), m.length > 0 && a({
24
- type: D.Warning,
25
- message: y(N)
26
- });
27
- } catch (t) {
28
- console.error("Failed to repair module on add:", t);
36
+ } catch (e) {
37
+ console.error("Failed to repair module on add:", e);
29
38
  }
30
39
  } };
31
40
  };
32
41
  export {
33
- N as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
34
- d as useModuleRepair
42
+ E as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
43
+ S as useModuleRepair
35
44
  };
@@ -1,91 +1,96 @@
1
- import { useActionsApi as q } from "./useActionsApi.js";
2
- import { useConfig as O } from "./useConfig.js";
3
- import { useEditorLock as D } from "./useEditorLock.js";
4
- import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
5
- import { useSaveValidation as z } from "./useSaveValidation.js";
6
- import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
7
- import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
1
+ import { useActionsApi as O } from "./useActionsApi.js";
2
+ import { useConfig as D } from "./useConfig.js";
3
+ import { useEditorLock as F } from "./useEditorLock.js";
4
+ import { useSaveStart as I, useSaveComplete as N } from "./useGuidoActions.js";
5
+ import { useSaveValidation as j } from "./useSaveValidation.js";
6
+ import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
7
+ import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
8
8
  import { ToasterTypeOptions as J } from "../enums/toaster.js";
9
9
  import { useStripoApi as K } from "../services/stripoApi.js";
10
- import { useConfigStore as N } from "../stores/config.js";
11
- import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
12
- import { useSaveValidationStore as X } from "../stores/save-validation.js";
13
- import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
14
- import { useAllowlist as _ } from "./useAllowlist.js";
15
- import { useHtmlValidator as $ } from "./useHtmlValidator.js";
16
- import { useToaster as tt } from "./useToaster.js";
17
- import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
18
- import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
19
- import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
20
- import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
10
+ import { useConfigStore as Q } from "../stores/config.js";
11
+ import { useDynamicContentStore as X } from "../stores/dynamic-content.js";
12
+ import { useSaveValidationStore as Y } from "../stores/save-validation.js";
13
+ import { useTemplatePreparation as Z, getHtmlReferencedUnsubscribePages as _ } from "../utils/templatePreparation.js";
14
+ import { useAllowlist as $ } from "./useAllowlist.js";
15
+ import { useHtmlValidator as tt } from "./useHtmlValidator.js";
16
+ import { useToaster as et } from "./useToaster.js";
17
+ import { useCouponBlockValidator as ot } from "./validators/useCouponBlockValidator.js";
18
+ import { useHtmlDocumentCountValidator as it } from "./validators/useHtmlDocumentCountValidator.js";
19
+ import { useLiquidValidator as st } from "./validators/useLiquidValidator.js";
20
+ import { useSyncModuleBlockValidator as rt } from "./validators/useSyncModuleBlockValidator.js";
21
21
  import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
22
22
  const Pt = () => {
23
- const n = F(), w = j(), { validateHtml: y } = $(), { validateLiquidSyntax: E } = it(), { validateCouponBlockTags: b } = et(), { validateUnsubscribeBlockUniqueness: g, validateUnsubscribeBlockHasTemplate: H } = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = ot(), { callbacks: r, isFeatureEnabled: v } = O(), { extractSyncModuleData: V } = I(), { setSyncModuleUnsubscriptionPages: x } = K(), { editorSave: C, getTemplateData: u } = q(), { showToaster: k } = tt(), { getBlockedDomains: h, resolveToast: B } = _(), { prepareTemplateDetails: p } = Y(), { collectSaveValidationErrors: T } = z(), { isEnabled: P } = G(), L = X(), U = Q(), S = N(), { runExclusive: m } = D(), d = async (t, e, i) => {
24
- if (!v("allowlistEnabled"))
23
+ const n = I(), S = N(), { validateHtml: y } = tt(), { validateLiquidSyntax: b } = st(), { validateCouponBlockTags: H } = ot(), {
24
+ validateUnsubscribeBlockUniqueness: E,
25
+ validateUnsubscribeBlockHasTemplate: g,
26
+ validateNoInsiderUnsubscribeCode: V
27
+ } = at(), { validateSyncModuleBlocks: l } = rt(), { validateSingleHtmlDocument: c } = it(), { callbacks: a, isFeatureEnabled: u } = D(), { extractSyncModuleData: x } = G(), { setSyncModuleUnsubscriptionPages: k } = K(), { editorSave: C, getTemplateData: m } = O(), { showToaster: h } = et(), { getBlockedDomains: B, resolveToast: T } = $(), { prepareTemplateDetails: p } = Z(), { collectSaveValidationErrors: L } = j(), { isEnabled: P } = z(), U = Y(), A = X(), w = Q(), { runExclusive: d } = F(), f = async (t, e, i) => {
28
+ if (!u("allowlistEnabled"))
25
29
  return !1;
26
- const o = await h(t, e);
30
+ const o = await B(t, e);
27
31
  if (!o.length)
28
32
  return !1;
29
33
  if (!i) {
30
- const s = await B(o);
31
- s != null && s.message && k({
34
+ const s = await T(o);
35
+ s != null && s.message && h({
32
36
  type: J.Warning,
33
37
  message: s.message,
34
38
  actionButton: s.actionButton
35
39
  });
36
40
  }
37
41
  return !0;
38
- }, A = async (t) => !b(t.compiledHtml) || !g(t.compiledHtml) || !H(t.compiledHtml) ? !1 : v("liquidSyntax") ? E(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), f = async (t, e) => {
42
+ }, M = async (t, e) => !H(t.compiledHtml) || u("blockUnsubscribeLinks") && !V(t.rawHtml, e) || !E(t.compiledHtml) || !g(t.compiledHtml) ? !1 : u("liquidSyntax") ? b(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), v = async (t, e) => {
39
43
  if (!await C())
40
44
  return;
41
- const { unsubscribePayload: o, stripoModules: s } = V(t.rawHtml);
42
- if (await x(o), t.modules = s, !e.suppress) {
43
- const a = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
44
- w({ ...t, ...a, silent: e.silent });
45
+ const { unsubscribePayload: o, stripoModules: s } = x(t.rawHtml);
46
+ if (await k(o), t.modules = s, !e.suppress) {
47
+ const r = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
48
+ S({ ...t, ...r, silent: e.silent });
45
49
  }
46
50
  return t;
47
- }, M = async (t, e) => {
51
+ }, W = async (t, e) => {
48
52
  var s;
49
53
  n();
50
- const i = await u();
54
+ const i = await m();
51
55
  if (!c(i.html, e))
52
56
  return;
53
57
  const o = await p(i);
54
58
  if (l(o.rawHtml, e)) {
55
59
  if (P.value && !e) {
56
- const a = await T(
60
+ const r = await L(
57
61
  o.compiledHtml,
58
- o.dynamicContentList
62
+ o.dynamicContentList,
63
+ o.rawHtml
59
64
  );
60
- if (a.length) {
61
- L.open(a, "save");
65
+ if (r.length) {
66
+ U.open(r, "save");
62
67
  return;
63
68
  }
64
- } else if (!await A(o))
69
+ } else if (!await M(o, e))
65
70
  return;
66
- if (!((s = r.value) != null && s.externalValidation && !await r.value.externalValidation(o)) && !await d(o.compiledHtml, o.css, e))
67
- return f(o, { silent: e, suppress: t });
71
+ if (!((s = a.value) != null && s.externalValidation && !await a.value.externalValidation(o)) && !await f(o.compiledHtml, o.css, e))
72
+ return v(o, { silent: e, suppress: t });
68
73
  }
69
- }, W = async () => {
74
+ }, R = async () => {
70
75
  var i;
71
- if (!S.allowSaveWithErrors)
76
+ if (!w.allowSaveWithErrors)
72
77
  return;
73
78
  n();
74
- const t = await u();
79
+ const t = await m();
75
80
  if (!c(t.html, !1))
76
81
  return;
77
82
  const e = await p(t);
78
- if (l(e.rawHtml, !1) && !((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(e)) && !await d(e.compiledHtml, e.css, !1))
79
- return f(e, { silent: !1, blankCompiled: !0 });
80
- }, R = async () => {
81
- if (!S.allowSaveWithErrors)
83
+ if (l(e.rawHtml, !1) && !((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(e)) && !await f(e.compiledHtml, e.css, !1))
84
+ return v(e, { silent: !1, blankCompiled: !0 });
85
+ }, q = async () => {
86
+ if (!w.allowSaveWithErrors)
82
87
  return;
83
88
  n();
84
- const { html: t, css: e } = await u();
85
- if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
89
+ const { html: t, css: e } = await m();
90
+ if (!c(t, !0) || !l(t, !0) || await f(t, e, !0))
86
91
  return;
87
- const i = Z(t), o = {
88
- dynamicContentList: U.getSelectedDynamicContentList,
92
+ const i = _(t), o = {
93
+ dynamicContentList: A.getSelectedDynamicContentList,
89
94
  compiledHtml: "",
90
95
  rawHtml: t,
91
96
  css: e,
@@ -99,11 +104,11 @@ const Pt = () => {
99
104
  config: i
100
105
  }
101
106
  };
102
- return f(o, { silent: !0 });
107
+ return v(o, { silent: !0 });
103
108
  };
104
- return { save: (t = !1, e = !1) => m(
105
- () => M(t, e)
106
- ), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
109
+ return { save: (t = !1, e = !1) => d(
110
+ () => W(t, e)
111
+ ), saveWithErrors: () => d(R), saveRawOnly: () => d(q) };
107
112
  };
108
113
  export {
109
114
  Pt as useSave