@eifi1/ui-kit 0.41.0 → 0.43.0

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 (190) hide show
  1. package/README.md +26 -7
  2. package/dist/admin/admin-area-labels.d.ts +59 -0
  3. package/dist/admin/admin-area-labels.js +35 -0
  4. package/dist/admin/admin-area-labels.js.map +1 -0
  5. package/dist/admin/admin-forbidden.d.ts +35 -0
  6. package/dist/admin/admin-forbidden.js +36 -0
  7. package/dist/admin/admin-forbidden.js.map +1 -0
  8. package/dist/admin/admin-overview.d.ts +110 -0
  9. package/dist/admin/admin-overview.js +92 -0
  10. package/dist/admin/admin-overview.js.map +1 -0
  11. package/dist/admin/admin-sections.d.ts +94 -0
  12. package/dist/admin/admin-sections.js +81 -0
  13. package/dist/admin/admin-sections.js.map +1 -0
  14. package/dist/admin/admin-tool-links.d.ts +48 -0
  15. package/dist/admin/admin-tool-links.js +31 -0
  16. package/dist/admin/admin-tool-links.js.map +1 -0
  17. package/dist/billing/billing-banner.d.ts +33 -2
  18. package/dist/billing/billing-banner.js +29 -3
  19. package/dist/billing/billing-banner.js.map +1 -1
  20. package/dist/billing/billing-labels.d.ts +36 -0
  21. package/dist/billing/billing-labels.js +10 -0
  22. package/dist/billing/billing-labels.js.map +1 -1
  23. package/dist/billing/billing-overview.d.ts +33 -0
  24. package/dist/billing/billing-overview.js +6 -0
  25. package/dist/billing/billing-overview.js.map +1 -1
  26. package/dist/billing/billing-standing.d.ts +8 -0
  27. package/dist/billing/billing-standing.js.map +1 -1
  28. package/dist/billing/cancel-request.d.ts +53 -0
  29. package/dist/billing/cancel-request.js +21 -0
  30. package/dist/billing/cancel-request.js.map +1 -0
  31. package/dist/billing/cancel-subscription.d.ts +46 -0
  32. package/dist/billing/cancel-subscription.js +57 -0
  33. package/dist/billing/cancel-subscription.js.map +1 -0
  34. package/dist/billing/plan-card.d.ts +45 -1
  35. package/dist/billing/plan-card.js +53 -2
  36. package/dist/billing/plan-card.js.map +1 -1
  37. package/dist/billing/plan-switch.d.ts +10 -1
  38. package/dist/billing/plan-switch.js +22 -13
  39. package/dist/billing/plan-switch.js.map +1 -1
  40. package/dist/billing/provider-page.d.ts +40 -0
  41. package/dist/billing/provider-page.js +33 -0
  42. package/dist/billing/provider-page.js.map +1 -0
  43. package/dist/billing/subscription-actions.d.ts +68 -4
  44. package/dist/billing/subscription-actions.js +65 -5
  45. package/dist/billing/subscription-actions.js.map +1 -1
  46. package/dist/components/account-chips.d.ts +50 -2
  47. package/dist/components/account-chips.js +33 -0
  48. package/dist/components/account-chips.js.map +1 -1
  49. package/dist/components/empty-state.d.ts +2 -1
  50. package/dist/components/empty-state.js.map +1 -1
  51. package/dist/eslint/index.js +1 -1
  52. package/dist/feedback/feedback-menu.d.ts +7 -4
  53. package/dist/feedback/feedback-menu.js +4 -2
  54. package/dist/feedback/feedback-menu.js.map +1 -1
  55. package/dist/hooks/use-search-param-state.js +4 -1
  56. package/dist/hooks/use-search-param-state.js.map +1 -1
  57. package/dist/i18n/defaults.js +7 -1
  58. package/dist/i18n/defaults.js.map +1 -1
  59. package/dist/i18n/german.js +113 -0
  60. package/dist/i18n/german.js.map +1 -1
  61. package/dist/i18n/kit-labels.d.ts +12 -0
  62. package/dist/i18n/kit-labels.js.map +1 -1
  63. package/dist/i18n/locales/en.js +142 -1
  64. package/dist/i18n/locales/en.js.map +3 -3
  65. package/dist/i18n/locales/es.js +110 -0
  66. package/dist/i18n/locales/es.js.map +1 -1
  67. package/dist/i18n/locales/fr.js +109 -0
  68. package/dist/i18n/locales/fr.js.map +1 -1
  69. package/dist/i18n/locales/hu.js +110 -0
  70. package/dist/i18n/locales/hu.js.map +1 -1
  71. package/dist/i18n/locales/it.js +110 -0
  72. package/dist/i18n/locales/it.js.map +1 -1
  73. package/dist/i18n/locales/zh.js +109 -0
  74. package/dist/i18n/locales/zh.js.map +1 -1
  75. package/dist/i18n/review.js +34 -1
  76. package/dist/i18n/review.js.map +1 -1
  77. package/dist/index.d.ts +24 -2
  78. package/dist/index.js +29 -1
  79. package/dist/index.js.map +1 -1
  80. package/dist/search/global-search.d.ts +3 -0
  81. package/dist/search/global-search.js +3 -1
  82. package/dist/search/global-search.js.map +1 -1
  83. package/dist/settings/settings-catalogue.d.ts +9 -1
  84. package/dist/settings/settings-catalogue.js +1 -1
  85. package/dist/settings/settings-catalogue.js.map +1 -1
  86. package/dist/settings/settings-layout.d.ts +7 -1
  87. package/dist/settings/settings-layout.js +35 -27
  88. package/dist/settings/settings-layout.js.map +1 -1
  89. package/dist/shell/account-menu-language.d.ts +46 -0
  90. package/dist/shell/account-menu-language.js +64 -0
  91. package/dist/shell/account-menu-language.js.map +1 -0
  92. package/dist/shell/admin-menu.d.ts +69 -0
  93. package/dist/shell/admin-menu.js +64 -0
  94. package/dist/shell/admin-menu.js.map +1 -0
  95. package/dist/shell/app-shell.d.ts +10 -0
  96. package/dist/shell/app-shell.js +22 -4
  97. package/dist/shell/app-shell.js.map +1 -1
  98. package/dist/shell/dev-switchers.d.ts +53 -0
  99. package/dist/shell/dev-switchers.js +107 -0
  100. package/dist/shell/dev-switchers.js.map +1 -0
  101. package/dist/shell/sync-status-indicator.d.ts +86 -0
  102. package/dist/shell/sync-status-indicator.js +170 -0
  103. package/dist/shell/sync-status-indicator.js.map +1 -0
  104. package/dist/shell/top-bar-actions.d.ts +49 -0
  105. package/dist/shell/top-bar-actions.js +31 -0
  106. package/dist/shell/top-bar-actions.js.map +1 -0
  107. package/dist/shell/top-bar-parts-labels.d.ts +90 -0
  108. package/dist/shell/top-bar-parts-labels.js +51 -0
  109. package/dist/shell/top-bar-parts-labels.js.map +1 -0
  110. package/dist/shell/topbar-action-menu.d.ts +13 -1
  111. package/dist/shell/topbar-action-menu.js +5 -2
  112. package/dist/shell/topbar-action-menu.js.map +1 -1
  113. package/dist/shell/topbar-controls.d.ts +16 -3
  114. package/dist/shell/topbar-controls.js +5 -1
  115. package/dist/shell/topbar-controls.js.map +1 -1
  116. package/dist/shell/tour-menu.d.ts +67 -0
  117. package/dist/shell/tour-menu.js +87 -0
  118. package/dist/shell/tour-menu.js.map +1 -0
  119. package/dist/shell.d.ts +16 -0
  120. package/dist/shell.js +21 -0
  121. package/dist/shell.js.map +1 -1
  122. package/dist/tour/tour-catalogue-labels.d.ts +44 -0
  123. package/dist/tour/tour-catalogue-labels.js +32 -0
  124. package/dist/tour/tour-catalogue-labels.js.map +1 -0
  125. package/dist/tour/tour-catalogue.d.ts +68 -0
  126. package/dist/tour/tour-catalogue.js +189 -0
  127. package/dist/tour/tour-catalogue.js.map +1 -0
  128. package/dist/tour/tour-info.d.ts +112 -0
  129. package/dist/tour/tour-info.js +36 -0
  130. package/dist/tour/tour-info.js.map +1 -0
  131. package/dist/tour/use-tour-progress.d.ts +61 -0
  132. package/dist/tour/use-tour-progress.js +116 -0
  133. package/dist/tour/use-tour-progress.js.map +1 -0
  134. package/dist/tour/use-tour-url-sync.d.ts +58 -0
  135. package/dist/tour/use-tour-url-sync.js +110 -0
  136. package/dist/tour/use-tour-url-sync.js.map +1 -0
  137. package/dist/tour.d.ts +8 -0
  138. package/dist/tour.js +18 -0
  139. package/dist/tour.js.map +1 -1
  140. package/package.json +1 -1
  141. package/src/admin/admin-area-labels.ts +91 -0
  142. package/src/admin/admin-forbidden.tsx +75 -0
  143. package/src/admin/admin-overview.tsx +217 -0
  144. package/src/admin/admin-sections.tsx +198 -0
  145. package/src/admin/admin-tool-links.tsx +84 -0
  146. package/src/billing/billing-banner.tsx +57 -6
  147. package/src/billing/billing-labels.ts +59 -0
  148. package/src/billing/billing-overview.ts +37 -0
  149. package/src/billing/billing-standing.ts +8 -0
  150. package/src/billing/cancel-request.ts +75 -0
  151. package/src/billing/cancel-subscription.tsx +102 -0
  152. package/src/billing/plan-card.tsx +97 -1
  153. package/src/billing/plan-switch.tsx +16 -0
  154. package/src/billing/provider-page.ts +75 -0
  155. package/src/billing/subscription-actions.tsx +155 -20
  156. package/src/components/account-chips.tsx +89 -2
  157. package/src/components/empty-state.tsx +2 -1
  158. package/src/feedback/feedback-menu.tsx +8 -3
  159. package/src/hooks/use-search-param-state.ts +6 -1
  160. package/src/i18n/defaults.ts +6 -0
  161. package/src/i18n/german.ts +127 -0
  162. package/src/i18n/kit-labels.tsx +12 -0
  163. package/src/i18n/locales/en.ts +32 -0
  164. package/src/i18n/locales/es.ts +121 -0
  165. package/src/i18n/locales/fr.ts +121 -0
  166. package/src/i18n/locales/hu.ts +119 -0
  167. package/src/i18n/locales/it.ts +122 -0
  168. package/src/i18n/locales/zh.ts +114 -0
  169. package/src/i18n/review.ts +33 -0
  170. package/src/index.ts +38 -2
  171. package/src/search/global-search.tsx +5 -0
  172. package/src/settings/settings-catalogue.ts +10 -2
  173. package/src/settings/settings-layout.tsx +58 -34
  174. package/src/shell/account-menu-language.tsx +116 -0
  175. package/src/shell/admin-menu.tsx +146 -0
  176. package/src/shell/app-shell.tsx +44 -3
  177. package/src/shell/dev-switchers.tsx +179 -0
  178. package/src/shell/sync-status-indicator.tsx +301 -0
  179. package/src/shell/top-bar-actions.tsx +79 -0
  180. package/src/shell/top-bar-parts-labels.ts +142 -0
  181. package/src/shell/topbar-action-menu.tsx +15 -2
  182. package/src/shell/topbar-controls.tsx +20 -3
  183. package/src/shell/tour-menu.tsx +179 -0
  184. package/src/shell.ts +27 -0
  185. package/src/tour/tour-catalogue-labels.ts +75 -0
  186. package/src/tour/tour-catalogue.tsx +316 -0
  187. package/src/tour/tour-info.ts +144 -0
  188. package/src/tour/use-tour-progress.ts +198 -0
  189. package/src/tour/use-tour-url-sync.ts +221 -0
  190. package/src/tour.ts +11 -0
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { createElement } from "react";
3
+ import { History, LayoutDashboard, Mail, Receipt, Users } from "lucide-react";
4
+ import { DEFAULT_ADMIN_AREA_LABELS } from "./admin-area-labels.js";
5
+ const ADMIN_SECTIONS = Object.freeze([
6
+ { id: "overview", icon: LayoutDashboard },
7
+ { id: "users", icon: Users },
8
+ { id: "invitations", icon: Mail },
9
+ { id: "billing", icon: Receipt },
10
+ { id: "activity", icon: History }
11
+ ]);
12
+ const OWN_DEFAULT_AFTER = "invitations";
13
+ function orderSections(own, leaveOutIds) {
14
+ const leaveOut = new Set(leaveOutIds ?? []);
15
+ const shared = new Set(ADMIN_SECTIONS.map((s) => s.id));
16
+ const ownIds = /* @__PURE__ */ new Set();
17
+ for (const section of own) {
18
+ if (shared.has(section.id)) throw new Error(`adminSections: "${section.id}" is a shared section's id`);
19
+ if (ownIds.has(section.id)) throw new Error(`adminSections: "${section.id}" is given twice`);
20
+ ownIds.add(section.id);
21
+ }
22
+ for (const section of own) {
23
+ const after = section.after;
24
+ if (after !== void 0 && !shared.has(after) && !ownIds.has(after)) {
25
+ throw new Error(`adminSections: "${section.id}" goes after "${after}", which is no section`);
26
+ }
27
+ }
28
+ const followers = /* @__PURE__ */ new Map();
29
+ for (const section of own) {
30
+ const after = section.after ?? OWN_DEFAULT_AFTER;
31
+ followers.set(after, [...followers.get(after) ?? [], section]);
32
+ }
33
+ const out = [];
34
+ const placed = /* @__PURE__ */ new Set();
35
+ const placeAfter = (id) => {
36
+ for (const section of followers.get(id) ?? []) {
37
+ out.push({ own: section });
38
+ placed.add(section.id);
39
+ placeAfter(section.id);
40
+ }
41
+ };
42
+ for (const definition of ADMIN_SECTIONS) {
43
+ if (!leaveOut.has(definition.id)) out.push({ shared: definition });
44
+ placeAfter(definition.id);
45
+ }
46
+ const stuck = own.filter((s) => !placed.has(s.id)).map((s) => s.id);
47
+ if (stuck.length) throw new Error(`adminSections: ${stuck.join(", ")} follow each other in a circle`);
48
+ return out;
49
+ }
50
+ function adminSectionOrder(own = [], options = {}) {
51
+ return orderSections(own, options.leaveOut).map(
52
+ (s) => "shared" in s ? s.shared.id : s.own.id
53
+ );
54
+ }
55
+ function adminSections(labels, own = [], options = {}) {
56
+ const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;
57
+ return orderSections(own, options.leaveOut).map((s) => {
58
+ if ("own" in s) {
59
+ const { after: _after, ...group } = s.own;
60
+ return group;
61
+ }
62
+ const { id, icon } = s.shared;
63
+ const visible = options.visible?.[id];
64
+ return {
65
+ id,
66
+ icon: createElement(icon, { "aria-hidden": true }),
67
+ title: words.sections[id].title,
68
+ help: words.sections[id].help,
69
+ // 0.43 (kastlan): the overview is a page of tiles, not of setting cards — it shows
70
+ // with no entry of its own.
71
+ ...id === "overview" ? { standalone: true } : null,
72
+ ...visible === void 0 ? null : { visible }
73
+ };
74
+ });
75
+ }
76
+ export {
77
+ ADMIN_SECTIONS,
78
+ adminSectionOrder,
79
+ adminSections
80
+ };
81
+ //# sourceMappingURL=admin-sections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/admin/admin-sections.tsx"],"sourcesContent":["import { createElement } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { History, LayoutDashboard, Mail, Receipt, Users } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport type { SettingsGroup } from \"../settings/settings-catalogue\";\nimport { DEFAULT_ADMIN_AREA_LABELS } from \"./admin-area-labels\";\nimport type { AdminAreaLabels, AdminSharedSection } from \"./admin-area-labels\";\n\n/**\n * The admin area's sections (0.42.0, docs/admin-harmonization.md §2.3, §6.8): the five\n * every app shares, in the template's order, and the helper that builds an app's\n * `SettingsLayout` catalogue groups from them and the app's own.\n */\n\n/** One shared section: its path segment and its icon. The words are `adminArea.sections`. */\nexport interface AdminSectionDefinition {\n id: AdminSharedSection;\n icon: LucideIcon;\n}\n\n/**\n * The shared sections in the template's order (§2.3 decision 10, §6.13): Overview, Users,\n * Invitations, Billing, Activity. An app's own sections go between them\n * ({@link adminSections}).\n */\nexport const ADMIN_SECTIONS: readonly AdminSectionDefinition[] = Object.freeze([\n { id: \"overview\", icon: LayoutDashboard },\n { id: \"users\", icon: Users },\n { id: \"invitations\", icon: Mail },\n { id: \"billing\", icon: Receipt },\n { id: \"activity\", icon: History },\n]);\n\n/**\n * One of the app's own sections: a catalogue group with its words, plus where it goes.\n * `after` names the section it follows — a shared one or another of the app's own. Left\n * out, it goes where the template puts an app's sections, after Invitations and before\n * Billing, in the order given.\n */\nexport interface AdminOwnSection<G extends string = string> extends SettingsGroup<G> {\n after?: AdminSharedSection | G;\n}\n\n/** Where one section goes, without its words — what {@link adminSectionOrder} takes. An\n * {@link AdminOwnSection} is one. */\nexport interface AdminSectionPlace<G extends string = string> {\n id: G;\n after?: AdminSharedSection | G;\n}\n\n/** The order's options: the shared sections an app does not have. */\nexport interface AdminSectionOrderOptions<L extends AdminSharedSection = AdminSharedSection> {\n /**\n * Shared sections this app does not have — keksdose and Kurvenschmiede have no billing\n * view (`[\"billing\"]`). Left out, every shared section is in the catalogue. Since 0.43\n * the result's type leaves them out too, so no cast is needed to drop `\"billing\"` —\n * when TypeScript infers the type arguments. With them written out, name the left-out\n * ones as the second (`adminSections<Own, \"billing\">(…)`); `adminSections<Own>(…)`\n * keeps every shared id in the type, as before.\n */\n leaveOut?: readonly L[];\n}\n\nexport interface AdminSectionsOptions<L extends AdminSharedSection = AdminSharedSection> extends AdminSectionOrderOptions<L> {\n /**\n * A shared section that is in the catalogue but hidden for now, as\n * {@link SettingsGroup.visible}: kastlan's `{ billing: billingEnabled }` (settings §5),\n * whose path then acts as an unknown one.\n */\n visible?: Partial<Record<AdminSharedSection, boolean>>;\n}\n\n/** The shared sections an app keeps when it leaves out `L`. A `leaveOut` typed as the\n * whole union (a variable of `AdminSharedSection[]`) says nothing about which, so it\n * narrows nothing. */\nexport type AdminKeptSection<L extends AdminSharedSection = AdminSharedSection> = [AdminSharedSection] extends [L]\n ? AdminSharedSection\n : Exclude<AdminSharedSection, L>;\n\n/** The shared section after which the app's sections go when they name no place. */\nconst OWN_DEFAULT_AFTER: AdminSharedSection = \"invitations\";\n\n/** The shared and own sections in their order — a shared one as its definition, an own\n * one as given. Throws as {@link adminSections} documents. */\nfunction orderSections<S extends AdminSectionPlace<string>>(\n own: readonly S[],\n leaveOutIds: readonly AdminSharedSection[] | undefined,\n): ({ shared: AdminSectionDefinition } | { own: S })[] {\n const leaveOut = new Set<string>(leaveOutIds ?? []);\n const shared = new Set<string>(ADMIN_SECTIONS.map((s) => s.id));\n const ownIds = new Set<string>();\n for (const section of own) {\n if (shared.has(section.id)) throw new Error(`adminSections: \"${section.id}\" is a shared section's id`);\n if (ownIds.has(section.id)) throw new Error(`adminSections: \"${section.id}\" is given twice`);\n ownIds.add(section.id);\n }\n for (const section of own) {\n const after = section.after;\n if (after !== undefined && !shared.has(after) && !ownIds.has(after)) {\n throw new Error(`adminSections: \"${section.id}\" goes after \"${after}\", which is no section`);\n }\n }\n\n // Each section's followers, in the order given: the shared ones, then the own ones\n // under their `after`, recursively, so an own section may follow another own one.\n const followers = new Map<string, S[]>();\n for (const section of own) {\n const after = section.after ?? OWN_DEFAULT_AFTER;\n followers.set(after, [...(followers.get(after) ?? []), section]);\n }\n\n const out: ({ shared: AdminSectionDefinition } | { own: S })[] = [];\n const placed = new Set<string>();\n const placeAfter = (id: string) => {\n for (const section of followers.get(id) ?? []) {\n out.push({ own: section });\n placed.add(section.id);\n placeAfter(section.id);\n }\n };\n for (const definition of ADMIN_SECTIONS) {\n if (!leaveOut.has(definition.id)) out.push({ shared: definition });\n // A left-out section's followers keep its place.\n placeAfter(definition.id);\n }\n const stuck = own.filter((s) => !placed.has(s.id)).map((s) => s.id);\n if (stuck.length) throw new Error(`adminSections: ${stuck.join(\", \")} follow each other in a circle`);\n return out;\n}\n\n/**\n * The admin area's section ids in the template's order (0.43, keksdose) — what\n * {@link adminSections} builds its groups in, without the words: for an app that needs the\n * ORDER only (a router's list of paths, a test), outside a component, with no labels.\n *\n * adminSectionOrder([{ id: \"metrics\", after: \"overview\" }], { leaveOut: [\"billing\"] })\n * // [\"overview\", \"metrics\", \"users\", \"invitations\", \"activity\"]\n *\n * Throws as {@link adminSections} does.\n */\nexport function adminSectionOrder<G extends string = never, L extends AdminSharedSection = AdminSharedSection>(\n own: readonly AdminSectionPlace<G>[] = [],\n options: AdminSectionOrderOptions<L> = {},\n): (AdminKeptSection<L> | G)[] {\n return orderSections(own, options.leaveOut).map((s) =>\n \"shared\" in s ? (s.shared.id as AdminKeptSection<L>) : s.own.id,\n );\n}\n\n/**\n * An app's admin catalogue groups, in the template's order (§2.3 decision 10, §6.8): the\n * shared sections with the kit's icons and words, and the app's own at the places they\n * name. The result is `SettingsLayout`'s `groups`; the entries stay the app's (a group\n * with no visible entry is hidden, as on any settings page — except, since 0.43, the\n * Overview, a page of tiles that needs no entry: it is `standalone`). Since 0.43 the\n * result's type leaves out the `leaveOut` sections, and {@link adminSectionOrder} gives\n * the same order as ids, without words.\n *\n * const groups = adminSections(useAdminAreaLabels(), [\n * { id: \"metrics\", icon: <BarChart3 />, title: t(\"…\"), help: t(\"…\"), after: \"overview\" },\n * { id: \"messaging\", icon: <MessageSquare />, title: t(\"…\"), help: t(\"…\") },\n * { id: \"health\", icon: <HeartPulse />, title: t(\"…\"), help: t(\"…\"), after: \"billing\" },\n * ], { leaveOut: [\"billing\"] });\n *\n * gives keksdose's overview, metrics, users, invitations, messaging, health, activity.\n * An `after` that names a left-out section takes that section's place. Kurvenschmiede's\n * Teams needs no `after`: between Invitations and Activity is the default.\n *\n * `labels` is the `adminArea` namespace, resolved — {@link useAdminAreaLabels} inside a\n * component, or the app's catalogue for the language; `undefined` is English. Throws for\n * an own section whose id is a shared one, an id given twice, or an `after` that names no\n * section: the catalogue is built once, and a section quietly missing from it is worse.\n */\nexport function adminSections<G extends string = never, L extends AdminSharedSection = AdminSharedSection>(\n labels: AdminAreaLabels | undefined,\n own: readonly AdminOwnSection<G>[] = [],\n options: AdminSectionsOptions<L> = {},\n): SettingsGroup<AdminKeptSection<L> | G>[] {\n const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;\n return orderSections(own, options.leaveOut).map((s): SettingsGroup<AdminKeptSection<L> | G> => {\n if (\"own\" in s) {\n const { after: _after, ...group } = s.own;\n return group;\n }\n const { id, icon } = s.shared;\n const visible = options.visible?.[id];\n return {\n id: id as AdminKeptSection<L>,\n icon: createElement(icon, { \"aria-hidden\": true }) as ReactNode,\n title: words.sections[id].title,\n help: words.sections[id].help,\n // 0.43 (kastlan): the overview is a page of tiles, not of setting cards — it shows\n // with no entry of its own.\n ...(id === \"overview\" ? { standalone: true } : null),\n ...(visible === undefined ? null : { visible }),\n };\n });\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAE9B,SAAS,SAAS,iBAAiB,MAAM,SAAS,aAAa;AAG/D,SAAS,iCAAiC;AAoBnC,MAAM,iBAAoD,OAAO,OAAO;AAAA,EAC7E,EAAE,IAAI,YAAY,MAAM,gBAAgB;AAAA,EACxC,EAAE,IAAI,SAAS,MAAM,MAAM;AAAA,EAC3B,EAAE,IAAI,eAAe,MAAM,KAAK;AAAA,EAChC,EAAE,IAAI,WAAW,MAAM,QAAQ;AAAA,EAC/B,EAAE,IAAI,YAAY,MAAM,QAAQ;AAClC,CAAC;AAiDD,MAAM,oBAAwC;AAI9C,SAAS,cACP,KACA,aACqD;AACrD,QAAM,WAAW,IAAI,IAAY,eAAe,CAAC,CAAC;AAClD,QAAM,SAAS,IAAI,IAAY,eAAe,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9D,QAAM,SAAS,oBAAI,IAAY;AAC/B,aAAW,WAAW,KAAK;AACzB,QAAI,OAAO,IAAI,QAAQ,EAAE,EAAG,OAAM,IAAI,MAAM,mBAAmB,QAAQ,EAAE,4BAA4B;AACrG,QAAI,OAAO,IAAI,QAAQ,EAAE,EAAG,OAAM,IAAI,MAAM,mBAAmB,QAAQ,EAAE,kBAAkB;AAC3F,WAAO,IAAI,QAAQ,EAAE;AAAA,EACvB;AACA,aAAW,WAAW,KAAK;AACzB,UAAM,QAAQ,QAAQ;AACtB,QAAI,UAAU,UAAa,CAAC,OAAO,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,GAAG;AACnE,YAAM,IAAI,MAAM,mBAA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,SAAS,GAAG;AACd,YAAM,EAAE,OAAO,QAAQ,GAAG,MAAM,IAAI,EAAE;AACtC,aAAO;AAAA,IACT;AACA,UAAM,EAAE,IAAI,KAAK,IAAI,EAAE;AACvB,UAAM,UAAU,QAAQ,UAAU,EAAE;AACpC,WAAO;AAAA,MACL;AAAA,MACA,MAAM,cAAc,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,MACjD,OAAO,MAAM,SAAS,EAAE,EAAE;AAAA,MAC1B,MAAM,MAAM,SAAS,EAAE,EAAE;AAAA;AAAA;AAAA,MAGzB,GAAI,OAAO,aAAa,EAAE,YAAY,KAAK,IAAI;AAAA,MAC/C,GAAI,YAAY,SAAY,OAAO,EAAE,QAAQ;AAAA,IAC/C;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,48 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { ListItemLinkProps } from "../components/list.js";
3
+ import type { LabelOverride } from "../i18n/kit-labels.js";
4
+ import type { AdminAreaLabels } from "./admin-area-labels.js";
5
+ /** One link of the Tools list. */
6
+ export interface AdminToolLink {
7
+ /** Unique in the list. */
8
+ key: string;
9
+ label: string;
10
+ href: string;
11
+ /** A lucide element, sized by the row. */
12
+ icon?: ReactNode;
13
+ /** `false` leaves the link out — Translations for an admin who doesn't review
14
+ * (§6.11, ka F7). Default: shown. */
15
+ visible?: boolean;
16
+ }
17
+ export interface AdminToolLinksProps {
18
+ links: readonly AdminToolLink[];
19
+ /**
20
+ * `sidebar` (default): a `<nav>` named and headed "Tools", for `SettingsLayout`'s
21
+ * `sidebarFooter` under the section list on a desktop. `list`: the bare rows, for
22
+ * `SettingsLayout`'s `phoneFooter`, which puts them in a list of their own.
23
+ */
24
+ variant?: "sidebar" | "list";
25
+ /** Your router's link. Default: the `<UiKitProvider linkComponent>`, then `<a>`. */
26
+ renderLink?: (props: ListItemLinkProps) => ReactElement;
27
+ /** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */
28
+ labels?: LabelOverride<AdminAreaLabels>;
29
+ className?: string;
30
+ }
31
+ /**
32
+ * The admin area's links to the admin tools that are pages of their own (0.42.0,
33
+ * docs/admin-harmonization.md §2.5 decision 16, §6.11): Translations, and the app's task
34
+ * pages (kastlan's Data import). The feedback inbox is not one of them: the top bar's
35
+ * feedback menu reaches it, and the overview's tiles link to it.
36
+ *
37
+ * Draw it twice from one list — at the foot of the section sidebar and in the phone
38
+ * footer:
39
+ *
40
+ * <SettingsLayout
41
+ * sidebarFooter={<AdminToolLinks links={TOOLS} />}
42
+ * phoneFooter={<AdminToolLinks links={TOOLS} variant="list" />}
43
+ * …
44
+ * />
45
+ *
46
+ * With no visible link it renders nothing.
47
+ */
48
+ export declare function AdminToolLinks({ links, variant, renderLink, labels: labelsProp, className }: AdminToolLinksProps): import("react").JSX.Element | null;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ import { cn } from "../lib/cn.js";
5
+ import { List, ListItem } from "../components/list.js";
6
+ import { useAdminAreaLabels } from "./admin-area-labels.js";
7
+ function AdminToolLinks({ links, variant = "sidebar", renderLink, labels: labelsProp, className }) {
8
+ const labels = useAdminAreaLabels(labelsProp);
9
+ const headingId = useId();
10
+ const shown = links.filter((l) => l.visible !== false);
11
+ if (shown.length === 0) return null;
12
+ const rows = shown.map((l) => /* @__PURE__ */ jsx(
13
+ ListItem,
14
+ {
15
+ href: l.href,
16
+ renderLink,
17
+ title: l.label,
18
+ leading: l.icon === void 0 ? void 0 : /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "flex shrink-0 text-muted [&_svg]:size-4", children: l.icon })
19
+ },
20
+ l.key
21
+ ));
22
+ if (variant === "list") return /* @__PURE__ */ jsx(Fragment, { children: rows });
23
+ return /* @__PURE__ */ jsxs("nav", { "data-slot": "admin-tool-links", "aria-labelledby": headingId, className: cn("space-y-1", className), children: [
24
+ /* @__PURE__ */ jsx("div", { id: headingId, className: "px-3 text-caption font-semibold uppercase tracking-wide text-muted", children: labels.tools }),
25
+ /* @__PURE__ */ jsx(List, { density: "compact", children: rows })
26
+ ] });
27
+ }
28
+ export {
29
+ AdminToolLinks
30
+ };
31
+ //# sourceMappingURL=admin-tool-links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/admin/admin-tool-links.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { List, ListItem } from \"../components/list\";\nimport type { ListItemLinkProps } from \"../components/list\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { useAdminAreaLabels } from \"./admin-area-labels\";\nimport type { AdminAreaLabels } from \"./admin-area-labels\";\n\n/** One link of the Tools list. */\nexport interface AdminToolLink {\n /** Unique in the list. */\n key: string;\n label: string;\n href: string;\n /** A lucide element, sized by the row. */\n icon?: ReactNode;\n /** `false` leaves the link out — Translations for an admin who doesn't review\n * (§6.11, ka F7). Default: shown. */\n visible?: boolean;\n}\n\nexport interface AdminToolLinksProps {\n links: readonly AdminToolLink[];\n /**\n * `sidebar` (default): a `<nav>` named and headed \"Tools\", for `SettingsLayout`'s\n * `sidebarFooter` under the section list on a desktop. `list`: the bare rows, for\n * `SettingsLayout`'s `phoneFooter`, which puts them in a list of their own.\n */\n variant?: \"sidebar\" | \"list\";\n /** Your router's link. Default: the `<UiKitProvider linkComponent>`, then `<a>`. */\n renderLink?: (props: ListItemLinkProps) => ReactElement;\n /** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */\n labels?: LabelOverride<AdminAreaLabels>;\n className?: string;\n}\n\n/**\n * The admin area's links to the admin tools that are pages of their own (0.42.0,\n * docs/admin-harmonization.md §2.5 decision 16, §6.11): Translations, and the app's task\n * pages (kastlan's Data import). The feedback inbox is not one of them: the top bar's\n * feedback menu reaches it, and the overview's tiles link to it.\n *\n * Draw it twice from one list — at the foot of the section sidebar and in the phone\n * footer:\n *\n * <SettingsLayout\n * sidebarFooter={<AdminToolLinks links={TOOLS} />}\n * phoneFooter={<AdminToolLinks links={TOOLS} variant=\"list\" />}\n * …\n * />\n *\n * With no visible link it renders nothing.\n */\nexport function AdminToolLinks({ links, variant = \"sidebar\", renderLink, labels: labelsProp, className }: AdminToolLinksProps) {\n const labels = useAdminAreaLabels(labelsProp);\n const headingId = useId();\n const shown = links.filter((l) => l.visible !== false);\n if (shown.length === 0) return null;\n const rows = shown.map((l) => (\n <ListItem\n key={l.key}\n href={l.href}\n renderLink={renderLink}\n title={l.label}\n leading={\n l.icon === undefined ? undefined : (\n <span aria-hidden className=\"flex shrink-0 text-muted [&_svg]:size-4\">\n {l.icon}\n </span>\n )\n }\n />\n ));\n if (variant === \"list\") return <>{rows}</>;\n return (\n <nav data-slot=\"admin-tool-links\" aria-labelledby={headingId} className={cn(\"space-y-1\", className)}>\n <div id={headingId} className=\"px-3 text-caption font-semibold uppercase tracking-wide text-muted\">\n {labels.tools}\n </div>\n <List density=\"compact\">{rows}</List>\n </nav>\n );\n}\n"],"mappings":";AAmEU,SAOuB,UAPvB,KASN,YATM;AAnEV,SAAS,aAAa;AAEtB,SAAS,UAAU;AACnB,SAAS,MAAM,gBAAgB;AAG/B,SAAS,0BAA0B;AAgD5B,SAAS,eAAe,EAAE,OAAO,UAAU,WAAW,YAAY,QAAQ,YAAY,UAAU,GAAwB;AAC7H,QAAM,SAAS,mBAAmB,UAAU;AAC5C,QAAM,YAAY,MAAM;AACxB,QAAM,QAAQ,MAAM,OAAO,CAAC,MAAM,EAAE,YAAY,KAAK;AACrD,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,OAAO,MAAM,IAAI,CAAC,MACtB;AAAA,IAAC;AAAA;AAAA,MAEC,MAAM,EAAE;AAAA,MACR;AAAA,MACA,OAAO,EAAE;AAAA,MACT,SACE,EAAE,SAAS,SAAY,SACrB,oBAAC,UAAK,eAAW,MAAC,WAAU,2CACzB,YAAE,MACL;AAAA;AAAA,IARC,EAAE;AAAA,EAWT,CACD;AACD,MAAI,YAAY,OAAQ,QAAO,gCAAG,gBAAK;AACvC,SACE,qBAAC,SAAI,aAAU,oBAAmB,mBAAiB,WAAW,WAAW,GAAG,aAAa,SAAS,GAChG;AAAA,wBAAC,SAAI,IAAI,WAAW,WAAU,sEAC3B,iBAAO,OACV;AAAA,IACA,oBAAC,QAAK,SAAQ,WAAW,gBAAK;AAAA,KAChC;AAEJ;","names":[]}
@@ -2,6 +2,7 @@ import type { ComponentPropsWithRef } from "react";
2
2
  import type { LabelOverride } from "../i18n/kit-labels.js";
