@burdenoff/microfe-billing 2026.1113.1 → 2026.1113.3

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 (109) hide show
  1. package/dist/billing/BillingRoot.js +83 -77
  2. package/dist/billing/BillingRoot.js.map +1 -1
  3. package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js +78 -78
  4. package/dist/billing/modules/addons/pages/AddonCreatePage.js +70 -70
  5. package/dist/billing/modules/addons/pages/AddonDetailPage.js +72 -72
  6. package/dist/billing/modules/addons/pages/AddonEditPage.js +79 -79
  7. package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +224 -224
  8. package/dist/billing/modules/addons/pages/AddonsListPage.js +186 -186
  9. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +168 -168
  10. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  11. package/dist/billing/modules/analytics/pages/AnalyticsPage.js +88 -88
  12. package/dist/billing/modules/billing/hooks/index.js +5 -5
  13. package/dist/billing/modules/billing/hooks/useInvoices.js +39 -20
  14. package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
  15. package/dist/billing/modules/billing/index.js +14 -14
  16. package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js +92 -92
  17. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +160 -160
  18. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
  19. package/dist/billing/modules/billing/pages/InvoicesListPage.js +100 -100
  20. package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js +105 -105
  21. package/dist/billing/modules/billing/pages/PaymentMethodsPage.js +37 -37
  22. package/dist/billing/modules/billing/pages/RefundIssueLogsPage.js +41 -41
  23. package/dist/billing/modules/billing/pages/RefundsPage.js +334 -334
  24. package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
  25. package/dist/billing/modules/billing/pages/TransactionsPage.js +174 -174
  26. package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
  27. package/dist/billing/modules/billing/pages/UserRefundsPage.js +24 -24
  28. package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
  29. package/dist/billing/modules/checkout/components/OrderSummary.js +71 -71
  30. package/dist/billing/modules/checkout/pages/CheckoutPage.js +646 -625
  31. package/dist/billing/modules/checkout/pages/CheckoutPage.js.map +1 -1
  32. package/dist/billing/modules/checkout/utils/checkoutOptions.d.ts +23 -0
  33. package/dist/billing/modules/checkout/utils/checkoutOptions.js +8 -0
  34. package/dist/billing/modules/checkout/utils/checkoutOptions.js.map +1 -0
  35. package/dist/billing/modules/coupons/pages/CouponDetailPage.js +112 -112
  36. package/dist/billing/modules/coupons/pages/CouponsListPage.js +118 -118
  37. package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
  38. package/dist/billing/modules/coupons/pages/CreateCouponPage.js +119 -119
  39. package/dist/billing/modules/coupons/pages/EditCouponPage.js +82 -82
  40. package/dist/billing/modules/credits/pages/AdminCreditsPage.js +30 -30
  41. package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +77 -77
  42. package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +144 -144
  43. package/dist/billing/modules/credits/pages/CreditsPage.js +67 -67
  44. package/dist/billing/modules/dashboard/pages/OverviewPage.js +594 -442
  45. package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
  46. package/dist/billing/modules/dashboard/utils/overviewSummary.d.ts +46 -0
  47. package/dist/billing/modules/dashboard/utils/overviewSummary.js +37 -0
  48. package/dist/billing/modules/dashboard/utils/overviewSummary.js.map +1 -0
  49. package/dist/billing/modules/discounts/pages/DiscountsListPage.js +199 -199
  50. package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
  51. package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +64 -64
  52. package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +122 -122
  53. package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
  54. package/dist/billing/modules/earnings/pages/EarningsPage.js +102 -102
  55. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  56. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +178 -178
  57. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
  58. package/dist/billing/modules/earnings/pages/PayoutsPage.js +107 -107
  59. package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
  60. package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +54 -54
  61. package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +94 -94
  62. package/dist/billing/modules/plans/pages/PlanCreatePage.js +73 -73
  63. package/dist/billing/modules/plans/pages/PlanDetailPage.js +96 -96
  64. package/dist/billing/modules/plans/pages/PlanEditPage.js +16 -16
  65. package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
  66. package/dist/billing/modules/plans/pages/PlansBrowsePage.js +143 -143
  67. package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
  68. package/dist/billing/modules/plans/pages/PlansListPage.js +88 -88
  69. package/dist/billing/modules/plans/utils/planAction.d.ts +9 -0
  70. package/dist/billing/modules/plans/utils/planAction.js +4 -1
  71. package/dist/billing/modules/plans/utils/planAction.js.map +1 -1
  72. package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +60 -60
  73. package/dist/billing/modules/promotions/pages/PromotionsListPage.js +37 -37
  74. package/dist/billing/modules/quota/pages/QuotaAssignFreePage.js +62 -62
  75. package/dist/billing/modules/quota/pages/QuotaPage.js +1 -1
  76. package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js +69 -69
  77. package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +76 -76
  78. package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +80 -80
  79. package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js +95 -95
  80. package/dist/billing/modules/settings/pages/SettingsPage.js +134 -134
  81. package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
  82. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +62 -62
  83. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
  84. package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js +36 -36
  85. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +534 -410
  86. package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
  87. package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js +111 -111
  88. package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js +166 -160
  89. package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js.map +1 -1
  90. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.d.ts +30 -0
  91. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js +20 -0
  92. package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js.map +1 -0
  93. package/dist/billing/modules/subscriptions/utils/upgradeAccess.d.ts +10 -0
  94. package/dist/billing/modules/subscriptions/utils/upgradeAccess.js +7 -0
  95. package/dist/billing/modules/subscriptions/utils/upgradeAccess.js.map +1 -0
  96. package/dist/billing/modules/usage/pages/UsagePage.js +722 -591
  97. package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
  98. package/dist/billing/modules/usage/utils/usageHealth.d.ts +63 -0
  99. package/dist/billing/modules/usage/utils/usageHealth.js +43 -0
  100. package/dist/billing/modules/usage/utils/usageHealth.js.map +1 -0
  101. package/dist/billing/shared/components/EmptyState.js +3 -3
  102. package/dist/billing/shared/components/MoneyActionDialog.js +12 -12
  103. package/dist/billing/shared/ui/MetricCard.js +13 -13
  104. package/dist/billing/shared/utils/format.js +16 -4
  105. package/dist/billing/shared/utils/format.js.map +1 -1
  106. package/dist/billing/shared/utils/index.js +8 -8
  107. package/dist/generated/global-operations.js +294 -286
  108. package/dist/generated/global-operations.js.map +1 -1
  109. package/package.json +2 -2
@@ -1,516 +1,668 @@
1
1
  import { useBilling as e } from "../../../providers/BillingProvider.js";
2
2
  import { useBillingEventEmitter as t } from "../../../hooks/useBillingEventEmitter.js";
3
3
  import { useBillingPermissions as n } from "../../../hooks/useBillingPermissions.js";
4
- import { StatCard as r } from "../../../shared/components/StatCard.js";
5
- import { ServerError as ee } from "../../../shared/components/ServerError.js";
6
- import { AccessDenied as te } from "../../../shared/components/AccessDenied.js";
7
- import { PushPermissionNudge as ne } from "../../../shared/components/PushPermissionNudge.js";
4
+ import { useIsFluidgridsVariant as ee } from "../../../hooks/useBillingVariant.js";
5
+ import "../../billing/hooks/index.js";
6
+ import { formatCardBrand as r, formatCardExpiry as i, formatCardNumber as te, formatCurrency as a, formatDate as o, formatInvoiceStatus as s, formatPlanPrice as ne } from "../../../shared/utils/format.js";
7
+ import { pickLatestInvoice as c, pickSavedCard as re, resolveChangePlanPath as ie, resolveNoAccountMode as ae, shouldShowNewAccountButton as oe, summarizePlan as se } from "../utils/overviewSummary.js";
8
+ import { StatCard as l } from "../../../shared/components/StatCard.js";
9
+ import { ServerError as ce } from "../../../shared/components/ServerError.js";
10
+ import { isServerError as le } from "../../../shared/utils/error.js";
11
+ import { AccessDenied as ue } from "../../../shared/components/AccessDenied.js";
12
+ import { PushPermissionNudge as de } from "../../../shared/components/PushPermissionNudge.js";
8
13
  import "../../../shared/utils/index.js";
