gt-react 10.19.17 → 10.19.19

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.
package/dist/browser.cjs CHANGED
@@ -4198,14 +4198,17 @@ function extractVars(icuString) {
4198
4198
  });
4199
4199
  return variables;
4200
4200
  }
4201
+ const CONTAINS_INDEXED_GT_REGEX = new RegExp(`${VAR_IDENTIFIER}\\d+`);
4201
4202
  /**
4202
4203
  * Given an indexed ICU string, condenses any select to an argument
4204
+ * Unindexed _gt_ source strings and indexed _gt_# translation strings
4205
+ * are mutually exclusive.
4203
4206
  * indexVars('Hello {_gt_1, select, other {World}}') => 'Hello {_gt_1}'
4204
4207
  * @param {string} icuString - The ICU string to condense.
4205
4208
  * @returns {string} The condensed ICU string.
4206
4209
  */
4207
4210
  function condenseVars(icuString) {
4208
- if (!icuString.includes("_gt_")) return icuString;
4211
+ if (!CONTAINS_INDEXED_GT_REGEX.test(icuString)) return icuString;
4209
4212
  function visitor(child) {
4210
4213
  child.type = import_types.TYPE.argument;
4211
4214
  Reflect.deleteProperty(child, "options");
@@ -4402,7 +4405,7 @@ function sanitizeJsxChildren(childrenAsObjects) {
4402
4405
  return Array.isArray(childrenAsObjects) ? childrenAsObjects.map(sanitizeChild) : sanitizeChild(childrenAsObjects);
4403
4406
  }
4404
4407
  //#endregion
4405
- //#region ../i18n/dist/versionId-BkJZGHXr.mjs
4408
+ //#region ../i18n/dist/versionId-BTjLA0FZ.mjs
4406
4409
  /**
4407
4410
  * Throw errors if there are any errors and log warnings if there are any warnings
4408
4411
  * @param {ValidationResult[]} results - The results to print
@@ -4668,83 +4671,269 @@ function routeCreateTranslationLoader({ type, remoteTranslationLoaderParams, loa
4668
4671
  case "disabled": return createFallbackTranslationLoader();
4669
4672
  }
4670
4673
  }
4671
- function isPlainObject(value) {
4672
- if (value == null || typeof value !== "object") return false;
4673
- const prototype = Object.getPrototypeOf(value);
4674
- return prototype === Object.prototype || prototype === null;
4674
+ function getDictionaryPath(id) {
4675
+ const path = id ? id.split(".") : [];
4676
+ for (const segment of path) assertSafeDictionaryPathSegment(segment, id);
4677
+ return path;
4675
4678
  }
4676
- function copyCacheValue(value) {
4677
- if (Array.isArray(value)) return [...value];
4678
- if (isPlainObject(value)) return { ...value };
4679
- return value;
4679
+ function assertSafeDictionaryPathSegment(segment, path) {
4680
+ if (segment === "__proto__" || segment === "constructor" || segment === "prototype") throw new Error(`Dictionary path "${path}" contains an unsafe segment`);
4681
+ }
4682
+ function isDictionaryObject(value) {
4683
+ return typeof value === "object" && value != null && !Array.isArray(value);
4684
+ }
4685
+ function cloneDictionaryValue(value) {
4686
+ if (value === void 0 || typeof value === "string") return value;
4687
+ return structuredClone(value);
4688
+ }
4689
+ function getDictionaryValueAtPath(dictionary, path) {
4690
+ let current = dictionary;
4691
+ for (const segment of getDictionaryPath(path)) {
4692
+ if (!isDictionaryObject(current)) return;
4693
+ current = current[segment];
4694
+ }
4695
+ return current;
4696
+ }
4697
+ function setDictionaryValueAtPath(dictionary, path, value) {
4698
+ const segments = getDictionaryPath(path);
4699
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4700
+ if (segments.length === 0) {
4701
+ if (isDictionaryObject(value)) replaceDictionary(dictionary, value);
4702
+ return;
4703
+ }
4704
+ let current = dictionary;
4705
+ for (const segment of segments.slice(0, -1)) {
4706
+ const next = current[segment];
4707
+ if (!isDictionaryObject(next)) current[segment] = {};
4708
+ current = current[segment];
4709
+ }
4710
+ const leafSegment = segments[segments.length - 1];
4711
+ current[leafSegment] = value;
4712
+ }
4713
+ function getDictionaryEntry(value) {
4714
+ if (!isDictionaryLeafNode(value)) return;
4715
+ return {
4716
+ entry: Array.isArray(value) ? value[0] : value,
4717
+ options: Array.isArray(value) ? value[1] ?? {} : {}
4718
+ };
4719
+ }
4720
+ function getDictionaryValue(value) {
4721
+ if (Object.keys(value.options).length === 0) return value.entry;
4722
+ return [value.entry, value.options];
4723
+ }
4724
+ function resolveDictionaryLookupOptions(options) {
4725
+ const { $format, context, ...rest } = options;
4726
+ return {
4727
+ ...rest,
4728
+ $format: isStringFormat($format) ? $format : "ICU",
4729
+ ...rest.$context === void 0 && typeof context === "string" && { $context: context }
4730
+ };
4731
+ }
4732
+ function isDictionaryLeafNode(value) {
4733
+ if (typeof value === "string") return true;
4734
+ if (!Array.isArray(value) || typeof value[0] !== "string") return false;
4735
+ if (value.length === 1) return true;
4736
+ return value.length === 2 && isDictionaryOptions(value[1]);
4737
+ }
4738
+ function isDictionaryOptions(value) {
4739
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
4740
+ const options = value;
4741
+ return (options.$context === void 0 || typeof options.$context === "string") && (options.$format === void 0 || isStringFormat(options.$format)) && (options.$maxChars === void 0 || typeof options.$maxChars === "number") && (options.context === void 0 || typeof options.context === "string");
4680
4742
  }
4743
+ function isStringFormat(value) {
4744
+ return value === "ICU" || value === "I18NEXT" || value === "STRING";
4745
+ }
4746
+ function replaceDictionary(target, source) {
4747
+ for (const key of Object.keys(target)) delete target[key];
4748
+ for (const key of Object.keys(source)) target[key] = source[key];
4749
+ }
4750
+ function assertSafeDictionaryObject(dictionary, parentPath = "") {
4751
+ for (const [key, value] of Object.entries(dictionary)) {
4752
+ const path = parentPath ? `${parentPath}.${key}` : key;
4753
+ assertSafeDictionaryPathSegment(key, path);
4754
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4755
+ }
4756
+ }
4757
+ var DictionarySourceNotFoundError = class extends Error {
4758
+ constructor(id) {
4759
+ super(`I18nManager: source dictionary entry ${id} is not defined`);
4760
+ this.name = "DictionarySourceNotFoundError";
4761
+ }
4762
+ };
4681
4763
  /**
4682
- * Cache class
4683
- * This is designed in such a way that it is the responsibility of the client
4684
- * to invoke the cache miss method when a cache miss occurs.
4685
- *
4686
- * TODO: maybe add "OutputValue" as a reflection of "InputKey"
4687
- */
4688
- var Cache = class {
4689
- /**
4690
- * Constructor
4691
- * @param {Object} params - The parameters for the cache
4692
- * @param {Record<CacheKey, CacheValue>} params.init - The initial cache
4693
- * @param {CacheLifecycle} [lifecycle] - Optional lifecycle callbacks
4694
- */
4695
- constructor(init, lifecycle) {
4696
- this.cache = {};
4697
- this.fallbackPromises = {};
4764
+ * Builds the dictionary value for a requested path by combining existing target
4765
+ * translations with runtime translations of any source leaves that are missing.
4766
+ */
4767
+ async function materializeDictionaryValue({ key, sourceValue, targetValue, translateEntry }) {
4768
+ if (getDictionaryEntry(targetValue) !== void 0) return cloneDictionaryValue(targetValue);
4769
+ if (isDictionaryObject(targetValue) && !isDictionaryObject(sourceValue)) return cloneDictionaryValue(targetValue);
4770
+ const sourceEntry = getDictionaryEntry(sourceValue);
4771
+ if (sourceEntry !== void 0) return await translateEntry(key, sourceEntry);
4772
+ if (!isDictionaryObject(sourceValue)) throw new DictionarySourceNotFoundError(key);
4773
+ const targetDictionary = isDictionaryObject(targetValue) ? targetValue : {};
4774
+ const keys = new Set([...Object.keys(sourceValue), ...Object.keys(targetDictionary)]);
4775
+ const entries = await Promise.all(Array.from(keys).map(async (childKey) => {
4776
+ const childPath = key ? `${key}.${childKey}` : childKey;
4777
+ assertSafeDictionaryPathSegment(childKey, childPath);
4778
+ const childSource = sourceValue[childKey];
4779
+ if (childSource === void 0) return [childKey, cloneDictionaryValue(targetDictionary[childKey])];
4780
+ return [childKey, await materializeDictionaryValue({
4781
+ key: childPath,
4782
+ sourceValue: childSource,
4783
+ targetValue: targetDictionary[childKey],
4784
+ translateEntry
4785
+ })];
4786
+ }));
4787
+ return Object.fromEntries(entries);
4788
+ }
4789
+ function cloneDictionaryEntry(entry) {
4790
+ return {
4791
+ entry: entry.entry,
4792
+ options: structuredClone(entry.options)
4793
+ };
4794
+ }
4795
+ var DictionaryCache = class {
4796
+ constructor({ init, lifecycle = {}, runtimeTranslate }) {
4797
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4798
+ this.pendingMaterializations = /* @__PURE__ */ new Map();
4698
4799
  this.cache = structuredClone(init);
4699
- this.onHit = lifecycle?.onHit;
4700
- this.onMiss = lifecycle?.onMiss;
4800
+ this.runtimeTranslate = runtimeTranslate;
4801
+ this.lifecycle = lifecycle;
4701
4802
  }
4702
- /**
4703
- * Set the value for a key
4704
- */
4705
- setCache(cacheKey, value) {
4706
- this.cache[cacheKey] = value;
4803
+ getEntry(key) {
4804
+ const value = getDictionaryValueAtPath(this.cache, key);
4805
+ const entry = getDictionaryEntry(value);
4806
+ if (entry === void 0) return;
4807
+ const outputEntry = cloneDictionaryEntry(entry);
4808
+ this.lifecycle.onHit?.({
4809
+ inputKey: key,
4810
+ cacheKey: key,
4811
+ cacheValue: value,
4812
+ outputValue: outputEntry
4813
+ });
4814
+ return outputEntry;
4707
4815
  }
4708
- /**
4709
- * Look up the key
4710
- */
4711
- getCache(key) {
4712
- const cacheKey = this.genKey(key);
4713
- return this.cache[cacheKey];
4816
+ getValue(key) {
4817
+ const value = getDictionaryValueAtPath(this.cache, key);
4818
+ if (value === void 0) return;
4819
+ const outputValue = cloneDictionaryValue(value);
4820
+ this.lifecycle.onDictionaryObjectCacheHit?.({
4821
+ inputKey: key,
4822
+ cacheKey: key,
4823
+ cacheValue: value,
4824
+ outputValue
4825
+ });
4826
+ return outputValue;
4827
+ }
4828
+ setValue(key, value) {
4829
+ setDictionaryValueAtPath(this.cache, key, cloneDictionaryValue(value));
4714
4830
  }
4715
- /**
4716
- * Get the internal cache
4717
- * @returns The internal cache
4718
- *
4719
- * @internal - used by gt-tanstack-start
4720
- */
4721
4831
  getInternalCache() {
4722
- return Object.fromEntries(Object.entries(this.cache).map(([key, value]) => [key, copyCacheValue(value)]));
4832
+ return cloneDictionaryValue(this.cache);
4833
+ }
4834
+ async materializeValue(key, sourceValue, targetValue = getDictionaryValueAtPath(this.cache, key)) {
4835
+ let materializationPromise = this.pendingMaterializations.get(key);
4836
+ if (!materializationPromise) {
4837
+ materializationPromise = materializeDictionaryValue({
4838
+ key,
4839
+ sourceValue,
4840
+ targetValue,
4841
+ translateEntry: async (entryKey, sourceEntry) => getDictionaryValue(await this.materializeEntry(entryKey, sourceEntry))
4842
+ }).then((value) => {
4843
+ this.setValue(key, value);
4844
+ return value;
4845
+ });
4846
+ this.pendingMaterializations.set(key, materializationPromise);
4847
+ }
4848
+ try {
4849
+ return await materializationPromise;
4850
+ } finally {
4851
+ this.pendingMaterializations.delete(key);
4852
+ }
4723
4853
  }
4724
- /**
4725
- * Get the mutable cache for subclasses that need custom read/write behavior.
4726
- */
4727
- getMutableCache() {
4728
- return this.cache;
4854
+ async materializeEntry(key, sourceEntry) {
4855
+ let translationPromise = this.pendingTranslations.get(key);
4856
+ if (!translationPromise) {
4857
+ translationPromise = this.runtimeTranslate(key, sourceEntry).then((value) => {
4858
+ setDictionaryValueAtPath(this.cache, key, value);
4859
+ const entry = getDictionaryEntry(value);
4860
+ if (entry === void 0) throw new Error("DictionaryCache materializeEntry did not return a DictionaryEntry");
4861
+ this.lifecycle.onMiss?.({
4862
+ inputKey: key,
4863
+ cacheKey: key,
4864
+ cacheValue: value,
4865
+ outputValue: cloneDictionaryEntry(entry)
4866
+ });
4867
+ return cloneDictionaryEntry(entry);
4868
+ });
4869
+ this.pendingTranslations.set(key, translationPromise);
4870
+ }
4871
+ try {
4872
+ return cloneDictionaryEntry(await translationPromise);
4873
+ } finally {
4874
+ this.pendingTranslations.delete(key);
4875
+ }
4729
4876
  }
4730
- /**
4731
- * Fallback to the value from the fallback function on a cache miss
4732
- * @important assumes that the fallback error handling done upstream
4733
- */
4734
- async missCache(...args) {
4735
- const key = args[0];
4736
- const cacheKey = this.genKey(key);
4737
- if (this.fallbackPromises[cacheKey] !== void 0) return await this.fallbackPromises[cacheKey];
4738
- const fallbackPromise = this.fallback(...args);
4739
- this.fallbackPromises[cacheKey] = fallbackPromise;
4877
+ };
4878
+ var ResourceCache = class {
4879
+ constructor({ load, lifecycle = {}, ttl }) {
4880
+ this.cache = /* @__PURE__ */ new Map();
4881
+ this.pendingLoads = /* @__PURE__ */ new Map();
4882
+ this.loadResource = load;
4883
+ this.lifecycle = lifecycle;
4884
+ this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4885
+ }
4886
+ get(key) {
4887
+ const entry = this.cache.get(key);
4888
+ if (!entry || this.isExpired(entry)) return;
4889
+ this.lifecycle.onHit?.({
4890
+ inputKey: key,
4891
+ cacheKey: key,
4892
+ cacheValue: entry,
4893
+ outputValue: entry.value
4894
+ });
4895
+ return entry.value;
4896
+ }
4897
+ set(key, value, { expiresAt = this.getExpiresAt() } = {}) {
4898
+ this.cache.set(key, {
4899
+ expiresAt,
4900
+ value
4901
+ });
4902
+ }
4903
+ async getOrLoad(key) {
4904
+ return this.get(key) ?? await this.load(key);
4905
+ }
4906
+ async load(key) {
4907
+ let loadPromise = this.pendingLoads.get(key);
4908
+ if (!loadPromise) {
4909
+ loadPromise = this.loadResource(key).then((value) => {
4910
+ const entry = {
4911
+ expiresAt: this.getExpiresAt(),
4912
+ value
4913
+ };
4914
+ this.cache.set(key, entry);
4915
+ this.lifecycle.onMiss?.({
4916
+ inputKey: key,
4917
+ cacheKey: key,
4918
+ cacheValue: entry,
4919
+ outputValue: entry.value
4920
+ });
4921
+ return entry;
4922
+ });
4923
+ this.pendingLoads.set(key, loadPromise);
4924
+ }
4740
4925
  try {
4741
- const value = await fallbackPromise;
4742
- this.setCache(cacheKey, value);
4743
- return value;
4926
+ return (await loadPromise).value;
4744
4927
  } finally {
4745
- delete this.fallbackPromises[cacheKey];
4928
+ this.pendingLoads.delete(key);
4746
4929
  }
4747
4930
  }
4931
+ getExpiresAt() {
4932
+ return this.ttl < 0 ? this.ttl : Date.now() + this.ttl;
4933
+ }
4934
+ isExpired(entry) {
4935
+ return entry.expiresAt > 0 && entry.expiresAt < Date.now();
4936
+ }
4748
4937
  };
4749
4938
  /**
4750
4939
  * Hash a message string
@@ -4789,20 +4978,22 @@ function normalizeBatchConfig(batchConfig) {
4789
4978
  * Locale logic is handled at the LocalesCache level. Use a callback function that has the
4790
4979
  * locale parameter embedded if you wish to use the locale code.
4791
4980
  */
4792
- var TranslationsCache = class extends Cache {
4981
+ var TranslationsCache = class {
4793
4982
  /**
4794
4983
  * Constructor
4795
4984
  * @param {Object} params - The parameters for the cache
4796
4985
  * @param {Record<Hash, TranslationValue>} params.init - The initial cache
4797
4986
  * @param {Function} params.fallback - Get the fallback value for a cache miss
4798
4987
  */
4799
- constructor({ init, translateMany, lifecycle, batchConfig }) {
4800
- super(init, lifecycle);
4801
- this._queue = [];
4802
- this._batchTimer = null;
4803
- this._activeRequests = 0;
4804
- this._translateMany = translateMany;
4805
- this._batchConfig = normalizeBatchConfig(batchConfig);
4988
+ constructor({ init, translateMany, lifecycle = {}, batchConfig }) {
4989
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4990
+ this.queue = [];
4991
+ this.batchTimer = null;
4992
+ this.activeRequests = 0;
4993
+ this.cache = structuredClone(init);
4994
+ this.translateMany = translateMany;
4995
+ this.batchConfig = normalizeBatchConfig(batchConfig);
4996
+ this.lifecycle = lifecycle;
4806
4997
  }
4807
4998
  /**
4808
4999
  * Get the translation value for a given key
@@ -4810,10 +5001,11 @@ var TranslationsCache = class extends Cache {
4810
5001
  * @returns The translation value
4811
5002
  */
4812
5003
  get(key) {
4813
- const value = this.getCache(key);
4814
- if (value != null && this.onHit) this.onHit({
5004
+ const cacheKey = this.getCacheKey(key);
5005
+ const value = this.cache[cacheKey];
5006
+ if (value != null) this.lifecycle.onHit?.({
4815
5007
  inputKey: key,
4816
- cacheKey: this.genKey(key),
5008
+ cacheKey,
4817
5009
  cacheValue: value,
4818
5010
  outputValue: value
4819
5011
  });
@@ -4825,75 +5017,64 @@ var TranslationsCache = class extends Cache {
4825
5017
  * @returns The translation value
4826
5018
  */
4827
5019
  async miss(key) {
4828
- const value = await this.missCache(key);
4829
- if (value != null && this.onMiss) this.onMiss({
4830
- inputKey: key,
4831
- cacheKey: this.genKey(key),
4832
- cacheValue: value,
4833
- outputValue: value
4834
- });
4835
- return value;
5020
+ const cacheKey = this.getCacheKey(key);
5021
+ let translationPromise = this.pendingTranslations.get(cacheKey);
5022
+ if (!translationPromise) {
5023
+ translationPromise = this.translate(key);
5024
+ this.pendingTranslations.set(cacheKey, translationPromise);
5025
+ }
5026
+ try {
5027
+ const value = await translationPromise;
5028
+ if (value != null) this.lifecycle.onMiss?.({
5029
+ inputKey: key,
5030
+ cacheKey,
5031
+ cacheValue: value,
5032
+ outputValue: value
5033
+ });
5034
+ return value;
5035
+ } finally {
5036
+ this.pendingTranslations.delete(cacheKey);
5037
+ }
4836
5038
  }
4837
- /**
4838
- * Generate a key for the cache
4839
- * @param key - The translation key
4840
- * @returns The key
4841
- */
4842
- genKey(key) {
5039
+ getInternalCache() {
5040
+ return structuredClone(this.cache);
5041
+ }
5042
+ getCacheKey(key) {
4843
5043
  return hashMessage(key.message, key.options);
4844
5044
  }
4845
- /**
4846
- * Get the fallback value for a cache miss
4847
- * @param key - The translation key
4848
- * @returns The fallback value
4849
- */
4850
- fallback(key) {
4851
- const translationPromise = this._enqueueTranslation(key);
4852
- if (this._queue.length >= this._batchConfig.maxBatchSize) this._flushNow();
4853
- else this._scheduleBatch();
5045
+ translate(key) {
5046
+ const translationPromise = this.enqueueTranslation(key);
5047
+ if (this.queue.length >= this.batchConfig.maxBatchSize) this.flushNow();
5048
+ else this.scheduleBatch();
4854
5049
  return translationPromise;
4855
5050
  }
4856
- /**
4857
- * Flush the queue now
4858
- */
4859
- _flushNow() {
4860
- if (this._batchTimer) {
4861
- clearTimeout(this._batchTimer);
4862
- this._batchTimer = null;
5051
+ flushNow() {
5052
+ if (this.batchTimer) {
5053
+ clearTimeout(this.batchTimer);
5054
+ this.batchTimer = null;
4863
5055
  }
4864
- this._drainQueue();
4865
- }
4866
- /**
4867
- * Schedule a batch of translations
4868
- */
4869
- _scheduleBatch() {
4870
- if (this._batchTimer) return;
4871
- this._batchTimer = setTimeout(() => {
4872
- this._batchTimer = null;
4873
- this._drainQueue();
4874
- }, this._batchConfig.batchInterval);
4875
- }
4876
- /**
4877
- * Drain the queue
4878
- */
4879
- _drainQueue() {
4880
- while (this._queue.length > 0 && this._activeRequests < this._batchConfig.maxConcurrentRequests) {
4881
- const batch = this._queue.splice(0, this._batchConfig.maxBatchSize);
4882
- this._sendBatchRequest(batch);
5056
+ this.drainQueue();
5057
+ }
5058
+ scheduleBatch() {
5059
+ if (this.batchTimer) return;
5060
+ this.batchTimer = setTimeout(() => {
5061
+ this.batchTimer = null;
5062
+ this.drainQueue();
5063
+ }, this.batchConfig.batchInterval);
5064
+ }
5065
+ drainQueue() {
5066
+ while (this.queue.length > 0 && this.activeRequests < this.batchConfig.maxConcurrentRequests) {
5067
+ const batch = this.queue.splice(0, this.batchConfig.maxBatchSize);
5068
+ this.sendBatchRequest(batch);
4883
5069
  }
4884
- if (this._queue.length > 0) this._scheduleBatch();
5070
+ if (this.queue.length > 0) this.scheduleBatch();
4885
5071
  }
4886
- /**
4887
- * Enqueue translation request and return a promise that resolves when the translation is ready
4888
- * @param {TranslationKey<TranslationValue>} key - The translation key
4889
- * @returns {Promise<TranslationValue>} The translation promise
4890
- */
4891
- _enqueueTranslation(key) {
4892
- const hash = this.genKey(key);
5072
+ enqueueTranslation(key) {
5073
+ const hash = this.getCacheKey(key);
4893
5074
  const options = key.options;
4894
5075
  const metadataOptions = options;
4895
5076
  return new Promise((resolve, reject) => {
4896
- this._queue.push({
5077
+ this.queue.push({
4897
5078
  key: hash,
4898
5079
  source: key.message,
4899
5080
  metadata: {
@@ -4908,38 +5089,28 @@ var TranslationsCache = class extends Cache {
4908
5089
  });
4909
5090
  });
4910
5091
  }
4911
- /**
4912
- * Send a batch request for translations
4913
- * @param {QueueEntry<TranslationValue>[]} batch - The batch of requests to send
4914
- */
4915
- async _sendBatchRequest(batch) {
4916
- this._activeRequests++;
5092
+ async sendBatchRequest(batch) {
5093
+ this.activeRequests++;
4917
5094
  const requests = convertBatchToTranslateManyParams(batch);
4918
- const response = await this._sendBatchRequestWithErrorHandling(batch, requests);
4919
- if (response) this._handleTranslationResponse(batch, response);
4920
- this._activeRequests--;
5095
+ const response = await this.sendBatchRequestWithErrorHandling(batch, requests);
5096
+ if (response) this.handleTranslationResponse(batch, response);
5097
+ this.activeRequests--;
4921
5098
  }
4922
- /**
4923
- * Send a translation request with error handling
4924
- */
4925
- async _sendBatchRequestWithErrorHandling(batch, requests) {
5099
+ async sendBatchRequestWithErrorHandling(batch, requests) {
4926
5100
  try {
4927
- return await this._translateMany(requests);
5101
+ return await this.translateMany(requests);
4928
5102
  } catch (error) {
4929
5103
  for (const entry of batch) entry.reject(error);
4930
5104
  return;
4931
5105
  }
4932
5106
  }
4933
- /**
4934
- * Handle a translation response
4935
- */
4936
- _handleTranslationResponse(batch, response) {
5107
+ handleTranslationResponse(batch, response) {
4937
5108
  for (const entry of batch) {
4938
5109
  const { key } = entry;
4939
5110
  const result = response[key];
4940
5111
  if (result && result.success) {
4941
5112
  const translation = result.translation;
4942
- this.setCache(key, translation);
5113
+ this.cache[key] = translation;
4943
5114
  entry.resolve(translation);
4944
5115
  } else entry.reject(result?.error);
4945
5116
  }
@@ -4957,415 +5128,87 @@ function convertBatchToTranslateManyParams(batch) {
4957
5128
  return acc;
4958
5129
  }, {});
4959
5130
  }
4960
- /**
4961
- * Default cache expiry time in milliseconds
4962
- */
4963
- const DEFAULT_CACHE_EXPIRY_TIME = 6e4;
4964
- /**
4965
- * Cache for looking up translations by locale
4966
- */
4967
- var LocalesCache = class extends Cache {
4968
- /**
4969
- * Constructor
4970
- * @param {Object} params - The parameters for the cache
4971
- * @param {Record<string, CacheEntry<TranslationValue>>} params.init - The initial cache
4972
- * @param {number | null} params.ttl - The time to live for cache entries
4973
- * @param {SafeTranslationsLoader<TranslationValue>} params.loadTranslations - The translation loader function
4974
- * @param {CreateTranslateMany} params.createTranslateMany - Factory function for creating a translate many function
4975
- */
4976
- constructor({ init = {}, ttl, batchConfig, loadTranslations, createTranslateMany, lifecycle: { onLocalesCacheHit: onHit, onLocalesCacheMiss: onMiss, onTranslationsCacheHit, onTranslationsCacheMiss } }) {
4977
- super(init, {
4978
- onHit,
4979
- onMiss
5131
+ var LocalesCache = class {
5132
+ constructor({ ttl, batchConfig, defaultLocale, dictionary = {}, loadTranslations, loadDictionary, createTranslateMany, translateDictionaryEntry, lifecycle }) {
5133
+ this.translations = new ResourceCache({
5134
+ ttl,
5135
+ load: async (locale) => new TranslationsCache({
5136
+ init: await loadTranslations(locale),
5137
+ lifecycle: createTranslationsCacheLifecycle(locale, lifecycle),
5138
+ translateMany: createTranslateMany(locale),
5139
+ batchConfig
5140
+ }),
5141
+ lifecycle: {
5142
+ onHit: lifecycle.onLocalesCacheHit,
5143
+ onMiss: lifecycle.onLocalesCacheMiss
5144
+ }
4980
5145
  });
4981
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
4982
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4983
- this._translationLoader = loadTranslations;
4984
- this._createTranslateMany = createTranslateMany;
4985
- this._batchConfig = batchConfig;
4986
- this._onTranslationsCacheHit = onTranslationsCacheHit;
4987
- this._onTranslationsCacheMiss = onTranslationsCacheMiss;
4988
- }
4989
- /**
4990
- * Get the translations for a given locale
4991
- * @param key - The locale
4992
- * @returns The translations
4993
- */
4994
- get(key) {
4995
- const entry = this.getCache(key);
4996
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
4997
- const value = entry.translationsCache;
4998
- if (value != null && this.onHit) this.onHit({
4999
- inputKey: key,
5000
- cacheKey: this.genKey(key),
5001
- cacheValue: entry,
5002
- outputValue: value
5146
+ this.dictionaries = new ResourceCache({
5147
+ ttl,
5148
+ load: async (locale) => createDictionaryCache({
5149
+ locale,
5150
+ dictionary: await loadDictionary(locale),
5151
+ translate: translateDictionaryEntry,
5152
+ lifecycle
5153
+ }),
5154
+ lifecycle: {
5155
+ onHit: lifecycle.onLocalesDictionaryCacheHit,
5156
+ onMiss: lifecycle.onLocalesDictionaryCacheMiss
5157
+ }
5003
5158
  });
5004
- return value;
5159
+ this.dictionaries.set(defaultLocale, createDictionaryCache({
5160
+ locale: defaultLocale,
5161
+ dictionary,
5162
+ translate: translateDictionaryEntry,
5163
+ lifecycle
5164
+ }), { expiresAt: -1 });
5005
5165
  }
5006
- /**
5007
- * Miss the cache
5008
- * @param key - The locale
5009
- * @returns The translations cache
5010
- */
5011
- async miss(key) {
5012
- const cacheValue = await this.missCache(key);
5013
- const value = cacheValue.translationsCache;
5014
- if (value != null && this.onMiss) this.onMiss({
5015
- inputKey: key,
5016
- cacheKey: this.genKey(key),
5017
- cacheValue,
5018
- outputValue: value
5019
- });
5020
- return value;
5166
+ getTranslations(locale) {
5167
+ return this.translations.get(locale);
5021
5168
  }
5022
- /**
5023
- * Generate the cache key for a given locale
5024
- * @param key - The locale
5025
- * @returns The cache key
5026
- *
5027
- * This is just an identity function, no transformation needed
5028
- */
5029
- genKey(key) {
5030
- return key;
5169
+ getOrLoadTranslations(locale) {
5170
+ return this.translations.getOrLoad(locale);
5031
5171
  }
5032
- /**
5033
- * Fallback for a cache miss
5034
- * @param locale - The locale
5035
- * @returns The cache entry
5036
- */
5037
- async fallback(locale) {
5038
- return {
5039
- translationsCache: new TranslationsCache({
5040
- init: await this._translationLoader(locale),
5041
- lifecycle: this._createTranslationsCacheLifecycle(locale),
5042
- translateMany: this._createTranslateMany(locale),
5043
- batchConfig: this._batchConfig
5044
- }),
5045
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
5046
- };
5172
+ getDictionary(locale) {
5173
+ return this.dictionaries.get(locale);
5047
5174
  }
5048
- /**
5049
- * Create the translations cache lifecycle
5050
- * @param locale - The locale
5051
- * @returns The translations cache lifecycle
5052
- */
5053
- _createTranslationsCacheLifecycle(locale) {
5054
- return {
5055
- onHit: this._onTranslationsCacheHit ? (params) => this._onTranslationsCacheHit({
5056
- locale,
5057
- ...params
5058
- }) : void 0,
5059
- onMiss: this._onTranslationsCacheMiss ? (params) => this._onTranslationsCacheMiss({
5060
- locale,
5061
- ...params
5062
- }) : void 0
5063
- };
5175
+ getOrLoadDictionary(locale) {
5176
+ return this.dictionaries.getOrLoad(locale);
5064
5177
  }
5065
5178
  };
5066
- function getDictionaryPath(id) {
5067
- if (!id) return [];
5068
- return id.split(".");
5069
- }
5070
- function isDictionaryValue(value) {
5071
- return typeof value === "object" && value != null && !Array.isArray(value);
5072
- }
5073
- function getDictionaryEntry(value) {
5074
- if (!isDictionaryLeafNode(value)) return;
5179
+ function createTranslationsCacheLifecycle(locale, lifecycle) {
5075
5180
  return {
5076
- entry: Array.isArray(value) ? value[0] : value,
5077
- options: Array.isArray(value) ? value[1] ?? {} : {}
5078
- };
5079
- }
5080
- function getDictionaryValue(value) {
5081
- if (Object.keys(value.options).length === 0) return value.entry;
5082
- return [value.entry, value.options];
5083
- }
5084
- function resolveDictionaryLookupOptions(options) {
5085
- const { $format, ...rest } = options;
5086
- return {
5087
- ...rest,
5088
- $format: isStringFormat($format) ? $format : "ICU",
5089
- ...rest.$context === void 0 && typeof rest.context === "string" && { $context: rest.context }
5181
+ onHit: withLocale(locale, lifecycle.onTranslationsCacheHit),
5182
+ onMiss: withLocale(locale, lifecycle.onTranslationsCacheMiss)
5090
5183
  };
5091
5184
  }
5092
- function isDictionaryLeafNode(value) {
5093
- if (typeof value === "string") return true;
5094
- if (!Array.isArray(value) || typeof value[0] !== "string") return false;
5095
- if (value.length === 1) return true;
5096
- return value.length === 2 && isDictionaryOptions(value[1]);
5097
- }
5098
- function isDictionaryOptions(value) {
5099
- if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
5100
- const options = value;
5101
- return (options.$context === void 0 || typeof options.$context === "string") && (options.$format === void 0 || isStringFormat(options.$format)) && (options.$maxChars === void 0 || typeof options.$maxChars === "number") && (options.context === void 0 || typeof options.context === "string");
5102
- }
5103
- function isStringFormat(value) {
5104
- return value === "ICU" || value === "I18NEXT" || value === "STRING";
5185
+ function createDictionaryCache({ locale, dictionary, translate, lifecycle }) {
5186
+ const { onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } = lifecycle;
5187
+ return new DictionaryCache({
5188
+ init: dictionary,
5189
+ runtimeTranslate: (key, sourceEntry) => translate(locale, key, sourceEntry),
5190
+ lifecycle: {
5191
+ onHit: withLocale(locale, onDictionaryCacheHit),
5192
+ onMiss: withLocale(locale, onDictionaryCacheMiss),
5193
+ onDictionaryObjectCacheHit: withLocale(locale, onDictionaryObjectCacheHit)
5194
+ }
5195
+ });
5105
5196
  }
5106
- function replaceDictionary(target, source) {
5107
- for (const key of Object.keys(target)) delete target[key];
5108
- Object.assign(target, source);
5197
+ function withLocale(locale, callback) {
5198
+ return callback ? (params) => callback({
5199
+ locale,
5200
+ ...params
5201
+ }) : void 0;
5109
5202
  }
5110
- var DictionarySourceNotFoundError = class extends Error {
5111
- constructor(id) {
5112
- super(`I18nManager: source dictionary entry ${id} is not defined`);
5113
- this.name = "DictionarySourceNotFoundError";
5114
- }
5115
- };
5116
- /**
5117
- * A cache for a single locale's dictionary
5118
- *
5119
- * Principles:
5120
- * - This class is language agnostic, and should never store the locale code as a parameter.
5121
- * Locale logic is handled at the LocalesDictionaryCache level. Use a callback function
5122
- * that has the locale parameter embedded if you wish to use the locale code.
5123
- */
5124
- var DictionaryCache = class extends Cache {
5125
- /**
5126
- * Constructor
5127
- * @param {Object} params - The parameters for the cache
5128
- * @param {Dictionary} params.init - The initial cache
5129
- */
5130
- constructor({ init, lifecycle, runtimeTranslate }) {
5131
- super(init, lifecycle);
5132
- this._runtimeTranslate = runtimeTranslate;
5133
- this.onHitObj = lifecycle?.onHitObj;
5134
- this.onMissObj = lifecycle?.onMissObj;
5135
- }
5136
- /**
5137
- * Get the dictionary value for a given key
5138
- * @param key - The dictionary key
5139
- * @returns The dictionary value
5140
- */
5141
- get(key) {
5142
- const value = this.getCache(key);
5143
- const entry = getDictionaryEntry(value);
5144
- if (entry === void 0) return;
5145
- if (this.onHit) this.onHit({
5146
- inputKey: key,
5147
- cacheKey: this.genKey(key),
5148
- cacheValue: value,
5149
- outputValue: entry
5150
- });
5151
- return entry;
5152
- }
5153
- set(key, value) {
5154
- const dictionaryValue = getDictionaryValue(value);
5155
- this.setCache(this.genKey(key), dictionaryValue);
5156
- }
5157
- getObj(key) {
5158
- const value = this.getCache(key);
5159
- if (value === void 0) return;
5160
- const outputValue = structuredClone(value);
5161
- if (this.onHitObj) this.onHitObj({
5162
- inputKey: key,
5163
- cacheKey: this.genKey(key),
5164
- cacheValue: value,
5165
- outputValue
5166
- });
5167
- return outputValue;
5168
- }
5169
- setObj(key, value) {
5170
- this.setCache(this.genKey(key), structuredClone(value));
5171
- }
5172
- async missObj(key, sourceObject) {
5173
- const sourceEntry = getDictionaryEntry(sourceObject);
5174
- if (sourceEntry !== void 0) return getDictionaryValue(await this.miss(key, sourceEntry));
5175
- if (!isDictionaryValue(sourceObject)) throw new DictionarySourceNotFoundError(key);
5176
- const translatedEntries = await Promise.all(Object.entries(sourceObject).map(async ([childKey, childSource]) => {
5177
- const childPath = key ? `${key}.${childKey}` : childKey;
5178
- return [childKey, await this.missObj(childPath, childSource)];
5179
- }));
5180
- const translatedObject = Object.fromEntries(translatedEntries);
5181
- this.setObj(key, translatedObject);
5182
- return translatedObject;
5183
- }
5184
- /**
5185
- * Miss the cache
5186
- * @param key - The dictionary key
5187
- * @returns The dictionary value
5188
- */
5189
- async miss(key, sourceEntry) {
5190
- const value = await this.missCache(key, sourceEntry);
5191
- const entry = getDictionaryEntry(value);
5192
- if (entry === void 0) throw new Error("DictionaryCache missCache did not return a DictionaryEntry");
5193
- if (this.onMiss) this.onMiss({
5194
- inputKey: key,
5195
- cacheKey: this.genKey(key),
5196
- cacheValue: value,
5197
- outputValue: entry
5198
- });
5199
- return entry;
5200
- }
5201
- /**
5202
- * Set the value for a key
5203
- */
5204
- setCache(cacheKey, value) {
5205
- const cache = this.getMutableCache();
5206
- const dictionaryPath = getDictionaryPath(cacheKey);
5207
- if (dictionaryPath.length === 0) {
5208
- if (isDictionaryValue(value)) replaceDictionary(cache, value);
5209
- return;
5210
- }
5211
- let current = cache;
5212
- for (const key of dictionaryPath.slice(0, -1)) {
5213
- const next = current[key];
5214
- if (!isDictionaryValue(next)) current[key] = {};
5215
- current = current[key];
5216
- }
5217
- current[dictionaryPath[dictionaryPath.length - 1]] = value;
5218
- }
5219
- /**
5220
- * Look up the key
5221
- */
5222
- getCache(key) {
5223
- const dictionaryPath = getDictionaryPath(this.genKey(key));
5224
- let current = this.getMutableCache();
5225
- if (dictionaryPath.length === 0) return current;
5226
- for (const pathSegment of dictionaryPath) {
5227
- if (!isDictionaryValue(current)) return;
5228
- current = current[pathSegment];
5229
- }
5230
- return current;
5231
- }
5232
- /**
5233
- * Generate a key for the cache
5234
- * @param key - The dictionary key
5235
- * @returns The key
5236
- */
5237
- genKey(key) {
5238
- return key;
5239
- }
5240
- /**
5241
- * Get the fallback value for a cache miss
5242
- * @param key - The dictionary key
5243
- * @returns The fallback value
5244
- *
5245
- * @throws {Error} - If the fallback is not implemented
5246
- */
5247
- fallback(key, sourceEntry) {
5248
- return this._runtimeTranslate(key, sourceEntry);
5249
- }
5250
- };
5251
- /**
5252
- * Cache for looking up dictionaries by locale
5253
- */
5254
- var LocalesDictionaryCache = class extends Cache {
5255
- /**
5256
- * Constructor
5257
- * @param {Object} params - The parameters for the cache
5258
- * @param {number | null} params.ttl - The time to live for cache entries
5259
- * @param {DictionaryLoader} params.loadDictionary - The dictionary loader function
5260
- */
5261
- constructor({ ttl, defaultLocale, dictionary = {}, loadDictionary, runtimeTranslate, lifecycle: { onLocalesDictionaryCacheHit: onHit, onLocalesDictionaryCacheMiss: onMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } }) {
5262
- super({}, {
5263
- onHit,
5264
- onMiss
5265
- });
5266
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
5267
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
5268
- this._dictionaryLoader = loadDictionary;
5269
- this._runtimeTranslate = runtimeTranslate;
5270
- this._onDictionaryCacheHit = onDictionaryCacheHit;
5271
- this._onDictionaryCacheMiss = onDictionaryCacheMiss;
5272
- this._onDictionaryObjectCacheHit = onDictionaryObjectCacheHit;
5273
- this.setCache(defaultLocale, {
5274
- dictionaryCache: new DictionaryCache({
5275
- init: dictionary,
5276
- runtimeTranslate: this._createDictionaryRuntimeTranslate(defaultLocale),
5277
- lifecycle: this._createDictionaryCacheLifecycle(defaultLocale)
5278
- }),
5279
- expiresAt: -1
5280
- });
5281
- }
5282
- /**
5283
- * Get the dictionary for a given locale
5284
- * @param key - The locale
5285
- * @returns The dictionary
5286
- */
5287
- get(key) {
5288
- const entry = this.getCache(key);
5289
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
5290
- const value = entry.dictionaryCache;
5291
- if (value != null && this.onHit) this.onHit({
5292
- inputKey: key,
5293
- cacheKey: this.genKey(key),
5294
- cacheValue: entry,
5295
- outputValue: value
5296
- });
5297
- return value;
5298
- }
5299
- /**
5300
- * Miss the cache
5301
- * @param key - The locale
5302
- * @returns The dictionary cache
5303
- */
5304
- async miss(key) {
5305
- const cacheValue = await this.missCache(key);
5306
- const value = cacheValue.dictionaryCache;
5307
- if (value != null && this.onMiss) this.onMiss({
5308
- inputKey: key,
5309
- cacheKey: this.genKey(key),
5310
- cacheValue,
5311
- outputValue: value
5312
- });
5313
- return value;
5314
- }
5315
- /**
5316
- * Generate the cache key for a given locale
5317
- * @param key - The locale
5318
- * @returns The cache key
5319
- *
5320
- * This is just an identity function, no transformation needed
5321
- */
5322
- genKey(key) {
5323
- return key;
5324
- }
5325
- /**
5326
- * Fallback for a cache miss
5327
- * @param locale - The locale
5328
- * @returns The cache entry
5329
- */
5330
- async fallback(locale) {
5331
- return {
5332
- dictionaryCache: new DictionaryCache({
5333
- init: await this._dictionaryLoader(locale),
5334
- runtimeTranslate: this._createDictionaryRuntimeTranslate(locale),
5335
- lifecycle: this._createDictionaryCacheLifecycle(locale)
5336
- }),
5337
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
5338
- };
5339
- }
5340
- /**
5341
- * Create the dictionary cache lifecycle
5342
- * @param locale - The locale
5343
- * @returns The dictionary cache lifecycle
5344
- */
5345
- _createDictionaryCacheLifecycle(locale) {
5346
- return {
5347
- onHit: this._onDictionaryCacheHit ? (params) => this._onDictionaryCacheHit({
5348
- locale,
5349
- ...params
5350
- }) : void 0,
5351
- onMiss: this._onDictionaryCacheMiss ? (params) => this._onDictionaryCacheMiss({
5352
- locale,
5353
- ...params
5354
- }) : void 0,
5355
- onHitObj: this._onDictionaryObjectCacheHit ? (params) => this._onDictionaryObjectCacheHit({
5356
- locale,
5357
- ...params
5358
- }) : void 0
5359
- };
5360
- }
5361
- _createDictionaryRuntimeTranslate(locale) {
5362
- return (key, sourceEntry) => this._runtimeTranslate(locale, key, sourceEntry);
5363
- }
5364
- };
5203
+ const LOCALES_CACHE_HIT_EVENT_NAME = "locales-cache-hit";
5365
5204
  const LOCALES_CACHE_MISS_EVENT_NAME = "locales-cache-miss";
5205
+ const TRANSLATIONS_CACHE_HIT_EVENT_NAME = "translations-cache-hit";
5366
5206
  const TRANSLATIONS_CACHE_MISS_EVENT_NAME = "translations-cache-miss";
5207
+ const LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME = "locales-dictionary-cache-hit";
5367
5208
  const LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME = "locales-dictionary-cache-miss";
5209
+ const DICTIONARY_CACHE_HIT_EVENT_NAME = "dictionary-cache-hit";
5368
5210
  const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5211
+ const DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME = "dictionary-object-cache-hit";
5369
5212
  /**
5370
5213
  * Maps consumer-facing lifecycle callbacks to internal locales cache lifecycle callbacks.
5371
5214
  * The consumer API exposes simplified params (locale, hash, value) while the internal
@@ -5373,22 +5216,24 @@ const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5373
5216
  *
5374
5217
  * @deprecated - move to subscription api instead
5375
5218
  */
5376
- function createLifecycleCallbacks(emit) {
5219
+ function createLifecycleCallbacks(emit, hasListeners = () => true) {
5377
5220
  return {
5378
5221
  onLocalesCacheHit: (params) => {
5379
- emit("locales-cache-hit", {
5222
+ if (!hasListeners("locales-cache-hit")) return;
5223
+ emit(LOCALES_CACHE_HIT_EVENT_NAME, {
5380
5224
  locale: params.inputKey,
5381
5225
  translations: params.outputValue.getInternalCache()
5382
5226
  });
5383
5227
  },
5384
5228
  onLocalesCacheMiss: (params) => {
5229
+ if (!hasListeners("locales-cache-miss")) return;
5385
5230
  emit(LOCALES_CACHE_MISS_EVENT_NAME, {
5386
5231
  locale: params.inputKey,
5387
5232
  translations: params.outputValue.getInternalCache()
5388
5233
  });
5389
5234
  },
5390
5235
  onTranslationsCacheHit: (params) => {
5391
- emit("translations-cache-hit", {
5236
+ emit(TRANSLATIONS_CACHE_HIT_EVENT_NAME, {
5392
5237
  locale: params.locale,
5393
5238
  hash: params.cacheKey,
5394
5239
  translation: params.outputValue
@@ -5402,19 +5247,21 @@ function createLifecycleCallbacks(emit) {
5402
5247
  });
5403
5248
  },
5404
5249
  onLocalesDictionaryCacheHit: (params) => {
5405
- emit("locales-dictionary-cache-hit", {
5250
+ if (!hasListeners("locales-dictionary-cache-hit")) return;
5251
+ emit(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, {
5406
5252
  locale: params.inputKey,
5407
5253
  dictionary: params.outputValue.getInternalCache()
5408
5254
  });
5409
5255
  },
5410
5256
  onLocalesDictionaryCacheMiss: (params) => {
5257
+ if (!hasListeners("locales-dictionary-cache-miss")) return;
5411
5258
  emit(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, {
5412
5259
  locale: params.inputKey,
5413
5260
  dictionary: params.outputValue.getInternalCache()
5414
5261
  });
5415
5262
  },
5416
5263
  onDictionaryCacheHit: (params) => {
5417
- emit("dictionary-cache-hit", {
5264
+ emit(DICTIONARY_CACHE_HIT_EVENT_NAME, {
5418
5265
  locale: params.locale,
5419
5266
  id: params.cacheKey,
5420
5267
  dictionaryEntry: params.outputValue
@@ -5428,7 +5275,7 @@ function createLifecycleCallbacks(emit) {
5428
5275
  });
5429
5276
  },
5430
5277
  onDictionaryObjectCacheHit: (params) => {
5431
- emit("dictionary-object-cache-hit", {
5278
+ emit(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, {
5432
5279
  locale: params.locale,
5433
5280
  id: params.cacheKey,
5434
5281
  dictionaryValue: params.outputValue
@@ -5463,6 +5310,9 @@ var EventEmitter = class {
5463
5310
  emit(eventName, event) {
5464
5311
  this.listeners[eventName]?.forEach((subscriber) => subscriber(event));
5465
5312
  }
5313
+ hasListeners(eventName) {
5314
+ return (this.listeners[eventName]?.size ?? 0) > 0;
5315
+ }
5466
5316
  };
5467
5317
  /**
5468
5318
  * Subscribes to the lifecycle callbacks and emits the events to the event emitter
@@ -5472,7 +5322,7 @@ var EventEmitter = class {
5472
5322
  * and is only used internally
5473
5323
  */
5474
5324
  function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, onTranslationsCacheHit, onTranslationsCacheMiss, onLocalesDictionaryCacheHit, onLocalesDictionaryCacheMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit }, subscribe) {
5475
- if (onLocalesCacheHit) subscribe("locales-cache-hit", (event) => {
5325
+ if (onLocalesCacheHit) subscribe(LOCALES_CACHE_HIT_EVENT_NAME, (event) => {
5476
5326
  onLocalesCacheHit({
5477
5327
  ...event,
5478
5328
  value: event.translations
@@ -5484,7 +5334,7 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5484
5334
  value: event.translations
5485
5335
  });
5486
5336
  });
5487
- if (onTranslationsCacheHit) subscribe("translations-cache-hit", (event) => {
5337
+ if (onTranslationsCacheHit) subscribe(TRANSLATIONS_CACHE_HIT_EVENT_NAME, (event) => {
5488
5338
  onTranslationsCacheHit({
5489
5339
  ...event,
5490
5340
  value: event.translation
@@ -5496,19 +5346,19 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5496
5346
  value: event.translation
5497
5347
  });
5498
5348
  });
5499
- if (onLocalesDictionaryCacheHit) subscribe("locales-dictionary-cache-hit", (event) => {
5349
+ if (onLocalesDictionaryCacheHit) subscribe(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5500
5350
  onLocalesDictionaryCacheHit(event);
5501
5351
  });
5502
5352
  if (onLocalesDictionaryCacheMiss) subscribe(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5503
5353
  onLocalesDictionaryCacheMiss(event);
5504
5354
  });
5505
- if (onDictionaryCacheHit) subscribe("dictionary-cache-hit", (event) => {
5355
+ if (onDictionaryCacheHit) subscribe(DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5506
5356
  onDictionaryCacheHit(event);
5507
5357
  });
5508
5358
  if (onDictionaryCacheMiss) subscribe(DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5509
5359
  onDictionaryCacheMiss(event);
5510
5360
  });
5511
- if (onDictionaryObjectCacheHit) subscribe("dictionary-object-cache-hit", (event) => {
5361
+ if (onDictionaryObjectCacheHit) subscribe(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, (event) => {
5512
5362
  onDictionaryObjectCacheHit(event);
5513
5363
  });
5514
5364
  }
@@ -5539,26 +5389,32 @@ var I18nManager = class extends EventEmitter {
5539
5389
  locales: this.config.locales,
5540
5390
  customMapping: this.config.customMapping
5541
5391
  });
5542
- const loadTranslations = createTranslationLoader(params);
5543
- const loadDictionary = createDictionaryLoader(params);
5392
+ const loadTranslations = routeCreateTranslationLoader({
5393
+ loadTranslations: params.loadTranslations,
5394
+ type: getLoadTranslationsType(params),
5395
+ remoteTranslationLoaderParams: {
5396
+ cacheUrl: params.cacheUrl,
5397
+ projectId: params.projectId,
5398
+ _versionId: params._versionId,
5399
+ _branchId: params._branchId,
5400
+ customMapping: params.customMapping
5401
+ }
5402
+ });
5403
+ const loadDictionary = params.loadDictionary ?? (() => Promise.resolve({}));
5544
5404
  const runtimeTranslationTimeout = this.config.runtimeTranslation?.timeout ?? DEFAULT_TRANSLATION_TIMEOUT;
5545
5405
  const runtimeTranslationMetadata = this.config.runtimeTranslation?.metadata ?? {};
5546
5406
  const createTranslateMany = createTranslateManyFactory(this.getGTClassClean(), runtimeTranslationTimeout, runtimeTranslationMetadata);
5547
5407
  subscribeLifecycleCallbacks(params.lifecycle ?? {}, (...args) => this.subscribe(...args));
5548
- const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args));
5408
+ const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args), (eventName) => this.hasListeners(eventName));
5549
5409
  this.localesCache = new LocalesCache({
5550
- loadTranslations,
5551
- createTranslateMany,
5552
- lifecycle,
5553
- ttl: this.config.cacheExpiryTime,
5554
- batchConfig: this.config.batchConfig
5555
- });
5556
- this.localesDictionaryCache = new LocalesDictionaryCache({
5557
5410
  defaultLocale: this.config.defaultLocale,
5558
5411
  dictionary: params.dictionary,
5412
+ loadTranslations,
5559
5413
  loadDictionary,
5560
- runtimeTranslate: (locale, id, sourceEntry) => this.dictionaryRuntimeTranslate(locale, id, sourceEntry),
5414
+ createTranslateMany,
5415
+ translateDictionaryEntry: (locale, id, sourceEntry) => this.translateDictionaryEntry(locale, id, sourceEntry),
5561
5416
  ttl: this.config.cacheExpiryTime,
5417
+ batchConfig: this.config.batchConfig,
5562
5418
  lifecycle
5563
5419
  });
5564
5420
  }
@@ -5630,9 +5486,7 @@ var I18nManager = class extends EventEmitter {
5630
5486
  try {
5631
5487
  const translationLocale = this.resolveCacheLocale(locale);
5632
5488
  if (!translationLocale) return {};
5633
- let txCache = this.localesCache.get(translationLocale);
5634
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5635
- return txCache.getInternalCache();
5489
+ return (await this.localesCache.getOrLoadTranslations(translationLocale)).getInternalCache();
5636
5490
  } catch (error) {
5637
5491
  this.handleError(error);
5638
5492
  return {};
@@ -5645,10 +5499,8 @@ var I18nManager = class extends EventEmitter {
5645
5499
  async loadDictionary(locale) {
5646
5500
  try {
5647
5501
  const dictionaryLocale = this.resolveCacheLocale(locale);
5648
- if (!dictionaryLocale) return this.localesDictionaryCache.get(this.config.defaultLocale)?.getInternalCache() ?? {};
5649
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5650
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5651
- return dictionaryCache.getInternalCache();
5502
+ if (!dictionaryLocale) return this.getDefaultDictionaryCache()?.getInternalCache() ?? {};
5503
+ return (await this.localesCache.getOrLoadDictionary(dictionaryLocale)).getInternalCache();
5652
5504
  } catch (error) {
5653
5505
  this.handleError(error);
5654
5506
  return {};
@@ -5659,8 +5511,8 @@ var I18nManager = class extends EventEmitter {
5659
5511
  */
5660
5512
  lookupDictionary(locale, id) {
5661
5513
  try {
5662
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5663
- return this.localesDictionaryCache.get(dictionaryLocale)?.get(id);
5514
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5515
+ return this.localesCache.getDictionary(dictionaryLocale)?.getEntry(id);
5664
5516
  } catch (error) {
5665
5517
  this.handleError(error);
5666
5518
  return;
@@ -5671,8 +5523,8 @@ var I18nManager = class extends EventEmitter {
5671
5523
  */
5672
5524
  lookupDictionaryObj(locale, id) {
5673
5525
  try {
5674
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5675
- return this.localesDictionaryCache.get(dictionaryLocale)?.getObj(id);
5526
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5527
+ return this.localesCache.getDictionary(dictionaryLocale)?.getValue(id);
5676
5528
  } catch (error) {
5677
5529
  this.handleError(error);
5678
5530
  return;
@@ -5685,19 +5537,10 @@ var I18nManager = class extends EventEmitter {
5685
5537
  async lookupDictionaryWithFallback(locale, id) {
5686
5538
  try {
5687
5539
  const dictionaryLocale = this.resolveCacheLocale(locale);
5688
- if (!dictionaryLocale) {
5689
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5690
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5691
- return sourceEntry;
5692
- }
5693
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5694
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5695
- let dictionaryEntry = dictionaryCache.get(id);
5696
- if (dictionaryEntry === void 0) {
5697
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5698
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5699
- dictionaryEntry = await dictionaryCache.miss(id, sourceEntry);
5700
- }
5540
+ if (!dictionaryLocale) return this.getSourceDictionaryEntry(id);
5541
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5542
+ let dictionaryEntry = dictionaryCache.getEntry(id);
5543
+ if (dictionaryEntry === void 0) dictionaryEntry = await dictionaryCache.materializeEntry(id, this.getSourceDictionaryEntry(id));
5701
5544
  return dictionaryEntry;
5702
5545
  } catch (error) {
5703
5546
  this.handleError(error);
@@ -5711,25 +5554,41 @@ var I18nManager = class extends EventEmitter {
5711
5554
  async lookupDictionaryObjWithFallback(locale, id) {
5712
5555
  try {
5713
5556
  const dictionaryLocale = this.resolveCacheLocale(locale);
5714
- if (!dictionaryLocale) {
5715
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5716
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5717
- return sourceObject;
5557
+ if (!dictionaryLocale) return this.getSourceDictionaryObject(id);
5558
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5559
+ const targetObject = dictionaryCache.getValue(id);
5560
+ const sourceObject = this.getSourceDictionaryObject(id, { throwOnMissing: false });
5561
+ if (sourceObject === void 0) {
5562
+ if (targetObject !== void 0) return targetObject;
5563
+ throw new DictionarySourceNotFoundError(id);
5718
5564
  }
5719
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5720
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5721
- let dictionaryObject = dictionaryCache.getObj(id);
5722
- if (dictionaryObject === void 0) {
5723
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5724
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5725
- dictionaryObject = await dictionaryCache.missObj(id, sourceObject);
5726
- }
5727
- return dictionaryObject;
5565
+ return await dictionaryCache.materializeValue(id, sourceObject, targetObject);
5728
5566
  } catch (error) {
5729
5567
  this.handleError(error);
5730
5568
  return;
5731
5569
  }
5732
5570
  }
5571
+ async translateDictionaryEntry(locale, id, sourceEntry) {
5572
+ const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5573
+ if (typeof translation !== "string") throw new Error(`Dictionary entry "${id}" could not be translated into a string. Check the source entry and translation loader output.`);
5574
+ return translation;
5575
+ }
5576
+ getSourceDictionaryEntry(id) {
5577
+ const sourceEntry = this.getDefaultDictionaryCache()?.getEntry(id);
5578
+ if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5579
+ return sourceEntry;
5580
+ }
5581
+ getSourceDictionaryObject(id, { throwOnMissing = true } = {}) {
5582
+ const sourceObject = this.getDefaultDictionaryCache()?.getValue(id);
5583
+ if (sourceObject === void 0 && throwOnMissing) throw new DictionarySourceNotFoundError(id);
5584
+ return sourceObject;
5585
+ }
5586
+ getDefaultDictionaryCache() {
5587
+ return this.localesCache.getDictionary(this.config.defaultLocale);
5588
+ }
5589
+ resolveDictionaryCacheLocale(locale) {
5590
+ return this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5591
+ }
5733
5592
  /**
5734
5593
  * Just lookup a translation
5735
5594
  */
@@ -5737,7 +5596,7 @@ var I18nManager = class extends EventEmitter {
5737
5596
  try {
5738
5597
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5739
5598
  if (!translationLocale) return message;
5740
- const txCache = this.localesCache.get(translationLocale);
5599
+ const txCache = this.localesCache.getTranslations(translationLocale);
5741
5600
  if (!txCache) return void 0;
5742
5601
  return txCache.get({
5743
5602
  message,
@@ -5775,9 +5634,7 @@ var I18nManager = class extends EventEmitter {
5775
5634
  if (!translationLocale) return (message) => message;
5776
5635
  const resolvedPrefetchEntries = resolvePrefetchEntriesByLocale(prefetchEntries, translationLocale, (entryLocale) => this.resolveCacheLocale(entryLocale) ?? this.resolveLocale(entryLocale));
5777
5636
  if (resolvedPrefetchEntries.length !== prefetchEntries.length) logger_default.warn(`I18nManager: getLookupTranslation(): prefetchEntries must all be the same locale, ignoring all entries that are not for ${translationLocale}`);
5778
- let txCache = this.localesCache.get(translationLocale);
5779
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5780
- if (!txCache) return () => void 0;
5637
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5781
5638
  await Promise.all(resolvedPrefetchEntries.filter((entry) => txCache.get(entry) == null).map((entry) => txCache.miss(entry)));
5782
5639
  return (message, options = {}) => {
5783
5640
  return txCache.get({
@@ -5879,8 +5736,7 @@ var I18nManager = class extends EventEmitter {
5879
5736
  async lookupTranslationWithFallbackResolved(locale, message, options) {
5880
5737
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5881
5738
  if (!translationLocale) return message;
5882
- let txCache = this.localesCache.get(translationLocale);
5883
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5739
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5884
5740
  let translation = txCache.get({
5885
5741
  message,
5886
5742
  options: lookupOptions
@@ -5892,14 +5748,6 @@ var I18nManager = class extends EventEmitter {
5892
5748
  return translation;
5893
5749
  }
5894
5750
  /**
5895
- * Runtime lookup function for dictionaries
5896
- */
5897
- async dictionaryRuntimeTranslate(locale, id, sourceEntry) {
5898
- const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5899
- if (typeof translation !== "string") throw new Error(`Dictionary entry "${id}" could not be translated into a string. Check the source entry and translation loader output.`);
5900
- return translation;
5901
- }
5902
- /**
5903
5751
  * A helper function to create a gt class that is locale agnostic
5904
5752
  * This is helpful for when our getLocale function is bound to a
5905
5753
  * specific context
@@ -5996,28 +5844,6 @@ function resolvePrefetchEntriesByLocale(prefetchEntries, locale, resolveLocale)
5996
5844
  }
5997
5845
  });
5998
5846
  }
5999
- /**
6000
- * Helper function for creating a translation loader
6001
- */
6002
- function createTranslationLoader(params) {
6003
- return routeCreateTranslationLoader({
6004
- loadTranslations: params.loadTranslations,
6005
- type: getLoadTranslationsType(params),
6006
- remoteTranslationLoaderParams: {
6007
- cacheUrl: params.cacheUrl,
6008
- projectId: params.projectId,
6009
- _versionId: params._versionId,
6010
- _branchId: params._branchId,
6011
- customMapping: params.customMapping
6012
- }
6013
- });
6014
- }
6015
- /**
6016
- * Helper function for creating a dictionary loader
6017
- */
6018
- function createDictionaryLoader(params) {
6019
- return params.loadDictionary ?? (() => Promise.resolve({}));
6020
- }
6021
5847
  let i18nManager = void 0;
6022
5848
  let fallbackDefaultLocale = "en";
6023
5849
  const fallbackConditionStore = { getLocale: () => fallbackDefaultLocale };
@@ -6356,7 +6182,7 @@ function S({ source: e, severity: t, whatHappened: n, reassurance: r, why: i, fi
6356
6182
  let p = f.join(` `);
6357
6183
  return l ? `${l} ${p}` : p;
6358
6184
  }
6359
- function E(e) {
6185
+ function ie(e) {
6360
6186
  let t = e;
6361
6187
  if (t && typeof t == `object` && typeof t.k == `string`) {
6362
6188
  let e = Object.keys(t);
@@ -6364,43 +6190,43 @@ function E(e) {
6364
6190
  }
6365
6191
  return !1;
6366
6192
  }
6367
- function ie(e) {
6193
+ function ae(e) {
6368
6194
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === `Uint8Array` && `BYTES_PER_ELEMENT` in e && e.BYTES_PER_ELEMENT === 1;
6369
6195
  }
6370
- function D(e, t, n = ``) {
6371
- let r = ie(e), i = e?.length, a = t !== void 0;
6196
+ function E(e, t, n = ``) {
6197
+ let r = ae(e), i = e?.length, a = t !== void 0;
6372
6198
  if (!r || a && i !== t) {
6373
6199
  let o = n && `"${n}" `, s = a ? ` of length ${t}` : ``, c = r ? `length=${i}` : `type=${typeof e}`, l = o + `expected Uint8Array` + s + `, got ` + c;
6374
6200
  throw r ? RangeError(l) : TypeError(l);
6375
6201
  }
6376
6202
  return e;
6377
6203
  }
6378
- function ae(e, t = !0) {
6204
+ function oe(e, t = !0) {
6379
6205
  if (e.destroyed) throw Error(`Hash instance has been destroyed`);
6380
6206
  if (t && e.finished) throw Error(`Hash#digest() has already been called`);
6381
6207
  }
6382
- function oe(e, t) {
6383
- D(e, void 0, `digestInto() output`);
6208
+ function se(e, t) {
6209
+ E(e, void 0, `digestInto() output`);
6384
6210
  let n = t.outputLen;
6385
6211
  if (e.length < n) throw RangeError(`"digestInto() output" expected to be of length >=` + n);
6386
6212
  }
6387
- function se(...e) {
6213
+ function ce(...e) {
6388
6214
  for (let t = 0; t < e.length; t++) e[t].fill(0);
6389
6215
  }
6390
- function ce(e) {
6216
+ function le(e) {
6391
6217
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
6392
6218
  }
6393
- function O(e, t) {
6219
+ function D(e, t) {
6394
6220
  return e << 32 - t | e >>> t;
6395
6221
  }
6396
6222
  new Uint8Array(new Uint32Array([287454020]).buffer)[0];
6397
6223
  typeof Uint8Array.from([]).toHex == `function` && Uint8Array.fromHex;
6398
6224
  Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, `0`));
6399
- function pe(e, t = {}) {
6225
+ function me(e, t = {}) {
6400
6226
  let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
6401
6227
  return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
6402
6228
  }
6403
- const me = (e) => ({ oid: Uint8Array.from([
6229
+ const he = (e) => ({ oid: Uint8Array.from([
6404
6230
  6,
6405
6231
  9,
6406
6232
  96,
@@ -6413,13 +6239,13 @@ const me = (e) => ({ oid: Uint8Array.from([
6413
6239
  2,
6414
6240
  e
6415
6241
  ]) });
6416
- function he(e, t, n) {
6242
+ function ge(e, t, n) {
6417
6243
  return e & t ^ ~e & n;
6418
6244
  }
6419
- function ge(e, t, n) {
6245
+ function _e(e, t, n) {
6420
6246
  return e & t ^ e & n ^ t & n;
6421
6247
  }
6422
- var _e = class {
6248
+ var ve = class {
6423
6249
  blockLen;
6424
6250
  outputLen;
6425
6251
  canXOF = !1;
@@ -6432,15 +6258,15 @@ var _e = class {
6432
6258
  pos = 0;
6433
6259
  destroyed = !1;
6434
6260
  constructor(e, t, n, r) {
6435
- this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = ce(this.buffer);
6261
+ this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = le(this.buffer);
6436
6262
  }
6437
6263
  update(e) {
6438
- ae(this), D(e);
6264
+ oe(this), E(e);
6439
6265
  let { view: t, buffer: n, blockLen: r } = this, i = e.length;
6440
6266
  for (let a = 0; a < i;) {
6441
6267
  let o = Math.min(r - this.pos, i - a);
6442
6268
  if (o === r) {
6443
- let t = ce(e);
6269
+ let t = le(e);
6444
6270
  for (; r <= i - a; a += r) this.process(t, a);
6445
6271
  continue;
6446
6272
  }
@@ -6449,12 +6275,12 @@ var _e = class {
6449
6275
  return this.length += e.length, this.roundClean(), this;
6450
6276
  }
6451
6277
  digestInto(e) {
6452
- ae(this), oe(e, this), this.finished = !0;
6278
+ oe(this), se(e, this), this.finished = !0;
6453
6279
  let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
6454
- t[a++] = 128, se(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6280
+ t[a++] = 128, ce(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6455
6281
  for (let e = a; e < r; e++) t[e] = 0;
6456
6282
  n.setBigUint64(r - 8, BigInt(this.length * 8), i), this.process(n, 0);
6457
- let o = ce(e), s = this.outputLen;
6283
+ let o = le(e), s = this.outputLen;
6458
6284
  if (s % 4) throw Error(`_sha2: outputLen must be aligned to 32bit`);
6459
6285
  let c = s / 4, l = this.get();
6460
6286
  if (c > l.length) throw Error(`_sha2: outputLen bigger than state`);
@@ -6475,7 +6301,7 @@ var _e = class {
6475
6301
  return this._cloneInto();
6476
6302
  }
6477
6303
  };
6478
- const k = Uint32Array.from([
6304
+ const O = Uint32Array.from([
6479
6305
  1779033703,
6480
6306
  3144134277,
6481
6307
  1013904242,
@@ -6484,25 +6310,25 @@ const k = Uint32Array.from([
6484
6310
  2600822924,
6485
6311
  528734635,
6486
6312
  1541459225
6487
- ]), A = BigInt(2 ** 32 - 1), ve = BigInt(32);
6488
- function ye(e, t = !1) {
6313
+ ]), k = BigInt(2 ** 32 - 1), ye = BigInt(32);
6314
+ function be(e, t = !1) {
6489
6315
  return t ? {
6490
- h: Number(e & A),
6491
- l: Number(e >> ve & A)
6316
+ h: Number(e & k),
6317
+ l: Number(e >> ye & k)
6492
6318
  } : {
6493
- h: Number(e >> ve & A) | 0,
6494
- l: Number(e & A) | 0
6319
+ h: Number(e >> ye & k) | 0,
6320
+ l: Number(e & k) | 0
6495
6321
  };
6496
6322
  }
6497
- function be(e, t = !1) {
6323
+ function xe(e, t = !1) {
6498
6324
  let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
6499
6325
  for (let a = 0; a < n; a++) {
6500
- let { h: n, l: o } = ye(e[a], t);
6326
+ let { h: n, l: o } = be(e[a], t);
6501
6327
  [r[a], i[a]] = [n, o];
6502
6328
  }
6503
6329
  return [r, i];
6504
6330
  }
6505
- const xe = Uint32Array.from([
6331
+ const Se = Uint32Array.from([
6506
6332
  1116352408,
6507
6333
  1899447441,
6508
6334
  3049323471,
@@ -6567,8 +6393,8 @@ const xe = Uint32Array.from([
6567
6393
  2756734187,
6568
6394
  3204031479,
6569
6395
  3329325298
6570
- ]), j = new Uint32Array(64);
6571
- var Se = class extends _e {
6396
+ ]), A = new Uint32Array(64);
6397
+ var Ce = class extends ve {
6572
6398
  constructor(e) {
6573
6399
  super(64, e, 8, !1);
6574
6400
  }
@@ -6589,41 +6415,41 @@ var Se = class extends _e {
6589
6415
  this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0, this.F = a | 0, this.G = o | 0, this.H = s | 0;
6590
6416
  }
6591
6417
  process(e, t) {
6592
- for (let n = 0; n < 16; n++, t += 4) j[n] = e.getUint32(t, !1);
6418
+ for (let n = 0; n < 16; n++, t += 4) A[n] = e.getUint32(t, !1);
6593
6419
  for (let e = 16; e < 64; e++) {
6594
- let t = j[e - 15], n = j[e - 2], r = O(t, 7) ^ O(t, 18) ^ t >>> 3;
6595
- j[e] = (O(n, 17) ^ O(n, 19) ^ n >>> 10) + j[e - 7] + r + j[e - 16] | 0;
6420
+ let t = A[e - 15], n = A[e - 2], r = D(t, 7) ^ D(t, 18) ^ t >>> 3;
6421
+ A[e] = (D(n, 17) ^ D(n, 19) ^ n >>> 10) + A[e - 7] + r + A[e - 16] | 0;
6596
6422
  }
6597
6423
  let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
6598
6424
  for (let e = 0; e < 64; e++) {
6599
- let t = O(o, 6) ^ O(o, 11) ^ O(o, 25), u = l + t + he(o, s, c) + xe[e] + j[e] | 0, d = (O(n, 2) ^ O(n, 13) ^ O(n, 22)) + ge(n, r, i) | 0;
6425
+ let t = D(o, 6) ^ D(o, 11) ^ D(o, 25), u = l + t + ge(o, s, c) + Se[e] + A[e] | 0, d = (D(n, 2) ^ D(n, 13) ^ D(n, 22)) + _e(n, r, i) | 0;
6600
6426
  l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
6601
6427
  }
6602
6428
  n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, s = s + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(n, r, i, a, o, s, c, l);
6603
6429
  }
6604
6430
  roundClean() {
6605
- se(j);
6431
+ ce(A);
6606
6432
  }
6607
6433
  destroy() {
6608
- this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), se(this.buffer);
6609
- }
6610
- }, Ce = class extends Se {
6611
- A = k[0] | 0;
6612
- B = k[1] | 0;
6613
- C = k[2] | 0;
6614
- D = k[3] | 0;
6615
- E = k[4] | 0;
6616
- F = k[5] | 0;
6617
- G = k[6] | 0;
6618
- H = k[7] | 0;
6434
+ this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), ce(this.buffer);
6435
+ }
6436
+ }, we = class extends Ce {
6437
+ A = O[0] | 0;
6438
+ B = O[1] | 0;
6439
+ C = O[2] | 0;
6440
+ D = O[3] | 0;
6441
+ E = O[4] | 0;
6442
+ F = O[5] | 0;
6443
+ G = O[6] | 0;
6444
+ H = O[7] | 0;
6619
6445
  constructor() {
6620
6446
  super(32);
6621
6447
  }
6622
6448
  };
6623
- const we = be(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map((e) => BigInt(e)));
6624
- we[0], we[1];
6625
- pe(() => new Ce(), me(1));
6626
- const Ee = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, De = `DEFAULT_TERMINATOR_KEY`, Oe = {
6449
+ const Te = xe(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map((e) => BigInt(e)));
6450
+ Te[0], Te[1];
6451
+ me(() => new we(), he(1));
6452
+ const De = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, Oe = `DEFAULT_TERMINATOR_KEY`, ke = {
6627
6453
  ellipsis: {
6628
6454
  fr: {
6629
6455
  terminator: `…`,
@@ -6637,17 +6463,17 @@ const Ee = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${
6637
6463
  terminator: `……`,
6638
6464
  separator: void 0
6639
6465
  },
6640
- [De]: {
6466
+ [Oe]: {
6641
6467
  terminator: `…`,
6642
6468
  separator: void 0
6643
6469
  }
6644
6470
  },
6645
- none: { [De]: {
6471
+ none: { [Oe]: {
6646
6472
  terminator: void 0,
6647
6473
  separator: void 0
6648
6474
  } }
6649
6475
  };
6650
- var ke = class e {
6476
+ var Ae = class e {
6651
6477
  static resolveLocale(e) {
6652
6478
  try {
6653
6479
  let t = e ? Array.isArray(e) ? e.map(String) : [String(e)] : [`en`], [n] = Intl.getCanonicalLocales(t);
@@ -6659,8 +6485,8 @@ var ke = class e {
6659
6485
  constructor(t, n = {}) {
6660
6486
  this.locale = e.resolveLocale(t);
6661
6487
  let r = n.style ?? `ellipsis`;
6662
- if (!Oe[r]) throw Error(Ee(r));
6663
- let i = n.maxChars === void 0 ? void 0 : Oe[r][new Intl.Locale(this.locale).language] || Oe[r].DEFAULT_TERMINATOR_KEY, a = n.terminator ?? i?.terminator, o = a == null ? void 0 : n.separator ?? i?.separator;
6488
+ if (!ke[r]) throw Error(De(r));
6489
+ let i = n.maxChars === void 0 ? void 0 : ke[r][new Intl.Locale(this.locale).language] || ke[r].DEFAULT_TERMINATOR_KEY, a = n.terminator ?? i?.terminator, o = a == null ? void 0 : n.separator ?? i?.separator;
6664
6490
  this.additionLength = (a?.length ?? 0) + (o?.length ?? 0), n.maxChars !== void 0 && Math.abs(n.maxChars) < this.additionLength && (a = void 0, o = void 0), this.options = {
6665
6491
  maxChars: n.maxChars,
6666
6492
  style: n.maxChars === void 0 ? void 0 : r,
@@ -6687,7 +6513,7 @@ var ke = class e {
6687
6513
  return this.options;
6688
6514
  }
6689
6515
  };
6690
- const Ae = {
6516
+ const je = {
6691
6517
  Collator: Intl.Collator,
6692
6518
  DateTimeFormat: Intl.DateTimeFormat,
6693
6519
  DisplayNames: Intl.DisplayNames,
@@ -6697,8 +6523,8 @@ const Ae = {
6697
6523
  PluralRules: Intl.PluralRules,
6698
6524
  RelativeTimeFormat: Intl.RelativeTimeFormat,
6699
6525
  Segmenter: Intl.Segmenter,
6700
- CutoffFormat: ke
6701
- }, je = new class {
6526
+ CutoffFormat: Ae
6527
+ }, Me = new class {
6702
6528
  constructor() {
6703
6529
  this.cache = {};
6704
6530
  }
@@ -6709,73 +6535,73 @@ const Ae = {
6709
6535
  let [n = `en`, r = {}] = t, i = this.generateKey(n, r), a = this.cache[e];
6710
6536
  a === void 0 && (a = {}, this.cache[e] = a);
6711
6537
  let o = a[i];
6712
- return o === void 0 && (o = new Ae[e](...t), a[i] = o), o;
6538
+ return o === void 0 && (o = new je[e](...t), a[i] = o), o;
6713
6539
  }
6714
6540
  }();
6715
- function Me(e) {
6716
- return je.get(`PluralRules`, e);
6541
+ function Ne(e) {
6542
+ return Me.get(`PluralRules`, e);
6717
6543
  }
6718
- var M = m({
6719
- __addDisposableResource: () => it,
6544
+ var j = m({
6545
+ __addDisposableResource: () => at,
6720
6546
  __assign: () => F,
6721
- __asyncDelegator: () => Xe,
6722
- __asyncGenerator: () => Ye,
6723
- __asyncValues: () => Ze,
6724
- __await: () => P,
6725
- __awaiter: () => He,
6726
- __classPrivateFieldGet: () => tt,
6727
- __classPrivateFieldIn: () => rt,
6728
- __classPrivateFieldSet: () => nt,
6547
+ __asyncDelegator: () => Ze,
6548
+ __asyncGenerator: () => Xe,
6549
+ __asyncValues: () => Qe,
6550
+ __await: () => N,
6551
+ __awaiter: () => Ue,
6552
+ __classPrivateFieldGet: () => nt,
6553
+ __classPrivateFieldIn: () => it,
6554
+ __classPrivateFieldSet: () => rt,
6729
6555
  __createBinding: () => I,
6730
- __decorate: () => Fe,
6731
- __disposeResources: () => at,
6732
- __esDecorate: () => Le,
6733
- __exportStar: () => We,
6734
- __extends: () => Ne,
6735
- __generator: () => Ue,
6736
- __importDefault: () => et,
6737
- __importStar: () => $e,
6738
- __makeTemplateObject: () => Qe,
6739
- __metadata: () => Ve,
6740
- __param: () => Ie,
6741
- __propKey: () => ze,
6742
- __read: () => Ge,
6743
- __rest: () => Pe,
6744
- __rewriteRelativeImportExtension: () => ot,
6745
- __runInitializers: () => Re,
6746
- __setFunctionName: () => Be,
6747
- __spread: () => Ke,
6748
- __spreadArray: () => Je,
6749
- __spreadArrays: () => qe,
6750
- __values: () => N,
6556
+ __decorate: () => Ie,
6557
+ __disposeResources: () => ot,
6558
+ __esDecorate: () => Re,
6559
+ __exportStar: () => Ge,
6560
+ __extends: () => Pe,
6561
+ __generator: () => We,
6562
+ __importDefault: () => tt,
6563
+ __importStar: () => et,
6564
+ __makeTemplateObject: () => $e,
6565
+ __metadata: () => He,
6566
+ __param: () => Le,
6567
+ __propKey: () => Be,
6568
+ __read: () => Ke,
6569
+ __rest: () => Fe,
6570
+ __rewriteRelativeImportExtension: () => st,
6571
+ __runInitializers: () => ze,
6572
+ __setFunctionName: () => Ve,
6573
+ __spread: () => qe,
6574
+ __spreadArray: () => Ye,
6575
+ __spreadArrays: () => Je,
6576
+ __values: () => M,
6751
6577
  default: () => ut
6752
6578
  });
6753
- function Ne(e, t) {
6579
+ function Pe(e, t) {
6754
6580
  if (typeof t != `function` && t !== null) throw TypeError(`Class extends value ` + String(t) + ` is not a constructor or null`);
6755
- st(e, t);
6581
+ P(e, t);
6756
6582
  function n() {
6757
6583
  this.constructor = e;
6758
6584
  }
6759
6585
  e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
6760
6586
  }
6761
- function Pe(e, t) {
6587
+ function Fe(e, t) {
6762
6588
  var n = {};
6763
6589
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
6764
6590
  if (e != null && typeof Object.getOwnPropertySymbols == `function`) for (var i = 0, r = Object.getOwnPropertySymbols(e); i < r.length; i++) t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]);
6765
6591
  return n;
6766
6592
  }
6767
- function Fe(e, t, n, r) {
6593
+ function Ie(e, t, n, r) {
6768
6594
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
6769
6595
  if (typeof Reflect == `object` && typeof Reflect.decorate == `function`) a = Reflect.decorate(e, t, n, r);
6770
6596
  else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
6771
6597
  return i > 3 && a && Object.defineProperty(t, n, a), a;
6772
6598
  }
6773
- function Ie(e, t) {
6599
+ function Le(e, t) {
6774
6600
  return function(n, r) {
6775
6601
  t(n, r, e);
6776
6602
  };
6777
6603
  }
6778
- function Le(e, t, n, r, i, a) {
6604
+ function Re(e, t, n, r, i, a) {
6779
6605
  function o(e) {
6780
6606
  if (e !== void 0 && typeof e != `function`) throw TypeError(`Function expected`);
6781
6607
  return e;
@@ -6800,23 +6626,23 @@ function Le(e, t, n, r, i, a) {
6800
6626
  }
6801
6627
  l && Object.defineProperty(l, r.name, u), f = !0;
6802
6628
  }
6803
- function Re(e, t, n) {
6629
+ function ze(e, t, n) {
6804
6630
  for (var r = arguments.length > 2, i = 0; i < t.length; i++) n = r ? t[i].call(e, n) : t[i].call(e);
6805
6631
  return r ? n : void 0;
6806
6632
  }
6807
- function ze(e) {
6633
+ function Be(e) {
6808
6634
  return typeof e == `symbol` ? e : `${e}`;
6809
6635
  }
6810
- function Be(e, t, n) {
6636
+ function Ve(e, t, n) {
6811
6637
  return typeof t == `symbol` && (t = t.description ? `[${t.description}]` : ``), Object.defineProperty(e, `name`, {
6812
6638
  configurable: !0,
6813
6639
  value: n ? `${n} ${t}` : t
6814
6640
  });
6815
6641
  }
6816
- function Ve(e, t) {
6642
+ function He(e, t) {
6817
6643
  if (typeof Reflect == `object` && typeof Reflect.metadata == `function`) return Reflect.metadata(e, t);
6818
6644
  }
6819
- function He(e, t, n, r) {
6645
+ function Ue(e, t, n, r) {
6820
6646
  function i(e) {
6821
6647
  return e instanceof n ? e : new n(function(t) {
6822
6648
  t(e);
@@ -6843,7 +6669,7 @@ function He(e, t, n, r) {
6843
6669
  c((r = r.apply(e, t || [])).next());
6844
6670
  });
6845
6671
  }
6846
- function Ue(e, t) {
6672
+ function We(e, t) {
6847
6673
  var n = {
6848
6674
  label: 0,
6849
6675
  sent: function() {
@@ -6913,10 +6739,10 @@ function Ue(e, t) {
6913
6739
  };
6914
6740
  }
6915
6741
  }
6916
- function We(e, t) {
6742
+ function Ge(e, t) {
6917
6743
  for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, n) && I(t, e, n);
6918
6744
  }
6919
- function N(e) {
6745
+ function M(e) {
6920
6746
  var t = typeof Symbol == `function` && Symbol.iterator, n = t && e[t], r = 0;
6921
6747
  if (n) return n.call(e);
6922
6748
  if (e && typeof e.length == `number`) return { next: function() {
@@ -6927,7 +6753,7 @@ function N(e) {
6927
6753
  } };
6928
6754
  throw TypeError(t ? `Object is not iterable.` : `Symbol.iterator is not defined.`);
6929
6755
  }
6930
- function Ge(e, t) {
6756
+ function Ke(e, t) {
6931
6757
  var n = typeof Symbol == `function` && e[Symbol.iterator];
6932
6758
  if (!n) return e;
6933
6759
  var r = n.call(e), i, a = [], o;
@@ -6944,23 +6770,23 @@ function Ge(e, t) {
6944
6770
  }
6945
6771
  return a;
6946
6772
  }
6947
- function Ke() {
6948
- for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ge(arguments[t]));
6773
+ function qe() {
6774
+ for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ke(arguments[t]));
6949
6775
  return e;
6950
6776
  }
6951
- function qe() {
6777
+ function Je() {
6952
6778
  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
6953
6779
  for (var r = Array(e), i = 0, t = 0; t < n; t++) for (var a = arguments[t], o = 0, s = a.length; o < s; o++, i++) r[i] = a[o];
6954
6780
  return r;
6955
6781
  }
6956
- function Je(e, t, n) {
6782
+ function Ye(e, t, n) {
6957
6783
  if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
6958
6784
  return e.concat(a || Array.prototype.slice.call(t));
6959
6785
  }
6960
- function P(e) {
6961
- return this instanceof P ? (this.v = e, this) : new P(e);
6786
+ function N(e) {
6787
+ return this instanceof N ? (this.v = e, this) : new N(e);
6962
6788
  }
6963
- function Ye(e, t, n) {
6789
+ function Xe(e, t, n) {
6964
6790
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
6965
6791
  var r = n.apply(e, t || []), i, a = [];
6966
6792
  return i = Object.create((typeof AsyncIterator == `function` ? AsyncIterator : Object).prototype), s(`next`), s(`throw`), s(`return`, o), i[Symbol.asyncIterator] = function() {
@@ -6991,7 +6817,7 @@ function Ye(e, t, n) {
6991
6817
  }
6992
6818
  }
6993
6819
  function l(e) {
6994
- e.value instanceof P ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6820
+ e.value instanceof N ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6995
6821
  }
6996
6822
  function u(e) {
6997
6823
  c(`next`, e);
@@ -7003,7 +6829,7 @@ function Ye(e, t, n) {
7003
6829
  e(t), a.shift(), a.length && c(a[0][0], a[0][1]);
7004
6830
  }
7005
6831
  }
7006
- function Xe(e) {
6832
+ function Ze(e) {
7007
6833
  var t, n;
7008
6834
  return t = {}, r(`next`), r(`throw`, function(e) {
7009
6835
  throw e;
@@ -7013,16 +6839,16 @@ function Xe(e) {
7013
6839
  function r(r, i) {
7014
6840
  t[r] = e[r] ? function(t) {
7015
6841
  return (n = !n) ? {
7016
- value: P(e[r](t)),
6842
+ value: N(e[r](t)),
7017
6843
  done: !1
7018
6844
  } : i ? i(t) : t;
7019
6845
  } : i;
7020
6846
  }
7021
6847
  }
7022
- function Ze(e) {
6848
+ function Qe(e) {
7023
6849
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
7024
6850
  var t = e[Symbol.asyncIterator], n;
7025
- return t ? t.call(e) : (e = typeof N == `function` ? N(e) : e[Symbol.iterator](), n = {}, r(`next`), r(`throw`), r(`return`), n[Symbol.asyncIterator] = function() {
6851
+ return t ? t.call(e) : (e = typeof M == `function` ? M(e) : e[Symbol.iterator](), n = {}, r(`next`), r(`throw`), r(`return`), n[Symbol.asyncIterator] = function() {
7026
6852
  return this;
7027
6853
  }, n);
7028
6854
  function r(t) {
@@ -7041,34 +6867,34 @@ function Ze(e) {
7041
6867
  }, t);
7042
6868
  }
7043
6869
  }
7044
- function Qe(e, t) {
6870
+ function $e(e, t) {
7045
6871
  return Object.defineProperty ? Object.defineProperty(e, `raw`, { value: t }) : e.raw = t, e;
7046
6872
  }
7047
- function $e(e) {
6873
+ function et(e) {
7048
6874
  if (e && e.__esModule) return e;
7049
6875
  var t = {};
7050
6876
  if (e != null) for (var n = L(e), r = 0; r < n.length; r++) n[r] !== `default` && I(t, e, n[r]);
7051
6877
  return ct(t, e), t;
7052
6878
  }
7053
- function et(e) {
6879
+ function tt(e) {
7054
6880
  return e && e.__esModule ? e : { default: e };
7055
6881
  }
7056
- function tt(e, t, n, r) {
6882
+ function nt(e, t, n, r) {
7057
6883
  if (n === `a` && !r) throw TypeError(`Private accessor was defined without a getter`);
7058
6884
  if (typeof t == `function` ? e !== t || !r : !t.has(e)) throw TypeError(`Cannot read private member from an object whose class did not declare it`);
7059
6885
  return n === `m` ? r : n === `a` ? r.call(e) : r ? r.value : t.get(e);
7060
6886
  }
7061
- function nt(e, t, n, r, i) {
6887
+ function rt(e, t, n, r, i) {
7062
6888
  if (r === `m`) throw TypeError(`Private method is not writable`);
7063
6889
  if (r === `a` && !i) throw TypeError(`Private accessor was defined without a setter`);
7064
6890
  if (typeof t == `function` ? e !== t || !i : !t.has(e)) throw TypeError(`Cannot write private member to an object whose class did not declare it`);
7065
6891
  return r === `a` ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
7066
6892
  }
7067
- function rt(e, t) {
6893
+ function it(e, t) {
7068
6894
  if (t === null || typeof t != `object` && typeof t != `function`) throw TypeError(`Cannot use 'in' operator on non-object`);
7069
6895
  return typeof e == `function` ? t === e : e.has(t);
7070
6896
  }
7071
- function it(e, t, n) {
6897
+ function at(e, t, n) {
7072
6898
  if (t != null) {
7073
6899
  if (typeof t != `object` && typeof t != `function`) throw TypeError(`Object expected.`);
7074
6900
  var r, i;
@@ -7095,7 +6921,7 @@ function it(e, t, n) {
7095
6921
  } else n && e.stack.push({ async: !0 });
7096
6922
  return t;
7097
6923
  }
7098
- function at(e) {
6924
+ function ot(e) {
7099
6925
  function t(t) {
7100
6926
  e.error = e.hasError ? new lt(t, e.error, `An error was suppressed during disposal.`) : t, e.hasError = !0;
7101
6927
  }
@@ -7117,18 +6943,18 @@ function at(e) {
7117
6943
  }
7118
6944
  return i();
7119
6945
  }
7120
- function ot(e, t) {
6946
+ function st(e, t) {
7121
6947
  return typeof e == `string` && /^\.\.?\//.test(e) ? e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(e, n, r, i, a) {
7122
6948
  return n ? t ? `.jsx` : `.js` : r && (!i || !a) ? e : r + i + `.` + a.toLowerCase() + `js`;
7123
6949
  }) : e;
7124
6950
  }
7125
- var st, F, I, ct, L, lt, ut, R = f((() => {
7126
- st = function(e, t) {
7127
- return st = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
6951
+ var P, F, I, ct, L, lt, ut, R = f((() => {
6952
+ P = function(e, t) {
6953
+ return P = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
7128
6954
  e.__proto__ = t;
7129
6955
  } || function(e, t) {
7130
6956
  for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
7131
- }, st(e, t);
6957
+ }, P(e, t);
7132
6958
  }, F = function() {
7133
6959
  return F = Object.assign || function(e) {
7134
6960
  for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
@@ -7162,38 +6988,38 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
7162
6988
  var r = Error(n);
7163
6989
  return r.name = `SuppressedError`, r.error = e, r.suppressed = t, r;
7164
6990
  }, ut = {
7165
- __extends: Ne,
6991
+ __extends: Pe,
7166
6992
  __assign: F,
7167
- __rest: Pe,
7168
- __decorate: Fe,
7169
- __param: Ie,
7170
- __esDecorate: Le,
7171
- __runInitializers: Re,
7172
- __propKey: ze,
7173
- __setFunctionName: Be,
7174
- __metadata: Ve,
7175
- __awaiter: He,
7176
- __generator: Ue,
6993
+ __rest: Fe,
6994
+ __decorate: Ie,
6995
+ __param: Le,
6996
+ __esDecorate: Re,
6997
+ __runInitializers: ze,
6998
+ __propKey: Be,
6999
+ __setFunctionName: Ve,
7000
+ __metadata: He,
7001
+ __awaiter: Ue,
7002
+ __generator: We,
7177
7003
  __createBinding: I,
7178
- __exportStar: We,
7179
- __values: N,
7180
- __read: Ge,
7181
- __spread: Ke,
7182
- __spreadArrays: qe,
7183
- __spreadArray: Je,
7184
- __await: P,
7185
- __asyncGenerator: Ye,
7186
- __asyncDelegator: Xe,
7187
- __asyncValues: Ze,
7188
- __makeTemplateObject: Qe,
7189
- __importStar: $e,
7190
- __importDefault: et,
7191
- __classPrivateFieldGet: tt,
7192
- __classPrivateFieldSet: nt,
7193
- __classPrivateFieldIn: rt,
7194
- __addDisposableResource: it,
7195
- __disposeResources: at,
7196
- __rewriteRelativeImportExtension: ot
7004
+ __exportStar: Ge,
7005
+ __values: M,
7006
+ __read: Ke,
7007
+ __spread: qe,
7008
+ __spreadArrays: Je,
7009
+ __spreadArray: Ye,
7010
+ __await: N,
7011
+ __asyncGenerator: Xe,
7012
+ __asyncDelegator: Ze,
7013
+ __asyncValues: Qe,
7014
+ __makeTemplateObject: $e,
7015
+ __importStar: et,
7016
+ __importDefault: tt,
7017
+ __classPrivateFieldGet: nt,
7018
+ __classPrivateFieldSet: rt,
7019
+ __classPrivateFieldIn: it,
7020
+ __addDisposableResource: at,
7021
+ __disposeResources: ot,
7022
+ __rewriteRelativeImportExtension: st
7197
7023
  };
7198
7024
  })), dt = p(((e) => {
7199
7025
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.ErrorKind = void 0;
@@ -7363,7 +7189,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
7363
7189
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.WHITE_SPACE_REGEX = void 0, e.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
7364
7190
  })), ht = p(((e) => {
7365
7191
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseNumberSkeletonFromString = r, e.parseNumberSkeleton = p;
7366
- var t = (R(), g(M)), n = mt();
7192
+ var t = (R(), g(j)), n = mt();
7367
7193
  function r(e) {
7368
7194
  if (e.length === 0) throw Error(`Number skeleton cannot be empty`);
7369
7195
  for (var t = e.split(n.WHITE_SPACE_REGEX).filter(function(e) {
@@ -7543,7 +7369,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
7543
7369
  }
7544
7370
  })), gt = p(((e) => {
7545
7371
  Object.defineProperty(e, `__esModule`, { value: !0 });
7546
- var t = (R(), g(M));
7372
+ var t = (R(), g(j));
7547
7373
  t.__exportStar(pt(), e), t.__exportStar(ht(), e);
7548
7374
  })), _t = p(((e) => {
7549
7375
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.timeData = void 0, e.timeData = {
@@ -8731,7 +8557,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
8731
8557
  }
8732
8558
  })), yt = p(((e) => {
8733
8559
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.Parser = void 0;
8734
- var t = (R(), g(M)), n = dt(), r = z(), i = ft(), a = gt(), o = vt(), s = RegExp(`^${i.SPACE_SEPARATOR_REGEX.source}*`), c = RegExp(`${i.SPACE_SEPARATOR_REGEX.source}*\$`);
8560
+ var t = (R(), g(j)), n = dt(), r = z(), i = ft(), a = gt(), o = vt(), s = RegExp(`^${i.SPACE_SEPARATOR_REGEX.source}*`), c = RegExp(`${i.SPACE_SEPARATOR_REGEX.source}*\$`);
8735
8561
  function l(e, t) {
8736
8562
  return {
8737
8563
  start: e,
@@ -8791,7 +8617,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
8791
8617
  } else C = function(e, t) {
8792
8618
  for (var n = [];;) {
8793
8619
  var r = x(e, t);
8794
- if (r === void 0 || ie(r) || D(r)) break;
8620
+ if (r === void 0 || ae(r) || E(r)) break;
8795
8621
  n.push(r), t += r >= 65536 ? 2 : 1;
8796
8622
  }
8797
8623
  return y.apply(void 0, n);
@@ -8870,7 +8696,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
8870
8696
  } else return this.error(n.ErrorKind.INVALID_TAG, l(i, this.clonePosition()));
8871
8697
  }, e.prototype.parseTagName = function() {
8872
8698
  var e = this.offset();
8873
- for (this.bump(); !this.isEOF() && E(this.char());) this.bump();
8699
+ for (this.bump(); !this.isEOF() && ie(this.char());) this.bump();
8874
8700
  return this.message.slice(e, this.offset());
8875
8701
  }, e.prototype.parseLiteral = function(e, t) {
8876
8702
  for (var n = this.clonePosition(), i = ``;;) {
@@ -9198,7 +9024,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
9198
9024
  if (this.bump(), this.isEOF()) break;
9199
9025
  }
9200
9026
  }, e.prototype.bumpSpace = function() {
9201
- for (; !this.isEOF() && ie(this.char());) this.bump();
9027
+ for (; !this.isEOF() && ae(this.char());) this.bump();
9202
9028
  }, e.prototype.peek = function() {
9203
9029
  if (this.isEOF()) return null;
9204
9030
  var e = this.char(), t = this.offset();
@@ -9211,18 +9037,18 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
9211
9037
  function re(e) {
9212
9038
  return T(e) || e === 47;
9213
9039
  }
9214
- function E(e) {
9040
+ function ie(e) {
9215
9041
  return e === 45 || e === 46 || e >= 48 && e <= 57 || e === 95 || e >= 97 && e <= 122 || e >= 65 && e <= 90 || e == 183 || e >= 192 && e <= 214 || e >= 216 && e <= 246 || e >= 248 && e <= 893 || e >= 895 && e <= 8191 || e >= 8204 && e <= 8205 || e >= 8255 && e <= 8256 || e >= 8304 && e <= 8591 || e >= 11264 && e <= 12271 || e >= 12289 && e <= 55295 || e >= 63744 && e <= 64975 || e >= 65008 && e <= 65533 || e >= 65536 && e <= 983039;
9216
9042
  }
9217
- function ie(e) {
9043
+ function ae(e) {
9218
9044
  return e >= 9 && e <= 13 || e === 32 || e === 133 || e >= 8206 && e <= 8207 || e === 8232 || e === 8233;
9219
9045
  }
9220
- function D(e) {
9046
+ function E(e) {
9221
9047
  return e >= 33 && e <= 35 || e === 36 || e >= 37 && e <= 39 || e === 40 || e === 41 || e === 42 || e === 43 || e === 44 || e === 45 || e >= 46 && e <= 47 || e >= 58 && e <= 59 || e >= 60 && e <= 62 || e >= 63 && e <= 64 || e === 91 || e === 92 || e === 93 || e === 94 || e === 96 || e === 123 || e === 124 || e === 125 || e === 126 || e === 161 || e >= 162 && e <= 165 || e === 166 || e === 167 || e === 169 || e === 171 || e === 172 || e === 174 || e === 176 || e === 177 || e === 182 || e === 187 || e === 191 || e === 215 || e === 247 || e >= 8208 && e <= 8213 || e >= 8214 && e <= 8215 || e === 8216 || e === 8217 || e === 8218 || e >= 8219 && e <= 8220 || e === 8221 || e === 8222 || e === 8223 || e >= 8224 && e <= 8231 || e >= 8240 && e <= 8248 || e === 8249 || e === 8250 || e >= 8251 && e <= 8254 || e >= 8257 && e <= 8259 || e === 8260 || e === 8261 || e === 8262 || e >= 8263 && e <= 8273 || e === 8274 || e === 8275 || e >= 8277 && e <= 8286 || e >= 8592 && e <= 8596 || e >= 8597 && e <= 8601 || e >= 8602 && e <= 8603 || e >= 8604 && e <= 8607 || e === 8608 || e >= 8609 && e <= 8610 || e === 8611 || e >= 8612 && e <= 8613 || e === 8614 || e >= 8615 && e <= 8621 || e === 8622 || e >= 8623 && e <= 8653 || e >= 8654 && e <= 8655 || e >= 8656 && e <= 8657 || e === 8658 || e === 8659 || e === 8660 || e >= 8661 && e <= 8691 || e >= 8692 && e <= 8959 || e >= 8960 && e <= 8967 || e === 8968 || e === 8969 || e === 8970 || e === 8971 || e >= 8972 && e <= 8991 || e >= 8992 && e <= 8993 || e >= 8994 && e <= 9e3 || e === 9001 || e === 9002 || e >= 9003 && e <= 9083 || e === 9084 || e >= 9085 && e <= 9114 || e >= 9115 && e <= 9139 || e >= 9140 && e <= 9179 || e >= 9180 && e <= 9185 || e >= 9186 && e <= 9254 || e >= 9255 && e <= 9279 || e >= 9280 && e <= 9290 || e >= 9291 && e <= 9311 || e >= 9472 && e <= 9654 || e === 9655 || e >= 9656 && e <= 9664 || e === 9665 || e >= 9666 && e <= 9719 || e >= 9720 && e <= 9727 || e >= 9728 && e <= 9838 || e === 9839 || e >= 9840 && e <= 10087 || e === 10088 || e === 10089 || e === 10090 || e === 10091 || e === 10092 || e === 10093 || e === 10094 || e === 10095 || e === 10096 || e === 10097 || e === 10098 || e === 10099 || e === 10100 || e === 10101 || e >= 10132 && e <= 10175 || e >= 10176 && e <= 10180 || e === 10181 || e === 10182 || e >= 10183 && e <= 10213 || e === 10214 || e === 10215 || e === 10216 || e === 10217 || e === 10218 || e === 10219 || e === 10220 || e === 10221 || e === 10222 || e === 10223 || e >= 10224 && e <= 10239 || e >= 10240 && e <= 10495 || e >= 10496 && e <= 10626 || e === 10627 || e === 10628 || e === 10629 || e === 10630 || e === 10631 || e === 10632 || e === 10633 || e === 10634 || e === 10635 || e === 10636 || e === 10637 || e === 10638 || e === 10639 || e === 10640 || e === 10641 || e === 10642 || e === 10643 || e === 10644 || e === 10645 || e === 10646 || e === 10647 || e === 10648 || e >= 10649 && e <= 10711 || e === 10712 || e === 10713 || e === 10714 || e === 10715 || e >= 10716 && e <= 10747 || e === 10748 || e === 10749 || e >= 10750 && e <= 11007 || e >= 11008 && e <= 11055 || e >= 11056 && e <= 11076 || e >= 11077 && e <= 11078 || e >= 11079 && e <= 11084 || e >= 11085 && e <= 11123 || e >= 11124 && e <= 11125 || e >= 11126 && e <= 11157 || e === 11158 || e >= 11159 && e <= 11263 || e >= 11776 && e <= 11777 || e === 11778 || e === 11779 || e === 11780 || e === 11781 || e >= 11782 && e <= 11784 || e === 11785 || e === 11786 || e === 11787 || e === 11788 || e === 11789 || e >= 11790 && e <= 11798 || e === 11799 || e >= 11800 && e <= 11801 || e === 11802 || e === 11803 || e === 11804 || e === 11805 || e >= 11806 && e <= 11807 || e === 11808 || e === 11809 || e === 11810 || e === 11811 || e === 11812 || e === 11813 || e === 11814 || e === 11815 || e === 11816 || e === 11817 || e >= 11818 && e <= 11822 || e === 11823 || e >= 11824 && e <= 11833 || e >= 11834 && e <= 11835 || e >= 11836 && e <= 11839 || e === 11840 || e === 11841 || e === 11842 || e >= 11843 && e <= 11855 || e >= 11856 && e <= 11857 || e === 11858 || e >= 11859 && e <= 11903 || e >= 12289 && e <= 12291 || e === 12296 || e === 12297 || e === 12298 || e === 12299 || e === 12300 || e === 12301 || e === 12302 || e === 12303 || e === 12304 || e === 12305 || e >= 12306 && e <= 12307 || e === 12308 || e === 12309 || e === 12310 || e === 12311 || e === 12312 || e === 12313 || e === 12314 || e === 12315 || e === 12316 || e === 12317 || e >= 12318 && e <= 12319 || e === 12320 || e === 12336 || e === 64830 || e === 64831 || e >= 65093 && e <= 65094;
9222
9048
  }
9223
9049
  })), bt = p(((e) => {
9224
9050
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.hoistSelectors = s, e.isStructurallySame = l;
9225
- var t = (R(), g(M)), n = z();
9051
+ var t = (R(), g(j)), n = z();
9226
9052
  function r(e) {
9227
9053
  return Array.isArray(e) ? t.__spreadArray([], e.map(r), !0) : typeof e == `object` && e ? Object.keys(e).reduce(function(t, n) {
9228
9054
  return t[n] = r(e[n]), t;
@@ -9281,7 +9107,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
9281
9107
  }
9282
9108
  })), xt = p(((e) => {
9283
9109
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.isStructurallySame = e._Parser = void 0, e.parse = o;
9284
- var t = (R(), g(M)), n = dt(), r = yt(), i = z();
9110
+ var t = (R(), g(j)), n = dt(), r = yt(), i = z();
9285
9111
  function a(e) {
9286
9112
  e.forEach(function(e) {
9287
9113
  if (delete e.location, (0, i.isSelectElement)(e) || (0, i.isPluralElement)(e)) for (var t in e.options) delete e.options[t].location, a(e.options[t].value);
@@ -9310,7 +9136,7 @@ var st, F, I, ct, L, lt, ut, R = f((() => {
9310
9136
  });
9311
9137
  })), St = p(((e) => {
9312
9138
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.printAST = r;
9313
- var t = (R(), g(M)), n = z();
9139
+ var t = (R(), g(j)), n = z();
9314
9140
  function r(e) {
9315
9141
  return i(e, !1);
9316
9142
  }
@@ -9391,7 +9217,7 @@ function Tt(e) {
9391
9217
  return wt.includes(e);
9392
9218
  }
9393
9219
  function Et(e, t = wt, n = [`en`]) {
9394
- let r = Me(n).select(e), i = Math.abs(e);
9220
+ let r = Ne(n).select(e), i = Math.abs(e);
9395
9221
  if (i === 0 && t.includes(`zero`)) return `zero`;
9396
9222
  if (i === 1) {
9397
9223
  if (t.includes(`singular`)) return `singular`;
@@ -9417,7 +9243,8 @@ function Ot(e) {
9417
9243
  const U = `_gt_`;
9418
9244
  RegExp(`^${U}\\d+$`);
9419
9245
  RegExp(`^${U}$`);
9420
- function Vt(e, n = 0) {
9246
+ RegExp(`${U}\\d+`);
9247
+ function Ht(e, n = 0) {
9421
9248
  let r = n, a = (e) => {
9422
9249
  let { type: t, props: n } = e;
9423
9250
  r += 1;
@@ -9431,11 +9258,11 @@ function Vt(e, n = 0) {
9431
9258
  if (a) {
9432
9259
  let e = a.split(`-`);
9433
9260
  if ((e[1] === `automatic` || e[2] === `automatic`) && (i.injectionType = `automatic`), e[0] === `translate` && (e[0] = `fragment`), e[0] === `variable` && (i.variableType = e?.[1] || `variable`), e[0] === `plural`) {
9434
- let e = Object.entries(n).reduce((e, [t, n]) => (Tt(t) && (e[t] = Vt(n, r)), e), {});
9261
+ let e = Object.entries(n).reduce((e, [t, n]) => (Tt(t) && (e[t] = Ht(n, r)), e), {});
9435
9262
  Object.keys(e).length && (i.branches = e);
9436
9263
  }
9437
9264
  if (e[0] === `branch`) {
9438
- let { children: e, branch: t, ...a } = n, o = Object.fromEntries(Object.entries(a).filter(([e]) => !e.startsWith(`data-`))), s = Object.entries(o).reduce((e, [t, n]) => (e[t] = Vt(n, r), e), {});
9265
+ let { children: e, branch: t, ...a } = n, o = Object.fromEntries(Object.entries(a).filter(([e]) => !e.startsWith(`data-`))), s = Object.entries(o).reduce((e, [t, n]) => (e[t] = Ht(n, r), e), {});
9439
9266
  Object.keys(s).length && (i.branches = s);
9440
9267
  }
9441
9268
  i.transformation = e[0];
@@ -9457,10 +9284,10 @@ function Vt(e, n = 0) {
9457
9284
  }
9458
9285
  return c(e);
9459
9286
  }
9460
- const Ht = `@generaltranslation/react-core`;
9287
+ const Ut = `@generaltranslation/react-core`;
9461
9288
  function W(e) {
9462
9289
  return S({
9463
- source: Ht,
9290
+ source: Ut,
9464
9291
  ...e
9465
9292
  });
9466
9293
  }
@@ -9507,12 +9334,12 @@ W({
9507
9334
  whatHappened: `No dictionary was found`,
9508
9335
  fix: `Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations`
9509
9336
  });
9510
- const Kt = `${Ht} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9511
- function qt(e) {
9337
+ const qt = `${Ut} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9338
+ function Jt(e) {
9512
9339
  return K(e, 0);
9513
9340
  }
9514
- function Jt(e, t) {
9515
- let { type: n, props: i } = e, a = Yt(n);
9341
+ function Yt(e, t) {
9342
+ let { type: n, props: i } = e, a = Xt(n);
9516
9343
  if (typeof i != `object` || !i) return e;
9517
9344
  if (a) {
9518
9345
  let { componentType: n, injectionType: o } = a;
@@ -9524,7 +9351,7 @@ function Jt(e, t) {
9524
9351
  ...`children` in i && { children: K(i.children, t + 1) }
9525
9352
  });
9526
9353
  if (n === `translate` && o === `automatic` && t > 0) return `children` in i ? K(i.children, t) : void 0;
9527
- n === `translate` && o === `automatic` && console.warn(Kt);
9354
+ n === `translate` && o === `automatic` && console.warn(qt);
9528
9355
  }
9529
9356
  return (0, react.cloneElement)(e, {
9530
9357
  ...i,
@@ -9532,12 +9359,12 @@ function Jt(e, t) {
9532
9359
  });
9533
9360
  }
9534
9361
  function G(e, t) {
9535
- return (0, react.isValidElement)(e) ? Jt(e, t) : e;
9362
+ return (0, react.isValidElement)(e) ? Yt(e, t) : e;
9536
9363
  }
9537
9364
  function K(e, t) {
9538
9365
  return Array.isArray(e) ? react.Children.map(e, (e) => G(e, t)) : G(e, t);
9539
9366
  }
9540
- function Yt(e) {
9367
+ function Xt(e) {
9541
9368
  let t = typeof e == `function` && `_gtt` in e ? e._gtt : void 0;
9542
9369
  if (t == null || typeof t != `string`) return;
9543
9370
  let n = t.split(`-`);
@@ -9546,27 +9373,27 @@ function Yt(e) {
9546
9373
  injectionType: n[1] === `automatic` || n[2] === `automatic` ? `automatic` : `manual`
9547
9374
  };
9548
9375
  }
9549
- const Xt = {
9376
+ const Zt = {
9550
9377
  variable: `value`,
9551
9378
  number: `n`,
9552
9379
  datetime: `date`,
9553
9380
  currency: `cost`,
9554
9381
  "relative-time": `time`
9555
9382
  };
9556
- function Zt(e = {}, t) {
9557
- return typeof e.name == `string` ? e.name : `_gt_${Xt[t] || `value`}_${e[`data-_gt`]?.id}`;
9383
+ function Qt(e = {}, t) {
9384
+ return typeof e.name == `string` ? e.name : `_gt_${Zt[t] || `value`}_${e[`data-_gt`]?.id}`;
9558
9385
  }
9559
- function Qt(e) {
9386
+ function $t(e) {
9560
9387
  return react.default.isValidElement(e);
9561
9388
  }
9562
- const $t = {
9389
+ const en = {
9563
9390
  pl: `placeholder`,
9564
9391
  ti: `title`,
9565
9392
  alt: `alt`,
9566
9393
  arl: `aria-label`,
9567
9394
  arb: `aria-labelledby`,
9568
9395
  ard: `aria-describedby`
9569
- }, en = (e) => {
9396
+ }, tn = (e) => {
9570
9397
  if (!e) return ``;
9571
9398
  let { type: t, props: n } = e;
9572
9399
  if (t && typeof t == `function`) {
@@ -9574,8 +9401,8 @@ const $t = {
9574
9401
  if (`name` in t && typeof t.name == `string` && t.name) return t.name;
9575
9402
  }
9576
9403
  return t && typeof t == `string` ? t : n.href ? `a` : n[`data-_gt`]?.id ? `C${n[`data-_gt`].id}` : `function`;
9577
- }, tn = (e, t, n) => {
9578
- let r = Object.entries($t).reduce((e, [n, r]) => {
9404
+ }, nn = (e, t, n) => {
9405
+ let r = Object.entries(en).reduce((e, [n, r]) => {
9579
9406
  let i = t[r];
9580
9407
  return typeof i == `string` && (e[n] = i), e;
9581
9408
  }, {});
@@ -9600,20 +9427,20 @@ const $t = {
9600
9427
  };
9601
9428
  }
9602
9429
  return Object.keys(r).length ? r : void 0;
9603
- }, nn = (e) => {
9604
- let { props: t } = e, n = { t: en(e) };
9430
+ }, rn = (e) => {
9431
+ let { props: t } = e, n = { t: tn(e) };
9605
9432
  if (t[`data-_gt`]) {
9606
9433
  let e = t[`data-_gt`], r = e.transformation;
9607
9434
  if (r === `variable`) {
9608
- let n = e.variableType || `variable`, r = Zt(t, n), i = Ot(n);
9435
+ let n = e.variableType || `variable`, r = Qt(t, n), i = Ot(n);
9609
9436
  return {
9610
9437
  i: e.id,
9611
9438
  k: r,
9612
9439
  v: i
9613
9440
  };
9614
9441
  }
9615
- n.i = e.id, n.d = tn(r, t, e.branches);
9616
- let i = Object.entries($t).reduce((e, [n, r]) => {
9442
+ n.i = e.id, n.d = nn(r, t, e.branches);
9443
+ let i = Object.entries(en).reduce((e, [n, r]) => {
9617
9444
  let i = t[r];
9618
9445
  return typeof i == `string` && (e[n] = i), e;
9619
9446
  }, {});
@@ -9640,21 +9467,21 @@ const $t = {
9640
9467
  n.d = Object.keys(i).length ? i : void 0;
9641
9468
  }
9642
9469
  return t.children && (n.c = q(t.children)), n;
9643
- }, rn = (e) => Qt(e) ? nn(e) : typeof e == `number` ? e.toString() : e;
9470
+ }, an = (e) => $t(e) ? rn(e) : typeof e == `number` ? e.toString() : e;
9644
9471
  function q(e) {
9645
- return Array.isArray(e) ? e.map(rn) : rn(e);
9472
+ return Array.isArray(e) ? e.map(an) : an(e);
9646
9473
  }
9647
9474
  function J(e, t, n) {
9648
9475
  let r = ``, i = null;
9649
9476
  return typeof e == `number` && !i && n && (r = Et(e, Object.keys(n).filter(Tt), t)), r && !i && (i = n[r]), i;
9650
9477
  }
9651
- function on(e) {
9478
+ function sn(e) {
9652
9479
  return typeof e == `object` && !!e && `data-_gt` in e && typeof e[`data-_gt`] == `object` && !!e[`data-_gt`] && `transformation` in e[`data-_gt`] && e[`data-_gt`]?.transformation === `variable`;
9653
9480
  }
9654
- function sn(e) {
9481
+ function cn(e) {
9655
9482
  let t = e[`data-_gt`]?.variableType || `variable`;
9656
9483
  return {
9657
- variableName: Zt(e, t),
9484
+ variableName: Qt(e, t),
9658
9485
  variableType: Ot(t),
9659
9486
  injectionType: e[`data-_gt`]?.injectionType || `manual`,
9660
9487
  variableValue: (() => {
@@ -9674,14 +9501,14 @@ function sn(e) {
9674
9501
  })()
9675
9502
  };
9676
9503
  }
9677
- function ln(e) {
9504
+ function un(e) {
9678
9505
  return e && e.props && e.props[`data-_gt`] ? e.props[`data-_gt`] : null;
9679
9506
  }
9680
9507
  function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9681
9508
  let i = (e) => {
9682
- let i = ln(e);
9683
- if (on(e.props)) {
9684
- let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = sn(e.props);
9509
+ let i = un(e);
9510
+ if (sn(e.props)) {
9511
+ let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = cn(e.props);
9685
9512
  return r({
9686
9513
  variableType: t,
9687
9514
  variableValue: i,
@@ -9714,9 +9541,9 @@ function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9714
9541
  }, a = (e) => react.default.isValidElement(e) ? i(e) : e, o = (e) => Array.isArray(e) ? react.default.Children.map(e, a) : a(e);
9715
9542
  return o(e);
9716
9543
  }
9717
- function un({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9544
+ function dn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9718
9545
  let { props: a } = e, o = a[`data-_gt`], s = o?.transformation, c = n.d, l = {};
9719
- if (c && Object.entries($t).forEach(([e, t]) => {
9546
+ if (c && Object.entries(en).forEach(([e, t]) => {
9720
9547
  c[e] && (l[t] = c[e]);
9721
9548
  }), s === `plural`) {
9722
9549
  let t = e.props.n;
@@ -9775,18 +9602,18 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9775
9602
  if (typeof n == `string`) return n;
9776
9603
  if (Array.isArray(n) && !Array.isArray(e) && e && (e = [e]), Array.isArray(e) && Array.isArray(n)) {
9777
9604
  let a = {}, o = {}, c = {}, l = e.filter((e) => {
9778
- if (react.default.isValidElement(e)) if (on(e.props)) {
9779
- let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = sn(e.props);
9605
+ if (react.default.isValidElement(e)) if (sn(e.props)) {
9606
+ let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = cn(e.props);
9780
9607
  a[t] = n, o[t] = r, c[t] = i;
9781
9608
  } else return !0;
9782
9609
  return !1;
9783
9610
  }), u = (e) => l.find((t) => {
9784
- let n = ln(t);
9611
+ let n = un(t);
9785
9612
  return n?.id === void 0 ? !1 : n.id === e.i;
9786
9613
  }) || l.shift();
9787
9614
  return n.map((e, n) => {
9788
9615
  if (typeof e == `string`) return (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: e }, `string_${n}`);
9789
- if (E(e)) return (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: i({
9616
+ if (ie(e)) return (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: i({
9790
9617
  variableType: e.v || `v`,
9791
9618
  variableValue: a[e.k],
9792
9619
  variableOptions: o[e.k],
@@ -9794,7 +9621,7 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9794
9621
  injectionType: c[e.k] || `manual`
9795
9622
  }) }, `var_${n}`);
9796
9623
  let l = u(e);
9797
- return l ? (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: un({
9624
+ return l ? (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: dn({
9798
9625
  sourceElement: l,
9799
9626
  targetElement: e,
9800
9627
  locales: r,
@@ -9803,16 +9630,16 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9803
9630
  });
9804
9631
  }
9805
9632
  if (n && typeof n == `object` && !Array.isArray(n)) {
9806
- let a = E(n) ? `variable` : `element`;
9633
+ let a = ie(n) ? `variable` : `element`;
9807
9634
  if (react.default.isValidElement(e)) {
9808
- if (a === `element`) return un({
9635
+ if (a === `element`) return dn({
9809
9636
  sourceElement: e,
9810
9637
  targetElement: n,
9811
9638
  locales: r,
9812
9639
  renderVariable: i
9813
9640
  });
9814
- if (on(e.props)) {
9815
- let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = sn(e.props);
9641
+ if (sn(e.props)) {
9642
+ let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = cn(e.props);
9816
9643
  return i({
9817
9644
  variableType: a,
9818
9645
  variableValue: t,
@@ -9829,15 +9656,15 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9829
9656
  renderVariable: i
9830
9657
  });
9831
9658
  }
9832
- const pn = `generaltranslation.locale`;
9659
+ const mn = `generaltranslation.locale`;
9833
9660
  react.use;
9834
- function Jn({ children: e }) {
9661
+ function Yn({ children: e }) {
9835
9662
  return e;
9836
9663
  }
9837
- function Yn(e) {
9838
- return Jn(e);
9664
+ function Xn(e) {
9665
+ return Yn(e);
9839
9666
  }
9840
- Jn._gtt = `derive`, Yn._gtt = `derive`;
9667
+ Yn._gtt = `derive`, Xn._gtt = `derive`;
9841
9668
  //#endregion
9842
9669
  //#region src/shared/cookies.ts
9843
9670
  /**
@@ -9868,7 +9695,7 @@ function setCookieValue(cookieName, value) {
9868
9695
  * @returns The determined locale
9869
9696
  *
9870
9697
  */
9871
- function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = pn, getLocale }) {
9698
+ function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = mn, getLocale }) {
9872
9699
  const localeConfig = {
9873
9700
  defaultLocale,
9874
9701
  locales,
@@ -9903,7 +9730,7 @@ var BrowserConditionStore = class {
9903
9730
  /**
9904
9731
  * @param {BrowserConditionStoreConstructorParams} params - The configuration for the BrowserConditionStore
9905
9732
  */
9906
- constructor({ getLocale, localeCookieName = pn, ...localeConfig } = {}) {
9733
+ constructor({ getLocale, localeCookieName = mn, ...localeConfig } = {}) {
9907
9734
  this.localeConfig = localeConfig;
9908
9735
  this.customGetLocale = getLocale;
9909
9736
  this.localeCookieName = localeCookieName;
@@ -10648,7 +10475,7 @@ GtInternalTranslateJsx._gtt = "translate-client-automatic";
10648
10475
  * Implementation for the T component logic
10649
10476
  */
10650
10477
  function useComputeT({ children: sourceChildren, ...params }) {
10651
- const taggedSourceChildren = (0, react.useMemo)(() => Vt(qt(sourceChildren)), [sourceChildren]);
10478
+ const taggedSourceChildren = (0, react.useMemo)(() => Ht(Jt(sourceChildren)), [sourceChildren]);
10652
10479
  const sourceJsxChildren = (0, react.useMemo)(() => q(taggedSourceChildren), [taggedSourceChildren]);
10653
10480
  const renderSourceChildren = () => Z({
10654
10481
  children: taggedSourceChildren,