@citolab/qti-components 3.0.80 → 3.0.82

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 (94) hide show
  1. package/index.css +2 -0
  2. package/index.d.ts +51 -0
  3. package/index.js +3655 -0
  4. package/index.umd.cjs +503 -0
  5. package/lab/qti-custom-operator/qti-custom-operator-levenshtein.d.ts +11 -0
  6. package/lab/qti-custom-operator/qti-custom-operator-numeric-parse-nl.d.ts +11 -0
  7. package/lab/qti-custom-operator/qti-custom-operator-numeric.d.ts +6 -0
  8. package/lab/qti-custom-operator/qti-custom-operator-remove-spaces.d.ts +6 -0
  9. package/lab/qti-custom-operator/qti-custom-operator-trim.d.ts +6 -0
  10. package/lab/qti-item/qti-item.d.ts +20 -0
  11. package/lab/qti-manual-scoring/qti-manual-scoring.d.ts +15 -0
  12. package/lab/qti-test/index.d.ts +2 -0
  13. package/lab/qti-test/qti-test.d.ts +57 -0
  14. package/lib/qti-assessment-item/qti-assessment-item.d.ts +44 -0
  15. package/lib/qti-choice/qti-choice.d.ts +34 -0
  16. package/lib/qti-choice/qti-hottext/qti-hottext.d.ts +8 -0
  17. package/lib/qti-choice/qti-simple-choice/qti-simple-choice.d.ts +8 -0
  18. package/lib/qti-companion-materials-info/qti-companion-materials-info.d.ts +3 -0
  19. package/lib/qti-feedback/qti-feedback-inline/qti-feedback-inline.d.ts +5 -0
  20. package/lib/qti-feedback/qti-feedback.d.ts +30 -0
  21. package/lib/qti-feedback/qti-modal-feedback/qti-modal-feedback.d.ts +4 -0
  22. package/lib/qti-interaction/qti-associate-interaction/qti-associate-interaction.d.ts +9 -0
  23. package/lib/qti-interaction/qti-associate-interaction/qti-simple-associable-choice.d.ts +5 -0
  24. package/lib/qti-interaction/qti-choice-interaction/qti-choice-interaction.d.ts +10 -0
  25. package/lib/qti-interaction/qti-extended-text-interaction/qti-extended-text-interaction.d.ts +18 -0
  26. package/lib/qti-interaction/qti-gap-match-interaction/qti-gap-match-interaction.d.ts +7 -0
  27. package/lib/qti-interaction/qti-gap-match-interaction/qti-gap-text.d.ts +5 -0
  28. package/lib/qti-interaction/qti-gap-match-interaction/qti-gap.d.ts +4 -0
  29. package/lib/qti-interaction/qti-graphic-associate-interaction/qti-graphic-associate-interaction.d.ts +9 -0
  30. package/lib/qti-interaction/qti-graphic-gap-match-interaction/qti-graphic-gap-match-interaction.d.ts +10 -0
  31. package/lib/qti-interaction/qti-graphic-order-interaction/qti-graphic-order-interaction.d.ts +10 -0
  32. package/lib/qti-interaction/qti-hotspot-choice.d.ts +5 -0
  33. package/lib/qti-interaction/qti-hotspot-interaction/qti-hotspot-interaction.d.ts +8 -0
  34. package/lib/qti-interaction/qti-hottext-interaction/qti-hottext-interaction.d.ts +5 -0
  35. package/lib/qti-interaction/qti-inline-choice-interaction/qti-inline-choice-interaction.d.ts +26 -0
  36. package/lib/qti-interaction/qti-match-interaction/qti-match-interaction.d.ts +7 -0
  37. package/lib/qti-interaction/qti-media-interaction/qti-media-interaction.d.ts +18 -0
  38. package/lib/qti-interaction/qti-order-interaction/qti-order-interaction.d.ts +22 -0
  39. package/lib/qti-interaction/qti-portable-custom-interaction/qti-portable-custom-interaction.d.ts +34 -0
  40. package/lib/qti-interaction/qti-preview-badge.d.ts +1 -0
  41. package/lib/qti-interaction/qti-select-point-interaction/qti-select-point-interaction.d.ts +9 -0
  42. package/lib/qti-interaction/qti-slider-interaction/qti-slider-interaction.d.ts +31 -0
  43. package/lib/qti-interaction/qti-text-entry-interaction/qti-text-entry-interaction.d.ts +33 -0
  44. package/lib/qti-item-body/qti-item-body.d.ts +5 -0
  45. package/lib/qti-prompt/qti-prompt.d.ts +5 -0
  46. package/lib/qti-responseprocessing/index.d.ts +18 -0
  47. package/lib/qti-responseprocessing/qti-expression/qti-and/qti-and.d.ts +7 -0
  48. package/lib/qti-responseprocessing/qti-expression/qti-basevalue/qti-basevalue.d.ts +6 -0
  49. package/lib/qti-responseprocessing/qti-expression/qti-contains/qti-contains.d.ts +6 -0
  50. package/lib/qti-responseprocessing/qti-expression/qti-correct/qti-correct.d.ts +6 -0
  51. package/lib/qti-responseprocessing/qti-expression/qti-expression.d.ts +6 -0
  52. package/lib/qti-responseprocessing/qti-expression/qti-gte/qti-gte.d.ts +6 -0
  53. package/lib/qti-responseprocessing/qti-expression/qti-is-null/qti-is-null.d.ts +6 -0
  54. package/lib/qti-responseprocessing/qti-expression/qti-mapresponse/qti-mapresponse.d.ts +4 -0
  55. package/lib/qti-responseprocessing/qti-expression/qti-match/qti-match.d.ts +4 -0
  56. package/lib/qti-responseprocessing/qti-expression/qti-multiple/qti-multiple.d.ts +4 -0
  57. package/lib/qti-responseprocessing/qti-expression/qti-or/qti-or.d.ts +7 -0
  58. package/lib/qti-responseprocessing/qti-expression/qti-variable/qti-variable.d.ts +6 -0
  59. package/lib/qti-responseprocessing/qti-responseelse/qti-responseelse.d.ts +15 -0
  60. package/lib/qti-responseprocessing/qti-responseelse/qti-responseif/qti-responseelseif/qti-responseelseif.d.ts +4 -0
  61. package/lib/qti-responseprocessing/qti-responseelse/qti-responseif/qti-responseif.d.ts +7 -0
  62. package/lib/qti-responseprocessing/qti-responseprocessing/qti-responseprocessing.d.ts +7 -0
  63. package/lib/qti-responseprocessing/qti-rule/qti-responsecondition/qti-responsecondition.d.ts +5 -0
  64. package/lib/qti-responseprocessing/qti-rule/qti-rule.d.ts +5 -0
  65. package/lib/qti-responseprocessing/qti-rule/qti-setoutcomevalue/qti-setoutcomevalue.d.ts +4 -0
  66. package/lib/qti-rubric-block/qti-content-body.d.ts +4 -0
  67. package/lib/qti-rubric-block/qti-rubric-block.d.ts +15 -0
  68. package/lib/qti-stylesheet/qti-stylesheet.d.ts +7 -0
  69. package/lib/qti-utilities/EventStrings.d.ts +19 -0
  70. package/lib/qti-utilities/EventTypes.d.ts +7 -0
  71. package/lib/qti-utilities/ExpressionResult.d.ts +43 -0
  72. package/lib/qti-utilities/OutcomeVariable.d.ts +8 -0
  73. package/lib/qti-utilities/ResponseVariable.d.ts +28 -0
  74. package/lib/qti-utilities/TemplateStrings.d.ts +3 -0
  75. package/lib/qti-utilities/VariableDeclaration.d.ts +7 -0
  76. package/lib/qti-variabledeclaration/qti-outcomedeclaration/qti-outcomedeclaration.d.ts +5 -0
  77. package/lib/qti-variabledeclaration/qti-responsedeclaration/qti-responsedeclaration.d.ts +9 -0
  78. package/lib/qti-variabledeclaration/qti-variabledeclaration.d.ts +4 -0
  79. package/lib/utilities/choice/choices.d.ts +23 -0
  80. package/lib/utilities/context/context.d.ts +7 -0
  81. package/lib/utilities/decorators/liveQuery.d.ts +10 -0
  82. package/lib/utilities/decorators/watch.d.ts +14 -0
  83. package/lib/utilities/drag-drop/drag-drop-api.d.ts +91 -0
  84. package/lib/utilities/drag-drop/drag-drop-interaction-mixin.d.ts +5 -0
  85. package/lib/utilities/drag-drop/droppables-mixin.d.ts +6 -0
  86. package/lib/utilities/drag-drop/flippables-mixin.d.ts +8 -0
  87. package/lib/utilities/drag-drop/index.d.ts +4 -0
  88. package/lib/utilities/element/qti-element.d.ts +6 -0
  89. package/lib/utilities/hotspots/hotspot.d.ts +2 -0
  90. package/lib/utilities/interaction/interaction.d.ts +14 -0
  91. package/lib/utilities/interaction/interaction.interface.d.ts +8 -0
  92. package/lib/utilities/reset-styles/reset-shadowroot-styles.d.ts +1 -0
  93. package/lib/utilities/scale-to-fit/scale-to-fit.mixin.d.ts +6 -0
  94. package/package.json +1 -4