9
- import { isServerError as re } from "../../../shared/utils/error.js";
14
+ import { useInvoices as u } from "../../billing/hooks/useInvoices.js";
10
15
  import "../hooks/index.js";
11
16
  import "../components/index.js";
12
- import { useDashboardMutations as ie } from "../hooks/useDashboard.js";
13
- import { useBillingOverviewData as ae } from "../hooks/useBillingOverviewData.js";
14
- import { useAddonCartStore as oe } from "../../addons/store/addonCartStore.js";
15
- import { BillingAccountCard as se } from "../components/BillingAccountCard.js";
16
- import { PaymentMethodsSection as ce } from "../components/PaymentMethodsSection.js";
17
- import { ActiveSubscriptionCard as le } from "../components/ActiveSubscriptionCard.js";
18
- import { RecommendedAddonsSection as ue } from "../components/RecommendedAddonsSection.js";
19
- import { CreateBillingAccountModal as i } from "../components/CreateBillingAccountModal.js";
20
- import { AddPaymentMethodModal as de } from "../components/AddPaymentMethodModal.js";
21
- import { FloatingCartDrawer as fe } from "../../addons/components/FloatingCartDrawer.js";
22
- import { getStoredBillingAccountId as pe, setStoredBillingAccountId as me } from "../../../hooks/useBillingAccountSelection.js";
23
- import { withBillingAccountId as he } from "../../../shared/utils/navigation.js";
24
- import { useTr as ge } from "../../../shared/hooks/useTr.js";
25
- import { useCallback as a, useEffect as o, useState as s } from "react";
26
- import { Activity as _e, ArrowRight as ve, Building2 as c, Check as l, ChevronDown as u, Coins as ye, Crown as d, Loader2 as be, Plus as f, Receipt as xe, RefreshCw as p, Sparkles as Se, Wallet as m } from "lucide-react";
27
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
28
- import { AuroraBackground as Ce, Button as we, CTAOverflowMenu as Te, GlassCard as Ee, GradientText as De, IllustratedEmptyState as Oe, PagePurpose as ke } from "@burdenoff/fe-libs/ui";
29
- import { shouldPromptForPushPermission as Ae } from "@burdenoff/fe-libs/shared/native";
17
+ import { useDashboardMutations as fe } from "../hooks/useDashboard.js";
18
+ import { useBillingOverviewData as pe } from "../hooks/useBillingOverviewData.js";
19
+ import { useAddonCartStore as me } from "../../addons/store/addonCartStore.js";
20
+ import { BillingAccountCard as he } from "../components/BillingAccountCard.js";
21
+ import { PaymentMethodsSection as ge } from "../components/PaymentMethodsSection.js";
22
+ import { ActiveSubscriptionCard as _e } from "../components/ActiveSubscriptionCard.js";
23
+ import { RecommendedAddonsSection as ve } from "../components/RecommendedAddonsSection.js";
24
+ import { CreateBillingAccountModal as ye } from "../components/CreateBillingAccountModal.js";
25
+ import { AddPaymentMethodModal as be } from "../components/AddPaymentMethodModal.js";
26
+ import { FloatingCartDrawer as xe } from "../../addons/components/FloatingCartDrawer.js";
27
+ import { getStoredBillingAccountId as Se, setStoredBillingAccountId as Ce } from "../../../hooks/useBillingAccountSelection.js";
28
+ import { withBillingAccountId as we } from "../../../shared/utils/navigation.js";
29
+ import { useTr as Te } from "../../../shared/hooks/useTr.js";
30
+ import { useCallback as d, useEffect as f, useState as p } from "react";
31
+ import { AccessGate as Ee, AuroraBackground as De, Button as Oe, CTAOverflowMenu as ke, GlassCard as Ae, GradientText as m, IllustratedEmptyState as je, OptionalFields as Me, PagePurpose as Ne } from "@burdenoff/fe-libs/ui";
32
+ import { Activity as Pe, ArrowRight as h, Building2 as g, CalendarClock as Fe, Check as _, ChevronDown as v, Coins as Ie, CreditCard as Le, Crown as y, FileText as b, Loader2 as Re, Plus as x, Receipt as ze, RefreshCw as S, Sparkles as Be, Wallet as C } from "lucide-react";
33
+ import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
34
+ import { shouldPromptForPushPermission as Ve } from "@burdenoff/fe-libs/shared/native";
30
35
  // src/billing/modules/dashboard/pages/OverviewPage.tsx
