@schematichq/schematic-components 2.29.0 → 2.29.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.
@@ -4002,6 +4002,10 @@ function BillingArrearsCadenceFromJSONTyped(json, ignoreDiscriminator) {
4002
4002
  }
4003
4003
 
4004
4004
  // src/api/checkoutexternal/models/BillingCollectionMethod.ts
4005
+ var BillingCollectionMethod = {
4006
+ ChargeAutomatically: "charge_automatically",
4007
+ SendInvoice: "send_invoice"
4008
+ };
4005
4009
  function BillingCollectionMethodFromJSON(json) {
4006
4010
  return BillingCollectionMethodFromJSONTyped(json, false);
4007
4011
  }
@@ -6101,6 +6105,48 @@ function CompanyOverrideResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6101
6105
  };
6102
6106
  }
6103
6107
 
6108
+ // src/api/checkoutexternal/models/CompanyPaymentMethodResponseData.ts
6109
+ function CompanyPaymentMethodResponseDataFromJSON(json) {
6110
+ return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
6111
+ }
6112
+ function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6113
+ if (json == null) {
6114
+ return json;
6115
+ }
6116
+ return {
6117
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
6118
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
6119
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
6120
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
6121
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
6122
+ canRemove: json["can_remove"],
6123
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
6124
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
6125
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
6126
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
6127
+ externalId: json["external_id"],
6128
+ id: json["id"],
6129
+ isDefault: json["is_default"],
6130
+ type: json["type"]
6131
+ };
6132
+ }
6133
+
6134
+ // src/api/checkoutexternal/models/CompanyPaymentMethodsResponseData.ts
6135
+ function CompanyPaymentMethodsResponseDataFromJSON(json) {
6136
+ return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
6137
+ }
6138
+ function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6139
+ if (json == null) {
6140
+ return json;
6141
+ }
6142
+ return {
6143
+ count: json["count"],
6144
+ paymentMethods: json["payment_methods"].map(
6145
+ CompanyPaymentMethodResponseDataFromJSON
6146
+ )
6147
+ };
6148
+ }
6149
+
6104
6150
  // src/api/checkoutexternal/models/CompanyPlanInvalidReason.ts
6105
6151
  var CompanyPlanInvalidReason = {
6106
6152
  DowngradeNotPermitted: "downgrade_not_permitted",
@@ -7504,6 +7550,20 @@ function GetCompanyInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
7504
7550
  };
7505
7551
  }
7506
7552
 
7553
+ // src/api/checkoutexternal/models/GetCompanyPaymentMethodsResponse.ts
7554
+ function GetCompanyPaymentMethodsResponseFromJSON(json) {
7555
+ return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
7556
+ }
7557
+ function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
7558
+ if (json == null) {
7559
+ return json;
7560
+ }
7561
+ return {
7562
+ data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
7563
+ params: json["params"]
7564
+ };
7565
+ }
7566
+
7507
7567
  // src/api/checkoutexternal/models/GetCompanyUpcomingInvoiceResponse.ts
7508
7568
  function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
7509
7569
  return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
@@ -8398,6 +8458,38 @@ var CheckoutexternalApi = class extends BaseAPI {
8398
8458
  );
8399
8459
  return await response.value();
8400
8460
  }
8461
+ /**
8462
+ * Get company payment methods
8463
+ */
8464
+ async getCompanyPaymentMethodsRaw(initOverrides) {
8465
+ const queryParameters = {};
8466
+ const headerParameters = {};
8467
+ if (this.configuration && this.configuration.apiKey) {
8468
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
8469
+ "X-Schematic-Api-Key"
8470
+ );
8471
+ }
8472
+ const response = await this.request(
8473
+ {
8474
+ path: `/company/payment-methods`,
8475
+ method: "GET",
8476
+ headers: headerParameters,
8477
+ query: queryParameters
8478
+ },
8479
+ initOverrides
8480
+ );
8481
+ return new JSONApiResponse(
8482
+ response,
8483
+ (jsonValue) => GetCompanyPaymentMethodsResponseFromJSON(jsonValue)
8484
+ );
8485
+ }
8486
+ /**
8487
+ * Get company payment methods
8488
+ */
8489
+ async getCompanyPaymentMethods(initOverrides) {
8490
+ const response = await this.getCompanyPaymentMethodsRaw(initOverrides);
8491
+ return await response.value();
8492
+ }
8401
8493
  /**
8402
8494
  * Get company upcoming invoice
8403
8495
  */
