@pie-element/match 12.1.2-next.1 → 12.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.json +1462 -0
  2. package/CHANGELOG.md +2337 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +892 -0
  6. package/configure/CHANGELOG.md +2040 -0
  7. package/configure/lib/add-row.js +40 -0
  8. package/configure/lib/add-row.js.map +1 -0
  9. package/configure/lib/answer-config-block.js +288 -0
  10. package/configure/lib/answer-config-block.js.map +1 -0
  11. package/configure/lib/common.js +31 -0
  12. package/configure/lib/common.js.map +1 -0
  13. package/configure/lib/configure.js +410 -0
  14. package/configure/lib/configure.js.map +1 -0
  15. package/configure/lib/defaults.js +201 -0
  16. package/configure/lib/defaults.js.map +1 -0
  17. package/configure/lib/general-config-block.js +144 -0
  18. package/configure/lib/general-config-block.js.map +1 -0
  19. package/configure/lib/index.js +152 -0
  20. package/configure/lib/index.js.map +1 -0
  21. package/configure/lib/row.js +321 -0
  22. package/configure/lib/row.js.map +1 -0
  23. package/configure/lib/utils.js +12 -0
  24. package/configure/lib/utils.js.map +1 -0
  25. package/configure/package.json +29 -0
  26. package/configure/utils.js +19 -0
  27. package/controller/CHANGELOG.json +502 -0
  28. package/controller/CHANGELOG.md +1363 -0
  29. package/controller/lib/defaults.js +25 -0
  30. package/controller/lib/defaults.js.map +1 -0
  31. package/controller/lib/index.js +424 -0
  32. package/controller/lib/index.js.map +1 -0
  33. package/controller/package.json +24 -0
  34. package/docs/config-schema.json +2929 -0
  35. package/docs/config-schema.json.md +2162 -0
  36. package/docs/demo/config.js +8 -0
  37. package/docs/demo/generate.js +49 -0
  38. package/docs/demo/index.html +1 -0
  39. package/docs/demo/session.js +11 -0
  40. package/docs/pie-schema.json +1530 -0
  41. package/docs/pie-schema.json.md +907 -0
  42. package/lib/answer-grid.js +166 -0
  43. package/lib/answer-grid.js.map +1 -0
  44. package/lib/index.js +85 -0
  45. package/lib/index.js.map +1 -0
  46. package/lib/main.js +163 -0
  47. package/lib/main.js.map +1 -0
  48. package/package.json +21 -88
  49. package/configure.js +0 -2
  50. package/controller.js +0 -1
  51. package/dist/author/add-row.d.ts +0 -17
  52. package/dist/author/add-row.js +0 -24
  53. package/dist/author/answer-config-block.d.ts +0 -36
  54. package/dist/author/answer-config-block.js +0 -176
  55. package/dist/author/common.d.ts +0 -22
  56. package/dist/author/configure.d.ts +0 -48
  57. package/dist/author/configure.js +0 -259
  58. package/dist/author/defaults.d.ts +0 -203
  59. package/dist/author/defaults.js +0 -151
  60. package/dist/author/general-config-block.d.ts +0 -22
  61. package/dist/author/general-config-block.js +0 -93
  62. package/dist/author/index.d.ts +0 -44
  63. package/dist/author/index.js +0 -76
  64. package/dist/author/row.d.ts +0 -51
  65. package/dist/author/row.js +0 -204
  66. package/dist/author/utils.d.ts +0 -10
  67. package/dist/author/utils.js +0 -10
  68. package/dist/browser/Typography-CbSskKxx.js +0 -9217
  69. package/dist/browser/Typography-CbSskKxx.js.map +0 -1
  70. package/dist/browser/author/index.js +0 -41596
  71. package/dist/browser/author/index.js.map +0 -1
  72. package/dist/browser/browser-kkT1XVKw.js +0 -219
  73. package/dist/browser/browser-kkT1XVKw.js.map +0 -1
  74. package/dist/browser/controller/index.js +0 -267
  75. package/dist/browser/controller/index.js.map +0 -1
  76. package/dist/browser/delivery/index.js +0 -1984
  77. package/dist/browser/delivery/index.js.map +0 -1
  78. package/dist/browser/dist-i687VHmY.js +0 -100
  79. package/dist/browser/dist-i687VHmY.js.map +0 -1
  80. package/dist/browser/match.css +0 -2
  81. package/dist/controller/defaults.d.ts +0 -27
  82. package/dist/controller/defaults.js +0 -25
  83. package/dist/controller/index.d.ts +0 -29
  84. package/dist/controller/index.js +0 -154
  85. package/dist/delivery/answer-grid.d.ts +0 -28
  86. package/dist/delivery/answer-grid.js +0 -99
  87. package/dist/delivery/index.d.ts +0 -21
  88. package/dist/delivery/index.js +0 -51
  89. package/dist/delivery/main.d.ts +0 -26
  90. package/dist/delivery/main.js +0 -112
  91. package/dist/index.d.ts +0 -1
  92. package/dist/index.iife.d.ts +0 -8
  93. package/dist/index.iife.js +0 -148
  94. package/dist/index.js +0 -2
  95. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  96. package/dist/runtime-support.d.ts +0 -12
  97. package/dist/runtime-support.js +0 -12