3
3
  import type { AlertSize, AlertTone } from "../components/alert-banner.js";
4
4
  import type { BillingLabels } from "./billing-labels.js";
5
+ import type { BillingPortalAccess } from "./billing-overview.js";
5
6
  /**
6
7
  * The billing banners (docs/billing-harmonization.md §3.3, §7, §12.6, §12.21):
7
8
  *
@@ -9,7 +10,8 @@ import type { BillingLabels } from "./billing-labels.js";
9
10
  * - `grant-ending` — from 7 days before `comped_until`: a beta user's 12 months, an
10
11
  * operator's grant;
11
12
  * - `payment-failed` — from the first failed payment (`past_due`), while the provider
12
- * retries;
13
+ * retries; since 0.42, for an admin who isn't the buyer (`portal="buyer_only"`), it
14
+ * names who can update the payment method, with no button;
13
15
  * - `plan-ended` — out of good standing: read-only, never locked (§2.3);
14
16
  * - `guest` — a guest in someone else's read-only item (§12.6);
15
17
  * - `processing` — back from checkout before the webhook landed (§12.21).
@@ -50,6 +52,14 @@ interface BillingBannerBaseProps extends Omit<ComponentPropsWithRef<"div">, "chi
50
52
  actionLabel?: string;
51
53
  /** The action is under way: the button's spinner, no second press. */
