@schematichq/schematic-components 2.37.0 → 2.39.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.
@@ -3814,6 +3814,7 @@ var initialContext = {
3814
3814
  getUpcomingInvoice: stub,
3815
3815
  getCustomerBalance: stub,
3816
3816
  listInvoices: stub,
3817
+ getInvoiceLink: stub,
3817
3818
  getCreditUsageByUser: stub,
3818
3819
  getFeatureUsageByUser: stub,
3819
3820
  createSetupIntent: stub,
@@ -5074,6 +5075,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
5074
5075
  quantity: json["quantity"],
5075
5076
  subscriptionId: json["subscription_id"],
5076
5077
  subscriptionItemExternalId: json["subscription_item_external_id"] == null ? void 0 : json["subscription_item_external_id"],
5078
+ tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON(json["tiers_mode"]),
5077
5079
  updatedAt: new Date(json["updated_at"]),
5078
5080
  usageType: BillingPriceUsageTypeFromJSON(json["usage_type"])
5079
5081
  };
@@ -6551,6 +6553,119 @@ function CompanyCreditBalancesResponseDataFromJSONTyped(json, ignoreDiscriminato
6551
6553
  };
6552
6554
  }
6553
6555
 
6556
+ // src/api/checkoutexternal/models/CompanyCreditLedgerBundleResponseData.ts
6557
+ function CompanyCreditLedgerBundleResponseDataFromJSON(json) {
6558
+ return CompanyCreditLedgerBundleResponseDataFromJSONTyped(json, false);
6559
+ }
6560
+ function CompanyCreditLedgerBundleResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6561
+ if (json == null) {
6562
+ return json;
6563
+ }
6564
+ return {
6565
+ id: json["id"],
6566
+ name: json["name"]
6567
+ };
6568
+ }
6569
+
6570
+ // src/api/checkoutexternal/models/CompanyCreditLedgerCreditResponseData.ts
6571
+ function CompanyCreditLedgerCreditResponseDataFromJSON(json) {
6572
+ return CompanyCreditLedgerCreditResponseDataFromJSONTyped(json, false);
6573
+ }
6574
+ function CompanyCreditLedgerCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6575
+ if (json == null) {
6576
+ return json;
6577
+ }
6578
+ return {
6579
+ id: json["id"],
6580
+ name: json["name"],
6581
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
6582
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"]
6583
+ };
6584
+ }
6585
+
6586
+ // src/api/checkoutexternal/models/CreditUsageReason.ts
6587
+ function CreditUsageReasonFromJSON(json) {
6588
+ return CreditUsageReasonFromJSONTyped(json, false);
6589
+ }
6590
+ function CreditUsageReasonFromJSONTyped(json, ignoreDiscriminator) {
6591
+ return json;
6592
+ }
6593
+
6594
+ // src/api/checkoutexternal/models/CompanyCreditLedgerUserResponseData.ts
6595
+ function CompanyCreditLedgerUserResponseDataFromJSON(json) {
6596
+ return CompanyCreditLedgerUserResponseDataFromJSONTyped(json, false);
6597
+ }
6598
+ function CompanyCreditLedgerUserResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6599
+ if (json == null) {
6600
+ return json;
6601
+ }
6602
+ return {
6603
+ id: json["id"],
6604
+ name: json["name"]
6605
+ };
6606
+ }
6607
+
6608
+ // src/api/checkoutexternal/models/CompanyCreditLedgerFeatureResponseData.ts
6609
+ function CompanyCreditLedgerFeatureResponseDataFromJSON(json) {
6610
+ return CompanyCreditLedgerFeatureResponseDataFromJSONTyped(json, false);
6611
+ }
6612
+ function CompanyCreditLedgerFeatureResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6613
+ if (json == null) {
6614
+ return json;
6615
+ }
6616
+ return {
6617
+ id: json["id"],
6618
+ name: json["name"]
6619
+ };
6620
+ }
6621
+
6622
+ // src/api/checkoutexternal/models/CreditLedgerEntryKind.ts
6623
+ function CreditLedgerEntryKindFromJSON(json) {
6624
+ return CreditLedgerEntryKindFromJSONTyped(json, false);
6625
+ }
6626
+ function CreditLedgerEntryKindFromJSONTyped(json, ignoreDiscriminator) {
6627
+ return json;
6628
+ }
6629
+
6630
+ // src/api/checkoutexternal/models/CompanyCreditLedgerEntryResponseData.ts
6631
+ function CompanyCreditLedgerEntryResponseDataFromJSON(json) {
6632
+ return CompanyCreditLedgerEntryResponseDataFromJSONTyped(json, false);
6633
+ }
6634
+ function CompanyCreditLedgerEntryResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6635
+ if (json == null) {
6636
+ return json;
6637
+ }
6638
+ return {
6639
+ amount: json["amount"],
6640
+ bundle: json["bundle"] == null ? void 0 : CompanyCreditLedgerBundleResponseDataFromJSON(json["bundle"]),
6641
+ credit: CompanyCreditLedgerCreditResponseDataFromJSON(json["credit"]),
6642
+ eventAt: new Date(json["event_at"]),
6643
+ feature: json["feature"] == null ? void 0 : CompanyCreditLedgerFeatureResponseDataFromJSON(json["feature"]),
6644
+ grantReason: json["grant_reason"] == null ? void 0 : BillingCreditGrantReasonFromJSON(json["grant_reason"]),
6645
+ id: json["id"],
6646
+ kind: CreditLedgerEntryKindFromJSON(json["kind"]),
6647
+ usageReason: json["usage_reason"] == null ? void 0 : CreditUsageReasonFromJSON(json["usage_reason"]),
6648
+ user: json["user"] == null ? void 0 : CompanyCreditLedgerUserResponseDataFromJSON(json["user"]),
6649
+ zeroedOutReason: json["zeroed_out_reason"] == null ? void 0 : BillingCreditGrantZeroedOutReasonFromJSON(json["zeroed_out_reason"])
6650
+ };
6651
+ }
6652
+
6653
+ // src/api/checkoutexternal/models/CompanyCreditLedgerResponseData.ts
6654
+ function CompanyCreditLedgerResponseDataFromJSON(json) {
6655
+ return CompanyCreditLedgerResponseDataFromJSONTyped(json, false);
6656
+ }
6657
+ function CompanyCreditLedgerResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6658
+ if (json == null) {
6659
+ return json;
6660
+ }
6661
+ return {
6662
+ entries: json["entries"].map(
6663
+ CompanyCreditLedgerEntryResponseDataFromJSON
6664
+ ),
6665
+ nextCursor: json["next_cursor"] == null ? void 0 : json["next_cursor"]
6666
+ };
6667
+ }
6668
+
6554
6669
  // src/api/checkoutexternal/models/CompanyCreditUserUsageRowResponseData.ts
6555
6670
  function CompanyCreditUserUsageRowResponseDataFromJSON(json) {
6556
6671
  return CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, false);
@@ -6784,7 +6899,9 @@ function ScheduledDowngradeResponseDataFromJSONTyped(json, ignoreDiscriminator)
6784
6899
  fromSubscriptionPrice: json["from_subscription_price"],
6785
6900
  id: json["id"],
6786
6901
  interval: json["interval"],
6902
+ intervalCount: json["interval_count"],
6787
6903
  scheduledInterval: json["scheduled_interval"] == null ? void 0 : json["scheduled_interval"],
6904
+ scheduledIntervalCount: json["scheduled_interval_count"] == null ? void 0 : json["scheduled_interval_count"],
6788
6905
  scheduledPrice: json["scheduled_price"] == null ? void 0 : json["scheduled_price"],
6789
6906
  toPlanId: json["to_plan_id"],
6790
6907
  toPlanName: json["to_plan_name"]
@@ -7940,6 +8057,20 @@ function PlanCurrencyPricesResponseDataFromJSONTyped(json, ignoreDiscriminator)
7940
8057
  };
7941
8058
  }
7942
8059
 
8060
+ // src/api/checkoutexternal/models/RenewalDestinationResponseData.ts
8061
+ function RenewalDestinationResponseDataFromJSON(json) {
8062
+ return RenewalDestinationResponseDataFromJSONTyped(json, false);
8063
+ }
8064
+ function RenewalDestinationResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8065
+ if (json == null) {
8066
+ return json;
8067
+ }
8068
+ return {
8069
+ billingPeriod: PlanPriceCadenceFromJSON(json["billing_period"]),
8070
+ planId: json["plan_id"]
8071
+ };
8072
+ }
8073
+
7943
8074
  // src/api/checkoutexternal/models/RenewalPolicy.ts
7944
8075
  function RenewalPolicyFromJSON(json) {
7945
8076
  return RenewalPolicyFromJSONTyped(json, false);
@@ -7965,6 +8096,7 @@ function PlanVersionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7965
8096
  name: json["name"],
7966
8097
  originalPlanId: json["original_plan_id"] == null ? void 0 : json["original_plan_id"],
7967
8098
  planType: PlanTypeFromJSON(json["plan_type"]),
8099
+ renewalDestination: json["renewal_destination"] == null ? void 0 : RenewalDestinationResponseDataFromJSON(json["renewal_destination"]),
7968
8100
  renewalPolicy: RenewalPolicyFromJSON(json["renewal_policy"]),
7969
8101
  status: PlanVersionStatusFromJSON(json["status"]),
7970
8102
  updatedAt: new Date(json["updated_at"]),
@@ -8168,6 +8300,7 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
8168
8300
  ),
8169
8301
  expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
8170
8302
  interval: json["interval"],
8303
+ intervalCount: json["interval_count"] == null ? void 0 : json["interval_count"],
8171
8304
  isInitial: json["is_initial"],
8172
8305
  latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
8173
8306
  pauseBehavior: json["pause_behavior"] == null ? void 0 : BillingSubscriptionPauseBehaviorFromJSON(json["pause_behavior"]),
@@ -8644,6 +8777,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
8644
8777
  };
8645
8778
  }
8646
8779
 
8780
+ // src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
8781
+ function CreditSpendWindowUnitFromJSON(json) {
8782
+ return CreditSpendWindowUnitFromJSONTyped(json, false);
8783
+ }
8784
+ function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
8785
+ return json;
8786
+ }
8787
+ function CreditSpendWindowUnitToJSON(value) {
8788
+ return value;
8789
+ }
8790
+
8791
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
8792
+ function CreateCompanySpendPolicyRequestBodyToJSON(json) {
8793
+ return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
8794
+ }
8795
+ function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
8796
+ if (value == null) {
8797
+ return value;
8798
+ }
8799
+ return {
8800
+ billing_credit_id: value["billingCreditId"],
8801
+ label: value["label"],
8802
+ max_per_draw: value["maxPerDraw"],
8803
+ user_id: value["userId"],
8804
+ window_amount: value["windowAmount"],
8805
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
8806
+ };
8807
+ }
8808
+
8809
+ // src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
8810
+ function CreditSpendPolicyScopeFromJSON(json) {
8811
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
8812
+ }
8813
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
8814
+ return json;
8815
+ }
8816
+
8817
+ // src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
8818
+ function CreditSpendPolicyResponseDataFromJSON(json) {
8819
+ return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
8820
+ }
8821
+ function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8822
+ if (json == null) {
8823
+ return json;
8824
+ }
8825
+ return {
8826
+ billingCreditId: json["billing_credit_id"],
8827
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
8828
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
8829
+ createdAt: new Date(json["created_at"]),
8830
+ headroom: json["headroom"] == null ? void 0 : json["headroom"],
8831
+ id: json["id"],
8832
+ label: json["label"] == null ? void 0 : json["label"],
8833
+ maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
8834
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
8835
+ scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
8836
+ updatedAt: new Date(json["updated_at"]),
8837
+ userId: json["user_id"] == null ? void 0 : json["user_id"],
8838
+ windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
8839
+ windowCount: json["window_count"],
8840
+ windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
8841
+ };
8842
+ }
8843
+
8844
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
8845
+ function CreateCompanySpendPolicyResponseFromJSON(json) {
8846
+ return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
8847
+ }
8848
+ function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8849
+ if (json == null) {
8850
+ return json;
8851
+ }
8852
+ return {
8853
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
8854
+ params: json["params"]
8855
+ };
8856
+ }
8857
+
8647
8858
  // src/api/checkoutexternal/models/SetupIntentResponseData.ts
8648
8859
  function SetupIntentResponseDataFromJSON(json) {
8649
8860
  return SetupIntentResponseDataFromJSONTyped(json, false);
@@ -8732,6 +8943,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8732
8943
  };
8733
8944
  }
8734
8945
 
8946
+ // src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
8947
+ function DeleteCompanySpendPolicyResponseFromJSON(json) {
8948
+ return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
8949
+ }
8950
+ function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8951
+ if (json == null) {
8952
+ return json;
8953
+ }
8954
+ return {
8955
+ data: DeleteResponseFromJSON(json["data"]),
8956
+ params: json["params"]
8957
+ };
8958
+ }
8959
+
8735
8960
  // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
8736
8961
  function DeletePaymentMethodResponseFromJSON(json) {
8737
8962
  return DeletePaymentMethodResponseFromJSONTyped(json, false);
@@ -8909,6 +9134,36 @@ function GetCompanyCreditBalancesResponseFromJSONTyped(json, ignoreDiscriminator
8909
9134
  };
8910
9135
  }
8911
9136
 
9137
+ // src/api/checkoutexternal/models/GetCompanyCreditLedgerParams.ts
9138
+ function GetCompanyCreditLedgerParamsFromJSON(json) {
9139
+ return GetCompanyCreditLedgerParamsFromJSONTyped(json, false);
9140
+ }
9141
+ function GetCompanyCreditLedgerParamsFromJSONTyped(json, ignoreDiscriminator) {
9142
+ if (json == null) {
9143
+ return json;
9144
+ }
9145
+ return {
9146
+ creditIds: json["credit_ids"] == null ? void 0 : json["credit_ids"],
9147
+ cursor: json["cursor"] == null ? void 0 : json["cursor"],
9148
+ includeGrants: json["include_grants"] == null ? void 0 : json["include_grants"],
9149
+ limit: json["limit"] == null ? void 0 : json["limit"]
9150
+ };
9151
+ }
9152
+
9153
+ // src/api/checkoutexternal/models/GetCompanyCreditLedgerResponse.ts
9154
+ function GetCompanyCreditLedgerResponseFromJSON(json) {
9155
+ return GetCompanyCreditLedgerResponseFromJSONTyped(json, false);
9156
+ }
9157
+ function GetCompanyCreditLedgerResponseFromJSONTyped(json, ignoreDiscriminator) {
9158
+ if (json == null) {
9159
+ return json;
9160
+ }
9161
+ return {
9162
+ data: CompanyCreditLedgerResponseDataFromJSON(json["data"]),
9163
+ params: GetCompanyCreditLedgerParamsFromJSON(json["params"])
9164
+ };
9165
+ }
9166
+
8912
9167
  // src/api/checkoutexternal/models/GetCompanyCreditUserUsageParams.ts
8913
9168
  function GetCompanyCreditUserUsageParamsFromJSON(json) {
8914
9169
  return GetCompanyCreditUserUsageParamsFromJSONTyped(json, false);
@@ -9106,6 +9361,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
9106
9361
  };
9107
9362
  }
9108
9363
 
