@citolab/qti-components 10.0.0-next.0 → 10.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +191 -183
  3. package/dist/base.d.ts +2 -2
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-EPSUZIWL.js → chunk-2KP5UU5A.js} +6 -6
  6. package/dist/{chunk-GPNWMLLA.js → chunk-35WWWFS6.js} +2 -2
  7. package/dist/{chunk-QD3Y6UK3.js → chunk-3ZNECUPV.js} +2 -2
  8. package/dist/{chunk-3BAQWO5C.js → chunk-6K3QWJHH.js} +2 -2
  9. package/dist/{chunk-AWTQKBC4.js → chunk-6U3YPHXU.js} +2 -2
  10. package/dist/{chunk-WNAOVXXN.js → chunk-FD4AB6TM.js} +2 -2
  11. package/dist/{chunk-SVYHZIJ7.js → chunk-GBZNFSFY.js} +2 -2
  12. package/dist/{chunk-EUKU5QKV.js → chunk-K3VKQ6QF.js} +509 -274
  13. package/dist/chunk-K3VKQ6QF.js.map +1 -0
  14. package/dist/{chunk-ACRN7YJM.js → chunk-MI7774NV.js} +2 -2
  15. package/dist/{chunk-CNFVA3AA.js → chunk-RSMYGGQK.js} +2 -2
  16. package/dist/{chunk-F7R7GSWL.js → chunk-RU6332MD.js} +2 -2
  17. package/dist/{chunk-R7MMMDP7.js → chunk-TDWJ6WZA.js} +20 -2
  18. package/dist/chunk-TDWJ6WZA.js.map +1 -0
  19. package/dist/corrections.d.ts +2 -2
  20. package/dist/corrections.js +7 -7
  21. package/dist/elements.js +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +16 -12
  24. package/dist/interactions.js +3 -3
  25. package/dist/item.js +3 -3
  26. package/dist/processing.d.ts +2 -2
  27. package/dist/processing.js +3 -3
  28. package/dist/qti-components-jsx.d.ts +120 -0
  29. package/dist/{qti-condition-expression.d-L7yb3Rzy.d.ts → qti-condition-expression.d-VJH6cWxf.d.ts} +1 -1
  30. package/dist/{qti-expression.d-CuaLjZ6g.d.ts → qti-expression.d-BPxEp8HU.d.ts} +7 -0
  31. package/dist/{qti-test.d-_THYXPzd.d.ts → qti-test.d-DkpBNcsv.d.ts} +62 -2
  32. package/dist/test.d.ts +3 -3
  33. package/dist/test.js +8 -4
  34. package/package.json +8 -8
  35. package/dist/chunk-EUKU5QKV.js.map +0 -1
  36. package/dist/chunk-R7MMMDP7.js.map +0 -1
  37. /package/dist/{chunk-EPSUZIWL.js.map → chunk-2KP5UU5A.js.map} +0 -0
  38. /package/dist/{chunk-GPNWMLLA.js.map → chunk-35WWWFS6.js.map} +0 -0
  39. /package/dist/{chunk-QD3Y6UK3.js.map → chunk-3ZNECUPV.js.map} +0 -0
  40. /package/dist/{chunk-3BAQWO5C.js.map → chunk-6K3QWJHH.js.map} +0 -0
  41. /package/dist/{chunk-AWTQKBC4.js.map → chunk-6U3YPHXU.js.map} +0 -0
  42. /package/dist/{chunk-WNAOVXXN.js.map → chunk-FD4AB6TM.js.map} +0 -0
  43. /package/dist/{chunk-SVYHZIJ7.js.map → chunk-GBZNFSFY.js.map} +0 -0
  44. /package/dist/{chunk-ACRN7YJM.js.map → chunk-MI7774NV.js.map} +0 -0
  45. /package/dist/{chunk-CNFVA3AA.js.map → chunk-RSMYGGQK.js.map} +0 -0
  46. /package/dist/{chunk-F7R7GSWL.js.map → chunk-RU6332MD.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiProcessingElements
3
- } from "./chunk-3BAQWO5C.js";
3
+ } from "./chunk-6K3QWJHH.js";
4
4
 
5
5
  // ../qti-processing/dist/register.js
6
6
  for (const { tag, ctor } of qtiProcessingElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiProcessingElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-ACRN7YJM.js.map
11
+ //# sourceMappingURL=chunk-MI7774NV.js.map
@@ -14,7 +14,7 @@ import {
14
14
  responseAttributeConverter,
15
15
  serializeResponseAttribute,
16
16
  validationMessage
17
- } from "./chunk-R7MMMDP7.js";
17
+ } from "./chunk-TDWJ6WZA.js";
18
18
 
19
19
  // ../interactions/core/dist/elements/qti-associable-hotspot/qti-associable-hotspot.js
20
20
  import { LitElement, html } from "lit";
@@ -11834,4 +11834,4 @@ export {
11834
11834
  elements31 as elements21,
11835
11835
  qtiInteractionElements
11836
11836
  };
11837
- //# sourceMappingURL=chunk-CNFVA3AA.js.map
11837
+ //# sourceMappingURL=chunk-RSMYGGQK.js.map
@@ -11,7 +11,7 @@ import {
11
11
  computedItemContext,
12
12
  configContext,
13
13
  qtiContext
14
- } from "./chunk-R7MMMDP7.js";
14
+ } from "./chunk-TDWJ6WZA.js";
15
15
 
16
16
  // ../qti-item/dist/components/item-container/item-container.js
17
17
  import { consume } from "@lit/context";
@@ -349,4 +349,4 @@ export {
349
349
  QtiItem,
350
350
  qtiItemElements
351
351
  };
352
- //# sourceMappingURL=chunk-F7R7GSWL.js.map
352
+ //# sourceMappingURL=chunk-RU6332MD.js.map
@@ -732,7 +732,20 @@ var QtiExpression = class extends LitElement3 {
732
732
  * throwing, so callers degrade gracefully.
733
733
  */
734
734
  resolveVariable(identifier) {
735
- return this.context?.variables.find((v) => v.identifier === identifier) ?? this._testContext?.testOutcomeVariables?.find((v) => v.identifier === identifier) ?? null;
735
+ return this.context?.variables.find((v) => v.identifier === identifier) ?? this._testContext?.testOutcomeVariables?.find((v) => v.identifier === identifier) ?? this.resolveItemVariable(identifier);
736
+ }
737
+ /**
738
+ * `ITEMREF.VAR`: a variable of an individual item session, looked up by prefixing the variable
739
+ * with the identifier the item ref gave the item (QTI 3 `qti-variable`), e.g. `Q01.SCORE`. An
740
+ * item that was never presented has no variables, which resolves to NULL. Instances of a cloned
741
+ * item (`Q01.2.SCORE`) are not supported: the item itself is used.
742
+ */
743
+ resolveItemVariable(identifier) {
744
+ if (!identifier?.includes("."))
745
+ return null;
746
+ const parts = identifier.split(".");
747
+ const item = this._testContext?.items?.find((i) => i.identifier === parts[0]);
748
+ return item?.variables?.find((v) => v.identifier === parts[parts.length - 1]) ?? null;
736
749
  }
737
750
  };