52
54
  actionPending?: boolean;
55
+ /**
56
+ * 0.43 (§17): the action opens the provider's portal in a NEW TAB (`openProviderPage`
57
+ * in {@link onAction}): the external-link mark, "(opens in a new tab)" for a reader,
58
+ * and `target="_blank"` on an {@link actionHref}. Default: true for `payment-failed`
59
+ * with `onAction` (the portal's card page), false otherwise — an `actionHref` is
60
+ * usually the app's own subscription page.
61
+ */
62
+ actionNewTab?: boolean;
53
63
  /** An × that calls this; the app removes the banner and remembers that it did. */
54
64
  onDismiss?: () => void;
55
65
  dismissLabel?: string;
@@ -61,16 +71,37 @@ export type BillingBannerProps = BillingBannerBaseProps & ({
61
71
  /** Calendar days left — `billingDaysLeft(trial_ends_at)`. 0 is today. */
62
72
  daysLeft: number;
63
73
  item?: never;
74
+ portal?: never;
75
+ buyerName?: never;
64
76
  } | {
65
77
  kind: "guest";
66
78
  /** The item's own name ("Household 2026"), or nothing. NEVER the owner's status:
67
79
  * the banner says "for now" and nothing more (§12.6). */
68
80
  item?: string;
69
81
  daysLeft?: never;
82
+ portal?: never;
83
+ buyerName?: never;
84
+ } | {
85
+ kind: "payment-failed";
86
+ /**
87
+ * 0.42 (§16.7 A, §16.8): `GET /billing/status`'s `portal` (`BillingStanding`).
88
+ * `"buyer_only"` — the viewer isn't the buyer, so the portal's page for the card
89
+ * would answer 403: the banner says who can update the payment method
90
+ * (`paymentFailedAskBuyer`) and shows NO button, whatever `actionHref` or
91
+ * `onAction` say. `"open"` (default): as before.
92
+ */
93
+ portal?: BillingPortalAccess;
94
+ /** 0.42: the status's `buyer_name`, under `"buyer_only"`. Empty: "…the admin who
95
+ * bought the subscription". */
96
+ buyerName?: string | null;
97
+ daysLeft?: never;
98
+ item?: never;
70
99
  } | {
71
- kind: "payment-failed" | "plan-ended" | "processing";
100
+ kind: "plan-ended" | "processing";
72
101
  daysLeft?: never;
73
102
  item?: never;
103
+ portal?: never;
104
+ buyerName?: never;
74
105
  });
