@burdenoff/microfe-billing 2026.708.1 → 2026.716.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,29 +26,31 @@ import { SubscriptionSelector as xe } from "../components/SubscriptionSelector.j
26
26
  import { SimpleAutoPayToggle as Se } from "../components/SimpleAutoPayToggle.js";
27
27
  import { UnifiedPaymentMethodSelector as Ce } from "../components/UnifiedPaymentMethodSelector.js";
28
28
  import { CompleteBillingAccountModal as we, isBillingAccountComplete as Te } from "../components/CompleteBillingAccountModal.js";
29
- import { WorkspaceQuotaAssignmentModal as Ee, isWorkspaceScopedQuota as De } from "../components/WorkspaceQuotaAssignmentModal.js";
29
+ import { STORE_SHIPPING_ITEM_ID as Ee, useSetStoreOrderShipping as De } from "../hooks/useStoreShipping.js";
30
+ import { StoreShippingSection as Oe } from "../components/StoreShippingSection.js";
31
+ import { WorkspaceQuotaAssignmentModal as ke, isWorkspaceScopedQuota as Ae } from "../components/WorkspaceQuotaAssignmentModal.js";
30
32
  import "../components/index.js";
31
- import { buildStoreOrderCheckoutItems as Oe, normalizeStoreOrderCurrency as ke } from "../utils/storeOrder.js";
32
- import { useCallback as s, useEffect as c, useMemo as l, useRef as Ae, useState as u } from "react";
33
- import { ArrowLeft as je, ArrowRight as Me, Blocks as Ne, CheckCircle as Pe, Coins as Fe, CreditCard as Ie, Loader2 as d, Package as Le, Receipt as Re, RefreshCw as ze, ShoppingCart as Be, Wallet as Ve, XCircle as He } from "lucide-react";
34
- import { useLocation as Ue, useParams as We } from "react-router-dom";
35
- import { useAppShell as Ge } from "@burdenoff/fe-libs/shared/providers/shell";
33
+ import { buildStoreOrderCheckoutItems as je, normalizeStoreOrderCurrency as Me } from "../utils/storeOrder.js";
34
+ import { useCallback as s, useEffect as c, useMemo as l, useRef as Ne, useState as u } from "react";
35
+ import { ArrowLeft as Pe, ArrowRight as Fe, Blocks as Ie, CheckCircle as Le, Coins as Re, CreditCard as ze, Loader2 as d, Package as Be, Receipt as Ve, RefreshCw as He, ShoppingCart as Ue, Wallet as We, XCircle as Ge } from "lucide-react";
36
+ import { useLocation as Ke, useParams as qe } from "react-router-dom";
37
+ import { useAppShell as Je } from "@burdenoff/fe-libs/shared/providers/shell";
36
38
  import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
37
- import { useI18n as Ke } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
38
- import { getProfileScopedKey as qe } from "@burdenoff/fe-libs/shared/utils";
39
- import { PagePurpose as Je } from "@burdenoff/fe-libs/ui";
39
+ import { useI18n as Ye } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
40
+ import { getProfileScopedKey as Xe } from "@burdenoff/fe-libs/shared/utils";
41
+ import { PagePurpose as Ze } from "@burdenoff/fe-libs/ui";
40
42
  //#region src/billing/modules/checkout/pages/CheckoutPage.tsx
