@pie-element/venn-classification 0.1.1-next.5 → 0.1.1-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.
@@ -1,13 +1,12 @@
1
1
  var defaults_default = {
2
2
  model: {
3
- id: "1",
4
- element: "venn-classification",
5
3
  prompt: "<p>Sort each tile into the correct region of the Venn diagram.</p>",
6
4
  promptEnabled: true,
7
5
  circles: [{ label: "Set A" }, { label: "Set B" }],
8
6
  tiles: [],
9
7
  regionLabels: {},
10
- scoringPolicy: "partialPerTile"
8
+ scoringPolicy: "partialPerTile",
9
+ teacherInstructionsEnabled: true
11
10
  },
12
11
  configuration: {
13
12
  prompt: {
@@ -21,8 +20,2354 @@ var defaults_default = {
21
20
  }
22
21
  };
23
22
  //#endregion
23
+ //#region ../../shared/translator/dist/en.js
24
+ var e$1 = {
25
+ translation: {
26
+ categorize: {
27
+ limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
28
+ maxChoicesPerCategoryRestriction: "To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s]."
29
+ },
30
+ ebsr: { part: "Part {{index}}" },
31
+ numberLine: {
32
+ addElementLimit_one: "You can only add {{count}} element",
33
+ addElementLimit_other: "You can only add {{count}} elements",
34
+ clearAll: "Clear all"
35
+ },
36
+ imageClozeAssociation: {
37
+ reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
38
+ reachedLimit_other: "Full"
39
+ },
40
+ drawingResponse: {
41
+ fillColor: "Fill color",
42
+ outlineColor: "Outline color",
43
+ noFill: "No fill",
44
+ lightblue: "Light blue",
45
+ lightyellow: "Light yellow",
46
+ red: "Red",
47
+ orange: "Orange",
48
+ yellow: "Yellow",
49
+ violet: "Violet",
50
+ blue: "Blue",
51
+ green: "Green",
52
+ white: "White",
53
+ black: "Black",
54
+ onDoubleClick: "Double click to edit this text. Press Enter to submit."
55
+ },
56
+ charting: {
57
+ addCategory: "Add category",
58
+ actions: "Actions",
59
+ add: "Add",
60
+ delete: "Delete",
61
+ newLabel: "New label",
62
+ reachedLimit_other: "There can't be more than {{count}} categories.",
63
+ keyLegend: {
64
+ incorrectAnswer: "Student incorrect answer",
65
+ correctAnswer: "Student correct answer",
66
+ correctKeyAnswer: "Answer key correct"
67
+ }
68
+ },
69
+ graphing: {
70
+ point: "Point",
71
+ circle: "Circle",
72
+ line: "Line",
73
+ parabola: "Parabola",
74
+ absolute: "Absolute Value",
75
+ exponential: "Exponential",
76
+ polygon: "Polygon",
77
+ ray: "Ray",
78
+ segment: "Segment",
79
+ sine: "Sine",
80
+ vector: "Vector",
81
+ label: "Label",
82
+ redo: "Redo",
83
+ reset: "Reset"
84
+ },
85
+ 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." },
86
+ mcPopulatedBlank: {
87
+ answerChoices: "Answer choices",
88
+ blankLabel: "blank",
89
+ emptyBlank: "(blank)",
90
+ blankPreSelectionHint: "The answer you choose will appear on the blank line above.",
91
+ correctAnswerSelected: "Correct answer selected",
92
+ incorrectAnswerSelected: "Incorrect answer selected",
93
+ selectedAnswerImage: "Selected answer image",
94
+ choiceImage: "Choice {{id}}",
95
+ clickToEnableAutoplay: "Click to enable audio autoplay",
96
+ audioResourceUnavailable: "Audio is enabled but no playable audio URL is configured.",
97
+ listen: "Listen",
98
+ listenSilentAlt: "Repeat instructions",
99
+ listenPlayingAlt: "Instructions are playing",
100
+ printAudio: "Audio:",
101
+ printTranscript: "Transcript:",
102
+ printKey: "(key)"
103
+ },
104
+ multipleChoice: {
105
+ minSelections: "Select at least {{minSelections}}.",
106
+ maxSelections_one: "Only {{maxSelections}} answer is allowed.",
107
+ maxSelections_other: "Only {{maxSelections}} answers are allowed.",
108
+ minmaxSelections_equal: "Select {{minSelections}}.",
109
+ minmaxSelections_range: "Select between {{minSelections}} and {{maxSelections}}."
110
+ },
111
+ selectText: {
112
+ correctAnswerSelected: "Correct",
113
+ correctAnswerNotSelected: "Correct Answer Not Selected",
114
+ incorrectSelection: "Incorrect Selection",
115
+ key: "Key"
116
+ },
117
+ simpleCloze: {
118
+ correctAnswerShown: "Correct answer",
119
+ correct: "Correct",
120
+ incorrect: "Incorrect",
121
+ unanswered: "No answer",
122
+ placeholder: "Enter your answer...",
123
+ answerInput: "Your answer",
124
+ printCorrectAnswer: "Correct answer:",
125
+ printAnswerBlank: "Answer blank"
126
+ },
127
+ vennClassification: {
128
+ tray: "Tiles to classify",
129
+ unknownTarget: "unknown",
130
+ cancelled: "Cancelled",
131
+ returnedToTray: "{{name}} returned to tray",
132
+ placedIn: "{{name}} placed in {{target}}",
133
+ pickedUp: "Picked up {{name}}",
134
+ pickedUpWithKeyboard: "Picked up {{name}}, drop target: {{target}}. Use arrow keys to choose a drop target, Enter to drop, Escape to cancel.",
135
+ dropTarget: "Drop target: {{target}}",
136
+ unsupportedCircles_one: "This diagram cannot be shown: it has {{count}} circle, and only {{supported}} are supported.",
137
+ unsupportedCircles_other: "This diagram cannot be shown: it has {{count}} circles, and only {{supported}} are supported.",
138
+ setNumber: "Set {{number}}",
139
+ regionOnly: "{{set}} only",
140
+ regionNeither: "Neither {{first}} nor {{second}}",
141
+ regionNoneOf: "None of {{sets}}",
142
+ regionAndSeparator: " and ",
143
+ tileFallbackName: "Tile",
144
+ tileNotPlaced: "not placed",
145
+ tileInRegion: "in {{region}}",
146
+ tileCorrect: "correct",
147
+ tileIncorrect: "incorrect"
148
+ }
149
+ },
150
+ common: {
151
+ undo: "Undo",
152
+ clearAll: "Clear all",
153
+ correct: "Correct",
154
+ incorrect: "Incorrect",
155
+ showCorrectAnswer: "Show correct answer",
156
+ hideCorrectAnswer: "Hide correct answer",
157
+ showTeacherInstructions: "Show Teacher Instructions",
158
+ hideTeacherInstructions: "Hide Teacher Instructions",
159
+ 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.",
160
+ warning: "Warning",
161
+ showNote: "Show Note",
162
+ hideNote: "Hide Note",
163
+ cancel: "Cancel"
164
+ }
165
+ };
166
+ //#endregion
167
+ //#region ../../shared/translator/dist/es.js
168
+ var e = {
169
+ translation: {
170
+ categorize: {
171
+ limitMaxChoicesPerCategory: "Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
172
+ maxChoicesPerCategoryRestriction: "Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta"
173
+ },
174
+ ebsr: { part: "Parte {{index}}" },
175
+ numberLine: {
176
+ addElementLimit_one: "Solo puedes agregar {{count}} elemento",
177
+ addElementLimit_other: "Solo puedes agregar {{count}} elementos",
178
+ clearAll: "Borrar todo"
179
+ },
180
+ imageClozeAssociation: {
181
+ reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
182
+ reachedLimit_other: "Lleno"
183
+ },
184
+ drawingResponse: {
185
+ fillColor: "Color de relleno",
186
+ outlineColor: "Color del contorno",
187
+ noFill: "Sin relleno",
188
+ lightblue: "Azul claro",
189
+ lightyellow: "Amarillo claro",
190
+ red: "Rojo",
191
+ orange: "Naranja",
192
+ yellow: "Amarillo",
193
+ violet: "Violeta",
194
+ blue: "Azul",
195
+ green: "Verde",
196
+ white: "Blanco",
197
+ black: "Negro",
198
+ onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
199
+ },
200
+ charting: {
201
+ addCategory: "Añadir categoría",
202
+ actions: "Acciones",
203
+ add: "Añadir",
204
+ delete: "Eliminar",
205
+ newLabel: "Nueva etiqueta",
206
+ reachedLimit_other: "No puede haber más de {{count}} categorías.",
207
+ keyLegend: {
208
+ incorrectAnswer: "Respuesta incorrecta del estudiante",
209
+ correctAnswer: "Respuesta correcta del estudiante",
210
+ correctKeyAnswer: "Clave de respuesta correcta"
211
+ }
212
+ },
213
+ graphing: {
214
+ point: "Punto",
215
+ circle: "Circulo",
216
+ line: "Línea",
217
+ parabola: "Parábola",
218
+ absolute: "Valor absoluto",
219
+ exponential: "Exponencial",
220
+ polygon: "Polígono",
221
+ ray: "Semirrecta",
222
+ segment: "Segmento ",
223
+ sine: "Seno",
224
+ vector: "Vector",
225
+ label: "Etiqueta",
226
+ redo: "Rehacer",
227
+ reset: "Reiniciar"
228
+ },
229
+ 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." },
230
+ mcPopulatedBlank: {
231
+ answerChoices: "Opciones de respuesta",
232
+ blankLabel: "espacio en blanco",
233
+ emptyBlank: "(en blanco)",
234
+ blankPreSelectionHint: "La respuesta que elijas aparecerá en la línea en blanco de arriba.",
235
+ correctAnswerSelected: "Respuesta correcta seleccionada",
236
+ incorrectAnswerSelected: "Respuesta incorrecta seleccionada",
237
+ selectedAnswerImage: "Imagen de la respuesta seleccionada",
238
+ choiceImage: "Opción {{id}}",
239
+ clickToEnableAutoplay: "Haz clic para activar la reproducción automática del audio",
240
+ audioResourceUnavailable: "El audio está activado, pero no hay una URL de audio reproducible configurada.",
241
+ listen: "Escuchar",
242
+ listenSilentAlt: "Escuchar. Repetir las instrucciones.",
243
+ listenPlayingAlt: "Escuchar. Estas son las instrucciones.",
244
+ printAudio: "Audio:",
245
+ printTranscript: "Transcripción:",
246
+ printKey: "(clave)"
247
+ },
248
+ multipleChoice: {
249
+ minSelections: "Seleccione al menos {{minSelections}}.",
250
+ maxSelections_one: "Sólo se permite {{maxSelections}} respuesta.",
251
+ maxSelections_other: "Sólo se permiten {{maxSelections}} respuestas.",
252
+ minmaxSelections_equal: "Seleccione {{minSelections}}.",
253
+ minmaxSelections_range: "Seleccione entre {{minSelections}} y {{maxSelections}}."
254
+ },
255
+ selectText: {
256
+ correctAnswerSelected: "Respuesta Correcta",
257
+ correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
258
+ incorrectSelection: "Selección Incorrecta",
259
+ key: "Clave"
260
+ },
261
+ simpleCloze: {
262
+ correctAnswerShown: "Respuesta correcta",
263
+ correct: "Correcto",
264
+ incorrect: "Incorrecto",
265
+ unanswered: "Sin respuesta",
266
+ placeholder: "Escribe tu respuesta...",
267
+ answerInput: "Tu respuesta",
268
+ printCorrectAnswer: "Respuesta correcta:",
269
+ printAnswerBlank: "Espacio para la respuesta"
270
+ },
271
+ vennClassification: {
272
+ tray: "Fichas para clasificar",
273
+ unknownTarget: "desconocido",
274
+ cancelled: "Cancelado",
275
+ returnedToTray: "Se devolvió {{name}} a la bandeja",
276
+ placedIn: "Se colocó {{name}} en {{target}}",
277
+ pickedUp: "Se tomó {{name}}",
278
+ pickedUpWithKeyboard: "Se tomó {{name}}, destino: {{target}}. Usa las flechas para elegir un destino, Enter para soltar y Escape para cancelar.",
279
+ dropTarget: "Destino: {{target}}",
280
+ unsupportedCircles_one: "No se puede mostrar este diagrama: tiene {{count}} círculo, y solo se admiten {{supported}}.",
281
+ unsupportedCircles_other: "No se puede mostrar este diagrama: tiene {{count}} círculos, y solo se admiten {{supported}}.",
282
+ setNumber: "Conjunto {{number}}",
283
+ regionOnly: "Solo {{set}}",
284
+ regionNeither: "Ni {{first}} ni {{second}}",
285
+ regionNoneOf: "Ninguno de {{sets}}",
286
+ regionAndSeparator: " y ",
287
+ tileFallbackName: "Ficha",
288
+ tileNotPlaced: "sin colocar",
289
+ tileInRegion: "en {{region}}",
290
+ tileCorrect: "correcta",
291
+ tileIncorrect: "incorrecta"
292
+ }
293
+ },
294
+ common: {
295
+ undo: "Deshacer",
296
+ clearAll: "Borrar todo",
297
+ correct: "Correcto",
298
+ incorrect: "Incorrecto",
299
+ showCorrectAnswer: "Mostrar respuesta correcta",
300
+ hideCorrectAnswer: "Ocultar respuesta correcta",
301
+ showTeacherInstructions: "Mostrar instrucciones para el maestro",
302
+ hideTeacherInstructions: "Ocultar instrucciones para el maestro",
303
+ 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.",
304
+ warning: "Advertencia",
305
+ showNote: "Mostrar Nota",
306
+ hideNote: "Ocultar Nota",
307
+ cancel: "Cancelar"
308
+ }
309
+ };
310
+ //#endregion
311
+ //#region ../../../node_modules/.bun/i18next@25.10.10+1fb4c65d43e298b9/node_modules/i18next/dist/esm/i18next.js
312
+ var isString = (obj) => typeof obj === "string";
313
+ var defer = () => {
314
+ let res;
315
+ let rej;
316
+ const promise = new Promise((resolve, reject) => {
317
+ res = resolve;
318
+ rej = reject;
319
+ });
320
+ promise.resolve = res;
321
+ promise.reject = rej;
322
+ return promise;
323
+ };
324
+ var makeString = (object) => {
325
+ if (object == null) return "";
326
+ return "" + object;
327
+ };
328
+ var copy = (a, s, t) => {
329
+ a.forEach((m) => {
330
+ if (s[m]) t[m] = s[m];
331
+ });
332
+ };
333
+ var lastOfPathSeparatorRegExp = /###/g;
334
+ var cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
335
+ var canNotTraverseDeeper = (object) => !object || isString(object);
336
+ var getLastOfPath = (object, path, Empty) => {
337
+ const stack = !isString(path) ? path : path.split(".");
338
+ let stackIndex = 0;
339
+ while (stackIndex < stack.length - 1) {
340
+ if (canNotTraverseDeeper(object)) return {};
341
+ const key = cleanKey(stack[stackIndex]);
342
+ if (!object[key] && Empty) object[key] = new Empty();
343
+ if (Object.prototype.hasOwnProperty.call(object, key)) object = object[key];
344
+ else object = {};
345
+ ++stackIndex;
346
+ }
347
+ if (canNotTraverseDeeper(object)) return {};
348
+ return {
349
+ obj: object,
350
+ k: cleanKey(stack[stackIndex])
351
+ };
352
+ };
353
+ var setPath = (object, path, newValue) => {
354
+ const { obj, k } = getLastOfPath(object, path, Object);
355
+ if (obj !== void 0 || path.length === 1) {
356
+ obj[k] = newValue;
357
+ return;
358
+ }
359
+ let e = path[path.length - 1];
360
+ let p = path.slice(0, path.length - 1);
361
+ let last = getLastOfPath(object, p, Object);
362
+ while (last.obj === void 0 && p.length) {
363
+ e = `${p[p.length - 1]}.${e}`;
364
+ p = p.slice(0, p.length - 1);
365
+ last = getLastOfPath(object, p, Object);
366
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") last.obj = void 0;
367
+ }
368
+ last.obj[`${last.k}.${e}`] = newValue;
369
+ };
370
+ var pushPath = (object, path, newValue, concat) => {
371
+ const { obj, k } = getLastOfPath(object, path, Object);
372
+ obj[k] = obj[k] || [];
373
+ obj[k].push(newValue);
374
+ };
375
+ var getPath = (object, path) => {
376
+ const { obj, k } = getLastOfPath(object, path);
377
+ if (!obj) return void 0;
378
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
379
+ return obj[k];
380
+ };
381
+ var getPathWithDefaults = (data, defaultData, key) => {
382
+ const value = getPath(data, key);
383
+ if (value !== void 0) return value;
384
+ return getPath(defaultData, key);
385
+ };
386
+ var deepExtend = (target, source, overwrite) => {
387
+ 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) {
388
+ if (overwrite) target[prop] = source[prop];
389
+ } else deepExtend(target[prop], source[prop], overwrite);
390
+ else target[prop] = source[prop];
391
+ return target;
392
+ };
393
+ var regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
394
+ var _entityMap = {
395
+ "&": "&amp;",
396
+ "<": "&lt;",
397
+ ">": "&gt;",
398
+ "\"": "&quot;",
399
+ "'": "&#39;",
400
+ "/": "&#x2F;"
401
+ };
402
+ var escape = (data) => {
403
+ if (isString(data)) return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
404
+ return data;
405
+ };
406
+ var RegExpCache = class {
407
+ constructor(capacity) {
408
+ this.capacity = capacity;
409
+ this.regExpMap = /* @__PURE__ */ new Map();
410
+ this.regExpQueue = [];
411
+ }
412
+ getRegExp(pattern) {
413
+ const regExpFromCache = this.regExpMap.get(pattern);
414
+ if (regExpFromCache !== void 0) return regExpFromCache;
415
+ const regExpNew = new RegExp(pattern);
416
+ if (this.regExpQueue.length === this.capacity) this.regExpMap.delete(this.regExpQueue.shift());
417
+ this.regExpMap.set(pattern, regExpNew);
418
+ this.regExpQueue.push(pattern);
419
+ return regExpNew;
420
+ }
421
+ };
422
+ var chars = [
423
+ " ",
424
+ ",",
425
+ "?",
426
+ "!",
427
+ ";"
428
+ ];
429
+ var looksLikeObjectPathRegExpCache = new RegExpCache(20);
430
+ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
431
+ nsSeparator = nsSeparator || "";
432
+ keySeparator = keySeparator || "";
433
+ const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
434
+ if (possibleChars.length === 0) return true;
435
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
436
+ let matched = !r.test(key);
437
+ if (!matched) {
438
+ const ki = key.indexOf(keySeparator);
439
+ if (ki > 0 && !r.test(key.substring(0, ki))) matched = true;
440
+ }
441
+ return matched;
442
+ };
443
+ var deepFind = (obj, path, keySeparator = ".") => {
444
+ if (!obj) return void 0;
445
+ if (obj[path]) {
446
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
447
+ return obj[path];
448
+ }
449
+ const tokens = path.split(keySeparator);
450
+ let current = obj;
451
+ for (let i = 0; i < tokens.length;) {
452
+ if (!current || typeof current !== "object") return;
453
+ let next;
454
+ let nextPath = "";
455
+ for (let j = i; j < tokens.length; ++j) {
456
+ if (j !== i) nextPath += keySeparator;
457
+ nextPath += tokens[j];
458
+ next = current[nextPath];
459
+ if (next !== void 0) {
460
+ if ([
461
+ "string",
462
+ "number",
463
+ "boolean"
464
+ ].indexOf(typeof next) > -1 && j < tokens.length - 1) continue;
465
+ i += j - i + 1;
466
+ break;
467
+ }
468
+ }
469
+ current = next;
470
+ }
471
+ return current;
472
+ };
473
+ var getCleanedCode = (code) => code?.replace(/_/g, "-");
474
+ var consoleLogger = {
475
+ type: "logger",
476
+ log(args) {
477
+ this.output("log", args);
478
+ },
479
+ warn(args) {
480
+ this.output("warn", args);
481
+ },
482
+ error(args) {
483
+ this.output("error", args);
484
+ },
485
+ output(type, args) {
486
+ console?.[type]?.apply?.(console, args);
487
+ }
488
+ };
489
+ var baseLogger = new class Logger {
490
+ constructor(concreteLogger, options = {}) {
491
+ this.init(concreteLogger, options);
492
+ }
493
+ init(concreteLogger, options = {}) {
494
+ this.prefix = options.prefix || "i18next:";
495
+ this.logger = concreteLogger || consoleLogger;
496
+ this.options = options;
497
+ this.debug = options.debug;
498
+ }
499
+ log(...args) {
500
+ return this.forward(args, "log", "", true);
501
+ }
502
+ warn(...args) {
503
+ return this.forward(args, "warn", "", true);
504
+ }
505
+ error(...args) {
506
+ return this.forward(args, "error", "");
507
+ }
508
+ deprecate(...args) {
509
+ return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
510
+ }
511
+ forward(args, lvl, prefix, debugOnly) {
512
+ if (debugOnly && !this.debug) return null;
513
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
514
+ return this.logger[lvl](args);
515
+ }
516
+ create(moduleName) {
517
+ return new Logger(this.logger, {
518
+ prefix: `${this.prefix}:${moduleName}:`,
519
+ ...this.options
520
+ });
521
+ }
522
+ clone(options) {
523
+ options = options || this.options;
524
+ options.prefix = options.prefix || this.prefix;
525
+ return new Logger(this.logger, options);
526
+ }
527
+ }();
528
+ var EventEmitter = class {
529
+ constructor() {
530
+ this.observers = {};
531
+ }
532
+ on(events, listener) {
533
+ events.split(" ").forEach((event) => {
534
+ if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
535
+ const numListeners = this.observers[event].get(listener) || 0;
536
+ this.observers[event].set(listener, numListeners + 1);
537
+ });
538
+ return this;
539
+ }
540
+ off(event, listener) {
541
+ if (!this.observers[event]) return;
542
+ if (!listener) {
543
+ delete this.observers[event];
544
+ return;
545
+ }
546
+ this.observers[event].delete(listener);
547
+ }
548
+ emit(event, ...args) {
549
+ if (this.observers[event]) Array.from(this.observers[event].entries()).forEach(([observer, numTimesAdded]) => {
550
+ for (let i = 0; i < numTimesAdded; i++) observer(...args);
551
+ });
552
+ if (this.observers["*"]) Array.from(this.observers["*"].entries()).forEach(([observer, numTimesAdded]) => {
553
+ for (let i = 0; i < numTimesAdded; i++) observer.apply(observer, [event, ...args]);
554
+ });
555
+ }
556
+ };
557
+ var ResourceStore = class extends EventEmitter {
558
+ constructor(data, options = {
559
+ ns: ["translation"],
560
+ defaultNS: "translation"
561
+ }) {
562
+ super();
563
+ this.data = data || {};
564
+ this.options = options;
565
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
566
+ if (this.options.ignoreJSONStructure === void 0) this.options.ignoreJSONStructure = true;
567
+ }
568
+ addNamespaces(ns) {
569
+ if (this.options.ns.indexOf(ns) < 0) this.options.ns.push(ns);
570
+ }
571
+ removeNamespaces(ns) {
572
+ const index = this.options.ns.indexOf(ns);
573
+ if (index > -1) this.options.ns.splice(index, 1);
574
+ }
575
+ getResource(lng, ns, key, options = {}) {
576
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
577
+ const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
578
+ let path;
579
+ if (lng.indexOf(".") > -1) path = lng.split(".");
580
+ else {
581
+ path = [lng, ns];
582
+ if (key) if (Array.isArray(key)) path.push(...key);
583
+ else if (isString(key) && keySeparator) path.push(...key.split(keySeparator));
584
+ else path.push(key);
585
+ }
586
+ const result = getPath(this.data, path);
587
+ if (!result && !ns && !key && lng.indexOf(".") > -1) {
588
+ lng = path[0];
589
+ ns = path[1];
590
+ key = path.slice(2).join(".");
591
+ }
592
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
593
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
594
+ }
595
+ addResource(lng, ns, key, value, options = { silent: false }) {
596
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
597
+ let path = [lng, ns];
598
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
599
+ if (lng.indexOf(".") > -1) {
600
+ path = lng.split(".");
601
+ value = ns;
602
+ ns = path[1];
603
+ }
604
+ this.addNamespaces(ns);
605
+ setPath(this.data, path, value);
606
+ if (!options.silent) this.emit("added", lng, ns, key, value);
607
+ }
608
+ addResources(lng, ns, resources, options = { silent: false }) {
609
+ for (const m in resources) if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], { silent: true });
610
+ if (!options.silent) this.emit("added", lng, ns, resources);
611
+ }
612
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
613
+ silent: false,
614
+ skipCopy: false
615
+ }) {
616
+ let path = [lng, ns];
617
+ if (lng.indexOf(".") > -1) {
618
+ path = lng.split(".");
619
+ deep = resources;
620
+ resources = ns;
621
+ ns = path[1];
622
+ }
623
+ this.addNamespaces(ns);
624
+ let pack = getPath(this.data, path) || {};
625
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
626
+ if (deep) deepExtend(pack, resources, overwrite);
627
+ else pack = {
628
+ ...pack,
629
+ ...resources
630
+ };
631
+ setPath(this.data, path, pack);
632
+ if (!options.silent) this.emit("added", lng, ns, resources);
633
+ }
634
+ removeResourceBundle(lng, ns) {
635
+ if (this.hasResourceBundle(lng, ns)) delete this.data[lng][ns];
636
+ this.removeNamespaces(ns);
637
+ this.emit("removed", lng, ns);
638
+ }
639
+ hasResourceBundle(lng, ns) {
640
+ return this.getResource(lng, ns) !== void 0;
641
+ }
642
+ getResourceBundle(lng, ns) {
643
+ if (!ns) ns = this.options.defaultNS;
644
+ return this.getResource(lng, ns);
645
+ }
646
+ getDataByLanguage(lng) {
647
+ return this.data[lng];
648
+ }
649
+ hasLanguageSomeTranslations(lng) {
650
+ const data = this.getDataByLanguage(lng);
651
+ return !!(data && Object.keys(data) || []).find((v) => data[v] && Object.keys(data[v]).length > 0);
652
+ }
653
+ toJSON() {
654
+ return this.data;
655
+ }
656
+ };
657
+ var postProcessor = {
658
+ processors: {},
659
+ addPostProcessor(module) {
660
+ this.processors[module.name] = module;
661
+ },
662
+ handle(processors, value, key, options, translator) {
663
+ processors.forEach((processor) => {
664
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
665
+ });
666
+ return value;
667
+ }
668
+ };
669
+ var PATH_KEY = Symbol("i18next/PATH_KEY");
670
+ function createProxy() {
671
+ const state = [];
672
+ const handler = Object.create(null);
673
+ let proxy;
674
+ handler.get = (target, key) => {
675
+ proxy?.revoke?.();
676
+ if (key === PATH_KEY) return state;
677
+ state.push(key);
678
+ proxy = Proxy.revocable(target, handler);
679
+ return proxy.proxy;
680
+ };
681
+ return Proxy.revocable(Object.create(null), handler).proxy;
682
+ }
683
+ function keysFromSelector(selector, opts) {
684
+ const { [PATH_KEY]: path } = selector(createProxy());
685
+ const keySeparator = opts?.keySeparator ?? ".";
686
+ const nsSeparator = opts?.nsSeparator ?? ":";
687
+ if (path.length > 1 && nsSeparator) {
688
+ const ns = opts?.ns;
689
+ const nsArray = Array.isArray(ns) ? ns : null;
690
+ if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
691
+ }
692
+ return path.join(keySeparator);
693
+ }
694
+ var checkedLoadedFor = {};
695
+ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
696
+ var Translator = class Translator extends EventEmitter {
697
+ constructor(services, options = {}) {
698
+ super();
699
+ copy([
700
+ "resourceStore",
701
+ "languageUtils",
702
+ "pluralResolver",
703
+ "interpolator",
704
+ "backendConnector",
705
+ "i18nFormat",
706
+ "utils"
707
+ ], services, this);
708
+ this.options = options;
709
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
710
+ this.logger = baseLogger.create("translator");
711
+ }
712
+ changeLanguage(lng) {
713
+ if (lng) this.language = lng;
714
+ }
715
+ exists(key, o = { interpolation: {} }) {
716
+ const opt = { ...o };
717
+ if (key == null) return false;
718
+ const resolved = this.resolve(key, opt);
719
+ if (resolved?.res === void 0) return false;
720
+ const isObject = shouldHandleAsObject(resolved.res);
721
+ if (opt.returnObjects === false && isObject) return false;
722
+ return true;
723
+ }
724
+ extractFromKey(key, opt) {
725
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
726
+ if (nsSeparator === void 0) nsSeparator = ":";
727
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
728
+ let namespaces = opt.ns || this.options.defaultNS || [];
729
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
730
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
731
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
732
+ const m = key.match(this.interpolator.nestingRegexp);
733
+ if (m && m.length > 0) return {
734
+ key,
735
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
736
+ };
737
+ const parts = key.split(nsSeparator);
738
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
739
+ key = parts.join(keySeparator);
740
+ }
741
+ return {
742
+ key,
743
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
744
+ };
745
+ }
746
+ translate(keys, o, lastKey) {
747
+ let opt = typeof o === "object" ? { ...o } : o;
748
+ if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) opt = this.options.overloadTranslationOptionHandler(arguments);
749
+ if (typeof opt === "object") opt = { ...opt };
750
+ if (!opt) opt = {};
751
+ if (keys == null) return "";
752
+ if (typeof keys === "function") keys = keysFromSelector(keys, {
753
+ ...this.options,
754
+ ...opt
755
+ });
756
+ if (!Array.isArray(keys)) keys = [String(keys)];
757
+ keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
758
+ ...this.options,
759
+ ...opt
760
+ }) : String(k));
761
+ const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
762
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
763
+ const { key, namespaces } = this.extractFromKey(keys[keys.length - 1], opt);
764
+ const namespace = namespaces[namespaces.length - 1];
765
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
766
+ if (nsSeparator === void 0) nsSeparator = ":";
767
+ const lng = opt.lng || this.language;
768
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
769
+ if (lng?.toLowerCase() === "cimode") {
770
+ if (appendNamespaceToCIMode) {
771
+ if (returnDetails) return {
772
+ res: `${namespace}${nsSeparator}${key}`,
773
+ usedKey: key,
774
+ exactUsedKey: key,
775
+ usedLng: lng,
776
+ usedNS: namespace,
777
+ usedParams: this.getUsedParamsDetails(opt)
778
+ };
779
+ return `${namespace}${nsSeparator}${key}`;
780
+ }
781
+ if (returnDetails) return {
782
+ res: key,
783
+ usedKey: key,
784
+ exactUsedKey: key,
785
+ usedLng: lng,
786
+ usedNS: namespace,
787
+ usedParams: this.getUsedParamsDetails(opt)
788
+ };
789
+ return key;
790
+ }
791
+ const resolved = this.resolve(keys, opt);
792
+ let res = resolved?.res;
793
+ const resUsedKey = resolved?.usedKey || key;
794
+ const resExactUsedKey = resolved?.exactUsedKey || key;
795
+ const noObject = [
796
+ "[object Number]",
797
+ "[object Function]",
798
+ "[object RegExp]"
799
+ ];
800
+ const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
801
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
802
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
803
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
804
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
805
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, { ordinal: false }) : "";
806
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
807
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
808
+ let resForObjHndl = res;
809
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) resForObjHndl = defaultValue;
810
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
811
+ const resType = Object.prototype.toString.apply(resForObjHndl);
812
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
813
+ if (!opt.returnObjects && !this.options.returnObjects) {
814
+ if (!this.options.returnedObjectHandler) this.logger.warn("accessing an object - but returnObjects options is not enabled!");
815
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
816
+ ...opt,
817
+ ns: namespaces
818
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
819
+ if (returnDetails) {
820
+ resolved.res = r;
821
+ resolved.usedParams = this.getUsedParamsDetails(opt);
822
+ return resolved;
823
+ }
824
+ return r;
825
+ }
826
+ if (keySeparator) {
827
+ const resTypeIsArray = Array.isArray(resForObjHndl);
828
+ const copy = resTypeIsArray ? [] : {};
829
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
830
+ for (const m in resForObjHndl) if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
831
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
832
+ if (hasDefaultValue && !res) copy[m] = this.translate(deepKey, {
833
+ ...opt,
834
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
835
+ joinArrays: false,
836
+ ns: namespaces
837
+ });
838
+ else copy[m] = this.translate(deepKey, {
839
+ ...opt,
840
+ joinArrays: false,
841
+ ns: namespaces
842
+ });
843
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
844
+ }
845
+ res = copy;
846
+ }
847
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
848
+ res = res.join(joinArrays);
849
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
850
+ } else {
851
+ let usedDefault = false;
852
+ let usedKey = false;
853
+ if (!this.isValidLookup(res) && hasDefaultValue) {
854
+ usedDefault = true;
855
+ res = defaultValue;
856
+ }
857
+ if (!this.isValidLookup(res)) {
858
+ usedKey = true;
859
+ res = key;
860
+ }
861
+ const resForMissing = (opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && usedKey ? void 0 : res;
862
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
863
+ if (usedKey || usedDefault || updateMissing) {
864
+ this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
865
+ if (keySeparator) {
866
+ const fk = this.resolve(key, {
867
+ ...opt,
868
+ keySeparator: false
869
+ });
870
+ 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.");
871
+ }
872
+ let lngs = [];
873
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
874
+ if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) for (let i = 0; i < fallbackLngs.length; i++) lngs.push(fallbackLngs[i]);
875
+ else if (this.options.saveMissingTo === "all") lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
876
+ else lngs.push(opt.lng || this.language);
877
+ const send = (l, k, specificDefaultValue) => {
878
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
879
+ if (this.options.missingKeyHandler) this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
880
+ else if (this.backendConnector?.saveMissing) this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
881
+ this.emit("missingKey", l, namespace, k, res);
882
+ };
883
+ if (this.options.saveMissing) if (this.options.saveMissingPlurals && needsPluralHandling) lngs.forEach((language) => {
884
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
885
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) suffixes.push(`${this.options.pluralSeparator}zero`);
886
+ suffixes.forEach((suffix) => {
887
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
888
+ });
889
+ });
890
+ else send(lngs, key, defaultValue);
891
+ }
892
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
893
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}${nsSeparator}${key}`;
894
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
895
+ }
896
+ if (returnDetails) {
897
+ resolved.res = res;
898
+ resolved.usedParams = this.getUsedParamsDetails(opt);
899
+ return resolved;
900
+ }
901
+ return res;
902
+ }
903
+ extendTranslation(res, key, opt, resolved, lastKey) {
904
+ if (this.i18nFormat?.parse) res = this.i18nFormat.parse(res, {
905
+ ...this.options.interpolation.defaultVariables,
906
+ ...opt
907
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, { resolved });
908
+ else if (!opt.skipInterpolation) {
909
+ if (opt.interpolation) this.interpolator.init({
910
+ ...opt,
911
+ interpolation: {
912
+ ...this.options.interpolation,
913
+ ...opt.interpolation
914
+ }
915
+ });
916
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
917
+ let nestBef;
918
+ if (skipOnVariables) {
919
+ const nb = res.match(this.interpolator.nestingRegexp);
920
+ nestBef = nb && nb.length;
921
+ }
922
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
923
+ if (this.options.interpolation.defaultVariables) data = {
924
+ ...this.options.interpolation.defaultVariables,
925
+ ...data
926
+ };
927
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
928
+ if (skipOnVariables) {
929
+ const na = res.match(this.interpolator.nestingRegexp);
930
+ const nestAft = na && na.length;
931
+ if (nestBef < nestAft) opt.nest = false;
932
+ }
933
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
934
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
935
+ if (lastKey?.[0] === args[0] && !opt.context) {
936
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
937
+ return null;
938
+ }
939
+ return this.translate(...args, key);
940
+ }, opt);
941
+ if (opt.interpolation) this.interpolator.reset();
942
+ }
943
+ const postProcess = opt.postProcess || this.options.postProcess;
944
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
945
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
946
+ i18nResolved: {
947
+ ...resolved,
948
+ usedParams: this.getUsedParamsDetails(opt)
949
+ },
950
+ ...opt
951
+ } : opt, this);
952
+ return res;
953
+ }
954
+ resolve(keys, opt = {}) {
955
+ let found;
956
+ let usedKey;
957
+ let exactUsedKey;
958
+ let usedLng;
959
+ let usedNS;
960
+ if (isString(keys)) keys = [keys];
961
+ if (Array.isArray(keys)) keys = keys.map((k) => typeof k === "function" ? keysFromSelector(k, {
962
+ ...this.options,
963
+ ...opt
964
+ }) : k);
965
+ keys.forEach((k) => {
966
+ if (this.isValidLookup(found)) return;
967
+ const extracted = this.extractFromKey(k, opt);
968
+ const key = extracted.key;
969
+ usedKey = key;
970
+ let namespaces = extracted.namespaces;
971
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
972
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
973
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
974
+ const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
975
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
976
+ namespaces.forEach((ns) => {
977
+ if (this.isValidLookup(found)) return;
978
+ usedNS = ns;
979
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
980
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
981
+ 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!!!");
982
+ }
983
+ codes.forEach((code) => {
984
+ if (this.isValidLookup(found)) return;
985
+ usedLng = code;
986
+ const finalKeys = [key];
987
+ if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
988
+ else {
989
+ let pluralSuffix;
990
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
991
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
992
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
993
+ if (needsPluralHandling) {
994
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
995
+ finalKeys.push(key + pluralSuffix);
996
+ if (needsZeroSuffixLookup) finalKeys.push(key + zeroSuffix);
997
+ }
998
+ if (needsContextHandling) {
999
+ const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
1000
+ finalKeys.push(contextKey);
1001
+ if (needsPluralHandling) {
1002
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
1003
+ finalKeys.push(contextKey + pluralSuffix);
1004
+ if (needsZeroSuffixLookup) finalKeys.push(contextKey + zeroSuffix);
1005
+ }
1006
+ }
1007
+ }
1008
+ let possibleKey;
1009
+ while (possibleKey = finalKeys.pop()) if (!this.isValidLookup(found)) {
1010
+ exactUsedKey = possibleKey;
1011
+ found = this.getResource(code, ns, possibleKey, opt);
1012
+ }
1013
+ });
1014
+ });
1015
+ });
1016
+ return {
1017
+ res: found,
1018
+ usedKey,
1019
+ exactUsedKey,
1020
+ usedLng,
1021
+ usedNS
1022
+ };
1023
+ }
1024
+ isValidLookup(res) {
1025
+ return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
1026
+ }
1027
+ getResource(code, ns, key, options = {}) {
1028
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
1029
+ return this.resourceStore.getResource(code, ns, key, options);
1030
+ }
1031
+ getUsedParamsDetails(options = {}) {
1032
+ const optionsKeys = [
1033
+ "defaultValue",
1034
+ "ordinal",
1035
+ "context",
1036
+ "replace",
1037
+ "lng",
1038
+ "lngs",
1039
+ "fallbackLng",
1040
+ "ns",
1041
+ "keySeparator",
1042
+ "nsSeparator",
1043
+ "returnObjects",
1044
+ "returnDetails",
1045
+ "joinArrays",
1046
+ "postProcess",
1047
+ "interpolation"
1048
+ ];
1049
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
1050
+ let data = useOptionsReplaceForData ? options.replace : options;
1051
+ if (useOptionsReplaceForData && typeof options.count !== "undefined") data.count = options.count;
1052
+ if (this.options.interpolation.defaultVariables) data = {
1053
+ ...this.options.interpolation.defaultVariables,
1054
+ ...data
1055
+ };
1056
+ if (!useOptionsReplaceForData) {
1057
+ data = { ...data };
1058
+ for (const key of optionsKeys) delete data[key];
1059
+ }
1060
+ return data;
1061
+ }
1062
+ static hasDefaultValue(options) {
1063
+ const prefix = "defaultValue";
1064
+ for (const option in options) if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, 12) && void 0 !== options[option]) return true;
1065
+ return false;
1066
+ }
1067
+ };
1068
+ var LanguageUtil = class {
1069
+ constructor(options) {
1070
+ this.options = options;
1071
+ this.supportedLngs = this.options.supportedLngs || false;
1072
+ this.logger = baseLogger.create("languageUtils");
1073
+ }
1074
+ getScriptPartFromCode(code) {
1075
+ code = getCleanedCode(code);
1076
+ if (!code || code.indexOf("-") < 0) return null;
1077
+ const p = code.split("-");
1078
+ if (p.length === 2) return null;
1079
+ p.pop();
1080
+ if (p[p.length - 1].toLowerCase() === "x") return null;
1081
+ return this.formatLanguageCode(p.join("-"));
1082
+ }
1083
+ getLanguagePartFromCode(code) {
1084
+ code = getCleanedCode(code);
1085
+ if (!code || code.indexOf("-") < 0) return code;
1086
+ const p = code.split("-");
1087
+ return this.formatLanguageCode(p[0]);
1088
+ }
1089
+ formatLanguageCode(code) {
1090
+ if (isString(code) && code.indexOf("-") > -1) {
1091
+ let formattedCode;
1092
+ try {
1093
+ formattedCode = Intl.getCanonicalLocales(code)[0];
1094
+ } catch (e) {}
1095
+ if (formattedCode && this.options.lowerCaseLng) formattedCode = formattedCode.toLowerCase();
1096
+ if (formattedCode) return formattedCode;
1097
+ if (this.options.lowerCaseLng) return code.toLowerCase();
1098
+ return code;
1099
+ }
1100
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
1101
+ }
1102
+ isSupportedCode(code) {
1103
+ if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) code = this.getLanguagePartFromCode(code);
1104
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
1105
+ }
1106
+ getBestMatchFromCodes(codes) {
1107
+ if (!codes) return null;
1108
+ let found;
1109
+ codes.forEach((code) => {
1110
+ if (found) return;
1111
+ const cleanedLng = this.formatLanguageCode(code);
1112
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
1113
+ });
1114
+ if (!found && this.options.supportedLngs) codes.forEach((code) => {
1115
+ if (found) return;
1116
+ const lngScOnly = this.getScriptPartFromCode(code);
1117
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
1118
+ const lngOnly = this.getLanguagePartFromCode(code);
1119
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
1120
+ found = this.options.supportedLngs.find((supportedLng) => {
1121
+ if (supportedLng === lngOnly) return supportedLng;
1122
+ if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
1123
+ if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
1124
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
1125
+ });
1126
+ });
1127
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
1128
+ return found;
1129
+ }
1130
+ getFallbackCodes(fallbacks, code) {
1131
+ if (!fallbacks) return [];
1132
+ if (typeof fallbacks === "function") fallbacks = fallbacks(code);
1133
+ if (isString(fallbacks)) fallbacks = [fallbacks];
1134
+ if (Array.isArray(fallbacks)) return fallbacks;
1135
+ if (!code) return fallbacks.default || [];
1136
+ let found = fallbacks[code];
1137
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
1138
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
1139
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
1140
+ if (!found) found = fallbacks.default;
1141
+ return found || [];
1142
+ }
1143
+ toResolveHierarchy(code, fallbackCode) {
1144
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
1145
+ const codes = [];
1146
+ const addCode = (c) => {
1147
+ if (!c) return;
1148
+ if (this.isSupportedCode(c)) codes.push(c);
1149
+ else this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
1150
+ };
1151
+ if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
1152
+ if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
1153
+ if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
1154
+ if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
1155
+ } else if (isString(code)) addCode(this.formatLanguageCode(code));
1156
+ fallbackCodes.forEach((fc) => {
1157
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
1158
+ });
1159
+ return codes;
1160
+ }
1161
+ };
1162
+ var suffixesOrder = {
1163
+ zero: 0,
1164
+ one: 1,
1165
+ two: 2,
1166
+ few: 3,
1167
+ many: 4,
1168
+ other: 5
1169
+ };
1170
+ var dummyRule = {
1171
+ select: (count) => count === 1 ? "one" : "other",
1172
+ resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
1173
+ };
1174
+ var PluralResolver = class {
1175
+ constructor(languageUtils, options = {}) {
1176
+ this.languageUtils = languageUtils;
1177
+ this.options = options;
1178
+ this.logger = baseLogger.create("pluralResolver");
1179
+ this.pluralRulesCache = {};
1180
+ }
1181
+ clearCache() {
1182
+ this.pluralRulesCache = {};
1183
+ }
1184
+ getRule(code, options = {}) {
1185
+ const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
1186
+ const type = options.ordinal ? "ordinal" : "cardinal";
1187
+ const cacheKey = JSON.stringify({
1188
+ cleanedCode,
1189
+ type
1190
+ });
1191
+ if (cacheKey in this.pluralRulesCache) return this.pluralRulesCache[cacheKey];
1192
+ let rule;
1193
+ try {
1194
+ rule = new Intl.PluralRules(cleanedCode, { type });
1195
+ } catch (err) {
1196
+ if (typeof Intl === "undefined") {
1197
+ this.logger.error("No Intl support, please use an Intl polyfill!");
1198
+ return dummyRule;
1199
+ }
1200
+ if (!code.match(/-|_/)) return dummyRule;
1201
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1202
+ rule = this.getRule(lngPart, options);
1203
+ }
1204
+ this.pluralRulesCache[cacheKey] = rule;
1205
+ return rule;
1206
+ }
1207
+ needsPlural(code, options = {}) {
1208
+ let rule = this.getRule(code, options);
1209
+ if (!rule) rule = this.getRule("dev", options);
1210
+ return rule?.resolvedOptions().pluralCategories.length > 1;
1211
+ }
1212
+ getPluralFormsOfKey(code, key, options = {}) {
1213
+ return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
1214
+ }
1215
+ getSuffixes(code, options = {}) {
1216
+ let rule = this.getRule(code, options);
1217
+ if (!rule) rule = this.getRule("dev", options);
1218
+ if (!rule) return [];
1219
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
1220
+ }
1221
+ getSuffix(code, count, options = {}) {
1222
+ const rule = this.getRule(code, options);
1223
+ if (rule) return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
1224
+ this.logger.warn(`no plural rule found for: ${code}`);
1225
+ return this.getSuffix("dev", count, options);
1226
+ }
1227
+ };
1228
+ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
1229
+ let path = getPathWithDefaults(data, defaultData, key);
1230
+ if (!path && ignoreJSONStructure && isString(key)) {
1231
+ path = deepFind(data, key, keySeparator);
1232
+ if (path === void 0) path = deepFind(defaultData, key, keySeparator);
1233
+ }
1234
+ return path;
1235
+ };
1236
+ var regexSafe = (val) => val.replace(/\$/g, "$$$$");
1237
+ var Interpolator = class {
1238
+ constructor(options = {}) {
1239
+ this.logger = baseLogger.create("interpolator");
1240
+ this.options = options;
1241
+ this.format = options?.interpolation?.format || ((value) => value);
1242
+ this.init(options);
1243
+ }
1244
+ init(options = {}) {
1245
+ if (!options.interpolation) options.interpolation = { escapeValue: true };
1246
+ const { escape: escape$1, escapeValue, useRawValueToEscape, prefix, prefixEscaped, suffix, suffixEscaped, formatSeparator, unescapeSuffix, unescapePrefix, nestingPrefix, nestingPrefixEscaped, nestingSuffix, nestingSuffixEscaped, nestingOptionsSeparator, maxReplaces, alwaysFormat } = options.interpolation;
1247
+ this.escape = escape$1 !== void 0 ? escape$1 : escape;
1248
+ this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
1249
+ this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
1250
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
1251
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
1252
+ this.formatSeparator = formatSeparator || ",";
1253
+ this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
1254
+ this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
1255
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
1256
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
1257
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
1258
+ this.maxReplaces = maxReplaces || 1e3;
1259
+ this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
1260
+ this.resetRegExp();
1261
+ }
1262
+ reset() {
1263
+ if (this.options) this.init(this.options);
1264
+ }
1265
+ resetRegExp() {
1266
+ const getOrResetRegExp = (existingRegExp, pattern) => {
1267
+ if (existingRegExp?.source === pattern) {
1268
+ existingRegExp.lastIndex = 0;
1269
+ return existingRegExp;
1270
+ }
1271
+ return new RegExp(pattern, "g");
1272
+ };
1273
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1274
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1275
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
1276
+ }
1277
+ interpolate(str, data, lng, options) {
1278
+ let match;
1279
+ let value;
1280
+ let replaces;
1281
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1282
+ const handleFormat = (key) => {
1283
+ if (key.indexOf(this.formatSeparator) < 0) {
1284
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1285
+ return this.alwaysFormat ? this.format(path, void 0, lng, {
1286
+ ...options,
1287
+ ...data,
1288
+ interpolationkey: key
1289
+ }) : path;
1290
+ }
1291
+ const p = key.split(this.formatSeparator);
1292
+ const k = p.shift().trim();
1293
+ const f = p.join(this.formatSeparator).trim();
1294
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1295
+ ...options,
1296
+ ...data,
1297
+ interpolationkey: k
1298
+ });
1299
+ };
1300
+ this.resetRegExp();
1301
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1302
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1303
+ [{
1304
+ regex: this.regexpUnescape,
1305
+ safeValue: (val) => regexSafe(val)
1306
+ }, {
1307
+ regex: this.regexp,
1308
+ safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1309
+ }].forEach((todo) => {
1310
+ replaces = 0;
1311
+ while (match = todo.regex.exec(str)) {
1312
+ const matchedVar = match[1].trim();
1313
+ value = handleFormat(matchedVar);
1314
+ if (value === void 0) if (typeof missingInterpolationHandler === "function") {
1315
+ const temp = missingInterpolationHandler(str, match, options);
1316
+ value = isString(temp) ? temp : "";
1317
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) value = "";
1318
+ else if (skipOnVariables) {
1319
+ value = match[0];
1320
+ continue;
1321
+ } else {
1322
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1323
+ value = "";
1324
+ }
1325
+ else if (!isString(value) && !this.useRawValueToEscape) value = makeString(value);
1326
+ const safeValue = todo.safeValue(value);
1327
+ str = str.replace(match[0], safeValue);
1328
+ if (skipOnVariables) {
1329
+ todo.regex.lastIndex += value.length;
1330
+ todo.regex.lastIndex -= match[0].length;
1331
+ } else todo.regex.lastIndex = 0;
1332
+ replaces++;
1333
+ if (replaces >= this.maxReplaces) break;
1334
+ }
1335
+ });
1336
+ return str;
1337
+ }
1338
+ nest(str, fc, options = {}) {
1339
+ let match;
1340
+ let value;
1341
+ let clonedOptions;
1342
+ const handleHasOptions = (key, inheritedOptions) => {
1343
+ const sep = this.nestingOptionsSeparator;
1344
+ if (key.indexOf(sep) < 0) return key;
1345
+ const c = key.split(new RegExp(`${regexEscape(sep)}[ ]*{`));
1346
+ let optionsString = `{${c[1]}`;
1347
+ key = c[0];
1348
+ optionsString = this.interpolate(optionsString, clonedOptions);
1349
+ const matchedSingleQuotes = optionsString.match(/'/g);
1350
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1351
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || (matchedDoubleQuotes?.length ?? 0) % 2 !== 0) optionsString = optionsString.replace(/'/g, "\"");
1352
+ try {
1353
+ clonedOptions = JSON.parse(optionsString);
1354
+ if (inheritedOptions) clonedOptions = {
1355
+ ...inheritedOptions,
1356
+ ...clonedOptions
1357
+ };
1358
+ } catch (e) {
1359
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1360
+ return `${key}${sep}${optionsString}`;
1361
+ }
1362
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1363
+ return key;
1364
+ };
1365
+ while (match = this.nestingRegexp.exec(str)) {
1366
+ let formatters = [];
1367
+ clonedOptions = { ...options };
1368
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1369
+ clonedOptions.applyPostProcessor = false;
1370
+ delete clonedOptions.defaultValue;
1371
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
1372
+ if (keyEndIndex !== -1) {
1373
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
1374
+ match[1] = match[1].slice(0, keyEndIndex);
1375
+ }
1376
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1377
+ if (value && match[0] === str && !isString(value)) return value;
1378
+ if (!isString(value)) value = makeString(value);
1379
+ if (!value) {
1380
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1381
+ value = "";
1382
+ }
1383
+ if (formatters.length) value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1384
+ ...options,
1385
+ interpolationkey: match[1].trim()
1386
+ }), value.trim());
1387
+ str = str.replace(match[0], value);
1388
+ this.regexp.lastIndex = 0;
1389
+ }
1390
+ return str;
1391
+ }
1392
+ };
1393
+ var parseFormatStr = (formatStr) => {
1394
+ let formatName = formatStr.toLowerCase().trim();
1395
+ const formatOptions = {};
1396
+ if (formatStr.indexOf("(") > -1) {
1397
+ const p = formatStr.split("(");
1398
+ formatName = p[0].toLowerCase().trim();
1399
+ const optStr = p[1].substring(0, p[1].length - 1);
1400
+ if (formatName === "currency" && optStr.indexOf(":") < 0) {
1401
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1402
+ } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
1403
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1404
+ } else optStr.split(";").forEach((opt) => {
1405
+ if (opt) {
1406
+ const [key, ...rest] = opt.split(":");
1407
+ const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
1408
+ const trimmedKey = key.trim();
1409
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1410
+ if (val === "false") formatOptions[trimmedKey] = false;
1411
+ if (val === "true") formatOptions[trimmedKey] = true;
1412
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1413
+ }
1414
+ });
1415
+ }
1416
+ return {
1417
+ formatName,
1418
+ formatOptions
1419
+ };
1420
+ };
1421
+ var createCachedFormatter = (fn) => {
1422
+ const cache = {};
1423
+ return (v, l, o) => {
1424
+ let optForCache = o;
1425
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) optForCache = {
1426
+ ...optForCache,
1427
+ [o.interpolationkey]: void 0
1428
+ };
1429
+ const key = l + JSON.stringify(optForCache);
1430
+ let frm = cache[key];
1431
+ if (!frm) {
1432
+ frm = fn(getCleanedCode(l), o);
1433
+ cache[key] = frm;
1434
+ }
1435
+ return frm(v);
1436
+ };
1437
+ };
1438
+ var createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
1439
+ var Formatter = class {
1440
+ constructor(options = {}) {
1441
+ this.logger = baseLogger.create("formatter");
1442
+ this.options = options;
1443
+ this.init(options);
1444
+ }
1445
+ init(services, options = { interpolation: {} }) {
1446
+ this.formatSeparator = options.interpolation.formatSeparator || ",";
1447
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1448
+ this.formats = {
1449
+ number: cf((lng, opt) => {
1450
+ const formatter = new Intl.NumberFormat(lng, { ...opt });
1451
+ return (val) => formatter.format(val);
1452
+ }),
1453
+ currency: cf((lng, opt) => {
1454
+ const formatter = new Intl.NumberFormat(lng, {
1455
+ ...opt,
1456
+ style: "currency"
1457
+ });
1458
+ return (val) => formatter.format(val);
1459
+ }),
1460
+ datetime: cf((lng, opt) => {
1461
+ const formatter = new Intl.DateTimeFormat(lng, { ...opt });
1462
+ return (val) => formatter.format(val);
1463
+ }),
1464
+ relativetime: cf((lng, opt) => {
1465
+ const formatter = new Intl.RelativeTimeFormat(lng, { ...opt });
1466
+ return (val) => formatter.format(val, opt.range || "day");
1467
+ }),
1468
+ list: cf((lng, opt) => {
1469
+ const formatter = new Intl.ListFormat(lng, { ...opt });
1470
+ return (val) => formatter.format(val);
1471
+ })
1472
+ };
1473
+ }
1474
+ add(name, fc) {
1475
+ this.formats[name.toLowerCase().trim()] = fc;
1476
+ }
1477
+ addCached(name, fc) {
1478
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1479
+ }
1480
+ format(value, format, lng, options = {}) {
1481
+ const formats = format.split(this.formatSeparator);
1482
+ if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
1483
+ const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
1484
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1485
+ }
1486
+ return formats.reduce((mem, f) => {
1487
+ const { formatName, formatOptions } = parseFormatStr(f);
1488
+ if (this.formats[formatName]) {
1489
+ let formatted = mem;
1490
+ try {
1491
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1492
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1493
+ formatted = this.formats[formatName](mem, l, {
1494
+ ...formatOptions,
1495
+ ...options,
1496
+ ...valOptions
1497
+ });
1498
+ } catch (error) {
1499
+ this.logger.warn(error);
1500
+ }
1501
+ return formatted;
1502
+ } else this.logger.warn(`there was no format function for ${formatName}`);
1503
+ return mem;
1504
+ }, value);
1505
+ }
1506
+ };
1507
+ var removePending = (q, name) => {
1508
+ if (q.pending[name] !== void 0) {
1509
+ delete q.pending[name];
1510
+ q.pendingCount--;
1511
+ }
1512
+ };
1513
+ var Connector = class extends EventEmitter {
1514
+ constructor(backend, store, services, options = {}) {
1515
+ super();
1516
+ this.backend = backend;
1517
+ this.store = store;
1518
+ this.services = services;
1519
+ this.languageUtils = services.languageUtils;
1520
+ this.options = options;
1521
+ this.logger = baseLogger.create("backendConnector");
1522
+ this.waitingReads = [];
1523
+ this.maxParallelReads = options.maxParallelReads || 10;
1524
+ this.readingCalls = 0;
1525
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1526
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1527
+ this.state = {};
1528
+ this.queue = [];
1529
+ this.backend?.init?.(services, options.backend, options);
1530
+ }
1531
+ queueLoad(languages, namespaces, options, callback) {
1532
+ const toLoad = {};
1533
+ const pending = {};
1534
+ const toLoadLanguages = {};
1535
+ const toLoadNamespaces = {};
1536
+ languages.forEach((lng) => {
1537
+ let hasAllNamespaces = true;
1538
+ namespaces.forEach((ns) => {
1539
+ const name = `${lng}|${ns}`;
1540
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) this.state[name] = 2;
1541
+ else if (this.state[name] < 0);
1542
+ else if (this.state[name] === 1) {
1543
+ if (pending[name] === void 0) pending[name] = true;
1544
+ } else {
1545
+ this.state[name] = 1;
1546
+ hasAllNamespaces = false;
1547
+ if (pending[name] === void 0) pending[name] = true;
1548
+ if (toLoad[name] === void 0) toLoad[name] = true;
1549
+ if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
1550
+ }
1551
+ });
1552
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1553
+ });
1554
+ if (Object.keys(toLoad).length || Object.keys(pending).length) this.queue.push({
1555
+ pending,
1556
+ pendingCount: Object.keys(pending).length,
1557
+ loaded: {},
1558
+ errors: [],
1559
+ callback
1560
+ });
1561
+ return {
1562
+ toLoad: Object.keys(toLoad),
1563
+ pending: Object.keys(pending),
1564
+ toLoadLanguages: Object.keys(toLoadLanguages),
1565
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1566
+ };
1567
+ }
1568
+ loaded(name, err, data) {
1569
+ const s = name.split("|");
1570
+ const lng = s[0];
1571
+ const ns = s[1];
1572
+ if (err) this.emit("failedLoading", lng, ns, err);
1573
+ if (!err && data) this.store.addResourceBundle(lng, ns, data, void 0, void 0, { skipCopy: true });
1574
+ this.state[name] = err ? -1 : 2;
1575
+ if (err && data) this.state[name] = 0;
1576
+ const loaded = {};
1577
+ this.queue.forEach((q) => {
1578
+ pushPath(q.loaded, [lng], ns);
1579
+ removePending(q, name);
1580
+ if (err) q.errors.push(err);
1581
+ if (q.pendingCount === 0 && !q.done) {
1582
+ Object.keys(q.loaded).forEach((l) => {
1583
+ if (!loaded[l]) loaded[l] = {};
1584
+ const loadedKeys = q.loaded[l];
1585
+ if (loadedKeys.length) loadedKeys.forEach((n) => {
1586
+ if (loaded[l][n] === void 0) loaded[l][n] = true;
1587
+ });
1588
+ });
1589
+ q.done = true;
1590
+ if (q.errors.length) q.callback(q.errors);
1591
+ else q.callback();
1592
+ }
1593
+ });
1594
+ this.emit("loaded", loaded);
1595
+ this.queue = this.queue.filter((q) => !q.done);
1596
+ }
1597
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1598
+ if (!lng.length) return callback(null, {});
1599
+ if (this.readingCalls >= this.maxParallelReads) {
1600
+ this.waitingReads.push({
1601
+ lng,
1602
+ ns,
1603
+ fcName,
1604
+ tried,
1605
+ wait,
1606
+ callback
1607
+ });
1608
+ return;
1609
+ }
1610
+ this.readingCalls++;
1611
+ const resolver = (err, data) => {
1612
+ this.readingCalls--;
1613
+ if (this.waitingReads.length > 0) {
1614
+ const next = this.waitingReads.shift();
1615
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1616
+ }
1617
+ if (err && data && tried < this.maxRetries) {
1618
+ setTimeout(() => {
1619
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1620
+ }, wait);
1621
+ return;
1622
+ }
1623
+ callback(err, data);
1624
+ };
1625
+ const fc = this.backend[fcName].bind(this.backend);
1626
+ if (fc.length === 2) {
1627
+ try {
1628
+ const r = fc(lng, ns);
1629
+ if (r && typeof r.then === "function") r.then((data) => resolver(null, data)).catch(resolver);
1630
+ else resolver(null, r);
1631
+ } catch (err) {
1632
+ resolver(err);
1633
+ }
1634
+ return;
1635
+ }
1636
+ return fc(lng, ns, resolver);
1637
+ }
1638
+ prepareLoading(languages, namespaces, options = {}, callback) {
1639
+ if (!this.backend) {
1640
+ this.logger.warn("No backend was added via i18next.use. Will not load resources.");
1641
+ return callback && callback();
1642
+ }
1643
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1644
+ if (isString(namespaces)) namespaces = [namespaces];
1645
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1646
+ if (!toLoad.toLoad.length) {
1647
+ if (!toLoad.pending.length) callback();
1648
+ return null;
1649
+ }
1650
+ toLoad.toLoad.forEach((name) => {
1651
+ this.loadOne(name);
1652
+ });
1653
+ }
1654
+ load(languages, namespaces, callback) {
1655
+ this.prepareLoading(languages, namespaces, {}, callback);
1656
+ }
1657
+ reload(languages, namespaces, callback) {
1658
+ this.prepareLoading(languages, namespaces, { reload: true }, callback);
1659
+ }
1660
+ loadOne(name, prefix = "") {
1661
+ const s = name.split("|");
1662
+ const lng = s[0];
1663
+ const ns = s[1];
1664
+ this.read(lng, ns, "read", void 0, void 0, (err, data) => {
1665
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1666
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1667
+ this.loaded(name, err, data);
1668
+ });
1669
+ }
1670
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
1671
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1672
+ 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!!!");
1673
+ return;
1674
+ }
1675
+ if (key === void 0 || key === null || key === "") return;
1676
+ if (this.backend?.create) {
1677
+ const opts = {
1678
+ ...options,
1679
+ isUpdate
1680
+ };
1681
+ const fc = this.backend.create.bind(this.backend);
1682
+ if (fc.length < 6) try {
1683
+ let r;
1684
+ if (fc.length === 5) r = fc(languages, namespace, key, fallbackValue, opts);
1685
+ else r = fc(languages, namespace, key, fallbackValue);
1686
+ if (r && typeof r.then === "function") r.then((data) => clb(null, data)).catch(clb);
1687
+ else clb(null, r);
1688
+ } catch (err) {
1689
+ clb(err);
1690
+ }
1691
+ else fc(languages, namespace, key, fallbackValue, clb, opts);
1692
+ }
1693
+ if (!languages || !languages[0]) return;
1694
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1695
+ }
1696
+ };
1697
+ var get = () => ({
1698
+ debug: false,
1699
+ initAsync: true,
1700
+ ns: ["translation"],
1701
+ defaultNS: ["translation"],
1702
+ fallbackLng: ["dev"],
1703
+ fallbackNS: false,
1704
+ supportedLngs: false,
1705
+ nonExplicitSupportedLngs: false,
1706
+ load: "all",
1707
+ preload: false,
1708
+ simplifyPluralSuffix: true,
1709
+ keySeparator: ".",
1710
+ nsSeparator: ":",
1711
+ pluralSeparator: "_",
1712
+ contextSeparator: "_",
1713
+ partialBundledLanguages: false,
1714
+ saveMissing: false,
1715
+ updateMissing: false,
1716
+ saveMissingTo: "fallback",
1717
+ saveMissingPlurals: true,
1718
+ missingKeyHandler: false,
1719
+ missingInterpolationHandler: false,
1720
+ postProcess: false,
1721
+ postProcessPassResolved: false,
1722
+ returnNull: false,
1723
+ returnEmptyString: true,
1724
+ returnObjects: false,
1725
+ joinArrays: false,
1726
+ returnedObjectHandler: false,
1727
+ parseMissingKeyHandler: false,
1728
+ appendNamespaceToMissingKey: false,
1729
+ appendNamespaceToCIMode: false,
1730
+ overloadTranslationOptionHandler: (args) => {
1731
+ let ret = {};
1732
+ if (typeof args[1] === "object") ret = args[1];
1733
+ if (isString(args[1])) ret.defaultValue = args[1];
1734
+ if (isString(args[2])) ret.tDescription = args[2];
1735
+ if (typeof args[2] === "object" || typeof args[3] === "object") {
1736
+ const options = args[3] || args[2];
1737
+ Object.keys(options).forEach((key) => {
1738
+ ret[key] = options[key];
1739
+ });
1740
+ }
1741
+ return ret;
1742
+ },
1743
+ interpolation: {
1744
+ escapeValue: true,
1745
+ format: (value) => value,
1746
+ prefix: "{{",
1747
+ suffix: "}}",
1748
+ formatSeparator: ",",
1749
+ unescapePrefix: "-",
1750
+ nestingPrefix: "$t(",
1751
+ nestingSuffix: ")",
1752
+ nestingOptionsSeparator: ",",
1753
+ maxReplaces: 1e3,
1754
+ skipOnVariables: true
1755
+ },
1756
+ cacheInBuiltFormats: true
1757
+ });
1758
+ var transformOptions = (options) => {
1759
+ if (isString(options.ns)) options.ns = [options.ns];
1760
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1761
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1762
+ if (options.supportedLngs?.indexOf?.("cimode") < 0) options.supportedLngs = options.supportedLngs.concat(["cimode"]);
1763
+ if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
1764
+ return options;
1765
+ };
1766
+ var noop = () => {};
1767
+ var bindMemberFunctions = (inst) => {
1768
+ Object.getOwnPropertyNames(Object.getPrototypeOf(inst)).forEach((mem) => {
1769
+ if (typeof inst[mem] === "function") inst[mem] = inst[mem].bind(inst);
1770
+ });
1771
+ };
1772
+ var SUPPORT_NOTICE_KEY = "__i18next_supportNoticeShown";
1773
+ var getSupportNoticeShown = () => {
1774
+ if (typeof globalThis !== "undefined" && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
1775
+ if (typeof process !== "undefined" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
1776
+ if (typeof process !== "undefined" && process.env && process.env.NODE_ENV === "production") return true;
1777
+ return false;
1778
+ };
1779
+ var setSupportNoticeShown = () => {
1780
+ if (typeof globalThis !== "undefined") globalThis[SUPPORT_NOTICE_KEY] = true;
1781
+ };
1782
+ var usesLocize = (inst) => {
1783
+ if (inst?.modules?.backend?.name?.indexOf("Locize") > 0) return true;
1784
+ if (inst?.modules?.backend?.constructor?.name?.indexOf("Locize") > 0) return true;
1785
+ if (inst?.options?.backend?.backends) {
1786
+ if (inst.options.backend.backends.some((b) => b?.name?.indexOf("Locize") > 0 || b?.constructor?.name?.indexOf("Locize") > 0)) return true;
1787
+ }
1788
+ if (inst?.options?.backend?.projectId) return true;
1789
+ if (inst?.options?.backend?.backendOptions) {
1790
+ if (inst.options.backend.backendOptions.some((b) => b?.projectId)) return true;
1791
+ }
1792
+ return false;
1793
+ };
1794
+ var instance = class I18n extends EventEmitter {
1795
+ constructor(options = {}, callback) {
1796
+ super();
1797
+ this.options = transformOptions(options);
1798
+ this.services = {};
1799
+ this.logger = baseLogger;
1800
+ this.modules = { external: [] };
1801
+ bindMemberFunctions(this);
1802
+ if (callback && !this.isInitialized && !options.isClone) {
1803
+ if (!this.options.initAsync) {
1804
+ this.init(options, callback);
1805
+ return this;
1806
+ }
1807
+ setTimeout(() => {
1808
+ this.init(options, callback);
1809
+ }, 0);
1810
+ }
1811
+ }
1812
+ init(options = {}, callback) {
1813
+ this.isInitializing = true;
1814
+ if (typeof options === "function") {
1815
+ callback = options;
1816
+ options = {};
1817
+ }
1818
+ if (options.defaultNS == null && options.ns) {
1819
+ if (isString(options.ns)) options.defaultNS = options.ns;
1820
+ else if (options.ns.indexOf("translation") < 0) options.defaultNS = options.ns[0];
1821
+ }
1822
+ const defOpts = get();
1823
+ this.options = {
1824
+ ...defOpts,
1825
+ ...this.options,
1826
+ ...transformOptions(options)
1827
+ };
1828
+ this.options.interpolation = {
1829
+ ...defOpts.interpolation,
1830
+ ...this.options.interpolation
1831
+ };
1832
+ if (options.keySeparator !== void 0) this.options.userDefinedKeySeparator = options.keySeparator;
1833
+ if (options.nsSeparator !== void 0) this.options.userDefinedNsSeparator = options.nsSeparator;
1834
+ if (typeof this.options.overloadTranslationOptionHandler !== "function") this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1835
+ if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
1836
+ 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 💙");
1837
+ setSupportNoticeShown();
1838
+ }
1839
+ const createClassOnDemand = (ClassOrObject) => {
1840
+ if (!ClassOrObject) return null;
1841
+ if (typeof ClassOrObject === "function") return new ClassOrObject();
1842
+ return ClassOrObject;
1843
+ };
1844
+ if (!this.options.isClone) {
1845
+ if (this.modules.logger) baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1846
+ else baseLogger.init(null, this.options);
1847
+ let formatter;
1848
+ if (this.modules.formatter) formatter = this.modules.formatter;
1849
+ else formatter = Formatter;
1850
+ const lu = new LanguageUtil(this.options);
1851
+ this.store = new ResourceStore(this.options.resources, this.options);
1852
+ const s = this.services;
1853
+ s.logger = baseLogger;
1854
+ s.resourceStore = this.store;
1855
+ s.languageUtils = lu;
1856
+ s.pluralResolver = new PluralResolver(lu, {
1857
+ prepend: this.options.pluralSeparator,
1858
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1859
+ });
1860
+ 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`);
1861
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1862
+ s.formatter = createClassOnDemand(formatter);
1863
+ if (s.formatter.init) s.formatter.init(s, this.options);
1864
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1865
+ }
1866
+ s.interpolator = new Interpolator(this.options);
1867
+ s.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) };
1868
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1869
+ s.backendConnector.on("*", (event, ...args) => {
1870
+ this.emit(event, ...args);
1871
+ });
1872
+ if (this.modules.languageDetector) {
1873
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1874
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1875
+ }
1876
+ if (this.modules.i18nFormat) {
1877
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1878
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1879
+ }
1880
+ this.translator = new Translator(this.services, this.options);
1881
+ this.translator.on("*", (event, ...args) => {
1882
+ this.emit(event, ...args);
1883
+ });
1884
+ this.modules.external.forEach((m) => {
1885
+ if (m.init) m.init(this);
1886
+ });
1887
+ }
1888
+ this.format = this.options.interpolation.format;
1889
+ if (!callback) callback = noop;
1890
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1891
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1892
+ if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
1893
+ }
1894
+ if (!this.services.languageDetector && !this.options.lng) this.logger.warn("init: no languageDetector is used and no lng is defined");
1895
+ [
1896
+ "getResource",
1897
+ "hasResourceBundle",
1898
+ "getResourceBundle",
1899
+ "getDataByLanguage"
1900
+ ].forEach((fcName) => {
1901
+ this[fcName] = (...args) => this.store[fcName](...args);
1902
+ });
1903
+ [
1904
+ "addResource",
1905
+ "addResources",
1906
+ "addResourceBundle",
1907
+ "removeResourceBundle"
1908
+ ].forEach((fcName) => {
1909
+ this[fcName] = (...args) => {
1910
+ this.store[fcName](...args);
1911
+ return this;
1912
+ };
1913
+ });
1914
+ const deferred = defer();
1915
+ const load = () => {
1916
+ const finish = (err, t) => {
1917
+ this.isInitializing = false;
1918
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
1919
+ this.isInitialized = true;
1920
+ if (!this.options.isClone) this.logger.log("initialized", this.options);
1921
+ this.emit("initialized", this.options);
1922
+ deferred.resolve(t);
1923
+ callback(err, t);
1924
+ };
1925
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1926
+ this.changeLanguage(this.options.lng, finish);
1927
+ };
1928
+ if (this.options.resources || !this.options.initAsync) load();
1929
+ else setTimeout(load, 0);
1930
+ return deferred;
1931
+ }
1932
+ loadResources(language, callback = noop) {
1933
+ let usedCallback = callback;
1934
+ const usedLng = isString(language) ? language : this.language;
1935
+ if (typeof language === "function") usedCallback = language;
1936
+ if (!this.options.resources || this.options.partialBundledLanguages) {
1937
+ if (usedLng?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1938
+ const toLoad = [];
1939
+ const append = (lng) => {
1940
+ if (!lng) return;
1941
+ if (lng === "cimode") return;
1942
+ this.services.languageUtils.toResolveHierarchy(lng).forEach((l) => {
1943
+ if (l === "cimode") return;
1944
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
1945
+ });
1946
+ };
1947
+ if (!usedLng) this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => append(l));
1948
+ else append(usedLng);
1949
+ this.options.preload?.forEach?.((l) => append(l));
1950
+ this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
1951
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1952
+ usedCallback(e);
1953
+ });
1954
+ } else usedCallback(null);
1955
+ }
1956
+ reloadResources(lngs, ns, callback) {
1957
+ const deferred = defer();
1958
+ if (typeof lngs === "function") {
1959
+ callback = lngs;
1960
+ lngs = void 0;
1961
+ }
1962
+ if (typeof ns === "function") {
1963
+ callback = ns;
1964
+ ns = void 0;
1965
+ }
1966
+ if (!lngs) lngs = this.languages;
1967
+ if (!ns) ns = this.options.ns;
1968
+ if (!callback) callback = noop;
1969
+ this.services.backendConnector.reload(lngs, ns, (err) => {
1970
+ deferred.resolve();
1971
+ callback(err);
1972
+ });
1973
+ return deferred;
1974
+ }
1975
+ use(module) {
1976
+ if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1977
+ if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1978
+ if (module.type === "backend") this.modules.backend = module;
1979
+ if (module.type === "logger" || module.log && module.warn && module.error) this.modules.logger = module;
1980
+ if (module.type === "languageDetector") this.modules.languageDetector = module;
1981
+ if (module.type === "i18nFormat") this.modules.i18nFormat = module;
1982
+ if (module.type === "postProcessor") postProcessor.addPostProcessor(module);
1983
+ if (module.type === "formatter") this.modules.formatter = module;
1984
+ if (module.type === "3rdParty") this.modules.external.push(module);
1985
+ return this;
1986
+ }
1987
+ setResolvedLanguage(l) {
1988
+ if (!l || !this.languages) return;
1989
+ if (["cimode", "dev"].indexOf(l) > -1) return;
1990
+ for (let li = 0; li < this.languages.length; li++) {
1991
+ const lngInLngs = this.languages[li];
1992
+ if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
1993
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1994
+ this.resolvedLanguage = lngInLngs;
1995
+ break;
1996
+ }
1997
+ }
1998
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1999
+ this.resolvedLanguage = l;
2000
+ this.languages.unshift(l);
2001
+ }
2002
+ }
2003
+ changeLanguage(lng, callback) {
2004
+ this.isLanguageChangingTo = lng;
2005
+ const deferred = defer();
2006
+ this.emit("languageChanging", lng);
2007
+ const setLngProps = (l) => {
2008
+ this.language = l;
2009
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
2010
+ this.resolvedLanguage = void 0;
2011
+ this.setResolvedLanguage(l);
2012
+ };
2013
+ const done = (err, l) => {
2014
+ if (l) {
2015
+ if (this.isLanguageChangingTo === lng) {
2016
+ setLngProps(l);
2017
+ this.translator.changeLanguage(l);
2018
+ this.isLanguageChangingTo = void 0;
2019
+ this.emit("languageChanged", l);
2020
+ this.logger.log("languageChanged", l);
2021
+ }
2022
+ } else this.isLanguageChangingTo = void 0;
2023
+ deferred.resolve((...args) => this.t(...args));
2024
+ if (callback) callback(err, (...args) => this.t(...args));
2025
+ };
2026
+ const setLng = (lngs) => {
2027
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
2028
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
2029
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
2030
+ if (l) {
2031
+ if (!this.language) setLngProps(l);
2032
+ if (!this.translator.language) this.translator.changeLanguage(l);
2033
+ this.services.languageDetector?.cacheUserLanguage?.(l);
2034
+ }
2035
+ this.loadResources(l, (err) => {
2036
+ done(err, l);
2037
+ });
2038
+ };
2039
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) setLng(this.services.languageDetector.detect());
2040
+ else if (!lng && this.services.languageDetector && this.services.languageDetector.async) if (this.services.languageDetector.detect.length === 0) this.services.languageDetector.detect().then(setLng);
2041
+ else this.services.languageDetector.detect(setLng);
2042
+ else setLng(lng);
2043
+ return deferred;
2044
+ }
2045
+ getFixedT(lng, ns, keyPrefix) {
2046
+ const fixedT = (key, opts, ...rest) => {
2047
+ let o;
2048
+ if (typeof opts !== "object") o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2049
+ else o = { ...opts };
2050
+ o.lng = o.lng || fixedT.lng;
2051
+ o.lngs = o.lngs || fixedT.lngs;
2052
+ o.ns = o.ns || fixedT.ns;
2053
+ if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
2054
+ const selectorOpts = {
2055
+ ...this.options,
2056
+ ...o
2057
+ };
2058
+ if (typeof o.keyPrefix === "function") o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
2059
+ const keySeparator = this.options.keySeparator || ".";
2060
+ let resultKey;
2061
+ if (o.keyPrefix && Array.isArray(key)) resultKey = key.map((k) => {
2062
+ if (typeof k === "function") k = keysFromSelector(k, selectorOpts);
2063
+ return `${o.keyPrefix}${keySeparator}${k}`;
2064
+ });
2065
+ else {
2066
+ if (typeof key === "function") key = keysFromSelector(key, selectorOpts);
2067
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2068
+ }
2069
+ return this.t(resultKey, o);
2070
+ };
2071
+ if (isString(lng)) fixedT.lng = lng;
2072
+ else fixedT.lngs = lng;
2073
+ fixedT.ns = ns;
2074
+ fixedT.keyPrefix = keyPrefix;
2075
+ return fixedT;
2076
+ }
2077
+ t(...args) {
2078
+ return this.translator?.translate(...args);
2079
+ }
2080
+ exists(...args) {
2081
+ return this.translator?.exists(...args);
2082
+ }
2083
+ setDefaultNamespace(ns) {
2084
+ this.options.defaultNS = ns;
2085
+ }
2086
+ hasLoadedNamespace(ns, options = {}) {
2087
+ if (!this.isInitialized) {
2088
+ this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
2089
+ return false;
2090
+ }
2091
+ if (!this.languages || !this.languages.length) {
2092
+ this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
2093
+ return false;
2094
+ }
2095
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
2096
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
2097
+ const lastLng = this.languages[this.languages.length - 1];
2098
+ if (lng.toLowerCase() === "cimode") return true;
2099
+ const loadNotPending = (l, n) => {
2100
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
2101
+ return loadState === -1 || loadState === 0 || loadState === 2;
2102
+ };
2103
+ if (options.precheck) {
2104
+ const preResult = options.precheck(this, loadNotPending);
2105
+ if (preResult !== void 0) return preResult;
2106
+ }
2107
+ if (this.hasResourceBundle(lng, ns)) return true;
2108
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2109
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2110
+ return false;
2111
+ }
2112
+ loadNamespaces(ns, callback) {
2113
+ const deferred = defer();
2114
+ if (!this.options.ns) {
2115
+ if (callback) callback();
2116
+ return Promise.resolve();
2117
+ }
2118
+ if (isString(ns)) ns = [ns];
2119
+ ns.forEach((n) => {
2120
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2121
+ });
2122
+ this.loadResources((err) => {
2123
+ deferred.resolve();
2124
+ if (callback) callback(err);
2125
+ });
2126
+ return deferred;
2127
+ }
2128
+ loadLanguages(lngs, callback) {
2129
+ const deferred = defer();
2130
+ if (isString(lngs)) lngs = [lngs];
2131
+ const preloaded = this.options.preload || [];
2132
+ const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2133
+ if (!newLngs.length) {
2134
+ if (callback) callback();
2135
+ return Promise.resolve();
2136
+ }
2137
+ this.options.preload = preloaded.concat(newLngs);
2138
+ this.loadResources((err) => {
2139
+ deferred.resolve();
2140
+ if (callback) callback(err);
2141
+ });
2142
+ return deferred;
2143
+ }
2144
+ dir(lng) {
2145
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2146
+ if (!lng) return "rtl";
2147
+ try {
2148
+ const l = new Intl.Locale(lng);
2149
+ if (l && l.getTextInfo) {
2150
+ const ti = l.getTextInfo();
2151
+ if (ti && ti.direction) return ti.direction;
2152
+ }
2153
+ } catch (e) {}
2154
+ const rtlLngs = [
2155
+ "ar",
2156
+ "shu",
2157
+ "sqr",
2158
+ "ssh",
2159
+ "xaa",
2160
+ "yhd",
2161
+ "yud",
2162
+ "aao",
2163
+ "abh",
2164
+ "abv",
2165
+ "acm",
2166
+ "acq",
2167
+ "acw",
2168
+ "acx",
2169
+ "acy",
2170
+ "adf",
2171
+ "ads",
2172
+ "aeb",
2173
+ "aec",
2174
+ "afb",
2175
+ "ajp",
2176
+ "apc",
2177
+ "apd",
2178
+ "arb",
2179
+ "arq",
2180
+ "ars",
2181
+ "ary",
2182
+ "arz",
2183
+ "auz",
2184
+ "avl",
2185
+ "ayh",
2186
+ "ayl",
2187
+ "ayn",
2188
+ "ayp",
2189
+ "bbz",
2190
+ "pga",
2191
+ "he",
2192
+ "iw",
2193
+ "ps",
2194
+ "pbt",
2195
+ "pbu",
2196
+ "pst",
2197
+ "prp",
2198
+ "prd",
2199
+ "ug",
2200
+ "ur",
2201
+ "ydd",
2202
+ "yds",
2203
+ "yih",
2204
+ "ji",
2205
+ "yi",
2206
+ "hbo",
2207
+ "men",
2208
+ "xmn",
2209
+ "fa",
2210
+ "jpr",
2211
+ "peo",
2212
+ "pes",
2213
+ "prs",
2214
+ "dv",
2215
+ "sam",
2216
+ "ckb"
2217
+ ];
2218
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2219
+ if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
2220
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
2221
+ }
2222
+ static createInstance(options = {}, callback) {
2223
+ const instance = new I18n(options, callback);
2224
+ instance.createInstance = I18n.createInstance;
2225
+ return instance;
2226
+ }
2227
+ cloneInstance(options = {}, callback = noop) {
2228
+ const forkResourceStore = options.forkResourceStore;
2229
+ if (forkResourceStore) delete options.forkResourceStore;
2230
+ const mergedOptions = {
2231
+ ...this.options,
2232
+ ...options,
2233
+ isClone: true
2234
+ };
2235
+ const clone = new I18n(mergedOptions);
2236
+ if (options.debug !== void 0 || options.prefix !== void 0) clone.logger = clone.logger.clone(options);
2237
+ [
2238
+ "store",
2239
+ "services",
2240
+ "language"
2241
+ ].forEach((m) => {
2242
+ clone[m] = this[m];
2243
+ });
2244
+ clone.services = { ...this.services };
2245
+ clone.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
2246
+ if (forkResourceStore) {
2247
+ clone.store = new ResourceStore(Object.keys(this.store.data).reduce((prev, l) => {
2248
+ prev[l] = { ...this.store.data[l] };
2249
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
2250
+ acc[n] = { ...prev[l][n] };
2251
+ return acc;
2252
+ }, prev[l]);
2253
+ return prev;
2254
+ }, {}), mergedOptions);
2255
+ clone.services.resourceStore = clone.store;
2256
+ }
2257
+ if (options.interpolation) {
2258
+ const mergedInterpolation = {
2259
+ ...get().interpolation,
2260
+ ...this.options.interpolation,
2261
+ ...options.interpolation
2262
+ };
2263
+ const mergedForInterpolator = {
2264
+ ...mergedOptions,
2265
+ interpolation: mergedInterpolation
2266
+ };
2267
+ clone.services.interpolator = new Interpolator(mergedForInterpolator);
2268
+ }
2269
+ clone.translator = new Translator(clone.services, mergedOptions);
2270
+ clone.translator.on("*", (event, ...args) => {
2271
+ clone.emit(event, ...args);
2272
+ });
2273
+ clone.init(mergedOptions, callback);
2274
+ clone.translator.options = mergedOptions;
2275
+ clone.translator.backendConnector.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
2276
+ return clone;
2277
+ }
2278
+ toJSON() {
2279
+ return {
2280
+ options: this.options,
2281
+ store: this.store,
2282
+ language: this.language,
2283
+ languages: this.languages,
2284
+ resolvedLanguage: this.resolvedLanguage
2285
+ };
2286
+ }
2287
+ }.createInstance();
2288
+ instance.createInstance;
2289
+ instance.dir;
2290
+ instance.init;
2291
+ instance.loadResources;
2292
+ instance.reloadResources;
2293
+ instance.use;
2294
+ instance.changeLanguage;
2295
+ instance.getFixedT;
2296
+ instance.t;
2297
+ instance.exists;
2298
+ instance.setDefaultNamespace;
2299
+ instance.hasLoadedNamespace;
2300
+ instance.loadNamespaces;
2301
+ instance.loadLanguages;
2302
+ //#endregion
2303
+ //#region ../../shared/translator/dist/index.js
2304
+ instance.init({
2305
+ fallbackLng: "en",
2306
+ lng: "en",
2307
+ showSupportNotice: !1,
2308
+ resources: {
2309
+ en: e$1,
2310
+ es: e
2311
+ }
2312
+ });
2313
+ //#endregion
2314
+ //#region src/i18n.ts
2315
+ var { translator } = {
2316
+ translator: {
2317
+ ...instance,
2318
+ t: (e, t) => {
2319
+ let { lng: r } = t;
2320
+ switch (r) {
2321
+ case "en_US":
2322
+ case "en-US":
2323
+ t.lng = "en";
2324
+ break;
2325
+ case "es_ES":
2326
+ case "es-ES":
2327
+ case "es_MX":
2328
+ case "es-MX":
2329
+ t.lng = "es";
2330
+ break;
2331
+ default: break;
2332
+ }
2333
+ return instance.t(e, {
2334
+ lng: r,
2335
+ ...t
2336
+ });
2337
+ }
2338
+ },
2339
+ languageOptions: [{
2340
+ value: "en_US",
2341
+ label: "English (US)"
2342
+ }, {
2343
+ value: "es_ES",
2344
+ label: "Spanish"
2345
+ }]
2346
+ };
2347
+ /**
2348
+ * A learner-facing string in `language`, the model's `language`. i18next falls
2349
+ * back to English for a language or key it does not hold. Values are not
2350
+ * HTML-escaped: they are circle and tile names, and Svelte escapes what it
2351
+ * renders.
2352
+ */
2353
+ function t(key, language, values = {}) {
2354
+ return translator.t(`translation:vennClassification:${key}`, {
2355
+ lng: language,
2356
+ ...values,
2357
+ interpolation: { escapeValue: false }
2358
+ });
2359
+ }
2360
+ //#endregion
24
2361
  //#region src/controller/region.ts
