@burdenoff/microfe-notification 2026.1129.3 → 2026.1130.2

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.
@@ -14,9 +14,9 @@ import { CheckCheck as g, Search as _ } from "lucide-react";
14
14
  import { Navigate as v, useNavigate as y, useSearchParams as b } from "react-router";
15
15
  import { jsx as x, jsxs as S } from "react/jsx-runtime";
16
16
  import { PageHeader as C } from "@burdenoff/fe-libs/chrome";
17
- import { Button as w, EmptyState as T, Input as E, LoadError as D, PageTabs as O, useNotify as k } from "@burdenoff/fe-libs/ui";
17
+ import { Button as w, EmptyState as T, Input as E, LoadError as D, PageTabs as O, WorkspacePage as k, useNotify as A } from "@burdenoff/fe-libs/ui";
18
18
  // src/v2/InboxPage.tsx
19
- var A = {
19
+ var j = {
20
20
  all: {
21
21
  archived: !1,
22
22
  channel: "IN_APP"
@@ -34,156 +34,152 @@ var A = {
34
34
  archived: !0,
35
35
  channel: "IN_APP"
36
36
  }
37
- }, j = { channel: "IN_APP" };
38
- function M(e, t) {
37
+ }, M = { channel: "IN_APP" };
38
+ function N(e, t) {
39
39
  return e === "send" ? t.send : e === "templates" ? t.templates : e === "topics" ? t.topics : e === "history" ? t.deliveryLog : null;
40
40
  }
41
- function N() {
42
- let e = n(), [t] = b(), r = M(t.get("tab"), e);
41
+ function P() {
42
+ let e = n(), [t] = b(), r = N(t.get("tab"), e);
43
43
  return r ? /* @__PURE__ */ x(v, {
44
44
  to: r,
45
45
  replace: !0
46
- }) : /* @__PURE__ */ x(P, {});
46
+ }) : /* @__PURE__ */ x(F, {});
47
47
  }
48
- function P() {
49
- let v = t(), T = y(), M = k(), N = n(), { tools: P } = i(), { hasPermission: I, isLoading: L } = h(), [R, z] = b(), B = R.get("send") === "1" && !L && r("send", I), V = c(R.get("tab")), H = R.get("open"), U = e({
50
- baseFilter: A[V],
51
- unreadFilter: j
52
- }), W = d(), G = m(() => V === "action" ? U.notifications.filter(s) : U.notifications, [U.notifications, V]), K = U.notificationFilter.search ?? "", q = (e) => {
53
- let t = new URLSearchParams(R);
54
- e ? t.set("open", e) : t.delete("open"), z(t);
55
- }, J = (e) => {
56
- let t = new URLSearchParams(R);
57
- e ? t.set(p, "1") : t.delete(p), z(t);
58
- }, Y = async () => {
59
- let e = U.allNotifications.filter(o).map((e) => e.id), t = e.length >= U.unreadCount;
60
- await U.markAllAsRead(), M({
61
- title: v("notifications.v3.markedAll", "Marked {{count}} as read", { count: U.unreadCount || e.length }),
48
+ function F() {
49
+ let v = t(), T = y(), N = A(), P = n(), { tools: F } = i(), { hasPermission: L, isLoading: R } = h(), [z, B] = b(), V = z.get("send") === "1" && !R && r("send", L), H = c(z.get("tab")), U = z.get("open"), W = e({
50
+ baseFilter: j[H],
51
+ unreadFilter: M
52
+ }), G = d(), K = m(() => H === "action" ? W.notifications.filter(s) : W.notifications, [W.notifications, H]), q = W.notificationFilter.search ?? "", J = (e) => {
53
+ let t = new URLSearchParams(z);
54
+ e ? t.set("open", e) : t.delete("open"), B(t);
55
+ }, Y = (e) => {
56
+ let t = new URLSearchParams(z);
57
+ e ? t.set(p, "1") : t.delete(p), B(t);
58
+ }, X = async () => {
59
+ let e = W.allNotifications.filter(o).map((e) => e.id), t = e.length >= W.unreadCount;
60
+ await W.markAllAsRead(), N({
61
+ title: v("notifications.v3.markedAll", "Marked {{count}} as read", { count: W.unreadCount || e.length }),
62
62
  tone: "success",
63
63
  undo: t && e.length > 0 ? async () => {
64
- await W(e), await U.refetch();
64
+ await G(e), await W.refetch();
65
65
  } : void 0
66
66
  });
67
- }, X = {
67
+ }, Z = {
68
68
  all: v("notifications.v3.tab.all", "All"),
69
69
  unread: v("notifications.v3.tab.unread", "Unread"),
70
70
  action: v("notifications.v3.tab.action", "Needs action"),
71
71
  archived: v("notifications.v3.tab.archived", "Archived")
72
72
  };
73
- return /* @__PURE__ */ S("div", {
74
- "data-account-pages-v2": "notifications",
75
- className: "flex w-full min-w-0 flex-col",
76
- children: [
77
- /* @__PURE__ */ x(C, {
78
- variant: "compact",
79
- title: v("notifications.v3.title", "Notifications"),
80
- description: v("notifications.v3.purpose", "Everything that needs you, and everything you were told."),
81
- primary: /* @__PURE__ */ S(w, {
82
- variant: "outline",
83
- disabled: U.unreadCount === 0,
84
- onClick: () => void Y(),
85
- "data-testid": "inbox-mark-all",
86
- children: [/* @__PURE__ */ x(g, { "aria-hidden": "true" }), v("notifications.v3.markAll", "Mark all as read")]
87
- }),
88
- settings: {
89
- label: v("notifications.v3.settings", "Notification settings"),
90
- onClick: () => T(N.preferences)
91
- },
92
- more: P.map((e) => e.id === "send" ? {
93
- id: e.id,
94
- label: v("notifications.v3.send.title", "Send a notification"),
95
- onSelect: () => J(!0)
96
- } : {
97
- id: e.id,
98
- label: e.label,
99
- onSelect: () => T(e.href)
100
- })
73
+ return /* @__PURE__ */ S(k, { children: [
74
+ /* @__PURE__ */ x(C, {
75
+ variant: "compact",
76
+ title: v("notifications.v3.title", "Notifications"),
77
+ description: v("notifications.v3.purpose", "Everything that needs you, and everything you were told."),
78
+ primary: /* @__PURE__ */ S(w, {
79
+ variant: "outline",
80
+ disabled: W.unreadCount === 0,
81
+ onClick: () => void X(),
82
+ "data-testid": "inbox-mark-all",
83
+ children: [/* @__PURE__ */ x(g, { "aria-hidden": "true" }), v("notifications.v3.markAll", "Mark all as read")]
101
84
  }),
102
- /* @__PURE__ */ x(O, {
103
- ariaLabel: v("notifications.v3.title", "Notifications"),
104
- activeId: V,
105
- tabs: a.map((e) => ({
106
- id: e,
107
- label: X[e],
108
- href: `?tab=${e}`,
109
- badge: e === "unread" && U.unreadCount > 0 ? U.unreadCount : void 0
110
- }))
111
- }),
112
- /* @__PURE__ */ S("div", {
113
- className: "mt-4 flex flex-col gap-3",
114
- children: [
115
- /* @__PURE__ */ S("label", {
116
- className: "relative block max-w-md",
117
- children: [
118
- /* @__PURE__ */ x("span", {
119
- className: "sr-only",
120
- children: v("notifications.v3.search", "Search notifications")
121
- }),
122
- /* @__PURE__ */ x(_, {
123
- className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
124
- "aria-hidden": "true"
125
- }),
126
- /* @__PURE__ */ x(E, {
127
- type: "search",
128
- className: "pl-9",
129
- value: K,
130
- placeholder: v("notifications.v3.search", "Search notifications"),
131
- onChange: (e) => U.updateFilter({ search: e.target.value }),
132
- "data-testid": "inbox-search"
133
- })
134
- ]
135
- }),
136
- U.error && G.length === 0 ? /* @__PURE__ */ x(D, {
137
- what: v("notifications.v3.title", "Notifications"),
138
- error: U.error,
139
- onRetry: () => void U.refetch()
140
- }) : !U.isLoading && G.length === 0 ? /* @__PURE__ */ x(F, {
141
- tab: V,
142
- searching: !!K.trim()
143
- }) : /* @__PURE__ */ x(l, {
144
- notifications: G,
145
- loading: U.isLoading && G.length === 0,
146
- onOpen: (e) => {
147
- q(e);
148
- let t = G.find((t) => t.id === e);
149
- t && o(t) && U.markAsRead(e);
150
- },
151
- onMarkRead: (e) => void U.markAsRead(e),
152
- onMarkUnread: (e) => void W([e]).then(() => U.refetch()),
153
- onArchive: (e) => void U.archiveNotification(e),
154
- onRestore: (e) => void U.unarchiveNotification(e)
155
- }),
156
- U.hasMore ? /* @__PURE__ */ x("div", {
157
- className: "flex justify-center",
158
- children: /* @__PURE__ */ x(w, {
159
- variant: "ghost",
160
- busy: U.isLoadingMore,
161
- onClick: () => void U.loadMore(),
162
- "data-testid": "inbox-more",
163
- children: v("notifications.v3.more", "Show more")
85
+ settings: {
86
+ label: v("notifications.v3.settings", "Notification settings"),
87
+ onClick: () => T(P.preferences)
88
+ },
89
+ more: F.map((e) => e.id === "send" ? {
90
+ id: e.id,
91
+ label: v("notifications.v3.send.title", "Send a notification"),
92
+ onSelect: () => Y(!0)
93
+ } : {
94
+ id: e.id,
95
+ label: e.label,
96
+ onSelect: () => T(e.href)
97
+ })
98
+ }),
99
+ /* @__PURE__ */ x(O, {
100
+ ariaLabel: v("notifications.v3.title", "Notifications"),
101
+ activeId: H,
102
+ tabs: a.map((e) => ({
103
+ id: e,
104
+ label: Z[e],
105
+ href: `?tab=${e}`,
106
+ badge: e === "unread" && W.unreadCount > 0 ? W.unreadCount : void 0
107
+ }))
108
+ }),
109
+ /* @__PURE__ */ S("div", {
110
+ className: "flex flex-col gap-3",
111
+ children: [
112
+ /* @__PURE__ */ S("label", {
113
+ className: "relative block max-w-md",
114
+ children: [
115
+ /* @__PURE__ */ x("span", {
116
+ className: "sr-only",
117
+ children: v("notifications.v3.search", "Search notifications")
118
+ }),
119
+ /* @__PURE__ */ x(_, {
120
+ className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
121
+ "aria-hidden": "true"
122
+ }),
123
+ /* @__PURE__ */ x(E, {
124
+ type: "search",
125
+ className: "pl-9",
126
+ value: q,
127
+ placeholder: v("notifications.v3.search", "Search notifications"),
128
+ onChange: (e) => W.updateFilter({ search: e.target.value }),
129
+ "data-testid": "inbox-search"
164
130
  })
165
- }) : null
166
- ]
167
- }),
168
- /* @__PURE__ */ x(u, {
169
- id: H,
170
- onClose: () => q(null),
171
- inboxActions: {
172
- markUnread: (e) => void W([e]).then(() => U.refetch()),
173
- archive: (e) => {
174
- U.archiveNotification(e), q(null);
131
+ ]
132
+ }),
133
+ W.error && K.length === 0 ? /* @__PURE__ */ x(D, {
134
+ what: v("notifications.v3.title", "Notifications"),
135
+ error: W.error,
136
+ onRetry: () => void W.refetch()
137
+ }) : !W.isLoading && K.length === 0 ? /* @__PURE__ */ x(I, {
138
+ tab: H,
139
+ searching: !!q.trim()
140
+ }) : /* @__PURE__ */ x(l, {
141
+ notifications: K,
142
+ loading: W.isLoading && K.length === 0,
143
+ onOpen: (e) => {
144
+ J(e);
145
+ let t = K.find((t) => t.id === e);
146
+ t && o(t) && W.markAsRead(e);
175
147
  },
176
- restore: (e) => void U.unarchiveNotification(e)
177
- }
178
- }),
179
- /* @__PURE__ */ x(f, {
180
- open: B,
181
- onClose: () => J(!1)
182
- })
183
- ]
184
- });
148
+ onMarkRead: (e) => void W.markAsRead(e),
149
+ onMarkUnread: (e) => void G([e]).then(() => W.refetch()),
150
+ onArchive: (e) => void W.archiveNotification(e),
151
+ onRestore: (e) => void W.unarchiveNotification(e)
152
+ }),
153
+ W.hasMore ? /* @__PURE__ */ x("div", {
154
+ className: "flex justify-center",
155
+ children: /* @__PURE__ */ x(w, {
156
+ variant: "ghost",
157
+ busy: W.isLoadingMore,
158
+ onClick: () => void W.loadMore(),
159
+ "data-testid": "inbox-more",
160
+ children: v("notifications.v3.more", "Show more")
161
+ })
162
+ }) : null
163
+ ]
164
+ }),
165
+ /* @__PURE__ */ x(u, {
166
+ id: U,
167
+ onClose: () => J(null),
168
+ inboxActions: {
169
+ markUnread: (e) => void G([e]).then(() => W.refetch()),
170
+ archive: (e) => {
171
+ W.archiveNotification(e), J(null);
172
+ },
173
+ restore: (e) => void W.unarchiveNotification(e)
174
+ }
175
+ }),
176
+ /* @__PURE__ */ x(f, {
177
+ open: V,
178
+ onClose: () => Y(!1)
179
+ })
180
+ ] });
185
181
  }
186
- function F({ tab: e, searching: n }) {
182
+ function I({ tab: e, searching: n }) {
187
183
  let r = t();
188
184
  if (n) return /* @__PURE__ */ x(T, {
189
185
  kind: "no-results",
@@ -202,6 +198,6 @@ function F({ tab: e, searching: n }) {
202
198
  description: a
203
199
  });
204
200
  }
205
- export { N as InboxPage };
201
+ export { P as InboxPage };
206
202
 
207
203
  //# sourceMappingURL=InboxPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","navigate","useNavigate","notify","useNotify","useAdminTools","permissionsLoading","usePermissions","setParams","sendOpen","holdsAdminToolPermission","hasPermission","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","showSend","show","SEND_PARAM","markAll","unreadIds","isUnread","n","everyOne","tabLabel","PageHeader","Button","CheckCheck","tools","tool","PageTabs","INBOX_TABS","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","SendNotificationDialog","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send a\n * notification (a dialog, `?send=1`), Templates, Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { Button, EmptyState, Input, LoadError, PageTabs, useNotify } from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { holdsAdminToolPermission, useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\nimport { SendNotificationDialog } from './send/SendNotificationDialog';\nimport { SEND_PARAM } from './send/sendModel';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const [params, setParams] = useSearchParams();\n // Send a notification (C2b): a dialog over the inbox, for whoever may send.\n const sendOpen =\n params.get(SEND_PARAM) === '1' &&\n !permissionsLoading &&\n holdsAdminToolPermission('send', hasPermission);\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const showSend = (show: boolean) => {\n const next = new URLSearchParams(params);\n if (show) next.set(SEND_PARAM, '1');\n else next.delete(SEND_PARAM);\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <div data-account-pages-v2=\"notifications\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n disabled={inbox.unreadCount === 0}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) =>\n tool.id === 'send'\n ? {\n id: tool.id,\n label: tr('notifications.v3.send.title', 'Send a notification'),\n onSelect: () => showSend(true),\n }\n : { id: tool.id, label: tool.label, onSelect: () => navigate(tool.href) }\n )}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <div className=\"mt-4 flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n if (notification && isUnread(notification)) void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n inboxActions={{\n markUnread: (id) => void markUnread([id]).then(() => inbox.refetch()),\n archive: (id) => {\n void inbox.archiveNotification(id);\n open(null);\n },\n restore: (id) => void inbox.unarchiveNotification(id),\n }}\n />\n <SendNotificationDialog open={sendOpen} onClose={() => showSend(false)} />\n </div>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;EAAO,SAAS;CAAS;CAC7C,UAAU;EAAE,UAAU;EAAM,SAAS;CAAS;AAChD,GACMC,IAAgB,EAAE,SAAS,SAAS;AAG1C,SAASC,EACP,GACA,GACe;CAKf,OAJIC,MAAQ,SAAeC,EAAM,OAC7BD,MAAQ,cAAoBC,EAAM,YAClCD,MAAQ,WAAiBC,EAAM,SAC/BD,MAAQ,YAAkBC,EAAM,cAC7B;AACT;AAEA,SAAgBC,IAAY;CAC1B,IAAMD,IAAQE,EAAqB,GAC7B,CAACC,KAAUC,EAAgB,GAC3BC,IAASP,EAAaK,EAAO,IAAI,KAAK,GAAGH,CAAK;CAEpD,OADIK,IAAe,kBAACC,GAAD;EAAU,IAAID;EAAQ,SAAA;CAAS,CAAA,IAC3C,kBAACV,GAAD,CAAQ,CAAA;AACjB;AAEA,SAASA,IAAQ;CACf,IAAMa,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAASC,EAAU,GACnBb,IAAQE,EAAqB,GAC7B,EAAE,aAAUY,EAAc,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AeS,EAAK,IAAI;IACxB,cAAc;KACZ,aAAa,MAAO,KAAKN,EAAW,CAACQ,CAAE,CAAC,CAAC,CAAC,WAAWV,EAAM,QAAQ,CAAC;KACpE,UAAU,MAAO;MAEf,AADAA,EAAW,oBAAoBU,CAAE,GACjCF,EAAK,IAAI;KACX;KACA,UAAU,MAAO,KAAKR,EAAM,sBAAsBU,CAAE;IACtD;GACD,CAAA;GACD,kBAACyB,GAAD;IAAwB,MAAMxC;IAAU,eAAegB,EAAS,EAAK;GAAI,CAAA;EACtE;;AAET;AAEA,SAASoB,EAAW,EAAE,QAAK,gBAAoD;CAC7E,IAAM9C,IAAKC,EAAM;CACjB,IAAIkD,GACF,OACE,kBAACC,GAAD;EACE,MAAK;EACL,OAAOpD,EAAG,sCAAsC,wBAAwB;EACxE,aAAaA,EAAG,qCAAqC,kBAAkB;CACxE,CAAA;CAwBL,IAAM,CAACqD,GAAOC,KAAe;EApB3B,KAAK,CACHtD,EAAG,mCAAmC,sBAAsB,GAC5DA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAAC6D,GAAD;EACE,MAAM7D,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
1
+ {"version":3,"file":"InboxPage.js","names":["Inbox","TAB_FILTERS","UNREAD_FILTER","oldTabTarget","tab","paths","InboxPage","useNotificationPaths","params","useSearchParams","target","Navigate","Inbox$1","tr","useTr","navigate","useNavigate","notify","useNotify","useAdminTools","permissionsLoading","usePermissions","setParams","sendOpen","holdsAdminToolPermission","hasPermission","readInboxTab","openId","inbox","useNotifications","markUnread","useMarkUnread","shown","useMemo","needsAction","search","open","next","id","showSend","show","SEND_PARAM","markAll","unreadIds","isUnread","n","everyOne","tabLabel","WorkspacePage","PageHeader","Button","CheckCheck","tools","tool","PageTabs","INBOX_TABS","Search","Input","event","LoadError","InboxEmpty","InboxRows","notification","NotificationDetailPanel","SendNotificationDialog","searching","EmptyState","title","description"],"sources":["../../src/v2/InboxPage.tsx"],"sourcesContent":["/**\n * Notifications (BOFF-16785, C1; the mockup's `notif`), under fe-libs' `accountPagesV2`: the inbox\n * at the list width, tabs All · Unread · Needs action · Archived (`?tab=`), compact rows grouped by\n * day, \"Mark all as read\" with Undo, the settings under the gear and, for admins, Send a\n * notification (a dialog, `?send=1`), Templates, Topics and the Delivery log in ⋯. A row opens its panel (`?open=<id>`, decision 10). The same\n * queries as the inbox today (`useNotifications`).\n */\nimport { useMemo } from 'react';\nimport { Navigate, useNavigate, useSearchParams } from 'react-router';\nimport { CheckCheck, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n EmptyState,\n Input,\n LoadError,\n PageTabs,\n WorkspacePage,\n useNotify,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotifications } from '../hooks';\nimport type { NotificationFilter } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { holdsAdminToolPermission, useAdminTools } from '../navigation-v2/useAdminTools';\nimport { INBOX_TABS, isUnread, needsAction, readInboxTab, type InboxTab } from './model/inbox';\nimport { InboxRows } from './InboxRows';\nimport { NotificationDetailPanel } from './NotificationDetailPanel';\nimport { useMarkUnread } from './useNotificationDetail';\nimport { SendNotificationDialog } from './send/SendNotificationDialog';\nimport { SEND_PARAM } from './send/sendModel';\n\n/** What each tab asks the service for: the in-app inbox, archived or not, unread or not. */\nconst TAB_FILTERS: Record<InboxTab, Partial<NotificationFilter>> = {\n all: { archived: false, channel: 'IN_APP' },\n unread: { archived: false, channel: 'IN_APP', isRead: false },\n action: { archived: false, channel: 'IN_APP' },\n archived: { archived: true, channel: 'IN_APP' },\n};\nconst UNREAD_FILTER = { channel: 'IN_APP' };\n\n/** Where today's `?tab=` values still go (the round-1 landing's links). */\nfunction oldTabTarget(\n tab: string | null,\n paths: ReturnType<typeof useNotificationPaths>\n): string | null {\n if (tab === 'send') return paths.send;\n if (tab === 'templates') return paths.templates;\n if (tab === 'topics') return paths.topics;\n if (tab === 'history') return paths.deliveryLog;\n return null;\n}\n\nexport function InboxPage() {\n const paths = useNotificationPaths();\n const [params] = useSearchParams();\n const target = oldTabTarget(params.get('tab'), paths);\n if (target) return <Navigate to={target} replace />;\n return <Inbox />;\n}\n\nfunction Inbox() {\n const tr = useTr();\n const navigate = useNavigate();\n const notify = useNotify();\n const paths = useNotificationPaths();\n const { tools } = useAdminTools();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const [params, setParams] = useSearchParams();\n // Send a notification (C2b): a dialog over the inbox, for whoever may send.\n const sendOpen =\n params.get(SEND_PARAM) === '1' &&\n !permissionsLoading &&\n holdsAdminToolPermission('send', hasPermission);\n const tab = readInboxTab(params.get('tab'));\n const openId = params.get('open');\n const inbox = useNotifications({ baseFilter: TAB_FILTERS[tab], unreadFilter: UNREAD_FILTER });\n const markUnread = useMarkUnread();\n const shown = useMemo(\n () => (tab === 'action' ? inbox.notifications.filter(needsAction) : inbox.notifications),\n [inbox.notifications, tab]\n );\n const search = inbox.notificationFilter.search ?? '';\n\n const open = (id: string | null) => {\n const next = new URLSearchParams(params);\n if (id) next.set('open', id);\n else next.delete('open');\n setParams(next);\n };\n\n const showSend = (show: boolean) => {\n const next = new URLSearchParams(params);\n if (show) next.set(SEND_PARAM, '1');\n else next.delete(SEND_PARAM);\n setParams(next);\n };\n\n const markAll = async () => {\n // Undo can only bring back what's loaded: offer it when every unread one is on the page.\n const unreadIds = inbox.allNotifications.filter(isUnread).map((n) => n.id);\n const everyOne = unreadIds.length >= inbox.unreadCount;\n await inbox.markAllAsRead();\n notify({\n title: tr('notifications.v3.markedAll', 'Marked {{count}} as read', {\n count: inbox.unreadCount || unreadIds.length,\n }),\n tone: 'success',\n undo:\n everyOne && unreadIds.length > 0\n ? async () => {\n await markUnread(unreadIds);\n await inbox.refetch();\n }\n : undefined,\n });\n };\n\n const tabLabel: Record<InboxTab, string> = {\n all: tr('notifications.v3.tab.all', 'All'),\n unread: tr('notifications.v3.tab.unread', 'Unread'),\n action: tr('notifications.v3.tab.action', 'Needs action'),\n archived: tr('notifications.v3.tab.archived', 'Archived'),\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr(\n 'notifications.v3.purpose',\n 'Everything that needs you, and everything you were told.'\n )}\n primary={\n <Button\n variant=\"outline\"\n disabled={inbox.unreadCount === 0}\n onClick={() => void markAll()}\n data-testid=\"inbox-mark-all\"\n >\n <CheckCheck aria-hidden=\"true\" />\n {tr('notifications.v3.markAll', 'Mark all as read')}\n </Button>\n }\n settings={{\n label: tr('notifications.v3.settings', 'Notification settings'),\n onClick: () => navigate(paths.preferences),\n }}\n more={tools.map((tool) =>\n tool.id === 'send'\n ? {\n id: tool.id,\n label: tr('notifications.v3.send.title', 'Send a notification'),\n onSelect: () => showSend(true),\n }\n : { id: tool.id, label: tool.label, onSelect: () => navigate(tool.href) }\n )}\n />\n <PageTabs\n ariaLabel={tr('notifications.v3.title', 'Notifications')}\n activeId={tab}\n tabs={INBOX_TABS.map((id) => ({\n id,\n label: tabLabel[id],\n href: `?tab=${id}`,\n badge: id === 'unread' && inbox.unreadCount > 0 ? inbox.unreadCount : undefined,\n }))}\n />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">{tr('notifications.v3.search', 'Search notifications')}</span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.search', 'Search notifications')}\n onChange={(event) => inbox.updateFilter({ search: event.target.value })}\n data-testid=\"inbox-search\"\n />\n </label>\n {inbox.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.title', 'Notifications')}\n error={inbox.error}\n onRetry={() => void inbox.refetch()}\n />\n ) : !inbox.isLoading && shown.length === 0 ? (\n <InboxEmpty tab={tab} searching={Boolean(search.trim())} />\n ) : (\n <InboxRows\n notifications={shown}\n loading={inbox.isLoading && shown.length === 0}\n onOpen={(id) => {\n open(id);\n const notification = shown.find((n) => n.id === id);\n if (notification && isUnread(notification)) void inbox.markAsRead(id);\n }}\n onMarkRead={(id) => void inbox.markAsRead(id)}\n onMarkUnread={(id) => void markUnread([id]).then(() => inbox.refetch())}\n onArchive={(id) => void inbox.archiveNotification(id)}\n onRestore={(id) => void inbox.unarchiveNotification(id)}\n />\n )}\n {inbox.hasMore ? (\n <div className=\"flex justify-center\">\n <Button\n variant=\"ghost\"\n busy={inbox.isLoadingMore}\n onClick={() => void inbox.loadMore()}\n data-testid=\"inbox-more\"\n >\n {tr('notifications.v3.more', 'Show more')}\n </Button>\n </div>\n ) : null}\n </div>\n <NotificationDetailPanel\n id={openId}\n onClose={() => open(null)}\n inboxActions={{\n markUnread: (id) => void markUnread([id]).then(() => inbox.refetch()),\n archive: (id) => {\n void inbox.archiveNotification(id);\n open(null);\n },\n restore: (id) => void inbox.unarchiveNotification(id),\n }}\n />\n <SendNotificationDialog open={sendOpen} onClose={() => showSend(false)} />\n </WorkspacePage>\n );\n}\n\nfunction InboxEmpty({ tab, searching }: { tab: InboxTab; searching: boolean }) {\n const tr = useTr();\n if (searching) {\n return (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.empty.searchTitle', 'No notifications match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n );\n }\n const words: Record<InboxTab, [string, string]> = {\n all: [\n tr('notifications.v3.empty.allTitle', 'You’re all caught up'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n unread: [\n tr('notifications.v3.empty.unreadTitle', 'Nothing unread'),\n tr('notifications.v3.empty.allBody', 'New notifications show up here and on the bell.'),\n ],\n action: [\n tr('notifications.v3.empty.actionTitle', 'Nothing waiting for you'),\n tr('notifications.v3.empty.actionBody', 'Approvals and requests show up here.'),\n ],\n archived: [\n tr('notifications.v3.empty.archivedTitle', 'Nothing archived'),\n tr(\n 'notifications.v3.empty.archivedBody',\n 'Archive a notification to keep it out of the way. It stays here.'\n ),\n ],\n };\n const [title, description] = words[tab];\n return (\n <EmptyState\n kind={tab === 'archived' ? 'first-use' : 'all-done'}\n title={title}\n description={description}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,IAAMC,IAA6D;CACjE,KAAK;EAAE,UAAU;EAAO,SAAS;CAAS;CAC1C,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAU,QAAQ;CAAM;CAC5D,QAAQ;EAAE,UAAU;EAAO,SAAS;CAAS;CAC7C,UAAU;EAAE,UAAU;EAAM,SAAS;CAAS;AAChD,GACMC,IAAgB,EAAE,SAAS,SAAS;AAG1C,SAASC,EACP,GACA,GACe;CAKf,OAJIC,MAAQ,SAAeC,EAAM,OAC7BD,MAAQ,cAAoBC,EAAM,YAClCD,MAAQ,WAAiBC,EAAM,SAC/BD,MAAQ,YAAkBC,EAAM,cAC7B;AACT;AAEA,SAAgBC,IAAY;CAC1B,IAAMD,IAAQE,EAAqB,GAC7B,CAACC,KAAUC,EAAgB,GAC3BC,IAASP,EAAaK,EAAO,IAAI,KAAK,GAAGH,CAAK;CAEpD,OADIK,IAAe,kBAACC,GAAD;EAAU,IAAID;EAAQ,SAAA;CAAS,CAAA,IAC3C,kBAACV,GAAD,CAAQ,CAAA;AACjB;AAEA,SAASA,IAAQ;CACf,IAAMa,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAASC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,GAAD;GACE,IAAIpC;GACJ,eAAeS,EAAK,IAAI;GACxB,cAAc;IACZ,aAAa,MAAO,KAAKN,EAAW,CAACQ,CAAE,CAAC,CAAC,CAAC,WAAWV,EAAM,QAAQ,CAAC;IACpE,UAAU,MAAO;KAEf,AADAA,EAAW,oBAAoBU,CAAE,GACjCF,EAAK,IAAI;IACX;IACA,UAAU,MAAO,KAAKR,EAAM,sBAAsBU,CAAE;GACtD;EACD,CAAA;EACD,kBAAC0B,GAAD;GAAwB,MAAMzC;GAAU,eAAegB,EAAS,EAAK;EAAI,CAAA;CAC5D,EAAA,CAAA;AAEnB;AAEA,SAASqB,EAAW,EAAE,QAAK,gBAAoD;CAC7E,IAAM/C,IAAKC,EAAM;CACjB,IAAImD,GACF,OACE,kBAACC,GAAD;EACE,MAAK;EACL,OAAOrD,EAAG,sCAAsC,wBAAwB;EACxE,aAAaA,EAAG,qCAAqC,kBAAkB;CACxE,CAAA;CAwBL,IAAM,CAACsD,GAAOC,KAAe;EApB3B,KAAK,CACHvD,EAAG,mCAAmC,sBAAsB,GAC5DA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,gBAAgB,GACzDA,EAAG,kCAAkC,iDAAiD,CACxF;EACA,QAAQ,CACNA,EAAG,sCAAsC,yBAAyB,GAClEA,EAAG,qCAAqC,sCAAsC,CAChF;EACA,UAAU,CACRA,EAAG,wCAAwC,kBAAkB,GAC7DA,EACE,uCACA,kEACF,CACF;CAE2B,EAAMT;CACnC,OACE,kBAAC8D,GAAD;EACE,MAAM9D,MAAQ,aAAa,cAAc;EAClC;EACM;CACd,CAAA;AAEL"}
@@ -8,98 +8,94 @@ import { Bell as u, BellOff as d, Check as f, Inbox as p, Megaphone as m, Search
8
8
  import { useNavigate as _ } from "react-router";
9
9
  import { jsx as v, jsxs as y } from "react/jsx-runtime";
10
10
  import { PageHeader as b, PushOptInToggle as x } from "@burdenoff/fe-libs/chrome";
11
- import { Button as S, Input as C, SettingRow as w, SettingsSection as T, Switch as E } from "@burdenoff/fe-libs/ui";
11
+ import { Button as S, Input as C, SettingRow as w, SettingsSection as T, Switch as E, WorkspacePage as D } from "@burdenoff/fe-libs/ui";
12
12
  // src/v2/PreferencesPage.tsx
13
- function D() {
14
- let f = r(), g = _(), w = i(), E = n(), { topics: D, isLoading: k, isForbidden: A } = e({
13
+ function O() {
14
+ let f = r(), g = _(), w = i(), E = n(), { topics: O, isLoading: A, isForbidden: j } = e({
15
15
  type: "MARKETING",
16
16
  isActive: !0
17
- }), [j, M] = l(""), N = c(() => {
18
- let e = j.trim().toLowerCase();
19
- return e ? D.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : D;
20
- }, [j, D]), P = E.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, F = (e, n, r = {}) => /* @__PURE__ */ v(O, {
17
+ }), [M, N] = l(""), P = c(() => {
18
+ let e = M.trim().toLowerCase();
19
+ return e ? O.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : O;
20
+ }, [M, O]), F = E.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, I = (e, n, r = {}) => /* @__PURE__ */ v(k, {
21
21
  target: e,
22
22
  label: n,
23
23
  options: r,
24
24
  toggles: E
25
25
  }, t(e));
26
- return /* @__PURE__ */ y("div", {
27
- "data-account-pages-v2": "notification-settings",
28
- className: "flex w-full min-w-0 flex-col",
29
- children: [/* @__PURE__ */ v(b, {
30
- variant: "compact",
31
- title: f("notifications.v3.title", "Notifications"),
32
- description: f("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
33
- secondary: /* @__PURE__ */ y(S, {
34
- variant: "outline",
35
- onClick: () => g(w.inbox),
36
- children: [/* @__PURE__ */ v(p, { "aria-hidden": "true" }), f("notifications.v3.prefs.openInbox", "Open the inbox")]
37
- })
38
- }), /* @__PURE__ */ y("div", {
39
- className: "flex flex-col gap-4",
40
- children: [
41
- /* @__PURE__ */ v(T, {
42
- icon: d,
43
- title: f("notifications.v3.prefs.pauseTitle", "Pause everything"),
44
- children: F({ scope: "GLOBAL" }, f("notifications.v3.prefs.pause", "Pause notifications"), {
45
- description: P ? f("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : f("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
46
- inverted: !0
47
- })
48
- }),
49
- /* @__PURE__ */ y(T, {
50
- icon: u,
51
- title: f("notifications.v3.prefs.whereTitle", "Where you hear from us"),
52
- children: [[...a, ...o].map((e) => F({
53
- scope: "CHANNEL",
54
- channel: e.value
55
- }, f(e.labelKey, e.label))), /* @__PURE__ */ v("div", {
56
- className: "px-1 py-2",
57
- children: /* @__PURE__ */ v(x, {})
58
- })]
59
- }),
60
- /* @__PURE__ */ v(T, {
61
- icon: p,
62
- title: f("notifications.v3.prefs.whatTitle", "What you hear about"),
63
- children: s.map((e) => F({
64
- scope: "TYPE",
65
- type: e.value
66
- }, f(e.labelKey, e.label)))
67
- }),
68
- !k && !A && D.length > 0 ? /* @__PURE__ */ y(T, {
69
- icon: m,
70
- title: f("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
71
- children: [D.length > 5 ? /* @__PURE__ */ y("label", {
72
- className: "relative block px-1 py-2",
73
- children: [
74
- /* @__PURE__ */ v("span", {
75
- className: "sr-only",
76
- children: f("notifications.searchTopics", "Search topics...")
77
- }),
78
- /* @__PURE__ */ v(h, {
79
- className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
80
- "aria-hidden": "true"
81
- }),
82
- /* @__PURE__ */ v(C, {
83
- type: "search",
84
- className: "pl-9",
85
- value: j,
86
- placeholder: f("notifications.searchTopics", "Search topics..."),
87
- onChange: (e) => M(e.target.value)
88
- })
89
- ]
90
- }) : null, N.length === 0 ? /* @__PURE__ */ v("p", {
91
- className: "m-0 px-1 py-2 text-sm text-text-secondary",
92
- children: f("notifications.noTopicsFound", "No topics match your search")
93
- }) : N.map((e) => F({
94
- scope: "TOPIC",
95
- topicId: e.id
96
- }, e.name, { description: e.description || void 0 }))]
97
- }) : null
98
- ]
99
- })]
100
- });
26
+ return /* @__PURE__ */ y(D, { children: [/* @__PURE__ */ v(b, {
27
+ variant: "compact",
28
+ title: f("notifications.v3.title", "Notifications"),
29
+ description: f("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
30
+ secondary: /* @__PURE__ */ y(S, {
31
+ variant: "outline",
32
+ onClick: () => g(w.inbox),
33
+ children: [/* @__PURE__ */ v(p, { "aria-hidden": "true" }), f("notifications.v3.prefs.openInbox", "Open the inbox")]
34
+ })
35
+ }), /* @__PURE__ */ y("div", {
36
+ className: "flex flex-col gap-4",
37
+ children: [
38
+ /* @__PURE__ */ v(T, {
39
+ icon: d,
40
+ title: f("notifications.v3.prefs.pauseTitle", "Pause everything"),
41
+ children: I({ scope: "GLOBAL" }, f("notifications.v3.prefs.pause", "Pause notifications"), {
42
+ description: F ? f("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : f("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
43
+ inverted: !0
44
+ })
45
+ }),
46
+ /* @__PURE__ */ y(T, {
47
+ icon: u,
48
+ title: f("notifications.v3.prefs.whereTitle", "Where you hear from us"),
49
+ children: [[...a, ...o].map((e) => I({
50
+ scope: "CHANNEL",
51
+ channel: e.value
52
+ }, f(e.labelKey, e.label))), /* @__PURE__ */ v("div", {
53
+ className: "px-1 py-2",
54
+ children: /* @__PURE__ */ v(x, {})
55
+ })]
56
+ }),
57
+ /* @__PURE__ */ v(T, {
58
+ icon: p,
59
+ title: f("notifications.v3.prefs.whatTitle", "What you hear about"),
60
+ children: s.map((e) => I({
61
+ scope: "TYPE",
62
+ type: e.value
63
+ }, f(e.labelKey, e.label)))
64
+ }),
65
+ !A && !j && O.length > 0 ? /* @__PURE__ */ y(T, {
66
+ icon: m,
67
+ title: f("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
68
+ children: [O.length > 5 ? /* @__PURE__ */ y("label", {
69
+ className: "relative block px-1 py-2",
70
+ children: [
71
+ /* @__PURE__ */ v("span", {
72
+ className: "sr-only",
73
+ children: f("notifications.searchTopics", "Search topics...")
74
+ }),
75
+ /* @__PURE__ */ v(h, {
76
+ className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
77
+ "aria-hidden": "true"
78
+ }),
79
+ /* @__PURE__ */ v(C, {
80
+ type: "search",
81
+ className: "pl-9",
82
+ value: M,
83
+ placeholder: f("notifications.searchTopics", "Search topics..."),
84
+ onChange: (e) => N(e.target.value)
85
+ })
86
+ ]
87
+ }) : null, P.length === 0 ? /* @__PURE__ */ v("p", {
88
+ className: "m-0 px-1 py-2 text-sm text-text-secondary",
89
+ children: f("notifications.noTopicsFound", "No topics match your search")
90
+ }) : P.map((e) => I({
91
+ scope: "TOPIC",
92
+ topicId: e.id
93
+ }, e.name, { description: e.description || void 0 }))]
94
+ }) : null
95
+ ]
96
+ })] });
101
97
  }
102
- function O({ target: e, label: n, options: i, toggles: a }) {
98
+ function k({ target: e, label: n, options: i, toggles: a }) {
103
99
  let o = r(), s = t(e), c = a.preferencesByKey.get(s), l = c?.enabled ?? !0, u = a.saveFeedback?.key === s ? a.saveFeedback : null, d = i.description;
104
100
  if (u) {
105
101
  let e = u.type === "success" ? f : g;
@@ -134,6 +130,6 @@ function O({ target: e, label: n, options: i, toggles: a }) {
134
130
  })
135
131
  });
136
132
  }
137
- export { D as PreferencesPage };
133
+ export { O as PreferencesPage };
138
134
 
139
135
  //# sourceMappingURL=PreferencesPage.js.map