41
- var Ye = () => {
42
- let { t: Ye } = Ke(), h = (e, t) => {
43
- let n = Ye(e);
43
+ var Qe = () => {
44
+ let { t: Qe } = Ye(), h = (e, t) => {
45
+ let n = Qe(e);
44
46
  return n === e ? t : n;
45
- }, { planId: Xe, addonId: g, storeOrderId: _ } = We(), v = se(), y = Ue(), b = y.state, Ze = a(), { emit: x } = r(), { orgId: S, stripePublishableKey: Qe, razorpayKey: $e, apiGatewayUrl: et, authToken: tt, currentUser: nt, workspaceId: C } = e(), { productSlug: rt } = Ge(), w = Ae(null), it = C ? [{
46
- id: C,
47
+ }, { planId: $e, addonId: et, storeOrderId: g } = qe(), _ = se(), tt = Ke(), v = tt.state, nt = a(), { emit: y } = r(), { orgId: b, stripePublishableKey: rt, razorpayKey: it, apiGatewayUrl: at, authToken: ot, currentUser: st, workspaceId: x } = e(), { productSlug: ct } = Je(), lt = Ne(null), ut = x ? [{
48
+ id: x,
47
49
  name: "Current workspace"
48
- }] : [], { items: T, clearCart: at, _hasHydrated: E } = oe(), D = y.pathname.includes("/checkout/addons") && !g, O = y.pathname.includes("/checkout/store") && !!_, k = D ? "ADDON" : O ? "ORDER" : b?.purchaseType ?? (Xe ? "PLAN" : g ? "ADDON" : "CREDITS"), A = b?.itemId ?? Xe ?? g ?? _, [ot, st] = u(!1), ct = Ae(!1), [lt, j] = u(!1), [ut, dt] = u([]), [ft, pt] = u(null), [M, N] = u("select"), [P, mt] = u(null), [ht, F] = u(null), [I, gt] = u(null), [_t, vt] = u("card");
50
+ }] : [], { items: S, clearCart: dt, _hasHydrated: C } = oe(), w = tt.pathname.includes("/checkout/addons") && !et, T = tt.pathname.includes("/checkout/store") && !!g, E = w ? "ADDON" : T ? "ORDER" : v?.purchaseType ?? ($e ? "PLAN" : et ? "ADDON" : "CREDITS"), D = v?.itemId ?? $e ?? et ?? g, [ft, O] = u(!1), k = Ne(!1), [pt, A] = u(!1), [mt, ht] = u([]), [gt, _t] = u(null), [j, M] = u("select"), [N, vt] = u(null), [yt, P] = u(null), [F, bt] = u(null), [xt, St] = u("card");
49
51
  c(() => {
50
- if (M !== "success" || !I) return;
51
- let e = typeof window < "u" ? window.localStorage.getItem(qe("boff-referral-attribution")) : null;
52
+ if (j !== "success" || !F) return;
53
+ let e = typeof window < "u" ? window.localStorage.getItem(Xe("boff-referral-attribution")) : null;
52
54
  if (!e) return;
53
55
  let t;
54
56
  try {
@@ -57,184 +59,192 @@ var Ye = () => {
57
59
  return;
58
60
  }
59
61
  if (!t.journeyId && !t.codeId) return;
60
- let n = I.transactionId || P?.paymentId || P?.orderId || _ || A || k, r = `${t.journeyId ?? "journey"}:${n}`;
61
- w.current !== r && (w.current = r, ce({
62
+ let n = F.transactionId || N?.paymentId || N?.orderId || g || D || E, r = `${t.journeyId ?? "journey"}:${n}`;
63
+ lt.current !== r && (lt.current = r, ce({
62
64
  journeyId: t.journeyId,
63
65
  codeId: t.codeId,
64
- eventType: k === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
65
- productSlug: rt,
66
- actorUserId: nt?.id,
67
- orderId: I.transactionId || P?.paymentId || P?.orderId,
68
- billingAccountId: I.billingAccountId,
69
- storeOrderId: k === "ORDER" ? _ : void 0,
70
- valueAmount: I.total,
71
- currency: I.currency,
66
+ eventType: E === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
67
+ productSlug: ct,
68
+ actorUserId: st?.id,
69
+ orderId: F.transactionId || N?.paymentId || N?.orderId,
70
+ billingAccountId: F.billingAccountId,
71
+ storeOrderId: E === "ORDER" ? g : void 0,
72
+ valueAmount: F.total,
73
+ currency: F.currency,
72
74
  mode: "billing-checkout",
73
75
  metadata: {
74
- purchaseType: k,
75
- billingAccountName: I.billingAccountName
76
+ purchaseType: E,
77
+ billingAccountName: F.billingAccountName
76
78
  }
77
79
  }, {
78
- apiGatewayUrl: et,
79
- authToken: tt,
80
- orgId: S
80
+ apiGatewayUrl: at,
81
+ authToken: ot,
82
+ orgId: b
81
83
  }).catch(() => {
82
- w.current = null;
84
+ lt.current = null;
83
85
  }));
84
86
  }, [
85
- et,
86
- tt,
87
- nt?.id,
88
- A,
89
- M,
90
- S,
91
- P?.orderId,
92
- P?.paymentId,
93
- rt,
94
- I,
95
- k,
96
- _
87
+ at,
88
+ ot,
89
+ st?.id,
90
+ D,
91
+ j,
92
+ b,
93
+ N?.orderId,
94
+ N?.paymentId,
95
+ ct,
96
+ F,
97
+ E,
98
+ g
97
99
  ]);
98
- let [L, R] = u(1), z = le({
100
+ let [I, L] = u(1), R = le({
99
101
  defaultCurrency: "USD",
100
- upgradeFromSubscriptionId: b?.upgradeFromSubscriptionId,
101
- downgradeFromSubscriptionId: b?.downgradeFromSubscriptionId
102
- }), { config: yt, stripeEnabled: bt, razorpayEnabled: B } = fe(), { elapsedTime: V, error: xt } = pe({
103
- paymentId: M === "processing" ? P?.paymentId ?? null : null,
104
- billingAccountId: z.billingAccount?.id ?? I?.billingAccountId ?? null,
105
- paymentType: _t,
102
+ upgradeFromSubscriptionId: v?.upgradeFromSubscriptionId,
103
+ downgradeFromSubscriptionId: v?.downgradeFromSubscriptionId
104
+ }), { config: Ct, stripeEnabled: wt, razorpayEnabled: Tt } = fe(), { elapsedTime: Et, error: Dt } = pe({
105
+ paymentId: j === "processing" ? N?.paymentId ?? null : null,
106
+ billingAccountId: R.billingAccount?.id ?? F?.billingAccountId ?? null,
107
+ paymentType: xt,
106
108
  pollingInterval: 5e3,
107
109
  maxPollingTime: 3e5,
108
110
  onSuccess: (e) => {
109
- if (e.transactionId && gt((t) => t && {
111
+ if (e.transactionId && bt((t) => t && {
110
112
  ...t,
111
113
  transactionId: e.transactionId
112
- }), N("success"), D && at(), (k === "PLAN" || k === "ADDON") && C) {
113
- let e = (H?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && De(e.quota.name)).map((e) => {
114
+ }), M("success"), w && dt(), (E === "PLAN" || E === "ADDON") && x) {
115
+ let e = (z?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && Ae(e.quota.name)).map((e) => {
114
116
  let t = e.quota?.limits, n = t && "value" in t ? Number(t.value) : null, r = t && "type" in t ? String(t.type) : "number";
115
117
  return {
116
118
  quotaName: e.quota.name,
117
- productId: H?.getPlan?.context?.productId ?? "platform",
119
+ productId: z?.getPlan?.context?.productId ?? "platform",
118
120
  limit: r === "number" ? n : null,
119
121
  noLimit: r !== "number",
120
122
  resetPeriod: "NEVER",
121
123
  quotaMode: "dedicated"
122
124
  };
123
125
  });
124
- e.length > 0 && (dt(e), jt().then((e) => {
125
- let t = e.data?.getActiveSubscriptions?.find((e) => e.planId === A);
126
- t && pt(t.id);
127
- }), (it.length === 1 || it.length > 1) && j(!0));
126
+ e.length > 0 && (ht(e), Vt().then((e) => {
127
+ let t = e.data?.getActiveSubscriptions?.find((e) => e.planId === D);
128
+ t && _t(t.id);
129
+ }), (ut.length === 1 || ut.length > 1) && A(!0));
128
130
  }
129
131
  },
130
132
  onFailure: (e) => {
131
- F(e.failureReason || "Payment failed"), N("error");
133
+ P(e.failureReason || "Payment failed"), M("error");
132
134
  },
133
135
  onTimeout: () => {
134
- F("Payment verification timed out. Please check your billing history for the payment status."), N("error");
136
+ P("Payment verification timed out. Please check your billing history for the payment status."), M("error");
135
137
  }
136
- }), { data: St, loading: Ct, refetch: wt } = ee({}), { data: H, loading: Tt } = re({
137
- variables: { id: A },
138
- skip: k !== "PLAN" || !A
139
- }), { data: U, loading: Et } = ie({
140
- variables: { addonIDs: A ? [A] : [] },
141
- skip: k !== "ADDON" || !A || O
142
- }), { data: W } = ae({
143
- variables: { id: _ },
144
- skip: !O || !_
145
- }), { data: Dt, loading: Ot } = ne({
146
- variables: { billingAccountId: z.billingAccount?.id },
147
- skip: !z.billingAccount?.id
148
- }), { data: kt, loading: At, refetch: jt } = o({
149
- variables: { billingAccountId: z.billingAccount?.id },
150
- skip: !z.billingAccount?.id || k !== "ADDON" && k !== "PLAN" || O
151
- }), G = l(() => kt?.getActiveSubscriptions ?? [], [kt]), K = l(() => !z.selectedSubscriptionId || G.length === 0 ? null : G.find((e) => e.id === z.selectedSubscriptionId) ?? null, [z.selectedSubscriptionId, G]), q = z.items[0]?.type === "CREDITS" ? z.items[0].quantity : 100, { data: Mt, loading: Nt } = te({
138
+ }), { data: Ot, loading: kt, refetch: At } = ee({}), { data: z, loading: jt } = re({
139
+ variables: { id: D },
140
+ skip: E !== "PLAN" || !D
141
+ }), { data: B, loading: Mt } = ie({
142
+ variables: { addonIDs: D ? [D] : [] },
143
+ skip: E !== "ADDON" || !D || T
144
+ }), { data: V } = ae({
145
+ variables: { id: g },
146
+ skip: !T || !g
147
+ }), Nt = l(() => {
148
+ let e = V?.getStoreOrder?.lineItems;
149
+ return Array.isArray(e) ? e : [];
150
+ }, [V]), H = T && Nt.some((e) => String(e.itemType).toUpperCase() === "PHYSICAL"), Pt = Me(V?.getStoreOrder?.currency), [U, Ft] = u({
151
+ shippingAddressId: null,
152
+ shippingMethodId: null,
153
+ shippingCost: 0,
154
+ destinationCountry: null
155
+ }), [It] = De(), { data: Lt, loading: Rt } = ne({
156
+ variables: { billingAccountId: R.billingAccount?.id },
157
+ skip: !R.billingAccount?.id
158
+ }), { data: zt, loading: Bt, refetch: Vt } = o({
159
+ variables: { billingAccountId: R.billingAccount?.id },
160
+ skip: !R.billingAccount?.id || E !== "ADDON" && E !== "PLAN" || T
161
+ }), W = l(() => zt?.getActiveSubscriptions ?? [], [zt]), G = l(() => !R.selectedSubscriptionId || W.length === 0 ? null : W.find((e) => e.id === R.selectedSubscriptionId) ?? null, [R.selectedSubscriptionId, W]), K = R.items[0]?.type === "CREDITS" ? R.items[0].quantity : 100, { data: Ht, loading: Ut } = te({
152
162
  variables: {
153
- creditAmount: q,
154
- currency: z.selectedCurrency || "USD"
163
+ creditAmount: K,
164
+ currency: R.selectedCurrency || "USD"
155
165
  },
156
- skip: k !== "CREDITS"
157
- }), J = l(() => Mt?.getCostOfCredits?.amount && q > 0 ? Mt.getCostOfCredits.amount / q : .01, [Mt, q]), Y = l(() => Dt?.getPaymentMethods ?? [], [Dt]), X = l(() => St?.getBillingAccountsByOrg ?? [], [St]), Z = l(() => {
158
- if (!z.billingAccount) return;
159
- let e = X.find((e) => e.id === z.billingAccount?.id)?.billingAddresses;
166
+ skip: E !== "CREDITS"
167
+ }), q = l(() => Ht?.getCostOfCredits?.amount && K > 0 ? Ht.getCostOfCredits.amount / K : .01, [Ht, K]), J = l(() => Lt?.getPaymentMethods ?? [], [Lt]), Y = l(() => Ot?.myBillingAccounts ?? [], [Ot]), X = l(() => {
168
+ if (!R.billingAccount) return;
169
+ let e = Y.find((e) => e.id === R.billingAccount?.id)?.billingAddresses;
160
170
  if (e && e.length > 0) return e[0]?.country || void 0;
161
- }, [z.billingAccount, X]), [Pt, Ft] = u(null);
171
+ }, [R.billingAccount, Y]), [Wt, Gt] = u(null);
162
172
  c(() => {
163
- if (Z) if (Z === "IN") z.selectedCurrency !== "INR" && z.setCurrency("INR"), B && Pt !== Z && z.selectedProvider !== "CREDITS" && (z.setPaymentProvider("RAZORPAY"), Ft(Z));
173
+ if (X) if (X === "IN") R.selectedCurrency !== "INR" && R.setCurrency("INR"), Tt && Wt !== X && R.selectedProvider !== "CREDITS" && (R.setPaymentProvider("RAZORPAY"), Gt(X));
164
174
  else {
165
- if (z.selectedCurrency === "INR") {
166
- let e = z.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
167
- z.setCurrency(t);
175
+ if (R.selectedCurrency === "INR") {
176
+ let e = R.billingAccount?.currency, t = e && e !== "INR" ? e : "USD";
177
+ R.setCurrency(t);
168
178
  }
169
- z.selectedProvider === "RAZORPAY" && (z.setPaymentProvider("STRIPE"), Ft(Z));
179
+ R.selectedProvider === "RAZORPAY" && (R.setPaymentProvider("STRIPE"), Gt(X));
170
180
  }
171
181
  }, [
172
- Z,
173
- z.selectedCurrency,
174
- z.selectedProvider,
175
- z.setCurrency,
176
- z.setPaymentProvider,
177
- z.billingAccount?.currency,
178
- B,
179
- Pt
182
+ X,
183
+ R.selectedCurrency,
184
+ R.selectedProvider,
185
+ R.setCurrency,
186
+ R.setPaymentProvider,
187
+ R.billingAccount?.currency,
188
+ Tt,
189
+ Wt
180
190
  ]), c(() => {
181
- if (!z.billingAccount?.currency || Z === "IN") return;
182
- let e = z.billingAccount.currency;
183
- e !== "INR" && z.selectedCurrency !== e && z.setCurrency(e);
191
+ if (!R.billingAccount?.currency || X === "IN") return;
192
+ let e = R.billingAccount.currency;
193
+ e !== "INR" && R.selectedCurrency !== e && R.setCurrency(e);
184
194
  }, [
185
- z.billingAccount?.id,
186
- z.billingAccount?.currency,
187
- Z,
188
- z.selectedCurrency,
189
- z.setCurrency
195
+ R.billingAccount?.id,
196
+ R.billingAccount?.currency,
197
+ X,
198
+ R.selectedCurrency,
199
+ R.setCurrency
190
200
  ]), c(() => {
191
- if (z.selectedProvider !== "AUTO" && z.selectedProvider !== null) return;
192
- let e = z.availableCredits >= z.total;
193
- if (z.canPayWithCredits && e) {
194
- z.setPaymentProvider("CREDITS"), z.setSelectedPaymentMethodId(null);
201
+ if (R.selectedProvider !== "AUTO" && R.selectedProvider !== null) return;
202
+ let e = R.availableCredits >= R.total;
203
+ if (R.canPayWithCredits && e) {
204
+ R.setPaymentProvider("CREDITS"), R.setSelectedPaymentMethodId(null);
195
205
  return;
196
206
  }
197
- if (Y.length > 0 && !z.selectedPaymentMethodId) {
198
- let e = Y.find((e) => e.isDefault && e.isVerified), t = Y.find((e) => e.isVerified), n = e || t;
207
+ if (J.length > 0 && !R.selectedPaymentMethodId) {
208
+ let e = J.find((e) => e.isDefault && e.isVerified), t = J.find((e) => e.isVerified), n = e || t;
199
209
  if (n) {
200
- z.setSelectedPaymentMethodId(n.id), n.razorpayPaymentMethodId ? z.setPaymentProvider("RAZORPAY") : n.stripePaymentMethodId && z.setPaymentProvider("STRIPE");
210
+ R.setSelectedPaymentMethodId(n.id), n.razorpayPaymentMethodId ? R.setPaymentProvider("RAZORPAY") : n.stripePaymentMethodId && R.setPaymentProvider("STRIPE");
201
211
  return;
202
212
  }
203
213
  }
204
214
  }, [
205
- Y.length,
206
- z.canPayWithCredits,
207
- z.availableCredits,
208
- z.total
215
+ J.length,
216
+ R.canPayWithCredits,
217
+ R.availableCredits,
218
+ R.total
209
219
  ]);
210
- let [Q, $] = u(!1);
220
+ let [Z, Q] = u(!1);
211
221
  c(() => {
212
- if (!O || Q || !W?.getStoreOrder) return;
213
- let e = ke(W.getStoreOrder.currency);
214
- z.selectedCurrency !== e && z.setCurrency(e);
222
+ if (!T || Z || !V?.getStoreOrder) return;
223
+ let e = Me(V.getStoreOrder.currency);
224
+ R.selectedCurrency !== e && R.setCurrency(e);
215
225
  }, [
216
- O,
217
- Q,
218
- W,
219
- z.selectedCurrency,
220
- z.setCurrency
226
+ T,
227
+ Z,
228
+ V,
229
+ R.selectedCurrency,
230
+ R.setCurrency
221
231
  ]), c(() => {
222
- if (k === "PLAN" && H?.getPlan?.pricingModel === "PER_SEAT") {
223
- let e = H.getPlan.minSeats ?? 1;
224
- R((t) => t < e ? e : t);
232
+ if (E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT") {
233
+ let e = z.getPlan.minSeats ?? 1;
234
+ L((t) => t < e ? e : t);
225
235
  }
226
- }, [H, k]), c(() => {
227
- k === "PLAN" && H?.getPlan?.pricingModel === "PER_SEAT" && Q && $(!1);
228
- }, [L]), c(() => {
229
- if (!Q) {
230
- if (D && E && T.length > 0) {
231
- z.clearItems();
232
- for (let e of T) {
236
+ }, [z, E]), c(() => {
237
+ E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT" && Z && Q(!1);
238
+ }, [I]), c(() => {
239
+ if (!Z) {
240
+ if (w && C && S.length > 0) {
241
+ R.clearItems();
242
+ for (let e of S) {
233
243
  let t = e.addon, n = t.features?.map((e) => ({
234
244
  id: e.quota?.id || e.id,
235
245
  name: e.quota?.name || "Feature",
236
246
  limits: e.quota?.limits
237
- })) || [], r = z.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
247
+ })) || [], r = R.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
238
248
  id: t.id,
239
249
  type: "ADDON",
240
250
  name: t.name,
@@ -246,25 +256,25 @@ var Ye = () => {
246
256
  features: n,
247
257
  metadata: { addonId: t.id }
248
258
  };
249
- z.addItem(a);
259
+ R.addItem(a);
250
260
  }
251
- $(!0);
261
+ Q(!0);
252
262
  return;
253
263
  }
254
- if (k === "PLAN" && H?.getPlan) {
255
- let e = H.getPlan, t = e.features?.map((e) => ({
264
+ if (E === "PLAN" && z?.getPlan) {
265
+ let e = z.getPlan, t = e.features?.map((e) => ({
256
266
  id: e.quota?.id || e.id,
257
267
  name: e.quota?.name || "Feature",
258
268
  limits: e.quota?.limits
259
- })) || [], n = z.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
269
+ })) || [], n = R.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
260
270
  if (i && e.pricePerSeat) {
261
271
  let t = r?.[n];
262
- a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * L;
272
+ a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * I;
263
273
  } else {
264
274
  let t = r?.[n];
265
275
  a = typeof t == "number" ? t : e.price;
266
276
  }
267
- let o = i ? L : 1, ee = {
277
+ let o = i ? I : 1, ee = {
268
278
  id: e.id,
269
279
  type: "PLAN",
270
280
  name: e.name,
@@ -280,13 +290,13 @@ var Ye = () => {
280
290
  seatCount: i ? o : void 0
281
291
  }
282
292
  };
283
- z.addItem(ee), $(!0);
284
- } else if (k === "ADDON" && !D && U?.getSelectedAddons?.[0]) {
285
- let e = U.getSelectedAddons[0], t = e.features?.map((e) => ({
293
+ R.addItem(ee), Q(!0);
294
+ } else if (E === "ADDON" && !w && B?.getSelectedAddons?.[0]) {
295
+ let e = B.getSelectedAddons[0], t = e.features?.map((e) => ({
286
296
  id: e.quota?.id || e.id,
287
297
  name: e.quota?.name || "Feature",
288
298
  limits: e.quota?.limits
289
- })) || [], n = z.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
299
+ })) || [], n = R.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
290
300
  id: e.id,
291
301
  type: "ADDON",
292
302
  name: e.name,
@@ -294,184 +304,229 @@ var Ye = () => {
294
304
  price: r,
295
305
  priceUSD: e.price,
296
306
  currency: n,
297
- quantity: b?.quantity ?? 1,
307
+ quantity: v?.quantity ?? 1,
298
308
  features: t,
299
309
  metadata: { addonId: e.id }
300
310
  };
301
- z.addItem(i), $(!0);
302
- } else if (O && W?.getStoreOrder) {
303
- let e = W.getStoreOrder, t = Oe(e);
304
- for (let e of t) z.addItem(e);
305
- $(!0);
306
- } else if (k === "CREDITS") {
311
+ R.addItem(i), Q(!0);
312
+ } else if (T && V?.getStoreOrder) {
313
+ let e = V.getStoreOrder, t = je(e);
314
+ for (let e of t) R.addItem(e);
315
+ Q(!0);
316
+ } else if (E === "CREDITS") {
307
317
  let e = {
308
318
  id: "credits-purchase",
309
319
  type: "CREDITS",
310
320
  name: "Credits",
311
321
  description: "Purchase credits for your account",
312
- price: J,
313
- currency: z.selectedCurrency || "USD",
322
+ price: q,
323
+ currency: R.selectedCurrency || "USD",
314
324
  quantity: 100
315
325
  };
316
- z.addItem(e), $(!0);
326
+ R.addItem(e), Q(!0);
317
327
  }
318
328
  }
319
329
  }, [
320
- k,
321
- H,
322
- U,
323
- W,
324
- z.addItem,
325
- z.clearItems,
326
- b?.quantity,
327
- Q,
328
- D,
329
- O,
330
- T,
331
330
  E,
332
- J,
333
- z.selectedCurrency
331
+ z,
332
+ B,
333
+ V,
334
+ R.addItem,
335
+ R.clearItems,
336
+ v?.quantity,
337
+ Z,
338
+ w,
339
+ T,
340
+ S,
341
+ C,
342
+ q,
343
+ R.selectedCurrency
334
344
  ]), c(() => {
335
- if (!(!O || !Q || z.conversionRate <= 1)) {
336
- for (let e of z.items) if (e.type === "ORDER" && e.currency !== z.selectedCurrency) {
337
- let t = e.price * z.conversionRate;
338
- z.updateItemPrice(e.id, t, z.selectedCurrency);
345
+ if (!(!T || !Z || R.conversionRate <= 1)) {
346
+ for (let e of R.items) if (e.type === "ORDER" && e.currency !== R.selectedCurrency) {
347
+ let t = e.price * R.conversionRate;
348
+ R.updateItemPrice(e.id, t, R.selectedCurrency);
339
349
  }
340
350
  }
341
351
  }, [
342
- O,
343
- Q,
344
- z.conversionRate,
345
- z.selectedCurrency,
346
- z.updateItemPrice
352
+ T,
353
+ Z,
354
+ R.conversionRate,
355
+ R.selectedCurrency,
356
+ R.updateItemPrice
357
+ ]);
358
+ let $ = Ne(null);
359
+ c(() => {
360
+ if (H) if (U.shippingCost > 0) {
361
+ let e = R.selectedCurrency, t = Pt !== e && R.conversionRate > 1 ? U.shippingCost * R.conversionRate : U.shippingCost, n = $.current;
362
+ if (n && n.price === t && n.currency === e) return;
363
+ n === null ? R.addItem({
364
+ id: Ee,
365
+ type: "ORDER",
366
+ name: "Shipping",
367
+ price: t,
368
+ currency: e,
369
+ quantity: 1,
370
+ metadata: {
371
+ storeOrderId: g,
372
+ isShipping: !0
373
+ }
374
+ }) : R.updateItemPrice(Ee, t, e), $.current = {
375
+ price: t,
376
+ currency: e
377
+ };
378
+ } else $.current !== null && ($.current = null, R.removeItem(Ee));
379
+ }, [
380
+ H,
381
+ U.shippingCost,
382
+ Pt,
383
+ R.selectedCurrency,
384
+ R.conversionRate,
385
+ g,
386
+ R.addItem,
387
+ R.updateItemPrice,
388
+ R.removeItem
347
389
  ]), c(() => {
348
- if (k === "CREDITS" && Q && J > 0) {
349
- let e = z.items.find((e) => e.id === "credits-purchase");
350
- e && e.price !== J && z.updateItemPrice("credits-purchase", J);
390
+ if (E === "CREDITS" && Z && q > 0) {
391
+ let e = R.items.find((e) => e.id === "credits-purchase");
392
+ e && e.price !== q && R.updateItemPrice("credits-purchase", q);
351
393
  }
352
394
  }, [
353
- k,
354
- Q,
355
- J,
356
- z.items,
357
- z.updateItemPrice
395
+ E,
396
+ Z,
397
+ q,
398
+ R.items,
399
+ R.updateItemPrice
358
400
  ]), c(() => {
359
- if (!Q || z.items.length === 0) return;
360
- let e = z.selectedCurrency || "USD";
361
- for (let t of z.items) if (t.type === "PLAN" && H?.getPlan) {
362
- let n = H.getPlan.currencyPrices?.[e] ?? H.getPlan.price;
363
- (t.price !== n || t.currency !== e) && z.updateItemPrice(t.id, n, e);
401
+ if (!Z || R.items.length === 0) return;
402
+ let e = R.selectedCurrency || "USD";
403
+ for (let t of R.items) if (t.type === "PLAN" && z?.getPlan) {
404
+ let n = z.getPlan.currencyPrices?.[e] ?? z.getPlan.price;
405
+ (t.price !== n || t.currency !== e) && R.updateItemPrice(t.id, n, e);
364
406
  } else if (t.type === "ADDON") {
365
- if (!D && U?.getSelectedAddons?.[0]) {
366
- let n = U.getSelectedAddons[0], r = n.currencyPrices?.[e] ?? n.price;
367
- (t.price !== r || t.currency !== e) && z.updateItemPrice(t.id, r, e);
407
+ if (!w && B?.getSelectedAddons?.[0]) {
408
+ let n = B.getSelectedAddons[0], r = n.currencyPrices?.[e] ?? n.price;
409
+ (t.price !== r || t.currency !== e) && R.updateItemPrice(t.id, r, e);
368
410
  }
369
- if (D) {
370
- let n = T.find((e) => e.addon.id === t.id);
411
+ if (w) {
412
+ let n = S.find((e) => e.addon.id === t.id);
371
413
  if (n) {
372
414
  let r = n.addon.currencyPrices?.[e] ?? n.addon.price;
373
- (t.price !== r || t.currency !== e) && z.updateItemPrice(t.id, r, e);
415
+ (t.price !== r || t.currency !== e) && R.updateItemPrice(t.id, r, e);
374
416
  }
375
417
  }
376
418
  }
377
419
  }, [
378
- z.selectedCurrency,
379
- Q,
380
- z.items,
381
- z.updateItemPrice,
382
- H,
383
- U,
384
- T,
385
- D
420
+ R.selectedCurrency,
421
+ Z,
422
+ R.items,
423
+ R.updateItemPrice,
424
+ z,
425
+ B,
426
+ S,
427
+ w
386
428
  ]), c(() => {
387
- if (X.length > 0 && !z.billingAccount) {
388
- if (b?.billingAccountId) {
389
- let e = X.find((e) => e.id === b.billingAccountId);
429
+ if (Y.length > 0 && !R.billingAccount) {
430
+ if (v?.billingAccountId) {
431
+ let e = Y.find((e) => e.id === v.billingAccountId);
390
432
  if (e) {
391
- z.setBillingAccount(e);
433
+ R.setBillingAccount(e);
392
434
  return;
393
435
  }
394
436
  }
395
- if (S) {
396
- let e = i(S);
437
+ if (b) {
438
+ let e = i(b);
397
439
  if (e) {
398
- let t = X.find((t) => t.id === e);
440
+ let t = Y.find((t) => t.id === e);
399
441
  if (t) {
400
- z.setBillingAccount(t);
442
+ R.setBillingAccount(t);
401
443
  return;
402
444
  }
403
445
  }
404
446
  }
405
- z.setBillingAccount(X[0]);
447
+ R.setBillingAccount(Y[0]);
406
448
  }
407
449
  }, [
408
- X,
409
- z.billingAccount,
410
- z.setBillingAccount,
411
- b?.billingAccountId,
412
- S
450
+ Y,
451
+ R.billingAccount,
452
+ R.setBillingAccount,
453
+ v?.billingAccountId,
454
+ b
413
455
  ]);
414
- let It = !!(b?.upgradeFromSubscriptionId || b?.downgradeFromSubscriptionId);
456
+ let Kt = !!(v?.upgradeFromSubscriptionId || v?.downgradeFromSubscriptionId);
415
457
  c(() => {
416
- D && E && T.length === 0 && !Q && v("/addons", { replace: !0 });
458
+ w && C && S.length === 0 && !Z && _("/addons", { replace: !0 });
417
459
  }, [
418
- E,
419
- T.length,
420
- D,
421
- Q,
422
- v
460
+ C,
461
+ S.length,
462
+ w,
463
+ Z,
464
+ _
423
465
  ]);
424
- let Lt = de({
425
- billingAccountId: z.billingAccount?.id,
426
- purchaseType: k,
427
- productId: A
428
- }), Rt = s(async () => {
429
- if (!z.billingAccount) return;
430
- let e = ct.current;
431
- if (ct.current = !1, !e && !Te(z.billingAccount)) {
432
- st(!0);
466
+ let qt = de({
467
+ billingAccountId: R.billingAccount?.id,
468
+ purchaseType: E,
469
+ productId: D
470
+ }), Jt = s(async () => {
471
+ if (!R.billingAccount) return;
472
+ let e = k.current;
473
+ if (k.current = !1, !e && !Te(R.billingAccount)) {
474
+ O(!0);
433
475
  return;
434
476
  }
435
- F(null);
436
- let t = z.billingAccount.creditAmount ?? 0, n = [...z.items], r = z.total, i = await z.initiatePayment();
477
+ if (P(null), H) try {
478
+ let e = (await It({ variables: { input: {
479
+ orderId: g,
480
+ shippingMethodId: U.shippingMethodId,
481
+ ...U.shippingAddressId ? { shippingAddressId: U.shippingAddressId } : {}
482
+ } } })).data?.setStoreOrderShipping?.shippingCost;
483
+ typeof e == "number" && e !== U.shippingCost && Ft((t) => ({
484
+ ...t,
485
+ shippingCost: e
486
+ }));
487
+ } catch {
488
+ P("Could not save your shipping details. Please review your delivery address and try again."), M("error");
489
+ return;
490
+ }
491
+ let t = R.billingAccount.creditAmount ?? 0, n = [...R.items], r = R.total, i = await R.initiatePayment();
437
492
  if (i.success) {
438
- if (x("billing.checkout.initiated", {
493
+ if (y("billing.checkout.initiated", {
439
494
  route: "/billing/checkout",
440
495
  entityId: i.paymentId ?? i.orderId,
441
496
  source: "checkout",
442
497
  amount: i.total || r,
443
- currency: i.currency || z.selectedCurrency
444
- }), z.selectedProvider === "CREDITS") {
445
- x("billing.credits.spent", {
498
+ currency: i.currency || R.selectedCurrency
499
+ }), R.selectedProvider === "CREDITS") {
500
+ y("billing.credits.spent", {
446
501
  route: "/billing/checkout",
447
502
  entityId: i.orderId,
448
503
  source: "checkout",
449
504
  amount: r,
450
505
  currency: "CREDITS"
451
- }), gt({
506
+ }), bt({
452
507
  items: n,
453
508
  total: r,
454
- billingAccountName: z.billingAccount.name,
455
- billingAccountId: z.billingAccount.id,
509
+ billingAccountName: R.billingAccount.name,
510
+ billingAccountId: R.billingAccount.id,
456
511
  previousBalance: t,
457
512
  newBalance: t - r,
458
513
  paymentMethod: "credits",
459
514
  currency: "Credits",
460
515
  transactionId: i.orderId
461
- }), vt("credits"), mt({ paymentId: i.orderId }), N("processing");
516
+ }), St("credits"), vt({ paymentId: i.orderId }), M("processing");
462
517
  return;
463
518
  }
464
- gt({
519
+ bt({
465
520
  items: n,
466
521
  total: i.total || r,
467
- billingAccountName: z.billingAccount.name,
468
- billingAccountId: z.billingAccount.id,
522
+ billingAccountName: R.billingAccount.name,
523
+ billingAccountId: R.billingAccount.id,
469
524
  previousBalance: t,
470
525
  newBalance: t,
471
526
  paymentMethod: "card",
472
- currency: i.currency || z.selectedCurrency,
527
+ currency: i.currency || R.selectedCurrency,
473
528
  transactionId: i.paymentId
474
- }), vt("card"), mt({
529
+ }), St("card"), vt({
475
530
  clientSecret: i.clientSecret,
476
531
  orderId: i.orderId,
477
532
  razorpayKeyId: i.razorpayKeyId,
@@ -483,66 +538,73 @@ var Ye = () => {
483
538
  prefillContact: i.prefillContact,
484
539
  total: i.total,
485
540
  currency: i.currency
486
- }), i.paymentComplete ? N("processing") : N("payment");
487
- } else x("billing.checkout.failed", {
541
+ }), i.paymentComplete ? M("processing") : M("payment");
542
+ } else y("billing.checkout.failed", {
488
543
  route: "/billing/checkout",
489
544
  source: "checkout",
490
545
  reason: i.error || "Payment initiation failed"
491
- }), F(i.error || "Payment initiation failed"), N("error");
492
- }, [z, x]), zt = s((e) => {
493
- x("billing.payment.succeeded", {
546
+ }), P(i.error || "Payment initiation failed"), M("error");
547
+ }, [
548
+ R,
549
+ y,
550
+ H,
551
+ U,
552
+ g,
553
+ It
554
+ ]), Yt = s((e) => {
555
+ y("billing.payment.succeeded", {
494
556
  route: "/billing/checkout",
495
- entityId: P?.paymentId ?? P?.orderId,
557
+ entityId: N?.paymentId ?? N?.orderId,
496
558
  source: "checkout"
497
- }), mt((e) => e), N("processing");
559
+ }), vt((e) => e), M("processing");
498
560
  }, [
499
- x,
500
- P?.orderId,
501
- P?.paymentId
502
- ]), Bt = s((e) => {
503
- x("billing.payment.failed", {
561
+ y,
562
+ N?.orderId,
563
+ N?.paymentId
564
+ ]), Xt = s((e) => {
565
+ y("billing.payment.failed", {
504
566
  route: "/billing/checkout",
505
- entityId: P?.paymentId ?? P?.orderId,
567
+ entityId: N?.paymentId ?? N?.orderId,
506
568
  source: "checkout",
507
569
  reason: e
508
- }), F(e), N("error");
570
+ }), P(e), M("error");
509
571
  }, [
510
- x,
511
- P?.orderId,
512
- P?.paymentId
513
- ]), Vt = s((e) => {
514
- z.updateItemQuantity("credits-purchase", e);
515
- }, [z]);
516
- if (!Ze.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
572
+ y,
573
+ N?.orderId,
574
+ N?.paymentId
575
+ ]), Zt = s((e) => {
576
+ R.updateItemQuantity("credits-purchase", e);
577
+ }, [R]);
578
+ if (!nt.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
517
579
  if (ue()) return /* @__PURE__ */ p(me, {
518
- purchaseType: k,
519
- productId: A,
520
- billingAccountId: z.billingAccount?.id,
521
- nativeCheckout: Lt,
522
- onBack: () => v("dashboard")
580
+ purchaseType: E,
581
+ productId: D,
582
+ billingAccountId: R.billingAccount?.id,
583
+ nativeCheckout: qt,
584
+ onBack: () => _("dashboard")
523
585
  });
524
- let Ht = Ct || Tt && k === "PLAN" || Et && k === "ADDON" && !D || D && !E;
525
- if (D && E && T.length === 0 && !Q) return null;
526
- let Ut = () => {
527
- if (D) {
528
- let e = z.items.length;
586
+ let Qt = kt || jt && E === "PLAN" || Mt && E === "ADDON" && !w || w && !C;
587
+ if (w && C && S.length === 0 && !Z) return null;
588
+ let $t = () => {
589
+ if (w) {
590
+ let e = R.items.length;
529
591
  return `Purchase ${e} Add-on${e === 1 ? "" : "s"}`;
530
592
  }
531
- switch (k) {
593
+ switch (E) {
532
594
  case "CREDITS": return "Buy Credits";
533
595
  case "PLAN": return "Subscribe to Plan";
534
596
  case "ADDON": return "Purchase Add-on";
535
597
  default: return "Checkout";
536
598
  }
537
- }, Wt = () => {
538
- switch (k) {
539
- case "CREDITS": return /* @__PURE__ */ p(Fe, { className: "size-6" });
540
- case "PLAN": return /* @__PURE__ */ p(Le, { className: "size-6" });
541
- case "ADDON": return /* @__PURE__ */ p(Ne, { className: "size-6" });
542
- default: return /* @__PURE__ */ p(Be, { className: "size-6" });
599
+ }, en = () => {
600
+ switch (E) {
601
+ case "CREDITS": return /* @__PURE__ */ p(Re, { className: "size-6" });
602
+ case "PLAN": return /* @__PURE__ */ p(Be, { className: "size-6" });
603
+ case "ADDON": return /* @__PURE__ */ p(Ie, { className: "size-6" });
604
+ default: return /* @__PURE__ */ p(Ue, { className: "size-6" });
543
605
  }
544
606
  };
545
- if (Ht) return /* @__PURE__ */ p("div", {
607
+ if (Qt) return /* @__PURE__ */ p("div", {
546
608
  className: "flex items-center justify-center min-h-[400px]",
547
609
  children: /* @__PURE__ */ m("div", {
548
610
  className: "text-center space-y-4",
@@ -552,10 +614,10 @@ var Ye = () => {
552
614
  })]
553
615
  })
554
616
  });
555
- if (M === "success") {
617
+ if (j === "success") {
556
618
  let e = (e) => {
557
- if (!I) return `${e.toFixed(2)}`;
558
- let t = I.currency;
619
+ if (!F) return `${e.toFixed(2)}`;
620
+ let t = F.currency;
559
621
  return t === "Credits" ? `${e.toFixed(2)} Credits` : `${{
560
622
  INR: "₹",
561
623
  USD: "$",
@@ -570,7 +632,7 @@ var Ye = () => {
570
632
  className: "text-center space-y-4",
571
633
  children: [/* @__PURE__ */ p("div", {
572
634
  className: "inline-flex p-4 rounded-full bg-status-success-bg-subtle text-status-success-text",
573
- children: /* @__PURE__ */ p(Pe, { className: "size-12" })
635
+ children: /* @__PURE__ */ p(Le, { className: "size-12" })
574
636
  }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
575
637
  className: "text-2xl font-bold text-text-primary",
576
638
  children: h("billing.checkout.paymentSuccessful", "Payment Successful!")
@@ -579,25 +641,25 @@ var Ye = () => {
579
641
  children: h("billing.checkout.purchaseCompleted", "Your purchase has been completed successfully.")
580
642
  })] })]
581
643
  }),
582
- I && /* @__PURE__ */ m("div", {
644
+ F && /* @__PURE__ */ m("div", {
583
645
  className: "bg-bg-surface border border-border-subtle rounded-lg overflow-hidden",
584
646
  children: [
585
647
  /* @__PURE__ */ m("div", {
586
648
  className: "p-4 border-b border-border-subtle",
587
649
  children: [/* @__PURE__ */ m("h3", {
588
650
  className: "font-semibold text-text-primary mb-3 flex items-center gap-2",
589
- children: [/* @__PURE__ */ p(Re, { className: "size-4" }), h("billing.checkout.itemsPurchased", "Items Purchased")]
651
+ children: [/* @__PURE__ */ p(Ve, { className: "size-4" }), h("billing.checkout.itemsPurchased", "Items Purchased")]
590
652
  }), /* @__PURE__ */ p("div", {
591
653
  className: "space-y-2",
592
- children: I.items.map((t) => /* @__PURE__ */ m("div", {
654
+ children: F.items.map((t) => /* @__PURE__ */ m("div", {
593
655
  className: "flex items-center justify-between",
594
656
  children: [/* @__PURE__ */ m("div", {
595
657
  className: "flex items-center gap-2",
596
658
  children: [
597
- t.type === "PLAN" && /* @__PURE__ */ p(Le, { className: "size-4 text-accent-blue" }),
598
- t.type === "ADDON" && /* @__PURE__ */ p(Ne, { className: "size-4 text-accent-purple" }),
599
- t.type === "CREDITS" && /* @__PURE__ */ p(Fe, { className: "size-4 text-status-warning-text" }),
600
- t.type === "ORDER" && /* @__PURE__ */ p(Be, { className: "size-4 text-status-success-text" }),
659
+ t.type === "PLAN" && /* @__PURE__ */ p(Be, { className: "size-4 text-accent-blue" }),
660
+ t.type === "ADDON" && /* @__PURE__ */ p(Ie, { className: "size-4 text-accent-purple" }),
661
+ t.type === "CREDITS" && /* @__PURE__ */ p(Re, { className: "size-4 text-status-warning-text" }),
662
+ t.type === "ORDER" && /* @__PURE__ */ p(Ue, { className: "size-4 text-status-success-text" }),
601
663
  /* @__PURE__ */ p("span", {
602
664
  className: "text-text-primary",
603
665
  children: t.name
@@ -623,10 +685,10 @@ var Ye = () => {
623
685
  children: h("billing.checkout.paymentMethod", "Payment Method")
624
686
  }), /* @__PURE__ */ p("div", {
625
687
  className: "flex items-center gap-2",
626
- children: I.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Ve, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
688
+ children: F.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(We, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
627
689
  className: "font-medium text-text-primary",
628
690
  children: h("billing.checkout.credits", "Credits")
629
- })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Ie, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
691
+ })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
630
692
  className: "font-medium text-text-primary",
631
693
  children: h("billing.checkout.card", "Card")
632
694
  })] })
@@ -637,16 +699,16 @@ var Ye = () => {
637
699
  children: h("billing.checkout.totalPaid", "Total Paid")
638
700
  }), /* @__PURE__ */ p("p", {
639
701
  className: "font-bold text-lg text-text-primary",
640
- children: e(I.total)
702
+ children: e(F.total)
641
703
  })]
642
704
  })]
643
705
  })
644
706
  }),
645
- I.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
707
+ F.paymentMethod === "credits" && /* @__PURE__ */ m("div", {
646
708
  className: "p-4 border-b border-border-subtle",
647
709
  children: [/* @__PURE__ */ m("h3", {
648
710
  className: "font-semibold text-text-primary mb-3 flex items-center gap-2",
649
- children: [/* @__PURE__ */ p(Ve, { className: "size-4" }), h("billing.checkout.creditBalance", "Credit Balance")]
711
+ children: [/* @__PURE__ */ p(We, { className: "size-4" }), h("billing.checkout.creditBalance", "Credit Balance")]
650
712
  }), /* @__PURE__ */ m("div", {
651
713
  className: "flex items-center gap-4",
652
714
  children: [
@@ -657,10 +719,10 @@ var Ye = () => {
657
719
  children: h("billing.checkout.previousBalance", "Previous Balance")
658
720
  }), /* @__PURE__ */ p("p", {
659
721
  className: "font-semibold text-text-primary",
660
- children: t(I.previousBalance)
722
+ children: t(F.previousBalance)
661
723
  })]
662
724
  }),
663
- /* @__PURE__ */ p(Me, { className: "size-5 text-text-secondary shrink-0" }),
725
+ /* @__PURE__ */ p(Fe, { className: "size-5 text-text-secondary shrink-0" }),
664
726
  /* @__PURE__ */ m("div", {
665
727
  className: "flex-1 text-center p-3 rounded-lg bg-status-success-bg-subtle",
666
728
  children: [/* @__PURE__ */ p("p", {
@@ -668,7 +730,7 @@ var Ye = () => {
668
730
  children: h("billing.checkout.newBalance", "New Balance")
669
731
  }), /* @__PURE__ */ p("p", {
670
732
  className: "font-semibold text-status-success-text",
671
- children: t(I.newBalance)
733
+ children: t(F.newBalance)
672
734
  })]
673
735
  })
674
736
  ]
@@ -683,15 +745,15 @@ var Ye = () => {
683
745
  children: h("billing.checkout.billingAccount", "Billing Account")
684
746
  }), /* @__PURE__ */ p("p", {
685
747
  className: "font-medium text-text-primary",
686
- children: I.billingAccountName
687
- })] }), I.transactionId && /* @__PURE__ */ m("div", {
748
+ children: F.billingAccountName
749
+ })] }), F.transactionId && /* @__PURE__ */ m("div", {
688
750
  className: "text-right",
689
751
  children: [/* @__PURE__ */ p("p", {
690
752
  className: "text-xs text-text-secondary mb-1",
691
753
  children: h("billing.checkout.transactionId", "Transaction ID")
692
754
  }), /* @__PURE__ */ m("p", {
693
755
  className: "font-mono text-xs text-text-secondary",
694
- children: [I.transactionId.slice(0, 8), "..."]
756
+ children: [F.transactionId.slice(0, 8), "..."]
695
757
  })]
696
758
  })]
697
759
  })
@@ -702,54 +764,54 @@ var Ye = () => {
702
764
  className: "flex flex-col sm:flex-row gap-3 justify-center pt-2",
703
765
  children: [/* @__PURE__ */ p("button", {
704
766
  type: "button",
705
- onClick: () => v("/overview"),
767
+ onClick: () => _("/overview"),
706
768
  className: "px-6 py-3 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-lg hover:bg-action-primary-bgHover transition-colors",
707
769
  children: h("billing.checkout.backToOverview", "Back to Overview")
708
770
  }), /* @__PURE__ */ p("button", {
709
771
  type: "button",
710
- onClick: () => v("/subscriptions"),
772
+ onClick: () => _("/subscriptions"),
711
773
  className: "px-6 py-3 text-sm font-medium border border-border-subtle text-text-primary rounded-lg hover:bg-bg-sunken transition-colors",
712
774
  children: h("billing.checkout.viewSubscriptions", "View Subscriptions")
713
775
  })]
714
776
  })
715
777
  ]
716
- }), lt && ut.length > 0 && C && ft && /* @__PURE__ */ p(Ee, {
717
- billingAccountId: I?.billingAccountId ?? "",
718
- subscriptionId: ft,
719
- quotas: ut,
720
- workspaces: it,
721
- currentWorkspaceId: C,
722
- onAssigned: () => j(!1),
723
- onSkip: () => j(!1)
778
+ }), pt && mt.length > 0 && x && gt && /* @__PURE__ */ p(ke, {
779
+ billingAccountId: F?.billingAccountId ?? "",
780
+ subscriptionId: gt,
781
+ quotas: mt,
782
+ workspaces: ut,
783
+ currentWorkspaceId: x,
784
+ onAssigned: () => A(!1),
785
+ onSkip: () => A(!1)
724
786
  })] });
725
787
  }
726
- if (M === "error") return /* @__PURE__ */ p("div", {
788
+ if (j === "error") return /* @__PURE__ */ p("div", {
727
789
  className: "max-w-lg mx-auto p-6",
728
790
  children: /* @__PURE__ */ m("div", {
729
791
  className: "text-center space-y-6",
730
792
  children: [
731
793
  /* @__PURE__ */ p("div", {
732
794
  className: "inline-flex p-4 rounded-full bg-status-error-bg-subtle text-status-error-text",
733
- children: /* @__PURE__ */ p(He, { className: "size-12" })
795
+ children: /* @__PURE__ */ p(Ge, { className: "size-12" })
734
796
  }),
735
797
  /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
736
798
  className: "text-2xl font-bold text-text-primary",
737
799
  children: h("billing.checkout.paymentFailed", "Payment Failed")
738
800
  }), /* @__PURE__ */ p("p", {
739
801
  className: "text-text-secondary mt-2",
740
- children: ht || xt || z.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
802
+ children: yt || Dt || R.error || h("billing.checkout.genericError", "Something went wrong. Please try again.")
741
803
  })] }),
742
804
  /* @__PURE__ */ m("div", {
743
805
  className: "flex gap-3 justify-center",
744
806
  children: [/* @__PURE__ */ p("button", {
745
807
  type: "button",
746
- onClick: () => v(-1),
808
+ onClick: () => _(-1),
747
809
  className: "px-4 py-2 rounded-lg border border-border-subtle hover:bg-bg-sunken",
748
810
  children: h("billing.checkout.goBack", "Go Back")
749
811
  }), /* @__PURE__ */ p("button", {
750
812
  type: "button",
751
813
  onClick: () => {
752
- N("select"), F(null), z.reset();
814
+ M("select"), P(null), R.reset();
753
815
  },
754
816
  className: "px-4 py-2 rounded-lg bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover",
755
817
  children: h("billing.checkout.tryAgain", "Try Again")
@@ -758,7 +820,7 @@ var Ye = () => {
758
820
  ]
759
821
  })
760
822
  });
761
- if (M === "processing") return /* @__PURE__ */ p("div", {
823
+ if (j === "processing") return /* @__PURE__ */ p("div", {
762
824
  className: "max-w-lg mx-auto p-6",
763
825
  children: /* @__PURE__ */ m("div", {
764
826
  className: "text-center space-y-6",
@@ -786,7 +848,7 @@ var Ye = () => {
786
848
  children: ((e) => {
787
849
  let t = Math.floor(e / 1e3);
788
850
  return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
789
- })(V)
851
+ })(Et)
790
852
  })
791
853
  ]
792
854
  }), /* @__PURE__ */ p("p", {
@@ -798,13 +860,13 @@ var Ye = () => {
798
860
  className: "w-full bg-bg-sunken rounded-full h-2 overflow-hidden",
799
861
  children: /* @__PURE__ */ p("div", {
800
862
  className: "bg-action-primary-bg h-2 rounded-full transition-all duration-1000",
801
- style: { width: `${Math.min(V / 3e5 * 100, 100)}%` }
863
+ style: { width: `${Math.min(Et / 3e5 * 100, 100)}%` }
802
864
  })
803
865
  }),
804
- V > 3e4 && /* @__PURE__ */ p("button", {
866
+ Et > 3e4 && /* @__PURE__ */ p("button", {
805
867
  type: "button",
806
868
  onClick: () => {
807
- N("error"), F("Payment verification was cancelled. Please check your billing history.");
869
+ M("error"), P("Payment verification was cancelled. Please check your billing history.");
808
870
  },
809
871
  className: "text-sm text-text-secondary hover:text-text-primary underline",
810
872
  children: h("billing.checkout.cancelAndCheckHistory", "Cancel and check billing history")
@@ -812,21 +874,21 @@ var Ye = () => {
812
874
  ]
813
875
  })
814
876
  });
815
- if (M === "payment" && P) {
877
+ if (j === "payment" && N) {
816
878
  let e = (e, t) => `${{
817
879
  INR: "₹",
818
880
  USD: "$",
819
881
  EUR: "€",
820
882
  GBP: "£"
821
- }[t] || t + " "}${e.toFixed(2)}`, t = P.currency || z.selectedCurrency, r = P.total ?? z.total;
883
+ }[t] || t + " "}${e.toFixed(2)}`, t = N.currency || R.selectedCurrency, r = N.total ?? R.total;
822
884
  return /* @__PURE__ */ m("div", {
823
885
  className: "max-w-2xl mx-auto p-4 sm:p-6 space-y-6",
824
886
  children: [
825
887
  /* @__PURE__ */ m("button", {
826
888
  type: "button",
827
- onClick: () => N("select"),
889
+ onClick: () => M("select"),
828
890
  className: "flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary",
829
- children: [/* @__PURE__ */ p(je, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
891
+ children: [/* @__PURE__ */ p(Pe, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
830
892
  }),
831
893
  /* @__PURE__ */ p(n, {
832
894
  title: h("billing.checkout.completePayment", "Complete Payment"),
@@ -837,9 +899,9 @@ var Ye = () => {
837
899
  children: [
838
900
  /* @__PURE__ */ m("h3", {
839
901
  className: "font-semibold text-text-primary flex items-center gap-2",
840
- children: [/* @__PURE__ */ p(Re, { className: "size-4" }), h("billing.checkout.paymentSummary", "Payment Summary")]
902
+ children: [/* @__PURE__ */ p(Ve, { className: "size-4" }), h("billing.checkout.paymentSummary", "Payment Summary")]
841
903
  }),
842
- z.billingAccount && /* @__PURE__ */ m("div", {
904
+ R.billingAccount && /* @__PURE__ */ m("div", {
843
905
  className: "p-3 bg-bg-sunken rounded-lg space-y-1",
844
906
  children: [
845
907
  /* @__PURE__ */ p("div", {
@@ -848,15 +910,15 @@ var Ye = () => {
848
910
  }),
849
911
  /* @__PURE__ */ p("div", {
850
912
  className: "font-medium text-text-primary",
851
- children: z.billingAccount.name
913
+ children: R.billingAccount.name
852
914
  }),
853
915
  /* @__PURE__ */ p("div", {
854
916
  className: "text-sm text-text-secondary",
855
- children: z.billingAccount.email
917
+ children: R.billingAccount.email
856
918
  })
857
919
  ]
858
920
  }),
859
- k === "ADDON" && z.selectedSubscriptionId && K && /* @__PURE__ */ m("div", {
921
+ E === "ADDON" && R.selectedSubscriptionId && G && /* @__PURE__ */ m("div", {
860
922
  className: "p-3 bg-bg-sunken rounded-lg space-y-1",
861
923
  children: [
862
924
  /* @__PURE__ */ p("div", {
@@ -865,11 +927,11 @@ var Ye = () => {
865
927
  }),
866
928
  /* @__PURE__ */ p("div", {
867
929
  className: "font-medium text-text-primary",
868
- children: K.plan?.name || h("billing.checkout.subscription", "Subscription")
930
+ children: G.plan?.name || h("billing.checkout.subscription", "Subscription")
869
931
  }),
870
- K.plan?.product?.name && /* @__PURE__ */ p("div", {
932
+ G.plan?.product?.name && /* @__PURE__ */ p("div", {
871
933
  className: "text-sm text-text-secondary",
872
- children: K.plan.product.name
934
+ children: G.plan.product.name
873
935
  })
874
936
  ]
875
937
  }),
@@ -877,7 +939,7 @@ var Ye = () => {
877
939
  className: "space-y-2 text-sm",
878
940
  children: [
879
941
  (() => {
880
- let n = z.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
942
+ let n = R.taxRate, i = n > 0 ? r / (1 + n) : r, a = n > 0 ? r - i : 0;
881
943
  return /* @__PURE__ */ m(f, { children: [
882
944
  /* @__PURE__ */ m("div", {
883
945
  className: "flex justify-between",
@@ -889,16 +951,16 @@ var Ye = () => {
889
951
  children: e(i, t)
890
952
  })]
891
953
  }),
892
- z.discountAmount > 0 && /* @__PURE__ */ m("div", {
954
+ R.discountAmount > 0 && /* @__PURE__ */ m("div", {
893
955
  className: "flex justify-between text-status-success-text",
894
- children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(z.discountAmount, t)] })]
956
+ children: [/* @__PURE__ */ p("span", { children: h("billing.checkout.discount", "Discount") }), /* @__PURE__ */ m("span", { children: ["-", e(R.discountAmount, t)] })]
895
957
  }),
896
958
  a > 0 && /* @__PURE__ */ m("div", {
897
959
  className: "flex justify-between",
898
960
  children: [/* @__PURE__ */ m("span", {
899
961
  className: "text-text-secondary",
900
962
  children: [
901
- z.taxType || h("billing.checkout.tax", "Tax"),
963
+ R.taxType || h("billing.checkout.tax", "Tax"),
902
964
  " (",
903
965
  (n * 100).toFixed(0),
904
966
  "%)"
@@ -925,23 +987,23 @@ var Ye = () => {
925
987
  })
926
988
  ]
927
989
  }),
928
- z.selectedProvider === "STRIPE" && P.clientSecret && /* @__PURE__ */ p("div", {
990
+ R.selectedProvider === "STRIPE" && N.clientSecret && /* @__PURE__ */ p("div", {
929
991
  className: "rounded-lg border border-border-subtle bg-bg-surface overflow-hidden",
930
992
  children: /* @__PURE__ */ p("div", {
931
993
  className: "p-4 space-y-4",
932
994
  children: /* @__PURE__ */ p(ye, {
933
- clientSecret: P.clientSecret,
934
- publishableKey: Qe || yt?.stripePublishableKey || "",
935
- amount: Math.round((P.total ?? z.total) * 100),
936
- currency: P.currency || z.selectedCurrency,
937
- onSuccess: zt,
938
- onError: Bt,
939
- onCancel: () => N("select"),
940
- isCompletingExistingPayment: !!z.selectedPaymentMethodId
995
+ clientSecret: N.clientSecret,
996
+ publishableKey: rt || Ct?.stripePublishableKey || "",
997
+ amount: Math.round((N.total ?? R.total) * 100),
998
+ currency: N.currency || R.selectedCurrency,
999
+ onSuccess: Yt,
1000
+ onError: Xt,
1001
+ onCancel: () => M("select"),
1002
+ isCompletingExistingPayment: !!R.selectedPaymentMethodId
941
1003
  })
942
1004
  })
943
1005
  }),
944
- z.selectedProvider === "RAZORPAY" && P.orderId && /* @__PURE__ */ p("div", {
1006
+ R.selectedProvider === "RAZORPAY" && N.orderId && /* @__PURE__ */ p("div", {
945
1007
  className: "rounded-lg border border-border-subtle bg-bg-surface overflow-hidden",
946
1008
  children: /* @__PURE__ */ m("div", {
947
1009
  className: "p-4 space-y-4",
@@ -949,27 +1011,27 @@ var Ye = () => {
949
1011
  className: "flex items-center gap-2 cursor-pointer",
950
1012
  children: [/* @__PURE__ */ p("input", {
951
1013
  type: "checkbox",
952
- checked: z.saveCard,
953
- onChange: (e) => z.setSaveCard(e.target.checked),
1014
+ checked: R.saveCard,
1015
+ onChange: (e) => R.setSaveCard(e.target.checked),
954
1016
  className: "size-4 rounded border-border-subtle text-text-link focus:ring-[var(--color-focus-ring)]"
955
1017
  }), /* @__PURE__ */ p("span", {
956
1018
  className: "text-sm text-text-secondary",
957
1019
  children: "Save card for future purchases"
958
1020
  })]
959
1021
  }), /* @__PURE__ */ p(be, {
960
- orderId: P.orderId,
961
- keyId: P.razorpayKeyId || $e || "",
962
- amount: Math.round((P.total ?? z.total) * 100),
963
- currency: P.currency || "INR",
964
- customerId: P.razorpayCustomerId,
1022
+ orderId: N.orderId,
1023
+ keyId: N.razorpayKeyId || it || "",
1024
+ amount: Math.round((N.total ?? R.total) * 100),
1025
+ currency: N.currency || "INR",
1026
+ customerId: N.razorpayCustomerId,
965
1027
  prefill: {
966
- name: P.prefillName,
967
- email: P.prefillEmail,
968
- contact: P.prefillContact
1028
+ name: N.prefillName,
1029
+ email: N.prefillEmail,
1030
+ contact: N.prefillContact
969
1031
  },
970
- onSuccess: (e) => zt(e.razorpay_payment_id),
971
- onError: Bt,
972
- onCancel: () => N("select")
1032
+ onSuccess: (e) => Yt(e.razorpay_payment_id),
1033
+ onError: Xt,
1034
+ onCancel: () => M("select")
973
1035
  })]
974
1036
  })
975
1037
  })
@@ -981,34 +1043,34 @@ var Ye = () => {
981
1043
  children: [
982
1044
  /* @__PURE__ */ m("button", {
983
1045
  type: "button",
984
- onClick: () => v(-1),
1046
+ onClick: () => _(-1),
985
1047
  className: "flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary mb-4",
986
- children: [/* @__PURE__ */ p(je, { className: "size-4" }), "Back"]
1048
+ children: [/* @__PURE__ */ p(Pe, { className: "size-4" }), "Back"]
987
1049
  }),
988
1050
  /* @__PURE__ */ m("div", {
989
1051
  className: "flex items-center gap-3 mb-6",
990
1052
  children: [/* @__PURE__ */ p("div", {
991
1053
  className: "p-2 rounded-lg bg-[var(--color-accent-soft)] text-text-link",
992
- children: Wt()
1054
+ children: en()
993
1055
  }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
994
1056
  className: "text-2xl font-bold text-text-primary",
995
- children: Ut()
1057
+ children: $t()
996
1058
  }), /* @__PURE__ */ p("p", {
997
1059
  className: "text-sm text-text-secondary",
998
1060
  children: "Complete your purchase securely"
999
1061
  })] })]
1000
1062
  }),
1001
- /* @__PURE__ */ p(Je, {
1063
+ /* @__PURE__ */ p(Ze, {
1002
1064
  className: "mb-6",
1003
1065
  children: h("billing.checkout.purpose", "Review what you are buying — plan, add-ons or credits — pick the billing account and payment method, apply any discount code, and pay. Taxes and the final total are shown before you confirm.")
1004
1066
  }),
1005
- b?.upgradeFromSubscriptionId && b?.currentPlanName && /* @__PURE__ */ p("div", {
1067
+ v?.upgradeFromSubscriptionId && v?.currentPlanName && /* @__PURE__ */ p("div", {
1006
1068
  className: "mb-6 p-4 rounded-lg border border-border-subtle bg-status-info-bg-subtle",
1007
1069
  children: /* @__PURE__ */ m("div", {
1008
1070
  className: "flex items-center gap-3",
1009
1071
  children: [/* @__PURE__ */ p("div", {
1010
1072
  className: "p-2 rounded-full bg-status-info-bg-subtle",
1011
- children: /* @__PURE__ */ p(ze, { className: "size-4 text-accent-blue" })
1073
+ children: /* @__PURE__ */ p(He, { className: "size-4 text-accent-blue" })
1012
1074
  }), /* @__PURE__ */ m("div", {
1013
1075
  className: "flex-1",
1014
1076
  children: [/* @__PURE__ */ m("p", {
@@ -1018,7 +1080,7 @@ var Ye = () => {
1018
1080
  " ",
1019
1081
  /* @__PURE__ */ p("span", {
1020
1082
  className: "font-semibold",
1021
- children: b.currentPlanName
1083
+ children: v.currentPlanName
1022
1084
  })
1023
1085
  ]
1024
1086
  }), /* @__PURE__ */ p("p", {
@@ -1028,13 +1090,13 @@ var Ye = () => {
1028
1090
  })]
1029
1091
  })
1030
1092
  }),
1031
- b?.downgradeFromSubscriptionId && b?.currentPlanName && /* @__PURE__ */ p("div", {
1093
+ v?.downgradeFromSubscriptionId && v?.currentPlanName && /* @__PURE__ */ p("div", {
1032
1094
  className: "mb-6 p-4 rounded-lg border border-status-warning-border bg-status-warning-bg-subtle",
1033
1095
  children: /* @__PURE__ */ m("div", {
1034
1096
  className: "flex items-center gap-3",
1035
1097
  children: [/* @__PURE__ */ p("div", {
1036
1098
  className: "p-2 rounded-full bg-status-warning-bg-subtle",
1037
- children: /* @__PURE__ */ p(ze, { className: "size-4 text-status-warning-text" })
1099
+ children: /* @__PURE__ */ p(He, { className: "size-4 text-status-warning-text" })
1038
1100
  }), /* @__PURE__ */ m("div", {
1039
1101
  className: "flex-1",
1040
1102
  children: [/* @__PURE__ */ m("p", {
@@ -1044,7 +1106,7 @@ var Ye = () => {
1044
1106
  " ",
1045
1107
  /* @__PURE__ */ p("span", {
1046
1108
  className: "font-semibold",
1047
- children: b.currentPlanName
1109
+ children: v.currentPlanName
1048
1110
  })
1049
1111
  ]
1050
1112
  }), /* @__PURE__ */ p("p", {
@@ -1059,53 +1121,58 @@ var Ye = () => {
1059
1121
  children: [/* @__PURE__ */ m("div", {
1060
1122
  className: "lg:col-span-3 space-y-6 order-2 lg:order-1",
1061
1123
  children: [
1062
- k === "CREDITS" && z.items[0] && /* @__PURE__ */ p("div", {
1124
+ E === "CREDITS" && R.items[0] && /* @__PURE__ */ p("div", {
1063
1125
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6",
1064
1126
  children: /* @__PURE__ */ p(ve, {
1065
- value: z.items[0].quantity,
1066
- onChange: Vt,
1067
- costPerCredit: J,
1068
- currency: z.selectedCurrency,
1069
- disabled: Nt
1127
+ value: R.items[0].quantity,
1128
+ onChange: Zt,
1129
+ costPerCredit: q,
1130
+ currency: R.selectedCurrency,
1131
+ disabled: Ut
1070
1132
  })
1071
1133
  }),
1072
1134
  /* @__PURE__ */ m("div", {
1073
1135
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1074
1136
  children: [/* @__PURE__ */ p(he, {
1075
- accounts: X,
1076
- selectedAccountId: z.billingAccount?.id ?? null,
1077
- onSelect: z.setBillingAccount,
1078
- isLoading: Ct,
1079
- disabled: It,
1080
- disabledMessage: It ? "Billing account is locked for plan changes" : void 0
1081
- }), k === "ADDON" && !O && z.billingAccount && /* @__PURE__ */ p(xe, {
1082
- subscriptions: G,
1083
- selectedSubscriptionId: z.selectedSubscriptionId,
1084
- onSelect: z.setSelectedSubscriptionId,
1085
- isLoading: At
1137
+ accounts: Y,
1138
+ selectedAccountId: R.billingAccount?.id ?? null,
1139
+ onSelect: R.setBillingAccount,
1140
+ isLoading: kt,
1141
+ disabled: Kt,
1142
+ disabledMessage: Kt ? "Billing account is locked for plan changes" : void 0
1143
+ }), E === "ADDON" && !T && R.billingAccount && /* @__PURE__ */ p(xe, {
1144
+ subscriptions: W,
1145
+ selectedSubscriptionId: R.selectedSubscriptionId,
1146
+ onSelect: R.setSelectedSubscriptionId,
1147
+ isLoading: Bt
1086
1148
  })]
1087
1149
  }),
1150
+ H && /* @__PURE__ */ p(Oe, {
1151
+ storeOrderId: g,
1152
+ currency: R.selectedCurrency,
1153
+ onChange: Ft
1154
+ }),
1088
1155
  /* @__PURE__ */ m("div", {
1089
1156
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1090
1157
  children: [
1091
1158
  /* @__PURE__ */ p(Ce, {
1092
- savedPaymentMethods: Y,
1093
- selectedPaymentMethodId: z.selectedPaymentMethodId,
1094
- onSelectSavedCard: z.setSelectedPaymentMethodId,
1095
- selectedProvider: z.selectedProvider,
1096
- onSelectProvider: z.setPaymentProvider,
1097
- stripeEnabled: bt,
1098
- razorpayEnabled: B,
1099
- canPayWithCredits: z.canPayWithCredits && z.hasEnoughCredits,
1100
- availableCredits: z.availableCredits,
1101
- totalAmount: z.subtotalUSD,
1102
- billingCountry: Z,
1103
- saveCard: z.saveCard,
1104
- onSaveCardChange: z.setSaveCard,
1105
- autoRenewEnabled: k === "PLAN" && z.autoRenew,
1106
- isLoading: Ot
1159
+ savedPaymentMethods: J,
1160
+ selectedPaymentMethodId: R.selectedPaymentMethodId,
1161
+ onSelectSavedCard: R.setSelectedPaymentMethodId,
1162
+ selectedProvider: R.selectedProvider,
1163
+ onSelectProvider: R.setPaymentProvider,
1164
+ stripeEnabled: wt,
1165
+ razorpayEnabled: Tt,
1166
+ canPayWithCredits: R.canPayWithCredits && R.hasEnoughCredits,
1167
+ availableCredits: R.availableCredits,
1168
+ totalAmount: R.subtotalUSD,
1169
+ billingCountry: X,
1170
+ saveCard: R.saveCard,
1171
+ onSaveCardChange: R.setSaveCard,
1172
+ autoRenewEnabled: E === "PLAN" && R.autoRenew,
1173
+ isLoading: Rt
1107
1174
  }),
1108
- z.selectedProvider !== "CREDITS" && z.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border-subtle" }), /* @__PURE__ */ p("div", {
1175
+ R.selectedProvider !== "CREDITS" && R.selectedProvider !== "AUTO" && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("div", { className: "border-t border-border-subtle" }), /* @__PURE__ */ p("div", {
1109
1176
  className: "bg-bg-sunken p-4 rounded-button",
1110
1177
  children: /* @__PURE__ */ m("div", {
1111
1178
  className: "flex items-start gap-3",
@@ -1124,7 +1191,7 @@ var Ye = () => {
1124
1191
  className: "flex-1 text-sm",
1125
1192
  children: [/* @__PURE__ */ m("p", {
1126
1193
  className: "font-medium text-text-primary mb-1",
1127
- children: ["Currency: ", z.selectedCurrency]
1194
+ children: ["Currency: ", R.selectedCurrency]
1128
1195
  }), /* @__PURE__ */ m("p", {
1129
1196
  className: "text-text-secondary text-xs",
1130
1197
  children: [
@@ -1132,30 +1199,30 @@ var Ye = () => {
1132
1199
  " ",
1133
1200
  /* @__PURE__ */ p("strong", {
1134
1201
  className: "text-text-primary",
1135
- children: z.selectedCurrency
1202
+ children: R.selectedCurrency
1136
1203
  }),
1137
1204
  " ",
1138
1205
  "based on your billing account settings.",
1139
- z.selectedCurrency === "INR" && " GST will be applied at checkout."
1206
+ R.selectedCurrency === "INR" && " GST will be applied at checkout."
1140
1207
  ]
1141
1208
  })]
1142
1209
  })]
1143
1210
  })
1144
1211
  })] }),
1145
- k === "PLAN" && H?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1212
+ E === "PLAN" && z?.getPlan?.pricingModel === "PER_SEAT" && /* @__PURE__ */ p("div", {
1146
1213
  className: "border-t border-border-subtle pt-4",
1147
1214
  children: /* @__PURE__ */ m("div", {
1148
1215
  className: "space-y-3",
1149
1216
  children: [/* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("label", {
1150
1217
  className: "text-sm font-medium text-text-primary",
1151
1218
  children: "Number of seats"
1152
- }), H.getPlan.minSeats && /* @__PURE__ */ m("p", {
1219
+ }), z.getPlan.minSeats && /* @__PURE__ */ m("p", {
1153
1220
  className: "text-xs text-text-secondary mt-0.5",
1154
1221
  children: [
1155
1222
  "Minimum ",
1156
- H.getPlan.minSeats,
1223
+ z.getPlan.minSeats,
1157
1224
  " seat",
1158
- H.getPlan.minSeats === 1 ? "" : "s",
1225
+ z.getPlan.minSeats === 1 ? "" : "s",
1159
1226
  " required"
1160
1227
  ]
1161
1228
  })] }), /* @__PURE__ */ m("div", {
@@ -1163,44 +1230,44 @@ var Ye = () => {
1163
1230
  children: [
1164
1231
  /* @__PURE__ */ p("button", {
1165
1232
  type: "button",
1166
- onClick: () => R((e) => Math.max(H.getPlan?.minSeats ?? 1, e - 1)),
1167
- disabled: L <= (H.getPlan.minSeats ?? 1),
1233
+ onClick: () => L((e) => Math.max(z.getPlan?.minSeats ?? 1, e - 1)),
1234
+ disabled: I <= (z.getPlan.minSeats ?? 1),
1168
1235
  className: "size-9 rounded-button border border-border-subtle flex items-center justify-center hover:bg-action-ghost-bgHover disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-text-primary",
1169
1236
  children: "−"
1170
1237
  }),
1171
1238
  /* @__PURE__ */ p("input", {
1172
1239
  type: "number",
1173
- value: L,
1174
- min: H.getPlan.minSeats ?? 1,
1175
- max: H.getPlan.maxSeats ?? 999,
1240
+ value: I,
1241
+ min: z.getPlan.minSeats ?? 1,
1242
+ max: z.getPlan.maxSeats ?? 999,
1176
1243
  onChange: (e) => {
1177
1244
  let t = parseInt(e.target.value, 10);
1178
- isNaN(t) || R(Math.max(H.getPlan?.minSeats ?? 1, t));
1245
+ isNaN(t) || L(Math.max(z.getPlan?.minSeats ?? 1, t));
1179
1246
  },
1180
1247
  className: "w-20 h-9 text-center border border-border-subtle rounded-button bg-bg-surface text-text-primary text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
1181
1248
  }),
1182
1249
  /* @__PURE__ */ p("button", {
1183
1250
  type: "button",
1184
- onClick: () => R((e) => Math.min(H.getPlan?.maxSeats ?? 999, e + 1)),
1185
- disabled: L >= (H.getPlan.maxSeats ?? 999),
1251
+ onClick: () => L((e) => Math.min(z.getPlan?.maxSeats ?? 999, e + 1)),
1252
+ disabled: I >= (z.getPlan.maxSeats ?? 999),
1186
1253
  className: "size-9 rounded-button border border-border-subtle flex items-center justify-center hover:bg-action-ghost-bgHover disabled:opacity-40 disabled:cursor-not-allowed transition-colors text-text-primary",
1187
1254
  children: "+"
1188
1255
  }),
1189
- H.getPlan.pricePerSeat && /* @__PURE__ */ m("span", {
1256
+ z.getPlan.pricePerSeat && /* @__PURE__ */ m("span", {
1190
1257
  className: "text-sm text-text-secondary",
1191
1258
  children: [
1192
1259
  "×",
1193
1260
  " ",
1194
- H.getPlan.pricePerSeat.toLocaleString("en", {
1261
+ z.getPlan.pricePerSeat.toLocaleString("en", {
1195
1262
  style: "currency",
1196
- currency: H.getPlan.currency ?? "USD"
1263
+ currency: z.getPlan.currency ?? "USD"
1197
1264
  }),
1198
1265
  " ",
1199
1266
  "=",
1200
1267
  " ",
1201
- (H.getPlan.pricePerSeat * L).toLocaleString("en", {
1268
+ (z.getPlan.pricePerSeat * I).toLocaleString("en", {
1202
1269
  style: "currency",
1203
- currency: H.getPlan.currency ?? "USD"
1270
+ currency: z.getPlan.currency ?? "USD"
1204
1271
  }),
1205
1272
  "/mo"
1206
1273
  ]
@@ -1223,46 +1290,46 @@ var Ye = () => {
1223
1290
  /* @__PURE__ */ p("div", {
1224
1291
  className: "p-4",
1225
1292
  children: /* @__PURE__ */ p(ge, {
1226
- items: z.items,
1227
- subtotal: z.subtotal,
1228
- discountAmount: z.discountAmount,
1229
- taxAmount: z.taxAmount,
1230
- taxRate: z.taxRate,
1231
- taxType: z.taxType,
1232
- total: z.total,
1233
- currency: z.selectedCurrency,
1234
- isCalculatingTax: z.isCalculatingTax,
1235
- showInCredits: z.selectedProvider === "CREDITS",
1236
- onUpdateQuantity: k !== "PLAN" && k !== "ORDER" ? z.updateItemQuantity : void 0,
1237
- onRemoveItem: z.removeItem,
1238
- isEditable: k !== "PLAN" && k !== "ORDER"
1293
+ items: R.items,
1294
+ subtotal: R.subtotal,
1295
+ discountAmount: R.discountAmount,
1296
+ taxAmount: R.taxAmount,
1297
+ taxRate: R.taxRate,
1298
+ taxType: R.taxType,
1299
+ total: R.total,
1300
+ currency: R.selectedCurrency,
1301
+ isCalculatingTax: R.isCalculatingTax,
1302
+ showInCredits: R.selectedProvider === "CREDITS",
1303
+ onUpdateQuantity: E !== "PLAN" && E !== "ORDER" ? R.updateItemQuantity : void 0,
1304
+ onRemoveItem: R.removeItem,
1305
+ isEditable: E !== "PLAN" && E !== "ORDER"
1239
1306
  })
1240
1307
  }),
1241
1308
  /* @__PURE__ */ p("div", {
1242
1309
  className: "px-4 pb-4 border-t border-border-subtle pt-4",
1243
1310
  children: /* @__PURE__ */ p(_e, {
1244
- value: z.promoCode,
1245
- onChange: z.setPromoCode,
1246
- onValidate: async () => await z.validatePromoCode(),
1247
- onClear: z.clearPromoCode,
1248
- isApplied: z.promoDiscount > 0,
1249
- discountValue: z.promoDiscount,
1250
- discountType: z.promoDiscountType,
1251
- isValidating: z.isProcessing
1311
+ value: R.promoCode,
1312
+ onChange: R.setPromoCode,
1313
+ onValidate: async () => await R.validatePromoCode(),
1314
+ onClear: R.clearPromoCode,
1315
+ isApplied: R.promoDiscount > 0,
1316
+ discountValue: R.promoDiscount,
1317
+ discountType: R.promoDiscountType,
1318
+ isValidating: R.isProcessing
1252
1319
  })
1253
1320
  }),
1254
- k === "PLAN" && z.selectedProvider !== "CREDITS" && z.selectedProvider !== "AUTO" && (() => {
1321
+ E === "PLAN" && R.selectedProvider !== "CREDITS" && R.selectedProvider !== "AUTO" && (() => {
1255
1322
  let e = "", t = !1, n = !1;
1256
- if (z.selectedPaymentMethodId) {
1257
- let r = Y.find((e) => e.id === z.selectedPaymentMethodId);
1323
+ if (R.selectedPaymentMethodId) {
1324
+ let r = J.find((e) => e.id === R.selectedPaymentMethodId);
1258
1325
  r && (e = `${r.type === "CREDIT_CARD" || r.type === "DEBIT_CARD" ? "Card" : r.type}${r.last4 ? ` •••• ${r.last4}` : ""}`, t = !0, n = !1);
1259
- } else (z.selectedProvider === "RAZORPAY" || z.selectedProvider === "STRIPE") && (e = z.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1326
+ } else (R.selectedProvider === "RAZORPAY" || R.selectedProvider === "STRIPE") && (e = R.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1260
1327
  return /* @__PURE__ */ p("div", {
1261
1328
  className: "px-4 pb-4",
1262
1329
  children: /* @__PURE__ */ p(Se, {
1263
- enabled: z.autoRenew,
1330
+ enabled: R.autoRenew,
1264
1331
  onToggle: (e) => {
1265
- z.setAutoRenew(e), e && z.selectedPaymentMethodId && z.setAutoRenewPaymentMethodId(z.selectedPaymentMethodId);
1332
+ R.setAutoRenew(e), e && R.selectedPaymentMethodId && R.setAutoRenewPaymentMethodId(R.selectedPaymentMethodId);
1266
1333
  },
1267
1334
  hasPaymentMethodSelected: t,
1268
1335
  selectedPaymentMethodDisplay: e,
@@ -1274,10 +1341,10 @@ var Ye = () => {
1274
1341
  }),
1275
1342
  /* @__PURE__ */ p("button", {
1276
1343
  type: "button",
1277
- onClick: Rt,
1278
- disabled: z.isProcessing || !z.billingAccount || z.items.length === 0 || k === "ADDON" && !O && At || k === "ADDON" && !O && G.length === 0 || k === "ADDON" && !O && !z.selectedSubscriptionId,
1344
+ onClick: Jt,
1345
+ disabled: R.isProcessing || !R.billingAccount || R.items.length === 0 || E === "ADDON" && !T && Bt || E === "ADDON" && !T && W.length === 0 || E === "ADDON" && !T && !R.selectedSubscriptionId || H && (!U.shippingAddressId || !U.shippingMethodId),
1279
1346
  className: "w-full px-6 py-4 rounded-lg bg-action-primary-bg text-action-primary-text font-semibold\n hover:bg-action-primary-bgHover disabled:opacity-50 disabled:cursor-not-allowed\n transition-colors flex items-center justify-center gap-2",
1280
- children: z.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : z.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1347
+ children: R.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : R.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1281
1348
  }),
1282
1349
  /* @__PURE__ */ p("p", {
1283
1350
  className: "text-center text-xs text-text-secondary",
@@ -1287,22 +1354,22 @@ var Ye = () => {
1287
1354
  })
1288
1355
  })]
1289
1356
  }),
1290
- ot && z.billingAccount && /* @__PURE__ */ p(we, {
1291
- billingAccountId: z.billingAccount.id,
1292
- hasPhone: !!z.billingAccount.contactNumber?.trim(),
1293
- hasAddress: !!(z.billingAccount.billingAddresses?.[0]?.line1?.trim() && z.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1357
+ ft && R.billingAccount && /* @__PURE__ */ p(we, {
1358
+ billingAccountId: R.billingAccount.id,
1359
+ hasPhone: !!R.billingAccount.contactNumber?.trim(),
1360
+ hasAddress: !!(R.billingAccount.billingAddresses?.[0]?.line1?.trim() && R.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),
1294
1361
  onCompleted: () => {
1295
- ct.current = !0, st(!1), Rt(), wt().then((e) => {
1296
- let t = (e.data?.getBillingAccountsByOrg ?? []).find((e) => e.id === z.billingAccount?.id);
1297
- t && z.setBillingAccount(t);
1362
+ k.current = !0, O(!1), Jt(), At().then((e) => {
1363
+ let t = (e.data?.myBillingAccounts ?? []).find((e) => e.id === R.billingAccount?.id);
1364
+ t && R.setBillingAccount(t);
1298
1365
  });
1299
1366
  },
1300
- onCancel: () => st(!1)
1367
+ onCancel: () => O(!1)
1301
1368
  })
1302
1369
  ]
1303
1370
  });
1304
1371
  };
1305
1372
  //#endregion
1306
- export { Ye as CheckoutPage };
1373
+ export { Qe as CheckoutPage };
1307
1374
 
1308
1375
  //# sourceMappingURL=CheckoutPage.js.map