25
2362
  /**
2363
+ * Region helpers for the venn-classification controller.
2364
+ *
2365
+ * A region is a sorted-ascending array of circle indexes. These helpers deal
2366
+ * with keying, labelling, and equality in a layout-agnostic way so that both
2367
+ * the controller (for scoring / validation) and delivery (for rendering)
2368
+ * can share them.
2369
+ */
2370
+ /**
26
2371
  * Returns the canonical region key: sorted-ascending indexes joined by commas.
27
2372
  * Outside / "neither" region is the empty string.
28
2373
  */
@@ -74,16 +2419,19 @@ function enumerateRegions(circleCount) {
74
2419
  * [0,1] -> "<X> and <Y>"
75
2420
  * [0,1,2] -> "<X> and <Y> and <Z>"
76
2421
  */
77
- function composeRegionLabel(circles, region) {
2422
+ function composeRegionLabel(circles, region, language) {
78
2423
  const norm = normalizeRegion(region);
79
- const labels = norm.map((i) => circles[i]?.label ?? `Set ${i + 1}`);
80
- const circleCount = circles.length;
2424
+ const setLabel = (i) => circles[i]?.label ?? t("setNumber", language, { number: i + 1 });
2425
+ const labels = norm.map(setLabel);
81
2426
  if (norm.length === 0) {
82
- if (circleCount === 2) return `Neither ${circles[0]?.label ?? "Set 1"} nor ${circles[1]?.label ?? "Set 2"}`;
83
- return `None of ${circles.map((c, i) => c?.label ?? `Set ${i + 1}`).join(", ")}`;
2427
+ if (circles.length === 2) return t("regionNeither", language, {
2428
+ first: setLabel(0),
2429
+ second: setLabel(1)
2430
+ });
2431
+ return t("regionNoneOf", language, { sets: circles.map((_, i) => setLabel(i)).join(", ") });
84
2432
  }
85
- if (norm.length === 1) return `${labels[0]} only`;
86
- return labels.join(" and ");
2433
+ if (norm.length === 1) return t("regionOnly", language, { set: labels[0] });
2434
+ return labels.join(t("regionAndSeparator", language));
87
2435
  }
88
2436
  /**
89
2437
  * Resolve the label for a region, preferring an author-supplied override from
@@ -94,7 +2442,7 @@ function getRegionLabel(model, region) {
94
2442
  const key = regionKey(region);
95
2443
  const override = model.regionLabels?.[key];
96
2444
  if (typeof override === "string" && override.trim().length > 0) return override;
97
- return composeRegionLabel(model.circles ?? [], region);
2445
+ return composeRegionLabel(model.circles ?? [], region, model.language);
98
2446
  }
99
2447
  //#endregion
100
2448
  //#region src/controller/index.ts
@@ -104,7 +2452,6 @@ function getRegionLabel(model, region) {
104
2452
  * plus the 3-set layout/picker once that work ships.
105
2453
  */
106
2454
  var SUPPORTED_CIRCLE_COUNTS = /* @__PURE__ */ new Set([2]);
107
- var isEmptyObject = (value) => !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
108
2455
  function tilePlainLabel(label) {
109
2456
  return String(label ?? "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
110
2457
  }
@@ -167,32 +2514,29 @@ function getCorrectnessMap(model, session) {
167
2514
  for (const tile of model.tiles ?? []) out[tile.id] = getTileCorrectness(tile, placements[tile.id] ?? null);
168
2515
  return out;
169
2516
  }
2517
+ /**
2518
+ * The scoring policy in force: the model's `scoringPolicy`, overridden to
2519
+ * all-or-nothing by `env.partialScoring === false` - the rule the React
2520
+ * elements apply through `partialScoring.enabled(model, env)`.
2521
+ */
2522
+ function effectiveScoringPolicy(model, env) {
2523
+ if (model.scoringPolicy === "allOrNothing" || env?.partialScoring === false) return "allOrNothing";
2524
+ return "partialPerTile";
2525
+ }
2526
+ var EMPTY_OUTCOME = {
2527
+ score: 0,
2528
+ empty: true,
2529
+ traceLog: ["Student did not place any tiles. Score is 0."]
2530
+ };
2531
+ /**
2532
+ * Score a session. Scores in every mode, as multiple-choice does: a player
2533
+ * calls this with the env it scores under, not only `evaluate`.
2534
+ */
170
2535
  function outcome(question, session, env = {}) {
171
2536
  return new Promise((resolve) => {
172
- if (!session || isEmptyObject(session) || !session.placements || Object.keys(session.placements).length === 0) {
173
- resolve({
174
- score: 0,
175
- empty: true
176
- });
177
- return;
178
- }
179
- if (env.mode !== "evaluate") {
180
- resolve({
181
- score: void 0,
182
- completed: void 0
183
- });
184
- return;
185
- }
186
2537
  const model = createDefaultModel(question || void 0);
187
- const tiles = model.tiles || [];
188
- if (tiles.length === 0) {
189
- resolve({
190
- score: 0,
191
- empty: true
192
- });
193
- return;
194
- }
195
- const placements = session.placements || {};
2538
+ const tiles = model.tiles;
2539
+ const placements = session?.placements ?? {};
196
2540
  let correct = 0;
197
2541
  let answered = 0;
198
2542
  for (const tile of tiles) {
@@ -203,16 +2547,22 @@ function outcome(question, session, env = {}) {
203
2547
  }
204
2548
  if (answered === 0) {
205
2549
  resolve({
206
- score: 0,
207
- empty: true
2550
+ ...EMPTY_OUTCOME,
2551
+ traceLog: [...EMPTY_OUTCOME.traceLog]
208
2552
  });
209
2553
  return;
210
2554
  }
211
- if ((model.scoringPolicy === "allOrNothing" ? "allOrNothing" : "partialPerTile") === "allOrNothing") {
212
- resolve({ score: correct === tiles.length ? 1 : 0 });
213
- return;
214
- }
215
- resolve({ score: correct / tiles.length });
2555
+ const policy = effectiveScoringPolicy(model, env);
2556
+ const score = policy === "allOrNothing" ? correct === tiles.length ? 1 : 0 : Number.parseFloat((correct / tiles.length).toFixed(2));
2557
+ resolve({
2558
+ score,
2559
+ empty: false,
2560
+ traceLog: [
2561
+ `Student placed ${answered} of ${tiles.length} tile(s); ${correct} in the correct region.`,
2562
+ `Score calculated using ${policy === "allOrNothing" ? "all-or-nothing" : "partial"} scoring.`,
2563
+ `Final score: ${score}.`
2564
+ ]
2565
+ });
216
2566
  });
217
2567
  }
218
2568
  /**
@@ -242,6 +2592,7 @@ function model(question, session, env = {}) {
242
2592
  }),
243
2593
  regionLabels: { ...normalizedQuestion.regionLabels || {} },
244
2594
  scoringPolicy: normalizedQuestion.scoringPolicy ?? "partialPerTile",
2595
+ language: normalizedQuestion.language,
245
2596
  disabled: safeEnv.mode !== "gather",
246
2597
  mode: safeEnv.mode,
247
2598
  env: safeEnv
@@ -252,10 +2603,8 @@ function model(question, session, env = {}) {
252
2603
  out.correctRegionsById = correctRegionsById;
253
2604
  out.correctness = getCorrectnessMap(normalizedQuestion, session);
254
2605
  }
255
- if (safeEnv.role === "instructor" && (safeEnv.mode === "view" || safeEnv.mode === "evaluate")) {
256
- const anyQ = normalizedQuestion;
257
- out.teacherInstructions = anyQ.teacherInstructionsEnabled ? anyQ.teacherInstructions ?? null : null;
258
- } else out.teacherInstructions = null;
2606
+ if (safeEnv.role === "instructor" && (safeEnv.mode === "view" || safeEnv.mode === "evaluate")) out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions ?? null : null;
2607
+ else out.teacherInstructions = null;
259
2608
  resolve(out);
260
2609
  });
261
2610
  }
@@ -270,7 +2619,6 @@ function createCorrectResponseSession(question, env = {}) {
270
2619
  for (const tile of model.tiles) placements[tile.id] = normalizeRegion(tile.correctRegion);
271
2620
  resolve({
272
2621
  id: "1",
273
- element: "venn-classification",
274
2622
  placements,
275
2623
  completed: true
276
2624
  });
@@ -350,12 +2698,11 @@ function buildPreviewSession(model) {
350
2698
  for (const tile of m.tiles) placements[tile.id] = normalizeRegion(tile.correctRegion);
351
2699
  return {
352
2700
  id: "preview",
353
- element: "venn-classification",
354
2701
  placements,
355
2702
  completed: true
356
2703
  };
357
2704
  }
358
2705
  //#endregion
359
- export { SUPPORTED_CIRCLE_COUNTS, buildPreviewSession, composeRegionLabel, createCorrectResponseSession, createDefaultModel, enumerateRegions, getCorrectnessMap, getRegionLabel, getTileCorrectness, isComplete, model, normalizeRegion, normalizeSession, outcome, regionKey, regionsEqual, validate };
2706
+ export { SUPPORTED_CIRCLE_COUNTS, buildPreviewSession, composeRegionLabel, createCorrectResponseSession, createDefaultModel, effectiveScoringPolicy, enumerateRegions, getCorrectnessMap, getRegionLabel, getTileCorrectness, isComplete, model, normalizeRegion, normalizeSession, outcome, regionKey, regionsEqual, validate };
360
2707
 
361
2708
  //# sourceMappingURL=index.js.map