@citolab/qti-components 9.3.0 → 9.4.0

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 (58) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +217 -204
  3. package/dist/base.d.ts +10 -10
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-G5RQ5GKG.js → chunk-3BAQWO5C.js} +2 -2
  6. package/dist/{chunk-ZG7FBQFP.js → chunk-ACRN7YJM.js} +2 -2
  7. package/dist/{chunk-JLZCZVRX.js → chunk-B5XHZI2P.js} +2 -2
  8. package/dist/{chunk-RAJQKCQ3.js → chunk-B74SYQB2.js} +2 -2
  9. package/dist/{chunk-YIYHCHHM.js → chunk-BMXG7D2N.js} +2 -2
  10. package/dist/{chunk-FG5JAWSN.js → chunk-C3JPUV36.js} +2 -2
  11. package/dist/{chunk-TDWLV5OD.js → chunk-GNTO3IFM.js} +559 -251
  12. package/dist/chunk-GNTO3IFM.js.map +1 -0
  13. package/dist/{chunk-7VDR765S.js → chunk-JHPQJDAV.js} +2 -2
  14. package/dist/{chunk-CQHGVPOT.js → chunk-LKHRHFXO.js} +6 -6
  15. package/dist/{chunk-JGPWBIVD.js → chunk-MSGYZE6L.js} +2 -2
  16. package/dist/{chunk-YVZWNLF4.js → chunk-R7MMMDP7.js} +139 -18
  17. package/dist/chunk-R7MMMDP7.js.map +1 -0
  18. package/dist/{chunk-REKCRWJV.js → chunk-XEWGFAS4.js} +166 -104
  19. package/dist/chunk-XEWGFAS4.js.map +1 -0
  20. package/dist/{computed.types.d-DB5gfOh9.d.ts → computed.types.d-gJrBeUMG.d.ts} +1 -1
  21. package/dist/corrections.d.ts +9 -9
  22. package/dist/corrections.js +7 -7
  23. package/dist/elements.d.ts +46 -6
  24. package/dist/elements.js +5 -3
  25. package/dist/index.d.ts +12 -12
  26. package/dist/index.js +16 -12
  27. package/dist/{interaction.d-DegNJ5ZA.d.ts → interaction.d-g6XG0T0Z.d.ts} +2 -2
  28. package/dist/interactions.d.ts +4 -4
  29. package/dist/interactions.js +3 -3
  30. package/dist/item.d.ts +4 -4
  31. package/dist/item.js +3 -3
  32. package/dist/{item.types.d-BDFrq19E.d.ts → item.types.d-B55QkJ92.d.ts} +10 -0
  33. package/dist/loader.d.ts +2 -2
  34. package/dist/processing.d.ts +3 -3
  35. package/dist/processing.js +3 -3
  36. package/dist/qti-components-jsx.d.ts +353 -266
  37. package/dist/{qti-condition-expression.d-DLboq8bR.d.ts → qti-condition-expression.d-L7yb3Rzy.d.ts} +1 -1
  38. package/dist/{qti-expression.d-BksT9iLB.d.ts → qti-expression.d-CuaLjZ6g.d.ts} +1 -1
  39. package/dist/{qti-feedback.d-D-w6-mJv.d.ts → qti-feedback.d-wMYNVkkj.d.ts} +2 -3
  40. package/dist/{qti-item.d-D_-9_0e6.d.ts → qti-item.d-DgC1AQbY.d.ts} +1 -1
  41. package/dist/{qti-test.d-D-ELy0Mr.d.ts → qti-test.d-Cud5Gvy0.d.ts} +204 -42
  42. package/dist/{qti-text-entry-interaction.d-CATtcPyX.d.ts → qti-text-entry-interaction.d-DKvz9ncv.d.ts} +2 -2
  43. package/dist/{session.context.d-Cjs0BkJB.d.ts → session.context.d-D5080LVx.d.ts} +3 -1
  44. package/dist/test.d.ts +58 -11
  45. package/dist/test.js +6 -4
  46. package/package.json +4 -4
  47. package/dist/chunk-REKCRWJV.js.map +0 -1
  48. package/dist/chunk-TDWLV5OD.js.map +0 -1
  49. package/dist/chunk-YVZWNLF4.js.map +0 -1
  50. /package/dist/{chunk-G5RQ5GKG.js.map → chunk-3BAQWO5C.js.map} +0 -0
  51. /package/dist/{chunk-ZG7FBQFP.js.map → chunk-ACRN7YJM.js.map} +0 -0
  52. /package/dist/{chunk-JLZCZVRX.js.map → chunk-B5XHZI2P.js.map} +0 -0
  53. /package/dist/{chunk-RAJQKCQ3.js.map → chunk-B74SYQB2.js.map} +0 -0
  54. /package/dist/{chunk-YIYHCHHM.js.map → chunk-BMXG7D2N.js.map} +0 -0
  55. /package/dist/{chunk-FG5JAWSN.js.map → chunk-C3JPUV36.js.map} +0 -0
  56. /package/dist/{chunk-7VDR765S.js.map → chunk-JHPQJDAV.js.map} +0 -0
  57. /package/dist/{chunk-CQHGVPOT.js.map → chunk-LKHRHFXO.js.map} +0 -0
  58. /package/dist/{chunk-JGPWBIVD.js.map → chunk-MSGYZE6L.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  QtiModalFeedback
3
- } from "./chunk-REKCRWJV.js";
3
+ } from "./chunk-XEWGFAS4.js";
4
4
  import {
5
5
  item_css_default
6
6
  } from "./chunk-A32YH4H5.js";
@@ -21,7 +21,7 @@ import {
21
21
  qtiContext,
22
22
  sessionContext,
23
23
  testContext
24
- } from "./chunk-YVZWNLF4.js";
24
+ } from "./chunk-R7MMMDP7.js";
25
25
 
26
26
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
27
27
  import { LitElement, nothing as nothing2 } from "lit";
@@ -1096,6 +1096,10 @@ var makeLitTemplate = (template) => {
1096
1096
  return litTemplate;
1097
1097
  };
1098
1098
 
