@pie-element/simple-cloze 0.1.4-next.5 → 0.1.4-next.7

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.
Files changed (39) hide show
  1. package/author.js +2 -0
  2. package/dist/author/index.d.ts +6 -0
  3. package/dist/author/index.js +12147 -21505
  4. package/dist/author/index.js.map +1 -1
  5. package/dist/browser/author/index.js +9202 -16240
  6. package/dist/browser/author/index.js.map +1 -1
  7. package/dist/browser/{client-Dt8SOe5Z.js → client-BSTc3boO.js} +650 -755
  8. package/dist/browser/client-BSTc3boO.js.map +1 -0
  9. package/dist/browser/controller/index.js +42 -32
  10. package/dist/browser/controller/index.js.map +1 -1
  11. package/dist/browser/delivery/index.js +129 -136
  12. package/dist/browser/delivery/index.js.map +1 -1
  13. package/dist/browser/dist-CYpSKy-4.js +80 -0
  14. package/dist/browser/dist-CYpSKy-4.js.map +1 -0
  15. package/dist/browser/i18n-DJMxdTMU.js +1612 -0
  16. package/dist/browser/i18n-DJMxdTMU.js.map +1 -0
  17. package/dist/browser/plain-text-iaQZhkGe.js +53 -0
  18. package/dist/browser/plain-text-iaQZhkGe.js.map +1 -0
  19. package/dist/browser/print/index.js +64 -21
  20. package/dist/browser/print/index.js.map +1 -1
  21. package/dist/controller/defaults.d.ts +1 -0
  22. package/dist/controller/index.d.ts +51 -8
  23. package/dist/controller/index.js +121 -29
  24. package/dist/controller/index.js.map +1 -1
  25. package/dist/controller/plain-text.d.ts +11 -0
  26. package/dist/delivery/index.d.ts +9 -4
  27. package/dist/delivery/index.js +2826 -267
  28. package/dist/delivery/index.js.map +1 -1
  29. package/dist/i18n.d.ts +7 -0
  30. package/dist/index.iife.js +9 -3
  31. package/dist/index.js +2826 -267
  32. package/dist/index.js.map +1 -1
  33. package/dist/print/index.d.ts +7 -0
  34. package/dist/print/index.js +2775 -28
  35. package/dist/print/index.js.map +1 -1
  36. package/module/print.js +2383 -600
  37. package/module/print.js.map +1 -1
  38. package/package.json +2 -1
  39. package/dist/browser/client-Dt8SOe5Z.js.map +0 -1
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ var object_prototype = Object.prototype;
23
23
  var array_prototype = Array.prototype;
24
24
  var get_prototype_of = Object.getPrototypeOf;
25
25
  var is_extensible = Object.isExtensible;
26
- var noop = () => {};
26
+ var noop$1 = () => {};
27
27
  /** @param {Array<() => void>} arr */
28
28
  function run_all(arr) {
29
29
  for (var i = 0; i < arr.length; i++) arr[i]();
@@ -245,14 +245,6 @@ function safe_not_equal(a, b) {
245
245
  function safe_equals(value) {
246
246
  return !safe_not_equal(value, this.v);
247
247
  }
248
- /**
249
- * `%name%(...)` can only be used during component initialisation
250
- * @param {string} name
251
- * @returns {never}
252
- */
253
- function lifecycle_outside_component(name) {
254
- throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
255
- }
256
248
  //#endregion
257
249
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/errors.js
258
250
  /**
@@ -300,6 +292,14 @@ function hydration_failed() {
300
292
  throw new Error(`https://svelte.dev/e/hydration_failed`);
301
293
  }
302
294
  /**
295
+ * Cannot do `bind:%key%={undefined}` when `%key%` has a fallback value
296
+ * @param {string} key
297
+ * @returns {never}
298
+ */
299
+ function props_invalid_value(key) {
300
+ throw new Error(`https://svelte.dev/e/props_invalid_value`);
301
+ }
302
+ /**
303
303
  * Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
304
304
  * @returns {never}
305
305
  */
@@ -474,6 +474,29 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
474
474
  * schedule effects if the update takes place inside a `$:` effect
475
475
  */
476
476
  var legacy_is_updating_store = false;
477
+ /**
478
+ * Whether or not the prop currently being read is a store binding, as in
479
+ * `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in
480
+ * runes mode, and skip `binding_property_non_reactive` validation
481
+ */
482
+ var is_store_binding = false;
483
+ /**
484
+ * Returns a tuple that indicates whether `fn()` reads a prop that is a store binding.
485
+ * Used to prevent `binding_property_non_reactive` validation false positives and
486
+ * ensure that these props are treated as mutable even in runes mode
487
+ * @template T
488
+ * @param {() => T} fn
489
+ * @returns {[T, boolean]}
490
+ */
491
+ function capture_store_binding(fn) {
492
+ var previous_is_store_binding = is_store_binding;
493
+ try {
494
+ is_store_binding = false;
495
+ return [fn(), is_store_binding];
496
+ } finally {
497
+ is_store_binding = previous_is_store_binding;
498
+ }
499
+ }
477
500
  //#endregion
478
501
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/bindings/shared.js
479
502
  /**
@@ -769,7 +792,7 @@ function freeze_derived_effects(derived) {
769
792
  /** @type {AbortController} */ e.ac.abort(STALE_REACTION);
770
793
  e.ac = null;
771
794
  });
772
- if (e.fn !== null) e.teardown = noop;
795
+ if (e.fn !== null) e.teardown = noop$1;
773
796
  remove_reactions(e, 0);
774
797
  destroy_effect_children(e);
775
798
  }
@@ -1743,7 +1766,7 @@ function proxy(value) {
1743
1766
  sources.set(prop, s);
1744
1767
  }
1745
1768
  if (s !== void 0) {
1746
- var v = get(s);
1769
+ var v = get$1(s);
1747
1770
  return v === UNINITIALIZED ? void 0 : v;
1748
1771
  }
1749
1772
  return Reflect.get(target, prop, receiver);
@@ -1752,7 +1775,7 @@ function proxy(value) {
1752
1775
  var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1753
1776
  if (descriptor && "value" in descriptor) {
1754
1777
  var s = sources.get(prop);
1755
- if (s) descriptor.value = get(s);
1778
+ if (s) descriptor.value = get$1(s);
1756
1779
  } else if (descriptor === void 0) {
1757
1780
  var source = sources.get(prop);
1758
1781
  var value = source?.v;
@@ -1776,7 +1799,7 @@ function proxy(value) {
1776
1799
  });
1777
1800
  sources.set(prop, s);
1778
1801
  }
1779
- if (get(s) === UNINITIALIZED) return false;
1802
+ if (get$1(s) === UNINITIALIZED) return false;
1780
1803
  }
1781
1804
  return has;
1782
1805
  },
@@ -1815,7 +1838,7 @@ function proxy(value) {
1815
1838
  return true;
1816
1839
  },
