@useinsider/guido 1.0.3-beta.a6893cb → 1.0.3-beta.a6a2da8

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 (112) hide show
  1. package/dist/@types/generic.d.ts +9 -0
  2. package/dist/components/Guido.vue.d.ts +2 -2
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +74 -69
  5. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.d.ts +2 -0
  6. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue.js +18 -0
  7. package/dist/components/organisms/unsubscribe/UnsubscribeBreadcrumb.vue2.js +16 -0
  8. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.d.ts +2 -0
  9. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +24 -0
  10. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +64 -0
  11. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.d.ts +2 -0
  12. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +18 -0
  13. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +107 -0
  14. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.d.ts +2 -0
  15. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue.js +18 -0
  16. package/dist/components/organisms/unsubscribe/UnsubscribeWrapper.vue2.js +12 -0
  17. package/dist/components/wrappers/WpDrawer.vue.d.ts +6 -4
  18. package/dist/components/wrappers/WpDrawer.vue.js +6 -4
  19. package/dist/composables/useStripo.js +40 -32
  20. package/dist/config/compiler/unsubscribeCompilerRules.js +42 -29
  21. package/dist/config/migrator/couponBlockMigrator.d.ts +1 -0
  22. package/dist/config/migrator/couponBlockMigrator.js +67 -0
  23. package/dist/config/migrator/index.d.ts +1 -1
  24. package/dist/config/migrator/index.js +7 -5
  25. package/dist/config/migrator/unsubscribeMigrator.d.ts +1 -0
  26. package/dist/config/migrator/unsubscribeMigrator.js +124 -0
  27. package/dist/enums/defaults.js +6 -3
  28. package/dist/enums/unsubscribe.d.ts +19 -0
  29. package/dist/enums/unsubscribe.js +39 -6
  30. package/dist/extensions/Blocks/Checkbox/block.d.ts +1 -0
  31. package/dist/extensions/Blocks/Checkbox/block.js +15 -24
  32. package/dist/extensions/Blocks/Checkbox/control.js +24 -38
  33. package/dist/extensions/Blocks/Checkbox/extension.js +5 -16
  34. package/dist/extensions/Blocks/Checkbox/iconsRegistry.d.ts +4 -0
  35. package/dist/extensions/Blocks/Checkbox/iconsRegistry.js +18 -0
  36. package/dist/extensions/Blocks/Checkbox/settingsPanel.js +12 -25
  37. package/dist/extensions/Blocks/Checkbox/template.js +5 -16
  38. package/dist/extensions/Blocks/CouponBlock/block.d.ts +12 -0
  39. package/dist/extensions/Blocks/CouponBlock/block.js +33 -0
  40. package/dist/extensions/Blocks/CouponBlock/extension.d.ts +2 -0
  41. package/dist/extensions/Blocks/CouponBlock/extension.js +8 -0
  42. package/dist/extensions/Blocks/CouponBlock/iconsRegistry.d.ts +4 -0
  43. package/dist/extensions/Blocks/CouponBlock/iconsRegistry.js +33 -0
  44. package/dist/extensions/Blocks/CouponBlock/settingsPanel.d.ts +4 -0
  45. package/dist/extensions/Blocks/CouponBlock/settingsPanel.js +24 -0
  46. package/dist/extensions/Blocks/CouponBlock/template.d.ts +3 -0
  47. package/dist/extensions/Blocks/CouponBlock/template.js +18 -0
  48. package/dist/extensions/Blocks/RadioButton/block.d.ts +1 -0
  49. package/dist/extensions/Blocks/RadioButton/block.js +13 -22
  50. package/dist/extensions/Blocks/RadioButton/control.js +32 -46
  51. package/dist/extensions/Blocks/RadioButton/extension.js +4 -15
  52. package/dist/extensions/Blocks/RadioButton/iconsRegistry.d.ts +4 -0
  53. package/dist/extensions/Blocks/RadioButton/iconsRegistry.js +14 -0
  54. package/dist/extensions/Blocks/RadioButton/settingsPanel.js +13 -26
  55. package/dist/extensions/Blocks/RadioButton/template.js +7 -18
  56. package/dist/extensions/Blocks/Unsubscribe/block.d.ts +32 -0
  57. package/dist/extensions/Blocks/Unsubscribe/block.js +131 -0
  58. package/dist/extensions/Blocks/Unsubscribe/control.d.ts +29 -0
  59. package/dist/extensions/Blocks/Unsubscribe/control.js +167 -0
  60. package/dist/extensions/Blocks/Unsubscribe/elements/preview.d.ts +11 -0
  61. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +42 -0
  62. package/dist/extensions/Blocks/Unsubscribe/extension.d.ts +2 -0
  63. package/dist/extensions/Blocks/Unsubscribe/extension.js +21 -0
  64. package/dist/extensions/Blocks/Unsubscribe/iconsRegistry.d.ts +4 -0
  65. package/dist/extensions/Blocks/Unsubscribe/iconsRegistry.js +21 -0
  66. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.d.ts +4 -0
  67. package/dist/extensions/Blocks/Unsubscribe/settingsPanel.js +35 -0
  68. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +42 -0
  69. package/dist/extensions/Blocks/Unsubscribe/tagRegistry.d.ts +4 -0
  70. package/dist/extensions/Blocks/Unsubscribe/tagRegistry.js +10 -0
  71. package/dist/extensions/Blocks/Unsubscribe/template.d.ts +12 -0
  72. package/dist/extensions/Blocks/Unsubscribe/template.js +22 -0
  73. package/dist/extensions/Blocks/Unsubscribe/utils/constants.d.ts +9 -0
  74. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +11 -0
  75. package/dist/extensions/Blocks/Unsubscribe/utils/utils.d.ts +7 -0
  76. package/dist/extensions/Blocks/Unsubscribe/utils/utils.js +6 -0
  77. package/dist/extensions/Blocks/_Boilerplate/block.d.ts +1 -0
  78. package/dist/extensions/Blocks/_Boilerplate/iconsRegistry.d.ts +4 -0
  79. package/dist/extensions/DynamicContent/dynamic-content.js +31 -45
  80. package/dist/extensions/DynamicContent/extension.js +6 -18
  81. package/dist/guido.css +1 -1
  82. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +648 -0
  83. package/dist/services/unsubscribeApi.d.ts +4 -0
  84. package/dist/services/unsubscribeApi.js +16 -0
  85. package/dist/stores/config.d.ts +96 -0
  86. package/dist/stores/config.js +17 -0
  87. package/dist/stores/unsubscribe.d.ts +253 -5
  88. package/dist/stores/unsubscribe.js +126 -6
  89. package/dist/utils/templatePreparation.js +17 -16
  90. package/package.json +2 -2
  91. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/Extension.js +0 -75
  92. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ExtensionBuilder.js +0 -77
  93. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js +0 -123
  94. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js +0 -7
  95. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js +0 -7
  96. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js +0 -12
  97. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js +0 -7
  98. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js +0 -119
  99. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js +0 -7
  100. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js +0 -7
  101. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js +0 -7
  102. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js +0 -12
  103. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js +0 -7
  104. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js +0 -7
  105. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js +0 -7
  106. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementsAttributes.js +0 -24
  107. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/Control.js +0 -24
  108. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelRegistry.js +0 -11
  109. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/controls/SettingsPanelTab.js +0 -33
  110. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/modifications/ModificationDescription.js +0 -22
  111. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElement.js +0 -40
  112. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/ui-elements/UIElementTagRegistry.js +0 -5
