@schematichq/schematic-components 2.37.0 → 2.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3814,6 +3814,7 @@ var initialContext = {
3814
3814
  getUpcomingInvoice: stub,
3815
3815
  getCustomerBalance: stub,
3816
3816
  listInvoices: stub,
3817
+ getInvoiceLink: stub,
3817
3818
  getCreditUsageByUser: stub,
3818
3819
  getFeatureUsageByUser: stub,
3819
3820
  createSetupIntent: stub,
@@ -8644,6 +8645,84 @@ function CreateCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
8644
8645
  };
8645
8646
  }
8646
8647
 
8648
+ // src/api/checkoutexternal/models/CreditSpendWindowUnit.ts
8649
+ function CreditSpendWindowUnitFromJSON(json) {
8650
+ return CreditSpendWindowUnitFromJSONTyped(json, false);
8651
+ }
8652
+ function CreditSpendWindowUnitFromJSONTyped(json, ignoreDiscriminator) {
8653
+ return json;
8654
+ }
8655
+ function CreditSpendWindowUnitToJSON(value) {
8656
+ return value;
8657
+ }
8658
+
8659
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyRequestBody.ts
8660
+ function CreateCompanySpendPolicyRequestBodyToJSON(json) {
8661
+ return CreateCompanySpendPolicyRequestBodyToJSONTyped(json, false);
8662
+ }
8663
+ function CreateCompanySpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
8664
+ if (value == null) {
8665
+ return value;
8666
+ }
8667
+ return {
8668
+ billing_credit_id: value["billingCreditId"],
8669
+ label: value["label"],
8670
+ max_per_draw: value["maxPerDraw"],
8671
+ user_id: value["userId"],
8672
+ window_amount: value["windowAmount"],
8673
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
8674
+ };
8675
+ }
8676
+
8677
+ // src/api/checkoutexternal/models/CreditSpendPolicyScope.ts
8678
+ function CreditSpendPolicyScopeFromJSON(json) {
8679
+ return CreditSpendPolicyScopeFromJSONTyped(json, false);
8680
+ }
8681
+ function CreditSpendPolicyScopeFromJSONTyped(json, ignoreDiscriminator) {
8682
+ return json;
8683
+ }
8684
+
8685
+ // src/api/checkoutexternal/models/CreditSpendPolicyResponseData.ts
8686
+ function CreditSpendPolicyResponseDataFromJSON(json) {
8687
+ return CreditSpendPolicyResponseDataFromJSONTyped(json, false);
8688
+ }
8689
+ function CreditSpendPolicyResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8690
+ if (json == null) {
8691
+ return json;
8692
+ }
8693
+ return {
8694
+ billingCreditId: json["billing_credit_id"],
8695
+ companyId: json["company_id"] == null ? void 0 : json["company_id"],
8696
+ consumed: json["consumed"] == null ? void 0 : json["consumed"],
8697
+ createdAt: new Date(json["created_at"]),
8698
+ headroom: json["headroom"] == null ? void 0 : json["headroom"],
8699
+ id: json["id"],
8700
+ label: json["label"] == null ? void 0 : json["label"],
8701
+ maxPerDraw: json["max_per_draw"] == null ? void 0 : json["max_per_draw"],
8702
+ resetsAt: json["resets_at"] == null ? void 0 : new Date(json["resets_at"]),
8703
+ scopeType: CreditSpendPolicyScopeFromJSON(json["scope_type"]),
8704
+ updatedAt: new Date(json["updated_at"]),
8705
+ userId: json["user_id"] == null ? void 0 : json["user_id"],
8706
+ windowAmount: json["window_amount"] == null ? void 0 : json["window_amount"],
8707
+ windowCount: json["window_count"],
8708
+ windowUnit: json["window_unit"] == null ? void 0 : CreditSpendWindowUnitFromJSON(json["window_unit"])
8709
+ };
8710
+ }
8711
+
8712
+ // src/api/checkoutexternal/models/CreateCompanySpendPolicyResponse.ts
8713
+ function CreateCompanySpendPolicyResponseFromJSON(json) {
8714
+ return CreateCompanySpendPolicyResponseFromJSONTyped(json, false);
8715
+ }
8716
+ function CreateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8717
+ if (json == null) {
8718
+ return json;
8719
+ }
8720
+ return {
8721
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
8722
+ params: json["params"]
8723
+ };
8724
+ }
8725
+
8647
8726
  // src/api/checkoutexternal/models/SetupIntentResponseData.ts
8648
8727
  function SetupIntentResponseDataFromJSON(json) {
8649
8728
  return SetupIntentResponseDataFromJSONTyped(json, false);
@@ -8732,6 +8811,20 @@ function CreditUserUsageResponseDataFromJSONTyped(json, ignoreDiscriminator) {
8732
8811
  };
8733
8812
  }
8734
8813
 
8814
+ // src/api/checkoutexternal/models/DeleteCompanySpendPolicyResponse.ts
8815
+ function DeleteCompanySpendPolicyResponseFromJSON(json) {
8816
+ return DeleteCompanySpendPolicyResponseFromJSONTyped(json, false);
8817
+ }
8818
+ function DeleteCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
8819
+ if (json == null) {
8820
+ return json;
8821
+ }
8822
+ return {
8823
+ data: DeleteResponseFromJSON(json["data"]),
8824
+ params: json["params"]
8825
+ };
8826
+ }
8827
+
8735
8828
  // src/api/checkoutexternal/models/DeletePaymentMethodResponse.ts
8736
8829
  function DeletePaymentMethodResponseFromJSON(json) {
8737
8830
  return DeletePaymentMethodResponseFromJSONTyped(json, false);
@@ -9106,6 +9199,34 @@ function GetFeatureUsageByUserResponseFromJSONTyped(json, ignoreDiscriminator) {
9106
9199
  };
9107
9200
  }
9108
9201
 
9202
+ // src/api/checkoutexternal/models/InvoiceLink.ts
9203
+ function InvoiceLinkFromJSON(json) {
9204
+ return InvoiceLinkFromJSONTyped(json, false);
9205
+ }
9206
+ function InvoiceLinkFromJSONTyped(json, ignoreDiscriminator) {
9207
+ if (json == null) {
9208
+ return json;
9209
+ }
9210
+ return {
9211
+ id: json["id"],
9212
+ url: json["url"]
9213
+ };
9214
+ }
9215
+
9216
+ // src/api/checkoutexternal/models/GetInvoiceLinkResponse.ts
9217
+ function GetInvoiceLinkResponseFromJSON(json) {
9218
+ return GetInvoiceLinkResponseFromJSONTyped(json, false);
9219
+ }
9220
+ function GetInvoiceLinkResponseFromJSONTyped(json, ignoreDiscriminator) {
9221
+ if (json == null) {
9222
+ return json;
9223
+ }
9224
+ return {
9225
+ data: InvoiceLinkFromJSON(json["data"]),
9226
+ params: json["params"]
9227
+ };
9228
+ }
9229
+
9109
9230
  // src/api/checkoutexternal/models/GetSetupIntentResponse.ts
9110
9231
  function GetSetupIntentResponseFromJSON(json) {
9111
9232
  return GetSetupIntentResponseFromJSONTyped(json, false);
@@ -9219,6 +9340,35 @@ function ListCheckoutsResponseFromJSONTyped(json, ignoreDiscriminator) {
9219
9340
  };
9220
9341
  }
9221
9342
 