31
- var v = () => {
32
- let v = ge(), { navigate: y, basePath: b, orgId: x, productId: je } = e(), S = n(), { emit: C } = t(), [w, Me] = s(() => pe(x)), [T, E] = s(!1), [D, O] = s(null), [Ne, k] = s(!1), [A, j] = s(!1), [Pe, M] = s(!1), [N, P] = s(0), [F, I] = s(!1), { billingAccounts: L, currentAccount: R, paymentMethods: z, activeSubscriptions: B, hasActiveSubscription: V, recommendedAddons: Fe, isLoading: H, error: U, refetchAll: W } = ae(w, je), G = R?.id, Ie = H, K = a((e) => {
33
- Me(e), me(x, e);
34
- }, [x]), { addToCart: q, isInCart: J, getCartItem: Le, updateQuantity: Re, removeFromCart: Y } = oe(), { createBillingAccount: ze, setBillingAddress: X, setDefaultPaymentMethod: Be, deletePaymentMethod: Ve, isCreatingAccount: He } = ie();
35
- o(() => {
36
- P(0), I(!1);
37
- }, [G, B.length]), o(() => {
38
- w && L.length > 0 && (L.some((e) => e.id === w) || K(null));
36
+ var He = ({ billingAccountId: e, onViewAll: t }) => {
37
+ let n = Te(), { invoices: ee, isLoading: r } = u({ billingAccountId: e }), i = c(ee);
38
+ return /* @__PURE__ */ E("div", {
39
+ className: "flex items-start gap-3",
40
+ children: [/* @__PURE__ */ T("div", {
41
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
42
+ children: /* @__PURE__ */ T(b, { className: "size-4 text-text-secondary" })
43
+ }), /* @__PURE__ */ E("div", {
44
+ className: "min-w-0",
45
+ children: [
46
+ /* @__PURE__ */ T("p", {
47
+ className: "text-xs text-text-secondary",
48
+ children: n("billing.overview.latestInvoice", "Latest invoice")
49
+ }),
50
+ i ? /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ E("p", {
51
+ className: "text-sm font-medium text-text-primary",
52
+ children: [
53
+ a(i.total, i.currency),
54
+ " · ",
55
+ s(i.status)
56
+ ]
57
+ }), /* @__PURE__ */ E("p", {
58
+ className: "text-xs text-text-secondary",
59
+ children: [
60
+ i.invoiceNumber,
61
+ " · ",
62
+ o(i.createdAt)
63
+ ]
64
+ })] }) : /* @__PURE__ */ T("p", {
65
+ className: "text-sm text-text-secondary",
66
+ children: r ? n("billing.overview.loadingInvoice", "Loading...") : n("billing.overview.noInvoices", "No invoices yet")
67
+ }),
68
+ /* @__PURE__ */ T("button", {
69
+ type: "button",
70
+ onClick: t,
71
+ className: "text-xs text-text-link hover:underline mt-1",
72
+ children: n("billing.overview.viewInvoices", "View all invoices")
73
+ })
74
+ ]
75
+ })]
76
+ });
77
+ }, D = () => {
78
+ let s = Te(), { navigate: c, basePath: u, orgId: b, productId: D } = e(), O = n(), k = ee(), { emit: A } = t(), [j, Ue] = p(() => Se(b)), [M, N] = p(!1), [P, F] = p(null), [We, Ge] = p(!1), [I, L] = p(!1), [Ke, qe] = p(!1), [Je, Ye] = p(0), [R, z] = p(!1), { billingAccounts: B, currentAccount: V, paymentMethods: H, activeSubscriptions: U, hasActiveSubscription: Xe, recommendedAddons: Ze, isLoading: W, error: Qe, refetchAll: G } = pe(j, D), K = V?.id, $e = W, q = d((e) => {
79
+ Ue(e), Ce(b, e);
80
+ }, [b]), { addToCart: et, isInCart: tt, getCartItem: nt, updateQuantity: rt, removeFromCart: J } = me(), { createBillingAccount: it, setBillingAddress: at, setDefaultPaymentMethod: ot, deletePaymentMethod: st, isCreatingAccount: ct } = fe();
81
+ f(() => {
82
+ Ye(0), z(!1);
83
+ }, [K, U.length]), f(() => {
84
+ j && B.length > 0 && (B.some((e) => e.id === j) || q(null));
39
85
  }, [
40
- L,
41
- w,
42
- K
43
- ]), o(() => {
44
- if (!w && L.length > 0) {
45
- let e = L.find((e) => e.isDefault) ?? L[0];
46
- K(e.id);
86
+ B,
87
+ j,
88
+ q
89
+ ]), f(() => {
90
+ if (!j && B.length > 0) {
91
+ let e = B.find((e) => e.isDefault) ?? B[0];
92
+ q(e.id);
47
93
  }
48
94
  }, [
49
- L,
50
- w,
51
- K
95
+ B,
96
+ j,
97
+ q
52
98
  ]);
53
- let Z = B[N] || B[0] || null, Q = a((e) => {
99
+ let Y = U[Je] || U[0] || null, X = d((e) => {
54
100
  let t = e;
55
- b && b !== "/" && (t = `${b.endsWith("/") ? b.slice(0, -1) : b}${e.startsWith("/") ? e : `/${e}`}`), y(t);
56
- }, [y, b]), Ue = a(async (e, t) => {
57
- O(null);
101
+ u && u !== "/" && (t = `${u.endsWith("/") ? u.slice(0, -1) : u}${e.startsWith("/") ? e : `/${e}`}`), c(t);
102
+ }, [c, u]), lt = d(async (e, t) => {
103
+ F(null);
58
104
  try {
59
- let n = await ze(e);
60
- t && n.id && await X({
105
+ let n = await it(e);
106
+ t && n.id && await at({
61
107
  billingAccountId: n.id,
62
108
  ...t
63
- }), E(!1), K(n.id), C("billing.billing_account.created", {
109
+ }), N(!1), q(n.id), A("billing.billing_account.created", {
64
110
  route: "/billing/overview",
65
111
  entityId: n.id,
66
112
  source: "overview"
67
- }), await W(), Ae() && k(!0);
113
+ }), await G(), Ve() && Ge(!0);
68
114
  } catch (e) {
69
- O(e instanceof Error ? e.message : "Failed to create billing account");
115
+ F(e instanceof Error ? e.message : "Failed to create billing account");
70
116
  }
71
117
  }, [
72
- ze,
73
- C,
74
- W,
75
- X,
76
- K
77
- ]), We = a(() => {
78
- M(!0);
79
- }, []), $ = a(async () => {
80
- await W();
81
- }, [W]), Ge = a(async () => {
82
- C("billing.payment_method.added", {
118
+ it,
119
+ A,
120
+ G,
121
+ at,
122
+ q
123
+ ]), ut = d(() => {
124
+ qe(!0);
125
+ }, []), Z = d(async () => {
126
+ await G();
127
+ }, [G]), dt = d(async () => {
128
+ A("billing.payment_method.added", {
83
129
  route: "/billing/overview",
84
- entityId: G,
130
+ entityId: K,
85
131
  source: "overview"
86
- }), await $();
132
+ }), await Z();
87
133
  }, [
88
- G,
89
- C,
90
- $
91
- ]), Ke = a(async (e) => {
92
- G && (await Be(e, G), C("billing.payment_method.default_set", {
134
+ K,
135
+ A,
136
+ Z
137
+ ]), ft = d(async (e) => {
138
+ K && (await ot(e, K), A("billing.payment_method.default_set", {
93
139
  route: "/billing/overview",
94
140
  entityId: e,
95
141
  source: "overview"
96
- }), await $());
142
+ }), await Z());
97
143
  }, [
98
- G,
99
- C,
100
- Be,
101
- $
102
- ]), qe = a(async (e) => {
103
- G && (await Ve(e, G), C("billing.payment_method.deleted", {
144
+ K,
145
+ A,
146
+ ot,
147
+ Z
148
+ ]), pt = d(async (e) => {
149
+ K && (await st(e, K), A("billing.payment_method.deleted", {
104
150
  route: "/billing/overview",
105
151
  entityId: e,
106
152
  source: "overview"
107
- }), await $());
153
+ }), await Z());
108
154
  }, [
109
- G,
110
- Ve,
111
- C,
112
- $
113
- ]), Je = a((e) => {
114
- K(e.id), j(!1);
115
- }, [K]), Ye = a(async () => {
116
- await W();
117
- }, [W]), Xe = a((e) => {
118
- q(e);
119
- }, [q]), Ze = a((e) => J(e), [J]), Qe = a((e) => Le(e)?.quantity || 0, [Le]), $e = a((e, t) => {
120
- t <= 0 ? Y(e) : Re(e, t);
121
- }, [Re, Y]), et = a((e) => {
122
- Y(e);
123
- }, [Y]);
124
- return S.canViewBillingAccount ? U && re(U) && !H ? /* @__PURE__ */ g("div", {
155
+ K,
156
+ st,
157
+ A,
158
+ Z
159
+ ]), mt = d((e) => {
160
+ q(e.id), L(!1);
161
+ }, [q]), ht = d(async () => {
162
+ await G();
163
+ }, [G]), gt = d((e) => {
164
+ et(e);
165
+ }, [et]), _t = d((e) => tt(e), [tt]), vt = d((e) => nt(e)?.quantity || 0, [nt]), yt = d((e, t) => {
166
+ t <= 0 ? J(e) : rt(e, t);
167
+ }, [rt, J]), bt = d((e) => {
168
+ J(e);
169
+ }, [J]);
170
+ if (!O.canViewBillingAccount) return /* @__PURE__ */ T(ue, { message: "You don't have permission to view billing information." });
171
+ if (Qe && le(Qe) && !W) return /* @__PURE__ */ T("div", {
125
172
  className: "p-6",
126
- children: /* @__PURE__ */ g(ee, {
127
- title: v("billing.serverError.title", "Server Unavailable"),
128
- message: v("billing.overview.serverUnavailableMessage", "Unable to load billing overview. The server might be down or experiencing issues."),
129
- onRetry: Ye,
173
+ children: /* @__PURE__ */ T(ce, {
174
+ title: s("billing.serverError.title", "Server Unavailable"),
175
+ message: s("billing.overview.serverUnavailableMessage", "Unable to load billing overview. The server might be down or experiencing issues."),
176
+ onRetry: ht,
130
177
  showRetry: !0
131
178
  })
132
- }) : H && !R ? /* @__PURE__ */ g("div", {
179
+ });
180
+ if (W && !V) return /* @__PURE__ */ T("div", {
133
181
  className: "flex items-center justify-center min-h-[400px]",
134
- children: /* @__PURE__ */ _("div", {
182
+ children: /* @__PURE__ */ E("div", {
135
183
  className: "flex flex-col items-center gap-3",
136
- children: [/* @__PURE__ */ g(be, { className: "size-8 animate-spin text-text-link" }), /* @__PURE__ */ g("p", {
184
+ children: [/* @__PURE__ */ T(Re, { className: "size-8 animate-spin text-text-link" }), /* @__PURE__ */ T("p", {
137
185
  className: "text-sm text-text-secondary",
138
- children: v("billing.overview.loadingInfo", "Loading billing information...")
186
+ children: s("billing.overview.loadingInfo", "Loading billing information...")
139
187
  })]
140
188
  })
141
- }) : !H && L.length === 0 && !R ? /* @__PURE__ */ _("div", {
142
- className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6",
189
+ });
190
+ if (!W && B.length === 0 && !V) {
191
+ let e = ae(k, O.canManageBillingAccount);
192
+ return /* @__PURE__ */ E("div", {
193
+ className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6",
194
+ children: [
195
+ /* @__PURE__ */ E("header", {
196
+ className: "relative overflow-hidden mb-6 sm:mb-8 rounded-card",
197
+ children: [
198
+ /* @__PURE__ */ T(De, { intensity: "subtle" }),
199
+ /* @__PURE__ */ T("h1", {
200
+ className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
201
+ children: /* @__PURE__ */ T(m, { children: s("billing.overview.title", "Billing Overview") })
202
+ }),
203
+ /* @__PURE__ */ T("p", {
204
+ className: "text-sm text-text-secondary mt-1",
205
+ children: s("billing.overview.emptySetupDescription", "Set up billing to manage subscriptions, payments, and invoices")
206
+ })
207
+ ]
208
+ }),
209
+ e === "request-access" ? /* @__PURE__ */ T(Ee, {
210
+ message: s("billing.overview.needAccountAccess", "You need access to create a billing account"),
211
+ granterHint: s("billing.overview.needAccountAccessHint", "Ask a billing admin of this organization to create one or give you access.")
212
+ }) : /* @__PURE__ */ T(je, {
213
+ illustration: "onboarding",
214
+ title: s("billing.overview.emptyTitle", "No billing account"),
215
+ description: s("billing.overview.emptyDescription", "Create a billing account to start managing your subscriptions and payments"),
216
+ action: O.canManageBillingAccount ? /* @__PURE__ */ E("button", {
217
+ type: "button",
218
+ onClick: () => N(!0),
219
+ className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-action-primary-text bg-action-primary-bg rounded-button hover:bg-action-primary-bgHover transition-colors duration-200",
220
+ children: [/* @__PURE__ */ T(x, { className: "size-4" }), s("billing.overview.createBillingAccount", "Create Billing Account")]
221
+ }) : void 0
222
+ }),
223
+ /* @__PURE__ */ T(ye, {
224
+ isOpen: M,
225
+ onClose: () => {
226
+ N(!1), F(null);
227
+ },
228
+ onSubmit: lt,
229
+ isSubmitting: ct,
230
+ error: P
231
+ })
232
+ ]
233
+ });
234
+ }
235
+ let xt = B.length > 1 && /* @__PURE__ */ E("div", {
236
+ className: "relative",
237
+ "data-tour": "billing-overview-account-selector",
238
+ children: [/* @__PURE__ */ E("button", {
239
+ type: "button",
240
+ onClick: () => L(!I),
241
+ className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
242
+ children: [/* @__PURE__ */ E("div", {
243
+ className: "flex items-center gap-3",
244
+ children: [/* @__PURE__ */ T("div", {
245
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
246
+ children: /* @__PURE__ */ T(g, { className: "size-4 text-text-link" })
247
+ }), /* @__PURE__ */ E("div", {
248
+ className: "text-left",
249
+ children: [/* @__PURE__ */ T("p", {
250
+ className: "text-sm font-medium text-text-primary",
251
+ children: V?.name || s("billing.overview.selectAccount", "Select Account")
252
+ }), /* @__PURE__ */ T("p", {
253
+ className: "text-xs text-text-secondary",
254
+ children: V?.email
255
+ })]
256
+ })]
257
+ }), /* @__PURE__ */ T(v, { className: `size-4 text-text-muted transition-transform ${I ? "rotate-180" : ""}` })]
258
+ }), I && /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("div", {
259
+ className: "fixed inset-0 z-10",
260
+ onClick: () => L(!1)
261
+ }), /* @__PURE__ */ T("div", {
262
+ className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
263
+ children: B.map((e) => /* @__PURE__ */ E("button", {
264
+ type: "button",
265
+ onClick: () => mt(e),
266
+ className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
267
+ children: [/* @__PURE__ */ E("div", {
268
+ className: "flex items-center gap-3 min-w-0",
269
+ children: [/* @__PURE__ */ T("div", {
270
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
271
+ children: /* @__PURE__ */ T(g, { className: "size-4 text-text-secondary" })
272
+ }), /* @__PURE__ */ E("div", {
273
+ className: "text-left min-w-0",
274
+ children: [/* @__PURE__ */ T("p", {
275
+ className: "text-sm font-medium text-text-primary truncate",
276
+ children: e.name
277
+ }), /* @__PURE__ */ T("p", {
278
+ className: "text-xs text-text-secondary truncate",
279
+ children: e.email
280
+ })]
281
+ })]
282
+ }), V?.id === e.id && /* @__PURE__ */ T(_, { className: "size-4 text-text-link flex-shrink-0" })]
283
+ }, e.id))
284
+ })] })]
285
+ }), St = V && /* @__PURE__ */ E("div", {
286
+ className: "grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4",
287
+ "data-tour": "billing-overview-stats-row",
143
288
  children: [
144
- /* @__PURE__ */ _("header", {
145
- className: "relative overflow-hidden mb-6 sm:mb-8 rounded-card",
146
- children: [
147
- /* @__PURE__ */ g(Ce, { intensity: "subtle" }),
148
- /* @__PURE__ */ g("h1", {
149
- className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
150
- children: /* @__PURE__ */ g(De, { children: v("billing.overview.title", "Billing Overview") })
151
- }),
152
- /* @__PURE__ */ g("p", {
153
- className: "text-sm text-text-secondary mt-1",
154
- children: v("billing.overview.emptySetupDescription", "Set up billing to manage subscriptions, payments, and invoices")
155
- })
156
- ]
289
+ /* @__PURE__ */ T(l, {
290
+ className: "p-3 sm:p-5",
291
+ label: s("billing.overview.stats.creditBalance", "Credit Balance"),
292
+ value: `${(V.creditAmount || 0).toLocaleString()} Credits`,
293
+ icon: /* @__PURE__ */ T(C, { className: "size-5" })
157
294
  }),
158
- /* @__PURE__ */ g(Oe, {
159
- illustration: "onboarding",
160
- title: v("billing.overview.emptyTitle", "No billing account"),
161
- description: v("billing.overview.emptyDescription", "Create a billing account to start managing your subscriptions and payments"),
162
- action: S.canManageBillingAccount ? /* @__PURE__ */ _("button", {
163
- type: "button",
164
- onClick: () => E(!0),
165
- className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-action-primary-text bg-action-primary-bg rounded-button hover:bg-action-primary-bgHover transition-colors duration-200",
166
- children: [/* @__PURE__ */ g(f, { className: "size-4" }), v("billing.overview.createBillingAccount", "Create Billing Account")]
167
- }) : void 0
295
+ /* @__PURE__ */ T(l, {
296
+ className: "p-3 sm:p-5",
297
+ label: s("billing.overview.stats.activePlans", "Active Plans"),
298
+ value: U.length > 0 ? U.length === 1 ? U[0]?.plan?.name || "1 Plan" : `${U.length} ${s("billing.overview.stats.plansSuffix", "Plans")}` : s("billing.overview.stats.none", "None"),
299
+ icon: /* @__PURE__ */ T(S, { className: "size-5" })
168
300
  }),
169
- /* @__PURE__ */ g(i, {
170
- isOpen: T,
171
- onClose: () => {
172
- E(!1), O(null);
173
- },
174
- onSubmit: Ue,
175
- isSubmitting: He,
176
- error: D
301
+ /* @__PURE__ */ T(l, {
302
+ className: "p-3 sm:p-5",
303
+ label: s("billing.overview.stats.paymentMethods", "Payment Methods"),
304
+ value: H.length,
305
+ icon: /* @__PURE__ */ T(g, { className: "size-5" })
306
+ }),
307
+ /* @__PURE__ */ T(l, {
308
+ className: "p-3 sm:p-5",
309
+ label: s("billing.overview.stats.paymentCurrency", "Payment Currency"),
310
+ value: V.currency || "USD",
311
+ icon: /* @__PURE__ */ T(g, { className: "size-5" })
177
312
  })
178
313
  ]
179
- }) : /* @__PURE__ */ _("div", {
314
+ }), Ct = /* @__PURE__ */ E("div", {
315
+ className: "grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6",
316
+ children: [/* @__PURE__ */ E("div", {
317
+ className: "lg:col-span-2 space-y-4 sm:space-y-6",
318
+ children: [
319
+ V && /* @__PURE__ */ T(he, {
320
+ dataTour: "billing-overview-billing-account-card",
321
+ account: V,
322
+ isDefault: V.isDefault ?? !1,
323
+ onEdit: () => V && X(`/settings?billingAccountId=${V.id}`),
324
+ onViewTransactions: () => X(`/transactions/${V.id}`),
325
+ onViewCreditTransactions: () => X(`/creditTransactions/${V.id}`)
326
+ }),
327
+ /* @__PURE__ */ E("div", {
328
+ className: "space-y-3",
329
+ children: [U.length > 1 && /* @__PURE__ */ E("div", {
330
+ className: "relative",
331
+ children: [/* @__PURE__ */ E("button", {
332
+ type: "button",
333
+ onClick: () => z(!R),
334
+ className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
335
+ children: [/* @__PURE__ */ E("div", {
336
+ className: "flex items-center gap-3",
337
+ children: [/* @__PURE__ */ T("div", {
338
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
339
+ children: /* @__PURE__ */ T(y, { className: "size-4 text-text-link" })
340
+ }), /* @__PURE__ */ E("div", {
341
+ className: "text-left",
342
+ children: [/* @__PURE__ */ E("p", {
343
+ className: "text-sm font-medium text-text-primary",
344
+ children: [Y?.plan?.name || s("billing.overview.selectSubscription", "Select Subscription"), Y?.plan?.product?.name && /* @__PURE__ */ E("span", {
345
+ className: "text-text-secondary font-normal",
346
+ children: [
347
+ " ",
348
+ "· ",
349
+ Y.plan.product.name
350
+ ]
351
+ })]
352
+ }), /* @__PURE__ */ E("p", {
353
+ className: "text-xs text-text-secondary",
354
+ children: [
355
+ U.length,
356
+ " ",
357
+ s("billing.overview.activeSubscriptions", "active subscriptions")
358
+ ]
359
+ })]
360
+ })]
361
+ }), /* @__PURE__ */ T(v, { className: `size-4 text-text-muted transition-transform ${R ? "rotate-180" : ""}` })]
362
+ }), R && /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T("div", {
363
+ className: "fixed inset-0 z-10",
364
+ onClick: () => z(!1)
365
+ }), /* @__PURE__ */ T("div", {
366
+ className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
367
+ children: U.map((e, t) => /* @__PURE__ */ E("button", {
368
+ type: "button",
369
+ onClick: () => {
370
+ Ye(t), z(!1);
371
+ },
372
+ className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
373
+ children: [/* @__PURE__ */ E("div", {
374
+ className: "flex items-center gap-3 min-w-0",
375
+ children: [/* @__PURE__ */ T("div", {
376
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
377
+ children: /* @__PURE__ */ T(y, { className: "size-4 text-text-secondary" })
378
+ }), /* @__PURE__ */ E("div", {
379
+ className: "text-left min-w-0",
380
+ children: [/* @__PURE__ */ T("p", {
381
+ className: "text-sm font-medium text-text-primary truncate",
382
+ children: e.plan?.name || s("billing.overview.subscription", "Subscription")
383
+ }), /* @__PURE__ */ E("p", {
384
+ className: "text-xs text-text-secondary truncate",
385
+ children: [
386
+ e.plan?.product?.name || s("billing.overview.unknownProduct", "Unknown Product"),
387
+ " ",
388
+ "· ",
389
+ s("billing.overview.ends", "Ends"),
390
+ " ",
391
+ new Date(e.endDate).toLocaleDateString()
392
+ ]
393
+ })]
394
+ })]
395
+ }), Je === t && /* @__PURE__ */ T(_, { className: "size-4 text-text-link flex-shrink-0" })]
396
+ }, e.id))
397
+ })] })]
398
+ }), /* @__PURE__ */ T(_e, {
399
+ dataTour: "billing-overview-active-subscription-card",
400
+ subscription: Y,
401
+ onViewDetails: () => Y && X(we(`/subscriptions/${Y.id}`, Y.billingAccountId ?? V?.id)),
402
+ onUpgrade: () => Y && X(we(`/subscriptions/${Y.id}/upgrade`, Y.billingAccountId ?? V?.id)),
403
+ onManage: () => V && X(`/subscriptions?billingAccountId=${V.id}`),
404
+ onPurchasePlan: () => X("/plans")
405
+ })]
406
+ }),
407
+ V && /* @__PURE__ */ T(ge, {
408
+ dataTour: "billing-overview-payment-methods-section",
409
+ paymentMethods: H,
410
+ billingAccountId: V.id,
411
+ onAddPaymentMethod: ut,
412
+ onSetDefault: ft,
413
+ onDelete: pt,
414
+ isLoading: W
415
+ })
416
+ ]
417
+ }), /* @__PURE__ */ E("div", {
418
+ className: "space-y-4 sm:space-y-6",
419
+ children: [/* @__PURE__ */ E("section", {
420
+ className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-5",
421
+ "data-tour": "billing-overview-quick-actions",
422
+ children: [/* @__PURE__ */ T("h3", {
423
+ className: "font-semibold text-text-primary mb-4",
424
+ children: s("billing.overview.quickActions", "Quick Actions")
425
+ }), /* @__PURE__ */ E("div", {
426
+ className: "space-y-1.5",
427
+ children: [
428
+ /* @__PURE__ */ E("button", {
429
+ type: "button",
430
+ onClick: () => V && X(`/transactions/${V.id}`),
431
+ disabled: !V,
432
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
433
+ children: [/* @__PURE__ */ T("div", {
434
+ className: "size-9 rounded-lg bg-status-info-bg-subtle flex items-center justify-center",
435
+ children: /* @__PURE__ */ T(ze, { className: "size-4 text-status-info-text" })
436
+ }), s("billing.overview.viewTransactions", "View Transactions")]
437
+ }),
438
+ /* @__PURE__ */ E("button", {
439
+ type: "button",
440
+ onClick: () => V && X(`/creditTransactions/${V.id}`),
441
+ disabled: !V,
442
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
443
+ children: [/* @__PURE__ */ T("div", {
444
+ className: "size-9 rounded-lg bg-status-warning-bg-subtle flex items-center justify-center",
445
+ children: /* @__PURE__ */ T(C, { className: "size-4 text-status-warning-text" })
446
+ }), s("billing.overview.creditHistory", "Credit History")]
447
+ }),
448
+ /* @__PURE__ */ E("button", {
449
+ type: "button",
450
+ onClick: () => X("/checkout/credits"),
451
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors",
452
+ children: [/* @__PURE__ */ T("div", {
453
+ className: "size-9 rounded-lg bg-status-success-bg-subtle flex items-center justify-center",
454
+ children: /* @__PURE__ */ T(Ie, { className: "size-4 text-status-success-text" })
455
+ }), s("billing.overview.purchaseCredits", "Purchase Credits")]
456
+ }),
457
+ /* @__PURE__ */ E("button", {
458
+ type: "button",
459
+ onClick: () => V && X(`/usage?billingAccountId=${V.id}`),
460
+ disabled: !V,
461
+ className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
462
+ children: [/* @__PURE__ */ T("div", {
463
+ className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
464
+ children: /* @__PURE__ */ T(Pe, { className: "size-4 text-text-link" })
465
+ }), s("billing.overview.usageAnalytics", "Usage Analytics")]
466
+ })
467
+ ]
468
+ })]
469
+ }), !Xe && /* @__PURE__ */ E(Ae, {
470
+ treatment: "glass",
471
+ glow: !0,
472
+ className: "p-4 sm:p-5",
473
+ children: [/* @__PURE__ */ E("div", {
474
+ className: "flex items-start gap-3 mb-4",
475
+ children: [/* @__PURE__ */ T("div", {
476
+ className: "size-10 rounded-lg bg-bg-surface flex items-center justify-center flex-shrink-0 shadow-elevation-1",
477
+ children: /* @__PURE__ */ T(Be, { className: "size-5 text-text-link" })
478
+ }), /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("h3", {
479
+ className: "font-semibold text-text-primary",
480
+ children: s("billing.overview.getStarted", "Get Started")
481
+ }), /* @__PURE__ */ T("p", {
482
+ className: "text-sm text-text-secondary mt-1",
483
+ children: s("billing.overview.getStartedDescription", "Choose a plan that fits your needs to unlock all features")
484
+ })] })]
485
+ }), /* @__PURE__ */ E(Oe, {
486
+ type: "button",
487
+ onClick: () => X("/plans"),
488
+ className: "w-full",
489
+ children: [s("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ T(h, { className: "size-4" })]
490
+ })]
491
+ })]
492
+ })]
493
+ }), wt = /* @__PURE__ */ T(ve, {
494
+ dataTour: "billing-overview-recommended-addons",
495
+ addons: Ze,
496
+ hasSubscription: Xe,
497
+ onViewAddon: (e) => X(`/addons/${e}`),
498
+ onPurchaseAddon: (e) => X(`/addons/${e}?action=purchase`),
499
+ onViewAllAddons: () => X("/addons"),
500
+ onAddToCart: gt,
501
+ isInCart: _t,
502
+ getCartQuantity: vt,
503
+ onUpdateQuantity: yt,
504
+ onRemoveFromCart: bt,
505
+ maxAddons: 3,
506
+ isLoading: $e
507
+ }), Q = se(Y), $ = re(H), Tt = ie(Y), Et = /* @__PURE__ */ E("section", {
508
+ className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-6 space-y-5",
509
+ "data-tour": "billing-overview-plan-summary",
510
+ children: [/* @__PURE__ */ E("div", {
511
+ className: "flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",
512
+ children: [/* @__PURE__ */ E("div", {
513
+ className: "flex items-start gap-3",
514
+ children: [/* @__PURE__ */ T("div", {
515
+ className: "size-10 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center flex-shrink-0",
516
+ children: /* @__PURE__ */ T(y, { className: "size-5 text-text-link" })
517
+ }), /* @__PURE__ */ E("div", { children: [
518
+ /* @__PURE__ */ T("p", {
519
+ className: "text-xs text-text-secondary",
520
+ children: s("billing.overview.currentPlan", "Current plan")
521
+ }),
522
+ /* @__PURE__ */ T("p", {
523
+ className: "text-lg font-semibold text-text-primary",
524
+ children: Q ? Q.planName ?? s("billing.overview.subscription", "Subscription") : s("billing.overview.noPlan", "No plan yet")
525
+ }),
526
+ Q && Q.price !== null && Q.currency && /* @__PURE__ */ T("p", {
527
+ className: "text-sm text-text-secondary",
528
+ children: Q.duration ? ne(Q.price, Q.currency, Q.duration) : a(Q.price, Q.currency)
529
+ })
530
+ ] })]
531
+ }), /* @__PURE__ */ E(Oe, {
532
+ type: "button",
533
+ onClick: () => X(Tt),
534
+ children: [Q ? s("billing.overview.changePlan", "Change plan") : s("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ T(h, { className: "size-4" })]
535
+ })]
536
+ }), /* @__PURE__ */ E("div", {
537
+ className: "grid grid-cols-1 sm:grid-cols-3 gap-4 border-t border-border-seam pt-4",
538
+ children: [
539
+ /* @__PURE__ */ E("div", {
540
+ className: "flex items-start gap-3",
541
+ children: [/* @__PURE__ */ T("div", {
542
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
543
+ children: /* @__PURE__ */ T(Fe, { className: "size-4 text-text-secondary" })
544
+ }), /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("p", {
545
+ className: "text-xs text-text-secondary",
546
+ children: s("billing.overview.nextBill", "Next bill")
547
+ }), /* @__PURE__ */ T("p", {
548
+ className: "text-sm font-medium text-text-primary",
549
+ children: Q?.nextBillDate ? o(Q.nextBillDate) : s("billing.overview.noNextBill", "None scheduled")
550
+ })] })]
551
+ }),
552
+ /* @__PURE__ */ E("div", {
553
+ className: "flex items-start gap-3",
554
+ children: [/* @__PURE__ */ T("div", {
555
+ className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
556
+ children: /* @__PURE__ */ T(Le, { className: "size-4 text-text-secondary" })
557
+ }), /* @__PURE__ */ E("div", { children: [
558
+ /* @__PURE__ */ T("p", {
559
+ className: "text-xs text-text-secondary",
560
+ children: s("billing.overview.savedCard", "Saved card")
561
+ }),
562
+ $ ? /* @__PURE__ */ E("p", {
563
+ className: "text-sm font-medium text-text-primary",
564
+ children: [
565
+ r($.brand),
566
+ " ",
567
+ te($.last4),
568
+ i($.expiryMonth, $.expiryYear) && ` · ${i($.expiryMonth, $.expiryYear)}`
569
+ ]
570
+ }) : /* @__PURE__ */ T("p", {
571
+ className: "text-sm text-text-secondary",
572
+ children: s("billing.overview.noCard", "No card saved")
573
+ }),
574
+ /* @__PURE__ */ T("button", {
575
+ type: "button",
576
+ onClick: () => X("/payment-methods"),
577
+ className: "text-xs text-text-link hover:underline mt-1",
578
+ children: s("billing.overview.managePaymentMethods", "Payment methods")
579
+ })
580
+ ] })]
581
+ }),
582
+ V && /* @__PURE__ */ T(He, {
583
+ billingAccountId: V.id,
584
+ onViewAll: () => X("/invoices")
585
+ })
586
+ ]
587
+ })]
588
+ });
589
+ return /* @__PURE__ */ E("div", {
180
590
  className: "px-4 sm:px-6 lg:px-8 py-4 sm:py-6 space-y-4 sm:space-y-8",
181
591
  children: [
182
- /* @__PURE__ */ _("header", {
592
+ /* @__PURE__ */ E("header", {
183
593
  className: "relative overflow-hidden rounded-card flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",
184
594
  children: [
185
- /* @__PURE__ */ g(Ce, { intensity: "subtle" }),
186
- /* @__PURE__ */ _("div", { children: [
187
- /* @__PURE__ */ g("h1", {
595
+ /* @__PURE__ */ T(De, { intensity: "subtle" }),
596
+ /* @__PURE__ */ E("div", { children: [
597
+ /* @__PURE__ */ T("h1", {
188
598
  className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
189
- children: /* @__PURE__ */ g(De, { children: v("billing.overview.title", "Billing Overview") })
599
+ children: /* @__PURE__ */ T(m, { children: s("billing.overview.title", "Billing Overview") })
190
600
  }),
191
- /* @__PURE__ */ g("p", {
601
+ /* @__PURE__ */ T("p", {
192
602
  className: "text-sm text-text-secondary mt-1",
193
- children: v("billing.overview.description", "Manage your billing accounts, subscriptions, and payment methods")
603
+ children: s("billing.overview.description", "Manage your billing accounts, subscriptions, and payment methods")
194
604
  }),
195
- /* @__PURE__ */ g(ke, {
605
+ /* @__PURE__ */ T(Ne, {
196
606
  className: "mt-3",
197
- children: v("billing.overview.purpose", "Your billing home base — see your current plan, credit balance and payment methods at a glance, and jump to transactions, usage, credits or new plans. Start here to understand what you are paying for and manage it.")
607
+ children: s("billing.overview.purpose", "Your billing home base — see your current plan, credit balance and payment methods at a glance, and jump to transactions, usage, credits or new plans. Start here to understand what you are paying for and manage it.")
198
608
  })
199
609
  ] }),
200
- /* @__PURE__ */ g(Te, {
201
- primary: S.canManageBillingAccount && L.length > 0 ? {
202
- label: v("billing.overview.newAccount", "New Account"),
203
- onSelect: () => E(!0),
204
- icon: /* @__PURE__ */ g(f, { className: "size-4" })
610
+ /* @__PURE__ */ T(ke, {
611
+ primary: oe(k, O.canManageBillingAccount, B.length) ? {
612
+ label: s("billing.overview.newAccount", "New Account"),
613
+ onSelect: () => N(!0),
614
+ icon: /* @__PURE__ */ T(x, { className: "size-4" })
205
615
  } : void 0,
206
616
  actions: [{
207
- label: v("billing.overview.refresh", "Refresh"),
617
+ label: s("billing.overview.refresh", "Refresh"),
208
618
  onSelect: () => {
209
- Ye();
619
+ ht();
210
620
  },
211
- icon: /* @__PURE__ */ g(p, { className: `size-4 ${H ? "animate-spin" : ""}` })
621
+ icon: /* @__PURE__ */ T(S, { className: `size-4 ${W ? "animate-spin" : ""}` })
212
622
  }]
213
623
  })
214
624
  ]
215
625
  }),
216
- L.length > 1 && /* @__PURE__ */ _("div", {
217
- className: "relative",
218
- "data-tour": "billing-overview-account-selector",
219
- children: [/* @__PURE__ */ _("button", {
220
- type: "button",
221
- onClick: () => j(!A),
222
- className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
223
- children: [/* @__PURE__ */ _("div", {
224
- className: "flex items-center gap-3",
225
- children: [/* @__PURE__ */ g("div", {
226
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
227
- children: /* @__PURE__ */ g(c, { className: "size-4 text-text-link" })
228
- }), /* @__PURE__ */ _("div", {
229
- className: "text-left",
230
- children: [/* @__PURE__ */ g("p", {
231
- className: "text-sm font-medium text-text-primary",
232
- children: R?.name || v("billing.overview.selectAccount", "Select Account")
233
- }), /* @__PURE__ */ g("p", {
234
- className: "text-xs text-text-secondary",
235
- children: R?.email
236
- })]
237
- })]
238
- }), /* @__PURE__ */ g(u, { className: `size-4 text-text-muted transition-transform ${A ? "rotate-180" : ""}` })]
239
- }), A && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", {
240
- className: "fixed inset-0 z-10",
241
- onClick: () => j(!1)
242
- }), /* @__PURE__ */ g("div", {
243
- className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
244
- children: L.map((e) => /* @__PURE__ */ _("button", {
245
- type: "button",
246
- onClick: () => Je(e),
247
- className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
248
- children: [/* @__PURE__ */ _("div", {
249
- className: "flex items-center gap-3 min-w-0",
250
- children: [/* @__PURE__ */ g("div", {
251
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
252
- children: /* @__PURE__ */ g(c, { className: "size-4 text-text-secondary" })
253
- }), /* @__PURE__ */ _("div", {
254
- className: "text-left min-w-0",
255
- children: [/* @__PURE__ */ g("p", {
256
- className: "text-sm font-medium text-text-primary truncate",
257
- children: e.name
258
- }), /* @__PURE__ */ g("p", {
259
- className: "text-xs text-text-secondary truncate",
260
- children: e.email
261
- })]
262
- })]
263
- }), R?.id === e.id && /* @__PURE__ */ g(l, { className: "size-4 text-text-link flex-shrink-0" })]
264
- }, e.id))
265
- })] })]
266
- }),
267
- R && /* @__PURE__ */ _("div", {
268
- className: "grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4",
269
- "data-tour": "billing-overview-stats-row",
270
- children: [
271
- /* @__PURE__ */ g(r, {
272
- className: "p-3 sm:p-5",
273
- label: v("billing.overview.stats.creditBalance", "Credit Balance"),
274
- value: `${(R.creditAmount || 0).toLocaleString()} Credits`,
275
- icon: /* @__PURE__ */ g(m, { className: "size-5" })
276
- }),
277
- /* @__PURE__ */ g(r, {
278
- className: "p-3 sm:p-5",
279
- label: v("billing.overview.stats.activePlans", "Active Plans"),
280
- value: B.length > 0 ? B.length === 1 ? B[0]?.plan?.name || "1 Plan" : `${B.length} ${v("billing.overview.stats.plansSuffix", "Plans")}` : v("billing.overview.stats.none", "None"),
281
- icon: /* @__PURE__ */ g(p, { className: "size-5" })
282
- }),
283
- /* @__PURE__ */ g(r, {
284
- className: "p-3 sm:p-5",
285
- label: v("billing.overview.stats.paymentMethods", "Payment Methods"),
286
- value: z.length,
287
- icon: /* @__PURE__ */ g(c, { className: "size-5" })
288
- }),
289
- /* @__PURE__ */ g(r, {
290
- className: "p-3 sm:p-5",
291
- label: v("billing.overview.stats.paymentCurrency", "Payment Currency"),
292
- value: R.currency || "USD",
293
- icon: /* @__PURE__ */ g(c, { className: "size-5" })
294
- })
295
- ]
296
- }),
297
- /* @__PURE__ */ _("div", {
298
- className: "grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6",
299
- children: [/* @__PURE__ */ _("div", {
300
- className: "lg:col-span-2 space-y-4 sm:space-y-6",
626
+ k ? /* @__PURE__ */ E(w, { children: [Et, /* @__PURE__ */ T(Me, {
627
+ storageKey: "billing.overview.more",
628
+ label: s("billing.overview.moreOptions", "More options"),
629
+ children: /* @__PURE__ */ E("div", {
630
+ className: "space-y-4 sm:space-y-8",
301
631
  children: [
302
- R && /* @__PURE__ */ g(se, {
303
- dataTour: "billing-overview-billing-account-card",
304
- account: R,
305
- isDefault: R.isDefault ?? !1,
306
- onEdit: () => R && Q(`/settings?billingAccountId=${R.id}`),
307
- onViewTransactions: () => Q(`/transactions/${R.id}`),
308
- onViewCreditTransactions: () => Q(`/creditTransactions/${R.id}`)
309
- }),
310
- /* @__PURE__ */ _("div", {
311
- className: "space-y-3",
312
- children: [B.length > 1 && /* @__PURE__ */ _("div", {
313
- className: "relative",
314
- children: [/* @__PURE__ */ _("button", {
315
- type: "button",
316
- onClick: () => I(!F),
317
- className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-seam rounded-card bg-bg-surface hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
318
- children: [/* @__PURE__ */ _("div", {
319
- className: "flex items-center gap-3",
320
- children: [/* @__PURE__ */ g("div", {
321
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
322
- children: /* @__PURE__ */ g(d, { className: "size-4 text-text-link" })
323
- }), /* @__PURE__ */ _("div", {
324
- className: "text-left",
325
- children: [/* @__PURE__ */ _("p", {
326
- className: "text-sm font-medium text-text-primary",
327
- children: [Z?.plan?.name || v("billing.overview.selectSubscription", "Select Subscription"), Z?.plan?.product?.name && /* @__PURE__ */ _("span", {
328
- className: "text-text-secondary font-normal",
329
- children: [
330
- " ",
331
- "· ",
332
- Z.plan.product.name
333
- ]
334
- })]
335
- }), /* @__PURE__ */ _("p", {
336
- className: "text-xs text-text-secondary",
337
- children: [
338
- B.length,
339
- " ",
340
- v("billing.overview.activeSubscriptions", "active subscriptions")
341
- ]
342
- })]
343
- })]
344
- }), /* @__PURE__ */ g(u, { className: `size-4 text-text-muted transition-transform ${F ? "rotate-180" : ""}` })]
345
- }), F && /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g("div", {
346
- className: "fixed inset-0 z-10",
347
- onClick: () => I(!1)
348
- }), /* @__PURE__ */ g("div", {
349
- className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-bg-elevated border border-border-seam rounded-card shadow-elevation-3 z-20 py-1 max-h-60 overflow-y-auto",
350
- children: B.map((e, t) => /* @__PURE__ */ _("button", {
351
- type: "button",
352
- onClick: () => {
353
- P(t), I(!1);
354
- },
355
- className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
356
- children: [/* @__PURE__ */ _("div", {
357
- className: "flex items-center gap-3 min-w-0",
358
- children: [/* @__PURE__ */ g("div", {
359
- className: "size-9 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
360
- children: /* @__PURE__ */ g(d, { className: "size-4 text-text-secondary" })
361
- }), /* @__PURE__ */ _("div", {
362
- className: "text-left min-w-0",
363
- children: [/* @__PURE__ */ g("p", {
364
- className: "text-sm font-medium text-text-primary truncate",
365
- children: e.plan?.name || v("billing.overview.subscription", "Subscription")
366
- }), /* @__PURE__ */ _("p", {
367
- className: "text-xs text-text-secondary truncate",
368
- children: [
369
- e.plan?.product?.name || v("billing.overview.unknownProduct", "Unknown Product"),
370
- " ",
371
- "· ",
372
- v("billing.overview.ends", "Ends"),
373
- " ",
374
- new Date(e.endDate).toLocaleDateString()
375
- ]
376
- })]
377
- })]
378
- }), N === t && /* @__PURE__ */ g(l, { className: "size-4 text-text-link flex-shrink-0" })]
379
- }, e.id))
380
- })] })]
381
- }), /* @__PURE__ */ g(le, {
382
- dataTour: "billing-overview-active-subscription-card",
383
- subscription: Z,
384
- onViewDetails: () => Z && Q(he(`/subscriptions/${Z.id}`, Z.billingAccountId ?? R?.id)),
385
- onUpgrade: () => Z && Q(he(`/subscriptions/${Z.id}/upgrade`, Z.billingAccountId ?? R?.id)),
386
- onManage: () => R && Q(`/subscriptions?billingAccountId=${R.id}`),
387
- onPurchasePlan: () => Q("/plans")
388
- })]
389
- }),
390
- R && /* @__PURE__ */ g(ce, {
391
- dataTour: "billing-overview-payment-methods-section",
392
- paymentMethods: z,
393
- billingAccountId: R.id,
394
- onAddPaymentMethod: We,
395
- onSetDefault: Ke,
396
- onDelete: qe,
397
- isLoading: H
398
- })
632
+ xt,
633
+ St,
634
+ Ct,
635
+ wt
399
636
  ]
400
- }), /* @__PURE__ */ _("div", {
401
- className: "space-y-4 sm:space-y-6",
402
- children: [/* @__PURE__ */ _("section", {
403
- className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-4 sm:p-5",
404
- "data-tour": "billing-overview-quick-actions",
405
- children: [/* @__PURE__ */ g("h3", {
406
- className: "font-semibold text-text-primary mb-4",
407
- children: v("billing.overview.quickActions", "Quick Actions")
408
- }), /* @__PURE__ */ _("div", {
409
- className: "space-y-1.5",
410
- children: [
411
- /* @__PURE__ */ _("button", {
412
- type: "button",
413
- onClick: () => R && Q(`/transactions/${R.id}`),
414
- disabled: !R,
415
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
416
- children: [/* @__PURE__ */ g("div", {
417
- className: "size-9 rounded-lg bg-status-info-bg-subtle flex items-center justify-center",
418
- children: /* @__PURE__ */ g(xe, { className: "size-4 text-status-info-text" })
419
- }), v("billing.overview.viewTransactions", "View Transactions")]
420
- }),
421
- /* @__PURE__ */ _("button", {
422
- type: "button",
423
- onClick: () => R && Q(`/creditTransactions/${R.id}`),
424
- disabled: !R,
425
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
426
- children: [/* @__PURE__ */ g("div", {
427
- className: "size-9 rounded-lg bg-status-warning-bg-subtle flex items-center justify-center",
428
- children: /* @__PURE__ */ g(m, { className: "size-4 text-status-warning-text" })
429
- }), v("billing.overview.creditHistory", "Credit History")]
430
- }),
431
- /* @__PURE__ */ _("button", {
432
- type: "button",
433
- onClick: () => Q("/checkout/credits"),
434
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors",
435
- children: [/* @__PURE__ */ g("div", {
436
- className: "size-9 rounded-lg bg-status-success-bg-subtle flex items-center justify-center",
437
- children: /* @__PURE__ */ g(ye, { className: "size-4 text-status-success-text" })
438
- }), v("billing.overview.purchaseCredits", "Purchase Credits")]
439
- }),
440
- /* @__PURE__ */ _("button", {
441
- type: "button",
442
- onClick: () => R && Q(`/usage?billingAccountId=${R.id}`),
443
- disabled: !R,
444
- className: "w-full flex items-center gap-3 px-3 py-2.5 text-sm text-left text-text-primary hover:bg-bg-sunken rounded-button transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
445
- children: [/* @__PURE__ */ g("div", {
446
- className: "size-9 rounded-lg bg-[var(--color-accent-soft)] flex items-center justify-center",
447
- children: /* @__PURE__ */ g(_e, { className: "size-4 text-text-link" })
448
- }), v("billing.overview.usageAnalytics", "Usage Analytics")]
449
- })
450
- ]
451
- })]
452
- }), !V && /* @__PURE__ */ _(Ee, {
453
- treatment: "glass",
454
- glow: !0,
455
- className: "p-4 sm:p-5",
456
- children: [/* @__PURE__ */ _("div", {
457
- className: "flex items-start gap-3 mb-4",
458
- children: [/* @__PURE__ */ g("div", {
459
- className: "size-10 rounded-lg bg-bg-surface flex items-center justify-center flex-shrink-0 shadow-elevation-1",
460
- children: /* @__PURE__ */ g(Se, { className: "size-5 text-text-link" })
461
- }), /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("h3", {
462
- className: "font-semibold text-text-primary",
463
- children: v("billing.overview.getStarted", "Get Started")
464
- }), /* @__PURE__ */ g("p", {
465
- className: "text-sm text-text-secondary mt-1",
466
- children: v("billing.overview.getStartedDescription", "Choose a plan that fits your needs to unlock all features")
467
- })] })]
468
- }), /* @__PURE__ */ _(we, {
469
- type: "button",
470
- onClick: () => Q("/plans"),
471
- className: "w-full",
472
- children: [v("billing.overview.browsePlans", "Browse Plans"), /* @__PURE__ */ g(ve, { className: "size-4" })]
473
- })]
474
- })]
475
- })]
476
- }),
477
- /* @__PURE__ */ g(ue, {
478
- dataTour: "billing-overview-recommended-addons",
479
- addons: Fe,
480
- hasSubscription: V,
481
- onViewAddon: (e) => Q(`/addons/${e}`),
482
- onPurchaseAddon: (e) => Q(`/addons/${e}?action=purchase`),
483
- onViewAllAddons: () => Q("/addons"),
484
- onAddToCart: Xe,
485
- isInCart: Ze,
486
- getCartQuantity: Qe,
487
- onUpdateQuantity: $e,
488
- onRemoveFromCart: et,
489
- maxAddons: 3,
490
- isLoading: Ie
491
- }),
492
- /* @__PURE__ */ g(fe, {}),
493
- Ne && /* @__PURE__ */ g(ne, { onDismiss: () => k(!1) }),
494
- /* @__PURE__ */ g(i, {
495
- isOpen: T,
637
+ })
638
+ })] }) : /* @__PURE__ */ E(w, { children: [
639
+ xt,
640
+ St,
641
+ Ct,
642
+ wt
643
+ ] }),
644
+ /* @__PURE__ */ T(xe, {}),
645
+ We && /* @__PURE__ */ T(de, { onDismiss: () => Ge(!1) }),
646
+ /* @__PURE__ */ T(ye, {
647
+ isOpen: M,
496
648
  onClose: () => {
497
- E(!1), O(null);
649
+ N(!1), F(null);
498
650
  },
499
- onSubmit: Ue,
500
- isSubmitting: He,
501
- error: D
651
+ onSubmit: lt,
652
+ isSubmitting: ct,
653
+ error: P
502
654
  }),
503
- R && /* @__PURE__ */ g(de, {
504
- isOpen: Pe,
505
- onClose: () => M(!1),
506
- billingAccountId: R.id,
507
- currency: R.currency,
508
- country: R.billingAddresses?.[0]?.country,
509
- onSuccess: Ge
655
+ V && /* @__PURE__ */ T(be, {
656
+ isOpen: Ke,
657
+ onClose: () => qe(!1),
658
+ billingAccountId: V.id,
659
+ currency: V.currency,
660
+ country: V.billingAddresses?.[0]?.country,
661
+ onSuccess: dt
510
662
  })
511
663
  ]
512
- }) : /* @__PURE__ */ g(te, { message: "You don't have permission to view billing information." });
664
+ });
513
665
  };
514
- export { v as OverviewPage };
666
+ export { D as OverviewPage };
515
667
 
516
668
  //# sourceMappingURL=OverviewPage.js.map