@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.
@@ -1936,6 +1936,7 @@ var initialContext = {
1936
1936
  getUpcomingInvoice: stub,
1937
1937
  getCustomerBalance: stub,
1938
1938
  listInvoices: stub,
1939
+ getInvoiceLink: stub,
1939
1940
  getCreditUsageByUser: stub,
1940
1941
  getFeatureUsageByUser: stub,
1941
1942
  createSetupIntent: stub,
@@ -4608,6 +4609,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
4608
4609
  quantity: json["quantity"],
4609
4610
  subscriptionId: json["subscription_id"],
4610
4611
  subscriptionItemExternalId: json["subscription_item_external_id"] == null ? void 0 : json["subscription_item_external_id"],
4612
+ tiersMode: json["tiers_mode"] == null ? void 0 : BillingTiersModeFromJSON(json["tiers_mode"]),
4611
4613
  updatedAt: new Date(json["updated_at"]),
4612
4614
  usageType: BillingPriceUsageTypeFromJSON(json["usage_type"])
4613
4615
  };
@@ -6085,6 +6087,119 @@ function CompanyCreditBalancesResponseDataFromJSONTyped(json, ignoreDiscriminato
6085
6087
  };
6086
6088
  }
6087
6089
 
6090
+ // src/api/checkoutexternal/models/CompanyCreditLedgerBundleResponseData.ts
6091
+ function CompanyCreditLedgerBundleResponseDataFromJSON(json) {
6092
+ return CompanyCreditLedgerBundleResponseDataFromJSONTyped(json, false);
6093
+ }
6094
+ function CompanyCreditLedgerBundleResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6095
+ if (json == null) {
6096
+ return json;
6097
+ }
6098
+ return {
6099
+ id: json["id"],
6100
+ name: json["name"]
6101
+ };
6102
+ }
6103
+
6104
+ // src/api/checkoutexternal/models/CompanyCreditLedgerCreditResponseData.ts
6105
+ function CompanyCreditLedgerCreditResponseDataFromJSON(json) {
6106
+ return CompanyCreditLedgerCreditResponseDataFromJSONTyped(json, false);
6107
+ }
6108
+ function CompanyCreditLedgerCreditResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6109
+ if (json == null) {
6110
+ return json;
6111
+ }
6112
+ return {
6113
+ id: json["id"],
6114
+ name: json["name"],
6115
+ pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
6116
+ singularName: json["singular_name"] == null ? void 0 : json["singular_name"]
6117
+ };
6118
+ }
6119
+
6120
+ // src/api/checkoutexternal/models/CreditUsageReason.ts
6121
+ function CreditUsageReasonFromJSON(json) {
6122
+ return CreditUsageReasonFromJSONTyped(json, false);
6123
+ }
6124
+ function CreditUsageReasonFromJSONTyped(json, ignoreDiscriminator) {
6125
+ return json;
6126
+ }
6127
+
6128
+ // src/api/checkoutexternal/models/CompanyCreditLedgerUserResponseData.ts
6129
+ function CompanyCreditLedgerUserResponseDataFromJSON(json) {
6130
+ return CompanyCreditLedgerUserResponseDataFromJSONTyped(json, false);
6131
+ }
6132
+ function CompanyCreditLedgerUserResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6133
+ if (json == null) {
6134
+ return json;
6135
+ }
6136
+ return {
6137
+ id: json["id"],
6138
+ name: json["name"]
6139
+ };
6140
+ }
6141
+
6142
+ // src/api/checkoutexternal/models/CompanyCreditLedgerFeatureResponseData.ts
6143
+ function CompanyCreditLedgerFeatureResponseDataFromJSON(json) {
6144
+ return CompanyCreditLedgerFeatureResponseDataFromJSONTyped(json, false);
6145
+ }
6146
+ function CompanyCreditLedgerFeatureResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6147
+ if (json == null) {
6148
+ return json;
6149
+ }
6150
+ return {
6151
+ id: json["id"],
6152
+ name: json["name"]
6153
+ };
6154
+ }
6155
+
6156
+ // src/api/checkoutexternal/models/CreditLedgerEntryKind.ts
6157
+ function CreditLedgerEntryKindFromJSON(json) {
6158
+ return CreditLedgerEntryKindFromJSONTyped(json, false);
6159
+ }
6160
+ function CreditLedgerEntryKindFromJSONTyped(json, ignoreDiscriminator) {
6161
+ return json;
6162
+ }
6163
+
6164
+ // src/api/checkoutexternal/models/CompanyCreditLedgerEntryResponseData.ts
6165
+ function CompanyCreditLedgerEntryResponseDataFromJSON(json) {
6166
+ return CompanyCreditLedgerEntryResponseDataFromJSONTyped(json, false);
6167
+ }
6168
+ function CompanyCreditLedgerEntryResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6169
+ if (json == null) {
6170
+ return json;
6171
+ }
6172
+ return {
6173
+ amount: json["amount"],
6174
+ bundle: json["bundle"] == null ? void 0 : CompanyCreditLedgerBundleResponseDataFromJSON(json["bundle"]),
6175
+ credit: CompanyCreditLedgerCreditResponseDataFromJSON(json["credit"]),
6176
+ eventAt: new Date(json["event_at"]),
6177
+ feature: json["feature"] == null ? void 0 : CompanyCreditLedgerFeatureResponseDataFromJSON(json["feature"]),
6178
+ grantReason: json["grant_reason"] == null ? void 0 : BillingCreditGrantReasonFromJSON(json["grant_reason"]),
6179
+ id: json["id"],
6180
+ kind: CreditLedgerEntryKindFromJSON(json["kind"]),
6181
+ usageReason: json["usage_reason"] == null ? void 0 : CreditUsageReasonFromJSON(json["usage_reason"]),
6182
+ user: json["user"] == null ? void 0 : CompanyCreditLedgerUserResponseDataFromJSON(json["user"]),
6183
+ zeroedOutReason: json["zeroed_out_reason"] == null ? void 0 : BillingCreditGrantZeroedOutReasonFromJSON(json["zeroed_out_reason"])
6184
+ };
6185
+ }
6186
+
6187
+ // src/api/checkoutexternal/models/CompanyCreditLedgerResponseData.ts
6188
+ function CompanyCreditLedgerResponseDataFromJSON(json) {
6189
+ return CompanyCreditLedgerResponseDataFromJSONTyped(json, false);
6190
+ }
6191
+ function CompanyCreditLedgerResponseDataFromJSONTyped(json, ignoreDiscriminator) {
6192
+ if (json == null) {
6193
+ return json;
6194
+ }
6195
+ return {
6196
+ entries: json["entries"].map(
6197
+ CompanyCreditLedgerEntryResponseDataFromJSON
6198
+ ),
6199
+ nextCursor: json["next_cursor"] == null ? void 0 : json["next_cursor"]
6200
+ };
6201
+ }
6202
+
6088
6203
  // src/api/checkoutexternal/models/CompanyCreditUserUsageRowResponseData.ts
6089
6204
  function CompanyCreditUserUsageRowResponseDataFromJSON(json) {
6090
6205
  return CompanyCreditUserUsageRowResponseDataFromJSONTyped(json, false);
@@ -6318,7 +6433,9 @@ function ScheduledDowngradeResponseDataFromJSONTyped(json, ignoreDiscriminator)
6318
6433
  fromSubscriptionPrice: json["from_subscription_price"],
6319
6434
  id: json["id"],
6320
6435
  interval: json["interval"],
6436
+ intervalCount: json["interval_count"],
6321
6437
  scheduledInterval: json["scheduled_interval"] == null ? void 0 : json["scheduled_interval"],
6438
+ scheduledIntervalCount: json["scheduled_interval_count"] == null ? void 0 : json["scheduled_interval_count"],
6322
6439
  scheduledPrice: json["scheduled_price"] == null ? void 0 : json["scheduled_price"],
6323
6440
  toPlanId: json["to_plan_id"],
6324
6441
  toPlanName: json["to_plan_name"]
@@ -7474,6 +7591,20 @@ function PlanCurrencyPricesResponseDataFromJSONTyped(json, ignoreDiscriminator)
7474
7591
  };
7475
7592
  }
7476
7593
 
7594
+ // src/api/checkoutexternal/models/RenewalDestinationResponseData.ts
7595
+ function RenewalDestinationResponseDataFromJSON(json) {
7596
+ return RenewalDestinationResponseDataFromJSONTyped(json, false);
7597
+ }
7598
+ function RenewalDestinationResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7599
+ if (json == null) {
7600
+ return json;
7601
+ }
7602
+ return {
7603
+ billingPeriod: PlanPriceCadenceFromJSON(json["billing_period"]),
7604
+ planId: json["plan_id"]
7605
+ };
7606
+ }
7607
+
7477
7608
  // src/api/checkoutexternal/models/RenewalPolicy.ts
7478
7609
  function RenewalPolicyFromJSON(json) {
7479
7610
  return RenewalPolicyFromJSONTyped(json, false);
@@ -7499,6 +7630,7 @@ function PlanVersionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
7499
7630
  name: json["name"],
7500
7631
  originalPlanId: json["original_plan_id"] == null ? void 0 : json["original_plan_id"],
7501
7632
  planType: PlanTypeFromJSON(json["plan_type"]),
7633
+ renewalDestination: json["renewal_destination"] == null ? void 0 : RenewalDestinationResponseDataFromJSON(json["renewal_destination"]),
7502
7634
  renewalPolicy: RenewalPolicyFromJSON(json["renewal_policy"]),
7503
7635
  status: PlanVersionStatusFromJSON(json["status"]),
7504
7636
  updatedAt: new Date(json["updated_at"]),
@@ -7702,6 +7834,7 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
7702
7834
  ),
7703
7835
  expiredAt: json["expired_at"] == null ? void 0 : new Date(json["expired_at"]),
7704
7836
  interval: json["interval"],
7837
+ intervalCount: json["interval_count"] == null ? void 0 : json["interval_count"],
7705
7838
  isInitial: json["is_initial"],
7706
7839
  latestInvoice: json["latest_invoice"] == null ? void 0 : InvoiceResponseDataFromJSON(json["latest_invoice"]),
7707
7840
  pauseBehavior: json["pause_behavior"] == null ? void 0 : BillingSubscriptionPauseBehaviorFromJSON(json["pause_behavior"]),
@@ -8178,6 +8311,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
8178
8311
  };
8179
8312
  }
8180
8313
 
8314
+ // src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
8315
+ function CreditSpendWindowUnitFromJSON(json) {
8316
+ return CreditSpendWindowUnitFromJSONTyped(json, false);
8317
+ }
8318
+ function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
8319
+ return json;
8320
+ }
8321
+ function CreditSpendWindowUnitToJSON(value) {
8322
+ return value;
8323
+ }
8324
+
8325
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
8326
+ function CreateCompanySpendPolicyRequestBodyToJSON(json) {
8327
+ return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
8328
+ }
8329
+ function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
8330
+ if (value == null) {
8331
+ return value;
8332
+ }
8333
+ return {
8334
+ billing_credit_id: value["billingCreditId"],
8335
+ label: value["label"],
8336
+ max_per_draw: value["maxPerDraw"],
8337
+ user_id: value["userId"],
8338
+ window_amount: value["windowAmount"],
8339
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
8340
+ };
8341
+ }
8342
+
8343
+ // src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
8344
+ function CreditSpendPolicyScopeFromJSON(json) {
8345
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
8346
+ }
8347
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
8348
+ return json;
8349
+ }
8350
+
8351
+ // src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
8352
+ function CreditSpendPolicyResponseDataFromJSON(json) {
8353
+ return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
8354
+ }
8355
+ function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8356
+ if (json == null) {
8357
+ return json;
8358
+ }
8359
+ return {
8360
+ billingCreditId: json["billing_credit_id"],
8361
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
8362
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
8363
+ createdAt: new Date(json["created_at"]),
8364
+ headroom: json["headroom"] == null ? void 0 : json["headroom"],
8365
+ id: json["id"],
8366
+ label: json["label"] == null ? void 0 : json["label"],
8367
+ maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
8368
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
8369
+ scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
8370
+ updatedAt: new Date(json["updated_at"]),
8371
+ userId: json["user_id"] == null ? void 0 : json["user_id"],
8372
+ windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
8373
+ windowCount: json["window_count"],
8374
+ windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
8375
+ };
8376
+ }
8377
+
8378
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
8379
+ function CreateCompanySpendPolicyResponseFromJSON(json) {
8380
+ return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
8381
+ }
8382
+ function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8383
+ if (json == null) {
8384
+ return json;
8385
+ }
8386
+ return {
8387
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
8388
+ params: json["params"]
8389
+ };
8390
+ }
8391
+
8181
8392
  // src/api/checkoutexternal/models/SetupIntentResponseData.ts
8182
8393
  function SetupIntentResponseDataFromJSON(json) {
8183
8394
  return SetupIntentResponseDataFromJSONTyped(json, false);
@@ -8266,6 +8477,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8266
8477
  };
8267
8478
  }
8268
8479
 
8480
+ // src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
8481
+ function DeleteCompanySpendPolicyResponseFromJSON(json) {
8482
+ return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
8483
+ }
8484
+ function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8485
+ if (json == null) {
8486
+ return json;
8487
+ }
8488
+ return {
8489
+ data: DeleteResponseFromJSON(json["data"]),
8490
+ params: json["params"]
8491
+ };
8492
+ }
8493
+
8269
8494
  // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
8270
8495
  function DeletePaymentMethodResponseFromJSON(json) {
8271
8496
  return DeletePaymentMethodResponseFromJSONTyped(json, false);
@@ -8443,6 +8668,36 @@ function GetCompanyCreditBalancesResponseFromJSONTyped(json, ignoreDiscriminator
8443
8668
  };
8444
8669
  }
8445
8670
 
8671
+ // src/api/checkoutexternal/models/GetCompanyCreditLedgerParams.ts
8672
+ function GetCompanyCreditLedgerParamsFromJSON(json) {
8673
+ return GetCompanyCreditLedgerParamsFromJSONTyped(json, false);
8674
+ }
8675
+ function GetCompanyCreditLedgerParamsFromJSONTyped(json, ignoreDiscriminator) {
8676
+ if (json == null) {
8677
+ return json;
8678
+ }
8679
+ return {
8680
+ creditIds: json["credit_ids"] == null ? void 0 : json["credit_ids"],
8681
+ cursor: json["cursor"] == null ? void 0 : json["cursor"],
8682
+ includeGrants: json["include_grants"] == null ? void 0 : json["include_grants"],
8683
+ limit: json["limit"] == null ? void 0 : json["limit"]
8684
+ };
8685
+ }
8686
+
8687
+ // src/api/checkoutexternal/models/GetCompanyCreditLedgerResponse.ts
8688
+ function GetCompanyCreditLedgerResponseFromJSON(json) {
8689
+ return GetCompanyCreditLedgerResponseFromJSONTyped(json, false);
8690
+ }
8691
+ function GetCompanyCreditLedgerResponseFromJSONTyped(json, ignoreDiscriminator) {
8692
+ if (json == null) {
8693
+ return json;
8694
+ }
8695
+ return {
8696
+ data: CompanyCreditLedgerResponseDataFromJSON(json["data"]),
8697
+ params: GetCompanyCreditLedgerParamsFromJSON(json["params"])
8698
+ };
8699
+ }
8700
+
8446
8701
  // src/api/checkoutexternal/models/GetCompanyCreditUserUsageParams.ts
8447
8702
  function GetCompanyCreditUserUsageParamsFromJSON(json) {
8448
8703
  return GetCompanyCreditUserUsageParamsFromJSONTyped(json, false);
@@ -8640,6 +8895,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
8640
8895
  };
