@burdenoff/microfe-subscriberbot 2026.1023.1 → 2026.1029.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 (46) hide show
  1. package/dist/subscriberbot/admin/AdminDashboardPage.js +5 -5
  2. package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
  3. package/dist/subscriberbot/components/PostureOptions.d.ts +10 -0
  4. package/dist/subscriberbot/components/PostureOptions.d.ts.map +1 -0
  5. package/dist/subscriberbot/components/PostureOptions.js +20 -0
  6. package/dist/subscriberbot/components/PostureOptions.js.map +1 -0
  7. package/dist/subscriberbot/components/index.d.ts +2 -0
  8. package/dist/subscriberbot/components/index.d.ts.map +1 -1
  9. package/dist/subscriberbot/components/index.js +1 -0
  10. package/dist/subscriberbot/hooks/index.d.ts +1 -0
  11. package/dist/subscriberbot/hooks/index.d.ts.map +1 -1
  12. package/dist/subscriberbot/hooks/index.js +2 -1
  13. package/dist/subscriberbot/hooks/useAutonomousAgentMode.d.ts +15 -0
  14. package/dist/subscriberbot/hooks/useAutonomousAgentMode.d.ts.map +1 -0
  15. package/dist/subscriberbot/hooks/useAutonomousAgentMode.js +13 -0
  16. package/dist/subscriberbot/hooks/useAutonomousAgentMode.js.map +1 -0
  17. package/dist/subscriberbot/hooks/useSubscriberBotApi.d.ts.map +1 -1
  18. package/dist/subscriberbot/hooks/useSubscriberBotApi.js +9 -0
  19. package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
  20. package/dist/subscriberbot/pages/AssetVaultPage.js +16 -16
  21. package/dist/subscriberbot/pages/DashboardPage.js +23 -23
  22. package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
  23. package/dist/subscriberbot/pages/InboxPage.js +62 -62
  24. package/dist/subscriberbot/pages/InsightsPage.js +14 -14
  25. package/dist/subscriberbot/pages/InvoicesPage.js +66 -66
  26. package/dist/subscriberbot/pages/WorkflowsPage.js +20 -20
  27. package/dist/subscriberbot/pages/agents/AgentDetailPage.d.ts.map +1 -1
  28. package/dist/subscriberbot/pages/agents/AgentDetailPage.js +184 -182
  29. package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
  30. package/dist/subscriberbot/pages/agents/AgentNewPage.d.ts.map +1 -1
  31. package/dist/subscriberbot/pages/agents/AgentNewPage.js +77 -79
  32. package/dist/subscriberbot/pages/agents/AgentNewPage.js.map +1 -1
  33. package/dist/subscriberbot/pages/agents/AgentsListPage.d.ts.map +1 -1
  34. package/dist/subscriberbot/pages/agents/AgentsListPage.js +134 -133
  35. package/dist/subscriberbot/pages/agents/AgentsListPage.js.map +1 -1
  36. package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +64 -64
  37. package/dist/subscriberbot/pages/providers/ProviderNewPage.js +3 -3
  38. package/dist/subscriberbot/pages/providers/ProvidersListPage.js +18 -18
  39. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.d.ts.map +1 -1
  40. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +122 -89
  41. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
  42. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js +6 -6
  43. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js +7 -7
  44. package/dist/subscriberbot/types/index.d.ts +1 -0
  45. package/dist/subscriberbot/types/index.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/subscriberbot/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * Dashboard / Overview\n * @module subscriberbot/pages\n *\n * The Subscriber Bot landing page: a premium fintech console over every\n * recurring digital relationship — total recurring spend, portfolio-by-status,\n * upcoming renewals, the action-required inbox, and outstanding invoices. Every\n * number and chart is COMPUTED from real data returned by\n * `wspace-subscriberbot-svc` — nothing is mocked.\n */\n\nimport { useMemo } from 'react';\nimport {\n Repeat2,\n Wallet,\n CalendarClock,\n Inbox,\n AlertTriangle,\n ArrowRight,\n ArrowUpRight,\n Sparkles,\n Bot,\n ShieldCheck,\n} from 'lucide-react';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n StatusBadge,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n Donut,\n Legend,\n Timeline,\n type Segment,\n type TimelineItem,\n} from '../components';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useRelationships,\n useInvoices,\n useInboxMessages,\n useRenewalEvents,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\nimport { formatCurrency, formatRelativeTime, formatEnumLabel } from '../utils/formatters';\nimport type { SubBillingInterval, SubRelationship, SubRenewalEvent } from '../types';\n\n// Normalize any billing interval to an approximate monthly multiplier so we can\n// express total recurring spend as one comparable \"per month\" number.\nconst MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n// A single normalized \"what charges next\" row, sourced from real renewal events\n// when present, otherwise derived from each relationship's own `renewsAt`.\ninterface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n soon: boolean;\n}\n\nconst MS_PER_DAY = 1000 * 60 * 60 * 24;\n\nexport function DashboardPage() {\n const { navigateTo, currentUser } = useSubscriberBot();\n const tr = useTr();\n\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const invoicesQ = useInvoices({ pagination: { limit: 50, offset: 0 } });\n const inboxQ = useInboxMessages({ pagination: { limit: 50, offset: 0 } });\n const renewalsQ = useRenewalEvents({ upcomingOnly: true });\n\n const relationships = useMemo(() => relationshipsQ.data?.items ?? [], [relationshipsQ.data]);\n const invoices = useMemo(() => invoicesQ.data?.items ?? [], [invoicesQ.data]);\n const messages = useMemo(() => inboxQ.data?.items ?? [], [inboxQ.data]);\n const renewals = useMemo(() => renewalsQ.data ?? [], [renewalsQ.data]);\n\n // Fast label lookup so renewal rows can name the relationship they belong to.\n const relationshipById = useMemo(() => {\n const map = new Map<string, SubRelationship>();\n relationships.forEach((r) => map.set(r.id, r));\n return map;\n }, [relationships]);\n\n const stats = useMemo(() => {\n const active = relationships.filter((r) => r.status === 'ACTIVE' || r.status === 'TRIAL');\n const monthlySpend = active.reduce(\n (sum, r) => sum + r.amount * (MONTHLY_FACTOR[r.interval] ?? 1),\n 0\n );\n const primaryCurrency = active[0]?.currency ?? relationships[0]?.currency ?? 'USD';\n // BOFF-8660 — KPI must match the Universal Inbox \"need action\" counter\n // and the on-page Needs-attention list, both of which count by\n // `actionRequired` alone (read state is irrelevant). The previous\n // `&& !m.isRead` clause made the tile show 0 the moment the user read\n // the only action-required message, contradicting the surfaces below.\n const actionRequired = messages.filter((m) => m.actionRequired).length;\n const openInvoices = invoices.filter(\n (i) => i.status === 'ISSUED' || i.status === 'OVERDUE' || i.status === 'FAILED'\n );\n const openInvoiceTotal = openInvoices.reduce((sum, i) => sum + i.total, 0);\n const atRisk = relationships.filter(\n (r) => r.status === 'PAST_DUE' || r.status === 'LAPSED'\n ).length;\n\n return {\n activeCount: active.length,\n totalCount: relationships.length,\n monthlySpend,\n primaryCurrency,\n actionRequired,\n openInvoiceCount: openInvoices.length,\n openInvoiceTotal,\n atRisk,\n };\n }, [relationships, messages, invoices]);\n\n // Portfolio-by-status → donut segments (grouped from real relationships).\n const statusSegments = useMemo<Segment[]>(() => {\n const counts = new Map<string, number>();\n relationships.forEach((r) => counts.set(r.status, (counts.get(r.status) ?? 0) + 1));\n return Array.from(counts.entries())\n .sort((a, b) => b[1] - a[1])\n .map(([status, value]) => ({ label: formatEnumLabel(status), value }));\n }, [relationships]);\n\n // Normalize upcoming renewals: prefer real renewal events, fall back to\n // relationship `renewsAt` when the event stream is empty. Sorted soonest-first.\n const upcoming = useMemo<UpcomingRenewal[]>(() => {\n const now = Date.now();\n const fromEvents: UpcomingRenewal[] = renewals.map((e: SubRenewalEvent) => {\n const rel = relationshipById.get(e.relationshipId);\n const t = new Date(e.occursAt).getTime();\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? formatEnumLabel(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n soon: !Number.isNaN(t) && t - now <= 7 * MS_PER_DAY,\n };\n });\n\n if (fromEvents.length > 0) {\n return fromEvents\n .filter((u) => !Number.isNaN(new Date(u.when).getTime()))\n .sort((a, b) => new Date(a.when).getTime() - new Date(b.when).getTime());\n }\n\n // Derive from relationships that carry a future renewal date.\n return relationships\n .filter((r) => {\n if (!r.renewsAt) return false;\n const t = new Date(r.renewsAt).getTime();\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const t = new Date(r.renewsAt as string).getTime();\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when: r.renewsAt as string,\n amount: r.amount,\n currency: r.currency,\n soon: t - now <= 7 * MS_PER_DAY,\n };\n })\n .sort((a, b) => new Date(a.when).getTime() - new Date(b.when).getTime());\n }, [renewals, relationships, relationshipById]);\n\n const timelineItems = useMemo<TimelineItem[]>(\n () =>\n upcoming.slice(0, 6).map((u) => ({\n title: u.title,\n sub: formatRelativeTime(u.when),\n tone: u.soon ? 'warning' : 'default',\n meta:\n u.amount != null\n ? formatCurrency(u.amount, u.currency ?? stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })\n : undefined,\n })),\n [upcoming, stats.primaryCurrency]\n );\n\n const actionMessages = useMemo(() => messages.filter((m) => m.actionRequired), [messages]);\n\n const isLoading =\n relationshipsQ.isLoading || invoicesQ.isLoading || inboxQ.isLoading || renewalsQ.isLoading;\n const isError =\n relationshipsQ.isError && invoicesQ.isError && inboxQ.isError && renewalsQ.isError;\n\n if (isLoading) {\n return (\n <PageLayout\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <LoadingView label={tr('dashboard.loading', 'Loading your subscription portfolio…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <ErrorView\n message={tr(\n 'dashboard.error',\n \"We couldn't reach the Subscriber Bot service. Please try again.\"\n )}\n onRetry={() => {\n void relationshipsQ.refetch();\n void invoicesQ.refetch();\n void inboxQ.refetch();\n void renewalsQ.refetch();\n }}\n />\n </PageLayout>\n );\n }\n\n const greetingName = currentUser?.firstName || currentUser?.name?.split(' ')[0];\n\n const quickActions = [\n {\n labelKey: 'dashboard.quickActions.addRelationship.label',\n descriptionKey: 'dashboard.quickActions.addRelationship.description',\n fallbackLabel: 'Add a relationship',\n fallbackDescription: 'Track a new subscription',\n icon: <Repeat2 className=\"h-5 w-5\" />,\n path: '/relationships/new',\n },\n {\n labelKey: 'dashboard.quickActions.discoverProviders.label',\n descriptionKey: 'dashboard.quickActions.discoverProviders.description',\n fallbackLabel: 'Discover providers',\n fallbackDescription: 'Browse the registry',\n icon: <Sparkles className=\"h-5 w-5\" />,\n path: '/providers',\n },\n {\n labelKey: 'dashboard.quickActions.openInbox.label',\n descriptionKey: 'dashboard.quickActions.openInbox.description',\n fallbackLabel: 'Open inbox',\n fallbackDescription: 'Merged communications',\n icon: <Inbox className=\"h-5 w-5\" />,\n path: '/inbox',\n },\n {\n labelKey: 'dashboard.quickActions.configureAgents.label',\n descriptionKey: 'dashboard.quickActions.configureAgents.description',\n fallbackLabel: 'Configure agents',\n fallbackDescription: 'Automate your portfolio',\n icon: <Bot className=\"h-5 w-5\" />,\n path: '/agents',\n },\n ];\n\n return (\n <PageLayout\n title={\n greetingName\n ? tr('dashboard.welcomeBack', 'Welcome back, {{name}}', { name: greetingName })\n : tr('dashboard.title', 'Overview')\n }\n description={tr(\n 'dashboard.description',\n 'Everything you pay for on repeat — in one intelligent console.'\n )}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'dashboard.purpose',\n 'Subscriber Bot is your system of record for every recurring digital relationship. See total recurring spend, what renews next, what needs action, and what to optimize — all from real data across your providers.'\n )}\n </PagePurpose>\n\n {/* KPI tiles */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <MetricsCard\n featured\n icon={<Wallet />}\n value={formatCurrency(stats.monthlySpend, stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })}\n label={tr('dashboard.metrics.recurringSpend', 'Recurring spend / month')}\n />\n <MetricsCard\n icon={<Repeat2 />}\n value={stats.activeCount}\n label={tr('dashboard.metrics.activeRelationships', 'Active relationships')}\n />\n <MetricsCard\n icon={<CalendarClock />}\n value={upcoming.length}\n label={tr('dashboard.metrics.upcomingRenewals', 'Upcoming renewals')}\n />\n <MetricsCard\n icon={<AlertTriangle />}\n value={stats.actionRequired}\n label={tr('dashboard.metrics.needsAction', 'Need your action')}\n trend={stats.actionRequired > 0 ? 'down' : undefined}\n />\n </div>\n\n {/* Main console: renewals (left) + portfolio donut & needs-attention (right) */}\n <div className=\"mt-8 grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Upcoming renewals timeline — spans two columns on desktop */}\n <div className=\"lg:col-span-2\">\n <Section\n title={tr('dashboard.renewals.title', 'Upcoming renewals')}\n description={tr(\n 'dashboard.renewals.description',\n \"What's charging next across your portfolio\"\n )}\n className=\"mt-0\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-text-link hover:underline\"\n >\n {tr('common.viewAll', 'View all')} <ArrowUpRight className=\"h-3.5 w-3.5\" />\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-5\">\n {timelineItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('dashboard.renewals.emptyTitle', 'No upcoming renewals')}\n description={tr(\n 'dashboard.renewals.emptyDescription',\n 'Renewals you track will appear here ahead of time.'\n )}\n />\n ) : (\n <Timeline items={timelineItems} />\n )}\n </GlassCard>\n </Section>\n </div>\n\n {/* Right rail: portfolio-by-status donut + needs-attention panel */}\n <div className=\"flex flex-col gap-6\">\n <Section\n title={tr('dashboard.portfolio.title', 'Portfolio by status')}\n description={tr('dashboard.portfolio.description', 'Where your relationships stand')}\n className=\"mt-0\"\n >\n <GlassCard treatment=\"glass\" className=\"p-5\">\n {statusSegments.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('dashboard.portfolio.emptyTitle', 'No relationships yet')}\n description={tr(\n 'dashboard.portfolio.emptyDescription',\n 'Add your first subscription to see the breakdown.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships/new')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('dashboard.portfolio.addRelationship', 'Add relationship')}\n </button>\n }\n />\n ) : (\n <div className=\"flex flex-col items-center gap-5 sm:flex-row sm:items-center lg:flex-col xl:flex-row\">\n <Donut\n data={statusSegments}\n size={148}\n thickness={20}\n centerLabel={String(stats.totalCount)}\n centerSub={tr(\n stats.totalCount === 1\n ? 'dashboard.portfolio.relationshipSingular'\n : 'dashboard.portfolio.relationshipPlural',\n stats.totalCount === 1 ? 'relationship' : 'relationships'\n )}\n className=\"shrink-0\"\n />\n <Legend data={statusSegments} className=\"w-full min-w-0 flex-1\" />\n </div>\n )}\n </GlassCard>\n </Section>\n\n <Section\n title={tr('dashboard.needsAttention.title', 'Needs attention')}\n description={tr(\n 'dashboard.needsAttention.description',\n 'Required actions from the Universal Inbox'\n )}\n className=\"mt-0\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"text-sm font-medium text-text-link hover:underline\"\n >\n {tr('dashboard.needsAttention.openInbox', 'Open inbox')}\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-3\">\n {actionMessages.length === 0 ? (\n <div className=\"flex items-center gap-3 px-2 py-4\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-status-success-bg-subtle text-status-success-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('dashboard.needsAttention.allCaughtUp', \"You're all caught up\")}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'dashboard.needsAttention.allCaughtUpDescription',\n 'Required actions across your channels will surface here.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <ul className=\"space-y-1\">\n {actionMessages.slice(0, 5).map((message) => (\n <li key={message.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"flex w-full items-center gap-3 rounded-lg border-l-2 border-status-warning-text/60 bg-status-warning-bg-subtle/50 p-3 text-left transition-colors hover:bg-status-warning-bg-subtle\"\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {message.subject ||\n tr('dashboard.needsAttention.noSubject', '(no subject)')}\n </p>\n {message.preview && (\n <p className=\"truncate text-xs text-text-secondary\">\n {message.preview}\n </p>\n )}\n </div>\n <StatusBadge status={message.category} className=\"shrink-0\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </Section>\n </div>\n </div>\n\n {/* Open-invoice call-out (only when there is real outstanding balance) */}\n {stats.openInvoiceCount > 0 && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/invoices')}\n className=\"mt-6 flex w-full items-center justify-between gap-3 rounded-xl border border-status-warning-text/30 bg-status-warning-bg-subtle px-5 py-4 text-left transition-shadow hover:shadow-md\"\n >\n <div className=\"flex items-center gap-3\">\n <AlertTriangle className=\"h-5 w-5 shrink-0 text-status-warning-text\" />\n <span className=\"text-sm font-medium text-status-warning-text\">\n {tr(\n 'dashboard.openInvoices.label',\n '{{count}} open invoice · {{amount}} outstanding',\n {\n count: stats.openInvoiceCount,\n amount: formatCurrency(stats.openInvoiceTotal, stats.primaryCurrency),\n }\n )}\n </span>\n </div>\n <ArrowRight className=\"h-4 w-4 shrink-0 text-status-warning-text\" />\n </button>\n )}\n\n {/* Quick actions */}\n <Section\n title={tr('dashboard.quickActions.title', 'Quick actions')}\n description={tr('dashboard.quickActions.description', 'Jump straight into your workflow')}\n >\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {quickActions.map((qa) => (\n <button\n key={qa.path}\n type=\"button\"\n onClick={() => navigateTo(qa.path)}\n className=\"group flex items-center gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 text-left transition-all hover:-translate-y-0.5 hover:border-border-seam hover:shadow-md\"\n >\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n {qa.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-sm font-medium text-text-primary\">\n {tr(qa.labelKey, qa.fallbackLabel)}\n </span>\n <span className=\"block text-xs text-text-secondary\">\n {tr(qa.descriptionKey, qa.fallbackDescription)}\n </span>\n </span>\n <ArrowRight className=\"h-4 w-4 shrink-0 text-text-secondary transition-transform group-hover:translate-x-0.5\" />\n </button>\n ))}\n </div>\n </Section>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAM,IAAqD;CACzD,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAcM,IAAa,MAAO,KAAK,KAAK;AAEpC,SAAgB,IAAgB;CAC9B,IAAM,EAAE,eAAY,mBAAgB,EAAiB,GAC/C,IAAK,EAAM,GAEX,IAAiB,EAAiB,EAAE,YAAY;EAAE,OAAO;EAAK,QAAQ;CAAE,EAAE,CAAC,GAC3E,IAAY,EAAY,EAAE,YAAY;EAAE,OAAO;EAAI,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BAAC,GAAD;UAAa,QAAQ,EAAQ;UAAU,WAAU;SAAY,CAAA,CACvD;WACN,GAnBK,EAAQ,EAmBb,CACL;OACC,CAAA;MAEG,CAAA;KACJ,CAAA,CACN;MACF;;GAGJ,EAAM,mBAAmB,KACxB,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,EAAW,WAAW;IACrC,WAAU;cAHZ,CAKE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD,EAAe,WAAU,4CAA6C,CAAA,GACtE,kBAAC,QAAD;MAAM,WAAU;gBACb,EACC,gCACA,mDACA;OACE,OAAO,EAAM;OACb,QAAQ,EAAe,EAAM,kBAAkB,EAAM,eAAe;MACtE,CACF;KACI,CAAA,CACH;QACL,kBAAC,GAAD,EAAY,WAAU,4CAA6C,CAAA,CAC7D;;GAIV,kBAAC,GAAD;IACE,OAAO,EAAG,gCAAgC,eAAe;IACzD,aAAa,EAAG,sCAAsC,kCAAkC;cAExF,kBAAC,OAAD;KAAK,WAAU;eACZ,GAAa,KAAK,MACjB,kBAAC,UAAD;MAEE,MAAK;MACL,eAAe,EAAW,EAAG,IAAI;MACjC,WAAU;gBAJZ;OAME,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAG;OACA,CAAA;OACN,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CACE,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAG,EAAG,UAAU,EAAG,aAAa;QAC7B,CAAA,GACN,kBAAC,QAAD;SAAM,WAAU;mBACb,EAAG,EAAG,gBAAgB,EAAG,mBAAmB;QACzC,CAAA,CACF;;OACN,kBAAC,GAAD,EAAY,WAAU,wFAAyF,CAAA;MACzG;QAjBD,EAAG,IAiBF,CACT;IACE,CAAA;GACE,CAAA;EACC;;AAEhB"}
