@burdenoff/microfe-billing 2026.910.5 → 2026.910.6

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.
@@ -5,34 +5,34 @@ import "../../../shared/components/index.js";
5
5
  import { useBillingEventEmitter as r } from "../../../hooks/useBillingEventEmitter.js";
6
6
  import { getStoredBillingAccountId as i } from "../../../hooks/useBillingAccountSelection.js";
7
7
  import { useBillingPermissions as a } from "../../../hooks/useBillingPermissions.js";
8
- import { useGetActiveSubscriptionsCheckoutQuery as o, useGetBillingAccountsCheckoutQuery as ee, useGetCostOfCreditsCheckoutQuery as te, useGetPaymentMethodsCheckoutQuery as ne, useGetPlanCheckoutQuery as re, useGetSelectedAddonCheckoutQuery as ie, useGetStoreOrderCheckoutQuery as ae } from "../../../../generated/global-operations.js";
9
- import { useAddonCartStore as oe } from "../../addons/store/addonCartStore.js";
10
- import { useBillingNavigate as se } from "../../../hooks/useBillingNavigate.js";
11
- import { recordAffiliateEvent as ce } from "../../affiliate/api.js";
12
- import { STORE_SHIPPING_ITEM_ID as le, useSetStoreOrderShipping as ue } from "../hooks/useStoreShipping.js";
13
- import { useCheckout as de } from "../hooks/useCheckout.js";
14
- import { isNativeIAPAvailable as fe } from "../../../lib/native-purchases.js";
15
- import { useNativeCheckout as pe } from "../hooks/useNativeCheckout.js";
16
- import { usePaymentProviders as me } from "../hooks/usePaymentProviders.js";
17
- import { usePaymentStatusPolling as he } from "../hooks/usePaymentStatusPolling.js";
8
+ import { useGetActiveSubscriptionsCheckoutQuery as o, useGetBillingAccountsCheckoutQuery as ee, useGetCostOfCreditsCheckoutQuery as te, useGetPaymentMethodsCheckoutQuery as s, useGetPlanCheckoutQuery as ne, useGetSelectedAddonCheckoutQuery as re, useGetStoreOrderCheckoutQuery as ie } from "../../../../generated/global-operations.js";
9
+ import { useAddonCartStore as ae } from "../../addons/store/addonCartStore.js";
10
+ import { useBillingNavigate as oe } from "../../../hooks/useBillingNavigate.js";
11
+ import { recordAffiliateEvent as se } from "../../affiliate/api.js";
12
+ import { STORE_SHIPPING_ITEM_ID as ce, useSetStoreOrderShipping as le } from "../hooks/useStoreShipping.js";
13
+ import { useCheckout as ue } from "../hooks/useCheckout.js";
14
+ import { isNativeIAPAvailable as de } from "../../../lib/native-purchases.js";
15
+ import { useNativeCheckout as fe } from "../hooks/useNativeCheckout.js";
16
+ import { usePaymentProviders as pe } from "../hooks/usePaymentProviders.js";
17
+ import { usePaymentStatusPolling as me } from "../hooks/usePaymentStatusPolling.js";
18
18
  import "../hooks/index.js";
19
- import { NativeCheckoutView as ge } from "../components/NativeCheckoutView.js";
20
- import { BillingAccountSelector as _e } from "../components/BillingAccountSelector.js";
21
- import { OrderSummary as ve } from "../components/OrderSummary.js";
22
- import { PromoCodeInput as ye } from "../components/PromoCodeInput.js";
23
- import { CreditsAmountInput as be } from "../components/CreditsAmountInput.js";
24
- import { StripePaymentForm as xe } from "../components/StripePaymentForm.js";
25
- import { RazorpayPaymentButton as Se } from "../components/RazorpayPaymentButton.js";
26
- import { SubscriptionSelector as Ce } from "../components/SubscriptionSelector.js";
27
- import { SimpleAutoPayToggle as we } from "../components/SimpleAutoPayToggle.js";
28
- import { UnifiedPaymentMethodSelector as Te } from "../components/UnifiedPaymentMethodSelector.js";
29
- import { CompleteBillingAccountModal as Ee, isBillingAccountComplete as De } from "../components/CompleteBillingAccountModal.js";
30
- import { StoreShippingSection as Oe } from "../components/StoreShippingSection.js";
31
- import { WorkspaceQuotaAssignmentModal as ke, isWorkspaceScopedQuota as Ae } from "../components/WorkspaceQuotaAssignmentModal.js";
19
+ import { NativeCheckoutView as he } from "../components/NativeCheckoutView.js";
20
+ import { BillingAccountSelector as ge } from "../components/BillingAccountSelector.js";
21
+ import { OrderSummary as _e } from "../components/OrderSummary.js";
22
+ import { PromoCodeInput as ve } from "../components/PromoCodeInput.js";
23
+ import { CreditsAmountInput as ye } from "../components/CreditsAmountInput.js";
24
+ import { StripePaymentForm as be } from "../components/StripePaymentForm.js";
25
+ import { RazorpayPaymentButton as xe } from "../components/RazorpayPaymentButton.js";
26
+ import { SubscriptionSelector as Se } from "../components/SubscriptionSelector.js";
27
+ import { SimpleAutoPayToggle as Ce } from "../components/SimpleAutoPayToggle.js";
28
+ import { UnifiedPaymentMethodSelector as we } from "../components/UnifiedPaymentMethodSelector.js";
29
+ import { CompleteBillingAccountModal as Te, isBillingAccountComplete as Ee } from "../components/CompleteBillingAccountModal.js";
30
+ import { StoreShippingSection as De } from "../components/StoreShippingSection.js";
31
+ import { WorkspaceQuotaAssignmentModal as Oe, isWorkspaceScopedQuota as ke } from "../components/WorkspaceQuotaAssignmentModal.js";
32
32
  import "../components/index.js";
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";
33
+ import { buildStoreOrderCheckoutItems as Ae, normalizeStoreOrderCurrency as je } from "../utils/storeOrder.js";
34
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as Me, useState as d } from "react";
35
+ import { ArrowLeft as Ne, ArrowRight as Pe, Blocks as Fe, CheckCircle as Ie, Coins as Le, CreditCard as Re, Loader2 as ze, Package as Be, Receipt as Ve, RefreshCw as He, ShoppingCart as Ue, Wallet as We, XCircle as Ge } from "lucide-react";
36
36
  import { useLocation as Ke, useParams as qe } from "react-router";
