@arbidocs/blocks 0.4.158 → 0.4.159

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 (172) hide show
  1. package/dist/{ConnectedNativeDocxComparison-64RDIFEI.cjs → ConnectedNativeDocxComparison-R6RU5TZE.cjs} +12 -11
  2. package/dist/{ConnectedNativeDocxComparison-64RDIFEI.cjs.map → ConnectedNativeDocxComparison-R6RU5TZE.cjs.map} +1 -1
  3. package/dist/{ConnectedStreamedWordArtifact-GYBCBAJZ.js → ConnectedNativeDocxComparison-XMZ5KLD4.js} +11 -10
  4. package/dist/{ConnectedStreamedWordArtifact-GYBCBAJZ.js.map → ConnectedNativeDocxComparison-XMZ5KLD4.js.map} +1 -1
  5. package/dist/{ConnectedNativeDocxEditor-UAAICR4X.cjs → ConnectedNativeDocxEditor-LBATSM3M.cjs} +11 -10
  6. package/dist/{ConnectedNativeDocxEditor-UAAICR4X.cjs.map → ConnectedNativeDocxEditor-LBATSM3M.cjs.map} +1 -1
  7. package/dist/{ConnectedNativeDocxEditor-OT5DLWCM.js → ConnectedNativeDocxEditor-NGUK2AX6.js} +9 -8
  8. package/dist/{ConnectedNativeDocxEditor-OT5DLWCM.js.map → ConnectedNativeDocxEditor-NGUK2AX6.js.map} +1 -1
  9. package/dist/{ConnectedStreamedWordArtifact-AJXPNTT3.cjs → ConnectedStreamedWordArtifact-CWFR6A37.cjs} +12 -11
  10. package/dist/ConnectedStreamedWordArtifact-CWFR6A37.cjs.map +1 -0
  11. package/dist/{ConnectedNativeDocxComparison-JOWYEINS.js → ConnectedStreamedWordArtifact-IXRJ7MUE.js} +11 -10
  12. package/dist/{ConnectedNativeDocxComparison-JOWYEINS.js.map → ConnectedStreamedWordArtifact-IXRJ7MUE.js.map} +1 -1
  13. package/dist/{NativeDocxEditor-M3I776GD.cjs → NativeDocxEditor-T2PJIZMU.cjs} +9 -7
  14. package/dist/{NativeDocxEditor-M3I776GD.cjs.map → NativeDocxEditor-T2PJIZMU.cjs.map} +1 -1
  15. package/dist/{NativeDocxEditor-JBQMH3MP.js → NativeDocxEditor-TBTBD6TC.js} +5 -3
  16. package/dist/{NativeDocxEditor-JBQMH3MP.js.map → NativeDocxEditor-TBTBD6TC.js.map} +1 -1
  17. package/dist/{WorkspaceTableView-FQPJQWUE.js → WorkspaceTableView-DWUE4VQF.js} +7 -6
  18. package/dist/WorkspaceTableView-DWUE4VQF.js.map +1 -0
  19. package/dist/{WorkspaceTableView-CZEFIAVT.cjs → WorkspaceTableView-EYLEUZZT.cjs} +9 -8
  20. package/dist/WorkspaceTableView-EYLEUZZT.cjs.map +1 -0
  21. package/dist/agents/index.cjs +241 -241
  22. package/dist/agents/index.js +7 -7
  23. package/dist/calls/index.cjs +3 -3
  24. package/dist/calls/index.js +2 -2
  25. package/dist/chat/index.cjs +1 -1
  26. package/dist/chat/index.js +1 -1
  27. package/dist/{chunk-RJUXSXBH.cjs → chunk-2BHDRVVL.cjs} +18 -8
  28. package/dist/chunk-2BHDRVVL.cjs.map +1 -0
  29. package/dist/chunk-2R3GGNPA.js +151 -0
  30. package/dist/chunk-2R3GGNPA.js.map +1 -0
  31. package/dist/{chunk-Y7PPQ7UT.js → chunk-3OCNUKGX.js} +4 -4
  32. package/dist/{chunk-Y7PPQ7UT.js.map → chunk-3OCNUKGX.js.map} +1 -1
  33. package/dist/{chunk-D3WFIFRY.cjs → chunk-3VW7ZXQ6.cjs} +211 -5
  34. package/dist/chunk-3VW7ZXQ6.cjs.map +1 -0
  35. package/dist/{chunk-JSQEAPTC.cjs → chunk-4GITK3Q5.cjs} +398 -75
  36. package/dist/chunk-4GITK3Q5.cjs.map +1 -0
  37. package/dist/{chunk-7KWUQQIB.js → chunk-5ZIYPZYE.js} +3 -3
  38. package/dist/{chunk-7KWUQQIB.js.map → chunk-5ZIYPZYE.js.map} +1 -1
  39. package/dist/{chunk-AUDUNQO6.cjs → chunk-6QAAIDQQ.cjs} +50 -50
  40. package/dist/{chunk-AUDUNQO6.cjs.map → chunk-6QAAIDQQ.cjs.map} +1 -1
  41. package/dist/{chunk-V3HG3LK3.js → chunk-7UENVUA6.js} +4 -4
  42. package/dist/{chunk-V3HG3LK3.js.map → chunk-7UENVUA6.js.map} +1 -1
  43. package/dist/{chunk-EWCJXUBP.js → chunk-AVXRXPII.js} +3 -3
  44. package/dist/{chunk-EWCJXUBP.js.map → chunk-AVXRXPII.js.map} +1 -1
  45. package/dist/{chunk-TAWPVD6C.cjs → chunk-B3FMUFAW.cjs} +3 -3
  46. package/dist/{chunk-TAWPVD6C.cjs.map → chunk-B3FMUFAW.cjs.map} +1 -1
  47. package/dist/{chunk-7IRSCMNK.js → chunk-BGXWPVHR.js} +3 -3
  48. package/dist/{chunk-7IRSCMNK.js.map → chunk-BGXWPVHR.js.map} +1 -1
  49. package/dist/chunk-DAN7EJ4O.js +482 -0
  50. package/dist/chunk-DAN7EJ4O.js.map +1 -0
  51. package/dist/{chunk-ZAVEMQ37.cjs → chunk-DWZXSPMB.cjs} +3 -3
  52. package/dist/{chunk-ZAVEMQ37.cjs.map → chunk-DWZXSPMB.cjs.map} +1 -1
  53. package/dist/chunk-E4H5H2C3.cjs +18 -0
  54. package/dist/{chunk-DVIQWBDM.cjs.map → chunk-E4H5H2C3.cjs.map} +1 -1
  55. package/dist/{chunk-VY4UFXTM.cjs → chunk-ETJFC6MO.cjs} +4 -4
  56. package/dist/{chunk-VY4UFXTM.cjs.map → chunk-ETJFC6MO.cjs.map} +1 -1
  57. package/dist/{chunk-FGI3YFQH.js → chunk-FTZ45WHY.js} +4 -4
  58. package/dist/{chunk-FGI3YFQH.js.map → chunk-FTZ45WHY.js.map} +1 -1
  59. package/dist/{chunk-FBSIWJSG.cjs → chunk-GC2FSPSQ.cjs} +6 -6
  60. package/dist/{chunk-FBSIWJSG.cjs.map → chunk-GC2FSPSQ.cjs.map} +1 -1
  61. package/dist/{chunk-TQIY2SVY.cjs → chunk-GFVIFXWT.cjs} +5 -5
  62. package/dist/{chunk-TQIY2SVY.cjs.map → chunk-GFVIFXWT.cjs.map} +1 -1
  63. package/dist/chunk-JPWPR6QU.cjs +485 -0
  64. package/dist/chunk-JPWPR6QU.cjs.map +1 -0
  65. package/dist/{chunk-KQYPP72K.js → chunk-JTJCCL2E.js} +212 -9
  66. package/dist/chunk-JTJCCL2E.js.map +1 -0
  67. package/dist/{chunk-P6FMKXAB.js → chunk-KFMRBZQK.js} +16 -6
  68. package/dist/chunk-KFMRBZQK.js.map +1 -0
  69. package/dist/{chunk-VMFLWFXK.js → chunk-MNG7N6M2.js} +4 -4
  70. package/dist/{chunk-VMFLWFXK.js.map → chunk-MNG7N6M2.js.map} +1 -1
  71. package/dist/chunk-NMZI3K6R.cjs +159 -0
  72. package/dist/chunk-NMZI3K6R.cjs.map +1 -0
  73. package/dist/{chunk-UYC5BJCB.cjs → chunk-NPLGB4LI.cjs} +5 -5
  74. package/dist/{chunk-UYC5BJCB.cjs.map → chunk-NPLGB4LI.cjs.map} +1 -1
  75. package/dist/{chunk-SCK3GAE5.cjs → chunk-P2YM67Y5.cjs} +5 -5
  76. package/dist/{chunk-SCK3GAE5.cjs.map → chunk-P2YM67Y5.cjs.map} +1 -1
  77. package/dist/{chunk-VE6S6NRQ.js → chunk-P6RIBIVN.js} +4 -4
  78. package/dist/{chunk-VE6S6NRQ.js.map → chunk-P6RIBIVN.js.map} +1 -1
  79. package/dist/chunk-Q2XGM372.cjs +18 -0
  80. package/dist/{chunk-GWGUZ5X6.cjs.map → chunk-Q2XGM372.cjs.map} +1 -1
  81. package/dist/{chunk-FWIBFGUQ.cjs → chunk-QJFJ5JBF.cjs} +3 -3
  82. package/dist/{chunk-FWIBFGUQ.cjs.map → chunk-QJFJ5JBF.cjs.map} +1 -1
  83. package/dist/{chunk-2DQHFJNP.js → chunk-QKR5LWDO.js} +7 -7
  84. package/dist/{chunk-2DQHFJNP.js.map → chunk-QKR5LWDO.js.map} +1 -1
  85. package/dist/{chunk-GDRLM2EX.js → chunk-RATEAOKT.js} +3 -3
  86. package/dist/{chunk-GDRLM2EX.js.map → chunk-RATEAOKT.js.map} +1 -1
  87. package/dist/{chunk-NFI46I77.cjs → chunk-TQUYWUEE.cjs} +11 -157
  88. package/dist/chunk-TQUYWUEE.cjs.map +1 -0
  89. package/dist/{chunk-ECERC6TI.js → chunk-VHJHY7TT.js} +3 -3
  90. package/dist/{chunk-ECERC6TI.js.map → chunk-VHJHY7TT.js.map} +1 -1
  91. package/dist/{chunk-ZO7PJMCO.js → chunk-WU34CHU5.js} +3 -3
  92. package/dist/{chunk-ZO7PJMCO.js.map → chunk-WU34CHU5.js.map} +1 -1
  93. package/dist/{chunk-ONTUMV74.js → chunk-XER3JLC7.js} +398 -78
  94. package/dist/chunk-XER3JLC7.js.map +1 -0
  95. package/dist/{chunk-LY37J3AC.cjs → chunk-YF3QUHKN.cjs} +4 -4
  96. package/dist/{chunk-LY37J3AC.cjs.map → chunk-YF3QUHKN.cjs.map} +1 -1
  97. package/dist/{chunk-Y73X65FF.js → chunk-ZDOKJD44.js} +5 -144
  98. package/dist/chunk-ZDOKJD44.js.map +1 -0
  99. package/dist/collaboration/index.cjs +1 -1
  100. package/dist/collaboration/index.js +1 -1
  101. package/dist/connect/docx.cjs +15 -14
  102. package/dist/connect/docx.js +11 -10
  103. package/dist/connect/index.cjs +542 -540
  104. package/dist/connect/index.cjs.map +1 -1
  105. package/dist/connect/index.js +27 -25
  106. package/dist/connect/index.js.map +1 -1
  107. package/dist/connect/viewer.cjs +90 -69
  108. package/dist/connect/viewer.cjs.map +1 -1
  109. package/dist/connect/viewer.js +40 -19
  110. package/dist/connect/viewer.js.map +1 -1
  111. package/dist/connection/viewer/ViewerPdfPane.d.ts +7 -1
  112. package/dist/document-tools/AdoptSignatureDialog.d.ts +39 -4
  113. package/dist/document-tools/PlaceMySignatureButton.d.ts +16 -0
  114. package/dist/document-tools/SavedSignatureSettings.d.ts +10 -0
  115. package/dist/document-tools/index.cjs +38 -23
  116. package/dist/document-tools/index.d.ts +2 -0
  117. package/dist/document-tools/index.js +6 -3
  118. package/dist/document-tools/viewer/AnnotatedPdfViewer.d.ts +10 -1
  119. package/dist/document-tools/viewer/SignatureRequestEditor.d.ts +7 -4
  120. package/dist/document-tools/viewer/index.cjs +184 -18
  121. package/dist/document-tools/viewer/index.cjs.map +1 -1
  122. package/dist/document-tools/viewer/index.js +184 -18
  123. package/dist/document-tools/viewer/index.js.map +1 -1
  124. package/dist/docx/NativeDocxEditor.d.ts +5 -0
  125. package/dist/docx/index.cjs +61 -47
  126. package/dist/docx/index.d.ts +1 -0
  127. package/dist/docx/index.js +5 -3
  128. package/dist/docx/signatures/SignatureFields.d.ts +50 -0
  129. package/dist/facts/index.cjs +56 -56
  130. package/dist/facts/index.js +6 -6
  131. package/dist/files/index.cjs +239 -239
  132. package/dist/files/index.js +6 -6
  133. package/dist/home/index.cjs +2 -2
  134. package/dist/home/index.js +2 -2
  135. package/dist/index.cjs +409 -409
  136. package/dist/index.js +14 -14
  137. package/dist/retrieval/index.cjs +1 -1
  138. package/dist/retrieval/index.js +1 -1
  139. package/dist/settings/index.cjs +187 -186
  140. package/dist/settings/index.js +4 -3
  141. package/dist/shell/index.cjs +3 -3
  142. package/dist/shell/index.js +3 -3
  143. package/dist/studio/index.cjs +3 -3
  144. package/dist/studio/index.js +3 -3
  145. package/dist/workflow-canvas/index.cjs +19 -19
  146. package/dist/workflow-canvas/index.js +7 -7
  147. package/node_modules/@arbidocs/coedit/dist/commands.cjs +109 -16
  148. package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
  149. package/node_modules/@arbidocs/coedit/dist/commands.d.cts +84 -1
  150. package/node_modules/@arbidocs/coedit/dist/commands.d.ts +84 -1
  151. package/node_modules/@arbidocs/coedit/dist/commands.js +99 -17
  152. package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
  153. package/node_modules/@arbidocs/coedit/package.json +1 -1
  154. package/package.json +5 -5
  155. package/src/docx/styles.css +50 -0
  156. package/dist/ConnectedStreamedWordArtifact-AJXPNTT3.cjs.map +0 -1
  157. package/dist/WorkspaceTableView-CZEFIAVT.cjs.map +0 -1
  158. package/dist/WorkspaceTableView-FQPJQWUE.js.map +0 -1
  159. package/dist/chunk-6MG62I5B.cjs +0 -272
  160. package/dist/chunk-6MG62I5B.cjs.map +0 -1
  161. package/dist/chunk-D3WFIFRY.cjs.map +0 -1
  162. package/dist/chunk-DVIQWBDM.cjs +0 -18
  163. package/dist/chunk-EQB3WELX.js +0 -269
  164. package/dist/chunk-EQB3WELX.js.map +0 -1
  165. package/dist/chunk-GWGUZ5X6.cjs +0 -18
  166. package/dist/chunk-JSQEAPTC.cjs.map +0 -1
  167. package/dist/chunk-KQYPP72K.js.map +0 -1
  168. package/dist/chunk-NFI46I77.cjs.map +0 -1
  169. package/dist/chunk-ONTUMV74.js.map +0 -1
  170. package/dist/chunk-P6FMKXAB.js.map +0 -1
  171. package/dist/chunk-RJUXSXBH.cjs.map +0 -1
  172. package/dist/chunk-Y73X65FF.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { ProjectReadout, ProjectBreakdown } from './chunk-RQKWYKZY.js';