1
+ {"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/subscriberbot/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * Dashboard / Overview\n * @module subscriberbot/pages\n *\n * The Subscriber Bot landing page: a premium fintech console over every\n * recurring digital relationship — total recurring spend, portfolio-by-status,\n * upcoming renewals, the action-required inbox, and outstanding invoices. Every\n * number and chart is COMPUTED from real data returned by\n * `wspace-subscriberbot-svc` — nothing is mocked.\n */\n\nimport { useMemo } from 'react';\nimport {\n Repeat2,\n Wallet,\n CalendarClock,\n Inbox,\n AlertTriangle,\n ArrowRight,\n ArrowUpRight,\n Sparkles,\n Bot,\n ShieldCheck,\n} from 'lucide-react';\nimport { PagePurpose, GlassCard } from '@burdenoff/fe-libs/ui';\nimport {\n PageLayout,\n MetricsCard,\n StatusBadge,\n EmptyState,\n LoadingView,\n ErrorView,\n Section,\n Donut,\n Legend,\n Timeline,\n type Segment,\n type TimelineItem,\n} from '../components';\nimport { useSubscriberBot } from '../context/SubscriberBotContext';\nimport {\n useRelationships,\n useInvoices,\n useInboxMessages,\n useRenewalEvents,\n} from '../hooks/useSubscriberBotApi';\nimport { useTr } from '../hooks/useTr';\nimport { formatCurrency, formatRelativeTime, formatEnumLabel } from '../utils/formatters';\nimport type { SubBillingInterval, SubRelationship, SubRenewalEvent } from '../types';\n\n// Normalize any billing interval to an approximate monthly multiplier so we can\n// express total recurring spend as one comparable \"per month\" number.\nconst MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n// A single normalized \"what charges next\" row, sourced from real renewal events\n// when present, otherwise derived from each relationship's own `renewsAt`.\ninterface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n soon: boolean;\n}\n\nconst MS_PER_DAY = 1000 * 60 * 60 * 24;\n\nexport function DashboardPage() {\n const { navigateTo, currentUser } = useSubscriberBot();\n const tr = useTr();\n\n const relationshipsQ = useRelationships({ pagination: { limit: 100, offset: 0 } });\n const invoicesQ = useInvoices({ pagination: { limit: 50, offset: 0 } });\n const inboxQ = useInboxMessages({ pagination: { limit: 50, offset: 0 } });\n const renewalsQ = useRenewalEvents({ upcomingOnly: true });\n\n const relationships = useMemo(() => relationshipsQ.data?.items ?? [], [relationshipsQ.data]);\n const invoices = useMemo(() => invoicesQ.data?.items ?? [], [invoicesQ.data]);\n const messages = useMemo(() => inboxQ.data?.items ?? [], [inboxQ.data]);\n const renewals = useMemo(() => renewalsQ.data ?? [], [renewalsQ.data]);\n\n // Fast label lookup so renewal rows can name the relationship they belong to.\n const relationshipById = useMemo(() => {\n const map = new Map<string, SubRelationship>();\n relationships.forEach((r) => map.set(r.id, r));\n return map;\n }, [relationships]);\n\n const stats = useMemo(() => {\n const active = relationships.filter((r) => r.status === 'ACTIVE' || r.status === 'TRIAL');\n const monthlySpend = active.reduce(\n (sum, r) => sum + r.amount * (MONTHLY_FACTOR[r.interval] ?? 1),\n 0\n );\n const primaryCurrency = active[0]?.currency ?? relationships[0]?.currency ?? 'USD';\n // BOFF-8660 — KPI must match the Universal Inbox \"need action\" counter\n // and the on-page Needs-attention list, both of which count by\n // `actionRequired` alone (read state is irrelevant). The previous\n // `&& !m.isRead` clause made the tile show 0 the moment the user read\n // the only action-required message, contradicting the surfaces below.\n const actionRequired = messages.filter((m) => m.actionRequired).length;\n const openInvoices = invoices.filter(\n (i) => i.status === 'ISSUED' || i.status === 'OVERDUE' || i.status === 'FAILED'\n );\n const openInvoiceTotal = openInvoices.reduce((sum, i) => sum + i.total, 0);\n const atRisk = relationships.filter(\n (r) => r.status === 'PAST_DUE' || r.status === 'LAPSED'\n ).length;\n\n return {\n activeCount: active.length,\n totalCount: relationships.length,\n monthlySpend,\n primaryCurrency,\n actionRequired,\n openInvoiceCount: openInvoices.length,\n openInvoiceTotal,\n atRisk,\n };\n }, [relationships, messages, invoices]);\n\n // Portfolio-by-status → donut segments (grouped from real relationships).\n const statusSegments = useMemo<Segment[]>(() => {\n const counts = new Map<string, number>();\n relationships.forEach((r) => counts.set(r.status, (counts.get(r.status) ?? 0) + 1));\n return Array.from(counts.entries())\n .sort((a, b) => b[1] - a[1])\n .map(([status, value]) => ({ label: formatEnumLabel(status), value }));\n }, [relationships]);\n\n // Normalize upcoming renewals: prefer real renewal events, fall back to\n // relationship `renewsAt` when the event stream is empty. Sorted soonest-first.\n const upcoming = useMemo<UpcomingRenewal[]>(() => {\n const now = Date.now();\n const fromEvents: UpcomingRenewal[] = renewals.map((e: SubRenewalEvent) => {\n const rel = relationshipById.get(e.relationshipId);\n const t = new Date(e.occursAt).getTime();\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? formatEnumLabel(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n soon: !Number.isNaN(t) && t - now <= 7 * MS_PER_DAY,\n };\n });\n\n if (fromEvents.length > 0) {\n return fromEvents\n .filter((u) => !Number.isNaN(new Date(u.when).getTime()))\n .sort((a, b) => new Date(a.when).getTime() - new Date(b.when).getTime());\n }\n\n // Derive from relationships that carry a future renewal date.\n return relationships\n .filter((r) => {\n if (!r.renewsAt) return false;\n const t = new Date(r.renewsAt).getTime();\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const t = new Date(r.renewsAt as string).getTime();\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when: r.renewsAt as string,\n amount: r.amount,\n currency: r.currency,\n soon: t - now <= 7 * MS_PER_DAY,\n };\n })\n .sort((a, b) => new Date(a.when).getTime() - new Date(b.when).getTime());\n }, [renewals, relationships, relationshipById]);\n\n const timelineItems = useMemo<TimelineItem[]>(\n () =>\n upcoming.slice(0, 6).map((u) => ({\n title: u.title,\n sub: formatRelativeTime(u.when),\n tone: u.soon ? 'warning' : 'default',\n meta:\n u.amount != null\n ? formatCurrency(u.amount, u.currency ?? stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })\n : undefined,\n })),\n [upcoming, stats.primaryCurrency]\n );\n\n const actionMessages = useMemo(() => messages.filter((m) => m.actionRequired), [messages]);\n\n const isLoading =\n relationshipsQ.isLoading || invoicesQ.isLoading || inboxQ.isLoading || renewalsQ.isLoading;\n const isError =\n relationshipsQ.isError && invoicesQ.isError && inboxQ.isError && renewalsQ.isError;\n\n if (isLoading) {\n return (\n <PageLayout\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <LoadingView label={tr('dashboard.loading', 'Loading your subscription portfolio…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout\n title={tr('dashboard.title', 'Overview')}\n description={tr(\n 'dashboard.description',\n 'Your recurring digital relationships at a glance'\n )}\n >\n <ErrorView\n message={tr(\n 'dashboard.error',\n \"We couldn't reach the Subscriber Bot service. Please try again.\"\n )}\n onRetry={() => {\n void relationshipsQ.refetch();\n void invoicesQ.refetch();\n void inboxQ.refetch();\n void renewalsQ.refetch();\n }}\n />\n </PageLayout>\n );\n }\n\n const greetingName = currentUser?.firstName || currentUser?.name?.split(' ')[0];\n\n const quickActions = [\n {\n labelKey: 'dashboard.quickActions.addRelationship.label',\n descriptionKey: 'dashboard.quickActions.addRelationship.description',\n fallbackLabel: 'Add a relationship',\n fallbackDescription: 'Track a new subscription',\n icon: <Repeat2 className=\"h-5 w-5\" />,\n path: '/relationships/new',\n },\n {\n labelKey: 'dashboard.quickActions.discoverProviders.label',\n descriptionKey: 'dashboard.quickActions.discoverProviders.description',\n fallbackLabel: 'Discover providers',\n fallbackDescription: 'Browse the registry',\n icon: <Sparkles className=\"h-5 w-5\" />,\n path: '/providers',\n },\n {\n labelKey: 'dashboard.quickActions.openInbox.label',\n descriptionKey: 'dashboard.quickActions.openInbox.description',\n fallbackLabel: 'Open inbox',\n fallbackDescription: 'Merged communications',\n icon: <Inbox className=\"h-5 w-5\" />,\n path: '/inbox',\n },\n {\n labelKey: 'dashboard.quickActions.configureAgents.label',\n descriptionKey: 'dashboard.quickActions.configureAgents.description',\n fallbackLabel: 'Configure agents',\n fallbackDescription: 'Automate your portfolio',\n icon: <Bot className=\"h-5 w-5\" />,\n path: '/agents',\n },\n ];\n\n return (\n <PageLayout\n title={\n greetingName\n ? tr('dashboard.welcomeBack', 'Welcome back, {{name}}', { name: greetingName })\n : tr('dashboard.title', 'Overview')\n }\n description={tr(\n 'dashboard.description',\n 'Everything you pay for on repeat — in one intelligent console.'\n )}\n >\n <PagePurpose className=\"mb-6\">\n {tr(\n 'dashboard.purpose',\n 'Subscriber Bot is your system of record for every recurring digital relationship. See total recurring spend, what renews next, what needs action, and what to optimize — all from real data across your providers.'\n )}\n </PagePurpose>\n\n {/* KPI tiles */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <MetricsCard\n featured\n icon={<Wallet />}\n value={formatCurrency(stats.monthlySpend, stats.primaryCurrency, {\n maximumFractionDigits: 0,\n })}\n label={tr('dashboard.metrics.recurringSpend', 'Recurring spend / month')}\n />\n <MetricsCard\n icon={<Repeat2 />}\n value={stats.activeCount}\n label={tr('dashboard.metrics.activeRelationships', 'Active relationships')}\n />\n <MetricsCard\n icon={<CalendarClock />}\n value={upcoming.length}\n label={tr('dashboard.metrics.upcomingRenewals', 'Upcoming renewals')}\n />\n <MetricsCard\n icon={<AlertTriangle />}\n value={stats.actionRequired}\n label={tr('dashboard.metrics.needsAction', 'Need your action')}\n trend={stats.actionRequired > 0 ? 'down' : undefined}\n />\n </div>\n\n {/* Main console: renewals (left) + portfolio donut & needs-attention (right) */}\n <div className=\"mt-8 grid grid-cols-1 gap-6 lg:grid-cols-3\">\n {/* Upcoming renewals timeline — spans two columns on desktop */}\n <div className=\"lg:col-span-2\">\n <Section\n title={tr('dashboard.renewals.title', 'Upcoming renewals')}\n description={tr(\n 'dashboard.renewals.description',\n \"What's charging next across your portfolio\"\n )}\n className=\"mt-0\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-text-link hover:underline\"\n >\n {tr('common.viewAll', 'View all')} <ArrowUpRight className=\"h-3.5 w-3.5\" />\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-5\">\n {timelineItems.length === 0 ? (\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('dashboard.renewals.emptyTitle', 'No upcoming renewals')}\n description={tr(\n 'dashboard.renewals.emptyDescription',\n 'Renewals you track will appear here ahead of time.'\n )}\n />\n ) : (\n <Timeline items={timelineItems} />\n )}\n </GlassCard>\n </Section>\n </div>\n\n {/* Right rail: portfolio-by-status donut + needs-attention panel */}\n <div className=\"flex flex-col gap-6\">\n <Section\n title={tr('dashboard.portfolio.title', 'Portfolio by status')}\n description={tr('dashboard.portfolio.description', 'Where your relationships stand')}\n className=\"mt-0\"\n >\n <GlassCard treatment=\"glass\" className=\"p-5\">\n {statusSegments.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('dashboard.portfolio.emptyTitle', 'No relationships yet')}\n description={tr(\n 'dashboard.portfolio.emptyDescription',\n 'Add your first subscription to see the breakdown.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships/new')}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('dashboard.portfolio.addRelationship', 'Add relationship')}\n </button>\n }\n />\n ) : (\n <div className=\"flex flex-col items-center gap-5 sm:flex-row sm:items-center lg:flex-col xl:flex-row\">\n <Donut\n data={statusSegments}\n size={148}\n thickness={20}\n centerLabel={String(stats.totalCount)}\n centerSub={tr(\n stats.totalCount === 1\n ? 'dashboard.portfolio.relationshipSingular'\n : 'dashboard.portfolio.relationshipPlural',\n stats.totalCount === 1 ? 'relationship' : 'relationships'\n )}\n className=\"shrink-0\"\n />\n <Legend data={statusSegments} className=\"w-full min-w-0 flex-1\" />\n </div>\n )}\n </GlassCard>\n </Section>\n\n <Section\n title={tr('dashboard.needsAttention.title', 'Needs attention')}\n description={tr(\n 'dashboard.needsAttention.description',\n 'Required actions from the Universal Inbox'\n )}\n className=\"mt-0\"\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"text-sm font-medium text-text-link hover:underline\"\n >\n {tr('dashboard.needsAttention.openInbox', 'Open inbox')}\n </button>\n }\n >\n <GlassCard treatment=\"plain\" className=\"p-3\">\n {actionMessages.length === 0 ? (\n <div className=\"flex items-center gap-3 px-2 py-4\">\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-status-success-bg-subtle text-status-success-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n {tr('dashboard.needsAttention.allCaughtUp', \"You're all caught up\")}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {tr(\n 'dashboard.needsAttention.allCaughtUpDescription',\n 'Required actions across your channels will surface here.'\n )}\n </p>\n </div>\n </div>\n ) : (\n <ul className=\"space-y-1\">\n {actionMessages.slice(0, 5).map((message) => (\n <li key={message.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo('/inbox')}\n className=\"flex w-full items-center gap-3 rounded-lg border-l-2 border-status-warning-text/60 bg-status-warning-bg-subtle/50 p-3 text-left transition-colors hover:bg-status-warning-bg-subtle\"\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {message.subject ||\n tr('dashboard.needsAttention.noSubject', '(no subject)')}\n </p>\n {message.preview && (\n <p className=\"truncate text-xs text-text-secondary\">\n {message.preview}\n </p>\n )}\n </div>\n <StatusBadge status={message.category} className=\"shrink-0\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n </Section>\n </div>\n </div>\n\n {/* Open-invoice call-out (only when there is real outstanding balance) */}\n {stats.openInvoiceCount > 0 && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/invoices')}\n className=\"mt-6 flex w-full items-center justify-between gap-3 rounded-xl border border-status-warning-text/30 bg-status-warning-bg-subtle px-5 py-4 text-left transition-shadow hover:shadow-md\"\n >\n <div className=\"flex items-center gap-3\">\n <AlertTriangle className=\"h-5 w-5 shrink-0 text-status-warning-text\" />\n <span className=\"text-sm font-medium text-status-warning-text\">\n {tr(\n 'dashboard.openInvoices.label',\n '{{count}} open invoice · {{amount}} outstanding',\n {\n count: stats.openInvoiceCount,\n amount: formatCurrency(stats.openInvoiceTotal, stats.primaryCurrency),\n }\n )}\n </span>\n </div>\n <ArrowRight className=\"h-4 w-4 shrink-0 text-status-warning-text\" />\n </button>\n )}\n\n {/* Quick actions */}\n <Section\n title={tr('dashboard.quickActions.title', 'Quick actions')}\n description={tr('dashboard.quickActions.description', 'Jump straight into your workflow')}\n >\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {quickActions.map((qa) => (\n <button\n key={qa.path}\n type=\"button\"\n onClick={() => navigateTo(qa.path)}\n className=\"group flex items-center gap-3 rounded-xl border border-border-subtle bg-bg-surface p-4 text-left transition-all hover:-translate-y-0.5 hover:border-border-seam hover:shadow-md\"\n >\n <span className=\"flex size-10 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary\">\n {qa.icon}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block text-sm font-medium text-text-primary\">\n {tr(qa.labelKey, qa.fallbackLabel)}\n </span>\n <span className=\"block text-xs text-text-secondary\">\n {tr(qa.descriptionKey, qa.fallbackDescription)}\n </span>\n </span>\n <ArrowRight className=\"h-4 w-4 shrink-0 text-text-secondary transition-transform group-hover:translate-x-0.5\" />\n </button>\n ))}\n </div>\n </Section>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAM,IAAqD;CACzD,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAcM,IAAa,MAAO,KAAK,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AyF,CAAA;MACzG;QAjBD,EAAG,IAiBF,CACT;IACE,CAAA;GACE,CAAA;EACC;;AAEhB"}
@@ -5,10 +5,10 @@ import { formatDateTime as r, formatEnumLabel as i, formatRelativeTime as a } fr
5
5
  import { StatusBadge as o } from "../components/StatusBadge.js";
