@interlacejs/quiz 0.2.0 → 0.2.1

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.
package/dist/index.cjs CHANGED
@@ -326,11 +326,11 @@ function getQuizAuthoringIssues(data) {
326
326
  issues.push(`${label} needs text`);
327
327
  }
328
328
  if (question.options.length < 2) {
329
- issues.push(`${label} needs at least 2 answers`);
329
+ issues.push(`${label} needs at least 2 options`);
330
330
  }
331
331
  question.options.forEach((option, optionIndex) => {
332
332
  if (option.text.trim().length === 0) {
333
- issues.push(`${label}, answer ${optionIndex + 1} needs text`);
333
+ issues.push(`${label}, option ${optionIndex + 1} needs text`);
334
334
  }
335
335
  });
336
336
  const hasCorrect = question.options.some(
@@ -344,7 +344,7 @@ function getQuizAuthoringIssues(data) {
344
344
  // src/quiz-editor.ts
345
345
  var quizEditorControllers = /* @__PURE__ */ new WeakMap();
346
346
  var editorInstanceCount = 0;
347
- var MIN_ANSWERS = 2;
347
+ var MIN_OPTIONS = 2;
348
348
  function buildMediaRef(src, alt) {
349
349
  if (src.length === 0) return void 0;
350
350
  return alt.length > 0 ? { src, alt } : { src };
@@ -703,33 +703,33 @@ function createQuizEditorController(container, data, onChange) {
703
703
  });
704
704
  questionField.appendChild(questionMedia.root);
705
705
  body.appendChild(questionField);
706
- const answersSection = document.createElement("div");
707
- answersSection.style.display = "flex";
708
- answersSection.style.flexDirection = "column";
709
- answersSection.style.gap = `${import_core.SPACE[2]}px`;
710
- const answersHeading = document.createElement("div");
711
- answersHeading.id = `${uid}-answers-label`;
712
- answersHeading.className = "interlace-label quiz-answers-heading";
713
- answersHeading.textContent = "Answers";
714
- answersHeading.style.fontSize = `${import_core.TYPE.sm}px`;
715
- answersHeading.style.fontWeight = "600";
716
- const answersHint = document.createElement("p");
717
- answersHint.id = `${uid}-answers-hint`;
718
- answersHint.className = "interlace-hint quiz-answers-hint";
719
- answersHint.textContent = "Select the correct answer.";
720
- answersHint.style.margin = "0";
721
- answersHint.style.fontSize = `${import_core.TYPE.sm}px`;
722
- answersHint.style.color = import_core.COLORS.textMuted;
706
+ const optionsSection = document.createElement("div");
707
+ optionsSection.style.display = "flex";
708
+ optionsSection.style.flexDirection = "column";
709
+ optionsSection.style.gap = `${import_core.SPACE[2]}px`;
710
+ const optionsHeading = document.createElement("div");
711
+ optionsHeading.id = `${uid}-options-label`;
712
+ optionsHeading.className = "interlace-label quiz-options-heading";
713
+ optionsHeading.textContent = "Options";
714
+ optionsHeading.style.fontSize = `${import_core.TYPE.sm}px`;
715
+ optionsHeading.style.fontWeight = "600";
716
+ const optionsHint = document.createElement("p");
717
+ optionsHint.id = `${uid}-options-hint`;
718
+ optionsHint.className = "interlace-hint quiz-options-hint";
719
+ optionsHint.textContent = "Select the correct answer.";
720
+ optionsHint.style.margin = "0";
721
+ optionsHint.style.fontSize = `${import_core.TYPE.sm}px`;
722
+ optionsHint.style.color = import_core.COLORS.textMuted;
723
723
  const optionsContainer = document.createElement("div");
724
724
  optionsContainer.className = "quiz-options";
725
725
  optionsContainer.setAttribute("role", "radiogroup");
726
- optionsContainer.setAttribute("aria-labelledby", answersHeading.id);
727
- optionsContainer.setAttribute("aria-describedby", answersHint.id);
726
+ optionsContainer.setAttribute("aria-labelledby", optionsHeading.id);
727
+ optionsContainer.setAttribute("aria-describedby", optionsHint.id);
728
728
  optionsContainer.style.display = "flex";
729
729
  optionsContainer.style.flexDirection = "column";
730
730
  optionsContainer.style.gap = `${import_core.SPACE[2]}px`;
731
731
  const addOptionButton = createButton(
732
- "+ Add answer",
732
+ "+ Add option",
733
733
  "secondary",
734
734
  "quiz-add-option"
735
735
  );
@@ -751,13 +751,13 @@ function createQuizEditorController(container, data, onChange) {
751
751
  };
752
752
  });
753
753
  });