75
106
  /**
76
107
  * One of the billing banners, as a kit `AlertBanner` strip (§7): the kind's sentence, its
@@ -1,10 +1,12 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { CreditCard, Hourglass, PencilOff } from "lucide-react";
4
+ import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
4
5
  import { AlertBanner } from "../components/alert-banner.js";
5
6
  import { Button } from "../components/button.js";
6
7
  import { Spinner } from "../components/spinner.js";
7
8
  import { useBillingLabels } from "./billing-labels.js";
9
+ import { ExternalMark } from "./subscription-actions.js";
8
10
  const LAST_DAYS = 3;
9
11
  function defaultTone(kind, daysLeft) {
10
12
  switch (kind) {
@@ -24,6 +26,8 @@ function BillingBanner(props) {
24
26
  kind,
25
27
  daysLeft,
26
28
  item,
29
+ portal,
30
+ buyerName,
27
31
  tone,
28
32
  variant = "strip",
29
33
  size,
@@ -31,6 +35,7 @@ function BillingBanner(props) {
31
35
  onAction,
32
36
  actionLabel,
33
37
  actionPending,
38
+ actionNewTab,
34
39
  onDismiss,
35
40
  dismissLabel,
36
41
  labels: labelsProp,
@@ -38,10 +43,12 @@ function BillingBanner(props) {
38
43
  ...rest
39
44
  } = props;
40
45
  const labels = useBillingLabels(labelsProp);
46
+ const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
41
47
  const days = Math.max(0, Math.floor(daysLeft ?? 0));
42
48
  let text;
43
49
  let icon;
44
50
  let ownAction;
51
+ const askBuyer = kind === "payment-failed" && portal === "buyer_only";
45
52
  switch (kind) {
46
53
  case "trial-ending":
47
54
  text = labels.trialEnding(days);
@@ -54,7 +61,7 @@ function BillingBanner(props) {
54
61
  ownAction = labels.choosePlan;
55
62
  break;
56
63
  case "payment-failed":
57
- text = labels.paymentFailed;
64
+ text = askBuyer ? labels.paymentFailedAskBuyer(buyerName || void 0) : labels.paymentFailed;
58
65
  icon = /* @__PURE__ */ jsx(CreditCard, {});
59
66
  ownAction = labels.updatePayment;
60
67
  break;
@@ -75,7 +82,26 @@ function BillingBanner(props) {
75
82
  break;
76
83
  }
77
84
  const words = actionLabel ?? ownAction;