8641
8896
  }
8642
8897
 
8898
+ // src/api/checkoutexternal/models/InvoiceLink.ts
8899
+ function InvoiceLinkFromJSON(json) {
8900
+ return InvoiceLinkFromJSONTyped(json, false);
8901
+ }
8902
+ function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
8903
+ if (json == null) {
8904
+ return json;
8905
+ }
8906
+ return {
8907
+ id: json["id"],
8908
+ url: json["url"]
8909
+ };
8910
+ }
8911
+
8912
+ // src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
8913
+ function GetInvoiceLinkResponseFromJSON(json) {
8914
+ return GetInvoiceLinkResponseFromJSONTyped(json, false);
8915
+ }
8916
+ function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
8917
+ if (json == null) {
8918
+ return json;
8919
+ }
8920
+ return {
8921
+ data: InvoiceLinkFromJSON(json["data"]),
8922
+ params: json["params"]
8923
+ };
8924
+ }
8925
+
8643
8926
  // src/api/checkoutexternal/models/GetSetupIntentResponse.ts
8644
8927
  function GetSetupIntentResponseFromJSON(json) {
8645
8928
  return GetSetupIntentResponseFromJSONTyped(json, false);
@@ -8753,6 +9036,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
8753
9036
  };
8754
9037
  }
8755
9038
 
9039
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
9040
+ function ListCompanySpendPoliciesParamsFromJSON(json) {
9041
+ return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
9042
+ }
9043
+ function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
9044
+ if (json == null) {
9045
+ return json;
9046
+ }
9047
+ return {
9048
+ billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
9049
+ };
9050
+ }
9051
+
9052
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
9053
+ function ListCompanySpendPoliciesResponseFromJSON(json) {
9054
+ return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
9055
+ }
9056
+ function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
9057
+ if (json == null) {
9058
+ return json;
9059
+ }
9060
+ return {
9061
+ data: json["data"].map(
9062
+ CreditSpendPolicyResponseDataFromJSON
9063
+ ),
9064
+ params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
9065
+ };
9066
+ }
9067
+
8756
9068
  // src/api/checkoutexternal/models/ListInvoicesParams.ts
8757
9069
  function ListInvoicesParamsFromJSON(json) {
8758
9070
  return ListInvoicesParamsFromJSONTyped(json, false);
@@ -8925,6 +9237,7 @@ function PreviewSubscriptionChangeResponseDataFromJSONTyped(json, ignoreDiscrimi
8925
9237
  proration: json["proration"],
8926
9238
  scheduledChangeTime: json["scheduled_change_time"] == null ? void 0 : new Date(json["scheduled_change_time"]),
8927
9239
  trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"]),
9240
+ unbilledUsageFeatureIds: json["unbilled_usage_feature_ids"],
8928
9241
  usageViolations: json["usage_violations"].map(
8929
9242
  FeatureUsageResponseDataFromJSON
8930
9243
  )
@@ -9083,6 +9396,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
9083
9396
  };
9084
9397
  }
9085
9398
 
9399
+ // src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
9400
+ function UpdateCompanySpendPolicyResponseFromJSON(json) {
9401
+ return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
9402
+ }
9403
+ function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
9404
+ if (json == null) {
9405
+ return json;
9406
+ }
9407
+ return {
9408
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
9409
+ params: json["params"]
9410
+ };
9411
+ }
9412
+
9413
+ // src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
9414
+ function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
9415
+ return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
9416
+ }
9417
+ function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
9418
+ if (value == null) {
9419
+ return value;
9420
+ }
9421
+ return {
9422
+ label: value["label"],
9423
+ max_per_draw: value["maxPerDraw"],
9424
+ window_amount: value["windowAmount"],
9425
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
9426
+ };
9427
+ }
9428
+
9086
9429
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
9087
9430
  function UpdatePaymentMethodRequestBodyToJSON(json) {
9088
9431
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -9240,6 +9583,51 @@ var CheckoutexternalApi = class extends BaseAPI {
9240
9583
  );
9241
9584
  return await response.value();
9242
9585
  }
9586
+ /**
9587
+ * Create company spend policy
9588
+ */
9589
+ async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
9590
+ if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
9591
+ throw new RequiredError(
9592
+ "createCompanySpendPolicyRequestBody",
9593
+ 'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
9594
+ );
9595
+ }
9596
+ const queryParameters = {};
9597
+ const headerParameters = {};
9598
+ headerParameters["Content-Type"] = "application/json";
9599
+ if (this.configuration && this.configuration.apiKey) {
9600
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9601
+ "X-Schematic-Api-Key"
9602
+ );
9603
+ }
9604
+ const response = await this.request(
9605
+ {
9606
+ path: `/company/credits/spend-policies`,
9607
+ method: "POST",
9608
+ headers: headerParameters,
9609
+ query: queryParameters,
9610
+ body: CreateCompanySpendPolicyRequestBodyToJSON(
9611
+ requestParameters["createCompanySpendPolicyRequestBody"]
9612
+ )
9613
+ },
9614
+ initOverrides
9615
+ );
9616
+ return new JSONApiResponse(
9617
+ response,
9618
+ (jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
9619
+ );
9620
+ }
9621
+ /**
9622
+ * Create company spend policy
9623
+ */
9624
+ async createCompanySpendPolicy(requestParameters, initOverrides) {
9625
+ const response = await this.createCompanySpendPolicyRaw(
9626
+ requestParameters,
9627
+ initOverrides
9628
+ );
9629
+ return await response.value();
9630
+ }
9243
9631
  /**
9244
9632
  * 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.
9245
9633
  * Create a setup intent
@@ -9274,6 +9662,50 @@ var CheckoutexternalApi = class extends BaseAPI {
9274
9662
  const response = await this.createSetupIntentRaw(initOverrides);
9275
9663
  return await response.value();
9276
9664
  }
9665
+ /**
9666
+ * Delete company spend policy
9667
+ */
9668
+ async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
9669
+ if (requestParameters["spendPolicyId"] == null) {
9670
+ throw new RequiredError(
9671
+ "spendPolicyId",
9672
+ 'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
9673
+ );
9674
+ }
9675
+ const queryParameters = {};
9676
+ const headerParameters = {};
9677
+ if (this.configuration && this.configuration.apiKey) {
9678
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9679
+ "X-Schematic-Api-Key"
9680
+ );
9681
+ }
9682
+ const response = await this.request(
9683
+ {
9684
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
9685
+ `{${"spend_policy_id"}}`,
9686
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
9687
+ ),
9688
+ method: "DELETE",
9689
+ headers: headerParameters,
9690
+ query: queryParameters
9691
+ },
9692
+ initOverrides
9693
+ );
9694
+ return new JSONApiResponse(
9695
+ response,
9696
+ (jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
9697
+ );
9698
+ }
9699
+ /**
9700
+ * Delete company spend policy
9701
+ */
9702
+ async deleteCompanySpendPolicy(requestParameters, initOverrides) {
9703
+ const response = await this.deleteCompanySpendPolicyRaw(
9704
+ requestParameters,
9705
+ initOverrides
9706
+ );
9707
+ return await response.value();
9708
+ }
9277
9709
  /**
9278
9710
  * 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.
9279
9711
  * Remove a payment method
@@ -9641,6 +10073,55 @@ var CheckoutexternalApi = class extends BaseAPI {
9641
10073
  const response = await this.getCompanyCreditBalancesRaw(initOverrides);
9642
10074
  return await response.value();
9643
10075
  }
10076
+ /**
10077
+ * 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.
10078
+ * List credit activity
10079
+ */
10080
+ async getCompanyCreditLedgerRaw(requestParameters, initOverrides) {
10081
+ const queryParameters = {};
10082
+ if (requestParameters["creditIds"] != null) {
10083
+ queryParameters["credit_ids"] = requestParameters["creditIds"];
10084
+ }
10085
+ if (requestParameters["cursor"] != null) {
10086
+ queryParameters["cursor"] = requestParameters["cursor"];
10087
+ }
10088
+ if (requestParameters["includeGrants"] != null) {
10089
+ queryParameters["include_grants"] = requestParameters["includeGrants"];
10090
+ }
10091
+ if (requestParameters["limit"] != null) {
10092
+ queryParameters["limit"] = requestParameters["limit"];
10093
+ }
10094
+ const headerParameters = {};
10095
+ if (this.configuration && this.configuration.apiKey) {
10096
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10097
+ "X-Schematic-Api-Key"
10098
+ );
10099
+ }
10100
+ const response = await this.request(
10101
+ {
10102
+ path: `/company/credits/ledger`,
10103
+ method: "GET",
10104
+ headers: headerParameters,
10105
+ query: queryParameters
10106
+ },
10107
+ initOverrides
10108
+ );
10109
+ return new JSONApiResponse(
10110
+ response,
10111
+ (jsonValue) => GetCompanyCreditLedgerResponseFromJSON(jsonValue)
10112
+ );
10113
+ }
10114
+ /**
10115
+ * 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.
10116
+ * List credit activity
10117
+ */
10118
+ async getCompanyCreditLedger(requestParameters = {}, initOverrides) {
10119
+ const response = await this.getCompanyCreditLedgerRaw(
10120
+ requestParameters,
10121
+ initOverrides
10122
+ );
10123
+ return await response.value();
10124
+ }
9644
10125
  /**
9645
10126
  * Who in the company consumed the credit, and how much each.
9646
10127
  * List credit usage by user
@@ -10000,6 +10481,50 @@ var CheckoutexternalApi = class extends BaseAPI {
10000
10481
  );
10001
10482
  return await response.value();
10002
10483
  }
10484
+ /**
10485
+ * Get invoice link
10486
+ */
10487
+ async getInvoiceLinkRaw(requestParameters, initOverrides) {
10488
+ if (requestParameters["billingInvoiceId"] == null) {
10489
+ throw new RequiredError(
10490
+ "billingInvoiceId",
10491
+ 'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
10492
+ );
10493
+ }
10494
+ const queryParameters = {};
10495
+ const headerParameters = {};
10496
+ if (this.configuration && this.configuration.apiKey) {
10497
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10498
+ "X-Schematic-Api-Key"
10499
+ );
10500
+ }
10501
+ const response = await this.request(
10502
+ {
10503
+ path: `/components/invoices/{billing_invoice_id}/link`.replace(
10504
+ `{${"billing_invoice_id"}}`,
10505
+ encodeURIComponent(String(requestParameters["billingInvoiceId"]))
10506
+ ),
10507
+ method: "GET",
10508
+ headers: headerParameters,
10509
+ query: queryParameters
10510
+ },
10511
+ initOverrides
10512
+ );
10513
+ return new JSONApiResponse(
10514
+ response,
10515
+ (jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
10516
+ );
10517
+ }
10518
+ /**
10519
+ * Get invoice link
10520
+ */
10521
+ async getInvoiceLink(requestParameters, initOverrides) {
10522
+ const response = await this.getInvoiceLinkRaw(
10523
+ requestParameters,
10524
+ initOverrides
10525
+ );
10526
+ return await response.value();
10527
+ }
10003
10528
  /**
10004
10529
  * Get setup intent
10005
10530
  */