9343
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesParams.ts
9344
+ function ListCompanySpendPoliciesParamsFromJSON(json) {
9345
+ return ListCompanySpendPoliciesParamsFromJSONTyped(json, false);
9346
+ }
9347
+ function ListCompanySpendPoliciesParamsFromJSONTyped(json, ignoreDiscriminator) {
9348
+ if (json == null) {
9349
+ return json;
9350
+ }
9351
+ return {
9352
+ billingCreditId: json["billing_credit_id"] == null ? void 0 : json["billing_credit_id"]
9353
+ };
9354
+ }
9355
+
9356
+ // src/api/checkoutexternal/models/ListCompanySpendPoliciesResponse.ts
9357
+ function ListCompanySpendPoliciesResponseFromJSON(json) {
9358
+ return ListCompanySpendPoliciesResponseFromJSONTyped(json, false);
9359
+ }
9360
+ function ListCompanySpendPoliciesResponseFromJSONTyped(json, ignoreDiscriminator) {
9361
+ if (json == null) {
9362
+ return json;
9363
+ }
9364
+ return {
9365
+ data: json["data"].map(
9366
+ CreditSpendPolicyResponseDataFromJSON
9367
+ ),
9368
+ params: ListCompanySpendPoliciesParamsFromJSON(json["params"])
9369
+ };
9370
+ }
9371
+
9222
9372
  // src/api/checkoutexternal/models/ListInvoicesParams.ts
9223
9373
  function ListInvoicesParamsFromJSON(json) {
9224
9374
  return ListInvoicesParamsFromJSONTyped(json, false);
@@ -9549,6 +9699,36 @@ function UpdateCheckoutTaxIDResponseFromJSONTyped(json, ignoreDiscriminator) {
9549
9699
  };
9550
9700
  }
9551
9701
 
9702
+ // src/api/checkoutexternal/models/UpdateCompanySpendPolicyResponse.ts
9703
+ function UpdateCompanySpendPolicyResponseFromJSON(json) {
9704
+ return UpdateCompanySpendPolicyResponseFromJSONTyped(json, false);
9705
+ }
9706
+ function UpdateCompanySpendPolicyResponseFromJSONTyped(json, ignoreDiscriminator) {
9707
+ if (json == null) {
9708
+ return json;
9709
+ }
9710
+ return {
9711
+ data: CreditSpendPolicyResponseDataFromJSON(json["data"]),
9712
+ params: json["params"]
9713
+ };
9714
+ }
9715
+
9716
+ // src/api/checkoutexternal/models/UpdateCreditSpendPolicyRequestBody.ts
9717
+ function UpdateCreditSpendPolicyRequestBodyToJSON(json) {
9718
+ return UpdateCreditSpendPolicyRequestBodyToJSONTyped(json, false);
9719
+ }
9720
+ function UpdateCreditSpendPolicyRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
9721
+ if (value == null) {
9722
+ return value;
9723
+ }
9724
+ return {
9725
+ label: value["label"],
9726
+ max_per_draw: value["maxPerDraw"],
9727
+ window_amount: value["windowAmount"],
9728
+ window_unit: CreditSpendWindowUnitToJSON(value["windowUnit"])
9729
+ };
9730
+ }
9731
+
9552
9732
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
9553
9733
  function UpdatePaymentMethodRequestBodyToJSON(json) {
9554
9734
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -9706,6 +9886,51 @@ var CheckoutexternalApi = class extends BaseAPI {
9706
9886
  );
9707
9887
  return await response.value();
9708
9888
  }
9889
+ /**
9890
+ * Create company spend policy
9891
+ */
9892
+ async createCompanySpendPolicyRaw(requestParameters, initOverrides) {
9893
+ if (requestParameters["createCompanySpendPolicyRequestBody"] == null) {
9894
+ throw new RequiredError(
9895
+ "createCompanySpendPolicyRequestBody",
9896
+ 'Required parameter "createCompanySpendPolicyRequestBody" was null or undefined when calling createCompanySpendPolicy().'
9897
+ );
9898
+ }
9899
+ const queryParameters = {};
9900
+ const headerParameters = {};
9901
+ headerParameters["Content-Type"] = "application/json";
9902
+ if (this.configuration && this.configuration.apiKey) {
9903
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9904
+ "X-Schematic-Api-Key"
9905
+ );
9906
+ }
9907
+ const response = await this.request(
9908
+ {
9909
+ path: `/company/credits/spend-policies`,
9910
+ method: "POST",
9911
+ headers: headerParameters,
9912
+ query: queryParameters,
9913
+ body: CreateCompanySpendPolicyRequestBodyToJSON(
9914
+ requestParameters["createCompanySpendPolicyRequestBody"]
9915
+ )
9916
+ },
9917
+ initOverrides
9918
+ );
9919
+ return new JSONApiResponse(
9920
+ response,
9921
+ (jsonValue) => CreateCompanySpendPolicyResponseFromJSON(jsonValue)
9922
+ );
9923
+ }
9924
+ /**
9925
+ * Create company spend policy
9926
+ */
9927
+ async createCompanySpendPolicy(requestParameters, initOverrides) {
9928
+ const response = await this.createCompanySpendPolicyRaw(
9929
+ requestParameters,
9930
+ initOverrides
9931
+ );
9932
+ return await response.value();
9933
+ }
9709
9934
  /**
9710
9935
  * A Stripe SetupIntent for collecting a new payment method with Stripe\'s Payment Element. Confirm it with `stripe.confirmSetup`; the method it saves joins the company\'s methods on file.
9711
9936
  * Create a setup intent
@@ -9740,6 +9965,50 @@ var CheckoutexternalApi = class extends BaseAPI {
9740
9965
  const response = await this.createSetupIntentRaw(initOverrides);
9741
9966
  return await response.value();
9742
9967
  }
9968
+ /**
9969
+ * Delete company spend policy
9970
+ */
9971
+ async deleteCompanySpendPolicyRaw(requestParameters, initOverrides) {
9972
+ if (requestParameters["spendPolicyId"] == null) {
9973
+ throw new RequiredError(
9974
+ "spendPolicyId",
9975
+ 'Required parameter "spendPolicyId" was null or undefined when calling deleteCompanySpendPolicy().'
9976
+ );
9977
+ }
9978
+ const queryParameters = {};
9979
+ const headerParameters = {};
9980
+ if (this.configuration && this.configuration.apiKey) {
9981
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
9982
+ "X-Schematic-Api-Key"
9983
+ );
9984
+ }
9985
+ const response = await this.request(
9986
+ {
9987
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
9988
+ `{${"spend_policy_id"}}`,
9989
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
9990
+ ),
9991
+ method: "DELETE",
9992
+ headers: headerParameters,
9993
+ query: queryParameters
9994
+ },
9995
+ initOverrides
9996
+ );
9997
+ return new JSONApiResponse(
9998
+ response,
9999
+ (jsonValue) => DeleteCompanySpendPolicyResponseFromJSON(jsonValue)
10000
+ );
10001
+ }
10002
+ /**
10003
+ * Delete company spend policy
10004
+ */
10005
+ async deleteCompanySpendPolicy(requestParameters, initOverrides) {
10006
+ const response = await this.deleteCompanySpendPolicyRaw(
10007
+ requestParameters,
10008
+ initOverrides
10009
+ );
10010
+ return await response.value();
10011
+ }
9743
10012
  /**
9744
10013
  * Detaches a payment method from the company\'s billing customer. The path parameter is the payment method\'s `id` from the list, not a checkout\'s; `usePaymentMethods().remove` calls this and reloads the list. The list says whether each method can be removed.
9745
10014
  * Remove a payment method
@@ -10466,6 +10735,50 @@ var CheckoutexternalApi = class extends BaseAPI {
10466
10735
  );
10467
10736
  return await response.value();
10468
10737
  }
10738
+ /**
10739
+ * Get invoice link
10740
+ */
10741
+ async getInvoiceLinkRaw(requestParameters, initOverrides) {
10742
+ if (requestParameters["billingInvoiceId"] == null) {
10743
+ throw new RequiredError(
10744
+ "billingInvoiceId",
10745
+ 'Required parameter "billingInvoiceId" was null or undefined when calling getInvoiceLink().'
10746
+ );
10747
+ }
10748
+ const queryParameters = {};
10749
+ const headerParameters = {};
10750
+ if (this.configuration && this.configuration.apiKey) {
10751
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
10752
+ "X-Schematic-Api-Key"
10753
+ );
10754
+ }
10755
+ const response = await this.request(
10756
+ {
10757
+ path: `/components/invoices/{billing_invoice_id}/link`.replace(
10758
+ `{${"billing_invoice_id"}}`,
10759
+ encodeURIComponent(String(requestParameters["billingInvoiceId"]))
10760
+ ),
10761
+ method: "GET",
10762
+ headers: headerParameters,
10763
+ query: queryParameters
10764
+ },
10765
+ initOverrides
10766
+ );
10767
+ return new JSONApiResponse(
10768
+ response,
10769
+ (jsonValue) => GetInvoiceLinkResponseFromJSON(jsonValue)
10770
+ );
10771
+ }
10772
+ /**
10773
+ * Get invoice link
10774
+ */
10775
+ async getInvoiceLink(requestParameters, initOverrides) {
10776
+ const response = await this.getInvoiceLinkRaw(
10777
+ requestParameters,
10778
+ initOverrides
10779
+ );
10780
+ return await response.value();
10781
+ }
10469
10782
  /**
10470
10783
  * Get setup intent
10471
10784
  */