1099
+ // ../qti-test/dist/internal/test-host.context.js
1100
+ import { createContext } from "@lit/context";
1101
+ var testHostContext = createContext(/* @__PURE__ */ Symbol("testHost"));
1102
+
1099
1103
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
1100
1104
  var __decorate = function(decorators, target, key, desc) {
1101
1105
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1147,31 +1151,13 @@ var QtiAssessmentItemRef = class extends LitElement {
1147
1151
  get assessmentItem() {
1148
1152
  return this.renderRoot?.querySelector("qti-assessment-item");
1149
1153
  }
1150
- /**
1151
- * The `<qti-test>` this ref belongs to, crossing shadow boundaries on the way
1152
- * up.
1153
- *
1154
- * `<test-container>` renders its items into a shadow root, so an item-ref is
1155
- * usually one hop below one; but it is also valid in plain light DOM, and a
1156
- * host is free to nest it deeper. Climbing root by root covers all three
1157
- * without assuming any of them.
1158
- */
1159
- #findTestElement() {
1160
- const own = this.closest("qti-test");
1161
- if (own)
1162
- return own;
1163
- let root = this.getRootNode();
1164
- while (root instanceof ShadowRoot) {
1165
- const test = root.host.closest("qti-test");
1166
- if (test)
1167
- return test;
1168
- root = root.host.getRootNode();
1169
- }
1170
- return null;
1154
+ disconnectedCallback() {
1155
+ super.disconnectedCallback();
1156
+ this.testHost = void 0;
1171
1157
  }
1172
1158
  async connectedCallback() {
1173
1159
  super.connectedCallback();
1174
- const templateElement = this.#findTestElement()?.querySelector("template[item-ref]");
1160
+ const templateElement = this.testHost?.querySelector("template[item-ref]");
1175
1161
  this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;
1176
1162
  this.requestUpdate();
1177
1163
  await this.updateComplete;
@@ -1247,6 +1233,9 @@ __decorate([
1247
1233
  __decorate([
1248
1234
  property({ type: Object, attribute: false })
1249
1235
  ], QtiAssessmentItemRef.prototype, "xmlDoc", void 0);
1236
+ __decorate([
1237
+ consume({ context: testHostContext, subscribe: true })
1238
+ ], QtiAssessmentItemRef.prototype, "testHost", void 0);
1250
1239
 
1251
1240
  // ../qti-test/dist/components/qti-assessment-section/qti-assessment-section.js
1252
1241
  import { consume as consume2 } from "@lit/context";
@@ -1647,8 +1636,11 @@ var QtiTestVariablesExpression = class {
1647
1636
  }
1648
1637
  };
1649
1638
 
1639
+ // ../qti-test/dist/types/qti-test-state.js
1640
+ var QTI_TEST_STATE_VERSION = 1;
1641
+
1650
1642
  // ../qti-test/dist/components/qti-test/qti-test.js
1651
- import { provide as provide2 } from "@lit/context";
1643
+ import { ContextProvider, provide as provide2 } from "@lit/context";
1652
1644
  import { html as html7, LitElement as LitElement8 } from "lit";
1653
1645
  import { state as state2 } from "lit/decorators.js";
1654
1646
 
@@ -1688,7 +1680,7 @@ var TestNavigationMixin = (superClass) => {
1688
1680
  /**
1689
1681
  * Navigate to a specific item or section
1690
1682
  * @param type - Navigation type ('item' or 'section')
1691
- * @param id - Target identifier (optional, falls back to first available)
1683
+ * @param id - Target identifier (optional, falls back to the current position, or the first one before there is any)
1692
1684
  */
1693
1685
  navigateTo(type, id) {
1694
1686
  const targetId = id || this._getDefaultNavigationId(type);
@@ -1769,7 +1761,7 @@ var TestNavigationMixin = (superClass) => {
1769
1761
  // ===========================================
1770
1762
  _getDefaultNavigationId(type) {
1771
1763
  if (type === "section") {
1772
- return this._testElement?.querySelector("qti-assessment-section")?.identifier;
1764
+ return this.sessionContext?.navSectionId ?? this._testElement?.querySelector("qti-assessment-section")?.identifier;
1773
1765
  }
1774
1766
  return this.sessionContext?.navItemRefId ?? this._testElement?.querySelector("qti-assessment-item-ref")?.identifier;
1775
1767
  }
@@ -1935,10 +1927,9 @@ var TestNavigationMixin = (superClass) => {
1935
1927
  console.warn("No stimulus content to apply");
1936
1928
  return;
1937
1929
  }
1938
- const elements = stimulus.querySelectorAll("qti-stimulus-body, qti-stylesheet");
1939
- console.info(`Found ${elements.length} stimulus elements to apply for ${element.identifier}`);
1940
- if (elements.length === 0) {
1941
- console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");
1930
+ const root = stimulus.querySelector("qti-assessment-stimulus");
1931
+ if (!root) {
1932
+ console.warn("No qti-assessment-stimulus element found in stimulus");
1942
1933
  return;
1943
1934
  }
1944
1935
  let targets = [];
@@ -1963,8 +1954,7 @@ var TestNavigationMixin = (superClass) => {
1963
1954
  }
1964
1955
  targets.forEach((target, index) => {
1965
1956
  target.innerHTML = "";
1966
- const clonedElements = Array.from(elements).map((el) => el.cloneNode(true));
1967
- target.append(...clonedElements);
1957
+ target.append(root.cloneNode(true));
1968
1958
  console.info(`Applied stimulus content to target ${index + 1}/${targets.length}`);
1969
1959
  });
1970
1960
  }
@@ -2021,7 +2011,7 @@ var TestNavigationMixin = (superClass) => {
2021
2011
  }
2022
2012
  async _loadSingleItem(itemRef, navigationId, controller) {
2023
2013
  try {
2024
- const seed = this.querySelector("test-navigation")?.qtiContext?.QTI_CONTEXT?.seed;
2014
+ const seed = this.qtiContext?.QTI_CONTEXT?.seed;
2025
2015
  let transformer = (await qtiTransformItem().load(itemRef.href, controller.signal)).shuffleInteractions(seed);
2026
2016
  if (this.postLoadTransformCallback) {
2027
2017
  transformer = await this.postLoadTransformCallback(transformer, itemRef);
@@ -2212,7 +2202,7 @@ var TestBaseMixin = (superClass) => {
2212
2202
  this.testContext = INITIAL_TEST_CONTEXT;
2213
2203
  this.sessionContext = INITIAL_SESSION_CONTEXT;
2214
2204
  this._updateItemInTestContext = (assessmentItem) => {
2215
- const context = assessmentItem._context;
2205
+ const context = assessmentItem.itemContext;
2216
2206
  const identifier = context.identifier;
2217
2207
  const fullVariables = context.variables;
2218
2208
  const itemContext = this.testContext.items.find((i) => i?.identifier === identifier);
@@ -2221,7 +2211,7 @@ var TestBaseMixin = (superClass) => {
2221
2211
  return;
2222
2212
  }
2223
2213
  if (itemContext.variables?.length === 1) {
2224
- this._updateItemVariablesInTestContext(identifier, fullVariables);
2214
+ this._updateItemVariablesInTestContext(identifier, fullVariables, void 0, context.valid);
2225
2215
  } else {
2226
2216
  const newVariables = [...assessmentItem.variables];
2227
2217
  for (const variable of itemContext.variables) {
@@ -2233,22 +2223,54 @@ var TestBaseMixin = (superClass) => {
2233
2223
  }
2234
2224
  }
2235
2225
  assessmentItem.variables = newVariables;
2226
+ if (itemContext.state) {
2227
+ assessmentItem.state = itemContext.state;
2228
+ }
2236
2229
  }
2237
2230
  };
2238
2231
  this._initializeEventListeners();
2239
2232
  }
2240
- updateItemVariables(itemRefID, variables) {
2241
- const itemContext = this.testContext.items.find((item) => item.identifier === itemRefID);
2242
- if (itemContext) {
2243
- itemContext.variables = itemContext.variables.map((variable) => {
2244
- const updatedVariable = variables.find((v) => v.identifier === variable.identifier);
2245
- return updatedVariable ? { ...variable, ...updatedVariable } : variable;
2246
- });
2247
- }
2248
- const itemRef = this._testElement.querySelector(`qti-assessment-item-ref[identifier="${itemRefID}"]`);
2249
- if (itemRef && itemRef.assessmentItem) {
2250
- itemRef.assessmentItem.variables = variables;
2251
- }
2233
+ /**
2234
+ * Sets values on one item from outside the candidate's session, e.g. a score from manual
2235
+ * scoring. Values are merged into the item's entry in the test context, and into the item
2236
+ * itself if it is on screen; a value the item has not seen yet is added, so this also works
2237
+ * before the item has loaded. To restore a whole session, assign `state` instead.
2238
+ *
2239
+ * The test context is replaced rather than changed in place, so its consumers update and
2240
+ * `qti-state-changed` fires.
2241
+ *
2242
+ * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.
2243
+ * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.
2244
+ */
2245
+ updateItemVariables(itemRefID, values, state9) {
2246
+ this.testContext = {
2247
+ ...this.testContext,
2248
+ items: this.testContext.items.map((item) => {
2249
+ if (item.identifier !== itemRefID)
2250
+ return item;
2251
+ const variables = [...item.variables ?? []];
2252
+ for (const { identifier, type, value } of values) {
2253
+ const index = variables.findIndex((v) => v.identifier === identifier);
2254
+ const updated = {
2255
+ ...index >= 0 ? variables[index] : {},
2256
+ identifier,
2257
+ ...type ? { type } : {},
2258
+ value: Array.isArray(value) ? [...value] : value
2259
+ };
2260
+ if (index >= 0)
2261
+ variables[index] = updated;
2262
+ else
2263
+ variables.push(updated);
2264
+ }
2265
+ return { ...item, variables, ...state9 ? { state: { ...state9 } } : {} };
2266
+ })
2267
+ };
2268
+ const assessmentItem = this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(itemRefID)}"]`)?.assessmentItem;
2269
+ if (!assessmentItem)
2270
+ return;
2271
+ assessmentItem.variables = [...this.testContext.items.find((i) => i.identifier === itemRefID)?.variables ?? []];
2272
+ if (state9)
2273
+ assessmentItem.state = state9;
2252
2274
  }
2253
2275
  _initializeEventListeners() {
2254
2276
  this.addEventListener("qti-testdoc-loaded", () => {
@@ -2282,10 +2304,10 @@ var TestBaseMixin = (superClass) => {
2282
2304
  this._updateItemInTestContext(e.detail);
2283
2305
  });
2284
2306
  this.addEventListener("qti-item-context-updated", (e) => {
2285
- this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state);
2307
+ this._updateItemVariablesInTestContext(e.detail.itemContext.identifier, e.detail.itemContext.variables, e.detail.itemContext.state, e.detail.itemContext.valid);
2286
2308
  });
2287
2309
  }
2288
- _updateItemVariablesInTestContext(identifier, variables, state9) {
2310
+ _updateItemVariablesInTestContext(identifier, variables, state9, valid) {
2289
2311
  this.testContext = {
2290
2312
  ...this.testContext,
2291
2313
  // Spread existing test context properties
@@ -2300,7 +2322,8 @@ var TestBaseMixin = (superClass) => {
2300
2322
  const matchingVariable = itemContext.variables.find((v) => v.identifier === variable.identifier);
2301
2323
  return matchingVariable ? { ...matchingVariable, ...variable } : variable;
2302
2324
  }),
2303
- ...state9 !== void 0 ? { state: state9 ? { ...state9 } : void 0 } : {}
2325
+ ...state9 !== void 0 ? { state: state9 ? { ...state9 } : void 0 } : {},
2326
+ ...valid !== void 0 ? { valid } : {}
2304
2327
  };
2305
2328
  })
2306
2329
  };
@@ -2320,6 +2343,115 @@ var TestBaseMixin = (superClass) => {
2320
2343
  var TestBase = class extends TestBaseMixin(LitElement7) {
2321
2344
  };
2322
2345
 
2346
+ // ../qti-test/dist/mixins/test-state.mixin.js
2347
+ var copy = (value) => Array.isArray(value) ? [...value] : value ?? null;
2348
+ var isQtiTestState = (value) => {
2349
+ const state9 = value;
2350
+ return state9?.version === QTI_TEST_STATE_VERSION && Array.isArray(state9.test?.items) && Array.isArray(state9.test?.outcomes) && typeof state9.session === "object" && state9.session !== null;
2351
+ };
2352
+ var toState = (test, session) => ({
2353
+ version: QTI_TEST_STATE_VERSION,
2354
+ test: {
2355
+ items: (test?.items ?? []).filter((item) => item.identifier).map((item) => ({
2356
+ identifier: item.identifier,
2357
+ variables: (item.variables ?? []).map((v) => ({
2358
+ identifier: v.identifier,
2359
+ ...v.type ? { type: v.type } : {},
2360
+ value: copy(v.value)
2361
+ })),
2362
+ ...item.state ? { state: { ...item.state } } : {}
2363
+ })),
2364
+ outcomes: (test?.testOutcomeVariables ?? []).map((v) => ({ identifier: v.identifier, value: copy(v.value) }))
2365
+ },
2366
+ session: {
2367
+ ...session?.navPartId !== void 0 ? { navPartId: session.navPartId } : {},
2368
+ ...session?.navSectionId !== void 0 ? { navSectionId: session.navSectionId } : {},
2369
+ ...session?.navItemRefId !== void 0 ? { navItemRefId: session.navItemRefId } : {}
2370
+ }
2371
+ });
2372
+ var TestStateMixin = (superClass) => {
2373
+ class TestStateClass extends superClass {
2374
+ /** A state assigned before the test connected, applied when it does. */
2375
+ #pending = null;
2376
+ /**
2377
+ * False while a test document is loading. Loading resets both contexts and rebuilds them, so
2378
+ * the intermediate states are empty — emitting one would invite a host to save it over the
2379
+ * real one.
2380
+ */
2381
+ #ready = false;
2382
+ #lastEmitted = null;
2383
+ constructor(...args) {
2384
+ super(...args);
2385
+ this.addEventListener("qti-testdoc-loaded", () => {
2386
+ this.#ready = false;
2387
+ this.#lastEmitted = null;
2388
+ });
2389
+ this.addEventListener("qti-assessment-test-connected", () => {
2390
+ if (this.#pending) {
2391
+ this.#apply(this.#pending);
2392
+ this.#pending = null;
2393
+ }
2394
+ this.#ready = true;
2395
+ });
2396
+ }
2397
+ get state() {
2398
+ return toState(this.testContext, this.sessionContext);
2399
+ }
2400
+ set state(value) {
2401
+ if (!isQtiTestState(value)) {
2402
+ console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);
2403
+ return;
2404
+ }
2405
+ if (!this.#ready) {
2406
+ this.#pending = value;
2407
+ return;
2408
+ }
2409
+ const { navItemRefId, navSectionId } = this.sessionContext;
2410
+ this.#apply(value);
2411
+ const restored = this.sessionContext;
2412
+ if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {
2413
+ this.#requestNavigation("item", restored.navItemRefId);
2414
+ } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {
2415
+ this.#requestNavigation("section", restored.navSectionId);
2416
+ }
2417
+ }
2418
+ updated(changed) {
2419
+ super.updated(changed);
2420
+ if (!this.#ready || !(changed.has("testContext") || changed.has("sessionContext")))
2421
+ return;
2422
+ const state9 = this.state;
2423
+ const serialized = JSON.stringify(state9);
2424
+ if (serialized === this.#lastEmitted)
2425
+ return;
2426
+ this.#lastEmitted = serialized;
2427
+ this.dispatchEvent(new CustomEvent("qti-state-changed", { detail: state9, bubbles: true, composed: true }));
2428
+ }
2429
+ #apply(state9) {
2430
+ for (const saved of state9.test.items)
2431
+ this.updateItemVariables(saved.identifier, saved.variables, saved.state);
2432
+ const savedOutcomes = new Map(state9.test.outcomes.map((outcome) => [outcome.identifier, outcome.value]));
2433
+ this.testContext = {
2434
+ ...this.testContext,
2435
+ testOutcomeVariables: this.testContext.testOutcomeVariables?.map((v) => savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v)
2436
+ };
2437
+ this.sessionContext = { ...this.sessionContext, ...this.#validSession(state9.session) };
2438
+ }
2439
+ /** A stored position may point at an item or section a revised test no longer has. */
2440
+ #validSession(session) {
2441
+ const exists = (selector, id) => !!id && !!this._testElement?.querySelector(`${selector}[identifier="${CSS.escape(id)}"]`);
2442
+ return {
2443
+ ...exists("qti-test-part", session.navPartId) ? { navPartId: session.navPartId } : {},
2444
+ ...exists("qti-assessment-section", session.navSectionId) ? { navSectionId: session.navSectionId } : {},
2445
+ ...this.testContext.items.some((i) => i.identifier === session.navItemRefId) ? { navItemRefId: session.navItemRefId } : {}
2446
+ };
2447
+ }
2448
+ #requestNavigation(type, id) {
2449
+ this.dispatchEvent(new CustomEvent("qti-request-navigation", { detail: { type, id }, bubbles: true, composed: true }));
2450
+ }
2451
+ }
2452
+ return TestStateClass;
2453
+ };
2454
+
2323
2455
  // ../qti-test/dist/mixins/test-processing.mixin.js
2324
2456
  var TestProcessingMixin = (superClass) => {
2325
2457
  class TestProcessingElement extends superClass {
@@ -2339,7 +2471,7 @@ var TestProcessingMixin = (superClass) => {
2339
2471
  });
2340
2472
  }
2341
2473
  outcomeProcessing() {
2342
- const outcomeProcessor = this.querySelector("qti-outcome-processing");
2474
+ const outcomeProcessor = (this._testElement ?? this).querySelector("qti-outcome-processing");
2343
2475
  if (!outcomeProcessor)
2344
2476
  return false;
2345
2477
  outcomeProcessor?.process();
@@ -2382,10 +2514,20 @@ var __decorate9 = function(decorators, target, key, desc) {
2382
2514
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2383
2515
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2384
2516
  };
2385
- var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestBaseMixin(LitElement8)))) {
2517
+ var QtiTest = class extends TestNavigationMixin(TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement8))))) {
2518
+ // TODO: Properly implement IQtiTest interface
2519
+ // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {
2386
2520
  constructor() {
2387
- super(...arguments);
2521
+ super();
2388
2522
  this.configContext = {};
2523
+ this.qtiContext = {
2524
+ QTI_CONTEXT: {
2525
+ testIdentifier: "",
2526
+ candidateIdentifier: "",
2527
+ environmentIdentifier: "default"
2528
+ }
2529
+ };
2530
+ new ContextProvider(this, { context: testHostContext, initialValue: this });
2389
2531
  }
2390
2532
  /**
2391
2533
  * Renders the component's template.
@@ -2404,8 +2546,13 @@ __decorate9([
2404
2546
  state2(),
2405
2547
  provide2({ context: configContext })
2406
2548
  ], QtiTest.prototype, "configContext", void 0);
2549
+ __decorate9([
2550
+ state2(),
2551
+ provide2({ context: qtiContext })
2552
+ ], QtiTest.prototype, "qtiContext", void 0);
2407
2553
 
2408
2554
  // ../qti-test/dist/components/test-check-item/test-check-item.js
2555
+ import { consume as consume5 } from "@lit/context";
2409
2556
  import { css as css4, html as html8, LitElement as LitElement9 } from "lit";
2410
2557
 
2411
2558
  // ../qti-test/dist/components/styles.js
@@ -2448,6 +2595,12 @@ var ind = css3`
2448
2595
  `;
2449
2596
 
2450
2597
  // ../qti-test/dist/components/test-check-item/test-check-item.js
2598
+ var __decorate10 = function(decorators, target, key, desc) {
2599
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2600
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2601
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2602
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2603
+ };
2451
2604
  var TestCheckItem = class extends LitElement9 {
2452
2605
  static {
2453
2606
  this.styles = css4`
@@ -2469,8 +2622,9 @@ var TestCheckItem = class extends LitElement9 {
2469
2622
  super();
2470
2623
  this.addEventListener("click", () => {
2471
2624
  this.dispatchEvent(new CustomEvent("test-end-attempt", { bubbles: true }));
2472
- const qtiTest = this.closest("qti-test");
2473
- const testContainer = qtiTest.querySelector("test-container");
2625
+ const testContainer = this.testHost?.querySelector("test-container");
2626
+ if (!testContainer)
2627
+ return;
2474
2628
  const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll("[view]"));
2475
2629
  viewElements.forEach((element) => {
2476
2630
  element.classList.toggle("show", true);
@@ -2481,13 +2635,16 @@ var TestCheckItem = class extends LitElement9 {
2481
2635
  return html8` <slot></slot> `;
2482
2636
  }
2483
2637
  };
2638
+ __decorate10([
2639
+ consume5({ context: testHostContext, subscribe: true })
2640
+ ], TestCheckItem.prototype, "testHost", void 0);
2484
2641
 
2485
2642
  // ../qti-test/dist/components/test-container/test-container.js
2486
- import { consume as consume5 } from "@lit/context";
2643
+ import { consume as consume6 } from "@lit/context";
2487
2644
  import { LitElement as LitElement10, html as html9 } from "lit";
2488
2645
  import { property as property8, state as state3 } from "lit/decorators.js";
2489
2646
  import { until } from "lit/directives/until.js";
2490
- var __decorate10 = function(decorators, target, key, desc) {
2647
+ var __decorate11 = function(decorators, target, key, desc) {
2491
2648
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2492
2649
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2493
2650
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2525,7 +2682,7 @@ var TestContainer = class extends LitElement10 {
2525
2682
  try {
2526
2683
  const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;
2527
2684
  let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);
2528
- const qtiTest = this.closest("qti-test");
2685
+ const qtiTest = this.testHost;
2529
2686
  if (qtiTest?.postLoadTestTransformCallback) {
2530
2687
  const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? void 0);
2531
2688
  const testElement = tempDoc.querySelector("qti-assessment-test");
@@ -2593,34 +2750,37 @@ var TestContainer = class extends LitElement10 {
2593
2750
  `;
2594
2751
  }
2595
2752
  };
2596
- __decorate10([
2753
+ __decorate11([
2597
2754
  property8({ attribute: false })
2598
2755
  ], TestContainer.prototype, "customElementRegistry", void 0);
2599
- __decorate10([
2756
+ __decorate11([
2600
2757
  property8({ type: String, attribute: "test-url" })
2601
2758
  ], TestContainer.prototype, "testURL", void 0);
2602
- __decorate10([
2759
+ __decorate11([
2603
2760
  state3()
2604
2761
  ], TestContainer.prototype, "testDoc", void 0);
2605
- __decorate10([
2762
+ __decorate11([
2606
2763
  state3()
2607
2764
  ], TestContainer.prototype, "testXML", void 0);
2608
- __decorate10([
2765
+ __decorate11([
2766
+ consume6({ context: testHostContext, subscribe: true })
2767
+ ], TestContainer.prototype, "testHost", void 0);
2768
+ __decorate11([
2609
2769
  state3(),
2610
- consume5({ context: qtiContext, subscribe: true })
2770
+ consume6({ context: qtiContext, subscribe: true })
2611
2771
  ], TestContainer.prototype, "qtiContext", void 0);
2612
- __decorate10([
2772
+ __decorate11([
2613
2773
  watch("testURL", { waitUntilFirstUpdate: true })
2614
2774
  ], TestContainer.prototype, "handleTestURLChange", null);
2615
- __decorate10([
2775
+ __decorate11([
2616
2776
  watch("testXML", { waitUntilFirstUpdate: true })
2617
2777
  ], TestContainer.prototype, "handleTestXMLChange", null);
2618
2778
 
2619
2779
  // ../qti-test/dist/components/test-end-attempt/test-end-attempt.js
2620
2780
  import { css as css5, html as html10, LitElement as LitElement11 } from "lit";
2621
2781
  import { property as property9 } from "lit/decorators.js";
2622
- import { consume as consume6 } from "@lit/context";
2623
- var __decorate11 = function(decorators, target, key, desc) {
2782
+ import { consume as consume7 } from "@lit/context";
2783
+ var __decorate12 = function(decorators, target, key, desc) {
2624
2784
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2625
2785
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2626
2786
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2692,21 +2852,21 @@ var TestEndAttempt = class extends LitElement11 {
2692
2852
  return html10` <slot></slot> `;
2693
2853
  }
2694
2854
  };
2695
- __decorate11([
2696
- consume6({ context: computedContext, subscribe: true }),
2855
+ __decorate12([
2856
+ consume7({ context: computedContext, subscribe: true }),
2697
2857
  property9({ attribute: false })
2698
2858
  ], TestEndAttempt.prototype, "computedContext", void 0);
2699
- __decorate11([
2859
+ __decorate12([
2700
2860
  property9({ type: Boolean, reflect: true, attribute: "disabled" })
2701
2861
  ], TestEndAttempt.prototype, "_internalDisabled", void 0);
2702
- __decorate11([
2862
+ __decorate12([
2703
2863
  watch("computedContext")
2704
2864
  ], TestEndAttempt.prototype, "_handleTestElementChange", null);
2705
2865
 
2706
2866
  // ../qti-test/dist/components/test-item-link/test-item-link.js
2707
2867
  import { css as css6, html as html11, LitElement as LitElement12 } from "lit";
2708
2868
  import { property as property10 } from "lit/decorators.js";
2709
- var __decorate12 = function(decorators, target, key, desc) {
2869
+ var __decorate13 = function(decorators, target, key, desc) {
2710
2870
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2711
2871
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2712
2872
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2748,16 +2908,16 @@ var TestItemLink = class extends LitElement12 {
2748
2908
  return html11` <slot></slot> `;
2749
2909
  }
2750
2910
  };
2751
- __decorate12([
2911
+ __decorate13([
2752
2912
  property10({ type: String, attribute: "item-id" })
2753
2913
  ], TestItemLink.prototype, "itemId", void 0);
2754
2914
 
2755
2915
  // ../qti-test/dist/components/test-item-to-speech/test-item-to-speech.js
2756
2916
  import { html as html12, LitElement as LitElement13, css as css7 } from "lit";
2757
- import { consume as consume7, provide as provide3, createContext } from "@lit/context";
2917
+ import { consume as consume8, provide as provide3, createContext as createContext2 } from "@lit/context";
2758
2918
  import { property as property11, state as state4 } from "lit/decorators.js";
2759
2919
  import { ifDefined } from "lit/directives/if-defined.js";
2760
- var __decorate13 = function(decorators, target, key, desc) {
2920
+ var __decorate14 = function(decorators, target, key, desc) {
2761
2921
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2762
2922
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2763
2923
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -2776,7 +2936,7 @@ function getHighlightSheet() {
2776
2936
  }
2777
2937
  return highlightSheet;
2778
2938
  }
2779
- var ttsContext = createContext(/* @__PURE__ */ Symbol("tts-context"));
2939
+ var ttsContext = createContext2(/* @__PURE__ */ Symbol("tts-context"));
2780
2940
  var ICONS = {
2781
2941
  play: "M8 5v14l11-7z",
2782
2942
  pause: "M6 5h4v14H6zM14 5h4v14h-4z",
@@ -2785,8 +2945,12 @@ var ICONS = {
2785
2945
  next: "M16 5h2v14h-2zM4 5v14l11-7z",
2786
2946
  pick: "M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"
2787
2947
  };
2788
- var iconContent = (icon, label) => html12`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d=${ICONS[icon]}></path></svg
2789
- ><span class="label">${label}</span>`;
2948
+ var iconContent = (icon, label) => {
2949
+ const svg = html12`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
2950
+ <path d="${ICONS[icon]}"></path>
2951
+ </svg>`;
2952
+ return html12`${svg}<span class="label">${label}</span>`;
2953
+ };
2790
2954
  var TtsButtonBase = class extends LitElement13 {
2791
2955
  static {
2792
2956
  this.styles = css7`
@@ -2797,6 +2961,10 @@ var TtsButtonBase = class extends LitElement13 {
2797
2961
  ${btn};
2798
2962
  min-inline-size: var(--test-button-size, 2.25rem);
2799
2963
  padding-inline: 0.5rem;
2964
+ /* Containing block for the visually hidden .label. Without it the label is placed against
2965
+ the nearest positioned ancestor, which can sit outside a scroll container and make the
2966
+ page as tall as the scrolled content. */
2967
+ position: relative;
2800
2968
  }
2801
2969
  button:hover:not(:disabled) {
2802
2970
  ${btnInteractive};
@@ -2849,11 +3017,11 @@ var TtsButtonBase = class extends LitElement13 {
2849
3017
  this.#internals.states.add("picking");
2850
3018
  }
2851
3019
  };
2852
- __decorate13([
3020
+ __decorate14([
2853
3021
  property11({ type: String })
2854
3022
  ], TtsButtonBase.prototype, "label", void 0);
2855
- __decorate13([
2856
- consume7({ context: ttsContext, subscribe: true })
3023
+ __decorate14([
3024
+ consume8({ context: ttsContext, subscribe: true })
2857
3025
  ], TtsButtonBase.prototype, "_tts", void 0);
2858
3026
  var TestItemToSpeech = class extends LitElement13 {
2859
3027
  static {
@@ -2867,10 +3035,24 @@ var TestItemToSpeech = class extends LitElement13 {
2867
3035
  `;
2868
3036
  }
2869
3037
  #internals;
2870
- #itemElements;
2871
- #boundHandleItemConnected;
3038
+ // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The
3039
+ // placeholder itself is looked up on every use — a host may swap the element.
3040
+ #stimulusMode;
3041
+ // Stimulus mode: resets the player when the stimulus content next to it is replaced.
3042
+ #stimulusObserver;
3043
+ // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.
3044
+ // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).
3045
+ #contentMode;
3046
+ // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.
3047
+ #itemRef;
3048
+ // Where the item-connected (and, in cursor mode, navigation) events are listened for.
2872
3049
  #eventHost;
2873
- // Current set of block-level reading elements for the active item
3050
+ #boundHandleItemConnected;
3051
+ #boundHandleNavigation;
3052
+ // Cursor mode: the previous navigation position, to detect moving to another item or section.
3053
+ #prevNavItemRefId;
3054
+ #prevNavSectionId;
3055
+ // Current set of block-level reading elements for the item
2874
3056
  #readingElements;
2875
3057
  #currentElementIndex;
2876
3058
  // Text nodes of the element currently being spoken (for word-boundary highlight)
@@ -2890,17 +3072,19 @@ var TestItemToSpeech = class extends LitElement13 {
2890
3072
  // whole-element cursor
2891
3073
  #wordHighlight;
2892
3074
  // current word during speech
2893
- // Tracks previous navItemRefId to detect item switches
2894
- #prevNavItemRefId;
2895
- #prevNavSectionId;
2896
- #boundHandleNavigation;
2897
3075
  constructor() {
2898
3076
  super();
2899
3077
  this.language = "nl-NL";
2900
3078
  this.#internals = this.attachInternals();
2901
- this.#itemElements = /* @__PURE__ */ new Map();
2902
- this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
3079
+ this.#stimulusMode = false;
3080
+ this.#stimulusObserver = null;
3081
+ this.#contentMode = false;
3082
+ this.#itemRef = null;
2903
3083
  this.#eventHost = null;
3084
+ this.#boundHandleItemConnected = this.#handleItemConnected.bind(this);
3085
+ this.#boundHandleNavigation = () => this.#stop();
3086
+ this.#prevNavItemRefId = void 0;
3087
+ this.#prevNavSectionId = void 0;
2904
3088
  this.#readingElements = null;
2905
3089
  this.#currentElementIndex = 0;
2906
3090
  this.#textNodes = [];
@@ -2911,9 +3095,6 @@ var TestItemToSpeech = class extends LitElement13 {
2911
3095
  this.#finished = false;
2912
3096
  this.#elementHighlight = new Highlight();
2913
3097
  this.#wordHighlight = new Highlight();
2914
- this.#prevNavItemRefId = void 0;
2915
- this.#prevNavSectionId = void 0;
2916
- this.#boundHandleNavigation = () => this.#stop();
2917
3098
  this._ttsContext = {
2918
3099
  state: "idle",
2919
3100
  currentElementIndex: 0,
@@ -2931,21 +3112,19 @@ var TestItemToSpeech = class extends LitElement13 {
2931
3112
  picking: false
2932
3113
  };
2933
3114
  }
3115
+ // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the
3116
+ // render already under way instead of scheduling a second one (Lit's change-in-update).
2934
3117
  willUpdate(changed) {
2935
- void changed;
2936
- }
2937
- updated(changed) {
2938
- if (changed.has("itemRefId") && changed.get("itemRefId") !== void 0) {
2939
- this.#resetReadingPosition();
2940
- }
2941
- const current = this._sessionContext?.navItemRefId ?? null;
3118
+ super.willUpdate(changed);
3119
+ if (this.#stimulusMode || this.#contentMode || this.#itemRef)
3120
+ return;
3121
+ const item = this._sessionContext?.navItemRefId ?? null;
2942
3122
  const section = this._sessionContext?.navSectionId ?? null;
2943
- const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== current;
3123
+ const itemChanged = this.#prevNavItemRefId !== void 0 && this.#prevNavItemRefId !== item;
2944
3124
  const sectionChanged = this.#prevNavSectionId !== void 0 && this.#prevNavSectionId !== section;
2945
- if (sectionChanged || itemChanged && !this.itemRefId) {
3125
+ if (itemChanged || sectionChanged)
2946
3126
  this.#resetReadingPosition();
2947
- }
2948
- this.#prevNavItemRefId = current;
3127
+ this.#prevNavItemRefId = item;
2949
3128
  this.#prevNavSectionId = section;
2950
3129
  }
2951
3130
  /** Stop speech and forget the collected reading elements, so the next play starts afresh. */
@@ -2960,9 +3139,24 @@ var TestItemToSpeech = class extends LitElement13 {
2960
3139
  connectedCallback() {
2961
3140
  super.connectedCallback();
2962
3141
  this.#setSpeechState("idle");
2963
- this.#eventHost = this.closest("test-navigation") ?? this.closest("qti-test") ?? this.getRootNode();
3142
+ this.#stimulusMode = this.#stimulusPlaceholder() !== null;
3143
+ if (this.#stimulusMode) {
3144
+ this.#stimulusObserver = new MutationObserver((records) => {
3145
+ if (records.some((record) => !this.contains(record.target)))
3146
+ this.#handleStimulusReplaced();
3147
+ });
3148
+ this.#stimulusObserver.observe(this.parentElement, { childList: true, subtree: true });
3149
+ return;
3150
+ }
3151
+ this.#contentMode = this.#contentElement() !== null;
3152
+ if (this.#contentMode)
3153
+ return;
3154
+ this.#itemRef = this.closest("qti-assessment-item-ref");
3155
+ this.#eventHost = this.#itemRef ?? this.closest("test-navigation") ?? this.testHost ?? this.getRootNode();
2964
3156
  this.#eventHost.addEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
2965
- this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
3157
+ if (!this.#itemRef) {
3158
+ this.#eventHost.addEventListener("qti-request-navigation", this.#boundHandleNavigation);
3159
+ }
2966
3160
  }
2967
3161
  disconnectedCallback() {
2968
3162
  super.disconnectedCallback();
@@ -2975,51 +3169,111 @@ var TestItemToSpeech = class extends LitElement13 {
2975
3169
  this.#eventHost?.removeEventListener("qti-assessment-item-connected", this.#boundHandleItemConnected);
2976
3170
  this.#eventHost?.removeEventListener("qti-request-navigation", this.#boundHandleNavigation);
2977
3171
  this.#eventHost = null;
2978
- this.#itemElements.clear();
3172
+ this.#itemRef = null;
3173
+ this.#stimulusObserver?.disconnect();
3174
+ this.#stimulusObserver = null;
3175
+ this.#stimulusMode = false;
3176
+ this.#contentMode = false;
2979
3177
  }
2980
3178
  render() {
2981
3179
  return html12`<slot></slot>`;
2982
3180
  }
3181
+ /**
3182
+ * An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the
3183
+ * elements collected earlier are detached now. That does not move the navigation cursor, so
3184
+ * the check in updated() does not catch it.
3185
+ */
2983
3186
  #handleItemConnected(event) {
2984
- const item = event.detail;
2985
- if (item?.identifier) {
2986
- this.#itemElements.set(item.identifier, item);
2987
- if (this.itemRefId && item.identifier === this.itemRefId && this.#readingElements !== null) {
2988
- this.#resetReadingPosition();
2989
- }
3187
+ if (this.#readingElements === null)
3188
+ return;
3189
+ const identifier = event.detail?.identifier;
3190
+ if (this.#itemRef || identifier === this._sessionContext?.navItemRefId)
3191
+ this.#resetReadingPosition();
3192
+ }
3193
+ /**
3194
+ * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was
3195
+ * collected, so the next play reads the new content from the top. Unlike
3196
+ * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading
3197
+ * while an item player on the same page is speaking.
3198
+ */
3199
+ #handleStimulusReplaced() {
3200
+ if (this.#currentUtterance) {
3201
+ this.#currentUtterance = null;
3202
+ speechSynthesis.cancel();
2990
3203
  }
3204
+ this.#stopPicking();
3205
+ this.#clearAllHighlights();
3206
+ this.#setSpeechState("idle");
3207
+ this.#readingElements = null;
3208
+ this.#currentElementIndex = 0;
3209
+ this.#finished = false;
3210
+ this.#updateContext();
3211
+ }
3212
+ /**
3213
+ * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or
3214
+ * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because
3215
+ * loading replaces the placeholder's content.
3216
+ */
3217
+ #stimulusPlaceholder() {
3218
+ return this.parentElement?.querySelector(":scope > [data-stimulus-idref]") ?? null;
2991
3219
  }
2992
3220
  /**
2993
- * Find the rendered `qti-assessment-item` for an item-ref identifier without relying on the
2994
- * connected-event cache — the player may be added after the item rendered (a header built
2995
- * around an existing item) or sit in a shadow root the event never bubbled through.
3221
+ * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.
3222
+ * The marker goes on one container; the player finds the readable elements inside it.
3223
+ */
3224
+ #contentElement() {
3225
+ return this.parentElement?.querySelector(":scope > [data-tts-content]") ?? null;
3226
+ }
3227
+ /**
3228
+ * The element whose text is read: the stimulus body next to the player (stimulus mode), the
3229
+ * marked content next to it (content mode), or the item body of the item to read.
3230
+ */
3231
+ #resolveReadingRoot() {
3232
+ if (this.#stimulusMode)
3233
+ return this.#stimulusPlaceholder()?.querySelector("qti-stimulus-body") ?? null;
3234
+ if (this.#contentMode)
3235
+ return this.#contentElement();
3236
+ return this.#resolveItem()?.querySelector("qti-item-body") ?? null;
3237
+ }
3238
+ /** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */
3239
+ #resolveItem() {
3240
+ if (this.#itemRef)
3241
+ return this.#itemRef.assessmentItem;
3242
+ const identifier = this._sessionContext?.navItemRefId;
3243
+ return identifier ? this.#findItemInDom(identifier) : null;
3244
+ }
3245
+ /**
3246
+ * Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —
3247
+ * a page can hold several tests showing the same item — then every root from here up to the
3248
+ * document; each scope directly and in the `test-container` shadow roots inside it.
2996
3249
  */
2997
3250
  #findItemInDom(identifier) {
2998
- const esc = (v) => typeof CSS !== "undefined" && CSS.escape ? CSS.escape(v) : v.replace(/"/g, '\\"');
2999
- const selector = `qti-assessment-item-ref[identifier="${esc(identifier)}"] qti-assessment-item, qti-assessment-item[identifier="${esc(identifier)}"]`;
3000
- const ownRef = this.closest("qti-assessment-item-ref");
3001
- if (ownRef?.getAttribute("identifier") === identifier) {
3002
- const own = ownRef.querySelector("qti-assessment-item");
3003
- if (own)
3004
- return own;
3005
- }
3006
- let root = this.getRootNode();
3007
- while (root) {
3008
- const scope = root;
3009
- const direct = scope.querySelector?.(selector);
3251
+ const selector = `qti-assessment-item-ref[identifier="${CSS.escape(identifier)}"] qti-assessment-item`;
3252
+ const search = (scope) => {
3253
+ const direct = scope.querySelector(selector);
3010
3254
  if (direct)
3011
3255
  return direct;
3012
- for (const container of Array.from(scope.querySelectorAll?.("test-container") ?? [])) {
3256
+ for (const container of Array.from(scope.querySelectorAll("test-container"))) {
3013
3257
  const inShadow = container.shadowRoot?.querySelector(selector);
3014
3258
  if (inShadow)
3015
3259
  return inShadow;
3016
3260
  }
3261
+ return null;
3262
+ };
3263
+ const test = this.closest("qti-test");
3264
+ const inTest = test && search(test);
3265
+ if (inTest)
3266
+ return inTest;
3267
+ let root = this.getRootNode();
3268
+ for (; ; ) {
3269
+ const found = search(root);
3270
+ if (found)
3271
+ return found;
3017
3272
  const host = root.host;
3018
3273
  if (!host)
3019
- break;
3274
+ return null;
3020
3275
  root = host.getRootNode();
3021
3276
  }
3022
- return null;
3023
3277
  }
3024
3278
  /** Update speech state on both the context (notifies children) and the host's CSS custom states. */
3025
3279
  #setSpeechState(state9) {
@@ -3034,26 +3288,37 @@ var TestItemToSpeech = class extends LitElement13 {
3034
3288
  this._ttsContext = {
3035
3289
  ...this._ttsContext,
3036
3290
  currentElementIndex: this.#currentElementIndex,
3037
- elementCount: this.#readingElements?.length ?? 0
3291
+ elementCount: this.#getReadingElements().length
3038
3292
  };
3039
3293
  }
3040
- /** Return cached reading elements, collecting them lazily on first call for the active item. */
3294
+ /**
3295
+ * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on
3296
+ * first call), filtered live for visibility on every call. Feedback and other
3297
+ * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a
3298
+ * CSS custom state reveals it) is excluded while hidden and picked up again once shown,
3299
+ * without needing to re-collect the candidate set.
3300
+ */
3041
3301
  #getReadingElements() {
3042
- if (this.#readingElements !== null)
3043
- return this.#readingElements;
3044
- const identifier = this.itemRefId || this._sessionContext?.navItemRefId;
3045
- if (!identifier)
3046
- return [];
3047
- const cached = this.#itemElements.get(identifier);
3048
- const assessmentItem = cached?.isConnected ? cached : this.#findItemInDom(identifier);
3049
- if (!assessmentItem)
3050
- return [];
3051
- const itemBody = assessmentItem.querySelector("qti-item-body");
3052
- if (!itemBody)
3053
- return [];
3054
- const selector = "p, h1, h2, h3, h4, h5, h6, li, blockquote, figcaption, qti-prompt, qti-simple-choice";
3055
- this.#readingElements = Array.from(itemBody.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector));
3056
- return this.#readingElements;
3302
+ if (this.#contentMode && this.#readingElements?.some((el) => !el.isConnected)) {
3303
+ this.#readingElements = null;
3304
+ this.#currentElementIndex = 0;
3305
+ this.#finished = false;
3306
+ }
3307
+ if (this.#readingElements === null) {
3308
+ const root = this.#resolveReadingRoot();
3309
+ if (!root)
3310
+ return [];
3311
+ const selector = "p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";
3312
+ this.#readingElements = Array.from(root.querySelectorAll(selector)).filter((el) => (el.textContent ?? "").trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden="true"]'));
3313
+ }
3314
+ return this.#readingElements.filter((el) => this.#isVisible(el));
3315
+ }
3316
+ /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */
3317
+ #isVisible(element) {
3318
+ if (typeof element.checkVisibility === "function") {
3319
+ return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });
3320
+ }
3321
+ return element.getClientRects().length > 0;
3057
3322
  }
3058
3323
  /**
3059
3324
  * Resolve the speech language for a reading element.
@@ -3076,7 +3341,7 @@ var TestItemToSpeech = class extends LitElement13 {
3076
3341
  #playSpeech() {
3077
3342
  const elements = this.#getReadingElements();
3078
3343
  if (!elements.length) {
3079
- console.warn("test-item-to-speech: no readable elements found in qti-item-body");
3344
+ console.warn("test-item-to-speech: no readable elements found");
3080
3345
  return;
3081
3346
  }
3082
3347
  this.#stopPicking();
@@ -3085,11 +3350,13 @@ var TestItemToSpeech = class extends LitElement13 {
3085
3350
  this.#finished = false;
3086
3351
  this.#currentElementIndex = 0;
3087
3352
  }
3353
+ if (this.#contentMode && this.#currentElementIndex === 0)
3354
+ this.#readingElements = null;
3088
3355
  this.#speakElement(this.#currentElementIndex);
3089
3356
  }
3090
3357
  /** Speak the element at the given index, then auto-advance when it ends. */
3091
3358
  #speakElement(index) {
3092
- const elements = this.#readingElements ?? [];
3359
+ const elements = this.#getReadingElements();
3093
3360
  if (index >= elements.length) {
3094
3361
  this.#clearWordHighlight();
3095
3362
  this.#currentElementIndex = elements.length - 1;
@@ -3161,9 +3428,11 @@ var TestItemToSpeech = class extends LitElement13 {
3161
3428
  }
3162
3429
  /** Highlight every reading element and wait for a click on one of them. */
3163
3430
  #startPicking() {
3431
+ if (this.#contentMode)
3432
+ this.#readingElements = null;
3164
3433
  const elements = this.#getReadingElements();
3165
3434
  if (!elements.length) {
3166
- console.warn("test-item-to-speech: no readable elements found in qti-item-body");
3435
+ console.warn("test-item-to-speech: no readable elements found");
3167
3436
  return;
3168
3437
  }
3169
3438
  this.#stop();
@@ -3185,7 +3454,7 @@ var TestItemToSpeech = class extends LitElement13 {
3185
3454
  this._ttsContext = { ...this._ttsContext, picking: false };
3186
3455
  }
3187
3456
  #handlePickClick(event) {
3188
- const elements = this.#readingElements ?? [];
3457
+ const elements = this.#getReadingElements();
3189
3458
  const path = event.composedPath();
3190
3459
  let index = elements.findIndex((el) => path.includes(el));
3191
3460
  if (index < 0) {
@@ -3237,7 +3506,7 @@ var TestItemToSpeech = class extends LitElement13 {
3237
3506
  const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
3238
3507
  let node;
3239
3508
  while (node = walker.nextNode()) {
3240
- if ((node.textContent ?? "").length > 0) {
3509
+ if ((node.textContent ?? "").length > 0 && !node.parentElement?.closest('[aria-hidden="true"]')) {
3241
3510
  nodes.push(node);
3242
3511
  }
3243
3512
  }
@@ -3328,7 +3597,7 @@ var TestItemToSpeech = class extends LitElement13 {
3328
3597
  document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
3329
3598
  }
3330
3599
  const roots = /* @__PURE__ */ new Set();
3331
- const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.closest("qti-test")?.querySelector("test-container");
3600
+ const testContainer = this.closest("test-navigation")?.querySelector("test-container") ?? this.testHost?.querySelector("test-container");
3332
3601
  if (testContainer?.shadowRoot)
3333
3602
  roots.add(testContainer.shadowRoot);
3334
3603
  const ownRoot = this.getRootNode();
@@ -3344,16 +3613,16 @@ var TestItemToSpeech = class extends LitElement13 {
3344
3613
  }
3345
3614
  }
3346
3615
  };
3347
- __decorate13([
3616
+ __decorate14([
3348
3617
  property11({ type: String })
3349
3618
  ], TestItemToSpeech.prototype, "language", void 0);
3350
- __decorate13([
3351
- property11({ type: String, attribute: "item-ref-id" })
3352
- ], TestItemToSpeech.prototype, "itemRefId", void 0);
3353
- __decorate13([
3354
- consume7({ context: sessionContext, subscribe: true })
3619
+ __decorate14([
3620
+ consume8({ context: sessionContext, subscribe: true })
3355
3621
  ], TestItemToSpeech.prototype, "_sessionContext", void 0);
3356
- __decorate13([
3622
+ __decorate14([
3623
+ consume8({ context: testHostContext, subscribe: true })
3624
+ ], TestItemToSpeech.prototype, "testHost", void 0);
3625
+ __decorate14([
3357
3626
  state4(),
3358
3627
  provide3({ context: ttsContext })
3359
3628
  ], TestItemToSpeech.prototype, "_ttsContext", void 0);
@@ -3377,7 +3646,7 @@ var TestTtsPlay = class extends TtsButtonBase {
3377
3646
  `;
3378
3647
  }
3379
3648
  };
3380
- __decorate13([
3649
+ __decorate14([
3381
3650
  property11({ type: String, attribute: "pause-label" })
3382
3651
  ], TestTtsPlay.prototype, "pauseLabel", void 0);
3383
3652
  var TestTtsPause = class extends TtsButtonBase {
@@ -3466,16 +3735,54 @@ var TestTtsPick = class extends TtsButtonBase {
3466
3735
  };
3467
3736
 
3468
3737
  // ../qti-test/dist/components/test-navigation/test-navigation.js
3469
- import { consume as consume8, provide as provide4 } from "@lit/context";
3738
+ import { ContextConsumer, consume as consume9, provide as provide4 } from "@lit/context";
3470
3739
  import { html as html13, LitElement as LitElement14 } from "lit";
3471
3740
  import { property as property12, state as state5 } from "lit/decorators.js";
3472
- var __decorate14 = function(decorators, target, key, desc) {
3741
+ var __decorate15 = function(decorators, target, key, desc) {
3473
3742
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3474
3743
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3475
3744
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3476
3745
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3477
3746
  };
3747
+ var newQtiContext = () => ({
3748
+ QTI_CONTEXT: { testIdentifier: "", candidateIdentifier: "", environmentIdentifier: "default" }
3749
+ });
3478
3750
  var TestNavigation = class extends LitElement14 {
3751
+ /**
3752
+ * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the
3753
+ * enclosing test's: reading returns it, writing replaces it, so a host that has always set the
3754
+ * shuffle seed here keeps working. Removed in the next major.
3755
+ *
3756
+ * Written before the navigation is inside a test, it waits and is handed over on connect.
3757
+ */
3758
+ get qtiContext() {
3759
+ return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());
3760
+ }
3761
+ set qtiContext(value) {
3762
+ if (!this.#warnedQtiContext) {
3763
+ this.#warnedQtiContext = true;
3764
+ console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.");
3765
+ }
3766
+ this.#writeQtiContext(value);
3767
+ }
3768
+ #pendingQtiContext;
3769
+ #warnedQtiContext;
3770
+ /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */
3771
+ #writeQtiContext(value) {
3772
+ const owner = this.#owner();
3773
+ if (owner)
3774
+ owner.qtiContext = value;
3775
+ else
3776
+ this.#pendingQtiContext = value;
3777
+ }
3778
+ /**
3779
+ * The `qti-test` this navigation is in, found through context so it works across shadow roots.
3780
+ * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.
3781
+ */
3782
+ #testHost;
3783
+ #owner() {
3784
+ return this.#testHost.value ?? null;
3785
+ }
3479
3786
  #testElement;
3480
3787
  /**
3481
3788
  * Whether each item's last *ended attempt* reached the optimal outcome, keyed
@@ -3489,13 +3796,17 @@ var TestNavigation = class extends LitElement14 {
3489
3796
  super();
3490
3797
  this.identifier = void 0;
3491
3798
  this.initContext = [];
3492
- this.qtiContext = {
3493
- QTI_CONTEXT: {
3494
- testIdentifier: "",
3495
- candidateIdentifier: "",
3496
- environmentIdentifier: "default"
3799
+ this.#warnedQtiContext = false;
3800
+ this.#testHost = new ContextConsumer(this, {
3801
+ context: testHostContext,
3802
+ subscribe: true,
3803
+ callback: (host) => {
3804
+ if (host && this.#pendingQtiContext) {
3805
+ host.qtiContext = this.#pendingQtiContext;
3806
+ this.#pendingQtiContext = void 0;
3807
+ }
3497
3808
  }
3498
- };
3809
+ });
3499
3810
  this.configContext = {};
3500
3811
  this.autoScoreItems = false;
3501
3812
  this.#optimality = /* @__PURE__ */ new Map();
@@ -3594,26 +3905,26 @@ var TestNavigation = class extends LitElement14 {
3594
3905
  candidateIdentifier: "not set",
3595
3906
  environmentIdentifier: "default"
3596
3907
  };
3597
- this.qtiContext = {
3908
+ this.#writeQtiContext({
3598
3909
  QTI_CONTEXT: {
3599
3910
  ...currentContext,
3600
3911
  testIdentifier: this.#testElement.identifier,
3601
3912
  environmentIdentifier: currentContext.environmentIdentifier || "default"
3602
3913
  }
3603
- };
3914
+ });
3604
3915
  }
3605
3916
  const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]');
3606
3917
  contextDeclarations.forEach((declaration) => {
3607
3918
  const defaultValues = this.#extractDefaultValues(declaration);
3608
3919
  if (Object.keys(defaultValues).length > 0) {
3609
- this.qtiContext = {
3920
+ this.#writeQtiContext({
3610
3921
  QTI_CONTEXT: {
3611
3922
  ...defaultValues,
3612
3923
  // Default values first
3613
3924
  ...this.qtiContext.QTI_CONTEXT
3614
3925
  // Runtime values override defaults
3615
3926
  }
3616
- };
3927
+ });
3617
3928
  }
3618
3929
  });
3619
3930
  const testPartElements = Array.from(this.#testElement?.querySelectorAll(`qti-test-part`) || []);
@@ -3785,7 +4096,7 @@ var TestNavigation = class extends LitElement14 {
3785
4096
  const response = computedItem.variables?.find((v) => v.identifier === "RESPONSE")?.value || "";
3786
4097
  const numAttempts = Number(computedItem.variables?.find((v) => v.identifier === "numAttempts")?.value) || 0;
3787
4098
  const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;
3788
- const valid = this.#assessmentItemFor(computedItem.identifier)?.validate(false) ?? true;
4099
+ const valid = itemContext?.valid ?? true;
3789
4100
  const responseVars = itemContext?.variables?.filter((v) => v.type === "response") || [];
3790
4101
  const isDefaultResponse = responseVars.every((v) => {
3791
4102
  if (v.value === void 0 || v.value === null) {
@@ -3937,41 +4248,37 @@ var TestNavigation = class extends LitElement14 {
3937
4248
  return Number.isNaN(parsed) ? null : parsed;
3938
4249
  }
3939
4250
  };
3940
- __decorate14([
4251
+ __decorate15([
3941
4252
  property12({ type: String })
3942
4253
  ], TestNavigation.prototype, "identifier", void 0);
3943
- __decorate14([
4254
+ __decorate15([
3944
4255
  state5()
3945
4256
  ], TestNavigation.prototype, "initContext", void 0);
3946
- __decorate14([
3947
- state5(),
3948
- provide4({ context: qtiContext })
3949
- ], TestNavigation.prototype, "qtiContext", void 0);
3950
- __decorate14([
4257
+ __decorate15([
3951
4258
  state5(),
3952
- consume8({ context: configContext, subscribe: true })
4259
+ consume9({ context: configContext, subscribe: true })
3953
4260
  ], TestNavigation.prototype, "configContext", void 0);
3954
- __decorate14([
4261
+ __decorate15([
3955
4262
  state5(),
3956
- consume8({ context: testContext, subscribe: true })
4263
+ consume9({ context: testContext, subscribe: true })
3957
4264
  ], TestNavigation.prototype, "_testContext", void 0);
3958
- __decorate14([
4265
+ __decorate15([
3959
4266
  state5(),
3960
- consume8({ context: sessionContext, subscribe: true })
4267
+ consume9({ context: sessionContext, subscribe: true })
3961
4268
  ], TestNavigation.prototype, "_sessionContext", void 0);
3962
- __decorate14([
4269
+ __decorate15([
3963
4270
  state5(),
3964
4271
  provide4({ context: computedContext })
3965
4272
  ], TestNavigation.prototype, "computedContext", void 0);
3966
- __decorate14([
4273
+ __decorate15([
3967
4274
  property12({ type: Boolean, attribute: "auto-score-items" })
3968
4275
  ], TestNavigation.prototype, "autoScoreItems", void 0);
3969
4276
 
3970
4277
  // ../qti-test/dist/components/test-next/test-next.js
3971
4278
  import { css as css8, html as html14, LitElement as LitElement15 } from "lit";
3972
4279
  import { property as property13 } from "lit/decorators.js";
3973
- import { consume as consume9 } from "@lit/context";
3974
- var __decorate15 = function(decorators, target, key, desc) {
4280
+ import { consume as consume10 } from "@lit/context";
4281
+ var __decorate16 = function(decorators, target, key, desc) {
3975
4282
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3976
4283
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3977
4284
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4051,20 +4358,20 @@ var TestNext = class extends LitElement15 {
4051
4358
  return html14`<slot></slot>`;
4052
4359
  }
4053
4360
  };
4054
- __decorate15([
4361
+ __decorate16([
4055
4362
  property13({ type: Boolean, reflect: true, attribute: "disabled" })
4056
4363
  ], TestNext.prototype, "_internalDisabled", void 0);
4057
- __decorate15([
4058
- consume9({ context: computedContext, subscribe: true })
4364
+ __decorate16([
4365
+ consume10({ context: computedContext, subscribe: true })
4059
4366
  ], TestNext.prototype, "computedContext", void 0);
4060
- __decorate15([
4367
+ __decorate16([
4061
4368
  watch("computedContext")
4062
4369
  ], TestNext.prototype, "_handleTestElementChange", null);
4063
4370
 
4064
4371
  // ../qti-test/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js
4065
4372
  import { html as html15, LitElement as LitElement16 } from "lit";
4066
- import { consume as consume10 } from "@lit/context";
4067
- var __decorate16 = function(decorators, target, key, desc) {
4373
+ import { consume as consume11 } from "@lit/context";
4374
+ var __decorate17 = function(decorators, target, key, desc) {
4068
4375
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4069
4376
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4070
4377
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4092,15 +4399,15 @@ var TestPagingButtonsStamp = class extends LitElement16 {
4092
4399
  return html15` ${items.map((item) => this.myTemplate({ item, view: this.computedContext.view }))} `;
4093
4400
  }
4094
4401
  };
4095
- __decorate16([
4096
- consume10({ context: computedContext, subscribe: true })
4402
+ __decorate17([
4403
+ consume11({ context: computedContext, subscribe: true })
4097
4404
  ], TestPagingButtonsStamp.prototype, "computedContext", void 0);
4098
4405
 
4099
4406
  // ../qti-test/dist/components/test-prev/test-prev.js
4100
4407
  import { css as css9, html as html16, LitElement as LitElement17 } from "lit";
4101
4408
  import { property as property14 } from "lit/decorators.js";
4102
- import { consume as consume11 } from "@lit/context";
4103
- var __decorate17 = function(decorators, target, key, desc) {
4409
+ import { consume as consume12 } from "@lit/context";
4410
+ var __decorate18 = function(decorators, target, key, desc) {
4104
4411
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4105
4412
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4106
4413
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4167,21 +4474,21 @@ var TestPrev = class extends LitElement17 {
4167
4474
  return html16`<slot></slot>`;
4168
4475
  }
4169
4476
  };
4170
- __decorate17([
4477
+ __decorate18([
4171
4478
  property14({ type: Boolean, reflect: true, attribute: "disabled" })
4172
4479
  ], TestPrev.prototype, "_internalDisabled", void 0);
4173
- __decorate17([
4174
- consume11({ context: computedContext, subscribe: true })
4480
+ __decorate18([
4481
+ consume12({ context: computedContext, subscribe: true })
4175
4482
  ], TestPrev.prototype, "computedContext", void 0);
4176
- __decorate17([
4483
+ __decorate18([
4177
4484
  watch("computedContext")
4178
4485
  ], TestPrev.prototype, "_handleTestElementChange", null);
4179
4486
 
4180
4487
  // ../qti-test/dist/components/test-print-context/test-print-context.js
4181
4488
  import { html as html17, LitElement as LitElement18 } from "lit";
4182
- import { consume as consume12 } from "@lit/context";
4489
+ import { consume as consume13 } from "@lit/context";
4183
4490
  import { state as state6 } from "lit/decorators.js";
4184
- var __decorate18 = function(decorators, target, key, desc) {
4491
+ var __decorate19 = function(decorators, target, key, desc) {
4185
4492
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4186
4493
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4187
4494
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4192,15 +4499,15 @@ var TestPrintContext = class extends LitElement18 {
4192
4499
  return html17` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;
4193
4500
  }
4194
4501
  };
4195
- __decorate18([
4502
+ __decorate19([
4196
4503
  state6(),
4197
- consume12({ context: computedContext, subscribe: true })
4504
+ consume13({ context: computedContext, subscribe: true })
4198
4505
  ], TestPrintContext.prototype, "computedContext", void 0);
4199
4506
 
4200
4507
  // ../qti-test/dist/components/test-print-item-variables/test-print-item-variables.js
4201
4508
  import { html as html18, css as css10, LitElement as LitElement19 } from "lit";
4202
- import { consume as consume13 } from "@lit/context";
4203
- var __decorate19 = function(decorators, target, key, desc) {
4509
+ import { consume as consume14 } from "@lit/context";
4510
+ var __decorate20 = function(decorators, target, key, desc) {
4204
4511
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4205
4512
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4206
4513
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4272,15 +4579,15 @@ var TestPrintVariables = class extends LitElement19 {
4272
4579
  `;
4273
4580
  }
4274
4581
  };
4275
- __decorate19([
4276
- consume13({ context: computedContext, subscribe: true })
4582
+ __decorate20([
4583
+ consume14({ context: computedContext, subscribe: true })
4277
4584
  ], TestPrintVariables.prototype, "computedContext", void 0);
4278
4585
 
4279
4586
  // ../qti-test/dist/components/test-scoring-buttons/test-scoring-buttons.js
4280
4587
  import { html as html19, LitElement as LitElement20, nothing as nothing3 } from "lit";
4281
- import { consume as consume14 } from "@lit/context";
4588
+ import { consume as consume15 } from "@lit/context";
4282
4589
  import { property as property15 } from "lit/decorators.js";
4283
- var __decorate20 = function(decorators, target, key, desc) {
4590
+ var __decorate21 = function(decorators, target, key, desc) {
4284
4591
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4285
4592
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4286
4593
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4339,21 +4646,21 @@ var TestScoringButtons = class extends LitElement20 {
4339
4646
  });
4340
4647
  }
4341
4648
  };
4342
- __decorate20([
4649
+ __decorate21([
4343
4650
  property15({ type: String, attribute: "view" })
4344
4651
  ], TestScoringButtons.prototype, "view", void 0);
4345
- __decorate20([
4652
+ __decorate21([
4346
4653
  property15({ type: Boolean })
4347
4654
  ], TestScoringButtons.prototype, "disabled", void 0);
4348
- __decorate20([
4349
- consume14({ context: computedContext, subscribe: true })
4655
+ __decorate21([
4656
+ consume15({ context: computedContext, subscribe: true })
4350
4657
  ], TestScoringButtons.prototype, "computedContext", void 0);
4351
4658
 
4352
4659
  // ../qti-test/dist/components/test-scoring-feedback/test-scoring-feedback.js
4353
- import { consume as consume15 } from "@lit/context";
4660
+ import { consume as consume16 } from "@lit/context";
4354
4661
  import { html as html20, LitElement as LitElement21 } from "lit";
4355
4662
  import { property as property16 } from "lit/decorators.js";
4356
- var __decorate21 = function(decorators, target, key, desc) {
4663
+ var __decorate22 = function(decorators, target, key, desc) {
4357
4664
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4358
4665
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4359
4666
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4392,17 +4699,17 @@ var TestScoringFeedback = class extends LitElement21 {
4392
4699
  return html20`<div>${feedbackText()}</div>`;
4393
4700
  }
4394
4701
  };
4395
- __decorate21([
4396
- consume15({ context: computedContext, subscribe: true })
4702
+ __decorate22([
4703
+ consume16({ context: computedContext, subscribe: true })
4397
4704
  ], TestScoringFeedback.prototype, "computedContext", void 0);
4398
- __decorate21([
4705
+ __decorate22([
4399
4706
  property16({ type: String, attribute: "view" })
4400
4707
  ], TestScoringFeedback.prototype, "view", void 0);
4401
4708
 
4402
4709
  // ../qti-test/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js
4403
4710
  import { html as html21, LitElement as LitElement22 } from "lit";
4404
- import { consume as consume16 } from "@lit/context";
4405
- var __decorate22 = function(decorators, target, key, desc) {
4711
+ import { consume as consume17 } from "@lit/context";
4712
+ var __decorate23 = function(decorators, target, key, desc) {
4406
4713
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4407
4714
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4408
4715
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4430,14 +4737,14 @@ var TestSectionButtonsStamp = class extends LitElement22 {
4430
4737
  return html21` ${sections.map((item) => this.myTemplate({ item }))} `;
4431
4738
  }
4432
4739
  };
4433
- __decorate22([
4434
- consume16({ context: computedContext, subscribe: true })
4740
+ __decorate23([
4741
+ consume17({ context: computedContext, subscribe: true })
4435
4742
  ], TestSectionButtonsStamp.prototype, "computedContext", void 0);
4436
4743
 
4437
4744
  // ../qti-test/dist/components/test-section-link/test-section-link.js
4438
4745
  import { css as css11, html as html22, LitElement as LitElement23 } from "lit";
4439
4746
  import { property as property17 } from "lit/decorators.js";
4440
- var __decorate23 = function(decorators, target, key, desc) {
4747
+ var __decorate24 = function(decorators, target, key, desc) {
4441
4748
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4442
4749
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4443
4750
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4479,15 +4786,15 @@ var TestSectionLink = class extends LitElement23 {
4479
4786
  return html22` <slot></slot> `;
4480
4787
  }
4481
4788
  };
4482
- __decorate23([
4789
+ __decorate24([
4483
4790
  property17({ type: String, attribute: "section-id" })
4484
4791
  ], TestSectionLink.prototype, "sectionId", void 0);
4485
4792
 
4486
4793
  // ../qti-test/dist/components/test-stamp/test-stamp.js
4487
4794
  import { html as html23, LitElement as LitElement24, nothing as nothing4 } from "lit";
4488
4795
  import { property as property18, state as state7 } from "lit/decorators.js";
4489
- import { consume as consume17 } from "@lit/context";
4490
- var __decorate24 = function(decorators, target, key, desc) {
4796
+ import { consume as consume18 } from "@lit/context";
4797
+ var __decorate25 = function(decorators, target, key, desc) {
4491
4798
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4492
4799
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4493
4800
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4560,22 +4867,22 @@ var TestStamp = class extends LitElement24 {
4560
4867
  ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing4}`;
4561
4868
  }
4562
4869
  };
4563
- __decorate24([
4870
+ __decorate25([
4564
4871
  property18({ type: Boolean, reflect: true })
4565
4872
  ], TestStamp.prototype, "debug", void 0);
4566
- __decorate24([
4873
+ __decorate25([
4567
4874
  state7(),
4568
- consume17({ context: computedContext, subscribe: true })
4875
+ consume18({ context: computedContext, subscribe: true })
4569
4876
  ], TestStamp.prototype, "computedContext", void 0);
4570
- __decorate24([
4877
+ __decorate25([
4571
4878
  state7()
4572
4879
  ], TestStamp.prototype, "stampContext", void 0);
4573
4880
 
4574
4881
  // ../qti-test/dist/components/test-view-toggle/test-view.js
4575
4882
  import { html as html24, LitElement as LitElement25 } from "lit";
4576
4883
  import { property as property19, state as state8 } from "lit/decorators.js";
4577
- import { consume as consume18 } from "@lit/context";
4578
- var __decorate25 = function(decorators, target, key, desc) {
4884
+ import { consume as consume19 } from "@lit/context";
4885
+ var __decorate26 = function(decorators, target, key, desc) {
4579
4886
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4580
4887
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4581
4888
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4630,26 +4937,26 @@ var TestView = class extends LitElement25 {
4630
4937
  }
4631
4938
  };
4632
4939
  _a = TestView;
4633
- __decorate25([
4634
- consume18({ context: sessionContext, subscribe: true })
4940
+ __decorate26([
4941
+ consume19({ context: sessionContext, subscribe: true })
4635
4942
  ], TestView.prototype, "sessionContext", void 0);
4636
- __decorate25([
4943
+ __decorate26([
4637
4944
  property19({ type: String })
4638
4945
  ], TestView.prototype, "label", void 0);
4639
- __decorate25([
4946
+ __decorate26([
4640
4947
  property19({ type: String, attribute: "view-options" })
4641
4948
  ], TestView.prototype, "viewOptions", void 0);
4642
- __decorate25([
4949
+ __decorate26([
4643
4950
  watch("viewOptions", { waitUntilFirstUpdate: true })
4644
4951
  ], TestView.prototype, "_handleViewOptionsChange", void 0);
4645
- __decorate25([
4952
+ __decorate26([
4646
4953
  state8()
4647
4954
  ], TestView.prototype, "_viewOptions", void 0);
4648
4955
 
4649
4956
  // ../qti-test/dist/components/test-view-toggle/test-view-toggle.js
4650
- import { consume as consume19 } from "@lit/context";
4957
+ import { consume as consume20 } from "@lit/context";
4651
4958
  import { html as html25, LitElement as LitElement26, nothing as nothing5 } from "lit";
4652
- var __decorate26 = function(decorators, target, key, desc) {
4959
+ var __decorate27 = function(decorators, target, key, desc) {
4653
4960
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4654
4961
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4655
4962
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -4690,8 +4997,8 @@ var TestViewToggle = class extends LitElement26 {
4690
4997
  }) : nothing5}`;
4691
4998
  }
4692
4999
  };
4693
- __decorate26([
4694
- consume19({ context: sessionContext, subscribe: true })
5000
+ __decorate27([
5001
+ consume20({ context: sessionContext, subscribe: true })
4695
5002
  ], TestViewToggle.prototype, "sessionContext", void 0);
4696
5003
 
4697
5004
  // ../qti-test/dist/elements.js
@@ -4745,6 +5052,7 @@ export {
4745
5052
  QtiTestPart,
4746
5053
  QtiTestVariables,
4747
5054
  QtiTestVariablesExpression,
5055
+ QTI_TEST_STATE_VERSION,
4748
5056
  QtiTest,
4749
5057
  TestCheckItem,
4750
5058
  TestContainer,
@@ -4786,4 +5094,4 @@ export {
4786
5094
  * Portions Copyright (c) 2013, the Dart project authors.
4787
5095
  *)
4788
5096
  */
4789
- //# sourceMappingURL=chunk-TDWLV5OD.js.map
5097
+ //# sourceMappingURL=chunk-GNTO3IFM.js.map