@@ -13342,6 +13434,7 @@ var en = {
13342
13434
  "Error saving custom field values. Please try again.": "Error saving custom field values. Please try again.",
13343
13435
  "Pay now": "Pay now",
13344
13436
  "Payment Details": "Payment Details",
13437
+ "Payment due": "Payment due {{date}}",
13345
13438
  "Plan selected": "Plan selected",
13346
13439
  "Please accept the agreement to continue.": "Please accept the agreement to continue.",
13347
13440
  "Please try again later.": "Please try again later.",
@@ -15603,7 +15696,7 @@ var reducer = (state, action) => {
15603
15696
  // src/context/EmbedProvider.tsx
15604
15697
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
15605
15698
  var getCustomHeaders = (sessionId) => ({
15606
- "X-Schematic-Components-Version": "2.29.0",
15699
+ "X-Schematic-Components-Version": "2.29.1",
15607
15700
  "X-Schematic-Session-ID": sessionId
15608
15701
  });
15609
15702
  var normalizeCurrencyFilter = (filter2) => {
@@ -16389,6 +16482,29 @@ function useIsLightBackground() {
16389
16482
  return isLightBackground;
16390
16483
  }
16391
16484
 
16485
+ // src/hooks/useNextBillDate.ts
16486
+ import { useMemo as useMemo7 } from "react";
16487
+ function useNextBillDate(upcomingInvoice) {
16488
+ const { data } = useEmbed();
16489
+ const invoice = upcomingInvoice === void 0 ? data?.upcomingInvoice : upcomingInvoice;
16490
+ const subscription = data?.company?.billingSubscription;
16491
+ const cancelAtPeriodEnd = subscription?.cancelAtPeriodEnd;
16492
+ const periodEnd = subscription?.periodEnd;
16493
+ const collectionMethod = invoice?.collectionMethod;
16494
+ const dueDate = invoice?.dueDate ?? void 0;
16495
+ return useMemo7(() => {
16496
+ if (cancelAtPeriodEnd) {
16497
+ return { billDate: void 0, paymentDueDate: void 0 };
16498
+ }
16499
+ const billDate = periodEnd && periodEnd > 0 ? new Date(periodEnd * 1e3) : dueDate;
16500
+ const hasSeparateDeadline = collectionMethod === BillingCollectionMethod.SendInvoice && dueDate && billDate && new Date(dueDate).toDateString() !== new Date(billDate).toDateString();
16501
+ return {
16502
+ billDate,
16503
+ paymentDueDate: hasSeparateDeadline ? dueDate : void 0
16504
+ };
16505
+ }, [cancelAtPeriodEnd, periodEnd, collectionMethod, dueDate]);
16506
+ }
16507
+
16392
16508
  // src/hooks/usePaymentConfirmation.ts
16393
16509
  import { useCallback as useCallback4, useEffect as useEffect2, useRef as useRef3, useState } from "react";
16394
16510
  var usePaymentConfirmation = ({
@@ -16496,7 +16612,7 @@ var usePaymentConfirmation = ({
16496
16612
  };
16497
16613
 
16498
16614
  // src/hooks/useRequest.ts
16499
- import { useCallback as useCallback5, useMemo as useMemo7, useState as useState2 } from "react";
16615
+ import { useCallback as useCallback5, useMemo as useMemo8, useState as useState2 } from "react";
16500
16616
  function useRequest(fn) {
16501
16617
  const [isLoading, setIsLoading] = useState2(false);
16502
16618
  const [error, setError] = useState2(null);
@@ -16516,7 +16632,7 @@ function useRequest(fn) {
16516
16632
  setIsLoading(false);
16517
16633
  }
16518
16634
  }, [fn]);
16519
- const value = useMemo7(() => {
16635
+ const value = useMemo8(() => {
16520
16636
  const state = { isLoading, error, data };
16521
16637
  return [state, request];
16522
16638
  }, [isLoading, error, data, request]);
@@ -16524,11 +16640,11 @@ function useRequest(fn) {
16524
16640
  }
16525
16641
 
16526
16642
  // src/hooks/useTrialEnd.ts
16527
- import { useMemo as useMemo8 } from "react";
16643
+ import { useMemo as useMemo9 } from "react";
16528
16644
  function useTrialEnd() {
16529
16645
  const { data } = useEmbed();
16530
16646
  const { t: t3 } = useTranslation();
16531
- const { endDate, amount, units } = useMemo8(() => {
16647
+ const { endDate, amount, units } = useMemo9(() => {
16532
16648
  const billingSubscription = data?.company?.billingSubscription;
16533
16649
  const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
16534
16650
  let amount2;
@@ -16558,13 +16674,13 @@ function useTrialEnd() {
16558
16674
  }
16559
16675
 
16560
16676
  // src/hooks/useTruncatedList.ts
16561
- import { useCallback as useCallback6, useMemo as useMemo9, useState as useState3 } from "react";
16677
+ import { useCallback as useCallback6, useMemo as useMemo10, useState as useState3 } from "react";
16562
16678
  function useTruncatedList(items, { limit }) {
16563
16679
  const [isExpandedState, setIsExpanded] = useState3(false);
16564
16680
  const total = items.length;
16565
16681
  const canExpand = total > limit;
16566
16682
  const isExpanded = canExpand && isExpandedState;
16567
- const visibleItems = useMemo9(
16683
+ const visibleItems = useMemo10(
16568
16684
  () => canExpand && !isExpanded ? items.slice(0, limit) : items,
16569
16685
  [items, limit, canExpand, isExpanded]
16570
16686
  );
@@ -17045,7 +17161,7 @@ import {
17045
17161
  forwardRef,
17046
17162
  useImperativeHandle,
17047
17163
  useLayoutEffect as useLayoutEffect2,
17048
- useMemo as useMemo10,
17164
+ useMemo as useMemo11,
17049
17165
  useRef as useRef4
17050
17166
  } from "react";
17051
17167
 
@@ -17138,7 +17254,7 @@ var Dialog2 = forwardRef(
17138
17254
  document.body.style.overflow = initialOverflowValue;
17139
17255
  };
17140
17256
  }, [isModal]);
17141
- const dialog = useMemo10(
17257
+ const dialog = useMemo11(
17142
17258
  () => /* @__PURE__ */ jsx4(
17143
17259
  Dialog,
17144
17260
  {
@@ -18151,7 +18267,7 @@ var ButtonGroup = ({
18151
18267
  };
18152
18268
 
18153
18269
  // src/components/shared/checkout-dialog/Plan/Entitlement.tsx
18154
- import { useMemo as useMemo11 } from "react";
18270
+ import { useMemo as useMemo12 } from "react";
18155
18271
  import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
18156
18272
  var Entitlement = ({
18157
18273
  portal,
@@ -18181,7 +18297,7 @@ var Entitlement = ({
18181
18297
  tiersMode
18182
18298
  } = entitlementBillingPrice || {};
18183
18299
  const tiered = entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(entitlementBillingPrice);
18184
- const text = useMemo11(() => {
18300
+ const text = useMemo12(() => {
18185
18301
  if (!entitlement.feature) {
18186
18302
  return;
18187
18303
  }
@@ -18289,7 +18405,7 @@ var Entitlement = ({
18289
18405
  selectedCurrency,
18290
18406
  showWarningThresholdAsLimit
18291
18407
  ]);
18292
- const usageText = useMemo11(() => {
18408
+ const usageText = useMemo12(() => {
18293
18409
  if (!entitlement.feature) {
18294
18410
  return;
18295
18411
  }
@@ -18635,7 +18751,7 @@ var Plan = ({
18635
18751
  };
18636
18752
 
18637
18753
  // src/components/shared/checkout-dialog/AutoTopup.tsx
18638
- import { useMemo as useMemo12 } from "react";
18754
+ import { useMemo as useMemo13 } from "react";
18639
18755
  import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
18640
18756
  var AutoTopup = ({
18641
18757
  planCreditGrants,
@@ -18645,7 +18761,7 @@ var AutoTopup = ({
18645
18761
  const { settings } = useEmbed();
18646
18762
  const { t: t3, locale } = useTranslation();
18647
18763
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
18648
- const configurableCreditGrants = useMemo12(() => {
18764
+ const configurableCreditGrants = useMemo13(() => {
18649
18765
  return planCreditGrants.reduce(
18650
18766
  (acc, grant) => {
18651
18767
  if (isSelfServiceAutoTopupAvailable(grant)) {
@@ -18771,7 +18887,7 @@ var AutoTopup = ({
18771
18887
  };
18772
18888
 
18773
18889
  // src/components/shared/checkout-dialog/Quantity.tsx
18774
- import { useMemo as useMemo13 } from "react";
18890
+ import { useMemo as useMemo14 } from "react";
18775
18891
  import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
18776
18892
  var Quantity = ({
18777
18893
  portal,
@@ -18786,12 +18902,12 @@ var Quantity = ({
18786
18902
  const isLightBackground = useIsLightBackground();
18787
18903
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
18788
18904
  const unitPriceFontSize = 0.875 * settings.theme.typography.text.fontSize;
18789
- const planCredits = useMemo13(
18905
+ const planCredits = useMemo14(
18790
18906
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
18791
18907
  [selectedPlan?.includedCreditGrants]
18792
18908
  );
18793
18909
  const prorationBehavior = data?.checkoutSettings?.prorationBehavior;
18794
- const renewalDate = data?.upcomingInvoice?.dueDate ?? void 0;
18910
+ const { billDate: renewalDate } = useNextBillDate();
18795
18911
  return /* @__PURE__ */ jsx21(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce((acc, entitlement) => {
18796
18912
  if (entitlement.feature) {
18797
18913
  const entitlementBillingPrice = getEntitlementPrice(
@@ -19564,7 +19680,7 @@ var CustomCheckoutFields = ({
19564
19680
  };
19565
19681
 
19566
19682
  // src/components/shared/checkout-dialog/TaxIdField.tsx
19567
- import { useMemo as useMemo14 } from "react";
19683
+ import { useMemo as useMemo15 } from "react";
19568
19684
  import { jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
19569
19685
  var Select = Tt(Input2).attrs({ as: "select" })`
19570
19686
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23666' stroke-width='1.5' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
@@ -19579,7 +19695,7 @@ var TaxIdField = ({
19579
19695
  }) => {
19580
19696
  const { t: t3, locale } = useTranslation();
19581
19697
  const isLightBackground = useIsLightBackground();
19582
- const countryOptions = useMemo14(() => taxIdCountryOptions(locale), [locale]);
19698
+ const countryOptions = useMemo15(() => taxIdCountryOptions(locale), [locale]);
19583
19699
  const jurisdictions = taxIdJurisdictionsForCountry(value.country);
19584
19700
  const handleCountryChange = (country) => {
19585
19701
  const next2 = taxIdJurisdictionsForCountry(country);
@@ -19808,7 +19924,7 @@ import {
19808
19924
  useCallback as useCallback8,
19809
19925
  useEffect as useEffect3,
19810
19926
  useLayoutEffect as useLayoutEffect4,
19811
- useMemo as useMemo15,
19927
+ useMemo as useMemo16,
19812
19928
  useRef as useRef6,
19813
19929
  useState as useState8
19814
19930
  } from "react";
@@ -19972,7 +20088,7 @@ var CheckoutDialog = ({ top }) => {
19972
20088
  const [isModal, setIsModal] = useState8(true);
19973
20089
  const showPeriodToggle = data?.displaySettings?.showPeriodToggle ?? true;
19974
20090
  const trialPaymentMethodRequired = data?.trialPaymentMethodRequired === true;
19975
- const featureUsage = useMemo15(
20091
+ const featureUsage = useMemo16(
19976
20092
  () => data?.featureUsage?.features ?? [],
19977
20093
  [data?.featureUsage?.features]
19978
20094
  );
@@ -20028,7 +20144,7 @@ var CheckoutDialog = ({ top }) => {
20028
20144
  useSelectedPeriod: showPeriodToggle
20029
20145
  });
20030
20146
  const [selectedPlanId, setSelectedPlanId] = useState8(void 0);
20031
- const selectedPlan = useMemo15(() => {
20147
+ const selectedPlan = useMemo16(() => {
20032
20148
  if (selectedPlanId === null) {
20033
20149
  return void 0;
20034
20150
  }
@@ -20044,7 +20160,7 @@ var CheckoutDialog = ({ top }) => {
20044
20160
  );
20045
20161
  }, [availablePlans, checkoutState, selectedPlanId]);
20046
20162
  const [shouldTrial, setShouldTrial] = useState8(false);
20047
- const planCreditGrants = useMemo15(() => {
20163
+ const planCreditGrants = useMemo16(() => {
20048
20164
  const grants = mergeCompanyGrants(
20049
20165
  selectedPlan?.includedCreditGrants,
20050
20166
  data?.company?.plan?.includedCreditGrants
@@ -20090,11 +20206,11 @@ var CheckoutDialog = ({ top }) => {
20090
20206
  }
20091
20207
  return ids;
20092
20208
  });
20093
- const addOnCompatibilityLookup = useMemo15(
20209
+ const addOnCompatibilityLookup = useMemo16(
20094
20210
  () => buildAddOnCompatibilityLookup(data?.addOnCompatibilities),
20095
20211
  [data?.addOnCompatibilities]
20096
20212
  );
20097
- const addOns = useMemo15(() => {
20213
+ const addOns = useMemo16(() => {
20098
20214
  return availableAddOns.filter((availAddOn) => {
20099
20215
  if (hasCurrency && !planSupportsCurrency(availAddOn, effectiveCurrency)) {
20100
20216
  return false;
@@ -20123,7 +20239,7 @@ var CheckoutDialog = ({ top }) => {
20123
20239
  const [bundleCounts, setBundleCounts] = useState8({});
20124
20240
  const bundleCountsRef = useRef6(bundleCounts);
20125
20241
  const bundleGatingPlanId = selectedPlan?.id ?? data?.company?.plan?.id;
20126
- const creditBundles = useMemo15(() => {
20242
+ const creditBundles = useMemo16(() => {
20127
20243
  return deriveCreditBundles(
20128
20244
  data?.creditBundles,
20129
20245
  bundleGatingPlanId,
@@ -20133,7 +20249,7 @@ var CheckoutDialog = ({ top }) => {
20133
20249
  const [hasInitialPaymentMethod] = useState8(
20134
20250
  () => !!(data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId)
20135
20251
  );
20136
- const isCreditOnlyPurchase = useMemo15(
20252
+ const isCreditOnlyPurchase = useMemo16(
20137
20253
  () => isCreditOnlyCheckout({
20138
20254
  plan: selectedPlan,
20139
20255
  creditBundles,
@@ -20200,13 +20316,13 @@ var CheckoutDialog = ({ top }) => {
20200
20316
  checkoutState?.payInAdvanceQuantities
20201
20317
  );
20202
20318
  });
20203
- const payInAdvanceEntitlements = useMemo15(
20319
+ const payInAdvanceEntitlements = useMemo16(
20204
20320
  () => usageBasedEntitlements.filter(
20205
20321
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20206
20322
  ),
20207
20323
  [usageBasedEntitlements]
20208
20324
  );
20209
- const addOnPayInAdvanceEntitlements = useMemo15(
20325
+ const addOnPayInAdvanceEntitlements = useMemo16(
20210
20326
  () => addOnUsageBasedEntitlements.filter(
20211
20327
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20212
20328
  ),
@@ -20222,7 +20338,7 @@ var CheckoutDialog = ({ top }) => {
20222
20338
  }
20223
20339
  return values;
20224
20340
  });
20225
- const hasIncompleteRequiredCustomFields = useMemo15(() => {
20341
+ const hasIncompleteRequiredCustomFields = useMemo16(() => {
20226
20342
  return (data?.customCheckoutFields ?? []).some(
20227
20343
  (field) => field.required && !customFieldValues[field.id]?.trim()
20228
20344
  );
@@ -20272,12 +20388,12 @@ var CheckoutDialog = ({ top }) => {
20272
20388
  const [optInAccepted, setOptInAccepted] = useState8(false);
20273
20389
  const presentedOptInRef = useRef6(null);
20274
20390
  const [willScheduleDowngrade, setWillScheduleDowngrade] = useState8(false);
20275
- const willTrialWithoutPaymentMethod = useMemo15(
20391
+ const willTrialWithoutPaymentMethod = useMemo16(
20276
20392
  () => shouldTrial && !trialPaymentMethodRequired,
20277
20393
  [shouldTrial, trialPaymentMethodRequired]
20278
20394
  );
20279
20395
  const isSelectedPlanTrialable = selectedPlan && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
20280
- const checkoutStages = useMemo15(() => {
20396
+ const checkoutStages = useMemo16(() => {
20281
20397
  const stages = [];
20282
20398
  const checkoutStage2 = {
20283
20399
  id: "checkout",
@@ -20383,7 +20499,7 @@ var CheckoutDialog = ({ top }) => {
20383
20499
  }
20384
20500
  return "plan";
20385
20501
  });
20386
- const effectiveCheckoutStage = useMemo15(() => {
20502
+ const effectiveCheckoutStage = useMemo16(() => {
20387
20503
  if (isBypassLoading) return checkoutStage;
20388
20504
  let id = checkoutStage;
20389
20505
  if (id === "credits" && !checkoutStages.some((stage) => stage.id === id)) {
@@ -20399,7 +20515,7 @@ var CheckoutDialog = ({ top }) => {
20399
20515
  }, [checkoutStage, checkoutStages, checkoutState, isBypassLoading]);
20400
20516
  const previewRequestIdRef = useRef6(0);
20401
20517
  const planStageVisible = checkoutStages.some((stage) => stage.id === "plan") && !checkoutState?.bypassPlanSelection;
20402
- const checkoutStageCurrencies = useMemo15(() => {
20518
+ const checkoutStageCurrencies = useMemo16(() => {
20403
20519
  if (!selectedPlan) return currencies;
20404
20520
  return currencies.filter(
20405
20521
  (currency) => planOffersCurrencyForPeriod(selectedPlan, planPeriod, currency)
@@ -20972,7 +21088,7 @@ var CheckoutDialog = ({ top }) => {
20972
21088
  const activeCheckoutStage = checkoutStages.find(
20973
21089
  (stage) => stage.id === effectiveCheckoutStage
20974
21090
  );
20975
- const visibleStages = useMemo15(() => {
21091
+ const visibleStages = useMemo16(() => {
20976
21092
  if (!checkoutState?.hideSkippedStages) {
20977
21093
  return checkoutStages;
20978
21094
  }
@@ -20995,7 +21111,7 @@ var CheckoutDialog = ({ top }) => {
20995
21111
  return true;
20996
21112
  });
20997
21113
  }, [checkoutStages, checkoutState]);
20998
- const navigableStages = useMemo15(() => {
21114
+ const navigableStages = useMemo16(() => {
20999
21115
  return checkoutStages.filter((stage) => {
21000
21116
  if (stage.id === "plan" && checkoutState?.bypassPlanSelection) {
21001
21117
  return false;
@@ -21608,17 +21724,17 @@ var InvalidCurrencyNotice = ({
21608
21724
  import { useCallback as useCallback10, useLayoutEffect as useLayoutEffect5, useRef as useRef7, useState as useState10 } from "react";
21609
21725
 
21610
21726
  // src/components/shared/checkout-dialog/EditableCustomCheckoutFields.tsx
21611
- import { useCallback as useCallback9, useMemo as useMemo16, useState as useState9 } from "react";
21727
+ import { useCallback as useCallback9, useMemo as useMemo17, useState as useState9 } from "react";
21612
21728
  import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
21613
21729
  var EditableCustomCheckoutFields = () => {
21614
21730
  const { t: t3 } = useTranslation();
21615
21731
  const isLightBackground = useIsLightBackground();
21616
21732
  const { data, updateCustomFieldValues } = useEmbed();
21617
- const customCheckoutFields = useMemo16(
21733
+ const customCheckoutFields = useMemo17(
21618
21734
  () => data?.customCheckoutFields ?? [],
21619
21735
  [data?.customCheckoutFields]
21620
21736
  );
21621
- const serverFieldValues = useMemo16(() => {
21737
+ const serverFieldValues = useMemo17(() => {
21622
21738
  const values2 = {};
21623
21739
  for (const field of customCheckoutFields) {
21624
21740
  values2[field.id] = field.value ?? "";
@@ -21788,7 +21904,7 @@ import {
21788
21904
  useElements,
21789
21905
  useStripe
21790
21906
  } from "@stripe/react-stripe-js";
21791
- import { useEffect as useEffect4, useMemo as useMemo17, useRef as useRef8, useState as useState11 } from "react";
21907
+ import { useEffect as useEffect4, useMemo as useMemo18, useRef as useRef8, useState as useState11 } from "react";
21792
21908
  import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
21793
21909
  var PaymentForm = ({ onConfirm, financeData }) => {
21794
21910
  const { t: t3 } = useTranslation();
@@ -21819,7 +21935,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
21819
21935
  const [isAddressComplete, setIsAddressComplete] = useState11(
21820
21936
  () => !shouldCollectAddress
21821
21937
  );
21822
- const addressDefaultsKey = useMemo17(
21938
+ const addressDefaultsKey = useMemo18(
21823
21939
  () => JSON.stringify(billing ?? {}),
21824
21940
  [billing]
21825
21941
  );
@@ -21984,7 +22100,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
21984
22100
  };
21985
22101
 
21986
22102
  // src/components/shared/period-toggle/PeriodToggle.tsx
21987
- import { useMemo as useMemo18 } from "react";
22103
+ import { useMemo as useMemo19 } from "react";
21988
22104
  import { jsx as jsx37 } from "react/jsx-runtime";
21989
22105
  var PERIOD_MONTH_COUNT = {
21990
22106
  year: 12,
@@ -22000,7 +22116,7 @@ var PeriodToggle = ({
22000
22116
  const { t: t3 } = useTranslation();
22001
22117
  const { settings } = useEmbed();
22002
22118
  const isLightBackground = useIsLightBackground();
22003
- const savingsByPeriod = useMemo18(() => {
22119
+ const savingsByPeriod = useMemo19(() => {
22004
22120
  const result = {};
22005
22121
  if (!selectedPlan) {
22006
22122
  return result;
@@ -22157,10 +22273,10 @@ var PlanCreditText = ({
22157
22273
  };
22158
22274
 
22159
22275
  // src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
22160
- import { useMemo as useMemo20 } from "react";
22276
+ import { useMemo as useMemo21 } from "react";
22161
22277
 
22162
22278
  // src/components/shared/pricing-tiers-tooltip/PriceText.tsx
22163
- import { useMemo as useMemo19 } from "react";
22279
+ import { useMemo as useMemo20 } from "react";
22164
22280
  import { Fragment as Fragment12, jsx as jsx39, jsxs as jsxs27 } from "react/jsx-runtime";
22165
22281
  var PriceText = ({
22166
22282
  feature,
@@ -22171,7 +22287,7 @@ var PriceText = ({
22171
22287
  }) => {
22172
22288
  const { settings } = useEmbed();
22173
22289
  const { t: t3, locale } = useTranslation();
22174
- const text = useMemo19(() => {
22290
+ const text = useMemo20(() => {
22175
22291
  if (!flatAmount && perUnitPrice) {
22176
22292
  return /* @__PURE__ */ jsxs27(Fragment12, { children: [
22177
22293
  formatCurrency(perUnitPrice, { locale, currency }),
@@ -22228,7 +22344,7 @@ var PricingTiersTooltip = ({
22228
22344
  const { t: t3 } = useTranslation();
22229
22345
  const { settings } = useEmbed();
22230
22346
  const isLightBackground = useIsLightBackground();
22231
- const { tiers } = useMemo20(() => {
22347
+ const { tiers } = useMemo21(() => {
22232
22348
  return priceTiers.reduce(
22233
22349
  (acc, tier) => {
22234
22350
  const end = tier.upTo ?? Infinity;
@@ -22326,7 +22442,7 @@ import {
22326
22442
  forwardRef as forwardRef7,
22327
22443
  useCallback as useCallback11,
22328
22444
  useLayoutEffect as useLayoutEffect6,
22329
- useMemo as useMemo21,
22445
+ useMemo as useMemo22,
22330
22446
  useRef as useRef9,
22331
22447
  useState as useState13
22332
22448
  } from "react";
@@ -22928,7 +23044,7 @@ var SubscriptionSidebar = forwardRef7(
22928
23044
  billingSubscription,
22929
23045
  paymentMethod,
22930
23046
  trialPaymentMethodRequired
22931
- } = useMemo21(() => {
23047
+ } = useMemo22(() => {
22932
23048
  const currentEntitlements2 = data?.featureUsage?.features || [];
22933
23049
  return {
22934
23050
  currentPlan: data?.company?.plan,
@@ -22951,7 +23067,7 @@ var SubscriptionSidebar = forwardRef7(
22951
23067
  data?.subscription?.paymentMethod,
22952
23068
  data?.trialPaymentMethodRequired
22953
23069
  ]);
22954
- const planCreditGrants = useMemo21(() => {
23070
+ const planCreditGrants = useMemo22(() => {
22955
23071
  const grants = mergeCompanyGrants(
22956
23072
  selectedPlan?.includedCreditGrants,
22957
23073
  data?.company?.plan?.includedCreditGrants
@@ -22961,11 +23077,11 @@ var SubscriptionSidebar = forwardRef7(
22961
23077
  selectedPlan?.includedCreditGrants,
22962
23078
  data?.company?.plan?.includedCreditGrants
22963
23079
  ]);
22964
- const planCredits = useMemo21(
23080
+ const planCredits = useMemo22(
22965
23081
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
22966
23082
  [selectedPlan?.includedCreditGrants]
22967
23083
  );
22968
- const { payInAdvanceEntitlements } = useMemo21(() => {
23084
+ const { payInAdvanceEntitlements } = useMemo22(() => {
22969
23085
  const payAsYouGoEntitlements = [];
22970
23086
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
22971
23087
  (entitlement) => {
@@ -22977,7 +23093,7 @@ var SubscriptionSidebar = forwardRef7(
22977
23093
  );
22978
23094
  return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
22979
23095
  }, [usageBasedEntitlements]);
22980
- const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = useMemo21(() => {
23096
+ const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = useMemo22(() => {
22981
23097
  let planPrice;
22982
23098
  let resolvedCurrency;
22983
23099
  if (selectedPlan) {
@@ -23048,7 +23164,7 @@ var SubscriptionSidebar = forwardRef7(
23048
23164
  proration,
23049
23165
  taxAmount,
23050
23166
  taxDescription
23051
- } = useMemo21(() => {
23167
+ } = useMemo22(() => {
23052
23168
  return {
23053
23169
  amountOff: charges?.amountOff ?? 0,
23054
23170
  discountAmount: charges?.discountAmount ?? 0,
@@ -23118,7 +23234,7 @@ var SubscriptionSidebar = forwardRef7(
23118
23234
  }
23119
23235
  );
23120
23236
  };
23121
- const updatedUsageBasedEntitlements = useMemo21(() => {
23237
+ const updatedUsageBasedEntitlements = useMemo22(() => {
23122
23238
  const changedUsageBasedEntitlements = [];
23123
23239
  const allSelectedUsageBasedEntitlements = [
23124
23240
  ...usageBasedEntitlements,
@@ -23181,19 +23297,19 @@ var SubscriptionSidebar = forwardRef7(
23181
23297
  usageBasedEntitlements,
23182
23298
  addOnUsageBasedEntitlements
23183
23299
  ]);
23184
- const selectedAddOnsWithPrice = useMemo21(
23300
+ const selectedAddOnsWithPrice = useMemo22(
23185
23301
  () => addOns.filter(
23186
23302
  (addOn) => addOn.isSelected && getPlanPrice(addOn, void 0, void 0, currency)?.price
23187
23303
  ),
23188
23304
  [addOns, currency]
23189
23305
  );
23190
- const selectedOneTimeAddOns = useMemo21(
23306
+ const selectedOneTimeAddOns = useMemo22(
23191
23307
  () => addOns.filter(
23192
23308
  (addOn) => addOn.isSelected && addOn.chargeType === ChargeType.oneTime && getAddOnPrice(addOn, planPeriod, currency)?.price
23193
23309
  ),
23194
23310
  [addOns, planPeriod, currency]
23195
23311
  );
23196
- const { removedAddOns, willAddOnsChange } = useMemo21(() => {
23312
+ const { removedAddOns, willAddOnsChange } = useMemo22(() => {
23197
23313
  const addedAddOns = selectedAddOnsWithPrice.filter(
23198
23314
  (selected) => getPlanPrice(selected, void 0, void 0, currency)?.price && !currentAddOns.some((current) => selected.id === current.id)
23199
23315
  );
@@ -23209,15 +23325,15 @@ var SubscriptionSidebar = forwardRef7(
23209
23325
  willAddOnsChange: willAddOnsChange2
23210
23326
  };
23211
23327
  }, [currentAddOns, selectedAddOnsWithPrice, currency]);
23212
- const addedCreditBundles = useMemo21(
23328
+ const addedCreditBundles = useMemo22(
23213
23329
  () => creditBundles.filter((bundle) => bundle.count > 0),
23214
23330
  [creditBundles]
23215
23331
  );
23216
- const discountApplied = useMemo21(
23332
+ const discountApplied = useMemo22(
23217
23333
  () => promoCode && (amountOff > 0 || percentOff > 0),
23218
23334
  [promoCode, amountOff, percentOff]
23219
23335
  );
23220
- const subscriptionDiscount = useMemo21(
23336
+ const subscriptionDiscount = useMemo22(
23221
23337
  () => getSubscriptionDiscount(
23222
23338
  charges?.discounts,
23223
23339
  subscriptionTotal,
@@ -23377,7 +23493,7 @@ var SubscriptionSidebar = forwardRef7(
23377
23493
  }
23378
23494
  }, [t3, unsubscribe, setError, setIsLoading, setLayout]);
23379
23495
  const isSelectedPlanTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
23380
- const button = useMemo21(() => {
23496
+ const button = useMemo22(() => {
23381
23497
  const hasEntitlementDowngrade = payInAdvanceEntitlements.some((e) => e.quantity < e.usage) || addOnPayInAdvanceEntitlements.some((e) => e.quantity < e.usage);
23382
23498
  const canCheckout = error !== t3("Downgrade not permitted.") && !hasEntitlementDowngrade;
23383
23499
  const isSticky = !isButtonInView;
@@ -24105,14 +24221,14 @@ var SubscriptionSidebar = forwardRef7(
24105
24221
  SubscriptionSidebar.displayName = "SubscriptionSidebar";
24106
24222
 
24107
24223
  // src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
24108
- import { useMemo as useMemo22 } from "react";
24224
+ import { useMemo as useMemo23 } from "react";
24109
24225
  var TieredPricingDetails = ({
24110
24226
  entitlement,
24111
24227
  period,
24112
24228
  currency: selectedCurrency
24113
24229
  }) => {
24114
24230
  const { t: t3, locale } = useTranslation();
24115
- const { currency, flatAmount, perUnitPrice, upTo } = useMemo22(() => {
24231
+ const { currency, flatAmount, perUnitPrice, upTo } = useMemo23(() => {
24116
24232
  const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period, selectedCurrency) || {};
24117
24233
  const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
24118
24234
  return {
@@ -24160,7 +24276,7 @@ var TieredPricingDetails = ({
24160
24276
  };
24161
24277
 
24162
24278
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
24163
- import { useCallback as useCallback12, useLayoutEffect as useLayoutEffect7, useMemo as useMemo23, useRef as useRef10, useState as useState14 } from "react";
24279
+ import { useCallback as useCallback12, useLayoutEffect as useLayoutEffect7, useMemo as useMemo24, useRef as useRef10, useState as useState14 } from "react";
24164
24280
  import { jsx as jsx45, jsxs as jsxs33 } from "react/jsx-runtime";
24165
24281
  var UnsubscribeDialog = ({ top }) => {
24166
24282
  const { t: t3, locale } = useTranslation();
@@ -24177,8 +24293,9 @@ var UnsubscribeDialog = ({ top }) => {
24177
24293
  const [error, setError] = useState14();
24178
24294
  const [isLoading, setIsLoading] = useState14(false);
24179
24295
  const [isModal, setIsModal] = useState14(true);
24180
- const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo23(() => {
24181
- const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
24296
+ const { billDate } = useNextBillDate();
24297
+ const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo24(() => {
24298
+ const cancelDate2 = data?.subscription?.cancelAt || billDate;
24182
24299
  return {
24183
24300
  planPeriod: getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month",
24184
24301
  currentPlan: data?.company?.plan,
@@ -24192,10 +24309,10 @@ var UnsubscribeDialog = ({ top }) => {
24192
24309
  data?.company?.plan,
24193
24310
  data?.featureUsage,
24194
24311
  data?.subscription?.cancelAt,
24195
- data?.upcomingInvoice?.dueDate
24312
+ billDate
24196
24313
  ]);
24197
24314
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
24198
- const selectedPlan = useMemo23(
24315
+ const selectedPlan = useMemo24(
24199
24316
  () => availablePlans.find((plan) => plan.id === currentPlan?.id),
24200
24317
  [currentPlan?.id, availablePlans]
24201
24318
  );
@@ -24204,7 +24321,7 @@ var UnsubscribeDialog = ({ top }) => {
24204
24321
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
24205
24322
  []
24206
24323
  );
24207
- const addOns = useMemo23(
24324
+ const addOns = useMemo24(
24208
24325
  () => availableAddOns.map((available) => ({
24209
24326
  ...available,
24210
24327
  isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
@@ -24595,10 +24712,10 @@ var ButtonElement = forwardRef9(({ children, className, ...rest }, ref) => {
24595
24712
  ButtonElement.displayName = "Button";
24596
24713
 
24597
24714
  // src/components/elements/included-features/IncludedFeatures.tsx
24598
- import { Fragment as Fragment19, forwardRef as forwardRef10, useMemo as useMemo25 } from "react";
24715
+ import { Fragment as Fragment19, forwardRef as forwardRef10, useMemo as useMemo26 } from "react";
24599
24716
 
24600
24717
  // src/components/elements/included-features/UsageDetails.tsx
24601
- import { Fragment as Fragment17, useMemo as useMemo24 } from "react";
24718
+ import { Fragment as Fragment17, useMemo as useMemo25 } from "react";
24602
24719
  import { Fragment as Fragment18, jsx as jsx51, jsxs as jsxs37 } from "react/jsx-runtime";
24603
24720
  var UsageDetails = ({ entitlement, layout }) => {
24604
24721
  const {
@@ -24626,7 +24743,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24626
24743
  currentTier,
24627
24744
  tiersMode,
24628
24745
  tiered
24629
- } = useMemo24(() => {
24746
+ } = useMemo25(() => {
24630
24747
  const { billingPrice, amount, limit: limit2, cost: cost2, currentTier: currentTier2 } = getUsageDetails(
24631
24748
  entitlement,
24632
24749
  period,
@@ -24653,7 +24770,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24653
24770
  tiered: priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(billingPrice)
24654
24771
  };
24655
24772
  }, [entitlement, period, priceBehavior, showWarningThresholdAsLimit]);
24656
- const text = useMemo24(() => {
24773
+ const text = useMemo25(() => {
24657
24774
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
24658
24775
  return;
24659
24776
  }
@@ -24728,7 +24845,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24728
24845
  currentTier,
24729
24846
  showCredits
24730
24847
  ]);
24731
- const usageText = useMemo24(() => {
24848
+ const usageText = useMemo25(() => {
24732
24849
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
24733
24850
  return;
24734
24851
  }
@@ -24905,7 +25022,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
24905
25022
  const { t: t3, locale } = useTranslation();
24906
25023
  const { data, settings } = useEmbed();
24907
25024
  const isLightBackground = useIsLightBackground();
24908
- const { plan, addOns, featureUsage } = useMemo25(() => {
25025
+ const { plan, addOns, featureUsage } = useMemo26(() => {
24909
25026
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
24910
25027
  (acc, id) => {
24911
25028
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -25043,7 +25160,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
25043
25160
  IncludedFeatures.displayName = "IncludedFeatures";
25044
25161
 
25045
25162
  // src/components/elements/invoices/Invoices.tsx
25046
- import { forwardRef as forwardRef11, useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo26, useState as useState16 } from "react";
25163
+ import { forwardRef as forwardRef11, useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo27, useState as useState16 } from "react";
25047
25164
  import { Fragment as Fragment20, jsx as jsx53, jsxs as jsxs39 } from "react/jsx-runtime";
25048
25165
  function resolveDesignProps3(props) {
25049
25166
  return {
@@ -25111,11 +25228,11 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
25111
25228
  const [rawInvoices, setInvoices] = useState16(
25112
25229
  () => data && "invoices" in data ? data.invoices : rest.data
25113
25230
  );
25114
- const invoices = useMemo26(
25231
+ const invoices = useMemo27(
25115
25232
  () => formatInvoices(rawInvoices, locale),
25116
25233
  [rawInvoices, locale]
25117
25234
  );
25118
- const reachableInvoices = useMemo26(
25235
+ const reachableInvoices = useMemo27(
25119
25236
  () => invoices.slice(0, MAX_VISIBLE_INVOICE_COUNT),
25120
25237
  [invoices]
25121
25238
  );
@@ -25234,7 +25351,7 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
25234
25351
  Invoices.displayName = "Invoices";
25235
25352
 
25236
25353
  // src/components/elements/metered-features/MeteredFeatures.tsx
25237
- import { forwardRef as forwardRef12, useCallback as useCallback14, useMemo as useMemo28, useRef as useRef12, useState as useState18 } from "react";
25354
+ import { forwardRef as forwardRef12, useCallback as useCallback14, useMemo as useMemo29, useRef as useRef12, useState as useState18 } from "react";
25238
25355
 
25239
25356
  // src/components/elements/metered-features/Meter.tsx
25240
25357
  import { jsx as jsx54 } from "react/jsx-runtime";
@@ -25367,7 +25484,7 @@ var PriceDetails = ({
25367
25484
  };
25368
25485
 
25369
25486
  // src/components/elements/metered-features/UsageByUser.tsx
25370
- import { useEffect as useEffect6, useMemo as useMemo27, useState as useState17 } from "react";
25487
+ import { useEffect as useEffect6, useMemo as useMemo28, useState as useState17 } from "react";
25371
25488
  import { jsx as jsx56, jsxs as jsxs41 } from "react/jsx-runtime";
25372
25489
  var COLLAPSED_COUNT = 3;
25373
25490
  var EXPANDED_COUNT = 20;
@@ -25464,7 +25581,7 @@ var UsageByUser = ({ source, unit }) => {
25464
25581
  sourceKey
25465
25582
  ]);
25466
25583
  const entries = current?.section?.entries;
25467
- const attributed = useMemo27(
25584
+ const attributed = useMemo28(
25468
25585
  () => [...entries ?? []].sort((a2, b2) => b2.amount - a2.amount),
25469
25586
  [entries]
25470
25587
  );
@@ -25658,7 +25775,8 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25658
25775
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
25659
25776
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
25660
25777
  const isLightBackground = useIsLightBackground();
25661
- const meteredFeatures = useMemo28(() => {
25778
+ const { billDate: renewalDate } = useNextBillDate();
25779
+ const meteredFeatures = useMemo29(() => {
25662
25780
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
25663
25781
  (acc, id) => {
25664
25782
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -25675,7 +25793,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25675
25793
  ({ feature }) => feature?.featureType === FeatureType.Event || feature?.featureType === FeatureType.Trait
25676
25794
  );
25677
25795
  }, [props.visibleFeatures, data?.featureUsage?.features]);
25678
- const creditGroups = useMemo28(
25796
+ const creditGroups = useMemo29(
25679
25797
  () => withEmptyPlanCreditBalances(
25680
25798
  aggregateActiveGrantsByCredit(data?.creditGrants || []),
25681
25799
  listPlanCredits(
@@ -25686,7 +25804,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25686
25804
  ),
25687
25805
  [data?.creditGrants, data?.featureUsage?.features, data?.company]
25688
25806
  );
25689
- const planCreditCompositions = useMemo28(
25807
+ const planCreditCompositions = useMemo29(
25690
25808
  () => groupPlanCreditGrants(data?.company?.plan?.includedCreditGrants ?? []),
25691
25809
  [data?.company?.plan?.includedCreditGrants]
25692
25810
  );
@@ -25700,7 +25818,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25700
25818
  },
25701
25819
  [data?.featureUsage?.features]
25702
25820
  );
25703
- const purchasableCreditIds = useMemo28(
25821
+ const purchasableCreditIds = useMemo29(
25704
25822
  () => getPurchasableCreditIds(data?.creditBundles, data?.company?.plan?.id),
25705
25823
  [data?.creditBundles, data?.company?.plan?.id]
25706
25824
  );
@@ -25945,7 +26063,6 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25945
26063
  })
25946
26064
  );
25947
26065
  }
25948
- const renewalDate = data?.upcomingInvoice?.dueDate;
25949
26066
  return (
25950
26067
  // Pulled up against the balance line despite the column's 2rem gap
25951
26068
  /* @__PURE__ */ jsx57(Box, { $marginTop: "-1.5rem", children: /* @__PURE__ */ jsxs42(
@@ -26106,10 +26223,10 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
26106
26223
  MeteredFeatures.displayName = "MeteredFeatures";
26107
26224
 
26108
26225
  // src/components/elements/payment-method/PaymentMethod.tsx
26109
- import { forwardRef as forwardRef13, useMemo as useMemo30 } from "react";
26226
+ import { forwardRef as forwardRef13, useMemo as useMemo31 } from "react";
26110
26227
 
26111
26228
  // src/components/elements/payment-method/PaymentMethodElement.tsx
26112
- import { useMemo as useMemo29 } from "react";
26229
+ import { useMemo as useMemo30 } from "react";
26113
26230
  import { jsx as jsx58, jsxs as jsxs43 } from "react/jsx-runtime";
26114
26231
  var PaymentElement2 = ({
26115
26232
  iconName,
@@ -26285,7 +26402,7 @@ var PaymentListElement = ({
26285
26402
  const { settings } = useEmbed();
26286
26403
  const isLightBackground = useIsLightBackground();
26287
26404
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
26288
- const expirationDate = useMemo29(() => {
26405
+ const expirationDate = useMemo30(() => {
26289
26406
  const { cardExpMonth, cardExpYear } = paymentMethod;
26290
26407
  if (!cardExpMonth || !cardExpYear) {
26291
26408
  return;
@@ -26380,7 +26497,7 @@ var resolveDesignProps5 = (props) => {
26380
26497
  var PaymentMethod = forwardRef13(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
26381
26498
  const props = resolveDesignProps5(rest);
26382
26499
  const { data, setLayout } = useEmbed();
26383
- const { paymentMethod, monthsToExpiration } = useMemo30(() => {
26500
+ const { paymentMethod, monthsToExpiration } = useMemo31(() => {
26384
26501
  const paymentMethod2 = data?.subscription?.paymentMethod || data?.company?.defaultPaymentMethod;
26385
26502
  let monthsToExpiration2;
26386
26503
  if (typeof paymentMethod2?.cardExpYear === "number" && typeof paymentMethod2?.cardExpMonth === "number") {
@@ -26584,7 +26701,7 @@ var loadStripe = function loadStripe2() {
26584
26701
  };
26585
26702
 
26586
26703
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
26587
- import { useCallback as useCallback15, useEffect as useEffect7, useMemo as useMemo31, useState as useState19 } from "react";
26704
+ import { useCallback as useCallback15, useEffect as useEffect7, useMemo as useMemo32, useState as useState19 } from "react";
26588
26705
  import { jsx as jsx60, jsxs as jsxs44 } from "react/jsx-runtime";
26589
26706
  var resolveDesignProps6 = () => {
26590
26707
  return {
@@ -26613,7 +26730,7 @@ var PaymentMethodDetails = ({
26613
26730
  updatePaymentMethod,
26614
26731
  deletePaymentMethod
26615
26732
  } = useEmbed();
26616
- const { defaultPaymentMethod, paymentMethods, subscription } = useMemo31(() => {
26733
+ const { defaultPaymentMethod, paymentMethods, subscription } = useMemo32(() => {
26617
26734
  return {
26618
26735
  defaultPaymentMethod: data?.company?.defaultPaymentMethod,
26619
26736
  paymentMethods: data?.company?.paymentMethods || [],
@@ -26645,7 +26762,7 @@ var PaymentMethodDetails = ({
26645
26762
  },
26646
26763
  autoConfirm: true
26647
26764
  });
26648
- const monthsToExpiration = useMemo31(() => {
26765
+ const monthsToExpiration = useMemo32(() => {
26649
26766
  let expiration;
26650
26767
  if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
26651
26768
  const now = /* @__PURE__ */ new Date();
@@ -26668,7 +26785,7 @@ var PaymentMethodDetails = ({
26668
26785
  const toggleShowPaymentMethods = () => {
26669
26786
  setShowDifferentPaymentMethods((prev2) => !prev2);
26670
26787
  };
26671
- const locale = useMemo31(() => stripeLocale(language), [language]);
26788
+ const locale = useMemo32(() => stripeLocale(language), [language]);
26672
26789
  const initializeStripe = useCallback15(() => {
26673
26790
  if (stripe || !setupIntent) {
26674
26791
  return;
@@ -26928,7 +27045,7 @@ var PaymentMethodDetails = ({
26928
27045
  };
26929
27046
 
26930
27047
  // src/components/elements/plan-manager/PlanManager.tsx
26931
- import { forwardRef as forwardRef14, useMemo as useMemo33 } from "react";
27048
+ import { forwardRef as forwardRef14, useMemo as useMemo34 } from "react";
26932
27049
 
26933
27050
  // src/components/elements/plan-manager/AddOn.tsx
26934
27051
  import { jsx as jsx61, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -26954,7 +27071,7 @@ var AddOn = ({ addOn, currency, period, layout }) => {
26954
27071
  };
26955
27072
 
26956
27073
  // src/components/elements/plan-manager/UsageDetails.tsx
26957
- import { Fragment as Fragment23, useMemo as useMemo32 } from "react";
27074
+ import { Fragment as Fragment23, useMemo as useMemo33 } from "react";
26958
27075
  import { Fragment as Fragment24, jsx as jsx62, jsxs as jsxs46 } from "react/jsx-runtime";
26959
27076
  var UsageDetails2 = ({
26960
27077
  entitlement,
@@ -26970,13 +27087,13 @@ var UsageDetails2 = ({
26970
27087
  billingPrice,
26971
27088
  limit,
26972
27089
  cost = 0
26973
- } = useMemo32(
27090
+ } = useMemo33(
26974
27091
  () => getUsageDetails(entitlement, period, currency, {
26975
27092
  showWarningThresholdAsLimit
26976
27093
  }),
26977
27094
  [entitlement, period, currency, showWarningThresholdAsLimit]
26978
27095
  );
26979
- const description = useMemo32(() => {
27096
+ const description = useMemo33(() => {
26980
27097
  const acc = [];
26981
27098
  let index = 0;
26982
27099
  if (entitlement.priceBehavior === EntitlementPriceBehavior.Overage) {
@@ -27155,7 +27272,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27155
27272
  showCredits,
27156
27273
  showZeroPriceAsFree,
27157
27274
  trialPaymentMethodRequired
27158
- } = useMemo33(() => {
27275
+ } = useMemo34(() => {
27159
27276
  const planCreditOrder = /* @__PURE__ */ new Map();
27160
27277
  (data?.company?.plan?.includedCreditGrants ?? []).forEach((grant) => {
27161
27278
  if (!planCreditOrder.has(grant.creditId)) {
@@ -27215,15 +27332,15 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27215
27332
  data?.displaySettings?.showZeroPriceAsFree,
27216
27333
  data?.trialPaymentMethodRequired
27217
27334
  ]);
27218
- const usageBasedEntitlements = useMemo33(
27335
+ const usageBasedEntitlements = useMemo34(
27219
27336
  () => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
27220
27337
  [featureUsage]
27221
27338
  );
27222
- const planCreditCompositions = useMemo33(
27339
+ const planCreditCompositions = useMemo34(
27223
27340
  () => groupPlanCreditGrants(currentPlan?.includedCreditGrants ?? []),
27224
27341
  [currentPlan?.includedCreditGrants]
27225
27342
  );
27226
- const resolveLicenseQuantity = useMemo33(() => {
27343
+ const resolveLicenseQuantity = useMemo34(() => {
27227
27344
  return (licenseId) => {
27228
27345
  const allocation = findLicenseSource(featureUsage, licenseId)?.allocation;
27229
27346
  return typeof allocation === "number" ? allocation : void 0;
@@ -27246,7 +27363,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27246
27363
  subscriptionCurrency,
27247
27364
  willSubscriptionCancel,
27248
27365
  isTrialSubscription
27249
- } = useMemo33(() => {
27366
+ } = useMemo34(() => {
27250
27367
  const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
27251
27368
  const subscriptionCurrency2 = billingSubscription?.currency;
27252
27369
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
@@ -27259,7 +27376,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27259
27376
  };
27260
27377
  }, [billingSubscription]);
27261
27378
  const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
27262
- const { isFreePlan, isUsageBasedPlan } = useMemo33(() => {
27379
+ const { isFreePlan, isUsageBasedPlan } = useMemo34(() => {
27263
27380
  const isFreePlan2 = currentPlan?.planPrice === 0;
27264
27381
  const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
27265
27382
  return { isFreePlan: isFreePlan2, isUsageBasedPlan: isUsageBasedPlan2 };
@@ -27908,12 +28025,12 @@ import {
27908
28025
  forwardRef as forwardRef15,
27909
28026
  useCallback as useCallback16,
27910
28027
  useEffect as useEffect8,
27911
- useMemo as useMemo35,
28028
+ useMemo as useMemo36,
27912
28029
  useState as useState21
27913
28030
  } from "react";
27914
28031
 
27915
28032
  // src/components/elements/pricing-table/AddOn.tsx
27916
- import { useMemo as useMemo34 } from "react";
28033
+ import { useMemo as useMemo35 } from "react";
27917
28034
  import { Fragment as Fragment26, jsx as jsx64, jsxs as jsxs48 } from "react/jsx-runtime";
27918
28035
  function renderMeteredEntitlementPricing2({
27919
28036
  priceBehavior,
@@ -27971,7 +28088,7 @@ var AddOn2 = ({
27971
28088
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
27972
28089
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
27973
28090
  const isLightBackground = useIsLightBackground();
27974
- const { currentAddOns, canCheckout, isStandalone } = useMemo34(() => {
28091
+ const { currentAddOns, canCheckout, isStandalone } = useMemo35(() => {
27975
28092
  const isStandalone2 = typeof data?.component === "undefined";
27976
28093
  return {
27977
28094
  currentAddOns: data?.company?.addOns || [],
@@ -28845,13 +28962,13 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
28845
28962
  } = useAvailablePlans(selectedPeriod, {
28846
28963
  useSelectedPeriod: showPeriodToggle
28847
28964
  });
28848
- const plans = useMemo35(
28965
+ const plans = useMemo36(
28849
28966
  () => hasCurrency ? allPlans.filter(
28850
28967
  (plan) => planSupportsCurrency(plan, selectedCurrency)
28851
28968
  ) : allPlans,
28852
28969
  [allPlans, hasCurrency, selectedCurrency]
28853
28970
  );
28854
- const addOns = useMemo35(
28971
+ const addOns = useMemo36(
28855
28972
  () => hasCurrency ? allAddOns.filter(
28856
28973
  (addOn) => planSupportsCurrency(addOn, selectedCurrency)
28857
28974
  ) : allAddOns,
@@ -29064,7 +29181,7 @@ var TextElement = forwardRef16(({ children, className, ...rest }, ref) => {
29064
29181
  TextElement.displayName = "Text";
29065
29182
 
29066
29183
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
29067
- import { forwardRef as forwardRef17, useMemo as useMemo36 } from "react";
29184
+ import { forwardRef as forwardRef17, useMemo as useMemo37 } from "react";
29068
29185
  import { jsx as jsx69 } from "react/jsx-runtime";
29069
29186
  var buttonStyles = {
29070
29187
  primary: {
@@ -29095,7 +29212,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
29095
29212
  const props = resolveDesignProps10(rest);
29096
29213
  const { t: t3 } = useTranslation();
29097
29214
  const { data, setLayout } = useEmbed();
29098
- const hasActiveSubscription = useMemo36(() => {
29215
+ const hasActiveSubscription = useMemo37(() => {
29099
29216
  return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
29100
29217
  }, [data?.subscription]);
29101
29218
  if (!hasActiveSubscription) {
@@ -29130,7 +29247,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
29130
29247
  UnsubscribeButton.displayName = "UnsubscribeButton";
29131
29248
 
29132
29249
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
29133
- import { forwardRef as forwardRef18, useCallback as useCallback17, useEffect as useEffect9, useMemo as useMemo37, useState as useState22 } from "react";
29250
+ import { forwardRef as forwardRef18, useCallback as useCallback17, useEffect as useEffect9, useMemo as useMemo38, useState as useState22 } from "react";
29134
29251
  import { jsx as jsx70, jsxs as jsxs52 } from "react/jsx-runtime";
29135
29252
  function resolveDesignProps11(props) {
29136
29253
  return {
@@ -29158,7 +29275,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29158
29275
  const [isLoading, setIsLoading] = useState22(false);
29159
29276
  const [error, setError] = useState22();
29160
29277
  const [upcomingInvoice, setUpcomingInvoice] = useState22(data?.upcomingInvoice);
29161
- const discounts = useMemo37(() => {
29278
+ const discounts = useMemo38(() => {
29162
29279
  return (data?.subscription?.discounts || []).filter(
29163
29280
  (discount) => (
29164
29281
  // Only surface discounts that are currently active and actually
@@ -29200,7 +29317,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29200
29317
  setUpcomingInvoice(data.upcomingInvoice);
29201
29318
  }
29202
29319
  }, [data?.upcomingInvoice]);
29203
- const { currency, applied, remaining } = useMemo37(() => {
29320
+ const { currency, applied, remaining } = useMemo38(() => {
29204
29321
  const currency2 = upcomingInvoice?.currency;
29205
29322
  const startingBalance = upcomingInvoice?.startingBalance ?? 0;
29206
29323
  const endingBalance = upcomingInvoice?.endingBalance ?? 0;
@@ -29214,6 +29331,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29214
29331
  upcomingInvoice?.endingBalance,
29215
29332
  upcomingInvoice?.subtotal
29216
29333
  ]);
29334
+ const { billDate, paymentDueDate } = useNextBillDate(upcomingInvoice ?? null);
29217
29335
  const hasApplied = applied > 0;
29218
29336
  const hasBalance = remaining > 0 || applied > 0;
29219
29337
  if (!data?.subscription || data.subscription.cancelAt) {
@@ -29245,10 +29363,21 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29245
29363
  ]
29246
29364
  }
29247
29365
  ) : !isLoading && /* @__PURE__ */ jsx70(TransitionBox, { children: upcomingInvoice ? /* @__PURE__ */ jsxs52(Flex, { $flexDirection: "column", $gap: "1rem", children: [
29248
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsxs52(Text, { display: props.header.fontStyle, children: [
29249
- t3(props.header.prefix),
29250
- " ",
29251
- toPrettyDate(upcomingInvoice.dueDate, { locale })
29366
+ props.header.isVisible && upcomingInvoice.dueDate && billDate && /* @__PURE__ */ jsxs52(Flex, { $flexDirection: "column", $gap: "0.25rem", children: [
29367
+ /* @__PURE__ */ jsxs52(Text, { display: props.header.fontStyle, children: [
29368
+ t3(props.header.prefix),
29369
+ " ",
29370
+ toPrettyDate(billDate, { locale })
29371
+ ] }),
29372
+ paymentDueDate && /* @__PURE__ */ jsx70(
29373
+ Text,
29374
+ {
29375
+ $size: 0.8125 * settings.theme.typography.text.fontSize,
29376
+ children: t3("Payment due", {
29377
+ date: toPrettyDate(paymentDueDate, { locale })
29378
+ })
29379
+ }
29380
+ )
29252
29381
  ] }),
29253
29382
  /* @__PURE__ */ jsxs52(
29254
29383
  Flex,
@@ -31990,7 +32119,7 @@ function inflate(input, options = {}) {
31990
32119
  }
31991
32120
 
31992
32121
  // src/components/embed/Embed.tsx
31993
- import { useContext as useContext3, useEffect as useEffect10, useMemo as useMemo38 } from "react";
32122
+ import { useContext as useContext3, useEffect as useEffect10, useMemo as useMemo39 } from "react";
31994
32123
 
31995
32124
  // src/components/embed/renderer.ts
31996
32125
  import { createElement } from "react";
@@ -32120,7 +32249,7 @@ var SchematicEmbed = ({ id, accessToken }) => {
32120
32249
  setBuilderSettings
32121
32250
  } = useEmbed();
32122
32251
  const compressedAst = data?.component?.ast;
32123
- const { children, parsedSettings, parseError } = useMemo38(() => {
32252
+ const { children, parsedSettings, parseError } = useMemo39(() => {
32124
32253
  let children2 = null;
32125
32254
  let parsedSettings2 = null;
32126
32255
  let parseError2 = null;
@@ -32275,6 +32404,7 @@ export {
32275
32404
  useCustomPlanBilling,
32276
32405
  useEmbed,
32277
32406
  useIsLightBackground,
32407
+ useNextBillDate,
32278
32408
  usePaymentConfirmation,
32279
32409
  useRequest,
32280
32410
  useSubscriptionCurrency,