37
37
  import { useAppShell as Je } from "@burdenoff/fe-libs/shared/providers/shell";
38
38
  import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
@@ -56,11 +56,11 @@ var $e = () => {
56
56
  let { t: $e } = Ye(), h = (e, t) => {
57
57
  let n = $e(e);
58
58
  return n === e ? t : n;
59
- }, { planId: et, addonId: tt, storeOrderId: g } = qe(), _ = se(), nt = Ke(), v = nt.state, rt = a(), { emit: y } = r(), { orgId: b, stripePublishableKey: it, razorpayKey: at, apiGatewayUrl: ot, authToken: st, currentUser: ct, workspaceId: x } = e(), { productSlug: lt } = Je(), ut = Ne(null), dt = x ? [{
59
+ }, { planId: et, addonId: tt, storeOrderId: g } = qe(), _ = oe(), nt = Ke(), v = nt.state, rt = a(), { emit: y } = r(), { orgId: b, stripePublishableKey: it, razorpayKey: at, apiGatewayUrl: ot, authToken: st, currentUser: ct, workspaceId: x } = e(), { productSlug: lt } = Je(), ut = Me(null), dt = x ? [{
60
60
  id: x,
61
61
  name: "Current workspace"
62
- }] : [], { items: S, clearCart: ft, _hasHydrated: C } = oe(), w = nt.pathname.includes("/checkout/addons") && !tt, T = nt.pathname.includes("/checkout/store") && !!g, E = w ? "ADDON" : T ? "ORDER" : v?.purchaseType ?? (et ? "PLAN" : tt ? "ADDON" : "CREDITS"), D = v?.itemId ?? et ?? tt ?? g, [pt, mt] = u(!1), ht = Ne(!1), [gt, _t] = u(!1), [vt, yt] = u([]), [bt, xt] = u(null), [O, k] = u("select"), [A, St] = u(null), [Ct, j] = u(null), [M, wt] = u(null), [Tt, Et] = u("card");
63
- c(() => {
62
+ }] : [], { items: S, clearCart: ft, _hasHydrated: C } = ae(), w = nt.pathname.includes("/checkout/addons") && !tt, T = nt.pathname.includes("/checkout/store") && !!g, E = w ? "ADDON" : T ? "ORDER" : v?.purchaseType ?? (et ? "PLAN" : tt ? "ADDON" : "CREDITS"), D = v?.itemId ?? et ?? tt ?? g, [pt, mt] = d(!1), ht = Me(!1), [gt, _t] = d(!1), [vt, yt] = d([]), [bt, xt] = d(null), [O, k] = d("select"), [A, St] = d(null), [Ct, j] = d(null), [M, wt] = d(null), [Tt, Et] = d("card");
63
+ l(() => {
64
64
  if (O !== "success" || !M) return;
65
65
  let e = typeof window < "u" ? window.localStorage.getItem(Xe("boff-referral-attribution")) : null;
66
66
  if (!e) return;
@@ -72,7 +72,7 @@ var $e = () => {
72
72
  }
73
73
  if (!t.journeyId && !t.codeId) return;
74
74
  let n = M.transactionId || A?.paymentId || A?.orderId || g || D || E, r = `${t.journeyId ?? "journey"}:${n}`;
75
- ut.current !== r && (ut.current = r, ce({
75
+ ut.current !== r && (ut.current = r, se({
76
76
  journeyId: t.journeyId,
77
77
  codeId: t.codeId,
78
78
  eventType: E === "ORDER" ? "STORE_PURCHASE" : "PAID_CONVERSION",
@@ -109,11 +109,11 @@ var $e = () => {
109
109
  E,
110
110
  g
111
111
  ]);
112
- let [N, P] = u(1), F = de({
112
+ let [N, P] = d(1), F = ue({
113
113
  defaultCurrency: "USD",
114
114
  upgradeFromSubscriptionId: v?.upgradeFromSubscriptionId,
115
115
  downgradeFromSubscriptionId: v?.downgradeFromSubscriptionId
116
- }), { config: Dt, stripeEnabled: Ot, razorpayEnabled: kt } = me(), { elapsedTime: At, error: jt } = he({
116
+ }), { config: Dt, stripeEnabled: Ot, razorpayEnabled: kt } = pe(), { elapsedTime: At, error: jt } = me({
117
117
  paymentId: O === "processing" ? A?.paymentId ?? null : null,
118
118
  billingAccountId: F.billingAccount?.id ?? M?.billingAccountId ?? null,
119
119
  paymentType: Tt,
@@ -124,7 +124,7 @@ var $e = () => {
124
124
  ...t,
125
125
  transactionId: e.transactionId
126
126
  }), k("success"), w && ft(), (E === "PLAN" || E === "ADDON") && x) {
127
- let e = (I?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && Ae(e.quota.name)).map((e) => {
127
+ let e = (I?.getPlan?.features ?? []).filter((e) => e != null).filter((e) => e.quota?.name && ke(e.quota.name)).map((e) => {
128
128
  let t = e.quota?.limits, n = t && "type" in t ? String(t.type) : "number", r = e.context && "quantity" in e.context ? Number(e.context.quantity) : null, i = t && "value" in t ? Number(t.value) : null, a = r ?? i;
129
129
  return {
130
130
  quotaName: e.quota.name,
@@ -147,41 +147,41 @@ var $e = () => {
147
147
  onTimeout: () => {
148
148
  j("Payment verification timed out. Please check your billing history for the payment status."), k("error");
149
149
  }
150
- }), { data: Mt, loading: Nt, refetch: Pt } = ee({}), { data: I, loading: Ft } = re({
150
+ }), { data: Mt, loading: Nt, refetch: Pt } = ee({}), { data: I, loading: Ft } = ne({
151
151
  variables: { id: D },
152
152
  skip: E !== "PLAN" || !D
153
- }), { data: L, loading: It } = ie({
153
+ }), { data: L, loading: It } = re({
154
154
  variables: { addonIDs: D ? [D] : [] },
155
155
  skip: E !== "ADDON" || !D || T
156
- }), { data: R } = ae({
156
+ }), { data: R } = ie({
157
157
  variables: { id: g },
158
158
  skip: !T || !g
159
- }), Lt = l(() => {
159
+ }), Lt = u(() => {
160
160
  let e = R?.getStoreOrder?.lineItems;
161
161
  return Array.isArray(e) ? e : [];
162
- }, [R]), z = T && Lt.some((e) => String(e.itemType).toUpperCase() === "PHYSICAL"), Rt = Me(R?.getStoreOrder?.currency), [B, zt] = u({
162
+ }, [R]), z = T && Lt.some((e) => String(e.itemType).toUpperCase() === "PHYSICAL"), Rt = je(R?.getStoreOrder?.currency), [B, zt] = d({
163
163
  shippingAddressId: null,
164
164
  shippingMethodId: null,
165
165
  shippingCost: 0,
166
166
  destinationCountry: null
167
- }), [Bt] = ue(), { data: Vt, loading: Ht } = ne({
167
+ }), [Bt] = le(), { data: Vt, loading: Ht } = s({
168
168
  variables: { billingAccountId: F.billingAccount?.id },
169
169
  skip: !F.billingAccount?.id
170
170
  }), { data: Ut, loading: Wt, refetch: Gt } = o({
171
171
  variables: { billingAccountId: F.billingAccount?.id },
172
172
  skip: !F.billingAccount?.id || E !== "ADDON" && E !== "PLAN" || T
173
- }), V = l(() => Ut?.getActiveSubscriptions ?? [], [Ut]), H = l(() => !F.selectedSubscriptionId || V.length === 0 ? null : V.find((e) => e.id === F.selectedSubscriptionId) ?? null, [F.selectedSubscriptionId, V]), U = F.items[0]?.type === "CREDITS" ? F.items[0].quantity : 100, { data: Kt, loading: qt } = te({
173
+ }), V = u(() => Ut?.getActiveSubscriptions ?? [], [Ut]), H = u(() => !F.selectedSubscriptionId || V.length === 0 ? null : V.find((e) => e.id === F.selectedSubscriptionId) ?? null, [F.selectedSubscriptionId, V]), U = F.items[0]?.type === "CREDITS" ? F.items[0].quantity : 100, { data: Kt, loading: qt } = te({
174
174
  variables: {
175
175
  creditAmount: U,
176
176
  currency: F.selectedCurrency || "USD"
177
177
  },
178
178
  skip: E !== "CREDITS"
179
- }), W = l(() => Kt?.getCostOfCredits?.amount && U > 0 ? Kt.getCostOfCredits.amount / U : .01, [Kt, U]), G = l(() => Vt?.getPaymentMethods ?? [], [Vt]), K = l(() => Mt?.myBillingAccounts ?? [], [Mt]), q = l(() => {
179
+ }), W = u(() => Kt?.getCostOfCredits?.amount && U > 0 ? Kt.getCostOfCredits.amount / U : .01, [Kt, U]), G = u(() => Vt?.getPaymentMethods ?? [], [Vt]), K = u(() => Mt?.myBillingAccounts ?? [], [Mt]), q = u(() => {
180
180
  if (!F.billingAccount) return;
181
181
  let e = K.find((e) => e.id === F.billingAccount?.id)?.billingAddresses;
182
182
  if (e && e.length > 0) return e[0]?.country || void 0;
183
- }, [F.billingAccount, K]), [Jt, Yt] = u(null);
184
- c(() => {
183
+ }, [F.billingAccount, K]), [Jt, Yt] = d(null);
184
+ l(() => {
185
185
  if (q) if (q === "IN") F.selectedCurrency !== "INR" && F.setCurrency("INR"), kt && Jt !== q && F.selectedProvider !== "CREDITS" && (F.setPaymentProvider("RAZORPAY"), Yt(q));
186
186
  else {
187
187
  if (F.selectedCurrency === "INR") {
@@ -201,7 +201,7 @@ var $e = () => {
201
201
  Jt
202
202
  ]);
203
203
  let { availableCredits: Xt, billingAccount: Zt, canPayWithCredits: Qt, selectedCurrency: J, selectedPaymentMethodId: $t, selectedProvider: en, setCurrency: Y, setPaymentProvider: X, setSelectedPaymentMethodId: tn, total: nn } = F;
204
- c(() => {
204
+ l(() => {
205
205
  if (!Zt?.currency || q === "IN") return;
206
206
  let e = Zt.currency;
207
207
  e !== "INR" && J !== e && Y(e);
@@ -210,7 +210,7 @@ var $e = () => {
210
210
  Zt,
211
211
  J,
212
212
  Y
213
- ]), c(() => {
213
+ ]), l(() => {
214
214
  if (!(en !== "AUTO" && en !== null)) {
215
215
  if (Qt && Xt >= nn) {
216
216
  X("CREDITS"), tn(null);
@@ -234,10 +234,10 @@ var $e = () => {
234
234
  X,
235
235
  tn
236
236
  ]);
237
- let [Z, Q] = u(!1);
238
- c(() => {
237
+ let [Z, Q] = d(!1);
238
+ l(() => {
239
239
  if (!T || Z || !R?.getStoreOrder) return;
240
- let e = Me(R.getStoreOrder.currency);
240
+ let e = je(R.getStoreOrder.currency);
241
241
  J !== e && Y(e);
242
242
  }, [
243
243
  T,
@@ -245,23 +245,29 @@ var $e = () => {
245
245
  J,
246
246
  Y,
247
247
  R
248
- ]), c(() => {
248
+ ]), l(() => {
249
249
  if (E === "PLAN" && I?.getPlan?.pricingModel === "PER_SEAT") {
250
250
  let e = I.getPlan.minSeats ?? 1;
251
251
  P((t) => t < e ? e : t);
252
252
  }
253
- }, [I, E]), c(() => {
253
+ }, [I, E]), l(() => {
254
254
  E === "PLAN" && I?.getPlan?.pricingModel === "PER_SEAT" && Z && Q(!1);
255
- }, [N]), c(() => {
255
+ }, [N]), l(() => {
256
256
  if (!Z) {
257
257
  if (w && C && S.length > 0) {
258
258
  F.clearItems();
259
259
  for (let e of S) {
260
- let t = e.addon, n = t.features?.map((e) => ({
261
- id: e.quota?.id || e.id,
262
- name: e.quota?.name || "Feature",
263
- limits: e.quota?.limits
264
- })) || [], r = F.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
260
+ let t = e.addon, n = t.features?.map((e) => {
261
+ let t = e.quota?.limits, n = e.context && "quantity" in e.context ? Number(e.context.quantity) : void 0;
262
+ return {
263
+ id: e.quota?.id || e.id,
264
+ name: e.quota?.name || "Feature",
265
+ limits: n !== void 0 && t && "type" in t ? {
266
+ ...t,
267
+ value: n
268
+ } : t
269
+ };
270
+ }) || [], r = F.selectedCurrency || "USD", i = t.currencyPrices?.[r] ?? t.price, a = {
265
271
  id: t.id,
266
272
  type: "ADDON",
267
273
  name: t.name,
@@ -279,11 +285,17 @@ var $e = () => {
279
285
  return;
280
286
  }
281
287
  if (E === "PLAN" && I?.getPlan) {
282
- let e = I.getPlan, t = e.features?.map((e) => ({
283
- id: e.quota?.id || e.id,
284
- name: e.quota?.name || "Feature",
285
- limits: e.quota?.limits
286
- })) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
288
+ let e = I.getPlan, t = e.features?.map((e) => {
289
+ let t = e.quota?.limits, n = e.context && "quantity" in e.context ? Number(e.context.quantity) : void 0;
290
+ return {
291
+ id: e.quota?.id || e.id,
292
+ name: e.quota?.name || "Feature",
293
+ limits: n !== void 0 && t && "type" in t ? {
294
+ ...t,
295
+ value: n
296
+ } : t
297
+ };
298
+ }) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices, i = e.pricingModel === "PER_SEAT", a;
287
299
  if (i && e.pricePerSeat) {
288
300
  let t = r?.[n];
289
301
  a = (typeof t == "object" && t?.perSeat ? t.perSeat : e.pricePerSeat) * N;
@@ -291,29 +303,35 @@ var $e = () => {
291
303
  let t = r?.[n];
292
304
  a = typeof t == "number" ? t : e.price;
293
305
  }
294
- let o = i ? N : 1, ee = {
306
+ let o = r?.USD, ee = typeof o == "number" ? o : e.price, te = typeof o == "object" && o?.perSeat ? o.perSeat : e.pricePerSeat, s = i ? N : 1, ne = {
295
307
  id: e.id,
296
308
  type: "PLAN",
297
309
  name: e.name,
298
310
  description: typeof e.context == "object" && e.context !== null ? e.context.description : typeof e.context == "string" ? e.context : void 0,
299
311
  price: a,
300
- priceUSD: i && e.pricePerSeat ? e.pricePerSeat * o : e.price,
312
+ priceUSD: i && e.pricePerSeat ? (te ?? e.pricePerSeat) * s : ee,
301
313
  currency: n,
302
- quantity: o,
314
+ quantity: s,
303
315
  features: t,
304
316
  metadata: {
305
317
  planId: e.id,
306
318
  duration: e.duration,
307
- seatCount: i ? o : void 0
319
+ seatCount: i ? s : void 0
308
320
  }
309
321
  };
310
- F.addItem(ee), Q(!0);
322
+ F.addItem(ne), Q(!0);
311
323
  } else if (E === "ADDON" && !w && L?.getSelectedAddons?.[0]) {
312
- let e = L.getSelectedAddons[0], t = e.features?.map((e) => ({
313
- id: e.quota?.id || e.id,
314
- name: e.quota?.name || "Feature",
315
- limits: e.quota?.limits
316
- })) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
324
+ let e = L.getSelectedAddons[0], t = e.features?.map((e) => {
325
+ let t = e.quota?.limits, n = e.context && "quantity" in e.context ? Number(e.context.quantity) : void 0;
326
+ return {
327
+ id: e.quota?.id || e.id,
328
+ name: e.quota?.name || "Feature",
329
+ limits: n !== void 0 && t && "type" in t ? {
330
+ ...t,
331
+ value: n
332
+ } : t
333
+ };
334
+ }) || [], n = F.selectedCurrency || "USD", r = e.currencyPrices?.[n] ?? e.price, i = {
317
335
  id: e.id,
318
336
  type: "ADDON",
319
337
  name: e.name,
@@ -327,7 +345,7 @@ var $e = () => {
327
345
  };
328
346
  F.addItem(i), Q(!0);
329
347
  } else if (T && R?.getStoreOrder) {
330
- let e = R.getStoreOrder, t = je(e);
348
+ let e = R.getStoreOrder, t = Ae(e);
331
349
  for (let e of t) F.addItem(e);
332
350
  Q(!0);
333
351
  } else if (E === "CREDITS") {
@@ -358,7 +376,7 @@ var $e = () => {
358
376
  C,
359
377
  W,
360
378
  F.selectedCurrency
361
- ]), c(() => {
379
+ ]), l(() => {
362
380
  if (!(!T || !Z || F.convertedAmount === null)) {
363
381
  for (let e of F.items) if (e.type === "ORDER" && e.currency !== F.selectedCurrency) {
364
382
  let t = e.price * F.conversionRate;
@@ -373,13 +391,13 @@ var $e = () => {
373
391
  F.selectedCurrency,
374
392
  F.updateItemPrice
375
393
  ]);
376
- let $ = Ne(null);
377
- c(() => {
394
+ let $ = Me(null);
395
+ l(() => {
378
396
  if (z) if (B.shippingCost > 0) {
379
397
  let e = F.selectedCurrency, t = Rt !== e && F.convertedAmount !== null ? B.shippingCost * F.conversionRate : B.shippingCost, n = $.current;
380
398
  if (n && n.price === t && n.currency === e) return;
381
399
  n === null ? F.addItem({
382
- id: le,
400
+ id: ce,
383
401
  type: "ORDER",
384
402
  name: "Shipping",
385
403
  price: t,
@@ -389,11 +407,11 @@ var $e = () => {
389
407
  storeOrderId: g,
390
408
  isShipping: !0
391
409
  }
392
- }) : F.updateItemPrice(le, t, e), $.current = {
410
+ }) : F.updateItemPrice(ce, t, e), $.current = {
393
411
  price: t,
394
412
  currency: e
395
413
  };
396
- } else $.current !== null && ($.current = null, F.removeItem(le));
414
+ } else $.current !== null && ($.current = null, F.removeItem(ce));
397
415
  }, [
398
416
  z,
399
417
  B.shippingCost,
@@ -405,7 +423,7 @@ var $e = () => {
405
423
  F.addItem,
406
424
  F.updateItemPrice,
407
425
  F.removeItem
408
- ]), c(() => {
426
+ ]), l(() => {
409
427
  if (E === "CREDITS" && Z && W > 0) {
410
428
  let e = F.items.find((e) => e.id === "credits-purchase");
411
429
  e && e.price !== W && F.updateItemPrice("credits-purchase", W);
@@ -416,7 +434,7 @@ var $e = () => {
416
434
  W,
417
435
  F.items,
418
436
  F.updateItemPrice
419
- ]), c(() => {
437
+ ]), l(() => {
420
438
  if (!Z || F.items.length === 0) return;
421
439
  let e = F.selectedCurrency || "USD";
422
440
  for (let t of F.items) if (t.type === "PLAN" && I?.getPlan) {
@@ -444,7 +462,7 @@ var $e = () => {
444
462
  L,
445
463
  S,
446
464
  w
447
- ]), c(() => {
465
+ ]), l(() => {
448
466
  if (K.length > 0 && !F.billingAccount) {
449
467
  if (v?.billingAccountId) {
450
468
  let e = K.find((e) => e.id === v.billingAccountId);
@@ -473,7 +491,7 @@ var $e = () => {
473
491
  b
474
492
  ]);
475
493
  let rn = !!(v?.upgradeFromSubscriptionId || v?.downgradeFromSubscriptionId);
476
- c(() => {
494
+ l(() => {
477
495
  w && C && S.length === 0 && !Z && _("/addons", { replace: !0 });
478
496
  }, [
479
497
  C,
@@ -482,14 +500,14 @@ var $e = () => {
482
500
  Z,
483
501
  _
484
502
  ]);
485
- let an = pe({
503
+ let an = fe({
486
504
  billingAccountId: F.billingAccount?.id,
487
505
  purchaseType: E,
488
506
  productId: D
489
- }), on = s(async () => {
507
+ }), on = c(async () => {
490
508
  if (!F.billingAccount) return;
491
509
  let e = ht.current;
492
- if (ht.current = !1, !e && !De(F.billingAccount)) {
510
+ if (ht.current = !1, !e && !Ee(F.billingAccount)) {
493
511
  mt(!0);
494
512
  return;
495
513
  }
@@ -571,7 +589,7 @@ var $e = () => {
571
589
  g,
572
590
  Rt,
573
591
  Bt
574
- ]), sn = s((e) => {
592
+ ]), sn = c((e) => {
575
593
  y("billing.payment.succeeded", {
576
594
  route: "/billing/checkout",
577
595
  entityId: A?.paymentId ?? A?.orderId,
@@ -581,7 +599,7 @@ var $e = () => {
581
599
  y,
582
600
  A?.orderId,
583
601
  A?.paymentId
584
- ]), cn = s((e) => {
602
+ ]), cn = c((e) => {
585
603
  y("billing.payment.failed", {
586
604
  route: "/billing/checkout",
587
605
  entityId: A?.paymentId ?? A?.orderId,
@@ -592,11 +610,11 @@ var $e = () => {
592
610
  y,
593
611
  A?.orderId,
594
612
  A?.paymentId
595
- ]), ln = s((e) => {
613
+ ]), ln = c((e) => {
596
614
  F.updateItemQuantity("credits-purchase", e);
597
615
  }, [F]);
598
616
  if (!rt.canProcessPayment) return /* @__PURE__ */ p(t, { message: "You don't have permission to make purchases." });
599
- if (fe()) return /* @__PURE__ */ p(ge, {
617
+ if (de()) return /* @__PURE__ */ p(he, {
600
618
  purchaseType: E,
601
619
  productId: D,
602
620
  billingAccountId: F.billingAccount?.id,
@@ -618,9 +636,9 @@ var $e = () => {
618
636
  }
619
637
  }, fn = () => {
620
638
  switch (E) {
621
- case "CREDITS": return /* @__PURE__ */ p(Re, { className: "size-6" });
639
+ case "CREDITS": return /* @__PURE__ */ p(Le, { className: "size-6" });
622
640
  case "PLAN": return /* @__PURE__ */ p(Be, { className: "size-6" });
623
- case "ADDON": return /* @__PURE__ */ p(Ie, { className: "size-6" });
641
+ case "ADDON": return /* @__PURE__ */ p(Fe, { className: "size-6" });
624
642
  default: return /* @__PURE__ */ p(Ue, { className: "size-6" });
625
643
  }
626
644
  };
@@ -628,7 +646,7 @@ var $e = () => {
628
646
  className: "flex items-center justify-center min-h-[400px]",
629
647
  children: /* @__PURE__ */ m("div", {
630
648
  className: "text-center space-y-4",
631
- children: [/* @__PURE__ */ p(d, { className: "size-8 animate-spin mx-auto text-text-link" }), /* @__PURE__ */ p("p", {
649
+ children: [/* @__PURE__ */ p(ze, { className: "size-8 animate-spin mx-auto text-text-link" }), /* @__PURE__ */ p("p", {
632
650
  className: "text-text-secondary",
633
651
  children: h("billing.checkout.loadingCheckout", "Loading checkout...")
634
652
  })]
@@ -652,7 +670,7 @@ var $e = () => {
652
670
  className: "text-center space-y-4",
653
671
  children: [/* @__PURE__ */ p("div", {
654
672
  className: "inline-flex p-4 rounded-full bg-status-success-bg-subtle text-status-success-text",
655
- children: /* @__PURE__ */ p(Le, { className: "size-12" })
673
+ children: /* @__PURE__ */ p(Ie, { className: "size-12" })
656
674
  }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
657
675
  className: "text-2xl font-bold text-text-primary",
658
676
  children: h("billing.checkout.paymentSuccessful", "Payment Successful!")
@@ -677,8 +695,8 @@ var $e = () => {
677
695
  className: "flex items-center gap-2",
678
696
  children: [
679
697
  t.type === "PLAN" && /* @__PURE__ */ p(Be, { className: "size-4 text-accent-blue" }),
680
- t.type === "ADDON" && /* @__PURE__ */ p(Ie, { className: "size-4 text-accent-purple" }),
681
- t.type === "CREDITS" && /* @__PURE__ */ p(Re, { className: "size-4 text-status-warning-text" }),
698
+ t.type === "ADDON" && /* @__PURE__ */ p(Fe, { className: "size-4 text-accent-purple" }),
699
+ t.type === "CREDITS" && /* @__PURE__ */ p(Le, { className: "size-4 text-status-warning-text" }),
682
700
  t.type === "ORDER" && /* @__PURE__ */ p(Ue, { className: "size-4 text-status-success-text" }),
683
701
  /* @__PURE__ */ p("span", {
684
702
  className: "text-text-primary",
@@ -708,7 +726,7 @@ var $e = () => {
708
726
  children: M.paymentMethod === "credits" ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(We, { className: "size-4 text-status-warning-text" }), /* @__PURE__ */ p("span", {
709
727
  className: "font-medium text-text-primary",
710
728
  children: h("billing.checkout.credits", "Credits")
711
- })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
729
+ })] }) : /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(Re, { className: "size-4 text-accent-blue" }), /* @__PURE__ */ p("span", {
712
730
  className: "font-medium text-text-primary",
713
731
  children: h("billing.checkout.card", "Card")
714
732
  })] })
@@ -742,7 +760,7 @@ var $e = () => {
742
760
  children: t(M.previousBalance)
743
761
  })]
744
762
  }),
745
- /* @__PURE__ */ p(Fe, { className: "size-5 text-text-secondary shrink-0" }),
763
+ /* @__PURE__ */ p(Pe, { className: "size-5 text-text-secondary shrink-0" }),
746
764
  /* @__PURE__ */ m("div", {
747
765
  className: "flex-1 text-center p-3 rounded-lg bg-status-success-bg-subtle",
748
766
  children: [/* @__PURE__ */ p("p", {
@@ -795,7 +813,7 @@ var $e = () => {
795
813
  })]
796
814
  })
797
815
  ]
798
- }), gt && vt.length > 0 && x && bt && /* @__PURE__ */ p(ke, {
816
+ }), gt && vt.length > 0 && x && bt && /* @__PURE__ */ p(Oe, {
799
817
  billingAccountId: M?.billingAccountId ?? "",
800
818
  subscriptionId: bt,
801
819
  quotas: vt,
@@ -847,7 +865,7 @@ var $e = () => {
847
865
  children: [
848
866
  /* @__PURE__ */ p("div", {
849
867
  className: "inline-flex p-4 rounded-full bg-[var(--color-accent-soft)] text-text-link",
850
- children: /* @__PURE__ */ p(d, { className: "size-12 animate-spin" })
868
+ children: /* @__PURE__ */ p(ze, { className: "size-12 animate-spin" })
851
869
  }),
852
870
  /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("h1", {
853
871
  className: "text-2xl font-bold text-text-primary",
@@ -908,7 +926,7 @@ var $e = () => {
908
926
  type: "button",
909
927
  onClick: () => k("select"),
910
928
  className: "flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary",
911
- children: [/* @__PURE__ */ p(Pe, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
929
+ children: [/* @__PURE__ */ p(Ne, { className: "size-4" }), h("billing.checkout.backToCheckout", "Back to checkout")]
912
930
  }),
913
931
  /* @__PURE__ */ p(n, {
914
932
  title: h("billing.checkout.completePayment", "Complete Payment"),
@@ -1011,7 +1029,7 @@ var $e = () => {
1011
1029
  className: "rounded-lg border border-border-subtle bg-bg-surface overflow-hidden",
1012
1030
  children: /* @__PURE__ */ p("div", {
1013
1031
  className: "p-4 space-y-4",
1014
- children: /* @__PURE__ */ p(xe, {
1032
+ children: /* @__PURE__ */ p(be, {
1015
1033
  clientSecret: A.clientSecret,
1016
1034
  publishableKey: it || Dt?.stripePublishableKey || "",
1017
1035
  amount: Math.round((A.total ?? F.total) * 100),
@@ -1038,7 +1056,7 @@ var $e = () => {
1038
1056
  className: "text-sm text-text-secondary",
1039
1057
  children: "Save card for future purchases"
1040
1058
  })]
1041
- }), /* @__PURE__ */ p(Se, {
1059
+ }), /* @__PURE__ */ p(xe, {
1042
1060
  orderId: A.orderId,
1043
1061
  keyId: A.razorpayKeyId || at || "",
1044
1062
  amount: Math.round((A.total ?? F.total) * 100),
@@ -1065,7 +1083,7 @@ var $e = () => {
1065
1083
  type: "button",
1066
1084
  onClick: () => _(-1),
1067
1085
  className: "flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary mb-4",
1068
- children: [/* @__PURE__ */ p(Pe, { className: "size-4" }), "Back"]
1086
+ children: [/* @__PURE__ */ p(Ne, { className: "size-4" }), "Back"]
1069
1087
  }),
1070
1088
  /* @__PURE__ */ m("div", {
1071
1089
  className: "flex items-center gap-3 mb-6",
@@ -1143,7 +1161,7 @@ var $e = () => {
1143
1161
  children: [
1144
1162
  E === "CREDITS" && F.items[0] && /* @__PURE__ */ p("div", {
1145
1163
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6",
1146
- children: /* @__PURE__ */ p(be, {
1164
+ children: /* @__PURE__ */ p(ye, {
1147
1165
  value: F.items[0].quantity,
1148
1166
  onChange: ln,
1149
1167
  costPerCredit: W,
@@ -1153,21 +1171,21 @@ var $e = () => {
1153
1171
  }),
1154
1172
  /* @__PURE__ */ m("div", {
1155
1173
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1156
- children: [/* @__PURE__ */ p(_e, {
1174
+ children: [/* @__PURE__ */ p(ge, {
1157
1175
  accounts: K,
1158
1176
  selectedAccountId: F.billingAccount?.id ?? null,
1159
1177
  onSelect: F.setBillingAccount,
1160
1178
  isLoading: Nt,
1161
1179
  disabled: rn,
1162
1180
  disabledMessage: rn ? "Billing account is locked for plan changes" : void 0
1163
- }), E === "ADDON" && !T && F.billingAccount && /* @__PURE__ */ p(Ce, {
1181
+ }), E === "ADDON" && !T && F.billingAccount && /* @__PURE__ */ p(Se, {
1164
1182
  subscriptions: V,
1165
1183
  selectedSubscriptionId: F.selectedSubscriptionId,
1166
1184
  onSelect: F.setSelectedSubscriptionId,
1167
1185
  isLoading: Wt
1168
1186
  })]
1169
1187
  }),
1170
- z && /* @__PURE__ */ p(Oe, {
1188
+ z && /* @__PURE__ */ p(De, {
1171
1189
  storeOrderId: g,
1172
1190
  currency: F.selectedCurrency,
1173
1191
  onChange: zt
@@ -1175,7 +1193,7 @@ var $e = () => {
1175
1193
  /* @__PURE__ */ m("div", {
1176
1194
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 sm:p-6 space-y-4",
1177
1195
  children: [
1178
- /* @__PURE__ */ p(Te, {
1196
+ /* @__PURE__ */ p(we, {
1179
1197
  savedPaymentMethods: G,
1180
1198
  selectedPaymentMethodId: F.selectedPaymentMethodId,
1181
1199
  onSelectSavedCard: F.setSelectedPaymentMethodId,
@@ -1183,7 +1201,7 @@ var $e = () => {
1183
1201
  onSelectProvider: F.setPaymentProvider,
1184
1202
  stripeEnabled: Ot,
1185
1203
  razorpayEnabled: kt,
1186
- canPayWithCredits: F.canPayWithCredits && F.hasEnoughCredits,
1204
+ canPayWithCredits: F.canPayWithCredits,
1187
1205
  availableCredits: F.availableCredits,
1188
1206
  totalAmount: F.subtotalUSD,
1189
1207
  billingCountry: q,
@@ -1309,7 +1327,7 @@ var $e = () => {
1309
1327
  children: [
1310
1328
  /* @__PURE__ */ p("div", {
1311
1329
  className: "p-4",
1312
- children: /* @__PURE__ */ p(ve, {
1330
+ children: /* @__PURE__ */ p(_e, {
1313
1331
  items: F.items,
1314
1332
  subtotal: F.subtotal,
1315
1333
  discountAmount: F.discountAmount,
@@ -1327,7 +1345,7 @@ var $e = () => {
1327
1345
  }),
1328
1346
  /* @__PURE__ */ p("div", {
1329
1347
  className: "px-4 pb-4 border-t border-border-subtle pt-4",
1330
- children: /* @__PURE__ */ p(ye, {
1348
+ children: /* @__PURE__ */ p(ve, {
1331
1349
  value: F.promoCode,
1332
1350
  onChange: F.setPromoCode,
1333
1351
  onValidate: async () => await F.validatePromoCode(),
@@ -1346,7 +1364,7 @@ var $e = () => {
1346
1364
  } else (F.selectedProvider === "RAZORPAY" || F.selectedProvider === "STRIPE") && (e = F.selectedProvider === "RAZORPAY" ? "new card (Razorpay)" : "new card (Stripe)", t = !0, n = !0);
1347
1365
  return /* @__PURE__ */ p("div", {
1348
1366
  className: "px-4 pb-4",
1349
- children: /* @__PURE__ */ p(we, {
1367
+ children: /* @__PURE__ */ p(Ce, {
1350
1368
  enabled: F.autoRenew,
1351
1369
  onToggle: (e) => {
1352
1370
  F.setAutoRenew(e), e && F.selectedPaymentMethodId && F.setAutoRenewPaymentMethodId(F.selectedPaymentMethodId);
@@ -1364,7 +1382,7 @@ var $e = () => {
1364
1382
  onClick: on,
1365
1383
  disabled: F.isProcessing || !F.billingAccount || F.items.length === 0 || E === "ADDON" && !T && Wt || E === "ADDON" && !T && V.length === 0 || E === "ADDON" && !T && !F.selectedSubscriptionId || z && (!B.shippingAddressId || !B.shippingMethodId),
1366
1384
  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",
1367
- children: F.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(d, { className: "size-5 animate-spin" }), "Processing…"] }) : F.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1385
+ children: F.isProcessing ? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ze, { className: "size-5 animate-spin" }), "Processing…"] }) : F.selectedProvider === "CREDITS" ? "Pay with Credits" : "Proceed to Payment"
1368
1386
  }),
1369
1387
  /* @__PURE__ */ p("p", {
1370
1388
  className: "text-center text-xs text-text-secondary",
@@ -1374,7 +1392,7 @@ var $e = () => {
1374
1392
  })
1375
1393
  })]
1376
1394
  }),
1377
- pt && F.billingAccount && /* @__PURE__ */ p(Ee, {
1395
+ pt && F.billingAccount && /* @__PURE__ */ p(Te, {
1378
1396
  billingAccountId: F.billingAccount.id,
1379
1397
  hasPhone: !!F.billingAccount.contactNumber?.trim(),
1380
1398
  hasAddress: !!(F.billingAccount.billingAddresses?.[0]?.line1?.trim() && F.billingAccount.billingAddresses?.[0]?.postalCode?.trim()),