@citolab/qti-components 10.0.0-next.12 → 10.0.0-next.13

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 (55) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +227 -176
  3. package/dist/base.d.ts +2 -2
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-YOCOLMGB.js → chunk-AKX4YMWU.js} +2 -2
  6. package/dist/chunk-DVLSXMXD.js +7 -0
  7. package/dist/chunk-DVLSXMXD.js.map +1 -0
  8. package/dist/{chunk-PLP3YX6C.js → chunk-EIBGCCXH.js} +2 -2
  9. package/dist/{chunk-RWMY7KRT.js → chunk-FLAD6SC6.js} +2 -2
  10. package/dist/{chunk-AVZRY5SQ.js → chunk-G6LTYTJR.js} +2 -2
  11. package/dist/{chunk-OHRAG2UM.js → chunk-H3GITIPE.js} +36 -15
  12. package/dist/chunk-H3GITIPE.js.map +1 -0
  13. package/dist/{chunk-O76BOKAP.js → chunk-HOGJ5ZNW.js} +8 -6
  14. package/dist/{chunk-O76BOKAP.js.map → chunk-HOGJ5ZNW.js.map} +1 -1
  15. package/dist/{chunk-AJ5U5KXR.js → chunk-K4WLYVDT.js} +2 -2
  16. package/dist/{chunk-LCGPLQLE.js → chunk-MDBNEEPH.js} +2 -2
  17. package/dist/{chunk-M7X6TWSX.js → chunk-PHRHLDQB.js} +2 -2
  18. package/dist/{chunk-XXJAE6AP.js → chunk-PYHKCIYN.js} +3 -3
  19. package/dist/{chunk-T7YSBBAA.js → chunk-WUIA4OOX.js} +1 -1
  20. package/dist/chunk-WUIA4OOX.js.map +1 -0
  21. package/dist/{chunk-5K5JO7OG.js → chunk-Y5DZTCDP.js} +179 -103
  22. package/dist/chunk-Y5DZTCDP.js.map +1 -0
  23. package/dist/{config.context.d-BvU9r-Mg.d.ts → config.context.d-BniMHSBB.d.ts} +3 -2
  24. package/dist/corrections.d.ts +16 -6
  25. package/dist/corrections.js +8 -8
  26. package/dist/elements.js +3 -3
  27. package/dist/index.d.ts +5 -5
  28. package/dist/index.js +15 -13
  29. package/dist/interactions.d.ts +4 -4
  30. package/dist/interactions.js +3 -3
  31. package/dist/item.css +36 -16
  32. package/dist/item.d.ts +2 -2
  33. package/dist/item.js +4 -4
  34. package/dist/processing.js +3 -3
  35. package/dist/qti-components-jsx.d.ts +78 -11
  36. package/dist/{qti-item.d-B1gffYCL.d.ts → qti-item.d-BqWYBdV2.d.ts} +1 -1
  37. package/dist/{qti-test.d-D5C7W8Lg.d.ts → qti-test.d-B6AGSQlk.d.ts} +29 -3
  38. package/dist/{qti-text-entry-interaction.d-CU-fAAD1.d.ts → qti-text-entry-interaction.d-B44Z3qUG.d.ts} +6 -4
  39. package/dist/{record.d-wB9uYs-j.d.ts → record.d-C6m0Y4xr.d.ts} +1 -1
  40. package/dist/test.d.ts +7 -4
  41. package/dist/test.js +7 -5
  42. package/package.json +9 -9
  43. package/dist/chunk-5K5JO7OG.js.map +0 -1
  44. package/dist/chunk-OHRAG2UM.js.map +0 -1
  45. package/dist/chunk-T7YSBBAA.js.map +0 -1
  46. package/dist/chunk-YKXVAXSI.js +0 -7
  47. package/dist/chunk-YKXVAXSI.js.map +0 -1
  48. /package/dist/{chunk-YOCOLMGB.js.map → chunk-AKX4YMWU.js.map} +0 -0
  49. /package/dist/{chunk-PLP3YX6C.js.map → chunk-EIBGCCXH.js.map} +0 -0
  50. /package/dist/{chunk-RWMY7KRT.js.map → chunk-FLAD6SC6.js.map} +0 -0
  51. /package/dist/{chunk-AVZRY5SQ.js.map → chunk-G6LTYTJR.js.map} +0 -0
  52. /package/dist/{chunk-AJ5U5KXR.js.map → chunk-K4WLYVDT.js.map} +0 -0
  53. /package/dist/{chunk-LCGPLQLE.js.map → chunk-MDBNEEPH.js.map} +0 -0
  54. /package/dist/{chunk-M7X6TWSX.js.map → chunk-PHRHLDQB.js.map} +0 -0
  55. /package/dist/{chunk-XXJAE6AP.js.map → chunk-PYHKCIYN.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../qti-corrections/src/components/item-correct-response-mode/item-correct-response-mode.ts","../../qti-corrections/src/components/item-show-candidate-correction/item-show-candidate-correction.ts","../../qti-corrections/src/components/styles.ts","../../qti-corrections/src/components/item-show-correct-response/item-show-correct-response.ts","../../qti-corrections/src/components/test-show-correct-response/test-show-correct-response.ts","../../qti-corrections/src/styles/correction.styles.ts","../../qti-corrections/src/elements/qti-gap-text-correction.ts","../../qti-corrections/src/mixins/active-element-correction.mixin.ts","../../qti-corrections/src/elements/qti-hotspot-choice-correction.ts","../../qti-corrections/src/elements/qti-hottext-correction.ts","../../qti-corrections/src/elements/qti-simple-associable-choice-correction.ts","../../qti-corrections/src/elements/qti-simple-choice-correction.ts","../../qti-corrections/src/mixins/correct-response.mixin.ts","../../qti-corrections/src/mixins/candidate-correction.mixin.ts","../../qti-corrections/src/mixins/drag-drop-correction.mixin.ts","../../qti-corrections/src/interactions/qti-associate-interaction-correction.ts","../../qti-corrections/src/mixins/choice-correction.mixin.ts","../../qti-corrections/src/interactions/qti-choice-interaction-correction.ts","../../qti-corrections/src/interactions/qti-extended-text-interaction-correction.ts","../../qti-corrections/src/interactions/shared.ts","../../qti-corrections/src/interactions/qti-gap-match-interaction-correction.ts","../../qti-corrections/src/interactions/qti-graphic-associate-interaction-correction.ts","../../qti-corrections/src/interactions/qti-graphic-gap-match-interaction-correction.ts","../../qti-corrections/src/interactions/qti-graphic-order-interaction-correction.ts","../../qti-corrections/src/interactions/qti-hotspot-interaction-correction.ts","../../qti-corrections/src/interactions/qti-hottext-interaction-correction.ts","../../qti-corrections/src/interactions/qti-inline-choice-interaction-correction.ts","../../qti-corrections/src/interactions/qti-match-interaction-correction.ts","../../qti-corrections/src/utils/longest-increasing-subsequence.ts","../../qti-corrections/src/interactions/qti-order-interaction-correction.ts","../../qti-corrections/src/interactions/qti-portable-custom-interaction-correction.ts","../../qti-corrections/src/interactions/qti-select-point-interaction-correction.ts","../../qti-corrections/src/interactions/qti-slider-interaction-correction.ts","../../qti-corrections/src/interactions/qti-text-entry-interaction-correction.ts","../../qti-corrections/src/components/qti-assessment-item-correction.ts","../../qti-corrections/src/components/qti-item-correction.ts","../../qti-corrections/src/components/test-correction-elements.ts"],"sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { configContext } from '@qti-components/base';\n\nimport type { ConfigContext } from '@qti-components/base';\nimport type { CorrectionConfig, CorrectResponseMode } from '../../context/correction-config';\n\nexport class ItemCorrectResponseMode extends LitElement {\n @consume({ context: configContext, subscribe: true })\n private itemContext: ConfigContext & CorrectionConfig;\n\n @property({ type: String })\n label = 'Correct response mode';\n\n @state()\n private _options = {\n internal: 'Internal',\n full: 'Full (copy)'\n };\n\n #switchMode(view: CorrectResponseMode) {\n this.dispatchEvent(\n new CustomEvent('item-switch-correct-response-mode', {\n detail: view,\n bubbles: true\n })\n );\n }\n\n override render() {\n return html`\n <label part=\"label\" for=\"modeSelect\">${this.label}</label>\n <select\n part=\"select\"\n id=\"modeSelect\"\n @change=${(e: Event) => {\n const el = e.target as HTMLSelectElement;\n this.#switchMode(el.value as CorrectResponseMode);\n }}\n >\n ${Object.keys(this._options).map(\n value =>\n html`<option value=\"${value}\" ?selected=${value === this.itemContext?.correctResponseMode}>\n ${this._options[value as keyof typeof this._options]}\n </option>`\n )}\n </select>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-correct-response-mode': ItemCorrectResponseMode;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedItemContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\n\nimport type { ComputedItemContext } from '@qti-components/base';\n\nexport class ItemShowCandidateCorrection extends LitElement {\n @consume({ context: computedItemContext, subscribe: true })\n public computedContext?: ComputedItemContext;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: Boolean, reflect: true }) shown = false;\n @property({ type: Boolean, reflect: true }) disabled = false; // Reflects to `disabled` attribute\n @property({ type: String }) showCandidateCorrectionText = 'Show candidate correction';\n @property({ type: String }) hideCandidateCorrectionText = 'Hide candidate correction';\n @property({ type: String }) noCorrectResponseText = 'No correct response specified';\n\n #hasCorrectResponse = false; // correct response is removed on certain point\n #previousActiveItem = ''; // Store previous active item reference\n\n constructor() {\n super();\n }\n\n override updated() {\n if (!this.#hasCorrectResponse || this.#previousActiveItem !== this.computedContext?.identifier) {\n this.#previousActiveItem = this.computedContext?.identifier;\n const containsCorrectResponse = !!this.computedContext?.variables.some(v => (v as any)['correctResponse']);\n const containsMapping = !!this.computedContext?.variables.some(v => {\n return (v as any)['mapping']?.mapEntries?.length > 0 || (v as any)['areaMapping']?.areaMapEntries?.length > 0;\n });\n this.#hasCorrectResponse = containsCorrectResponse || containsMapping;\n }\n this.disabled = !this.#hasCorrectResponse;\n }\n\n #toggleState() {\n if (this.disabled) return; // Prevent toggle if disabled\n\n this.dispatchEvent(\n new CustomEvent('item-show-candidate-correction', {\n detail: !this.shown,\n bubbles: true\n })\n );\n }\n\n #getDisplayedText(): string {\n return this.disabled\n ? this.noCorrectResponseText\n : this.shown\n ? this.hideCandidateCorrectionText\n : this.showCandidateCorrectionText;\n }\n\n override render() {\n return html` <div @click=\"${this.#toggleState}\">${this.#getDisplayedText()}</div> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-show-candidate-correction': ItemShowCandidateCorrection;\n }\n}\n","import { css } from 'lit';\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n cursor: pointer;\n padding: 0.5rem 1rem;\n border-radius: 0.25rem;\n user-select: none;\n`;\n\nexport const btn = css`\n background-color: lightgray;\n ${form};\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.8;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedItemContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\n\nimport type { ComputedItemContext } from '@qti-components/base';\n\nexport class ItemShowCorrectResponse extends LitElement {\n @consume({ context: computedItemContext, subscribe: true })\n public computedContext?: ComputedItemContext;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: Boolean, reflect: true }) shown = false;\n @property({ type: Boolean, reflect: true }) disabled = false; // Reflects to `disabled` attribute\n @property({ type: String }) showCorrectText = 'Show correct response';\n @property({ type: String }) hideCorrectText = 'Hide correct response';\n @property({ type: String }) noCorrectResponseText = 'No correct response specified';\n\n #hasCorrectResponse = false; // correct response is removed on certain point\n #previousActiveItem = ''; // Store previous active item reference\n\n override updated() {\n if (!this.#hasCorrectResponse || this.#previousActiveItem !== this.computedContext?.identifier) {\n this.#previousActiveItem = this.computedContext?.identifier;\n const containsCorrectResponse = !!this.computedContext?.variables.some(v => (v as any)['correctResponse']);\n const containsMapping = !!this.computedContext?.variables.some(v => {\n return (v as any)['mapping']?.mapEntries?.length > 0 || (v as any)['areaMapping']?.areaMapEntries?.length > 0;\n });\n this.#hasCorrectResponse = containsCorrectResponse || containsMapping;\n }\n this.disabled = !this.#hasCorrectResponse;\n }\n\n #toggleState() {\n if (this.disabled) return; // Prevent toggle if disabled\n\n this.dispatchEvent(\n new CustomEvent('item-show-correct-response', {\n detail: !this.shown,\n bubbles: true\n })\n );\n }\n\n #getDisplayedText(): string {\n return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;\n }\n\n override render() {\n return html` <div @click=\"${this.#toggleState}\">${this.#getDisplayedText()}</div> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'item-show-correct-response': ItemShowCorrectResponse;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\n\nimport type { ComputedContext } from '@qti-components/base';\n\n/**\n * @deprecated test-show-correct-response is deprecated and will be removed in the future.\n */\n\nexport class TestShowCorrectResponse extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: Boolean, reflect: true }) shown = false;\n @property({ type: Boolean, reflect: true }) disabled = false;\n @property({ type: String }) showCorrectText = 'Show correct response';\n @property({ type: String }) hideCorrectText = 'Hide correct response';\n @property({ type: String }) noCorrectResponseText = 'No correct response specified';\n\n #previousActiveItem?: unknown; // Store previous active item reference\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n // If active item changed, reset shown before the update\n if (this.#previousActiveItem !== activeItem) {\n this.shown = false;\n this.#previousActiveItem = activeItem; // Update previous active item\n }\n\n if (activeItem) {\n const containsCorrectResponse = !!activeItem?.variables?.some(v => (v as any)['correctResponse']);\n const containsMapping = !!activeItem?.variables?.some(v => {\n return (v as any)['mapping']?.mapEntries?.length > 0 || (v as any)['areaMapping']?.areaMapEntries?.length > 0;\n });\n this.disabled = !containsCorrectResponse && !containsMapping;\n } else {\n this.disabled = true;\n }\n }\n #toggleState() {\n if (this.disabled) return;\n this.shown = !this.shown;\n\n this.dispatchEvent(\n new CustomEvent('test-show-correct-response', {\n detail: this.shown,\n bubbles: true\n })\n );\n }\n\n #getDisplayedText(): string {\n return this.disabled ? this.noCorrectResponseText : this.shown ? this.hideCorrectText : this.showCorrectText;\n }\n\n override render() {\n return html` <div @click=\"${this.#toggleState}\">${this.#getDisplayedText()}</div> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-show-correct-response': TestShowCorrectResponse;\n }\n}\n","import { css } from 'lit';\n\n/**\n * The candidate-correction badge shared by correction-package elements.\n *\n * The component decides where the badge sits in the markup — last, after the label — and how big\n * its box is. It decides nothing about how it looks. The disc, the tick, the cross, and whether it\n * is lifted out of flow at all are the theme's, keyed on ::part(correction-correct) /\n * ::part(correction-incorrect).\n *\n * It replaces six implementations of one idea: four ::after glyph blocks in kennisnet, an\n * ::before/::after pair in order-interaction, and a .correct-option span that gap-match and match\n * built in JavaScript with inline styles. Several of those set margin-left and width inside a\n * :state(candidate-*) rule — a transient state doing layout, which is the bug this contract exists\n * to prevent.\n *\n * Reachable everywhere. A chip has three homes, and inside a drop target's shadow root the document\n * cannot see its badge: parts do not chain, so ::part(drag)::part(correction) is inert. A part\n * token survives exportparts, so one bare ::part(correction-correct) reaches the badge in the drag\n * bank, on the floating clone, and inside a gap. Verified in Chromium.\n *\n * Deliberately not anchored, and not absolutely positioned. Both were tried; both left\n * qti-choice-interaction unable to reach layout stability, and the VRT stability detector spent 20\n * seconds waiting before capturing a half-settled frame. A theme that wants a corner badge can\n * position ::part(correction-correct) itself — it is a part, that is the point.\n */\nexport const correctionPart = css`\n /* Nothing at all until the item judges this element. */\n [part~='correction'] {\n display: none;\n }\n\n [part~='correction-correct'],\n [part~='correction-incorrect'],\n [part~='correction-partially-correct'] {\n display: inline-flex;\n flex: 0 0 auto;\n\n /*\n * The badge aligns ITSELF, and that is the whole of the vertical story.\n *\n * It is a flex item with a definite height, so left alone its cross-axis position is decided by\n * whatever its host says — and the hosts disagree: qti-simple-associable-choice defaults to\n * align-items: normal, and qti-gap-text gates center behind :not([part~='drag']), so the\n * same chip centred its badge in the bank and top-aligned it once placed. align-self settles it\n * from the badge's side, in one line, without touching a single container.\n *\n * This replaces an align-items/justify-content: center pair that had never done anything: the\n * badge is empty — a mask painted over a background — so centring its CONTENTS centres nothing.\n */\n align-self: center;\n\n box-sizing: border-box;\n width: var(--qti-correction-size, 1em);\n height: var(--qti-correction-size, 1em);\n margin-left: var(--qti-glyph-gap, 0.5em);\n\n pointer-events: none;\n }\n`;\n","import { html } from 'lit';\n\nimport { QtiGapText } from '@qti-components/interactions-core/elements/qti-gap-text';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiGapTextCorrection extends ActiveElementCorrectionMixin(QtiGapText) {\n static override styles = [QtiGapText.styles, correctionPart];\n\n override render() {\n return html`<div part=\"control\"></div>\n <slot part=\"label\"></slot>\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>`;\n }\n}\n","type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport type CandidateCorrection = 'correct' | 'incorrect' | 'partially-correct' | null;\n\nexport interface ActiveElementCorrectionInterface {\n candidateCorrection: CandidateCorrection;\n readonly correctionPart: string;\n}\n\ntype ActiveElement = HTMLElement & {\n readonly internals: ElementInternals;\n requestUpdate(name?: PropertyKey, oldValue?: unknown): unknown;\n};\n\n/** Adds candidate-verdict state to a lean choice/chip element. */\nexport const ActiveElementCorrectionMixin = <T extends AbstractConstructor<ActiveElement>>(superClass: T) => {\n abstract class ActiveElementCorrectionMixinClass extends superClass {\n #candidateCorrection: CandidateCorrection = null;\n\n public get candidateCorrection(): CandidateCorrection {\n return this.#candidateCorrection;\n }\n\n public set candidateCorrection(value: CandidateCorrection) {\n if (this.#candidateCorrection === value) return;\n const previous = this.#candidateCorrection;\n this.#candidateCorrection = value;\n\n const states = this.internals.states;\n states.delete('candidate-correct');\n states.delete('candidate-incorrect');\n states.delete('candidate-partially-correct');\n if (value) states.add(`candidate-${value}`);\n this.requestUpdate('candidateCorrection', previous);\n }\n\n public get correctionPart(): string {\n return this.#candidateCorrection ? `correction correction-${this.#candidateCorrection}` : 'correction';\n }\n }\n\n return ActiveElementCorrectionMixinClass as unknown as AbstractConstructor<ActiveElementCorrectionInterface> & T;\n};\n","import { property } from 'lit/decorators.js';\n\nimport { QtiHotspotChoice } from '@qti-components/interactions-core/elements/qti-hotspot-choice';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\n\nexport class QtiHotspotChoiceCorrection extends ActiveElementCorrectionMixin(QtiHotspotChoice) {\n @property({ attribute: 'aria-ordercorrectvalue', type: Number, reflect: true })\n orderCorrect: number | null = null;\n}\n","import { html } from 'lit';\n\nimport { QtiHottext } from '@qti-components/interactions-core/elements/qti-hottext';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiHottextCorrection extends ActiveElementCorrectionMixin(QtiHottext) {\n static override styles = [QtiHottext.styles, correctionPart];\n\n override render() {\n return html`<div part=\"control\"><div part=\"control-mark\"></div></div>\n <slot part=\"label\"></slot>\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>`;\n }\n}\n","import { html } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport { QtiSimpleAssociableChoice } from '@qti-components/interactions-core/elements/qti-simple-associable-choice';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiSimpleAssociableChoiceCorrection extends ActiveElementCorrectionMixin(QtiSimpleAssociableChoice) {\n static override styles = [QtiSimpleAssociableChoice.styles, correctionPart];\n\n override render() {\n return html`\n <div part=\"control\"></div>\n <slot part=\"label\"></slot>\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>\n <div part=\"drop\">\n ${repeat(\n this.drags,\n node => node.getAttribute('identifier'),\n node => node\n )}\n </div>\n `;\n }\n}\n","import { html, nothing } from 'lit';\n\nimport { QtiSimpleChoice } from '@qti-components/interactions-core/elements/qti-simple-choice';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiSimpleChoiceCorrection extends ActiveElementCorrectionMixin(QtiSimpleChoice) {\n static override styles = [QtiSimpleChoice.styles, correctionPart];\n\n // Same template as QtiSimpleChoice plus the badge. No tabindex on the control: the choice takes\n // focus on its host, and a focusable control made every choice two Tab stops.\n override render() {\n return html`<div part=\"control\"><div part=\"control-mark\"></div></div>\n ${this.marker ? html`<div id=\"label\" part=\"marker\">${this.marker}</div>` : nothing}\n <slot part=\"label\"></slot>\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>`;\n }\n}\n","import { property, state } from 'lit/decorators.js';\n\nimport { watch } from '@qti-components/utilities';\nimport { responseAttributeConverter, type Interaction, type ResponseValue } from '@qti-components/base';\n\nimport type { CorrectionConfig } from '../context/correction-config';\n\ntype AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport enum Correctness {\n Correct = 'correct',\n PartiallyCorrect = 'partially-correct',\n Incorrect = 'incorrect'\n}\n\n/**\n * Adds correct-response and full-correct-response behaviour\n * on top of any `Interaction` subclass.\n *\n * Usage:\n * ```ts\n * export abstract class CorrectableInteraction extends CorrectResponseMixin(Interaction) {}\n * ```\n *\n * Interactions that genuinely have no correct-response concept\n * (extended-text, upload, media) should extend `Interaction` directly\n * and omit this mixin.\n */\nexport const CorrectResponseMixin = <T extends AbstractConstructor<Interaction>>(superClass: T) => {\n abstract class CorrectResponseMixinClass extends superClass {\n // ─── Correct-response attribute ──────────────────────────────────────────\n\n /**\n * The correct response for this interaction. Can be set as a comma-separated\n * string via attribute or as string/string[] via property.\n *\n * @example\n * ```html\n * <qti-choice-interaction correct-response=\"A,B\">\n * ```\n */\n @property({\n attribute: 'correct-response',\n reflect: true,\n converter: responseAttributeConverter({ emptyAs: null })\n })\n set correctResponseAttr(val: ResponseValue) {\n this._correctResponse = val;\n }\n\n get correctResponseAttr(): ResponseValue {\n return this._correctResponse;\n }\n\n // ─── Show-correct-response ────────────────────────────────────────────────\n\n @property({ type: Boolean, attribute: 'show-correct-response', reflect: true })\n showCorrectResponse = false;\n\n @watch('showCorrectResponse', { waitUntilFirstUpdate: true })\n protected _handleShowCorrectResponseChange = (_: boolean, show: boolean) => {\n this.toggleInternalCorrectResponse(show);\n };\n\n // ─── Show-full-correct-response ───────────────────────────────────────────\n\n @property({ type: Boolean, attribute: 'show-full-correct-response', reflect: true })\n showFullCorrectResponse = false;\n\n @watch('showFullCorrectResponse', { waitUntilFirstUpdate: true })\n protected _handleShowFullCorrectResponseChange = (_: boolean, show: boolean) => {\n this.toggleFullCorrectResponse(show);\n };\n\n // ─── Show-candidate-correction ────────────────────────────────────────────\n\n @property({ type: Boolean, attribute: 'show-candidate-correction', reflect: true })\n showCandidateCorrection = false;\n\n @watch('showCandidateCorrection', { waitUntilFirstUpdate: true })\n protected _handleShowCandidateCorrectionChange = (_: boolean, show: boolean) => {\n this.toggleCandidateCorrection(show);\n };\n\n // ─── isFullCorrectResponse ────────────────────────────────────────────────\n\n @state()\n protected _isFullCorrectResponse: boolean;\n\n get isFullCorrectResponse(): boolean {\n return this._isFullCorrectResponse;\n }\n\n protected override get registersWithItem(): boolean {\n return !this.isFullCorrectResponse && super.registersWithItem;\n }\n\n set isFullCorrectResponse(val: boolean) {\n this._isFullCorrectResponse = val;\n if (val) {\n // `inert` already makes the answer-key clone non-interactive. Do NOT also set `disabled`:\n // it would mark every choice `:state(disabled)`, which the theme dims (opacity), fading the\n // answer key that is meant to be crisp. inert is enough.\n this.setAttribute('inert', '');\n this.setAttribute('response-identifier', this.responseIdentifier + '_cr');\n // An answer key shows the answer, not the means of giving one, so every drag-drop\n // interaction hides its chip bank here. Each one does that in its own stylesheet, keyed on\n // this attribute — hiding removes a box from the flow, which makes it layout, and layout is\n // not the theme's to declare (CONTRACT.md §7).\n //\n // The class the theme used instead, `.full-correct-response`, is on the wrapper *around*\n // this element, so only a document selector could see it. This attribute is on the clone\n // itself, which is what a shadow root can reach.\n this.setAttribute('answer-key', '');\n }\n }\n\n // ─── correctResponse property ─────────────────────────────────────────────\n\n @state()\n protected _correctResponse: string | string[] | null = null;\n\n get correctResponse(): Readonly<string | string[] | null> {\n const responseVariable = this.responseVariable;\n if (responseVariable?.correctResponse) {\n return responseVariable.correctResponse;\n }\n return this._correctResponse;\n }\n\n set correctResponse(val: Readonly<string | string[] | null>) {\n const oldVal = this._correctResponse;\n this._correctResponse = val as string | string[] | null;\n if (val === null || val === undefined) {\n this.removeAttribute('correct-response');\n } else {\n this.setAttribute('correct-response', Array.isArray(val) ? val.join(',') : (val as string));\n }\n this.requestUpdate('_correctResponse', oldVal);\n }\n\n // ─── correctness getter ───────────────────────────────────────────────────\n\n get correctness(): Readonly<Correctness | null> {\n const correctResponse = this.correctResponse;\n if (!correctResponse) return null;\n\n const currentResponse = this.response;\n if (\n currentResponse === null ||\n currentResponse === undefined ||\n currentResponse === '' ||\n (Array.isArray(currentResponse) && currentResponse.length === 0)\n ) {\n return null;\n }\n\n const correctArr = Array.isArray(correctResponse) ? correctResponse : [correctResponse];\n const responseArr = Array.isArray(currentResponse) ? currentResponse : [currentResponse];\n const filteredResponseArr = responseArr.filter(r => r !== '');\n if (filteredResponseArr.length === 0) return null;\n\n const correctCount = filteredResponseArr.filter(r => correctArr.includes(r)).length;\n const incorrectCount = filteredResponseArr.filter(r => !correctArr.includes(r)).length;\n\n if (\n correctCount === correctArr.length &&\n incorrectCount === 0 &&\n filteredResponseArr.length === correctArr.length\n ) {\n return Correctness.Correct;\n }\n\n if (correctCount > 0 && (correctCount < correctArr.length || incorrectCount > 0)) {\n return Correctness.PartiallyCorrect;\n }\n\n return Correctness.Incorrect;\n }\n\n // ─── correctionPart ───────────────────────────────────────────────────────\n\n public get correctionPart(): string {\n return 'correction';\n }\n\n // ─── toggle methods ───────────────────────────────────────────────────────\n\n public toggleCorrectResponse(show: boolean): void {\n const correctionConfig = this.configContext as CorrectionConfig | undefined;\n const correctResponseMode = correctionConfig?.correctResponseMode || 'internal';\n\n if (correctResponseMode === 'full') {\n this.toggleFullCorrectResponse(show);\n } else {\n this.toggleInternalCorrectResponse(show);\n }\n }\n\n /**\n * Whether the full correct response is withheld from a candidate who is already correct.\n *\n * Withheld by default, unless the item configures `fullCorrectResponseOnlyWhenIncorrect: false`\n * — the behaviour `show-full-correct-response` has always had, on the reasoning that a correct\n * answer already *is* the key.\n *\n * An interaction that routes its internal mode here overrides this to false: there, the caller\n * asked to show the correct response, and silently showing nothing is worse than showing the\n * candidate the answer they already gave.\n */\n protected get withholdsFullCorrectResponseWhenCorrect(): boolean {\n return (this.configContext as CorrectionConfig | undefined)?.fullCorrectResponseOnlyWhenIncorrect !== false;\n }\n\n protected async toggleFullCorrectResponse(show: boolean): Promise<void> {\n const nextSibling = this.nextSibling;\n const nextSiblingIsFullCorrectResponse =\n nextSibling instanceof HTMLDivElement && nextSibling?.classList.contains('full-correct-response');\n\n const correctResponse = this.correctResponse;\n\n if (!correctResponse) {\n return;\n }\n\n const showFullCorrectResponse =\n show && (!this.withholdsFullCorrectResponseWhenCorrect || this.correctness !== Correctness.Correct);\n\n if (!showFullCorrectResponse) {\n if (!nextSiblingIsFullCorrectResponse) {\n return;\n }\n this.parentElement?.removeChild(nextSibling);\n return;\n }\n\n if (nextSiblingIsFullCorrectResponse) {\n return;\n }\n\n const clone = this.cloneNode(true) as Interaction & CorrectResponseMixinClass;\n\n clone.removeAttribute('show-full-correct-response');\n clone.removeAttribute('show-correct-response');\n clone.removeAttribute('show-candidate-correction');\n\n const containerDiv = document.createElement('div');\n containerDiv.classList.add('full-correct-response');\n if (this.isInline) {\n containerDiv.classList.add('full-correct-response-inline');\n } else {\n containerDiv.classList.add('full-correct-response-block');\n }\n containerDiv.role = 'full-correct-response';\n containerDiv.appendChild(clone);\n\n clone.isFullCorrectResponse = true;\n\n this.parentElement?.insertBefore(containerDiv, this.nextSibling);\n await clone.updateComplete;\n\n clone.response = Array.isArray(correctResponse)\n ? ([...correctResponse] as string[])\n : (correctResponse as string);\n }\n\n public toggleInternalCorrectResponse(show: boolean): void {\n this._internals.states.delete('show-correct-response');\n if (show && this.correctResponse) {\n this._internals.states.add('show-correct-response');\n }\n }\n\n public toggleCandidateCorrection(show: boolean): void {\n if (!show) {\n return;\n }\n }\n\n // ─── Lifecycle ────────────────────────────────────────────────────────────\n\n protected override firstUpdated(): void {\n super.firstUpdated();\n\n if (this.isFullCorrectResponse) {\n return;\n }\n\n if (this.showCorrectResponse) {\n this.toggleInternalCorrectResponse(true);\n }\n if (this.showFullCorrectResponse) {\n this.toggleFullCorrectResponse(true);\n }\n }\n }\n\n // Cast strips the anonymous class type so TypeScript can generate clean .d.ts\n // for any named class that extends this mixin (avoids TS4094).\n return CorrectResponseMixinClass as unknown as AbstractConstructor<CorrectResponseInterface> & T;\n};\n\n/** Public type surface exposed by `CorrectResponseMixin`. */\nexport interface CorrectResponseInterface {\n correctResponseAttr: ResponseValue;\n showCorrectResponse: boolean;\n showFullCorrectResponse: boolean;\n showCandidateCorrection: boolean;\n isFullCorrectResponse: boolean;\n correctResponse: Readonly<string | string[] | null>;\n readonly correctness: Readonly<Correctness | null>;\n readonly correctionPart: string;\n toggleCorrectResponse(show: boolean): void;\n toggleCandidateCorrection(show: boolean): void;\n /** Protected at runtime; exposed here so subclasses can call `super.toggleInternalCorrectResponse()`. */\n toggleInternalCorrectResponse(show: boolean): void;\n /** Protected at runtime. */\n toggleFullCorrectResponse(show: boolean): Promise<void>;\n /** Protected at runtime; declared here so a subclass can `override` it. */\n readonly withholdsFullCorrectResponseWhenCorrect: boolean;\n}\n","import { state } from 'lit/decorators.js';\n\nimport { CorrectResponseMixin, Correctness, type CorrectResponseInterface } from './correct-response.mixin';\n\nimport type { Interaction } from '@qti-components/base';\n\ntype AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport const CandidateCorrectionMixin = <T extends AbstractConstructor<Interaction>>(superClass: T) => {\n abstract class CandidateCorrectionMixinClass extends CorrectResponseMixin(superClass) {\n @state() private _candidateCorrection: 'correct' | 'incorrect' | 'partially-correct' | null = null;\n\n public override get correctionPart(): string {\n return this._candidateCorrection ? `correction correction-${this._candidateCorrection}` : 'correction';\n }\n\n public override toggleCandidateCorrection(show: boolean): void {\n if (this.showCandidateCorrection !== show) {\n this.showCandidateCorrection = show;\n }\n\n super.toggleCandidateCorrection(show);\n\n const internals = (this as unknown as { _internals: ElementInternals })._internals;\n\n internals.states.delete('candidate-correct');\n internals.states.delete('candidate-partially-correct');\n internals.states.delete('candidate-incorrect');\n\n let verdict: 'correct' | 'incorrect' | 'partially-correct' | null = null;\n\n if (show) {\n if (this.correctness === Correctness.Correct) {\n internals.states.add('candidate-correct');\n verdict = 'correct';\n }\n if (this.correctness === Correctness.PartiallyCorrect) {\n internals.states.add('candidate-partially-correct');\n verdict = 'partially-correct';\n }\n if (this.correctness === Correctness.Incorrect) {\n internals.states.add('candidate-incorrect');\n verdict = 'incorrect';\n }\n }\n\n if (this._candidateCorrection !== verdict) {\n this._candidateCorrection = verdict;\n }\n }\n\n override connectedCallback(): void {\n super.connectedCallback?.();\n\n queueMicrotask(() => {\n if (!this.isConnected || this.isFullCorrectResponse) {\n return;\n }\n if (this.showCandidateCorrection) {\n this.toggleCandidateCorrection(true);\n }\n });\n }\n }\n\n return CandidateCorrectionMixinClass as unknown as AbstractConstructor<CorrectResponseInterface> & T;\n};\n","import { CandidateCorrectionMixin } from './candidate-correction.mixin';\n\nimport type { Interaction } from '@qti-components/base';\nimport type { CorrectResponseInterface } from './correct-response.mixin';\n\ntype AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;\n\ntype DragDropInteraction = Interaction & {\n afterCache(): void;\n};\n\n/** Adds correction lifecycle behavior shared by drag-and-drop interactions. */\nexport const DragDropCorrectionMixin = <T extends AbstractConstructor<DragDropInteraction>>(superClass: T) => {\n abstract class DragDropCorrectionMixinClass extends CandidateCorrectionMixin(superClass) {\n public override toggleInternalCorrectResponse(show: boolean): void {\n if (!this.showFullCorrectResponse) {\n this.toggleFullCorrectResponse(show);\n }\n }\n\n public override afterCache(): void {\n super.afterCache();\n if (this.showCorrectResponse) this.toggleInternalCorrectResponse(true);\n if (this.showCandidateCorrection) this.toggleCandidateCorrection(true);\n if (this.showFullCorrectResponse) this.toggleFullCorrectResponse(true);\n }\n }\n\n return DragDropCorrectionMixinClass as unknown as AbstractConstructor<CorrectResponseInterface> & T;\n};\n","import { QtiAssociateInteraction } from '@qti-components/associate-interaction/elements';\n\nimport { DragDropCorrectionMixin } from '../mixins/drag-drop-correction.mixin';\n\nexport class QtiAssociateInteractionCorrection extends DragDropCorrectionMixin(QtiAssociateInteraction) {}\n","import { CandidateCorrectionMixin } from './candidate-correction.mixin';\n\nimport type { Interaction } from '@qti-components/base';\nimport type { CorrectResponseInterface } from './correct-response.mixin';\n\ntype AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;\n\ntype CorrectableChoice = HTMLElement & {\n identifier: string;\n internals: ElementInternals;\n candidateCorrection: 'correct' | 'incorrect' | 'partially-correct' | null;\n};\n\ntype ChoicesCorrectionBase = Interaction & {\n readonly response: string | string[] | null;\n readonly internals: ElementInternals;\n};\n\n/** Adds per-choice candidate marking to interactions built on `ChoicesMixin`. */\nexport const ChoiceCorrectionMixin = <T extends AbstractConstructor<ChoicesCorrectionBase>>(superClass: T) => {\n abstract class ChoiceCorrectionMixinClass extends CandidateCorrectionMixin(superClass) {\n declare protected _choiceElements: CorrectableChoice[];\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n\n const correctResponse = this.correctResponse;\n const correctResponses = correctResponse\n ? Array.isArray(correctResponse)\n ? correctResponse\n : [correctResponse]\n : [];\n\n for (const choice of this._choiceElements) {\n choice.internals.states.delete('correct-response');\n choice.internals.states.delete('incorrect-response');\n if (show && correctResponses.length > 0) {\n choice.internals.states.add(\n correctResponses.includes(choice.identifier) ? 'correct-response' : 'incorrect-response'\n );\n }\n }\n }\n\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n\n for (const choice of this._choiceElements) {\n choice.candidateCorrection = null;\n }\n\n if (!show || !this.correctResponse) {\n return;\n }\n\n const correctResponses = Array.isArray(this.correctResponse) ? this.correctResponse : [this.correctResponse];\n const candidateResponses = Array.isArray(this.response) ? this.response : this.response ? [this.response] : [];\n\n for (const choice of this._choiceElements) {\n if (!candidateResponses.includes(choice.identifier)) {\n continue;\n }\n choice.candidateCorrection = correctResponses.includes(choice.identifier) ? 'correct' : 'incorrect';\n }\n }\n }\n\n return ChoiceCorrectionMixinClass as unknown as AbstractConstructor<CorrectResponseInterface> & T;\n};\n","import { QtiChoiceInteraction } from '@qti-components/choice-interaction/elements';\n\nimport { ChoiceCorrectionMixin } from '../mixins/choice-correction.mixin';\n\n/**\n * Correction-capable `qti-choice-interaction` implementation.\n *\n * It is registered under the standard tag only inside a correction registry;\n * the standard package constructor remains correction-free.\n */\nexport class QtiChoiceInteractionCorrection extends ChoiceCorrectionMixin(QtiChoiceInteraction) {}\n","import { css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { QtiExtendedTextInteraction } from '@qti-components/extended-text-interaction/elements';\n\nimport { ActiveElementCorrectionMixin } from '../mixins/active-element-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nimport type { CandidateCorrection } from '../mixins/active-element-correction.mixin';\n\n/**\n * Extended-text, judged from OUTSIDE.\n *\n * Every other correction class in this folder derives its verdict: it is handed a `correct-response`\n * and compares. Extended-text cannot — the response is free prose, there is nothing to compare it\n * to, and that is exactly why the base component extends `Interaction` directly and carries no\n * correction machinery (correct-response.mixin.ts says so for extended-text, upload and media).\n *\n * But an extended-text answer is still judged; just not here. A teacher, a marking service, or an app\n * that already knows the score decides, and then has to tell the component. This class is that\n * channel and nothing more: it computes no correctness, it only accepts one.\n *\n * Hence `ActiveElementCorrectionMixin` rather than `CandidateCorrectionMixin`. The two are otherwise\n * the same bookkeeping — clear the three `candidate-*` states, add one, expose `correctionPart` — but\n * `CandidateCorrectionMixin` sits on top of `CorrectResponseMixin` and drives everything off a\n * computed `correctness` getter with no setter. `ActiveElementCorrectionMixin` is the settable one,\n * written for chips whose parent interaction pushes a verdict into them. An externally-graded essay\n * is the same shape: something else knows the answer.\n *\n * Two consequences worth knowing:\n *\n * - The `item-show-candidate-correction` button will not drive this. It disables itself unless a\n * response variable declares a correctResponse / mapping / areaMapping, which a prose item never\n * does. Correct: the verdict comes from the host application, which sets the attribute.\n * - The verdict survives typing. It is a property, not the `showCandidateCorrection` toggle, so\n * `afterResponseVariableUpdated()` does not clear it. If a stale grade should be dropped when the\n * candidate edits their answer, that is an explicit decision for the host app to make.\n */\nexport class QtiExtendedTextInteractionCorrection extends ActiveElementCorrectionMixin(QtiExtendedTextInteraction) {\n static override styles = [\n QtiExtendedTextInteraction.styles,\n correctionPart,\n css`\n /*\n * Placement only — the glyph itself is the theme's, keyed on ::part(correction-*). That split\n * is the contract in correction.styles.ts, which deliberately leaves the shared badge in flow\n * and invites a component to lift it out if it wants a corner badge.\n *\n * A textarea is a box the candidate writes in, so the badge goes in its top end corner (top\n * right in a left-to-right text) rather than trailing the text the way a chip's does, and the\n * theme reserves the gutter for it (the end padding on ::part(textarea)).\n *\n * Anchored to the TEXTAREA, not to the host. The badge's containing block is :host, and the\n * host also contains the prompt slot — so a plain top: 0.85rem measured from the host lands on\n * the prompt and the badge floats above the field, which is exactly what it did. Only the\n * vertical offset needs anchoring: the textarea spans the host's full width, so the left\n * offset is the same measured from either.\n */\n [part~='textarea'] {\n anchor-name: --qti-extended-text-field;\n }\n\n [part~='correction'] {\n position: absolute;\n position-anchor: --qti-extended-text-field;\n margin: 0;\n width: var(--qti-correction-size);\n\n /*\n * One FIELD line tall, not square — this is what puts the glyph on the text rather than near\n * it. The mask is drawn center / contain, so in a box exactly one line high it centres itself\n * on that line while the width still governs the glyph's size.\n *\n * Not 1lh: that unit resolves against the BADGE's own inherited line-height (measured 18.4px),\n * not the textarea's (24px), so it landed a third of a line low. --qti-field-line-height is\n * the same number @mixin field-typography gives the field, so the two cannot drift.\n */\n height: calc(var(--qti-correction-size) * var(--qti-field-line-height));\n\n /* In the gutter at the end of the line, inset exactly as the text is from the other side:\n the same trailing token the two field-shaped interactions use. The gutter was on the start\n side once, which left every answer indented by the badge's room even when ungraded. */\n inset-inline-end: var(--qti-correction-inset);\n\n /* Anchored to the field's first line: its top edge plus the field's own padding-top. */\n top: calc(anchor(top) + var(--qti-spacing));\n }\n\n /*\n * Fallback for engines without anchor positioning, where the top above does not parse and the\n * badge would fall to its static position below the field. The bottom of the gutter needs no\n * knowledge of where the field starts, and the gutter runs the full height, so the badge still\n * clears the text.\n *\n * Scoped by @supports rather than declared alongside. Both were set at first, on the assumption\n * that top + height over-constrains the box and bottom is ignored — it is not: measured, the\n * bottom won and put the badge on the third line.\n */\n @supports not (anchor-name: --probe) {\n [part~='correction'] {\n top: auto;\n bottom: var(--qti-correction-inset);\n }\n }\n `\n ];\n\n /**\n * The verdict, pushed in from outside: `correct`, `partially-correct`, `incorrect`, or absent.\n *\n * `noAccessor` because the mixin already owns the accessor — its setter is what writes the\n * `:state(candidate-*)` custom states — and Lit would otherwise replace it with a generated one and\n * silently drop that bookkeeping. Same pattern as the `response` attribute on\n * qti-inline-choice-interaction and qti-slider-interaction.\n */\n @property({ attribute: 'candidate-correction', reflect: true, noAccessor: true })\n declare candidateCorrection: CandidateCorrection;\n\n /** The badge goes between the field and the validation message; everything else is the base's. */\n override render() {\n return html`${this.renderPrompt()}${this.renderTextarea()}\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>\n ${this.renderValidationMessage()}`;\n }\n}\n","/** Helpers shared by more than one correction interaction. */\n\n/** A choice element that can carry a per-candidate correction verdict. */\nexport type CorrectableChoice = HTMLElement & {\n identifier: string;\n candidateCorrection: 'correct' | 'incorrect' | 'partially-correct' | null;\n};\n\n/** Splits a `\"source target\"` correct-response into its pairs. */\nexport const parsePairs = (response: Readonly<string | string[] | null>): Array<{ source: string; target: string }> => {\n if (!response) return [];\n const entries = Array.isArray(response) ? response : [response];\n return entries.map(entry => {\n const [source, target] = entry.split(' ');\n return { source, target };\n });\n};\n","import { QtiGapMatchInteraction } from '@qti-components/gap-match-interaction/elements';\n\nimport { DragDropCorrectionMixin } from '../mixins/drag-drop-correction.mixin';\nimport { parsePairs, type CorrectableChoice } from './shared';\n\nexport class QtiGapMatchInteractionCorrection extends DragDropCorrectionMixin(QtiGapMatchInteraction) {\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n const matches = parsePairs(this.correctResponse);\n\n for (const target of this.querySelectorAll('qti-gap')) {\n const targetId = target.getAttribute('identifier');\n const selectedChoices = (target as unknown as HTMLElement & { drags: readonly CorrectableChoice[] }).drags;\n for (const choice of selectedChoices) {\n choice.candidateCorrection = null;\n if (show && matches.some(match => match.source === choice.identifier && match.target === targetId)) {\n choice.candidateCorrection = 'correct';\n } else if (show) {\n choice.candidateCorrection = 'incorrect';\n }\n }\n }\n }\n}\n","import { svg } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport { QtiGraphicAssociateInteraction } from '@qti-components/graphic-associate-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\n\nexport class QtiGraphicAssociateInteractionCorrection extends CandidateCorrectionMixin(QtiGraphicAssociateInteraction) {\n #correctLines: string[] = [];\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n const response = this.correctResponse;\n const previous = this.#correctLines;\n this.#correctLines = show && response ? (Array.isArray(response) ? [...response] : [response]) : [];\n this.requestUpdate('correctLines', previous);\n }\n\n protected override renderSupplementalLines(): unknown {\n return repeat(\n this.#correctLines,\n line => line,\n line => svg`\n <line\n part=\"correct-line\"\n x1=${parseInt(this.querySelector<SVGLineElement>(`[identifier=${line.split(' ')[0]}]`)!.style.left)}\n y1=${parseInt(this.querySelector<SVGLineElement>(`[identifier=${line.split(' ')[0]}]`)!.style.top)}\n x2=${parseInt(this.querySelector<SVGLineElement>(`[identifier=${line.split(' ')[1]}]`)!.style.left)}\n y2=${parseInt(this.querySelector<SVGLineElement>(`[identifier=${line.split(' ')[1]}]`)!.style.top)}\n stroke=\"var(--qti-correct)\"\n stroke-width=\"3\"\n stroke-dasharray=\"5,5\"\n />\n `\n );\n }\n}\n","import { QtiGraphicGapMatchInteraction } from '@qti-components/graphic-gap-match-interaction/elements';\n\nimport { DragDropCorrectionMixin } from '../mixins/drag-drop-correction.mixin';\n\nexport class QtiGraphicGapMatchInteractionCorrection extends DragDropCorrectionMixin(QtiGraphicGapMatchInteraction) {}\n","import { QtiGraphicOrderInteraction } from '@qti-components/graphic-order-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\n\nimport type { Choice } from '@qti-components/interactions-core/mixins/choices/choices.mixin';\n\ntype OrderedHotspot = Choice & { order: number | null };\n\ntype CorrectableOrderedHotspot = OrderedHotspot & {\n candidateCorrection: 'correct' | 'incorrect' | 'partially-correct' | null;\n orderCorrect: number | null;\n};\n\nexport class QtiGraphicOrderInteractionCorrection extends CandidateCorrectionMixin(QtiGraphicOrderInteraction) {\n protected override resolvePinColor(choice: OrderedHotspot): string {\n const correctableChoice = choice as CorrectableOrderedHotspot;\n if (correctableChoice.matches(':state(candidate-incorrect)')) return 'var(--qti-incorrect)';\n if (correctableChoice.matches(':state(candidate-correct)')) return 'var(--qti-correct)';\n if (correctableChoice.matches(':state(correct-response)')) return 'var(--qti-answer-border)';\n return super.resolvePinColor(choice);\n }\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n const response = this.correctResponse;\n const correctOrder = response ? (Array.isArray(response) ? response : [response]) : [];\n for (const hotspot of this._choiceElements as CorrectableOrderedHotspot[]) {\n const index = correctOrder.indexOf(hotspot.identifier);\n hotspot.orderCorrect = show && index >= 0 ? index + 1 : null;\n }\n this.refreshLocatorPins();\n }\n\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n const response = this.correctResponse;\n const correctOrder = response ? (Array.isArray(response) ? response : [response]) : [];\n for (const hotspot of this._choiceElements as CorrectableOrderedHotspot[]) {\n hotspot.candidateCorrection = null;\n if (show && hotspot.order != null) {\n hotspot.candidateCorrection = correctOrder[hotspot.order - 1] === hotspot.identifier ? 'correct' : 'incorrect';\n }\n }\n this.refreshLocatorPins();\n }\n}\n","import { QtiHotspotInteraction } from '@qti-components/hotspot-interaction/elements';\n\nimport { ChoiceCorrectionMixin } from '../mixins/choice-correction.mixin';\n\nexport class QtiHotspotInteractionCorrection extends ChoiceCorrectionMixin(QtiHotspotInteraction) {}\n","import { QtiHottextInteraction } from '@qti-components/hottext-interaction/elements';\n\nimport { ChoiceCorrectionMixin } from '../mixins/choice-correction.mixin';\n\nexport class QtiHottextInteractionCorrection extends ChoiceCorrectionMixin(QtiHottextInteraction) {}\n","import { css, html } from 'lit';\n\nimport { QtiInlineChoiceInteraction } from '@qti-components/inline-choice-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiInlineChoiceInteractionCorrection extends CandidateCorrectionMixin(QtiInlineChoiceInteraction) {\n static override get styles() {\n return [\n QtiInlineChoiceInteraction.styles,\n correctionPart,\n css`\n /*\n * Only the TRAILING inset — the leading gap is the shared --qti-glyph-gap, like every other\n * badge. This used to set both margins to --qti-gap (1rem), twice everyone else's 0.5em, on\n * the one token qti-variables.css calls \"the page's rhythm … an order of magnitude too wide\n * for a glyph sitting inside a line\".\n *\n * The trailing inset is needed here, and in text-entry, because these two put the field's box\n * on the HOST while its padding sits on an inner element (::part(trigger), ::part(input)) —\n * so a badge that is a child of the host falls outside that padding and lands on the border.\n * Chips, choices and hottext carry their padding on the host, so their badge is already inset\n * by it and needs nothing.\n */\n [part~='correction'] {\n margin-inline-end: var(--qti-correction-inset);\n }\n `\n ];\n }\n\n /**\n * Internal mode defers to the full correct response, exactly as text-entry does.\n *\n * There is no room beside a dropdown for an answer key: the interaction sits inside a line of\n * running text, so a marker next to the field competes with the sentence around it, and when the\n * candidate happened to pick the correct option it printed the same word twice. The full variant\n * puts the key in a `div.full-correct-response-inline` after the field instead — one already-themed\n * presentation for both inline interactions rather than a second one only these two use.\n *\n * `super` is deliberately not called: its `show-correct-response` host state paints the dashed\n * outline in qti-states.css, and this element is no longer the thing presenting the key — the\n * wrapper beside it is. Leaving the state off keeps internal mode looking identical to an item\n * authored with `show-full-correct-response`.\n *\n * The guard stops the two entry points rendering two wrappers: `showFullCorrectResponse` has its\n * own watcher, so with both flags set this would otherwise run a second time.\n */\n public override toggleInternalCorrectResponse(show: boolean): void {\n if (!this.showFullCorrectResponse) this.toggleFullCorrectResponse(show);\n }\n\n /**\n * The key is shown whether or not the candidate was right.\n *\n * The base withholds it from a correct candidate, on the reasoning that their answer already is\n * the key. That reasoning does not survive contact with this element: asking for the correct\n * response and being shown nothing is indistinguishable from the feature being broken, and it is\n * the only inline interaction where the answer and the key are the same short phrase, so there is\n * no visual clue either. Show it, and let the correctness badge say who was right.\n */\n public override get withholdsFullCorrectResponseWhenCorrect(): boolean {\n return false;\n }\n\n /** The badge trails the validation message; everything else is the base's. */\n override render() {\n return html`\n ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()}\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>\n `;\n }\n}\n","import { QtiMatchInteraction } from '@qti-components/match-interaction/elements';\n\nimport { DragDropCorrectionMixin } from '../mixins/drag-drop-correction.mixin';\nimport { parsePairs, type CorrectableChoice } from './shared';\n\nexport class QtiMatchInteractionCorrection extends DragDropCorrectionMixin(QtiMatchInteraction) {\n #correctPairs = new Set<string>();\n\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n const matches = parsePairs(this.correctResponse);\n this.#correctPairs = show ? new Set(matches.map(match => `${match.source} ${match.target}`)) : new Set();\n\n for (const target of this.targetChoices) {\n const targetId = target.getAttribute('identifier');\n const selectedChoices = (target as unknown as { drags: readonly CorrectableChoice[] }).drags;\n for (const choice of selectedChoices) {\n choice.candidateCorrection = null;\n if (show) {\n choice.candidateCorrection = this.#correctPairs.has(`${choice.identifier} ${targetId}`)\n ? 'correct'\n : 'incorrect';\n }\n }\n }\n this.requestUpdate();\n }\n\n protected override getCellStateVariant(value: string, checked: boolean): string {\n if (!this.showCandidateCorrection || !checked) return '';\n return this.#correctPairs.has(value) ? 'correct' : 'incorrect';\n }\n}\n","/**\n * Numeric core: indices of the chosen longest increasing subsequence within a\n * sequence of distinct numbers.\n *\n * Tiebreaker: strict `>` comparisons keep the smallest predecessor index when\n * lengths tie, and the smallest ending index is picked when multiple indices\n * achieve the maximum length. This is equivalent to \"the first LIS found when\n * iterating left-to-right\".\n */\nexport function findLongestIncreasingSubsequenceIndices(sequence: number[]): Set<number> {\n if (sequence.length === 0) {\n return new Set();\n }\n\n const lengthEndingAt: number[] = new Array(sequence.length).fill(1);\n const predecessorIndex: number[] = new Array(sequence.length).fill(-1);\n\n for (let currentIndex = 0; currentIndex < sequence.length; currentIndex++) {\n for (let previousIndex = 0; previousIndex < currentIndex; previousIndex++) {\n if (\n sequence[previousIndex] < sequence[currentIndex] &&\n lengthEndingAt[previousIndex] + 1 > lengthEndingAt[currentIndex]\n ) {\n lengthEndingAt[currentIndex] = lengthEndingAt[previousIndex] + 1;\n predecessorIndex[currentIndex] = previousIndex;\n }\n }\n }\n\n let bestEndIndex = 0;\n for (let index = 1; index < sequence.length; index++) {\n if (lengthEndingAt[index] > lengthEndingAt[bestEndIndex]) {\n bestEndIndex = index;\n }\n }\n\n const resultIndices = new Set<number>();\n for (let index = bestEndIndex; index !== -1; index = predecessorIndex[index]) {\n resultIndices.add(index);\n }\n\n return resultIndices;\n}\n\n/**\n * Domain wrapper: identifiers of candidate-placed choices counted as\n * correctly placed, i.e. the longest run of choices whose relative order\n * matches the correct order.\n *\n * Assumes identifiers are unique within both arrays (guaranteed by QTI).\n * Identifiers not present in `correctOrder` are foreign to the response and\n * are never included in the result.\n */\nexport function findCorrectlyPlacedIdentifiers(candidateOrder: string[], correctOrder: string[]): Set<string> {\n const rankByIdentifier = new Map<string, number>(correctOrder.map((identifier, position) => [identifier, position]));\n\n const knownIdentifiers = candidateOrder.filter(identifier => rankByIdentifier.has(identifier));\n const rankSequence = knownIdentifiers.map(identifier => rankByIdentifier.get(identifier));\n\n const winningIndices = findLongestIncreasingSubsequenceIndices(rankSequence);\n\n const result = new Set<string>();\n winningIndices.forEach(index => result.add(knownIdentifiers[index]));\n return result;\n}\n","import { QtiOrderInteraction } from '@qti-components/order-interaction/elements';\n\nimport { DragDropCorrectionMixin } from '../mixins/drag-drop-correction.mixin';\nimport { findCorrectlyPlacedIdentifiers } from '../utils/longest-increasing-subsequence';\nimport { type CorrectableChoice } from './shared';\n\nexport class QtiOrderInteractionCorrection extends DragDropCorrectionMixin(QtiOrderInteraction) {\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n\n const dropTargets = Array.from(this.shadowRoot!.querySelectorAll<HTMLElement>(`[part~='drop']`));\n const placedChoices = dropTargets.flatMap(drop => this.chipsIn(drop) as CorrectableChoice[]);\n for (const choice of placedChoices) choice.candidateCorrection = null;\n if (!show) return;\n\n const response = this.correctResponse;\n const entries = response ? (Array.isArray(response) ? response : [response]) : [];\n const correctOrder = entries\n .map((entry, index) => {\n const [identifier, dropId] = entry.split(' ');\n const parsed = dropId?.startsWith('droplist') ? parseInt(dropId.slice('droplist'.length), 10) : index;\n return { identifier, dropIndex: Number.isNaN(parsed) ? index : parsed };\n })\n .filter(entry => entry.identifier)\n .sort((a, b) => a.dropIndex - b.dropIndex)\n .map(entry => entry.identifier);\n if (correctOrder.length === 0) return;\n\n const placedEntries = placedChoices\n .map(choice => ({ choice, identifier: choice.getAttribute('identifier') }))\n .filter((entry): entry is { choice: CorrectableChoice; identifier: string } => Boolean(entry.identifier));\n const correctlyPlaced = findCorrectlyPlacedIdentifiers(\n placedEntries.map(entry => entry.identifier),\n correctOrder\n );\n for (const { choice, identifier } of placedEntries) {\n choice.candidateCorrection = correctlyPlaced.has(identifier) ? 'correct' : 'incorrect';\n }\n }\n}\n","import { QtiPortableCustomInteraction } from '@qti-components/portable-custom-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\n\nimport type { BaseType, Cardinality } from '@qti-components/base';\n\nexport class QtiPortableCustomInteractionCorrection extends CandidateCorrectionMixin(QtiPortableCustomInteraction) {\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n const responseVariable = this.responseVariable;\n const sourceResponse = responseVariable?.correctResponse ?? this.correctResponse;\n this.correctResponse = show ? sourceResponse : responseVariable?.cardinality === 'single' ? '' : [];\n\n const containerId = `correct-response-container-${this.responseIdentifier}`;\n this.parentElement?.querySelectorAll(`#${containerId}`).forEach(element => element.remove());\n\n if (!show) {\n this.enable();\n return;\n }\n this.disable();\n if (!this.correctResponse) return;\n\n const container = document.createElement('div');\n container.id = containerId;\n container.className = 'pci-correct-response-container';\n Object.assign(container.style, {\n position: 'relative',\n marginTop: '20px',\n border: '2px solid green',\n padding: '16px',\n borderRadius: '4px',\n backgroundColor: 'rgba(0, 128, 0, 0.05)'\n });\n\n const label = document.createElement('div');\n label.textContent = 'Correct Response:';\n Object.assign(label.style, { fontWeight: 'bold', marginBottom: '10px', color: 'green' });\n container.append(label);\n\n // `cloneNode(false)`, not `document.createElement`: a shallow clone is created in the same\n // custom element registry as this element, so the viewer is still upgraded when the item was\n // rendered into a scoped registry. It carries the attributes over and none of the children.\n const viewer = this.cloneNode(false) as QtiPortableCustomInteractionCorrection;\n // Two elements in one tree cannot share an id, and the flags would have the viewer show a\n // correction of its own.\n viewer.removeAttribute('id');\n viewer.removeAttribute('show-correct-response');\n viewer.removeAttribute('show-full-correct-response');\n viewer.removeAttribute('show-candidate-correction');\n viewer.isFullCorrectResponse = true;\n const originalResponseId = this.responseIdentifier;\n viewer.responseIdentifier = `${originalResponseId}-correct`;\n\n // Only the authored light DOM — modules, markup, properties, stylesheets. The runtime's own\n // children must not come along: the PCI appends its iframe to itself, and the `disable()` above\n // has just added the review overlay. A cloned iframe never loads, so the viewer would paint a\n // dead frame above the live one.\n for (const child of Array.from(this.children)) {\n if (child.tagName.startsWith('QTI-')) viewer.append(child.cloneNode(true));\n }\n\n const correctResponse = this.correctResponse as string | string[];\n const cardinality: Cardinality =\n responseVariable?.cardinality ?? (Array.isArray(correctResponse) ? 'multiple' : 'single');\n const baseType: BaseType = responseVariable?.baseType ?? 'string';\n\n // The standards-conformant handoff, for a PCI that implements the solution use case: it reads\n // the key out of its own `getInstance` configuration rather than having a response pushed at it.\n // Set explicitly because the viewer has no response declaration to derive one from — it is not a\n // registered interaction, so `responseVariable` is undefined and the derived getter returns null.\n // See https://github.com/1EdTech/qti-project-management/issues/210\n viewer.status = 'solution';\n viewer.responseDeclaration = {\n baseType,\n cardinality,\n correctResponse: { value: correctResponse }\n };\n\n // The push below stays for PCIs that do NOT implement the solution use case: those only know how\n // to render a response bound to them. It goes out once the viewer's own iframe has finished its\n // handshake — listened for rather than hooked into `connectedCallback`, since custom element\n // reactions are looked up on the prototype when the element is defined, so an instance-level\n // override of it is never read.\n viewer.addEventListener(\n 'qti-portable-custom-interaction-loaded',\n () => {\n const value = viewer.responseVariablesToQtiVariableJSON(correctResponse, cardinality, baseType);\n viewer.sendMessageToIframe('setBoundTo', { [originalResponseId]: value });\n viewer.sendMessageToIframe('setState', { state: 'review' });\n },\n { once: true }\n );\n viewer.style.pointerEvents = 'none';\n container.append(viewer);\n this.after(container);\n }\n}\n","import { css, html } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nimport { ScoringHelper } from '@qti-components/base';\nimport { QtiSelectPointInteraction } from '@qti-components/select-point-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\n\nimport type { QtiAreaMapEntry } from '@qti-components/base';\n\nexport class QtiSelectPointInteractionCorrection extends CandidateCorrectionMixin(QtiSelectPointInteraction) {\n #correctAreas: Array<{ shape: string; coords: string }> = [];\n\n #responseCorrection: boolean[] = [];\n\n static override styles = [\n QtiSelectPointInteraction.styles,\n css`\n [part~='correct'] {\n --qti-select-point-marker-color: var(--qti-correct);\n }\n [part~='incorrect'] {\n --qti-select-point-marker-color: var(--qti-incorrect);\n }\n `\n ];\n\n public override toggleCandidateCorrection(show: boolean): void {\n super.toggleCandidateCorrection(show);\n const previous = this.#responseCorrection;\n this.#responseCorrection = [];\n if (!show) {\n this.requestUpdate('responseCorrection', previous);\n return;\n }\n\n const areaEntries = this._effectiveAreaEntries;\n const baseType = this.responseVariable?.baseType;\n const response = this.correctResponse;\n for (const point of this.responsePoints) {\n let correct = areaEntries.some(area =>\n ScoringHelper.isPointInArea(`${point.x} ${point.y}`, `${area.shape},${area.coords}`, baseType)\n );\n if (!areaEntries.length && response) {\n const expected = Array.isArray(response) ? response : [response];\n correct = expected.some(entry => {\n const [x, y] = entry.split(' ').map(Number);\n return Number.isFinite(x) && Number.isFinite(y) && Math.hypot(point.x - x, point.y - y) <= 10;\n });\n }\n this.#responseCorrection.push(correct);\n }\n this.requestUpdate('responseCorrection', previous);\n }\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n if (!show) {\n const previous = this.#correctAreas;\n this.#correctAreas = [];\n this.requestUpdate('correctAreas', previous);\n return;\n }\n\n let entries: QtiAreaMapEntry[] = this._effectiveAreaEntries;\n if (!entries.length) {\n const response = this.correctResponse;\n const values = response ? (Array.isArray(response) ? response : [response]) : [];\n if (values.some(value => value.split(' ').length < 2)) {\n console.error('No valid correct responses found.');\n return;\n }\n entries = values.map(value => ({\n shape: 'circle',\n coords: `${value.split(' ').join(',')},10`,\n defaultValue: 1,\n mappedValue: 1\n }));\n }\n const previous = this.#correctAreas;\n this.#correctAreas = entries.map(entry => ({ shape: entry.shape, coords: entry.coords }));\n this.requestUpdate('correctAreas', previous);\n }\n\n protected override pointPart(_point: string, index: number): string {\n const verdict = this.#responseCorrection[index];\n return verdict === undefined ? 'point' : `point ${verdict ? 'correct' : 'incorrect'}`;\n }\n\n protected override renderSupplementalLayer(): unknown {\n return repeat(\n this.#correctAreas,\n area => `${area.shape}:${area.coords}`,\n (area, index) =>\n html`<div\n style=${styleMap({\n position: 'absolute',\n pointerEvents: 'none',\n backgroundColor: 'var(--qti-correct)',\n opacity: '0.5'\n })}\n data-correction-area\n data-coord=${area.coords}\n data-shape=${area.shape}\n alt=${`correct-response-${index + 1}`}\n ></div>`\n );\n }\n\n protected override updated(changedProperties: Map<string | number | symbol, unknown>): void {\n super.updated(changedProperties);\n if (changedProperties.has('correctAreas' as never)) {\n this.positionOverlayElements(this.shadowRoot!.querySelectorAll<HTMLElement>('[data-correction-area]'));\n }\n }\n}\n","import { css, html, nothing } from 'lit';\n\nimport { QtiSliderInteraction } from '@qti-components/slider-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\n\nexport class QtiSliderInteractionCorrection extends CandidateCorrectionMixin(QtiSliderInteraction) {\n #correctResponseNumber: number | null = null;\n\n static override styles = [\n QtiSliderInteraction.styles,\n css`\n [part='knob-correct'] {\n background-color: var(--qti-correct-light);\n border: 2px solid var(--qti-correct);\n position: relative;\n height: 1rem;\n width: 1rem;\n transform-origin: center;\n transform: translateX(-50%);\n cursor: pointer;\n border-radius: 9999px;\n left: var(--value-percentage-correct);\n }\n `\n ];\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n super.toggleInternalCorrectResponse(show);\n const response = this.correctResponse;\n const raw = Array.isArray(response) ? response[0] : response;\n const value = show && raw ? parseFloat(raw) : NaN;\n const previous = this.#correctResponseNumber;\n this.#correctResponseNumber = Number.isFinite(value) ? value : null;\n if (this.#correctResponseNumber !== null) {\n const percentage = ((this.#correctResponseNumber - this.min) / (this.max - this.min)) * 100;\n this.style.setProperty('--value-percentage-correct', `${percentage}%`);\n } else {\n this.style.removeProperty('--value-percentage-correct');\n }\n this.requestUpdate('correctResponseNumber', previous);\n }\n\n protected override renderRailSupplement(): unknown {\n return this.#correctResponseNumber === null\n ? nothing\n : html`<div id=\"knob-correct\" part=\"knob-correct\">\n <div id=\"value\" part=\"value\">${this.#correctResponseNumber}</div>\n </div>`;\n }\n}\n","import { css, html } from 'lit';\n\nimport { QtiTextEntryInteraction } from '@qti-components/text-entry-interaction/elements';\n\nimport { CandidateCorrectionMixin } from '../mixins/candidate-correction.mixin';\nimport { Correctness } from '../mixins/correct-response.mixin';\nimport { correctionPart } from '../styles/correction.styles';\n\nexport class QtiTextEntryInteractionCorrection extends CandidateCorrectionMixin(QtiTextEntryInteraction) {\n static override styles = [\n QtiTextEntryInteraction.styles,\n correctionPart,\n css`\n /*\n * The trailing inset only — size and leading gap come from the shared sheet.\n *\n * This block used to also set position: static; translate: none (dead: nothing positions this\n * badge) and size it with --qti-control-size, the radio/checkbox token — 1rem, absolute, where\n * every other badge is 1em and scales with the text it annotates. The two agreed only while the\n * item's font-size happened to equal the root's.\n *\n * The inset is needed because the field's box is the HOST while its padding is on ::part(input),\n * so the badge — a child of the host — falls outside that padding and lands flush on the border.\n * Measured at 0px from the border, against 16px for a choice and 12.8px for a chip.\n */\n [part~='correction'] {\n margin-inline-end: var(--qti-correction-inset);\n }\n :host {\n position: relative;\n anchor-name: --text-entry-host, --qti-correction-anchor;\n }\n [part='correct'] {\n position: absolute;\n position-anchor: --text-entry-host;\n position-area: top span-right;\n margin-bottom: 0.25rem;\n padding: var(--qti-padding-box);\n background-color: var(--qti-bg);\n white-space: nowrap;\n }\n `\n ];\n\n public override get correctness(): Readonly<Correctness | null> {\n const variable = this.responseVariable;\n if (!variable) return super.correctness;\n if (variable.value === null) return Correctness.Incorrect;\n\n if (variable.mapping) {\n const maxScore = variable.mapping.mapEntries.reduce((maximum, entry) => Math.max(entry.mappedValue, maximum), 0);\n for (const entry of variable.mapping.mapEntries) {\n let expected = entry.mapKey;\n let actual = variable.value as string;\n if (!entry.caseSensitive) {\n expected = expected.toLowerCase();\n actual = actual.toLowerCase();\n }\n if (expected !== actual) continue;\n if (entry.mappedValue === maxScore) return Correctness.Correct;\n if (entry.mappedValue <= (variable.mapping.defaultValue || 0)) return Correctness.Incorrect;\n return Correctness.PartiallyCorrect;\n }\n }\n\n return variable.correctResponse === variable.value ? Correctness.Correct : Correctness.Incorrect;\n }\n\n public override toggleInternalCorrectResponse(show: boolean): void {\n if (!this.showFullCorrectResponse) this.toggleFullCorrectResponse(show);\n }\n\n /** The badge goes between the field and the validation message; everything else is the base's. */\n override render() {\n return html`\n ${this.renderAnswer()} ${this.renderInput()}\n <span part=${this.correctionPart} aria-hidden=\"true\"></span>\n ${this.renderValidationMessage()}\n `;\n }\n}\n","import { QtiAssessmentItem } from '@qti-components/elements/elements';\n\ntype CorrectionInteraction = {\n toggleCorrectResponse(show: boolean): void;\n toggleCandidateCorrection(show: boolean): void;\n};\n\n/** Assessment-item extension that coordinates correction-capable interactions. */\nexport class QtiAssessmentItemCorrection extends QtiAssessmentItem {\n public showCorrectResponse(show: boolean): void {\n for (const interaction of this.interactionElements) {\n (interaction as unknown as Partial<CorrectionInteraction>).toggleCorrectResponse?.(show);\n }\n\n this.updateControlState('item-show-correct-response', show);\n }\n\n public showCandidateCorrection(show: boolean): void {\n for (const interaction of this.interactionElements) {\n (interaction as unknown as Partial<CorrectionInteraction>).toggleCandidateCorrection?.(show);\n }\n\n this.updateControlState('item-show-candidate-correction', show);\n }\n\n protected override afterResponseVariableUpdated(): void {\n this.showCandidateCorrection(false);\n }\n\n private updateControlState(selector: string, shown: boolean): void {\n let root = this.getRootNode();\n while (true) {\n (root as ParentNode)\n .querySelectorAll<HTMLElement & { shown: boolean }>(selector)\n .forEach(control => (control.shown = shown));\n\n if (!(root instanceof ShadowRoot)) return;\n root = root.host.getRootNode();\n }\n }\n}\n","import { QtiItem } from '@qti-components/item/elements';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { View } from '@qti-components/base';\nimport type { CorrectResponseMode } from '../context/correction-config';\n\ntype CorrectionAssessmentItem = {\n showCorrectResponse(show: boolean): void;\n showCandidateCorrection(show: boolean): void;\n};\n\n/** Item host extension that handles correction controls and mode changes. */\nexport class QtiItemCorrection extends QtiItem {\n readonly #onShowCorrectResponse = (event: Event) => {\n const show = (event as CustomEvent<boolean>).detail;\n (this.assessmentItem as unknown as Partial<CorrectionAssessmentItem>)?.showCorrectResponse?.(show);\n this.updateControlState('item-show-correct-response', show);\n };\n\n readonly #onShowCandidateCorrection = (event: Event) => {\n const show = (event as CustomEvent<boolean>).detail;\n (this.assessmentItem as unknown as Partial<CorrectionAssessmentItem>)?.showCandidateCorrection?.(show);\n this.updateControlState('item-show-candidate-correction', show);\n };\n\n readonly #onSwitchCorrectResponseMode = (event: Event) => {\n (this.assessmentItem as unknown as Partial<CorrectionAssessmentItem>)?.showCorrectResponse?.(false);\n this.configContext = {\n ...this.configContext,\n correctResponseMode: (event as CustomEvent<CorrectResponseMode>).detail\n } as typeof this.configContext;\n };\n\n /**\n * Scorer view IS the answer key, the same pairing `QtiTestCorrection` makes at test level.\n * A marker switching to `scorer` to read the rubric would otherwise have to ask for the key\n * separately, and the two would drift apart.\n *\n * `scorer` alone because that is what the test side does — not because no other audience has\n * a use for a key. An author reviewing their own item plainly wants one, and arguably a tutor\n * does too. If that is ever granted it has to be granted in both places at once, or the same\n * item answers differently depending on whether it is delivered inside a test.\n */\n override updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void {\n (assessmentItem as unknown as Partial<CorrectionAssessmentItem>)?.showCorrectResponse?.(view === 'scorer');\n this.updateControlState('item-show-correct-response', view === 'scorer');\n }\n\n constructor() {\n super();\n this.addEventListener('item-show-correct-response', this.#onShowCorrectResponse);\n this.addEventListener('item-show-candidate-correction', this.#onShowCandidateCorrection);\n this.addEventListener('item-switch-correct-response-mode', this.#onSwitchCorrectResponseMode);\n }\n\n private updateControlState(selector: string, shown: boolean): void {\n this.querySelectorAll<HTMLElement & { shown: boolean }>(selector).forEach(control => (control.shown = shown));\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('item-show-correct-response', this.#onShowCorrectResponse);\n this.removeEventListener('item-show-candidate-correction', this.#onShowCandidateCorrection);\n this.removeEventListener('item-switch-correct-response-mode', this.#onSwitchCorrectResponseMode);\n super.disconnectedCallback();\n }\n}\n","import { QtiTest, TestCheckItem, TestNavigation } from '@qti-components/test/elements';\n\nimport type { ComputedItem, View } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\n\ntype CorrectionAssessmentItem = QtiAssessmentItem & {\n showCorrectResponse(show: boolean): void;\n showCandidateCorrection(show: boolean): void;\n};\n\n/** Test navigation extension that routes correction controls to the active item. */\nexport class TestNavigationCorrection extends TestNavigation {\n readonly #onShowCorrectResponse = (event: Event) => {\n (this.activeAssessmentItem as Partial<CorrectionAssessmentItem> | undefined)?.showCorrectResponse?.(\n (event as CustomEvent<boolean>).detail\n );\n };\n\n readonly #onShowCandidateCorrection = (event: Event) => {\n (this.activeAssessmentItem as Partial<CorrectionAssessmentItem> | undefined)?.showCandidateCorrection?.(\n (event as CustomEvent<boolean>).detail\n );\n };\n\n constructor() {\n super();\n this.addEventListener('test-show-correct-response', this.#onShowCorrectResponse);\n this.addEventListener('test-show-candidate-correction', this.#onShowCandidateCorrection);\n }\n\n override disconnectedCallback(): void {\n this.removeEventListener('test-show-correct-response', this.#onShowCorrectResponse);\n this.removeEventListener('test-show-candidate-correction', this.#onShowCandidateCorrection);\n super.disconnectedCallback();\n }\n\n /**\n * Reflect correctness back to the candidate after an ended attempt, for items\n * the assessment opted in via the standard `qti-item-session-control\n * show-solution` (QTI 3.0 ItemSessionControl.show-solution) — the player takes\n * no opinion of its own:\n * - candidate correction (a mark on the learner's selection) after every attempt;\n * - the correct response (a mark on the right answer) once the item is done —\n * the candidate reached the optimal outcome, or ran out of attempts.\n */\n protected override afterAttemptEnded(\n assessmentItem: QtiAssessmentItem | undefined,\n computedItem: ComputedItem | undefined,\n done: boolean\n ): void {\n if (!assessmentItem || !computedItem?.showSolution) return;\n\n const correctable = assessmentItem as Partial<CorrectionAssessmentItem>;\n correctable.showCandidateCorrection?.(true);\n correctable.showCorrectResponse?.(done);\n }\n}\n\n/** Test host extension that shows correct responses in scorer view. */\nexport class QtiTestCorrection extends QtiTest {\n public override updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void {\n (assessmentItem as Partial<CorrectionAssessmentItem>).showCorrectResponse?.(view === 'scorer');\n }\n}\n\n/** Check-item extension that reveals the correct response after scoring. */\nexport class TestCheckItemCorrection extends TestCheckItem {\n constructor() {\n super();\n this.addEventListener('click', () => {\n this.dispatchEvent(new CustomEvent('test-show-correct-response', { detail: true, bubbles: true }));\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,MAAM,kBAAkB;AACjC,SAAS,UAAU,aAAa;AAChC,SAAS,eAAe;;;;;;;AAOlB,IAAO,0BAAP,cAAuC,WAAU;EAAvD,cAAA;;AAKE,SAAA,QAAQ;AAGA,SAAA,WAAW;MACjB,UAAU;MACV,MAAM;;EAgCV;EA7BE,YAAY,MAAyB;AACnC,SAAK,cACH,IAAI,YAAY,qCAAqC;MACnD,QAAQ;MACR,SAAS;KACV,CAAC;EAEN;EAES,SAAM;AACb,WAAO;6CACkC,KAAK,KAAK;;;;kBAIrC,CAAC,MAAY;AACrB,YAAM,KAAK,EAAE;AACb,WAAK,YAAY,GAAG,KAA4B;IAClD,CAAC;;UAEC,OAAO,KAAK,KAAK,QAAQ,EAAE,IAC3B,WACE,sBAAsB,KAAK,eAAe,UAAU,KAAK,aAAa,mBAAmB;gBACrF,KAAK,SAAS,KAAmC,CAAC;sBAC5C,CACb;;;EAGP;;AAvCQ,WAAA;EADP,QAAQ,EAAE,SAAS,eAAe,WAAW,KAAI,CAAE;;AAIpD,WAAA;EADC,SAAS,EAAE,MAAM,OAAM,CAAE;;AAIlB,WAAA;EADP,MAAK;;;;AChBR,SAAS,OAAAA,MAAK,QAAAC,OAAM,cAAAC,mBAAkB;AACtC,SAAS,YAAAC,iBAA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AM,SAAS,KAAI,CAAE,CAAC;IACnG,CAAC;EACH;;","names":["css","html","LitElement","property","consume","LitElement","css","html","__decorate","consume","property","css","html","LitElement","property","consume","LitElement","css","html","__decorate","consume","property","css","html","LitElement","property","consume","LitElement","css","html","__decorate","consume","property","css","html","html","property","__decorate","property","html","html","html","html","html","html","property","state","Correctness","__decorate","property","state","state","__decorate","state","css","html","property","css","html","__decorate","property","repeat","repeat","css","html","css","html","css","html","repeat","css","previous","repeat","html","css","html","nothing","css","nothing","html","css","html","css","html"]}
@@ -1 +0,0 @@
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/record.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 * What test plugins keep, by plugin name: JSON the test stores and restores without reading it.\n * Part of the persisted state (`QtiTestState.session.plugins`); written through the\n * `cito-test-update-plugin-state` request.\n */\n plugins?: Readonly<Record<string, unknown>>;\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 type { BaseType } from './expression-result';\n\n/**\n * The value of a variable with `record` cardinality: its fields by field identifier.\n *\n * Field values are kept the way every other response value is kept, as QTI string literals — a\n * float is `\"4.12\"`, a point is `\"455 250\"` — with a list-valued field as an array of them.\n */\nexport type RecordValue = Record<string, string | string[] | null>;\n\n/** A record's field values with the base type each `qti-value` declared for its field. */\nexport interface RecordFieldValues {\n value: RecordValue;\n baseTypes: Record<string, BaseType>;\n}\n\n/** Whether a variable value is a record: a plain object, not a list and not NULL. */\nexport const isRecordValue = (value: unknown): value is RecordValue =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\n\n/**\n * Reads the field values of a record out of `qti-value field-identifier=\"…\" base-type=\"…\"`\n * elements, as found in a `qti-correct-response` or `qti-default-value` of a record declaration.\n *\n * A value without a `field-identifier` is not a record field and is skipped. A field without a\n * `base-type` gets no entry in `baseTypes`, so a reader can tell \"declared string\" from \"unknown\".\n */\nexport const readRecordFieldValues = (valueElements: Iterable<Element>): RecordFieldValues => {\n const value: RecordValue = {};\n const baseTypes: Record<string, BaseType> = {};\n for (const element of valueElements) {\n const fieldIdentifier = element.getAttribute('field-identifier');\n if (!fieldIdentifier) continue;\n value[fieldIdentifier] = element.textContent?.trim() ?? '';\n const baseType = element.getAttribute('base-type');\n if (baseType) baseTypes[fieldIdentifier] = baseType as BaseType;\n }\n return { value, baseTypes };\n};\n\nconst NUMBER = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)([eE][+-]?\\d+)?$/;\n\n/**\n * A best guess at a record field's base type, for when the declaration does not say.\n *\n * A record field value carries no type of its own once it is stored, and a record response\n * declaration has no `base-type`, so this is the fallback. A number is a float (or an integer\n * when given as a whole JS number), two numbers separated by whitespace are a point, and\n * anything else is a string.\n */\nexport const inferRecordFieldBaseType = (value: unknown): BaseType => {\n if (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'float';\n if (typeof value === 'boolean') return 'boolean';\n if (typeof value !== 'string') return 'string';\n const text = value.trim();\n if (NUMBER.test(text)) return 'float';\n const parts = text.split(/\\s+/);\n if (parts.length === 2 && parts.every(part => NUMBER.test(part))) return 'point';\n return 'string';\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;;AAClC,qBAAe,MAAM,KAAK,OAAM,CAAE;EACzC;EAEA,SAAM;AACJ,QAAI,KAAK,SAAS;AAAG,WAAK,MAAM,gBAAgB,YAAY;;AACvD,WAAK,MAAM,aAAa,cAAc,MAAM,KAAK,IAAI,EAAE,KAAK,GAAG,CAAC;EACvE;;AAKF,IAAM,YAAY;AAaZ,SAAU,2BACd,iBAAwD;AAExD,MAAI,EAAE,YAAY,iBAAiB;AAAY,WAAO;AACtD,MAAI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U,MAAM,GAAG;AAC1D,mBAAO,WAAW;UACpB;AACA,iBAAO,SAAS;QAClB,OAAO;AACL,kBAAQ,MAAM,kBAAkB,MAAM,WAAW,MAAM,UAAU;QACnE;AACA;MACF;MACA,KAAK,SAAS;AACZ,cAAM,SAAS,WAAW,MAAM;AAChC,cAAM,SAAS,WAAW,MAAM;AAChC,YAAI,CAAC,MAAM,MAAM,KAAK,CAAC,MAAM,MAAM,GAAG;AACpC,iBAAO,WAAW;QACpB,OAAO;AACL,kBAAQ,MAAM,oBAAoB,MAAM,WAAW,MAAM,YAAY;QACvE;AACA;MACF;MACA,KAAK;MACL,KAAK,gBAAgB;AAUnB,cAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,cAAM,QAAQ,OAAO,MAAM,GAAG;AAC9B,YAAI,MAAM,WAAW,KAAK,MAAM,WAAW,GAAG;AAC5C,cAAI,aAAa,QAAQ;AACvB,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"]}