@citolab/qti-components 10.0.0-next.1 → 10.0.0-next.3

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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../qti-test/src/components/qti-assessment-item-ref/qti-assessment-item-ref.ts","../../../node_modules/.pnpm/@heximal+templates@0.1.5/node_modules/@heximal/templates/src/index.ts","../../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/src/lib/constants.ts","../../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/src/lib/tokenizer.ts","../../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/src/lib/parser.ts","../../../node_modules/.pnpm/@heximal+expressions@0.1.5/node_modules/@heximal/expressions/src/lib/eval.ts","../../qti-test/src/internal/test-host.context.ts","../../qti-test/src/public-events.ts","../../qti-test/src/components/qti-assessment-section/qti-assessment-section.ts","../../qti-test/src/components/qti-assessment-test/qti-assessment-test.ts","../../qti-test/src/components/qti-branch-rule/qti-branch-rule.ts","../../qti-test/src/internal/evaluate-condition.ts","../../qti-test/src/components/qti-item-session-control/qti-item-session-control.ts","../../qti-test/src/internal/item-ref-selection.ts","../../qti-test/src/components/qti-number-selected/qti-number-selected.ts","../../qti-test/src/components/qti-pre-condition/qti-pre-condition.ts","../../qti-test/src/components/qti-outcome-processing/qti-outcome-processing.ts","../../qti-test/src/components/qti-test-feedback/qti-test-feedback.ts","../../qti-test/src/components/qti-test-part/qti-test-part.ts","../../qti-test/src/components/qti-test-variables/qti-test-variables.ts","../../qti-test/src/types/qti-test-state.ts","../../qti-test/src/components/qti-test/qti-test.ts","../../qti-test/src/mixins/test-navigation.mixin.ts","../../qti-test/src/internal/item-sequencing.ts","../../qti-test/src/mixins/test-view.mixin.ts","../../qti-test/src/mixins/test-base.ts","../../qti-test/src/mixins/test-state.mixin.ts","../../qti-test/src/mixins/test-processing.mixin.ts","../../qti-test/src/components/test-check-item/test-check-item.ts","../../qti-test/src/components/styles.ts","../../qti-test/src/components/test-container/test-container.ts","../../qti-test/src/components/test-end-attempt/test-end-attempt.ts","../../qti-test/src/components/test-item-link/test-item-link.ts","../../qti-test/src/components/test-item-to-speech/test-item-to-speech.ts","../../qti-test/src/components/test-navigation/test-navigation.ts","../../qti-test/src/components/test-next/test-next.ts","../../qti-test/src/components/test-paging-buttons-stamp/test-paging-buttons-stamp.ts","../../qti-test/src/components/test-prev/test-prev.ts","../../qti-test/src/components/test-print-context/test-print-context.ts","../../qti-test/src/components/test-print-item-variables/test-print-item-variables.ts","../../qti-test/src/components/test-scoring-buttons/test-scoring-buttons.ts","../../qti-test/src/components/test-scoring-feedback/test-scoring-feedback.ts","../../qti-test/src/components/test-section-buttons-stamp/test-section-buttons-stamp.ts","../../qti-test/src/components/test-section-link/test-section-link.ts","../../qti-test/src/components/test-stamp/test-stamp.ts","../../qti-test/src/components/test-view-toggle/test-view.ts","../../qti-test/src/components/test-view-toggle/test-view-toggle.ts","../../qti-test/src/elements.ts"],"sourcesContent":["import { LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TemplateFunction } from '@heximal/templates';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * The model a `<template item-ref>` is rendered with.\n *\n * Only what this element already knows: the item's parsed document and the\n * attributes off the item-ref itself. `itemRef` is the escape hatch — a\n * template that needs anything else (a click handler, a value from the host\n * app) reaches it through a property on the element, which the host is free to\n * set.\n */\nexport interface ItemRefTemplateModel {\n /** The item's parsed document, i.e. what the element renders by default. */\n xmlDoc: DocumentFragment;\n identifier?: string;\n href?: string;\n category?: string;\n /**\n * This item's entry in the computed context, the same object the stamps\n * iterate as `item`: `index` (1-based, null for info items), `score`,\n * `maxScore`, `completed`, `active`, … Undefined until the test has computed it.\n */\n item?: ComputedItem;\n /** The element being rendered. */\n itemRef: QtiAssessmentItemRef;\n}\n\n// @customElement('qti-assessment-item-ref')\nexport class QtiAssessmentItemRef extends LitElement {\n @property({ type: String }) category?: string;\n @property({ type: String }) identifier?: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) required?: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed?: boolean;\n @property({ type: String }) href?: string;\n\n // Only read by a <template item-ref>; subscribing re-renders it as scores come in\n @state()\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n /**\n * The `<qti-weight>` children of this ref, keyed by identifier — what\n * `qti-test-variables`' `weight-identifier` resolves against.\n *\n * Read on access rather than cached: the test document is rendered into this\n * element's light DOM, so the weights are not in place at construction time,\n * and outcome processing runs long after they are.\n */\n get weights(): Map<string, number> {\n const weights = new Map<string, number>();\n for (const weight of this.querySelectorAll(':scope > qti-weight')) {\n const identifier = weight.getAttribute('identifier');\n if (!identifier) continue;\n const value = Number(weight.getAttribute('value'));\n if (Number.isNaN(value)) {\n console.warn(`qti-weight \"${identifier}\" has a non-numeric value, ignoring it`);\n continue;\n }\n weights.set(identifier, value);\n }\n return weights;\n }\n\n @property({ type: Object, attribute: false })\n xmlDoc: DocumentFragment | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n get assessmentItem(): QtiAssessmentItem | null {\n return this.renderRoot?.querySelector('qti-assessment-item');\n }\n\n myTemplate: TemplateFunction | null = null;\n\n /** The `qti-test` this ref belongs to, wherever it renders: light DOM, or any depth of shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n // A context consumer keeps its last value when it is moved somewhere with no provider, and\n // `closest()` never did: a ref moved out of a test must not keep that test's template.\n this.testHost = undefined;\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n\n /*\n Optional per-item template, used to render extra things around an item —\n a bookmark, an index number, a score badge. Put it in the light DOM of\n your qti-test, and every item-ref in the test renders with it:\n\n <qti-test>\n <template item-ref>\n <div class=\"badge\">{{ identifier }}</div>\n {{ xmlDoc }}\n </template>\n …\n </qti-test>\n\n The template is the WHOLE render, so it has to place {{ xmlDoc }} itself;\n leaving it out renders the chrome and no item. Without a template the\n element renders the item on its own, exactly as before.\n\n Resolved once, on connect: one template serves every item, and everything\n that varies per item comes through the model (see ItemRefTemplateModel).\n */\n const templateElement = this.testHost?.querySelector<HTMLTemplateElement>('template[item-ref]');\n this.myTemplate = templateElement ? prepareTemplate(templateElement) : null;\n this.requestUpdate();\n\n await this.updateComplete;\n\n dispatchPublic(this, 'cito-item-ref-connected', {\n identifier: this.identifier,\n href: this.href,\n category: this.category\n });\n }\n\n #computedItem(): ComputedItem | undefined {\n for (const testPart of this.computedContext?.testParts ?? []) {\n for (const section of testPart.sections) {\n const item = section.items.find(i => i.identifier === this.identifier);\n if (item) return item;\n }\n }\n return undefined;\n }\n\n /**\n * The clone of `xmlDoc` that is rendered, and what it was cloned for. Cloned\n * once per document and template, not per render: re-renders from\n * computed-context changes then hand Lit the same fragment, which it leaves\n * alone, instead of rebuilding the item (and reloading its PCIs, which\n * changes the context again).\n */\n #rendered: { source: DocumentFragment; template: TemplateFunction | null; doc: DocumentFragment } | null = null;\n\n override render() {\n // Item refs connect before loading, and navigation clears their documents.\n if (!this.xmlDoc) {\n this.#rendered = null;\n return nothing;\n }\n\n if (this.#rendered?.source !== this.xmlDoc || this.#rendered.template !== this.myTemplate) {\n this.#rendered = {\n source: this.xmlDoc,\n template: this.myTemplate,\n doc: this.xmlDoc.cloneNode(true) as DocumentFragment\n };\n }\n const xmlDoc = this.#rendered.doc;\n if (!this.myTemplate) return xmlDoc;\n\n const model: ItemRefTemplateModel = {\n xmlDoc,\n identifier: this.identifier,\n href: this.href,\n category: this.category,\n item: this.#computedItem(),\n itemRef: this\n };\n return this.myTemplate(model);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-item-ref': QtiAssessmentItemRef;\n }\n}\n","import {\n render as renderLit,\n TemplateInstance,\n nothing,\n CompiledTemplate,\n CompiledTemplateResult,\n RenderOptions,\n} from 'lit-html';\n\nimport {parse, Parser, EvalAstFactory} from '@heximal/expressions';\nimport type {Expression, Scope} from '@heximal/expressions/lib/eval';\n\nimport {_$LH} from 'lit-html/private-ssr-support.js';\nconst {AttributePart, PropertyPart, BooleanAttributePart, EventPart} = _$LH;\n\nconst astFactory = new EvalAstFactory();\nconst expressionCache = new Map<string, Expression | undefined>();\n\nconst toCamelCase = (s: string) =>\n s.replace(/-(-|\\w)/g, (_, p1: string) => p1.toUpperCase());\n\n/**\n * Gets the value from a string that contains a delimted expression: {{ ... }}\n */\nconst getSingleValue = (s: string, model: any) => {\n let ast = expressionCache.get(s);\n if (ast === undefined) {\n if (expressionCache.has(s)) {\n return undefined;\n }\n s = s.trim();\n if (s.startsWith('{{') && s.endsWith('}}')) {\n const expression = s.substring(2, s.length - 2).trim();\n ast = new Parser(expression, astFactory).parse();\n expressionCache.set(s, ast);\n }\n }\n return ast?.evaluate(model);\n};\n\nexport interface TemplateFunction {\n (model: object): unknown;\n}\n\n/**\n * A Renderer is responsible for rendering a block call, like\n * <template name=\"foo\">\n */\n// TODO: rename to BlockRenderer?\nexport interface Renderer {\n (model: any, handlers: TemplateHandlers, renderers: Renderers): unknown;\n}\n\nexport interface Renderers {\n [name: string]: Renderer;\n}\n\n/**\n * A TemplateHandlers is responsible for rendering control flow like\n * <template type=\"if\" if=\"{{x}}\">\n */\nexport type TemplateHandler = (\n template: HTMLTemplateElement,\n model: object,\n handlers: TemplateHandlers,\n renderers: Renderers,\n) => unknown;\n\nexport interface TemplateHandlers {\n [name: string]: TemplateHandler;\n}\n\nexport const ifHandler: TemplateHandler = (\n template: HTMLTemplateElement,\n model: object,\n handlers: TemplateHandlers,\n renderers: Renderers,\n) => {\n const ifAttribute = template.getAttribute('if');\n if (ifAttribute !== null && getSingleValue(ifAttribute, model)) {\n return evaluateTemplate(template, model, handlers, renderers);\n }\n return undefined;\n};\n\nconst bindingRegex = /(?<!\\\\){{(.*?)(?:(?<!\\\\)}})/g;\n\nconst hasEscapedBindingMarkers = (s: string) => /(?:\\\\{{)|(?:\\\\}})/g.test(s);\n\nconst unescapeBindingMarkers = (s: string) =>\n s.replaceAll(/\\\\{{/g, '{{').replace(/\\\\}}/g, '}}');\n\nexport const repeatHandler: TemplateHandler = (\n template: HTMLTemplateElement,\n model: object & {this?: unknown},\n handlers: TemplateHandlers,\n renderers: Renderers,\n) => {\n const repeatAttribute = template.getAttribute('repeat');\n if (repeatAttribute !== null) {\n const items = getSingleValue(repeatAttribute, model);\n if (!items[Symbol.iterator]) {\n return nothing;\n }\n const litTemplate = getLitTemplate(template);\n\n let index = -1;\n const result = [];\n for (const item of items) {\n index++;\n const itemModel = Object.create(model);\n itemModel.item = item;\n itemModel.index = index;\n itemModel['this'] = model['this'] ?? model;\n\n const values = [];\n for (const part of litTemplate.parts) {\n const value = part.update(itemModel, handlers, renderers);\n if (part.type === 1) {\n values.push(...(value as Iterable<unknown>));\n } else {\n values.push(value);\n }\n }\n const templateResult: CompiledTemplateResult = {\n _$litType$: litTemplate,\n values,\n };\n result.push(templateResult);\n }\n return result;\n }\n return undefined;\n};\n\nexport const defaultHandlers = <TemplateHandlers>{\n if: ifHandler,\n repeat: repeatHandler,\n};\n\n/**\n * @returns {Function} a template function of the form (model) => TemplateResult\n */\nexport const prepareTemplate = (\n template: HTMLTemplateElement,\n handlers: TemplateHandlers = defaultHandlers,\n renderers: Renderers = {},\n superTemplate?: HTMLTemplateElement,\n): TemplateFunction => {\n const litTemplate = getLitTemplate(template);\n const templateRenderers = litTemplate.renderers;\n if (superTemplate) {\n const superLitTemplate = getLitTemplate(superTemplate);\n const superRenderers = superLitTemplate.renderers;\n const superCallRenderer = templateRenderers['super'];\n\n if (superCallRenderer !== undefined) {\n // Explicit super call\n\n // render the sub template with:\n renderers = {\n // sub template's own renderes\n ...templateRenderers,\n // passed-in renderers\n ...renderers,\n // a super call renderer\n super: (model, handlers, renderers) => {\n // This renderer delegates to the super block in the sub template,\n // which in turn delegates back to the super renderer below, but with\n // the inner blocks of the super call.\n // when the super call goes, render with:\n renderers = {\n // super template's own blocks\n ...superRenderers,\n // passed-in renderers\n ...renderers,\n // sub template's overrides will be added by the inner super call\n super: (model, handlers, renderers) => {\n return evaluateTemplate(\n superTemplate,\n model,\n handlers,\n renderers,\n );\n },\n };\n return superCallRenderer(model, handlers, renderers);\n },\n };\n } else {\n // Implicit super call\n\n // Wrap the whole template in an implicit super call by rendering the\n // super template first, but using the block renderers from this template.\n // Render the super template with:\n renderers = {\n // super template's own blocks\n ...superRenderers,\n // sub template's overrides\n ...templateRenderers,\n // passed-in renderers\n ...renderers,\n };\n template = superTemplate;\n }\n } else {\n // No super call\n renderers = {\n // template's named blocks\n ...templateRenderers,\n // passed-in renderers\n ...renderers,\n };\n }\n return (model) => evaluateTemplate(template, model, handlers, renderers);\n};\n\nexport interface HeximalRenderOptions {\n renderers?: Renderers;\n extends?: HTMLTemplateElement;\n}\n\n/**\n * Renders a template element containing a Heximal template.\n *\n * This is a convenience function wrapper around:\n *\n * ```\n * import {render} from 'lit';\n * const templateFn = prepareTemplate(templateEl);\n * render(templateFn(model), container);\n * ```\n */\nexport const render = (\n template: HTMLTemplateElement,\n container: HTMLElement,\n model: any,\n handlers: TemplateHandlers = defaultHandlers,\n options: RenderOptions = {},\n) => {\n const litTemplate = prepareTemplate(template, handlers);\n renderLit(litTemplate(model), container, options);\n};\n\n/**\n * Evaluates the given template and returns its result\n *\n * @param template\n * @param model\n * @param handlers\n * @param renderers\n * @returns\n */\nexport const evaluateTemplate = (\n template: HTMLTemplateElement,\n model: any,\n handlers: TemplateHandlers = defaultHandlers,\n renderers: Renderers = {},\n) => {\n const litTemplate = getLitTemplate(template);\n const values: Array<unknown> = [];\n for (const part of litTemplate.parts) {\n const value = part.update(model, handlers, renderers);\n if (part.type === 1) {\n values.push(...(value as Iterable<unknown>));\n } else {\n values.push(value);\n }\n }\n const templateResult: CompiledTemplateResult = {\n _$litType$: litTemplate,\n values,\n };\n return templateResult;\n};\n\ntype TemplatePart = TemplateInstance['_$template']['parts'][0];\n\ntype HeximalTemplatePart = TemplatePart & {\n update: PartUpdater;\n};\n\ntype PartUpdater = (\n model: object,\n handlers: TemplateHandlers,\n blocks: Renderers,\n) => unknown;\n\ninterface HeximalTemplate extends CompiledTemplate {\n parts: Array<HeximalTemplatePart>;\n renderers: Renderers;\n}\n\nconst litTemplateCache = new Map<HTMLTemplateElement, HeximalTemplate>();\n\nexport const getLitTemplate = (\n template: HTMLTemplateElement,\n): HeximalTemplate => {\n let litTemplate = litTemplateCache.get(template);\n if (litTemplate === undefined) {\n litTemplateCache.set(template, (litTemplate = makeLitTemplate(template)));\n }\n return litTemplate;\n};\n\nconst makeLitTemplate = (template: HTMLTemplateElement): HeximalTemplate => {\n const litTemplate: HeximalTemplate = {\n h: undefined as unknown as TemplateStringsArray,\n el: template.cloneNode(true) as HTMLTemplateElement,\n parts: [],\n renderers: {},\n };\n const walker = document.createTreeWalker(\n litTemplate.el!.content,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT,\n );\n let node: Node | null = walker.currentNode;\n let nodeIndex = -1;\n const elementsToRemove = [];\n\n while ((node = walker.nextNode()) !== null) {\n if (node.nodeType === Node.COMMENT_NODE) {\n nodeIndex++;\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n nodeIndex++;\n const element = node as Element;\n if (element.tagName === 'TEMPLATE') {\n const type = element.getAttribute('type');\n const name = element.getAttribute('name');\n const call = element.getAttribute('call');\n\n if (call !== null || type !== null || name !== null) {\n element.parentNode!.insertBefore(document.createComment(''), element);\n elementsToRemove.push(element);\n let update: PartUpdater;\n\n if (call !== null) {\n // This is a sub-template call, like <template call=\"foo\">\n const templateName = call.trim();\n const templateNameIsExpression =\n templateName.startsWith('{{') && templateName.endsWith('}}');\n\n update = (\n model: object,\n handlers: TemplateHandlers,\n renderers: Renderers,\n ) => {\n const dataAttr = element.getAttribute('data');\n const data =\n dataAttr === null ? undefined : getSingleValue(dataAttr, model);\n\n const renderer = templateNameIsExpression\n ? getSingleValue(templateName, model)\n : renderers[call];\n return renderer?.(data, handlers, renderers);\n };\n } else if (type !== null) {\n // This is a control-flow call, like if/repeat\n update = (\n model: object,\n handlers: TemplateHandlers,\n renderers: Renderers,\n ) => {\n const handler = handlers[type];\n return handler?.(\n element as HTMLTemplateElement,\n model,\n handlers,\n renderers,\n );\n };\n } else {\n // This is a named block\n if (name === 'super') {\n litTemplate.renderers['super'] = (\n model: any,\n handlers: TemplateHandlers,\n renderers: Renderers,\n ) => {\n // Instead of rendering this block, delegate to a passed in\n // 'super' renderer which will actually render the late-bound\n // super template. We pass that renderer the child blocks from\n // this block for block overrides.\n const superRenderer = renderers['super'];\n const superCallTemplate = getLitTemplate(\n element as HTMLTemplateElement,\n );\n renderers = {\n ...renderers,\n ...superCallTemplate.renderers,\n };\n return superRenderer(model, handlers, renderers);\n };\n } else {\n // The renderer renders the contents of the named block\n litTemplate.renderers[name!] = (\n model: any,\n handlers: TemplateHandlers,\n renderers: Renderers,\n ) => {\n return evaluateTemplate(\n element as HTMLTemplateElement,\n model,\n handlers,\n renderers,\n );\n };\n }\n // The updater runs when the template is evaluated and functions as\n // a template _call_. It looks for a named renderer, which might be\n // the renderer function above if the block is not overridden.\n update = (\n model: object,\n handlers: TemplateHandlers,\n renderers: Renderers,\n ) => {\n const renderer = renderers[name!];\n return renderer?.(model, handlers, renderers);\n };\n }\n litTemplate.parts.push({\n type: 2, // text binding\n index: nodeIndex,\n update,\n });\n // Template with call, type, or name attributes are removed from the\n // DOM, so they can't have attribute bindings.\n continue;\n }\n }\n const attributeNames = element.getAttributeNames();\n for (const attributeName of attributeNames) {\n const attributeValue = element.getAttribute(attributeName)!;\n // TODO: use alternative to negative lookbehind\n // (but it's so convenient!)\n const splitValue = attributeValue.split(bindingRegex);\n if (splitValue.length === 1) {\n if (hasEscapedBindingMarkers(attributeValue)) {\n element.setAttribute(\n attributeName,\n unescapeBindingMarkers(attributeValue),\n );\n }\n continue;\n }\n element.removeAttribute(attributeName);\n let name = attributeName;\n let ctor = AttributePart;\n const prefix = attributeName[0];\n if (prefix === '.') {\n name = toCamelCase(attributeName.substring(1));\n ctor = PropertyPart;\n } else if (prefix === '?') {\n name = attributeName.substring(1);\n ctor = BooleanAttributePart;\n } else if (prefix === '@') {\n name = toCamelCase(attributeName.substring(1));\n ctor = EventPart;\n }\n\n const strings = [unescapeBindingMarkers(splitValue[0])];\n const exprs: Array<Expression> = [];\n for (let i = 1; i < splitValue.length; i += 2) {\n const exprText = splitValue[i];\n exprs.push(parse(exprText, astFactory) as Expression);\n strings.push(unescapeBindingMarkers(splitValue[i + 1]));\n }\n\n litTemplate.parts.push({\n type: 1, // attribute binding\n index: nodeIndex,\n name,\n strings,\n ctor,\n update: (\n model: object,\n _handlers: TemplateHandlers,\n _renderers: Renderers,\n ) => {\n return exprs.map((expr) => expr.evaluate(model));\n },\n });\n }\n } else if (node.nodeType === Node.TEXT_NODE) {\n let textNode = node as Text;\n const text = textNode.textContent!;\n const strings = text.split(bindingRegex);\n if (strings.length > 1) {\n textNode.textContent = unescapeBindingMarkers(strings[0]);\n } else if (hasEscapedBindingMarkers(text)) {\n textNode.textContent = unescapeBindingMarkers(text);\n }\n for (let i = 1; i < strings.length; i += 2) {\n const exprText = strings[i];\n const expr = parse(exprText, astFactory) as Expression;\n litTemplate.parts.push({\n type: 2,\n index: ++nodeIndex,\n update: (model: unknown, _handlers: TemplateHandlers) =>\n expr.evaluate(model as Scope),\n });\n const newTextNode = new Text(strings[i + 1].replace('\\\\{{', '{{'));\n textNode.parentNode!.insertBefore(newTextNode, textNode.nextSibling);\n textNode.parentNode!.insertBefore(\n document.createComment(''),\n textNode.nextSibling,\n );\n textNode = newTextNode;\n // This TreeWalker isn't configured to walk comment nodes, but this\n // node will be returned next time through the loop. This is the easiest\n // way to get the walker to proceed to the next successor after the\n // marker, even when the marker doesn't have a nextSibling\n walker.currentNode = newTextNode;\n }\n }\n }\n for (const e of elementsToRemove) {\n e.remove();\n }\n return litTemplate;\n};\n","/*\n * @license\n * Portions Copyright (c) 2013, the Dart project authors.\n */\n\nexport const KEYWORDS = ['this'];\nexport const UNARY_OPERATORS = ['+', '-', '!'];\nexport const BINARY_OPERATORS = [\n '=',\n '+',\n '-',\n '*',\n '/',\n '%',\n '^',\n '==',\n '!=',\n '>',\n '<',\n '>=',\n '<=',\n '||',\n '&&',\n '??',\n '&',\n '===',\n '!==',\n '|',\n '|>',\n];\n\nexport const PRECEDENCE: Record<string, number> = {\n '!': 0,\n ':': 0,\n ',': 0,\n ')': 0,\n ']': 0,\n '}': 0,\n\n '|>': 1,\n '?': 2,\n '??': 3,\n '||': 4,\n '&&': 5,\n '|': 6,\n '^': 7,\n '&': 8,\n\n // equality\n '!=': 9,\n '==': 9,\n '!==': 9,\n '===': 9,\n\n // relational\n '>=': 10,\n '>': 10,\n '<=': 10,\n '<': 10,\n\n // additive\n '+': 11,\n '-': 11,\n\n // multiplicative\n '%': 12,\n '/': 12,\n '*': 12,\n\n // postfix\n '(': 13,\n '[': 13,\n '.': 13,\n '{': 13, // not sure this is correct\n};\n\nexport const POSTFIX_PRECEDENCE = 13;\n","/*\n * @license\n * Portions Copyright (c) 2013, the Dart project authors.\n */\n\nimport {KEYWORDS, POSTFIX_PRECEDENCE, PRECEDENCE} from './constants.js';\n\nconst TWO_CHAR_OPS = ['==', '!=', '<=', '>=', '||', '&&', '??', '|>'];\nconst THREE_CHAR_OPS = ['===', '!=='];\n\nexport interface Token {\n kind: Kind;\n value: string;\n precedence: number;\n}\n\nexport enum Kind {\n STRING = 1,\n IDENTIFIER = 2,\n DOT = 3,\n COMMA = 4,\n COLON = 5,\n INTEGER = 6,\n DECIMAL = 7,\n OPERATOR = 8,\n GROUPER = 9,\n KEYWORD = 10,\n ARROW = 11,\n}\n\nexport const token = (kind: Kind, value: string, precedence: number = 0) => ({\n kind,\n value,\n precedence,\n});\n\nconst isWhitespace = (ch: number) =>\n ch === 9 /* \\t */ ||\n ch === 10 /* \\n */ ||\n ch === 13 /* \\r */ ||\n ch === 32; /* space */\n\n// TODO(justinfagnani): allow code points > 127\nconst isIdentOrKeywordStart = (ch: number) =>\n ch === 95 /* _ */ ||\n ch === 36 /* $ */ ||\n // ch &= ~32 puts ch into the range [65,90] [A-Z] only if ch was already in\n // the that range or in the range [97,122] [a-z]. We must mutate ch only after\n // checking other characters, thus the comma operator.\n ((ch &= ~32), 65 /* A */ <= ch && ch <= 90); /* Z */\n\n// TODO(justinfagnani): allow code points > 127\nconst isIdentifier = (ch: number) => isIdentOrKeywordStart(ch) || isNumber(ch);\n\nconst isKeyword = (str: string) => KEYWORDS.indexOf(str) !== -1;\n\nconst isQuote = (ch: number) => ch === 34 /* \" */ || ch === 39; /* ' */\n\nconst isNumber = (ch: number) => 48 /* 0 */ <= ch && ch <= 57; /* 9 */\n\nconst isOperator = (ch: number) =>\n ch === 43 /* + */ ||\n ch === 45 /* - */ ||\n ch === 42 /* * */ ||\n ch === 47 /* / */ ||\n ch === 33 /* ! */ ||\n ch === 38 /* & */ ||\n ch === 37 /* % */ ||\n ch === 60 /* < */ ||\n ch === 61 /* = */ ||\n ch === 62 /* > */ ||\n ch === 63 /* ? */ ||\n ch === 94 /* ^ */ ||\n ch === 124; /* | */\n\nconst _isGrouper = (ch: number) =>\n ch === 40 /* ( */ ||\n ch === 41 /* ) */ ||\n ch === 91 /* [ */ ||\n ch === 93 /* ] */ ||\n ch === 123 /* { */ ||\n ch === 125; /* } */\n\nconst escapeString = (str: string) =>\n str.replace(/\\\\(.)/g, (_match, group) => {\n switch (group) {\n case 'n':\n return '\\n';\n case 'r':\n return '\\r';\n case 't':\n return '\\t';\n case 'b':\n return '\\b';\n case 'f':\n return '\\f';\n default:\n return group;\n }\n });\n\nexport class Tokenizer {\n #input: string;\n #index = -1;\n #tokenStart = 0;\n #next?: number;\n\n constructor(input: string) {\n this.#input = input;\n this.#advance();\n }\n\n nextToken() {\n while (isWhitespace(this.#next!)) {\n this.#advance(true);\n }\n if (isQuote(this.#next!)) return this.#tokenizeString();\n if (isIdentOrKeywordStart(this.#next!)) {\n return this.#tokenizeIdentOrKeyword();\n }\n if (isNumber(this.#next!)) return this.#tokenizeNumber();\n if (this.#next === 46 /* . */) return this.#tokenizeDot();\n if (this.#next === 44 /* , */) return this.#tokenizeComma();\n if (this.#next === 58 /* : */) return this.#tokenizeColon();\n if (isOperator(this.#next!)) return this.#tokenizeOperator();\n if (_isGrouper(this.#next!)) return this.#tokenizeGrouper();\n // no match, should be end of input\n this.#advance();\n if (this.#next !== undefined) {\n throw new Error(`Expected end of input, got ${this.#next}`);\n }\n return undefined;\n }\n\n #advance(resetTokenStart?: boolean) {\n this.#index++;\n if (this.#index < this.#input.length) {\n this.#next = this.#input.charCodeAt(this.#index);\n if (resetTokenStart === true) {\n this.#tokenStart = this.#index;\n }\n } else {\n this.#next = undefined;\n }\n }\n\n #getValue(lookahead: number = 0) {\n const v = this.#input.substring(this.#tokenStart, this.#index + lookahead);\n if (lookahead === 0) {\n this.#clearValue();\n }\n return v;\n }\n\n #clearValue() {\n this.#tokenStart = this.#index;\n }\n\n #tokenizeString() {\n const _us = 'unterminated string';\n const quoteChar = this.#next;\n this.#advance(true);\n while (this.#next !== quoteChar) {\n if (this.#next === undefined) throw new Error(_us);\n if (this.#next === 92 /* \\ */) {\n this.#advance();\n if (this.#next === undefined) throw new Error(_us);\n }\n this.#advance();\n }\n const t = token(Kind.STRING, escapeString(this.#getValue()));\n this.#advance();\n return t;\n }\n\n #tokenizeIdentOrKeyword() {\n // This do/while loops assumes isIdentifier(this._next!), so it must only\n // be called if isIdentOrKeywordStart(this._next!) has returned true.\n do {\n this.#advance();\n } while (isIdentifier(this.#next!));\n const value = this.#getValue();\n const kind = isKeyword(value) ? Kind.KEYWORD : Kind.IDENTIFIER;\n return token(kind, value);\n }\n\n #tokenizeNumber() {\n // This do/while loops assumes isNumber(this._next!), so it must only\n // be called if isNumber(this._next!) has returned true.\n do {\n this.#advance();\n } while (isNumber(this.#next!));\n if (this.#next === 46 /* . */) return this.#tokenizeDot();\n return token(Kind.INTEGER, this.#getValue());\n }\n\n #tokenizeDot() {\n this.#advance();\n if (isNumber(this.#next!)) return this.#tokenizeFraction();\n this.#clearValue();\n return token(Kind.DOT, '.', POSTFIX_PRECEDENCE);\n }\n\n #tokenizeComma() {\n this.#advance(true);\n return token(Kind.COMMA, ',');\n }\n\n #tokenizeColon() {\n this.#advance(true);\n return token(Kind.COLON, ':');\n }\n\n #tokenizeFraction() {\n // This do/while loops assumes isNumber(this._next!), so it must only\n // be called if isNumber(this._next!) has returned true.\n do {\n this.#advance();\n } while (isNumber(this.#next!));\n return token(Kind.DECIMAL, this.#getValue());\n }\n\n #tokenizeOperator() {\n this.#advance();\n let op = this.#getValue(2);\n\n if (THREE_CHAR_OPS.indexOf(op) !== -1) {\n this.#advance();\n this.#advance();\n } else {\n op = this.#getValue(1);\n if (op === '=>') {\n this.#advance();\n return token(Kind.ARROW, op);\n }\n if (TWO_CHAR_OPS.indexOf(op) !== -1) {\n this.#advance();\n }\n }\n op = this.#getValue();\n return token(Kind.OPERATOR, op, PRECEDENCE[op]);\n }\n\n #tokenizeGrouper() {\n const value = String.fromCharCode(this.#next!);\n const t = token(Kind.GROUPER, value, PRECEDENCE[value]);\n this.#advance(true);\n return t;\n }\n}\n","/*\n * @license\n * Portions Copyright (c) 2013, the Dart project authors.\n */\n\nimport {ID, Invoke, Expression} from './ast.js';\nimport {AstFactory} from './ast_factory.js';\nimport {\n BINARY_OPERATORS,\n KEYWORDS,\n POSTFIX_PRECEDENCE,\n UNARY_OPERATORS,\n} from './constants.js';\nimport {Kind, Token, Tokenizer} from './tokenizer.js';\n\nexport const parse = <E extends Expression>(\n expr: string,\n astFactory: AstFactory<E>,\n): E | undefined => new Parser<E>(expr, astFactory).parse();\n\nexport class Parser<N extends Expression> {\n #kind?: Kind;\n #tokenizer: Tokenizer;\n #ast: AstFactory<N>;\n #token?: Token;\n #value?: string;\n\n constructor(input: string, astFactory: AstFactory<N>) {\n this.#tokenizer = new Tokenizer(input);\n this.#ast = astFactory;\n }\n\n parse(): N | undefined {\n this.#advance();\n return this.#parseExpression();\n }\n\n #advance(kind?: Kind, value?: string) {\n if (!this._matches(kind, value)) {\n throw new Error(\n `Expected kind ${kind} (${value}), was ${this.#token?.kind} (${this.#token?.value})`,\n );\n }\n const t = this.#tokenizer.nextToken();\n this.#token = t;\n this.#kind = t?.kind;\n this.#value = t?.value;\n }\n\n _matches(kind?: Kind, value?: string) {\n return !((kind && this.#kind !== kind) || (value && this.#value !== value));\n }\n\n #parseExpression(): N | undefined {\n if (!this.#token) return this.#ast.empty();\n const expr = this.#parseUnary();\n return expr === undefined ? undefined : this.#parsePrecedence(expr, 0);\n }\n\n // #parsePrecedence and #parseBinary implement the precedence climbing\n // algorithm as described in:\n // http://en.wikipedia.org/wiki/Operator-precedence_parser#Precedence_climbing_method\n #parsePrecedence(left: N | undefined, precedence: number) {\n if (left === undefined) {\n throw new Error('Expected left to be defined.');\n }\n while (this.#token) {\n if (this._matches(Kind.GROUPER, '(')) {\n const args = this.#parseArguments();\n left = this.#ast.invoke(left, undefined, args);\n } else if (this._matches(Kind.GROUPER, '[')) {\n const indexExpr = this.#parseIndex();\n left = this.#ast.index(left, indexExpr);\n } else if (this._matches(Kind.DOT)) {\n this.#advance();\n const right = this.#parseUnary();\n left = this.#makeInvokeOrGetter(left, right);\n } else if (this._matches(Kind.KEYWORD)) {\n break;\n } else if (\n this._matches(Kind.OPERATOR) &&\n this.#token.precedence >= precedence\n ) {\n left =\n this.#value === '?'\n ? this.#parseTernary(left)\n : this.#parseBinary(left, this.#token);\n } else {\n break;\n }\n }\n return left;\n }\n\n #makeInvokeOrGetter(left: N, right: N | undefined) {\n if (right === undefined) {\n throw new Error('expected identifier');\n }\n if (right.type === 'ID') {\n return this.#ast.getter(left, (right as ID).value);\n } else if (\n right.type === 'Invoke' &&\n (right as Invoke).receiver.type === 'ID'\n ) {\n const method = (right as Invoke).receiver as ID;\n return this.#ast.invoke(\n left,\n method.value,\n (right as Invoke).arguments as any,\n );\n } else {\n throw new Error(`expected identifier: ${right}`);\n }\n }\n\n #parseBinary(left: N, op: Token) {\n if (BINARY_OPERATORS.indexOf(op.value) === -1) {\n throw new Error(`unknown operator: ${op.value}`);\n }\n this.#advance();\n let right = this.#parseUnary();\n while (\n (this.#kind === Kind.OPERATOR ||\n this.#kind === Kind.DOT ||\n this.#kind === Kind.GROUPER) &&\n this.#token!.precedence > op.precedence\n ) {\n right = this.#parsePrecedence(right, this.#token!.precedence);\n }\n return this.#ast.binary(left, op.value, right);\n }\n\n #parseUnary(): N | undefined {\n if (this._matches(Kind.OPERATOR)) {\n const value = this.#value;\n this.#advance();\n // handle unary + and - on numbers as part of the literal, not as a\n // unary operator\n if (value === '+' || value === '-') {\n if (this._matches(Kind.INTEGER)) {\n return this.#parseInteger(value);\n } else if (this._matches(Kind.DECIMAL)) {\n return this.#parseDecimal(value);\n }\n }\n if (UNARY_OPERATORS.indexOf(value!) === -1)\n throw new Error(`unexpected token: ${value}`);\n const expr = this.#parsePrecedence(\n this.#parsePrimary(),\n POSTFIX_PRECEDENCE,\n );\n return this.#ast.unary(value!, expr);\n }\n return this.#parsePrimary();\n }\n\n #parseTernary(condition: N) {\n this.#advance(Kind.OPERATOR, '?');\n const trueExpr = this.#parseExpression();\n this.#advance(Kind.COLON);\n const falseExpr = this.#parseExpression();\n return this.#ast.ternary(condition, trueExpr, falseExpr);\n }\n\n #parsePrimary() {\n switch (this.#kind) {\n case Kind.KEYWORD:\n const keyword = this.#value!;\n if (keyword === 'this') {\n this.#advance();\n // TODO(justin): return keyword node\n return this.#ast.id(keyword);\n } else if (KEYWORDS.indexOf(keyword) !== -1) {\n throw new Error(`unexpected keyword: ${keyword}`);\n }\n throw new Error(`unrecognized keyword: ${keyword}`);\n case Kind.IDENTIFIER:\n return this.#parseInvokeOrIdentifier();\n case Kind.STRING:\n return this.#parseString();\n case Kind.INTEGER:\n return this.#parseInteger();\n case Kind.DECIMAL:\n return this.#parseDecimal();\n case Kind.GROUPER:\n if (this.#value === '(') {\n return this.#parseParenOrFunction();\n } else if (this.#value === '{') {\n return this.#parseMap();\n } else if (this.#value === '[') {\n return this.#parseList();\n }\n return undefined;\n case Kind.COLON:\n throw new Error('unexpected token \":\"');\n default:\n return undefined;\n }\n }\n\n #parseList() {\n const items: (N | undefined)[] = [];\n do {\n this.#advance();\n if (this._matches(Kind.GROUPER, ']')) break;\n items.push(this.#parseExpression());\n } while (this._matches(Kind.COMMA));\n this.#advance(Kind.GROUPER, ']');\n return this.#ast.list(items);\n }\n\n #parseMap() {\n const entries: {[key: string]: N | undefined} = {};\n do {\n this.#advance();\n if (this._matches(Kind.GROUPER, '}')) break;\n const key = this.#value!;\n if (this._matches(Kind.STRING) || this._matches(Kind.IDENTIFIER)) {\n this.#advance();\n }\n this.#advance(Kind.COLON);\n entries[key] = this.#parseExpression();\n } while (this._matches(Kind.COMMA));\n this.#advance(Kind.GROUPER, '}');\n return this.#ast.map(entries);\n }\n\n #parseInvokeOrIdentifier() {\n const value = this.#value;\n if (value === 'true') {\n this.#advance();\n return this.#ast.literal(true);\n }\n if (value === 'false') {\n this.#advance();\n return this.#ast.literal(false);\n }\n if (value === 'null') {\n this.#advance();\n return this.#ast.literal(null);\n }\n if (value === 'undefined') {\n this.#advance();\n return this.#ast.literal(undefined);\n }\n const identifier = this.#parseIdentifier();\n const args = this.#parseArguments();\n return !args ? identifier : this.#ast.invoke(identifier, undefined, args);\n }\n\n #parseIdentifier() {\n if (!this._matches(Kind.IDENTIFIER)) {\n throw new Error(`expected identifier: ${this.#value}`);\n }\n const value = this.#value;\n this.#advance();\n return this.#ast.id(value!);\n }\n\n #parseArguments() {\n if (!this._matches(Kind.GROUPER, '(')) {\n return undefined;\n }\n const args: Array<N | undefined> = [];\n do {\n this.#advance();\n if (this._matches(Kind.GROUPER, ')')) {\n break;\n }\n const expr = this.#parseExpression();\n args.push(expr);\n } while (this._matches(Kind.COMMA));\n this.#advance(Kind.GROUPER, ')');\n return args;\n }\n\n #parseIndex() {\n // console.assert(this.#matches(Kind.GROUPER, '['));\n this.#advance();\n const expr = this.#parseExpression();\n this.#advance(Kind.GROUPER, ']');\n return expr;\n }\n\n #parseParenOrFunction() {\n const expressions = this.#parseArguments();\n if (this._matches(Kind.ARROW)) {\n this.#advance();\n const body = this.#parseExpression();\n const params = expressions?.map((e) => (e as ID).value) ?? [];\n return this.#ast.arrowFunction(params, body);\n } else {\n return this.#ast.paren(expressions![0]);\n }\n }\n\n #parseString() {\n const value = this.#ast.literal(this.#value!);\n this.#advance();\n return value;\n }\n\n #parseInteger(prefix: string = '') {\n const value = this.#ast.literal(parseInt(`${prefix}${this.#value}`, 10));\n this.#advance();\n return value;\n }\n\n #parseDecimal(prefix: string = '') {\n const value = this.#ast.literal(parseFloat(`${prefix}${this.#value}`));\n this.#advance();\n return value;\n }\n}\n","/*\n * @license\n * Portions Copyright (c) 2013, the Dart project authors.\n */\n\nimport * as ast from './ast.js';\nimport {AstFactory} from './ast_factory.js';\n\nconst {hasOwn, fromEntries} = Object;\n\nconst _BINARY_OPERATORS: Record<string, (a: any, b: any) => any> = {\n '+': (a: any, b: any) => a + b,\n '-': (a: any, b: any) => a - b,\n '*': (a: any, b: any) => a * b,\n '/': (a: any, b: any) => a / b,\n '%': (a: any, b: any) => a % b,\n '==': (a: any, b: any) => a == b,\n '!=': (a: any, b: any) => a != b,\n '===': (a: any, b: any) => a === b,\n '!==': (a: any, b: any) => a !== b,\n '>': (a: any, b: any) => a > b,\n '>=': (a: any, b: any) => a >= b,\n '<': (a: any, b: any) => a < b,\n '<=': (a: any, b: any) => a <= b,\n '||': (a: any, b: any) => a || b,\n '&&': (a: any, b: any) => a && b,\n '??': (a: any, b: any) => a ?? b,\n '|': (a: any, f: (a: any) => any) => f(a),\n '|>': (a: any, f: (a: any) => any) => f(a),\n};\n\nconst _UNARY_OPERATORS: Record<string, (a: any) => any> = {\n '+': (a: any) => a,\n '-': (a: any) => -a,\n '!': (a: any) => !a,\n};\n\nexport interface Scope {\n [key: string]: any;\n}\n\nexport interface Evaluatable {\n evaluate(scope: Scope): any;\n getIds(idents: string[]): string[];\n}\n\nexport type Expression =\n | Literal\n | Empty\n | ID\n | Unary\n | Binary\n | Getter\n | Invoke\n | Index\n | Ternary\n | Map\n | List\n | ArrowFunction;\n\nexport interface Literal extends Evaluatable {\n type: 'Literal';\n value: ast.LiteralValue;\n}\nexport interface Empty extends Evaluatable {\n type: 'Empty';\n}\nexport interface ID extends Evaluatable {\n type: 'ID';\n value: string;\n}\nexport interface Unary extends Evaluatable {\n type: 'Unary';\n operator: string;\n child: Expression;\n}\nexport interface Binary extends Evaluatable {\n type: 'Binary';\n operator: string;\n left: Expression;\n right: Expression;\n}\nexport interface Getter extends Evaluatable {\n type: 'Getter';\n receiver: Expression;\n name: string;\n}\nexport interface Invoke extends Evaluatable {\n type: 'Invoke';\n receiver: Expression;\n method: string | undefined;\n arguments: Array<Expression> | undefined;\n}\nexport interface Index extends Evaluatable {\n type: 'Index';\n receiver: Expression;\n argument: Expression;\n}\nexport interface Ternary extends Evaluatable {\n type: 'Ternary';\n condition: Expression;\n trueExpr: Expression;\n falseExpr: Expression;\n}\nexport interface Map extends Evaluatable {\n type: 'Map';\n entries: {[key: string]: Expression | undefined} | undefined;\n}\nexport interface List extends Evaluatable {\n type: 'List';\n items: Array<Expression> | undefined;\n}\nexport interface ArrowFunction extends Evaluatable {\n type: 'ArrowFunction';\n params: Array<string>;\n body: Expression;\n}\n\nexport class EvalAstFactory implements AstFactory<Expression> {\n empty(): Empty {\n // TODO(justinfagnani): return null instead?\n return {\n type: 'Empty',\n evaluate(scope) {\n return scope;\n },\n getIds(idents) {\n return idents;\n },\n };\n }\n\n // TODO(justinfagnani): just use a JS literal?\n literal(v: string): Literal {\n return {\n type: 'Literal',\n value: v,\n evaluate(_scope) {\n return this.value;\n },\n getIds(idents) {\n return idents;\n },\n };\n }\n\n id(v: string): ID {\n return {\n type: 'ID',\n value: v,\n evaluate(scope) {\n // TODO(justinfagnani): this prevents access to properties named 'this'\n if (this.value === 'this') return scope;\n return scope?.[this.value];\n },\n getIds(idents) {\n idents.push(this.value);\n return idents;\n },\n };\n }\n\n unary(op: string, expr: Expression): Unary {\n const f = _UNARY_OPERATORS[op];\n return {\n type: 'Unary',\n operator: op,\n child: expr,\n evaluate(scope) {\n return f(this.child.evaluate(scope));\n },\n getIds(idents) {\n return this.child.getIds(idents);\n },\n };\n }\n\n binary(l: Expression, op: string, r: Expression): Binary {\n const f = _BINARY_OPERATORS[op];\n return {\n type: 'Binary',\n operator: op,\n left: l,\n right: r,\n evaluate(scope) {\n if (this.operator === '=') {\n if (\n this.left.type !== 'ID' &&\n this.left.type !== 'Getter' &&\n this.left.type !== 'Index'\n ) {\n throw new Error(`Invalid assignment target: ${this.left}`);\n }\n const value = this.right.evaluate(scope);\n let receiver: object | undefined = undefined;\n let property!: string;\n if (this.left.type === 'Getter') {\n receiver = this.left.receiver.evaluate(scope);\n property = this.left.name;\n } else if (this.left.type === 'Index') {\n receiver = this.left.receiver.evaluate(scope);\n property = this.left.argument.evaluate(scope);\n } else if (this.left.type === 'ID') {\n // TODO: the id could be a parameter\n receiver = scope;\n property = this.left.value;\n }\n return receiver === undefined\n ? undefined\n : ((receiver as any)[property] = value);\n }\n return f(this.left.evaluate(scope), this.right.evaluate(scope));\n },\n getIds(idents) {\n this.left.getIds(idents);\n this.right.getIds(idents);\n return idents;\n },\n };\n }\n\n getter(g: Expression, n: string): Getter {\n return {\n type: 'Getter',\n receiver: g,\n name: n,\n evaluate(scope) {\n return this.receiver.evaluate(scope)?.[this.name];\n },\n getIds(idents) {\n this.receiver.getIds(idents);\n return idents;\n },\n };\n }\n\n invoke(receiver: Expression, method: string, args: Expression[]): Invoke {\n if (method != null && typeof method !== 'string') {\n throw new Error('method not a string');\n }\n return {\n type: 'Invoke',\n receiver: receiver,\n method: method,\n arguments: args,\n evaluate(scope) {\n const receiver = this.receiver.evaluate(scope);\n // TODO(justinfagnani): this might be wrong in cases where we're\n // invoking a top-level function rather than a method. If method is\n // defined on a nested scope, then we should probably set _this to null.\n const _this = this.method ? receiver : (scope?.['this'] ?? scope);\n const f = this.method ? receiver?.[method] : receiver;\n const args = this.arguments ?? [];\n const argValues = args.map((a) => a?.evaluate(scope));\n return f?.apply?.(_this, argValues);\n },\n getIds(idents) {\n this.receiver.getIds(idents);\n this.arguments?.forEach((a) => a?.getIds(idents));\n return idents;\n },\n };\n }\n\n paren(e: Expression): Expression {\n return e;\n }\n\n index(e: Expression, a: Expression): Index {\n return {\n type: 'Index',\n receiver: e,\n argument: a,\n evaluate(scope) {\n return this.receiver.evaluate(scope)?.[this.argument.evaluate(scope)];\n },\n getIds(idents) {\n this.receiver.getIds(idents);\n return idents;\n },\n };\n }\n\n ternary(c: Expression, t: Expression, f: Expression): Ternary {\n return {\n type: 'Ternary',\n condition: c,\n trueExpr: t,\n falseExpr: f,\n evaluate(scope) {\n const c = this.condition.evaluate(scope);\n if (c) {\n return this.trueExpr.evaluate(scope);\n } else {\n return this.falseExpr.evaluate(scope);\n }\n },\n getIds(idents) {\n this.condition.getIds(idents);\n this.trueExpr.getIds(idents);\n this.falseExpr.getIds(idents);\n return idents;\n },\n };\n }\n\n map(entries: {[key: string]: Expression} | undefined): Map {\n return {\n type: 'Map',\n entries: entries,\n evaluate(scope) {\n const map = {};\n if (entries && this.entries) {\n for (const key in entries) {\n const val = this.entries[key];\n if (val) {\n (map as any)[key] = val.evaluate(scope);\n }\n }\n }\n return map;\n },\n getIds(idents) {\n if (entries && this.entries) {\n for (const key in entries) {\n const val = this.entries[key];\n if (val) {\n val.getIds(idents);\n }\n }\n }\n return idents;\n },\n };\n }\n\n // TODO(justinfagnani): if the list is deeply literal\n list(l: Array<Expression> | undefined): List {\n return {\n type: 'List',\n items: l,\n evaluate(scope) {\n return this.items?.map((a) => a?.evaluate(scope));\n },\n getIds(idents) {\n this.items?.forEach((i) => i?.getIds(idents));\n return idents;\n },\n };\n }\n\n arrowFunction(params: string[], body: Expression): Expression {\n return {\n type: 'ArrowFunction',\n params,\n body,\n evaluate(scope) {\n const params = this.params;\n const body = this.body;\n return function (...args: any[]) {\n // Create a nested scope for the function body with a proxy to getting\n // and setting parameters on a paramsObj, and setting other\n // identifiers on the scope. Without a proxy, attempting to set\n // properties on the outer scope would actually set them on the\n // inner scope due to JavaScript's assignment semantics.\n const paramsObj = fromEntries(params.map((p, i) => [p, args[i]]));\n const newScope = new Proxy(scope ?? {}, {\n set(target, prop, value) {\n if (hasOwn(paramsObj, prop)) {\n paramsObj[prop as string] = value;\n }\n return (target[prop as string] = value);\n },\n get(target, prop) {\n if (hasOwn(paramsObj, prop)) {\n return paramsObj[prop as string];\n }\n return target[prop as string];\n },\n });\n return body.evaluate(newScope);\n };\n },\n getIds(idents) {\n // Only return the _free_ variables in the body. Since arrow function\n // parameters are the only way to introduce new variable names, we can\n // assume that any variable in the body that isn't a parameter is free.\n return this.body\n .getIds(idents)\n .filter((id) => !this.params.includes(id));\n },\n };\n }\n}\n","import { createContext } from '@lit/context';\n\nimport type { QtiContext } from '@qti-components/base';\nimport type { transformTestApi } from '@qti-components/transformers';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\n\n/**\n * Defined here, and re-exported by the navigation mixin under the same name, so this file imports\n * nothing from the mixin: the mixin imports the components that consume this context, and a type\n * import counts as a dependency for madge.\n */\nexport type PostLoadTestTransformCallback = (\n transformer: transformTestApi,\n testElement: QtiAssessmentTest\n) => transformTestApi | Promise<transformTestApi>;\n\n/**\n * What the components inside a test need from the `qti-test` that contains them: the things a host\n * put on it, and the element to query. Provided by `qti-test` about itself.\n *\n * It is context and not `closest('qti-test')` because a request crosses shadow roots and `closest`\n * stops at the first one, so a navigation or container a host renders inside its own component\n * would never find its test. Internal on purpose: not exported from the package, and not API.\n */\nexport interface TestHost extends HTMLElement {\n qtiContext: QtiContext;\n postLoadTestTransformCallback: PostLoadTestTransformCallback | null;\n}\n\nexport const testHostContext = createContext<TestHost>(Symbol('testHost'));\n","import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `cito-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the name this event had before it became public. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'cito-test-navigate': CustomEvent<NavigationTarget>;\n 'cito-test-end-attempt': CustomEvent<unknown>;\n 'cito-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'cito-test-switch-view': CustomEvent<View>;\n 'cito-test-navigated': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-started': CustomEvent<NavigationTarget>;\n 'cito-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'cito-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `cito-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'cito-test-state-changed': CustomEvent<QtiTestState>;\n 'cito-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'cito-test-end-reached': CustomEvent<Record<string, never>>;\n 'cito-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'cito-test-navigate': { kind: 'request', scope: 'test', deprecated: 'qti-request-navigation' },\n 'cito-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'test-end-attempt' },\n 'cito-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'test-update-outcome-variable' },\n 'cito-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'on-test-switch-view' },\n 'cito-test-navigated': { kind: 'notification', scope: 'test' },\n 'cito-test-navigation-started': {\n kind: 'notification',\n scope: 'test',\n deprecated: 'qti-navigation-loading-started'\n },\n 'cito-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'qti-navigation-error' },\n 'cito-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'qti-test-loaded' },\n 'cito-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'qti-assessment-test-connected' },\n 'cito-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'qti-state-changed' },\n 'cito-test-items-skipped': { kind: 'notification', scope: 'test' },\n 'cito-test-end-reached': { kind: 'notification', scope: 'test' },\n 'cito-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'qti-assessment-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n","import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { testContext } from '@qti-components/base';\n\nimport type { TestContext } from '@qti-components/base';\n\n// https://www.imsglobal.org/sites/default/files/spec/qti/v3/info/index.html#Root_AssessmentSection\n\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\nexport class QtiAssessmentSection extends LitElement {\n @property({ type: String }) identifier: string;\n @property({ type: String }) required: string;\n @property({ type: Boolean, converter: stringToBooleanConverter }) fixed: boolean;\n\n override get title(): string {\n return this.#title;\n }\n override set title(value: string) {\n this.#title = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n @property({ type: Boolean, converter: stringToBooleanConverter }) visible: boolean;\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'keep-together' }) keepTogether: boolean;\n @property({ type: String, attribute: 'navigation-mode' }) navigationMode?: 'linear' | 'nonlinear';\n @property({ type: String, attribute: 'submission-mode' }) submissionMode?: 'individual' | 'simultaneous';\n\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #title = '';\n\n override async connectedCallback(): Promise<void> {\n this.#title = this.getAttribute('title') || '';\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(\n new Event('qti-assessment-section-connected', {\n bubbles: true,\n composed: true\n })\n );\n }\n\n override render() {\n return html`<slot name=\"qti-rubric-block\"></slot><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-section': QtiAssessmentSection;\n }\n}\n","import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { testContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestContext } from '@qti-components/base';\n\nexport class QtiAssessmentTest extends LitElement {\n @property({ type: String }) identifier: string;\n @property({ type: String })\n override get title(): string {\n return this.#title;\n }\n override set title(value: string) {\n this.#title = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n #title = '';\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n dispatchPublic(this, 'cito-test-loaded', this);\n }\n\n override render() {\n return html` <slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-assessment-test': QtiAssessmentTest;\n }\n}\n\ndeclare module '../../public-events' {\n interface PublicEventMap {\n 'cito-test-loaded': CustomEvent<QtiAssessmentTest>;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { evaluateBooleanChild } from '../../internal/evaluate-condition';\n\nimport type { Condition } from '../../internal/evaluate-condition';\n\n/**\n * @summary The qti-branch-rule element jumps the test forward to `target` when its expression is true.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.branch-rule\n *\n * A child of `qti-test-part`, `qti-assessment-section` or `qti-assessment-item-ref`. It is\n * evaluated after the parent has been presented; the first rule whose expression is true wins.\n * Branch rules only apply in linear navigation mode. An expression that cannot be evaluated does\n * not branch.\n *\n * @attr {string} target - Required. The identifier of an item ref, section or test part ahead of\n * the parent, or one of the reserved targets `EXIT_SECTION`, `EXIT_TESTPART`, `EXIT_TEST`.\n *\n * @slot - The boolean expression.\n */\nexport class QtiBranchRule extends LitElement implements Condition {\n static readonly EXIT_SECTION = 'EXIT_SECTION';\n static readonly EXIT_TESTPART = 'EXIT_TESTPART';\n static readonly EXIT_TEST = 'EXIT_TEST';\n\n static override styles = css`\n :host {\n display: none;\n }\n `;\n\n @property({ type: String }) target = '';\n\n /** `true` when the test should jump to `target`. */\n public evaluate(): boolean {\n return evaluateBooleanChild(this, false);\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-branch-rule': QtiBranchRule;\n }\n}\n","/** An element that evaluates to a boolean: a `qti-pre-condition` or `qti-branch-rule`. */\nexport interface Condition extends Element {\n evaluate(): boolean;\n}\n\n/** The expression a condition wraps: any QtiExpression, which answers with `calculate()`. */\ninterface Calculable extends Element {\n calculate(): unknown;\n}\n\n/**\n * Evaluate the single expression child of a pre-condition or branch rule. NULL counts as false (a\n * variable that does not resolve gives NULL, so a misspelled `ITEMREF.VAR` is false, not an error).\n *\n * `onError` is what an expression that throws (or has no expression child) means: a pre-condition fails open (`true`,\n * the item is shown) so a malformed package never hides content silently; a branch rule does not\n * branch (`false`).\n */\nexport function evaluateBooleanChild(element: Element, onError: boolean): boolean {\n const expression = element.firstElementChild as Calculable | null;\n if (!expression || typeof expression.calculate !== 'function') {\n console.warn(`<${element.localName}> has no evaluable expression child`, element);\n return onError;\n }\n try {\n const result = expression.calculate();\n return result === true || result === 'true';\n } catch (error) {\n console.warn(`<${element.localName}> could not evaluate its expression`, error);\n return onError;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\n// Converter function to interpret \"true\" and \"false\" as booleans\nconst stringToBooleanConverter = {\n fromAttribute(value: string): boolean {\n return value === 'true';\n },\n toAttribute(value: boolean): string {\n return value ? 'true' : 'false';\n }\n};\n\n/**\n * @summary The qti-item-session-control element contains configurations relating to flow of test sessions.\n * @documentation https://www.imsglobal.org/sites/default/files/spec/qti/v3/info/imsqti_asi_v3p0p1_infomodel_v1p0.html#Derived_ItemSessionControl\n */\nexport class QtiItemSessionControl extends LitElement {\n @property({ type: Number, attribute: 'max-attempts' })\n maxAttempts: number = 1;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'show-feedback' })\n showFeedback = false;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'allow-review' })\n allowReview = true;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'show-solution' })\n showSolution = false;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'allow-comment' })\n allowComment = false;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'allow-skipping' })\n allowSkipping = true;\n\n @property({ type: Boolean, converter: stringToBooleanConverter, attribute: 'validate-responses' })\n validateResponses = false;\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(\n new CustomEvent('qti-item-session-control-connected', {\n detail: this,\n bubbles: true,\n composed: true\n })\n );\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-item-session-control': QtiItemSessionControl;\n }\n}\n","import type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\n\n/**\n * How the test-level expressions choose which item references they read.\n *\n * `qti-test-variables` and `qti-number-selected` select over the same set with\n * the same attributes, so the rules live here rather than in either element.\n */\n\n/** `category`, `include-category` and `exclude-category` are space-separated lists. */\nexport const categoryList = (value: string | null | undefined): string[] => value?.split(/\\s+/).filter(Boolean) ?? [];\n\nexport interface ItemRefSelection {\n /** Only item refs inside the section with this identifier; every section when absent. */\n sectionIdentifier?: string | null;\n includeCategories: string[];\n excludeCategories: string[];\n}\n\n/** Read the selection attributes an expression element carries. */\nexport const selectionFrom = (element: Element): ItemRefSelection => ({\n sectionIdentifier: element.getAttribute('section-identifier'),\n includeCategories: categoryList(element.getAttribute('include-category')),\n excludeCategories: categoryList(element.getAttribute('exclude-category'))\n});\n\n/**\n * The item refs of a test that a selection covers.\n *\n * Both category attributes may be present, and then both have to hold: an item\n * ref qualifies when it carries one of the included categories and none of the\n * excluded ones. Its own `category` is a list too, so matching any entry of it\n * is enough.\n */\nexport const selectItemRefs = (\n testElement: QtiAssessmentTest,\n { sectionIdentifier, includeCategories, excludeCategories }: ItemRefSelection\n): QtiAssessmentItemRef[] => {\n const scopes = sectionIdentifier\n ? Array.from(testElement.querySelectorAll(`qti-assessment-section[identifier=\"${CSS.escape(sectionIdentifier)}\"]`))\n : [testElement];\n if (scopes.length === 0) {\n console.warn(`no qti-assessment-section with identifier \"${sectionIdentifier}\"`);\n return [];\n }\n\n return scopes\n .flatMap(scope => Array.from(scope.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref')))\n .filter(itemRef => {\n const categories = categoryList(itemRef.category);\n if (includeCategories.length > 0 && !categories.some(c => includeCategories.includes(c))) {\n return false;\n }\n if (excludeCategories.length > 0 && categories.some(c => excludeCategories.includes(c))) {\n return false;\n }\n return true;\n });\n};\n","import { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\n\n/**\n * @summary The qti-number-selected expression counts the item refs selected for the test.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.number-selected\n *\n * Outcome processing only. `section-identifier`, `include-category` and\n * `exclude-category` narrow which item references are counted; with none of\n * them it is every item reference in the test.\n *\n * The count comes from the item refs in the document rather than the test\n * context, so it is the same set `qti-test-variables` aggregates over — and it\n * is right before any item has been attempted.\n */\nexport class QtiNumberSelected extends QtiExpression<number> {\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qti-assessment-test-connected` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult(): number {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-number-selected: no enclosing qti-assessment-test, nothing to count');\n return 0;\n }\n\n return selectItemRefs(testElement, selectionFrom(this)).length;\n }\n\n public override calculate(): number {\n return this.getResult();\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-number-selected': QtiNumberSelected;\n }\n}\n","import { css, html, LitElement } from 'lit';\n\nimport { evaluateBooleanChild } from '../../internal/evaluate-condition';\n\nimport type { Condition } from '../../internal/evaluate-condition';\n\n/**\n * @summary The qti-pre-condition element holds one boolean expression that decides whether its parent is presented.\n * @documentation https://www.imsglobal.org/spec/qti/v3p0/impl#h.pre-condition\n *\n * A child of `qti-test-part`, `qti-assessment-section` or `qti-assessment-item-ref`. When the test\n * is about to present the parent and the expression is false (or NULL), the parent is skipped.\n * Pre-conditions only apply in linear navigation mode; in nonlinear mode they are ignored.\n *\n * Evaluation is pull-based, like every expression: the test calls `evaluate()` when it needs the\n * answer. An expression that cannot be evaluated fails open, so the parent is shown.\n *\n * @slot - The boolean expression.\n */\nexport class QtiPreCondition extends LitElement implements Condition {\n static override styles = css`\n :host {\n display: none;\n }\n `;\n\n /** `true` when the parent may be presented. */\n public evaluate(): boolean {\n return evaluateBooleanChild(this, true);\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-pre-condition': QtiPreCondition;\n }\n}\n","import { css, html, LitElement } from 'lit';\n\nimport { QtiExitTestSignal } from '@qti-components/base';\n\nimport type { QtiRuleBase } from '@qti-components/base';\n\nexport class QtiOutcomeProcessing extends LitElement {\n static override styles = [\n css`\n :host {\n display: none;\n }\n `\n ];\n\n override render() {\n return html`<slot></slot>`;\n }\n\n public process() {\n const logic = new QtiOutcomeProcessingProcessor();\n const rules = [...this.children] as unknown as QtiRuleBase[];\n logic.process(rules);\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-outcome-processing': QtiOutcomeProcessing;\n }\n}\n\nexport class QtiOutcomeProcessingProcessor {\n public process(rules: QtiRuleBase[]) {\n try {\n for (const rule of rules) {\n rule.process();\n }\n } catch (error) {\n // `qti-exit-test` ends the run from wherever it sits, however deeply\n // nested. Reaching here is the rule doing its job; anything else is a\n // real failure and rethrows.\n if (!(error instanceof QtiExitTestSignal)) throw error;\n }\n }\n}\n","import { css, html } from 'lit';\n\nimport { QtiModalFeedback } from '@qti-components/elements/elements';\n\nexport class QtiTestFeedback extends QtiModalFeedback {\n static override styles = css`\n :host {\n color: gray;\n }\n `;\n override render() {\n return html``;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-feedback': QtiTestFeedback;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nexport class QtiTestPart extends LitElement {\n @property({ type: String }) identifier: string = '';\n override get title(): string {\n return this.#title;\n }\n override set title(value: string) {\n this.#title = value;\n this.removeAttribute('title');\n this.setAttribute('data-title', value);\n }\n @property({ type: String }) class: string = '';\n\n @property({ type: String, attribute: 'navigation-mode' })\n navigationMode: 'linear' | 'nonlinear' = 'nonlinear';\n\n @property({ type: String, attribute: 'submission-mode' })\n submissionMode: 'individual' | 'simultaneous' = 'individual';\n\n #title = '';\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(\n new Event('qti-test-part-connected', {\n bubbles: true,\n composed: true\n })\n );\n }\n\n override render() {\n return html` <slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-part': QtiTestPart;\n }\n}\n","import { consume } from '@lit/context';\n\nimport { testContext } from '@qti-components/base';\nimport { QtiExpression } from '@qti-components/base';\n\nimport { selectItemRefs, selectionFrom } from '../../internal/item-ref-selection';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { TestContext } from '@qti-components/base';\nimport type { QtiExpressionBase } from '@qti-components/base';\n\nexport class QtiTestVariables extends QtiExpression<number> {\n @consume({ context: testContext, subscribe: true })\n public _testContext?: TestContext;\n\n #connectedTest: QtiAssessmentTest | null = null;\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => (this.#connectedTest = e.detail));\n }\n\n /**\n * `qti-assessment-test-connected` bubbles *up* from the test element, and this\n * expression lives inside that test's `qti-outcome-processing` — so the\n * listener above only ever fires for a test handed to us directly (a test\n * harness). Walking up the tree is what resolves the test in a real document.\n */\n get #testElement(): QtiAssessmentTest | null {\n return this.#connectedTest ?? this.closest<QtiAssessmentTest>('qti-assessment-test');\n }\n\n public override getResult() {\n const testElement = this.#testElement;\n if (!testElement) {\n console.warn('qti-test-variables: no enclosing qti-assessment-test, nothing to aggregate');\n return 0;\n }\n\n const weightIdentifier = this.getAttribute('weight-identifier') ?? '';\n const itemVariable = this.getAttribute('variable-identifier');\n\n const includedItems = selectItemRefs(testElement, selectionFrom(this)).map(itemRef => ({\n item: itemRef.identifier,\n weight: (weightIdentifier ? itemRef.weights.get(weightIdentifier) : undefined) ?? 1\n }));\n\n const logic = new QtiTestVariablesExpression(this._testContext, itemVariable, includedItems);\n const value = logic.calculate();\n return value;\n }\n\n public override calculate() {\n return this.getResult();\n }\n}\n\nexport class QtiTestVariablesExpression implements QtiExpressionBase<number> {\n constructor(\n private testContext: TestContext,\n private itemVariable: string,\n private includedItems: { item: string; weight: number }[]\n ) {}\n\n calculate(): number {\n const items = this.testContext?.items ?? [];\n let total = 0;\n const uniqueItems = [...new Set(this.includedItems.map(item => item.item))];\n items.forEach(item => {\n if (uniqueItems.includes(item.identifier)) {\n const variable = item.variables.find(vr => vr.identifier === this.itemVariable);\n const weight = this.includedItems.find(i => i.item === item.identifier)?.weight ?? 1;\n if (variable) {\n // An unscored item carries a non-numeric value; counting it as NaN\n // would poison the whole total rather than just its own contribution.\n const value = Number(variable.value);\n if (!Number.isNaN(value)) {\n total += value * weight;\n }\n }\n }\n });\n return total;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test-variables': QtiTestVariables;\n }\n}\n","/**\n * Everything a host needs to persist to resume a candidate's test session, and nothing else.\n *\n * Read it from `qtiTest.state` or the `qti-state-changed` event, store it wherever you like —\n * a database, `localStorage`, `sessionStorage` — and assign it back to `qtiTest.state` to resume.\n *\n * Deliberately not here:\n * - declaration metadata (`baseType`, `cardinality`, `correctResponse`, `mapping`, …): it comes\n * from the item XML on every load, and persisting the answer key with the candidate's data is\n * both bloat and a leak;\n * - `configContext` and `qtiContext`: inputs the host supplies on every load, not session state.\n * The shuffle `seed` in particular must be passed in again, or the restored order changes;\n * - `view`: a role the host decides, not something the candidate produced;\n * - anything computed — scores per section, `done`, `active` — which is rederived from this.\n */\nexport interface QtiTestState {\n /** Bumped on any incompatible change to this shape. A state with another version is ignored. */\n version: 1;\n test: {\n items: QtiTestStateItem[];\n /** Test-level outcome values. Only outcomes the test declares are restored. */\n outcomes: QtiTestStateValue[];\n };\n session: QtiTestStateSession;\n}\n\nexport interface QtiTestStateItem {\n /** The `qti-assessment-item-ref` identifier. */\n identifier: string;\n variables: (QtiTestStateValue & { type?: 'response' | 'outcome' | 'template' | 'context' })[];\n /** Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`. */\n state?: Record<string, string | null>;\n}\n\nexport interface QtiTestStateValue {\n identifier: string;\n value: string | string[] | null;\n}\n\n/** Where the candidate is. */\nexport interface QtiTestStateSession {\n navPartId?: string | null;\n navSectionId?: string | null;\n navItemRefId?: string | null;\n}\n\nexport const QTI_TEST_STATE_VERSION = 1;\n","import { ContextProvider, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { state } from 'lit/decorators.js';\n\nimport { configContext, qtiContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { TestNavigationMixin, TestViewMixin } from '../../mixins';\nimport { TestBaseMixin } from '../../mixins/test-base';\nimport { TestProcessingMixin } from '../../mixins/test-processing.mixin';\nimport { TestStateMixin } from '../../mixins/test-state.mixin';\n\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { IQtiTest } from '../../types/iqti-test';\n\n/**\n * `<qti-test>` is a custom element designed for rendering and interacting with QTI (Question and Test Interoperability) tests.\n *\n * This component leverages several mixins to provide functionality for loading, navigating, processing, and displaying QTI test assessments.\n *\n * ### Example Usage\n *\n * Minimal example including navigation:\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container test-url=\"./path/to/assessment.xml\"></test-container>\n * <nav class=\"flex\">\n * <test-prev></test-prev>\n * <test-next></test-next>\n * </nav>\n * </test-navigation>\n * </qti-test>\n * ```\n *\n * Use the following file structure\n * A qti-test loads a QTI3.0 assessmenttest.xml file from a package folder.\n *\n * ```plaintext\n * Root/\n * ├── index.html\n * └── /assets/api/examples/\n * ├── assessmenttest.xml\n * └── imsmanifest.xml\n *\n * ```\n *\n * ### Test components\n *\n * Use test components inside the qti-test component for added functionality.\n * ### Test next\n * `<test-next> | TestNext`\n *\n * ### Test prev\n *\n * `<test-prev> | TestPrev`\n * ### Test components\n *\n * You can use normal class names to style the elements.\n * And you can use the `test-prev` and `test-next` elements to navigate through the test.\n *\n * @event qti-state-changed - The candidate's persistable state changed. `detail` is a `QtiTestState`; assign it back to `state` to resume.\n * @event qti-test-context-updated - Deprecated: listen to `qti-state-changed` to persist a session. `detail` is the full test context, including declaration metadata and the answer key. Removed in the next major.\n */\n\nexport class QtiTest extends TestNavigationMixin(\n TestViewMixin(TestProcessingMixin(TestStateMixin(TestBaseMixin(LitElement))))\n) {\n // TODO: Properly implement IQtiTest interface\n // export class QtiTest extends TestLoaderMixin(TestNavigationMixin(TestViewMixin(TestBase))) {\n\n constructor() {\n super();\n // The components inside find their test through this, across shadow roots (see TestHost).\n new ContextProvider(this, { context: testHostContext, initialValue: this });\n }\n\n @state()\n @provide({ context: configContext })\n public configContext: ConfigContext = {};\n\n /**\n * Who is taking which test, and the optional shuffle `seed`. Provided here, at the test, so\n * everything inside reads one value: the test-container shuffling the item order, the test\n * shuffling interactions as it navigates, and the expressions that read `QTI_CONTEXT`.\n *\n * Pass the same `seed` when resuming a session, or the order comes back different. Replace the\n * object, do not mutate it: an in-place change does not notify the components inside.\n *\n * `test-navigation.qtiContext` is an alias of this.\n */\n @state()\n @provide({ context: qtiContext })\n public qtiContext: QtiContext = {\n QTI_CONTEXT: {\n testIdentifier: '',\n candidateIdentifier: '',\n environmentIdentifier: 'default'\n }\n };\n\n /**\n * Renders the component's template.\n * Provides a default `<slot>` for content projection.\n */\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n await this.updateComplete;\n this.dispatchEvent(new CustomEvent('qti-test-connected', { detail: this }));\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'qti-test': QtiTest;\n }\n}\n","import { property } from 'lit/decorators.js';\n\nimport { qtiTransformItem } from '@qti-components/transformers';\n\nimport { idOf, resolveFirstItem, resolveNextItem } from '../internal/item-sequencing';\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { QtiAssessmentStimulusRefConnectedEvent } from '@qti-components/elements';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { transformItemApi, transformTestApi } from '@qti-components/transformers';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentSection } from '../components/qti-assessment-section/qti-assessment-section';\nimport type { QtiTestPart } from '../components/qti-test-part/qti-test-part';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { TestContainer } from '../components/test-container/test-container';\nimport type { PostLoadTestTransformCallback } from '../internal/test-host.context';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport type PostLoadTransformCallback = (\n transformer: transformItemApi,\n itemRef: QtiAssessmentItemRef\n) => transformItemApi | Promise<transformItemApi>;\n\nexport type { PostLoadTestTransformCallback };\n\nexport interface NavigationError {\n message: string;\n details?: any;\n itemId?: string;\n sectionId?: string;\n}\n\n/**\n * Exactly what this mixin adds. `IQtiTest` composes it (see ../types/iqti-test, which\n * re-exports it), and `TestNavigationClass` below `implements` it, so the interface and the\n * class cannot drift apart.\n *\n * This was `declare class TestNavigationInterface {}` — EMPTY — so the returned\n * `Constructor<TestNavigationInterface> & T` added nothing and every member the mixin\n * contributes was erased from the public type. `QtiTest` looked as though it had no\n * `navigate` or `postLoadTransformCallback`, and consumers had to intersect the class with\n * `IQtiTest` by hand to describe one element.\n *\n * `showLoadingIndicators` and `retryNavigation` used to be listed on the `IQtiTest` side with\n * no implementation anywhere in the repo, so calling `retryNavigation()` would have thrown.\n * They are gone rather than stubbed: there was no behaviour to preserve.\n */\nexport interface ITestNavigationMixin {\n navigate: 'item' | 'section' | null;\n requestTimeout: number;\n postLoadTransformCallback: PostLoadTransformCallback | null;\n postLoadTestTransformCallback: PostLoadTestTransformCallback | null;\n navigateTo(type: 'item' | 'section', id?: string): void;\n getLoadingProgress(): {\n expectedItems: number;\n connectedItems: number;\n expectedStimulus: number;\n loadedStimulus: number;\n isComplete: boolean;\n };\n}\n\n/**\n * Navigation mixin for QTI test components\n *\n * Provides comprehensive navigation functionality with:\n * - Efficient item/section loading with AbortController support\n * - Stimulus reference coordination and duplicate prevention\n * - Proper event timing and state management\n * - Error handling and edge case coverage\n */\nexport const TestNavigationMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestNavigationClass extends superClass implements ITestNavigationMixin {\n @property({ type: String }) navigate: 'item' | 'section' | null = null;\n @property({ type: Number }) requestTimeout: number = 30000;\n @property({ attribute: false }) postLoadTransformCallback: PostLoadTransformCallback | null = null;\n @property({ attribute: false }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;\n\n public _testElement: QtiAssessmentTest;\n\n // Navigation state tracking\n private _activeController: AbortController | null = null;\n private _loadResults: any[] = [];\n private _navigationId = 0;\n\n // Simple loading progress tracking\n private _loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Track loaded/loading stimulus hrefs to prevent duplicates\n private _loadedStimulusHrefs = new Set<string>();\n private _loadingStimulusHrefs = new Set<string>();\n\n constructor(...args: any[]) {\n super(...args);\n this._bindEventHandlers();\n }\n\n // ===========================================\n // PUBLIC API\n // ===========================================\n\n /**\n * Navigate to a specific item or section\n * @param type - Navigation type ('item' or 'section')\n * @param id - Target identifier (optional, falls back to the current position, or the first one before there is any)\n */\n public navigateTo(type: 'item' | 'section', id?: string): void {\n const targetId = id || this._getDefaultNavigationId(type);\n\n if (targetId) {\n dispatchPublic(this, 'cito-test-navigate', { type, id: targetId });\n }\n }\n\n // ===========================================\n // EVENT HANDLER SETUP\n // ===========================================\n\n private _bindEventHandlers(): void {\n listenPublic(this, 'cito-test-navigate', this._handleNavigationRequest.bind(this));\n listenPublic(this, 'cito-test-loaded', this._handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this._handleItemConnected.bind(this));\n this.addEventListener('qti-assessment-stimulus-ref-connected', this._handleStimulusRefConnected.bind(this));\n }\n\n private _handleTestConnected(e: CustomEvent<QtiAssessmentTest>): void {\n this._testElement = e.detail;\n this._initializeNavigation();\n }\n\n /**\n * Handle item connection events - track connected items and discover stimulus references\n */\n private _handleItemConnected(e: CustomEvent<QtiAssessmentItemRef>): void {\n const itemRef = e.detail;\n\n // Increment connected items count\n this._loadingState.connectedItems++;\n\n // Count stimulus references in this item and add to expected\n const stimulusRefs = itemRef.querySelectorAll('qti-assessment-stimulus-ref');\n this._loadingState.expectedStimulus += stimulusRefs.length;\n\n this._checkLoadingComplete();\n }\n\n /**\n * Handle stimulus reference connection events with duplicate prevention\n */\n private async _handleStimulusRefConnected(e: QtiAssessmentStimulusRefConnectedEvent): Promise<void> {\n e.preventDefault();\n\n const { element, item } = e;\n console.info('Stimulus ref connected:', {\n identifier: element.identifier,\n href: element.href,\n item: item.identifier\n });\n\n // Check if this stimulus href is already loaded or currently loading\n if (this._loadedStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loaded, skipping:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n if (this._loadingStimulusHrefs.has(element.href)) {\n console.info('Stimulus already loading, skipping duplicate:', element.href);\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n return;\n }\n\n // Mark as currently loading\n this._loadingStimulusHrefs.add(element.href);\n console.info('Starting stimulus load:', element.href);\n\n try {\n await this._loadStimulusRef(element, item);\n this._loadedStimulusHrefs.add(element.href);\n this._loadingState.loadedStimulus++;\n console.info('Stimulus loaded successfully:', element.href);\n this._checkLoadingComplete();\n } catch (error) {\n if (error.name !== 'AbortError') {\n console.warn(`Failed to load stimulus ${element.identifier}:`, error);\n }\n // Still count as \"processed\" even if failed to avoid hanging\n this._loadingState.loadedStimulus++;\n this._checkLoadingComplete();\n } finally {\n // Remove from loading set regardless of outcome\n this._loadingStimulusHrefs.delete(element.href);\n }\n }\n\n // ===========================================\n // NAVIGATION FLOW\n // ===========================================\n\n private _getDefaultNavigationId(type: 'item' | 'section'): string | undefined {\n if (type === 'section') {\n return (\n this.sessionContext?.navSectionId ??\n this._testElement?.querySelector<QtiAssessmentSection>('qti-assessment-section')?.identifier\n );\n }\n return (\n this.sessionContext?.navItemRefId ??\n this._testElement?.querySelector<QtiAssessmentItemRef>('qti-assessment-item-ref')?.identifier\n );\n }\n\n private _initializeNavigation(): void {\n if (!this.navigate) return;\n\n let id = this._getDefaultNavigationId(this.navigate);\n if (this.navigate === 'item' && this._testElement && !this.sessionContext?.navItemRefId) {\n // a fresh start: the first item of a linear part may itself have a false pre-condition\n const refs = [...this._testElement.querySelectorAll('qti-assessment-item-ref')];\n if (refs[0]?.closest('qti-test-part')?.getAttribute('navigation-mode') === 'linear') {\n const first = resolveFirstItem(refs);\n if (first.skipped.length) dispatchPublic(this, 'cito-test-items-skipped', { ids: first.skipped });\n if (first.id === null) {\n dispatchPublic(this, 'cito-test-end-reached', {});\n return;\n }\n id = first.id;\n }\n }\n if (id) {\n this.navigateTo(this.navigate, id);\n }\n }\n\n private _isLinearNavigationRestricted(type: 'item' | 'section', targetId: string): boolean {\n const currentItemId = this.sessionContext?.navItemRefId;\n if (!currentItemId) return false;\n\n // Never restrict navigating to the same item\n if (type === 'item' && targetId === currentItemId) return false;\n\n const currentItemRef = this._testElement?.querySelector(`qti-assessment-item-ref[identifier=\"${currentItemId}\"]`);\n if (!currentItemRef) return false;\n\n const section = currentItemRef.closest('qti-assessment-section') as QtiAssessmentSection;\n const testPart = currentItemRef.closest('qti-test-part') as QtiTestPart;\n\n const navigationMode = (section?.navigationMode ||\n section?.getAttribute('navigation-mode') ||\n testPart?.navigationMode ||\n testPart?.getAttribute('navigation-mode') ||\n 'nonlinear') as string;\n\n if (navigationMode !== 'linear') return false;\n\n const allItemRefs = Array.from(\n this._testElement?.querySelectorAll('qti-assessment-item-ref') || []\n ) as QtiAssessmentItemRef[];\n const currentIndex = allItemRefs.findIndex(ref => ref.identifier === currentItemId);\n\n if (type === 'item') {\n const targetIndex = allItemRefs.findIndex(ref => ref.identifier === targetId);\n if (targetIndex === -1 || currentIndex === -1) return false;\n\n // Only allow moving to the next item in linear mode\n return targetIndex !== currentIndex + 1;\n }\n\n // Sections are generally restricted in linear mode unless we are moving to the next one\n return true;\n }\n\n /**\n * A \"next\" step in a linear test part (a request for item i+1 while item i is active) goes\n * through the branch rules and pre-conditions. Deep links, item links and nonlinear parts are\n * left alone: the spec ignores both in nonlinear mode.\n *\n * @returns the item to present instead, `null` when the test has no eligible item left, or\n * `undefined` when the request is not a \"next\" step.\n */\n private _resolveLinearNext(\n type: 'item' | 'section',\n id: string\n ): { id: string | null; skipped: string[] } | undefined {\n if (type !== 'item' || !this._testElement) return undefined;\n\n const refs = [...this._testElement.querySelectorAll('qti-assessment-item-ref')];\n const current = refs.findIndex(ref => idOf(ref) === this.sessionContext?.navItemRefId);\n if (current < 0 || !refs[current + 1] || idOf(refs[current + 1]) !== id) return undefined;\n if (refs[current].closest('qti-test-part')?.getAttribute('navigation-mode') !== 'linear') return undefined;\n\n const next = resolveNextItem(refs, current);\n if (next.id === id) return undefined;\n\n return next;\n }\n\n /**\n * Main navigation request handler with proper lifecycle management\n */\n private async _handleNavigationRequest({ detail }: CustomEvent<{ type: 'item' | 'section'; id: string }>) {\n if (!detail?.id) return;\n\n const resolved = this._resolveLinearNext(detail.type, detail.id);\n if (resolved?.id === null) {\n if (resolved.skipped.length) dispatchPublic(this, 'cito-test-items-skipped', { ids: resolved.skipped });\n dispatchPublic(this, 'cito-test-end-reached', {});\n return;\n }\n const target = resolved?.id ?? detail.id;\n // a resolved jump is not a free choice by the candidate, so the linear restriction does not apply to it\n if (!resolved && this._isLinearNavigationRestricted(detail.type, target)) {\n this._handleNavigationError(new Error('Navigation restricted in linear mode'), detail.type, detail.id);\n return;\n }\n\n this._cancelPreviousNavigation();\n const navigationId = ++this._navigationId;\n const controller = new AbortController();\n\n try {\n this._dispatchLoadingStarted(detail.type, target);\n this._activeController = controller;\n\n await this._executeNavigation(detail.type, target, navigationId, controller);\n // only tell hosts about skipped items once the jump went through\n if (resolved?.skipped.length && navigationId === this._navigationId && !controller.signal.aborted) {\n dispatchPublic(this, 'cito-test-items-skipped', { ids: resolved.skipped });\n }\n } catch (error) {\n this._handleNavigationError(error, detail.type, target);\n } finally {\n if (this._activeController === controller) {\n this._activeController = null;\n }\n this._dispatchLoadingEnded(detail.type, target);\n }\n }\n\n private _handleNavigationError(error: any, type: string, id: string): void {\n if (error.name !== 'AbortError') {\n this._dispatchError(this._createNavigationError(error, type, id));\n }\n }\n\n private async _executeNavigation(\n type: 'item' | 'section',\n id: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n if (type === 'item') {\n await this._navigateToItem(id, navigationId, controller);\n } else {\n await this._navigateToSection(id, navigationId, controller);\n }\n }\n\n /**\n * Navigate to specific item with simple state tracking\n */\n private async _navigateToItem(itemId: string, navigationId: number, controller: AbortController): Promise<void> {\n const itemRef = this._findItemRef(itemId);\n this._updateSessionContext(itemRef, itemId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = 1;\n\n await this._loadItems([itemId], navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults, 'item', itemId);\n }\n\n /**\n * Navigate to section with simple state tracking\n */\n private async _navigateToSection(\n sectionId: string,\n navigationId: number,\n controller: AbortController\n ): Promise<void> {\n const sectionEl = this._findSection(sectionId);\n const navPartId = sectionEl?.closest('qti-test-part')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId: sectionId,\n navItemRefId: null\n };\n\n const itemIds = this._getSectionItemIds(sectionId);\n\n this._resetLoadingState();\n this._loadingState.expectedItems = itemIds.length;\n\n await this._loadItems(itemIds, navigationId, controller);\n await this._waitForLoadingComplete(navigationId, controller);\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n this._dispatchTestLoaded(this._loadResults, 'section', sectionId);\n }\n\n // ===========================================\n // LOADING STATE MANAGEMENT\n // ===========================================\n\n /**\n * Reset loading state for new navigation\n */\n private _resetLoadingState(): void {\n this._loadingState = {\n expectedItems: 0,\n connectedItems: 0,\n expectedStimulus: 0,\n loadedStimulus: 0,\n isComplete: false\n };\n\n // Clear stimulus tracking - start fresh for new navigation\n this._loadedStimulusHrefs.clear();\n this._loadingStimulusHrefs.clear();\n }\n\n /**\n * Check if loading is complete and dispatch events accordingly\n */\n private _checkLoadingComplete(): void {\n const allItemsConnected = this._loadingState.connectedItems >= this._loadingState.expectedItems;\n const allStimulusLoaded = this._loadingState.loadedStimulus >= this._loadingState.expectedStimulus;\n\n if (allItemsConnected && allStimulusLoaded && !this._loadingState.isComplete) {\n this._loadingState.isComplete = true;\n }\n }\n\n /**\n * Wait for loading to complete with simple polling\n */\n private async _waitForLoadingComplete(navigationId: number, controller: AbortController): Promise<void> {\n while (!this._loadingState.isComplete) {\n if (this._isStaleNavigation(navigationId, controller)) return;\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n }\n\n /**\n * Get current loading progress for external consumption\n */\n public getLoadingProgress() {\n return { ...this._loadingState };\n }\n\n /**\n * Load stimulus reference with simple tracking\n */\n private async _loadStimulusRef(\n element: { identifier: string; href: string },\n item: QtiAssessmentItem\n ): Promise<void> {\n console.info('Loading stimulus:', element.href);\n const stimulus = await this._loadStimulus(element.href);\n console.info('Stimulus loaded, applying content:', stimulus ? 'has content' : 'no content');\n this._applyStimulusContent(stimulus, element, item);\n }\n\n private _applyStimulusContent(\n stimulus: DocumentFragment | null,\n element: { identifier: string },\n item: QtiAssessmentItem\n ): void {\n if (!stimulus) {\n console.warn('No stimulus content to apply');\n return;\n }\n\n // Place the whole qti-assessment-stimulus, not just its body: its `lang` is what the stimulus\n // content inherits its language from.\n const root = stimulus.querySelector('qti-assessment-stimulus');\n\n if (!root) {\n console.warn('No qti-assessment-stimulus element found in stimulus');\n return;\n }\n\n // Try multiple target selection strategies\n let targets: Element[] = [];\n\n // Strategy 1: Search inside the actual item element first.\n // This keeps stimulus placement working when items are rendered in a shadow root.\n const specificTarget = item.querySelector(`[data-stimulus-idref=\"${element.identifier}\"]`);\n\n if (specificTarget) {\n targets.push(specificTarget);\n console.info('Found specific target:', specificTarget);\n } else {\n // Strategy 2: Any element with matching stimulus idref\n const allTargetsWithId = Array.from(this.querySelectorAll(`[data-stimulus-idref=\"${element.identifier}\"]`));\n\n if (allTargetsWithId.length > 0) {\n targets = allTargetsWithId;\n console.info('Found targets by identifier:', allTargetsWithId.length);\n } else {\n // Strategy 3: Any stimulus idref target (fallback)\n const allStimulusTargets = Array.from(this.querySelectorAll('[data-stimulus-idref]'));\n targets = allStimulusTargets;\n console.info('Using fallback targets:', allStimulusTargets.length);\n }\n }\n\n if (targets.length === 0) {\n console.warn('No targets found for stimulus content');\n return;\n }\n\n // Apply content to all targets\n targets.forEach((target, index) => {\n target.innerHTML = '';\n target.append(root.cloneNode(true));\n console.info(`Applied stimulus content to target ${index + 1}/${targets.length}`);\n });\n } // ===========================================\n // LOADING INFRASTRUCTURE\n // ===========================================\n\n /**\n * Cancel previous navigation and clean up all state\n */\n private _cancelPreviousNavigation(): void {\n if (this._activeController) {\n this._activeController.abort();\n console.info('Previous navigation request cancelled');\n }\n\n this._clearNavigationState();\n }\n\n private _clearNavigationState(): void {\n this._clearLoadedItems();\n this._resetLoadingState();\n this._loadResults = [];\n }\n\n /**\n * Load items with simple tracking\n */\n private async _loadItems(itemIds: string[], navigationId: number, controller: AbortController): Promise<void> {\n if (!this._testElement || itemIds.length === 0) return;\n\n const itemRefs = itemIds.map(id => this._findItemRef(id));\n this._clearLoadedItems();\n this._clearStimulusRef();\n\n const results = await Promise.all(itemRefs.map(ref => this._loadSingleItem(ref, navigationId, controller)));\n const validResults = results.filter(Boolean);\n\n if (this._isStaleNavigation(navigationId, controller)) return;\n\n validResults.forEach(({ itemRef, doc }) => {\n if (itemRef && doc) itemRef.xmlDoc = doc;\n });\n\n // Restore per-item state as early as possible (before iframe-based interactions initialize).\n // Some PCIs (including IMS conformance examples) only support restoration via getInstance(state),\n // so the state needs to be present on the provided itemContext at initial render time.\n validResults.forEach(({ itemRef }) => {\n const itemId = itemRef?.identifier;\n if (!itemRef || !itemId) return;\n\n const savedState = this.testContext.items.find(i => i.identifier === itemId)?.state;\n if (savedState === undefined) return;\n\n itemRef.updateComplete.then(() => {\n const assessmentItem = itemRef.assessmentItem as QtiAssessmentItem | null;\n if (!assessmentItem) return;\n assessmentItem.state = savedState;\n });\n });\n\n this._loadResults = validResults;\n }\n\n private async _loadSingleItem(itemRef: QtiAssessmentItemRef, navigationId: number, controller: AbortController) {\n try {\n // The same seed `test-container` shuffled the item order with.\n const seed = this.qtiContext?.QTI_CONTEXT?.seed;\n let transformer = (await qtiTransformItem().load(itemRef.href, controller.signal)).shuffleInteractions(seed);\n\n if (this.postLoadTransformCallback) {\n transformer = await this.postLoadTransformCallback(transformer, itemRef);\n }\n\n if (this._isStaleNavigation(navigationId, controller)) {\n return null;\n }\n\n return { itemRef, doc: transformer.htmlDoc(this._customElementRegistry()) };\n } catch (error) {\n if (error.name === 'AbortError') {\n console.info(`Item load for ${itemRef.identifier} was aborted`);\n throw error;\n }\n console.warn(`Failed to load item ${itemRef.identifier}:`, error);\n return null;\n }\n }\n\n private async _loadStimulus(href: string): Promise<DocumentFragment | null> {\n const transformer = await qtiTransformItem().load(href, this._activeController?.signal);\n return transformer.htmlDoc(this._customElementRegistry());\n }\n\n private _customElementRegistry(): CustomElementRegistry | undefined {\n const container = this.querySelector<TestContainer>('test-container');\n if (!container) return undefined;\n return container.customElementRegistry ?? undefined;\n }\n\n // ===========================================\n // UTILITIES\n // ===========================================\n\n private _findItemRef(itemId: string): QtiAssessmentItemRef {\n const itemRef = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${itemId}\"]`\n );\n\n if (!itemRef) {\n throw new Error(`Item with identifier \"${itemId}\" not found`);\n }\n\n return itemRef;\n }\n\n private _findSection(sectionId: string): QtiAssessmentSection | null {\n return (\n this._testElement?.querySelector<QtiAssessmentSection>(`qti-assessment-section[identifier=\"${sectionId}\"]`) ||\n null\n );\n }\n\n private _updateSessionContext(itemRef: QtiAssessmentItemRef, itemId: string): void {\n const navPartId = itemRef.closest('qti-test-part')?.identifier;\n const navSectionId = itemRef.closest('qti-assessment-section')?.identifier;\n\n this.sessionContext = {\n ...this.sessionContext,\n navPartId,\n navSectionId,\n navItemRefId: itemId\n };\n }\n\n private _getSectionItemIds(sectionId: string): string[] {\n return Array.from(\n this._testElement.querySelectorAll<QtiAssessmentItemRef>(\n `qti-assessment-section[identifier=\"${sectionId}\"] > qti-assessment-item-ref`\n )\n )\n .map(ref => ref.identifier)\n .filter(Boolean);\n }\n\n private _clearLoadedItems(): void {\n const itemRefs = this._testElement?.querySelectorAll<QtiAssessmentItemRef>('qti-assessment-item-ref');\n Array.from(itemRefs || []).forEach(element => {\n element.xmlDoc = null;\n });\n }\n\n private _clearStimulusRef(): void {\n this.querySelectorAll('[data-stimulus-idref]').forEach(el => (el.innerHTML = ''));\n }\n\n private _isStaleNavigation(navigationId: number, controller: AbortController): boolean {\n return controller.signal.aborted || navigationId !== this._navigationId;\n }\n\n private _createNavigationError(error: any, type: string, id: string): NavigationError {\n return {\n message: error.message || `Failed to load ${type}: ${id}`,\n details: error,\n itemId: type === 'item' ? id : undefined,\n sectionId: type === 'section' ? id : undefined\n };\n }\n\n // ===========================================\n // EVENT DISPATCHING\n // ===========================================\n\n private _dispatchLoadingStarted(type: string, id: string): void {\n dispatchPublic(this, 'cito-test-navigation-started', { type: type as 'item' | 'section', id });\n }\n\n private _dispatchLoadingEnded(type: string, id: string): void {\n this.dispatchEvent(\n new CustomEvent('qti-navigation-loading-ended', {\n detail: { type, id },\n bubbles: true,\n composed: true\n })\n );\n }\n\n private _dispatchError(error: NavigationError): void {\n dispatchPublic(this, 'cito-test-navigation-failed', error);\n }\n\n /** The items are in the DOM: tell hosts the new position rendered (`cito-test-navigated`) and which items it holds. */\n private _dispatchTestLoaded(results: any[], type: 'item' | 'section', id: string): void {\n requestAnimationFrame(() => {\n dispatchPublic(\n this,\n 'cito-test-rendered',\n results.map(({ itemRef }) => ({\n identifier: itemRef?.identifier,\n element: itemRef\n }))\n );\n dispatchPublic(this, 'cito-test-navigated', { type, id });\n });\n }\n }\n\n return TestNavigationClass as Constructor<ITestNavigationMixin> & T;\n};\n","import { QtiBranchRule } from '../components/qti-branch-rule/qti-branch-rule';\n\nimport type { Condition } from './evaluate-condition';\n\nconst SECTION = 'qti-assessment-section';\nconst TEST_PART = 'qti-test-part';\n\n/** The item-ref identifier, also before the element is upgraded. */\nexport const idOf = (ref: Element): string =>\n (ref as Element & { identifier?: string }).identifier || ref.getAttribute('identifier') || '';\n\nexport interface NextItem {\n /** The item ref to present next, or `null` when the test (part) ends. */\n id: string | null;\n /** The item refs passed over on the way, in document order. */\n skipped: string[];\n}\n\n/**\n * The item to present after `refs[current]`, applying branch rules and then pre-conditions.\n *\n * Branch rules: those of the item ref first, then those of each section / test part it was the\n * last item of; the first one that is true wins. A target that is not ahead of the current item\n * is ignored. Pre-conditions: those of the candidate item ref and of every section / test part it\n * would enter. Items skipped this way are not presented.\n *\n * @param refs every item ref of the test, in document order\n * @param current index in `refs` of the item that was just presented\n */\nexport function resolveNextItem(refs: Element[], current: number): NextItem {\n const from = refs[current];\n let start = current + 1;\n\n const rule = firstFiringBranchRule(from, refs, current);\n if (rule) {\n const target = branchTargetIndex(rule, refs, current);\n if (target === null) return { id: null, skipped: refs.slice(current + 1).map(idOf) };\n if (target > current) start = target;\n else console.warn(`qti-branch-rule target \"${rule.target}\" is not ahead of \"${idOf(from)}\", ignored`);\n }\n\n const skipped = refs.slice(current + 1, start).map(idOf);\n for (let i = start; i < refs.length; i++) {\n if (preConditionsPass(refs[i], from)) return { id: idOf(refs[i]), skipped };\n skipped.push(idOf(refs[i]));\n }\n return { id: null, skipped };\n}\n\n/**\n * The first item to present when a linear test starts: the first item ref whose pre-conditions\n * (and those of every section / test part it enters) pass. `null` when none is eligible.\n */\nexport function resolveFirstItem(refs: Element[]): NextItem {\n const skipped: string[] = [];\n for (const ref of refs) {\n if (preConditionsPass(ref, null)) return { id: idOf(ref), skipped };\n skipped.push(idOf(ref));\n }\n return { id: null, skipped };\n}\n\nfunction firstFiringBranchRule(itemRef: Element, refs: Element[], current: number): QtiBranchRule | null {\n const owners: Element[] = [itemRef];\n for (\n let el = itemRef.parentElement;\n el && (el.localName === SECTION || el.localName === TEST_PART);\n el = el.parentElement\n ) {\n if (el.contains(refs[current + 1] ?? null)) break; // not the last item of this container\n owners.push(el);\n }\n for (const owner of owners) {\n for (const rule of owner.querySelectorAll<QtiBranchRule>(':scope > qti-branch-rule')) {\n if (rule.evaluate?.()) return rule;\n }\n }\n return null;\n}\n\n/** Index of the first item ref to consider after a branch, or null for EXIT_TEST / leaving the last part. */\nfunction branchTargetIndex(rule: QtiBranchRule, refs: Element[], current: number): number | null {\n const owner = rule.parentElement as Element;\n const firstAfter = (container: Element | null): number | null => {\n if (!container) return null;\n const last = refs.findLastIndex(ref => container.contains(ref));\n return last + 1 < refs.length ? last + 1 : null;\n };\n\n switch (rule.target) {\n case QtiBranchRule.EXIT_TEST:\n return null;\n case QtiBranchRule.EXIT_TESTPART:\n return firstAfter(owner.closest(TEST_PART));\n case QtiBranchRule.EXIT_SECTION: {\n const section = owner.localName === SECTION ? owner : owner.closest(SECTION);\n return firstAfter(section ?? owner);\n }\n default: {\n const byRef = refs.findIndex(ref => idOf(ref) === rule.target);\n if (byRef >= 0) return byRef;\n const container = [\n ...(owner.closest('qti-assessment-test')?.querySelectorAll(`${SECTION}, ${TEST_PART}`) ?? [])\n ].find(el => el.getAttribute('identifier') === rule.target);\n const inside = container ? refs.findIndex(ref => container.contains(ref)) : -1;\n if (inside >= 0) return inside;\n console.warn(`qti-branch-rule target \"${rule.target}\" not found`);\n return current + 1;\n }\n }\n}\n\nfunction preConditionsPass(itemRef: Element, from: Element | null): boolean {\n const owners: Element[] = [itemRef];\n for (\n let el = itemRef.parentElement;\n el && (el.localName === SECTION || el.localName === TEST_PART);\n el = el.parentElement\n ) {\n if (!from || !el.contains(from)) owners.push(el);\n }\n return owners.every(owner =>\n [...owner.querySelectorAll<Condition>(':scope > qti-pre-condition')].every(\n condition => condition.evaluate?.() ?? true\n )\n );\n}\n","import { listenPublic } from '../public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestViewInterface {\n updateAssessmentItemView(assessmentItem: QtiAssessmentItem, view: View): void;\n}\n\nexport const TestViewMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestViewClass extends superClass implements TestViewInterface {\n constructor(...args: any[]) {\n super(...args);\n this.sessionContext = { ...this.sessionContext, view: 'candidate' };\n\n listenPublic(this, 'cito-test-switch-view', e => {\n this.sessionContext = { ...this.sessionContext, view: e.detail };\n this._updateElementView();\n });\n listenPublic(this, 'cito-test-loaded', () => {\n this._updateElementView();\n });\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent) => {\n this._updateElementView();\n this._setCorrectResponseVisibility(e.detail);\n });\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n super.willUpdate(changedProperties);\n if (changedProperties.has('sessionContext')) {\n this._updateElementView();\n }\n }\n\n // Method to handle view updates for elements based on the current context view\n private _updateElementView() {\n if (this._testElement) {\n const viewElements = Array.from(this._testElement.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', element.getAttribute('view') === this.sessionContext.view);\n });\n\n const assessmentItemRef = this._testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this.sessionContext.navItemRefId}\"]`\n );\n const assessmentItem = assessmentItemRef?.assessmentItem;\n\n if (assessmentItem) this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n }\n\n // Event handler for connected QTI assessment items\n private _setCorrectResponseVisibility(assessmentItem: QtiAssessmentItem): void {\n this.updateAssessmentItemView(assessmentItem, this.sessionContext.view);\n }\n\n /** Extension point for packages that add view-dependent assessment presentation. */\n public updateAssessmentItemView(_assessmentItem: QtiAssessmentItem, _view: View): void {}\n }\n\n return TestViewClass as Constructor<TestViewInterface> & T;\n};\n","import { provide } from '@lit/context';\nimport { LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { INITIAL_TEST_CONTEXT, testContext } from '@qti-components/base';\nimport { INITIAL_SESSION_CONTEXT, type SessionContext, sessionContext } from '@qti-components/base';\n\nimport { listenPublic } from '../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentTest } from '../components/qti-assessment-test/qti-assessment-test';\nimport type { ConfigContext, QtiContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { OutcomeVariable, VariableDeclaration, VariableValue } from '@qti-components/base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\nexport interface TestBaseInterface extends LitElement {\n testContext: Readonly<TestContext>;\n sessionContext: Readonly<SessionContext>;\n configContext?: Readonly<ConfigContext>;\n /** Provided by `qti-test`. */\n qtiContext?: Readonly<QtiContext>;\n _testElement: QtiAssessmentTest;\n updateItemVariables(itemRefID: string, variables: readonly ItemVariableValue[], state?: ItemContext['state']): void;\n}\n\n/** A value to set on an item; `type` is only needed for a variable the item does not declare. */\nexport type ItemVariableValue = Pick<VariableValue<string | string[] | null>, 'identifier' | 'value'> &\n Partial<Pick<VariableValue<string | string[] | null>, 'type'>>;\n\nexport const TestBaseMixin = <T extends Constructor<LitElement>>(superClass: T) => {\n abstract class TestBaseClass extends superClass implements TestBaseInterface {\n @property({ attribute: false, type: Object })\n @provide({ context: testContext })\n public testContext: Readonly<TestContext> = INITIAL_TEST_CONTEXT;\n\n @property({ attribute: false, type: Object })\n @provide({ context: sessionContext })\n public sessionContext: Readonly<SessionContext> = INITIAL_SESSION_CONTEXT;\n\n public _testElement: QtiAssessmentTest;\n\n constructor(...args: any[]) {\n super(...args);\n this._initializeEventListeners();\n }\n\n /**\n * Sets values on one item from outside the candidate's session, e.g. a score from manual\n * scoring. Values are merged into the item's entry in the test context, and into the item\n * itself if it is on screen; a value the item has not seen yet is added, so this also works\n * before the item has loaded. To restore a whole session, assign `state` instead.\n *\n * The test context is replaced rather than changed in place, so its consumers update and\n * `qti-state-changed` fires.\n *\n * @param itemRefID The `qti-assessment-item-ref` identifier, not the item's own identifier.\n * @param state Opaque per-interaction state keyed by response identifier, e.g. a PCI's `getState()`.\n */\n updateItemVariables(itemRefID: string, values: readonly ItemVariableValue[], state?: ItemContext['state']): void {\n this.testContext = {\n ...this.testContext,\n items: this.testContext.items.map(item => {\n if (item.identifier !== itemRefID) return item;\n\n const variables = [...(item.variables ?? [])];\n for (const { identifier, type, value } of values) {\n const index = variables.findIndex(v => v.identifier === identifier);\n const updated = {\n ...(index >= 0 ? variables[index] : {}),\n identifier,\n ...(type ? { type } : {}),\n value: Array.isArray(value) ? [...value] : value\n } as VariableDeclaration<string | string[] | null>;\n if (index >= 0) variables[index] = updated;\n else variables.push(updated);\n }\n return { ...item, variables, ...(state ? { state: { ...state } } : {}) };\n })\n };\n\n const assessmentItem = this._testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${CSS.escape(itemRefID)}\"]`\n )?.assessmentItem;\n if (!assessmentItem) return;\n assessmentItem.variables = [...(this.testContext.items.find(i => i.identifier === itemRefID)?.variables ?? [])];\n if (state) assessmentItem.state = state;\n }\n\n private _initializeEventListeners(): void {\n /**\n * A new test document means a new test and session context.\n *\n * This resets on the document being loaded rather than on\n * `qti-assessment-test-connected`, because the new document's children —\n * test-level `qti-outcome-declaration` among them — connect and register\n * themselves into the context *before* the test element announces itself.\n * Resetting on that announcement discarded every one of those\n * registrations, so no test-level outcome could be read or set.\n */\n this.addEventListener('qti-testdoc-loaded', () => {\n this.testContext = INITIAL_TEST_CONTEXT;\n this.sessionContext = INITIAL_SESSION_CONTEXT;\n });\n\n /**\n * When the test is connected, its item-refs are added to the test context.\n * Registrations from the document's children are already present on the\n * context reset above, so this must preserve what is there.\n */\n listenPublic(this, 'cito-test-loaded', (e: CustomEvent<QtiAssessmentTest>) => {\n this._testElement = e.detail;\n const items = Array.from(this._testElement.querySelectorAll('qti-assessment-item-ref')).map(itemRef => {\n return {\n href: itemRef.href,\n identifier: itemRef.identifier,\n category: itemRef.category,\n variables: [\n {\n identifier: 'completionStatus',\n value: 'not_attempted',\n type: 'outcome'\n } as OutcomeVariable\n ]\n };\n });\n this.testContext = { ...this.testContext, items };\n });\n\n this.addEventListener('qti-assessment-item-connected', (e: CustomEvent<QtiAssessmentItem>) => {\n const assessmentItem = e.detail as QtiAssessmentItem;\n const assessmentRefId = assessmentItem.closest('qti-assessment-item-ref')?.identifier;\n if (assessmentRefId) {\n assessmentItem.assessmentItemRefId = assessmentRefId;\n }\n this._updateItemInTestContext(e.detail);\n });\n\n this.addEventListener('qti-item-context-updated', (e: CustomEvent<{ itemContext: ItemContext }>) => {\n // const assessmentitem = e.composedPath()[0] as QtiAssessmentItem;\n this._updateItemVariablesInTestContext(\n e.detail.itemContext.identifier,\n e.detail.itemContext.variables,\n e.detail.itemContext.state,\n e.detail.itemContext.valid\n );\n });\n }\n\n private _updateItemVariablesInTestContext(\n identifier: string,\n variables: readonly VariableDeclaration<string | string[] | null>[],\n state?: ItemContext['state'],\n valid?: boolean\n ): void {\n // Update the test context with modified variables for the specified item\n this.testContext = {\n ...this.testContext, // Spread existing test context properties\n items: this.testContext.items.map(itemContext => {\n // If the item identifier doesn't match, keep it unchanged\n if (itemContext.identifier !== identifier) {\n return itemContext;\n }\n\n // Update the matching item with new variables\n return {\n ...itemContext, // Keep other properties of the item context\n variables: variables.map(variable => {\n // Find a matching variable in the current item context\n const matchingVariable = itemContext.variables.find(v => v.identifier === variable.identifier);\n\n // Merge matching variable with the new one, or use the new variable if no match\n return matchingVariable ? { ...matchingVariable, ...variable } : variable;\n }),\n ...(state !== undefined ? { state: state ? { ...state } : undefined } : {}),\n ...(valid !== undefined ? { valid } : {})\n };\n })\n };\n // Deprecated for hosts, see `@event` on `qti-test`; kept until the next major.\n this.dispatchEvent(\n new CustomEvent('qti-test-context-updated', { detail: this.testContext, bubbles: false, composed: false })\n );\n }\n\n /**\n * Updates the variables of an assessment item in the test context.\n * - Matches the assessment item with the corresponding test context item.\n * - If the item is not found, logs a warning.\n * - Updates variables in the test context if exactly one variable exists.\n * - Otherwise, syncs the assessment item's variables with the test context.\n *\n * @param assessmentItem - The assessment item to update.\n */\n private _updateItemInTestContext = (assessmentItem: QtiAssessmentItem): void => {\n const context = assessmentItem.itemContext;\n const identifier = context.identifier;\n const fullVariables = context.variables;\n\n // Find the corresponding item in the test context by identifier\n const itemContext = this.testContext.items.find(i => i?.identifier === identifier);\n\n if (!itemContext) {\n console.warn(`Item IDs between assessment.xml and item.xml should match: ${identifier} is not found!`);\n return;\n }\n\n // Update variables in the test context or sync them to the assessment item\n if (itemContext.variables?.length === 1) {\n // The loaded qti-assessment-item itself has variables which are not in test context yet.\n this._updateItemVariablesInTestContext(identifier, fullVariables, undefined, context.valid);\n } else {\n const newVariables = [...assessmentItem.variables];\n // Sync the assessment item's variables with the test context\n for (const variable of itemContext.variables) {\n const currentVariable = newVariables.find(v => v.identifier === variable.identifier);\n if (currentVariable) {\n currentVariable.value = variable.value;\n } else {\n newVariables.push(variable);\n }\n }\n assessmentItem.variables = newVariables;\n // Opaque interaction state (a PCI's getState()) is read from the item context when the\n // interaction initializes, so it has to be in place now, before that happens.\n if (itemContext.state) {\n assessmentItem.state = itemContext.state;\n }\n }\n };\n }\n\n return TestBaseClass as Constructor<TestBaseInterface> & T;\n};\n\n// Keep the old abstract class for backwards compatibility during migration\nexport abstract class TestBase extends TestBaseMixin(LitElement) {}\n","import { QTI_TEST_STATE_VERSION } from '../types/qti-test-state';\nimport { dispatchPublic, listenPublic } from '../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext, TestContext } from '@qti-components/base';\nimport type { QtiTestState, QtiTestStateSession } from '../types/qti-test-state';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\ntype Value = string | string[] | null;\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'qti-state-changed': CustomEvent<QtiTestState>;\n }\n}\n\nexport interface ITestStateMixin {\n /**\n * The candidate's persistable state: what they answered and where they are.\n *\n * Assign a stored state to resume. It may be assigned at any time: before the test document\n * has loaded it is held and applied as soon as the test connects — before the first item\n * loads, so items and the initial navigation start from it — and after that it is applied\n * immediately and the test navigates to the restored position.\n *\n * Items are matched by item-ref identifier; items the state does not mention start fresh, and\n * stored items, test outcomes or a position the test no longer has are ignored. Restoring is a\n * resume, so linear-mode navigation restrictions do not apply.\n */\n state: QtiTestState;\n}\n\nconst copy = (value: Readonly<Value> | undefined): Value =>\n Array.isArray(value) ? [...value] : ((value as string | null | undefined) ?? null);\n\nconst isQtiTestState = (value: unknown): value is QtiTestState => {\n const state = value as QtiTestState | null;\n return (\n state?.version === QTI_TEST_STATE_VERSION &&\n Array.isArray(state.test?.items) &&\n Array.isArray(state.test?.outcomes) &&\n typeof state.session === 'object' &&\n state.session !== null\n );\n};\n\nconst toState = (test: Readonly<TestContext>, session: Readonly<SessionContext>): QtiTestState => ({\n version: QTI_TEST_STATE_VERSION,\n test: {\n items: (test?.items ?? [])\n .filter(item => item.identifier)\n .map(item => ({\n identifier: item.identifier,\n variables: (item.variables ?? []).map(v => ({\n identifier: v.identifier,\n ...(v.type ? { type: v.type } : {}),\n value: copy(v.value)\n })),\n ...(item.state ? { state: { ...item.state } } : {})\n })),\n outcomes: (test?.testOutcomeVariables ?? []).map(v => ({ identifier: v.identifier, value: copy(v.value) }))\n },\n session: {\n ...(session?.navPartId !== undefined ? { navPartId: session.navPartId } : {}),\n ...(session?.navSectionId !== undefined ? { navSectionId: session.navSectionId } : {}),\n ...(session?.navItemRefId !== undefined ? { navItemRefId: session.navItemRefId } : {})\n }\n});\n\n/**\n * Persist and resume a test session through one value, `state`, and one event,\n * `qti-state-changed`.\n *\n * Sits directly on top of `TestBaseMixin`, so its `qti-assessment-test-connected` listener runs\n * after the base has built `testContext.items` from the item-refs, and before the navigation\n * mixin's listener picks the first item to load.\n */\nexport const TestStateMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestStateClass extends superClass implements ITestStateMixin {\n /** A state assigned before the test connected, applied when it does. */\n #pending: QtiTestState | null = null;\n\n /**\n * False while a test document is loading. Loading resets both contexts and rebuilds them, so\n * the intermediate states are empty — emitting one would invite a host to save it over the\n * real one.\n */\n #ready = false;\n\n #lastEmitted: string | null = null;\n\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-testdoc-loaded', () => {\n this.#ready = false;\n this.#lastEmitted = null;\n });\n listenPublic(this, 'cito-test-loaded', () => {\n if (this.#pending) {\n this.#apply(this.#pending);\n this.#pending = null;\n }\n this.#ready = true;\n });\n }\n\n get state(): QtiTestState {\n return toState(this.testContext, this.sessionContext);\n }\n\n set state(value: QtiTestState) {\n if (!isQtiTestState(value)) {\n console.warn(`[qti-test] Ignoring a state that is not a version ${QTI_TEST_STATE_VERSION} QtiTestState.`);\n return;\n }\n if (!this.#ready) {\n this.#pending = value;\n return;\n }\n\n const { navItemRefId, navSectionId } = this.sessionContext;\n this.#apply(value);\n\n const restored = this.sessionContext;\n if (restored.navItemRefId && restored.navItemRefId !== navItemRefId) {\n this.#requestNavigation('item', restored.navItemRefId);\n } else if (!restored.navItemRefId && restored.navSectionId && restored.navSectionId !== navSectionId) {\n this.#requestNavigation('section', restored.navSectionId);\n }\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n if (!this.#ready || !(changed.has('testContext') || changed.has('sessionContext'))) return;\n\n const state = this.state;\n const serialized = JSON.stringify(state);\n if (serialized === this.#lastEmitted) return;\n this.#lastEmitted = serialized;\n dispatchPublic(this, 'cito-test-state-changed', state);\n }\n\n #apply(state: QtiTestState): void {\n // Before the items load this only fills the test context; items already on screen are\n // updated too.\n for (const saved of state.test.items) this.updateItemVariables(saved.identifier, saved.variables, saved.state);\n\n const savedOutcomes = new Map(state.test.outcomes.map(outcome => [outcome.identifier, outcome.value]));\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v =>\n savedOutcomes.has(v.identifier) ? { ...v, value: copy(savedOutcomes.get(v.identifier)) } : v\n )\n };\n\n // Written before any navigation request, so the linear-mode restriction — which compares\n // against the current position — sees the restored item as current and lets it load.\n this.sessionContext = { ...this.sessionContext, ...this.#validSession(state.session) };\n }\n\n /** A stored position may point at an item or section a revised test no longer has. */\n #validSession(session: QtiTestStateSession): QtiTestStateSession {\n const exists = (selector: string, id: string | null | undefined) =>\n !!id && !!this._testElement?.querySelector(`${selector}[identifier=\"${CSS.escape(id)}\"]`);\n return {\n ...(exists('qti-test-part', session.navPartId) ? { navPartId: session.navPartId } : {}),\n ...(exists('qti-assessment-section', session.navSectionId) ? { navSectionId: session.navSectionId } : {}),\n ...(this.testContext.items.some(i => i.identifier === session.navItemRefId)\n ? { navItemRefId: session.navItemRefId }\n : {})\n };\n }\n\n #requestNavigation(type: 'item' | 'section', id: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type, id });\n }\n }\n\n return TestStateClass as Constructor<ITestStateMixin> & T;\n};\n","import type { QtiOutcomeProcessing } from '../components/qti-outcome-processing/qti-outcome-processing';\nimport type { OutcomeVariable, VariableDeclaration } from '@qti-components/base';\nimport type { TestBaseInterface } from './test-base';\n\ntype Constructor<T = {}> = abstract new (...args: any[]) => T;\n\ndeclare class TestProcessingInterface {\n updateOutcomeVariable(identifier: string, value: string | string[] | undefined): void;\n getOutcome(identifier: string): Readonly<OutcomeVariable>;\n getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>>;\n outcomeProcessing(): boolean;\n}\nexport const TestProcessingMixin = <T extends Constructor<TestBaseInterface>>(superClass: T) => {\n abstract class TestProcessingElement extends superClass implements TestProcessingInterface {\n constructor(...args: any[]) {\n super(...args);\n this.addEventListener('qti-register-variable', (e: CustomEvent<{ variable: any }>) => {\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: [...(this.testContext.testOutcomeVariables || []), e.detail.variable]\n };\n e.stopPropagation();\n });\n // wordt aangeroepen vanuit de processingtemplate\n this.addEventListener(\n 'qti-set-outcome-value',\n (e: CustomEvent<{ outcomeIdentifier: string; value: string | string[] }>) => {\n const { outcomeIdentifier, value } = e.detail;\n this.updateOutcomeVariable(outcomeIdentifier, value);\n e.stopPropagation();\n }\n );\n }\n\n outcomeProcessing(): boolean {\n // Inside the loaded test: `test-container` renders it into its own shadow root, which a\n // `querySelector` on this element does not reach. Without a loaded test, look in the light DOM.\n const outcomeProcessor = (this._testElement ?? this).querySelector(\n 'qti-outcome-processing'\n ) as unknown as QtiOutcomeProcessing;\n if (!outcomeProcessor) return false;\n outcomeProcessor?.process();\n return true;\n }\n\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n\n public updateOutcomeVariable(identifier: string, value: string | string[] | undefined) {\n const outcomeVariable = this.getOutcome(identifier);\n if (!outcomeVariable) {\n console.warn(`Can not set qti-outcome-identifier: ${identifier}, it is not available`);\n return;\n }\n this.testContext = {\n ...this.testContext,\n testOutcomeVariables: this.testContext.testOutcomeVariables?.map(v => {\n if (v.identifier !== identifier) {\n return v;\n }\n return {\n ...v,\n value: outcomeVariable.cardinality === 'single' ? value : [...v.value, value as string]\n };\n })\n };\n }\n\n public getOutcome(identifier: string): Readonly<OutcomeVariable> {\n return this.getVariable(identifier) as OutcomeVariable;\n }\n public getVariable(identifier: string): Readonly<VariableDeclaration<string | string[] | null>> {\n return this.testContext.testOutcomeVariables?.find(v => v.identifier === identifier) || null;\n }\n /* --------------------------- ENABLED WHEN UNIT TESTING OUTCOME PROCESSING ------------------------------------ */\n }\n\n return TestProcessingElement as Constructor<TestProcessingInterface> & T;\n};\n","import { consume } from '@lit/context';\nimport { css, html, LitElement } from 'lit';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { TestContainer } from '../test-container/test-container';\n\nexport class TestCheckItem extends LitElement {\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n const testContainer = this.testHost?.querySelector<TestContainer>('test-container');\n if (!testContainer) return;\n\n const viewElements = Array.from(testContainer.shadowRoot.querySelectorAll('[view]'));\n\n viewElements.forEach((element: HTMLElement) => {\n element.classList.toggle('show', true);\n });\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n","// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test\n * chrome along with the items; every token has a literal fallback equal to the theme's own\n * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot\n * in front of each token repaints the test controls alone.\n */\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));\n color: var(--test-button-color, var(--qti-component-color, inherit));\n border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)\n var(--test-button-border-color, var(--qti-component-border-color, #0175aa));\n`;\n\n/** Hover and keyboard focus; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));\n`;\n\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);\n outline-offset: 2px;\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n","import { consume } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { until } from 'lit/directives/until.js';\n\nimport { qtiContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\nimport { qtiTransformTest } from '@qti-components/transformers';\nimport itemCss from '@qti-components/theme/item-css';\n\nimport { testHostContext } from '../../internal/test-host.context';\n\nimport type { QtiContext } from '@qti-components/base';\nimport type { TestHost } from '../../internal/test-host.context';\n\n/**\n * `<test-container>` is a custom element designed for hosting the qti-assessment-item.\n * The `qti-assessment-test` will be placed inside the shadow DOM of this element.\n * The element loads the test from the provided URL and renders it inside the shadow DOM.\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container class=\"m-4 bg-white\" test-url=\"./path/to/assessmenttest.xml\"></test-container>\n * </test-navigation>\n * </qti-test>\n * ```\n */\n\nexport class TestContainer extends LitElement {\n /** Scoped registry used by the test shadow root. Must be set before connection. */\n @property({ attribute: false })\n customElementRegistry: CustomElementRegistry | null = null;\n\n /** URL of the item to load */\n @property({ type: String, attribute: 'test-url' })\n testURL: string | null = null;\n\n /** A parsed HTML document */\n @state()\n testDoc: DocumentFragment | null = null;\n\n /** The raw XML string */\n @state()\n testXML: string | null = null;\n\n /** The `qti-test` this container is in: where the host's `postLoadTestTransformCallback` lives. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n @state()\n @consume({ context: qtiContext, subscribe: true })\n protected qtiContext: QtiContext = {\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n };\n\n /** Template content if provided */\n #templateContent: unknown = null;\n #resolvedCustomElementRegistry: CustomElementRegistry | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const registry = this.customElementRegistry;\n\n this.#resolvedCustomElementRegistry = registry;\n\n return (\n this.shadowRoot ??\n this.attachShadow({\n ...(this.constructor as typeof TestContainer).shadowRootOptions,\n ...(registry ? { customElementRegistry: registry } : {})\n })\n );\n }\n\n /** Callback function to transform the test after loading */\n // @property({ type: Function }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;\n\n @watch('testURL', { waitUntilFirstUpdate: true })\n protected async handleTestURLChange() {\n if (!this.testURL) return;\n try {\n const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;\n let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);\n // Apply external transformation if provided\n const qtiTest = this.testHost;\n if (qtiTest?.postLoadTestTransformCallback) {\n // Create a temporary document to get the test element reference\n const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n const testElement = tempDoc.querySelector('qti-assessment-test') as any;\n\n if (testElement) {\n // Apply the callback with the test element\n api = await qtiTest.postLoadTestTransformCallback(api, testElement);\n }\n }\n\n this.#setTestDoc(api.htmlDoc(this.#resolvedCustomElementRegistry ?? undefined));\n } catch (error) {\n console.error('Error loading or parsing XML:', error);\n }\n }\n\n /**\n * Assign a new test document and announce it.\n *\n * The announcement has to happen here rather than on\n * `qti-assessment-test-connected`, because by then the new document's\n * children have already connected and registered themselves — a host that\n * resets its context on that event throws those registrations away. Lit's\n * re-render is async, so a handler running now still gets in before any child\n * of the new `qti-assessment-test` connects.\n */\n #setTestDoc(testDoc: DocumentFragment): void {\n this.testDoc = testDoc;\n this.dispatchEvent(\n new CustomEvent('qti-testdoc-loaded', {\n bubbles: true,\n composed: true\n })\n );\n }\n\n @watch('testXML', { waitUntilFirstUpdate: true })\n protected handleTestXMLChange() {\n if (!this.testXML) return;\n try {\n const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;\n this.#setTestDoc(\n qtiTransformTest()\n .parse(this.testXML)\n .shuffleOrdering(explicitSeed)\n .htmlDoc(this.#resolvedCustomElementRegistry ?? undefined)\n );\n } catch (error) {\n console.error('Error parsing XML:', error);\n }\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.#initializeTemplateContent();\n this.#applyStyles();\n if (this.testURL) {\n this.handleTestURLChange();\n }\n if (this.testXML) {\n this.handleTestXMLChange();\n }\n }\n\n #initializeTemplateContent() {\n const template = this.querySelector('template') as HTMLTemplateElement;\n this.#templateContent = template ? template.content : html``;\n }\n\n #applyStyles() {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(itemCss);\n this.shadowRoot.adoptedStyleSheets = [sheet];\n }\n\n override render() {\n return html`\n ${this.#templateContent}\n <slot></slot>\n ${until(this.testDoc, html`<span>Loading...</span>`)}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-container': TestContainer;\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';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n","import { html, LitElement, css } from 'lit';\nimport { consume, provide, createContext } from '@lit/context';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { sessionContext } from '@qti-components/base';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport * as styles from '../styles';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestHost } from '../../internal/test-host.context';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\n\n// ─── CSS Custom Highlight ─────────────────────────────────────────────────────\n\nconst HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element\nconst HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech\n\n// Shared across all instances — added to whichever shadow root needs it\nlet highlightSheet: CSSStyleSheet | null = null;\n\nfunction getHighlightSheet(): CSSStyleSheet {\n if (!highlightSheet) {\n highlightSheet = new CSSStyleSheet();\n highlightSheet.replaceSync(`\n ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }\n ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }\n `);\n }\n return highlightSheet;\n}\n\ntype SpeechState = 'idle' | 'playing' | 'paused';\n\n// ─── TTS Context ──────────────────────────────────────────────────────────────\n\nexport interface TtsContext {\n state: SpeechState;\n /** True while every reading element is highlighted and a click on one starts reading there. */\n picking: boolean;\n /** Index of the currently highlighted reading element (0-based). */\n currentElementIndex: number;\n /** Total number of navigable reading elements in the current item. */\n elementCount: number;\n play(): void;\n pause(): void;\n resume(): void;\n stop(): void;\n prevElement(): void;\n nextElement(): void;\n /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */\n togglePick(): void;\n}\n\nexport { SpeechState };\nexport const ttsContext = createContext<TtsContext>(Symbol('tts-context'));\n\n// ─── Icons ────────────────────────────────────────────────────────────────────\n\n// Plain geometric glyphs on a 24-unit grid, painted in currentColor. SVG rather than text so\n// every button gets the same box: text glyphs (◀◀ ▶ ⏸ ■ ☞) differ in width, and some fall back\n// to an emoji font with different line metrics.\nconst ICONS = {\n play: 'M8 5v14l11-7z',\n pause: 'M6 5h4v14H6zM14 5h4v14h-4z',\n stop: 'M6 6h12v12H6z',\n prev: 'M6 5h2v14H6zM20 5v14L9 12z',\n next: 'M16 5h2v14h-2zM4 5v14l11-7z',\n pick: 'M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z'\n} as const;\n\n/** Default button content: the icon, plus a visually hidden label as the accessible name. */\nconst iconContent = (icon: keyof typeof ICONS, label: string) => {\n const svg = html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"${ICONS[icon]}\"></path>\n </svg>`;\n return html`${svg}<span class=\"label\">${label}</span>`;\n};\n\n// ─── Shared base for child button elements ────────────────────────────────────\n\n/**\n * Base class shared by all TTS control elements. Consumes `ttsContext` and\n * mirrors the current speech state onto CSS custom states so each child can\n * be styled with `:state(playing)`, `:state(paused)`, `:state(idle)`.\n */\nabstract class TtsButtonBase extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n }\n button {\n ${styles.btn};\n min-inline-size: var(--test-button-size, 2.25rem);\n padding-inline: 0.5rem;\n /* Containing block for the visually hidden .label. Without it the label is placed against\n the nearest positioned ancestor, which can sit outside a scroll container and make the\n page as tall as the scrolled content. */\n position: relative;\n }\n button:hover:not(:disabled) {\n ${styles.btnInteractive};\n }\n button:focus-visible {\n ${styles.focusRing};\n }\n button:disabled {\n ${styles.dis};\n }\n button[aria-pressed='true'],\n button[aria-pressed='true']:hover {\n background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));\n color: var(--test-button-selected-color, var(--qti-selected-color, #fff));\n }\n svg,\n ::slotted(svg) {\n flex: none;\n inline-size: var(--test-tts-icon-size, 1.125rem);\n block-size: var(--test-tts-icon-size, 1.125rem);\n }\n svg {\n fill: currentColor;\n }\n /* The default content is icon-only; this keeps the button's accessible name. */\n .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `;\n\n /**\n * Accessible name of the button. Without it the default icon carries an English name, and\n * slotted content names the button by its text; set it when you slot an icon of your own,\n * which has no text to be named by.\n */\n @property({ type: String }) label?: string;\n\n #internals = this.attachInternals();\n\n @consume({ context: ttsContext, subscribe: true })\n protected _tts?: TtsContext;\n\n #mirroredState: SpeechState | undefined;\n #mirroredPicking = false;\n\n override updated(_changed: PropertyValues) {\n // `_tts` is a context field, not a reactive property, so it never shows up in `changed`:\n // compare against what was last mirrored instead.\n const state = this._tts?.state;\n const picking = this._tts?.picking ?? false;\n if (state === this.#mirroredState && picking === this.#mirroredPicking) return;\n this.#mirroredState = state;\n this.#mirroredPicking = picking;\n this.#internals.states.clear();\n if (state) this.#internals.states.add(state);\n if (picking) this.#internals.states.add('picking');\n }\n}\n\n// ─── Controller element ───────────────────────────────────────────────────────\n\n/**\n * `<test-item-to-speech>` is the controller and context provider. It manages\n * speech synthesis, word highlighting, and item element lookup. Compose your\n * own player by placing control elements as children.\n *\n * @example\n * ```html\n * <test-item-to-speech language=\"nl-NL\">\n * <test-tts-play></test-tts-play>\n * <test-tts-prev></test-tts-prev>\n * <test-tts-next></test-tts-next>\n * <test-tts-stop></test-tts-stop>\n * </test-item-to-speech>\n * ```\n *\n * The controller lays its controls out as a wrapping row; each control draws an icon button,\n * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a\n * control with a slotted icon a `label`, since an icon has no text to name the button by. Buttons read the qti-theme tokens (with the theme's\n * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.\n *\n * ### Language resolution\n *\n * Each reading element is spoken in the language of the nearest `lang` attribute:\n *\n * 1. `lang` (or `xml:lang`) on the element itself\n * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across\n * shadow roots, anything wrapping the test\n * 3. `lang` on the document's `<html>` element\n * 4. the `language` attribute on `<test-item-to-speech>`\n *\n * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with\n * `xml:lang=\"en-GB\"` on a `<p>` or on the item root is honoured without further work.\n *\n * ### What is read\n *\n * Decided once per connect, by where the player is placed. The first rule that matches wins:\n *\n * 1. **Next to a stimulus placeholder** — the player shares its parent with a\n * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the\n * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the\n * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation\n * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts\n * over on the new content.\n * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked\n * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes\n * on one container; the player reads the readable elements inside it. Navigation is ignored.\n * The reading list is rebuilt when the player starts from the top, and when an element in it\n * has left the page — so a re-render of the content never interrupts speech.\n * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,\n * so every item gets a player of its own: the player reads that item, and only that item.\n * The navigation cursor is ignored; speech stops when the player leaves the page with its item.\n * 4. **Anywhere else** — a toolbar in the page chrome: the player follows the navigation cursor\n * and reads the item `navItemRefId` (session context) points at, found in any\n * `test-container` reachable from the player. Navigating stops speech and starts the next\n * item from the top.\n *\n * ```html\n * <!-- 1. a player for the shared reading text -->\n * <aside>\n * <test-item-to-speech>…</test-item-to-speech>\n * <div data-stimulus-idref=\"Stimulus1\"></div>\n * </aside>\n *\n * <!-- 2. a player for any other HTML -->\n * <div>\n * <test-item-to-speech>…</test-item-to-speech>\n * <section data-tts-content lang=\"nl-NL\">…</section>\n * </div>\n *\n * <!-- 3. one player per item -->\n * <qti-test>\n * <template item-ref>\n * <test-item-to-speech>…</test-item-to-speech>\n * {{ xmlDoc }}\n * </template>\n * …\n * </qti-test>\n *\n * <!-- 4. one player in the toolbar, following navigation -->\n * <test-navigation>\n * <header><test-item-to-speech>…</test-item-to-speech></header>\n * <test-container test-url=\"…\"></test-container>\n * </test-navigation>\n * ```\n *\n * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the\n * player on the fresh content. An item player reads the item body as rendered: a stimulus\n * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player\n * can speak at a time; starting one stops any other.\n *\n * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,\n * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)\n * or inside `aria-hidden=\"true\"`.\n *\n * ### Starting somewhere in the middle\n *\n * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue\n * cursor highlight, and the first click on one of them leaves pick mode and starts reading\n * from that element. Pressing the button again leaves pick mode without reading.\n *\n * @cssstate idle - No speech active\n * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click\n * @cssstate playing - Speech is playing\n * @cssstate paused - Speech is paused\n */\n\nexport class TestItemToSpeech extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--test-tts-gap, 0.25rem);\n }\n `;\n\n /** Fallback language when neither the item content nor the document declares one. */\n @property({ type: String }) language = 'nl-NL';\n\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n /** The `qti-test` this player is in, across shadow roots. */\n @consume({ context: testHostContext, subscribe: true })\n protected testHost?: TestHost;\n\n @state()\n @provide({ context: ttsContext })\n _ttsContext!: TtsContext;\n\n #internals = this.attachInternals();\n\n // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The\n // placeholder itself is looked up on every use — a host may swap the element.\n #stimulusMode = false;\n // Stimulus mode: resets the player when the stimulus content next to it is replaced.\n #stimulusObserver: MutationObserver | null = null;\n // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.\n // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).\n #contentMode = false;\n // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.\n #itemRef: QtiAssessmentItemRef | null = null;\n // Where the item-connected (and, in cursor mode, navigation) events are listened for.\n #eventHost: EventTarget | null = null;\n #boundHandleItemConnected = this.#handleItemConnected.bind(this);\n #boundHandleNavigation = () => this.#stop();\n\n // Cursor mode: the previous navigation position, to detect moving to another item or section.\n #prevNavItemRefId: string | null | undefined = undefined;\n #prevNavSectionId: string | null | undefined = undefined;\n\n // Current set of block-level reading elements for the item\n #readingElements: Element[] | null = null;\n #currentElementIndex = 0;\n\n // Text nodes of the element currently being spoken (for word-boundary highlight)\n #textNodes: Text[] = [];\n\n // The utterance this player is speaking; lets the error handler tell \"our speech was\n // cancelled by another player\" apart from a cancel we issued ourselves.\n #currentUtterance: SpeechSynthesisUtterance | null = null;\n\n // Pick mode: all elements highlighted, a click on one starts reading from there.\n #picking = false;\n #pickRoot: EventTarget | null = null;\n #boundHandlePickClick = this.#handlePickClick.bind(this);\n\n // Set when the last element has been read: the cursor stays on it (so prev still works),\n // but the next play starts the item over instead of repeating that last element.\n #finished = false;\n\n // Two separate CSS Highlight objects\n #elementHighlight = new Highlight(); // whole-element cursor\n #wordHighlight = new Highlight(); // current word during speech\n\n constructor() {\n super();\n this._ttsContext = {\n state: 'idle',\n currentElementIndex: 0,\n elementCount: 0,\n play: () => this.#playSpeech(),\n pause: () => this.#pause(),\n resume: () => this.#resume(),\n stop: () => {\n this.#stopPicking();\n this.#stop();\n },\n prevElement: () => this.#prevElement(),\n nextElement: () => this.#nextElement(),\n togglePick: () => this.#togglePick(),\n picking: false\n };\n }\n\n // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the\n // render already under way instead of scheduling a second one (Lit's change-in-update).\n override willUpdate(changed: PropertyValues) {\n super.willUpdate(changed);\n // Stimulus, content and item-ref mode: the navigation cursor does not change what this player reads.\n if (this.#stimulusMode || this.#contentMode || this.#itemRef) return;\n // Cursor mode: moving to another item or section stops speech and starts over (ignore the\n // initial undefined → value transition). Section navigation leaves navItemRefId null, so it\n // needs its own check.\n const item = this._sessionContext?.navItemRefId ?? null;\n const section = this._sessionContext?.navSectionId ?? null;\n const itemChanged = this.#prevNavItemRefId !== undefined && this.#prevNavItemRefId !== item;\n const sectionChanged = this.#prevNavSectionId !== undefined && this.#prevNavSectionId !== section;\n if (itemChanged || sectionChanged) this.#resetReadingPosition();\n this.#prevNavItemRefId = item;\n this.#prevNavSectionId = section;\n }\n\n /** Stop speech and forget the collected reading elements, so the next play starts afresh. */\n #resetReadingPosition() {\n this.#stopPicking();\n this.#stop();\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#setSpeechState('idle');\n // NOTE: #ensureHighlightStyles() is called lazily on first highlight use\n // because test-container may not be in the DOM yet at this point.\n this.#stimulusMode = this.#stimulusPlaceholder() !== null;\n if (this.#stimulusMode) {\n // Stimulus mode: neither items nor navigation decide what is read, only the content of the\n // placeholder. qti-components replaces it whenever it loads a stimulus (innerHTML, then\n // append), so watch the parent — that also catches a host swapping the placeholder itself.\n this.#stimulusObserver = new MutationObserver(records => {\n if (records.some(record => !this.contains(record.target))) this.#handleStimulusReplaced();\n });\n this.#stimulusObserver.observe(this.parentElement!, { childList: true, subtree: true });\n return;\n }\n // Content mode: plain HTML next to the player. Nothing to listen for: what is read only\n // depends on that element, and the reading list is rebuilt when it goes stale.\n this.#contentMode = this.#contentElement() !== null;\n if (this.#contentMode) return;\n this.#itemRef = this.closest<QtiAssessmentItemRef>('qti-assessment-item-ref');\n // qti-assessment-item-connected is bubbles+composed: it passes the item's own item-ref, and\n // reaches test-navigation / qti-test from inside test-container's shadow root.\n this.#eventHost =\n this.#itemRef ?? this.closest('test-navigation') ?? this.testHost ?? (this.getRootNode() as EventTarget);\n this.#eventHost.addEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n if (!this.#itemRef) {\n // Cursor mode: cito-test-navigate fires synchronously on prev/next — stop right away\n // instead of waiting for the new position to arrive through the session context.\n this.#eventHost.addEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost.addEventListener('qti-request-navigation', this.#boundHandleNavigation); // deprecated name, still sent by hosts\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // Only silence the synthesizer if it is speaking for this player.\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#eventHost?.removeEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n this.#eventHost?.removeEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost?.removeEventListener('qti-request-navigation', this.#boundHandleNavigation);\n this.#eventHost = null;\n this.#itemRef = null;\n this.#stimulusObserver?.disconnect();\n this.#stimulusObserver = null;\n this.#stimulusMode = false;\n this.#contentMode = false;\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /**\n * An item (re)rendered. If it is ours — e.g. after navigating to the item already shown — the\n * elements collected earlier are detached now. That does not move the navigation cursor, so\n * the check in updated() does not catch it.\n */\n #handleItemConnected(event: Event) {\n if (this.#readingElements === null) return;\n // In item-ref mode the event came through our own item-ref, so it is always ours.\n const identifier = (event as CustomEvent<QtiAssessmentItem>).detail?.identifier;\n if (this.#itemRef || identifier === this._sessionContext?.navItemRefId) this.#resetReadingPosition();\n }\n\n /**\n * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was\n * collected, so the next play reads the new content from the top. Unlike\n * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading\n * while an item player on the same page is speaking.\n */\n #handleStimulusReplaced() {\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n /**\n * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or\n * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because\n * loading replaces the placeholder's content.\n */\n #stimulusPlaceholder(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-stimulus-idref]') ?? null;\n }\n\n /**\n * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.\n * The marker goes on one container; the player finds the readable elements inside it.\n */\n #contentElement(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-tts-content]') ?? null;\n }\n\n /**\n * The element whose text is read: the stimulus body next to the player (stimulus mode), the\n * marked content next to it (content mode), or the item body of the item to read.\n */\n #resolveReadingRoot(): Element | null {\n if (this.#stimulusMode) return this.#stimulusPlaceholder()?.querySelector('qti-stimulus-body') ?? null;\n if (this.#contentMode) return this.#contentElement();\n return this.#resolveItem()?.querySelector('qti-item-body') ?? null;\n }\n\n /** The item to read: our item-ref's (item-ref mode), or the navigated one (cursor mode). */\n #resolveItem(): QtiAssessmentItem | null {\n if (this.#itemRef) return this.#itemRef.assessmentItem;\n const identifier = this._sessionContext?.navItemRefId;\n return identifier ? this.#findItemInDom(identifier) : null;\n }\n\n /**\n * Cursor mode: find the rendered item for an item-ref identifier. Our own `<qti-test>` first —\n * a page can hold several tests showing the same item — then every root from here up to the\n * document; each scope directly and in the `test-container` shadow roots inside it.\n */\n #findItemInDom(identifier: string): QtiAssessmentItem | null {\n const selector = `qti-assessment-item-ref[identifier=\"${CSS.escape(identifier)}\"] qti-assessment-item`;\n const search = (scope: ParentNode): QtiAssessmentItem | null => {\n const direct = scope.querySelector<QtiAssessmentItem>(selector);\n if (direct) return direct;\n for (const container of Array.from(scope.querySelectorAll('test-container'))) {\n const inShadow = container.shadowRoot?.querySelector<QtiAssessmentItem>(selector);\n if (inShadow) return inShadow;\n }\n return null;\n };\n\n const test = this.closest('qti-test');\n const inTest = test && search(test);\n if (inTest) return inTest;\n\n let root: Node = this.getRootNode();\n for (;;) {\n const found = search(root as ParentNode);\n if (found) return found;\n const host = (root as ShadowRoot).host;\n if (!host) return null;\n root = host.getRootNode();\n }\n }\n\n /** Update speech state on both the context (notifies children) and the host's CSS custom states. */\n #setSpeechState(state: SpeechState) {\n this._ttsContext = { ...this._ttsContext, state };\n this.#internals.states.delete('idle');\n this.#internals.states.delete('playing');\n this.#internals.states.delete('paused');\n this.#internals.states.add(state);\n }\n\n /** Push currentElementIndex and elementCount into context so children can react. */\n #updateContext() {\n this._ttsContext = {\n ...this._ttsContext,\n currentElementIndex: this.#currentElementIndex,\n elementCount: this.#getReadingElements().length\n };\n }\n\n /**\n * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on\n * first call), filtered live for visibility on every call. Feedback and other\n * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a\n * CSS custom state reveals it) is excluded while hidden and picked up again once shown,\n * without needing to re-collect the candidate set.\n */\n #getReadingElements(): Element[] {\n // Content mode has no events or observer telling it the content changed (a framework like\n // React re-renders it at will). Rebuild the list once an element in it has left the page;\n // text changed inside an element needs nothing, it is read when that element is spoken.\n if (this.#contentMode && this.#readingElements?.some(el => !el.isConnected)) {\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n }\n if (this.#readingElements === null) {\n const root = this.#resolveReadingRoot();\n // Leave the cache empty (rather than `[]`) while the item or stimulus has not rendered yet,\n // so the next call retries instead of getting stuck on an empty result forever.\n if (!root) return [];\n\n // Collect block-level elements (and QTI prompt / choice elements) that contain readable text.\n // Keep only the innermost matches so `<li><p>…</p></li>` is not read twice. Content hidden\n // from assistive technology (`aria-hidden=\"true\"`, e.g. decorative icons) is not read either.\n const selector =\n 'p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice';\n this.#readingElements = Array.from(root.querySelectorAll(selector)).filter(\n el =>\n (el.textContent ?? '').trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden=\"true\"]')\n );\n }\n\n return this.#readingElements.filter(el => this.#isVisible(el));\n }\n\n /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */\n #isVisible(element: Element): boolean {\n if (typeof element.checkVisibility === 'function') {\n return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });\n }\n // Older Safari (< 17.4) fallback: display:none leaves no client rects. Doesn't catch\n // visibility:hidden, which still occupies layout, but display:none is what QTI feedback\n // elements actually use (see qti-feedback-block/qti-feedback-inline default styles).\n return element.getClientRects().length > 0;\n }\n\n /**\n * Resolve the speech language for a reading element.\n * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.\n * Empty `lang=\"\"` is treated as absent.\n */\n #resolveLang(element: Element): string {\n let node: Element | null = element;\n while (node) {\n const lang = node.getAttribute('lang') || node.getAttribute('xml:lang');\n if (lang?.trim()) return lang.trim();\n node = node.parentElement ?? (node.getRootNode() as ShadowRoot).host ?? null;\n }\n const documentLang = document.documentElement.getAttribute('lang');\n if (documentLang?.trim()) return documentLang.trim();\n return this.language;\n }\n\n #playSpeech() {\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stopPicking();\n // speechSynthesis is one global queue: another player mid-sentence would otherwise\n // finish first and this one would silently wait its turn.\n speechSynthesis.cancel();\n if (this.#finished) {\n this.#finished = false;\n this.#currentElementIndex = 0;\n }\n // Content mode: starting from the top rebuilds the list, so elements the page added since\n // the last read (a framework re-render) are included.\n if (this.#contentMode && this.#currentElementIndex === 0) this.#readingElements = null;\n this.#speakElement(this.#currentElementIndex);\n }\n\n /** Speak the element at the given index, then auto-advance when it ends. */\n #speakElement(index: number) {\n const elements = this.#getReadingElements();\n\n if (index >= elements.length) {\n // Finished all elements — stay on the last element so the user can walk back with prev\n this.#clearWordHighlight();\n this.#currentElementIndex = elements.length - 1;\n if (elements.length > 0) this.#highlightElement(elements[this.#currentElementIndex]);\n this.#finished = true;\n this.#setSpeechState('idle');\n this.#updateContext();\n return;\n }\n\n this.#currentElementIndex = index;\n this.#finished = false;\n this.#updateContext();\n\n const element = elements[index];\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(element);\n\n // Collect text nodes of this element for word-boundary mapping\n this.#textNodes = this.#collectTextNodes(element);\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n\n if (!text.trim()) {\n // Skip blank element and move to next\n this.#speakElement(index + 1);\n return;\n }\n\n const utterance = new SpeechSynthesisUtterance(text);\n utterance.lang = this.#resolveLang(element);\n utterance.rate = 1;\n\n utterance.onboundary = (event: SpeechSynthesisEvent) => {\n if (event.name !== 'word') return;\n this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);\n };\n\n utterance.onend = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearWordHighlight();\n this.#speakElement(this.#currentElementIndex + 1);\n };\n\n // Fires when speech is cancelled from outside this player (another player starting,\n // or the browser); a cancel we issued ourselves has already cleared #currentUtterance.\n utterance.onerror = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n };\n\n this.#currentUtterance = utterance;\n speechSynthesis.speak(utterance);\n this.#setSpeechState('playing');\n }\n\n #pause() {\n speechSynthesis.pause();\n this.#setSpeechState('paused');\n }\n\n #resume() {\n speechSynthesis.resume();\n this.#setSpeechState('playing');\n }\n\n #stop() {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n }\n\n // ─── Pick mode ────────────────────────────────────────────────────────────\n\n #togglePick() {\n if (this.#picking) this.#stopPicking();\n else this.#startPicking();\n }\n\n /** Highlight every reading element and wait for a click on one of them. */\n #startPicking() {\n // Content mode: pick from the page as it is now, like starting from the top does.\n if (this.#contentMode) this.#readingElements = null;\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stop();\n this.#picking = true;\n this.#internals.states.add('picking');\n this.#highlightElements(elements);\n // Listen on the item's root so the click is seen before any interaction handles it — in\n // pick mode a click on a choice picks the sentence, it does not answer the question.\n this.#pickRoot = elements[0].getRootNode();\n this.#pickRoot.addEventListener('click', this.#boundHandlePickClick, true);\n this._ttsContext = { ...this._ttsContext, picking: true };\n }\n\n #stopPicking() {\n if (!this.#picking) return;\n this.#picking = false;\n this.#internals.states.delete('picking');\n this.#pickRoot?.removeEventListener('click', this.#boundHandlePickClick, true);\n this.#pickRoot = null;\n this.#clearAllHighlights();\n this._ttsContext = { ...this._ttsContext, picking: false };\n }\n\n #handlePickClick(event: Event) {\n const elements = this.#getReadingElements();\n const path = event.composedPath();\n let index = elements.findIndex(el => path.includes(el));\n if (index < 0) {\n // Not on the text itself. A click on the choice or list item around it (its radio button,\n // the padding) still means \"this one\": take the first reading element inside it.\n const container = path.find(\n (node): node is Element => node instanceof Element && node.matches('qti-simple-choice, li, qti-prompt')\n );\n if (container) index = elements.findIndex(el => container.contains(el));\n }\n if (index < 0) return; // not on a highlighted element — stay in pick mode\n event.preventDefault();\n event.stopPropagation();\n this.#stopPicking();\n speechSynthesis.cancel();\n this.#speakElement(index);\n }\n\n #prevElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n #nextElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n /** Walk text nodes without crossing shadow DOM boundaries. */\n #collectTextNodes(root: Element): Text[] {\n const nodes: Text[] = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n let node: Node | null;\n while ((node = walker.nextNode())) {\n // Text hidden from assistive technology inside a read element — a decorative icon in a\n // list item — is not spoken either. Skipped here, so speech and word highlight agree.\n if ((node.textContent ?? '').length > 0 && !node.parentElement?.closest('[aria-hidden=\"true\"]')) {\n nodes.push(node as Text);\n }\n }\n return nodes;\n }\n\n /** Highlight the whole element as the navigation cursor (blue). */\n #highlightElement(element: Element) {\n this.#highlightElements([element]);\n }\n\n /** Put the blue cursor highlight on several elements at once (pick mode). */\n #highlightElements(elements: Element[]) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#elementHighlight.clear();\n for (const element of elements) {\n const range = new Range();\n range.selectNodeContents(element);\n this.#elementHighlight.add(range);\n }\n CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);\n }\n\n /** Highlight the current word within #textNodes (yellow, during speech). */\n #updateWordHighlight(charIndex: number, charLength: number) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#wordHighlight.clear();\n\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));\n let offset = 0;\n let startNode: Text | null = null;\n let startOffset = 0;\n let endNode: Text | null = null;\n let endOffset = 0;\n\n for (const node of this.#textNodes) {\n const len = node.textContent?.length ?? 0;\n if (!startNode && offset + len > charIndex) {\n startNode = node;\n startOffset = charIndex - offset;\n }\n if (startNode && offset + len >= endIndex) {\n endNode = node;\n endOffset = endIndex - offset;\n break;\n }\n offset += len;\n }\n\n if (startNode && endNode) {\n const range = new Range();\n range.setStart(startNode, startOffset);\n range.setEnd(endNode, endOffset);\n this.#wordHighlight.add(range);\n CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);\n }\n }\n\n #clearWordHighlight() {\n if (!('highlights' in CSS)) return;\n this.#wordHighlight.clear();\n // The registry is shared by every player on the page: only drop the entry if it is ours.\n if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight) CSS.highlights.delete(HIGHLIGHT_WORD);\n }\n\n #clearAllHighlights() {\n if (!('highlights' in CSS)) return;\n this.#clearWordHighlight();\n this.#elementHighlight.clear();\n if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight) CSS.highlights.delete(HIGHLIGHT_ELEMENT);\n }\n\n /** Fallback word-length when charLength is 0. */\n #wordLengthAt(charIndex: number, text: string): number {\n const right = text.slice(charIndex).search(/\\s/);\n return right < 0 ? text.length - charIndex : right;\n }\n\n /**\n * Add ::highlight() rules both to test-container's shadow root (where highlighted\n * text lives) and to the document (safety net — spec allows document rules to apply\n * across shadow DOM). Called lazily on first highlight use so test-container is\n * guaranteed to be in the DOM by the time navigation or speech starts.\n */\n #ensureHighlightStyles() {\n if (!('highlights' in CSS)) return;\n const sheet = getHighlightSheet();\n\n // 1. Document-level rule — applies broadly regardless of shadow DOM depth\n if (!document.adoptedStyleSheets.includes(sheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n }\n\n // 2. Shadow roots the highlighted text may live in: test-container's, and the player's own\n // root when the player itself sits inside a shadow tree (e.g. built into an item card).\n const roots = new Set<ShadowRoot>();\n const testContainer =\n this.closest('test-navigation')?.querySelector('test-container') ??\n this.testHost?.querySelector('test-container');\n if (testContainer?.shadowRoot) roots.add(testContainer.shadowRoot);\n const ownRoot = this.getRootNode();\n if (ownRoot instanceof ShadowRoot) roots.add(ownRoot);\n const itemRoot = this.#readingElements?.[0]?.getRootNode();\n if (itemRoot instanceof ShadowRoot) roots.add(itemRoot);\n for (const root of roots) {\n if (!root.adoptedStyleSheets.includes(sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n }\n }\n }\n}\n\n// ─── Child control elements ───────────────────────────────────────────────────\n\n/**\n * Play/pause/resume toggle button — always enabled, cycles through states.\n * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and\n * `pause-label` name the button in each state (set them when the slotted content is an icon).\n *\n * @example\n * ```html\n * <test-tts-play>\n * <span slot=\"play\">Voorlezen</span>\n * <span slot=\"pause\">Pauzeren</span>\n * </test-tts-play>\n * ```\n *\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPlay extends TtsButtonBase {\n /** Accessible name of the button while speech is playing; see `label`. */\n @property({ type: String, attribute: 'pause-label' }) pauseLabel?: string;\n\n #toggle() {\n if (!this._tts) return;\n if (this._tts.state === 'idle') this._tts.play();\n else if (this._tts.state === 'playing') this._tts.pause();\n else this._tts.resume();\n }\n\n override render() {\n const playing = this._tts?.state === 'playing';\n return html`\n <button part=\"button\" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>\n ${playing\n ? html`<slot name=\"pause\">${iconContent('pause', this.pauseLabel ?? 'Pause')}</slot>`\n : html`<slot name=\"play\">${iconContent('play', this.label ?? 'Play')}</slot>`}\n </button>\n `;\n }\n}\n\n/**\n * Pause button — enabled only when playing.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPause extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'playing'}\n @click=${() => this._tts?.pause()}\n >\n <slot>${iconContent('pause', this.label ?? 'Pause')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Resume button — enabled only when paused.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsResume extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'paused'}\n @click=${() => this._tts?.resume()}\n >\n <slot>${iconContent('play', this.label ?? 'Resume')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsStop extends TtsButtonBase {\n override render() {\n const idle = this._tts?.state === 'idle' && !this._tts?.picking;\n return html`\n <button part=\"button\" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>\n <slot>${iconContent('stop', this.label ?? 'Stop')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Prev-element button — moves cursor to the previous reading element and pauses.\n * Disabled at the first element. Reading elements are collected lazily, so an element count\n * of 0 means \"not looked yet\" rather than \"nothing to read\": the button stays enabled and the\n * first click collects them.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPrev extends TtsButtonBase {\n override render() {\n const collected = (this._tts?.elementCount ?? 0) > 0;\n const atStart = (this._tts?.currentElementIndex ?? 0) === 0;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${collected && atStart}\n @click=${() => this._tts?.prevElement()}\n >\n <slot>${iconContent('prev', this.label ?? 'Previous sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Next-element button — moves cursor to the next reading element and pauses.\n * Disabled at the last element; enabled while the elements have not been collected yet\n * (see `TestTtsPrev`).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsNext extends TtsButtonBase {\n override render() {\n const count = this._tts?.elementCount ?? 0;\n const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${atEnd}\n @click=${() => this._tts?.nextElement()}\n >\n <slot>${iconContent('next', this.label ?? 'Next sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Pick button — toggles pick mode on the controller: every reading element is highlighted and\n * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.\n * @cssstate idle / playing / paused\n * @cssstate picking\n * @csspart button\n */\n\nexport class TestTtsPick extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n aria-pressed=${this._tts?.picking ? 'true' : 'false'}\n @click=${() => this._tts?.togglePick()}\n >\n <slot>${iconContent('pick', this.label ?? 'Read from here')}</slot>\n </button>\n `;\n }\n}\n\n// ─── Global type declarations ─────────────────────────────────────────────────\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-to-speech': TestItemToSpeech;\n 'test-tts-play': TestTtsPlay;\n 'test-tts-pause': TestTtsPause;\n 'test-tts-resume': TestTtsResume;\n 'test-tts-stop': TestTtsStop;\n 'test-tts-prev': TestTtsPrev;\n 'test-tts-next': TestTtsNext;\n 'test-tts-pick': TestTtsPick;\n }\n}\n","import { ContextConsumer, consume, provide } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\nimport { configContext } from '@qti-components/base';\nimport { testContext } from '@qti-components/base';\nimport { sessionContext } from '@qti-components/base';\nimport { listenPublic as listenItemPublic } from '@qti-components/elements/public-events';\n\nimport { testHostContext } from '../../internal/test-host.context';\nimport { listenPublic } from '../../public-events';\n\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiContext } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { QtiAssessmentItemRef } from '../qti-assessment-item-ref/qti-assessment-item-ref';\nimport type { QtiAssessmentSection } from '../qti-assessment-section/qti-assessment-section';\nimport type { QtiAssessmentTest } from '../qti-assessment-test/qti-assessment-test';\nimport type { QtiTestPart } from '../qti-test-part/qti-test-part';\nimport type { QtiItemSessionControl } from '../qti-item-session-control/qti-item-session-control';\nimport type { ConfigContext } from '@qti-components/base';\nimport type { SessionContext } from '@qti-components/base';\nimport type { TestContext } from '@qti-components/base';\nimport type { ItemContext } from '@qti-components/base';\nimport type { ResponseVariable } from '@qti-components/base';\n\n/**\n * Whether an item's ended attempt reached the best achievable outcome:\n * 'optimal' (nothing to improve), 'suboptimal' (a better attempt is possible),\n * or 'unscored' (no machine-judgeable optimal value — see #assessOptimality).\n */\ntype ItemOptimality = 'optimal' | 'suboptimal' | 'unscored';\n\n/** A new object each time: a host that mutates the one it read must not change anyone else's. */\nconst newQtiContext = (): QtiContext => ({\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n});\n\nexport class TestNavigation extends LitElement {\n @property({ type: String }) identifier: string | undefined = undefined;\n\n @state()\n public initContext: { identifier: string; [key: string]: any }[] = [];\n\n /**\n * @deprecated Set `qtiContext` on `qti-test`, which provides it. This is an alias for the\n * enclosing test's: reading returns it, writing replaces it, so a host that has always set the\n * shuffle seed here keeps working. Removed in the next major.\n *\n * Written before the navigation is inside a test, it waits and is handed over on connect.\n */\n public get qtiContext(): QtiContext {\n return this.#owner()?.qtiContext ?? (this.#pendingQtiContext ??= newQtiContext());\n }\n\n public set qtiContext(value: QtiContext) {\n if (!this.#warnedQtiContext) {\n this.#warnedQtiContext = true;\n console.warn(\n '[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major ' +\n 'release. Set `qtiContext` on `<qti-test>` instead; it is the same value.'\n );\n }\n this.#writeQtiContext(value);\n }\n\n #pendingQtiContext?: QtiContext;\n #warnedQtiContext = false;\n\n /** The write the library itself makes. Not the deprecated setter, so it never warns about itself. */\n #writeQtiContext(value: QtiContext): void {\n const owner = this.#owner();\n if (owner) owner.qtiContext = value;\n else this.#pendingQtiContext = value;\n }\n\n /**\n * The `qti-test` this navigation is in, found through context so it works across shadow roots.\n * A write made before it is known waits in `#pendingQtiContext` and is handed over on arrival.\n */\n #testHost = new ContextConsumer(this, {\n context: testHostContext,\n subscribe: true,\n callback: host => {\n if (host && this.#pendingQtiContext) {\n host.qtiContext = this.#pendingQtiContext;\n this.#pendingQtiContext = undefined;\n }\n }\n });\n\n #owner(): { qtiContext: QtiContext } | null {\n return this.#testHost.value ?? null;\n }\n\n @state()\n @consume({ context: configContext, subscribe: true })\n public configContext: ConfigContext = {};\n\n @state()\n @consume({ context: testContext, subscribe: true })\n protected _testContext?: TestContext;\n\n @state()\n @consume({ context: sessionContext, subscribe: true })\n protected _sessionContext?: SessionContext;\n\n @state()\n @provide({ context: computedContext })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, attribute: 'auto-score-items' }) autoScoreItems = false;\n\n #testElement: QtiAssessmentTest;\n\n /**\n * Whether each item's last *ended attempt* reached the optimal outcome, keyed\n * by item-ref id. Written from #handleItemContextUpdated when processResponse\n * ends an attempt — never on a plain selection. Mirrors how inline feedback\n * only re-evaluates when an attempt is processed, so a freshly-picked answer\n * doesn't flip `done` until the candidate ends the attempt.\n */\n #optimality = new Map<string, ItemOptimality>();\n\n constructor() {\n super();\n listenPublic(this, 'cito-test-loaded', this.#handleTestConnected.bind(this));\n this.addEventListener('qti-assessment-item-connected', this.#handleItemConnected.bind(this));\n\n listenItemPublic(this, 'cito-item-response-changed', this.#handleInteractionChanged.bind(this));\n this.addEventListener('qti-item-context-updated', this.#handleItemContextUpdated.bind(this));\n\n listenPublic(this, 'cito-test-end-attempt', this.#handleTestEndAttempt.bind(this));\n listenPublic(this, 'cito-test-update-outcome', this.#handleTestUpdateOutcomeVariable.bind(this));\n }\n\n /**\n * Latch whether an item reached its optimal outcome whenever it has just ended\n * an attempt. processResponse — fired by test-end-attempt, autoscore, or an\n * in-item end-attempt interaction — flags its context update with\n * `responseProcessed`; a plain selection updates the context without it, so\n * `done` can't flip until the candidate actually ends the attempt.\n */\n #handleItemContextUpdated(event: CustomEvent<{ itemContext: ItemContext; responseProcessed?: boolean }>) {\n if (!event.detail?.responseProcessed) return;\n const itemContext = event.detail.itemContext;\n if (!itemContext?.identifier) return;\n const optimality = this.#assessOptimality(itemContext);\n this.#optimality.set(itemContext.identifier, optimality);\n\n const computedItem = this.computedItemFor(itemContext.identifier);\n const numAttempts = Number(itemContext.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n this.afterAttemptEnded(\n (event.composedPath()[0] as HTMLElement)?.closest<QtiAssessmentItem>('qti-assessment-item'),\n computedItem,\n this.#isItemDone(numAttempts, optimality, computedItem?.maxAttempts)\n );\n }\n\n /**\n * Extension point for presentation packages reacting to an ended attempt.\n * `done` is settled here — from the freshly latched optimality and the\n * session-control cascade — because the computed context only catches up on\n * the next update, after this event has finished bubbling.\n */\n protected afterAttemptEnded(\n _assessmentItem: QtiAssessmentItem | undefined,\n _computedItem: ComputedItem | undefined,\n _done: boolean\n ): void {}\n\n /** The computed-context entry for an item, from the session-control cascade. */\n protected computedItemFor(identifier: string): ComputedItem | undefined {\n return this.computedContext?.testParts\n ?.flatMap(part => part.sections)\n .flatMap(section => section.items)\n .find(i => i.identifier === identifier);\n }\n\n /** The assessment item for an item-ref id, if it has been rendered. */\n #assessmentItemFor(identifier: string | undefined): QtiAssessmentItem | undefined {\n if (!identifier) return undefined;\n const itemRef = this.#testElement?.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${identifier}\"]`\n );\n return itemRef?.assessmentItem ?? undefined;\n }\n\n /** The currently active assessment item, exposed for optional presentation extensions. */\n protected get activeAssessmentItem(): QtiAssessmentItem | undefined {\n if (!this.#testElement || !this._sessionContext?.navItemRefId) return undefined;\n return this.#testElement.querySelector<QtiAssessmentItemRef>(\n `qti-assessment-item-ref[identifier=\"${this._sessionContext.navItemRefId}\"]`\n )?.assessmentItem;\n }\n\n /**\n * Handles the 'test-end-attempt' event.\n * @private\n * @listens TestNavigation#test-end-attempt\n * @param {CustomEvent} event - The custom event object.\n */\n #handleTestEndAttempt(_event: CustomEvent) {\n const qtiAssessmentItemEl = this.activeAssessmentItem;\n if (!qtiAssessmentItemEl) return;\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n qtiAssessmentItemEl.processResponse(true, reportValidityAfterScoring);\n }\n\n #handleTestUpdateOutcomeVariable(event: CustomEvent) {\n const qtiAssessmentItemEl = this.#assessmentItemFor(event.detail?.assessmentItemRefId);\n if (!qtiAssessmentItemEl) return;\n qtiAssessmentItemEl.setOutcomeVariable(event.detail.outcomeVariableId, event.detail.value);\n }\n\n #handleInteractionChanged(_event: CustomEvent) {\n if (this.autoScoreItems) {\n const assessmentItem = (_event.composedPath()[0] as HTMLElement).closest<QtiAssessmentItem>(\n 'qti-assessment-item'\n );\n // Autoscoring resolves the item from the event's own path, so a change\n // raised outside an assessment item has nothing to score.\n if (!assessmentItem) return;\n const scoreOutcomeIdentifier = assessmentItem.variables.find(v => v.identifier === 'SCORE') as OutcomeVariable;\n if (\n scoreOutcomeIdentifier &&\n scoreOutcomeIdentifier.externalScored === null &&\n assessmentItem.adaptive === 'false'\n ) {\n const reportValidityAfterScoring = this.configContext?.reportValidityAfterScoring === true ? true : false;\n assessmentItem.processResponse(true, reportValidityAfterScoring);\n }\n }\n }\n\n override render() {\n // return this.myTemplate ? this.myTemplate(this.stampContext) : nothing;\n return html`<slot></slot>`;\n }\n\n /* PK: on test connected we can build the computed context */\n #handleTestConnected(event: CustomEvent) {\n this.#testElement = event.detail as QtiAssessmentTest;\n // A fresh test invalidates the per-test optimality latches.\n this.#optimality.clear();\n // Set the testIdentifier in qtiContext if not already set\n if (!this.qtiContext.QTI_CONTEXT?.testIdentifier) {\n const currentContext = this.qtiContext.QTI_CONTEXT || {\n testIdentifier: '',\n candidateIdentifier: 'not set',\n environmentIdentifier: 'default'\n };\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...currentContext,\n testIdentifier: this.#testElement.identifier,\n environmentIdentifier: currentContext.environmentIdentifier || 'default'\n }\n });\n }\n\n // Process qti-context-declaration elements to get default values\n const contextDeclarations = this.#testElement.querySelectorAll('qti-context-declaration[identifier=\"QTI_CONTEXT\"]');\n\n contextDeclarations.forEach(declaration => {\n const defaultValues = this.#extractDefaultValues(declaration);\n if (Object.keys(defaultValues).length > 0) {\n // Merge default values with current context, but don't override existing runtime values\n this.#writeQtiContext({\n QTI_CONTEXT: {\n ...defaultValues, // Default values first\n ...this.qtiContext.QTI_CONTEXT // Runtime values override defaults\n }\n });\n }\n });\n\n const testPartElements = Array.from(this.#testElement?.querySelectorAll<QtiTestPart>(`qti-test-part`) || []);\n this.computedContext = {\n identifier: this.#testElement.identifier,\n title: this.#testElement.title,\n view: this._sessionContext?.view,\n testParts: testPartElements.map(testPart => {\n const sectionElements = [...testPart.querySelectorAll<QtiAssessmentSection>(`qti-assessment-section`)];\n const testPartSessionControl = testPart.querySelector<QtiItemSessionControl>(\n ':scope > qti-item-session-control'\n );\n const partAllowSkipping = testPartSessionControl ? testPartSessionControl.allowSkipping : true;\n const partMaxAttempts = testPartSessionControl ? testPartSessionControl.maxAttempts : 1;\n const partShowFeedback = testPartSessionControl ? testPartSessionControl.showFeedback : false;\n const partShowSolution = testPartSessionControl ? testPartSessionControl.showSolution : false;\n return {\n active: false,\n identifier: testPart.identifier,\n navigationMode: testPart.navigationMode,\n submissionMode: testPart.submissionMode,\n allowSkipping: partAllowSkipping,\n sections: sectionElements.map(section => {\n const itemElements = [...section.querySelectorAll<QtiAssessmentItemRef>(`qti-assessment-item-ref`)];\n const sectionSessionControl = section.querySelector<QtiItemSessionControl>(\n ':scope > qti-item-session-control'\n );\n const sectionAllowSkipping = sectionSessionControl\n ? sectionSessionControl.allowSkipping\n : partAllowSkipping;\n const sectionMaxAttempts = sectionSessionControl ? sectionSessionControl.maxAttempts : partMaxAttempts;\n const sectionShowFeedback = sectionSessionControl ? sectionSessionControl.showFeedback : partShowFeedback;\n const sectionShowSolution = sectionSessionControl ? sectionSessionControl.showSolution : partShowSolution;\n return {\n active: false,\n identifier: section.identifier,\n title: section.title,\n navigationMode: section.navigationMode,\n submissionMode: section.submissionMode,\n allowSkipping: sectionAllowSkipping,\n items: itemElements.map(item => {\n const itemSessionControl = item.querySelector<QtiItemSessionControl>(\n ':scope > qti-item-session-control'\n );\n const itemAllowSkipping = itemSessionControl ? itemSessionControl.allowSkipping : sectionAllowSkipping;\n const itemMaxAttempts = itemSessionControl ? itemSessionControl.maxAttempts : sectionMaxAttempts;\n const itemShowFeedback = itemSessionControl ? itemSessionControl.showFeedback : sectionShowFeedback;\n const itemShowSolution = itemSessionControl ? itemSessionControl.showSolution : sectionShowSolution;\n return {\n ...this.initContext?.find(i => i.identifier === item.identifier),\n active: false,\n identifier: item.identifier,\n categories: item.category ? item.category?.split(' ') : [],\n href: item.href,\n variables: [] as OutcomeVariable[],\n allowSkipping: itemAllowSkipping,\n maxAttempts: itemMaxAttempts,\n showFeedback: itemShowFeedback,\n showSolution: itemShowSolution\n };\n })\n };\n })\n };\n })\n };\n }\n\n /**\n * Extract default values from a qti-context-declaration element\n */\n #extractDefaultValues(declaration: Element): Record<string, any> {\n const defaultValues: Record<string, any> = {};\n\n const defaultValueElement = declaration.querySelector('qti-default-value');\n if (!defaultValueElement) {\n return defaultValues;\n }\n\n const valueElements = defaultValueElement.querySelectorAll('qti-value[field-identifier]');\n valueElements.forEach(valueElement => {\n const fieldIdentifier = valueElement.getAttribute('field-identifier');\n const baseType = valueElement.getAttribute('base-type') || 'string';\n const textContent = valueElement.textContent?.trim() || '';\n\n if (fieldIdentifier) {\n // Convert value based on base-type\n let value: any = textContent;\n switch (baseType) {\n case 'integer':\n value = parseInt(textContent, 10);\n break;\n case 'float':\n case 'duration':\n value = parseFloat(textContent);\n break;\n case 'boolean':\n value = textContent.toLowerCase() === 'true';\n break;\n case 'string':\n default:\n value = textContent;\n break;\n }\n\n defaultValues[fieldIdentifier] = value;\n }\n });\n\n return defaultValues;\n }\n\n /* PK: on item connected we can add item only properties in the xml */\n #handleItemConnected(event: CustomEvent) {\n const itemElement = event.detail as QtiAssessmentItem;\n\n this.computedContext = {\n ...this.computedContext,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n items: section.items.map(item => {\n if (item.identifier !== itemElement.parentElement.getAttribute('identifier')) {\n return item;\n }\n\n const scoreOutcome = itemElement.querySelector<HTMLElement>(\n \"qti-outcome-declaration[identifier='SCORE']\"\n );\n // const scoreOutcome = item.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n const externalScored = scoreOutcome?.getAttribute('externalScored');\n\n const responseDeclarations = itemElement.querySelectorAll<HTMLElement>('qti-response-declaration');\n const containsCorrectResponse = Array.from(responseDeclarations).some((r: HTMLElement) =>\n r.querySelector('qti-correct-response')\n );\n // check if every responseDeclaration has a correctResponse\n const containsMapping = Array.from(responseDeclarations).some((r: HTMLElement) => {\n const mapping = r.querySelector('qti-mapping');\n const areaMapping = r.querySelector('qti-area-mapping');\n return mapping?.querySelector('qti-map-entry') || areaMapping?.querySelector('qti-area-map-entry');\n });\n\n const hasCorrectResponse = containsCorrectResponse || containsMapping;\n\n const hasResponseProcessing = itemElement.querySelector('qti-response-processing') ? true : false;\n\n return {\n ...item,\n assessmentItemIdentifier: itemElement.getAttribute('identifier'),\n label: itemElement.getAttribute('label'),\n title: itemElement.title,\n externalScored,\n adaptive: itemElement.adaptive == 'true' || false,\n timeDependent: itemElement.timeDependent == 'true' || false,\n variables: itemElement.variables,\n hasCorrectResponse,\n hasResponseProcessing\n };\n })\n };\n })\n };\n })\n };\n }\n\n /* PK: on every change of the candidate we will recomputed the computedContext */\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) return;\n\n let itemIndex = 1;\n this.computedContext = {\n ...this.computedContext,\n view: this._sessionContext?.view,\n testParts: this.computedContext.testParts.map(testPart => {\n return {\n ...testPart,\n active: this._sessionContext?.navPartId === testPart.identifier || false,\n sections: testPart.sections.map(section => {\n return {\n ...section,\n active: this._sessionContext?.navSectionId === section.identifier || false,\n completed: section.items.every(\n item =>\n this._testContext.items\n .find(i => i.identifier === item.identifier)\n ?.variables.find(v => v.identifier === 'completionStatus').value === 'completed'\n ),\n\n items: section.items.map(item => {\n const itemContext = this._testContext?.items.find(i => i.identifier === item.identifier);\n const computedItem = {\n ...item,\n ...itemContext,\n ...this.initContext?.find(i => i.identifier === item.identifier)\n };\n\n const rawscore = computedItem.variables?.find(vr => vr.identifier == 'SCORE')?.value;\n\n const score = rawscore === undefined || rawscore === null ? null : parseFloat(rawscore?.toString());\n\n const completionStatus = computedItem.variables?.find(v => v.identifier === 'completionStatus')\n ?.value as string;\n\n const response = computedItem.variables?.find(v => v.identifier === 'RESPONSE')?.value || '';\n const numAttempts =\n Number(computedItem.variables?.find(v => v.identifier === 'numAttempts')?.value) || 0;\n\n const active = this._sessionContext?.navItemRefId === computedItem.identifier || false;\n\n // Published by the item. One that is not on screen has nothing to be invalid.\n const valid = itemContext?.valid ?? true;\n\n const responseVars = itemContext?.variables?.filter(v => v.type === 'response') || [];\n\n const isDefaultResponse = responseVars.every(v => {\n if (v.value === undefined || v.value === null) {\n return true;\n }\n let fallbackValue: string;\n switch (v.baseType) {\n case 'integer':\n case 'float':\n case 'duration':\n fallbackValue = '0';\n break;\n case 'boolean':\n fallbackValue = 'false';\n break;\n case 'string':\n case 'directedPair':\n case 'identifier':\n case 'pair':\n case 'record':\n default:\n fallbackValue = '';\n break;\n }\n\n const defaultValue = v.defaultValue ?? fallbackValue;\n\n if (Array.isArray(v.value)) {\n const dv = Array.isArray(defaultValue) ? defaultValue : [defaultValue];\n return v.value.length === dv.length && v.value.every((val, i) => val === dv[i]);\n }\n\n return v.value === defaultValue;\n });\n\n // Computed and opiniated\n // const type = item.categories.includes(this.configContext?.infoItemCategory) ? 'info' : 'regular';\n // const correct = (type == 'regular' && score !== undefined && !isNaN(score) && score > 0) || false;\n // const incorrect = (type == 'regular' && score !== undefined && !isNaN(score) && score <= 0) || false;\n // const completed = completionStatus === 'completed';\n\n const index = item.categories.includes(this.configContext?.infoItemCategory) ? null : itemIndex++;\n const rawMaxScore = item.variables?.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const maxScore =\n rawMaxScore === undefined || rawMaxScore === null ? null : parseFloat(rawMaxScore?.toString());\n\n // Optimality comes from the last *ended attempt* (#optimality),\n // latched in #handleItemContextUpdated — never from a live\n // mid-attempt selection. On a restored session no attempt is ended\n // this run, so seed it once from the persisted context, which still\n // holds the submitted response.\n let optimality = this.#optimality.get(computedItem.identifier);\n if (optimality === undefined) {\n optimality = itemContext ? this.#assessOptimality(itemContext) : 'unscored';\n if (numAttempts > 0) this.#optimality.set(computedItem.identifier, optimality);\n }\n\n const done = this.#isItemDone(numAttempts, optimality, computedItem.maxAttempts);\n\n return {\n ...computedItem,\n completionStatus,\n numAttempts,\n score,\n response,\n index,\n active,\n valid,\n isDefaultResponse,\n maxScore,\n done,\n // Reflects the last *ended* attempt only. Read the latch directly\n // (not the `optimality` local) — the latch is written solely on\n // responseProcessed / restore-seed (line above, guarded by\n // numAttempts > 0), so a freshly-picked mid-attempt selection\n // computed live is never stored and never counts as optimal.\n optimal: this.#optimality.get(computedItem.identifier) === 'optimal'\n // type,\n // correct,\n // incorrect,\n // completed\n };\n })\n };\n })\n };\n })\n };\n\n this.dispatchEvent(\n new CustomEvent('qti-computed-context-updated', {\n detail: this.computedContext,\n bubbles: true\n })\n );\n }\n\n /**\n * Decide whether an item should be treated as \"the candidate is done with it\"\n * for the purpose of gating forward navigation and further attempts.\n *\n * - The candidate must have actually ended an attempt (numAttempts > 0).\n * - Once attempted, the item is done if they reached the optimal outcome\n * ('optimal'), or there's nothing to improve on ('unscored'). It is only *not*\n * done while a better attempt is still possible ('suboptimal') and attempts\n * remain — see #assessOptimality for how \"optimal\" is determined.\n *\n * `optimality` reflects the last *ended attempt* (see #optimality), not the\n * live selection — so a freshly-picked optimal answer doesn't count as done\n * until test-end-attempt evaluates it.\n */\n #isItemDone(numAttempts: number, optimality: ItemOptimality, maxAttempts: number | undefined): boolean {\n if (numAttempts === 0) return false;\n if (optimality !== 'suboptimal') return true;\n const max = maxAttempts ?? 1;\n return max > 0 && numAttempts >= max;\n }\n\n /**\n * Decide whether an item's submission is as good as it can get — i.e. the\n * candidate reached the *optimal* outcome, so there's no reason to make them\n * try again. 'optimal' means best achievable, 'suboptimal' means a better\n * attempt is still possible, 'unscored' means there's nothing to judge against.\n * (\"optimal\" is the spec's own word — a qti-correct-response is defined as\n * \"the (or an) optimal value\".)\n *\n * Two signals, in order of authority:\n * 1. The scored outcome: optimal ⟺ SCORE has reached its maximum (MAXSCORE).\n * This correctly handles partial-credit / qti-mapping items, where an exact\n * response match would under- or over-judge.\n * 2. The declared qti-correct-response, for items that aren't scored (no\n * SCORE/MAXSCORE) — an exact match is the best available proxy. Bookkeeping\n * variables like numAttempts can be typed 'response' but never declare a\n * correctResponse, so we filter on a declared correctResponse.\n *\n * Items with neither a comparable score nor a correctResponse (essays, info\n * items, etc.) are 'unscored' — there's no optimal value to require, so one\n * attempt is enough.\n */\n #assessOptimality(item: ItemContext): ItemOptimality {\n const variables = item.variables ?? [];\n\n const score = this.#numericVariable(variables, 'SCORE');\n const maxScore = this.#numericVariable(variables, 'MAXSCORE');\n if (score !== null && maxScore !== null) {\n return score >= maxScore ? 'optimal' : 'suboptimal';\n }\n\n const responseVars = variables.filter(\n (v): v is ResponseVariable =>\n v.type === 'response' &&\n (v as ResponseVariable).correctResponse !== undefined &&\n (v as ResponseVariable).correctResponse !== null\n );\n if (responseVars.length === 0) return 'unscored';\n const allMatch = responseVars.every(v => {\n const expected = v.correctResponse;\n const actual = v.value;\n if (actual === undefined || actual === null) return false;\n if (Array.isArray(expected) && Array.isArray(actual)) {\n return expected.length === actual.length && expected.every(e => actual.includes(e));\n }\n if (Array.isArray(expected) || Array.isArray(actual)) return false;\n return expected === actual;\n });\n return allMatch ? 'optimal' : 'suboptimal';\n }\n\n /** Read a single numeric outcome value, or null when absent / non-numeric. */\n #numericVariable(variables: ItemContext['variables'], identifier: string): number | null {\n const raw = variables?.find(v => v.identifier === identifier)?.value;\n if (raw === undefined || raw === null || Array.isArray(raw)) return null;\n const parsed = parseFloat(raw.toString());\n return Number.isNaN(parsed) ? null : parsed;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-navigation': TestNavigation;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const activeSection = testPart.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart.navigationMode;\n const submissionMode = activeSection?.submissionMode || testPart.submissionMode;\n const activeItem = this.sectionItems[this.itemIndex];\n\n const isLinearIndividual = navigationMode === 'linear' && submissionMode === 'individual';\n\n // In linear individual mode the candidate may only advance once they are\n // \"done\" with the active item: they reached the optimal outcome (best score),\n // exhausted maxAttempts, or the item has no judgeable optimal value. `done` is\n // computed centrally in test-navigation (#isItemDone), so this Next gate\n // matches the exact rule that decides an item is resolved.\n this._internalDisabled =\n !this.computedContext ||\n this.itemIndex < 0 ||\n this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 ||\n (isLinearIndividual && !activeItem?.done);\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * @deprecated test-paging-buttons-stamp is deprecated and will be removed in the future.\n */\n\nexport class TestPagingButtonsStamp extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n myTemplate: TemplateFunction;\n #internals: ElementInternals;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n constructor() {\n super();\n this.#internals = this.attachInternals();\n this.#internals.ariaLabel = 'pagination';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n override render() {\n if (!this.computedContext) return html``;\n const items = this.computedContext.testParts.flatMap(testPart =>\n testPart.sections.flatMap(section => section.items)\n );\n\n return html` ${items.map(item => this.myTemplate({ item, view: this.computedContext.view }))} `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-paging-buttons-stamp': TestPagingButtonsStamp;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const activeSection = testPart?.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || 'nonlinear';\n\n this._internalDisabled =\n navigationMode === 'linear' || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { state } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestPrintContext extends LitElement {\n @state()\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n override render() {\n return html` <small><pre>${JSON.stringify(this.computedContext, null, 2)}</pre></small> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-context': TestPrintContext;\n }\n}\n","import { html, css, LitElement } from 'lit';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ResponseVariable } from '@qti-components/base';\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestPrintVariables extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n public computedContext?: ComputedContext;\n\n static override styles = css`\n table {\n width: 100%;\n border-collapse: collapse;\n margin: 20px 0;\n font-size: 14px;\n text-align: left;\n }\n th,\n td {\n border: 1px solid #ddd;\n padding: 8px;\n }\n th {\n background-color: #f4f4f4;\n font-weight: bold;\n }\n h3 {\n margin-top: 20px;\n font-size: 16px;\n }\n `;\n\n override render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const responseVariables: ResponseVariable[] = activeItem.variables.filter(v => v.type === 'response');\n const outcomeVariables = activeItem.variables.filter(v => v.type === 'outcome');\n\n const renderTable = (variables: ResponseVariable[], title: string) => html`\n <h3>${title}</h3>\n <table>\n <thead>\n <tr>\n <th>Identifier</th>\n <th>Value</th>\n <th>Cardinality</th>\n <th>Base Type</th>\n <th>Correct Response / Mappings</th>\n </tr>\n </thead>\n <tbody>\n ${variables.map(v => {\n const correctResponse = v.correctResponse\n ? Array.isArray(v.correctResponse)\n ? v.correctResponse.join(', ')\n : v.correctResponse\n : '';\n\n const mapEntries = v.mapping?.mapEntries?.map(m => `${m.mapKey}=${m.mappedValue}pt`).join(', ') || '';\n\n const areaMapEntries =\n v.areaMapping?.areaMapEntries?.map(m => `${m.shape}(${m.coords})=${m.mappedValue}pt`).join(', ') || '';\n\n return html`\n <tr>\n <td>${v.identifier}</td>\n <td>${Array.isArray(v.value) ? v.value.join(', ') : v.value}</td>\n <td>${v.cardinality}</td>\n <td>${v.baseType}</td>\n <td>${correctResponse || mapEntries || areaMapEntries}</td>\n </tr>\n `;\n })}\n </tbody>\n </table>\n `;\n\n return html`\n ${renderTable(responseVariables, 'Response Variables')} ${renderTable(outcomeVariables, 'Outcome Variables')}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-print-item-variables': TestPrintVariables;\n }\n}\n","import { html, LitElement, nothing } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { computedContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { TemplateFunction } from '@heximal/templates';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestScoringButtons extends LitElement {\n @property({ type: String, attribute: 'view' }) view = ''; // is only an attribute, but this is here because.. react\n @property({ type: Boolean }) disabled: boolean = false;\n myTemplate: TemplateFunction | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n #changeOutcomeScore(value: number) {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const currentItemIdentifier = sectionItems.find(item => item.active)?.identifier;\n\n dispatchPublic(this, 'cito-test-update-outcome', {\n assessmentItemRefId: currentItemIdentifier,\n outcomeVariableId: 'SCORE',\n value\n });\n }\n\n override render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n const maxScore = activeItem.variables.find(vr => vr.identifier == 'MAXSCORE')?.value;\n const scoreOutcome = activeItem.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = scoreOutcome?.value;\n\n const disabled = !(scoreOutcome?.externalScored === 'human');\n\n if (!maxScore || !scoreOutcome) return nothing;\n const scores = [...Array(Number(maxScore) + 1).keys()];\n\n return html`${this.myTemplate ? this.myTemplate({ scores, score, disabled }) : nothing}`;\n }\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n const target = e.target as HTMLInputElement;\n const value = parseFloat(target.value);\n if (target.tagName === 'INPUT') {\n this.#changeOutcomeScore(value);\n }\n });\n\n // return maxScore\n // ? html`\n // <form part=\"form\">\n // ${[...Array(Number(maxScore) + 1).keys()].map(itemIndex => {\n // const identifier = `scoring-buttons${itemIndex}${activeItem.identifier}`;\n // return html` <input\n // part=\"input\"\n // type=\"radio\"\n // ?disabled=${this.disabled}\n // .checked=${itemIndex === Number(score)}\n // @change=${() => this._changeOutcomeScore(itemIndex)}\n // id=${identifier}\n // name=${`scoring-buttons-${activeItem.identifier}`}\n // value=${itemIndex}\n // />\n\n // <label part=\"label\" for=${identifier}>${itemIndex}</label>`;\n // })}\n // </form>\n // <slot></slot>\n // `\n // : nothing;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-buttons': TestScoringButtons;\n }\n}\n","import { consume } from '@lit/context';\nimport { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { OutcomeVariable } from '@qti-components/base';\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestScoringFeedback extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n protected computedContext?: ComputedContext;\n\n @property({ type: String, attribute: 'view' })\n public view: View = null;\n\n override render() {\n const activeItem = this.computedContext?.testParts\n .flatMap(testPart => testPart.sections.flatMap(section => section.items))\n .find(item => item.active);\n\n if (!activeItem || !activeItem.variables) return html``;\n\n if ((activeItem as any)['category'] === 'dep-informational') return html`<div>${this.dataset.informational}</div>`;\n\n const completionStatus = activeItem?.variables.find(v => v.identifier === 'completionStatus')?.value;\n const scoreOutcome = activeItem?.variables.find(vr => vr.identifier == 'SCORE') as OutcomeVariable;\n\n const score = parseFloat(scoreOutcome?.value as string);\n const externalScored = (activeItem as any)['externalScored'];\n\n const feedbackText = () => {\n if (completionStatus !== 'completed') {\n return this.dataset.textNoResponse;\n }\n\n if (!externalScored && score !== undefined && !Number.isNaN(score)) {\n return score > 0 ? this.dataset.textCorrect : this.dataset.textIncorrect;\n }\n\n if (externalScored === 'externalMachine') {\n return Number.isNaN(score) || score === undefined\n ? this.dataset.scoreUnknown\n : `We hebben je antwoord ${score === 0 ? 'geen punten' : score == 1 ? 'één punt' : `${score} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`;\n }\n\n if (externalScored === 'human') {\n return Number.isNaN(score) ? '' : 'Deze score heb je zelf toegekend.';\n }\n\n return this.dataset.inProgress;\n };\n\n return html`<div>${feedbackText()}</div>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-scoring-feedback': TestScoringFeedback;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * @deprecated test-section-buttons-stamp is deprecated and will be removed in the future.\n */\n\nexport class TestSectionButtonsStamp extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n myTemplate: TemplateFunction;\n #internals: ElementInternals;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n constructor() {\n super();\n this.#internals = this.attachInternals();\n this.#internals.ariaLabel = 'pagination';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n override render() {\n if (!this.computedContext) return html``;\n const sections = this.computedContext.testParts.flatMap(testPart => testPart.sections);\n\n return html` ${sections.map(item => this.myTemplate({ item }))} `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-buttons-stamp': TestSectionButtonsStamp;\n }\n}\n","import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'cito-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n","import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * A custom web component that renders a test stamp using the Lit framework.\n * This component is deprecated and will be removed in the future.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart || !activeSection || !activeItem) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = { ...activeSection, items: activeSection.items.map(({ variables, ...rest }) => rest) };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n","import { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { sessionContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { SessionContext } from '@qti-components/base';\nimport type { View } from '@qti-components/base';\n\nexport class TestView extends LitElement {\n static DEFAULT_VIEW_OPTIONS = ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'];\n\n @consume({ context: sessionContext, subscribe: true })\n private sessionContext: SessionContext;\n\n /** label accompanying the select view dropdown */\n @property({ type: String })\n label = 'view';\n\n /** The options to display in the dropdown, default: ['author', 'candidate', 'proctor', 'scorer', 'testConstructor', 'tutor'] */\n @property({ type: String, attribute: 'view-options' }) viewOptions: string;\n @watch('viewOptions', { waitUntilFirstUpdate: true })\n protected _handleViewOptionsChange = () => {\n this.#updateViewOptions();\n };\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#updateViewOptions();\n }\n\n @state()\n private _viewOptions: string[] = TestView.DEFAULT_VIEW_OPTIONS;\n\n #updateViewOptions() {\n if (this.viewOptions) {\n const options = this.viewOptions.split(',').map(opt => opt.trim());\n this._viewOptions = options.filter(opt => TestView.DEFAULT_VIEW_OPTIONS.includes(opt));\n } else {\n this._viewOptions = TestView.DEFAULT_VIEW_OPTIONS;\n }\n }\n\n protected _switchView(view: string) {\n dispatchPublic(this, 'cito-test-switch-view', view as View);\n }\n\n override render() {\n return html`\n <label part=\"label\" for=\"viewSelect\">${this.label}</label>\n <select\n part=\"select\"\n id=\"viewSelect\"\n @change=${(e: Event) => {\n const el = e.target as HTMLSelectElement;\n this._switchView(el.value);\n }}\n >\n ${this._viewOptions.map(\n v => html`<option value=\"${v}\" ?selected=${v === this.sessionContext.view}>${v}</option>`\n )}\n </select>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view': TestView;\n }\n}\n","import { consume } from '@lit/context';\nimport { html, LitElement, nothing } from 'lit';\nimport { prepareTemplate } from '@heximal/templates';\n\nimport { sessionContext } from '@qti-components/base';\n\nimport { dispatchPublic } from '../../public-events';\n\nimport type { PropertyValues } from 'lit';\nimport type { SessionContext } from '@qti-components/base';\nimport type { View } from '@qti-components/base';\n\nexport class TestViewToggle extends LitElement {\n myTemplate: any;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n @consume({ context: sessionContext, subscribe: true })\n private sessionContext: SessionContext;\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n _switchView(view: string) {\n dispatchPublic(this, 'cito-test-switch-view', view as View);\n }\n\n protected override firstUpdated(_changedProperties: PropertyValues): void {\n this.addEventListener('click', () => {\n if (this.sessionContext?.view === 'scorer') {\n this._switchView('candidate');\n } else {\n this._switchView('scorer');\n }\n });\n }\n\n override render() {\n return html`${this.myTemplate\n ? this.myTemplate({\n view: this.sessionContext?.view\n })\n : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-view-toggle': TestViewToggle;\n }\n}\n","import { QtiAssessmentItemRef } from './components/qti-assessment-item-ref/qti-assessment-item-ref';\nimport { QtiAssessmentSection } from './components/qti-assessment-section/qti-assessment-section';\nimport { QtiAssessmentTest } from './components/qti-assessment-test/qti-assessment-test';\nimport { QtiBranchRule } from './components/qti-branch-rule/qti-branch-rule';\nimport { QtiItemSessionControl } from './components/qti-item-session-control/qti-item-session-control';\nimport { QtiNumberSelected } from './components/qti-number-selected/qti-number-selected';\nimport { QtiPreCondition } from './components/qti-pre-condition/qti-pre-condition';\nimport { QtiOutcomeProcessing } from './components/qti-outcome-processing/qti-outcome-processing';\nimport { QtiTestFeedback } from './components/qti-test-feedback/qti-test-feedback';\nimport { QtiTestPart } from './components/qti-test-part/qti-test-part';\nimport { QtiTestVariables } from './components/qti-test-variables/qti-test-variables';\nimport { QtiTest } from './components/qti-test/qti-test';\nimport { TestCheckItem } from './components/test-check-item/test-check-item';\nimport { TestContainer } from './components/test-container/test-container';\nimport { TestEndAttempt } from './components/test-end-attempt/test-end-attempt';\nimport { TestItemLink } from './components/test-item-link/test-item-link';\nimport {\n TestItemToSpeech,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop\n} from './components/test-item-to-speech/test-item-to-speech';\nimport { TestNavigation } from './components/test-navigation/test-navigation';\nimport { TestNext } from './components/test-next/test-next';\nimport { TestPagingButtonsStamp } from './components/test-paging-buttons-stamp/test-paging-buttons-stamp';\nimport { TestPrev } from './components/test-prev/test-prev';\nimport { TestPrintContext } from './components/test-print-context/test-print-context';\nimport { TestPrintVariables } from './components/test-print-item-variables/test-print-item-variables';\nimport { TestScoringButtons } from './components/test-scoring-buttons/test-scoring-buttons';\nimport { TestScoringFeedback } from './components/test-scoring-feedback/test-scoring-feedback';\nimport { TestSectionButtonsStamp } from './components/test-section-buttons-stamp/test-section-buttons-stamp';\nimport { TestSectionLink } from './components/test-section-link/test-section-link';\nimport { TestStamp } from './components/test-stamp/test-stamp';\nimport { TestView } from './components/test-view-toggle/test-view';\nimport { TestViewToggle } from './components/test-view-toggle/test-view-toggle';\n\nexport {\n QtiAssessmentItemRef,\n QtiAssessmentSection,\n QtiAssessmentTest,\n QtiBranchRule,\n QtiItemSessionControl,\n QtiNumberSelected,\n QtiOutcomeProcessing,\n QtiPreCondition,\n QtiTest,\n QtiTestFeedback,\n QtiTestPart,\n QtiTestVariables,\n TestCheckItem,\n TestContainer,\n TestEndAttempt,\n TestItemLink,\n TestItemToSpeech,\n TestNavigation,\n TestNext,\n TestPagingButtonsStamp,\n TestPrev,\n TestPrintContext,\n TestPrintVariables,\n TestScoringButtons,\n TestScoringFeedback,\n TestSectionButtonsStamp,\n TestSectionLink,\n TestStamp,\n TestTtsNext,\n TestTtsPause,\n TestTtsPick,\n TestTtsPlay,\n TestTtsPrev,\n TestTtsResume,\n TestTtsStop,\n TestView,\n TestViewToggle\n};\n\nexport const qtiTestElements = [\n { tag: 'qti-assessment-item-ref', ctor: QtiAssessmentItemRef },\n { tag: 'qti-assessment-section', ctor: QtiAssessmentSection },\n { tag: 'qti-assessment-test', ctor: QtiAssessmentTest },\n { tag: 'qti-branch-rule', ctor: QtiBranchRule },\n { tag: 'qti-item-session-control', ctor: QtiItemSessionControl },\n { tag: 'qti-number-selected', ctor: QtiNumberSelected },\n { tag: 'qti-outcome-processing', ctor: QtiOutcomeProcessing },\n { tag: 'qti-pre-condition', ctor: QtiPreCondition },\n { tag: 'qti-test', ctor: QtiTest },\n { tag: 'qti-test-feedback', ctor: QtiTestFeedback },\n { tag: 'qti-test-part', ctor: QtiTestPart },\n { tag: 'qti-test-variables', ctor: QtiTestVariables },\n { tag: 'test-check-item', ctor: TestCheckItem },\n { tag: 'test-container', ctor: TestContainer },\n { tag: 'test-end-attempt', ctor: TestEndAttempt },\n { tag: 'test-item-link', ctor: TestItemLink },\n { tag: 'test-item-to-speech', ctor: TestItemToSpeech },\n { tag: 'test-navigation', ctor: TestNavigation },\n { tag: 'test-next', ctor: TestNext },\n { tag: 'test-paging-buttons-stamp', ctor: TestPagingButtonsStamp },\n { tag: 'test-prev', ctor: TestPrev },\n { tag: 'test-print-context', ctor: TestPrintContext },\n { tag: 'test-print-item-variables', ctor: TestPrintVariables },\n { tag: 'test-scoring-buttons', ctor: TestScoringButtons },\n { tag: 'test-scoring-feedback', ctor: TestScoringFeedback },\n { tag: 'test-section-buttons-stamp', ctor: TestSectionButtonsStamp },\n { tag: 'test-section-link', ctor: TestSectionLink },\n { tag: 'test-stamp', ctor: TestStamp },\n { tag: 'test-tts-next', ctor: TestTtsNext },\n { tag: 'test-tts-pause', ctor: TestTtsPause },\n { tag: 'test-tts-pick', ctor: TestTtsPick },\n { tag: 'test-tts-play', ctor: TestTtsPlay },\n { tag: 'test-tts-prev', ctor: TestTtsPrev },\n { tag: 'test-tts-resume', ctor: TestTtsResume },\n { tag: 'test-tts-stop', ctor: TestTtsStop },\n { tag: 'test-view', ctor: TestView },\n { tag: 'test-view-toggle', ctor: TestViewToggle }\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAAA,gBAAe;AACpC,SAAS,UAAU,aAAa;AAChC,SAAS,eAAe;;;ACFxB,SACE,UAAU,WAEV,eAIK;;;ACFA,IAAM,WAAW,CAAC,MAAM;AACxB,IAAM,kBAAkB,CAAC,KAAK,KAAK,GAAG;AACtC,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAGK,IAAM,aAAqC;EAChD,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EAEL,MAAM;EACN,KAAK;EACL,MAAM;EACN,MAAM;EACN,MAAM;EACN,KAAK;EACL,KAAK;EACL,KAAK;;EAGL,MAAM;EACN,MAAM;EACN,OAAO;EACP,OAAO;;EAGP,MAAM;EACN,KAAK;EACL,MAAM;EACN,KAAK;;EAGL,KAAK;EACL,KAAK;;EAGL,KAAK;EACL,KAAK;EACL,KAAK;;EAGL,KAAK;EACL,KAAK;EACL,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BAAsB,MAAM,iBAAgB;EACnD,EAAE,KAAK,6BAA6B,MAAM,mBAAkB;EAC5D,EAAE,KAAK,wBAAwB,MAAM,mBAAkB;EACvD,EAAE,KAAK,yBAAyB,MAAM,oBAAmB;EACzD,EAAE,KAAK,8BAA8B,MAAM,wBAAuB;EAClE,EAAE,KAAK,qBAAqB,MAAM,gBAAe;EACjD,EAAE,KAAK,cAAc,MAAM,UAAS;EACpC,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,kBAAkB,MAAM,aAAY;EAC3C,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,mBAAmB,MAAM,cAAa;EAC7C,EAAE,KAAK,iBAAiB,MAAM,YAAW;EACzC,EAAE,KAAK,aAAa,MAAM,SAAQ;EAClC,EAAE,KAAK,oBAAoB,MAAM,eAAc;;","names":["nothing","Kind","astFactory","property","receiver","args","c","params","body","handlers","renderers","model","listenPublic","nothing","consume","LitElement","property","stringToBooleanConverter","LitElement","__decorate","property","consume","consume","html","LitElement","property","LitElement","html","__decorate","property","consume","html","LitElement","property","LitElement","html","__decorate","property","html","LitElement","property","stringToBooleanConverter","__decorate","listenPublic","css","html","LitElement","LitElement","css","html","css","html","LitElement","LitElement","css","html","css","html","css","html","html","LitElement","property","__decorate","consume","listenPublic","__decorate","consume","testContext","provide","html","LitElement","state","property","listenPublic","__decorate","property","listenPublic","LitElement","property","state","listenPublic","__decorate","property","LitElement","state","listenPublic","LitElement","html","__decorate","state","provide","consume","css","html","LitElement","css","LitElement","css","html","__decorate","consume","consume","LitElement","html","property","state","LitElement","html","__decorate","property","state","consume","css","html","LitElement","property","consume","LitElement","css","testPart","html","__decorate","consume","property","css","html","LitElement","property","LitElement","css","html","__decorate","property","html","LitElement","css","consume","provide","createContext","property","state","createContext","html","LitElement","css","state","__decorate","property","consume","provide","consume","provide","html","LitElement","property","state","LitElement","listenPublic","html","__decorate","property","state","consume","provide","css","html","LitElement","property","consume","LitElement","css","testPart","html","__decorate","property","consume","html","LitElement","consume","LitElement","html","__decorate","consume","css","html","LitElement","property","consume","LitElement","css","testPart","html","__decorate","property","consume","html","LitElement","consume","state","LitElement","html","__decorate","state","consume","html","css","LitElement","consume","LitElement","css","html","__decorate","consume","html","LitElement","nothing","consume","property","LitElement","testPart","html","nothing","__decorate","property","consume","consume","html","LitElement","property","LitElement","html","__decorate","consume","property","html","LitElement","consume","LitElement","html","__decorate","consume","css","html","LitElement","property","LitElement","css","html","__decorate","property","html","LitElement","nothing","property","state","consume","LitElement","variables","html","nothing","__decorate","property","state","consume","html","LitElement","property","state","consume","LitElement","html","__decorate","consume","property","state","consume","html","LitElement","nothing","LitElement","html","nothing","__decorate","consume"]}