3
- import { PlanBadge, QuotaMeter } from './chunk-Y73X65FF.js';
3
+ import { PlanBadge, QuotaMeter } from './chunk-ZDOKJD44.js';
4
4
  import { UsageMeter } from './chunk-66TA5IBN.js';
5
5
  import { createContext, useContext } from 'react';
6
6
  import { useArbi, formatGbp, useUserSettings } from '@arbidocs/react';
@@ -427,5 +427,5 @@ function projectGroupBilling(project, { isOwned, stripeEnabled }) {
427
427
  }
428
428
 
429
429
  export { ADDON_BLOCK_AI_GBP, ANNUAL_PREMIUM_AI_NOTE, BillingSupportProvider, CAP_REACHED_MESSAGE, DEFAULT_SPEND_CAP_PENCE, FREE_AI_GBP, FREE_COLLABORATORS, FREE_STORAGE_MB, MAX_CHECKOUT_BLOCKS, MIN_AUTO_TOPUP_THRESHOLD_GBP, PAY_TODAY_UNPRICED, PLAN_CHOICE_PACKS, POSTCODE_COUNTRIES, PRO_AI_GBP, PRO_PACKS, PRO_STORAGE_GB, STORAGE_BLOCK_GB, SUGGESTED_DAILY_CAP_PER_USER, TAX_LOCATION_INVALID, USAGE_CAP_HELP, USAGE_CAP_LABEL, ZERO_BUDGET_MESSAGE, addStepCaption, addonCharge, addonPrice, addonSettingsBody, aiUsageResetTimestamp, apiErrorDetail, autoRoom, blocksLabel, budgetSavedMessage, calcSavingsPercent, checkoutBlockPriceText, checkoutItemsLabel, findProPrices, formatMoney, formatPeriodEnd, formatResetDate, getQuotaItems, isAddonBudgetZero, isProProject, money2, nextPeriodBody, nextRemovedBlockSize, packPrice, parseBudgetPounds, planBadgeView, planName, planNameForPacks, planPreviewLines, plusVat, proTierName, projectGroupBilling, quoteError, quoteParts, quoteTotalLine, reduceBounds, splitBlocks, stepLabel, taxDetail, totalWithTaxWord, useBillingSupport, useRewardBalance, useSelfExtId };