package/index.js ADDED
@@ -0,0 +1,3655 @@
1
+ import { LitElement as g, html as h, css as _ } from "lit";
2
+ var F = /* @__PURE__ */ ((n) => (n.boolean = "boolean", n.directedPair = "directedPair", n.float = "float", n.integer = "integer", n.string = "string", n.identifier = "identifier", n.pair = "pair", n))(F || {}), Ze = /* @__PURE__ */ ((n) => (n.multiple = "multiple", n.ordered = "ordered", n.single = "single", n))(Ze || {});
3
+ const m = {
4
+ // PK: external event internal response from an interaction the qti-assessment-item
5
+ ON_OUTCOME_CHANGED: "on-outcome-changed",
6
+ // PK: external event internal response from an interaction the qti-assessment-item
7
+ ON_INTERACTION_CHANGED: "on-interaction-changed",
8
+ // ***** INTERNAL EVENTS ******/
9
+ ON_REGISTER_VARIABLE: "on-register-variable",
10
+ ON_REGISTER_FEEDBACK: "on-register-feedback",
11
+ ON_REGISTER_INTERACTION: "on-register-interaction",
12
+ ON_REGISTER_CHOICE: "on-register-choice",
13
+ ON_REGISTER_HOTSPOT: "on-register-hotspot",
14
+ ON_LOOSE_CHOICE: "on-loose-choice",
15
+ // PK: internal response from an interaction the qti-assessment-item
16
+ ON_INTERACTION_RESPONSE: "on-interaction-response",
17
+ // PK: events specific to elements from interactions
18
+ ON_DROPDOWN_SELECTED: "on-dropdown-selected",
19
+ ON_CHOICE_ELEMENT_SELECTED: "choice-element-selected"
20
+ }, Ii = {
21
+ EMPTY: "empty",
22
+ USER: "user",
23
+ FEEDBACK: "feedback",
24
+ EXPECTED: "expected"
25
+ };
26
+ class se {
27
+ constructor({ mapping: e, correctResponse: t, cardinality: s, baseType: i, identifier: r }) {
28
+ this._basetype = F.string, this._mapping = e, this._correctResponse = t, this._cardinality = s, this._basetype = i, this._identifier = r;
29
+ }
30
+ static getCandidateResponse(e) {
31
+ return e[Object.keys(e)[0]][Object.keys(e[Object.keys(e)[0]])[0]];
32
+ }
33
+ get mapping() {
34
+ return this._mapping;
35
+ }
36
+ get correctResponse() {
37
+ return this._correctResponse;
38
+ }
39
+ get cardinality() {
40
+ return this._cardinality;
41
+ }
42
+ get baseType() {
43
+ return this._basetype;
44
+ }
45
+ get identifier() {
46
+ return this._identifier;
47
+ }
48
+ get value() {
49
+ return this._candidateResponse;
50
+ }
51
+ set value(e) {
52
+ this._candidateResponse = e;
53
+ }
54
+ // http://www.imsproject.org/spec/qti/v3p0/impl#h.8mgucf4bmbi6
55
+ set qtiVariable(e) {
56
+ this._qtiVariable = e, this._candidateResponse = se.getCandidateResponse(e);
57
+ }
58
+ get qtiVariable() {
59
+ return this._qtiVariable;
60
+ }
61
+ }
62
+ class Je {
63
+ }
64
+ class $ extends g {
65
+ /** Emits a custom event with more convenient defaults. */
66
+ emit(e, t) {
67
+ const s = new CustomEvent(e, {
68
+ bubbles: !0,
69
+ cancelable: !1,
70
+ composed: !0,
71
+ detail: {},
72
+ ...t
73
+ });
74
+ return this.dispatchEvent(s), s;
75
+ }
76
+ err(e) {
77
+ throw e;
78
+ }
79
+ }
80
+ class $t extends $ {
81
+ constructor() {
82
+ super(), this.variables = [], this.feedbackElements = [], this.interactionElements = [], this.identifier = "", this.addEventListener(m.ON_REGISTER_VARIABLE, this._registerVariable), this.addEventListener(m.ON_REGISTER_FEEDBACK, this.registerFeedbackElement), this.addEventListener(m.ON_REGISTER_INTERACTION, this.registerInteractionElement), this.addEventListener(m.ON_OUTCOME_CHANGED, this.outcomeChanged), this.addEventListener(m.ON_INTERACTION_RESPONSE, this.interactionResponse);
83
+ }
84
+ static get properties() {
85
+ return {
86
+ title: { type: String },
87
+ identifier: { type: String },
88
+ disabled: { type: Boolean },
89
+ readonly: { type: Boolean }
90
+ };
91
+ }
92
+ render() {
93
+ return h`<slot></slot>`;
94
+ }
95
+ updated(e) {
96
+ e.forEach((t, s) => {
97
+ switch (s) {
98
+ case "disabled":
99
+ this.interactionElements.forEach((i) => i.disabled = this.disabled);
100
+ break;
101
+ case "readonly":
102
+ this.interactionElements.forEach((i) => i.readonly = this.readonly);
103
+ break;
104
+ }
105
+ });
106
+ }
107
+ disconnectedCallback() {
108
+ this.removeEventListener(m.ON_REGISTER_VARIABLE, this._registerVariable), this.removeEventListener(m.ON_REGISTER_FEEDBACK, this.registerFeedbackElement), this.removeEventListener(m.ON_REGISTER_INTERACTION, this.registerInteractionElement), this.removeEventListener(m.ON_OUTCOME_CHANGED, this.outcomeChanged), this.removeEventListener(m.ON_INTERACTION_RESPONSE, this.interactionResponse);
109
+ }
110
+ _registerVariable(e) {
111
+ this.variables.push(e.detail);
112
+ }
113
+ showCorrectResponse() {
114
+ const e = this.variables.filter((s) => s.correctResponse), t = {
115
+ item: this.identifier,
116
+ interactions: e.map((s) => ({
117
+ responseIdentifier: s.identifier,
118
+ responses: { base: { identifier: s.correctResponse } }
119
+ }))
120
+ };
121
+ this.responses = t;
122
+ }
123
+ processResponse() {
124
+ if (this.validateResponses()) {
125
+ const e = this.querySelector("qti-response-processing");
126
+ return e ? e.process ? (e.process(), !0) : (console.info("Client side response webcomponents not available"), !1) : (console.info("Client side response processing template not available"), !1);
127
+ } else
128
+ return console.info("Item is not valid, call validateResponses first"), !1;
129
+ }
130
+ // check set response back for interactions
131
+ // We can set the responses as a string or as an object in ResponseFormat
132
+ set responses(e) {
133
+ e && e.interactions.forEach((s) => {
134
+ const i = this.interactionElements.find(
135
+ (a) => a.getAttribute("response-identifier") === s.responseIdentifier
136
+ ), r = this.getResponse(s.responseIdentifier);
137
+ r && (r.qtiVariable = s.responses);
138
+ const o = se.getCandidateResponse(s.responses);
139
+ i.response = o;
140
+ });
141
+ }
142
+ resetInteractions() {
143
+ this.interactionElements.forEach((e) => e.reset());
144
+ }
145
+ // check all interactions contain valid responses
146
+ validateResponses() {
147
+ let e = !0;
148
+ return this.interactionElements.forEach((t) => {
149
+ t.validate() || (e = !1);
150
+ }), e;
151
+ }
152
+ getVariableValue(e) {
153
+ return this.variables.find((t) => t.identifier === e).value;
154
+ }
155
+ getResponse(e) {
156
+ const t = this.variables.find((s) => s.identifier === e);
157
+ if (t instanceof se)
158
+ return t;
159
+ }
160
+ getOutcome(e) {
161
+ const t = this.variables.find((s) => s.identifier === e);
162
+ return t instanceof Je ? t : null;
163
+ }
164
+ registerFeedbackElement(e) {
165
+ e.stopPropagation(), this.feedbackElements.push(e.detail);
166
+ }
167
+ registerInteractionElement(e) {
168
+ e.stopPropagation(), this.interactionElements.push(e.target);
169
+ }
170
+ // interaction has fired an event to save response.
171
+ interactionResponse(e) {
172
+ const t = this.getResponse(e.detail.responseIdentifier);
173
+ t && (t.qtiVariable = e.detail.responses), e.stopImmediatePropagation(), this.dispatchEvent(
174
+ new CustomEvent(m.ON_INTERACTION_CHANGED, {
175
+ bubbles: !0,
176
+ composed: !0,
177
+ detail: {
178
+ item: this.getAttribute("identifier"),
179
+ interaction: {
180
+ responseIdentifier: e.detail.responseIdentifier,
181
+ responses: e.detail.responses
182
+ }
183
+ }
184
+ })
185
+ );
186
+ }
187
+ // checks the attributes of all feedback elements and shows/hides as appropriate.
188
+ outcomeChanged(e) {
189
+ this.feedbackElements.forEach((t) => {
190
+ t.checkShowFeedback(e.detail.outcomeIdentifier, e.detail.value);
191
+ });
192
+ }
193
+ setOutcomeValue(e, t) {
194
+ const s = this.getOutcome(e);
195
+ if (!s) {
196
+ this.err(`Can not set qti-outcome-identifier: ${e}, it is not available`);
197
+ return;
198
+ }
199
+ s.value = t, this.dispatchEvent(
200
+ new CustomEvent(m.ON_OUTCOME_CHANGED, {
201
+ bubbles: !0,
202
+ composed: !0,
203
+ detail: {
204
+ item: this.identifier,
205
+ outcomeIdentifier: e,
206
+ value: t
207
+ }
208
+ })
209
+ );
210
+ }
211
+ }
212
+ customElements.define("qti-assessment-item", $t);
213
+ class qt extends g {
214
+ constructor() {
215
+ super();
216
+ }
217
+ connectedCallback() {
218
+ super.connectedCallback();
219
+ const e = this.closest("qti-assessment-item"), t = this.getAttribute("href"), s = document.createElement("link");
220
+ s.rel = "stylesheet", s.type = "text/css", s.media = "screen", s.href = t, e.appendChild(s), this.styleLink = s;
221
+ }
222
+ disconnectedCallback() {
223
+ const e = this.closest("qti-assessment-item");
224
+ if (this.styleLink && this.styleLink.parentElement === this)
225
+ try {
226
+ e.removeChild(this.styleLink);
227
+ } catch {
228
+ console.log("could not remove stylesheet");
229
+ }
230
+ }
231
+ }
232
+ customElements.define("qti-stylesheet", qt);
233
+ /**
234
+ * @license
235
+ * Copyright 2017 Google LLC
236
+ * SPDX-License-Identifier: BSD-3-Clause
237
+ */
238
+ const T = (n) => (e) => typeof e == "function" ? ((t, s) => (customElements.define(t, s), s))(n, e) : ((t, s) => {
239
+ const { kind: i, elements: r } = s;
240
+ return { kind: i, elements: r, finisher(o) {
241
+ customElements.define(t, o);
242
+ } };
243
+ })(n, e);
244
+ /**
245
+ * @license
246
+ * Copyright 2017 Google LLC
247
+ * SPDX-License-Identifier: BSD-3-Clause
248
+ */
249
+ const Ot = (n, e) => e.kind === "method" && e.descriptor && !("value" in e.descriptor) ? { ...e, finisher(t) {
250
+ t.createProperty(e.key, n);
251
+ } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e.key, initializer() {
252
+ typeof e.initializer == "function" && (this[e.key] = e.initializer.call(this));
253
+ }, finisher(t) {
254
+ t.createProperty(e.key, n);
255
+ } };
256
+ function d(n) {
257
+ return (e, t) => t !== void 0 ? ((s, i, r) => {
258
+ i.constructor.createProperty(r, s);
259
+ })(n, e, t) : Ot(n, e);
260
+ }
261
+ /**
262
+ * @license
263
+ * Copyright 2017 Google LLC
264
+ * SPDX-License-Identifier: BSD-3-Clause
265
+ */
266
+ function Ee(n) {
267
+ return d({ ...n, state: !0 });
268
+ }
269
+ /**
270
+ * @license
271
+ * Copyright 2017 Google LLC
272
+ * SPDX-License-Identifier: BSD-3-Clause
273
+ */
274
+ const wt = ({ finisher: n, descriptor: e }) => (t, s) => {
275
+ var i;
276
+ if (s === void 0) {
277
+ const r = (i = t.originalKey) !== null && i !== void 0 ? i : t.key, o = e != null ? { kind: "method", placement: "prototype", key: r, descriptor: e(t.key) } : { ...t, key: r };
278
+ return n != null && (o.finisher = function(a) {
279
+ n(a, r);
280
+ }), o;
281
+ }
282
+ {
283
+ const r = t.constructor;
284
+ e !== void 0 && Object.defineProperty(t, s, e(s)), n?.(r, s);
285
+ }
286
+ };
287
+ /**
288
+ * @license
289
+ * Copyright 2017 Google LLC
290
+ * SPDX-License-Identifier: BSD-3-Clause
291
+ */
292
+ function pe(n, e) {
293
+ return wt({ descriptor: (t) => {
294
+ const s = { get() {
295
+ var i, r;
296
+ return (r = (i = this.renderRoot) === null || i === void 0 ? void 0 : i.querySelector(n)) !== null && r !== void 0 ? r : null;
297
+ }, enumerable: !0, configurable: !0 };
298
+ if (e) {
299
+ const i = typeof t == "symbol" ? Symbol() : "__" + t;
300
+ s.get = function() {
301
+ var r, o;
302
+ return this[i] === void 0 && (this[i] = (o = (r = this.renderRoot) === null || r === void 0 ? void 0 : r.querySelector(n)) !== null && o !== void 0 ? o : null), this[i];
303
+ };
304
+ }
305
+ return s;
306
+ } });
307
+ }
308
+ /**
309
+ * @license
310
+ * Copyright 2021 Google LLC
311
+ * SPDX-License-Identifier: BSD-3-Clause
312
+ */
313
+ var be;
314
+ ((be = window.HTMLSlotElement) === null || be === void 0 ? void 0 : be.prototype.assignedElements) != null;
315
+ var St = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, It = (n, e, t, s) => {
316
+ for (var i = s > 1 ? void 0 : s ? Rt(e, t) : e, r = n.length - 1, o; r >= 0; r--)
317
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
318
+ return s && i && St(e, t, i), i;
319
+ };
320
+ let ye = class extends g {
321
+ render() {
322
+ return h`
323
+ <slot name="qti-rubric-block"></slot>
324
+ <slot></slot>`;
325
+ }
326
+ };
327
+ ye.styles = _`
328
+ :host {
329
+ display: block;
330
+ }
331
+ `;
332
+ ye = It([
333
+ T("qti-item-body")
334
+ ], ye);
335
+ class Nt extends g {
336
+ render() {
337
+ return h` <slot></slot> `;
338
+ }
339
+ connectedCallback() {
340
+ this.parentElement.tagName.endsWith("INTERACTION") && this.setAttribute("slot", "prompt");
341
+ }
342
+ }
343
+ customElements.define("qti-prompt", Nt);
344
+ /**
345
+ * @license
346
+ * Copyright 2017 Google LLC
347
+ * SPDX-License-Identifier: BSD-3-Clause
348
+ */
349
+ var ve;
350
+ const ce = window, Y = ce.trustedTypes, He = Y ? Y.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, D = `lit$${(Math.random() + "").slice(9)}$`, et = "?" + D, Tt = `<${et}>`, G = document, he = (n = "") => G.createComment(n), ie = (n) => n === null || typeof n != "object" && typeof n != "function", tt = Array.isArray, Pt = (n) => tt(n) || typeof n?.[Symbol.iterator] == "function", J = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ue = /-->/g, Fe = />/g, U = RegExp(`>|[
351
+ \f\r](?:([^\\s"'>=/]+)([
352
+ \f\r]*=[
353
+ \f\r]*(?:[^
354
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Qe = /'/g, je = /"/g, st = /^(?:script|style|textarea|title)$/i, kt = (n) => (e, ...t) => ({ _$litType$: n, strings: e, values: t }), Dt = kt(1), ne = Symbol.for("lit-noChange"), v = Symbol.for("lit-nothing"), Be = /* @__PURE__ */ new WeakMap(), B = G.createTreeWalker(G, 129, null, !1), Mt = (n, e) => {
355
+ const t = n.length - 1, s = [];
356
+ let i, r = e === 2 ? "<svg>" : "", o = J;
357
+ for (let c = 0; c < t; c++) {
358
+ const l = n[c];
359
+ let f, p, u = -1, y = 0;
360
+ for (; y < l.length && (o.lastIndex = y, p = o.exec(l), p !== null); )
361
+ y = o.lastIndex, o === J ? p[1] === "!--" ? o = Ue : p[1] !== void 0 ? o = Fe : p[2] !== void 0 ? (st.test(p[2]) && (i = RegExp("</" + p[2], "g")), o = U) : p[3] !== void 0 && (o = U) : o === U ? p[0] === ">" ? (o = i ?? J, u = -1) : p[1] === void 0 ? u = -2 : (u = o.lastIndex - p[2].length, f = p[1], o = p[3] === void 0 ? U : p[3] === '"' ? je : Qe) : o === je || o === Qe ? o = U : o === Ue || o === Fe ? o = J : (o = U, i = void 0);
362
+ const C = o === U && n[c + 1].startsWith("/>") ? " " : "";
363
+ r += o === J ? l + Tt : u >= 0 ? (s.push(f), l.slice(0, u) + "$lit$" + l.slice(u) + D + C) : l + D + (u === -2 ? (s.push(void 0), c) : C);
364
+ }
365
+ const a = r + (n[t] || "<?>") + (e === 2 ? "</svg>" : "");
366
+ if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
367
+ throw Error("invalid template strings array");
368
+ return [He !== void 0 ? He.createHTML(a) : a, s];
369
+ };
370
+ class re {
371
+ constructor({ strings: e, _$litType$: t }, s) {
372
+ let i;
373
+ this.parts = [];
374
+ let r = 0, o = 0;
375
+ const a = e.length - 1, c = this.parts, [l, f] = Mt(e, t);
376
+ if (this.el = re.createElement(l, s), B.currentNode = this.el.content, t === 2) {
377
+ const p = this.el.content, u = p.firstChild;
378
+ u.remove(), p.append(...u.childNodes);
379
+ }
380
+ for (; (i = B.nextNode()) !== null && c.length < a; ) {
381
+ if (i.nodeType === 1) {
382
+ if (i.hasAttributes()) {
383
+ const p = [];
384
+ for (const u of i.getAttributeNames())
385
+ if (u.endsWith("$lit$") || u.startsWith(D)) {
386
+ const y = f[o++];
387
+ if (p.push(u), y !== void 0) {
388
+ const C = i.getAttribute(y.toLowerCase() + "$lit$").split(D), b = /([.?@])?(.*)/.exec(y);
389
+ c.push({ type: 1, index: r, name: b[2], strings: C, ctor: b[1] === "." ? Ht : b[1] === "?" ? Ft : b[1] === "@" ? Qt : me });
390
+ } else
391
+ c.push({ type: 6, index: r });
392
+ }
393
+ for (const u of p)
394
+ i.removeAttribute(u);
395
+ }
396
+ if (st.test(i.tagName)) {
397
+ const p = i.textContent.split(D), u = p.length - 1;
398
+ if (u > 0) {
399
+ i.textContent = Y ? Y.emptyScript : "";
400
+ for (let y = 0; y < u; y++)
401
+ i.append(p[y], he()), B.nextNode(), c.push({ type: 2, index: ++r });
402
+ i.append(p[u], he());
403
+ }
404
+ }
405
+ } else if (i.nodeType === 8)
406
+ if (i.data === et)
407
+ c.push({ type: 2, index: r });
408
+ else {
409
+ let p = -1;
410
+ for (; (p = i.data.indexOf(D, p + 1)) !== -1; )
411
+ c.push({ type: 7, index: r }), p += D.length - 1;
412
+ }
413
+ r++;
414
+ }
415
+ }
416
+ static createElement(e, t) {
417
+ const s = G.createElement("template");
418
+ return s.innerHTML = e, s;
419
+ }
420
+ }
421
+ function X(n, e, t = n, s) {
422
+ var i, r, o, a;
423
+ if (e === ne)
424
+ return e;
425
+ let c = s !== void 0 ? (i = t._$Co) === null || i === void 0 ? void 0 : i[s] : t._$Cl;
426
+ const l = ie(e) ? void 0 : e._$litDirective$;
427
+ return c?.constructor !== l && ((r = c?._$AO) === null || r === void 0 || r.call(c, !1), l === void 0 ? c = void 0 : (c = new l(n), c._$AT(n, t, s)), s !== void 0 ? ((o = (a = t)._$Co) !== null && o !== void 0 ? o : a._$Co = [])[s] = c : t._$Cl = c), c !== void 0 && (e = X(n, c._$AS(n, e.values), c, s)), e;
428
+ }
429
+ class Lt {
430
+ constructor(e, t) {
431
+ this.u = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
432
+ }
433
+ get parentNode() {
434
+ return this._$AM.parentNode;
435
+ }
436
+ get _$AU() {
437
+ return this._$AM._$AU;
438
+ }
439
+ v(e) {
440
+ var t;
441
+ const { el: { content: s }, parts: i } = this._$AD, r = ((t = e?.creationScope) !== null && t !== void 0 ? t : G).importNode(s, !0);
442
+ B.currentNode = r;
443
+ let o = B.nextNode(), a = 0, c = 0, l = i[0];
444
+ for (; l !== void 0; ) {
445
+ if (a === l.index) {
446
+ let f;
447
+ l.type === 2 ? f = new ue(o, o.nextSibling, this, e) : l.type === 1 ? f = new l.ctor(o, l.name, l.strings, this, e) : l.type === 6 && (f = new jt(o, this, e)), this.u.push(f), l = i[++c];
448
+ }
449
+ a !== l?.index && (o = B.nextNode(), a++);
450
+ }
451
+ return r;
452
+ }
453
+ p(e) {
454
+ let t = 0;
455
+ for (const s of this.u)
456
+ s !== void 0 && (s.strings !== void 0 ? (s._$AI(e, s, t), t += s.strings.length - 2) : s._$AI(e[t])), t++;
457
+ }
458
+ }
459
+ class ue {
460
+ constructor(e, t, s, i) {
461
+ var r;
462
+ this.type = 2, this._$AH = v, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = s, this.options = i, this._$Cm = (r = i?.isConnected) === null || r === void 0 || r;
463
+ }
464
+ get _$AU() {
465
+ var e, t;
466
+ return (t = (e = this._$AM) === null || e === void 0 ? void 0 : e._$AU) !== null && t !== void 0 ? t : this._$Cm;
467
+ }
468
+ get parentNode() {
469
+ let e = this._$AA.parentNode;
470
+ const t = this._$AM;
471
+ return t !== void 0 && e.nodeType === 11 && (e = t.parentNode), e;
472
+ }
473
+ get startNode() {
474
+ return this._$AA;
475
+ }
476
+ get endNode() {
477
+ return this._$AB;
478
+ }
479
+ _$AI(e, t = this) {
480
+ e = X(this, e, t), ie(e) ? e === v || e == null || e === "" ? (this._$AH !== v && this._$AR(), this._$AH = v) : e !== this._$AH && e !== ne && this.g(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : Pt(e) ? this.k(e) : this.g(e);
481
+ }
482
+ O(e, t = this._$AB) {
483
+ return this._$AA.parentNode.insertBefore(e, t);
484
+ }
485
+ T(e) {
486
+ this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
487
+ }
488
+ g(e) {
489
+ this._$AH !== v && ie(this._$AH) ? this._$AA.nextSibling.data = e : this.T(G.createTextNode(e)), this._$AH = e;
490
+ }
491
+ $(e) {
492
+ var t;
493
+ const { values: s, _$litType$: i } = e, r = typeof i == "number" ? this._$AC(e) : (i.el === void 0 && (i.el = re.createElement(i.h, this.options)), i);
494
+ if (((t = this._$AH) === null || t === void 0 ? void 0 : t._$AD) === r)
495
+ this._$AH.p(s);
496
+ else {
497
+ const o = new Lt(r, this), a = o.v(this.options);
498
+ o.p(s), this.T(a), this._$AH = o;
499
+ }
500
+ }
501
+ _$AC(e) {
502
+ let t = Be.get(e.strings);
503
+ return t === void 0 && Be.set(e.strings, t = new re(e)), t;
504
+ }
505
+ k(e) {
506
+ tt(this._$AH) || (this._$AH = [], this._$AR());
507
+ const t = this._$AH;
508
+ let s, i = 0;
509
+ for (const r of e)
510
+ i === t.length ? t.push(s = new ue(this.O(he()), this.O(he()), this, this.options)) : s = t[i], s._$AI(r), i++;
511
+ i < t.length && (this._$AR(s && s._$AB.nextSibling, i), t.length = i);
512
+ }
513
+ _$AR(e = this._$AA.nextSibling, t) {
514
+ var s;
515
+ for ((s = this._$AP) === null || s === void 0 || s.call(this, !1, !0, t); e && e !== this._$AB; ) {
516
+ const i = e.nextSibling;
517
+ e.remove(), e = i;
518
+ }
519
+ }
520
+ setConnected(e) {
521
+ var t;
522
+ this._$AM === void 0 && (this._$Cm = e, (t = this._$AP) === null || t === void 0 || t.call(this, e));
523
+ }
524
+ }
525
+ class me {
526
+ constructor(e, t, s, i, r) {
527
+ this.type = 1, this._$AH = v, this._$AN = void 0, this.element = e, this.name = t, this._$AM = i, this.options = r, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = v;
528
+ }
529
+ get tagName() {
530
+ return this.element.tagName;
531
+ }
532
+ get _$AU() {
533
+ return this._$AM._$AU;
534
+ }
535
+ _$AI(e, t = this, s, i) {
536
+ const r = this.strings;
537
+ let o = !1;
538
+ if (r === void 0)
539
+ e = X(this, e, t, 0), o = !ie(e) || e !== this._$AH && e !== ne, o && (this._$AH = e);
540
+ else {
541
+ const a = e;
542
+ let c, l;
543
+ for (e = r[0], c = 0; c < r.length - 1; c++)
544
+ l = X(this, a[s + c], t, c), l === ne && (l = this._$AH[c]), o || (o = !ie(l) || l !== this._$AH[c]), l === v ? e = v : e !== v && (e += (l ?? "") + r[c + 1]), this._$AH[c] = l;
545
+ }
546
+ o && !i && this.j(e);
547
+ }
548
+ j(e) {
549
+ e === v ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
550
+ }
551
+ }
552
+ class Ht extends me {
553
+ constructor() {
554
+ super(...arguments), this.type = 3;
555
+ }
556
+ j(e) {
557
+ this.element[this.name] = e === v ? void 0 : e;
558
+ }
559
+ }
560
+ const Ut = Y ? Y.emptyScript : "";
561
+ class Ft extends me {
562
+ constructor() {
563
+ super(...arguments), this.type = 4;
564
+ }
565
+ j(e) {
566
+ e && e !== v ? this.element.setAttribute(this.name, Ut) : this.element.removeAttribute(this.name);
567
+ }
568
+ }
569
+ class Qt extends me {
570
+ constructor(e, t, s, i, r) {
571
+ super(e, t, s, i, r), this.type = 5;
572
+ }
573
+ _$AI(e, t = this) {
574
+ var s;
575
+ if ((e = (s = X(this, e, t, 0)) !== null && s !== void 0 ? s : v) === ne)
576
+ return;
577
+ const i = this._$AH, r = e === v && i !== v || e.capture !== i.capture || e.once !== i.once || e.passive !== i.passive, o = e !== v && (i === v || r);
578
+ r && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, e), this._$AH = e;
579
+ }
580
+ handleEvent(e) {
581
+ var t, s;
582
+ typeof this._$AH == "function" ? this._$AH.call((s = (t = this.options) === null || t === void 0 ? void 0 : t.host) !== null && s !== void 0 ? s : this.element, e) : this._$AH.handleEvent(e);
583
+ }
584
+ }
585
+ class jt {
586
+ constructor(e, t, s) {
587
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = s;
588
+ }
589
+ get _$AU() {
590
+ return this._$AM._$AU;
591
+ }
592
+ _$AI(e) {
593
+ X(this, e);
594
+ }
595
+ }
596
+ const Ve = ce.litHtmlPolyfillSupport;
597
+ Ve?.(re, ue), ((ve = ce.litHtmlVersions) !== null && ve !== void 0 ? ve : ce.litHtmlVersions = []).push("2.6.1");
598
+ /**
599
+ * @license
600
+ * Copyright 2020 Google LLC
601
+ * SPDX-License-Identifier: BSD-3-Clause
602
+ */
603
+ const Bt = Symbol.for(""), Vt = (n) => {
604
+ if (n?.r === Bt)
605
+ return n?._$litStatic$;
606
+ }, Ye = /* @__PURE__ */ new Map(), Yt = (n) => (e, ...t) => {
607
+ const s = t.length;
608
+ let i, r;
609
+ const o = [], a = [];
610
+ let c, l = 0, f = !1;
611
+ for (; l < s; ) {
612
+ for (c = e[l]; l < s && (r = t[l], (i = Vt(r)) !== void 0); )
613
+ c += i + e[++l], f = !0;
614
+ a.push(r), o.push(c), l++;
615
+ }
616
+ if (l === s && o.push(e[s]), f) {
617
+ const p = o.join("$$lit$$");
618
+ (e = Ye.get(p)) === void 0 && (o.raw = o, Ye.set(p, e = o)), t = a;
619
+ }
620
+ return n(e, ...t);
621
+ }, Gt = Yt(Dt);
622
+ function E(n, e) {
623
+ const t = {
624
+ waitUntilFirstUpdate: !1,
625
+ ...e
626
+ };
627
+ return (s, i) => {
628
+ const { update: r } = s;
629
+ if (n in s) {
630
+ const o = n;
631
+ s.update = function(a) {
632
+ if (a.has(o)) {
633
+ const c = a.get(o), l = this[o];
634
+ c !== l && (!t.waitUntilFirstUpdate || this.hasUpdated) && this[i](c, l);
635
+ }
636
+ r.call(this, a);
637
+ };
638
+ }
639
+ };
640
+ }
641
+ var Xt = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Q = (n, e, t, s) => {
642
+ for (var i = s > 1 ? void 0 : s ? zt(e, t) : e, r = n.length - 1, o; r >= 0; r--)
643
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
644
+ return s && i && Xt(e, t, i), i;
645
+ };
646
+ const Wt = {
647
+ SPACE: 32
648
+ };
649
+ let S = class extends $ {
650
+ constructor() {
651
+ super(...arguments), this.tabindex = 0, this.disabled = !1, this.readonly = !1, this.checked = !1;
652
+ }
653
+ handleDisabledChange(n, e) {
654
+ e ? (this.tabindex = void 0, this.blur()) : this.tabIndex = 0;
655
+ }
656
+ connectedCallback() {
657
+ super.connectedCallback(), this.addEventListener("keyup", this._onKeyUp), this.addEventListener("click", this._onClick), this.emit(m.ON_REGISTER_CHOICE);
658
+ }
659
+ disconnectedCallback() {
660
+ this.removeEventListener("keyup", this._onKeyUp), this.removeEventListener("click", this._onClick), this.emit(m.ON_LOOSE_CHOICE);
661
+ }
662
+ reset() {
663
+ this.checked = !1, this.disabled = !1;
664
+ }
665
+ _onKeyUp(n) {
666
+ if (!n.altKey)
667
+ switch (n.keyCode) {
668
+ case Wt.SPACE:
669
+ n.preventDefault(), this._toggleChecked();
670
+ break;
671
+ default:
672
+ return;
673
+ }
674
+ }
675
+ _onClick() {
676
+ this._toggleChecked();
677
+ }
678
+ _toggleChecked() {
679
+ this.disabled || this.readonly || (this.checked = !this.checked, this.emit(m.ON_CHOICE_ELEMENT_SELECTED, { detail: { identifier: this.identifier, checked: this.checked } }));
680
+ }
681
+ validateAllProps() {
682
+ return !!this.getAttribute("identifier");
683
+ }
684
+ render() {
685
+ return this.validateAllProps() || console.warn(`Invalid props for ${this.outerHTML}`, "missing identifier"), Gt` <slot></slot> `;
686
+ }
687
+ };
688
+ Q([
689
+ d({ type: String })
690
+ ], S.prototype, "identifier", 2);
691
+ Q([
692
+ d({ type: Number, reflect: !0 })
693
+ ], S.prototype, "tabindex", 2);
694
+ Q([
695
+ d({ type: Boolean, reflect: !0 })
696
+ ], S.prototype, "disabled", 2);
697
+ Q([
698
+ d({ type: Boolean, reflect: !0 })
699
+ ], S.prototype, "readonly", 2);
700
+ Q([
701
+ d({
702
+ reflect: !0,
703
+ type: Boolean,
704
+ attribute: "aria-checked",
705
+ converter: {
706
+ toAttribute: (n) => `${n}`
707
+ }
708
+ })
709
+ ], S.prototype, "checked", 2);
710
+ Q([
711
+ E("disabled", { waitUntilFirstUpdate: !0 })
712
+ ], S.prototype, "handleDisabledChange", 1);
713
+ S = Q([
714
+ T("qti-choice")
715
+ ], S);
716
+ class Ce extends g {
717
+ render() {
718
+ return h``;
719
+ }
720
+ }
721
+ customElements.define("qti-variabledeclaration", Ce);
722
+ var Kt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, xe = (n, e, t, s) => {
723
+ for (var i = s > 1 ? void 0 : s ? Zt(e, t) : e, r = n.length - 1, o; r >= 0; r--)
724
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
725
+ return s && i && Kt(e, t, i), i;
726
+ };
727
+ class fe extends Ce {
728
+ connectedCallback() {
729
+ super.connectedCallback();
730
+ const e = new se({
731
+ baseType: this.baseType,
732
+ identifier: this.identifier,
733
+ correctResponse: this.correctResponse,
734
+ cardinality: this.cardinality || Ze.single,
735
+ mapping: this.mapping
736
+ });
737
+ this.dispatchEvent(
738
+ new CustomEvent(m.ON_REGISTER_VARIABLE, {
739
+ bubbles: !0,
740
+ composed: !0,
741
+ detail: e
742
+ })
743
+ );
744
+ }
745
+ get correctResponse() {
746
+ let e;
747
+ const t = this.querySelector("qti-correct-response");
748
+ if (t) {
749
+ const s = t.querySelectorAll("qti-value");
750
+ if (s.length === 1)
751
+ e = s[0].textContent, s[0].remove();
752
+ else {
753
+ e = [];
754
+ for (let i = 0; i < s.length; i++)
755
+ e.push(s[i].textContent), s[i].remove();
756
+ }
757
+ }
758
+ return e;
759
+ }
760
+ get mapping() {
761
+ const e = this.querySelector("qti-mapping");
762
+ if (e) {
763
+ const t = /* @__PURE__ */ new Map(), s = e.querySelectorAll("qti-map-entry");
764
+ for (let i = 0; i < s.length; i++) {
765
+ const r = s[i], o = r.getAttribute("map-key"), a = r.getAttribute("mapped-value");
766
+ t.set(o, a ? parseFloat(a) : null);
767
+ }
768
+ return t;
769
+ } else
770
+ return null;
771
+ }
772
+ }
773
+ xe([
774
+ d({ type: String, attribute: "base-type" })
775
+ ], fe.prototype, "baseType", 2);
776
+ xe([
777
+ d({ type: String, attribute: "identifier" })
778
+ ], fe.prototype, "identifier", 2);
779
+ xe([
780
+ d({ type: String, attribute: "cardinality" })
781
+ ], fe.prototype, "cardinality", 2);
782
+ customElements.define("qti-response-declaration", fe);
783
+ class Jt extends Ce {
784
+ // fIXME: PK: attributes
785
+ static get observedAttributes() {
786
+ return ["identifier", "cardinality", "base-type"];
787
+ }
788
+ connectedCallback() {
789
+ super.connectedCallback();
790
+ const e = this.getAttribute("identifier"), t = new Je();
791
+ t.identifier = e, this.dispatchEvent(
792
+ new CustomEvent(m.ON_REGISTER_VARIABLE, {
793
+ bubbles: !0,
794
+ composed: !0,
795
+ detail: t
796
+ })
797
+ );
798
+ }
799
+ }
800
+ customElements.define("qti-outcome-declaration", Jt);
801
+ var es = Object.defineProperty, ts = Object.getOwnPropertyDescriptor, ss = (n, e, t, s) => {
802
+ for (var i = s > 1 ? void 0 : s ? ts(e, t) : e, r = n.length - 1, o; r >= 0; r--)
803
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
804
+ return s && i && es(e, t, i), i;
805
+ };
806
+ let Ge = class extends $ {
807
+ // static override styles = css`
808
+ // slot {
809
+ // display: hidden;
810
+ // }
811
+ // `;
812
+ // override render() {
813
+ // return html` <slot></slot> `;
814
+ // }
815
+ };
816
+ Ge = ss([
817
+ T("qti-companion-materials-info")
818
+ ], Ge);
819
+ /**
820
+ * @license
821
+ * Copyright 2021 Google LLC
822
+ * SPDX-License-Identifier: BSD-3-Clause
823
+ */
824
+ let is = class extends Event {
825
+ constructor(e, t, s) {
826
+ super("context-request", { bubbles: !0, composed: !0 }), this.context = e, this.callback = t, this.subscribe = s;
827
+ }
828
+ };
829
+ /**
830
+ * @license
831
+ * Copyright 2021 Google LLC
832
+ * SPDX-License-Identifier: BSD-3-Clause
833
+ */
834
+ /**
835
+ * @license
836
+ * Copyright 2021 Google LLC
837
+ * SPDX-License-Identifier: BSD-3-Clause
838
+ */
839
+ let it = class {
840
+ constructor(e, t, s, i = !1) {
841
+ this.host = e, this.context = t, this.callback = s, this.subscribe = i, this.provided = !1, this.value = void 0, this.host.addController(this);
842
+ }
843
+ hostConnected() {
844
+ this.dispatchRequest();
845
+ }
846
+ hostDisconnected() {
847
+ this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
848
+ }
849
+ dispatchRequest() {
850
+ this.host.dispatchEvent(new is(this.context, (e, t) => {
851
+ this.unsubscribe && (this.unsubscribe !== t && (this.provided = !1, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = e, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = !0, this.callback && this.callback(e, t)), this.unsubscribe = t;
852
+ }, this.subscribe));
853
+ }
854
+ };
855
+ /**
856
+ * @license
857
+ * Copyright 2021 Google LLC
858
+ * SPDX-License-Identifier: BSD-3-Clause
859
+ */
860
+ let ns = class {
861
+ constructor(e) {
862
+ this.callbacks = /* @__PURE__ */ new Map(), this.updateObservers = () => {
863
+ for (const [t, s] of this.callbacks)
864
+ t(this.t, s);
865
+ }, e !== void 0 && (this.value = e);
866
+ }
867
+ get value() {
868
+ return this.t;
869
+ }
870
+ set value(e) {
871
+ this.setValue(e);
872
+ }
873
+ setValue(e, t = !1) {
874
+ const s = t || !Object.is(e, this.t);
875
+ this.t = e, s && this.updateObservers();
876
+ }
877
+ addCallback(e, t) {
878
+ t && (this.callbacks.has(e) || this.callbacks.set(e, () => {
879
+ this.callbacks.delete(e);
880
+ })), e(this.value);
881
+ }
882
+ clearCallbacks() {
883
+ this.callbacks.clear();
884
+ }
885
+ };
886
+ /**
887
+ * @license
888
+ * Copyright 2021 Google LLC
889
+ * SPDX-License-Identifier: BSD-3-Clause
890
+ */
891
+ let rs = class extends Event {
892
+ constructor(e) {
893
+ super("context-provider", { bubbles: !0, composed: !0 }), this.context = e;
894
+ }
895
+ }, os = class extends ns {
896
+ constructor(e, t, s) {
897
+ super(s), this.host = e, this.context = t, this.onContextRequest = (i) => {
898
+ i.context === this.context && i.composedPath()[0] !== this.host && (i.stopPropagation(), this.addCallback(i.callback, i.subscribe));
899
+ }, this.attachListeners(), this.host.addController(this);
900
+ }
901
+ attachListeners() {
902
+ this.host.addEventListener("context-request", this.onContextRequest);
903
+ }
904
+ hostConnected() {
905
+ this.host.dispatchEvent(new rs(this.context));
906
+ }
907
+ };
908
+ const Ae = "logger";
909
+ var as = Object.defineProperty, ls = Object.getOwnPropertyDescriptor, z = (n, e, t, s) => {
910
+ for (var i = s > 1 ? void 0 : s ? ls(e, t) : e, r = n.length - 1, o; r >= 0; r--)
911
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
912
+ return s && i && as(e, t, i), i;
913
+ };
914
+ let M = class extends $ {
915
+ constructor() {
916
+ super(...arguments), this.logger = new it(
917
+ this,
918
+ Ae,
919
+ (n) => this.style.display = this.view === n.view ? "block" : "none",
920
+ !0
921
+ );
922
+ }
923
+ handleclassNamesChange(n, e) {
924
+ this.classNames.split(" ").forEach((s) => {
925
+ switch (s) {
926
+ case "qti-rubric-discretionary-placement":
927
+ this.setAttribute("slot", "qti-rubric-block");
928
+ break;
929
+ case "qti-rubric-inline":
930
+ this.setAttribute("slot", "");
931
+ break;
932
+ }
933
+ });
934
+ }
935
+ render() {
936
+ return h`<slot></slot>`;
937
+ }
938
+ connectedCallback() {
939
+ super.connectedCallback(), this.setAttribute("slot", "qti-rubric-block");
940
+ }
941
+ };
942
+ M.styles = _`
943
+ :host {
944
+ display: block;
945
+ }
946
+ `;
947
+ z([
948
+ d({ type: String })
949
+ ], M.prototype, "id", 2);
950
+ z([
951
+ d({ type: String })
952
+ ], M.prototype, "use", 2);
953
+ z([
954
+ d({ type: String })
955
+ ], M.prototype, "view", 2);
956
+ z([
957
+ d({ type: String, attribute: "class" })
958
+ ], M.prototype, "classNames", 2);
959
+ z([
960
+ E("classNames", { waitUntilFirstUpdate: !0 })
961
+ ], M.prototype, "handleclassNamesChange", 1);
962
+ M = z([
963
+ T("qti-rubric-block")
964
+ ], M);
965
+ var cs = Object.defineProperty, hs = Object.getOwnPropertyDescriptor, ds = (n, e, t, s) => {
966
+ for (var i = s > 1 ? void 0 : s ? hs(e, t) : e, r = n.length - 1, o; r >= 0; r--)
967
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
968
+ return s && i && cs(e, t, i), i;
969
+ };
970
+ let Xe = class extends $ {
971
+ render() {
972
+ return h`<slot></slot>`;
973
+ }
974
+ };
975
+ Xe = ds([
976
+ T("qti-content-body")
977
+ ], Xe);
978
+ class nt extends g {
979
+ constructor() {
980
+ super(), this.showHide = "show", this.showFeedback(this.showHide === "hide");
981
+ }
982
+ static get properties() {
983
+ return {
984
+ showStatus: {
985
+ type: String,
986
+ attribute: !0,
987
+ // pk: this was false, because its not a supported qti3 inline feedback
988
+ reflect: !0
989
+ // pk: this was not reflected, but I do it anyways for supporting styling in light dom
990
+ },
991
+ showHide: {
992
+ type: String,
993
+ attribute: "show-hide"
994
+ },
995
+ outcomeIdentifier: {
996
+ type: String,
997
+ attribute: "outcome-identifier"
998
+ },
999
+ identifier: {
1000
+ type: String
1001
+ }
1002
+ };
1003
+ }
1004
+ connectedCallback() {
1005
+ super.connectedCallback(), this.dispatchEvent(
1006
+ new CustomEvent(m.ON_REGISTER_FEEDBACK, {
1007
+ bubbles: !0,
1008
+ composed: !0,
1009
+ detail: this
1010
+ })
1011
+ );
1012
+ }
1013
+ checkShowFeedback(e, t) {
1014
+ this.outcomeIdentifier === e && (t instanceof Array ? this.showFeedback(t.indexOf(this.identifier) !== -1) : this.showFeedback(this.identifier === t));
1015
+ }
1016
+ showFeedback(e) {
1017
+ this.showStatus = e ? "on" : "off";
1018
+ }
1019
+ }
1020
+ class rt extends nt {
1021
+ constructor() {
1022
+ super(...arguments), this.render = () => h` <slot class="${this.showStatus}"></slot> `;
1023
+ }
1024
+ }
1025
+ rt.styles = _`
1026
+ .on {
1027
+ display: inline-block;
1028
+ }
1029
+ .off {
1030
+ display: none;
1031
+ }
1032
+ `;
1033
+ customElements.define("qti-feedback-inline", rt);
1034
+ class ps extends nt {
1035
+ render() {
1036
+ return h`
1037
+ <style>
1038
+ .on {
1039
+ display: inline-block;
1040
+ }
1041
+ .off {
1042
+ display: none;
1043
+ }
1044
+ </style>
1045
+ <div class="feedback ${this.showStatus}">
1046
+ <slot></slot>
1047
+ </div>
1048
+ `;
1049
+ }
1050
+ }
1051
+ customElements.define("qti-modal-feedback", ps);
1052
+ /**
1053
+ * @license
1054
+ * Copyright 2018 Google LLC
1055
+ * SPDX-License-Identifier: BSD-3-Clause
1056
+ */
1057
+ const V = (n) => n ?? v;
1058
+ var us = Object.defineProperty, ms = Object.getOwnPropertyDescriptor, $e = (n, e, t, s) => {
1059
+ for (var i = s > 1 ? void 0 : s ? ms(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1060
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1061
+ return s && i && us(e, t, i), i;
1062
+ };
1063
+ class A extends $ {
1064
+ constructor() {
1065
+ super(...arguments), this.responseIdentifier = "", this.disabled = !1, this.readonly = !1;
1066
+ }
1067
+ connectedCallback() {
1068
+ super.connectedCallback(), this.emit(m.ON_REGISTER_INTERACTION);
1069
+ }
1070
+ saveResponse(e) {
1071
+ this.emit(m.ON_INTERACTION_RESPONSE, {
1072
+ detail: {
1073
+ responseIdentifier: this.responseIdentifier,
1074
+ responses: e
1075
+ }
1076
+ });
1077
+ }
1078
+ }
1079
+ $e([
1080
+ d({ attribute: "response-identifier" })
1081
+ ], A.prototype, "responseIdentifier", 2);
1082
+ $e([
1083
+ d({ reflect: !0, type: Boolean })
1084
+ ], A.prototype, "disabled", 2);
1085
+ $e([
1086
+ d({ reflect: !0, type: Boolean })
1087
+ ], A.prototype, "readonly", 2);
1088
+ const qe = _`
1089
+ /***
1090
+ The new CSS reset - version 1.4.9 (last updated 11.2.2022)
1091
+ GitHub page: https://github.com/elad2412/the-new-css-reset
1092
+ ***/
1093
+
1094
+ /*
1095
+ Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
1096
+ - The "symbol *" part is to solve Firefox SVG sprite bug
1097
+ */
1098
+ *:where(:not(iframe, canvas, img, svg, video, object):not(svg *, symbol *)) {
1099
+ all: unset;
1100
+ display: revert;
1101
+ }
1102
+
1103
+ /* Preferred box-sizing value */
1104
+ *,
1105
+ *::before,
1106
+ *::after {
1107
+ box-sizing: border-box;
1108
+ }
1109
+
1110
+ /* Reapply the pointer cursor for anchor tags */
1111
+ a,
1112
+ button {
1113
+ cursor: revert;
1114
+ }
1115
+
1116
+ /* Remove list styles (bullets/numbers) */
1117
+ ol,
1118
+ ul,
1119
+ menu {
1120
+ list-style: none;
1121
+ }
1122
+
1123
+ /* For images to not be able to exceed their container */
1124
+ img {
1125
+ max-width: 100%;
1126
+ }
1127
+
1128
+ /* removes spacing between cells in tables */
1129
+ table {
1130
+ border-collapse: collapse;
1131
+ }
1132
+
1133
+ /* revert the 'white-space' property for textarea elements on Safari */
1134
+ textarea {
1135
+ white-space: revert;
1136
+ }
1137
+
1138
+ /* minimum style to allow to style meter element */
1139
+ meter {
1140
+ -webkit-appearance: revert;
1141
+ appearance: revert;
1142
+ }
1143
+
1144
+ /* reset default text opacity of input placeholder */
1145
+ ::placeholder {
1146
+ all: unset;
1147
+ }
1148
+
1149
+ /* fix the feature of 'hidden' attribute.
1150
+ display:revert; revert to element instead of attribute */
1151
+ :where([hidden]) {
1152
+ display: none;
1153
+ }
1154
+
1155
+ /* revert for bug in Chromium browsers
1156
+ - fix for the content editable attribute will work properly. */
1157
+ :where([contenteditable]) {
1158
+ -moz-user-modify: read-write;
1159
+ -webkit-user-modify: read-write;
1160
+ overflow-wrap: break-word;
1161
+ -webkit-line-break: after-white-space;
1162
+ }
1163
+
1164
+ /* apply back the draggable feature - exist only in Chromium and Safari */
1165
+ :where([draggable='true']) {
1166
+ -webkit-user-drag: element;
1167
+ }
1168
+ `;
1169
+ class ot extends A {
1170
+ constructor() {
1171
+ super(), this.value = "";
1172
+ }
1173
+ static get properties() {
1174
+ return {
1175
+ ...A.properties,
1176
+ expectedLength: {
1177
+ type: Number,
1178
+ attribute: "expected-length"
1179
+ },
1180
+ patternMask: {
1181
+ type: String,
1182
+ attribute: "pattern-mask"
1183
+ },
1184
+ placeholderText: {
1185
+ type: String,
1186
+ attribute: "placeholder-text"
1187
+ },
1188
+ value: {
1189
+ type: String
1190
+ }
1191
+ };
1192
+ }
1193
+ set response(e) {
1194
+ this.value = e !== void 0 ? e : "";
1195
+ }
1196
+ validate() {
1197
+ return this.value !== "";
1198
+ }
1199
+ static get styles() {
1200
+ return [
1201
+ qe,
1202
+ _`
1203
+ /* PK: display host as block, else design will be collapsed */
1204
+ :host {
1205
+ display: inline-block;
1206
+ }
1207
+ input {
1208
+ padding: var(--qti-padding, 0.5rem);
1209
+ }
1210
+ `
1211
+ ];
1212
+ }
1213
+ render() {
1214
+ return h`
1215
+ <input
1216
+ spellcheck="false"
1217
+ autocomplete="off"
1218
+ @keydown="${(e) => e.stopImmediatePropagation()}"
1219
+ @keyup="${this.textChanged}"
1220
+ @change="${this.textChanged}"
1221
+ type="text"
1222
+ placeholder="${V(this.placeholderText ? this.placeholderText : void 0)}"
1223
+ .value="${this.value}"
1224
+ size="${V(this.expectedLength ? this.expectedLength : void 0)}"
1225
+ pattern="${V(this.patternMask ? this.patternMask : void 0)}"
1226
+ ?disabled="${this.disabled}"
1227
+ ?readonly="${this.readonly}"
1228
+ />`;
1229
+ }
1230
+ // maxlength="${ifDefined(this.expectedLength ? this.expectedLength : undefined)}"
1231
+ textChanged(e) {
1232
+ if (this.disabled || this.readonly)
1233
+ return;
1234
+ const t = e.target;
1235
+ this.setEmptyAttribute(t.value), this.value = t.value, this.saveResponse({ base: { string: t.value } });
1236
+ }
1237
+ reset() {
1238
+ this.value = "";
1239
+ }
1240
+ setEmptyAttribute(e) {
1241
+ this.setAttribute("empty", e === "" ? "true" : "false");
1242
+ }
1243
+ }
1244
+ ot.inputWidthClass = [
1245
+ "",
1246
+ "qti-input-width-2",
1247
+ "qti-input-width-1",
1248
+ "qti-input-width-3",
1249
+ "qti-input-width-4",
1250
+ "qti-input-width-6",
1251
+ "qti-input-width-10",
1252
+ "qti-input-width-15",
1253
+ "qti-input-width-20",
1254
+ "qti-input-width-72"
1255
+ ];
1256
+ customElements.define("qti-text-entry-interaction", ot);
1257
+ /**
1258
+ * @license
1259
+ * Copyright 2020 Google LLC
1260
+ * SPDX-License-Identifier: BSD-3-Clause
1261
+ */
1262
+ const fs = (n) => n.strings === void 0;
1263
+ /**
1264
+ * @license
1265
+ * Copyright 2017 Google LLC
1266
+ * SPDX-License-Identifier: BSD-3-Clause
1267
+ */
1268
+ const gs = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }, bs = (n) => (...e) => ({ _$litDirective$: n, values: e });
1269
+ class vs {
1270
+ constructor(e) {
1271
+ }
1272
+ get _$AU() {
1273
+ return this._$AM._$AU;
1274
+ }
1275
+ _$AT(e, t, s) {
1276
+ this._$Ct = e, this._$AM = t, this._$Ci = s;
1277
+ }
1278
+ _$AS(e, t) {
1279
+ return this.update(e, t);
1280
+ }
1281
+ update(e, t) {
1282
+ return this.render(...t);
1283
+ }
1284
+ }
1285
+ /**
1286
+ * @license
1287
+ * Copyright 2017 Google LLC
1288
+ * SPDX-License-Identifier: BSD-3-Clause
1289
+ */
1290
+ const ee = (n, e) => {
1291
+ var t, s;
1292
+ const i = n._$AN;
1293
+ if (i === void 0)
1294
+ return !1;
1295
+ for (const r of i)
1296
+ (s = (t = r)._$AO) === null || s === void 0 || s.call(t, e, !1), ee(r, e);
1297
+ return !0;
1298
+ }, de = (n) => {
1299
+ let e, t;
1300
+ do {
1301
+ if ((e = n._$AM) === void 0)
1302
+ break;
1303
+ t = e._$AN, t.delete(n), n = e;
1304
+ } while (t?.size === 0);
1305
+ }, at = (n) => {
1306
+ for (let e; e = n._$AM; n = e) {
1307
+ let t = e._$AN;
1308
+ if (t === void 0)
1309
+ e._$AN = t = /* @__PURE__ */ new Set();
1310
+ else if (t.has(n))
1311
+ break;
1312
+ t.add(n), Es(e);
1313
+ }
1314
+ };
1315
+ function _s(n) {
1316
+ this._$AN !== void 0 ? (de(this), this._$AM = n, at(this)) : this._$AM = n;
1317
+ }
1318
+ function ys(n, e = !1, t = 0) {
1319
+ const s = this._$AH, i = this._$AN;
1320
+ if (i !== void 0 && i.size !== 0)
1321
+ if (e)
1322
+ if (Array.isArray(s))
1323
+ for (let r = t; r < s.length; r++)
1324
+ ee(s[r], !1), de(s[r]);
1325
+ else
1326
+ s != null && (ee(s, !1), de(s));
1327
+ else
1328
+ ee(this, n);
1329
+ }
1330
+ const Es = (n) => {
1331
+ var e, t, s, i;
1332
+ n.type == gs.CHILD && ((e = (s = n)._$AP) !== null && e !== void 0 || (s._$AP = ys), (t = (i = n)._$AQ) !== null && t !== void 0 || (i._$AQ = _s));
1333
+ };
1334
+ class Cs extends vs {
1335
+ constructor() {
1336
+ super(...arguments), this._$AN = void 0;
1337
+ }
1338
+ _$AT(e, t, s) {
1339
+ super._$AT(e, t, s), at(this), this.isConnected = e._$AU;
1340
+ }
1341
+ _$AO(e, t = !0) {
1342
+ var s, i;
1343
+ e !== this.isConnected && (this.isConnected = e, e ? (s = this.reconnected) === null || s === void 0 || s.call(this) : (i = this.disconnected) === null || i === void 0 || i.call(this)), t && (ee(this, e), de(this));
1344
+ }
1345
+ setValue(e) {
1346
+ if (fs(this._$Ct))
1347
+ this._$Ct._$AI(e, this);
1348
+ else {
1349
+ const t = [...this._$Ct._$AH];
1350
+ t[this._$Ci] = e, this._$Ct._$AI(t, this, 0);
1351
+ }
1352
+ }
1353
+ disconnected() {
1354
+ }
1355
+ reconnected() {
1356
+ }
1357
+ }
1358
+ /**
1359
+ * @license
1360
+ * Copyright 2020 Google LLC
1361
+ * SPDX-License-Identifier: BSD-3-Clause
1362
+ */
1363
+ const xs = () => new As();
1364
+ class As {
1365
+ }
1366
+ const _e = /* @__PURE__ */ new WeakMap(), $s = bs(class extends Cs {
1367
+ render(n) {
1368
+ return v;
1369
+ }
1370
+ update(n, [e]) {
1371
+ var t;
1372
+ const s = e !== this.Y;
1373
+ return s && this.Y !== void 0 && this.rt(void 0), (s || this.lt !== this.ct) && (this.Y = e, this.dt = (t = n.options) === null || t === void 0 ? void 0 : t.host, this.rt(this.ct = n.element)), v;
1374
+ }
1375
+ rt(n) {
1376
+ var e;
1377
+ if (typeof this.Y == "function") {
1378
+ const t = (e = this.dt) !== null && e !== void 0 ? e : globalThis;
1379
+ let s = _e.get(t);
1380
+ s === void 0 && (s = /* @__PURE__ */ new WeakMap(), _e.set(t, s)), s.get(this.Y) !== void 0 && this.Y.call(this.dt, void 0), s.set(this.Y, n), n !== void 0 && this.Y.call(this.dt, n);
1381
+ } else
1382
+ this.Y.value = n;
1383
+ }
1384
+ get lt() {
1385
+ var n, e, t;
1386
+ return typeof this.Y == "function" ? (e = _e.get((n = this.dt) !== null && n !== void 0 ? n : globalThis)) === null || e === void 0 ? void 0 : e.get(this.Y) : (t = this.Y) === null || t === void 0 ? void 0 : t.value;
1387
+ }
1388
+ disconnected() {
1389
+ this.lt === this.ct && this.rt(void 0);
1390
+ }
1391
+ reconnected() {
1392
+ this.rt(this.ct);
1393
+ }
1394
+ });
1395
+ var qs = Object.defineProperty, Os = Object.getOwnPropertyDescriptor, W = (n, e, t, s) => {
1396
+ for (var i = s > 1 ? void 0 : s ? Os(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1397
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1398
+ return s && i && qs(e, t, i), i;
1399
+ };
1400
+ class H extends A {
1401
+ constructor() {
1402
+ super(...arguments), this.textareaRef = xs(), this.value = "";
1403
+ }
1404
+ handleclassNamesChange(e, t) {
1405
+ this.classNames.split(" ").forEach((i) => {
1406
+ if (i.startsWith("qti-height-lines")) {
1407
+ const r = i.replace("qti-height-lines-", "");
1408
+ this.textareaRef && (this.textareaRef.value.rows = parseInt(r));
1409
+ }
1410
+ });
1411
+ }
1412
+ set response(e) {
1413
+ this.value = e !== void 0 ? e : "";
1414
+ }
1415
+ validate() {
1416
+ return this.value !== "";
1417
+ }
1418
+ static get styles() {
1419
+ return [
1420
+ qe,
1421
+ _`
1422
+ /* PK: display host as block, else design will be collapsed */
1423
+ :host {
1424
+ display: block;
1425
+ }
1426
+ textarea {
1427
+ padding: var(--qti-padding, 0.5rem);
1428
+ width: 100%;
1429
+ height: 100%;
1430
+ }
1431
+ `
1432
+ ];
1433
+ }
1434
+ render() {
1435
+ return h`<textarea
1436
+ ${$s(this.textareaRef)}
1437
+ spellcheck="false"
1438
+ autocomplete="off"
1439
+ @keydown="${(e) => e.stopImmediatePropagation()}"
1440
+ @keyup="${this.textChanged}"
1441
+ @change="${this.textChanged}"
1442
+ placeholder="${V(this.placeholderText ? this.placeholderText : void 0)}"
1443
+ maxlength="${V(this.expectedLength ? this.expectedLength : void 0)}"
1444
+ pattern="${V(this.patternMask ? this.patternMask : void 0)}"
1445
+ ?disabled="${this.disabled}"
1446
+ ?readonly="${this.readonly}"
1447
+ .value=${this.value}
1448
+ ></textarea>`;
1449
+ }
1450
+ textChanged(e) {
1451
+ if (this.disabled || this.readonly)
1452
+ return;
1453
+ const t = e.target;
1454
+ this.setEmptyAttribute(t.value), this.value = t.value, this.saveResponse({ base: { string: t.value } });
1455
+ }
1456
+ reset() {
1457
+ this.value = "";
1458
+ }
1459
+ setEmptyAttribute(e) {
1460
+ this.setAttribute("empty", e === "" ? "true" : "false");
1461
+ }
1462
+ }
1463
+ H.rowHeightClass = ["", "qti-height-lines-3", "qti-height-lines-6", "qti-height-lines-15"];
1464
+ W([
1465
+ d({ type: Number, attribute: "expected-length" })
1466
+ ], H.prototype, "expectedLength", 2);
1467
+ W([
1468
+ d({ type: String, attribute: "pattern-mask" })
1469
+ ], H.prototype, "patternMask", 2);
1470
+ W([
1471
+ d({ type: String, attribute: "placeholder-text" })
1472
+ ], H.prototype, "placeholderText", 2);
1473
+ W([
1474
+ d({ type: String })
1475
+ ], H.prototype, "value", 2);
1476
+ W([
1477
+ d({ type: String, attribute: "class" })
1478
+ ], H.prototype, "classNames", 2);
1479
+ W([
1480
+ E("classNames", { waitUntilFirstUpdate: !0 })
1481
+ ], H.prototype, "handleclassNamesChange", 1);
1482
+ customElements.define("qti-extended-text-interaction", H);
1483
+ var ws = Object.defineProperty, Ss = Object.getOwnPropertyDescriptor, Rs = (n, e, t, s) => {
1484
+ for (var i = s > 1 ? void 0 : s ? Ss(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1485
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1486
+ return s && i && ws(e, t, i), i;
1487
+ };
1488
+ let ze = class extends S {
1489
+ };
1490
+ ze = Rs([
1491
+ T("qti-hottext")
1492
+ ], ze);
1493
+ var Is = Object.defineProperty, Ns = Object.getOwnPropertyDescriptor, oe = (n, e, t, s) => {
1494
+ for (var i = s > 1 ? void 0 : s ? Ns(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1495
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1496
+ return s && i && Is(e, t, i), i;
1497
+ };
1498
+ class R extends A {
1499
+ constructor() {
1500
+ super(), this._choiceElements = [], this.minChoices = 0, this.maxChoices = 1, this._handleDisabledChange = (e, t) => this._choiceElements.forEach((s) => s.disabled = t), this._handleReadonlyChange = (e, t) => this._choiceElements.forEach((s) => s.readonly = t), this._handleMaxChoicesChange = () => this._determineInputType(), this.addEventListener(m.ON_REGISTER_CHOICE, this._registerChoiceElement), this.addEventListener(m.ON_LOOSE_CHOICE, this._looseChoiceElement);
1501
+ }
1502
+ reset() {
1503
+ this._choiceElements.forEach((e) => {
1504
+ e.reset();
1505
+ });
1506
+ }
1507
+ validate() {
1508
+ return this._choiceElements.reduce((t, s) => t + (s.checked === !0 ? 1 : 0), 0) >= this.minChoices;
1509
+ }
1510
+ set response(e) {
1511
+ this._choiceElements.forEach((s) => {
1512
+ s.checked = !1;
1513
+ }), (Array.isArray(e) ? e : [e]).forEach((s) => {
1514
+ const i = this.querySelector("[identifier='" + s + "']");
1515
+ i && (i.checked = !0);
1516
+ });
1517
+ }
1518
+ connectedCallback() {
1519
+ super.connectedCallback(), this.addEventListener(m.ON_CHOICE_ELEMENT_SELECTED, this._choiceElementSelectedHandler);
1520
+ }
1521
+ disconnectedCallback() {
1522
+ super.disconnectedCallback(), this.removeEventListener(m.ON_CHOICE_ELEMENT_SELECTED, this._choiceElementSelectedHandler), this.removeEventListener(m.ON_REGISTER_CHOICE, this._registerChoiceElement);
1523
+ }
1524
+ _registerChoiceElement(e) {
1525
+ e.stopPropagation();
1526
+ const t = e.target;
1527
+ this._choiceElements.push(t), this._setInputType(t);
1528
+ }
1529
+ _looseChoiceElement(e) {
1530
+ e.stopPropagation();
1531
+ const t = e.target;
1532
+ this._choiceElements.push(t), this._choiceElements = this._choiceElements.filter((s) => s !== t);
1533
+ }
1534
+ _determineInputType() {
1535
+ this._choiceElements.forEach((e) => {
1536
+ this._setInputType(e);
1537
+ });
1538
+ }
1539
+ _setInputType(e) {
1540
+ this.maxChoices === 1 ? e.setAttribute("role", "radio") : e.setAttribute("role", "checkbox");
1541
+ }
1542
+ _choiceElementSelectedHandler(e) {
1543
+ this.maxChoices === 1 && this._choiceElements.filter((t) => t.identifier !== e.detail.identifier).forEach((t) => {
1544
+ t.checked = !1;
1545
+ }), this._choiceElementSelected();
1546
+ }
1547
+ _choiceElementSelected() {
1548
+ const e = this._choiceElements.filter((s) => s.checked == !0).map((s) => s.identifier);
1549
+ this.maxChoices > 1 && (this.maxChoices === e.length ? this._choiceElements.forEach((s) => s.disabled = s.checked != !0) : this._choiceElements.forEach((s) => s.disabled = !1));
1550
+ let t;
1551
+ this.maxChoices === 1 ? t = { base: { identifier: e.length > 0 ? e[0] : "" } } : t = { list: { identifier: e } }, this.saveResponse(t);
1552
+ }
1553
+ }
1554
+ oe([
1555
+ d({
1556
+ type: Number,
1557
+ attribute: "min-choices"
1558
+ })
1559
+ ], R.prototype, "minChoices", 2);
1560
+ oe([
1561
+ d({
1562
+ type: Number,
1563
+ attribute: "max-choices"
1564
+ })
1565
+ ], R.prototype, "maxChoices", 2);
1566
+ oe([
1567
+ E("disabled", { waitUntilFirstUpdate: !0 })
1568
+ ], R.prototype, "_handleDisabledChange", 2);
1569
+ oe([
1570
+ E("readonly", { waitUntilFirstUpdate: !0 })
1571
+ ], R.prototype, "_handleReadonlyChange", 2);
1572
+ oe([
1573
+ E("_maxChoices", { waitUntilFirstUpdate: !0 })
1574
+ ], R.prototype, "_handleMaxChoicesChange", 2);
1575
+ class Ts extends R {
1576
+ constructor() {
1577
+ super(...arguments), this.render = () => h`<slot></slot>`;
1578
+ }
1579
+ connectedCallback() {
1580
+ super.connectedCallback(), this.setAttribute("qti-hottext-interaction", "");
1581
+ }
1582
+ }
1583
+ customElements.define("qti-hottext-interaction", Ts);
1584
+ class lt extends A {
1585
+ constructor() {
1586
+ super(), this.options = [], this.addEventListener(m.ON_DROPDOWN_SELECTED, this.choiceSelected);
1587
+ const e = Array.from(this.querySelectorAll("qti-inline-choice"));
1588
+ this.options = [
1589
+ {
1590
+ textContent: "select",
1591
+ value: "",
1592
+ selected: !1
1593
+ },
1594
+ ...e.map((t) => ({
1595
+ textContent: t.innerHTML,
1596
+ value: t.getAttribute("identifier"),
1597
+ selected: !1
1598
+ }))
1599
+ ];
1600
+ }
1601
+ static get properties() {
1602
+ return {
1603
+ ...A.properties,
1604
+ options: {
1605
+ type: Array,
1606
+ value: [],
1607
+ attribute: !1
1608
+ }
1609
+ };
1610
+ }
1611
+ connectedCallback() {
1612
+ super.connectedCallback();
1613
+ }
1614
+ static get styles() {
1615
+ return [
1616
+ qe,
1617
+ _`
1618
+ :host {
1619
+ display: inline-block;
1620
+ }
1621
+ select {
1622
+ width:100%;
1623
+ padding: var(--qti-padding-y) var(--qti-padding-x);
1624
+ padding-right: calc(var(--qti-padding-x) + 1ch)
1625
+ }
1626
+ `
1627
+ ];
1628
+ }
1629
+ render() {
1630
+ return h`
1631
+ <select
1632
+ @change="${this.choiceSelected}"
1633
+ ?disabled="${this.disabled}"
1634
+ ?readonly="${this.readonly}"
1635
+ >
1636
+ ${this.options.map(
1637
+ (e) => h`
1638
+ <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option>
1639
+ `
1640
+ )}
1641
+ </select>`;
1642
+ }
1643
+ validate() {
1644
+ const e = this.options.find((t) => t.selected);
1645
+ return e ? e.value !== "" : !1;
1646
+ }
1647
+ reset() {
1648
+ this.options = this.options.map((e, t) => ({ ...e, selected: t === 0 }));
1649
+ }
1650
+ set response(e) {
1651
+ this.options = this.options.map((t) => (e === t.value && (t.selected = !0), t));
1652
+ }
1653
+ choiceSelected(e) {
1654
+ const t = e.target.value;
1655
+ this.options = this.options.map((s) => ({ ...s, selected: s.value === t })), this.saveResponse({ base: { string: t } });
1656
+ }
1657
+ }
1658
+ lt.inputWidthClass = [
1659
+ "",
1660
+ "qti-input-width-2",
1661
+ "qti-input-width-1",
1662
+ "qti-input-width-3",
1663
+ "qti-input-width-4",
1664
+ "qti-input-width-6",
1665
+ "qti-input-width-10",
1666
+ "qti-input-width-15",
1667
+ "qti-input-width-20",
1668
+ "qti-input-width-72"
1669
+ ];
1670
+ customElements.define("qti-inline-choice-interaction", lt);
1671
+ var Ps = Object.defineProperty, ks = Object.getOwnPropertyDescriptor, ct = (n, e, t, s) => {
1672
+ for (var i = s > 1 ? void 0 : s ? ks(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1673
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1674
+ return s && i && Ps(e, t, i), i;
1675
+ };
1676
+ class ae extends R {
1677
+ constructor() {
1678
+ super(...arguments), this.shuffle = !1, this.render = () => h` <slot name="prompt"></slot>
1679
+ <slot></slot>`;
1680
+ }
1681
+ }
1682
+ ae.layoutClass = [
1683
+ "",
1684
+ "qti-choices-stacking-2",
1685
+ "qti-choices-stacking-3",
1686
+ "qti-choices-stacking-4",
1687
+ "qti-orientation-vertical",
1688
+ "qti-orientation-horizontal"
1689
+ ];
1690
+ ae.presentationClass = ["", "qti-input-control-hidden"];
1691
+ ct([
1692
+ d({ attribute: "orientation", type: String })
1693
+ ], ae.prototype, "orientation", 2);
1694
+ ct([
1695
+ d({ attribute: "shuffle", type: Boolean })
1696
+ ], ae.prototype, "shuffle", 2);
1697
+ customElements.define("qti-choice-interaction", ae);
1698
+ var Ds = Object.defineProperty, Ms = Object.getOwnPropertyDescriptor, Ls = (n, e, t, s) => {
1699
+ for (var i = s > 1 ? void 0 : s ? Ms(e, t) : e, r = n.length - 1, o; r >= 0; r--)
1700
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
1701
+ return s && i && Ds(e, t, i), i;
1702
+ };
1703
+ let We = class extends S {
1704
+ };
1705
+ We = Ls([
1706
+ T("qti-simple-choice")
1707
+ ], We);
1708
+ const Hs = `<qti-response-processing>
1709
+ <qti-response-condition>
1710
+ <qti-response-if>
1711
+ <qti-match>
1712
+ <qti-variable identifier="RESPONSE"></qti-variable>
1713
+ <qti-correct identifier="RESPONSE"></qti-correct>
1714
+ </qti-match>
1715
+ <qti-set-outcome-value identifier="SCORE">
1716
+ <qti-base-value base-type="float">1</qti-base-value>
1717
+ </qti-set-outcome-value>
1718
+ </qti-response-if>
1719
+ <qti-response-else>
1720
+ <qti-set-outcome-value identifier="SCORE">
1721
+ <qti-base-value base-type="float">0</qti-base-value>
1722
+ </qti-set-outcome-value>
1723
+ </qti-response-else>
1724
+ </qti-response-condition>
1725
+ </qti-response-processing>`, Us = `<qti-response-processing>
1726
+ <qti-response-condition>
1727
+ <qti-response-if>
1728
+ <qti-is-null>
1729
+ <qti-variable identifier="RESPONSE"></qti-variable>
1730
+ </qti-is-null>
1731
+ <qti-set-outcome-value identifier="SCORE">
1732
+ <qti-base-value base-type="float">0.0</qti-base-value>
1733
+ </qti-set-outcome-value>
1734
+ </qti-response-if>
1735
+ <qti-response-else>
1736
+ <qti-set-outcome-value identifier="SCORE">
1737
+ <qti-map-response identifier="RESPONSE"> </qti-map-response>
1738
+ </qti-set-outcome-value>
1739
+ </qti-response-else>
1740
+ </qti-response-condition>
1741
+ </qti-response-processing>`, Fs = `<qti-response-processing>
1742
+ <qti-response-condition>
1743
+ <qti-response-if>
1744
+ <qti-is-null>
1745
+ <qti-variable identifier="RESPONSE"></qti-variable>
1746
+ </qti-is-null>
1747
+ <qti-set-outcome-value identifier="SCORE">
1748
+ <qti-base-value base-type="float">0</qti-base-value>
1749
+ </qti-set-outcome-value>
1750
+ </qti-response-if>
1751
+ <qti-response-else>
1752
+ <qti-set-outcome-value identifier="SCORE">
1753
+ <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
1754
+ </qti-set-outcome-value>
1755
+ </qti-response-else>
1756
+ </qti-response-condition>
1757
+ </qti-response-processing>`;
1758
+ class Qs extends g {
1759
+ render() {
1760
+ return h`<slot></slot>`;
1761
+ }
1762
+ // fIXME: PK: attributes
1763
+ static get observedAttributes() {
1764
+ return ["identifier"];
1765
+ }
1766
+ process() {
1767
+ if (this.getAttribute("template")) {
1768
+ const t = this.getAttribute("template").split("/"), s = t[t.length - 1].replace(".xml", "");
1769
+ switch (this.innerHTML = "", s) {
1770
+ case "map_response": {
1771
+ this.appendChild(this.fragmentFromString(Us));
1772
+ break;
1773
+ }
1774
+ case "map_response_point": {
1775
+ this.appendChild(this.fragmentFromString(Fs));
1776
+ break;
1777
+ }
1778
+ case "match_correct":
1779
+ this.appendChild(this.fragmentFromString(Hs));
1780
+ break;
1781
+ }
1782
+ }
1783
+ const e = [...this.children];
1784
+ for (let t = 0; t < e.length; t++)
1785
+ e[t].process();
1786
+ }
1787
+ fragmentFromString(e) {
1788
+ return document.createRange().createContextualFragment(e);
1789
+ }
1790
+ }
1791
+ customElements.define("qti-response-processing", Qs);
1792
+ class Oe extends g {
1793
+ render() {
1794
+ return h``;
1795
+ }
1796
+ process() {
1797
+ throw new Error("Not implemented");
1798
+ }
1799
+ }
1800
+ customElements.define("qti-rule", Oe);
1801
+ class js extends Oe {
1802
+ render() {
1803
+ return h`<slot></slot>`;
1804
+ }
1805
+ process() {
1806
+ const e = [...this.children];
1807
+ for (let t = 0; t < e.length; t++) {
1808
+ const s = e[t];
1809
+ if (s.calculate()) {
1810
+ s.process();
1811
+ return;
1812
+ }
1813
+ }
1814
+ }
1815
+ }
1816
+ customElements.define("qti-response-condition", js);
1817
+ class ht extends g {
1818
+ static get properties() {
1819
+ return {
1820
+ debugCalculateResult: { type: Object }
1821
+ };
1822
+ }
1823
+ render() {
1824
+ return h`
1825
+ <slot></slot>`;
1826
+ }
1827
+ calculate() {
1828
+ return this.debugCalculateResult = !0, !0;
1829
+ }
1830
+ getSubRules() {
1831
+ return [...this.children];
1832
+ }
1833
+ process() {
1834
+ const e = this.getSubRules();
1835
+ for (let t = 0; t < e.length; t++)
1836
+ e[t].process();
1837
+ }
1838
+ }
1839
+ customElements.define("qti-response-else", ht);
1840
+ class dt extends ht {
1841
+ render() {
1842
+ return h`${super.render()}`;
1843
+ }
1844
+ calculate() {
1845
+ const t = this.firstElementChild.calculate();
1846
+ return this.debugCalculateResult = t, t;
1847
+ }
1848
+ getSubRules() {
1849
+ const e = [];
1850
+ for (let t = 1; t < this.children.length; t++)
1851
+ e.push(this.children[t]);
1852
+ return e;
1853
+ }
1854
+ }
1855
+ customElements.define("qti-response-if", dt);
1856
+ class Bs extends dt {
1857
+ render() {
1858
+ return h`${super.render()}`;
1859
+ }
1860
+ }
1861
+ customElements.define("qti-response-else-if", Bs);
1862
+ class q extends $ {
1863
+ render() {
1864
+ return h``;
1865
+ }
1866
+ calculate() {
1867
+ throw new Error("Not implemented");
1868
+ }
1869
+ }
1870
+ customElements.define("qti-expression", q);
1871
+ class Vs extends q {
1872
+ calculate() {
1873
+ const e = this.getAttribute("identifier"), t = this.closest("qti-assessment-item").getResponse(e);
1874
+ if (!t)
1875
+ return this.err(`Response ${e} can not be found`), null;
1876
+ const s = t.mapping, i = t.value;
1877
+ let r = 0;
1878
+ if (Array.isArray(i)) {
1879
+ for (let o = 0; o < i.length; o++)
1880
+ r += Ke(s, i[o], t.baseType);
1881
+ return r;
1882
+ } else
1883
+ r += Ke(s, i, t.baseType);
1884
+ return r;
1885
+ }
1886
+ }
1887
+ customElements.define("qti-map-response", Vs);
1888
+ function Ke(n, e, t) {
1889
+ let s = 0;
1890
+ for (const i of n.entries()) {
1891
+ const { entryTyped: r, valueTyped: o } = Ys(
1892
+ t,
1893
+ i,
1894
+ e
1895
+ );
1896
+ r === o && (s += i[1]);
1897
+ }
1898
+ return s;
1899
+ }
1900
+ function Ys(n, e, t) {
1901
+ let s, i;
1902
+ switch (n) {
1903
+ case F.string:
1904
+ case F.identifier:
1905
+ case F.directedPair:
1906
+ s = "" + e[0], i = "" + t;
1907
+ break;
1908
+ case F.float:
1909
+ s = parseFloat(e[0].replace(",", ".")), i = parseFloat(t.replace(",", "."));
1910
+ break;
1911
+ default:
1912
+ console.warn("no base-type identifier");
1913
+ }
1914
+ return { entryTyped: s, valueTyped: i };
1915
+ }
1916
+ class Gs extends Oe {
1917
+ process() {
1918
+ const e = this.getAttribute("identifier"), t = this.firstElementChild, s = t ? t.calculate() : null;
1919
+ this.closest("qti-assessment-item").setOutcomeValue(e, s);
1920
+ }
1921
+ }
1922
+ customElements.define("qti-set-outcome-value", Gs);
1923
+ class Xs extends q {
1924
+ render() {
1925
+ return h``;
1926
+ }
1927
+ calculate() {
1928
+ const e = this.getAttribute("identifier"), t = this.closest("qti-assessment-item").getResponse(e);
1929
+ return t ? t.correctResponse : (this.err(`Can not find qti-response-identifier: ${e}`), null);
1930
+ }
1931
+ }
1932
+ customElements.define("qti-correct", Xs);
1933
+ class zs extends q {
1934
+ render() {
1935
+ return h``;
1936
+ }
1937
+ calculate() {
1938
+ const e = this.getAttribute("identifier");
1939
+ return this.closest("qti-assessment-item").getVariableValue(e);
1940
+ }
1941
+ }
1942
+ customElements.define("qti-variable", zs);
1943
+ class Ws extends q {
1944
+ calculate() {
1945
+ const t = this.firstElementChild.calculate(), i = this.lastElementChild.calculate();
1946
+ let r = !0;
1947
+ return t instanceof Array ? r = t.length === i.length ? t.filter((o, a) => o === i[a]).length === t.length : !1 : r = t == i, r;
1948
+ }
1949
+ }
1950
+ customElements.define("qti-match", Ws);
1951
+ class we extends q {
1952
+ calculate() {
1953
+ return we.calculate(this.textContent, this.getAttribute("base-type"));
1954
+ }
1955
+ static calculate(e, t) {
1956
+ let s;
1957
+ switch (t) {
1958
+ case F.directedPair:
1959
+ {
1960
+ const i = e.split(" ");
1961
+ s = {
1962
+ destination: i[1],
1963
+ source: i[0]
1964
+ };
1965
+ }
1966
+ break;
1967
+ default:
1968
+ s = e;
1969
+ break;
1970
+ }
1971
+ return s;
1972
+ }
1973
+ }
1974
+ customElements.define("qti-base-value", we);
1975
+ class Se extends q {
1976
+ calculate() {
1977
+ const e = this.firstElementChild, t = this.lastElementChild;
1978
+ return Se.calculate(e, t);
1979
+ }
1980
+ static calculate(e, t) {
1981
+ const s = e.calculate(), i = t.calculate(), r = s.map((l) => l.source + " " + l.destination), o = i.map((l) => l.source + " " + l.destination);
1982
+ return r.filter((l) => o.includes(l)).length > 0;
1983
+ }
1984
+ }
1985
+ customElements.define("qti-contains", Se);
1986
+ class Re extends q {
1987
+ calculate() {
1988
+ return this.children.length === 2 ? Re.calculate(this.children[0], this.children[1]) : (this.err("unexpected number of children in qte"), null);
1989
+ }
1990
+ static calculate(e, t) {
1991
+ const s = +e.calculate(), i = +t.calculate();
1992
+ return s >= i;
1993
+ }
1994
+ }
1995
+ customElements.define("qti-gte", Re);
1996
+ class Ks extends q {
1997
+ calculate() {
1998
+ return Array.from(this.children).map((e) => e.calculate());
1999
+ }
2000
+ }
2001
+ customElements.define("qti-multiple", Ks);
2002
+ class Ie extends q {
2003
+ render() {
2004
+ return h``;
2005
+ }
2006
+ calculate() {
2007
+ return Ie.calculate(Array.from(this.children));
2008
+ }
2009
+ static calculate(e) {
2010
+ return e.every(
2011
+ (t) => t.calculate()
2012
+ );
2013
+ }
2014
+ }
2015
+ customElements.define("qti-and", Ie);
2016
+ class Ne extends q {
2017
+ render() {
2018
+ return h``;
2019
+ }
2020
+ calculate() {
2021
+ return Ne.calculate(Array.from(this.children));
2022
+ }
2023
+ static calculate(e) {
2024
+ return !!e.find(
2025
+ (t) => t.calculate()
2026
+ );
2027
+ }
2028
+ }
2029
+ customElements.define("qti-or", Ne);
2030
+ class Te extends q {
2031
+ calculate() {
2032
+ return this.children.length === 1 ? Te.calculate(this.children[0]) : (this.err("unexpected number of children in qte"), null);
2033
+ }
2034
+ static calculate(e) {
2035
+ const t = e.calculate();
2036
+ return t == null || t == null || t === "";
2037
+ }
2038
+ }
2039
+ customElements.define("qti-is-null", Te);
2040
+ class Zs extends $ {
2041
+ constructor() {
2042
+ super(...arguments), this._errorMessage = null;
2043
+ }
2044
+ static get properties() {
2045
+ return {
2046
+ responseIdentifier: {
2047
+ type: String,
2048
+ attribute: "response-identifier"
2049
+ },
2050
+ module: { type: String, attribute: "module" },
2051
+ customInteractionTypeIdentifier: {
2052
+ type: String,
2053
+ attribute: "custom-interaction-type-identifier"
2054
+ },
2055
+ baseUrl: {
2056
+ type: String,
2057
+ attribute: "base-url"
2058
+ },
2059
+ _errorMessage: {
2060
+ type: String,
2061
+ state: !0
2062
+ }
2063
+ };
2064
+ }
2065
+ getTAOConfig(e) {
2066
+ const t = e.querySelectorAll("properties");
2067
+ let s = {};
2068
+ const i = (o) => {
2069
+ const a = {}, c = o.getAttribute("key");
2070
+ if (c) {
2071
+ const l = Array.from(o.children), f = l.map((u) => u.getAttribute("key"));
2072
+ f.length > 0 && !f.find((u) => !Number.isInteger(+u)) ? a[c] = l.map((u) => r(u)) : a[c] = o.textContent;
2073
+ }
2074
+ return a;
2075
+ }, r = (o) => {
2076
+ if (o) {
2077
+ let a = {};
2078
+ for (const c of o.children)
2079
+ a = { ...a, ...i(c) };
2080
+ return a;
2081
+ }
2082
+ };
2083
+ for (const o of t)
2084
+ return o.getAttribute("key") || (s = { ...s, ...r(o) }), s;
2085
+ this.err("Can not find qti-custom-interaction config");
2086
+ }
2087
+ register(e) {
2088
+ const t = this.parentElement.tagName === "QTI-CUSTOM-INTERACTION" ? "TAO" : "IMS", s = t == "IMS" ? this.querySelector("qti-interaction-markup") : this.querySelector("markup");
2089
+ s.classList.add("qti-customInteraction"), t == "TAO" && this.querySelector("properties") && (this.querySelector("properties").style.display = "none");
2090
+ const i = t == "IMS" ? {
2091
+ properties: this.dataset
2092
+ } : this.getTAOConfig(this);
2093
+ t == "IMS" ? e.getInstance(s, i, void 0) : e.initialize(this.customInteractionTypeIdentifier, s.firstElementChild, i), t == "TAO" && Array.from(this.querySelectorAll("link")).map((o) => o.getAttribute("href")).forEach((o) => {
2094
+ const a = document.createElement("link");
2095
+ a.rel = "stylesheet", a.type = "text/css", a.media = "screen", a.href = o, s.appendChild(a);
2096
+ });
2097
+ }
2098
+ connectedCallback() {
2099
+ super.connectedCallback();
2100
+ const e = {
2101
+ context: this.customInteractionTypeIdentifier,
2102
+ baseUrl: this.baseUrl,
2103
+ catchError: !0
2104
+ };
2105
+ window.requirePaths && window.requireShim && (e.paths = window.requirePaths, e.shim = window.requireShim), requirejs.config(e)(
2106
+ ["require"],
2107
+ (s) => {
2108
+ define("qtiCustomInteractionContext", () => ({
2109
+ register: (i) => {
2110
+ this.register(i);
2111
+ },
2112
+ notifyReady: () => {
2113
+ }
2114
+ })), s([this.module], () => {
2115
+ }, (i) => {
2116
+ this._errorMessage = i;
2117
+ });
2118
+ },
2119
+ (s) => {
2120
+ this._errorMessage = s;
2121
+ }
2122
+ );
2123
+ }
2124
+ render() {
2125
+ return h`<slot></slot>${this._errorMessage && h`<div style="color:red"><h1>Error</h1>${this._errorMessage}</div>`}`;
2126
+ }
2127
+ }
2128
+ customElements.define("qti-portable-custom-interaction", Zs);
2129
+ var Js = Object.defineProperty, ei = Object.getOwnPropertyDescriptor, ti = (n, e, t, s) => {
2130
+ for (var i = s > 1 ? void 0 : s ? ei(e, t) : e, r = n.length - 1, o; r >= 0; r--)
2131
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
2132
+ return s && i && Js(e, t, i), i;
2133
+ };
2134
+ const si = (n, e, t) => {
2135
+ class s extends n {
2136
+ constructor() {
2137
+ super(...arguments), this.disabled = !1;
2138
+ }
2139
+ firstUpdated(r) {
2140
+ if (this.classList.contains("qti-match-tabular"))
2141
+ return;
2142
+ super.firstUpdated(r);
2143
+ const o = Array.from(
2144
+ e ? this.shadowRoot.querySelectorAll(t) : this.querySelectorAll(t)
2145
+ );
2146
+ this.dragoverHandler = this.dragoverHandler.bind(this), this.dragleaveHandler = this.dragleaveHandler.bind(this), this.dropHandler = this.dropHandler.bind(this), o.forEach((a) => {
2147
+ a.setAttribute("dropzone", "move"), a.addEventListener("dragleave", this.dragleaveHandler), this.attachHandler(a);
2148
+ });
2149
+ for (const a of o)
2150
+ this.observer = new MutationObserver((c) => {
2151
+ c.forEach((l) => {
2152
+ if (l.type === "attributes")
2153
+ switch (l.attributeName) {
2154
+ case "disabled": {
2155
+ a.hasAttribute("disabled") ? this.removeHandler(a) : this.attachHandler(a);
2156
+ break;
2157
+ }
2158
+ }
2159
+ });
2160
+ }), this.observer.observe(a, {
2161
+ attributes: !0
2162
+ //configure it to listen to attribute changes
2163
+ });
2164
+ }
2165
+ attachHandler(r) {
2166
+ r.addEventListener("dragover", this.dragoverHandler), r.addEventListener("drop", this.dropHandler);
2167
+ }
2168
+ removeHandler(r) {
2169
+ r.removeEventListener("dragover", this.dragoverHandler), r.removeEventListener("drop", this.dropHandler);
2170
+ }
2171
+ disconnectedCallback() {
2172
+ this.classList.contains("qti-match-tabular") || (super.disconnectedCallback(), this.observer?.disconnect());
2173
+ }
2174
+ dragoverHandler(r) {
2175
+ return r.preventDefault(), r.currentTarget.setAttribute("active", ""), r.dataTransfer.dropEffect = "move", !1;
2176
+ }
2177
+ dropHandler(r) {
2178
+ r.preventDefault();
2179
+ const o = r.currentTarget, a = this.querySelector(`[identifier=${r.dataTransfer.getData("text")}`), c = a || this.shadowRoot.querySelector(`[identifier=${r.dataTransfer.getData("text")}`);
2180
+ return o ? c.parentElement.getAttribute("identifier") !== o.getAttribute("identifier") && o.appendChild(c) : console.error(`cannot find droppable, target: ${r.target ? JSON.stringify(r.target) : "null"}`), o.removeAttribute("active"), !1;
2181
+ }
2182
+ dragleaveHandler(r) {
2183
+ return r.preventDefault(), r.currentTarget.removeAttribute("active"), !1;
2184
+ }
2185
+ }
2186
+ return ti([
2187
+ d({ type: Boolean, reflect: !0 })
2188
+ ], s.prototype, "disabled", 2), s;
2189
+ }, ii = (n, e, t) => {
2190
+ class s extends n {
2191
+ // private state = new Map<Element, any>();
2192
+ // private observer: MutationObserver;
2193
+ // flippablesSelector: string;
2194
+ // override async firstUpdated(changedProps) {
2195
+ // await this.updateComplete; // pk: this is the key to calculate correct proportions
2196
+ // const draggables = Array.from(this.querySelectorAll(draggablesSel));
2197
+ // draggables.forEach((elem) => {
2198
+ // const { left, top, width, height } = elem.getBoundingClientRect();
2199
+ // this.state.set(elem, { left, top, width, height });
2200
+ // });
2201
+ // this.observer = new MutationObserver(this.animateMe);
2202
+ // const droppables = Array.from(this.querySelectorAll(droppablesSel));
2203
+ // droppables.forEach((draggable) => {
2204
+ // this.observer.observe(draggable, { childList: true });
2205
+ // });
2206
+ // this.observer.observe(this, { childList: true });
2207
+ // super.firstUpdated(changedProps);
2208
+ // }
2209
+ // private animateMe = () => {
2210
+ // this.state.forEach((value, elem) => {
2211
+ // const { left, top, width, height } = elem.getBoundingClientRect();
2212
+ // if (this.state.get(elem) == null) {
2213
+ // this.state.set(elem, { left, top, width, height });
2214
+ // }
2215
+ // const cache = this.state.get(elem);
2216
+ // const deltaX = cache.left - left;
2217
+ // const deltaY = cache.top - top;
2218
+ // const deltaW = cache.width / width;
2219
+ // const deltaH = cache.height / height;
2220
+ // this.state.set(elem, { left, top, width, height });
2221
+ // const { duration, easing } = { duration: 350, easing: 'cubic-bezier(0.26, 0.86, 0.44, 0.985)' };
2222
+ // elem.animate(
2223
+ // [
2224
+ // {
2225
+ // transformOrigin: 'top left',
2226
+ // transform: `
2227
+ // translate(${deltaX}px, ${deltaY}px)
2228
+ // scale(${deltaW}, ${deltaH})
2229
+ // `,
2230
+ // // width: cache.width,
2231
+ // // height: cache.height+ 'px',
2232
+ // // opacity: cache.opacity,
2233
+ // },
2234
+ // {
2235
+ // transformOrigin: 'top left',
2236
+ // transform: 'none',
2237
+ // },
2238
+ // ],
2239
+ // {
2240
+ // duration,
2241
+ // easing,
2242
+ // }
2243
+ // );
2244
+ // });
2245
+ // };
2246
+ // override disconnectedCallback(): void {
2247
+ // super.disconnectedCallback();
2248
+ // this.observer.disconnect();
2249
+ // }
2250
+ }
2251
+ return s;
2252
+ };
2253
+ class te {
2254
+ constructor() {
2255
+ return this._touchBegin = 0, this._touchDown = null, this._lastClick = 0, this._canDrag = !1, this._dragSrc = null, this._dragCopy = null, this._touchEndCalled = !1, this._dragRunning = !1, this._dataTransfer = {
2256
+ data: {},
2257
+ setData: function(e, t) {
2258
+ this.data[e] = t;
2259
+ },
2260
+ getData: function(e) {
2261
+ return this.data[e];
2262
+ },
2263
+ effectAllowed: "move"
2264
+ }, this._copyOffset = { x: 0, y: 0 }, this._lastTarget = null, this._currentDropContainer = null, this._handleClick = !0, this._DBLCLICKDELAY = 500, this._CONTEXTMENUDELAY = 1e3, this._DRAGDELTA = 5, this._COPYOPACITY = 0.7, this.copyStylesDragClone = !0, this.dragOnClick = !1, this.createDragCopy = (e, t) => {
2265
+ if (this._dragCopy === null && this._dragRunning) {
2266
+ this._dragSrc.style.opacity = this._COPYOPACITY, this._dragCopy = this._dragSrc.cloneNode(!0);
2267
+ const i = window.getComputedStyle(this._dragSrc);
2268
+ if (this._dragCopy.style = "", this._dragCopy.setAttribute("dragclone", ""), this.copyStylesDragClone)
2269
+ for (const r of i)
2270
+ this._dragCopy.style[r] = i.getPropertyValue(r);
2271
+ this._calculateDragCopyPosition(t), this._dragCopy.style.top = t.clientY - this._copyOffset.y + "px", this._dragCopy.style.left = t.clientX - this._copyOffset.x + "px", this._dragCopy.style.position = "absolute", this._dragCopy.style.pointerEvents = "none", this._dragCopy.style.zIndex = "999999", this._dragCopy = document.body.appendChild(this._dragCopy), this._dispatchEvent(this._dragSrc, "dragstart");
2272
+ }
2273
+ if (this._dragRunning) {
2274
+ const i = this;
2275
+ requestAnimationFrame(function() {
2276
+ i._touchEndCalled || i._dragCopy === null || (i._dragCopy.style.top = t.clientY - i._copyOffset.y + "px", i._dragCopy.style.left = t.clientX - i._copyOffset.x + "px");
2277
+ });
2278
+ var s = this._findDroppable(e);
2279
+ s != this._lastTarget && (this._dispatchEvent(s, "dragenter"), this._dispatchEvent(this._lastTarget, "dragleave"), this._lastTarget = s), this._currentDropContainer = s, this._currentDropContainer && this._dispatchEvent(s, "dragover");
2280
+ }
2281
+ }, te._instance ? te._instance : (te._instance = this, document.addEventListener("touchmove", this._touchMove.bind(this), { passive: !1, capture: !1 }), document.addEventListener("mousemove", this._touchMove.bind(this), { passive: !1, capture: !1 }), document.addEventListener("touchend", this._touchEnd.bind(this), { passive: !1, capture: !1 }), document.addEventListener("mouseup", this._touchEnd.bind(this), { passive: !1, capture: !1 }), document.addEventListener("touchcancel", this._touchCancel.bind(this), { passive: !1, capture: !1 }), this);
2282
+ }
2283
+ addDraggables(e) {
2284
+ e.forEach((t) => {
2285
+ t.addEventListener("touchstart", this._touchStart.bind(this), { passive: !1, capture: !1 }), t.addEventListener("mousedown", this._touchStart.bind(this), { passive: !1, capture: !1 });
2286
+ });
2287
+ }
2288
+ /**
2289
+ * Callback for touchstart event listener.
2290
+ * @param {TouchEvent} e
2291
+ */
2292
+ _touchStart(e) {
2293
+ this._touchBegin = Date.now();
2294
+ const { x: t, y: s } = this.getPositionFromEvent(e);
2295
+ if (this._touchDown = { x: t, y: s }, this._dragSrc = e.currentTarget, this._canDrag = !0, this.dragOnClick) {
2296
+ const i = { clientX: t, clientY: s };
2297
+ this._dragRunning = !0, this.createDragCopy(e, i);
2298
+ }
2299
+ e.preventDefault();
2300
+ }
2301
+ /**
2302
+ * Callback for touchmove event listener.
2303
+ * @param {TouchEvent} e
2304
+ */
2305
+ _touchMove(e) {
2306
+ if (this._canDrag && this._dragSrc) {
2307
+ const { x: t, y: s } = this.getPositionFromEvent(e), i = { clientX: t, clientY: s };
2308
+ this._getDelta(i) >= this._DRAGDELTA && (this._dragRunning = !0), this.createDragCopy(e, i), e.preventDefault();
2309
+ }
2310
+ }
2311
+ /**
2312
+ * Callback for touchend event listener.
2313
+ * @param {TouchEvent} e
2314
+ */
2315
+ _touchEnd(e) {
2316
+ if (this._touchEndCalled = !0, this._canDrag = !1, this._currentDropContainer)
2317
+ this._dispatchEvent(this._currentDropContainer, "drop"), this._dispatchEvent(this._dragSrc, "dragend");
2318
+ else if (this._dragRunning) {
2319
+ const t = new CustomEvent("dragend", { bubbles: !0, cancelable: !0 });
2320
+ t.dataTransfer = { dropEffect: "none" }, this._dragSrc?.dispatchEvent(t);
2321
+ }
2322
+ this._reset();
2323
+ }
2324
+ /**
2325
+ * Callback for touchcancel event listener, in case browser supports this.
2326
+ * @param {TouchEvent} e
2327
+ */
2328
+ _touchCancel(e) {
2329
+ this._reset();
2330
+ }
2331
+ /**
2332
+ * Determines the next droppable element at current point.
2333
+ * @param {Object} pt
2334
+ */
2335
+ _findDroppable(e) {
2336
+ let t;
2337
+ const s = e.composedPath().find((i) => {
2338
+ if (i.nodeType === 1 && i.nodeName !== "SLOT" && i.hasAttribute("dropzone"))
2339
+ return i;
2340
+ });
2341
+ if (s) {
2342
+ const i = s.getRootNode(), r = this._getPoint(e);
2343
+ t = i.elementFromPoint(r.x, r.y);
2344
+ }
2345
+ return t;
2346
+ }
2347
+ _getPoint(e, t) {
2348
+ return e && e.touches && (e = e.touches[0]), {
2349
+ x: t ? e.pageX : e.clientX,
2350
+ y: t ? e.pageY : e.clientY
2351
+ };
2352
+ }
2353
+ /**
2354
+ * Calculates the offset for displaying the drag copy to have a seamless dragging.
2355
+ * @param {Touch} touch The current touch.
2356
+ */
2357
+ _calculateDragCopyPosition(e) {
2358
+ const t = this._dragSrc.getBoundingClientRect();
2359
+ this._copyOffset.x = e.clientX - t.left, this._copyOffset.y = e.clientY - t.top;
2360
+ }
2361
+ /**
2362
+ * Calculates the pixel delta between first touch and the current touch position.
2363
+ * @param {Object} touch
2364
+ */
2365
+ _getDelta(e) {
2366
+ const t = Math.abs(e.clientX - this._touchDown.x), s = Math.abs(e.clientY - this._touchDown.y);
2367
+ return t + s;
2368
+ }
2369
+ /**
2370
+ *
2371
+ * @param {Element} e The event's target element.
2372
+ * @param {string} eventType The type of the event.
2373
+ * @param {bool} bubble Sets whether the event should bubble.
2374
+ */
2375
+ _dispatchEvent(e, t, s = !0) {
2376
+ if (!e)
2377
+ return !1;
2378
+ const i = new CustomEvent(t, { bubbles: s, cancelable: !0 });
2379
+ return i.dataTransfer = this._dataTransfer, e.dispatchEvent(i), i.defaultPrevented;
2380
+ }
2381
+ /**
2382
+ * Resets all variables and prepares for new Drag and Drop.
2383
+ */
2384
+ _reset() {
2385
+ this._dragRunning && (this._dragSrc.style.opacity = "1.0", this._dragCopy.parentElement.removeChild(this._dragCopy)), this._dragRunning = !1, this._dragSrc = null, this._dragCopy = null, this._canDrag = !1, this._touchBegin = 0, this._touchDown = null, this._lastClick = 0, this._touchEndCalled = !1, this._dataTransfer = {
2386
+ data: {},
2387
+ setData: function(e, t) {
2388
+ this.data[e] = t;
2389
+ },
2390
+ getData: function(e) {
2391
+ return this.data[e];
2392
+ },
2393
+ effectAllowed: "move"
2394
+ }, this._copyOffset = { x: 0, y: 0 }, this._lastTarget = null, this._currentDropContainer = null, this._handleClick = !0;
2395
+ }
2396
+ getPositionFromEvent(e) {
2397
+ let t;
2398
+ if (e.type == "touchstart" || e.type == "touchmove" || e.type == "touchend" || e.type == "touchcancel") {
2399
+ const s = typeof e.originalEvent > "u" ? e : e.originalEvent, i = s.touches[0] || s.changedTouches[0];
2400
+ t = {
2401
+ x: i.pageX,
2402
+ y: i.pageY
2403
+ };
2404
+ } else
2405
+ (e.type == "mousedown" || e.type == "mouseup" || e.type == "mousemove" || e.type == "mouseover" || e.type == "mouseout" || e.type == "mouseenter" || e.type == "mouseleave") && (t = {
2406
+ x: e.clientX,
2407
+ y: e.clientY
2408
+ });
2409
+ return t;
2410
+ }
2411
+ }
2412
+ function ni(n, e) {
2413
+ let t;
2414
+ return {
2415
+ ...e
2416
+ }, (s, i) => {
2417
+ const { connectedCallback: r, disconnectedCallback: o } = s;
2418
+ s.connectedCallback = function() {
2419
+ r.call(this);
2420
+ const a = (l) => {
2421
+ const f = Array.from(this.querySelectorAll(n));
2422
+ for (const p of l) {
2423
+ const u = Array.from(p.addedNodes).map((C) => C), y = Array.from(p.addedNodes).map((C) => C);
2424
+ p.type === "childList" && u.find((C) => f.includes(C)) && this[i](u, y);
2425
+ }
2426
+ };
2427
+ t = new MutationObserver(a), t.observe(this, { childList: !0, subtree: !0 });
2428
+ const c = this.querySelectorAll(n) ?? [];
2429
+ this[i](Array.from(c), []);
2430
+ }, s.disconnectedCallback = function() {
2431
+ o.call(this), t.disconnect();
2432
+ };
2433
+ };
2434
+ }
2435
+ var ri = Object.defineProperty, oi = Object.getOwnPropertyDescriptor, I = (n, e, t, s) => {
2436
+ for (var i = s > 1 ? void 0 : s ? oi(e, t) : e, r = n.length - 1, o; r >= 0; r--)
2437
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
2438
+ return s && i && ri(e, t, i), i;
2439
+ };
2440
+ const le = (n, e, t, s) => {
2441
+ class i extends ii(
2442
+ si(n, t, s)
2443
+ ) {
2444
+ constructor() {
2445
+ super(...arguments), this.draggables = /* @__PURE__ */ new Map(), this.responseIdentifier = "", this.configuration = {
2446
+ copyStylesDragClone: !0,
2447
+ dragCanBePlacedBack: !0,
2448
+ dragOnClick: !1
2449
+ }, this.disabled = !1, this.readonly = !1, this.minAssociations = 1, this.maxAssociations = 1;
2450
+ }
2451
+ reInitDragAndDrop(o, a) {
2452
+ if (this.classList.contains("qti-match-tabular"))
2453
+ return;
2454
+ o.filter((l) => !this.draggables || !this.draggables.get(l)).length > 0 && (this.dragDropApi.addDraggables(o), o.forEach((l) => {
2455
+ this.draggables.set(l, {
2456
+ parent: l.parentElement,
2457
+ index: Array.from(l.parentNode.children).indexOf(l)
2458
+ }), l.setAttribute("qti-draggable", "true"), l.addEventListener("dragstart", (f) => {
2459
+ f.dataTransfer.setData("text", f.currentTarget.getAttribute("identifier")), l.setAttribute("dragging", "");
2460
+ }), l.addEventListener("dragend", (f) => {
2461
+ if (f.preventDefault(), l.removeAttribute("over"), l.removeAttribute("dragging"), f.dataTransfer.dropEffect === "none" && this.configuration.dragCanBePlacedBack) {
2462
+ const p = f.currentTarget, u = this.draggables.get(p), y = u.index < u.parent.children.length ? u.index : u.parent.children.length - 1, C = u.parent, b = u.parent.children[y];
2463
+ C.insertBefore(p, b), this.saveResponse(), this.checkMaxMatchAssociations();
2464
+ }
2465
+ f.dataTransfer.dropEffect === "move" && (this.saveResponse(), this.checkMaxMatchAssociations());
2466
+ });
2467
+ }));
2468
+ }
2469
+ handleDragOptionsChanged(o, a) {
2470
+ this.dragDropApi.copyStylesDragClone = a.copyStylesDragClone, this.dragDropApi.dragOnClick = a.dragOnClick;
2471
+ }
2472
+ handleDisabledChange(o, a) {
2473
+ this.draggables.forEach((c, l) => {
2474
+ a ? l.setAttribute("disabled", "") : l.removeAttribute("disabled"), a ? l.removeAttribute("qti-draggable") : l.setAttribute("qti-draggable", "true");
2475
+ });
2476
+ }
2477
+ handleReadonlyChange(o, a) {
2478
+ this.draggables.forEach((c, l) => {
2479
+ a ? l.setAttribute("readonly", "") : l.removeAttribute("readonly"), a ? l.removeAttribute("qti-draggable") : l.setAttribute("qti-draggable", "true");
2480
+ });
2481
+ }
2482
+ firstUpdated(o) {
2483
+ super.firstUpdated(o), this.droppables = Array.from(
2484
+ t ? this.shadowRoot.querySelectorAll(s) : this.querySelectorAll(s)
2485
+ );
2486
+ }
2487
+ connectedCallback() {
2488
+ super.connectedCallback(), this.dragDropApi = new te(), this.dispatchEvent(
2489
+ new CustomEvent(m.ON_REGISTER_INTERACTION, {
2490
+ bubbles: !0,
2491
+ composed: !0,
2492
+ detail: this
2493
+ })
2494
+ );
2495
+ }
2496
+ reset(o = !0) {
2497
+ this.draggables.forEach((a, c) => {
2498
+ const l = a.parent.children, f = a.index < l.length ? a.index : l.length;
2499
+ a.parent.insertBefore(c, l[f]);
2500
+ }), o && this.saveResponse();
2501
+ }
2502
+ checkMaxMatchAssociations() {
2503
+ this.droppables.forEach((o) => {
2504
+ const c = +(o.getAttribute("match-max") || 1) <= (o.children.length || 0);
2505
+ c ? o.setAttribute("disabled", "") : o.removeAttribute("disabled"), c ? o.removeAttribute("dropzone") : o.setAttribute("dropzone", "move");
2506
+ });
2507
+ }
2508
+ set response(o) {
2509
+ this.classList.contains("qti-match-tabular") || (this.reset(!1), o !== null && Array.isArray(o) && o.forEach((a) => {
2510
+ const [c, ...l] = a.split(" ").reverse();
2511
+ if (c) {
2512
+ const f = this.droppables.find((p) => p.getAttribute("identifier") === c);
2513
+ l.forEach((p) => {
2514
+ const u = this.querySelector(`[identifier=${p}]`);
2515
+ f ? u ? (f.appendChild(u), this.checkMaxMatchAssociations()) : console.error(`cannot find draggable with identifier: ${p}`) : console.error(`cannot find droppable with identifier: ${c}`);
2516
+ });
2517
+ }
2518
+ }));
2519
+ }
2520
+ validate() {
2521
+ const a = (t ? Array.from(this.shadowRoot.querySelectorAll(s)) : Array.from(this.querySelectorAll(s))).filter((c) => c.childElementCount > 0).length;
2522
+ return this.minAssociations <= 0 || this.minAssociations <= a;
2523
+ }
2524
+ saveResponse() {
2525
+ const a = { list: { pair: this.droppables.map((c) => {
2526
+ let l = "";
2527
+ return c.children?.length > 0 && (l += Array.from(c.children).map((f) => f.getAttribute("identifier")).join(" ") + " "), l += c.getAttribute("identifier"), l;
2528
+ }) } };
2529
+ this.dispatchEvent(
2530
+ new CustomEvent(m.ON_INTERACTION_RESPONSE, {
2531
+ bubbles: !0,
2532
+ composed: !0,
2533
+ detail: {
2534
+ responseIdentifier: this.responseIdentifier,
2535
+ responses: a
2536
+ }
2537
+ })
2538
+ );
2539
+ }
2540
+ }
2541
+ return I([
2542
+ ni(e)
2543
+ ], i.prototype, "reInitDragAndDrop", 1), I([
2544
+ d({ type: String, attribute: "response-identifier" })
2545
+ ], i.prototype, "responseIdentifier", 2), I([
2546
+ d({ type: Object })
2547
+ ], i.prototype, "configuration", 2), I([
2548
+ E("configuration")
2549
+ ], i.prototype, "handleDragOptionsChanged", 1), I([
2550
+ d({ type: Boolean, reflect: !0 })
2551
+ ], i.prototype, "disabled", 2), I([
2552
+ E("disabled", { waitUntilFirstUpdate: !0 })
2553
+ ], i.prototype, "handleDisabledChange", 1), I([
2554
+ d({ type: Boolean, reflect: !0 })
2555
+ ], i.prototype, "readonly", 2), I([
2556
+ E("readonly", { waitUntilFirstUpdate: !0 })
2557
+ ], i.prototype, "handleReadonlyChange", 1), I([
2558
+ d({ type: Number, reflect: !0, attribute: "min-associations" })
2559
+ ], i.prototype, "minAssociations", 2), I([
2560
+ d({ type: Number, reflect: !0, attribute: "max-associations" })
2561
+ ], i.prototype, "maxAssociations", 2), i;
2562
+ };
2563
+ var ai = Object.defineProperty, li = Object.getOwnPropertyDescriptor, ci = (n, e, t, s) => {
2564
+ for (var i = s > 1 ? void 0 : s ? li(e, t) : e, r = n.length - 1, o; r >= 0; r--)
2565
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
2566
+ return s && i && ai(e, t, i), i;
2567
+ };
2568
+ class Pe extends le(
2569
+ $,
2570
+ "qti-simple-associable-choice",
2571
+ !0,
2572
+ "drop-list"
2573
+ ) {
2574
+ render() {
2575
+ return h` <slot name="prompt"></slot>
2576
+ <slot name="qti-simple-associable-choice"></slot>
2577
+ ${this._childrenMap.length > 0 && Array.from(Array(Math.ceil(this._childrenMap.length / 2)).keys()).map(
2578
+ (e, t) => h`<div part="associables-container">
2579
+ <drop-list part="drop-list" identifier="droplist${t}_left"></drop-list>
2580
+ <drop-list part="drop-list" identifier="droplist${t}_right"></drop-list>
2581
+ </div>`
2582
+ )}`;
2583
+ }
2584
+ connectedCallback() {
2585
+ super.connectedCallback(), this._childrenMap = Array.from(this.querySelectorAll("qti-simple-associable-choice"));
2586
+ }
2587
+ }
2588
+ Pe.styles = _`
2589
+ :host {
2590
+ display: block; /* necessary to calculate scaling position */
2591
+ }
2592
+ slot[name='qti-simple-associable-choice'] {
2593
+ display: flex;
2594
+ flex-wrap: wrap;
2595
+ gap: 0.5rem;
2596
+ }
2597
+ `;
2598
+ ci([
2599
+ Ee()
2600
+ ], Pe.prototype, "_childrenMap", 2);
2601
+ customElements.define("qti-associate-interaction", Pe);
2602
+ class hi extends g {
2603
+ // pk: This needs some explanation
2604
+ // in the associate interaction there is a special slot for these qti-simple-associable-choices
2605
+ connectedCallback() {
2606
+ super.connectedCallback(), this.setAttribute("slot", "qti-simple-associable-choice"), this.setAttribute("part", "qti-simple-associable-choice");
2607
+ }
2608
+ // pk: This needs some explanation
2609
+ // in qti-match-interaction, qti-simple-associable-choice is used to denote the
2610
+ // draggable, but also the droppable. WEIRD.. but lets deal with it.
2611
+ // So we have a slot for whenever another qti-simple-associable-choice is dropped in here.
2612
+ // And we have slot for content like in this associate interaction
2613
+ render() {
2614
+ return h`
2615
+ <slot></slot>
2616
+ <slot name="qti-simple-associable-choice"></slot>
2617
+ `;
2618
+ }
2619
+ }
2620
+ customElements.define("qti-simple-associable-choice", hi);
2621
+ class pt extends le(g, "qti-gap-text", !1, "qti-gap") {
2622
+ render() {
2623
+ return h` <slot name="qti-gap-text"></slot>
2624
+ <slot></slot>`;
2625
+ }
2626
+ }
2627
+ pt.styles = _`
2628
+ :host {
2629
+ display: block; /* necessary to calculate scaling position */
2630
+ }
2631
+ slot[name='qti-gap-text'] {
2632
+ display: flex;
2633
+ flex-wrap: wrap;
2634
+ gap: var(--qti-gap, 0.5rem);
2635
+ padding: var(--qti-gap, 0.5rem) 0px;
2636
+ }
2637
+ `;
2638
+ customElements.define("qti-gap-match-interaction", pt);
2639
+ class di extends g {
2640
+ connectedCallback() {
2641
+ super.connectedCallback(), this.setAttribute("slot", "qti-gap-text");
2642
+ }
2643
+ render() {
2644
+ return h`<slot></slot>`;
2645
+ }
2646
+ }
2647
+ customElements.define("qti-gap-text", di);
2648
+ class pi extends g {
2649
+ render() {
2650
+ return h` <slot name="qti-gap-text"></slot>`;
2651
+ }
2652
+ }
2653
+ customElements.define("qti-gap", pi);
2654
+ function ke(n, e, t, s) {
2655
+ switch (n) {
2656
+ case "circle":
2657
+ {
2658
+ const [i, r, o] = e, a = i / t.width * 100, c = r / t.height * 100, l = o / t.width * 100;
2659
+ s.style.left = a - l + "%", s.style.top = c - l + "%", s.style.width = s.style.height = 4 * l + "px", s.style.clipPath = "circle(50% at 50% 50%)";
2660
+ }
2661
+ break;
2662
+ case "rect":
2663
+ {
2664
+ const [i, r, o, a] = e, c = i / t.width * 100, l = r / t.height * 100, f = o / t.width * 100, p = a / t.height * 100;
2665
+ s.style.left = c + "%", s.style.top = l + "%", s.style.width = f - c + "%", s.style.height = p - l + "%";
2666
+ }
2667
+ break;
2668
+ case "poly":
2669
+ {
2670
+ const i = e.reduce((b, Ct, Le, xt) => {
2671
+ if (Le % 2 === 1) {
2672
+ const At = b.pop();
2673
+ b[b.length] = { x: At, y: xt[Le] };
2674
+ } else
2675
+ b.push(Ct);
2676
+ return b;
2677
+ }, []), r = Math.min(...i.map((b) => b.x)), o = Math.max(...i.map((b) => b.x)), a = Math.min(...i.map((b) => b.y)), c = Math.max(...i.map((b) => b.y)), l = r / t.width * 100, f = a / t.height * 100, p = o / t.width * 100, u = c / t.height * 100;
2678
+ s.style.left = r / t.width * 100 + "%", s.style.top = a / t.height * 100 + "%", s.style.width = p - l + "%", s.style.height = u - f + "%";
2679
+ const C = i.map((b) => ({
2680
+ x: (b.x - r) / (o - r) * 100,
2681
+ y: (b.y - a) / (c - a) * 100
2682
+ })).map((b) => Math.round(b.x) + "% " + Math.round(b.y) + "%").join(",");
2683
+ s.style.clipPath = `polygon(${C})`;
2684
+ }
2685
+ break;
2686
+ }
2687
+ }
2688
+ class ut extends R {
2689
+ render() {
2690
+ return h`
2691
+ <slot name="prompt"></slot>
2692
+ <!-- slot for the prompt -->
2693
+ <slot></slot>
2694
+ <!-- slot for the image and hotspots -->
2695
+ `;
2696
+ }
2697
+ positionHotspotOnRegister(e) {
2698
+ const t = this.querySelector("img"), s = e.target, i = s.getAttribute("coords"), r = s.getAttribute("shape"), o = i.split(",").map((a) => parseInt(a));
2699
+ ke(r, o, t, s);
2700
+ }
2701
+ connectedCallback() {
2702
+ super.connectedCallback(), this.addEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2703
+ }
2704
+ disconnectedCallback() {
2705
+ super.disconnectedCallback(), this.removeEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2706
+ }
2707
+ }
2708
+ ut.styles = [
2709
+ _`
2710
+ slot:not([name='prompt']) {
2711
+ position: relative; /* qti-hotspot-choice relative to the slot */
2712
+ display: block;
2713
+ width: fit-content; /* hotspots not stretching further if image is at max size */
2714
+ }
2715
+ ::slotted(img) {
2716
+ /* image not selectable anymore */
2717
+ pointer-events: none;
2718
+ user-select: none;
2719
+ }
2720
+ `
2721
+ ];
2722
+ customElements.define("qti-graphic-associate-interaction", ut);
2723
+ class mt extends le(
2724
+ $,
2725
+ "qti-gap-img",
2726
+ !1,
2727
+ "qti-associable-hotspot"
2728
+ ) {
2729
+ render() {
2730
+ return h` <slot></slot>
2731
+ <slot name="qti-gap-img"></slot>`;
2732
+ }
2733
+ positionHotspotOnRegister(e) {
2734
+ const t = e.target, s = t.getAttribute("coords"), i = t.getAttribute("shape"), r = s.split(",").map((o) => parseInt(o));
2735
+ switch (i) {
2736
+ case "circle":
2737
+ {
2738
+ const [o, a, c] = r;
2739
+ t.style.left = o - c + "px", t.style.top = a - c + "px", t.style.width = t.style.height = 2 * c + "px";
2740
+ }
2741
+ break;
2742
+ case "rect":
2743
+ {
2744
+ const [o, a, c, l] = r;
2745
+ t.style.left = o + "px", t.style.top = a + "px", t.style.width = c - o + "px", t.style.height = l - a + "px";
2746
+ }
2747
+ break;
2748
+ }
2749
+ }
2750
+ connectedCallback() {
2751
+ super.connectedCallback(), this.addEventListener(m.ON_REGISTER_HOTSPOT, this.positionHotspotOnRegister);
2752
+ }
2753
+ disconnectedCallback() {
2754
+ super.disconnectedCallback(), this.removeEventListener(m.ON_REGISTER_HOTSPOT, this.positionHotspotOnRegister);
2755
+ }
2756
+ }
2757
+ mt.styles = _`
2758
+ slot[name="qti-gap-img"] {
2759
+ display: flex;
2760
+ gap: 1rem;
2761
+ }
2762
+ `;
2763
+ customElements.define("qti-graphic-gap-match-interaction", mt);
2764
+ class ft extends R {
2765
+ render() {
2766
+ return h`
2767
+ <slot name="prompt"></slot>
2768
+ <!-- slot for the prompt -->
2769
+ <slot></slot>
2770
+ <!-- slot for the image and hotspots -->
2771
+ `;
2772
+ }
2773
+ setHotspotOrder(e) {
2774
+ const { identifier: t } = e.detail, s = this._choiceElements.find((r) => r.getAttribute("identifier") === t), i = this._choiceElements.length;
2775
+ if (!this.choiceOrdering) {
2776
+ if (this.choiceOrdering = !0, s.order == null) {
2777
+ if (this._choiceElements.filter((r) => r.order > 0).length >= i) {
2778
+ this.choiceOrdering = !1;
2779
+ return;
2780
+ }
2781
+ s.order = this._choiceElements.filter((r) => !!r.order).length + 1, this.choiceOrdering = !1;
2782
+ return;
2783
+ } else
2784
+ this._choiceElements.forEach((r) => (r.order > r.order && r.order--, r)), s.order = null;
2785
+ this.choiceOrdering = !1;
2786
+ }
2787
+ }
2788
+ positionHotspotOnRegister(e) {
2789
+ const t = this.querySelector("img"), s = e.target, i = s.getAttribute("coords"), r = s.getAttribute("shape"), o = i.split(",").map((a) => parseInt(a));
2790
+ ke(r, o, t, s);
2791
+ }
2792
+ connectedCallback() {
2793
+ super.connectedCallback(), this.addEventListener(m.ON_CHOICE_ELEMENT_SELECTED, this.setHotspotOrder), this.addEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2794
+ }
2795
+ disconnectedCallback() {
2796
+ super.disconnectedCallback(), this.removeEventListener(m.ON_CHOICE_ELEMENT_SELECTED, this.setHotspotOrder), this.removeEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2797
+ }
2798
+ }
2799
+ ft.styles = [
2800
+ _`
2801
+ slot:not([name='prompt']) {
2802
+ position: relative; /* qti-hotspot-choice relative to the slot */
2803
+ display: block;
2804
+ width: fit-content; /* hotspots not stretching further if image is at max size */
2805
+ }
2806
+ ::slotted(img) {
2807
+ /* image not selectable anymore */
2808
+ pointer-events: none;
2809
+ user-select: none;
2810
+ }
2811
+ `
2812
+ ];
2813
+ customElements.define("qti-graphic-order-interaction", ft);
2814
+ class gt extends R {
2815
+ render() {
2816
+ return h`
2817
+ <slot name="prompt"></slot>
2818
+ <!-- slot for the prompt -->
2819
+ <slot></slot>
2820
+ <!-- slot for the image and hotspots -->
2821
+ `;
2822
+ }
2823
+ positionHotspotOnRegister(e) {
2824
+ const t = this.querySelector("img"), s = e.target, i = s.getAttribute("coords"), r = s.getAttribute("shape"), o = i.split(",").map((a) => parseInt(a));
2825
+ ke(r, o, t, s);
2826
+ }
2827
+ connectedCallback() {
2828
+ super.connectedCallback(), this.addEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2829
+ }
2830
+ disconnectedCallback() {
2831
+ super.disconnectedCallback(), this.removeEventListener(m.ON_REGISTER_CHOICE, this.positionHotspotOnRegister);
2832
+ }
2833
+ }
2834
+ gt.styles = [
2835
+ _`
2836
+ slot:not([name='prompt']) {
2837
+ position: relative; /* qti-hotspot-choice relative to the slot */
2838
+ display: block;
2839
+ width: fit-content; /* hotspots not stretching further if image is at max size */
2840
+ }
2841
+ ::slotted(img) {
2842
+ /* image not selectable anymore */
2843
+ pointer-events: none;
2844
+ user-select: none;
2845
+ }
2846
+ `
2847
+ ];
2848
+ customElements.define("qti-hotspot-interaction", gt);
2849
+ var ui = Object.defineProperty, mi = Object.getOwnPropertyDescriptor, fi = (n, e, t, s) => {
2850
+ for (var i = s > 1 ? void 0 : s ? mi(e, t) : e, r = n.length - 1, o; r >= 0; r--)
2851
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
2852
+ return s && i && ui(e, t, i), i;
2853
+ };
2854
+ class De extends S {
2855
+ }
2856
+ De.styles = _`
2857
+ :host {
2858
+ position: absolute;
2859
+ }
2860
+ `;
2861
+ fi([
2862
+ d({ attribute: "aria-ordervalue", type: Number, reflect: !0 })
2863
+ ], De.prototype, "order", 2);
2864
+ customElements.define("qti-hotspot-choice", De);
2865
+ const ge = _`
2866
+ .notification {
2867
+ position: absolute;
2868
+ z-index: 100000;
2869
+ top: 0;
2870
+ bottom: 0;
2871
+ right: 0;
2872
+ left: 0;
2873
+ /* background: repeating-linear-gradient(45deg, #606cbc00, #606cbc00 10px, #4652980f 10px, #4652980f 20px); */
2874
+ }
2875
+ .notification:after {
2876
+ position: absolute;
2877
+ right: 1rem;
2878
+ top: 1rem;
2879
+ background-color: #222222;
2880
+ color: #dddddd;
2881
+ font-size: 14px;
2882
+ width: fit-content;
2883
+ padding: 0.4rem 0.6rem;
2884
+ border-radius: 99999px;
2885
+ content: 'preview not interactive';
2886
+ }
2887
+ `;
2888
+ class bt extends le(
2889
+ g,
2890
+ "qti-simple-match-set:first-of-type qti-simple-associable-choice",
2891
+ !1,
2892
+ "qti-simple-match-set:last-of-type qti-simple-associable-choice"
2893
+ ) {
2894
+ render() {
2895
+ return h`
2896
+ <slot name="prompt"></slot>
2897
+ <slot></slot>`;
2898
+ }
2899
+ }
2900
+ bt.styles = [ge];
2901
+ customElements.define("qti-match-interaction", bt);
2902
+ class vt extends A {
2903
+ constructor() {
2904
+ super();
2905
+ }
2906
+ reset() {
2907
+ }
2908
+ validate() {
2909
+ return !0;
2910
+ }
2911
+ set response(e) {
2912
+ }
2913
+ static get properties() {
2914
+ return {
2915
+ ...A.properties,
2916
+ step: {
2917
+ type: Number,
2918
+ attribute: "step",
2919
+ default: 10
2920
+ }
2921
+ };
2922
+ }
2923
+ render() {
2924
+ return h`
2925
+ <slot name="prompt"></slot>
2926
+ <slot></slot>`;
2927
+ }
2928
+ connectedCallback() {
2929
+ super.connectedCallback();
2930
+ }
2931
+ }
2932
+ vt.styles = [ge, _``];
2933
+ customElements.define("qti-media-interaction", vt);
2934
+ class Me extends le($, "qti-simple-choice", !0, "drop-list") {
2935
+ static get properties() {
2936
+ return {
2937
+ _classNames: {
2938
+ type: String,
2939
+ attribute: "class"
2940
+ },
2941
+ _orientation: {
2942
+ type: String,
2943
+ attribute: "orientation"
2944
+ }
2945
+ };
2946
+ }
2947
+ render() {
2948
+ return h` <slot name="prompt"> </slot>
2949
+ <div class=${`container ${this._classNames}`}>
2950
+ <slot class=${this._orientation === "vertical" ? "ver" : "hor"}> </slot>
2951
+ <div class=${this._orientation === "vertical" ? "ver" : "hor"}>
2952
+ ${this.childrenMap.map((e, t) => h`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
2953
+ </div>
2954
+ </div>`;
2955
+ }
2956
+ connectedCallback() {
2957
+ super.connectedCallback(), this.childrenMap = Array.from(this.querySelectorAll("qti-simple-choice")), this.childrenMap.forEach((e) => e.setAttribute("part", "qti-simple-choice"));
2958
+ }
2959
+ }
2960
+ Me.layoutClass = [
2961
+ "qti-choices-top",
2962
+ "qti-choices-bottom",
2963
+ "qti-choices-left",
2964
+ "qti-choices-right"
2965
+ ];
2966
+ Me.styles = [
2967
+ ge,
2968
+ _`
2969
+ .hor {
2970
+ display: grid;
2971
+ gap: var(--qti-gap, 2px);
2972
+ grid-auto-flow: column;
2973
+ grid-auto-columns: 1fr;
2974
+ }
2975
+ .ver {
2976
+ width:50%;
2977
+ display: grid;
2978
+ gap: var(--qti-gap, 2px);
2979
+ grid-auto-flow: row;
2980
+ grid-auto-columns: 1fr;
2981
+ }
2982
+ .container {
2983
+ display: flex;
2984
+ gap: var(--qti-gap, 2px);
2985
+ }
2986
+ .qti-choices-top {
2987
+ flex-direction: column;
2988
+ }
2989
+ .qti-choices-bottom {
2990
+ flex-direction: column-reverse;
2991
+ }
2992
+ .qti-choices-left {
2993
+ flex-direction: row;
2994
+ }
2995
+ .qti-choices-right {
2996
+ flex-direction: row-reverse;
2997
+ }
2998
+ drop-list:empty::before {
2999
+ content: 'drop here';
3000
+ color: var(--qti-placeholder-text);
3001
+ }
3002
+ `
3003
+ ];
3004
+ customElements.define("qti-order-interaction", Me);
3005
+ class _t extends R {
3006
+ constructor() {
3007
+ super();
3008
+ }
3009
+ render() {
3010
+ return h`<slot></slot>
3011
+ <div class="notification"></div>`;
3012
+ }
3013
+ connectedCallback() {
3014
+ super.connectedCallback();
3015
+ }
3016
+ disconnectedCallback() {
3017
+ super.disconnectedCallback();
3018
+ }
3019
+ }
3020
+ _t.styles = [ge];
3021
+ customElements.define("qti-select-point-interaction", _t);
3022
+ var gi = Object.defineProperty, bi = Object.getOwnPropertyDescriptor, N = (n, e, t, s) => {
3023
+ for (var i = s > 1 ? void 0 : s ? bi(e, t) : e, r = n.length - 1, o; r >= 0; r--)
3024
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
3025
+ return s && i && gi(e, t, i), i;
3026
+ };
3027
+ class O extends A {
3028
+ constructor() {
3029
+ super(...arguments), this.stepLabel = !1, this.reverse = !1, this._handleDisabledChange = (e, t) => {
3030
+ }, this._handleReadonlyChange = (e, t) => {
3031
+ };
3032
+ }
3033
+ set min(e) {
3034
+ this._min = e, this.style.setProperty("--min", `${this._min}`);
3035
+ }
3036
+ get min() {
3037
+ return this._min;
3038
+ }
3039
+ set max(e) {
3040
+ this._max = e, this.style.setProperty("--max", `${this._max}`);
3041
+ }
3042
+ get max() {
3043
+ return this._max;
3044
+ }
3045
+ set step(e) {
3046
+ this._step = e, this.style.setProperty("--step", `${this._step}`);
3047
+ }
3048
+ get step() {
3049
+ return this._step;
3050
+ }
3051
+ reset() {
3052
+ }
3053
+ validate() {
3054
+ return !0;
3055
+ }
3056
+ set response(e) {
3057
+ this.value = e;
3058
+ }
3059
+ render() {
3060
+ this.value < this.min && (this.value = this.min), this.value > this.max && (this.value = this.max);
3061
+ const e = (this.value - this.min) / (this.max - this.min) * 100;
3062
+ return h`<slot name="prompt"></slot>
3063
+ <div id="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove} part="rail">
3064
+ <div id="knob" part="knob" style="left:${e}%"></div>
3065
+ </div>`;
3066
+ }
3067
+ connectedCallback() {
3068
+ super.connectedCallback(), this.step = 1, this.setAttribute("tabindex", "0"), this.setAttribute("role", "slider");
3069
+ }
3070
+ _onTouchMove(e) {
3071
+ const t = (o) => {
3072
+ const { x: a } = this.getPositionFromEvent(o), c = a - this._rail.getBoundingClientRect().left - document.documentElement.scrollLeft;
3073
+ this.calculateValue(c), o.stopPropagation();
3074
+ }, s = () => {
3075
+ document.removeEventListener("touchmove", t), document.removeEventListener("touchend", s), this.saveResponse({ base: { float: this.value } });
3076
+ };
3077
+ document.addEventListener("touchmove", t), document.addEventListener("touchend", s);
3078
+ const { x: i } = this.getPositionFromEvent(e), r = i - this._rail.getBoundingClientRect().left - document.documentElement.scrollLeft;
3079
+ this.calculateValue(r), e.stopPropagation();
3080
+ }
3081
+ _onMouseDown(e) {
3082
+ const t = (r) => {
3083
+ const o = r.pageX - this._rail.getBoundingClientRect().left - document.documentElement.scrollLeft;
3084
+ this.calculateValue(o), r.preventDefault(), r.stopPropagation();
3085
+ }, s = () => {
3086
+ document.removeEventListener("mousemove", t), document.removeEventListener("mouseup", s), this.saveResponse({ base: { float: this.value } });
3087
+ };
3088
+ document.addEventListener("mousemove", t), document.addEventListener("mouseup", s);
3089
+ const i = e.pageX - this._rail.getBoundingClientRect().left - document.documentElement.scrollLeft;
3090
+ this.calculateValue(i), e.preventDefault(), e.stopPropagation();
3091
+ }
3092
+ /** calculateValue gets x position and compares this with the total width in pixels */
3093
+ calculateValue(e) {
3094
+ const t = this.min + (this.max - this.min) * e / this.offsetWidth, s = this.min + Math.round((t - this.min) / this._step) * this._step;
3095
+ this.value = s;
3096
+ }
3097
+ getPositionFromEvent(e) {
3098
+ let t;
3099
+ if (e.type == "touchstart" || e.type == "touchmove" || e.type == "touchend" || e.type == "touchcancel") {
3100
+ const s = typeof e.originalEvent > "u" ? e : e.originalEvent, i = s.touches[0] || s.changedTouches[0];
3101
+ t = {
3102
+ x: i.pageX,
3103
+ y: i.pageY
3104
+ };
3105
+ } else
3106
+ (e.type == "mousedown" || e.type == "mouseup" || e.type == "mousemove" || e.type == "mouseover" || e.type == "mouseout" || e.type == "mouseenter" || e.type == "mouseleave") && (t = {
3107
+ x: e.clientX,
3108
+ y: e.clientY
3109
+ });
3110
+ return t;
3111
+ }
3112
+ }
3113
+ O.styles = [_``];
3114
+ N([
3115
+ pe("#knob")
3116
+ ], O.prototype, "_knob", 2);
3117
+ N([
3118
+ pe("#rail")
3119
+ ], O.prototype, "_rail", 2);
3120
+ N([
3121
+ d({ type: Number })
3122
+ ], O.prototype, "value", 2);
3123
+ N([
3124
+ d({ type: Boolean, attribute: "step-label" })
3125
+ ], O.prototype, "stepLabel", 2);
3126
+ N([
3127
+ d({ type: Boolean })
3128
+ ], O.prototype, "reverse", 2);
3129
+ N([
3130
+ d({ type: Number, attribute: "lower-bound" })
3131
+ ], O.prototype, "min", 1);
3132
+ N([
3133
+ d({ type: Number, attribute: "upper-bound" })
3134
+ ], O.prototype, "max", 1);
3135
+ N([
3136
+ d({ type: Number, attribute: "step" })
3137
+ ], O.prototype, "step", 1);
3138
+ N([
3139
+ E("disabled", { waitUntilFirstUpdate: !0 })
3140
+ ], O.prototype, "_handleDisabledChange", 2);
3141
+ N([
3142
+ E("readonly", { waitUntilFirstUpdate: !0 })
3143
+ ], O.prototype, "_handleReadonlyChange", 2);
3144
+ customElements.define("qti-slider-interaction", O);
3145
+ class yt extends g {
3146
+ constructor() {
3147
+ super(...arguments), this.render = () => h`${this.value}`;
3148
+ }
3149
+ levenshtein(e, t) {
3150
+ let s;
3151
+ if (e.length === 0)
3152
+ return t.length;
3153
+ if (t.length === 0)
3154
+ return e.length;
3155
+ e.length > t.length && (s = e, e = t, t = s);
3156
+ const i = e.length, r = t.length, o = Array(i);
3157
+ let a, c, l;
3158
+ for (a = 0; a <= i; a++)
3159
+ o[a] = a;
3160
+ for (a = 1; a <= r; a++) {
3161
+ for (l = a, c = 1; c <= i; c++)
3162
+ s = o[c - 1], o[c - 1] = l, l = Math.min(s + (t[a - 1] !== e[c - 1]), l + 1, o[c] + 1);
3163
+ o[c - 1] = l;
3164
+ }
3165
+ return l;
3166
+ }
3167
+ calculate() {
3168
+ const e = this.firstElementChild, t = this.lastElementChild, s = e.calculate(), i = t.calculate();
3169
+ return this.value = 100 - this.levenshtein(s.toString().trim(), i.toString().trim()) / i.toString().length * 100, this.value;
3170
+ }
3171
+ }
3172
+ yt.properties = { value: {} };
3173
+ customElements.define("qti-custom-operator-levenshtein", yt);
3174
+ class vi extends g {
3175
+ render() {
3176
+ return h``;
3177
+ }
3178
+ calculate() {
3179
+ const t = this.firstElementChild.calculate()?.toString();
3180
+ return t ? t.replace(/[^0-9$.,]/g, "") : "";
3181
+ }
3182
+ }
3183
+ customElements.define("qti-custom-operator-numeric", vi);
3184
+ class Et extends g {
3185
+ constructor() {
3186
+ super(...arguments), this.render = () => h`${this.value}`;
3187
+ }
3188
+ calculate() {
3189
+ let e;
3190
+ const s = this.firstElementChild.calculate()?.toString();
3191
+ return this.value = s ? this.parseNumber(s, e) : "", this.value;
3192
+ }
3193
+ parseNumber(e, t = navigator.languages) {
3194
+ const s = Intl.NumberFormat(t).format(1.1), i = new RegExp(`[^-+0-9${s.charAt(1)}]`, "g"), o = e.replace(i, "").replace(s.charAt(1), ".");
3195
+ return parseFloat(o);
3196
+ }
3197
+ }
3198
+ Et.properties = { value: {} };
3199
+ customElements.define("qti-custom-operator-parse-numeric-nl", Et);
3200
+ class _i extends g {
3201
+ render() {
3202
+ return h``;
3203
+ }
3204
+ calculate() {
3205
+ const t = this.firstElementChild.calculate()?.toString();
3206
+ return t ? t.replace(/ /g, "") : "";
3207
+ }
3208
+ }
3209
+ customElements.define("qti-custom-operator-remove-spaces", _i);
3210
+ class yi extends g {
3211
+ render() {
3212
+ return h``;
3213
+ }
3214
+ calculate() {
3215
+ return this.firstElementChild.calculate().toString().trim();
3216
+ }
3217
+ }
3218
+ customElements.define("qti-custom-operator-trim", yi);
3219
+ const K = (n, e) => {
3220
+ class t extends n {
3221
+ _dispatch() {
3222
+ this.dispatchEvent(
3223
+ new CustomEvent(e, {
3224
+ composed: !0,
3225
+ bubbles: !0,
3226
+ detail: +this.getAttribute("index")
3227
+ })
3228
+ );
3229
+ }
3230
+ connectedCallback() {
3231
+ super.connectedCallback(), this.addEventListener("click", this._dispatch);
3232
+ }
3233
+ disconnectedCallback() {
3234
+ super.disconnectedCallback(), this.removeEventListener("click", this._dispatch);
3235
+ }
3236
+ }
3237
+ return t;
3238
+ };
3239
+ customElements.define(
3240
+ "qti-test-next",
3241
+ class extends K(g, "on-next-item") {
3242
+ constructor() {
3243
+ super(...arguments), this.render = () => h`<slot></slot>`;
3244
+ }
3245
+ }
3246
+ );
3247
+ customElements.define(
3248
+ "qti-test-item",
3249
+ class extends K(g, "on-request-item") {
3250
+ constructor() {
3251
+ super(...arguments), this.render = () => h`<slot></slot>`;
3252
+ }
3253
+ }
3254
+ );
3255
+ customElements.define(
3256
+ "qti-test-prev",
3257
+ class extends K(g, "on-prev-item") {
3258
+ constructor() {
3259
+ super(...arguments), this.render = () => h`<slot></slot>`;
3260
+ }
3261
+ }
3262
+ );
3263
+ customElements.define(
3264
+ "qti-test-check",
3265
+ class extends K(g, "on-check-item") {
3266
+ constructor() {
3267
+ super(...arguments), this.render = () => h`<slot></slot>`;
3268
+ }
3269
+ }
3270
+ );
3271
+ customElements.define(
3272
+ "qti-test-score",
3273
+ class extends K(g, "on-score-item") {
3274
+ constructor() {
3275
+ super(...arguments), this.render = () => h`<slot></slot>`;
3276
+ }
3277
+ }
3278
+ );
3279
+ customElements.define(
3280
+ "qti-test-show-correct",
3281
+ class extends K(g, "on-show-correct") {
3282
+ constructor() {
3283
+ super(...arguments), this.render = () => h`<slot></slot>`;
3284
+ }
3285
+ }
3286
+ );
3287
+ var Ei = Object.defineProperty, Ci = Object.getOwnPropertyDescriptor, w = (n, e, t, s) => {
3288
+ for (var i = s > 1 ? void 0 : s ? Ci(e, t) : e, r = n.length - 1, o; r >= 0; r--)
3289
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
3290
+ return s && i && Ei(e, t, i), i;
3291
+ };
3292
+ const k = {
3293
+ ON_ITEM_WAS_FINISHED: "onItemWasFinished",
3294
+ ON_NO_RESPONSE_ON_SUBMIT: "onNoResponseOnSubmit",
3295
+ ON_REQUEST_ITEM: "onRequestItem",
3296
+ ON_TEST_FINISHED: "onTestFinished",
3297
+ ON_ITEM_READY: "onItemReady"
3298
+ };
3299
+ var xi = /* @__PURE__ */ ((n) => (n.linear = "linear", n.nonlinear = "nonlinear", n))(xi || {}), Ai = /* @__PURE__ */ ((n) => (n.individual = "individual", n.simultaneous = "simultaneous", n))(Ai || {});
3300
+ let x = class extends g {
3301
+ constructor() {
3302
+ super(...arguments), this.disabled = !1, this.readonly = !1, this._navigationMode = "nonlinear", this._submissionMode = "simultaneous", this.items = [], this.itemIndex = 0, this.provider = new os(this, Ae, {
3303
+ log: (n) => {
3304
+ console.log(`[my-app] ${n}`);
3305
+ },
3306
+ view: "candidate"
3307
+ });
3308
+ }
3309
+ handleNavigationModeChange(n, e) {
3310
+ this.prevButton.style.visibility = e === "linear" ? "hidden" : "visible";
3311
+ }
3312
+ handleItemIndexChange(n, e) {
3313
+ this.emit(k.ON_REQUEST_ITEM, { detail: e });
3314
+ }
3315
+ set qtiContext(n) {
3316
+ this.provider.value.view = n.view, this.provider.updateObservers();
3317
+ }
3318
+ set itemXML(n) {
3319
+ this._itemRef && this._itemRef.remove(), this.insertAdjacentHTML("afterbegin", n);
3320
+ }
3321
+ set manualOutcomeValue(n) {
3322
+ this._itemRef.setOutcomeValue("SCORE", n);
3323
+ }
3324
+ set itemResponse(n) {
3325
+ this._itemRef && (this._itemRef.responses = n, this._navigationMode === "linear" && (this._itemRef.style.filter = "blur(5px)", this._itemRef.setAttribute("disabled", ""), this.dispatchEvent(new CustomEvent(k.ON_ITEM_WAS_FINISHED))));
3326
+ }
3327
+ _onCheckItem() {
3328
+ return this._itemRef.validateResponses() ? (this._itemRef.processResponse(), !0) : !1;
3329
+ }
3330
+ _onScoreItem() {
3331
+ this._onCheckItem() && this._itemRef.processResponse();
3332
+ }
3333
+ _onPrevItem() {
3334
+ this.itemIndex > 0 && this.emit(k.ON_REQUEST_ITEM, { detail: this.itemIndex - 1 });
3335
+ }
3336
+ _onNextItem() {
3337
+ if (this._navigationMode === "linear" && !this._itemRef.validateResponses()) {
3338
+ this.dispatchEvent(new CustomEvent(k.ON_NO_RESPONSE_ON_SUBMIT));
3339
+ return;
3340
+ }
3341
+ this.itemIndex < this.items.length - 1 ? this.emit(k.ON_REQUEST_ITEM, { detail: this.itemIndex + 1 }) : this.dispatchEvent(new CustomEvent(k.ON_TEST_FINISHED));
3342
+ }
3343
+ _onShowCorrect() {
3344
+ this._itemRef.showCorrectResponse();
3345
+ }
3346
+ _onRequestItem({ detail: n }) {
3347
+ this.emit(k.ON_REQUEST_ITEM, { detail: n });
3348
+ }
3349
+ _handleSlotchange(n) {
3350
+ const e = this.querySelector("qti-assessment-item");
3351
+ e && (this._itemRef = e, this.disabled && this._itemRef.setAttribute("disabled", ""), this.readonly && this._itemRef.setAttribute("readonly", ""), this.emit(k.ON_ITEM_READY, { detail: e }));
3352
+ }
3353
+ render() {
3354
+ return h`
3355
+ <slot
3356
+ @slotchange=${this._handleSlotchange}
3357
+ @on-prev-item=${this._onPrevItem}
3358
+ @on-next-item=${this._onNextItem}
3359
+ @on-check-item=${this._onCheckItem}
3360
+ @on-score-item=${this._onScoreItem}
3361
+ @on-request-item=${this._onRequestItem}
3362
+ @on-show-correct=${this._onShowCorrect}
3363
+ >
3364
+ </slot>
3365
+ `;
3366
+ }
3367
+ emit(n, e) {
3368
+ const t = new CustomEvent(n, {
3369
+ bubbles: !0,
3370
+ cancelable: !1,
3371
+ composed: !0,
3372
+ detail: {},
3373
+ ...e
3374
+ });
3375
+ this.dispatchEvent(t);
3376
+ }
3377
+ };
3378
+ w([
3379
+ pe("qti-test-prev")
3380
+ ], x.prototype, "prevButton", 2);
3381
+ w([
3382
+ pe("qti-test-next")
3383
+ ], x.prototype, "nextButton", 2);
3384
+ w([
3385
+ d({ type: Boolean })
3386
+ ], x.prototype, "disabled", 2);
3387
+ w([
3388
+ d({ type: Boolean })
3389
+ ], x.prototype, "readonly", 2);
3390
+ w([
3391
+ d({ type: String, attribute: "navigation-mode" })
3392
+ ], x.prototype, "_navigationMode", 2);
3393
+ w([
3394
+ E("_navigationMode", { waitUntilFirstUpdate: !0 })
3395
+ ], x.prototype, "handleNavigationModeChange", 1);
3396
+ w([
3397
+ d({ type: String, attribute: "submission-mode" })
3398
+ ], x.prototype, "_submissionMode", 2);
3399
+ w([
3400
+ d()
3401
+ ], x.prototype, "items", 2);
3402
+ w([
3403
+ d({ type: Number, attribute: "item-index", reflect: !0 })
3404
+ ], x.prototype, "itemIndex", 2);
3405
+ w([
3406
+ E("itemIndex", { waitUntilFirstUpdate: !0 })
3407
+ ], x.prototype, "handleItemIndexChange", 1);
3408
+ w([
3409
+ Ee()
3410
+ ], x.prototype, "_itemRef", 2);
3411
+ x = w([
3412
+ T("qti-test")
3413
+ ], x);
3414
+ const $i = (n, e) => {
3415
+ class t extends n {
3416
+ constructor() {
3417
+ super(...arguments), this.scale = 1, this.ro = new ResizeObserver((i) => {
3418
+ for (const r of i)
3419
+ this.fitToParent(r.contentRect.width);
3420
+ });
3421
+ }
3422
+ connectedCallback() {
3423
+ super.connectedCallback(), this.ro.observe(this), this.fitToParent();
3424
+ }
3425
+ static get properties() {
3426
+ return {
3427
+ scales: {
3428
+ type: Boolean,
3429
+ reflect: !0
3430
+ }
3431
+ };
3432
+ }
3433
+ updated(i) {
3434
+ i.forEach((r, o) => {
3435
+ switch (o) {
3436
+ case "scales":
3437
+ this.scales && this.fitToParent();
3438
+ break;
3439
+ }
3440
+ });
3441
+ }
3442
+ fitToParent(i = this.clientWidth) {
3443
+ const r = this.querySelector(e);
3444
+ if (r) {
3445
+ const o = i / r.clientWidth;
3446
+ this.scale = o, this.marginY = -r.clientHeight * (1 - o) + "px", requestAnimationFrame(() => {
3447
+ r.style.transform = `scale(${this.scale})`, r.style.margin = `0 0 ${this.marginY} 0`;
3448
+ });
3449
+ }
3450
+ }
3451
+ }
3452
+ return t;
3453
+ };
3454
+ var qi = Object.defineProperty, Oi = Object.getOwnPropertyDescriptor, j = (n, e, t, s) => {
3455
+ for (var i = s > 1 ? void 0 : s ? Oi(e, t) : e, r = n.length - 1, o; r >= 0; r--)
3456
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
3457
+ return s && i && qi(e, t, i), i;
3458
+ };
3459
+ class P extends $i(g, "qti-assessment-item") {
3460
+ constructor() {
3461
+ super(...arguments), this.disabled = !1, this.readonly = !1, this.processResponse = () => this._item?.processResponse(), this.validateResponses = () => this._item ? this._item.validateResponses() : !1, this.resetInteractions = () => this._item?.resetInteractions(), this.render = () => h`<slot @slotchange=${this.handleSlotchange}></slot>`;
3462
+ }
3463
+ handleDisabledChange(e, t) {
3464
+ t && this._item?.setAttribute("disabled", ""), !t && this._item?.removeAttribute("disabled");
3465
+ }
3466
+ handleReadonlyChange(e, t) {
3467
+ t && this._item?.setAttribute("readonly", ""), !t && this._item?.removeAttribute("readonly");
3468
+ }
3469
+ handleResponsesChange(e, t) {
3470
+ this._item && (this._item.responses = t);
3471
+ }
3472
+ handleSlotchange(e) {
3473
+ const t = e.target.assignedNodes({ flatten: !0 });
3474
+ this._item = null, t.forEach((s) => {
3475
+ s.nodeName == "QTI-ASSESSMENT-ITEM" && (this._item = s, this.disabled && this._item.setAttribute("disabled", ""), this.readonly && this._item.setAttribute("readonly", ""), this.responses && (this._item.responses = this.responses));
3476
+ });
3477
+ }
3478
+ }
3479
+ P.styles = _`
3480
+ :host {
3481
+ display: block; /* necessary to calculate scaling position */
3482
+ width: 100%;
3483
+ height: 100%;
3484
+ overflow: auto;
3485
+ }
3486
+ ::slotted(qti-assessment-item) {
3487
+ display: block; /* necessary to calculate scaling position */
3488
+ width: 100%;
3489
+ }
3490
+ :host([scales]) ::slotted(qti-assessment-item) {
3491
+ aspect-ratio: 4 / 3;
3492
+ width: 1024px;
3493
+ transform-origin: 0 0;
3494
+ }
3495
+ `;
3496
+ j([
3497
+ d({ type: Boolean, reflect: !0 })
3498
+ ], P.prototype, "disabled", 2);
3499
+ j([
3500
+ E("disabled", { waitUntilFirstUpdate: !0 })
3501
+ ], P.prototype, "handleDisabledChange", 1);
3502
+ j([
3503
+ d({ type: Boolean, reflect: !0 })
3504
+ ], P.prototype, "readonly", 2);
3505
+ j([
3506
+ E("readonly", { waitUntilFirstUpdate: !0 })
3507
+ ], P.prototype, "handleReadonlyChange", 1);
3508
+ j([
3509
+ d({ type: Object, reflect: !0 })
3510
+ ], P.prototype, "responses", 2);
3511
+ j([
3512
+ E("responses", { waitUntilFirstUpdate: !0 })
3513
+ ], P.prototype, "handleResponsesChange", 1);
3514
+ j([
3515
+ Ee()
3516
+ ], P.prototype, "_item", 2);
3517
+ customElements.define("qti-item", P);
3518
+ var wi = Object.defineProperty, Si = Object.getOwnPropertyDescriptor, Z = (n, e, t, s) => {
3519
+ for (var i = s > 1 ? void 0 : s ? Si(e, t) : e, r = n.length - 1, o; r >= 0; r--)
3520
+ (o = n[r]) && (i = (s ? o(e, t, i) : o(i)) || i);
3521
+ return s && i && wi(e, t, i), i;
3522
+ };
3523
+ let L = class extends $ {
3524
+ constructor() {
3525
+ super(...arguments), this.disabled = !1, this.readonly = !1, this.logger = new it(
3526
+ this,
3527
+ Ae,
3528
+ (n) => this.style.display = n.view === "scorer" ? "block" : "none",
3529
+ !0
3530
+ );
3531
+ }
3532
+ textChanged(n) {
3533
+ if (this.disabled || this.readonly)
3534
+ return;
3535
+ const e = n.target;
3536
+ this.value = e.value, this.closest("qti-test").manualOutcomeValue = this.value;
3537
+ }
3538
+ render() {
3539
+ return h`<input
3540
+ part="input"
3541
+ type="number"
3542
+ spellcheck="false"
3543
+ autocomplete="off"
3544
+ @keyup=${this.textChanged}
3545
+ @change=${this.textChanged}
3546
+ placeholder="score"
3547
+ min=${this.min}
3548
+ max=${this.max}
3549
+ .value=${this.value}
3550
+ size="10"
3551
+ ?disabled=${this.disabled}
3552
+ ?readonly=${this.readonly}
3553
+ />`;
3554
+ }
3555
+ };
3556
+ L.styles = _`
3557
+ :host {
3558
+ display: none;
3559
+ }
3560
+ `;
3561
+ Z([
3562
+ d({ type: Boolean })
3563
+ ], L.prototype, "disabled", 2);
3564
+ Z([
3565
+ d({ type: Boolean })
3566
+ ], L.prototype, "readonly", 2);
3567
+ Z([
3568
+ d({ type: Number })
3569
+ ], L.prototype, "value", 2);
3570
+ Z([
3571
+ d({ type: Number })
3572
+ ], L.prototype, "min", 2);
3573
+ Z([
3574
+ d({ type: Number })
3575
+ ], L.prototype, "max", 2);
3576
+ L = Z([
3577
+ T("qti-manual-scoring")
3578
+ ], L);
3579
+ export {
3580
+ F as BaseType,
3581
+ Ze as Cardinality,
3582
+ R as Choices,
3583
+ le as DragDropInteractionMixin,
3584
+ si as DroppablesMixin,
3585
+ m as Events,
3586
+ ii as FlippablesMixin,
3587
+ xi as NavigationMode,
3588
+ Je as OutcomeVariable,
3589
+ Ie as QtiAnd,
3590
+ $t as QtiAssessmentItem,
3591
+ Pe as QtiAssociateInteraction,
3592
+ we as QtiBaseValue,
3593
+ S as QtiChoice,
3594
+ ae as QtiChoiceInteraction,
3595
+ Ge as QtiCompanionMaterialsInfo,
3596
+ Se as QtiContains,
3597
+ Xs as QtiCorrect,
3598
+ yt as QtiCustomOperatorLevenshtein,
3599
+ vi as QtiCustomOperatorNumericOnly,
3600
+ Et as QtiCustomOperatorParseNumberLocalNl,
3601
+ _i as QtiCustomOperatorRemoveAllSpaces,
3602
+ yi as QtiCustomOperatorTrim,
3603
+ q as QtiExpression,
3604
+ H as QtiExtendedTextInteraction,
3605
+ rt as QtiFeedbackInline,
3606
+ pi as QtiGap,
3607
+ pt as QtiGapMatchInteraction,
3608
+ di as QtiGapText,
3609
+ ut as QtiGraphicAssociateInteraction,
3610
+ mt as QtiGraphicGapMatchInteraction,
3611
+ ft as QtiGraphicOrderInteraction,
3612
+ Re as QtiGte,
3613
+ De as QtiHotspotChoice,
3614
+ gt as QtiHotspotInteraction,
3615
+ ze as QtiHottext,
3616
+ Ts as QtiHottextInteraction,
3617
+ lt as QtiInlineChoiceInteraction,
3618
+ Te as QtiIsNull,
3619
+ P as QtiItem,
3620
+ ye as QtiItemBody,
3621
+ L as QtiManualScoring,
3622
+ Vs as QtiMapResponse,
3623
+ Ws as QtiMatch,
3624
+ bt as QtiMatchInteraction,
3625
+ vt as QtiMediaInteraction,
3626
+ ps as QtiModalFeedback,
3627
+ Ks as QtiMultiple,
3628
+ Ne as QtiOr,
3629
+ Me as QtiOrderInteraction,
3630
+ Jt as QtiOutcomeDeclaration,
3631
+ Zs as QtiPortableCustomInteraction,
3632
+ Nt as QtiPrompt,
3633
+ js as QtiResponseCondition,
3634
+ fe as QtiResponseDeclaration,
3635
+ ht as QtiResponseElse,
3636
+ Bs as QtiResponseElseIf,
3637
+ dt as QtiResponseIf,
3638
+ Qs as QtiResponseProcessing,
3639
+ _t as QtiSelectPointInteraction,
3640
+ Gs as QtiSetOutcomeValue,
3641
+ We as QtiSimpleChoice,
3642
+ O as QtiSliderInteraction,
3643
+ qt as QtiStylesheet,
3644
+ x as QtiTest,
3645
+ ot as QtiTextEntryInteraction,
3646
+ zs as QtiVariable,
3647
+ se as ResponseVariable,
3648
+ Ii as Status,
3649
+ Ai as SubmissionMode,
3650
+ k as TestEvents,
3651
+ te as TouchDragAndDrop,
3652
+ Xe as qtiContentBody,
3653
+ M as qtiRubricBlock,
3654
+ hi as qtiSimpleAssociableChoice
3655
+ };