@pie-element/multiple-choice 13.2.2-next.2 → 13.2.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 (114) hide show
  1. package/CHANGELOG.json +1972 -0
  2. package/CHANGELOG.md +2727 -0
  3. package/LICENSE.md +5 -0
  4. package/PRINT.md +35 -0
  5. package/README.md +56 -0
  6. package/choice.png +0 -0
  7. package/configure/CHANGELOG.json +1387 -0
  8. package/configure/CHANGELOG.md +2074 -0
  9. package/configure/lib/defaults.js +203 -0
  10. package/configure/lib/defaults.js.map +1 -0
  11. package/configure/lib/index.js +202 -0
  12. package/configure/lib/index.js.map +1 -0
  13. package/configure/lib/main.js +484 -0
  14. package/configure/lib/main.js.map +1 -0
  15. package/configure/lib/utils.js +18 -0
  16. package/configure/lib/utils.js.map +1 -0
  17. package/configure/package.json +22 -0
  18. package/controller/CHANGELOG.json +527 -0
  19. package/controller/CHANGELOG.md +1405 -0
  20. package/controller/lib/defaults.js +33 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +288 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +15 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +15 -0
  27. package/docs/config-schema.json +2993 -0
  28. package/docs/config-schema.json.md +2217 -0
  29. package/docs/demo/config.js +8 -0
  30. package/docs/demo/generate.js +61 -0
  31. package/docs/demo/index.html +1 -0
  32. package/docs/demo/session.js +7 -0
  33. package/docs/pie-schema.json +1332 -0
  34. package/docs/pie-schema.json.md +1015 -0
  35. package/lib/choice-input.js +377 -0
  36. package/lib/choice-input.js.map +1 -0
  37. package/lib/choice.js +192 -0
  38. package/lib/choice.js.map +1 -0
  39. package/lib/feedback-tick.js +134 -0
  40. package/lib/feedback-tick.js.map +1 -0
  41. package/lib/index.js +402 -0
  42. package/lib/index.js.map +1 -0
  43. package/lib/main.js +63 -0
  44. package/lib/main.js.map +1 -0
  45. package/lib/multiple-choice.js +397 -0
  46. package/lib/multiple-choice.js.map +1 -0
  47. package/lib/print.js +94 -0
  48. package/lib/print.js.map +1 -0
  49. package/lib/session-updater.js +37 -0
  50. package/lib/session-updater.js.map +1 -0
  51. package/module/configure.js +1 -0
  52. package/module/controller.js +3045 -0
  53. package/module/demo.js +86 -0
  54. package/module/element.js +1 -0
  55. package/module/index.html +21 -0
  56. package/module/manifest.json +14 -0
  57. package/module/print-demo.js +124 -0
  58. package/module/print.html +18 -0
  59. package/module/print.js +1 -0
  60. package/package.json +29 -89
  61. package/configure.js +0 -2
  62. package/controller.js +0 -1
  63. package/dist/author/defaults.d.ts +0 -205
  64. package/dist/author/defaults.js +0 -151
  65. package/dist/author/index.d.ts +0 -26
  66. package/dist/author/index.js +0 -119
  67. package/dist/author/main.d.ts +0 -34
  68. package/dist/author/main.js +0 -287
  69. package/dist/author/utils.d.ts +0 -9
  70. package/dist/author/utils.js +0 -7
  71. package/dist/browser/Radio-DADh6qUM.js +0 -9579
  72. package/dist/browser/Radio-DADh6qUM.js.map +0 -1
  73. package/dist/browser/author/index.js +0 -39745
  74. package/dist/browser/author/index.js.map +0 -1
  75. package/dist/browser/controller/index.js +0 -199
  76. package/dist/browser/controller/index.js.map +0 -1
  77. package/dist/browser/delivery/index.js +0 -251
  78. package/dist/browser/delivery/index.js.map +0 -1
  79. package/dist/browser/dist-nl5urzAW.js +0 -107
  80. package/dist/browser/dist-nl5urzAW.js.map +0 -1
  81. package/dist/browser/main-C4I_9OBk.js +0 -2440
  82. package/dist/browser/main-C4I_9OBk.js.map +0 -1
  83. package/dist/browser/multiple-choice.css +0 -2
  84. package/dist/browser/print/index.js +0 -43
  85. package/dist/browser/print/index.js.map +0 -1
  86. package/dist/controller/defaults.d.ts +0 -35
  87. package/dist/controller/defaults.js +0 -29
  88. package/dist/controller/index.d.ts +0 -65
  89. package/dist/controller/index.js +0 -124
  90. package/dist/controller/utils.d.ts +0 -10
  91. package/dist/controller/utils.js +0 -8
  92. package/dist/delivery/choice-input.d.ts +0 -44
  93. package/dist/delivery/choice-input.js +0 -272
  94. package/dist/delivery/choice.d.ts +0 -20
  95. package/dist/delivery/choice.js +0 -105
  96. package/dist/delivery/feedback-tick.d.ts +0 -20
  97. package/dist/delivery/feedback-tick.js +0 -104
  98. package/dist/delivery/index.d.ts +0 -37
  99. package/dist/delivery/index.js +0 -214
  100. package/dist/delivery/main.d.ts +0 -31
  101. package/dist/delivery/main.js +0 -51
  102. package/dist/delivery/multiple-choice.d.ts +0 -61
  103. package/dist/delivery/multiple-choice.js +0 -244
  104. package/dist/delivery/session-updater.d.ts +0 -10
  105. package/dist/delivery/session-updater.js +0 -9
  106. package/dist/index.d.ts +0 -1
  107. package/dist/index.iife.d.ts +0 -8
  108. package/dist/index.iife.js +0 -148
  109. package/dist/index.js +0 -2
  110. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  111. package/dist/print/index.d.ts +0 -15
  112. package/dist/print/index.js +0 -43
  113. package/dist/runtime-support.d.ts +0 -12
  114. package/dist/runtime-support.js +0 -12