430
- //# sourceMappingURL=chunk-GDRLM2EX.js.map
431
- //# sourceMappingURL=chunk-GDRLM2EX.js.map
430
+ //# sourceMappingURL=chunk-RATEAOKT.js.map
431
+ //# sourceMappingURL=chunk-RATEAOKT.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/billing/support.tsx","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/reward-balance.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["formatGbp","gbp","jsx"],"mappings":";;;;;;;;AA0BA,IAAM,qBAAA,GAAwB,aAAA,CAA8B,EAAE,aAAA,EAAe,OAAO,CAAA;AAE7E,SAAS,sBAAA,CAAuB;AAAA,EACrC,KAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,uBAAO,GAAA,CAAC,qBAAA,CAAsB,QAAA,EAAtB,EAA+B,OAAe,QAAA,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Content":["/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. Without\n * a `BillingSupportProvider` nothing is for sale: projects show their limits and usage only.\n */\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n /**\n * Add-on blocks the user just bought here, so the host does not announce them later as having\n * arrived on their own.\n */\n onAddonBlocksBought?: (projectExtId: string, blocks: { ai: number; storage: number }) => void\n}\n\nconst BillingSupportContext = createContext<BillingSupport>({ stripeEnabled: false })\n\nexport function BillingSupportProvider({\n value,\n children,\n}: {\n value: BillingSupport\n children: ReactNode\n}) {\n return <BillingSupportContext.Provider value={value}>{children}</BillingSupportContext.Provider>\n}\n\nexport function useBillingSupport(): BillingSupport {\n return useContext(BillingSupportContext)\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\n\n/**\n * Add-on block sizes (£25 of AI usage or 25 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 25\nexport const STORAGE_BLOCK_GB = 25\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI usage (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for Pro/dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI usage cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI usage in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI usage allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI usage reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit >= UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI usage',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings()\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nexport function addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£25 of AI usage\" / \"25 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £25 of AI usage\", \"1 × £10 + 1 × £25 of AI usage\", \"1 × 10 GB + 2 × 25 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI usage' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = kind === 'ai_usage' ? 0 : Math.min(addons.storage_blocks_min, current)\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI usage and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£25/month + VAT\" or \"£225/year + VAT\". */\nexport function blockRenewalShort(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean\n): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} + VAT`\n}\n\n/** The extra line annual plans show beside an AI usage add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual plans'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Usage cap'\n\n/** What the usage cap means (in \"More info\"): £0 and \"No limit\" explained. */\nexport const USAGE_CAP_HELP =\n 'The most automatic top-ups (AI usage added when it runs low, storage added when an upload needs it) may ' +\n 'cost in a month. Adding or removing by hand is never limited by it; the plan and renewals are not counted. ' +\n '£0 = no automatic top-ups: AI usage and uploads stop at your allowance unless you add more. ' +\n 'No limit = no cap.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI usage / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = addonPriceExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£25 of AI usage\" / \"25 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI usage` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£25/month · today £25\" (annual: \"£18.75/month · today £150\");\n * storage, charged for the rest of the period: \"£25/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { components } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = components['schemas']['TaxQuoteResponse']\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI usage + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\nimport { ADDON_BLOCK_AI_GBP, STORAGE_BLOCK_GB } from './plan-constants'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 + VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} + VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/**\n * The add-on offer on this interval's price, each block with its own price:\n * \"£25 of AI usage for £25/month + VAT or 25 GB for £25/month + VAT\". Null when unlisted.\n */\nexport function addonOfferText(price: ProductPrice | undefined): string | null {\n const ai = addonPrice(price, 'ai_usage')\n const storage = addonPrice(price, 'storage')\n const parts = [\n ai && `${formatGbp(ai.ai_gbp)} of AI usage for ${gbp(ai.monthly_ex_vat)}/month + VAT`,\n storage && `${storage.storage_gb} GB for ${gbp(storage.monthly_ex_vat)}/month + VAT`,\n ].filter(Boolean)\n return parts.length ? parts.join(' or ') : null\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £25 of AI usage + 1 × 25 GB\". */\nexport function checkoutItemsLabel(aiBlocks: number, storageBlocks: number): string {\n return [\n 'Pro',\n aiBlocks > 0 && `${aiBlocks} × ${formatGbp(ADDON_BLOCK_AI_GBP)} of AI usage`,\n storageBlocks > 0 && `${storageBlocks} × ${STORAGE_BLOCK_GB} GB`,\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£25/month + VAT each\", annual: \"£225/year + VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year + VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month + VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Plan and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/billing/support.tsx","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/reward-balance.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["formatGbp","gbp","jsx"],"mappings":";;;;;;;;AA0BA,IAAM,qBAAA,GAAwB,aAAA,CAA8B,EAAE,aAAA,EAAe,OAAO,CAAA;AAE7E,SAAS,sBAAA,CAAuB;AAAA,EACrC,KAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,uBAAO,GAAA,CAAC,qBAAA,CAAsB,QAAA,EAAtB,EAA+B,OAAe,QAAA,EAAS,CAAA;AACjE;AAEO,SAAS,iBAAA,GAAoC;AAClD,EAAA,OAAO,WAAW,qBAAqB,CAAA;AACzC;AAGO,SAAS,YAAA,GAAmC;AACjD,EAAA,MAAM,OAAO,OAAA,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,WAAW,CAAA,CAAA,EAAG,GAAI,MAAA;AAAA,MAEpF,KAAA,EAAO;AAAA,QACL,MAAA,EAAQ,CAAA,cAAA,EAAiB,OAAA,CAAQ,WAAW,CAAA,CAAA;AAAA;AAAA,QAE5C,sBACEA,GAAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,KAAA,EAAO,UAAA;AAAA,YACP,IAAA,EAAK,IAAA;AAAA,YACL,YAAA,EAAc,KAAA;AAAA,YACd,QAAA,EAAU,aAAA;AAAA,YACV,WAAA,EAAa;AAAA;AAAA;AACf;AAEJ;AAAA,GACF,GAEA,SAAA;AAEF,EAAA,MAAM,4BACJA,GAAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,MAAM,OAAA,CAAQ,IAAA;AAAA,MACd,KAAA,EAAO,SAAA;AAAA,MACP,MAAA,EACE,OAAA,GACI,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,GAAA,EAAI,qBACnDA,GAAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UAEC,IAAA;AAAA,UACA,KAAA;AAAA,UACA,KAAA,EAAO,WAAA;AAAA,UACP;AAAA,SAAA;AAAA,QAJK;AAAA,OAMR,CAAA,GACD,MAAA;AAAA,MAEN,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,KAAA,EACE,QAAQ,kBAAA,IAAsB,IAAA,GAC1B,aACA,OAAA,CAAQ,kBAAA,CAAmB,eAAe,OAAO;AAAA;AACzD;AAAA,GACF;AAEF,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,SAAA,EAAU;AACzC","file":"chunk-RATEAOKT.js","sourcesContent":["/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. Without\n * a `BillingSupportProvider` nothing is for sale: projects show their limits and usage only.\n */\nimport { createContext, useContext, type ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n /**\n * Add-on blocks the user just bought here, so the host does not announce them later as having\n * arrived on their own.\n */\n onAddonBlocksBought?: (projectExtId: string, blocks: { ai: number; storage: number }) => void\n}\n\nconst BillingSupportContext = createContext<BillingSupport>({ stripeEnabled: false })\n\nexport function BillingSupportProvider({\n value,\n children,\n}: {\n value: BillingSupport\n children: ReactNode\n}) {\n return <BillingSupportContext.Provider value={value}>{children}</BillingSupportContext.Provider>\n}\n\nexport function useBillingSupport(): BillingSupport {\n return useContext(BillingSupportContext)\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\n\n/**\n * Add-on block sizes (£25 of AI usage or 25 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 25\nexport const STORAGE_BLOCK_GB = 25\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI usage (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for Pro/dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI usage cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI usage in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI usage allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI usage reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit >= UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI usage',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings()\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nexport function addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£25 of AI usage\" / \"25 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £25 of AI usage\", \"1 × £10 + 1 × £25 of AI usage\", \"1 × 10 GB + 2 × 25 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI usage' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = kind === 'ai_usage' ? 0 : Math.min(addons.storage_blocks_min, current)\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI usage and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£25/month + VAT\" or \"£225/year + VAT\". */\nexport function blockRenewalShort(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean\n): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} + VAT`\n}\n\n/** The extra line annual plans show beside an AI usage add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual plans'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Usage cap'\n\n/** What the usage cap means (in \"More info\"): £0 and \"No limit\" explained. */\nexport const USAGE_CAP_HELP =\n 'The most automatic top-ups (AI usage added when it runs low, storage added when an upload needs it) may ' +\n 'cost in a month. Adding or removing by hand is never limited by it; the plan and renewals are not counted. ' +\n '£0 = no automatic top-ups: AI usage and uploads stop at your allowance unless you add more. ' +\n 'No limit = no cap.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI usage / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = addonPriceExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£25 of AI usage\" / \"25 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI usage` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£25/month · today £25\" (annual: \"£18.75/month · today £150\");\n * storage, charged for the rest of the period: \"£25/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { components } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = components['schemas']['TaxQuoteResponse']\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI usage + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\nimport { ADDON_BLOCK_AI_GBP, STORAGE_BLOCK_GB } from './plan-constants'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 + VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} + VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/**\n * The add-on offer on this interval's price, each block with its own price:\n * \"£25 of AI usage for £25/month + VAT or 25 GB for £25/month + VAT\". Null when unlisted.\n */\nexport function addonOfferText(price: ProductPrice | undefined): string | null {\n const ai = addonPrice(price, 'ai_usage')\n const storage = addonPrice(price, 'storage')\n const parts = [\n ai && `${formatGbp(ai.ai_gbp)} of AI usage for ${gbp(ai.monthly_ex_vat)}/month + VAT`,\n storage && `${storage.storage_gb} GB for ${gbp(storage.monthly_ex_vat)}/month + VAT`,\n ].filter(Boolean)\n return parts.length ? parts.join(' or ') : null\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £25 of AI usage + 1 × 25 GB\". */\nexport function checkoutItemsLabel(aiBlocks: number, storageBlocks: number): string {\n return [\n 'Pro',\n aiBlocks > 0 && `${aiBlocks} × ${formatGbp(ADDON_BLOCK_AI_GBP)} of AI usage`,\n storageBlocks > 0 && `${storageBlocks} × ${STORAGE_BLOCK_GB} GB`,\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£25/month + VAT each\", annual: \"£225/year + VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year + VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month + VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Plan and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}
@@ -1,14 +1,15 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
+ var chunkNMZI3K6R_cjs = require('./chunk-NMZI3K6R.cjs');
4
5
  var chunkQZTNTP75_cjs = require('./chunk-QZTNTP75.cjs');