78
- const action = words === void 0 || actionHref === void 0 && onAction === void 0 ? void 0 : actionHref !== void 0 ? /* @__PURE__ */ jsx(Button, { href: actionHref, variant: "secondary", size: "sm", children: words }) : /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", size: "sm", onClick: onAction, pending: actionPending, children: words });
85
+ const newTab = actionNewTab ?? (kind === "payment-failed" && actionHref === void 0 && onAction !== void 0);
86
+ const action = askBuyer || words === void 0 || actionHref === void 0 && onAction === void 0 ? void 0 : actionHref !== void 0 ? /* @__PURE__ */ jsxs(Button, { href: actionHref, variant: "secondary", size: "sm", external: newTab || void 0, children: [
87
+ words,
88
+ newTab && /* @__PURE__ */ jsx(ExternalMark, {})
89
+ ] }) : /* @__PURE__ */ jsxs(
90
+ Button,
91
+ {
92
+ type: "button",
93
+ variant: "secondary",
94
+ size: "sm",
95
+ onClick: onAction,
96
+ pending: actionPending,
97
+ className: newTab ? "relative" : void 0,
98
+ "data-portal-action": newTab ? "payment_method" : void 0,
99
+ children: [
100
+ words,
101
+ newTab && /* @__PURE__ */ jsx(ExternalMark, { reader: common.opensInNewTab })
102
+ ]
103
+ }
104
+ );
79
105
  return /* @__PURE__ */ jsx(
80
106
  AlertBanner,
81
107
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/billing/billing-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { CreditCard, Hourglass, PencilOff } from \"lucide-react\";\n\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport type { AlertSize, AlertTone } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Spinner } from \"../components/spinner\";\nimport { useBillingLabels } from \"./billing-labels\";\nimport type { BillingLabels } from \"./billing-labels\";\n\n/**\n * The billing banners (docs/billing-harmonization.md §3.3, §7, §12.6, §12.21):\n *\n * - `trial-ending` — from 7 days before `trial_ends_at` (§3.3);\n * - `grant-ending` — from 7 days before `comped_until`: a beta user's 12 months, an\n * operator's grant;\n * - `payment-failed` — from the first failed payment (`past_due`), while the provider\n * retries;\n * - `plan-ended` — out of good standing: read-only, never locked (§2.3);\n * - `guest` — a guest in someone else's read-only item (§12.6);\n * - `processing` — back from checkout before the webhook landed (§12.21).\n */\nexport type BillingBannerKind =\n | \"trial-ending\"\n | \"grant-ending\"\n | \"payment-failed\"\n | \"plan-ended\"\n | \"guest\"\n | \"processing\";\n\n/** A `div`'s props, `ref` included since 0.35 (round 0.35 R4, the follow-up to API-2): they\n * go on to the {@link AlertBanner}, so the ref is the banner's `<div>` — with an × too,\n * since the banner has no `href` or `onClick` that would make its row a link or a button. */\ninterface BillingBannerBaseProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onClick\"> {\n /**\n * Over the kind's tone: `trial-ending` and `grant-ending` are `info` until the last\n * three days and `warning` in them; `payment-failed` is `danger` (money did not\n * arrive — kastlan's past-due strip was red); `plan-ended` is `warning`, a state with\n * everything still there rather than an error; `guest` and `processing` are `info`.\n */\n tone?: AlertTone;\n /** `strip` (default): the band under the top bar, on every page. `box`: the same\n * message on the subscription page itself. */\n variant?: \"strip\" | \"box\";\n /** Default `sm` for a strip (the demo's banner), `md` for a box. */\n size?: AlertSize;\n /**\n * Where the action goes — the subscription page, say. The app's action, as an `href`\n * or as {@link onAction}; without either there is no button. Never a write-locked\n * commit: billing itself always works (§3.3).\n */\n actionHref?: string;\n /** What the action does — the app's portal call (`POST /billing/portal`, then off to\n * its `url`): for `payment-failed` with `{target: \"payment_method\"}`, the portal's\n * page for the card (§14.5); for `processing`, `useCheckoutProcessing`'s\n * `checkAgain`. The kit sends no request. */\n onAction?: () => void;\n /**\n * Over the kind's action words: \"Choose a plan\" (trial, grant, plan ended), \"Update\n * payment method\" (payment failed), \"Check again\" (processing). The guest banner has\n * none of its own: an action there needs this.\n */\n actionLabel?: string;\n /** The action is under way: the button's spinner, no second press. */\n actionPending?: boolean;\n /** An × that calls this; the app removes the banner and remembers that it did. */\n onDismiss?: () => void;\n dismissLabel?: string;\n /** Prop > `<UiKitProvider labels={{ billing }}>` > English. */\n labels?: LabelOverride<BillingLabels>;\n}\n\nexport type BillingBannerProps = BillingBannerBaseProps &\n (\n | {\n kind: \"trial-ending\" | \"grant-ending\";\n /** Calendar days left — `billingDaysLeft(trial_ends_at)`. 0 is today. */\n daysLeft: number;\n item?: never;\n }\n | {\n kind: \"guest\";\n /** The item's own name (\"Household 2026\"), or nothing. NEVER the owner's status:\n * the banner says \"for now\" and nothing more (§12.6). */\n item?: string;\n daysLeft?: never;\n }\n | {\n kind: \"payment-failed\" | \"plan-ended\" | \"processing\";\n daysLeft?: never;\n item?: never;\n }\n );\n\n/** The last days, in which an ending trial or grant turns from news into a warning. */\nconst LAST_DAYS = 3;\n\nfunction defaultTone(kind: BillingBannerKind, daysLeft: number | undefined): AlertTone {\n switch (kind) {\n case \"trial-ending\":\n case \"grant-ending\":\n return (daysLeft ?? 0) > LAST_DAYS ? \"info\" : \"warning\";\n case \"payment-failed\":\n return \"danger\";\n case \"plan-ended\":\n return \"warning\";\n default:\n return \"info\";\n }\n}\n\n/**\n * One of the billing banners, as a kit `AlertBanner` strip (§7): the kind's sentence, its\n * glyph and tone, and the app's action. Carries `data-billing-banner` with the kind.\n *\n * The app decides WHICH banner shows, from `GET /billing/overview` (and hides all of them\n * while billing is off, §4); the kit only says it. A guest's banner takes no status at\n * all — the type does not let one in — so the owner's payment state cannot leak into it\n * by a wrong prop (§12.6).\n *\n * `processing` is a live region (`role=\"status\"`): it appears when the person comes back\n * from checkout and goes when the overview catches up (§12.21), and a screen reader\n * should hear both. The others are page furniture, role-less as the strip is.\n */\nexport function BillingBanner(props: BillingBannerProps) {\n const {\n kind,\n daysLeft,\n item,\n tone,\n variant = \"strip\",\n size,\n actionHref,\n onAction,\n actionLabel,\n actionPending,\n onDismiss,\n dismissLabel,\n labels: labelsProp,\n role,\n ...rest\n } = props;\n const labels = useBillingLabels(labelsProp);\n const days = Math.max(0, Math.floor(daysLeft ?? 0));\n\n let text: string;\n let icon: ReactNode;\n let ownAction: string | undefined;\n switch (kind) {\n case \"trial-ending\":\n text = labels.trialEnding(days);\n icon = <Hourglass />;\n ownAction = labels.choosePlan;\n break;\n case \"grant-ending\":\n text = labels.grantEnding(days);\n icon = <Hourglass />;\n ownAction = labels.choosePlan;\n break;\n case \"payment-failed\":\n text = labels.paymentFailed;\n icon = <CreditCard />;\n ownAction = labels.updatePayment;\n break;\n case \"plan-ended\":\n text = labels.planEnded;\n icon = <PencilOff />;\n ownAction = labels.choosePlan;\n break;\n case \"guest\":\n text = labels.guestReadOnly(item);\n icon = <PencilOff />;\n ownAction = undefined;\n break;\n case \"processing\":\n text = labels.processing;\n icon = <Spinner label={null} />;\n ownAction = labels.checkAgain;\n break;\n }\n\n const words = actionLabel ?? ownAction;\n const action =\n words === undefined || (actionHref === undefined && onAction === undefined) ? undefined : actionHref !== undefined ? (\n <Button href={actionHref} variant=\"secondary\" size=\"sm\">\n {words}\n </Button>\n ) : (\n <Button type=\"button\" variant=\"secondary\" size=\"sm\" onClick={onAction} pending={actionPending}>\n {words}\n </Button>\n );\n\n return (\n <AlertBanner\n {...rest}\n role={role ?? (kind === \"processing\" ? \"status\" : undefined)}\n variant={variant}\n size={size ?? (variant === \"strip\" ? \"sm\" : \"md\")}\n tone={tone ?? defaultTone(kind, days)}\n icon={icon}\n action={action}\n onDismiss={onDismiss}\n dismissLabel={dismissLabel}\n data-billing-banner={kind}\n >\n {text}\n </AlertBanner>\n );\n}\n"],"mappings":";AAwJa;AAvJb,SAAS,YAAY,WAAW,iBAAiB;AAGjD,SAAS,mBAAmB;AAE5B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAwFjC,MAAM,YAAY;AAElB,SAAS,YAAY,MAAyB,UAAyC;AACrF,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AACH,cAAQ,YAAY,KAAK,YAAY,SAAS;AAAA,IAChD,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAeO,SAAS,cAAc,OAA2B;AACvD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AA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OAAO;AAAA,MAC5C,MAAM,QAAQ,YAAY,MAAM,IAAI;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAqB;AAAA,MAEpB;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/billing/billing-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { CreditCard, Hourglass, PencilOff } from \"lucide-react\";\n\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport type { AlertSize, AlertTone } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Spinner } from \"../components/spinner\";\nimport { useBillingLabels } from \"./billing-labels\";\nimport type { BillingLabels } from \"./billing-labels\";\nimport type { BillingPortalAccess } from \"./billing-overview\";\nimport { ExternalMark } from \"./subscription-actions\";\n\n/**\n * The billing banners (docs/billing-harmonization.md §3.3, §7, §12.6, §12.21):\n *\n * - `trial-ending` — from 7 days before `trial_ends_at` (§3.3);\n * - `grant-ending` — from 7 days before `comped_until`: a beta user's 12 months, an\n * operator's grant;\n * - `payment-failed` — from the first failed payment (`past_due`), while the provider\n * retries; since 0.42, for an admin who isn't the buyer (`portal=\"buyer_only\"`), it\n * names who can update the payment method, with no button;\n * - `plan-ended` — out of good standing: read-only, never locked (§2.3);\n * - `guest` — a guest in someone else's read-only item (§12.6);\n * - `processing` — back from checkout before the webhook landed (§12.21).\n */\nexport type BillingBannerKind =\n | \"trial-ending\"\n | \"grant-ending\"\n | \"payment-failed\"\n | \"plan-ended\"\n | \"guest\"\n | \"processing\";\n\n/** A `div`'s props, `ref` included since 0.35 (round 0.35 R4, the follow-up to API-2): they\n * go on to the {@link AlertBanner}, so the ref is the banner's `<div>` — with an × too,\n * since the banner has no `href` or `onClick` that would make its row a link or a button. */\ninterface BillingBannerBaseProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onClick\"> {\n /**\n * Over the kind's tone: `trial-ending` and `grant-ending` are `info` until the last\n * three days and `warning` in them; `payment-failed` is `danger` (money did not\n * arrive — kastlan's past-due strip was red); `plan-ended` is `warning`, a state with\n * everything still there rather than an error; `guest` and `processing` are `info`.\n */\n tone?: AlertTone;\n /** `strip` (default): the band under the top bar, on every page. `box`: the same\n * message on the subscription page itself. */\n variant?: \"strip\" | \"box\";\n /** Default `sm` for a strip (the demo's banner), `md` for a box. */\n size?: AlertSize;\n /**\n * Where the action goes — the subscription page, say. The app's action, as an `href`\n * or as {@link onAction}; without either there is no button. Never a write-locked\n * commit: billing itself always works (§3.3).\n */\n actionHref?: string;\n /** What the action does — the app's portal call (`POST /billing/portal`, then off to\n * its `url`): for `payment-failed` with `{target: \"payment_method\"}`, the portal's\n * page for the card (§14.5); for `processing`, `useCheckoutProcessing`'s\n * `checkAgain`. The kit sends no request. */\n onAction?: () => void;\n /**\n * Over the kind's action words: \"Choose a plan\" (trial, grant, plan ended), \"Update\n * payment method\" (payment failed), \"Check again\" (processing). The guest banner has\n * none of its own: an action there needs this.\n */\n actionLabel?: string;\n /** The action is under way: the button's spinner, no second press. */\n actionPending?: boolean;\n /**\n * 0.43 (§17): the action opens the provider's portal in a NEW TAB (`openProviderPage`\n * in {@link onAction}): the external-link mark, \"(opens in a new tab)\" for a reader,\n * and `target=\"_blank\"` on an {@link actionHref}. Default: true for `payment-failed`\n * with `onAction` (the portal's card page), false otherwise — an `actionHref` is\n * usually the app's own subscription page.\n */\n actionNewTab?: boolean;\n /** An × that calls this; the app removes the banner and remembers that it did. */\n onDismiss?: () => void;\n dismissLabel?: string;\n /** Prop > `<UiKitProvider labels={{ billing }}>` > English. */\n labels?: LabelOverride<BillingLabels>;\n}\n\nexport type BillingBannerProps = BillingBannerBaseProps &\n (\n | {\n kind: \"trial-ending\" | \"grant-ending\";\n /** Calendar days left — `billingDaysLeft(trial_ends_at)`. 0 is today. */\n daysLeft: number;\n item?: never;\n portal?: never;\n buyerName?: never;\n }\n | {\n kind: \"guest\";\n /** The item's own name (\"Household 2026\"), or nothing. NEVER the owner's status:\n * the banner says \"for now\" and nothing more (§12.6). */\n item?: string;\n daysLeft?: never;\n portal?: never;\n buyerName?: never;\n }\n | {\n kind: \"payment-failed\";\n /**\n * 0.42 (§16.7 A, §16.8): `GET /billing/status`'s `portal` (`BillingStanding`).\n * `\"buyer_only\"` — the viewer isn't the buyer, so the portal's page for the card\n * would answer 403: the banner says who can update the payment method\n * (`paymentFailedAskBuyer`) and shows NO button, whatever `actionHref` or\n * `onAction` say. `\"open\"` (default): as before.\n */\n portal?: BillingPortalAccess;\n /** 0.42: the status's `buyer_name`, under `\"buyer_only\"`. Empty: \"…the admin who\n * bought the subscription\". */\n buyerName?: string | null;\n daysLeft?: never;\n item?: never;\n }\n | {\n kind: \"plan-ended\" | \"processing\";\n daysLeft?: never;\n item?: never;\n portal?: never;\n buyerName?: never;\n }\n );\n\n/** The last days, in which an ending trial or grant turns from news into a warning. */\nconst LAST_DAYS = 3;\n\nfunction defaultTone(kind: BillingBannerKind, daysLeft: number | undefined): AlertTone {\n switch (kind) {\n case \"trial-ending\":\n case \"grant-ending\":\n return (daysLeft ?? 0) > LAST_DAYS ? \"info\" : \"warning\";\n case \"payment-failed\":\n return \"danger\";\n case \"plan-ended\":\n return \"warning\";\n default:\n return \"info\";\n }\n}\n\n/**\n * One of the billing banners, as a kit `AlertBanner` strip (§7): the kind's sentence, its\n * glyph and tone, and the app's action. Carries `data-billing-banner` with the kind.\n *\n * The app decides WHICH banner shows, from `GET /billing/overview` (and hides all of them\n * while billing is off, §4); the kit only says it. A guest's banner takes no status at\n * all — the type does not let one in — so the owner's payment state cannot leak into it\n * by a wrong prop (§12.6).\n *\n * `processing` is a live region (`role=\"status\"`): it appears when the person comes back\n * from checkout and goes when the overview catches up (§12.21), and a screen reader\n * should hear both. The others are page furniture, role-less as the strip is.\n */\nexport function BillingBanner(props: BillingBannerProps) {\n const {\n kind,\n daysLeft,\n item,\n portal,\n buyerName,\n tone,\n variant = \"strip\",\n size,\n actionHref,\n onAction,\n actionLabel,\n actionPending,\n actionNewTab,\n onDismiss,\n dismissLabel,\n labels: labelsProp,\n role,\n ...rest\n } = props;\n const labels = useBillingLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const days = Math.max(0, Math.floor(daysLeft ?? 0));\n\n let text: string;\n let icon: ReactNode;\n let ownAction: string | undefined;\n // 0.42 (§16.7 A): only the buyer can reach the portal's card page.\n const askBuyer = kind === \"payment-failed\" && portal === \"buyer_only\";\n switch (kind) {\n case \"trial-ending\":\n text = labels.trialEnding(days);\n icon = <Hourglass />;\n ownAction = labels.choosePlan;\n break;\n case \"grant-ending\":\n text = labels.grantEnding(days);\n icon = <Hourglass />;\n ownAction = labels.choosePlan;\n break;\n case \"payment-failed\":\n text = askBuyer ? labels.paymentFailedAskBuyer(buyerName || undefined) : labels.paymentFailed;\n icon = <CreditCard />;\n ownAction = labels.updatePayment;\n break;\n case \"plan-ended\":\n text = labels.planEnded;\n icon = <PencilOff />;\n ownAction = labels.choosePlan;\n break;\n case \"guest\":\n text = labels.guestReadOnly(item);\n icon = <PencilOff />;\n ownAction = undefined;\n break;\n case \"processing\":\n text = labels.processing;\n icon = <Spinner label={null} />;\n ownAction = labels.checkAgain;\n break;\n }\n\n const words = actionLabel ?? ownAction;\n const newTab = actionNewTab ?? (kind === \"payment-failed\" && actionHref === undefined && onAction !== undefined);\n const action =\n askBuyer || words === undefined || (actionHref === undefined && onAction === undefined) ? undefined : actionHref !== undefined ? (\n <Button href={actionHref} variant=\"secondary\" size=\"sm\" external={newTab || undefined}>\n {words}\n {newTab && <ExternalMark />}\n </Button>\n ) : (\n <Button\n type=\"button\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onAction}\n pending={actionPending}\n className={newTab ? \"relative\" : undefined}\n data-portal-action={newTab ? \"payment_method\" : undefined}\n >\n {words}\n {newTab && <ExternalMark reader={common.opensInNewTab} />}\n </Button>\n );\n\n return (\n <AlertBanner\n {...rest}\n role={role ?? (kind === \"processing\" ? \"status\" : undefined)}\n variant={variant}\n size={size ?? (variant === \"strip\" ? \"sm\" : \"md\")}\n tone={tone ?? defaultTone(kind, days)}\n icon={icon}\n action={action}\n onDismiss={onDismiss}\n dismissLabel={dismissLabel}\n data-billing-banner={kind}\n >\n {text}\n </AlertBanner>\n );\n}\n"],"mappings":";AAgMa,cAkCP,YAlCO;AA/Lb,SAAS,YAAY,WAAW,iBAAiB;AAEjD,SAAS,uBAAuB,oBAAoB;AAEpD,SAAS,mBAAmB;AAE5B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,wBAAwB;AAGjC,SAAS,oBAAoB;AAsH7B,MAAM,YAAY;AAElB,SAAS,YAAY,MAAyB,UAAyC;AACrF,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AACH,cAAQ,YAAY,KAAK,YAAY,SAAS;AAAA,IAChD,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAeO,SAAS,cAAc,OAA2B;AACvD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,SAAS,iBAAiB,UAAU;AAC1C,QAAM,SAAS,aAAa,UAAU,qBAAqB;AAC3D,QAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,YAAY,CAAC,CAAC;AAElD,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,QAAM,WAAW,SAAS,oBAAoB,WAAW;AACzD,UAAQ,MAAM;AAAA,IACZ,KAAK;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D;AAAA,MACA,MAAM,SAAS,YAAY,UAAU,OAAO;AAAA,MAC5C,MAAM,QAAQ,YAAY,MAAM,IAAI;AAAA,MACpC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAqB;AAAA,MAEpB;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -91,6 +91,13 @@ export interface BillingLabels {
91
91
  choosePlan: string;
92
92
  /** The payment-failed banner's action, to the provider's portal: "Update payment method". */
93
93
  updatePayment: string;
94
+ /**
95
+ * 0.42 (§16.7 A, §16.8): the payment-failed banner for an admin who isn't the buyer
96
+ * (`portal: "buyer_only"`), with no button — only the buyer can change the card.
97
+ * `buyer` is their display name, or `undefined` when they are gone ("the admin who
98
+ * bought the subscription").
99
+ */
100
+ paymentFailedAskBuyer: (buyer?: string) => string;
94
101
  /** The processing banner's action, when the app gives one: "Check again". */
95
102
  checkAgain: string;
96
103
  /** The `WriteLockProvider` reason for the payer (§3.3, verbatim). A guest's reason is
@@ -129,6 +136,28 @@ export interface BillingLabels {
129
136
  * the words for `409 billing_not_at_provider`, a stale page that asked anyway.
130
137
  */
131
138
  notAtProvider: string;
139
+ /**
140
+ * In place of "Payment and invoices" for an admin who isn't the buyer (`portal:
141
+ * "buyer_only"`, §16.2 decision 3): the provider's portal opens only for the buyer.
142
+ * `buyer` is their display name — or `undefined` when they are gone or have left the
143
+ * company, and the words then say "the admin who bought the subscription".
144
+ */
145
+ buyerHolds: (buyer?: string) => string;
146
+ /** `CancelSubscriptionConfirm`'s title: "Cancel subscription". */
147
+ cancelConfirmTitle: string;
148
+ /** Its body; `date` is the period's end, formatted: "Your subscription ends on
149
+ * 9 Nov 2026. Until then everything works as before." */
150
+ cancelConfirmBody: (date: string) => string;
151
+ /** Its confirm button (§16.4): "Cancel subscription now". German: "Jetzt kündigen",
152
+ * the confirmation button's words in §312k BGB. */
153
+ cancelConfirmAction: string;
154
+ /** In place of "Cancel subscription" while a cancel is scheduled (§16.7 C, `POST
155
+ * /billing/resume`): "Keep subscription". */
156
+ keepSubscription: string;
157
+ /** 0.43 (§17.3): the muted note under the actions while the portal opens in a new tab —
158
+ * `provider` the provider's name ("Paddle"), `app` the app's; without the app, "this
159
+ * page". "Payment and invoices open at Paddle in a new tab; Kastlan stays open here." */
160
+ portalOpensNewTab: (provider: string, app?: string) => string;
132
161
  /** While the checkout opens. */
