@schematichq/schematic-components 2.29.0 → 2.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3877,6 +3877,10 @@ function BillingArrearsCadenceFromJSONTyped(json, ignoreDiscriminator) {
3877
3877
  }
3878
3878
 
3879
3879
  // src/api/checkoutexternal/models/BillingCollectionMethod.ts
3880
+ var BillingCollectionMethod = {
3881
+ ChargeAutomatically: "charge_automatically",
3882
+ SendInvoice: "send_invoice"
3883
+ };
3880
3884
  function BillingCollectionMethodFromJSON(json) {
3881
3885
  return BillingCollectionMethodFromJSONTyped(json, false);
3882
3886
  }
@@ -5976,6 +5980,48 @@ function CompanyOverrideResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5976
5980
  };
5977
5981
  }
5978
5982
 
5983
+ // src/api/checkoutexternal/models/CompanyPaymentMethodResponseData.ts
5984
+ function CompanyPaymentMethodResponseDataFromJSON(json) {
5985
+ return CompanyPaymentMethodResponseDataFromJSONTyped(json, false);
5986
+ }
5987
+ function CompanyPaymentMethodResponseDataFromJSONTyped(json, ignoreDiscriminator) {
5988
+ if (json == null) {
5989
+ return json;
5990
+ }
5991
+ return {
5992
+ accountLast4: json["account_last4"] == null ? void 0 : json["account_last4"],
5993
+ accountName: json["account_name"] == null ? void 0 : json["account_name"],
5994
+ bankName: json["bank_name"] == null ? void 0 : json["bank_name"],
5995
+ billingEmail: json["billing_email"] == null ? void 0 : json["billing_email"],
5996
+ billingName: json["billing_name"] == null ? void 0 : json["billing_name"],
5997
+ canRemove: json["can_remove"],
5998
+ cardBrand: json["card_brand"] == null ? void 0 : json["card_brand"],
5999
+ cardExpMonth: json["card_exp_month"] == null ? void 0 : json["card_exp_month"],
6000
+ cardExpYear: json["card_exp_year"] == null ? void 0 : json["card_exp_year"],
6001
+ cardLast4: json["card_last4"] == null ? void 0 : json["card_last4"],
6002
+ externalId: json["external_id"],
6003
+ id: json["id"],
6004
+ isDefault: json["is_default"],
6005
+ type: json["type"]
6006
+ };
6007
+ }
6008
+
6009
+ // src/api/checkoutexternal/models/CompanyPaymentMethodsResponseData.ts
6010
+ function CompanyPaymentMethodsResponseDataFromJSON(json) {
6011
+ return CompanyPaymentMethodsResponseDataFromJSONTyped(json, false);
6012
+ }
6013
+ function CompanyPaymentMethodsResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6014
+ if (json == null) {
6015
+ return json;
6016
+ }
6017
+ return {
6018
+ count: json["count"],
6019
+ paymentMethods: json["payment_methods"].map(
6020
+ CompanyPaymentMethodResponseDataFromJSON
6021
+ )
6022
+ };
6023
+ }
6024
+
5979
6025
  // src/api/checkoutexternal/models/CompanyPlanInvalidReason.ts
5980
6026
  var CompanyPlanInvalidReason = {
5981
6027
  DowngradeNotPermitted: "downgrade_not_permitted",
@@ -7379,6 +7425,20 @@ function GetCompanyInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
7379
7425
  };
7380
7426
  }
7381
7427
 
7428
+ // src/api/checkoutexternal/models/GetCompanyPaymentMethodsResponse.ts
7429
+ function GetCompanyPaymentMethodsResponseFromJSON(json) {
7430
+ return GetCompanyPaymentMethodsResponseFromJSONTyped(json, false);
7431
+ }
7432
+ function GetCompanyPaymentMethodsResponseFromJSONTyped(json, ignoreDiscriminator) {
7433
+ if (json == null) {
7434
+ return json;
7435
+ }
7436
+ return {
7437
+ data: CompanyPaymentMethodsResponseDataFromJSON(json["data"]),
7438
+ params: json["params"]
7439
+ };
7440
+ }
7441
+
7382
7442
  // src/api/checkoutexternal/models/GetCompanyUpcomingInvoiceResponse.ts
7383
7443
  function GetCompanyUpcomingInvoiceResponseFromJSON(json) {
7384
7444
  return GetCompanyUpcomingInvoiceResponseFromJSONTyped(json, false);
@@ -8273,6 +8333,38 @@ var CheckoutexternalApi = class extends BaseAPI {
8273
8333
  );
8274
8334
  return await response.value();
8275
8335
  }
8336
+ /**
8337
+ * Get company payment methods
8338
+ */
8339
+ async getCompanyPaymentMethodsRaw(initOverrides) {
8340
+ const queryParameters = {};
8341
+ const headerParameters = {};
8342
+ if (this.configuration && this.configuration.apiKey) {
8343
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
8344
+ "X-Schematic-Api-Key"
8345
+ );
8346
+ }
8347
+ const response = await this.request(
8348
+ {
8349
+ path: `/company/payment-methods`,
8350
+ method: "GET",
8351
+ headers: headerParameters,
8352
+ query: queryParameters
8353
+ },
8354
+ initOverrides
8355
+ );
8356
+ return new JSONApiResponse(
8357
+ response,
8358
+ (jsonValue) => GetCompanyPaymentMethodsResponseFromJSON(jsonValue)
8359
+ );
8360
+ }
8361
+ /**
8362
+ * Get company payment methods
8363
+ */
8364
+ async getCompanyPaymentMethods(initOverrides) {
8365
+ const response = await this.getCompanyPaymentMethodsRaw(initOverrides);
8366
+ return await response.value();
8367
+ }
8276
8368
  /**
8277
8369
  * Get company upcoming invoice
8278
8370
  */
