@burdenoff/microfe-subscriberbot 2026.1107.8 → 2026.1110.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/node_modules/clsx/dist/clsx.js +8 -7
  2. package/dist/node_modules/clsx/dist/clsx.js.map +1 -1
  3. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +134 -151
  4. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
  5. package/dist/subscriberbot/SubscriberBotRoot.js +10 -7
  6. package/dist/subscriberbot/SubscriberBotRoot.js.map +1 -1
  7. package/dist/subscriberbot/SubscriberBotRoutes.js +1 -2
  8. package/dist/subscriberbot/SubscriberBotRoutes.js.map +1 -1
  9. package/dist/subscriberbot/admin/AdminDashboardPage.js +9 -10
  10. package/dist/subscriberbot/admin/AdminDashboardPage.js.map +1 -1
  11. package/dist/subscriberbot/admin/AdminRoot.js +2 -3
  12. package/dist/subscriberbot/admin/AdminRoot.js.map +1 -1
  13. package/dist/subscriberbot/admin/NegotiationDeskPanel.js +56 -57
  14. package/dist/subscriberbot/admin/NegotiationDeskPanel.js.map +1 -1
  15. package/dist/subscriberbot/admin/ProcurementDeskPanel.js +107 -108
  16. package/dist/subscriberbot/admin/ProcurementDeskPanel.js.map +1 -1
  17. package/dist/subscriberbot/admin/index.js +1 -1
  18. package/dist/subscriberbot/components/EmptyState.js +1 -2
  19. package/dist/subscriberbot/components/EmptyState.js.map +1 -1
  20. package/dist/subscriberbot/components/MetricsCard.js +1 -2
  21. package/dist/subscriberbot/components/MetricsCard.js.map +1 -1
  22. package/dist/subscriberbot/components/Modal.js +2 -3
  23. package/dist/subscriberbot/components/Modal.js.map +1 -1
  24. package/dist/subscriberbot/components/PageLayout.js +1 -2
  25. package/dist/subscriberbot/components/PageLayout.js.map +1 -1
  26. package/dist/subscriberbot/components/PostureOptions.js +7 -8
  27. package/dist/subscriberbot/components/PostureOptions.js.map +1 -1
  28. package/dist/subscriberbot/components/StateViews.js +1 -2
  29. package/dist/subscriberbot/components/StateViews.js.map +1 -1
  30. package/dist/subscriberbot/components/StatusBadge.js +2 -3
  31. package/dist/subscriberbot/components/StatusBadge.js.map +1 -1
  32. package/dist/subscriberbot/components/decisions/DecisionBanners.js +7 -8
  33. package/dist/subscriberbot/components/decisions/DecisionBanners.js.map +1 -1
  34. package/dist/subscriberbot/components/decisions/DecisionCard.js +65 -66
  35. package/dist/subscriberbot/components/decisions/DecisionCard.js.map +1 -1
  36. package/dist/subscriberbot/components/decisions/decisionModel.js +2 -3
  37. package/dist/subscriberbot/components/decisions/decisionModel.js.map +1 -1
  38. package/dist/subscriberbot/components/decisions/index.js +4 -3
  39. package/dist/subscriberbot/components/index.js +8 -7
  40. package/dist/subscriberbot/components/mobile/MobileDashboard.js +23 -24
  41. package/dist/subscriberbot/components/mobile/MobileDashboard.js.map +1 -1
  42. package/dist/subscriberbot/components/mobile/MobileRelationshipList.js +40 -49
  43. package/dist/subscriberbot/components/mobile/MobileRelationshipList.js.map +1 -1
  44. package/dist/subscriberbot/components/mobile/MobileScreen.js +1 -2
  45. package/dist/subscriberbot/components/mobile/MobileScreen.js.map +1 -1
  46. package/dist/subscriberbot/components/mobile/RelationshipGlyph.js +1 -2
  47. package/dist/subscriberbot/components/mobile/RelationshipGlyph.js.map +1 -1
  48. package/dist/subscriberbot/components/mobile/index.js +4 -3
  49. package/dist/subscriberbot/components/negotiations/NegotiationStatusPill.js +1 -2
  50. package/dist/subscriberbot/components/negotiations/NegotiationStatusPill.js.map +1 -1
  51. package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js +4 -5
  52. package/dist/subscriberbot/components/negotiations/NegotiationTimeline.js.map +1 -1
  53. package/dist/subscriberbot/components/negotiations/OutcomeForm.js +4 -5
  54. package/dist/subscriberbot/components/negotiations/OutcomeForm.js.map +1 -1
  55. package/dist/subscriberbot/components/negotiations/index.js +5 -4
  56. package/dist/subscriberbot/components/negotiations/labels.js +1 -2
  57. package/dist/subscriberbot/components/negotiations/labels.js.map +1 -1
  58. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js +4 -5
  59. package/dist/subscriberbot/components/procurement/ProcurementOutcomeForm.js.map +1 -1
  60. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js +1 -2
  61. package/dist/subscriberbot/components/procurement/ProcurementStatusPill.js.map +1 -1
  62. package/dist/subscriberbot/components/procurement/ProcurementThread.js +4 -5
  63. package/dist/subscriberbot/components/procurement/ProcurementThread.js.map +1 -1
  64. package/dist/subscriberbot/components/procurement/index.js +5 -4
  65. package/dist/subscriberbot/components/procurement/labels.js +1 -2
  66. package/dist/subscriberbot/components/procurement/labels.js.map +1 -1
  67. package/dist/subscriberbot/components/savings/SavingsCards.js +90 -91
  68. package/dist/subscriberbot/components/savings/SavingsCards.js.map +1 -1
  69. package/dist/subscriberbot/components/savings/index.js +3 -2
  70. package/dist/subscriberbot/components/savings/savingsModel.js +2 -3
  71. package/dist/subscriberbot/components/savings/savingsModel.js.map +1 -1
  72. package/dist/subscriberbot/components/viz.js +2 -3
  73. package/dist/subscriberbot/components/viz.js.map +1 -1
  74. package/dist/subscriberbot/context/SubscriberBotContext.js +3 -3
  75. package/dist/subscriberbot/context/SubscriberBotContext.js.map +1 -1
  76. package/dist/subscriberbot/context/index.js +1 -1
  77. package/dist/subscriberbot/hooks/index.js +2 -2
  78. package/dist/subscriberbot/hooks/useAutonomousAgentMode.js +2 -3
  79. package/dist/subscriberbot/hooks/useAutonomousAgentMode.js.map +1 -1
  80. package/dist/subscriberbot/hooks/useBankingApi.js +2 -3
  81. package/dist/subscriberbot/hooks/useBankingApi.js.map +1 -1
  82. package/dist/subscriberbot/hooks/useCompactViewport.js +1 -2
  83. package/dist/subscriberbot/hooks/useCompactViewport.js.map +1 -1
  84. package/dist/subscriberbot/hooks/useFormError.js +1 -2
  85. package/dist/subscriberbot/hooks/useFormError.js.map +1 -1
  86. package/dist/subscriberbot/hooks/useFormatters.js +1 -2
  87. package/dist/subscriberbot/hooks/useFormatters.js.map +1 -1
  88. package/dist/subscriberbot/hooks/useNegotiationApi.js +2 -3
  89. package/dist/subscriberbot/hooks/useNegotiationApi.js.map +1 -1
  90. package/dist/subscriberbot/hooks/useProcurementApi.js +2 -3
  91. package/dist/subscriberbot/hooks/useProcurementApi.js.map +1 -1
  92. package/dist/subscriberbot/hooks/useRouteSelection.js +3 -3
  93. package/dist/subscriberbot/hooks/useRouteSelection.js.map +1 -1
  94. package/dist/subscriberbot/hooks/useSubscriberBotApi.js +1 -2
  95. package/dist/subscriberbot/hooks/useSubscriberBotApi.js.map +1 -1
  96. package/dist/subscriberbot/hooks/useTr.js +1 -2
  97. package/dist/subscriberbot/hooks/useTr.js.map +1 -1
  98. package/dist/subscriberbot/index.js +9 -8
  99. package/dist/subscriberbot/pages/AssetVaultPage.js +34 -35
  100. package/dist/subscriberbot/pages/AssetVaultPage.js.map +1 -1
  101. package/dist/subscriberbot/pages/DashboardPage.js +86 -87
  102. package/dist/subscriberbot/pages/DashboardPage.js.map +1 -1
  103. package/dist/subscriberbot/pages/InboxPage.js +194 -199
  104. package/dist/subscriberbot/pages/InboxPage.js.map +1 -1
  105. package/dist/subscriberbot/pages/InsightsPage.js +28 -29
  106. package/dist/subscriberbot/pages/InsightsPage.js.map +1 -1
  107. package/dist/subscriberbot/pages/InvoicesPage.js +179 -188
  108. package/dist/subscriberbot/pages/InvoicesPage.js.map +1 -1
  109. package/dist/subscriberbot/pages/RenewalsPage.js +293 -298
  110. package/dist/subscriberbot/pages/RenewalsPage.js.map +1 -1
  111. package/dist/subscriberbot/pages/SavingsPage.js +25 -26
  112. package/dist/subscriberbot/pages/SavingsPage.js.map +1 -1
  113. package/dist/subscriberbot/pages/WorkflowsPage.js +67 -68
  114. package/dist/subscriberbot/pages/WorkflowsPage.js.map +1 -1
  115. package/dist/subscriberbot/pages/agents/AgentDetailPage.js +126 -127
  116. package/dist/subscriberbot/pages/agents/AgentDetailPage.js.map +1 -1
  117. package/dist/subscriberbot/pages/agents/AgentNewPage.js +10 -11
  118. package/dist/subscriberbot/pages/agents/AgentNewPage.js.map +1 -1
  119. package/dist/subscriberbot/pages/agents/AgentsListPage.js +23 -24
  120. package/dist/subscriberbot/pages/agents/AgentsListPage.js.map +1 -1
  121. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js +337 -359
  122. package/dist/subscriberbot/pages/banking/BankConnectionsPage.js.map +1 -1
  123. package/dist/subscriberbot/pages/banking/ConnectBankModal.js +22 -27
  124. package/dist/subscriberbot/pages/banking/ConnectBankModal.js.map +1 -1
  125. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js +25 -26
  126. package/dist/subscriberbot/pages/decisions/DecisionDetailPage.js.map +1 -1
  127. package/dist/subscriberbot/pages/decisions/DecisionsPage.js +34 -35
  128. package/dist/subscriberbot/pages/decisions/DecisionsPage.js.map +1 -1
  129. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js +125 -130
  130. package/dist/subscriberbot/pages/enterprise/EnterpriseSpendPage.js.map +1 -1
  131. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js +94 -95
  132. package/dist/subscriberbot/pages/negotiations/NegotiationDetailPage.js.map +1 -1
  133. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js +15 -16
  134. package/dist/subscriberbot/pages/negotiations/NegotiationNewPage.js.map +1 -1
  135. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js +20 -21
  136. package/dist/subscriberbot/pages/negotiations/NegotiationsPage.js.map +1 -1
  137. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js +86 -87
  138. package/dist/subscriberbot/pages/procurement/ProcurementDetailPage.js.map +1 -1
  139. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js +164 -165
  140. package/dist/subscriberbot/pages/procurement/ProcurementNewPage.js.map +1 -1
  141. package/dist/subscriberbot/pages/procurement/ProcurementPage.js +20 -21
  142. package/dist/subscriberbot/pages/procurement/ProcurementPage.js.map +1 -1
  143. package/dist/subscriberbot/pages/providers/ProviderDetailPage.js +350 -351
  144. package/dist/subscriberbot/pages/providers/ProviderDetailPage.js.map +1 -1
  145. package/dist/subscriberbot/pages/providers/ProviderInsights.js +95 -96
  146. package/dist/subscriberbot/pages/providers/ProviderInsights.js.map +1 -1
  147. package/dist/subscriberbot/pages/providers/ProviderNewPage.js +11 -12
  148. package/dist/subscriberbot/pages/providers/ProviderNewPage.js.map +1 -1
  149. package/dist/subscriberbot/pages/providers/ProvidersListPage.js +62 -63
  150. package/dist/subscriberbot/pages/providers/ProvidersListPage.js.map +1 -1
  151. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js +166 -172
  152. package/dist/subscriberbot/pages/relationships/RelationshipDetailPage.js.map +1 -1
  153. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js +12 -13
  154. package/dist/subscriberbot/pages/relationships/RelationshipNewPage.js.map +1 -1
  155. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js +21 -22
  156. package/dist/subscriberbot/pages/relationships/RelationshipsListPage.js.map +1 -1
  157. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js +242 -255
  158. package/dist/subscriberbot/pages/workflows/WorkflowBuilderPage.js.map +1 -1
  159. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js +2 -3
  160. package/dist/subscriberbot/pages/workflows/workflowBuilderGraph.js.map +1 -1
  161. package/dist/subscriberbot/services/createSandboxAssistantTransport.js +1 -2
  162. package/dist/subscriberbot/services/createSandboxAssistantTransport.js.map +1 -1
  163. package/dist/subscriberbot/store/index.js +1 -1
  164. package/dist/subscriberbot/store/subscriberbotStore.js +1 -2
  165. package/dist/subscriberbot/store/subscriberbotStore.js.map +1 -1
  166. package/dist/subscriberbot/utils/bankRedirectLink.js +18 -19
  167. package/dist/subscriberbot/utils/bankRedirectLink.js.map +1 -1
  168. package/dist/subscriberbot/utils/chartScale.js +1 -2
  169. package/dist/subscriberbot/utils/chartScale.js.map +1 -1
  170. package/dist/subscriberbot/utils/cn.js +2 -3
  171. package/dist/subscriberbot/utils/cn.js.map +1 -1
  172. package/dist/subscriberbot/utils/formatters.js +4 -5
  173. package/dist/subscriberbot/utils/formatters.js.map +1 -1
  174. package/dist/subscriberbot/utils/navigation.js +1 -2
  175. package/dist/subscriberbot/utils/navigation.js.map +1 -1
  176. package/dist/subscriberbot/utils/pageContext.js +3 -4
  177. package/dist/subscriberbot/utils/pageContext.js.map +1 -1
  178. package/dist/subscriberbot/utils/plaidLink.js +21 -22
  179. package/dist/subscriberbot/utils/plaidLink.js.map +1 -1
  180. package/dist/subscriberbot/utils/portfolio.js +5 -6
  181. package/dist/subscriberbot/utils/portfolio.js.map +1 -1
  182. package/dist/subscriberbot/utils/renewals.js +1 -2
  183. package/dist/subscriberbot/utils/renewals.js.map +1 -1
  184. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- //#region src/subscriberbot/utils/formatters.ts