@@ -1,1984 +0,0 @@
1
- import { a as e } from "../browser-kkT1XVKw.js";
2
- import { Nt as t, O as n, a as r, d as i, dt as a, f as o, ft as s, ht as c, k as l, n as u, p as d, pt as f, r as p, t as m, u as h, x as g } from "../Typography-CbSskKxx.js";
3
- import _, { useRef as v } from "react";
4
- import { createRoot as y } from "react-dom/client";
5
- import { jsx as b, jsxs as x } from "react/jsx-runtime";
6
- //#region ../../lib-react/correct-answer-toggle/dist/expander.js
7
- var S = /* @__PURE__ */ e(t(), 1), C = "height ease-in 300ms, opacity ease-in 300ms", w = c("div")(() => ({
8
- position: "relative",
9
- height: 0,
10
- overflow: "hidden",
11
- display: "flex",
12
- visibility: "hidden",
13
- width: 0,
14
- "&.enter": {
15
- transition: C,
16
- opacity: 1,
17
- height: "auto",
18
- width: "auto",
19
- visibility: "visible",
20
- minHeight: "25px"
21
- },
22
- "&.enter-done": {
23
- height: "auto",
24
- visibility: "visible",
25
- width: "auto",
26
- minHeight: "25px"
27
- },
28
- "&.exit": {
29
- transition: C,
30
- opacity: 0,
31
- height: 0,
32
- visibility: "visible",
33
- width: 0
34
- },
35
- "&.exit-done": {
36
- opacity: 0,
37
- visibility: "hidden",
38
- height: 0,
39
- width: 0
40
- }
41
- })), T = (e) => {
42
- let { show: t, children: n, className: r } = e, i = v(null);
43
- return /* @__PURE__ */ b(f, {
44
- nodeRef: i,
45
- in: t,
46
- appear: !0,
47
- mountOnEnter: !1,
48
- timeout: 300,
49
- classNames: {
50
- enter: "enter",
51
- enterDone: "enter-done",
52
- exit: "exit",
53
- exitDone: "exit-done"
54
- },
55
- children: /* @__PURE__ */ b(w, {
56
- ref: i,
57
- className: r,
58
- children: n
59
- })
60
- });
61
- };
62
- T.propTypes = {
63
- show: S.default.bool.isRequired,
64
- className: S.default.string,
65
- children: S.default.oneOfType([S.default.arrayOf(S.default.node), S.default.node]).isRequired
66
- };
67
- //#endregion
68
- //#region ../../lib-react/icons/dist/correct-response-icon.js
69
- var E = ({ bgFill: e, fgFill: t }) => /* @__PURE__ */ x("svg", {
70
- preserveAspectRatio: "xMinYMin meet",
71
- version: "1.1",
72
- viewBox: "-283 359 34 35",
73
- style: { enableBackground: "new -283 359 34 35" },
74
- children: [
75
- /* @__PURE__ */ b("circle", {
76
- cx: "-266",
77
- cy: "375.9",
78
- r: "14",
79
- fill: e
80
- }),
81
- /* @__PURE__ */ b("path", {
82
- d: "M-280.5,375.9c0-8,6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5s-6.5,14.5-14.5,14.5S-280.5,383.9-280.5,375.9z\n M-279.5,375.9c0,7.4,6.1,13.5,13.5,13.5c7.4,0,13.5-6.1,13.5-13.5s-6.1-13.5-13.5-13.5C-273.4,362.4-279.5,368.5-279.5,375.9z",
83
- fill: e
84
- }),
85
- /* @__PURE__ */ b("polygon", {
86
- points: "-265.4,383.1 -258.6,377.2 -261.2,374.2 -264.3,376.9 -268.9,368.7 -272.4,370.6",
87
- fill: t
88
- })
89
- ]
90
- });
91
- E.propTypes = {
92
- bgFill: S.default.string.isRequired,
93
- fgFill: S.default.string.isRequired
94
- };
95
- var D = ({ bgFill: e, fgFill: t, borderFill: n }) => /* @__PURE__ */ x("svg", {
96
- preserveAspectRatio: "xMinYMin meet",
97
- version: "1.1",
98
- viewBox: "-129.5 127 34 35",
99
- style: { enableBackground: "new -129.5 127 34 35" },
100
- children: [
101
- /* @__PURE__ */ b("path", {
102
- style: {
103
- fill: "#D0CAC5",
104
- stroke: "#E6E3E0",
105
- strokeWidth: .75,
106
- strokeMiterlimit: 10
107
- },
108
- d: "M-112.9,160.4c-8.5,0-15.5-6.9-15.5-15.5c0-8.5,6.9-15.5,15.5-15.5s15.5,6.9,15.5,15.5\n C-97.4,153.5-104.3,160.4-112.9,160.4z"
109
- }),
110
- /* @__PURE__ */ b("path", {
111
- style: {
112
- fill: "#B3ABA4",
113
- stroke: "#CDC7C2",
114
- strokeWidth: .5,
115
- strokeMiterlimit: 10
116
- },
117
- d: "M-113.2,159c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-105.2,159-113.2,159z"
118
- }),
119
- /* @__PURE__ */ b("circle", {
120
- cx: "-114.2",
121
- cy: "143.5",
122
- r: "14",
123
- fill: e
124
- }),
125
- /* @__PURE__ */ b("path", {
126
- d: "M-114.2,158c-8,0-14.5-6.5-14.5-14.5s6.5-14.5,14.5-14.5s14.5,6.5,14.5,14.5S-106.2,158-114.2,158z\n M-114.2,130c-7.4,0-13.5,6.1-13.5,13.5s6.1,13.5,13.5,13.5s13.5-6.1,13.5-13.5S-106.8,130-114.2,130z",
127
- fill: n
128
- }),
129
- /* @__PURE__ */ b("polygon", {
130
- points: "-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2",
131
- fill: t
132
- })
133
- ]
134
- });
135
- D.propTypes = {
136
- bgFill: S.default.string.isRequired,
137
- fgFill: S.default.string.isRequired,
138
- borderFill: S.default.string.isRequired
139
- };
140
- var ee = c("div")(({ size: e }) => ({
141
- width: e || "25px",
142
- height: e || "25px"
143
- })), O = ({ open: e, size: t }) => /* @__PURE__ */ b(ee, {
144
- size: t,
145
- children: e ? /* @__PURE__ */ b(E, {
146
- bgFill: "#bce2ff",
147
- fgFill: "#1a9cff"
148
- }) : /* @__PURE__ */ b(D, {
149
- bgFill: "white",
150
- fgFill: "#1a9cff",
151
- borderFill: "#bce2ff"
152
- })
153
- });
154
- O.propTypes = {
155
- open: S.default.bool,
156
- size: S.default.string
157
- }, O.defaultProps = { open: !1 };
158
- //#endregion
159
- //#region ../../lib-react/translator/dist/en.js
160
- var te = {
161
- translation: {
162
- categorize: {
163
- limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
164
- maxChoicesPerCategoryRestriction: "To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s]."
165
- },
166
- ebsr: { part: "Part {{index}}" },
167
- numberLine: {
168
- addElementLimit_one: "You can only add {{count}} element",
169
- addElementLimit_other: "You can only add {{count}} elements",
170
- clearAll: "Clear all"
171
- },
172
- imageClozeAssociation: {
173
- reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
174
- reachedLimit_other: "Full"
175
- },
176
- drawingResponse: {
177
- fillColor: "Fill color",
178
- outlineColor: "Outline color",
179
- noFill: "No fill",
180
- lightblue: "Light blue",
181
- lightyellow: "Light yellow",
182
- red: "Red",
183
- orange: "Orange",
184
- yellow: "Yellow",
185
- violet: "Violet",
186
- blue: "Blue",
187
- green: "Green",
188
- white: "White",
189
- black: "Black",
190
- onDoubleClick: "Double click to edit this text. Press Enter to submit."
191
- },
192
- charting: {
193
- addCategory: "Add category",
194
- actions: "Actions",
195
- add: "Add",
196
- delete: "Delete",
197
- newLabel: "New label",
198
- reachedLimit_other: "There can't be more than {{count}} categories.",
199
- keyLegend: {
200
- incorrectAnswer: "Student incorrect answer",
201
- correctAnswer: "Student correct answer",
202
- correctKeyAnswer: "Answer key correct"
203
- }
204
- },
205
- graphing: {
206
- point: "Point",
207
- circle: "Circle",
208
- line: "Line",
209
- parabola: "Parabola",
210
- absolute: "Absolute Value",
211
- exponential: "Exponential",
212
- polygon: "Polygon",
213
- ray: "Ray",
214
- segment: "Segment",
215
- sine: "Sine",
216
- vector: "Vector",
217
- label: "Label",
218
- redo: "Redo",
219
- reset: "Reset"
220
- },
221
- 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." },
222
- multipleChoice: {
223
- minSelections: "Select at least {{minSelections}}.",
224
- maxSelections_one: "Only {{maxSelections}} answer is allowed.",
225
- maxSelections_other: "Only {{maxSelections}} answers are allowed.",
226
- minmaxSelections_equal: "Select {{minSelections}}.",
227
- minmaxSelections_range: "Select between {{minSelections}} and {{maxSelections}}."
228
- },
229
- selectText: {
230
- correctAnswerSelected: "Correct",
231
- correctAnswerNotSelected: "Correct Answer Not Selected",
232
- incorrectSelection: "Incorrect Selection",
233
- key: "Key"
234
- }
235
- },
236
- common: {
237
- undo: "Undo",
238
- clearAll: "Clear all",
239
- correct: "Correct",
240
- incorrect: "Incorrect",
241
- showCorrectAnswer: "Show correct answer",
242
- hideCorrectAnswer: "Hide correct answer",
243
- 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.",
244
- warning: "Warning",
245
- showNote: "Show Note",
246
- hideNote: "Hide Note",
247
- cancel: "Cancel"
248
- }
249
- }, ne = {
250
- translation: {
251
- categorize: {
252
- limitMaxChoicesPerCategory: "Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
253
- maxChoicesPerCategoryRestriction: "Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta"
254
- },
255
- ebsr: { part: "Parte {{index}}" },
256
- numberLine: {
257
- addElementLimit_one: "Solo puedes agregar {{count}} elemento",
258
- addElementLimit_other: "Solo puedes agregar {{count}} elementos",
259
- clearAll: "Borrar todo"
260
- },
261
- imageClozeAssociation: {
262
- reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
263
- reachedLimit_other: "Lleno"
264
- },
265
- drawingResponse: {
266
- fillColor: "Color de relleno",
267
- outlineColor: "Color del contorno",
268
- noFill: "Sin relleno",
269
- lightblue: "Azul claro",
270
- lightyellow: "Amarillo claro",
271
- red: "Rojo",
272
- orange: "Naranja",
273
- yellow: "Amarillo",
274
- violet: "Violeta",
275
- blue: "Azul",
276
- green: "Verde",
277
- white: "Blanco",
278
- black: "Negro",
279
- onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
280
- },
281
- charting: {
282
- addCategory: "Añadir categoría",
283
- actions: "Acciones",
284
- add: "Añadir",
285
- delete: "Eliminar",
286
- newLabel: "Nueva etiqueta",
287
- reachedLimit_other: "No puede haber más de {{count}} categorías.",
288
- keyLegend: {
289
- incorrectAnswer: "Respuesta incorrecta del estudiante",
290
- correctAnswer: "Respuesta correcta del estudiante",
291
- correctKeyAnswer: "Clave de respuesta correcta"
292
- }
293
- },
294
- graphing: {
295
- point: "Punto",
296
- circle: "Circulo",
297
- line: "Línea",
298
- parabola: "Parábola",
299
- absolute: "Valor absoluto",
300
- exponential: "Exponencial",
301
- polygon: "Polígono",
302
- ray: "Semirrecta",
303
- segment: "Segmento ",
304
- sine: "Seno",
305
- vector: "Vector",
306
- label: "Etiqueta",
307
- redo: "Rehacer",
308
- reset: "Reiniciar"
309
- },
310
- 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." },
311
- multipleChoice: {
312
- minSelections: "Seleccione al menos {{minSelections}}.",
313
- maxSelections_one: "Sólo se permite {{maxSelections}} respuesta.",
314
- maxSelections_other: "Sólo se permiten {{maxSelections}} respuestas.",
315
- minmaxSelections_equal: "Seleccione {{minSelections}}.",
316
- minmaxSelections_range: "Seleccione entre {{minSelections}} y {{maxSelections}}."
317
- },
318
- selectText: {
319
- correctAnswerSelected: "Respuesta Correcta",
320
- correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
321
- incorrectSelection: "Selección Incorrecta",
322
- key: "Clave"
323
- }
324
- },
325
- common: {
326
- undo: "Deshacer",
327
- clearAll: "Borrar todo",
328
- correct: "Correct",
329
- incorrect: "Incorrect",
330
- showCorrectAnswer: "Mostrar respuesta correcta",
331
- hideCorrectAnswer: "Ocultar respuesta correcta",
332
- 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.",
333
- warning: "Advertencia",
334
- showNote: "Mostrar Nota",
335
- hideNote: "Ocultar Nota",
336
- cancel: "Cancelar"
337
- }
338
- }, k = (e) => typeof e == "string", A = () => {
339
- let e, t, n = new Promise((n, r) => {
340
- e = n, t = r;
341
- });
342
- return n.resolve = e, n.reject = t, n;
343
- }, re = (e) => e == null ? "" : "" + e, ie = (e, t, n) => {
344
- e.forEach((e) => {
345
- t[e] && (n[e] = t[e]);
346
- });
347
- }, ae = /###/g, oe = (e) => e && e.indexOf("###") > -1 ? e.replace(ae, ".") : e, se = (e) => !e || k(e), j = (e, t, n) => {
348
- let r = k(t) ? t.split(".") : t, i = 0;
349
- for (; i < r.length - 1;) {
350
- if (se(e)) return {};
351
- let t = oe(r[i]);
352
- !e[t] && n && (e[t] = new n()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++i;
353
- }
354
- return se(e) ? {} : {
355
- obj: e,
356
- k: oe(r[i])
357
- };
358
- }, ce = (e, t, n) => {
359
- let { obj: r, k: i } = j(e, t, Object);
360
- if (r !== void 0 || t.length === 1) {
361
- r[i] = n;
362
- return;
363
- }
364
- let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = j(e, o, Object);
365
- for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = j(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
366
- s.obj[`${s.k}.${a}`] = n;
367
- }, le = (e, t, n, r) => {
368
- let { obj: i, k: a } = j(e, t, Object);
369
- i[a] = i[a] || [], i[a].push(n);
370
- }, M = (e, t) => {
371
- let { obj: n, k: r } = j(e, t);
372
- if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
373
- }, ue = (e, t, n) => {
374
- let r = M(e, n);
375
- return r === void 0 ? M(t, n) : r;
376
- }, de = (e, t, n) => {
377
- for (let r in t) r !== "__proto__" && r !== "constructor" && (r in e ? k(e[r]) || e[r] instanceof String || k(t[r]) || t[r] instanceof String ? n && (e[r] = t[r]) : de(e[r], t[r], n) : e[r] = t[r]);
378
- return e;
379
- }, N = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), fe = {
380
- "&": "&amp;",
381
- "<": "&lt;",
382
- ">": "&gt;",
383
- "\"": "&quot;",
384
- "'": "&#39;",
385
- "/": "&#x2F;"
386
- }, pe = (e) => k(e) ? e.replace(/[&<>"'\/]/g, (e) => fe[e]) : e, me = class {
387
- constructor(e) {
388
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
389
- }
390
- getRegExp(e) {
391
- let t = this.regExpMap.get(e);
392
- if (t !== void 0) return t;
393
- let n = new RegExp(e);
394
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
395
- }
396
- }, he = [
397
- " ",
398
- ",",
399
- "?",
400
- "!",
401
- ";"
402
- ], ge = new me(20), _e = (e, t, n) => {
403
- t ||= "", n ||= "";
404
- let r = he.filter((e) => t.indexOf(e) < 0 && n.indexOf(e) < 0);
405
- if (r.length === 0) return !0;
406
- let i = ge.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
407
- if (!a) {
408
- let t = e.indexOf(n);
409
- t > 0 && !i.test(e.substring(0, t)) && (a = !0);
410
- }
411
- return a;
412
- }, P = (e, t, n = ".") => {
413
- if (!e) return;
414
- if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
415
- let r = t.split(n), i = e;
416
- for (let e = 0; e < r.length;) {
417
- if (!i || typeof i != "object") return;
418
- let t, a = "";
419
- for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
420
- if ([
421
- "string",
422
- "number",
423
- "boolean"
424
- ].indexOf(typeof t) > -1 && o < r.length - 1) continue;
425
- e += o - e + 1;
426
- break;
427
- }
428
- i = t;
429
- }
430
- return i;
431
- }, F = (e) => e?.replace(/_/g, "-"), ve = {
432
- type: "logger",
433
- log(e) {
434
- this.output("log", e);
435
- },
436
- warn(e) {
437
- this.output("warn", e);
438
- },
439
- error(e) {
440
- this.output("error", e);
441
- },
442
- output(e, t) {
443
- console?.[e]?.apply?.(console, t);
444
- }
445
- }, I = new class e {
446
- constructor(e, t = {}) {
447
- this.init(e, t);
448
- }
449
- init(e, t = {}) {
450
- this.prefix = t.prefix || "i18next:", this.logger = e || ve, this.options = t, this.debug = t.debug;
451
- }
452
- log(...e) {
453
- return this.forward(e, "log", "", !0);
454
- }
455
- warn(...e) {
456
- return this.forward(e, "warn", "", !0);
457
- }
458
- error(...e) {
459
- return this.forward(e, "error", "");
460
- }
461
- deprecate(...e) {
462
- return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
463
- }
464
- forward(e, t, n, r) {
465
- return r && !this.debug ? null : (k(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
466
- }
467
- create(t) {
468
- return new e(this.logger, {
469
- prefix: `${this.prefix}:${t}:`,
470
- ...this.options
471
- });
472
- }
473
- clone(t) {
474
- return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
475
- }
476
- }(), L = class {
477
- constructor() {
478
- this.observers = {};
479
- }
480
- on(e, t) {
481
- return e.split(" ").forEach((e) => {
482
- this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
483
- let n = this.observers[e].get(t) || 0;
484
- this.observers[e].set(t, n + 1);
485
- }), this;
486
- }
487
- off(e, t) {
488
- if (this.observers[e]) {
489
- if (!t) {
490
- delete this.observers[e];
491
- return;
492
- }
493
- this.observers[e].delete(t);
494
- }
495
- }
496
- emit(e, ...t) {
497
- this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
498
- for (let r = 0; r < n; r++) e(...t);
499
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
500
- for (let i = 0; i < r; i++) n.apply(n, [e, ...t]);
501
- });
502
- }
503
- }, ye = class extends L {
504
- constructor(e, t = {
505
- ns: ["translation"],
506
- defaultNS: "translation"
507
- }) {
508
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
509
- }
510
- addNamespaces(e) {
511
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
512
- }
513
- removeNamespaces(e) {
514
- let t = this.options.ns.indexOf(e);
515
- t > -1 && this.options.ns.splice(t, 1);
516
- }
517
- getResource(e, t, n, r = {}) {
518
- let i = r.keySeparator === void 0 ? this.options.keySeparator : r.keySeparator, a = r.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : r.ignoreJSONStructure, o;
519
- e.indexOf(".") > -1 ? o = e.split(".") : (o = [e, t], n && (Array.isArray(n) ? o.push(...n) : k(n) && i ? o.push(...n.split(i)) : o.push(n)));
520
- let s = M(this.data, o);
521
- return !s && !t && !n && e.indexOf(".") > -1 && (e = o[0], t = o[1], n = o.slice(2).join(".")), s || !a || !k(n) ? s : P(this.data?.[e]?.[t], n, i);
522
- }
523
- addResource(e, t, n, r, i = { silent: !1 }) {
524
- let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
525
- n && (o = o.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), ce(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
526
- }
527
- addResources(e, t, n, r = { silent: !1 }) {
528
- for (let r in n) (k(n[r]) || Array.isArray(n[r])) && this.addResource(e, t, r, n[r], { silent: !0 });
529
- r.silent || this.emit("added", e, t, n);
530
- }
531
- addResourceBundle(e, t, n, r, i, a = {
532
- silent: !1,
533
- skipCopy: !1
534
- }) {
535
- let o = [e, t];
536
- e.indexOf(".") > -1 && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
537
- let s = M(this.data, o) || {};
538
- a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? de(s, n, i) : s = {
539
- ...s,
540
- ...n
541
- }, ce(this.data, o, s), a.silent || this.emit("added", e, t, n);
542
- }
543
- removeResourceBundle(e, t) {
544
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
545
- }
546
- hasResourceBundle(e, t) {
547
- return this.getResource(e, t) !== void 0;
548
- }
549
- getResourceBundle(e, t) {
550
- return t ||= this.options.defaultNS, this.getResource(e, t);
551
- }
552
- getDataByLanguage(e) {
553
- return this.data[e];
554
- }
555
- hasLanguageSomeTranslations(e) {
556
- let t = this.getDataByLanguage(e);
557
- return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
558
- }
559
- toJSON() {
560
- return this.data;
561
- }
562
- }, be = {
563
- processors: {},
564
- addPostProcessor(e) {
565
- this.processors[e.name] = e;
566
- },
567
- handle(e, t, n, r, i) {
568
- return e.forEach((e) => {
569
- t = this.processors[e]?.process(t, n, r, i) ?? t;
570
- }), t;
571
- }
572
- }, xe = Symbol("i18next/PATH_KEY");
573
- function Se() {
574
- let e = [], t = Object.create(null), n;
575
- return t.get = (r, i) => (n?.revoke?.(), i === xe ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
576
- }
577
- function R(e, t) {
578
- let { [xe]: n } = e(Se()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":";
579
- if (n.length > 1 && i) {
580
- let e = t?.ns, a = Array.isArray(e) ? e : null;
581
- if (a && a.length > 1 && a.slice(1).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
582
- }
583
- return n.join(r);
584
- }
585
- var Ce = {}, z = (e) => !k(e) && typeof e != "boolean" && typeof e != "number", B = class e extends L {
586
- constructor(e, t = {}) {
587
- super(), ie([
588
- "resourceStore",
589
- "languageUtils",
590
- "pluralResolver",
591
- "interpolator",
592
- "backendConnector",
593
- "i18nFormat",
594
- "utils"
595
- ], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = I.create("translator");
596
- }
597
- changeLanguage(e) {
598
- e && (this.language = e);
599
- }
600
- exists(e, t = { interpolation: {} }) {
601
- let n = { ...t };
602
- if (e == null) return !1;
603
- let r = this.resolve(e, n);
604
- if (r?.res === void 0) return !1;
605
- let i = z(r.res);
606
- return !(n.returnObjects === !1 && i);
607
- }
608
- extractFromKey(e, t) {
609
- let n = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
610
- n === void 0 && (n = ":");
611
- let r = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, i = t.ns || this.options.defaultNS || [], a = n && e.indexOf(n) > -1, o = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !_e(e, n, r);
612
- if (a && !o) {
613
- let t = e.match(this.interpolator.nestingRegexp);
614
- if (t && t.length > 0) return {
615
- key: e,
616
- namespaces: k(i) ? [i] : i
617
- };
618
- let a = e.split(n);
619
- (n !== r || n === r && this.options.ns.indexOf(a[0]) > -1) && (i = a.shift()), e = a.join(r);
620
- }
621
- return {
622
- key: e,
623
- namespaces: k(i) ? [i] : i
624
- };
625
- }
626
- translate(t, n, r) {
627
- let i = typeof n == "object" ? { ...n } : n;
628
- if (typeof i != "object" && this.options.overloadTranslationOptionHandler && (i = this.options.overloadTranslationOptionHandler(arguments)), typeof i == "object" && (i = { ...i }), i ||= {}, t == null) return "";
629
- typeof t == "function" && (t = R(t, {
630
- ...this.options,
631
- ...i
632
- })), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? R(e, {
633
- ...this.options,
634
- ...i
635
- }) : String(e));
636
- let a = i.returnDetails === void 0 ? this.options.returnDetails : i.returnDetails, o = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, { key: s, namespaces: c } = this.extractFromKey(t[t.length - 1], i), l = c[c.length - 1], u = i.nsSeparator === void 0 ? this.options.nsSeparator : i.nsSeparator;
637
- u === void 0 && (u = ":");
638
- let d = i.lng || this.language, f = i.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
639
- if (d?.toLowerCase() === "cimode") return f ? a ? {
640
- res: `${l}${u}${s}`,
641
- usedKey: s,
642
- exactUsedKey: s,
643
- usedLng: d,
644
- usedNS: l,
645
- usedParams: this.getUsedParamsDetails(i)
646
- } : `${l}${u}${s}` : a ? {
647
- res: s,
648
- usedKey: s,
649
- exactUsedKey: s,
650
- usedLng: d,
651
- usedNS: l,
652
- usedParams: this.getUsedParamsDetails(i)
653
- } : s;
654
- let p = this.resolve(t, i), m = p?.res, h = p?.usedKey || s, g = p?.exactUsedKey || s, _ = [
655
- "[object Number]",
656
- "[object Function]",
657
- "[object RegExp]"
658
- ], v = i.joinArrays === void 0 ? this.options.joinArrays : i.joinArrays, y = !this.i18nFormat || this.i18nFormat.handleAsObject, b = i.count !== void 0 && !k(i.count), x = e.hasDefaultValue(i), S = b ? this.pluralResolver.getSuffix(d, i.count, i) : "", C = i.ordinal && b ? this.pluralResolver.getSuffix(d, i.count, { ordinal: !1 }) : "", w = b && !i.ordinal && i.count === 0, T = w && i[`defaultValue${this.options.pluralSeparator}zero`] || i[`defaultValue${S}`] || i[`defaultValue${C}`] || i.defaultValue, E = m;
659
- y && !m && x && (E = T);
660
- let D = z(E), ee = Object.prototype.toString.apply(E);
661
- if (y && E && D && _.indexOf(ee) < 0 && !(k(v) && Array.isArray(E))) {
662
- if (!i.returnObjects && !this.options.returnObjects) {
663
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
664
- let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(h, E, {
665
- ...i,
666
- ns: c
667
- }) : `key '${s} (${this.language})' returned an object instead of string.`;
668
- return a ? (p.res = e, p.usedParams = this.getUsedParamsDetails(i), p) : e;
669
- }
670
- if (o) {
671
- let e = Array.isArray(E), t = e ? [] : {}, n = e ? g : h;
672
- for (let e in E) if (Object.prototype.hasOwnProperty.call(E, e)) {
673
- let r = `${n}${o}${e}`;
674
- x && !m ? t[e] = this.translate(r, {
675
- ...i,
676
- defaultValue: z(T) ? T[e] : void 0,
677
- joinArrays: !1,
678
- ns: c
679
- }) : t[e] = this.translate(r, {
680
- ...i,
681
- joinArrays: !1,
682
- ns: c
683
- }), t[e] === r && (t[e] = E[e]);
684
- }
685
- m = t;
686
- }
687
- } else if (y && k(v) && Array.isArray(m)) m = m.join(v), m &&= this.extendTranslation(m, t, i, r);
688
- else {
689
- let e = !1, n = !1;
690
- !this.isValidLookup(m) && x && (e = !0, m = T), this.isValidLookup(m) || (n = !0, m = s);
691
- let a = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : m, c = x && T !== m && this.options.updateMissing;
692
- if (n || e || c) {
693
- if (this.logger.log(c ? "updateKey" : "missingKey", d, l, s, c ? T : m), o) {
694
- let e = this.resolve(s, {
695
- ...i,
696
- keySeparator: !1
697
- });
698
- e && e.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.");
699
- }
700
- let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, i.lng || this.language);
701
- if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
702
- else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(i.lng || this.language) : e.push(i.lng || this.language);
703
- let n = (e, t, n) => {
704
- let r = x && n !== m ? n : a;
705
- this.options.missingKeyHandler ? this.options.missingKeyHandler(e, l, t, r, c, i) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, l, t, r, c, i), this.emit("missingKey", e, l, t, m);
706
- };
707
- this.options.saveMissing && (this.options.saveMissingPlurals && b ? e.forEach((e) => {
708
- let t = this.pluralResolver.getSuffixes(e, i);
709
- w && i[`defaultValue${this.options.pluralSeparator}zero`] && t.indexOf(`${this.options.pluralSeparator}zero`) < 0 && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
710
- n([e], s + t, i[`defaultValue${t}`] || T);
711
- });
712
- }) : n(e, s, T));
713
- }
714
- m = this.extendTranslation(m, t, i, p, r), n && m === s && this.options.appendNamespaceToMissingKey && (m = `${l}${u}${s}`), (n || e) && this.options.parseMissingKeyHandler && (m = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${l}${u}${s}` : s, e ? m : void 0, i));
715
- }
716
- return a ? (p.res = m, p.usedParams = this.getUsedParamsDetails(i), p) : m;
717
- }
718
- extendTranslation(e, t, n, r, i) {
719
- if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
720
- ...this.options.interpolation.defaultVariables,
721
- ...n
722
- }, n.lng || this.language || r.usedLng, r.usedNS, r.usedKey, { resolved: r });
723
- else if (!n.skipInterpolation) {
724
- n.interpolation && this.interpolator.init({
725
- ...n,
726
- interpolation: {
727
- ...this.options.interpolation,
728
- ...n.interpolation
729
- }
730
- });
731
- let a = k(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), o;
732
- if (a) {
733
- let t = e.match(this.interpolator.nestingRegexp);
734
- o = t && t.length;
735
- }
736
- let s = n.replace && !k(n.replace) ? n.replace : n;
737
- if (this.options.interpolation.defaultVariables && (s = {
738
- ...this.options.interpolation.defaultVariables,
739
- ...s
740
- }), e = this.interpolator.interpolate(e, s, n.lng || this.language || r.usedLng, n), a) {
741
- let t = e.match(this.interpolator.nestingRegexp), r = t && t.length;
742
- o < r && (n.nest = !1);
743
- }
744
- !n.lng && r && r.res && (n.lng = this.language || r.usedLng), n.nest !== !1 && (e = this.interpolator.nest(e, (...e) => i?.[0] === e[0] && !n.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), n)), n.interpolation && this.interpolator.reset();
745
- }
746
- let a = n.postProcess || this.options.postProcess, o = k(a) ? [a] : a;
747
- return e != null && o?.length && n.applyPostProcessor !== !1 && (e = be.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
748
- i18nResolved: {
749
- ...r,
750
- usedParams: this.getUsedParamsDetails(n)
751
- },
752
- ...n
753
- } : n, this)), e;
754
- }
755
- resolve(e, t = {}) {
756
- let n, r, i, a, o;
757
- return k(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? R(e, {
758
- ...this.options,
759
- ...t
760
- }) : e)), e.forEach((e) => {
761
- if (this.isValidLookup(n)) return;
762
- let s = this.extractFromKey(e, t), c = s.key;
763
- r = c;
764
- let l = s.namespaces;
765
- this.options.fallbackNS && (l = l.concat(this.options.fallbackNS));
766
- let u = t.count !== void 0 && !k(t.count), d = u && !t.ordinal && t.count === 0, f = t.context !== void 0 && (k(t.context) || typeof t.context == "number") && t.context !== "", p = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
767
- l.forEach((e) => {
768
- this.isValidLookup(n) || (o = e, !Ce[`${p[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(o) && (Ce[`${p[0]}-${e}`] = !0, this.logger.warn(`key "${r}" for languages "${p.join(", ")}" won't get resolved as namespace "${o}" 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!!!")), p.forEach((r) => {
769
- if (this.isValidLookup(n)) return;
770
- a = r;
771
- let o = [c];
772
- if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(o, c, r, e, t);
773
- else {
774
- let e;
775
- u && (e = this.pluralResolver.getSuffix(r, t.count, t));
776
- let n = `${this.options.pluralSeparator}zero`, i = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
777
- if (u && (t.ordinal && e.indexOf(i) === 0 && o.push(c + e.replace(i, this.options.pluralSeparator)), o.push(c + e), d && o.push(c + n)), f) {
778
- let r = `${c}${this.options.contextSeparator || "_"}${t.context}`;
779
- o.push(r), u && (t.ordinal && e.indexOf(i) === 0 && o.push(r + e.replace(i, this.options.pluralSeparator)), o.push(r + e), d && o.push(r + n));
780
- }
781
- }
782
- let s;
783
- for (; s = o.pop();) this.isValidLookup(n) || (i = s, n = this.getResource(r, e, s, t));
784
- }));
785
- });
786
- }), {
787
- res: n,
788
- usedKey: r,
789
- exactUsedKey: i,
790
- usedLng: a,
791
- usedNS: o
792
- };
793
- }
794
- isValidLookup(e) {
795
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
796
- }
797
- getResource(e, t, n, r = {}) {
798
- return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
799
- }
800
- getUsedParamsDetails(e = {}) {
801
- let t = [
802
- "defaultValue",
803
- "ordinal",
804
- "context",
805
- "replace",
806
- "lng",
807
- "lngs",
808
- "fallbackLng",
809
- "ns",
810
- "keySeparator",
811
- "nsSeparator",
812
- "returnObjects",
813
- "returnDetails",
814
- "joinArrays",
815
- "postProcess",
816
- "interpolation"
817
- ], n = e.replace && !k(e.replace), r = n ? e.replace : e;
818
- if (n && e.count !== void 0 && (r.count = e.count), this.options.interpolation.defaultVariables && (r = {
819
- ...this.options.interpolation.defaultVariables,
820
- ...r
821
- }), !n) {
822
- r = { ...r };
823
- for (let e of t) delete r[e];
824
- }
825
- return r;
826
- }
827
- static hasDefaultValue(e) {
828
- for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.substring(0, 12) === "defaultValue" && e[t] !== void 0) return !0;
829
- return !1;
830
- }
831
- }, we = class {
832
- constructor(e) {
833
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = I.create("languageUtils");
834
- }
835
- getScriptPartFromCode(e) {
836
- if (e = F(e), !e || e.indexOf("-") < 0) return null;
837
- let t = e.split("-");
838
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
839
- }
840
- getLanguagePartFromCode(e) {
841
- if (e = F(e), !e || e.indexOf("-") < 0) return e;
842
- let t = e.split("-");
843
- return this.formatLanguageCode(t[0]);
844
- }
845
- formatLanguageCode(e) {
846
- if (k(e) && e.indexOf("-") > -1) {
847
- let t;
848
- try {
849
- t = Intl.getCanonicalLocales(e)[0];
850
- } catch {}
851
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
852
- }
853
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
854
- }
855
- isSupportedCode(e) {
856
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
857
- }
858
- getBestMatchFromCodes(e) {
859
- if (!e) return null;
860
- let t;
861
- return e.forEach((e) => {
862
- if (t) return;
863
- let n = this.formatLanguageCode(e);
864
- (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
865
- }), !t && this.options.supportedLngs && e.forEach((e) => {
866
- if (t) return;
867
- let n = this.getScriptPartFromCode(e);
868
- if (this.isSupportedCode(n)) return t = n;
869
- let r = this.getLanguagePartFromCode(e);
870
- if (this.isSupportedCode(r)) return t = r;
871
- t = this.options.supportedLngs.find((e) => {
872
- if (e === r || !(e.indexOf("-") < 0 && r.indexOf("-") < 0) && (e.indexOf("-") > 0 && r.indexOf("-") < 0 && e.substring(0, e.indexOf("-")) === r || e.indexOf(r) === 0 && r.length > 1)) return e;
873
- });
874
- }), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
875
- }
876
- getFallbackCodes(e, t) {
877
- if (!e) return [];
878
- if (typeof e == "function" && (e = e(t)), k(e) && (e = [e]), Array.isArray(e)) return e;
879
- if (!t) return e.default || [];
880
- let n = e[t];
881
- return n ||= e[this.getScriptPartFromCode(t)], n ||= e[this.formatLanguageCode(t)], n ||= e[this.getLanguagePartFromCode(t)], n ||= e.default, n || [];
882
- }
883
- toResolveHierarchy(e, t) {
884
- let n = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), r = [], i = (e) => {
885
- e && (this.isSupportedCode(e) ? r.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
886
- };
887
- return k(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && i(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && i(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && i(this.getLanguagePartFromCode(e))) : k(e) && i(this.formatLanguageCode(e)), n.forEach((e) => {
888
- r.indexOf(e) < 0 && i(this.formatLanguageCode(e));
889
- }), r;
890
- }
891
- }, Te = {
892
- zero: 0,
893
- one: 1,
894
- two: 2,
895
- few: 3,
896
- many: 4,
897
- other: 5
898
- }, Ee = {
899
- select: (e) => e === 1 ? "one" : "other",
900
- resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
901
- }, De = class {
902
- constructor(e, t = {}) {
903
- this.languageUtils = e, this.options = t, this.logger = I.create("pluralResolver"), this.pluralRulesCache = {};
904
- }
905
- clearCache() {
906
- this.pluralRulesCache = {};
907
- }
908
- getRule(e, t = {}) {
909
- let n = F(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
910
- cleanedCode: n,
911
- type: r
912
- });
913
- if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
914
- let a;
915
- try {
916
- a = new Intl.PluralRules(n, { type: r });
917
- } catch {
918
- if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), Ee;
919
- if (!e.match(/-|_/)) return Ee;
920
- let n = this.languageUtils.getLanguagePartFromCode(e);
921
- a = this.getRule(n, t);
922
- }
923
- return this.pluralRulesCache[i] = a, a;
924
- }
925
- needsPlural(e, t = {}) {
926
- let n = this.getRule(e, t);
927
- return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
928
- }
929
- getPluralFormsOfKey(e, t, n = {}) {
930
- return this.getSuffixes(e, n).map((e) => `${t}${e}`);
931
- }
932
- getSuffixes(e, t = {}) {
933
- let n = this.getRule(e, t);
934
- return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => Te[e] - Te[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
935
- }
936
- getSuffix(e, t, n = {}) {
937
- let r = this.getRule(e, n);
938
- return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
939
- }
940
- }, Oe = (e, t, n, r = ".", i = !0) => {
941
- let a = ue(e, t, n);
942
- return !a && i && k(n) && (a = P(e, n, r), a === void 0 && (a = P(t, n, r))), a;
943
- }, V = (e) => e.replace(/\$/g, "$$$$"), ke = class {
944
- constructor(e = {}) {
945
- this.logger = I.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
946
- }
947
- init(e = {}) {
948
- e.interpolation ||= { escapeValue: !0 };
949
- let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: h, maxReplaces: g, alwaysFormat: _ } = e.interpolation;
950
- this.escape = t === void 0 ? pe : t, this.escapeValue = n === void 0 ? !0 : n, this.useRawValueToEscape = r === void 0 ? !1 : r, this.prefix = i ? N(i) : a || "{{", this.suffix = o ? N(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? N(d) : f || N("$t("), this.nestingSuffix = p ? N(p) : m || N(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = g || 1e3, this.alwaysFormat = _ === void 0 ? !1 : _, this.resetRegExp();
951
- }
952
- reset() {
953
- this.options && this.init(this.options);
954
- }
955
- resetRegExp() {
956
- let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
957
- this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
958
- }
959
- interpolate(e, t, n, r) {
960
- let i, a, o, s = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (e) => {
961
- if (e.indexOf(this.formatSeparator) < 0) {
962
- let i = Oe(t, s, e, this.options.keySeparator, this.options.ignoreJSONStructure);
963
- return this.alwaysFormat ? this.format(i, void 0, n, {
964
- ...r,
965
- ...t,
966
- interpolationkey: e
967
- }) : i;
968
- }
969
- let i = e.split(this.formatSeparator), a = i.shift().trim(), o = i.join(this.formatSeparator).trim();
970
- return this.format(Oe(t, s, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
971
- ...r,
972
- ...t,
973
- interpolationkey: a
974
- });
975
- };
976
- this.resetRegExp();
977
- let l = r?.missingInterpolationHandler || this.options.missingInterpolationHandler, u = r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables;
978
- return [{
979
- regex: this.regexpUnescape,
980
- safeValue: (e) => V(e)
981
- }, {
982
- regex: this.regexp,
983
- safeValue: (e) => this.escapeValue ? V(this.escape(e)) : V(e)
984
- }].forEach((t) => {
985
- for (o = 0; i = t.regex.exec(e);) {
986
- let n = i[1].trim();
987
- if (a = c(n), a === void 0) if (typeof l == "function") {
988
- let t = l(e, i, r);
989
- a = k(t) ? t : "";
990
- } else if (r && Object.prototype.hasOwnProperty.call(r, n)) a = "";
991
- else if (u) {
992
- a = i[0];
993
- continue;
994
- } else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`), a = "";
995
- else !k(a) && !this.useRawValueToEscape && (a = re(a));
996
- let s = t.safeValue(a);
997
- if (e = e.replace(i[0], s), u ? (t.regex.lastIndex += a.length, t.regex.lastIndex -= i[0].length) : t.regex.lastIndex = 0, o++, o >= this.maxReplaces) break;
998
- }
999
- }), e;
1000
- }
1001
- nest(e, t, n = {}) {
1002
- let r, i, a, o = (e, t) => {
1003
- let n = this.nestingOptionsSeparator;
1004
- if (e.indexOf(n) < 0) return e;
1005
- let r = e.split(RegExp(`${N(n)}[ ]*{`)), i = `{${r[1]}`;
1006
- e = r[0], i = this.interpolate(i, a);
1007
- let o = i.match(/'/g), s = i.match(/"/g);
1008
- ((o?.length ?? 0) % 2 == 0 && !s || (s?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
1009
- try {
1010
- a = JSON.parse(i), t && (a = {
1011
- ...t,
1012
- ...a
1013
- });
1014
- } catch (t) {
1015
- return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
1016
- }
1017
- return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, e;
1018
- };
1019
- for (; r = this.nestingRegexp.exec(e);) {
1020
- let s = [];
1021
- a = { ...n }, a = a.replace && !k(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
1022
- let c = /{.*}/.test(r[1]) ? r[1].lastIndexOf("}") + 1 : r[1].indexOf(this.formatSeparator);
1023
- if (c !== -1 && (s = r[1].slice(c).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), r[1] = r[1].slice(0, c)), i = t(o.call(this, r[1].trim(), a), a), i && r[0] === e && !k(i)) return i;
1024
- k(i) || (i = re(i)), i ||= (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), ""), s.length && (i = s.reduce((e, t) => this.format(e, t, n.lng, {
1025
- ...n,
1026
- interpolationkey: r[1].trim()
1027
- }), i.trim())), e = e.replace(r[0], i), this.regexp.lastIndex = 0;
1028
- }
1029
- return e;
1030
- }
1031
- }, Ae = (e) => {
1032
- let t = e.toLowerCase().trim(), n = {};
1033
- if (e.indexOf("(") > -1) {
1034
- let r = e.split("(");
1035
- t = r[0].toLowerCase().trim();
1036
- let i = r[1].substring(0, r[1].length - 1);
1037
- t === "currency" && i.indexOf(":") < 0 ? n.currency ||= i.trim() : t === "relativetime" && i.indexOf(":") < 0 ? n.range ||= i.trim() : i.split(";").forEach((e) => {
1038
- if (e) {
1039
- let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
1040
- n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
1041
- }
1042
- });
1043
- }
1044
- return {
1045
- formatName: t,
1046
- formatOptions: n
1047
- };
1048
- }, je = (e) => {
1049
- let t = {};
1050
- return (n, r, i) => {
1051
- let a = i;
1052
- i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
1053
- ...a,
1054
- [i.interpolationkey]: void 0
1055
- });
1056
- let o = r + JSON.stringify(a), s = t[o];
1057
- return s || (s = e(F(r), i), t[o] = s), s(n);
1058
- };
1059
- }, Me = (e) => (t, n, r) => e(F(n), r)(t), Ne = class {
1060
- constructor(e = {}) {
1061
- this.logger = I.create("formatter"), this.options = e, this.init(e);
1062
- }
1063
- init(e, t = { interpolation: {} }) {
1064
- this.formatSeparator = t.interpolation.formatSeparator || ",";
1065
- let n = t.cacheInBuiltFormats ? je : Me;
1066
- this.formats = {
1067
- number: n((e, t) => {
1068
- let n = new Intl.NumberFormat(e, { ...t });
1069
- return (e) => n.format(e);
1070
- }),
1071
- currency: n((e, t) => {
1072
- let n = new Intl.NumberFormat(e, {
1073
- ...t,
1074
- style: "currency"
1075
- });
1076
- return (e) => n.format(e);
1077
- }),
1078
- datetime: n((e, t) => {
1079
- let n = new Intl.DateTimeFormat(e, { ...t });
1080
- return (e) => n.format(e);
1081
- }),
1082
- relativetime: n((e, t) => {
1083
- let n = new Intl.RelativeTimeFormat(e, { ...t });
1084
- return (e) => n.format(e, t.range || "day");
1085
- }),
1086
- list: n((e, t) => {
1087
- let n = new Intl.ListFormat(e, { ...t });
1088
- return (e) => n.format(e);
1089
- })
1090
- };
1091
- }
1092
- add(e, t) {
1093
- this.formats[e.toLowerCase().trim()] = t;
1094
- }
1095
- addCached(e, t) {
1096
- this.formats[e.toLowerCase().trim()] = je(t);
1097
- }
1098
- format(e, t, n, r = {}) {
1099
- let i = t.split(this.formatSeparator);
1100
- if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((e) => e.indexOf(")") > -1)) {
1101
- let e = i.findIndex((e) => e.indexOf(")") > -1);
1102
- i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
1103
- }
1104
- return i.reduce((e, t) => {
1105
- let { formatName: i, formatOptions: a } = Ae(t);
1106
- if (this.formats[i]) {
1107
- let t = e;
1108
- try {
1109
- let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
1110
- t = this.formats[i](e, s, {
1111
- ...a,
1112
- ...r,
1113
- ...o
1114
- });
1115
- } catch (e) {
1116
- this.logger.warn(e);
1117
- }
1118
- return t;
1119
- } else this.logger.warn(`there was no format function for ${i}`);
1120
- return e;
1121
- }, e);
1122
- }
1123
- }, Pe = (e, t) => {
1124
- e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
1125
- }, Fe = class extends L {
1126
- constructor(e, t, n, r = {}) {
1127
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = I.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
1128
- }
1129
- queueLoad(e, t, n, r) {
1130
- let i = {}, a = {}, o = {}, s = {};
1131
- return e.forEach((e) => {
1132
- let r = !0;
1133
- t.forEach((t) => {
1134
- let o = `${e}|${t}`;
1135
- !n.reload && this.store.hasResourceBundle(e, t) ? this.state[o] = 2 : this.state[o] < 0 || (this.state[o] === 1 ? a[o] === void 0 && (a[o] = !0) : (this.state[o] = 1, r = !1, a[o] === void 0 && (a[o] = !0), i[o] === void 0 && (i[o] = !0), s[t] === void 0 && (s[t] = !0)));
1136
- }), r || (o[e] = !0);
1137
- }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
1138
- pending: a,
1139
- pendingCount: Object.keys(a).length,
1140
- loaded: {},
1141
- errors: [],
1142
- callback: r
1143
- }), {
1144
- toLoad: Object.keys(i),
1145
- pending: Object.keys(a),
1146
- toLoadLanguages: Object.keys(o),
1147
- toLoadNamespaces: Object.keys(s)
1148
- };
1149
- }
1150
- loaded(e, t, n) {
1151
- let r = e.split("|"), i = r[0], a = r[1];
1152
- t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
1153
- let o = {};
1154
- this.queue.forEach((n) => {
1155
- le(n.loaded, [i], a), Pe(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
1156
- o[e] || (o[e] = {});
1157
- let t = n.loaded[e];
1158
- t.length && t.forEach((t) => {
1159
- o[e][t] === void 0 && (o[e][t] = !0);
1160
- });
1161
- }), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
1162
- }), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
1163
- }
1164
- read(e, t, n, r = 0, i = this.retryTimeout, a) {
1165
- if (!e.length) return a(null, {});
1166
- if (this.readingCalls >= this.maxParallelReads) {
1167
- this.waitingReads.push({
1168
- lng: e,
1169
- ns: t,
1170
- fcName: n,
1171
- tried: r,
1172
- wait: i,
1173
- callback: a
1174
- });
1175
- return;
1176
- }
1177
- this.readingCalls++;
1178
- let o = (o, s) => {
1179
- if (this.readingCalls--, this.waitingReads.length > 0) {
1180
- let e = this.waitingReads.shift();
1181
- this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
1182
- }
1183
- if (o && s && r < this.maxRetries) {
1184
- setTimeout(() => {
1185
- this.read.call(this, e, t, n, r + 1, i * 2, a);
1186
- }, i);
1187
- return;
1188
- }
1189
- a(o, s);
1190
- }, s = this.backend[n].bind(this.backend);
1191
- if (s.length === 2) {
1192
- try {
1193
- let n = s(e, t);
1194
- n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
1195
- } catch (e) {
1196
- o(e);
1197
- }
1198
- return;
1199
- }
1200
- return s(e, t, o);
1201
- }
1202
- prepareLoading(e, t, n = {}, r) {
1203
- if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), r && r();
1204
- k(e) && (e = this.languageUtils.toResolveHierarchy(e)), k(t) && (t = [t]);
1205
- let i = this.queueLoad(e, t, n, r);
1206
- if (!i.toLoad.length) return i.pending.length || r(), null;
1207
- i.toLoad.forEach((e) => {
1208
- this.loadOne(e);
1209
- });
1210
- }
1211
- load(e, t, n) {
1212
- this.prepareLoading(e, t, {}, n);
1213
- }
1214
- reload(e, t, n) {
1215
- this.prepareLoading(e, t, { reload: !0 }, n);
1216
- }
1217
- loadOne(e, t = "") {
1218
- let n = e.split("|"), r = n[0], i = n[1];
1219
- this.read(r, i, "read", void 0, void 0, (n, a) => {
1220
- n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
1221
- });
1222
- }
1223
- saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
1224
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
1225
- this.logger.warn(`did not save key "${n}" as the namespace "${t}" 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!!!");
1226
- return;
1227
- }
1228
- if (!(n == null || n === "")) {
1229
- if (this.backend?.create) {
1230
- let s = {
1231
- ...a,
1232
- isUpdate: i
1233
- }, c = this.backend.create.bind(this.backend);
1234
- if (c.length < 6) try {
1235
- let i;
1236
- i = c.length === 5 ? c(e, t, n, r, s) : c(e, t, n, r), i && typeof i.then == "function" ? i.then((e) => o(null, e)).catch(o) : o(null, i);
1237
- } catch (e) {
1238
- o(e);
1239
- }
1240
- else c(e, t, n, r, o, s);
1241
- }
1242
- !e || !e[0] || this.store.addResource(e[0], t, n, r);
1243
- }
1244
- }
1245
- }, H = () => ({
1246
- debug: !1,
1247
- initAsync: !0,
1248
- ns: ["translation"],
1249
- defaultNS: ["translation"],
1250
- fallbackLng: ["dev"],
1251
- fallbackNS: !1,
1252
- supportedLngs: !1,
1253
- nonExplicitSupportedLngs: !1,
1254
- load: "all",
1255
- preload: !1,
1256
- simplifyPluralSuffix: !0,
1257
- keySeparator: ".",
1258
- nsSeparator: ":",
1259
- pluralSeparator: "_",
1260
- contextSeparator: "_",
1261
- partialBundledLanguages: !1,
1262
- saveMissing: !1,
1263
- updateMissing: !1,
1264
- saveMissingTo: "fallback",
1265
- saveMissingPlurals: !0,
1266
- missingKeyHandler: !1,
1267
- missingInterpolationHandler: !1,
1268
- postProcess: !1,
1269
- postProcessPassResolved: !1,
1270
- returnNull: !1,
1271
- returnEmptyString: !0,
1272
- returnObjects: !1,
1273
- joinArrays: !1,
1274
- returnedObjectHandler: !1,
1275
- parseMissingKeyHandler: !1,
1276
- appendNamespaceToMissingKey: !1,
1277
- appendNamespaceToCIMode: !1,
1278
- overloadTranslationOptionHandler: (e) => {
1279
- let t = {};
1280
- if (typeof e[1] == "object" && (t = e[1]), k(e[1]) && (t.defaultValue = e[1]), k(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
1281
- let n = e[3] || e[2];
1282
- Object.keys(n).forEach((e) => {
1283
- t[e] = n[e];
1284
- });
1285
- }
1286
- return t;
1287
- },
1288
- interpolation: {
1289
- escapeValue: !0,
1290
- format: (e) => e,
1291
- prefix: "{{",
1292
- suffix: "}}",
1293
- formatSeparator: ",",
1294
- unescapePrefix: "-",
1295
- nestingPrefix: "$t(",
1296
- nestingSuffix: ")",
1297
- nestingOptionsSeparator: ",",
1298
- maxReplaces: 1e3,
1299
- skipOnVariables: !0
1300
- },
1301
- cacheInBuiltFormats: !0
1302
- }), Ie = (e) => (k(e.ns) && (e.ns = [e.ns]), k(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), k(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs?.indexOf?.("cimode") < 0 && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), typeof e.initImmediate == "boolean" && (e.initAsync = e.initImmediate), e), U = () => {}, Le = (e) => {
1303
- Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
1304
- typeof e[t] == "function" && (e[t] = e[t].bind(e));
1305
- });
1306
- }, Re = "__i18next_supportNoticeShown", ze = () => !!(typeof globalThis < "u" && globalThis[Re] || typeof process < "u" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE || typeof process < "u" && process.env), Be = () => {
1307
- typeof globalThis < "u" && (globalThis[Re] = !0);
1308
- }, Ve = (e) => !!(e?.modules?.backend?.name?.indexOf("Locize") > 0 || e?.modules?.backend?.constructor?.name?.indexOf("Locize") > 0 || e?.options?.backend?.backends && e.options.backend.backends.some((e) => e?.name?.indexOf("Locize") > 0 || e?.constructor?.name?.indexOf("Locize") > 0) || e?.options?.backend?.projectId || e?.options?.backend?.backendOptions && e.options.backend.backendOptions.some((e) => e?.projectId)), W = class e extends L {
1309
- constructor(e = {}, t) {
1310
- if (super(), this.options = Ie(e), this.services = {}, this.logger = I, this.modules = { external: [] }, Le(this), t && !this.isInitialized && !e.isClone) {
1311
- if (!this.options.initAsync) return this.init(e, t), this;
1312
- setTimeout(() => {
1313
- this.init(e, t);
1314
- }, 0);
1315
- }
1316
- }
1317
- init(e = {}, t) {
1318
- this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (k(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
1319
- let n = H();
1320
- this.options = {
1321
- ...n,
1322
- ...this.options,
1323
- ...Ie(e)
1324
- }, this.options.interpolation = {
1325
- ...n.interpolation,
1326
- ...this.options.interpolation
1327
- }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = n.overloadTranslationOptionHandler), this.options.showSupportNotice !== !1 && !Ve(this) && !ze() && (typeof console < "u" && console.info !== void 0 && console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"), Be());
1328
- let r = (e) => e ? typeof e == "function" ? new e() : e : null;
1329
- if (!this.options.isClone) {
1330
- this.modules.logger ? I.init(r(this.modules.logger), this.options) : I.init(null, this.options);
1331
- let e;
1332
- e = this.modules.formatter ? this.modules.formatter : Ne;
1333
- let t = new we(this.options);
1334
- this.store = new ye(this.options.resources, this.options);
1335
- let i = this.services;
1336
- i.logger = I, i.resourceStore = this.store, i.languageUtils = t, i.pluralResolver = new De(t, {
1337
- prepend: this.options.pluralSeparator,
1338
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1339
- }), this.options.interpolation.format && this.options.interpolation.format !== n.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"), e && (!this.options.interpolation.format || this.options.interpolation.format === n.interpolation.format) && (i.formatter = r(e), i.formatter.init && i.formatter.init(i, this.options), this.options.interpolation.format = i.formatter.format.bind(i.formatter)), i.interpolator = new ke(this.options), i.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, i.backendConnector = new Fe(r(this.modules.backend), i.resourceStore, i, this.options), i.backendConnector.on("*", (e, ...t) => {
1340
- this.emit(e, ...t);
1341
- }), this.modules.languageDetector && (i.languageDetector = r(this.modules.languageDetector), i.languageDetector.init && i.languageDetector.init(i, this.options.detection, this.options)), this.modules.i18nFormat && (i.i18nFormat = r(this.modules.i18nFormat), i.i18nFormat.init && i.i18nFormat.init(this)), this.translator = new B(this.services, this.options), this.translator.on("*", (e, ...t) => {
1342
- this.emit(e, ...t);
1343
- }), this.modules.external.forEach((e) => {
1344
- e.init && e.init(this);
1345
- });
1346
- }
1347
- if (this.format = this.options.interpolation.format, t ||= U, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1348
- let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1349
- e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
1350
- }
1351
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), [
1352
- "getResource",
1353
- "hasResourceBundle",
1354
- "getResourceBundle",
1355
- "getDataByLanguage"
1356
- ].forEach((e) => {
1357
- this[e] = (...t) => this.store[e](...t);
1358
- }), [
1359
- "addResource",
1360
- "addResources",
1361
- "addResourceBundle",
1362
- "removeResourceBundle"
1363
- ].forEach((e) => {
1364
- this[e] = (...t) => (this.store[e](...t), this);
1365
- });
1366
- let i = A(), a = () => {
1367
- let e = (e, n) => {
1368
- this.isInitializing = !1, this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), i.resolve(n), t(e, n);
1369
- };
1370
- if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
1371
- this.changeLanguage(this.options.lng, e);
1372
- };
1373
- return this.options.resources || !this.options.initAsync ? a() : setTimeout(a, 0), i;
1374
- }
1375
- loadResources(e, t = U) {
1376
- let n = t, r = k(e) ? e : this.language;
1377
- if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1378
- if (r?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1379
- let e = [], t = (t) => {
1380
- t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
1381
- t !== "cimode" && e.indexOf(t) < 0 && e.push(t);
1382
- });
1383
- };
1384
- r ? t(r) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
1385
- !e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(e);
1386
- });
1387
- } else n(null);
1388
- }
1389
- reloadResources(e, t, n) {
1390
- let r = A();
1391
- return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= U, this.services.backendConnector.reload(e, t, (e) => {
1392
- r.resolve(), n(e);
1393
- }), r;
1394
- }
1395
- use(e) {
1396
- if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1397
- if (!e.type) throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1398
- return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && be.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1399
- }
1400
- setResolvedLanguage(e) {
1401
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
1402
- for (let e = 0; e < this.languages.length; e++) {
1403
- let t = this.languages[e];
1404
- if (!(["cimode", "dev"].indexOf(t) > -1) && this.store.hasLanguageSomeTranslations(t)) {
1405
- this.resolvedLanguage = t;
1406
- break;
1407
- }
1408
- }
1409
- !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1410
- }
1411
- }
1412
- changeLanguage(e, t) {
1413
- this.isLanguageChangingTo = e;
1414
- let n = A();
1415
- this.emit("languageChanging", e);
1416
- let r = (e) => {
1417
- this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
1418
- }, i = (i, a) => {
1419
- a ? this.isLanguageChangingTo === e && (r(a), this.translator.changeLanguage(a), this.isLanguageChangingTo = void 0, this.emit("languageChanged", a), this.logger.log("languageChanged", a)) : this.isLanguageChangingTo = void 0, n.resolve((...e) => this.t(...e)), t && t(i, (...e) => this.t(...e));
1420
- }, a = (t) => {
1421
- !e && !t && this.services.languageDetector && (t = []);
1422
- let n = k(t) ? t : t && t[0], a = this.store.hasLanguageSomeTranslations(n) ? n : this.services.languageUtils.getBestMatchFromCodes(k(t) ? [t] : t);
1423
- a && (this.language || r(a), this.translator.language || this.translator.changeLanguage(a), this.services.languageDetector?.cacheUserLanguage?.(a)), this.loadResources(a, (e) => {
1424
- i(e, a);
1425
- });
1426
- };
1427
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? a(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(a) : this.services.languageDetector.detect(a) : a(e), n;
1428
- }
1429
- getFixedT(e, t, n) {
1430
- let r = (e, t, ...i) => {
1431
- let a;
1432
- a = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(i)), a.lng = a.lng || r.lng, a.lngs = a.lngs || r.lngs, a.ns = a.ns || r.ns, a.keyPrefix !== "" && (a.keyPrefix = a.keyPrefix || n || r.keyPrefix);
1433
- let o = {
1434
- ...this.options,
1435
- ...a
1436
- };
1437
- typeof a.keyPrefix == "function" && (a.keyPrefix = R(a.keyPrefix, o));
1438
- let s = this.options.keySeparator || ".", c;
1439
- return a.keyPrefix && Array.isArray(e) ? c = e.map((e) => (typeof e == "function" && (e = R(e, o)), `${a.keyPrefix}${s}${e}`)) : (typeof e == "function" && (e = R(e, o)), c = a.keyPrefix ? `${a.keyPrefix}${s}${e}` : e), this.t(c, a);
1440
- };
1441
- return k(e) ? r.lng = e : r.lngs = e, r.ns = t, r.keyPrefix = n, r;
1442
- }
1443
- t(...e) {
1444
- return this.translator?.translate(...e);
1445
- }
1446
- exists(...e) {
1447
- return this.translator?.exists(...e);
1448
- }
1449
- setDefaultNamespace(e) {
1450
- this.options.defaultNS = e;
1451
- }
1452
- hasLoadedNamespace(e, t = {}) {
1453
- if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1454
- if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1455
- let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
1456
- if (n.toLowerCase() === "cimode") return !0;
1457
- let a = (e, t) => {
1458
- let n = this.services.backendConnector.state[`${e}|${t}`];
1459
- return n === -1 || n === 0 || n === 2;
1460
- };
1461
- if (t.precheck) {
1462
- let e = t.precheck(this, a);
1463
- if (e !== void 0) return e;
1464
- }
1465
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!r || a(i, e)));
1466
- }
1467
- loadNamespaces(e, t) {
1468
- let n = A();
1469
- return this.options.ns ? (k(e) && (e = [e]), e.forEach((e) => {
1470
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
1471
- }), this.loadResources((e) => {
1472
- n.resolve(), t && t(e);
1473
- }), n) : (t && t(), Promise.resolve());
1474
- }
1475
- loadLanguages(e, t) {
1476
- let n = A();
1477
- k(e) && (e = [e]);
1478
- let r = this.options.preload || [], i = e.filter((e) => r.indexOf(e) < 0 && this.services.languageUtils.isSupportedCode(e));
1479
- return i.length ? (this.options.preload = r.concat(i), this.loadResources((e) => {
1480
- n.resolve(), t && t(e);
1481
- }), n) : (t && t(), Promise.resolve());
1482
- }
1483
- dir(e) {
1484
- if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
1485
- try {
1486
- let t = new Intl.Locale(e);
1487
- if (t && t.getTextInfo) {
1488
- let e = t.getTextInfo();
1489
- if (e && e.direction) return e.direction;
1490
- }
1491
- } catch {}
1492
- let t = /* @__PURE__ */ "ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb".split("."), n = this.services?.languageUtils || new we(H());
1493
- return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1494
- }
1495
- static createInstance(t = {}, n) {
1496
- let r = new e(t, n);
1497
- return r.createInstance = e.createInstance, r;
1498
- }
1499
- cloneInstance(t = {}, n = U) {
1500
- let r = t.forkResourceStore;
1501
- r && delete t.forkResourceStore;
1502
- let i = {
1503
- ...this.options,
1504
- ...t,
1505
- isClone: !0
1506
- }, a = new e(i);
1507
- if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
1508
- "store",
1509
- "services",
1510
- "language"
1511
- ].forEach((e) => {
1512
- a[e] = this[e];
1513
- }), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new ye(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, e[t] = Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), e[t]), e), {}), i), a.services.resourceStore = a.store), t.interpolation) {
1514
- let e = {
1515
- ...H().interpolation,
1516
- ...this.options.interpolation,
1517
- ...t.interpolation
1518
- }, n = {
1519
- ...i,
1520
- interpolation: e
1521
- };
1522
- a.services.interpolator = new ke(n);
1523
- }
1524
- return a.translator = new B(a.services, i), a.translator.on("*", (e, ...t) => {
1525
- a.emit(e, ...t);
1526
- }), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
1527
- }
1528
- toJSON() {
1529
- return {
1530
- options: this.options,
1531
- store: this.store,
1532
- language: this.language,
1533
- languages: this.languages,
1534
- resolvedLanguage: this.resolvedLanguage
1535
- };
1536
- }
1537
- }.createInstance();
1538
- //#endregion
1539
- //#region ../../lib-react/translator/dist/index.js
1540
- W.createInstance, W.dir, W.init, W.loadResources, W.reloadResources, W.use, W.changeLanguage, W.getFixedT, W.t, W.exists, W.setDefaultNamespace, W.hasLoadedNamespace, W.loadNamespaces, W.loadLanguages, W.init({
1541
- fallbackLng: "en",
1542
- lng: "en",
1543
- debug: !0,
1544
- resources: {
1545
- en: te,
1546
- es: ne
1547
- }
1548
- });
1549
- var He = {
1550
- translator: {
1551
- ...W,
1552
- t: (e, t) => {
1553
- let { lng: n } = t;
1554
- switch (n) {
1555
- case "en_US":
1556
- case "en-US":
1557
- t.lng = "en";
1558
- break;
1559
- case "es_ES":
1560
- case "es-ES":
1561
- case "es_MX":
1562
- case "es-MX":
1563
- t.lng = "es";
1564
- break;
1565
- default: break;
1566
- }
1567
- return W.t(e, {
1568
- lng: n,
1569
- ...t
1570
- });
1571
- }
1572
- },
1573
- languageOptions: [{
1574
- value: "en_US",
1575
- label: "English (US)"
1576
- }, {
1577
- value: "es_ES",
1578
- label: "Spanish"
1579
- }]
1580
- };
1581
- //#endregion
1582
- //#region ../../lib-react/correct-answer-toggle/dist/index.js
1583
- function G(e) {
1584
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
1585
- }
1586
- function Ue(e, t) {
1587
- return !e || G(e) ? e : G(e.default) ? e.default : t && G(e[t]) ? e[t] : t && G(e[t]?.default) ? e[t].default : e;
1588
- }
1589
- var We = Ue(o, "Readable") || Ue(Ke.Readable, "Readable"), Ge = r, K = Ge.default, Ke = K && typeof K == "object" ? K : Ge, { translator: q } = He, qe = {
1590
- WebkitTouchCallout: "none",
1591
- WebkitUserSelect: "none",
1592
- KhtmlUserSelect: "none",
1593
- MozUserSelect: "none",
1594
- msUserSelect: "none",
1595
- userSelect: "none"
1596
- }, Je = c("div")(() => ({
1597
- width: "100%",
1598
- cursor: "pointer"
1599
- })), Ye = c("div")(() => ({
1600
- margin: "0 auto",
1601
- textAlign: "center",
1602
- display: "flex"
1603
- })), Xe = c("div")(() => ({
1604
- width: "fit-content",
1605
- minWidth: "140px",
1606
- alignSelf: "center",
1607
- verticalAlign: "middle",
1608
- color: `var(--correct-answer-toggle-label-color, ${s.text()})`,
1609
- fontWeight: "normal",
1610
- ...qe
1611
- })), Ze = c("div")(() => ({
1612
- position: "absolute",
1613
- width: "25px",
1614
- "&.enter": { opacity: "0" },
1615
- "&.enter-active": {
1616
- opacity: "1",
1617
- transition: "opacity 0.3s ease-in"
1618
- },
1619
- "&.exit": { opacity: "1" },
1620
- "&.exit-active": {
1621
- opacity: "0",
1622
- transition: "opacity 0.3s ease-in"
1623
- }
1624
- })), Qe = c("div")(() => ({
1625
- width: "25px",
1626
- marginRight: "5px",
1627
- display: "flex",
1628
- alignItems: "center"
1629
- })), $e = class e extends _.Component {
1630
- static propTypes = {
1631
- onToggle: S.default.func,
1632
- toggled: S.default.bool,
1633
- show: S.default.bool,
1634
- hideMessage: S.default.string,
1635
- showMessage: S.default.string,
1636
- className: S.default.string,
1637
- language: S.default.string
1638
- };
1639
- static defaultProps = {
1640
- showMessage: "Show correct answer",
1641
- hideMessage: "Hide correct answer",
1642
- show: !1,
1643
- toggled: !1
1644
- };
1645
- constructor(t) {
1646
- super(t), this.state = { show: t.show }, this.openIconRef = _.createRef(), this.closedIconRef = _.createRef(), e.defaultProps = {
1647
- ...e.defaultProps,
1648
- showMessage: q.t("common:showCorrectAnswer", { lng: t.language }),
1649
- hideMessage: q.t("common:hideCorrectAnswer", { lng: t.language })
1650
- };
1651
- }
1652
- onClick() {
1653
- this.props.onToggle(!this.props.toggled);
1654
- }
1655
- onTouch(e) {
1656
- e.preventDefault(), this.props.onToggle(!this.props.toggled);
1657
- }
1658
- UNSAFE_componentWillReceiveProps(t) {
1659
- this.setState({ show: t.show }), t.language !== this.props?.language && (e.defaultProps = {
1660
- ...e.defaultProps,
1661
- showMessage: q.t("common:showCorrectAnswer", { lng: t.language }),
1662
- hideMessage: q.t("common:hideCorrectAnswer", { lng: t.language })
1663
- });
1664
- }
1665
- render() {
1666
- let { className: e, toggled: t, hideMessage: n, showMessage: r } = this.props;
1667
- return /* @__PURE__ */ b(Je, {
1668
- className: e,
1669
- children: /* @__PURE__ */ b(T, {
1670
- show: this.state.show,
1671
- children: /* @__PURE__ */ x(Ye, {
1672
- onClick: this.onClick.bind(this),
1673
- onTouchEnd: this.onTouch.bind(this),
1674
- children: [/* @__PURE__ */ x(Qe, { children: [/* @__PURE__ */ b(f, {
1675
- nodeRef: this.openIconRef,
1676
- timeout: 400,
1677
- in: t,
1678
- exit: !t,
1679
- classNames: {
1680
- enter: "enter",
1681
- enterActive: "enter-active",
1682
- exit: "exit",
1683
- exitActive: "exit-active"
1684
- },
1685
- children: /* @__PURE__ */ b(Ze, {
1686
- ref: this.openIconRef,
1687
- children: /* @__PURE__ */ b(O, { open: t }, "correct-open")
1688
- })
1689
- }), /* @__PURE__ */ b(f, {
1690
- nodeRef: this.closedIconRef,
1691
- timeout: 5e3,
1692
- in: !t,
1693
- exit: t,
1694
- classNames: {
1695
- enter: "enter",
1696
- enterActive: "enter-active",
1697
- exit: "exit",
1698
- exitActive: "exit-active"
1699
- },
1700
- children: /* @__PURE__ */ b(Ze, {
1701
- ref: this.closedIconRef,
1702
- children: /* @__PURE__ */ b(O, { open: t }, "correct-closed")
1703
- })
1704
- })] }), /* @__PURE__ */ b(We, {
1705
- false: !0,
1706
- children: /* @__PURE__ */ b(Xe, {
1707
- "aria-hidden": !this.state.show,
1708
- children: t ? n : r
1709
- })
1710
- })]
1711
- })
1712
- })
1713
- });
1714
- }
1715
- }, et = c("div")(({ theme: e }) => ({
1716
- marginLeft: "auto",
1717
- marginRight: "auto",
1718
- marginTop: e.spacing(1),
1719
- marginBottom: e.spacing(1)
1720
- })), tt = c("td")({ padding: "5px 0" }), nt = c(m)(({ theme: e }) => ({ margin: e.spacing(2) })), rt = c("th")({ padding: 0 }), J = c("div")(({ theme: e, isQuestionText: t }) => ({
1721
- padding: e.spacing(1.5),
1722
- textAlign: t ? "left" : "center"
1723
- })), it = c("tr")({
1724
- border: 0,
1725
- borderTop: `2.5px solid ${s.primaryLight()}`,
1726
- width: "100%"
1727
- }), at = c("table")({
1728
- color: s.text(),
1729
- backgroundColor: s.background(),
1730
- borderCollapse: "collapse",
1731
- borderSpacing: 0,
1732
- marginBottom: 0
1733
- }), ot = class extends _.Component {
1734
- static propTypes = {
1735
- correctAnswers: S.default.object,
1736
- view: S.default.bool.isRequired,
1737
- showCorrect: S.default.bool.isRequired,
1738
- disabled: S.default.bool.isRequired,
1739
- onAnswerChange: S.default.func.isRequired,
1740
- choiceMode: S.default.string.isRequired,
1741
- rows: S.default.array.isRequired,
1742
- headers: S.default.array.isRequired,
1743
- answers: S.default.object.isRequired
1744
- };
1745
- onRowValueChange = (e, t) => (n) => {
1746
- let { onAnswerChange: r, choiceMode: i, answers: a } = this.props, o = { ...a };
1747
- if (i === "radio") for (let t = 0; t < o[e].length; t++) o[e][t] = !1;
1748
- o[e][t] = n.target.checked, r(o);
1749
- };
1750
- answerIsCorrect = (e, t, n) => {
1751
- let { correctAnswers: r } = this.props;
1752
- return r[e][n] === t && t === !0;
1753
- };
1754
- answerIsIncorrect = (e, t, n) => {
1755
- let { correctAnswers: r } = this.props;
1756
- return r[e][n] === !0 && t === !1 || r[e][n] === !1 && t === !0;
1757
- };
1758
- render() {
1759
- let { showCorrect: e, headers: t, rows: n, choiceMode: r, answers: i, disabled: a, view: o } = this.props, c = r === "radio" ? p : u, l = a && !o;
1760
- return !n || n.length === 0 ? /* @__PURE__ */ b(et, { children: /* @__PURE__ */ b(nt, {
1761
- component: "div",
1762
- children: "There are currently no questions to show."
1763
- }) }) : /* @__PURE__ */ b(et, { children: /* @__PURE__ */ x(at, { children: [
1764
- /* @__PURE__ */ b("colgroup", { children: (t || []).map((e, t) => /* @__PURE__ */ b("col", {}, `col-${t}`)) }),
1765
- /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: (t || []).map((e, t) => /* @__PURE__ */ b(rt, {
1766
- "data-colno": `${t}`,
1767
- scope: "row",
1768
- children: /* @__PURE__ */ b(J, {
1769
- isQuestionText: t === 0,
1770
- dangerouslySetInnerHTML: { __html: e }
1771
- })
1772
- }, `th-${t}`)) }) }),
1773
- (n || []).map((t, n) => /* @__PURE__ */ b("tbody", {
1774
- role: "group",
1775
- children: /* @__PURE__ */ x(it, { children: [/* @__PURE__ */ b("td", {
1776
- "data-colno": "0",
1777
- children: /* @__PURE__ */ b(J, {
1778
- isQuestionText: !0,
1779
- dangerouslySetInnerHTML: { __html: t.title }
1780
- })
1781
- }, `td-title-${n}`), (i[t.id] || []).map((r, i) => /* @__PURE__ */ b(tt, {
1782
- "data-colno": `${i + 1}`,
1783
- children: /* @__PURE__ */ b(J, { children: /* @__PURE__ */ b(c, {
1784
- sx: {
1785
- padding: "6px",
1786
- color: e && r === !0 || l && this.answerIsCorrect(t.id, r, i) ? s.correct() : l && this.answerIsIncorrect(t.id, r, i) ? s.incorrect() : r === !0 && !l ? s.primary() : a ? s.disabled() : s.text(),
1787
- cursor: a ? "not-allowed" : "pointer",
1788
- pointerEvents: a ? "initial" : "auto",
1789
- opacity: a ? .7 : 1,
1790
- "& input": { width: "100% !important" },
1791
- "&:hover": { color: a ? s.disabled() : s.primaryLight() },
1792
- "&.Mui-disabled": { color: `${e && r === !0 || l && this.answerIsCorrect(t.id, r, i) ? s.correct() : l && this.answerIsIncorrect(t.id, r, i) ? s.incorrect() : r === !0 && !l ? s.primary() : s.disabled()}` }
1793
- },
1794
- disabled: a,
1795
- onChange: this.onRowValueChange(t.id, i),
1796
- checked: r === !0
1797
- }) })
1798
- }, `td-${n}-${i}`))] })
1799
- }, `row-${n}`))
1800
- ] }) });
1801
- }
1802
- };
1803
- //#endregion
1804
- //#region src/delivery/main.tsx
1805
- function Y(e) {
1806
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
1807
- }
1808
- function X(e, t) {
1809
- return !e || Y(e) ? e : Y(e.default) ? e.default : t && Y(e[t]) ? e[t] : t && Y(e[t]?.default) ? e[t].default : e;
1810
- }
1811
- var st = X(g, "UiLayout") || X($.UiLayout, "UiLayout"), Z = X(d, "PreviewPrompt") || X($.PreviewPrompt, "PreviewPrompt"), ct = X(a, "Feedback") || X($.Feedback, "Feedback"), lt = X(n, "Collapsible") || X($.Collapsible, "Collapsible"), ut = r, Q = ut.default, $ = Q && typeof Q == "object" ? Q : ut, dt = c("div")({ verticalAlign: "middle" }), ft = c(lt)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), pt = class extends _.Component {
1812
- static propTypes = {
1813
- session: S.default.object.isRequired,
1814
- onSessionChange: S.default.func,
1815
- model: S.default.object.isRequired
1816
- };
1817
- constructor(e) {
1818
- super(e), this.state = {
1819
- session: {
1820
- ...e.session,
1821
- answers: e.session && e.session.answers || this.generateAnswers(e.model)
1822
- },
1823
- showCorrect: !1
1824
- }, this.callOnSessionChange();
1825
- }
1826
- generateAnswers = (e) => {
1827
- let t = {};
1828
- return e.rows?.forEach((n) => {
1829
- t[n.id] = Array(e.layout - 1).fill(!1);
1830
- }), t;
1831
- };
1832
- isAnswerRegenerationRequired = (e) => {
1833
- let { model: { choiceMode: t, layout: n, rows: r } = {} } = this.props, { session: { answers: i } = {} } = e, a = !1;
1834
- return t !== e.model.choiceMode && (a = !0), n !== e.model.layout && (a = !0), (r.length !== e.model.rows.length || i && e.model.rows.length !== Object.keys(i).length) && (a = !0), a || !i;
1835
- };
1836
- UNSAFE_componentWillReceiveProps(e) {
1837
- let t = this.isAnswerRegenerationRequired(e);
1838
- this.setState((n) => ({
1839
- session: {
1840
- ...e.session,
1841
- answers: t ? this.generateAnswers(e.model) : e.session.answers
1842
- },
1843
- showCorrect: this.props.model.disabled && !e.model.disabled && n.showCorrect ? !1 : n.showCorrect
1844
- }), () => {
1845
- t && this.callOnSessionChange();
1846
- });
1847
- }
1848
- callOnSessionChange = () => {
1849
- let { onSessionChange: e } = this.props;
1850
- e && e(this.state.session);
1851
- };
1852
- toggleShowCorrect = (e) => {
1853
- this.setState({ showCorrect: e });
1854
- };
1855
- onAnswerChange = (e) => {
1856
- this.setState((t) => ({ session: {
1857
- ...t.session,
1858
- answers: e
1859
- } }), this.callOnSessionChange);
1860
- };
1861
- render() {
1862
- let { model: e } = this.props, { showCorrect: t, session: n } = this.state, { correctness: r = {}, extraCSSRules: a, language: o } = e, s = r.correctness && r.correctness !== "correct", c = e.rationale && (i(e.rationale) || h(e.rationale));
1863
- return /* @__PURE__ */ x(st, {
1864
- extraCSSRules: a,
1865
- children: [
1866
- e.teacherInstructions && (i(e.teacherInstructions) || h(e.teacherInstructions)) && /* @__PURE__ */ b(ft, {
1867
- labels: {
1868
- hidden: "Show Teacher Instructions",
1869
- visible: "Hide Teacher Instructions"
1870
- },
1871
- children: /* @__PURE__ */ b(Z, { prompt: e.teacherInstructions })
1872
- }),
1873
- e.prompt && /* @__PURE__ */ b(dt, { children: /* @__PURE__ */ b(Z, { prompt: e.prompt }) }),
1874
- /* @__PURE__ */ b($e, {
1875
- language: o,
1876
- show: s,
1877
- toggled: t,
1878
- onToggle: this.toggleShowCorrect
1879
- }),
1880
- /* @__PURE__ */ b(ot, {
1881
- showCorrect: t,
1882
- correctAnswers: e.correctResponse,
1883
- disabled: e.disabled,
1884
- view: e.view,
1885
- onAnswerChange: this.onAnswerChange,
1886
- choiceMode: e.choiceMode,
1887
- answers: t ? e.correctResponse || {} : n.answers,
1888
- headers: e.headers,
1889
- rows: e.rows
1890
- }),
1891
- c && /* @__PURE__ */ b(lt, {
1892
- labels: {
1893
- hidden: "Show Rationale",
1894
- visible: "Hide Rationale"
1895
- },
1896
- children: /* @__PURE__ */ b(Z, { prompt: e.rationale })
1897
- }),
1898
- e.feedback && /* @__PURE__ */ b(ct, {
1899
- correctness: r.correctness,
1900
- feedback: e.feedback
1901
- })
1902
- ]
1903
- });
1904
- }
1905
- };
1906
- (class e extends CustomEvent {
1907
- static {
1908
- this.TYPE = "model-set";
1909
- }
1910
- constructor(t, n, r) {
1911
- super(e.TYPE, {
1912
- bubbles: !0,
1913
- composed: !0,
1914
- detail: {
1915
- complete: n,
1916
- component: t,
1917
- hasModel: r
1918
- }
1919
- }), this.component = t, this.complete = n;
1920
- }
1921
- });
1922
- //#endregion
1923
- //#region ../../shared/player-events/dist/index.js
1924
- var mt = class e extends CustomEvent {
1925
- static {
1926
- this.TYPE = "session-changed";
1927
- }
1928
- constructor(t, n) {
1929
- super(e.TYPE, {
1930
- bubbles: !0,
1931
- composed: !0,
1932
- detail: {
1933
- complete: n,
1934
- component: t
1935
- }
1936
- }), this.component = t, this.complete = n;
1937
- }
1938
- }, ht = (e, t) => (t?.rows?.map((e) => e.id) || []).reduce((t, n) => {
1939
- if (!t) return !1;
1940
- let r = e.answers && e.answers[n];
1941
- return Array.isArray(r) && r.includes(!0) && t;
1942
- }, !0), gt = class extends HTMLElement {
1943
- constructor() {
1944
- super(), this._root = null;
1945
- }
1946
- set model(e) {
1947
- this._model = {
1948
- ...e,
1949
- ...e?.config || {}
1950
- }, this._render();
1951
- }
1952
- set session(e) {
1953
- this._session = e, this._render();
1954
- }
1955
- get session() {
1956
- return this._session;
1957
- }
1958
- sessionChanged(e) {
1959
- this._session.answers = e.answers;
1960
- let t = ht(this._session, this._model);
1961
- this.dispatchEvent(new mt(this.tagName.toLowerCase(), t)), this._render();
1962
- }
1963
- connectedCallback() {
1964
- this._render();
1965
- }
1966
- _render() {
1967
- if (!this._model || !this._session) return;
1968
- let e = _.createElement(pt, {
1969
- model: this._model,
1970
- session: this._session,
1971
- onSessionChange: this.sessionChanged.bind(this)
1972
- });
1973
- this._root ||= y(this), this._root.render(e), queueMicrotask(() => {
1974
- l(this);
1975
- });
1976
- }
1977
- disconnectedCallback() {
1978
- this._root && this._root.unmount();
1979
- }
1980
- };
1981
- //#endregion
1982
- export { pt as Component, gt as default, ht as isComplete };
1983
-
1984
- //# sourceMappingURL=index.js.map