9364
+ // src/api/checkoutexternal/models/InvoiceLink.ts
9365
+ function InvoiceLinkFromJSON(json) {
9366
+ return InvoiceLinkFromJSONTyped(json, false);
9367
+ }
9368
+ function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
9369
+ if (json == null) {
9370
+ return json;
9371
+ }
9372
+ return {
9373
+ id: json["id"],
9374
+ url: json["url"]
9375
+ };
9376
+ }
9377
+
9378
+ // src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
9379
+ function GetInvoiceLinkResponseFromJSON(json) {
9380
+ return GetInvoiceLinkResponseFromJSONTyped(json, false);
9381
+ }
9382
+ function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
9383
+ if (json == null) {
9384
+ return json;
9385
+ }
9386
+ return {
9387
+ data: InvoiceLinkFromJSON(json["data"]),
9388
+ params: json["params"]
9389
+ };
9390
+ }
9391
+
9109
9392
  // src/api/checkoutexternal/models/GetSetupIntentResponse.ts
9110
9393
  function GetSetupIntentResponseFromJSON(json) {
9111
9394
  return GetSetupIntentResponseFromJSONTyped(json, false);
@@ -9219,6 +9502,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
9219
9502
  };
9220
9503
  }
9221
9504
 
9505
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
9506
+ function ListCompanySpendPoliciesParamsFromJSON(json) {
9507
+ return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
9508
+ }
9509
+ function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
9510
+ if (json == null) {
9511
+ return json;
9512
+ }
9513
+ return {
9514
+ billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
9515
+ };
9516
+ }
9517
+
9518
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
9519
+ function ListCompanySpendPoliciesResponseFromJSON(json) {
9520
+ return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
9521
+ }
9522
+ function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
9523
+ if (json == null) {
9524
+ return json;
9525
+ }
9526
+ return {
9527
+ data: json["data"].map(
9528
+ CreditSpendPolicyResponseDataFromJSON
9529
+ ),
9530
+ params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
9531
+ };
9532
+ }
9533
+
9222
9534
  // src/api/checkoutexternal/models/ListInvoicesParams.ts
9223
9535
  function ListInvoicesParamsFromJSON(json) {
9224
9536
  return ListInvoicesParamsFromJSONTyped(json, false);
@@ -9391,6 +9703,7 @@ function PreviewSubscriptionChangeResponseDataFromJSONTyped(json, ignoreDiscrimi
9391
9703
  proration: json["proration"],
9392
9704
  scheduledChangeTime: json["scheduled_change_time"] == null ? void 0 : new Date(json["scheduled_change_time"]),
9393
9705
  trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"]),
9706
+ unbilledUsageFeatureIds: json["unbilled_usage_feature_ids"],
9394
9707
  usageViolations: json["usage_violations"].map(
9395
9708
  FeatureUsageResponseDataFromJSON
9396
9709
  )
@@ -9549,6 +9862,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
9549
9862
  };
9550
9863
  }
9551
9864
 
9865
+ // src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
9866
+ function UpdateCompanySpendPolicyResponseFromJSON(json) {
9867
+ return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
9868
+ }
9869
+ function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
9870
+ if (json == null) {
9871
+ return json;
9872
+ }
9873
+ return {
9874
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
9875
+ params: json["params"]
9876
+ };
9877
+ }
9878
+
9879
+ // src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
9880
+ function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
9881
+ return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
9882
+ }
9883
+ function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
9884
+ if (value == null) {
9885
+ return value;
9886
+ }
9887
+ return {
9888
+ label: value["label"],
9889
+ max_per_draw: value["maxPerDraw"],
9890
+ window_amount: value["windowAmount"],
9891
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
9892
+ };
9893
+ }
9894
+
9552
9895
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
9553
9896
  function UpdatePaymentMethodRequestBodyToJSON(json) {
9554
9897
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -9706,6 +10049,51 @@ var CheckoutexternalApi = class extends BaseAPI {
9706
10049
  );
9707
10050
  return await response.value();
9708
10051
  }
10052
+ /**
10053
+ * Create company spend policy
10054
+ */
10055
+ async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
10056
+ if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
10057
+ throw new RequiredError(
10058
+ "createCompanySpendPolicyRequestBody",
10059
+ 'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
10060
+ );
10061
+ }
10062
+ const queryParameters = {};
10063
+ const headerParameters = {};
10064
+ headerParameters["Content-Type"] = "application/json";
10065
+ if (this.configuration && this.configuration.apiKey) {
10066
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10067
+ "X-Schematic-Api-Key"
10068
+ );
10069
+ }
10070
+ const response = await this.request(
10071
+ {
10072
+ path: `/company/credits/spend-policies`,
10073
+ method: "POST",
10074
+ headers: headerParameters,
10075
+ query: queryParameters,
10076
+ body: CreateCompanySpendPolicyRequestBodyToJSON(
10077
+ requestParameters["createCompanySpendPolicyRequestBody"]
10078
+ )
10079
+ },
10080
+ initOverrides
10081
+ );
10082
+ return new JSONApiResponse(
10083
+ response,
10084
+ (jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
10085
+ );
10086
+ }
10087
+ /**
10088
+ * Create company spend policy
10089
+ */
10090
+ async createCompanySpendPolicy(requestParameters, initOverrides) {
10091
+ const response = await this.createCompanySpendPolicyRaw(
10092
+ requestParameters,
10093
+ initOverrides
10094
+ );
10095
+ return await response.value();
10096
+ }
9709
10097
  /**
9710
10098
  * A Stripe SetupIntent for collecting a new payment method with Stripe\'s Payment Element. Confirm it with `stripe.confirmSetup`; the method it saves joins the company\'s methods on file.
9711
10099
  * Create a setup intent
@@ -9740,6 +10128,50 @@ var CheckoutexternalApi = class extends BaseAPI {
9740
10128
  const response = await this.createSetupIntentRaw(initOverrides);
9741
10129
  return await response.value();
9742
10130
  }
10131
+ /**
10132
+ * Delete company spend policy
10133
+ */
10134
+ async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
10135
+ if (requestParameters["spendPolicyId"] == null) {
10136
+ throw new RequiredError(
10137
+ "spendPolicyId",
10138
+ 'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
10139
+ );
10140
+ }
10141
+ const queryParameters = {};
10142
+ const headerParameters = {};
10143
+ if (this.configuration && this.configuration.apiKey) {
10144
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10145
+ "X-Schematic-Api-Key"
10146
+ );
10147
+ }
10148
+ const response = await this.request(
10149
+ {
10150
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
10151
+ `{${"spend_policy_id"}}`,
10152
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
10153
+ ),
10154
+ method: "DELETE",
10155
+ headers: headerParameters,
10156
+ query: queryParameters
10157
+ },
10158
+ initOverrides
10159
+ );
10160
+ return new JSONApiResponse(
10161
+ response,
10162
+ (jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
10163
+ );
10164
+ }
10165
+ /**
10166
+ * Delete company spend policy
10167
+ */
10168
+ async deleteCompanySpendPolicy(requestParameters, initOverrides) {
10169
+ const response = await this.deleteCompanySpendPolicyRaw(
10170
+ requestParameters,
10171
+ initOverrides
10172
+ );
10173
+ return await response.value();
10174
+ }
9743
10175
  /**
9744
10176
  * Detaches a payment method from the company\'s billing customer. The path parameter is the payment method\'s `id` from the list, not a checkout\'s; `usePaymentMethods().remove` calls this and reloads the list. The list says whether each method can be removed.
9745
10177
  * Remove a payment method
@@ -10107,6 +10539,55 @@ var CheckoutexternalApi = class extends BaseAPI {
10107
10539
  const response = await this.getCompanyCreditBalancesRaw(initOverrides);
10108
10540
  return await response.value();
10109
10541
  }
10542
+ /**
10543
+ * The company\'s credit activity, newest first: draws by feature and user, grants, and credits removed when they expired or reset. A draw written against several grants is one entry. Pass the response\'s `next_cursor` as `cursor` to read the next page.
10544
+ * List credit activity
10545
+ */
10546
+ async getCompanyCreditLedgerRaw(requestParameters, initOverrides) {
10547
+ const queryParameters = {};
10548
+ if (requestParameters["creditIds"] != null) {
10549
+ queryParameters["credit_ids"] = requestParameters["creditIds"];
10550
+ }
10551
+ if (requestParameters["cursor"] != null) {
10552
+ queryParameters["cursor"] = requestParameters["cursor"];
10553
+ }
10554
+ if (requestParameters["includeGrants"] != null) {
10555
+ queryParameters["include_grants"] = requestParameters["includeGrants"];
10556
+ }
10557
+ if (requestParameters["limit"] != null) {
10558
+ queryParameters["limit"] = requestParameters["limit"];
10559
+ }
10560
+ const headerParameters = {};
10561
+ if (this.configuration && this.configuration.apiKey) {
10562
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10563
+ "X-Schematic-Api-Key"
10564
+ );
10565
+ }
10566
+ const response = await this.request(
10567
+ {
10568
+ path: `/company/credits/ledger`,
10569
+ method: "GET",
10570
+ headers: headerParameters,
10571
+ query: queryParameters
10572
+ },
10573
+ initOverrides
10574
+ );
10575
+ return new JSONApiResponse(
10576
+ response,
10577
+ (jsonValue) => GetCompanyCreditLedgerResponseFromJSON(jsonValue)
10578
+ );
10579
+ }
10580
+ /**
10581
+ * The company\'s credit activity, newest first: draws by feature and user, grants, and credits removed when they expired or reset. A draw written against several grants is one entry. Pass the response\'s `next_cursor` as `cursor` to read the next page.
10582
+ * List credit activity
10583
+ */
10584
+ async getCompanyCreditLedger(requestParameters = {}, initOverrides) {
10585
+ const response = await this.getCompanyCreditLedgerRaw(
10586
+ requestParameters,
10587
+ initOverrides
10588
+ );
10589
+ return await response.value();
10590
+ }
10110
10591
  /**
10111
10592
  * Who in the company consumed the credit, and how much each.
10112
10593
  * List credit usage by user
@@ -10466,6 +10947,50 @@ var CheckoutexternalApi = class extends BaseAPI {
10466
10947
  );
10467
10948
  return await response.value();
10468
10949
  }
10950
+ /**
10951
+ * Get invoice link
10952
+ */
10953
+ async getInvoiceLinkRaw(requestParameters, initOverrides) {
10954
+ if (requestParameters["billingInvoiceId"] == null) {
10955
+ throw new RequiredError(
10956
+ "billingInvoiceId",
10957
+ 'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
10958
+ );
10959
+ }
10960
+ const queryParameters = {};
10961
+ const headerParameters = {};
10962
+ if (this.configuration && this.configuration.apiKey) {
10963
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10964
+ "X-Schematic-Api-Key"
10965
+ );
10966
+ }
10967
+ const response = await this.request(
10968
+ {
10969
+ path: `/components/invoices/{billing_invoice_id}/link`.replace(
10970
+ `{${"billing_invoice_id"}}`,
10971
+ encodeURIComponent(String(requestParameters["billingInvoiceId"]))
10972
+ ),
10973
+ method: "GET",
10974
+ headers: headerParameters,
10975
+ query: queryParameters
10976
+ },
10977
+ initOverrides
10978
+ );
10979
+ return new JSONApiResponse(
10980
+ response,
10981
+ (jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
10982
+ );
10983
+ }
10984
+ /**
10985
+ * Get invoice link
10986
+ */
10987
+ async getInvoiceLink(requestParameters, initOverrides) {
10988
+ const response = await this.getInvoiceLinkRaw(
10989
+ requestParameters,
10990
+ initOverrides
10991
+ );
10992
+ return await response.value();
10993
+ }
10469
10994
  /**
10470
10995
  * Get setup intent
10471
10996
  */
@@ -10665,7 +11190,46 @@ var CheckoutexternalApi = class extends BaseAPI {
10665
11190
  }