@@ -10688,6 +11001,44 @@ var CheckoutexternalApi = class extends BaseAPI {
10688
11001
  );
10689
11002
  return await response.value();
10690
11003
  }
11004
+ /**
11005
+ * List company spend policies
11006
+ */
11007
+ async listCompanySpendPoliciesRaw(requestParameters, initOverrides) {
11008
+ const queryParameters = {};
11009
+ if (requestParameters["billingCreditId"] != null) {
11010
+ queryParameters["billing_credit_id"] = requestParameters["billingCreditId"];
11011
+ }
11012
+ const headerParameters = {};
11013
+ if (this.configuration && this.configuration.apiKey) {
11014
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11015
+ "X-Schematic-Api-Key"
11016
+ );
11017
+ }
11018
+ const response = await this.request(
11019
+ {
11020
+ path: `/company/credits/spend-policies`,
11021
+ method: "GET",
11022
+ headers: headerParameters,
11023
+ query: queryParameters
11024
+ },
11025
+ initOverrides
11026
+ );
11027
+ return new JSONApiResponse(
11028
+ response,
11029
+ (jsonValue) => ListCompanySpendPoliciesResponseFromJSON(jsonValue)
11030
+ );
11031
+ }
11032
+ /**
11033
+ * List company spend policies
11034
+ */
11035
+ async listCompanySpendPolicies(requestParameters = {}, initOverrides) {
11036
+ const response = await this.listCompanySpendPoliciesRaw(
11037
+ requestParameters,
11038
+ initOverrides
11039
+ );
11040
+ return await response.value();
11041
+ }
10691
11042
  /**
10692
11043
  * List invoices
10693
11044
  */
@@ -10922,6 +11273,60 @@ var CheckoutexternalApi = class extends BaseAPI {
10922
11273
  );
10923
11274
  return await response.value();
10924
11275
  }
11276
+ /**
11277
+ * Update company spend policy
11278
+ */
11279
+ async updateCompanySpendPolicyRaw(requestParameters, initOverrides) {
11280
+ if (requestParameters["spendPolicyId"] == null) {
11281
+ throw new RequiredError(
11282
+ "spendPolicyId",
11283
+ 'Required parameter "spendPolicyId" was null or undefined when calling updateCompanySpendPolicy().'
11284
+ );
11285
+ }
11286
+ if (requestParameters["updateCreditSpendPolicyRequestBody"] == null) {
11287
+ throw new RequiredError(
11288
+ "updateCreditSpendPolicyRequestBody",
11289
+ 'Required parameter "updateCreditSpendPolicyRequestBody" was null or undefined when calling updateCompanySpendPolicy().'
11290
+ );
11291
+ }
11292
+ const queryParameters = {};
11293
+ const headerParameters = {};
11294
+ headerParameters["Content-Type"] = "application/json";
11295
+ if (this.configuration && this.configuration.apiKey) {
11296
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11297
+ "X-Schematic-Api-Key"
11298
+ );
11299
+ }
11300
+ const response = await this.request(
11301
+ {
11302
+ path: `/company/credits/spend-policies/{spend_policy_id}`.replace(
11303
+ `{${"spend_policy_id"}}`,
11304
+ encodeURIComponent(String(requestParameters["spendPolicyId"]))
11305
+ ),
11306
+ method: "PUT",
11307
+ headers: headerParameters,
11308
+ query: queryParameters,
11309
+ body: UpdateCreditSpendPolicyRequestBodyToJSON(
11310
+ requestParameters["updateCreditSpendPolicyRequestBody"]
11311
+ )
11312
+ },
11313
+ initOverrides
11314
+ );
11315
+ return new JSONApiResponse(
11316
+ response,
11317
+ (jsonValue) => UpdateCompanySpendPolicyResponseFromJSON(jsonValue)
11318
+ );
11319
+ }
11320
+ /**
11321
+ * Update company spend policy
11322
+ */
11323
+ async updateCompanySpendPolicy(requestParameters, initOverrides) {
11324
+ const response = await this.updateCompanySpendPolicyRaw(
11325
+ requestParameters,
11326
+ initOverrides
11327
+ );
11328
+ return await response.value();
11329
+ }
10925
11330
  /**
10926
11331
  * Makes a method on file the one the company\'s charges use. The body\'s `payment_method_id` is the provider\'s id of the method, the `external_id` the list returns; `usePaymentMethods().setDefault` calls this and reloads the list. A card saved during a checkout joins the methods on file and becomes the default the same way.
10927
11332
  * Make a payment method the default
@@ -12949,7 +13354,7 @@ function resolveLocale(locale) {
12949
13354
  return locale !== void 0 && locale !== "" && isUsableLocale(locale) ? locale : DEFAULT_LOCALE;
12950
13355
  }
12951
13356
 
12952
- // node_modules/.pnpm/i18next@26.7.1_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
13357
+ // node_modules/.pnpm/i18next@27.0.0_typescript@6.0.3/node_modules/i18next/dist/esm/i18next.js
12953
13358
  var isString = (obj) => typeof obj === "string";
12954
13359
  var defer = () => {
12955
13360
  let res;
@@ -13064,12 +13469,11 @@ var _entityMap = {
13064
13469
  "<": "&lt;",
13065
13470
  ">": "&gt;",
13066
13471
  '"': "&quot;",
13067
- "'": "&#39;",
13068
- "/": "&#x2F;"
13472
+ "'": "&#39;"
13069
13473
  };
13070
13474
  var escape = (data) => {
13071
13475
  if (isString(data)) {
13072
- return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
13476
+ return data.replace(/[&<>"']/g, (s) => _entityMap[s]);
13073
13477
  }
13074
13478
  return data;
13075
13479
  };
@@ -13116,6 +13520,9 @@ var deepFind = (obj, path, keySeparator = ".") => {
13116
13520
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
13117
13521
  return obj[path];
13118
13522
  }
13523
+ if (!keySeparator) {
13524
+ return Object.prototype.hasOwnProperty.call(obj, path) ? obj[path] : void 0;
13525
+ }
13119
13526
  const tokens = path.split(keySeparator);
13120
13527
  let current = obj;
13121
13528
  for (let i = 0; i < tokens.length; ) {
@@ -13260,15 +13667,20 @@ var EventEmitter = class {
13260
13667
  }
13261
13668
  };
13262
13669
  var nonEmptyBundles = /* @__PURE__ */ new WeakSet();