5
6
  var chunkNWNVWO6L_cjs = require('./chunk-NWNVWO6L.cjs');
6
7
  var chunkDVUZTGVL_cjs = require('./chunk-DVUZTGVL.cjs');
7
8
  var chunkADOKTJHV_cjs = require('./chunk-ADOKTJHV.cjs');
8
9
  var chunk7RGLTF76_cjs = require('./chunk-7RGLTF76.cjs');
9
- var chunkULWRNGGE_cjs = require('./chunk-ULWRNGGE.cjs');
10
10
  var chunk32HW2Q33_cjs = require('./chunk-32HW2Q33.cjs');
11
11
  var chunkMHVNT4J3_cjs = require('./chunk-MHVNT4J3.cjs');
12
+ var chunkULWRNGGE_cjs = require('./chunk-ULWRNGGE.cjs');
12
13
  var chunkKDG6FER6_cjs = require('./chunk-KDG6FER6.cjs');
13
14
  var react = require('react');
14
15
  var lucideReact = require('lucide-react');
@@ -333,146 +334,6 @@ function LogoutDialog({
333
334
  }
334
335
  ) });
335
336
  }
336
- var DEFAULT_SETTINGS_DANGER_ZONE_LABELS = {
337
- dangerZone: "Danger Zone"
338
- };
339
- function SettingsPanel({ className, testId, ...props }) {
340
- return /* @__PURE__ */ jsxRuntime.jsx(
341
- "div",
342
- {
343
- "data-slot": "settings-panel",
344
- "data-testid": testId,
345
- className: ui.cn("mx-auto w-full max-w-xl space-y-6", className),
346
- ...props
347
- }
348
- );
349
- }
350
- function SettingsSection({
351
- icon,
352
- title,
353
- description,
354
- action,
355
- testId,
356
- className,
357
- children,
358
- ...props
359
- }) {
360
- return /* @__PURE__ */ jsxRuntime.jsxs(
361
- "section",
362
- {
363
- "data-slot": "settings-section",
364
- "data-testid": testId,
365
- className: ui.cn("space-y-3", className),
366
- ...props,
367
- children: [
368
- (title || action) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3", children: [
369
- title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
370
- icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground [&_svg]:h-4 [&_svg]:w-4", children: icon }),
371
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-base font-semibold text-foreground", children: title })
372
- ] }),
373
- action
374
- ] }),
375
- description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: description }),
376
- children
377
- ]
378
- }
379
- );
380
- }
381
- function SettingsRow({
382
- label,
383
- labelFor,
384
- description,
385
- children,
386
- testId,
387
- className,
388
- ...props
389
- }) {
390
- return /* @__PURE__ */ jsxRuntime.jsxs(
391
- "div",
392
- {
393
- "data-slot": "settings-row",
394
- "data-testid": testId,
395
- className: ui.cn(
396
- "flex flex-col gap-2 py-2 @xl:flex-row @xl:items-center @xl:justify-between @xl:gap-6",
397
- className
398
- ),
399
- ...props,
400
- children: [
401
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
402
- labelFor ? /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: labelFor, className: "text-sm font-medium text-foreground", children: label }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-foreground", children: label }),
403
- description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: description })
404
- ] }),
405
- children && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children })
406
- ]
407
- }
408
- );
409
- }
410
- function SettingsCard({ padding = "md", className, ...props }) {
411
- return /* @__PURE__ */ jsxRuntime.jsx(
412
- "div",
413
- {
414
- "data-slot": "settings-card",
415
- className: ui.cn(
416
- "rounded-lg border border-border bg-card shadow-xs",
417
- padding === "md" ? "space-y-5 p-5" : "divide-y divide-border p-2",
418
- className
419
- ),
420
- ...props
421
- }
422
- );
423
- }
424
- function SettingsActionRow({ title, description, onClick, testId }) {
425
- return /* @__PURE__ */ jsxRuntime.jsxs(
426
- "button",
427
- {
428
- type: "button",
429
- onClick,
430
- "data-slot": "settings-action-row",
431
- "data-testid": testId,
432
- className: "flex w-full items-center gap-3 rounded-md px-3 py-3 text-left transition-colors hover:bg-background/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:min-h-11",
433
- children: [
434
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
435
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-foreground", children: title }),
436
- description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 text-xs leading-relaxed text-muted-foreground", children: description })
437
- ] }),
438
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 shrink-0 text-muted-foreground" })
439
- ]
440
- }
441
- );
442
- }
443
- function SettingsDangerZone({
444
- isOpen,
445
- onToggle,
446
- label,
447
- title,
448
- description,
449
- action,
450
- labels
451
- }) {
452
- const l = react.useMemo(() => ({ ...DEFAULT_SETTINGS_DANGER_ZONE_LABELS, ...labels }), [labels]);
453
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "settings-danger-zone", className: "mt-8 pt-2", children: [
454
- /* @__PURE__ */ jsxRuntime.jsxs(
455
- "button",
456
- {
457
- type: "button",
458
- onClick: onToggle,
459
- "aria-expanded": isOpen,
460
- className: "flex w-full items-center gap-1.5 text-left pointer-coarse:min-h-11",
461
- children: [
462
- isOpen ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" }),
463
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: label ?? l.dangerZone })
464
- ]
465
- }
466
- ),
467
- isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex items-center justify-between gap-4 rounded-lg bg-destructive/5 p-4", children: [
468
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
469
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: title }),
470
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: description })
471
- ] }),
472
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0", children: action })
473
- ] })
474
- ] });
475
- }
476
337
  function SegmentedControl({
477
338
  value,
478
339
  onChange,
@@ -3820,7 +3681,7 @@ function ProfileCard({
3820
3681
  labels
3821
3682
  }) {
3822
3683
  const l = react.useMemo(() => ({ ...DEFAULT_PROFILE_CARD_LABELS, ...labels }), [labels]);
3823
- return /* @__PURE__ */ jsxRuntime.jsxs(SettingsCard, { children: [
3684
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunkNMZI3K6R_cjs.SettingsCard, { children: [
3824
3685
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-5", children: [
3825
3686
  avatar,
3826
3687
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 space-y-3", children: [
@@ -4728,8 +4589,8 @@ function IdentityVerificationCard({
4728
4589
  resuming ? l.continue : l.verify
4729
4590
  ] });
4730
4591
  }
4731
- return /* @__PURE__ */ jsxRuntime.jsxs(SettingsCard, { padding: "sm", "data-testid": "identity-verification-card", children: [
4732
- /* @__PURE__ */ jsxRuntime.jsx(SettingsRow, { label: l.title, description, children: action }),
4592
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunkNMZI3K6R_cjs.SettingsCard, { padding: "sm", "data-testid": "identity-verification-card", children: [
4593
+ /* @__PURE__ */ jsxRuntime.jsx(chunkNMZI3K6R_cjs.SettingsRow, { label: l.title, description, children: action }),
4733
4594
  !flow.isOpen && /* @__PURE__ */ jsxRuntime.jsx(Problem, { flow, onManageBilling, label: l.manageBilling })
4734
4595
  ] });
4735
4596
  }
@@ -4950,9 +4811,9 @@ function AppearanceSettings({
4950
4811
  onReset
4951
4812
  }) {
4952
4813
  const activePairing = chunkNWNVWO6L_cjs.getFontPairing(pairingId) ?? chunkNWNVWO6L_cjs.getFontPairing(pairingIds[0]);
4953
- return /* @__PURE__ */ jsxRuntime.jsxs(SettingsPanel, { testId: "settings-appearance", children: [
4814
+ return /* @__PURE__ */ jsxRuntime.jsxs(chunkNMZI3K6R_cjs.SettingsPanel, { testId: "settings-appearance", children: [
4954
4815
  /* @__PURE__ */ jsxRuntime.jsx(
4955
- SettingsSection,
4816
+ chunkNMZI3K6R_cjs.SettingsSection,
4956
4817
  {
4957
4818
  title: "Colour scheme",
4958
4819
  action: onReset && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -4979,7 +4840,7 @@ function AppearanceSettings({
4979
4840
  )
4980
4841
  }
4981
4842
  ),
4982
- /* @__PURE__ */ jsxRuntime.jsxs(SettingsSection, { title: "Text size", children: [
4843
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkNMZI3K6R_cjs.SettingsSection, { title: "Text size", children: [
4983
4844
  /* @__PURE__ */ jsxRuntime.jsx(
4984
4845
  SegmentedControl,
4985
4846
  {
@@ -4991,7 +4852,7 @@ function AppearanceSettings({
4991
4852
  ),
4992
4853
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Makes all text larger, including documents in the viewer and citations. Applied straight away and remembered on this device." })
4993
4854
  ] }),
4994
- /* @__PURE__ */ jsxRuntime.jsxs(SettingsSection, { title: "Typeface", children: [
4855
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkNMZI3K6R_cjs.SettingsSection, { title: "Typeface", children: [
4995
4856
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { value: pairingId, onValueChange: onPairingChange, children: [
4996
4857
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { className: "w-full", "data-testid": "appearance-typeface-select", children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, { children: activePairing && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily: activePairing.display }, children: activePairing.label }) }) }),
4997
4858
  /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: pairingIds.map((id) => {
@@ -5082,7 +4943,6 @@ exports.DEFAULT_PROJECT_LIST_LABELS = DEFAULT_PROJECT_LIST_LABELS;
5082
4943
  exports.DEFAULT_QUOTA_EXCEEDED_DIALOG_LABELS = DEFAULT_QUOTA_EXCEEDED_DIALOG_LABELS;
5083
4944
  exports.DEFAULT_REFERRAL_REWARD_LABELS = DEFAULT_REFERRAL_REWARD_LABELS;
5084
4945
  exports.DEFAULT_RENAME_DIALOG_LABELS = DEFAULT_RENAME_DIALOG_LABELS;
5085
- exports.DEFAULT_SETTINGS_DANGER_ZONE_LABELS = DEFAULT_SETTINGS_DANGER_ZONE_LABELS;
5086
4946
  exports.DEFAULT_SHARED_PROJECTS_SECTION_LABELS = DEFAULT_SHARED_PROJECTS_SECTION_LABELS;
5087
4947
  exports.DEFAULT_SUBSCRIPTION_STATUS_LABELS = DEFAULT_SUBSCRIPTION_STATUS_LABELS;
5088
4948
  exports.DEFAULT_SUPPORT_PANEL_LABELS = DEFAULT_SUPPORT_PANEL_LABELS;
@@ -5153,13 +5013,7 @@ exports.RenameDialog = RenameDialog;
5153
5013
  exports.RequireVerified = RequireVerified;
5154
5014
  exports.SegmentedControl = SegmentedControl;
5155
5015
  exports.ServerConnectionButton = ServerConnectionButton;
5156
- exports.SettingsActionRow = SettingsActionRow;
5157
- exports.SettingsCard = SettingsCard;
5158
- exports.SettingsDangerZone = SettingsDangerZone;
5159
5016
  exports.SettingsPage = SettingsPage;
5160
- exports.SettingsPanel = SettingsPanel;
5161
- exports.SettingsRow = SettingsRow;
5162
- exports.SettingsSection = SettingsSection;
5163
5017
  exports.SettingsSwitchGroup = SettingsSwitchGroup;
5164
5018
  exports.SettingsSwitchRow = SettingsSwitchRow;
5165
5019
  exports.SharedProjectRow = SharedProjectRow;
@@ -5207,5 +5061,5 @@ exports.toActiveSessionViews = toActiveSessionViews;
5207
5061
  exports.toDeleteBlockerViews = toDeleteBlockerViews;
5208
5062
  exports.toLogoutSessionViews = toLogoutSessionViews;
5209
5063
  exports.toNotificationCategories = toNotificationCategories;
5210
- //# sourceMappingURL=chunk-NFI46I77.cjs.map
5211
- //# sourceMappingURL=chunk-NFI46I77.cjs.map
5064
+ //# sourceMappingURL=chunk-TQUYWUEE.cjs.map
5065
+ //# sourceMappingURL=chunk-TQUYWUEE.cjs.map