@burdenoff/microfe-subscriberbot 2026.1107.4 → 2026.1107.5
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.
- package/dist/subscriberbot/components/PageLayout.d.ts.map +1 -1
- package/dist/subscriberbot/components/PageLayout.js +1 -1
- package/dist/subscriberbot/components/PageLayout.js.map +1 -1
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +5 -5
- package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
- package/dist/subscriberbot/utils/portfolio.d.ts +7 -4
- package/dist/subscriberbot/utils/portfolio.d.ts.map +1 -1
- package/dist/subscriberbot/utils/portfolio.js +47 -38
- package/dist/subscriberbot/utils/portfolio.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLayout.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/PageLayout.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,UAAU,eAAe;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"PageLayout.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/components/PageLayout.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,UAAU,eAAe;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA+C1C,CAAC"}
|
|
@@ -24,7 +24,7 @@ var a = ({ title: a, description: o, actions: s, children: c, className: l, titl
|
|
|
24
24
|
})]
|
|
25
25
|
}),
|
|
26
26
|
s && /* @__PURE__ */ t("div", {
|
|
27
|
-
className: "flex flex-wrap items-center gap-3 shrink-0",
|
|
27
|
+
className: "flex w-full flex-wrap items-center gap-3 sm:w-auto sm:shrink-0",
|
|
28
28
|
children: s
|
|
29
29
|
})
|
|
30
30
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageLayout.js","names":[],"sources":["../../../src/subscriberbot/components/PageLayout.tsx"],"sourcesContent":["/**\n * Page Layout Component\n * @module subscriberbot/components\n *\n * Boff UI 2.0 page wrapper. Supports a living-glass {@link AuroraBackground}\n * hero backdrop and a gradient hero title for the MFE's primary page.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AuroraBackground, GradientText } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface PageLayoutProps {\n title: ReactNode;\n description?: string;\n actions?: ReactNode;\n children: ReactNode;\n className?: string;\n /**\n * Render the title as a gradient hero heading (Boff UI 2.0). Reserve for the\n * ONE primary page of the MFE so it stays a hero accent, never body copy.\n */\n titleGradient?: boolean;\n /**\n * Drop a subtle living-glass {@link AuroraBackground} behind the header.\n * Use on the MFE's primary page only (one aurora per MFE). Sits at -z-10 and\n * never moves content; auto-static under reduced motion.\n */\n aurora?: boolean;\n /**\n * Stable product-tour anchor prefix (BOFF-3358). Renders\n * `data-tour=\"{dataTour}-header\"` on the page header so seeded tours in\n * global-tours-svc can target it. Use `subscriberbot-{page}`.\n */\n dataTour?: string;\n}\n\nexport const PageLayout: FC<PageLayoutProps> = ({\n title,\n description,\n actions,\n children,\n className,\n titleGradient = false,\n aurora = false,\n dataTour,\n}) => {\n return (\n <div className={cn('flex flex-col h-full', className)}>\n {/* Page Header — optionally on a living-glass aurora hero backdrop. The\n aurora layer sits at -z-10 and never moves content. */}\n <div\n data-tour={dataTour ? `${dataTour}-header` : undefined}\n className={cn(\n // Phones stack the actions under the title so long titles and\n // action buttons never squeeze each other at 375px (BOFF-4010).\n 'relative flex flex-col items-start gap-3 px-4 py-4 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4 sm:px-6',\n aurora ? 'overflow-hidden bg-gloss-card' : 'bg-bg-surface'\n )}\n >\n {aurora && <AuroraBackground intensity=\"subtle\" />}\n <div className=\"min-w-0\">\n {titleGradient && typeof title === 'string' ? (\n <GradientText as=\"h1\" className=\"text-2xl font-semibold tracking-tight\">\n {title}\n </GradientText>\n ) : (\n <h1 className=\"text-2xl font-semibold text-text-primary\">{title}</h1>\n )}\n {description && <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>}\n </div>\n {actions && <div className=\"flex flex-wrap items-center gap-3 shrink-0\"
|
|
1
|
+
{"version":3,"file":"PageLayout.js","names":[],"sources":["../../../src/subscriberbot/components/PageLayout.tsx"],"sourcesContent":["/**\n * Page Layout Component\n * @module subscriberbot/components\n *\n * Boff UI 2.0 page wrapper. Supports a living-glass {@link AuroraBackground}\n * hero backdrop and a gradient hero title for the MFE's primary page.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AuroraBackground, GradientText } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface PageLayoutProps {\n title: ReactNode;\n description?: string;\n actions?: ReactNode;\n children: ReactNode;\n className?: string;\n /**\n * Render the title as a gradient hero heading (Boff UI 2.0). Reserve for the\n * ONE primary page of the MFE so it stays a hero accent, never body copy.\n */\n titleGradient?: boolean;\n /**\n * Drop a subtle living-glass {@link AuroraBackground} behind the header.\n * Use on the MFE's primary page only (one aurora per MFE). Sits at -z-10 and\n * never moves content; auto-static under reduced motion.\n */\n aurora?: boolean;\n /**\n * Stable product-tour anchor prefix (BOFF-3358). Renders\n * `data-tour=\"{dataTour}-header\"` on the page header so seeded tours in\n * global-tours-svc can target it. Use `subscriberbot-{page}`.\n */\n dataTour?: string;\n}\n\nexport const PageLayout: FC<PageLayoutProps> = ({\n title,\n description,\n actions,\n children,\n className,\n titleGradient = false,\n aurora = false,\n dataTour,\n}) => {\n return (\n <div className={cn('flex flex-col h-full', className)}>\n {/* Page Header — optionally on a living-glass aurora hero backdrop. The\n aurora layer sits at -z-10 and never moves content. */}\n <div\n data-tour={dataTour ? `${dataTour}-header` : undefined}\n className={cn(\n // Phones stack the actions under the title so long titles and\n // action buttons never squeeze each other at 375px (BOFF-4010).\n 'relative flex flex-col items-start gap-3 px-4 py-4 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4 sm:px-6',\n aurora ? 'overflow-hidden bg-gloss-card' : 'bg-bg-surface'\n )}\n >\n {aurora && <AuroraBackground intensity=\"subtle\" />}\n <div className=\"min-w-0\">\n {titleGradient && typeof title === 'string' ? (\n <GradientText as=\"h1\" className=\"text-2xl font-semibold tracking-tight\">\n {title}\n </GradientText>\n ) : (\n <h1 className=\"text-2xl font-semibold text-text-primary\">{title}</h1>\n )}\n {description && <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>}\n </div>\n {/* Full width and wrapping on phones, so a page with several actions\n wraps them onto a second row instead of running off-screen. */}\n {actions && (\n <div className=\"flex w-full flex-wrap items-center gap-3 sm:w-auto sm:shrink-0\">\n {actions}\n </div>\n )}\n </div>\n\n {/* Page Content */}\n <div className=\"flex-1 overflow-auto p-4 sm:p-6\">{children}</div>\n </div>\n );\n};\n"],"mappings":";;;;AAqCA,IAAa,KAAmC,EAC9C,UACA,gBACA,YACA,aACA,cACA,mBAAgB,IAChB,YAAS,IACT,kBAGE,kBAAC,OAAD;CAAK,WAAW,EAAG,wBAAwB,CAAS;WAApD,CAGE,kBAAC,OAAD;EACE,aAAW,IAAW,GAAG,EAAS,WAAW,KAAA;EAC7C,WAAW,EAGT,kJACA,IAAS,kCAAkC,eAC7C;YAPF;GASG,KAAU,kBAAC,GAAD,EAAkB,WAAU,SAAU,CAAA;GACjD,kBAAC,OAAD;IAAK,WAAU;cAAf,CACG,KAAiB,OAAO,KAAU,WACjC,kBAAC,GAAD;KAAc,IAAG;KAAK,WAAU;eAC7B;IACW,CAAA,IAEd,kBAAC,MAAD;KAAI,WAAU;eAA4C;IAAU,CAAA,GAErE,KAAe,kBAAC,KAAD;KAAG,WAAU;eAAoC;IAAe,CAAA,CAC7E;;GAGJ,KACC,kBAAC,OAAD;IAAK,WAAU;cACZ;GACE,CAAA;EAEJ;KAGL,kBAAC,OAAD;EAAK,WAAU;EAAmC;CAAc,CAAA,CAC7D"}
|
|
@@ -703,12 +703,12 @@ function me() {
|
|
|
703
703
|
title: $.label,
|
|
704
704
|
description: $.provider?.name ?? y(oe[$.kind], h($.kind)),
|
|
705
705
|
actions: /* @__PURE__ */ U("div", {
|
|
706
|
-
className: "flex items-center gap-2",
|
|
706
|
+
className: "flex flex-wrap items-center gap-2",
|
|
707
707
|
children: [
|
|
708
708
|
/* @__PURE__ */ U("button", {
|
|
709
709
|
type: "button",
|
|
710
710
|
onClick: () => J(!0),
|
|
711
|
-
className: "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
711
|
+
className: "inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
712
712
|
children: [
|
|
713
713
|
/* @__PURE__ */ H(ee, { className: "h-4 w-4" }),
|
|
714
714
|
" ",
|
|
@@ -719,7 +719,7 @@ function me() {
|
|
|
719
719
|
type: "button",
|
|
720
720
|
"data-testid": "negotiate-bill",
|
|
721
721
|
onClick: () => C(`/negotiations/new?relationshipId=${encodeURIComponent($.id)}`),
|
|
722
|
-
className: "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
722
|
+
className: "inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
723
723
|
children: [
|
|
724
724
|
/* @__PURE__ */ H(L, { className: "h-4 w-4" }),
|
|
725
725
|
" ",
|
|
@@ -730,7 +730,7 @@ function me() {
|
|
|
730
730
|
type: "button",
|
|
731
731
|
"data-testid": "request-procurement",
|
|
732
732
|
onClick: () => C(`/procurement/new?relationshipId=${encodeURIComponent($.id)}`),
|
|
733
|
-
className: "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
733
|
+
className: "inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
734
734
|
children: [
|
|
735
735
|
/* @__PURE__ */ H(N, { className: "h-4 w-4" }),
|
|
736
736
|
" ",
|
|
@@ -740,7 +740,7 @@ function me() {
|
|
|
740
740
|
/* @__PURE__ */ U("button", {
|
|
741
741
|
type: "button",
|
|
742
742
|
onClick: () => C("/relationships"),
|
|
743
|
-
className: "inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
743
|
+
className: "inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken",
|
|
744
744
|
children: [
|
|
745
745
|
/* @__PURE__ */ H(j, { className: "rtl:rotate-180 h-4 w-4" }),
|
|
746
746
|
" ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipDetailPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\nimport { useFormError } from '../../hooks/useFormError';\n/**\n * Relationship detail\n * @module subscriberbot/pages/relationships\n *\n * Full per-relationship view: plan, price, billing period, next renewal,\n * health score, entitlements, attached assets and renewal events — plus\n * lifecycle transitions (validated server-side), edit, and cancel.\n * Reads `subRelationship(id)`; writes `subTransitionRelationship`,\n * `subCancelRelationship`, `subUpdateRelationship`, `subCreateEntitlement`,\n * `subCreateAsset`.\n */\n\nimport { useState, type ReactNode } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n Briefcase,\n CreditCard,\n Wallet,\n ShieldCheck,\n CalendarClock,\n Paperclip,\n Activity,\n Tag,\n Pencil,\n Handshake,\n Plus,\n Pause,\n Play,\n Ban,\n Download,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { Modal } from '../../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../../components/StateViews';\nimport { AiDisclaimer, DecisionCard } from '../../components/decisions';\nimport { Gauge, Timeline, MiniProgress } from '../../components';\nimport type { TimelineItem } from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useRelationship,\n useTransitionRelationship,\n useCancelRelationship,\n useUpdateRelationship,\n useCreateEntitlement,\n useCreateAsset,\n useUploadFile,\n useFileDownloadUrl,\n useProviders,\n usePlans,\n useDecisions,\n useInvoices,\n} from '../../hooks/useSubscriberBotApi';\n\nimport { useTr } from '../../hooks/useTr';\nimport { canTransition } from '../../utils/portfolio';\nimport type {\n SubAssetType,\n SubBillingInterval,\n SubEntitlementType,\n SubInvoice,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubUpdateRelationshipInput,\n} from '../../types';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst INTERVALS: SubBillingInterval[] = [\n 'MONTHLY',\n 'YEARLY',\n 'QUARTERLY',\n 'WEEKLY',\n 'DAILY',\n 'USAGE_BASED',\n 'LIFETIME',\n 'FREE',\n];\n\nconst ENTITLEMENT_TYPES: SubEntitlementType[] = [\n 'FEATURE_ACCESS',\n 'SEAT',\n 'USAGE_QUOTA',\n 'CONTENT',\n 'DISCOUNT',\n 'SUPPORT_TIER',\n];\n\nconst ASSET_TYPES: SubAssetType[] = [\n 'RECEIPT',\n 'INVOICE',\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst KIND_KEY: Record<SubRelationshipKind, string> = {\n SUBSCRIPTION: 'relationships.kinds.subscription',\n MEMBERSHIP: 'relationships.kinds.membership',\n LICENSE: 'relationships.kinds.license',\n CONTRACT: 'relationships.kinds.contract',\n NEWSLETTER: 'relationships.kinds.newsletter',\n RECURRING_PAYMENT: 'relationships.kinds.recurringPayment',\n ENROLLMENT: 'relationships.kinds.enrollment',\n TRIAL: 'relationships.kinds.trial',\n};\n\n// Lifecycle actions surfaced as buttons; the server validates the transition.\nconst TRANSITIONS: Array<{\n status: SubRelationshipStatus;\n labelKey: string;\n defaultLabel: string;\n icon: typeof Play;\n}> = [\n {\n status: 'ACTIVE',\n labelKey: 'relationships.detail.actions.activate',\n defaultLabel: 'Activate',\n icon: Play,\n },\n {\n status: 'PAUSED',\n labelKey: 'relationships.detail.actions.pause',\n defaultLabel: 'Pause',\n icon: Pause,\n },\n {\n status: 'EXPIRED',\n labelKey: 'relationships.detail.actions.markExpired',\n defaultLabel: 'Mark expired',\n icon: Ban,\n },\n];\n\n/** Compact label/value row for the detail info cards. */\nfunction InfoRow({ label, value }: { label: string; value: ReactNode }) {\n return (\n <div className=\"flex items-center justify-between gap-3 border-b border-border-subtle/60 py-2.5 last:border-0 last:pb-0\">\n <span className=\"shrink-0 text-sm text-text-secondary\">{label}</span>\n <span className=\"min-w-0 truncate text-end text-sm font-medium text-text-primary\">\n {value}\n </span>\n </div>\n );\n}\n\n/** Map a 0–100 health score onto a MiniProgress tone. */\nfunction healthTone(\n score: number | null | undefined\n): 'positive' | 'accent' | 'warning' | 'negative' {\n if (score == null) return 'accent';\n if (score >= 66) return 'positive';\n if (score >= 33) return 'warning';\n return 'negative';\n}\n\n/** ISO string → yyyy-mm-dd for a native <input type=\"date\">. */\nfunction toDateInputValue(iso: string | null | undefined): string {\n if (!iso) return '';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '';\n return d.toISOString().slice(0, 10);\n}\n\n// ---------------------------------------------------------------------------\n// Edit relationship modal → subUpdateRelationship\n// ---------------------------------------------------------------------------\n\nfunction RelationshipEditModal({\n relationship,\n onClose,\n}: {\n relationship: SubRelationship;\n onClose: () => void;\n}) {\n const tr = useTr();\n const update = useUpdateRelationship();\n const providersQ = useProviders({ pagination: { limit: 100, offset: 0 } });\n\n const [label, setLabel] = useState(relationship.label);\n const [providerId, setProviderId] = useState(relationship.providerId ?? '');\n const [planId, setPlanId] = useState(relationship.planId ?? '');\n const [amount, setAmount] = useState(String(relationship.amount ?? ''));\n const [currency, setCurrency] = useState(relationship.currency);\n const [interval, setInterval] = useState<SubBillingInterval>(relationship.interval);\n const [renewsAt, setRenewsAt] = useState(toDateInputValue(relationship.renewsAt));\n const [autoRenew, setAutoRenew] = useState(relationship.autoRenew);\n const [notes, setNotes] = useState(relationship.notes ?? '');\n const [department, setDepartment] = useState(relationship.department ?? '');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const plansQ = usePlans(providerId || undefined);\n\n // Ensure the currently-linked provider is always selectable even if it isn't\n // in the first page of the registry.\n const providerOptions = (() => {\n const list = providersQ.data?.items ?? [];\n if (relationship.provider && !list.some((p) => p.id === relationship.provider?.id)) {\n return [relationship.provider, ...list];\n }\n return list;\n })();\n const plans = plansQ.data ?? [];\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!label.trim()) {\n setFormError(\n tr('relationships.detail.editModal.labelRequired', 'A label is required.'),\n 'edit-label'\n );\n return;\n }\n const input: SubUpdateRelationshipInput = {\n label: label.trim(),\n interval,\n autoRenew,\n currency: currency.trim() || 'USD',\n notes: notes.trim(),\n // Always sent: an empty string clears the department allocation.\n department: department.trim(),\n ...(providerId ? { providerId } : {}),\n ...(planId ? { planId } : {}),\n ...(amount.trim() ? { amount: Number(amount) } : {}),\n ...(renewsAt ? { renewsAt: new Date(renewsAt).toISOString() } : {}),\n };\n update.mutate(\n { id: relationship.id, input },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.editModal.error', 'Could not update relationship.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.editModal.title', 'Edit relationship')}\n onClose={onClose}\n maxWidthClassName=\"max-w-2xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <div>\n <label htmlFor=\"edit-label\" className={labelCls}>\n {tr('relationships.detail.editModal.labelLabel', 'Label')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('edit-label')}\n id=\"edit-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n className={inputCls}\n required\n />\n </div>\n\n <div>\n <label htmlFor=\"edit-department\" className={labelCls}>\n {tr('relationships.detail.editModal.departmentLabel', 'Department or team')}\n </label>\n <input\n {...fieldErrorProps('edit-department')}\n id=\"edit-department\"\n type=\"text\"\n maxLength={120}\n value={department}\n onChange={(e) => setDepartment(e.target.value)}\n placeholder={tr(\n 'relationships.detail.editModal.departmentPlaceholder',\n 'e.g. Engineering, Marketing'\n )}\n className={inputCls}\n />\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"edit-provider\" className={labelCls}>\n {tr('relationships.detail.editModal.providerLabel', 'Provider')}\n </label>\n <select\n {...fieldErrorProps('edit-provider')}\n id=\"edit-provider\"\n value={providerId}\n onChange={(e) => {\n setProviderId(e.target.value);\n setPlanId('');\n }}\n className={inputCls}\n >\n <option value=\"\">\n {tr('relationships.detail.editModal.providerNone', '— None —')}\n </option>\n {providerOptions.map((p) => (\n <option key={p.id} value={p.id}>\n {p.name}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"edit-plan\" className={labelCls}>\n {tr('relationships.detail.editModal.planLabel', 'Plan')}\n </label>\n <select\n {...fieldErrorProps('edit-plan')}\n id=\"edit-plan\"\n value={planId}\n onChange={(e) => setPlanId(e.target.value)}\n className={inputCls}\n disabled={!providerId || plans.length === 0}\n >\n <option value=\"\">{tr('relationships.detail.editModal.planNone', '— None —')}</option>\n {plans.map((pl) => (\n <option key={pl.id} value={pl.id}>\n {pl.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-amount\" className={labelCls}>\n {tr('relationships.detail.editModal.amountLabel', 'Amount')}\n </label>\n <input\n {...fieldErrorProps('edit-amount')}\n id=\"edit-amount\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-currency\" className={labelCls}>\n {tr('relationships.detail.editModal.currencyLabel', 'Currency')}\n </label>\n <input\n {...fieldErrorProps('edit-currency')}\n id=\"edit-currency\"\n type=\"text\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase())}\n maxLength={3}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-interval\" className={labelCls}>\n {tr('relationships.detail.editModal.intervalLabel', 'Billing interval')}\n </label>\n <select\n {...fieldErrorProps('edit-interval')}\n id=\"edit-interval\"\n value={interval}\n onChange={(e) => setInterval(e.target.value as SubBillingInterval)}\n className={inputCls}\n >\n {INTERVALS.map((i) => (\n <option key={i} value={i}>\n {i.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-renews\" className={labelCls}>\n {tr('relationships.detail.editModal.renewsOnLabel', 'Renews on')}\n </label>\n <input\n {...fieldErrorProps('edit-renews')}\n id=\"edit-renews\"\n type=\"date\"\n value={renewsAt}\n onChange={(e) => setRenewsAt(e.target.value)}\n className={inputCls}\n />\n </div>\n <div className=\"flex items-end\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={autoRenew}\n onChange={(e) => setAutoRenew(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('relationships.detail.editModal.autoRenews', 'Auto-renews')}\n </label>\n </div>\n </div>\n\n <div>\n <label htmlFor=\"edit-notes\" className={labelCls}>\n {tr('relationships.detail.editModal.notesLabel', 'Notes')}\n </label>\n <textarea\n {...fieldErrorProps('edit-notes')}\n id=\"edit-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n rows={3}\n className={inputCls}\n />\n </div>\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.editModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={update.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {update.isPending\n ? tr('relationships.detail.editModal.saving', 'Saving…')\n : tr('relationships.detail.editModal.submit', 'Save changes')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add entitlement modal → subCreateEntitlement\n// ---------------------------------------------------------------------------\n\nfunction AddEntitlementModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateEntitlement();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubEntitlementType>('FEATURE_ACCESS');\n const [quota, setQuota] = useState('');\n const [unit, setUnit] = useState('');\n const [description, setDescription] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!name.trim()) {\n setFormError(\n tr(\n 'relationships.detail.addEntitlementModal.nameRequired',\n 'An entitlement name is required.'\n ),\n 'ent-name'\n );\n return;\n }\n create.mutate(\n {\n relationshipId,\n name: name.trim(),\n type,\n ...(quota.trim() ? { quota: Number(quota) } : {}),\n ...(unit.trim() ? { unit: unit.trim() } : {}),\n ...(description.trim() ? { description: description.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.addEntitlementModal.error', 'Could not add entitlement.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.addEntitlementModal.title', 'Add entitlement')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"ent-name\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.nameLabel', 'Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ent-name')}\n id=\"ent-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.namePlaceholder',\n 'e.g. Seats, API calls, Priority support'\n )}\n className={inputCls}\n required\n />\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"ent-type\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ent-type')}\n id=\"ent-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubEntitlementType)}\n className={inputCls}\n >\n {ENTITLEMENT_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ent-quota\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.quotaLabel', 'Quota')}\n </label>\n <input\n {...fieldErrorProps('ent-quota')}\n id=\"ent-quota\"\n type=\"number\"\n min=\"0\"\n value={quota}\n onChange={(e) => setQuota(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.quotaPlaceholder',\n 'e.g. 5'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"ent-unit\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.unitLabel', 'Unit')}\n </label>\n <input\n {...fieldErrorProps('ent-unit')}\n id=\"ent-unit\"\n type=\"text\"\n value={unit}\n onChange={(e) => setUnit(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.unitPlaceholder',\n 'e.g. seats, GB'\n )}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ent-desc\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.descriptionLabel', 'Description')}\n </label>\n <textarea\n {...fieldErrorProps('ent-desc')}\n id=\"ent-desc\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.addEntitlementModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('relationships.detail.addEntitlementModal.adding', 'Adding…')\n : tr('relationships.detail.addEntitlementModal.submit', 'Add entitlement')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Attach asset modal → upload to files-svc, then subCreateAsset\n// ---------------------------------------------------------------------------\n\nfunction AttachAssetModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateAsset();\n const { uploadFile, progress, isUploading } = useUploadFile();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubAssetType>('RECEIPT');\n const [file, setFile] = useState<File | null>(null);\n const [expiresAt, setExpiresAt] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const busy = isUploading || create.isPending;\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!file) {\n setFormError(\n tr('relationships.detail.attachAssetModal.chooseFile', 'Choose a file to attach.'),\n 'asset-file'\n );\n return;\n }\n try {\n const { fileId, fileName } = await uploadFile(file);\n await create.mutateAsync({\n relationshipId,\n name: name.trim() || fileName,\n type,\n fileId,\n ...(expiresAt ? { expiresAt: new Date(expiresAt).toISOString() } : {}),\n });\n onClose();\n } catch (err) {\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.attachAssetModal.error', 'Could not attach the asset.')\n );\n }\n };\n\n return (\n <Modal\n title={tr('relationships.detail.attachAssetModal.title', 'Attach asset')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"asset-file\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.fileLabel', 'File')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('asset-file')}\n id=\"asset-file\"\n type=\"file\"\n onChange={(e) => {\n const f = e.target.files?.[0] ?? null;\n setFile(f);\n if (f && !name.trim()) setName(f.name);\n }}\n className=\"w-full text-sm text-text-secondary file:me-3 file:rounded-lg file:border file:border-border-subtle file:bg-bg-surface file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-text-primary hover:file:bg-bg-sunken\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.attachAssetModal.fileHint',\n 'Stored securely in files — only a reference is kept here.'\n )}\n </p>\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"asset-name\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.nameLabel', 'Name')}\n </label>\n <input\n {...fieldErrorProps('asset-name')}\n id=\"asset-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.attachAssetModal.namePlaceholder',\n 'Defaults to the file name'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"asset-type\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('asset-type')}\n id=\"asset-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubAssetType)}\n className={inputCls}\n >\n {ASSET_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"asset-expires\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.expiresOnLabel', 'Expires on')}\n </label>\n <input\n {...fieldErrorProps('asset-expires')}\n id=\"asset-expires\"\n type=\"date\"\n value={expiresAt}\n onChange={(e) => setExpiresAt(e.target.value)}\n className={inputCls}\n />\n </div>\n {isUploading && (\n <p className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.attachAssetModal.uploading', 'Uploading… {{progress}}%', {\n progress,\n })}\n </p>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.attachAssetModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={busy}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {busy\n ? tr('relationships.detail.attachAssetModal.attaching', 'Attaching…')\n : tr('relationships.detail.attachAssetModal.submit', 'Attach asset')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Asset row — resolves a presigned download URL on demand\n// ---------------------------------------------------------------------------\n\nfunction AssetRow({ asset }: { asset: NonNullable<SubRelationship['assets']>[number] }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [downloading, setDownloading] = useState(false);\n\n const handleDownload = async () => {\n if (!asset.file?.id) return;\n setDownloading(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } catch {\n // Non-fatal: a broken/expired file reference just can't be downloaded.\n } finally {\n setDownloading(false);\n }\n };\n\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{asset.name}</p>\n <p className=\"text-xs text-text-secondary\">{formatEnumLabel(asset.type)}</p>\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-3\">\n {asset.expiresAt && (\n <span className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.assetRow.expires', 'Expires {{date}}', {\n date: formatDate(asset.expiresAt),\n })}\n </span>\n )}\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={handleDownload}\n disabled={downloading}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Download className=\"h-3.5 w-3.5\" />{' '}\n {downloading\n ? tr('relationships.detail.assetRow.opening', 'Opening…')\n : tr('relationships.detail.assetRow.download', 'Download')}\n </button>\n )}\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Invoice row (BOFF-8659) — every invoice linked to this relationship via\n// `SubInvoice.relationshipId` is shown in the Assets section alongside any\n// file-based assets, so users don't have to leave the relationship page to\n// discover that they have an outstanding invoice tied to it.\n// ---------------------------------------------------------------------------\n\nfunction InvoiceRow({ invoice }: { invoice: SubInvoice }) {\n const { formatCurrency, formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n // Each invoice appears once, grouped by the (most-recent) due or issue\n // date and labelled with number · status, then a right-aligned total that\n // matches the Invoices list currency formatting.\n const label =\n invoice.number ?? tr('relationships.detail.invoiceRow.unnumbered', 'Unnumbered invoice');\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <CreditCard className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{label}</p>\n <p className=\"text-xs text-text-secondary\">\n {formatEnumLabel(invoice.status)}\n {invoice.dueDate\n ? ` · ${tr('relationships.detail.invoiceRow.due', 'due {{date}}', {\n date: formatDate(invoice.dueDate),\n })}`\n : invoice.issueDate\n ? ` · ${formatDate(invoice.issueDate)}`\n : ''}\n </p>\n </div>\n </div>\n <span className=\"shrink-0 text-sm font-medium tabular-nums text-text-primary\">\n {formatCurrency(invoice.total, invoice.currency)}\n </span>\n </div>\n );\n}\n\nexport function RelationshipDetailPage() {\n const { formatCurrency, formatDate, formatEnumLabel, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { id } = useParams<{ id: string }>();\n const { navigateTo } = useSubscriberBot();\n const { data: relationship, isLoading, isError, refetch } = useRelationship(id);\n const transition = useTransitionRelationship();\n const cancel = useCancelRelationship();\n const [actionError, setActionError] = useState<string | null>(null);\n const [showEdit, setShowEdit] = useState(false);\n const [showAddEntitlement, setShowAddEntitlement] = useState(false);\n const [showAttachAsset, setShowAttachAsset] = useState(false);\n // Open AI recommendations about this subscription (BOFF-3663). Best effort:\n // if the decision engine is unavailable the section is simply omitted, and\n // every change it could propose stays available through the actions above.\n // Invoices linked through SubInvoice.relationshipId (BOFF-8659). The svc\n // exposes them through subListInvoices(relationshipId), not as a field on\n // SubRelationship, so they are read with their own query.\n const relationshipInvoices = useInvoices(\n { relationshipId: id, pagination: { limit: 50, offset: 0 } },\n { enabled: Boolean(id) }\n );\n const openDecisions = useDecisions(\n { relationshipId: id, status: 'PROPOSED' },\n { enabled: Boolean(id) }\n );\n\n if (isLoading) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <LoadingView label={tr('relationships.detail.loading', 'Loading relationship…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <ErrorView\n message={tr('relationships.detail.error', 'Could not load this relationship.')}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n if (!relationship) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.notFoundTitle', 'Relationship not found')}\n description={tr(\n 'relationships.detail.notFoundDescription',\n 'It may have been removed, or you may not have access to it.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\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('relationships.detail.backToRelationships', 'Back to relationships')}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const r = relationship;\n const isBusy = transition.isPending || cancel.isPending;\n\n const runTransition = (status: SubRelationshipStatus) => {\n setActionError(null);\n transition.mutate(\n { id: r.id, status },\n {\n onError: (e) =>\n setActionError(\n e instanceof Error\n ? e.message\n : tr('relationships.detail.transitionError', 'Transition failed')\n ),\n }\n );\n };\n\n const runCancel = () => {\n setActionError(null);\n cancel.mutate(r.id, {\n onError: (e) =>\n setActionError(\n e instanceof Error ? e.message : tr('relationships.detail.cancelError', 'Cancel failed')\n ),\n });\n };\n\n // Renewal timeline — built entirely from the real renewalEvents, oldest → newest.\n const renewalTimeline: TimelineItem[] = [...(r.renewalEvents ?? [])]\n .sort((a, b) => new Date(a.occursAt).getTime() - new Date(b.occursAt).getTime())\n .map((event) => {\n const ts = new Date(event.occursAt).getTime();\n const isFuture = !Number.isNaN(ts) && ts > Date.now();\n return {\n title: formatEnumLabel(event.eventType),\n sub: `${formatDate(event.occursAt)}${event.detail ? ` · ${event.detail}` : ''}`,\n meta:\n event.amount != null\n ? formatCurrency(event.amount, event.currency ?? r.currency)\n : undefined,\n tone: isFuture ? 'warning' : 'muted',\n };\n });\n\n const autoRenewPill = r.autoRenew ? (\n <span className=\"inline-flex items-center rounded-full bg-status-success-bg-subtle px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tr('relationships.detail.autoRenewOn', 'On')}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.autoRenewOff', 'Off')}\n </span>\n );\n\n // Only offer transitions the svc state machine accepts from the current\n // status (a cancelled relationship no longer shows Activate / Pause).\n const availableTransitions = TRANSITIONS.filter((t) => canTransition(r.status, t.status));\n const planFeatures = r.plan?.features ?? [];\n\n return (\n <PageLayout\n title={r.label}\n description={r.provider?.name ?? tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n actions={\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowEdit(true)}\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Pencil className=\"h-4 w-4\" /> {tr('relationships.detail.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n data-testid=\"negotiate-bill\"\n onClick={() =>\n navigateTo(`/negotiations/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Handshake className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.negotiate', 'Negotiate this bill')}\n </button>\n <button\n type=\"button\"\n data-testid=\"request-procurement\"\n onClick={() =>\n navigateTo(`/procurement/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Briefcase className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.procurement', 'Ask an expert to negotiate')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-2 rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('relationships.detail.back', 'Back')}\n </button>\n </div>\n }\n >\n {/* Hero summary + lifecycle actions */}\n <GlassCard treatment=\"glass\" glow className=\"p-5 sm:p-6\">\n <div className=\"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-3\">\n <span className=\"text-3xl font-bold tabular-nums text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n <span className=\"text-base font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </span>\n <StatusBadge status={r.status} />\n </div>\n <div className=\"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <CalendarClock className=\"h-3.5 w-3.5\" />\n {r.renewsAt\n ? tr('relationships.detail.renews', 'Renews {{date}}', {\n date: formatDate(r.renewsAt),\n })\n : tr('relationships.detail.noRenewalScheduled', 'No renewal scheduled')}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n <ShieldCheck className=\"h-3.5 w-3.5\" />\n {formatEnumLabel(r.discoverySource)}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n {tr('relationships.detail.autoRenew', 'Auto-renew')} {autoRenewPill}\n </span>\n </div>\n {r.tags.length > 0 && (\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Tag className=\"h-3.5 w-3.5 text-text-secondary\" />\n {r.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n\n {/* Lifecycle actions */}\n <div className=\"grid shrink-0 grid-cols-2 gap-2 sm:flex sm:flex-wrap lg:flex-col lg:items-stretch\">\n {availableTransitions.map((t) => {\n const Icon = t.icon;\n return (\n <button\n key={t.status}\n type=\"button\"\n disabled={isBusy}\n onClick={() => runTransition(t.status)}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Icon className=\"h-3.5 w-3.5\" /> {tr(t.labelKey, t.defaultLabel)}\n </button>\n );\n })}\n {canTransition(r.status, 'CANCELLED') && (\n <button\n type=\"button\"\n disabled={isBusy}\n onClick={runCancel}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-status-error-text hover:opacity-90 disabled:opacity-50\"\n >\n <Ban className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.actions.cancel', 'Cancel')}\n </button>\n )}\n </div>\n </div>\n </GlassCard>\n\n {actionError && (\n <div className=\"mt-4 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {actionError}\n </div>\n )}\n\n {/* Main layout: details (left) + health & timeline rail (right) */}\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Plan & pricing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CreditCard className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.planPricing', 'Plan & pricing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.plan', 'Plan')}\n value={r.plan?.name ?? '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.price', 'Price')}\n value={\n <>\n {formatCurrency(r.amount, r.currency)}\n <span className=\"font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </>\n }\n />\n <InfoRow\n label={tr('relationships.detail.info.billingInterval', 'Billing interval')}\n value={formatEnumLabel(r.interval)}\n />\n <InfoRow\n label={tr('relationships.detail.info.provider', 'Provider')}\n value={r.provider?.name ?? '—'}\n />\n </div>\n {planFeatures.length > 0 && (\n <div className=\"mt-3 flex flex-wrap gap-1.5\">\n {planFeatures.map((f) => (\n <span\n key={f}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {f}\n </span>\n ))}\n </div>\n )}\n </GlassCard>\n\n {/* Payment & billing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Wallet className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.paymentBilling', 'Payment & billing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.currency', 'Currency')}\n value={r.currency}\n />\n <InfoRow\n label={tr('relationships.detail.info.autoRenew', 'Auto-renew')}\n value={autoRenewPill}\n />\n <InfoRow\n label={tr('relationships.detail.info.nextRenewal', 'Next renewal')}\n value={r.renewsAt ? formatDate(r.renewsAt) : '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.started', 'Started')}\n value={r.startedAt ? formatDate(r.startedAt) : '—'}\n />\n {r.trialEndsAt && (\n <InfoRow\n label={tr('relationships.detail.info.trialEnds', 'Trial ends')}\n value={formatDate(r.trialEndsAt)}\n />\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Open AI recommendations for this subscription */}\n {(openDecisions.data?.items.length ?? 0) > 0 && (\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.aiRecommendations', 'AI recommendations')}\n description={tr(\n 'relationships.detail.sections.aiRecommendationsDescription',\n 'Open recommendations about this subscription. You can also make any of these changes by hand above.'\n )}\n >\n <AiDisclaimer className=\"mb-3\" />\n <div className=\"grid grid-cols-1 gap-3\" data-testid=\"relationship-decisions\">\n {openDecisions.data?.items.map((d) => (\n <DecisionCard key={d.id} decision={d} />\n ))}\n </div>\n </Section>\n )}\n\n {/* Entitlements */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.entitlements', 'Entitlements')}\n description={tr(\n 'relationships.detail.sections.entitlementsDescription',\n 'What this relationship grants you'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAddEntitlement(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.addEntitlement', 'Add entitlement')}\n </button>\n }\n >\n {!r.entitlements || r.entitlements.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noEntitlementsTitle', 'No entitlements')}\n description={tr(\n 'relationships.detail.empty.noEntitlementsDescription',\n 'Entitlements (seats, quotas, feature access) will appear here.'\n )}\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n {r.entitlements.map((e) => {\n const hasQuota = e.quota != null && e.quota > 0;\n return (\n <GlassCard key={e.id} treatment=\"plain\" className=\"p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <p className=\"min-w-0 truncate text-sm font-medium text-text-primary\">\n {e.name}\n </p>\n <StatusBadge status={e.isActive ? 'ACTIVE' : 'DISABLED'} />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">{formatEnumLabel(e.type)}</p>\n {hasQuota && (\n <div className=\"mt-3\">\n <div className=\"flex items-center justify-between text-xs text-text-secondary\">\n <span>\n {e.used} / {e.quota}\n {e.unit ? ` ${e.unit}` : ''}\n </span>\n <span className=\"tabular-nums\">\n {Math.round((e.used / (e.quota as number)) * 100)}%\n </span>\n </div>\n <MiniProgress\n label={tr('common.quotaUtilization', 'Quota utilization')}\n value={e.used}\n max={e.quota as number}\n tone={\n e.used / (e.quota as number) >= 0.9\n ? 'negative'\n : e.used / (e.quota as number) >= 0.7\n ? 'warning'\n : 'accent'\n }\n className=\"mt-1.5\"\n />\n </div>\n )}\n </GlassCard>\n );\n })}\n </div>\n )}\n </Section>\n\n {/* Assets — file-based assets + relationship-owned invoices.\n BOFF-8659: invoices linked via `SubInvoice.relationshipId` are now\n shown here too, so the panel copy \"Invoices, contracts, licenses\n and credentials\" is honored for the cross-module Relationships ↔\n Invoices flow. */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.assets', 'Assets')}\n description={tr(\n 'relationships.detail.sections.assetsDescription',\n 'Invoices, contracts, licenses and credentials'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAttachAsset(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.attachAsset', 'Attach asset')}\n </button>\n }\n >\n {(() => {\n const assets = r.assets ?? [];\n // BOFF-8659 — pull relationship-owned invoices into the same\n // Assets list, sorted next to file-based assets by their sort\n // time so invoices appear in the same order as the Invoices\n // list (newest first).\n const invoices: SubInvoice[] = relationshipInvoices.data?.items ?? [];\n const hasAny = assets.length > 0 || invoices.length > 0;\n if (!hasAny) {\n return (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noAssetsTitle', 'No assets attached')}\n description={tr(\n 'relationships.detail.empty.noAssetsDescription',\n 'Attach invoices, contracts, licenses or receipts to this relationship.'\n )}\n />\n );\n }\n type AssetLike =\n | {\n kind: 'asset';\n sort: number;\n asset: NonNullable<SubRelationship['assets']>[number];\n }\n | {\n kind: 'invoice';\n sort: number;\n invoice: SubInvoice;\n };\n const combined: AssetLike[] = [\n ...assets.map((a) => ({\n kind: 'asset' as const,\n sort: new Date(a.createdAt).getTime() || 0,\n asset: a,\n })),\n ...invoices.map((i) => ({\n kind: 'invoice' as const,\n sort: new Date(i.createdAt).getTime() || 0,\n invoice: i,\n })),\n ].sort((x, y) => y.sort - x.sort);\n return (\n <GlassCard treatment=\"plain\" className=\"divide-y divide-border-subtle p-0\">\n {combined.map((row) =>\n row.kind === 'asset' ? (\n <AssetRow key={`a-${row.asset.id}`} asset={row.asset} />\n ) : (\n <InvoiceRow key={`i-${row.invoice.id}`} invoice={row.invoice} />\n )\n )}\n </GlassCard>\n );\n })()}\n </Section>\n\n {r.notes && (\n <GlassCard treatment=\"plain\" className=\"p-4\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.sections.notes', 'Notes')}\n </p>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{r.notes}</p>\n </GlassCard>\n )}\n </div>\n\n {/* Right rail: health gauge + renewal timeline */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Activity className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.healthScore', 'Health score')}\n </div>\n {r.healthScore != null ? (\n <div className=\"mt-4 flex flex-col items-center\">\n <Gauge\n value={r.healthScore}\n max={100}\n size={160}\n label={tr('relationships.detail.outOf100', 'of 100')}\n />\n <div className=\"mt-2 w-full\">\n <MiniProgress\n label={tr('common.healthScore', 'Health score')}\n value={r.healthScore}\n max={100}\n tone={healthTone(r.healthScore)}\n />\n </div>\n <p\n className=\"mt-3 text-center text-xs text-text-secondary\"\n data-testid=\"health-score-basis\"\n >\n {tr(\n 'relationships.detail.healthScoreBasis',\n 'Computed from usage, payment history, price stability and overlap with your other subscriptions.'\n )}\n </p>\n </div>\n ) : (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'relationships.detail.empty.noHealthScore',\n 'Not scored yet. A health score appears once Subscriber Bot has enough signal.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CalendarClock className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.renewalTimeline', 'Renewal timeline')}\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.sections.renewalTimelineDescription',\n 'Detected renewals and price changes'\n )}\n </p>\n {renewalTimeline.length === 0 ? (\n <div className=\"mt-4\">\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('relationships.detail.empty.noRenewalEventsTitle', 'No renewal events')}\n description={tr(\n 'relationships.detail.empty.noRenewalEventsDescription',\n \"Renewals and price changes will appear here as they're detected.\"\n )}\n />\n </div>\n ) : (\n <Timeline items={renewalTimeline} className=\"mt-4\" />\n )}\n </GlassCard>\n </div>\n </div>\n\n {showEdit && <RelationshipEditModal relationship={r} onClose={() => setShowEdit(false)} />}\n {showAddEntitlement && (\n <AddEntitlementModal relationshipId={r.id} onClose={() => setShowAddEntitlement(false)} />\n )}\n {showAttachAsset && (\n <AttachAssetModal relationshipId={r.id} onClose={() => setShowAttachAsset(false)} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,IACJ,wMACI,IAAW,sDAEX,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,KAAgD;CACpD,cAAc;CACd,YAAY;CACZ,SAAS;CACT,UAAU;CACV,YAAY;CACZ,mBAAmB;CACnB,YAAY;CACZ,OAAO;AACT,GAGM,KAKD;CACH;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;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;EAE3E;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"RelationshipDetailPage.js","names":[],"sources":["../../../../src/subscriberbot/pages/relationships/RelationshipDetailPage.tsx"],"sourcesContent":["import { useFormatters } from '../../hooks/useFormatters';\nimport { useFormError } from '../../hooks/useFormError';\n/**\n * Relationship detail\n * @module subscriberbot/pages/relationships\n *\n * Full per-relationship view: plan, price, billing period, next renewal,\n * health score, entitlements, attached assets and renewal events — plus\n * lifecycle transitions (validated server-side), edit, and cancel.\n * Reads `subRelationship(id)`; writes `subTransitionRelationship`,\n * `subCancelRelationship`, `subUpdateRelationship`, `subCreateEntitlement`,\n * `subCreateAsset`.\n */\n\nimport { useState, type ReactNode } from 'react';\nimport { useParams } from 'react-router';\nimport {\n ArrowLeft,\n Briefcase,\n CreditCard,\n Wallet,\n ShieldCheck,\n CalendarClock,\n Paperclip,\n Activity,\n Tag,\n Pencil,\n Handshake,\n Plus,\n Pause,\n Play,\n Ban,\n Download,\n} from 'lucide-react';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { PageLayout } from '../../components/PageLayout';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { Modal } from '../../components/Modal';\nimport { LoadingView, ErrorView, Section } from '../../components/StateViews';\nimport { AiDisclaimer, DecisionCard } from '../../components/decisions';\nimport { Gauge, Timeline, MiniProgress } from '../../components';\nimport type { TimelineItem } from '../../components';\nimport { useSubscriberBot } from '../../context/SubscriberBotContext';\nimport {\n useRelationship,\n useTransitionRelationship,\n useCancelRelationship,\n useUpdateRelationship,\n useCreateEntitlement,\n useCreateAsset,\n useUploadFile,\n useFileDownloadUrl,\n useProviders,\n usePlans,\n useDecisions,\n useInvoices,\n} from '../../hooks/useSubscriberBotApi';\n\nimport { useTr } from '../../hooks/useTr';\nimport { canTransition } from '../../utils/portfolio';\nimport type {\n SubAssetType,\n SubBillingInterval,\n SubEntitlementType,\n SubInvoice,\n SubRelationship,\n SubRelationshipKind,\n SubRelationshipStatus,\n SubUpdateRelationshipInput,\n} from '../../types';\n\nconst inputCls =\n 'w-full rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\nconst labelCls = 'mb-1 block text-xs font-medium text-text-secondary';\n\nconst INTERVALS: SubBillingInterval[] = [\n 'MONTHLY',\n 'YEARLY',\n 'QUARTERLY',\n 'WEEKLY',\n 'DAILY',\n 'USAGE_BASED',\n 'LIFETIME',\n 'FREE',\n];\n\nconst ENTITLEMENT_TYPES: SubEntitlementType[] = [\n 'FEATURE_ACCESS',\n 'SEAT',\n 'USAGE_QUOTA',\n 'CONTENT',\n 'DISCOUNT',\n 'SUPPORT_TIER',\n];\n\nconst ASSET_TYPES: SubAssetType[] = [\n 'RECEIPT',\n 'INVOICE',\n 'CONTRACT',\n 'LICENSE_KEY',\n 'CREDENTIAL',\n 'CERTIFICATE',\n 'WARRANTY',\n 'DOMAIN',\n];\n\nconst KIND_KEY: Record<SubRelationshipKind, string> = {\n SUBSCRIPTION: 'relationships.kinds.subscription',\n MEMBERSHIP: 'relationships.kinds.membership',\n LICENSE: 'relationships.kinds.license',\n CONTRACT: 'relationships.kinds.contract',\n NEWSLETTER: 'relationships.kinds.newsletter',\n RECURRING_PAYMENT: 'relationships.kinds.recurringPayment',\n ENROLLMENT: 'relationships.kinds.enrollment',\n TRIAL: 'relationships.kinds.trial',\n};\n\n// Lifecycle actions surfaced as buttons; the server validates the transition.\nconst TRANSITIONS: Array<{\n status: SubRelationshipStatus;\n labelKey: string;\n defaultLabel: string;\n icon: typeof Play;\n}> = [\n {\n status: 'ACTIVE',\n labelKey: 'relationships.detail.actions.activate',\n defaultLabel: 'Activate',\n icon: Play,\n },\n {\n status: 'PAUSED',\n labelKey: 'relationships.detail.actions.pause',\n defaultLabel: 'Pause',\n icon: Pause,\n },\n {\n status: 'EXPIRED',\n labelKey: 'relationships.detail.actions.markExpired',\n defaultLabel: 'Mark expired',\n icon: Ban,\n },\n];\n\n/** Compact label/value row for the detail info cards. */\nfunction InfoRow({ label, value }: { label: string; value: ReactNode }) {\n return (\n <div className=\"flex items-center justify-between gap-3 border-b border-border-subtle/60 py-2.5 last:border-0 last:pb-0\">\n <span className=\"shrink-0 text-sm text-text-secondary\">{label}</span>\n <span className=\"min-w-0 truncate text-end text-sm font-medium text-text-primary\">\n {value}\n </span>\n </div>\n );\n}\n\n/** Map a 0–100 health score onto a MiniProgress tone. */\nfunction healthTone(\n score: number | null | undefined\n): 'positive' | 'accent' | 'warning' | 'negative' {\n if (score == null) return 'accent';\n if (score >= 66) return 'positive';\n if (score >= 33) return 'warning';\n return 'negative';\n}\n\n/** ISO string → yyyy-mm-dd for a native <input type=\"date\">. */\nfunction toDateInputValue(iso: string | null | undefined): string {\n if (!iso) return '';\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return '';\n return d.toISOString().slice(0, 10);\n}\n\n// ---------------------------------------------------------------------------\n// Edit relationship modal → subUpdateRelationship\n// ---------------------------------------------------------------------------\n\nfunction RelationshipEditModal({\n relationship,\n onClose,\n}: {\n relationship: SubRelationship;\n onClose: () => void;\n}) {\n const tr = useTr();\n const update = useUpdateRelationship();\n const providersQ = useProviders({ pagination: { limit: 100, offset: 0 } });\n\n const [label, setLabel] = useState(relationship.label);\n const [providerId, setProviderId] = useState(relationship.providerId ?? '');\n const [planId, setPlanId] = useState(relationship.planId ?? '');\n const [amount, setAmount] = useState(String(relationship.amount ?? ''));\n const [currency, setCurrency] = useState(relationship.currency);\n const [interval, setInterval] = useState<SubBillingInterval>(relationship.interval);\n const [renewsAt, setRenewsAt] = useState(toDateInputValue(relationship.renewsAt));\n const [autoRenew, setAutoRenew] = useState(relationship.autoRenew);\n const [notes, setNotes] = useState(relationship.notes ?? '');\n const [department, setDepartment] = useState(relationship.department ?? '');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const plansQ = usePlans(providerId || undefined);\n\n // Ensure the currently-linked provider is always selectable even if it isn't\n // in the first page of the registry.\n const providerOptions = (() => {\n const list = providersQ.data?.items ?? [];\n if (relationship.provider && !list.some((p) => p.id === relationship.provider?.id)) {\n return [relationship.provider, ...list];\n }\n return list;\n })();\n const plans = plansQ.data ?? [];\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!label.trim()) {\n setFormError(\n tr('relationships.detail.editModal.labelRequired', 'A label is required.'),\n 'edit-label'\n );\n return;\n }\n const input: SubUpdateRelationshipInput = {\n label: label.trim(),\n interval,\n autoRenew,\n currency: currency.trim() || 'USD',\n notes: notes.trim(),\n // Always sent: an empty string clears the department allocation.\n department: department.trim(),\n ...(providerId ? { providerId } : {}),\n ...(planId ? { planId } : {}),\n ...(amount.trim() ? { amount: Number(amount) } : {}),\n ...(renewsAt ? { renewsAt: new Date(renewsAt).toISOString() } : {}),\n };\n update.mutate(\n { id: relationship.id, input },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.editModal.error', 'Could not update relationship.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.editModal.title', 'Edit relationship')}\n onClose={onClose}\n maxWidthClassName=\"max-w-2xl\"\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n\n <div>\n <label htmlFor=\"edit-label\" className={labelCls}>\n {tr('relationships.detail.editModal.labelLabel', 'Label')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('edit-label')}\n id=\"edit-label\"\n type=\"text\"\n value={label}\n onChange={(e) => setLabel(e.target.value)}\n className={inputCls}\n required\n />\n </div>\n\n <div>\n <label htmlFor=\"edit-department\" className={labelCls}>\n {tr('relationships.detail.editModal.departmentLabel', 'Department or team')}\n </label>\n <input\n {...fieldErrorProps('edit-department')}\n id=\"edit-department\"\n type=\"text\"\n maxLength={120}\n value={department}\n onChange={(e) => setDepartment(e.target.value)}\n placeholder={tr(\n 'relationships.detail.editModal.departmentPlaceholder',\n 'e.g. Engineering, Marketing'\n )}\n className={inputCls}\n />\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"edit-provider\" className={labelCls}>\n {tr('relationships.detail.editModal.providerLabel', 'Provider')}\n </label>\n <select\n {...fieldErrorProps('edit-provider')}\n id=\"edit-provider\"\n value={providerId}\n onChange={(e) => {\n setProviderId(e.target.value);\n setPlanId('');\n }}\n className={inputCls}\n >\n <option value=\"\">\n {tr('relationships.detail.editModal.providerNone', '— None —')}\n </option>\n {providerOptions.map((p) => (\n <option key={p.id} value={p.id}>\n {p.name}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"edit-plan\" className={labelCls}>\n {tr('relationships.detail.editModal.planLabel', 'Plan')}\n </label>\n <select\n {...fieldErrorProps('edit-plan')}\n id=\"edit-plan\"\n value={planId}\n onChange={(e) => setPlanId(e.target.value)}\n className={inputCls}\n disabled={!providerId || plans.length === 0}\n >\n <option value=\"\">{tr('relationships.detail.editModal.planNone', '— None —')}</option>\n {plans.map((pl) => (\n <option key={pl.id} value={pl.id}>\n {pl.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-amount\" className={labelCls}>\n {tr('relationships.detail.editModal.amountLabel', 'Amount')}\n </label>\n <input\n {...fieldErrorProps('edit-amount')}\n id=\"edit-amount\"\n type=\"number\"\n min=\"0\"\n step=\"0.01\"\n value={amount}\n onChange={(e) => setAmount(e.target.value)}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-currency\" className={labelCls}>\n {tr('relationships.detail.editModal.currencyLabel', 'Currency')}\n </label>\n <input\n {...fieldErrorProps('edit-currency')}\n id=\"edit-currency\"\n type=\"text\"\n value={currency}\n onChange={(e) => setCurrency(e.target.value.toUpperCase())}\n maxLength={3}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"edit-interval\" className={labelCls}>\n {tr('relationships.detail.editModal.intervalLabel', 'Billing interval')}\n </label>\n <select\n {...fieldErrorProps('edit-interval')}\n id=\"edit-interval\"\n value={interval}\n onChange={(e) => setInterval(e.target.value as SubBillingInterval)}\n className={inputCls}\n >\n {INTERVALS.map((i) => (\n <option key={i} value={i}>\n {i.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"edit-renews\" className={labelCls}>\n {tr('relationships.detail.editModal.renewsOnLabel', 'Renews on')}\n </label>\n <input\n {...fieldErrorProps('edit-renews')}\n id=\"edit-renews\"\n type=\"date\"\n value={renewsAt}\n onChange={(e) => setRenewsAt(e.target.value)}\n className={inputCls}\n />\n </div>\n <div className=\"flex items-end\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={autoRenew}\n onChange={(e) => setAutoRenew(e.target.checked)}\n className=\"size-4 rounded border-border-subtle\"\n />\n {tr('relationships.detail.editModal.autoRenews', 'Auto-renews')}\n </label>\n </div>\n </div>\n\n <div>\n <label htmlFor=\"edit-notes\" className={labelCls}>\n {tr('relationships.detail.editModal.notesLabel', 'Notes')}\n </label>\n <textarea\n {...fieldErrorProps('edit-notes')}\n id=\"edit-notes\"\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n rows={3}\n className={inputCls}\n />\n </div>\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.editModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={update.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {update.isPending\n ? tr('relationships.detail.editModal.saving', 'Saving…')\n : tr('relationships.detail.editModal.submit', 'Save changes')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Add entitlement modal → subCreateEntitlement\n// ---------------------------------------------------------------------------\n\nfunction AddEntitlementModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateEntitlement();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubEntitlementType>('FEATURE_ACCESS');\n const [quota, setQuota] = useState('');\n const [unit, setUnit] = useState('');\n const [description, setDescription] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const handleSubmit = (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!name.trim()) {\n setFormError(\n tr(\n 'relationships.detail.addEntitlementModal.nameRequired',\n 'An entitlement name is required.'\n ),\n 'ent-name'\n );\n return;\n }\n create.mutate(\n {\n relationshipId,\n name: name.trim(),\n type,\n ...(quota.trim() ? { quota: Number(quota) } : {}),\n ...(unit.trim() ? { unit: unit.trim() } : {}),\n ...(description.trim() ? { description: description.trim() } : {}),\n },\n {\n onSuccess: () => onClose(),\n onError: (err) =>\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.addEntitlementModal.error', 'Could not add entitlement.')\n ),\n }\n );\n };\n\n return (\n <Modal\n title={tr('relationships.detail.addEntitlementModal.title', 'Add entitlement')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"ent-name\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.nameLabel', 'Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('ent-name')}\n id=\"ent-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.namePlaceholder',\n 'e.g. Seats, API calls, Priority support'\n )}\n className={inputCls}\n required\n />\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <div>\n <label htmlFor=\"ent-type\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('ent-type')}\n id=\"ent-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubEntitlementType)}\n className={inputCls}\n >\n {ENTITLEMENT_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n <div>\n <label htmlFor=\"ent-quota\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.quotaLabel', 'Quota')}\n </label>\n <input\n {...fieldErrorProps('ent-quota')}\n id=\"ent-quota\"\n type=\"number\"\n min=\"0\"\n value={quota}\n onChange={(e) => setQuota(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.quotaPlaceholder',\n 'e.g. 5'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"ent-unit\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.unitLabel', 'Unit')}\n </label>\n <input\n {...fieldErrorProps('ent-unit')}\n id=\"ent-unit\"\n type=\"text\"\n value={unit}\n onChange={(e) => setUnit(e.target.value)}\n placeholder={tr(\n 'relationships.detail.addEntitlementModal.unitPlaceholder',\n 'e.g. seats, GB'\n )}\n className={inputCls}\n />\n </div>\n </div>\n <div>\n <label htmlFor=\"ent-desc\" className={labelCls}>\n {tr('relationships.detail.addEntitlementModal.descriptionLabel', 'Description')}\n </label>\n <textarea\n {...fieldErrorProps('ent-desc')}\n id=\"ent-desc\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n rows={2}\n className={inputCls}\n />\n </div>\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.addEntitlementModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={create.isPending}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {create.isPending\n ? tr('relationships.detail.addEntitlementModal.adding', 'Adding…')\n : tr('relationships.detail.addEntitlementModal.submit', 'Add entitlement')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Attach asset modal → upload to files-svc, then subCreateAsset\n// ---------------------------------------------------------------------------\n\nfunction AttachAssetModal({\n relationshipId,\n onClose,\n}: {\n relationshipId: string;\n onClose: () => void;\n}) {\n const tr = useTr();\n const create = useCreateAsset();\n const { uploadFile, progress, isUploading } = useUploadFile();\n const [name, setName] = useState('');\n const [type, setType] = useState<SubAssetType>('RECEIPT');\n const [file, setFile] = useState<File | null>(null);\n const [expiresAt, setExpiresAt] = useState('');\n const [formError, setFormError, fieldErrorProps, formErrorId] = useFormError();\n\n const busy = isUploading || create.isPending;\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n setFormError(null);\n if (!file) {\n setFormError(\n tr('relationships.detail.attachAssetModal.chooseFile', 'Choose a file to attach.'),\n 'asset-file'\n );\n return;\n }\n try {\n const { fileId, fileName } = await uploadFile(file);\n await create.mutateAsync({\n relationshipId,\n name: name.trim() || fileName,\n type,\n fileId,\n ...(expiresAt ? { expiresAt: new Date(expiresAt).toISOString() } : {}),\n });\n onClose();\n } catch (err) {\n setFormError(\n err instanceof Error\n ? err.message\n : tr('relationships.detail.attachAssetModal.error', 'Could not attach the asset.')\n );\n }\n };\n\n return (\n <Modal\n title={tr('relationships.detail.attachAssetModal.title', 'Attach asset')}\n onClose={onClose}\n >\n <form onSubmit={handleSubmit} className=\"space-y-4\">\n {formError && (\n <div\n id={formErrorId}\n tabIndex={-1}\n role=\"alert\"\n className=\"rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\"\n >\n {formError}\n </div>\n )}\n <div>\n <label htmlFor=\"asset-file\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.fileLabel', 'File')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n {...fieldErrorProps('asset-file')}\n id=\"asset-file\"\n type=\"file\"\n onChange={(e) => {\n const f = e.target.files?.[0] ?? null;\n setFile(f);\n if (f && !name.trim()) setName(f.name);\n }}\n className=\"w-full text-sm text-text-secondary file:me-3 file:rounded-lg file:border file:border-border-subtle file:bg-bg-surface file:px-3 file:py-1.5 file:text-sm file:font-medium file:text-text-primary hover:file:bg-bg-sunken\"\n />\n <p className=\"mt-1 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.attachAssetModal.fileHint',\n 'Stored securely in files — only a reference is kept here.'\n )}\n </p>\n </div>\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"asset-name\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.nameLabel', 'Name')}\n </label>\n <input\n {...fieldErrorProps('asset-name')}\n id=\"asset-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={tr(\n 'relationships.detail.attachAssetModal.namePlaceholder',\n 'Defaults to the file name'\n )}\n className={inputCls}\n />\n </div>\n <div>\n <label htmlFor=\"asset-type\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.typeLabel', 'Type')}\n </label>\n <select\n {...fieldErrorProps('asset-type')}\n id=\"asset-type\"\n value={type}\n onChange={(e) => setType(e.target.value as SubAssetType)}\n className={inputCls}\n >\n {ASSET_TYPES.map((t) => (\n <option key={t} value={t}>\n {t.replace(/_/g, ' ')}\n </option>\n ))}\n </select>\n </div>\n </div>\n <div>\n <label htmlFor=\"asset-expires\" className={labelCls}>\n {tr('relationships.detail.attachAssetModal.expiresOnLabel', 'Expires on')}\n </label>\n <input\n {...fieldErrorProps('asset-expires')}\n id=\"asset-expires\"\n type=\"date\"\n value={expiresAt}\n onChange={(e) => setExpiresAt(e.target.value)}\n className={inputCls}\n />\n </div>\n {isUploading && (\n <p className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.attachAssetModal.uploading', 'Uploading… {{progress}}%', {\n progress,\n })}\n </p>\n )}\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n {tr('relationships.detail.attachAssetModal.cancel', 'Cancel')}\n </button>\n <button\n type=\"submit\"\n disabled={busy}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90 disabled:opacity-50\"\n >\n {busy\n ? tr('relationships.detail.attachAssetModal.attaching', 'Attaching…')\n : tr('relationships.detail.attachAssetModal.submit', 'Attach asset')}\n </button>\n </div>\n </form>\n </Modal>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Asset row — resolves a presigned download URL on demand\n// ---------------------------------------------------------------------------\n\nfunction AssetRow({ asset }: { asset: NonNullable<SubRelationship['assets']>[number] }) {\n const { formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n const getDownloadUrl = useFileDownloadUrl();\n const [downloading, setDownloading] = useState(false);\n\n const handleDownload = async () => {\n if (!asset.file?.id) return;\n setDownloading(true);\n try {\n const url = await getDownloadUrl(asset.file.id);\n window.open(url, '_blank', 'noopener,noreferrer');\n } catch {\n // Non-fatal: a broken/expired file reference just can't be downloaded.\n } finally {\n setDownloading(false);\n }\n };\n\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <Paperclip className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{asset.name}</p>\n <p className=\"text-xs text-text-secondary\">{formatEnumLabel(asset.type)}</p>\n </div>\n </div>\n <div className=\"flex shrink-0 items-center gap-3\">\n {asset.expiresAt && (\n <span className=\"text-xs text-text-secondary\">\n {tr('relationships.detail.assetRow.expires', 'Expires {{date}}', {\n date: formatDate(asset.expiresAt),\n })}\n </span>\n )}\n {asset.file?.id && (\n <button\n type=\"button\"\n onClick={handleDownload}\n disabled={downloading}\n className=\"inline-flex items-center gap-1 rounded-lg border border-border-subtle px-2.5 py-1 text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Download className=\"h-3.5 w-3.5\" />{' '}\n {downloading\n ? tr('relationships.detail.assetRow.opening', 'Opening…')\n : tr('relationships.detail.assetRow.download', 'Download')}\n </button>\n )}\n </div>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Invoice row (BOFF-8659) — every invoice linked to this relationship via\n// `SubInvoice.relationshipId` is shown in the Assets section alongside any\n// file-based assets, so users don't have to leave the relationship page to\n// discover that they have an outstanding invoice tied to it.\n// ---------------------------------------------------------------------------\n\nfunction InvoiceRow({ invoice }: { invoice: SubInvoice }) {\n const { formatCurrency, formatDate, formatEnumLabel } = useFormatters();\n\n const tr = useTr();\n // Each invoice appears once, grouped by the (most-recent) due or issue\n // date and labelled with number · status, then a right-aligned total that\n // matches the Invoices list currency formatting.\n const label =\n invoice.number ?? tr('relationships.detail.invoiceRow.unnumbered', 'Unnumbered invoice');\n return (\n <div className=\"flex items-center justify-between gap-3 p-3\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <CreditCard className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <div className=\"min-w-0\">\n <p className=\"truncate text-sm font-medium text-text-primary\">{label}</p>\n <p className=\"text-xs text-text-secondary\">\n {formatEnumLabel(invoice.status)}\n {invoice.dueDate\n ? ` · ${tr('relationships.detail.invoiceRow.due', 'due {{date}}', {\n date: formatDate(invoice.dueDate),\n })}`\n : invoice.issueDate\n ? ` · ${formatDate(invoice.issueDate)}`\n : ''}\n </p>\n </div>\n </div>\n <span className=\"shrink-0 text-sm font-medium tabular-nums text-text-primary\">\n {formatCurrency(invoice.total, invoice.currency)}\n </span>\n </div>\n );\n}\n\nexport function RelationshipDetailPage() {\n const { formatCurrency, formatDate, formatEnumLabel, formatIntervalSuffix } = useFormatters();\n\n const tr = useTr();\n const { id } = useParams<{ id: string }>();\n const { navigateTo } = useSubscriberBot();\n const { data: relationship, isLoading, isError, refetch } = useRelationship(id);\n const transition = useTransitionRelationship();\n const cancel = useCancelRelationship();\n const [actionError, setActionError] = useState<string | null>(null);\n const [showEdit, setShowEdit] = useState(false);\n const [showAddEntitlement, setShowAddEntitlement] = useState(false);\n const [showAttachAsset, setShowAttachAsset] = useState(false);\n // Open AI recommendations about this subscription (BOFF-3663). Best effort:\n // if the decision engine is unavailable the section is simply omitted, and\n // every change it could propose stays available through the actions above.\n // Invoices linked through SubInvoice.relationshipId (BOFF-8659). The svc\n // exposes them through subListInvoices(relationshipId), not as a field on\n // SubRelationship, so they are read with their own query.\n const relationshipInvoices = useInvoices(\n { relationshipId: id, pagination: { limit: 50, offset: 0 } },\n { enabled: Boolean(id) }\n );\n const openDecisions = useDecisions(\n { relationshipId: id, status: 'PROPOSED' },\n { enabled: Boolean(id) }\n );\n\n if (isLoading) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <LoadingView label={tr('relationships.detail.loading', 'Loading relationship…')} />\n </PageLayout>\n );\n }\n\n if (isError) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <ErrorView\n message={tr('relationships.detail.error', 'Could not load this relationship.')}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n if (!relationship) {\n return (\n <PageLayout title={tr('relationships.title', 'Relationship')}>\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.notFoundTitle', 'Relationship not found')}\n description={tr(\n 'relationships.detail.notFoundDescription',\n 'It may have been removed, or you may not have access to it.'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\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('relationships.detail.backToRelationships', 'Back to relationships')}\n </button>\n }\n />\n </PageLayout>\n );\n }\n\n const r = relationship;\n const isBusy = transition.isPending || cancel.isPending;\n\n const runTransition = (status: SubRelationshipStatus) => {\n setActionError(null);\n transition.mutate(\n { id: r.id, status },\n {\n onError: (e) =>\n setActionError(\n e instanceof Error\n ? e.message\n : tr('relationships.detail.transitionError', 'Transition failed')\n ),\n }\n );\n };\n\n const runCancel = () => {\n setActionError(null);\n cancel.mutate(r.id, {\n onError: (e) =>\n setActionError(\n e instanceof Error ? e.message : tr('relationships.detail.cancelError', 'Cancel failed')\n ),\n });\n };\n\n // Renewal timeline — built entirely from the real renewalEvents, oldest → newest.\n const renewalTimeline: TimelineItem[] = [...(r.renewalEvents ?? [])]\n .sort((a, b) => new Date(a.occursAt).getTime() - new Date(b.occursAt).getTime())\n .map((event) => {\n const ts = new Date(event.occursAt).getTime();\n const isFuture = !Number.isNaN(ts) && ts > Date.now();\n return {\n title: formatEnumLabel(event.eventType),\n sub: `${formatDate(event.occursAt)}${event.detail ? ` · ${event.detail}` : ''}`,\n meta:\n event.amount != null\n ? formatCurrency(event.amount, event.currency ?? r.currency)\n : undefined,\n tone: isFuture ? 'warning' : 'muted',\n };\n });\n\n const autoRenewPill = r.autoRenew ? (\n <span className=\"inline-flex items-center rounded-full bg-status-success-bg-subtle px-2 py-0.5 text-xs font-medium text-status-success-text\">\n {tr('relationships.detail.autoRenewOn', 'On')}\n </span>\n ) : (\n <span className=\"inline-flex items-center rounded-full bg-bg-sunken px-2 py-0.5 text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.autoRenewOff', 'Off')}\n </span>\n );\n\n // Only offer transitions the svc state machine accepts from the current\n // status (a cancelled relationship no longer shows Activate / Pause).\n const availableTransitions = TRANSITIONS.filter((t) => canTransition(r.status, t.status));\n const planFeatures = r.plan?.features ?? [];\n\n return (\n <PageLayout\n title={r.label}\n description={r.provider?.name ?? tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setShowEdit(true)}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Pencil className=\"h-4 w-4\" /> {tr('relationships.detail.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n data-testid=\"negotiate-bill\"\n onClick={() =>\n navigateTo(`/negotiations/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Handshake className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.negotiate', 'Negotiate this bill')}\n </button>\n <button\n type=\"button\"\n data-testid=\"request-procurement\"\n onClick={() =>\n navigateTo(`/procurement/new?relationshipId=${encodeURIComponent(r.id)}`)\n }\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Briefcase className=\"h-4 w-4\" />{' '}\n {tr('relationships.detail.procurement', 'Ask an expert to negotiate')}\n </button>\n <button\n type=\"button\"\n onClick={() => navigateTo('/relationships')}\n className=\"inline-flex items-center gap-2 whitespace-nowrap rounded-lg border border-border-subtle px-3 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <ArrowLeft className=\"rtl:rotate-180 h-4 w-4\" />{' '}\n {tr('relationships.detail.back', 'Back')}\n </button>\n </div>\n }\n >\n {/* Hero summary + lifecycle actions */}\n <GlassCard treatment=\"glass\" glow className=\"p-5 sm:p-6\">\n <div className=\"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between\">\n <div className=\"min-w-0\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {tr(KIND_KEY[r.kind], formatEnumLabel(r.kind))}\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-3\">\n <span className=\"text-3xl font-bold tabular-nums text-text-primary\">\n {formatCurrency(r.amount, r.currency)}\n <span className=\"text-base font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </span>\n <StatusBadge status={r.status} />\n </div>\n <div className=\"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-text-secondary\">\n <span className=\"inline-flex items-center gap-1.5\">\n <CalendarClock className=\"h-3.5 w-3.5\" />\n {r.renewsAt\n ? tr('relationships.detail.renews', 'Renews {{date}}', {\n date: formatDate(r.renewsAt),\n })\n : tr('relationships.detail.noRenewalScheduled', 'No renewal scheduled')}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n <ShieldCheck className=\"h-3.5 w-3.5\" />\n {formatEnumLabel(r.discoverySource)}\n </span>\n <span className=\"inline-flex items-center gap-1.5\">\n {tr('relationships.detail.autoRenew', 'Auto-renew')} {autoRenewPill}\n </span>\n </div>\n {r.tags.length > 0 && (\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">\n <Tag className=\"h-3.5 w-3.5 text-text-secondary\" />\n {r.tags.map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n\n {/* Lifecycle actions */}\n <div className=\"grid shrink-0 grid-cols-2 gap-2 sm:flex sm:flex-wrap lg:flex-col lg:items-stretch\">\n {availableTransitions.map((t) => {\n const Icon = t.icon;\n return (\n <button\n key={t.status}\n type=\"button\"\n disabled={isBusy}\n onClick={() => runTransition(t.status)}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-border-subtle bg-bg-surface px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50\"\n >\n <Icon className=\"h-3.5 w-3.5\" /> {tr(t.labelKey, t.defaultLabel)}\n </button>\n );\n })}\n {canTransition(r.status, 'CANCELLED') && (\n <button\n type=\"button\"\n disabled={isBusy}\n onClick={runCancel}\n className=\"inline-flex min-h-11 items-center justify-center gap-1.5 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-3 py-1.5 text-sm sm:min-h-0 sm:text-xs font-medium text-status-error-text hover:opacity-90 disabled:opacity-50\"\n >\n <Ban className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.actions.cancel', 'Cancel')}\n </button>\n )}\n </div>\n </div>\n </GlassCard>\n\n {actionError && (\n <div className=\"mt-4 rounded-lg border border-status-error-text/30 bg-status-error-bg-subtle px-4 py-2 text-sm text-status-error-text\">\n {actionError}\n </div>\n )}\n\n {/* Main layout: details (left) + health & timeline rail (right) */}\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3\">\n <div className=\"space-y-4 lg:col-span-2\">\n <div className=\"grid grid-cols-1 gap-4 md:grid-cols-2\">\n {/* Plan & pricing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CreditCard className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.planPricing', 'Plan & pricing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.plan', 'Plan')}\n value={r.plan?.name ?? '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.price', 'Price')}\n value={\n <>\n {formatCurrency(r.amount, r.currency)}\n <span className=\"font-normal text-text-secondary\">\n {formatIntervalSuffix(r.interval)}\n </span>\n </>\n }\n />\n <InfoRow\n label={tr('relationships.detail.info.billingInterval', 'Billing interval')}\n value={formatEnumLabel(r.interval)}\n />\n <InfoRow\n label={tr('relationships.detail.info.provider', 'Provider')}\n value={r.provider?.name ?? '—'}\n />\n </div>\n {planFeatures.length > 0 && (\n <div className=\"mt-3 flex flex-wrap gap-1.5\">\n {planFeatures.map((f) => (\n <span\n key={f}\n className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n >\n {f}\n </span>\n ))}\n </div>\n )}\n </GlassCard>\n\n {/* Payment & billing */}\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Wallet className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.paymentBilling', 'Payment & billing')}\n </div>\n <div className=\"mt-3\">\n <InfoRow\n label={tr('relationships.detail.info.currency', 'Currency')}\n value={r.currency}\n />\n <InfoRow\n label={tr('relationships.detail.info.autoRenew', 'Auto-renew')}\n value={autoRenewPill}\n />\n <InfoRow\n label={tr('relationships.detail.info.nextRenewal', 'Next renewal')}\n value={r.renewsAt ? formatDate(r.renewsAt) : '—'}\n />\n <InfoRow\n label={tr('relationships.detail.info.started', 'Started')}\n value={r.startedAt ? formatDate(r.startedAt) : '—'}\n />\n {r.trialEndsAt && (\n <InfoRow\n label={tr('relationships.detail.info.trialEnds', 'Trial ends')}\n value={formatDate(r.trialEndsAt)}\n />\n )}\n </div>\n </GlassCard>\n </div>\n\n {/* Open AI recommendations for this subscription */}\n {(openDecisions.data?.items.length ?? 0) > 0 && (\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.aiRecommendations', 'AI recommendations')}\n description={tr(\n 'relationships.detail.sections.aiRecommendationsDescription',\n 'Open recommendations about this subscription. You can also make any of these changes by hand above.'\n )}\n >\n <AiDisclaimer className=\"mb-3\" />\n <div className=\"grid grid-cols-1 gap-3\" data-testid=\"relationship-decisions\">\n {openDecisions.data?.items.map((d) => (\n <DecisionCard key={d.id} decision={d} />\n ))}\n </div>\n </Section>\n )}\n\n {/* Entitlements */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.entitlements', 'Entitlements')}\n description={tr(\n 'relationships.detail.sections.entitlementsDescription',\n 'What this relationship grants you'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAddEntitlement(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.addEntitlement', 'Add entitlement')}\n </button>\n }\n >\n {!r.entitlements || r.entitlements.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noEntitlementsTitle', 'No entitlements')}\n description={tr(\n 'relationships.detail.empty.noEntitlementsDescription',\n 'Entitlements (seats, quotas, feature access) will appear here.'\n )}\n />\n ) : (\n <div className=\"grid grid-cols-1 gap-3 sm:grid-cols-2\">\n {r.entitlements.map((e) => {\n const hasQuota = e.quota != null && e.quota > 0;\n return (\n <GlassCard key={e.id} treatment=\"plain\" className=\"p-4\">\n <div className=\"flex items-start justify-between gap-2\">\n <p className=\"min-w-0 truncate text-sm font-medium text-text-primary\">\n {e.name}\n </p>\n <StatusBadge status={e.isActive ? 'ACTIVE' : 'DISABLED'} />\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">{formatEnumLabel(e.type)}</p>\n {hasQuota && (\n <div className=\"mt-3\">\n <div className=\"flex items-center justify-between text-xs text-text-secondary\">\n <span>\n {e.used} / {e.quota}\n {e.unit ? ` ${e.unit}` : ''}\n </span>\n <span className=\"tabular-nums\">\n {Math.round((e.used / (e.quota as number)) * 100)}%\n </span>\n </div>\n <MiniProgress\n label={tr('common.quotaUtilization', 'Quota utilization')}\n value={e.used}\n max={e.quota as number}\n tone={\n e.used / (e.quota as number) >= 0.9\n ? 'negative'\n : e.used / (e.quota as number) >= 0.7\n ? 'warning'\n : 'accent'\n }\n className=\"mt-1.5\"\n />\n </div>\n )}\n </GlassCard>\n );\n })}\n </div>\n )}\n </Section>\n\n {/* Assets — file-based assets + relationship-owned invoices.\n BOFF-8659: invoices linked via `SubInvoice.relationshipId` are now\n shown here too, so the panel copy \"Invoices, contracts, licenses\n and credentials\" is honored for the cross-module Relationships ↔\n Invoices flow. */}\n <Section\n className=\"mt-0\"\n title={tr('relationships.detail.sections.assets', 'Assets')}\n description={tr(\n 'relationships.detail.sections.assetsDescription',\n 'Invoices, contracts, licenses and credentials'\n )}\n action={\n <button\n type=\"button\"\n onClick={() => setShowAttachAsset(true)}\n className=\"inline-flex items-center gap-1.5 rounded-lg border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {tr('relationships.detail.sections.attachAsset', 'Attach asset')}\n </button>\n }\n >\n {(() => {\n const assets = r.assets ?? [];\n // BOFF-8659 — pull relationship-owned invoices into the same\n // Assets list, sorted next to file-based assets by their sort\n // time so invoices appear in the same order as the Invoices\n // list (newest first).\n const invoices: SubInvoice[] = relationshipInvoices.data?.items ?? [];\n const hasAny = assets.length > 0 || invoices.length > 0;\n if (!hasAny) {\n return (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('relationships.detail.empty.noAssetsTitle', 'No assets attached')}\n description={tr(\n 'relationships.detail.empty.noAssetsDescription',\n 'Attach invoices, contracts, licenses or receipts to this relationship.'\n )}\n />\n );\n }\n type AssetLike =\n | {\n kind: 'asset';\n sort: number;\n asset: NonNullable<SubRelationship['assets']>[number];\n }\n | {\n kind: 'invoice';\n sort: number;\n invoice: SubInvoice;\n };\n const combined: AssetLike[] = [\n ...assets.map((a) => ({\n kind: 'asset' as const,\n sort: new Date(a.createdAt).getTime() || 0,\n asset: a,\n })),\n ...invoices.map((i) => ({\n kind: 'invoice' as const,\n sort: new Date(i.createdAt).getTime() || 0,\n invoice: i,\n })),\n ].sort((x, y) => y.sort - x.sort);\n return (\n <GlassCard treatment=\"plain\" className=\"divide-y divide-border-subtle p-0\">\n {combined.map((row) =>\n row.kind === 'asset' ? (\n <AssetRow key={`a-${row.asset.id}`} asset={row.asset} />\n ) : (\n <InvoiceRow key={`i-${row.invoice.id}`} invoice={row.invoice} />\n )\n )}\n </GlassCard>\n );\n })()}\n </Section>\n\n {r.notes && (\n <GlassCard treatment=\"plain\" className=\"p-4\">\n <p className=\"text-xs font-medium text-text-secondary\">\n {tr('relationships.detail.sections.notes', 'Notes')}\n </p>\n <p className=\"mt-1 whitespace-pre-wrap text-sm text-text-primary\">{r.notes}</p>\n </GlassCard>\n )}\n </div>\n\n {/* Right rail: health gauge + renewal timeline */}\n <div className=\"space-y-4\">\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Activity className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.healthScore', 'Health score')}\n </div>\n {r.healthScore != null ? (\n <div className=\"mt-4 flex flex-col items-center\">\n <Gauge\n value={r.healthScore}\n max={100}\n size={160}\n label={tr('relationships.detail.outOf100', 'of 100')}\n />\n <div className=\"mt-2 w-full\">\n <MiniProgress\n label={tr('common.healthScore', 'Health score')}\n value={r.healthScore}\n max={100}\n tone={healthTone(r.healthScore)}\n />\n </div>\n <p\n className=\"mt-3 text-center text-xs text-text-secondary\"\n data-testid=\"health-score-basis\"\n >\n {tr(\n 'relationships.detail.healthScoreBasis',\n 'Computed from usage, payment history, price stability and overlap with your other subscriptions.'\n )}\n </p>\n </div>\n ) : (\n <p className=\"mt-4 text-sm text-text-secondary\">\n {tr(\n 'relationships.detail.empty.noHealthScore',\n 'Not scored yet. A health score appears once Subscriber Bot has enough signal.'\n )}\n </p>\n )}\n </GlassCard>\n\n <GlassCard treatment=\"metric\" className=\"p-5\">\n <div className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CalendarClock className=\"h-4 w-4 text-text-secondary\" />{' '}\n {tr('relationships.detail.sections.renewalTimeline', 'Renewal timeline')}\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {tr(\n 'relationships.detail.sections.renewalTimelineDescription',\n 'Detected renewals and price changes'\n )}\n </p>\n {renewalTimeline.length === 0 ? (\n <div className=\"mt-4\">\n <EmptyState\n illustration=\"empty-calendar\"\n title={tr('relationships.detail.empty.noRenewalEventsTitle', 'No renewal events')}\n description={tr(\n 'relationships.detail.empty.noRenewalEventsDescription',\n \"Renewals and price changes will appear here as they're detected.\"\n )}\n />\n </div>\n ) : (\n <Timeline items={renewalTimeline} className=\"mt-4\" />\n )}\n </GlassCard>\n </div>\n </div>\n\n {showEdit && <RelationshipEditModal relationship={r} onClose={() => setShowEdit(false)} />}\n {showAddEntitlement && (\n <AddEntitlementModal relationshipId={r.id} onClose={() => setShowAddEntitlement(false)} />\n )}\n {showAttachAsset && (\n <AttachAssetModal relationshipId={r.id} onClose={() => setShowAttachAsset(false)} />\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwEA,IAAM,IACJ,wMACI,IAAW,sDAEX,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA0C;CAC9C;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,IAA8B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAEM,KAAgD;CACpD,cAAc;CACd,YAAY;CACZ,SAAS;CACT,UAAU;CACV,YAAY;CACZ,mBAAmB;CACnB,YAAY;CACZ,OAAO;AACT,GAGM,KAKD;CACH;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;CACA;EACE,QAAQ;EACR,UAAU;EACV,cAAc;EACd,MAAM;CACR;AACF;AAGA,SAAS,EAAQ,EAAE,UAAO,YA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23
23
|
/** Total monthly recurring spend over the relationships that still bill. */
|
|
24
24
|
export declare function recurringSpend(relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]): RecurringSpend;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* Calendar days from today until `date`, in the viewer's local time zone:
|
|
27
|
+
* 0 is "today", 1 is "tomorrow", negative is overdue. Counting calendar days
|
|
28
|
+
* (not 24-hour blocks) matters for renewals stored at midnight UTC: one due
|
|
29
|
+
* tomorrow used to read "Renews today" for most of the day before
|
|
30
|
+
* (BOFF-4010). Null when the date is missing or unparseable.
|
|
30
31
|
*/
|
|
31
32
|
export declare function daysUntil(date: string | null | undefined, now?: number): number | null;
|
|
32
33
|
/** Translation key, English fallback and params for a renewal countdown. */
|
|
@@ -54,6 +55,8 @@ export interface UpcomingRenewal {
|
|
|
54
55
|
* stream is empty the list is derived from each relationship's own future
|
|
55
56
|
* `renewsAt`, so a freshly-tracked portfolio still shows what renews next.
|
|
56
57
|
* `fallbackTitle` names an event whose relationship is not in the page.
|
|
58
|
+
* Relationships that no longer renew (cancelled, expired, lapsed, paused) are
|
|
59
|
+
* left out of both sources.
|
|
57
60
|
*/
|
|
58
61
|
export declare function buildUpcomingRenewals(relationships: readonly SubRelationship[], events: readonly SubRenewalEvent[], fallbackTitle: (eventType: string) => string, now?: number): UpcomingRenewal[];
|
|
59
62
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/utils/portfolio.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,UAAU,QAAsB,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,gBAAgB,IAAI,CAAC;A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AqB,GAAG,WAAW,EAAE,CAgB5E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAGrF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE3E"}
|
|
@@ -8,26 +8,32 @@ var e = 1e3 * 60 * 60 * 24, t = {
|
|
|
8
8
|
LIFETIME: 0,
|
|
9
9
|
FREE: 0,
|
|
10
10
|
USAGE_BASED: 1
|
|
11
|
-
}, n = new Set([
|
|
12
|
-
|
|
11
|
+
}, n = new Set([
|
|
12
|
+
"ACTIVE",
|
|
13
|
+
"TRIAL",
|
|
14
|
+
"PAST_DUE"
|
|
15
|
+
]), r = new Set(["ACTIVE", "TRIAL"]);
|
|
16
|
+
function i(e) {
|
|
13
17
|
return e.amount * (t[e.interval] ?? 1);
|
|
14
18
|
}
|
|
15
|
-
function
|
|
16
|
-
let t = e.filter((e) =>
|
|
19
|
+
function a(e) {
|
|
20
|
+
let t = e.filter((e) => r.has(e.status));
|
|
17
21
|
return {
|
|
18
|
-
monthly: t.reduce((e, t) => e +
|
|
22
|
+
monthly: t.reduce((e, t) => e + i(t), 0),
|
|
19
23
|
currency: t[0]?.currency ?? e[0]?.currency ?? "USD",
|
|
20
24
|
activeCount: t.length
|
|
21
25
|
};
|
|
22
26
|
}
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
function o(e, t = Date.now()) {
|
|
28
|
+
if (!e) return null;
|
|
29
|
+
let n = new Date(e).getTime();
|
|
30
|
+
return Number.isNaN(n) ? null : s(n) - s(t);
|
|
31
|
+
}
|
|
32
|
+
function s(t) {
|
|
33
|
+
let n = new Date(t);
|
|
34
|
+
return Math.round(Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()) / e);
|
|
29
35
|
}
|
|
30
|
-
function
|
|
36
|
+
function c(e) {
|
|
31
37
|
return e < 0 ? {
|
|
32
38
|
key: "mobile.renewal.overdue",
|
|
33
39
|
fallback: "Renewal overdue",
|
|
@@ -47,27 +53,30 @@ function o(e) {
|
|
|
47
53
|
tone: e <= 7 ? "soon" : "later"
|
|
48
54
|
};
|
|
49
55
|
}
|
|
50
|
-
function
|
|
51
|
-
let
|
|
52
|
-
t.forEach((e) =>
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
function l(t, r, i, a = Date.now()) {
|
|
57
|
+
let o = /* @__PURE__ */ new Map();
|
|
58
|
+
t.forEach((e) => o.set(e.id, e));
|
|
59
|
+
let s = a + 7 * e, c = (e) => new Date(e).getTime(), l = (e) => {
|
|
60
|
+
let t = o.get(e);
|
|
61
|
+
return !t || n.has(t.status);
|
|
62
|
+
};
|
|
63
|
+
return r.length > 0 ? r.filter((e) => !Number.isNaN(c(e.occursAt)) && l(e.relationshipId)).map((e) => {
|
|
64
|
+
let t = o.get(e.relationshipId);
|
|
56
65
|
return {
|
|
57
66
|
id: e.id,
|
|
58
67
|
relationshipId: e.relationshipId,
|
|
59
|
-
title: t?.label ??
|
|
68
|
+
title: t?.label ?? i(e.eventType),
|
|
60
69
|
when: e.occursAt,
|
|
61
70
|
amount: e.amount ?? t?.amount ?? null,
|
|
62
71
|
currency: e.currency ?? t?.currency ?? null,
|
|
63
72
|
interval: t?.interval ?? null,
|
|
64
73
|
kind: t?.kind ?? null,
|
|
65
|
-
soon:
|
|
74
|
+
soon: c(e.occursAt) <= s
|
|
66
75
|
};
|
|
67
|
-
}).sort((e, t) =>
|
|
68
|
-
if (!e.renewsAt) return !1;
|
|
69
|
-
let t =
|
|
70
|
-
return !Number.isNaN(t) && t >=
|
|
76
|
+
}).sort((e, t) => c(e.when) - c(t.when)) : t.filter((e) => {
|
|
77
|
+
if (!e.renewsAt || !n.has(e.status)) return !1;
|
|
78
|
+
let t = c(e.renewsAt);
|
|
79
|
+
return !Number.isNaN(t) && t >= a;
|
|
71
80
|
}).map((e) => {
|
|
72
81
|
let t = e.renewsAt;
|
|
73
82
|
return {
|
|
@@ -79,11 +88,11 @@ function s(t, n, r, i = Date.now()) {
|
|
|
79
88
|
currency: e.currency,
|
|
80
89
|
interval: e.interval,
|
|
81
90
|
kind: e.kind,
|
|
82
|
-
soon:
|
|
91
|
+
soon: c(t) <= s
|
|
83
92
|
};
|
|
84
|
-
}).sort((e, t) =>
|
|
93
|
+
}).sort((e, t) => c(e.when) - c(t.when));
|
|
85
94
|
}
|
|
86
|
-
var
|
|
95
|
+
var u = {
|
|
87
96
|
TRIAL: [
|
|
88
97
|
"ACTIVE",
|
|
89
98
|
"CANCELLED",
|
|
@@ -113,39 +122,39 @@ var c = {
|
|
|
113
122
|
CANCELLED: [],
|
|
114
123
|
EXPIRED: []
|
|
115
124
|
};
|
|
116
|
-
function
|
|
117
|
-
return
|
|
125
|
+
function d(e, t) {
|
|
126
|
+
return u[e]?.includes(t) ?? !1;
|
|
118
127
|
}
|
|
119
|
-
function
|
|
128
|
+
function f(e) {
|
|
120
129
|
let t = [];
|
|
121
|
-
return
|
|
130
|
+
return d(e, "ACTIVE") && t.push({
|
|
122
131
|
id: e === "TRIAL" ? "activate" : "resume",
|
|
123
132
|
target: "ACTIVE",
|
|
124
133
|
destructive: !1
|
|
125
|
-
}),
|
|
134
|
+
}), d(e, "PAUSED") && t.push({
|
|
126
135
|
id: "pause",
|
|
127
136
|
target: "PAUSED",
|
|
128
137
|
destructive: !1
|
|
129
|
-
}),
|
|
138
|
+
}), d(e, "CANCELLED") && t.push({
|
|
130
139
|
id: "cancel",
|
|
131
140
|
target: "CANCELLED",
|
|
132
141
|
destructive: !0
|
|
133
142
|
}), t;
|
|
134
143
|
}
|
|
135
|
-
function
|
|
144
|
+
function p(e, t, n) {
|
|
136
145
|
let r = t ? -n : 0;
|
|
137
146
|
return Math.min(0, Math.max(-n, r + e));
|
|
138
147
|
}
|
|
139
|
-
function
|
|
148
|
+
function m(e, t) {
|
|
140
149
|
return t > 0 && -e >= t / 2;
|
|
141
150
|
}
|
|
142
|
-
function
|
|
151
|
+
function h(e) {
|
|
143
152
|
return e + 400;
|
|
144
153
|
}
|
|
145
|
-
function
|
|
154
|
+
function g(e, t) {
|
|
146
155
|
return e <= t;
|
|
147
156
|
}
|
|
148
157
|
//#endregion
|
|
149
|
-
export {
|
|
158
|
+
export { l as buildUpcomingRenewals, d as canTransition, o as daysUntil, g as isSwipeTrailingClick, f as quickActionsFor, a as recurringSpend, c as renewalCountdown, h as swipeClickDeadline, p as swipeOffset, m as swipeSettlesOpen };
|
|
150
159
|
|
|
151
160
|
//# sourceMappingURL=portfolio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portfolio.js","names":[],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const 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/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Whole days from `now` until `date`: anything less than 24 hours away reads\n * as 0 (\"today\"), 24–48 hours as 1, and so on. Negative (whole days, rounded\n * away from zero) when the date has passed; null when it is missing or\n * unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n const diff = t - now;\n if (diff < 0) return -Math.ceil(-diff / MS_PER_DAY);\n return Math.floor(diff / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. Real renewal events win; when the event\n * stream is empty the list is derived from each relationship's own future\n * `renewsAt`, so a freshly-tracked portfolio still shows what renews next.\n * `fallbackTitle` names an event whose relationship is not in the page.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n if (events.length > 0) {\n return events\n .filter((e) => !Number.isNaN(time(e.occursAt)))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n }\n\n return relationships\n .filter((r) => {\n if (!r.renewsAt) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAa,IAAa,MAAO,KAAK,KAAK,IAW9B,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAGM,IAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgB,EAAc,GAAoE;CAChG,OAA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gB,EAAgB,GAA8C;CAC5E,IAAM,IAAyB,CAAC;CAchC,OAbI,EAAc,GAAQ,QAAQ,KAChC,EAAQ,KAAK;EACX,IAAI,MAAW,UAAU,aAAa;EACtC,QAAQ;EACR,aAAa;CACf,CAAC,GAEC,EAAc,GAAQ,QAAQ,KAChC,EAAQ,KAAK;EAAE,IAAI;EAAS,QAAQ;EAAU,aAAa;CAAM,CAAC,GAEhE,EAAc,GAAQ,WAAW,KACnC,EAAQ,KAAK;EAAE,IAAI;EAAU,QAAQ;EAAa,aAAa;CAAK,CAAC,GAEhE;AACT;AAOA,SAAgB,EAAY,GAAY,GAAkB,GAA6B;CACrF,IAAM,IAAO,IAAU,CAAC,IAAc;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,GAAa,IAAO,CAAE,CAAC;AACtD;AAMA,SAAgB,EAAiB,GAAgB,GAA8B;CAC7E,OAAO,IAAc,KAAK,CAAC,KAAU,IAAc;AACrD;AAYA,SAAgB,EAAmB,GAAyB;CAC1D,OAAO,IAAA;AACT;AAGA,SAAgB,EAAqB,GAAa,GAA2B;CAC3E,OAAO,KAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"portfolio.js","names":[],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const 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/**\n * Statuses that still renew. A cancelled, expired, lapsed or paused\n * relationship has no upcoming charge, even if it keeps an old `renewsAt`\n * or the renewal stream still holds an event for it.\n */\nconst RENEWING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n 'PAST_DUE',\n]);\n\n/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Calendar days from today until `date`, in the viewer's local time zone:\n * 0 is \"today\", 1 is \"tomorrow\", negative is overdue. Counting calendar days\n * (not 24-hour blocks) matters for renewals stored at midnight UTC: one due\n * tomorrow used to read \"Renews today\" for most of the day before\n * (BOFF-4010). Null when the date is missing or unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n return calendarDay(t) - calendarDay(now);\n}\n\n/**\n * The local calendar date of `ms` as a whole-day ordinal. Local Y/M/D are\n * re-read as a UTC date so daylight-saving shifts never leave a fraction.\n */\nfunction calendarDay(ms: number): number {\n const d = new Date(ms);\n return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. Real renewal events win; when the event\n * stream is empty the list is derived from each relationship's own future\n * `renewsAt`, so a freshly-tracked portfolio still shows what renews next.\n * `fallbackTitle` names an event whose relationship is not in the page.\n * Relationships that no longer renew (cancelled, expired, lapsed, paused) are\n * left out of both sources.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n // An event whose relationship is not in the page is kept: its status is\n // unknown here, and the renewal stream is the better source.\n const renews = (relationshipId: string) => {\n const rel = byId.get(relationshipId);\n return !rel || RENEWING_STATUSES.has(rel.status);\n };\n\n if (events.length > 0) {\n return events\n .filter((e) => !Number.isNaN(time(e.occursAt)) && renews(e.relationshipId))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n }\n\n return relationships\n .filter((r) => {\n if (!r.renewsAt || !RENEWING_STATUSES.has(r.status)) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n })\n .sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAa,IAAa,MAAO,KAAK,KAAK,IAW9B,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAOM,IAAwD,IAAI,IAA2B;CAC3F;CACA;CACA;AACF,CAAC,GAGK,IAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgB,EAAc,GAAoE;CAChG,OAAO,EAAa,UAAU,EAAe,EAAa,aAAa;AACzE;AAYA,SAAgB,EACd,GACgB;CAChB,IAAM,IAAS,EAAc,QAAQ,MAAM,EAAiB,IAAI,EAAE,MAAM,CAAC;CACzE,OAAO;EACL,SAAS,EAAO,QAAQ,GAAK,MAAM,IAAM,EAAc,CAAC,GAAG,CAAC;EAC5D,UAAU,EAAO,IAAI,YAAY,EAAc,IAAI,YAAY;EAC/D,aAAa,EAAO;CACtB;AACF;AASA,SAAgB,EACd,GACA,IAAc,KAAK,IAAI,GACR;CACf,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAI,IAAI,KAAK,CAAI,EAAE,QAAQ;CAEjC,OADI,OAAO,MAAM,CAAC,IAAU,OACrB,EAAY,CAAC,IAAI,EAAY,CAAG;AACzC;AAMA,SAAS,EAAY,GAAoB;CACvC,IAAM,IAAI,IAAI,KAAK,CAAE;CACrB,OAAO,KAAK,MAAM,KA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