1817
1840
  ownKeys(target) {
1818
- get(version);
1841
+ get$1(version);
1819
1842
  var own_keys = Reflect.ownKeys(target).filter((key) => {
1820
1843
  var source = sources.get(key);
1821
1844
  return source === void 0 || source.v !== UNINITIALIZED;
@@ -2205,7 +2228,7 @@ function render_effect(fn, flags = 0) {
2205
2228
  function template_effect(fn, sync = [], async = [], blockers = []) {
2206
2229
  flatten(blockers, sync, async, (values) => {
2207
2230
  create_effect(8, () => {
2208
- fn(...values.map(get));
2231
+ fn(...values.map(get$1));
2209
2232
  });
2210
2233
  });
2211
2234
  }
@@ -2690,7 +2713,7 @@ function update_effect(effect) {
2690
2713
  * @param {Value<V>} signal
2691
2714
  * @returns {V}
2692
2715
  */
2693
- function get(signal) {
2716
+ function get$1(signal) {
2694
2717
  var is_derived = (signal.f & 2) !== 0;
2695
2718
  captured_signals?.add(signal);
2696
2719
  if (active_reaction !== null && !untracking) {
@@ -3100,7 +3123,7 @@ function createSubscriber(start) {
3100
3123
  let stop;
3101
3124
  return () => {
3102
3125
  if (effect_tracking()) {
3103
- get(version);
3126
+ get$1(version);
3104
3127
  render_effect(() => {
3105
3128
  if (subscribers === 0) stop = untrack(() => start(() => increment(version)));
3106
3129
  subscribers += 1;
@@ -3263,7 +3286,7 @@ var Boundary = class {
3263
3286
  }
3264
3287
  get_effect_pending() {
3265
3288
  _classPrivateFieldGet2(_effect_pending_subscriber, this).call(this);
3266
- return get(_classPrivateFieldGet2(_effect_pending, this));
3289
+ return get$1(_classPrivateFieldGet2(_effect_pending, this));
3267
3290
  }
3268
3291
  /** @param {unknown} error */
3269
3292
  error(error) {
@@ -3811,40 +3834,6 @@ var BranchManager = class {
3811
3834
  }
3812
3835
  }
3813
3836
  };
3814
- /**
3815
- * `onMount`, like [`$effect`](https://svelte.dev/docs/svelte/$effect), schedules a function to run as soon as the component has been mounted to the DOM.
3816
- * Unlike `$effect`, the provided function only runs once.
3817
- *
3818
- * It must be called during the component's initialisation (but doesn't need to live _inside_ the component;
3819
- * it can be called from an external module). If a function is returned _synchronously_ from `onMount`,
3820
- * it will be called when the component is unmounted.
3821
- *
3822
- * `onMount` functions do not run during [server-side rendering](https://svelte.dev/docs/svelte/svelte-server#render).
3823
- *
3824
- * @template T
3825
- * @param {() => NotFunction<T> | Promise<NotFunction<T>> | (() => any)} fn
3826
- * @returns {void}
3827
- */
3828
- function onMount(fn) {
3829
- if (component_context === null) lifecycle_outside_component("onMount");
3830
- if (legacy_mode_flag && component_context.l !== null) init_update_callbacks(component_context).m.push(fn);
3831
- else user_effect(() => {
3832
- const cleanup = untrack(fn);
3833
- if (typeof cleanup === "function") return cleanup;
3834
- });
3835
- }
3836
- /**
3837
- * Legacy-mode: Init callbacks object for onMount/beforeUpdate/afterUpdate
3838
- * @param {ComponentContext} context
3839
- */
3840
- function init_update_callbacks(context) {
3841
- var l = context.l;
3842
- return l.u ?? (l.u = {
3843
- a: [],
3844
- b: [],
3845
- m: []
3846
- });
3847
- }
3848
3837
  //#endregion
3849
3838
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/blocks/if.js
3850
3839
  /** @import { TemplateNode } from '#client' */
@@ -3957,7 +3946,7 @@ function html(node, get_value, is_controlled = false, svg = false, mathml = fals
3957
3946
  * @param {Node} anchor
3958
3947
  * @param {{ hash: string, code: string }} css
3959
3948
  */
3960
- function append_styles$1(anchor, css) {
3949
+ function append_styles(anchor, css) {
3961
3950
  effect(() => {
3962
3951
  anchor = active_effect?.parent?.nodes?.start ?? anchor;
3963
3952
  var root = anchor.getRootNode();
@@ -3972,123 +3961,54 @@ function append_styles$1(anchor, css) {
3972
3961
  }
3973
3962
  //#endregion
3974
3963
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/shared/attributes.js
3975
- /**
3976
- *
3977
- * @param {Record<string,any>} styles
3978
- * @param {boolean} important
3979
- */
3980
- function append_styles(styles, important = false) {
3981
- var separator = important ? " !important;" : ";";
3982
- var css = "";
3983
- for (var key of Object.keys(styles)) {
3984
- var value = styles[key];
3985
- if (value != null && value !== "") css += " " + key + ": " + value + separator;
3986
- }
3987
- return css;
3988
- }
3989
- /**
3990
- * @param {string} name
3991
- * @returns {string}
3992
- */
3993
- function to_css_name(name) {
3994
- if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
3995
- return name;
3996
- }
3964
+ var whitespace = [..." \n\r\f\xA0\v"];
3997
3965
  /**
3998
3966
  * @param {any} value
3999
- * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
3967
+ * @param {string | null} [hash]
3968
+ * @param {Record<string, boolean>} [directives]
4000
3969
  * @returns {string | null}
4001
3970
  */
4002
- function to_style(value, styles) {
4003
- if (styles) {
4004
- var new_style = "";
4005
- /** @type {Record<string,any> | undefined} */
4006
- var normal_styles;
4007
- /** @type {Record<string,any> | undefined} */
4008
- var important_styles;
4009
- if (Array.isArray(styles)) {
4010
- normal_styles = styles[0];
4011
- important_styles = styles[1];
4012
- } else normal_styles = styles;
4013
- if (value) {
4014
- value = String(value).replaceAll(/\/\*.*?\*\//g, "").trim();
4015
- /** @type {boolean | '"' | "'"} */
4016
- var in_str = false;
4017
- var in_apo = 0;
4018
- var in_comment = false;
4019
- var reserved_names = [];
4020
- if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
4021
- if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
4022
- var start_index = 0;
4023
- var name_index = -1;
4024
- const len = value.length;
4025
- for (var i = 0; i < len; i++) {
4026
- var c = value[i];
4027
- if (in_comment) {
4028
- if (c === "/" && value[i - 1] === "*") in_comment = false;
4029
- } else if (in_str) {
4030
- if (in_str === c) in_str = false;
4031
- } else if (c === "/" && value[i + 1] === "*") in_comment = true;
4032
- else if (c === "\"" || c === "'") in_str = c;
4033
- else if (c === "(") in_apo++;
4034
- else if (c === ")") in_apo--;
4035
- if (!in_comment && in_str === false && in_apo === 0) {
4036
- if (c === ":" && name_index === -1) name_index = i;
4037
- else if (c === ";" || i === len - 1) {
4038
- if (name_index !== -1) {
4039
- var name = to_css_name(value.substring(start_index, name_index).trim());
4040
- if (!reserved_names.includes(name)) {
4041
- if (c !== ";") i++;
4042
- var property = value.substring(start_index, i).trim();
4043
- new_style += " " + property + ";";
4044
- }
4045
- }
4046
- start_index = i + 1;
4047
- name_index = -1;
4048
- }
4049
- }
3971
+ function to_class(value, hash, directives) {
3972
+ var classname = value == null ? "" : "" + value;
3973
+ if (hash) classname = classname ? classname + " " + hash : hash;
3974
+ if (directives) {
3975
+ for (var key of Object.keys(directives)) if (directives[key]) classname = classname ? classname + " " + key : key;
3976
+ else if (classname.length) {
3977
+ var len = key.length;
3978
+ var a = 0;
3979
+ while ((a = classname.indexOf(key, a)) >= 0) {
3980
+ var b = a + len;
3981
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
3982
+ else a = b;
4050
3983
  }
4051
3984
  }
4052
- if (normal_styles) new_style += append_styles(normal_styles);
4053
- if (important_styles) new_style += append_styles(important_styles, true);
4054
- new_style = new_style.trim();
4055
- return new_style === "" ? null : new_style;
4056
3985
  }
4057
- return value == null ? null : String(value);
3986
+ return classname === "" ? null : classname;
4058
3987
  }
4059
3988
  //#endregion
4060
- //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/style.js
3989
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/class.js
4061
3990
  /**
4062
- * @param {Element & ElementCSSInlineStyle} dom
4063
- * @param {Record<string, any>} prev
4064
- * @param {Record<string, any>} next
4065
- * @param {string} [priority]
4066
- */
4067
- function update_styles(dom, prev = {}, next, priority) {
4068
- for (var key in next) {
4069
- var value = next[key];
4070
- if (prev[key] !== value) if (next[key] == null) dom.style.removeProperty(key);
4071
- else dom.style.setProperty(key, value, priority);
4072
- }
4073
- }
4074
- /**
4075
- * @param {Element & ElementCSSInlineStyle} dom
3991
+ * @param {Element} dom
3992
+ * @param {boolean | number} is_html
4076
3993
  * @param {string | null} value
4077
- * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [prev_styles]
4078
- * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [next_styles]
4079
- */
4080
- function set_style(dom, value, prev_styles, next_styles) {
4081
- var prev = dom[STYLE_CACHE];
4082
- if (hydrating || prev !== value) {
4083
- var next_style_attr = to_style(value, next_styles);
4084
- if (!hydrating || next_style_attr !== dom.getAttribute("style")) if (next_style_attr == null) dom.removeAttribute("style");
4085
- else dom.style.cssText = next_style_attr;
4086
- /** @type {any} */ dom[STYLE_CACHE] = value;
4087
- } else if (next_styles) if (Array.isArray(next_styles)) {
4088
- update_styles(dom, prev_styles?.[0], next_styles[0]);
4089
- update_styles(dom, prev_styles?.[1], next_styles[1], "important");
4090
- } else update_styles(dom, prev_styles, next_styles);
4091
- return next_styles;
3994
+ * @param {string} [hash]
3995
+ * @param {Record<string, any>} [prev_classes]
3996
+ * @param {Record<string, any>} [next_classes]
3997
+ * @returns {Record<string, boolean> | undefined}
3998
+ */
3999
+ function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
4000
+ var prev = dom[CLASS_CACHE];
4001
+ if (hydrating || prev !== value || prev === void 0) {
4002
+ var next_class_name = to_class(value, hash, next_classes);
4003
+ if (!hydrating || next_class_name !== dom.getAttribute("class")) if (next_class_name == null) dom.removeAttribute("class");
4004
+ else if (is_html) dom.className = next_class_name;
4005
+ else dom.setAttribute("class", next_class_name);
4006
+ /** @type {any} */ dom[CLASS_CACHE] = value;
4007
+ } else if (next_classes && prev_classes !== next_classes) for (var key in next_classes) {
4008
+ var is_present = !!next_classes[key];
4009
+ if (prev_classes == null || is_present !== !!prev_classes[key]) dom.classList.toggle(key, is_present);
4010
+ }
4011
+ return next_classes;
4092
4012
  }
4093
4013
  //#endregion
4094
4014
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/dom/elements/attributes.js
@@ -4250,6 +4170,99 @@ function bind_this(element_or_component = mark_as_component(), update, get_value
4250
4170
  return element_or_component;
4251
4171
  }
4252
4172
  //#endregion
4173
+ //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/internal/client/reactivity/props.js
4174
+ /** @import { Derived, Effect, Source } from './types.js' */
4175
+ /**
4176
+ * This function is responsible for synchronizing a possibly bound prop with the inner component state.
4177
+ * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.
4178
+ * @template V
4179
+ * @param {Record<string, unknown>} props
4180
+ * @param {string} key
4181
+ * @param {number} flags
4182
+ * @param {V | (() => V)} [fallback]
4183
+ * @returns {(() => V | ((arg: V) => V) | ((arg: V, mutation: boolean) => V))}
4184
+ */
4185
+ function prop(props, key, flags, fallback) {
4186
+ var runes = !legacy_mode_flag || (flags & 2) !== 0;
4187
+ var bindable = (flags & 8) !== 0;
4188
+ var lazy = (flags & 16) !== 0;
4189
+ var fallback_value = fallback;
4190
+ var fallback_dirty = true;
4191
+ var fallback_signal = void 0;
4192
+ var get_fallback = () => {
4193
+ if (lazy && runes) {
4194
+ fallback_signal ?? (fallback_signal = /* @__PURE__ */ derived(fallback));
4195
+ return get$1(fallback_signal);
4196
+ }
4197
+ if (fallback_dirty) {
4198
+ fallback_dirty = false;
4199
+ fallback_value = lazy ? untrack(fallback) : fallback;
4200
+ }
4201
+ return fallback_value;
4202
+ };
4203
+ /** @type {((v: V) => void) | undefined} */
4204
+ let setter;
4205
+ if (bindable) {
4206
+ var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
4207
+ setter = get_descriptor(props, key)?.set ?? (is_entry_props && key in props ? (v) => props[key] = v : void 0);
4208
+ }
4209
+ /** @type {V} */
4210
+ var initial_value;
4211
+ var is_store_sub = false;
4212
+ if (bindable) [initial_value, is_store_sub] = capture_store_binding(() => props[key]);
4213
+ else initial_value = props[key];
4214
+ if (initial_value === void 0 && fallback !== void 0) {
4215
+ initial_value = get_fallback();
4216
+ if (setter) {
4217
+ if (runes) props_invalid_value(key);
4218
+ setter(initial_value);
4219
+ }
4220
+ }
4221
+ /** @type {() => V} */
4222
+ var getter;
4223
+ if (runes) getter = () => {
4224
+ var value = props[key];
4225
+ if (value === void 0) return get_fallback();
4226
+ fallback_dirty = true;
4227
+ return value;
4228
+ };
4229
+ else getter = () => {
4230
+ var value = props[key];
4231
+ if (value !== void 0) fallback_value = void 0;
4232
+ return value === void 0 ? fallback_value : value;
4233
+ };
4234
+ if (runes && (flags & 4) === 0) return getter;
4235
+ if (setter) {
4236
+ var legacy_parent = props.$$legacy;
4237
+ return (function(value, mutation) {
4238
+ if (arguments.length > 0) {
4239
+ if (!runes || !mutation || legacy_parent || is_store_sub)
4240
+ /** @type {Function} */ setter(mutation ? getter() : value);
4241
+ return value;
4242
+ }
4243
+ return getter();
4244
+ });
4245
+ }
4246
+ var overridden = false;
4247
+ var d = ((flags & 1) !== 0 ? derived : derived_safe_equal)(() => {
4248
+ overridden = false;
4249
+ return getter();
4250
+ });
4251
+ if (bindable) get$1(d);
4252
+ var parent_effect = active_effect;
4253
+ return (function(value, mutation) {
4254
+ if (arguments.length > 0) {
4255
+ const new_value = mutation ? get$1(d) : runes && bindable ? proxy(value) : value;
4256
+ set(d, new_value);
4257
+ overridden = true;
4258
+ if (fallback_value !== void 0) fallback_value = new_value;
4259
+ return value;
4260
+ }
4261
+ if (is_destroying_effect && overridden || (parent_effect.f & 16384) !== 0) return d.v;
4262
+ return get$1(d);
4263
+ });
4264
+ }
4265
+ //#endregion
4253
4266
  //#region ../../../node_modules/.bun/svelte@5.57.0/node_modules/svelte/src/legacy/legacy-client.js
4254
4267
  /** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
4255
4268
  /**
@@ -4300,11 +4313,11 @@ var Svelte4Component = class {
4300
4313
  $$events: {}
4301
4314
  }, {
4302
4315
  get(target, prop) {
4303
- return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4316
+ return get$1(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4304
4317
  },
4305
4318
  has(target, prop) {
4306
4319
  if (prop === LEGACY_PROPS) return true;
4307
- get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4320
+ get$1(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
4308
4321
  return Reflect.has(target, prop);
4309
4322
  },
4310
4323
  set(target, prop, value) {
@@ -4654,10 +4667,10 @@ function create_custom_element(Component, props_definition, slots, exports, shad
4654
4667
  return Class;
4655
4668
  }
4656
4669
  //#endregion
4657
- //#region ../../lib-svelte/delivery-events/dist/index2.js
4670
+ //#region ../../shared/player-events/dist/index.js
4658
4671
  var _e;
4659
4672
  var _e2;
4660
- var e = (_e = class e extends CustomEvent {
4673
+ var s$2 = (_e = class e extends CustomEvent {
4661
4674
  constructor(t, n, r) {
4662
4675
  super(e.TYPE, {
4663
4676
  bubbles: !0,
@@ -4670,7 +4683,7 @@ var e = (_e = class e extends CustomEvent {
4670
4683
  }), this.component = t, this.complete = n;
4671
4684
  }
4672
4685
  }, _e.TYPE = "model-set", _e);
4673
- var t$1 = (_e2 = class e extends CustomEvent {
4686
+ var c$2 = (_e2 = class e extends CustomEvent {
4674
4687
  constructor(t, n) {
4675
4688
  super(e.TYPE, {
4676
4689
  bubbles: !0,
@@ -4683,29 +4696,30 @@ var t$1 = (_e2 = class e extends CustomEvent {
4683
4696
  }
4684
4697
  }, _e2.TYPE = "session-changed", _e2);
4685
4698
  //#endregion
4686
- //#region ../../lib-svelte/delivery-events/dist/index3.js
4687
- var t = (e) => {
4699
+ //#region ../../lib-svelte/delivery-events/dist/index2.js
4700
+ var t$3 = (e) => {
4688
4701
  let t = e;
4689
4702
  return t ? typeof t.onSessionChange == "function" || typeof t.onAudioStarted == "function" || typeof t.onAudioEnded == "function" : !1;
4690
4703
  };
4691
- function n(e, n = {}) {
4692
- let r = n.hostPredicate ?? t, i = e;
4693
- for (; i;) {
4694
- if (r(i)) return i;
4695
- i = i.parentElement;
4696
- }
4697
- if (typeof document < "u" && n.fallbackSelector) {
4698
- let e = document.querySelector(n.fallbackSelector);
4699
- if (r(e)) return e;
4704
+ function n$1(e) {
4705
+ if (e.parentElement) return e.parentElement;
4706
+ let t = e.getRootNode();
4707
+ return t instanceof ShadowRoot ? t.host : null;
4708
+ }
4709
+ function r$2(e, r = {}) {
4710
+ let i = r.hostPredicate ?? t$3, a = e;
4711
+ for (; a;) {
4712
+ if (i(a)) return a;
4713
+ a = n$1(a);
4700
4714
  }
4701
4715
  return null;
4702
4716
  }
4703
- function r(e) {
4717
+ function i(e) {
4704
4718
  return !!e && typeof e == "object" && !Array.isArray(e);
4705
4719
  }
4706
- function i(e, t) {
4720
+ function a$1(e, t) {
4707
4721
  if (e === t) return e;
4708
- if (!r(e) || !r(t) || Object.isFrozen(e) || !Object.isExtensible(e)) return t;
4722
+ if (!i(e) || !i(t) || Object.isFrozen(e) || !Object.isExtensible(e)) return t;
4709
4723
  try {
4710
4724
  for (let n of Object.keys(e)) n in t || delete e[n];
4711
4725
  Object.assign(e, t);
@@ -4714,137 +4728,2673 @@ function i(e, t) {
4714
4728
  }
4715
4729
  return e;
4716
4730
  }
4717
- function a({ sourceEl: t, fallbackSelector: r, component: i, complete: a, session: o }) {
4718
- let s = n(t, { fallbackSelector: r });
4719
- return s ? typeof s.onSessionChange == "function" ? (s.onSessionChange(o), s) : (s.dispatchEvent(new t$1(i, a)), s) : null;
4720
- }
4721
- var root = /* @__PURE__ */ from_html(`<div class="mb-4 prose"></div>`);
4722
- var root_1 = /* @__PURE__ */ from_svg(`<svg style="width: 25px; height: 25px;" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-283 359 34 35"><circle cx="-266" cy="375.9" r="14" fill="#bce2ff"></circle><path d="M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z" fill="#bce2ff"></path><polygon points="-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6" fill="#1a9cff"></polygon></svg>`);
4723
- var root_2 = /* @__PURE__ */ from_svg(`<svg style="width: 25px; height: 25px;" preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-129.5 127 34 35"><path style="fill: #D0CAC5; stroke: #E6E3E0; stroke-width: 0.75; stroke-miterlimit: 10;" d="M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5 C-97.4,153.5-104.3,160.4-112.9,160.4z"></path><path style="fill: #B3ABA4; stroke: #CDC7C2; stroke-width: 0.5; stroke-miterlimit: 10;" d="M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"></path><circle cx="-114.2" cy="143.5" r="14" fill="white"></circle><path d="M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z" fill="#bce2ff"></path><polygon points="-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2" fill="#1a9cff"></polygon></svg>`);
4724
- var root_3 = /* @__PURE__ */ from_html(`<button type="button" class="mb-3 flex items-center gap-2 cursor-pointer select-none"><!> <span class="text-sm hover:underline"> </span></button>`);
4725
- var root_4 = /* @__PURE__ */ from_html(`<span class="correctness-icon svelte-1glps5n" style="background-color: #0EA449;"><svg style="width: 12px; height: 12px; color: white;" fill="currentColor" viewBox="0 0 24 24"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"></path></svg></span>`);
4726
- var root_5 = /* @__PURE__ */ from_html(`<span class="correctness-icon svelte-1glps5n" style="background-color: #BF0D00;"><svg style="width: 12px; height: 12px; color: white;" fill="currentColor" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg></span>`);
4727
- var root_6 = /* @__PURE__ */ from_html(`<div class="p-4"><!> <!> <div class="relative inline-block"><!> <!> <input type="text" placeholder="Enter your answer..." class="outline-none px-3 py-2 rounded svelte-1glps5n"/></div></div>`);
4731
+ var o$1 = {};
4732
+ var s$1 = /* @__PURE__ */ new WeakSet();
4733
+ function c$1(e) {
4734
+ let t = e ?? o$1;
4735
+ if (s$1.has(t)) return;
4736
+ s$1.add(t);
4737
+ let n = e ? `above <${e.tagName.toLowerCase()}>` : "for an update with no source element";
4738
+ console.warn(`[session-bridge] no delivery host ${n}; the session change was not forwarded to the player`);
4739
+ }
4740
+ function l({ sourceEl: t, complete: n, session: i }) {
4741
+ let o = r$2(t);
4742
+ if (!o) return c$1(t), null;
4743
+ if (typeof o.onSessionChange == "function") return o.onSessionChange(i), o;
4744
+ let s = a$1(o.session, i);
4745
+ return s !== o.session && (o.session = s), o.dispatchEvent(new c$2(o.tagName.toLowerCase(), n)), o;
4746
+ }
4747
+ //#endregion
4748
+ //#region ../../shared/math-rendering-mathjax/dist/index.js
4749
+ var e$2 = null;
4750
+ function t$2(t) {
4751
+ return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : e$2 || (e$2 = new Promise((e, n) => {
4752
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
4753
+ loader: { load: i ? ["a11y/assistive-mml"] : [] },
4754
+ tex: {
4755
+ packages: [
4756
+ "base",
4757
+ "ams",
4758
+ "autoload"
4759
+ ],
4760
+ macros: {
4761
+ parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
4762
+ overarc: "\\overparen",
4763
+ napprox: "\\not\\approx",
4764
+ longdiv: "\\enclose{longdiv}"
4765
+ }
4766
+ },
4767
+ options: {
4768
+ enableMenu: i,
4769
+ enableExplorer: i,
4770
+ enableAssistiveMml: i
4771
+ },
4772
+ startup: {
4773
+ ready: () => {
4774
+ window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
4775
+ },
4776
+ defaultReady: () => {}
4777
+ }
4778
+ };
4779
+ r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
4780
+ let c = document.createElement("script");
4781
+ c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
4782
+ setTimeout(e, 100);
4783
+ }, c.onerror = () => {
4784
+ n(/* @__PURE__ */ Error("Failed to load MathJax"));
4785
+ }, document.head.appendChild(c);
4786
+ }), e$2);
4787
+ }
4788
+ function n() {
4789
+ let e = window.MathJax?.startup?.document;
4790
+ if (typeof e?.assistiveMml == "function") try {
4791
+ e.assistiveMml().updateDocument?.();
4792
+ } catch (e) {
4793
+ console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
4794
+ }
4795
+ }
4796
+ function r$1(e = {}) {
4797
+ return async (r) => {
4798
+ if (await t$2(e), !window.MathJax?.typesetPromise) {
4799
+ console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
4800
+ return;
4801
+ }
4802
+ await window.MathJax.typesetPromise([r]), n();
4803
+ };
4804
+ }
4805
+ var a = null;
4806
+ function o() {
4807
+ return a || (a = r$1({
4808
+ accessibility: !0,
4809
+ useSingleDollar: !0
4810
+ })), a;
4811
+ }
4812
+ function s() {
4813
+ if (typeof window > "u") return null;
4814
+ let e = window["@pie-lib/math-rendering"];
4815
+ return typeof e?.renderMath == "function" ? e : null;
4816
+ }
4817
+ var c = async (e) => {
4818
+ if (typeof window > "u") return;
4819
+ let t = typeof e == "string", n;
4820
+ t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
4821
+ let r = s();
4822
+ return r ? await r.renderMath?.(n) : await o()(n), t ? n.innerHTML : void 0;
4823
+ };
4824
+ //#endregion
4825
+ //#region ../../shared/translator/dist/en.js
4826
+ var e$1 = {
4827
+ translation: {
4828
+ categorize: {
4829
+ limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
4830
+ maxChoicesPerCategoryRestriction: "To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s]."
4831
+ },
4832
+ ebsr: { part: "Part {{index}}" },
4833
+ numberLine: {
4834
+ addElementLimit_one: "You can only add {{count}} element",
4835
+ addElementLimit_other: "You can only add {{count}} elements",
4836
+ clearAll: "Clear all"
4837
+ },
4838
+ imageClozeAssociation: {
4839
+ reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
4840
+ reachedLimit_other: "Full"
4841
+ },
4842
+ drawingResponse: {
4843
+ fillColor: "Fill color",
4844
+ outlineColor: "Outline color",
4845
+ noFill: "No fill",
4846
+ lightblue: "Light blue",
4847
+ lightyellow: "Light yellow",
4848
+ red: "Red",
4849
+ orange: "Orange",
4850
+ yellow: "Yellow",
4851
+ violet: "Violet",
4852
+ blue: "Blue",
4853
+ green: "Green",
4854
+ white: "White",
4855
+ black: "Black",
4856
+ onDoubleClick: "Double click to edit this text. Press Enter to submit."
4857
+ },
4858
+ charting: {
4859
+ addCategory: "Add category",
4860
+ actions: "Actions",
4861
+ add: "Add",
4862
+ delete: "Delete",
4863
+ newLabel: "New label",
4864
+ reachedLimit_other: "There can't be more than {{count}} categories.",
4865
+ keyLegend: {
4866
+ incorrectAnswer: "Student incorrect answer",
4867
+ correctAnswer: "Student correct answer",
4868
+ correctKeyAnswer: "Answer key correct"
4869
+ }
4870
+ },
4871
+ graphing: {
4872
+ point: "Point",
4873
+ circle: "Circle",
4874
+ line: "Line",
4875
+ parabola: "Parabola",
4876
+ absolute: "Absolute Value",
4877
+ exponential: "Exponential",
4878
+ polygon: "Polygon",
4879
+ ray: "Ray",
4880
+ segment: "Segment",
4881
+ sine: "Sine",
4882
+ vector: "Vector",
4883
+ label: "Label",
4884
+ redo: "Redo",
4885
+ reset: "Reset"
4886
+ },
4887
+ mathInline: { primaryCorrectWithAlternates: "Note: The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct." },
4888
+ mcPopulatedBlank: {
4889
+ answerChoices: "Answer choices",
4890
+ blankLabel: "blank",
4891
+ emptyBlank: "(blank)",
4892
+ blankPreSelectionHint: "The answer you choose will appear on the blank line above.",
4893
+ correctAnswerSelected: "Correct answer selected",
4894
+ incorrectAnswerSelected: "Incorrect answer selected",
4895
+ selectedAnswerImage: "Selected answer image",
4896
+ choiceImage: "Choice {{id}}",
4897
+ clickToEnableAutoplay: "Click to enable audio autoplay",
4898
+ audioResourceUnavailable: "Audio is enabled but no playable audio URL is configured.",
4899
+ listen: "Listen",
4900
+ listenSilentAlt: "Repeat instructions",
4901
+ listenPlayingAlt: "Instructions are playing",
4902
+ printAudio: "Audio:",
4903
+ printTranscript: "Transcript:",
4904
+ printKey: "(key)"
4905
+ },
4906
+ multipleChoice: {
4907
+ minSelections: "Select at least {{minSelections}}.",
4908
+ maxSelections_one: "Only {{maxSelections}} answer is allowed.",
4909
+ maxSelections_other: "Only {{maxSelections}} answers are allowed.",
4910
+ minmaxSelections_equal: "Select {{minSelections}}.",
4911
+ minmaxSelections_range: "Select between {{minSelections}} and {{maxSelections}}."
4912
+ },
4913
+ selectText: {
4914
+ correctAnswerSelected: "Correct",
4915
+ correctAnswerNotSelected: "Correct Answer Not Selected",
4916
+ incorrectSelection: "Incorrect Selection",
4917
+ key: "Key"
4918
+ },
4919
+ simpleCloze: {
4920
+ correctAnswerShown: "Correct answer",
4921
+ correct: "Correct",
4922
+ incorrect: "Incorrect",
4923
+ unanswered: "No answer",
4924
+ placeholder: "Enter your answer...",
4925
+ answerInput: "Your answer",
4926
+ printCorrectAnswer: "Correct answer:",
4927
+ printAnswerBlank: "Answer blank"
4928
+ },
4929
+ vennClassification: {
4930
+ tray: "Tiles to classify",
4931
+ unknownTarget: "unknown",
4932
+ cancelled: "Cancelled",
4933
+ returnedToTray: "{{name}} returned to tray",
4934
+ placedIn: "{{name}} placed in {{target}}",
4935
+ pickedUp: "Picked up {{name}}",
4936
+ pickedUpWithKeyboard: "Picked up {{name}}, drop target: {{target}}. Use arrow keys to choose a drop target, Enter to drop, Escape to cancel.",
4937
+ dropTarget: "Drop target: {{target}}",
4938
+ unsupportedCircles_one: "This diagram cannot be shown: it has {{count}} circle, and only {{supported}} are supported.",
4939
+ unsupportedCircles_other: "This diagram cannot be shown: it has {{count}} circles, and only {{supported}} are supported.",
4940
+ setNumber: "Set {{number}}",
4941
+ regionOnly: "{{set}} only",
4942
+ regionNeither: "Neither {{first}} nor {{second}}",
4943
+ regionNoneOf: "None of {{sets}}",
4944
+ regionAndSeparator: " and ",
4945
+ tileFallbackName: "Tile",
4946
+ tileNotPlaced: "not placed",
4947
+ tileInRegion: "in {{region}}",
4948
+ tileCorrect: "correct",
4949
+ tileIncorrect: "incorrect"
4950
+ }
4951
+ },
4952
+ common: {
4953
+ undo: "Undo",
4954
+ clearAll: "Clear all",
4955
+ correct: "Correct",
4956
+ incorrect: "Incorrect",
4957
+ showCorrectAnswer: "Show correct answer",
4958
+ hideCorrectAnswer: "Hide correct answer",
4959
+ showTeacherInstructions: "Show Teacher Instructions",
4960
+ hideTeacherInstructions: "Hide Teacher Instructions",
4961
+ commonCorrectAnswerWithAlternates: "Note: The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.",
4962
+ warning: "Warning",
4963
+ showNote: "Show Note",
4964
+ hideNote: "Hide Note",
4965
+ cancel: "Cancel"
4966
+ }
4967
+ };
4968
+ //#endregion
4969
+ //#region ../../shared/translator/dist/es.js
4970
+ var e = {
4971
+ translation: {
4972
+ categorize: {
4973
+ limitMaxChoicesPerCategory: "Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
4974
+ maxChoicesPerCategoryRestriction: "Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta"
4975
+ },
4976
+ ebsr: { part: "Parte {{index}}" },
4977
+ numberLine: {
4978
+ addElementLimit_one: "Solo puedes agregar {{count}} elemento",
4979
+ addElementLimit_other: "Solo puedes agregar {{count}} elementos",
4980
+ clearAll: "Borrar todo"
4981
+ },
4982
+ imageClozeAssociation: {
4983
+ reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
4984
+ reachedLimit_other: "Lleno"
4985
+ },
4986
+ drawingResponse: {
4987
+ fillColor: "Color de relleno",
4988
+ outlineColor: "Color del contorno",
4989
+ noFill: "Sin relleno",
4990
+ lightblue: "Azul claro",
4991
+ lightyellow: "Amarillo claro",
4992
+ red: "Rojo",
4993
+ orange: "Naranja",
4994
+ yellow: "Amarillo",
4995
+ violet: "Violeta",
4996
+ blue: "Azul",
4997
+ green: "Verde",
4998
+ white: "Blanco",
4999
+ black: "Negro",
5000
+ onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
5001
+ },
5002
+ charting: {
5003
+ addCategory: "Añadir categoría",
5004
+ actions: "Acciones",
5005
+ add: "Añadir",
5006
+ delete: "Eliminar",
5007
+ newLabel: "Nueva etiqueta",
5008
+ reachedLimit_other: "No puede haber más de {{count}} categorías.",
5009
+ keyLegend: {
5010
+ incorrectAnswer: "Respuesta incorrecta del estudiante",
5011
+ correctAnswer: "Respuesta correcta del estudiante",
5012
+ correctKeyAnswer: "Clave de respuesta correcta"
5013
+ }
5014
+ },
5015
+ graphing: {
5016
+ point: "Punto",
5017
+ circle: "Circulo",
5018
+ line: "Línea",
5019
+ parabola: "Parábola",
5020
+ absolute: "Valor absoluto",
5021
+ exponential: "Exponencial",
5022
+ polygon: "Polígono",
5023
+ ray: "Semirrecta",
5024
+ segment: "Segmento ",
5025
+ sine: "Seno",
5026
+ vector: "Vector",
5027
+ label: "Etiqueta",
5028
+ redo: "Rehacer",
5029
+ reset: "Reiniciar"
5030
+ },
5031
+ mathInline: { primaryCorrectWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta principal especificada por el autor para esta pregunta, pero también se pueden reconocer otras respuestas como correctas." },
5032
+ mcPopulatedBlank: {
5033
+ answerChoices: "Opciones de respuesta",
5034
+ blankLabel: "espacio en blanco",
5035
+ emptyBlank: "(en blanco)",
5036
+ blankPreSelectionHint: "La respuesta que elijas aparecerá en la línea en blanco de arriba.",
5037
+ correctAnswerSelected: "Respuesta correcta seleccionada",
5038
+ incorrectAnswerSelected: "Respuesta incorrecta seleccionada",
5039
+ selectedAnswerImage: "Imagen de la respuesta seleccionada",
5040
+ choiceImage: "Opción {{id}}",
5041
+ clickToEnableAutoplay: "Haz clic para activar la reproducción automática del audio",
5042
+ audioResourceUnavailable: "El audio está activado, pero no hay una URL de audio reproducible configurada.",
5043
+ listen: "Escuchar",
5044
+ listenSilentAlt: "Escuchar. Repetir las instrucciones.",
5045
+ listenPlayingAlt: "Escuchar. Estas son las instrucciones.",
5046
+ printAudio: "Audio:",
5047
+ printTranscript: "Transcripción:",
5048
+ printKey: "(clave)"
5049
+ },
5050
+ multipleChoice: {
5051
+ minSelections: "Seleccione al menos {{minSelections}}.",
5052
+ maxSelections_one: "Sólo se permite {{maxSelections}} respuesta.",
5053
+ maxSelections_other: "Sólo se permiten {{maxSelections}} respuestas.",
5054
+ minmaxSelections_equal: "Seleccione {{minSelections}}.",
5055
+ minmaxSelections_range: "Seleccione entre {{minSelections}} y {{maxSelections}}."
5056
+ },
5057
+ selectText: {
5058
+ correctAnswerSelected: "Respuesta Correcta",
5059
+ correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
5060
+ incorrectSelection: "Selección Incorrecta",
5061
+ key: "Clave"
5062
+ },
5063
+ simpleCloze: {
5064
+ correctAnswerShown: "Respuesta correcta",
5065
+ correct: "Correcto",
5066
+ incorrect: "Incorrecto",
5067
+ unanswered: "Sin respuesta",
5068
+ placeholder: "Escribe tu respuesta...",
5069
+ answerInput: "Tu respuesta",
5070
+ printCorrectAnswer: "Respuesta correcta:",
5071
+ printAnswerBlank: "Espacio para la respuesta"
5072
+ },
5073
+ vennClassification: {
5074
+ tray: "Fichas para clasificar",
5075
+ unknownTarget: "desconocido",
5076
+ cancelled: "Cancelado",
5077
+ returnedToTray: "Se devolvió {{name}} a la bandeja",
5078
+ placedIn: "Se colocó {{name}} en {{target}}",
5079
+ pickedUp: "Se tomó {{name}}",
5080
+ pickedUpWithKeyboard: "Se tomó {{name}}, destino: {{target}}. Usa las flechas para elegir un destino, Enter para soltar y Escape para cancelar.",
5081
+ dropTarget: "Destino: {{target}}",
5082
+ unsupportedCircles_one: "No se puede mostrar este diagrama: tiene {{count}} círculo, y solo se admiten {{supported}}.",
5083
+ unsupportedCircles_other: "No se puede mostrar este diagrama: tiene {{count}} círculos, y solo se admiten {{supported}}.",
5084
+ setNumber: "Conjunto {{number}}",
5085
+ regionOnly: "Solo {{set}}",
5086
+ regionNeither: "Ni {{first}} ni {{second}}",
5087
+ regionNoneOf: "Ninguno de {{sets}}",
5088
+ regionAndSeparator: " y ",
5089
+ tileFallbackName: "Ficha",
5090
+ tileNotPlaced: "sin colocar",
5091
+ tileInRegion: "en {{region}}",
5092
+ tileCorrect: "correcta",
5093
+ tileIncorrect: "incorrecta"
5094
+ }
5095
+ },
5096
+ common: {
5097
+ undo: "Deshacer",
5098
+ clearAll: "Borrar todo",
5099
+ correct: "Correcto",
5100
+ incorrect: "Incorrecto",
5101
+ showCorrectAnswer: "Mostrar respuesta correcta",
5102
+ hideCorrectAnswer: "Ocultar respuesta correcta",
5103
+ showTeacherInstructions: "Mostrar instrucciones para el maestro",
5104
+ hideTeacherInstructions: "Ocultar instrucciones para el maestro",
5105
+ commonCorrectAnswerWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta más común para esta pregunta. También se definen una o más respuestas correctas adicionales, y también se reconocerán como correctas.",
5106
+ warning: "Advertencia",
5107
+ showNote: "Mostrar Nota",
5108
+ hideNote: "Ocultar Nota",
5109
+ cancel: "Cancelar"
5110
+ }
5111
+ };
5112
+ //#endregion
5113
+ //#region ../../../node_modules/.bun/i18next@25.10.10+1fb4c65d43e298b9/node_modules/i18next/dist/esm/i18next.js
5114
+ var isString = (obj) => typeof obj === "string";
5115
+ var defer = () => {
5116
+ let res;
5117
+ let rej;
5118
+ const promise = new Promise((resolve, reject) => {
5119
+ res = resolve;
5120
+ rej = reject;
5121
+ });
5122
+ promise.resolve = res;
5123
+ promise.reject = rej;
5124
+ return promise;
5125
+ };
5126
+ var makeString = (object) => {
5127
+ if (object == null) return "";
5128
+ return "" + object;
5129
+ };
5130
+ var copy = (a, s, t) => {
5131
+ a.forEach((m) => {
5132
+ if (s[m]) t[m] = s[m];
5133
+ });
5134
+ };
5135
+ var lastOfPathSeparatorRegExp = /###/g;
5136
+ var cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
5137
+ var canNotTraverseDeeper = (object) => !object || isString(object);
5138
+ var getLastOfPath = (object, path, Empty) => {
5139
+ const stack = !isString(path) ? path : path.split(".");
5140
+ let stackIndex = 0;
5141
+ while (stackIndex < stack.length - 1) {
5142
+ if (canNotTraverseDeeper(object)) return {};
5143
+ const key = cleanKey(stack[stackIndex]);
5144
+ if (!object[key] && Empty) object[key] = new Empty();
5145
+ if (Object.prototype.hasOwnProperty.call(object, key)) object = object[key];
5146
+ else object = {};
5147
+ ++stackIndex;
5148
+ }
5149
+ if (canNotTraverseDeeper(object)) return {};
5150
+ return {
5151
+ obj: object,
5152
+ k: cleanKey(stack[stackIndex])
5153
+ };
5154
+ };
5155
+ var setPath = (object, path, newValue) => {
5156
+ const { obj, k } = getLastOfPath(object, path, Object);
5157
+ if (obj !== void 0 || path.length === 1) {
5158
+ obj[k] = newValue;
5159
+ return;
5160
+ }
5161
+ let e = path[path.length - 1];
5162
+ let p = path.slice(0, path.length - 1);
5163
+ let last = getLastOfPath(object, p, Object);
5164
+ while (last.obj === void 0 && p.length) {
5165
+ e = `${p[p.length - 1]}.${e}`;
5166
+ p = p.slice(0, p.length - 1);
5167
+ last = getLastOfPath(object, p, Object);
5168
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") last.obj = void 0;
5169
+ }
5170
+ last.obj[`${last.k}.${e}`] = newValue;
5171
+ };
5172
+ var pushPath = (object, path, newValue, concat) => {
5173
+ const { obj, k } = getLastOfPath(object, path, Object);
5174
+ obj[k] = obj[k] || [];
5175
+ obj[k].push(newValue);
5176
+ };
5177
+ var getPath = (object, path) => {
5178
+ const { obj, k } = getLastOfPath(object, path);
5179
+ if (!obj) return void 0;
5180
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
5181
+ return obj[k];
5182
+ };
5183
+ var getPathWithDefaults = (data, defaultData, key) => {
5184
+ const value = getPath(data, key);
5185
+ if (value !== void 0) return value;
5186
+ return getPath(defaultData, key);
5187
+ };
5188
+ var deepExtend = (target, source, overwrite) => {
5189
+ for (const prop in source) if (prop !== "__proto__" && prop !== "constructor") if (prop in target) if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
5190
+ if (overwrite) target[prop] = source[prop];
5191
+ } else deepExtend(target[prop], source[prop], overwrite);
5192
+ else target[prop] = source[prop];
5193
+ return target;
5194
+ };
5195
+ var regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
5196
+ var _entityMap = {
5197
+ "&": "&amp;",
5198
+ "<": "&lt;",
5199
+ ">": "&gt;",
5200
+ "\"": "&quot;",
5201
+ "'": "&#39;",
5202
+ "/": "&#x2F;"
5203
+ };
5204
+ var escape = (data) => {
5205
+ if (isString(data)) return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
5206
+ return data;
5207
+ };
5208
+ var RegExpCache = class {
5209
+ constructor(capacity) {
5210
+ this.capacity = capacity;
5211
+ this.regExpMap = /* @__PURE__ */ new Map();
5212
+ this.regExpQueue = [];
5213
+ }
5214
+ getRegExp(pattern) {
5215
+ const regExpFromCache = this.regExpMap.get(pattern);
5216
+ if (regExpFromCache !== void 0) return regExpFromCache;
5217
+ const regExpNew = new RegExp(pattern);
5218
+ if (this.regExpQueue.length === this.capacity) this.regExpMap.delete(this.regExpQueue.shift());
5219
+ this.regExpMap.set(pattern, regExpNew);
5220
+ this.regExpQueue.push(pattern);
5221
+ return regExpNew;
5222
+ }
5223
+ };
5224
+ var chars = [
5225
+ " ",
5226
+ ",",
5227
+ "?",
5228
+ "!",
5229
+ ";"
5230
+ ];
5231
+ var looksLikeObjectPathRegExpCache = new RegExpCache(20);
5232
+ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
5233
+ nsSeparator = nsSeparator || "";
5234
+ keySeparator = keySeparator || "";
5235
+ const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
5236
+ if (possibleChars.length === 0) return true;
5237
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
5238
+ let matched = !r.test(key);
5239
+ if (!matched) {
5240
+ const ki = key.indexOf(keySeparator);
5241
+ if (ki > 0 && !r.test(key.substring(0, ki))) matched = true;
5242
+ }
5243
+ return matched;
5244
+ };
5245
+ var deepFind = (obj, path, keySeparator = ".") => {
5246
+ if (!obj) return void 0;
5247
+ if (obj[path]) {
5248
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
5249
+ return obj[path];
5250
+ }
5251
+ const tokens = path.split(keySeparator);
5252
+ let current = obj;
5253
+ for (let i = 0; i < tokens.length;) {
5254
+ if (!current || typeof current !== "object") return;
5255
+ let next;
5256
+ let nextPath = "";
5257
+ for (let j = i; j < tokens.length; ++j) {
5258
+ if (j !== i) nextPath += keySeparator;
5259
+ nextPath += tokens[j];
5260
+ next = current[nextPath];
5261
+ if (next !== void 0) {
5262
+ if ([
5263
+ "string",
5264
+ "number",
5265
+ "boolean"
5266
+ ].indexOf(typeof next) > -1 && j < tokens.length - 1) continue;
5267
+ i += j - i + 1;
5268
+ break;
5269
+ }
5270
+ }
5271
+ current = next;
5272
+ }
5273
+ return current;
5274
+ };
5275
+ var getCleanedCode = (code) => code?.replace(/_/g, "-");
5276
+ var consoleLogger = {
5277
+ type: "logger",
5278
+ log(args) {
5279
+ this.output("log", args);
5280
+ },
5281
+ warn(args) {
5282
+ this.output("warn", args);
5283
+ },
5284
+ error(args) {
5285
+ this.output("error", args);
5286
+ },
5287
+ output(type, args) {
5288
+ console?.[type]?.apply?.(console, args);
5289
+ }
5290
+ };
5291
+ var baseLogger = new class Logger {
5292
+ constructor(concreteLogger, options = {}) {
5293
+ this.init(concreteLogger, options);
5294
+ }
5295
+ init(concreteLogger, options = {}) {
5296
+ this.prefix = options.prefix || "i18next:";
5297
+ this.logger = concreteLogger || consoleLogger;
5298
+ this.options = options;
5299
+ this.debug = options.debug;
5300
+ }
5301
+ log(...args) {
5302
+ return this.forward(args, "log", "", true);
5303
+ }
5304
+ warn(...args) {
5305
+ return this.forward(args, "warn", "", true);
5306
+ }
5307
+ error(...args) {
5308
+ return this.forward(args, "error", "");
5309
+ }
5310
+ deprecate(...args) {
5311
+ return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
5312
+ }
5313
+ forward(args, lvl, prefix, debugOnly) {
5314
+ if (debugOnly && !this.debug) return null;
5315
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
5316
+ return this.logger[lvl](args);
5317
+ }
5318
+ create(moduleName) {
5319
+ return new Logger(this.logger, {
5320
+ prefix: `${this.prefix}:${moduleName}:`,
5321
+ ...this.options
5322
+ });
5323
+ }
5324
+ clone(options) {
5325
+ options = options || this.options;
5326
+ options.prefix = options.prefix || this.prefix;
5327
+ return new Logger(this.logger, options);
5328
+ }
5329
+ }();
5330
+ var EventEmitter = class {
5331
+ constructor() {
5332
+ this.observers = {};
5333
+ }
5334
+ on(events, listener) {
5335
+ events.split(" ").forEach((event) => {
5336
+ if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
5337
+ const numListeners = this.observers[event].get(listener) || 0;
5338
+ this.observers[event].set(listener, numListeners + 1);
5339
+ });
5340
+ return this;
5341
+ }
5342
+ off(event, listener) {
5343
+ if (!this.observers[event]) return;
5344
+ if (!listener) {
5345
+ delete this.observers[event];
5346
+ return;
5347
+ }
5348
+ this.observers[event].delete(listener);
5349
+ }
5350
+ emit(event, ...args) {
5351
+ if (this.observers[event]) Array.from(this.observers[event].entries()).forEach(([observer, numTimesAdded]) => {
5352
+ for (let i = 0; i < numTimesAdded; i++) observer(...args);
5353
+ });
5354
+ if (this.observers["*"]) Array.from(this.observers["*"].entries()).forEach(([observer, numTimesAdded]) => {
5355
+ for (let i = 0; i < numTimesAdded; i++) observer.apply(observer, [event, ...args]);
5356
+ });
5357
+ }
5358
+ };
5359
+ var ResourceStore = class extends EventEmitter {
5360
+ constructor(data, options = {
5361
+ ns: ["translation"],
5362
+ defaultNS: "translation"
5363
+ }) {
5364
+ super();
5365
+ this.data = data || {};
5366
+ this.options = options;
5367
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
5368
+ if (this.options.ignoreJSONStructure === void 0) this.options.ignoreJSONStructure = true;
5369
+ }
5370
+ addNamespaces(ns) {
5371
+ if (this.options.ns.indexOf(ns) < 0) this.options.ns.push(ns);
5372
+ }
5373
+ removeNamespaces(ns) {
5374
+ const index = this.options.ns.indexOf(ns);
5375
+ if (index > -1) this.options.ns.splice(index, 1);
5376
+ }
5377
+ getResource(lng, ns, key, options = {}) {
5378
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
5379
+ const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
5380
+ let path;
5381
+ if (lng.indexOf(".") > -1) path = lng.split(".");
5382
+ else {
5383
+ path = [lng, ns];
5384
+ if (key) if (Array.isArray(key)) path.push(...key);
5385
+ else if (isString(key) && keySeparator) path.push(...key.split(keySeparator));
5386
+ else path.push(key);
5387
+ }
5388
+ const result = getPath(this.data, path);
5389
+ if (!result && !ns && !key && lng.indexOf(".") > -1) {
5390
+ lng = path[0];
5391
+ ns = path[1];
5392
+ key = path.slice(2).join(".");
5393
+ }
5394
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
5395
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
5396
+ }
5397
+ addResource(lng, ns, key, value, options = { silent: false }) {
5398
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
5399
+ let path = [lng, ns];
5400
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
5401
+ if (lng.indexOf(".") > -1) {
5402
+ path = lng.split(".");
5403
+ value = ns;
5404
+ ns = path[1];
5405
+ }
5406
+ this.addNamespaces(ns);
5407
+ setPath(this.data, path, value);
5408
+ if (!options.silent) this.emit("added", lng, ns, key, value);
5409
+ }
5410
+ addResources(lng, ns, resources, options = { silent: false }) {
5411
+ for (const m in resources) if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], { silent: true });
5412
+ if (!options.silent) this.emit("added", lng, ns, resources);
5413
+ }
5414
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
5415
+ silent: false,
5416
+ skipCopy: false
5417
+ }) {
5418
+ let path = [lng, ns];
5419
+ if (lng.indexOf(".") > -1) {
5420
+ path = lng.split(".");
5421
+ deep = resources;
5422
+ resources = ns;
5423
+ ns = path[1];
5424
+ }
5425
+ this.addNamespaces(ns);
5426
+ let pack = getPath(this.data, path) || {};
5427
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
5428
+ if (deep) deepExtend(pack, resources, overwrite);
5429
+ else pack = {
5430
+ ...pack,
5431
+ ...resources
5432
+ };
5433
+ setPath(this.data, path, pack);
5434
+ if (!options.silent) this.emit("added", lng, ns, resources);
5435
+ }
5436
+ removeResourceBundle(lng, ns) {
5437
+ if (this.hasResourceBundle(lng, ns)) delete this.data[lng][ns];
5438
+ this.removeNamespaces(ns);
5439
+ this.emit("removed", lng, ns);
5440
+ }
5441
+ hasResourceBundle(lng, ns) {
5442
+ return this.getResource(lng, ns) !== void 0;
5443
+ }
5444
+ getResourceBundle(lng, ns) {
5445
+ if (!ns) ns = this.options.defaultNS;
5446
+ return this.getResource(lng, ns);
5447
+ }
5448
+ getDataByLanguage(lng) {
5449
+ return this.data[lng];
5450
+ }
5451
+ hasLanguageSomeTranslations(lng) {
5452
+ const data = this.getDataByLanguage(lng);
5453
+ return !!(data && Object.keys(data) || []).find((v) => data[v] && Object.keys(data[v]).length > 0);
5454
+ }
5455
+ toJSON() {
5456
+ return this.data;
5457
+ }
5458
+ };
5459
+ var postProcessor = {
5460
+ processors: {},
5461
+ addPostProcessor(module) {
5462
+ this.processors[module.name] = module;
5463
+ },
5464
+ handle(processors, value, key, options, translator) {
5465
+ processors.forEach((processor) => {
5466
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
5467
+ });
5468
+ return value;
5469
+ }
5470
+ };
5471
+ var PATH_KEY = Symbol("i18next/PATH_KEY");
5472
+ function createProxy() {
5473
+ const state = [];
5474
+ const handler = Object.create(null);
5475
+ let proxy;
5476
+ handler.get = (target, key) => {
5477
+ proxy?.revoke?.();
5478
+ if (key === PATH_KEY) return state;
5479
+ state.push(key);
5480
+ proxy = Proxy.revocable(target, handler);
5481
+ return proxy.proxy;
5482
+ };
5483
+ return Proxy.revocable(Object.create(null), handler).proxy;
5484
+ }
5485
+ function keysFromSelector(selector, opts) {
5486
+ const { [PATH_KEY]: path } = selector(createProxy());
5487
+ const keySeparator = opts?.keySeparator ?? ".";
5488
+ const nsSeparator = opts?.nsSeparator ?? ":";
5489
+ if (path.length > 1 && nsSeparator) {
5490
+ const ns = opts?.ns;
5491
+ const nsArray = Array.isArray(ns) ? ns : null;
5492
+ if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
5493
+ }
5494
+ return path.join(keySeparator);
5495
+ }
5496
+ var checkedLoadedFor = {};
5497
+ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
5498
+ var Translator = class Translator extends EventEmitter {
5499
+ constructor(services, options = {}) {
5500
+ super();
5501
+ copy([
5502
+ "resourceStore",
5503
+ "languageUtils",
5504
+ "pluralResolver",
5505
+ "interpolator",
5506
+ "backendConnector",
5507
+ "i18nFormat",
5508
+ "utils"
5509
+ ], services, this);
5510
+ this.options = options;
5511
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
5512
+ this.logger = baseLogger.create("translator");
5513
+ }
5514
+ changeLanguage(lng) {
5515
+ if (lng) this.language = lng;
5516
+ }
5517
+ exists(key, o = { interpolation: {} }) {
5518
+ const opt = { ...o };
5519
+ if (key == null) return false;
5520
+ const resolved = this.resolve(key, opt);
5521
+ if (resolved?.res === void 0) return false;
5522
+ const isObject = shouldHandleAsObject(resolved.res);
5523
+ if (opt.returnObjects === false && isObject) return false;
5524
+ return true;
5525
+ }
5526
+ extractFromKey(key, opt) {
5527
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
5528
+ if (nsSeparator === void 0) nsSeparator = ":";
5529
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
5530
+ let namespaces = opt.ns || this.options.defaultNS || [];
5531
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
5532
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
5533
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
5534
+ const m = key.match(this.interpolator.nestingRegexp);
5535
+ if (m && m.length > 0) return {
5536
+ key,
5537
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
5538
+ };
5539
+ const parts = key.split(nsSeparator);
5540
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
5541
+ key = parts.join(keySeparator);
5542
+ }
5543
+ return {
5544
+ key,
5545
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
5546
+ };
5547
+ }
5548
+ translate(keys, o, lastKey) {
5549
+ let opt = typeof o === "object" ? { ...o } : o;
5550
+ if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) opt = this.options.overloadTranslationOptionHandler(arguments);
5551
+ if (typeof opt === "object") opt = { ...opt };
5552
+ if (!opt) opt = {};
5553
+ if (keys == null) return "";
5554
+ if (typeof keys === "function") keys = keysFromSelector(keys, {
5555
+ ...this.options,
5556
+ ...opt
5557
+ });
5558
+ if (!Array.isArray(keys)) keys = [String(keys)];
5559
+ keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
5560
+ ...this.options,
5561
+ ...opt
5562
+ }) : String(k));
5563
+ const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
5564
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
5565
+ const { key, namespaces } = this.extractFromKey(keys[keys.length - 1], opt);
5566
+ const namespace = namespaces[namespaces.length - 1];
5567
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
5568
+ if (nsSeparator === void 0) nsSeparator = ":";
5569
+ const lng = opt.lng || this.language;
5570
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
5571
+ if (lng?.toLowerCase() === "cimode") {
5572
+ if (appendNamespaceToCIMode) {
5573
+ if (returnDetails) return {
5574
+ res: `${namespace}${nsSeparator}${key}`,
5575
+ usedKey: key,
5576
+ exactUsedKey: key,
5577
+ usedLng: lng,
5578
+ usedNS: namespace,
5579
+ usedParams: this.getUsedParamsDetails(opt)
5580
+ };
5581
+ return `${namespace}${nsSeparator}${key}`;
5582
+ }
5583
+ if (returnDetails) return {
5584
+ res: key,
5585
+ usedKey: key,
5586
+ exactUsedKey: key,
5587
+ usedLng: lng,
5588
+ usedNS: namespace,
5589
+ usedParams: this.getUsedParamsDetails(opt)
5590
+ };
5591
+ return key;
5592
+ }
5593
+ const resolved = this.resolve(keys, opt);
5594
+ let res = resolved?.res;
5595
+ const resUsedKey = resolved?.usedKey || key;
5596
+ const resExactUsedKey = resolved?.exactUsedKey || key;
5597
+ const noObject = [
5598
+ "[object Number]",
5599
+ "[object Function]",
5600
+ "[object RegExp]"
5601
+ ];
5602
+ const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
5603
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
5604
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
5605
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
5606
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
5607
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, { ordinal: false }) : "";
5608
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
5609
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
5610
+ let resForObjHndl = res;
5611
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) resForObjHndl = defaultValue;
5612
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
5613
+ const resType = Object.prototype.toString.apply(resForObjHndl);
5614
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
5615
+ if (!opt.returnObjects && !this.options.returnObjects) {
5616
+ if (!this.options.returnedObjectHandler) this.logger.warn("accessing an object - but returnObjects options is not enabled!");
5617
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
5618
+ ...opt,
5619
+ ns: namespaces
5620
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
5621
+ if (returnDetails) {
5622
+ resolved.res = r;
5623
+ resolved.usedParams = this.getUsedParamsDetails(opt);
5624
+ return resolved;
5625
+ }
5626
+ return r;
5627
+ }
5628
+ if (keySeparator) {
5629
+ const resTypeIsArray = Array.isArray(resForObjHndl);
5630
+ const copy = resTypeIsArray ? [] : {};
5631
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
5632
+ for (const m in resForObjHndl) if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
5633
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
5634
+ if (hasDefaultValue && !res) copy[m] = this.translate(deepKey, {
5635
+ ...opt,
5636
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
5637
+ joinArrays: false,
5638
+ ns: namespaces
5639
+ });
5640
+ else copy[m] = this.translate(deepKey, {
5641
+ ...opt,
5642
+ joinArrays: false,
5643
+ ns: namespaces
5644
+ });
5645
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
5646
+ }
5647
+ res = copy;
5648
+ }
5649
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
5650
+ res = res.join(joinArrays);
5651
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
5652
+ } else {
5653
+ let usedDefault = false;
5654
+ let usedKey = false;
5655
+ if (!this.isValidLookup(res) && hasDefaultValue) {
5656
+ usedDefault = true;
5657
+ res = defaultValue;
5658
+ }
5659
+ if (!this.isValidLookup(res)) {
5660
+ usedKey = true;
5661
+ res = key;
5662
+ }
5663
+ const resForMissing = (opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && usedKey ? void 0 : res;
5664
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
5665
+ if (usedKey || usedDefault || updateMissing) {
5666
+ this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
5667
+ if (keySeparator) {
5668
+ const fk = this.resolve(key, {
5669
+ ...opt,
5670
+ keySeparator: false
5671
+ });
5672
+ if (fk && fk.res) this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.");
5673
+ }
5674
+ let lngs = [];
5675
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
5676
+ if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) for (let i = 0; i < fallbackLngs.length; i++) lngs.push(fallbackLngs[i]);
5677
+ else if (this.options.saveMissingTo === "all") lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
5678
+ else lngs.push(opt.lng || this.language);
5679
+ const send = (l, k, specificDefaultValue) => {
5680
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
5681
+ if (this.options.missingKeyHandler) this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
5682
+ else if (this.backendConnector?.saveMissing) this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
5683
+ this.emit("missingKey", l, namespace, k, res);
5684
+ };
5685
+ if (this.options.saveMissing) if (this.options.saveMissingPlurals && needsPluralHandling) lngs.forEach((language) => {
5686
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
5687
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) suffixes.push(`${this.options.pluralSeparator}zero`);
5688
+ suffixes.forEach((suffix) => {
5689
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
5690
+ });
5691
+ });
5692
+ else send(lngs, key, defaultValue);
5693
+ }
5694
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
5695
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}${nsSeparator}${key}`;
5696
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
5697
+ }
5698
+ if (returnDetails) {
5699
+ resolved.res = res;
5700
+ resolved.usedParams = this.getUsedParamsDetails(opt);
5701
+ return resolved;
5702
+ }
5703
+ return res;
5704
+ }
5705
+ extendTranslation(res, key, opt, resolved, lastKey) {
5706
+ if (this.i18nFormat?.parse) res = this.i18nFormat.parse(res, {
5707
+ ...this.options.interpolation.defaultVariables,
5708
+ ...opt
5709
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, { resolved });
5710
+ else if (!opt.skipInterpolation) {
5711
+ if (opt.interpolation) this.interpolator.init({
5712
+ ...opt,
5713
+ interpolation: {
5714
+ ...this.options.interpolation,
5715
+ ...opt.interpolation
5716
+ }
5717
+ });
5718
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
5719
+ let nestBef;
5720
+ if (skipOnVariables) {
5721
+ const nb = res.match(this.interpolator.nestingRegexp);
5722
+ nestBef = nb && nb.length;
5723
+ }
5724
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
5725
+ if (this.options.interpolation.defaultVariables) data = {
5726
+ ...this.options.interpolation.defaultVariables,
5727
+ ...data
5728
+ };
5729
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
5730
+ if (skipOnVariables) {
5731
+ const na = res.match(this.interpolator.nestingRegexp);
5732
+ const nestAft = na && na.length;
5733
+ if (nestBef < nestAft) opt.nest = false;
5734
+ }
5735
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
5736
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
5737
+ if (lastKey?.[0] === args[0] && !opt.context) {
5738
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
5739
+ return null;
5740
+ }
5741
+ return this.translate(...args, key);
5742
+ }, opt);
5743
+ if (opt.interpolation) this.interpolator.reset();
5744
+ }
5745
+ const postProcess = opt.postProcess || this.options.postProcess;
5746
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
5747
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
5748
+ i18nResolved: {
5749
+ ...resolved,
5750
+ usedParams: this.getUsedParamsDetails(opt)
5751
+ },
5752
+ ...opt
5753
+ } : opt, this);
5754
+ return res;
5755
+ }
5756
+ resolve(keys, opt = {}) {
5757
+ let found;
5758
+ let usedKey;
5759
+ let exactUsedKey;
5760
+ let usedLng;
5761
+ let usedNS;
5762
+ if (isString(keys)) keys = [keys];
5763
+ if (Array.isArray(keys)) keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
5764
+ ...this.options,
5765
+ ...opt
5766
+ }) : k);
5767
+ keys.forEach((k) => {
5768
+ if (this.isValidLookup(found)) return;
5769
+ const extracted = this.extractFromKey(k, opt);
5770
+ const key = extracted.key;
5771
+ usedKey = key;
5772
+ let namespaces = extracted.namespaces;
5773
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
5774
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
5775
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
5776
+ const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
5777
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
5778
+ namespaces.forEach((ns) => {
5779
+ if (this.isValidLookup(found)) return;
5780
+ usedNS = ns;
5781
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
5782
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
5783
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
5784
+ }
5785
+ codes.forEach((code) => {
5786
+ if (this.isValidLookup(found)) return;
5787
+ usedLng = code;
5788
+ const finalKeys = [key];
5789
+ if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
5790
+ else {
5791
+ let pluralSuffix;
5792
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
5793
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
5794
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
5795
+ if (needsPluralHandling) {
5796
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
5797
+ finalKeys.push(key + pluralSuffix);
5798
+ if (needsZeroSuffixLookup) finalKeys.push(key + zeroSuffix);
5799
+ }
5800
+ if (needsContextHandling) {
5801
+ const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
5802
+ finalKeys.push(contextKey);
5803
+ if (needsPluralHandling) {
5804
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
5805
+ finalKeys.push(contextKey + pluralSuffix);
5806
+ if (needsZeroSuffixLookup) finalKeys.push(contextKey + zeroSuffix);
5807
+ }
5808
+ }
5809
+ }
5810
+ let possibleKey;
5811
+ while (possibleKey = finalKeys.pop()) if (!this.isValidLookup(found)) {
5812
+ exactUsedKey = possibleKey;
5813
+ found = this.getResource(code, ns, possibleKey, opt);
5814
+ }
5815
+ });
5816
+ });
5817
+ });
5818
+ return {
5819
+ res: found,
5820
+ usedKey,
5821
+ exactUsedKey,
5822
+ usedLng,
5823
+ usedNS
5824
+ };
5825
+ }
5826
+ isValidLookup(res) {
5827
+ return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
5828
+ }
5829
+ getResource(code, ns, key, options = {}) {
5830
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
5831
+ return this.resourceStore.getResource(code, ns, key, options);
5832
+ }
5833
+ getUsedParamsDetails(options = {}) {
5834
+ const optionsKeys = [
5835
+ "defaultValue",
5836
+ "ordinal",
5837
+ "context",
5838
+ "replace",
5839
+ "lng",
5840
+ "lngs",
5841
+ "fallbackLng",
5842
+ "ns",
5843
+ "keySeparator",
5844
+ "nsSeparator",
5845
+ "returnObjects",
5846
+ "returnDetails",
5847
+ "joinArrays",
5848
+ "postProcess",
5849
+ "interpolation"
5850
+ ];
5851
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
5852
+ let data = useOptionsReplaceForData ? options.replace : options;
5853
+ if (useOptionsReplaceForData && typeof options.count !== "undefined") data.count = options.count;
5854
+ if (this.options.interpolation.defaultVariables) data = {
5855
+ ...this.options.interpolation.defaultVariables,
5856
+ ...data
5857
+ };
5858
+ if (!useOptionsReplaceForData) {
5859
+ data = { ...data };
5860
+ for (const key of optionsKeys) delete data[key];
5861
+ }
5862
+ return data;
5863
+ }
5864
+ static hasDefaultValue(options) {
5865
+ const prefix = "defaultValue";
5866
+ for (const option in options) if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, 12) && void 0 !== options[option]) return true;
5867
+ return false;
5868
+ }
5869
+ };
5870
+ var LanguageUtil = class {
5871
+ constructor(options) {
5872
+ this.options = options;
5873
+ this.supportedLngs = this.options.supportedLngs || false;
5874
+ this.logger = baseLogger.create("languageUtils");
5875
+ }
5876
+ getScriptPartFromCode(code) {
5877
+ code = getCleanedCode(code);
5878
+ if (!code || code.indexOf("-") < 0) return null;
5879
+ const p = code.split("-");
5880
+ if (p.length === 2) return null;
5881
+ p.pop();
5882
+ if (p[p.length - 1].toLowerCase() === "x") return null;
5883
+ return this.formatLanguageCode(p.join("-"));
5884
+ }
5885
+ getLanguagePartFromCode(code) {
5886
+ code = getCleanedCode(code);
5887
+ if (!code || code.indexOf("-") < 0) return code;
5888
+ const p = code.split("-");
5889
+ return this.formatLanguageCode(p[0]);
5890
+ }
5891
+ formatLanguageCode(code) {
5892
+ if (isString(code) && code.indexOf("-") > -1) {
5893
+ let formattedCode;
5894
+ try {
5895
+ formattedCode = Intl.getCanonicalLocales(code)[0];
5896
+ } catch (e) {}
5897
+ if (formattedCode && this.options.lowerCaseLng) formattedCode = formattedCode.toLowerCase();
5898
+ if (formattedCode) return formattedCode;
5899
+ if (this.options.lowerCaseLng) return code.toLowerCase();
5900
+ return code;
5901
+ }
5902
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
5903
+ }
5904
+ isSupportedCode(code) {
5905
+ if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) code = this.getLanguagePartFromCode(code);
5906
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
5907
+ }
5908
+ getBestMatchFromCodes(codes) {
5909
+ if (!codes) return null;
5910
+ let found;
5911
+ codes.forEach((code) => {
5912
+ if (found) return;
5913
+ const cleanedLng = this.formatLanguageCode(code);
5914
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
5915
+ });
5916
+ if (!found && this.options.supportedLngs) codes.forEach((code) => {
5917
+ if (found) return;
5918
+ const lngScOnly = this.getScriptPartFromCode(code);
5919
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
5920
+ const lngOnly = this.getLanguagePartFromCode(code);
5921
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
5922
+ found = this.options.supportedLngs.find((supportedLng) => {
5923
+ if (supportedLng === lngOnly) return supportedLng;
5924
+ if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
5925
+ if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
5926
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
5927
+ });
5928
+ });
5929
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
5930
+ return found;
5931
+ }
5932
+ getFallbackCodes(fallbacks, code) {
5933
+ if (!fallbacks) return [];
5934
+ if (typeof fallbacks === "function") fallbacks = fallbacks(code);
5935
+ if (isString(fallbacks)) fallbacks = [fallbacks];
5936
+ if (Array.isArray(fallbacks)) return fallbacks;
5937
+ if (!code) return fallbacks.default || [];
5938
+ let found = fallbacks[code];
5939
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
5940
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
5941
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
5942
+ if (!found) found = fallbacks.default;
5943
+ return found || [];
5944
+ }
5945
+ toResolveHierarchy(code, fallbackCode) {
5946
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
5947
+ const codes = [];
5948
+ const addCode = (c) => {
5949
+ if (!c) return;
5950
+ if (this.isSupportedCode(c)) codes.push(c);
5951
+ else this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
5952
+ };
5953
+ if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
5954
+ if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
5955
+ if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
5956
+ if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
5957
+ } else if (isString(code)) addCode(this.formatLanguageCode(code));
5958
+ fallbackCodes.forEach((fc) => {
5959
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
5960
+ });
5961
+ return codes;
5962
+ }
5963
+ };
5964
+ var suffixesOrder = {
5965
+ zero: 0,
5966
+ one: 1,
5967
+ two: 2,
5968
+ few: 3,
5969
+ many: 4,
5970
+ other: 5
5971
+ };
5972
+ var dummyRule = {
5973
+ select: (count) => count === 1 ? "one" : "other",
5974
+ resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
5975
+ };
5976
+ var PluralResolver = class {
5977
+ constructor(languageUtils, options = {}) {
5978
+ this.languageUtils = languageUtils;
5979
+ this.options = options;
5980
+ this.logger = baseLogger.create("pluralResolver");
5981
+ this.pluralRulesCache = {};
5982
+ }
5983
+ clearCache() {
5984
+ this.pluralRulesCache = {};
5985
+ }
5986
+ getRule(code, options = {}) {
5987
+ const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
5988
+ const type = options.ordinal ? "ordinal" : "cardinal";
5989
+ const cacheKey = JSON.stringify({
5990
+ cleanedCode,
5991
+ type
5992
+ });
5993
+ if (cacheKey in this.pluralRulesCache) return this.pluralRulesCache[cacheKey];
5994
+ let rule;
5995
+ try {
5996
+ rule = new Intl.PluralRules(cleanedCode, { type });
5997
+ } catch (err) {
5998
+ if (typeof Intl === "undefined") {
5999
+ this.logger.error("No Intl support, please use an Intl polyfill!");
6000
+ return dummyRule;
6001
+ }
6002
+ if (!code.match(/-|_/)) return dummyRule;
6003
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
6004
+ rule = this.getRule(lngPart, options);
6005
+ }
6006
+ this.pluralRulesCache[cacheKey] = rule;
6007
+ return rule;
6008
+ }
6009
+ needsPlural(code, options = {}) {
6010
+ let rule = this.getRule(code, options);
6011
+ if (!rule) rule = this.getRule("dev", options);
6012
+ return rule?.resolvedOptions().pluralCategories.length > 1;
6013
+ }
6014
+ getPluralFormsOfKey(code, key, options = {}) {
6015
+ return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
6016
+ }
6017
+ getSuffixes(code, options = {}) {
6018
+ let rule = this.getRule(code, options);
6019
+ if (!rule) rule = this.getRule("dev", options);
6020
+ if (!rule) return [];
6021
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
6022
+ }
6023
+ getSuffix(code, count, options = {}) {
6024
+ const rule = this.getRule(code, options);
6025
+ if (rule) return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
6026
+ this.logger.warn(`no plural rule found for: ${code}`);
6027
+ return this.getSuffix("dev", count, options);
6028
+ }
6029
+ };
6030
+ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
6031
+ let path = getPathWithDefaults(data, defaultData, key);
6032
+ if (!path && ignoreJSONStructure && isString(key)) {
6033
+ path = deepFind(data, key, keySeparator);
6034
+ if (path === void 0) path = deepFind(defaultData, key, keySeparator);
6035
+ }
6036
+ return path;
6037
+ };
6038
+ var regexSafe = (val) => val.replace(/\$/g, "$$$$");
6039
+ var Interpolator = class {
6040
+ constructor(options = {}) {
6041
+ this.logger = baseLogger.create("interpolator");
6042
+ this.options = options;
6043
+ this.format = options?.interpolation?.format || ((value) => value);
6044
+ this.init(options);
6045
+ }
6046
+ init(options = {}) {
6047
+ if (!options.interpolation) options.interpolation = { escapeValue: true };
6048
+ const { escape: escape$1, escapeValue, useRawValueToEscape, prefix, prefixEscaped, suffix, suffixEscaped, formatSeparator, unescapeSuffix, unescapePrefix, nestingPrefix, nestingPrefixEscaped, nestingSuffix, nestingSuffixEscaped, nestingOptionsSeparator, maxReplaces, alwaysFormat } = options.interpolation;
6049
+ this.escape = escape$1 !== void 0 ? escape$1 : escape;
6050
+ this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
6051
+ this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
6052
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
6053
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
6054
+ this.formatSeparator = formatSeparator || ",";
6055
+ this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
6056
+ this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
6057
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
6058
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
6059
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
6060
+ this.maxReplaces = maxReplaces || 1e3;
6061
+ this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
6062
+ this.resetRegExp();
6063
+ }
6064
+ reset() {
6065
+ if (this.options) this.init(this.options);
6066
+ }
6067
+ resetRegExp() {
6068
+ const getOrResetRegExp = (existingRegExp, pattern) => {
6069
+ if (existingRegExp?.source === pattern) {
6070
+ existingRegExp.lastIndex = 0;
6071
+ return existingRegExp;
6072
+ }
6073
+ return new RegExp(pattern, "g");
6074
+ };
6075
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
6076
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
6077
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
6078
+ }
6079
+ interpolate(str, data, lng, options) {
6080
+ let match;
6081
+ let value;
6082
+ let replaces;
6083
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
6084
+ const handleFormat = (key) => {
6085
+ if (key.indexOf(this.formatSeparator) < 0) {
6086
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
6087
+ return this.alwaysFormat ? this.format(path, void 0, lng, {
6088
+ ...options,
6089
+ ...data,
6090
+ interpolationkey: key
6091
+ }) : path;
6092
+ }
6093
+ const p = key.split(this.formatSeparator);
6094
+ const k = p.shift().trim();
6095
+ const f = p.join(this.formatSeparator).trim();
6096
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
6097
+ ...options,
6098
+ ...data,
6099
+ interpolationkey: k
6100
+ });
6101
+ };
6102
+ this.resetRegExp();
6103
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
6104
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
6105
+ [{
6106
+ regex: this.regexpUnescape,
6107
+ safeValue: (val) => regexSafe(val)
6108
+ }, {
6109
+ regex: this.regexp,
6110
+ safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
6111
+ }].forEach((todo) => {
6112
+ replaces = 0;
6113
+ while (match = todo.regex.exec(str)) {
6114
+ const matchedVar = match[1].trim();
6115
+ value = handleFormat(matchedVar);
6116
+ if (value === void 0) if (typeof missingInterpolationHandler === "function") {
6117
+ const temp = missingInterpolationHandler(str, match, options);
6118
+ value = isString(temp) ? temp : "";
6119
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) value = "";
6120
+ else if (skipOnVariables) {
6121
+ value = match[0];
6122
+ continue;
6123
+ } else {
6124
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
6125
+ value = "";
6126
+ }
6127
+ else if (!isString(value) && !this.useRawValueToEscape) value = makeString(value);
6128
+ const safeValue = todo.safeValue(value);
6129
+ str = str.replace(match[0], safeValue);
6130
+ if (skipOnVariables) {
6131
+ todo.regex.lastIndex += value.length;
6132
+ todo.regex.lastIndex -= match[0].length;
6133
+ } else todo.regex.lastIndex = 0;
6134
+ replaces++;
6135
+ if (replaces >= this.maxReplaces) break;
6136
+ }
6137
+ });
6138
+ return str;
6139
+ }
6140
+ nest(str, fc, options = {}) {
6141
+ let match;
6142
+ let value;
6143
+ let clonedOptions;
6144
+ const handleHasOptions = (key, inheritedOptions) => {
6145
+ const sep = this.nestingOptionsSeparator;
6146
+ if (key.indexOf(sep) < 0) return key;
6147
+ const c = key.split(new RegExp(`${regexEscape(sep)}[ ]*{`));
6148
+ let optionsString = `{${c[1]}`;
6149
+ key = c[0];
6150
+ optionsString = this.interpolate(optionsString, clonedOptions);
6151
+ const matchedSingleQuotes = optionsString.match(/'/g);
6152
+ const matchedDoubleQuotes = optionsString.match(/"/g);
6153
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || (matchedDoubleQuotes?.length ?? 0) % 2 !== 0) optionsString = optionsString.replace(/'/g, "\"");
6154
+ try {
6155
+ clonedOptions = JSON.parse(optionsString);
6156
+ if (inheritedOptions) clonedOptions = {
6157
+ ...inheritedOptions,
6158
+ ...clonedOptions
6159
+ };
6160
+ } catch (e) {
6161
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
6162
+ return `${key}${sep}${optionsString}`;
6163
+ }
6164
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
6165
+ return key;
6166
+ };
6167
+ while (match = this.nestingRegexp.exec(str)) {
6168
+ let formatters = [];
6169
+ clonedOptions = { ...options };
6170
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
6171
+ clonedOptions.applyPostProcessor = false;
6172
+ delete clonedOptions.defaultValue;
6173
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
6174
+ if (keyEndIndex !== -1) {
6175
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
6176
+ match[1] = match[1].slice(0, keyEndIndex);
6177
+ }
6178
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
6179
+ if (value && match[0] === str && !isString(value)) return value;
6180
+ if (!isString(value)) value = makeString(value);
6181
+ if (!value) {
6182
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
6183
+ value = "";
6184
+ }
6185
+ if (formatters.length) value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
6186
+ ...options,
6187
+ interpolationkey: match[1].trim()
6188
+ }), value.trim());
6189
+ str = str.replace(match[0], value);
6190
+ this.regexp.lastIndex = 0;
6191
+ }
6192
+ return str;
6193
+ }
6194
+ };
6195
+ var parseFormatStr = (formatStr) => {
6196
+ let formatName = formatStr.toLowerCase().trim();
6197
+ const formatOptions = {};
6198
+ if (formatStr.indexOf("(") > -1) {
6199
+ const p = formatStr.split("(");
6200
+ formatName = p[0].toLowerCase().trim();
6201
+ const optStr = p[1].substring(0, p[1].length - 1);
6202
+ if (formatName === "currency" && optStr.indexOf(":") < 0) {
6203
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
6204
+ } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
6205
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
6206
+ } else optStr.split(";").forEach((opt) => {
6207
+ if (opt) {
6208
+ const [key, ...rest] = opt.split(":");
6209
+ const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
6210
+ const trimmedKey = key.trim();
6211
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
6212
+ if (val === "false") formatOptions[trimmedKey] = false;
6213
+ if (val === "true") formatOptions[trimmedKey] = true;
6214
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
6215
+ }
6216
+ });
6217
+ }
6218
+ return {
6219
+ formatName,
6220
+ formatOptions
6221
+ };
6222
+ };
6223
+ var createCachedFormatter = (fn) => {
6224
+ const cache = {};
6225
+ return (v, l, o) => {
6226
+ let optForCache = o;
6227
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) optForCache = {
6228
+ ...optForCache,
6229
+ [o.interpolationkey]: void 0
6230
+ };
6231
+ const key = l + JSON.stringify(optForCache);
6232
+ let frm = cache[key];
6233
+ if (!frm) {
6234
+ frm = fn(getCleanedCode(l), o);
6235
+ cache[key] = frm;
6236
+ }
6237
+ return frm(v);
6238
+ };
6239
+ };
6240
+ var createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
6241
+ var Formatter = class {
6242
+ constructor(options = {}) {
6243
+ this.logger = baseLogger.create("formatter");
6244
+ this.options = options;
6245
+ this.init(options);
6246
+ }
6247
+ init(services, options = { interpolation: {} }) {
6248
+ this.formatSeparator = options.interpolation.formatSeparator || ",";
6249
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
6250
+ this.formats = {
6251
+ number: cf((lng, opt) => {
6252
+ const formatter = new Intl.NumberFormat(lng, { ...opt });
6253
+ return (val) => formatter.format(val);
6254
+ }),
6255
+ currency: cf((lng, opt) => {
6256
+ const formatter = new Intl.NumberFormat(lng, {
6257
+ ...opt,
6258
+ style: "currency"
6259
+ });
6260
+ return (val) => formatter.format(val);
6261
+ }),
6262
+ datetime: cf((lng, opt) => {
6263
+ const formatter = new Intl.DateTimeFormat(lng, { ...opt });
6264
+ return (val) => formatter.format(val);
6265
+ }),
6266
+ relativetime: cf((lng, opt) => {
6267
+ const formatter = new Intl.RelativeTimeFormat(lng, { ...opt });
6268
+ return (val) => formatter.format(val, opt.range || "day");
6269
+ }),
6270
+ list: cf((lng, opt) => {
6271
+ const formatter = new Intl.ListFormat(lng, { ...opt });
6272
+ return (val) => formatter.format(val);
6273
+ })
6274
+ };
6275
+ }
6276
+ add(name, fc) {
6277
+ this.formats[name.toLowerCase().trim()] = fc;
6278
+ }
6279
+ addCached(name, fc) {
6280
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
6281
+ }
6282
+ format(value, format, lng, options = {}) {
6283
+ const formats = format.split(this.formatSeparator);
6284
+ if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
6285
+ const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
6286
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
6287
+ }
6288
+ return formats.reduce((mem, f) => {
6289
+ const { formatName, formatOptions } = parseFormatStr(f);
6290
+ if (this.formats[formatName]) {
6291
+ let formatted = mem;
6292
+ try {
6293
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
6294
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
6295
+ formatted = this.formats[formatName](mem, l, {
6296
+ ...formatOptions,
6297
+ ...options,
6298
+ ...valOptions
6299
+ });
6300
+ } catch (error) {
6301
+ this.logger.warn(error);
6302
+ }
6303
+ return formatted;
6304
+ } else this.logger.warn(`there was no format function for ${formatName}`);
6305
+ return mem;
6306
+ }, value);
6307
+ }
6308
+ };
6309
+ var removePending = (q, name) => {
6310
+ if (q.pending[name] !== void 0) {
6311
+ delete q.pending[name];
6312
+ q.pendingCount--;
6313
+ }
6314
+ };
6315
+ var Connector = class extends EventEmitter {
6316
+ constructor(backend, store, services, options = {}) {
6317
+ super();
6318
+ this.backend = backend;
6319
+ this.store = store;
6320
+ this.services = services;
6321
+ this.languageUtils = services.languageUtils;
6322
+ this.options = options;
6323
+ this.logger = baseLogger.create("backendConnector");
6324
+ this.waitingReads = [];
6325
+ this.maxParallelReads = options.maxParallelReads || 10;
6326
+ this.readingCalls = 0;
6327
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
6328
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
6329
+ this.state = {};
6330
+ this.queue = [];
6331
+ this.backend?.init?.(services, options.backend, options);
6332
+ }
6333
+ queueLoad(languages, namespaces, options, callback) {
6334
+ const toLoad = {};
6335
+ const pending = {};
6336
+ const toLoadLanguages = {};
6337
+ const toLoadNamespaces = {};
6338
+ languages.forEach((lng) => {
6339
+ let hasAllNamespaces = true;
6340
+ namespaces.forEach((ns) => {
6341
+ const name = `${lng}|${ns}`;
6342
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) this.state[name] = 2;
6343
+ else if (this.state[name] < 0);
6344
+ else if (this.state[name] === 1) {
6345
+ if (pending[name] === void 0) pending[name] = true;
6346
+ } else {
6347
+ this.state[name] = 1;
6348
+ hasAllNamespaces = false;
6349
+ if (pending[name] === void 0) pending[name] = true;
6350
+ if (toLoad[name] === void 0) toLoad[name] = true;
6351
+ if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
6352
+ }
6353
+ });
6354
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
6355
+ });
6356
+ if (Object.keys(toLoad).length || Object.keys(pending).length) this.queue.push({
6357
+ pending,
6358
+ pendingCount: Object.keys(pending).length,
6359
+ loaded: {},
6360
+ errors: [],
6361
+ callback
6362
+ });
6363
+ return {
6364
+ toLoad: Object.keys(toLoad),
6365
+ pending: Object.keys(pending),
6366
+ toLoadLanguages: Object.keys(toLoadLanguages),
6367
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
6368
+ };
6369
+ }
6370
+ loaded(name, err, data) {
6371
+ const s = name.split("|");
6372
+ const lng = s[0];
6373
+ const ns = s[1];
6374
+ if (err) this.emit("failedLoading", lng, ns, err);
6375
+ if (!err && data) this.store.addResourceBundle(lng, ns, data, void 0, void 0, { skipCopy: true });
6376
+ this.state[name] = err ? -1 : 2;
6377
+ if (err && data) this.state[name] = 0;
6378
+ const loaded = {};
6379
+ this.queue.forEach((q) => {
6380
+ pushPath(q.loaded, [lng], ns);
6381
+ removePending(q, name);
6382
+ if (err) q.errors.push(err);
6383
+ if (q.pendingCount === 0 && !q.done) {
6384
+ Object.keys(q.loaded).forEach((l) => {
6385
+ if (!loaded[l]) loaded[l] = {};
6386
+ const loadedKeys = q.loaded[l];
6387
+ if (loadedKeys.length) loadedKeys.forEach((n) => {
6388
+ if (loaded[l][n] === void 0) loaded[l][n] = true;
6389
+ });
6390
+ });
6391
+ q.done = true;
6392
+ if (q.errors.length) q.callback(q.errors);
6393
+ else q.callback();
6394
+ }
6395
+ });
6396
+ this.emit("loaded", loaded);
6397
+ this.queue = this.queue.filter((q) => !q.done);
6398
+ }
6399
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
6400
+ if (!lng.length) return callback(null, {});
6401
+ if (this.readingCalls >= this.maxParallelReads) {
6402
+ this.waitingReads.push({
6403
+ lng,
6404
+ ns,
6405
+ fcName,
6406
+ tried,
6407
+ wait,
6408
+ callback
6409
+ });
6410
+ return;
6411
+ }
6412
+ this.readingCalls++;
6413
+ const resolver = (err, data) => {
6414
+ this.readingCalls--;
6415
+ if (this.waitingReads.length > 0) {
6416
+ const next = this.waitingReads.shift();
6417
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
6418
+ }
6419
+ if (err && data && tried < this.maxRetries) {
6420
+ setTimeout(() => {
6421
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
6422
+ }, wait);
6423
+ return;
6424
+ }
6425
+ callback(err, data);
6426
+ };
6427
+ const fc = this.backend[fcName].bind(this.backend);
6428
+ if (fc.length === 2) {
6429
+ try {
6430
+ const r = fc(lng, ns);
6431
+ if (r && typeof r.then === "function") r.then((data) => resolver(null, data)).catch(resolver);
6432
+ else resolver(null, r);
6433
+ } catch (err) {
6434
+ resolver(err);
6435
+ }
6436
+ return;
6437
+ }
6438
+ return fc(lng, ns, resolver);
6439
+ }
6440
+ prepareLoading(languages, namespaces, options = {}, callback) {
6441
+ if (!this.backend) {
6442
+ this.logger.warn("No backend was added via i18next.use. Will not load resources.");
6443
+ return callback && callback();
6444
+ }
6445
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
6446
+ if (isString(namespaces)) namespaces = [namespaces];
6447
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
6448
+ if (!toLoad.toLoad.length) {
6449
+ if (!toLoad.pending.length) callback();
6450
+ return null;
6451
+ }
6452
+ toLoad.toLoad.forEach((name) => {
6453
+ this.loadOne(name);
6454
+ });
6455
+ }
6456
+ load(languages, namespaces, callback) {
6457
+ this.prepareLoading(languages, namespaces, {}, callback);
6458
+ }
6459
+ reload(languages, namespaces, callback) {
6460
+ this.prepareLoading(languages, namespaces, { reload: true }, callback);
6461
+ }
6462
+ loadOne(name, prefix = "") {
6463
+ const s = name.split("|");
6464
+ const lng = s[0];
6465
+ const ns = s[1];
6466
+ this.read(lng, ns, "read", void 0, void 0, (err, data) => {
6467
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
6468
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
6469
+ this.loaded(name, err, data);
6470
+ });
6471
+ }
6472
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
6473
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
6474
+ this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, "This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");
6475
+ return;
6476
+ }
6477
+ if (key === void 0 || key === null || key === "") return;
6478
+ if (this.backend?.create) {
6479
+ const opts = {
6480
+ ...options,
6481
+ isUpdate
6482
+ };
6483
+ const fc = this.backend.create.bind(this.backend);
6484
+ if (fc.length < 6) try {
6485
+ let r;
6486
+ if (fc.length === 5) r = fc(languages, namespace, key, fallbackValue, opts);
6487
+ else r = fc(languages, namespace, key, fallbackValue);
6488
+ if (r && typeof r.then === "function") r.then((data) => clb(null, data)).catch(clb);
6489
+ else clb(null, r);
6490
+ } catch (err) {
6491
+ clb(err);
6492
+ }
6493
+ else fc(languages, namespace, key, fallbackValue, clb, opts);
6494
+ }
6495
+ if (!languages || !languages[0]) return;
6496
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
6497
+ }
6498
+ };
6499
+ var get = () => ({
6500
+ debug: false,
6501
+ initAsync: true,
6502
+ ns: ["translation"],
6503
+ defaultNS: ["translation"],
6504
+ fallbackLng: ["dev"],
6505
+ fallbackNS: false,
6506
+ supportedLngs: false,
6507
+ nonExplicitSupportedLngs: false,
6508
+ load: "all",
6509
+ preload: false,
6510
+ simplifyPluralSuffix: true,
6511
+ keySeparator: ".",
6512
+ nsSeparator: ":",
6513
+ pluralSeparator: "_",
6514
+ contextSeparator: "_",
6515
+ partialBundledLanguages: false,
6516
+ saveMissing: false,
6517
+ updateMissing: false,
6518
+ saveMissingTo: "fallback",
6519
+ saveMissingPlurals: true,
6520
+ missingKeyHandler: false,
6521
+ missingInterpolationHandler: false,
6522
+ postProcess: false,
6523
+ postProcessPassResolved: false,
6524
+ returnNull: false,
6525
+ returnEmptyString: true,
6526
+ returnObjects: false,
6527
+ joinArrays: false,
6528
+ returnedObjectHandler: false,
6529
+ parseMissingKeyHandler: false,
6530
+ appendNamespaceToMissingKey: false,
6531
+ appendNamespaceToCIMode: false,
6532
+ overloadTranslationOptionHandler: (args) => {
6533
+ let ret = {};
6534
+ if (typeof args[1] === "object") ret = args[1];
6535
+ if (isString(args[1])) ret.defaultValue = args[1];
6536
+ if (isString(args[2])) ret.tDescription = args[2];
6537
+ if (typeof args[2] === "object" || typeof args[3] === "object") {
6538
+ const options = args[3] || args[2];
6539
+ Object.keys(options).forEach((key) => {
6540
+ ret[key] = options[key];
6541
+ });
6542
+ }
6543
+ return ret;
6544
+ },
6545
+ interpolation: {
6546
+ escapeValue: true,
6547
+ format: (value) => value,
6548
+ prefix: "{{",
6549
+ suffix: "}}",
6550
+ formatSeparator: ",",
6551
+ unescapePrefix: "-",
6552
+ nestingPrefix: "$t(",
6553
+ nestingSuffix: ")",
6554
+ nestingOptionsSeparator: ",",
6555
+ maxReplaces: 1e3,
6556
+ skipOnVariables: true
6557
+ },
6558
+ cacheInBuiltFormats: true
6559
+ });
6560
+ var transformOptions = (options) => {
6561
+ if (isString(options.ns)) options.ns = [options.ns];
6562
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
6563
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
6564
+ if (options.supportedLngs?.indexOf?.("cimode") < 0) options.supportedLngs = options.supportedLngs.concat(["cimode"]);
6565
+ if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
6566
+ return options;
6567
+ };
6568
+ var noop = () => {};
6569
+ var bindMemberFunctions = (inst) => {
6570
+ Object.getOwnPropertyNames(Object.getPrototypeOf(inst)).forEach((mem) => {
6571
+ if (typeof inst[mem] === "function") inst[mem] = inst[mem].bind(inst);
6572
+ });
6573
+ };
6574
+ var SUPPORT_NOTICE_KEY = "__i18next_supportNoticeShown";
6575
+ var getSupportNoticeShown = () => {
6576
+ if (typeof globalThis !== "undefined" && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
6577
+ if (typeof process !== "undefined" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
6578
+ if (typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production") return true;
6579
+ return false;
6580
+ };
6581
+ var setSupportNoticeShown = () => {
6582
+ if (typeof globalThis !== "undefined") globalThis[SUPPORT_NOTICE_KEY] = true;
6583
+ };
6584
+ var usesLocize = (inst) => {
6585
+ if (inst?.modules?.backend?.name?.indexOf("Locize") > 0) return true;
6586
+ if (inst?.modules?.backend?.constructor?.name?.indexOf("Locize") > 0) return true;
6587
+ if (inst?.options?.backend?.backends) {
6588
+ if (inst.options.backend.backends.some((b) => b?.name?.indexOf("Locize") > 0 || b?.constructor?.name?.indexOf("Locize") > 0)) return true;
6589
+ }
6590
+ if (inst?.options?.backend?.projectId) return true;
6591
+ if (inst?.options?.backend?.backendOptions) {
6592
+ if (inst.options.backend.backendOptions.some((b) => b?.projectId)) return true;
6593
+ }
6594
+ return false;
6595
+ };
6596
+ var instance = class I18n extends EventEmitter {
6597
+ constructor(options = {}, callback) {
6598
+ super();
6599
+ this.options = transformOptions(options);
6600
+ this.services = {};
6601
+ this.logger = baseLogger;
6602
+ this.modules = { external: [] };
6603
+ bindMemberFunctions(this);
6604
+ if (callback && !this.isInitialized && !options.isClone) {
6605
+ if (!this.options.initAsync) {
6606
+ this.init(options, callback);
6607
+ return this;
6608
+ }
6609
+ setTimeout(() => {
6610
+ this.init(options, callback);
6611
+ }, 0);
6612
+ }
6613
+ }
6614
+ init(options = {}, callback) {
6615
+ this.isInitializing = true;
6616
+ if (typeof options === "function") {
6617
+ callback = options;
6618
+ options = {};
6619
+ }
6620
+ if (options.defaultNS == null && options.ns) {
6621
+ if (isString(options.ns)) options.defaultNS = options.ns;
6622
+ else if (options.ns.indexOf("translation") < 0) options.defaultNS = options.ns[0];
6623
+ }
6624
+ const defOpts = get();
6625
+ this.options = {
6626
+ ...defOpts,
6627
+ ...this.options,
6628
+ ...transformOptions(options)
6629
+ };
6630
+ this.options.interpolation = {
6631
+ ...defOpts.interpolation,
6632
+ ...this.options.interpolation
6633
+ };
6634
+ if (options.keySeparator !== void 0) this.options.userDefinedKeySeparator = options.keySeparator;
6635
+ if (options.nsSeparator !== void 0) this.options.userDefinedNsSeparator = options.nsSeparator;
6636
+ if (typeof this.options.overloadTranslationOptionHandler !== "function") this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
6637
+ if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
6638
+ if (typeof console !== "undefined" && typeof console.info !== "undefined") console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙");
6639
+ setSupportNoticeShown();
6640
+ }
6641
+ const createClassOnDemand = (ClassOrObject) => {
6642
+ if (!ClassOrObject) return null;
6643
+ if (typeof ClassOrObject === "function") return new ClassOrObject();
6644
+ return ClassOrObject;
6645
+ };
6646
+ if (!this.options.isClone) {
6647
+ if (this.modules.logger) baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
6648
+ else baseLogger.init(null, this.options);
6649
+ let formatter;
6650
+ if (this.modules.formatter) formatter = this.modules.formatter;
6651
+ else formatter = Formatter;
6652
+ const lu = new LanguageUtil(this.options);
6653
+ this.store = new ResourceStore(this.options.resources, this.options);
6654
+ const s = this.services;
6655
+ s.logger = baseLogger;
6656
+ s.resourceStore = this.store;
6657
+ s.languageUtils = lu;
6658
+ s.pluralResolver = new PluralResolver(lu, {
6659
+ prepend: this.options.pluralSeparator,
6660
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
6661
+ });
6662
+ if (this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format) this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
6663
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
6664
+ s.formatter = createClassOnDemand(formatter);
6665
+ if (s.formatter.init) s.formatter.init(s, this.options);
6666
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
6667
+ }
6668
+ s.interpolator = new Interpolator(this.options);
6669
+ s.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) };
6670
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
6671
+ s.backendConnector.on("*", (event, ...args) => {
6672
+ this.emit(event, ...args);
6673
+ });
6674
+ if (this.modules.languageDetector) {
6675
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
6676
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
6677
+ }
6678
+ if (this.modules.i18nFormat) {
6679
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
6680
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
6681
+ }
6682
+ this.translator = new Translator(this.services, this.options);
6683
+ this.translator.on("*", (event, ...args) => {
6684
+ this.emit(event, ...args);
6685
+ });
6686
+ this.modules.external.forEach((m) => {
6687
+ if (m.init) m.init(this);
6688
+ });
6689
+ }
6690
+ this.format = this.options.interpolation.format;
6691
+ if (!callback) callback = noop;
6692
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
6693
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
6694
+ if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
6695
+ }
6696
+ if (!this.services.languageDetector && !this.options.lng) this.logger.warn("init: no languageDetector is used and no lng is defined");
6697
+ [
6698
+ "getResource",
6699
+ "hasResourceBundle",
6700
+ "getResourceBundle",
6701
+ "getDataByLanguage"
6702
+ ].forEach((fcName) => {
6703
+ this[fcName] = (...args) => this.store[fcName](...args);
6704
+ });
6705
+ [
6706
+ "addResource",
6707
+ "addResources",
6708
+ "addResourceBundle",
6709
+ "removeResourceBundle"
6710
+ ].forEach((fcName) => {
6711
+ this[fcName] = (...args) => {
6712
+ this.store[fcName](...args);
6713
+ return this;
6714
+ };
6715
+ });
6716
+ const deferred = defer();
6717
+ const load = () => {
6718
+ const finish = (err, t) => {
6719
+ this.isInitializing = false;
6720
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
6721
+ this.isInitialized = true;
6722
+ if (!this.options.isClone) this.logger.log("initialized", this.options);
6723
+ this.emit("initialized", this.options);
6724
+ deferred.resolve(t);
6725
+ callback(err, t);
6726
+ };
6727
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
6728
+ this.changeLanguage(this.options.lng, finish);
6729
+ };
6730
+ if (this.options.resources || !this.options.initAsync) load();
6731
+ else setTimeout(load, 0);
6732
+ return deferred;
6733
+ }
6734
+ loadResources(language, callback = noop) {
6735
+ let usedCallback = callback;
6736
+ const usedLng = isString(language) ? language : this.language;
6737
+ if (typeof language === "function") usedCallback = language;
6738
+ if (!this.options.resources || this.options.partialBundledLanguages) {
6739
+ if (usedLng?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
6740
+ const toLoad = [];
6741
+ const append = (lng) => {
6742
+ if (!lng) return;
6743
+ if (lng === "cimode") return;
6744
+ this.services.languageUtils.toResolveHierarchy(lng).forEach((l) => {
6745
+ if (l === "cimode") return;
6746
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
6747
+ });
6748
+ };
6749
+ if (!usedLng) this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => append(l));
6750
+ else append(usedLng);
6751
+ this.options.preload?.forEach?.((l) => append(l));
6752
+ this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
6753
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
6754
+ usedCallback(e);
6755
+ });
6756
+ } else usedCallback(null);
6757
+ }
6758
+ reloadResources(lngs, ns, callback) {
6759
+ const deferred = defer();
6760
+ if (typeof lngs === "function") {
6761
+ callback = lngs;
6762
+ lngs = void 0;
6763
+ }
6764
+ if (typeof ns === "function") {
6765
+ callback = ns;
6766
+ ns = void 0;
6767
+ }
6768
+ if (!lngs) lngs = this.languages;
6769
+ if (!ns) ns = this.options.ns;
6770
+ if (!callback) callback = noop;
6771
+ this.services.backendConnector.reload(lngs, ns, (err) => {
6772
+ deferred.resolve();
6773
+ callback(err);
6774
+ });
6775
+ return deferred;
6776
+ }
6777
+ use(module) {
6778
+ if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
6779
+ if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
6780
+ if (module.type === "backend") this.modules.backend = module;
6781
+ if (module.type === "logger" || module.log && module.warn && module.error) this.modules.logger = module;
6782
+ if (module.type === "languageDetector") this.modules.languageDetector = module;
6783
+ if (module.type === "i18nFormat") this.modules.i18nFormat = module;
6784
+ if (module.type === "postProcessor") postProcessor.addPostProcessor(module);
6785
+ if (module.type === "formatter") this.modules.formatter = module;
6786
+ if (module.type === "3rdParty") this.modules.external.push(module);
6787
+ return this;
6788
+ }
6789
+ setResolvedLanguage(l) {
6790
+ if (!l || !this.languages) return;
6791
+ if (["cimode", "dev"].indexOf(l) > -1) return;
6792
+ for (let li = 0; li < this.languages.length; li++) {
6793
+ const lngInLngs = this.languages[li];
6794
+ if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
6795
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
6796
+ this.resolvedLanguage = lngInLngs;
6797
+ break;
6798
+ }
6799
+ }
6800
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
6801
+ this.resolvedLanguage = l;
6802
+ this.languages.unshift(l);
6803
+ }
6804
+ }
6805
+ changeLanguage(lng, callback) {
6806
+ this.isLanguageChangingTo = lng;
6807
+ const deferred = defer();
6808
+ this.emit("languageChanging", lng);
6809
+ const setLngProps = (l) => {
6810
+ this.language = l;
6811
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
6812
+ this.resolvedLanguage = void 0;
6813
+ this.setResolvedLanguage(l);
6814
+ };
6815
+ const done = (err, l) => {
6816
+ if (l) {
6817
+ if (this.isLanguageChangingTo === lng) {
6818
+ setLngProps(l);
6819
+ this.translator.changeLanguage(l);
6820
+ this.isLanguageChangingTo = void 0;
6821
+ this.emit("languageChanged", l);
6822
+ this.logger.log("languageChanged", l);
6823
+ }
6824
+ } else this.isLanguageChangingTo = void 0;
6825
+ deferred.resolve((...args) => this.t(...args));
6826
+ if (callback) callback(err, (...args) => this.t(...args));
6827
+ };
6828
+ const setLng = (lngs) => {
6829
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
6830
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
6831
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
6832
+ if (l) {
6833
+ if (!this.language) setLngProps(l);
6834
+ if (!this.translator.language) this.translator.changeLanguage(l);
6835
+ this.services.languageDetector?.cacheUserLanguage?.(l);
6836
+ }
6837
+ this.loadResources(l, (err) => {
6838
+ done(err, l);
6839
+ });
6840
+ };
6841
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) setLng(this.services.languageDetector.detect());
6842
+ else if (!lng && this.services.languageDetector && this.services.languageDetector.async) if (this.services.languageDetector.detect.length === 0) this.services.languageDetector.detect().then(setLng);
6843
+ else this.services.languageDetector.detect(setLng);
6844
+ else setLng(lng);
6845
+ return deferred;
6846
+ }
6847
+ getFixedT(lng, ns, keyPrefix) {
6848
+ const fixedT = (key, opts, ...rest) => {
6849
+ let o;
6850
+ if (typeof opts !== "object") o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
6851
+ else o = { ...opts };
6852
+ o.lng = o.lng || fixedT.lng;
6853
+ o.lngs = o.lngs || fixedT.lngs;
6854
+ o.ns = o.ns || fixedT.ns;
6855
+ if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
6856
+ const selectorOpts = {
6857
+ ...this.options,
6858
+ ...o
6859
+ };
6860
+ if (typeof o.keyPrefix === "function") o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
6861
+ const keySeparator = this.options.keySeparator || ".";
6862
+ let resultKey;
6863
+ if (o.keyPrefix && Array.isArray(key)) resultKey = key.map((k) => {
6864
+ if (typeof k === "function") k = keysFromSelector(k, selectorOpts);
6865
+ return `${o.keyPrefix}${keySeparator}${k}`;
6866
+ });
6867
+ else {
6868
+ if (typeof key === "function") key = keysFromSelector(key, selectorOpts);
6869
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
6870
+ }
6871
+ return this.t(resultKey, o);
6872
+ };
6873
+ if (isString(lng)) fixedT.lng = lng;
6874
+ else fixedT.lngs = lng;
6875
+ fixedT.ns = ns;
6876
+ fixedT.keyPrefix = keyPrefix;
6877
+ return fixedT;
6878
+ }
6879
+ t(...args) {
6880
+ return this.translator?.translate(...args);
6881
+ }
6882
+ exists(...args) {
6883
+ return this.translator?.exists(...args);
6884
+ }
6885
+ setDefaultNamespace(ns) {
6886
+ this.options.defaultNS = ns;
6887
+ }
6888
+ hasLoadedNamespace(ns, options = {}) {
6889
+ if (!this.isInitialized) {
6890
+ this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
6891
+ return false;
6892
+ }
6893
+ if (!this.languages || !this.languages.length) {
6894
+ this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
6895
+ return false;
6896
+ }
6897
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
6898
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
6899
+ const lastLng = this.languages[this.languages.length - 1];
6900
+ if (lng.toLowerCase() === "cimode") return true;
6901
+ const loadNotPending = (l, n) => {
6902
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
6903
+ return loadState === -1 || loadState === 0 || loadState === 2;
6904
+ };
6905
+ if (options.precheck) {
6906
+ const preResult = options.precheck(this, loadNotPending);
6907
+ if (preResult !== void 0) return preResult;
6908
+ }
6909
+ if (this.hasResourceBundle(lng, ns)) return true;
6910
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
6911
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
6912
+ return false;
6913
+ }
6914
+ loadNamespaces(ns, callback) {
6915
+ const deferred = defer();
6916
+ if (!this.options.ns) {
6917
+ if (callback) callback();
6918
+ return Promise.resolve();
6919
+ }
6920
+ if (isString(ns)) ns = [ns];
6921
+ ns.forEach((n) => {
6922
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
6923
+ });
6924
+ this.loadResources((err) => {
6925
+ deferred.resolve();
6926
+ if (callback) callback(err);
6927
+ });
6928
+ return deferred;
6929
+ }
6930
+ loadLanguages(lngs, callback) {
6931
+ const deferred = defer();
6932
+ if (isString(lngs)) lngs = [lngs];
6933
+ const preloaded = this.options.preload || [];
6934
+ const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
6935
+ if (!newLngs.length) {
6936
+ if (callback) callback();
6937
+ return Promise.resolve();
6938
+ }
6939
+ this.options.preload = preloaded.concat(newLngs);
6940
+ this.loadResources((err) => {
6941
+ deferred.resolve();
6942
+ if (callback) callback(err);
6943
+ });
6944
+ return deferred;
6945
+ }
6946
+ dir(lng) {
6947
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
6948
+ if (!lng) return "rtl";
6949
+ try {
6950
+ const l = new Intl.Locale(lng);
6951
+ if (l && l.getTextInfo) {
6952
+ const ti = l.getTextInfo();
6953
+ if (ti && ti.direction) return ti.direction;
6954
+ }
6955
+ } catch (e) {}
6956
+ const rtlLngs = [
6957
+ "ar",
6958
+ "shu",
6959
+ "sqr",
6960
+ "ssh",
6961
+ "xaa",
6962
+ "yhd",
6963
+ "yud",
6964
+ "aao",
6965
+ "abh",
6966
+ "abv",
6967
+ "acm",
6968
+ "acq",
6969
+ "acw",
6970
+ "acx",
6971
+ "acy",
6972
+ "adf",
6973
+ "ads",
6974
+ "aeb",
6975
+ "aec",
6976
+ "afb",
6977
+ "ajp",
6978
+ "apc",
6979
+ "apd",
6980
+ "arb",
6981
+ "arq",
6982
+ "ars",
6983
+ "ary",
6984
+ "arz",
6985
+ "auz",
6986
+ "avl",
6987
+ "ayh",
6988
+ "ayl",
6989
+ "ayn",
6990
+ "ayp",
6991
+ "bbz",
6992
+ "pga",
6993
+ "he",
6994
+ "iw",
6995
+ "ps",
6996
+ "pbt",
6997
+ "pbu",
6998
+ "pst",
6999
+ "prp",
7000
+ "prd",
7001
+ "ug",
7002
+ "ur",
7003
+ "ydd",
7004
+ "yds",
7005
+ "yih",
7006
+ "ji",
7007
+ "yi",
7008
+ "hbo",
7009
+ "men",
7010
+ "xmn",
7011
+ "fa",
7012
+ "jpr",
7013
+ "peo",
7014
+ "pes",
7015
+ "prs",
7016
+ "dv",
7017
+ "sam",
7018
+ "ckb"
7019
+ ];
7020
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
7021
+ if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
7022
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
7023
+ }
7024
+ static createInstance(options = {}, callback) {
7025
+ const instance = new I18n(options, callback);
7026
+ instance.createInstance = I18n.createInstance;
7027
+ return instance;
7028
+ }
7029
+ cloneInstance(options = {}, callback = noop) {
7030
+ const forkResourceStore = options.forkResourceStore;
7031
+ if (forkResourceStore) delete options.forkResourceStore;
7032
+ const mergedOptions = {
7033
+ ...this.options,
7034
+ ...options,
7035
+ isClone: true
7036
+ };
7037
+ const clone = new I18n(mergedOptions);
7038
+ if (options.debug !== void 0 || options.prefix !== void 0) clone.logger = clone.logger.clone(options);
7039
+ [
7040
+ "store",
7041
+ "services",
7042
+ "language"
7043
+ ].forEach((m) => {
7044
+ clone[m] = this[m];
7045
+ });
7046
+ clone.services = { ...this.services };
7047
+ clone.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
7048
+ if (forkResourceStore) {
7049
+ clone.store = new ResourceStore(Object.keys(this.store.data).reduce((prev, l) => {
7050
+ prev[l] = { ...this.store.data[l] };
7051
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
7052
+ acc[n] = { ...prev[l][n] };
7053
+ return acc;
7054
+ }, prev[l]);
7055
+ return prev;
7056
+ }, {}), mergedOptions);
7057
+ clone.services.resourceStore = clone.store;
7058
+ }
7059
+ if (options.interpolation) {
7060
+ const mergedInterpolation = {
7061
+ ...get().interpolation,
7062
+ ...this.options.interpolation,
7063
+ ...options.interpolation
7064
+ };
7065
+ const mergedForInterpolator = {
7066
+ ...mergedOptions,
7067
+ interpolation: mergedInterpolation
7068
+ };
7069
+ clone.services.interpolator = new Interpolator(mergedForInterpolator);
7070
+ }
7071
+ clone.translator = new Translator(clone.services, mergedOptions);
7072
+ clone.translator.on("*", (event, ...args) => {
7073
+ clone.emit(event, ...args);
7074
+ });
7075
+ clone.init(mergedOptions, callback);
7076
+ clone.translator.options = mergedOptions;
7077
+ clone.translator.backendConnector.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
7078
+ return clone;
7079
+ }
7080
+ toJSON() {
7081
+ return {
7082
+ options: this.options,
7083
+ store: this.store,
7084
+ language: this.language,
7085
+ languages: this.languages,
7086
+ resolvedLanguage: this.resolvedLanguage
7087
+ };
7088
+ }
7089
+ }.createInstance();
7090
+ instance.createInstance;
7091
+ instance.dir;
7092
+ instance.init;
7093
+ instance.loadResources;
7094
+ instance.reloadResources;
7095
+ instance.use;
7096
+ instance.changeLanguage;
7097
+ instance.getFixedT;
7098
+ instance.t;
7099
+ instance.exists;
7100
+ instance.setDefaultNamespace;
7101
+ instance.hasLoadedNamespace;
7102
+ instance.loadNamespaces;
7103
+ instance.loadLanguages;
7104
+ //#endregion
7105
+ //#region ../../shared/translator/dist/index.js
7106
+ instance.init({
7107
+ fallbackLng: "en",
7108
+ lng: "en",
7109
+ showSupportNotice: !1,
7110
+ resources: {
7111
+ en: e$1,
7112
+ es: e
7113
+ }
7114
+ });
7115
+ //#endregion
7116
+ //#region src/i18n.ts
7117
+ var { translator } = {
7118
+ translator: {
7119
+ ...instance,
7120
+ t: (e, t) => {
7121
+ let { lng: r } = t;
7122
+ switch (r) {
7123
+ case "en_US":
7124
+ case "en-US":
7125
+ t.lng = "en";
7126
+ break;
7127
+ case "es_ES":
7128
+ case "es-ES":
7129
+ case "es_MX":
7130
+ case "es-MX":
7131
+ t.lng = "es";
7132
+ break;
7133
+ default: break;
7134
+ }
7135
+ return instance.t(e, {
7136
+ lng: r,
7137
+ ...t
7138
+ });
7139
+ }
7140
+ },
7141
+ languageOptions: [{
7142
+ value: "en_US",
7143
+ label: "English (US)"
7144
+ }, {
7145
+ value: "es_ES",
7146
+ label: "Spanish"
7147
+ }]
7148
+ };
7149
+ /**
7150
+ * A learner-facing string in `language`, the model's `language`. i18next falls
7151
+ * back to English for a language or key it does not hold.
7152
+ */
7153
+ function t(key, language) {
7154
+ return translator.t(`translation:simpleCloze:${key}`, { lng: language });
7155
+ }
7156
+ /** A string shared across elements, such as the correct-answer toggle's labels. */
7157
+ function tCommon(key, language) {
7158
+ return translator.t(`common:${key}`, { lng: language });
7159
+ }
7160
+ //#endregion
7161
+ //#region src/delivery/TeacherInstructions.svelte
7162
+ var root$1 = /* @__PURE__ */ from_html(`<div class="teacher-instructions pie-teacher-instructions svelte-1jhejbv"><button type="button" class="teacher-instructions-toggle pie-teacher-instructions-toggle svelte-1jhejbv"> </button> <div class="teacher-instructions-content pie-teacher-instructions-content svelte-1jhejbv"></div></div>`);
7163
+ var $$css$1 = {
7164
+ hash: "svelte-1jhejbv",
7165
+ code: ".teacher-instructions.svelte-1jhejbv {margin-bottom:1rem;}.teacher-instructions-toggle.svelte-1jhejbv {padding:0;border:0;border-bottom:1px dotted currentColor;background:transparent;font:inherit;color:var(--pie-primary, #3f51b5);cursor:pointer;}.teacher-instructions-toggle.svelte-1jhejbv:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.teacher-instructions-content.svelte-1jhejbv {padding-top:1rem;}"
7166
+ };
7167
+ function TeacherInstructions($$anchor, $$props) {
7168
+ push($$props, true);
7169
+ append_styles($$anchor, $$css$1);
7170
+ let html$1 = prop($$props, "html", 7), language = prop($$props, "language", 7);
7171
+ let expanded = /* @__PURE__ */ state(false);
7172
+ const panelId = `simple-cloze-teacher-instructions-${Math.random().toString(36).slice(2, 10)}`;
7173
+ var $$exports = {
7174
+ get html() {
7175
+ return html$1();
7176
+ },
7177
+ set html($$value) {
7178
+ html$1($$value);
7179
+ flushSync();
7180
+ },
7181
+ get language() {
7182
+ return language();
7183
+ },
7184
+ set language($$value) {
7185
+ language($$value);
7186
+ flushSync();
7187
+ }
7188
+ };
7189
+ var div = root$1();
7190
+ var button = child(div);
7191
+ var text = only_child(button, true);
7192
+ var div_1 = sibling(button, 2);
7193
+ html(div_1, html$1, true);
7194
+ reset(div_1);
7195
+ reset(div);
7196
+ template_effect(($0) => {
7197
+ set_attribute(button, "aria-expanded", get$1(expanded));
7198
+ set_attribute(button, "aria-controls", panelId);
7199
+ set_text(text, $0);
7200
+ set_attribute(div_1, "id", panelId);
7201
+ set_attribute(div_1, "hidden", !get$1(expanded));
7202
+ }, [() => tCommon(get$1(expanded) ? "hideTeacherInstructions" : "showTeacherInstructions", language())]);
7203
+ delegated("click", button, () => set(expanded, !get$1(expanded)));
7204
+ append($$anchor, div);
7205
+ return pop($$exports);
7206
+ }
7207
+ delegate(["click"]);
7208
+ create_custom_element(TeacherInstructions, {
7209
+ html: {},
7210
+ language: {}
7211
+ }, [], [], { mode: "open" });
7212
+ //#endregion
7213
+ //#region src/delivery/SimpleCloze.svelte
7214
+ var root = /* @__PURE__ */ from_html(`<div class="simple-cloze-prompt svelte-1glps5n"></div>`);
7215
+ var root_1 = /* @__PURE__ */ from_svg(`<svg preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-283 359 34 35" focusable="false" class="svelte-1glps5n"><circle cx="-266" cy="375.9" r="14" fill="#bce2ff"></circle><path d="M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z" fill="#bce2ff"></path><polygon points="-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6" fill="#1a9cff"></polygon></svg>`);
7216
+ var root_2 = /* @__PURE__ */ from_svg(`<svg preserveAspectRatio="xMinYMin meet" version="1.1" viewBox="-129.5 127 34 35" focusable="false" class="svelte-1glps5n"><path style="fill: #D0CAC5; stroke: #E6E3E0; stroke-width: 0.75; stroke-miterlimit: 10;" d="M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5 C-97.4,153.5-104.3,160.4-112.9,160.4z"></path><path style="fill: #B3ABA4; stroke: #CDC7C2; stroke-width: 0.5; stroke-miterlimit: 10;" d="M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"></path><circle cx="-114.2" cy="143.5" r="14" fill="white"></circle><path d="M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z" fill="#bce2ff"></path><polygon points="-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2" fill="#1a9cff"></polygon></svg>`);
7217
+ var root_3 = /* @__PURE__ */ from_html(`<button type="button" class="simple-cloze-toggle svelte-1glps5n"><span class="simple-cloze-toggle-icon svelte-1glps5n" aria-hidden="true"><!></span> <span class="simple-cloze-toggle-label svelte-1glps5n"> </span></button>`);
7218
+ var root_4 = /* @__PURE__ */ from_html(`<span class="correctness-icon correctness-icon--correct svelte-1glps5n" aria-hidden="true"><svg fill="currentColor" viewBox="0 0 24 24" focusable="false" class="svelte-1glps5n"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"></path></svg></span>`);
7219
+ var root_5 = /* @__PURE__ */ from_html(`<span class="correctness-icon correctness-icon--incorrect svelte-1glps5n" aria-hidden="true"><svg fill="currentColor" viewBox="0 0 24 24" focusable="false" class="svelte-1glps5n"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg></span>`);
7220
+ var root_6 = /* @__PURE__ */ from_html(`<div class="simple-cloze-root svelte-1glps5n"><!> <!> <!> <div class="simple-cloze-response svelte-1glps5n"><!> <input type="text" spellcheck="false"/> <span class="sr-only svelte-1glps5n" role="status"> </span></div></div>`);
4728
7221
  var $$css = {
4729
7222
  hash: "svelte-1glps5n",
4730
- code: "\n /* Custom styles for correct answer display */input[readonly].svelte-1glps5n {font-weight:600;}.correctness-icon.svelte-1glps5n {position:absolute;top:-8px;left:-8px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:2px;}"
7223
+ code: "\n /*\n * Self-contained: players ship no Tailwind, so nothing here relies on host\n * utility classes or a CSS reset. Colours are `--pie-*` theme variables with\n * the fallbacks `@pie-lib/render-ui`'s `color` module uses.\n */.simple-cloze-root.svelte-1glps5n {padding:1rem;color:var(--pie-text, black);}.simple-cloze-prompt.svelte-1glps5n {margin-bottom:1rem;}.simple-cloze-prompt.svelte-1glps5n p {margin:0.5em 0;}.simple-cloze-prompt.svelte-1glps5n strong {font-weight:600;}.simple-cloze-toggle.svelte-1glps5n {display:flex;align-items:center;gap:0.5rem;margin:0 0 0.75rem;padding:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;user-select:none;}.simple-cloze-toggle.svelte-1glps5n:hover .simple-cloze-toggle-label:where(.svelte-1glps5n) {text-decoration:underline;}.simple-cloze-toggle.svelte-1glps5n:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.simple-cloze-toggle-icon.svelte-1glps5n {display:inline-flex;}.simple-cloze-toggle-icon.svelte-1glps5n svg:where(.svelte-1glps5n) {width:25px;height:25px;}.simple-cloze-toggle-label.svelte-1glps5n {font-size:0.875rem;line-height:1.25rem;}.simple-cloze-response.svelte-1glps5n {position:relative;display:inline-block;}.simple-cloze-input.svelte-1glps5n {box-sizing:border-box;margin:0;padding:0.5rem 0.75rem;\n /* The text colour, as ECR's input border: a light grey fails 3:1 (WCAG 1.4.11). */border:1px solid var(--pie-text, black);border-radius:0.25rem;background-color:transparent;color:var(--pie-text, black);font:inherit;}.simple-cloze-input.svelte-1glps5n:disabled {opacity:1;color:var(--pie-text, black);-webkit-text-fill-color:currentColor;}.simple-cloze-input.svelte-1glps5n:focus-visible {outline:2px solid var(--pie-button-focus-outline, #3b82f6);outline-offset:2px;}.simple-cloze-input--correct.svelte-1glps5n {border:2px solid var(--pie-correct-tertiary, #0ea449);}.simple-cloze-input--incorrect.svelte-1glps5n {border:2px solid var(--pie-incorrect-icon, #bf0d00);}.simple-cloze-input[readonly].svelte-1glps5n {font-weight:600;}.correctness-icon.svelte-1glps5n {position:absolute;top:-8px;left:-8px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;padding:2px;color:var(--pie-white, #ffffff);}.correctness-icon.svelte-1glps5n svg:where(.svelte-1glps5n) {width:12px;height:12px;}.correctness-icon--correct.svelte-1glps5n {background-color:var(--pie-correct-tertiary, #0ea449);}.correctness-icon--incorrect.svelte-1glps5n {background-color:var(--pie-incorrect-icon, #bf0d00);}.sr-only.svelte-1glps5n {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;}"
4731
7224
  };
4732
7225
  function SimpleCloze($$anchor, $$props) {
4733
7226
  push($$props, true);
4734
- append_styles$1($$anchor, $$css);
4735
- let inputElement = null;
7227
+ append_styles($$anchor, $$css);
7228
+ let model = prop($$props, "model", 7, null), session = prop($$props, "session", 7, null);
7229
+ const instanceId = `simple-cloze-${Math.random().toString(36).slice(2, 10)}`;
7230
+ const promptId = `${instanceId}-prompt`;
7231
+ const feedbackId = `${instanceId}-feedback`;
7232
+ let promptElement = /* @__PURE__ */ state(null);
7233
+ let inputElement = /* @__PURE__ */ state(null);
4736
7234
  let showCorrectAnswer = /* @__PURE__ */ state(false);
4737
- onMount(() => {
4738
- if (inputElement) {
4739
- inputElement.value = $$props?.session?.response || "";
4740
- inputElement.addEventListener("input", handleInput);
4741
- }
4742
- return () => {
4743
- if (inputElement) inputElement.removeEventListener("input", handleInput);
4744
- };
7235
+ const isEvaluateMode = /* @__PURE__ */ user_derived(() => model()?.mode === "evaluate");
7236
+ const correctness = /* @__PURE__ */ user_derived(() => model()?.correctness);
7237
+ const isCorrect = /* @__PURE__ */ user_derived(() => get$1(correctness) === "correct");
7238
+ const isIncorrect = /* @__PURE__ */ user_derived(() => get$1(correctness) === "incorrect");
7239
+ const isUnanswered = /* @__PURE__ */ user_derived(() => get$1(correctness) === "unanswered");
7240
+ const prompt = /* @__PURE__ */ user_derived(() => typeof model()?.prompt === "string" ? model().prompt : "");
7241
+ const correctAnswer = /* @__PURE__ */ user_derived(() => typeof model()?.correctAnswer === "string" ? model().correctAnswer : "");
7242
+ const sessionValue = /* @__PURE__ */ user_derived(() => typeof session()?.value === "string" ? session().value : "");
7243
+ const canShowCorrectAnswer = /* @__PURE__ */ user_derived(() => get$1(isEvaluateMode) && !get$1(isCorrect) && !!get$1(correctAnswer).trim());
7244
+ const showingCorrectAnswer = /* @__PURE__ */ user_derived(() => get$1(showCorrectAnswer) && get$1(canShowCorrectAnswer));
7245
+ const feedbackText = /* @__PURE__ */ user_derived(() => {
7246
+ if (!get$1(isEvaluateMode)) return "";
7247
+ if (get$1(showingCorrectAnswer)) return t("correctAnswerShown", model()?.language);
7248
+ if (get$1(isCorrect)) return t("correct", model()?.language);
7249
+ if (get$1(isIncorrect)) return t("incorrect", model()?.language);
7250
+ if (get$1(isUnanswered)) return t("unanswered", model()?.language);
7251
+ return "";
4745
7252
  });
4746
7253
  user_effect(() => {
4747
- if (inputElement && !get(showCorrectAnswer)) {
4748
- const sessionValue = $$props?.session?.response || "";
4749
- if (inputElement.value !== sessionValue) inputElement.value = sessionValue;
4750
- }
7254
+ if (!get$1(canShowCorrectAnswer)) set(showCorrectAnswer, false);
7255
+ });
7256
+ user_effect(() => {
7257
+ if (!get$1(inputElement)) return;
7258
+ const next = get$1(showingCorrectAnswer) ? get$1(correctAnswer) : get$1(sessionValue);
7259
+ if (get$1(inputElement).value !== next) get$1(inputElement).value = next;
4751
7260
  });
4752
7261
  user_effect(() => {
4753
- if (inputElement) {
4754
- if (get(showCorrectAnswer) && $$props?.model?.correctAnswer) inputElement.value = $$props.model.correctAnswer;
4755
- else if (!get(showCorrectAnswer)) inputElement.value = $$props?.session?.response || "";
7262
+ if (!get$1(promptElement) || !get$1(prompt)) return;
7263
+ const warn = (err) => console.warn("simple-cloze: MathJax render failed", err);
7264
+ try {
7265
+ Promise.resolve(c(get$1(promptElement))).catch(warn);
7266
+ } catch (err) {
7267
+ warn(err);
4756
7268
  }
4757
7269
  });
4758
7270
  function handleInput(event) {
4759
7271
  const target = event.target;
4760
7272
  const newValue = target.value;
4761
- a({
7273
+ l({
4762
7274
  sourceEl: target,
4763
- fallbackSelector: "simple-cloze",
4764
- component: "simple-cloze",
4765
7275
  session: {
4766
- ...$$props.session,
4767
- response: newValue
7276
+ ...session(),
7277
+ value: newValue
4768
7278
  },
4769
7279
  complete: newValue.trim().length > 0
4770
7280
  });
4771
7281
  }
4772
7282
  function toggleCorrectAnswer() {
4773
- set(showCorrectAnswer, !get(showCorrectAnswer));
7283
+ if (!get$1(canShowCorrectAnswer)) return;
7284
+ set(showCorrectAnswer, !get$1(showCorrectAnswer));
4774
7285
  }
4775
- const isEvaluateMode = /* @__PURE__ */ user_derived(() => $$props?.model?.env?.mode === "evaluate");
4776
- const correctness = /* @__PURE__ */ user_derived(() => $$props?.model?.correctness);
4777
- const isCorrect = /* @__PURE__ */ user_derived(() => get(correctness) === "correct");
4778
- const isIncorrect = /* @__PURE__ */ user_derived(() => get(correctness) === "incorrect");
7286
+ var $$exports = {
7287
+ get model() {
7288
+ return model();
7289
+ },
7290
+ set model($$value = null) {
7291
+ model($$value);
7292
+ flushSync();
7293
+ },
7294
+ get session() {
7295
+ return session();
7296
+ },
7297
+ set session($$value = null) {
7298
+ session($$value);
7299
+ flushSync();
7300
+ }
7301
+ };
4779
7302
  var div = root_6();
4780
7303
  var node = child(div);
4781
7304
  var consequent = ($$anchor) => {
7305
+ {
7306
+ let $0 = /* @__PURE__ */ user_derived(() => model()?.language);
7307
+ TeacherInstructions($$anchor, {
7308
+ get html() {
7309
+ return model().teacherInstructions;
7310
+ },
7311
+ get language() {
7312
+ return get$1($0);
7313
+ }
7314
+ });
7315
+ }
7316
+ };
7317
+ if_block(node, ($$render) => {
7318
+ if (model()?.teacherInstructions) $$render(consequent);
7319
+ });
7320
+ var node_1 = sibling(node, 2);
7321
+ var consequent_1 = ($$anchor) => {
4782
7322
  var div_1 = root();
4783
- html(div_1, () => $$props.model.prompt, true);
7323
+ html(div_1, () => get$1(prompt), true);
4784
7324
  reset(div_1);
7325
+ bind_this(div_1, ($$value) => set(promptElement, $$value), () => get$1(promptElement));
7326
+ template_effect(() => set_attribute(div_1, "id", promptId));
4785
7327
  append($$anchor, div_1);
4786
7328
  };
4787
- if_block(node, ($$render) => {
4788
- if ($$props?.model?.prompt) $$render(consequent);
7329
+ if_block(node_1, ($$render) => {
7330
+ if (get$1(prompt)) $$render(consequent_1);
4789
7331
  });
4790
- var node_1 = sibling(node, 2);
4791
- var consequent_2 = ($$anchor) => {
7332
+ var node_2 = sibling(node_1, 2);
7333
+ var consequent_3 = ($$anchor) => {
4792
7334
  var button = root_3();
4793
- var node_2 = child(button);
4794
- var consequent_1 = ($$anchor) => {
7335
+ var span = child(button);
7336
+ var node_3 = child(span);
7337
+ var consequent_2 = ($$anchor) => {
4795
7338
  append($$anchor, root_1());
4796
7339
  };
4797
7340
  var alternate = ($$anchor) => {
4798
7341
  append($$anchor, root_2());
4799
7342
  };
4800
- if_block(node_2, ($$render) => {
4801
- if (get(showCorrectAnswer)) $$render(consequent_1);
7343
+ if_block(node_3, ($$render) => {
7344
+ if (get$1(showingCorrectAnswer)) $$render(consequent_2);
4802
7345
  else $$render(alternate, -1);
4803
7346
  });
4804
- var text = only_child(sibling(node_2, 2));
7347
+ reset(span);
7348
+ var text = only_child(sibling(span, 2), true);
4805
7349
  reset(button);
4806
- template_effect(() => {
4807
- set_attribute(button, "aria-pressed", get(showCorrectAnswer));
4808
- set_text(text, `${get(showCorrectAnswer) ? "Hide" : "Show"} correct answer`);
4809
- });
7350
+ template_effect(($0) => {
7351
+ set_attribute(button, "aria-pressed", get$1(showingCorrectAnswer));
7352
+ set_text(text, $0);
7353
+ }, [() => tCommon(get$1(showingCorrectAnswer) ? "hideCorrectAnswer" : "showCorrectAnswer", model()?.language)]);
4810
7354
  delegated("click", button, toggleCorrectAnswer);
4811
7355
  append($$anchor, button);
4812
7356
  };
4813
- if_block(node_1, ($$render) => {
4814
- if (get(isEvaluateMode) && get(isIncorrect)) $$render(consequent_2);
7357
+ if_block(node_2, ($$render) => {
7358
+ if (get$1(canShowCorrectAnswer)) $$render(consequent_3);
4815
7359
  });
4816
- var div_2 = sibling(node_1, 2);
4817
- var node_3 = child(div_2);
4818
- var consequent_3 = ($$anchor) => {
7360
+ var div_2 = sibling(node_2, 2);
7361
+ var node_4 = child(div_2);
7362
+ var consequent_4 = ($$anchor) => {
4819
7363
  append($$anchor, root_4());
4820
7364
  };
4821
- if_block(node_3, ($$render) => {
4822
- if (get(isEvaluateMode) && (get(isCorrect) || get(showCorrectAnswer))) $$render(consequent_3);
4823
- });
4824
- var node_4 = sibling(node_3, 2);
4825
- var consequent_4 = ($$anchor) => {
7365
+ var consequent_5 = ($$anchor) => {
4826
7366
  append($$anchor, root_5());
4827
7367
  };
4828
7368
  if_block(node_4, ($$render) => {
4829
- if (get(isEvaluateMode) && get(isIncorrect) && !get(showCorrectAnswer)) $$render(consequent_4);
7369
+ if (get$1(isEvaluateMode) && (get$1(isCorrect) || get$1(showingCorrectAnswer))) $$render(consequent_4);
7370
+ else if (get$1(isEvaluateMode) && get$1(isIncorrect)) $$render(consequent_5, 1);
4830
7371
  });
4831
7372
  var input = sibling(node_4, 2);
4832
- let styles;
4833
- bind_this(input, ($$value) => inputElement = $$value, () => inputElement);
7373
+ let classes;
7374
+ bind_this(input, ($$value) => set(inputElement, $$value), () => get$1(inputElement));
7375
+ var span_4 = sibling(input, 2);
7376
+ var text_1 = only_child(span_4, true);
4834
7377
  reset(div_2);
4835
7378
  reset(div);
4836
- template_effect(() => {
4837
- input.disabled = $$props?.model?.disabled;
4838
- input.readOnly = get(showCorrectAnswer);
4839
- styles = set_style(input, "", styles, {
4840
- border: get(isEvaluateMode) && (get(isCorrect) || get(showCorrectAnswer)) ? "solid 2px #0EA449" : get(isEvaluateMode) && get(isIncorrect) && !get(showCorrectAnswer) ? "solid 2px #BF0D00" : "solid 1px #d1d5db",
4841
- color: get(isEvaluateMode) && (get(isCorrect) || get(isIncorrect)) ? "black" : ""
7379
+ template_effect(($0, $1) => {
7380
+ classes = set_class(input, 1, "simple-cloze-input svelte-1glps5n", null, classes, {
7381
+ "simple-cloze-input--correct": get$1(isEvaluateMode) && (get$1(isCorrect) || get$1(showingCorrectAnswer)),
7382
+ "simple-cloze-input--incorrect": get$1(isEvaluateMode) && get$1(isIncorrect) && !get$1(showingCorrectAnswer)
4842
7383
  });
4843
- });
7384
+ set_attribute(input, "placeholder", $0);
7385
+ set_attribute(input, "aria-labelledby", get$1(prompt) ? promptId : void 0);
7386
+ set_attribute(input, "aria-label", $1);
7387
+ set_attribute(input, "aria-describedby", get$1(feedbackText) ? feedbackId : void 0);
7388
+ input.disabled = model()?.disabled;
7389
+ input.readOnly = get$1(showingCorrectAnswer);
7390
+ set_attribute(span_4, "id", feedbackId);
7391
+ set_text(text_1, get$1(feedbackText));
7392
+ }, [() => t("placeholder", model()?.language), () => get$1(prompt) ? void 0 : t("answerInput", model()?.language)]);
7393
+ delegated("input", input, handleInput);
4844
7394
  append($$anchor, div);
4845
- pop();
7395
+ return pop($$exports);
4846
7396
  }
4847
- delegate(["click"]);
7397
+ delegate(["click", "input"]);
4848
7398
  create_custom_element(SimpleCloze, {
4849
7399
  model: { type: "Object" },
4850
7400
  session: { type: "Object" }
@@ -4855,31 +7405,41 @@ var SvelteElementClass = SimpleCloze.element;
4855
7405
  var SimpleClozeElement = class extends SvelteElementClass {
4856
7406
  constructor(..._args) {
4857
7407
  super(..._args);
4858
- _defineProperty(this, "_internalSession", null);
4859
7408
  _defineProperty(
4860
7409
  this,
4861
7410
  /**
4862
- * The session object the player handed us. A player reads the learner's
4863
- * response back off this object, so every update is written into it as well
4864
- * as into the copy the component renders from.
7411
+ * The session object the player handed us, which `session` returns. A player
7412
+ * reads the learner's response back off this object, so every update is
7413
+ * written into it; the component renders from a fresh copy so its `$derived`
7414
+ * reads re-run.
4865
7415
  */
4866
7416
  "_playerSession",
4867
7417
  null
4868
7418
  );
4869
7419
  _defineProperty(this, "_model", null);
4870
7420
  _defineProperty(this, "_isComplete", () => {
4871
- const response = this._internalSession?.response;
4872
- return typeof response === "string" && response.trim().length > 0;
4873
- });
4874
- _defineProperty(this, "_dispatchModelSet", () => {
4875
- this.dispatchEvent(new e(this.tagName.toLowerCase(), this._isComplete(), this._model !== void 0));
7421
+ const value = this._playerSession?.value;
7422
+ return typeof value === "string" && value.trim().length > 0;
4876
7423
  });
7424
+ _defineProperty(
7425
+ this,
7426
+ /**
7427
+ * Dispatched a microtask later: on load a player sets the model and then the
7428
+ * session in the same task (`element.model = …; element.session = …`), and
7429
+ * `complete` can only report a restored response once the session is here.
7430
+ */
7431
+ "_dispatchModelSet",
7432
+ () => {
7433
+ queueMicrotask(() => {
7434
+ this.dispatchEvent(new s$2(this.tagName.toLowerCase(), this._isComplete(), this._model !== void 0));
7435
+ });
7436
+ }
7437
+ );
4877
7438
  _defineProperty(this, "_dispatchSessionChanged", () => {
4878
- this.dispatchEvent(new t$1(this.tagName.toLowerCase(), this._isComplete()));
7439
+ this.dispatchEvent(new c$2(this.tagName.toLowerCase(), this._isComplete()));
4879
7440
  });
4880
7441
  _defineProperty(this, "onSessionChange", (updatedSession) => {
4881
- i(this._playerSession, updatedSession);
4882
- this._internalSession = updatedSession;
7442
+ this._playerSession = a$1(this._playerSession, updatedSession);
4883
7443
  super.session = updatedSession;
4884
7444
  this._dispatchSessionChanged();
4885
7445
  });
@@ -4894,12 +7454,11 @@ var SimpleClozeElement = class extends SvelteElementClass {
4894
7454
  }
4895
7455
  set session(s) {
4896
7456
  this._playerSession = s;
4897
- this._internalSession = s;
4898
7457
  super.session = s;
4899
7458
  this._dispatchSessionChanged();
4900
7459
  }
4901
7460
  get session() {
4902
- return this._internalSession;
7461
+ return this._playerSession;
4903
7462
  }
4904
7463
  connectedCallback() {
4905
7464
  super.connectedCallback();