@@ -13217,6 +13309,7 @@ var en = {
13217
13309
  "Error saving custom field values. Please try again.": "Error saving custom field values. Please try again.",
13218
13310
  "Pay now": "Pay now",
13219
13311
  "Payment Details": "Payment Details",
13312
+ "Payment due": "Payment due {{date}}",
13220
13313
  "Plan selected": "Plan selected",
13221
13314
  "Please accept the agreement to continue.": "Please accept the agreement to continue.",
13222
13315
  "Please try again later.": "Please try again later.",
@@ -15478,7 +15571,7 @@ var reducer = (state, action) => {
15478
15571
  // src/context/EmbedProvider.tsx
15479
15572
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
15480
15573
  var getCustomHeaders = (sessionId) => ({
15481
- "X-Schematic-Components-Version": "2.29.0",
15574
+ "X-Schematic-Components-Version": "2.30.0",
15482
15575
  "X-Schematic-Session-ID": sessionId
15483
15576
  });
15484
15577
  var normalizeCurrencyFilter = (filter2) => {
@@ -16264,6 +16357,29 @@ function useIsLightBackground() {
16264
16357
  return isLightBackground;
16265
16358
  }
16266
16359
 
16360
+ // src/hooks/useNextBillDate.ts
16361
+ import { useMemo as useMemo7 } from "react";
16362
+ function useNextBillDate(upcomingInvoice) {
16363
+ const { data } = useEmbed();
16364
+ const invoice = upcomingInvoice === void 0 ? data?.upcomingInvoice : upcomingInvoice;
16365
+ const subscription = data?.company?.billingSubscription;
16366
+ const cancelAtPeriodEnd = subscription?.cancelAtPeriodEnd;
16367
+ const periodEnd = subscription?.periodEnd;
16368
+ const collectionMethod = invoice?.collectionMethod;
16369
+ const dueDate = invoice?.dueDate ?? void 0;
16370
+ return useMemo7(() => {
16371
+ if (cancelAtPeriodEnd) {
16372
+ return { billDate: void 0, paymentDueDate: void 0 };
16373
+ }
16374
+ const billDate = periodEnd && periodEnd > 0 ? new Date(periodEnd * 1e3) : dueDate;
16375
+ const hasSeparateDeadline = collectionMethod === BillingCollectionMethod.SendInvoice && dueDate && billDate && new Date(dueDate).toDateString() !== new Date(billDate).toDateString();
16376
+ return {
16377
+ billDate,
16378
+ paymentDueDate: hasSeparateDeadline ? dueDate : void 0
16379
+ };
16380
+ }, [cancelAtPeriodEnd, periodEnd, collectionMethod, dueDate]);
16381
+ }
16382
+
16267
16383
  // src/hooks/usePaymentConfirmation.ts
16268
16384
  import { useCallback as useCallback4, useEffect as useEffect2, useRef as useRef3, useState } from "react";
16269
16385
  var usePaymentConfirmation = ({
@@ -16371,7 +16487,7 @@ var usePaymentConfirmation = ({
16371
16487
  };
16372
16488
 
16373
16489
  // src/hooks/useRequest.ts
16374
- import { useCallback as useCallback5, useMemo as useMemo7, useState as useState2 } from "react";
16490
+ import { useCallback as useCallback5, useMemo as useMemo8, useState as useState2 } from "react";
16375
16491
  function useRequest(fn) {
16376
16492
  const [isLoading, setIsLoading] = useState2(false);
16377
16493
  const [error, setError] = useState2(null);
@@ -16391,7 +16507,7 @@ function useRequest(fn) {
16391
16507
  setIsLoading(false);
16392
16508
  }
16393
16509
  }, [fn]);
16394
- const value = useMemo7(() => {
16510
+ const value = useMemo8(() => {
16395
16511
  const state = { isLoading, error, data };
16396
16512
  return [state, request];
16397
16513
  }, [isLoading, error, data, request]);
@@ -16399,11 +16515,11 @@ function useRequest(fn) {
16399
16515
  }
16400
16516
 
16401
16517
  // src/hooks/useTrialEnd.ts
16402
- import { useMemo as useMemo8 } from "react";
16518
+ import { useMemo as useMemo9 } from "react";
16403
16519
  function useTrialEnd() {
16404
16520
  const { data } = useEmbed();
16405
16521
  const { t: t3 } = useTranslation();
16406
- const { endDate, amount, units } = useMemo8(() => {
16522
+ const { endDate, amount, units } = useMemo9(() => {
16407
16523
  const billingSubscription = data?.company?.billingSubscription;
16408
16524
  const end = typeof billingSubscription?.trialEnd === "number" ? new Date(billingSubscription.trialEnd * 1e3) : void 0;
16409
16525
  let amount2;
@@ -16433,13 +16549,13 @@ function useTrialEnd() {
16433
16549
  }
16434
16550
 
16435
16551
  // src/hooks/useTruncatedList.ts
16436
- import { useCallback as useCallback6, useMemo as useMemo9, useState as useState3 } from "react";
16552
+ import { useCallback as useCallback6, useMemo as useMemo10, useState as useState3 } from "react";
16437
16553
  function useTruncatedList(items, { limit }) {
16438
16554
  const [isExpandedState, setIsExpanded] = useState3(false);
16439
16555
  const total = items.length;
16440
16556
  const canExpand = total > limit;
16441
16557
  const isExpanded = canExpand && isExpandedState;
16442
- const visibleItems = useMemo9(
16558
+ const visibleItems = useMemo10(
16443
16559
  () => canExpand && !isExpanded ? items.slice(0, limit) : items,
16444
16560
  [items, limit, canExpand, isExpanded]
16445
16561
  );
@@ -16920,7 +17036,7 @@ import {
16920
17036
  forwardRef,
16921
17037
  useImperativeHandle,
16922
17038
  useLayoutEffect as useLayoutEffect2,
16923
- useMemo as useMemo10,
17039
+ useMemo as useMemo11,
16924
17040
  useRef as useRef4
16925
17041
  } from "react";
16926
17042
 
@@ -17013,7 +17129,7 @@ var Dialog2 = forwardRef(
17013
17129
  document.body.style.overflow = initialOverflowValue;
17014
17130
  };
17015
17131
  }, [isModal]);
17016
- const dialog = useMemo10(
17132
+ const dialog = useMemo11(
17017
17133
  () => /* @__PURE__ */ jsx4(
17018
17134
  Dialog,
17019
17135
  {
@@ -18026,7 +18142,7 @@ var ButtonGroup = ({
18026
18142
  };
18027
18143
 
18028
18144
  // src/components/shared/checkout-dialog/Plan/Entitlement.tsx
18029
- import { useMemo as useMemo11 } from "react";
18145
+ import { useMemo as useMemo12 } from "react";
18030
18146
  import { Fragment as Fragment4, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
18031
18147
  var Entitlement = ({
18032
18148
  portal,
@@ -18056,7 +18172,7 @@ var Entitlement = ({
18056
18172
  tiersMode
18057
18173
  } = entitlementBillingPrice || {};
18058
18174
  const tiered = entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(entitlementBillingPrice);
18059
- const text = useMemo11(() => {
18175
+ const text = useMemo12(() => {
18060
18176
  if (!entitlement.feature) {
18061
18177
  return;
18062
18178
  }
@@ -18164,7 +18280,7 @@ var Entitlement = ({
18164
18280
  selectedCurrency,
18165
18281
  showWarningThresholdAsLimit
18166
18282
  ]);
18167
- const usageText = useMemo11(() => {
18283
+ const usageText = useMemo12(() => {
18168
18284
  if (!entitlement.feature) {
18169
18285
  return;
18170
18286
  }
@@ -18510,7 +18626,7 @@ var Plan = ({
18510
18626
  };
18511
18627
 
18512
18628
  // src/components/shared/checkout-dialog/AutoTopup.tsx
18513
- import { useMemo as useMemo12 } from "react";
18629
+ import { useMemo as useMemo13 } from "react";
18514
18630
  import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
18515
18631
  var AutoTopup = ({
18516
18632
  planCreditGrants,
@@ -18520,7 +18636,7 @@ var AutoTopup = ({
18520
18636
  const { settings } = useEmbed();
18521
18637
  const { t: t3, locale } = useTranslation();
18522
18638
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
18523
- const configurableCreditGrants = useMemo12(() => {
18639
+ const configurableCreditGrants = useMemo13(() => {
18524
18640
  return planCreditGrants.reduce(
18525
18641
  (acc, grant) => {
18526
18642
  if (isSelfServiceAutoTopupAvailable(grant)) {
@@ -18646,7 +18762,7 @@ var AutoTopup = ({
18646
18762
  };
18647
18763
 
18648
18764
  // src/components/shared/checkout-dialog/Quantity.tsx
18649
- import { useMemo as useMemo13 } from "react";
18765
+ import { useMemo as useMemo14 } from "react";
18650
18766
  import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
18651
18767
  var Quantity = ({
18652
18768
  portal,
@@ -18661,12 +18777,12 @@ var Quantity = ({
18661
18777
  const isLightBackground = useIsLightBackground();
18662
18778
  const cardPadding = settings.theme.card.padding / TEXT_BASE_SIZE;
18663
18779
  const unitPriceFontSize = 0.875 * settings.theme.typography.text.fontSize;
18664
- const planCredits = useMemo13(
18780
+ const planCredits = useMemo14(
18665
18781
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
18666
18782
  [selectedPlan?.includedCreditGrants]
18667
18783
  );
18668
18784
  const prorationBehavior = data?.checkoutSettings?.prorationBehavior;
18669
- const renewalDate = data?.upcomingInvoice?.dueDate ?? void 0;
18785
+ const { billDate: renewalDate } = useNextBillDate();
18670
18786
  return /* @__PURE__ */ jsx21(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce((acc, entitlement) => {
18671
18787
  if (entitlement.feature) {
18672
18788
  const entitlementBillingPrice = getEntitlementPrice(
@@ -19439,7 +19555,7 @@ var CustomCheckoutFields = ({
19439
19555
  };
19440
19556
 
19441
19557
  // src/components/shared/checkout-dialog/TaxIdField.tsx
19442
- import { useMemo as useMemo14 } from "react";
19558
+ import { useMemo as useMemo15 } from "react";
19443
19559
  import { jsx as jsx25, jsxs as jsxs15 } from "react/jsx-runtime";
19444
19560
  var Select = gt(Input2).attrs({ as: "select" })`
19445
19561
  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");
@@ -19454,7 +19570,7 @@ var TaxIdField = ({
19454
19570
  }) => {
19455
19571
  const { t: t3, locale } = useTranslation();
19456
19572
  const isLightBackground = useIsLightBackground();
19457
- const countryOptions = useMemo14(() => taxIdCountryOptions(locale), [locale]);
19573
+ const countryOptions = useMemo15(() => taxIdCountryOptions(locale), [locale]);
19458
19574
  const jurisdictions = taxIdJurisdictionsForCountry(value.country);
19459
19575
  const handleCountryChange = (country) => {
19460
19576
  const next2 = taxIdJurisdictionsForCountry(country);
@@ -19683,7 +19799,7 @@ import {
19683
19799
  useCallback as useCallback8,
19684
19800
  useEffect as useEffect3,
19685
19801
  useLayoutEffect as useLayoutEffect4,
19686
- useMemo as useMemo15,
19802
+ useMemo as useMemo16,
19687
19803
  useRef as useRef6,
19688
19804
  useState as useState8
19689
19805
  } from "react";
@@ -19847,7 +19963,7 @@ var CheckoutDialog = ({ top }) => {
19847
19963
  const [isModal, setIsModal] = useState8(true);
19848
19964
  const showPeriodToggle = data?.displaySettings?.showPeriodToggle ?? true;
19849
19965
  const trialPaymentMethodRequired = data?.trialPaymentMethodRequired === true;
19850
- const featureUsage = useMemo15(
19966
+ const featureUsage = useMemo16(
19851
19967
  () => data?.featureUsage?.features ?? [],
19852
19968
  [data?.featureUsage?.features]
19853
19969
  );
@@ -19903,7 +20019,7 @@ var CheckoutDialog = ({ top }) => {
19903
20019
  useSelectedPeriod: showPeriodToggle
19904
20020
  });
19905
20021
  const [selectedPlanId, setSelectedPlanId] = useState8(void 0);
19906
- const selectedPlan = useMemo15(() => {
20022
+ const selectedPlan = useMemo16(() => {
19907
20023
  if (selectedPlanId === null) {
19908
20024
  return void 0;
19909
20025
  }
@@ -19919,7 +20035,7 @@ var CheckoutDialog = ({ top }) => {
19919
20035
  );
19920
20036
  }, [availablePlans, checkoutState, selectedPlanId]);
19921
20037
  const [shouldTrial, setShouldTrial] = useState8(false);
19922
- const planCreditGrants = useMemo15(() => {
20038
+ const planCreditGrants = useMemo16(() => {
19923
20039
  const grants = mergeCompanyGrants(
19924
20040
  selectedPlan?.includedCreditGrants,
19925
20041
  data?.company?.plan?.includedCreditGrants
@@ -19965,11 +20081,11 @@ var CheckoutDialog = ({ top }) => {
19965
20081
  }
19966
20082
  return ids;
19967
20083
  });
19968
- const addOnCompatibilityLookup = useMemo15(
20084
+ const addOnCompatibilityLookup = useMemo16(
19969
20085
  () => buildAddOnCompatibilityLookup(data?.addOnCompatibilities),
19970
20086
  [data?.addOnCompatibilities]
19971
20087
  );
19972
- const addOns = useMemo15(() => {
20088
+ const addOns = useMemo16(() => {
19973
20089
  return availableAddOns.filter((availAddOn) => {
19974
20090
  if (hasCurrency && !planSupportsCurrency(availAddOn, effectiveCurrency)) {
19975
20091
  return false;
@@ -19998,7 +20114,7 @@ var CheckoutDialog = ({ top }) => {
19998
20114
  const [bundleCounts, setBundleCounts] = useState8({});
19999
20115
  const bundleCountsRef = useRef6(bundleCounts);
20000
20116
  const bundleGatingPlanId = selectedPlan?.id ?? data?.company?.plan?.id;
20001
- const creditBundles = useMemo15(() => {
20117
+ const creditBundles = useMemo16(() => {
20002
20118
  return deriveCreditBundles(
20003
20119
  data?.creditBundles,
20004
20120
  bundleGatingPlanId,
@@ -20008,7 +20124,7 @@ var CheckoutDialog = ({ top }) => {
20008
20124
  const [hasInitialPaymentMethod] = useState8(
20009
20125
  () => !!(data?.subscription?.paymentMethod?.externalId || data?.company?.defaultPaymentMethod?.externalId)
20010
20126
  );
20011
- const isCreditOnlyPurchase = useMemo15(
20127
+ const isCreditOnlyPurchase = useMemo16(
20012
20128
  () => isCreditOnlyCheckout({
20013
20129
  plan: selectedPlan,
20014
20130
  creditBundles,
@@ -20075,13 +20191,13 @@ var CheckoutDialog = ({ top }) => {
20075
20191
  checkoutState?.payInAdvanceQuantities
20076
20192
  );
20077
20193
  });
20078
- const payInAdvanceEntitlements = useMemo15(
20194
+ const payInAdvanceEntitlements = useMemo16(
20079
20195
  () => usageBasedEntitlements.filter(
20080
20196
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20081
20197
  ),
20082
20198
  [usageBasedEntitlements]
20083
20199
  );
20084
- const addOnPayInAdvanceEntitlements = useMemo15(
20200
+ const addOnPayInAdvanceEntitlements = useMemo16(
20085
20201
  () => addOnUsageBasedEntitlements.filter(
20086
20202
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
20087
20203
  ),
@@ -20097,7 +20213,7 @@ var CheckoutDialog = ({ top }) => {
20097
20213
  }
20098
20214
  return values;
20099
20215
  });
20100
- const hasIncompleteRequiredCustomFields = useMemo15(() => {
20216
+ const hasIncompleteRequiredCustomFields = useMemo16(() => {
20101
20217
  return (data?.customCheckoutFields ?? []).some(
20102
20218
  (field) => field.required && !customFieldValues[field.id]?.trim()
20103
20219
  );
@@ -20147,12 +20263,12 @@ var CheckoutDialog = ({ top }) => {
20147
20263
  const [optInAccepted, setOptInAccepted] = useState8(false);
20148
20264
  const presentedOptInRef = useRef6(null);
20149
20265
  const [willScheduleDowngrade, setWillScheduleDowngrade] = useState8(false);
20150
- const willTrialWithoutPaymentMethod = useMemo15(
20266
+ const willTrialWithoutPaymentMethod = useMemo16(
20151
20267
  () => shouldTrial && !trialPaymentMethodRequired,
20152
20268
  [shouldTrial, trialPaymentMethodRequired]
20153
20269
  );
20154
20270
  const isSelectedPlanTrialable = selectedPlan && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
20155
- const checkoutStages = useMemo15(() => {
20271
+ const checkoutStages = useMemo16(() => {
20156
20272
  const stages = [];
20157
20273
  const checkoutStage2 = {
20158
20274
  id: "checkout",
@@ -20258,7 +20374,7 @@ var CheckoutDialog = ({ top }) => {
20258
20374
  }
20259
20375
  return "plan";
20260
20376
  });
20261
- const effectiveCheckoutStage = useMemo15(() => {
20377
+ const effectiveCheckoutStage = useMemo16(() => {
20262
20378
  if (isBypassLoading) return checkoutStage;
20263
20379
  let id = checkoutStage;
20264
20380
  if (id === "credits" && !checkoutStages.some((stage) => stage.id === id)) {
@@ -20274,7 +20390,7 @@ var CheckoutDialog = ({ top }) => {
20274
20390
  }, [checkoutStage, checkoutStages, checkoutState, isBypassLoading]);
20275
20391
  const previewRequestIdRef = useRef6(0);
20276
20392
  const planStageVisible = checkoutStages.some((stage) => stage.id === "plan") && !checkoutState?.bypassPlanSelection;
20277
- const checkoutStageCurrencies = useMemo15(() => {
20393
+ const checkoutStageCurrencies = useMemo16(() => {
20278
20394
  if (!selectedPlan) return currencies;
20279
20395
  return currencies.filter(
20280
20396
  (currency) => planOffersCurrencyForPeriod(selectedPlan, planPeriod, currency)
@@ -20847,7 +20963,7 @@ var CheckoutDialog = ({ top }) => {
20847
20963
  const activeCheckoutStage = checkoutStages.find(
20848
20964
  (stage) => stage.id === effectiveCheckoutStage
20849
20965
  );
20850
- const visibleStages = useMemo15(() => {
20966
+ const visibleStages = useMemo16(() => {
20851
20967
  if (!checkoutState?.hideSkippedStages) {
20852
20968
  return checkoutStages;
20853
20969
  }
@@ -20870,7 +20986,7 @@ var CheckoutDialog = ({ top }) => {
20870
20986
  return true;
20871
20987
  });
20872
20988
  }, [checkoutStages, checkoutState]);
20873
- const navigableStages = useMemo15(() => {
20989
+ const navigableStages = useMemo16(() => {
20874
20990
  return checkoutStages.filter((stage) => {
20875
20991
  if (stage.id === "plan" && checkoutState?.bypassPlanSelection) {
20876
20992
  return false;
@@ -21483,17 +21599,17 @@ var InvalidCurrencyNotice = ({
21483
21599
  import { useCallback as useCallback10, useLayoutEffect as useLayoutEffect5, useRef as useRef7, useState as useState10 } from "react";
21484
21600
 
21485
21601
  // src/components/shared/checkout-dialog/EditableCustomCheckoutFields.tsx
21486
- import { useCallback as useCallback9, useMemo as useMemo16, useState as useState9 } from "react";
21602
+ import { useCallback as useCallback9, useMemo as useMemo17, useState as useState9 } from "react";
21487
21603
  import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
21488
21604
  var EditableCustomCheckoutFields = () => {
21489
21605
  const { t: t3 } = useTranslation();
21490
21606
  const isLightBackground = useIsLightBackground();
21491
21607
  const { data, updateCustomFieldValues } = useEmbed();
21492
- const customCheckoutFields = useMemo16(
21608
+ const customCheckoutFields = useMemo17(
21493
21609
  () => data?.customCheckoutFields ?? [],
21494
21610
  [data?.customCheckoutFields]
21495
21611
  );
21496
- const serverFieldValues = useMemo16(() => {
21612
+ const serverFieldValues = useMemo17(() => {
21497
21613
  const values2 = {};
21498
21614
  for (const field of customCheckoutFields) {
21499
21615
  values2[field.id] = field.value ?? "";
@@ -21663,7 +21779,7 @@ import {
21663
21779
  useElements,
21664
21780
  useStripe
21665
21781
  } from "@stripe/react-stripe-js";
21666
- import { useEffect as useEffect4, useMemo as useMemo17, useRef as useRef8, useState as useState11 } from "react";
21782
+ import { useEffect as useEffect4, useMemo as useMemo18, useRef as useRef8, useState as useState11 } from "react";
21667
21783
  import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
21668
21784
  var PaymentForm = ({ onConfirm, financeData }) => {
21669
21785
  const { t: t3 } = useTranslation();
@@ -21694,7 +21810,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
21694
21810
  const [isAddressComplete, setIsAddressComplete] = useState11(
21695
21811
  () => !shouldCollectAddress
21696
21812
  );
21697
- const addressDefaultsKey = useMemo17(
21813
+ const addressDefaultsKey = useMemo18(
21698
21814
  () => JSON.stringify(billing ?? {}),
21699
21815
  [billing]
21700
21816
  );
@@ -21859,7 +21975,7 @@ var PaymentForm = ({ onConfirm, financeData }) => {
21859
21975
  };
21860
21976
 
21861
21977
  // src/components/shared/period-toggle/PeriodToggle.tsx
21862
- import { useMemo as useMemo18 } from "react";
21978
+ import { useMemo as useMemo19 } from "react";
21863
21979
  import { jsx as jsx37 } from "react/jsx-runtime";
21864
21980
  var PERIOD_MONTH_COUNT = {
21865
21981
  year: 12,
@@ -21875,7 +21991,7 @@ var PeriodToggle = ({
21875
21991
  const { t: t3 } = useTranslation();
21876
21992
  const { settings } = useEmbed();
21877
21993
  const isLightBackground = useIsLightBackground();
21878
- const savingsByPeriod = useMemo18(() => {
21994
+ const savingsByPeriod = useMemo19(() => {
21879
21995
  const result = {};
21880
21996
  if (!selectedPlan) {
21881
21997
  return result;
@@ -22032,10 +22148,10 @@ var PlanCreditText = ({
22032
22148
  };
22033
22149
 
22034
22150
  // src/components/shared/pricing-tiers-tooltip/PricingTiersTooltip.tsx
22035
- import { useMemo as useMemo20 } from "react";
22151
+ import { useMemo as useMemo21 } from "react";
22036
22152
 
22037
22153
  // src/components/shared/pricing-tiers-tooltip/PriceText.tsx
22038
- import { useMemo as useMemo19 } from "react";
22154
+ import { useMemo as useMemo20 } from "react";
22039
22155
  import { Fragment as Fragment12, jsx as jsx39, jsxs as jsxs27 } from "react/jsx-runtime";
22040
22156
  var PriceText = ({
22041
22157
  feature,
@@ -22046,7 +22162,7 @@ var PriceText = ({
22046
22162
  }) => {
22047
22163
  const { settings } = useEmbed();
22048
22164
  const { t: t3, locale } = useTranslation();
22049
- const text = useMemo19(() => {
22165
+ const text = useMemo20(() => {
22050
22166
  if (!flatAmount && perUnitPrice) {
22051
22167
  return /* @__PURE__ */ jsxs27(Fragment12, { children: [
22052
22168
  formatCurrency(perUnitPrice, { locale, currency }),
@@ -22103,7 +22219,7 @@ var PricingTiersTooltip = ({
22103
22219
  const { t: t3 } = useTranslation();
22104
22220
  const { settings } = useEmbed();
22105
22221
  const isLightBackground = useIsLightBackground();
22106
- const { tiers } = useMemo20(() => {
22222
+ const { tiers } = useMemo21(() => {
22107
22223
  return priceTiers.reduce(
22108
22224
  (acc, tier) => {
22109
22225
  const end = tier.upTo ?? Infinity;
@@ -22201,7 +22317,7 @@ import {
22201
22317
  forwardRef as forwardRef7,
22202
22318
  useCallback as useCallback11,
22203
22319
  useLayoutEffect as useLayoutEffect6,
22204
- useMemo as useMemo21,
22320
+ useMemo as useMemo22,
22205
22321
  useRef as useRef9,
22206
22322
  useState as useState13
22207
22323
  } from "react";
@@ -22803,7 +22919,7 @@ var SubscriptionSidebar = forwardRef7(
22803
22919
  billingSubscription,
22804
22920
  paymentMethod,
22805
22921
  trialPaymentMethodRequired
22806
- } = useMemo21(() => {
22922
+ } = useMemo22(() => {
22807
22923
  const currentEntitlements2 = data?.featureUsage?.features || [];
22808
22924
  return {
22809
22925
  currentPlan: data?.company?.plan,
@@ -22826,7 +22942,7 @@ var SubscriptionSidebar = forwardRef7(
22826
22942
  data?.subscription?.paymentMethod,
22827
22943
  data?.trialPaymentMethodRequired
22828
22944
  ]);
22829
- const planCreditGrants = useMemo21(() => {
22945
+ const planCreditGrants = useMemo22(() => {
22830
22946
  const grants = mergeCompanyGrants(
22831
22947
  selectedPlan?.includedCreditGrants,
22832
22948
  data?.company?.plan?.includedCreditGrants
@@ -22836,11 +22952,11 @@ var SubscriptionSidebar = forwardRef7(
22836
22952
  selectedPlan?.includedCreditGrants,
22837
22953
  data?.company?.plan?.includedCreditGrants
22838
22954
  ]);
22839
- const planCredits = useMemo21(
22955
+ const planCredits = useMemo22(
22840
22956
  () => groupPlanCreditGrants(selectedPlan?.includedCreditGrants ?? []),
22841
22957
  [selectedPlan?.includedCreditGrants]
22842
22958
  );
22843
- const { payInAdvanceEntitlements } = useMemo21(() => {
22959
+ const { payInAdvanceEntitlements } = useMemo22(() => {
22844
22960
  const payAsYouGoEntitlements = [];
22845
22961
  const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
22846
22962
  (entitlement) => {
@@ -22852,7 +22968,7 @@ var SubscriptionSidebar = forwardRef7(
22852
22968
  );
22853
22969
  return { payAsYouGoEntitlements, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
22854
22970
  }, [usageBasedEntitlements]);
22855
- const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = useMemo21(() => {
22971
+ const { subscriptionPrice, subscriptionTotal, subscriptionCurrency } = useMemo22(() => {
22856
22972
  let planPrice;
22857
22973
  let resolvedCurrency;
22858
22974
  if (selectedPlan) {
@@ -22923,7 +23039,7 @@ var SubscriptionSidebar = forwardRef7(
22923
23039
  proration,
22924
23040
  taxAmount,
22925
23041
  taxDescription
22926
- } = useMemo21(() => {
23042
+ } = useMemo22(() => {
22927
23043
  return {
22928
23044
  amountOff: charges?.amountOff ?? 0,
22929
23045
  discountAmount: charges?.discountAmount ?? 0,
@@ -22993,7 +23109,7 @@ var SubscriptionSidebar = forwardRef7(
22993
23109
  }
22994
23110
  );
22995
23111
  };
22996
- const updatedUsageBasedEntitlements = useMemo21(() => {
23112
+ const updatedUsageBasedEntitlements = useMemo22(() => {
22997
23113
  const changedUsageBasedEntitlements = [];
22998
23114
  const allSelectedUsageBasedEntitlements = [
22999
23115
  ...usageBasedEntitlements,
@@ -23056,19 +23172,19 @@ var SubscriptionSidebar = forwardRef7(
23056
23172
  usageBasedEntitlements,
23057
23173
  addOnUsageBasedEntitlements
23058
23174
  ]);
23059
- const selectedAddOnsWithPrice = useMemo21(
23175
+ const selectedAddOnsWithPrice = useMemo22(
23060
23176
  () => addOns.filter(
23061
23177
  (addOn) => addOn.isSelected && getPlanPrice(addOn, void 0, void 0, currency)?.price
23062
23178
  ),
23063
23179
  [addOns, currency]
23064
23180
  );
23065
- const selectedOneTimeAddOns = useMemo21(
23181
+ const selectedOneTimeAddOns = useMemo22(
23066
23182
  () => addOns.filter(
23067
23183
  (addOn) => addOn.isSelected && addOn.chargeType === ChargeType.oneTime && getAddOnPrice(addOn, planPeriod, currency)?.price
23068
23184
  ),
23069
23185
  [addOns, planPeriod, currency]
23070
23186
  );
23071
- const { removedAddOns, willAddOnsChange } = useMemo21(() => {
23187
+ const { removedAddOns, willAddOnsChange } = useMemo22(() => {
23072
23188
  const addedAddOns = selectedAddOnsWithPrice.filter(
23073
23189
  (selected) => getPlanPrice(selected, void 0, void 0, currency)?.price && !currentAddOns.some((current) => selected.id === current.id)
23074
23190
  );
@@ -23084,15 +23200,15 @@ var SubscriptionSidebar = forwardRef7(
23084
23200
  willAddOnsChange: willAddOnsChange2
23085
23201
  };
23086
23202
  }, [currentAddOns, selectedAddOnsWithPrice, currency]);
23087
- const addedCreditBundles = useMemo21(
23203
+ const addedCreditBundles = useMemo22(
23088
23204
  () => creditBundles.filter((bundle) => bundle.count > 0),
23089
23205
  [creditBundles]
23090
23206
  );
23091
- const discountApplied = useMemo21(
23207
+ const discountApplied = useMemo22(
23092
23208
  () => promoCode && (amountOff > 0 || percentOff > 0),
23093
23209
  [promoCode, amountOff, percentOff]
23094
23210
  );
23095
- const subscriptionDiscount = useMemo21(
23211
+ const subscriptionDiscount = useMemo22(
23096
23212
  () => getSubscriptionDiscount(
23097
23213
  charges?.discounts,
23098
23214
  subscriptionTotal,
@@ -23252,7 +23368,7 @@ var SubscriptionSidebar = forwardRef7(
23252
23368
  }
23253
23369
  }, [t3, unsubscribe, setError, setIsLoading, setLayout]);
23254
23370
  const isSelectedPlanTrialable = selectedPlan?.companyCanTrial === true && selectedPlan?.isTrialable === true;
23255
- const button = useMemo21(() => {
23371
+ const button = useMemo22(() => {
23256
23372
  const hasEntitlementDowngrade = payInAdvanceEntitlements.some((e) => e.quantity < e.usage) || addOnPayInAdvanceEntitlements.some((e) => e.quantity < e.usage);
23257
23373
  const canCheckout = error !== t3("Downgrade not permitted.") && !hasEntitlementDowngrade;
23258
23374
  const isSticky = !isButtonInView;
@@ -23980,14 +24096,14 @@ var SubscriptionSidebar = forwardRef7(
23980
24096
  SubscriptionSidebar.displayName = "SubscriptionSidebar";
23981
24097
 
23982
24098
  // src/components/shared/tiered-pricing-details/TieredPricingDetails.tsx
23983
- import { useMemo as useMemo22 } from "react";
24099
+ import { useMemo as useMemo23 } from "react";
23984
24100
  var TieredPricingDetails = ({
23985
24101
  entitlement,
23986
24102
  period,
23987
24103
  currency: selectedCurrency
23988
24104
  }) => {
23989
24105
  const { t: t3, locale } = useTranslation();
23990
- const { currency, flatAmount, perUnitPrice, upTo } = useMemo22(() => {
24106
+ const { currency, flatAmount, perUnitPrice, upTo } = useMemo23(() => {
23991
24107
  const { currency: currency2, priceTier } = getEntitlementPrice(entitlement, period, selectedCurrency) || {};
23992
24108
  const { flatAmount: flatAmount2, perUnitPrice: perUnitPrice2, perUnitPriceDecimal, upTo: upTo2 } = priceTier?.[0] || {};
23993
24109
  return {
@@ -24035,7 +24151,7 @@ var TieredPricingDetails = ({
24035
24151
  };
24036
24152
 
24037
24153
  // src/components/shared/unsubscribe-dialog/UnsubscribeDialog.tsx
24038
- import { useCallback as useCallback12, useLayoutEffect as useLayoutEffect7, useMemo as useMemo23, useRef as useRef10, useState as useState14 } from "react";
24154
+ import { useCallback as useCallback12, useLayoutEffect as useLayoutEffect7, useMemo as useMemo24, useRef as useRef10, useState as useState14 } from "react";
24039
24155
  import { jsx as jsx45, jsxs as jsxs33 } from "react/jsx-runtime";
24040
24156
  var UnsubscribeDialog = ({ top }) => {
24041
24157
  const { t: t3, locale } = useTranslation();
@@ -24052,8 +24168,9 @@ var UnsubscribeDialog = ({ top }) => {
24052
24168
  const [error, setError] = useState14();
24053
24169
  const [isLoading, setIsLoading] = useState14(false);
24054
24170
  const [isModal, setIsModal] = useState14(true);
24055
- const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo23(() => {
24056
- const cancelDate2 = data?.subscription?.cancelAt || data?.upcomingInvoice?.dueDate;
24171
+ const { billDate } = useNextBillDate();
24172
+ const { planPeriod, currentPlan, currentAddOns, featureUsage, cancelDate } = useMemo24(() => {
24173
+ const cancelDate2 = data?.subscription?.cancelAt || billDate;
24057
24174
  return {
24058
24175
  planPeriod: getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || "month",
24059
24176
  currentPlan: data?.company?.plan,
@@ -24067,10 +24184,10 @@ var UnsubscribeDialog = ({ top }) => {
24067
24184
  data?.company?.plan,
24068
24185
  data?.featureUsage,
24069
24186
  data?.subscription?.cancelAt,
24070
- data?.upcomingInvoice?.dueDate
24187
+ billDate
24071
24188
  ]);
24072
24189
  const { plans: availablePlans, addOns: availableAddOns } = useAvailablePlans(planPeriod);
24073
- const selectedPlan = useMemo23(
24190
+ const selectedPlan = useMemo24(
24074
24191
  () => availablePlans.find((plan) => plan.id === currentPlan?.id),
24075
24192
  [currentPlan?.id, availablePlans]
24076
24193
  );
@@ -24079,7 +24196,7 @@ var UnsubscribeDialog = ({ top }) => {
24079
24196
  createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
24080
24197
  []
24081
24198
  );
24082
- const addOns = useMemo23(
24199
+ const addOns = useMemo24(
24083
24200
  () => availableAddOns.map((available) => ({
24084
24201
  ...available,
24085
24202
  isSelected: currentAddOns.some((current) => available.id === current.id) ?? false
@@ -24470,10 +24587,10 @@ var ButtonElement = forwardRef9(({ children, className, ...rest }, ref) => {
24470
24587
  ButtonElement.displayName = "Button";
24471
24588
 
24472
24589
  // src/components/elements/included-features/IncludedFeatures.tsx
24473
- import { Fragment as Fragment19, forwardRef as forwardRef10, useMemo as useMemo25 } from "react";
24590
+ import { Fragment as Fragment19, forwardRef as forwardRef10, useMemo as useMemo26 } from "react";
24474
24591
 
24475
24592
  // src/components/elements/included-features/UsageDetails.tsx
24476
- import { Fragment as Fragment17, useMemo as useMemo24 } from "react";
24593
+ import { Fragment as Fragment17, useMemo as useMemo25 } from "react";
24477
24594
  import { Fragment as Fragment18, jsx as jsx51, jsxs as jsxs37 } from "react/jsx-runtime";
24478
24595
  var UsageDetails = ({ entitlement, layout }) => {
24479
24596
  const {
@@ -24501,7 +24618,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24501
24618
  currentTier,
24502
24619
  tiersMode,
24503
24620
  tiered
24504
- } = useMemo24(() => {
24621
+ } = useMemo25(() => {
24505
24622
  const { billingPrice, amount, limit: limit2, cost: cost2, currentTier: currentTier2 } = getUsageDetails(
24506
24623
  entitlement,
24507
24624
  period,
@@ -24528,7 +24645,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24528
24645
  tiered: priceBehavior === EntitlementPriceBehavior.PayInAdvance && isTieredPrice(billingPrice)
24529
24646
  };
24530
24647
  }, [entitlement, period, priceBehavior, showWarningThresholdAsLimit]);
24531
- const text = useMemo24(() => {
24648
+ const text = useMemo25(() => {
24532
24649
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
24533
24650
  return;
24534
24651
  }
@@ -24603,7 +24720,7 @@ var UsageDetails = ({ entitlement, layout }) => {
24603
24720
  currentTier,
24604
24721
  showCredits
24605
24722
  ]);
24606
- const usageText = useMemo24(() => {
24723
+ const usageText = useMemo25(() => {
24607
24724
  if (!feature || feature.featureType !== FeatureType.Event && feature.featureType !== FeatureType.Trait) {
24608
24725
  return;
24609
24726
  }
@@ -24780,7 +24897,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
24780
24897
  const { t: t3, locale } = useTranslation();
24781
24898
  const { data, settings } = useEmbed();
24782
24899
  const isLightBackground = useIsLightBackground();
24783
- const { plan, addOns, featureUsage } = useMemo25(() => {
24900
+ const { plan, addOns, featureUsage } = useMemo26(() => {
24784
24901
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
24785
24902
  (acc, id) => {
24786
24903
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -24918,7 +25035,7 @@ var IncludedFeatures = forwardRef10(({ className, ...rest }, ref) => {
24918
25035
  IncludedFeatures.displayName = "IncludedFeatures";
24919
25036
 
24920
25037
  // src/components/elements/invoices/Invoices.tsx
24921
- import { forwardRef as forwardRef11, useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo26, useState as useState16 } from "react";
25038
+ import { forwardRef as forwardRef11, useCallback as useCallback13, useEffect as useEffect5, useMemo as useMemo27, useState as useState16 } from "react";
24922
25039
  import { Fragment as Fragment20, jsx as jsx53, jsxs as jsxs39 } from "react/jsx-runtime";
24923
25040
  function resolveDesignProps3(props) {
24924
25041
  return {
@@ -24986,11 +25103,11 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
24986
25103
  const [rawInvoices, setInvoices] = useState16(
24987
25104
  () => data && "invoices" in data ? data.invoices : rest.data
24988
25105
  );
24989
- const invoices = useMemo26(
25106
+ const invoices = useMemo27(
24990
25107
  () => formatInvoices(rawInvoices, locale),
24991
25108
  [rawInvoices, locale]
24992
25109
  );
24993
- const reachableInvoices = useMemo26(
25110
+ const reachableInvoices = useMemo27(
24994
25111
  () => invoices.slice(0, MAX_VISIBLE_INVOICE_COUNT),
24995
25112
  [invoices]
24996
25113
  );
@@ -25109,7 +25226,7 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
25109
25226
  Invoices.displayName = "Invoices";
25110
25227
 
25111
25228
  // src/components/elements/metered-features/MeteredFeatures.tsx
25112
- import { forwardRef as forwardRef12, useCallback as useCallback14, useMemo as useMemo28, useRef as useRef12, useState as useState18 } from "react";
25229
+ import { forwardRef as forwardRef12, useCallback as useCallback14, useMemo as useMemo29, useRef as useRef12, useState as useState18 } from "react";
25113
25230
 
25114
25231
  // src/components/elements/metered-features/Meter.tsx
25115
25232
  import { jsx as jsx54 } from "react/jsx-runtime";
@@ -25242,7 +25359,7 @@ var PriceDetails = ({
25242
25359
  };
25243
25360
 
25244
25361
  // src/components/elements/metered-features/UsageByUser.tsx
25245
- import { useEffect as useEffect6, useMemo as useMemo27, useState as useState17 } from "react";
25362
+ import { useEffect as useEffect6, useMemo as useMemo28, useState as useState17 } from "react";
25246
25363
  import { jsx as jsx56, jsxs as jsxs41 } from "react/jsx-runtime";
25247
25364
  var COLLAPSED_COUNT = 3;
25248
25365
  var EXPANDED_COUNT = 20;
@@ -25339,7 +25456,7 @@ var UsageByUser = ({ source, unit }) => {
25339
25456
  sourceKey
25340
25457
  ]);
25341
25458
  const entries = current?.section?.entries;
25342
- const attributed = useMemo27(
25459
+ const attributed = useMemo28(
25343
25460
  () => [...entries ?? []].sort((a2, b2) => b2.amount - a2.amount),
25344
25461
  [entries]
25345
25462
  );
@@ -25533,7 +25650,8 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25533
25650
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
25534
25651
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
25535
25652
  const isLightBackground = useIsLightBackground();
25536
- const meteredFeatures = useMemo28(() => {
25653
+ const { billDate: renewalDate } = useNextBillDate();
25654
+ const meteredFeatures = useMemo29(() => {
25537
25655
  const orderedFeatureUsage = props.visibleFeatures?.reduce(
25538
25656
  (acc, id) => {
25539
25657
  const mappedFeatureUsage = data?.featureUsage?.features.find(
@@ -25550,7 +25668,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25550
25668
  ({ feature }) => feature?.featureType === FeatureType.Event || feature?.featureType === FeatureType.Trait
25551
25669
  );
25552
25670
  }, [props.visibleFeatures, data?.featureUsage?.features]);
25553
- const creditGroups = useMemo28(
25671
+ const creditGroups = useMemo29(
25554
25672
  () => withEmptyPlanCreditBalances(
25555
25673
  aggregateActiveGrantsByCredit(data?.creditGrants || []),
25556
25674
  listPlanCredits(
@@ -25561,7 +25679,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25561
25679
  ),
25562
25680
  [data?.creditGrants, data?.featureUsage?.features, data?.company]
25563
25681
  );
25564
- const planCreditCompositions = useMemo28(
25682
+ const planCreditCompositions = useMemo29(
25565
25683
  () => groupPlanCreditGrants(data?.company?.plan?.includedCreditGrants ?? []),
25566
25684
  [data?.company?.plan?.includedCreditGrants]
25567
25685
  );
@@ -25575,7 +25693,7 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25575
25693
  },
25576
25694
  [data?.featureUsage?.features]
25577
25695
  );
25578
- const purchasableCreditIds = useMemo28(
25696
+ const purchasableCreditIds = useMemo29(
25579
25697
  () => getPurchasableCreditIds(data?.creditBundles, data?.company?.plan?.id),
25580
25698
  [data?.creditBundles, data?.company?.plan?.id]
25581
25699
  );
@@ -25820,7 +25938,6 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25820
25938
  })
25821
25939
  );
25822
25940
  }
25823
- const renewalDate = data?.upcomingInvoice?.dueDate;
25824
25941
  return (
25825
25942
  // Pulled up against the balance line despite the column's 2rem gap
25826
25943
  /* @__PURE__ */ jsx57(Box, { $marginTop: "-1.5rem", children: /* @__PURE__ */ jsxs42(
@@ -25981,10 +26098,10 @@ var MeteredFeatures = forwardRef12(({ className, ...rest }, ref) => {
25981
26098
  MeteredFeatures.displayName = "MeteredFeatures";
25982
26099
 
25983
26100
  // src/components/elements/payment-method/PaymentMethod.tsx
25984
- import { forwardRef as forwardRef13, useMemo as useMemo30 } from "react";
26101
+ import { forwardRef as forwardRef13, useMemo as useMemo31 } from "react";
25985
26102
 
25986
26103
  // src/components/elements/payment-method/PaymentMethodElement.tsx
25987
- import { useMemo as useMemo29 } from "react";
26104
+ import { useMemo as useMemo30 } from "react";
25988
26105
  import { jsx as jsx58, jsxs as jsxs43 } from "react/jsx-runtime";
25989
26106
  var PaymentElement2 = ({
25990
26107
  iconName,
@@ -26160,7 +26277,7 @@ var PaymentListElement = ({
26160
26277
  const { settings } = useEmbed();
26161
26278
  const isLightBackground = useIsLightBackground();
26162
26279
  const { iconName, iconTitle, label, paymentLast4 } = getPaymentMethodData(paymentMethod);
26163
- const expirationDate = useMemo29(() => {
26280
+ const expirationDate = useMemo30(() => {
26164
26281
  const { cardExpMonth, cardExpYear } = paymentMethod;
26165
26282
  if (!cardExpMonth || !cardExpYear) {
26166
26283
  return;
@@ -26255,7 +26372,7 @@ var resolveDesignProps5 = (props) => {
26255
26372
  var PaymentMethod = forwardRef13(({ children, className, portal, allowEdit = true, ...rest }, ref) => {
26256
26373
  const props = resolveDesignProps5(rest);
26257
26374
  const { data, setLayout } = useEmbed();
26258
- const { paymentMethod, monthsToExpiration } = useMemo30(() => {
26375
+ const { paymentMethod, monthsToExpiration } = useMemo31(() => {
26259
26376
  const paymentMethod2 = data?.subscription?.paymentMethod || data?.company?.defaultPaymentMethod;
26260
26377
  let monthsToExpiration2;
26261
26378
  if (typeof paymentMethod2?.cardExpYear === "number" && typeof paymentMethod2?.cardExpMonth === "number") {
@@ -26459,7 +26576,7 @@ var loadStripe = function loadStripe2() {
26459
26576
  };
26460
26577
 
26461
26578
  // src/components/elements/payment-method/PaymentMethodDetails.tsx
26462
- import { useCallback as useCallback15, useEffect as useEffect7, useMemo as useMemo31, useState as useState19 } from "react";
26579
+ import { useCallback as useCallback15, useEffect as useEffect7, useMemo as useMemo32, useState as useState19 } from "react";
26463
26580
  import { jsx as jsx60, jsxs as jsxs44 } from "react/jsx-runtime";
26464
26581
  var resolveDesignProps6 = () => {
26465
26582
  return {
@@ -26488,7 +26605,7 @@ var PaymentMethodDetails = ({
26488
26605
  updatePaymentMethod,
26489
26606
  deletePaymentMethod
26490
26607
  } = useEmbed();
26491
- const { defaultPaymentMethod, paymentMethods, subscription } = useMemo31(() => {
26608
+ const { defaultPaymentMethod, paymentMethods, subscription } = useMemo32(() => {
26492
26609
  return {
26493
26610
  defaultPaymentMethod: data?.company?.defaultPaymentMethod,
26494
26611
  paymentMethods: data?.company?.paymentMethods || [],
@@ -26520,7 +26637,7 @@ var PaymentMethodDetails = ({
26520
26637
  },
26521
26638
  autoConfirm: true
26522
26639
  });
26523
- const monthsToExpiration = useMemo31(() => {
26640
+ const monthsToExpiration = useMemo32(() => {
26524
26641
  let expiration;
26525
26642
  if (typeof currentPaymentMethod?.cardExpYear === "number" && typeof currentPaymentMethod?.cardExpMonth === "number") {
26526
26643
  const now = /* @__PURE__ */ new Date();
@@ -26543,7 +26660,7 @@ var PaymentMethodDetails = ({
26543
26660
  const toggleShowPaymentMethods = () => {
26544
26661
  setShowDifferentPaymentMethods((prev2) => !prev2);
26545
26662
  };
26546
- const locale = useMemo31(() => stripeLocale(language), [language]);
26663
+ const locale = useMemo32(() => stripeLocale(language), [language]);
26547
26664
  const initializeStripe = useCallback15(() => {
26548
26665
  if (stripe || !setupIntent) {
26549
26666
  return;
@@ -26803,7 +26920,7 @@ var PaymentMethodDetails = ({
26803
26920
  };
26804
26921
 
26805
26922
  // src/components/elements/plan-manager/PlanManager.tsx
26806
- import { forwardRef as forwardRef14, useMemo as useMemo33 } from "react";
26923
+ import { forwardRef as forwardRef14, useMemo as useMemo34 } from "react";
26807
26924
 
26808
26925
  // src/components/elements/plan-manager/AddOn.tsx
26809
26926
  import { jsx as jsx61, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -26829,7 +26946,7 @@ var AddOn = ({ addOn, currency, period, layout }) => {
26829
26946
  };
26830
26947
 
26831
26948
  // src/components/elements/plan-manager/UsageDetails.tsx
26832
- import { Fragment as Fragment23, useMemo as useMemo32 } from "react";
26949
+ import { Fragment as Fragment23, useMemo as useMemo33 } from "react";
26833
26950
  import { Fragment as Fragment24, jsx as jsx62, jsxs as jsxs46 } from "react/jsx-runtime";
26834
26951
  var UsageDetails2 = ({
26835
26952
  entitlement,
@@ -26845,13 +26962,13 @@ var UsageDetails2 = ({
26845
26962
  billingPrice,
26846
26963
  limit,
26847
26964
  cost = 0
26848
- } = useMemo32(
26965
+ } = useMemo33(
26849
26966
  () => getUsageDetails(entitlement, period, currency, {
26850
26967
  showWarningThresholdAsLimit
26851
26968
  }),
26852
26969
  [entitlement, period, currency, showWarningThresholdAsLimit]
26853
26970
  );
26854
- const description = useMemo32(() => {
26971
+ const description = useMemo33(() => {
26855
26972
  const acc = [];
26856
26973
  let index = 0;
26857
26974
  if (entitlement.priceBehavior === EntitlementPriceBehavior.Overage) {
@@ -27030,7 +27147,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27030
27147
  showCredits,
27031
27148
  showZeroPriceAsFree,
27032
27149
  trialPaymentMethodRequired
27033
- } = useMemo33(() => {
27150
+ } = useMemo34(() => {
27034
27151
  const planCreditOrder = /* @__PURE__ */ new Map();
27035
27152
  (data?.company?.plan?.includedCreditGrants ?? []).forEach((grant) => {
27036
27153
  if (!planCreditOrder.has(grant.creditId)) {
@@ -27090,15 +27207,15 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27090
27207
  data?.displaySettings?.showZeroPriceAsFree,
27091
27208
  data?.trialPaymentMethodRequired
27092
27209
  ]);
27093
- const usageBasedEntitlements = useMemo33(
27210
+ const usageBasedEntitlements = useMemo34(
27094
27211
  () => featureUsage.filter((usage) => typeof usage.priceBehavior === "string"),
27095
27212
  [featureUsage]
27096
27213
  );
27097
- const planCreditCompositions = useMemo33(
27214
+ const planCreditCompositions = useMemo34(
27098
27215
  () => groupPlanCreditGrants(currentPlan?.includedCreditGrants ?? []),
27099
27216
  [currentPlan?.includedCreditGrants]
27100
27217
  );
27101
- const resolveLicenseQuantity = useMemo33(() => {
27218
+ const resolveLicenseQuantity = useMemo34(() => {
27102
27219
  return (licenseId) => {
27103
27220
  const allocation = findLicenseSource(featureUsage, licenseId)?.allocation;
27104
27221
  return typeof allocation === "number" ? allocation : void 0;
@@ -27121,7 +27238,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27121
27238
  subscriptionCurrency,
27122
27239
  willSubscriptionCancel,
27123
27240
  isTrialSubscription
27124
- } = useMemo33(() => {
27241
+ } = useMemo34(() => {
27125
27242
  const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
27126
27243
  const subscriptionCurrency2 = billingSubscription?.currency;
27127
27244
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
@@ -27134,7 +27251,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
27134
27251
  };
27135
27252
  }, [billingSubscription]);
27136
27253
  const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
27137
- const { isFreePlan, isUsageBasedPlan } = useMemo33(() => {
27254
+ const { isFreePlan, isUsageBasedPlan } = useMemo34(() => {
27138
27255
  const isFreePlan2 = currentPlan?.planPrice === 0;
27139
27256
  const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
27140
27257
  return { isFreePlan: isFreePlan2, isUsageBasedPlan: isUsageBasedPlan2 };
@@ -27783,12 +27900,12 @@ import {
27783
27900
  forwardRef as forwardRef15,
27784
27901
  useCallback as useCallback16,
27785
27902
  useEffect as useEffect8,
27786
- useMemo as useMemo35,
27903
+ useMemo as useMemo36,
27787
27904
  useState as useState21
27788
27905
  } from "react";
27789
27906
 
27790
27907
  // src/components/elements/pricing-table/AddOn.tsx
27791
- import { useMemo as useMemo34 } from "react";
27908
+ import { useMemo as useMemo35 } from "react";
27792
27909
  import { Fragment as Fragment26, jsx as jsx64, jsxs as jsxs48 } from "react/jsx-runtime";
27793
27910
  function renderMeteredEntitlementPricing2({
27794
27911
  priceBehavior,
@@ -27846,7 +27963,7 @@ var AddOn2 = ({
27846
27963
  const { data, settings, setCheckoutState, warningThresholdConfig } = useEmbed();
27847
27964
  const showWarningThresholdAsLimit = warningThresholdConfig?.showAsLimit ?? false;
27848
27965
  const isLightBackground = useIsLightBackground();
27849
- const { currentAddOns, canCheckout, isStandalone } = useMemo34(() => {
27966
+ const { currentAddOns, canCheckout, isStandalone } = useMemo35(() => {
27850
27967
  const isStandalone2 = typeof data?.component === "undefined";
27851
27968
  return {
27852
27969
  currentAddOns: data?.company?.addOns || [],
@@ -28720,13 +28837,13 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
28720
28837
  } = useAvailablePlans(selectedPeriod, {
28721
28838
  useSelectedPeriod: showPeriodToggle
28722
28839
  });
28723
- const plans = useMemo35(
28840
+ const plans = useMemo36(
28724
28841
  () => hasCurrency ? allPlans.filter(
28725
28842
  (plan) => planSupportsCurrency(plan, selectedCurrency)
28726
28843
  ) : allPlans,
28727
28844
  [allPlans, hasCurrency, selectedCurrency]
28728
28845
  );
28729
- const addOns = useMemo35(
28846
+ const addOns = useMemo36(
28730
28847
  () => hasCurrency ? allAddOns.filter(
28731
28848
  (addOn) => planSupportsCurrency(addOn, selectedCurrency)
28732
28849
  ) : allAddOns,
@@ -28939,7 +29056,7 @@ var TextElement = forwardRef16(({ children, className, ...rest }, ref) => {
28939
29056
  TextElement.displayName = "Text";
28940
29057
 
28941
29058
  // src/components/elements/unsubscribe-button/UnsubscribeButton.tsx
28942
- import { forwardRef as forwardRef17, useMemo as useMemo36 } from "react";
29059
+ import { forwardRef as forwardRef17, useMemo as useMemo37 } from "react";
28943
29060
  import { jsx as jsx69 } from "react/jsx-runtime";
28944
29061
  var buttonStyles = {
28945
29062
  primary: {
@@ -28970,7 +29087,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
28970
29087
  const props = resolveDesignProps10(rest);
28971
29088
  const { t: t3 } = useTranslation();
28972
29089
  const { data, setLayout } = useEmbed();
28973
- const hasActiveSubscription = useMemo36(() => {
29090
+ const hasActiveSubscription = useMemo37(() => {
28974
29091
  return data?.subscription && data.subscription.status !== "cancelled" && !data.subscription.cancelAt;
28975
29092
  }, [data?.subscription]);
28976
29093
  if (!hasActiveSubscription) {
@@ -29005,7 +29122,7 @@ var UnsubscribeButton = forwardRef17(({ children, className, ...rest }, ref) =>
29005
29122
  UnsubscribeButton.displayName = "UnsubscribeButton";
29006
29123
 
29007
29124
  // src/components/elements/upcoming-bill/UpcomingBill.tsx
29008
- import { forwardRef as forwardRef18, useCallback as useCallback17, useEffect as useEffect9, useMemo as useMemo37, useState as useState22 } from "react";
29125
+ import { forwardRef as forwardRef18, useCallback as useCallback17, useEffect as useEffect9, useMemo as useMemo38, useState as useState22 } from "react";
29009
29126
  import { jsx as jsx70, jsxs as jsxs52 } from "react/jsx-runtime";
29010
29127
  function resolveDesignProps11(props) {
29011
29128
  return {
@@ -29033,7 +29150,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29033
29150
  const [isLoading, setIsLoading] = useState22(false);
29034
29151
  const [error, setError] = useState22();
29035
29152
  const [upcomingInvoice, setUpcomingInvoice] = useState22(data?.upcomingInvoice);
29036
- const discounts = useMemo37(() => {
29153
+ const discounts = useMemo38(() => {
29037
29154
  return (data?.subscription?.discounts || []).filter(
29038
29155
  (discount) => (
29039
29156
  // Only surface discounts that are currently active and actually
@@ -29075,7 +29192,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29075
29192
  setUpcomingInvoice(data.upcomingInvoice);
29076
29193
  }
29077
29194
  }, [data?.upcomingInvoice]);
29078
- const { currency, applied, remaining } = useMemo37(() => {
29195
+ const { currency, applied, remaining } = useMemo38(() => {
29079
29196
  const currency2 = upcomingInvoice?.currency;
29080
29197
  const startingBalance = upcomingInvoice?.startingBalance ?? 0;
29081
29198
  const endingBalance = upcomingInvoice?.endingBalance ?? 0;
@@ -29089,6 +29206,7 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29089
29206
  upcomingInvoice?.endingBalance,
29090
29207
  upcomingInvoice?.subtotal
29091
29208
  ]);
29209
+ const { billDate, paymentDueDate } = useNextBillDate(upcomingInvoice ?? null);
29092
29210
  const hasApplied = applied > 0;
29093
29211
  const hasBalance = remaining > 0 || applied > 0;
29094
29212
  if (!data?.subscription || data.subscription.cancelAt) {
@@ -29120,10 +29238,21 @@ var UpcomingBill = forwardRef18(({ className, ...rest }, ref) => {
29120
29238
  ]
29121
29239
  }
29122
29240
  ) : !isLoading && /* @__PURE__ */ jsx70(TransitionBox, { children: upcomingInvoice ? /* @__PURE__ */ jsxs52(Flex, { $flexDirection: "column", $gap: "1rem", children: [
29123
- props.header.isVisible && upcomingInvoice.dueDate && /* @__PURE__ */ jsxs52(Text, { display: props.header.fontStyle, children: [
29124
- t3(props.header.prefix),
29125
- " ",
29126
- toPrettyDate(upcomingInvoice.dueDate, { locale })
29241
+ props.header.isVisible && upcomingInvoice.dueDate && billDate && /* @__PURE__ */ jsxs52(Flex, { $flexDirection: "column", $gap: "0.25rem", children: [
29242
+ /* @__PURE__ */ jsxs52(Text, { display: props.header.fontStyle, children: [
29243
+ t3(props.header.prefix),
29244
+ " ",
29245
+ toPrettyDate(billDate, { locale })
29246
+ ] }),
29247
+ paymentDueDate && /* @__PURE__ */ jsx70(
29248
+ Text,
29249
+ {
29250
+ $size: 0.8125 * settings.theme.typography.text.fontSize,
29251
+ children: t3("Payment due", {
29252
+ date: toPrettyDate(paymentDueDate, { locale })
29253
+ })
29254
+ }
29255
+ )
29127
29256
  ] }),
29128
29257
  /* @__PURE__ */ jsxs52(
29129
29258
  Flex,
@@ -31865,7 +31994,7 @@ function inflate(input, options = {}) {
31865
31994
  }
31866
31995
 
31867
31996
  // src/components/embed/Embed.tsx
31868
- import { useContext as useContext3, useEffect as useEffect10, useMemo as useMemo38 } from "react";
31997
+ import { useContext as useContext3, useEffect as useEffect10, useMemo as useMemo39 } from "react";
31869
31998
 
31870
31999
  // src/components/embed/renderer.ts
31871
32000
  import { createElement } from "react";
@@ -31995,7 +32124,7 @@ var SchematicEmbed = ({ id, accessToken }) => {
31995
32124
  setBuilderSettings
31996
32125
  } = useEmbed();
31997
32126
  const compressedAst = data?.component?.ast;
31998
- const { children, parsedSettings, parseError } = useMemo38(() => {
32127
+ const { children, parsedSettings, parseError } = useMemo39(() => {
31999
32128
  let children2 = null;
32000
32129
  let parsedSettings2 = null;
32001
32130
  let parseError2 = null;
@@ -32150,6 +32279,7 @@ export {
32150
32279
  useCustomPlanBilling,
32151
32280
  useEmbed,
32152
32281
  useIsLightBackground,
32282
+ useNextBillDate,
32153
32283
  usePaymentConfirmation,
32154
32284
  useRequest,
32155
32285
  useSubscriptionCurrency,