@@ -1,18 +1,20 @@
1
1
  import { useActionsApi as f } from "./useActionsApi.js";
2
- import { useCustomInterfaceAppearance as S } from "./useCustomInterfaceAppearance.js";
3
- import { useStripoEventHandler as E } from "./useStripoEventHandler.js";
2
+ import { useCustomInterfaceAppearance as E } from "./useCustomInterfaceAppearance.js";
3
+ import { useStripoEventHandler as S } from "./useStripoEventHandler.js";
4
4
  import { useToaster as C } from "./useToaster.js";
5
5
  import { displayConditions as y } from "../enums/displayConditions.js";
6
6
  import h from "../extensions/Blocks/Checkbox/extension.js";
7
- import w from "../extensions/Blocks/RadioButton/extension.js";
8
- import b from "../extensions/DynamicContent/extension.js";
9
- import { useStripoApi as k } from "../services/stripoApi.js";
10
- import B from "../static/styles/customEditorStyle.css.js";
11
- import { useEditorStore as V } from "../stores/editor.js";
12
- import { dynamicContentToMergeTags as _ } from "../utils/genericUtil.js";
13
- const q = (s) => {
14
- const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = k(), { handleEvent: l } = E(), m = (r, i = []) => {
15
- const o = V(), { html: e, css: a, forceRecreate: g } = r;
7
+ import w from "../extensions/Blocks/CouponBlock/extension.js";
8
+ import b from "../extensions/Blocks/RadioButton/extension.js";
9
+ import _ from "../extensions/Blocks/Unsubscribe/extension.js";
10
+ import k from "../extensions/DynamicContent/extension.js";
11
+ import { useStripoApi as B } from "../services/stripoApi.js";
12
+ import V from "../static/styles/customEditorStyle.css.js";
13
+ import { useEditorStore as F } from "../stores/editor.js";
14
+ import { dynamicContentToMergeTags as x } from "../utils/genericUtil.js";
15
+ const N = (s) => {
16
+ const { handleError: d } = C(), { getToken: c, getCustomFonts: u } = B(), { handleEvent: l } = S(), m = (r, i = []) => {
17
+ const t = F(), { html: e, css: a, forceRecreate: g } = r;
16
18
  window.UIEditor.initEditor(
17
19
  document.querySelector("#guido-editor"),
18
20
  {
@@ -29,7 +31,7 @@ const q = (s) => {
29
31
  customAppearanceMergetags: !0,
30
32
  customAppearanceMergetagsBorderColor: "#f1f3fe",
31
33
  customAppearanceMergetagsBackgroundColor: "#f1f3fe",
32
- customViewStyles: B,
34
+ customViewStyles: V,
33
35
  conditionsEnabled: !0,
34
36
  customConditionsEnabled: !0,
35
37
  conditionCategories: y,
@@ -43,49 +45,55 @@ const q = (s) => {
43
45
  },
44
46
  mergeTags: [
45
47
  {
46
- entries: _(s.preselectedDynamicContentList)
48
+ entries: x(s.preselectedDynamicContentList)
47
49
  }
48
50
  ],
49
- async onTokenRefreshRequest(t) {
51
+ async onTokenRefreshRequest(o) {
50
52
  try {
51
53
  const n = await c();
52
- t(n);
54
+ o(n);
53
55
  } catch (n) {
54
56
  d(n, "Failed to refresh token");
55
57
  }
56
58
  },
57
59
  onTemplateLoaded() {
58
60
  try {
59
- const { importCss: t } = S(), { activateCustomViewStyles: n } = f();
60
- t(), n(), s.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
61
- o.hasChanges = !1;
61
+ const { importCss: o } = E(), { activateCustomViewStyles: n } = f();
62
+ o(), n(), s.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
63
+ t.hasChanges = !1;
62
64
  }, 1e3);
63
- } catch (t) {
64
- d(t, "Failed to load custom interface appearance");
65
+ } catch (o) {
66
+ d(o, "Failed to load custom interface appearance");
65
67
  }
66
68
  },
67
- onCodeEditorVisibilityChanged(t) {
68
- o.isCodeEditorOpen = t;
69
+ onCodeEditorVisibilityChanged(o) {
70
+ t.isCodeEditorOpen = o;
69
71
  },
70
- onEditorVisualModeChanged(t) {
71
- o.editorVisualMode = t.toLowerCase();
72
+ onEditorVisualModeChanged(o) {
73
+ t.editorVisualMode = o.toLowerCase();
72
74
  },
73
- onVersionHistoryVisibilityChanged(t) {
74
- o.isVersionHistoryOpen = t;
75
+ onVersionHistoryVisibilityChanged(o) {
76
+ t.isVersionHistoryOpen = o;
75
77
  },
76
78
  onDataChanged() {
77
- o.hasChanges = !0;
79
+ t.hasChanges = !0;
78
80
  },
79
81
  onEvent: l,
80
- ignoreClickOutsideSelectors: ["#guido-dynamic-content-modal", ".in-on-board-wrapper"],
82
+ ignoreClickOutsideSelectors: [
83
+ "#guido-dynamic-content-modal",
84
+ ".in-on-board-wrapper",
85
+ ".in-drawer__container"
86
+ ],
81
87
  extensions: [
82
- b,
88
+ k,
83
89
  h,
90
+ b,
91
+ _,
84
92
  w
85
93
  ]
86
94
  }
87
95
  );
88
- }, p = (r) => new Promise((i, o) => {
96
+ }, p = (r) => new Promise((i, t) => {
89
97
  if (document.getElementById("UiEditorScript")) {
90
98
  r(), i();
91
99
  return;
@@ -95,7 +103,7 @@ const q = (s) => {
95
103
  r(), i();
96
104
  }, e.onerror = () => {
97
105
  const a = new Error("Failed to load Stripo UIEditor script");
98
- o(a);
106
+ t(a);
99
107
  }, document.body.appendChild(e);
100
108
  });
101
109
  return { initPlugin: async (r) => {
@@ -106,5 +114,5 @@ const q = (s) => {
106
114
  } };
107
115
  };
108
116
  export {
109
- q as useStripo
117
+ N as useStripo
110
118
  };
@@ -1,23 +1,36 @@
1
- import { usePartner as m } from "../../composables/usePartner.js";
2
- import { LINK_REGEXES as c, LINK_TYPES as p, URLS as E } from "../../enums/unsubscribe.js";
3
- import { useUnsubscribeStore as b } from "../../stores/unsubscribe.js";
4
- const S = [
1
+ import { usePartner as U } from "../../composables/usePartner.js";
2
+ import { LINK_REGEXES as l, LINK_TYPES as b, URLS as f } from "../../enums/unsubscribe.js";
3
+ import { parsePageList as B } from "../../extensions/Blocks/Unsubscribe/utils/utils.js";
4
+ import { useConfigStore as N } from "../../stores/config.js";
5
+ import { useUnsubscribeStore as I } from "../../stores/unsubscribe.js";
6
+ const T = [
5
7
  {
6
8
  id: "add-unsubscribe-link-values",
7
9
  description: "Adding unsubscribe link values",
8
10
  type: "custom",
9
- processor: (n) => {
10
- var a, u;
11
- const { getPartnerName: i } = m(), t = b();
12
- let e = n;
13
- const o = `/${i()}/email/0?user={{iid}}`, r = (a = t.selectedUnsubscribePages) == null ? void 0 : a.find((l) => l.type === p.UNSUBSCRIBE_LINK_TYPE), s = (u = t.selectedUnsubscribePages) == null ? void 0 : u.find((l) => l.type === p.PREFERENCES_LINK_TYPE);
14
- return r && (e = e.replace(
15
- c.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
16
- E.UNSUBSCRIBE_URL + o
17
- )), s && (e = e.replace(
18
- c.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
19
- E.PREFERENCES_URL + o
20
- )), e.replace(c.UNSUBSCRIBE_LINK_REGEX, "");
11
+ processor: (t) => {
12
+ const { getPartnerName: i } = U(), a = N(), n = I(), u = a.getVariationId;
13
+ if (!u)
14
+ return t;
15
+ let o = t;
16
+ const e = `/${i()}/email/${u}?user={{iid}}`;
17
+ return new DOMParser().parseFromString(o, "text/html").querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-list]").forEach((p) => {
18
+ var g;
19
+ const d = p.getAttribute("data-unsubscribe-page-list");
20
+ if (!d)
21
+ return;
22
+ const S = B(d), m = ((g = n.templates) == null ? void 0 : g.filter(
23
+ (c) => S.includes(c.id)
24
+ )) ?? [], R = m.some((c) => c.type === b.UNSUBSCRIBE_LINK_TYPE), _ = m.some((c) => c.type === b.PREFERENCES_LINK_TYPE), E = p.outerHTML;
25
+ let s = E;
26
+ R && (s = s.replace(
27
+ l.GLOBAL_UNSUBSCRIBE_LINK_REGEX,
28
+ f.UNSUBSCRIBE_URL + e
29
+ )), _ && (s = s.replace(
30
+ l.PREFERENCES_UNSUBSCRIBE_LINK_REGEX,
31
+ f.PREFERENCES_URL + e
32
+ )), s = s.replace(l.UNSUBSCRIBE_LINK_REGEX, ""), o = o.replace(E, s);
33
+ }), o;
21
34
  },
22
35
  priority: 60
23
36
  },
@@ -25,7 +38,7 @@ const S = [
25
38
  id: "remove-data-ogsb-button-styles",
26
39
  description: "Removing styles like [data-ogsb] .es-button.es-button-123 { background: red; }",
27
40
  type: "regex",
28
- pattern: c.DATA_OGSB_BUTTON_CSS_REGEX,
41
+ pattern: l.DATA_OGSB_BUTTON_CSS_REGEX,
29
42
  replacement: "",
30
43
  flags: "g",
31
44
  priority: 61
@@ -34,25 +47,25 @@ const S = [
34
47
  id: "format-comment-braces",
35
48
  description: "Adding spaces around comment braces for proper formatting",
36
49
  type: "custom",
37
- processor: (n) => n.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
50
+ processor: (t) => t.replace(/{#/g, "{ #").replace(/#}/g, "# }"),
38
51
  priority: 62
39
52
  },
40
53
  {
41
54
  id: "add-universal-link-flags",
42
55
  description: "Adding universal link flags",
43
56
  type: "custom",
44
- processor: (n) => {
45
- let i = n;
46
- const t = i.match(/<a[^>]+>(.*?)<\/a>/gm);
47
- return t && t.forEach((e) => {
48
- if (e.includes("insEmail=1"))
57
+ processor: (t) => {
58
+ let i = t;
59
+ const a = i.match(/<a[^>]+>(.*?)<\/a>/gm);
60
+ return a && a.forEach((n) => {
61
+ if (n.includes("insEmail=1"))
49
62
  return;
50
- if (e.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
51
- const o = e.replace(/href=(["'`”])(.*?)\1/gm, (r) => {
52
- const s = r.slice(6, r.length - 1).trim();
53
- return r.includes("?") || r.includes("#") ? s.slice(-1) === "&" ? r.replace(s, `${s}insEmail=1`) : r.replace(s, `${s}&insEmail=1`) : r.replace(s, `${s}?insEmail=1`);
63
+ if (n.match(/<a\s+(?:[^>]*?\s+)?href=(["'`”])(.*?)\1\s+(?:[^>]*?\s+)?universal=(["'`”])true\3/gm)) {
64
+ const o = n.replace(/href=(["'`”])(.*?)\1/gm, (e) => {
65
+ const r = e.slice(6, e.length - 1).trim();
66
+ return e.includes("?") || e.includes("#") ? r.slice(-1) === "&" ? e.replace(r, `${r}insEmail=1`) : e.replace(r, `${r}&insEmail=1`) : e.replace(r, `${r}?insEmail=1`);
54
67
  });
55
- i = i.replace(e, o);
68
+ i = i.replace(n, o);
56
69
  }
57
70
  }), i;
58
71
  },
@@ -60,5 +73,5 @@ const S = [
60
73
  }
61
74
  ];
62
75
  export {
63
- S as unsubscribeCompilerRules
76
+ T as unsubscribeCompilerRules
64
77
  };
@@ -0,0 +1 @@
1
+ export declare function migrateCouponBlock(html: string): string;
@@ -0,0 +1,67 @@
1
+ var k = Object.defineProperty;
2
+ var m = (o, t, e) => t in o ? k(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var x = (o, t, e) => m(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import h from "../../extensions/Blocks/CouponBlock/template.js";
5
+ class y {
6
+ constructor() {
7
+ x(this, "parser");
8
+ this.parser = new DOMParser();
9
+ }
10
+ migrate(t) {
11
+ try {
12
+ const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.coupon-block.ins-coupon-code:not([esd-extension-block-id])");
13
+ return n.length === 0 ? t : (n.forEach((s) => {
14
+ const i = this.extractText(s), c = this.extractAttributes(s), l = h.replace("{@COUPON_CODE}", i).replace(
15
+ 'class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block"',
16
+ c.class
17
+ ).replace(
18
+ 'esd-extension-block-id="coupon-block"',
19
+ `esd-extension-block-id="coupon-block"${c.block}`
20
+ ).replace(
21
+ '<p class="ins-title"',
22
+ `<p class="ins-title"${c.text}`
23
+ );
24
+ s.outerHTML = l;
25
+ }), e.documentElement.outerHTML);
26
+ } catch (e) {
27
+ return console.error("CouponBlockMigrator failed:", e), t;
28
+ }
29
+ }
30
+ extractText(t) {
31
+ var g;
32
+ const e = t.querySelector(".ins-title");
33
+ if (!e)
34
+ return "{@COUPON_CODE}";
35
+ const n = ((g = e.textContent) == null ? void 0 : g.trim()) || "{@COUPON_CODE}", s = e.getAttribute("style") || "", i = /font-weight\s*:\s*bold/i.test(s), c = /font-style\s*:\s*italic/i.test(s), l = /text-decoration[^;]*underline/i.test(s), u = /text-decoration[^;]*line-through/i.test(s), a = /vertical-align\s*:\s*sub/i.test(s), p = /vertical-align\s*:\s*super/i.test(s);
36
+ return [
37
+ [i, "strong"],
38
+ [c, "em"],
39
+ [l, "u"],
40
+ [u, "s"],
41
+ [a, "sub"],
42
+ [p, "sup"]
43
+ ].reduce((b, [f, d]) => f ? `<${d}>${b}</${d}>` : b, n);
44
+ }
45
+ extractAttributes(t) {
46
+ const e = t.querySelector(".ins-title"), n = t.className.split(" ").filter((r) => r.startsWith("es-")), s = t.getAttribute("align"), i = t.getAttribute("bgcolor"), c = t.getAttribute("style"), l = e == null ? void 0 : e.getAttribute("style");
47
+ let u = 'class="coupon-block coupon-block-v2 ins-coupon-code esd-block-text esd-extension-block';
48
+ n.length && (u += ` ${n.join(" ")}`), u += '"';
49
+ let a = "";
50
+ if (s && (a += ` align="${s}"`), i && (a += ` bgcolor="${i}"`), c) {
51
+ const r = c.replace(/background-color[^;]+;?/gi, "").replace(/;+/g, ";").trim();
52
+ r && (a += ` style="${r.replace(/"/g, "'")}"`);
53
+ }
54
+ let p = "";
55
+ if (l) {
56
+ const r = l.replace(/&quot;/g, '"').replace(/font-weight\s*:\s*[^;]+;?/gi, "").replace(/font-style\s*:\s*[^;]+;?/gi, "").replace(/text-decoration\s*:\s*[^;]+;?/gi, "").replace(/vertical-align\s*:\s*[^;]+;?/gi, "").replace(/;+/g, ";").replace(/^;|;$/g, "").trim().replace(/"/g, "'");
57
+ r && (p = ` style="${r}"`);
58
+ }
59
+ return { class: u, block: a, text: p };
60
+ }
61
+ }
62
+ function C(o) {
63
+ return new y().migrate(o);
64
+ }
65
+ export {
66
+ C as migrateCouponBlock
67
+ };
@@ -1 +1 @@
1
- export declare const migrate: (html: string) => string;
1
+ export declare const migrate: (html: string) => Promise<string>;
@@ -1,9 +1,11 @@
1
1
  import { migrateCheckbox as o } from "./checkboxMigrator.js";
2
- import { migrateRadioButton as e } from "./radioButtonMigrator.js";
3
- const a = (r) => {
4
- let t = r;
5
- return t = o(r), t = e(r), t;
2
+ import { migrateCouponBlock as m } from "./couponBlockMigrator.js";
3
+ import { migrateRadioButton as i } from "./radioButtonMigrator.js";
4
+ import { migrateUnsubscribe as e } from "./unsubscribeMigrator.js";
5
+ const c = async (t) => {
6
+ let r = t;
7
+ return r = o(r), r = i(r), r = await e(r), r = m(r), r;
6
8
  };
7
9
  export {
8
- a as migrate
10
+ c as migrate
9
11
  };
@@ -0,0 +1 @@
1
+ export declare function migrateUnsubscribe(html: string): Promise<string>;
@@ -0,0 +1,124 @@
1
+ var h = Object.defineProperty;
2
+ var x = (l, e, t) => e in l ? h(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var S = (l, e, t) => x(l, typeof e != "symbol" ? e + "" : e, t);
4
+ import { MERGE_TAGS as k, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
5
+ import { DATA_ATTRIBUTES as A } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { useUnsubscribeStore as T } from "../../stores/unsubscribe.js";
7
+ class C {
8
+ constructor() {
9
+ S(this, "parser");
10
+ this.parser = new DOMParser();
11
+ }
12
+ async migrate(e) {
13
+ try {
14
+ const t = this.parser.parseFromString(e, "text/html"), i = t.querySelectorAll("td.unsubscribe-block");
15
+ if (!i.length)
16
+ return e;
17
+ const o = T();
18
+ return await o.fetchTemplates(), i.forEach((r) => {
19
+ const c = r.getAttribute("id"), g = this.extractPaddingClass(r), u = r.getAttribute("bgcolor") || "", n = this.extractUnsubscribeContent(r), s = this.getCollectionTypeFromMergeTag(n.linkHref), b = o.getSelectedUnsubscribePagesByCollection(s);
20
+ console.debug("[UnsubscribeMigrator]", {
21
+ mergeTag: n.linkHref,
22
+ collectionType: s,
23
+ pageIds: b,
24
+ paddingClass: g,
25
+ bgColor: u
26
+ });
27
+ const f = this.buildUnsubscribeBlock(
28
+ n,
29
+ s,
30
+ b,
31
+ g,
32
+ u
33
+ ), a = this.parser.parseFromString(
34
+ `<table id="tempDoc"><tbody><tr>${f}</tr></tbody></table>`,
35
+ "text/html"
36
+ ).querySelector(".unsubscribe-block-v2");
37
+ a && r.parentNode && (a.setAttribute("id", c || ""), r.parentNode.replaceChild(a, r));
38
+ }), t.documentElement.outerHTML;
39
+ } catch (t) {
40
+ return console.error("UnsubscribeMigrator failed:", t), e;
41
+ }
42
+ }
43
+ extractPaddingClass(e) {
44
+ const i = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
45
+ return i ? i[0] : "";
46
+ }
47
+ extractUnsubscribeContent(e) {
48
+ var m;
49
+ const t = e.querySelector("p");
50
+ if (!t)
51
+ return {
52
+ textBefore: "You can ",
53
+ linkText: "unsubscribe",
54
+ linkHref: "{{ins-unsubscribe-link}}",
55
+ linkStyle: "",
56
+ textAfter: " from our emails, if you need to.",
57
+ isBold: !1,
58
+ isItalic: !1,
59
+ align: "center",
60
+ paragraphStyle: ""
61
+ };
62
+ const i = e.getAttribute("align") || t.getAttribute("align") || "center", o = t.getAttribute("style") || "", r = t.querySelector("a.unsubscribe-link") || t.querySelector('a[href*="unsubscribe"]');
63
+ if (!r)
64
+ return {
65
+ textBefore: "You can ",
66
+ linkText: "unsubscribe",
67
+ linkHref: "{{ins-unsubscribe-link}}",
68
+ linkStyle: "",
69
+ textAfter: " from our emails, if you need to.",
70
+ isBold: !1,
71
+ isItalic: !1,
72
+ align: i,
73
+ paragraphStyle: o
74
+ };
75
+ const c = ((m = r.textContent) == null ? void 0 : m.trim()) || "unsubscribe", g = r.getAttribute("href") || "{{ins-unsubscribe-link}}", u = r.getAttribute("style") || "", n = t.textContent || "", s = n.indexOf(c), b = s >= 0 ? n.substring(0, s).trim() : "You can ", f = s >= 0 ? n.substring(s + c.length).trim() : " from our emails, if you need to.", d = !!t.querySelector("b, strong"), a = !!t.querySelector("i, em");
76
+ return {
77
+ textBefore: b,
78
+ linkText: c,
79
+ linkHref: this.normalizeUnsubscribeHref(g),
80
+ linkStyle: u,
81
+ textAfter: f,
82
+ isBold: d,
83
+ isItalic: a,
84
+ align: i,
85
+ paragraphStyle: o
86
+ };
87
+ }
88
+ buildUnsubscribeBlock(e, t, i, o, r) {
89
+ const c = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${c}>${e.linkText}</a>`, n = [];
90
+ e.textBefore && n.push(e.textBefore), n.push(u), e.textAfter && n.push(e.textAfter);
91
+ let s = n.join(" ");
92
+ e.isBold && e.isItalic ? s = `<strong path="1,0"><em path="1,0,0">${s}</em></strong>` : e.isBold ? s = `<strong path="1,0">${s}</strong>` : e.isItalic && (s = `<em path="1,0">${s}</em>`);
93
+ const b = e.align ? ` align="${e.align}"` : "", f = r ? ` bgcolor="${r}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", a = i.length > 0 ? ` ${A.PAGE_LIST}="${i.join(",")}"` : "", m = ` ${A.PAGE_TYPE}="${t}"`, y = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
94
+ return `
95
+ <td
96
+ data-migration="true"
97
+ esd-extension-block-id="unsubscribe-block"
98
+ class="${o ? `${y} ${o}` : y}"
99
+ ${b}${f}${m}${a}
100
+ >
101
+ <p path="1"${d}>
102
+ ${s}
103
+ </p>
104
+ </td>
105
+ `;
106
+ }
107
+ getCollectionTypeFromMergeTag(e) {
108
+ return e === k[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === k[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
109
+ }
110
+ normalizeUnsubscribeHref(e) {
111
+ if (Object.values(k).includes(e))
112
+ return e;
113
+ const i = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
114
+ return i ? i[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
115
+ `[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
116
+ ), "{{ins-unsubscribe-link}}") : e;
117
+ }
118
+ }
119
+ async function M(l) {
120
+ return new C().migrate(l);
121
+ }
122
+ export {
123
+ M as migrateUnsubscribe
124
+ };
@@ -4,6 +4,9 @@ const a = {
4
4
  senderName: "",
5
5
  subject: ""
6
6
  },
7
+ extensions: {
8
+ unsubscribe: !0
9
+ },
7
10
  features: {
8
11
  dynamicContent: !0,
9
12
  saveAsTemplate: !0,
@@ -13,7 +16,7 @@ const a = {
13
16
  }, t = {
14
17
  promotional: 1,
15
18
  transactional: 2
16
- }, e = "email", o = "Guido User", n = t.promotional, i = 2, s = {
19
+ }, e = "email", o = "Guido User", n = t.promotional, s = 2, i = {
17
20
  email: 60,
18
21
  architect: 49
19
22
  }, u = [
@@ -53,8 +56,8 @@ export {
53
56
  n as DefaultMessageType,
54
57
  e as DefaultProductType,
55
58
  o as DefaultUsername,
56
- i as EditorType,
57
- s as ProductIds,
59
+ s as EditorType,
60
+ i as ProductIds,
58
61
  u as TEST_PARTNER_LIST,
59
62
  t as TemplateTypes
60
63
  };
@@ -13,3 +13,22 @@ export declare const URLS: {
13
13
  PREFERENCES_URL: string;
14
14
  };
15
15
  export declare const INSIDER_ID = "iid";
16
+ export declare const ACADEMY_LINK = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center";
17
+ export declare const UNSUBSCRIBE_PAGES_LINK = "/email/unsubscribe-pages";
18
+ export declare const PAGE_TYPES: {
19
+ GLOBAL_UNSUBSCRIBE: number;
20
+ GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: number;
21
+ SUBSCRIPTION_PREFERENCE_CENTER: number;
22
+ SUBSCRIPTION_PREFERENCE_CONFIRMATION: number;
23
+ RESUBSCRIBE: number;
24
+ };
25
+ export declare const TYPE_COLLECTIONS: {
26
+ [x: number]: number[];
27
+ };
28
+ export declare const TYPE_TRANSLATIONS: {
29
+ [x: number]: string;
30
+ };
31
+ export declare const MERGE_TAGS: {
32
+ [x: number]: string;
33
+ default: string;
34
+ };
@@ -1,17 +1,50 @@
1
- const E = {
1
+ import { useTranslations as e } from "../composables/useTranslations.js";
2
+ const s = e(), n = {
2
3
  UNSUBSCRIBE_LINK_TYPE: 1,
3
4
  PREFERENCES_LINK_TYPE: 3
4
- }, s = {
5
+ }, S = {
5
6
  UNSUBSCRIBE_LINK_REGEX: /{{ins-unsubscribe-link}}/g,
6
7
  DATA_OGSB_BUTTON_CSS_REGEX: "\\[data-ogsb\\]\\s*\\.es-button\\.es-button-[0-9]+\\s*\\{(?:[^\\}]*)\\}",
7
8
  GLOBAL_UNSUBSCRIBE_LINK_REGEX: /{{ins-global-unsubscribe-link}}/g,
8
9
  PREFERENCES_UNSUBSCRIBE_LINK_REGEX: /{{ins-preferences-unsubscribe-link}}/g
9
- }, _ = {
10
+ }, N = {
10
11
  UNSUBSCRIBE_URL: "https://mail.useinsider.com/user/v1/unsub",
11
12
  PREFERENCES_URL: "https://mail.useinsider.com/user/v1/prefs"
13
+ }, _ = "https://academy.useinsider.com/docs/global-unsubscribe-preference-center", I = "/email/unsubscribe-pages", E = {
14
+ GLOBAL_UNSUBSCRIBE: 1,
15
+ GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE: 2,
16
+ SUBSCRIPTION_PREFERENCE_CENTER: 3,
17
+ SUBSCRIPTION_PREFERENCE_CONFIRMATION: 4,
18
+ RESUBSCRIBE: 5
19
+ }, r = {
20
+ [E.GLOBAL_UNSUBSCRIBE]: [
21
+ E.GLOBAL_UNSUBSCRIBE,
22
+ E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE,
23
+ E.RESUBSCRIBE
24
+ ],
25
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: [
26
+ E.SUBSCRIPTION_PREFERENCE_CENTER,
27
+ E.SUBSCRIPTION_PREFERENCE_CONFIRMATION
28
+ ]
29
+ }, i = {
30
+ [E.GLOBAL_UNSUBSCRIBE]: s("unsubscription-preference.type-global-unsubscribe"),
31
+ [E.GLOBAL_UNSUBSCRIBE_CONFIRMATION_PAGE]: s("unsubscription-preference.type-global-unsubscription-confirmation"),
32
+ [E.RESUBSCRIBE]: s("unsubscription-preference.type-resubscribe"),
33
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: s("unsubscription-preference.type-subscription-preferences-center"),
34
+ [E.SUBSCRIPTION_PREFERENCE_CONFIRMATION]: s("unsubscription-preference.type-subscription-preferences-confirmation")
35
+ }, B = {
36
+ default: "{{ins-unsubscribe-link}}",
37
+ [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
38
+ [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
12
39
  };
13
40
  export {
14
- s as LINK_REGEXES,
15
- E as LINK_TYPES,
16
- _ as URLS
41
+ _ as ACADEMY_LINK,
42
+ S as LINK_REGEXES,
43
+ n as LINK_TYPES,
44
+ B as MERGE_TAGS,
45
+ E as PAGE_TYPES,
46
+ r as TYPE_COLLECTIONS,
47
+ i as TYPE_TRANSLATIONS,
48
+ I as UNSUBSCRIBE_PAGES_LINK,
49
+ N as URLS
17
50
  };
@@ -1,6 +1,7 @@
1
1
  import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
2
2
  export declare const CHECKBOX_BLOCK_ID = "checkbox-block";
3
3
  export declare class CheckboxBlock extends Block {
4
+ constructor();
4
5
  getId(): string;
5
6
  getIcon(): string;
6
7
  getBlockCompositionType(): BlockCompositionType;
@@ -1,39 +1,30 @@
1
- import { Block as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/blocks/Block.js";
2
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/AiAssistantValueType.js";
3
- import { BlockCompositionType as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockCompositionType.js";
4
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockName.js";
5
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BlockType.js";
6
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/BuiltInControlTypes.js";
7
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/ContextActionType.js";
8
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/EditorStatePropertyType.js";
9
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PanelPosition.js";
10
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/Popover.js";
11
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/PreviewDeviceMode.js";
12
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/SettingsTab.js";
13
- import "../../../node_modules/@stripoinc/ui-editor-extensions/dist/constants/UIElementType.js";
14
- import { getDefaultTemplate as r } from "./template.js";
15
- const e = "checkbox-block";
16
- class x extends t {
1
+ import { Block as e, BlockCompositionType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { getDefaultTemplate as o } from "./template.js";
3
+ const r = "checkbox-block";
4
+ class p extends e {
5
+ constructor() {
6
+ super();
7
+ }
17
8
  getId() {
18
- return e;
9
+ return r;
19
10
  }
20
11
  getIcon() {
21
- return "check-circle";
12
+ return "checkbox-icon";
22
13
  }
23
14
  getBlockCompositionType() {
24
- return o.BLOCK;
15
+ return t.CONTAINER;
25
16
  }
26
17
  getName() {
27
- return this.api.translate("Checkbox block");
18
+ return this.api.translate("Checkbox Block");
28
19
  }
29
20
  getDescription() {
30
- return this.api.translate("Checkbox block description");
21
+ return this.api.translate("Checkbox Block Description");
31
22
  }
32
23
  getTemplate() {
33
- return r();
24
+ return o();
34
25
  }
35
26
  }
36
27
  export {
37
- e as CHECKBOX_BLOCK_ID,
38
- x as CheckboxBlock
28
+ r as CHECKBOX_BLOCK_ID,
29
+ p as CheckboxBlock
39
30
  };