10666
11191
  const response = await this.request(
10667
11192
  {
10668
- path: `/checkouts`,
11193
+ path: `/checkouts`,
11194
+ method: "GET",
11195
+ headers: headerParameters,
11196
+ query: queryParameters
11197
+ },
11198
+ initOverrides
11199
+ );
11200
+ return new JSONApiResponse(
11201
+ response,
11202
+ (jsonValue) => ListCheckoutsResponseFromJSON(jsonValue)
11203
+ );
11204
+ }
11205
+ /**
11206
+ * The checkouts this session opened for the token\'s company. Filter by `statuses`.
11207
+ * List checkouts
11208
+ */
11209
+ async listCheckouts(requestParameters = {}, initOverrides) {
11210
+ const response = await this.listCheckoutsRaw(
11211
+ requestParameters,
11212
+ initOverrides
11213
+ );
11214
+ return await response.value();
11215
+ }
11216
+ /**
11217
+ * List company spend policies
11218
+ */
11219
+ async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
11220
+ const queryParameters = {};
11221
+ if (requestParameters["billingCreditId"] != null) {
11222
+ queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
11223
+ }
11224
+ const headerParameters = {};
11225
+ if (this.configuration && this.configuration.apiKey) {
11226
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11227
+ "X-Schematic-Api-Key"
11228
+ );
11229
+ }
11230
+ const response = await this.request(
11231
+ {
11232
+ path: `/company/credits/spend-policies`,
10669
11233
  method: "GET",
10670
11234
  headers: headerParameters,
10671
11235
  query: queryParameters
@@ -10674,15 +11238,14 @@ var CheckoutexternalApi = class extends BaseAPI {
10674
11238
  );
10675
11239
  return new JSONApiResponse(
10676
11240
  response,
10677
- (jsonValue) => ListCheckoutsResponseFromJSON(jsonValue)
11241
+ (jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
10678
11242
  );
10679
11243
  }
10680
11244
  /**
10681
- * The checkouts this session opened for the token\'s company. Filter by `statuses`.
10682
- * List checkouts
11245
+ * List company spend policies
10683
11246
  */
10684
- async listCheckouts(requestParameters = {}, initOverrides) {
10685
- const response = await this.listCheckoutsRaw(
11247
+ async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
11248
+ const response = await this.listCompanySpendPoliciesRaw(
10686
11249
  requestParameters,
10687
11250
  initOverrides
10688
11251
  );
@@ -10922,6 +11485,60 @@ var CheckoutexternalApi = class extends BaseAPI {
10922
11485
  );
10923
11486
  return await response.value();
10924
11487
  }
11488
+ /**
11489
+ * Update company spend policy
11490
+ */
11491
+ async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
11492
+ if (requestParameters["spendPolicyId"] == null) {
11493
+ throw new RequiredError(
11494
+ "spendPolicyId",
11495
+ 'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
11496
+ );
11497
+ }
11498
+ if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
11499
+ throw new RequiredError(
11500
+ "updateCreditSpendPolicyRequestBody",
11501
+ 'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
11502
+ );
11503
+ }
11504
+ const queryParameters = {};
11505
+ const headerParameters = {};
11506
+ headerParameters["Content-Type"] = "application/json";
11507
+ if (this.configuration && this.configuration.apiKey) {
11508
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11509
+ "X-Schematic-Api-Key"
11510
+ );
11511
+ }
11512
+ const response = await this.request(
11513
+ {
11514
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
11515
+ `{${"spend_policy_id"}}`,
11516
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
11517
+ ),
11518
+ method: "PUT",
11519
+ headers: headerParameters,
11520
+ query: queryParameters,
11521
+ body: UpdateCreditSpendPolicyRequestBodyToJSON(
11522
+ requestParameters["updateCreditSpendPolicyRequestBody"]
11523
+ )
11524
+ },
11525
+ initOverrides
11526
+ );
11527
+ return new JSONApiResponse(
11528
+ response,
11529
+ (jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
11530
+ );
11531
+ }
11532
+ /**
11533
+ * Update company spend policy
11534
+ */
11535
+ async updateCompanySpendPolicy(requestParameters, initOverrides) {
11536
+ const response = await this.updateCompanySpendPolicyRaw(
11537
+ requestParameters,
11538
+ initOverrides
11539
+ );
11540
+ return await response.value();
11541
+ }
10925
11542
  /**
10926
11543
  * Makes a method on file the one the company\'s charges use. The body\'s `payment_method_id` is the provider\'s id of the method, the `external_id` the list returns; `usePaymentMethods().setDefault` calls this and reloads the list. A card saved during a checkout joins the methods on file and becomes the default the same way.
10927
11544
  * Make a payment method the default
@@ -11447,9 +12064,9 @@ function BillingPriceUsageTypeFromJSONTyped5(json, ignoreDiscriminator) {
11447
12064
 
11448
12065
  // src/api/componentspublic/models/BillingTiersMode.ts
11449
12066
  function BillingTiersModeFromJSON2(json) {
11450
- return BillingTiersModeFromJSONTyped6(json, false);
12067
+ return BillingTiersModeFromJSONTyped7(json, false);
11451
12068
  }
11452
- function BillingTiersModeFromJSONTyped6(json, ignoreDiscriminator) {
12069
+ function BillingTiersModeFromJSONTyped7(json, ignoreDiscriminator) {
11453
12070
  return json;
11454
12071
  }
11455
12072
 
@@ -11725,9 +12342,9 @@ function ChargeTypeFromJSONTyped7(json, ignoreDiscriminator) {
11725
12342
 
11726
12343
  // src/api/componentspublic/models/PlanPriceCadence.ts
11727
12344
  function PlanPriceCadenceFromJSON2(json) {
11728
- return PlanPriceCadenceFromJSONTyped7(json, false);
12345
+ return PlanPriceCadenceFromJSONTyped8(json, false);
11729
12346
  }
11730
- function PlanPriceCadenceFromJSONTyped7(json, ignoreDiscriminator) {
12347
+ function PlanPriceCadenceFromJSONTyped8(json, ignoreDiscriminator) {
11731
12348
  return json;
11732
12349
  }
11733
12350
 
@@ -12356,6 +12973,20 @@ function PlanCurrencyPricesResponseDataFromJSONTyped5(json, ignoreDiscriminator)
12356
12973
  };
12357
12974
  }
12358
12975
 
12976
+ // src/api/componentspublic/models/RenewalDestinationResponseData.ts
12977
+ function RenewalDestinationResponseDataFromJSON2(json) {
12978
+ return RenewalDestinationResponseDataFromJSONTyped3(json, false);
12979
+ }
12980
+ function RenewalDestinationResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
12981
+ if (json == null) {
12982
+ return json;
12983
+ }
12984
+ return {
12985
+ billingPeriod: PlanPriceCadenceFromJSON2(json["billing_period"]),
12986
+ planId: json["plan_id"]
12987
+ };
12988
+ }
12989
+
12359
12990
  // src/api/componentspublic/models/RenewalPolicy.ts
12360
12991
  function RenewalPolicyFromJSON2(json) {
12361
12992
  return RenewalPolicyFromJSONTyped3(json, false);
@@ -12381,6 +13012,7 @@ function PlanVersionResponseDataFromJSONTyped5(json, ignoreDiscriminator) {
12381
13012
  name: json["name"],
12382
13013
  originalPlanId: json["original_plan_id"] == null ? void 0 : json["original_plan_id"],
12383
13014
  planType: PlanTypeFromJSON2(json["plan_type"]),
13015
+ renewalDestination: json["renewal_destination"] == null ? void 0 : RenewalDestinationResponseDataFromJSON2(json["renewal_destination"]),
12384
13016
  renewalPolicy: RenewalPolicyFromJSON2(json["renewal_policy"]),
12385
13017
  status: PlanVersionStatusFromJSON2(json["status"]),
12386
13018
  updatedAt: new Date(json["updated_at"]),
@@ -12949,7 +13581,7 @@ function resolveLocale(locale) {
12949
13581
  return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
12950
13582
  }
12951
13583
 
12952
- // node_modules/.pnpm/i18next@26.7.1_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
13584
+ // node_modules/.pnpm/i18next@27.1.2_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
12953
13585
  var isString = (obj) => typeof obj === "string";
12954
13586
  var defer = () => {
12955
13587
  let res;
@@ -13064,12 +13696,11 @@ var _entityMap = {
13064
13696
  "<": "&lt;",
13065
13697
  ">": "&gt;",
13066
13698
  '"': "&quot;",
13067
- "'": "&#39;",
13068
- "/": "&#x2F;"
13699
+ "'": "&#39;"
13069
13700
  };
13070
13701
  var escape = (data) => {
13071
13702
  if (isString(data)) {
13072
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
13703
+ return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
13073
13704
  }
13074
13705
  return data;
13075
13706
  };
@@ -13116,6 +13747,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
13116
13747
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
13117
13748
  return obj[path];
13118
13749
  }
13750
+ if (!keySeparator) {
13751
+ return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
13752
+ }
13119
13753
  const tokens = path.split(keySeparator);
13120
13754
  let current = obj;
13121
13755
  for (let i = 0; i < tokens.length; ) {
@@ -13260,15 +13894,20 @@ var EventEmitter = class {
13260
13894
  }
13261
13895
  };
13262
13896
  var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
13897
+ var assertSeparateArguments = (method, ...args) => {
13898
+ if (args.some((a) => !isString(a))) {
13899
+ throw new TypeError(`${method}: pass language, namespace${method === "addResource" ? " and key" : ""} as separate strings; the dotted form ('en.translation.key') was removed in i18next v27`);
13900
+ }
13901
+ };
13263
13902
  var ResourceStore = class extends EventEmitter {
13264
13903
  constructor(data, options = {
13265
13904
  ns: ["translation"],
13266
13905
  defaultNS: "translation"
13267
- }) {
13906
+ }, logger = baseLogger) {
13268
13907
  super();
13269
13908
  this.data = data || {};
13270
13909
  this.options = options;
13271
- this.logger = baseLogger.create("resourceStore");
13910
+ this.logger = logger.create("resourceStore");
13272
13911
  if (this.options.keySeparator === void 0) {
13273
13912
  this.options.keySeparator = ".";
13274
13913
  }
@@ -13287,49 +13926,30 @@ var ResourceStore = class extends EventEmitter {
13287
13926
  this.options.ns.splice(index, 1);
13288
13927
  }
13289
13928
  }
13290
- deprecateDottedLng(method) {
13291
- this.logger.once(method, "deprecate", `${method}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`);
13292
- }
13293
13929
  getResource(lng, ns, key, options = {}) {
13294
13930
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
13295
13931
  const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
13296
- let path;
13297
- if (lng.includes(".")) {
13298
- this.deprecateDottedLng("getResource");
13299
- path = lng.split(".");
13300
- } else {
13301
- path = [lng, ns];
13302
- if (key) {
13303
- if (Array.isArray(key)) {
13304
- path.push(...key);
13305
- } else if (isString(key) && keySeparator) {
13306
- path.push(...key.split(keySeparator));
13307
- } else {
13308
- path.push(key);
13309
- }
13932
+ const path = [lng, ns];
13933
+ if (key) {
13934
+ if (Array.isArray(key)) {
13935
+ path.push(...key);
13936
+ } else if (isString(key) && keySeparator) {
13937
+ path.push(...key.split(keySeparator));
13938
+ } else {
13939
+ path.push(key);
13310
13940
  }
13311
13941
  }
13312
13942
  const result = getPath(this.data, path);
13313
- if (result == null && !ns && !key && lng.includes(".")) {
13314
- lng = path[0];
13315
- ns = path[1];
13316
- key = path.slice(2).join(".");
13317
- }
13318
13943
  if (result != null || !ignoreJSONStructure || !isString(key)) return result;
13319
13944
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
13320
13945
  }
13321
13946
  addResource(lng, ns, key, value, options = {
13322
13947
  silent: false
13323
13948
  }) {
13949
+ assertSeparateArguments("addResource", lng, ns, key);
13324
13950
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
13325
13951
  let path = [lng, ns];
13326
13952
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
13327
- if (lng.includes(".")) {
13328
- this.deprecateDottedLng("addResource");
13329
- path = lng.split(".");
13330
- value = ns;
13331
- ns = path[1];
13332
- }
13333
13953
  this.addNamespaces(ns);
13334
13954
  setPath(this.data, path, value);
13335
13955
  if (!options.silent) this.emit("added", lng, ns, key, value);
@@ -13337,25 +13957,21 @@ var ResourceStore = class extends EventEmitter {
13337
13957
  addResources(lng, ns, resources, options = {
13338
13958
  silent: false
13339
13959
  }) {
13340
- for (const m in resources) {
13341
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
13960
+ assertSeparateArguments("addResources", lng, ns);
13961
+ Object.keys(resources || {}).forEach((m) => {
13962
+ if (m === "__proto__" || m === "constructor") return;
13963
+ this.addResource(lng, ns, m, resources[m], {
13342
13964
  silent: true
13343
13965
  });
13344
- }
13966
+ });
13345
13967
  if (!options.silent) this.emit("added", lng, ns, resources);
13346
13968
  }
13347
13969
  addResourceBundle(lng, ns, resources, deep, overwrite, options = {
13348
13970
  silent: false,
13349
13971
  skipCopy: false
13350
13972
  }) {
13351
- let path = [lng, ns];
13352
- if (lng.includes(".")) {
13353
- this.deprecateDottedLng("addResourceBundle");
13354
- path = lng.split(".");
13355
- deep = resources;
13356
- resources = ns;
13357
- ns = path[1];
13358
- }
13973
+ assertSeparateArguments("addResourceBundle", lng, ns);
13974
+ const path = [lng, ns];
13359
13975
  this.addNamespaces(ns);
13360
13976
  let pack = getPath(this.data, path) || {};
13361
13977
  if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
@@ -13402,18 +14018,6 @@ var ResourceStore = class extends EventEmitter {
13402
14018
  return this.data;
13403
14019
  }
13404
14020
  };
13405
- var postProcessor = {
13406
- processors: {},
13407
- addPostProcessor(module2) {
13408
- this.processors[module2.name] = module2;
13409
- },
13410
- handle(processors, value, key, options, translator) {
13411
- processors.forEach((processor) => {
13412
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
13413
- });
13414
- return value;
13415
- }
13416
- };
13417
14021
  var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
13418
14022
  function createProxy() {
13419
14023
  const state = [];
@@ -13432,7 +14036,7 @@ function keysFromSelector(selector, opts) {
13432
14036
  const {
13433
14037
  [PATH_KEY]: path
13434
14038
  } = selector(createProxy());
13435
- const keySeparator = opts?.keySeparator ?? ".";
14039
+ const keySeparator = opts?.keySeparator || ".";
13436
14040
  const nsSeparator = opts?.nsSeparator ?? ":";
13437
14041
  const strict = opts?.enableSelector === "strict";
13438
14042
  if (path.length > 1 && nsSeparator) {
@@ -13451,12 +14055,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
13451
14055
  var Translator = class _Translator extends EventEmitter {
13452
14056
  constructor(services, options = {}) {
13453
14057
  super();
13454
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "ownPostProcessors"], services, this);
14058
+ copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
13455
14059
  this.options = options;
13456
14060
  if (this.options.keySeparator === void 0) {
13457
14061
  this.options.keySeparator = ".";
13458
14062
  }
13459
- this.logger = baseLogger.create("translator");
14063
+ this.logger = (services.logger || baseLogger).create("translator");
13460
14064
  this.checkedLoadedFor = {};
13461
14065
  }
13462
14066
  changeLanguage(lng) {
@@ -13573,30 +14177,32 @@ var Translator = class _Translator extends EventEmitter {
13573
14177
  ordinal: false
13574
14178
  }) : "";
13575
14179
  const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
13576
- const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
14180
+ const sep = this.options.pluralSeparator;
14181
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${sep}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || (opt.defaultValue ?? (needsPluralHandling ? opt[`defaultValue${opt.ordinal ? `${sep}ordinal${sep}` : sep}other`] : void 0));
13577
14182
  let resForObjHndl = res;
13578
14183
  if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
13579
14184
  resForObjHndl = defaultValue;
13580
14185
  }
13581
14186
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
13582
14187
  const resType = Object.prototype.toString.apply(resForObjHndl);
13583
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
13584
- if (!opt.returnObjects && !this.options.returnObjects) {
13585
- if (!this.options.returnedObjectHandler) {
13586
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13587
- this.logger.once("returnedObject", "deprecate", "accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)");
13588
- }
13589
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13590
- ...opt,
13591
- ns: namespaces
13592
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
13593
- if (returnDetails) {
13594
- resolved.res = r;
13595
- resolved.usedParams = this.getUsedParamsDetails(opt);
13596
- return resolved;
13597
- }
13598
- return r;
14188
+ const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
14189
+ const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
14190
+ if (objectNotReturned && this.options.returnedObjectHandler) {
14191
+ const r = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
14192
+ ...opt,
14193
+ ns: namespaces
14194
+ });
14195
+ if (returnDetails) {
14196
+ resolved.res = r;
14197
+ resolved.usedParams = this.getUsedParamsDetails(opt);
14198
+ return resolved;
13599
14199
  }
14200
+ return r;
14201
+ }
14202
+ if (objectNotReturned) {
14203
+ this.logger.warn("accessing an object - but returnObjects options is not enabled!");
14204
+ }
14205
+ if (isObjectHit && !objectNotReturned) {
13600
14206
  if (keySeparator) {
13601
14207
  const resTypeIsArray = Array.isArray(resForObjHndl);
13602
14208
  const copy2 = resTypeIsArray ? [] : {};
@@ -13633,18 +14239,19 @@ var Translator = class _Translator extends EventEmitter {
13633
14239
  } else {
13634
14240
  let usedDefault = false;
13635
14241
  let usedKey = false;
13636
- if (!this.isValidLookup(res) && hasDefaultValue) {
14242
+ if (objectNotReturned) res = void 0;
14243
+ if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
13637
14244
  usedDefault = true;
13638
14245
  res = defaultValue;
13639
14246
  }
13640
- if (!this.isValidLookup(res)) {
14247
+ if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
13641
14248
  usedKey = true;
13642
14249
  res = key;
13643
14250
  }
13644
14251
  const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
13645
14252
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
13646
14253
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
13647
- if (usedKey || usedDefault || updateMissing) {
14254
+ if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
13648
14255
  this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
13649
14256
  if (keySeparator) {
13650
14257
  const fk = this.resolve(key, {
@@ -13725,7 +14332,7 @@ var Translator = class _Translator extends EventEmitter {
13725
14332
  const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
13726
14333
  let nestBef;
13727
14334
  if (skipOnVariables) {
13728
- const nb = res.match(this.interpolator.nestingRegexp);
14335
+ const nb = res.includes(this.interpolator.nestingPrefixText) ? res.match(this.interpolator.nestingRegexp) : null;
13729
14336
  nestBef = nb && nb.length;
13730
14337
  }
13731
14338
  let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
@@ -13735,7 +14342,7 @@ var Translator = class _Translator extends EventEmitter {
13735
14342
  };
13736
14343
  res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
13737
14344
  if (skipOnVariables) {
13738
- const na = res.match(this.interpolator.nestingRegexp);
14345
+ const na = res.includes(this.interpolator.nestingPrefixText) ? res.match(this.interpolator.nestingRegexp) : null;
13739
14346
  const nestAft = na && na.length;
13740
14347
  if (nestBef < nestAft) opt.nest = false;
13741
14348
  }
@@ -13752,18 +14359,21 @@ var Translator = class _Translator extends EventEmitter {
13752
14359
  const postProcess = opt.postProcess || this.options.postProcess;
13753
14360
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
13754
14361
  if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
13755
- postProcessorNames.forEach((name) => {
13756
- if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
13757
- this.logger.once(name, "deprecate", `postProcess: '${name}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`);
13758
- }
13759
- });
13760
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
14362
+ const ppOptions = this.options?.postProcessPassResolved ? {
13761
14363
  i18nResolved: {
13762
14364
  ...resolved,
13763
14365
  usedParams: this.getUsedParamsDetails(opt)
13764
14366
  },
13765
14367
  ...opt
13766
- } : opt, this);
14368
+ } : opt;
14369
+ postProcessorNames.forEach((name) => {
14370
+ const processor = this.postProcessors?.[name];
14371
+ if (!processor) {
14372
+ this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
14373
+ return;
14374
+ }
14375
+ res = processor.process(res, key, ppOptions, this) ?? res;
14376
+ });
13767
14377
  }
13768
14378
  return res;
13769
14379
  }
@@ -13829,6 +14439,15 @@ var Translator = class _Translator extends EventEmitter {
13829
14439
  }
13830
14440
  }
13831
14441
  }
14442
+ if (needsPluralHandling) {
14443
+ const otherSuffix = `${opt.ordinal ? ordinalPrefix : this.options.pluralSeparator}other`;
14444
+ if (pluralSuffix !== otherSuffix) {
14445
+ if (needsContextHandling) {
14446
+ finalKeys.unshift(`${key}${this.options.contextSeparator || "_"}${opt.context}${otherSuffix}`);
14447
+ }
14448
+ finalKeys.unshift(key + otherSuffix);
14449
+ }
14450
+ }
13832
14451
  }
13833
14452
  let possibleKey;
13834
14453
  while (possibleKey = finalKeys.pop()) {
@@ -13892,14 +14511,16 @@ var Translator = class _Translator extends EventEmitter {
13892
14511
  }
13893
14512
  };
13894
14513
  var LanguageUtil = class {
13895
- constructor(options) {
14514
+ constructor(options, logger = baseLogger) {
13896
14515
  this.options = options;
13897
14516
  this.supportedLngs = this.options.supportedLngs || false;
13898
- this.logger = baseLogger.create("languageUtils");
14517
+ this.logger = logger.create("languageUtils");
13899
14518
  this.resolveHierarchyCache = {};
14519
+ this.formattedCodes = /* @__PURE__ */ new Map();
13900
14520
  }
