@burdenoff/microfe-subscriberbot 2026.1107.3 → 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.
@@ -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;EAC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AE3E;;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,YAA8C;CACtE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@module subscriberbot/utils/chartScale
4
+ *
5
+ * Splitting a raw [min, max] range into equal parts gives ticks such as
6
+ * 9.7 / 10.47 / 11.23 / 12.3. Rounded for display those read "$10, $11, $11,
7
+ * $12": two labels repeat and none sits where its value is. `niceScale` widens
8
+ * the range to whole multiples of a round step (1, 2, 2.5 or 5 x 10^k), so
9
+ * every tick is an exact, distinct, readable value, and reports how many
10
+ * fraction digits a label needs to show it.
11
+ */
12
+ export interface NiceScale {
13
+ /** Lower bound of the axis (the first tick). */
14
+ min: number;
15
+ /** Upper bound of the axis (the last tick). */
16
+ max: number;
17
+ /** Distance between neighbouring ticks. */
18
+ step: number;
19
+ /** Tick values from `min` to `max`, inclusive. */
20
+ ticks: number[];
21
+ /** Fraction digits needed to print every tick distinctly (0 to 10). */
22
+ fractionDigits: number;
23
+ }
24
+ /**
25
+ * Build a nice axis covering [lo, hi] with about `targetTicks` ticks.
26
+ *
27
+ * - The axis never starts below zero when `lo` is not negative.
28
+ * - A flat range (lo === hi) is widened around the value so it sits mid-axis.
29
+ * - Non-finite input falls back to a 0..1 axis.
30
+ */
31
+ export declare function niceScale(lo: number, hi: number, targetTicks?: number): NiceScale;
32
+ //# sourceMappingURL=chartScale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartScale.d.ts","sourceRoot":"","sources":["../../../src/subscriberbot/utils/chartScale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,SAAS;IACxB,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,uEAAuE;IACvE,cAAc,EAAE,MAAM,CAAC;CACxB;AA2BD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,SAAI,GAAG,SAAS,CA4B5E"}
@@ -0,0 +1,45 @@
1
+ //#region src/subscriberbot/utils/chartScale.ts
2
+ var e = [
3
+ 1,
4
+ 2,
5
+ 2.5,
6
+ 5,
7
+ 10
8
+ ];
9
+ function t(e) {
10
+ return Number.parseFloat(e.toPrecision(12));
11
+ }
12
+ function n(t) {
13
+ let n = 10 ** Math.floor(Math.log10(t)), r = t / n;
14
+ return (e.find((e) => r <= e) ?? 10) * n;
15
+ }
16
+ var r = 10;
17
+ function i(e) {
18
+ for (let t = 0; t < r; t++) {
19
+ let n = e * 10 ** t;
20
+ if (Math.abs(Math.round(n) - n) < 1e-9 * Math.max(1, n)) return t;
21
+ }
22
+ return r;
23
+ }
24
+ function a(e, r, a = 4) {
25
+ let o = Number.isFinite(e) ? e : 0, s = Number.isFinite(r) ? r : o + 1;
26
+ if (o > s && ([o, s] = [s, o]), o === s) {
27
+ let t = Math.max(Math.abs(o) * .2, 1);
28
+ o -= t, s += t, e >= 0 && (o = Math.max(0, o));
29
+ }
30
+ let c = Math.max(1, Math.round(a) - 1), l = n((s - o) / c), u = Math.floor(o / l) * l, d = Math.ceil(s / l) * l;
31
+ (d - u) / l > c + 2 && (l = n((d - u) / c), u = Math.floor(o / l) * l, d = Math.ceil(s / l) * l), e >= 0 && u < 0 && (u = 0), u = t(u), d = t(d), l = t(l);
32
+ let f = [], p = Math.round((d - u) / l);
33
+ for (let e = 0; e <= p; e++) f.push(t(u + e * l));
34
+ return {
35
+ min: u,
36
+ max: d,
37
+ step: l,
38
+ ticks: f,
39
+ fractionDigits: i(l)
40
+ };
41
+ }
42
+ //#endregion
43
+ export { a as niceScale };
44
+
45
+ //# sourceMappingURL=chartScale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chartScale.js","names":[],"sources":["../../../src/subscriberbot/utils/chartScale.ts"],"sourcesContent":["/**\n * \"Nice\" value axes for charts.\n * @module subscriberbot/utils/chartScale\n *\n * Splitting a raw [min, max] range into equal parts gives ticks such as\n * 9.7 / 10.47 / 11.23 / 12.3. Rounded for display those read \"$10, $11, $11,\n * $12\": two labels repeat and none sits where its value is. `niceScale` widens\n * the range to whole multiples of a round step (1, 2, 2.5 or 5 x 10^k), so\n * every tick is an exact, distinct, readable value, and reports how many\n * fraction digits a label needs to show it.\n */\n\nexport interface NiceScale {\n /** Lower bound of the axis (the first tick). */\n min: number;\n /** Upper bound of the axis (the last tick). */\n max: number;\n /** Distance between neighbouring ticks. */\n step: number;\n /** Tick values from `min` to `max`, inclusive. */\n ticks: number[];\n /** Fraction digits needed to print every tick distinctly (0 to 10). */\n fractionDigits: number;\n}\n\nconst NICE_STEPS = [1, 2, 2.5, 5, 10];\n\n/** Round away floating-point noise such as 0.30000000000000004. */\nfunction clean(n: number): number {\n return Number.parseFloat(n.toPrecision(12));\n}\n\nfunction niceStep(rough: number): number {\n const magnitude = 10 ** Math.floor(Math.log10(rough));\n const residual = rough / magnitude;\n const factor = NICE_STEPS.find((s) => residual <= s) ?? 10;\n return factor * magnitude;\n}\n\n/** Most digits a label can need; well inside Intl's 0-20 fraction digit range. */\nconst MAX_FRACTION_DIGITS = 10;\n\nfunction digitsFor(step: number): number {\n for (let d = 0; d < MAX_FRACTION_DIGITS; d++) {\n const scaled = step * 10 ** d;\n if (Math.abs(Math.round(scaled) - scaled) < 1e-9 * Math.max(1, scaled)) return d;\n }\n return MAX_FRACTION_DIGITS;\n}\n\n/**\n * Build a nice axis covering [lo, hi] with about `targetTicks` ticks.\n *\n * - The axis never starts below zero when `lo` is not negative.\n * - A flat range (lo === hi) is widened around the value so it sits mid-axis.\n * - Non-finite input falls back to a 0..1 axis.\n */\nexport function niceScale(lo: number, hi: number, targetTicks = 4): NiceScale {\n let a = Number.isFinite(lo) ? lo : 0;\n let b = Number.isFinite(hi) ? hi : a + 1;\n if (a > b) [a, b] = [b, a];\n if (a === b) {\n const pad = Math.max(Math.abs(a) * 0.2, 1);\n a -= pad;\n b += pad;\n if (lo >= 0) a = Math.max(0, a);\n }\n const intervals = Math.max(1, Math.round(targetTicks) - 1);\n let step = niceStep((b - a) / intervals);\n let min = Math.floor(a / step) * step;\n let max = Math.ceil(b / step) * step;\n // A coarse step can leave many more ticks than asked for; widen once.\n if ((max - min) / step > intervals + 2) {\n step = niceStep((max - min) / intervals);\n min = Math.floor(a / step) * step;\n max = Math.ceil(b / step) * step;\n }\n if (lo >= 0 && min < 0) min = 0;\n min = clean(min);\n max = clean(max);\n step = clean(step);\n const ticks: number[] = [];\n const count = Math.round((max - min) / step);\n for (let i = 0; i <= count; i++) ticks.push(clean(min + i * step));\n return { min, max, step, ticks, fractionDigits: digitsFor(step) };\n}\n"],"mappings":";AAyBA,IAAM,IAAa;CAAC;CAAG;CAAG;CAAK;CAAG;AAAE;AAGpC,SAAS,EAAM,GAAmB;CAChC,OAAO,OAAO,WAAW,EAAE,YAAY,EAAE,CAAC;AAC5C;AAEA,SAAS,EAAS,GAAuB;CACvC,IAAM,IAAY,MAAM,KAAK,MAAM,KAAK,MAAM,CAAK,CAAC,GAC9C,IAAW,IAAQ;CAEzB,QADe,EAAW,MAAM,MAAM,KAAY,CAAC,KAAK,MACxC;AAClB;AAGA,IAAM,IAAsB;AAE5B,SAAS,EAAU,GAAsB;CACvC,KAAK,IAAI,IAAI,GAAG,IAAI,GAAqB,KAAK;EAC5C,IAAM,IAAS,IAAO,MAAM;EAC5B,IAAI,KAAK,IAAI,KAAK,MAAM,CAAM,IAAI,CAAM,IAAI,OAAO,KAAK,IAAI,GAAG,CAAM,GAAG,OAAO;CACjF;CACA,OAAO;AACT;AASA,SAAgB,EAAU,GAAY,GAAY,IAAc,GAAc;CAC5E,IAAI,IAAI,OAAO,SAAS,CAAE,IAAI,IAAK,GAC/B,IAAI,OAAO,SAAS,CAAE,IAAI,IAAK,IAAI;CAEvC,IADI,IAAI,MAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IACrB,MAAM,GAAG;EACX,IAAM,IAAM,KAAK,IAAI,KAAK,IAAI,CAAC,IAAI,IAAK,CAAC;EAGzC,AAFA,KAAK,GACL,KAAK,GACD,KAAM,MAAG,IAAI,KAAK,IAAI,GAAG,CAAC;CAChC;CACA,IAAM,IAAY,KAAK,IAAI,GAAG,KAAK,MAAM,CAAW,IAAI,CAAC,GACrD,IAAO,GAAU,IAAI,KAAK,CAAS,GACnC,IAAM,KAAK,MAAM,IAAI,CAAI,IAAI,GAC7B,IAAM,KAAK,KAAK,IAAI,CAAI,IAAI;CAUhC,CARK,IAAM,KAAO,IAAO,IAAY,MACnC,IAAO,GAAU,IAAM,KAAO,CAAS,GACvC,IAAM,KAAK,MAAM,IAAI,CAAI,IAAI,GAC7B,IAAM,KAAK,KAAK,IAAI,CAAI,IAAI,IAE1B,KAAM,KAAK,IAAM,MAAG,IAAM,IAC9B,IAAM,EAAM,CAAG,GACf,IAAM,EAAM,CAAG,GACf,IAAO,EAAM,CAAI;CACjB,IAAM,IAAkB,CAAC,GACnB,IAAQ,KAAK,OAAO,IAAM,KAAO,CAAI;CAC3C,KAAK,IAAI,IAAI,GAAG,KAAK,GAAO,KAAK,EAAM,KAAK,EAAM,IAAM,IAAI,CAAI,CAAC;CACjE,OAAO;EAAE;EAAK;EAAK;EAAM;EAAO,gBAAgB,EAAU,CAAI;CAAE;AAClE"}
@@ -23,10 +23,11 @@ export interface RecurringSpend {
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
- * Whole days from `now` until `date`: anything less than 24 hours away reads
27
- * as 0 ("today"), 24–48 hours as 1, and so on. Negative (whole days, rounded
28
- * away from zero) when the date has passed; null when it is missing or
29
- * unparseable.
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;AAElC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAS7D,CAAC;AAQF,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,CAAC,GAAG,MAAM,CAEhG;AAED,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG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