gt-react 10.19.16 → 10.19.18

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
@@ -36,29 +36,48 @@ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["modu
36
36
  let _generaltranslation_format = require("@generaltranslation/format");
37
37
  let generaltranslation = require("generaltranslation");
38
38
  let react = require("react");
39
- let react$1 = __toESM(react, 1);
40
- react = __toESM(react);
39
+ react = __toESM(react, 1);
41
40
  let react_jsx_runtime = require("react/jsx-runtime");
42
- //#region src/shared/messages.ts
43
- const PACKAGE_NAME = "gt-react";
44
- const BROWSER_ENVIRONMENT_ERROR = `${PACKAGE_NAME}/browser Error: The ${PACKAGE_NAME}/browser module requires a browser environment`;
45
- const GENERIC_BROWSER_ENVIRONMENT_ERROR = `${PACKAGE_NAME} Error: You are trying to import a browser-only module into a non-browser environment.`;
46
- const BROWSER_I18N_MANAGER_NOT_INITIALIZED_ERROR = `${PACKAGE_NAME} Error: BrowserI18nManager not initialized. Invoke initializeGT() to initialize.`;
47
- const createTranslationFailedDueToBrowserEnvironmentWarning = (message) => `${PACKAGE_NAME} Warning: Translation failed for t("${typeof message === "string" ? message : "`" + message?.join("${}") + "`"}") because it was used outside of a browser environment. Falling back to original message.`;
48
- const createNoLocaleCouldBeDeterminedFromCustomGetLocaleWarning = ({ customLocale, defaultLocale }) => `${PACKAGE_NAME} Warning: Custom getLocale() function returned an unsupported locale: "${customLocale}". Falling back to default locale: "${defaultLocale}".`;
49
- const createInvalidLocaleWarning = (locale) => `${PACKAGE_NAME} Warning: Invalid locale: "${locale}".`;
50
- //#endregion
51
- //#region src/i18n-context/utils/enforceBrowser.ts
52
- /**
53
- * @internal
54
- *
55
- * Throws an error when imported outside of a browser environment.
56
- */
57
- function enforceBrowser(errorMessage = GENERIC_BROWSER_ENVIRONMENT_ERROR) {
58
- if (typeof window === "undefined") throw new Error(errorMessage);
41
+ //#region ../core/dist/base64-r7YWJYWt.mjs
42
+ function ensureSentence(text) {
43
+ const trimmed = text.trim();
44
+ if (!trimmed) return "";
45
+ return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;
46
+ }
47
+ function stripSentence(text) {
48
+ const trimmed = text.trim();
49
+ let end = trimmed.length;
50
+ while (end > 0) {
51
+ const char = trimmed[end - 1];
52
+ if (char !== "." && char !== "!" && char !== "?") break;
53
+ end -= 1;
54
+ }
55
+ return trimmed.slice(0, end);
56
+ }
57
+ function lowercaseFirstWord(text) {
58
+ return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
59
+ }
60
+ function formatDetails(details) {
61
+ if (!details) return "";
62
+ const detailText = Array.isArray(details) ? details.join(", ") : details;
63
+ if (!detailText.trim()) return "";
64
+ return ensureSentence(`Details: ${detailText}`);
65
+ }
66
+ function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
67
+ const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
68
+ const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
69
+ const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
70
+ const messageParts = [
71
+ whatAndWhy,
72
+ reassurance,
73
+ shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
74
+ shouldCombineWayOut ? void 0 : wayOut,
75
+ formatDetails(details)
76
+ ].filter((part) => !!part).map(ensureSentence);
77
+ if (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);
78
+ const message = messageParts.join(" ");
79
+ return prefix ? `${prefix} ${message}` : message;
59
80
  }
60
- //#endregion
61
- //#region ../core/dist/base64-CWITCfhU.mjs
62
81
  const defaultCacheUrl = "https://cdn.gtx.dev";
63
82
  //#endregion
64
83
  //#region ../core/dist/isVariable-fAKEB7gF.mjs
@@ -4199,6 +4218,56 @@ function condenseVars(icuString) {
4199
4218
  }));
4200
4219
  }
4201
4220
  //#endregion
4221
+ //#region src/shared/messages.ts
4222
+ const PACKAGE_NAME = "gt-react";
4223
+ const BROWSER_ENVIRONMENT_ERROR = createDiagnosticMessage({
4224
+ source: `${PACKAGE_NAME}/browser`,
4225
+ severity: "Error",
4226
+ whatHappened: "This module requires a browser environment",
4227
+ fix: "Import it only from client-side code"
4228
+ });
4229
+ const GENERIC_BROWSER_ENVIRONMENT_ERROR = createDiagnosticMessage({
4230
+ source: PACKAGE_NAME,
4231
+ severity: "Error",
4232
+ whatHappened: "A browser-only module was imported outside the browser",
4233
+ fix: "Move this import to client-side code"
4234
+ });
4235
+ const BROWSER_I18N_MANAGER_NOT_INITIALIZED_ERROR = createDiagnosticMessage({
4236
+ source: PACKAGE_NAME,
4237
+ severity: "Error",
4238
+ whatHappened: "BrowserI18nManager is not initialized",
4239
+ fix: "Call initializeGT() before using browser translation APIs"
4240
+ });
4241
+ const createTranslationFailedDueToBrowserEnvironmentWarning = (message) => createDiagnosticMessage({
4242
+ source: PACKAGE_NAME,
4243
+ severity: "Warning",
4244
+ whatHappened: `t("${typeof message === "string" ? message : "`" + message?.join("${}") + "`"}") could not be translated because it ran outside the browser`,
4245
+ wayOut: "The original message will render as a fallback"
4246
+ });
4247
+ const createNoLocaleCouldBeDeterminedFromCustomGetLocaleWarning = ({ customLocale, defaultLocale }) => createDiagnosticMessage({
4248
+ source: PACKAGE_NAME,
4249
+ severity: "Warning",
4250
+ whatHappened: `Custom getLocale() returned unsupported locale "${customLocale}"`,
4251
+ wayOut: `Falling back to default locale "${defaultLocale}"`,
4252
+ fix: "Add the locale to your config if you want to support it"
4253
+ });
4254
+ const createInvalidLocaleWarning = (locale) => createDiagnosticMessage({
4255
+ source: PACKAGE_NAME,
4256
+ severity: "Warning",
4257
+ whatHappened: `Locale "${locale}" is not valid`,
4258
+ fix: "Use a valid BCP 47 locale code or add a custom mapping"
4259
+ });
4260
+ //#endregion
4261
+ //#region src/i18n-context/utils/enforceBrowser.ts
4262
+ /**
4263
+ * @internal
4264
+ *
4265
+ * Throws an error when imported outside of a browser environment.
4266
+ */
4267
+ function enforceBrowser(errorMessage = GENERIC_BROWSER_ENVIRONMENT_ERROR) {
4268
+ if (typeof window === "undefined") throw new Error(errorMessage);
4269
+ }
4270
+ //#endregion
4202
4271
  //#region ../i18n/dist/isEncodedTranslationOptions-BOwWa_-J.mjs