738
751
  __decorate2([
@@ -1023,6 +1036,7 @@ var unregisterCustomOperator = (definition) => {
1023
1036
  var getCustomOperator = (definition) => registered.get(definition) ?? builtIns.get(definition) ?? null;
1024
1037
 
1025
1038
  // ../qti-base/dist/utils/scoring-helper.js
1039
+ var SCORING_BOOLEANS = { true: true, "1": true, false: false, "0": false };
1026
1040
  var ScoringHelper = class {
1027
1041
  /**
1028
1042
  * Checks if a given point is within a specified area.
@@ -1113,6 +1127,10 @@ var ScoringHelper = class {
1113
1127
  case "identifier":
1114
1128
  case "string":
1115
1129
  return value1 === value2;
1130
+ case "boolean": {
1131
+ const bool1 = SCORING_BOOLEANS[value1.trim().toLowerCase()];
1132
+ return bool1 !== void 0 && bool1 === SCORING_BOOLEANS[value2.trim().toLowerCase()];
1133
+ }
1116
1134
  case "integer": {
1117
1135
  const int1 = parseInt(value1, 10);
1118
1136
  const int2 = parseInt(value2, 10);
@@ -1226,4 +1244,4 @@ export {
1226
1244
  getCustomOperator,
1227
1245
  ScoringHelper
1228
1246
  };
1229
- //# sourceMappingURL=chunk-R7MMMDP7.js.map
1247
+ //# sourceMappingURL=chunk-TDWJ6WZA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-base/src/elements.ts","../../qti-base/src/utils/custom-state-set.ts","../../qti-base/src/context/computed-item.context.ts","../../qti-base/src/context/computed.context.ts","../../qti-base/src/context/config.context.ts","../../qti-base/src/context/interaction.context.ts","../../qti-base/src/context/item.context.ts","../../qti-base/src/context/types/item.types.ts","../../qti-base/src/context/qti.context.ts","../../qti-base/src/context/session.context.ts","../../qti-base/src/context/test.context.ts","../../qti-base/src/styles/box-sizing.styles.ts","../../qti-base/src/styles/drop-region.styles.ts","../../qti-base/src/styles/validation-message.styles.ts","../../qti-base/src/abstract/interaction.ts","../../qti-base/src/abstract/qti-variable-declaration.ts","../../qti-base/src/abstract/qti-expression.ts","../../qti-base/src/abstract/qti-condition-expression.ts","../../qti-base/src/utils/utils.ts","../../qti-base/src/abstract/qti-feedback.ts","../../qti-base/src/lib/response.ts","../../qti-base/src/lib/qti-rule-base.ts","../../qti-base/src/lib/custom-operators.ts","../../qti-base/src/utils/scoring-helper.ts","../../qti-base/src/context/context-root.ts","../../qti-base/src/register.ts"],"sourcesContent":["/**\n * Custom elements this package registers into an application's registry.\n *\n * Empty, deliberately. `qti-base` is abstractions and context — it contributes no elements to a\n * delivery application.\n *\n * The one entry that used to be here, `qti-config-test-provider`, is gone entirely. It was a\n * TEST-ONLY wrapper that every consumer of `import '@qti-components/base'` registered transitively,\n * and it carried `@customElement(...)` on top of this list — an UNGUARDED `customElements.define()`\n * at module-evaluation time. A module graph holding two copies of this package (a workspace build\n * alongside a published dist, which is what the editor resolves) evaluated it twice and the second\n * threw `NotSupportedError: ... already been used with this registry`, aborting module evaluation\n * and taking down every test file that imported it — 34 suites in the editor, none of which used\n * the element. `register.ts` had the guard right all along; the decorator bypassed it.\n *\n * Config for a single interaction is a property binding now — see config.context.ts.\n *\n * The array and `register.ts` stay so the elements + guarded-register convention the other 30\n * packages follow is already in place the day this package does own an element.\n */\nexport const qtiBaseElements: readonly { tag: string; ctor: CustomElementConstructor }[] = [];\n","/**\n * Custom-state support shim for browsers this library cannot use natively.\n *\n * Interactions track selection and correct/incorrect marking through\n * `internals.states`, with bare state names (`checked`, `radio`,\n * `correct-response`, …). Two browser profiles cannot service that:\n *\n * - Safari 16.4–17.3 implement `ElementInternals` but not `CustomStateSet`, so\n * `internals.states` is `undefined` and reading it throws — \"undefined is not\n * an object (evaluating 'internals.states.has')\".\n * - Chrome and Edge before the CSS custom-state spec change expose `states` but\n * reject names that do not start with `--`, so `states.add('radio')` throws\n * \"The specified value 'radio' must start with '--'\".\n *\n * On both, picking a choice throws rather than registering. `attachInternals`\n * itself is unguarded throughout the interaction base classes, which puts the\n * hard support floor at Safari 16.4 — inside the range that breaks.\n *\n * The shim replaces `states` with a permissive `Set` and mirrors its contents to\n * a space-separated `data-state` attribute on the host, because these browsers'\n * CSS parsers also drop any selector list containing `:state()`. The theme's\n * built stylesheets pair every `:state(x)` with a `[data-state~='x']` arm (see\n * `tools/postcss/custom-state-fallback.mjs`), so styling survives too.\n *\n * Support is classified by behaviour rather than by browser version, and the\n * shim is not installed at all where `states` works.\n */\n\n/** A permissive `CustomStateSet` that mirrors its contents to `data-state`. */\nexport class CustomStateSetShim extends Set<string> {\n readonly #host: HTMLElement;\n\n constructor(host: HTMLElement) {\n super();\n this.#host = host;\n }\n\n override add(state: string): this {\n super.add(state);\n this.#reflect();\n return this;\n }\n\n override delete(state: string): boolean {\n const deleted = super.delete(state);\n this.#reflect();\n return deleted;\n }\n\n override clear(): void {\n super.clear();\n this.#reflect();\n }\n\n #reflect(): void {\n // A custom element must not gain attributes while it is upgrading, so defer\n // the write until the element is connected.\n if (this.#host.isConnected) this.#write();\n else queueMicrotask(() => this.#write());\n }\n\n #write(): void {\n if (this.size === 0) this.#host.removeAttribute('data-state');\n else this.#host.setAttribute('data-state', Array.from(this).join(' '));\n }\n}\n\nexport type CustomStateSupport = 'missing' | 'legacy' | 'modern';\n\nconst PROBE_TAG = 'custom-state-support-probe';\n\n/**\n * Classify native custom-state support by behaviour:\n *\n * - `missing`: `ElementInternals` carries no `states` at all.\n * - `legacy`: `states` exists but rejects a bare name.\n * - `modern`: `states` exists and accepts a bare name — no shim wanted.\n *\n * `attachInternals` only works on a custom element, so the probe registers a\n * throwaway one. That happens solely when `states` is present, so the `missing`\n * path never defines anything.\n */\nexport function classifyCustomStateSupport(\n attachInternals: (this: HTMLElement) => ElementInternals\n): CustomStateSupport {\n if (!('states' in ElementInternals.prototype)) return 'missing';\n if (typeof customElements === 'undefined') return 'modern';\n\n try {\n if (!customElements.get(PROBE_TAG)) customElements.define(PROBE_TAG, class extends HTMLElement {});\n const states = attachInternals.call(document.createElement(PROBE_TAG)).states;\n if (!states) return 'missing';\n // A bare name throws SyntaxError under the legacy spec and never does under\n // the current one, so classify on the throw alone — not on whether the value\n // sticks, which some environments do not honour on a detached element.\n states.add('probe');\n states.delete('probe');\n return 'modern';\n } catch {\n return 'legacy';\n }\n}\n\nlet installed = false;\n\n/**\n * Patch `HTMLElement.prototype.attachInternals` so every element's `states` is\n * the shim, on the two profiles that need it. Idempotent, and a no-op where\n * native support is usable.\n *\n * Returns the classification that was acted on, which is what the tests assert.\n */\nexport function installCustomStateSetFallback(): CustomStateSupport | 'already-installed' {\n if (installed) return 'already-installed';\n if (typeof HTMLElement === 'undefined' || typeof ElementInternals === 'undefined') return 'modern';\n\n const native = HTMLElement.prototype.attachInternals;\n if (!native) return 'modern';\n\n const support = classifyCustomStateSupport(native);\n if (support === 'modern') return support;\n\n installed = true;\n HTMLElement.prototype.attachInternals = function attachInternals(this: HTMLElement): ElementInternals {\n const internals = native.call(this);\n Object.defineProperty(internals, 'states', {\n configurable: true,\n enumerable: true,\n value: new CustomStateSetShim(this)\n });\n return internals;\n };\n\n return support;\n}\n","import { createContext } from '@lit/context';\n\nimport type { ComputedItemContext } from './types/computed-item.types';\n\nexport const computedItemContext = createContext<Readonly<ComputedItemContext>>(Symbol('computedItemContext'));\n","import { createContext } from '@lit/context';\n\nimport type { ComputedContext } from './types/computed.types';\n\nexport const computedContext = createContext<Readonly<ComputedContext>>(Symbol('computedContext'));\n","import { createContext } from '@lit/context';\n\nexport type ValidationDisplayMode = 'inline' | 'native' | 'both' | 'none';\n\n/**\n * Configuration context for QTI components. Provides runtime options for assessment item and\n * interaction behavior.\n *\n * ── Three ways to set it, in the order you should reach for them ─────────────────────────────\n *\n * 1. **On a provider**, for real delivery. `qti-test` and `qti-item` both provide it, so setting\n * `item.configContext = {…}` configures every interaction inside.\n *\n * 2. **On one interaction, directly** — the development-time route, and the reason\n * `Interaction.configContext` is public:\n *\n * orderInteraction.configContext = { allowReorder: false };\n *\n * or, in a lit-html template, as a property binding — which lands before `connectedCallback`:\n *\n * html`<qti-order-interaction .configContext=${{ allowReorder: false }}>…`\n *\n * An interaction has to work standalone, so in a story or a spec there is usually no provider\n * above it, and then nothing ever overwrites what you set. Where a provider DOES exist it wins on\n * its next emit, because `@consume` writes that same field.\n *\n * A `qti-config-test-provider` element used to exist for scoping config to a subtree. It is gone:\n * it was test-only yet registered itself into every consumer's element registry via an unguarded\n * `@customElement`, which threw whenever two copies of this package ended up in one module graph.\n * Bind the property on each interaction instead, or provide from `qti-item`.\n *\n * There is no merging at any level: @lit/context resolves to the nearest provider and that object\n * replaces the ancestor's wholesale. A deeper provider therefore has to restate anything from above\n * that it still wants.\n *\n * Note what is NOT here. Options an item author chooses per question are attributes on the\n * interaction (`auto-size-dropzones`, `max-associations`, `disable-animations`); options only a\n * developer chooses are mixin factory arguments or method overrides. This context is for what a\n * delivery environment decides across items. `interactionContext` and `dragDropContext` are neither\n * — they publish derived state (what a choice IS, what a drop HOLDS), never configuration.\n */\nexport interface ConfigContext {\n /**\n * Optional category label for info items, used for reporting or display purposes.\n * Example: \"General Information\", \"Instructions\".\n */\n infoItemCategory?: string;\n\n /**\n * If true, calls reportValidity() on interactions after scoring to show validation feedback.\n * Used to trigger UI validation after a scoring event.\n */\n reportValidityAfterScoring?: boolean;\n\n /**\n * Controls how validation feedback is displayed by interactions:\n * - 'inline': render message in #validation-message (default behavior)\n * - 'native': use browser-native reportValidity popup behavior\n * - 'both': show both inline and native feedback\n * - 'none': keep validity state only, without visual feedback\n */\n validationDisplayMode?: ValidationDisplayMode;\n\n /**\n * If true, disables further user actions when an interaction reaches its configured maximum.\n * Applies to both choice-based and drag/drop interactions.\n */\n disableAfterMaxReached?: boolean;\n\n /**\n * If false, chips already placed in a drop target cannot be reordered or moved between targets in\n * drag/drop sortable interactions (order, match, gap-match). Defaults to true. A per-interaction\n * `allowReorder` property overrides this.\n */\n allowReorder?: boolean;\n\n /**\n * If true, disables further selection in choice interactions after the maximum number of choices is reached.\n * @deprecated Legacy alias for choice interactions. Prefer disableAfterMaxReached.\n */\n disableAfterIfMaxChoicesReached?: boolean;\n\n /**\n * Optional prompt text to display in inline choice interactions when no option is selected.\n * Example: \"Select an answer...\"\n */\n inlineChoicePrompt?: string;\n\n /**\n * If true, the inline choice interaction automatically measures the widest option and sizes the\n * trigger button to match. Defaults to false.\n * When a `qti-input-width-*` class is present on the interaction, that class width always takes\n * precedence and autosizing is skipped regardless of this setting.\n */\n inlineChoiceAutosize?: boolean;\n}\n\nexport const configContext = createContext<Readonly<ConfigContext>>(Symbol('configContext'));\n","import { createContext } from '@lit/context';\n\n/**\n * What a choice element should render and behave as. The same element — `qti-simple-choice`,\n * `qti-hottext` — is a radio in one interaction and a checkbox in another. It cannot know this\n * by itself.\n *\n * Note \"drag\" is deliberately *not* a choiceRole. In `qti-match-interaction` the same element\n * type is a drag in one match-set and a drop target in the other, so draggability is positional,\n * not a property of the interaction. It is derived from `draggablesSelector` instead. It is also\n * not a valid ARIA role, so it may only ever be a custom state.\n */\nexport type ChoiceRole = 'radio' | 'checkbox';\n\n/**\n * State an interaction publishes to the choice elements inside it.\n *\n * Provided by the `qti-*-interaction`, never by `qti-assessment-item`: interactions must work\n * standalone — in a plain form, in a story, in a vendor's app — with no QTI ancestor. Consumers\n * must therefore tolerate its absence and fall back to a sensible default:\n *\n * const role = this.interactionContext?.choiceRole ?? null;\n */\nexport interface InteractionContext {\n /** `null` when the interaction assigns no particular role to its choices. */\n choiceRole: ChoiceRole | null;\n\n /**\n * The selector this interaction uses to recognise its draggable chips. An element tests\n * itself with `this.matches(draggablesSelector)` and takes `:state(chip)` if it matches.\n *\n * Published rather than pushed because draggability can be positional: match-interaction's\n * selector distinguishes the source match-set from the target one, so two elements of the\n * same tag get different answers.\n */\n draggablesSelector: string | null;\n}\n\nexport const interactionContext = createContext<Readonly<InteractionContext>>(Symbol('interactionContext'));\n","import { createContext } from '@lit/context';\n\nimport type { ItemContext } from './types/item.types';\n\nexport const itemContext = createContext<ItemContext>(Symbol('item'));\n","import type { VariableDeclaration } from '../../lib/variables';\n\nexport interface ItemContext {\n identifier?: string;\n href?: string;\n variables?: ReadonlyArray<VariableDeclaration<string | string[] | null>>;\n /**\n * Optional per-interaction opaque state, keyed by responseIdentifier.\n * Used for interactions that support state save/restore (e.g. PCI).\n */\n state?: Record<string, string | null>;\n /** The item is shown for reading only. Interactions follow it; see `qti-assessment-item`'s `readonly`. */\n readonly?: boolean;\n /** The item is locked, for example after it was submitted. Interactions follow it; see `qti-assessment-item`'s `disabled`. */\n disabled?: boolean;\n /**\n * Whether the interactions in the item are valid right now (a required answer is given, a limit is\n * respected). Published by the item whenever it checks, so a reader never has to ask the item.\n * Unset until the item has checked once.\n */\n valid?: boolean;\n}\n\nexport const itemContextVariables = [\n {\n identifier: 'completionStatus',\n cardinality: 'single',\n baseType: 'string',\n value: 'unknown',\n type: 'outcome'\n },\n {\n identifier: 'numAttempts',\n cardinality: 'single',\n baseType: 'integer',\n value: '0',\n type: 'response'\n }\n] as VariableDeclaration<string | string[]>[];\n","import { createContext } from '@lit/context';\n\n/**\n * A validated deterministic shuffle seed.\n *\n * Branded so that only values verified through {@link isSeed} (or constructed via\n * {@link asSeed}) can be assigned where a seed is expected. This prevents arbitrary\n * strings from silently being used as a seed.\n *\n * A usable seed is a non-empty string of letters, digits and hyphens (e.g. a GUID\n * \"N\" format like `8f14e45fceea167a5a36dedd4bea2543`, or a readable label like\n * `delivery-2026-06-05`). Whitespace and other characters are rejected.\n */\nexport type Seed = string & { readonly __seedBrand: 'Seed' };\n\n/** Format a value must match to be usable as a {@link Seed}. */\nconst SEED_PATTERN = /^[A-Za-z0-9-]+$/;\n\n/**\n * Runtime type guard that narrows an unknown value to a {@link Seed}.\n * Use this at boundaries (e.g. values coming from XML, a host application or a\n * backend) before treating a string as a seed.\n */\nexport const isSeed = (value: unknown): value is Seed => typeof value === 'string' && SEED_PATTERN.test(value);\n\n/**\n * Validates and brands a value as a {@link Seed}, returning `undefined` when the\n * value is missing or not in a usable seed format.\n */\nexport const asSeed = (value: unknown): Seed | undefined => (isSeed(value) ? value : undefined);\n\nexport type QtiContextType = {\n testIdentifier: string;\n candidateIdentifier: string;\n environmentIdentifier: string;\n /**\n * Optional deterministic seed for shuffling.\n *\n * When set, it is used to reproduce a stable shuffle order across reloads/restarts:\n * - test ordering in `test-container` (`<qti-ordering shuffle=\"true\">`),\n * - seeded item interaction shuffling in `item-container` and during test navigation.\n *\n * Typically generated once per session by the host/backend and passed in via\n * `QTI_CONTEXT`. When omitted, each item falls back to its own URI-derived seed.\n */\n seed?: Seed;\n [key: string]: string | string[]; // Allow for additional context variables\n};\n\nexport interface QtiContext {\n QTI_CONTEXT: QtiContextType;\n}\n\nexport const qtiContext = createContext<Readonly<QtiContext>>(Symbol('qtiContext'));\n","import { createContext } from '@lit/context';\n\nexport type View = 'author' | 'candidate' | 'proctor' | 'scorer' | 'testConstructor' | 'tutor' | '';\n\nexport interface SessionContext {\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n /** @deprecated Never set by the library. Removed in the next major. */\n navItemLoading?: boolean;\n /** @deprecated Never set by the library. Removed in the next major. */\n navTestLoading?: boolean;\n view?: View;\n}\n\nexport const INITIAL_SESSION_CONTEXT: Readonly<SessionContext> = { view: 'candidate' };\n\nexport const sessionContext = createContext<Readonly<SessionContext>>(Symbol('sessionContext'));\n","import { createContext } from '@lit/context';\n\nimport type { ItemContext } from './types/item.types';\nimport type { VariableDeclaration } from '../lib/variables';\n\nexport interface TestContext {\n items: (ItemContext & { category?: string })[];\n testOutcomeVariables?: VariableDeclaration<string | string[] | null>[];\n}\n\nexport const INITIAL_TEST_CONTEXT: Readonly<TestContext> = { items: [], testOutcomeVariables: [] };\n\nexport const testContext = createContext<Readonly<TestContext>>(Symbol('testContext'));\n","import { css } from 'lit';\n\n/**\n * The border-box reset, for shadow trees.\n *\n * `modern-normalize` applies `*, ::before, ::after { box-sizing: border-box }` to the document,\n * but a universal selector never crosses a shadow boundary: every shadow root starts over at\n * the UA default, `content-box`. So each component has to opt in, and until now 15 of them did\n * so ad hoc — one of them with `content-box`, one with `!important`.\n *\n * Why this matters beyond tidiness: under `content-box`, padding and border are *size*. A rule\n * that only means to repaint a chip — `:state(dragging) { border: none }` — silently shrinks it\n * by two pixels per axis, the drag bank rewraps, and a drop target slides out from under the\n * user's pointer mid-drag. Border-box is what makes \"a state may repaint but never re-lay-out\"\n * a rule the CSS can actually keep.\n *\n * `:host` is set explicitly and descendants inherit, so a component that genuinely needs\n * `content-box` for a subtree (an image map, say) can opt out at one node and have it hold for\n * everything below it.\n */\nexport const boxSizing = css`\n :host {\n box-sizing: border-box;\n }\n\n *,\n *::before,\n *::after {\n box-sizing: inherit;\n }\n`;\n","import { css } from 'lit';\n\n/**\n * The `drop` region of every drop target.\n *\n * One rule: **a drop container hosts a chip, it never sizes one.** No `flex: 1`, no stretch, no\n * centring. The chip's box is decided by the chip — in the drag bank, mid-flight as a clone, and\n * once dropped — and a container that centres or stretches it makes the drop the one place where\n * that stops being true. That is felt as the chip jumping the instant it lands.\n *\n * `flex: 0 1 auto` on the children says \"intrinsic size, no growing, shrink if you must\".\n * `align-items: flex-start` stops the cross axis stretching them, which is the flex default and\n * the reason a chip in a tall dropzone used to grow to fill it.\n *\n * The shrink half used to be 0 as well, on the reading that a drop must not resize a chip. It does\n * not say that. `flex-shrink: 0` does not preserve the chip's size, it preserves the chip's\n * UNCONSTRAINED max-content size — and those are the same number only while the bank is wide enough\n * to give the chip its full width. Once the bank is narrower, the bank chip (`flex: 0 1 auto`, like\n * any flex item) shrinks and wraps, the placed chip does not, and the two disagree.\n *\n * Measured on the order fixture, bank vs placed: 209x36 / 209x36 at a 480px interaction, but\n * 204x55 / 209x36 at 440px and 154x55 / 209x36 at 340px — the placed chip a fixed 209px wide,\n * overflowing a drop that had correctly reserved 156px for it. It reached CI as a font difference:\n * the same label measures ~227px under the Linux fonts, which puts 480px on the wrong side of the\n * boundary too.\n *\n * Shrinking cannot make a placed chip smaller than the reservation, because the reservation IS the\n * measured chip (`--qti-dropzone-min-*`, applied to this region's content box). So the floor a\n * shrink stops at is the chip's own size, which is the rule above, not an exception to it.\n * `flex-grow: 0` is what actually prevents the stretch this block cares about, and it is untouched.\n *\n * A container that wants a *minimum* size still declares one (see `--qti-dropzone-min-*`). That\n * sizes the container, never its contents.\n *\n * Verified by drag-drop.invariance.spec.ts: \"a chip is the same chip wherever it lives\" — including\n * the narrow-bank order fixture, which is there because the wide one passes either way.\n */\nexport const dropRegion = css`\n [part~='drop'] {\n /*\n * The one deliberate opt-out from the border-box reset.\n *\n * --qti-dropzone-min-* is the border-box of the largest chip, and what has to hold that chip is\n * this region's *content* area. Under border-box a theme's dashed drop border is subtracted\n * from the chip's own size, the content comes up short, and the drop grows the moment a chip\n * lands in it. Order's drop did exactly that: 64px empty, 66px full, for a 1px border.\n */\n box-sizing: content-box;\n\n /*\n * No padding, and no token for one.\n *\n * A drop reserves --qti-dropzone-min-*, which is the chip's BORDER-box, as this region's CONTENT\n * area — so the chip already fits exactly, with nothing to spare and nothing squeezed. An inset\n * on top would only make the drop bigger than the thing it holds.\n *\n * There was a 1px one, to make the drop read as a frame a hair outside the chip. It never painted:\n * an EMPTY slot has nothing inside the inset to separate from, and a FILLED one hides its edge\n * (DROP-SIZING.md §4), so both states spent 2px on an invisible ring. The one drop that genuinely\n * wants breathing room — match's category card — declares padding on its own rule, which a\n * theme reaches with ::part(drop). A token in between bought nothing.\n */\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: flex-start;\n /* No gap either: 0 is the flex initial value, so the declaration only existed to host a token.\n A drop that wants space between chips sets gap on its own rule. */\n /* Containing block for anything a theme draws over the drop. Was 'position: relative' in the\n theme's 'drop' mixin, which put a document stylesheet in charge of a shadow node's position. */\n position: relative;\n }\n\n [part~='drop'] > * {\n flex: 0 1 auto;\n align-self: flex-start;\n }\n`;\n","import { css } from 'lit';\n\n/**\n * The `#validation-message` region every interaction renders, hidden until there is a message.\n *\n * `Interaction` owns showing and hiding it: `reportValidity` sets\n * `display: block !important` inline when `_internals.validationMessage` is non-empty, and clears the\n * text and sets `display: none` inline again when it is not (see interaction.ts). An inline\n * `!important` beats this rule, so the JS still wins whenever it speaks.\n *\n * What it did not own was the *initial* state. Before first validation the div has no inline style,\n * so it needs a stylesheet to start hidden — otherwise it paints as an empty box with the theme's\n * warning border and padding. That hide used to be a `display: none` inside the theme's\n * `validation-message` mixin, which made a document stylesheet responsible for a shadow node's box.\n * Two components had already noticed and worked around it with `style=\"display:none\"` in their\n * template; the other five relied on the theme.\n *\n * The theme still paints the message — colour, border, padding, radius — via `::part(message)`.\n */\nexport const validationMessage = css`\n [part~='message'] {\n display: none;\n }\n`;\n","import { ContextConsumer, consume, provide } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { configContext } from '../context/config.context';\nimport { interactionContext } from '../context/interaction.context';\nimport { itemContext } from '../context/item.context';\n\nimport type { PropertyValues } from 'lit';\nimport type { InteractionContext } from '../context/interaction.context';\nimport type { ConfigContext, ValidationDisplayMode } from '../context/config.context';\nimport type { ItemContext } from '../context/types/item.types';\nimport type { ValidatableInteraction } from '../lib/interaction.interface';\nimport type { ResponseVariable } from '../lib/variables';\n\n/**\n * Shared QTI interaction base. Formative correction behavior is supplied by the\n * `@qti-components/corrections` package.\n */\nexport abstract class Interaction extends LitElement implements ValidatableInteraction {\n /**\n * The item's variables. The interaction takes its response from here as well as publishing it:\n * when the item's value for this response changes to something other than what the interaction\n * shows, it adopts it. That is how `item.variables = …` reaches it, with no list of interactions\n * kept by the item. See {@link Interaction.#adoptResponse}.\n */\n #itemContext = new ContextConsumer(this, {\n context: itemContext,\n subscribe: true,\n callback: context => this.#followItem(context)\n });\n\n private get _context(): ItemContext | undefined {\n return this.#itemContext.value;\n }\n\n #seenReadonly?: boolean;\n #seenDisabled?: boolean;\n\n /**\n * Follows the item: its `readonly` and `disabled`, and the value it holds for this response.\n * `readonly` and `disabled` are only taken when the item says something, so an interaction\n * authored with either stays so inside an item that does not mention it.\n */\n #followItem(context: ItemContext | undefined) {\n if (context?.readonly !== undefined && context.readonly !== this.#seenReadonly) {\n this.#seenReadonly = context.readonly;\n this.readonly = context.readonly;\n }\n if (context?.disabled !== undefined && context.disabled !== this.#seenDisabled) {\n this.#seenDisabled = context.disabled;\n this.disabled = context.disabled;\n }\n this.#adoptResponse(context);\n }\n\n /** The item's last value for this response, serialised, to tell a change from an unrelated update. */\n #seenResponse?: string;\n /**\n * What this interaction last published or adopted, serialised. It is kept from the interaction's\n * own `qti-interaction-response` events, which every emitter dispatches on the interaction itself,\n * and not read back from `response`: that getter has no common shape (the drag-drop interactions\n * return one comma-joined string where they publish an array), so it cannot be compared.\n */\n #lastResponse?: string;\n #adoptScheduled = false;\n\n /**\n * Adopts the item's value for this response when it changed and the interaction does not already\n * show it.\n *\n * Two things keep this from fighting the candidate. It reacts to the item's value for *this*\n * response changing, not to any context update, so a score or a timer ticking never rewrites what\n * is being typed. And when the item's value is what the interaction itself last published (which\n * is what happens right after it publishes an answer) it does nothing, so there is no echo.\n *\n * The first value is only adopted when it says something: an unanswered item must not wipe a\n * `response` attribute the author put on the interaction.\n *\n * Setting `response` on an interaction that has not rendered yet is what the item used to avoid\n * by waiting, so until the first update this waits too, then looks at the latest value.\n */\n #adoptResponse(context: ItemContext | undefined) {\n const id = this.responseIdentifier ?? this.getAttribute('response-identifier');\n const variable = context?.variables?.find(v => v.type === 'response' && v.identifier === id);\n if (!variable) return;\n\n if (!this.hasUpdated) {\n if (!this.#adoptScheduled) {\n this.#adoptScheduled = true;\n void this.updateComplete.then(() => {\n this.#adoptScheduled = false;\n this.#adoptResponse(this._context);\n });\n }\n return;\n }\n\n const first = this.#seenResponse === undefined;\n const serialised = JSON.stringify(variable.value ?? null);\n if (serialised === this.#seenResponse) return;\n this.#seenResponse = serialised;\n if (first && (variable.value === null || variable.value === undefined)) return;\n if (serialised === this.#lastResponse) return;\n this.#lastResponse = serialised;\n this.response = variable.value as string | string[] | null;\n }\n\n /**\n * Delivery configuration, from the nearest provider — `qti-test` or `qti-item`.\n *\n * **Public so it can be assigned directly, which is the development-time route.** An interaction\n * has to work standalone, and in a story or a spec there is usually no provider above it — so\n * setting the field is all that is needed:\n *\n * orderInteraction.configContext = { allowReorder: false, validationDisplayMode: 'none' };\n *\n * With no provider, nothing ever overwrites it. That is the whole contract, and its limit: where a\n * provider DOES exist it re-emits on its next update and wins, because `@consume` writes this same\n * field. There is no merging — set the value on the provider in that case.\n *\n * In a lit-html template, bind it as a property rather than assigning after the fact:\n *\n * html`<qti-order-interaction .configContext=${{ allowReorder: false }}>…`\n *\n * The binding is committed on the detached template clone, before the fragment is inserted, so it\n * is in place by `connectedCallback` — which matters for anything that reads config on connect.\n *\n * It was `protected`, which fooled nobody: every caller reached it anyway through an\n * `as any` / `as { configContext?: … }` cast. Public says what was already true and removes the\n * casts, rather than pretending at an encapsulation the type system was the only thing enforcing.\n */\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext;\n\n #didLogDisableAfterIfMaxChoicesReachedDeprecation = false;\n\n /*\n * Published to the choice elements inside this interaction — their role, and how to tell\n * whether they are draggable. Provided here on the base rather than in a mixin so that\n * ChoicesMixin and the drag-drop mixins can each contribute without two providers of the same\n * context competing on one element.\n *\n * Reassign, never mutate: an in-place change does not notify consumers.\n */\n @provide({ context: interactionContext })\n protected _interactionContext: Readonly<InteractionContext> = { choiceRole: null, draggablesSelector: null };\n\n static formAssociated = true;\n protected _internals: ElementInternals;\n\n get internals(): ElementInternals {\n return this._internals;\n }\n\n @property({ type: String, attribute: 'response-identifier' }) responseIdentifier: string;\n\n @property({ reflect: true, type: Boolean }) disabled = false;\n\n @property({ reflect: true, type: Boolean }) readonly = false;\n\n @property({ type: String }) name;\n\n /** Extension point used by wrappers that should not register as candidate inputs. */\n protected get registersWithItem(): boolean {\n return true;\n }\n\n get isInline(): boolean {\n return false;\n }\n\n get responseVariable(): ResponseVariable | undefined {\n if (!this._context?.variables) {\n return undefined;\n }\n const responseVariables = this._context.variables.filter(v => v.type === 'response') as ResponseVariable[];\n const responseIdentifier = this.getAttribute('response-identifier');\n return responseVariables.find(v => v.identifier === responseIdentifier);\n }\n\n abstract validate(): boolean;\n\n get value(): string | null {\n return JSON.stringify(this.response);\n }\n\n set value(val: string | null) {\n this.response = val ? JSON.parse(val) : null;\n }\n\n abstract get response(): string | string[] | null;\n abstract set response(val: string | string[] | null);\n\n public reportValidity(): boolean {\n const isValid = this._internals.validity.valid;\n const mode = this.validationDisplayMode;\n\n if (mode === 'native' || mode === 'both') {\n this._internals.reportValidity();\n }\n\n if (mode === 'inline' || mode === 'both') {\n this.updateInlineValidationMessage();\n } else {\n this.clearInlineValidationMessage();\n }\n\n if (mode === 'none') {\n this.clearInlineValidationMessage();\n }\n\n return isValid;\n }\n\n protected get validationDisplayMode(): ValidationDisplayMode {\n return this.configContext?.validationDisplayMode ?? 'inline';\n }\n\n protected resolveAllowReorder(options?: { defaultWhenUnset?: boolean }): boolean {\n const defaultWhenUnset = options?.defaultWhenUnset ?? true;\n const config = this.configContext;\n if (!config) {\n return defaultWhenUnset;\n }\n if (config.allowReorder !== undefined) {\n return config.allowReorder;\n }\n return defaultWhenUnset;\n }\n\n protected resolveDisableAfterMaxReached(options?: { defaultWhenUnset?: boolean }): boolean {\n const defaultWhenUnset = options?.defaultWhenUnset ?? false;\n const config = this.configContext;\n\n if (!config) {\n return defaultWhenUnset;\n }\n\n if (config.disableAfterMaxReached !== undefined) {\n return config.disableAfterMaxReached;\n }\n\n if (config.disableAfterIfMaxChoicesReached !== undefined) {\n if (!this.#didLogDisableAfterIfMaxChoicesReachedDeprecation) {\n this.#didLogDisableAfterIfMaxChoicesReachedDeprecation = true;\n console.warn(\n '[QTI Config] `disableAfterIfMaxChoicesReached` is deprecated. Use `disableAfterMaxReached` instead.'\n );\n }\n return config.disableAfterIfMaxChoicesReached;\n }\n\n return defaultWhenUnset;\n }\n\n protected setInteractionValidity(\n isValid: boolean,\n validityMessage = '',\n anchor?: HTMLElement | null,\n options?: { suppressInline?: boolean }\n ): void {\n const validityAnchor = anchor ?? this;\n this._internals.setValidity(isValid ? {} : { customError: true }, validityMessage, validityAnchor);\n\n if (\n options?.suppressInline !== true &&\n (this.validationDisplayMode === 'inline' || this.validationDisplayMode === 'both')\n ) {\n this.updateInlineValidationMessage();\n }\n }\n\n protected updateInlineValidationMessage(): void {\n const validationMessageElement = this.getValidationMessageElement();\n if (!validationMessageElement) {\n return;\n }\n\n if (!this._internals.validity.valid) {\n validationMessageElement.textContent = this._internals.validationMessage;\n validationMessageElement.style.setProperty('display', 'block', 'important');\n return;\n }\n\n validationMessageElement.textContent = '';\n validationMessageElement.style.display = 'none';\n }\n\n protected clearInlineValidationMessage(): void {\n const validationMessageElement = this.getValidationMessageElement();\n if (!validationMessageElement) {\n return;\n }\n\n validationMessageElement.textContent = '';\n validationMessageElement.style.display = 'none';\n }\n\n protected getValidationMessageElement(): HTMLElement | null {\n return this.shadowRoot?.querySelector('#validation-message') as HTMLElement | null;\n }\n\n public reset(): void {\n this.response = null;\n }\n\n public formResetCallback(): void {\n this.reset();\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n if (!this.registersWithItem) {\n return;\n }\n\n this.dispatchEvent(\n new CustomEvent('qti-register-interaction', {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n interactionElement: this,\n responseIdentifier: this.responseIdentifier\n }\n })\n );\n }\n\n public saveResponse(value: string | string[], state?: string | null): void {\n this.dispatchEvent(\n new CustomEvent('qti-interaction-response', {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n responseIdentifier: this.responseIdentifier,\n response: Array.isArray(value) ? [...value] : value,\n ...(state !== undefined ? { state } : {})\n }\n })\n );\n }\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n this.addEventListener('qti-interaction-response', (e: Event) => {\n this.#lastResponse = JSON.stringify((e as CustomEvent).detail?.response ?? null);\n });\n }\n\n /**\n * Optional lifecycle bridge for interaction subclasses that do not need changed-property data.\n *\n * The parameter is `PropertyValues`, matching LitElement, and NOT `PropertyValues<this>`.\n * The polymorphic `this` narrowed the parameter per subclass, which made every interaction\n * class structurally incompatible with `LitElement` — so `Constructor<LitElement>`, the\n * standard constraint for a Lit mixin, rejected all of them and consumers could not wrap an\n * interaction in a mixin without casting. `this` buys nothing in a parameter position and\n * costs contravariant compatibility with the base class.\n *\n * Still optional, so subclasses that ignore the argument can override with `firstUpdated()`.\n */\n protected override firstUpdated(_changedProperties?: PropertyValues): void {}\n}\n","import { html, LitElement } from 'lit';\n\nimport type { Cardinality } from '../lib/expression-result';\n\nexport abstract class QtiVariableDeclaration extends LitElement {\n override render() {\n return html`<slot></slot>`;\n }\n\n protected defaultValues(cardinality: Cardinality) {\n const htmlValues = Array.from(this.querySelectorAll('qti-default-value > qti-value'));\n\n if (htmlValues.length === 0) {\n return null;\n }\n\n const defaultValues = htmlValues.map(n => n.innerHTML.trim());\n if (defaultValues.length > 1 || cardinality === 'multiple' || cardinality === 'ordered') {\n return defaultValues;\n }\n return defaultValues[0];\n }\n}\n","import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { itemContext } from '../context/item.context';\nimport { qtiContext } from '../context/qti.context';\nimport { testContext } from '../context/test.context';\n\nimport type { ItemContext } from '../context/types/item.types';\nimport type { QtiContext, QtiContextType } from '../context/qti.context';\nimport type { Calculate } from '../lib/expression-result';\nimport type { BaseType } from '../lib/expression-result';\nimport type { ResponseVariable, VariableDeclaration } from '../lib/variables';\nimport type { TestContext } from '../context/test.context';\n\ntype ExpressionVariable = ResponseVariable | VariableDeclaration<QtiContextType>;\n\nexport interface QtiExpressionBase<T> {\n // get assessmentItem(): QtiAssessmentItem;\n\n // getVariables(): VariableDeclaration<number | string | (number | string)[] | null>[];\n calculate(): Readonly<T>;\n}\n\n/**\n * Wrap whatever an expression handed back in a variable, reading the base type\n * off the value itself.\n *\n * An operator that knows its own result type says so through `resultBaseType`\n * and that wins, because the QTI vocabulary fixes it regardless of the operands\n * — `qti-divide` is a float even when it divides two integers exactly. Only\n * when nothing is declared, as for a custom operator returning whatever the\n * host computed, is the type read off the value.\n *\n * Everything used to be labelled `integer`, and since `compareSingleValues`\n * parses an integer with `parseInt`, that silently truncated:\n * `equal(divide(5, 2), 2.4)` compared 2 against 2 and answered true.\n */\nconst variableFromValue = (value: unknown, declared?: BaseType): ResponseVariable => {\n /*\n * A NULL result is still a value: the operand exists and is NULL. Returning\n * nothing would drop it from the list, which both hides the NULL from\n * `qti-is-null` and shifts every operand after it — a binary operator with a\n * NULL first argument would silently read its second as its first. The base\n * type is moot here, since every operator tests the value before it.\n */\n if (value === null || value === undefined) {\n return {\n identifier: '',\n baseType: 'string',\n value: null,\n cardinality: 'single',\n type: 'response'\n } as ResponseVariable;\n }\n\n if (Array.isArray(value)) {\n return {\n identifier: '',\n baseType: declared ?? inferBaseType(value[0]),\n value: value.map(entry => String(entry)),\n cardinality: 'multiple',\n type: 'response'\n } as ResponseVariable;\n }\n\n return {\n identifier: '',\n baseType: declared ?? inferBaseType(value),\n value: String(value),\n cardinality: 'single',\n type: 'response'\n } as ResponseVariable;\n};\n\n/** A JS value's QTI base type. A string stays text; it is not re-parsed. */\nconst inferBaseType = (value: unknown): BaseType => {\n if (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'float';\n if (typeof value === 'boolean') return 'boolean';\n return 'string';\n};\n\nconst inferContainerBaseType = (expression: QtiExpression<unknown>, value: unknown): BaseType | undefined => {\n if (!Array.isArray(value) || value.length > 0) {\n return undefined;\n }\n\n return expression.lastVariables.find(\n variable => variable?.baseType && variable.baseType !== 'record' && variable.cardinality !== 'record'\n )?.baseType as BaseType | undefined;\n};\n\nexport abstract class QtiExpression<T> extends LitElement implements QtiExpressionBase<T> {\n /*\n * Not `@state()`. Nothing renders it any more (see `render` below), so making\n * it reactive only scheduled an update per `calculate()` — and response\n * processing calls that on every expression of every rule it walks.\n */\n protected result: any;\n #lastVariables: ExpressionVariable[] = [];\n\n /**\n * What the last `calculate()` produced, or undefined if it has not run.\n *\n * This is the supported way to inspect a scoring run: process the responses,\n * then walk the rule tree reading this off each expression. A tool that wants\n * to visualise how a score came about gets the whole tree annotated with its\n * values, without the components having to re-render to show them.\n */\n public get lastResult(): Readonly<T> | undefined {\n return this.result;\n }\n\n public get lastVariables(): readonly ExpressionVariable[] {\n return this.#lastVariables;\n }\n\n /*\n * Written here rather than imported from a .css file, and that is a packaging constraint rather\n * than a style preference.\n *\n * The rule used to live in qti-expression.css, imported with Vite's inline-stylesheet query so\n * DevTools could show source-file provenance. That query is a VITE specifier, and tsc copies it\n * verbatim into dist — so the published package shipped an import only a Vite-based consumer\n * could resolve. Every other consumer broke on it: plain Node, tsx, any non-Vite bundler. It was\n * the single such specifier reachable from this package, and it took down QTI-Editor's schema\n * check, which loads the components under tsx to build the real ProseMirror schema\n * (ERR_UNKNOWN_FILE_EXTENSION on a file that has nothing to do with schemas).\n *\n * A `build:assets` step used to copy the .css into dist beside it. That went too — it existed\n * only to give the unresolvable import something to point at.\n *\n * Two lines of CSS are not worth a dist that only one bundler can consume. If this ever grows\n * into a real stylesheet, give it a `.styles.ts` exporting a `css` template — the house pattern\n * everywhere else in this repo — rather than reintroducing a bundler-specific import.\n *\n * The element renders a debug <pre> of its computed result plus a <slot>; hiding the slot is all\n * the styling it has ever had.\n */\n static override styles = css`\n slot {\n display: none;\n }\n `;\n\n /*\n * Just the slot. This used to render `JSON.stringify(this.result, null, 2)`\n * into a <pre> beside it — a development aid that nobody could see, because\n * expressions live inside `qti-response-processing`, which is `display: none`.\n * It cost a full serialisation of the result on every render.\n */\n override render() {\n return html`<slot></slot>`;\n }\n\n /*\n * Render once, then never again: the template above is constant, so every\n * later update is pure overhead.\n *\n * It is not the `@state()` decorators that drive those updates — `@consume`\n * subscribes through `ContextConsumer`, which calls `host.requestUpdate()`\n * itself on every context change, \"in case this value is used in a template\".\n * Here it is not. An item with 30 response-processing rules holds ~180\n * expression elements and the test context changes on every keystroke, so\n * that was ~180 renders per keystroke producing identical output.\n *\n * The subscriptions stay, because `calculate()` reads the current values when\n * a rule invokes it. Only the rendering stops.\n */\n protected override shouldUpdate(): boolean {\n return !this.hasUpdated;\n }\n\n public calculate(): Readonly<T> {\n this.result = this.getResult();\n return this.result;\n }\n\n protected getResult(): Readonly<T> {\n throw new Error('Not implemented');\n }\n\n /**\n * The base type this operator always produces, when the QTI vocabulary fixes\n * one regardless of its operands — `qti-divide` is a float even dividing two\n * integers exactly, and `qti-round` is an integer whatever it rounds.\n *\n * Left undefined by operators whose result type follows their operands (a\n * `qti-sum` of integers is an integer) and by those that return no number at\n * all; the type is then read off the value.\n */\n public get resultBaseType(): BaseType | undefined {\n return undefined;\n }\n\n /*\n * Subscribed but deliberately NOT `@state()`.\n *\n * An expression is pull-based: nothing reads these until a rule calls\n * `calculate()`, which reads whatever the consumer has by then. Marking them\n * reactive made every context change schedule a render of every expression\n * element in the document — an item with 30 response-processing rules holds\n * ~180 of them, and the test context changes on every keystroke. The\n * subscription still keeps the properties current; it just no longer asks\n * for a render nothing depends on.\n */\n @consume({ context: itemContext, subscribe: true })\n protected context?: ItemContext;\n\n @consume({ context: qtiContext, subscribe: true })\n protected qtiContext?: QtiContext;\n\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n /**\n * Resolve a declared variable from the closest available scope: item-level\n * first, then the test-level outcome variables. So an expression used in an\n * assessmentTest's outcome processing can reference a test-level outcome\n * (e.g. a total set earlier in the same run) — which the QTI variable\n * expression is specified to do. Returns null when unresolved rather than\n * throwing, so callers degrade gracefully.\n */\n protected resolveVariable(identifier: string): VariableDeclaration<string | string[] | null> | null {\n return (\n this.context?.variables.find(v => v.identifier === identifier) ??\n this._testContext?.testOutcomeVariables?.find(v => v.identifier === identifier) ??\n this.resolveItemVariable(identifier)\n );\n }\n\n /**\n * `ITEMREF.VAR`: a variable of an individual item session, looked up by prefixing the variable\n * with the identifier the item ref gave the item (QTI 3 `qti-variable`), e.g. `Q01.SCORE`. An\n * item that was never presented has no variables, which resolves to NULL. Instances of a cloned\n * item (`Q01.2.SCORE`) are not supported: the item itself is used.\n */\n private resolveItemVariable(identifier: string): VariableDeclaration<string | string[] | null> | null {\n if (!identifier?.includes('.')) return null;\n const parts = identifier.split('.');\n const item = this._testContext?.items?.find(i => i.identifier === parts[0]);\n return item?.variables?.find(v => v.identifier === parts[parts.length - 1]) ?? null;\n }\n\n getVariables = (): ExpressionVariable[] => {\n // FIXME: if this itself is multiple, this will never enter the qti-multiple switch\n // See this example here: https://github.com/1EdTech/qti-examples/blob/master/qtiv3-examples/packaging/items/Example05-feedbackBlock-adaptive.xml\n\n const variables = Array.from(this.children)\n .map((e: Element) => {\n switch (e.tagName.toLowerCase()) {\n case 'qti-base-value': {\n return {\n baseType: e.getAttribute('base-type'),\n value: e.textContent.trim(),\n cardinality: 'single'\n } as ResponseVariable;\n }\n case 'qti-variable': {\n const identifier = e.getAttribute('identifier') || '';\n\n // Special handling for QTI_CONTEXT\n if (identifier === 'QTI_CONTEXT') {\n if (!this.qtiContext?.QTI_CONTEXT) {\n console.warn('QTI_CONTEXT not available');\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n return {\n identifier: 'QTI_CONTEXT',\n baseType: 'record',\n value: this.qtiContext.QTI_CONTEXT,\n cardinality: 'record',\n type: 'context'\n } as VariableDeclaration<QtiContextType>;\n }\n\n return this.resolveVariable(identifier);\n }\n case 'qti-multiple': {\n const multiple = e as QtiExpression<ResponseVariable[]>;\n\n const values = multiple.getResult();\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'multiple',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-ordered': {\n const multiple = e as QtiExpression<ResponseVariable[]>;\n const values = multiple.getResult();\n if (values?.length > 0) {\n return {\n identifier: '',\n baseType: values[0].baseType,\n value: values.map(v => v.value),\n cardinality: 'ordered',\n type: 'response'\n } as ResponseVariable;\n }\n return null;\n }\n case 'qti-repeat': {\n const repeat = e as QtiExpression<ResponseVariable[]>;\n const values = repeat.getResult();\n if (values?.length > 0) {\n return values;\n }\n return null;\n }\n case 'qti-custom-operator': {\n // Not a QtiExpression — it has `calculate` but no `getResult`, so\n // the default branch below throws on it and the surrounding\n // expression is handed nothing.\n return variableFromValue((e as unknown as Calculate).calculate?.());\n }\n case 'qti-correct': {\n const identifier = e.getAttribute('identifier') || '';\n const responseVariable = this.context?.variables?.find(v => v.identifier === identifier) as\n | ResponseVariable\n | undefined;\n\n // A `qti-correct` naming a response that is not declared — a typo,\n // or an expression evaluated before the declaration registered —\n // used to dereference the null this deliberately produced and take\n // down the whole processing run. It is an unresolved variable, so\n // it is NULL.\n if (!responseVariable) {\n console.warn(`qti-correct: no response declaration for \"${identifier}\"`);\n return variableFromValue(null);\n }\n\n return {\n baseType: responseVariable.baseType,\n value: responseVariable.correctResponse,\n cardinality: responseVariable.cardinality\n } as ResponseVariable;\n }\n default: {\n // Every operator without a case of its own lands here.\n try {\n const expression = e as QtiExpression<unknown>;\n const result = expression.getResult();\n return variableFromValue(result, expression.resultBaseType ?? inferContainerBaseType(expression, result));\n } catch (error) {\n console.warn(`getVariables: could not read a value from <${e.tagName.toLowerCase()}>`, error);\n }\n return null;\n }\n }\n })\n .flatMap(v => (Array.isArray(v) ? v : [v]))\n .filter((v): v is ExpressionVariable => v !== null);\n\n this.#lastVariables = variables;\n return variables;\n };\n}\n","import { QtiExpression } from './qti-expression';\n\nexport abstract class QtiConditionExpression extends QtiExpression<boolean> {\n public override calculate(): Readonly<boolean> {\n this.result = this.getResult();\n return this.result;\n }\n\n public override getResult(): Readonly<boolean> {\n throw new Error('Not implemented');\n }\n}\n","export const decimalSeparator = () => {\n return new Intl.NumberFormat().format(0.1).replace(/\\d/g, '');\n};\n\n/**\n * Renders a number the way QTI stores one: a plain decimal string with `.` as the separator and no\n * grouping, whatever the browser's locale is. Strings are already in that form and pass through.\n *\n * `Number.prototype.toString()` is exactly that format. The locale-aware versions this used to call\n * are not: under a comma-decimal locale (nl, de, fr, ...) it ran `.replace('.', '')` over a string\n * that always uses `.`, so a score of 0.5 was stored as \"05\" and 1.5 as \"15\" — an item's SCORE came\n * out ten times too big for every value with a fraction. Under a dot-decimal locale\n * `toLocaleString()` grouped thousands instead, turning 1234.5 into \"1,234.5\".\n */\nexport const convertNumberToUniversalFormat = (number: number | string) => {\n return typeof number === 'string' ? number : number.toString();\n};\n\nexport function IsNullOrUndefined(value: unknown) {\n return value === null || value === undefined;\n}\n\nexport function removeDoubleSlashes(str: string) {\n const singleForwardSlashes = str\n .replace(/([^:]\\/)\\/+/g, '$1')\n .replace(/\\/\\//g, '/')\n .replace('http:/', 'http://')\n .replace('https:/', 'https://');\n return singleForwardSlashes;\n}\n","import { ContextConsumer, consume } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '../context/computed.context';\nimport { itemContext } from '../context/item.context';\nimport { IsNullOrUndefined } from '../utils/utils';\n\nimport type { ComputedContext } from '../context/types/computed.types';\nimport type { ItemContext } from '../context/types/item.types';\n\nexport abstract class QtiFeedback extends LitElement {\n @property({ type: String, attribute: 'show-hide' })\n protected showHide: 'show' | 'hide' = 'show';\n\n @property({ type: String, attribute: 'outcome-identifier' })\n public outcomeIdentifier: string;\n\n @property({ type: String })\n protected identifier: string;\n\n @property({ type: String, attribute: false })\n public showStatus: string;\n\n /**\n * The item's variables. Feedback follows them itself: every time the item publishes a new context\n * this decides, synchronously, whether its own outcome now calls for showing it, so the item has\n * no list of feedback elements to push to. Synchronous matters. A host that sets an outcome\n * reads `showStatus` straight after, with no await in between.\n */\n #itemContext = new ContextConsumer(this, {\n context: itemContext,\n subscribe: true,\n callback: context => this.#followItem(context)\n });\n\n private get _context(): ItemContext | undefined {\n return this.#itemContext.value;\n }\n\n /** What the last context carried that decides this feedback, to tell a relevant update from noise. */\n #seen?: string;\n\n @consume({ context: computedContext, subscribe: true })\n @state()\n private _computedContext?: ComputedContext;\n\n /**\n * Re-decide when this feedback's outcome changed, or once an attempt has been made. Before the\n * first attempt an unchanged outcome says nothing yet: a `hide` feedback would otherwise switch\n * on for an item nobody has answered.\n */\n #followItem(context: ItemContext | undefined) {\n const variables = context?.variables;\n if (!variables || !this.outcomeIdentifier) return;\n const outcome = JSON.stringify(variables.find(v => v.identifier === this.outcomeIdentifier)?.value ?? null);\n const numAttempts = Number(variables.find(v => v.identifier === 'numAttempts')?.value) || 0;\n const relevant = this.#seen === undefined ? numAttempts > 0 : this.#seen !== outcome || numAttempts > 0;\n this.#seen = outcome;\n if (relevant) this.checkShowFeedback(this.outcomeIdentifier);\n }\n\n public checkShowFeedback(outcomeIdentifier: string) {\n const outcomeVariable = this._context.variables.find(v => v.identifier === outcomeIdentifier) || null;\n if (this.outcomeIdentifier !== outcomeIdentifier || !outcomeVariable) return;\n let isFound = false;\n if (Array.isArray(outcomeVariable.value)) {\n isFound = outcomeVariable.value.includes(this.identifier);\n } else {\n isFound =\n (!IsNullOrUndefined(this.identifier) &&\n !IsNullOrUndefined(outcomeVariable?.value) &&\n this.identifier === outcomeVariable.value) ||\n false;\n }\n\n this.#showFeedback(isFound);\n }\n\n #showFeedback(value: boolean) {\n if (!this.#sessionControlAllowsFeedback()) {\n this.showStatus = 'off';\n return;\n }\n this.showStatus = (value && this.showHide === 'show') || (!value && this.showHide === 'hide') ? 'on' : 'off';\n }\n\n /**\n * The QTI `show-feedback` constraint governs exactly one state: after the end of\n * the last attempt. Up to that point the spec requires any applicable feedback to\n * be shown — \"a value of max-attempts greater than 1, by definition, indicates\n * that any applicable feedback must be shown\" — and only \"once the maximum number\n * of allowed attempts have been used (or for adaptive items, completionStatus has\n * been set to completed)\" does `show-feedback` decide.\n *\n * This only ever forces feedback off, so `show-feedback` being true settles it:\n * there is no state in which the constraint hides feedback. It defaults to\n * false, and an absent value suppresses once the attempts are gone.\n *\n * That leaves one question — is the item out of attempts? — and the two item\n * kinds answer it from different variables, so each reads only its own.\n */\n #sessionControlAllowsFeedback(): boolean {\n if (!this._computedContext) return true;\n const activeItem = this._computedContext.testParts\n ?.find(tp => tp.active)\n ?.sections.flatMap(s => s.items)\n .find(i => i.active);\n if (!activeItem || activeItem.showFeedback) return true;\n\n // Adaptive items ignore max-attempts: \"the number of attempts is limited by\n // the value of the completionStatus built-in outcome variable\".\n if (activeItem.adaptive) return activeItem.completionStatus !== 'completed';\n\n // `max-attempts=\"0\"` is \"no limit\", so the last attempt never arrives.\n const maxAttempts = activeItem.maxAttempts ?? 1;\n if (maxAttempts <= 0) return true;\n\n const numAttempts = Number(this._context?.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n return numAttempts < maxAttempts;\n }\n}\n","/**\n * Canonical `response=\"...\"` / `correct-response=\"...\"` attribute codec.\n *\n * Authors put a single string on an interaction element. This module is the\n * single source of truth for how that string parses into the runtime's\n * internal value AND how an editor serializes the internal value back to the\n * attribute. Both `@qti-components/*` interactions and `@citolab/prose-qti`\n * (the editor) import from here — no per-codebase parsers, no drift.\n *\n * The two attributes share the same grammar; the codec is agnostic about\n * which of them is being parsed.\n *\n * ---\n *\n * Format reference (per interaction):\n *\n * | Interaction | base-type | cardinality | attribute value |\n * |----------------------|---------------|----------------------|---------------------------|\n * | choice | identifier | single / multiple | \"A\" / \"A,B,C\" |\n * | inline-choice | identifier | single | \"Y\" |\n * | hottext | identifier | single / multiple | \"h1\" / \"h1,h2\" |\n * | hotspot | identifier | single / multiple | \"spot1\" / \"spot1,spot2\" |\n * | order | identifier | ordered | \"a,b,c\" (order matters) |\n * | graphic-order | identifier | ordered | \"spot1,spot2,spot3\" |\n * | match | directedPair | multiple | \"src1 tgt1,src2 tgt2\" |\n * | associate | directedPair | multiple | \"A B,C D\" |\n * | gap-match | directedPair | multiple | \"gtext1 gap1,...\" |\n * | graphic-associate | directedPair | multiple | \"spot1 spot2,...\" |\n * | graphic-gap-match | directedPair | multiple | \"gimg1 spot1,...\" |\n * | select-point | point | single / multiple | \"100 150\" / \"100 150,…\" |\n * | slider | integer | single | \"50\" |\n * | text-entry | string | single | \"paris\" |\n *\n * Rules:\n * - Comma `,` separates VALUES (different identifiers / pairs / points).\n * - Space ` ` separates PARTS within one value (pair members or point coords).\n * - Each value is trimmed on parse.\n * - No escape mechanism. Identifiers that contain commas cannot round-trip.\n */\n\n// ─── parsed shape ────────────────────────────────────────────────────────────\n\n/** Canonical parsed value of a `response` / `correct-response` attribute. */\nexport type ResponseValue = string | string[] | null;\n\n// ─── per-shape branded types (advisory at compile time) ──────────────────────\n\n/** Identifier literal — opaque QTI identifier (e.g. `\"choice1\"`). */\nexport type Identifier = string;\n\n/** Directed pair literal — `\"sourceId targetId\"`. Used by match / associate / gap-match. */\nexport type DirectedPair = `${string} ${string}`;\n\n/** Point literal — `\"x y\"` integer coordinates. Used by select-point / graphic-*. */\nexport type Point = `${number} ${number}`;\n\n// ─── attribute-level parser / serializer ─────────────────────────────────────\n\n/**\n * Parse a raw `response` / `correct-response` attribute string into the\n * canonical value.\n *\n * - `null` / `undefined` / empty → `null`\n * - no comma → trimmed string\n * - one or more commas → trimmed array (single-element collapses to a string)\n */\nexport function parseResponseAttribute(raw: string | null | undefined): ResponseValue {\n if (raw == null) return null;\n if (!raw.includes(',')) {\n const trimmed = raw.trim();\n return trimmed.length > 0 ? trimmed : null;\n }\n const tokens = raw\n .split(',')\n .map(token => token.trim())\n .filter(token => token.length > 0);\n if (tokens.length === 0) return null;\n if (tokens.length === 1) return tokens[0];\n return tokens;\n}\n\n/**\n * Serialize a canonical value back to the attribute string. Returns `null` for\n * empty inputs so a Lit `@property({ reflect: true })` drops the attribute.\n */\nexport function serializeResponseAttribute(value: ResponseValue): string | null {\n if (value == null) return null;\n if (Array.isArray(value)) {\n const tokens = value.map(token => token.trim()).filter(token => token.length > 0);\n return tokens.length > 0 ? tokens.join(',') : null;\n }\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\n// ─── value-shape helpers (per interaction type) ──────────────────────────────\n\n/**\n * Iterate over the comma-separated entries in a response value, regardless of\n * whether the caller has the raw string, the parsed string, or a string[].\n * Yields trimmed non-empty entries.\n */\nexport function* iterResponseValues(raw: ResponseValue): Generator<string> {\n if (raw == null) return;\n if (Array.isArray(raw)) {\n for (const v of raw) {\n const t = v.trim();\n if (t) yield t;\n }\n return;\n }\n if (!raw.includes(',')) {\n const t = raw.trim();\n if (t) yield t;\n return;\n }\n for (const v of raw.split(',')) {\n const t = v.trim();\n if (t) yield t;\n }\n}\n\n/** Parse a directed-pair value into `{ source, target }`. Throws on malformed input. */\nexport function parsePair(value: string): { source: string; target: string } {\n const [source, target, ...rest] = value.trim().split(/\\s+/);\n if (!source || !target || rest.length > 0) {\n throw new Error(`malformed directed-pair value: \"${value}\" (expected \"source target\")`);\n }\n return { source, target };\n}\n\n/** Serialize a directed pair to canonical `\"source target\"` form. */\nexport function serializePair(source: string, target: string): DirectedPair {\n return `${source} ${target}`;\n}\n\n/** Parse a point value into `{ x, y }`. Throws on malformed input. */\nexport function parsePoint(value: string): { x: number; y: number } {\n const [xStr, yStr, ...rest] = value.trim().split(/\\s+/);\n const x = Number(xStr);\n const y = Number(yStr);\n if (!Number.isFinite(x) || !Number.isFinite(y) || rest.length > 0) {\n throw new Error(`malformed point value: \"${value}\" (expected \"x y\" numeric coords)`);\n }\n return { x, y };\n}\n\n/** Serialize a point to canonical `\"x y\"` form. */\nexport function serializePoint(x: number, y: number): Point {\n return `${x} ${y}`;\n}\n\n// ─── Lit converter factory ───────────────────────────────────────────────────\n\n/**\n * Ready-to-use Lit `converter` for `response` / `correct-response` attributes.\n * Assign to the `converter` option:\n *\n * @property({ attribute: 'response', converter: responseAttributeConverter({ emptyAs: [] }) })\n *\n * `emptyAs` picks the sentinel returned when the attribute is absent / blank.\n * Three sentinels exist across the codebase — match the one your call site\n * already uses. Future work may normalize to a single sentinel.\n *\n * - '' (empty string) — ChoicesMixin convention\n * - [] — DragDropSlottedMixin / graphic-associate convention\n * - null — base interaction / select-point convention\n *\n * On the serialize side, the `emptyAs` value roundtrips back to `null` so a\n * `reflect: true` property drops the attribute rather than emitting `\"\"`.\n */\nexport function responseAttributeConverter<E extends '' | null | readonly unknown[]>(opts: {\n emptyAs: E;\n}): {\n fromAttribute: (value: string | null) => ResponseValue | E;\n toAttribute: (value: ResponseValue | E) => string | null;\n} {\n const { emptyAs } = opts;\n const isEmptySentinel = (value: unknown): boolean =>\n value === emptyAs || value == null || value === '' || (Array.isArray(value) && value.length === 0);\n\n return {\n fromAttribute: (value: string | null): ResponseValue | E => {\n const parsed = parseResponseAttribute(value);\n return parsed === null ? emptyAs : parsed;\n },\n toAttribute: (value: ResponseValue | E): string | null => {\n if (isEmptySentinel(value)) return null;\n return serializeResponseAttribute(value as ResponseValue);\n }\n };\n}\n","import { LitElement } from 'lit';\n\n/**\n * Interface for any object that can process QTI rules\n */\nexport interface QtiRuleBase {\n process(): any;\n}\n\n/**\n * Abstract base class for QTI rule DOM elements\n */\nexport abstract class QtiRuleElement extends LitElement implements QtiRuleBase {\n abstract process(): any;\n}\n\n/**\n * Thrown by `qti-exit-response` to end the response processing of an attempt.\n *\n * An exit can sit at any depth — inside a `qti-response-condition` branch, or\n * inside a `qti-response-processing-fragment` — and has to stop every rule\n * after it, not just its own siblings. Unwinding the stack is what reaches\n * every one of those loops without each of them having to report upwards.\n *\n * `qti-response-processing` catches it at the top of the run. The outcomes set\n * before the exit are kept, because each `qti-set-outcome-value` has already\n * dispatched by the time this is thrown.\n */\nexport class QtiExitResponseSignal extends Error {\n constructor() {\n super('qti-exit-response');\n this.name = 'QtiExitResponseSignal';\n }\n}\n\n/**\n * Thrown by `qti-exit-test` to end the outcome processing of a test.\n *\n * The test-level twin of {@link QtiExitResponseSignal}, and unwinds the stack\n * for the same reason: an exit inside a `qti-outcome-condition` branch has to\n * stop the rules after the condition, not just its own siblings.\n */\nexport class QtiExitTestSignal extends Error {\n constructor() {\n super('qti-exit-test');\n this.name = 'QtiExitTestSignal';\n }\n}\n","/**\n * The registry behind `<qti-custom-operator definition=\"…\">`.\n *\n * A custom operator is by definition outside the QTI vocabulary, so which ones\n * exist is a property of the delivery engine rather than of an item. An item\n * names one in its `definition` attribute and the engine supplies it — here,\n * through this registry.\n *\n * This is the second of two mechanisms on `qti-custom-operator`. The other runs\n * inline JavaScript out of a CDATA section and is selected with\n * `class=\"js.org\"`; it stays as it is. `definition` is what items authored\n * against the Citolab scoring engine use, and the two do not interact.\n */\n\nexport type CustomOperatorValue = string | string[] | number | boolean | null;\n\n/**\n * Handed the calculated values of the element's child expressions, in document\n * order, and returns the value of the expression.\n */\nexport type CustomOperator = (values: CustomOperatorValue[]) => CustomOperatorValue;\n\n/** The value an operator most often works on: the first child, as text. */\nconst firstString = (values: CustomOperatorValue[]): string | null => {\n const value = values[0];\n if (value === null || value === undefined) return null;\n return Array.isArray(value) ? (value[0] ?? null) : String(value);\n};\n\n/** A text operator that leaves a NULL or absent first value alone. */\nconst textOperator =\n (transform: (value: string) => string): CustomOperator =>\n values => {\n const value = firstString(values);\n return value === null ? null : transform(value);\n };\n\n/**\n * The three operators the scoring engine ships, under each of the prefixes it\n * registers them with. The prefix is part of the key because `definition` is\n * matched whole, exactly as the item writes it.\n */\nconst BUILT_IN_PREFIXES = ['depcp', 'questify', 'qade'] as const;\n\nconst BUILT_IN_OPERATORS: Record<string, CustomOperator> = {\n Trim: textOperator(value => value.trim()),\n // Decompose, then drop the combining marks that decomposition split off, so\n // \"café\" compares as \"cafe\".\n ToAscii: textOperator(value => value.normalize('NFD').replace(/[̀-ͯ]/g, '')),\n // A decimal comma written where the response processing expects a dot. Only\n // the first comma, which is the decimal separator in the locales that use it.\n ParseCommaDecimal: textOperator(value => value.replace(',', '.'))\n};\n\nconst builtIns = new Map<string, CustomOperator>(\n BUILT_IN_PREFIXES.flatMap(prefix =>\n Object.entries(BUILT_IN_OPERATORS).map(([name, operator]): [string, CustomOperator] => [\n `${prefix}:${name}`,\n operator\n ])\n )\n);\n\n/** Registered by the host application; consulted before the built-ins. */\nconst registered = new Map<string, CustomOperator>();\n\n/**\n * Make an operator available to every `qti-custom-operator` that names it.\n *\n * The key is the `definition` attribute in full, prefix included. Registering a\n * key a built-in already uses overrides that built-in, which is how a delivery\n * engine replaces one it disagrees with.\n */\nexport const registerCustomOperator = (definition: string, operator: CustomOperator): void => {\n registered.set(definition, operator);\n};\n\n/** Undo a {@link registerCustomOperator}, restoring any built-in of that name. */\nexport const unregisterCustomOperator = (definition: string): void => {\n registered.delete(definition);\n};\n\n/** The operator for a `definition`, or null when nothing provides it. */\nexport const getCustomOperator = (definition: string): CustomOperator | null =>\n registered.get(definition) ?? builtIns.get(definition) ?? null;\n","import type { BaseType } from '../lib/expression-result';\n\nconst SCORING_BOOLEANS: Record<string, boolean | undefined> = { true: true, '1': true, false: false, '0': false };\n\nexport class ScoringHelper {\n /**\n * Checks if a given point is within a specified area.\n * @param point The point to test, represented as a string \"x y\" (e.g., \"102 113\").\n * @param areaKey The area definition, including shape and coordinates (e.g., \"circle,102,113,16\").\n * @param baseType The base type of the response, must be \"point\" for this method to proceed.\n * @returns True if the point is within the area; false otherwise.\n */\n public static isPointInArea(point: string, areaKey: string, baseType: string): boolean {\n if (baseType !== 'point') {\n console.warn(`Base type ${baseType} is not supported for point area mapping.`);\n return false;\n }\n\n // Parse the point as x and y coordinates\n const [px, py] = point.split(' ').map(Number);\n\n // Parse the area definition\n const [shape, ...coords] = areaKey.split(',');\n const coordinates = coords.map(Number);\n\n switch (shape.toLowerCase()) {\n // \"The default shape refers to the entire area of the associated image\" (QTI 3.0 §8.29), so\n // every point is inside it and the coords are not read — §7.9 says none should be given, and\n // the XSD still requires the attribute, so whatever is there is filler.\n //\n // This used to share the `circle` branch below, which demands exactly three coords and so\n // rejected any real default entry as an \"Invalid circle definition\" (Citolab/qti-components#83).\n case 'default':\n return true;\n\n case 'circle': {\n const [cx, cy, radius] = coordinates;\n if (coordinates.length !== 3) {\n console.warn(`Invalid circle definition: ${areaKey}`);\n return false;\n }\n const distance = Math.sqrt((px - cx) ** 2 + (py - cy) ** 2);\n return distance <= radius;\n }\n\n case 'rect': {\n const [x1, y1, x2, y2] = coordinates;\n if (coordinates.length !== 4) {\n console.warn(`Invalid rectangle definition: ${areaKey}`);\n return false;\n }\n return px >= x1 && px <= x2 && py >= y1 && py <= y2;\n }\n\n case 'ellipse': {\n const [cx, cy, rx, ry] = coordinates;\n if (coordinates.length !== 4) {\n console.warn(`Invalid ellipse definition: ${areaKey}`);\n return false;\n }\n // Ellipse equation: ((px - cx)² / rx²) + ((py - cy)² / ry²) <= 1\n const normalizedX = (px - cx) ** 2 / rx ** 2;\n const normalizedY = (py - cy) ** 2 / ry ** 2;\n return normalizedX + normalizedY <= 1;\n }\n\n case 'poly': {\n if (coordinates.length < 6 || coordinates.length % 2 !== 0) {\n console.warn(`Invalid polygon definition: ${areaKey}`);\n return false;\n }\n const vertices = [];\n for (let i = 0; i < coordinates.length; i += 2) {\n vertices.push({ x: coordinates[i], y: coordinates[i + 1] });\n }\n return this.isPointInPolygon({ x: px, y: py }, vertices);\n }\n\n default:\n console.warn(`Unsupported shape type: ${shape}`);\n return false;\n }\n }\n\n /**\n * Checks if a point is inside a polygon using the ray-casting algorithm.\n * @param point The point to test.\n * @param vertices The vertices of the polygon in order (array of {x, y} objects).\n * @returns True if the point is inside the polygon; false otherwise.\n */\n static isPointInPolygon(point: { x: number; y: number }, vertices: { x: number; y: number }[]): boolean {\n let inside = false;\n for (let i = 0, j = vertices.length - 1; i < vertices.length; j = i++) {\n const xi = vertices[i].x,\n yi = vertices[i].y;\n const xj = vertices[j].x,\n yj = vertices[j].y;\n\n const intersect = yi > point.y !== yj > point.y && point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi;\n\n if (intersect) inside = !inside;\n }\n return inside;\n }\n\n public static compareSingleValues(value1: Readonly<string>, value2: Readonly<string>, baseType: BaseType): boolean {\n switch (baseType) {\n case 'identifier':\n case 'string':\n return value1 === value2;\n case 'boolean': {\n // XML Schema booleans: \"true\" / \"1\" and \"false\" / \"0\"\n const bool1 = SCORING_BOOLEANS[value1.trim().toLowerCase()];\n return bool1 !== undefined && bool1 === SCORING_BOOLEANS[value2.trim().toLowerCase()];\n }\n case 'integer': {\n const int1 = parseInt(value1, 10);\n const int2 = parseInt(value2, 10);\n if (!isNaN(int1) && !isNaN(int2)) {\n /*\n * `parseInt` truncates, so on its own it reads \"2\" and \"2.5\" as the\n * same number. That matters because the base type is taken from one\n * operand: an expression whose result happens to be whole is an\n * integer, and it was then compared against a fractional value with\n * the fraction thrown away — `equal(divide(4, 2), 2.5)` was true.\n *\n * When either side has a fractional part the two are, by definition,\n * not the same number. Comparing them in full says so, while the\n * integer path keeps `parseInt`'s tolerance of a value like \"12 euro\"\n * for everything that really is whole.\n */\n const float1 = parseFloat(value1);\n const float2 = parseFloat(value2);\n if (!Number.isInteger(float1) || !Number.isInteger(float2)) {\n return float1 === float2;\n }\n return int1 === int2;\n } else {\n console.error(`Cannot convert ${value1} and/or ${value2} to int.`);\n }\n break;\n }\n case 'float': {\n const float1 = parseFloat(value1);\n const float2 = parseFloat(value2);\n if (!isNaN(float1) && !isNaN(float2)) {\n return float1 === float2;\n } else {\n console.error(`couldn't convert ${value1} and/or ${value2} to float.`);\n }\n break;\n }\n case 'pair':\n case 'directedPair': {\n /*\n * Only a `pair` is unordered. A `directedPair` is directed — \"A B\" and\n * \"B A\" are different values — so it must be compared as written.\n *\n * Both operands used to be sorted the moment they were split, which\n * made the `baseType === 'pair'` sort below it dead code and every\n * directedPair comparison order-insensitive: a candidate who matched\n * the right two identifiers the wrong way round scored as correct.\n */\n const pair1 = value1.split(' ');\n const pair2 = value2.split(' ');\n if (pair1.length === 2 && pair2.length === 2) {\n if (baseType === 'pair') {\n pair1.sort();\n pair2.sort();\n }\n return pair1.join(' ') === pair2.join(' ');\n } else {\n console.error(`compared two pair but one of the values does not have 2 values: 1: ${value1} 2: ${value2}`);\n }\n break;\n }\n }\n\n return false;\n }\n}\n","import { ContextRoot } from '@lit/context';\n\nconst INSTALLED = Symbol.for('qti-components.context-root');\n\n/**\n * Catches context requests nobody answered and asks again when a provider connects, so a component\n * that upgrades before the element providing its context still gets the value.\n *\n * It has to live on the document and not on one of our elements: the case it exists for is the\n * providing element not having upgraded yet, so there is nothing of ours to attach it to. It holds\n * only requests that subscribe, which every `@consume` in this library does, and it holds them\n * weakly, so nothing is kept alive that would not be anyway.\n *\n * Once per page, however many copies of the package the page ends up with.\n */\nexport const installContextRoot = (): void => {\n if (typeof document === 'undefined') return;\n const page = globalThis as unknown as Record<symbol, ContextRoot | undefined>;\n if (page[INSTALLED]) return;\n page[INSTALLED] = new ContextRoot();\n page[INSTALLED].attach(document.documentElement);\n};\n\ninstallContextRoot();\n","import { qtiBaseElements } from './elements';\nimport { installCustomStateSetFallback } from './utils/custom-state-set';\n\n// Before any element is defined, so the patched `attachInternals` is in place by\n// the time the first interaction upgrades. No-op where `states` works natively.\ninstallCustomStateSetFallback();\n\nfor (const { tag, ctor } of qtiBaseElements) {\n if (!customElements.get(tag)) {\n customElements.define(tag, ctor);\n }\n}\n"],"mappings":";AAoBO,IAAM,kBAA8E,CAAA;;;ACSrF,IAAO,qBAAP,cAAkC,IAAW;EACxC;EAET,YAAY,MAAiB;AAC3B,UAAK;AACL,SAAK,QAAQ;EACf;EAES,IAAIA,QAAa;AACxB,UAAM,IAAIA,MAAK;AACf,SAAK,SAAQ;AACb,WAAO;EACT;EAES,OAAOA,QAAa;AAC3B,UAAM,UAAU,MAAM,OAAOA,MAAK;AAClC,SAAK,SAAQ;AACb,WAAO;EACT;EAES,QAAK;AACZ,UAAM,MAAK;AACX,SAAK,SAAQ;EACf;EAEA,WAAQ;AAGN,QAAI,KAAK,MAAM;AAAa,WAAK,OAAM;;AA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B,kBAAM,KAAI;AACV,kBAAM,KAAI;UACZ;AACA,iBAAO,MAAM,KAAK,GAAG,MAAM,MAAM,KAAK,GAAG;QAC3C,OAAO;AACL,kBAAQ,MAAM,sEAAsE,MAAM,OAAO,MAAM,EAAE;QAC3G;AACA;MACF;IACF;AAEA,WAAO;EACT;;;;ACnLF,SAAS,mBAAmB;AAE5B,IAAM,YAAY,uBAAO,IAAI,6BAA6B;AAanD,IAAM,qBAAqB,MAAW;AAC3C,MAAI,OAAO,aAAa;AAAa;AACrC,QAAM,OAAO;AACb,MAAI,KAAK,SAAS;AAAG;AACrB,OAAK,SAAS,IAAI,IAAI,YAAW;AACjC,OAAK,SAAS,EAAE,OAAO,SAAS,eAAe;AACjD;AAEA,mBAAkB;;;AClBlB,8BAA6B;AAE7B,WAAW,EAAE,KAAK,KAAI,KAAM,iBAAiB;AAC3C,MAAI,CAAC,eAAe,IAAI,GAAG,GAAG;AAC5B,mBAAe,OAAO,KAAK,IAAI;EACjC;AACF;","names":["state","createContext","createContext","createContext","createContext","createContext","createContext","createContext","css","css","state","LitElement","consume","css","html","LitElement","LitElement","css","html","__decorate","consume","ContextConsumer","consume","LitElement","property","LitElement","ContextConsumer","__decorate","property","consume","LitElement"]}
@@ -6,7 +6,7 @@ import { g as QtiGapText, k as QtiHotspotChoice, m as QtiHottext, v as QtiSimple
6
6
  import { QtiAssessmentItem } from './elements.js';
7
7
  import { Q as QtiItem } from './qti-item.d-DgC1AQbY.js';
8
8
  import { V as View, C as ComputedItemContext } from './session.context.d-D5080LVx.js';
9
- import { i as QtiTest, T as TestCheckItem, r as TestNavigation } from './qti-test.d-_THYXPzd.js';
9
+ import { k as QtiTest, T as TestCheckItem, t as TestNavigation } from './qti-test.d-DkpBNcsv.js';
10
10
  import { a as ComputedItem, C as ComputedContext } from './computed.types.d-gJrBeUMG.js';
11
11
  import './config.context.d-BvU9r-Mg.js';
12
12
  import './interaction.interface.d-CvjHM2bi.js';
@@ -16,7 +16,7 @@ import 'lit/directives/ref.js';
16
16
  import './qti-feedback.d-wMYNVkkj.js';
17
17
  import './qti-rule-base.d-Bdzg8eGH.js';
18
18
  import './qti-transform-test.d-BL7GGFJj.js';
19
- import './qti-expression.d-CuaLjZ6g.js';
19
+ import './qti-expression.d-BPxEp8HU.js';
20
20
  import '@heximal/templates';
21
21
 
22
22
  type AbstractConstructor$2<T = {}> = abstract new (...args: any[]) => T;
@@ -34,28 +34,28 @@ import {
34
34
  TestNavigationCorrection,
35
35
  TestShowCorrectResponse,
36
36
  correctionPart
37
- } from "./chunk-EPSUZIWL.js";
37
+ } from "./chunk-2KP5UU5A.js";
38
38
  import {
39
39
  qtiTestElements
40
- } from "./chunk-EUKU5QKV.js";
40
+ } from "./chunk-K3VKQ6QF.js";
41
41
  import {
42
42
  qtiContentElements
43
- } from "./chunk-AWTQKBC4.js";
43
+ } from "./chunk-6U3YPHXU.js";
44
44
  import {
45
45
  qtiInteractionElements
46
- } from "./chunk-CNFVA3AA.js";
46
+ } from "./chunk-RSMYGGQK.js";
47
47
  import {
48
48
  qtiItemElements
49
- } from "./chunk-F7R7GSWL.js";
49
+ } from "./chunk-RU6332MD.js";
50
50
  import "./chunk-ZP6QQYSU.js";
51
51
  import "./chunk-4DB4SC5K.js";
52
52
  import "./chunk-TLAVOBEM.js";
53
53
  import {
54
54
  qtiProcessingElements
55
- } from "./chunk-3BAQWO5C.js";
55
+ } from "./chunk-6K3QWJHH.js";
56
56
  import {
57
57
  qtiBaseElements
58
- } from "./chunk-R7MMMDP7.js";
58
+ } from "./chunk-TDWJ6WZA.js";
59
59
 
