@gatewaze/admin-embed 0.1.0

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 (96) hide show
  1. package/README.md +42 -0
  2. package/dist/AiSkillsPicker-dbFhcanE.js +373 -0
  3. package/dist/ContentAccessPage-D0HRqPFc.js +264 -0
  4. package/dist/DataTable-fe6yRVpF.js +1984 -0
  5. package/dist/DetailPageHeader-D_v7924k.js +69 -0
  6. package/dist/EditionEmail-CyhC8232.js +8382 -0
  7. package/dist/GuideContent-DBXKCu7r.js +7580 -0
  8. package/dist/HostMediaTab-BsIBEQ1v.js +440 -0
  9. package/dist/InboxPage-C8ivCKdx.js +1112 -0
  10. package/dist/NewsletterCanvasEditor--B06apn3.js +11453 -0
  11. package/dist/NewsletterSetupWizard-BqV6-fa5.js +347 -0
  12. package/dist/NewsletterSignup-DRVZIpOs.js +224 -0
  13. package/dist/Page-D3u8IZ2a.js +14 -0
  14. package/dist/Toaster-Cde0i6IA.js +18 -0
  15. package/dist/Tooltip-CqxUlW1d.js +746 -0
  16. package/dist/_collectionSlug_-B3UN6M-Q.js +308 -0
  17. package/dist/_collection_-Qz4k_Qjl.js +139 -0
  18. package/dist/_edition_-DQXwkI_-.js +301 -0
  19. package/dist/_id_-CtT7rT9f.js +257 -0
  20. package/dist/_id_-CzScE4Qn.js +1197 -0
  21. package/dist/_virtual_gatewaze-modules-BeloWlOa.js +991 -0
  22. package/dist/admin-B0Mmrh_O.js +1239 -0
  23. package/dist/admin-CcfoK6vD.js +17 -0
  24. package/dist/admin-embed.js +21844 -0
  25. package/dist/admin.css +2 -0
  26. package/dist/block-editor-vXBShAue.js +226 -0
  27. package/dist/brand-DklYwIeA.js +11 -0
  28. package/dist/brick-editor-CmBitMMK.js +225 -0
  29. package/dist/broadcastService-CBqXNt_N.js +190 -0
  30. package/dist/classnames-uWIYaD6z.js +44 -0
  31. package/dist/contentAccessService-Cs7tdAo-.js +59 -0
  32. package/dist/context-jzuubYRz.js +5 -0
  33. package/dist/createSafeContext-P1pK0sAN.js +17 -0
  34. package/dist/detail-B8SVFJJr.js +26285 -0
  35. package/dist/detail-uFBxRbLF.js +2966 -0
  36. package/dist/dist-DTrOExw8.js +38806 -0
  37. package/dist/edition-slug-CARO24Bs.js +7 -0
  38. package/dist/export-edition-html-C_hdXQu5.js +18893 -0
  39. package/dist/floating-ui.dom-Cyv879E9.js +987 -0
  40. package/dist/hooks-C377EXJG.js +2974 -0
  41. package/dist/img/mlops-logo.png +0 -0
  42. package/dist/img/mlops-logo2.png +0 -0
  43. package/dist/index.d.ts +105 -0
  44. package/dist/jsx-runtime-CjozyJt-.js +180 -0
  45. package/dist/lib-CylJmhlJ.js +828 -0
  46. package/dist/list-C0cz0aQz.js +451 -0
  47. package/dist/list-CIVgIGsU.js +166 -0
  48. package/dist/logo/mlops-alt.png +0 -0
  49. package/dist/logo/mlops-logo.png +0 -0
  50. package/dist/new-r4KWpqa6.js +80 -0
  51. package/dist/outline-DwDYhYcF.js +6538 -0
  52. package/dist/pages-Ersfxcz7.js +216 -0
  53. package/dist/preview/12627f.jpg +0 -0
  54. package/dist/preview/af009d.jpg +0 -0
  55. package/dist/public-api-LD11kMxh.js +238 -0
  56. package/dist/react-DB2tPNit.js +933 -0
  57. package/dist/react-dom-giQNVXng.js +267 -0
  58. package/dist/registry-4XrV9iNG.js +7 -0
  59. package/dist/render-BtUWfMUt.js +59634 -0
  60. package/dist/resolvePeopleByEmail-hivX2l07.js +828 -0
  61. package/dist/runtime-config.js +10 -0
  62. package/dist/sends-BkPO6PG2.js +182 -0
  63. package/dist/server.browser-Pj3QUa7k.js +15227 -0
  64. package/dist/shim-BCerG8nb.js +6681 -0
  65. package/dist/sonnerHostBridge-CXuCMM3R.js +665 -0
  66. package/dist/src-BWDAOzZO.js +799 -0
  67. package/dist/starter-templates-CFs-QUdF.js +3077 -0
  68. package/dist/storage-VDSvnkvR.js +39 -0
  69. package/dist/templateParser-BQ2IsJ6c.js +49 -0
  70. package/dist/templates-rjQjWsRr.js +253 -0
  71. package/dist/theme/gatewaze/android-icon-144x144.png +0 -0
  72. package/dist/theme/gatewaze/android-icon-192x192.png +0 -0
  73. package/dist/theme/gatewaze/android-icon-36x36.png +0 -0
  74. package/dist/theme/gatewaze/android-icon-48x48.png +0 -0
  75. package/dist/theme/gatewaze/android-icon-72x72.png +0 -0
  76. package/dist/theme/gatewaze/android-icon-96x96.png +0 -0
  77. package/dist/theme/gatewaze/favicon-144x144.png +0 -0
  78. package/dist/theme/gatewaze/favicon-16x16.png +0 -0
  79. package/dist/theme/gatewaze/favicon-192x192.png +0 -0
  80. package/dist/theme/gatewaze/favicon-32x32.png +0 -0
  81. package/dist/theme/gatewaze/favicon-96x96.png +0 -0
  82. package/dist/theme/gatewaze/favicon.ico +0 -0
  83. package/dist/theme/gatewaze/gatewaze-icon-512.png +0 -0
  84. package/dist/theme/gatewaze/gatewaze-logo-black.svg +24 -0
  85. package/dist/theme/gatewaze/gatewaze-logo-white.svg +20 -0
  86. package/dist/theme/gatewaze/gatewaze-poweredby-black.svg +25 -0
  87. package/dist/theme/gatewaze/gatewaze-poweredby-white.svg +25 -0
  88. package/dist/theme/gatewaze/logo_black.svg +24 -0
  89. package/dist/theme/gatewaze/logo_white.svg +20 -0
  90. package/dist/theme-D6odw5nx.js +586 -0
  91. package/dist/ui-DRIo9Krs.js +9747 -0
  92. package/dist/upload-DMNfZ6FX.js +505 -0
  93. package/dist/useModuleFeature-DgsFIUpv.js +8 -0
  94. package/dist/utils-BcVvIjaY.js +36 -0
  95. package/dist/with-selector-B8eSdVx_.js +100 -0
  96. package/package.json +33 -0