133
162
  payOpening: string;
134
163
  /** A link without a transaction, or billing switched off: nothing to pay. */
@@ -154,6 +183,13 @@ export interface BillingLabels {
154
183
  switchNextCharge: (date: string) => string;
155
184
  /** The confirm button: "Change plan". */
156
185
  switchConfirm: string;
186
+ /** The warning's title, before a checkout (`PlanPicker`) or a switch
187
+ * (`PlanSwitchConfirm`) under a grant without an end: "Your free access continues". */
188
+ grantWarningTitle: string;
189
+ /** What the purchase does under it: nothing to the plan while the grant runs. */
190
+ grantWarningBody: string;
191
+ /** `PlanPicker`'s button that goes on to the checkout: "Buy anyway". */
192
+ grantWarningAction: string;
157
193
  /** Changes refused as `billing_read_only` inside a sync reply, kept queued and sent
158
194
  * after payment: "3 changes waiting for a plan". */
159
195
  waitingChanges: (count: number) => string;
@@ -50,6 +50,7 @@ const DEFAULT_BILLING_LABELS = {
50
50
  processing: "Your payment is being processed. Your plan starts as soon as it\u2019s confirmed; this page updates by itself.",
51
51
  choosePlan: "Choose a plan",
52
52
  updatePayment: "Update payment method",
53
+ paymentFailedAskBuyer: (buyer) => buyer ? `The payment failed. ${buyer} can update the payment method.` : "The payment failed. The admin who bought the subscription can update the payment method.",
53
54
  checkAgain: "Check again",
54
55
  lockReason: "Your plan has ended. Choose a plan to make changes again.",
55
56
  limitReached: "Plan limit reached",
@@ -62,6 +63,12 @@ const DEFAULT_BILLING_LABELS = {
62
63
  manage: "Payment and invoices",
63
64
  cancel: "Cancel subscription",
64
65
  notAtProvider: "Nothing to manage yet. Payments and invoices appear here once you have a paid plan.",
66
+ buyerHolds: (buyer) => buyer ? `The payment method and the invoices are with ${buyer}, who bought the subscription.` : "The payment method and the invoices are with the admin who bought the subscription.",
67
+ cancelConfirmTitle: "Cancel subscription",
68
+ cancelConfirmBody: (date) => `Your subscription ends on ${date}. Until then everything works as before.`,
69
+ cancelConfirmAction: "Cancel subscription now",
70
+ keepSubscription: "Keep subscription",
71
+ portalOpensNewTab: (provider, app) => `Payment and invoices open at ${provider} in a new tab; ${app ? `${app} stays open here` : "this page stays open"}.`,
65
72
  payOpening: "Opening the secure checkout\u2026",
66
73
  payNothing: "There\u2019s no payment to make here. To choose a plan, go back to the app.",
67
74
  payFailed: "The checkout couldn\u2019t be opened. Please go back and try again in a moment.",
@@ -73,6 +80,9 @@ const DEFAULT_BILLING_LABELS = {
73
80
  switchCredited: "Credited towards your next charges",
74
81
  switchNextCharge: (date) => `Next charge on ${date}`,
75
82
  switchConfirm: "Change plan",
83
+ grantWarningTitle: "Your free access continues",
84
+ grantWarningBody: "You have free access with no end date. A purchase won\u2019t change your plan while the free access runs: you would pay for a plan that doesn\u2019t apply.",
85
+ grantWarningAction: "Buy anyway",
76
86
  waitingChanges: (count) => count === 1 ? "1 change waiting for a plan" : `${count} changes waiting for a plan`,
77
87
  discardWaiting: "Discard waiting changes",
78
88
  notConfigured: "Payments aren't set up yet. Please try again later.",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/billing/billing-labels.ts"],"sourcesContent":["import { useKitLabels } from \"../i18n/kit-labels\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\n\n/**\n * The subscription's status vocabulary (docs/billing-harmonization.md §3.2) — server-kit's\n * `SubscriptionStatus`, value for value:\n *\n * - `trialing` — the 30-day trial without a card (§2.7), or a pure guest's row whose trial\n * has not started (§12.9, `trial_ends_at` empty);\n * - `active` — paid;\n * - `past_due` — a payment failed; in good standing during the provider's retries (§3.3);\n * - `canceled` — the payer cancelled; the American spelling is the wire's, the word shown\n * is \"Cancelled\";\n * - `expired` — a trial, a grant or a failed subscription ran out: read-only (§2.3);\n * - `comped` — free by the operator's grant or as a beta user (§3.2, `comped_until`).\n */\nexport type SubscriptionStatus = \"trialing\" | \"active\" | \"past_due\" | \"canceled\" | \"expired\" | \"comped\";\n\n/** Every status, in the order a lifecycle reads: trial, paid, trouble, ended, granted. */\nexport const SUBSCRIPTION_STATUSES: readonly SubscriptionStatus[] = Object.freeze([\n \"trialing\",\n \"active\",\n \"past_due\",\n \"canceled\",\n \"expired\",\n \"comped\",\n]);\n\n/**\n * The words of the subscription parts — the `billing` namespace of `<UiKitProvider labels>`\n * (docs/billing-harmonization.md §7, §10; ui-kit 0.32.0).\n *\n * WORDING (§12.24): the English group is \"Subscription\", never \"Plan\" — keksdose's \"plan\"\n * is the month's budget plan (\"One plan per month\"), and two meanings of one word on one\n * settings page is the clash the review found. \"Plan\" stays the word for WHAT is bought\n * (Free, Pro), \"subscription\" for the standing arrangement. German says \"Tarif\" for the\n * plan and \"Abonnement\" for the subscription (§10).\n *\n * Prices are GROSS (§12.17): Swiss consumer law (PBV) wants a consumer price with the\n * MWST in it, so the cards say so (`vatIncluded`).\n */\nexport interface BillingLabels {\n /** The settings group or admin section the parts live on (§7, §12.24): \"Subscription\". */\n group: string;\n\n /* ── PlanPicker / PlanCard (§7) ── */\n /** The picker's name when it has no visible `legend`: \"Plans\". */\n plans: string;\n /** The name of the billing-period switch: \"Billing period\". */\n interval: string;\n /** The switch's two options — yearly first (§12.17). */\n yearly: string;\n monthly: string;\n /** The name of the currency switch: \"Currency\". */\n currency: string;\n /** After a price: \"per year\", \"per month\". */\n perYear: string;\n perMonth: string;\n /** Under a price (§12.17): \"VAT included\". German: \"inkl. MWST\". */\n vatIncluded: string;\n /** A plan with no price, or a price of 0: \"Free\". */\n free: string;\n /** A plan with prices, but none for this currency and period. */\n notOffered: string;\n /** A limit of `null` (§3.1): \"Unlimited\". */\n unlimited: string;\n /** The accessible names of a card's two lists. */\n limits: string;\n features: string;\n /** The chip on the payer's current plan. */\n current: string;\n /** The picker's button for `plan` (the plan's display name) with no current plan —\n * during a trial, or after a plan ended: \"Choose Pro\". */\n choose: (plan: string) => string;\n /** …for a plan after the current one in the catalogue's order: \"Upgrade to Pro\". */\n upgrade: (plan: string) => string;\n /** …for a plan before it: \"Switch to Free\". */\n downgrade: (plan: string) => string;\n /** Why the button is off while the current plan is the one picked. */\n isCurrent: string;\n /** Why it is off while nothing is picked. */\n pickFirst: string;\n\n /* ── SubscriptionStatusChip (§6) ── */\n /** One word per status. */\n status: Record<SubscriptionStatus, string>;\n\n /* ── BillingBanner (§3.3, §12.6, §12.21) ── */\n /** A trial ends in `days` calendar days — 0 is today, 1 tomorrow. */\n trialEnding: (days: number) => string;\n /** A free grant (`comped_until`: a beta user's 12 months, an operator's grant) ends in\n * `days` calendar days. */\n grantEnding: (days: number) => string;\n /** The first failed payment (`past_due`), while the provider retries. */\n paymentFailed: string;\n /** Out of good standing: read-only, never locked (§2.3). */\n planEnded: string;\n /**\n * A guest in someone else's item that is read-only for billing (§12.6). It never says\n * WHY beyond \"for now\": the owner's payment status is the owner's personal data.\n * `item` is the item's own name (\"Household 2026\"), shown in quotes — or `undefined`.\n */\n guestReadOnly: (item?: string) => string;\n /** Back from checkout before the provider's webhook landed (§12.21). */\n processing: string;\n /** The action of the trial, grant and plan-ended banners, and of `PlanLimitNotice`'s\n * `upgrade` mode: \"Choose a plan\". */\n choosePlan: string;\n /** The payment-failed banner's action, to the provider's portal: \"Update payment method\". */\n updatePayment: string;\n /** The processing banner's action, when the app gives one: \"Check again\". */\n checkAgain: string;\n\n /* ── The read-only lock (§3.3, §12.6) ── */\n /** The `WriteLockProvider` reason for the payer (§3.3, verbatim). A guest's reason is\n * {@link guestReadOnly}. */\n lockReason: string;\n\n /* ── PlanLimitNotice (§3.4) ── */\n /** The notice's first line: \"Plan limit reached\". */\n limitReached: string;\n /** Mode `upgrade`: what the action does. */\n limitUpgrade: string;\n /** Mode `contact` (the operator grants plans by hand, keksdose's today). */\n limitContact: string;\n /** Mode `contact`'s action, a mail to support: \"Ask for more\". */\n askForMore: string;\n /** The meter's value: \"3 of 3\". Both figures are formatted already. */\n usage: (used: string, limit: string) => string;\n /** The subject of the `contact` mail; `dimension` is the app's name for it (\"Budgets\"). */\n contactSubject: (dimension: string) => string;\n /**\n * The figure line of the limit's toast (`usePlanLimitToast`, §14.11) and of an\n * operator's plan change over the new limit (§14.12): \"Budgets: 3 of 3\". A key of its\n * own rather than `${dimension}: ${usage}`, because French puts a space before the\n * colon. Both figures are formatted already.\n */\n limitUsageLine: (dimension: string, used: string, limit: string) => string;\n\n /* ── The provider's portal (§7, §12.26) ── */\n /** The portal: payment method and invoices (§2.8, the provider hosts both). */\n manage: string;\n /**\n * The visible cancel link on the app's subscription page (§12.26). German: §312k BGB\n * wants the button that leads to the cancellation labelled \"Verträge hier kündigen\" or\n * as unambiguously — a translator should use exactly that.\n */\n cancel: string;\n /**\n * In place of both while the payer hasn't reached the provider (the overview's\n * `at_provider` is false, §14.5): there is no customer to open a portal for yet. Also\n * the words for `409 billing_not_at_provider`, a stale page that asked anyway.\n */\n notAtProvider: string;\n\n /* ── The pay page (§14.4) ── */\n /* Built into the static page `dist/pay/` at the kit's build: it has no React and no\n provider, so an app's override never reaches it. */\n /** While the checkout opens. */\n payOpening: string;\n /** A link without a transaction, or billing switched off: nothing to pay. */\n payNothing: string;\n /** Paddle's script didn't load, or the page's configuration is wrong. */\n payFailed: string;\n /** The buyer closed the checkout without paying. */\n payBack: string;\n /** 0.39 (§15.2.5): paid, for a transaction that names no app the page knows (a\n * payment-method update from Paddle's e-mail) — no way back to offer. */\n payDone: string;\n\n /* ── PlanSwitchConfirm (0.39, §15.2.10) ── */\n /** The dialog's title: \"Change plan\". */\n switchTitle: string;\n /** The line naming both plans, each with its billing period: \"From Pro (Monthly) to\n * Business (Yearly)\". */\n switchFromTo: (from: string, to: string) => string;\n /** What an upgrade charges at once (Paddle's preview, prorated): \"Charged now\". */\n switchChargedNow: string;\n /** What a downgrade credits — the customer's balance, which Paddle takes off the next\n * charges: \"Credited towards your next charges\". */\n switchCredited: string;\n /** The next regular charge; `date` is formatted: \"Next charge on 9 Nov 2026\". */\n switchNextCharge: (date: string) => string;\n /** The confirm button: \"Change plan\". */\n switchConfirm: string;\n\n /* ── Offline (§12.5) ── */\n /** Changes refused as `billing_read_only` inside a sync reply, kept queued and sent\n * after payment: \"3 changes waiting for a plan\". */\n waitingChanges: (count: number) => string;\n /** The sign-out guard's way out for someone who will not pay. */\n discardWaiting: string;\n\n /* ── Refusals with no part of their own (0.32.1, kastlan's 0.32 report) ── */\n /**\n * `billing_not_configured`: billing is on but the provider's settings are missing — the\n * operator's mistake, so the words ask the payer to wait, not to act. For the toast or\n * alert after \"Choose a plan\" or \"Payment and invoices\" (`isBillingError(err,\n * \"billing_not_configured\")`). `billing_read_only` and `plan_limit` need none: the\n * write lock, the banner and `PlanLimitNotice` say them.\n */\n notConfigured: string;\n /** `billing_disabled`: billing is switched off on this server (§2.9), for a page or a\n * link that reached it anyway. */\n disabled: string;\n /* 0.33.0 — server-kit 0.7's refusals (§14.2). `billing_not_at_provider` is\n {@link notAtProvider}'s: a stale page that asked for the portal anyway. */\n /** `billing_provider_unavailable` (502): the provider didn't answer. Try again. */\n providerUnavailable: string;\n /** `billing_already_subscribed` (409): a second checkout while a subscription runs\n * (§14.6). Since 0.39 plan changes go through the app's own switch (§15.2.10), not the\n * portal, and the words say so. */\n alreadySubscribed: string;\n /** `billing_plan_not_sold` (422): the catalogue doesn't sell this plan with that\n * period or currency — at a checkout, or (0.39) a switch to a plan no longer sold. */\n planNotSold: string;\n /** 0.39 (§15.2.10): `billing_not_subscribed` (409), a plan switch with no running\n * provider subscription — the page offers the checkout instead. */\n notSubscribed: string;\n /** 0.39: `billing_plan_unchanged` (409), a switch to the price the payer pays now. */\n planUnchanged: string;\n}\n\n/** \"today\", \"tomorrow\", \"in 5 days\". */\nfunction inDays(days: number): string {\n if (days <= 0) return \"today\";\n if (days === 1) return \"tomorrow\";\n return `in ${days} days`;\n}\n\nexport const DEFAULT_BILLING_LABELS: BillingLabels = {\n group: \"Subscription\",\n\n plans: \"Plans\",\n interval: \"Billing period\",\n yearly: \"Yearly\",\n monthly: \"Monthly\",\n currency: \"Currency\",\n perYear: \"per year\",\n perMonth: \"per month\",\n vatIncluded: \"VAT included\",\n free: \"Free\",\n notOffered: \"Not offered for this billing period\",\n unlimited: \"Unlimited\",\n limits: \"Limits\",\n features: \"Included\",\n current: \"Current plan\",\n choose: (plan) => `Choose ${plan}`,\n upgrade: (plan) => `Upgrade to ${plan}`,\n downgrade: (plan) => `Switch to ${plan}`,\n isCurrent: \"This is your current plan.\",\n pickFirst: \"Pick a plan first.\",\n\n status: {\n trialing: \"Trial\",\n active: \"Active\",\n past_due: \"Payment overdue\",\n canceled: \"Cancelled\",\n expired: \"Expired\",\n comped: \"Complimentary\",\n },\n\n trialEnding: (days) =>\n `Your trial ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,\n grantEnding: (days) =>\n `Your free access ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,\n paymentFailed: \"Your last payment didn’t go through. Update your payment method to keep your plan.\",\n planEnded: \"Your plan has ended. You can still view and export everything; choose a plan to make changes again.\",\n guestReadOnly: (item) =>\n item ? `“${item}” is read-only for now; its owner can lift that.` : \"This is read-only for now; its owner can lift that.\",\n processing: \"Your payment is being processed. Your plan starts as soon as it’s confirmed; this page updates by itself.\",\n choosePlan: \"Choose a plan\",\n updatePayment: \"Update payment method\",\n checkAgain: \"Check again\",\n\n lockReason: \"Your plan has ended. Choose a plan to make changes again.\",\n\n limitReached: \"Plan limit reached\",\n limitUpgrade: \"To add more, choose a plan with a higher limit.\",\n limitContact: \"To add more, ask us for a higher limit.\",\n askForMore: \"Ask for more\",\n usage: (used, limit) => `${used} of ${limit}`,\n contactSubject: (dimension) => `Plan limit: ${dimension}`,\n limitUsageLine: (dimension, used, limit) => `${dimension}: ${used} of ${limit}`,\n\n manage: \"Payment and invoices\",\n cancel: \"Cancel subscription\",\n notAtProvider: \"Nothing to manage yet. Payments and invoices appear here once you have a paid plan.\",\n\n payOpening: \"Opening the secure checkout…\",\n payNothing: \"There’s no payment to make here. To choose a plan, go back to the app.\",\n payFailed: \"The checkout couldn’t be opened. Please go back and try again in a moment.\",\n payBack: \"The checkout was closed. You can go back, or reload this page to open it again.\",\n payDone: \"Payment complete. You can close this page.\",\n\n switchTitle: \"Change plan\",\n switchFromTo: (from, to) => `From ${from} to ${to}`,\n switchChargedNow: \"Charged now\",\n switchCredited: \"Credited towards your next charges\",\n switchNextCharge: (date) => `Next charge on ${date}`,\n switchConfirm: \"Change plan\",\n\n waitingChanges: (count) =>\n count === 1 ? \"1 change waiting for a plan\" : `${count} changes waiting for a plan`,\n discardWaiting: \"Discard waiting changes\",\n\n notConfigured: \"Payments aren't set up yet. Please try again later.\",\n disabled: \"Subscriptions aren't available here.\",\n providerUnavailable: \"The payment provider can’t be reached right now. Please try again in a moment.\",\n alreadySubscribed: \"You already have a subscription. Change your plan above.\",\n planNotSold: \"This plan isn’t offered for that billing period or currency. Please choose another.\",\n notSubscribed: \"There’s no running subscription to change. Choose a plan to subscribe.\",\n planUnchanged: \"That’s already your plan. Pick another plan or billing period.\",\n};\n\n/** The `billing` namespace, resolved: English, then the provider, then `labels` — which\n * may be partial at every depth (`{ status: { comped: \"Beta\" } }`). */\nexport function useBillingLabels(labels?: LabelOverride<BillingLabels>): BillingLabels {\n return useKitLabels(\"billing\", DEFAULT_BILLING_LABELS, labels);\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAmBtB,MAAM,wBAAuD,OAAO,OAAO;AAAA,EAChF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAsMD,SAAS,OAAO,MAAsB;AACpC,MAAI,QAAQ,EAAG,QAAO;AACtB,MAAI,SAAS,EAAG,QAAO;AACvB,SAAO,MAAM,IAAI;AACnB;AAEO,MAAM,yBAAwC;AAAA,EACnD,OAAO;AAAA,EAEP,OAAO;AAAA,EACP,UAAU;AAAA,EACV,QAAQ;AAAA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I,OAAO,EAAE;AAAA,EACjD,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,kBAAkB,CAAC,SAAS,kBAAkB,IAAI;AAAA,EAClD,eAAe;AAAA,EAEf,gBAAgB,CAAC,UACf,UAAU,IAAI,gCAAgC,GAAG,KAAK;AAAA,EACxD,gBAAgB;AAAA,EAEhB,eAAe;AAAA,EACf,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,eAAe;AACjB;AAIO,SAAS,iBAAiB,QAAsD;AACrF,SAAO,aAAa,WAAW,wBAAwB,MAAM;AAC/D;","names":[]}
1
+ {"version":3,"sources":["../../src/billing/billing-labels.ts"],"sourcesContent":["import { useKitLabels } from \"../i18n/kit-labels\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\n\n/**\n * The subscription's status vocabulary (docs/billing-harmonization.md §3.2) — server-kit's\n * `SubscriptionStatus`, value for value:\n *\n * - `trialing` — the 30-day trial without a card (§2.7), or a pure guest's row whose trial\n * has not started (§12.9, `trial_ends_at` empty);\n * - `active` — paid;\n * - `past_due` — a payment failed; in good standing during the provider's retries (§3.3);\n * - `canceled` — the payer cancelled; the American spelling is the wire's, the word shown\n * is \"Cancelled\";\n * - `expired` — a trial, a grant or a failed subscription ran out: read-only (§2.3);\n * - `comped` — free by the operator's grant or as a beta user (§3.2, `comped_until`).\n */\nexport type SubscriptionStatus = \"trialing\" | \"active\" | \"past_due\" | \"canceled\" | \"expired\" | \"comped\";\n\n/** Every status, in the order a lifecycle reads: trial, paid, trouble, ended, granted. */\nexport const SUBSCRIPTION_STATUSES: readonly SubscriptionStatus[] = Object.freeze([\n \"trialing\",\n \"active\",\n \"past_due\",\n \"canceled\",\n \"expired\",\n \"comped\",\n]);\n\n/**\n * The words of the subscription parts — the `billing` namespace of `<UiKitProvider labels>`\n * (docs/billing-harmonization.md §7, §10; ui-kit 0.32.0).\n *\n * WORDING (§12.24): the English group is \"Subscription\", never \"Plan\" — keksdose's \"plan\"\n * is the month's budget plan (\"One plan per month\"), and two meanings of one word on one\n * settings page is the clash the review found. \"Plan\" stays the word for WHAT is bought\n * (Free, Pro), \"subscription\" for the standing arrangement. German says \"Tarif\" for the\n * plan and \"Abonnement\" for the subscription (§10).\n *\n * Prices are GROSS (§12.17): Swiss consumer law (PBV) wants a consumer price with the\n * MWST in it, so the cards say so (`vatIncluded`).\n */\nexport interface BillingLabels {\n /** The settings group or admin section the parts live on (§7, §12.24): \"Subscription\". */\n group: string;\n\n /* ── PlanPicker / PlanCard (§7) ── */\n /** The picker's name when it has no visible `legend`: \"Plans\". */\n plans: string;\n /** The name of the billing-period switch: \"Billing period\". */\n interval: string;\n /** The switch's two options — yearly first (§12.17). */\n yearly: string;\n monthly: string;\n /** The name of the currency switch: \"Currency\". */\n currency: string;\n /** After a price: \"per year\", \"per month\". */\n perYear: string;\n perMonth: string;\n /** Under a price (§12.17): \"VAT included\". German: \"inkl. MWST\". */\n vatIncluded: string;\n /** A plan with no price, or a price of 0: \"Free\". */\n free: string;\n /** A plan with prices, but none for this currency and period. */\n notOffered: string;\n /** A limit of `null` (§3.1): \"Unlimited\". */\n unlimited: string;\n /** The accessible names of a card's two lists. */\n limits: string;\n features: string;\n /** The chip on the payer's current plan. */\n current: string;\n /** The picker's button for `plan` (the plan's display name) with no current plan —\n * during a trial, or after a plan ended: \"Choose Pro\". */\n choose: (plan: string) => string;\n /** …for a plan after the current one in the catalogue's order: \"Upgrade to Pro\". */\n upgrade: (plan: string) => string;\n /** …for a plan before it: \"Switch to Free\". */\n downgrade: (plan: string) => string;\n /** Why the button is off while the current plan is the one picked. */\n isCurrent: string;\n /** Why it is off while nothing is picked. */\n pickFirst: string;\n\n /* ── SubscriptionStatusChip (§6) ── */\n /** One word per status. */\n status: Record<SubscriptionStatus, string>;\n\n /* ── BillingBanner (§3.3, §12.6, §12.21) ── */\n /** A trial ends in `days` calendar days — 0 is today, 1 tomorrow. */\n trialEnding: (days: number) => string;\n /** A free grant (`comped_until`: a beta user's 12 months, an operator's grant) ends in\n * `days` calendar days. */\n grantEnding: (days: number) => string;\n /** The first failed payment (`past_due`), while the provider retries. */\n paymentFailed: string;\n /** Out of good standing: read-only, never locked (§2.3). */\n planEnded: string;\n /**\n * A guest in someone else's item that is read-only for billing (§12.6). It never says\n * WHY beyond \"for now\": the owner's payment status is the owner's personal data.\n * `item` is the item's own name (\"Household 2026\"), shown in quotes — or `undefined`.\n */\n guestReadOnly: (item?: string) => string;\n /** Back from checkout before the provider's webhook landed (§12.21). */\n processing: string;\n /** The action of the trial, grant and plan-ended banners, and of `PlanLimitNotice`'s\n * `upgrade` mode: \"Choose a plan\". */\n choosePlan: string;\n /** The payment-failed banner's action, to the provider's portal: \"Update payment method\". */\n updatePayment: string;\n /**\n * 0.42 (§16.7 A, §16.8): the payment-failed banner for an admin who isn't the buyer\n * (`portal: \"buyer_only\"`), with no button — only the buyer can change the card.\n * `buyer` is their display name, or `undefined` when they are gone (\"the admin who\n * bought the subscription\").\n */\n paymentFailedAskBuyer: (buyer?: string) => string;\n /** The processing banner's action, when the app gives one: \"Check again\". */\n checkAgain: string;\n\n /* ── The read-only lock (§3.3, §12.6) ── */\n /** The `WriteLockProvider` reason for the payer (§3.3, verbatim). A guest's reason is\n * {@link guestReadOnly}. */\n lockReason: string;\n\n /* ── PlanLimitNotice (§3.4) ── */\n /** The notice's first line: \"Plan limit reached\". */\n limitReached: string;\n /** Mode `upgrade`: what the action does. */\n limitUpgrade: string;\n /** Mode `contact` (the operator grants plans by hand, keksdose's today). */\n limitContact: string;\n /** Mode `contact`'s action, a mail to support: \"Ask for more\". */\n askForMore: string;\n /** The meter's value: \"3 of 3\". Both figures are formatted already. */\n usage: (used: string, limit: string) => string;\n /** The subject of the `contact` mail; `dimension` is the app's name for it (\"Budgets\"). */\n contactSubject: (dimension: string) => string;\n /**\n * The figure line of the limit's toast (`usePlanLimitToast`, §14.11) and of an\n * operator's plan change over the new limit (§14.12): \"Budgets: 3 of 3\". A key of its\n * own rather than `${dimension}: ${usage}`, because French puts a space before the\n * colon. Both figures are formatted already.\n */\n limitUsageLine: (dimension: string, used: string, limit: string) => string;\n\n /* ── The provider's portal (§7, §12.26) ── */\n /** The portal: payment method and invoices (§2.8, the provider hosts both). */\n manage: string;\n /**\n * The visible cancel link on the app's subscription page (§12.26). German: §312k BGB\n * wants the button that leads to the cancellation labelled \"Verträge hier kündigen\" or\n * as unambiguously — a translator should use exactly that.\n */\n cancel: string;\n /**\n * In place of both while the payer hasn't reached the provider (the overview's\n * `at_provider` is false, §14.5): there is no customer to open a portal for yet. Also\n * the words for `409 billing_not_at_provider`, a stale page that asked anyway.\n */\n notAtProvider: string;\n\n /* ── The portal for the buyer only, the in-app cancel (0.42, §16) ── */\n /**\n * In place of \"Payment and invoices\" for an admin who isn't the buyer (`portal:\n * \"buyer_only\"`, §16.2 decision 3): the provider's portal opens only for the buyer.\n * `buyer` is their display name — or `undefined` when they are gone or have left the\n * company, and the words then say \"the admin who bought the subscription\".\n */\n buyerHolds: (buyer?: string) => string;\n /** `CancelSubscriptionConfirm`'s title: \"Cancel subscription\". */\n cancelConfirmTitle: string;\n /** Its body; `date` is the period's end, formatted: \"Your subscription ends on\n * 9 Nov 2026. Until then everything works as before.\" */\n cancelConfirmBody: (date: string) => string;\n /** Its confirm button (§16.4): \"Cancel subscription now\". German: \"Jetzt kündigen\",\n * the confirmation button's words in §312k BGB. */\n cancelConfirmAction: string;\n /** In place of \"Cancel subscription\" while a cancel is scheduled (§16.7 C, `POST\n * /billing/resume`): \"Keep subscription\". */\n keepSubscription: string;\n /** 0.43 (§17.3): the muted note under the actions while the portal opens in a new tab —\n * `provider` the provider's name (\"Paddle\"), `app` the app's; without the app, \"this\n * page\". \"Payment and invoices open at Paddle in a new tab; Kastlan stays open here.\" */\n portalOpensNewTab: (provider: string, app?: string) => string;\n\n /* ── The pay page (§14.4) ── */\n /* Built into the static page `dist/pay/` at the kit's build: it has no React and no\n provider, so an app's override never reaches it. */\n /** While the checkout opens. */\n payOpening: string;\n /** A link without a transaction, or billing switched off: nothing to pay. */\n payNothing: string;\n /** Paddle's script didn't load, or the page's configuration is wrong. */\n payFailed: string;\n /** The buyer closed the checkout without paying. */\n payBack: string;\n /** 0.39 (§15.2.5): paid, for a transaction that names no app the page knows (a\n * payment-method update from Paddle's e-mail) — no way back to offer. */\n payDone: string;\n\n /* ── PlanSwitchConfirm (0.39, §15.2.10) ── */\n /** The dialog's title: \"Change plan\". */\n switchTitle: string;\n /** The line naming both plans, each with its billing period: \"From Pro (Monthly) to\n * Business (Yearly)\". */\n switchFromTo: (from: string, to: string) => string;\n /** What an upgrade charges at once (Paddle's preview, prorated): \"Charged now\". */\n switchChargedNow: string;\n /** What a downgrade credits — the customer's balance, which Paddle takes off the next\n * charges: \"Credited towards your next charges\". */\n switchCredited: string;\n /** The next regular charge; `date` is formatted: \"Next charge on 9 Nov 2026\". */\n switchNextCharge: (date: string) => string;\n /** The confirm button: \"Change plan\". */\n switchConfirm: string;\n\n /* ── The permanent-grant warning (0.42, §16.2 decision 5, §16.8 B) ── */\n /** The warning's title, before a checkout (`PlanPicker`) or a switch\n * (`PlanSwitchConfirm`) under a grant without an end: \"Your free access continues\". */\n grantWarningTitle: string;\n /** What the purchase does under it: nothing to the plan while the grant runs. */\n grantWarningBody: string;\n /** `PlanPicker`'s button that goes on to the checkout: \"Buy anyway\". */\n grantWarningAction: string;\n\n /* ── Offline (§12.5) ── */\n /** Changes refused as `billing_read_only` inside a sync reply, kept queued and sent\n * after payment: \"3 changes waiting for a plan\". */\n waitingChanges: (count: number) => string;\n /** The sign-out guard's way out for someone who will not pay. */\n discardWaiting: string;\n\n /* ── Refusals with no part of their own (0.32.1, kastlan's 0.32 report) ── */\n /**\n * `billing_not_configured`: billing is on but the provider's settings are missing — the\n * operator's mistake, so the words ask the payer to wait, not to act. For the toast or\n * alert after \"Choose a plan\" or \"Payment and invoices\" (`isBillingError(err,\n * \"billing_not_configured\")`). `billing_read_only` and `plan_limit` need none: the\n * write lock, the banner and `PlanLimitNotice` say them.\n */\n notConfigured: string;\n /** `billing_disabled`: billing is switched off on this server (§2.9), for a page or a\n * link that reached it anyway. */\n disabled: string;\n /* 0.33.0 — server-kit 0.7's refusals (§14.2). `billing_not_at_provider` is\n {@link notAtProvider}'s: a stale page that asked for the portal anyway. */\n /** `billing_provider_unavailable` (502): the provider didn't answer. Try again. */\n providerUnavailable: string;\n /** `billing_already_subscribed` (409): a second checkout while a subscription runs\n * (§14.6). Since 0.39 plan changes go through the app's own switch (§15.2.10), not the\n * portal, and the words say so. */\n alreadySubscribed: string;\n /** `billing_plan_not_sold` (422): the catalogue doesn't sell this plan with that\n * period or currency — at a checkout, or (0.39) a switch to a plan no longer sold. */\n planNotSold: string;\n /** 0.39 (§15.2.10): `billing_not_subscribed` (409), a plan switch with no running\n * provider subscription — the page offers the checkout instead. */\n notSubscribed: string;\n /** 0.39: `billing_plan_unchanged` (409), a switch to the price the payer pays now. */\n planUnchanged: string;\n}\n\n/** \"today\", \"tomorrow\", \"in 5 days\". */\nfunction inDays(days: number): string {\n if (days <= 0) return \"today\";\n if (days === 1) return \"tomorrow\";\n return `in ${days} days`;\n}\n\nexport const DEFAULT_BILLING_LABELS: BillingLabels = {\n group: \"Subscription\",\n\n plans: \"Plans\",\n interval: \"Billing period\",\n yearly: \"Yearly\",\n monthly: \"Monthly\",\n currency: \"Currency\",\n perYear: \"per year\",\n perMonth: \"per month\",\n vatIncluded: \"VAT included\",\n free: \"Free\",\n notOffered: \"Not offered for this billing period\",\n unlimited: \"Unlimited\",\n limits: \"Limits\",\n features: \"Included\",\n current: \"Current plan\",\n choose: (plan) => `Choose ${plan}`,\n upgrade: (plan) => `Upgrade to ${plan}`,\n downgrade: (plan) => `Switch to ${plan}`,\n isCurrent: \"This is your current plan.\",\n pickFirst: \"Pick a plan first.\",\n\n status: {\n trialing: \"Trial\",\n active: \"Active\",\n past_due: \"Payment overdue\",\n canceled: \"Cancelled\",\n expired: \"Expired\",\n comped: \"Complimentary\",\n },\n\n trialEnding: (days) =>\n `Your trial ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,\n grantEnding: (days) =>\n `Your free access ends ${inDays(days)}. After that you can still view everything, but changes need a plan.`,\n paymentFailed: \"Your last payment didn’t go through. Update your payment method to keep your plan.\",\n planEnded: \"Your plan has ended. You can still view and export everything; choose a plan to make changes again.\",\n guestReadOnly: (item) =>\n item ? `“${item}” is read-only for now; its owner can lift that.` : \"This is read-only for now; its owner can lift that.\",\n processing: \"Your payment is being processed. Your plan starts as soon as it’s confirmed; this page updates by itself.\",\n choosePlan: \"Choose a plan\",\n updatePayment: \"Update payment method\",\n paymentFailedAskBuyer: (buyer) =>\n buyer\n ? `The payment failed. ${buyer} can update the payment method.`\n : \"The payment failed. The admin who bought the subscription can update the payment method.\",\n checkAgain: \"Check again\",\n\n lockReason: \"Your plan has ended. Choose a plan to make changes again.\",\n\n limitReached: \"Plan limit reached\",\n limitUpgrade: \"To add more, choose a plan with a higher limit.\",\n limitContact: \"To add more, ask us for a higher limit.\",\n askForMore: \"Ask for more\",\n usage: (used, limit) => `${used} of ${limit}`,\n contactSubject: (dimension) => `Plan limit: ${dimension}`,\n limitUsageLine: (dimension, used, limit) => `${dimension}: ${used} of ${limit}`,\n\n manage: \"Payment and invoices\",\n cancel: \"Cancel subscription\",\n notAtProvider: \"Nothing to manage yet. Payments and invoices appear here once you have a paid plan.\",\n buyerHolds: (buyer) =>\n buyer\n ? `The payment method and the invoices are with ${buyer}, who bought the subscription.`\n : \"The payment method and the invoices are with the admin who bought the subscription.\",\n cancelConfirmTitle: \"Cancel subscription\",\n cancelConfirmBody: (date) => `Your subscription ends on ${date}. Until then everything works as before.`,\n cancelConfirmAction: \"Cancel subscription now\",\n keepSubscription: \"Keep subscription\",\n portalOpensNewTab: (provider, app) =>\n `Payment and invoices open at ${provider} in a new tab; ${app ? `${app} stays open here` : \"this page stays open\"}.`,\n\n payOpening: \"Opening the secure checkout…\",\n payNothing: \"There’s no payment to make here. To choose a plan, go back to the app.\",\n payFailed: \"The checkout couldn’t be opened. Please go back and try again in a moment.\",\n payBack: \"The checkout was closed. You can go back, or reload this page to open it again.\",\n payDone: \"Payment complete. You can close this page.\",\n\n switchTitle: \"Change plan\",\n switchFromTo: (from, to) => `From ${from} to ${to}`,\n switchChargedNow: \"Charged now\",\n switchCredited: \"Credited towards your next charges\",\n switchNextCharge: (date) => `Next charge on ${date}`,\n switchConfirm: \"Change plan\",\n\n grantWarningTitle: \"Your free access continues\",\n grantWarningBody:\n \"You have free access with no end date. A purchase won’t change your plan while the free access runs: you would pay for a plan that doesn’t apply.\",\n grantWarningAction: \"Buy anyway\",\n\n waitingChanges: (count) =>\n count === 1 ? \"1 change waiting for a plan\" : `${count} changes waiting for a plan`,\n discardWaiting: \"Discard waiting changes\",\n\n notConfigured: \"Payments aren't set up yet. Please try again later.\",\n disabled: \"Subscriptions aren't available here.\",\n providerUnavailable: \"The payment provider can’t be reached right now. Please try again in a moment.\",\n alreadySubscribed: \"You already have a subscription. Change your plan above.\",\n planNotSold: \"This plan isn’t offered for that billing period or currency. Please choose another.\",\n notSubscribed: \"There’s no running subscription to change. Choose a plan to subscribe.\",\n planUnchanged: \"That’s already your plan. Pick another plan or billing period.\",\n};\n\n/** The `billing` namespace, resolved: English, then the provider, then `labels` — which\n * may be partial at every depth (`{ status: { comped: \"Beta\" } }`). */\nexport function useBillingLabels(labels?: LabelOverride<BillingLabels>): BillingLabels {\n return useKitLabels(\"billing\", DEFAULT_BILLING_LABELS, labels);\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAmBtB,MAAM,wBAAuD,OAAO,OAAO;AAAA,EAChF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AA8OD,SAAS,OAAO,MAAsB;AACpC,MAAI,QAAQ,EAAG,QAAO;AACtB,MAAI,SAAS,EAAG,QAAO;AACvB,SAAO,MAAM,IAAI;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