13901
14521
  clearCache() {
13902
14522
  this.resolveHierarchyCache = {};
14523
+ this.formattedCodes.clear();
13903
14524
  }
13904
14525
  getScriptPartFromCode(code) {
13905
14526
  code = getCleanedCode(code);
@@ -13917,35 +14538,28 @@ var LanguageUtil = class {
13917
14538
  return this.formatLanguageCode(p[0]);
13918
14539
  }
13919
14540
  formatLanguageCode(code) {
13920
- if (isString(code) && code.includes("-")) {
13921
- let formattedCode;
14541
+ if (!isString(code)) return code;
14542
+ let formatted = this.formattedCodes.get(code);
14543
+ if (formatted !== void 0) return formatted;
14544
+ formatted = this.formatUncached(code);
14545
+ if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
14546
+ this.formattedCodes.set(code, formatted);
14547
+ return formatted;
14548
+ }
14549
+ formatUncached(code) {
14550
+ const hasSubtags = code.includes("-");
14551
+ if (hasSubtags || this.options.cleanCode !== false) {
14552
+ let canonical;
13922
14553
  try {
13923
- formattedCode = Intl.getCanonicalLocales(code)[0];
14554
+ canonical = Intl.getCanonicalLocales(code)[0];
13924
14555
  } catch (e) {
13925
14556
  }
13926
- if (formattedCode && this.options.lowerCaseLng) {
13927
- formattedCode = formattedCode.toLowerCase();
13928
- }
13929
- if (formattedCode) return formattedCode;
13930
- if (this.options.lowerCaseLng) {
13931
- return code.toLowerCase();
14557
+ if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
14558
+ return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
13932
14559
  }
13933
- return code;
14560
+ if (canonical) return code.toLowerCase();
13934
14561
  }
13935
- const formatted = this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
13936
- if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
13937
- return formatted;
13938
- }
13939
- deprecateBareCode(code, formatted) {
13940
- let v27;
13941
- try {
13942
- v27 = Intl.getCanonicalLocales(code)[0];
13943
- } catch (e) {
13944
- return;
13945
- }
13946
- if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
13947
- if (v27 === formatted) return;
13948
- this.logger.once(code, "deprecate", `language code '${code}' is used as '${formatted}'; i18next v27 canonicalizes it to '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
14562
+ return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
13949
14563
  }
13950
14564
  isSupportedCode(code) {
13951
14565
  if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
@@ -14036,6 +14650,7 @@ var LanguageUtil = class {
14036
14650
  if (!codes.includes(formattedFc)) addCode(formattedFc);
14037
14651
  });
14038
14652
  if (cacheKey !== null) {
14653
+ if (Object.keys(this.resolveHierarchyCache).length >= 1e3) this.resolveHierarchyCache = {};
14039
14654
  this.resolveHierarchyCache[cacheKey] = codes;
14040
14655
  return codes.slice();
14041
14656
  }
@@ -14057,10 +14672,10 @@ var dummyRule = {
14057
14672
  })
14058
14673
  };
14059
14674
  var PluralResolver = class {
14060
- constructor(languageUtils, options = {}) {
14675
+ constructor(languageUtils, options = {}, logger = baseLogger) {
14061
14676
  this.languageUtils = languageUtils;
14062
14677
  this.options = options;
14063
- this.logger = baseLogger.create("pluralResolver");
14678
+ this.logger = logger.create("pluralResolver");
14064
14679
  this.pluralRulesCache = {};
14065
14680
  }
14066
14681
  clearCache() {
@@ -14090,6 +14705,7 @@ var PluralResolver = class {
14090
14705
  const lngPart = this.languageUtils.getLanguagePartFromCode(code);
14091
14706
  rule = this.getRule(lngPart, options);
14092
14707
  }
14708
+ if (Object.keys(this.pluralRulesCache).length >= 1e3) this.pluralRulesCache = {};
14093
14709
  this.pluralRulesCache[cacheKey] = rule;
14094
14710
  return rule;
14095
14711
  }
@@ -14125,8 +14741,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
14125
14741
  return path;
14126
14742
  };
14127
14743
  var Interpolator = class {
14128
- constructor(options = {}) {
14129
- this.logger = baseLogger.create("interpolator");
14744
+ constructor(options = {}, logger = baseLogger) {
14745
+ this.logger = logger.create("interpolator");
14130
14746
  this.options = options;
14131
14747
  this.format = options?.interpolation?.format || ((value) => value);
14132
14748
  this.init(options);
@@ -14140,39 +14756,28 @@ var Interpolator = class {
14140
14756
  escapeValue,
14141
14757
  useRawValueToEscape,
14142
14758
  prefix,
14143
- prefixEscaped,
14144
14759
  suffix,
14145
- suffixEscaped,
14146
14760
  formatSeparator,
14147
14761
  unescapeSuffix,
14148
14762
  unescapePrefix,
14149
14763
  nestingPrefix,
14150
- nestingPrefixEscaped,
14151
14764
  nestingSuffix,
14152
- nestingSuffixEscaped,
14153
14765
  nestingOptionsSeparator,
14154
14766
  maxReplaces,
14155
14767
  alwaysFormat
14156
14768
  } = options.interpolation;
14157
- if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
14158
- const names = Object.entries({
14159
- prefixEscaped,
14160
- suffixEscaped,
14161
- nestingPrefixEscaped,
14162
- nestingSuffixEscaped
14163
- }).filter(([, v]) => v).map(([k]) => k);
14164
- this.logger.once(names.join(), "deprecate", `interpolation.${names.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`);
14165
- }
14166
14769
  this.escape = escape$1 !== void 0 ? escape$1 : escape;
14167
14770
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
14168
14771
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
14169
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
14170
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
14772
+ this.prefix = prefix ? regexEscape(prefix) : "{{";
14773
+ this.suffix = suffix ? regexEscape(suffix) : "}}";
14171
14774
  this.formatSeparator = formatSeparator || ",";
14172
14775
  this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
14173
14776
  this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
14174
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
14175
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
14777
+ this.prefixText = prefix || "{{";
14778
+ this.nestingPrefixText = nestingPrefix || "$t(";
14779
+ this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
14780
+ this.nestingSuffix = regexEscape(nestingSuffix || ")");
14176
14781
  this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
14177
14782
  this.maxReplaces = maxReplaces || 1e3;
14178
14783
  this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
@@ -14223,18 +14828,13 @@ var Interpolator = class {
14223
14828
  }
14224
14829
  const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
14225
14830
  const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
14831
+ if (isString(str) && !str.includes(this.prefixText)) return str;
14226
14832
  const todos = [{
14227
14833
  regex: this.regexpUnescape,
14228
14834
  safeValue: (val) => val
14229
14835
  }, {
14230
14836
  regex: this.regexp,
14231
- safeValue: (val) => {
14232
- if (!this.escapeValue) return val;
14233
- if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
14234
- this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '&#x2F;' today; from v27 the default escape leaves '/' as it is");
14235
- }
14236
- return this.escape(val);
14237
- }
14837
+ safeValue: (val) => this.escapeValue ? this.escape(val) : val
14238
14838
  }];
14239
14839
  const unescapedValues = [];
14240
14840
  let shift = 0;
@@ -14318,6 +14918,7 @@ var Interpolator = class {
14318
14918
  if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix)) delete clonedOptions.defaultValue;
14319
14919
  return key;
14320
14920
  };
14921
+ if (isString(str) && !str.includes(this.nestingPrefixText)) return str;
14321
14922
  const nestingRegexp = new RegExp(this.nestingRegexp);
14322
14923
  let out = "";
14323
14924
  let lastEnd = 0;
@@ -14385,8 +14986,9 @@ var parseFormatStr = (formatStr) => {
14385
14986
  formatOptions
14386
14987
  };
14387
14988
  };
14989
+ var cachedFormattersLimit = 1e3;
14388
14990
  var createCachedFormatter = (fn) => {
14389
- const cache = {};
14991
+ const cache = /* @__PURE__ */ new Map();
14390
14992
  return (v, l, o) => {
14391
14993
  let optForCache = o;
14392
14994
  if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
@@ -14401,10 +15003,11 @@ var createCachedFormatter = (fn) => {
14401
15003
  } catch (e) {
14402
15004
  return fn(getCleanedCode(l), o)(v);
14403
15005
  }
14404
- let frm = cache[key];
15006
+ let frm = cache.get(key);
14405
15007
  if (!frm) {
14406
15008
  frm = fn(getCleanedCode(l), o);
14407
- cache[key] = frm;
15009
+ if (cache.size >= cachedFormattersLimit) cache.delete(cache.keys().next().value);
15010
+ cache.set(key, frm);
14408
15011
  }
14409
15012
  return frm(v);
14410
15013
  };
@@ -14419,6 +15022,7 @@ var Formatter = class {
14419
15022
  init(services, options = {
14420
15023
  interpolation: {}
14421
15024
  }) {
15025
+ if (services?.logger?.create) this.logger = services.logger.create("formatter");
14422
15026
  this.formatSeparator = options.interpolation.formatSeparator || ",";
14423
15027
  const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
14424
15028
  this.formats = {
@@ -14500,6 +15104,7 @@ var Formatter = class {
14500
15104
  return result;
14501
15105
  }
14502
15106
  };
15107
+ var maxFailedLoads = 1e3;
14503
15108
  var removePending = (q, name) => {
14504
15109
  if (q.pending[name] !== void 0) {
14505
15110
  delete q.pending[name];
@@ -14514,13 +15119,14 @@ var Connector = class extends EventEmitter {
14514
15119
  this.services = services;
14515
15120
  this.languageUtils = services.languageUtils;
14516
15121
  this.options = options;
14517
- this.logger = baseLogger.create("backendConnector");
15122
+ this.logger = (services.logger || baseLogger).create("backendConnector");
14518
15123
  this.waitingReads = [];
14519
15124
  this.maxParallelReads = options.maxParallelReads || 10;
14520
15125
  this.readingCalls = 0;
14521
15126
  this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
14522
15127
  this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
14523
15128
  this.state = {};
15129
+ this.failed = /* @__PURE__ */ new Set();
14524
15130
  this.queue = [];
14525
15131
  this.backend?.init?.(services, options.backend, options);
14526
15132
  this.callbackApi = callbackApiOf(this.backend);
@@ -14580,6 +15186,15 @@ var Connector = class extends EventEmitter {
14580
15186
  }
14581
15187
  this.state[name] = err ? -1 : 2;
14582
15188
  if (err && data) this.state[name] = 0;
15189
+ this.failed.delete(name);
15190
+ if (err) {
15191
+ this.failed.add(name);
15192
+ if (this.failed.size > maxFailedLoads) {
15193
+ const oldest = this.failed.values().next().value;
15194
+ this.failed.delete(oldest);
15195
+ if (this.state[oldest] < 1) delete this.state[oldest];
15196
+ }
15197
+ }
14583
15198
  const loaded = {};
14584
15199
  this.queue.forEach((q) => {
14585
15200
  pushPath(q.loaded, [lng], ns);
@@ -14674,15 +15289,10 @@ var Connector = class extends EventEmitter {
14674
15289
  reload: true
14675
15290
  }, callback);
14676
15291
  }
14677
- noticeDevFallback(lng) {
14678
- if (lng !== "dev" || !this.devIsDefaultFallback) return;
14679
- this.logger.once("dev", "warn", "language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior");
14680
- }
14681
15292
  loadOne(name, prefix = "") {
14682
15293
  const s = name.split("|");
14683
15294
  const lng = s[0];
14684
15295
  const ns = s[1];
14685
- this.noticeDevFallback(lng);
14686
15296
  this.read(lng, ns, "read", void 0, void 0, (err, data) => {
14687
15297
  if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
14688
15298
  if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
@@ -14697,7 +15307,6 @@ var Connector = class extends EventEmitter {
14697
15307
  }
14698
15308
  if (key === void 0 || key === null || key === "") return;
14699
15309
  if (this.backend?.create) {
14700
- languages?.forEach?.((l) => this.noticeDevFallback(l));
14701
15310
  const opts = {
14702
15311
  ...options,
14703
15312
  isUpdate
@@ -14732,7 +15341,7 @@ var get = () => ({
14732
15341
  initAsync: true,
14733
15342
  ns: ["translation"],
14734
15343
  defaultNS: ["translation"],
14735
- fallbackLng: ["dev"],
15344
+ fallbackLng: false,
14736
15345
  fallbackNS: false,
14737
15346
  supportedLngs: false,
14738
15347
  nonExplicitSupportedLngs: false,
@@ -14753,7 +15362,7 @@ var get = () => ({
14753
15362
  postProcess: false,
14754
15363
  postProcessPassResolved: false,
14755
15364
  returnNull: false,
14756
- returnEmptyString: true,
15365
+ returnEmptyString: false,
14757
15366
  returnObjects: false,
14758
15367
  joinArrays: false,
14759
15368
  returnedObjectHandler: false,
@@ -14798,7 +15407,39 @@ var transformOptions = (options) => {
14798
15407
  };
14799
15408
  var noop = () => {
14800
15409
  };
14801
- var loggerOwner;
15410
+ var withDefaults = (options) => {
15411
+ const defOpts = get();
15412
+ const merged = {
15413
+ ...defOpts,
15414
+ ...options
15415
+ };
15416
+ merged.interpolation = {
15417
+ ...defOpts.interpolation,
15418
+ ...options.interpolation
15419
+ };
15420
+ if (typeof merged.overloadTranslationOptionHandler !== "function") {
15421
+ merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
15422
+ }
15423
+ return merged;
15424
+ };
15425
+ var configuredLanguageCodes = (options) => {
15426
+ const codes = [].concat(options.supportedLngs || [], options.preload || []);
15427
+ codes.push(...Object.keys(options.resources || {}));
15428
+ const fallbackLng = options.fallbackLng;
15429
+ if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
15430
+ else if (fallbackLng && typeof fallbackLng === "object") {
15431
+ Object.keys(fallbackLng).forEach((code) => {
15432
+ if (code !== "default") codes.push(code);
15433
+ codes.push(...[].concat(fallbackLng[code]));
15434
+ });
15435
+ }
15436
+ return codes;
15437
+ };
15438
+ var isRefusedLanguageCode = (i18n2, code) => {
15439
+ if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
15440
+ i18n2.logger.once(`lng:${code}`, "warn", `refused the language code '${code.slice(0, 64)}' from lng, changeLanguage(), the language detector or loadLanguages(): it is not configured and has other characters than letters, digits, '-', '_', '@' and '.' (or '..', or more than 128). List it in supportedLngs to use it`);
15441
+ return true;
15442
+ };
14802
15443
  var bindMemberFunctions = (inst) => {
14803
15444
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
14804
15445
  mems.forEach((mem) => {
@@ -14810,17 +15451,18 @@ var bindMemberFunctions = (inst) => {
14810
15451
  var I18n = class _I18n extends EventEmitter {
14811
15452
  constructor(options = {}, callback) {
14812
15453
  super();
14813
- this.options = transformOptions(options);
15454
+ this.userOptions = transformOptions(options);
15455
+ this.options = withDefaults(this.userOptions);
14814
15456
  this.services = {
14815
- ownPostProcessors: /* @__PURE__ */ new Set()
15457
+ postProcessors: /* @__PURE__ */ Object.create(null)
14816
15458
  };
14817
- this.logger = baseLogger;
15459
+ this.logger = new Logger(null, this.options);
14818
15460
  this.modules = {
14819
15461
  external: []
14820
15462
  };
14821
15463
  bindMemberFunctions(this);
14822
15464
  if (callback && !this.isInitialized && !options.isClone) {
14823
- if (!this.options.initAsync) {
15465
+ if (!this.userOptions.initAsync) {
14824
15466
  this.init(options, callback);
14825
15467
  return this;
14826
15468
  }
@@ -14842,25 +15484,23 @@ var I18n = class _I18n extends EventEmitter {
14842
15484
  options.defaultNS = options.ns[0];
14843
15485
  }
14844
15486
  }
14845
- const fallbackLngIsDefault = options.fallbackLng === void 0 && this.options.fallbackLng === void 0;
14846
- const defOpts = get();
14847
- this.options = {
14848
- ...defOpts,
14849
- ...this.options,
14850
- ...transformOptions(options)
15487
+ transformOptions(options);
15488
+ const userOptions = {
15489
+ ...this.userOptions,
15490
+ ...options
14851
15491
  };
14852
- this.options.interpolation = {
14853
- ...defOpts.interpolation,
14854
- ...this.options.interpolation
14855
- };
14856
- if (options.keySeparator !== void 0) {
14857
- this.options.userDefinedKeySeparator = options.keySeparator;
15492
+ this.options = withDefaults({
15493
+ ...this.options,
15494
+ ...options
15495
+ });
15496
+ if (userOptions.keySeparator !== void 0) {
15497
+ this.options.userDefinedKeySeparator = userOptions.keySeparator;
14858
15498
  }
14859
- if (options.nsSeparator !== void 0) {
14860
- this.options.userDefinedNsSeparator = options.nsSeparator;
15499
+ if (userOptions.nsSeparator !== void 0) {
15500
+ this.options.userDefinedNsSeparator = userOptions.nsSeparator;
14861
15501
  }
14862
- if (typeof this.options.overloadTranslationOptionHandler !== "function") {
14863
- this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
15502
+ if (!this.options.isClone) {
15503
+ this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
14864
15504
  }
14865
15505
  const createClassOnDemand = (ClassOrObject) => {
14866
15506
  if (!ClassOrObject) return null;
@@ -14868,15 +15508,10 @@ var I18n = class _I18n extends EventEmitter {
14868
15508
  return ClassOrObject;
14869
15509
  };
14870
15510
  if (!this.options.isClone) {
14871
- if (loggerOwner && loggerOwner !== this && loggerOwner.modules.logger !== this.modules.logger) {
14872
- baseLogger.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger");
14873
- }
14874
- loggerOwner = this.modules.logger ? this : void 0;
14875
- if (this.modules.logger) {
14876
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
14877
- } else {
14878
- baseLogger.init(null, this.options);
14879
- }
15511
+ this.logger.init(createClassOnDemand(this.modules.logger), this.options);
15512
+ const {
15513
+ logger
15514
+ } = this;
14880
15515
  this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
14881
15516
  this.pendingWarnings = void 0;
14882
15517
  let formatter;
@@ -14885,27 +15520,26 @@ var I18n = class _I18n extends EventEmitter {
14885
15520
  } else {
14886
15521
  formatter = Formatter;
14887
15522
  }
14888
- const lu = new LanguageUtil(this.options);
14889
- this.store = new ResourceStore(this.options.resources, this.options);
15523
+ const lu = new LanguageUtil(this.options, logger);
15524
+ this.store = new ResourceStore(this.options.resources, this.options, logger);
14890
15525
  const s = this.services;
14891
- s.logger = baseLogger;
15526
+ s.logger = logger;
14892
15527
  s.resourceStore = this.store;
14893
15528
  s.languageUtils = lu;
14894
15529
  s.pluralResolver = new PluralResolver(lu, {
14895
15530
  prepend: this.options.pluralSeparator
14896
- });
15531
+ }, logger);
14897
15532
  if (formatter) {
14898
15533
  s.formatter = createClassOnDemand(formatter);
14899
15534
  if (s.formatter.init) s.formatter.init(s, this.options);
14900
15535
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
14901
15536
  }
14902
- s.interpolator = new Interpolator(this.options);
15537
+ s.interpolator = new Interpolator(this.options, logger);
14903
15538
  s.utils = {
14904
15539
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
14905
15540
  reloadResources: this.reloadResources.bind(this)
14906
15541
  };
14907
15542
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
14908
- s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
14909
15543
  s.backendConnector.on("*", (event, ...args) => {
14910
15544
  this.emit(event, ...args);
14911
15545
  });
@@ -15046,8 +15680,7 @@ var I18n = class _I18n extends EventEmitter {
15046
15680
  setModule("i18nFormat");
15047
15681
  }
15048
15682
  if (module2.type === "postProcessor") {
15049
- postProcessor.addPostProcessor(module2);
15050
- this.services.ownPostProcessors?.add(module2.name);
15683
+ this.services.postProcessors[module2.name] = module2;
15051
15684
  }
15052
15685
  if (module2.type === "formatter") {
15053
15686
  setModule("formatter");
@@ -15122,14 +15755,16 @@ var I18n = class _I18n extends EventEmitter {
15122
15755
  };
15123
15756
  const setLng = (lngs) => {
15124
15757
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
15125
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
15126
- const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15127
- if (l && this.logger.debug && !isSafeLanguageCode(l)) {
15128
- const configured = [].concat(this.options.supportedLngs || [], this.services.languageUtils.getFallbackCodes(this.options.fallbackLng, l), this.options.preload || []);
15129
- if (!configured.includes(l) && !Object.prototype.hasOwnProperty.call(this.store.data, l)) {
15130
- this.logger.once(`lng:${l}`, "deprecate", `changeLanguage: the language code '${l.slice(0, 64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`);
15131
- }
15758
+ const {
15759
+ supportedLngs
15760
+ } = this.options;
15761
+ if (lngs && !supportedLngs) {
15762
+ const accepted = [].concat(lngs).filter((c) => !isRefusedLanguageCode(this, c));
15763
+ if (accepted.length < [].concat(lngs).length) lngs = accepted;
15132
15764
  }
15765
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
15766
+ let l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15767
+ if (supportedLngs && isRefusedLanguageCode(this, l)) l = this.services.languageUtils.getBestMatchFromCodes([]);
15133
15768
  if (l) {
15134
15769
  if (!this.language) {
15135
15770
  setLngProps(l);
@@ -15244,7 +15879,7 @@ var I18n = class _I18n extends EventEmitter {
15244
15879
  }
15245
15880
  loadNamespaces(ns, callback) {
15246
15881
  const deferred = defer();
15247
- if (!this.options.ns) {
15882
+ if (!this.options.ns || !this.services.backendConnector) {
15248
15883
  if (callback) callback();
15249
15884
  return Promise.resolve();
15250
15885
  }
@@ -15262,7 +15897,7 @@ var I18n = class _I18n extends EventEmitter {
15262
15897
  const deferred = defer();
15263
15898
  if (isString(lngs)) lngs = [lngs];
15264
15899
  const preloaded = this.options.preload || [];
15265
- const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
15900
+ const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
15266
15901
  if (!newLngs.length) {
15267
15902
  if (callback) callback();
15268
15903
  return Promise.resolve();
@@ -15312,16 +15947,15 @@ var I18n = class _I18n extends EventEmitter {
15312
15947
  }
15313
15948
  };
15314
15949
  const clone = new _I18n(mergedOptions);
15315
- if (options.debug !== void 0 || options.prefix !== void 0) {
15316
- clone.logger = clone.logger.clone(options);
15317
- }
15318
- const membersToCopy = ["store", "services", "language"];
15950
+ clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
15951
+ const membersToCopy = ["store", "language"];
15319
15952
  membersToCopy.forEach((m) => {
15320
15953
  clone[m] = this[m];
15321
15954
  });
15322
15955
  clone.services = {
15323
15956
  ...this.services
15324
15957
  };
15958
+ clone.services.postProcessors = Object.create(this.services.postProcessors);
15325
15959
  clone.services.utils = {
15326
15960
  ...clone.services.utils,
15327
15961
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
@@ -15338,7 +15972,7 @@ var I18n = class _I18n extends EventEmitter {
15338
15972
  return copied;
15339
15973
  };
15340
15974
  const clonedData = copyData(this.store.data);
15341
- clone.store = new ResourceStore(clonedData, mergedOptions);
15975
+ clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
15342
15976
  clone.services.resourceStore = clone.store;
15343
15977
  }
15344
15978
  if (options.interpolation) {
@@ -15352,8 +15986,9 @@ var I18n = class _I18n extends EventEmitter {
15352
15986
  ...mergedOptions,
15353
15987
  interpolation: mergedInterpolation
15354
15988
  };
15355
- clone.services.interpolator = new Interpolator(mergedForInterpolator);
15989
+ clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
15356
15990
  }
15991
+ clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
15357
15992
  clone.translator = new Translator(clone.services, mergedOptions);
15358
15993
  clone.translator.on("*", (event, ...args) => {
15359
15994
  clone.emit(event, ...args);
@@ -15650,6 +16285,19 @@ var en = {
15650
16285
  "mo": "mo",
15651
16286
  "qtr": "qtr",
15652
16287
  "yr": "yr",
16288
+ "wk": "wk",
16289
+ "X days short": "{{amount, number}}d",
16290
+ "X weeks short": "{{amount, number}}wk",
16291
+ "X months short": "{{amount, number}}mo",
16292
+ "X years short": "{{amount, number}}yr",
16293
+ "X days_one": "{{count, number}} day",
16294
+ "X days_other": "{{count, number}} days",
16295
+ "X weeks_one": "{{count, number}} week",
16296
+ "X weeks_other": "{{count, number}} weeks",
16297
+ "X months_one": "{{count, number}} month",
16298
+ "X months_other": "{{count, number}} months",
16299
+ "X years_one": "{{count, number}} year",
16300
+ "X years_other": "{{count, number}} years",
15653
16301
  "one time": "one time",
15654
16302
  "billing period": "billing period",
15655
16303
  "billing period_one": "billing period",
@@ -15659,6 +16307,7 @@ var en = {
15659
16307
  "monthly": "monthly",
15660
16308
  "quarterly": "quarterly",
15661
16309
  "yearly": "yearly",
16310
+ "every period": "every {{period}}",
15662
16311
  "expires after purchase": "expires {{amount}} {{unit}} after purchase",
15663
16312
  "expires at the end of the billing period": "expires at the end of the billing period",
15664
16313
  "expires at the end of the next billing period": "expires at the end of the next billing period",
@@ -15961,6 +16610,23 @@ var it = {
15961
16610
  "mo": "mese",
15962
16611
  "qtr": "trim.",
15963
16612
  "yr": "anno",
16613
+ "wk": "sett.",
16614
+ "X days short": "{{amount, number}} gg",
16615
+ "X weeks short": "{{amount, number}} sett.",
16616
+ "X months short": "{{amount, number}} mesi",
16617
+ "X years short": "{{amount, number}} anni",
16618
+ "X days_one": "{{count, number}} giorno",
16619
+ "X days_many": "{{count, number}} giorni",
16620
+ "X days_other": "{{count, number}} giorni",
16621
+ "X weeks_one": "{{count, number}} settimana",
16622
+ "X weeks_many": "{{count, number}} settimane",
16623
+ "X weeks_other": "{{count, number}} settimane",
16624
+ "X months_one": "{{count, number}} mese",
16625
+ "X months_many": "{{count, number}} mesi",
16626
+ "X months_other": "{{count, number}} mesi",
16627
+ "X years_one": "{{count, number}} anno",
16628
+ "X years_many": "{{count, number}} anni",
16629
+ "X years_other": "{{count, number}} anni",
15964
16630
  "one time": "una tantum",
15965
16631
  "billing period": "periodo di fatturazione",
15966
16632
  "billing period_one": "periodo di fatturazione",
@@ -15994,6 +16660,7 @@ var it = {
15994
16660
  "monthly": "mensile",
15995
16661
  "quarterly": "trimestrale",
15996
16662
  "yearly": "annuale",
16663
+ "every period": "ogni {{period}}",
15997
16664
  "Usage by user": "Utilizzo per utente",
15998
16665
  "X used by your team this period": "{{amount}} utilizzati dal tuo team in questo periodo",
15999
16666
  "Show all X users_one": "Mostra {{count, number}} utente",
@@ -16187,14 +16854,24 @@ function derivePeriod(interval, intervalCount) {
16187
16854
  }
16188
16855
  return interval;
16189
16856
  }
16190
- function getSubscriptionPeriod(billingSubscription) {
16857
+ function getSubscriptionInterval(billingSubscription) {
16191
16858
  if (!billingSubscription) {
16192
16859
  return void 0;
16193
16860
  }
16194
16861
  const product = billingSubscription.products?.find(
16195
16862
  (p) => p.interval && p.interval !== "one-time"
16196
16863
  );
16197
- return derivePeriod(product?.interval, product?.intervalCount) ?? derivePeriod(billingSubscription.interval);
16864
+ if (product?.interval) {
16865
+ return { interval: product.interval, intervalCount: product.intervalCount };
16866
+ }
16867
+ return billingSubscription.interval ? { interval: billingSubscription.interval } : void 0;
16868
+ }
16869
+ function getSubscriptionPeriod(billingSubscription) {
16870
+ const subscriptionInterval = getSubscriptionInterval(billingSubscription);
16871
+ return derivePeriod(
16872
+ subscriptionInterval?.interval,
16873
+ subscriptionInterval?.intervalCount
16874
+ );
16198
16875
  }
16199
16876
  function getDefaultPlanPeriod(plans = []) {
16200
16877
  if (plans.some((plan) => plan.monthlyPrice)) return "month";
@@ -16467,6 +17144,8 @@ function getResetCadencePeriod(cadence) {
16467
17144
  switch (cadence) {
16468
17145
  case BillingPlanCreditGrantResetCadence.Yearly:
16469
17146
  return "year";
17147
+ case BillingPlanCreditGrantResetCadence.Quarterly:
17148
+ return "quarter";
16470
17149
  case BillingPlanCreditGrantResetCadence.Monthly:
16471
17150
  return "month";
16472
17151
  case BillingPlanCreditGrantResetCadence.Weekly:
@@ -16956,6 +17635,11 @@ function getEntitlementFeatureName(entitlement, defaultValue) {
16956
17635
  function entitlementHasCost(entitlement) {
16957
17636
  return entitlement.priceBehavior && (entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && entitlement.quantity > 0 || entitlement.priceBehavior !== EntitlementPriceBehavior.PayInAdvance);
16958
17637
  }
17638
+ function hasMeteredCosts(entitlements) {
17639
+ return entitlements.some(
17640
+ ({ priceBehavior }) => !!priceBehavior && priceBehavior !== EntitlementPriceBehavior.PayInAdvance && priceBehavior !== EntitlementPriceBehavior.CreditBurndown
17641
+ );
17642
+ }
16959
17643
  function entitlementHasHardLimit(entitlement) {
16960
17644
  return entitlement.priceBehavior && entitlement.priceBehavior !== EntitlementPriceBehavior.CreditBurndown;
16961
17645
  }
@@ -17105,8 +17789,38 @@ function getMonthName(date, { locale, ...format }) {
17105
17789
  ...format
17106
17790
  }).format(new Date(date));
17107
17791
  }
17108
- function shortenPeriod(period, t2) {
17109
- switch (period) {
17792
+ var QUARTERLY_INTERVAL_COUNT = 3;
17793
+ var YEARLY_INTERVAL_COUNT = 12;
17794
+ function normalizeInterval(interval, intervalCount) {
17795
+ const count = intervalCount && intervalCount > 1 ? intervalCount : 1;
17796
+ if (interval === "month" && count === QUARTERLY_INTERVAL_COUNT) {
17797
+ return { period: "quarter", count: 1 };
17798
+ }
17799
+ if (interval === "month" && count === YEARLY_INTERVAL_COUNT) {
17800
+ return { period: "year", count: 1 };
17801
+ }
17802
+ return { period: interval, count };
17803
+ }
17804
+ function shortenPeriod(period, t2, intervalCount) {
17805
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17806
+ if (count > 1) {
17807
+ switch (unit) {
17808
+ case "day":
17809
+ return t2("X days short", { amount: count });
17810
+ case "week":
17811
+ return t2("X weeks short", { amount: count });
17812
+ case "month":
17813
+ return t2("X months short", { amount: count });
17814
+ case "year":
17815
+ return t2("X years short", { amount: count });
17816
+ }
17817
+ return;
17818
+ }
17819
+ switch (unit) {
17820
+ case "day":
17821
+ return t2("day");
17822
+ case "week":
17823
+ return t2("wk");
17110
17824
  case "month":
17111
17825
  return t2("mo");
17112
17826
  case "quarter":
@@ -17115,6 +17829,31 @@ function shortenPeriod(period, t2) {
17115
17829
  return t2("yr");
17116
17830
  }
17117
17831
  }
17832
+ function nameInterval(period, t2, intervalCount) {
17833
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17834
+ if (count > 1) {
17835
+ switch (unit) {
17836
+ case "day":
17837
+ return t2("X days", { count });
17838
+ case "week":
17839
+ return t2("X weeks", { count });
17840
+ case "month":
17841
+ return t2("X months", { count });
17842
+ case "year":
17843
+ return t2("X years", { count });
17844
+ }
17845
+ return period;
17846
+ }
17847
+ switch (unit) {
17848
+ case "day":
17849
+ case "week":
17850
+ case "month":
17851
+ case "quarter":
17852
+ case "year":
17853
+ return t2(unit);
17854
+ }
17855
+ return period;
17856
+ }
17118
17857
  function modifyDate(date, days) {
17119
17858
  const copy2 = new Date(date);
17120
17859
  copy2.setDate(copy2.getDate() + days);
@@ -17197,8 +17936,14 @@ function formatCurrency(amount, {
17197
17936
  function formatOrdinal(n, t2) {
17198
17937
  return t2("Ordinal", { count: n, ordinal: true });
17199
17938
  }
17200
- function adjectify(period, t2) {
17201
- switch (period) {
17939
+ function adjectify(period, t2, intervalCount) {
17940
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17941
+ if (count > 1) {
17942
+ return t2("every period", {
17943
+ period: nameInterval(period, t2, intervalCount)
17944
+ });
17945
+ }
17946
+ switch (unit) {
17202
17947
  case "day":
17203
17948
  return t2("daily");
17204
17949
  case "week":
@@ -17381,6 +18126,25 @@ var createKeyboardExecutionHandler = (fn) => {
17381
18126
  return handler;
17382
18127
  };
17383
18128
 
18129
+ // src/utils/invoiceLink.ts
18130
+ function openInvoiceLink(event, storedUrl, fetchUrl) {
18131
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
18132
+ return Promise.resolve();
18133
+ }
18134
+ const tab = window.open("", "_blank");
18135
+ if (tab === null) {
18136
+ return Promise.resolve();
18137
+ }
18138
+ event.preventDefault();
18139
+ tab.opener = null;
18140
+ return fetchUrl().then(
18141
+ (url) => url || storedUrl,
18142
+ () => storedUrl
18143
+ ).then((url) => {
18144
+ tab.location.href = url;
18145
+ });
18146
+ }
18147
+
17384
18148
  // src/utils/markdown.tsx
17385
18149
  var import_react3 = require("react");
17386
18150
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -18134,7 +18898,7 @@ var reducer = (state, action) => {
18134
18898
  // src/context/EmbedProvider.tsx
18135
18899
  var import_jsx_runtime4 = require("react/jsx-runtime");
18136
18900
  var getCustomHeaders = (sessionId) => ({
18137
- "X-Schematic-Components-Version": "2.37.0",
18901
+ "X-Schematic-Components-Version": "2.39.0",
18138
18902
  "X-Schematic-Session-ID": sessionId
18139
18903
  });
18140
18904
  var normalizeCurrencyFilter = (filter) => {
@@ -18522,6 +19286,12 @@ var EmbedProvider = ({
18522
19286
  () => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
18523
19287
  [listInvoices]
18524
19288
  );
19289
+ const getInvoiceLink = (0, import_react4.useCallback)(
19290
+ async (billingInvoiceId) => {
19291
+ return checkoutApi?.getInvoiceLink({ billingInvoiceId });
19292
+ },
19293
+ [checkoutApi]
19294
+ );
18525
19295
  const getCreditUsageByUser = (0, import_react4.useCallback)(
18526
19296
  async (billingCreditId, limit) => {
18527
19297
  return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
@@ -18716,6 +19486,7 @@ var EmbedProvider = ({
18716
19486
  getUpcomingInvoice: debouncedGetUpcomingInvoice,
18717
19487
  getCustomerBalance: debouncedGetCustomerBalance,
18718
19488
  listInvoices: debouncedListInvoices,
19489
+ getInvoiceLink,
18719
19490
  getCreditUsageByUser: debouncedGetCreditUsageByUser,
18720
19491
  getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
18721
19492
  finishCheckout,
@@ -18854,10 +19625,10 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
18854
19625
  return periods;
18855
19626
  }, [data?.activePlans, data?.activeAddOns]);
18856
19627
  const getActivePlans = (0, import_react7.useCallback)(
18857
- (plans) => {
19628
+ (plans, period = activePeriod) => {
18858
19629
  const activePlans = settings.mode === "edit" ? plans.slice() : plans.filter((plan) => {
18859
19630
  if (options.useSelectedPeriod) {
18860
- return activePeriod === "month" && plan.monthlyPrice || activePeriod === "quarter" && plan.quarterlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
19631
+ return period === "month" && plan.monthlyPrice || period === "quarter" && plan.quarterlyPrice || period === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
18861
19632
  }
18862
19633
  return plan.monthlyPrice || plan.quarterlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
18863
19634
  });
@@ -18869,7 +19640,8 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
18869
19640
  return {
18870
19641
  plans: getActivePlans(data?.activePlans || []),
18871
19642
  addOns: getActivePlans(data?.activeAddOns || []),
18872
- periods: getAvailablePeriods()
19643
+ periods: getAvailablePeriods(),
19644
+ plansForPeriod: (period) => getActivePlans(data?.activePlans || [], period)
18873
19645
  };
18874
19646
  }, [
18875
19647
  data?.activePlans,
@@ -22587,28 +23359,49 @@ var CheckoutDialog = ({ top }) => {
22587
23359
  }
22588
23360
  }, [filterBlocksSubscriptionCurrency, lockedCurrency, debug]);
22589
23361
  const {
22590
- plans: availablePlans,
23362
+ plans: periodPlans,
22591
23363
  addOns: availableAddOns,
22592
- periods: availablePeriods
23364
+ periods: availablePeriods,
23365
+ plansForPeriod
22593
23366
  } = useAvailablePlans(planPeriod, {
22594
23367
  useSelectedPeriod: showPeriodToggle
22595
23368
  });
22596
- const [selectedPlanId, setSelectedPlanId] = (0, import_react29.useState)(void 0);
22597
- const selectedPlan = (0, import_react29.useMemo)(() => {
22598
- if (selectedPlanId === null) {
22599
- return void 0;
22600
- }
22601
- if (selectedPlanId) {
22602
- return availablePlans.find((p) => p.id === selectedPlanId);
22603
- }
22604
- if (checkoutState?.planId) {
22605
- return availablePlans.find((plan) => plan.id === checkoutState.planId);
22606
- }
22607
- return availablePlans.find(
22608
- (plan) => plan.current && // do not initially set the current plan for a trial
22609
- (!plan.isTrialable || !plan.companyCanTrial)
22610
- );
22611
- }, [availablePlans, checkoutState, selectedPlanId]);
23369
+ const requestedPlanId = checkoutState?.planId;
23370
+ const bypassPlanSelection = checkoutState?.bypassPlanSelection;
23371
+ const supportsCheckoutCurrency = (0, import_react29.useCallback)(
23372
+ (plan) => !hasCurrency || planSupportsCurrency(plan, effectiveCurrency) || // A plan the host picks and skips past is kept so the currency/period
23373
+ // mismatch notice can say it is unavailable.
23374
+ !!bypassPlanSelection && plan.id === requestedPlanId,
23375
+ [hasCurrency, effectiveCurrency, bypassPlanSelection, requestedPlanId]
23376
+ );
23377
+ const availablePlans = (0, import_react29.useMemo)(
23378
+ () => periodPlans.filter(supportsCheckoutCurrency),
23379
+ [periodPlans, supportsCheckoutCurrency]
23380
+ );
23381
+ const [selectedPlanId, setSelectedPlanId] = (0, import_react29.useState)(
23382
+ void 0
23383
+ );
23384
+ const isTrialing = data?.company?.billingSubscription?.status === "trialing";
23385
+ const findSelectedPlan = (0, import_react29.useCallback)(
23386
+ (plans) => {
23387
+ if (selectedPlanId) {
23388
+ return plans.find((p) => p.id === selectedPlanId);
23389
+ }
23390
+ if (requestedPlanId) {
23391
+ return plans.find((plan) => plan.id === requestedPlanId);
23392
+ }
23393
+ return plans.find(
23394
+ (plan) => plan.current && // A company that could trial its current plan chooses for itself,
23395
+ // unless it is already trialing it.
23396
+ (isTrialing || !plan.isTrialable || !plan.companyCanTrial)
23397
+ );
23398
+ },
23399
+ [requestedPlanId, selectedPlanId, isTrialing]
23400
+ );
23401
+ const selectedPlan = (0, import_react29.useMemo)(
23402
+ () => findSelectedPlan(availablePlans),
23403
+ [availablePlans, findSelectedPlan]
23404
+ );
22612
23405
  const [shouldTrial, setShouldTrial] = (0, import_react29.useState)(false);
22613
23406
  const displayedPlanCreditGrants = (0, import_react29.useMemo)(
22614
23407
  () => getDisplayedPlanCreditGrants(selectedPlan),
@@ -22974,7 +23767,7 @@ var CheckoutDialog = ({ top }) => {
22974
23767
  }, [currencies, selectedPlan, planPeriod]);
22975
23768
  const showPlanCurrencySelector = canSelectCurrency && planStageVisible;
22976
23769
  const showCheckoutCurrencySelector = canSelectCurrency && !planStageVisible && checkoutStageCurrencies.length > 1;
22977
- const currencyPeriodMismatch = hasCurrency && !lockedCurrency && !planStageVisible && !!selectedPlan && !planOffersCurrencyForPeriod(selectedPlan, planPeriod, effectiveCurrency);
23770
+ const currencyPeriodMismatch = hasCurrency && !planStageVisible && !!selectedPlan && !planOffersCurrencyForPeriod(selectedPlan, planPeriod, effectiveCurrency);
22978
23771
  (0, import_react29.useEffect)(() => {
22979
23772
  if (currencyPeriodMismatch) {
22980
23773
  console.error(
@@ -23026,7 +23819,6 @@ var CheckoutDialog = ({ top }) => {
23026
23819
  if (isBypassLoading) {
23027
23820
  setIsBypassLoading(false);
23028
23821
  }
23029
- setSelectedPlanId(null);
23030
23822
  return;
23031
23823
  }
23032
23824
  const requestId = ++previewRequestIdRef.current;
@@ -23265,7 +24057,8 @@ var CheckoutDialog = ({ top }) => {
23265
24057
  }
23266
24058
  const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
23267
24059
  setShouldTrial(updatedShouldTrial);
23268
- if (willTrialWithoutPaymentMethod) {
24060
+ const updatedWillTrialWithoutPaymentMethod = updatedShouldTrial && !trialPaymentMethodRequired;
24061
+ if (updatedWillTrialWithoutPaymentMethod) {
23269
24062
  setSelectedAddOnIds(/* @__PURE__ */ new Set());
23270
24063
  }
23271
24064
  const resolvedCreditBundles = (data?.creditBundles ?? []).map(
@@ -23278,14 +24071,10 @@ var CheckoutDialog = ({ top }) => {
23278
24071
  period,
23279
24072
  plan,
23280
24073
  shouldTrial: updatedShouldTrial,
23281
- ...willTrialWithoutPaymentMethod ? {
23282
- addOns: [],
23283
- payInAdvanceEntitlements: []
23284
- } : {
23285
- payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
23286
- ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
23287
- )
23288
- },
24074
+ ...updatedWillTrialWithoutPaymentMethod && { addOns: [] },
24075
+ payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
24076
+ ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
24077
+ ),
23289
24078
  creditBundles: resolvedCreditBundles
23290
24079
  });
23291
24080
  },
@@ -23297,7 +24086,7 @@ var CheckoutDialog = ({ top }) => {
23297
24086
  featureUsage,
23298
24087
  bundleCounts,
23299
24088
  shouldTrial,
23300
- willTrialWithoutPaymentMethod,
24089
+ trialPaymentMethodRequired,
23301
24090
  handlePreviewCheckout,
23302
24091
  checkoutState?.payInAdvanceQuantities
23303
24092
  ]
@@ -23308,40 +24097,42 @@ var CheckoutDialog = ({ top }) => {
23308
24097
  return;
23309
24098
  }
23310
24099
  setPlanPeriod(period);
23311
- const updatedUsageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
23312
- createActiveUsageBasedEntitlementsReducer(featureUsage, period),
23313
- [...[]]
23314
- );
23315
- setUsageBasedEntitlements(
23316
- (prev) => updatedUsageBasedEntitlements.map((updated) => {
23317
- const current = prev.find(
23318
- ({ featureId }) => featureId === updated.featureId
23319
- );
23320
- if (typeof current?.quantity === "number") {
23321
- return { ...updated, quantity: current.quantity };
23322
- }
23323
- return updated;
23324
- })
24100
+ const plan = findSelectedPlan(
24101
+ plansForPeriod(period).filter(supportsCheckoutCurrency)
23325
24102
  );
24103
+ const updatedUsageBasedEntitlements = plan ? (plan.entitlements || []).reduce(
24104
+ createActiveUsageBasedEntitlementsReducer(featureUsage, period),
24105
+ []
24106
+ ).map((updated) => {
24107
+ const current = usageBasedEntitlements.find(
24108
+ ({ featureId }) => featureId === updated.featureId
24109
+ );
24110
+ if (typeof current?.quantity === "number") {
24111
+ return { ...updated, quantity: current.quantity };
24112
+ }
24113
+ return updated;
24114
+ }) : usageBasedEntitlements;
24115
+ if (plan) {
24116
+ setUsageBasedEntitlements(updatedUsageBasedEntitlements);
24117
+ }
23326
24118
  const updatedAddOnUsageBasedEntitlements = addOns.filter((addOn) => addOn.isSelected).flatMap(
23327
24119
  (addOn) => (addOn.entitlements ?? []).reduce(
23328
24120
  createActiveUsageBasedEntitlementsReducer(featureUsage, period),
23329
24121
  []
23330
24122
  )
23331
- );
23332
- setAddOnUsageBasedEntitlements(
23333
- (prev) => updatedAddOnUsageBasedEntitlements.map((updated) => {
23334
- const current = prev.find(
23335
- ({ featureId }) => featureId === updated.featureId
23336
- );
23337
- if (typeof current?.quantity === "number") {
23338
- return { ...updated, quantity: current.quantity };
23339
- }
23340
- return updated;
23341
- })
23342
- );
24123
+ ).map((updated) => {
24124
+ const current = addOnUsageBasedEntitlements.find(
24125
+ ({ featureId }) => featureId === updated.featureId
24126
+ );
24127
+ if (typeof current?.quantity === "number") {
24128
+ return { ...updated, quantity: current.quantity };
24129
+ }
24130
+ return updated;
24131
+ });
24132
+ setAddOnUsageBasedEntitlements(updatedAddOnUsageBasedEntitlements);
23343
24133
  handlePreviewCheckout({
23344
24134
  period,
24135
+ plan,
23345
24136
  payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
23346
24137
  ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
23347
24138
  ),
@@ -23352,9 +24143,13 @@ var CheckoutDialog = ({ top }) => {
23352
24143
  },
23353
24144
  [
23354
24145
  planPeriod,
23355
- selectedPlan?.entitlements,
24146
+ plansForPeriod,
24147
+ findSelectedPlan,
24148
+ supportsCheckoutCurrency,
23356
24149
  featureUsage,
24150
+ usageBasedEntitlements,
23357
24151
  addOns,
24152
+ addOnUsageBasedEntitlements,
23358
24153
  setPlanPeriod,
23359
24154
  handlePreviewCheckout
23360
24155
  ]
@@ -23498,12 +24293,12 @@ var CheckoutDialog = ({ top }) => {
23498
24293
  }, [setLayout, clearCheckoutState]);
23499
24294
  const hasInitializedPlan = (0, import_react29.useRef)(false);
23500
24295
  (0, import_react29.useEffect)(() => {
23501
- if (!hasInitializedPlan.current && selectedPlan) {
24296
+ if (!hasInitializedPlan.current && selectedPlan && selectedPlanId === void 0) {
23502
24297
  hasInitializedPlan.current = true;
23503
- const shouldTrial2 = checkoutState?.startTrialIfAvailable && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
24298
+ const shouldTrial2 = checkoutState?.startTrialIfAvailable && !(isTrialing && selectedPlan.current) && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
23504
24299
  selectPlan({ plan: selectedPlan, period: planPeriod, shouldTrial: shouldTrial2 });
23505
24300
  }
23506
- }, [selectedPlan, planPeriod, selectPlan]);
24301
+ }, [selectedPlan, selectedPlanId, planPeriod, selectPlan]);
23507
24302
  (0, import_react29.useLayoutEffect)(() => {
23508
24303
  const element = dialogRef.current;
23509
24304
  if (layout !== "checkout" || !element) {
@@ -23751,6 +24546,7 @@ var CheckoutDialog = ({ top }) => {
23751
24546
  options: availablePeriods,
23752
24547
  selectedOption: planPeriod,
23753
24548
  selectedPlan,
24549
+ currency: hasCurrency ? effectiveCurrency : void 0,
23754
24550
  onSelect: changePlanPeriod
23755
24551
  }
23756
24552
  )
@@ -24557,6 +25353,7 @@ var PeriodToggle = ({
24557
25353
  options,
24558
25354
  selectedOption,
24559
25355
  selectedPlan,
25356
+ currency,
24560
25357
  onSelect
24561
25358
  }) => {
24562
25359
  const { t: t2 } = useTranslation();
@@ -24567,19 +25364,19 @@ var PeriodToggle = ({
24567
25364
  if (!selectedPlan) {
24568
25365
  return result;
24569
25366
  }
24570
- const monthlyPrice = getPlanPrice(selectedPlan, "month")?.price ?? 0;
25367
+ const monthlyPrice = getPlanPrice(selectedPlan, "month", void 0, currency)?.price ?? 0;
24571
25368
  if (monthlyPrice <= 0) {
24572
25369
  return result;
24573
25370
  }
24574
25371
  for (const [period, months] of Object.entries(PERIOD_MONTH_COUNT)) {
24575
- const periodPrice = getPlanPrice(selectedPlan, period)?.price ?? 0;
25372
+ const periodPrice = getPlanPrice(selectedPlan, period, void 0, currency)?.price ?? 0;
24576
25373
  if (periodPrice > 0) {
24577
25374
  const baseline = monthlyPrice * months;
24578
25375
  result[period] = Math.round((baseline - periodPrice) / baseline * 1e4) / 100;
24579
25376
  }
24580
25377
  }
24581
25378
  return result;
24582
- }, [selectedPlan]);
25379
+ }, [selectedPlan, currency]);
24583
25380
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
24584
25381
  Flex,
24585
25382
  {
@@ -24967,10 +25764,12 @@ var CheckoutStageButton = ({
24967
25764
  willScheduleDowngrade,
24968
25765
  hasIncompleteRequiredCustomFields = false,
24969
25766
  isCreditOnlyPurchase = false,
24970
- isOneTimeOnlyPurchase = false
25767
+ isOneTimeOnlyPurchase = false,
25768
+ isUnchangedTrial = false
24971
25769
  }) => {
24972
25770
  const { t: t2 } = useTranslation();
24973
25771
  const isDisabled = isLoading || !hasPlan && !isCreditOnlyPurchase || inEditMode || !canCheckout;
25772
+ const isCheckoutDisabled = isDisabled || isUnchangedTrial;
24974
25773
  const optInUnmet = optInRequired && !optInAccepted;
24975
25774
  const getNextStageId = (currentStageId) => {
24976
25775
  if (!checkoutStages) return void 0;
@@ -25032,7 +25831,7 @@ var CheckoutStageButton = ({
25032
25831
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25033
25832
  NoPaymentRequired,
25034
25833
  {
25035
- isDisabled,
25834
+ isDisabled: isCheckoutDisabled,
25036
25835
  isLoading,
25037
25836
  onClick: checkout,
25038
25837
  isSticky,
@@ -25067,7 +25866,7 @@ var CheckoutStageButton = ({
25067
25866
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25068
25867
  NoPaymentRequired,
25069
25868
  {
25070
- isDisabled,
25869
+ isDisabled: isCheckoutDisabled,
25071
25870
  isLoading,
25072
25871
  onClick: checkout,
25073
25872
  isSticky,
@@ -25111,7 +25910,7 @@ var CheckoutStageButton = ({
25111
25910
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25112
25911
  NoPaymentRequired,
25113
25912
  {
25114
- isDisabled,
25913
+ isDisabled: isCheckoutDisabled,
25115
25914
  isLoading,
25116
25915
  onClick: checkout,
25117
25916
  isSticky,
@@ -25155,7 +25954,7 @@ var CheckoutStageButton = ({
25155
25954
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25156
25955
  NoPaymentRequired,
25157
25956
  {
25158
- isDisabled,
25957
+ isDisabled: isCheckoutDisabled,
25159
25958
  isLoading,
25160
25959
  onClick: checkout,
25161
25960
  isSticky,
@@ -25198,7 +25997,7 @@ var CheckoutStageButton = ({
25198
25997
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25199
25998
  NoPaymentRequired,
25200
25999
  {
25201
- isDisabled,
26000
+ isDisabled: isCheckoutDisabled,
25202
26001
  isLoading,
25203
26002
  onClick: checkout,
25204
26003
  isSticky,
@@ -25242,7 +26041,7 @@ var CheckoutStageButton = ({
25242
26041
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25243
26042
  NoPaymentRequired,
25244
26043
  {
25245
- isDisabled,
26044
+ isDisabled: isCheckoutDisabled,
25246
26045
  isLoading,
25247
26046
  onClick: checkout,
25248
26047
  isSticky,
@@ -25286,7 +26085,7 @@ var CheckoutStageButton = ({
25286
26085
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
25287
26086
  NoPaymentRequired,
25288
26087
  {
25289
- isDisabled: isDisabled || hasIncompleteRequiredCustomFields || optInUnmet,
26088
+ isDisabled: isCheckoutDisabled || hasIncompleteRequiredCustomFields || optInUnmet,
25290
26089
  isLoading,
25291
26090
  onClick: checkout,
25292
26091
  isSticky,
@@ -25302,7 +26101,7 @@ var CheckoutStageButton = ({
25302
26101
  Button,
25303
26102
  {
25304
26103
  type: "button",
25305
- disabled: isDisabled || !hasPaymentMethod || hasIncompleteRequiredCustomFields || optInUnmet,
26104
+ disabled: isCheckoutDisabled || !hasPaymentMethod || hasIncompleteRequiredCustomFields || optInUnmet,
25306
26105
  onClick: checkout,
25307
26106
  $fullWidth: true,
25308
26107
  $isLoading: isLoading,
@@ -25784,9 +26583,9 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
25784
26583
  ]);
25785
26584
  const selectedAddOnsWithPrice = (0, import_react37.useMemo)(
25786
26585
  () => addOns.filter(
25787
- (addOn) => addOn.isSelected && getPlanPrice(addOn, void 0, void 0, currency)?.price
26586
+ (addOn) => addOn.isSelected && getPlanPrice(addOn, planPeriod, void 0, currency)?.price
25788
26587
  ),
25789
- [addOns, currency]
26588
+ [addOns, planPeriod, currency]
25790
26589
  );
25791
26590
  const selectedOneTimeAddOns = (0, import_react37.useMemo)(
25792
26591
  () => addOns.filter(
@@ -25796,7 +26595,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
25796
26595
  );
25797
26596
  const { removedAddOns, willAddOnsChange } = (0, import_react37.useMemo)(() => {
25798
26597
  const addedAddOns = selectedAddOnsWithPrice.filter(
25799
- (selected) => getPlanPrice(selected, void 0, void 0, currency)?.price && !currentAddOns.some((current) => selected.id === current.id)
26598
+ (selected) => !currentAddOns.some((current) => selected.id === current.id)
25800
26599
  );
25801
26600
  const removedAddOns2 = currentAddOns.filter(
25802
26601
  (current) => current.planPrice && current.planPeriod !== "one-time" && !selectedAddOnsWithPrice.some(
@@ -25809,7 +26608,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
25809
26608
  removedAddOns: removedAddOns2,
25810
26609
  willAddOnsChange: willAddOnsChange2
25811
26610
  };
25812
- }, [currentAddOns, selectedAddOnsWithPrice, currency]);
26611
+ }, [currentAddOns, selectedAddOnsWithPrice]);
25813
26612
  const addedCreditBundles = (0, import_react37.useMemo)(
25814
26613
  () => creditBundles.filter((bundle) => bundle.count > 0),
25815
26614
  [creditBundles]
@@ -25835,6 +26634,24 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
25835
26634
  selectedOneTimeAddOns.length,
25836
26635
  addedCreditBundles.length
25837
26636
  ]);
26637
+ const isUnchangedTrial = (0, import_react37.useMemo)(() => {
26638
+ if (billingSubscription?.status !== "trialing" || !selectedPlan?.current) {
26639
+ return false;
26640
+ }
26641
+ const currentPeriod = getSubscriptionPeriod(billingSubscription);
26642
+ if (currentPeriod && currentPeriod !== planPeriod) {
26643
+ return false;
26644
+ }
26645
+ return !willAddOnsChange && updatedUsageBasedEntitlements.changed.length === 0 && selectedOneTimeAddOns.length === 0 && addedCreditBundles.length === 0;
26646
+ }, [
26647
+ selectedPlan,
26648
+ billingSubscription,
26649
+ planPeriod,
26650
+ willAddOnsChange,
26651
+ updatedUsageBasedEntitlements.changed.length,
26652
+ selectedOneTimeAddOns.length,
26653
+ addedCreditBundles.length
26654
+ ]);
25838
26655
  const discountApplied = (0, import_react37.useMemo)(
25839
26656
  () => promoCode && (amountOff > 0 || percentOff > 0),
25840
26657
  [promoCode, amountOff, percentOff]
@@ -26028,6 +26845,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26028
26845
  hasIncompleteRequiredCustomFields,
26029
26846
  isCreditOnlyPurchase,
26030
26847
  isOneTimeOnlyPurchase,
26848
+ isUnchangedTrial,
26031
26849
  checkout: handleCheckout
26032
26850
  }
26033
26851
  );
@@ -26073,6 +26891,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26073
26891
  addOnPayInAdvanceEntitlements,
26074
26892
  isCreditOnlyPurchase,
26075
26893
  isOneTimeOnlyPurchase,
26894
+ isUnchangedTrial,
26076
26895
  hasIncompleteRequiredCustomFields
26077
26896
  ]);
26078
26897
  (0, import_react37.useLayoutEffect)(() => {
@@ -26107,7 +26926,10 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26107
26926
  subscriptionPrice,
26108
26927
  planPeriod,
26109
26928
  periodStart: renewDate,
26110
- hasUsageBasedCosts: usageBasedEntitlements.length > 0,
26929
+ hasUsageBasedCosts: hasMeteredCosts([
26930
+ ...usageBasedEntitlements,
26931
+ ...addOnUsageBasedEntitlements
26932
+ ]),
26111
26933
  discount: subscriptionDiscount,
26112
26934
  locale
26113
26935
  },
@@ -26119,6 +26941,14 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26119
26941
  locale
26120
26942
  })
26121
26943
  }) : billingPreviewText;
26944
+ const currentPriceInterval = getSubscriptionInterval(
26945
+ billingSubscription
26946
+ ) ?? { interval: currentPlan?.planPeriod || planPeriod };
26947
+ const currentPriceSuffix = shortenPeriod(
26948
+ currentPriceInterval.interval,
26949
+ t2,
26950
+ currentPriceInterval.intervalCount
26951
+ );
26122
26952
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
26123
26953
  Flex,
26124
26954
  {
@@ -26187,10 +27017,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26187
27017
  }),
26188
27018
  /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("sub", { children: [
26189
27019
  "/",
26190
- shortenPeriod(
26191
- getSubscriptionPeriod(billingSubscription) || currentPlan.planPeriod || planPeriod,
26192
- t2
26193
- )
27020
+ currentPriceSuffix
26194
27021
  ] })
26195
27022
  ] }) })
26196
27023
  ]
@@ -26400,7 +27227,7 @@ var SubscriptionSidebar = (0, import_react37.forwardRef)(
26400
27227
  }),
26401
27228
  addOn.planPeriod !== "one-time" && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("sub", { children: [
26402
27229
  "/",
26403
- shortenPeriod(planPeriod, t2)
27230
+ currentPriceSuffix
26404
27231
  ] })
26405
27232
  ] }) })
26406
27233
  ]
@@ -27715,12 +28542,13 @@ function formatInvoices(invoices, locale, options) {
27715
28542
  const dateA = a.dueDate ?? a.createdAt;
27716
28543
  const dateB = b.dueDate ?? b.createdAt;
27717
28544
  return +dateB - +dateA;
27718
- }).map(({ amountDue, dueDate, createdAt, url, currency }) => {
28545
+ }).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
27719
28546
  const formatted = formatCurrency(Math.abs(amountDue), {
27720
28547
  locale,
27721
28548
  currency
27722
28549
  });
27723
28550
  return {
28551
+ id,
27724
28552
  amount: amountDue < 0 ? `(${formatted})` : formatted,
27725
28553
  amountDue,
27726
28554
  date: toPrettyDate(dueDate ?? createdAt, { locale }),
@@ -27731,7 +28559,7 @@ function formatInvoices(invoices, locale, options) {
27731
28559
  var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27732
28560
  const props = resolveDesignProps3(rest);
27733
28561
  const { t: t2, locale } = useTranslation();
27734
- const { data, listInvoices, settings } = useEmbed();
28562
+ const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
27735
28563
  const [isLoading, setIsLoading] = (0, import_react44.useState)(false);
27736
28564
  const [error, setError] = (0, import_react44.useState)();
27737
28565
  const [rawInvoices, setInvoices] = (0, import_react44.useState)(
@@ -27808,7 +28636,7 @@ var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27808
28636
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Text, { display: props.header.fontStyle, children: t2("Invoices") }) }),
27809
28637
  invoices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
27810
28638
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
27811
- ({ date, amount, amountDue, url }, index) => {
28639
+ ({ id, date, amount, amountDue, url }, index) => {
27812
28640
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
27813
28641
  Flex,
27814
28642
  {
@@ -27819,11 +28647,18 @@ var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27819
28647
  Text,
27820
28648
  {
27821
28649
  display: props.date.fontStyle,
27822
- ...url && {
28650
+ ...id && url && {
27823
28651
  as: "a",
27824
28652
  href: url,
27825
28653
  target: "_blank",
27826
- rel: "noreferrer"
28654
+ rel: "noreferrer",
28655
+ onClick: (event) => {
28656
+ void openInvoiceLink(
28657
+ event,
28658
+ url,
28659
+ async () => (await getInvoiceLink(id))?.data.url
28660
+ );
28661
+ }
27827
28662
  },
27828
28663
  $color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
27829
28664
  children: date
@@ -29559,9 +30394,14 @@ var import_react51 = require("react");
29559
30394
 
29560
30395
  // src/components/elements/plan-manager/AddOn.tsx
29561
30396
  var import_jsx_runtime63 = require("react/jsx-runtime");
29562
- var AddOn = ({ addOn, currency, period, layout }) => {
30397
+ var AddOn = ({
30398
+ addOn,
30399
+ currency,
30400
+ priceInterval,
30401
+ layout
30402
+ }) => {
29563
30403
  const { t: t2, locale } = useTranslation();
29564
- const resolvedPeriod = addOn.planPeriod === "one-time" ? addOn.planPeriod : period ?? addOn.planPeriod;
30404
+ const resolvedInterval = addOn.planPeriod === "one-time" ? { interval: addOn.planPeriod } : priceInterval ?? (addOn.planPeriod ? { interval: addOn.planPeriod } : void 0);
29565
30405
  return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
29566
30406
  Flex,
29567
30407
  {
@@ -29571,9 +30411,13 @@ var AddOn = ({ addOn, currency, period, layout }) => {
29571
30411
  $gap: "1rem",
29572
30412
  children: [
29573
30413
  /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Text, { display: layout.addOns.fontStyle, children: addOn.name }),
29574
- typeof addOn.planPrice === "number" && resolvedPeriod && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Text, { children: [
30414
+ typeof addOn.planPrice === "number" && resolvedInterval && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Text, { children: [
29575
30415
  formatCurrency(addOn.planPrice, { locale, currency }),
29576
- /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("sub", { children: resolvedPeriod === "one-time" ? shortenPeriod(resolvedPeriod, t2) : `/${shortenPeriod(resolvedPeriod, t2)}` })
30416
+ /* @__PURE__ */ (0, import_jsx_runtime63.jsx)("sub", { children: resolvedInterval.interval === "one-time" ? shortenPeriod(resolvedInterval.interval, t2) : `/${shortenPeriod(
30417
+ resolvedInterval.interval,
30418
+ t2,
30419
+ resolvedInterval.intervalCount
30420
+ )}` })
29577
30421
  ] })
29578
30422
  ]
29579
30423
  }
@@ -29874,7 +30718,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
29874
30718
  willSubscriptionCancel,
29875
30719
  isTrialSubscription
29876
30720
  } = (0, import_react51.useMemo)(() => {
29877
- const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
30721
+ const subscriptionInterval2 = getSubscriptionInterval(billingSubscription);
29878
30722
  const subscriptionCurrency2 = billingSubscription?.currency;
29879
30723
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
29880
30724
  const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number" && billingSubscription?.cancelAtPeriodEnd === true;
@@ -29886,6 +30730,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
29886
30730
  };
29887
30731
  }, [billingSubscription]);
29888
30732
  const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
30733
+ const currentPriceInterval = subscriptionInterval ?? (currentPlanPeriod ? { interval: currentPlanPeriod } : void 0);
29889
30734
  const { isFreePlan, isUsageBasedPlan } = (0, import_react51.useMemo)(() => {
29890
30735
  const isFreePlan2 = currentPlan?.planPrice === 0;
29891
30736
  const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
@@ -30044,9 +30889,13 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30044
30889
  })
30045
30890
  }
30046
30891
  ),
30047
- !isFreePlan && currentPlanPeriod && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("sub", { children: [
30892
+ !isFreePlan && currentPriceInterval && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("sub", { children: [
30048
30893
  "/",
30049
- shortenPeriod(currentPlanPeriod, t2)
30894
+ shortenPeriod(
30895
+ currentPriceInterval.interval,
30896
+ t2,
30897
+ currentPriceInterval.intervalCount
30898
+ )
30050
30899
  ] }) })
30051
30900
  ] })
30052
30901
  ]
@@ -30066,7 +30915,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30066
30915
  {
30067
30916
  addOn,
30068
30917
  currency: subscriptionCurrency,
30069
- period: currentPlanPeriod,
30918
+ priceInterval: currentPriceInterval,
30070
30919
  layout: props
30071
30920
  },
30072
30921
  addOnIndex
@@ -30125,7 +30974,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30125
30974
  resolveLicenseQuantity
30126
30975
  );
30127
30976
  const licenseQuantity = perLicenseGrant?.licenseId ? resolveLicenseQuantity(perLicenseGrant.licenseId) : void 0;
30128
- const creditPeriod = composition.period ?? subscriptionInterval;
30977
+ const creditInterval = composition.period ? { interval: composition.period } : subscriptionInterval;
30129
30978
  const showPerLicense = !!perLicenseGrant && !!licenseFeature;
30130
30979
  return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
30131
30980
  Flex,
@@ -30155,7 +31004,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30155
31004
  1
30156
31005
  )
30157
31006
  }),
30158
- composition.fixedQuantity > 0 && creditPeriod && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
31007
+ composition.fixedQuantity > 0 && creditInterval && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
30159
31008
  " ",
30160
31009
  t2("Plus X credits per period", {
30161
31010
  amount: composition.fixedQuantity,
@@ -30164,8 +31013,10 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30164
31013
  locale,
30165
31014
  composition.fixedQuantity
30166
31015
  ),
30167
- period: t2(
30168
- creditPeriod
31016
+ period: nameInterval(
31017
+ creditInterval.interval,
31018
+ t2,
31019
+ creditInterval.intervalCount
30169
31020
  )
30170
31021
  })
30171
31022
  ] })
@@ -30174,11 +31025,13 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30174
31025
  " ",
30175
31026
  getFeatureName(group, locale, group.total.value),
30176
31027
  " ",
30177
- subscriptionInterval && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
31028
+ creditInterval && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
30178
31029
  t2("per"),
30179
31030
  " ",
30180
- t2(
30181
- subscriptionInterval
31031
+ nameInterval(
31032
+ creditInterval.interval,
31033
+ t2,
31034
+ creditInterval.intervalCount
30182
31035
  )
30183
31036
  ] })
30184
31037
  ] }) }),
@@ -30205,7 +31058,7 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30205
31058
  ]
30206
31059
  }
30207
31060
  ),
30208
- showPerLicense && typeof licenseQuantity === "number" && typeof resolvedTotal === "number" && creditPeriod && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
31061
+ showPerLicense && typeof licenseQuantity === "number" && typeof resolvedTotal === "number" && creditInterval && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
30209
31062
  Text,
30210
31063
  {
30211
31064
  style: { opacity: 0.54 },
@@ -30226,7 +31079,11 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30226
31079
  locale,
30227
31080
  resolvedTotal
30228
31081
  ),
30229
- period: shortenPeriod(creditPeriod, t2)
31082
+ period: shortenPeriod(
31083
+ creditInterval.interval,
31084
+ t2,
31085
+ creditInterval.intervalCount
31086
+ )
30230
31087
  }) : t2("X licenses times Y credits", {
30231
31088
  quantity: licenseQuantity,
30232
31089
  licenseName: getFeatureName(
@@ -30241,7 +31098,11 @@ var PlanManager = (0, import_react51.forwardRef)(({ children, className, portal,
30241
31098
  locale,
30242
31099
  resolvedTotal
30243
31100
  ),
30244
- period: shortenPeriod(creditPeriod, t2)
31101
+ period: shortenPeriod(
31102
+ creditInterval.interval,
31103
+ t2,
31104
+ creditInterval.intervalCount
31105
+ )
30245
31106
  })
30246
31107
  }
30247
31108
  )
@@ -31457,16 +32318,18 @@ var PricingTable = (0, import_react54.forwardRef)(({ className, ...rest }, ref)
31457
32318
  () => getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || getDefaultPlanPeriod(data?.activePlans)
31458
32319
  );
31459
32320
  const { currencies, invalidFilterEntries } = useAvailableCurrenciesWithInvalid();
31460
- const [selectedCurrency, setSelectedCurrency] = (0, import_react54.useState)(
32321
+ const [chosenCurrency, setSelectedCurrency] = (0, import_react54.useState)(
31461
32322
  () => currencies[0] ?? DEFAULT_CURRENCY
31462
32323
  );
31463
- if (currencies.length > 0 && !currencies.includes(selectedCurrency)) {
32324
+ if (currencies.length > 0 && !currencies.includes(chosenCurrency)) {
31464
32325
  setSelectedCurrency(currencies[0]);
31465
32326
  }
32327
+ const lockedCurrency = useSubscriptionCurrency();
32328
+ const selectedCurrency = lockedCurrency ?? chosenCurrency;
31466
32329
  const showPeriodToggle = rest.showPeriodToggle ?? data?.displaySettings?.showPeriodToggle ?? true;
31467
32330
  const hasCurrencyFilter = !!currencyFilter && currencyFilter.length > 0;
31468
- const showCurrencySelector = currencies.length > 1;
31469
- const hasCurrency = currencies.length > 1 || hasCurrencyFilter;
32331
+ const showCurrencySelector = currencies.length > 1 && !lockedCurrency;
32332
+ const hasCurrency = !!lockedCurrency || currencies.length > 1 || hasCurrencyFilter;
31470
32333
  const hasNoUsableCurrency = currencies.length === 0;
31471
32334
  const {
31472
32335
  plans: allPlans,
@@ -31565,6 +32428,7 @@ var PricingTable = (0, import_react54.forwardRef)(({ className, ...rest }, ref)
31565
32428
  options: periods,
31566
32429
  selectedOption: selectedPeriod,
31567
32430
  selectedPlan: currentPlan,
32431
+ currency: hasCurrency ? selectedCurrency : void 0,
31568
32432
  onSelect: (period) => {
31569
32433
  if (period !== selectedPeriod) {
31570
32434
  setSelectedPeriod(period);