@@ -0,0 +1,347 @@
1
+ import { c as e, t } from "./react-DB2tPNit.js";
2
+ import { d as n } from "./shim-BCerG8nb.js";
3
+ import { t as r } from "./jsx-runtime-CjozyJt-.js";
4
+ import { D as i, E as a, a as o } from "./ui-DRIo9Krs.js";
5
+ import { a as s } from "./hooks-C377EXJG.js";
6
+ import { n as c } from "./sonnerHostBridge-CXuCMM3R.js";
7
+ import { t as l } from "./outline-DwDYhYcF.js";
8
+ //#region ../../../gatewaze-modules/modules/newsletters/admin/components/NewsletterSetupWizard.tsx
9
+ var u = /* @__PURE__ */ e(t()), d = l(), f = r();
10
+ function p(e) {
11
+ return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
12
+ }
13
+ var m = [
14
+ {
15
+ id: "basics",
16
+ label: "Basics",
17
+ icon: d.PaintBrushIcon
18
+ },
19
+ {
20
+ id: "sender",
21
+ label: "Sender",
22
+ icon: d.EnvelopeIcon
23
+ },
24
+ {
25
+ id: "list",
26
+ label: "List",
27
+ icon: d.QueueListIcon
28
+ }
29
+ ], h = [
30
+ "#00a2c7",
31
+ "#0e7490",
32
+ "#059669",
33
+ "#7c3aed",
34
+ "#dc2626",
35
+ "#ea580c",
36
+ "#d97706",
37
+ "#2563eb",
38
+ "#4f46e5",
39
+ "#be185d"
40
+ ];
41
+ function g({ isOpen: e = !0, onClose: t } = {}) {
42
+ let r = s(), [l, g] = (0, u.useState)(0), [_, v] = (0, u.useState)(!1), [y, b] = (0, u.useState)([]), [x, S] = (0, u.useState)([]), [C, w] = (0, u.useState)({
43
+ name: "",
44
+ slug: "",
45
+ description: "",
46
+ content_category: "",
47
+ accent_color: "#00a2c7",
48
+ from_name: "",
49
+ from_email: "",
50
+ reply_to: "",
51
+ list_id: ""
52
+ });
53
+ (0, u.useEffect)(() => {
54
+ n.from("lists").select("id, name, slug").eq("is_active", !0).order("name").then(({ data: e }) => b(e || [])).catch(() => {}), n.from("platform_settings").select("value").eq("key", "content_categories").maybeSingle().then(({ data: e }) => {
55
+ if (e?.value) try {
56
+ S(JSON.parse(e.value));
57
+ } catch {}
58
+ });
59
+ }, []);
60
+ let T = (e, t) => {
61
+ w((n) => ({
62
+ ...n,
63
+ [e]: t,
64
+ ...e === "name" && !n.slug ? { slug: p(t) } : {}
65
+ }));
66
+ }, E = () => {
67
+ switch (l) {
68
+ case 0: return C.name.trim().length > 0;
69
+ case 1: return C.from_name.trim().length > 0 && C.from_email.trim().length > 0;
70
+ case 2: return !0;
71
+ default: return !1;
72
+ }
73
+ }, D = async () => {
74
+ v(!0);
75
+ try {
76
+ let { data: e, error: t } = await n.from("newsletters_template_collections").insert({
77
+ name: C.name,
78
+ slug: C.slug || p(C.name),
79
+ description: C.description || null,
80
+ content_category: C.content_category || null,
81
+ accent_color: C.accent_color,
82
+ from_name: C.from_name,
83
+ from_email: C.from_email,
84
+ reply_to: C.reply_to || null,
85
+ list_id: C.list_id || null,
86
+ setup_complete: !0
87
+ }).select().single();
88
+ if (t) throw t;
89
+ let { error: i } = await n.from("templates_libraries").insert({
90
+ id: e.id,
91
+ host_kind: "newsletter",
92
+ host_id: e.id,
93
+ name: C.name,
94
+ description: C.description || null,
95
+ theme_kind: "email"
96
+ });
97
+ if (i) throw console.error("[newsletter-setup] templates_libraries insert failed:", i), Error(`Failed to provision template library for newsletter: ${i.message}`);
98
+ for (let t of [
99
+ "header",
100
+ "content_section",
101
+ "ai_section",
102
+ "footer"
103
+ ]) await n.from("templates_block_defs").insert({
104
+ library_id: e.id,
105
+ key: t,
106
+ name: t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()),
107
+ description: null,
108
+ source_kind: "static",
109
+ html: "",
110
+ rich_text_template: "",
111
+ has_bricks: !1,
112
+ schema: {},
113
+ version: 1,
114
+ is_current: !0,
115
+ render_kind: "react-email",
116
+ component_id: t
117
+ });
118
+ try {
119
+ let { data: t } = await n.auth.getSession(), r = t.session?.access_token, i = globalThis.__GATEWAZE_CONFIG__.VITE_API_URL ?? "", a = await fetch(`${i}/api/admin/newsletters/collections/${e.id}/init-repo`, {
120
+ method: "POST",
121
+ credentials: "include",
122
+ headers: {
123
+ "Content-Type": "application/json",
124
+ ...r ? { Authorization: `Bearer ${r}` } : {}
125
+ }
126
+ });
127
+ if (a.ok) {
128
+ let e = await a.json().catch(() => null);
129
+ e?.kind === "initialised" ? c.success("Boilerplate cloned to internal git repo") : e?.kind === "failed" && c.warning(`Boilerplate clone deferred: ${e.message ?? "unknown"}`);
130
+ }
131
+ } catch (e) {
132
+ console.warn("[wizard] init-repo failed:", e);
133
+ }
134
+ c.success(`Newsletter "${C.name}" created!`), r(`/newsletters/${e.slug}`);
135
+ } catch (e) {
136
+ c.error(e.message || "Failed to create newsletter");
137
+ } finally {
138
+ v(!1);
139
+ }
140
+ }, O = "w-full px-3 py-2 text-sm border border-[var(--gray-a6)] rounded-md bg-[var(--color-surface)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-8)]", k = () => {
141
+ t ? t() : r("/newsletters");
142
+ };
143
+ return /* @__PURE__ */ (0, f.jsx)(o, {
144
+ isOpen: e,
145
+ onClose: k,
146
+ title: "Create Newsletter",
147
+ size: "xl",
148
+ footer: /* @__PURE__ */ (0, f.jsxs)("div", {
149
+ className: "flex items-center justify-between w-full",
150
+ children: [/* @__PURE__ */ (0, f.jsx)(i, {
151
+ variant: "outline",
152
+ onClick: () => l > 0 ? g(l - 1) : k(),
153
+ disabled: _,
154
+ children: l === 0 ? "Cancel" : "Back"
155
+ }), /* @__PURE__ */ (0, f.jsxs)("div", {
156
+ className: "flex items-center gap-2",
157
+ children: [/* @__PURE__ */ (0, f.jsxs)("span", {
158
+ className: "text-sm text-[var(--gray-9)]",
159
+ children: [
160
+ "Step ",
161
+ l + 1,
162
+ " of ",
163
+ m.length
164
+ ]
165
+ }), l < m.length - 1 ? /* @__PURE__ */ (0, f.jsx)(i, {
166
+ variant: "solid",
167
+ onClick: () => g(l + 1),
168
+ disabled: !E(),
169
+ children: "Next"
170
+ }) : /* @__PURE__ */ (0, f.jsx)(i, {
171
+ variant: "solid",
172
+ onClick: D,
173
+ disabled: _ || !C.name.trim(),
174
+ children: _ ? "Creating..." : "Create Newsletter"
175
+ })]
176
+ })]
177
+ }),
178
+ children: /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("div", {
179
+ className: "flex items-center gap-2 mb-8",
180
+ children: m.map((e, t) => {
181
+ let n = e.icon, r = t === l, i = t < l;
182
+ return /* @__PURE__ */ (0, f.jsxs)("div", {
183
+ className: "flex items-center gap-2 flex-1",
184
+ children: [
185
+ /* @__PURE__ */ (0, f.jsx)("div", {
186
+ className: `flex items-center justify-center w-8 h-8 rounded-full shrink-0 ${i ? "bg-green-500 text-white" : r ? "bg-[var(--accent-9)] text-white" : "bg-[var(--gray-a4)] text-[var(--gray-9)]"}`,
187
+ children: i ? /* @__PURE__ */ (0, f.jsx)(d.CheckIcon, { className: "w-4 h-4" }) : /* @__PURE__ */ (0, f.jsx)(n, { className: "w-4 h-4" })
188
+ }),
189
+ /* @__PURE__ */ (0, f.jsx)("span", {
190
+ className: `text-sm font-medium ${r ? "text-[var(--gray-12)]" : "text-[var(--gray-9)]"}`,
191
+ children: e.label
192
+ }),
193
+ t < m.length - 1 && /* @__PURE__ */ (0, f.jsx)("div", { className: "flex-1 h-px bg-[var(--gray-a5)]" })
194
+ ]
195
+ }, e.id);
196
+ })
197
+ }), /* @__PURE__ */ (0, f.jsxs)(a, {
198
+ variant: "surface",
199
+ className: "p-6 mb-6",
200
+ children: [
201
+ l === 0 && /* @__PURE__ */ (0, f.jsxs)("div", {
202
+ className: "space-y-4",
203
+ children: [
204
+ /* @__PURE__ */ (0, f.jsx)("h2", {
205
+ className: "text-lg font-semibold text-[var(--gray-12)]",
206
+ children: "Newsletter Basics"
207
+ }),
208
+ /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
209
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
210
+ children: "Newsletter Name *"
211
+ }), /* @__PURE__ */ (0, f.jsx)("input", {
212
+ value: C.name,
213
+ onChange: (e) => T("name", e.target.value),
214
+ className: O,
215
+ placeholder: "EXAMPLE Weekly"
216
+ })] }),
217
+ /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
218
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
219
+ children: "Slug"
220
+ }), /* @__PURE__ */ (0, f.jsx)("input", {
221
+ value: C.slug,
222
+ onChange: (e) => T("slug", p(e.target.value)),
223
+ className: `${O} font-mono`,
224
+ placeholder: "example-weekly"
225
+ })] }),
226
+ /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
227
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
228
+ children: "Description"
229
+ }), /* @__PURE__ */ (0, f.jsx)("textarea", {
230
+ value: C.description,
231
+ onChange: (e) => T("description", e.target.value),
232
+ className: O,
233
+ rows: 2,
234
+ placeholder: "Weekly updates from the EXAMPLE community"
235
+ })] }),
236
+ x.length > 0 && /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
237
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
238
+ children: "Content Category"
239
+ }), /* @__PURE__ */ (0, f.jsxs)("select", {
240
+ value: C.content_category,
241
+ onChange: (e) => T("content_category", e.target.value),
242
+ className: O,
243
+ children: [/* @__PURE__ */ (0, f.jsx)("option", {
244
+ value: "",
245
+ children: "No category"
246
+ }), x.map((e) => /* @__PURE__ */ (0, f.jsx)("option", {
247
+ value: e.value,
248
+ children: e.label
249
+ }, e.value))]
250
+ })] }),
251
+ /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
252
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-2",
253
+ children: "Accent Color"
254
+ }), /* @__PURE__ */ (0, f.jsx)("div", {
255
+ className: "flex gap-2",
256
+ children: h.map((e) => /* @__PURE__ */ (0, f.jsx)("button", {
257
+ onClick: () => T("accent_color", e),
258
+ className: `w-8 h-8 rounded-full border-2 transition-transform ${C.accent_color === e ? "border-[var(--gray-12)] scale-110" : "border-transparent"}`,
259
+ style: { backgroundColor: e }
260
+ }, e))
261
+ })] })
262
+ ]
263
+ }),
264
+ l === 1 && /* @__PURE__ */ (0, f.jsxs)("div", {
265
+ className: "space-y-4",
266
+ children: [
267
+ /* @__PURE__ */ (0, f.jsx)("h2", {
268
+ className: "text-lg font-semibold text-[var(--gray-12)]",
269
+ children: "Sender Identity"
270
+ }),
271
+ /* @__PURE__ */ (0, f.jsx)("p", {
272
+ className: "text-sm text-[var(--gray-9)]",
273
+ children: "This is how your newsletter will appear in recipients' inboxes."
274
+ }),
275
+ /* @__PURE__ */ (0, f.jsxs)("div", {
276
+ className: "grid grid-cols-2 gap-4",
277
+ children: [/* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
278
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
279
+ children: "From Name *"
280
+ }), /* @__PURE__ */ (0, f.jsx)("input", {
281
+ value: C.from_name,
282
+ onChange: (e) => T("from_name", e.target.value),
283
+ className: O,
284
+ placeholder: "EXAMPLE Newsletter"
285
+ })] }), /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
286
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
287
+ children: "From Email *"
288
+ }), /* @__PURE__ */ (0, f.jsx)("input", {
289
+ type: "email",
290
+ value: C.from_email,
291
+ onChange: (e) => T("from_email", e.target.value),
292
+ className: O,
293
+ placeholder: "newsletter@example.io"
294
+ })] })]
295
+ }),
296
+ /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
297
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
298
+ children: "Reply-To Email"
299
+ }), /* @__PURE__ */ (0, f.jsx)("input", {
300
+ type: "email",
301
+ value: C.reply_to,
302
+ onChange: (e) => T("reply_to", e.target.value),
303
+ className: O,
304
+ placeholder: "hello@example.io"
305
+ })] })
306
+ ]
307
+ }),
308
+ l === 2 && /* @__PURE__ */ (0, f.jsxs)("div", {
309
+ className: "space-y-4",
310
+ children: [
311
+ /* @__PURE__ */ (0, f.jsx)("h2", {
312
+ className: "text-lg font-semibold text-[var(--gray-12)]",
313
+ children: "Subscription List"
314
+ }),
315
+ /* @__PURE__ */ (0, f.jsx)("p", {
316
+ className: "text-sm text-[var(--gray-9)]",
317
+ children: "Link a subscription list to manage who receives this newsletter."
318
+ }),
319
+ y.length > 0 ? /* @__PURE__ */ (0, f.jsxs)("div", { children: [/* @__PURE__ */ (0, f.jsx)("label", {
320
+ className: "block text-sm font-medium text-[var(--gray-11)] mb-1",
321
+ children: "Select List"
322
+ }), /* @__PURE__ */ (0, f.jsxs)("select", {
323
+ value: C.list_id,
324
+ onChange: (e) => T("list_id", e.target.value),
325
+ className: O,
326
+ children: [/* @__PURE__ */ (0, f.jsx)("option", {
327
+ value: "",
328
+ children: "No list (configure later)"
329
+ }), y.map((e) => /* @__PURE__ */ (0, f.jsx)("option", {
330
+ value: e.id,
331
+ children: e.name
332
+ }, e.id))]
333
+ })] }) : /* @__PURE__ */ (0, f.jsx)("div", {
334
+ className: "p-4 bg-[var(--gray-a2)] rounded-lg",
335
+ children: /* @__PURE__ */ (0, f.jsx)("p", {
336
+ className: "text-sm text-[var(--gray-11)]",
337
+ children: "No subscription lists available. You can create one in the Lists section and link it later."
338
+ })
339
+ })
340
+ ]
341
+ })
342
+ ]
343
+ })] })
344
+ });
345
+ }
346
+ //#endregion
347
+ export { g as default };
@@ -0,0 +1,224 @@
1
+ import { c as e, n as t, t as n } from "./react-DB2tPNit.js";
2
+ import { t as r } from "./jsx-runtime-CjozyJt-.js";
3
+ import { n as i, t as a } from "./brand-DklYwIeA.js";
4
+ //#region \0stub:/Users/dan/Git/gatewaze/gw-embed-build/packages/admin/src/hooks/useAuth
5
+ var o = /* @__PURE__ */ t(((e, t) => {
6
+ t.exports = {};
7
+ })), s = a(), c = o(), l = /* @__PURE__ */ e(n()), u = i(), d = r();
8
+ function f() {
9
+ let [e, t] = (0, l.useState)(null);
10
+ return (0, l.useEffect)(() => {
11
+ let e = !1;
12
+ return (async () => {
13
+ try {
14
+ let { data: n } = await (0, u.getSupabaseClient)().from("platform_settings").select("value").eq("key", "newsletter_consent_html").maybeSingle();
15
+ !e && n?.value && n.value.trim() && t(n.value.trim());
16
+ } catch {}
17
+ })(), () => {
18
+ e = !0;
19
+ };
20
+ }, []), e ? /* @__PURE__ */ (0, d.jsx)("p", {
21
+ className: "pub-nl-consent",
22
+ style: {
23
+ color: "var(--ink-3)",
24
+ fontSize: 12,
25
+ lineHeight: 1.55,
26
+ marginTop: 10,
27
+ maxWidth: "52ch"
28
+ },
29
+ dangerouslySetInnerHTML: { __html: e }
30
+ }) : null;
31
+ }
32
+ //#endregion
33
+ //#region ../../../gatewaze-modules/modules/newsletters/portal/components/NewsletterSignup.tsx
34
+ var p = () => `${(0, s.getClientBrandConfig)().supabaseUrl}/functions/v1/newsletter-signup`;
35
+ function m(e) {
36
+ let { user: t, session: n } = (0, c.useAuth)(), [r, i] = (0, l.useState)(void 0), [a, o] = (0, l.useState)("idle"), u = (0, l.useRef)(n);
37
+ return u.current = n, (0, l.useEffect)(() => {
38
+ let n = !1;
39
+ if (!t) {
40
+ i(null);
41
+ return;
42
+ }
43
+ return i(void 0), (async () => {
44
+ try {
45
+ let t = (0, s.getClientBrandConfig)(), r = u.current?.access_token;
46
+ if (!r) {
47
+ n || i((e) => e ?? {
48
+ subscribed: !1,
49
+ email: null
50
+ });
51
+ return;
52
+ }
53
+ let a = await fetch(p(), {
54
+ method: "POST",
55
+ headers: {
56
+ "Content-Type": "application/json",
57
+ apikey: t.supabaseAnonKey,
58
+ Authorization: `Bearer ${r}`
59
+ },
60
+ body: JSON.stringify({
61
+ action: "status",
62
+ collection: e
63
+ })
64
+ }), o = a.ok ? await a.json().catch(() => null) : null;
65
+ if (n) return;
66
+ o && typeof o.subscribed == "boolean" ? i(o) : i((e) => e ?? {
67
+ subscribed: !1,
68
+ email: null
69
+ });
70
+ } catch {
71
+ n || i((e) => e ?? {
72
+ subscribed: !1,
73
+ email: null
74
+ });
75
+ }
76
+ })(), () => {
77
+ n = !0;
78
+ };
79
+ }, [t?.id, e]), {
80
+ user: t,
81
+ sub: r,
82
+ setSub: i,
83
+ unsubState: a,
84
+ setUnsubState: o,
85
+ unsubscribe: async () => {
86
+ let t = u.current?.access_token;
87
+ if (t) {
88
+ o("working");
89
+ try {
90
+ let n = (0, s.getClientBrandConfig)();
91
+ if (!(await fetch(p(), {
92
+ method: "POST",
93
+ headers: {
94
+ "Content-Type": "application/json",
95
+ apikey: n.supabaseAnonKey,
96
+ Authorization: `Bearer ${t}`
97
+ },
98
+ body: JSON.stringify({
99
+ action: "unsubscribe",
100
+ collection: e
101
+ })
102
+ })).ok) throw Error();
103
+ o("done"), i({
104
+ subscribed: !1,
105
+ email: null
106
+ });
107
+ } catch {
108
+ o("error");
109
+ }
110
+ }
111
+ }
112
+ };
113
+ }
114
+ function h({ sub: e, unsubState: t, unsubscribe: n }) {
115
+ return /* @__PURE__ */ (0, d.jsxs)("div", {
116
+ className: "pub-nl-substate",
117
+ children: [
118
+ /* @__PURE__ */ (0, d.jsxs)("p", {
119
+ className: "pub-nl-signup-msg ok",
120
+ style: { margin: "14px 0 10px" },
121
+ children: [
122
+ "✓ You’re subscribed",
123
+ e.email ? /* @__PURE__ */ (0, d.jsxs)(d.Fragment, { children: [" as ", /* @__PURE__ */ (0, d.jsx)("strong", { children: e.email })] }) : null,
124
+ "."
125
+ ]
126
+ }),
127
+ /* @__PURE__ */ (0, d.jsx)("button", {
128
+ type: "button",
129
+ className: "pub-nl-unsub-btn",
130
+ onClick: n,
131
+ disabled: t === "working",
132
+ children: t === "working" ? "Unsubscribing…" : "Unsubscribe"
133
+ }),
134
+ t === "error" && /* @__PURE__ */ (0, d.jsx)("p", {
135
+ className: "pub-nl-signup-msg err",
136
+ children: "Couldn’t unsubscribe right now — please try again."
137
+ })
138
+ ]
139
+ });
140
+ }
141
+ function g({ collectionSlug: e, subscription: t }) {
142
+ let n = m(e), { user: r, sub: i, setSub: a, unsubState: o, unsubscribe: c } = t ?? n, [u, g] = (0, l.useState)(""), [_, v] = (0, l.useState)("idle");
143
+ return (0, l.useEffect)(() => {
144
+ r?.email && g((e) => e || r.email);
145
+ }, [r?.email]), i?.subscribed ? /* @__PURE__ */ (0, d.jsx)(h, {
146
+ sub: i,
147
+ unsubState: o,
148
+ unsubscribe: c
149
+ }) : _ === "done" ? /* @__PURE__ */ (0, d.jsx)("p", {
150
+ className: "pub-nl-signup-msg ok",
151
+ style: { marginTop: 14 },
152
+ children: "Thanks — you’re subscribed. Watch your inbox for the next edition."
153
+ }) : /* @__PURE__ */ (0, d.jsxs)(d.Fragment, { children: [
154
+ o === "done" && /* @__PURE__ */ (0, d.jsx)("p", {
155
+ className: "pub-nl-signup-msg",
156
+ style: { marginTop: 10 },
157
+ children: "You’ve been unsubscribed. Changed your mind? Subscribe again below."
158
+ }),
159
+ /* @__PURE__ */ (0, d.jsxs)("form", {
160
+ onSubmit: async (t) => {
161
+ t.preventDefault();
162
+ let n = u.trim();
163
+ if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(n)) {
164
+ v("invalid");
165
+ return;
166
+ }
167
+ v("submitting");
168
+ try {
169
+ let t = (0, s.getClientBrandConfig)();
170
+ if (!(await fetch(p(), {
171
+ method: "POST",
172
+ headers: {
173
+ "Content-Type": "application/json",
174
+ apikey: t.supabaseAnonKey,
175
+ Authorization: `Bearer ${t.supabaseAnonKey}`
176
+ },
177
+ body: JSON.stringify({
178
+ email: n,
179
+ collection: e
180
+ })
181
+ })).ok) throw Error();
182
+ v("done"), r || g(""), a((e) => e === null ? null : {
183
+ subscribed: !0,
184
+ email: n.toLowerCase()
185
+ });
186
+ } catch {
187
+ v("error");
188
+ }
189
+ },
190
+ className: "pub-nl-signup",
191
+ children: [
192
+ /* @__PURE__ */ (0, d.jsx)("input", {
193
+ type: "email",
194
+ inputMode: "email",
195
+ autoComplete: "email",
196
+ value: u,
197
+ onChange: (e) => {
198
+ g(e.target.value), (_ === "invalid" || _ === "error") && v("idle");
199
+ },
200
+ placeholder: "Email address",
201
+ "aria-label": "Email address",
202
+ className: "pub-nl-signup-input"
203
+ }),
204
+ /* @__PURE__ */ (0, d.jsx)("button", {
205
+ type: "submit",
206
+ className: "pub-nl-signup-btn",
207
+ disabled: _ === "submitting",
208
+ children: _ === "submitting" ? "Subscribing…" : "Subscribe"
209
+ }),
210
+ _ === "invalid" && /* @__PURE__ */ (0, d.jsx)("p", {
211
+ className: "pub-nl-signup-msg err",
212
+ children: "Please enter a valid email address."
213
+ }),
214
+ _ === "error" && /* @__PURE__ */ (0, d.jsx)("p", {
215
+ className: "pub-nl-signup-msg err",
216
+ children: "Couldn’t subscribe right now — please try again."
217
+ })
218
+ ]
219
+ }),
220
+ /* @__PURE__ */ (0, d.jsx)(f, {})
221
+ ] });
222
+ }
223
+ //#endregion
224
+ export { f as i, h as n, m as r, g as t };
@@ -0,0 +1,14 @@
1
+ import { c as e, t } from "./react-DB2tPNit.js";
2
+ import { t as n } from "./jsx-runtime-CjozyJt-.js";
3
+ import { A as r, L as i } from "./ui-DRIo9Krs.js";
4
+ //#region src/components/shared/Page.tsx
5
+ var a = /* @__PURE__ */ e(t()), o = n();
6
+ function s({ title: e = "", component: t, children: n, ...s }) {
7
+ let c = t || a.Fragment;
8
+ return i(`${e} - ${r}`), /* @__PURE__ */ (0, o.jsx)(c, {
9
+ ...s,
10
+ children: n
11
+ });
12
+ }
13
+ //#endregion
14
+ export { s as t };
@@ -0,0 +1,18 @@
1
+ import { t as e } from "./jsx-runtime-CjozyJt-.js";
2
+ import { t } from "./sonnerHostBridge-CXuCMM3R.js";
3
+ import { i as n, t as r } from "./theme-D6odw5nx.js";
4
+ //#region src/components/template/Toaster.tsx
5
+ var i = e();
6
+ function a() {
7
+ let { isDark: e, notification: a } = n();
8
+ return /* @__PURE__ */ (0, i.jsx)(t.Toaster, {
9
+ theme: e ? "dark" : "light",
10
+ offset: "16px",
11
+ position: a?.position || r?.notification?.position,
12
+ expand: a?.isExpanded || r?.notification?.isExpanded,
13
+ visibleToasts: a?.visibleToasts || r?.notification?.visibleToasts,
14
+ richColors: !0
15
+ });
16
+ }
17
+ //#endregion
18
+ export { a as default };