@burdenoff/microfe-notification 2026.1129.2 → 2026.1130.1

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 (48) hide show
  1. package/dist/NotificationRoutes.js +73 -72
  2. package/dist/NotificationRoutes.js.map +1 -1
  3. package/dist/hooks/useSendNotification.d.ts +1 -1
  4. package/dist/hooks/useSendNotification.js.map +1 -1
  5. package/dist/translations/en.d.ts +55 -0
  6. package/dist/v2/InboxPage.js +150 -138
  7. package/dist/v2/InboxPage.js.map +1 -1
  8. package/dist/v2/NotificationDetailPanel.d.ts +9 -5
  9. package/dist/v2/NotificationDetailPanel.js +66 -51
  10. package/dist/v2/NotificationDetailPanel.js.map +1 -1
  11. package/dist/v2/PreferencesPage.js +80 -84
  12. package/dist/v2/PreferencesPage.js.map +1 -1
  13. package/dist/v2/admin/DeliveryLogPage.js +44 -48
  14. package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
  15. package/dist/v2/admin/TemplateEditor.js +28 -33
  16. package/dist/v2/admin/TemplateEditor.js.map +1 -1
  17. package/dist/v2/admin/TemplateFields.js +1 -1
  18. package/dist/v2/admin/TemplateFields.js.map +1 -1
  19. package/dist/v2/admin/TemplatePage.js +19 -19
  20. package/dist/v2/admin/TemplatePage.js.map +1 -1
  21. package/dist/v2/admin/TemplatesPage.js +123 -127
  22. package/dist/v2/admin/TemplatesPage.js.map +1 -1
  23. package/dist/v2/admin/TopicsPage.js +101 -105
  24. package/dist/v2/admin/TopicsPage.js.map +1 -1
  25. package/dist/v2/admin/templateText.js +22 -17
  26. package/dist/v2/admin/templateText.js.map +1 -1
  27. package/dist/v2/send/MessageTab.d.ts +4 -0
  28. package/dist/v2/send/MessageTab.js +152 -0
  29. package/dist/v2/send/MessageTab.js.map +1 -0
  30. package/dist/v2/send/PeopleTab.d.ts +4 -0
  31. package/dist/v2/send/PeopleTab.js +156 -0
  32. package/dist/v2/send/PeopleTab.js.map +1 -0
  33. package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
  34. package/dist/v2/send/SendNotificationDialog.js +98 -0
  35. package/dist/v2/send/SendNotificationDialog.js.map +1 -0
  36. package/dist/v2/send/SendRedirect.d.ts +1 -0
  37. package/dist/v2/send/SendRedirect.js +20 -0
  38. package/dist/v2/send/SendRedirect.js.map +1 -0
  39. package/dist/v2/send/WhenTab.d.ts +4 -0
  40. package/dist/v2/send/WhenTab.js +64 -0
  41. package/dist/v2/send/WhenTab.js.map +1 -0
  42. package/dist/v2/send/sendModel.d.ts +47 -0
  43. package/dist/v2/send/sendModel.js +90 -0
  44. package/dist/v2/send/sendModel.js.map +1 -0
  45. package/dist/v2/send/useSendDraft.d.ts +24 -0
  46. package/dist/v2/send/useSendDraft.js +120 -0
  47. package/dist/v2/send/useSendDraft.js.map +1 -0
  48. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TemplatesPage.js","names":["TemplatesPage","AdminPageV2","TemplatesList","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","when","useWhenLabels","templates","useNotificationTemplates","search","setSearch","useState","shown","useMemo","query","all","template","toggle","remove","PageHeader","Button","Plus","Search","Input","event","LoadError","EmptyState","DataRows","IconTile","Mail","toReadable","readDetails","kindWord","channelWord","StatusChip","ActionMenu"],"sources":["../../../src/v2/admin/TemplatesPage.tsx"],"sourcesContent":["/**\n * Templates (BOFF-16785, C2; the mockup's `ntemplates`), under fe-libs' `accountPagesV2`: the\n * messages this product sends, at the list width. A row each (what it's about, how it's sent,\n * when it was edited, on or off), search, New template, and ⋯ (turn off or on, delete). Admins\n * only: anyone else sees who to ask (`AdminPageV2`). Today's hook and storage.\n */\nimport { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Mail, Plus, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n Input,\n LoadError,\n StatusChip,\n useConfirm,\n useNotify,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport {\n useNotificationTemplates,\n type BackendNotificationTemplate,\n} from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { channelWord, kindWord } from './words';\nimport { readDetails, toReadable } from './templateText';\n\nexport function TemplatesPage() {\n return (\n <AdminPageV2 tool=\"templates\" back={false}>\n <TemplatesList />\n </AdminPageV2>\n );\n}\n\nfunction TemplatesList() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const when = useWhenLabels();\n const templates = useNotificationTemplates();\n const [search, setSearch] = useState('');\n const shown = useMemo(() => {\n const query = search.trim().toLowerCase();\n const all = templates.allTemplates;\n if (!query) return all;\n return all.filter(\n (template) =>\n template.name.toLowerCase().includes(query) ||\n (template.subject ?? '').toLowerCase().includes(query)\n );\n }, [search, templates.allTemplates]);\n\n const toggle = async (template: BackendNotificationTemplate) => {\n try {\n await templates.updateTemplate(template.id, { enabled: !template.enabled });\n notify({\n title: template.enabled\n ? tr('notifications.v3.templates.turnedOff', '{{name}} is off', { name: template.name })\n : tr('notifications.v3.templates.turnedOn', '{{name}} is on', { name: template.name }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n });\n }\n };\n\n const remove = async (template: BackendNotificationTemplate) => {\n const yes = await confirm({\n title: tr('notifications.v3.templates.deleteTitle', 'Delete {{name}}?', {\n name: template.name,\n }),\n description: tr(\n 'notifications.v3.templates.deleteBody',\n 'Anything that sends this template stops sending it. Messages already sent stay as they are.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: template.name,\n });\n if (!yes) return;\n try {\n await templates.deleteTemplate(template.id);\n notify({\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: template.name,\n }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n });\n }\n };\n\n return (\n <div data-account-pages-v2=\"notification-templates\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.templates.title', 'Templates')}\n description={tr(\n 'notifications.v3.templates.purpose',\n 'Messages written once and sent many times: what they say, and how they’re sent.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => navigate(paths.newTemplate)} data-testid=\"templates-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">\n {tr('notifications.v3.templates.search', 'Search templates')}\n </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.templates.search', 'Search templates')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n {templates.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.templates.title', 'Templates')}\n error={templates.error}\n onRetry={() => void templates.refetch()}\n />\n ) : !templates.isLoading && shown.length === 0 ? (\n search.trim() ? (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.templates.noMatch', 'No templates match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n ) : (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.templates.emptyTitle', 'No templates yet')}\n description={tr(\n 'notifications.v3.templates.emptyBody',\n 'A template is a message you write once, like a welcome email, and send many times.'\n )}\n action={\n <Button onClick={() => navigate(paths.newTemplate)}>\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n )\n ) : (\n <DataRows\n items={shown}\n loading={templates.isLoading && shown.length === 0}\n skeletonRows={5}\n getId={(template) => template.id}\n label={tr('notifications.v3.templates.title', 'Templates')}\n lead={{\n header: tr('notifications.v3.templates.template', 'Template'),\n media: () => (\n <IconTile size=\"sm\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (template) => template.name,\n subtitle: (template) =>\n template.subject\n ? toReadable(template.subject, readDetails(template.variables))\n : undefined,\n onOpen: (template) => navigate(paths.template(template.slug)),\n }}\n columns={[\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (template) => kindWord(template.type, tr),\n },\n {\n id: 'channel',\n header: tr('notifications.v3.templates.channel', 'Sent by'),\n cell: (template) => channelWord(template.channel, tr),\n },\n {\n id: 'edited',\n header: tr('notifications.v3.templates.edited', 'Edited'),\n cell: (template) => when.moment(template.updatedAt),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (template) =>\n template.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n ),\n },\n ]}\n actions={(template) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: template.name,\n })}\n items={[\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void toggle(template),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(template),\n },\n ]}\n />\n )}\n />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,SAAgBA,IAAgB;CAC9B,OACE,kBAACC,GAAD;EAAa,MAAK;EAAY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AAY,QAAO;OAAM,UAAAvC,EAAG,uBAAuB,IAAI;MAAc,CAAA,IAErE,kBAACuC,GAAD;OAAY,QAAO;OAAU,UAAAvC,EAAG,wBAAwB,KAAK;MAAc,CAAA;KAEjF;IACF;IACA,UAAU,MACR,kBAACwC,GAAD;KACE,WAAU;KACV,OAAOxC,EAAG,yCAAyC,wBAAwB,EACzE,MAAMqB,EAAS,KACjB,CAAC;KACD,OAAO,CACL;MACE,IAAI;MACJ,OAAOA,EAAS,UACZrB,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;MACrD,gBAAgB,KAAKsB,EAAOD,CAAQ;KACtC,GACA;MACE,IAAI;MACJ,OAAOrB,EAAG,qCAAqC,QAAQ;MACvD,QAAQ;MACR,gBAAgB,KAAKuB,EAAOF,CAAQ;KACtC,CACF;IACD,CAAA;GAEJ,CAAA,CAEA;EACF,CAAA,CAAA;;AAET"}
1
+ {"version":3,"file":"TemplatesPage.js","names":["TemplatesPage","AdminPageV2","TemplatesList","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","when","useWhenLabels","templates","useNotificationTemplates","search","setSearch","useState","shown","useMemo","query","all","template","toggle","remove","WorkspacePage","PageHeader","Button","Plus","Search","Input","event","LoadError","EmptyState","DataRows","IconTile","Mail","toReadable","readDetails","kindWord","channelWord","StatusChip","ActionMenu"],"sources":["../../../src/v2/admin/TemplatesPage.tsx"],"sourcesContent":["/**\n * Templates (BOFF-16785, C2; the mockup's `ntemplates`), under fe-libs' `accountPagesV2`: the\n * messages this product sends, at the list width. A row each (what it's about, how it's sent,\n * when it was edited, on or off), search, New template, and ⋯ (turn off or on, delete). Admins\n * only: anyone else sees who to ask (`AdminPageV2`). Today's hook and storage.\n */\nimport { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Mail, Plus, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n Input,\n LoadError,\n StatusChip,\n WorkspacePage,\n useConfirm,\n useNotify,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport {\n useNotificationTemplates,\n type BackendNotificationTemplate,\n} from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { channelWord, kindWord } from './words';\nimport { readDetails, toReadable } from './templateText';\n\nexport function TemplatesPage() {\n return (\n <AdminPageV2 tool=\"templates\" back={false}>\n <TemplatesList />\n </AdminPageV2>\n );\n}\n\nfunction TemplatesList() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const when = useWhenLabels();\n const templates = useNotificationTemplates();\n const [search, setSearch] = useState('');\n const shown = useMemo(() => {\n const query = search.trim().toLowerCase();\n const all = templates.allTemplates;\n if (!query) return all;\n return all.filter(\n (template) =>\n template.name.toLowerCase().includes(query) ||\n (template.subject ?? '').toLowerCase().includes(query)\n );\n }, [search, templates.allTemplates]);\n\n const toggle = async (template: BackendNotificationTemplate) => {\n try {\n await templates.updateTemplate(template.id, { enabled: !template.enabled });\n notify({\n title: template.enabled\n ? tr('notifications.v3.templates.turnedOff', '{{name}} is off', { name: template.name })\n : tr('notifications.v3.templates.turnedOn', '{{name}} is on', { name: template.name }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n });\n }\n };\n\n const remove = async (template: BackendNotificationTemplate) => {\n const yes = await confirm({\n title: tr('notifications.v3.templates.deleteTitle', 'Delete {{name}}?', {\n name: template.name,\n }),\n description: tr(\n 'notifications.v3.templates.deleteBody',\n 'Anything that sends this template stops sending it. Messages already sent stay as they are.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: template.name,\n });\n if (!yes) return;\n try {\n await templates.deleteTemplate(template.id);\n notify({\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: template.name,\n }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n });\n }\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.templates.title', 'Templates')}\n description={tr(\n 'notifications.v3.templates.purpose',\n 'Messages written once and sent many times: what they say, and how they’re sent.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => navigate(paths.newTemplate)} data-testid=\"templates-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">\n {tr('notifications.v3.templates.search', 'Search templates')}\n </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.templates.search', 'Search templates')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n {templates.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.templates.title', 'Templates')}\n error={templates.error}\n onRetry={() => void templates.refetch()}\n />\n ) : !templates.isLoading && shown.length === 0 ? (\n search.trim() ? (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.templates.noMatch', 'No templates match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n ) : (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.templates.emptyTitle', 'No templates yet')}\n description={tr(\n 'notifications.v3.templates.emptyBody',\n 'A template is a message you write once, like a welcome email, and send many times.'\n )}\n action={\n <Button onClick={() => navigate(paths.newTemplate)}>\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n )\n ) : (\n <DataRows\n items={shown}\n loading={templates.isLoading && shown.length === 0}\n skeletonRows={5}\n getId={(template) => template.id}\n label={tr('notifications.v3.templates.title', 'Templates')}\n lead={{\n header: tr('notifications.v3.templates.template', 'Template'),\n media: () => (\n <IconTile size=\"sm\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (template) => template.name,\n subtitle: (template) =>\n template.subject\n ? toReadable(template.subject, readDetails(template.variables))\n : undefined,\n onOpen: (template) => navigate(paths.template(template.slug)),\n }}\n columns={[\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (template) => kindWord(template.type, tr),\n },\n {\n id: 'channel',\n header: tr('notifications.v3.templates.channel', 'Sent by'),\n cell: (template) => channelWord(template.channel, tr),\n },\n {\n id: 'edited',\n header: tr('notifications.v3.templates.edited', 'Edited'),\n cell: (template) => when.moment(template.updatedAt),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (template) =>\n template.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n ),\n },\n ]}\n actions={(template) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: template.name,\n })}\n items={[\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void toggle(template),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(template),\n },\n ]}\n />\n )}\n />\n )}\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,SAAgBA,IAAgB;CAC9B,OACE,kBAACC,GA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AAO;MAAM,UAAAxC,EAAG,uBAAuB,IAAI;KAAc,CAAA,IAErE,kBAACwC,GAAD;MAAY,QAAO;MAAU,UAAAxC,EAAG,wBAAwB,KAAK;KAAc,CAAA;IAEjF;GACF;GACA,UAAU,MACR,kBAACyC,GAAD;IACE,WAAU;IACV,OAAOzC,EAAG,yCAAyC,wBAAwB,EACzE,MAAMqB,EAAS,KACjB,CAAC;IACD,OAAO,CACL;KACE,IAAI;KACJ,OAAOA,EAAS,UACZrB,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;KACrD,gBAAgB,KAAKsB,EAAOD,CAAQ;IACtC,GACA;KACE,IAAI;KACJ,OAAOrB,EAAG,qCAAqC,QAAQ;KACvD,QAAQ;KACR,gBAAgB,KAAKuB,EAAOF,CAAQ;IACtC,CACF;GACD,CAAA;EAEJ,CAAA,CAEA;CACQ,CAAA,CAAA,EAAA,CAAA;AAEnB"}
@@ -8,36 +8,36 @@ import { useState as o } from "react";
8
8
  import { Plus as s, Tag as c } from "lucide-react";
9
9
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
10
  import { PageHeader as d } from "@burdenoff/fe-libs/chrome";
11
- import { ActionMenu as f, Button as p, DataRows as m, EmptyState as h, IconTile as g, LoadError as _, StatusChip as v, useConfirm as y, useNotify as b } from "@burdenoff/fe-libs/ui";
11
+ import { ActionMenu as f, Button as p, DataRows as m, EmptyState as h, IconTile as g, LoadError as _, StatusChip as v, WorkspacePage as y, useConfirm as b, useNotify as x } from "@burdenoff/fe-libs/ui";
12
12
  // src/v2/admin/TopicsPage.tsx
13
- var x = new Intl.NumberFormat();
14
- function S() {
13
+ var S = new Intl.NumberFormat();
14
+ function C() {
15
15
  return /* @__PURE__ */ l(r, {
16
16
  tool: "topics",
17
17
  back: !1,
18
- children: /* @__PURE__ */ l(C, {})
18
+ children: /* @__PURE__ */ l(w, {})
19
19
  });
20
20
  }
21
- function C() {
22
- let r = t(), S = n(), C = y(), w = b(), T = e(), [E, D] = o(null), O = async (e) => {
23
- let t = await T.updateTopic(e.id, { isActive: !e.isActive });
24
- w(t ? {
21
+ function w() {
22
+ let r = t(), C = n(), w = b(), T = x(), E = e(), [D, O] = o(null), k = async (e) => {
23
+ let t = await E.updateTopic(e.id, { isActive: !e.isActive });
24
+ T(t ? {
25
25
  title: e.isActive ? r("notifications.v3.topics.turnedOff", "{{name}} is off", { name: e.name }) : r("notifications.v3.topics.turnedOn", "{{name}} is on", { name: e.name }),
26
26
  tone: "success"
27
27
  } : {
28
28
  title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
29
29
  tone: "error"
30
30
  });
31
- }, k = async (e) => {
32
- if (!await C({
31
+ }, A = async (e) => {
32
+ if (!await w({
33
33
  title: r("notifications.v3.topics.deleteTitle", "Delete {{name}}?", { name: e.name }),
34
34
  description: r("notifications.v3.topics.deleteBody", "People stop being able to choose it in their settings."),
35
35
  confirmLabel: r("notifications.v3.templates.delete", "Delete"),
36
36
  tone: "danger",
37
37
  typeToConfirm: e.name
38
38
  })) return;
39
- let t = await T.deleteTopic(e.id);
40
- w(t ? {
39
+ let t = await E.deleteTopic(e.id);
40
+ T(t ? {
41
41
  title: r("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
42
42
  tone: "success"
43
43
  } : {
@@ -45,108 +45,104 @@ function C() {
45
45
  tone: "error"
46
46
  });
47
47
  };
48
- return /* @__PURE__ */ u("div", {
49
- "data-account-pages-v2": "notification-topics",
50
- className: "flex w-full min-w-0 flex-col",
51
- children: [
52
- /* @__PURE__ */ l(d, {
53
- variant: "compact",
54
- title: r("notifications.v3.topics.title", "Topics"),
55
- description: r("notifications.v3.topics.purpose", "Groups of notifications people can turn on or off."),
56
- back: {
57
- label: r("notifications.v3.title", "Notifications"),
58
- to: S.inbox
48
+ return /* @__PURE__ */ u(y, { children: [
49
+ /* @__PURE__ */ l(d, {
50
+ variant: "compact",
51
+ title: r("notifications.v3.topics.title", "Topics"),
52
+ description: r("notifications.v3.topics.purpose", "Groups of notifications people can turn on or off."),
53
+ back: {
54
+ label: r("notifications.v3.title", "Notifications"),
55
+ to: C.inbox
56
+ },
57
+ primary: /* @__PURE__ */ u(p, {
58
+ onClick: () => O("new"),
59
+ "data-testid": "topics-new",
60
+ children: [/* @__PURE__ */ l(s, { "aria-hidden": "true" }), r("notifications.v3.topics.new", "New topic")]
61
+ })
62
+ }),
63
+ E.error && E.topics.length === 0 ? /* @__PURE__ */ l(_, {
64
+ what: r("notifications.v3.topics.title", "Topics"),
65
+ error: E.error,
66
+ onRetry: () => void E.refetch()
67
+ }) : !E.isLoading && E.topics.length === 0 ? /* @__PURE__ */ l(h, {
68
+ kind: "first-use",
69
+ title: r("notifications.v3.topics.emptyTitle", "No topics yet"),
70
+ description: r("notifications.v3.topics.emptyBody", "Topics let people choose what they hear about, like “Billing” or “Product news”."),
71
+ action: /* @__PURE__ */ l(p, {
72
+ onClick: () => O("new"),
73
+ children: r("notifications.v3.topics.new", "New topic")
74
+ })
75
+ }) : /* @__PURE__ */ l(m, {
76
+ items: E.topics,
77
+ loading: E.isLoading && E.topics.length === 0,
78
+ skeletonRows: 4,
79
+ getId: (e) => e.id,
80
+ label: r("notifications.v3.topics.title", "Topics"),
81
+ lead: {
82
+ header: r("notifications.v3.topics.topic", "Topic"),
83
+ media: () => /* @__PURE__ */ l(g, {
84
+ size: "sm",
85
+ children: /* @__PURE__ */ l(c, { "aria-hidden": "true" })
86
+ }),
87
+ title: (e) => e.name,
88
+ subtitle: (e) => e.description || void 0,
89
+ onOpen: (e) => O(e)
90
+ },
91
+ columns: [
92
+ {
93
+ id: "people",
94
+ header: r("notifications.v3.topics.people", "Following"),
95
+ cell: (e) => S.format(e.subscriberCount ?? 0)
59
96
  },
60
- primary: /* @__PURE__ */ u(p, {
61
- onClick: () => D("new"),
62
- "data-testid": "topics-new",
63
- children: [/* @__PURE__ */ l(s, { "aria-hidden": "true" }), r("notifications.v3.topics.new", "New topic")]
64
- })
65
- }),
66
- T.error && T.topics.length === 0 ? /* @__PURE__ */ l(_, {
67
- what: r("notifications.v3.topics.title", "Topics"),
68
- error: T.error,
69
- onRetry: () => void T.refetch()
70
- }) : !T.isLoading && T.topics.length === 0 ? /* @__PURE__ */ l(h, {
71
- kind: "first-use",
72
- title: r("notifications.v3.topics.emptyTitle", "No topics yet"),
73
- description: r("notifications.v3.topics.emptyBody", "Topics let people choose what they hear about, like “Billing” or “Product news”."),
74
- action: /* @__PURE__ */ l(p, {
75
- onClick: () => D("new"),
76
- children: r("notifications.v3.topics.new", "New topic")
77
- })
78
- }) : /* @__PURE__ */ l(m, {
79
- items: T.topics,
80
- loading: T.isLoading && T.topics.length === 0,
81
- skeletonRows: 4,
82
- getId: (e) => e.id,
83
- label: r("notifications.v3.topics.title", "Topics"),
84
- lead: {
85
- header: r("notifications.v3.topics.topic", "Topic"),
86
- media: () => /* @__PURE__ */ l(g, {
87
- size: "sm",
88
- children: /* @__PURE__ */ l(c, { "aria-hidden": "true" })
89
- }),
90
- title: (e) => e.name,
91
- subtitle: (e) => e.description || void 0,
92
- onOpen: (e) => D(e)
97
+ {
98
+ id: "kind",
99
+ header: r("notifications.v3.templates.kind", "About"),
100
+ cell: (e) => i(e.type, r)
93
101
  },
94
- columns: [
102
+ {
103
+ id: "status",
104
+ header: r("notifications.v3.templates.status", "Status"),
105
+ cell: (e) => e.isActive ? /* @__PURE__ */ l(v, {
106
+ status: "ok",
107
+ children: r("notifications.v3.on", "On")
108
+ }) : /* @__PURE__ */ l(v, {
109
+ status: "paused",
110
+ children: r("notifications.v3.off", "Off")
111
+ })
112
+ }
113
+ ],
114
+ actions: (e) => /* @__PURE__ */ l(f, {
115
+ placement: "row",
116
+ label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
117
+ items: [
95
118
  {
96
- id: "people",
97
- header: r("notifications.v3.topics.people", "Following"),
98
- cell: (e) => x.format(e.subscriberCount ?? 0)
119
+ id: "edit",
120
+ label: r("notifications.v3.topics.edit", "Edit"),
121
+ onSelect: () => O(e)
99
122
  },
100
123
  {
101
- id: "kind",
102
- header: r("notifications.v3.templates.kind", "About"),
103
- cell: (e) => i(e.type, r)
124
+ id: "toggle",
125
+ label: e.isActive ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
126
+ onSelect: () => void k(e)
104
127
  },
105
128
  {
106
- id: "status",
107
- header: r("notifications.v3.templates.status", "Status"),
108
- cell: (e) => e.isActive ? /* @__PURE__ */ l(v, {
109
- status: "ok",
110
- children: r("notifications.v3.on", "On")
111
- }) : /* @__PURE__ */ l(v, {
112
- status: "paused",
113
- children: r("notifications.v3.off", "Off")
114
- })
129
+ id: "delete",
130
+ label: r("notifications.v3.templates.delete", "Delete"),
131
+ danger: !0,
132
+ onSelect: () => void A(e)
115
133
  }
116
- ],
117
- actions: (e) => /* @__PURE__ */ l(f, {
118
- placement: "row",
119
- label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
120
- items: [
121
- {
122
- id: "edit",
123
- label: r("notifications.v3.topics.edit", "Edit"),
124
- onSelect: () => D(e)
125
- },
126
- {
127
- id: "toggle",
128
- label: e.isActive ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
129
- onSelect: () => void O(e)
130
- },
131
- {
132
- id: "delete",
133
- label: r("notifications.v3.templates.delete", "Delete"),
134
- danger: !0,
135
- onSelect: () => void k(e)
136
- }
137
- ]
138
- })
139
- }),
140
- /* @__PURE__ */ l(a, {
141
- open: E !== null,
142
- topic: E === "new" ? null : E,
143
- onClose: () => D(null),
144
- onCreate: T.createTopic,
145
- onUpdate: T.updateTopic
134
+ ]
146
135
  })
147
- ]
148
- });
136
+ }),
137
+ /* @__PURE__ */ l(a, {
138
+ open: D !== null,
139
+ topic: D === "new" ? null : D,
140
+ onClose: () => O(null),
141
+ onCreate: E.createTopic,
142
+ onUpdate: E.updateTopic
143
+ })
144
+ ] });
149
145
  }
150
- export { S as TopicsPage };
146
+ export { C as TopicsPage };
151
147
 
152
148
  //# sourceMappingURL=TopicsPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TopicsPage.js","names":["COUNT","TopicsPage","AdminPageV2","TopicsList","tr","useTr","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","topics","useNotificationTopics","editing","setEditing","useState","toggle","result","topic","remove","done","PageHeader","Button","Plus","LoadError","EmptyState","DataRows","IconTile","Tag","kindWord","StatusChip","ActionMenu","TopicDialog"],"sources":["../../../src/v2/admin/TopicsPage.tsx"],"sourcesContent":["/**\n * Topics (BOFF-16785, C2; the mockup's `ntopics`), under fe-libs' `accountPagesV2`: the groups of\n * notifications people can turn on or off. A row each (who follows it, what it's about, on or off),\n * New topic and Edit in a short dialog, and ⋯ (turn off or on, delete). Admins only\n * (`AdminPageV2`). Today's hook and storage.\n */\nimport { useState } from 'react';\nimport { Plus, Tag } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n LoadError,\n StatusChip,\n useConfirm,\n useNotify,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../../hooks';\nimport type { NotificationTopic } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { kindWord } from './words';\nimport { TopicDialog } from './TopicDialog';\n\nconst COUNT = new Intl.NumberFormat();\n\nexport function TopicsPage() {\n return (\n <AdminPageV2 tool=\"topics\" back={false}>\n <TopicsList />\n </AdminPageV2>\n );\n}\n\nfunction TopicsList() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const topics = useNotificationTopics();\n const [editing, setEditing] = useState<NotificationTopic | 'new' | null>(null);\n\n const toggle = async (topic: NotificationTopic) => {\n const result = await topics.updateTopic(topic.id, { isActive: !topic.isActive });\n notify(\n result\n ? {\n title: topic.isActive\n ? tr('notifications.v3.topics.turnedOff', '{{name}} is off', { name: topic.name })\n : tr('notifications.v3.topics.turnedOn', '{{name}} is on', { name: topic.name }),\n tone: 'success',\n }\n : {\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n }\n );\n };\n\n const remove = async (topic: NotificationTopic) => {\n const yes = await confirm({\n title: tr('notifications.v3.topics.deleteTitle', 'Delete {{name}}?', { name: topic.name }),\n description: tr(\n 'notifications.v3.topics.deleteBody',\n 'People stop being able to choose it in their settings.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: topic.name,\n });\n if (!yes) return;\n const done = await topics.deleteTopic(topic.id);\n notify(\n done\n ? {\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: topic.name,\n }),\n tone: 'success',\n }\n : {\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n }\n );\n };\n\n return (\n <div data-account-pages-v2=\"notification-topics\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.topics.title', 'Topics')}\n description={tr(\n 'notifications.v3.topics.purpose',\n 'Groups of notifications people can turn on or off.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => setEditing('new')} data-testid=\"topics-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.topics.new', 'New topic')}\n </Button>\n }\n />\n {topics.error && topics.topics.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.topics.title', 'Topics')}\n error={topics.error}\n onRetry={() => void topics.refetch()}\n />\n ) : !topics.isLoading && topics.topics.length === 0 ? (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.topics.emptyTitle', 'No topics yet')}\n description={tr(\n 'notifications.v3.topics.emptyBody',\n 'Topics let people choose what they hear about, like “Billing” or “Product news”.'\n )}\n action={\n <Button onClick={() => setEditing('new')}>\n {tr('notifications.v3.topics.new', 'New topic')}\n </Button>\n }\n />\n ) : (\n <DataRows\n items={topics.topics}\n loading={topics.isLoading && topics.topics.length === 0}\n skeletonRows={4}\n getId={(topic) => topic.id}\n label={tr('notifications.v3.topics.title', 'Topics')}\n lead={{\n header: tr('notifications.v3.topics.topic', 'Topic'),\n media: () => (\n <IconTile size=\"sm\">\n <Tag aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (topic) => topic.name,\n subtitle: (topic) => topic.description || undefined,\n onOpen: (topic) => setEditing(topic),\n }}\n columns={[\n {\n id: 'people',\n header: tr('notifications.v3.topics.people', 'Following'),\n cell: (topic) => COUNT.format(topic.subscriberCount ?? 0),\n },\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (topic) => kindWord(topic.type, tr),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (topic) =>\n topic.isActive ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n ),\n },\n ]}\n actions={(topic) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: topic.name,\n })}\n items={[\n {\n id: 'edit',\n label: tr('notifications.v3.topics.edit', 'Edit'),\n onSelect: () => setEditing(topic),\n },\n {\n id: 'toggle',\n label: topic.isActive\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void toggle(topic),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(topic),\n },\n ]}\n />\n )}\n />\n )}\n <TopicDialog\n open={editing !== null}\n topic={editing === 'new' ? null : editing}\n onClose={() => setEditing(null)}\n onCreate={topics.createTopic}\n onUpdate={topics.upd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D,OAAO,MAAUJ,EAAM,OAAOmB,EAAM,mBAAmB,CAAC;KAC1D;KACA;MACE,IAAI;MACJ,QAAQf,EAAG,mCAAmC,OAAO;MACrD,OAAO,MAAU0B,EAASX,EAAM,MAAMf,CAAE;KAC1C;KACA;MACE,IAAI;MACJ,QAAQA,EAAG,qCAAqC,QAAQ;MACxD,OAAO,MACLe,EAAM,WACJ,kBAACY,GAAD;OAAY,QAAO;OAAM,UAAA3B,EAAG,uBAAuB,IAAI;MAAc,CAAA,IAErE,kBAAC2B,GAAD;OAAY,QAAO;OAAU,UAAA3B,EAAG,wBAAwB,KAAK;MAAc,CAAA;KAEjF;IACF;IACA,UAAU,MACR,kBAAC4B,GAAD;KACE,WAAU;KACV,OAAO5B,EAAG,yCAAyC,wBAAwB,EACzE,MAAMe,EAAM,KACd,CAAC;KACD,OAAO;MACL;OACE,IAAI;OACJ,OAAOf,EAAG,gCAAgC,MAAM;OAChD,gBAAgBW,EAAWI,CAAK;MAClC;MACA;OACE,IAAI;OACJ,OAAOA,EAAM,WACTf,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;OACrD,gBAAgB,KAAKa,EAAOE,CAAK;MACnC;MACA;OACE,IAAI;OACJ,OAAOf,EAAG,qCAAqC,QAAQ;OACvD,QAAQ;OACR,gBAAgB,KAAKgB,EAAOD,CAAK;MACnC;KACF;IACD,CAAA;GAEJ,CAAA;GAEH,kBAACc,GAAD;IACE,MAAMnB,MAAY;IAClB,OAAOA,MAAY,QAAQ,OAAOA;IAClC,eAAeC,EAAW,IAAI;IAC9B,UAAUH,EAAO;IACjB,UAAUA,EAAO;GAClB,CAAA;EACE;;AAET"}
1
+ {"version":3,"file":"TopicsPage.js","names":["COUNT","TopicsPage","AdminPageV2","TopicsList","tr","useTr","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","topics","useNotificationTopics","editing","setEditing","useState","toggle","result","topic","remove","done","WorkspacePage","PageHeader","Button","Plus","LoadError","EmptyState","DataRows","IconTile","Tag","kindWord","StatusChip","ActionMenu","TopicDialog"],"sources":["../../../src/v2/admin/TopicsPage.tsx"],"sourcesContent":["/**\n * Topics (BOFF-16785, C2; the mockup's `ntopics`), under fe-libs' `accountPagesV2`: the groups of\n * notifications people can turn on or off. A row each (who follows it, what it's about, on or off),\n * New topic and Edit in a short dialog, and ⋯ (turn off or on, delete). Admins only\n * (`AdminPageV2`). Today's hook and storage.\n */\nimport { useState } from 'react';\nimport { Plus, Tag } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n LoadError,\n StatusChip,\n WorkspacePage,\n useConfirm,\n useNotify,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../../hooks';\nimport type { NotificationTopic } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { kindWord } from './words';\nimport { TopicDialog } from './TopicDialog';\n\nconst COUNT = new Intl.NumberFormat();\n\nexport function TopicsPage() {\n return (\n <AdminPageV2 tool=\"topics\" back={false}>\n <TopicsList />\n </AdminPageV2>\n );\n}\n\nfunction TopicsList() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const topics = useNotificationTopics();\n const [editing, setEditing] = useState<NotificationTopic | 'new' | null>(null);\n\n const toggle = async (topic: NotificationTopic) => {\n const result = await topics.updateTopic(topic.id, { isActive: !topic.isActive });\n notify(\n result\n ? {\n title: topic.isActive\n ? tr('notifications.v3.topics.turnedOff', '{{name}} is off', { name: topic.name })\n : tr('notifications.v3.topics.turnedOn', '{{name}} is on', { name: topic.name }),\n tone: 'success',\n }\n : {\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n }\n );\n };\n\n const remove = async (topic: NotificationTopic) => {\n const yes = await confirm({\n title: tr('notifications.v3.topics.deleteTitle', 'Delete {{name}}?', { name: topic.name }),\n description: tr(\n 'notifications.v3.topics.deleteBody',\n 'People stop being able to choose it in their settings.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: topic.name,\n });\n if (!yes) return;\n const done = await topics.deleteTopic(topic.id);\n notify(\n done\n ? {\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: topic.name,\n }),\n tone: 'success',\n }\n : {\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n }\n );\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.topics.title', 'Topics')}\n description={tr(\n 'notifications.v3.topics.purpose',\n 'Groups of notifications people can turn on or off.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => setEditing('new')} data-testid=\"topics-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.topics.new', 'New topic')}\n </Button>\n }\n />\n {topics.error && topics.topics.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.topics.title', 'Topics')}\n error={topics.error}\n onRetry={() => void topics.refetch()}\n />\n ) : !topics.isLoading && topics.topics.length === 0 ? (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.topics.emptyTitle', 'No topics yet')}\n description={tr(\n 'notifications.v3.topics.emptyBody',\n 'Topics let people choose what they hear about, like “Billing” or “Product news”.'\n )}\n action={\n <Button onClick={() => setEditing('new')}>\n {tr('notifications.v3.topics.new', 'New topic')}\n </Button>\n }\n />\n ) : (\n <DataRows\n items={topics.topics}\n loading={topics.isLoading && topics.topics.length === 0}\n skeletonRows={4}\n getId={(topic) => topic.id}\n label={tr('notifications.v3.topics.title', 'Topics')}\n lead={{\n header: tr('notifications.v3.topics.topic', 'Topic'),\n media: () => (\n <IconTile size=\"sm\">\n <Tag aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (topic) => topic.name,\n subtitle: (topic) => topic.description || undefined,\n onOpen: (topic) => setEditing(topic),\n }}\n columns={[\n {\n id: 'people',\n header: tr('notifications.v3.topics.people', 'Following'),\n cell: (topic) => COUNT.format(topic.subscriberCount ?? 0),\n },\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (topic) => kindWord(topic.type, tr),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (topic) =>\n topic.isActive ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n ),\n },\n ]}\n actions={(topic) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: topic.name,\n })}\n items={[\n {\n id: 'edit',\n label: tr('notifications.v3.topics.edit', 'Edit'),\n onSelect: () => setEditing(topic),\n },\n {\n id: 'toggle',\n label: topic.isActive\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void toggle(topic),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(topic),\n },\n ]}\n />\n )}\n />\n )}\n <TopicDialog\n open={editing !== null}\n topic={editing === 'new' ? null : editing}\n onClose={() => setEditing(null)}\n onCreate={topics.createTopic}\n onUpdate={topics.updateTopic}\n />\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAMA,IAAQ,IAAI,KAAK,aAAa;AAEpC,SAAgBC,IAAa;CAC3B,OACE,kBAACC,GAAD;EAAa,MAAK;EAAS,MAAM;EAC/B,UAAA,kBAACC,GAAD,CAAa,CAAA;CACF,CAAA;AAEjB;AAEA,SAASA,IAAa;CACpB,IAAMC,IAAKC,EAAM,GACXC,IAAQC,EAAqB,GAC7BC,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AErE,kBAAC4B,GAAD;MAAY,QAAO;MAAU,UAAA5B,EAAG,wBAAwB,KAAK;KAAc,CAAA;IAEjF;GACF;GACA,UAAU,MACR,kBAAC6B,GAAD;IACE,WAAU;IACV,OAAO7B,EAAG,yCAAyC,wBAAwB,EACzE,MAAMe,EAAM,KACd,CAAC;IACD,OAAO;KACL;MACE,IAAI;MACJ,OAAOf,EAAG,gCAAgC,MAAM;MAChD,gBAAgBW,EAAWI,CAAK;KAClC;KACA;MACE,IAAI;MACJ,OAAOA,EAAM,WACTf,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;MACrD,gBAAgB,KAAKa,EAAOE,CAAK;KACnC;KACA;MACE,IAAI;MACJ,OAAOf,EAAG,qCAAqC,QAAQ;MACvD,QAAQ;MACR,gBAAgB,KAAKgB,EAAOD,CAAK;KACnC;IACF;GACD,CAAA;EAEJ,CAAA;EAEH,kBAACe,GAAD;GACE,MAAMpB,MAAY;GAClB,OAAOA,MAAY,QAAQ,OAAOA;GAClC,eAAeC,EAAW,IAAI;GAC9B,UAAUH,EAAO;GACjB,UAAUA,EAAO;EAClB,CAAA;CACY,EAAA,CAAA;AAEnB"}
@@ -19,7 +19,12 @@ function i(t, n) {
19
19
  return n ? `{{${n}}}` : e;
20
20
  });
21
21
  }
22
- var a = {
22
+ function a(e) {
23
+ let t = /* @__PURE__ */ new Set();
24
+ for (let r of e.matchAll(n)) t.add(r[1]);
25
+ return [...t];
26
+ }
27
+ var o = {
23
28
  firstname: "Maya",
24
29
  lastname: "Fernandes",
25
30
  name: "Maya Fernandes",
@@ -35,9 +40,9 @@ var a = {
35
40
  link: "https://app.example/runs/81",
36
41
  url: "https://app.example/runs/81"
37
42
  };
38
- function o(t, n) {
43
+ function s(t, n) {
39
44
  if (t.defaultValue) return t.defaultValue;
40
- let r = a[t.name.toLowerCase()];
45
+ let r = o[t.name.toLowerCase()];
41
46
  if (r) return r;
42
47
  switch (t.type) {
43
48
  case "number": return "3";
@@ -46,31 +51,31 @@ function o(t, n) {
46
51
  default: return e(t.name);
47
52
  }
48
53
  }
49
- function s(e, t, r) {
54
+ function c(e, t, r) {
50
55
  let i = new Map(t.map((e) => [e.name, e]));
51
56
  return e.replace(n, (e, t) => {
52
57
  let n = i.get(t);
53
- return n ? o(n, r) : e;
58
+ return n ? s(n, r) : e;
54
59
  });
55
60
  }
56
- function c(e) {
61
+ function l(e) {
57
62
  return typeof e == "object" && !!e && !Array.isArray(e);
58
63
  }
59
- function l(e) {
64
+ function u(e) {
60
65
  return e === "number" || e === "boolean" || e === "date" ? e : "string";
61
66
  }
62
- function u(e) {
63
- return Array.isArray(e) ? e.filter(c).flatMap((e) => typeof e.name == "string" && e.name ? [{
67
+ function d(e) {
68
+ return Array.isArray(e) ? e.filter(l).flatMap((e) => typeof e.name == "string" && e.name ? [{
64
69
  name: e.name,
65
- type: l(e.type),
70
+ type: u(e.type),
66
71
  defaultValue: e.defaultValue ? String(e.defaultValue) : ""
67
- }] : []) : c(e) ? Object.entries(e).map(([e, t]) => ({
72
+ }] : []) : l(e) ? Object.entries(e).map(([e, t]) => ({
68
73
  name: e,
69
- type: l(c(t) ? t.type : void 0),
70
- defaultValue: c(t) && t.defaultValue ? String(t.defaultValue) : ""
74
+ type: u(l(t) ? t.type : void 0),
75
+ defaultValue: l(t) && t.defaultValue ? String(t.defaultValue) : ""
71
76
  })) : [];
72
77
  }
73
- function d(e) {
78
+ function f(e) {
74
79
  let t = {};
75
80
  for (let n of e) t[n.name] = {
76
81
  type: n.type,
@@ -79,10 +84,10 @@ function d(e) {
79
84
  };
80
85
  return t;
81
86
  }
82
- function f(e) {
87
+ function p(e) {
83
88
  return e.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
84
89
  }
85
- var p = [
90
+ var m = [
86
91
  {
87
92
  name: "firstName",
88
93
  type: "string",
@@ -104,6 +109,6 @@ var p = [
104
109
  defaultValue: ""
105
110
  }
106
111
  ];
107
- export { p as COMMON_DETAILS, e as detailLabel, t as detailName, s as fillSamples, u as readDetails, o as sampleValue, f as templateSlug, r as toReadable, i as toStored, d as writeDetails };
112
+ export { m as COMMON_DETAILS, e as detailLabel, t as detailName, c as fillSamples, d as readDetails, s as sampleValue, p as templateSlug, r as toReadable, i as toStored, a as usedDetailNames, f as writeDetails };
108
113
 
109
114
  //# sourceMappingURL=templateText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateText.js","names":["detailLabel","words","name","detailName","label","index","word","STORED","toReadable","known","details","detail","text","match","toStored","byLabel","SAMPLES","sampleValue","locale","fillSamples","byName","stored","isRecord","value","asType","readDetails","json","item","writeDetails","out","templateSlug","COMMON_DETAILS"],"sources":["../../../src/v2/admin/templateText.ts"],"sourcesContent":["/**\n * A template's text as people read it (BOFF-16785, C2; the mockup's `ntemplate`): the stored\n * `{{firstName}}` shows as the detail `[First name]`, and Insert adds details, so nobody types\n * braces. Saving turns each known `[Label]` back into `{{name}}`; anything else in brackets stays\n * as written. The template's details are its `variables`, stored as today\n * (`{name: {type, required, defaultValue}}`).\n */\n\nexport type DetailType = 'string' | 'number' | 'boolean' | 'date';\n\nexport interface TemplateDetail {\n name: string;\n type: DetailType;\n defaultValue: string;\n}\n\n/** \"firstName\" → \"First name\", \"workflow_name\" → \"Workflow name\", \"url\" → \"Url\". */\nexport function detailLabel(name: string): string {\n const words = name\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase();\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : name;\n}\n\n/** \"First name\" → \"firstName\": the stored name for a detail someone adds. */\nexport function detailName(label: string): string {\n const words = label\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean);\n const name = words\n .map((word, index) =>\n index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n return /^[A-Za-z]/.test(name) ? name : name ? `detail${name}` : '';\n}\n\nconst STORED = /\\{\\{\\s*([A-Za-z_][\\w.]*)\\s*\\}\\}/g;\n\n/** Stored text as people read it: each `{{name}}` of a known detail becomes `[Label]`. */\nexport function toReadable(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const known = new Set(details.map((detail) => detail.name));\n return text.replace(STORED, (match, name: string) =>\n known.has(name) ? `[${detailLabel(name)}]` : match\n );\n}\n\n/** Text as people wrote it, ready to store: each `[Label]` of a known detail becomes `{{name}}`. */\nexport function toStored(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const byLabel = new Map(details.map((detail) => [detailLabel(detail.name), detail.name]));\n return text.replace(/\\[([^[\\]\\n]+)\\]/g, (match, label: string) => {\n const name = byLabel.get(label.trim());\n return name ? `{{${name}}}` : match;\n });\n}\n\n/** The details a stored text uses (`{{name}}`), in order, once each. */\nexport function usedDetailNames(stored: string): string[] {\n const names = new Set<string>();\n for (const match of stored.matchAll(STORED)) names.add(match[1]);\n return [...names];\n}\n\nconst SAMPLES: Record<string, string> = {\n firstname: 'Maya',\n lastname: 'Fernandes',\n name: 'Maya Fernandes',\n fullname: 'Maya Fernandes',\n email: 'maya@northwind.example',\n workflow: 'Lead routing',\n workflowname: 'Lead routing',\n step: 'New lead',\n stepname: 'New lead',\n workspace: 'Northwind',\n workspacename: 'Northwind',\n organization: 'Northwind Labs',\n link: 'https://app.example/runs/81',\n url: 'https://app.example/runs/81',\n};\n\n/** A sample for the preview: the detail's default, else a likely value, else its label. */\nexport function sampleValue(detail: TemplateDetail, locale?: string): string {\n if (detail.defaultValue) return detail.defaultValue;\n const known = SAMPLES[detail.name.toLowerCase()];\n if (known) return known;\n switch (detail.type) {\n case 'number':\n return '3';\n case 'boolean':\n return 'yes';\n case 'date':\n return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(\n new Date(2026, 10, 28)\n );\n default:\n return detailLabel(detail.name);\n }\n}\n\n/** Stored text with samples filled in, for the preview. Unknown `{{x}}` stay as they are. */\nexport function fillSamples(\n stored: string,\n details: readonly TemplateDetail[],\n locale?: string\n): string {\n const byName = new Map(details.map((detail) => [detail.name, detail]));\n return stored.replace(STORED, (match, name: string) => {\n const detail = byName.get(name);\n return detail ? sampleValue(detail, locale) : match;\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asType(value: unknown): DetailType {\n return value === 'number' || value === 'boolean' || value === 'date' ? value : 'string';\n}\n\n/** The stored `variables` (object, or the older array) as details. */\nexport function readDetails(json: unknown): TemplateDetail[] {\n if (Array.isArray(json)) {\n return json.filter(isRecord).flatMap((item) =>\n typeof item.name === 'string' && item.name\n ? [\n {\n name: item.name,\n type: asType(item.type),\n defaultValue: item.defaultValue ? String(item.defaultValue) : '',\n },\n ]\n : []\n );\n }\n if (!isRecord(json)) return [];\n return Object.entries(json).map(([name, value]) => ({\n name,\n type: asType(isRecord(value) ? value.type : undefined),\n defaultValue: isRecord(value) && value.defaultValue ? String(value.defaultValue) : '',\n }));\n}\n\n/** Details as stored today: `{name: {type, required, defaultValue?}}`. */\nexport function writeDetails(details: readonly TemplateDetail[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const detail of details) {\n out[detail.name] = {\n type: detail.type,\n required: true,\n ...(detail.defaultValue ? { defaultValue: detail.defaultValue } : {}),\n };\n }\n return out;\n}\n\n/** \"Hi there, Maya\" → \"hi-there-maya\": a template's web-safe key from its name. */\nexport function templateSlug(name: string): string {\n return name\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n .replace(/-+$/g, '');\n}\n\n/** Details most messages need, offered when the template doesn't have them yet. */\nexport const COMMON_DETAILS: readonly TemplateDetail[] = [\n { name: 'firstName', type: 'string', defaultValue: '' },\n { name: 'workflowName', type: 'string', defaultValue: '' },\n { name: 'stepName', type: 'string', defaultValue: '' },\n { name: 'link', type: 'string', defaultValue: '' },\n];\n"],"mappings":";AAiBA,SAAgBA,EAAY,GAAsB;CAChD,IAAMC,IAAQC,EACX,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,KAAK,CAAC,CACN,YAAY;CACf,OAAOD,IAAQA,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAM,MAAM,CAAC,IAAIC;AAClE;AAGA,SAAgBC,EAAW,GAAuB;CAQhD,IAAMD,IAPQE,EACX,UAAU,MAAM,CAAC,CACjB,QAAQ,UAAU,EAAE,CAAC,CACrB,QAAQ,kBAAkB,GAAG,CAAC,CAC9B,KAAK,CAAC,CACN,MAAM,GAAG,CAAC,CACV,OAAO,OACG,CAAA,CACV,KAAK,GAAM,MACVC,MAAU,IAAIC,EAAK,YAAY,IAAIA,EAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAC9F,CAAC,CACA,KAAK,EAAE;CACV,OAAO,YAAY,KAAKJ,CAAI,IAAIA,IAAOA,IAAO,SAASA,MAAS;AAClE;AAEA,IAAMK,IAAS;AAGf,SAAgBC,EAAW,GAAc,GAA0D;CACjG,IAAMC,IAAQ,IAAI,IAAIC,EAAQ,KAAK,MAAWC,EAAO,IAAI,CAAC;CAC1D,OAAOC,EAAK,QAAQL,IAAS,GAAO,MAClCE,EAAM,IAAIP,CAAI,IAAI,IAAIF,EAAYE,CAAI,EAAE,KAAKW,CAC/C;AACF;AAGA,SAAgBC,EAAS,GAAc,GAA0D;CAC/F,IAAMC,IAAU,IAAI,IAAIL,EAAQ,KAAK,MAAW,CAACV,EAAYW,EAAO,IAAI,GAAGA,EAAO,IAAI,CAAC,CAAC;CACxF,OAAOC,EAAK,QAAQ,qBAAq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AOJ,CAAQ,CAAC,CAAC,SAAS,MACpC,OAAOK,EAAK,QAAS,YAAYA,EAAK,OAClC,CACE;EACE,MAAMA,EAAK;EACX,MAAMH,EAAOG,EAAK,IAAI;EACtB,cAAcA,EAAK,eAAe,OAAOA,EAAK,YAAY,IAAI;CAChE,CACF,IACA,CAAC,CACP,IAEGL,EAASI,CAAI,IACX,OAAO,QAAQA,CAAI,CAAC,CAAC,KAAK,CAACxB,GAAMqB,QAAY;EAClD;EACA,MAAMC,EAAOF,EAASC,CAAK,IAAIA,EAAM,OAAO,KAAA,CAAS;EACrD,cAAcD,EAASC,CAAK,KAAKA,EAAM,eAAe,OAAOA,EAAM,YAAY,IAAI;CACrF,EAAE,IAL0B,CAAC;AAM/B;AAGA,SAAgBK,EAAa,GAA6D;CACxF,IAAMC,IAA+B,CAAC;CACtC,KAAK,IAAMlB,KAAUD,GACnB,EAAIC,EAAO,QAAQ;EACjB,MAAMA,EAAO;EACb,UAAU;EACV,GAAIA,EAAO,eAAe,EAAE,cAAcA,EAAO,aAAa,IAAI,CAAC;CACrE;CAEF,OAAOkB;AACT;AAGA,SAAgBC,EAAa,GAAsB;CACjD,OAAO5B,EACJ,UAAU,MAAM,CAAC,CACjB,QAAQ,UAAU,EAAE,CAAC,CACrB,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE,CAAC,CACvB,MAAM,GAAG,EAAE,CAAC,CACZ,QAAQ,QAAQ,EAAE;AACvB;AAGA,IAAa6B,IAA4C;CACvD;EAAE,MAAM;EAAa,MAAM;EAAU,cAAc;CAAG;CACtD;EAAE,MAAM;EAAgB,MAAM;EAAU,cAAc;CAAG;CACzD;EAAE,MAAM;EAAY,MAAM;EAAU,cAAc;CAAG;CACrD;EAAE,MAAM;EAAQ,MAAM;EAAU,cAAc;CAAG;AACnD"}
1
+ {"version":3,"file":"templateText.js","names":["detailLabel","words","name","detailName","label","index","word","STORED","toReadable","known","details","detail","text","match","toStored","byLabel","usedDetailNames","names","stored","SAMPLES","sampleValue","locale","fillSamples","byName","isRecord","value","asType","readDetails","json","item","writeDetails","out","templateSlug","COMMON_DETAILS"],"sources":["../../../src/v2/admin/templateText.ts"],"sourcesContent":["/**\n * A template's text as people read it (BOFF-16785, C2; the mockup's `ntemplate`): the stored\n * `{{firstName}}` shows as the detail `[First name]`, and Insert adds details, so nobody types\n * braces. Saving turns each known `[Label]` back into `{{name}}`; anything else in brackets stays\n * as written. The template's details are its `variables`, stored as today\n * (`{name: {type, required, defaultValue}}`).\n */\n\nexport type DetailType = 'string' | 'number' | 'boolean' | 'date';\n\nexport interface TemplateDetail {\n name: string;\n type: DetailType;\n defaultValue: string;\n}\n\n/** \"firstName\" → \"First name\", \"workflow_name\" → \"Workflow name\", \"url\" → \"Url\". */\nexport function detailLabel(name: string): string {\n const words = name\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim()\n .toLowerCase();\n return words ? words.charAt(0).toUpperCase() + words.slice(1) : name;\n}\n\n/** \"First name\" → \"firstName\": the stored name for a detail someone adds. */\nexport function detailName(label: string): string {\n const words = label\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .trim()\n .split(' ')\n .filter(Boolean);\n const name = words\n .map((word, index) =>\n index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()\n )\n .join('');\n return /^[A-Za-z]/.test(name) ? name : name ? `detail${name}` : '';\n}\n\nconst STORED = /\\{\\{\\s*([A-Za-z_][\\w.]*)\\s*\\}\\}/g;\n\n/** Stored text as people read it: each `{{name}}` of a known detail becomes `[Label]`. */\nexport function toReadable(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const known = new Set(details.map((detail) => detail.name));\n return text.replace(STORED, (match, name: string) =>\n known.has(name) ? `[${detailLabel(name)}]` : match\n );\n}\n\n/** Text as people wrote it, ready to store: each `[Label]` of a known detail becomes `{{name}}`. */\nexport function toStored(text: string, details: readonly Pick<TemplateDetail, 'name'>[]): string {\n const byLabel = new Map(details.map((detail) => [detailLabel(detail.name), detail.name]));\n return text.replace(/\\[([^[\\]\\n]+)\\]/g, (match, label: string) => {\n const name = byLabel.get(label.trim());\n return name ? `{{${name}}}` : match;\n });\n}\n\n/** The details a stored text uses (`{{name}}`), in order, once each. */\nexport function usedDetailNames(stored: string): string[] {\n const names = new Set<string>();\n for (const match of stored.matchAll(STORED)) names.add(match[1]);\n return [...names];\n}\n\nconst SAMPLES: Record<string, string> = {\n firstname: 'Maya',\n lastname: 'Fernandes',\n name: 'Maya Fernandes',\n fullname: 'Maya Fernandes',\n email: 'maya@northwind.example',\n workflow: 'Lead routing',\n workflowname: 'Lead routing',\n step: 'New lead',\n stepname: 'New lead',\n workspace: 'Northwind',\n workspacename: 'Northwind',\n organization: 'Northwind Labs',\n link: 'https://app.example/runs/81',\n url: 'https://app.example/runs/81',\n};\n\n/** A sample for the preview: the detail's default, else a likely value, else its label. */\nexport function sampleValue(detail: TemplateDetail, locale?: string): string {\n if (detail.defaultValue) return detail.defaultValue;\n const known = SAMPLES[detail.name.toLowerCase()];\n if (known) return known;\n switch (detail.type) {\n case 'number':\n return '3';\n case 'boolean':\n return 'yes';\n case 'date':\n return new Intl.DateTimeFormat(locale, { dateStyle: 'medium' }).format(\n new Date(2026, 10, 28)\n );\n default:\n return detailLabel(detail.name);\n }\n}\n\n/** Stored text with samples filled in, for the preview. Unknown `{{x}}` stay as they are. */\nexport function fillSamples(\n stored: string,\n details: readonly TemplateDetail[],\n locale?: string\n): string {\n const byName = new Map(details.map((detail) => [detail.name, detail]));\n return stored.replace(STORED, (match, name: string) => {\n const detail = byName.get(name);\n return detail ? sampleValue(detail, locale) : match;\n });\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction asType(value: unknown): DetailType {\n return value === 'number' || value === 'boolean' || value === 'date' ? value : 'string';\n}\n\n/** The stored `variables` (object, or the older array) as details. */\nexport function readDetails(json: unknown): TemplateDetail[] {\n if (Array.isArray(json)) {\n return json.filter(isRecord).flatMap((item) =>\n typeof item.name === 'string' && item.name\n ? [\n {\n name: item.name,\n type: asType(item.type),\n defaultValue: item.defaultValue ? String(item.defaultValue) : '',\n },\n ]\n : []\n );\n }\n if (!isRecord(json)) return [];\n return Object.entries(json).map(([name, value]) => ({\n name,\n type: asType(isRecord(value) ? value.type : undefined),\n defaultValue: isRecord(value) && value.defaultValue ? String(value.defaultValue) : '',\n }));\n}\n\n/** Details as stored today: `{name: {type, required, defaultValue?}}`. */\nexport function writeDetails(details: readonly TemplateDetail[]): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const detail of details) {\n out[detail.name] = {\n type: detail.type,\n required: true,\n ...(detail.defaultValue ? { defaultValue: detail.defaultValue } : {}),\n };\n }\n return out;\n}\n\n/** \"Hi there, Maya\" → \"hi-there-maya\": a template's web-safe key from its name. */\nexport function templateSlug(name: string): string {\n return name\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 60)\n .replace(/-+$/g, '');\n}\n\n/** Details most messages need, offered when the template doesn't have them yet. */\nexport const COMMON_DETAILS: readonly TemplateDetail[] = [\n { name: 'firstName', type: 'string', defaultValue: '' },\n { name: 'workflowName', type: 'string', defaultValue: '' },\n { name: 'stepName', type: 'string', defaultValue: '' },\n { name: 'link', type: 'string', defaultValue: '' },\n];\n"],"mappings":";AAiBA,SAAgBA,EAAY,GAAsB;CAChD,IAAMC,IAAQC,EACX,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,sBAAsB,OAAO,CAAC,CACtC,KAAK,CAAC,CACN,YAAY;CACf,OAAOD,IAAQA,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAM,MAAM,CAAC,IAAIC;AA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AAC,CACP,IAEGL,EAASI,CAAI,IACX,OAAO,QAAQA,CAAI,CAAC,CAAC,KAAK,CAAC1B,GAAMuB,QAAY;EAClD;EACA,MAAMC,EAAOF,EAASC,CAAK,IAAIA,EAAM,OAAO,KAAA,CAAS;EACrD,cAAcD,EAASC,CAAK,KAAKA,EAAM,eAAe,OAAOA,EAAM,YAAY,IAAI;CACrF,EAAE,IAL0B,CAAC;AAM/B;AAGA,SAAgBK,EAAa,GAA6D;CACxF,IAAMC,IAA+B,CAAC;CACtC,KAAK,IAAMpB,KAAUD,GACnB,EAAIC,EAAO,QAAQ;EACjB,MAAMA,EAAO;EACb,UAAU;EACV,GAAIA,EAAO,eAAe,EAAE,cAAcA,EAAO,aAAa,IAAI,CAAC;CACrE;CAEF,OAAOoB;AACT;AAGA,SAAgBC,EAAa,GAAsB;CACjD,OAAO9B,EACJ,UAAU,MAAM,CAAC,CACjB,QAAQ,UAAU,EAAE,CAAC,CACrB,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE,CAAC,CACvB,MAAM,GAAG,EAAE,CAAC,CACZ,QAAQ,QAAQ,EAAE;AACvB;AAGA,IAAa+B,IAA4C;CACvD;EAAE,MAAM;EAAa,MAAM;EAAU,cAAc;CAAG;CACtD;EAAE,MAAM;EAAgB,MAAM;EAAU,cAAc;CAAG;CACzD;EAAE,MAAM;EAAY,MAAM;EAAU,cAAc;CAAG;CACrD;EAAE,MAAM;EAAQ,MAAM;EAAU,cAAc;CAAG;AACnD"}
@@ -0,0 +1,4 @@
1
+ import { SendDraft } from './useSendDraft';
2
+ export declare function MessageTab({ draft }: {
3
+ draft: SendDraft;
4
+ }): import('react').JSX.Element;