@@ -1,2440 +0,0 @@
1
- import { At as e, It as t, Rt as n, Vt as r, _t as i, g as a, gt as o, h as s, ht as c, i as l, j as u, n as d, o as f, p, s as m, t as h, w as g, yt as _ } from "./Radio-DADh6qUM.js";
2
- import v, { useRef as y } from "react";
3
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
4
- //#region ../../lib-react/icons/dist/correct-response-icon.js
5
- var C = /* @__PURE__ */ r(n(), 1), w = ({ bgFill: e, fgFill: t }) => /* @__PURE__ */ S("svg", {
6
- preserveAspectRatio: "xMinYMin meet",
7
- version: "1.1",
8
- viewBox: "-283 359 34 35",
9
- style: { enableBackground: "new -283 359 34 35" },
10
- children: [
11
- /* @__PURE__ */ x("circle", {
12
- cx: "-266",
13
- cy: "375.9",
14
- r: "14",
15
- fill: e
16
- }),
17
- /* @__PURE__ */ x("path", {
18
- 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",
19
- fill: e
20
- }),
21
- /* @__PURE__ */ x("polygon", {
22
- 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",
23
- fill: t
24
- })
25
- ]
26
- });
27
- w.propTypes = {
28
- bgFill: C.default.string.isRequired,
29
- fgFill: C.default.string.isRequired
30
- };
31
- var T = ({ bgFill: e, fgFill: t, borderFill: n }) => /* @__PURE__ */ S("svg", {
32
- preserveAspectRatio: "xMinYMin meet",
33
- version: "1.1",
34
- viewBox: "-129.5 127 34 35",
35
- style: { enableBackground: "new -129.5 127 34 35" },
36
- children: [
37
- /* @__PURE__ */ x("path", {
38
- style: {
39
- fill: "#D0CAC5",
40
- stroke: "#E6E3E0",
41
- strokeWidth: .75,
42
- strokeMiterlimit: 10
43
- },
44
- 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"
45
- }),
46
- /* @__PURE__ */ x("path", {
47
- style: {
48
- fill: "#B3ABA4",
49
- stroke: "#CDC7C2",
50
- strokeWidth: .5,
51
- strokeMiterlimit: 10
52
- },
53
- 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"
54
- }),
55
- /* @__PURE__ */ x("circle", {
56
- cx: "-114.2",
57
- cy: "143.5",
58
- r: "14",
59
- fill: e
60
- }),
61
- /* @__PURE__ */ x("path", {
62
- 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",
63
- fill: n
64
- }),
65
- /* @__PURE__ */ x("polygon", {
66
- points: "-114.8,150.7 -121.6,144.8 -119,141.8 -115.9,144.5 -111.3,136.3 -107.8,138.2",
67
- fill: t
68
- })
69
- ]
70
- });
71
- T.propTypes = {
72
- bgFill: C.default.string.isRequired,
73
- fgFill: C.default.string.isRequired,
74
- borderFill: C.default.string.isRequired
75
- };
76
- var E = _("div")(({ size: e }) => ({
77
- width: e || "25px",
78
- height: e || "25px"
79
- })), D = ({ open: e, size: t }) => /* @__PURE__ */ x(E, {
80
- size: t,
81
- children: e ? /* @__PURE__ */ x(w, {
82
- bgFill: "#bce2ff",
83
- fgFill: "#1a9cff"
84
- }) : /* @__PURE__ */ x(T, {
85
- bgFill: "white",
86
- fgFill: "#1a9cff",
87
- borderFill: "#bce2ff"
88
- })
89
- });
90
- D.propTypes = {
91
- open: C.default.bool,
92
- size: C.default.string
93
- }, D.defaultProps = { open: !1 };
94
- //#endregion
95
- //#region ../../lib-react/correct-answer-toggle/dist/expander.js
96
- var O = "height ease-in 300ms, opacity ease-in 300ms", k = _("div")(() => ({
97
- position: "relative",
98
- height: 0,
99
- overflow: "hidden",
100
- display: "flex",
101
- visibility: "hidden",
102
- width: 0,
103
- "&.enter": {
104
- transition: O,
105
- opacity: 1,
106
- height: "auto",
107
- width: "auto",
108
- visibility: "visible",
109
- minHeight: "25px"
110
- },
111
- "&.enter-done": {
112
- height: "auto",
113
- visibility: "visible",
114
- width: "auto",
115
- minHeight: "25px"
116
- },
117
- "&.exit": {
118
- transition: O,
119
- opacity: 0,
120
- height: 0,
121
- visibility: "visible",
122
- width: 0
123
- },
124
- "&.exit-done": {
125
- opacity: 0,
126
- visibility: "hidden",
127
- height: 0,
128
- width: 0
129
- }
130
- })), A = (e) => {
131
- let { show: t, children: n, className: r } = e, a = y(null);
132
- return /* @__PURE__ */ x(i, {
133
- nodeRef: a,
134
- in: t,
135
- appear: !0,
136
- mountOnEnter: !1,
137
- timeout: 300,
138
- classNames: {
139
- enter: "enter",
140
- enterDone: "enter-done",
141
- exit: "exit",
142
- exitDone: "exit-done"
143
- },
144
- children: /* @__PURE__ */ x(k, {
145
- ref: a,
146
- className: r,
147
- children: n
148
- })
149
- });
150
- };
151
- A.propTypes = {
152
- show: C.default.bool.isRequired,
153
- className: C.default.string,
154
- children: C.default.oneOfType([C.default.arrayOf(C.default.node), C.default.node]).isRequired
155
- };
156
- //#endregion
157
- //#region ../../lib-react/translator/dist/en.js
158
- var j = {
159
- translation: {
160
- categorize: {
161
- limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
162
- maxChoicesPerCategoryRestriction: "To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s]."
163
- },
164
- ebsr: { part: "Part {{index}}" },
165
- numberLine: {
166
- addElementLimit_one: "You can only add {{count}} element",
167
- addElementLimit_other: "You can only add {{count}} elements",
168
- clearAll: "Clear all"
169
- },
170
- imageClozeAssociation: {
171
- reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
172
- reachedLimit_other: "Full"
173
- },
174
- drawingResponse: {
175
- fillColor: "Fill color",
176
- outlineColor: "Outline color",
177
- noFill: "No fill",
178
- lightblue: "Light blue",
179
- lightyellow: "Light yellow",
180
- red: "Red",
181
- orange: "Orange",
182
- yellow: "Yellow",
183
- violet: "Violet",
184
- blue: "Blue",
185
- green: "Green",
186
- white: "White",
187
- black: "Black",
188
- onDoubleClick: "Double click to edit this text. Press Enter to submit."
189
- },
190
- charting: {
191
- addCategory: "Add category",
192
- actions: "Actions",
193
- add: "Add",
194
- delete: "Delete",
195
- newLabel: "New label",
196
- reachedLimit_other: "There can't be more than {{count}} categories.",
197
- keyLegend: {
198
- incorrectAnswer: "Student incorrect answer",
199
- correctAnswer: "Student correct answer",
200
- correctKeyAnswer: "Answer key correct"
201
- }
202
- },
203
- graphing: {
204
- point: "Point",
205
- circle: "Circle",
206
- line: "Line",
207
- parabola: "Parabola",
208
- absolute: "Absolute Value",
209
- exponential: "Exponential",
210
- polygon: "Polygon",
211
- ray: "Ray",
212
- segment: "Segment",
213
- sine: "Sine",
214
- vector: "Vector",
215
- label: "Label",
216
- redo: "Redo",
217
- reset: "Reset"
218
- },
219
- 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." },
220
- multipleChoice: {
221
- minSelections: "Select at least {{minSelections}}.",
222
- maxSelections_one: "Only {{maxSelections}} answer is allowed.",
223
- maxSelections_other: "Only {{maxSelections}} answers are allowed.",
224
- minmaxSelections_equal: "Select {{minSelections}}.",
225
- minmaxSelections_range: "Select between {{minSelections}} and {{maxSelections}}."
226
- },
227
- selectText: {
228
- correctAnswerSelected: "Correct",
229
- correctAnswerNotSelected: "Correct Answer Not Selected",
230
- incorrectSelection: "Incorrect Selection",
231
- key: "Key"
232
- }
233
- },
234
- common: {
235
- undo: "Undo",
236
- clearAll: "Clear all",
237
- correct: "Correct",
238
- incorrect: "Incorrect",
239
- showCorrectAnswer: "Show correct answer",
240
- hideCorrectAnswer: "Hide correct answer",
241
- 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.",
242
- warning: "Warning",
243
- showNote: "Show Note",
244
- hideNote: "Hide Note",
245
- cancel: "Cancel"
246
- }
247
- }, M = {
248
- translation: {
249
- categorize: {
250
- limitMaxChoicesPerCategory: "Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
251
- maxChoicesPerCategoryRestriction: "Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta"
252
- },
253
- ebsr: { part: "Parte {{index}}" },
254
- numberLine: {
255
- addElementLimit_one: "Solo puedes agregar {{count}} elemento",
256
- addElementLimit_other: "Solo puedes agregar {{count}} elementos",
257
- clearAll: "Borrar todo"
258
- },
259
- imageClozeAssociation: {
260
- reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
261
- reachedLimit_other: "Lleno"
262
- },
263
- drawingResponse: {
264
- fillColor: "Color de relleno",
265
- outlineColor: "Color del contorno",
266
- noFill: "Sin relleno",
267
- lightblue: "Azul claro",
268
- lightyellow: "Amarillo claro",
269
- red: "Rojo",
270
- orange: "Naranja",
271
- yellow: "Amarillo",
272
- violet: "Violeta",
273
- blue: "Azul",
274
- green: "Verde",
275
- white: "Blanco",
276
- black: "Negro",
277
- onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
278
- },
279
- charting: {
280
- addCategory: "Añadir categoría",
281
- actions: "Acciones",
282
- add: "Añadir",
283
- delete: "Eliminar",
284
- newLabel: "Nueva etiqueta",
285
- reachedLimit_other: "No puede haber más de {{count}} categorías.",
286
- keyLegend: {
287
- incorrectAnswer: "Respuesta incorrecta del estudiante",
288
- correctAnswer: "Respuesta correcta del estudiante",
289
- correctKeyAnswer: "Clave de respuesta correcta"
290
- }
291
- },
292
- graphing: {
293
- point: "Punto",
294
- circle: "Circulo",
295
- line: "Línea",
296
- parabola: "Parábola",
297
- absolute: "Valor absoluto",
298
- exponential: "Exponencial",
299
- polygon: "Polígono",
300
- ray: "Semirrecta",
301
- segment: "Segmento ",
302
- sine: "Seno",
303
- vector: "Vector",
304
- label: "Etiqueta",
305
- redo: "Rehacer",
306
- reset: "Reiniciar"
307
- },
308
- 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." },
309
- multipleChoice: {
310
- minSelections: "Seleccione al menos {{minSelections}}.",
311
- maxSelections_one: "Sólo se permite {{maxSelections}} respuesta.",
312
- maxSelections_other: "Sólo se permiten {{maxSelections}} respuestas.",
313
- minmaxSelections_equal: "Seleccione {{minSelections}}.",
314
- minmaxSelections_range: "Seleccione entre {{minSelections}} y {{maxSelections}}."
315
- },
316
- selectText: {
317
- correctAnswerSelected: "Respuesta Correcta",
318
- correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
319
- incorrectSelection: "Selección Incorrecta",
320
- key: "Clave"
321
- }
322
- },
323
- common: {
324
- undo: "Deshacer",
325
- clearAll: "Borrar todo",
326
- correct: "Correct",
327
- incorrect: "Incorrect",
328
- showCorrectAnswer: "Mostrar respuesta correcta",
329
- hideCorrectAnswer: "Ocultar respuesta correcta",
330
- 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.",
331
- warning: "Advertencia",
332
- showNote: "Mostrar Nota",
333
- hideNote: "Ocultar Nota",
334
- cancel: "Cancelar"
335
- }
336
- }, N = (e) => typeof e == "string", P = () => {
337
- let e, t, n = new Promise((n, r) => {
338
- e = n, t = r;
339
- });
340
- return n.resolve = e, n.reject = t, n;
341
- }, ee = (e) => e == null ? "" : "" + e, te = (e, t, n) => {
342
- e.forEach((e) => {
343
- t[e] && (n[e] = t[e]);
344
- });
345
- }, ne = /###/g, re = (e) => e && e.indexOf("###") > -1 ? e.replace(ne, ".") : e, ie = (e) => !e || N(e), F = (e, t, n) => {
346
- let r = N(t) ? t.split(".") : t, i = 0;
347
- for (; i < r.length - 1;) {
348
- if (ie(e)) return {};
349
- let t = re(r[i]);
350
- !e[t] && n && (e[t] = new n()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++i;
351
- }
352
- return ie(e) ? {} : {
353
- obj: e,
354
- k: re(r[i])
355
- };
356
- }, ae = (e, t, n) => {
357
- let { obj: r, k: i } = F(e, t, Object);
358
- if (r !== void 0 || t.length === 1) {
359
- r[i] = n;
360
- return;
361
- }
362
- let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = F(e, o, Object);
363
- for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = F(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
364
- s.obj[`${s.k}.${a}`] = n;
365
- }, oe = (e, t, n, r) => {
366
- let { obj: i, k: a } = F(e, t, Object);
367
- i[a] = i[a] || [], i[a].push(n);
368
- }, I = (e, t) => {
369
- let { obj: n, k: r } = F(e, t);
370
- if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
371
- }, se = (e, t, n) => {
372
- let r = I(e, n);
373
- return r === void 0 ? I(t, n) : r;
374
- }, ce = (e, t, n) => {
375
- for (let r in t) r !== "__proto__" && r !== "constructor" && (r in e ? N(e[r]) || e[r] instanceof String || N(t[r]) || t[r] instanceof String ? n && (e[r] = t[r]) : ce(e[r], t[r], n) : e[r] = t[r]);
376
- return e;
377
- }, L = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), le = {
378
- "&": "&amp;",
379
- "<": "&lt;",
380
- ">": "&gt;",
381
- "\"": "&quot;",
382
- "'": "&#39;",
383
- "/": "&#x2F;"
384
- }, ue = (e) => N(e) ? e.replace(/[&<>"'\/]/g, (e) => le[e]) : e, de = class {
385
- constructor(e) {
386
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
387
- }
388
- getRegExp(e) {
389
- let t = this.regExpMap.get(e);
390
- if (t !== void 0) return t;
391
- let n = new RegExp(e);
392
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
393
- }
394
- }, fe = [
395
- " ",
396
- ",",
397
- "?",
398
- "!",
399
- ";"
400
- ], pe = new de(20), me = (e, t, n) => {
401
- t ||= "", n ||= "";
402
- let r = fe.filter((e) => t.indexOf(e) < 0 && n.indexOf(e) < 0);
403
- if (r.length === 0) return !0;
404
- let i = pe.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
405
- if (!a) {
406
- let t = e.indexOf(n);
407
- t > 0 && !i.test(e.substring(0, t)) && (a = !0);
408
- }
409
- return a;
410
- }, he = (e, t, n = ".") => {
411
- if (!e) return;
412
- if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
413
- let r = t.split(n), i = e;
414
- for (let e = 0; e < r.length;) {
415
- if (!i || typeof i != "object") return;
416
- let t, a = "";
417
- for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
418
- if ([
419
- "string",
420
- "number",
421
- "boolean"
422
- ].indexOf(typeof t) > -1 && o < r.length - 1) continue;
423
- e += o - e + 1;
424
- break;
425
- }
426
- i = t;
427
- }
428
- return i;
429
- }, R = (e) => e?.replace(/_/g, "-"), ge = {
430
- type: "logger",
431
- log(e) {
432
- this.output("log", e);
433
- },
434
- warn(e) {
435
- this.output("warn", e);
436
- },
437
- error(e) {
438
- this.output("error", e);
439
- },
440
- output(e, t) {
441
- console?.[e]?.apply?.(console, t);
442
- }
443
- }, z = new class e {
444
- constructor(e, t = {}) {
445
- this.init(e, t);
446
- }
447
- init(e, t = {}) {
448
- this.prefix = t.prefix || "i18next:", this.logger = e || ge, this.options = t, this.debug = t.debug;
449
- }
450
- log(...e) {
451
- return this.forward(e, "log", "", !0);
452
- }
453
- warn(...e) {
454
- return this.forward(e, "warn", "", !0);
455
- }
456
- error(...e) {
457
- return this.forward(e, "error", "");
458
- }
459
- deprecate(...e) {
460
- return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
461
- }
462
- forward(e, t, n, r) {
463
- return r && !this.debug ? null : (N(e[0]) && (e[0] = `${n}${this.prefix} ${e[0]}`), this.logger[t](e));
464
- }
465
- create(t) {
466
- return new e(this.logger, {
467
- prefix: `${this.prefix}:${t}:`,
468
- ...this.options
469
- });
470
- }
471
- clone(t) {
472
- return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
473
- }
474
- }(), B = class {
475
- constructor() {
476
- this.observers = {};
477
- }
478
- on(e, t) {
479
- return e.split(" ").forEach((e) => {
480
- this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
481
- let n = this.observers[e].get(t) || 0;
482
- this.observers[e].set(t, n + 1);
483
- }), this;
484
- }
485
- off(e, t) {
486
- if (this.observers[e]) {
487
- if (!t) {
488
- delete this.observers[e];
489
- return;
490
- }
491
- this.observers[e].delete(t);
492
- }
493
- }
494
- emit(e, ...t) {
495
- this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
496
- for (let r = 0; r < n; r++) e(...t);
497
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
498
- for (let i = 0; i < r; i++) n.apply(n, [e, ...t]);
499
- });
500
- }
501
- }, _e = class extends B {
502
- constructor(e, t = {
503
- ns: ["translation"],
504
- defaultNS: "translation"
505
- }) {
506
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
507
- }
508
- addNamespaces(e) {
509
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
510
- }
511
- removeNamespaces(e) {
512
- let t = this.options.ns.indexOf(e);
513
- t > -1 && this.options.ns.splice(t, 1);
514
- }
515
- getResource(e, t, n, r = {}) {
516
- let i = r.keySeparator === void 0 ? this.options.keySeparator : r.keySeparator, a = r.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : r.ignoreJSONStructure, o;
517
- e.indexOf(".") > -1 ? o = e.split(".") : (o = [e, t], n && (Array.isArray(n) ? o.push(...n) : N(n) && i ? o.push(...n.split(i)) : o.push(n)));
518
- let s = I(this.data, o);
519
- return !s && !t && !n && e.indexOf(".") > -1 && (e = o[0], t = o[1], n = o.slice(2).join(".")), s || !a || !N(n) ? s : he(this.data?.[e]?.[t], n, i);
520
- }
521
- addResource(e, t, n, r, i = { silent: !1 }) {
522
- let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
523
- n && (o = o.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), ae(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
524
- }
525
- addResources(e, t, n, r = { silent: !1 }) {
526
- for (let r in n) (N(n[r]) || Array.isArray(n[r])) && this.addResource(e, t, r, n[r], { silent: !0 });
527
- r.silent || this.emit("added", e, t, n);
528
- }
529
- addResourceBundle(e, t, n, r, i, a = {
530
- silent: !1,
531
- skipCopy: !1
532
- }) {
533
- let o = [e, t];
534
- e.indexOf(".") > -1 && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
535
- let s = I(this.data, o) || {};
536
- a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? ce(s, n, i) : s = {
537
- ...s,
538
- ...n
539
- }, ae(this.data, o, s), a.silent || this.emit("added", e, t, n);
540
- }
541
- removeResourceBundle(e, t) {
542
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
543
- }
544
- hasResourceBundle(e, t) {
545
- return this.getResource(e, t) !== void 0;
546
- }
547
- getResourceBundle(e, t) {
548
- return t ||= this.options.defaultNS, this.getResource(e, t);
549
- }
550
- getDataByLanguage(e) {
551
- return this.data[e];
552
- }
553
- hasLanguageSomeTranslations(e) {
554
- let t = this.getDataByLanguage(e);
555
- return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
556
- }
557
- toJSON() {
558
- return this.data;
559
- }
560
- }, ve = {
561
- processors: {},
562
- addPostProcessor(e) {
563
- this.processors[e.name] = e;
564
- },
565
- handle(e, t, n, r, i) {
566
- return e.forEach((e) => {
567
- t = this.processors[e]?.process(t, n, r, i) ?? t;
568
- }), t;
569
- }
570
- }, ye = Symbol("i18next/PATH_KEY");
571
- function be() {
572
- let e = [], t = Object.create(null), n;
573
- return t.get = (r, i) => (n?.revoke?.(), i === ye ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
574
- }
575
- function V(e, t) {
576
- let { [ye]: n } = e(be()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":";
577
- if (n.length > 1 && i) {
578
- let e = t?.ns, a = Array.isArray(e) ? e : null;
579
- if (a && a.length > 1 && a.slice(1).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
580
- }
581
- return n.join(r);
582
- }
583
- var xe = {}, Se = (e) => !N(e) && typeof e != "boolean" && typeof e != "number", Ce = class e extends B {
584
- constructor(e, t = {}) {
585
- super(), te([
586
- "resourceStore",
587
- "languageUtils",
588
- "pluralResolver",
589
- "interpolator",
590
- "backendConnector",
591
- "i18nFormat",
592
- "utils"
593
- ], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = z.create("translator");
594
- }
595
- changeLanguage(e) {
596
- e && (this.language = e);
597
- }
598
- exists(e, t = { interpolation: {} }) {
599
- let n = { ...t };
600
- if (e == null) return !1;
601
- let r = this.resolve(e, n);
602
- if (r?.res === void 0) return !1;
603
- let i = Se(r.res);
604
- return !(n.returnObjects === !1 && i);
605
- }
606
- extractFromKey(e, t) {
607
- let n = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
608
- n === void 0 && (n = ":");
609
- 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 && !me(e, n, r);
610
- if (a && !o) {
611
- let t = e.match(this.interpolator.nestingRegexp);
612
- if (t && t.length > 0) return {
613
- key: e,
614
- namespaces: N(i) ? [i] : i
615
- };
616
- let a = e.split(n);
617
- (n !== r || n === r && this.options.ns.indexOf(a[0]) > -1) && (i = a.shift()), e = a.join(r);
618
- }
619
- return {
620
- key: e,
621
- namespaces: N(i) ? [i] : i
622
- };
623
- }
624
- translate(t, n, r) {
625
- let i = typeof n == "object" ? { ...n } : n;
626
- if (typeof i != "object" && this.options.overloadTranslationOptionHandler && (i = this.options.overloadTranslationOptionHandler(arguments)), typeof i == "object" && (i = { ...i }), i ||= {}, t == null) return "";
627
- typeof t == "function" && (t = V(t, {
628
- ...this.options,
629
- ...i
630
- })), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? V(e, {
631
- ...this.options,
632
- ...i
633
- }) : String(e));
634
- 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;
635
- u === void 0 && (u = ":");
636
- let d = i.lng || this.language, f = i.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
637
- if (d?.toLowerCase() === "cimode") return f ? a ? {
638
- res: `${l}${u}${s}`,
639
- usedKey: s,
640
- exactUsedKey: s,
641
- usedLng: d,
642
- usedNS: l,
643
- usedParams: this.getUsedParamsDetails(i)
644
- } : `${l}${u}${s}` : a ? {
645
- res: s,
646
- usedKey: s,
647
- exactUsedKey: s,
648
- usedLng: d,
649
- usedNS: l,
650
- usedParams: this.getUsedParamsDetails(i)
651
- } : s;
652
- let p = this.resolve(t, i), m = p?.res, h = p?.usedKey || s, g = p?.exactUsedKey || s, _ = [
653
- "[object Number]",
654
- "[object Function]",
655
- "[object RegExp]"
656
- ], v = i.joinArrays === void 0 ? this.options.joinArrays : i.joinArrays, y = !this.i18nFormat || this.i18nFormat.handleAsObject, b = i.count !== void 0 && !N(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;
657
- y && !m && x && (E = T);
658
- let D = Se(E), O = Object.prototype.toString.apply(E);
659
- if (y && E && D && _.indexOf(O) < 0 && !(N(v) && Array.isArray(E))) {
660
- if (!i.returnObjects && !this.options.returnObjects) {
661
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
662
- let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(h, E, {
663
- ...i,
664
- ns: c
665
- }) : `key '${s} (${this.language})' returned an object instead of string.`;
666
- return a ? (p.res = e, p.usedParams = this.getUsedParamsDetails(i), p) : e;
667
- }
668
- if (o) {
669
- let e = Array.isArray(E), t = e ? [] : {}, n = e ? g : h;
670
- for (let e in E) if (Object.prototype.hasOwnProperty.call(E, e)) {
671
- let r = `${n}${o}${e}`;
672
- x && !m ? t[e] = this.translate(r, {
673
- ...i,
674
- defaultValue: Se(T) ? T[e] : void 0,
675
- joinArrays: !1,
676
- ns: c
677
- }) : t[e] = this.translate(r, {
678
- ...i,
679
- joinArrays: !1,
680
- ns: c
681
- }), t[e] === r && (t[e] = E[e]);
682
- }
683
- m = t;
684
- }
685
- } else if (y && N(v) && Array.isArray(m)) m = m.join(v), m &&= this.extendTranslation(m, t, i, r);
686
- else {
687
- let e = !1, n = !1;
688
- !this.isValidLookup(m) && x && (e = !0, m = T), this.isValidLookup(m) || (n = !0, m = s);
689
- let a = (i.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : m, c = x && T !== m && this.options.updateMissing;
690
- if (n || e || c) {
691
- if (this.logger.log(c ? "updateKey" : "missingKey", d, l, s, c ? T : m), o) {
692
- let e = this.resolve(s, {
693
- ...i,
694
- keySeparator: !1
695
- });
696
- 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.");
697
- }
698
- let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, i.lng || this.language);
699
- if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
700
- else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(i.lng || this.language) : e.push(i.lng || this.language);
701
- let n = (e, t, n) => {
702
- let r = x && n !== m ? n : a;
703
- 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);
704
- };
705
- this.options.saveMissing && (this.options.saveMissingPlurals && b ? e.forEach((e) => {
706
- let t = this.pluralResolver.getSuffixes(e, i);
707
- w && i[`defaultValue${this.options.pluralSeparator}zero`] && t.indexOf(`${this.options.pluralSeparator}zero`) < 0 && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
708
- n([e], s + t, i[`defaultValue${t}`] || T);
709
- });
710
- }) : n(e, s, T));
711
- }
712
- 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));
713
- }
714
- return a ? (p.res = m, p.usedParams = this.getUsedParamsDetails(i), p) : m;
715
- }
716
- extendTranslation(e, t, n, r, i) {
717
- if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
718
- ...this.options.interpolation.defaultVariables,
719
- ...n
720
- }, n.lng || this.language || r.usedLng, r.usedNS, r.usedKey, { resolved: r });
721
- else if (!n.skipInterpolation) {
722
- n.interpolation && this.interpolator.init({
723
- ...n,
724
- interpolation: {
725
- ...this.options.interpolation,
726
- ...n.interpolation
727
- }
728
- });
729
- let a = N(e) && (n?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : n.interpolation.skipOnVariables), o;
730
- if (a) {
731
- let t = e.match(this.interpolator.nestingRegexp);
732
- o = t && t.length;
733
- }
734
- let s = n.replace && !N(n.replace) ? n.replace : n;
735
- if (this.options.interpolation.defaultVariables && (s = {
736
- ...this.options.interpolation.defaultVariables,
737
- ...s
738
- }), e = this.interpolator.interpolate(e, s, n.lng || this.language || r.usedLng, n), a) {
739
- let t = e.match(this.interpolator.nestingRegexp), r = t && t.length;
740
- o < r && (n.nest = !1);
741
- }
742
- !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();
743
- }
744
- let a = n.postProcess || this.options.postProcess, o = N(a) ? [a] : a;
745
- return e != null && o?.length && n.applyPostProcessor !== !1 && (e = ve.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
746
- i18nResolved: {
747
- ...r,
748
- usedParams: this.getUsedParamsDetails(n)
749
- },
750
- ...n
751
- } : n, this)), e;
752
- }
753
- resolve(e, t = {}) {
754
- let n, r, i, a, o;
755
- return N(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? V(e, {
756
- ...this.options,
757
- ...t
758
- }) : e)), e.forEach((e) => {
759
- if (this.isValidLookup(n)) return;
760
- let s = this.extractFromKey(e, t), c = s.key;
761
- r = c;
762
- let l = s.namespaces;
763
- this.options.fallbackNS && (l = l.concat(this.options.fallbackNS));
764
- let u = t.count !== void 0 && !N(t.count), d = u && !t.ordinal && t.count === 0, f = t.context !== void 0 && (N(t.context) || typeof t.context == "number") && t.context !== "", p = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
765
- l.forEach((e) => {
766
- this.isValidLookup(n) || (o = e, !xe[`${p[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(o) && (xe[`${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) => {
767
- if (this.isValidLookup(n)) return;
768
- a = r;
769
- let o = [c];
770
- if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(o, c, r, e, t);
771
- else {
772
- let e;
773
- u && (e = this.pluralResolver.getSuffix(r, t.count, t));
774
- let n = `${this.options.pluralSeparator}zero`, i = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
775
- 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) {
776
- let r = `${c}${this.options.contextSeparator || "_"}${t.context}`;
777
- 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));
778
- }
779
- }
780
- let s;
781
- for (; s = o.pop();) this.isValidLookup(n) || (i = s, n = this.getResource(r, e, s, t));
782
- }));
783
- });
784
- }), {
785
- res: n,
786
- usedKey: r,
787
- exactUsedKey: i,
788
- usedLng: a,
789
- usedNS: o
790
- };
791
- }
792
- isValidLookup(e) {
793
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
794
- }
795
- getResource(e, t, n, r = {}) {
796
- return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
797
- }
798
- getUsedParamsDetails(e = {}) {
799
- let t = [
800
- "defaultValue",
801
- "ordinal",
802
- "context",
803
- "replace",
804
- "lng",
805
- "lngs",
806
- "fallbackLng",
807
- "ns",
808
- "keySeparator",
809
- "nsSeparator",
810
- "returnObjects",
811
- "returnDetails",
812
- "joinArrays",
813
- "postProcess",
814
- "interpolation"
815
- ], n = e.replace && !N(e.replace), r = n ? e.replace : e;
816
- if (n && e.count !== void 0 && (r.count = e.count), this.options.interpolation.defaultVariables && (r = {
817
- ...this.options.interpolation.defaultVariables,
818
- ...r
819
- }), !n) {
820
- r = { ...r };
821
- for (let e of t) delete r[e];
822
- }
823
- return r;
824
- }
825
- static hasDefaultValue(e) {
826
- for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.substring(0, 12) === "defaultValue" && e[t] !== void 0) return !0;
827
- return !1;
828
- }
829
- }, we = class {
830
- constructor(e) {
831
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = z.create("languageUtils");
832
- }
833
- getScriptPartFromCode(e) {
834
- if (e = R(e), !e || e.indexOf("-") < 0) return null;
835
- let t = e.split("-");
836
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
837
- }
838
- getLanguagePartFromCode(e) {
839
- if (e = R(e), !e || e.indexOf("-") < 0) return e;
840
- let t = e.split("-");
841
- return this.formatLanguageCode(t[0]);
842
- }
843
- formatLanguageCode(e) {
844
- if (N(e) && e.indexOf("-") > -1) {
845
- let t;
846
- try {
847
- t = Intl.getCanonicalLocales(e)[0];
848
- } catch {}
849
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
850
- }
851
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
852
- }
853
- isSupportedCode(e) {
854
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
855
- }
856
- getBestMatchFromCodes(e) {
857
- if (!e) return null;
858
- let t;
859
- return e.forEach((e) => {
860
- if (t) return;
861
- let n = this.formatLanguageCode(e);
862
- (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
863
- }), !t && this.options.supportedLngs && e.forEach((e) => {
864
- if (t) return;
865
- let n = this.getScriptPartFromCode(e);
866
- if (this.isSupportedCode(n)) return t = n;
867
- let r = this.getLanguagePartFromCode(e);
868
- if (this.isSupportedCode(r)) return t = r;
869
- t = this.options.supportedLngs.find((e) => {
870
- 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;
871
- });
872
- }), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
873
- }
874
- getFallbackCodes(e, t) {
875
- if (!e) return [];
876
- if (typeof e == "function" && (e = e(t)), N(e) && (e = [e]), Array.isArray(e)) return e;
877
- if (!t) return e.default || [];
878
- let n = e[t];
879
- return n ||= e[this.getScriptPartFromCode(t)], n ||= e[this.formatLanguageCode(t)], n ||= e[this.getLanguagePartFromCode(t)], n ||= e.default, n || [];
880
- }
881
- toResolveHierarchy(e, t) {
882
- let n = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), r = [], i = (e) => {
883
- e && (this.isSupportedCode(e) ? r.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
884
- };
885
- return N(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))) : N(e) && i(this.formatLanguageCode(e)), n.forEach((e) => {
886
- r.indexOf(e) < 0 && i(this.formatLanguageCode(e));
887
- }), r;
888
- }
889
- }, Te = {
890
- zero: 0,
891
- one: 1,
892
- two: 2,
893
- few: 3,
894
- many: 4,
895
- other: 5
896
- }, Ee = {
897
- select: (e) => e === 1 ? "one" : "other",
898
- resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
899
- }, De = class {
900
- constructor(e, t = {}) {
901
- this.languageUtils = e, this.options = t, this.logger = z.create("pluralResolver"), this.pluralRulesCache = {};
902
- }
903
- clearCache() {
904
- this.pluralRulesCache = {};
905
- }
906
- getRule(e, t = {}) {
907
- let n = R(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
908
- cleanedCode: n,
909
- type: r
910
- });
911
- if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
912
- let a;
913
- try {
914
- a = new Intl.PluralRules(n, { type: r });
915
- } catch {
916
- if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), Ee;
917
- if (!e.match(/-|_/)) return Ee;
918
- let n = this.languageUtils.getLanguagePartFromCode(e);
919
- a = this.getRule(n, t);
920
- }
921
- return this.pluralRulesCache[i] = a, a;
922
- }
923
- needsPlural(e, t = {}) {
924
- let n = this.getRule(e, t);
925
- return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
926
- }
927
- getPluralFormsOfKey(e, t, n = {}) {
928
- return this.getSuffixes(e, n).map((e) => `${t}${e}`);
929
- }
930
- getSuffixes(e, t = {}) {
931
- let n = this.getRule(e, t);
932
- 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}`) : [];
933
- }
934
- getSuffix(e, t, n = {}) {
935
- let r = this.getRule(e, n);
936
- 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));
937
- }
938
- }, Oe = (e, t, n, r = ".", i = !0) => {
939
- let a = se(e, t, n);
940
- return !a && i && N(n) && (a = he(e, n, r), a === void 0 && (a = he(t, n, r))), a;
941
- }, ke = (e) => e.replace(/\$/g, "$$$$"), Ae = class {
942
- constructor(e = {}) {
943
- this.logger = z.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
944
- }
945
- init(e = {}) {
946
- e.interpolation ||= { escapeValue: !0 };
947
- 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;
948
- this.escape = t === void 0 ? ue : t, this.escapeValue = n === void 0 ? !0 : n, this.useRawValueToEscape = r === void 0 ? !1 : r, this.prefix = i ? L(i) : a || "{{", this.suffix = o ? L(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? L(d) : f || L("$t("), this.nestingSuffix = p ? L(p) : m || L(")"), this.nestingOptionsSeparator = h || ",", this.maxReplaces = g || 1e3, this.alwaysFormat = _ === void 0 ? !1 : _, this.resetRegExp();
949
- }
950
- reset() {
951
- this.options && this.init(this.options);
952
- }
953
- resetRegExp() {
954
- let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
955
- 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}`);
956
- }
957
- interpolate(e, t, n, r) {
958
- let i, a, o, s = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, c = (e) => {
959
- if (e.indexOf(this.formatSeparator) < 0) {
960
- let i = Oe(t, s, e, this.options.keySeparator, this.options.ignoreJSONStructure);
961
- return this.alwaysFormat ? this.format(i, void 0, n, {
962
- ...r,
963
- ...t,
964
- interpolationkey: e
965
- }) : i;
966
- }
967
- let i = e.split(this.formatSeparator), a = i.shift().trim(), o = i.join(this.formatSeparator).trim();
968
- return this.format(Oe(t, s, a, this.options.keySeparator, this.options.ignoreJSONStructure), o, n, {
969
- ...r,
970
- ...t,
971
- interpolationkey: a
972
- });
973
- };
974
- this.resetRegExp();
975
- let l = r?.missingInterpolationHandler || this.options.missingInterpolationHandler, u = r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables;
976
- return [{
977
- regex: this.regexpUnescape,
978
- safeValue: (e) => ke(e)
979
- }, {
980
- regex: this.regexp,
981
- safeValue: (e) => this.escapeValue ? ke(this.escape(e)) : ke(e)
982
- }].forEach((t) => {
983
- for (o = 0; i = t.regex.exec(e);) {
984
- let n = i[1].trim();
985
- if (a = c(n), a === void 0) if (typeof l == "function") {
986
- let t = l(e, i, r);
987
- a = N(t) ? t : "";
988
- } else if (r && Object.prototype.hasOwnProperty.call(r, n)) a = "";
989
- else if (u) {
990
- a = i[0];
991
- continue;
992
- } else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`), a = "";
993
- else !N(a) && !this.useRawValueToEscape && (a = ee(a));
994
- let s = t.safeValue(a);
995
- 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;
996
- }
997
- }), e;
998
- }
999
- nest(e, t, n = {}) {
1000
- let r, i, a, o = (e, t) => {
1001
- let n = this.nestingOptionsSeparator;
1002
- if (e.indexOf(n) < 0) return e;
1003
- let r = e.split(RegExp(`${L(n)}[ ]*{`)), i = `{${r[1]}`;
1004
- e = r[0], i = this.interpolate(i, a);
1005
- let o = i.match(/'/g), s = i.match(/"/g);
1006
- ((o?.length ?? 0) % 2 == 0 && !s || (s?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
1007
- try {
1008
- a = JSON.parse(i), t && (a = {
1009
- ...t,
1010
- ...a
1011
- });
1012
- } catch (t) {
1013
- return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
1014
- }
1015
- return a.defaultValue && a.defaultValue.indexOf(this.prefix) > -1 && delete a.defaultValue, e;
1016
- };
1017
- for (; r = this.nestingRegexp.exec(e);) {
1018
- let s = [];
1019
- a = { ...n }, a = a.replace && !N(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
1020
- let c = /{.*}/.test(r[1]) ? r[1].lastIndexOf("}") + 1 : r[1].indexOf(this.formatSeparator);
1021
- 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 && !N(i)) return i;
1022
- N(i) || (i = ee(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, {
1023
- ...n,
1024
- interpolationkey: r[1].trim()
1025
- }), i.trim())), e = e.replace(r[0], i), this.regexp.lastIndex = 0;
1026
- }
1027
- return e;
1028
- }
1029
- }, je = (e) => {
1030
- let t = e.toLowerCase().trim(), n = {};
1031
- if (e.indexOf("(") > -1) {
1032
- let r = e.split("(");
1033
- t = r[0].toLowerCase().trim();
1034
- let i = r[1].substring(0, r[1].length - 1);
1035
- t === "currency" && i.indexOf(":") < 0 ? n.currency ||= i.trim() : t === "relativetime" && i.indexOf(":") < 0 ? n.range ||= i.trim() : i.split(";").forEach((e) => {
1036
- if (e) {
1037
- let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
1038
- n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
1039
- }
1040
- });
1041
- }
1042
- return {
1043
- formatName: t,
1044
- formatOptions: n
1045
- };
1046
- }, Me = (e) => {
1047
- let t = {};
1048
- return (n, r, i) => {
1049
- let a = i;
1050
- i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
1051
- ...a,
1052
- [i.interpolationkey]: void 0
1053
- });
1054
- let o = r + JSON.stringify(a), s = t[o];
1055
- return s || (s = e(R(r), i), t[o] = s), s(n);
1056
- };
1057
- }, Ne = (e) => (t, n, r) => e(R(n), r)(t), Pe = class {
1058
- constructor(e = {}) {
1059
- this.logger = z.create("formatter"), this.options = e, this.init(e);
1060
- }
1061
- init(e, t = { interpolation: {} }) {
1062
- this.formatSeparator = t.interpolation.formatSeparator || ",";
1063
- let n = t.cacheInBuiltFormats ? Me : Ne;
1064
- this.formats = {
1065
- number: n((e, t) => {
1066
- let n = new Intl.NumberFormat(e, { ...t });
1067
- return (e) => n.format(e);
1068
- }),
1069
- currency: n((e, t) => {
1070
- let n = new Intl.NumberFormat(e, {
1071
- ...t,
1072
- style: "currency"
1073
- });
1074
- return (e) => n.format(e);
1075
- }),
1076
- datetime: n((e, t) => {
1077
- let n = new Intl.DateTimeFormat(e, { ...t });
1078
- return (e) => n.format(e);
1079
- }),
1080
- relativetime: n((e, t) => {
1081
- let n = new Intl.RelativeTimeFormat(e, { ...t });
1082
- return (e) => n.format(e, t.range || "day");
1083
- }),
1084
- list: n((e, t) => {
1085
- let n = new Intl.ListFormat(e, { ...t });
1086
- return (e) => n.format(e);
1087
- })
1088
- };
1089
- }
1090
- add(e, t) {
1091
- this.formats[e.toLowerCase().trim()] = t;
1092
- }
1093
- addCached(e, t) {
1094
- this.formats[e.toLowerCase().trim()] = Me(t);
1095
- }
1096
- format(e, t, n, r = {}) {
1097
- let i = t.split(this.formatSeparator);
1098
- if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((e) => e.indexOf(")") > -1)) {
1099
- let e = i.findIndex((e) => e.indexOf(")") > -1);
1100
- i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
1101
- }
1102
- return i.reduce((e, t) => {
1103
- let { formatName: i, formatOptions: a } = je(t);
1104
- if (this.formats[i]) {
1105
- let t = e;
1106
- try {
1107
- let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
1108
- t = this.formats[i](e, s, {
1109
- ...a,
1110
- ...r,
1111
- ...o
1112
- });
1113
- } catch (e) {
1114
- this.logger.warn(e);
1115
- }
1116
- return t;
1117
- } else this.logger.warn(`there was no format function for ${i}`);
1118
- return e;
1119
- }, e);
1120
- }
1121
- }, Fe = (e, t) => {
1122
- e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
1123
- }, Ie = class extends B {
1124
- constructor(e, t, n, r = {}) {
1125
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = z.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);
1126
- }
1127
- queueLoad(e, t, n, r) {
1128
- let i = {}, a = {}, o = {}, s = {};
1129
- return e.forEach((e) => {
1130
- let r = !0;
1131
- t.forEach((t) => {
1132
- let o = `${e}|${t}`;
1133
- !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)));
1134
- }), r || (o[e] = !0);
1135
- }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
1136
- pending: a,
1137
- pendingCount: Object.keys(a).length,
1138
- loaded: {},
1139
- errors: [],
1140
- callback: r
1141
- }), {
1142
- toLoad: Object.keys(i),
1143
- pending: Object.keys(a),
1144
- toLoadLanguages: Object.keys(o),
1145
- toLoadNamespaces: Object.keys(s)
1146
- };
1147
- }
1148
- loaded(e, t, n) {
1149
- let r = e.split("|"), i = r[0], a = r[1];
1150
- 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);
1151
- let o = {};
1152
- this.queue.forEach((n) => {
1153
- oe(n.loaded, [i], a), Fe(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
1154
- o[e] || (o[e] = {});
1155
- let t = n.loaded[e];
1156
- t.length && t.forEach((t) => {
1157
- o[e][t] === void 0 && (o[e][t] = !0);
1158
- });
1159
- }), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
1160
- }), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
1161
- }
1162
- read(e, t, n, r = 0, i = this.retryTimeout, a) {
1163
- if (!e.length) return a(null, {});
1164
- if (this.readingCalls >= this.maxParallelReads) {
1165
- this.waitingReads.push({
1166
- lng: e,
1167
- ns: t,
1168
- fcName: n,
1169
- tried: r,
1170
- wait: i,
1171
- callback: a
1172
- });
1173
- return;
1174
- }
1175
- this.readingCalls++;
1176
- let o = (o, s) => {
1177
- if (this.readingCalls--, this.waitingReads.length > 0) {
1178
- let e = this.waitingReads.shift();
1179
- this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
1180
- }
1181
- if (o && s && r < this.maxRetries) {
1182
- setTimeout(() => {
1183
- this.read.call(this, e, t, n, r + 1, i * 2, a);
1184
- }, i);
1185
- return;
1186
- }
1187
- a(o, s);
1188
- }, s = this.backend[n].bind(this.backend);
1189
- if (s.length === 2) {
1190
- try {
1191
- let n = s(e, t);
1192
- n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
1193
- } catch (e) {
1194
- o(e);
1195
- }
1196
- return;
1197
- }
1198
- return s(e, t, o);
1199
- }
1200
- prepareLoading(e, t, n = {}, r) {
1201
- if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), r && r();
1202
- N(e) && (e = this.languageUtils.toResolveHierarchy(e)), N(t) && (t = [t]);
1203
- let i = this.queueLoad(e, t, n, r);
1204
- if (!i.toLoad.length) return i.pending.length || r(), null;
1205
- i.toLoad.forEach((e) => {
1206
- this.loadOne(e);
1207
- });
1208
- }
1209
- load(e, t, n) {
1210
- this.prepareLoading(e, t, {}, n);
1211
- }
1212
- reload(e, t, n) {
1213
- this.prepareLoading(e, t, { reload: !0 }, n);
1214
- }
1215
- loadOne(e, t = "") {
1216
- let n = e.split("|"), r = n[0], i = n[1];
1217
- this.read(r, i, "read", void 0, void 0, (n, a) => {
1218
- 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);
1219
- });
1220
- }
1221
- saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
1222
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
1223
- 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!!!");
1224
- return;
1225
- }
1226
- if (!(n == null || n === "")) {
1227
- if (this.backend?.create) {
1228
- let s = {
1229
- ...a,
1230
- isUpdate: i
1231
- }, c = this.backend.create.bind(this.backend);
1232
- if (c.length < 6) try {
1233
- let i;
1234
- 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);
1235
- } catch (e) {
1236
- o(e);
1237
- }
1238
- else c(e, t, n, r, o, s);
1239
- }
1240
- !e || !e[0] || this.store.addResource(e[0], t, n, r);
1241
- }
1242
- }
1243
- }, Le = () => ({
1244
- debug: !1,
1245
- initAsync: !0,
1246
- ns: ["translation"],
1247
- defaultNS: ["translation"],
1248
- fallbackLng: ["dev"],
1249
- fallbackNS: !1,
1250
- supportedLngs: !1,
1251
- nonExplicitSupportedLngs: !1,
1252
- load: "all",
1253
- preload: !1,
1254
- simplifyPluralSuffix: !0,
1255
- keySeparator: ".",
1256
- nsSeparator: ":",
1257
- pluralSeparator: "_",
1258
- contextSeparator: "_",
1259
- partialBundledLanguages: !1,
1260
- saveMissing: !1,
1261
- updateMissing: !1,
1262
- saveMissingTo: "fallback",
1263
- saveMissingPlurals: !0,
1264
- missingKeyHandler: !1,
1265
- missingInterpolationHandler: !1,
1266
- postProcess: !1,
1267
- postProcessPassResolved: !1,
1268
- returnNull: !1,
1269
- returnEmptyString: !0,
1270
- returnObjects: !1,
1271
- joinArrays: !1,
1272
- returnedObjectHandler: !1,
1273
- parseMissingKeyHandler: !1,
1274
- appendNamespaceToMissingKey: !1,
1275
- appendNamespaceToCIMode: !1,
1276
- overloadTranslationOptionHandler: (e) => {
1277
- let t = {};
1278
- if (typeof e[1] == "object" && (t = e[1]), N(e[1]) && (t.defaultValue = e[1]), N(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
1279
- let n = e[3] || e[2];
1280
- Object.keys(n).forEach((e) => {
1281
- t[e] = n[e];
1282
- });
1283
- }
1284
- return t;
1285
- },
1286
- interpolation: {
1287
- escapeValue: !0,
1288
- format: (e) => e,
1289
- prefix: "{{",
1290
- suffix: "}}",
1291
- formatSeparator: ",",
1292
- unescapePrefix: "-",
1293
- nestingPrefix: "$t(",
1294
- nestingSuffix: ")",
1295
- nestingOptionsSeparator: ",",
1296
- maxReplaces: 1e3,
1297
- skipOnVariables: !0
1298
- },
1299
- cacheInBuiltFormats: !0
1300
- }), Re = (e) => (N(e.ns) && (e.ns = [e.ns]), N(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), N(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), H = () => {}, ze = (e) => {
1301
- Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
1302
- typeof e[t] == "function" && (e[t] = e[t].bind(e));
1303
- });
1304
- }, Be = "__i18next_supportNoticeShown", Ve = () => !!(typeof globalThis < "u" && globalThis[Be] || typeof process < "u" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE || typeof process < "u" && process.env), He = () => {
1305
- typeof globalThis < "u" && (globalThis[Be] = !0);
1306
- }, Ue = (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)), U = class e extends B {
1307
- constructor(e = {}, t) {
1308
- if (super(), this.options = Re(e), this.services = {}, this.logger = z, this.modules = { external: [] }, ze(this), t && !this.isInitialized && !e.isClone) {
1309
- if (!this.options.initAsync) return this.init(e, t), this;
1310
- setTimeout(() => {
1311
- this.init(e, t);
1312
- }, 0);
1313
- }
1314
- }
1315
- init(e = {}, t) {
1316
- this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (N(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
1317
- let n = Le();
1318
- this.options = {
1319
- ...n,
1320
- ...this.options,
1321
- ...Re(e)
1322
- }, this.options.interpolation = {
1323
- ...n.interpolation,
1324
- ...this.options.interpolation
1325
- }, 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 && !Ue(this) && !Ve() && (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 💙"), He());
1326
- let r = (e) => e ? typeof e == "function" ? new e() : e : null;
1327
- if (!this.options.isClone) {
1328
- this.modules.logger ? z.init(r(this.modules.logger), this.options) : z.init(null, this.options);
1329
- let e;
1330
- e = this.modules.formatter ? this.modules.formatter : Pe;
1331
- let t = new we(this.options);
1332
- this.store = new _e(this.options.resources, this.options);
1333
- let i = this.services;
1334
- i.logger = z, i.resourceStore = this.store, i.languageUtils = t, i.pluralResolver = new De(t, {
1335
- prepend: this.options.pluralSeparator,
1336
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1337
- }), 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 Ae(this.options), i.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, i.backendConnector = new Ie(r(this.modules.backend), i.resourceStore, i, this.options), i.backendConnector.on("*", (e, ...t) => {
1338
- this.emit(e, ...t);
1339
- }), 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 Ce(this.services, this.options), this.translator.on("*", (e, ...t) => {
1340
- this.emit(e, ...t);
1341
- }), this.modules.external.forEach((e) => {
1342
- e.init && e.init(this);
1343
- });
1344
- }
1345
- if (this.format = this.options.interpolation.format, t ||= H, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1346
- let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1347
- e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
1348
- }
1349
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), [
1350
- "getResource",
1351
- "hasResourceBundle",
1352
- "getResourceBundle",
1353
- "getDataByLanguage"
1354
- ].forEach((e) => {
1355
- this[e] = (...t) => this.store[e](...t);
1356
- }), [
1357
- "addResource",
1358
- "addResources",
1359
- "addResourceBundle",
1360
- "removeResourceBundle"
1361
- ].forEach((e) => {
1362
- this[e] = (...t) => (this.store[e](...t), this);
1363
- });
1364
- let i = P(), a = () => {
1365
- let e = (e, n) => {
1366
- 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);
1367
- };
1368
- if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
1369
- this.changeLanguage(this.options.lng, e);
1370
- };
1371
- return this.options.resources || !this.options.initAsync ? a() : setTimeout(a, 0), i;
1372
- }
1373
- loadResources(e, t = H) {
1374
- let n = t, r = N(e) ? e : this.language;
1375
- if (typeof e == "function" && (n = e), !this.options.resources || this.options.partialBundledLanguages) {
1376
- if (r?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return n();
1377
- let e = [], t = (t) => {
1378
- t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
1379
- t !== "cimode" && e.indexOf(t) < 0 && e.push(t);
1380
- });
1381
- };
1382
- 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) => {
1383
- !e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), n(e);
1384
- });
1385
- } else n(null);
1386
- }
1387
- reloadResources(e, t, n) {
1388
- let r = P();
1389
- 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 ||= H, this.services.backendConnector.reload(e, t, (e) => {
1390
- r.resolve(), n(e);
1391
- }), r;
1392
- }
1393
- use(e) {
1394
- if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1395
- if (!e.type) throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1396
- 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" && ve.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1397
- }
1398
- setResolvedLanguage(e) {
1399
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
1400
- for (let e = 0; e < this.languages.length; e++) {
1401
- let t = this.languages[e];
1402
- if (!(["cimode", "dev"].indexOf(t) > -1) && this.store.hasLanguageSomeTranslations(t)) {
1403
- this.resolvedLanguage = t;
1404
- break;
1405
- }
1406
- }
1407
- !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1408
- }
1409
- }
1410
- changeLanguage(e, t) {
1411
- this.isLanguageChangingTo = e;
1412
- let n = P();
1413
- this.emit("languageChanging", e);
1414
- let r = (e) => {
1415
- this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
1416
- }, i = (i, a) => {
1417
- 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));
1418
- }, a = (t) => {
1419
- !e && !t && this.services.languageDetector && (t = []);
1420
- let n = N(t) ? t : t && t[0], a = this.store.hasLanguageSomeTranslations(n) ? n : this.services.languageUtils.getBestMatchFromCodes(N(t) ? [t] : t);
1421
- a && (this.language || r(a), this.translator.language || this.translator.changeLanguage(a), this.services.languageDetector?.cacheUserLanguage?.(a)), this.loadResources(a, (e) => {
1422
- i(e, a);
1423
- });
1424
- };
1425
- 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;
1426
- }
1427
- getFixedT(e, t, n) {
1428
- let r = (e, t, ...i) => {
1429
- let a;
1430
- 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);
1431
- let o = {
1432
- ...this.options,
1433
- ...a
1434
- };
1435
- typeof a.keyPrefix == "function" && (a.keyPrefix = V(a.keyPrefix, o));
1436
- let s = this.options.keySeparator || ".", c;
1437
- return a.keyPrefix && Array.isArray(e) ? c = e.map((e) => (typeof e == "function" && (e = V(e, o)), `${a.keyPrefix}${s}${e}`)) : (typeof e == "function" && (e = V(e, o)), c = a.keyPrefix ? `${a.keyPrefix}${s}${e}` : e), this.t(c, a);
1438
- };
1439
- return N(e) ? r.lng = e : r.lngs = e, r.ns = t, r.keyPrefix = n, r;
1440
- }
1441
- t(...e) {
1442
- return this.translator?.translate(...e);
1443
- }
1444
- exists(...e) {
1445
- return this.translator?.exists(...e);
1446
- }
1447
- setDefaultNamespace(e) {
1448
- this.options.defaultNS = e;
1449
- }
1450
- hasLoadedNamespace(e, t = {}) {
1451
- if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1452
- if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1453
- let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
1454
- if (n.toLowerCase() === "cimode") return !0;
1455
- let a = (e, t) => {
1456
- let n = this.services.backendConnector.state[`${e}|${t}`];
1457
- return n === -1 || n === 0 || n === 2;
1458
- };
1459
- if (t.precheck) {
1460
- let e = t.precheck(this, a);
1461
- if (e !== void 0) return e;
1462
- }
1463
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!r || a(i, e)));
1464
- }
1465
- loadNamespaces(e, t) {
1466
- let n = P();
1467
- return this.options.ns ? (N(e) && (e = [e]), e.forEach((e) => {
1468
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
1469
- }), this.loadResources((e) => {
1470
- n.resolve(), t && t(e);
1471
- }), n) : (t && t(), Promise.resolve());
1472
- }
1473
- loadLanguages(e, t) {
1474
- let n = P();
1475
- N(e) && (e = [e]);
1476
- let r = this.options.preload || [], i = e.filter((e) => r.indexOf(e) < 0 && this.services.languageUtils.isSupportedCode(e));
1477
- return i.length ? (this.options.preload = r.concat(i), this.loadResources((e) => {
1478
- n.resolve(), t && t(e);
1479
- }), n) : (t && t(), Promise.resolve());
1480
- }
1481
- dir(e) {
1482
- if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
1483
- try {
1484
- let t = new Intl.Locale(e);
1485
- if (t && t.getTextInfo) {
1486
- let e = t.getTextInfo();
1487
- if (e && e.direction) return e.direction;
1488
- }
1489
- } catch {}
1490
- 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(Le());
1491
- return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1492
- }
1493
- static createInstance(t = {}, n) {
1494
- let r = new e(t, n);
1495
- return r.createInstance = e.createInstance, r;
1496
- }
1497
- cloneInstance(t = {}, n = H) {
1498
- let r = t.forkResourceStore;
1499
- r && delete t.forkResourceStore;
1500
- let i = {
1501
- ...this.options,
1502
- ...t,
1503
- isClone: !0
1504
- }, a = new e(i);
1505
- if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
1506
- "store",
1507
- "services",
1508
- "language"
1509
- ].forEach((e) => {
1510
- a[e] = this[e];
1511
- }), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new _e(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) {
1512
- let e = {
1513
- ...Le().interpolation,
1514
- ...this.options.interpolation,
1515
- ...t.interpolation
1516
- }, n = {
1517
- ...i,
1518
- interpolation: e
1519
- };
1520
- a.services.interpolator = new Ae(n);
1521
- }
1522
- return a.translator = new Ce(a.services, i), a.translator.on("*", (e, ...t) => {
1523
- a.emit(e, ...t);
1524
- }), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
1525
- }
1526
- toJSON() {
1527
- return {
1528
- options: this.options,
1529
- store: this.store,
1530
- language: this.language,
1531
- languages: this.languages,
1532
- resolvedLanguage: this.resolvedLanguage
1533
- };
1534
- }
1535
- }.createInstance();
1536
- //#endregion
1537
- //#region ../../lib-react/translator/dist/index.js
1538
- U.createInstance, U.dir, U.init, U.loadResources, U.reloadResources, U.use, U.changeLanguage, U.getFixedT, U.t, U.exists, U.setDefaultNamespace, U.hasLoadedNamespace, U.loadNamespaces, U.loadLanguages, U.init({
1539
- fallbackLng: "en",
1540
- lng: "en",
1541
- debug: !0,
1542
- resources: {
1543
- en: j,
1544
- es: M
1545
- }
1546
- });
1547
- var We = {
1548
- translator: {
1549
- ...U,
1550
- t: (e, t) => {
1551
- let { lng: n } = t;
1552
- switch (n) {
1553
- case "en_US":
1554
- case "en-US":
1555
- t.lng = "en";
1556
- break;
1557
- case "es_ES":
1558
- case "es-ES":
1559
- case "es_MX":
1560
- case "es-MX":
1561
- t.lng = "es";
1562
- break;
1563
- default: break;
1564
- }
1565
- return U.t(e, {
1566
- lng: n,
1567
- ...t
1568
- });
1569
- }
1570
- },
1571
- languageOptions: [{
1572
- value: "en_US",
1573
- label: "English (US)"
1574
- }, {
1575
- value: "es_ES",
1576
- label: "Spanish"
1577
- }]
1578
- };
1579
- //#endregion
1580
- //#region ../../lib-react/correct-answer-toggle/dist/index.js
1581
- function W(e) {
1582
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
1583
- }
1584
- function Ge(e, t) {
1585
- return !e || W(e) ? e : W(e.default) ? e.default : t && W(e[t]) ? e[t] : t && W(e[t]?.default) ? e[t].default : e;
1586
- }
1587
- var Ke = Ge(s, "Readable") || Ge(Ye.Readable, "Readable"), qe = m, Je = qe.default, Ye = Je && typeof Je == "object" ? Je : qe, { translator: G } = We, Xe = {
1588
- WebkitTouchCallout: "none",
1589
- WebkitUserSelect: "none",
1590
- KhtmlUserSelect: "none",
1591
- MozUserSelect: "none",
1592
- msUserSelect: "none",
1593
- userSelect: "none"
1594
- }, Ze = _("div")(() => ({
1595
- width: "100%",
1596
- cursor: "pointer"
1597
- })), Qe = _("div")(() => ({
1598
- margin: "0 auto",
1599
- textAlign: "center",
1600
- display: "flex"
1601
- })), $e = _("div")(() => ({
1602
- width: "fit-content",
1603
- minWidth: "140px",
1604
- alignSelf: "center",
1605
- verticalAlign: "middle",
1606
- color: `var(--correct-answer-toggle-label-color, ${t.text()})`,
1607
- fontWeight: "normal",
1608
- ...Xe
1609
- })), et = _("div")(() => ({
1610
- position: "absolute",
1611
- width: "25px",
1612
- "&.enter": { opacity: "0" },
1613
- "&.enter-active": {
1614
- opacity: "1",
1615
- transition: "opacity 0.3s ease-in"
1616
- },
1617
- "&.exit": { opacity: "1" },
1618
- "&.exit-active": {
1619
- opacity: "0",
1620
- transition: "opacity 0.3s ease-in"
1621
- }
1622
- })), tt = _("div")(() => ({
1623
- width: "25px",
1624
- marginRight: "5px",
1625
- display: "flex",
1626
- alignItems: "center"
1627
- })), nt = class e extends v.Component {
1628
- static propTypes = {
1629
- onToggle: C.default.func,
1630
- toggled: C.default.bool,
1631
- show: C.default.bool,
1632
- hideMessage: C.default.string,
1633
- showMessage: C.default.string,
1634
- className: C.default.string,
1635
- language: C.default.string
1636
- };
1637
- static defaultProps = {
1638
- showMessage: "Show correct answer",
1639
- hideMessage: "Hide correct answer",
1640
- show: !1,
1641
- toggled: !1
1642
- };
1643
- constructor(t) {
1644
- super(t), this.state = { show: t.show }, this.openIconRef = v.createRef(), this.closedIconRef = v.createRef(), e.defaultProps = {
1645
- ...e.defaultProps,
1646
- showMessage: G.t("common:showCorrectAnswer", { lng: t.language }),
1647
- hideMessage: G.t("common:hideCorrectAnswer", { lng: t.language })
1648
- };
1649
- }
1650
- onClick() {
1651
- this.props.onToggle(!this.props.toggled);
1652
- }
1653
- onTouch(e) {
1654
- e.preventDefault(), this.props.onToggle(!this.props.toggled);
1655
- }
1656
- UNSAFE_componentWillReceiveProps(t) {
1657
- this.setState({ show: t.show }), t.language !== this.props?.language && (e.defaultProps = {
1658
- ...e.defaultProps,
1659
- showMessage: G.t("common:showCorrectAnswer", { lng: t.language }),
1660
- hideMessage: G.t("common:hideCorrectAnswer", { lng: t.language })
1661
- });
1662
- }
1663
- render() {
1664
- let { className: e, toggled: t, hideMessage: n, showMessage: r } = this.props;
1665
- return /* @__PURE__ */ x(Ze, {
1666
- className: e,
1667
- children: /* @__PURE__ */ x(A, {
1668
- show: this.state.show,
1669
- children: /* @__PURE__ */ S(Qe, {
1670
- onClick: this.onClick.bind(this),
1671
- onTouchEnd: this.onTouch.bind(this),
1672
- children: [/* @__PURE__ */ S(tt, { children: [/* @__PURE__ */ x(i, {
1673
- nodeRef: this.openIconRef,
1674
- timeout: 400,
1675
- in: t,
1676
- exit: !t,
1677
- classNames: {
1678
- enter: "enter",
1679
- enterActive: "enter-active",
1680
- exit: "exit",
1681
- exitActive: "exit-active"
1682
- },
1683
- children: /* @__PURE__ */ x(et, {
1684
- ref: this.openIconRef,
1685
- children: /* @__PURE__ */ x(D, { open: t }, "correct-open")
1686
- })
1687
- }), /* @__PURE__ */ x(i, {
1688
- nodeRef: this.closedIconRef,
1689
- timeout: 5e3,
1690
- in: !t,
1691
- exit: t,
1692
- classNames: {
1693
- enter: "enter",
1694
- enterActive: "enter-active",
1695
- exit: "exit",
1696
- exitActive: "exit-active"
1697
- },
1698
- children: /* @__PURE__ */ x(et, {
1699
- ref: this.closedIconRef,
1700
- children: /* @__PURE__ */ x(D, { open: t }, "correct-closed")
1701
- })
1702
- })] }), /* @__PURE__ */ x(Ke, {
1703
- false: !0,
1704
- children: /* @__PURE__ */ x($e, {
1705
- "aria-hidden": !this.state.show,
1706
- children: t ? n : r
1707
- })
1708
- })]
1709
- })
1710
- })
1711
- });
1712
- }
1713
- }, rt = _(f)({
1714
- width: "33px",
1715
- height: "33px",
1716
- "& svg": {
1717
- position: "absolute",
1718
- display: "inline-block",
1719
- width: "33px",
1720
- height: "33px",
1721
- verticalAlign: "middle",
1722
- "& hide": { display: "none" }
1723
- }
1724
- }), it = _("svg")({
1725
- "& .incorrect-fill": { fill: `var(--feedback-incorrect-bg-color, ${t.incorrect()})` },
1726
- "& .correct-fill": { fill: `var(--feedback-correct-bg-color, ${t.correct()})` }
1727
- }), at = _("div")({
1728
- position: "relative",
1729
- "&.feedback-tick-enter": {
1730
- opacity: "0",
1731
- left: "-50px"
1732
- },
1733
- "&.feedback-tick-enter-active": {
1734
- opacity: "1",
1735
- left: "0px",
1736
- transition: "left 500ms ease-in 200ms, opacity 500ms linear 200ms"
1737
- },
1738
- "&.feedback-tick-exit": {
1739
- opacity: "1",
1740
- left: "0px"
1741
- },
1742
- "&.feedback-tick-exit-active": {
1743
- opacity: "0",
1744
- left: "-50px",
1745
- transition: "left 300ms ease-in, opacity 300ms"
1746
- }
1747
- }), ot = class extends v.Component {
1748
- static propTypes = { correctness: C.default.string };
1749
- constructor(e) {
1750
- super(e), this.nodeRef = v.createRef();
1751
- }
1752
- getIncorrectIcon = () => /* @__PURE__ */ x(it, {
1753
- preserveAspectRatio: "xMinYMin meet",
1754
- x: "0px",
1755
- y: "0px",
1756
- viewBox: "0 0 44 40",
1757
- style: { enableBackground: "new 0 0 44 40" },
1758
- children: /* @__PURE__ */ S("g", { children: [/* @__PURE__ */ x("rect", {
1759
- x: "11",
1760
- y: "17.3",
1761
- transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.852 19.2507)",
1762
- className: "incorrect-fill",
1763
- width: "16.6",
1764
- height: "3.7"
1765
- }), /* @__PURE__ */ x("rect", {
1766
- x: "17.4",
1767
- y: "10.7",
1768
- transform: "matrix(0.7071 -0.7071 0.7071 0.7071 -7.8175 19.209)",
1769
- className: "incorrect-fill",
1770
- width: "3.7",
1771
- height: "16.6"
1772
- })] })
1773
- }, "1");
1774
- getCorrectIcon = () => /* @__PURE__ */ x(it, {
1775
- preserveAspectRatio: "xMinYMin meet",
1776
- version: "1.1",
1777
- x: "0px",
1778
- y: "0px",
1779
- viewBox: "0 0 44 40",
1780
- style: { enableBackground: "new 0 0 44 40" },
1781
- children: /* @__PURE__ */ x("polygon", {
1782
- className: "correct-fill",
1783
- points: "19.1,28.6 11.8,22.3 14.4,19.2 17.9,22.1 23.9,11.4 27.5,13.4"
1784
- })
1785
- }, "2");
1786
- render() {
1787
- let { correctness: e } = this.props, t = e === "incorrect" ? this.getIncorrectIcon() : e === "correct" ? this.getCorrectIcon() : null;
1788
- return /* @__PURE__ */ x(rt, { children: /* @__PURE__ */ x(o, { children: e && /* @__PURE__ */ x(i, {
1789
- nodeRef: this.nodeRef,
1790
- classNames: {
1791
- enter: "feedback-tick-enter",
1792
- enterActive: "feedback-tick-enter-active",
1793
- exit: "feedback-tick-exit",
1794
- exitActive: "feedback-tick-exit-active"
1795
- },
1796
- timeout: {
1797
- enter: 700,
1798
- exit: 300
1799
- },
1800
- children: /* @__PURE__ */ x(at, {
1801
- ref: this.nodeRef,
1802
- children: t
1803
- })
1804
- }) }) });
1805
- }
1806
- };
1807
- //#endregion
1808
- //#region src/delivery/choice-input.tsx
1809
- function K(e) {
1810
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
1811
- }
1812
- function q(e, t) {
1813
- return !e || K(e) ? e : K(e.default) ? e.default : t && K(e[t]) ? e[t] : t && K(e[t]?.default) ? e[t].default : e;
1814
- }
1815
- var st = q(a, "PreviewPrompt") || q(dt.PreviewPrompt, "PreviewPrompt"), ct = q(c, "Feedback") || q(dt.Feedback, "Feedback"), lt = m, ut = lt.default, dt = ut && typeof ut == "object" ? ut : lt, J = "multiple-choice-component", ft = _(f)({
1816
- display: "flex",
1817
- alignItems: "center",
1818
- backgroundColor: t.background()
1819
- }), pt = _(f)({
1820
- display: "flex",
1821
- alignItems: "center",
1822
- backgroundColor: t.background(),
1823
- flex: 1,
1824
- "& .MuiFormControlLabel-root": { marginLeft: "-14px" },
1825
- "& label": {
1826
- color: t.text(),
1827
- "& > span": { fontSize: "inherit" },
1828
- "& > .MuiButtonBase-root": { padding: "12px" }
1829
- }
1830
- }), mt = _("span")(({ theme: e }) => ({
1831
- display: "flex",
1832
- alignItems: "center",
1833
- "& > span": { marginLeft: `-${e.spacing(1)}` }
1834
- })), ht = _("span")({
1835
- position: "absolute",
1836
- left: "-10000px",
1837
- top: "auto",
1838
- width: "1px",
1839
- height: "1px",
1840
- overflow: "hidden"
1841
- }), gt = _(l)({
1842
- "& .MuiFormControlLabel-label": {
1843
- color: `${t.text()} !important`,
1844
- backgroundColor: t.background(),
1845
- letterSpacing: "normal"
1846
- },
1847
- "&.Mui-disabled *": { cursor: "not-allowed !important" }
1848
- }), Y = (e, t) => ({ [`&.${J}`]: { color: `var(--choice-input-${e}, ${t}) !important` } }), _t = (e) => {
1849
- let n = (t) => e ? `${e}-${t}` : t;
1850
- return {
1851
- [n("root")]: {
1852
- ...Y("color", t.text()),
1853
- ...e ? {} : { "&:hover": { color: `${t.primaryLight()} !important` } },
1854
- ...e === "correct" ? Y("correct-color", t.text()) : {},
1855
- ...e === "incorrect" ? Y("incorrect-color", t.incorrect()) : {}
1856
- },
1857
- [n("checked")]: {
1858
- ...e === "correct" ? Y("correct-selected-color", t.correct()) : {},
1859
- ...e === "incorrect" ? Y("incorrect-checked", t.incorrect()) : {},
1860
- ...e ? {} : Y("selected-color", t.primary())
1861
- },
1862
- [n("disabled")]: {
1863
- ...Y("disabled-color", t.text()),
1864
- ...e === "correct" ? Y("correct-disabled-color", t.disabled()) : {},
1865
- ...e === "incorrect" ? Y("incorrect-disabled-color", t.disabled()) : {},
1866
- opacity: .6,
1867
- cursor: "not-allowed !important",
1868
- pointerEvents: "initial !important"
1869
- },
1870
- focusVisibleUnchecked: {
1871
- outline: `2px solid ${t.keyBoardFocusIndicator()}`,
1872
- backgroundColor: "transparent"
1873
- },
1874
- focusVisibleChecked: {
1875
- outline: `2px solid ${t.keyBoardFocusIndicator()}`,
1876
- backgroundColor: "transparent"
1877
- }
1878
- };
1879
- }, vt = _(d, { shouldForwardProp: (e) => e !== "correctness" })(({ correctness: e }) => {
1880
- let t = _t(e), n = (t) => e ? `${e}-${t}` : t;
1881
- return {
1882
- [`&.${J}`]: {
1883
- ...t[n("root")],
1884
- "&.Mui-checked": t[n("checked")],
1885
- "&.Mui-disabled": e ? {} : t[n("disabled")]
1886
- },
1887
- "&.Mui-focusVisible": {
1888
- "&:not(.Mui-checked)": t.focusVisibleUnchecked,
1889
- "&.Mui-checked": t.focusVisibleChecked
1890
- }
1891
- };
1892
- }), yt = (e) => {
1893
- let { correctness: t, checked: n, onChange: r, disabled: i, value: a, id: o, onKeyDown: s, inputRef: c } = e;
1894
- return /* @__PURE__ */ x(vt, {
1895
- id: o,
1896
- slotProps: { input: { ref: c } },
1897
- onKeyDown: s,
1898
- disableRipple: !0,
1899
- checked: n,
1900
- onChange: r,
1901
- disabled: i,
1902
- value: a,
1903
- correctness: t,
1904
- className: J
1905
- });
1906
- }, bt = _(h, { shouldForwardProp: (e) => e !== "correctness" })(({ correctness: e }) => {
1907
- let t = _t(e), n = (t) => e ? `${e}-${t}` : t;
1908
- return {
1909
- [`&.${J}`]: {
1910
- ...t[n("root")],
1911
- "&.Mui-checked": t[n("checked")],
1912
- "&.Mui-disabled": e ? {} : t[n("disabled")]
1913
- },
1914
- "&.Mui-focusVisible": {
1915
- "& input": { outline: 0 },
1916
- "&:not(.Mui-checked)": t.focusVisibleUnchecked,
1917
- "&.Mui-checked": t.focusVisibleChecked
1918
- }
1919
- };
1920
- }), xt = (e) => {
1921
- let { correctness: t, checked: n, onChange: r, disabled: i, value: a, id: o, tagName: s, inputRef: c } = e;
1922
- return /* @__PURE__ */ x(bt, {
1923
- id: o,
1924
- slotProps: { input: { ref: c } },
1925
- disableRipple: !0,
1926
- checked: n,
1927
- onChange: r,
1928
- disabled: i,
1929
- value: a,
1930
- correctness: t,
1931
- className: J,
1932
- name: s
1933
- });
1934
- }, St = class extends v.Component {
1935
- static propTypes = {
1936
- choiceMode: C.default.oneOf(["radio", "checkbox"]),
1937
- displayKey: C.default.string,
1938
- checked: C.default.bool.isRequired,
1939
- correctness: C.default.string,
1940
- disabled: C.default.bool.isRequired,
1941
- feedback: C.default.string,
1942
- label: C.default.string.isRequired,
1943
- rationale: C.default.string,
1944
- onChange: C.default.func.isRequired,
1945
- value: C.default.string.isRequired,
1946
- className: C.default.string,
1947
- tagName: C.default.string,
1948
- hideTick: C.default.bool,
1949
- isEvaluateMode: C.default.bool,
1950
- choicesLayout: C.default.oneOf([
1951
- "vertical",
1952
- "grid",
1953
- "horizontal"
1954
- ]),
1955
- isSelectionButtonBelow: C.default.bool
1956
- };
1957
- static defaultProps = {
1958
- rationale: null,
1959
- checked: !1,
1960
- isEvaluateMode: !1
1961
- };
1962
- constructor(e) {
1963
- super(e), this.onToggleChoice = this.onToggleChoice.bind(this), this.choiceId = this.generateChoiceId(), this.descId = `${this.choiceId}-desc`;
1964
- }
1965
- onToggleChoice(e) {
1966
- this.props.onChange(e);
1967
- }
1968
- generateChoiceId() {
1969
- return "choice-" + (Math.random() * 1e4).toFixed();
1970
- }
1971
- handleKeyDown = (e) => {
1972
- let { choiceMode: t } = this.props;
1973
- if (t !== "checkbox") return;
1974
- let n = e.key === "ArrowDown", r = e.key === "ArrowUp";
1975
- if (!n && !r) return;
1976
- e.preventDefault();
1977
- let i = document.getElementById(this.choiceId);
1978
- if (!i) return;
1979
- let a = i.closest("fieldset");
1980
- if (!a) return;
1981
- let o = Array.from(a.querySelectorAll("input[type=\"checkbox\"]")), s = o.findIndex((e) => e === i);
1982
- if (s === -1) return;
1983
- let c = o[n ? s + 1 : s - 1];
1984
- c && c.focus();
1985
- };
1986
- render() {
1987
- let { choiceMode: t, disabled: n, displayKey: r, feedback: i, label: a, correctness: o, className: s, rationale: c, hideTick: l, isEvaluateMode: u, choicesLayout: d, value: f, checked: p, tagName: m, isSelectionButtonBelow: h } = this.props, g = t === "checkbox" ? yt : xt, _ = t === "checkbox" ? "checkbox" : "radio-button", v = {
1988
- ...d === "horizontal" && { [`& .${J}`]: {
1989
- padding: "8px",
1990
- margin: "4px 0 4px 4px"
1991
- } },
1992
- ...h && d !== "grid" && { "& > label": { alignItems: "flex-start" } },
1993
- ...h && d === "grid" && {
1994
- justifyContent: "center",
1995
- "& > label": { alignItems: "center" }
1996
- }
1997
- }, y = typeof a == "string" && (a.includes("<math") || a.includes("\\(") || a.includes("\\[") || a.includes("<img") || a.includes("data-latex") || a.includes("data-raw") || a.includes("<mjx-container")), C = r ? /* @__PURE__ */ x(ht, {
1998
- id: this.descId,
1999
- children: y ? `Pick the answer below, ${r}` : r
2000
- }) : null, w = /* @__PURE__ */ x(b, { children: r && !h ? /* @__PURE__ */ S(ft, {
2001
- component: "span",
2002
- children: [/* @__PURE__ */ S("span", {
2003
- "aria-hidden": "true",
2004
- children: [
2005
- r,
2006
- ".",
2007
- "\xA0"
2008
- ]
2009
- }), /* @__PURE__ */ x(st, {
2010
- className: "prompt-label",
2011
- prompt: a,
2012
- tagName: "span"
2013
- })]
2014
- }) : /* @__PURE__ */ x(st, {
2015
- className: "prompt-label",
2016
- prompt: a,
2017
- tagName: "span"
2018
- }) }), T = {
2019
- disabled: n,
2020
- checked: p,
2021
- correctness: o,
2022
- tagName: m,
2023
- value: f,
2024
- id: this.choiceId,
2025
- onChange: this.onToggleChoice,
2026
- onKeyDown: this.handleKeyDown,
2027
- ...C ? { "aria-describedby": this.descId } : {}
2028
- }, E = h ? /* @__PURE__ */ S(mt, { children: [
2029
- C,
2030
- /* @__PURE__ */ x(g, {
2031
- ...T,
2032
- style: { padding: 0 }
2033
- }),
2034
- /* @__PURE__ */ x("span", {
2035
- "aria-hidden": "true",
2036
- children: r ? `${r}.` : ""
2037
- })
2038
- ] }) : /* @__PURE__ */ S(b, { children: [C, /* @__PURE__ */ x(g, { ...T })] });
2039
- return /* @__PURE__ */ S("div", {
2040
- className: e(s, "corespring-" + _, "choice-input"),
2041
- children: [
2042
- /* @__PURE__ */ S(ft, { children: [!l && u && /* @__PURE__ */ x(ot, { correctness: o }), /* @__PURE__ */ x(pt, {
2043
- className: "checkbox-holder",
2044
- sx: v,
2045
- children: /* @__PURE__ */ x(gt, {
2046
- label: w,
2047
- value: f,
2048
- htmlFor: this.choiceId,
2049
- labelPlacement: h ? "top" : void 0,
2050
- control: E
2051
- })
2052
- })] }),
2053
- c && /* @__PURE__ */ x(st, {
2054
- className: "rationale",
2055
- defaultClassName: "rationale",
2056
- prompt: c
2057
- }),
2058
- /* @__PURE__ */ x(ct, {
2059
- feedback: i,
2060
- correctness: o
2061
- })
2062
- ]
2063
- });
2064
- }
2065
- }, Ct = _(f, { shouldForwardProp: (e) => e !== "noBorder" && e !== "horizontalLayout" })(({ theme: e, noBorder: t, horizontalLayout: n }) => ({
2066
- paddingTop: e.spacing(2.5),
2067
- paddingBottom: `calc(${e.spacing(1)} + 2px)`,
2068
- paddingLeft: `calc(${e.spacing(1)} + 2px)`,
2069
- paddingRight: `calc(${e.spacing(1)} + 2px)`,
2070
- borderBottom: t ? "none" : `1px solid ${e.palette.grey[300]}`,
2071
- ...n && {
2072
- paddingRight: e.spacing(2.5),
2073
- "& label": { marginRight: e.spacing(1) }
2074
- }
2075
- })), wt = class extends v.Component {
2076
- static propTypes = {};
2077
- state = { isHovered: !1 };
2078
- handleMouseEnter = () => {
2079
- let { disabled: e, checked: t } = this.props;
2080
- !e && !t && this.setState({ isHovered: !0 });
2081
- };
2082
- handleMouseLeave = () => {
2083
- this.setState({ isHovered: !1 });
2084
- };
2085
- onChange = (e) => {
2086
- let { disabled: t, onChoiceChanged: n } = this.props;
2087
- t || n(e);
2088
- };
2089
- render() {
2090
- let { choice: e, index: t, choicesLength: n, showCorrect: r, isEvaluateMode: i, choiceMode: a, disabled: o, checked: s, correctness: c, displayKey: l, choicesLayout: u, gridColumns: d, isSelectionButtonBelow: f, selectedAnswerBackgroundColor: p, selectedAnswerStrokeColor: m, selectedAnswerStrokeWidth: h, hoverAnswerBackgroundColor: g, hoverAnswerStrokeColor: _, hoverAnswerStrokeWidth: v, tagName: y } = this.props, { isHovered: b } = this.state, S = "choice" + (t === n - 1 ? " last" : ""), C = !i || r ? "" : e.feedback, w = {
2091
- ...e,
2092
- checked: s,
2093
- choiceMode: a,
2094
- disabled: o,
2095
- feedback: C,
2096
- correctness: c,
2097
- displayKey: l,
2098
- index: t,
2099
- choicesLayout: u,
2100
- gridColumns: d,
2101
- onChange: this.onChange,
2102
- isEvaluateMode: i,
2103
- isSelectionButtonBelow: f,
2104
- selectedAnswerStrokeColor: m,
2105
- selectedAnswerStrokeWidth: h,
2106
- tagName: y
2107
- }, T = (e) => {
2108
- if (!e) return "2px";
2109
- let t = String(e).trim();
2110
- return /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t;
2111
- }, E = m && m !== "initial", D = _ && _ !== "initial", O = "transparent", k = "2px", A = "initial";
2112
- (E || D) && (s && E ? (O = m, k = h) : b && !o && D && (O = _, k = v)), s && p && p !== "initial" ? A = p : b && !o && g && g !== "initial" && (A = g);
2113
- let j = E || D, M = j ? {
2114
- border: `${T(k)} solid ${O}`,
2115
- borderRadius: "8px"
2116
- } : {}, N = t === n - 1 || u !== "vertical" || j, P = u === "horizontal";
2117
- return /* @__PURE__ */ x("div", {
2118
- className: S,
2119
- style: {
2120
- backgroundColor: A === "initial" ? "initial" : A,
2121
- ...M
2122
- },
2123
- onMouseEnter: this.handleMouseEnter,
2124
- onMouseLeave: this.handleMouseLeave,
2125
- children: /* @__PURE__ */ x(Ct, {
2126
- component: "div",
2127
- noBorder: N,
2128
- horizontalLayout: P,
2129
- children: /* @__PURE__ */ x(St, { ...w })
2130
- })
2131
- }, t);
2132
- }
2133
- };
2134
- wt.propTypes = {
2135
- choiceMode: C.default.oneOf(["radio", "checkbox"]),
2136
- choice: C.default.object,
2137
- disabled: C.default.bool.isRequired,
2138
- onChoiceChanged: C.default.func,
2139
- index: C.default.number,
2140
- choicesLength: C.default.number,
2141
- showCorrect: C.default.bool,
2142
- isEvaluateMode: C.default.bool,
2143
- checked: C.default.bool,
2144
- correctness: C.default.string,
2145
- displayKey: C.default.string,
2146
- choicesLayout: C.default.oneOf([
2147
- "vertical",
2148
- "grid",
2149
- "horizontal"
2150
- ]),
2151
- gridColumns: C.default.string,
2152
- selectedAnswerBackgroundColor: C.default.string,
2153
- selectedAnswerStrokeColor: C.default.string,
2154
- selectedAnswerStrokeWidth: C.default.string,
2155
- hoverAnswerBackgroundColor: C.default.string,
2156
- hoverAnswerStrokeColor: C.default.string,
2157
- hoverAnswerStrokeWidth: C.default.string,
2158
- tagName: C.default.string,
2159
- isSelectionButtonBelow: C.default.bool
2160
- };
2161
- //#endregion
2162
- //#region src/delivery/multiple-choice.tsx
2163
- function X(e) {
2164
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
2165
- }
2166
- function Z(e, t) {
2167
- return !e || X(e) ? e : X(e.default) ? e.default : t && X(e[t]) ? e[t] : t && X(e[t]?.default) ? e[t].default : e;
2168
- }
2169
- var Tt = Z(a, "PreviewPrompt") || Z(kt.PreviewPrompt, "PreviewPrompt"), Et = Z(u, "Collapsible") || Z(kt.Collapsible, "Collapsible"), Dt = m, Ot = Dt.default, kt = Ot && typeof Ot == "object" ? Ot : Dt, { translator: Q } = We, At = _(f)({
2170
- color: t.text(),
2171
- backgroundColor: t.background(),
2172
- "& *": { "-webkit-font-smoothing": "antialiased" },
2173
- position: "relative",
2174
- "& legend": { border: "none !important" }
2175
- }), jt = _("h2")(({ theme: e }) => ({
2176
- display: "block",
2177
- fontSize: "inherit",
2178
- margin: "0",
2179
- fontWeight: "normal",
2180
- paddingBottom: e.spacing(2)
2181
- })), Mt = _(f)(({ theme: e }) => ({ marginBottom: e.spacing(2) })), Nt = _(f)({
2182
- display: "flex",
2183
- flexDirection: "row",
2184
- flexWrap: "wrap"
2185
- }), Pt = _(f)({ display: "grid" }), Ft = _("fieldset")({
2186
- border: "0px",
2187
- padding: "0.01em 0 0 0",
2188
- margin: "0px",
2189
- minWidth: "0px"
2190
- }), It = _("h3")({
2191
- position: "absolute",
2192
- left: "-10000px",
2193
- top: "auto",
2194
- width: "1px",
2195
- height: "1px",
2196
- overflow: "hidden"
2197
- }), Lt = _("div")(({ theme: e }) => ({
2198
- fontSize: e.typography.fontSize - 2,
2199
- color: e.palette.error.main,
2200
- paddingTop: e.spacing(1)
2201
- })), Rt = class extends v.Component {
2202
- static propTypes = {
2203
- className: C.default.string,
2204
- mode: C.default.oneOf([
2205
- "gather",
2206
- "view",
2207
- "evaluate"
2208
- ]),
2209
- choiceMode: C.default.oneOf(["radio", "checkbox"]),
2210
- keyMode: C.default.oneOf([
2211
- "numbers",
2212
- "letters",
2213
- "none"
2214
- ]),
2215
- choices: C.default.array,
2216
- partLabel: C.default.string,
2217
- prompt: C.default.string,
2218
- teacherInstructions: C.default.string,
2219
- session: C.default.object,
2220
- disabled: C.default.bool,
2221
- onChoiceChanged: C.default.func,
2222
- responseCorrect: C.default.bool,
2223
- correctResponse: C.default.array,
2224
- choicesLayout: C.default.oneOf([
2225
- "vertical",
2226
- "grid",
2227
- "horizontal"
2228
- ]),
2229
- gridColumns: C.default.string,
2230
- alwaysShowCorrect: C.default.bool,
2231
- animationsDisabled: C.default.bool,
2232
- language: C.default.string,
2233
- selectedAnswerBackgroundColor: C.default.string,
2234
- selectedAnswerStrokeColor: C.default.string,
2235
- selectedAnswerStrokeWidth: C.default.string,
2236
- hoverAnswerBackgroundColor: C.default.string,
2237
- hoverAnswerStrokeColor: C.default.string,
2238
- hoverAnswerStrokeWidth: C.default.string,
2239
- onShowCorrectToggle: C.default.func,
2240
- isSelectionButtonBelow: C.default.bool,
2241
- minSelections: C.default.number,
2242
- maxSelections: C.default.number,
2243
- autoplayAudioEnabled: C.default.bool,
2244
- customAudioButton: {
2245
- playImage: C.default.string,
2246
- pauseImage: C.default.string
2247
- },
2248
- options: C.default.object,
2249
- baseHeadingLevel: C.default.number,
2250
- includeSrHeading: C.default.bool
2251
- };
2252
- constructor(e) {
2253
- super(e), this.state = {
2254
- showCorrect: this.props.options && this.props.alwaysShowCorrect || !1,
2255
- maxSelectionsErrorState: !1
2256
- }, this.onToggle = this.onToggle.bind(this), this.groupName = `mc-group-${Math.random().toString(36).slice(2, 10)}`;
2257
- }
2258
- isSelected(e) {
2259
- let t = this.props.session && this.props.session.value;
2260
- return t && t.indexOf && t.indexOf(e) >= 0;
2261
- }
2262
- handleChange = (e) => {
2263
- let { value: t, checked: n } = e.target, { maxSelections: r, onChoiceChanged: i, session: a } = this.props;
2264
- a.value && a.value.length >= r && (this.setState({ maxSelectionsErrorState: n }), n) || i({
2265
- value: t,
2266
- selected: n,
2267
- selector: "Mouse"
2268
- });
2269
- };
2270
- onToggle = () => {
2271
- this.props.mode === "evaluate" && this.setState({ showCorrect: !this.state.showCorrect }, () => {
2272
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
2273
- });
2274
- };
2275
- UNSAFE_componentWillReceiveProps(e) {
2276
- !e.correctResponse && this.state.showCorrect !== !1 && this.setState({ showCorrect: !1 }, () => {
2277
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
2278
- }), e.options && e.alwaysShowCorrect && this.state.showCorrect !== !0 && this.setState({ showCorrect: !0 }, () => {
2279
- this.props.onShowCorrectToggle && this.props.onShowCorrectToggle();
2280
- });
2281
- }
2282
- indexToSymbol(e) {
2283
- return this.props.keyMode === "numbers" ? `${e + 1}` : this.props.keyMode === "letters" ? String.fromCharCode(97 + e).toUpperCase() : "";
2284
- }
2285
- getCorrectness = (e = {}) => {
2286
- let t = e.correct, n = this.isSelected(e.value);
2287
- if (this.state.showCorrect) return t ? "correct" : void 0;
2288
- if (t) return n ? "correct" : "incorrect";
2289
- if (n) return "incorrect";
2290
- };
2291
- getChecked(e) {
2292
- return this.props.options && this.props.alwaysShowCorrect || this.state.showCorrect && this.props.mode === "evaluate" ? e.correct || !1 : this.isSelected(e.value);
2293
- }
2294
- renderHeading() {
2295
- let { mode: e, choiceMode: t, includeSrHeading: n, baseHeadingLevel: r, partLabel: i } = this.props;
2296
- if (!(!i && n !== !1) || e !== "gather") return null;
2297
- let a = r ? Math.min(6, r) : 2;
2298
- return /* @__PURE__ */ x(It.withComponent(`h${a}`), { children: t === "radio" ? "Multiple Choice Question" : "Multiple Select Question" });
2299
- }
2300
- render() {
2301
- let { mode: t, disabled: n, className: r, choices: i = [], choiceMode: a, gridColumns: o, partLabel: s, prompt: c, responseCorrect: l, teacherInstructions: u, alwaysShowCorrect: d, animationsDisabled: m, language: h, isSelectionButtonBelow: g, minSelections: _, maxSelections: v, autoplayAudioEnabled: y, session: b, customAudioButton: C, options: w, baseHeadingLevel: T } = this.props, { showCorrect: E, maxSelectionsErrorState: D } = this.state, O = t === "evaluate", k = O && !l, A = o > 1 ? { gridTemplateColumns: `repeat(${o}, 1fr)` } : void 0, j = b.value && b.value.length || 0, M = (() => {
2302
- if (!T) return;
2303
- let e = 1;
2304
- return s && (e += 1), Math.min(6, T + e);
2305
- })(), N = (e) => e && M ? p(e, M) : e, P = /* @__PURE__ */ x(Tt, {
2306
- tagName: "div",
2307
- className: "prompt",
2308
- defaultClassName: "teacher-instructions",
2309
- prompt: u
2310
- }), ee = () => _ && v ? _ === v ? Q.t("translation:multipleChoice:minmaxSelections_equal", {
2311
- lng: h,
2312
- minSelections: _
2313
- }) : Q.t("translation:multipleChoice:minmaxSelections_range", {
2314
- lng: h,
2315
- minSelections: _,
2316
- maxSelections: v
2317
- }) : _ ? Q.t("translation:multipleChoice:minSelections", {
2318
- lng: h,
2319
- minSelections: _
2320
- }) : "", te = this.props.choicesLayout === "grid" ? Pt : this.props.choicesLayout === "horizontal" ? Nt : f;
2321
- return /* @__PURE__ */ S(At, {
2322
- id: "main-container",
2323
- className: e(r, "multiple-choice"),
2324
- children: [
2325
- s && /* @__PURE__ */ x(jt, {
2326
- as: T ? `h${Math.min(6, T + 1)}` : "h2",
2327
- children: s
2328
- }),
2329
- this.renderHeading(),
2330
- u && /* @__PURE__ */ x(Mt, { children: m ? P : /* @__PURE__ */ x(Et, {
2331
- labels: {
2332
- hidden: "Show Teacher Instructions",
2333
- visible: "Hide Teacher Instructions"
2334
- },
2335
- children: P
2336
- }) }),
2337
- /* @__PURE__ */ S(Ft, {
2338
- role: a === "radio" ? "radiogroup" : "group",
2339
- children: [
2340
- /* @__PURE__ */ x(Tt, {
2341
- className: "prompt",
2342
- defaultClassName: "prompt",
2343
- prompt: N(c),
2344
- tagName: "legend",
2345
- autoplayAudioEnabled: y,
2346
- customAudioButton: C
2347
- }),
2348
- !(w && d) && /* @__PURE__ */ x(nt, {
2349
- show: k,
2350
- toggled: E,
2351
- onToggle: this.onToggle.bind(this),
2352
- language: h
2353
- }),
2354
- /* @__PURE__ */ x(te, {
2355
- style: A,
2356
- children: i.map((e, t) => /* @__PURE__ */ x(wt, {
2357
- choicesLayout: this.props.choicesLayout,
2358
- selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
2359
- selectedAnswerStrokeColor: this.props.selectedAnswerStrokeColor,
2360
- selectedAnswerStrokeWidth: this.props.selectedAnswerStrokeWidth,
2361
- hoverAnswerBackgroundColor: this.props.hoverAnswerBackgroundColor,
2362
- hoverAnswerStrokeColor: this.props.hoverAnswerStrokeColor,
2363
- hoverAnswerStrokeWidth: this.props.hoverAnswerStrokeWidth,
2364
- gridColumns: o,
2365
- choice: e,
2366
- index: t,
2367
- choicesLength: i.length,
2368
- showCorrect: E,
2369
- isEvaluateMode: O,
2370
- choiceMode: a,
2371
- disabled: n,
2372
- tagName: this.groupName,
2373
- onChoiceChanged: this.handleChange,
2374
- hideTick: e.hideTick,
2375
- checked: this.getChecked(e),
2376
- correctness: O ? this.getCorrectness(e) : void 0,
2377
- displayKey: this.indexToSymbol(t),
2378
- isSelectionButtonBelow: g
2379
- }, `choice-${t}`))
2380
- })
2381
- ]
2382
- }),
2383
- a === "checkbox" && j < _ && /* @__PURE__ */ x(Lt, { children: ee() }),
2384
- a === "checkbox" && D && /* @__PURE__ */ x(Lt, { children: Q.t(`translation:multipleChoice:maxSelections_${v === 1 ? "one" : "other"}`, {
2385
- lng: h,
2386
- maxSelections: v
2387
- }) })
2388
- ]
2389
- });
2390
- }
2391
- };
2392
- Rt.defaultProps = { session: { value: [] } };
2393
- //#endregion
2394
- //#region src/delivery/main.tsx
2395
- function $(e) {
2396
- return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
2397
- }
2398
- function zt(e, t) {
2399
- return !e || $(e) ? e : $(e.default) ? e.default : t && $(e[t]) ? e[t] : t && $(e[t]?.default) ? e[t].default : e;
2400
- }
2401
- var Bt = zt(g, "PreviewLayout") || zt(Ut.PreviewLayout, "PreviewLayout"), Vt = m, Ht = Vt.default, Ut = Ht && typeof Ht == "object" ? Ht : Vt, Wt = class extends v.Component {
2402
- static propTypes = {
2403
- model: C.default.object,
2404
- session: C.default.object,
2405
- options: C.default.object,
2406
- onChoiceChanged: C.default.func,
2407
- onShowCorrectToggle: C.default.func,
2408
- extraCSSRules: C.default.shape({
2409
- names: C.default.arrayOf(C.default.string),
2410
- rules: C.default.string
2411
- }),
2412
- baseHeadingLevel: C.default.number,
2413
- includeSrHeading: C.default.bool
2414
- };
2415
- static defaultProps = {
2416
- model: {},
2417
- session: {}
2418
- };
2419
- render() {
2420
- let { model: e, onChoiceChanged: t, session: n, onShowCorrectToggle: r, options: i, baseHeadingLevel: a, includeSrHeading: o } = this.props, { extraCSSRules: s, fontSizeFactor: c } = e;
2421
- return /* @__PURE__ */ x(Bt, {
2422
- extraCSSRules: s,
2423
- fontSizeFactor: c,
2424
- classes: {},
2425
- children: /* @__PURE__ */ x(Rt, {
2426
- ...e,
2427
- options: i,
2428
- session: n,
2429
- onChoiceChanged: t,
2430
- onShowCorrectToggle: r,
2431
- baseHeadingLevel: a,
2432
- includeSrHeading: o
2433
- })
2434
- });
2435
- }
2436
- };
2437
- //#endregion
2438
- export { Wt as t };
2439
-
2440
- //# sourceMappingURL=main-C4I_9OBk.js.map