13670
+ var assertSeparateArguments = (method, ...args) => {
13671
+ if (args.some((a) => !isString(a))) {
13672
+ 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`);
13673
+ }
13674
+ };
13263
13675
  var ResourceStore = class extends EventEmitter {
13264
13676
  constructor(data, options = {
13265
13677
  ns: ["translation"],
13266
13678
  defaultNS: "translation"
13267
- }) {
13679
+ }, logger = baseLogger) {
13268
13680
  super();
13269
13681
  this.data = data || {};
13270
13682
  this.options = options;
13271
- this.logger = baseLogger.create("resourceStore");
13683
+ this.logger = logger.create("resourceStore");
13272
13684
  if (this.options.keySeparator === void 0) {
13273
13685
  this.options.keySeparator = ".";
13274
13686
  }
@@ -13287,49 +13699,30 @@ var ResourceStore = class extends EventEmitter {
13287
13699
  this.options.ns.splice(index, 1);
13288
13700
  }
13289
13701
  }
13290
- deprecateDottedLng(method) {
13291
- this.logger.once(method, "deprecate", `${method}: a dotted language ('en.translation.key') that carries the namespace and key is removed in v27; pass language, namespace and key as separate arguments`);
13292
- }
13293
13702
  getResource(lng, ns, key, options = {}) {
13294
13703
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
13295
13704
  const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
13296
- let path;
13297
- if (lng.includes(".")) {
13298
- this.deprecateDottedLng("getResource");
13299
- path = lng.split(".");
13300
- } else {
13301
- path = [lng, ns];
13302
- if (key) {
13303
- if (Array.isArray(key)) {
13304
- path.push(...key);
13305
- } else if (isString(key) && keySeparator) {
13306
- path.push(...key.split(keySeparator));
13307
- } else {
13308
- path.push(key);
13309
- }
13705
+ const path = [lng, ns];
13706
+ if (key) {
13707
+ if (Array.isArray(key)) {
13708
+ path.push(...key);
13709
+ } else if (isString(key) && keySeparator) {
13710
+ path.push(...key.split(keySeparator));
13711
+ } else {
13712
+ path.push(key);
13310
13713
  }
13311
13714
  }
13312
13715
  const result = getPath(this.data, path);
13313
- if (result == null && !ns && !key && lng.includes(".")) {
13314
- lng = path[0];
13315
- ns = path[1];
13316
- key = path.slice(2).join(".");
13317
- }
13318
13716
  if (result != null || !ignoreJSONStructure || !isString(key)) return result;
13319
13717
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
13320
13718
  }
13321
13719
  addResource(lng, ns, key, value, options = {
13322
13720
  silent: false
13323
13721
  }) {
13722
+ assertSeparateArguments("addResource", lng, ns, key);
13324
13723
  const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
13325
13724
  let path = [lng, ns];
13326
13725
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
13327
- if (lng.includes(".")) {
13328
- this.deprecateDottedLng("addResource");
13329
- path = lng.split(".");
13330
- value = ns;
13331
- ns = path[1];
13332
- }
13333
13726
  this.addNamespaces(ns);
13334
13727
  setPath(this.data, path, value);
13335
13728
  if (!options.silent) this.emit("added", lng, ns, key, value);
@@ -13337,25 +13730,21 @@ var ResourceStore = class extends EventEmitter {
13337
13730
  addResources(lng, ns, resources, options = {
13338
13731
  silent: false
13339
13732
  }) {
13340
- for (const m in resources) {
13341
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
13733
+ assertSeparateArguments("addResources", lng, ns);
13734
+ Object.keys(resources || {}).forEach((m) => {
13735
+ if (m === "__proto__" || m === "constructor") return;
13736
+ this.addResource(lng, ns, m, resources[m], {
13342
13737
  silent: true
13343
13738
  });
13344
- }
13739
+ });
13345
13740
  if (!options.silent) this.emit("added", lng, ns, resources);
13346
13741
  }
13347
13742
  addResourceBundle(lng, ns, resources, deep, overwrite, options = {
13348
13743
  silent: false,
13349
13744
  skipCopy: false
13350
13745
  }) {
13351
- let path = [lng, ns];
13352
- if (lng.includes(".")) {
13353
- this.deprecateDottedLng("addResourceBundle");
13354
- path = lng.split(".");
13355
- deep = resources;
13356
- resources = ns;
13357
- ns = path[1];
13358
- }
13746
+ assertSeparateArguments("addResourceBundle", lng, ns);
13747
+ const path = [lng, ns];
13359
13748
  this.addNamespaces(ns);
13360
13749
  let pack = getPath(this.data, path) || {};
13361
13750
  if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
@@ -13402,18 +13791,6 @@ var ResourceStore = class extends EventEmitter {
13402
13791
  return this.data;
13403
13792
  }
13404
13793
  };
13405
- var postProcessor = {
13406
- processors: {},
13407
- addPostProcessor(module2) {
13408
- this.processors[module2.name] = module2;
13409
- },
13410
- handle(processors, value, key, options, translator) {
13411
- processors.forEach((processor) => {
13412
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
13413
- });
13414
- return value;
13415
- }
13416
- };
13417
13794
  var PATH_KEY = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
13418
13795
  function createProxy() {
13419
13796
  const state = [];
@@ -13432,7 +13809,7 @@ function keysFromSelector(selector, opts) {
13432
13809
  const {
13433
13810
  [PATH_KEY]: path
13434
13811
  } = selector(createProxy());
13435
- const keySeparator = opts?.keySeparator ?? ".";
13812
+ const keySeparator = opts?.keySeparator || ".";
13436
13813
  const nsSeparator = opts?.nsSeparator ?? ":";
13437
13814
  const strict = opts?.enableSelector === "strict";
13438
13815
  if (path.length > 1 && nsSeparator) {
@@ -13451,12 +13828,12 @@ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" &
13451
13828
  var Translator = class _Translator extends EventEmitter {
13452
13829
  constructor(services, options = {}) {
13453
13830
  super();
13454
- copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "ownPostProcessors"], services, this);
13831
+ copy(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils", "postProcessors"], services, this);
13455
13832
  this.options = options;
13456
13833
  if (this.options.keySeparator === void 0) {
13457
13834
  this.options.keySeparator = ".";
13458
13835
  }
13459
- this.logger = baseLogger.create("translator");
13836
+ this.logger = (services.logger || baseLogger).create("translator");
13460
13837
  this.checkedLoadedFor = {};
13461
13838
  }
13462
13839
  changeLanguage(lng) {
@@ -13580,23 +13957,24 @@ var Translator = class _Translator extends EventEmitter {
13580
13957
  }
13581
13958
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
13582
13959
  const resType = Object.prototype.toString.apply(resForObjHndl);
13583
- if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
13584
- if (!opt.returnObjects && !this.options.returnObjects) {
13585
- if (!this.options.returnedObjectHandler) {
13586
- this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13587
- this.logger.once("returnedObject", "deprecate", "accessing an object without returnObjects returns a sentence about it today; from v27 t() returns the key, as for a missing key (returnedObjectHandler can keep today's text)");
13588
- }
13589
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13590
- ...opt,
13591
- ns: namespaces
13592
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
13593
- if (returnDetails) {
13594
- resolved.res = r;
13595
- resolved.usedParams = this.getUsedParamsDetails(opt);
13596
- return resolved;
13597
- }
13598
- return r;
13960
+ const isObjectHit = handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && !noObject.includes(resType) && !(isString(joinArrays) && Array.isArray(resForObjHndl));
13961
+ const objectNotReturned = isObjectHit && !opt.returnObjects && !this.options.returnObjects;
13962
+ if (objectNotReturned && this.options.returnedObjectHandler) {
13963
+ const r = this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
13964
+ ...opt,
13965
+ ns: namespaces
13966
+ });
13967
+ if (returnDetails) {
13968
+ resolved.res = r;
13969
+ resolved.usedParams = this.getUsedParamsDetails(opt);
13970
+ return resolved;
13599
13971
  }
13972
+ return r;
13973
+ }
13974
+ if (objectNotReturned) {
13975
+ this.logger.warn("accessing an object - but returnObjects options is not enabled!");
13976
+ }
13977
+ if (isObjectHit && !objectNotReturned) {
13600
13978
  if (keySeparator) {
13601
13979
  const resTypeIsArray = Array.isArray(resForObjHndl);
13602
13980
  const copy2 = resTypeIsArray ? [] : {};
@@ -13633,18 +14011,19 @@ var Translator = class _Translator extends EventEmitter {
13633
14011
  } else {
13634
14012
  let usedDefault = false;
13635
14013
  let usedKey = false;
13636
- if (!this.isValidLookup(res) && hasDefaultValue) {
14014
+ if (objectNotReturned) res = void 0;
14015
+ if (!this.isValidLookup(res) && hasDefaultValue && !(objectNotReturned && shouldHandleAsObject(defaultValue))) {
13637
14016
  usedDefault = true;
13638
14017
  res = defaultValue;
13639
14018
  }
13640
- if (!this.isValidLookup(res)) {
14019
+ if (!this.isValidLookup(res) && !(usedDefault && res === "")) {
13641
14020
  usedKey = true;
13642
14021
  res = key;
13643
14022
  }
13644
14023
  const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
13645
14024
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? void 0 : res;
13646
14025
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
13647
- if (usedKey || usedDefault || updateMissing) {
14026
+ if (!objectNotReturned && (usedKey || usedDefault || updateMissing)) {
13648
14027
  this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, needsPluralHandling && !updateMissing ? `${key}${this.pluralResolver.getSuffix(lng, opt.count, opt)}` : key, updateMissing ? defaultValue : res);
13649
14028
  if (keySeparator) {
13650
14029
  const fk = this.resolve(key, {
@@ -13752,18 +14131,21 @@ var Translator = class _Translator extends EventEmitter {
13752
14131
  const postProcess = opt.postProcess || this.options.postProcess;
13753
14132
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
13754
14133
  if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
13755
- postProcessorNames.forEach((name) => {
13756
- if (this.logger.debug && postProcessor.processors[name] && this.ownPostProcessors && !this.ownPostProcessors.has(name)) {
13757
- this.logger.once(name, "deprecate", `postProcess: '${name}' was registered with use() on another i18next instance; from v27 post-processors are per instance, so call use() with it on this instance too`);
13758
- }
13759
- });
13760
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
14134
+ const ppOptions = this.options?.postProcessPassResolved ? {
13761
14135
  i18nResolved: {
13762
14136
  ...resolved,
13763
14137
  usedParams: this.getUsedParamsDetails(opt)
13764
14138
  },
13765
14139
  ...opt
13766
- } : opt, this);
14140
+ } : opt;
14141
+ postProcessorNames.forEach((name) => {
14142
+ const processor = this.postProcessors?.[name];
14143
+ if (!processor) {
14144
+ this.logger.once(`postProcess:${name}`, "warn", `postProcess: '${name}' is not registered on this i18next instance; call use() with it on this instance`);
14145
+ return;
14146
+ }
14147
+ res = processor.process(res, key, ppOptions, this) ?? res;
14148
+ });
13767
14149
  }
13768
14150
  return res;
13769
14151
  }
@@ -13892,14 +14274,16 @@ var Translator = class _Translator extends EventEmitter {
13892
14274
  }
13893
14275
  };
13894
14276
  var LanguageUtil = class {
13895
- constructor(options) {
14277
+ constructor(options, logger = baseLogger) {
13896
14278
  this.options = options;
13897
14279
  this.supportedLngs = this.options.supportedLngs || false;
13898
- this.logger = baseLogger.create("languageUtils");
14280
+ this.logger = logger.create("languageUtils");
13899
14281
  this.resolveHierarchyCache = {};
14282
+ this.formattedCodes = /* @__PURE__ */ new Map();
13900
14283
  }
13901
14284
  clearCache() {
13902
14285
  this.resolveHierarchyCache = {};
14286
+ this.formattedCodes.clear();
13903
14287
  }
13904
14288
  getScriptPartFromCode(code) {
13905
14289
  code = getCleanedCode(code);
@@ -13917,35 +14301,28 @@ var LanguageUtil = class {
13917
14301
  return this.formatLanguageCode(p[0]);
13918
14302
  }
13919
14303
  formatLanguageCode(code) {
13920
- if (isString(code) && code.includes("-")) {
13921
- let formattedCode;
14304
+ if (!isString(code)) return code;
14305
+ let formatted = this.formattedCodes.get(code);
14306
+ if (formatted !== void 0) return formatted;
14307
+ formatted = this.formatUncached(code);
14308
+ if (this.formattedCodes.size >= 1e3) this.formattedCodes.clear();
14309
+ this.formattedCodes.set(code, formatted);
14310
+ return formatted;
14311
+ }
14312
+ formatUncached(code) {
14313
+ const hasSubtags = code.includes("-");
14314
+ if (hasSubtags || this.options.cleanCode !== false) {
14315
+ let canonical;
13922
14316
  try {
13923
- formattedCode = Intl.getCanonicalLocales(code)[0];
14317
+ canonical = Intl.getCanonicalLocales(code)[0];
13924
14318
  } catch (e) {
13925
14319
  }
13926
- if (formattedCode && this.options.lowerCaseLng) {
13927
- formattedCode = formattedCode.toLowerCase();
13928
- }
13929
- if (formattedCode) return formattedCode;
13930
- if (this.options.lowerCaseLng) {
13931
- return code.toLowerCase();
14320
+ if (canonical && (hasSubtags || canonical.toLowerCase() === code.toLowerCase())) {
14321
+ return this.options.lowerCaseLng ? canonical.toLowerCase() : canonical;
13932
14322
  }
13933
- return code;
14323
+ if (canonical) return code.toLowerCase();
13934
14324
  }
13935
- const formatted = this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
13936
- if (this.logger.debug && isString(code)) this.deprecateBareCode(code, formatted);
13937
- return formatted;
13938
- }
13939
- deprecateBareCode(code, formatted) {
13940
- let v27;
13941
- try {
13942
- v27 = Intl.getCanonicalLocales(code)[0];
13943
- } catch (e) {
13944
- return;
13945
- }
13946
- if (this.options.lowerCaseLng) v27 = v27.toLowerCase();
13947
- if (v27 === formatted) return;
13948
- this.logger.once(code, "deprecate", `language code '${code}' is used as '${formatted}'; i18next v27 canonicalizes it to '${v27}', use '${v27}' in lng, fallbackLng, supportedLngs and the resources`);
14325
+ return this.options.lowerCaseLng || this.options.cleanCode && !hasSubtags ? code.toLowerCase() : code;
13949
14326
  }
13950
14327
  isSupportedCode(code) {
13951
14328
  if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) {
@@ -14057,10 +14434,10 @@ var dummyRule = {
14057
14434
  })
14058
14435
  };
14059
14436
  var PluralResolver = class {
14060
- constructor(languageUtils, options = {}) {
14437
+ constructor(languageUtils, options = {}, logger = baseLogger) {
14061
14438
  this.languageUtils = languageUtils;
14062
14439
  this.options = options;
14063
- this.logger = baseLogger.create("pluralResolver");
14440
+ this.logger = logger.create("pluralResolver");
14064
14441
  this.pluralRulesCache = {};
14065
14442
  }
14066
14443
  clearCache() {
@@ -14125,8 +14502,8 @@ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJS
14125
14502
  return path;
14126
14503
  };
14127
14504
  var Interpolator = class {
14128
- constructor(options = {}) {
14129
- this.logger = baseLogger.create("interpolator");
14505
+ constructor(options = {}, logger = baseLogger) {
14506
+ this.logger = logger.create("interpolator");
14130
14507
  this.options = options;
14131
14508
  this.format = options?.interpolation?.format || ((value) => value);
14132
14509
  this.init(options);
@@ -14140,39 +14517,26 @@ var Interpolator = class {
14140
14517
  escapeValue,
14141
14518
  useRawValueToEscape,
14142
14519
  prefix,
14143
- prefixEscaped,
14144
14520
  suffix,
14145
- suffixEscaped,
14146
14521
  formatSeparator,
14147
14522
  unescapeSuffix,
14148
14523
  unescapePrefix,
14149
14524
  nestingPrefix,
14150
- nestingPrefixEscaped,
14151
14525
  nestingSuffix,
14152
- nestingSuffixEscaped,
14153
14526
  nestingOptionsSeparator,
14154
14527
  maxReplaces,
14155
14528
  alwaysFormat
14156
14529
  } = options.interpolation;
14157
- if (prefixEscaped || suffixEscaped || nestingPrefixEscaped || nestingSuffixEscaped) {
14158
- const names = Object.entries({
14159
- prefixEscaped,
14160
- suffixEscaped,
14161
- nestingPrefixEscaped,
14162
- nestingSuffixEscaped
14163
- }).filter(([, v]) => v).map(([k]) => k);
14164
- this.logger.once(names.join(), "deprecate", `interpolation.${names.join(", interpolation.")}: the regex-escaped delimiter options are removed in v27; pass the literal delimiters as prefix, suffix, nestingPrefix and nestingSuffix`);
14165
- }
14166
14530
  this.escape = escape$1 !== void 0 ? escape$1 : escape;
14167
14531
  this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
14168
14532
  this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
14169
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
14170
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
14533
+ this.prefix = prefix ? regexEscape(prefix) : "{{";
14534
+ this.suffix = suffix ? regexEscape(suffix) : "}}";
14171
14535
  this.formatSeparator = formatSeparator || ",";
14172
14536
  this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix ? regexEscape(unescapePrefix) : "-";
14173
14537
  this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix ? regexEscape(unescapeSuffix) : "";
14174
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
14175
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
14538
+ this.nestingPrefix = regexEscape(nestingPrefix || "$t(");
14539
+ this.nestingSuffix = regexEscape(nestingSuffix || ")");
14176
14540
  this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
14177
14541
  this.maxReplaces = maxReplaces || 1e3;
14178
14542
  this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
@@ -14228,13 +14592,7 @@ var Interpolator = class {
14228
14592
  safeValue: (val) => val
14229
14593
  }, {
14230
14594
  regex: this.regexp,
14231
- safeValue: (val) => {
14232
- if (!this.escapeValue) return val;
14233
- if (this.escape === escape && this.options?.interpolation?.escapeValue !== false && isString(val) && val.includes("/")) {
14234
- this.logger.once("/", "deprecate", "escapeValue renders '/' in a value as '&#x2F;' today; from v27 the default escape leaves '/' as it is");
14235
- }
14236
- return this.escape(val);
14237
- }
14595
+ safeValue: (val) => this.escapeValue ? this.escape(val) : val
14238
14596
  }];
14239
14597
  const unescapedValues = [];
14240
14598
  let shift = 0;
@@ -14419,6 +14777,7 @@ var Formatter = class {
14419
14777
  init(services, options = {
14420
14778
  interpolation: {}
14421
14779
  }) {
14780
+ if (services?.logger?.create) this.logger = services.logger.create("formatter");
14422
14781
  this.formatSeparator = options.interpolation.formatSeparator || ",";
14423
14782
  const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
14424
14783
  this.formats = {
@@ -14514,7 +14873,7 @@ var Connector = class extends EventEmitter {
14514
14873
  this.services = services;
14515
14874
  this.languageUtils = services.languageUtils;
14516
14875
  this.options = options;
14517
- this.logger = baseLogger.create("backendConnector");
14876
+ this.logger = (services.logger || baseLogger).create("backendConnector");
14518
14877
  this.waitingReads = [];
14519
14878
  this.maxParallelReads = options.maxParallelReads || 10;
14520
14879
  this.readingCalls = 0;
@@ -14674,15 +15033,10 @@ var Connector = class extends EventEmitter {
14674
15033
  reload: true
14675
15034
  }, callback);
14676
15035
  }
14677
- noticeDevFallback(lng) {
14678
- if (lng !== "dev" || !this.devIsDefaultFallback) return;
14679
- this.logger.once("dev", "warn", "language 'dev' is requested because fallbackLng is not set (its default is ['dev']); i18next v27 defaults to fallbackLng: false and loads and saves missing keys in the requested language instead. Set fallbackLng to your source language, or to 'dev' to keep this behavior");
14680
- }
14681
15036
  loadOne(name, prefix = "") {
14682
15037
  const s = name.split("|");
14683
15038
  const lng = s[0];
14684
15039
  const ns = s[1];
14685
- this.noticeDevFallback(lng);
14686
15040
  this.read(lng, ns, "read", void 0, void 0, (err, data) => {
14687
15041
  if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
14688
15042
  if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
@@ -14697,7 +15051,6 @@ var Connector = class extends EventEmitter {
14697
15051
  }
14698
15052
  if (key === void 0 || key === null || key === "") return;
14699
15053
  if (this.backend?.create) {
14700
- languages?.forEach?.((l) => this.noticeDevFallback(l));
14701
15054
  const opts = {
14702
15055
  ...options,
14703
15056
  isUpdate
@@ -14732,7 +15085,7 @@ var get = () => ({
14732
15085
  initAsync: true,
14733
15086
  ns: ["translation"],
14734
15087
  defaultNS: ["translation"],
14735
- fallbackLng: ["dev"],
15088
+ fallbackLng: false,
14736
15089
  fallbackNS: false,
14737
15090
  supportedLngs: false,
14738
15091
  nonExplicitSupportedLngs: false,
@@ -14753,7 +15106,7 @@ var get = () => ({
14753
15106
  postProcess: false,
14754
15107
  postProcessPassResolved: false,
14755
15108
  returnNull: false,
14756
- returnEmptyString: true,
15109
+ returnEmptyString: false,
14757
15110
  returnObjects: false,
14758
15111
  joinArrays: false,
14759
15112
  returnedObjectHandler: false,
@@ -14798,7 +15151,39 @@ var transformOptions = (options) => {
14798
15151
  };
14799
15152
  var noop = () => {
14800
15153
  };
14801
- var loggerOwner;
15154
+ var withDefaults = (options) => {
15155
+ const defOpts = get();
15156
+ const merged = {
15157
+ ...defOpts,
15158
+ ...options
15159
+ };
15160
+ merged.interpolation = {
15161
+ ...defOpts.interpolation,
15162
+ ...options.interpolation
15163
+ };
15164
+ if (typeof merged.overloadTranslationOptionHandler !== "function") {
15165
+ merged.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
15166
+ }
15167
+ return merged;
15168
+ };
15169
+ var configuredLanguageCodes = (options) => {
15170
+ const codes = [].concat(options.supportedLngs || [], options.preload || []);
15171
+ codes.push(...Object.keys(options.resources || {}));
15172
+ const fallbackLng = options.fallbackLng;
15173
+ if (isString(fallbackLng) || Array.isArray(fallbackLng)) codes.push(...[].concat(fallbackLng));
15174
+ else if (fallbackLng && typeof fallbackLng === "object") {
15175
+ Object.keys(fallbackLng).forEach((code) => {
15176
+ if (code !== "default") codes.push(code);
15177
+ codes.push(...[].concat(fallbackLng[code]));
15178
+ });
15179
+ }
15180
+ return codes;
15181
+ };
15182
+ var isRefusedLanguageCode = (i18n2, code) => {
15183
+ if (!isString(code) || isSafeLanguageCode(code) || i18n2.configuredLngs?.has(code)) return false;
15184
+ 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`);
15185
+ return true;
15186
+ };
14802
15187
  var bindMemberFunctions = (inst) => {
14803
15188
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
14804
15189
  mems.forEach((mem) => {
@@ -14810,17 +15195,18 @@ var bindMemberFunctions = (inst) => {
14810
15195
  var I18n = class _I18n extends EventEmitter {
14811
15196
  constructor(options = {}, callback) {
14812
15197
  super();
14813
- this.options = transformOptions(options);
15198
+ this.userOptions = transformOptions(options);
15199
+ this.options = withDefaults(this.userOptions);
14814
15200
  this.services = {
14815
- ownPostProcessors: /* @__PURE__ */ new Set()
15201
+ postProcessors: /* @__PURE__ */ Object.create(null)
14816
15202
  };
14817
- this.logger = baseLogger;
15203
+ this.logger = new Logger(null, this.options);
14818
15204
  this.modules = {
14819
15205
  external: []
14820
15206
  };
14821
15207
  bindMemberFunctions(this);
14822
15208
  if (callback && !this.isInitialized && !options.isClone) {
14823
- if (!this.options.initAsync) {
15209
+ if (!this.userOptions.initAsync) {
14824
15210
  this.init(options, callback);
14825
15211
  return this;
14826
15212
  }
@@ -14842,25 +15228,23 @@ var I18n = class _I18n extends EventEmitter {
14842
15228
  options.defaultNS = options.ns[0];
14843
15229
  }
14844
15230
  }
14845
- const fallbackLngIsDefault = options.fallbackLng === void 0 && this.options.fallbackLng === void 0;
14846
- const defOpts = get();
14847
- this.options = {
14848
- ...defOpts,
14849
- ...this.options,
14850
- ...transformOptions(options)
15231
+ transformOptions(options);
15232
+ const userOptions = {
15233
+ ...this.userOptions,
15234
+ ...options
14851
15235
  };
14852
- this.options.interpolation = {
14853
- ...defOpts.interpolation,
14854
- ...this.options.interpolation
14855
- };
14856
- if (options.keySeparator !== void 0) {
14857
- this.options.userDefinedKeySeparator = options.keySeparator;
15236
+ this.options = withDefaults({
15237
+ ...this.options,
15238
+ ...options
15239
+ });
15240
+ if (userOptions.keySeparator !== void 0) {
15241
+ this.options.userDefinedKeySeparator = userOptions.keySeparator;
14858
15242
  }
14859
- if (options.nsSeparator !== void 0) {
14860
- this.options.userDefinedNsSeparator = options.nsSeparator;
15243
+ if (userOptions.nsSeparator !== void 0) {
15244
+ this.options.userDefinedNsSeparator = userOptions.nsSeparator;
14861
15245
  }
14862
- if (typeof this.options.overloadTranslationOptionHandler !== "function") {
14863
- this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
15246
+ if (!this.options.isClone) {
15247
+ this.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(userOptions)]);
14864
15248
  }
14865
15249
  const createClassOnDemand = (ClassOrObject) => {
14866
15250
  if (!ClassOrObject) return null;
@@ -14868,15 +15252,10 @@ var I18n = class _I18n extends EventEmitter {
14868
15252
  return ClassOrObject;
14869
15253
  };
14870
15254
  if (!this.options.isClone) {
14871
- if (loggerOwner && loggerOwner !== this && loggerOwner.modules.logger !== this.modules.logger) {
14872
- baseLogger.deprecate("init: this init() replaces the logger another i18next instance set with use(), as the logger is shared in v26; from v27 each instance keeps its own logger");
14873
- }
14874
- loggerOwner = this.modules.logger ? this : void 0;
14875
- if (this.modules.logger) {
14876
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
14877
- } else {
14878
- baseLogger.init(null, this.options);
14879
- }
15255
+ this.logger.init(createClassOnDemand(this.modules.logger), this.options);
15256
+ const {
15257
+ logger
15258
+ } = this;
14880
15259
  this.pendingWarnings?.forEach((msg) => this.logger.warn(msg));
14881
15260
  this.pendingWarnings = void 0;
14882
15261
  let formatter;
@@ -14885,27 +15264,26 @@ var I18n = class _I18n extends EventEmitter {
14885
15264
  } else {
14886
15265
  formatter = Formatter;
14887
15266
  }
14888
- const lu = new LanguageUtil(this.options);
14889
- this.store = new ResourceStore(this.options.resources, this.options);
15267
+ const lu = new LanguageUtil(this.options, logger);
15268
+ this.store = new ResourceStore(this.options.resources, this.options, logger);
14890
15269
  const s = this.services;
14891
- s.logger = baseLogger;
15270
+ s.logger = logger;
14892
15271
  s.resourceStore = this.store;
14893
15272
  s.languageUtils = lu;
14894
15273
  s.pluralResolver = new PluralResolver(lu, {
14895
15274
  prepend: this.options.pluralSeparator
14896
- });
15275
+ }, logger);
14897
15276
  if (formatter) {
14898
15277
  s.formatter = createClassOnDemand(formatter);
14899
15278
  if (s.formatter.init) s.formatter.init(s, this.options);
14900
15279
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
14901
15280
  }
14902
- s.interpolator = new Interpolator(this.options);
15281
+ s.interpolator = new Interpolator(this.options, logger);
14903
15282
  s.utils = {
14904
15283
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this),
14905
15284
  reloadResources: this.reloadResources.bind(this)
14906
15285
  };
14907
15286
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
14908
- s.backendConnector.devIsDefaultFallback = fallbackLngIsDefault;
14909
15287
  s.backendConnector.on("*", (event, ...args) => {
14910
15288
  this.emit(event, ...args);
14911
15289
  });
@@ -15046,8 +15424,7 @@ var I18n = class _I18n extends EventEmitter {
15046
15424
  setModule("i18nFormat");
15047
15425
  }
15048
15426
  if (module2.type === "postProcessor") {
15049
- postProcessor.addPostProcessor(module2);
15050
- this.services.ownPostProcessors?.add(module2.name);
15427
+ this.services.postProcessors[module2.name] = module2;
15051
15428
  }
15052
15429
  if (module2.type === "formatter") {
15053
15430
  setModule("formatter");
@@ -15122,14 +15499,16 @@ var I18n = class _I18n extends EventEmitter {
15122
15499
  };
15123
15500
  const setLng = (lngs) => {
15124
15501
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
15125
- const fl = isString(lngs) ? lngs : lngs && lngs[0];
15126
- const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15127
- if (l && this.logger.debug && !isSafeLanguageCode(l)) {
15128
- const configured = [].concat(this.options.supportedLngs || [], this.services.languageUtils.getFallbackCodes(this.options.fallbackLng, l), this.options.preload || []);
15129
- if (!configured.includes(l) && !Object.prototype.hasOwnProperty.call(this.store.data, l)) {
15130
- this.logger.once(`lng:${l}`, "deprecate", `changeLanguage: the language code '${l.slice(0, 64)}' comes from lng, changeLanguage() or the language detector and is not configured; from v27 such a code is refused unless it has only letters, digits, '-', '_', '@' and '.' (no '..'), at most 128 characters. Set supportedLngs, or check the code before passing it on`);
15131
- }
15502
+ const {
15503
+ supportedLngs
15504
+ } = this.options;
15505
+ if (lngs && !supportedLngs) {
15506
+ const accepted = [].concat(lngs).filter((c) => !isRefusedLanguageCode(this, c));
15507
+ if (accepted.length < [].concat(lngs).length) lngs = accepted;
15132
15508
  }
15509
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
15510
+ let l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
15511
+ if (supportedLngs && isRefusedLanguageCode(this, l)) l = this.services.languageUtils.getBestMatchFromCodes([]);
15133
15512
  if (l) {
15134
15513
  if (!this.language) {
15135
15514
  setLngProps(l);
@@ -15244,7 +15623,7 @@ var I18n = class _I18n extends EventEmitter {
15244
15623
  }
15245
15624
  loadNamespaces(ns, callback) {
15246
15625
  const deferred = defer();
15247
- if (!this.options.ns) {
15626
+ if (!this.options.ns || !this.services.backendConnector) {
15248
15627
  if (callback) callback();
15249
15628
  return Promise.resolve();
15250
15629
  }
@@ -15262,7 +15641,7 @@ var I18n = class _I18n extends EventEmitter {
15262
15641
  const deferred = defer();
15263
15642
  if (isString(lngs)) lngs = [lngs];
15264
15643
  const preloaded = this.options.preload || [];
15265
- const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && this.services.languageUtils.isSupportedCode(lng));
15644
+ const newLngs = lngs.filter((lng) => !preloaded.includes(lng) && !isRefusedLanguageCode(this, lng) && this.services.languageUtils.isSupportedCode(lng));
15266
15645
  if (!newLngs.length) {
15267
15646
  if (callback) callback();
15268
15647
  return Promise.resolve();
@@ -15312,16 +15691,15 @@ var I18n = class _I18n extends EventEmitter {
15312
15691
  }
15313
15692
  };
15314
15693
  const clone = new _I18n(mergedOptions);
15315
- if (options.debug !== void 0 || options.prefix !== void 0) {
15316
- clone.logger = clone.logger.clone(options);
15317
- }
15318
- const membersToCopy = ["store", "services", "language"];
15694
+ clone.logger = options.debug !== void 0 || options.prefix !== void 0 ? this.logger.clone(options) : this.logger;
15695
+ const membersToCopy = ["store", "language"];
15319
15696
  membersToCopy.forEach((m) => {
15320
15697
  clone[m] = this[m];
15321
15698
  });
15322
15699
  clone.services = {
15323
15700
  ...this.services
15324
15701
  };
15702
+ clone.services.postProcessors = Object.create(this.services.postProcessors);
15325
15703
  clone.services.utils = {
15326
15704
  ...clone.services.utils,
15327
15705
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone),
@@ -15338,7 +15716,7 @@ var I18n = class _I18n extends EventEmitter {
15338
15716
  return copied;
15339
15717
  };
15340
15718
  const clonedData = copyData(this.store.data);
15341
- clone.store = new ResourceStore(clonedData, mergedOptions);
15719
+ clone.store = new ResourceStore(clonedData, mergedOptions, this.logger);
15342
15720
  clone.services.resourceStore = clone.store;
15343
15721
  }
15344
15722
  if (options.interpolation) {
@@ -15352,8 +15730,9 @@ var I18n = class _I18n extends EventEmitter {
15352
15730
  ...mergedOptions,
15353
15731
  interpolation: mergedInterpolation
15354
15732
  };
15355
- clone.services.interpolator = new Interpolator(mergedForInterpolator);
15733
+ clone.services.interpolator = new Interpolator(mergedForInterpolator, this.logger);
15356
15734
  }
15735
+ clone.configuredLngs = /* @__PURE__ */ new Set([...this.configuredLngs || [], ...configuredLanguageCodes(options)]);
15357
15736
  clone.translator = new Translator(clone.services, mergedOptions);
15358
15737
  clone.translator.on("*", (event, ...args) => {
15359
15738
  clone.emit(event, ...args);
@@ -17381,6 +17760,25 @@ var createKeyboardExecutionHandler = (fn) => {
17381
17760
  return handler;
17382
17761
  };
17383
17762
 
17763
+ // src/utils/invoiceLink.ts
17764
+ function openInvoiceLink(event, storedUrl, fetchUrl) {
17765
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
17766
+ return Promise.resolve();
17767
+ }
17768
+ const tab = window.open("", "_blank");
17769
+ if (tab === null) {
17770
+ return Promise.resolve();
17771
+ }
17772
+ event.preventDefault();
17773
+ tab.opener = null;
17774
+ return fetchUrl().then(
17775
+ (url) => url || storedUrl,
17776
+ () => storedUrl
17777
+ ).then((url) => {
17778
+ tab.location.href = url;
17779
+ });
17780
+ }
17781
+
17384
17782
  // src/utils/markdown.tsx
17385
17783
  var import_react3 = require("react");
17386
17784
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -18134,7 +18532,7 @@ var reducer = (state, action) => {
18134
18532
  // src/context/EmbedProvider.tsx
18135
18533
  var import_jsx_runtime4 = require("react/jsx-runtime");
18136
18534
  var getCustomHeaders = (sessionId) => ({
18137
- "X-Schematic-Components-Version": "2.37.0",
18535
+ "X-Schematic-Components-Version": "2.38.0",
18138
18536
  "X-Schematic-Session-ID": sessionId
18139
18537
  });
18140
18538
  var normalizeCurrencyFilter = (filter) => {
@@ -18522,6 +18920,12 @@ var EmbedProvider = ({
18522
18920
  () => (0, import_debounce2.default)(listInvoices, FETCH_DEBOUNCE_TIMEOUT, LEADING_DEBOUNCE_SETTINGS),
18523
18921
  [listInvoices]
18524
18922
  );
18923
+ const getInvoiceLink = (0, import_react4.useCallback)(
18924
+ async (billingInvoiceId) => {
18925
+ return checkoutApi?.getInvoiceLink({ billingInvoiceId });
18926
+ },
18927
+ [checkoutApi]
18928
+ );
18525
18929
  const getCreditUsageByUser = (0, import_react4.useCallback)(
18526
18930
  async (billingCreditId, limit) => {
18527
18931
  return checkoutApi?.getCreditUsageByUser({ billingCreditId, limit });
@@ -18716,6 +19120,7 @@ var EmbedProvider = ({
18716
19120
  getUpcomingInvoice: debouncedGetUpcomingInvoice,
18717
19121
  getCustomerBalance: debouncedGetCustomerBalance,
18718
19122
  listInvoices: debouncedListInvoices,
19123
+ getInvoiceLink,
18719
19124
  getCreditUsageByUser: debouncedGetCreditUsageByUser,
18720
19125
  getFeatureUsageByUser: debouncedGetFeatureUsageByUser,
18721
19126
  finishCheckout,
@@ -27715,12 +28120,13 @@ function formatInvoices(invoices, locale, options) {
27715
28120
  const dateA = a.dueDate ?? a.createdAt;
27716
28121
  const dateB = b.dueDate ?? b.createdAt;
27717
28122
  return +dateB - +dateA;
27718
- }).map(({ amountDue, dueDate, createdAt, url, currency }) => {
28123
+ }).map(({ amountDue, dueDate, createdAt, id, url, currency }) => {
27719
28124
  const formatted = formatCurrency(Math.abs(amountDue), {
27720
28125
  locale,
27721
28126
  currency
27722
28127
  });
27723
28128
  return {
28129
+ id,
27724
28130
  amount: amountDue < 0 ? `(${formatted})` : formatted,
27725
28131
  amountDue,
27726
28132
  date: toPrettyDate(dueDate ?? createdAt, { locale }),
@@ -27731,7 +28137,7 @@ function formatInvoices(invoices, locale, options) {
27731
28137
  var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27732
28138
  const props = resolveDesignProps3(rest);
27733
28139
  const { t: t2, locale } = useTranslation();
27734
- const { data, listInvoices, settings } = useEmbed();
28140
+ const { data, getInvoiceLink, listInvoices, settings } = useEmbed();
27735
28141
  const [isLoading, setIsLoading] = (0, import_react44.useState)(false);
27736
28142
  const [error, setError] = (0, import_react44.useState)();
27737
28143
  const [rawInvoices, setInvoices] = (0, import_react44.useState)(
@@ -27808,7 +28214,7 @@ var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27808
28214
  props.header.isVisible && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $justifyContent: "space-between", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Text, { display: props.header.fontStyle, children: t2("Invoices") }) }),
27809
28215
  invoices.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
27810
28216
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Flex, { $flexDirection: "column", $gap: "0.5rem", children: visibleInvoices.items.map(
27811
- ({ date, amount, amountDue, url }, index) => {
28217
+ ({ id, date, amount, amountDue, url }, index) => {
27812
28218
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
27813
28219
  Flex,
27814
28220
  {
@@ -27819,11 +28225,18 @@ var Invoices = (0, import_react44.forwardRef)(({ className, ...rest }, ref) => {
27819
28225
  Text,
27820
28226
  {
27821
28227
  display: props.date.fontStyle,
27822
- ...url && {
28228
+ ...id && url && {
27823
28229
  as: "a",
27824
28230
  href: url,
27825
28231
  target: "_blank",
27826
- rel: "noreferrer"
28232
+ rel: "noreferrer",
28233
+ onClick: (event) => {
28234
+ void openInvoiceLink(
28235
+ event,
28236
+ url,
28237
+ async () => (await getInvoiceLink(id))?.data.url
28238
+ );
28239
+ }
27827
28240
  },
27828
28241
  $color: url ? settings.theme.typography.link.color : settings.theme.typography.text.color,
27829
28242
  children: date