6
6
  import { EmptyState as s } from "../components/EmptyState.js";
7
7
  import { Modal as c } from "../components/Modal.js";
8
- import { ErrorView as l, LoadingView as u, Section as d } from "../components/StateViews.js";
9
- import { MiniProgress as f } from "../components/viz.js";
10
- import { useChannels as p, useCreateChannel as m, useInboxMessages as h, useIngestMessage as g, useMarkMessageRead as _, useVerifyChannel as v } from "../hooks/useSubscriberBotApi.js";
11
- import { useTr as y } from "../hooks/useTr.js";
8
+ import { useTr as l } from "../hooks/useTr.js";
9
+ import { ErrorView as u, LoadingView as d, Section as f } from "../components/StateViews.js";
10
+ import { MiniProgress as p } from "../components/viz.js";
11
+ import { useChannels as m, useCreateChannel as h, useInboxMessages as g, useIngestMessage as _, useMarkMessageRead as v, useVerifyChannel as y } from "../hooks/useSubscriberBotApi.js";
12
12
  import { useState as b } from "react";
13
13
  import { AlertTriangle as x, BadgeCheck as S, Bell as C, ChevronRight as w, Hash as T, Inbox as E, Mail as D, MailOpen as O, MessageSquare as k, MessagesSquare as A, MousePointerClick as j, Phone as M, Plus as N, Radio as P, Send as F, ShieldAlert as I, Sparkles as L, Webhook as R } from "lucide-react";