@@ -10177,19 +10702,58 @@ var CheckoutexternalApi = class extends BaseAPI {
10177
10702
  * The checkouts this session opened for the token\'s company. Filter by `statuses`.
10178
10703
  * List checkouts
10179
10704
  */
10180
- async listCheckoutsRaw(requestParameters, initOverrides) {
10705
+ async listCheckoutsRaw(requestParameters, initOverrides) {
10706
+ const queryParameters = {};
10707
+ if (requestParameters["companyId"] != null) {
10708
+ queryParameters["company_id"] = requestParameters["companyId"];
10709
+ }
10710
+ if (requestParameters["statuses"] != null) {
10711
+ queryParameters["statuses"] = requestParameters["statuses"];
10712
+ }
10713
+ if (requestParameters["limit"] != null) {
10714
+ queryParameters["limit"] = requestParameters["limit"];
10715
+ }
10716
+ if (requestParameters["offset"] != null) {
10717
+ queryParameters["offset"] = requestParameters["offset"];
10718
+ }
10719
+ const headerParameters = {};
10720
+ if (this.configuration && this.configuration.apiKey) {
10721
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10722
+ "X-Schematic-Api-Key"
10723
+ );
10724
+ }
10725
+ const response = await this.request(
10726
+ {
10727
+ path: `/checkouts`,
10728
+ method: "GET",
10729
+ headers: headerParameters,
10730
+ query: queryParameters
10731
+ },
10732
+ initOverrides
10733
+ );
10734
+ return new JSONApiResponse(
10735
+ response,
10736
+ (jsonValue) => ListCheckoutsResponseFromJSON(jsonValue)
10737
+ );
10738
+ }
10739
+ /**
10740
+ * The checkouts this session opened for the token\'s company. Filter by `statuses`.
10741
+ * List checkouts
10742
+ */
10743
+ async listCheckouts(requestParameters = {}, initOverrides) {
10744
+ const response = await this.listCheckoutsRaw(
10745
+ requestParameters,
10746
+ initOverrides
10747
+ );
10748
+ return await response.value();
10749
+ }
10750
+ /**
10751
+ * List company spend policies
10752
+ */
10753
+ async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
10181
10754
  const queryParameters = {};
10182
- if (requestParameters["companyId"] != null) {
10183
- queryParameters["company_id"] = requestParameters["companyId"];
10184
- }
10185
- if (requestParameters["statuses"] != null) {
10186
- queryParameters["statuses"] = requestParameters["statuses"];
10187
- }
10188
- if (requestParameters["limit"] != null) {
10189
- queryParameters["limit"] = requestParameters["limit"];
10190
- }
10191
- if (requestParameters["offset"] != null) {
10192
- queryParameters["offset"] = requestParameters["offset"];
10755
+ if (requestParameters["billingCreditId"] != null) {
10756
+ queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
10193
10757
  }
10194
10758
  const headerParameters = {};
10195
10759
  if (this.configuration && this.configuration.apiKey) {
@@ -10199,7 +10763,7 @@ var CheckoutexternalApi = class extends BaseAPI {
10199
10763
  }
10200
10764
  const response = await this.request(
10201
10765
  {
10202
- path: `/checkouts`,
10766
+ path: `/company/credits/spend-policies`,
10203
10767
  method: "GET",
10204
10768
  headers: headerParameters,
10205
10769
  query: queryParameters
@@ -10208,15 +10772,14 @@ var CheckoutexternalApi = class extends BaseAPI {
10208
10772
  );
10209
10773
  return new JSONApiResponse(
10210
10774
  response,
10211
- (jsonValue) => ListCheckoutsResponseFromJSON(jsonValue)
10775
+ (jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
10212
10776
  );
10213
10777
  }
10214
10778
  /**
10215
- * The checkouts this session opened for the token\'s company. Filter by `statuses`.
10216
- * List checkouts
10779
+ * List company spend policies
10217
10780
  */
10218
- async listCheckouts(requestParameters = {}, initOverrides) {
10219
- const response = await this.listCheckoutsRaw(
10781
+ async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
10782
+ const response = await this.listCompanySpendPoliciesRaw(
10220
10783
  requestParameters,
10221
10784
  initOverrides
10222
10785
  );
@@ -10456,6 +11019,60 @@ var CheckoutexternalApi = class extends BaseAPI {
10456
11019
  );
10457
11020
  return await response.value();
10458
11021
  }
11022
+ /**
11023
+ * Update company spend policy
11024
+ */
11025
+ async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
11026
+ if (requestParameters["spendPolicyId"] == null) {
11027
+ throw new RequiredError(
11028
+ "spendPolicyId",
11029
+ 'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
11030
+ );
11031
+ }
11032
+ if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
11033
+ throw new RequiredError(
11034
+ "updateCreditSpendPolicyRequestBody",
11035
+ 'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
11036
+ );
11037
+ }
11038
+ const queryParameters = {};
11039
+ const headerParameters = {};
11040
+ headerParameters["Content-Type"] = "application/json";
11041
+ if (this.configuration && this.configuration.apiKey) {
11042
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11043
+ "X-Schematic-Api-Key"
11044
+ );
11045
+ }
11046
+ const response = await this.request(
11047
+ {
11048
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
11049
+ `{${"spend_policy_id"}}`,
11050
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
11051
+ ),
11052
+ method: "PUT",
11053
+ headers: headerParameters,
11054
+ query: queryParameters,
11055
+ body: UpdateCreditSpendPolicyRequestBodyToJSON(
11056
+ requestParameters["updateCreditSpendPolicyRequestBody"]
11057
+ )
11058
+ },
11059
+ initOverrides
11060
+ );
11061
+ return new JSONApiResponse(
11062
+ response,
11063
+ (jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
11064
+ );
11065
+ }
11066
+ /**
11067
+ * Update company spend policy
11068
+ */
11069
+ async updateCompanySpendPolicy(requestParameters, initOverrides) {
11070
+ const response = await this.updateCompanySpendPolicyRaw(
11071
+ requestParameters,
11072
+ initOverrides
11073
+ );
11074
+ return await response.value();
11075
+ }
10459
11076
  /**
10460
11077
  * 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.
10461
11078
  * Make a payment method the default
@@ -10981,9 +11598,9 @@ function BillingPriceUsageTypeFromJSONTyped5(json, ignoreDiscriminator) {
10981
11598
 
10982
11599
  // src/api/componentspublic/models/BillingTiersMode.ts
10983
11600
  function BillingTiersModeFromJSON2(json) {
10984
- return BillingTiersModeFromJSONTyped6(json, false);
11601
+ return BillingTiersModeFromJSONTyped7(json, false);
10985
11602
  }
10986
- function BillingTiersModeFromJSONTyped6(json, ignoreDiscriminator) {
11603
+ function BillingTiersModeFromJSONTyped7(json, ignoreDiscriminator) {
10987
11604
  return json;
10988
11605
  }
10989
11606
 
@@ -11259,9 +11876,9 @@ function ChargeTypeFromJSONTyped7(json, ignoreDiscriminator) {
11259
11876
 
11260
11877
  // src/api/componentspublic/models/PlanPriceCadence.ts
11261
11878
  function PlanPriceCadenceFromJSON2(json) {
11262
- return PlanPriceCadenceFromJSONTyped7(json, false);
11879
+ return PlanPriceCadenceFromJSONTyped8(json, false);
11263
11880
  }
11264
- function PlanPriceCadenceFromJSONTyped7(json, ignoreDiscriminator) {
11881
+ function PlanPriceCadenceFromJSONTyped8(json, ignoreDiscriminator) {
11265
11882
  return json;
11266
11883
  }
11267
11884
 
@@ -11890,6 +12507,20 @@ function PlanCurrencyPricesResponseDataFromJSONTyped5(json, ignoreDiscriminator)
11890
12507
  };
11891
12508
  }
11892
12509
 
12510
+ // src/api/componentspublic/models/RenewalDestinationResponseData.ts
12511
+ function RenewalDestinationResponseDataFromJSON2(json) {
12512
+ return RenewalDestinationResponseDataFromJSONTyped3(json, false);
12513
+ }
12514
+ function RenewalDestinationResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
12515
+ if (json == null) {
12516
+ return json;
12517
+ }
12518
+ return {
12519
+ billingPeriod: PlanPriceCadenceFromJSON2(json["billing_period"]),
12520
+ planId: json["plan_id"]
12521
+ };
12522
+ }
12523
+
11893
12524
  // src/api/componentspublic/models/RenewalPolicy.ts
11894
12525
  function RenewalPolicyFromJSON2(json) {
11895
12526
  return RenewalPolicyFromJSONTyped3(json, false);
@@ -11915,6 +12546,7 @@ function PlanVersionResponseDataFromJSONTyped5(json, ignoreDiscriminator) {
11915
12546
  name: json["name"],
11916
12547
  originalPlanId: json["original_plan_id"] == null ? void 0 : json["original_plan_id"],
11917
12548
  planType: PlanTypeFromJSON2(json["plan_type"]),
12549
+ renewalDestination: json["renewal_destination"] == null ? void 0 : RenewalDestinationResponseDataFromJSON2(json["renewal_destination"]),
11918
12550
  renewalPolicy: RenewalPolicyFromJSON2(json["renewal_policy"]),
11919
12551
  status: PlanVersionStatusFromJSON2(json["status"]),
11920
12552
  updatedAt: new Date(json["updated_at"]),
@@ -12490,7 +13122,7 @@ function resolveLocale(locale) {
12490
13122
  return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
12491
13123
  }
12492
13124
 
12493
- // node_modules/.pnpm/i18next@26.7.1_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
13125
+ // node_modules/.pnpm/i18next@27.1.2_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
12494
13126
  var isString = (obj) => typeof obj === "string";
12495
13127
  var defer = () => {
12496
13128
  let res;
@@ -12605,12 +13237,11 @@ var _entityMap = {
12605
13237
  "<": "&lt;",
12606
13238
  ">": "&gt;",
12607
13239
  '"': "&quot;",
12608
- "'": "&#39;",
12609
- "/": "&#x2F;"
13240
+ "'": "&#39;"
12610
13241
  };
12611
13242
  var escape = (data) => {
12612
13243
  if (isString(data)) {
12613
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
13244
+ return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
12614
13245
  }
12615
13246
  return data;
12616
13247
  };
@@ -12657,6 +13288,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
12657
13288
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
12658
13289
  return obj[path];
12659
13290
  }
13291
+ if (!keySeparator) {
13292
+ return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
13293
+ }
12660
13294
  const tokens = path.split(keySeparator);
12661
13295
  let current = obj;
12662
13296
  for (let i2 = 0; i2 < tokens.length; ) {
@@ -12801,15 +13435,20 @@ var EventEmitter = class {
12801
13435
  }
12802
13436
  };
12803
13437
  var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
13438
+ var assertSeparateArguments = (method, ...args) => {
13439
+ if (args.some((a2) => !isString(a2))) {
13440
+ 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`);
13441
+ }
13442
+ };
12804
13443
  var ResourceStore = class extends EventEmitter {
12805
13444
  constructor(data, options = {
12806
13445
  ns: ["translation"],
12807
13446
  defaultNS: "translation"
12808
- }) {
13447
+ }, logger = baseLogger) {
12809
13448
  super();
12810
13449
  this.data = data || {};
12811
13450
  this.options = options;
12812
- this.logger = baseLogger.create("resourceStore");
13451
+ this.logger = logger.create("resourceStore");
12813
13452
  if (this.options.keySeparator === void 0) {
12814
13453
  this.options.keySeparator = ".";
12815
13454
  }
@@ -12828,49 +13467,30 @@ var ResourceStore = class extends EventEmitter {
12828
13467
  this.options.ns.splice(index, 1);
12829
13468
  }
12830
13469
  }
12831
- deprecateDottedLng(method) {
12832
- 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`);
12833
- }
12834
13470
  getResource(lng, ns, key, options = {}) {
12835
13471
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
12836
13472
  const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
12837
- let path;
12838
- if (lng.includes(".")) {
12839
- this.deprecateDottedLng("getResource");
12840
- path = lng.split(".");
12841
- } else {
12842
- path = [lng, ns];
12843
- if (key) {
12844
- if (Array.isArray(key)) {
12845
- path.push(...key);
12846
- } else if (isString(key) && keySeparator) {
12847
- path.push(...key.split(keySeparator));
12848
- } else {
12849
- path.push(key);
12850
- }
13473
+ const path = [lng, ns];
13474
+ if (key) {
13475
+ if (Array.isArray(key)) {
13476
+ path.push(...key);
13477
+ } else if (isString(key) && keySeparator) {
13478
+ path.push(...key.split(keySeparator));
13479
+ } else {
13480
+ path.push(key);
12851
13481
  }
12852
13482
  }
12853
13483
  const result = getPath(this.data, path);
12854
- if (result == null && !ns && !key && lng.includes(".")) {
12855
- lng = path[0];
12856
- ns = path[1];
12857
- key = path.slice(2).join(".");
12858
- }
12859
13484
  if (result != null || !ignoreJSONStructure || !isString(key)) return result;
12860
13485
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
12861
13486
  }
12862
13487
  addResource(lng, ns, key, value, options = {
12863
13488
  silent: false
12864
13489
  }) {
13490
+ assertSeparateArguments("addResource", lng, ns, key);
12865
13491
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
12866
13492
  let path = [lng, ns];
12867
13493
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
12868
- if (lng.includes(".")) {
12869
- this.deprecateDottedLng("addResource");
12870
- path = lng.split(".");
12871
- value = ns;
12872
- ns = path[1];
12873
- }
12874
13494
  this.addNamespaces(ns);
12875
13495
  setPath(this.data, path, value);
12876
13496
  if (!options.silent) this.emit("added", lng, ns, key, value);
@@ -12878,25 +13498,21 @@ var ResourceStore = class extends EventEmitter {
12878
13498
  addResources(lng, ns, resources, options = {
12879
13499
  silent: false
12880
13500
  }) {
12881
- for (const m2 in resources) {
12882
- if (isString(resources[m2]) || Array.isArray(resources[m2])) this.addResource(lng, ns, m2, resources[m2], {
13501
+ assertSeparateArguments("addResources", lng, ns);
13502
+ Object.keys(resources || {}).forEach((m2) => {
13503
+ if (m2 === "__proto__" || m2 === "constructor") return;
13504
+ this.addResource(lng, ns, m2, resources[m2], {
12883
13505
  silent: true
12884
13506
  });
12885
- }
13507
+ });
12886
13508
  if (!options.silent) this.emit("added", lng, ns, resources);
12887
13509
  }
12888
13510
  addResourceBundle(lng, ns, resources, deep, overwrite, options = {
12889
13511
  silent: false,
12890
13512
  skipCopy: false
12891
13513
  }) {
12892
- let path = [lng, ns];
12893
- if (lng.includes(".")) {
12894
- this.deprecateDottedLng("addResourceBundle");
12895
- path = lng.split(".");
12896
- deep = resources;
12897
- resources = ns;
12898
- ns = path[1];
12899
- }
13514
+ assertSeparateArguments("addResourceBundle", lng, ns);
13515
+ const path = [lng, ns];
12900
13516
  this.addNamespaces(ns);
12901
13517
  let pack = getPath(this.data, path) || {};
12902
13518
  if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
@@ -12943,18 +13559,6 @@ var ResourceStore = class extends EventEmitter {
12943
13559
  return this.data;
12944
13560
  }
12945
13561
  };
12946
- var postProcessor = {
12947
- processors: {},
12948
- addPostProcessor(module) {
12949
- this.processors[module.name] = module;
12950
- },
12951
- handle(processors, value, key, options, translator) {
12952
- processors.forEach((processor) => {
12953
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
12954
- });
12955
- return value;
12956
- }
12957
- };
12958
13562
  var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
12959
13563
  function createProxy() {
12960
13564
  const state = [];
@@ -12973,7 +13577,7 @@ function keysFromSelector(selector, opts) {
12973
13577
  const {
12974
13578
  [PATH_KEY]: path
12975
13579
  } = selector(createProxy());
12976
- const keySeparator = opts?.keySeparator ?? ".";
13580
+ const keySeparator = opts?.keySeparator || ".";
12977
13581
  const nsSeparator = opts?.nsSeparator ?? ":";
12978
13582
  const strict = opts?.enableSelector === "strict";
12979
13583
  if (path.length > 1 && nsSeparator) {
@@ -12992,12 +13596,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
12992
13596
  var Translator = class _Translator extends EventEmitter {
12993
13597
  constructor(services, options = {}) {
12994
13598
  super();
12995
- copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "ownPostProcessors"], services, this);
13599
+ copy2(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
12996
13600
  this.options = options;
12997
13601
  if (this.options.keySeparator === void 0) {
12998
13602
  this.options.keySeparator = ".";
12999
13603
  }
13000
- this.logger = baseLogger.create("translator");
13604
+ this.logger = (services.logger || baseLogger).create("translator");
13001
13605
  this.checkedLoadedFor = {};
13002
13606
  }
13003
13607
  changeLanguage(lng) {
@@ -13114,30 +13718,32 @@ var Translator = class _Translator extends EventEmitter {
13114
13718
  ordinal: false
13115
13719
  }) : "";
13116
13720
  const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
13117
- const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
13721
+ const sep = this.options.pluralSeparator;
13722
+ 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));
13118
13723
  let resForObjHndl = res;
13119
13724
  if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
13120
13725
  resForObjHndl = defaultValue;
13121
13726
  }
13122
13727
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
13123
13728
  const resType = Object.prototype.toString.apply(resForObjHndl);
13124
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
13125
- if (!opt.returnObjects && !this.options.returnObjects) {
13126
- if (!this.options.returnedObjectHandler) {
13127
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13128
- 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)");
13129
- }
13130
- const r2 = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13131
- ...opt,
13132
- ns: namespaces
13133
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
13134
- if (returnDetails) {
13135
- resolved.res = r2;
13136
- resolved.usedParams = this.getUsedParamsDetails(opt);
13137
- return resolved;
13138
- }
13139
- return r2;
13729
+ const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
13730
+ const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
13731
+ if (objectNotReturned && this.options.returnedObjectHandler) {
13732
+ const r2 = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13733
+ ...opt,
13734
+ ns: namespaces
13735
+ });
13736
+ if (returnDetails) {
13737
+ resolved.res = r2;
13738
+ resolved.usedParams = this.getUsedParamsDetails(opt);
13739
+ return resolved;
13140
13740
  }
13741
+ return r2;
13742
+ }
13743
+ if (objectNotReturned) {
13744
+ this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13745
+ }
13746
+ if (isObjectHit && !objectNotReturned) {
13141
13747
  if (keySeparator) {
13142
13748
  const resTypeIsArray = Array.isArray(resForObjHndl);
13143
13749
  const copy3 = resTypeIsArray ? [] : {};
@@ -13174,18 +13780,19 @@ var Translator = class _Translator extends EventEmitter {
13174
13780
  } else {
13175
13781
  let usedDefault = false;
13176
13782
  let usedKey = false;
13177
- if (!this.isValidLookup(res) && hasDefaultValue) {
13783
+ if (objectNotReturned) res = void 0;
13784
+ if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
13178
13785
  usedDefault = true;
13179
13786
  res = defaultValue;
13180
13787
  }
13181
- if (!this.isValidLookup(res)) {
13788
+ if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
13182
13789
  usedKey = true;
13183
13790
  res = key;
13184
13791
  }
13185
13792
  const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
13186
13793
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
13187
13794
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
13188
- if (usedKey || usedDefault || updateMissing) {
13795
+ if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
13189
13796
  this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
13190
13797
  if (keySeparator) {
13191
13798
  const fk = this.resolve(key, {
@@ -13266,7 +13873,7 @@ var Translator = class _Translator extends EventEmitter {
13266
13873
  const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
13267
13874
  let nestBef;
13268
13875
  if (skipOnVariables) {
13269
- const nb = res.match(this.interpolator.nestingRegexp);
13876
+ const nb = res.includes(this.interpolator.nestingPrefixText) ? res.match(this.interpolator.nestingRegexp) : null;
13270
13877
  nestBef = nb && nb.length;
13271
13878
  }
13272
13879
  let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
@@ -13276,7 +13883,7 @@ var Translator = class _Translator extends EventEmitter {
13276
13883
  };
13277
13884
  res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
13278
13885
  if (skipOnVariables) {
13279
- const na = res.match(this.interpolator.nestingRegexp);
13886
+ const na = res.includes(this.interpolator.nestingPrefixText) ? res.match(this.interpolator.nestingRegexp) : null;
13280
13887
  const nestAft = na && na.length;
13281
13888
  if (nestBef < nestAft) opt.nest = false;
13282
13889
  }
@@ -13293,18 +13900,21 @@ var Translator = class _Translator extends EventEmitter {
13293
13900
  const postProcess = opt.postProcess || this.options.postProcess;
13294
13901
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
13295
13902
  if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
13296
- postProcessorNames.forEach((name) => {
13297
- if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
13298
- 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`);
13299
- }
13300
- });
13301
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
13903
+ const ppOptions = this.options?.postProcessPassResolved ? {
13302
13904
  i18nResolved: {
13303
13905
  ...resolved,
13304
13906
  usedParams: this.getUsedParamsDetails(opt)
13305
13907
  },
13306
13908
  ...opt
13307
- } : opt, this);
13909
+ } : opt;
13910
+ postProcessorNames.forEach((name) => {
13911
+ const processor = this.postProcessors?.[name];
13912
+ if (!processor) {
13913
+ this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
13914
+ return;
13915
+ }
13916
+ res = processor.process(res, key, ppOptions, this) ?? res;
13917
+ });
13308
13918
  }
13309
13919
  return res;
13310
13920
  }
@@ -13370,6 +13980,15 @@ var Translator = class _Translator extends EventEmitter {
13370
13980
  }
13371
13981
  }
13372
13982
  }
13983
+ if (needsPluralHandling) {
13984
+ const otherSuffix = `${opt.ordinal ? ordinalPrefix : this.options.pluralSeparator}other`;
13985
+ if (pluralSuffix !== otherSuffix) {
13986
+ if (needsContextHandling) {
13987
+ finalKeys.unshift(`${key}${this.options.contextSeparator || "_"}${opt.context}${otherSuffix}`);
13988
+ }
13989
+ finalKeys.unshift(key + otherSuffix);
13990
+ }
13991
+ }
13373
13992
  }
13374
13993
  let possibleKey;
13375
13994
  while (possibleKey = finalKeys.pop()) {
@@ -13433,14 +14052,16 @@ var Translator = class _Translator extends EventEmitter {
13433
14052
  }
13434
14053
  };
13435
14054
  var LanguageUtil = class {
13436
- constructor(options) {
14055
+ constructor(options, logger = baseLogger) {
13437
14056
  this.options = options;
13438
14057
  this.supportedLngs = this.options.supportedLngs || false;
13439
- this.logger = baseLogger.create("languageUtils");
14058
+ this.logger = logger.create("languageUtils");
13440
14059
  this.resolveHierarchyCache = {};
14060
+ this.formattedCodes = /* @__PURE__ */ new Map();
13441
14061
  }
13442
14062
  clearCache() {
13443
14063
  this.resolveHierarchyCache = {};
14064
+ this.formattedCodes.clear();
13444
14065
  }
13445
14066
  getScriptPartFromCode(code) {
13446
14067
  code = getCleanedCode(code);
@@ -13458,35 +14079,28 @@ var LanguageUtil = class {
13458
14079
  return this.formatLanguageCode(p2[0]);
13459
14080
  }
13460
14081
  formatLanguageCode(code) {
13461
- if (isString(code) && code.includes("-")) {
13462
- let formattedCode;
14082
+ if (!isString(code)) return code;
14083
+ let formatted = this.formattedCodes.get(code);
14084
+ if (formatted !== void 0) return formatted;
14085
+ formatted = this.formatUncached(code);
14086
+ if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
14087
+ this.formattedCodes.set(code, formatted);
14088
+ return formatted;
14089
+ }
14090
+ formatUncached(code) {
14091
+ const hasSubtags = code.includes("-");
14092
+ if (hasSubtags || this.options.cleanCode !== false) {
14093
+ let canonical;
13463
14094
  try {
13464
- formattedCode = Intl.getCanonicalLocales(code)[0];
14095
+ canonical = Intl.getCanonicalLocales(code)[0];
13465
14096
  } catch (e) {
13466
14097
  }
13467
- if (formattedCode && this.options.lowerCaseLng) {
13468
- formattedCode = formattedCode.toLowerCase();
13469
- }
13470
- if (formattedCode) return formattedCode;
13471
- if (this.options.lowerCaseLng) {
13472
- return code.toLowerCase();
14098
+ if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
14099
+ return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
13473
14100
  }
13474
- return code;
13475
- }
13476
- const formatted = this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
13477
- if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
13478
- return formatted;
13479
- }
13480
- deprecateBareCode(code, formatted) {
13481
- let v27;
13482
- try {
13483
- v27 = Intl.getCanonicalLocales(code)[0];
13484
- } catch (e) {
13485
- return;
14101
+ if (canonical) return code.toLowerCase();
13486
14102
  }
13487
- if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
13488
- if (v27 === formatted) return;
13489
- 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`);
14103
+ return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
13490
14104
  }
13491
14105
  isSupportedCode(code) {
13492
14106
  if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
@@ -13577,6 +14191,7 @@ var LanguageUtil = class {
13577
14191
  if (!codes.includes(formattedFc)) addCode(formattedFc);
13578
14192
  });
13579
14193
  if (cacheKey !== null) {
14194
+ if (Object.keys(this.resolveHierarchyCache).length >= 1e3) this.resolveHierarchyCache = {};
13580
14195
  this.resolveHierarchyCache[cacheKey] = codes;
13581
14196
  return codes.slice();
13582
14197
  }
@@ -13598,10 +14213,10 @@ var dummyRule = {
13598
14213
  })
13599
14214
  };
13600
14215
  var PluralResolver = class {
13601
- constructor(languageUtils, options = {}) {
14216
+ constructor(languageUtils, options = {}, logger = baseLogger) {
13602
14217
  this.languageUtils = languageUtils;
13603
14218
  this.options = options;
13604
- this.logger = baseLogger.create("pluralResolver");
14219
+ this.logger = logger.create("pluralResolver");
13605
14220
  this.pluralRulesCache = {};
13606
14221
  }
13607
14222
  clearCache() {
@@ -13631,6 +14246,7 @@ var PluralResolver = class {
13631
14246
  const lngPart = this.languageUtils.getLanguagePartFromCode(code);
13632
14247
  rule = this.getRule(lngPart, options);
13633
14248
  }
14249
+ if (Object.keys(this.pluralRulesCache).length >= 1e3) this.pluralRulesCache = {};
13634
14250
  this.pluralRulesCache[cacheKey] = rule;
13635
14251
  return rule;
13636
14252
  }
@@ -13666,8 +14282,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
13666
14282
  return path;
13667
14283
  };
13668
14284
  var Interpolator = class {
13669
- constructor(options = {}) {
13670
- this.logger = baseLogger.create("interpolator");
14285
+ constructor(options = {}, logger = baseLogger) {
14286
+ this.logger = logger.create("interpolator");
13671
14287
  this.options = options;
13672
14288
  this.format = options?.interpolation?.format || ((value) => value);
13673
14289
  this.init(options);
@@ -13681,39 +14297,28 @@ var Interpolator = class {
13681
14297
  escapeValue,
13682
14298
  useRawValueToEscape,
13683
14299
  prefix: prefix2,
13684
- prefixEscaped,
13685
14300
  suffix,
13686
- suffixEscaped,
13687
14301
  formatSeparator,
13688
14302
  unescapeSuffix,
13689
14303
  unescapePrefix,
13690
14304
  nestingPrefix,
13691
- nestingPrefixEscaped,
13692
14305
  nestingSuffix,
13693
- nestingSuffixEscaped,
13694
14306
  nestingOptionsSeparator,
13695
14307
  maxReplaces,
13696
14308
  alwaysFormat
13697
14309
  } = options.interpolation;
13698
- if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
13699
- const names = Object.entries({
13700
- prefixEscaped,
13701
- suffixEscaped,
13702
- nestingPrefixEscaped,
13703
- nestingSuffixEscaped
13704
- }).filter(([, v2]) => v2).map(([k2]) => k2);
13705
- 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`);
13706
- }
13707
14310
  this.escape = escape$1 !== void 0 ? escape$1 : escape;
13708
14311
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
13709
14312
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
13710
- this.prefix = prefix2 ? regexEscape(prefix2) : prefixEscaped || "{{";
13711
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
14313
+ this.prefix = prefix2 ? regexEscape(prefix2) : "{{";
14314
+ this.suffix = suffix ? regexEscape(suffix) : "}}";
13712
14315
  this.formatSeparator = formatSeparator || ",";
13713
14316
  this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
13714
14317
  this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
13715
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
13716
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
14318
+ this.prefixText = prefix2 || "{{";
14319
+ this.nestingPrefixText = nestingPrefix || "$t(";
14320
+ this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
14321
+ this.nestingSuffix = regexEscape(nestingSuffix || ")");
13717
14322
  this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
13718
14323
  this.maxReplaces = maxReplaces || 1e3;
13719
14324
  this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
@@ -13764,18 +14369,13 @@ var Interpolator = class {
13764
14369
  }
13765
14370
  const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
13766
14371
  const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
14372
+ if (isString(str) && !str.includes(this.prefixText)) return str;
13767
14373
  const todos = [{
13768
14374
  regex: this.regexpUnescape,
13769
14375
  safeValue: (val) => val
13770
14376
  }, {
13771
14377
  regex: this.regexp,
13772
- safeValue: (val) => {
13773
- if (!this.escapeValue) return val;
13774
- if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
13775
- this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '&#x2F;' today; from v27 the default escape leaves '/' as it is");
13776
- }
13777
- return this.escape(val);
13778
- }
14378
+ safeValue: (val) => this.escapeValue ? this.escape(val) : val
13779
14379
  }];
13780
14380
  const unescapedValues = [];
13781
14381
  let shift = 0;
@@ -13859,6 +14459,7 @@ var Interpolator = class {
13859
14459
  if (clonedOptions.defaultValue && clonedOptions.defaultValue.includes(this.prefix)) delete clonedOptions.defaultValue;
13860
14460
  return key;
13861
14461
  };
14462
+ if (isString(str) && !str.includes(this.nestingPrefixText)) return str;
13862
14463
  const nestingRegexp = new RegExp(this.nestingRegexp);
13863
14464
  let out = "";
13864
14465
  let lastEnd = 0;
@@ -13926,8 +14527,9 @@ var parseFormatStr = (formatStr) => {
13926
14527
  formatOptions
13927
14528
  };
13928
14529
  };
14530
+ var cachedFormattersLimit = 1e3;
13929
14531
  var createCachedFormatter = (fn) => {
13930
- const cache = {};
14532
+ const cache = /* @__PURE__ */ new Map();
13931
14533
  return (v2, l2, o) => {
13932
14534
  let optForCache = o;
13933
14535
  if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
@@ -13942,10 +14544,11 @@ var createCachedFormatter = (fn) => {
13942
14544
  } catch (e) {
13943
14545
  return fn(getCleanedCode(l2), o)(v2);
13944
14546
  }
13945
- let frm = cache[key];
14547
+ let frm = cache.get(key);
13946
14548
  if (!frm) {
13947
14549
  frm = fn(getCleanedCode(l2), o);
13948
- cache[key] = frm;
14550
+ if (cache.size >= cachedFormattersLimit) cache.delete(cache.keys().next().value);
14551
+ cache.set(key, frm);
13949
14552
  }
13950
14553
  return frm(v2);
13951
14554
  };
@@ -13960,6 +14563,7 @@ var Formatter = class {
13960
14563
  init(services, options = {
13961
14564
  interpolation: {}
13962
14565
  }) {
14566
+ if (services?.logger?.create) this.logger = services.logger.create("formatter");
13963
14567
  this.formatSeparator = options.interpolation.formatSeparator || ",";
13964
14568
  const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
13965
14569
  this.formats = {
@@ -14041,6 +14645,7 @@ var Formatter = class {
14041
14645
  return result;
14042
14646
  }
14043
14647
  };
14648
+ var maxFailedLoads = 1e3;
14044
14649
  var removePending = (q2, name) => {
14045
14650
  if (q2.pending[name] !== void 0) {
14046
14651
  delete q2.pending[name];
@@ -14055,13 +14660,14 @@ var Connector = class extends EventEmitter {
14055
14660
  this.services = services;
14056
14661
  this.languageUtils = services.languageUtils;
14057
14662
  this.options = options;
14058
- this.logger = baseLogger.create("backendConnector");
14663
+ this.logger = (services.logger || baseLogger).create("backendConnector");
14059
14664
  this.waitingReads = [];
14060
14665
  this.maxParallelReads = options.maxParallelReads || 10;
14061
14666
  this.readingCalls = 0;
14062
14667
  this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
14063
14668
  this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
14064
14669
  this.state = {};
14670
+ this.failed = /* @__PURE__ */ new Set();
14065
14671
  this.queue = [];
14066
14672
  this.backend?.init?.(services, options.backend, options);
14067
14673
  this.callbackApi = callbackApiOf(this.backend);
@@ -14121,6 +14727,15 @@ var Connector = class extends EventEmitter {
14121
14727
  }
14122
14728
  this.state[name] = err ? -1 : 2;
14123
14729
  if (err && data) this.state[name] = 0;
14730
+ this.failed.delete(name);
14731
+ if (err) {
14732
+ this.failed.add(name);
14733
+ if (this.failed.size > maxFailedLoads) {
14734
+ const oldest = this.failed.values().next().value;
14735
+ this.failed.delete(oldest);
14736
+ if (this.state[oldest] < 1) delete this.state[oldest];
14737
+ }
14738
+ }
14124
14739
  const loaded = {};
14125
14740
  this.queue.forEach((q2) => {
14126
14741
  pushPath(q2.loaded, [lng], ns);
@@ -14215,15 +14830,10 @@ var Connector = class extends EventEmitter {
14215
14830
  reload: true
14216
14831
  }, callback);
14217
14832
  }
14218
- noticeDevFallback(lng) {
14219
- if (lng !== "dev" || !this.devIsDefaultFallback) return;
14220
- 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");
14221
- }
14222
14833
  loadOne(name, prefix2 = "") {
14223
14834
  const s = name.split("|");
14224
14835
  const lng = s[0];
14225
14836
  const ns = s[1];
14226
- this.noticeDevFallback(lng);
14227
14837
  this.read(lng, ns, "read", void 0, void 0, (err, data) => {
14228
14838
  if (err) this.logger.warn(`${prefix2}loading namespace ${ns} for language ${lng} failed`, err);
14229
14839
  if (!err && data) this.logger.log(`${prefix2}loaded namespace ${ns} for language ${lng}`, data);
@@ -14238,7 +14848,6 @@ var Connector = class extends EventEmitter {
14238
14848
  }
14239
14849
  if (key === void 0 || key === null || key === "") return;
14240
14850
  if (this.backend?.create) {
14241
- languages?.forEach?.((l2) => this.noticeDevFallback(l2));
14242
14851
  const opts = {
14243
14852
  ...options,
14244
14853
  isUpdate
@@ -14273,7 +14882,7 @@ var get = () => ({
14273
14882
  initAsync: true,
14274
14883
  ns: ["translation"],
14275
14884
  defaultNS: ["translation"],
14276
- fallbackLng: ["dev"],
14885
+ fallbackLng: false,
14277
14886
  fallbackNS: false,
14278
14887
  supportedLngs: false,
14279
14888
  nonExplicitSupportedLngs: false,
@@ -14294,7 +14903,7 @@ var get = () => ({
14294
14903
  postProcess: false,
14295
14904
  postProcessPassResolved: false,
14296
14905
  returnNull: false,
14297
- returnEmptyString: true,
14906
+ returnEmptyString: false,
14298
14907
  returnObjects: false,
14299
14908
  joinArrays: false,
14300
14909
  returnedObjectHandler: false,
@@ -14339,7 +14948,39 @@ var transformOptions = (options) => {
14339
14948
  };
14340
14949
  var noop = () => {
14341
14950
  };
14342
- var loggerOwner;
14951
+ var withDefaults = (options) => {
14952
+ const defOpts = get();
14953
+ const merged = {
14954
+ ...defOpts,
14955
+ ...options
14956
+ };
14957
+ merged.interpolation = {
14958
+ ...defOpts.interpolation,
14959
+ ...options.interpolation
14960
+ };
14961
+ if (typeof merged.overloadTranslationOptionHandler !== "function") {
14962
+ merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
14963
+ }
14964
+ return merged;
14965
+ };
14966
+ var configuredLanguageCodes = (options) => {
14967
+ const codes = [].concat(options.supportedLngs || [], options.preload || []);
14968
+ codes.push(...Object.keys(options.resources || {}));
14969
+ const fallbackLng = options.fallbackLng;
14970
+ if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
14971
+ else if (fallbackLng && typeof fallbackLng === "object") {
14972
+ Object.keys(fallbackLng).forEach((code) => {
14973
+ if (code !== "default") codes.push(code);
14974
+ codes.push(...[].concat(fallbackLng[code]));
14975
+ });
14976
+ }
14977
+ return codes;
14978
+ };
14979
+ var isRefusedLanguageCode = (i18n2, code) => {
14980
+ if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
14981
+ 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`);
14982
+ return true;
14983
+ };
14343
14984
  var bindMemberFunctions = (inst) => {
14344
14985
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
14345
14986
  mems.forEach((mem) => {
@@ -14351,17 +14992,18 @@ var bindMemberFunctions = (inst) => {
14351
14992
  var I18n = class _I18n extends EventEmitter {
14352
14993
  constructor(options = {}, callback) {
14353
14994
  super();
14354
- this.options = transformOptions(options);
14995
+ this.userOptions = transformOptions(options);
14996
+ this.options = withDefaults(this.userOptions);
14355
14997
  this.services = {
14356
- ownPostProcessors: /* @__PURE__ */ new Set()
14998
+ postProcessors: /* @__PURE__ */ Object.create(null)
14357
14999
  };
14358
- this.logger = baseLogger;
15000
+ this.logger = new Logger(null, this.options);
14359
15001
  this.modules = {
14360
15002
  external: []
14361
15003
  };
14362
15004
  bindMemberFunctions(this);
14363
15005
  if (callback && !this.isInitialized && !options.isClone) {
14364
- if (!this.options.initAsync) {
15006
+ if (!this.userOptions.initAsync) {
14365
15007
  this.init(options, callback);
14366
15008
  return this;
14367
15009
  }
@@ -14383,25 +15025,23 @@ var I18n = class _I18n extends EventEmitter {
14383
15025
  options.defaultNS = options.ns[0];
14384
15026
  }
14385
15027
  }
14386
- const fallbackLngIsDefault = options.fallbackLng === void 0 && this.options.fallbackLng === void 0;
14387
- const defOpts = get();
14388
- this.options = {
14389
- ...defOpts,
14390
- ...this.options,
14391
- ...transformOptions(options)
15028
+ transformOptions(options);
15029
+ const userOptions = {
15030
+ ...this.userOptions,
15031
+ ...options
14392
15032
  };
14393
- this.options.interpolation = {
14394
- ...defOpts.interpolation,
14395
- ...this.options.interpolation
14396
- };
14397
- if (options.keySeparator !== void 0) {
14398
- this.options.userDefinedKeySeparator = options.keySeparator;
15033
+ this.options = withDefaults({
15034
+ ...this.options,
15035
+ ...options
15036
+ });
15037
+ if (userOptions.keySeparator !== void 0) {
15038
+ this.options.userDefinedKeySeparator = userOptions.keySeparator;
14399
15039
  }
14400
- if (options.nsSeparator !== void 0) {
14401
- this.options.userDefinedNsSeparator = options.nsSeparator;
15040
+ if (userOptions.nsSeparator !== void 0) {
15041
+ this.options.userDefinedNsSeparator = userOptions.nsSeparator;
14402
15042
  }
14403
- if (typeof this.options.overloadTranslationOptionHandler !== "function") {
14404
- this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
15043
+ if (!this.options.isClone) {
15044
+ this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
14405
15045
  }
14406
15046
  const createClassOnDemand = (ClassOrObject) => {
14407
15047
  if (!ClassOrObject) return null;
@@ -14409,15 +15049,10 @@ var I18n = class _I18n extends EventEmitter {
14409
15049
  return ClassOrObject;
14410
15050
  };
14411
15051
  if (!this.options.isClone) {
14412
- if (loggerOwner && loggerOwner !== this && loggerOwner.modules.logger !== this.modules.logger) {
14413
- 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");
14414
- }
14415
- loggerOwner = this.modules.logger ? this : void 0;
14416
- if (this.modules.logger) {
14417
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
14418
- } else {
14419
- baseLogger.init(null, this.options);
14420
- }
15052
+ this.logger.init(createClassOnDemand(this.modules.logger), this.options);
15053
+ const {
15054
+ logger
15055
+ } = this;
14421
15056
  this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
14422
15057
  this.pendingWarnings = void 0;
14423
15058
  let formatter;
@@ -14426,27 +15061,26 @@ var I18n = class _I18n extends EventEmitter {
14426
15061
  } else {
14427
15062
  formatter = Formatter;
14428
15063
  }
14429
- const lu = new LanguageUtil(this.options);
14430
- this.store = new ResourceStore(this.options.resources, this.options);
15064
+ const lu = new LanguageUtil(this.options, logger);
15065
+ this.store = new ResourceStore(this.options.resources, this.options, logger);
14431
15066
  const s = this.services;
14432
- s.logger = baseLogger;
15067
+ s.logger = logger;
14433
15068
  s.resourceStore = this.store;
14434
15069
  s.languageUtils = lu;
14435
15070
  s.pluralResolver = new PluralResolver(lu, {
14436
15071
  prepend: this.options.pluralSeparator
14437
- });
15072
+ }, logger);
14438
15073
  if (formatter) {
14439
15074
  s.formatter = createClassOnDemand(formatter);
14440
15075
  if (s.formatter.init) s.formatter.init(s, this.options);
14441
15076
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
14442
15077
  }
14443
- s.interpolator = new Interpolator(this.options);
15078
+ s.interpolator = new Interpolator(this.options, logger);
14444
15079
  s.utils = {
14445
15080
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
14446
15081
  reloadResources: this.reloadResources.bind(this)
14447
15082
  };
14448
15083
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
14449
- s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
14450
15084
  s.backendConnector.on("*", (event, ...args) => {
14451
15085
  this.emit(event, ...args);
14452
15086
  });
@@ -14587,8 +15221,7 @@ var I18n = class _I18n extends EventEmitter {
14587
15221
  setModule("i18nFormat");
14588
15222
  }
14589
15223
  if (module.type === "postProcessor") {
14590
- postProcessor.addPostProcessor(module);
14591
- this.services.ownPostProcessors?.add(module.name);
15224
+ this.services.postProcessors[module.name] = module;
14592
15225
  }
14593
15226
  if (module.type === "formatter") {
14594
15227
  setModule("formatter");
@@ -14663,14 +15296,16 @@ var I18n = class _I18n extends EventEmitter {
14663
15296
  };
14664
15297
  const setLng = (lngs) => {
14665
15298
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
14666
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
14667
- const l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
14668
- if (l2 && this.logger.debug && !isSafeLanguageCode(l2)) {
14669
- const configured = [].concat(this.options.supportedLngs || [], this.services.languageUtils.getFallbackCodes(this.options.fallbackLng, l2), this.options.preload || []);
14670
- if (!configured.includes(l2) && !Object.prototype.hasOwnProperty.call(this.store.data, l2)) {
14671
- this.logger.once(`lng:${l2}`, "deprecate", `changeLanguage: the language code '${l2.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`);
14672
- }
15299
+ const {
15300
+ supportedLngs
15301
+ } = this.options;
15302
+ if (lngs && !supportedLngs) {
15303
+ const accepted = [].concat(lngs).filter((c2) => !isRefusedLanguageCode(this, c2));
15304
+ if (accepted.length < [].concat(lngs).length) lngs = accepted;
14673
15305
  }
15306
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
15307
+ let l2 = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15308
+ if (supportedLngs && isRefusedLanguageCode(this, l2)) l2 = this.services.languageUtils.getBestMatchFromCodes([]);
14674
15309
  if (l2) {
14675
15310
  if (!this.language) {
14676
15311
  setLngProps(l2);
@@ -14785,7 +15420,7 @@ var I18n = class _I18n extends EventEmitter {
14785
15420
  }
14786
15421
  loadNamespaces(ns, callback) {
14787
15422
  const deferred = defer();
14788
- if (!this.options.ns) {
15423
+ if (!this.options.ns || !this.services.backendConnector) {
14789
15424
  if (callback) callback();
14790
15425
  return Promise.resolve();
14791
15426
  }
@@ -14803,7 +15438,7 @@ var I18n = class _I18n extends EventEmitter {
14803
15438
  const deferred = defer();
14804
15439
  if (isString(lngs)) lngs = [lngs];
14805
15440
  const preloaded = this.options.preload || [];
14806
- const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
15441
+ const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
14807
15442
  if (!newLngs.length) {
14808
15443
  if (callback) callback();
14809
15444
  return Promise.resolve();
@@ -14853,16 +15488,15 @@ var I18n = class _I18n extends EventEmitter {
14853
15488
  }
14854
15489
  };
14855
15490
  const clone = new _I18n(mergedOptions);
14856
- if (options.debug !== void 0 || options.prefix !== void 0) {
14857
- clone.logger = clone.logger.clone(options);
14858
- }
14859
- const membersToCopy = ["store", "services", "language"];
15491
+ clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
15492
+ const membersToCopy = ["store", "language"];
14860
15493
  membersToCopy.forEach((m2) => {
14861
15494
  clone[m2] = this[m2];
14862
15495
  });
14863
15496
  clone.services = {
14864
15497
  ...this.services
14865
15498
  };
15499
+ clone.services.postProcessors = Object.create(this.services.postProcessors);
14866
15500
  clone.services.utils = {
14867
15501
  ...clone.services.utils,
14868
15502
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
@@ -14879,7 +15513,7 @@ var I18n = class _I18n extends EventEmitter {
14879
15513
  return copied;
14880
15514
  };
14881
15515
  const clonedData = copyData(this.store.data);
14882
- clone.store = new ResourceStore(clonedData, mergedOptions);
15516
+ clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
14883
15517
  clone.services.resourceStore = clone.store;
14884
15518
  }
14885
15519
  if (options.interpolation) {
@@ -14893,8 +15527,9 @@ var I18n = class _I18n extends EventEmitter {
14893
15527
  ...mergedOptions,
14894
15528
  interpolation: mergedInterpolation
14895
15529
  };
14896
- clone.services.interpolator = new Interpolator(mergedForInterpolator);
15530
+ clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
14897
15531
  }
15532
+ clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
14898
15533
  clone.translator = new Translator(clone.services, mergedOptions);
14899
15534
  clone.translator.on("*", (event, ...args) => {
14900
15535
  clone.emit(event, ...args);
@@ -15191,6 +15826,19 @@ var en = {
15191
15826
  "mo": "mo",
15192
15827
  "qtr": "qtr",
15193
15828
  "yr": "yr",
15829
+ "wk": "wk",
15830
+ "X days short": "{{amount, number}}d",
15831
+ "X weeks short": "{{amount, number}}wk",
15832
+ "X months short": "{{amount, number}}mo",
15833
+ "X years short": "{{amount, number}}yr",
15834
+ "X days_one": "{{count, number}} day",
15835
+ "X days_other": "{{count, number}} days",
15836
+ "X weeks_one": "{{count, number}} week",
15837
+ "X weeks_other": "{{count, number}} weeks",
15838
+ "X months_one": "{{count, number}} month",
15839
+ "X months_other": "{{count, number}} months",
15840
+ "X years_one": "{{count, number}} year",
15841
+ "X years_other": "{{count, number}} years",
15194
15842
  "one time": "one time",
15195
15843
  "billing period": "billing period",
15196
15844
  "billing period_one": "billing period",
@@ -15200,6 +15848,7 @@ var en = {
15200
15848
  "monthly": "monthly",
15201
15849
  "quarterly": "quarterly",
15202
15850
  "yearly": "yearly",
15851
+ "every period": "every {{period}}",
15203
15852
  "expires after purchase": "expires {{amount}} {{unit}} after purchase",
15204
15853
  "expires at the end of the billing period": "expires at the end of the billing period",
15205
15854
  "expires at the end of the next billing period": "expires at the end of the next billing period",
@@ -15502,6 +16151,23 @@ var it2 = {
15502
16151
  "mo": "mese",
15503
16152
  "qtr": "trim.",
15504
16153
  "yr": "anno",
16154
+ "wk": "sett.",
16155
+ "X days short": "{{amount, number}} gg",
16156
+ "X weeks short": "{{amount, number}} sett.",
16157
+ "X months short": "{{amount, number}} mesi",
16158
+ "X years short": "{{amount, number}} anni",
16159
+ "X days_one": "{{count, number}} giorno",
16160
+ "X days_many": "{{count, number}} giorni",
16161
+ "X days_other": "{{count, number}} giorni",
16162
+ "X weeks_one": "{{count, number}} settimana",
16163
+ "X weeks_many": "{{count, number}} settimane",
16164
+ "X weeks_other": "{{count, number}} settimane",
16165
+ "X months_one": "{{count, number}} mese",
16166
+ "X months_many": "{{count, number}} mesi",
16167
+ "X months_other": "{{count, number}} mesi",
16168
+ "X years_one": "{{count, number}} anno",
16169
+ "X years_many": "{{count, number}} anni",
16170
+ "X years_other": "{{count, number}} anni",
15505
16171
  "one time": "una tantum",
15506
16172
  "billing period": "periodo di fatturazione",
15507
16173
  "billing period_one": "periodo di fatturazione",
@@ -15535,6 +16201,7 @@ var it2 = {
15535
16201
  "monthly": "mensile",
15536
16202
  "quarterly": "trimestrale",
15537
16203
  "yearly": "annuale",
16204
+ "every period": "ogni {{period}}",
15538
16205
  "Usage by user": "Utilizzo per utente",
15539
16206
  "X used by your team this period": "{{amount}} utilizzati dal tuo team in questo periodo",
15540
16207
  "Show all X users_one": "Mostra {{count, number}} utente",
@@ -15728,14 +16395,24 @@ function derivePeriod(interval, intervalCount) {
15728
16395
  }
15729
16396
  return interval;
15730
16397
  }
15731
- function getSubscriptionPeriod(billingSubscription) {
16398
+ function getSubscriptionInterval(billingSubscription) {
15732
16399
  if (!billingSubscription) {
15733
16400
  return void 0;
15734
16401
  }
15735
16402
  const product = billingSubscription.products?.find(
15736
16403
  (p2) => p2.interval && p2.interval !== "one-time"
15737
16404
  );
15738
- return derivePeriod(product?.interval, product?.intervalCount) ?? derivePeriod(billingSubscription.interval);
16405
+ if (product?.interval) {
16406
+ return { interval: product.interval, intervalCount: product.intervalCount };
16407
+ }
16408
+ return billingSubscription.interval ? { interval: billingSubscription.interval } : void 0;
16409
+ }
16410
+ function getSubscriptionPeriod(billingSubscription) {
16411
+ const subscriptionInterval = getSubscriptionInterval(billingSubscription);
16412
+ return derivePeriod(
16413
+ subscriptionInterval?.interval,
16414
+ subscriptionInterval?.intervalCount
16415
+ );
15739
16416
  }
15740
16417
  function getDefaultPlanPeriod(plans = []) {
15741
16418
  if (plans.some((plan) => plan.monthlyPrice)) return "month";
@@ -16008,6 +16685,8 @@ function getResetCadencePeriod(cadence) {
16008
16685
  switch (cadence) {
16009
16686
  case BillingPlanCreditGrantResetCadence.Yearly:
16010
16687
  return "year";
16688
+ case BillingPlanCreditGrantResetCadence.Quarterly:
16689
+ return "quarter";
16011
16690
  case BillingPlanCreditGrantResetCadence.Monthly:
16012
16691
  return "month";
16013
16692
  case BillingPlanCreditGrantResetCadence.Weekly:
@@ -16497,6 +17176,11 @@ function getEntitlementFeatureName(entitlement, defaultValue) {
16497
17176
  function entitlementHasCost(entitlement) {
16498
17177
  return entitlement.priceBehavior && (entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance && entitlement.quantity > 0 || entitlement.priceBehavior !== EntitlementPriceBehavior.PayInAdvance);
16499
17178
  }
17179
+ function hasMeteredCosts(entitlements) {
17180
+ return entitlements.some(
17181
+ ({ priceBehavior }) => !!priceBehavior && priceBehavior !== EntitlementPriceBehavior.PayInAdvance && priceBehavior !== EntitlementPriceBehavior.CreditBurndown
17182
+ );
17183
+ }
16500
17184
  function entitlementHasHardLimit(entitlement) {
16501
17185
  return entitlement.priceBehavior && entitlement.priceBehavior !== EntitlementPriceBehavior.CreditBurndown;
16502
17186
  }
@@ -16646,8 +17330,38 @@ function getMonthName(date, { locale, ...format }) {
16646
17330
  ...format
16647
17331
  }).format(new Date(date));
16648
17332
  }
16649
- function shortenPeriod(period, t3) {
16650
- switch (period) {
17333
+ var QUARTERLY_INTERVAL_COUNT = 3;
17334
+ var YEARLY_INTERVAL_COUNT = 12;
17335
+ function normalizeInterval(interval, intervalCount) {
17336
+ const count = intervalCount && intervalCount > 1 ? intervalCount : 1;
17337
+ if (interval === "month" && count === QUARTERLY_INTERVAL_COUNT) {
17338
+ return { period: "quarter", count: 1 };
17339
+ }
17340
+ if (interval === "month" && count === YEARLY_INTERVAL_COUNT) {
17341
+ return { period: "year", count: 1 };
17342
+ }
17343
+ return { period: interval, count };
17344
+ }
17345
+ function shortenPeriod(period, t3, intervalCount) {
17346
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17347
+ if (count > 1) {
17348
+ switch (unit) {
17349
+ case "day":
17350
+ return t3("X days short", { amount: count });
17351
+ case "week":
17352
+ return t3("X weeks short", { amount: count });
17353
+ case "month":
17354
+ return t3("X months short", { amount: count });
17355
+ case "year":
17356
+ return t3("X years short", { amount: count });
17357
+ }
17358
+ return;
17359
+ }
17360
+ switch (unit) {
17361
+ case "day":
17362
+ return t3("day");
17363
+ case "week":
17364
+ return t3("wk");
16651
17365
  case "month":
16652
17366
  return t3("mo");
16653
17367
  case "quarter":
@@ -16656,6 +17370,31 @@ function shortenPeriod(period, t3) {
16656
17370
  return t3("yr");
16657
17371
  }
16658
17372
  }
17373
+ function nameInterval(period, t3, intervalCount) {
17374
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17375
+ if (count > 1) {
17376
+ switch (unit) {
17377
+ case "day":
17378
+ return t3("X days", { count });
17379
+ case "week":
17380
+ return t3("X weeks", { count });
17381
+ case "month":
17382
+ return t3("X months", { count });
17383
+ case "year":
17384
+ return t3("X years", { count });
17385
+ }
17386
+ return period;
17387
+ }
17388
+ switch (unit) {
17389
+ case "day":
17390
+ case "week":
17391
+ case "month":
17392
+ case "quarter":
17393
+ case "year":
17394
+ return t3(unit);
17395
+ }
17396
+ return period;
17397
+ }
16659
17398
  function modifyDate(date, days) {
16660
17399
  const copy3 = new Date(date);
16661
17400
  copy3.setDate(copy3.getDate() + days);
@@ -16738,8 +17477,14 @@ function formatCurrency(amount, {
16738
17477
  function formatOrdinal(n2, t3) {
16739
17478
  return t3("Ordinal", { count: n2, ordinal: true });
16740
17479
  }
16741
- function adjectify(period, t3) {
16742
- switch (period) {
17480
+ function adjectify(period, t3, intervalCount) {
17481
+ const { period: unit, count } = normalizeInterval(period, intervalCount);
17482
+ if (count > 1) {
17483
+ return t3("every period", {
17484
+ period: nameInterval(period, t3, intervalCount)
17485
+ });
17486
+ }
17487
+ switch (unit) {
16743
17488
  case "day":
16744
17489
  return t3("daily");
16745
17490
  case "week":
@@ -16922,6 +17667,25 @@ var createKeyboardExecutionHandler = (fn) => {
16922
17667
  return handler;
16923
17668
  };
16924
17669
 
17670
+ // src/utils/invoiceLink.ts
17671
+ function openInvoiceLink(event, storedUrl, fetchUrl) {
17672
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
17673
+ return Promise.resolve();
17674
+ }
17675
+ const tab = window.open("", "_blank");
17676
+ if (tab === null) {
17677
+ return Promise.resolve();
17678
+ }
17679
+ event.preventDefault();
17680
+ tab.opener = null;
17681
+ return fetchUrl().then(
17682
+ (url) => url || storedUrl,
17683
+ () => storedUrl
17684
+ ).then((url) => {
17685
+ tab.location.href = url;
17686
+ });
17687
+ }
17688
+
16925
17689
  // src/utils/markdown.tsx
16926
17690
  import { Fragment } from "react";
16927
17691
  import { jsx as jsx2 } from "react/jsx-runtime";
@@ -17674,7 +18438,7 @@ var reducer = (state, action) => {
17674
18438
  // src/context/EmbedProvider.tsx
17675
18439
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
17676
18440
  var getCustomHeaders = (sessionId) => ({
17677
- "X-Schematic-Components-Version": "2.37.0",
18441
+ "X-Schematic-Components-Version": "2.39.0",
17678
18442
  "X-Schematic-Session-ID": sessionId
17679
18443
  });
17680
18444
  var normalizeCurrencyFilter = (filter2) => {
@@ -18062,6 +18826,12 @@ var EmbedProvider = ({
18062
18826
  () => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
18063
18827
  [listInvoices]
18064
18828
  );
18829
+ const getInvoiceLink = useCallback2(
18830
+ async (billingInvoiceId) => {
18831
+ return checkoutApi?.getInvoiceLink({ billingInvoiceId });
18832
+ },
18833
+ [checkoutApi]
18834
+ );
18065
18835
  const getCreditUsageByUser = useCallback2(
18066
18836
  async (billingCreditId, limit) => {
18067
18837
  return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
@@ -18256,6 +19026,7 @@ var EmbedProvider = ({
18256
19026
  getUpcomingInvoice: debouncedGetUpcomingInvoice,
18257
19027
  getCustomerBalance: debouncedGetCustomerBalance,
18258
19028
  listInvoices: debouncedListInvoices,
19029
+ getInvoiceLink,
18259
19030
  getCreditUsageByUser: debouncedGetCreditUsageByUser,
18260
19031
  getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
18261
19032
  finishCheckout,
@@ -18394,10 +19165,10 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
18394
19165
  return periods;
18395
19166
  }, [data?.activePlans, data?.activeAddOns]);
18396
19167
  const getActivePlans = useCallback3(
18397
- (plans) => {
19168
+ (plans, period = activePeriod) => {
18398
19169
  const activePlans = settings.mode === "edit" ? plans.slice() : plans.filter((plan) => {
18399
19170
  if (options.useSelectedPeriod) {
18400
- return activePeriod === "month" && plan.monthlyPrice || activePeriod === "quarter" && plan.quarterlyPrice || activePeriod === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
19171
+ return period === "month" && plan.monthlyPrice || period === "quarter" && plan.quarterlyPrice || period === "year" && plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
18401
19172
  }
18402
19173
  return plan.monthlyPrice || plan.quarterlyPrice || plan.yearlyPrice || plan.chargeType === ChargeType.oneTime;
18403
19174
  });
@@ -18409,7 +19180,8 @@ function useAvailablePlans(activePeriod, options = { useSelectedPeriod: true })
18409
19180
  return {
18410
19181
  plans: getActivePlans(data?.activePlans || []),
18411
19182
  addOns: getActivePlans(data?.activeAddOns || []),
18412
- periods: getAvailablePeriods()
19183
+ periods: getAvailablePeriods(),
19184
+ plansForPeriod: (period) => getActivePlans(data?.activePlans || [], period)
18413
19185
  };
18414
19186
  }, [
18415
19187
  data?.activePlans,
@@ -22127,28 +22899,49 @@ var CheckoutDialog = ({ top }) => {
22127
22899
  }
22128
22900
  }, [filterBlocksSubscriptionCurrency, lockedCurrency, debug]);
22129
22901
  const {
22130
- plans: availablePlans,
22902
+ plans: periodPlans,
22131
22903
  addOns: availableAddOns,
22132
- periods: availablePeriods
22904
+ periods: availablePeriods,
22905
+ plansForPeriod
22133
22906
  } = useAvailablePlans(planPeriod, {
22134
22907
  useSelectedPeriod: showPeriodToggle
22135
22908
  });
22136
- const [selectedPlanId, setSelectedPlanId] = useState8(void 0);
22137
- const selectedPlan = useMemo16(() => {
22138
- if (selectedPlanId === null) {
22139
- return void 0;
22140
- }
22141
- if (selectedPlanId) {
22142
- return availablePlans.find((p2) => p2.id === selectedPlanId);
22143
- }
22144
- if (checkoutState?.planId) {
22145
- return availablePlans.find((plan) => plan.id === checkoutState.planId);
22146
- }
22147
- return availablePlans.find(
22148
- (plan) => plan.current && // do not initially set the current plan for a trial
22149
- (!plan.isTrialable || !plan.companyCanTrial)
22150
- );
22151
- }, [availablePlans, checkoutState, selectedPlanId]);
22909
+ const requestedPlanId = checkoutState?.planId;
22910
+ const bypassPlanSelection = checkoutState?.bypassPlanSelection;
22911
+ const supportsCheckoutCurrency = useCallback8(
22912
+ (plan) => !hasCurrency || planSupportsCurrency(plan, effectiveCurrency) || // A plan the host picks and skips past is kept so the currency/period
22913
+ // mismatch notice can say it is unavailable.
22914
+ !!bypassPlanSelection && plan.id === requestedPlanId,
22915
+ [hasCurrency, effectiveCurrency, bypassPlanSelection, requestedPlanId]
22916
+ );
22917
+ const availablePlans = useMemo16(
22918
+ () => periodPlans.filter(supportsCheckoutCurrency),
22919
+ [periodPlans, supportsCheckoutCurrency]
22920
+ );
22921
+ const [selectedPlanId, setSelectedPlanId] = useState8(
22922
+ void 0
22923
+ );
22924
+ const isTrialing = data?.company?.billingSubscription?.status === "trialing";
22925
+ const findSelectedPlan = useCallback8(
22926
+ (plans) => {
22927
+ if (selectedPlanId) {
22928
+ return plans.find((p2) => p2.id === selectedPlanId);
22929
+ }
22930
+ if (requestedPlanId) {
22931
+ return plans.find((plan) => plan.id === requestedPlanId);
22932
+ }
22933
+ return plans.find(
22934
+ (plan) => plan.current && // A company that could trial its current plan chooses for itself,
22935
+ // unless it is already trialing it.
22936
+ (isTrialing || !plan.isTrialable || !plan.companyCanTrial)
22937
+ );
22938
+ },
22939
+ [requestedPlanId, selectedPlanId, isTrialing]
22940
+ );
22941
+ const selectedPlan = useMemo16(
22942
+ () => findSelectedPlan(availablePlans),
22943
+ [availablePlans, findSelectedPlan]
22944
+ );
22152
22945
  const [shouldTrial, setShouldTrial] = useState8(false);
22153
22946
  const displayedPlanCreditGrants = useMemo16(
22154
22947
  () => getDisplayedPlanCreditGrants(selectedPlan),
@@ -22514,7 +23307,7 @@ var CheckoutDialog = ({ top }) => {
22514
23307
  }, [currencies, selectedPlan, planPeriod]);
22515
23308
  const showPlanCurrencySelector = canSelectCurrency && planStageVisible;
22516
23309
  const showCheckoutCurrencySelector = canSelectCurrency && !planStageVisible && checkoutStageCurrencies.length > 1;
22517
- const currencyPeriodMismatch = hasCurrency && !lockedCurrency && !planStageVisible && !!selectedPlan && !planOffersCurrencyForPeriod(selectedPlan, planPeriod, effectiveCurrency);
23310
+ const currencyPeriodMismatch = hasCurrency && !planStageVisible && !!selectedPlan && !planOffersCurrencyForPeriod(selectedPlan, planPeriod, effectiveCurrency);
22518
23311
  useEffect3(() => {
22519
23312
  if (currencyPeriodMismatch) {
22520
23313
  console.error(
@@ -22566,7 +23359,6 @@ var CheckoutDialog = ({ top }) => {
22566
23359
  if (isBypassLoading) {
22567
23360
  setIsBypassLoading(false);
22568
23361
  }
22569
- setSelectedPlanId(null);
22570
23362
  return;
22571
23363
  }
22572
23364
  const requestId = ++previewRequestIdRef.current;
@@ -22805,7 +23597,8 @@ var CheckoutDialog = ({ top }) => {
22805
23597
  }
22806
23598
  const updatedShouldTrial = updates.shouldTrial ?? shouldTrial;
22807
23599
  setShouldTrial(updatedShouldTrial);
22808
- if (willTrialWithoutPaymentMethod) {
23600
+ const updatedWillTrialWithoutPaymentMethod = updatedShouldTrial && !trialPaymentMethodRequired;
23601
+ if (updatedWillTrialWithoutPaymentMethod) {
22809
23602
  setSelectedAddOnIds(/* @__PURE__ */ new Set());
22810
23603
  }
22811
23604
  const resolvedCreditBundles = (data?.creditBundles ?? []).map(
@@ -22818,14 +23611,10 @@ var CheckoutDialog = ({ top }) => {
22818
23611
  period,
22819
23612
  plan,
22820
23613
  shouldTrial: updatedShouldTrial,
22821
- ...willTrialWithoutPaymentMethod ? {
22822
- addOns: [],
22823
- payInAdvanceEntitlements: []
22824
- } : {
22825
- payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
22826
- ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
22827
- )
22828
- },
23614
+ ...updatedWillTrialWithoutPaymentMethod && { addOns: [] },
23615
+ payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
23616
+ ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
23617
+ ),
22829
23618
  creditBundles: resolvedCreditBundles
22830
23619
  });
22831
23620
  },
@@ -22837,7 +23626,7 @@ var CheckoutDialog = ({ top }) => {
22837
23626
  featureUsage,
22838
23627
  bundleCounts,
22839
23628
  shouldTrial,
22840
- willTrialWithoutPaymentMethod,
23629
+ trialPaymentMethodRequired,
22841
23630
  handlePreviewCheckout,
22842
23631
  checkoutState?.payInAdvanceQuantities
22843
23632
  ]
@@ -22848,40 +23637,42 @@ var CheckoutDialog = ({ top }) => {
22848
23637
  return;
22849
23638
  }
22850
23639
  setPlanPeriod(period);
22851
- const updatedUsageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
22852
- createActiveUsageBasedEntitlementsReducer(featureUsage, period),
22853
- [...[]]
22854
- );
22855
- setUsageBasedEntitlements(
22856
- (prev2) => updatedUsageBasedEntitlements.map((updated) => {
22857
- const current = prev2.find(
22858
- ({ featureId }) => featureId === updated.featureId
22859
- );
22860
- if (typeof current?.quantity === "number") {
22861
- return { ...updated, quantity: current.quantity };
22862
- }
22863
- return updated;
22864
- })
23640
+ const plan = findSelectedPlan(
23641
+ plansForPeriod(period).filter(supportsCheckoutCurrency)
22865
23642
  );
23643
+ const updatedUsageBasedEntitlements = plan ? (plan.entitlements || []).reduce(
23644
+ createActiveUsageBasedEntitlementsReducer(featureUsage, period),
23645
+ []
23646
+ ).map((updated) => {
23647
+ const current = usageBasedEntitlements.find(
23648
+ ({ featureId }) => featureId === updated.featureId
23649
+ );
23650
+ if (typeof current?.quantity === "number") {
23651
+ return { ...updated, quantity: current.quantity };
23652
+ }
23653
+ return updated;
23654
+ }) : usageBasedEntitlements;
23655
+ if (plan) {
23656
+ setUsageBasedEntitlements(updatedUsageBasedEntitlements);
23657
+ }
22866
23658
  const updatedAddOnUsageBasedEntitlements = addOns.filter((addOn) => addOn.isSelected).flatMap(
22867
23659
  (addOn) => (addOn.entitlements ?? []).reduce(
22868
23660
  createActiveUsageBasedEntitlementsReducer(featureUsage, period),
22869
23661
  []
22870
23662
  )
22871
- );
22872
- setAddOnUsageBasedEntitlements(
22873
- (prev2) => updatedAddOnUsageBasedEntitlements.map((updated) => {
22874
- const current = prev2.find(
22875
- ({ featureId }) => featureId === updated.featureId
22876
- );
22877
- if (typeof current?.quantity === "number") {
22878
- return { ...updated, quantity: current.quantity };
22879
- }
22880
- return updated;
22881
- })
22882
- );
23663
+ ).map((updated) => {
23664
+ const current = addOnUsageBasedEntitlements.find(
23665
+ ({ featureId }) => featureId === updated.featureId
23666
+ );
23667
+ if (typeof current?.quantity === "number") {
23668
+ return { ...updated, quantity: current.quantity };
23669
+ }
23670
+ return updated;
23671
+ });
23672
+ setAddOnUsageBasedEntitlements(updatedAddOnUsageBasedEntitlements);
22883
23673
  handlePreviewCheckout({
22884
23674
  period,
23675
+ plan,
22885
23676
  payInAdvanceEntitlements: updatedUsageBasedEntitlements.filter(
22886
23677
  ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
22887
23678
  ),
@@ -22892,9 +23683,13 @@ var CheckoutDialog = ({ top }) => {
22892
23683
  },
22893
23684
  [
22894
23685
  planPeriod,
22895
- selectedPlan?.entitlements,
23686
+ plansForPeriod,
23687
+ findSelectedPlan,
23688
+ supportsCheckoutCurrency,
22896
23689
  featureUsage,
23690
+ usageBasedEntitlements,
22897
23691
  addOns,
23692
+ addOnUsageBasedEntitlements,
22898
23693
  setPlanPeriod,
22899
23694
  handlePreviewCheckout
22900
23695
  ]
@@ -23038,12 +23833,12 @@ var CheckoutDialog = ({ top }) => {
23038
23833
  }, [setLayout, clearCheckoutState]);
23039
23834
  const hasInitializedPlan = useRef6(false);
23040
23835
  useEffect3(() => {
23041
- if (!hasInitializedPlan.current && selectedPlan) {
23836
+ if (!hasInitializedPlan.current && selectedPlan && selectedPlanId === void 0) {
23042
23837
  hasInitializedPlan.current = true;
23043
- const shouldTrial2 = checkoutState?.startTrialIfAvailable && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
23838
+ const shouldTrial2 = checkoutState?.startTrialIfAvailable && !(isTrialing && selectedPlan.current) && selectedPlan.isTrialable && selectedPlan.companyCanTrial;
23044
23839
  selectPlan({ plan: selectedPlan, period: planPeriod, shouldTrial: shouldTrial2 });
23045
23840
  }
23046
- }, [selectedPlan, planPeriod, selectPlan]);
23841
+ }, [selectedPlan, selectedPlanId, planPeriod, selectPlan]);
23047
23842
  useLayoutEffect4(() => {
23048
23843
  const element = dialogRef.current;
23049
23844
  if (layout !== "checkout" || !element) {
@@ -23291,6 +24086,7 @@ var CheckoutDialog = ({ top }) => {
23291
24086
  options: availablePeriods,
23292
24087
  selectedOption: planPeriod,
23293
24088
  selectedPlan,
24089
+ currency: hasCurrency ? effectiveCurrency : void 0,
23294
24090
  onSelect: changePlanPeriod
23295
24091
  }
23296
24092
  )
@@ -24102,6 +24898,7 @@ var PeriodToggle = ({
24102
24898
  options,
24103
24899
  selectedOption,
24104
24900
  selectedPlan,
24901
+ currency,
24105
24902
  onSelect
24106
24903
  }) => {
24107
24904
  const { t: t3 } = useTranslation();
@@ -24112,19 +24909,19 @@ var PeriodToggle = ({
24112
24909
  if (!selectedPlan) {
24113
24910
  return result;
24114
24911
  }
24115
- const monthlyPrice = getPlanPrice(selectedPlan, "month")?.price ?? 0;
24912
+ const monthlyPrice = getPlanPrice(selectedPlan, "month", void 0, currency)?.price ?? 0;
24116
24913
  if (monthlyPrice <= 0) {
24117
24914
  return result;
24118
24915
  }
24119
24916
  for (const [period, months] of Object.entries(PERIOD_MONTH_COUNT)) {
24120
- const periodPrice = getPlanPrice(selectedPlan, period)?.price ?? 0;
24917
+ const periodPrice = getPlanPrice(selectedPlan, period, void 0, currency)?.price ?? 0;
24121
24918
  if (periodPrice > 0) {
24122
24919
  const baseline = monthlyPrice * months;
24123
24920
  result[period] = Math.round((baseline - periodPrice) / baseline * 1e4) / 100;
24124
24921
  }
24125
24922
  }
24126
24923
  return result;
24127
- }, [selectedPlan]);
24924
+ }, [selectedPlan, currency]);
24128
24925
  return /* @__PURE__ */ jsx37(
24129
24926
  Flex,
24130
24927
  {
@@ -24519,10 +25316,12 @@ var CheckoutStageButton = ({
24519
25316
  willScheduleDowngrade,
24520
25317
  hasIncompleteRequiredCustomFields = false,
24521
25318
  isCreditOnlyPurchase = false,
24522
- isOneTimeOnlyPurchase = false
25319
+ isOneTimeOnlyPurchase = false,
25320
+ isUnchangedTrial = false
24523
25321
  }) => {
24524
25322
  const { t: t3 } = useTranslation();
24525
25323
  const isDisabled = isLoading || !hasPlan && !isCreditOnlyPurchase || inEditMode || !canCheckout;
25324
+ const isCheckoutDisabled = isDisabled || isUnchangedTrial;
24526
25325
  const optInUnmet = optInRequired && !optInAccepted;
24527
25326
  const getNextStageId = (currentStageId) => {
24528
25327
  if (!checkoutStages) return void 0;
@@ -24584,7 +25383,7 @@ var CheckoutStageButton = ({
24584
25383
  return /* @__PURE__ */ jsx42(
24585
25384
  NoPaymentRequired,
24586
25385
  {
24587
- isDisabled,
25386
+ isDisabled: isCheckoutDisabled,
24588
25387
  isLoading,
24589
25388
  onClick: checkout,
24590
25389
  isSticky,
@@ -24619,7 +25418,7 @@ var CheckoutStageButton = ({
24619
25418
  return /* @__PURE__ */ jsx42(
24620
25419
  NoPaymentRequired,
24621
25420
  {
24622
- isDisabled,
25421
+ isDisabled: isCheckoutDisabled,
24623
25422
  isLoading,
24624
25423
  onClick: checkout,
24625
25424
  isSticky,
@@ -24663,7 +25462,7 @@ var CheckoutStageButton = ({
24663
25462
  return /* @__PURE__ */ jsx42(
24664
25463
  NoPaymentRequired,
24665
25464
  {
24666
- isDisabled,
25465
+ isDisabled: isCheckoutDisabled,
24667
25466
  isLoading,
24668
25467
  onClick: checkout,
24669
25468
  isSticky,
@@ -24707,7 +25506,7 @@ var CheckoutStageButton = ({
24707
25506
  return /* @__PURE__ */ jsx42(
24708
25507
  NoPaymentRequired,
24709
25508
  {
24710
- isDisabled,
25509
+ isDisabled: isCheckoutDisabled,
24711
25510
  isLoading,
24712
25511
  onClick: checkout,
24713
25512
  isSticky,
@@ -24750,7 +25549,7 @@ var CheckoutStageButton = ({
24750
25549
  return /* @__PURE__ */ jsx42(
24751
25550
  NoPaymentRequired,
24752
25551
  {
24753
- isDisabled,
25552
+ isDisabled: isCheckoutDisabled,
24754
25553
  isLoading,
24755
25554
  onClick: checkout,
24756
25555
  isSticky,
@@ -24794,7 +25593,7 @@ var CheckoutStageButton = ({
24794
25593
  return /* @__PURE__ */ jsx42(
24795
25594
  NoPaymentRequired,
24796
25595
  {
24797
- isDisabled,
25596
+ isDisabled: isCheckoutDisabled,
24798
25597
  isLoading,
24799
25598
  onClick: checkout,
24800
25599
  isSticky,
@@ -24838,7 +25637,7 @@ var CheckoutStageButton = ({
24838
25637
  /* @__PURE__ */ jsx42(
24839
25638
  NoPaymentRequired,
24840
25639
  {
24841
- isDisabled: isDisabled || hasIncompleteRequiredCustomFields || optInUnmet,
25640
+ isDisabled: isCheckoutDisabled || hasIncompleteRequiredCustomFields || optInUnmet,
24842
25641
  isLoading,
24843
25642
  onClick: checkout,
24844
25643
  isSticky,
@@ -24854,7 +25653,7 @@ var CheckoutStageButton = ({
24854
25653
  Button,
24855
25654
  {
24856
25655
  type: "button",
24857
- disabled: isDisabled || !hasPaymentMethod || hasIncompleteRequiredCustomFields || optInUnmet,
25656
+ disabled: isCheckoutDisabled || !hasPaymentMethod || hasIncompleteRequiredCustomFields || optInUnmet,
24858
25657
  onClick: checkout,
24859
25658
  $fullWidth: true,
24860
25659
  $isLoading: isLoading,
@@ -25336,9 +26135,9 @@ var SubscriptionSidebar = forwardRef7(
25336
26135
  ]);
25337
26136
  const selectedAddOnsWithPrice = useMemo22(
25338
26137
  () => addOns.filter(
25339
- (addOn) => addOn.isSelected && getPlanPrice(addOn, void 0, void 0, currency)?.price
26138
+ (addOn) => addOn.isSelected && getPlanPrice(addOn, planPeriod, void 0, currency)?.price
25340
26139
  ),
25341
- [addOns, currency]
26140
+ [addOns, planPeriod, currency]
25342
26141
  );
25343
26142
  const selectedOneTimeAddOns = useMemo22(
25344
26143
  () => addOns.filter(
@@ -25348,7 +26147,7 @@ var SubscriptionSidebar = forwardRef7(
25348
26147
  );
25349
26148
  const { removedAddOns, willAddOnsChange } = useMemo22(() => {
25350
26149
  const addedAddOns = selectedAddOnsWithPrice.filter(
25351
- (selected) => getPlanPrice(selected, void 0, void 0, currency)?.price && !currentAddOns.some((current) => selected.id === current.id)
26150
+ (selected) => !currentAddOns.some((current) => selected.id === current.id)
25352
26151
  );
25353
26152
  const removedAddOns2 = currentAddOns.filter(
25354
26153
  (current) => current.planPrice && current.planPeriod !== "one-time" && !selectedAddOnsWithPrice.some(
@@ -25361,7 +26160,7 @@ var SubscriptionSidebar = forwardRef7(
25361
26160
  removedAddOns: removedAddOns2,
25362
26161
  willAddOnsChange: willAddOnsChange2
25363
26162
  };
25364
- }, [currentAddOns, selectedAddOnsWithPrice, currency]);
26163
+ }, [currentAddOns, selectedAddOnsWithPrice]);
25365
26164
  const addedCreditBundles = useMemo22(
25366
26165
  () => creditBundles.filter((bundle) => bundle.count > 0),
25367
26166
  [creditBundles]
@@ -25387,6 +26186,24 @@ var SubscriptionSidebar = forwardRef7(
25387
26186
  selectedOneTimeAddOns.length,
25388
26187
  addedCreditBundles.length
25389
26188
  ]);
26189
+ const isUnchangedTrial = useMemo22(() => {
26190
+ if (billingSubscription?.status !== "trialing" || !selectedPlan?.current) {
26191
+ return false;
26192
+ }
26193
+ const currentPeriod = getSubscriptionPeriod(billingSubscription);
26194
+ if (currentPeriod && currentPeriod !== planPeriod) {
26195
+ return false;
26196
+ }
26197
+ return !willAddOnsChange && updatedUsageBasedEntitlements.changed.length === 0 && selectedOneTimeAddOns.length === 0 && addedCreditBundles.length === 0;
26198
+ }, [
26199
+ selectedPlan,
26200
+ billingSubscription,
26201
+ planPeriod,
26202
+ willAddOnsChange,
26203
+ updatedUsageBasedEntitlements.changed.length,
26204
+ selectedOneTimeAddOns.length,
26205
+ addedCreditBundles.length
26206
+ ]);
25390
26207
  const discountApplied = useMemo22(
25391
26208
  () => promoCode && (amountOff > 0 || percentOff > 0),
25392
26209
  [promoCode, amountOff, percentOff]
@@ -25580,6 +26397,7 @@ var SubscriptionSidebar = forwardRef7(
25580
26397
  hasIncompleteRequiredCustomFields,
25581
26398
  isCreditOnlyPurchase,
25582
26399
  isOneTimeOnlyPurchase,
26400
+ isUnchangedTrial,
25583
26401
  checkout: handleCheckout
25584
26402
  }
25585
26403
  );
@@ -25625,6 +26443,7 @@ var SubscriptionSidebar = forwardRef7(
25625
26443
  addOnPayInAdvanceEntitlements,
25626
26444
  isCreditOnlyPurchase,
25627
26445
  isOneTimeOnlyPurchase,
26446
+ isUnchangedTrial,
25628
26447
  hasIncompleteRequiredCustomFields
25629
26448
  ]);
25630
26449
  useLayoutEffect6(() => {
@@ -25659,7 +26478,10 @@ var SubscriptionSidebar = forwardRef7(
25659
26478
  subscriptionPrice,
25660
26479
  planPeriod,
25661
26480
  periodStart: renewDate,
25662
- hasUsageBasedCosts: usageBasedEntitlements.length > 0,
26481
+ hasUsageBasedCosts: hasMeteredCosts([
26482
+ ...usageBasedEntitlements,
26483
+ ...addOnUsageBasedEntitlements
26484
+ ]),
25663
26485
  discount: subscriptionDiscount,
25664
26486
  locale
25665
26487
  },
@@ -25671,6 +26493,14 @@ var SubscriptionSidebar = forwardRef7(
25671
26493
  locale
25672
26494
  })
25673
26495
  }) : billingPreviewText;
26496
+ const currentPriceInterval = getSubscriptionInterval(
26497
+ billingSubscription
26498
+ ) ?? { interval: currentPlan?.planPeriod || planPeriod };
26499
+ const currentPriceSuffix = shortenPeriod(
26500
+ currentPriceInterval.interval,
26501
+ t3,
26502
+ currentPriceInterval.intervalCount
26503
+ );
25674
26504
  return /* @__PURE__ */ jsxs32(
25675
26505
  Flex,
25676
26506
  {
@@ -25739,10 +26569,7 @@ var SubscriptionSidebar = forwardRef7(
25739
26569
  }),
25740
26570
  /* @__PURE__ */ jsxs32("sub", { children: [
25741
26571
  "/",
25742
- shortenPeriod(
25743
- getSubscriptionPeriod(billingSubscription) || currentPlan.planPeriod || planPeriod,
25744
- t3
25745
- )
26572
+ currentPriceSuffix
25746
26573
  ] })
25747
26574
  ] }) })
25748
26575
  ]
@@ -25952,7 +26779,7 @@ var SubscriptionSidebar = forwardRef7(
25952
26779
  }),
25953
26780
  addOn.planPeriod !== "one-time" && /* @__PURE__ */ jsxs32("sub", { children: [
25954
26781
  "/",
25955
- shortenPeriod(planPeriod, t3)
26782
+ currentPriceSuffix
25956
26783
  ] })
25957
26784
  ] }) })
25958
26785
  ]
@@ -27266,12 +28093,13 @@ function formatInvoices(invoices, locale, options) {
27266
28093
  const dateA = a2.dueDate ?? a2.createdAt;
27267
28094
  const dateB = b2.dueDate ?? b2.createdAt;
27268
28095
  return +dateB - +dateA;
27269
- }).map(({ amountDue, dueDate, createdAt, url, currency }) => {
28096
+ }).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
27270
28097
  const formatted = formatCurrency(Math.abs(amountDue), {
27271
28098
  locale,
27272
28099
  currency
27273
28100
  });
27274
28101
  return {
28102
+ id,
27275
28103
  amount: amountDue < 0 ? `(${formatted})` : formatted,
27276
28104
  amountDue,
27277
28105
  date: toPrettyDate(dueDate ?? createdAt, { locale }),
@@ -27282,7 +28110,7 @@ function formatInvoices(invoices, locale, options) {
27282
28110
  var Invoices = forwardRef11(({ className, ...rest }, ref) => {
27283
28111
  const props = resolveDesignProps3(rest);
27284
28112
  const { t: t3, locale } = useTranslation();
27285
- const { data, listInvoices, settings } = useEmbed();
28113
+ const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
27286
28114
  const [isLoading, setIsLoading] = useState16(false);
27287
28115
  const [error, setError] = useState16();
27288
28116
  const [rawInvoices, setInvoices] = useState16(
@@ -27359,7 +28187,7 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
27359
28187
  props.header.isVisible && /* @__PURE__ */ jsx54(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ jsx54(Text, { display: props.header.fontStyle, children: t3("Invoices") }) }),
27360
28188
  invoices.length > 0 ? /* @__PURE__ */ jsxs39(Fragment20, { children: [
27361
28189
  /* @__PURE__ */ jsx54(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
27362
- ({ date, amount, amountDue, url }, index) => {
28190
+ ({ id, date, amount, amountDue, url }, index) => {
27363
28191
  return /* @__PURE__ */ jsxs39(
27364
28192
  Flex,
27365
28193
  {
@@ -27370,11 +28198,18 @@ var Invoices = forwardRef11(({ className, ...rest }, ref) => {
27370
28198
  Text,
27371
28199
  {
27372
28200
  display: props.date.fontStyle,
27373
- ...url && {
28201
+ ...id && url && {
27374
28202
  as: "a",
27375
28203
  href: url,
27376
28204
  target: "_blank",
27377
- rel: "noreferrer"
28205
+ rel: "noreferrer",
28206
+ onClick: (event) => {
28207
+ void openInvoiceLink(
28208
+ event,
28209
+ url,
28210
+ async () => (await getInvoiceLink(id))?.data.url
28211
+ );
28212
+ }
27378
28213
  },
27379
28214
  $color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
27380
28215
  children: date
@@ -29109,9 +29944,14 @@ import { forwardRef as forwardRef14, useMemo as useMemo34 } from "react";
29109
29944
 
29110
29945
  // src/components/elements/plan-manager/AddOn.tsx
29111
29946
  import { jsx as jsx62, jsxs as jsxs45 } from "react/jsx-runtime";
29112
- var AddOn = ({ addOn, currency, period, layout }) => {
29947
+ var AddOn = ({
29948
+ addOn,
29949
+ currency,
29950
+ priceInterval,
29951
+ layout
29952
+ }) => {
29113
29953
  const { t: t3, locale } = useTranslation();
29114
- const resolvedPeriod = addOn.planPeriod === "one-time" ? addOn.planPeriod : period ?? addOn.planPeriod;
29954
+ const resolvedInterval = addOn.planPeriod === "one-time" ? { interval: addOn.planPeriod } : priceInterval ?? (addOn.planPeriod ? { interval: addOn.planPeriod } : void 0);
29115
29955
  return /* @__PURE__ */ jsxs45(
29116
29956
  Flex,
29117
29957
  {
@@ -29121,9 +29961,13 @@ var AddOn = ({ addOn, currency, period, layout }) => {
29121
29961
  $gap: "1rem",
29122
29962
  children: [
29123
29963
  /* @__PURE__ */ jsx62(Text, { display: layout.addOns.fontStyle, children: addOn.name }),
29124
- typeof addOn.planPrice === "number" && resolvedPeriod && /* @__PURE__ */ jsxs45(Text, { children: [
29964
+ typeof addOn.planPrice === "number" && resolvedInterval && /* @__PURE__ */ jsxs45(Text, { children: [
29125
29965
  formatCurrency(addOn.planPrice, { locale, currency }),
29126
- /* @__PURE__ */ jsx62("sub", { children: resolvedPeriod === "one-time" ? shortenPeriod(resolvedPeriod, t3) : `/${shortenPeriod(resolvedPeriod, t3)}` })
29966
+ /* @__PURE__ */ jsx62("sub", { children: resolvedInterval.interval === "one-time" ? shortenPeriod(resolvedInterval.interval, t3) : `/${shortenPeriod(
29967
+ resolvedInterval.interval,
29968
+ t3,
29969
+ resolvedInterval.intervalCount
29970
+ )}` })
29127
29971
  ] })
29128
29972
  ]
29129
29973
  }
@@ -29424,7 +30268,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29424
30268
  willSubscriptionCancel,
29425
30269
  isTrialSubscription
29426
30270
  } = useMemo34(() => {
29427
- const subscriptionInterval2 = getSubscriptionPeriod(billingSubscription) ?? billingSubscription?.interval;
30271
+ const subscriptionInterval2 = getSubscriptionInterval(billingSubscription);
29428
30272
  const subscriptionCurrency2 = billingSubscription?.currency;
29429
30273
  const isTrialSubscription2 = billingSubscription?.status === "trialing";
29430
30274
  const willSubscriptionCancel2 = typeof billingSubscription?.cancelAt === "number" && billingSubscription?.cancelAtPeriodEnd === true;
@@ -29436,6 +30280,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29436
30280
  };
29437
30281
  }, [billingSubscription]);
29438
30282
  const currentPlanPeriod = getSubscriptionPeriod(billingSubscription) ?? currentPlan?.planPeriod ?? void 0;
30283
+ const currentPriceInterval = subscriptionInterval ?? (currentPlanPeriod ? { interval: currentPlanPeriod } : void 0);
29439
30284
  const { isFreePlan, isUsageBasedPlan } = useMemo34(() => {
29440
30285
  const isFreePlan2 = currentPlan?.planPrice === 0;
29441
30286
  const isUsageBasedPlan2 = isFreePlan2 && usageBasedEntitlements.length > 0;
@@ -29594,9 +30439,13 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29594
30439
  })
29595
30440
  }
29596
30441
  ),
29597
- !isFreePlan && currentPlanPeriod && /* @__PURE__ */ jsx64(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ jsxs47("sub", { children: [
30442
+ !isFreePlan && currentPriceInterval && /* @__PURE__ */ jsx64(Text, { display: props.header.price.fontStyle, children: /* @__PURE__ */ jsxs47("sub", { children: [
29598
30443
  "/",
29599
- shortenPeriod(currentPlanPeriod, t3)
30444
+ shortenPeriod(
30445
+ currentPriceInterval.interval,
30446
+ t3,
30447
+ currentPriceInterval.intervalCount
30448
+ )
29600
30449
  ] }) })
29601
30450
  ] })
29602
30451
  ]
@@ -29616,7 +30465,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29616
30465
  {
29617
30466
  addOn,
29618
30467
  currency: subscriptionCurrency,
29619
- period: currentPlanPeriod,
30468
+ priceInterval: currentPriceInterval,
29620
30469
  layout: props
29621
30470
  },
29622
30471
  addOnIndex
@@ -29675,7 +30524,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29675
30524
  resolveLicenseQuantity
29676
30525
  );
29677
30526
  const licenseQuantity = perLicenseGrant?.licenseId ? resolveLicenseQuantity(perLicenseGrant.licenseId) : void 0;
29678
- const creditPeriod = composition.period ?? subscriptionInterval;
30527
+ const creditInterval = composition.period ? { interval: composition.period } : subscriptionInterval;
29679
30528
  const showPerLicense = !!perLicenseGrant && !!licenseFeature;
29680
30529
  return /* @__PURE__ */ jsxs47(
29681
30530
  Flex,
@@ -29705,7 +30554,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29705
30554
  1
29706
30555
  )
29707
30556
  }),
29708
- composition.fixedQuantity > 0 && creditPeriod && /* @__PURE__ */ jsxs47(Fragment25, { children: [
30557
+ composition.fixedQuantity > 0 && creditInterval && /* @__PURE__ */ jsxs47(Fragment25, { children: [
29709
30558
  " ",
29710
30559
  t3("Plus X credits per period", {
29711
30560
  amount: composition.fixedQuantity,
@@ -29714,8 +30563,10 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29714
30563
  locale,
29715
30564
  composition.fixedQuantity
29716
30565
  ),
29717
- period: t3(
29718
- creditPeriod
30566
+ period: nameInterval(
30567
+ creditInterval.interval,
30568
+ t3,
30569
+ creditInterval.intervalCount
29719
30570
  )
29720
30571
  })
29721
30572
  ] })
@@ -29724,11 +30575,13 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29724
30575
  " ",
29725
30576
  getFeatureName(group, locale, group.total.value),
29726
30577
  " ",
29727
- subscriptionInterval && /* @__PURE__ */ jsxs47(Fragment25, { children: [
30578
+ creditInterval && /* @__PURE__ */ jsxs47(Fragment25, { children: [
29728
30579
  t3("per"),
29729
30580
  " ",
29730
- t3(
29731
- subscriptionInterval
30581
+ nameInterval(
30582
+ creditInterval.interval,
30583
+ t3,
30584
+ creditInterval.intervalCount
29732
30585
  )
29733
30586
  ] })
29734
30587
  ] }) }),
@@ -29755,7 +30608,7 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29755
30608
  ]
29756
30609
  }
29757
30610
  ),
29758
- showPerLicense && typeof licenseQuantity === "number" && typeof resolvedTotal === "number" && creditPeriod && /* @__PURE__ */ jsx64(
30611
+ showPerLicense && typeof licenseQuantity === "number" && typeof resolvedTotal === "number" && creditInterval && /* @__PURE__ */ jsx64(
29759
30612
  Text,
29760
30613
  {
29761
30614
  style: { opacity: 0.54 },
@@ -29776,7 +30629,11 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29776
30629
  locale,
29777
30630
  resolvedTotal
29778
30631
  ),
29779
- period: shortenPeriod(creditPeriod, t3)
30632
+ period: shortenPeriod(
30633
+ creditInterval.interval,
30634
+ t3,
30635
+ creditInterval.intervalCount
30636
+ )
29780
30637
  }) : t3("X licenses times Y credits", {
29781
30638
  quantity: licenseQuantity,
29782
30639
  licenseName: getFeatureName(
@@ -29791,7 +30648,11 @@ var PlanManager = forwardRef14(({ children, className, portal, ...rest }, ref) =
29791
30648
  locale,
29792
30649
  resolvedTotal
29793
30650
  ),
29794
- period: shortenPeriod(creditPeriod, t3)
30651
+ period: shortenPeriod(
30652
+ creditInterval.interval,
30653
+ t3,
30654
+ creditInterval.intervalCount
30655
+ )
29795
30656
  })
29796
30657
  }
29797
30658
  )
@@ -31014,16 +31875,18 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
31014
31875
  () => getSubscriptionPeriod(data?.company?.billingSubscription) || data?.company?.plan?.planPeriod || getDefaultPlanPeriod(data?.activePlans)
31015
31876
  );
31016
31877
  const { currencies, invalidFilterEntries } = useAvailableCurrenciesWithInvalid();
31017
- const [selectedCurrency, setSelectedCurrency] = useState21(
31878
+ const [chosenCurrency, setSelectedCurrency] = useState21(
31018
31879
  () => currencies[0] ?? DEFAULT_CURRENCY
31019
31880
  );
31020
- if (currencies.length > 0 && !currencies.includes(selectedCurrency)) {
31881
+ if (currencies.length > 0 && !currencies.includes(chosenCurrency)) {
31021
31882
  setSelectedCurrency(currencies[0]);
31022
31883
  }
31884
+ const lockedCurrency = useSubscriptionCurrency();
31885
+ const selectedCurrency = lockedCurrency ?? chosenCurrency;
31023
31886
  const showPeriodToggle = rest.showPeriodToggle ?? data?.displaySettings?.showPeriodToggle ?? true;
31024
31887
  const hasCurrencyFilter = !!currencyFilter && currencyFilter.length > 0;
31025
- const showCurrencySelector = currencies.length > 1;
31026
- const hasCurrency = currencies.length > 1 || hasCurrencyFilter;
31888
+ const showCurrencySelector = currencies.length > 1 && !lockedCurrency;
31889
+ const hasCurrency = !!lockedCurrency || currencies.length > 1 || hasCurrencyFilter;
31027
31890
  const hasNoUsableCurrency = currencies.length === 0;
31028
31891
  const {
31029
31892
  plans: allPlans,
@@ -31122,6 +31985,7 @@ var PricingTable = forwardRef15(({ className, ...rest }, ref) => {
31122
31985
  options: periods,
31123
31986
  selectedOption: selectedPeriod,
31124
31987
  selectedPlan: currentPlan,
31988
+ currency: hasCurrency ? selectedCurrency : void 0,
31125
31989
  onSelect: (period) => {
31126
31990
  if (period !== selectedPeriod) {
31127
31991
  setSelectedPeriod(period);