754
- answersSection.append(
755
- answersHeading,
756
- answersHint,
754
+ optionsSection.append(
755
+ optionsHeading,
756
+ optionsHint,
757
757
  optionsContainer,
758
758
  addOptionButton
759
759
  );
760
- body.appendChild(answersSection);
760
+ body.appendChild(optionsSection);
761
761
  container.appendChild(root);
762
762
  const createOptionRow = (option, optionIndex, optionCount) => {
763
763
  const number = optionIndex + 1;
@@ -777,7 +777,7 @@ function createQuizEditorController(container, data, onChange) {
777
777
  radio.className = "quiz-option-correct";
778
778
  radio.value = option.id;
779
779
  radio.checked = option.id === currentData.questions[selectedIndex]?.correctOptionId;
780
- radio.setAttribute("aria-label", `Mark answer ${number} as correct`);
780
+ radio.setAttribute("aria-label", `Mark option ${number} as correct`);
781
781
  radio.style.width = "18px";
782
782
  radio.style.height = "18px";
783
783
  radio.style.margin = "0";
@@ -795,12 +795,12 @@ function createQuizEditorController(container, data, onChange) {
795
795
  const textInput = createInput(
796
796
  "quiz-option-text",
797
797
  `${idPrefix}-text`,
798
- "Answer text"
798
+ "Option text"
799
799
  );
800
800
  textInput.value = option.text;
801
801
  textInput.style.gridColumn = "2";
802
802
  textInput.style.gridRow = "2";
803
- const label = createLabel(`Answer ${number}`, textInput.id);
803
+ const label = createLabel(`Option ${number}`, textInput.id);
804
804
  label.style.gridColumn = "2";
805
805
  label.style.gridRow = "1";
806
806
  const error = createErrorText(`${idPrefix}-error`, "quiz-option-error");
@@ -809,7 +809,7 @@ function createQuizEditorController(container, data, onChange) {
809
809
  setFieldError(
810
810
  textInput,
811
811
  error,
812
- show ? `Answer ${number} needs text` : null
812
+ show ? `Option ${number} needs text` : null
813
813
  );
814
814
  };
815
815
  textInput.addEventListener("input", () => {
@@ -837,7 +837,7 @@ function createQuizEditorController(container, data, onChange) {
837
837
  const media = createMediaEditor({
838
838
  classPrefix: "quiz-option-media",
839
839
  idPrefix: `${idPrefix}-media`,
840
- addLabel: `Add image to answer ${number}`,
840
+ addLabel: `Add image to option ${number}`,
841
841
  previewSlotClass: "quiz-option-media-preview",
842
842
  previewClass: "quiz-option-thumb",
843
843
  onEdit: (next) => {
@@ -860,13 +860,13 @@ function createQuizEditorController(container, data, onChange) {
860
860
  media.root.style.alignSelf = "stretch";
861
861
  details.append(error, media.root);
862
862
  const remove = createRemoveButton("quiz-option-remove");
863
- remove.setAttribute("aria-label", `Remove answer ${number}`);
863
+ remove.setAttribute("aria-label", `Remove option ${number}`);
864
864
  remove.style.gridColumn = "3";
865
865
  remove.style.gridRow = "2";
866
866
  setRemoveAllowed(
867
867
  remove,
868
- optionCount > MIN_ANSWERS,
869
- `A question needs at least ${MIN_ANSWERS} answers`
868
+ optionCount > MIN_OPTIONS,
869
+ `A question needs at least ${MIN_OPTIONS} options`
870
870
  );
871
871
  remove.addEventListener("click", () => {
872
872
  patchActiveQuestion((question) => {
@@ -978,7 +978,7 @@ function createQuizEditorController(container, data, onChange) {
978
978
  setFieldError(
979
979
  row.textInput,
980
980
  row.error,
981
- show ? `Answer ${optionIndex + 1} needs text` : null
981
+ show ? `Option ${optionIndex + 1} needs text` : null
982
982
  );
983
983
  });
984
984
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/quiz-editor.ts","../src/tokens.ts","../src/quiz-player.ts","../src/validate.ts","../src/quiz-content-type.ts"],"sourcesContent":["export { QuizContentType } from \"./quiz-content-type\";\nexport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nexport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nexport { getQuizAuthoringIssues, validateQuizData } from \"./validate\";\n\nexport type { QuizPlaybackCallbacks } from \"./quiz-player\";\nexport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\n","import { ContentType, ensureInterlaceStyles } from \"@interlacejs/core\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\nimport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\ninterface QuizEditorController {\n syncTo(data: QuizData, onChange: (next: QuizData) => void): void;\n}\n\n/**\n * Controllers are stashed per container so the slot can hand the same\n * controller back across the mount/update lifecycle. The slot always passes\n * the same container element to `renderEditor`/`updateEditor`/`unmount`.\n */\nconst quizEditorControllers = new WeakMap<HTMLElement, QuizEditorController>();\n\n/** Gives each mounted editor unique element ids and radio group names. */\nlet editorInstanceCount = 0;\n\n/** Fewest answers a question may be reduced to via the remove buttons. */\nconst MIN_ANSWERS = 2;\n\n/** Builds a media ref from src/alt text; `undefined` when src is blank. */\nfunction buildMediaRef(src: string, alt: string): QuizMediaRef | undefined {\n if (src.length === 0) return undefined;\n return alt.length > 0 ? { src, alt } : { src };\n}\n\n/** Creates a preview `<img>` for a media ref, or `null` when src is blank. */\nfunction createPreview(\n media: QuizMediaRef | undefined,\n className: string,\n): HTMLImageElement | null {\n if (!media || media.src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = media.src;\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"160px\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginTop = `${SPACE[1]}px`;\n if (media.alt) img.alt = media.alt;\n return img;\n}\n\n/** Renders `media` into `slot`, replacing any previous preview. */\nfunction syncPreview(\n slot: HTMLElement,\n media: QuizMediaRef | undefined,\n className: string,\n): void {\n slot.innerHTML = \"\";\n const img = createPreview(media, className);\n if (img) slot.appendChild(img);\n}\n\n/** Generates an option id that does not collide with existing ids. */\nfunction nextOptionId(options: QuizOption[], index: number): string {\n const base = `opt-${index}`;\n if (!options.some((option) => option.id === base)) return base;\n let candidate = index + 1;\n while (options.some((option) => option.id === `opt-${candidate}`)) {\n candidate += 1;\n }\n return `opt-${candidate}`;\n}\n\n/** Generates a question id that does not collide with existing ids. */\nfunction nextQuestionId(questions: QuizQuestionSpec[], index: number): string {\n const base = `q-${index}`;\n if (!questions.some((question) => question.id === base)) return base;\n let candidate = index + 1;\n while (questions.some((question) => question.id === `q-${candidate}`)) {\n candidate += 1;\n }\n return `q-${candidate}`;\n}\n\n/** An empty question stub so the form is never without a question. */\n/** A new question starts with the minimum of two answers, the first correct. */\nfunction emptyQuestion(id: string): QuizQuestionSpec {\n return {\n id,\n text: \"\",\n options: [\n { id: `${id}-a`, text: \"\" },\n { id: `${id}-b`, text: \"\" },\n ],\n correctOptionId: `${id}-a`,\n };\n}\n\n/**\n * Shows or hides an element. Uses inline `display` rather than `hidden`\n * because the shared `interlace-*` rules set `display` and would override\n * the user-agent `[hidden]` rule.\n */\nfunction setShown(el: HTMLElement, shown: boolean, display = \"\"): void {\n el.style.display = shown ? display : \"none\";\n}\n\n/** Sets an input's value only when it differs, so the caret is not moved. */\nfunction setValue(input: HTMLInputElement, value: string): void {\n if (input.value !== value) input.value = value;\n}\n\nfunction createButton(\n text: string,\n variant: \"primary\" | \"secondary\" | \"ghost\",\n className: string,\n): HTMLButtonElement {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `interlace-btn interlace-btn--${variant} ${className}`;\n button.textContent = text;\n return button;\n}\n\n/** A quiet \"×\" icon button for per-row remove actions. */\nfunction createRemoveButton(className: string): HTMLButtonElement {\n const button = createButton(\"×\", \"ghost\", `interlace-btn--icon ${className}`);\n button.style.fontSize = `${TYPE.lg}px`;\n button.style.lineHeight = \"1\";\n return button;\n}\n\n/** Enables a remove button, or disables it with `reason` as its tooltip. */\nfunction setRemoveAllowed(\n button: HTMLButtonElement,\n allowed: boolean,\n reason: string,\n): void {\n button.disabled = !allowed;\n if (allowed) button.removeAttribute(\"title\");\n else button.title = reason;\n}\n\nfunction createInput(\n className: string,\n id: string,\n placeholder?: string,\n): HTMLInputElement {\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.id = id;\n input.className = `interlace-input ${className}`;\n input.style.width = \"100%\";\n input.style.boxSizing = \"border-box\";\n if (placeholder) input.placeholder = placeholder;\n return input;\n}\n\nfunction createLabel(text: string, forId: string): HTMLLabelElement {\n const label = document.createElement(\"label\");\n label.className = \"interlace-label\";\n label.htmlFor = forId;\n label.textContent = text;\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.fontWeight = \"600\";\n return label;\n}\n\n/** A labelled field (label above input) wrapped in `interlace-field`. */\nfunction createField(\n labelText: string,\n input: HTMLInputElement,\n): HTMLDivElement {\n const field = document.createElement(\"div\");\n field.className = \"interlace-field\";\n field.style.display = \"flex\";\n field.style.flexDirection = \"column\";\n field.style.gap = `${SPACE[1]}px`;\n field.append(createLabel(labelText, input.id), input);\n return field;\n}\n\n/** An inline error message element, hidden until a message is set. */\nfunction createErrorText(id: string, className: string): HTMLParagraphElement {\n const error = document.createElement(\"p\");\n error.id = id;\n error.className = `interlace-hint quiz-field-error ${className}`;\n error.style.margin = \"0\";\n error.style.fontSize = `${TYPE.sm}px`;\n error.style.color = COLORS.errorText;\n setShown(error, false);\n return error;\n}\n\n/** Shows `message` for `input` (with aria wiring), or clears it on `null`. */\nfunction setFieldError(\n input: HTMLInputElement,\n error: HTMLElement,\n message: string | null,\n): void {\n if (message) {\n error.textContent = message;\n setShown(error, true);\n input.setAttribute(\"aria-invalid\", \"true\");\n input.setAttribute(\"aria-describedby\", error.id);\n } else {\n error.textContent = \"\";\n setShown(error, false);\n input.removeAttribute(\"aria-invalid\");\n input.removeAttribute(\"aria-describedby\");\n }\n}\n\ninterface MediaEditor {\n root: HTMLDivElement;\n srcInput: HTMLInputElement;\n altInput: HTMLInputElement;\n previewSlot: HTMLDivElement;\n /** Patches values/preview in place and shows or collapses the panel. */\n sync(media: QuizMediaRef | undefined, expanded: boolean): void;\n}\n\ninterface MediaEditorOptions {\n /** Class prefix, e.g. `quiz-question-media` → `quiz-question-media-src`. */\n classPrefix: string;\n idPrefix: string;\n /** Accessible name of the \"Add image\" button. */\n addLabel: string;\n previewSlotClass: string;\n previewClass: string;\n /** The author edited the URL or alt text. */\n onEdit(media: QuizMediaRef | undefined): void;\n /** The author expanded the panel via \"Add image\". */\n onExpand(): void;\n /** The author removed the image (fields are already cleared). */\n onRemove(): void;\n}\n\n/**\n * Image URL + alt fields tucked behind a ghost \"Add image\" button. The\n * panel opens on demand (or automatically when media exists, via `sync`)\n * and \"Remove image\" clears both fields and collapses it again.\n */\nfunction createMediaEditor(options: MediaEditorOptions): MediaEditor {\n const { classPrefix, idPrefix } = options;\n const root = document.createElement(\"div\");\n root.className = classPrefix;\n\n const addButton = createButton(\"+ Add image\", \"ghost\", `${classPrefix}-add`);\n addButton.setAttribute(\"aria-label\", options.addLabel);\n addButton.setAttribute(\"aria-controls\", `${idPrefix}-panel`);\n addButton.style.paddingLeft = `${SPACE[2]}px`;\n addButton.style.paddingRight = `${SPACE[2]}px`;\n\n const panel = document.createElement(\"div\");\n panel.id = `${idPrefix}-panel`;\n panel.className = `${classPrefix}-panel`;\n panel.style.flexDirection = \"column\";\n panel.style.gap = `${SPACE[2]}px`;\n panel.style.padding = `${SPACE[3]}px`;\n panel.style.backgroundColor = COLORS.surfaceRaised;\n panel.style.border = `1px solid ${COLORS.border}`;\n panel.style.borderRadius = `${RADIUS.md}`;\n\n const srcInput = createInput(\n `${classPrefix}-src`,\n `${idPrefix}-src`,\n \"https://example.com/image.png\",\n );\n const altInput = createInput(\n `${classPrefix}-alt`,\n `${idPrefix}-alt`,\n \"Describe the image for screen readers\",\n );\n const previewSlot = document.createElement(\"div\");\n previewSlot.className = options.previewSlotClass;\n\n const removeButton = createButton(\n \"Remove image\",\n \"ghost\",\n `${classPrefix}-remove`,\n );\n removeButton.style.alignSelf = \"flex-start\";\n\n panel.append(\n createField(\"Image URL\", srcInput),\n createField(\"Image description (alt text)\", altInput),\n previewSlot,\n removeButton,\n );\n root.append(addButton, panel);\n\n const setExpanded = (expanded: boolean): void => {\n setShown(panel, expanded, \"flex\");\n setShown(addButton, !expanded);\n addButton.setAttribute(\"aria-expanded\", String(expanded));\n };\n setExpanded(false);\n\n const handleEdit = (): void => {\n const media = buildMediaRef(srcInput.value, altInput.value);\n syncPreview(previewSlot, media, options.previewClass);\n options.onEdit(media);\n };\n srcInput.addEventListener(\"input\", handleEdit);\n altInput.addEventListener(\"input\", handleEdit);\n\n addButton.addEventListener(\"click\", () => {\n setExpanded(true);\n options.onExpand();\n srcInput.focus();\n });\n removeButton.addEventListener(\"click\", () => {\n srcInput.value = \"\";\n altInput.value = \"\";\n syncPreview(previewSlot, undefined, options.previewClass);\n setExpanded(false);\n options.onRemove();\n addButton.focus();\n });\n\n const sync = (media: QuizMediaRef | undefined, expanded: boolean): void => {\n setValue(srcInput, media?.src ?? \"\");\n setValue(altInput, media?.alt ?? \"\");\n syncPreview(previewSlot, media, options.previewClass);\n setExpanded(expanded);\n };\n\n return { root, srcInput, altInput, previewSlot, sync };\n}\n\ninterface OptionRow {\n row: HTMLDivElement;\n radio: HTMLInputElement;\n textInput: HTMLInputElement;\n error: HTMLParagraphElement;\n media: MediaEditor;\n}\n\n/**\n * Builds the quiz authoring form once and returns a controller whose\n * `syncTo` patches inputs in place (preserving focus) instead of rebuilding\n * the DOM on every keystroke. The form has a question tab list (add,\n * select); the ACTIVE question's text, image and answers are edited in the\n * tab panel below it, with the correct answer chosen by a radio on each\n * answer row. Switching the selected question rebuilds that question's\n * answer rows (an explicit action); within the active question, edits patch\n * in place. All edits emit canonical multi-question {@link QuizData}.\n */\nfunction createQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n ensureInterlaceStyles(container.ownerDocument);\n editorInstanceCount += 1;\n const uid = `quiz-editor-${editorInstanceCount}`;\n\n container.innerHTML = \"\";\n const root = document.createElement(\"div\");\n root.className = \"quiz-editor\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n root.style.display = \"flex\";\n root.style.flexDirection = \"column\";\n root.style.gap = `${SPACE[3]}px`;\n\n let currentData: QuizData = data;\n let currentOnChange = onChange;\n let selectedIndex = 0;\n let bodyQuestionIndex = -1;\n let optionRows: OptionRow[] = [];\n let tabButtons: HTMLButtonElement[] = [];\n /** Fields the author has blurred; errors only show for these. */\n const touched = new Set<string>();\n /** Media panels the author opened (kept open even while empty). */\n const expandedMedia = new Set<string>();\n\n const emit = (questions: QuizQuestionSpec[]): void => {\n currentOnChange({ questions });\n };\n\n /** Applies `mutate` to the active question and emits the canonical list. */\n const patchActiveQuestion = (\n mutate: (question: QuizQuestionSpec) => QuizQuestionSpec,\n ): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n const questions = currentData.questions.slice();\n questions[selectedIndex] = mutate(active);\n emit(questions);\n };\n\n /** Stable state key for the active question (or one of its answers). */\n const activeKey = (optionIndex?: number): string => {\n const active = currentData.questions[selectedIndex];\n const questionKey = active?.id ?? `#${selectedIndex}`;\n if (optionIndex === undefined) return questionKey;\n return `${questionKey}/${active?.options[optionIndex]?.id ?? `#${optionIndex}`}`;\n };\n\n // --- Question tabs ---\n const questionsHeader = document.createElement(\"div\");\n questionsHeader.id = `${uid}-questions-label`;\n questionsHeader.className = \"interlace-label\";\n questionsHeader.textContent = \"Questions\";\n questionsHeader.style.fontSize = `${TYPE.sm}px`;\n questionsHeader.style.fontWeight = \"600\";\n questionsHeader.style.color = COLORS.textMuted;\n\n const tabsRow = document.createElement(\"div\");\n tabsRow.style.display = \"flex\";\n tabsRow.style.flexWrap = \"wrap\";\n tabsRow.style.alignItems = \"center\";\n tabsRow.style.gap = `${SPACE[2]}px`;\n\n const tabsBar = document.createElement(\"div\");\n tabsBar.className = \"quiz-question-tabs\";\n tabsBar.setAttribute(\"role\", \"tablist\");\n tabsBar.setAttribute(\"aria-labelledby\", questionsHeader.id);\n tabsBar.style.display = \"flex\";\n tabsBar.style.flexWrap = \"wrap\";\n tabsBar.style.gap = `${SPACE[2]}px`;\n\n const addQuestionButton = createButton(\n \"+ Add question\",\n \"secondary\",\n \"quiz-add-question\",\n );\n addQuestionButton.addEventListener(\"click\", () => {\n const id = nextQuestionId(\n currentData.questions,\n currentData.questions.length,\n );\n const questions = [...currentData.questions, emptyQuestion(id)];\n currentData = { questions };\n selectedIndex = questions.length - 1;\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n });\n tabsRow.append(tabsBar, addQuestionButton);\n root.append(questionsHeader, tabsRow);\n\n // --- Active question panel ---\n const body = document.createElement(\"div\");\n body.id = `${uid}-panel`;\n body.className = \"quiz-editor-body\";\n body.setAttribute(\"role\", \"tabpanel\");\n body.style.display = \"flex\";\n body.style.flexDirection = \"column\";\n body.style.gap = `${SPACE[4]}px`;\n body.style.padding = `${SPACE[4]}px`;\n body.style.backgroundColor = COLORS.surface;\n body.style.border = `1px solid ${COLORS.border}`;\n body.style.borderRadius = `${RADIUS.md}`;\n root.appendChild(body);\n\n // Question text: label above, remove-question action on the same line.\n const questionInput = createInput(\n \"quiz-question\",\n `${uid}-question`,\n \"Type your question\",\n );\n questionInput.style.fontSize = `${TYPE.md}px`;\n const questionError = createErrorText(\n `${uid}-question-error`,\n \"quiz-question-error\",\n );\n const refreshQuestionError = (): void => {\n const show =\n touched.has(`text:${activeKey()}`) &&\n questionInput.value.trim().length === 0;\n setFieldError(\n questionInput,\n questionError,\n show ? \"Add the question text\" : null,\n );\n };\n questionInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n text: questionInput.value,\n }));\n refreshQuestionError();\n });\n questionInput.addEventListener(\"blur\", () => {\n touched.add(`text:${activeKey()}`);\n refreshQuestionError();\n });\n\n const removeQuestionButton = createRemoveButton(\"quiz-question-remove\");\n removeQuestionButton.addEventListener(\"click\", () =>\n removeQuestion(selectedIndex),\n );\n\n const questionHeader = document.createElement(\"div\");\n questionHeader.style.display = \"flex\";\n questionHeader.style.alignItems = \"center\";\n questionHeader.style.justifyContent = \"space-between\";\n questionHeader.style.gap = `${SPACE[2]}px`;\n questionHeader.append(\n createLabel(\"Question\", questionInput.id),\n removeQuestionButton,\n );\n\n const questionField = document.createElement(\"div\");\n questionField.className = \"interlace-field\";\n questionField.style.display = \"flex\";\n questionField.style.flexDirection = \"column\";\n questionField.style.gap = `${SPACE[1]}px`;\n questionField.append(questionHeader, questionInput, questionError);\n\n const questionMedia = createMediaEditor({\n classPrefix: \"quiz-question-media\",\n idPrefix: `${uid}-question-media`,\n addLabel: \"Add image to question\",\n previewSlotClass: \"quiz-question-media-preview-slot\",\n previewClass: \"quiz-question-media-preview\",\n onEdit: (media) => {\n expandedMedia.add(activeKey());\n patchActiveQuestion((question) => ({ ...question, media }));\n },\n onExpand: () => expandedMedia.add(activeKey()),\n onRemove: () => {\n expandedMedia.delete(activeKey());\n patchActiveQuestion((question) => ({ ...question, media: undefined }));\n },\n });\n questionField.appendChild(questionMedia.root);\n body.appendChild(questionField);\n\n // Answers: heading + hint, then one row per answer with a correct radio.\n const answersSection = document.createElement(\"div\");\n answersSection.style.display = \"flex\";\n answersSection.style.flexDirection = \"column\";\n answersSection.style.gap = `${SPACE[2]}px`;\n\n const answersHeading = document.createElement(\"div\");\n answersHeading.id = `${uid}-answers-label`;\n answersHeading.className = \"interlace-label quiz-answers-heading\";\n answersHeading.textContent = \"Answers\";\n answersHeading.style.fontSize = `${TYPE.sm}px`;\n answersHeading.style.fontWeight = \"600\";\n\n const answersHint = document.createElement(\"p\");\n answersHint.id = `${uid}-answers-hint`;\n answersHint.className = \"interlace-hint quiz-answers-hint\";\n answersHint.textContent = \"Select the correct answer.\";\n answersHint.style.margin = \"0\";\n answersHint.style.fontSize = `${TYPE.sm}px`;\n answersHint.style.color = COLORS.textMuted;\n\n const optionsContainer = document.createElement(\"div\");\n optionsContainer.className = \"quiz-options\";\n optionsContainer.setAttribute(\"role\", \"radiogroup\");\n optionsContainer.setAttribute(\"aria-labelledby\", answersHeading.id);\n optionsContainer.setAttribute(\"aria-describedby\", answersHint.id);\n optionsContainer.style.display = \"flex\";\n optionsContainer.style.flexDirection = \"column\";\n optionsContainer.style.gap = `${SPACE[2]}px`;\n\n const addOptionButton = createButton(\n \"+ Add answer\",\n \"secondary\",\n \"quiz-add-option\",\n );\n addOptionButton.style.alignSelf = \"flex-start\";\n addOptionButton.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const nextOptions: QuizOption[] = [\n ...question.options,\n {\n id: nextOptionId(question.options, question.options.length),\n text: \"\",\n },\n ];\n // Adding the first option defaults it to correct (ported behavior).\n const nextCorrectOptionId =\n question.options.length === 0\n ? nextOptions[0]!.id\n : question.correctOptionId;\n return {\n ...question,\n options: nextOptions,\n correctOptionId: nextCorrectOptionId,\n };\n });\n });\n\n answersSection.append(\n answersHeading,\n answersHint,\n optionsContainer,\n addOptionButton,\n );\n body.appendChild(answersSection);\n\n container.appendChild(root);\n\n const createOptionRow = (\n option: QuizOption,\n optionIndex: number,\n optionCount: number,\n ): OptionRow => {\n const number = optionIndex + 1;\n const idPrefix = `${uid}-q${selectedIndex}-opt${optionIndex}`;\n\n // Grid: [radio] [label / input / error + image] [remove].\n const row = document.createElement(\"div\");\n row.className = \"quiz-option-row interlace-choice\";\n row.style.display = \"grid\";\n row.style.gridTemplateColumns = \"auto minmax(0, 1fr) auto\";\n row.style.alignItems = \"center\";\n row.style.columnGap = `${SPACE[2]}px`;\n row.style.rowGap = `${SPACE[1]}px`;\n row.style.cursor = \"default\";\n // The inputs draw their own focus rings; skip the card's focus-within ring.\n row.style.outline = \"none\";\n\n const radio = document.createElement(\"input\");\n radio.type = \"radio\";\n radio.name = `${uid}-correct-${selectedIndex}`;\n radio.className = \"quiz-option-correct\";\n radio.value = option.id;\n radio.checked =\n option.id === currentData.questions[selectedIndex]?.correctOptionId;\n radio.setAttribute(\"aria-label\", `Mark answer ${number} as correct`);\n radio.style.width = \"18px\";\n radio.style.height = \"18px\";\n radio.style.margin = \"0\";\n radio.style.accentColor = COLORS.accent;\n radio.style.cursor = \"pointer\";\n radio.style.gridColumn = \"1\";\n radio.style.gridRow = \"2\";\n radio.addEventListener(\"change\", () => {\n if (!radio.checked) return;\n patchActiveQuestion((question) => ({\n ...question,\n correctOptionId: question.options[optionIndex]?.id ?? null,\n }));\n });\n\n const textInput = createInput(\n \"quiz-option-text\",\n `${idPrefix}-text`,\n \"Answer text\",\n );\n textInput.value = option.text;\n textInput.style.gridColumn = \"2\";\n textInput.style.gridRow = \"2\";\n const label = createLabel(`Answer ${number}`, textInput.id);\n label.style.gridColumn = \"2\";\n label.style.gridRow = \"1\";\n\n const error = createErrorText(`${idPrefix}-error`, \"quiz-option-error\");\n const refreshError = (): void => {\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n textInput.value.trim().length === 0;\n setFieldError(\n textInput,\n error,\n show ? `Answer ${number} needs text` : null,\n );\n };\n textInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = {\n ...nextOptions[optionIndex]!,\n text: textInput.value,\n };\n return { ...question, options: nextOptions };\n });\n refreshError();\n });\n textInput.addEventListener(\"blur\", () => {\n touched.add(`opt:${activeKey(optionIndex)}`);\n refreshError();\n });\n\n const patchOptionMedia = (media: QuizMediaRef | undefined): void => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = { ...nextOptions[optionIndex]!, media };\n return { ...question, options: nextOptions };\n });\n };\n const media = createMediaEditor({\n classPrefix: \"quiz-option-media\",\n idPrefix: `${idPrefix}-media`,\n addLabel: `Add image to answer ${number}`,\n previewSlotClass: \"quiz-option-media-preview\",\n previewClass: \"quiz-option-thumb\",\n onEdit: (next) => {\n expandedMedia.add(activeKey(optionIndex));\n patchOptionMedia(next);\n },\n onExpand: () => expandedMedia.add(activeKey(optionIndex)),\n onRemove: () => {\n expandedMedia.delete(activeKey(optionIndex));\n patchOptionMedia(undefined);\n },\n });\n\n const details = document.createElement(\"div\");\n details.style.gridColumn = \"2\";\n details.style.gridRow = \"3\";\n details.style.display = \"flex\";\n details.style.flexDirection = \"column\";\n details.style.alignItems = \"flex-start\";\n details.style.gap = `${SPACE[1]}px`;\n media.root.style.alignSelf = \"stretch\";\n details.append(error, media.root);\n\n const remove = createRemoveButton(\"quiz-option-remove\");\n remove.setAttribute(\"aria-label\", `Remove answer ${number}`);\n remove.style.gridColumn = \"3\";\n remove.style.gridRow = \"2\";\n setRemoveAllowed(\n remove,\n optionCount > MIN_ANSWERS,\n `A question needs at least ${MIN_ANSWERS} answers`,\n );\n remove.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const removed = question.options[optionIndex];\n const nextOptions = question.options.filter(\n (_, i) => i !== optionIndex,\n );\n return {\n ...question,\n options: nextOptions,\n // Removing the correct option clears correctness; do not shift it.\n correctOptionId:\n removed && removed.id === question.correctOptionId\n ? null\n : question.correctOptionId,\n };\n });\n });\n\n row.append(label, radio, textInput, remove, details);\n optionsContainer.appendChild(row);\n return { row, radio, textInput, error, media };\n };\n\n const selectQuestion = (index: number): void => {\n selectedIndex = index;\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const removeQuestion = (index: number): void => {\n const next = currentData.questions.filter((_, i) => i !== index);\n const questions =\n next.length > 0 ? next : [emptyQuestion(nextQuestionId([], 0))];\n if (selectedIndex === index) {\n selectedIndex = 0; // removing the selected question selects the first remaining\n } else if (index < selectedIndex) {\n selectedIndex -= 1;\n }\n currentData = { questions };\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const renderTabs = (): void => {\n tabsBar.innerHTML = \"\";\n const count = currentData.questions.length;\n tabButtons = currentData.questions.map((_, index) => {\n const selected = index === selectedIndex;\n const tab = createButton(\n `Question ${index + 1}`,\n selected ? \"primary\" : \"secondary\",\n \"quiz-question-tab\",\n );\n tab.id = `${uid}-tab-${index}`;\n tab.setAttribute(\"role\", \"tab\");\n tab.setAttribute(\"aria-selected\", String(selected));\n tab.setAttribute(\"aria-controls\", body.id);\n tab.tabIndex = selected ? 0 : -1;\n tab.addEventListener(\"click\", () => selectQuestion(index));\n tab.addEventListener(\"keydown\", (event) => {\n let target = -1;\n if (event.key === \"ArrowRight\") target = (index + 1) % count;\n else if (event.key === \"ArrowLeft\")\n target = (index - 1 + count) % count;\n else if (event.key === \"Home\") target = 0;\n else if (event.key === \"End\") target = count - 1;\n if (target < 0) return;\n event.preventDefault();\n selectQuestion(target);\n tabButtons[target]?.focus();\n });\n tabsBar.appendChild(tab);\n return tab;\n });\n\n body.setAttribute(\"aria-labelledby\", `${uid}-tab-${selectedIndex}`);\n removeQuestionButton.setAttribute(\n \"aria-label\",\n `Remove question ${selectedIndex + 1}`,\n );\n setRemoveAllowed(\n removeQuestionButton,\n count > 1,\n \"A quiz needs at least one question\",\n );\n };\n\n const syncActiveBody = (): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n\n setValue(questionInput, active.text);\n questionMedia.sync(\n active.media,\n !!active.media || expandedMedia.has(activeKey()),\n );\n refreshQuestionError();\n\n const options = active.options;\n if (\n bodyQuestionIndex !== selectedIndex ||\n optionRows.length !== options.length\n ) {\n // Question switch or option count change: rebuild the active question's rows.\n optionsContainer.innerHTML = \"\";\n optionRows = options.map((option, optionIndex) =>\n createOptionRow(option, optionIndex, options.length),\n );\n bodyQuestionIndex = selectedIndex;\n }\n // Patch values in place, preserving input focus.\n optionRows.forEach((row, optionIndex) => {\n const option = options[optionIndex]!;\n setValue(row.textInput, option.text);\n row.radio.value = option.id;\n row.radio.checked = option.id === active.correctOptionId;\n row.media.sync(\n option.media,\n !!option.media || expandedMedia.has(activeKey(optionIndex)),\n );\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n option.text.trim().length === 0;\n setFieldError(\n row.textInput,\n row.error,\n show ? `Answer ${optionIndex + 1} needs text` : null,\n );\n });\n };\n\n const syncTo = (\n nextData: QuizData,\n nextOnChange: (next: QuizData) => void,\n ): void => {\n currentData = nextData;\n currentOnChange = nextOnChange;\n if (currentData.questions.length === 0) {\n currentData = { questions: [emptyQuestion(\"q-0\")] };\n }\n if (selectedIndex >= currentData.questions.length) {\n selectedIndex = 0;\n }\n renderTabs();\n syncActiveBody();\n };\n\n renderTabs();\n syncActiveBody();\n\n return { syncTo };\n}\n\nfunction getOrCreateQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n let controller = quizEditorControllers.get(container);\n if (!controller) {\n controller = createQuizEditorController(container, data, onChange);\n quizEditorControllers.set(container, controller);\n }\n return controller;\n}\n\n/** Tears down the editor controller mounted in `container`, if any. */\nexport function unmountQuizEditor(container: HTMLElement): void {\n quizEditorControllers.delete(container);\n container.innerHTML = \"\";\n}\n\n/**\n * Built-in Quiz editor content type. Authors the canonical multi-question\n * {@link QuizData} shape with rich media (the single supported format).\n * Registered id is `quiz-editor`, matching the player's built-in quiz\n * content type.\n */\nexport const QuizEditorType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n","/**\n * Interlace design tokens, re-exported from `@interlacejs/core` so every\n * package shares one themeable set (CSS custom properties with defaults).\n */\nexport {\n COLORS,\n CONTROL_HEIGHT,\n FOCUS_RING,\n FONTS,\n RADIUS,\n SHADOWS,\n SPACE,\n TYPE,\n} from \"@interlacejs/core\";\n","import type { QuizData, QuizOption } from \"./schema\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\n\nexport interface QuizPlaybackCallbacks {\n onComplete(score?: number): void;\n}\n\ninterface QuizPlaybackSession {\n destroy: () => void;\n}\n\ninterface OptionEntry {\n button: HTMLButtonElement;\n option: QuizOption;\n statusGlyph: HTMLSpanElement;\n statusLabel: HTMLSpanElement;\n}\n\n/**\n * Per-container playback sessions, so `unmountQuizPlayback` can tear down\n * the listeners built by `renderQuizPlayback`.\n */\nconst quizPlaybackSessions = new WeakMap<HTMLElement, QuizPlaybackSession>();\n\n/** Creates a playback media `<img>`, or `null` when src is blank. */\nfunction createMediaImage(\n className: string,\n src: string,\n alt: string | undefined,\n): HTMLImageElement | null {\n if (src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginBottom = `${SPACE[2]}px`;\n if (alt) img.alt = alt;\n return img;\n}\n\n/** Locks an option button so it can no longer be clicked. */\nfunction lockOption(button: HTMLButtonElement): void {\n button.disabled = true;\n button.style.cursor = \"default\";\n}\n\n/** Reveals the correct-answer state on an option button. */\nfunction revealCorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-correct\");\n button.style.backgroundColor = COLORS.correctBg;\n button.style.borderColor = COLORS.correctBg;\n button.style.color = COLORS.correctText;\n glyph.textContent = \"✓\";\n label.textContent = \"Correct\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/** Reveals the wrong-answer state on the selected option button. */\nfunction revealIncorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-incorrect\");\n button.style.backgroundColor = COLORS.incorrectBg;\n button.style.borderColor = COLORS.incorrectBorder;\n button.style.color = COLORS.incorrectText;\n glyph.textContent = \"✕\";\n label.textContent = \"Incorrect\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/**\n * Renders a multi-question quiz into `container`: one question at a time\n * with a \"Question i of n\" indicator, per-question media and option buttons,\n * and an explicit navigation footer. Answering a question reveals\n * correctness and locks its options; the user then advances with **Next**.\n * On the final question, clicking **Next** reports the per-question\n * correct count (`onComplete(correctCount)`, one point per question) ONCE,\n * as the click handler's final statement. **Previous** returns to an\n * answered question in its locked, review-only state. The document is the\n * canonical single-format {@link QuizData} shape.\n */\nexport function renderQuizPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: QuizPlaybackCallbacks,\n): void {\n // Destroy any session already mounted in this container: the overlay\n // lifecycle may re-render without an intervening unmount, and overwriting\n // the WeakMap entry would leak the first root (and its click listeners).\n unmountQuizPlayback(container);\n\n const total = data.questions.length;\n // Per-question recorded selections; back-navigation and the final\n // aggregate both read from here, and reveal locks make it stable.\n const answers: (string | null)[] = data.questions.map(() => null);\n let currentIndex = 0;\n let completed = false;\n\n const root = document.createElement(\"div\");\n root.className = \"quiz-playback\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n const indicator = document.createElement(\"div\");\n indicator.className = \"quiz-playback-indicator\";\n indicator.style.fontSize = `${TYPE.xs}px`;\n indicator.style.fontWeight = \"600\";\n indicator.style.color = COLORS.textMuted;\n indicator.style.marginBottom = `${SPACE[2]}px`;\n indicator.style.textTransform = \"uppercase\";\n indicator.style.letterSpacing = \"0.06em\";\n root.appendChild(indicator);\n\n const question = document.createElement(\"p\");\n question.className = \"quiz-playback-question\";\n question.style.margin = `0 0 ${SPACE[2]}px 0`;\n question.style.fontFamily = FONTS.display;\n question.style.fontSize = `${TYPE.lg}px`;\n question.style.fontWeight = \"600\";\n root.appendChild(question);\n\n const questionMediaSlot = document.createElement(\"div\");\n root.appendChild(questionMediaSlot);\n\n const optionsBox = document.createElement(\"div\");\n optionsBox.className = \"quiz-playback-options\";\n optionsBox.style.display = \"flex\";\n optionsBox.style.flexDirection = \"column\";\n optionsBox.style.gap = `${SPACE[2]}px`;\n root.appendChild(optionsBox);\n\n // Navigation footer: Previous (review-only back) and Next. The final\n // question uses the same Next label; clicking it aggregates the score\n // and fires onComplete once.\n const navFooter = document.createElement(\"div\");\n navFooter.className = \"quiz-playback-nav\";\n navFooter.style.display = \"flex\";\n navFooter.style.justifyContent = \"flex-end\";\n navFooter.style.gap = `${SPACE[2]}px`;\n navFooter.style.marginTop = `${SPACE[4]}px`;\n root.appendChild(navFooter);\n\n const prevButton = document.createElement(\"button\");\n prevButton.type = \"button\";\n prevButton.className = \"quiz-playback-prev\";\n prevButton.textContent = \"Previous\";\n prevButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n prevButton.style.backgroundColor = COLORS.surface;\n prevButton.style.border = `1px solid ${COLORS.borderStrong}`;\n prevButton.style.borderRadius = `${RADIUS.md}`;\n prevButton.style.color = COLORS.text;\n prevButton.style.cursor = \"pointer\";\n prevButton.style.fontSize = `${TYPE.base}px`;\n prevButton.style.fontWeight = \"600\";\n prevButton.style.transition = \"background-color 150ms ease\";\n prevButton.addEventListener(\"click\", () => {\n if (currentIndex > 0) {\n renderQuestion(currentIndex - 1);\n }\n });\n navFooter.appendChild(prevButton);\n\n const nextButton = document.createElement(\"button\");\n nextButton.type = \"button\";\n nextButton.className = \"quiz-playback-next\";\n nextButton.textContent = \"Next\";\n nextButton.disabled = true;\n nextButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n nextButton.style.backgroundColor = COLORS.accent;\n nextButton.style.border = \"none\";\n nextButton.style.borderRadius = `${RADIUS.md}`;\n nextButton.style.color = COLORS.accentContrast;\n nextButton.style.cursor = \"pointer\";\n nextButton.style.fontSize = `${TYPE.base}px`;\n nextButton.style.fontWeight = \"600\";\n nextButton.style.transition =\n \"background-color 150ms ease, opacity 150ms ease\";\n nextButton.addEventListener(\"click\", () => {\n if (completed) return;\n if (currentIndex < total - 1) {\n renderQuestion(currentIndex + 1);\n } else {\n // Final question: aggregate the per-question answers.\n completed = true;\n const correctCount = data.questions.reduce(\n (count, questionSpec, questionIndex) =>\n count +\n (answers[questionIndex] !== null &&\n answers[questionIndex] === questionSpec.correctOptionId\n ? 1\n : 0),\n 0,\n );\n nextButton.disabled = true;\n nextButton.style.opacity = \"0.55\";\n callbacks.onComplete(correctCount);\n }\n });\n navFooter.appendChild(nextButton);\n\n container.appendChild(root);\n\n let optionEntries: OptionEntry[] = [];\n\n const syncFooter = (index: number): void => {\n prevButton.style.display = index > 0 ? \"block\" : \"none\";\n nextButton.textContent = \"Next\";\n const answered = answers[index] !== null;\n nextButton.disabled = completed || !answered;\n nextButton.style.opacity = nextButton.disabled ? \"0.55\" : \"1\";\n };\n\n const createOptionButton = (\n option: QuizOption,\n isReview: boolean,\n ): OptionEntry => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"quiz-playback-option\";\n button.style.display = \"flex\";\n button.style.alignItems = \"center\";\n button.style.gap = `${SPACE[2]}px`;\n button.style.width = \"100%\";\n button.style.padding = `${SPACE[3]}px ${SPACE[4]}px`;\n button.style.backgroundColor = COLORS.surface;\n button.style.border = `1px solid ${COLORS.borderStrong}`;\n button.style.borderRadius = `${RADIUS.md}`;\n button.style.cursor = \"pointer\";\n button.style.fontSize = `${TYPE.base}px`;\n button.style.color = COLORS.text;\n button.style.textAlign = \"left\";\n button.style.transition =\n \"background-color 150ms ease, border-color 150ms ease, color 150ms ease\";\n\n const text = document.createElement(\"span\");\n text.className = \"quiz-playback-option-text\";\n text.textContent = option.text;\n text.style.flex = \"1\";\n button.appendChild(text);\n\n const thumbnail = createMediaImage(\n \"quiz-playback-option-media\",\n option.media?.src ?? \"\",\n option.media?.alt,\n );\n if (thumbnail) button.appendChild(thumbnail);\n\n const status = document.createElement(\"span\");\n status.style.display = \"flex\";\n status.style.alignItems = \"center\";\n status.style.gap = `${SPACE[1]}px`;\n status.style.marginLeft = \"auto\";\n status.style.transition = \"opacity 150ms ease\";\n\n const glyph = document.createElement(\"span\");\n glyph.style.fontWeight = \"700\";\n glyph.style.fontSize = `${TYPE.md}px`;\n glyph.style.lineHeight = \"1\";\n status.appendChild(glyph);\n\n const label = document.createElement(\"span\");\n label.style.fontWeight = \"600\";\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.letterSpacing = \"0.04em\";\n status.appendChild(label);\n\n button.appendChild(status);\n\n if (isReview) {\n lockOption(button);\n }\n\n return { button, option, statusGlyph: glyph, statusLabel: label };\n };\n\n const revealQuestion = (\n questionIndex: number,\n selectedOptionId: string,\n ): void => {\n const spec = data.questions[questionIndex]!;\n const correctOptionId = spec.correctOptionId;\n\n optionEntries.forEach((entry) => {\n lockOption(entry.button);\n if (entry.option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (\n entry.option.id === selectedOptionId &&\n selectedOptionId !== correctOptionId\n ) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n });\n };\n\n const renderQuestion = (index: number): void => {\n currentIndex = index;\n const spec = data.questions[index]!;\n const correctOptionId = spec.correctOptionId;\n const answered = answers[index] ?? null;\n\n indicator.textContent = `Question ${index + 1} of ${total}`;\n question.textContent = spec.text;\n questionMediaSlot.innerHTML = \"\";\n const questionMedia = createMediaImage(\n \"quiz-playback-question-media\",\n spec.media?.src ?? \"\",\n spec.media?.alt,\n );\n if (questionMedia) questionMediaSlot.appendChild(questionMedia);\n\n optionsBox.innerHTML = \"\";\n optionEntries = spec.options.map((option) => {\n const isReview = answered !== null;\n const entry = createOptionButton(option, isReview);\n\n if (isReview) {\n if (option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (option.id === answered && answered !== correctOptionId) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n } else {\n entry.button.addEventListener(\"click\", () => {\n if (completed) return;\n answers[index] = option.id;\n // Reveal correctness and lock this question's options. No\n // auto-advance and no auto-complete: the footer gates progress.\n revealQuestion(index, option.id);\n syncFooter(index);\n });\n }\n\n optionsBox.appendChild(entry.button);\n return entry;\n });\n\n syncFooter(index);\n };\n\n renderQuestion(0);\n\n quizPlaybackSessions.set(container, {\n destroy: () => {\n root.remove();\n },\n });\n}\n\n/** Cleans up the playback session mounted in `container`, if any. */\nexport function unmountQuizPlayback(container: HTMLElement): void {\n quizPlaybackSessions.get(container)?.destroy();\n quizPlaybackSessions.delete(container);\n}\n","import type { QuizData } from \"./schema\";\n\n/**\n * Validates canonical quiz data, returning human-readable error strings\n * indexed per question. An empty array means the document is valid.\n *\n * The legacy flat input format was removed; only the canonical\n * multi-question `QuizData` shape is accepted.\n */\nexport function validateQuizData(data: QuizData): string[] {\n const errors: string[] = [];\n\n if (data.questions.length === 0) {\n errors.push(\"at least one question is required\");\n return errors;\n }\n\n data.questions.forEach((question, index) => {\n if (question.text.trim().length === 0) {\n errors.push(`questions[${index}].text must be a non-empty string`);\n }\n\n if (question.options.length === 0) {\n errors.push(`questions[${index}].at least one option is required`);\n } else {\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n errors.push(\n `questions[${index}].options[${optionIndex}].text must be a non-empty string`,\n );\n }\n });\n }\n\n if (question.correctOptionId === null) {\n errors.push(\n `questions[${index}].exactly one correct option must be resolvable`,\n );\n }\n });\n\n return errors;\n}\n/**\n * Author-facing readiness check for quiz data, used by the content type's\n * `validate`. Returns friendly messages (e.g. \"Question 1 needs text\"); an\n * empty array means the quiz is ready to save.\n */\nexport function getQuizAuthoringIssues(data: QuizData): string[] {\n if (data.questions.length === 0) return [\"Add at least one question\"];\n\n const issues: string[] = [];\n data.questions.forEach((question, index) => {\n const label = `Question ${index + 1}`;\n if (question.text.trim().length === 0) {\n issues.push(`${label} needs text`);\n }\n if (question.options.length < 2) {\n issues.push(`${label} needs at least 2 answers`);\n }\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n issues.push(`${label}, answer ${optionIndex + 1} needs text`);\n }\n });\n const hasCorrect = question.options.some(\n (option) => option.id === question.correctOptionId,\n );\n if (!hasCorrect) issues.push(`${label} needs a correct answer`);\n });\n return issues;\n}\n","import { ContentType } from \"@interlacejs/core\";\nimport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport type { QuizData } from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\n/**\n * Built-in Quiz content type for Interlace. Authors the canonical\n * {@link QuizData} shape with rich media and plays it back with immediate\n * scoring. Registered id is `quiz-editor` — the id the editor's built-in\n * quiz type authors with — so authored documents resolve without extra\n * registry wiring.\n */\nexport const QuizContentType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.renderEditor(container, data, onChange);\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.updateEditor?.(container, data, onChange);\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAAmD;;;ACInD,kBAS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A8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;;;AIv7BO,IAAM,kBAAyC;AAAA,EACpD,OAAO,MAAM;AAAA,EACb,YAAY,MAAM;AAAA,EAClB,gBAAgB,MAAM;AAAA,EACtB,gBAAgB,MAAM;AAAA,EAEtB,SAAS,MAA0B;AACjC,WAAO,uBAAuB,IAAI;AAAA,EACpC;AAAA,EAEA,gBAAgB,MAA0B;AACxC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,MAAM,UAAyB;AAAA,EAE/B;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,aAAa,WAAW,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,eAAe,WAAW,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;","names":["import_core","media"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/quiz-editor.ts","../src/tokens.ts","../src/quiz-player.ts","../src/validate.ts","../src/quiz-content-type.ts"],"sourcesContent":["export { QuizContentType } from \"./quiz-content-type\";\nexport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nexport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nexport { getQuizAuthoringIssues, validateQuizData } from \"./validate\";\n\nexport type { QuizPlaybackCallbacks } from \"./quiz-player\";\nexport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\n","import { ContentType, ensureInterlaceStyles } from \"@interlacejs/core\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\nimport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\ninterface QuizEditorController {\n syncTo(data: QuizData, onChange: (next: QuizData) => void): void;\n}\n\n/**\n * Controllers are stashed per container so the slot can hand the same\n * controller back across the mount/update lifecycle. The slot always passes\n * the same container element to `renderEditor`/`updateEditor`/`unmount`.\n */\nconst quizEditorControllers = new WeakMap<HTMLElement, QuizEditorController>();\n\n/** Gives each mounted editor unique element ids and radio group names. */\nlet editorInstanceCount = 0;\n\n/** Fewest options a question may be reduced to via the remove buttons. */\nconst MIN_OPTIONS = 2;\n\n/** Builds a media ref from src/alt text; `undefined` when src is blank. */\nfunction buildMediaRef(src: string, alt: string): QuizMediaRef | undefined {\n if (src.length === 0) return undefined;\n return alt.length > 0 ? { src, alt } : { src };\n}\n\n/** Creates a preview `<img>` for a media ref, or `null` when src is blank. */\nfunction createPreview(\n media: QuizMediaRef | undefined,\n className: string,\n): HTMLImageElement | null {\n if (!media || media.src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = media.src;\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"160px\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginTop = `${SPACE[1]}px`;\n if (media.alt) img.alt = media.alt;\n return img;\n}\n\n/** Renders `media` into `slot`, replacing any previous preview. */\nfunction syncPreview(\n slot: HTMLElement,\n media: QuizMediaRef | undefined,\n className: string,\n): void {\n slot.innerHTML = \"\";\n const img = createPreview(media, className);\n if (img) slot.appendChild(img);\n}\n\n/** Generates an option id that does not collide with existing ids. */\nfunction nextOptionId(options: QuizOption[], index: number): string {\n const base = `opt-${index}`;\n if (!options.some((option) => option.id === base)) return base;\n let candidate = index + 1;\n while (options.some((option) => option.id === `opt-${candidate}`)) {\n candidate += 1;\n }\n return `opt-${candidate}`;\n}\n\n/** Generates a question id that does not collide with existing ids. */\nfunction nextQuestionId(questions: QuizQuestionSpec[], index: number): string {\n const base = `q-${index}`;\n if (!questions.some((question) => question.id === base)) return base;\n let candidate = index + 1;\n while (questions.some((question) => question.id === `q-${candidate}`)) {\n candidate += 1;\n }\n return `q-${candidate}`;\n}\n\n/** An empty question stub so the form is never without a question. */\n/** A new question starts with the minimum of two options, the first correct. */\nfunction emptyQuestion(id: string): QuizQuestionSpec {\n return {\n id,\n text: \"\",\n options: [\n { id: `${id}-a`, text: \"\" },\n { id: `${id}-b`, text: \"\" },\n ],\n correctOptionId: `${id}-a`,\n };\n}\n\n/**\n * Shows or hides an element. Uses inline `display` rather than `hidden`\n * because the shared `interlace-*` rules set `display` and would override\n * the user-agent `[hidden]` rule.\n */\nfunction setShown(el: HTMLElement, shown: boolean, display = \"\"): void {\n el.style.display = shown ? display : \"none\";\n}\n\n/** Sets an input's value only when it differs, so the caret is not moved. */\nfunction setValue(input: HTMLInputElement, value: string): void {\n if (input.value !== value) input.value = value;\n}\n\nfunction createButton(\n text: string,\n variant: \"primary\" | \"secondary\" | \"ghost\",\n className: string,\n): HTMLButtonElement {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `interlace-btn interlace-btn--${variant} ${className}`;\n button.textContent = text;\n return button;\n}\n\n/** A quiet \"×\" icon button for per-row remove actions. */\nfunction createRemoveButton(className: string): HTMLButtonElement {\n const button = createButton(\"×\", \"ghost\", `interlace-btn--icon ${className}`);\n button.style.fontSize = `${TYPE.lg}px`;\n button.style.lineHeight = \"1\";\n return button;\n}\n\n/** Enables a remove button, or disables it with `reason` as its tooltip. */\nfunction setRemoveAllowed(\n button: HTMLButtonElement,\n allowed: boolean,\n reason: string,\n): void {\n button.disabled = !allowed;\n if (allowed) button.removeAttribute(\"title\");\n else button.title = reason;\n}\n\nfunction createInput(\n className: string,\n id: string,\n placeholder?: string,\n): HTMLInputElement {\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.id = id;\n input.className = `interlace-input ${className}`;\n input.style.width = \"100%\";\n input.style.boxSizing = \"border-box\";\n if (placeholder) input.placeholder = placeholder;\n return input;\n}\n\nfunction createLabel(text: string, forId: string): HTMLLabelElement {\n const label = document.createElement(\"label\");\n label.className = \"interlace-label\";\n label.htmlFor = forId;\n label.textContent = text;\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.fontWeight = \"600\";\n return label;\n}\n\n/** A labelled field (label above input) wrapped in `interlace-field`. */\nfunction createField(\n labelText: string,\n input: HTMLInputElement,\n): HTMLDivElement {\n const field = document.createElement(\"div\");\n field.className = \"interlace-field\";\n field.style.display = \"flex\";\n field.style.flexDirection = \"column\";\n field.style.gap = `${SPACE[1]}px`;\n field.append(createLabel(labelText, input.id), input);\n return field;\n}\n\n/** An inline error message element, hidden until a message is set. */\nfunction createErrorText(id: string, className: string): HTMLParagraphElement {\n const error = document.createElement(\"p\");\n error.id = id;\n error.className = `interlace-hint quiz-field-error ${className}`;\n error.style.margin = \"0\";\n error.style.fontSize = `${TYPE.sm}px`;\n error.style.color = COLORS.errorText;\n setShown(error, false);\n return error;\n}\n\n/** Shows `message` for `input` (with aria wiring), or clears it on `null`. */\nfunction setFieldError(\n input: HTMLInputElement,\n error: HTMLElement,\n message: string | null,\n): void {\n if (message) {\n error.textContent = message;\n setShown(error, true);\n input.setAttribute(\"aria-invalid\", \"true\");\n input.setAttribute(\"aria-describedby\", error.id);\n } else {\n error.textContent = \"\";\n setShown(error, false);\n input.removeAttribute(\"aria-invalid\");\n input.removeAttribute(\"aria-describedby\");\n }\n}\n\ninterface MediaEditor {\n root: HTMLDivElement;\n srcInput: HTMLInputElement;\n altInput: HTMLInputElement;\n previewSlot: HTMLDivElement;\n /** Patches values/preview in place and shows or collapses the panel. */\n sync(media: QuizMediaRef | undefined, expanded: boolean): void;\n}\n\ninterface MediaEditorOptions {\n /** Class prefix, e.g. `quiz-question-media` → `quiz-question-media-src`. */\n classPrefix: string;\n idPrefix: string;\n /** Accessible name of the \"Add image\" button. */\n addLabel: string;\n previewSlotClass: string;\n previewClass: string;\n /** The author edited the URL or alt text. */\n onEdit(media: QuizMediaRef | undefined): void;\n /** The author expanded the panel via \"Add image\". */\n onExpand(): void;\n /** The author removed the image (fields are already cleared). */\n onRemove(): void;\n}\n\n/**\n * Image URL + alt fields tucked behind a ghost \"Add image\" button. The\n * panel opens on demand (or automatically when media exists, via `sync`)\n * and \"Remove image\" clears both fields and collapses it again.\n */\nfunction createMediaEditor(options: MediaEditorOptions): MediaEditor {\n const { classPrefix, idPrefix } = options;\n const root = document.createElement(\"div\");\n root.className = classPrefix;\n\n const addButton = createButton(\"+ Add image\", \"ghost\", `${classPrefix}-add`);\n addButton.setAttribute(\"aria-label\", options.addLabel);\n addButton.setAttribute(\"aria-controls\", `${idPrefix}-panel`);\n addButton.style.paddingLeft = `${SPACE[2]}px`;\n addButton.style.paddingRight = `${SPACE[2]}px`;\n\n const panel = document.createElement(\"div\");\n panel.id = `${idPrefix}-panel`;\n panel.className = `${classPrefix}-panel`;\n panel.style.flexDirection = \"column\";\n panel.style.gap = `${SPACE[2]}px`;\n panel.style.padding = `${SPACE[3]}px`;\n panel.style.backgroundColor = COLORS.surfaceRaised;\n panel.style.border = `1px solid ${COLORS.border}`;\n panel.style.borderRadius = `${RADIUS.md}`;\n\n const srcInput = createInput(\n `${classPrefix}-src`,\n `${idPrefix}-src`,\n \"https://example.com/image.png\",\n );\n const altInput = createInput(\n `${classPrefix}-alt`,\n `${idPrefix}-alt`,\n \"Describe the image for screen readers\",\n );\n const previewSlot = document.createElement(\"div\");\n previewSlot.className = options.previewSlotClass;\n\n const removeButton = createButton(\n \"Remove image\",\n \"ghost\",\n `${classPrefix}-remove`,\n );\n removeButton.style.alignSelf = \"flex-start\";\n\n panel.append(\n createField(\"Image URL\", srcInput),\n createField(\"Image description (alt text)\", altInput),\n previewSlot,\n removeButton,\n );\n root.append(addButton, panel);\n\n const setExpanded = (expanded: boolean): void => {\n setShown(panel, expanded, \"flex\");\n setShown(addButton, !expanded);\n addButton.setAttribute(\"aria-expanded\", String(expanded));\n };\n setExpanded(false);\n\n const handleEdit = (): void => {\n const media = buildMediaRef(srcInput.value, altInput.value);\n syncPreview(previewSlot, media, options.previewClass);\n options.onEdit(media);\n };\n srcInput.addEventListener(\"input\", handleEdit);\n altInput.addEventListener(\"input\", handleEdit);\n\n addButton.addEventListener(\"click\", () => {\n setExpanded(true);\n options.onExpand();\n srcInput.focus();\n });\n removeButton.addEventListener(\"click\", () => {\n srcInput.value = \"\";\n altInput.value = \"\";\n syncPreview(previewSlot, undefined, options.previewClass);\n setExpanded(false);\n options.onRemove();\n addButton.focus();\n });\n\n const sync = (media: QuizMediaRef | undefined, expanded: boolean): void => {\n setValue(srcInput, media?.src ?? \"\");\n setValue(altInput, media?.alt ?? \"\");\n syncPreview(previewSlot, media, options.previewClass);\n setExpanded(expanded);\n };\n\n return { root, srcInput, altInput, previewSlot, sync };\n}\n\ninterface OptionRow {\n row: HTMLDivElement;\n radio: HTMLInputElement;\n textInput: HTMLInputElement;\n error: HTMLParagraphElement;\n media: MediaEditor;\n}\n\n/**\n * Builds the quiz authoring form once and returns a controller whose\n * `syncTo` patches inputs in place (preserving focus) instead of rebuilding\n * the DOM on every keystroke. The form has a question tab list (add,\n * select); the ACTIVE question's text, image and options are edited in the\n * tab panel below it, with the correct answer chosen by a radio on each\n * option row. Switching the selected question rebuilds that question's\n * option rows (an explicit action); within the active question, edits patch\n * in place. All edits emit canonical multi-question {@link QuizData}.\n */\nfunction createQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n ensureInterlaceStyles(container.ownerDocument);\n editorInstanceCount += 1;\n const uid = `quiz-editor-${editorInstanceCount}`;\n\n container.innerHTML = \"\";\n const root = document.createElement(\"div\");\n root.className = \"quiz-editor\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n root.style.display = \"flex\";\n root.style.flexDirection = \"column\";\n root.style.gap = `${SPACE[3]}px`;\n\n let currentData: QuizData = data;\n let currentOnChange = onChange;\n let selectedIndex = 0;\n let bodyQuestionIndex = -1;\n let optionRows: OptionRow[] = [];\n let tabButtons: HTMLButtonElement[] = [];\n /** Fields the author has blurred; errors only show for these. */\n const touched = new Set<string>();\n /** Media panels the author opened (kept open even while empty). */\n const expandedMedia = new Set<string>();\n\n const emit = (questions: QuizQuestionSpec[]): void => {\n currentOnChange({ questions });\n };\n\n /** Applies `mutate` to the active question and emits the canonical list. */\n const patchActiveQuestion = (\n mutate: (question: QuizQuestionSpec) => QuizQuestionSpec,\n ): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n const questions = currentData.questions.slice();\n questions[selectedIndex] = mutate(active);\n emit(questions);\n };\n\n /** Stable state key for the active question (or one of its options). */\n const activeKey = (optionIndex?: number): string => {\n const active = currentData.questions[selectedIndex];\n const questionKey = active?.id ?? `#${selectedIndex}`;\n if (optionIndex === undefined) return questionKey;\n return `${questionKey}/${active?.options[optionIndex]?.id ?? `#${optionIndex}`}`;\n };\n\n // --- Question tabs ---\n const questionsHeader = document.createElement(\"div\");\n questionsHeader.id = `${uid}-questions-label`;\n questionsHeader.className = \"interlace-label\";\n questionsHeader.textContent = \"Questions\";\n questionsHeader.style.fontSize = `${TYPE.sm}px`;\n questionsHeader.style.fontWeight = \"600\";\n questionsHeader.style.color = COLORS.textMuted;\n\n const tabsRow = document.createElement(\"div\");\n tabsRow.style.display = \"flex\";\n tabsRow.style.flexWrap = \"wrap\";\n tabsRow.style.alignItems = \"center\";\n tabsRow.style.gap = `${SPACE[2]}px`;\n\n const tabsBar = document.createElement(\"div\");\n tabsBar.className = \"quiz-question-tabs\";\n tabsBar.setAttribute(\"role\", \"tablist\");\n tabsBar.setAttribute(\"aria-labelledby\", questionsHeader.id);\n tabsBar.style.display = \"flex\";\n tabsBar.style.flexWrap = \"wrap\";\n tabsBar.style.gap = `${SPACE[2]}px`;\n\n const addQuestionButton = createButton(\n \"+ Add question\",\n \"secondary\",\n \"quiz-add-question\",\n );\n addQuestionButton.addEventListener(\"click\", () => {\n const id = nextQuestionId(\n currentData.questions,\n currentData.questions.length,\n );\n const questions = [...currentData.questions, emptyQuestion(id)];\n currentData = { questions };\n selectedIndex = questions.length - 1;\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n });\n tabsRow.append(tabsBar, addQuestionButton);\n root.append(questionsHeader, tabsRow);\n\n // --- Active question panel ---\n const body = document.createElement(\"div\");\n body.id = `${uid}-panel`;\n body.className = \"quiz-editor-body\";\n body.setAttribute(\"role\", \"tabpanel\");\n body.style.display = \"flex\";\n body.style.flexDirection = \"column\";\n body.style.gap = `${SPACE[4]}px`;\n body.style.padding = `${SPACE[4]}px`;\n body.style.backgroundColor = COLORS.surface;\n body.style.border = `1px solid ${COLORS.border}`;\n body.style.borderRadius = `${RADIUS.md}`;\n root.appendChild(body);\n\n // Question text: label above, remove-question action on the same line.\n const questionInput = createInput(\n \"quiz-question\",\n `${uid}-question`,\n \"Type your question\",\n );\n questionInput.style.fontSize = `${TYPE.md}px`;\n const questionError = createErrorText(\n `${uid}-question-error`,\n \"quiz-question-error\",\n );\n const refreshQuestionError = (): void => {\n const show =\n touched.has(`text:${activeKey()}`) &&\n questionInput.value.trim().length === 0;\n setFieldError(\n questionInput,\n questionError,\n show ? \"Add the question text\" : null,\n );\n };\n questionInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n text: questionInput.value,\n }));\n refreshQuestionError();\n });\n questionInput.addEventListener(\"blur\", () => {\n touched.add(`text:${activeKey()}`);\n refreshQuestionError();\n });\n\n const removeQuestionButton = createRemoveButton(\"quiz-question-remove\");\n removeQuestionButton.addEventListener(\"click\", () =>\n removeQuestion(selectedIndex),\n );\n\n const questionHeader = document.createElement(\"div\");\n questionHeader.style.display = \"flex\";\n questionHeader.style.alignItems = \"center\";\n questionHeader.style.justifyContent = \"space-between\";\n questionHeader.style.gap = `${SPACE[2]}px`;\n questionHeader.append(\n createLabel(\"Question\", questionInput.id),\n removeQuestionButton,\n );\n\n const questionField = document.createElement(\"div\");\n questionField.className = \"interlace-field\";\n questionField.style.display = \"flex\";\n questionField.style.flexDirection = \"column\";\n questionField.style.gap = `${SPACE[1]}px`;\n questionField.append(questionHeader, questionInput, questionError);\n\n const questionMedia = createMediaEditor({\n classPrefix: \"quiz-question-media\",\n idPrefix: `${uid}-question-media`,\n addLabel: \"Add image to question\",\n previewSlotClass: \"quiz-question-media-preview-slot\",\n previewClass: \"quiz-question-media-preview\",\n onEdit: (media) => {\n expandedMedia.add(activeKey());\n patchActiveQuestion((question) => ({ ...question, media }));\n },\n onExpand: () => expandedMedia.add(activeKey()),\n onRemove: () => {\n expandedMedia.delete(activeKey());\n patchActiveQuestion((question) => ({ ...question, media: undefined }));\n },\n });\n questionField.appendChild(questionMedia.root);\n body.appendChild(questionField);\n\n // Options: heading + hint, then one row per option with a correct radio.\n const optionsSection = document.createElement(\"div\");\n optionsSection.style.display = \"flex\";\n optionsSection.style.flexDirection = \"column\";\n optionsSection.style.gap = `${SPACE[2]}px`;\n\n const optionsHeading = document.createElement(\"div\");\n optionsHeading.id = `${uid}-options-label`;\n optionsHeading.className = \"interlace-label quiz-options-heading\";\n optionsHeading.textContent = \"Options\";\n optionsHeading.style.fontSize = `${TYPE.sm}px`;\n optionsHeading.style.fontWeight = \"600\";\n\n const optionsHint = document.createElement(\"p\");\n optionsHint.id = `${uid}-options-hint`;\n optionsHint.className = \"interlace-hint quiz-options-hint\";\n optionsHint.textContent = \"Select the correct answer.\";\n optionsHint.style.margin = \"0\";\n optionsHint.style.fontSize = `${TYPE.sm}px`;\n optionsHint.style.color = COLORS.textMuted;\n\n const optionsContainer = document.createElement(\"div\");\n optionsContainer.className = \"quiz-options\";\n optionsContainer.setAttribute(\"role\", \"radiogroup\");\n optionsContainer.setAttribute(\"aria-labelledby\", optionsHeading.id);\n optionsContainer.setAttribute(\"aria-describedby\", optionsHint.id);\n optionsContainer.style.display = \"flex\";\n optionsContainer.style.flexDirection = \"column\";\n optionsContainer.style.gap = `${SPACE[2]}px`;\n\n const addOptionButton = createButton(\n \"+ Add option\",\n \"secondary\",\n \"quiz-add-option\",\n );\n addOptionButton.style.alignSelf = \"flex-start\";\n addOptionButton.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const nextOptions: QuizOption[] = [\n ...question.options,\n {\n id: nextOptionId(question.options, question.options.length),\n text: \"\",\n },\n ];\n // Adding the first option defaults it to correct (ported behavior).\n const nextCorrectOptionId =\n question.options.length === 0\n ? nextOptions[0]!.id\n : question.correctOptionId;\n return {\n ...question,\n options: nextOptions,\n correctOptionId: nextCorrectOptionId,\n };\n });\n });\n\n optionsSection.append(\n optionsHeading,\n optionsHint,\n optionsContainer,\n addOptionButton,\n );\n body.appendChild(optionsSection);\n\n container.appendChild(root);\n\n const createOptionRow = (\n option: QuizOption,\n optionIndex: number,\n optionCount: number,\n ): OptionRow => {\n const number = optionIndex + 1;\n const idPrefix = `${uid}-q${selectedIndex}-opt${optionIndex}`;\n\n // Grid: [radio] [label / input / error + image] [remove].\n const row = document.createElement(\"div\");\n row.className = \"quiz-option-row interlace-choice\";\n row.style.display = \"grid\";\n row.style.gridTemplateColumns = \"auto minmax(0, 1fr) auto\";\n row.style.alignItems = \"center\";\n row.style.columnGap = `${SPACE[2]}px`;\n row.style.rowGap = `${SPACE[1]}px`;\n row.style.cursor = \"default\";\n // The inputs draw their own focus rings; skip the card's focus-within ring.\n row.style.outline = \"none\";\n\n const radio = document.createElement(\"input\");\n radio.type = \"radio\";\n radio.name = `${uid}-correct-${selectedIndex}`;\n radio.className = \"quiz-option-correct\";\n radio.value = option.id;\n radio.checked =\n option.id === currentData.questions[selectedIndex]?.correctOptionId;\n radio.setAttribute(\"aria-label\", `Mark option ${number} as correct`);\n radio.style.width = \"18px\";\n radio.style.height = \"18px\";\n radio.style.margin = \"0\";\n radio.style.accentColor = COLORS.accent;\n radio.style.cursor = \"pointer\";\n radio.style.gridColumn = \"1\";\n radio.style.gridRow = \"2\";\n radio.addEventListener(\"change\", () => {\n if (!radio.checked) return;\n patchActiveQuestion((question) => ({\n ...question,\n correctOptionId: question.options[optionIndex]?.id ?? null,\n }));\n });\n\n const textInput = createInput(\n \"quiz-option-text\",\n `${idPrefix}-text`,\n \"Option text\",\n );\n textInput.value = option.text;\n textInput.style.gridColumn = \"2\";\n textInput.style.gridRow = \"2\";\n const label = createLabel(`Option ${number}`, textInput.id);\n label.style.gridColumn = \"2\";\n label.style.gridRow = \"1\";\n\n const error = createErrorText(`${idPrefix}-error`, \"quiz-option-error\");\n const refreshError = (): void => {\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n textInput.value.trim().length === 0;\n setFieldError(\n textInput,\n error,\n show ? `Option ${number} needs text` : null,\n );\n };\n textInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = {\n ...nextOptions[optionIndex]!,\n text: textInput.value,\n };\n return { ...question, options: nextOptions };\n });\n refreshError();\n });\n textInput.addEventListener(\"blur\", () => {\n touched.add(`opt:${activeKey(optionIndex)}`);\n refreshError();\n });\n\n const patchOptionMedia = (media: QuizMediaRef | undefined): void => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = { ...nextOptions[optionIndex]!, media };\n return { ...question, options: nextOptions };\n });\n };\n const media = createMediaEditor({\n classPrefix: \"quiz-option-media\",\n idPrefix: `${idPrefix}-media`,\n addLabel: `Add image to option ${number}`,\n previewSlotClass: \"quiz-option-media-preview\",\n previewClass: \"quiz-option-thumb\",\n onEdit: (next) => {\n expandedMedia.add(activeKey(optionIndex));\n patchOptionMedia(next);\n },\n onExpand: () => expandedMedia.add(activeKey(optionIndex)),\n onRemove: () => {\n expandedMedia.delete(activeKey(optionIndex));\n patchOptionMedia(undefined);\n },\n });\n\n const details = document.createElement(\"div\");\n details.style.gridColumn = \"2\";\n details.style.gridRow = \"3\";\n details.style.display = \"flex\";\n details.style.flexDirection = \"column\";\n details.style.alignItems = \"flex-start\";\n details.style.gap = `${SPACE[1]}px`;\n media.root.style.alignSelf = \"stretch\";\n details.append(error, media.root);\n\n const remove = createRemoveButton(\"quiz-option-remove\");\n remove.setAttribute(\"aria-label\", `Remove option ${number}`);\n remove.style.gridColumn = \"3\";\n remove.style.gridRow = \"2\";\n setRemoveAllowed(\n remove,\n optionCount > MIN_OPTIONS,\n `A question needs at least ${MIN_OPTIONS} options`,\n );\n remove.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const removed = question.options[optionIndex];\n const nextOptions = question.options.filter(\n (_, i) => i !== optionIndex,\n );\n return {\n ...question,\n options: nextOptions,\n // Removing the correct option clears correctness; do not shift it.\n correctOptionId:\n removed && removed.id === question.correctOptionId\n ? null\n : question.correctOptionId,\n };\n });\n });\n\n row.append(label, radio, textInput, remove, details);\n optionsContainer.appendChild(row);\n return { row, radio, textInput, error, media };\n };\n\n const selectQuestion = (index: number): void => {\n selectedIndex = index;\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const removeQuestion = (index: number): void => {\n const next = currentData.questions.filter((_, i) => i !== index);\n const questions =\n next.length > 0 ? next : [emptyQuestion(nextQuestionId([], 0))];\n if (selectedIndex === index) {\n selectedIndex = 0; // removing the selected question selects the first remaining\n } else if (index < selectedIndex) {\n selectedIndex -= 1;\n }\n currentData = { questions };\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const renderTabs = (): void => {\n tabsBar.innerHTML = \"\";\n const count = currentData.questions.length;\n tabButtons = currentData.questions.map((_, index) => {\n const selected = index === selectedIndex;\n const tab = createButton(\n `Question ${index + 1}`,\n selected ? \"primary\" : \"secondary\",\n \"quiz-question-tab\",\n );\n tab.id = `${uid}-tab-${index}`;\n tab.setAttribute(\"role\", \"tab\");\n tab.setAttribute(\"aria-selected\", String(selected));\n tab.setAttribute(\"aria-controls\", body.id);\n tab.tabIndex = selected ? 0 : -1;\n tab.addEventListener(\"click\", () => selectQuestion(index));\n tab.addEventListener(\"keydown\", (event) => {\n let target = -1;\n if (event.key === \"ArrowRight\") target = (index + 1) % count;\n else if (event.key === \"ArrowLeft\")\n target = (index - 1 + count) % count;\n else if (event.key === \"Home\") target = 0;\n else if (event.key === \"End\") target = count - 1;\n if (target < 0) return;\n event.preventDefault();\n selectQuestion(target);\n tabButtons[target]?.focus();\n });\n tabsBar.appendChild(tab);\n return tab;\n });\n\n body.setAttribute(\"aria-labelledby\", `${uid}-tab-${selectedIndex}`);\n removeQuestionButton.setAttribute(\n \"aria-label\",\n `Remove question ${selectedIndex + 1}`,\n );\n setRemoveAllowed(\n removeQuestionButton,\n count > 1,\n \"A quiz needs at least one question\",\n );\n };\n\n const syncActiveBody = (): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n\n setValue(questionInput, active.text);\n questionMedia.sync(\n active.media,\n !!active.media || expandedMedia.has(activeKey()),\n );\n refreshQuestionError();\n\n const options = active.options;\n if (\n bodyQuestionIndex !== selectedIndex ||\n optionRows.length !== options.length\n ) {\n // Question switch or option count change: rebuild the active question's rows.\n optionsContainer.innerHTML = \"\";\n optionRows = options.map((option, optionIndex) =>\n createOptionRow(option, optionIndex, options.length),\n );\n bodyQuestionIndex = selectedIndex;\n }\n // Patch values in place, preserving input focus.\n optionRows.forEach((row, optionIndex) => {\n const option = options[optionIndex]!;\n setValue(row.textInput, option.text);\n row.radio.value = option.id;\n row.radio.checked = option.id === active.correctOptionId;\n row.media.sync(\n option.media,\n !!option.media || expandedMedia.has(activeKey(optionIndex)),\n );\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n option.text.trim().length === 0;\n setFieldError(\n row.textInput,\n row.error,\n show ? `Option ${optionIndex + 1} needs text` : null,\n );\n });\n };\n\n const syncTo = (\n nextData: QuizData,\n nextOnChange: (next: QuizData) => void,\n ): void => {\n currentData = nextData;\n currentOnChange = nextOnChange;\n if (currentData.questions.length === 0) {\n currentData = { questions: [emptyQuestion(\"q-0\")] };\n }\n if (selectedIndex >= currentData.questions.length) {\n selectedIndex = 0;\n }\n renderTabs();\n syncActiveBody();\n };\n\n renderTabs();\n syncActiveBody();\n\n return { syncTo };\n}\n\nfunction getOrCreateQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n let controller = quizEditorControllers.get(container);\n if (!controller) {\n controller = createQuizEditorController(container, data, onChange);\n quizEditorControllers.set(container, controller);\n }\n return controller;\n}\n\n/** Tears down the editor controller mounted in `container`, if any. */\nexport function unmountQuizEditor(container: HTMLElement): void {\n quizEditorControllers.delete(container);\n container.innerHTML = \"\";\n}\n\n/**\n * Built-in Quiz editor content type. Authors the canonical multi-question\n * {@link QuizData} shape with rich media (the single supported format).\n * Registered id is `quiz-editor`, matching the player's built-in quiz\n * content type.\n */\nexport const QuizEditorType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n","/**\n * Interlace design tokens, re-exported from `@interlacejs/core` so every\n * package shares one themeable set (CSS custom properties with defaults).\n */\nexport {\n COLORS,\n CONTROL_HEIGHT,\n FOCUS_RING,\n FONTS,\n RADIUS,\n SHADOWS,\n SPACE,\n TYPE,\n} from \"@interlacejs/core\";\n","import type { QuizData, QuizOption } from \"./schema\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\n\nexport interface QuizPlaybackCallbacks {\n onComplete(score?: number): void;\n}\n\ninterface QuizPlaybackSession {\n destroy: () => void;\n}\n\ninterface OptionEntry {\n button: HTMLButtonElement;\n option: QuizOption;\n statusGlyph: HTMLSpanElement;\n statusLabel: HTMLSpanElement;\n}\n\n/**\n * Per-container playback sessions, so `unmountQuizPlayback` can tear down\n * the listeners built by `renderQuizPlayback`.\n */\nconst quizPlaybackSessions = new WeakMap<HTMLElement, QuizPlaybackSession>();\n\n/** Creates a playback media `<img>`, or `null` when src is blank. */\nfunction createMediaImage(\n className: string,\n src: string,\n alt: string | undefined,\n): HTMLImageElement | null {\n if (src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginBottom = `${SPACE[2]}px`;\n if (alt) img.alt = alt;\n return img;\n}\n\n/** Locks an option button so it can no longer be clicked. */\nfunction lockOption(button: HTMLButtonElement): void {\n button.disabled = true;\n button.style.cursor = \"default\";\n}\n\n/** Reveals the correct-answer state on an option button. */\nfunction revealCorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-correct\");\n button.style.backgroundColor = COLORS.correctBg;\n button.style.borderColor = COLORS.correctBg;\n button.style.color = COLORS.correctText;\n glyph.textContent = \"✓\";\n label.textContent = \"Correct\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/** Reveals the wrong-answer state on the selected option button. */\nfunction revealIncorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-incorrect\");\n button.style.backgroundColor = COLORS.incorrectBg;\n button.style.borderColor = COLORS.incorrectBorder;\n button.style.color = COLORS.incorrectText;\n glyph.textContent = \"✕\";\n label.textContent = \"Incorrect\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/**\n * Renders a multi-question quiz into `container`: one question at a time\n * with a \"Question i of n\" indicator, per-question media and option buttons,\n * and an explicit navigation footer. Answering a question reveals\n * correctness and locks its options; the user then advances with **Next**.\n * On the final question, clicking **Next** reports the per-question\n * correct count (`onComplete(correctCount)`, one point per question) ONCE,\n * as the click handler's final statement. **Previous** returns to an\n * answered question in its locked, review-only state. The document is the\n * canonical single-format {@link QuizData} shape.\n */\nexport function renderQuizPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: QuizPlaybackCallbacks,\n): void {\n // Destroy any session already mounted in this container: the overlay\n // lifecycle may re-render without an intervening unmount, and overwriting\n // the WeakMap entry would leak the first root (and its click listeners).\n unmountQuizPlayback(container);\n\n const total = data.questions.length;\n // Per-question recorded selections; back-navigation and the final\n // aggregate both read from here, and reveal locks make it stable.\n const answers: (string | null)[] = data.questions.map(() => null);\n let currentIndex = 0;\n let completed = false;\n\n const root = document.createElement(\"div\");\n root.className = \"quiz-playback\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n const indicator = document.createElement(\"div\");\n indicator.className = \"quiz-playback-indicator\";\n indicator.style.fontSize = `${TYPE.xs}px`;\n indicator.style.fontWeight = \"600\";\n indicator.style.color = COLORS.textMuted;\n indicator.style.marginBottom = `${SPACE[2]}px`;\n indicator.style.textTransform = \"uppercase\";\n indicator.style.letterSpacing = \"0.06em\";\n root.appendChild(indicator);\n\n const question = document.createElement(\"p\");\n question.className = \"quiz-playback-question\";\n question.style.margin = `0 0 ${SPACE[2]}px 0`;\n question.style.fontFamily = FONTS.display;\n question.style.fontSize = `${TYPE.lg}px`;\n question.style.fontWeight = \"600\";\n root.appendChild(question);\n\n const questionMediaSlot = document.createElement(\"div\");\n root.appendChild(questionMediaSlot);\n\n const optionsBox = document.createElement(\"div\");\n optionsBox.className = \"quiz-playback-options\";\n optionsBox.style.display = \"flex\";\n optionsBox.style.flexDirection = \"column\";\n optionsBox.style.gap = `${SPACE[2]}px`;\n root.appendChild(optionsBox);\n\n // Navigation footer: Previous (review-only back) and Next. The final\n // question uses the same Next label; clicking it aggregates the score\n // and fires onComplete once.\n const navFooter = document.createElement(\"div\");\n navFooter.className = \"quiz-playback-nav\";\n navFooter.style.display = \"flex\";\n navFooter.style.justifyContent = \"flex-end\";\n navFooter.style.gap = `${SPACE[2]}px`;\n navFooter.style.marginTop = `${SPACE[4]}px`;\n root.appendChild(navFooter);\n\n const prevButton = document.createElement(\"button\");\n prevButton.type = \"button\";\n prevButton.className = \"quiz-playback-prev\";\n prevButton.textContent = \"Previous\";\n prevButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n prevButton.style.backgroundColor = COLORS.surface;\n prevButton.style.border = `1px solid ${COLORS.borderStrong}`;\n prevButton.style.borderRadius = `${RADIUS.md}`;\n prevButton.style.color = COLORS.text;\n prevButton.style.cursor = \"pointer\";\n prevButton.style.fontSize = `${TYPE.base}px`;\n prevButton.style.fontWeight = \"600\";\n prevButton.style.transition = \"background-color 150ms ease\";\n prevButton.addEventListener(\"click\", () => {\n if (currentIndex > 0) {\n renderQuestion(currentIndex - 1);\n }\n });\n navFooter.appendChild(prevButton);\n\n const nextButton = document.createElement(\"button\");\n nextButton.type = \"button\";\n nextButton.className = \"quiz-playback-next\";\n nextButton.textContent = \"Next\";\n nextButton.disabled = true;\n nextButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n nextButton.style.backgroundColor = COLORS.accent;\n nextButton.style.border = \"none\";\n nextButton.style.borderRadius = `${RADIUS.md}`;\n nextButton.style.color = COLORS.accentContrast;\n nextButton.style.cursor = \"pointer\";\n nextButton.style.fontSize = `${TYPE.base}px`;\n nextButton.style.fontWeight = \"600\";\n nextButton.style.transition =\n \"background-color 150ms ease, opacity 150ms ease\";\n nextButton.addEventListener(\"click\", () => {\n if (completed) return;\n if (currentIndex < total - 1) {\n renderQuestion(currentIndex + 1);\n } else {\n // Final question: aggregate the per-question answers.\n completed = true;\n const correctCount = data.questions.reduce(\n (count, questionSpec, questionIndex) =>\n count +\n (answers[questionIndex] !== null &&\n answers[questionIndex] === questionSpec.correctOptionId\n ? 1\n : 0),\n 0,\n );\n nextButton.disabled = true;\n nextButton.style.opacity = \"0.55\";\n callbacks.onComplete(correctCount);\n }\n });\n navFooter.appendChild(nextButton);\n\n container.appendChild(root);\n\n let optionEntries: OptionEntry[] = [];\n\n const syncFooter = (index: number): void => {\n prevButton.style.display = index > 0 ? \"block\" : \"none\";\n nextButton.textContent = \"Next\";\n const answered = answers[index] !== null;\n nextButton.disabled = completed || !answered;\n nextButton.style.opacity = nextButton.disabled ? \"0.55\" : \"1\";\n };\n\n const createOptionButton = (\n option: QuizOption,\n isReview: boolean,\n ): OptionEntry => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"quiz-playback-option\";\n button.style.display = \"flex\";\n button.style.alignItems = \"center\";\n button.style.gap = `${SPACE[2]}px`;\n button.style.width = \"100%\";\n button.style.padding = `${SPACE[3]}px ${SPACE[4]}px`;\n button.style.backgroundColor = COLORS.surface;\n button.style.border = `1px solid ${COLORS.borderStrong}`;\n button.style.borderRadius = `${RADIUS.md}`;\n button.style.cursor = \"pointer\";\n button.style.fontSize = `${TYPE.base}px`;\n button.style.color = COLORS.text;\n button.style.textAlign = \"left\";\n button.style.transition =\n \"background-color 150ms ease, border-color 150ms ease, color 150ms ease\";\n\n const text = document.createElement(\"span\");\n text.className = \"quiz-playback-option-text\";\n text.textContent = option.text;\n text.style.flex = \"1\";\n button.appendChild(text);\n\n const thumbnail = createMediaImage(\n \"quiz-playback-option-media\",\n option.media?.src ?? \"\",\n option.media?.alt,\n );\n if (thumbnail) button.appendChild(thumbnail);\n\n const status = document.createElement(\"span\");\n status.style.display = \"flex\";\n status.style.alignItems = \"center\";\n status.style.gap = `${SPACE[1]}px`;\n status.style.marginLeft = \"auto\";\n status.style.transition = \"opacity 150ms ease\";\n\n const glyph = document.createElement(\"span\");\n glyph.style.fontWeight = \"700\";\n glyph.style.fontSize = `${TYPE.md}px`;\n glyph.style.lineHeight = \"1\";\n status.appendChild(glyph);\n\n const label = document.createElement(\"span\");\n label.style.fontWeight = \"600\";\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.letterSpacing = \"0.04em\";\n status.appendChild(label);\n\n button.appendChild(status);\n\n if (isReview) {\n lockOption(button);\n }\n\n return { button, option, statusGlyph: glyph, statusLabel: label };\n };\n\n const revealQuestion = (\n questionIndex: number,\n selectedOptionId: string,\n ): void => {\n const spec = data.questions[questionIndex]!;\n const correctOptionId = spec.correctOptionId;\n\n optionEntries.forEach((entry) => {\n lockOption(entry.button);\n if (entry.option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (\n entry.option.id === selectedOptionId &&\n selectedOptionId !== correctOptionId\n ) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n });\n };\n\n const renderQuestion = (index: number): void => {\n currentIndex = index;\n const spec = data.questions[index]!;\n const correctOptionId = spec.correctOptionId;\n const answered = answers[index] ?? null;\n\n indicator.textContent = `Question ${index + 1} of ${total}`;\n question.textContent = spec.text;\n questionMediaSlot.innerHTML = \"\";\n const questionMedia = createMediaImage(\n \"quiz-playback-question-media\",\n spec.media?.src ?? \"\",\n spec.media?.alt,\n );\n if (questionMedia) questionMediaSlot.appendChild(questionMedia);\n\n optionsBox.innerHTML = \"\";\n optionEntries = spec.options.map((option) => {\n const isReview = answered !== null;\n const entry = createOptionButton(option, isReview);\n\n if (isReview) {\n if (option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (option.id === answered && answered !== correctOptionId) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n } else {\n entry.button.addEventListener(\"click\", () => {\n if (completed) return;\n answers[index] = option.id;\n // Reveal correctness and lock this question's options. No\n // auto-advance and no auto-complete: the footer gates progress.\n revealQuestion(index, option.id);\n syncFooter(index);\n });\n }\n\n optionsBox.appendChild(entry.button);\n return entry;\n });\n\n syncFooter(index);\n };\n\n renderQuestion(0);\n\n quizPlaybackSessions.set(container, {\n destroy: () => {\n root.remove();\n },\n });\n}\n\n/** Cleans up the playback session mounted in `container`, if any. */\nexport function unmountQuizPlayback(container: HTMLElement): void {\n quizPlaybackSessions.get(container)?.destroy();\n quizPlaybackSessions.delete(container);\n}\n","import type { QuizData } from \"./schema\";\n\n/**\n * Validates canonical quiz data, returning human-readable error strings\n * indexed per question. An empty array means the document is valid.\n *\n * The legacy flat input format was removed; only the canonical\n * multi-question `QuizData` shape is accepted.\n */\nexport function validateQuizData(data: QuizData): string[] {\n const errors: string[] = [];\n\n if (data.questions.length === 0) {\n errors.push(\"at least one question is required\");\n return errors;\n }\n\n data.questions.forEach((question, index) => {\n if (question.text.trim().length === 0) {\n errors.push(`questions[${index}].text must be a non-empty string`);\n }\n\n if (question.options.length === 0) {\n errors.push(`questions[${index}].at least one option is required`);\n } else {\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n errors.push(\n `questions[${index}].options[${optionIndex}].text must be a non-empty string`,\n );\n }\n });\n }\n\n if (question.correctOptionId === null) {\n errors.push(\n `questions[${index}].exactly one correct option must be resolvable`,\n );\n }\n });\n\n return errors;\n}\n/**\n * Author-facing readiness check for quiz data, used by the content type's\n * `validate`. Returns friendly messages (e.g. \"Question 1 needs text\"); an\n * empty array means the quiz is ready to save.\n */\nexport function getQuizAuthoringIssues(data: QuizData): string[] {\n if (data.questions.length === 0) return [\"Add at least one question\"];\n\n const issues: string[] = [];\n data.questions.forEach((question, index) => {\n const label = `Question ${index + 1}`;\n if (question.text.trim().length === 0) {\n issues.push(`${label} needs text`);\n }\n if (question.options.length < 2) {\n issues.push(`${label} needs at least 2 options`);\n }\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n issues.push(`${label}, option ${optionIndex + 1} needs text`);\n }\n });\n const hasCorrect = question.options.some(\n (option) => option.id === question.correctOptionId,\n );\n if (!hasCorrect) issues.push(`${label} needs a correct answer`);\n });\n return issues;\n}\n","import { ContentType } from \"@interlacejs/core\";\nimport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport type { QuizData } from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\n/**\n * Built-in Quiz content type for Interlace. Authors the canonical\n * {@link QuizData} shape with rich media and plays it back with immediate\n * scoring. Registered id is `quiz-editor` — the id the editor's built-in\n * quiz type authors with — so authored documents resolve without extra\n * registry wiring.\n */\nexport const QuizContentType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.renderEditor(container, data, onChange);\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.updateEditor?.(container, data, onChange);\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: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AAAA,EACF;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;;;AIv7BO,IAAM,kBAAyC;AAAA,EACpD,OAAO,MAAM;AAAA,EACb,YAAY,MAAM;AAAA,EAClB,gBAAgB,MAAM;AAAA,EACtB,gBAAgB,MAAM;AAAA,EAEtB,SAAS,MAA0B;AACjC,WAAO,uBAAuB,IAAI;AAAA,EACpC;AAAA,EAEA,gBAAgB,MAA0B;AACxC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,MAAM,UAAyB;AAAA,EAE/B;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,aAAa,WAAW,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,eAAe,WAAW,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;","names":["import_core","media"]}
package/dist/index.js CHANGED
@@ -303,11 +303,11 @@ function getQuizAuthoringIssues(data) {
303
303
  issues.push(`${label} needs text`);
304
304
  }
305
305
  if (question.options.length < 2) {
306
- issues.push(`${label} needs at least 2 answers`);
306
+ issues.push(`${label} needs at least 2 options`);
307
307
  }
308
308
  question.options.forEach((option, optionIndex) => {
309
309
  if (option.text.trim().length === 0) {
310
- issues.push(`${label}, answer ${optionIndex + 1} needs text`);
310
+ issues.push(`${label}, option ${optionIndex + 1} needs text`);
311
311
  }
312
312
  });
313
313
  const hasCorrect = question.options.some(
@@ -321,7 +321,7 @@ function getQuizAuthoringIssues(data) {
321
321
  // src/quiz-editor.ts
322
322
  var quizEditorControllers = /* @__PURE__ */ new WeakMap();
323
323
  var editorInstanceCount = 0;
324
- var MIN_ANSWERS = 2;
324
+ var MIN_OPTIONS = 2;
325
325
  function buildMediaRef(src, alt) {
326
326
  if (src.length === 0) return void 0;
327
327
  return alt.length > 0 ? { src, alt } : { src };
@@ -680,33 +680,33 @@ function createQuizEditorController(container, data, onChange) {
680
680
  });
681
681
  questionField.appendChild(questionMedia.root);
682
682
  body.appendChild(questionField);
683
- const answersSection = document.createElement("div");
684
- answersSection.style.display = "flex";
685
- answersSection.style.flexDirection = "column";
686
- answersSection.style.gap = `${SPACE[2]}px`;
687
- const answersHeading = document.createElement("div");
688
- answersHeading.id = `${uid}-answers-label`;
689
- answersHeading.className = "interlace-label quiz-answers-heading";
690
- answersHeading.textContent = "Answers";
691
- answersHeading.style.fontSize = `${TYPE.sm}px`;
692
- answersHeading.style.fontWeight = "600";
693
- const answersHint = document.createElement("p");
694
- answersHint.id = `${uid}-answers-hint`;
695
- answersHint.className = "interlace-hint quiz-answers-hint";
696
- answersHint.textContent = "Select the correct answer.";
697
- answersHint.style.margin = "0";
698
- answersHint.style.fontSize = `${TYPE.sm}px`;
699
- answersHint.style.color = COLORS.textMuted;
683
+ const optionsSection = document.createElement("div");
684
+ optionsSection.style.display = "flex";
685
+ optionsSection.style.flexDirection = "column";
686
+ optionsSection.style.gap = `${SPACE[2]}px`;
687
+ const optionsHeading = document.createElement("div");
688
+ optionsHeading.id = `${uid}-options-label`;
689
+ optionsHeading.className = "interlace-label quiz-options-heading";
690
+ optionsHeading.textContent = "Options";
691
+ optionsHeading.style.fontSize = `${TYPE.sm}px`;
692
+ optionsHeading.style.fontWeight = "600";
693
+ const optionsHint = document.createElement("p");
694
+ optionsHint.id = `${uid}-options-hint`;
695
+ optionsHint.className = "interlace-hint quiz-options-hint";
696
+ optionsHint.textContent = "Select the correct answer.";
697
+ optionsHint.style.margin = "0";
698
+ optionsHint.style.fontSize = `${TYPE.sm}px`;
699
+ optionsHint.style.color = COLORS.textMuted;
700
700
  const optionsContainer = document.createElement("div");
701
701
  optionsContainer.className = "quiz-options";
702
702
  optionsContainer.setAttribute("role", "radiogroup");
703
- optionsContainer.setAttribute("aria-labelledby", answersHeading.id);
704
- optionsContainer.setAttribute("aria-describedby", answersHint.id);
703
+ optionsContainer.setAttribute("aria-labelledby", optionsHeading.id);
704
+ optionsContainer.setAttribute("aria-describedby", optionsHint.id);
705
705
  optionsContainer.style.display = "flex";
706
706
  optionsContainer.style.flexDirection = "column";
707
707
  optionsContainer.style.gap = `${SPACE[2]}px`;
708
708
  const addOptionButton = createButton(
709
- "+ Add answer",
709
+ "+ Add option",
710
710
  "secondary",
711
711
  "quiz-add-option"
712
712
  );
@@ -728,13 +728,13 @@ function createQuizEditorController(container, data, onChange) {
728
728
  };
729
729
  });
730
730
  });
731
- answersSection.append(
732
- answersHeading,
733
- answersHint,
731
+ optionsSection.append(
732
+ optionsHeading,
733
+ optionsHint,
734
734
  optionsContainer,
735
735
  addOptionButton
736
736
  );
737
- body.appendChild(answersSection);
737
+ body.appendChild(optionsSection);
738
738
  container.appendChild(root);
739
739
  const createOptionRow = (option, optionIndex, optionCount) => {
740
740
  const number = optionIndex + 1;
@@ -754,7 +754,7 @@ function createQuizEditorController(container, data, onChange) {
754
754
  radio.className = "quiz-option-correct";
755
755
  radio.value = option.id;
756
756
  radio.checked = option.id === currentData.questions[selectedIndex]?.correctOptionId;
757
- radio.setAttribute("aria-label", `Mark answer ${number} as correct`);
757
+ radio.setAttribute("aria-label", `Mark option ${number} as correct`);
758
758
  radio.style.width = "18px";
759
759
  radio.style.height = "18px";
760
760
  radio.style.margin = "0";
@@ -772,12 +772,12 @@ function createQuizEditorController(container, data, onChange) {
772
772
  const textInput = createInput(
773
773
  "quiz-option-text",
774
774
  `${idPrefix}-text`,
775
- "Answer text"
775
+ "Option text"
776
776
  );
777
777
  textInput.value = option.text;
778
778
  textInput.style.gridColumn = "2";
779
779
  textInput.style.gridRow = "2";
780
- const label = createLabel(`Answer ${number}`, textInput.id);
780
+ const label = createLabel(`Option ${number}`, textInput.id);
781
781
  label.style.gridColumn = "2";
782
782
  label.style.gridRow = "1";
783
783
  const error = createErrorText(`${idPrefix}-error`, "quiz-option-error");
@@ -786,7 +786,7 @@ function createQuizEditorController(container, data, onChange) {
786
786
  setFieldError(
787
787
  textInput,
788
788
  error,
789
- show ? `Answer ${number} needs text` : null
789
+ show ? `Option ${number} needs text` : null
790
790
  );
791
791
  };
792
792
  textInput.addEventListener("input", () => {
@@ -814,7 +814,7 @@ function createQuizEditorController(container, data, onChange) {
814
814
  const media = createMediaEditor({
815
815
  classPrefix: "quiz-option-media",
816
816
  idPrefix: `${idPrefix}-media`,
817
- addLabel: `Add image to answer ${number}`,
817
+ addLabel: `Add image to option ${number}`,
818
818
  previewSlotClass: "quiz-option-media-preview",
819
819
  previewClass: "quiz-option-thumb",
820
820
  onEdit: (next) => {
@@ -837,13 +837,13 @@ function createQuizEditorController(container, data, onChange) {
837
837
  media.root.style.alignSelf = "stretch";
838
838
  details.append(error, media.root);
839
839
  const remove = createRemoveButton("quiz-option-remove");
840
- remove.setAttribute("aria-label", `Remove answer ${number}`);
840
+ remove.setAttribute("aria-label", `Remove option ${number}`);
841
841
  remove.style.gridColumn = "3";
842
842
  remove.style.gridRow = "2";
843
843
  setRemoveAllowed(
844
844
  remove,
845
- optionCount > MIN_ANSWERS,
846
- `A question needs at least ${MIN_ANSWERS} answers`
845
+ optionCount > MIN_OPTIONS,
846
+ `A question needs at least ${MIN_OPTIONS} options`
847
847
  );
848
848
  remove.addEventListener("click", () => {
849
849
  patchActiveQuestion((question) => {
@@ -955,7 +955,7 @@ function createQuizEditorController(container, data, onChange) {
955
955
  setFieldError(
956
956
  row.textInput,
957
957
  row.error,
958
- show ? `Answer ${optionIndex + 1} needs text` : null
958
+ show ? `Option ${optionIndex + 1} needs text` : null
959
959
  );
960
960
  });
961
961
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/quiz-editor.ts","../src/tokens.ts","../src/quiz-player.ts","../src/validate.ts","../src/quiz-content-type.ts"],"sourcesContent":["import { ContentType, ensureInterlaceStyles } from \"@interlacejs/core\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\nimport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\ninterface QuizEditorController {\n syncTo(data: QuizData, onChange: (next: QuizData) => void): void;\n}\n\n/**\n * Controllers are stashed per container so the slot can hand the same\n * controller back across the mount/update lifecycle. The slot always passes\n * the same container element to `renderEditor`/`updateEditor`/`unmount`.\n */\nconst quizEditorControllers = new WeakMap<HTMLElement, QuizEditorController>();\n\n/** Gives each mounted editor unique element ids and radio group names. */\nlet editorInstanceCount = 0;\n\n/** Fewest answers a question may be reduced to via the remove buttons. */\nconst MIN_ANSWERS = 2;\n\n/** Builds a media ref from src/alt text; `undefined` when src is blank. */\nfunction buildMediaRef(src: string, alt: string): QuizMediaRef | undefined {\n if (src.length === 0) return undefined;\n return alt.length > 0 ? { src, alt } : { src };\n}\n\n/** Creates a preview `<img>` for a media ref, or `null` when src is blank. */\nfunction createPreview(\n media: QuizMediaRef | undefined,\n className: string,\n): HTMLImageElement | null {\n if (!media || media.src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = media.src;\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"160px\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginTop = `${SPACE[1]}px`;\n if (media.alt) img.alt = media.alt;\n return img;\n}\n\n/** Renders `media` into `slot`, replacing any previous preview. */\nfunction syncPreview(\n slot: HTMLElement,\n media: QuizMediaRef | undefined,\n className: string,\n): void {\n slot.innerHTML = \"\";\n const img = createPreview(media, className);\n if (img) slot.appendChild(img);\n}\n\n/** Generates an option id that does not collide with existing ids. */\nfunction nextOptionId(options: QuizOption[], index: number): string {\n const base = `opt-${index}`;\n if (!options.some((option) => option.id === base)) return base;\n let candidate = index + 1;\n while (options.some((option) => option.id === `opt-${candidate}`)) {\n candidate += 1;\n }\n return `opt-${candidate}`;\n}\n\n/** Generates a question id that does not collide with existing ids. */\nfunction nextQuestionId(questions: QuizQuestionSpec[], index: number): string {\n const base = `q-${index}`;\n if (!questions.some((question) => question.id === base)) return base;\n let candidate = index + 1;\n while (questions.some((question) => question.id === `q-${candidate}`)) {\n candidate += 1;\n }\n return `q-${candidate}`;\n}\n\n/** An empty question stub so the form is never without a question. */\n/** A new question starts with the minimum of two answers, the first correct. */\nfunction emptyQuestion(id: string): QuizQuestionSpec {\n return {\n id,\n text: \"\",\n options: [\n { id: `${id}-a`, text: \"\" },\n { id: `${id}-b`, text: \"\" },\n ],\n correctOptionId: `${id}-a`,\n };\n}\n\n/**\n * Shows or hides an element. Uses inline `display` rather than `hidden`\n * because the shared `interlace-*` rules set `display` and would override\n * the user-agent `[hidden]` rule.\n */\nfunction setShown(el: HTMLElement, shown: boolean, display = \"\"): void {\n el.style.display = shown ? display : \"none\";\n}\n\n/** Sets an input's value only when it differs, so the caret is not moved. */\nfunction setValue(input: HTMLInputElement, value: string): void {\n if (input.value !== value) input.value = value;\n}\n\nfunction createButton(\n text: string,\n variant: \"primary\" | \"secondary\" | \"ghost\",\n className: string,\n): HTMLButtonElement {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `interlace-btn interlace-btn--${variant} ${className}`;\n button.textContent = text;\n return button;\n}\n\n/** A quiet \"×\" icon button for per-row remove actions. */\nfunction createRemoveButton(className: string): HTMLButtonElement {\n const button = createButton(\"×\", \"ghost\", `interlace-btn--icon ${className}`);\n button.style.fontSize = `${TYPE.lg}px`;\n button.style.lineHeight = \"1\";\n return button;\n}\n\n/** Enables a remove button, or disables it with `reason` as its tooltip. */\nfunction setRemoveAllowed(\n button: HTMLButtonElement,\n allowed: boolean,\n reason: string,\n): void {\n button.disabled = !allowed;\n if (allowed) button.removeAttribute(\"title\");\n else button.title = reason;\n}\n\nfunction createInput(\n className: string,\n id: string,\n placeholder?: string,\n): HTMLInputElement {\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.id = id;\n input.className = `interlace-input ${className}`;\n input.style.width = \"100%\";\n input.style.boxSizing = \"border-box\";\n if (placeholder) input.placeholder = placeholder;\n return input;\n}\n\nfunction createLabel(text: string, forId: string): HTMLLabelElement {\n const label = document.createElement(\"label\");\n label.className = \"interlace-label\";\n label.htmlFor = forId;\n label.textContent = text;\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.fontWeight = \"600\";\n return label;\n}\n\n/** A labelled field (label above input) wrapped in `interlace-field`. */\nfunction createField(\n labelText: string,\n input: HTMLInputElement,\n): HTMLDivElement {\n const field = document.createElement(\"div\");\n field.className = \"interlace-field\";\n field.style.display = \"flex\";\n field.style.flexDirection = \"column\";\n field.style.gap = `${SPACE[1]}px`;\n field.append(createLabel(labelText, input.id), input);\n return field;\n}\n\n/** An inline error message element, hidden until a message is set. */\nfunction createErrorText(id: string, className: string): HTMLParagraphElement {\n const error = document.createElement(\"p\");\n error.id = id;\n error.className = `interlace-hint quiz-field-error ${className}`;\n error.style.margin = \"0\";\n error.style.fontSize = `${TYPE.sm}px`;\n error.style.color = COLORS.errorText;\n setShown(error, false);\n return error;\n}\n\n/** Shows `message` for `input` (with aria wiring), or clears it on `null`. */\nfunction setFieldError(\n input: HTMLInputElement,\n error: HTMLElement,\n message: string | null,\n): void {\n if (message) {\n error.textContent = message;\n setShown(error, true);\n input.setAttribute(\"aria-invalid\", \"true\");\n input.setAttribute(\"aria-describedby\", error.id);\n } else {\n error.textContent = \"\";\n setShown(error, false);\n input.removeAttribute(\"aria-invalid\");\n input.removeAttribute(\"aria-describedby\");\n }\n}\n\ninterface MediaEditor {\n root: HTMLDivElement;\n srcInput: HTMLInputElement;\n altInput: HTMLInputElement;\n previewSlot: HTMLDivElement;\n /** Patches values/preview in place and shows or collapses the panel. */\n sync(media: QuizMediaRef | undefined, expanded: boolean): void;\n}\n\ninterface MediaEditorOptions {\n /** Class prefix, e.g. `quiz-question-media` → `quiz-question-media-src`. */\n classPrefix: string;\n idPrefix: string;\n /** Accessible name of the \"Add image\" button. */\n addLabel: string;\n previewSlotClass: string;\n previewClass: string;\n /** The author edited the URL or alt text. */\n onEdit(media: QuizMediaRef | undefined): void;\n /** The author expanded the panel via \"Add image\". */\n onExpand(): void;\n /** The author removed the image (fields are already cleared). */\n onRemove(): void;\n}\n\n/**\n * Image URL + alt fields tucked behind a ghost \"Add image\" button. The\n * panel opens on demand (or automatically when media exists, via `sync`)\n * and \"Remove image\" clears both fields and collapses it again.\n */\nfunction createMediaEditor(options: MediaEditorOptions): MediaEditor {\n const { classPrefix, idPrefix } = options;\n const root = document.createElement(\"div\");\n root.className = classPrefix;\n\n const addButton = createButton(\"+ Add image\", \"ghost\", `${classPrefix}-add`);\n addButton.setAttribute(\"aria-label\", options.addLabel);\n addButton.setAttribute(\"aria-controls\", `${idPrefix}-panel`);\n addButton.style.paddingLeft = `${SPACE[2]}px`;\n addButton.style.paddingRight = `${SPACE[2]}px`;\n\n const panel = document.createElement(\"div\");\n panel.id = `${idPrefix}-panel`;\n panel.className = `${classPrefix}-panel`;\n panel.style.flexDirection = \"column\";\n panel.style.gap = `${SPACE[2]}px`;\n panel.style.padding = `${SPACE[3]}px`;\n panel.style.backgroundColor = COLORS.surfaceRaised;\n panel.style.border = `1px solid ${COLORS.border}`;\n panel.style.borderRadius = `${RADIUS.md}`;\n\n const srcInput = createInput(\n `${classPrefix}-src`,\n `${idPrefix}-src`,\n \"https://example.com/image.png\",\n );\n const altInput = createInput(\n `${classPrefix}-alt`,\n `${idPrefix}-alt`,\n \"Describe the image for screen readers\",\n );\n const previewSlot = document.createElement(\"div\");\n previewSlot.className = options.previewSlotClass;\n\n const removeButton = createButton(\n \"Remove image\",\n \"ghost\",\n `${classPrefix}-remove`,\n );\n removeButton.style.alignSelf = \"flex-start\";\n\n panel.append(\n createField(\"Image URL\", srcInput),\n createField(\"Image description (alt text)\", altInput),\n previewSlot,\n removeButton,\n );\n root.append(addButton, panel);\n\n const setExpanded = (expanded: boolean): void => {\n setShown(panel, expanded, \"flex\");\n setShown(addButton, !expanded);\n addButton.setAttribute(\"aria-expanded\", String(expanded));\n };\n setExpanded(false);\n\n const handleEdit = (): void => {\n const media = buildMediaRef(srcInput.value, altInput.value);\n syncPreview(previewSlot, media, options.previewClass);\n options.onEdit(media);\n };\n srcInput.addEventListener(\"input\", handleEdit);\n altInput.addEventListener(\"input\", handleEdit);\n\n addButton.addEventListener(\"click\", () => {\n setExpanded(true);\n options.onExpand();\n srcInput.focus();\n });\n removeButton.addEventListener(\"click\", () => {\n srcInput.value = \"\";\n altInput.value = \"\";\n syncPreview(previewSlot, undefined, options.previewClass);\n setExpanded(false);\n options.onRemove();\n addButton.focus();\n });\n\n const sync = (media: QuizMediaRef | undefined, expanded: boolean): void => {\n setValue(srcInput, media?.src ?? \"\");\n setValue(altInput, media?.alt ?? \"\");\n syncPreview(previewSlot, media, options.previewClass);\n setExpanded(expanded);\n };\n\n return { root, srcInput, altInput, previewSlot, sync };\n}\n\ninterface OptionRow {\n row: HTMLDivElement;\n radio: HTMLInputElement;\n textInput: HTMLInputElement;\n error: HTMLParagraphElement;\n media: MediaEditor;\n}\n\n/**\n * Builds the quiz authoring form once and returns a controller whose\n * `syncTo` patches inputs in place (preserving focus) instead of rebuilding\n * the DOM on every keystroke. The form has a question tab list (add,\n * select); the ACTIVE question's text, image and answers are edited in the\n * tab panel below it, with the correct answer chosen by a radio on each\n * answer row. Switching the selected question rebuilds that question's\n * answer rows (an explicit action); within the active question, edits patch\n * in place. All edits emit canonical multi-question {@link QuizData}.\n */\nfunction createQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n ensureInterlaceStyles(container.ownerDocument);\n editorInstanceCount += 1;\n const uid = `quiz-editor-${editorInstanceCount}`;\n\n container.innerHTML = \"\";\n const root = document.createElement(\"div\");\n root.className = \"quiz-editor\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n root.style.display = \"flex\";\n root.style.flexDirection = \"column\";\n root.style.gap = `${SPACE[3]}px`;\n\n let currentData: QuizData = data;\n let currentOnChange = onChange;\n let selectedIndex = 0;\n let bodyQuestionIndex = -1;\n let optionRows: OptionRow[] = [];\n let tabButtons: HTMLButtonElement[] = [];\n /** Fields the author has blurred; errors only show for these. */\n const touched = new Set<string>();\n /** Media panels the author opened (kept open even while empty). */\n const expandedMedia = new Set<string>();\n\n const emit = (questions: QuizQuestionSpec[]): void => {\n currentOnChange({ questions });\n };\n\n /** Applies `mutate` to the active question and emits the canonical list. */\n const patchActiveQuestion = (\n mutate: (question: QuizQuestionSpec) => QuizQuestionSpec,\n ): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n const questions = currentData.questions.slice();\n questions[selectedIndex] = mutate(active);\n emit(questions);\n };\n\n /** Stable state key for the active question (or one of its answers). */\n const activeKey = (optionIndex?: number): string => {\n const active = currentData.questions[selectedIndex];\n const questionKey = active?.id ?? `#${selectedIndex}`;\n if (optionIndex === undefined) return questionKey;\n return `${questionKey}/${active?.options[optionIndex]?.id ?? `#${optionIndex}`}`;\n };\n\n // --- Question tabs ---\n const questionsHeader = document.createElement(\"div\");\n questionsHeader.id = `${uid}-questions-label`;\n questionsHeader.className = \"interlace-label\";\n questionsHeader.textContent = \"Questions\";\n questionsHeader.style.fontSize = `${TYPE.sm}px`;\n questionsHeader.style.fontWeight = \"600\";\n questionsHeader.style.color = COLORS.textMuted;\n\n const tabsRow = document.createElement(\"div\");\n tabsRow.style.display = \"flex\";\n tabsRow.style.flexWrap = \"wrap\";\n tabsRow.style.alignItems = \"center\";\n tabsRow.style.gap = `${SPACE[2]}px`;\n\n const tabsBar = document.createElement(\"div\");\n tabsBar.className = \"quiz-question-tabs\";\n tabsBar.setAttribute(\"role\", \"tablist\");\n tabsBar.setAttribute(\"aria-labelledby\", questionsHeader.id);\n tabsBar.style.display = \"flex\";\n tabsBar.style.flexWrap = \"wrap\";\n tabsBar.style.gap = `${SPACE[2]}px`;\n\n const addQuestionButton = createButton(\n \"+ Add question\",\n \"secondary\",\n \"quiz-add-question\",\n );\n addQuestionButton.addEventListener(\"click\", () => {\n const id = nextQuestionId(\n currentData.questions,\n currentData.questions.length,\n );\n const questions = [...currentData.questions, emptyQuestion(id)];\n currentData = { questions };\n selectedIndex = questions.length - 1;\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n });\n tabsRow.append(tabsBar, addQuestionButton);\n root.append(questionsHeader, tabsRow);\n\n // --- Active question panel ---\n const body = document.createElement(\"div\");\n body.id = `${uid}-panel`;\n body.className = \"quiz-editor-body\";\n body.setAttribute(\"role\", \"tabpanel\");\n body.style.display = \"flex\";\n body.style.flexDirection = \"column\";\n body.style.gap = `${SPACE[4]}px`;\n body.style.padding = `${SPACE[4]}px`;\n body.style.backgroundColor = COLORS.surface;\n body.style.border = `1px solid ${COLORS.border}`;\n body.style.borderRadius = `${RADIUS.md}`;\n root.appendChild(body);\n\n // Question text: label above, remove-question action on the same line.\n const questionInput = createInput(\n \"quiz-question\",\n `${uid}-question`,\n \"Type your question\",\n );\n questionInput.style.fontSize = `${TYPE.md}px`;\n const questionError = createErrorText(\n `${uid}-question-error`,\n \"quiz-question-error\",\n );\n const refreshQuestionError = (): void => {\n const show =\n touched.has(`text:${activeKey()}`) &&\n questionInput.value.trim().length === 0;\n setFieldError(\n questionInput,\n questionError,\n show ? \"Add the question text\" : null,\n );\n };\n questionInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n text: questionInput.value,\n }));\n refreshQuestionError();\n });\n questionInput.addEventListener(\"blur\", () => {\n touched.add(`text:${activeKey()}`);\n refreshQuestionError();\n });\n\n const removeQuestionButton = createRemoveButton(\"quiz-question-remove\");\n removeQuestionButton.addEventListener(\"click\", () =>\n removeQuestion(selectedIndex),\n );\n\n const questionHeader = document.createElement(\"div\");\n questionHeader.style.display = \"flex\";\n questionHeader.style.alignItems = \"center\";\n questionHeader.style.justifyContent = \"space-between\";\n questionHeader.style.gap = `${SPACE[2]}px`;\n questionHeader.append(\n createLabel(\"Question\", questionInput.id),\n removeQuestionButton,\n );\n\n const questionField = document.createElement(\"div\");\n questionField.className = \"interlace-field\";\n questionField.style.display = \"flex\";\n questionField.style.flexDirection = \"column\";\n questionField.style.gap = `${SPACE[1]}px`;\n questionField.append(questionHeader, questionInput, questionError);\n\n const questionMedia = createMediaEditor({\n classPrefix: \"quiz-question-media\",\n idPrefix: `${uid}-question-media`,\n addLabel: \"Add image to question\",\n previewSlotClass: \"quiz-question-media-preview-slot\",\n previewClass: \"quiz-question-media-preview\",\n onEdit: (media) => {\n expandedMedia.add(activeKey());\n patchActiveQuestion((question) => ({ ...question, media }));\n },\n onExpand: () => expandedMedia.add(activeKey()),\n onRemove: () => {\n expandedMedia.delete(activeKey());\n patchActiveQuestion((question) => ({ ...question, media: undefined }));\n },\n });\n questionField.appendChild(questionMedia.root);\n body.appendChild(questionField);\n\n // Answers: heading + hint, then one row per answer with a correct radio.\n const answersSection = document.createElement(\"div\");\n answersSection.style.display = \"flex\";\n answersSection.style.flexDirection = \"column\";\n answersSection.style.gap = `${SPACE[2]}px`;\n\n const answersHeading = document.createElement(\"div\");\n answersHeading.id = `${uid}-answers-label`;\n answersHeading.className = \"interlace-label quiz-answers-heading\";\n answersHeading.textContent = \"Answers\";\n answersHeading.style.fontSize = `${TYPE.sm}px`;\n answersHeading.style.fontWeight = \"600\";\n\n const answersHint = document.createElement(\"p\");\n answersHint.id = `${uid}-answers-hint`;\n answersHint.className = \"interlace-hint quiz-answers-hint\";\n answersHint.textContent = \"Select the correct answer.\";\n answersHint.style.margin = \"0\";\n answersHint.style.fontSize = `${TYPE.sm}px`;\n answersHint.style.color = COLORS.textMuted;\n\n const optionsContainer = document.createElement(\"div\");\n optionsContainer.className = \"quiz-options\";\n optionsContainer.setAttribute(\"role\", \"radiogroup\");\n optionsContainer.setAttribute(\"aria-labelledby\", answersHeading.id);\n optionsContainer.setAttribute(\"aria-describedby\", answersHint.id);\n optionsContainer.style.display = \"flex\";\n optionsContainer.style.flexDirection = \"column\";\n optionsContainer.style.gap = `${SPACE[2]}px`;\n\n const addOptionButton = createButton(\n \"+ Add answer\",\n \"secondary\",\n \"quiz-add-option\",\n );\n addOptionButton.style.alignSelf = \"flex-start\";\n addOptionButton.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const nextOptions: QuizOption[] = [\n ...question.options,\n {\n id: nextOptionId(question.options, question.options.length),\n text: \"\",\n },\n ];\n // Adding the first option defaults it to correct (ported behavior).\n const nextCorrectOptionId =\n question.options.length === 0\n ? nextOptions[0]!.id\n : question.correctOptionId;\n return {\n ...question,\n options: nextOptions,\n correctOptionId: nextCorrectOptionId,\n };\n });\n });\n\n answersSection.append(\n answersHeading,\n answersHint,\n optionsContainer,\n addOptionButton,\n );\n body.appendChild(answersSection);\n\n container.appendChild(root);\n\n const createOptionRow = (\n option: QuizOption,\n optionIndex: number,\n optionCount: number,\n ): OptionRow => {\n const number = optionIndex + 1;\n const idPrefix = `${uid}-q${selectedIndex}-opt${optionIndex}`;\n\n // Grid: [radio] [label / input / error + image] [remove].\n const row = document.createElement(\"div\");\n row.className = \"quiz-option-row interlace-choice\";\n row.style.display = \"grid\";\n row.style.gridTemplateColumns = \"auto minmax(0, 1fr) auto\";\n row.style.alignItems = \"center\";\n row.style.columnGap = `${SPACE[2]}px`;\n row.style.rowGap = `${SPACE[1]}px`;\n row.style.cursor = \"default\";\n // The inputs draw their own focus rings; skip the card's focus-within ring.\n row.style.outline = \"none\";\n\n const radio = document.createElement(\"input\");\n radio.type = \"radio\";\n radio.name = `${uid}-correct-${selectedIndex}`;\n radio.className = \"quiz-option-correct\";\n radio.value = option.id;\n radio.checked =\n option.id === currentData.questions[selectedIndex]?.correctOptionId;\n radio.setAttribute(\"aria-label\", `Mark answer ${number} as correct`);\n radio.style.width = \"18px\";\n radio.style.height = \"18px\";\n radio.style.margin = \"0\";\n radio.style.accentColor = COLORS.accent;\n radio.style.cursor = \"pointer\";\n radio.style.gridColumn = \"1\";\n radio.style.gridRow = \"2\";\n radio.addEventListener(\"change\", () => {\n if (!radio.checked) return;\n patchActiveQuestion((question) => ({\n ...question,\n correctOptionId: question.options[optionIndex]?.id ?? null,\n }));\n });\n\n const textInput = createInput(\n \"quiz-option-text\",\n `${idPrefix}-text`,\n \"Answer text\",\n );\n textInput.value = option.text;\n textInput.style.gridColumn = \"2\";\n textInput.style.gridRow = \"2\";\n const label = createLabel(`Answer ${number}`, textInput.id);\n label.style.gridColumn = \"2\";\n label.style.gridRow = \"1\";\n\n const error = createErrorText(`${idPrefix}-error`, \"quiz-option-error\");\n const refreshError = (): void => {\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n textInput.value.trim().length === 0;\n setFieldError(\n textInput,\n error,\n show ? `Answer ${number} needs text` : null,\n );\n };\n textInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = {\n ...nextOptions[optionIndex]!,\n text: textInput.value,\n };\n return { ...question, options: nextOptions };\n });\n refreshError();\n });\n textInput.addEventListener(\"blur\", () => {\n touched.add(`opt:${activeKey(optionIndex)}`);\n refreshError();\n });\n\n const patchOptionMedia = (media: QuizMediaRef | undefined): void => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = { ...nextOptions[optionIndex]!, media };\n return { ...question, options: nextOptions };\n });\n };\n const media = createMediaEditor({\n classPrefix: \"quiz-option-media\",\n idPrefix: `${idPrefix}-media`,\n addLabel: `Add image to answer ${number}`,\n previewSlotClass: \"quiz-option-media-preview\",\n previewClass: \"quiz-option-thumb\",\n onEdit: (next) => {\n expandedMedia.add(activeKey(optionIndex));\n patchOptionMedia(next);\n },\n onExpand: () => expandedMedia.add(activeKey(optionIndex)),\n onRemove: () => {\n expandedMedia.delete(activeKey(optionIndex));\n patchOptionMedia(undefined);\n },\n });\n\n const details = document.createElement(\"div\");\n details.style.gridColumn = \"2\";\n details.style.gridRow = \"3\";\n details.style.display = \"flex\";\n details.style.flexDirection = \"column\";\n details.style.alignItems = \"flex-start\";\n details.style.gap = `${SPACE[1]}px`;\n media.root.style.alignSelf = \"stretch\";\n details.append(error, media.root);\n\n const remove = createRemoveButton(\"quiz-option-remove\");\n remove.setAttribute(\"aria-label\", `Remove answer ${number}`);\n remove.style.gridColumn = \"3\";\n remove.style.gridRow = \"2\";\n setRemoveAllowed(\n remove,\n optionCount > MIN_ANSWERS,\n `A question needs at least ${MIN_ANSWERS} answers`,\n );\n remove.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const removed = question.options[optionIndex];\n const nextOptions = question.options.filter(\n (_, i) => i !== optionIndex,\n );\n return {\n ...question,\n options: nextOptions,\n // Removing the correct option clears correctness; do not shift it.\n correctOptionId:\n removed && removed.id === question.correctOptionId\n ? null\n : question.correctOptionId,\n };\n });\n });\n\n row.append(label, radio, textInput, remove, details);\n optionsContainer.appendChild(row);\n return { row, radio, textInput, error, media };\n };\n\n const selectQuestion = (index: number): void => {\n selectedIndex = index;\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const removeQuestion = (index: number): void => {\n const next = currentData.questions.filter((_, i) => i !== index);\n const questions =\n next.length > 0 ? next : [emptyQuestion(nextQuestionId([], 0))];\n if (selectedIndex === index) {\n selectedIndex = 0; // removing the selected question selects the first remaining\n } else if (index < selectedIndex) {\n selectedIndex -= 1;\n }\n currentData = { questions };\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const renderTabs = (): void => {\n tabsBar.innerHTML = \"\";\n const count = currentData.questions.length;\n tabButtons = currentData.questions.map((_, index) => {\n const selected = index === selectedIndex;\n const tab = createButton(\n `Question ${index + 1}`,\n selected ? \"primary\" : \"secondary\",\n \"quiz-question-tab\",\n );\n tab.id = `${uid}-tab-${index}`;\n tab.setAttribute(\"role\", \"tab\");\n tab.setAttribute(\"aria-selected\", String(selected));\n tab.setAttribute(\"aria-controls\", body.id);\n tab.tabIndex = selected ? 0 : -1;\n tab.addEventListener(\"click\", () => selectQuestion(index));\n tab.addEventListener(\"keydown\", (event) => {\n let target = -1;\n if (event.key === \"ArrowRight\") target = (index + 1) % count;\n else if (event.key === \"ArrowLeft\")\n target = (index - 1 + count) % count;\n else if (event.key === \"Home\") target = 0;\n else if (event.key === \"End\") target = count - 1;\n if (target < 0) return;\n event.preventDefault();\n selectQuestion(target);\n tabButtons[target]?.focus();\n });\n tabsBar.appendChild(tab);\n return tab;\n });\n\n body.setAttribute(\"aria-labelledby\", `${uid}-tab-${selectedIndex}`);\n removeQuestionButton.setAttribute(\n \"aria-label\",\n `Remove question ${selectedIndex + 1}`,\n );\n setRemoveAllowed(\n removeQuestionButton,\n count > 1,\n \"A quiz needs at least one question\",\n );\n };\n\n const syncActiveBody = (): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n\n setValue(questionInput, active.text);\n questionMedia.sync(\n active.media,\n !!active.media || expandedMedia.has(activeKey()),\n );\n refreshQuestionError();\n\n const options = active.options;\n if (\n bodyQuestionIndex !== selectedIndex ||\n optionRows.length !== options.length\n ) {\n // Question switch or option count change: rebuild the active question's rows.\n optionsContainer.innerHTML = \"\";\n optionRows = options.map((option, optionIndex) =>\n createOptionRow(option, optionIndex, options.length),\n );\n bodyQuestionIndex = selectedIndex;\n }\n // Patch values in place, preserving input focus.\n optionRows.forEach((row, optionIndex) => {\n const option = options[optionIndex]!;\n setValue(row.textInput, option.text);\n row.radio.value = option.id;\n row.radio.checked = option.id === active.correctOptionId;\n row.media.sync(\n option.media,\n !!option.media || expandedMedia.has(activeKey(optionIndex)),\n );\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n option.text.trim().length === 0;\n setFieldError(\n row.textInput,\n row.error,\n show ? `Answer ${optionIndex + 1} needs text` : null,\n );\n });\n };\n\n const syncTo = (\n nextData: QuizData,\n nextOnChange: (next: QuizData) => void,\n ): void => {\n currentData = nextData;\n currentOnChange = nextOnChange;\n if (currentData.questions.length === 0) {\n currentData = { questions: [emptyQuestion(\"q-0\")] };\n }\n if (selectedIndex >= currentData.questions.length) {\n selectedIndex = 0;\n }\n renderTabs();\n syncActiveBody();\n };\n\n renderTabs();\n syncActiveBody();\n\n return { syncTo };\n}\n\nfunction getOrCreateQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n let controller = quizEditorControllers.get(container);\n if (!controller) {\n controller = createQuizEditorController(container, data, onChange);\n quizEditorControllers.set(container, controller);\n }\n return controller;\n}\n\n/** Tears down the editor controller mounted in `container`, if any. */\nexport function unmountQuizEditor(container: HTMLElement): void {\n quizEditorControllers.delete(container);\n container.innerHTML = \"\";\n}\n\n/**\n * Built-in Quiz editor content type. Authors the canonical multi-question\n * {@link QuizData} shape with rich media (the single supported format).\n * Registered id is `quiz-editor`, matching the player's built-in quiz\n * content type.\n */\nexport const QuizEditorType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n","/**\n * Interlace design tokens, re-exported from `@interlacejs/core` so every\n * package shares one themeable set (CSS custom properties with defaults).\n */\nexport {\n COLORS,\n CONTROL_HEIGHT,\n FOCUS_RING,\n FONTS,\n RADIUS,\n SHADOWS,\n SPACE,\n TYPE,\n} from \"@interlacejs/core\";\n","import type { QuizData, QuizOption } from \"./schema\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\n\nexport interface QuizPlaybackCallbacks {\n onComplete(score?: number): void;\n}\n\ninterface QuizPlaybackSession {\n destroy: () => void;\n}\n\ninterface OptionEntry {\n button: HTMLButtonElement;\n option: QuizOption;\n statusGlyph: HTMLSpanElement;\n statusLabel: HTMLSpanElement;\n}\n\n/**\n * Per-container playback sessions, so `unmountQuizPlayback` can tear down\n * the listeners built by `renderQuizPlayback`.\n */\nconst quizPlaybackSessions = new WeakMap<HTMLElement, QuizPlaybackSession>();\n\n/** Creates a playback media `<img>`, or `null` when src is blank. */\nfunction createMediaImage(\n className: string,\n src: string,\n alt: string | undefined,\n): HTMLImageElement | null {\n if (src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginBottom = `${SPACE[2]}px`;\n if (alt) img.alt = alt;\n return img;\n}\n\n/** Locks an option button so it can no longer be clicked. */\nfunction lockOption(button: HTMLButtonElement): void {\n button.disabled = true;\n button.style.cursor = \"default\";\n}\n\n/** Reveals the correct-answer state on an option button. */\nfunction revealCorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-correct\");\n button.style.backgroundColor = COLORS.correctBg;\n button.style.borderColor = COLORS.correctBg;\n button.style.color = COLORS.correctText;\n glyph.textContent = \"✓\";\n label.textContent = \"Correct\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/** Reveals the wrong-answer state on the selected option button. */\nfunction revealIncorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-incorrect\");\n button.style.backgroundColor = COLORS.incorrectBg;\n button.style.borderColor = COLORS.incorrectBorder;\n button.style.color = COLORS.incorrectText;\n glyph.textContent = \"✕\";\n label.textContent = \"Incorrect\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/**\n * Renders a multi-question quiz into `container`: one question at a time\n * with a \"Question i of n\" indicator, per-question media and option buttons,\n * and an explicit navigation footer. Answering a question reveals\n * correctness and locks its options; the user then advances with **Next**.\n * On the final question, clicking **Next** reports the per-question\n * correct count (`onComplete(correctCount)`, one point per question) ONCE,\n * as the click handler's final statement. **Previous** returns to an\n * answered question in its locked, review-only state. The document is the\n * canonical single-format {@link QuizData} shape.\n */\nexport function renderQuizPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: QuizPlaybackCallbacks,\n): void {\n // Destroy any session already mounted in this container: the overlay\n // lifecycle may re-render without an intervening unmount, and overwriting\n // the WeakMap entry would leak the first root (and its click listeners).\n unmountQuizPlayback(container);\n\n const total = data.questions.length;\n // Per-question recorded selections; back-navigation and the final\n // aggregate both read from here, and reveal locks make it stable.\n const answers: (string | null)[] = data.questions.map(() => null);\n let currentIndex = 0;\n let completed = false;\n\n const root = document.createElement(\"div\");\n root.className = \"quiz-playback\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n const indicator = document.createElement(\"div\");\n indicator.className = \"quiz-playback-indicator\";\n indicator.style.fontSize = `${TYPE.xs}px`;\n indicator.style.fontWeight = \"600\";\n indicator.style.color = COLORS.textMuted;\n indicator.style.marginBottom = `${SPACE[2]}px`;\n indicator.style.textTransform = \"uppercase\";\n indicator.style.letterSpacing = \"0.06em\";\n root.appendChild(indicator);\n\n const question = document.createElement(\"p\");\n question.className = \"quiz-playback-question\";\n question.style.margin = `0 0 ${SPACE[2]}px 0`;\n question.style.fontFamily = FONTS.display;\n question.style.fontSize = `${TYPE.lg}px`;\n question.style.fontWeight = \"600\";\n root.appendChild(question);\n\n const questionMediaSlot = document.createElement(\"div\");\n root.appendChild(questionMediaSlot);\n\n const optionsBox = document.createElement(\"div\");\n optionsBox.className = \"quiz-playback-options\";\n optionsBox.style.display = \"flex\";\n optionsBox.style.flexDirection = \"column\";\n optionsBox.style.gap = `${SPACE[2]}px`;\n root.appendChild(optionsBox);\n\n // Navigation footer: Previous (review-only back) and Next. The final\n // question uses the same Next label; clicking it aggregates the score\n // and fires onComplete once.\n const navFooter = document.createElement(\"div\");\n navFooter.className = \"quiz-playback-nav\";\n navFooter.style.display = \"flex\";\n navFooter.style.justifyContent = \"flex-end\";\n navFooter.style.gap = `${SPACE[2]}px`;\n navFooter.style.marginTop = `${SPACE[4]}px`;\n root.appendChild(navFooter);\n\n const prevButton = document.createElement(\"button\");\n prevButton.type = \"button\";\n prevButton.className = \"quiz-playback-prev\";\n prevButton.textContent = \"Previous\";\n prevButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n prevButton.style.backgroundColor = COLORS.surface;\n prevButton.style.border = `1px solid ${COLORS.borderStrong}`;\n prevButton.style.borderRadius = `${RADIUS.md}`;\n prevButton.style.color = COLORS.text;\n prevButton.style.cursor = \"pointer\";\n prevButton.style.fontSize = `${TYPE.base}px`;\n prevButton.style.fontWeight = \"600\";\n prevButton.style.transition = \"background-color 150ms ease\";\n prevButton.addEventListener(\"click\", () => {\n if (currentIndex > 0) {\n renderQuestion(currentIndex - 1);\n }\n });\n navFooter.appendChild(prevButton);\n\n const nextButton = document.createElement(\"button\");\n nextButton.type = \"button\";\n nextButton.className = \"quiz-playback-next\";\n nextButton.textContent = \"Next\";\n nextButton.disabled = true;\n nextButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n nextButton.style.backgroundColor = COLORS.accent;\n nextButton.style.border = \"none\";\n nextButton.style.borderRadius = `${RADIUS.md}`;\n nextButton.style.color = COLORS.accentContrast;\n nextButton.style.cursor = \"pointer\";\n nextButton.style.fontSize = `${TYPE.base}px`;\n nextButton.style.fontWeight = \"600\";\n nextButton.style.transition =\n \"background-color 150ms ease, opacity 150ms ease\";\n nextButton.addEventListener(\"click\", () => {\n if (completed) return;\n if (currentIndex < total - 1) {\n renderQuestion(currentIndex + 1);\n } else {\n // Final question: aggregate the per-question answers.\n completed = true;\n const correctCount = data.questions.reduce(\n (count, questionSpec, questionIndex) =>\n count +\n (answers[questionIndex] !== null &&\n answers[questionIndex] === questionSpec.correctOptionId\n ? 1\n : 0),\n 0,\n );\n nextButton.disabled = true;\n nextButton.style.opacity = \"0.55\";\n callbacks.onComplete(correctCount);\n }\n });\n navFooter.appendChild(nextButton);\n\n container.appendChild(root);\n\n let optionEntries: OptionEntry[] = [];\n\n const syncFooter = (index: number): void => {\n prevButton.style.display = index > 0 ? \"block\" : \"none\";\n nextButton.textContent = \"Next\";\n const answered = answers[index] !== null;\n nextButton.disabled = completed || !answered;\n nextButton.style.opacity = nextButton.disabled ? \"0.55\" : \"1\";\n };\n\n const createOptionButton = (\n option: QuizOption,\n isReview: boolean,\n ): OptionEntry => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"quiz-playback-option\";\n button.style.display = \"flex\";\n button.style.alignItems = \"center\";\n button.style.gap = `${SPACE[2]}px`;\n button.style.width = \"100%\";\n button.style.padding = `${SPACE[3]}px ${SPACE[4]}px`;\n button.style.backgroundColor = COLORS.surface;\n button.style.border = `1px solid ${COLORS.borderStrong}`;\n button.style.borderRadius = `${RADIUS.md}`;\n button.style.cursor = \"pointer\";\n button.style.fontSize = `${TYPE.base}px`;\n button.style.color = COLORS.text;\n button.style.textAlign = \"left\";\n button.style.transition =\n \"background-color 150ms ease, border-color 150ms ease, color 150ms ease\";\n\n const text = document.createElement(\"span\");\n text.className = \"quiz-playback-option-text\";\n text.textContent = option.text;\n text.style.flex = \"1\";\n button.appendChild(text);\n\n const thumbnail = createMediaImage(\n \"quiz-playback-option-media\",\n option.media?.src ?? \"\",\n option.media?.alt,\n );\n if (thumbnail) button.appendChild(thumbnail);\n\n const status = document.createElement(\"span\");\n status.style.display = \"flex\";\n status.style.alignItems = \"center\";\n status.style.gap = `${SPACE[1]}px`;\n status.style.marginLeft = \"auto\";\n status.style.transition = \"opacity 150ms ease\";\n\n const glyph = document.createElement(\"span\");\n glyph.style.fontWeight = \"700\";\n glyph.style.fontSize = `${TYPE.md}px`;\n glyph.style.lineHeight = \"1\";\n status.appendChild(glyph);\n\n const label = document.createElement(\"span\");\n label.style.fontWeight = \"600\";\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.letterSpacing = \"0.04em\";\n status.appendChild(label);\n\n button.appendChild(status);\n\n if (isReview) {\n lockOption(button);\n }\n\n return { button, option, statusGlyph: glyph, statusLabel: label };\n };\n\n const revealQuestion = (\n questionIndex: number,\n selectedOptionId: string,\n ): void => {\n const spec = data.questions[questionIndex]!;\n const correctOptionId = spec.correctOptionId;\n\n optionEntries.forEach((entry) => {\n lockOption(entry.button);\n if (entry.option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (\n entry.option.id === selectedOptionId &&\n selectedOptionId !== correctOptionId\n ) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n });\n };\n\n const renderQuestion = (index: number): void => {\n currentIndex = index;\n const spec = data.questions[index]!;\n const correctOptionId = spec.correctOptionId;\n const answered = answers[index] ?? null;\n\n indicator.textContent = `Question ${index + 1} of ${total}`;\n question.textContent = spec.text;\n questionMediaSlot.innerHTML = \"\";\n const questionMedia = createMediaImage(\n \"quiz-playback-question-media\",\n spec.media?.src ?? \"\",\n spec.media?.alt,\n );\n if (questionMedia) questionMediaSlot.appendChild(questionMedia);\n\n optionsBox.innerHTML = \"\";\n optionEntries = spec.options.map((option) => {\n const isReview = answered !== null;\n const entry = createOptionButton(option, isReview);\n\n if (isReview) {\n if (option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (option.id === answered && answered !== correctOptionId) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n } else {\n entry.button.addEventListener(\"click\", () => {\n if (completed) return;\n answers[index] = option.id;\n // Reveal correctness and lock this question's options. No\n // auto-advance and no auto-complete: the footer gates progress.\n revealQuestion(index, option.id);\n syncFooter(index);\n });\n }\n\n optionsBox.appendChild(entry.button);\n return entry;\n });\n\n syncFooter(index);\n };\n\n renderQuestion(0);\n\n quizPlaybackSessions.set(container, {\n destroy: () => {\n root.remove();\n },\n });\n}\n\n/** Cleans up the playback session mounted in `container`, if any. */\nexport function unmountQuizPlayback(container: HTMLElement): void {\n quizPlaybackSessions.get(container)?.destroy();\n quizPlaybackSessions.delete(container);\n}\n","import type { QuizData } from \"./schema\";\n\n/**\n * Validates canonical quiz data, returning human-readable error strings\n * indexed per question. An empty array means the document is valid.\n *\n * The legacy flat input format was removed; only the canonical\n * multi-question `QuizData` shape is accepted.\n */\nexport function validateQuizData(data: QuizData): string[] {\n const errors: string[] = [];\n\n if (data.questions.length === 0) {\n errors.push(\"at least one question is required\");\n return errors;\n }\n\n data.questions.forEach((question, index) => {\n if (question.text.trim().length === 0) {\n errors.push(`questions[${index}].text must be a non-empty string`);\n }\n\n if (question.options.length === 0) {\n errors.push(`questions[${index}].at least one option is required`);\n } else {\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n errors.push(\n `questions[${index}].options[${optionIndex}].text must be a non-empty string`,\n );\n }\n });\n }\n\n if (question.correctOptionId === null) {\n errors.push(\n `questions[${index}].exactly one correct option must be resolvable`,\n );\n }\n });\n\n return errors;\n}\n/**\n * Author-facing readiness check for quiz data, used by the content type's\n * `validate`. Returns friendly messages (e.g. \"Question 1 needs text\"); an\n * empty array means the quiz is ready to save.\n */\nexport function getQuizAuthoringIssues(data: QuizData): string[] {\n if (data.questions.length === 0) return [\"Add at least one question\"];\n\n const issues: string[] = [];\n data.questions.forEach((question, index) => {\n const label = `Question ${index + 1}`;\n if (question.text.trim().length === 0) {\n issues.push(`${label} needs text`);\n }\n if (question.options.length < 2) {\n issues.push(`${label} needs at least 2 answers`);\n }\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n issues.push(`${label}, answer ${optionIndex + 1} needs text`);\n }\n });\n const hasCorrect = question.options.some(\n (option) => option.id === question.correctOptionId,\n );\n if (!hasCorrect) issues.push(`${label} needs a correct answer`);\n });\n return issues;\n}\n","import { ContentType } from \"@interlacejs/core\";\nimport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport type { QuizData } from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\n/**\n * Built-in Quiz content type for Interlace. Authors the canonical\n * {@link QuizData} shape with rich media and plays it back with immediate\n * scoring. Registered id is `quiz-editor` — the id the editor's built-in\n * quiz type authors with — so authored documents resolve without extra\n * registry wiring.\n */\nexport const QuizContentType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.renderEditor(container, data, onChange);\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.updateEditor?.(container, data, onChange);\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n"],"mappings":";AAAA,SAAsB,6BAA6B;;;ACInD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACSP,IAAM,uBAAuB,oBAAI,QAA0C;AAG3E,SAAS,iBACP,WACA,KACA,KACyB;AACzB,MAAI,IAAI,WAAW,EAAG,QAAO;AAC7B,QAAM,MAAM,SAAS,cAAc,KAAK;AACxC,MAAI,YAAY;AAChB,MAAI,MAAM;AACV,MAAI,MAAM,WAAW;AACrB,MAAI,MAAM,SAAS;AACnB,MAAI,MAAM,eAAe,GAAG,OAAO,EAAE;AACrC,MAAI,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC;AACpC,MAAI,IAAK,KAAI,MAAM;AACnB,SAAO;AACT;AAGA,SAAS,WAAW,QAAiC;AACnD,SAAO,WAAW;AAClB,SAAO,MAAM,SAAS;AACxB;AAGA,SAAS,cACP,QACA,OACA,OACM;AACN,SAAO,UAAU,IAAI,8BAA8B;AACnD,SAAO,MAAM,kBAAkB,OAAO;AACtC,SAAO,MAAM,cAAc,OAAO;AAClC,SAAO,MAAM,QAAQ,OAAO;AAC5B,QAAM,cAAc;AACpB,QAAM,cAAc;AACpB,QAAM,MAAM,UAAU;AACtB,QAAM,MAAM,UAAU;AACxB;AAGA,SAAS,gBACP,QACA,OACA,OACM;AACN,SAAO,UAAU,IAAI,gCAAgC;AACr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,aACE,WACA,MACA,UACM;AACN,oCAAgC,WAAW,MAAM,QAAQ,EAAE;AAAA,MACzD;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,oCAAgC,WAAW,MAAM,QAAQ,EAAE;AAAA,MACzD;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;;;AIv7BO,IAAM,kBAAyC;AAAA,EACpD,OAAO,MAAM;AAAA,EACb,YAAY,MAAM;AAAA,EAClB,gBAAgB,MAAM;AAAA,EACtB,gBAAgB,MAAM;AAAA,EAEtB,SAAS,MAA0B;AACjC,WAAO,uBAAuB,IAAI;AAAA,EACpC;AAAA,EAEA,gBAAgB,MAA0B;AACxC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,MAAM,UAAyB;AAAA,EAE/B;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,aAAa,WAAW,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,eAAe,WAAW,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;","names":["media"]}
1
+ {"version":3,"sources":["../src/quiz-editor.ts","../src/tokens.ts","../src/quiz-player.ts","../src/validate.ts","../src/quiz-content-type.ts"],"sourcesContent":["import { ContentType, ensureInterlaceStyles } from \"@interlacejs/core\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\nimport type {\n QuizData,\n QuizMediaRef,\n QuizOption,\n QuizQuestionSpec,\n} from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\ninterface QuizEditorController {\n syncTo(data: QuizData, onChange: (next: QuizData) => void): void;\n}\n\n/**\n * Controllers are stashed per container so the slot can hand the same\n * controller back across the mount/update lifecycle. The slot always passes\n * the same container element to `renderEditor`/`updateEditor`/`unmount`.\n */\nconst quizEditorControllers = new WeakMap<HTMLElement, QuizEditorController>();\n\n/** Gives each mounted editor unique element ids and radio group names. */\nlet editorInstanceCount = 0;\n\n/** Fewest options a question may be reduced to via the remove buttons. */\nconst MIN_OPTIONS = 2;\n\n/** Builds a media ref from src/alt text; `undefined` when src is blank. */\nfunction buildMediaRef(src: string, alt: string): QuizMediaRef | undefined {\n if (src.length === 0) return undefined;\n return alt.length > 0 ? { src, alt } : { src };\n}\n\n/** Creates a preview `<img>` for a media ref, or `null` when src is blank. */\nfunction createPreview(\n media: QuizMediaRef | undefined,\n className: string,\n): HTMLImageElement | null {\n if (!media || media.src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = media.src;\n img.style.maxWidth = \"100%\";\n img.style.maxHeight = \"160px\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginTop = `${SPACE[1]}px`;\n if (media.alt) img.alt = media.alt;\n return img;\n}\n\n/** Renders `media` into `slot`, replacing any previous preview. */\nfunction syncPreview(\n slot: HTMLElement,\n media: QuizMediaRef | undefined,\n className: string,\n): void {\n slot.innerHTML = \"\";\n const img = createPreview(media, className);\n if (img) slot.appendChild(img);\n}\n\n/** Generates an option id that does not collide with existing ids. */\nfunction nextOptionId(options: QuizOption[], index: number): string {\n const base = `opt-${index}`;\n if (!options.some((option) => option.id === base)) return base;\n let candidate = index + 1;\n while (options.some((option) => option.id === `opt-${candidate}`)) {\n candidate += 1;\n }\n return `opt-${candidate}`;\n}\n\n/** Generates a question id that does not collide with existing ids. */\nfunction nextQuestionId(questions: QuizQuestionSpec[], index: number): string {\n const base = `q-${index}`;\n if (!questions.some((question) => question.id === base)) return base;\n let candidate = index + 1;\n while (questions.some((question) => question.id === `q-${candidate}`)) {\n candidate += 1;\n }\n return `q-${candidate}`;\n}\n\n/** An empty question stub so the form is never without a question. */\n/** A new question starts with the minimum of two options, the first correct. */\nfunction emptyQuestion(id: string): QuizQuestionSpec {\n return {\n id,\n text: \"\",\n options: [\n { id: `${id}-a`, text: \"\" },\n { id: `${id}-b`, text: \"\" },\n ],\n correctOptionId: `${id}-a`,\n };\n}\n\n/**\n * Shows or hides an element. Uses inline `display` rather than `hidden`\n * because the shared `interlace-*` rules set `display` and would override\n * the user-agent `[hidden]` rule.\n */\nfunction setShown(el: HTMLElement, shown: boolean, display = \"\"): void {\n el.style.display = shown ? display : \"none\";\n}\n\n/** Sets an input's value only when it differs, so the caret is not moved. */\nfunction setValue(input: HTMLInputElement, value: string): void {\n if (input.value !== value) input.value = value;\n}\n\nfunction createButton(\n text: string,\n variant: \"primary\" | \"secondary\" | \"ghost\",\n className: string,\n): HTMLButtonElement {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `interlace-btn interlace-btn--${variant} ${className}`;\n button.textContent = text;\n return button;\n}\n\n/** A quiet \"×\" icon button for per-row remove actions. */\nfunction createRemoveButton(className: string): HTMLButtonElement {\n const button = createButton(\"×\", \"ghost\", `interlace-btn--icon ${className}`);\n button.style.fontSize = `${TYPE.lg}px`;\n button.style.lineHeight = \"1\";\n return button;\n}\n\n/** Enables a remove button, or disables it with `reason` as its tooltip. */\nfunction setRemoveAllowed(\n button: HTMLButtonElement,\n allowed: boolean,\n reason: string,\n): void {\n button.disabled = !allowed;\n if (allowed) button.removeAttribute(\"title\");\n else button.title = reason;\n}\n\nfunction createInput(\n className: string,\n id: string,\n placeholder?: string,\n): HTMLInputElement {\n const input = document.createElement(\"input\");\n input.type = \"text\";\n input.id = id;\n input.className = `interlace-input ${className}`;\n input.style.width = \"100%\";\n input.style.boxSizing = \"border-box\";\n if (placeholder) input.placeholder = placeholder;\n return input;\n}\n\nfunction createLabel(text: string, forId: string): HTMLLabelElement {\n const label = document.createElement(\"label\");\n label.className = \"interlace-label\";\n label.htmlFor = forId;\n label.textContent = text;\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.fontWeight = \"600\";\n return label;\n}\n\n/** A labelled field (label above input) wrapped in `interlace-field`. */\nfunction createField(\n labelText: string,\n input: HTMLInputElement,\n): HTMLDivElement {\n const field = document.createElement(\"div\");\n field.className = \"interlace-field\";\n field.style.display = \"flex\";\n field.style.flexDirection = \"column\";\n field.style.gap = `${SPACE[1]}px`;\n field.append(createLabel(labelText, input.id), input);\n return field;\n}\n\n/** An inline error message element, hidden until a message is set. */\nfunction createErrorText(id: string, className: string): HTMLParagraphElement {\n const error = document.createElement(\"p\");\n error.id = id;\n error.className = `interlace-hint quiz-field-error ${className}`;\n error.style.margin = \"0\";\n error.style.fontSize = `${TYPE.sm}px`;\n error.style.color = COLORS.errorText;\n setShown(error, false);\n return error;\n}\n\n/** Shows `message` for `input` (with aria wiring), or clears it on `null`. */\nfunction setFieldError(\n input: HTMLInputElement,\n error: HTMLElement,\n message: string | null,\n): void {\n if (message) {\n error.textContent = message;\n setShown(error, true);\n input.setAttribute(\"aria-invalid\", \"true\");\n input.setAttribute(\"aria-describedby\", error.id);\n } else {\n error.textContent = \"\";\n setShown(error, false);\n input.removeAttribute(\"aria-invalid\");\n input.removeAttribute(\"aria-describedby\");\n }\n}\n\ninterface MediaEditor {\n root: HTMLDivElement;\n srcInput: HTMLInputElement;\n altInput: HTMLInputElement;\n previewSlot: HTMLDivElement;\n /** Patches values/preview in place and shows or collapses the panel. */\n sync(media: QuizMediaRef | undefined, expanded: boolean): void;\n}\n\ninterface MediaEditorOptions {\n /** Class prefix, e.g. `quiz-question-media` → `quiz-question-media-src`. */\n classPrefix: string;\n idPrefix: string;\n /** Accessible name of the \"Add image\" button. */\n addLabel: string;\n previewSlotClass: string;\n previewClass: string;\n /** The author edited the URL or alt text. */\n onEdit(media: QuizMediaRef | undefined): void;\n /** The author expanded the panel via \"Add image\". */\n onExpand(): void;\n /** The author removed the image (fields are already cleared). */\n onRemove(): void;\n}\n\n/**\n * Image URL + alt fields tucked behind a ghost \"Add image\" button. The\n * panel opens on demand (or automatically when media exists, via `sync`)\n * and \"Remove image\" clears both fields and collapses it again.\n */\nfunction createMediaEditor(options: MediaEditorOptions): MediaEditor {\n const { classPrefix, idPrefix } = options;\n const root = document.createElement(\"div\");\n root.className = classPrefix;\n\n const addButton = createButton(\"+ Add image\", \"ghost\", `${classPrefix}-add`);\n addButton.setAttribute(\"aria-label\", options.addLabel);\n addButton.setAttribute(\"aria-controls\", `${idPrefix}-panel`);\n addButton.style.paddingLeft = `${SPACE[2]}px`;\n addButton.style.paddingRight = `${SPACE[2]}px`;\n\n const panel = document.createElement(\"div\");\n panel.id = `${idPrefix}-panel`;\n panel.className = `${classPrefix}-panel`;\n panel.style.flexDirection = \"column\";\n panel.style.gap = `${SPACE[2]}px`;\n panel.style.padding = `${SPACE[3]}px`;\n panel.style.backgroundColor = COLORS.surfaceRaised;\n panel.style.border = `1px solid ${COLORS.border}`;\n panel.style.borderRadius = `${RADIUS.md}`;\n\n const srcInput = createInput(\n `${classPrefix}-src`,\n `${idPrefix}-src`,\n \"https://example.com/image.png\",\n );\n const altInput = createInput(\n `${classPrefix}-alt`,\n `${idPrefix}-alt`,\n \"Describe the image for screen readers\",\n );\n const previewSlot = document.createElement(\"div\");\n previewSlot.className = options.previewSlotClass;\n\n const removeButton = createButton(\n \"Remove image\",\n \"ghost\",\n `${classPrefix}-remove`,\n );\n removeButton.style.alignSelf = \"flex-start\";\n\n panel.append(\n createField(\"Image URL\", srcInput),\n createField(\"Image description (alt text)\", altInput),\n previewSlot,\n removeButton,\n );\n root.append(addButton, panel);\n\n const setExpanded = (expanded: boolean): void => {\n setShown(panel, expanded, \"flex\");\n setShown(addButton, !expanded);\n addButton.setAttribute(\"aria-expanded\", String(expanded));\n };\n setExpanded(false);\n\n const handleEdit = (): void => {\n const media = buildMediaRef(srcInput.value, altInput.value);\n syncPreview(previewSlot, media, options.previewClass);\n options.onEdit(media);\n };\n srcInput.addEventListener(\"input\", handleEdit);\n altInput.addEventListener(\"input\", handleEdit);\n\n addButton.addEventListener(\"click\", () => {\n setExpanded(true);\n options.onExpand();\n srcInput.focus();\n });\n removeButton.addEventListener(\"click\", () => {\n srcInput.value = \"\";\n altInput.value = \"\";\n syncPreview(previewSlot, undefined, options.previewClass);\n setExpanded(false);\n options.onRemove();\n addButton.focus();\n });\n\n const sync = (media: QuizMediaRef | undefined, expanded: boolean): void => {\n setValue(srcInput, media?.src ?? \"\");\n setValue(altInput, media?.alt ?? \"\");\n syncPreview(previewSlot, media, options.previewClass);\n setExpanded(expanded);\n };\n\n return { root, srcInput, altInput, previewSlot, sync };\n}\n\ninterface OptionRow {\n row: HTMLDivElement;\n radio: HTMLInputElement;\n textInput: HTMLInputElement;\n error: HTMLParagraphElement;\n media: MediaEditor;\n}\n\n/**\n * Builds the quiz authoring form once and returns a controller whose\n * `syncTo` patches inputs in place (preserving focus) instead of rebuilding\n * the DOM on every keystroke. The form has a question tab list (add,\n * select); the ACTIVE question's text, image and options are edited in the\n * tab panel below it, with the correct answer chosen by a radio on each\n * option row. Switching the selected question rebuilds that question's\n * option rows (an explicit action); within the active question, edits patch\n * in place. All edits emit canonical multi-question {@link QuizData}.\n */\nfunction createQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n ensureInterlaceStyles(container.ownerDocument);\n editorInstanceCount += 1;\n const uid = `quiz-editor-${editorInstanceCount}`;\n\n container.innerHTML = \"\";\n const root = document.createElement(\"div\");\n root.className = \"quiz-editor\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n root.style.display = \"flex\";\n root.style.flexDirection = \"column\";\n root.style.gap = `${SPACE[3]}px`;\n\n let currentData: QuizData = data;\n let currentOnChange = onChange;\n let selectedIndex = 0;\n let bodyQuestionIndex = -1;\n let optionRows: OptionRow[] = [];\n let tabButtons: HTMLButtonElement[] = [];\n /** Fields the author has blurred; errors only show for these. */\n const touched = new Set<string>();\n /** Media panels the author opened (kept open even while empty). */\n const expandedMedia = new Set<string>();\n\n const emit = (questions: QuizQuestionSpec[]): void => {\n currentOnChange({ questions });\n };\n\n /** Applies `mutate` to the active question and emits the canonical list. */\n const patchActiveQuestion = (\n mutate: (question: QuizQuestionSpec) => QuizQuestionSpec,\n ): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n const questions = currentData.questions.slice();\n questions[selectedIndex] = mutate(active);\n emit(questions);\n };\n\n /** Stable state key for the active question (or one of its options). */\n const activeKey = (optionIndex?: number): string => {\n const active = currentData.questions[selectedIndex];\n const questionKey = active?.id ?? `#${selectedIndex}`;\n if (optionIndex === undefined) return questionKey;\n return `${questionKey}/${active?.options[optionIndex]?.id ?? `#${optionIndex}`}`;\n };\n\n // --- Question tabs ---\n const questionsHeader = document.createElement(\"div\");\n questionsHeader.id = `${uid}-questions-label`;\n questionsHeader.className = \"interlace-label\";\n questionsHeader.textContent = \"Questions\";\n questionsHeader.style.fontSize = `${TYPE.sm}px`;\n questionsHeader.style.fontWeight = \"600\";\n questionsHeader.style.color = COLORS.textMuted;\n\n const tabsRow = document.createElement(\"div\");\n tabsRow.style.display = \"flex\";\n tabsRow.style.flexWrap = \"wrap\";\n tabsRow.style.alignItems = \"center\";\n tabsRow.style.gap = `${SPACE[2]}px`;\n\n const tabsBar = document.createElement(\"div\");\n tabsBar.className = \"quiz-question-tabs\";\n tabsBar.setAttribute(\"role\", \"tablist\");\n tabsBar.setAttribute(\"aria-labelledby\", questionsHeader.id);\n tabsBar.style.display = \"flex\";\n tabsBar.style.flexWrap = \"wrap\";\n tabsBar.style.gap = `${SPACE[2]}px`;\n\n const addQuestionButton = createButton(\n \"+ Add question\",\n \"secondary\",\n \"quiz-add-question\",\n );\n addQuestionButton.addEventListener(\"click\", () => {\n const id = nextQuestionId(\n currentData.questions,\n currentData.questions.length,\n );\n const questions = [...currentData.questions, emptyQuestion(id)];\n currentData = { questions };\n selectedIndex = questions.length - 1;\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n });\n tabsRow.append(tabsBar, addQuestionButton);\n root.append(questionsHeader, tabsRow);\n\n // --- Active question panel ---\n const body = document.createElement(\"div\");\n body.id = `${uid}-panel`;\n body.className = \"quiz-editor-body\";\n body.setAttribute(\"role\", \"tabpanel\");\n body.style.display = \"flex\";\n body.style.flexDirection = \"column\";\n body.style.gap = `${SPACE[4]}px`;\n body.style.padding = `${SPACE[4]}px`;\n body.style.backgroundColor = COLORS.surface;\n body.style.border = `1px solid ${COLORS.border}`;\n body.style.borderRadius = `${RADIUS.md}`;\n root.appendChild(body);\n\n // Question text: label above, remove-question action on the same line.\n const questionInput = createInput(\n \"quiz-question\",\n `${uid}-question`,\n \"Type your question\",\n );\n questionInput.style.fontSize = `${TYPE.md}px`;\n const questionError = createErrorText(\n `${uid}-question-error`,\n \"quiz-question-error\",\n );\n const refreshQuestionError = (): void => {\n const show =\n touched.has(`text:${activeKey()}`) &&\n questionInput.value.trim().length === 0;\n setFieldError(\n questionInput,\n questionError,\n show ? \"Add the question text\" : null,\n );\n };\n questionInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => ({\n ...question,\n text: questionInput.value,\n }));\n refreshQuestionError();\n });\n questionInput.addEventListener(\"blur\", () => {\n touched.add(`text:${activeKey()}`);\n refreshQuestionError();\n });\n\n const removeQuestionButton = createRemoveButton(\"quiz-question-remove\");\n removeQuestionButton.addEventListener(\"click\", () =>\n removeQuestion(selectedIndex),\n );\n\n const questionHeader = document.createElement(\"div\");\n questionHeader.style.display = \"flex\";\n questionHeader.style.alignItems = \"center\";\n questionHeader.style.justifyContent = \"space-between\";\n questionHeader.style.gap = `${SPACE[2]}px`;\n questionHeader.append(\n createLabel(\"Question\", questionInput.id),\n removeQuestionButton,\n );\n\n const questionField = document.createElement(\"div\");\n questionField.className = \"interlace-field\";\n questionField.style.display = \"flex\";\n questionField.style.flexDirection = \"column\";\n questionField.style.gap = `${SPACE[1]}px`;\n questionField.append(questionHeader, questionInput, questionError);\n\n const questionMedia = createMediaEditor({\n classPrefix: \"quiz-question-media\",\n idPrefix: `${uid}-question-media`,\n addLabel: \"Add image to question\",\n previewSlotClass: \"quiz-question-media-preview-slot\",\n previewClass: \"quiz-question-media-preview\",\n onEdit: (media) => {\n expandedMedia.add(activeKey());\n patchActiveQuestion((question) => ({ ...question, media }));\n },\n onExpand: () => expandedMedia.add(activeKey()),\n onRemove: () => {\n expandedMedia.delete(activeKey());\n patchActiveQuestion((question) => ({ ...question, media: undefined }));\n },\n });\n questionField.appendChild(questionMedia.root);\n body.appendChild(questionField);\n\n // Options: heading + hint, then one row per option with a correct radio.\n const optionsSection = document.createElement(\"div\");\n optionsSection.style.display = \"flex\";\n optionsSection.style.flexDirection = \"column\";\n optionsSection.style.gap = `${SPACE[2]}px`;\n\n const optionsHeading = document.createElement(\"div\");\n optionsHeading.id = `${uid}-options-label`;\n optionsHeading.className = \"interlace-label quiz-options-heading\";\n optionsHeading.textContent = \"Options\";\n optionsHeading.style.fontSize = `${TYPE.sm}px`;\n optionsHeading.style.fontWeight = \"600\";\n\n const optionsHint = document.createElement(\"p\");\n optionsHint.id = `${uid}-options-hint`;\n optionsHint.className = \"interlace-hint quiz-options-hint\";\n optionsHint.textContent = \"Select the correct answer.\";\n optionsHint.style.margin = \"0\";\n optionsHint.style.fontSize = `${TYPE.sm}px`;\n optionsHint.style.color = COLORS.textMuted;\n\n const optionsContainer = document.createElement(\"div\");\n optionsContainer.className = \"quiz-options\";\n optionsContainer.setAttribute(\"role\", \"radiogroup\");\n optionsContainer.setAttribute(\"aria-labelledby\", optionsHeading.id);\n optionsContainer.setAttribute(\"aria-describedby\", optionsHint.id);\n optionsContainer.style.display = \"flex\";\n optionsContainer.style.flexDirection = \"column\";\n optionsContainer.style.gap = `${SPACE[2]}px`;\n\n const addOptionButton = createButton(\n \"+ Add option\",\n \"secondary\",\n \"quiz-add-option\",\n );\n addOptionButton.style.alignSelf = \"flex-start\";\n addOptionButton.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const nextOptions: QuizOption[] = [\n ...question.options,\n {\n id: nextOptionId(question.options, question.options.length),\n text: \"\",\n },\n ];\n // Adding the first option defaults it to correct (ported behavior).\n const nextCorrectOptionId =\n question.options.length === 0\n ? nextOptions[0]!.id\n : question.correctOptionId;\n return {\n ...question,\n options: nextOptions,\n correctOptionId: nextCorrectOptionId,\n };\n });\n });\n\n optionsSection.append(\n optionsHeading,\n optionsHint,\n optionsContainer,\n addOptionButton,\n );\n body.appendChild(optionsSection);\n\n container.appendChild(root);\n\n const createOptionRow = (\n option: QuizOption,\n optionIndex: number,\n optionCount: number,\n ): OptionRow => {\n const number = optionIndex + 1;\n const idPrefix = `${uid}-q${selectedIndex}-opt${optionIndex}`;\n\n // Grid: [radio] [label / input / error + image] [remove].\n const row = document.createElement(\"div\");\n row.className = \"quiz-option-row interlace-choice\";\n row.style.display = \"grid\";\n row.style.gridTemplateColumns = \"auto minmax(0, 1fr) auto\";\n row.style.alignItems = \"center\";\n row.style.columnGap = `${SPACE[2]}px`;\n row.style.rowGap = `${SPACE[1]}px`;\n row.style.cursor = \"default\";\n // The inputs draw their own focus rings; skip the card's focus-within ring.\n row.style.outline = \"none\";\n\n const radio = document.createElement(\"input\");\n radio.type = \"radio\";\n radio.name = `${uid}-correct-${selectedIndex}`;\n radio.className = \"quiz-option-correct\";\n radio.value = option.id;\n radio.checked =\n option.id === currentData.questions[selectedIndex]?.correctOptionId;\n radio.setAttribute(\"aria-label\", `Mark option ${number} as correct`);\n radio.style.width = \"18px\";\n radio.style.height = \"18px\";\n radio.style.margin = \"0\";\n radio.style.accentColor = COLORS.accent;\n radio.style.cursor = \"pointer\";\n radio.style.gridColumn = \"1\";\n radio.style.gridRow = \"2\";\n radio.addEventListener(\"change\", () => {\n if (!radio.checked) return;\n patchActiveQuestion((question) => ({\n ...question,\n correctOptionId: question.options[optionIndex]?.id ?? null,\n }));\n });\n\n const textInput = createInput(\n \"quiz-option-text\",\n `${idPrefix}-text`,\n \"Option text\",\n );\n textInput.value = option.text;\n textInput.style.gridColumn = \"2\";\n textInput.style.gridRow = \"2\";\n const label = createLabel(`Option ${number}`, textInput.id);\n label.style.gridColumn = \"2\";\n label.style.gridRow = \"1\";\n\n const error = createErrorText(`${idPrefix}-error`, \"quiz-option-error\");\n const refreshError = (): void => {\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n textInput.value.trim().length === 0;\n setFieldError(\n textInput,\n error,\n show ? `Option ${number} needs text` : null,\n );\n };\n textInput.addEventListener(\"input\", () => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = {\n ...nextOptions[optionIndex]!,\n text: textInput.value,\n };\n return { ...question, options: nextOptions };\n });\n refreshError();\n });\n textInput.addEventListener(\"blur\", () => {\n touched.add(`opt:${activeKey(optionIndex)}`);\n refreshError();\n });\n\n const patchOptionMedia = (media: QuizMediaRef | undefined): void => {\n patchActiveQuestion((question) => {\n const nextOptions = question.options.slice();\n nextOptions[optionIndex] = { ...nextOptions[optionIndex]!, media };\n return { ...question, options: nextOptions };\n });\n };\n const media = createMediaEditor({\n classPrefix: \"quiz-option-media\",\n idPrefix: `${idPrefix}-media`,\n addLabel: `Add image to option ${number}`,\n previewSlotClass: \"quiz-option-media-preview\",\n previewClass: \"quiz-option-thumb\",\n onEdit: (next) => {\n expandedMedia.add(activeKey(optionIndex));\n patchOptionMedia(next);\n },\n onExpand: () => expandedMedia.add(activeKey(optionIndex)),\n onRemove: () => {\n expandedMedia.delete(activeKey(optionIndex));\n patchOptionMedia(undefined);\n },\n });\n\n const details = document.createElement(\"div\");\n details.style.gridColumn = \"2\";\n details.style.gridRow = \"3\";\n details.style.display = \"flex\";\n details.style.flexDirection = \"column\";\n details.style.alignItems = \"flex-start\";\n details.style.gap = `${SPACE[1]}px`;\n media.root.style.alignSelf = \"stretch\";\n details.append(error, media.root);\n\n const remove = createRemoveButton(\"quiz-option-remove\");\n remove.setAttribute(\"aria-label\", `Remove option ${number}`);\n remove.style.gridColumn = \"3\";\n remove.style.gridRow = \"2\";\n setRemoveAllowed(\n remove,\n optionCount > MIN_OPTIONS,\n `A question needs at least ${MIN_OPTIONS} options`,\n );\n remove.addEventListener(\"click\", () => {\n patchActiveQuestion((question) => {\n const removed = question.options[optionIndex];\n const nextOptions = question.options.filter(\n (_, i) => i !== optionIndex,\n );\n return {\n ...question,\n options: nextOptions,\n // Removing the correct option clears correctness; do not shift it.\n correctOptionId:\n removed && removed.id === question.correctOptionId\n ? null\n : question.correctOptionId,\n };\n });\n });\n\n row.append(label, radio, textInput, remove, details);\n optionsContainer.appendChild(row);\n return { row, radio, textInput, error, media };\n };\n\n const selectQuestion = (index: number): void => {\n selectedIndex = index;\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const removeQuestion = (index: number): void => {\n const next = currentData.questions.filter((_, i) => i !== index);\n const questions =\n next.length > 0 ? next : [emptyQuestion(nextQuestionId([], 0))];\n if (selectedIndex === index) {\n selectedIndex = 0; // removing the selected question selects the first remaining\n } else if (index < selectedIndex) {\n selectedIndex -= 1;\n }\n currentData = { questions };\n emit(questions);\n bodyQuestionIndex = -1;\n renderTabs();\n syncActiveBody();\n };\n\n const renderTabs = (): void => {\n tabsBar.innerHTML = \"\";\n const count = currentData.questions.length;\n tabButtons = currentData.questions.map((_, index) => {\n const selected = index === selectedIndex;\n const tab = createButton(\n `Question ${index + 1}`,\n selected ? \"primary\" : \"secondary\",\n \"quiz-question-tab\",\n );\n tab.id = `${uid}-tab-${index}`;\n tab.setAttribute(\"role\", \"tab\");\n tab.setAttribute(\"aria-selected\", String(selected));\n tab.setAttribute(\"aria-controls\", body.id);\n tab.tabIndex = selected ? 0 : -1;\n tab.addEventListener(\"click\", () => selectQuestion(index));\n tab.addEventListener(\"keydown\", (event) => {\n let target = -1;\n if (event.key === \"ArrowRight\") target = (index + 1) % count;\n else if (event.key === \"ArrowLeft\")\n target = (index - 1 + count) % count;\n else if (event.key === \"Home\") target = 0;\n else if (event.key === \"End\") target = count - 1;\n if (target < 0) return;\n event.preventDefault();\n selectQuestion(target);\n tabButtons[target]?.focus();\n });\n tabsBar.appendChild(tab);\n return tab;\n });\n\n body.setAttribute(\"aria-labelledby\", `${uid}-tab-${selectedIndex}`);\n removeQuestionButton.setAttribute(\n \"aria-label\",\n `Remove question ${selectedIndex + 1}`,\n );\n setRemoveAllowed(\n removeQuestionButton,\n count > 1,\n \"A quiz needs at least one question\",\n );\n };\n\n const syncActiveBody = (): void => {\n const active = currentData.questions[selectedIndex];\n if (!active) return;\n\n setValue(questionInput, active.text);\n questionMedia.sync(\n active.media,\n !!active.media || expandedMedia.has(activeKey()),\n );\n refreshQuestionError();\n\n const options = active.options;\n if (\n bodyQuestionIndex !== selectedIndex ||\n optionRows.length !== options.length\n ) {\n // Question switch or option count change: rebuild the active question's rows.\n optionsContainer.innerHTML = \"\";\n optionRows = options.map((option, optionIndex) =>\n createOptionRow(option, optionIndex, options.length),\n );\n bodyQuestionIndex = selectedIndex;\n }\n // Patch values in place, preserving input focus.\n optionRows.forEach((row, optionIndex) => {\n const option = options[optionIndex]!;\n setValue(row.textInput, option.text);\n row.radio.value = option.id;\n row.radio.checked = option.id === active.correctOptionId;\n row.media.sync(\n option.media,\n !!option.media || expandedMedia.has(activeKey(optionIndex)),\n );\n const show =\n touched.has(`opt:${activeKey(optionIndex)}`) &&\n option.text.trim().length === 0;\n setFieldError(\n row.textInput,\n row.error,\n show ? `Option ${optionIndex + 1} needs text` : null,\n );\n });\n };\n\n const syncTo = (\n nextData: QuizData,\n nextOnChange: (next: QuizData) => void,\n ): void => {\n currentData = nextData;\n currentOnChange = nextOnChange;\n if (currentData.questions.length === 0) {\n currentData = { questions: [emptyQuestion(\"q-0\")] };\n }\n if (selectedIndex >= currentData.questions.length) {\n selectedIndex = 0;\n }\n renderTabs();\n syncActiveBody();\n };\n\n renderTabs();\n syncActiveBody();\n\n return { syncTo };\n}\n\nfunction getOrCreateQuizEditorController(\n container: HTMLElement,\n data: QuizData,\n onChange: (next: QuizData) => void,\n): QuizEditorController {\n let controller = quizEditorControllers.get(container);\n if (!controller) {\n controller = createQuizEditorController(container, data, onChange);\n quizEditorControllers.set(container, controller);\n }\n return controller;\n}\n\n/** Tears down the editor controller mounted in `container`, if any. */\nexport function unmountQuizEditor(container: HTMLElement): void {\n quizEditorControllers.delete(container);\n container.innerHTML = \"\";\n}\n\n/**\n * Built-in Quiz editor content type. Authors the canonical multi-question\n * {@link QuizData} shape with rich media (the single supported format).\n * Registered id is `quiz-editor`, matching the player's built-in quiz\n * content type.\n */\nexport const QuizEditorType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n getOrCreateQuizEditorController(container, data, onChange).syncTo(\n data,\n onChange,\n );\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n","/**\n * Interlace design tokens, re-exported from `@interlacejs/core` so every\n * package shares one themeable set (CSS custom properties with defaults).\n */\nexport {\n COLORS,\n CONTROL_HEIGHT,\n FOCUS_RING,\n FONTS,\n RADIUS,\n SHADOWS,\n SPACE,\n TYPE,\n} from \"@interlacejs/core\";\n","import type { QuizData, QuizOption } from \"./schema\";\nimport { COLORS, FONTS, RADIUS, SPACE, TYPE } from \"./tokens\";\n\nexport interface QuizPlaybackCallbacks {\n onComplete(score?: number): void;\n}\n\ninterface QuizPlaybackSession {\n destroy: () => void;\n}\n\ninterface OptionEntry {\n button: HTMLButtonElement;\n option: QuizOption;\n statusGlyph: HTMLSpanElement;\n statusLabel: HTMLSpanElement;\n}\n\n/**\n * Per-container playback sessions, so `unmountQuizPlayback` can tear down\n * the listeners built by `renderQuizPlayback`.\n */\nconst quizPlaybackSessions = new WeakMap<HTMLElement, QuizPlaybackSession>();\n\n/** Creates a playback media `<img>`, or `null` when src is blank. */\nfunction createMediaImage(\n className: string,\n src: string,\n alt: string | undefined,\n): HTMLImageElement | null {\n if (src.length === 0) return null;\n const img = document.createElement(\"img\");\n img.className = className;\n img.src = src;\n img.style.maxWidth = \"100%\";\n img.style.height = \"auto\";\n img.style.borderRadius = `${RADIUS.sm}`;\n img.style.marginBottom = `${SPACE[2]}px`;\n if (alt) img.alt = alt;\n return img;\n}\n\n/** Locks an option button so it can no longer be clicked. */\nfunction lockOption(button: HTMLButtonElement): void {\n button.disabled = true;\n button.style.cursor = \"default\";\n}\n\n/** Reveals the correct-answer state on an option button. */\nfunction revealCorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-correct\");\n button.style.backgroundColor = COLORS.correctBg;\n button.style.borderColor = COLORS.correctBg;\n button.style.color = COLORS.correctText;\n glyph.textContent = \"✓\";\n label.textContent = \"Correct\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/** Reveals the wrong-answer state on the selected option button. */\nfunction revealIncorrect(\n button: HTMLButtonElement,\n glyph: HTMLSpanElement,\n label: HTMLSpanElement,\n): void {\n button.classList.add(\"quiz-playback-option-incorrect\");\n button.style.backgroundColor = COLORS.incorrectBg;\n button.style.borderColor = COLORS.incorrectBorder;\n button.style.color = COLORS.incorrectText;\n glyph.textContent = \"✕\";\n label.textContent = \"Incorrect\";\n glyph.style.opacity = \"1\";\n label.style.opacity = \"1\";\n}\n\n/**\n * Renders a multi-question quiz into `container`: one question at a time\n * with a \"Question i of n\" indicator, per-question media and option buttons,\n * and an explicit navigation footer. Answering a question reveals\n * correctness and locks its options; the user then advances with **Next**.\n * On the final question, clicking **Next** reports the per-question\n * correct count (`onComplete(correctCount)`, one point per question) ONCE,\n * as the click handler's final statement. **Previous** returns to an\n * answered question in its locked, review-only state. The document is the\n * canonical single-format {@link QuizData} shape.\n */\nexport function renderQuizPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: QuizPlaybackCallbacks,\n): void {\n // Destroy any session already mounted in this container: the overlay\n // lifecycle may re-render without an intervening unmount, and overwriting\n // the WeakMap entry would leak the first root (and its click listeners).\n unmountQuizPlayback(container);\n\n const total = data.questions.length;\n // Per-question recorded selections; back-navigation and the final\n // aggregate both read from here, and reveal locks make it stable.\n const answers: (string | null)[] = data.questions.map(() => null);\n let currentIndex = 0;\n let completed = false;\n\n const root = document.createElement(\"div\");\n root.className = \"quiz-playback\";\n root.style.fontFamily = FONTS.body;\n root.style.color = COLORS.text;\n root.style.lineHeight = \"1.5\";\n\n const indicator = document.createElement(\"div\");\n indicator.className = \"quiz-playback-indicator\";\n indicator.style.fontSize = `${TYPE.xs}px`;\n indicator.style.fontWeight = \"600\";\n indicator.style.color = COLORS.textMuted;\n indicator.style.marginBottom = `${SPACE[2]}px`;\n indicator.style.textTransform = \"uppercase\";\n indicator.style.letterSpacing = \"0.06em\";\n root.appendChild(indicator);\n\n const question = document.createElement(\"p\");\n question.className = \"quiz-playback-question\";\n question.style.margin = `0 0 ${SPACE[2]}px 0`;\n question.style.fontFamily = FONTS.display;\n question.style.fontSize = `${TYPE.lg}px`;\n question.style.fontWeight = \"600\";\n root.appendChild(question);\n\n const questionMediaSlot = document.createElement(\"div\");\n root.appendChild(questionMediaSlot);\n\n const optionsBox = document.createElement(\"div\");\n optionsBox.className = \"quiz-playback-options\";\n optionsBox.style.display = \"flex\";\n optionsBox.style.flexDirection = \"column\";\n optionsBox.style.gap = `${SPACE[2]}px`;\n root.appendChild(optionsBox);\n\n // Navigation footer: Previous (review-only back) and Next. The final\n // question uses the same Next label; clicking it aggregates the score\n // and fires onComplete once.\n const navFooter = document.createElement(\"div\");\n navFooter.className = \"quiz-playback-nav\";\n navFooter.style.display = \"flex\";\n navFooter.style.justifyContent = \"flex-end\";\n navFooter.style.gap = `${SPACE[2]}px`;\n navFooter.style.marginTop = `${SPACE[4]}px`;\n root.appendChild(navFooter);\n\n const prevButton = document.createElement(\"button\");\n prevButton.type = \"button\";\n prevButton.className = \"quiz-playback-prev\";\n prevButton.textContent = \"Previous\";\n prevButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n prevButton.style.backgroundColor = COLORS.surface;\n prevButton.style.border = `1px solid ${COLORS.borderStrong}`;\n prevButton.style.borderRadius = `${RADIUS.md}`;\n prevButton.style.color = COLORS.text;\n prevButton.style.cursor = \"pointer\";\n prevButton.style.fontSize = `${TYPE.base}px`;\n prevButton.style.fontWeight = \"600\";\n prevButton.style.transition = \"background-color 150ms ease\";\n prevButton.addEventListener(\"click\", () => {\n if (currentIndex > 0) {\n renderQuestion(currentIndex - 1);\n }\n });\n navFooter.appendChild(prevButton);\n\n const nextButton = document.createElement(\"button\");\n nextButton.type = \"button\";\n nextButton.className = \"quiz-playback-next\";\n nextButton.textContent = \"Next\";\n nextButton.disabled = true;\n nextButton.style.padding = `${SPACE[2]}px ${SPACE[4]}px`;\n nextButton.style.backgroundColor = COLORS.accent;\n nextButton.style.border = \"none\";\n nextButton.style.borderRadius = `${RADIUS.md}`;\n nextButton.style.color = COLORS.accentContrast;\n nextButton.style.cursor = \"pointer\";\n nextButton.style.fontSize = `${TYPE.base}px`;\n nextButton.style.fontWeight = \"600\";\n nextButton.style.transition =\n \"background-color 150ms ease, opacity 150ms ease\";\n nextButton.addEventListener(\"click\", () => {\n if (completed) return;\n if (currentIndex < total - 1) {\n renderQuestion(currentIndex + 1);\n } else {\n // Final question: aggregate the per-question answers.\n completed = true;\n const correctCount = data.questions.reduce(\n (count, questionSpec, questionIndex) =>\n count +\n (answers[questionIndex] !== null &&\n answers[questionIndex] === questionSpec.correctOptionId\n ? 1\n : 0),\n 0,\n );\n nextButton.disabled = true;\n nextButton.style.opacity = \"0.55\";\n callbacks.onComplete(correctCount);\n }\n });\n navFooter.appendChild(nextButton);\n\n container.appendChild(root);\n\n let optionEntries: OptionEntry[] = [];\n\n const syncFooter = (index: number): void => {\n prevButton.style.display = index > 0 ? \"block\" : \"none\";\n nextButton.textContent = \"Next\";\n const answered = answers[index] !== null;\n nextButton.disabled = completed || !answered;\n nextButton.style.opacity = nextButton.disabled ? \"0.55\" : \"1\";\n };\n\n const createOptionButton = (\n option: QuizOption,\n isReview: boolean,\n ): OptionEntry => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"quiz-playback-option\";\n button.style.display = \"flex\";\n button.style.alignItems = \"center\";\n button.style.gap = `${SPACE[2]}px`;\n button.style.width = \"100%\";\n button.style.padding = `${SPACE[3]}px ${SPACE[4]}px`;\n button.style.backgroundColor = COLORS.surface;\n button.style.border = `1px solid ${COLORS.borderStrong}`;\n button.style.borderRadius = `${RADIUS.md}`;\n button.style.cursor = \"pointer\";\n button.style.fontSize = `${TYPE.base}px`;\n button.style.color = COLORS.text;\n button.style.textAlign = \"left\";\n button.style.transition =\n \"background-color 150ms ease, border-color 150ms ease, color 150ms ease\";\n\n const text = document.createElement(\"span\");\n text.className = \"quiz-playback-option-text\";\n text.textContent = option.text;\n text.style.flex = \"1\";\n button.appendChild(text);\n\n const thumbnail = createMediaImage(\n \"quiz-playback-option-media\",\n option.media?.src ?? \"\",\n option.media?.alt,\n );\n if (thumbnail) button.appendChild(thumbnail);\n\n const status = document.createElement(\"span\");\n status.style.display = \"flex\";\n status.style.alignItems = \"center\";\n status.style.gap = `${SPACE[1]}px`;\n status.style.marginLeft = \"auto\";\n status.style.transition = \"opacity 150ms ease\";\n\n const glyph = document.createElement(\"span\");\n glyph.style.fontWeight = \"700\";\n glyph.style.fontSize = `${TYPE.md}px`;\n glyph.style.lineHeight = \"1\";\n status.appendChild(glyph);\n\n const label = document.createElement(\"span\");\n label.style.fontWeight = \"600\";\n label.style.fontSize = `${TYPE.sm}px`;\n label.style.letterSpacing = \"0.04em\";\n status.appendChild(label);\n\n button.appendChild(status);\n\n if (isReview) {\n lockOption(button);\n }\n\n return { button, option, statusGlyph: glyph, statusLabel: label };\n };\n\n const revealQuestion = (\n questionIndex: number,\n selectedOptionId: string,\n ): void => {\n const spec = data.questions[questionIndex]!;\n const correctOptionId = spec.correctOptionId;\n\n optionEntries.forEach((entry) => {\n lockOption(entry.button);\n if (entry.option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (\n entry.option.id === selectedOptionId &&\n selectedOptionId !== correctOptionId\n ) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n });\n };\n\n const renderQuestion = (index: number): void => {\n currentIndex = index;\n const spec = data.questions[index]!;\n const correctOptionId = spec.correctOptionId;\n const answered = answers[index] ?? null;\n\n indicator.textContent = `Question ${index + 1} of ${total}`;\n question.textContent = spec.text;\n questionMediaSlot.innerHTML = \"\";\n const questionMedia = createMediaImage(\n \"quiz-playback-question-media\",\n spec.media?.src ?? \"\",\n spec.media?.alt,\n );\n if (questionMedia) questionMediaSlot.appendChild(questionMedia);\n\n optionsBox.innerHTML = \"\";\n optionEntries = spec.options.map((option) => {\n const isReview = answered !== null;\n const entry = createOptionButton(option, isReview);\n\n if (isReview) {\n if (option.id === correctOptionId) {\n revealCorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n if (option.id === answered && answered !== correctOptionId) {\n revealIncorrect(entry.button, entry.statusGlyph, entry.statusLabel);\n }\n } else {\n entry.button.addEventListener(\"click\", () => {\n if (completed) return;\n answers[index] = option.id;\n // Reveal correctness and lock this question's options. No\n // auto-advance and no auto-complete: the footer gates progress.\n revealQuestion(index, option.id);\n syncFooter(index);\n });\n }\n\n optionsBox.appendChild(entry.button);\n return entry;\n });\n\n syncFooter(index);\n };\n\n renderQuestion(0);\n\n quizPlaybackSessions.set(container, {\n destroy: () => {\n root.remove();\n },\n });\n}\n\n/** Cleans up the playback session mounted in `container`, if any. */\nexport function unmountQuizPlayback(container: HTMLElement): void {\n quizPlaybackSessions.get(container)?.destroy();\n quizPlaybackSessions.delete(container);\n}\n","import type { QuizData } from \"./schema\";\n\n/**\n * Validates canonical quiz data, returning human-readable error strings\n * indexed per question. An empty array means the document is valid.\n *\n * The legacy flat input format was removed; only the canonical\n * multi-question `QuizData` shape is accepted.\n */\nexport function validateQuizData(data: QuizData): string[] {\n const errors: string[] = [];\n\n if (data.questions.length === 0) {\n errors.push(\"at least one question is required\");\n return errors;\n }\n\n data.questions.forEach((question, index) => {\n if (question.text.trim().length === 0) {\n errors.push(`questions[${index}].text must be a non-empty string`);\n }\n\n if (question.options.length === 0) {\n errors.push(`questions[${index}].at least one option is required`);\n } else {\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n errors.push(\n `questions[${index}].options[${optionIndex}].text must be a non-empty string`,\n );\n }\n });\n }\n\n if (question.correctOptionId === null) {\n errors.push(\n `questions[${index}].exactly one correct option must be resolvable`,\n );\n }\n });\n\n return errors;\n}\n/**\n * Author-facing readiness check for quiz data, used by the content type's\n * `validate`. Returns friendly messages (e.g. \"Question 1 needs text\"); an\n * empty array means the quiz is ready to save.\n */\nexport function getQuizAuthoringIssues(data: QuizData): string[] {\n if (data.questions.length === 0) return [\"Add at least one question\"];\n\n const issues: string[] = [];\n data.questions.forEach((question, index) => {\n const label = `Question ${index + 1}`;\n if (question.text.trim().length === 0) {\n issues.push(`${label} needs text`);\n }\n if (question.options.length < 2) {\n issues.push(`${label} needs at least 2 options`);\n }\n question.options.forEach((option, optionIndex) => {\n if (option.text.trim().length === 0) {\n issues.push(`${label}, option ${optionIndex + 1} needs text`);\n }\n });\n const hasCorrect = question.options.some(\n (option) => option.id === question.correctOptionId,\n );\n if (!hasCorrect) issues.push(`${label} needs a correct answer`);\n });\n return issues;\n}\n","import { ContentType } from \"@interlacejs/core\";\nimport { QuizEditorType, unmountQuizEditor } from \"./quiz-editor\";\nimport { renderQuizPlayback, unmountQuizPlayback } from \"./quiz-player\";\nimport type { QuizData } from \"./schema\";\nimport { getQuizAuthoringIssues } from \"./validate\";\n\n/**\n * Built-in Quiz content type for Interlace. Authors the canonical\n * {@link QuizData} shape with rich media and plays it back with immediate\n * scoring. Registered id is `quiz-editor` — the id the editor's built-in\n * quiz type authors with — so authored documents resolve without extra\n * registry wiring.\n */\nexport const QuizContentType: ContentType<QuizData> = {\n getId: () => \"quiz-editor\",\n getVersion: () => 1,\n getDisplayName: () => \"Quiz\",\n getDescription: () => \"Multiple-choice questions that check understanding\",\n\n validate(data: QuizData): string[] {\n return getQuizAuthoringIssues(data);\n },\n\n getMaximumScore(data): number | undefined {\n return data.questions.length;\n },\n\n async preload(): Promise<void> {\n // No preload needed for quiz content.\n },\n\n renderEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.renderEditor(container, data, onChange);\n },\n\n updateEditor(\n container: HTMLElement,\n data: QuizData,\n onChange: (newData: QuizData) => void,\n ): void {\n QuizEditorType.updateEditor?.(container, data, onChange);\n },\n\n renderPlayback(\n container: HTMLElement,\n data: QuizData,\n callbacks: { onComplete(score?: number): void },\n ): void {\n renderQuizPlayback(container, data, callbacks);\n },\n\n unmountPlayback(container: HTMLElement): void {\n unmountQuizPlayback(container);\n },\n\n unmount(container: HTMLElement): void {\n unmountQuizEditor(container);\n },\n};\n"],"mappings":";AAAA,SAAsB,6BAA6B;;;ACInD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACSP,IAAM,uBAAuB,oBAAI,QAA0C;AAG3E,SAAS,iBACP,WACA,KACA,KACyB;AACzB,MAAI,IAAI,WAAW,EAAG,QAAO;AAC7B,QAAM,MAAM,SAAS,cAAc,KAAK;AACxC,MAAI,YAAY;AAChB,MAAI,MAAM;AACV,MAAI,MAAM,WAAW;AACrB,MAAI,MAAM,SAAS;AACnB,MAAI,MAAM,eAAe,GAAG,OAAO,EAAE;AACrC,MAAI,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC;AACpC,MAAI,IAAK,KAAI,MAAM;AACnB,SAAO;AACT;AAGA,SAAS,WAAW,QAAiC;AACnD,SAAO,WAAW;AAClB,SAAO,MAAM,SAAS;AACxB;AAGA,SAAS,cACP,QACA,OACA,OACM;AACN,SAAO,UAAU,IAAI,8BAA8B;AACnD,SAAO,MAAM,kBAAkB,OAAO;AACtC,SAAO,MAAM,cAAc,OAAO;AAClC,SAAO,MAAM,QAAQ,OAAO;AAC5B,QAAM,cAAc;AACpB,QAAM,cAAc;AACpB,QAAM,MAAM,UAAU;AACtB,QAAM,MAAM,UAAU;AACxB;AAGA,SAAS,gBACP,QACA,OACA,OACM;AACN,SAAO,UAAU,IAAI,gCAAgC;AACrD,SAAO,MAAM,kBAAkB,OAAO;AACtC,SAAO,MAAM,cAAc,OAAO;AAClC,SAAO,MAAM,QAAQ,OAAO;AAC5B,QAAM,cAAc;AACpB,QAAM,cAAc;AACpB,QAAM,MAAM,UAAU;AACtB,QAAM,MAAM,UAAU;AACxB;AAaO,SAAS,mBACd,WACA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ACF;AAAA,EACF;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;;;AIv7BO,IAAM,kBAAyC;AAAA,EACpD,OAAO,MAAM;AAAA,EACb,YAAY,MAAM;AAAA,EAClB,gBAAgB,MAAM;AAAA,EACtB,gBAAgB,MAAM;AAAA,EAEtB,SAAS,MAA0B;AACjC,WAAO,uBAAuB,IAAI;AAAA,EACpC;AAAA,EAEA,gBAAgB,MAA0B;AACxC,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEA,MAAM,UAAyB;AAAA,EAE/B;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,aAAa,WAAW,MAAM,QAAQ;AAAA,EACvD;AAAA,EAEA,aACE,WACA,MACA,UACM;AACN,mBAAe,eAAe,WAAW,MAAM,QAAQ;AAAA,EACzD;AAAA,EAEA,eACE,WACA,MACA,WACM;AACN,uBAAmB,WAAW,MAAM,SAAS;AAAA,EAC/C;AAAA,EAEA,gBAAgB,WAA8B;AAC5C,wBAAoB,SAAS;AAAA,EAC/B;AAAA,EAEA,QAAQ,WAA8B;AACpC,sBAAkB,SAAS;AAAA,EAC7B;AACF;","names":["media"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interlacejs/quiz",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Interlace quiz content type: data schema, validation, and playback contract.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",