14
14
  import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
@@ -103,7 +103,7 @@ function Z({ category: e }) {
103
103
  });
104
104
  }
105
105
  function Q({ className: e }) {
106
- let n = y();
106
+ let n = l();
107
107
  return /* @__PURE__ */ V("span", {
108
108
  title: n("inbox.message.actionRequiredTitle", "Action required"),
109
109
  className: t("inline-flex items-center gap-1 rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-[10px] font-medium text-status-warning-text", e),
@@ -115,32 +115,32 @@ function Q({ className: e }) {
115
115
  });
116
116
  }
117
117
  function ne({ onClose: e }) {
118
- let t = y(), n = m(), [r, a] = b("EMAIL"), [o, s] = b(""), [l, u] = b(""), [d, f] = b(!0), [p, h] = b(null);
118
+ let t = l(), n = h(), [r, a] = b("EMAIL"), [o, s] = b(""), [u, d] = b(""), [f, p] = b(!0), [m, g] = b(null);
119
119
  return /* @__PURE__ */ B(c, {
120
120
  title: t("inbox.addChannelModal.title", "Add channel"),
121
121
  onClose: e,
122
122
  maxWidthClassName: "max-w-xl",
123
123
  children: /* @__PURE__ */ V("form", {
124
124
  onSubmit: (i) => {
125
- if (i.preventDefault(), h(null), !o.trim()) {
126
- h(t("inbox.addChannelModal.addressRequired", "An address is required."));
125
+ if (i.preventDefault(), g(null), !o.trim()) {
126
+ g(t("inbox.addChannelModal.addressRequired", "An address is required."));
127
127
  return;
128
128
  }
129
129
  n.mutate({
130
130
  type: r,
131
131
  address: o.trim(),
132
- ingestEnabled: d,
133
- ...l.trim() ? { label: l.trim() } : {}
132
+ ingestEnabled: f,
133
+ ...u.trim() ? { label: u.trim() } : {}
134
134
  }, {
135
135
  onSuccess: () => e(),
136
- onError: (e) => h(e instanceof Error ? e.message : t("inbox.addChannelModal.error", "Could not add channel."))
136
+ onError: (e) => g(e instanceof Error ? e.message : t("inbox.addChannelModal.error", "Could not add channel."))
137
137
  });
138
138
  },
139
139
  className: "space-y-4",
140
140
  children: [
141
- p && /* @__PURE__ */ B("div", {
141
+ m && /* @__PURE__ */ B("div", {
142
142
  className: "rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
143
- children: p
143
+ children: m
144
144
  }),
145
145
  /* @__PURE__ */ V("div", {
146
146
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
@@ -164,8 +164,8 @@ function ne({ onClose: e }) {
164
164
  }), /* @__PURE__ */ B("input", {
165
165
  id: "ch-label",
166
166
  type: "text",
167
- value: l,
168
- onChange: (e) => u(e.target.value),
167
+ value: u,
168
+ onChange: (e) => d(e.target.value),
169
169
  placeholder: t("inbox.addChannelModal.labelPlaceholder", "e.g. Billing inbox"),
170
170
  className: G
171
171
  })] })]
@@ -194,8 +194,8 @@ function ne({ onClose: e }) {
194
194
  className: "flex items-center gap-2 text-sm text-text-primary",
195
195
  children: [/* @__PURE__ */ B("input", {
196
196
  type: "checkbox",
197
- checked: d,
198
- onChange: (e) => f(e.target.checked),
197
+ checked: f,
198
+ onChange: (e) => p(e.target.checked),
199
199
  className: "size-4 rounded border-border-subtle"
200
200
  }), t("inbox.addChannelModal.ingestLabel", "Ingest messages from this channel")]
201
201
  }),
@@ -218,30 +218,30 @@ function ne({ onClose: e }) {
218
218
  });
219
219
  }
220
220
  function re({ channel: e, onClose: t }) {
221
- let n = y(), r = g(), [a, o] = b(""), [s, l] = b(""), [u, d] = b("OTHER"), [f, p] = b(!1), [m, h] = b(null);
221
+ let n = l(), r = _(), [a, o] = b(""), [s, u] = b(""), [d, f] = b("OTHER"), [p, m] = b(!1), [h, g] = b(null);
222
222
  return /* @__PURE__ */ B(c, {
223
223
  title: n("inbox.logMessageModal.title", "Log test message"),
224
224
  description: n("inbox.logMessageModal.description", "Simulate an ingested message from {channel}.", { channel: e.label || e.address }),
225
225
  onClose: t,
226
226
  children: /* @__PURE__ */ V("form", {
227
227
  onSubmit: (i) => {
228
- i.preventDefault(), h(null), r.mutate({
228
+ i.preventDefault(), g(null), r.mutate({
229
229
  channelId: e.id,
230
230
  receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
231
- category: u,
232
- actionRequired: f,
231
+ category: d,
232
+ actionRequired: p,
233
233
  ...a.trim() ? { subject: a.trim() } : {},
234
234
  ...s.trim() ? { preview: s.trim() } : {}
235
235
  }, {
236
236
  onSuccess: () => t(),
237
- onError: (e) => h(e instanceof Error ? e.message : n("inbox.logMessageModal.error", "Could not log the message."))
237
+ onError: (e) => g(e instanceof Error ? e.message : n("inbox.logMessageModal.error", "Could not log the message."))
238
238
  });
239
239
  },
240
240
  className: "space-y-4",
241
241
  children: [
242
- m && /* @__PURE__ */ B("div", {
242
+ h && /* @__PURE__ */ B("div", {
243
243
  className: "rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text",
244
- children: m
244
+ children: h
245
245
  }),
246
246
  /* @__PURE__ */ V("div", { children: [/* @__PURE__ */ B("label", {
247
247
  htmlFor: "msg-subject",
@@ -262,7 +262,7 @@ function re({ channel: e, onClose: t }) {
262
262
  }), /* @__PURE__ */ B("textarea", {
263
263
  id: "msg-preview",
264
264
  value: s,
265
- onChange: (e) => l(e.target.value),
265
+ onChange: (e) => u(e.target.value),
266
266
  rows: 2,
267
267
  className: G
268
268
  })] }),
@@ -272,8 +272,8 @@ function re({ channel: e, onClose: t }) {
272
272
  children: n("inbox.logMessageModal.categoryLabel", "Category")
273
273
  }), /* @__PURE__ */ B("select", {
274
274
  id: "msg-category",
275
- value: u,
276
- onChange: (e) => d(e.target.value),
275
+ value: d,
276
+ onChange: (e) => f(e.target.value),
277
277
  className: G,
278
278
  children: q.map((e) => /* @__PURE__ */ B("option", {
279
279
  value: e,
@@ -284,8 +284,8 @@ function re({ channel: e, onClose: t }) {
284
284
  className: "flex items-center gap-2 text-sm text-text-primary",
285
285
  children: [/* @__PURE__ */ B("input", {
286
286
  type: "checkbox",
287
- checked: f,
288
- onChange: (e) => p(e.target.checked),
287
+ checked: p,
288
+ onChange: (e) => m(e.target.checked),
289
289
  className: "size-4 rounded border-border-subtle"
290
290
  }), n("inbox.logMessageModal.actionRequired", "Requires action")]
291
291
  }),
@@ -308,7 +308,7 @@ function re({ channel: e, onClose: t }) {
308
308
  });
309
309
  }
310
310
  function ie({ channel: e, onVerify: t, verifying: n, onLog: r }) {
311
- let a = y(), s = X[e.type] ?? P, c = e.status === "VERIFIED";
311
+ let a = l(), s = X[e.type] ?? P, c = e.status === "VERIFIED";
312
312
  return /* @__PURE__ */ V(H, {
313
313
  treatment: "metric",
314
314
  className: "flex flex-col p-4",
@@ -377,8 +377,8 @@ function ie({ channel: e, onVerify: t, verifying: n, onLog: r }) {
377
377
  });
378
378
  }
379
379
  function ae() {
380
- let e = y(), { data: t, isLoading: n, isError: r, refetch: i } = p(), a = v(), [o, c] = b(!1), [f, m] = b(null), h = t ?? [], g = h.filter((e) => e.status === "VERIFIED").length, _ = h.filter((e) => e.status === "PENDING").length;
381
- return /* @__PURE__ */ V(d, {
380
+ let e = l(), { data: t, isLoading: n, isError: r, refetch: i } = m(), a = y(), [o, c] = b(!1), [p, h] = b(null), g = t ?? [], _ = g.filter((e) => e.status === "VERIFIED").length, v = g.filter((e) => e.status === "PENDING").length;
381
+ return /* @__PURE__ */ V(f, {
382
382
  title: e("inbox.channels.title", "Ingest channels"),
383
383
  description: e("inbox.channels.description", "The sources the Universal Inbox pulls subscription communication from"),
384
384
  action: /* @__PURE__ */ V("button", {
@@ -392,48 +392,48 @@ function ae() {
392
392
  ]
393
393
  }),
394
394
  children: [
395
- n ? /* @__PURE__ */ B(u, { label: e("inbox.channels.loading", "Loading channels…") }) : r ? /* @__PURE__ */ B(l, {
395
+ n ? /* @__PURE__ */ B(d, { label: e("inbox.channels.loading", "Loading channels…") }) : r ? /* @__PURE__ */ B(u, {
396
396
  message: e("inbox.channels.error", "Could not load channels."),
397
397
  onRetry: () => void i()
398
- }) : h.length === 0 ? /* @__PURE__ */ B(s, {
398
+ }) : g.length === 0 ? /* @__PURE__ */ B(s, {
399
399
  illustration: "empty-data",
400
400
  icon: /* @__PURE__ */ B(P, { className: "h-12 w-12" }),
401
401
  title: e("inbox.channels.emptyTitle", "No channels yet"),
402
402
  description: e("inbox.channels.emptyDescription", "Add an email, SMS, Slack or webhook channel to start ingesting subscription communication.")
403
- }) : /* @__PURE__ */ V(z, { children: [(g > 0 || _ > 0) && /* @__PURE__ */ V("div", {
403
+ }) : /* @__PURE__ */ V(z, { children: [(_ > 0 || v > 0) && /* @__PURE__ */ V("div", {
404
404
  className: "mb-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-text-secondary",
405
405
  children: [/* @__PURE__ */ V("span", {
406
406
  className: "inline-flex items-center gap-1.5",
407
407
  children: [/* @__PURE__ */ B("span", {
408
408
  className: "size-1.5 rounded-full bg-status-success-text",
409
409
  "aria-hidden": !0
410
- }), e("inbox.channels.verified", "{{count}} verified", { count: g })]
411
- }), _ > 0 && /* @__PURE__ */ V("span", {
410
+ }), e("inbox.channels.verified", "{{count}} verified", { count: _ })]
411
+ }), v > 0 && /* @__PURE__ */ V("span", {
412
412
  className: "inline-flex items-center gap-1.5",
413
413
  children: [/* @__PURE__ */ B("span", {
414
414
  className: "size-1.5 rounded-full bg-status-warning-text",
415
415
  "aria-hidden": !0
416
- }), e("inbox.channels.pending", "{{count}} pending verification", { count: _ })]
416
+ }), e("inbox.channels.pending", "{{count}} pending verification", { count: v })]
417
417
  })]
418
418
  }), /* @__PURE__ */ B("div", {
419
419
  className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",
420
- children: h.map((e) => /* @__PURE__ */ B(ie, {
420
+ children: g.map((e) => /* @__PURE__ */ B(ie, {
421
421
  channel: e,
422
422
  verifying: a.isPending,
423
423
  onVerify: (e) => a.mutate(e),
424
- onLog: (e) => m(e)
424
+ onLog: (e) => h(e)
425
425
  }, e.id))
426
426
  })] }),
427
427
  o && /* @__PURE__ */ B(ne, { onClose: () => c(!1) }),
428
- f && /* @__PURE__ */ B(re, {
429
- channel: f,
430
- onClose: () => m(null)
428
+ p && /* @__PURE__ */ B(re, {
429
+ channel: p,
430
+ onClose: () => h(null)
431
431
  })
432
432
  ]
433
433
  });
434
434
  }
435
435
  function oe({ message: e, active: n, onSelect: r, onMarkRead: i, markPending: o, onViewRelationship: s }) {
436
- let c = y(), l = !e.isRead;
436
+ let c = l(), u = !e.isRead;
437
437
  return /* @__PURE__ */ V("div", {
438
438
  role: "button",
439
439
  tabIndex: 0,
@@ -442,15 +442,15 @@ function oe({ message: e, active: n, onSelect: r, onMarkRead: i, markPending: o,
442
442
  onKeyDown: (e) => {
443
443
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), r());
444
444
  },
445
- className: t("relative flex cursor-pointer items-start gap-3 p-4 transition-colors", "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset", n ? "bg-bg-sunken" : l ? "bg-accent-wash" : "hover:bg-bg-sunken/60"),
445
+ className: t("relative flex cursor-pointer items-start gap-3 p-4 transition-colors", "focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] focus-visible:ring-inset", n ? "bg-bg-sunken" : u ? "bg-accent-wash" : "hover:bg-bg-sunken/60"),
446
446
  children: [
447
- l && /* @__PURE__ */ B("span", {
447
+ u && /* @__PURE__ */ B("span", {
448
448
  "aria-hidden": !0,
449
449
  className: "absolute inset-y-0 left-0 w-0.5 bg-text-link"
450
450
  }),
451
451
  /* @__PURE__ */ B("span", {
452
452
  className: "mt-0.5 shrink-0 text-text-secondary",
453
- children: l ? /* @__PURE__ */ B(D, { className: "h-4 w-4 text-text-link" }) : /* @__PURE__ */ B(O, { className: "h-4 w-4" })
453
+ children: u ? /* @__PURE__ */ B(D, { className: "h-4 w-4 text-text-link" }) : /* @__PURE__ */ B(O, { className: "h-4 w-4" })
454
454
  }),
455
455
  /* @__PURE__ */ V("div", {
456
456
  className: "min-w-0 flex-1",
@@ -458,12 +458,12 @@ function oe({ message: e, active: n, onSelect: r, onMarkRead: i, markPending: o,
458
458
  /* @__PURE__ */ V("div", {
459
459
  className: "flex items-center gap-2",
460
460
  children: [
461
- l && /* @__PURE__ */ B("span", {
461
+ u && /* @__PURE__ */ B("span", {
462
462
  "aria-label": c("inbox.message.unreadAria", "Unread"),
463
463
  className: "size-1.5 shrink-0 rounded-full bg-text-link"
464
464
  }),
465
465
  /* @__PURE__ */ B("p", {
466
- className: t("min-w-0 flex-1 truncate text-sm", l ? "font-semibold text-text-primary" : "font-normal text-text-primary"),
466
+ className: t("min-w-0 flex-1 truncate text-sm", u ? "font-semibold text-text-primary" : "font-normal text-text-primary"),
467
467
  children: e.subject || c("inbox.message.noSubject", "(no subject)")
468
468
  }),
469
469
  /* @__PURE__ */ B("span", {
@@ -489,7 +489,7 @@ function oe({ message: e, active: n, onSelect: r, onMarkRead: i, markPending: o,
489
489
  className: "text-xs font-medium text-text-link hover:underline",
490
490
  children: c("inbox.message.viewRelationship", "View relationship")
491
491
  }),
492
- l && /* @__PURE__ */ B("button", {
492
+ u && /* @__PURE__ */ B("button", {
493
493
  type: "button",
494
494
  disabled: o,
495
495
  onClick: (e) => {
@@ -506,7 +506,7 @@ function oe({ message: e, active: n, onSelect: r, onMarkRead: i, markPending: o,
506
506
  });
507
507
  }
508
508
  function se({ message: e, channel: t, onMarkRead: n, markPending: i, onViewRelationship: a }) {
509
- let o = y();
509
+ let o = l();
510
510
  if (!e) return /* @__PURE__ */ V(H, {
511
511
  treatment: "metric",
512
512
  className: "flex min-h-[20rem] flex-col items-center justify-center p-8 text-center",
@@ -574,7 +574,7 @@ function se({ message: e, channel: t, onMarkRead: n, markPending: i, onViewRelat
574
574
  className: "tabular-nums text-text-secondary",
575
575
  children: o("inbox.readingPane.confidence", "{{pct}}% confidence", { pct: c })
576
576
  })]
577
- }), /* @__PURE__ */ B(f, {
577
+ }), /* @__PURE__ */ B(p, {
578
578
  value: c,
579
579
  max: 100,
580
580
  tone: c >= 66 ? "positive" : c >= 33 ? "accent" : "warning",
@@ -621,14 +621,14 @@ function $({ active: e, onClick: n, children: r, tone: i = "default" }) {
621
621
  });
622
622
  }
623
623
  function ce() {
624
- let r = y(), { navigateTo: i } = e(), [a, o] = b(0), [c, d] = b(""), [f, m] = b(!1), [g, v] = b(!1), [S, C] = b(null), { data: w, isLoading: T, isError: O, refetch: k, isFetching: A } = h({
624
+ let r = l(), { navigateTo: i } = e(), [a, o] = b(0), [c, f] = b(""), [p, h] = b(!1), [_, y] = b(!1), [S, C] = b(null), { data: w, isLoading: T, isError: O, refetch: k, isFetching: A } = g({
625
625
  category: c || void 0,
626
- unreadOnly: f || void 0,
626
+ unreadOnly: p || void 0,
627
627
  pagination: {
628
628
  limit: W,
629
629
  offset: a * W
630
630
  }
631
- }), { data: j } = p(), M = _(), N = w?.items ?? [], P = w?.pageInfo.hasMore ?? !1, F = g ? N.filter((e) => e.actionRequired) : N, I = N.filter((e) => !e.isRead).length, L = N.filter((e) => e.actionRequired).length, R = new Map((j ?? []).map((e) => [e.id, e])), z = F.find((e) => e.id === S) ?? null, H = z ? R.get(z.channelId) : void 0, G = () => {
631
+ }), { data: j } = m(), M = v(), N = w?.items ?? [], P = w?.pageInfo.hasMore ?? !1, F = _ ? N.filter((e) => e.actionRequired) : N, I = N.filter((e) => !e.isRead).length, L = N.filter((e) => e.actionRequired).length, R = new Map((j ?? []).map((e) => [e.id, e])), z = F.find((e) => e.id === S) ?? null, H = z ? R.get(z.channelId) : void 0, G = () => {
632
632
  o(0), C(null);
633
633
  };
634
634
  return /* @__PURE__ */ V(n, {
@@ -646,7 +646,7 @@ function ce() {
646
646
  children: /* @__PURE__ */ B($, {
647
647
  active: c === e.value,
648
648
  onClick: () => {
649
- d(e.value), G();
649
+ f(e.value), G();
650
650
  },
651
651
  children: r(e.key, e.fallback)
652
652
  })
@@ -656,10 +656,10 @@ function ce() {
656
656
  className: "mt-3 flex flex-wrap items-center gap-2",
657
657
  children: [
658
658
  /* @__PURE__ */ V($, {
659
- active: g,
659
+ active: _,
660
660
  tone: "warning",
661
661
  onClick: () => {
662
- v((e) => !e), C(null);
662
+ y((e) => !e), C(null);
663
663
  },
664
664
  children: [
665
665
  /* @__PURE__ */ B(x, { className: "h-3.5 w-3.5" }),
@@ -668,9 +668,9 @@ function ce() {
668
668
  ]
669
669
  }),
670
670
  /* @__PURE__ */ V($, {
671
- active: f,
671
+ active: p,
672
672
  onClick: () => {
673
- m((e) => !e), G();
673
+ h((e) => !e), G();
674
674
  },
675
675
  children: [
676
676
  /* @__PURE__ */ B(D, { className: "h-3.5 w-3.5" }),
@@ -689,7 +689,7 @@ function ce() {
689
689
  })
690
690
  ]
691
691
  }),
692
- T ? /* @__PURE__ */ B(u, { label: r("inbox.loading", "Loading inbox…") }) : O ? /* @__PURE__ */ B(l, {
692
+ T ? /* @__PURE__ */ B(d, { label: r("inbox.loading", "Loading inbox…") }) : O ? /* @__PURE__ */ B(u, {
693
693
  message: r("inbox.error", "Could not load the inbox."),
694
694
  onRetry: () => void k()
695
695
  }) : N.length === 0 ? /* @__PURE__ */ B("div", {
@@ -698,7 +698,7 @@ function ce() {
698
698
  illustration: "empty-inbox",
699
699
  icon: /* @__PURE__ */ B(E, { className: "h-12 w-12" }),
700
700
  title: r("inbox.emptyTitle", "Inbox is empty"),
701
- description: f || c ? r("inbox.emptyDescriptionFiltered", "No messages match these filters.") : r("inbox.emptyDescription", "Merged subscription communications will appear here once channels start ingesting.")
701
+ description: p || c ? r("inbox.emptyDescriptionFiltered", "No messages match these filters.") : r("inbox.emptyDescription", "Merged subscription communications will appear here once channels start ingesting.")
702
702
  })
703
703
  }) : /* @__PURE__ */ V("div", {
704
704
  className: "mt-5 grid grid-cols-1 gap-5 lg:grid-cols-[minmax(0,1fr)_380px]",
@@ -3,11 +3,11 @@ import { PageLayout as t } from "../components/PageLayout.js";
3
3
  import { MetricsCard as n } from "../components/MetricsCard.js";
4
4
  import { formatCurrency as r, formatEnumLabel as i } from "../utils/formatters.js";
5
5
  import { EmptyState as a } from "../components/EmptyState.js";
6
- import { ErrorView as o, LoadingView as s, Section as c } from "../components/StateViews.js";
7
- import { BarList as l, Donut as u, Legend as d, MiniProgress as f } from "../components/viz.js";
6
+ import { useTr as o } from "../hooks/useTr.js";
7
+ import { ErrorView as s, LoadingView as c, Section as l } from "../components/StateViews.js";
8
+ import { BarList as u, Donut as d, Legend as f, MiniProgress as p } from "../components/viz.js";
8
9
  import "../components/index.js";
9
- import { useRelationships as p } from "../hooks/useSubscriberBotApi.js";
10
- import { useTr as m } from "../hooks/useTr.js";
10
+ import { useRelationships as m } from "../hooks/useSubscriberBotApi.js";
11
11
  import { useMemo as h } from "react";
12
12
  import { CalendarClock as g, HeartPulse as _, Layers as v, TrendingUp as y, Wallet as b } from "lucide-react";
13
13
  import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
@@ -23,7 +23,7 @@ var E = {
23
23
  FREE: 0,
24
24
  USAGE_BASED: 1
25
25
  }, D = (e) => e.amount * (E[e.interval] ?? 1), O = (e) => e.status === "ACTIVE", k = () => {
26
- let E = p({ pagination: { limit: 100 } }), k = m(), A = h(() => E.data?.items ?? [], [E.data]), j = h(() => {
26
+ let E = m({ pagination: { limit: 100 } }), k = o(), A = h(() => E.data?.items ?? [], [E.data]), j = h(() => {
27
27
  let e = A.filter(O), t = e[0]?.currency ?? A[0]?.currency ?? "USD", n = e.reduce((e, t) => e + D(t), 0), r = A.filter((e) => e.healthScore != null), a = r.length ? r.reduce((e, t) => e + (t.healthScore ?? 0), 0) / r.length : null, o = /* @__PURE__ */ new Map();
28
28
  for (let e of A) o.set(e.status, (o.get(e.status) ?? 0) + 1);
29
29
  let s = /* @__PURE__ */ new Map();
@@ -67,8 +67,8 @@ var E = {
67
67
  total: A.length
68
68
  };
69
69
  }, [A]);
70
- if (E.isLoading) return /* @__PURE__ */ S(s, { label: k("insights.loading", "Crunching your spend insights…") });
71
- if (E.isError) return /* @__PURE__ */ S(o, {
70
+ if (E.isLoading) return /* @__PURE__ */ S(c, { label: k("insights.loading", "Crunching your spend insights…") });
71
+ if (E.isError) return /* @__PURE__ */ S(s, {
72
72
  message: k("insights.error", "Could not load insights."),
73
73
  onRetry: () => void E.refetch()
74
74
  });
@@ -121,11 +121,11 @@ var E = {
121
121
  children: k("insights.portfolioByStatus", "Portfolio by status")
122
122
  }), /* @__PURE__ */ C("div", {
123
123
  className: "flex flex-col items-center gap-6 sm:flex-row",
124
- children: [/* @__PURE__ */ S(u, {
124
+ children: [/* @__PURE__ */ S(d, {
125
125
  data: j.statusData,
126
126
  centerLabel: String(j.total),
127
127
  centerSub: k("insights.subscriptions", "subscriptions")
128
- }), /* @__PURE__ */ S(d, {
128
+ }), /* @__PURE__ */ S(f, {
129
129
  className: "w-full sm:flex-1",
130
130
  data: j.statusData
131
131
  })]
@@ -137,7 +137,7 @@ var E = {
137
137
  children: [/* @__PURE__ */ S("h3", {
138
138
  className: "mb-4 text-sm font-semibold text-text-primary",
139
139
  children: k("insights.spendByType", "Monthly spend by type")
140
- }), j.kindData.length ? /* @__PURE__ */ S(l, {
140
+ }), j.kindData.length ? /* @__PURE__ */ S(u, {
141
141
  data: j.kindData,
142
142
  valueFormat: M
143
143
  }) : /* @__PURE__ */ S("p", {
@@ -151,7 +151,7 @@ var E = {
151
151
  children: [/* @__PURE__ */ S("h3", {
152
152
  className: "mb-4 text-sm font-semibold text-text-primary",
153
153
  children: k("insights.renewalForecast", "Renewal forecast (6 mo)")
154
- }), j.forecast.some((e) => e.value > 0) ? /* @__PURE__ */ S(l, {
154
+ }), j.forecast.some((e) => e.value > 0) ? /* @__PURE__ */ S(u, {
155
155
  data: j.forecast,
156
156
  valueFormat: M
157
157
  }) : /* @__PURE__ */ S("p", {
@@ -163,7 +163,7 @@ var E = {
163
163
  }),
164
164
  /* @__PURE__ */ C("div", {
165
165
  className: "grid grid-cols-1 gap-4 lg:grid-cols-2",
166
- children: [/* @__PURE__ */ S(c, {
166
+ children: [/* @__PURE__ */ S(l, {
167
167
  title: k("insights.topCosts", "Top monthly costs"),
168
168
  children: /* @__PURE__ */ S(w, {
169
169
  treatment: "plain",
@@ -182,7 +182,7 @@ var E = {
182
182
  })]
183
183
  }, e.id))
184
184
  })
185
- }), /* @__PURE__ */ S(c, {
185
+ }), /* @__PURE__ */ S(l, {
186
186
  title: k("insights.healthWatchlist", "Health watchlist"),
187
187
  children: j.watchlist.length ? /* @__PURE__ */ S(w, {
188
188
  treatment: "plain",
@@ -194,7 +194,7 @@ var E = {
194
194
  className: "w-32 shrink-0 truncate text-sm text-text-primary",
195
195
  children: t.label
196
196
  }),
197
- /* @__PURE__ */ S(f, {
197
+ /* @__PURE__ */ S(p, {
198
198
  className: "flex-1",
199
199
  value: t.healthScore ?? 0,
200
200
  tone: "negative"