60
60
  // ../qti-corrections/dist/elements.js
61
61
  var qtiCorrectionElements = [
package/dist/elements.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-SVYHZIJ7.js";
1
+ import "./chunk-GBZNFSFY.js";
2
2
  import {
3
3
  PUBLIC_ITEM_EVENTS,
4
4
  QtiAssessmentItem,
@@ -25,10 +25,10 @@ import {
25
25
  dispatchPublic,
26
26
  listenDeclared,
27
27
  listenPublic
28
- } from "./chunk-AWTQKBC4.js";
28
+ } from "./chunk-6U3YPHXU.js";
29
29
  import "./chunk-4DB4SC5K.js";
30
30
  import "./chunk-TLAVOBEM.js";
31
- import "./chunk-R7MMMDP7.js";
31
+ import "./chunk-TDWJ6WZA.js";
32
32
  export {
33
33
  PUBLIC_ITEM_EVENTS,
34
34
  QtiAssessmentItem,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { I as ITestNavigationMixin, a as ITestStateMixin, b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiItemSessionControl, f as QtiNumberSelected, g as QtiOutcomeProcessing, h as QtiOutcomeProcessingProcessor, i as QtiTest, j as QtiTestFeedback, k as QtiTestPart, l as QtiTestVariables, m as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, n as TestContainer, o as TestEndAttempt, p as TestItemLink, q as TestItemToSpeech, r as TestNavigation, s as TestNext, t as TestPagingButtonsStamp, u as TestPrev, v as TestPrintContext, w as TestPrintVariables, x as TestScoringButtons, y as TestScoringFeedback, z as TestSectionButtonsStamp, A as TestSectionLink, B as TestStamp, C as TestTtsNext, D as TestTtsPause, E as TestTtsPick, F as TestTtsPlay, G as TestTtsPrev, H as TestTtsResume, J as TestTtsStop, K as TestView, L as TestViewToggle, M as TtsContext, N as ttsContext } from './qti-test.d-_THYXPzd.js';
1
+ export { I as ITestNavigationMixin, a as ITestStateMixin, b as ItemRefTemplateModel, Q as QtiAssessmentItemRef, c as QtiAssessmentSection, d as QtiAssessmentTest, e as QtiBranchRule, f as QtiItemSessionControl, g as QtiNumberSelected, h as QtiOutcomeProcessing, i as QtiOutcomeProcessingProcessor, j as QtiPreCondition, k as QtiTest, l as QtiTestFeedback, m as QtiTestPart, n as QtiTestVariables, o as QtiTestVariablesExpression, S as SpeechState, T as TestCheckItem, p as TestContainer, q as TestEndAttempt, r as TestItemLink, s as TestItemToSpeech, t as TestNavigation, u as TestNext, v as TestPagingButtonsStamp, w as TestPrev, x as TestPrintContext, y as TestPrintVariables, z as TestScoringButtons, A as TestScoringFeedback, B as TestSectionButtonsStamp, C as TestSectionLink, D as TestStamp, E as TestTtsNext, F as TestTtsPause, G as TestTtsPick, H as TestTtsPlay, J as TestTtsPrev, K as TestTtsResume, L as TestTtsStop, M as TestView, N as TestViewToggle, O as TtsContext, P as ttsContext } from './qti-test.d-DkpBNcsv.js';
2
2
  export { IMyQtiTest, IQtiTest, ITestProcessingMixin, QTI_TEST_STATE_VERSION, QtiTestState, QtiTestStateItem, QtiTestStateSession, QtiTestStateValue } from './test.js';
3
3
  export { I as ItemContainer, a as ItemPrintVariables, Q as QtiItem } from './qti-item.d-DgC1AQbY.js';
4
4
  export { ItemViewMixin } from './item.js';
@@ -15,9 +15,9 @@ export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } fr
15
15
  export { C as ChoiceRole, I as Interaction, a as InteractionContext, i as interactionContext } from './interaction.d-g6XG0T0Z.js';
16
16
  export { B as BaseType, C as Calculate, a as Cardinality, I as InterpolationTableEntry, b as ItemContext, M as Multiple, O as Ordered, c as OutcomeVariable, Q as QtiAreaMapEntry, d as QtiAreaMapping, e as QtiMapEntry, f as QtiMapping, R as ResponseInteraction, g as ResponseVariable, T as TemplateVariable, V as VariableDeclaration, h as VariableValue, i as areaShape, j as directedPair, k as float, l as integer, m as itemContextVariables } from './item.types.d-B55QkJ92.js';
17
17
  export { Q as QtiContext, a as QtiContextType, S as Seed, b as asSeed, i as isSeed, q as qtiContext } from './qti.context.d-CejJMlfZ.js';
18
- export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-CuaLjZ6g.js';
18
+ export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-BPxEp8HU.js';
19
19
  export { Q as QtiFeedback, a as QtiVariableDeclaration } from './qti-feedback.d-wMYNVkkj.js';
20
- export { Q as QtiConditionExpression } from './qti-condition-expression.d-L7yb3Rzy.js';
20
+ export { Q as QtiConditionExpression } from './qti-condition-expression.d-VJH6cWxf.js';
21
21
  export { D as DirectedPair, I as Identifier, P as Point, R as ResponseValue, i as iterResponseValues, p as parsePair, a as parsePoint, b as parseResponseAttribute, r as responseAttributeConverter, s as serializePair, c as serializePoint, d as serializeResponseAttribute } from './response.d-_8y4kjGP.js';
22
22
  export { F as FormAssociatedInteraction, I as IInteraction, R as ReadonlyInteraction, a as RegisteredInteraction, b as ResettableInteraction, c as ResponseIdentifiedInteraction, d as ResponseInteractionElement, V as ValidatableInteraction } from './interaction.interface.d-CvjHM2bi.js';
23
23
  export { Q as QtiExitResponseSignal, a as QtiExitTestSignal, b as QtiRuleBase, c as QtiRuleElement } from './qti-rule-base.d-Bdzg8eGH.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./chunk-QD3Y6UK3.js";
1
+ import "./chunk-3ZNECUPV.js";
2
2
  import {
3
3
  CandidateCorrectionMixin,
4
4
  ChoiceCorrectionMixin,
@@ -35,16 +35,18 @@ import {
35
35
  TestNavigationCorrection,
36
36
  TestShowCorrectResponse,
37
37
  correctionPart
38
- } from "./chunk-EPSUZIWL.js";
38
+ } from "./chunk-2KP5UU5A.js";
39
39
  import {
40
40
  QTI_TEST_STATE_VERSION,
41
41
  QtiAssessmentItemRef,
42
42
  QtiAssessmentSection,
43
43
  QtiAssessmentTest,
44
+ QtiBranchRule,
44
45
  QtiItemSessionControl,
45
46
  QtiNumberSelected,
46
47
  QtiOutcomeProcessing,
47
48
  QtiOutcomeProcessingProcessor,
49
+ QtiPreCondition,
48
50
  QtiTest,
49
51
  QtiTestFeedback,
50
52
  QtiTestPart,
@@ -76,8 +78,8 @@ import {
76
78
  TestView,
77
79
  TestViewToggle,
78
80
  ttsContext
79
- } from "./chunk-EUKU5QKV.js";
80
- import "./chunk-SVYHZIJ7.js";
81
+ } from "./chunk-K3VKQ6QF.js";
82
+ import "./chunk-GBZNFSFY.js";
81
83
  import {
82
84
  PUBLIC_ITEM_EVENTS,
83
85
  QtiAssessmentItem,
@@ -104,8 +106,8 @@ import {
104
106
  dispatchPublic,
105
107
  listenDeclared,
106
108
  listenPublic
107
- } from "./chunk-AWTQKBC4.js";
108
- import "./chunk-GPNWMLLA.js";
109
+ } from "./chunk-6U3YPHXU.js";
110
+ import "./chunk-35WWWFS6.js";
109
111
  import {
110
112
  QtiAssociableHotspot,
111
113
  QtiAssociateInteraction,
@@ -140,14 +142,14 @@ import {
140
142
  QtiTextEntryInteraction,
141
143
  QtiUploadInteraction,
142
144
  qtiInteractionElements
143
- } from "./chunk-CNFVA3AA.js";
144
- import "./chunk-WNAOVXXN.js";
145
+ } from "./chunk-RSMYGGQK.js";
146
+ import "./chunk-FD4AB6TM.js";
145
147
  import {
146
148
  ItemContainer,
147
149
  ItemPrintVariables,
148
150
  ItemViewMixin,
149
151
  QtiItem
150
- } from "./chunk-F7R7GSWL.js";
152
+ } from "./chunk-RU6332MD.js";
151
153
  import "./chunk-ZP6QQYSU.js";
