@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,308 @@
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, O as o, n as s } from "./ui-DRIo9Krs.js";
5
+ import { t as c } from "./DetailPageHeader-D_v7924k.js";
6
+ import { a as l, s as u } from "./hooks-C377EXJG.js";
7
+ import { n as d } from "./sonnerHostBridge-CXuCMM3R.js";
8
+ import { t as f } from "./outline-DwDYhYcF.js";
9
+ import { t as p } from "./Page-D3u8IZ2a.js";
10
+ import { t as m } from "./useModuleFeature-DgsFIUpv.js";
11
+ import { n as h, t as g } from "./utils-BcVvIjaY.js";
12
+ //#region ../../../gatewaze-modules/modules/newsletters/admin/pages/templates/[collectionSlug].tsx
13
+ var _ = /* @__PURE__ */ e(t()), v = f(), y = r();
14
+ function b() {
15
+ let { collectionSlug: e } = u(), t = l(), r = m("redirects-shortio"), f = m("redirects-bitly"), b = m("redirects-umami"), [x, S] = (0, _.useState)(null), [C, w] = (0, _.useState)([]), [T, E] = (0, _.useState)([]), [D, O] = (0, _.useState)(!0), [k, A] = (0, _.useState)(!1), [j, M] = (0, _.useState)(""), [N, P] = (0, _.useState)(!1), F = x?.metadata?.redirect_provider || "", I = [
16
+ {
17
+ value: "",
18
+ label: "None (use full URLs)"
19
+ },
20
+ ...r ? [{
21
+ value: "redirects-shortio",
22
+ label: "Short.io"
23
+ }] : [],
24
+ ...f ? [{
25
+ value: "redirects-bitly",
26
+ label: "Bitly"
27
+ }] : [],
28
+ ...b ? [{
29
+ value: "redirects-umami",
30
+ label: "Umami (self-hosted)"
31
+ }] : []
32
+ ];
33
+ (0, _.useEffect)(() => {
34
+ e && L();
35
+ }, [e]);
36
+ async function L() {
37
+ try {
38
+ let { data: t, error: r } = await n.from("newsletters_template_collections").select("*").eq("slug", e).single();
39
+ if (r) throw r;
40
+ S(t), M(t.name);
41
+ let [i, a, o] = await Promise.all([
42
+ n.from("templates_block_defs").select("id, key, name, description, schema, html, rich_text_template, has_bricks, library_id, block_type:key").eq("library_id", t.id).eq("is_current", !0).order("key"),
43
+ n.from("templates_brick_defs").select("id, block_def_id, key, name, schema, html, rich_text_template, sort_order, brick_type:key, templates_block_defs!inner(library_id)").eq("templates_block_defs.library_id", t.id).eq("is_current", !0).order("sort_order"),
44
+ n.from("templates_sources").select("id").eq("library_id", t.id).eq("kind", "git").eq("status", "active").limit(1)
45
+ ]);
46
+ if (i.error) throw i.error;
47
+ if (a.error) throw a.error;
48
+ if (o.error) throw o.error;
49
+ w(i.data || []), E(a.data || []), P((o.data ?? []).length > 0);
50
+ } catch (e) {
51
+ console.error("Error loading template:", e), d.error("Failed to load template");
52
+ } finally {
53
+ O(!1);
54
+ }
55
+ }
56
+ async function R() {
57
+ if (!(!x || !j.trim())) try {
58
+ let { error: e } = await n.from("newsletters_template_collections").update({ name: j.trim() }).eq("id", x.id);
59
+ if (e) throw e;
60
+ S({
61
+ ...x,
62
+ name: j.trim()
63
+ }), A(!1), d.success("Name updated");
64
+ } catch (e) {
65
+ console.error("Error updating name:", e), d.error("Failed to update name");
66
+ }
67
+ }
68
+ async function z(e) {
69
+ if (x) try {
70
+ let t = {
71
+ ...x.metadata || {},
72
+ redirect_provider: e || null
73
+ }, { error: r } = await n.from("newsletters_template_collections").update({ metadata: t }).eq("id", x.id);
74
+ if (r) throw r;
75
+ S({
76
+ ...x,
77
+ metadata: t
78
+ }), d.success("Redirect provider updated");
79
+ } catch (e) {
80
+ console.error("Error updating redirect provider:", e), d.error("Failed to update redirect provider");
81
+ }
82
+ }
83
+ async function B() {
84
+ if (x) try {
85
+ let e = await h(x.id);
86
+ g(e, x.slug), d.success("Template downloaded");
87
+ } catch (e) {
88
+ console.error("Error downloading template:", e), d.error("Failed to download template");
89
+ }
90
+ }
91
+ async function V(e, t) {
92
+ if (confirm(`Delete block template "${t}"? This cannot be undone.`)) try {
93
+ let { error: t } = await n.from("templates_block_defs").delete().eq("id", e);
94
+ if (t) throw t;
95
+ d.success("Block template deleted"), L();
96
+ } catch (e) {
97
+ console.error("Error deleting block:", e), d.error("Failed to delete block template");
98
+ }
99
+ }
100
+ async function H(e, t) {
101
+ if (confirm(`Delete brick template "${t}"? This cannot be undone.`)) try {
102
+ let { error: t } = await n.from("templates_brick_defs").delete().eq("id", e);
103
+ if (t) throw t;
104
+ d.success("Brick template deleted"), L();
105
+ } catch (e) {
106
+ console.error("Error deleting brick:", e), d.error("Failed to delete brick template");
107
+ }
108
+ }
109
+ return D ? /* @__PURE__ */ (0, y.jsx)(p, {
110
+ title: "Template",
111
+ children: /* @__PURE__ */ (0, y.jsx)("div", {
112
+ className: "flex items-center justify-center p-12",
113
+ children: /* @__PURE__ */ (0, y.jsx)(s, {})
114
+ })
115
+ }) : x ? /* @__PURE__ */ (0, y.jsx)(p, {
116
+ title: x.name,
117
+ children: /* @__PURE__ */ (0, y.jsxs)("div", {
118
+ className: "p-6",
119
+ children: [
120
+ /* @__PURE__ */ (0, y.jsx)(c, {
121
+ title: k ? "" : x.name,
122
+ subtitle: x.description || void 0,
123
+ backTo: "/newsletters/templates",
124
+ badges: x.is_default ? [{
125
+ label: "Default",
126
+ color: "blue"
127
+ }] : void 0,
128
+ actions: /* @__PURE__ */ (0, y.jsxs)(y.Fragment, { children: [C.length > 0 && /* @__PURE__ */ (0, y.jsxs)("button", {
129
+ onClick: B,
130
+ className: "px-3 py-1.5 text-sm font-medium rounded-md bg-white/90 backdrop-blur-md border border-white/40 text-gray-900 shadow-sm hover:bg-white transition-colors",
131
+ children: [/* @__PURE__ */ (0, y.jsx)(v.ArrowDownTrayIcon, { className: "w-4 h-4 inline mr-1" }), "Download"]
132
+ }), !N && /* @__PURE__ */ (0, y.jsxs)("button", {
133
+ onClick: () => {
134
+ C.length > 0 && !confirm("This will replace all block and brick templates. Existing editions are not affected. Continue?") || t(`/newsletters/templates/${e}/upload`);
135
+ },
136
+ className: "px-3 py-1.5 text-sm font-medium rounded-md bg-white/90 backdrop-blur-md border border-white/40 text-gray-900 shadow-sm hover:bg-white transition-colors",
137
+ children: [/* @__PURE__ */ (0, y.jsx)(v.ArrowUpTrayIcon, { className: "w-4 h-4 inline mr-1" }), C.length > 0 ? "Re-upload" : "Upload"]
138
+ })] }),
139
+ children: k && /* @__PURE__ */ (0, y.jsxs)("div", {
140
+ className: "flex items-center gap-2",
141
+ children: [
142
+ /* @__PURE__ */ (0, y.jsx)("input", {
143
+ type: "text",
144
+ value: j,
145
+ onChange: (e) => M(e.target.value),
146
+ className: "text-lg font-semibold px-2 py-1 rounded border border-white/40 bg-white/90 text-gray-900",
147
+ onKeyDown: (e) => {
148
+ e.key === "Enter" && R(), e.key === "Escape" && (A(!1), M(x.name));
149
+ },
150
+ autoFocus: !0
151
+ }),
152
+ /* @__PURE__ */ (0, y.jsx)("button", {
153
+ onClick: R,
154
+ className: "px-2 py-1 text-sm rounded bg-white/90 text-gray-900 hover:bg-white",
155
+ children: "Save"
156
+ }),
157
+ /* @__PURE__ */ (0, y.jsx)("button", {
158
+ onClick: () => {
159
+ A(!1), M(x.name);
160
+ },
161
+ className: "px-2 py-1 text-sm rounded bg-white/20 text-white/80 hover:bg-white/30",
162
+ children: "Cancel"
163
+ })
164
+ ]
165
+ })
166
+ }),
167
+ (r || f || b) && /* @__PURE__ */ (0, y.jsxs)(a, {
168
+ className: "p-4 mb-6",
169
+ children: [/* @__PURE__ */ (0, y.jsxs)("div", {
170
+ className: "flex items-center gap-2 mb-3",
171
+ children: [/* @__PURE__ */ (0, y.jsx)(v.Cog6ToothIcon, { className: "w-5 h-5 text-[var(--gray-10)]" }), /* @__PURE__ */ (0, y.jsx)("h2", {
172
+ className: "text-sm font-medium text-[var(--gray-12)]",
173
+ children: "Template Settings"
174
+ })]
175
+ }), /* @__PURE__ */ (0, y.jsxs)("div", {
176
+ className: "max-w-sm",
177
+ children: [
178
+ /* @__PURE__ */ (0, y.jsx)("label", {
179
+ className: "text-xs text-[var(--gray-10)] mb-1 block",
180
+ children: "Link Redirect Provider"
181
+ }),
182
+ /* @__PURE__ */ (0, y.jsx)("select", {
183
+ value: F,
184
+ onChange: (e) => z(e.target.value),
185
+ className: "w-full px-3 py-2 rounded-md border border-[var(--gray-6)] bg-[var(--gray-1)] text-[var(--gray-12)] text-sm",
186
+ children: I.map((e) => /* @__PURE__ */ (0, y.jsx)("option", {
187
+ value: e.value,
188
+ children: e.label
189
+ }, e.value))
190
+ }),
191
+ /* @__PURE__ */ (0, y.jsx)("p", {
192
+ className: "text-xs text-[var(--gray-10)] mt-1",
193
+ children: "Choose how links are shortened in editions using this template"
194
+ })
195
+ ]
196
+ })]
197
+ }),
198
+ /* @__PURE__ */ (0, y.jsxs)("div", {
199
+ className: "mb-8",
200
+ children: [/* @__PURE__ */ (0, y.jsx)("div", {
201
+ className: "flex items-center justify-between mb-4",
202
+ children: /* @__PURE__ */ (0, y.jsxs)("h2", {
203
+ className: "text-lg font-medium text-[var(--gray-12)] flex items-center gap-2",
204
+ children: [
205
+ /* @__PURE__ */ (0, y.jsx)(v.CubeIcon, { className: "w-5 h-5 text-[var(--accent-9)]" }),
206
+ "Block Templates",
207
+ N && /* @__PURE__ */ (0, y.jsx)(o, {
208
+ color: "gray",
209
+ children: "Managed by git"
210
+ })
211
+ ]
212
+ })
213
+ }), /* @__PURE__ */ (0, y.jsxs)("div", {
214
+ className: "space-y-2",
215
+ children: [C.map((n) => /* @__PURE__ */ (0, y.jsxs)(a, {
216
+ className: N ? "p-3 flex items-center justify-between" : "p-3 flex items-center justify-between hover:border-[var(--accent-8)] transition-colors cursor-pointer",
217
+ onClick: N ? void 0 : () => t(`/newsletters/templates/${e}/blocks/${n.block_type}`),
218
+ children: [/* @__PURE__ */ (0, y.jsxs)("div", {
219
+ className: "flex items-center gap-3",
220
+ children: [
221
+ /* @__PURE__ */ (0, y.jsx)(v.CubeIcon, { className: "w-4 h-4 text-[var(--gray-10)]" }),
222
+ /* @__PURE__ */ (0, y.jsxs)("div", { children: [/* @__PURE__ */ (0, y.jsx)("span", {
223
+ className: "text-sm font-medium text-[var(--gray-12)]",
224
+ children: n.name
225
+ }), /* @__PURE__ */ (0, y.jsx)("span", {
226
+ className: "text-xs text-[var(--gray-10)] ml-2",
227
+ children: n.block_type
228
+ })] }),
229
+ n.has_bricks && /* @__PURE__ */ (0, y.jsx)(o, {
230
+ color: "gray",
231
+ children: "has bricks"
232
+ }),
233
+ n.rich_text_template && /* @__PURE__ */ (0, y.jsx)(o, {
234
+ color: "gray",
235
+ children: "+ rich text"
236
+ })
237
+ ]
238
+ }), !N && /* @__PURE__ */ (0, y.jsx)(i, {
239
+ variant: "ghost",
240
+ onClick: (e) => {
241
+ e.stopPropagation(), V(n.id, n.name);
242
+ },
243
+ children: /* @__PURE__ */ (0, y.jsx)(v.TrashIcon, { className: "w-4 h-4 text-[var(--red-9)]" })
244
+ })]
245
+ }, n.id)), C.length === 0 && /* @__PURE__ */ (0, y.jsx)("p", {
246
+ className: "text-sm text-[var(--gray-10)] text-center py-4",
247
+ children: N ? "No block templates yet — push a block file to the connected git repo to get started" : "No block templates yet — upload an HTML file to get started"
248
+ })]
249
+ })]
250
+ }),
251
+ /* @__PURE__ */ (0, y.jsxs)("div", { children: [/* @__PURE__ */ (0, y.jsx)("div", {
252
+ className: "flex items-center justify-between mb-4",
253
+ children: /* @__PURE__ */ (0, y.jsxs)("h2", {
254
+ className: "text-lg font-medium text-[var(--gray-12)] flex items-center gap-2",
255
+ children: [
256
+ /* @__PURE__ */ (0, y.jsx)(v.PuzzlePieceIcon, { className: "w-5 h-5 text-[var(--accent-9)]" }),
257
+ "Brick Templates",
258
+ N && /* @__PURE__ */ (0, y.jsx)(o, {
259
+ color: "gray",
260
+ children: "Managed by git"
261
+ })
262
+ ]
263
+ })
264
+ }), /* @__PURE__ */ (0, y.jsxs)("div", {
265
+ className: "space-y-2",
266
+ children: [T.map((n) => /* @__PURE__ */ (0, y.jsxs)(a, {
267
+ className: N ? "p-3 flex items-center justify-between" : "p-3 flex items-center justify-between hover:border-[var(--accent-8)] transition-colors cursor-pointer",
268
+ onClick: N ? void 0 : () => t(`/newsletters/templates/${e}/bricks/${n.brick_type}`),
269
+ children: [/* @__PURE__ */ (0, y.jsxs)("div", {
270
+ className: "flex items-center gap-3",
271
+ children: [
272
+ /* @__PURE__ */ (0, y.jsx)(v.PuzzlePieceIcon, { className: "w-4 h-4 text-[var(--gray-10)]" }),
273
+ /* @__PURE__ */ (0, y.jsxs)("div", { children: [/* @__PURE__ */ (0, y.jsx)("span", {
274
+ className: "text-sm font-medium text-[var(--gray-12)]",
275
+ children: n.name
276
+ }), /* @__PURE__ */ (0, y.jsx)("span", {
277
+ className: "text-xs text-[var(--gray-10)] ml-2",
278
+ children: n.brick_type
279
+ })] }),
280
+ n.rich_text_template && /* @__PURE__ */ (0, y.jsx)(o, {
281
+ color: "gray",
282
+ children: "+ rich text"
283
+ })
284
+ ]
285
+ }), !N && /* @__PURE__ */ (0, y.jsx)(i, {
286
+ variant: "ghost",
287
+ onClick: (e) => {
288
+ e.stopPropagation(), H(n.id, n.name);
289
+ },
290
+ children: /* @__PURE__ */ (0, y.jsx)(v.TrashIcon, { className: "w-4 h-4 text-[var(--red-9)]" })
291
+ })]
292
+ }, n.id)), T.length === 0 && /* @__PURE__ */ (0, y.jsx)("p", {
293
+ className: "text-sm text-[var(--gray-10)] text-center py-4",
294
+ children: "No brick templates yet"
295
+ })]
296
+ })] })
297
+ ]
298
+ })
299
+ }) : /* @__PURE__ */ (0, y.jsx)(p, {
300
+ title: "Template Not Found",
301
+ children: /* @__PURE__ */ (0, y.jsx)("div", {
302
+ className: "p-6 text-center text-[var(--gray-10)]",
303
+ children: "Template not found"
304
+ })
305
+ });
306
+ }
307
+ //#endregion
308
+ export { b as default };
@@ -0,0 +1,139 @@
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 { t as i } from "./edition-slug-CARO24Bs.js";
4
+ import { n as a, r as o } from "./brand-DklYwIeA.js";
5
+ import { t as s } from "./NewsletterSignup-DRVZIpOs.js";
6
+ //#region \0stub:next/navigation
7
+ var c = /* @__PURE__ */ t(((e, t) => {
8
+ t.exports = {};
9
+ })), l = /* @__PURE__ */ e(n()), u = /* @__PURE__ */ e(o()), d = c(), f = a(), p = r();
10
+ function m(e) {
11
+ return new Date(e).toLocaleDateString("en-US", {
12
+ year: "numeric",
13
+ month: "short",
14
+ day: "numeric"
15
+ });
16
+ }
17
+ function h(e) {
18
+ return e.replace(/[-_]+/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
19
+ }
20
+ function g({ params: e }) {
21
+ let t = (0, d.useRouter)(), n = e.collection || "", r = n.includes("--"), [a, o] = (0, l.useState)(null), [c, g] = (0, l.useState)([]), [_, v] = (0, l.useState)(!0), [y, b] = (0, l.useState)(null);
22
+ if ((0, l.useEffect)(() => {
23
+ async function e() {
24
+ try {
25
+ let e = (0, f.getSupabaseClient)();
26
+ if (r) {
27
+ let [r, a] = n.split("--"), { data: o } = await e.from("newsletters_template_collections").select("id, slug").eq("slug", r).single();
28
+ if (!o) {
29
+ b("Newsletter not found"), v(!1);
30
+ return;
31
+ }
32
+ let { data: s } = await e.from("newsletters_editions").select("title, edition_date").eq("collection_id", o.id).eq("edition_date", a).eq("status", "published").order("created_at", { ascending: !1 }).limit(1).maybeSingle();
33
+ if (!s) {
34
+ b("Edition not found"), v(!1);
35
+ return;
36
+ }
37
+ t.replace(`/newsletters/${o.slug}/${i(s.edition_date, s.title)}`);
38
+ return;
39
+ }
40
+ let { data: a } = await e.from("newsletters_template_collections").select("id, name, slug, description, accent_color, content_category, require_login").eq("slug", n).eq("setup_complete", !0).maybeSingle();
41
+ if (!a) {
42
+ b("Newsletter not found"), v(!1);
43
+ return;
44
+ }
45
+ o(a);
46
+ let { data: s } = await e.from("newsletters_editions").select("id, title, edition_date, preheader").eq("collection_id", a.id).eq("status", "published").order("edition_date", { ascending: !1 });
47
+ g(s || []), v(!1);
48
+ } catch {
49
+ b("Failed to load newsletter"), v(!1);
50
+ }
51
+ }
52
+ e();
53
+ }, [
54
+ n,
55
+ r,
56
+ t
57
+ ]), _) return /* @__PURE__ */ (0, p.jsx)("div", {
58
+ className: "pub-wrap",
59
+ children: /* @__PURE__ */ (0, p.jsx)("div", {
60
+ className: "pub-empty",
61
+ children: "Loading…"
62
+ })
63
+ });
64
+ if (y || !a) return /* @__PURE__ */ (0, p.jsxs)("div", {
65
+ className: "pub-wrap",
66
+ children: [/* @__PURE__ */ (0, p.jsx)("div", {
67
+ className: "pub-h",
68
+ children: /* @__PURE__ */ (0, p.jsx)("h1", { children: "Newsletter" })
69
+ }), /* @__PURE__ */ (0, p.jsxs)("div", {
70
+ className: "pub-empty",
71
+ children: [
72
+ y || "Not found",
73
+ ". ",
74
+ /* @__PURE__ */ (0, p.jsx)(u.default, {
75
+ href: "/newsletters",
76
+ className: "pub-nl-viewall",
77
+ style: { marginTop: 0 },
78
+ children: "Back to newsletters"
79
+ })
80
+ ]
81
+ })]
82
+ });
83
+ let x = a.accent_color || "var(--accent)";
84
+ return /* @__PURE__ */ (0, p.jsxs)("div", {
85
+ className: "pub-wrap pub-fade",
86
+ children: [
87
+ /* @__PURE__ */ (0, p.jsxs)("div", {
88
+ className: "pub-h",
89
+ children: [/* @__PURE__ */ (0, p.jsxs)("div", {
90
+ className: "pub-nl-titlerow",
91
+ children: [
92
+ /* @__PURE__ */ (0, p.jsx)("span", {
93
+ className: "pub-nl-bar",
94
+ style: { background: x }
95
+ }),
96
+ /* @__PURE__ */ (0, p.jsx)("h1", {
97
+ style: { margin: 0 },
98
+ children: a.name
99
+ }),
100
+ a.content_category && /* @__PURE__ */ (0, p.jsx)("span", {
101
+ className: "pub-nl-badge",
102
+ children: h(a.content_category)
103
+ })
104
+ ]
105
+ }), a.description && /* @__PURE__ */ (0, p.jsx)("p", { children: a.description })]
106
+ }),
107
+ a.require_login ? /* @__PURE__ */ (0, p.jsx)("p", {
108
+ className: "pub-nl-note",
109
+ children: "Subscribers only — sign in to read the editions."
110
+ }) : /* @__PURE__ */ (0, p.jsx)("div", {
111
+ style: {
112
+ maxWidth: 480,
113
+ marginBottom: 8
114
+ },
115
+ children: /* @__PURE__ */ (0, p.jsx)(s, { collectionSlug: a.slug })
116
+ }),
117
+ c.length === 0 ? /* @__PURE__ */ (0, p.jsx)("div", {
118
+ className: "pub-empty",
119
+ children: "No editions published yet."
120
+ }) : /* @__PURE__ */ (0, p.jsx)("ul", {
121
+ className: "pub-nl-list",
122
+ style: { marginTop: 20 },
123
+ children: c.map((e) => /* @__PURE__ */ (0, p.jsx)("li", { children: /* @__PURE__ */ (0, p.jsxs)(u.default, {
124
+ href: `/newsletters/${a.slug}/${i(e.edition_date, e.title)}`,
125
+ className: "pub-nl-row",
126
+ children: [/* @__PURE__ */ (0, p.jsx)("span", {
127
+ className: "pub-nl-row-date",
128
+ children: m(e.edition_date)
129
+ }), /* @__PURE__ */ (0, p.jsx)("span", {
130
+ className: "pub-nl-row-title",
131
+ children: e.title || "Untitled edition"
132
+ })]
133
+ }) }, e.id))
134
+ })
135
+ ]
136
+ });
137
+ }
138
+ //#endregion
139
+ export { g as default };