4203
4272
  var logger_default = {
4204
4273
  warn(message) {
@@ -4333,7 +4402,7 @@ function sanitizeJsxChildren(childrenAsObjects) {
4333
4402
  return Array.isArray(childrenAsObjects) ? childrenAsObjects.map(sanitizeChild) : sanitizeChild(childrenAsObjects);
4334
4403
  }
4335
4404
  //#endregion
4336
- //#region ../i18n/dist/versionId-B2xfz6jP.mjs
4405
+ //#region ../i18n/dist/versionId-BTjLA0FZ.mjs
4337
4406
  /**
4338
4407
  * Throw errors if there are any errors and log warnings if there are any warnings
4339
4408
  * @param {ValidationResult[]} results - The results to print
@@ -4379,9 +4448,9 @@ function getLoadTranslationsType(config) {
4379
4448
  * Requirements:
4380
4449
  * - REMOTE:
4381
4450
  * - GT_REMOTE:
4382
- * - projectId is required
4451
+ * - projectId is needed
4383
4452
  * - CUSTOM:
4384
- * - loadTranslations is required
4453
+ * - loadTranslations is needed
4385
4454
  * - DISABLED:
4386
4455
  * - no requirements
4387
4456
  */
@@ -4393,13 +4462,19 @@ function validateLoadTranslations(params) {
4393
4462
  case "gt-remote":
4394
4463
  if (!projectId) results.push({
4395
4464
  type: "warning",
4396
- message: "projectId is required when loading translations from a remote store"
4465
+ message: createDiagnosticMessage({
4466
+ whatHappened: "Loading translations from a remote store needs a projectId",
4467
+ fix: "Add projectId to the I18nManager config or disable remote translation loading"
4468
+ })
4397
4469
  });
4398
4470
  break;
4399
4471
  case "custom":
4400
4472
  if (!loadTranslations) results.push({
4401
4473
  type: "error",
4402
- message: "loadTranslations is required when loading translations from a custom loader"
4474
+ message: createDiagnosticMessage({
4475
+ whatHappened: "Custom translation loading needs loadTranslations",
4476
+ fix: "Provide a loadTranslations function or disable custom translation loading"
4477
+ })
4403
4478
  });
4404
4479
  break;
4405
4480
  case "disabled": break;
@@ -4412,8 +4487,9 @@ function validateLoadTranslations(params) {
4412
4487
  * @returns The runtime translation type
4413
4488
  */
4414
4489
  function getTranslationApiType(params) {
4415
- if ((params.runtimeUrl === void 0 || params.runtimeUrl === "https://runtime2.gtx.dev") && params.projectId && (params.devApiKey || params.apiKey)) return "gt";
4416
- else if (params.runtimeUrl) return "custom";
4490
+ const usesDefaultRuntimeUrl = params.runtimeUrl === void 0 || params.runtimeUrl === "https://runtime2.gtx.dev";
4491
+ if (usesDefaultRuntimeUrl && params.projectId && (params.devApiKey || params.apiKey)) return "gt";
4492
+ else if (params.runtimeUrl && !usesDefaultRuntimeUrl) return "custom";
4417
4493
  else return "disabled";
4418
4494
  }
4419
4495
  /**
@@ -4429,8 +4505,8 @@ function getTranslationApiType(params) {
4429
4505
  * Requirements:
4430
4506
  * - CUSTOM:
4431
4507
  * - GT:
4432
- * - projectId is required
4433
- * - devApiKey or apiKey is required
4508
+ * - projectId is needed
4509
+ * - devApiKey or apiKey is needed
4434
4510
  * - DISABLED:
4435
4511
  * - no requirements
4436
4512
  *
@@ -4443,11 +4519,17 @@ function validateTranslationApi(params) {
4443
4519
  case "gt":
4444
4520
  if (!params.projectId) results.push({
4445
4521
  type: "warning",
4446
- message: "projectId is required"
4522
+ message: createDiagnosticMessage({
4523
+ whatHappened: "Runtime translation needs a projectId",
4524
+ fix: "Add projectId to the I18nManager config or disable runtime translation"
4525
+ })
4447
4526
  });
4448
4527
  if (!params.devApiKey && !params.apiKey) results.push({
4449
4528
  type: "warning",
4450
- message: "devApiKey or apiKey is required"
4529
+ message: createDiagnosticMessage({
4530
+ whatHappened: "Runtime translation needs devApiKey or apiKey",
4531
+ fix: "Add credentials to the I18nManager config or disable runtime translation"
4532
+ })
4451
4533
  });
4452
4534
  break;
4453
4535
  case "disabled": break;
@@ -4476,7 +4558,10 @@ function validateLocales(params) {
4476
4558
  new Set([...defaultLocale ? [defaultLocale] : [], ...locales || []]).forEach((locale) => {
4477
4559
  if (!(0, _generaltranslation_format.isValidLocale)(locale, customMapping)) results.push({
4478
4560
  type: "error",
4479
- message: `Invalid locale: ${locale}`
4561
+ message: createDiagnosticMessage({
4562
+ whatHappened: `Locale "${locale}" is not valid`,
4563
+ fix: "Use a valid BCP 47 locale code or add a custom mapping"
4564
+ })
4480
4565
  });
4481
4566
  });
4482
4567
  return results;
@@ -4491,7 +4576,10 @@ function validateDictionary(params) {
4491
4576
  const results = [];
4492
4577
  if (params.loadDictionary && !params.dictionary) results.push({
4493
4578
  type: "error",
4494
- message: "dictionary is required when loadDictionary is provided"
4579
+ message: createDiagnosticMessage({
4580
+ whatHappened: "loadDictionary needs a source dictionary",
4581
+ fix: "Provide dictionary so the default locale has source content"
4582
+ })
4495
4583
  });
4496
4584
  return results;
4497
4585
  }
@@ -4580,83 +4668,269 @@ function routeCreateTranslationLoader({ type, remoteTranslationLoaderParams, loa
4580
4668
  case "disabled": return createFallbackTranslationLoader();
4581
4669
  }
4582
4670
  }
4583
- function isPlainObject(value) {
4584
- if (value == null || typeof value !== "object") return false;
4585
- const prototype = Object.getPrototypeOf(value);
4586
- return prototype === Object.prototype || prototype === null;
4671
+ function getDictionaryPath(id) {
4672
+ const path = id ? id.split(".") : [];
4673
+ for (const segment of path) assertSafeDictionaryPathSegment(segment, id);
4674
+ return path;
4675
+ }
4676
+ function assertSafeDictionaryPathSegment(segment, path) {
4677
+ if (segment === "__proto__" || segment === "constructor" || segment === "prototype") throw new Error(`Dictionary path "${path}" contains an unsafe segment`);
4587
4678
  }
4588
- function copyCacheValue(value) {
4589
- if (Array.isArray(value)) return [...value];
4590
- if (isPlainObject(value)) return { ...value };
4591
- return value;
4679
+ function isDictionaryObject(value) {
4680
+ return typeof value === "object" && value != null && !Array.isArray(value);
4681
+ }
4682
+ function cloneDictionaryValue(value) {
4683
+ if (value === void 0 || typeof value === "string") return value;
4684
+ return structuredClone(value);
4685
+ }
4686
+ function getDictionaryValueAtPath(dictionary, path) {
4687
+ let current = dictionary;
4688
+ for (const segment of getDictionaryPath(path)) {
4689
+ if (!isDictionaryObject(current)) return;
4690
+ current = current[segment];
4691
+ }
4692
+ return current;
4693
+ }
4694
+ function setDictionaryValueAtPath(dictionary, path, value) {
4695
+ const segments = getDictionaryPath(path);
4696
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4697
+ if (segments.length === 0) {
4698
+ if (isDictionaryObject(value)) replaceDictionary(dictionary, value);
4699
+ return;
4700
+ }
4701
+ let current = dictionary;
4702
+ for (const segment of segments.slice(0, -1)) {
4703
+ const next = current[segment];
4704
+ if (!isDictionaryObject(next)) current[segment] = {};
4705
+ current = current[segment];
4706
+ }
4707
+ const leafSegment = segments[segments.length - 1];
4708
+ current[leafSegment] = value;
4709
+ }
4710
+ function getDictionaryEntry(value) {
4711
+ if (!isDictionaryLeafNode(value)) return;
4712
+ return {
4713
+ entry: Array.isArray(value) ? value[0] : value,
4714
+ options: Array.isArray(value) ? value[1] ?? {} : {}
4715
+ };
4716
+ }
4717
+ function getDictionaryValue(value) {
4718
+ if (Object.keys(value.options).length === 0) return value.entry;
4719
+ return [value.entry, value.options];
4720
+ }
4721
+ function resolveDictionaryLookupOptions(options) {
4722
+ const { $format, context, ...rest } = options;
4723
+ return {
4724
+ ...rest,
4725
+ $format: isStringFormat($format) ? $format : "ICU",
4726
+ ...rest.$context === void 0 && typeof context === "string" && { $context: context }
4727
+ };
4728
+ }
4729
+ function isDictionaryLeafNode(value) {
4730
+ if (typeof value === "string") return true;
4731
+ if (!Array.isArray(value) || typeof value[0] !== "string") return false;
4732
+ if (value.length === 1) return true;
4733
+ return value.length === 2 && isDictionaryOptions(value[1]);
4734
+ }
4735
+ function isDictionaryOptions(value) {
4736
+ if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
4737
+ const options = value;
4738
+ 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");
4739
+ }
4740
+ function isStringFormat(value) {
4741
+ return value === "ICU" || value === "I18NEXT" || value === "STRING";
4742
+ }
4743
+ function replaceDictionary(target, source) {
4744
+ for (const key of Object.keys(target)) delete target[key];
4745
+ for (const key of Object.keys(source)) target[key] = source[key];
4592
4746
  }
4747
+ function assertSafeDictionaryObject(dictionary, parentPath = "") {
4748
+ for (const [key, value] of Object.entries(dictionary)) {
4749
+ const path = parentPath ? `${parentPath}.${key}` : key;
4750
+ assertSafeDictionaryPathSegment(key, path);
4751
+ if (isDictionaryObject(value)) assertSafeDictionaryObject(value, path);
4752
+ }
4753
+ }
4754
+ var DictionarySourceNotFoundError = class extends Error {
4755
+ constructor(id) {
4756
+ super(`I18nManager: source dictionary entry ${id} is not defined`);
4757
+ this.name = "DictionarySourceNotFoundError";
4758
+ }
4759
+ };
4593
4760
  /**
4594
- * Cache class
4595
- * This is designed in such a way that it is the responsibility of the client
4596
- * to invoke the cache miss method when a cache miss occurs.
4597
- *
4598
- * TODO: maybe add "OutputValue" as a reflection of "InputKey"
4599
- */
4600
- var Cache = class {
4601
- /**
4602
- * Constructor
4603
- * @param {Object} params - The parameters for the cache
4604
- * @param {Record<CacheKey, CacheValue>} params.init - The initial cache
4605
- * @param {CacheLifecycle} [lifecycle] - Optional lifecycle callbacks
4606
- */
4607
- constructor(init, lifecycle) {
4608
- this.cache = {};
4609
- this.fallbackPromises = {};
4761
+ * Builds the dictionary value for a requested path by combining existing target
4762
+ * translations with runtime translations of any source leaves that are missing.
4763
+ */
4764
+ async function materializeDictionaryValue({ key, sourceValue, targetValue, translateEntry }) {
4765
+ if (getDictionaryEntry(targetValue) !== void 0) return cloneDictionaryValue(targetValue);
4766
+ if (isDictionaryObject(targetValue) && !isDictionaryObject(sourceValue)) return cloneDictionaryValue(targetValue);
4767
+ const sourceEntry = getDictionaryEntry(sourceValue);
4768
+ if (sourceEntry !== void 0) return await translateEntry(key, sourceEntry);
4769
+ if (!isDictionaryObject(sourceValue)) throw new DictionarySourceNotFoundError(key);
4770
+ const targetDictionary = isDictionaryObject(targetValue) ? targetValue : {};
4771
+ const keys = new Set([...Object.keys(sourceValue), ...Object.keys(targetDictionary)]);
4772
+ const entries = await Promise.all(Array.from(keys).map(async (childKey) => {
4773
+ const childPath = key ? `${key}.${childKey}` : childKey;
4774
+ assertSafeDictionaryPathSegment(childKey, childPath);
4775
+ const childSource = sourceValue[childKey];
4776
+ if (childSource === void 0) return [childKey, cloneDictionaryValue(targetDictionary[childKey])];
4777
+ return [childKey, await materializeDictionaryValue({
4778
+ key: childPath,
4779
+ sourceValue: childSource,
4780
+ targetValue: targetDictionary[childKey],
4781
+ translateEntry
4782
+ })];
4783
+ }));
4784
+ return Object.fromEntries(entries);
4785
+ }
4786
+ function cloneDictionaryEntry(entry) {
4787
+ return {
4788
+ entry: entry.entry,
4789
+ options: structuredClone(entry.options)
4790
+ };
4791
+ }
4792
+ var DictionaryCache = class {
4793
+ constructor({ init, lifecycle = {}, runtimeTranslate }) {
4794
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4795
+ this.pendingMaterializations = /* @__PURE__ */ new Map();
4610
4796
  this.cache = structuredClone(init);
4611
- this.onHit = lifecycle?.onHit;
4612
- this.onMiss = lifecycle?.onMiss;
4797
+ this.runtimeTranslate = runtimeTranslate;
4798
+ this.lifecycle = lifecycle;
4613
4799
  }
4614
- /**
4615
- * Set the value for a key
4616
- */
4617
- setCache(cacheKey, value) {
4618
- this.cache[cacheKey] = value;
4800
+ getEntry(key) {
4801
+ const value = getDictionaryValueAtPath(this.cache, key);
4802
+ const entry = getDictionaryEntry(value);
4803
+ if (entry === void 0) return;
4804
+ const outputEntry = cloneDictionaryEntry(entry);
4805
+ this.lifecycle.onHit?.({
4806
+ inputKey: key,
4807
+ cacheKey: key,
4808
+ cacheValue: value,
4809
+ outputValue: outputEntry
4810
+ });
4811
+ return outputEntry;
4619
4812
  }
4620
- /**
4621
- * Look up the key
4622
- */
4623
- getCache(key) {
4624
- const cacheKey = this.genKey(key);
4625
- return this.cache[cacheKey];
4813
+ getValue(key) {
4814
+ const value = getDictionaryValueAtPath(this.cache, key);
4815
+ if (value === void 0) return;
4816
+ const outputValue = cloneDictionaryValue(value);
4817
+ this.lifecycle.onDictionaryObjectCacheHit?.({
4818
+ inputKey: key,
4819
+ cacheKey: key,
4820
+ cacheValue: value,
4821
+ outputValue
4822
+ });
4823
+ return outputValue;
4824
+ }
4825
+ setValue(key, value) {
4826
+ setDictionaryValueAtPath(this.cache, key, cloneDictionaryValue(value));
4626
4827
  }
4627
- /**
4628
- * Get the internal cache
4629
- * @returns The internal cache
4630
- *
4631
- * @internal - used by gt-tanstack-start
4632
- */
4633
4828
  getInternalCache() {
4634
- return Object.fromEntries(Object.entries(this.cache).map(([key, value]) => [key, copyCacheValue(value)]));
4829
+ return cloneDictionaryValue(this.cache);
4830
+ }
4831
+ async materializeValue(key, sourceValue, targetValue = getDictionaryValueAtPath(this.cache, key)) {
4832
+ let materializationPromise = this.pendingMaterializations.get(key);
4833
+ if (!materializationPromise) {
4834
+ materializationPromise = materializeDictionaryValue({
4835
+ key,
4836
+ sourceValue,
4837
+ targetValue,
4838
+ translateEntry: async (entryKey, sourceEntry) => getDictionaryValue(await this.materializeEntry(entryKey, sourceEntry))
4839
+ }).then((value) => {
4840
+ this.setValue(key, value);
4841
+ return value;
4842
+ });
4843
+ this.pendingMaterializations.set(key, materializationPromise);
4844
+ }
4845
+ try {
4846
+ return await materializationPromise;
4847
+ } finally {
4848
+ this.pendingMaterializations.delete(key);
4849
+ }
4635
4850
  }
4636
- /**
4637
- * Get the mutable cache for subclasses that need custom read/write behavior.
4638
- */
4639
- getMutableCache() {
4640
- return this.cache;
4851
+ async materializeEntry(key, sourceEntry) {
4852
+ let translationPromise = this.pendingTranslations.get(key);
4853
+ if (!translationPromise) {
4854
+ translationPromise = this.runtimeTranslate(key, sourceEntry).then((value) => {
4855
+ setDictionaryValueAtPath(this.cache, key, value);
4856
+ const entry = getDictionaryEntry(value);
4857
+ if (entry === void 0) throw new Error("DictionaryCache materializeEntry did not return a DictionaryEntry");
4858
+ this.lifecycle.onMiss?.({
4859
+ inputKey: key,
4860
+ cacheKey: key,
4861
+ cacheValue: value,
4862
+ outputValue: cloneDictionaryEntry(entry)
4863
+ });
4864
+ return cloneDictionaryEntry(entry);
4865
+ });
4866
+ this.pendingTranslations.set(key, translationPromise);
4867
+ }
4868
+ try {
4869
+ return cloneDictionaryEntry(await translationPromise);
4870
+ } finally {
4871
+ this.pendingTranslations.delete(key);
4872
+ }
4641
4873
  }
4642
- /**
4643
- * Fallback to the value from the fallback function on a cache miss
4644
- * @important assumes that the fallback error handling done upstream
4645
- */
4646
- async missCache(...args) {
4647
- const key = args[0];
4648
- const cacheKey = this.genKey(key);
4649
- if (this.fallbackPromises[cacheKey] !== void 0) return await this.fallbackPromises[cacheKey];
4650
- const fallbackPromise = this.fallback(...args);
4651
- this.fallbackPromises[cacheKey] = fallbackPromise;
4874
+ };
4875
+ var ResourceCache = class {
4876
+ constructor({ load, lifecycle = {}, ttl }) {
4877
+ this.cache = /* @__PURE__ */ new Map();
4878
+ this.pendingLoads = /* @__PURE__ */ new Map();
4879
+ this.loadResource = load;
4880
+ this.lifecycle = lifecycle;
4881
+ this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4882
+ }
4883
+ get(key) {
4884
+ const entry = this.cache.get(key);
4885
+ if (!entry || this.isExpired(entry)) return;
4886
+ this.lifecycle.onHit?.({
4887
+ inputKey: key,
4888
+ cacheKey: key,
4889
+ cacheValue: entry,
4890
+ outputValue: entry.value
4891
+ });
4892
+ return entry.value;
4893
+ }
4894
+ set(key, value, { expiresAt = this.getExpiresAt() } = {}) {
4895
+ this.cache.set(key, {
4896
+ expiresAt,
4897
+ value
4898
+ });
4899
+ }
4900
+ async getOrLoad(key) {
4901
+ return this.get(key) ?? await this.load(key);
4902
+ }
4903
+ async load(key) {
4904
+ let loadPromise = this.pendingLoads.get(key);
4905
+ if (!loadPromise) {
4906
+ loadPromise = this.loadResource(key).then((value) => {
4907
+ const entry = {
4908
+ expiresAt: this.getExpiresAt(),
4909
+ value
4910
+ };
4911
+ this.cache.set(key, entry);
4912
+ this.lifecycle.onMiss?.({
4913
+ inputKey: key,
4914
+ cacheKey: key,
4915
+ cacheValue: entry,
4916
+ outputValue: entry.value
4917
+ });
4918
+ return entry;
4919
+ });
4920
+ this.pendingLoads.set(key, loadPromise);
4921
+ }
4652
4922
  try {
4653
- const value = await fallbackPromise;
4654
- this.setCache(cacheKey, value);
4655
- return value;
4923
+ return (await loadPromise).value;
4656
4924
  } finally {
4657
- delete this.fallbackPromises[cacheKey];
4925
+ this.pendingLoads.delete(key);
4658
4926
  }
4659
4927
  }
4928
+ getExpiresAt() {
4929
+ return this.ttl < 0 ? this.ttl : Date.now() + this.ttl;
4930
+ }
4931
+ isExpired(entry) {
4932
+ return entry.expiresAt > 0 && entry.expiresAt < Date.now();
4933
+ }
4660
4934
  };
4661
4935
  /**
4662
4936
  * Hash a message string
@@ -4701,20 +4975,22 @@ function normalizeBatchConfig(batchConfig) {
4701
4975
  * Locale logic is handled at the LocalesCache level. Use a callback function that has the
4702
4976
  * locale parameter embedded if you wish to use the locale code.
4703
4977
  */
4704
- var TranslationsCache = class extends Cache {
4978
+ var TranslationsCache = class {
4705
4979
  /**
4706
4980
  * Constructor
4707
4981
  * @param {Object} params - The parameters for the cache
4708
4982
  * @param {Record<Hash, TranslationValue>} params.init - The initial cache
4709
4983
  * @param {Function} params.fallback - Get the fallback value for a cache miss
4710
4984
  */
4711
- constructor({ init, translateMany, lifecycle, batchConfig }) {
4712
- super(init, lifecycle);
4713
- this._queue = [];
4714
- this._batchTimer = null;
4715
- this._activeRequests = 0;
4716
- this._translateMany = translateMany;
4717
- this._batchConfig = normalizeBatchConfig(batchConfig);
4985
+ constructor({ init, translateMany, lifecycle = {}, batchConfig }) {
4986
+ this.pendingTranslations = /* @__PURE__ */ new Map();
4987
+ this.queue = [];
4988
+ this.batchTimer = null;
4989
+ this.activeRequests = 0;
4990
+ this.cache = structuredClone(init);
4991
+ this.translateMany = translateMany;
4992
+ this.batchConfig = normalizeBatchConfig(batchConfig);
4993
+ this.lifecycle = lifecycle;
4718
4994
  }
4719
4995
  /**
4720
4996
  * Get the translation value for a given key
@@ -4722,10 +4998,11 @@ var TranslationsCache = class extends Cache {
4722
4998
  * @returns The translation value
4723
4999
  */
4724
5000
  get(key) {
4725
- const value = this.getCache(key);
4726
- if (value != null && this.onHit) this.onHit({
5001
+ const cacheKey = this.getCacheKey(key);
5002
+ const value = this.cache[cacheKey];
5003
+ if (value != null) this.lifecycle.onHit?.({
4727
5004
  inputKey: key,
4728
- cacheKey: this.genKey(key),
5005
+ cacheKey,
4729
5006
  cacheValue: value,
4730
5007
  outputValue: value
4731
5008
  });
@@ -4737,75 +5014,64 @@ var TranslationsCache = class extends Cache {
4737
5014
  * @returns The translation value
4738
5015
  */
4739
5016
  async miss(key) {
4740
- const value = await this.missCache(key);
4741
- if (value != null && this.onMiss) this.onMiss({
4742
- inputKey: key,
4743
- cacheKey: this.genKey(key),
4744
- cacheValue: value,
4745
- outputValue: value
4746
- });
4747
- return value;
5017
+ const cacheKey = this.getCacheKey(key);
5018
+ let translationPromise = this.pendingTranslations.get(cacheKey);
5019
+ if (!translationPromise) {
5020
+ translationPromise = this.translate(key);
5021
+ this.pendingTranslations.set(cacheKey, translationPromise);
5022
+ }
5023
+ try {
5024
+ const value = await translationPromise;
5025
+ if (value != null) this.lifecycle.onMiss?.({
5026
+ inputKey: key,
5027
+ cacheKey,
5028
+ cacheValue: value,
5029
+ outputValue: value
5030
+ });
5031
+ return value;
5032
+ } finally {
5033
+ this.pendingTranslations.delete(cacheKey);
5034
+ }
4748
5035
  }
4749
- /**
4750
- * Generate a key for the cache
4751
- * @param key - The translation key
4752
- * @returns The key
4753
- */
4754
- genKey(key) {
5036
+ getInternalCache() {
5037
+ return structuredClone(this.cache);
5038
+ }
5039
+ getCacheKey(key) {
4755
5040
  return hashMessage(key.message, key.options);
4756
5041
  }
4757
- /**
4758
- * Get the fallback value for a cache miss
4759
- * @param key - The translation key
4760
- * @returns The fallback value
4761
- */
4762
- fallback(key) {
4763
- const translationPromise = this._enqueueTranslation(key);
4764
- if (this._queue.length >= this._batchConfig.maxBatchSize) this._flushNow();
4765
- else this._scheduleBatch();
5042
+ translate(key) {
5043
+ const translationPromise = this.enqueueTranslation(key);
5044
+ if (this.queue.length >= this.batchConfig.maxBatchSize) this.flushNow();
5045
+ else this.scheduleBatch();
4766
5046
  return translationPromise;
4767
5047
  }
4768
- /**
4769
- * Flush the queue now
4770
- */
4771
- _flushNow() {
4772
- if (this._batchTimer) {
4773
- clearTimeout(this._batchTimer);
4774
- this._batchTimer = null;
5048
+ flushNow() {
5049
+ if (this.batchTimer) {
5050
+ clearTimeout(this.batchTimer);
5051
+ this.batchTimer = null;
4775
5052
  }
4776
- this._drainQueue();
4777
- }
4778
- /**
4779
- * Schedule a batch of translations
4780
- */
4781
- _scheduleBatch() {
4782
- if (this._batchTimer) return;
4783
- this._batchTimer = setTimeout(() => {
4784
- this._batchTimer = null;
4785
- this._drainQueue();
4786
- }, this._batchConfig.batchInterval);
4787
- }
4788
- /**
4789
- * Drain the queue
4790
- */
4791
- _drainQueue() {
4792
- while (this._queue.length > 0 && this._activeRequests < this._batchConfig.maxConcurrentRequests) {
4793
- const batch = this._queue.splice(0, this._batchConfig.maxBatchSize);
4794
- this._sendBatchRequest(batch);
5053
+ this.drainQueue();
5054
+ }
5055
+ scheduleBatch() {
5056
+ if (this.batchTimer) return;
5057
+ this.batchTimer = setTimeout(() => {
5058
+ this.batchTimer = null;
5059
+ this.drainQueue();
5060
+ }, this.batchConfig.batchInterval);
5061
+ }
5062
+ drainQueue() {
5063
+ while (this.queue.length > 0 && this.activeRequests < this.batchConfig.maxConcurrentRequests) {
5064
+ const batch = this.queue.splice(0, this.batchConfig.maxBatchSize);
5065
+ this.sendBatchRequest(batch);
4795
5066
  }
4796
- if (this._queue.length > 0) this._scheduleBatch();
5067
+ if (this.queue.length > 0) this.scheduleBatch();
4797
5068
  }
4798
- /**
4799
- * Enqueue translation request and return a promise that resolves when the translation is ready
4800
- * @param {TranslationKey<TranslationValue>} key - The translation key
4801
- * @returns {Promise<TranslationValue>} The translation promise
4802
- */
4803
- _enqueueTranslation(key) {
4804
- const hash = this.genKey(key);
5069
+ enqueueTranslation(key) {
5070
+ const hash = this.getCacheKey(key);
4805
5071
  const options = key.options;
4806
5072
  const metadataOptions = options;
4807
5073
  return new Promise((resolve, reject) => {
4808
- this._queue.push({
5074
+ this.queue.push({
4809
5075
  key: hash,
4810
5076
  source: key.message,
4811
5077
  metadata: {
@@ -4820,38 +5086,28 @@ var TranslationsCache = class extends Cache {
4820
5086
  });
4821
5087
  });
4822
5088
  }
4823
- /**
4824
- * Send a batch request for translations
4825
- * @param {QueueEntry<TranslationValue>[]} batch - The batch of requests to send
4826
- */
4827
- async _sendBatchRequest(batch) {
4828
- this._activeRequests++;
5089
+ async sendBatchRequest(batch) {
5090
+ this.activeRequests++;
4829
5091
  const requests = convertBatchToTranslateManyParams(batch);
4830
- const response = await this._sendBatchRequestWithErrorHandling(batch, requests);
4831
- if (response) this._handleTranslationResponse(batch, response);
4832
- this._activeRequests--;
5092
+ const response = await this.sendBatchRequestWithErrorHandling(batch, requests);
5093
+ if (response) this.handleTranslationResponse(batch, response);
5094
+ this.activeRequests--;
4833
5095
  }
4834
- /**
4835
- * Send a translation request with error handling
4836
- */
4837
- async _sendBatchRequestWithErrorHandling(batch, requests) {
5096
+ async sendBatchRequestWithErrorHandling(batch, requests) {
4838
5097
  try {
4839
- return await this._translateMany(requests);
5098
+ return await this.translateMany(requests);
4840
5099
  } catch (error) {
4841
5100
  for (const entry of batch) entry.reject(error);
4842
5101
  return;
4843
5102
  }
4844
5103
  }
4845
- /**
4846
- * Handle a translation response
4847
- */
4848
- _handleTranslationResponse(batch, response) {
5104
+ handleTranslationResponse(batch, response) {
4849
5105
  for (const entry of batch) {
4850
5106
  const { key } = entry;
4851
5107
  const result = response[key];
4852
5108
  if (result && result.success) {
4853
5109
  const translation = result.translation;
4854
- this.setCache(key, translation);
5110
+ this.cache[key] = translation;
4855
5111
  entry.resolve(translation);
4856
5112
  } else entry.reject(result?.error);
4857
5113
  }
@@ -4869,415 +5125,87 @@ function convertBatchToTranslateManyParams(batch) {
4869
5125
  return acc;
4870
5126
  }, {});
4871
5127
  }
4872
- /**
4873
- * Default cache expiry time in milliseconds
4874
- */
4875
- const DEFAULT_CACHE_EXPIRY_TIME = 6e4;
4876
- /**
4877
- * Cache for looking up translations by locale
4878
- */
4879
- var LocalesCache = class extends Cache {
4880
- /**
4881
- * Constructor
4882
- * @param {Object} params - The parameters for the cache
4883
- * @param {Record<string, CacheEntry<TranslationValue>>} params.init - The initial cache
4884
- * @param {number | null} params.ttl - The time to live for cache entries
4885
- * @param {SafeTranslationsLoader<TranslationValue>} params.loadTranslations - The translation loader function
4886
- * @param {CreateTranslateMany} params.createTranslateMany - Factory function for creating a translate many function
4887
- */
4888
- constructor({ init = {}, ttl, batchConfig, loadTranslations, createTranslateMany, lifecycle: { onLocalesCacheHit: onHit, onLocalesCacheMiss: onMiss, onTranslationsCacheHit, onTranslationsCacheMiss } }) {
4889
- super(init, {
4890
- onHit,
4891
- onMiss
5128
+ var LocalesCache = class {
5129
+ constructor({ ttl, batchConfig, defaultLocale, dictionary = {}, loadTranslations, loadDictionary, createTranslateMany, translateDictionaryEntry, lifecycle }) {
5130
+ this.translations = new ResourceCache({
5131
+ ttl,
5132
+ load: async (locale) => new TranslationsCache({
5133
+ init: await loadTranslations(locale),
5134
+ lifecycle: createTranslationsCacheLifecycle(locale, lifecycle),
5135
+ translateMany: createTranslateMany(locale),
5136
+ batchConfig
5137
+ }),
5138
+ lifecycle: {
5139
+ onHit: lifecycle.onLocalesCacheHit,
5140
+ onMiss: lifecycle.onLocalesCacheMiss
5141
+ }
4892
5142
  });
4893
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
4894
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
4895
- this._translationLoader = loadTranslations;
4896
- this._createTranslateMany = createTranslateMany;
4897
- this._batchConfig = batchConfig;
4898
- this._onTranslationsCacheHit = onTranslationsCacheHit;
4899
- this._onTranslationsCacheMiss = onTranslationsCacheMiss;
4900
- }
4901
- /**
4902
- * Get the translations for a given locale
4903
- * @param key - The locale
4904
- * @returns The translations
4905
- */
4906
- get(key) {
4907
- const entry = this.getCache(key);
4908
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
4909
- const value = entry.translationsCache;
4910
- if (value != null && this.onHit) this.onHit({
4911
- inputKey: key,
4912
- cacheKey: this.genKey(key),
4913
- cacheValue: entry,
4914
- outputValue: value
5143
+ this.dictionaries = new ResourceCache({
5144
+ ttl,
5145
+ load: async (locale) => createDictionaryCache({
5146
+ locale,
5147
+ dictionary: await loadDictionary(locale),
5148
+ translate: translateDictionaryEntry,
5149
+ lifecycle
5150
+ }),
5151
+ lifecycle: {
5152
+ onHit: lifecycle.onLocalesDictionaryCacheHit,
5153
+ onMiss: lifecycle.onLocalesDictionaryCacheMiss
5154
+ }
4915
5155
  });
4916
- return value;
5156
+ this.dictionaries.set(defaultLocale, createDictionaryCache({
5157
+ locale: defaultLocale,
5158
+ dictionary,
5159
+ translate: translateDictionaryEntry,
5160
+ lifecycle
5161
+ }), { expiresAt: -1 });
4917
5162
  }
4918
- /**
4919
- * Miss the cache
4920
- * @param key - The locale
4921
- * @returns The translations cache
4922
- */
4923
- async miss(key) {
4924
- const cacheValue = await this.missCache(key);
4925
- const value = cacheValue.translationsCache;
4926
- if (value != null && this.onMiss) this.onMiss({
4927
- inputKey: key,
4928
- cacheKey: this.genKey(key),
4929
- cacheValue,
4930
- outputValue: value
4931
- });
4932
- return value;
5163
+ getTranslations(locale) {
5164
+ return this.translations.get(locale);
4933
5165
  }
4934
- /**
4935
- * Generate the cache key for a given locale
4936
- * @param key - The locale
4937
- * @returns The cache key
4938
- *
4939
- * This is just an identity function, no transformation needed
4940
- */
4941
- genKey(key) {
4942
- return key;
5166
+ getOrLoadTranslations(locale) {
5167
+ return this.translations.getOrLoad(locale);
4943
5168
  }
4944
- /**
4945
- * Fallback for a cache miss
4946
- * @param locale - The locale
4947
- * @returns The cache entry
4948
- */
4949
- async fallback(locale) {
4950
- return {
4951
- translationsCache: new TranslationsCache({
4952
- init: await this._translationLoader(locale),
4953
- lifecycle: this._createTranslationsCacheLifecycle(locale),
4954
- translateMany: this._createTranslateMany(locale),
4955
- batchConfig: this._batchConfig
4956
- }),
4957
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
4958
- };
5169
+ getDictionary(locale) {
5170
+ return this.dictionaries.get(locale);
4959
5171
  }
4960
- /**
4961
- * Create the translations cache lifecycle
4962
- * @param locale - The locale
4963
- * @returns The translations cache lifecycle
4964
- */
4965
- _createTranslationsCacheLifecycle(locale) {
4966
- return {
4967
- onHit: this._onTranslationsCacheHit ? (params) => this._onTranslationsCacheHit({
4968
- locale,
4969
- ...params
4970
- }) : void 0,
4971
- onMiss: this._onTranslationsCacheMiss ? (params) => this._onTranslationsCacheMiss({
4972
- locale,
4973
- ...params
4974
- }) : void 0
4975
- };
5172
+ getOrLoadDictionary(locale) {
5173
+ return this.dictionaries.getOrLoad(locale);
4976
5174
  }
4977
5175
  };
4978
- function getDictionaryPath(id) {
4979
- if (!id) return [];
4980
- return id.split(".");
4981
- }
4982
- function isDictionaryValue(value) {
4983
- return typeof value === "object" && value != null && !Array.isArray(value);
4984
- }
4985
- function getDictionaryEntry(value) {
4986
- if (!isDictionaryLeafNode(value)) return;
5176
+ function createTranslationsCacheLifecycle(locale, lifecycle) {
4987
5177
  return {
4988
- entry: Array.isArray(value) ? value[0] : value,
4989
- options: Array.isArray(value) ? value[1] ?? {} : {}
4990
- };
4991
- }
4992
- function getDictionaryValue(value) {
4993
- if (Object.keys(value.options).length === 0) return value.entry;
4994
- return [value.entry, value.options];
4995
- }
4996
- function resolveDictionaryLookupOptions(options) {
4997
- const { $format, ...rest } = options;
4998
- return {
4999
- ...rest,
5000
- $format: isStringFormat($format) ? $format : "ICU",
5001
- ...rest.$context === void 0 && typeof rest.context === "string" && { $context: rest.context }
5178
+ onHit: withLocale(locale, lifecycle.onTranslationsCacheHit),
5179
+ onMiss: withLocale(locale, lifecycle.onTranslationsCacheMiss)
5002
5180
  };
5003
5181
  }
5004
- function isDictionaryLeafNode(value) {
5005
- if (typeof value === "string") return true;
5006
- if (!Array.isArray(value) || typeof value[0] !== "string") return false;
5007
- if (value.length === 1) return true;
5008
- return value.length === 2 && isDictionaryOptions(value[1]);
5009
- }
5010
- function isDictionaryOptions(value) {
5011
- if (typeof value !== "object" || value == null || Array.isArray(value)) return false;
5012
- const options = value;
5013
- 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");
5014
- }
5015
- function isStringFormat(value) {
5016
- return value === "ICU" || value === "I18NEXT" || value === "STRING";
5182
+ function createDictionaryCache({ locale, dictionary, translate, lifecycle }) {
5183
+ const { onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } = lifecycle;
5184
+ return new DictionaryCache({
5185
+ init: dictionary,
5186
+ runtimeTranslate: (key, sourceEntry) => translate(locale, key, sourceEntry),
5187
+ lifecycle: {
5188
+ onHit: withLocale(locale, onDictionaryCacheHit),
5189
+ onMiss: withLocale(locale, onDictionaryCacheMiss),
5190
+ onDictionaryObjectCacheHit: withLocale(locale, onDictionaryObjectCacheHit)
5191
+ }
5192
+ });
5017
5193
  }
5018
- function replaceDictionary(target, source) {
5019
- for (const key of Object.keys(target)) delete target[key];
5020
- Object.assign(target, source);
5194
+ function withLocale(locale, callback) {
5195
+ return callback ? (params) => callback({
5196
+ locale,
5197
+ ...params
5198
+ }) : void 0;
5021
5199
  }
5022
- var DictionarySourceNotFoundError = class extends Error {
5023
- constructor(id) {
5024
- super(`I18nManager: source dictionary entry ${id} is not defined`);
5025
- this.name = "DictionarySourceNotFoundError";
5026
- }
5027
- };
5028
- /**
5029
- * A cache for a single locale's dictionary
5030
- *
5031
- * Principles:
5032
- * - This class is language agnostic, and should never store the locale code as a parameter.
5033
- * Locale logic is handled at the LocalesDictionaryCache level. Use a callback function
5034
- * that has the locale parameter embedded if you wish to use the locale code.
5035
- */
5036
- var DictionaryCache = class extends Cache {
5037
- /**
5038
- * Constructor
5039
- * @param {Object} params - The parameters for the cache
5040
- * @param {Dictionary} params.init - The initial cache
5041
- */
5042
- constructor({ init, lifecycle, runtimeTranslate }) {
5043
- super(init, lifecycle);
5044
- this._runtimeTranslate = runtimeTranslate;
5045
- this.onHitObj = lifecycle?.onHitObj;
5046
- this.onMissObj = lifecycle?.onMissObj;
5047
- }
5048
- /**
5049
- * Get the dictionary value for a given key
5050
- * @param key - The dictionary key
5051
- * @returns The dictionary value
5052
- */
5053
- get(key) {
5054
- const value = this.getCache(key);
5055
- const entry = getDictionaryEntry(value);
5056
- if (entry === void 0) return;
5057
- if (this.onHit) this.onHit({
5058
- inputKey: key,
5059
- cacheKey: this.genKey(key),
5060
- cacheValue: value,
5061
- outputValue: entry
5062
- });
5063
- return entry;
5064
- }
5065
- set(key, value) {
5066
- const dictionaryValue = getDictionaryValue(value);
5067
- this.setCache(this.genKey(key), dictionaryValue);
5068
- }
5069
- getObj(key) {
5070
- const value = this.getCache(key);
5071
- if (value === void 0) return;
5072
- const outputValue = structuredClone(value);
5073
- if (this.onHitObj) this.onHitObj({
5074
- inputKey: key,
5075
- cacheKey: this.genKey(key),
5076
- cacheValue: value,
5077
- outputValue
5078
- });
5079
- return outputValue;
5080
- }
5081
- setObj(key, value) {
5082
- this.setCache(this.genKey(key), structuredClone(value));
5083
- }
5084
- async missObj(key, sourceObject) {
5085
- const sourceEntry = getDictionaryEntry(sourceObject);
5086
- if (sourceEntry !== void 0) return getDictionaryValue(await this.miss(key, sourceEntry));
5087
- if (!isDictionaryValue(sourceObject)) throw new DictionarySourceNotFoundError(key);
5088
- const translatedEntries = await Promise.all(Object.entries(sourceObject).map(async ([childKey, childSource]) => {
5089
- const childPath = key ? `${key}.${childKey}` : childKey;
5090
- return [childKey, await this.missObj(childPath, childSource)];
5091
- }));
5092
- const translatedObject = Object.fromEntries(translatedEntries);
5093
- this.setObj(key, translatedObject);
5094
- return translatedObject;
5095
- }
5096
- /**
5097
- * Miss the cache
5098
- * @param key - The dictionary key
5099
- * @returns The dictionary value
5100
- */
5101
- async miss(key, sourceEntry) {
5102
- const value = await this.missCache(key, sourceEntry);
5103
- const entry = getDictionaryEntry(value);
5104
- if (entry === void 0) throw new Error("DictionaryCache missCache did not return a DictionaryEntry");
5105
- if (this.onMiss) this.onMiss({
5106
- inputKey: key,
5107
- cacheKey: this.genKey(key),
5108
- cacheValue: value,
5109
- outputValue: entry
5110
- });
5111
- return entry;
5112
- }
5113
- /**
5114
- * Set the value for a key
5115
- */
5116
- setCache(cacheKey, value) {
5117
- const cache = this.getMutableCache();
5118
- const dictionaryPath = getDictionaryPath(cacheKey);
5119
- if (dictionaryPath.length === 0) {
5120
- if (isDictionaryValue(value)) replaceDictionary(cache, value);
5121
- return;
5122
- }
5123
- let current = cache;
5124
- for (const key of dictionaryPath.slice(0, -1)) {
5125
- const next = current[key];
5126
- if (!isDictionaryValue(next)) current[key] = {};
5127
- current = current[key];
5128
- }
5129
- current[dictionaryPath[dictionaryPath.length - 1]] = value;
5130
- }
5131
- /**
5132
- * Look up the key
5133
- */
5134
- getCache(key) {
5135
- const dictionaryPath = getDictionaryPath(this.genKey(key));
5136
- let current = this.getMutableCache();
5137
- if (dictionaryPath.length === 0) return current;
5138
- for (const pathSegment of dictionaryPath) {
5139
- if (!isDictionaryValue(current)) return;
5140
- current = current[pathSegment];
5141
- }
5142
- return current;
5143
- }
5144
- /**
5145
- * Generate a key for the cache
5146
- * @param key - The dictionary key
5147
- * @returns The key
5148
- */
5149
- genKey(key) {
5150
- return key;
5151
- }
5152
- /**
5153
- * Get the fallback value for a cache miss
5154
- * @param key - The dictionary key
5155
- * @returns The fallback value
5156
- *
5157
- * @throws {Error} - If the fallback is not implemented
5158
- */
5159
- fallback(key, sourceEntry) {
5160
- return this._runtimeTranslate(key, sourceEntry);
5161
- }
5162
- };
5163
- /**
5164
- * Cache for looking up dictionaries by locale
5165
- */
5166
- var LocalesDictionaryCache = class extends Cache {
5167
- /**
5168
- * Constructor
5169
- * @param {Object} params - The parameters for the cache
5170
- * @param {number | null} params.ttl - The time to live for cache entries
5171
- * @param {DictionaryLoader} params.loadDictionary - The dictionary loader function
5172
- */
5173
- constructor({ ttl, defaultLocale, dictionary = {}, loadDictionary, runtimeTranslate, lifecycle: { onLocalesDictionaryCacheHit: onHit, onLocalesDictionaryCacheMiss: onMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit } }) {
5174
- super({}, {
5175
- onHit,
5176
- onMiss
5177
- });
5178
- this.ttl = DEFAULT_CACHE_EXPIRY_TIME;
5179
- this.ttl = ttl === null ? -1 : ttl ?? 6e4;
5180
- this._dictionaryLoader = loadDictionary;
5181
- this._runtimeTranslate = runtimeTranslate;
5182
- this._onDictionaryCacheHit = onDictionaryCacheHit;
5183
- this._onDictionaryCacheMiss = onDictionaryCacheMiss;
5184
- this._onDictionaryObjectCacheHit = onDictionaryObjectCacheHit;
5185
- this.setCache(defaultLocale, {
5186
- dictionaryCache: new DictionaryCache({
5187
- init: dictionary,
5188
- runtimeTranslate: this._createDictionaryRuntimeTranslate(defaultLocale),
5189
- lifecycle: this._createDictionaryCacheLifecycle(defaultLocale)
5190
- }),
5191
- expiresAt: -1
5192
- });
5193
- }
5194
- /**
5195
- * Get the dictionary for a given locale
5196
- * @param key - The locale
5197
- * @returns The dictionary
5198
- */
5199
- get(key) {
5200
- const entry = this.getCache(key);
5201
- if (!entry || entry.expiresAt > 0 && entry.expiresAt < Date.now()) return;
5202
- const value = entry.dictionaryCache;
5203
- if (value != null && this.onHit) this.onHit({
5204
- inputKey: key,
5205
- cacheKey: this.genKey(key),
5206
- cacheValue: entry,
5207
- outputValue: value
5208
- });
5209
- return value;
5210
- }
5211
- /**
5212
- * Miss the cache
5213
- * @param key - The locale
5214
- * @returns The dictionary cache
5215
- */
5216
- async miss(key) {
5217
- const cacheValue = await this.missCache(key);
5218
- const value = cacheValue.dictionaryCache;
5219
- if (value != null && this.onMiss) this.onMiss({
5220
- inputKey: key,
5221
- cacheKey: this.genKey(key),
5222
- cacheValue,
5223
- outputValue: value
5224
- });
5225
- return value;
5226
- }
5227
- /**
5228
- * Generate the cache key for a given locale
5229
- * @param key - The locale
5230
- * @returns The cache key
5231
- *
5232
- * This is just an identity function, no transformation needed
5233
- */
5234
- genKey(key) {
5235
- return key;
5236
- }
5237
- /**
5238
- * Fallback for a cache miss
5239
- * @param locale - The locale
5240
- * @returns The cache entry
5241
- */
5242
- async fallback(locale) {
5243
- return {
5244
- dictionaryCache: new DictionaryCache({
5245
- init: await this._dictionaryLoader(locale),
5246
- runtimeTranslate: this._createDictionaryRuntimeTranslate(locale),
5247
- lifecycle: this._createDictionaryCacheLifecycle(locale)
5248
- }),
5249
- expiresAt: this.ttl < 0 ? this.ttl : Date.now() + this.ttl
5250
- };
5251
- }
5252
- /**
5253
- * Create the dictionary cache lifecycle
5254
- * @param locale - The locale
5255
- * @returns The dictionary cache lifecycle
5256
- */
5257
- _createDictionaryCacheLifecycle(locale) {
5258
- return {
5259
- onHit: this._onDictionaryCacheHit ? (params) => this._onDictionaryCacheHit({
5260
- locale,
5261
- ...params
5262
- }) : void 0,
5263
- onMiss: this._onDictionaryCacheMiss ? (params) => this._onDictionaryCacheMiss({
5264
- locale,
5265
- ...params
5266
- }) : void 0,
5267
- onHitObj: this._onDictionaryObjectCacheHit ? (params) => this._onDictionaryObjectCacheHit({
5268
- locale,
5269
- ...params
5270
- }) : void 0
5271
- };
5272
- }
5273
- _createDictionaryRuntimeTranslate(locale) {
5274
- return (key, sourceEntry) => this._runtimeTranslate(locale, key, sourceEntry);
5275
- }
5276
- };
5200
+ const LOCALES_CACHE_HIT_EVENT_NAME = "locales-cache-hit";
5277
5201
  const LOCALES_CACHE_MISS_EVENT_NAME = "locales-cache-miss";
5202
+ const TRANSLATIONS_CACHE_HIT_EVENT_NAME = "translations-cache-hit";
5278
5203
  const TRANSLATIONS_CACHE_MISS_EVENT_NAME = "translations-cache-miss";
5204
+ const LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME = "locales-dictionary-cache-hit";
5279
5205
  const LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME = "locales-dictionary-cache-miss";
5206
+ const DICTIONARY_CACHE_HIT_EVENT_NAME = "dictionary-cache-hit";
5280
5207
  const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5208
+ const DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME = "dictionary-object-cache-hit";
5281
5209
  /**
5282
5210
  * Maps consumer-facing lifecycle callbacks to internal locales cache lifecycle callbacks.
5283
5211
  * The consumer API exposes simplified params (locale, hash, value) while the internal
@@ -5285,22 +5213,24 @@ const DICTIONARY_CACHE_MISS_EVENT_NAME = "dictionary-cache-miss";
5285
5213
  *
5286
5214
  * @deprecated - move to subscription api instead
5287
5215
  */
5288
- function createLifecycleCallbacks(emit) {
5216
+ function createLifecycleCallbacks(emit, hasListeners = () => true) {
5289
5217
  return {
5290
5218
  onLocalesCacheHit: (params) => {
5291
- emit("locales-cache-hit", {
5219
+ if (!hasListeners("locales-cache-hit")) return;
5220
+ emit(LOCALES_CACHE_HIT_EVENT_NAME, {
5292
5221
  locale: params.inputKey,
5293
5222
  translations: params.outputValue.getInternalCache()
5294
5223
  });
5295
5224
  },
5296
5225
  onLocalesCacheMiss: (params) => {
5226
+ if (!hasListeners("locales-cache-miss")) return;
5297
5227
  emit(LOCALES_CACHE_MISS_EVENT_NAME, {
5298
5228
  locale: params.inputKey,
5299
5229
  translations: params.outputValue.getInternalCache()
5300
5230
  });
5301
5231
  },
5302
5232
  onTranslationsCacheHit: (params) => {
5303
- emit("translations-cache-hit", {
5233
+ emit(TRANSLATIONS_CACHE_HIT_EVENT_NAME, {
5304
5234
  locale: params.locale,
5305
5235
  hash: params.cacheKey,
5306
5236
  translation: params.outputValue
@@ -5314,19 +5244,21 @@ function createLifecycleCallbacks(emit) {
5314
5244
  });
5315
5245
  },
5316
5246
  onLocalesDictionaryCacheHit: (params) => {
5317
- emit("locales-dictionary-cache-hit", {
5247
+ if (!hasListeners("locales-dictionary-cache-hit")) return;
5248
+ emit(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, {
5318
5249
  locale: params.inputKey,
5319
5250
  dictionary: params.outputValue.getInternalCache()
5320
5251
  });
5321
5252
  },
5322
5253
  onLocalesDictionaryCacheMiss: (params) => {
5254
+ if (!hasListeners("locales-dictionary-cache-miss")) return;
5323
5255
  emit(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, {
5324
5256
  locale: params.inputKey,
5325
5257
  dictionary: params.outputValue.getInternalCache()
5326
5258
  });
5327
5259
  },
5328
5260
  onDictionaryCacheHit: (params) => {
5329
- emit("dictionary-cache-hit", {
5261
+ emit(DICTIONARY_CACHE_HIT_EVENT_NAME, {
5330
5262
  locale: params.locale,
5331
5263
  id: params.cacheKey,
5332
5264
  dictionaryEntry: params.outputValue
@@ -5340,7 +5272,7 @@ function createLifecycleCallbacks(emit) {
5340
5272
  });
5341
5273
  },
5342
5274
  onDictionaryObjectCacheHit: (params) => {
5343
- emit("dictionary-object-cache-hit", {
5275
+ emit(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, {
5344
5276
  locale: params.locale,
5345
5277
  id: params.cacheKey,
5346
5278
  dictionaryValue: params.outputValue
@@ -5375,6 +5307,9 @@ var EventEmitter = class {
5375
5307
  emit(eventName, event) {
5376
5308
  this.listeners[eventName]?.forEach((subscriber) => subscriber(event));
5377
5309
  }
5310
+ hasListeners(eventName) {
5311
+ return (this.listeners[eventName]?.size ?? 0) > 0;
5312
+ }
5378
5313
  };
5379
5314
  /**
5380
5315
  * Subscribes to the lifecycle callbacks and emits the events to the event emitter
@@ -5384,7 +5319,7 @@ var EventEmitter = class {
5384
5319
  * and is only used internally
5385
5320
  */
5386
5321
  function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, onTranslationsCacheHit, onTranslationsCacheMiss, onLocalesDictionaryCacheHit, onLocalesDictionaryCacheMiss, onDictionaryCacheHit, onDictionaryCacheMiss, onDictionaryObjectCacheHit }, subscribe) {
5387
- if (onLocalesCacheHit) subscribe("locales-cache-hit", (event) => {
5322
+ if (onLocalesCacheHit) subscribe(LOCALES_CACHE_HIT_EVENT_NAME, (event) => {
5388
5323
  onLocalesCacheHit({
5389
5324
  ...event,
5390
5325
  value: event.translations
@@ -5396,7 +5331,7 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5396
5331
  value: event.translations
5397
5332
  });
5398
5333
  });
5399
- if (onTranslationsCacheHit) subscribe("translations-cache-hit", (event) => {
5334
+ if (onTranslationsCacheHit) subscribe(TRANSLATIONS_CACHE_HIT_EVENT_NAME, (event) => {
5400
5335
  onTranslationsCacheHit({
5401
5336
  ...event,
5402
5337
  value: event.translation
@@ -5408,19 +5343,19 @@ function subscribeLifecycleCallbacks({ onLocalesCacheHit, onLocalesCacheMiss, on
5408
5343
  value: event.translation
5409
5344
  });
5410
5345
  });
5411
- if (onLocalesDictionaryCacheHit) subscribe("locales-dictionary-cache-hit", (event) => {
5346
+ if (onLocalesDictionaryCacheHit) subscribe(LOCALES_DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5412
5347
  onLocalesDictionaryCacheHit(event);
5413
5348
  });
5414
5349
  if (onLocalesDictionaryCacheMiss) subscribe(LOCALES_DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5415
5350
  onLocalesDictionaryCacheMiss(event);
5416
5351
  });
5417
- if (onDictionaryCacheHit) subscribe("dictionary-cache-hit", (event) => {
5352
+ if (onDictionaryCacheHit) subscribe(DICTIONARY_CACHE_HIT_EVENT_NAME, (event) => {
5418
5353
  onDictionaryCacheHit(event);
5419
5354
  });
5420
5355
  if (onDictionaryCacheMiss) subscribe(DICTIONARY_CACHE_MISS_EVENT_NAME, (event) => {
5421
5356
  onDictionaryCacheMiss(event);
5422
5357
  });
5423
- if (onDictionaryObjectCacheHit) subscribe("dictionary-object-cache-hit", (event) => {
5358
+ if (onDictionaryObjectCacheHit) subscribe(DICTIONARY_OBJECT_CACHE_HIT_EVENT_NAME, (event) => {
5424
5359
  onDictionaryObjectCacheHit(event);
5425
5360
  });
5426
5361
  }
@@ -5451,26 +5386,32 @@ var I18nManager = class extends EventEmitter {
5451
5386
  locales: this.config.locales,
5452
5387
  customMapping: this.config.customMapping
5453
5388
  });
5454
- const loadTranslations = createTranslationLoader(params);
5455
- const loadDictionary = createDictionaryLoader(params);
5389
+ const loadTranslations = routeCreateTranslationLoader({
5390
+ loadTranslations: params.loadTranslations,
5391
+ type: getLoadTranslationsType(params),
5392
+ remoteTranslationLoaderParams: {
5393
+ cacheUrl: params.cacheUrl,
5394
+ projectId: params.projectId,
5395
+ _versionId: params._versionId,
5396
+ _branchId: params._branchId,
5397
+ customMapping: params.customMapping
5398
+ }
5399
+ });
5400
+ const loadDictionary = params.loadDictionary ?? (() => Promise.resolve({}));
5456
5401
  const runtimeTranslationTimeout = this.config.runtimeTranslation?.timeout ?? DEFAULT_TRANSLATION_TIMEOUT;
5457
5402
  const runtimeTranslationMetadata = this.config.runtimeTranslation?.metadata ?? {};
5458
5403
  const createTranslateMany = createTranslateManyFactory(this.getGTClassClean(), runtimeTranslationTimeout, runtimeTranslationMetadata);
5459
5404
  subscribeLifecycleCallbacks(params.lifecycle ?? {}, (...args) => this.subscribe(...args));
5460
- const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args));
5405
+ const lifecycle = createLifecycleCallbacks((...args) => this.emit(...args), (eventName) => this.hasListeners(eventName));
5461
5406
  this.localesCache = new LocalesCache({
5462
- loadTranslations,
5463
- createTranslateMany,
5464
- lifecycle,
5465
- ttl: this.config.cacheExpiryTime,
5466
- batchConfig: this.config.batchConfig
5467
- });
5468
- this.localesDictionaryCache = new LocalesDictionaryCache({
5469
5407
  defaultLocale: this.config.defaultLocale,
5470
5408
  dictionary: params.dictionary,
5409
+ loadTranslations,
5471
5410
  loadDictionary,
5472
- runtimeTranslate: (locale, id, sourceEntry) => this.dictionaryRuntimeTranslate(locale, id, sourceEntry),
5411
+ createTranslateMany,
5412
+ translateDictionaryEntry: (locale, id, sourceEntry) => this.translateDictionaryEntry(locale, id, sourceEntry),
5473
5413
  ttl: this.config.cacheExpiryTime,
5414
+ batchConfig: this.config.batchConfig,
5474
5415
  lifecycle
5475
5416
  });
5476
5417
  }
@@ -5542,9 +5483,7 @@ var I18nManager = class extends EventEmitter {
5542
5483
  try {
5543
5484
  const translationLocale = this.resolveCacheLocale(locale);
5544
5485
  if (!translationLocale) return {};
5545
- let txCache = this.localesCache.get(translationLocale);
5546
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5547
- return txCache.getInternalCache();
5486
+ return (await this.localesCache.getOrLoadTranslations(translationLocale)).getInternalCache();
5548
5487
  } catch (error) {
5549
5488
  this.handleError(error);
5550
5489
  return {};
@@ -5557,10 +5496,8 @@ var I18nManager = class extends EventEmitter {
5557
5496
  async loadDictionary(locale) {
5558
5497
  try {
5559
5498
  const dictionaryLocale = this.resolveCacheLocale(locale);
5560
- if (!dictionaryLocale) return this.localesDictionaryCache.get(this.config.defaultLocale)?.getInternalCache() ?? {};
5561
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5562
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5563
- return dictionaryCache.getInternalCache();
5499
+ if (!dictionaryLocale) return this.getDefaultDictionaryCache()?.getInternalCache() ?? {};
5500
+ return (await this.localesCache.getOrLoadDictionary(dictionaryLocale)).getInternalCache();
5564
5501
  } catch (error) {
5565
5502
  this.handleError(error);
5566
5503
  return {};
@@ -5571,8 +5508,8 @@ var I18nManager = class extends EventEmitter {
5571
5508
  */
5572
5509
  lookupDictionary(locale, id) {
5573
5510
  try {
5574
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5575
- return this.localesDictionaryCache.get(dictionaryLocale)?.get(id);
5511
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5512
+ return this.localesCache.getDictionary(dictionaryLocale)?.getEntry(id);
5576
5513
  } catch (error) {
5577
5514
  this.handleError(error);
5578
5515
  return;
@@ -5583,8 +5520,8 @@ var I18nManager = class extends EventEmitter {
5583
5520
  */
5584
5521
  lookupDictionaryObj(locale, id) {
5585
5522
  try {
5586
- const dictionaryLocale = this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5587
- return this.localesDictionaryCache.get(dictionaryLocale)?.getObj(id);
5523
+ const dictionaryLocale = this.resolveDictionaryCacheLocale(locale);
5524
+ return this.localesCache.getDictionary(dictionaryLocale)?.getValue(id);
5588
5525
  } catch (error) {
5589
5526
  this.handleError(error);
5590
5527
  return;
@@ -5597,19 +5534,10 @@ var I18nManager = class extends EventEmitter {
5597
5534
  async lookupDictionaryWithFallback(locale, id) {
5598
5535
  try {
5599
5536
  const dictionaryLocale = this.resolveCacheLocale(locale);
5600
- if (!dictionaryLocale) {
5601
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5602
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5603
- return sourceEntry;
5604
- }
5605
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5606
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5607
- let dictionaryEntry = dictionaryCache.get(id);
5608
- if (dictionaryEntry === void 0) {
5609
- const sourceEntry = this.localesDictionaryCache.get(this.config.defaultLocale)?.get(id);
5610
- if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5611
- dictionaryEntry = await dictionaryCache.miss(id, sourceEntry);
5612
- }
5537
+ if (!dictionaryLocale) return this.getSourceDictionaryEntry(id);
5538
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5539
+ let dictionaryEntry = dictionaryCache.getEntry(id);
5540
+ if (dictionaryEntry === void 0) dictionaryEntry = await dictionaryCache.materializeEntry(id, this.getSourceDictionaryEntry(id));
5613
5541
  return dictionaryEntry;
5614
5542
  } catch (error) {
5615
5543
  this.handleError(error);
@@ -5623,25 +5551,41 @@ var I18nManager = class extends EventEmitter {
5623
5551
  async lookupDictionaryObjWithFallback(locale, id) {
5624
5552
  try {
5625
5553
  const dictionaryLocale = this.resolveCacheLocale(locale);
5626
- if (!dictionaryLocale) {
5627
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5628
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5629
- return sourceObject;
5630
- }
5631
- let dictionaryCache = this.localesDictionaryCache.get(dictionaryLocale);
5632
- if (!dictionaryCache) dictionaryCache = await this.localesDictionaryCache.miss(dictionaryLocale);
5633
- let dictionaryObject = dictionaryCache.getObj(id);
5634
- if (dictionaryObject === void 0) {
5635
- const sourceObject = this.localesDictionaryCache.get(this.config.defaultLocale)?.getObj(id);
5636
- if (sourceObject === void 0) throw new DictionarySourceNotFoundError(id);
5637
- dictionaryObject = await dictionaryCache.missObj(id, sourceObject);
5554
+ if (!dictionaryLocale) return this.getSourceDictionaryObject(id);
5555
+ const dictionaryCache = await this.localesCache.getOrLoadDictionary(dictionaryLocale);
5556
+ const targetObject = dictionaryCache.getValue(id);
5557
+ const sourceObject = this.getSourceDictionaryObject(id, { throwOnMissing: false });
5558
+ if (sourceObject === void 0) {
5559
+ if (targetObject !== void 0) return targetObject;
5560
+ throw new DictionarySourceNotFoundError(id);
5638
5561
  }
5639
- return dictionaryObject;
5562
+ return await dictionaryCache.materializeValue(id, sourceObject, targetObject);
5640
5563
  } catch (error) {
5641
5564
  this.handleError(error);
5642
5565
  return;
5643
5566
  }
5644
5567
  }
5568
+ async translateDictionaryEntry(locale, id, sourceEntry) {
5569
+ const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5570
+ 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.`);
5571
+ return translation;
5572
+ }
5573
+ getSourceDictionaryEntry(id) {
5574
+ const sourceEntry = this.getDefaultDictionaryCache()?.getEntry(id);
5575
+ if (sourceEntry === void 0) throw new DictionarySourceNotFoundError(id);
5576
+ return sourceEntry;
5577
+ }
5578
+ getSourceDictionaryObject(id, { throwOnMissing = true } = {}) {
5579
+ const sourceObject = this.getDefaultDictionaryCache()?.getValue(id);
5580
+ if (sourceObject === void 0 && throwOnMissing) throw new DictionarySourceNotFoundError(id);
5581
+ return sourceObject;
5582
+ }
5583
+ getDefaultDictionaryCache() {
5584
+ return this.localesCache.getDictionary(this.config.defaultLocale);
5585
+ }
5586
+ resolveDictionaryCacheLocale(locale) {
5587
+ return this.resolveCacheLocale(locale) ?? this.config.defaultLocale;
5588
+ }
5645
5589
  /**
5646
5590
  * Just lookup a translation
5647
5591
  */
@@ -5649,7 +5593,7 @@ var I18nManager = class extends EventEmitter {
5649
5593
  try {
5650
5594
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5651
5595
  if (!translationLocale) return message;
5652
- const txCache = this.localesCache.get(translationLocale);
5596
+ const txCache = this.localesCache.getTranslations(translationLocale);
5653
5597
  if (!txCache) return void 0;
5654
5598
  return txCache.get({
5655
5599
  message,
@@ -5687,9 +5631,7 @@ var I18nManager = class extends EventEmitter {
5687
5631
  if (!translationLocale) return (message) => message;
5688
5632
  const resolvedPrefetchEntries = resolvePrefetchEntriesByLocale(prefetchEntries, translationLocale, (entryLocale) => this.resolveCacheLocale(entryLocale) ?? this.resolveLocale(entryLocale));
5689
5633
  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}`);
5690
- let txCache = this.localesCache.get(translationLocale);
5691
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5692
- if (!txCache) return () => void 0;
5634
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5693
5635
  await Promise.all(resolvedPrefetchEntries.filter((entry) => txCache.get(entry) == null).map((entry) => txCache.miss(entry)));
5694
5636
  return (message, options = {}) => {
5695
5637
  return txCache.get({
@@ -5761,7 +5703,7 @@ var I18nManager = class extends EventEmitter {
5761
5703
  }
5762
5704
  resolveLocale(locale) {
5763
5705
  const resolvedLocale = this.localeConfig.determineLocale(locale);
5764
- if (!this.localeConfig.isValidLocale(locale) || !resolvedLocale) throw new Error(`I18nManager: validateLocale(): locale ${locale} is not valid`);
5706
+ if (!this.localeConfig.isValidLocale(locale) || !resolvedLocale) throw new Error(`Locale "${locale}" is not valid. Use a valid BCP 47 locale code or add a custom mapping.`);
5765
5707
  return resolvedLocale;
5766
5708
  }
5767
5709
  /**
@@ -5791,8 +5733,7 @@ var I18nManager = class extends EventEmitter {
5791
5733
  async lookupTranslationWithFallbackResolved(locale, message, options) {
5792
5734
  const { translationLocale, options: lookupOptions } = this.resolveLookupParams(locale, options);
5793
5735
  if (!translationLocale) return message;
5794
- let txCache = this.localesCache.get(translationLocale);
5795
- if (!txCache) txCache = await this.localesCache.miss(translationLocale);
5736
+ const txCache = await this.localesCache.getOrLoadTranslations(translationLocale);
5796
5737
  let translation = txCache.get({
5797
5738
  message,
5798
5739
  options: lookupOptions
@@ -5804,14 +5745,6 @@ var I18nManager = class extends EventEmitter {
5804
5745
  return translation;
5805
5746
  }
5806
5747
  /**
5807
- * Runtime lookup function for dictionaries
5808
- */
5809
- async dictionaryRuntimeTranslate(locale, id, sourceEntry) {
5810
- const translation = await this.lookupTranslationWithFallbackResolved(locale, sourceEntry.entry, resolveDictionaryLookupOptions(sourceEntry.options));
5811
- if (typeof translation !== "string") throw new Error(`I18nManager: dictionaryRuntimeTranslate(): unable to translate dictionary entry ${id}`);
5812
- return translation;
5813
- }
5814
- /**
5815
5748
  * A helper function to create a gt class that is locale agnostic
5816
5749
  * This is helpful for when our getLocale function is bound to a
5817
5750
  * specific context
@@ -5908,28 +5841,6 @@ function resolvePrefetchEntriesByLocale(prefetchEntries, locale, resolveLocale)
5908
5841
  }
5909
5842
  });
5910
5843
  }
5911
- /**
5912
- * Helper function for creating a translation loader
5913
- */
5914
- function createTranslationLoader(params) {
5915
- return routeCreateTranslationLoader({
5916
- loadTranslations: params.loadTranslations,
5917
- type: getLoadTranslationsType(params),
5918
- remoteTranslationLoaderParams: {
5919
- cacheUrl: params.cacheUrl,
5920
- projectId: params.projectId,
5921
- _versionId: params._versionId,
5922
- _branchId: params._branchId,
5923
- customMapping: params.customMapping
5924
- }
5925
- });
5926
- }
5927
- /**
5928
- * Helper function for creating a dictionary loader
5929
- */
5930
- function createDictionaryLoader(params) {
5931
- return params.loadDictionary ?? (() => Promise.resolve({}));
5932
- }
5933
5844
  let i18nManager = void 0;
5934
5845
  let fallbackDefaultLocale = "en";
5935
5846
  const fallbackConditionStore = { getLocale: () => fallbackDefaultLocale };
@@ -5941,7 +5852,7 @@ let conditionStore = fallbackConditionStore;
5941
5852
  */
5942
5853
  function getI18nManager() {
5943
5854
  if (!i18nManager) {
5944
- logger_default.warn("getI18nManager(): Translation failed because I18nManager not initialized.");
5855
+ logger_default.warn("getI18nManager(): I18nManager was not initialized. Falling back to the default locale until initializeGT() configures translations.");
5945
5856
  i18nManager = new I18nManager({
5946
5857
  defaultLocale: "en",
5947
5858
  locales: ["en"]
@@ -6235,7 +6146,40 @@ var c = Object.defineProperty, l = Object.getOwnPropertyDescriptor, u = Object.g
6235
6146
  });
6236
6147
  return e;
6237
6148
  }, g = (e) => d.call(e, `module.exports`) ? e[`module.exports`] : h(c({}, `__esModule`, { value: !0 }), e);
6238
- function C(e) {
6149
+ function b(e) {
6150
+ let t = e.trim();
6151
+ return t ? /[.!?)]$/.test(t) ? t : `${t}.` : ``;
6152
+ }
6153
+ function x(e) {
6154
+ let t = e.trim(), n = t.length;
6155
+ for (; n > 0;) {
6156
+ let e = t[n - 1];
6157
+ if (e !== `.` && e !== `!` && e !== `?`) break;
6158
+ --n;
6159
+ }
6160
+ return t.slice(0, n);
6161
+ }
6162
+ function te(e) {
6163
+ return e.replace(/^[A-Z][a-z]/, (e) => e.toLowerCase());
6164
+ }
6165
+ function ne(e) {
6166
+ if (!e) return ``;
6167
+ let t = Array.isArray(e) ? e.join(`, `) : e;
6168
+ return t.trim() ? b(`Details: ${t}`) : ``;
6169
+ }
6170
+ function S({ source: e, severity: t, whatHappened: n, reassurance: r, why: i, fix: a, wayOut: o, details: s, docsUrl: c }) {
6171
+ let l = e ? t ? `${e} ${t}:` : `${e}:` : t ? `${t}:` : ``, u = i ? `${x(n)} because ${te(x(i))}` : n, d = !!a && !!o && /^[a-z]/.test(x(o)), f = [
6172
+ u,
6173
+ r,
6174
+ d ? `${x(a)}, or ${te(x(o))}` : a,
6175
+ d ? void 0 : o,
6176
+ ne(s)
6177
+ ].filter((e) => !!e).map(b);
6178
+ c && f.push(`Learn more: ${c}`);
6179
+ let p = f.join(` `);
6180
+ return l ? `${l} ${p}` : p;
6181
+ }
6182
+ function E(e) {
6239
6183
  let t = e;
6240
6184
  if (t && typeof t == `object` && typeof t.k == `string`) {
6241
6185
  let e = Object.keys(t);
@@ -6243,43 +6187,43 @@ function C(e) {
6243
6187
  }
6244
6188
  return !1;
6245
6189
  }
6246
- function w(e) {
6190
+ function ie(e) {
6247
6191
  return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === `Uint8Array` && `BYTES_PER_ELEMENT` in e && e.BYTES_PER_ELEMENT === 1;
6248
6192
  }
6249
- function T$1(e, t, n = ``) {
6250
- let r = w(e), i = e?.length, a = t !== void 0;
6193
+ function D(e, t, n = ``) {
6194
+ let r = ie(e), i = e?.length, a = t !== void 0;
6251
6195
  if (!r || a && i !== t) {
6252
6196
  let o = n && `"${n}" `, s = a ? ` of length ${t}` : ``, c = r ? `length=${i}` : `type=${typeof e}`, l = o + `expected Uint8Array` + s + `, got ` + c;
6253
6197
  throw r ? RangeError(l) : TypeError(l);
6254
6198
  }
6255
6199
  return e;
6256
6200
  }
6257
- function E(e, t = !0) {
6201
+ function ae(e, t = !0) {
6258
6202
  if (e.destroyed) throw Error(`Hash instance has been destroyed`);
6259
6203
  if (t && e.finished) throw Error(`Hash#digest() has already been called`);
6260
6204
  }
6261
- function D(e, t) {
6262
- T$1(e, void 0, `digestInto() output`);
6205
+ function oe(e, t) {
6206
+ D(e, void 0, `digestInto() output`);
6263
6207
  let n = t.outputLen;
6264
6208
  if (e.length < n) throw RangeError(`"digestInto() output" expected to be of length >=` + n);
6265
6209
  }
6266
- function O(...e) {
6210
+ function se(...e) {
6267
6211
  for (let t = 0; t < e.length; t++) e[t].fill(0);
6268
6212
  }
6269
- function k(e) {
6213
+ function ce(e) {
6270
6214
  return new DataView(e.buffer, e.byteOffset, e.byteLength);
6271
6215
  }
6272
- function A(e, t) {
6216
+ function O(e, t) {
6273
6217
  return e << 32 - t | e >>> t;
6274
6218
  }
6275
6219
  new Uint8Array(new Uint32Array([287454020]).buffer)[0];
6276
6220
  typeof Uint8Array.from([]).toHex == `function` && Uint8Array.fromHex;
6277
6221
  Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, `0`));
6278
- function oe(e, t = {}) {
6222
+ function pe(e, t = {}) {
6279
6223
  let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
6280
6224
  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);
6281
6225
  }
6282
- const se = (e) => ({ oid: Uint8Array.from([
6226
+ const me = (e) => ({ oid: Uint8Array.from([
6283
6227
  6,
6284
6228
  9,
6285
6229
  96,
@@ -6292,13 +6236,13 @@ const se = (e) => ({ oid: Uint8Array.from([
6292
6236
  2,
6293
6237
  e
6294
6238
  ]) });
6295
- function ce(e, t, n) {
6239
+ function he(e, t, n) {
6296
6240
  return e & t ^ ~e & n;
6297
6241
  }
6298
- function le(e, t, n) {
6242
+ function ge(e, t, n) {
6299
6243
  return e & t ^ e & n ^ t & n;
6300
6244
  }
6301
- var ue = class {
6245
+ var _e = class {
6302
6246
  blockLen;
6303
6247
  outputLen;
6304
6248
  canXOF = !1;
@@ -6311,15 +6255,15 @@ var ue = class {
6311
6255
  pos = 0;
6312
6256
  destroyed = !1;
6313
6257
  constructor(e, t, n, r) {
6314
- this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = k(this.buffer);
6258
+ this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = ce(this.buffer);
6315
6259
  }
6316
6260
  update(e) {
6317
- E(this), T$1(e);
6261
+ ae(this), D(e);
6318
6262
  let { view: t, buffer: n, blockLen: r } = this, i = e.length;
6319
6263
  for (let a = 0; a < i;) {
6320
6264
  let o = Math.min(r - this.pos, i - a);
6321
6265
  if (o === r) {
6322
- let t = k(e);
6266
+ let t = ce(e);
6323
6267
  for (; r <= i - a; a += r) this.process(t, a);
6324
6268
  continue;
6325
6269
  }
@@ -6328,12 +6272,12 @@ var ue = class {
6328
6272
  return this.length += e.length, this.roundClean(), this;
6329
6273
  }
6330
6274
  digestInto(e) {
6331
- E(this), D(e, this), this.finished = !0;
6275
+ ae(this), oe(e, this), this.finished = !0;
6332
6276
  let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
6333
- t[a++] = 128, O(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6277
+ t[a++] = 128, se(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
6334
6278
  for (let e = a; e < r; e++) t[e] = 0;
6335
6279
  n.setBigUint64(r - 8, BigInt(this.length * 8), i), this.process(n, 0);
6336
- let o = k(e), s = this.outputLen;
6280
+ let o = ce(e), s = this.outputLen;
6337
6281
  if (s % 4) throw Error(`_sha2: outputLen must be aligned to 32bit`);
6338
6282
  let c = s / 4, l = this.get();
6339
6283
  if (c > l.length) throw Error(`_sha2: outputLen bigger than state`);
@@ -6354,7 +6298,7 @@ var ue = class {
6354
6298
  return this._cloneInto();
6355
6299
  }
6356
6300
  };
6357
- const j = Uint32Array.from([
6301
+ const k = Uint32Array.from([
6358
6302
  1779033703,
6359
6303
  3144134277,
6360
6304
  1013904242,
@@ -6363,25 +6307,25 @@ const j = Uint32Array.from([
6363
6307
  2600822924,
6364
6308
  528734635,
6365
6309
  1541459225
6366
- ]), M = BigInt(2 ** 32 - 1), de = BigInt(32);
6367
- function fe(e, t = !1) {
6310
+ ]), A = BigInt(2 ** 32 - 1), ve = BigInt(32);
6311
+ function ye(e, t = !1) {
6368
6312
  return t ? {
6369
- h: Number(e & M),
6370
- l: Number(e >> de & M)
6313
+ h: Number(e & A),
6314
+ l: Number(e >> ve & A)
6371
6315
  } : {
6372
- h: Number(e >> de & M) | 0,
6373
- l: Number(e & M) | 0
6316
+ h: Number(e >> ve & A) | 0,
6317
+ l: Number(e & A) | 0
6374
6318
  };
6375
6319
  }
6376
- function pe(e, t = !1) {
6320
+ function be(e, t = !1) {
6377
6321
  let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
6378
6322
  for (let a = 0; a < n; a++) {
6379
- let { h: n, l: o } = fe(e[a], t);
6323
+ let { h: n, l: o } = ye(e[a], t);
6380
6324
  [r[a], i[a]] = [n, o];
6381
6325
  }
6382
6326
  return [r, i];
6383
6327
  }
6384
- const me = Uint32Array.from([
6328
+ const xe = Uint32Array.from([
6385
6329
  1116352408,
6386
6330
  1899447441,
6387
6331
  3049323471,
@@ -6446,8 +6390,8 @@ const me = Uint32Array.from([
6446
6390
  2756734187,
6447
6391
  3204031479,
6448
6392
  3329325298
6449
- ]), N = new Uint32Array(64);
6450
- var he = class extends ue {
6393
+ ]), j = new Uint32Array(64);
6394
+ var Se = class extends _e {
6451
6395
  constructor(e) {
6452
6396
  super(64, e, 8, !1);
6453
6397
  }
@@ -6468,41 +6412,41 @@ var he = class extends ue {
6468
6412
  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;
6469
6413
  }
6470
6414
  process(e, t) {
6471
- for (let n = 0; n < 16; n++, t += 4) N[n] = e.getUint32(t, !1);
6415
+ for (let n = 0; n < 16; n++, t += 4) j[n] = e.getUint32(t, !1);
6472
6416
  for (let e = 16; e < 64; e++) {
6473
- let t = N[e - 15], n = N[e - 2], r = A(t, 7) ^ A(t, 18) ^ t >>> 3;
6474
- N[e] = (A(n, 17) ^ A(n, 19) ^ n >>> 10) + N[e - 7] + r + N[e - 16] | 0;
6417
+ let t = j[e - 15], n = j[e - 2], r = O(t, 7) ^ O(t, 18) ^ t >>> 3;
6418
+ j[e] = (O(n, 17) ^ O(n, 19) ^ n >>> 10) + j[e - 7] + r + j[e - 16] | 0;
6475
6419
  }
6476
6420
  let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
6477
6421
  for (let e = 0; e < 64; e++) {
6478
- let t = A(o, 6) ^ A(o, 11) ^ A(o, 25), u = l + t + ce(o, s, c) + me[e] + N[e] | 0, d = (A(n, 2) ^ A(n, 13) ^ A(n, 22)) + le(n, r, i) | 0;
6422
+ 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;
6479
6423
  l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
6480
6424
  }
6481
6425
  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);
6482
6426
  }
6483
6427
  roundClean() {
6484
- O(N);
6428
+ se(j);
6485
6429
  }
6486
6430
  destroy() {
6487
- this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), O(this.buffer);
6488
- }
6489
- }, ge = class extends he {
6490
- A = j[0] | 0;
6491
- B = j[1] | 0;
6492
- C = j[2] | 0;
6493
- D = j[3] | 0;
6494
- E = j[4] | 0;
6495
- F = j[5] | 0;
6496
- G = j[6] | 0;
6497
- H = j[7] | 0;
6431
+ this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), se(this.buffer);
6432
+ }
6433
+ }, Ce = class extends Se {
6434
+ A = k[0] | 0;
6435
+ B = k[1] | 0;
6436
+ C = k[2] | 0;
6437
+ D = k[3] | 0;
6438
+ E = k[4] | 0;
6439
+ F = k[5] | 0;
6440
+ G = k[6] | 0;
6441
+ H = k[7] | 0;
6498
6442
  constructor() {
6499
6443
  super(32);
6500
6444
  }
6501
6445
  };
6502
- const _e = pe(`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)));
6503
- _e[0], _e[1];
6504
- oe(() => new ge(), se(1));
6505
- const ye = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, be = `DEFAULT_TERMINATOR_KEY`, xe = {
6446
+ 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)));
6447
+ we[0], we[1];
6448
+ pe(() => new Ce(), me(1));
6449
+ const Ee = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${e}.`, De = `DEFAULT_TERMINATOR_KEY`, Oe = {
6506
6450
  ellipsis: {
6507
6451
  fr: {
6508
6452
  terminator: `…`,
@@ -6516,37 +6460,35 @@ const ye = (e) => `generaltranslation Formatting Error: Invalid cutoff style: ${
6516
6460
  terminator: `……`,
6517
6461
  separator: void 0
6518
6462
  },
6519
- [be]: {
6463
+ [De]: {
6520
6464
  terminator: `…`,
6521
6465
  separator: void 0
6522
6466
  }
6523
6467
  },
6524
- none: { [be]: {
6468
+ none: { [De]: {
6525
6469
  terminator: void 0,
6526
6470
  separator: void 0
6527
6471
  } }
6528
6472
  };
6529
- var Se = class {
6530
- constructor(e, t = {}) {
6473
+ var ke = class e {
6474
+ static resolveLocale(e) {
6531
6475
  try {
6532
- let t = e ? Array.isArray(e) ? e.map((e) => String(e)) : [String(e)] : [`en`], n = Intl.getCanonicalLocales(t);
6533
- this.locale = n.length ? n[0] : `en`;
6476
+ let t = e ? Array.isArray(e) ? e.map(String) : [String(e)] : [`en`], [n] = Intl.getCanonicalLocales(t);
6477
+ return n ?? `en`;
6534
6478
  } catch {
6535
- this.locale = `en`;
6479
+ return `en`;
6536
6480
  }
6537
- if (!xe[t.style ?? `ellipsis`]) throw Error(ye(t.style ?? `ellipsis`));
6538
- let n, r;
6539
- if (t.maxChars !== void 0) {
6540
- n = t.style ?? `ellipsis`;
6541
- let e = new Intl.Locale(this.locale).language;
6542
- r = xe[n][e] || xe[n].DEFAULT_TERMINATOR_KEY;
6543
- }
6544
- let i = t.terminator ?? r?.terminator, a = i == null ? void 0 : t.separator ?? r?.separator;
6545
- this.additionLength = (i?.length ?? 0) + (a?.length ?? 0), t.maxChars !== void 0 && Math.abs(t.maxChars) < this.additionLength && (i = void 0, a = void 0), this.options = {
6546
- maxChars: t.maxChars,
6547
- style: n,
6548
- terminator: i,
6549
- separator: a
6481
+ }
6482
+ constructor(t, n = {}) {
6483
+ this.locale = e.resolveLocale(t);
6484
+ let r = n.style ?? `ellipsis`;
6485
+ if (!Oe[r]) throw Error(Ee(r));
6486
+ 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;
6487
+ 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 = {
6488
+ maxChars: n.maxChars,
6489
+ style: n.maxChars === void 0 ? void 0 : r,
6490
+ terminator: a,
6491
+ separator: o
6550
6492
  };
6551
6493
  }
6552
6494
  format(e) {
@@ -6568,7 +6510,7 @@ var Se = class {
6568
6510
  return this.options;
6569
6511
  }
6570
6512
  };
6571
- const Ce = {
6513
+ const Ae = {
6572
6514
  Collator: Intl.Collator,
6573
6515
  DateTimeFormat: Intl.DateTimeFormat,
6574
6516
  DisplayNames: Intl.DisplayNames,
@@ -6578,83 +6520,85 @@ const Ce = {
6578
6520
  PluralRules: Intl.PluralRules,
6579
6521
  RelativeTimeFormat: Intl.RelativeTimeFormat,
6580
6522
  Segmenter: Intl.Segmenter,
6581
- CutoffFormat: Se
6582
- }, we = new class {
6523
+ CutoffFormat: ke
6524
+ }, je = new class {
6583
6525
  constructor() {
6584
6526
  this.cache = {};
6585
6527
  }
6586
- _generateKey(e, t = {}) {
6528
+ generateKey(e, t = {}) {
6587
6529
  return `${e ? Array.isArray(e) ? e.map((e) => String(e)).join(`,`) : String(e) : `undefined`}:${t ? JSON.stringify(t, Object.keys(t).sort()) : `{}`}`;
6588
6530
  }
6589
6531
  get(e, ...t) {
6590
- let [n = `en`, r = {}] = t, i = this._generateKey(n, r), a = this.cache[e]?.[i];
6591
- return a === void 0 && (a = new Ce[e](...t), this.cache[e] || (this.cache[e] = {}), this.cache[e][i] = a), a;
6532
+ let [n = `en`, r = {}] = t, i = this.generateKey(n, r), a = this.cache[e];
6533
+ a === void 0 && (a = {}, this.cache[e] = a);
6534
+ let o = a[i];
6535
+ return o === void 0 && (o = new Ae[e](...t), a[i] = o), o;
6592
6536
  }
6593
6537
  }();
6594
- function Te(e) {
6595
- return we.get(`PluralRules`, e);
6596
- }
6597
- var P = m({
6598
- __addDisposableResource: () => Ze,
6599
- __assign: () => R,
6600
- __asyncDelegator: () => Ue,
6601
- __asyncGenerator: () => He,
6602
- __asyncValues: () => We,
6603
- __await: () => I,
6604
- __awaiter: () => Fe,
6605
- __classPrivateFieldGet: () => Je,
6606
- __classPrivateFieldIn: () => Xe,
6607
- __classPrivateFieldSet: () => Ye,
6608
- __createBinding: () => z,
6609
- __decorate: () => Oe,
6610
- __disposeResources: () => Qe,
6611
- __esDecorate: () => Ae,
6612
- __exportStar: () => Le,
6613
- __extends: () => Ee,
6614
- __generator: () => Ie,
6615
- __importDefault: () => qe,
6616
- __importStar: () => Ke,
6617
- __makeTemplateObject: () => Ge,
6618
- __metadata: () => Pe,
6619
- __param: () => ke,
6620
- __propKey: () => Me,
6621
- __read: () => Re,
6622
- __rest: () => De,
6623
- __rewriteRelativeImportExtension: () => $e,
6624
- __runInitializers: () => je,
6625
- __setFunctionName: () => Ne,
6626
- __spread: () => ze,
6627
- __spreadArray: () => Ve,
6628
- __spreadArrays: () => Be,
6629
- __values: () => F,
6630
- default: () => nt
6538
+ function Me(e) {
6539
+ return je.get(`PluralRules`, e);
6540
+ }
6541
+ var M = m({
6542
+ __addDisposableResource: () => it,
6543
+ __assign: () => F,
6544
+ __asyncDelegator: () => Xe,
6545
+ __asyncGenerator: () => Ye,
6546
+ __asyncValues: () => Ze,
6547
+ __await: () => P,
6548
+ __awaiter: () => He,
6549
+ __classPrivateFieldGet: () => tt,
6550
+ __classPrivateFieldIn: () => rt,
6551
+ __classPrivateFieldSet: () => nt,
6552
+ __createBinding: () => I,
6553
+ __decorate: () => Fe,
6554
+ __disposeResources: () => at,
6555
+ __esDecorate: () => Le,
6556
+ __exportStar: () => We,
6557
+ __extends: () => Ne,
6558
+ __generator: () => Ue,
6559
+ __importDefault: () => et,
6560
+ __importStar: () => $e,
6561
+ __makeTemplateObject: () => Qe,
6562
+ __metadata: () => Ve,
6563
+ __param: () => Ie,
6564
+ __propKey: () => ze,
6565
+ __read: () => Ge,
6566
+ __rest: () => Pe,
6567
+ __rewriteRelativeImportExtension: () => ot,
6568
+ __runInitializers: () => Re,
6569
+ __setFunctionName: () => Be,
6570
+ __spread: () => Ke,
6571
+ __spreadArray: () => Je,
6572
+ __spreadArrays: () => qe,
6573
+ __values: () => N,
6574
+ default: () => ut
6631
6575
  });
6632
- function Ee(e, t) {
6576
+ function Ne(e, t) {
6633
6577
  if (typeof t != `function` && t !== null) throw TypeError(`Class extends value ` + String(t) + ` is not a constructor or null`);
6634
- L(e, t);
6578
+ st(e, t);
6635
6579
  function n() {
6636
6580
  this.constructor = e;
6637
6581
  }
6638
6582
  e.prototype = t === null ? Object.create(t) : (n.prototype = t.prototype, new n());
6639
6583
  }
6640
- function De(e, t) {
6584
+ function Pe(e, t) {
6641
6585
  var n = {};
6642
6586
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
6643
6587
  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]]);
6644
6588
  return n;
6645
6589
  }
6646
- function Oe(e, t, n, r) {
6590
+ function Fe(e, t, n, r) {
6647
6591
  var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
6648
6592
  if (typeof Reflect == `object` && typeof Reflect.decorate == `function`) a = Reflect.decorate(e, t, n, r);
6649
6593
  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);
6650
6594
  return i > 3 && a && Object.defineProperty(t, n, a), a;
6651
6595
  }
6652
- function ke(e, t) {
6596
+ function Ie(e, t) {
6653
6597
  return function(n, r) {
6654
6598
  t(n, r, e);
6655
6599
  };
6656
6600
  }
6657
- function Ae(e, t, n, r, i, a) {
6601
+ function Le(e, t, n, r, i, a) {
6658
6602
  function o(e) {
6659
6603
  if (e !== void 0 && typeof e != `function`) throw TypeError(`Function expected`);
6660
6604
  return e;
@@ -6679,23 +6623,23 @@ function Ae(e, t, n, r, i, a) {
6679
6623
  }
6680
6624
  l && Object.defineProperty(l, r.name, u), f = !0;
6681
6625
  }
6682
- function je(e, t, n) {
6626
+ function Re(e, t, n) {
6683
6627
  for (var r = arguments.length > 2, i = 0; i < t.length; i++) n = r ? t[i].call(e, n) : t[i].call(e);
6684
6628
  return r ? n : void 0;
6685
6629
  }
6686
- function Me(e) {
6630
+ function ze(e) {
6687
6631
  return typeof e == `symbol` ? e : `${e}`;
6688
6632
  }
6689
- function Ne(e, t, n) {
6633
+ function Be(e, t, n) {
6690
6634
  return typeof t == `symbol` && (t = t.description ? `[${t.description}]` : ``), Object.defineProperty(e, `name`, {
6691
6635
  configurable: !0,
6692
6636
  value: n ? `${n} ${t}` : t
6693
6637
  });
6694
6638
  }
6695
- function Pe(e, t) {
6639
+ function Ve(e, t) {
6696
6640
  if (typeof Reflect == `object` && typeof Reflect.metadata == `function`) return Reflect.metadata(e, t);
6697
6641
  }
6698
- function Fe(e, t, n, r) {
6642
+ function He(e, t, n, r) {
6699
6643
  function i(e) {
6700
6644
  return e instanceof n ? e : new n(function(t) {
6701
6645
  t(e);
@@ -6722,7 +6666,7 @@ function Fe(e, t, n, r) {
6722
6666
  c((r = r.apply(e, t || [])).next());
6723
6667
  });
6724
6668
  }
6725
- function Ie(e, t) {
6669
+ function Ue(e, t) {
6726
6670
  var n = {
6727
6671
  label: 0,
6728
6672
  sent: function() {
@@ -6792,10 +6736,10 @@ function Ie(e, t) {
6792
6736
  };
6793
6737
  }
6794
6738
  }
6795
- function Le(e, t) {
6796
- for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, n) && z(t, e, n);
6739
+ function We(e, t) {
6740
+ for (var n in e) n !== `default` && !Object.prototype.hasOwnProperty.call(t, n) && I(t, e, n);
6797
6741
  }
6798
- function F(e) {
6742
+ function N(e) {
6799
6743
  var t = typeof Symbol == `function` && Symbol.iterator, n = t && e[t], r = 0;
6800
6744
  if (n) return n.call(e);
6801
6745
  if (e && typeof e.length == `number`) return { next: function() {
@@ -6806,7 +6750,7 @@ function F(e) {
6806
6750
  } };
6807
6751
  throw TypeError(t ? `Object is not iterable.` : `Symbol.iterator is not defined.`);
6808
6752
  }
6809
- function Re(e, t) {
6753
+ function Ge(e, t) {
6810
6754
  var n = typeof Symbol == `function` && e[Symbol.iterator];
6811
6755
  if (!n) return e;
6812
6756
  var r = n.call(e), i, a = [], o;
@@ -6823,23 +6767,23 @@ function Re(e, t) {
6823
6767
  }
6824
6768
  return a;
6825
6769
  }
6826
- function ze() {
6827
- for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Re(arguments[t]));
6770
+ function Ke() {
6771
+ for (var e = [], t = 0; t < arguments.length; t++) e = e.concat(Ge(arguments[t]));
6828
6772
  return e;
6829
6773
  }
6830
- function Be() {
6774
+ function qe() {
6831
6775
  for (var e = 0, t = 0, n = arguments.length; t < n; t++) e += arguments[t].length;
6832
6776
  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];
6833
6777
  return r;
6834
6778
  }
6835
- function Ve(e, t, n) {
6779
+ function Je(e, t, n) {
6836
6780
  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]);
6837
6781
  return e.concat(a || Array.prototype.slice.call(t));
6838
6782
  }
6839
- function I(e) {
6840
- return this instanceof I ? (this.v = e, this) : new I(e);
6783
+ function P(e) {
6784
+ return this instanceof P ? (this.v = e, this) : new P(e);
6841
6785
  }
6842
- function He(e, t, n) {
6786
+ function Ye(e, t, n) {
6843
6787
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
6844
6788
  var r = n.apply(e, t || []), i, a = [];
6845
6789
  return i = Object.create((typeof AsyncIterator == `function` ? AsyncIterator : Object).prototype), s(`next`), s(`throw`), s(`return`, o), i[Symbol.asyncIterator] = function() {
@@ -6870,7 +6814,7 @@ function He(e, t, n) {
6870
6814
  }
6871
6815
  }
6872
6816
  function l(e) {
6873
- e.value instanceof I ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6817
+ e.value instanceof P ? Promise.resolve(e.value.v).then(u, d) : f(a[0][2], e);
6874
6818
  }
6875
6819
  function u(e) {
6876
6820
  c(`next`, e);
@@ -6882,7 +6826,7 @@ function He(e, t, n) {
6882
6826
  e(t), a.shift(), a.length && c(a[0][0], a[0][1]);
6883
6827
  }
6884
6828
  }
6885
- function Ue(e) {
6829
+ function Xe(e) {
6886
6830
  var t, n;
6887
6831
  return t = {}, r(`next`), r(`throw`, function(e) {
6888
6832
  throw e;
@@ -6892,16 +6836,16 @@ function Ue(e) {
6892
6836
  function r(r, i) {
6893
6837
  t[r] = e[r] ? function(t) {
6894
6838
  return (n = !n) ? {
6895
- value: I(e[r](t)),
6839
+ value: P(e[r](t)),
6896
6840
  done: !1
6897
6841
  } : i ? i(t) : t;
6898
6842
  } : i;
6899
6843
  }
6900
6844
  }
6901
- function We(e) {
6845
+ function Ze(e) {
6902
6846
  if (!Symbol.asyncIterator) throw TypeError(`Symbol.asyncIterator is not defined.`);
6903
6847
  var t = e[Symbol.asyncIterator], n;
6904
- return t ? t.call(e) : (e = typeof F == `function` ? F(e) : e[Symbol.iterator](), n = {}, r(`next`), r(`throw`), r(`return`), n[Symbol.asyncIterator] = function() {
6848
+ 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() {
6905
6849
  return this;
6906
6850
  }, n);
6907
6851
  function r(t) {
@@ -6920,34 +6864,34 @@ function We(e) {
6920
6864
  }, t);
6921
6865
  }
6922
6866
  }
6923
- function Ge(e, t) {
6867
+ function Qe(e, t) {
6924
6868
  return Object.defineProperty ? Object.defineProperty(e, `raw`, { value: t }) : e.raw = t, e;
6925
6869
  }
6926
- function Ke(e) {
6870
+ function $e(e) {
6927
6871
  if (e && e.__esModule) return e;
6928
6872
  var t = {};
6929
- if (e != null) for (var n = B(e), r = 0; r < n.length; r++) n[r] !== `default` && z(t, e, n[r]);
6930
- return et(t, e), t;
6873
+ if (e != null) for (var n = L(e), r = 0; r < n.length; r++) n[r] !== `default` && I(t, e, n[r]);
6874
+ return ct(t, e), t;
6931
6875
  }
6932
- function qe(e) {
6876
+ function et(e) {
6933
6877
  return e && e.__esModule ? e : { default: e };
6934
6878
  }
6935
- function Je(e, t, n, r) {
6879
+ function tt(e, t, n, r) {
6936
6880
  if (n === `a` && !r) throw TypeError(`Private accessor was defined without a getter`);
6937
6881
  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`);
6938
6882
  return n === `m` ? r : n === `a` ? r.call(e) : r ? r.value : t.get(e);
6939
6883
  }
6940
- function Ye(e, t, n, r, i) {
6884
+ function nt(e, t, n, r, i) {
6941
6885
  if (r === `m`) throw TypeError(`Private method is not writable`);
6942
6886
  if (r === `a` && !i) throw TypeError(`Private accessor was defined without a setter`);
6943
6887
  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`);
6944
6888
  return r === `a` ? i.call(e, n) : i ? i.value = n : t.set(e, n), n;
6945
6889
  }
6946
- function Xe(e, t) {
6890
+ function rt(e, t) {
6947
6891
  if (t === null || typeof t != `object` && typeof t != `function`) throw TypeError(`Cannot use 'in' operator on non-object`);
6948
6892
  return typeof e == `function` ? t === e : e.has(t);
6949
6893
  }
6950
- function Ze(e, t, n) {
6894
+ function it(e, t, n) {
6951
6895
  if (t != null) {
6952
6896
  if (typeof t != `object` && typeof t != `function`) throw TypeError(`Object expected.`);
6953
6897
  var r, i;
@@ -6974,9 +6918,9 @@ function Ze(e, t, n) {
6974
6918
  } else n && e.stack.push({ async: !0 });
6975
6919
  return t;
6976
6920
  }
6977
- function Qe(e) {
6921
+ function at(e) {
6978
6922
  function t(t) {
6979
- e.error = e.hasError ? new tt(t, e.error, `An error was suppressed during disposal.`) : t, e.hasError = !0;
6923
+ e.error = e.hasError ? new lt(t, e.error, `An error was suppressed during disposal.`) : t, e.hasError = !0;
6980
6924
  }
6981
6925
  var n, r = 0;
6982
6926
  function i() {
@@ -6996,24 +6940,24 @@ function Qe(e) {
6996
6940
  }
6997
6941
  return i();
6998
6942
  }
6999
- function $e(e, t) {
6943
+ function ot(e, t) {
7000
6944
  return typeof e == `string` && /^\.\.?\//.test(e) ? e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(e, n, r, i, a) {
7001
6945
  return n ? t ? `.jsx` : `.js` : r && (!i || !a) ? e : r + i + `.` + a.toLowerCase() + `js`;
7002
6946
  }) : e;
7003
6947
  }
7004
- var L, R, z, et, B, tt, nt, V = f((() => {
7005
- L = function(e, t) {
7006
- return L = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
6948
+ var st, F, I, ct, L, lt, ut, R = f((() => {
6949
+ st = function(e, t) {
6950
+ return st = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
7007
6951
  e.__proto__ = t;
7008
6952
  } || function(e, t) {
7009
6953
  for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
7010
- }, L(e, t);
7011
- }, R = function() {
7012
- return R = Object.assign || function(e) {
6954
+ }, st(e, t);
6955
+ }, F = function() {
6956
+ return F = Object.assign || function(e) {
7013
6957
  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]);
7014
6958
  return e;
7015
- }, R.apply(this, arguments);
7016
- }, z = Object.create ? (function(e, t, n, r) {
6959
+ }, F.apply(this, arguments);
6960
+ }, I = Object.create ? (function(e, t, n, r) {
7017
6961
  r === void 0 && (r = n);
7018
6962
  var i = Object.getOwnPropertyDescriptor(t, n);
7019
6963
  (!i || (`get` in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
@@ -7024,63 +6968,63 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7024
6968
  }), Object.defineProperty(e, r, i);
7025
6969
  }) : (function(e, t, n, r) {
7026
6970
  r === void 0 && (r = n), e[r] = t[n];
7027
- }), et = Object.create ? (function(e, t) {
6971
+ }), ct = Object.create ? (function(e, t) {
7028
6972
  Object.defineProperty(e, `default`, {
7029
6973
  enumerable: !0,
7030
6974
  value: t
7031
6975
  });
7032
6976
  }) : function(e, t) {
7033
6977
  e.default = t;
7034
- }, B = function(e) {
7035
- return B = Object.getOwnPropertyNames || function(e) {
6978
+ }, L = function(e) {
6979
+ return L = Object.getOwnPropertyNames || function(e) {
7036
6980
  var t = [];
7037
6981
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && (t[t.length] = n);
7038
6982
  return t;
7039
- }, B(e);
7040
- }, tt = typeof SuppressedError == `function` ? SuppressedError : function(e, t, n) {
6983
+ }, L(e);
6984
+ }, lt = typeof SuppressedError == `function` ? SuppressedError : function(e, t, n) {
7041
6985
  var r = Error(n);
7042
6986
  return r.name = `SuppressedError`, r.error = e, r.suppressed = t, r;
7043
- }, nt = {
7044
- __extends: Ee,
7045
- __assign: R,
7046
- __rest: De,
7047
- __decorate: Oe,
7048
- __param: ke,
7049
- __esDecorate: Ae,
7050
- __runInitializers: je,
7051
- __propKey: Me,
7052
- __setFunctionName: Ne,
7053
- __metadata: Pe,
7054
- __awaiter: Fe,
7055
- __generator: Ie,
7056
- __createBinding: z,
7057
- __exportStar: Le,
7058
- __values: F,
7059
- __read: Re,
7060
- __spread: ze,
7061
- __spreadArrays: Be,
7062
- __spreadArray: Ve,
7063
- __await: I,
7064
- __asyncGenerator: He,
7065
- __asyncDelegator: Ue,
7066
- __asyncValues: We,
7067
- __makeTemplateObject: Ge,
7068
- __importStar: Ke,
7069
- __importDefault: qe,
7070
- __classPrivateFieldGet: Je,
7071
- __classPrivateFieldSet: Ye,
7072
- __classPrivateFieldIn: Xe,
7073
- __addDisposableResource: Ze,
7074
- __disposeResources: Qe,
7075
- __rewriteRelativeImportExtension: $e
6987
+ }, ut = {
6988
+ __extends: Ne,
6989
+ __assign: F,
6990
+ __rest: Pe,
6991
+ __decorate: Fe,
6992
+ __param: Ie,
6993
+ __esDecorate: Le,
6994
+ __runInitializers: Re,
6995
+ __propKey: ze,
6996
+ __setFunctionName: Be,
6997
+ __metadata: Ve,
6998
+ __awaiter: He,
6999
+ __generator: Ue,
7000
+ __createBinding: I,
7001
+ __exportStar: We,
7002
+ __values: N,
7003
+ __read: Ge,
7004
+ __spread: Ke,
7005
+ __spreadArrays: qe,
7006
+ __spreadArray: Je,
7007
+ __await: P,
7008
+ __asyncGenerator: Ye,
7009
+ __asyncDelegator: Xe,
7010
+ __asyncValues: Ze,
7011
+ __makeTemplateObject: Qe,
7012
+ __importStar: $e,
7013
+ __importDefault: et,
7014
+ __classPrivateFieldGet: tt,
7015
+ __classPrivateFieldSet: nt,
7016
+ __classPrivateFieldIn: rt,
7017
+ __addDisposableResource: it,
7018
+ __disposeResources: at,
7019
+ __rewriteRelativeImportExtension: ot
7076
7020
  };
7077
- })), rt = p(((e) => {
7021
+ })), dt = p(((e) => {
7078
7022
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.ErrorKind = void 0;
7079
7023
  var t;
7080
7024
  (function(e) {
7081
7025
  e[e.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = `EXPECT_ARGUMENT_CLOSING_BRACE`, e[e.EMPTY_ARGUMENT = 2] = `EMPTY_ARGUMENT`, e[e.MALFORMED_ARGUMENT = 3] = `MALFORMED_ARGUMENT`, e[e.EXPECT_ARGUMENT_TYPE = 4] = `EXPECT_ARGUMENT_TYPE`, e[e.INVALID_ARGUMENT_TYPE = 5] = `INVALID_ARGUMENT_TYPE`, e[e.EXPECT_ARGUMENT_STYLE = 6] = `EXPECT_ARGUMENT_STYLE`, e[e.INVALID_NUMBER_SKELETON = 7] = `INVALID_NUMBER_SKELETON`, e[e.INVALID_DATE_TIME_SKELETON = 8] = `INVALID_DATE_TIME_SKELETON`, e[e.EXPECT_NUMBER_SKELETON = 9] = `EXPECT_NUMBER_SKELETON`, e[e.EXPECT_DATE_TIME_SKELETON = 10] = `EXPECT_DATE_TIME_SKELETON`, e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = `UNCLOSED_QUOTE_IN_ARGUMENT_STYLE`, e[e.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = `EXPECT_SELECT_ARGUMENT_OPTIONS`, e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = `EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE`, e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = `INVALID_PLURAL_ARGUMENT_OFFSET_VALUE`, e[e.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = `EXPECT_SELECT_ARGUMENT_SELECTOR`, e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = `EXPECT_PLURAL_ARGUMENT_SELECTOR`, e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = `EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT`, e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = `EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT`, e[e.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = `INVALID_PLURAL_ARGUMENT_SELECTOR`, e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = `DUPLICATE_PLURAL_ARGUMENT_SELECTOR`, e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = `DUPLICATE_SELECT_ARGUMENT_SELECTOR`, e[e.MISSING_OTHER_CLAUSE = 22] = `MISSING_OTHER_CLAUSE`, e[e.INVALID_TAG = 23] = `INVALID_TAG`, e[e.INVALID_TAG_NAME = 25] = `INVALID_TAG_NAME`, e[e.UNMATCHED_CLOSING_TAG = 26] = `UNMATCHED_CLOSING_TAG`, e[e.UNCLOSED_TAG = 27] = `UNCLOSED_TAG`;
7082
7026
  })(t || (e.ErrorKind = t = {}));
7083
- })), H = p(((e) => {
7027
+ })), z = p(((e) => {
7084
7028
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.SKELETON_TYPE = e.TYPE = void 0, e.isLiteralElement = r, e.isArgumentElement = i, e.isNumberElement = a, e.isDateElement = o, e.isTimeElement = s, e.isSelectElement = c, e.isPluralElement = l, e.isPoundElement = u, e.isTagElement = d, e.isNumberSkeleton = f, e.isDateTimeSkeleton = p, e.createLiteralElement = m, e.createNumberElement = h;
7085
7029
  var t;
7086
7030
  (function(e) {
@@ -7136,9 +7080,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7136
7080
  style: n
7137
7081
  };
7138
7082
  }
7139
- })), it = p(((e) => {
7083
+ })), ft = p(((e) => {
7140
7084
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.WHITE_SPACE_REGEX = e.SPACE_SEPARATOR_REGEX = void 0, e.SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/, e.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/;
7141
- })), at = p(((e) => {
7085
+ })), pt = p(((e) => {
7142
7086
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseDateTimeSkeleton = n;
7143
7087
  var t = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
7144
7088
  function n(e) {
@@ -7238,11 +7182,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7238
7182
  return ``;
7239
7183
  }), n;
7240
7184
  }
7241
- })), ot = p(((e) => {
7185
+ })), mt = p(((e) => {
7242
7186
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.WHITE_SPACE_REGEX = void 0, e.WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
7243
- })), st = p(((e) => {
7187
+ })), ht = p(((e) => {
7244
7188
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.parseNumberSkeletonFromString = r, e.parseNumberSkeleton = p;
7245
- var t = (V(), g(P)), n = ot();
7189
+ var t = (R(), g(M)), n = mt();
7246
7190
  function r(e) {
7247
7191
  if (e.length === 0) throw Error(`Number skeleton cannot be empty`);
7248
7192
  for (var t = e.split(n.WHITE_SPACE_REGEX).filter(function(e) {
@@ -7420,11 +7364,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
7420
7364
  }
7421
7365
  return n;
7422
7366
  }
7423
- })), ct = p(((e) => {
7367
+ })), gt = p(((e) => {
7424
7368
  Object.defineProperty(e, `__esModule`, { value: !0 });
7425
- var t = (V(), g(P));
7426
- t.__exportStar(at(), e), t.__exportStar(st(), e);
7427
- })), lt = p(((e) => {
7369
+ var t = (R(), g(M));
7370
+ t.__exportStar(pt(), e), t.__exportStar(ht(), e);
7371
+ })), _t = p(((e) => {
7428
7372
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.timeData = void 0, e.timeData = {
7429
7373
  "001": [`H`, `h`],
7430
7374
  419: [
@@ -8581,9 +8525,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8581
8525
  `h`
8582
8526
  ]
8583
8527
  };
8584
- })), ut = p(((e) => {
8528
+ })), vt = p(((e) => {
8585
8529
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.getBestPattern = n;
8586
- var t = lt();
8530
+ var t = _t();
8587
8531
  function n(e, t) {
8588
8532
  for (var n = ``, i = 0; i < e.length; i++) {
8589
8533
  var a = e.charAt(i);
@@ -8608,9 +8552,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8608
8552
  var r = e.language, i;
8609
8553
  return r !== `root` && (i = e.maximize().region), (t.timeData[i || ``] || t.timeData[r || ``] || t.timeData[`${r}-001`] || t.timeData[`001`])[0];
8610
8554
  }
8611
- })), dt = p(((e) => {
8555
+ })), yt = p(((e) => {
8612
8556
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.Parser = void 0;
8613
- var t = (V(), g(P)), n = rt(), r = H(), i = it(), a = ct(), o = ut(), s = RegExp(`^${i.SPACE_SEPARATOR_REGEX.source}*`), c = RegExp(`${i.SPACE_SEPARATOR_REGEX.source}*\$`);
8557
+ 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}*\$`);
8614
8558
  function l(e, t) {
8615
8559
  return {
8616
8560
  start: e,
@@ -8621,21 +8565,21 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8621
8565
  return typeof e == `number` && isFinite(e) && Math.floor(e) === e && Math.abs(e) <= 9007199254740991;
8622
8566
  }, v = !0;
8623
8567
  try {
8624
- v = C(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`).exec(`a`)?.[0] === `a`;
8568
+ v = S(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`).exec(`a`)?.[0] === `a`;
8625
8569
  } catch {
8626
8570
  v = !1;
8627
8571
  }
8628
- var y = u ? function(e, t, n) {
8572
+ var ee = u ? function(e, t, n) {
8629
8573
  return e.startsWith(t, n);
8630
8574
  } : function(e, t, n) {
8631
8575
  return e.slice(n, n + t.length) === t;
8632
- }, b = d ? String.fromCodePoint : function() {
8576
+ }, y = d ? String.fromCodePoint : function() {
8633
8577
  for (var e = [...arguments], t = ``, n = e.length, r = 0, i; n > r;) {
8634
8578
  if (i = e[r++], i > 1114111) throw RangeError(i + ` is not a valid code point`);
8635
8579
  t += i < 65536 ? String.fromCharCode(i) : String.fromCharCode(((i -= 65536) >> 10) + 55296, i % 1024 + 56320);
8636
8580
  }
8637
8581
  return t;
8638
- }, ee = f ? Object.fromEntries : function(e) {
8582
+ }, b = f ? Object.fromEntries : function(e) {
8639
8583
  for (var t = {}, n = 0, r = e; n < r.length; n++) {
8640
8584
  var i = r[n], a = i[0];
8641
8585
  t[a] = i[1];
@@ -8649,31 +8593,31 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8649
8593
  var r = e.charCodeAt(t), i;
8650
8594
  return r < 55296 || r > 56319 || t + 1 === n || (i = e.charCodeAt(t + 1)) < 56320 || i > 57343 ? r : (r - 55296 << 10) + (i - 56320) + 65536;
8651
8595
  }
8652
- }, S = m ? function(e) {
8596
+ }, te = m ? function(e) {
8653
8597
  return e.trimStart();
8654
8598
  } : function(e) {
8655
8599
  return e.replace(s, ``);
8656
- }, te = h ? function(e) {
8600
+ }, ne = h ? function(e) {
8657
8601
  return e.trimEnd();
8658
8602
  } : function(e) {
8659
8603
  return e.replace(c, ``);
8660
8604
  };
8661
- function C(e, t) {
8605
+ function S(e, t) {
8662
8606
  return new RegExp(e, t);
8663
8607
  }
8664
- var w;
8608
+ var C;
8665
8609
  if (v) {
8666
- var T = C(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`);
8667
- w = function(e, t) {
8668
- return T.lastIndex = t, T.exec(e)[1] ?? ``;
8610
+ var w = S(`([^\\p{White_Space}\\p{Pattern_Syntax}]*)`, `yu`);
8611
+ C = function(e, t) {
8612
+ return w.lastIndex = t, w.exec(e)[1] ?? ``;
8669
8613
  };
8670
- } else w = function(e, t) {
8614
+ } else C = function(e, t) {
8671
8615
  for (var n = [];;) {
8672
8616
  var r = x(e, t);
8673
- if (r === void 0 || k(r) || A(r)) break;
8617
+ if (r === void 0 || ie(r) || D(r)) break;
8674
8618
  n.push(r), t += r >= 65536 ? 2 : 1;
8675
8619
  }
8676
- return b.apply(void 0, n);
8620
+ return y.apply(void 0, n);
8677
8621
  };
8678
8622
  e.Parser = function() {
8679
8623
  function e(e, t) {
@@ -8703,7 +8647,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8703
8647
  } else if (o === 60 && !this.ignoreTag && this.peek() === 47) {
8704
8648
  if (i) break;
8705
8649
  return this.error(n.ErrorKind.UNMATCHED_CLOSING_TAG, l(this.clonePosition(), this.clonePosition()));
8706
- } else if (o === 60 && !this.ignoreTag && E(this.peek() || 0)) {
8650
+ } else if (o === 60 && !this.ignoreTag && T(this.peek() || 0)) {
8707
8651
  var s = this.parseTag(e, t);
8708
8652
  if (s.err) return s;
8709
8653
  a.push(s.val);
@@ -8734,7 +8678,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8734
8678
  if (o.err) return o;
8735
8679
  var s = o.val, c = this.clonePosition();
8736
8680
  if (this.bumpIf(`</`)) {
8737
- if (this.isEOF() || !E(this.char())) return this.error(n.ErrorKind.INVALID_TAG, l(c, this.clonePosition()));
8681
+ if (this.isEOF() || !T(this.char())) return this.error(n.ErrorKind.INVALID_TAG, l(c, this.clonePosition()));
8738
8682
  var u = this.clonePosition();
8739
8683
  return a === this.parseTagName() ? (this.bumpSpace(), this.bumpIf(`>`) ? {
8740
8684
  val: {
@@ -8749,7 +8693,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8749
8693
  } else return this.error(n.ErrorKind.INVALID_TAG, l(i, this.clonePosition()));
8750
8694
  }, e.prototype.parseTagName = function() {
8751
8695
  var e = this.offset();
8752
- for (this.bump(); !this.isEOF() && O(this.char());) this.bump();
8696
+ for (this.bump(); !this.isEOF() && E(this.char());) this.bump();
8753
8697
  return this.message.slice(e, this.offset());
8754
8698
  }, e.prototype.parseLiteral = function(e, t) {
8755
8699
  for (var n = this.clonePosition(), i = ``;;) {
@@ -8780,7 +8724,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8780
8724
  err: null
8781
8725
  };
8782
8726
  }, e.prototype.tryParseLeftAngleBracket = function() {
8783
- return !this.isEOF() && this.char() === 60 && (this.ignoreTag || !D(this.peek() || 0)) ? (this.bump(), `<`) : null;
8727
+ return !this.isEOF() && this.char() === 60 && (this.ignoreTag || !re(this.peek() || 0)) ? (this.bump(), `<`) : null;
8784
8728
  }, e.prototype.tryParseQuote = function(e) {
8785
8729
  if (this.isEOF() || this.char() !== 39) return null;
8786
8730
  switch (this.peek()) {
@@ -8806,11 +8750,11 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8806
8750
  else t.push(n);
8807
8751
  this.bump();
8808
8752
  }
8809
- return b.apply(void 0, t);
8753
+ return y.apply(void 0, t);
8810
8754
  }, e.prototype.tryParseUnquoted = function(e, t) {
8811
8755
  if (this.isEOF()) return null;
8812
8756
  var n = this.char();
8813
- return n === 60 || n === 123 || n === 35 && (t === `plural` || t === `selectordinal`) || n === 125 && e > 0 ? null : (this.bump(), b(n));
8757
+ return n === 60 || n === 123 || n === 35 && (t === `plural` || t === `selectordinal`) || n === 125 && e > 0 ? null : (this.bump(), y(n));
8814
8758
  }, e.prototype.parseArgument = function(e, t) {
8815
8759
  var i = this.clonePosition();
8816
8760
  if (this.bump(), this.bumpSpace(), this.isEOF()) return this.error(n.ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, l(i, this.clonePosition()));
@@ -8831,7 +8775,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8831
8775
  default: return this.error(n.ErrorKind.MALFORMED_ARGUMENT, l(i, this.clonePosition()));
8832
8776
  }
8833
8777
  }, e.prototype.parseIdentifierIfPossible = function() {
8834
- var e = this.clonePosition(), t = this.offset(), n = w(this.message, t), r = t + n.length;
8778
+ var e = this.clonePosition(), t = this.offset(), n = C(this.message, t), r = t + n.length;
8835
8779
  return this.bumpTo(r), {
8836
8780
  value: n,
8837
8781
  location: l(e, this.clonePosition())
@@ -8849,7 +8793,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8849
8793
  this.bumpSpace();
8850
8794
  var m = this.clonePosition(), h = this.parseSimpleArgStyleIfPossible();
8851
8795
  if (h.err) return h;
8852
- var g = te(h.val);
8796
+ var g = ne(h.val);
8853
8797
  if (g.length === 0) return this.error(n.ErrorKind.EXPECT_ARGUMENT_STYLE, l(this.clonePosition(), this.clonePosition()));
8854
8798
  p = {
8855
8799
  style: g,
@@ -8859,10 +8803,10 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8859
8803
  var _ = this.tryParseArgumentClose(c);
8860
8804
  if (_.err) return _;
8861
8805
  var v = l(c, this.clonePosition());
8862
- if (p && y(p?.style, `::`, 0)) {
8863
- var b = S(p.style.slice(2));
8806
+ if (p && ee(p?.style, `::`, 0)) {
8807
+ var y = te(p.style.slice(2));
8864
8808
  if (d === `number`) {
8865
- var h = this.parseNumberSkeletonFromString(b, p.styleLocation);
8809
+ var h = this.parseNumberSkeletonFromString(y, p.styleLocation);
8866
8810
  return h.err ? h : {
8867
8811
  val: {
8868
8812
  type: r.TYPE.number,
@@ -8873,9 +8817,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8873
8817
  err: null
8874
8818
  };
8875
8819
  } else {
8876
- if (b.length === 0) return this.error(n.ErrorKind.EXPECT_DATE_TIME_SKELETON, v);
8877
- var x = b;
8878
- this.locale && (x = (0, o.getBestPattern)(b, this.locale));
8820
+ if (y.length === 0) return this.error(n.ErrorKind.EXPECT_DATE_TIME_SKELETON, v);
8821
+ var x = y;
8822
+ this.locale && (x = (0, o.getBestPattern)(y, this.locale));
8879
8823
  var g = {
8880
8824
  type: r.SKELETON_TYPE.dateTime,
8881
8825
  pattern: x,
@@ -8905,38 +8849,38 @@ var L, R, z, et, B, tt, nt, V = f((() => {
8905
8849
  case `plural`:
8906
8850
  case `selectordinal`:
8907
8851
  case `select`:
8908
- var C = this.clonePosition();
8909
- if (this.bumpSpace(), !this.bumpIf(`,`)) return this.error(n.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, l(C, t.__assign({}, C)));
8852
+ var S = this.clonePosition();
8853
+ if (this.bumpSpace(), !this.bumpIf(`,`)) return this.error(n.ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, l(S, t.__assign({}, S)));
8910
8854
  this.bumpSpace();
8911
- var w = this.parseIdentifierIfPossible(), T = 0;
8912
- if (d !== `select` && w.value === `offset`) {
8855
+ var C = this.parseIdentifierIfPossible(), w = 0;
8856
+ if (d !== `select` && C.value === `offset`) {
8913
8857
  if (!this.bumpIf(`:`)) return this.error(n.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, l(this.clonePosition(), this.clonePosition()));
8914
8858
  this.bumpSpace();
8915
8859
  var h = this.tryParseDecimalInteger(n.ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, n.ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
8916
8860
  if (h.err) return h;
8917
- this.bumpSpace(), w = this.parseIdentifierIfPossible(), T = h.val;
8861
+ this.bumpSpace(), C = this.parseIdentifierIfPossible(), w = h.val;
8918
8862
  }
8919
- var E = this.tryParsePluralOrSelectOptions(e, d, i, w);
8920
- if (E.err) return E;
8863
+ var T = this.tryParsePluralOrSelectOptions(e, d, i, C);
8864
+ if (T.err) return T;
8921
8865
  var _ = this.tryParseArgumentClose(c);
8922
8866
  if (_.err) return _;
8923
- var D = l(c, this.clonePosition());
8867
+ var re = l(c, this.clonePosition());
8924
8868
  return d === `select` ? {
8925
8869
  val: {
8926
8870
  type: r.TYPE.select,
8927
8871
  value: s,
8928
- options: ee(E.val),
8929
- location: D
8872
+ options: b(T.val),
8873
+ location: re
8930
8874
  },
8931
8875
  err: null
8932
8876
  } : {
8933
8877
  val: {
8934
8878
  type: r.TYPE.plural,
8935
8879
  value: s,
8936
- options: ee(E.val),
8937
- offset: T,
8880
+ options: b(T.val),
8881
+ offset: w,
8938
8882
  pluralType: d === `plural` ? `cardinal` : `ordinal`,
8939
- location: D
8883
+ location: re
8940
8884
  },
8941
8885
  err: null
8942
8886
  };
@@ -9060,7 +9004,7 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9060
9004
  e === 10 ? (this.position.line += 1, this.position.column = 1, this.position.offset += 1) : (this.position.column += 1, this.position.offset += e < 65536 ? 1 : 2);
9061
9005
  }
9062
9006
  }, e.prototype.bumpIf = function(e) {
9063
- if (y(this.message, e, this.offset())) {
9007
+ if (ee(this.message, e, this.offset())) {
9064
9008
  for (var t = 0; t < e.length; t++) this.bump();
9065
9009
  return !0;
9066
9010
  }
@@ -9077,31 +9021,31 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9077
9021
  if (this.bump(), this.isEOF()) break;
9078
9022
  }
9079
9023
  }, e.prototype.bumpSpace = function() {
9080
- for (; !this.isEOF() && k(this.char());) this.bump();
9024
+ for (; !this.isEOF() && ie(this.char());) this.bump();
9081
9025
  }, e.prototype.peek = function() {
9082
9026
  if (this.isEOF()) return null;
9083
9027
  var e = this.char(), t = this.offset();
9084
9028
  return this.message.charCodeAt(t + (e >= 65536 ? 2 : 1)) ?? null;
9085
9029
  }, e;
9086
9030
  }();
9087
- function E(e) {
9031
+ function T(e) {
9088
9032
  return e >= 97 && e <= 122 || e >= 65 && e <= 90;
9089
9033
  }
9090
- function D(e) {
9091
- return E(e) || e === 47;
9034
+ function re(e) {
9035
+ return T(e) || e === 47;
9092
9036
  }
9093
- function O(e) {
9037
+ function E(e) {
9094
9038
  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;
9095
9039
  }
9096
- function k(e) {
9040
+ function ie(e) {
9097
9041
  return e >= 9 && e <= 13 || e === 32 || e === 133 || e >= 8206 && e <= 8207 || e === 8232 || e === 8233;
9098
9042
  }
9099
- function A(e) {
9043
+ function D(e) {
9100
9044
  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;
9101
9045
  }
9102
- })), ft = p(((e) => {
9046
+ })), bt = p(((e) => {
9103
9047
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.hoistSelectors = s, e.isStructurallySame = l;
9104
- var t = (V(), g(P)), n = H();
9048
+ var t = (R(), g(M)), n = z();
9105
9049
  function r(e) {
9106
9050
  return Array.isArray(e) ? t.__spreadArray([], e.map(r), !0) : typeof e == `object` && e ? Object.keys(e).reduce(function(t, n) {
9107
9051
  return t[n] = r(e[n]), t;
@@ -9158,9 +9102,9 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9158
9102
  error: Error(`Different number of variables: [${Array.from(r.keys()).join(`, `)}] vs [${Array.from(i.keys()).join(`, `)}]`)
9159
9103
  };
9160
9104
  }
9161
- })), pt = p(((e) => {
9105
+ })), xt = p(((e) => {
9162
9106
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.isStructurallySame = e._Parser = void 0, e.parse = o;
9163
- var t = (V(), g(P)), n = rt(), r = dt(), i = H();
9107
+ var t = (R(), g(M)), n = dt(), r = yt(), i = z();
9164
9108
  function a(e) {
9165
9109
  e.forEach(function(e) {
9166
9110
  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);
@@ -9179,17 +9123,17 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9179
9123
  }
9180
9124
  return i?.captureLocation || a(o.val), o.val;
9181
9125
  }
9182
- t.__exportStar(H(), e), e._Parser = r.Parser;
9183
- var s = ft();
9126
+ t.__exportStar(z(), e), e._Parser = r.Parser;
9127
+ var s = bt();
9184
9128
  Object.defineProperty(e, `isStructurallySame`, {
9185
9129
  enumerable: !0,
9186
9130
  get: function() {
9187
9131
  return s.isStructurallySame;
9188
9132
  }
9189
9133
  });
9190
- })), mt = p(((e) => {
9134
+ })), St = p(((e) => {
9191
9135
  Object.defineProperty(e, `__esModule`, { value: !0 }), e.printAST = r;
9192
- var t = (V(), g(P)), n = H();
9136
+ var t = (R(), g(M)), n = z();
9193
9137
  function r(e) {
9194
9138
  return i(e, !1);
9195
9139
  }
@@ -9252,10 +9196,10 @@ var L, R, z, et, B, tt, nt, V = f((() => {
9252
9196
  ].join(`,`)}}`;
9253
9197
  }
9254
9198
  }));
9255
- pt();
9256
- H();
9257
- mt();
9258
- const gt = [
9199
+ xt();
9200
+ z();
9201
+ St();
9202
+ const wt = [
9259
9203
  `singular`,
9260
9204
  `plural`,
9261
9205
  `dual`,
@@ -9266,11 +9210,11 @@ const gt = [
9266
9210
  `many`,
9267
9211
  `other`
9268
9212
  ];
9269
- function _t(e) {
9270
- return gt.includes(e);
9213
+ function Tt(e) {
9214
+ return wt.includes(e);
9271
9215
  }
9272
- function vt(e, t = gt, n = [`en`]) {
9273
- let r = Te(n).select(e), i = Math.abs(e);
9216
+ function Et(e, t = wt, n = [`en`]) {
9217
+ let r = Me(n).select(e), i = Math.abs(e);
9274
9218
  if (i === 0 && t.includes(`zero`)) return `zero`;
9275
9219
  if (i === 1) {
9276
9220
  if (t.includes(`singular`)) return `singular`;
@@ -9283,20 +9227,20 @@ function vt(e, t = gt, n = [`en`]) {
9283
9227
  }
9284
9228
  return r === `two` && t.includes(`dual`) ? `dual` : t.includes(r) ? r : r === `two` && t.includes(`dual`) ? `dual` : r === `two` && t.includes(`plural`) ? `plural` : r === `two` && t.includes(`other`) ? `other` : r === `few` && t.includes(`plural`) ? `plural` : r === `few` && t.includes(`other`) ? `other` : r === `many` && t.includes(`plural`) ? `plural` : r === `many` && t.includes(`other`) ? `other` : r === `other` && t.includes(`plural`) ? `plural` : ``;
9285
9229
  }
9286
- const yt = {
9230
+ const Dt = {
9287
9231
  variable: `v`,
9288
9232
  number: `n`,
9289
9233
  datetime: `d`,
9290
9234
  currency: `c`,
9291
9235
  "relative-time": `rt`
9292
9236
  };
9293
- function bt(e) {
9294
- return yt[e];
9237
+ function Ot(e) {
9238
+ return Dt[e];
9295
9239
  }
9296
- const K = `_gt_`;
9297
- RegExp(`^${K}\\d+$`);
9298
- RegExp(`^${K}$`);
9299
- function Nt(e, n = 0) {
9240
+ const U = `_gt_`;
9241
+ RegExp(`^${U}\\d+$`);
9242
+ RegExp(`^${U}$`);
9243
+ function Vt(e, n = 0) {
9300
9244
  let r = n, a = (e) => {
9301
9245
  let { type: t, props: n } = e;
9302
9246
  r += 1;
@@ -9310,11 +9254,11 @@ function Nt(e, n = 0) {
9310
9254
  if (a) {
9311
9255
  let e = a.split(`-`);
9312
9256
  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`) {
9313
- let e = Object.entries(n).reduce((e, [t, n]) => (_t(t) && (e[t] = Nt(n, r)), e), {});
9257
+ let e = Object.entries(n).reduce((e, [t, n]) => (Tt(t) && (e[t] = Vt(n, r)), e), {});
9314
9258
  Object.keys(e).length && (i.branches = e);
9315
9259
  }
9316
9260
  if (e[0] === `branch`) {
9317
- 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] = Nt(n, r), e), {});
9261
+ 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), {});
9318
9262
  Object.keys(s).length && (i.branches = s);
9319
9263
  }
9320
9264
  i.transformation = e[0];
@@ -9326,50 +9270,97 @@ function Nt(e, n = 0) {
9326
9270
  ...n,
9327
9271
  "data-_gt": r
9328
9272
  };
9329
- return n.children && !r.variableType && (i.children = c(n.children)), e.type === react$1.default.Fragment && (i[`data-_gt`].transformation = `fragment`), react$1.default.cloneElement(e, i);
9273
+ return n.children && !r.variableType && (i.children = c(n.children)), e.type === react.default.Fragment && (i[`data-_gt`].transformation = `fragment`), react.default.cloneElement(e, i);
9330
9274
  }
9331
9275
  function s(e) {
9332
- return (0, react$1.isValidElement)(e) ? o(e) : e;
9276
+ return (0, react.isValidElement)(e) ? o(e) : e;
9333
9277
  }
9334
9278
  function c(e) {
9335
- return Array.isArray(e) ? react$1.default.Children.map(e, s) : s(e);
9279
+ return Array.isArray(e) ? react.default.Children.map(e, s) : s(e);
9336
9280
  }
9337
9281
  return c(e);
9338
9282
  }
9339
- const q = `@generaltranslation/react-core`;
9340
- `${q}`, `${q}`, `${q}`, `${q}`, `${q}`, `${q}`;
9341
- `${q}`, `${q}`, `${q}`, `${q}`;
9342
- const Lt = `${q} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9343
- function Rt(e) {
9344
- return Bt(e, 0);
9283
+ const Ht = `@generaltranslation/react-core`;
9284
+ function W(e) {
9285
+ return S({
9286
+ source: Ht,
9287
+ ...e
9288
+ });
9289
+ }
9290
+ W({
9291
+ severity: `Error`,
9292
+ whatHappened: `Runtime translation needs a project ID`,
9293
+ fix: `Add projectId to your <GTProvider> configuration or set GT_PROJECT_ID in your environment`,
9294
+ docsUrl: `https://generaltranslation.com/dashboard`
9295
+ }), W({
9296
+ severity: `Error`,
9297
+ whatHappened: `Production environments cannot use a development API key`,
9298
+ fix: `Replace it with a production API key before deploying`
9299
+ }), W({
9300
+ severity: `Error`,
9301
+ whatHappened: `The API key is available to client-side production code`,
9302
+ fix: `Move translation credentials to a server-only environment before deploying`
9303
+ }), W({
9304
+ severity: `Error`,
9305
+ whatHappened: `Runtime translation is not configured`,
9306
+ fix: `Add projectId and devApiKey to your environment, or pass them to <GTProvider> directly`
9307
+ }), W({
9308
+ severity: `Error`,
9309
+ whatHappened: `Runtime translations could not be loaded`,
9310
+ wayOut: `Source content will render as a fallback`,
9311
+ fix: `Check your runtime translation configuration and try again`
9312
+ }), W({
9313
+ severity: `Error`,
9314
+ whatHappened: `Runtime translation could not be completed`
9315
+ });
9316
+ W({
9317
+ severity: `Warning`,
9318
+ whatHappened: `Runtime translation needs a project ID`,
9319
+ fix: `Add projectId to <GTProvider> or set GT_PROJECT_ID in your environment`,
9320
+ docsUrl: `https://generaltranslation.com/dashboard`
9321
+ }), W({
9322
+ severity: `Warning`,
9323
+ whatHappened: `Runtime translation needs a development API key`,
9324
+ fix: `Find your development API key at generaltranslation.com/dashboard, or set runtimeUrl to an empty string to disable runtime translation`
9325
+ }), W({
9326
+ severity: `Warning`,
9327
+ whatHappened: `Runtime translation timed out`
9328
+ }), W({
9329
+ severity: `Warning`,
9330
+ whatHappened: `No dictionary was found`,
9331
+ fix: `Pass a dictionary to <GTProvider> or configure a dictionary loader before rendering translations`
9332
+ });
9333
+ const Kt = `${Ht} Warning: A <_T> component was found injected outside of a <Derive> boundary. This may affect translation resolution for this component.`;
9334
+ function qt(e) {
9335
+ return K(e, 0);
9345
9336
  }
9346
- function zt(e, t) {
9347
- let { type: n, props: i } = e, a = Vt(n);
9337
+ function Jt(e, t) {
9338
+ let { type: n, props: i } = e, a = Yt(n);
9348
9339
  if (typeof i != `object` || !i) return e;
9349
9340
  if (a) {
9350
9341
  let { componentType: n, injectionType: o } = a;
9351
9342
  if (n === `variable`) return e;
9352
- if (n === `branch`) return (0, react$1.cloneElement)(e, { ...Object.entries(i).reduce((e, [n, r]) => (n !== `branch` && !n.startsWith(`data-`) ? e[n] = J(r, t) : e[n] = r, e), {}) });
9353
- if (n === `plural`) return (0, react$1.cloneElement)(e, { ...Object.entries(i).reduce((e, [n, r]) => (_t(n) || n === `children` ? e[n] = J(r, t) : e[n] = r, e), {}) });
9354
- if (n === `derive`) return (0, react$1.cloneElement)(e, {
9343
+ if (n === `branch`) return (0, react.cloneElement)(e, { ...Object.entries(i).reduce((e, [n, r]) => (n !== `branch` && !n.startsWith(`data-`) ? e[n] = G(r, t) : e[n] = r, e), {}) });
9344
+ if (n === `plural`) return (0, react.cloneElement)(e, { ...Object.entries(i).reduce((e, [n, r]) => (Tt(n) || n === `children` ? e[n] = G(r, t) : e[n] = r, e), {}) });
9345
+ if (n === `derive`) return (0, react.cloneElement)(e, {
9355
9346
  ...i,
9356
- ...`children` in i && { children: Bt(i.children, t + 1) }
9347
+ ...`children` in i && { children: K(i.children, t + 1) }
9357
9348
  });
9358
- if (n === `translate` && o === `automatic` && t > 0) return `children` in i ? Bt(i.children, t) : void 0;
9359
- n === `translate` && o === `automatic` && console.warn(Lt);
9349
+ if (n === `translate` && o === `automatic` && t > 0) return `children` in i ? K(i.children, t) : void 0;
9350
+ n === `translate` && o === `automatic` && console.warn(Kt);
9360
9351
  }
9361
- return (0, react$1.cloneElement)(e, {
9352
+ return (0, react.cloneElement)(e, {
9362
9353
  ...i,
9363
- ...`children` in i && { children: Bt(i.children, t) }
9354
+ ...`children` in i && { children: K(i.children, t) }
9364
9355
  });
9365
9356
  }
9366
- function J(e, t) {
9367
- return (0, react$1.isValidElement)(e) ? zt(e, t) : e;
9357
+ function G(e, t) {
9358
+ return (0, react.isValidElement)(e) ? Jt(e, t) : e;
9368
9359
  }
9369
- function Bt(e, t) {
9370
- return Array.isArray(e) ? react$1.Children.map(e, (e) => J(e, t)) : J(e, t);
9360
+ function K(e, t) {
9361
+ return Array.isArray(e) ? react.Children.map(e, (e) => G(e, t)) : G(e, t);
9371
9362
  }
9372
- function Vt(e) {
9363
+ function Yt(e) {
9373
9364
  let t = typeof e == `function` && `_gtt` in e ? e._gtt : void 0;
9374
9365
  if (t == null || typeof t != `string`) return;
9375
9366
  let n = t.split(`-`);
@@ -9378,27 +9369,27 @@ function Vt(e) {
9378
9369
  injectionType: n[1] === `automatic` || n[2] === `automatic` ? `automatic` : `manual`
9379
9370
  };
9380
9371
  }
9381
- const Ht = {
9372
+ const Xt = {
9382
9373
  variable: `value`,
9383
9374
  number: `n`,
9384
9375
  datetime: `date`,
9385
9376
  currency: `cost`,
9386
9377
  "relative-time": `time`
9387
9378
  };
9388
- function Ut(e = {}, t) {
9389
- return typeof e.name == `string` ? e.name : `_gt_${Ht[t] || `value`}_${e[`data-_gt`]?.id}`;
9379
+ function Zt(e = {}, t) {
9380
+ return typeof e.name == `string` ? e.name : `_gt_${Xt[t] || `value`}_${e[`data-_gt`]?.id}`;
9390
9381
  }
9391
- function Wt(e) {
9392
- return react$1.default.isValidElement(e);
9382
+ function Qt(e) {
9383
+ return react.default.isValidElement(e);
9393
9384
  }
9394
- const Gt = {
9385
+ const $t = {
9395
9386
  pl: `placeholder`,
9396
9387
  ti: `title`,
9397
9388
  alt: `alt`,
9398
9389
  arl: `aria-label`,
9399
9390
  arb: `aria-labelledby`,
9400
9391
  ard: `aria-describedby`
9401
- }, Kt = (e) => {
9392
+ }, en = (e) => {
9402
9393
  if (!e) return ``;
9403
9394
  let { type: t, props: n } = e;
9404
9395
  if (t && typeof t == `function`) {
@@ -9406,15 +9397,15 @@ const Gt = {
9406
9397
  if (`name` in t && typeof t.name == `string` && t.name) return t.name;
9407
9398
  }
9408
9399
  return t && typeof t == `string` ? t : n.href ? `a` : n[`data-_gt`]?.id ? `C${n[`data-_gt`].id}` : `function`;
9409
- }, qt = (e, t, n) => {
9410
- let r = Object.entries(Gt).reduce((e, [n, r]) => {
9400
+ }, tn = (e, t, n) => {
9401
+ let r = Object.entries($t).reduce((e, [n, r]) => {
9411
9402
  let i = t[r];
9412
9403
  return typeof i == `string` && (e[n] = i), e;
9413
9404
  }, {});
9414
9405
  if (e === `plural` && n) {
9415
9406
  let e = {};
9416
9407
  Object.entries(n).forEach(([t, n]) => {
9417
- e[t] = Y(n);
9408
+ e[t] = q(n);
9418
9409
  }), r = {
9419
9410
  ...r,
9420
9411
  b: e,
@@ -9424,7 +9415,7 @@ const Gt = {
9424
9415
  if (e === `branch` && n) {
9425
9416
  let e = {};
9426
9417
  Object.entries(n).forEach(([t, n]) => {
9427
- e[t] = Y(n);
9418
+ e[t] = q(n);
9428
9419
  }), r = {
9429
9420
  ...r,
9430
9421
  b: e,
@@ -9432,27 +9423,27 @@ const Gt = {
9432
9423
  };
9433
9424
  }
9434
9425
  return Object.keys(r).length ? r : void 0;
9435
- }, Jt = (e) => {
9436
- let { props: t } = e, n = { t: Kt(e) };
9426
+ }, nn = (e) => {
9427
+ let { props: t } = e, n = { t: en(e) };
9437
9428
  if (t[`data-_gt`]) {
9438
9429
  let e = t[`data-_gt`], r = e.transformation;
9439
9430
  if (r === `variable`) {
9440
- let n = e.variableType || `variable`, r = Ut(t, n), i = bt(n);
9431
+ let n = e.variableType || `variable`, r = Zt(t, n), i = Ot(n);
9441
9432
  return {
9442
9433
  i: e.id,
9443
9434
  k: r,
9444
9435
  v: i
9445
9436
  };
9446
9437
  }
9447
- n.i = e.id, n.d = qt(r, t, e.branches);
9448
- let i = Object.entries(Gt).reduce((e, [n, r]) => {
9438
+ n.i = e.id, n.d = tn(r, t, e.branches);
9439
+ let i = Object.entries($t).reduce((e, [n, r]) => {
9449
9440
  let i = t[r];
9450
9441
  return typeof i == `string` && (e[n] = i), e;
9451
9442
  }, {});
9452
9443
  if (r === `plural` && e.branches) {
9453
9444
  let t = {};
9454
9445
  Object.entries(e.branches).forEach(([e, n]) => {
9455
- t[e] = Y(n);
9446
+ t[e] = q(n);
9456
9447
  }), i = {
9457
9448
  ...i,
9458
9449
  b: t,
@@ -9462,7 +9453,7 @@ const Gt = {
9462
9453
  if (r === `branch` && e.branches) {
9463
9454
  let t = {};
9464
9455
  Object.entries(e.branches).forEach(([e, n]) => {
9465
- t[e] = Y(n);
9456
+ t[e] = q(n);
9466
9457
  }), i = {
9467
9458
  ...i,
9468
9459
  b: t,
@@ -9471,23 +9462,23 @@ const Gt = {
9471
9462
  }
9472
9463
  n.d = Object.keys(i).length ? i : void 0;
9473
9464
  }
9474
- return t.children && (n.c = Y(t.children)), n;
9475
- }, Yt = (e) => Wt(e) ? Jt(e) : typeof e == `number` ? e.toString() : e;
9476
- function Y(e) {
9477
- return Array.isArray(e) ? e.map(Yt) : Yt(e);
9465
+ return t.children && (n.c = q(t.children)), n;
9466
+ }, rn = (e) => Qt(e) ? nn(e) : typeof e == `number` ? e.toString() : e;
9467
+ function q(e) {
9468
+ return Array.isArray(e) ? e.map(rn) : rn(e);
9478
9469
  }
9479
- function Xt(e, t, n) {
9470
+ function J(e, t, n) {
9480
9471
  let r = ``, i = null;
9481
- return typeof e == `number` && !i && n && (r = vt(e, Object.keys(n).filter(_t), t)), r && !i && (i = n[r]), i;
9472
+ return typeof e == `number` && !i && n && (r = Et(e, Object.keys(n).filter(Tt), t)), r && !i && (i = n[r]), i;
9482
9473
  }
9483
- function $t(e) {
9474
+ function on(e) {
9484
9475
  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`;
9485
9476
  }
9486
- function en(e) {
9477
+ function sn(e) {
9487
9478
  let t = e[`data-_gt`]?.variableType || `variable`;
9488
9479
  return {
9489
- variableName: Ut(e, t),
9490
- variableType: bt(t),
9480
+ variableName: Zt(e, t),
9481
+ variableType: Ot(t),
9491
9482
  injectionType: e[`data-_gt`]?.injectionType || `manual`,
9492
9483
  variableValue: (() => {
9493
9484
  if (e.value !== void 0) return e.value;
@@ -9506,14 +9497,14 @@ function en(e) {
9506
9497
  })()
9507
9498
  };
9508
9499
  }
9509
- function nn(e) {
9500
+ function ln(e) {
9510
9501
  return e && e.props && e.props[`data-_gt`] ? e.props[`data-_gt`] : null;
9511
9502
  }
9512
9503
  function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9513
9504
  let i = (e) => {
9514
- let i = nn(e);
9515
- if ($t(e.props)) {
9516
- let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = en(e.props);
9505
+ let i = ln(e);
9506
+ if (on(e.props)) {
9507
+ let { variableType: t, variableValue: i, variableOptions: a, injectionType: o } = sn(e.props);
9517
9508
  return r({
9518
9509
  variableType: t,
9519
9510
  variableValue: i,
@@ -9525,30 +9516,30 @@ function Z({ children: e, defaultLocale: n = `en`, renderVariable: r }) {
9525
9516
  if (i?.transformation === `plural`) {
9526
9517
  let t = i.branches || {};
9527
9518
  if (typeof e.props.n != `number`) return e.props.children == null ? null : o(e.props.children);
9528
- let r = Xt(e.props.n, [n], t);
9519
+ let r = J(e.props.n, [n], t);
9529
9520
  return o(r === null ? e.props.children : r);
9530
9521
  }
9531
9522
  if (i?.transformation === `branch`) {
9532
9523
  let { children: t, branch: n } = e.props, r = i.branches || {}, a = n == null || n === `` ? void 0 : n.toString();
9533
9524
  return o(a && r[a] !== void 0 ? r[a] : t);
9534
9525
  }
9535
- return i?.transformation === `fragment` ? react$1.default.createElement(react$1.default.Fragment, {
9526
+ return i?.transformation === `fragment` ? react.default.createElement(react.default.Fragment, {
9536
9527
  key: e.props.key,
9537
9528
  children: o(e.props.children)
9538
- }) : e.props.children ? react$1.default.cloneElement(e, {
9529
+ }) : e.props.children ? react.default.cloneElement(e, {
9539
9530
  ...e.props,
9540
9531
  "data-_gt": void 0,
9541
9532
  children: o(e.props.children)
9542
- }) : react$1.default.cloneElement(e, {
9533
+ }) : react.default.cloneElement(e, {
9543
9534
  ...e.props,
9544
9535
  "data-_gt": void 0
9545
9536
  });
9546
- }, a = (e) => react$1.default.isValidElement(e) ? i(e) : e, o = (e) => Array.isArray(e) ? react$1.default.Children.map(e, a) : a(e);
9537
+ }, a = (e) => react.default.isValidElement(e) ? i(e) : e, o = (e) => Array.isArray(e) ? react.default.Children.map(e, a) : a(e);
9547
9538
  return o(e);
9548
9539
  }
9549
- function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9540
+ function un({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVariable: i }) {
9550
9541
  let { props: a } = e, o = a[`data-_gt`], s = o?.transformation, c = n.d, l = {};
9551
- if (c && Object.entries(Gt).forEach(([e, t]) => {
9542
+ if (c && Object.entries($t).forEach(([e, t]) => {
9552
9543
  c[e] && (l[t] = c[e]);
9553
9544
  }), s === `plural`) {
9554
9545
  let t = e.props.n;
@@ -9557,7 +9548,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9557
9548
  defaultLocale: r[0],
9558
9549
  renderVariable: i
9559
9550
  });
9560
- let a = Xt(t, r, o.branches || {}), s = a === null ? e.props.children : a, c = Xt(t, r, n.d?.b || {});
9551
+ let a = J(t, r, o.branches || {}), s = a === null ? e.props.children : a, c = J(t, r, n.d?.b || {});
9561
9552
  return Q({
9562
9553
  source: s,
9563
9554
  target: c === null ? n.c : c,
@@ -9574,7 +9565,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9574
9565
  renderVariable: i
9575
9566
  });
9576
9567
  }
9577
- return s === `fragment` && n.c ? react$1.default.createElement(react$1.default.Fragment, {
9568
+ return s === `fragment` && n.c ? react.default.createElement(react.default.Fragment, {
9578
9569
  key: e.props.key,
9579
9570
  children: Q({
9580
9571
  source: a.children,
@@ -9582,7 +9573,7 @@ function rn({ sourceElement: e, targetElement: n, locales: r = [`en`], renderVar
9582
9573
  locales: r,
9583
9574
  renderVariable: i
9584
9575
  })
9585
- }) : a?.children && n?.c ? react$1.default.cloneElement(e, {
9576
+ }) : a?.children && n?.c ? react.default.cloneElement(e, {
9586
9577
  ...a,
9587
9578
  ...l,
9588
9579
  "data-_gt": void 0,
@@ -9607,18 +9598,18 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9607
9598
  if (typeof n == `string`) return n;
9608
9599
  if (Array.isArray(n) && !Array.isArray(e) && e && (e = [e]), Array.isArray(e) && Array.isArray(n)) {
9609
9600
  let a = {}, o = {}, c = {}, l = e.filter((e) => {
9610
- if (react$1.default.isValidElement(e)) if ($t(e.props)) {
9611
- let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = en(e.props);
9601
+ if (react.default.isValidElement(e)) if (on(e.props)) {
9602
+ let { variableName: t, variableValue: n, variableOptions: r, injectionType: i } = sn(e.props);
9612
9603
  a[t] = n, o[t] = r, c[t] = i;
9613
9604
  } else return !0;
9614
9605
  return !1;
9615
9606
  }), u = (e) => l.find((t) => {
9616
- let n = nn(t);
9607
+ let n = ln(t);
9617
9608
  return n?.id === void 0 ? !1 : n.id === e.i;
9618
9609
  }) || l.shift();
9619
9610
  return n.map((e, n) => {
9620
- if (typeof e == `string`) return (0, react_jsx_runtime.jsx)(react$1.default.Fragment, { children: e }, `string_${n}`);
9621
- if (C(e)) return (0, react_jsx_runtime.jsx)(react$1.default.Fragment, { children: i({
9611
+ if (typeof e == `string`) return (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: e }, `string_${n}`);
9612
+ if (E(e)) return (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: i({
9622
9613
  variableType: e.v || `v`,
9623
9614
  variableValue: a[e.k],
9624
9615
  variableOptions: o[e.k],
@@ -9626,7 +9617,7 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9626
9617
  injectionType: c[e.k] || `manual`
9627
9618
  }) }, `var_${n}`);
9628
9619
  let l = u(e);
9629
- return l ? (0, react_jsx_runtime.jsx)(react$1.default.Fragment, { children: rn({
9620
+ return l ? (0, react_jsx_runtime.jsx)(react.default.Fragment, { children: un({
9630
9621
  sourceElement: l,
9631
9622
  targetElement: e,
9632
9623
  locales: r,
@@ -9635,16 +9626,16 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9635
9626
  });
9636
9627
  }
9637
9628
  if (n && typeof n == `object` && !Array.isArray(n)) {
9638
- let a = C(n) ? `variable` : `element`;
9639
- if (react$1.default.isValidElement(e)) {
9640
- if (a === `element`) return rn({
9629
+ let a = E(n) ? `variable` : `element`;
9630
+ if (react.default.isValidElement(e)) {
9631
+ if (a === `element`) return un({
9641
9632
  sourceElement: e,
9642
9633
  targetElement: n,
9643
9634
  locales: r,
9644
9635
  renderVariable: i
9645
9636
  });
9646
- if ($t(e.props)) {
9647
- let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = en(e.props);
9637
+ if (on(e.props)) {
9638
+ let { variableValue: t, variableOptions: n, variableType: a, injectionType: o } = sn(e.props);
9648
9639
  return i({
9649
9640
  variableType: a,
9650
9641
  variableValue: t,
@@ -9661,33 +9652,32 @@ function Q({ source: e, target: n, locales: r = [`en`], renderVariable: i }) {
9661
9652
  renderVariable: i
9662
9653
  });
9663
9654
  }
9664
- const sn = `generaltranslation.locale`;
9665
- react$1.use;
9666
- function Hn({ children: e }) {
9655
+ const pn = `generaltranslation.locale`;
9656
+ react.use;
9657
+ function Jn({ children: e }) {
9667
9658
  return e;
9668
9659
  }
9669
- function Un(e) {
9670
- return Hn(e);
9660
+ function Yn(e) {
9661
+ return Jn(e);
9671
9662
  }
9672
- Hn._gtt = `derive`, Un._gtt = `derive`;
9663
+ Jn._gtt = `derive`, Yn._gtt = `derive`;
9673
9664
  //#endregion
9674
- //#region src/i18n-context/browser-i18n-manager/utils/cookies.ts
9665
+ //#region src/shared/cookies.ts
9675
9666
  /**
9676
- * Minimally parses a cookie value for a given cookie name
9667
+ * Minimally parses a cookie value for a given cookie name.
9677
9668
  * @param cookieName - The name of the cookie
9678
- * @returns The locale from the cookie or undefined if not found or invalid
9669
+ * @returns The cookie value, or undefined when it is not found
9679
9670
  */
9680
- function getCookieValue({ cookieName }) {
9671
+ function getCookieValue(cookieName) {
9681
9672
  if (typeof document === "undefined") return void 0;
9682
9673
  return document.cookie.split("; ").find((row) => row.startsWith(`${cookieName}=`))?.split("=")[1];
9683
9674
  }
9684
9675
  /**
9685
- * Sets a cookie value for a given cookie name
9676
+ * Sets a cookie value for a given cookie name.
9686
9677
  * @param cookieName - The name of the cookie
9687
9678
  * @param value - The value to set
9688
- * @returns The value that was set
9689
9679
  */
9690
- function setCookieValue({ cookieName, value }) {
9680
+ function setCookieValue(cookieName, value) {
9691
9681
  if (typeof document === "undefined") return;
9692
9682
  document.cookie = `${cookieName}=${value};path=/`;
9693
9683
  }
@@ -9701,7 +9691,7 @@ function setCookieValue({ cookieName, value }) {
9701
9691
  * @returns The determined locale
9702
9692
  *
9703
9693
  */
9704
- function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = sn, getLocale }) {
9694
+ function determineLocale({ defaultLocale, locales, customMapping, localeCookieName = pn, getLocale }) {
9705
9695
  const localeConfig = {
9706
9696
  defaultLocale,
9707
9697
  locales,
@@ -9721,7 +9711,7 @@ function determineLocale({ defaultLocale, locales, customMapping, localeCookieNa
9721
9711
  return determinedLocale;
9722
9712
  }
9723
9713
  const candidates = [];
9724
- const cookieLocale = getCookieValue({ cookieName: localeCookieName });
9714
+ const cookieLocale = getCookieValue(localeCookieName);
9725
9715
  if (cookieLocale) candidates.push(cookieLocale);
9726
9716
  const navigatorLocales = navigator?.languages || [];
9727
9717
  candidates.push(...navigatorLocales);
@@ -9736,7 +9726,7 @@ var BrowserConditionStore = class {
9736
9726
  /**
9737
9727
  * @param {BrowserConditionStoreConstructorParams} params - The configuration for the BrowserConditionStore
9738
9728
  */
9739
- constructor({ getLocale, localeCookieName = sn, ...localeConfig } = {}) {
9729
+ constructor({ getLocale, localeCookieName = pn, ...localeConfig } = {}) {
9740
9730
  this.localeConfig = localeConfig;
9741
9731
  this.customGetLocale = getLocale;
9742
9732
  this.localeCookieName = localeCookieName;
@@ -9752,10 +9742,7 @@ var BrowserConditionStore = class {
9752
9742
  });
9753
9743
  }
9754
9744
  setLocale(locale) {
9755
- setCookieValue({
9756
- cookieName: this.localeCookieName,
9757
- value: locale
9758
- });
9745
+ setCookieValue(this.localeCookieName, locale);
9759
9746
  }
9760
9747
  };
9761
9748
  //#endregion
@@ -10169,7 +10156,7 @@ async function bootstrap(params) {
10169
10156
  */
10170
10157
  function Branch({ children, branch, ...branches }) {
10171
10158
  const branchKey = branch?.toString();
10172
- if (typeof branch === "string" && branch.startsWith("data-")) branch = void 0;
10159
+ if (branchKey?.startsWith("data-")) return children;
10173
10160
  return branchKey && typeof branches[branchKey] !== "undefined" ? branches[branchKey] : children;
10174
10161
  }
10175
10162
  /**
@@ -10196,7 +10183,7 @@ function Plural({ children, n, locales: localesProp, ...branches }) {
10196
10183
  getDefaultLocale()
10197
10184
  ];
10198
10185
  if (typeof n !== "number") return children;
10199
- const branch = Xt(n, locales, branches);
10186
+ const branch = J(n, locales, branches);
10200
10187
  return branch != null ? branch : children;
10201
10188
  }
10202
10189
  /**
@@ -10229,8 +10216,8 @@ function Derive({ children }) {
10229
10216
  /**
10230
10217
  * Equivalent to the `<Derive>` component, but used for auto insertion.
10231
10218
  */
10232
- function GtInternalDerive({ children }) {
10233
- return children;
10219
+ function GtInternalDerive(props) {
10220
+ return Derive(props);
10234
10221
  }
10235
10222
  /** @internal _gtt - The GT transformation and injection identifier for the component. */
10236
10223
  Derive._gtt = "derive";
@@ -10280,7 +10267,7 @@ const t = (messageOrStrings, ...values) => {
10280
10267
  */
10281
10268
  function handleTaggedTemplateLiteralTranslation(messageOrStrings, values) {
10282
10269
  const locale = getLocale();
10283
- const translatedInterpolatedTemplate = resolveTranslationSync(locale, interpolateTemplateLiteral(messageOrStrings, values));
10270
+ const translatedInterpolatedTemplate = resolveTranslationSync(locale, messageOrStrings.map((string, index) => string + (values[index] ?? "")).join(""));
10284
10271
  if (translatedInterpolatedTemplate) return translatedInterpolatedTemplate;
10285
10272
  const { message, variables } = extractInterpolatableValues(messageOrStrings, values);
10286
10273
  return resolveTranslationSyncWithFallback(locale, message, variables);
@@ -10309,17 +10296,6 @@ function extractInterpolatableValues(strings, values) {
10309
10296
  variables
10310
10297
  };
10311
10298
  }
10312
- /**
10313
- * Interpolate a template literal
10314
- * @param message - The message to interpolate.
10315
- * @param variables - The variables to interpolate.
10316
- * @returns The interpolated message.
10317
- */
10318
- function interpolateTemplateLiteral(strings, values) {
10319
- return strings.map((string, index) => {
10320
- return string + (values[index] ?? "");
10321
- }).join("");
10322
- }
10323
10299
  //#endregion
10324
10300
  //#region src/i18n-context/functions/translation/GtInternalRuntimeTranslateString.ts
10325
10301
  /**
@@ -10370,27 +10346,18 @@ function Num(props) {
10370
10346
  GtInternalNum._gtt = "variable-number-automatic";
10371
10347
  Num._gtt = "variable-number";
10372
10348
  //#endregion
10373
- //#region src/i18n-context/functions/variables/utils/computeVar.ts
10374
- /**
10375
- * Internal implementation of Var component for standardization
10376
- * @internal
10377
- */
10378
- function computeVar({ children }) {
10379
- return children;
10380
- }
10381
- //#endregion
10382
10349
  //#region src/i18n-context/functions/variables/GtInternalVar.tsx
10383
10350
  /**
10384
10351
  * Equivalent to the `<Var>` component, but used for auto insertion
10385
10352
  */
10386
10353
  function GtInternalVar({ children }) {
10387
- return computeVar({ children });
10354
+ return children;
10388
10355
  }
10389
10356
  /**
10390
10357
  * User facing version of the Var component
10391
10358
  */
10392
10359
  function Var({ children }) {
10393
- return computeVar({ children });
10360
+ return children;
10394
10361
  }
10395
10362
  /** @internal _gtt - The GT transformation and injection identifier for the component. */
10396
10363
  Var._gtt = "variable-variable";
@@ -10450,6 +10417,7 @@ GtInternalDateTime._gtt = "variable-datetime-automatic";
10450
10417
  DateTime._gtt = "variable-datetime";
10451
10418
  //#endregion
10452
10419
  //#region src/i18n-context/functions/variables/utils/renderVariable.tsx
10420
+ const getStringOrNumberValue = (value) => typeof value === "string" || typeof value === "number" || value == null ? value : void 0;
10453
10421
  /**
10454
10422
  * Custom override for the renderVariable function
10455
10423
  * to use the GtInternal components instead of the regular components
@@ -10466,7 +10434,7 @@ const renderVariable = ({ variableType, variableValue, variableOptions, injectio
10466
10434
  switch (variableType) {
10467
10435
  case "n": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(injectionType === "automatic" ? Num : GtInternalNum, {
10468
10436
  options: variableOptions,
10469
- children: typeof variableValue === "string" || typeof variableValue === "number" ? variableValue : variableValue == null ? variableValue : void 0
10437
+ children: getStringOrNumberValue(variableValue)
10470
10438
  });
10471
10439
  case "d": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(injectionType === "automatic" ? DateTime : GtInternalDateTime, {
10472
10440
  options: variableOptions,
@@ -10474,11 +10442,11 @@ const renderVariable = ({ variableType, variableValue, variableOptions, injectio
10474
10442
  });
10475
10443
  case "c": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(injectionType === "automatic" ? Currency : GtInternalCurrency, {
10476
10444
  options: variableOptions,
10477
- children: typeof variableValue === "string" || typeof variableValue === "number" ? variableValue : variableValue == null ? variableValue : void 0
10445
+ children: getStringOrNumberValue(variableValue)
10478
10446
  });
10479
10447
  default: {
10480
10448
  const renderedValue = variableValue;
10481
- return injectionType === "automatic" ? computeVar({ children: renderedValue }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Var, { children: renderedValue });
10449
+ return injectionType === "automatic" ? renderedValue : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Var, { children: renderedValue });
10482
10450
  }
10483
10451
  }
10484
10452
  };
@@ -10503,10 +10471,29 @@ GtInternalTranslateJsx._gtt = "translate-client-automatic";
10503
10471
  * Implementation for the T component logic
10504
10472
  */
10505
10473
  function useComputeT({ children: sourceChildren, ...params }) {
10506
- const { taggedSourceChildren, sourceJsxChildren, renderSourceChildren, options } = usePrepSourceRender({
10507
- sourceChildren,
10508
- params
10474
+ const taggedSourceChildren = (0, react.useMemo)(() => Vt(qt(sourceChildren)), [sourceChildren]);
10475
+ const sourceJsxChildren = (0, react.useMemo)(() => q(taggedSourceChildren), [taggedSourceChildren]);
10476
+ const renderSourceChildren = () => Z({
10477
+ children: taggedSourceChildren,
10478
+ defaultLocale: getLocale(),
10479
+ renderVariable
10509
10480
  });
10481
+ const options = (0, react.useMemo)(() => ({
10482
+ $format: "JSX",
10483
+ $context: params.context,
10484
+ $id: params.id,
10485
+ $_hash: params._hash,
10486
+ ...params
10487
+ }), [
10488
+ params.format,
10489
+ params.context,
10490
+ params.id,
10491
+ params._hash,
10492
+ params.$format,
10493
+ params.$context,
10494
+ params.$id,
10495
+ params.$_hash
10496
+ ]);
10510
10497
  const targetLocale = getLocale();
10511
10498
  if (!(0, _generaltranslation_format.requiresTranslation)(getDefaultLocale(), targetLocale)) return renderSourceChildren();
10512
10499
  const targetOptions = {
@@ -10532,44 +10519,6 @@ function useComputeT({ children: sourceChildren, ...params }) {
10532
10519
  return renderSourceChildren();
10533
10520
  }
10534
10521
  /**
10535
- * Returns the tagged source children and the default render function for the source children
10536
- */
10537
- function usePrepSourceRender({ sourceChildren, params }) {
10538
- const taggedSourceChildren = (0, react.useMemo)(() => Nt(Rt(sourceChildren)), [sourceChildren]);
10539
- return {
10540
- taggedSourceChildren,
10541
- sourceJsxChildren: (0, react.useMemo)(() => Y(taggedSourceChildren), [taggedSourceChildren]),
10542
- renderSourceChildren: (0, react.useCallback)(() => {
10543
- return Z({
10544
- children: taggedSourceChildren,
10545
- defaultLocale: getLocale(),
10546
- renderVariable
10547
- });
10548
- }, [taggedSourceChildren]),
10549
- options: (0, react.useMemo)(() => normalizeParameters(params), [
10550
- params.context,
10551
- params.id,
10552
- params._hash,
10553
- params.$format,
10554
- params.$context,
10555
- params.$id,
10556
- params.$_hash
10557
- ])
10558
- };
10559
- }
10560
- /**
10561
- * Normalizes the parameters into a lookup options object.
10562
- */
10563
- function normalizeParameters(parameters) {
10564
- return {
10565
- $format: "JSX",
10566
- $context: parameters.context,
10567
- $id: parameters.id,
10568
- $_hash: parameters._hash,
10569
- ...parameters
10570
- };
10571
- }
10572
- /**
10573
10522
  * Dev-only translation resolver that uses React Suspense.
10574
10523
  * Sync cache check already happened in computeT() — this only handles cache misses.
10575
10524
  * use() suspends until the async translation resolves.
@@ -10694,13 +10643,12 @@ function _convertCustomNamesToMapping(customNames) {
10694
10643
  */
10695
10644
  function InternalLocaleSelector({ locale, locales, customNames, customMapping = _convertCustomNamesToMapping(customNames), setLocale, getLocaleProperties, ...props }) {
10696
10645
  const getDisplayName = (locale) => {
10697
- if (customMapping && customMapping[locale]) {
10698
- if (typeof customMapping[locale] === "string") return customMapping[locale];
10699
- if (customMapping[locale].name) return customMapping[locale].name;
10700
- }
10646
+ const customLocale = customMapping?.[locale];
10647
+ if (typeof customLocale === "string") return customLocale;
10648
+ if (customLocale?.name) return customLocale.name;
10701
10649
  return capitalizeName(getLocaleProperties(locale).nativeNameWithRegionCode);
10702
10650
  };
10703
- if (!locales || locales.length === 0 || !setLocale) return null;
10651
+ if (!locales?.length || !setLocale) return null;
10704
10652
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
10705
10653
  ...props,
10706
10654
  value: locale || "",