@burdenoff/microfe-notification 2026.1202.1 → 2026.1202.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.
@@ -1,205 +1,209 @@
1
1
  import { useTr as e } from "../shared/hooks/useTr.js";
2
- import { navigateInApp as t } from "../utils/inAppNavigation.js";
3
- import { mapBackendToMfeNotification as n } from "../hooks/useNotifications.js";
4
- import { needsAction as r } from "./model/inbox.js";
5
- import { KindIcon as i } from "./KindIcon.js";
6
- import { notificationThing as a, thingFacts as o } from "./model/thing.js";
7
- import { timeline as s } from "./model/events.js";
8
- import { useNotificationDetail as c } from "./useNotificationDetail.js";
9
- import { ArrowUpRight as l, CheckCircle2 as u, Clock as d, Workflow as f, XCircle as p } from "lucide-react";
10
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { Button as g, DetailPanel as _, IconTile as v, LoadError as y, Skeleton as b, StatusChip as x, useWhenLabels as S } from "@burdenoff/fe-libs/ui";
2
+ import { useNeedsConnection as t, waitingButton as n } from "./useNeedsConnection.js";
3
+ import { navigateInApp as r } from "../utils/inAppNavigation.js";
4
+ import { mapBackendToMfeNotification as i } from "../hooks/useNotifications.js";
5
+ import { needsAction as a } from "./model/inbox.js";
6
+ import { KindIcon as o } from "./KindIcon.js";
7
+ import { notificationThing as s, thingFacts as c } from "./model/thing.js";
8
+ import { timeline as l } from "./model/events.js";
9
+ import { useNotificationDetail as u } from "./useNotificationDetail.js";
10
+ import { ArrowUpRight as d, CheckCircle2 as f, Clock as p, Workflow as m, XCircle as h } from "lucide-react";
11
+ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
12
+ import { Button as v, DetailPanel as y, IconTile as b, LoadError as x, Skeleton as S, StatusChip as C, useWhenLabels as w } from "@burdenoff/fe-libs/ui";
12
13
  // src/v2/NotificationDetailPanel.tsx