1
+ // src/subscriberbot/utils/formatters.ts
2
2
  function e(e, t = "USD", n, r) {
3
3
  if (!Number.isFinite(e)) return "—";
4
4
  try {
@@ -48,9 +48,9 @@ function r(e, t) {
48
48
  let n = typeof e == "string" ? new Date(e) : e;
49
49
  if (Number.isNaN(n.getTime())) return "—";
50
50
  let r = (n.getTime() - Date.now()) / 1e3, [i, a] = [
51
- ["year", 365 * 86400],
52
- ["month", 30 * 86400],
53
- ["week", 7 * 86400],
51
+ ["year", 31536e3],
52
+ ["month", 2592e3],
53
+ ["week", 604800],
54
54
  ["day", 86400],
55
55
  ["hour", 3600],
56
56
  ["minute", 60],
@@ -96,7 +96,6 @@ function s(s, c) {
96
96
  formatPrice: (e, t, n) => `${l(e, t)} / ${u(n).toLocaleLowerCase(s)}`
97
97
  };
98
98
  }
99
- //#endregion
100
99
  export { s as createFormatters, e as formatCurrency, t as formatDate, n as formatDateTime, a as formatEnumLabel, o as formatIntervalSuffix, i as formatNumber, r as formatRelativeTime };
101
100
 
102
101
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":[],"sources":["../../../src/subscriberbot/utils/formatters.ts"],"sourcesContent":["/**\n * Formatting utilities for the Subscriber Bot microfrontend\n * @module subscriberbot/utils/formatters\n *\n * Subscriber Bot is a global product — relationships are billed in many\n * currencies. Formatting is therefore currency-aware (each Relationship /\n * Invoice / Plan carries its own ISO currency code).\n */\n\n/**\n * Format an amount as currency using the relationship/invoice's own ISO code.\n *\n * @param amount - The numeric amount to format\n * @param currency - ISO 4217 currency code (e.g. \"USD\", \"EUR\", \"INR\")\n * @param options - Optional Intl.NumberFormat overrides\n * @returns Formatted currency string (e.g. \"$12.00\")\n *\n * @example\n * formatCurrency(12, 'USD') // => \"$12.00\"\n * formatCurrency(999, 'INR', { minimumFractionDigits: 0 }) // => \"₹999\"\n * formatCurrency(55, 'USD', { maximumFractionDigits: 0 }) // => \"$55\"\n */\nexport function formatCurrency(\n amount: number,\n currency = 'USD',\n options?: Partial<Intl.NumberFormatOptions>,\n locale?: string\n): string {\n if (!Number.isFinite(amount)) return '—';\n // Intl throws a RangeError when minimumFractionDigits > maximumFractionDigits,\n // so a caller that only lowers the maximum (e.g. whole-unit KPI tiles) must\n // also lower the default minimum instead of falling through to the\n // plain-number fallback below.\n try {\n const defaults = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency || 'USD',\n }).resolvedOptions();\n const maximumFractionDigits =\n options?.maximumFractionDigits ??\n Math.max(defaults.maximumFractionDigits ?? 2, options?.minimumFractionDigits ?? 0);\n const minimumFractionDigits =\n options?.minimumFractionDigits ??\n Math.min(defaults.minimumFractionDigits ?? 2, maximumFractionDigits);\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency || 'USD',\n ...options,\n minimumFractionDigits,\n maximumFractionDigits,\n }).format(amount);\n } catch {\n // Unknown/invalid currency code → fall back to a plain number + code.\n return `${new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount)} ${currency}`;\n }\n}\n\n/**\n * Format a date string or Date object into a human-readable date.\n *\n * @param date - ISO date string or Date object\n * @param options - Optional Intl.DateTimeFormat options\n * @returns Formatted date string (e.g. \"15 Jan 2026\")\n */\nexport function formatDate(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n ...(typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date) ? { timeZone: 'UTC' } : {}),\n ...options,\n }).format(d);\n}\n\n/**\n * Format a date-time into a date + time string.\n */\nexport function formatDateTime(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n ...options,\n }).format(d);\n}\n\n/**\n * Format a date into a relative time string (e.g. \"2 hours ago\", \"in 3 days\").\n *\n * @param date - ISO date string or Date object\n * @returns Human-readable relative time string\n */\nexport function formatRelativeTime(\n date: string | Date | null | undefined,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n const seconds = (d.getTime() - Date.now()) / 1000;\n const units: Array<[Intl.RelativeTimeFormatUnit, number]> = [\n ['year', 365 * 86400],\n ['month', 30 * 86400],\n ['week', 7 * 86400],\n ['day', 86400],\n ['hour', 3600],\n ['minute', 60],\n ['second', 1],\n ];\n const [unit, size] = units.find(([, size]) => Math.abs(seconds) >= size) ?? ['second', 1];\n const value = Math.trunc(seconds / size);\n return new Intl.RelativeTimeFormat(locale, { numeric: 'auto', style: 'short' }).format(\n value === 0 ? 0 : value,\n unit\n );\n}\n\n/**\n * Format a number with locale grouping.\n */\nexport function formatNumber(\n value: number,\n options?: Partial<Intl.NumberFormatOptions>,\n locale?: string\n): string {\n if (!Number.isFinite(value)) return '—';\n return new Intl.NumberFormat(locale, options).format(value);\n}\n\n/**\n * Turn an ENUM_LIKE_TOKEN into a human \"Enum Like Token\" label.\n */\nexport function formatEnumLabel(value: string): string {\n return value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\n/**\n * Format a billing interval enum into a short suffix (e.g. \"MONTHLY\" → \"/mo\").\n */\nexport function formatIntervalSuffix(interval: string): string {\n switch (interval) {\n case 'DAILY':\n return '/day';\n case 'WEEKLY':\n return '/wk';\n case 'MONTHLY':\n return '/mo';\n case 'QUARTERLY':\n return '/qtr';\n case 'YEARLY':\n return '/yr';\n case 'LIFETIME':\n return ' lifetime';\n case 'USAGE_BASED':\n return ' usage';\n case 'FREE':\n return '';\n default:\n return '';\n }\n}\n\n/** Bind pure formatters to the app's selected locale, without global mutable state. */\nexport function createFormatters(locale: string, tr: (key: string, fallback: string) => string) {\n const currency = (amount: number, code = 'USD', options?: Partial<Intl.NumberFormatOptions>) =>\n formatCurrency(amount, code, options, locale);\n const enumLabel = (value: string) => tr(`enums.${value.toLowerCase()}`, formatEnumLabel(value));\n return {\n formatCurrency: currency,\n formatDate: (\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n ) => formatDate(date, options, locale),\n formatDateTime: (\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n ) => formatDateTime(date, options, locale),\n formatNumber: (value: number, options?: Partial<Intl.NumberFormatOptions>) =>\n formatNumber(value, options, locale),\n formatRelativeTime: (date: string | Date | null | undefined) =>\n formatRelativeTime(date, locale),\n formatEnumLabel: enumLabel,\n formatIntervalSuffix: (interval: string) => {\n const fallback = formatIntervalSuffix(interval);\n return fallback ? tr(`intervals.${interval.toLowerCase()}`, fallback) : '';\n },\n formatPrice: (amount: number, code: string, interval: string) =>\n `${currency(amount, code)} / ${enumLabel(interval).toLocaleLowerCase(locale)}`,\n };\n}\n"],"mappings":";AAsBA,SAAgB,EACd,GACA,IAAW,OACX,GACA,GACQ;CACR,IAAI,CAAC,OAAO,SAAS,CAAM,GAAG,OAAO;CAKrC,IAAI;EACF,IAAM,IAAW,IAAI,KAAK,aAAa,GAAQ;GAC7C,OAAO;GACP,UAAU,KAAY;EACxB,CAAC,EAAE,gBAAgB,GACb,IACJ,GAAS,yBACT,KAAK,IAAI,EAAS,yBAAyB,GAAG,GAAS,yBAAyB,CAAC,GAC7E,IACJ,GAAS,yBACT,KAAK,IAAI,EAAS,yBAAyB,GAAG,CAAqB;EACrE,OAAO,IAAI,KAAK,aAAa,GAAQ;GACnC,OAAO;GACP,UAAU,KAAY;GACtB,GAAG;GACH;GACA;EACF,CAAC,EAAE,OAAO,CAAM;CAClB,QAAQ;EAEN,OAAO,GAAG,IAAI,KAAK,aAAa,GAAQ;GAAE,uBAAuB;GAAG,uBAAuB;EAAE,CAAC,EAAE,OAAO,CAAM,EAAE,GAAG;CACpH;AACF;AASA,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,CAAI,IAAI;CAEtD,OADI,OAAO,MAAM,EAAE,QAAQ,CAAC,IAAU,MAC/B,IAAI,KAAK,eAAe,GAAQ;EACrC,KAAK;EACL,OAAO;EACP,MAAM;EACN,GAAI,OAAO,KAAS,YAAY,sBAAsB,KAAK,CAAI,IAAI,EAAE,UAAU,MAAM,IAAI,CAAC;EAC1F,GAAG;CACL,CAAC,EAAE,OAAO,CAAC;AACb;AAKA,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAI,OAAO,KAAS,WAAW,IAAI,KAAK,CAAI,IAAI;CAEtD,OADI,OAAO,MAAM,EA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AO;EACT,KAAK,UACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,eACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAGA,SAAgB,EAAiB,GAAgB,GAA+C;CAC9F,IAAM,KAAY,GAAgB,IAAO,OAAO,MAC9C,EAAe,GAAQ,GAAM,GAAS,CAAM,GACxC,KAAa,MAAkB,EAAG,SAAS,EAAM,YAAY,KAAK,EAAgB,CAAK,CAAC;CAC9F,OAAO;EACL,gBAAgB;EAChB,aACE,GACA,MACG,EAAW,GAAM,GAAS,CAAM;EACrC,iBACE,GACA,MACG,EAAe,GAAM,GAAS,CAAM;EACzC,eAAe,GAAe,MAC5B,EAAa,GAAO,GAAS,CAAM;EACrC,qBAAqB,MACnB,EAAmB,GAAM,CAAM;EACjC,iBAAiB;EACjB,uBAAuB,MAAqB;GAC1C,IAAM,IAAW,EAAqB,CAAQ;GAC9C,OAAO,IAAW,EAAG,aAAa,EAAS,YAAY,KAAK,CAAQ,IAAI;EAC1E;EACA,cAAc,GAAgB,GAAc,MAC1C,GAAG,EAAS,GAAQ,CAAI,EAAE,KAAK,EAAU,CAAQ,EAAE,kBAAkB,CAAM;CAC/E;AACF"}
1
+ {"version":3,"file":"formatters.js","names":["formatCurrency","amount","defaults","locale","currency","maximumFractionDigits","options","minimumFractionDigits","formatDate","date","d","formatDateTime","formatRelativeTime","seconds","unit","size","value","formatNumber","formatEnumLabel","char","formatIntervalSuffix","interval","createFormatters","code","enumLabel","tr","fallback"],"sources":["../../../src/subscriberbot/utils/formatters.ts"],"sourcesContent":["/**\n * Formatting utilities for the Subscriber Bot microfrontend\n * @module subscriberbot/utils/formatters\n *\n * Subscriber Bot is a global product — relationships are billed in many\n * currencies. Formatting is therefore currency-aware (each Relationship /\n * Invoice / Plan carries its own ISO currency code).\n */\n\n/**\n * Format an amount as currency using the relationship/invoice's own ISO code.\n *\n * @param amount - The numeric amount to format\n * @param currency - ISO 4217 currency code (e.g. \"USD\", \"EUR\", \"INR\")\n * @param options - Optional Intl.NumberFormat overrides\n * @returns Formatted currency string (e.g. \"$12.00\")\n *\n * @example\n * formatCurrency(12, 'USD') // => \"$12.00\"\n * formatCurrency(999, 'INR', { minimumFractionDigits: 0 }) // => \"₹999\"\n * formatCurrency(55, 'USD', { maximumFractionDigits: 0 }) // => \"$55\"\n */\nexport function formatCurrency(\n amount: number,\n currency = 'USD',\n options?: Partial<Intl.NumberFormatOptions>,\n locale?: string\n): string {\n if (!Number.isFinite(amount)) return '—';\n // Intl throws a RangeError when minimumFractionDigits > maximumFractionDigits,\n // so a caller that only lowers the maximum (e.g. whole-unit KPI tiles) must\n // also lower the default minimum instead of falling through to the\n // plain-number fallback below.\n try {\n const defaults = new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency || 'USD',\n }).resolvedOptions();\n const maximumFractionDigits =\n options?.maximumFractionDigits ??\n Math.max(defaults.maximumFractionDigits ?? 2, options?.minimumFractionDigits ?? 0);\n const minimumFractionDigits =\n options?.minimumFractionDigits ??\n Math.min(defaults.minimumFractionDigits ?? 2, maximumFractionDigits);\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: currency || 'USD',\n ...options,\n minimumFractionDigits,\n maximumFractionDigits,\n }).format(amount);\n } catch {\n // Unknown/invalid currency code → fall back to a plain number + code.\n return `${new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(amount)} ${currency}`;\n }\n}\n\n/**\n * Format a date string or Date object into a human-readable date.\n *\n * @param date - ISO date string or Date object\n * @param options - Optional Intl.DateTimeFormat options\n * @returns Formatted date string (e.g. \"15 Jan 2026\")\n */\nexport function formatDate(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n ...(typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date) ? { timeZone: 'UTC' } : {}),\n ...options,\n }).format(d);\n}\n\n/**\n * Format a date-time into a date + time string.\n */\nexport function formatDateTime(\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n return new Intl.DateTimeFormat(locale, {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n hour: 'numeric',\n minute: '2-digit',\n ...options,\n }).format(d);\n}\n\n/**\n * Format a date into a relative time string (e.g. \"2 hours ago\", \"in 3 days\").\n *\n * @param date - ISO date string or Date object\n * @returns Human-readable relative time string\n */\nexport function formatRelativeTime(\n date: string | Date | null | undefined,\n locale?: string\n): string {\n if (!date) return '—';\n const d = typeof date === 'string' ? new Date(date) : date;\n if (Number.isNaN(d.getTime())) return '—';\n const seconds = (d.getTime() - Date.now()) / 1000;\n const units: Array<[Intl.RelativeTimeFormatUnit, number]> = [\n ['year', 365 * 86400],\n ['month', 30 * 86400],\n ['week', 7 * 86400],\n ['day', 86400],\n ['hour', 3600],\n ['minute', 60],\n ['second', 1],\n ];\n const [unit, size] = units.find(([, size]) => Math.abs(seconds) >= size) ?? ['second', 1];\n const value = Math.trunc(seconds / size);\n return new Intl.RelativeTimeFormat(locale, { numeric: 'auto', style: 'short' }).format(\n value === 0 ? 0 : value,\n unit\n );\n}\n\n/**\n * Format a number with locale grouping.\n */\nexport function formatNumber(\n value: number,\n options?: Partial<Intl.NumberFormatOptions>,\n locale?: string\n): string {\n if (!Number.isFinite(value)) return '—';\n return new Intl.NumberFormat(locale, options).format(value);\n}\n\n/**\n * Turn an ENUM_LIKE_TOKEN into a human \"Enum Like Token\" label.\n */\nexport function formatEnumLabel(value: string): string {\n return value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/\\b\\w/g, (char) => char.toUpperCase());\n}\n\n/**\n * Format a billing interval enum into a short suffix (e.g. \"MONTHLY\" → \"/mo\").\n */\nexport function formatIntervalSuffix(interval: string): string {\n switch (interval) {\n case 'DAILY':\n return '/day';\n case 'WEEKLY':\n return '/wk';\n case 'MONTHLY':\n return '/mo';\n case 'QUARTERLY':\n return '/qtr';\n case 'YEARLY':\n return '/yr';\n case 'LIFETIME':\n return ' lifetime';\n case 'USAGE_BASED':\n return ' usage';\n case 'FREE':\n return '';\n default:\n return '';\n }\n}\n\n/** Bind pure formatters to the app's selected locale, without global mutable state. */\nexport function createFormatters(locale: string, tr: (key: string, fallback: string) => string) {\n const currency = (amount: number, code = 'USD', options?: Partial<Intl.NumberFormatOptions>) =>\n formatCurrency(amount, code, options, locale);\n const enumLabel = (value: string) => tr(`enums.${value.toLowerCase()}`, formatEnumLabel(value));\n return {\n formatCurrency: currency,\n formatDate: (\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n ) => formatDate(date, options, locale),\n formatDateTime: (\n date: string | Date | null | undefined,\n options?: Partial<Intl.DateTimeFormatOptions>\n ) => formatDateTime(date, options, locale),\n formatNumber: (value: number, options?: Partial<Intl.NumberFormatOptions>) =>\n formatNumber(value, options, locale),\n formatRelativeTime: (date: string | Date | null | undefined) =>\n formatRelativeTime(date, locale),\n formatEnumLabel: enumLabel,\n formatIntervalSuffix: (interval: string) => {\n const fallback = formatIntervalSuffix(interval);\n return fallback ? tr(`intervals.${interval.toLowerCase()}`, fallback) : '';\n },\n formatPrice: (amount: number, code: string, interval: string) =>\n `${currency(amount, code)} / ${enumLabel(interval).toLocaleLowerCase(locale)}`,\n };\n}\n"],"mappings":";AAsBA,SAAgBA,EACd,GACA,IAAW,OACX,GACA,GACQ;CACR,IAAI,CAAC,OAAO,SAASC,CAAM,GAAG,OAAO;CAKrC,IAAI;EACF,IAAMC,IAAW,IAAI,KAAK,aAAaC,GAAQ;GAC7C,OAAO;GACP,UAAUC,KAAY;EACxB,CAAC,CAAC,CAAC,gBAAgB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,GAAQsB,GAAMjB,GAASH,CAAM,GACxCqB,KAAa,MAAkBC,EAAG,SAAST,EAAM,YAAY,KAAKE,EAAgBF,CAAK,CAAC;CAC9F,OAAO;EACL,gBAAgBZ;EAChB,aACE,GACA,MACGI,EAAWC,GAAMH,GAASH,CAAM;EACrC,iBACE,GACA,MACGQ,EAAeF,GAAMH,GAASH,CAAM;EACzC,eAAe,GAAe,MAC5Bc,EAAaD,GAAOV,GAASH,CAAM;EACrC,qBAAqB,MACnBS,EAAmBH,GAAMN,CAAM;EACjC,iBAAiBqB;EACjB,uBAAuB,MAAqB;GAC1C,IAAME,IAAWN,EAAqBC,CAAQ;GAC9C,OAAOK,IAAWD,EAAG,aAAaJ,EAAS,YAAY,KAAKK,CAAQ,IAAI;EAC1E;EACA,cAAc,GAAgB,GAAc,MAC1C,GAAGtB,EAASH,GAAQsB,CAAI,EAAE,KAAKC,EAAUH,CAAQ,CAAC,CAAC,kBAAkBlB,CAAM;CAC/E;AACF"}
@@ -1,9 +1,8 @@
1
- //#region src/subscriberbot/utils/navigation.ts
1
+ // src/subscriberbot/utils/navigation.ts
2
2
  function e(e, t) {
3
3
  let n = e.endsWith("/") ? e.slice(0, -1) : e;
4
4
  return !t || t === "" ? n || "/" : n + (t.startsWith("/") ? t : `/${t}`);
5
5
  }
6
- //#endregion
7
6
  export { e as joinPath };
8
7
 
9
8
  //# sourceMappingURL=navigation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.js","names":[],"sources":["../../../src/subscriberbot/utils/navigation.ts"],"sourcesContent":["/**\n * Navigation utilities for the SubscriberBot microfrontend\n * @module subscriberbot/utils\n */\n\n/**\n * Join basePath with a relative path, correctly handling slashes\n *\n * @param basePath - The base path (e.g., '/' or '/subscriberbot')\n * @param relativePath - The relative path (e.g., 'carts/new' or '/carts/new')\n * @returns The joined path (e.g., '/subscriberbot/carts/new')\n *\n * @example\n * joinPath('/', 'carts/new') // => '/carts/new'\n * joinPath('/', '/carts/new') // => '/carts/new'\n * joinPath('/subscriberbot', 'orders') // => '/subscriberbot/orders'\n * joinPath('/subscriberbot/', 'orders') // => '/subscriberbot/orders'\n * joinPath('/subscriberbot', '') // => '/subscriberbot'\n */\nexport function joinPath(basePath: string, relativePath: string): string {\n // Remove trailing slash from base\n const cleanBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n // Handle empty relative path (go to base)\n if (!relativePath || relativePath === '') {\n return cleanBase || '/';\n }\n\n // Ensure relative path starts with /\n const cleanPath = relativePath.startsWith('/') ? relativePath : `/${relativePath}`;\n\n // Join them\n return cleanBase + cleanPath;\n}\n"],"mappings":";AAmBA,SAAgB,EAAS,GAAkB,GAA8B;CAEvE,IAAM,IAAY,EAAS,SAAS,GAAG,IAAI,EAAS,MAAM,GAAG,EAAE,IAAI;CAWnE,OARI,CAAC,KAAgB,MAAiB,KAC7B,KAAa,MAOf,KAHW,EAAa,WAAW,GAAG,IAAI,IAAe,IAAI;AAItE"}
1
+ {"version":3,"file":"navigation.js","names":["joinPath","cleanBase","basePath","relativePath"],"sources":["../../../src/subscriberbot/utils/navigation.ts"],"sourcesContent":["/**\n * Navigation utilities for the SubscriberBot microfrontend\n * @module subscriberbot/utils\n */\n\n/**\n * Join basePath with a relative path, correctly handling slashes\n *\n * @param basePath - The base path (e.g., '/' or '/subscriberbot')\n * @param relativePath - The relative path (e.g., 'carts/new' or '/carts/new')\n * @returns The joined path (e.g., '/subscriberbot/carts/new')\n *\n * @example\n * joinPath('/', 'carts/new') // => '/carts/new'\n * joinPath('/', '/carts/new') // => '/carts/new'\n * joinPath('/subscriberbot', 'orders') // => '/subscriberbot/orders'\n * joinPath('/subscriberbot/', 'orders') // => '/subscriberbot/orders'\n * joinPath('/subscriberbot', '') // => '/subscriberbot'\n */\nexport function joinPath(basePath: string, relativePath: string): string {\n // Remove trailing slash from base\n const cleanBase = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n // Handle empty relative path (go to base)\n if (!relativePath || relativePath === '') {\n return cleanBase || '/';\n }\n\n // Ensure relative path starts with /\n const cleanPath = relativePath.startsWith('/') ? relativePath : `/${relativePath}`;\n\n // Join them\n return cleanBase + cleanPath;\n}\n"],"mappings":";AAmBA,SAAgBA,EAAS,GAAkB,GAA8B;CAEvE,IAAMC,IAAYC,EAAS,SAAS,GAAG,IAAIA,EAAS,MAAM,GAAG,EAAE,IAAIA;CAWnE,OARI,CAACC,KAAgBA,MAAiB,KAC7BF,KAAa,MAOfA,KAHWE,EAAa,WAAW,GAAG,IAAIA,IAAe,IAAIA;AAItE"}
@@ -1,4 +1,4 @@
1
- //#region src/subscriberbot/utils/pageContext.ts
1
+ // src/subscriberbot/utils/pageContext.ts
2
2
  var e = {
3
3
  relationship: "SUBSCRIBERBOT_RELATIONSHIP",
4
4
  provider: "SUBSCRIBERBOT_PROVIDER",
@@ -13,7 +13,7 @@ var e = {
13
13
  ["decisions", e.decision],
14
14
  ["inbox", e.inboxMessage],
15
15
  ["workflows", e.workflow]
16
- ], n = new Map([["workflows", new Set(["builder"])]]), r = new Set(["new"]), i = /^[A-Za-z0-9_-]{1,128}$/, a = /^[A-Za-z0-9_-]{1,64}$/;
16
+ ], n = /* @__PURE__ */ new Map([["workflows", /* @__PURE__ */ new Set(["builder"])]]), r = /* @__PURE__ */ new Set(["new"]), i = /^[A-Za-z0-9_-]{1,128}$/, a = /^[A-Za-z0-9_-]{1,64}$/;
17
17
  function o(e) {
18
18
  try {
19
19
  return decodeURIComponent(e);
@@ -56,7 +56,6 @@ function c() {
56
56
  viewportSize: `${window.innerWidth}x${window.innerHeight}`
57
57
  };
58
58
  }
59
- //#endregion
60
- export { c as gatherPageContext };
59
+ export { e as SUBSCRIBERBOT_ENTITY_TYPES, c as gatherPageContext, s as resolveSubscriberBotConversationContext };
61
60
 
62
61
  //# sourceMappingURL=pageContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageContext.js","names":[],"sources":["../../../src/subscriberbot/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context for the Subscriber Bot assistant.\n *\n * `gatherPageContext()` runs before every assistant turn and its result is sent\n * to the assistant sandbox, which keeps only the keys in the agent's\n * `ALLOWED_CONTEXT_KEYS` (ai-assistant `src/context-loader.ts`). Nothing filters\n * on this side, so every key returned here crosses the wire: return only\n * allow-listed keys, and never a message body, a payment-instrument detail or\n * anything else that identifies a person. `userAgent` and `timestamp` are\n * deliberately absent for the same reason (AI readiness criteria 3.1 and 3.3).\n *\n * `entityType` + `entityId` are what let the agent act on \"this\" in one turn\n * (\"unsubscribe from this\", \"pause this\", \"cancel this\"), so every page that has\n * an addressable entity in its URL must resolve here.\n */\n\n/**\n * The keys the assistant agent forwards to the model. Kept in step with\n * `ALLOWED_CONTEXT_KEYS` in ai-assistant `src/context-loader.ts`; the unit test\n * asserts that `gatherPageContext()` never returns a key outside this list.\n */\nexport const ASSISTANT_ALLOWED_CONTEXT_KEYS = [\n 'currentUrl',\n 'currentPage',\n 'entityType',\n 'entityId',\n 'entityName',\n 'pageTitle',\n 'pageType',\n 'activeTab',\n 'activeTool',\n 'selectedText',\n 'workspaceId',\n 'workspaceName',\n 'projectId',\n 'projectName',\n 'platform',\n 'version',\n 'viewportSize',\n] as const;\n\nexport type AssistantContextKey = (typeof ASSISTANT_ALLOWED_CONTEXT_KEYS)[number];\n\n/** Entity types the Subscriber Bot routes resolve to. The agent guide documents each one. */\nexport const SUBSCRIBERBOT_ENTITY_TYPES = {\n relationship: 'SUBSCRIBERBOT_RELATIONSHIP',\n provider: 'SUBSCRIBERBOT_PROVIDER',\n agent: 'SUBSCRIBERBOT_AGENT',\n decision: 'SUBSCRIBERBOT_DECISION',\n inboxMessage: 'SUBSCRIBERBOT_INBOX_MESSAGE',\n workflow: 'SUBSCRIBERBOT_WORKFLOW',\n} as const;\n\nexport type SubscriberBotEntityType =\n (typeof SUBSCRIBERBOT_ENTITY_TYPES)[keyof typeof SUBSCRIBERBOT_ENTITY_TYPES];\n\nexport interface ConversationContextShape {\n entityType?: SubscriberBotEntityType;\n entityId?: string;\n activeTab?: string;\n}\n\nexport type PageContext = Partial<Record<AssistantContextKey, string>> & {\n currentUrl: string;\n currentPage: string;\n platform: string;\n version: string;\n viewportSize: string;\n};\n\n/**\n * Route segment → entity type, for every route that carries one entity id.\n * Each entry mirrors a route in `SubscriberBotRoutes.tsx`; a pattern for a\n * route the app does not define would never match a real page.\n */\nconst ENTITY_ROUTES: ReadonlyArray<readonly [segment: string, type: SubscriberBotEntityType]> = [\n ['relationships', SUBSCRIBERBOT_ENTITY_TYPES.relationship],\n ['providers', SUBSCRIBERBOT_ENTITY_TYPES.provider],\n ['agents', SUBSCRIBERBOT_ENTITY_TYPES.agent],\n ['decisions', SUBSCRIBERBOT_ENTITY_TYPES.decision],\n ['inbox', SUBSCRIBERBOT_ENTITY_TYPES.inboxMessage],\n ['workflows', SUBSCRIBERBOT_ENTITY_TYPES.workflow],\n];\n\n/**\n * Sub-views of one entity (`/workflows/:id/builder`): the entity stays the\n * subject and the sub-view is reported as the active tab.\n */\nconst ENTITY_SUBVIEWS: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n ['workflows', new Set(['builder'])],\n]);\n\n/** Static sub-routes that sit where an id would (\"relationships/new\" is a form, not an entity). */\nconst NON_ENTITY_SEGMENTS: ReadonlySet<string> = new Set(['new']);\n\n/** Ids are opaque, but they are path segments: no separators, no whitespace, bounded length. */\nconst ENTITY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\n/** Tab names are short identifiers; anything else is ignored rather than forwarded. */\nconst TAB_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;\n\nfunction decodeSegment(segment: string): string | undefined {\n try {\n return decodeURIComponent(segment);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve the entity the user is looking at from the router location.\n *\n * `pathname` is the full browser path; the Subscriber Bot routes live under\n * `/subscriberbot`. Anything that is not an entity route resolves to an empty\n * entity, so the agent asks rather than acting on a guessed id.\n */\nexport function resolveSubscriberBotConversationContext(\n pathname: string,\n search: string\n): ConversationContextShape {\n const segments = pathname.split('/').filter(Boolean);\n const root = segments.indexOf('subscriberbot');\n const rest = root === -1 ? [] : segments.slice(root + 1);\n\n const tabParam = new URLSearchParams(search).get('tab');\n const activeTab = tabParam && TAB_PATTERN.test(tabParam) ? tabParam : undefined;\n\n if (rest.length === 3) {\n const [section, rawId, subview] = rest as [string, string, string];\n const route = ENTITY_ROUTES.find(([segment]) => segment === section);\n const id = decodeSegment(rawId);\n if (route && id && ENTITY_SUBVIEWS.get(section)?.has(subview) && ENTITY_ID_PATTERN.test(id)) {\n return { entityType: route[1], entityId: id, activeTab: subview };\n }\n }\n\n if (rest.length === 2) {\n const [section, rawId] = rest as [string, string];\n const route = ENTITY_ROUTES.find(([segment]) => segment === section);\n const id = decodeSegment(rawId);\n if (route && id && !NON_ENTITY_SEGMENTS.has(id) && ENTITY_ID_PATTERN.test(id)) {\n return { entityType: route[1], entityId: id, ...(activeTab ? { activeTab } : {}) };\n }\n }\n\n return activeTab ? { activeTab } : {};\n}\n\nexport function gatherPageContext(): PageContext {\n const { href, pathname, search } = window.location;\n const currentPage = pathname.split('/').filter(Boolean).slice(0, 3).join('/') || 'home';\n const entity = resolveSubscriberBotConversationContext(pathname, search);\n\n return {\n currentUrl: href,\n currentPage,\n ...(entity.entityType && entity.entityId\n ? { entityType: entity.entityType, entityId: entity.entityId }\n : {}),\n ...(entity.activeTab ? { activeTab: entity.activeTab } : {}),\n platform: 'subscriberbot',\n version: import.meta.env.VITE_APP_VERSION ?? '2026.615.1',\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n };\n}\n"],"mappings":";AA4CA,IAAa,IAA6B;CACxC,cAAc;CACd,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,UAAU;AACZ,GAwBM,IAA0F;CAC9F,CAAC,iBAAiB,EAA2B,YAAY;CACzD,CAAC,aAAa,EAA2B,QAAQ;CACjD,CAAC,UAAU,EAA2B,KAAK;CAC3C,CAAC,aAAa,EAA2B,Q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AO,IAAY,EAAE,aAAU,IAAI,CAAC;AACtC;AAEA,SAAgB,IAAiC;CAC/C,IAAM,EAAE,SAAM,aAAU,cAAW,OAAO,UACpC,IAAc,EAAS,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,QAC3E,IAAS,EAAwC,GAAU,CAAM;CAEvE,OAAO;EACL,YAAY;EACZ;EACA,GAAI,EAAO,cAAc,EAAO,WAC5B;GAAE,YAAY,EAAO;GAAY,UAAU,EAAO;EAAS,IAC3D,CAAC;EACL,GAAI,EAAO,YAAY,EAAE,WAAW,EAAO,UAAU,IAAI,CAAC;EAC1D,UAAU;EACV,SAA6C;EAC7C,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO;CAC/C;AACF"}
1
+ {"version":3,"file":"pageContext.js","names":["SUBSCRIBERBOT_ENTITY_TYPES","ENTITY_ROUTES","ENTITY_SUBVIEWS","NON_ENTITY_SEGMENTS","ENTITY_ID_PATTERN","TAB_PATTERN","decodeSegment","segment","resolveSubscriberBotConversationContext","segments","pathname","root","rest","tabParam","search","activeTab","section","rawId","subview","route","id","gatherPageContext","currentPage","entity","href"],"sources":["../../../src/subscriberbot/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context for the Subscriber Bot assistant.\n *\n * `gatherPageContext()` runs before every assistant turn and its result is sent\n * to the assistant sandbox, which keeps only the keys in the agent's\n * `ALLOWED_CONTEXT_KEYS` (ai-assistant `src/context-loader.ts`). Nothing filters\n * on this side, so every key returned here crosses the wire: return only\n * allow-listed keys, and never a message body, a payment-instrument detail or\n * anything else that identifies a person. `userAgent` and `timestamp` are\n * deliberately absent for the same reason (AI readiness criteria 3.1 and 3.3).\n *\n * `entityType` + `entityId` are what let the agent act on \"this\" in one turn\n * (\"unsubscribe from this\", \"pause this\", \"cancel this\"), so every page that has\n * an addressable entity in its URL must resolve here.\n */\n\n/**\n * The keys the assistant agent forwards to the model. Kept in step with\n * `ALLOWED_CONTEXT_KEYS` in ai-assistant `src/context-loader.ts`; the unit test\n * asserts that `gatherPageContext()` never returns a key outside this list.\n */\nexport const ASSISTANT_ALLOWED_CONTEXT_KEYS = [\n 'currentUrl',\n 'currentPage',\n 'entityType',\n 'entityId',\n 'entityName',\n 'pageTitle',\n 'pageType',\n 'activeTab',\n 'activeTool',\n 'selectedText',\n 'workspaceId',\n 'workspaceName',\n 'projectId',\n 'projectName',\n 'platform',\n 'version',\n 'viewportSize',\n] as const;\n\nexport type AssistantContextKey = (typeof ASSISTANT_ALLOWED_CONTEXT_KEYS)[number];\n\n/** Entity types the Subscriber Bot routes resolve to. The agent guide documents each one. */\nexport const SUBSCRIBERBOT_ENTITY_TYPES = {\n relationship: 'SUBSCRIBERBOT_RELATIONSHIP',\n provider: 'SUBSCRIBERBOT_PROVIDER',\n agent: 'SUBSCRIBERBOT_AGENT',\n decision: 'SUBSCRIBERBOT_DECISION',\n inboxMessage: 'SUBSCRIBERBOT_INBOX_MESSAGE',\n workflow: 'SUBSCRIBERBOT_WORKFLOW',\n} as const;\n\nexport type SubscriberBotEntityType =\n (typeof SUBSCRIBERBOT_ENTITY_TYPES)[keyof typeof SUBSCRIBERBOT_ENTITY_TYPES];\n\nexport interface ConversationContextShape {\n entityType?: SubscriberBotEntityType;\n entityId?: string;\n activeTab?: string;\n}\n\nexport type PageContext = Partial<Record<AssistantContextKey, string>> & {\n currentUrl: string;\n currentPage: string;\n platform: string;\n version: string;\n viewportSize: string;\n};\n\n/**\n * Route segment → entity type, for every route that carries one entity id.\n * Each entry mirrors a route in `SubscriberBotRoutes.tsx`; a pattern for a\n * route the app does not define would never match a real page.\n */\nconst ENTITY_ROUTES: ReadonlyArray<readonly [segment: string, type: SubscriberBotEntityType]> = [\n ['relationships', SUBSCRIBERBOT_ENTITY_TYPES.relationship],\n ['providers', SUBSCRIBERBOT_ENTITY_TYPES.provider],\n ['agents', SUBSCRIBERBOT_ENTITY_TYPES.agent],\n ['decisions', SUBSCRIBERBOT_ENTITY_TYPES.decision],\n ['inbox', SUBSCRIBERBOT_ENTITY_TYPES.inboxMessage],\n ['workflows', SUBSCRIBERBOT_ENTITY_TYPES.workflow],\n];\n\n/**\n * Sub-views of one entity (`/workflows/:id/builder`): the entity stays the\n * subject and the sub-view is reported as the active tab.\n */\nconst ENTITY_SUBVIEWS: ReadonlyMap<string, ReadonlySet<string>> = new Map([\n ['workflows', new Set(['builder'])],\n]);\n\n/** Static sub-routes that sit where an id would (\"relationships/new\" is a form, not an entity). */\nconst NON_ENTITY_SEGMENTS: ReadonlySet<string> = new Set(['new']);\n\n/** Ids are opaque, but they are path segments: no separators, no whitespace, bounded length. */\nconst ENTITY_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;\n\n/** Tab names are short identifiers; anything else is ignored rather than forwarded. */\nconst TAB_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;\n\nfunction decodeSegment(segment: string): string | undefined {\n try {\n return decodeURIComponent(segment);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve the entity the user is looking at from the router location.\n *\n * `pathname` is the full browser path; the Subscriber Bot routes live under\n * `/subscriberbot`. Anything that is not an entity route resolves to an empty\n * entity, so the agent asks rather than acting on a guessed id.\n */\nexport function resolveSubscriberBotConversationContext(\n pathname: string,\n search: string\n): ConversationContextShape {\n const segments = pathname.split('/').filter(Boolean);\n const root = segments.indexOf('subscriberbot');\n const rest = root === -1 ? [] : segments.slice(root + 1);\n\n const tabParam = new URLSearchParams(search).get('tab');\n const activeTab = tabParam && TAB_PATTERN.test(tabParam) ? tabParam : undefined;\n\n if (rest.length === 3) {\n const [section, rawId, subview] = rest as [string, string, string];\n const route = ENTITY_ROUTES.find(([segment]) => segment === section);\n const id = decodeSegment(rawId);\n if (route && id && ENTITY_SUBVIEWS.get(section)?.has(subview) && ENTITY_ID_PATTERN.test(id)) {\n return { entityType: route[1], entityId: id, activeTab: subview };\n }\n }\n\n if (rest.length === 2) {\n const [section, rawId] = rest as [string, string];\n const route = ENTITY_ROUTES.find(([segment]) => segment === section);\n const id = decodeSegment(rawId);\n if (route && id && !NON_ENTITY_SEGMENTS.has(id) && ENTITY_ID_PATTERN.test(id)) {\n return { entityType: route[1], entityId: id, ...(activeTab ? { activeTab } : {}) };\n }\n }\n\n return activeTab ? { activeTab } : {};\n}\n\nexport function gatherPageContext(): PageContext {\n const { href, pathname, search } = window.location;\n const currentPage = pathname.split('/').filter(Boolean).slice(0, 3).join('/') || 'home';\n const entity = resolveSubscriberBotConversationContext(pathname, search);\n\n return {\n currentUrl: href,\n currentPage,\n ...(entity.entityType && entity.entityId\n ? { entityType: entity.entityType, entityId: entity.entityId }\n : {}),\n ...(entity.activeTab ? { activeTab: entity.activeTab } : {}),\n platform: 'subscriberbot',\n version: import.meta.env.VITE_APP_VERSION ?? '2026.615.1',\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n };\n}\n"],"mappings":";AA4CA,IAAaA,IAA6B;CACxC,cAAc;CACd,UAAU;CACV,OAAO;CACP,UAAU;CACV,cAAc;CACd,UAAU;AACZ,GAwBMC,IAA0F;CAC9F,CAAC,iBAAiBD,EAA2B,YAAY;CACzD,CAAC,aAAaA,EAA2B,QAAQ;CACjD,CAAC,UAAUA,EAA2B,KAAK;CAC3C,CAAC,aAAaA,EAA2B,QAAQ;CACjD,CAAC,SAASA,EAA2B,YAAY;CACjD,CAAC,aAAaA,EAA2B,QAAQ;AACnD,GAMME,oBAA4D,IAAI,IAAI,CACxE,CAAC,6BAAa,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CACpC,CAAC,GAGKC,oBAA2C,IAAI,IAAI,CAAC,KAAK,CAAC,GAG1DC,IAAoB,0BAGpBC,IAAc;AAEpB,SAASC,EAAc,GAAqC;CAC1D,IAAI;EACF,OAAO,mBAAmBC,CAAO;CACnC,QAAQ;EACN;CACF;AACF;AASA,SAAgBC,EACd,GACA,GAC0B;CAC1B,IAAMC,IAAWC,EAAS,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,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,EAAO;GAAY,UAAUA,EAAO;EAAS,IAC3D,CAAC;EACL,GAAIA,EAAO,YAAY,EAAE,WAAWA,EAAO,UAAU,IAAI,CAAC;EAC1D,UAAU;EACV,SAA6C;EAC7C,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO;CAC/C;AACF"}
@@ -1,35 +1,34 @@
1
- //#region src/subscriberbot/utils/plaidLink.ts
2
- var e = "https://cdn.plaid.com/link/v2/stable/link-initialize.js", t = (e, t) => t, n = null;
3
- function r(t) {
4
- return window.Plaid ? Promise.resolve(window.Plaid) : n || (n = new Promise((r, i) => {
5
- let a = document.createElement("script");
6
- a.src = e, a.async = !0, a.onload = () => {
7
- window.Plaid ? r(window.Plaid) : i(Error(t("banking.link.error.initialize", "Plaid Link did not initialise")));
8
- }, a.onerror = () => {
9
- n = null, a.remove(), i(Error(t("banking.link.error.load", "Plaid Link could not be loaded")));
10
- }, document.head.appendChild(a);
11
- }), n);
1
+ // src/subscriberbot/utils/plaidLink.ts
2
+ var e = (e, t) => t, t = null;
3
+ function n(e) {
4
+ return window.Plaid ? Promise.resolve(window.Plaid) : t || (t = new Promise((n, r) => {
5
+ let i = document.createElement("script");
6
+ i.src = "https://cdn.plaid.com/link/v2/stable/link-initialize.js", i.async = !0, i.onload = () => {
7
+ window.Plaid ? n(window.Plaid) : r(Error(e("banking.link.error.initialize", "Plaid Link did not initialise")));
8
+ }, i.onerror = () => {
9
+ t = null, i.remove(), r(Error(e("banking.link.error.load", "Plaid Link could not be loaded")));
10
+ }, document.head.appendChild(i);
11
+ }), t);
12
12
  }
13
- async function i(e, n = t) {
14
- let i = await r(n);
15
- return new Promise((t, r) => {
13
+ async function r(t, r = e) {
14
+ let i = await n(r);
15
+ return new Promise((e, n) => {
16
16
  let a = i.create({
17
- token: e,
18
- onSuccess: (e, n) => {
19
- a.destroy(), t({
20
- publicToken: e,
17
+ token: t,
18
+ onSuccess: (t, n) => {
19
+ a.destroy(), e({
20
+ publicToken: t,
21
21
  institutionId: n.institution?.institution_id ?? null,
22
22
  institutionName: n.institution?.name ?? null
23
23
  });
24
24
  },
25
- onExit: (e) => {
26
- a.destroy(), e ? r(Error(e.display_message || e.error_message || n("banking.link.error.failed", "Plaid Link failed"))) : t(null);
25
+ onExit: (t) => {
26
+ a.destroy(), t ? n(Error(t.display_message || t.error_message || r("banking.link.error.failed", "Plaid Link failed"))) : e(null);
27
27
  }
28
28
  });
29
29
  a.open();
30
30
  });
31
31
  }
32
- //#endregion
33
- export { i as openPlaidLink };
32
+ export { r as openPlaidLink };
34
33
 
35
34
  //# sourceMappingURL=plaidLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plaidLink.js","names":[],"sources":["../../../src/subscriberbot/utils/plaidLink.ts"],"sourcesContent":["/**\n * Plaid Link loader (BOFF-4161)\n * @module subscriberbot/utils\n *\n * Plaid requires Link to be loaded from its own CDN (it cannot be bundled),\n * so the script is injected on first use only. Bank credentials are typed\n * into Plaid's hosted iframe and never touch Subscriber Bot; Link hands back\n * a one-time public token that the service exchanges server side.\n */\n\nconst PLAID_LINK_SRC = 'https://cdn.plaid.com/link/v2/stable/link-initialize.js';\n\nexport interface PlaidLinkSuccessMetadata {\n institution?: { name?: string | null; institution_id?: string | null } | null;\n}\n\ninterface PlaidLinkHandler {\n open: () => void;\n destroy: () => void;\n}\n\ninterface PlaidGlobal {\n create: (config: {\n token: string;\n onSuccess: (publicToken: string, metadata: PlaidLinkSuccessMetadata) => void;\n onExit: (\n error: { display_message?: string | null; error_message?: string | null } | null\n ) => void;\n }) => PlaidLinkHandler;\n}\n\ndeclare global {\n interface Window {\n Plaid?: PlaidGlobal;\n }\n}\n\ntype Translate = (key: string, fallback: string) => string;\nconst fallbackText: Translate = (_key, fallback) => fallback;\n\nlet loading: Promise<PlaidGlobal> | null = null;\n\nfunction loadPlaid(tr: Translate): Promise<PlaidGlobal> {\n if (window.Plaid) return Promise.resolve(window.Plaid);\n if (loading) return loading;\n loading = new Promise<PlaidGlobal>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = PLAID_LINK_SRC;\n script.async = true;\n script.onload = () => {\n if (window.Plaid) resolve(window.Plaid);\n else reject(new Error(tr('banking.link.error.initialize', 'Plaid Link did not initialise')));\n };\n script.onerror = () => {\n loading = null;\n script.remove();\n reject(new Error(tr('banking.link.error.load', 'Plaid Link could not be loaded')));\n };\n document.head.appendChild(script);\n });\n return loading;\n}\n\nexport interface PlaidLinkResult {\n publicToken: string;\n institutionId: string | null;\n institutionName: string | null;\n}\n\n/**\n * Open Plaid Link with a link token. Resolves with the public token when the\n * customer finishes, resolves `null` when they close Link, and rejects when\n * Link reports an error.\n */\nexport async function openPlaidLink(\n linkToken: string,\n tr: Translate = fallbackText\n): Promise<PlaidLinkResult | null> {\n const plaid = await loadPlaid(tr);\n return new Promise<PlaidLinkResult | null>((resolve, reject) => {\n const handler = plaid.create({\n token: linkToken,\n onSuccess: (publicToken, metadata) => {\n handler.destroy();\n resolve({\n publicToken,\n institutionId: metadata.institution?.institution_id ?? null,\n institutionName: metadata.institution?.name ?? null,\n });\n },\n onExit: (error) => {\n handler.destroy();\n if (error)\n reject(\n new Error(\n error.display_message ||\n error.error_message ||\n tr('banking.link.error.failed', 'Plaid Link failed')\n )\n );\n else resolve(null);\n },\n });\n handler.open();\n });\n}\n"],"mappings":";AAUA,IAAM,IAAiB,2DA4BjB,KAA2B,GAAM,MAAa,GAEhD,IAAuC;AAE3C,SAAS,EAAU,GAAqC;CAkBtD,OAjBI,OAAO,QAAc,QAAQ,QAAQ,OAAO,KAAK,IACjD,MACJ,IAAU,IAAI,SAAsB,GAAS,MAAW;EACtD,IAAM,IAAS,SAAS,cAAc,QAAQ;EAY9C,AAXA,EAAO,MAAM,GACb,EAAO,QAAQ,IACf,EAAO,eAAe;GACpB,AAAI,OAAO,QAAO,EAAQ,OAAO,KAAK,IACjC,EAAW,MAAM,EAAG,iCAAiC,+BAA+B,CAAC,CAAC;EAC7F,GACA,EAAO,gBAAgB;GAGrB,AAFA,IAAU,MACV,EAAO,OAAO,GACd,EAAW,MAAM,EAAG,2BAA2B,gCAAgC,CAAC,CAAC;EACnF,GACA,SAAS,KAAK,YAAY,CAAM;CAClC,CAAC,GACM;AACT;AAaA,eAAsB,EACpB,GACA,IAAgB,GACiB;CACjC,IAAM,IAAQ,MAAM,EAAU,CAAE;CAChC,OAAO,IAAI,SAAiC,GAAS,MAAW;EAC9D,IAAM,IAAU,EAAM,OAAO;GAC3B,OAAO;GACP,YAAY,GAAa,MAAa;IAEpC,AADA,EAAQ,QAAQ,GAChB,EAAQ;KACN;KACA,eAAe,EAAS,aAAa,kBAAkB;KACvD,iBAAiB,EAAS,aAAa,QAAQ;IACjD,CAAC;GACH;GACA,SAAS,MAAU;IAEjB,AADA,EAAQ,QAAQ,GACZ,IACF,EACM,MACF,EAAM,mBACJ,EAAM,iBACN,EAAG,6BAA6B,mBAAmB,CACvD,CACF,IACG,EAAQ,IAAI;GACnB;EACF,CAAC;EACD,EAAQ,KAAK;CACf,CAAC;AACH"}
1
+ {"version":3,"file":"plaidLink.js","names":["fallbackText","fallback","loading","loadPlaid","script","resolve","reject","tr","openPlaidLink","plaid","handler","linkToken","metadata","error"],"sources":["../../../src/subscriberbot/utils/plaidLink.ts"],"sourcesContent":["/**\n * Plaid Link loader (BOFF-4161)\n * @module subscriberbot/utils\n *\n * Plaid requires Link to be loaded from its own CDN (it cannot be bundled),\n * so the script is injected on first use only. Bank credentials are typed\n * into Plaid's hosted iframe and never touch Subscriber Bot; Link hands back\n * a one-time public token that the service exchanges server side.\n */\n\nconst PLAID_LINK_SRC = 'https://cdn.plaid.com/link/v2/stable/link-initialize.js';\n\nexport interface PlaidLinkSuccessMetadata {\n institution?: { name?: string | null; institution_id?: string | null } | null;\n}\n\ninterface PlaidLinkHandler {\n open: () => void;\n destroy: () => void;\n}\n\ninterface PlaidGlobal {\n create: (config: {\n token: string;\n onSuccess: (publicToken: string, metadata: PlaidLinkSuccessMetadata) => void;\n onExit: (\n error: { display_message?: string | null; error_message?: string | null } | null\n ) => void;\n }) => PlaidLinkHandler;\n}\n\ndeclare global {\n interface Window {\n Plaid?: PlaidGlobal;\n }\n}\n\ntype Translate = (key: string, fallback: string) => string;\nconst fallbackText: Translate = (_key, fallback) => fallback;\n\nlet loading: Promise<PlaidGlobal> | null = null;\n\nfunction loadPlaid(tr: Translate): Promise<PlaidGlobal> {\n if (window.Plaid) return Promise.resolve(window.Plaid);\n if (loading) return loading;\n loading = new Promise<PlaidGlobal>((resolve, reject) => {\n const script = document.createElement('script');\n script.src = PLAID_LINK_SRC;\n script.async = true;\n script.onload = () => {\n if (window.Plaid) resolve(window.Plaid);\n else reject(new Error(tr('banking.link.error.initialize', 'Plaid Link did not initialise')));\n };\n script.onerror = () => {\n loading = null;\n script.remove();\n reject(new Error(tr('banking.link.error.load', 'Plaid Link could not be loaded')));\n };\n document.head.appendChild(script);\n });\n return loading;\n}\n\nexport interface PlaidLinkResult {\n publicToken: string;\n institutionId: string | null;\n institutionName: string | null;\n}\n\n/**\n * Open Plaid Link with a link token. Resolves with the public token when the\n * customer finishes, resolves `null` when they close Link, and rejects when\n * Link reports an error.\n */\nexport async function openPlaidLink(\n linkToken: string,\n tr: Translate = fallbackText\n): Promise<PlaidLinkResult | null> {\n const plaid = await loadPlaid(tr);\n return new Promise<PlaidLinkResult | null>((resolve, reject) => {\n const handler = plaid.create({\n token: linkToken,\n onSuccess: (publicToken, metadata) => {\n handler.destroy();\n resolve({\n publicToken,\n institutionId: metadata.institution?.institution_id ?? null,\n institutionName: metadata.institution?.name ?? null,\n });\n },\n onExit: (error) => {\n handler.destroy();\n if (error)\n reject(\n new Error(\n error.display_message ||\n error.error_message ||\n tr('banking.link.error.failed', 'Plaid Link failed')\n )\n );\n else resolve(null);\n },\n });\n handler.open();\n });\n}\n"],"mappings":";AAUA,IA4BMA,KAA2B,GAAM,MAAaC,GAEhDC,IAAuC;AAE3C,SAASC,EAAU,GAAqC;CAkBtD,OAjBI,OAAO,QAAc,QAAQ,QAAQ,OAAO,KAAK,IACjDD,MACJ,IAAU,IAAI,SAAsB,GAAS,MAAW;EACtD,IAAME,IAAS,SAAS,cAAc,QAAQ;EAY9C,AAXA,EAAO,MAAM,2DACb,EAAO,QAAQ,IACf,EAAO,eAAe;GACpB,AAAI,OAAO,QAAOC,EAAQ,OAAO,KAAK,IACjCC,EAAW,MAAMC,EAAG,iCAAiC,+BAA+B,CAAC,CAAC;EAC7F,GACA,EAAO,gBAAgB;GAGrB,AAFA,IAAU,MACVH,EAAO,OAAO,GACdE,EAAW,MAAMC,EAAG,2BAA2B,gCAAgC,CAAC,CAAC;EACnF,GACA,SAAS,KAAK,YAAYH,CAAM;CAClC,CAAC,GACMF;AACT;AAaA,eAAsBM,EACpB,GACA,IAAgBR,GACiB;CACjC,IAAMS,IAAQ,MAAMN,EAAUI,CAAE;CAChC,OAAO,IAAI,SAAiC,GAAS,MAAW;EAC9D,IAAMG,IAAUD,EAAM,OAAO;GAC3B,OAAOE;GACP,YAAY,GAAa,MAAa;IAEpC,AADAD,EAAQ,QAAQ,GAChBL,EAAQ;KACN;KACA,eAAeO,EAAS,aAAa,kBAAkB;KACvD,iBAAiBA,EAAS,aAAa,QAAQ;IACjD,CAAC;GACH;GACA,SAAS,MAAU;IAEjB,AADAF,EAAQ,QAAQ,GACZG,IACFP,EACM,MACFO,EAAM,mBACJA,EAAM,iBACNN,EAAG,6BAA6B,mBAAmB,CACvD,CACF,IACGF,EAAQ,IAAI;GACnB;EACF,CAAC;EACD,EAAQ,KAAK;CACf,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
- //#region src/subscriberbot/utils/portfolio.ts
2
- var e = 1e3 * 60 * 60 * 24, t = {
1
+ // src/subscriberbot/utils/portfolio.ts
2
+ var e = 864e5, t = {
3
3
  DAILY: 30,
4
4
  WEEKLY: 4.345,
5
5
  MONTHLY: 1,
@@ -8,11 +8,11 @@ var e = 1e3 * 60 * 60 * 24, t = {
8
8
  LIFETIME: 0,
9
9
  FREE: 0,
10
10
  USAGE_BASED: 1
11
- }, n = new Set([
11
+ }, n = /* @__PURE__ */ new Set([
12
12
  "ACTIVE",
13
13
  "TRIAL",
14
14
  "PAST_DUE"
15
- ]), r = new Set(["ACTIVE", "TRIAL"]);
15
+ ]), r = /* @__PURE__ */ new Set(["ACTIVE", "TRIAL"]);
16
16
  function i(e) {
17
17
  return e.amount * (t[e.interval] ?? 1);
18
18
  }
@@ -154,7 +154,6 @@ function h(e) {
154
154
  function g(e, t) {
155
155
  return e <= t;
156
156
  }
157
- //#endregion
158
- export { l as buildUpcomingRenewals, d as canTransition, o as daysUntil, g as isSwipeTrailingClick, f as quickActionsFor, a as recurringSpend, c as renewalCountdown, h as swipeClickDeadline, p as swipeOffset, m as swipeSettlesOpen };
157
+ export { t as MONTHLY_FACTOR, e as MS_PER_DAY, u as RELATIONSHIP_TRANSITIONS, l as buildUpcomingRenewals, d as canTransition, o as daysUntil, g as isSwipeTrailingClick, i as monthlyAmount, f as quickActionsFor, a as recurringSpend, c as renewalCountdown, h as swipeClickDeadline, p as swipeOffset, m as swipeSettlesOpen };
159
158
 
160
159
  //# sourceMappingURL=portfolio.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"portfolio.js","names":[],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n/**\n * Statuses that still renew. A cancelled, expired, lapsed or paused\n * relationship has no upcoming charge, even if it keeps an old `renewsAt`\n * or the renewal stream still holds an event for it.\n */\nconst RENEWING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n 'PAST_DUE',\n]);\n\n/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Calendar days from today until `date`, in the viewer's local time zone:\n * 0 is \"today\", 1 is \"tomorrow\", negative is overdue. Counting calendar days\n * (not 24-hour blocks) matters for renewals stored at midnight UTC: one due\n * tomorrow used to read \"Renews today\" for most of the day before\n * (BOFF-4010). Null when the date is missing or unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n return calendarDay(t) - calendarDay(now);\n}\n\n/**\n * The local calendar date of `ms` as a whole-day ordinal. Local Y/M/D are\n * re-read as a UTC date so daylight-saving shifts never leave a fraction.\n */\nfunction calendarDay(ms: number): number {\n const d = new Date(ms);\n return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. A relationship's renewal event wins over\n * its own `renewsAt`; a relationship with no event is still listed from its\n * future `renewsAt`, so tracking a new subscription shows what renews next\n * even when other relationships already have renewal events.\n * `fallbackTitle` names an event whose relationship is not in the page.\n * Relationships that no longer renew (cancelled, expired, lapsed, paused) are\n * left out of both sources.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n // An event whose relationship is not in the page is kept: its status is\n // unknown here, and the renewal stream is the better source.\n const renews = (relationshipId: string) => {\n const rel = byId.get(relationshipId);\n return !rel || RENEWING_STATUSES.has(rel.status);\n };\n\n const fromEvents: UpcomingRenewal[] = events\n .filter((e) => !Number.isNaN(time(e.occursAt)) && renews(e.relationshipId))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n });\n\n // Fall back per relationship, not per page: one relationship's event must\n // not hide the relationships that have no event yet.\n const covered = new Set(fromEvents.map((e) => e.relationshipId));\n const fromRelationships: UpcomingRenewal[] = relationships\n .filter((r) => {\n if (covered.has(r.id)) return false;\n if (!r.renewsAt || !RENEWING_STATUSES.has(r.status)) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n });\n\n return [...fromEvents, ...fromRelationships].sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAa,IAAa,MAAO,KAAK,KAAK,IAW9B,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAOM,IAAwD,IAAI,IAA2B;CAC3F;CACA;CACA;AACF,CAAC,GAGK,IAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgB,EAAc,GAAoE;CAChG,OAAO,EAAa,UAAU,EAAe,EAAa,aAAa;AACzE;AAYA,SAAgB,EACd,GACgB;CAChB,IAAM,IAAS,EAAc,QAAQ,MAAM,EAAiB,IAAI,EAAE,MAAM,CAAC;CACzE,OAAO;EACL,SAAS,EAAO,QAAQ,GAAK,MAAM,IAAM,EAAc,CAAC,GAAG,CAAC;EAC5D,UAAU,EAAO,IAAI,YAAY,EAAc,IAAI,YAAY;EAC/D,aAAa,EAAO;CACtB;AACF;AASA,SAAgB,EACd,GACA,IAAc,KAAK,IAAI,GACR;CACf,IAAI,CAAC,GAAM,OAAO;CAClB,IAAM,IAAI,IAAI,KAAK,CAAI,EAAE,QAAQ;CAEjC,OADI,OAAO,MAA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;EACtC,QAAQ;EACR,aAAa;CACf,CAAC,GAEC,EAAc,GAAQ,QAAQ,KAChC,EAAQ,KAAK;EAAE,IAAI;EAAS,QAAQ;EAAU,aAAa;CAAM,CAAC,GAEhE,EAAc,GAAQ,WAAW,KACnC,EAAQ,KAAK;EAAE,IAAI;EAAU,QAAQ;EAAa,aAAa;CAAK,CAAC,GAEhE;AACT;AAOA,SAAgB,EAAY,GAAY,GAAkB,GAA6B;CACrF,IAAM,IAAO,IAAU,CAAC,IAAc;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,GAAa,IAAO,CAAE,CAAC;AACtD;AAMA,SAAgB,EAAiB,GAAgB,GAA8B;CAC7E,OAAO,IAAc,KAAK,CAAC,KAAU,IAAc;AACrD;AAYA,SAAgB,EAAmB,GAAyB;CAC1D,OAAO,IAAA;AACT;AAGA,SAAgB,EAAqB,GAAa,GAA2B;CAC3E,OAAO,KAAO;AAChB"}
1
+ {"version":3,"file":"portfolio.js","names":["MS_PER_DAY","MONTHLY_FACTOR","RENEWING_STATUSES","BILLING_STATUSES","monthlyAmount","relationship","recurringSpend","active","relationships","r","sum","daysUntil","date","t","calendarDay","now","d","ms","renewalCountdown","days","buildUpcomingRenewals","byId","soonCutoff","time","iso","renews","rel","relationshipId","fromEvents","events","fallbackTitle","covered","fromRelationships","when","a","b","RELATIONSHIP_TRANSITIONS","canTransition","from","to","quickActionsFor","actions","status","swipeOffset","base","wasOpen","revealWidth","dx","swipeSettlesOpen","offset","swipeClickDeadline","endedAt","isSwipeTrailingClick","deadline"],"sources":["../../../src/subscriberbot/utils/portfolio.ts"],"sourcesContent":["/**\n * Portfolio model shared by the desktop and mobile Subscriber Bot screens\n * @module subscriberbot/utils/portfolio\n *\n * Pure functions only (no React, no DOM) so the overview, the relationship\n * list and the relationship detail page compute spend, renewals and lifecycle\n * actions the same way at every viewport. Unit-tested in `portfolio.test.ts`.\n */\n\nimport type {\n SubBillingInterval,\n SubRelationship,\n SubRelationshipStatus,\n SubRenewalEvent,\n} from '../types';\n\nexport const MS_PER_DAY = 1000 * 60 * 60 * 24;\n\n/** Renewals inside this window are flagged as \"soon\". */\nexport const SOON_WINDOW_DAYS = 7;\n\n/**\n * Approximate monthly multiplier per billing interval, so total recurring\n * spend can be expressed as one comparable \"per month\" number. Usage-based\n * relationships count at their last known amount; free and lifetime ones\n * do not recur.\n */\nexport const MONTHLY_FACTOR: Record<SubBillingInterval, number> = {\n DAILY: 30,\n WEEKLY: 4.345,\n MONTHLY: 1,\n QUARTERLY: 1 / 3,\n YEARLY: 1 / 12,\n LIFETIME: 0,\n FREE: 0,\n USAGE_BASED: 1,\n};\n\n/**\n * Statuses that still renew. A cancelled, expired, lapsed or paused\n * relationship has no upcoming charge, even if it keeps an old `renewsAt`\n * or the renewal stream still holds an event for it.\n */\nconst RENEWING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n 'PAST_DUE',\n]);\n\n/** Statuses that are still being billed. */\nconst BILLING_STATUSES: ReadonlySet<SubRelationshipStatus> = new Set<SubRelationshipStatus>([\n 'ACTIVE',\n 'TRIAL',\n]);\n\n/** The relationship's cost normalised to one month. */\nexport function monthlyAmount(relationship: Pick<SubRelationship, 'amount' | 'interval'>): number {\n return relationship.amount * (MONTHLY_FACTOR[relationship.interval] ?? 1);\n}\n\nexport interface RecurringSpend {\n /** Sum of `monthlyAmount` over ACTIVE + TRIAL relationships. */\n monthly: number;\n /** Currency of the first billing relationship (portfolio display currency). */\n currency: string;\n /** Number of relationships that are still billing. */\n activeCount: number;\n}\n\n/** Total monthly recurring spend over the relationships that still bill. */\nexport function recurringSpend(\n relationships: readonly Pick<SubRelationship, 'amount' | 'interval' | 'status' | 'currency'>[]\n): RecurringSpend {\n const active = relationships.filter((r) => BILLING_STATUSES.has(r.status));\n return {\n monthly: active.reduce((sum, r) => sum + monthlyAmount(r), 0),\n currency: active[0]?.currency ?? relationships[0]?.currency ?? 'USD',\n activeCount: active.length,\n };\n}\n\n/**\n * Calendar days from today until `date`, in the viewer's local time zone:\n * 0 is \"today\", 1 is \"tomorrow\", negative is overdue. Counting calendar days\n * (not 24-hour blocks) matters for renewals stored at midnight UTC: one due\n * tomorrow used to read \"Renews today\" for most of the day before\n * (BOFF-4010). Null when the date is missing or unparseable.\n */\nexport function daysUntil(\n date: string | null | undefined,\n now: number = Date.now()\n): number | null {\n if (!date) return null;\n const t = new Date(date).getTime();\n if (Number.isNaN(t)) return null;\n return calendarDay(t) - calendarDay(now);\n}\n\n/**\n * The local calendar date of `ms` as a whole-day ordinal. Local Y/M/D are\n * re-read as a UTC date so daylight-saving shifts never leave a fraction.\n */\nfunction calendarDay(ms: number): number {\n const d = new Date(ms);\n return Math.round(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_PER_DAY);\n}\n\n/** Translation key, English fallback and params for a renewal countdown. */\nexport interface RenewalCountdown {\n key: string;\n fallback: string;\n params?: Record<string, number>;\n tone: 'overdue' | 'soon' | 'later';\n}\n\nexport function renewalCountdown(days: number): RenewalCountdown {\n if (days < 0) {\n return { key: 'mobile.renewal.overdue', fallback: 'Renewal overdue', tone: 'overdue' };\n }\n if (days === 0) {\n return { key: 'mobile.renewal.today', fallback: 'Renews today', tone: 'soon' };\n }\n if (days === 1) {\n return { key: 'mobile.renewal.tomorrow', fallback: 'Renews tomorrow', tone: 'soon' };\n }\n return {\n key: 'mobile.renewal.inDays',\n fallback: 'Renews in {{count}} days',\n params: { count: days },\n tone: days <= SOON_WINDOW_DAYS ? 'soon' : 'later',\n };\n}\n\n/** One normalised \"what charges next\" row. */\nexport interface UpcomingRenewal {\n id: string;\n relationshipId: string;\n title: string;\n when: string;\n amount: number | null;\n currency: string | null;\n interval: SubBillingInterval | null;\n kind: SubRelationship['kind'] | null;\n soon: boolean;\n}\n\n/**\n * Upcoming renewals, soonest first. A relationship's renewal event wins over\n * its own `renewsAt`; a relationship with no event is still listed from its\n * future `renewsAt`, so tracking a new subscription shows what renews next\n * even when other relationships already have renewal events.\n * `fallbackTitle` names an event whose relationship is not in the page.\n * Relationships that no longer renew (cancelled, expired, lapsed, paused) are\n * left out of both sources.\n */\nexport function buildUpcomingRenewals(\n relationships: readonly SubRelationship[],\n events: readonly SubRenewalEvent[],\n fallbackTitle: (eventType: string) => string,\n now: number = Date.now()\n): UpcomingRenewal[] {\n const byId = new Map<string, SubRelationship>();\n relationships.forEach((r) => byId.set(r.id, r));\n const soonCutoff = now + SOON_WINDOW_DAYS * MS_PER_DAY;\n const time = (iso: string) => new Date(iso).getTime();\n\n // An event whose relationship is not in the page is kept: its status is\n // unknown here, and the renewal stream is the better source.\n const renews = (relationshipId: string) => {\n const rel = byId.get(relationshipId);\n return !rel || RENEWING_STATUSES.has(rel.status);\n };\n\n const fromEvents: UpcomingRenewal[] = events\n .filter((e) => !Number.isNaN(time(e.occursAt)) && renews(e.relationshipId))\n .map((e) => {\n const rel = byId.get(e.relationshipId);\n return {\n id: e.id,\n relationshipId: e.relationshipId,\n title: rel?.label ?? fallbackTitle(e.eventType),\n when: e.occursAt,\n amount: e.amount ?? rel?.amount ?? null,\n currency: e.currency ?? rel?.currency ?? null,\n interval: rel?.interval ?? null,\n kind: rel?.kind ?? null,\n soon: time(e.occursAt) <= soonCutoff,\n };\n });\n\n // Fall back per relationship, not per page: one relationship's event must\n // not hide the relationships that have no event yet.\n const covered = new Set(fromEvents.map((e) => e.relationshipId));\n const fromRelationships: UpcomingRenewal[] = relationships\n .filter((r) => {\n if (covered.has(r.id)) return false;\n if (!r.renewsAt || !RENEWING_STATUSES.has(r.status)) return false;\n const t = time(r.renewsAt);\n return !Number.isNaN(t) && t >= now;\n })\n .map((r) => {\n const when = r.renewsAt as string;\n return {\n id: r.id,\n relationshipId: r.id,\n title: r.label,\n when,\n amount: r.amount,\n currency: r.currency,\n interval: r.interval,\n kind: r.kind,\n soon: time(when) <= soonCutoff,\n };\n });\n\n return [...fromEvents, ...fromRelationships].sort((a, b) => time(a.when) - time(b.when));\n}\n\n/**\n * Lifecycle state machine — mirrors `RELATIONSHIP_TRANSITIONS` in\n * wspace-subscriberbot-svc (relationships.service.ts). The server stays the\n * authority and re-validates every transition; this copy only decides which\n * actions are worth offering so the UI never shows a button that is certain\n * to fail.\n */\nexport const RELATIONSHIP_TRANSITIONS: Record<\n SubRelationshipStatus,\n readonly SubRelationshipStatus[]\n> = {\n TRIAL: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n ACTIVE: ['PAUSED', 'PAST_DUE', 'CANCELLED', 'EXPIRED'],\n PAUSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n PAST_DUE: ['ACTIVE', 'LAPSED', 'CANCELLED'],\n LAPSED: ['ACTIVE', 'CANCELLED', 'EXPIRED'],\n CANCELLED: [],\n EXPIRED: [],\n};\n\nexport function canTransition(from: SubRelationshipStatus, to: SubRelationshipStatus): boolean {\n return RELATIONSHIP_TRANSITIONS[from]?.includes(to) ?? false;\n}\n\nexport type QuickActionId = 'activate' | 'resume' | 'pause' | 'cancel';\n\nexport interface QuickAction {\n id: QuickActionId;\n /** Status the relationship moves to. CANCELLED goes through subCancelRelationship. */\n target: SubRelationshipStatus;\n /** Destructive actions ask for confirmation first. */\n destructive: boolean;\n}\n\n/**\n * The everyday actions a phone user reaches for from a list row or the\n * detail page — start, pause/resume, cancel — filtered to what the state\n * machine allows from `status`. Rarer bookkeeping transitions (mark expired,\n * past due, lapsed) stay on the desktop detail page.\n */\nexport function quickActionsFor(status: SubRelationshipStatus): QuickAction[] {\n const actions: QuickAction[] = [];\n if (canTransition(status, 'ACTIVE')) {\n actions.push({\n id: status === 'TRIAL' ? 'activate' : 'resume',\n target: 'ACTIVE',\n destructive: false,\n });\n }\n if (canTransition(status, 'PAUSED')) {\n actions.push({ id: 'pause', target: 'PAUSED', destructive: false });\n }\n if (canTransition(status, 'CANCELLED')) {\n actions.push({ id: 'cancel', target: 'CANCELLED', destructive: true });\n }\n return actions;\n}\n\n/**\n * Swipe-to-reveal geometry for a list row. `dx` is the horizontal drag\n * distance (negative = towards the left). Returns the clamped row offset\n * while dragging.\n */\nexport function swipeOffset(dx: number, wasOpen: boolean, revealWidth: number): number {\n const base = wasOpen ? -revealWidth : 0;\n return Math.min(0, Math.max(-revealWidth, base + dx));\n}\n\n/**\n * Whether the row should settle open once the finger lifts: past half the\n * action tray it snaps open, otherwise it snaps shut.\n */\nexport function swipeSettlesOpen(offset: number, revealWidth: number): boolean {\n return revealWidth > 0 && -offset >= revealWidth / 2;\n}\n\n/**\n * How long after a swipe ends the browser's trailing synthetic click is\n * treated as part of the gesture. Browsers dispatch it immediately after\n * `pointerup`, so a short window is enough; a real tap that follows later is\n * never swallowed, and a cancelled swipe (no click at all) leaves nothing\n * pending.\n */\nexport const SWIPE_CLICK_WINDOW_MS = 400;\n\n/** Deadline until which a click counts as the swipe's own trailing click. */\nexport function swipeClickDeadline(endedAt: number): number {\n return endedAt + SWIPE_CLICK_WINDOW_MS;\n}\n\n/** Whether a click at `now` is the trailing click of a swipe ending by `deadline`. */\nexport function isSwipeTrailingClick(now: number, deadline: number): boolean {\n return now <= deadline;\n}\n"],"mappings":";AAgBA,IAAaA,IAAa,OAWbC,IAAqD;CAChE,OAAO;CACP,QAAQ;CACR,SAAS;CACT,WAAW,IAAI;CACf,QAAQ,IAAI;CACZ,UAAU;CACV,MAAM;CACN,aAAa;AACf,GAOMC,oBAAwD,IAAI,IAA2B;CAC3F;CACA;CACA;AACF,CAAC,GAGKC,oBAAuD,IAAI,IAA2B,CAC1F,UACA,OACF,CAAC;AAGD,SAAgBC,EAAc,GAAoE;CAChG,OAAOC,EAAa,UAAUJ,EAAeI,EAAa,aAAa;AACzE;AAYA,SAAgBC,EACd,GACgB;CAChB,IAAMC,IAASC,EAAc,QAAQ,MAAML,EAAiB,IAAIM,EAAE,MAAM,CAAC;CACzE,OAAO;EACL,SAASF,EAAO,QAAQ,GAAK,MAAMG,IAAMN,EAAcK,CAAC,GAAG,CAAC;EAC5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AAQ;EAAC;EAAU;EAAa;CAAS;CACzC,UAAU;EAAC;EAAU;EAAU;CAAW;CAC1C,QAAQ;EAAC;EAAU;EAAa;CAAS;CACzC,WAAW,CAAC;CACZ,SAAS,CAAC;AACZ;AAEA,SAAgBC,EAAc,GAA6B,GAAoC;CAC7F,OAAOD,EAAyBE,EAAK,EAAE,SAASC,CAAE,KAAK;AACzD;AAkBA,SAAgBC,EAAgB,GAA8C;CAC5E,IAAMC,IAAyB,CAAC;CAchC,OAbIJ,EAAcK,GAAQ,QAAQ,KAChCD,EAAQ,KAAK;EACX,IAAIC,MAAW,UAAU,aAAa;EACtC,QAAQ;EACR,aAAa;CACf,CAAC,GAECL,EAAcK,GAAQ,QAAQ,KAChCD,EAAQ,KAAK;EAAE,IAAI;EAAS,QAAQ;EAAU,aAAa;CAAM,CAAC,GAEhEJ,EAAcK,GAAQ,WAAW,KACnCD,EAAQ,KAAK;EAAE,IAAI;EAAU,QAAQ;EAAa,aAAa;CAAK,CAAC,GAEhEA;AACT;AAOA,SAAgBE,EAAY,GAAY,GAAkB,GAA6B;CACrF,IAAMC,IAAOC,IAAU,CAACC,IAAc;CACtC,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,CAACA,GAAaF,IAAOG,CAAE,CAAC;AACtD;AAMA,SAAgBC,EAAiB,GAAgB,GAA8B;CAC7E,OAAOF,IAAc,KAAK,CAACG,KAAUH,IAAc;AACrD;AAYA,SAAgBI,EAAmB,GAAyB;CAC1D,OAAOC,IAAA;AACT;AAGA,SAAgBC,EAAqB,GAAa,GAA2B;CAC3E,OAAOrC,KAAOsC;AAChB"}
@@ -1,4 +1,4 @@
1
- //#region src/subscriberbot/utils/renewals.ts
1
+ // src/subscriberbot/utils/renewals.ts
2
2
  var e = 864e5, t = {
3
3
  DAILY: 1,
4
4
  WEEKLY: 7
@@ -20,7 +20,6 @@ function n(n, r, i) {
20
20
  function r(e) {
21
21
  return e.reduce((e, t) => e + Math.max(1, t.occurrenceCount), 0);
22
22
  }
23
- //#endregion
24
23
  export { r as countRenewalCharges, n as countRenewalsInWindow };
25
24
 
26
25
  //# sourceMappingURL=renewals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"renewals.js","names":[],"sources":["../../../src/subscriberbot/utils/renewals.ts"],"sourcesContent":["/**\n * Client-side helpers for the renewals & trials forecast page (BOFF-4004).\n */\nimport type { SubRenewalForecastItem } from '../types';\n\nconst DAY_MS = 86_400_000;\n\n/**\n * Days between consecutive charges for intervals that can renew more than once\n * a month. Mirrors the fixed steps the forecast uses on the backend; every other\n * interval contributes at most one renewal per forecast item.\n */\nconst FIXED_STEP_DAYS: Readonly<Record<string, number>> = {\n DAILY: 1,\n WEEKLY: 7,\n};\n\n/**\n * Number of individual renewal charges that fall in `[now, now + windowDays)`.\n *\n * A forecast item is one relationship in one calendar month, and a daily or\n * weekly plan bundles several charges into it (`occurrenceCount`, starting at\n * `renewsAt`). Counting items would undercount those plans, and summing whole\n * months would include charges outside the window, so each charge is placed on\n * its own date and counted only when it lands inside the window.\n */\nexport function countRenewalsInWindow(\n items: ReadonlyArray<Pick<SubRenewalForecastItem, 'renewsAt' | 'occurrenceCount' | 'interval'>>,\n now: number,\n windowDays: number\n): number {\n const end = now + windowDays * DAY_MS;\n let count = 0;\n for (const item of items) {\n const first = new Date(item.renewsAt).getTime();\n if (Number.isNaN(first)) continue;\n const step = FIXED_STEP_DAYS[item.interval];\n const occurrences = step ? Math.max(1, item.occurrenceCount) : 1;\n for (let k = 0; k < occurrences; k += 1) {\n const at = first + k * (step ?? 0) * DAY_MS;\n if (at >= end) break;\n if (at >= now) count += 1;\n }\n }\n return count;\n}\n\n/**\n * Number of renewal charges a set of forecast items stands for. Daily and\n * weekly items bundle several charges (`occurrenceCount`) into one row, and the\n * month total covers all of them, so the label next to it counts them too.\n */\nexport function countRenewalCharges(\n items: ReadonlyArray<Pick<SubRenewalForecastItem, 'occurrenceCount'>>\n): number {\n return items.reduce((sum, item) => sum + Math.max(1, item.occurrenceCount), 0);\n}\n"],"mappings":";AAKA,IAAM,IAAS,OAOT,IAAoD;CACxD,OAAO;CACP,QAAQ;AACV;AAWA,SAAgB,EACd,GACA,GACA,GACQ;CACR,IAAM,IAAM,IAAM,IAAa,GAC3B,IAAQ;CACZ,KAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAQ,IAAI,KAAK,EAAK,QAAQ,EAAE,QAAQ;EAC9C,IAAI,OAAO,MAAM,CAAK,GAAG;EACzB,IAAM,IAAO,EAAgB,EAAK,WAC5B,IAAc,IAAO,KAAK,IAAI,GAAG,EAAK,eAAe,IAAI;EAC/D,KAAK,IAAI,IAAI,GAAG,IAAI,GAAa,KAAK,GAAG;GACvC,IAAM,IAAK,IAAQ,KAAK,KAAQ,KAAK;GACrC,IAAI,KAAM,GAAK;GACf,AAAI,KAAM,MAAK,KAAS;EAC1B;CACF;CACA,OAAO;AACT;AAOA,SAAgB,EACd,GACQ;CACR,OAAO,EAAM,QAAQ,GAAK,MAAS,IAAM,KAAK,IAAI,GAAG,EAAK,eAAe,GAAG,CAAC;AAC/E"}
1
+ {"version":3,"file":"renewals.js","names":["DAY_MS","FIXED_STEP_DAYS","countRenewalsInWindow","end","now","windowDays","count","item","items","first","step","occurrences","k","at","countRenewalCharges","sum"],"sources":["../../../src/subscriberbot/utils/renewals.ts"],"sourcesContent":["/**\n * Client-side helpers for the renewals & trials forecast page (BOFF-4004).\n */\nimport type { SubRenewalForecastItem } from '../types';\n\nconst DAY_MS = 86_400_000;\n\n/**\n * Days between consecutive charges for intervals that can renew more than once\n * a month. Mirrors the fixed steps the forecast uses on the backend; every other\n * interval contributes at most one renewal per forecast item.\n */\nconst FIXED_STEP_DAYS: Readonly<Record<string, number>> = {\n DAILY: 1,\n WEEKLY: 7,\n};\n\n/**\n * Number of individual renewal charges that fall in `[now, now + windowDays)`.\n *\n * A forecast item is one relationship in one calendar month, and a daily or\n * weekly plan bundles several charges into it (`occurrenceCount`, starting at\n * `renewsAt`). Counting items would undercount those plans, and summing whole\n * months would include charges outside the window, so each charge is placed on\n * its own date and counted only when it lands inside the window.\n */\nexport function countRenewalsInWindow(\n items: ReadonlyArray<Pick<SubRenewalForecastItem, 'renewsAt' | 'occurrenceCount' | 'interval'>>,\n now: number,\n windowDays: number\n): number {\n const end = now + windowDays * DAY_MS;\n let count = 0;\n for (const item of items) {\n const first = new Date(item.renewsAt).getTime();\n if (Number.isNaN(first)) continue;\n const step = FIXED_STEP_DAYS[item.interval];\n const occurrences = step ? Math.max(1, item.occurrenceCount) : 1;\n for (let k = 0; k < occurrences; k += 1) {\n const at = first + k * (step ?? 0) * DAY_MS;\n if (at >= end) break;\n if (at >= now) count += 1;\n }\n }\n return count;\n}\n\n/**\n * Number of renewal charges a set of forecast items stands for. Daily and\n * weekly items bundle several charges (`occurrenceCount`) into one row, and the\n * month total covers all of them, so the label next to it counts them too.\n */\nexport function countRenewalCharges(\n items: ReadonlyArray<Pick<SubRenewalForecastItem, 'occurrenceCount'>>\n): number {\n return items.reduce((sum, item) => sum + Math.max(1, item.occurrenceCount), 0);\n}\n"],"mappings":";AAKA,IAAMA,IAAS,OAOTC,IAAoD;CACxD,OAAO;CACP,QAAQ;AACV;AAWA,SAAgBC,EACd,GACA,GACA,GACQ;CACR,IAAMC,IAAMC,IAAMC,IAAaL,GAC3BM,IAAQ;CACZ,KAAK,IAAMC,KAAQC,GAAO;EACxB,IAAMC,IAAQ,IAAI,KAAKF,EAAK,QAAQ,CAAC,CAAC,QAAQ;EAC9C,IAAI,OAAO,MAAME,CAAK,GAAG;EACzB,IAAMC,IAAOT,EAAgBM,EAAK,WAC5BI,IAAcD,IAAO,KAAK,IAAI,GAAGH,EAAK,eAAe,IAAI;EAC/D,KAAK,IAAIK,IAAI,GAAGA,IAAID,GAAa,KAAK,GAAG;GACvC,IAAME,IAAKJ,IAAQG,KAAKF,KAAQ,KAAKV;GACrC,IAAIa,KAAMV,GAAK;GACf,AAAIU,KAAMT,MAAK,KAAS;EAC1B;CACF;CACA,OAAOE;AACT;AAOA,SAAgBQ,EACd,GACQ;CACR,OAAON,EAAM,QAAQ,GAAK,MAASO,IAAM,KAAK,IAAI,GAAGR,EAAK,eAAe,GAAG,CAAC;AAC/E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-subscriberbot",
3
- "version": "2026.1107.8",
3
+ "version": "2026.1110.1",
4
4
  "description": "Burdenoff SubscriberBot Microfrontend",
5
5
  "type": "module",
6
6
  "files": [
@@ -92,7 +92,7 @@
92
92
  "tailwindcss": "^4.0.0",
93
93
  "typescript": "^5.9.0",
94
94
  "typescript-eslint": "^8.46.0",
95
- "vite": "8.0.16",
95
+ "vite": "8.3.5",
96
96
  "vite-plugin-dts": "3.9.1"
97
97
  },
98
98
  "peerDependencies": {