152
154
  import "./chunk-4DB4SC5K.js";
153
155
  import {
@@ -159,7 +161,7 @@ import {
159
161
  qtiTransformManifest,
160
162
  qtiTransformTest
161
163
  } from "./chunk-TLAVOBEM.js";
162
- import "./chunk-ACRN7YJM.js";
164
+ import "./chunk-MI7774NV.js";
163
165
  import {
164
166
  QtiAnd,
165
167
  QtiAnyN,
@@ -237,7 +239,7 @@ import {
237
239
  QtiVariable,
238
240
  qtiAndMixin,
239
241
  qtiSubtractMixin
240
- } from "./chunk-3BAQWO5C.js";
242
+ } from "./chunk-6K3QWJHH.js";
241
243
  import {
242
244
  CustomStateSetShim,
243
245
  INITIAL_SESSION_CONTEXT,
@@ -282,7 +284,7 @@ import {
282
284
  testContext,
283
285
  unregisterCustomOperator,
284
286
  validationMessage
285
- } from "./chunk-R7MMMDP7.js";
287
+ } from "./chunk-TDWJ6WZA.js";
286
288
  export {
287
289
  CandidateCorrectionMixin,
288
290
  ChoiceCorrectionMixin,
@@ -315,6 +317,7 @@ export {
315
317
  QtiAssociateInteraction,
316
318
  QtiAssociateInteractionCorrection,
317
319
  QtiBaseValue,
320
+ QtiBranchRule,
318
321
  QtiChoiceInteraction,
319
322
  QtiChoiceInteractionCorrection,
320
323
  QtiCompanionMaterialsInfo,
@@ -418,6 +421,7 @@ export {
418
421
  QtiPositionObjectInteraction,
419
422
  QtiPositionObjectStage,
420
423
  QtiPower,
424
+ QtiPreCondition,
421
425
  QtiPrintedVariable,
422
426
  QtiProduct,
423
427
  QtiPrompt,
@@ -1,4 +1,4 @@
1
- import "./chunk-GPNWMLLA.js";
1
+ import "./chunk-35WWWFS6.js";
2
2
  import {
3
3
  QtiAssociableHotspot,
4
4
  QtiAssociateInteraction,
@@ -33,9 +33,9 @@ import {
33
33
  QtiTextEntryInteraction,
34
34
  QtiUploadInteraction,
35
35
  qtiInteractionElements
36
- } from "./chunk-CNFVA3AA.js";
36
+ } from "./chunk-RSMYGGQK.js";
37
37
  import "./chunk-4DB4SC5K.js";
38
- import "./chunk-R7MMMDP7.js";
38
+ import "./chunk-TDWJ6WZA.js";
39
39
  export {
40
40
  QtiAssociableHotspot,
41
41
  QtiAssociateInteraction,
package/dist/item.js CHANGED
@@ -1,14 +1,14 @@
1
- import "./chunk-WNAOVXXN.js";
1
+ import "./chunk-FD4AB6TM.js";
2
2
  import {
3
3
  ItemContainer,
4
4
  ItemPrintVariables,
5
5
  ItemViewMixin,
6
6
  QtiItem
7
- } from "./chunk-F7R7GSWL.js";
7
+ } from "./chunk-RU6332MD.js";
8
8
  import "./chunk-ZP6QQYSU.js";
9
9
  import "./chunk-4DB4SC5K.js";
10
10
  import "./chunk-TLAVOBEM.js";
11
- import "./chunk-R7MMMDP7.js";
11
+ import "./chunk-TDWJ6WZA.js";
12
12
  export {
13
13
  ItemContainer,
14
14
  ItemPrintVariables,
@@ -2,8 +2,8 @@ import * as lit from 'lit';
2
2
  import { LitElement, nothing } from 'lit';
3
3
  import { b as QtiRuleBase } from './qti-rule-base.d-Bdzg8eGH.js';
4
4
  import { b as ItemContext, B as BaseType, g as ResponseVariable, V as VariableDeclaration } from './item.types.d-B55QkJ92.js';
5
- import { Q as QtiExpression, a as QtiExpressionBase, T as TestContext } from './qti-expression.d-CuaLjZ6g.js';
6
- import { Q as QtiConditionExpression } from './qti-condition-expression.d-L7yb3Rzy.js';
5
+ import { Q as QtiExpression, a as QtiExpressionBase, T as TestContext } from './qti-expression.d-BPxEp8HU.js';
6
+ import { Q as QtiConditionExpression } from './qti-condition-expression.d-VJH6cWxf.js';
7
7
  import './qti.context.d-CejJMlfZ.js';
8
8
 
9
9
  declare class QtiRule extends LitElement implements QtiRuleBase {
@@ -1,4 +1,4 @@
1
- import "./chunk-ACRN7YJM.js";
1
+ import "./chunk-MI7774NV.js";
2
2
  import {
3
3
  QtiAnd,
4
4
  QtiAnyN,
@@ -76,8 +76,8 @@ import {
76
76
  QtiVariable,
77
77
  qtiAndMixin,
78
78
  qtiSubtractMixin
79
- } from "./chunk-3BAQWO5C.js";
80
- import "./chunk-R7MMMDP7.js";
79
+ } from "./chunk-6K3QWJHH.js";
80
+ import "./chunk-TDWJ6WZA.js";
81
81
  export {
82
82
  QtiAnd,
83
83
  QtiAnyN,