13
- function C(e) {
14
- t(e) || window.open(e, "_blank", "noopener,noreferrer");
14
+ function T(e) {
15
+ r(e) || window.open(e, "_blank", "noopener,noreferrer");
15
16
  }
16
- function w({ id: t, onClose: r, inboxActions: a }) {
17
- let o = e(), { state: s, retry: l } = c(t), u = s.status === "ready" ? s.notification : null, d = u ? n(u) : null, f = d && a ? /* @__PURE__ */ m(T, {
17
+ function E({ id: t, onClose: n, inboxActions: r }) {
18
+ let a = e(), { state: s, retry: c } = u(t), l = s.status === "ready" ? s.notification : null, d = l ? i(l) : null, f = d && r ? /* @__PURE__ */ g(D, {
18
19
  notification: d,
19
- actions: a
20
+ actions: r
20
21
  }) : void 0;
21
- return /* @__PURE__ */ m(_, {
22
+ return /* @__PURE__ */ g(y, {
22
23
  open: !!t,
23
- onOpenChange: (e) => e ? void 0 : r(),
24
- title: d?.title ?? o("notifications.v3.panel.loading", "Notification"),
25
- sub: d ? /* @__PURE__ */ m(D, { notification: d }) : void 0,
26
- tile: d ? /* @__PURE__ */ m(v, {
24
+ onOpenChange: (e) => e ? void 0 : n(),
25
+ title: d?.title ?? a("notifications.v3.panel.loading", "Notification"),
26
+ sub: d ? /* @__PURE__ */ g(k, { notification: d }) : void 0,
27
+ tile: d ? /* @__PURE__ */ g(b, {
27
28
  size: "md",
28
- children: /* @__PURE__ */ m(i, { notification: d })
29
+ children: /* @__PURE__ */ g(o, { notification: d })
29
30
  }) : void 0,
30
- closeLabel: o("notifications.v3.panel.close", "Close"),
31
+ closeLabel: a("notifications.v3.panel.close", "Close"),
31
32
  "data-testid": "notification-panel",
32
33
  footer: f,
33
- children: /* @__PURE__ */ m(E, {
34
+ children: /* @__PURE__ */ g(O, {
34
35
  state: s,
35
- retry: l,
36
+ retry: c,
36
37
  notification: d
37
38
  })
38
39
  });
39
40
  }
40
- function T({ notification: t, actions: n }) {
41
- let r = e();
42
- return /* @__PURE__ */ h("div", {
41
+ function D({ notification: r, actions: i }) {
42
+ let a = e(), o = t();
43
+ return /* @__PURE__ */ _("div", {
43
44
  className: "flex w-full flex-wrap gap-2",
44
- children: [/* @__PURE__ */ m(g, {
45
+ children: [/* @__PURE__ */ g(v, {
45
46
  variant: "outline",
46
- onClick: () => n.markUnread(t.id),
47
- children: r("notifications.v3.markUnread", "Mark as unread")
48
- }), t.archivedAt ? /* @__PURE__ */ m(g, {
47
+ ...n(o),
48
+ onClick: () => i.markUnread(r.id),
49
+ children: a("notifications.v3.markUnread", "Mark as unread")
50
+ }), r.archivedAt ? /* @__PURE__ */ g(v, {
49
51
  variant: "ghost",
50
- onClick: () => n.restore(t.id),
51
- children: r("notifications.v3.restore", "Move back to the inbox")
52
- }) : /* @__PURE__ */ m(g, {
52
+ ...n(o),
53
+ onClick: () => i.restore(r.id),
54
+ children: a("notifications.v3.restore", "Move back to the inbox")
55
+ }) : /* @__PURE__ */ g(v, {
53
56
  variant: "ghost",
54
- onClick: () => n.archive(t.id),
55
- children: r("notifications.v3.archive", "Archive")
57
+ ...n(o),
58
+ onClick: () => i.archive(r.id),
59
+ children: a("notifications.v3.archive", "Archive")
56
60
  })]
57
61
  });
58
62
  }
59
- function E({ state: t, retry: n, notification: r }) {
63
+ function O({ state: t, retry: n, notification: r }) {
60
64
  let i = e();
61
- return t.status === "loading" ? /* @__PURE__ */ h("div", {
65
+ return t.status === "loading" ? /* @__PURE__ */ _("div", {
62
66
  className: "flex flex-col gap-3",
63
67
  "aria-busy": "true",
64
68
  children: [
65
- /* @__PURE__ */ m(b, { className: "h-4 w-3/4" }),
66
- /* @__PURE__ */ m(b, { className: "h-4 w-2/3" }),
67
- /* @__PURE__ */ m(b, { className: "h-24 w-full" })
69
+ /* @__PURE__ */ g(S, { className: "h-4 w-3/4" }),
70
+ /* @__PURE__ */ g(S, { className: "h-4 w-2/3" }),
71
+ /* @__PURE__ */ g(S, { className: "h-24 w-full" })
68
72
  ]
69
- }) : t.status === "failed" ? /* @__PURE__ */ m(y, {
73
+ }) : t.status === "failed" ? /* @__PURE__ */ g(x, {
70
74
  what: i("notifications.v3.panel.what", "This notification"),
71
75
  error: t.error,
72
76
  onRetry: n
73
- }) : t.status !== "ready" || !r ? /* @__PURE__ */ m("p", {
77
+ }) : t.status !== "ready" || !r ? /* @__PURE__ */ g("p", {
74
78
  className: "m-0 text-sm text-text-secondary",
75
79
  children: i("notifications.v3.panel.missing", "This notification isn’t available any more. It may have been deleted.")
76
- }) : /* @__PURE__ */ m(O, {
80
+ }) : /* @__PURE__ */ g(A, {
77
81
  notification: r,
78
82
  data: t.notification
79
83
  });
80
84
  }
81
- function D({ notification: t }) {
82
- let n = e(), i = S();
83
- return /* @__PURE__ */ h("span", {
85
+ function k({ notification: t }) {
86
+ let n = e(), r = w();
87
+ return /* @__PURE__ */ _("span", {
84
88
  className: "flex flex-wrap items-center gap-2",
85
- children: [/* @__PURE__ */ m("time", {
89
+ children: [/* @__PURE__ */ g("time", {
86
90
  dateTime: t.createdAt,
87
- children: i.moment(t.createdAt)
88
- }), r(t) ? /* @__PURE__ */ m(x, {
91
+ children: r.moment(t.createdAt)
92
+ }), a(t) ? /* @__PURE__ */ g(C, {
89
93
  status: "warn",
90
94
  children: n("notifications.v3.needsYou", "Needs you")
91
95
  }) : null]
92
96
  });
93
97
  }
94
- function O({ notification: t, data: n }) {
95
- let r = e(), i = a(n.metadata), o = t.actions;
96
- return /* @__PURE__ */ h("div", {
98
+ function A({ notification: t, data: n }) {
99
+ let r = e(), i = s(n.metadata), a = t.actions;
100
+ return /* @__PURE__ */ _("div", {
97
101
  className: "flex flex-col gap-5",
98
102
  children: [
99
- /* @__PURE__ */ m("p", {
103
+ /* @__PURE__ */ g("p", {
100
104
  className: "m-0 text-sm whitespace-pre-wrap text-text-primary",
101
105
  "data-testid": "panel-message",
102
106
  children: t.body
103
107
  }),
104
- i ? /* @__PURE__ */ m(k, {
108
+ i ? /* @__PURE__ */ g(j, {
105
109
  thing: i,
106
110
  actionUrl: t.actionUrl
107
111
  }) : null,
108
- o.length > 0 || t.actionUrl && !i ? /* @__PURE__ */ h("div", {
112
+ a.length > 0 || t.actionUrl && !i ? /* @__PURE__ */ _("div", {
109
113
  className: "flex flex-wrap gap-2",
110
114
  "data-testid": "panel-actions",
111
- children: [o.map((e, t) => /* @__PURE__ */ m(g, {
115
+ children: [a.map((e, t) => /* @__PURE__ */ g(v, {
112
116
  variant: t === 0 ? "default" : "outline",
113
- onClick: () => C(e.url),
117
+ onClick: () => T(e.url),
114
118
  children: e.label
115
- }, e.id)), o.length === 0 && t.actionUrl && !i ? /* @__PURE__ */ h(g, {
116
- onClick: () => C(t.actionUrl ?? ""),
117
- children: [/* @__PURE__ */ m(l, { "aria-hidden": "true" }), r("notifications.v3.panel.open", "Open where it happened")]
119
+ }, e.id)), a.length === 0 && t.actionUrl && !i ? /* @__PURE__ */ _(v, {
120
+ onClick: () => T(t.actionUrl ?? ""),
121
+ children: [/* @__PURE__ */ g(d, { "aria-hidden": "true" }), r("notifications.v3.panel.open", "Open where it happened")]
118
122
  }) : null]
119
123
  }) : null,
120
- /* @__PURE__ */ m(M, { events: n.events })
124
+ /* @__PURE__ */ g(P, { events: n.events })
121
125
  ]
122
126
  });
123
127
  }
124
- function k({ thing: t, actionUrl: n }) {
125
- let r = e(), i = S(), a = o(t, r);
126
- return /* @__PURE__ */ h("section", {
128
+ function j({ thing: t, actionUrl: n }) {
129
+ let r = e(), i = w(), a = c(t, r);
130
+ return /* @__PURE__ */ _("section", {
127
131
  className: "flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3",
128
132
  "aria-label": r("notifications.v3.thing.label", "What it’s about"),
129
133
  "data-testid": "panel-thing",
130
134
  children: [
131
- /* @__PURE__ */ h("div", {
135
+ /* @__PURE__ */ _("div", {
132
136
  className: "flex items-center gap-2",
133
- children: [/* @__PURE__ */ m(f, {
137
+ children: [/* @__PURE__ */ g(m, {
134
138
  className: "size-4 text-text-secondary",
135
139
  "aria-hidden": "true"
136
- }), /* @__PURE__ */ m("span", {
140
+ }), /* @__PURE__ */ g("span", {
137
141
  className: "text-sm font-semibold text-text-primary",
138
142
  children: t.workflowName
139
143
  })]
140
144
  }),
141
- a.length > 0 ? /* @__PURE__ */ m("dl", {
145
+ a.length > 0 ? /* @__PURE__ */ g("dl", {
142
146
  className: "m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm",
143
- children: a.map((e) => /* @__PURE__ */ h("div", {
147
+ children: a.map((e) => /* @__PURE__ */ _("div", {
144
148
  className: "contents",
145
- children: [/* @__PURE__ */ m("dt", {
149
+ children: [/* @__PURE__ */ g("dt", {
146
150
  className: "text-text-secondary",
147
151
  children: e.label
148
- }), /* @__PURE__ */ m("dd", {
152
+ }), /* @__PURE__ */ g("dd", {
149
153
  className: "m-0 text-text-primary",
150
154
  children: e.value
151
155
  })]
152
156
  }, e.id))
153
157
  }) : null,
154
- t.firstSeenAt ? /* @__PURE__ */ m("p", {
158
+ t.firstSeenAt ? /* @__PURE__ */ g("p", {
155
159
  className: "m-0 text-xs text-text-muted",
156
160
  children: r("notifications.v3.thing.firstSeen", "First seen {{when}}", { when: i.moment(t.firstSeenAt) })
157
161
  }) : null,
158
- n ? /* @__PURE__ */ m("div", { children: /* @__PURE__ */ m(g, {
162
+ n ? /* @__PURE__ */ g("div", { children: /* @__PURE__ */ g(v, {
159
163
  size: "sm",
160
164
  variant: "outline",
161
- onClick: () => C(n),
165
+ onClick: () => T(n),
162
166
  children: r("notifications.v3.thing.openRun", "Open the run")
163
167
  }) }) : null
164
168
  ]
165
169
  });
166
170
  }
167
- var A = {
168
- ok: u,
169
- bad: p,
170
- waiting: d,
171
- neutral: d
172
- }, j = {
171
+ var M = {
172
+ ok: f,
173
+ bad: h,
174
+ waiting: p,
175
+ neutral: p
176
+ }, N = {
173
177
  ok: "text-status-success-text",
174
178
  bad: "text-status-error-text",
175
179
  waiting: "text-status-warning-text",
176
180
  neutral: "text-text-muted"
177
181
  };
178
- function M({ events: t }) {
179
- let n = e(), r = S(), i = s(t, n);
180
- return i.length === 0 ? null : /* @__PURE__ */ h("section", {
182
+ function P({ events: t }) {
183
+ let n = e(), r = w(), i = l(t, n);
184
+ return i.length === 0 ? null : /* @__PURE__ */ _("section", {
181
185
  className: "flex flex-col gap-2",
182
186
  "aria-label": n("notifications.v3.timeline", "What happened"),
183
- children: [/* @__PURE__ */ m("h3", {
187
+ children: [/* @__PURE__ */ g("h3", {
184
188
  className: "m-0 text-xs font-medium text-text-muted",
185
189
  children: n("notifications.v3.timeline", "What happened")
186
- }), /* @__PURE__ */ m("ol", {
190
+ }), /* @__PURE__ */ g("ol", {
187
191
  className: "m-0 flex list-none flex-col gap-2 p-0",
188
192
  "data-testid": "panel-timeline",
189
193
  children: i.map((e) => {
190
- let t = A[e.tone];
191
- return /* @__PURE__ */ h("li", {
194
+ let t = M[e.tone];
195
+ return /* @__PURE__ */ _("li", {
192
196
  className: "flex items-center gap-2 text-sm",
193
197
  children: [
194
- /* @__PURE__ */ m(t, {
195
- className: `size-4 ${j[e.tone]}`,
198
+ /* @__PURE__ */ g(t, {
199
+ className: `size-4 ${N[e.tone]}`,
196
200
  "aria-hidden": "true"
197
201
  }),
198
- /* @__PURE__ */ m("span", {
202
+ /* @__PURE__ */ g("span", {
199
203
  className: "flex-1 text-text-primary",
200
204
  children: e.words
201
205
  }),
202
- /* @__PURE__ */ m("time", {
206
+ /* @__PURE__ */ g("time", {
203
207
  className: "text-xs text-text-muted",
204
208
  dateTime: e.at,
205
209
  children: r.moment(e.at)
@@ -210,6 +214,6 @@ function M({ events: t }) {
210
214
  })]
211
215
  });
212
216
  }
213
- export { w as NotificationDetailPanel };
217
+ export { E as NotificationDetailPanel };
214
218
 
215
219
  //# sourceMappingURL=NotificationDetailPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","footer","inboxActions","PanelFooter","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","PanelContent","Button","actions","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot, in\n * the person's own inbox only.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport {\n useNotificationDetail,\n type DetailState,\n type NotificationDetailData,\n} from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\n/** What the person can do with their own notification: absent in the admins' delivery log. */\nexport interface InboxActions {\n markUnread: (id: string) => void;\n archive: (id: string) => void;\n restore: (id: string) => void;\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n inboxActions,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox; the delivery log only reads, so it leaves these out. */\n inboxActions?: InboxActions;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n const footer =\n notification && inboxActions ? (\n <PanelFooter notification={notification} actions={inboxActions} />\n ) : undefined;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={footer}\n >\n <PanelContent state={state} retry={retry} notification={notification} />\n </DetailPanel>\n );\n}\n\n/** Mark as unread, and Archive or Move back to the inbox. */\nfunction PanelFooter({\n notification,\n actions,\n}: {\n notification: Notification;\n actions: InboxActions;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => actions.markUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => actions.restore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => actions.archive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n );\n}\n\n/** Loading, couldn't load, gone, or the notification itself. */\nfunction PanelContent({\n state,\n retry,\n notification,\n}: {\n state: DetailState;\n retry: () => void;\n notification: Notification | null;\n}) {\n const tr = useTr();\n if (state.status === 'loading') {\n return (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n );\n }\n if (state.status === 'failed') {\n return (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n );\n }\n if (state.status !== 'ready' || !notification) {\n return (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n );\n }\n return <PanelBody notification={notification} data={state.notification} />;\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA+BA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AASA,SAAgBC,EAAwB,EACtC,OACA,YACA,mBAMC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI,MAC5DI,IACJF,KAAgBG,IACd,kBAACC,GAAD;EAA2B;EAAc,SAASD;CAAe,CAAA,IAC/D,KAAA;CAEN,OACE,kBAACE,GAAD;EACE,MAAM,EAAQR;EACd,eAAe,MAAUS,IAAO,KAAA,IAAYC,EAAQ;EACpD,OAAOP,GAAc,SAASN,EAAG,kCAAkC,cAAc;EACjF,KAAKM,IAAe,kBAACQ,GAAD,EAAwB,gBAAe,CAAA,IAAI,KAAA;EAC/D,MACER,IACE,kBAACS,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAwB,gBAAe,CAAA;EAC/B,CAAA,IACR,KAAA;EAEN,YAAYhB,EAAG,gCAAgC,OAAO;EACtD,eAAY;EACJ;EAER,UAAA,kBAACiB,GAAD;GAAqB;GAAc;GAAqB;EAAe,CAAA;CAC5D,CAAA;AAEjB;AAGA,SAASP,EAAY,EACnB,iBACA,cAIC;CACD,IAAMV,IAAKC,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACiB,GAAD;GAAQ,SAAQ;GAAU,eAAeC,EAAQ,WAAWb,EAAa,EAAE;GACxE,UAAAN,EAAG,+BAA+B,gBAAgB;EAC7C,CAAA,GACPM,EAAa,aACZ,kBAACY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M,WAAW,UAAUJ,EAAWK,EAAM;OAAS,eAAY;MAAQ,CAAA;MACzE,kBAAC,QAAD;OAAM,WAAU;OAA4B,UAAAA,EAAM;MAAY,CAAA;MAC9D,kBAAC,QAAD;OAAM,WAAU;OAA0B,UAAUA,EAAM;OACvD,UAAA1B,EAAK,OAAO0B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
1
+ {"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","footer","inboxActions","PanelFooter","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","PanelContent","connection","useNeedsConnection","Button","waitingButton","actions","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot, in\n * the person's own inbox only.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNeedsConnection, waitingButton } from './useNeedsConnection';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport {\n useNotificationDetail,\n type DetailState,\n type NotificationDetailData,\n} from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\n/** What the person can do with their own notification: absent in the admins' delivery log. */\nexport interface InboxActions {\n markUnread: (id: string) => void;\n archive: (id: string) => void;\n restore: (id: string) => void;\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n inboxActions,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox; the delivery log only reads, so it leaves these out. */\n inboxActions?: InboxActions;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n const footer =\n notification && inboxActions ? (\n <PanelFooter notification={notification} actions={inboxActions} />\n ) : undefined;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={footer}\n >\n <PanelContent state={state} retry={retry} notification={notification} />\n </DetailPanel>\n );\n}\n\n/** Mark as unread, and Archive or Move back to the inbox. */\nfunction PanelFooter({\n notification,\n actions,\n}: {\n notification: Notification;\n actions: InboxActions;\n}) {\n const tr = useTr();\n const connection = useNeedsConnection();\n return (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button\n variant=\"outline\"\n {...waitingButton(connection)}\n onClick={() => actions.markUnread(notification.id)}\n >\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button\n variant=\"ghost\"\n {...waitingButton(connection)}\n onClick={() => actions.restore(notification.id)}\n >\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button\n variant=\"ghost\"\n {...waitingButton(connection)}\n onClick={() => actions.archive(notification.id)}\n >\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n );\n}\n\n/** Loading, couldn't load, gone, or the notification itself. */\nfunction PanelContent({\n state,\n retry,\n notification,\n}: {\n state: DetailState;\n retry: () => void;\n notification: Notification | null;\n}) {\n const tr = useTr();\n if (state.status === 'loading') {\n return (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n );\n }\n if (state.status === 'failed') {\n return (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n );\n }\n if (state.status !== 'ready' || !notification) {\n return (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n );\n }\n return <PanelBody notification={notification} data={state.notification} />;\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AASA,SAAgBC,EAAwB,EACtC,OACA,YACA,mBAMC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI,MAC5DI,IACJF,KAAgBG,IACd,kBAACC,GAAD;EAA2B;EAAc,SAASD;CAAe,CAAA,IAC/D,KAAA;C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IACC,kBAAC,OAAD,EAAA,UACE,kBAACvB,GAAD;IAAQ,MAAK;IAAK,SAAQ;IAAU,eAAexB,EAAO+C,CAAS;IAChE,UAAA3C,EAAG,kCAAkC,cAAc;GAC9C,CAAA,EACL,CAAA,IACH;EACG;;AAEb;AAEA,IAAM4C,IAA8C;CAClD,IAAIC;CACJ,KAAKC;CACL,SAASC;CACT,SAASA;AACX,GACMC,IAAwC;CAC5C,IAAI;CACJ,KAAK;CACL,SAAS;CACT,SAAS;AACX;AAEA,SAASV,EAAS,EAAE,aAAwD;CAC1E,IAAMtC,IAAKC,EAAM,GACX0B,IAAOC,EAAc,GACrBqB,IAAQC,EAASC,GAAQnD,CAAE;CAEjC,OADIiD,EAAM,WAAW,IAAU,OAE7B,kBAAC,WAAD;EACE,WAAU;EACV,cAAYjD,EAAG,6BAA6B,eAAe;EAF7D,UAAA,CAIE,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAA,EAAG,6BAA6B,eAAe;EAC9C,CAAA,GACJ,kBAAC,MAAD;GAAI,WAAU;GAAwC,eAAY;GAC/D,UAAAiD,EAAM,KAAK,MAAU;IACpB,IAAMG,IAAOR,EAAWS,EAAM;IAC9B,OACE,kBAAC,MAAD;KAAmB,WAAU;KAA7B,UAAA;MACE,kBAACD,GAAD;OAAM,WAAW,UAAUJ,EAAWK,EAAM;OAAS,eAAY;MAAQ,CAAA;MACzE,kBAAC,QAAD;OAAM,WAAU;OAA4B,UAAAA,EAAM;MAAY,CAAA;MAC9D,kBAAC,QAAD;OAAM,WAAU;OAA0B,UAAUA,EAAM;OACvD,UAAA1B,EAAK,OAAO0B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
@@ -1,97 +1,98 @@
1
1
  import { useNotificationTopics as e } from "../hooks/useNotificationTopics.js";
2
2
  import { preferenceKey as t, usePreferenceToggles as n } from "../hooks/usePreferenceToggles.js";
3
3
  import { useTr as r } from "../shared/hooks/useTr.js";
4
- import { useNotificationPaths as i } from "../navigation-v2/paths.js";
5
- import { EVERYDAY_CHANNELS as a, MORE_CHANNELS as o, TYPES as s } from "../navigation-v2/settingsOptions.js";
6
- import { StaleHint as c } from "./StaleHint.js";
7
- import { oldestLoad as l } from "./model/loadedAt.js";
8
- import { useMemo as u, useState as d } from "react";
9
- import { Bell as f, BellOff as p, Check as m, Inbox as h, Megaphone as g, Search as _, X as v } from "lucide-react";
10
- import { useNavigate as y } from "react-router";
11
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
12
- import { PageHeader as S, PushOptInToggle as C } from "@burdenoff/fe-libs/chrome";
13
- import { Button as w, Input as T, SettingRow as E, SettingsSection as D, Switch as O, WorkspacePage as k } from "@burdenoff/fe-libs/ui";
4
+ import { useNeedsConnection as i, waitingButton as a } from "./useNeedsConnection.js";
5
+ import { useNotificationPaths as o } from "../navigation-v2/paths.js";
6
+ import { EVERYDAY_CHANNELS as s, MORE_CHANNELS as c, TYPES as l } from "../navigation-v2/settingsOptions.js";
7
+ import { StaleHint as u } from "./StaleHint.js";
8
+ import { oldestLoad as d } from "./model/loadedAt.js";
9
+ import { useMemo as f, useState as p } from "react";
10
+ import { Bell as m, BellOff as h, Check as g, Inbox as _, Megaphone as v, Search as y, X as b } from "lucide-react";
11
+ import { useNavigate as x } from "react-router";
12
+ import { jsx as S, jsxs as C } from "react/jsx-runtime";
13
+ import { PageHeader as w, PushOptInToggle as T } from "@burdenoff/fe-libs/chrome";
14
+ import { Button as E, Input as D, SettingRow as O, SettingsSection as k, Switch as A, WorkspacePage as j } from "@burdenoff/fe-libs/ui";
14
15
  // src/v2/PreferencesPage.tsx
15
- function A() {
16
- let m = r(), v = y(), E = i(), O = n(), { topics: A, isLoading: M, isForbidden: N, dataUpdatedAt: P } = e({
16
+ function M() {
17
+ let i = r(), a = x(), g = o(), b = n(), { topics: O, isLoading: A, isForbidden: M, dataUpdatedAt: P } = e({
17
18
  type: "MARKETING",
18
19
  isActive: !0
19
- }), [F, I] = d(""), L = u(() => {
20
+ }), [F, I] = p(""), L = f(() => {
20
21
  let e = F.trim().toLowerCase();
21
- return e ? A.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : A;
22
- }, [F, A]), R = O.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, z = (e, n, r = {}) => /* @__PURE__ */ b(j, {
22
+ return e ? O.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : O;
23
+ }, [F, O]), R = b.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, z = (e, n, r = {}) => /* @__PURE__ */ S(N, {
23
24
  target: e,
24
25
  label: n,
25
26
  options: r,
26
- toggles: O
27
+ toggles: b
27
28
  }, t(e));
28
- return /* @__PURE__ */ x(k, { children: [
29
- /* @__PURE__ */ b(S, {
29
+ return /* @__PURE__ */ C(j, { children: [
30
+ /* @__PURE__ */ S(w, {
30
31
  variant: "compact",
31
- title: m("notifications.v3.title", "Notifications"),
32
- description: m("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
33
- secondary: /* @__PURE__ */ x(w, {
32
+ title: i("notifications.v3.title", "Notifications"),
33
+ description: i("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
34
+ secondary: /* @__PURE__ */ C(E, {
34
35
  variant: "outline",
35
- onClick: () => v(E.inbox),
36
- children: [/* @__PURE__ */ b(h, { "aria-hidden": "true" }), m("notifications.v3.prefs.openInbox", "Open the inbox")]
36
+ onClick: () => a(g.inbox),
37
+ children: [/* @__PURE__ */ S(_, { "aria-hidden": "true" }), i("notifications.v3.prefs.openInbox", "Open the inbox")]
37
38
  })
38
39
  }),
39
- /* @__PURE__ */ b(c, { loadedAt: l(O.preferencesUpdatedAt, P) }),
40
- /* @__PURE__ */ x("div", {
40
+ /* @__PURE__ */ S(u, { loadedAt: d(b.preferencesUpdatedAt, P) }),
41
+ /* @__PURE__ */ C("div", {
41
42
  className: "flex flex-col gap-4",
42
43
  children: [
43
- /* @__PURE__ */ b(D, {
44
- icon: p,
45
- title: m("notifications.v3.prefs.pauseTitle", "Pause everything"),
46
- children: z({ scope: "GLOBAL" }, m("notifications.v3.prefs.pause", "Pause notifications"), {
47
- description: R ? m("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : m("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
44
+ /* @__PURE__ */ S(k, {
45
+ icon: h,
46
+ title: i("notifications.v3.prefs.pauseTitle", "Pause everything"),
47
+ children: z({ scope: "GLOBAL" }, i("notifications.v3.prefs.pause", "Pause notifications"), {
48
+ description: R ? i("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : i("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
48
49
  inverted: !0
49
50
  })
50
51
  }),
51
- /* @__PURE__ */ x(D, {
52
- icon: f,
53
- title: m("notifications.v3.prefs.whereTitle", "Where you hear from us"),
54
- children: [[...a, ...o].map((e) => z({
52
+ /* @__PURE__ */ C(k, {
53
+ icon: m,
54
+ title: i("notifications.v3.prefs.whereTitle", "Where you hear from us"),
55
+ children: [[...s, ...c].map((e) => z({
55
56
  scope: "CHANNEL",
56
57
  channel: e.value
57
- }, m(e.labelKey, e.label))), /* @__PURE__ */ b("div", {
58
+ }, i(e.labelKey, e.label))), /* @__PURE__ */ S("div", {
58
59
  className: "px-1 py-2",
59
- children: /* @__PURE__ */ b(C, {})
60
+ children: /* @__PURE__ */ S(T, {})
60
61
  })]
61
62
  }),
62
- /* @__PURE__ */ b(D, {
63
- icon: h,
64
- title: m("notifications.v3.prefs.whatTitle", "What you hear about"),
65
- children: s.map((e) => z({
63
+ /* @__PURE__ */ S(k, {
64
+ icon: _,
65
+ title: i("notifications.v3.prefs.whatTitle", "What you hear about"),
66
+ children: l.map((e) => z({
66
67
  scope: "TYPE",
67
68
  type: e.value
68
- }, m(e.labelKey, e.label)))
69
+ }, i(e.labelKey, e.label)))
69
70
  }),
70
- !M && !N && A.length > 0 ? /* @__PURE__ */ x(D, {
71
- icon: g,
72
- title: m("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
73
- children: [A.length > 5 ? /* @__PURE__ */ x("label", {
71
+ !A && !M && O.length > 0 ? /* @__PURE__ */ C(k, {
72
+ icon: v,
73
+ title: i("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
74
+ children: [O.length > 5 ? /* @__PURE__ */ C("label", {
74
75
  className: "relative block px-1 py-2",
75
76
  children: [
76
- /* @__PURE__ */ b("span", {
77
+ /* @__PURE__ */ S("span", {
77
78
  className: "sr-only",
78
- children: m("notifications.searchTopics", "Search topics...")
79
+ children: i("notifications.searchTopics", "Search topics...")
79
80
  }),
80
- /* @__PURE__ */ b(_, {
81
+ /* @__PURE__ */ S(y, {
81
82
  className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
82
83
  "aria-hidden": "true"
83
84
  }),
84
- /* @__PURE__ */ b(T, {
85
+ /* @__PURE__ */ S(D, {
85
86
  type: "search",
86
87
  className: "pl-9",
87
88
  value: F,
88
- placeholder: m("notifications.searchTopics", "Search topics..."),
89
+ placeholder: i("notifications.searchTopics", "Search topics..."),
89
90
  onChange: (e) => I(e.target.value)
90
91
  })
91
92
  ]
92
- }) : null, L.length === 0 ? /* @__PURE__ */ b("p", {
93
+ }) : null, L.length === 0 ? /* @__PURE__ */ S("p", {
93
94
  className: "m-0 px-1 py-2 text-sm text-text-secondary",
94
- children: m("notifications.noTopicsFound", "No topics match your search")
95
+ children: i("notifications.noTopicsFound", "No topics match your search")
95
96
  }) : L.map((e) => z({
96
97
  scope: "TOPIC",
97
98
  topicId: e.id
@@ -101,41 +102,41 @@ function A() {
101
102
  })
102
103
  ] });
103
104
  }
104
- function j({ target: e, label: n, options: i, toggles: a }) {
105
- 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;
106
- if (u) {
107
- let e = u.type === "success" ? m : v;
108
- d = /* @__PURE__ */ x("span", {
109
- className: `inline-flex items-center gap-1 ${u.type === "success" ? "text-status-success-text" : "text-status-error-text"}`,
110
- role: u.type === "error" ? "alert" : "status",
111
- children: [/* @__PURE__ */ b(e, {
105
+ function N({ target: e, label: n, options: o, toggles: s }) {
106
+ let c = r(), l = i(), u = t(e), d = s.preferencesByKey.get(u), f = d?.enabled ?? !0, p = s.saveFeedback?.key === u ? s.saveFeedback : null, m = o.description;
107
+ if (p) {
108
+ let e = p.type === "success" ? g : b;
109
+ m = /* @__PURE__ */ C("span", {
110
+ className: `inline-flex items-center gap-1 ${p.type === "success" ? "text-status-success-text" : "text-status-error-text"}`,
111
+ role: p.type === "error" ? "alert" : "status",
112
+ children: [/* @__PURE__ */ S(e, {
112
113
  className: "size-3.5",
113
114
  "aria-hidden": "true"
114
- }), u.message]
115
+ }), p.message]
115
116
  });
116
117
  }
117
- return /* @__PURE__ */ b(E, {
118
+ return /* @__PURE__ */ S(O, {
118
119
  label: n,
119
- description: d,
120
- control: (t) => /* @__PURE__ */ x("span", {
120
+ description: m,
121
+ control: (t) => /* @__PURE__ */ C("span", {
121
122
  className: "flex items-center gap-2",
122
- children: [c ? /* @__PURE__ */ b(w, {
123
+ children: [d ? /* @__PURE__ */ S(E, {
123
124
  size: "sm",
124
125
  variant: "ghost",
125
- disabled: a.savingKey === s,
126
- onClick: () => void a.resetPreference(s),
127
- children: o("notifications.v3.prefs.useDefault", "Use default")
128
- }) : null, /* @__PURE__ */ b(O, {
129
- checked: i.inverted ? !l : l,
130
- disabled: a.savingKey === s,
131
- onCheckedChange: () => void a.togglePreference(e),
126
+ ...a(l, s.savingKey === u),
127
+ onClick: () => void s.resetPreference(u),
128
+ children: c("notifications.v3.prefs.useDefault", "Use default")
129
+ }) : null, /* @__PURE__ */ S(A, {
130
+ checked: o.inverted ? !f : f,
131
+ ...a(l, s.savingKey === u),
132
+ onCheckedChange: () => void s.togglePreference(e),
132
133
  "aria-labelledby": t.labelId,
133
134
  "aria-describedby": t.descriptionId,
134
- "data-testid": `pref-${s}`
135
+ "data-testid": `pref-${u}`
135
136
  })]
136
137
  })
137
138
  });
138
139
  }
139
- export { A as PreferencesPage };
140
+ export { M as PreferencesPage };
140
141
 
141
142
  //# sourceMappingURL=PreferencesPage.js.map