@intellectif/lk-react 19.0.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +31 -2
- package/dist/{WrittenResponse-DT_Yqbq1.d.cts → WrittenResponse-BVPmrmQL.d.cts} +8 -2
- package/dist/{WrittenResponse-CeHY5u3W.d.ts → WrittenResponse-IAJvvL-g.d.ts} +8 -2
- package/dist/ai/LkAiProvider.cjs +3 -3
- package/dist/ai/LkAiProvider.d.cts +5 -3
- package/dist/ai/LkAiProvider.d.ts +5 -3
- package/dist/ai/LkAiProvider.js +1 -1
- package/dist/ai/useAiHelp.cjs +5 -5
- package/dist/ai/useAiHelp.d.cts +8 -2
- package/dist/ai/useAiHelp.d.ts +8 -2
- package/dist/ai/useAiHelp.js +3 -3
- package/dist/{chunk-7NNMDZUU.js → chunk-5MO7ACSB.js} +10 -10
- package/dist/{chunk-7NNMDZUU.js.map → chunk-5MO7ACSB.js.map} +1 -1
- package/dist/{chunk-7K4B2EMU.js → chunk-5Q2KFIZQ.js} +4 -4
- package/dist/{chunk-7K4B2EMU.js.map → chunk-5Q2KFIZQ.js.map} +1 -1
- package/dist/{chunk-APZ6JFN6.cjs → chunk-6SNNMVBV.cjs} +5 -5
- package/dist/{chunk-APZ6JFN6.cjs.map → chunk-6SNNMVBV.cjs.map} +1 -1
- package/dist/{chunk-L7WY5YFQ.cjs → chunk-7JBXDQTD.cjs} +5 -5
- package/dist/{chunk-L7WY5YFQ.cjs.map → chunk-7JBXDQTD.cjs.map} +1 -1
- package/dist/{chunk-UXV3V5NH.js → chunk-AY3WN4FB.js} +27 -15
- package/dist/chunk-AY3WN4FB.js.map +1 -0
- package/dist/{chunk-XAIJNGTU.cjs → chunk-CB2A56Q7.cjs} +137 -51
- package/dist/chunk-CB2A56Q7.cjs.map +1 -0
- package/dist/chunk-CQ37UD4T.cjs +251 -0
- package/dist/chunk-CQ37UD4T.cjs.map +1 -0
- package/dist/{chunk-YRNEOBXA.js → chunk-EYLBSS4Y.js} +11 -2
- package/dist/chunk-EYLBSS4Y.js.map +1 -0
- package/dist/{chunk-AHGB5HH6.cjs → chunk-GHKMX5UT.cjs} +11 -2
- package/dist/chunk-GHKMX5UT.cjs.map +1 -0
- package/dist/chunk-GND3OBVE.js +241 -0
- package/dist/chunk-GND3OBVE.js.map +1 -0
- package/dist/{chunk-WKA6FUR4.cjs → chunk-GPGCBDBN.cjs} +66 -26
- package/dist/chunk-GPGCBDBN.cjs.map +1 -0
- package/dist/{chunk-55W2472T.cjs → chunk-GW3YIPDE.cjs} +18 -18
- package/dist/{chunk-55W2472T.cjs.map → chunk-GW3YIPDE.cjs.map} +1 -1
- package/dist/{chunk-JVWLXVYG.cjs → chunk-J2QIHZ3H.cjs} +2 -2
- package/dist/chunk-J2QIHZ3H.cjs.map +1 -0
- package/dist/{chunk-SEQTGOOU.js → chunk-KRM6DX47.js} +151 -50
- package/dist/chunk-KRM6DX47.js.map +1 -0
- package/dist/{chunk-2X2NZF46.cjs → chunk-LHFC2BCM.cjs} +104 -27
- package/dist/chunk-LHFC2BCM.cjs.map +1 -0
- package/dist/{chunk-G7AGM2Y7.js → chunk-M3K6BF5M.js} +4 -4
- package/dist/{chunk-G7AGM2Y7.js.map → chunk-M3K6BF5M.js.map} +1 -1
- package/dist/chunk-M4UJBLVR.cjs +55 -0
- package/dist/chunk-M4UJBLVR.cjs.map +1 -0
- package/dist/{chunk-YNDKAYW3.js → chunk-MCTNLUKO.js} +2 -2
- package/dist/{chunk-YNDKAYW3.js.map → chunk-MCTNLUKO.js.map} +1 -1
- package/dist/{chunk-ZDYNAWDZ.cjs → chunk-MPHX3Y42.cjs} +2 -2
- package/dist/{chunk-ZDYNAWDZ.cjs.map → chunk-MPHX3Y42.cjs.map} +1 -1
- package/dist/{chunk-YIYMBCPV.js → chunk-NDIKHMLJ.js} +19 -10
- package/dist/chunk-NDIKHMLJ.js.map +1 -0
- package/dist/{chunk-LX2X4KC7.cjs → chunk-NILHU555.cjs} +7 -7
- package/dist/{chunk-LX2X4KC7.cjs.map → chunk-NILHU555.cjs.map} +1 -1
- package/dist/{chunk-ZME5FMED.cjs → chunk-OKEN6NJL.cjs} +157 -54
- package/dist/chunk-OKEN6NJL.cjs.map +1 -0
- package/dist/chunk-PJMXHDY5.js +51 -0
- package/dist/chunk-PJMXHDY5.js.map +1 -0
- package/dist/{chunk-OWV7VRMQ.js → chunk-U2BX2RWY.js} +93 -16
- package/dist/chunk-U2BX2RWY.js.map +1 -0
- package/dist/{chunk-TEAVPUMX.js → chunk-U4KTOH7C.js} +2 -2
- package/dist/chunk-U4KTOH7C.js.map +1 -0
- package/dist/{chunk-FEOFX4QW.js → chunk-U6SEII5V.js} +3 -3
- package/dist/{chunk-FEOFX4QW.js.map → chunk-U6SEII5V.js.map} +1 -1
- package/dist/{chunk-XUQ4KRTT.cjs → chunk-W2P5RILE.cjs} +156 -55
- package/dist/chunk-W2P5RILE.cjs.map +1 -0
- package/dist/{chunk-XHF376ES.js → chunk-W6TWQY6S.js} +152 -49
- package/dist/chunk-W6TWQY6S.js.map +1 -0
- package/dist/{chunk-NGFTSRKO.cjs → chunk-WGHMWBEJ.cjs} +126 -48
- package/dist/chunk-WGHMWBEJ.cjs.map +1 -0
- package/dist/{chunk-5QCZZBOX.js → chunk-WNDNQ6NR.js} +120 -42
- package/dist/chunk-WNDNQ6NR.js.map +1 -0
- package/dist/{chunk-NZM3M5IR.cjs → chunk-WXESKL75.cjs} +47 -35
- package/dist/chunk-WXESKL75.cjs.map +1 -0
- package/dist/{chunk-BY4UQH2Y.js → chunk-X4YWXZ4J.js} +3 -3
- package/dist/{chunk-BY4UQH2Y.js.map → chunk-X4YWXZ4J.js.map} +1 -1
- package/dist/{chunk-KOFA54C7.js → chunk-XB2AHEU5.js} +55 -15
- package/dist/chunk-XB2AHEU5.js.map +1 -0
- package/dist/{chunk-NLTU5JFD.js → chunk-XM5Q2ZCH.js} +132 -46
- package/dist/chunk-XM5Q2ZCH.js.map +1 -0
- package/dist/{chunk-CQNKZ435.cjs → chunk-XZCMUDFP.cjs} +14 -12
- package/dist/chunk-XZCMUDFP.cjs.map +1 -0
- package/dist/{chunk-SXU26SFO.cjs → chunk-Y4IDF5UO.cjs} +20 -11
- package/dist/chunk-Y4IDF5UO.cjs.map +1 -0
- package/dist/{chunk-3FBBP5QR.cjs → chunk-YWJ5XJDU.cjs} +6 -6
- package/dist/{chunk-3FBBP5QR.cjs.map → chunk-YWJ5XJDU.cjs.map} +1 -1
- package/dist/{chunk-4NERCBOW.js → chunk-ZDDBWUUA.js} +10 -8
- package/dist/chunk-ZDDBWUUA.js.map +1 -0
- package/dist/components/ActivityPreview.cjs +17 -17
- package/dist/components/ActivityPreview.d.cts +2 -2
- package/dist/components/ActivityPreview.d.ts +2 -2
- package/dist/components/ActivityPreview.js +16 -16
- package/dist/components/ActivitySequence.cjs +18 -18
- package/dist/components/ActivitySequence.d.cts +34 -4
- package/dist/components/ActivitySequence.d.ts +34 -4
- package/dist/components/ActivitySequence.js +17 -17
- package/dist/components/Dictation.cjs +10 -10
- package/dist/components/Dictation.d.cts +1 -1
- package/dist/components/Dictation.d.ts +1 -1
- package/dist/components/Dictation.js +9 -9
- package/dist/components/FillInTheBlanks.cjs +10 -10
- package/dist/components/FillInTheBlanks.d.cts +1 -1
- package/dist/components/FillInTheBlanks.d.ts +1 -1
- package/dist/components/FillInTheBlanks.js +9 -9
- package/dist/components/GapSelect.cjs +10 -10
- package/dist/components/GapSelect.d.cts +1 -1
- package/dist/components/GapSelect.d.ts +1 -1
- package/dist/components/GapSelect.js +9 -9
- package/dist/components/InteractiveVideo.cjs +17 -17
- package/dist/components/InteractiveVideo.d.cts +32 -3
- package/dist/components/InteractiveVideo.d.ts +32 -3
- package/dist/components/InteractiveVideo.js +15 -15
- package/dist/components/MultipleChoice.cjs +10 -10
- package/dist/components/MultipleChoice.d.cts +1 -1
- package/dist/components/MultipleChoice.d.ts +1 -1
- package/dist/components/MultipleChoice.js +9 -9
- package/dist/components/PronunciationFeedback.cjs +4 -4
- package/dist/components/PronunciationFeedback.d.cts +1 -1
- package/dist/components/PronunciationFeedback.d.ts +1 -1
- package/dist/components/PronunciationFeedback.js +3 -3
- package/dist/components/ReadAloud.cjs +8 -8
- package/dist/components/ReadAloud.d.cts +2 -2
- package/dist/components/ReadAloud.d.ts +2 -2
- package/dist/components/ReadAloud.js +7 -7
- package/dist/components/StimulusPanel.cjs +4 -4
- package/dist/components/StimulusPanel.d.cts +1 -1
- package/dist/components/StimulusPanel.d.ts +1 -1
- package/dist/components/StimulusPanel.js +3 -3
- package/dist/components/WrittenResponse.cjs +7 -6
- package/dist/components/WrittenResponse.d.cts +3 -3
- package/dist/components/WrittenResponse.d.ts +3 -3
- package/dist/components/WrittenResponse.js +6 -5
- package/dist/i18n/LkIntlProvider.cjs +7 -7
- package/dist/i18n/LkIntlProvider.d.cts +2 -2
- package/dist/i18n/LkIntlProvider.d.ts +2 -2
- package/dist/i18n/LkIntlProvider.js +1 -1
- package/dist/index.cjs +41 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/theme/skin.css +55 -0
- package/dist/{types-BY-4S5Rd.d.ts → types-7lGlo0zE.d.ts} +56 -1
- package/dist/{types-DtPYG1hh.d.cts → types-Botf4Wqj.d.cts} +56 -1
- package/package.json +3 -3
- package/dist/chunk-2X2NZF46.cjs.map +0 -1
- package/dist/chunk-4NERCBOW.js.map +0 -1
- package/dist/chunk-5QCZZBOX.js.map +0 -1
- package/dist/chunk-AHGB5HH6.cjs.map +0 -1
- package/dist/chunk-BRPEB43C.cjs +0 -13
- package/dist/chunk-BRPEB43C.cjs.map +0 -1
- package/dist/chunk-CQNKZ435.cjs.map +0 -1
- package/dist/chunk-JVWLXVYG.cjs.map +0 -1
- package/dist/chunk-KGDGYRBL.cjs +0 -117
- package/dist/chunk-KGDGYRBL.cjs.map +0 -1
- package/dist/chunk-KOFA54C7.js.map +0 -1
- package/dist/chunk-NGFTSRKO.cjs.map +0 -1
- package/dist/chunk-NLTU5JFD.js.map +0 -1
- package/dist/chunk-NZM3M5IR.cjs.map +0 -1
- package/dist/chunk-OWV7VRMQ.js.map +0 -1
- package/dist/chunk-QRT2W5N5.js +0 -114
- package/dist/chunk-QRT2W5N5.js.map +0 -1
- package/dist/chunk-RCMYEWBE.js +0 -11
- package/dist/chunk-RCMYEWBE.js.map +0 -1
- package/dist/chunk-SEQTGOOU.js.map +0 -1
- package/dist/chunk-SXU26SFO.cjs.map +0 -1
- package/dist/chunk-TEAVPUMX.js.map +0 -1
- package/dist/chunk-UXV3V5NH.js.map +0 -1
- package/dist/chunk-WKA6FUR4.cjs.map +0 -1
- package/dist/chunk-XAIJNGTU.cjs.map +0 -1
- package/dist/chunk-XHF376ES.js.map +0 -1
- package/dist/chunk-XUQ4KRTT.cjs.map +0 -1
- package/dist/chunk-YIYMBCPV.js.map +0 -1
- package/dist/chunk-YRNEOBXA.js.map +0 -1
- package/dist/chunk-ZME5FMED.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/ActivitySequence/ActivitySequence.tsx"],"names":["next"],"mappings":";;;;;;;;;;;;;;AA+dA,SAAS,SAAA,CAAU,QAAgB,IAAA,EAAgD;AACjF,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,MAAM,CAAA,CAAA,EAAI,IAAA,CAAK,SAAS,EAAE,CAAA,CAAA;AAC3D;AAGA,SAAS,WAAW,IAAA,EAAgD;AAClE,EAAA,OAAO,KAAK,MAAA,CAAO,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,KAAK,IAAA,CAAK,MAAA;AAC3C;AAmBA,IAAI,iBAAA,GAAoB,CAAA;AA+BxB,SAAS,YAAA,CAAa;AAAA,EACpB,SAAA;AAAA,EACA,M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ent,\n type InteractionKind,\n type ItemOutcome,\n isItemGroup,\n type LearnerResponse,\n type RecordingRef,\n resolvePlaybackPolicy,\n type SequenceEntry,\n type SequenceSlot,\n type SequenceSlotGroup,\n type SpeechAssessment,\n slotMediaKey,\n stimulusMediaKey,\n type ThemeTokens,\n} from '@intellectif/lk-core';\nimport { type ComponentType, useEffect, useMemo, useRef, useState } from 'react';\nimport type { LearnerAi } from '../../ai/LkAiProvider.js';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport type { LkStringsOverride } from '../../i18n/strings.js';\nimport { randomSessionId } from '../_internal.js';\nimport { Dictation } from '../Dictation/index.js';\nimport { FillInTheBlanks } from '../FillInTheBlanks/index.js';\nimport { GapSelect } from '../GapSelect/index.js';\nimport { MultipleChoice } from '../MultipleChoice/index.js';\nimport { ReadAloud } from '../ReadAloud/index.js';\nimport type { RecordingBinding } from '../ReadAloud/ReadAloud.js';\nimport { StimulusPanel } from '../StimulusPanel/index.js';\nimport { stopCaptureGroup } from '../shared/capture-registry.js';\nimport {\n mintTake,\n type SequenceSlotChannel,\n SequenceSlotContext,\n type TakeState,\n takeOf,\n} from '../shared/sequence-slot.js';\nimport type {\n ActivityProps,\n HtmlSanitizer,\n MediaBudgetBinding,\n RenderableActivity,\n RenderMode,\n SequenceMediaBudget,\n SequenceRecordingBinding,\n SequenceRecordingSlot,\n} from '../types.js';\nimport { WrittenResponse, type WrittenResponseSubmission } from '../WrittenResponse/index.js';\n\n/**\n * What one finished slot in a sequence produced. Two kinds, because two kinds\n * of activity exist: those the SDK scores at submit time, and those a grader\n * scores later. Collapsing them would mean inventing a score for ungraded\n * work — the exact defect the deferred outcome exists to prevent.\n *\n * **A read-aloud hand-in adds no arm here, deliberately.** The obvious home for\n * a handed-in take is `submitted`, and it is the wrong one: that arm's payload\n * is typed `WrittenResponseSubmission`, this union is published from both the\n * barrel and the `components/ActivitySequence` subpath, and a consumer narrows\n * on `kind === 'submitted'` and reads `.text`. Widening the payload to a union\n * would break every one of those reads — a breaking change to a published\n * discriminated union, bought for a type that `responded` already describes: a\n * read-aloud hand-in IS a raw `LearnerResponse` with no grade, which is exactly\n * what `responded` carries.\n *\n * What a read-aloud does add is `unsubmitted`, for the one thing no existing\n * arm can say honestly: a take that never reached storage. Any response would\n * be a lie about it — a `recording` of `null` is the blank a learner chooses,\n * and grades as 0.\n */\nexport type SequenceItemOutcome =\n | {\n kind: 'scored';\n /** Presented position. */\n index: number;\n /** Slot identity from `flattenSequence` — stable under shuffling; the `slotId` to score with. */\n slotId: string;\n activityId: string;\n result: ActivityResult;\n /**\n * The answer this score grades, for a slot whose grade arrives after its\n * answer was handed in and whose learner may hand in another: a\n * `practice` read-aloud, whose `response.recording` names the take the\n * score belongs to. Absent for every other slot, whose score and answer\n * arrive together.\n */\n response?: LearnerResponse;\n }\n | {\n kind: 'submitted';\n index: number;\n slotId: string;\n activityId: string;\n /** Ungraded submission; the grade arrives asynchronously. */\n submission: WrittenResponseSubmission;\n }\n | {\n kind: 'restored';\n index: number;\n slotId: string;\n activityId: string;\n /**\n * The answer as restored, when one was. A slot can be submitted with no\n * stored response (a blank the learner committed), so this is optional —\n * inventing one would be worse than admitting it is absent.\n */\n response?: LearnerResponse;\n }\n | {\n kind: 'responded';\n index: number;\n slotId: string;\n activityId: string;\n /**\n * The raw answer, with no grade of any kind. This is what an `exam` slot\n * produces: the client is forbidden to score, so a response is all there\n * is until the server grades it.\n *\n * A read-aloud `recording` of `null` here is always a blank the learner\n * chose to hand in, never a take that failed to upload — that is\n * `unsubmitted`.\n */\n response: LearnerResponse;\n }\n | {\n /**\n * A question the learner tried to answer and could not hand in, and then\n * left: a `practice` read-aloud whose take never reached your storage. It\n * carries no response, because there is none.\n *\n * Deliberately not `responded` with a `recording` of `null`: that is the\n * blank a learner chooses, and a grader marks it 0 with every word\n * omitted — which would turn a storage outage into a zero. Grade nothing\n * for this slot; the learner can still return to it, and a take stored\n * then reaches you through `onSubmit`.\n */\n kind: 'unsubmitted';\n index: number;\n slotId: string;\n activityId: string;\n };\n\n/**\n * Where a question sits in the set, and the calls that tell the pager what the\n * learner did with it — handed to a `renderers` override as its `question`\n * prop, beside the shared {@link ActivityProps}.\n *\n * The SDK's own components make the same calls, so a question a host draws\n * counts exactly as one the SDK draws: in `onFinished`, in whether the set is\n * complete, and in what a resumed attempt reopens. Every call here keeps ONE\n * identity for the life of the set, so it is safe in an effect's dependencies,\n * and does nothing once the set has changed or the pager has gone.\n */\nexport interface SequenceQuestion {\n /**\n * The identity to store this question's answer against — the same object\n * `onSubmit` and `onActivityComplete` are handed, for the life of the set.\n * `slotId`, never `index`: the position moves under shuffling.\n */\n slot: SequenceRecordingSlot;\n /**\n * `true` while this is the question on screen. `false` from the moment the\n * learner pages away, and `true` again when they come back.\n *\n * WHEN IT TURNS `false`, STOP THE MICROPHONE, ANY TIMER AND ANY SPEECH. The\n * pager pauses the `<audio>` and `<video>` elements inside the question and\n * stops the recorders the SDK started, but it cannot reach a recorder it did\n * not create.\n */\n active: boolean;\n /**\n * An element inside this question's own pane, for popovers, tooltips and\n * dialogs. Portal into it rather than into `document.body`: a pane the\n * learner has paged away from is hidden, and anything portalled out of it\n * stays on screen over the next question — and in fullscreen, only the\n * subtree being painted is visible at all.\n *\n * It is the same element for as long as the set is on screen, and is `null`\n * only before the first commit.\n */\n portalContainer: HTMLElement | null;\n /**\n * The learner withdrew their answer — a \"Try again\". The question counts as\n * unanswered again and its outcome is forgotten, so the set is not complete\n * until it is answered again. Calls no host callback: the host already knows.\n */\n clear(): void;\n /**\n * Work is on its way for this question — an upload, an assessment, a save.\n * While any question is pending, the set is not reported: `onFinished` and\n * `onComplete` wait for it. Paging does not wait.\n *\n * Call `setPending(false)` however the work ends, a failure included.\n */\n setPending(pending: boolean): void;\n /** Forwards to `onInteraction`, with this question's `activityId` and the time filled in. */\n emit(type: InteractionKind, payload?: Record<string, unknown>): void;\n}\n\n/**\n * A component that can render one activity inside a sequence. Register one per\n * activity `type` to put a consumer-defined type on screen — the React half of\n * the activity-type registry, matching `registerActivityType` in lk-core.\n *\n * It receives the shared {@link ActivityProps} and one prop beyond them:\n * `question`, the pager's half of the contract ({@link SequenceQuestion}). A\n * renderer written as `ComponentType<ActivityProps>` still fits and simply\n * ignores it.\n */\nexport type ActivityRenderer = ComponentType<ActivityProps & { question?: SequenceQuestion }>;\n\n/** A slot as its own calls know it: its identity, plus the type that decides how an answer is recorded. */\ninterface SlotIdentity extends SequenceRecordingSlot {\n type: string;\n}\n\n/** One slot's calls, made once per slot per set. */\ninterface SlotCalls {\n slot: SequenceRecordingSlot;\n onSubmit: (response: LearnerResponse) => void;\n onComplete: (result: ActivityResult) => void;\n clear: () => void;\n setPending: (pending: boolean) => void;\n emit: (type: InteractionKind, payload?: Record<string, unknown>) => void;\n}\n\nexport interface ActivitySequenceProps {\n /**\n * The ordered set of entries to present, one question at a time: loose\n * activities, and item groups — a shared passage, recording or image with\n * the questions that refer to it. A group's stimulus stays on screen\n * alongside each of its questions.\n *\n * Accepts `redact()` projections. For data straight off a server, pass it\n * through `asRenderableSequence()` — see that helper for why a cast is\n * unavoidable there — and set `renderMode=\"exam\"`.\n */\n activities: readonly SequenceEntry<RenderableActivity>[];\n /**\n * Renderers for activity types beyond the built-ins, keyed by `data.type`.\n * A key matching a built-in overrides it, so a consumer can replace the\n * bundled renderer without forking the sequencer.\n *\n * A registered renderer is an {@link ActivityRenderer}: it receives the\n * shared prop contract, plus `question` — the pager's half of the contract\n * ({@link SequenceQuestion}), which tells it when its question is on screen,\n * holds the set while its work is in flight, and gives it somewhere to\n * portal a popover. `shuffleSeed`, `recordingBinding`, `assessment` and\n * `workletUrl` are outside both and reach no override: a replacement for\n * `read-aloud` has to be given its own binding by whoever wrote it.\n */\n renderers?: Readonly<Record<string, ActivityRenderer>>;\n /**\n * Called whenever an individual activity is scored at submit time — the\n * incremental persist hook.\n *\n * `slotId` is the identity to store the result against, NOT `index`.\n * `index` is where the question was PRESENTED, which is not stable: it moves\n * under shuffling, and it already differs from the slot identity whenever a\n * group is present (the second entry of a sequence is presented at index 1\n * but is slot `\"1.0\"` if it is a group's first question). `composeAssessmentScore`\n * scores by `slotId`, so persisting `index` cannot be reconciled with it.\n */\n onActivityComplete?: (result: ActivityResult, index: number, slotId: string) => void;\n /**\n * Called on every submit with the learner's raw response and the identity of\n * the slot that produced it — before any grading, in every render mode.\n *\n * **This is the only response channel an `exam` sequence has.** In `exam`\n * mode the components never grade, so `onActivityComplete` cannot fire and\n * `onComplete` never will; without this prop nothing a learner submitted\n * would reach the consumer at all. Persist `response` against `slotId`.\n */\n onSubmit?: (\n response: LearnerResponse,\n slot: { slotId: string; index: number; activityId: string },\n ) => void;\n /**\n * Called once every activity has been completed, with the scored results.\n *\n * Fires only when EVERY item produced a score. A set containing a\n * deferred-graded activity (a written response) can never satisfy that, so\n * use `onFinished` for mixed sets — it is the general completion signal and\n * reports both kinds of outcome. It also carries `slotId` per item, which\n * this callback's bare array cannot.\n *\n * It fires straight after `onFinished`, with the same results, or never: a\n * set `onFinished` reported with an ungraded slot is not reported here later,\n * when a re-recorded take is graded.\n */\n onComplete?: (results: ActivityResult[]) => void;\n /**\n * Called once every activity has been completed, whether it was scored at\n * submit time or submitted for later grading. Use this for any set that\n * mixes graded and deferred-graded activities.\n *\n * **Once per set**, and that matters for a `practice` read-aloud, whose grade\n * arrives after the submit that completed the slot. When the last slot is\n * filled while a read-aloud's take is still being stored or assessed, this\n * waits for it and reports the set then — with the grade in place, or with\n * the slot's raw `responded` outcome when the take came back with no grade.\n * A take that never settles is a question still being answered, so the set\n * is not reported while it runs.\n *\n * **A failure the learner can still retry is in flight too.** While a take\n * that failed to upload, or whose assessment failed, is offered \"Try again\"\n * on the question the learner is looking at, the set is not reported: the\n * retry may yet store and grade it. It completes once the learner moves to\n * another question — as the last take the slot stored, or as `unsubmitted`\n * when it never stored one, which is never a blank.\n *\n * **A score and a response always describe the same take.** A read-aloud\n * recorded again replaces the earlier take's grade with the new take's\n * `responded`, and a result that arrives for a take the learner has since\n * replaced, or for a paper no longer on screen, is not recorded at all.\n *\n * `onComplete` fires in the same report or not at all, so the two never\n * describe one set differently. What arrives after the set was reported is\n * not reported here again, because a consumer who persists on this callback\n * must not write one attempt twice: a later take reaches you through\n * `onSubmit`, and its grade through `onActivityComplete`, the per-item persist\n * hook keyed by `slotId` — which only ever grades the answer `onSubmit` last\n * reported for that slot.\n */\n onFinished?: (items: SequenceItemOutcome[]) => void;\n /** Forwarded to each activity. */\n onInteraction?: (event: InteractionEvent) => void;\n /** Forwarded to each activity. `exam` and `review` disable local scoring. */\n renderMode?: RenderMode;\n /**\n * Binds every budgeted recording in this sequence to a play ledger the\n * consumer persists.\n *\n * The SDK refuses a play; it does not remember one. `plays` seeds the counts\n * at mount (pass `restoreMediaPlayLedger(plan, stored).entries`), and\n * `onPlayConsumed` is how a play becomes durable — see\n * {@link SequenceMediaBudget}.\n */\n mediaBudget?: SequenceMediaBudget;\n /**\n * Where every read-aloud take in this sequence is stored, and how a\n * judgement comes back. Required by any `read-aloud` slot outside `review`:\n * the component refuses to render a recorder whose take is stored nowhere.\n *\n * Named `recordingBinding` rather than `recording` because both\n * `ReadAloudData.recording` (the bounds an item declares) and\n * `ReadAloudLearnerResponse.recording` (the take a learner handed in) already\n * exist — the plain name would read as one of those. Same name at both\n * levels, different types, as `mediaBudget` has.\n */\n recordingBinding?: SequenceRecordingBinding;\n /**\n * Speech assessments keyed by `slotId`, forwarded to the matching read-aloud\n * slot so `review` can show the per-word marks behind a stored grade.\n *\n * Read LIVE, like `outcomes` and unlike `responses`: an assessment is fetched\n * beside the attempt it explains and lands after the first paint, and a\n * mount-only read would show the grade with no marks under it for ever.\n */\n assessments?: Readonly<Record<string, SpeechAssessment>>;\n /**\n * The URL of a self-hosted copy of `CAPTURE_PROCESSOR_SOURCE`, forwarded to\n * every read-aloud slot's recorder, for a Content-Security-Policy whose\n * `script-src` does not allow `blob:`. See `ReadAloudProps.workletUrl`. Like\n * `recordingBinding`, it does not reach a `renderers` override.\n */\n workletUrl?: string;\n /** Overrides the SDK's chrome text for this sequence. See {@link LkIntlProvider}. */\n strings?: LkStringsOverride;\n /**\n * The host's AI ports, for every question this renders: explanations after\n * grading, hints before submit. The same as `LkAiProvider`, for this one\n * sequence, and a `renderers` override receives them as its own `ai` prop —\n * except in `exam`, where nothing AI appears and no question is given them.\n * See {@link LearnerAi}.\n */\n ai?: LearnerAi;\n /**\n * `entries` shuffles the top-level entries; a group moves as one block, and\n * the order INSIDE a group follows the group's own `shuffle` setting.\n * Default `none`: authored order.\n */\n shuffle?: 'none' | 'entries';\n /**\n * Seed for every shuffle in this sequence (`shuffle: 'entries'` and any\n * group with `shuffle: 'within-group'`). Supply the attempt id, so the\n * server's `flattenSequence(entries, { seed })` derives the same order this\n * pager shows.\n *\n * **Required whenever this sequence shuffles** — `shuffle: 'entries'`, or any\n * group with `shuffle: 'within-group'` — in `exam` or `review` mode; omitting\n * it then throws. An order nobody can reproduce cannot be reconciled with a\n * recorded attempt, and failing at render is the only way that mistake\n * surfaces before a learner sits the paper. A sequence that does not shuffle\n * needs no seed in any mode.\n *\n * The guard covers an activity's own `data.shuffle` too, a group's items\n * included: `<MultipleChoice>` would otherwise fall back to a per-mount seed,\n * in every mode.\n *\n * In `practice` mode it stays optional: a random per-mount seed is used,\n * stable within the mount and deliberately not reproducible. That fallback is\n * also not SSR-safe (server and client would invent different orders and\n * hydration would mismatch), so supply a seed for any server-rendered\n * sequence regardless of mode.\n */\n shuffleSeed?: string;\n /**\n * Where to open. Defaults to the first question; pass a stored\n * `AttemptState.index` to reopen an interrupted attempt where it was left.\n * Read at mount only, like any `default*` prop.\n */\n defaultIndex?: number;\n /**\n * Fires whenever the learner moves. Persist it and the next resume reopens\n * on the right question — without it, the pager's position is the one piece\n * of an attempt a consumer cannot recover.\n */\n onIndexChange?: (index: number) => void;\n /**\n * Answers to restore, keyed by `slotId`, seeded into each slot as its\n * `defaultValue`. This is the other half of resume: `AttemptState.responses`\n * goes straight in.\n *\n * Read at mount only. To restore a different attempt, remount with a `key`.\n */\n responses?: Readonly<Record<string, LearnerResponse>>;\n /**\n * Slots the learner had already submitted, from `AttemptState.submittedSlotIds`.\n * Each is mounted already submitted, so a resumed paper does not reopen a\n * locked question as answerable — without this a learner can change and\n * re-submit work they had already committed.\n *\n * Read at mount only, alongside `responses`.\n */\n submittedSlotIds?: readonly string[];\n /**\n * Server-computed outcomes keyed by `slotId`, forwarded to each slot. In\n * `review` mode this is what marks correctness — the client never scores, so\n * without it a review render has nothing to show.\n */\n outcomes?: Readonly<Record<string, ItemOutcome>>;\n /** Renders author-supplied rich text; forwarded to the stimulus panel and every activity. */\n sanitizeHtml?: HtmlSanitizer;\n theme?: Partial<ThemeTokens>;\n /**\n * BCP 47 tag stamped as `lang` on this component's root. This is the\n * INTERFACE language — the SDK's own chrome renders inside that element — so\n * it should carry the same value you give `<LkIntlProvider locale>`. Passing\n * a different one re-declares the language of every SDK string in this\n * subtree without changing the words.\n *\n * It is NOT `data.locale`, which labels xAPI statements — and, on a\n * dictation, places the dictation's own words: `<Dictation>` puts it, and\n * the direction it names, on its title, hints, marks and solution. Other\n * authored content in another language belongs on `stimulus.locale`, which\n * `<StimulusPanel>` puts on the passage alone.\n */\n locale?: string;\n disabled?: boolean;\n}\n\n/** One stimulus panel to keep mounted: the group, and the presented span of its questions. */\ninterface StimulusMount {\n /** Authored entry position — unique per group in the sequence even if two groups share an id. */\n entryKey: string;\n group: SequenceSlotGroup;\n first: number;\n last: number;\n}\n\n/**\n * One slot's key for the life of a set: its pane's React key, and the name its\n * portal node is held under.\n */\nfunction slotKeyOf(setKey: string, slot: SequenceSlot<RenderableActivity>): string {\n return `${setKey}::slot-${slot.slotId}-${slot.activity.id}`;\n}\n\n/** The authored-entry prefix of a slot id: `\"3\"` for `\"3\"` and for `\"3.1\"`. */\nfunction entryKeyOf(slot: SequenceSlot<RenderableActivity>): string {\n return slot.slotId.split('.')[0] ?? slot.slotId;\n}\n\n/** The latest take a slot has been told about, and how far it has got. */\ninterface SlotTake {\n /** A number from `mintTake`: unique on the page, larger for a later take. */\n take: number;\n state: TakeState;\n /** The answer the take was handed in as, once it was stored. */\n response?: LearnerResponse;\n}\n\n/**\n * Names the capture groups of one pager, so a slot's microphone belongs to that\n * pager alone. Per mount, for the reason the playback groups are: slot ids are\n * short and repeat (\"0\", \"1.0\"), so two pagers on one page — a review beside a\n * live attempt — would share a group, and hiding one's first question would\n * stop the other's recorder. The name never reaches the DOM, so a server and\n * the client that hydrates it may mint different ones.\n */\nlet captureScopeCount = 0;\n\n/**\n * A pane that is kept MOUNTED but shown only when it is the current one, and\n * that stops any media it contains on the way out.\n *\n * `hidden` alone is not enough. It resolves to `display: none`, and CSS does\n * not touch playback: an `<audio>` or `<video>` inside a hidden subtree keeps\n * playing to the end. (The HTML spec pauses a media element when it is\n * REMOVED from the document — a different thing, and the thing this pager\n * deliberately does not do, because unmounting is what used to destroy the\n * learner's answers.) So a recording started for one question would carry on\n * underneath the next, which for a listening paper means the passage plays\n * while the learner is somewhere else entirely.\n *\n * Pausing preserves `currentTime`: coming back to a group resumes where the\n * learner left off. Nothing auto-plays on the way in — starting audio the\n * learner did not ask for is its own defect.\n *\n * `embed` media (a provider iframe) cannot be paused this way: controlling a\n * third-party player needs its own JS API, which the SDK has no reliable\n * access to because the author supplies the embed URL. Use `audio`/`video`\n * media for anything that must stop when the learner navigates.\n *\n * A microphone is the other way round: it is not an element in this subtree, so\n * no query can find it. A slot pane hands its content a `channel` through\n * `SequenceSlotContext` — never a prop, so nothing on a public component's\n * signature can name it — whose `captureGroup` the pane's recorders join, and\n * hiding the pane stops them: a learner who navigates away mid-take must not\n * leave the microphone live under the next question.\n */\nfunction SequencePane({\n className,\n hidden,\n channel,\n children,\n}: {\n className: string;\n hidden: boolean;\n channel?: SequenceSlotChannel;\n children: React.ReactNode;\n}): React.JSX.Element {\n const ref = useRef<HTMLDivElement>(null);\n const captureGroup = channel?.captureGroup;\n\n useEffect(() => {\n if (!hidden) {\n return;\n }\n if (captureGroup !== undefined) {\n stopCaptureGroup(captureGroup);\n }\n const node = ref.current;\n if (node === null) {\n return;\n }\n for (const media of node.querySelectorAll('audio, video')) {\n const element = media as HTMLMediaElement;\n if (!element.paused) {\n element.pause();\n }\n }\n }, [hidden, captureGroup]);\n\n return (\n <div className={className} hidden={hidden} ref={ref}>\n {channel === undefined ? (\n children\n ) : (\n <SequenceSlotContext.Provider value={channel}>{children}</SequenceSlotContext.Provider>\n )}\n </div>\n );\n}\n\n/**\n * Presents a set of activities as an in-place pager: one question visible at a\n * time, navigated with Prev/Next (no page scrolling). Linear free navigation —\n * the learner may move back and forth; activities keep their own submit and\n * scoring. On navigation, focus moves to the question region and the position\n * is announced via an aria-live region.\n *\n * Item groups are flattened into consecutive questions; the group's stimulus\n * is mounted ONCE, beside the question region rather than inside it, and shown\n * alongside every question in the group — so a passage stays put, and a\n * recording keeps its position, as the learner moves between its questions.\n */\n/**\n * Whether an activity shuffles its own options, and therefore needs a seed of\n * its own. Read structurally: `shuffle` is a per-type content field, not part\n * of the sequence entry contract.\n */\nfunction shufflesItsOwnOptions(entry: unknown): boolean {\n const item = entry as { shuffle?: unknown; shuffleChoices?: unknown } | null;\n // Two content fields, one question: does this item deal an order of its own?\n // `shuffle` is MultipleChoice's; `shuffleChoices` is Gap Select's. A type\n // added without being named here shuffles unseeded in an exam — and one named\n // here but not in the seed guard's message sends its author looking for a\n // shuffle they never wrote.\n return item?.shuffle === true || item?.shuffleChoices === true;\n}\n\nexport function ActivitySequence({\n activities,\n renderers,\n onActivityComplete,\n onComplete,\n onFinished,\n onSubmit,\n onInteraction,\n renderMode = 'practice',\n shuffle,\n shuffleSeed,\n defaultIndex,\n onIndexChange,\n responses,\n submittedSlotIds,\n outcomes,\n sanitizeHtml,\n theme,\n locale,\n disabled,\n mediaBudget,\n recordingBinding,\n assessments,\n workletUrl,\n strings,\n ai,\n}: ActivitySequenceProps): React.JSX.Element {\n const sessionIdRef = useRef<string | null>(null);\n const s = useLkStrings(strings);\n const mediaPlays = mediaBudget?.plays;\n const [captureScope] = useState(() => {\n captureScopeCount += 1;\n return `lk-seq-capture-${captureScopeCount}`;\n });\n\n // The presented order comes from lk-core, never computed here: the server\n // that records an attempt calls the same function with the same seed.\n const shuffleEntries = shuffle === 'entries';\n // Every shuffle this sequence can produce, not just the ones it performs\n // itself. An ACTIVITY's own `data.shuffle` is the third source: MultipleChoice\n // falls back to a per-mount seed when none reaches it, so an unseeded item\n // shuffle used to render happily under `exam` and hand the learner a\n // different option order on every mount — exactly the unreproducible\n // arrangement this guard exists to refuse, arriving through the one door it\n // did not watch.\n const needsSeed =\n shuffleEntries ||\n activities.some((entry) =>\n isItemGroup(entry)\n ? entry.shuffle === 'within-group' || entry.items.some(shufflesItsOwnOptions)\n : shufflesItsOwnOptions(entry),\n );\n\n // An unreproducible order is a practice-only affordance. Under `exam` or\n // `review` the server has to be able to rebuild exactly what the learner\n // saw, so a missing seed is an error rather than something to paper over —\n // the same reason `flattenSequence` refuses to invent one.\n if (needsSeed && shuffleSeed === undefined && renderMode !== 'practice') {\n // Every door `needsSeed` watches, named: a reader whose only shuffle is an\n // item's own field must find that field here. And no single function\n // rebuilds all of these orders — `flattenSequence` deals entries and group\n // items, while an item deals its own options from the same seed — so the\n // message promises the seed, not a function.\n throw new Error(\n `ActivitySequence: renderMode \"${renderMode}\" requires a \\`shuffleSeed\\` when anything ` +\n 'in the sequence shuffles: shuffle=\"entries\", a group with shuffle: \"within-group\", or ' +\n \"an activity's own `data.shuffle` (multiple choice) or `data.shuffleChoices` (gap \" +\n 'select), including an activity inside a group. Pass the attempt id, so the server can ' +\n 'rebuild every order the learner saw from that one seed.',\n );\n }\n\n // Lazily created only when shuffling in practice without a caller seed (same\n // contract as MultipleChoice.shuffleSeed): a per-mount session seed, stable\n // across re-renders, never reproducible.\n const seed = needsSeed\n ? // biome-ignore lint/suspicious/noAssignInExpressions: sanctioned lazy ref initialization\n (shuffleSeed ?? (sessionIdRef.current ??= randomSessionId()))\n : undefined;\n const slots = useMemo(\n () => flattenSequence(activities, { shuffleEntries, ...(seed !== undefined ? { seed } : {}) }),\n [activities, shuffleEntries, seed],\n );\n\n // Clamped rather than trusted: a stored position from a paper that has since\n // lost its last question would open the pager on a slot that is not there,\n // which renders as an empty shell with no way forward.\n const [index, setIndex] = useState(() => {\n // NaN passes through Math.min/Math.max unchanged, so it survived every\n // clamp and indexed the slots with NaN — the pager then rendered the empty\n // shell this clamp exists to prevent. `NaN` is a `number`, so the prop type\n // gives no protection, and `Number(row.last_index)` on a NULL column\n // produces exactly that.\n const requested = Math.trunc(defaultIndex ?? 0);\n if (!Number.isFinite(requested)) {\n return 0;\n }\n return Math.min(Math.max(0, requested), Math.max(0, slots.length - 1));\n });\n // Outcomes live in a ref, not state: nothing renders from them, and a ref is\n // written SYNCHRONOUSLY. Reading them from a `useState` closure meant two\n // slots completing in the same tick both saw the pre-update array — the\n // second overwrote the first, so one answer vanished and completion never\n // fired. Every slot is mounted at once here, so same-tick completions are\n // reachable (a custom renderer that completes from a mount effect).\n const outcomesRef = useRef<(SequenceItemOutcome | null)[] | null>(null);\n // The slot each position of `outcomesRef` belongs to, assigned wherever that\n // array is created so the two can never describe different papers. A ref,\n // not the `slots` a closure saw: an outcome that settles late arrives through\n // a closure from the render that started it, and only a ref can tell it what\n // is at its position NOW — see `record`.\n const outcomeSlotsRef = useRef<readonly SequenceSlot<RenderableActivity>[] | null>(null);\n // The latest take each `practice` read-aloud slot has been told about, keyed\n // by position — see `record`. A ref for the reason the outcomes are one: a\n // submit, the grade after it and the report all read it inside one tick.\n const takesRef = useRef<Map<number, SlotTake>>(new Map());\n // Which set the outcomes describe: bumped on every set change, and captured\n // by every callback a render hands a slot. A result that arrives through a\n // callback from an earlier set is refused, whatever slot and activity ids the\n // new set reuses — ids a host chooses, and a loading blip or a paper that\n // shares an item repeats them exactly.\n const setGenerationRef = useRef(0);\n // The question on screen, as of the last commit: leaving a question is what\n // completes a failure on it that was being offered a retry, and a report made\n // on a position the screen does not show yet would describe a question the\n // learner is still looking at. Written by the effect below `go`.\n const indexRef = useRef(index);\n // Whether this set has been reported. One flag for both whole-set callbacks,\n // because they are one report: a set can be filled again after it reported —\n // a practice read-aloud recorded again replaces its own outcome — and a\n // consumer who persists on either callback must not be handed one attempt\n // twice, nor be told by `onComplete` later what `onFinished` reported\n // differently.\n const reportedRef = useRef(false);\n // The channel each slot pane hands its content, one per slot per set, so it\n // keeps one identity for as long as its set is on screen.\n const channelsRef = useRef<Map<string, SequenceSlotChannel>>(new Map());\n // The calls each slot makes, on the same terms and for the same reason: a\n // host renderer may hold them in an effect, and a new identity each render\n // would re-run it.\n const callsRef = useRef<Map<string, SlotCalls>>(new Map());\n // Questions whose host says work is on its way, by presented position. The\n // set is not reported while any of them is pending — the pager's own\n // read-aloud takes are tracked separately, by take, in `takesRef`.\n const hostPendingRef = useRef<Set<number>>(new Set());\n // The element each host-drawn question portals into, and the ref callbacks\n // that collect them. The callbacks are made once per slot: a new one each\n // render would detach and re-attach on every commit.\n const [portals, setPortals] = useState<ReadonlyMap<string, HTMLElement>>(() => new Map());\n const portalRefsRef = useRef<Map<string, (node: HTMLDivElement | null) => void>>(new Map());\n // The mode this pager is delivering in, as of the latest render: a channel\n // reads it through this ref rather than holding a copy, so a set switched\n // from practice to exam in place is an exam at once.\n const modeRef = useRef<RenderMode>(renderMode);\n modeRef.current = renderMode;\n // What a channel calls, as of the latest render — assigned below `updateTake`.\n const latestRef = useRef<{\n updateTake: (generation: number, at: number, take: number, state: TakeState) => void;\n reportIfFinished: () => void;\n submitSlot: (generation: number, at: SlotIdentity, response: LearnerResponse) => void;\n completeSlot: (generation: number, at: SlotIdentity, result: ActivityResult) => void;\n clearSlot: (generation: number, at: SlotIdentity) => void;\n hostPending: (generation: number, at: SlotIdentity, pending: boolean) => void;\n emit: (\n generation: number,\n at: SlotIdentity,\n type: InteractionKind,\n payload: Record<string, unknown> | undefined,\n ) => void;\n } | null>(null);\n // Cleared as this pager unmounts. A slot's own teardown tells the pager its\n // take is over, and a pager on its way out must not report a set on the\n // strength of that.\n const aliveRef = useRef(true);\n useEffect(() => {\n aliveRef.current = true;\n return () => {\n aliveRef.current = false;\n };\n }, []);\n if (outcomesRef.current === null) {\n // Slots the learner had already submitted are seeded as `restored`. They\n // will not submit again — they mount locked — so leaving them null meant\n // `onFinished` waited forever on outcomes that could never arrive, and a\n // resumed attempt could never signal completion however many of the\n // remaining questions the learner answered. Seeding fires no callback: the\n // attempt was already this far along before this mount existed.\n const submittedAtMount = new Set(submittedSlotIds ?? []);\n outcomesRef.current = slots.map((slot) =>\n submittedAtMount.has(slot.slotId)\n ? {\n kind: 'restored' as const,\n index: slot.index,\n slotId: slot.slotId,\n activityId: slot.activity.id,\n ...(responses !== undefined && Object.hasOwn(responses, slot.slotId)\n ? { response: responses[slot.slotId] as LearnerResponse }\n : {}),\n }\n : null,\n );\n outcomeSlotsRef.current = slots;\n }\n const regionRef = useRef<HTMLDivElement>(null);\n const mountedRef = useRef(false);\n\n // Reset pager position and outcomes when the presented SET changes (B8):\n // without this, results from the previous set leak into the new one and can\n // fire completion with a mixed old/new array. Keyed on the set's CONTENT\n // identity (ordered slot and activity ids), not the array reference — a\n // parent that re-creates a structurally identical array on every render\n // (inline literals, .map() in render) must not wipe in-progress answers.\n // JSON.stringify (not join) so ids containing the separator cannot collide.\n const setKey = JSON.stringify(slots.map((slot) => [slot.slotId, slot.activity.id]));\n const [prevSetKey, setPrevSetKey] = useState(setKey);\n // The set this component mounted with. `responses` seeds slots BY slotId,\n // and slot ids are short and repeat across papers (\"0\", \"1.0\"), so applying\n // them after the set changed would drop one paper's answers under another\n // paper's questions — a review modal stepping to the next attempt did\n // exactly that. Seeding stops at the first set change; to show a different\n // attempt, remount with a `key`, which is what \"read at mount only\" means.\n // `mediaBudget.resumeKey` participates so an invigilator can hand a play\n // back — re-seeding the budgets in place — without remounting the pager and\n // costing the learner their focus, their scroll position and an unsaved\n // answer.\n const seedKey = `${setKey}::${mediaBudget?.resumeKey ?? ''}`;\n const mountSetKeyRef = useRef(setKey);\n const mountSeedKeyRef = useRef(seedKey);\n const seedsApply = mountSetKeyRef.current === setKey;\n const mediaSeedsApply = mountSeedKeyRef.current === seedKey || seedsApply;\n if (mountSeedKeyRef.current !== seedKey) {\n mountSeedKeyRef.current = seedKey;\n }\n const submitted = useMemo(() => new Set(submittedSlotIds ?? []), [submittedSlotIds]);\n if (prevSetKey !== setKey) {\n setPrevSetKey(setKey);\n setIndex(0);\n // At once, not in the effect: a new set has no question the learner was on,\n // and the effect does not run at all when the position was already 0.\n indexRef.current = 0;\n outcomesRef.current = slots.map(() => null);\n outcomeSlotsRef.current = slots;\n takesRef.current = new Map();\n setGenerationRef.current += 1;\n channelsRef.current = new Map();\n callsRef.current = new Map();\n hostPendingRef.current = new Set();\n portalRefsRef.current = new Map();\n reportedRef.current = false;\n }\n const setGeneration = setGenerationRef.current;\n\n // After a navigation (not the initial mount) move focus to the question\n // region so screen-reader / keyboard users land on the new question.\n // biome-ignore lint/correctness/useExhaustiveDependencies: index is the intended trigger\n useEffect(() => {\n if (mountedRef.current) {\n regionRef.current?.focus();\n } else {\n mountedRef.current = true;\n }\n }, [index]);\n\n // Report where the pager actually IS, from an effect rather than from the\n // navigation handler. Two positions the learner never chose are still\n // positions a consumer has to persist: a `defaultIndex` that was clamped\n // (stored 99, showing 2) and the reset a set change performs. Reporting only\n // clicks left storage disagreeing with the screen, and the next autosave\n // then wrote a position the plan does not have.\n const reportedIndexRef = useRef<number | null>(null);\n useEffect(() => {\n if (reportedIndexRef.current === index) {\n return;\n }\n const first = reportedIndexRef.current === null;\n reportedIndexRef.current = index;\n // On mount, stay silent unless the requested position was corrected.\n if (first && index === Math.trunc(defaultIndex ?? 0)) {\n return;\n }\n onIndexChange?.(index);\n }, [index, defaultIndex, onIndexChange]);\n\n // The learner has moved, and the screen shows where to. Leaving a question\n // can complete a failure on it that was being offered a retry — see\n // `reportIfFinished` — so the set may be reportable now.\n useEffect(() => {\n if (indexRef.current === index) {\n return;\n }\n indexRef.current = index;\n latestRef.current?.reportIfFinished();\n }, [index]);\n\n // One panel per group, spanning the presented positions of its questions.\n const stimulusMounts = useMemo<StimulusMount[]>(() => {\n const mounts = new Map<string, StimulusMount>();\n for (const slot of slots) {\n if (slot.group === undefined) {\n continue;\n }\n const entryKey = entryKeyOf(slot);\n const existing = mounts.get(entryKey);\n if (existing === undefined) {\n mounts.set(entryKey, { entryKey, group: slot.group, first: slot.index, last: slot.index });\n } else {\n existing.last = slot.index;\n }\n }\n return [...mounts.values()];\n }, [slots]);\n\n const total = slots.length;\n const current = slots[index];\n\n const go = (next: number): void => {\n setIndex(next);\n };\n\n /**\n * Fires the whole-set callbacks — once, together — when every slot is done\n * and no take is still on its way.\n *\n * **A take on its way holds the report.** A practice read-aloud records its\n * `responded` outcome the moment its take is stored, and its grade can land\n * after the last slot was filled; reporting then handed `onFinished` the raw\n * outcome, and the grade a moment later could never reach it. So a slot\n * whose latest take is being stored or judged is not done. The take states\n * come from the component itself, through the slot's channel, and every way a\n * take can end reports an end — a grade, a take with no grade, a failure\n * nobody can retry, an unmount — so a take that settles never holds a set.\n *\n * **So does a failure the learner can still retry, on the question in front\n * of them.** Reporting there reported a set whose answer \"Try again\" was about\n * to change: the retry stored and graded the take, and `onComplete` then\n * described a different set from the `onFinished` before it. Once the learner\n * moves to another question the failure no longer holds the report: the slot\n * completes as whatever it last stored, or as `unsubmitted` when that is\n * nothing — never as a `recording` of `null`, which is the blank a learner\n * chooses and a grader marks 0. `unsubmitted` is a `practice` outcome only:\n * an exam question with no stored take is unanswered, and the learner has a\n * blank to hand in if that is their answer.\n */\n const reportIfFinished = (): void => {\n const held = outcomesRef.current;\n const presented = outcomeSlotsRef.current;\n if (held === null || presented === null || reportedRef.current) {\n return;\n }\n // A host's question says work is on its way for it: an upload, a save, a\n // judgement. Reporting now would describe the set as the learner left it a\n // moment before it settled.\n if (hostPendingRef.current.size > 0) {\n return;\n }\n const items: SequenceItemOutcome[] = [];\n for (const [at, outcome] of held.entries()) {\n const take = takesRef.current.get(at);\n if (take?.state === 'in-flight' || (take?.state === 'retryable' && at === indexRef.current)) {\n return;\n }\n const slot = presented[at];\n if (outcome !== null) {\n items.push(outcome);\n } else if (take?.state === 'retryable' && renderMode === 'practice' && slot !== undefined) {\n items.push({\n kind: 'unsubmitted',\n index: at,\n slotId: slot.slotId,\n activityId: slot.activity.id,\n });\n } else {\n return;\n }\n }\n reportedRef.current = true;\n onFinished?.(items);\n\n // `onComplete` predates deferred grading and promises ActivityResult[].\n // Fire it only when every slot really was scored, rather than inventing a\n // result for work nobody has graded — and only here, beside `onFinished`.\n const scored: ActivityResult[] = [];\n for (const item of items) {\n if (item.kind !== 'scored') {\n return;\n }\n scored.push(item.result);\n }\n onComplete?.(scored);\n };\n\n /**\n * Records a finished slot and reports the set when it is done — the one place\n * a slot's outcome is decided.\n *\n * **An outcome must come from the set on screen.** A grade can settle after\n * the paper changed — an assessment held across a swap of `activities`, or a\n * consumer's own renderer grading asynchronously — and it arrives through a\n * callback from the render that started it. Accepted, it landed in whatever\n * slot of the NEW paper had its index, and could report that paper fully\n * scored though nobody had answered it. Ids cannot tell the papers apart: a\n * new paper can reuse both the slot id and the activity id, and a loading\n * blip reuses every id there is. `generation` can: it is the set the callback\n * was handed out for, and it is refused unless that set is still current.\n *\n * **A slot that already holds an outcome is FINAL**: the first outcome wins,\n * so a renderer that reports twice keeps what it reported first. There is one\n * exception.\n *\n * **The exception is a `practice` read-aloud, and it is decided by `take`.**\n * That slot records `responded` when a take is stored, because a take that\n * comes back unscorable produces no grade at all and the slot would otherwise\n * stay `null` for ever. Each take has a number (`mintTake`), unique on the page\n * and larger for a later take, carried by everything the component reports\n * about it. The invariant:\n *\n * **The score and the response a slot holds always describe the same take.**\n *\n * - A `responded` for a newer take replaces whatever the slot holds, a grade\n * included: `onSubmit` has already told the host about that take, so a\n * grade kept for the older one would sit beside a response it does not\n * grade.\n * - A `scored` lands only for the slot's latest take, once, and replaces that\n * take's `responded`. A grade for any other take — one the learner has\n * since replaced, even one still in flight when they did — is dropped\n * rather than filed against a take it did not grade.\n * - A `restored` slot is never replaced: it was submitted before this mount,\n * and a resumed attempt must not be re-reported as if it had just been sat.\n *\n * A grade therefore lands once per take, and `onActivityComplete` — the\n * per-item hook, keyed by `slotId` — only ever grades the answer `onSubmit`\n * last reported for that slot. The whole-set callbacks stay once per set\n * whatever is replaced — see `reportedRef`.\n */\n const record = (outcome: SequenceItemOutcome, generation: number, take?: number): void => {\n const held = outcomesRef.current;\n if (held === null || generation !== setGenerationRef.current) {\n return;\n }\n const at = outcome.index;\n const holding = held[at];\n let accepted = outcome;\n if (take === undefined) {\n if (holding != null) {\n return;\n }\n } else {\n if (holding?.kind === 'restored') {\n return;\n }\n const latest = takesRef.current.get(at);\n if (outcome.kind === 'responded') {\n // Older than the latest take, or a second answer for the same one.\n if (\n latest !== undefined &&\n (take < latest.take || (take === latest.take && latest.response !== undefined))\n ) {\n return;\n }\n takesRef.current.set(at, {\n take,\n // A take this pager hears of first through its answer — a consumer's\n // renderer has no channel — has nothing on its way.\n state: latest?.take === take ? latest.state : 'settled',\n response: outcome.response,\n });\n } else if (outcome.kind === 'scored') {\n // Only the latest take's grade, only once it was stored, and only once.\n if (latest?.take !== take || latest.response === undefined || holding?.kind === 'scored') {\n return;\n }\n accepted = { ...outcome, response: latest.response };\n } else {\n return;\n }\n }\n const next = held.slice();\n next[at] = accepted;\n // Commit before firing anything: a second record() in the same tick must\n // see this one.\n outcomesRef.current = next;\n\n if (accepted.kind === 'scored') {\n onActivityComplete?.(accepted.result, accepted.index, accepted.slotId);\n }\n reportIfFinished();\n };\n\n /**\n * The learner committed an answer to a slot: the body of the `onSubmit` every\n * question is handed, the SDK's own components and a host's renderer alike.\n */\n const submitSlot = (generation: number, at: SlotIdentity, response: LearnerResponse): void => {\n // A submit through a callback handed out for an earlier set is a\n // consumer renderer's late one, for a question no longer on screen: the\n // host would file it against whatever slot reuses these ids now.\n if (generation !== setGenerationRef.current) {\n return;\n }\n onSubmit?.(response, { slotId: at.slotId, index: at.index, activityId: at.activityId });\n // Written responses are excluded in every mode because they report\n // something richer through `onSubmitted` a moment later, and the first\n // outcome wins.\n if (at.type === 'written-response') {\n return;\n }\n // Outside `practice` the components do not grade, so a raw response is\n // the ONLY outcome this slot will ever produce — record it, or the set\n // could never complete and `onFinished` would be dead in exam mode.\n if (renderMode !== 'practice') {\n record(\n {\n kind: 'responded',\n index: at.index,\n slotId: at.slotId,\n activityId: at.activityId,\n response,\n },\n generation,\n );\n return;\n }\n // A `practice` read-aloud is the one type that can submit and then\n // produce no score: an unscorable take, an assessor that failed, or a\n // binding that stores without judging all end the attempt with nothing\n // to grade, and `onComplete` fires only on a grade. Recorded for its\n // take, so the grade that may still arrive for that take replaces it —\n // and a take recorded again replaces the one before, grade and all.\n if (at.type === 'read-aloud') {\n record(\n {\n kind: 'responded',\n index: at.index,\n slotId: at.slotId,\n activityId: at.activityId,\n response,\n },\n generation,\n takeOf(response) ?? mintTake(),\n );\n }\n };\n\n /** A slot produced a grade: the body of the `onComplete` every question is handed. */\n const completeSlot = (generation: number, at: SlotIdentity, result: ActivityResult): void => {\n const takesAnswers = renderMode === 'practice' && at.type === 'read-aloud';\n record(\n { kind: 'scored', index: at.index, slotId: at.slotId, activityId: at.activityId, result },\n generation,\n // The take the grade is for: stamped by `<ReadAloud>`, and for a\n // consumer's renderer, which cannot stamp one, the slot's latest.\n takesAnswers ? (takeOf(result) ?? takesRef.current.get(at.index)?.take) : undefined,\n );\n };\n\n /**\n * A host's question withdrew its answer. The slot holds nothing again — its\n * outcome and, with it, the take any grade would be filed against — so the\n * set is unfinished until it is answered again.\n *\n * A set already reported stays reported: the whole-set callbacks fire once,\n * and a consumer who persists on them must not be handed one attempt twice.\n */\n const clearSlot = (generation: number, at: SlotIdentity): void => {\n const held = outcomesRef.current;\n if (!aliveRef.current || held === null || generation !== setGenerationRef.current) {\n return;\n }\n takesRef.current.delete(at.index);\n if (held[at.index] == null) {\n return;\n }\n const next = held.slice();\n next[at.index] = null;\n outcomesRef.current = next;\n };\n\n /** A host's question is waiting on work of its own, or has stopped waiting. */\n const hostPending = (generation: number, at: SlotIdentity, pending: boolean): void => {\n if (!aliveRef.current || generation !== setGenerationRef.current) {\n return;\n }\n const waiting = hostPendingRef.current;\n if (pending) {\n waiting.add(at.index);\n return;\n }\n if (!waiting.delete(at.index)) {\n return;\n }\n // The last thing the set was waiting for may just have arrived.\n reportIfFinished();\n };\n\n /** A host's question reported an interaction: its activity and the moment, filled in. */\n const emitFor = (\n generation: number,\n at: SlotIdentity,\n type: InteractionKind,\n payload: Record<string, unknown> | undefined,\n ): void => {\n if (!aliveRef.current || generation !== setGenerationRef.current) {\n return;\n }\n onInteraction?.({\n type,\n activityId: at.activityId,\n timestamp: Date.now(),\n payload: payload ?? {},\n });\n };\n\n /**\n * What a slot's channel reports: the state of one of its takes. A take older\n * than the slot's latest has been replaced, and a report from a set that is\n * no longer current, or reaching a pager that is unmounting, describes\n * nothing on screen.\n */\n const updateTake = (generation: number, at: number, take: number, state: TakeState): void => {\n if (!aliveRef.current || generation !== setGenerationRef.current) {\n return;\n }\n const latest = takesRef.current.get(at);\n if (latest !== undefined && take < latest.take) {\n return;\n }\n // A newer take starts with no answer of its own: the response the slot\n // holds belongs to the take before it until this one is stored.\n takesRef.current.set(at, latest?.take === take ? { ...latest, state } : { take, state });\n reportIfFinished();\n };\n // Channels and slot calls keep one identity for a whole set, so they call\n // through this ref and always reach the latest render's props.\n latestRef.current = {\n updateTake,\n reportIfFinished,\n submitSlot,\n completeSlot,\n clearSlot,\n hostPending,\n emit: emitFor,\n };\n\n /**\n * The calls one slot makes, made once per slot per set. They reach the latest\n * render through `latestRef`, so they can keep one identity while the props\n * they report to change — what a host renderer needs to hold them in an\n * effect, and what the pager needs so a host that re-renders on every\n * keystroke does not re-run one.\n */\n const callsFor = (slot: SequenceSlot<RenderableActivity>): SlotCalls => {\n const key = `${slot.index}::${slot.slotId}`;\n let calls = callsRef.current.get(key);\n if (calls === undefined) {\n const generation = setGeneration;\n const at: SlotIdentity = {\n slotId: slot.slotId,\n index: slot.index,\n activityId: slot.activity.id,\n type: slot.activity.type,\n };\n calls = {\n slot: { slotId: at.slotId, index: at.index, activityId: at.activityId },\n onSubmit: (response) => latestRef.current?.submitSlot(generation, at, response),\n onComplete: (result) => latestRef.current?.completeSlot(generation, at, result),\n clear: () => latestRef.current?.clearSlot(generation, at),\n setPending: (pending) => latestRef.current?.hostPending(generation, at, pending === true),\n emit: (type, payload) => latestRef.current?.emit(generation, at, type, payload),\n };\n callsRef.current.set(key, calls);\n }\n return calls;\n };\n\n /**\n * Where a host-drawn question portals: a node inside its own pane, so it is\n * hidden with the question it belongs to and painted with it in fullscreen.\n * One ref callback per slot, kept, because a new one each render detaches and\n * re-attaches the node on every commit.\n */\n const portalRefFor = (key: string): ((node: HTMLDivElement | null) => void) => {\n let callback = portalRefsRef.current.get(key);\n if (callback === undefined) {\n callback = (node: HTMLDivElement | null) => {\n setPortals((held) => {\n if (node === null) {\n if (!held.has(key)) {\n return held;\n }\n const next = new Map(held);\n next.delete(key);\n return next;\n }\n if (held.get(key) === node) {\n return held;\n }\n const next = new Map(held);\n next.set(key, node);\n return next;\n });\n };\n portalRefsRef.current.set(key, callback);\n }\n return callback;\n };\n\n /** The channel a slot's pane hands its content: its capture group and its takes. */\n const channelFor = (slot: SequenceSlot<RenderableActivity>): SequenceSlotChannel => {\n const key = `${slot.index}::${slot.slotId}`;\n let channel = channelsRef.current.get(key);\n if (channel === undefined) {\n const generation = setGeneration;\n const at = slot.index;\n channel = {\n captureGroup: `${captureScope}::${slot.slotId}`,\n // A getter, so the channel keeps the one identity a recorder joined\n // while still answering for the mode in force now.\n get renderMode() {\n return modeRef.current;\n },\n takeState: (take, state) => {\n latestRef.current?.updateTake(generation, at, take, state);\n },\n };\n channelsRef.current.set(key, channel);\n }\n return channel;\n };\n\n if (!current) {\n return <div className=\"lk-seq\" />;\n }\n\n // Every budgeted recording this paper presents, and the key it is budgeted\n // under. Derived from the resolved policy, so the pager, the plan and the\n // schema cannot disagree about what is budgeted.\n const budgetedMedia = slots.flatMap((slot) => {\n const found: { key: string; url: string }[] = [];\n const own = (slot.activity as { media?: ActivityMedia }).media;\n if (own !== undefined && resolvePlaybackPolicy(own).maxPlays !== null) {\n found.push({ key: slotMediaKey(slot.slotId), url: own.url });\n }\n const stimulus = slot.group?.stimulus.media;\n if (stimulus !== undefined && resolvePlaybackPolicy(stimulus).maxPlays !== null) {\n found.push({ key: stimulusMediaKey(slot.slotId), url: stimulus.url });\n }\n return found;\n });\n\n const budgetEnforced = mediaBudget?.enforced ?? renderMode !== 'review';\n\n if (budgetedMedia.length > 0 && renderMode === 'exam' && budgetEnforced) {\n if (mediaBudget?.onPlayConsumed === undefined) {\n throw new Error(\n 'ActivitySequence: renderMode \"exam\" with media that declares `maxPlays` requires ' +\n '`mediaBudget.onPlayConsumed`. The SDK persists nothing, so without it the count lives ' +\n 'only in this mount: a refresh silently restores the full budget, and a paper that ' +\n 'grants unlimited plays while showing \"2 plays remaining\" is indistinguishable — to the ' +\n 'learner and to an appeal — from one that works. Budgeted media: ' +\n `${[...new Set(budgetedMedia.map((m) => m.key))].join(', ')}.`,\n );\n }\n const resuming =\n (responses !== undefined && Object.keys(responses).length > 0) ||\n (submittedSlotIds !== undefined && submittedSlotIds.length > 0);\n if (resuming && mediaBudget.plays === undefined) {\n throw new Error(\n 'ActivitySequence: this is a resumed attempt (`responses`/`submittedSlotIds` were ' +\n 'supplied) but `mediaBudget.plays` is absent. A resume that omits the ledger hands the ' +\n 'learner a fresh budget at exactly the moment it matters. Pass ' +\n '`restoreMediaPlayLedger(plan, stored).entries`, or `{}` to state explicitly that ' +\n 'nothing was spent.',\n );\n }\n }\n\n // One recording must not carry two budgets, in any mode — six questions each\n // holding the same clip at maxPlays 2 is twelve plays of one recording.\n const keysByUrl = new Map<string, Set<string>>();\n for (const { key, url } of budgetedMedia) {\n const keys = keysByUrl.get(url) ?? new Set<string>();\n keys.add(key);\n keysByUrl.set(url, keys);\n }\n for (const [url, keys] of keysByUrl) {\n if (keys.size > 1) {\n throw new Error(\n `ActivitySequence: media ${JSON.stringify(url)} is budgeted under ${keys.size} separate ` +\n `keys (${[...keys].join(', ')}), so one recording grants ${keys.size} × maxPlays. Put ` +\n \"the questions that share a recording in an item group — a group's stimulus is one \" +\n 'recording with one budget.',\n );\n }\n }\n\n /** The per-media binding handed to a component or to the stimulus panel. */\n const bindingFor = (\n key: string,\n slot: { slotId: string; index: number; activity: { id: string } },\n ): MediaBudgetBinding | undefined => {\n if (mediaBudget === undefined) {\n return undefined;\n }\n const entry =\n mediaSeedsApply && mediaPlays !== undefined && Object.hasOwn(mediaPlays, key)\n ? mediaPlays[key]\n : undefined;\n return {\n key,\n slotId: slot.slotId,\n index: slot.index,\n activityId: slot.activity.id,\n ...(entry !== undefined ? { entry } : {}),\n ...(mediaBudget.enforced !== undefined ? { enforced: mediaBudget.enforced } : {}),\n ...(mediaBudget.onPlayConsumed !== undefined\n ? { onPlayConsumed: mediaBudget.onPlayConsumed }\n : {}),\n ...(mediaBudget.onPlayRefunded !== undefined\n ? { onPlayRefunded: mediaBudget.onPlayRefunded }\n : {}),\n ...(mediaBudget.onPosition !== undefined ? { onPosition: mediaBudget.onPosition } : {}),\n ...(mediaBudget.strings !== undefined ? { strings: mediaBudget.strings } : {}),\n };\n };\n\n /**\n * The per-slot recording binding handed to a read-aloud, modelled on\n * `bindingFor`: the sequence-level methods are called with the slot they\n * belong to, and `assess` / `playbackUrl` are copied only when the consumer\n * supplied them — a binding carrying `assess: undefined` is a binding the\n * component would try to call.\n *\n * It watches nothing. The pager used to watch the promises it handed out to\n * decide when a set was finished, and a promise knows nothing of the take\n * that asked for it: a late failure from a paper no longer on screen landed\n * in a new paper that reused the slot's ids, as a blank. What a take came to\n * is reported by the component, numbered by take, through the slot's channel\n * — see `record` and `reportIfFinished`.\n *\n * A consumer's own renderer is handed no binding.\n */\n const recordingBindingFor = (slot: {\n slotId: string;\n index: number;\n activity: { id: string };\n }): RecordingBinding | undefined => {\n if (recordingBinding === undefined) {\n return undefined;\n }\n const at: SequenceRecordingSlot = {\n slotId: slot.slotId,\n index: slot.index,\n activityId: slot.activity.id,\n };\n const { assess, playbackUrl } = recordingBinding;\n // Called on the binding, so a consumer's binding written as a class keeps\n // its `this`.\n return {\n upload: (take) => recordingBinding.upload(take, at),\n ...(assess !== undefined\n ? { assess: (ref: RecordingRef) => assess.call(recordingBinding, ref, at) }\n : {}),\n ...(playbackUrl !== undefined\n ? { playbackUrl: (ref: RecordingRef) => playbackUrl.call(recordingBinding, ref, at) }\n : {}),\n };\n };\n\n const forwarded = {\n ...(onInteraction ? { onInteraction } : {}),\n renderMode,\n ...(sanitizeHtml ? { sanitizeHtml } : {}),\n ...(strings !== undefined ? { strings } : {}),\n // Handed to no question in `exam`, where none gives AI help: a\n // `renderers` override is not given ports it must then know to ignore.\n ...(ai !== undefined && renderMode !== 'exam' ? { ai } : {}),\n ...(theme ? { theme } : {}),\n ...(locale ? { locale } : {}),\n ...(disabled ? { disabled } : {}),\n };\n\n const renderSlot = (slot: SequenceSlot<RenderableActivity>): React.JSX.Element => {\n const activity = slot.activity;\n const { slotId, index: slotIndex } = slot;\n const activityId = activity.id;\n const restored =\n seedsApply && responses !== undefined && Object.hasOwn(responses, slotId)\n ? responses[slotId]\n : undefined;\n const slotOutcome =\n outcomes !== undefined && Object.hasOwn(outcomes, slotId) ? outcomes[slotId] : undefined;\n const slotBinding = bindingFor(slotMediaKey(slotId), slot);\n const calls = callsFor(slot);\n const childProps = {\n // `defaultValue`, not `value`: the learner must be able to keep editing\n // a restored answer. A controlled `value` would freeze it unless the\n // consumer also threaded state back, which is not what resume means.\n ...(restored !== undefined ? { defaultValue: restored } : {}),\n ...(seedsApply && submitted.has(slotId) ? { defaultSubmitted: true } : {}),\n ...(slotOutcome !== undefined ? { outcome: slotOutcome } : {}),\n // One identity per slot for the life of the set — see `callsFor`. Their\n // bodies are `submitSlot` and `completeSlot`, the same ones a host's own\n // renderer calls, so a question the host draws is recorded exactly as one\n // the SDK draws.\n onComplete: calls.onComplete,\n onSubmit: calls.onSubmit,\n ...forwarded,\n ...(slotBinding !== undefined ? { mediaBudget: slotBinding } : {}),\n };\n\n const CustomRenderer = renderers?.[activity.type];\n if (CustomRenderer) {\n const portalKey = slotKeyOf(setKey, slot);\n return (\n <>\n <CustomRenderer\n data={activity}\n {...childProps}\n question={{\n slot: calls.slot,\n active: slotIndex === index,\n portalContainer: portals.get(portalKey) ?? null,\n clear: calls.clear,\n setPending: calls.setPending,\n emit: calls.emit,\n }}\n />\n {/*\n After the question, so a popover portalled into it paints above.\n Inside the pane, so it is hidden with the question and painted with\n it in fullscreen — the two things portalling into `document.body`\n gets wrong here.\n */}\n <div className=\"lk-seq-portal\" ref={portalRefFor(portalKey)} />\n </>\n );\n }\n if (activity.type === 'multiple-choice') {\n return (\n <MultipleChoice\n data={activity}\n // The sequence seed reaches the OPTION shuffle too. Without it a\n // resumed or reviewed item invented a fresh per-mount order, so the\n // learner saw their answers against a different arrangement than the\n // one they sat — the exact reproducibility the attempt id is for.\n {...(shuffleSeed !== undefined ? { shuffleSeed } : {})}\n {...childProps}\n />\n );\n }\n if (activity.type === 'fill-in-the-blanks') {\n return <FillInTheBlanks data={activity} {...childProps} />;\n }\n if (activity.type === 'gap-select') {\n return (\n <GapSelect\n data={activity}\n // The sequence seed reaches the per-gap choice shuffle too, for the\n // same reason it reaches MultipleChoice's options: a resumed or\n // reviewed item that dealt a fresh order would show the learner\n // their answers against an arrangement they never sat.\n {...(shuffleSeed !== undefined ? { shuffleSeed } : {})}\n {...childProps}\n />\n );\n }\n if (activity.type === 'dictation') {\n // Nothing to seed: a dictation shuffles nothing. Outside `practice` its\n // raw response is recorded through `onSubmit` above, like MC/FIB/GS.\n return <Dictation data={activity} {...childProps} />;\n }\n if (activity.type === 'read-aloud') {\n const slotRecordingBinding = recordingBindingFor(slot);\n const slotAssessment =\n assessments !== undefined && Object.hasOwn(assessments, slotId)\n ? assessments[slotId]\n : undefined;\n return (\n <ReadAloud\n data={activity}\n // The whole bag, nothing subtracted — unlike the written-response\n // branch below, which drops `onComplete` because it never grades. A\n // read-aloud needs it in `practice`, where a returned grade is a\n // score like any other, and simply never calls it in `exam`.\n {...childProps}\n // No capture group here: the slot's pane hands it down through\n // `SequenceSlotContext`, so it is no prop of the public component.\n {...(slotRecordingBinding !== undefined\n ? { recordingBinding: slotRecordingBinding }\n : {})}\n {...(slotAssessment !== undefined ? { assessment: slotAssessment } : {})}\n {...(workletUrl !== undefined ? { workletUrl } : {})}\n />\n );\n }\n if (activity.type === 'written-response') {\n // Derived from the SAME bag the other two get, minus the one prop this\n // component genuinely does not have. Listing the props by hand is what\n // made this the branch left behind three separate times —\n // `defaultSubmitted`, the redacted-in-`practice` guard and the media\n // budget were each added to `childProps` and each silently missed here.\n // Subtracting from the shared bag cannot forget a prop that is added to\n // it; listing them can.\n const { onComplete: _neverGrades, ...writtenResponseProps } = childProps;\n return (\n <WrittenResponse\n data={activity}\n {...writtenResponseProps}\n onSubmitted={(submission) =>\n record(\n { kind: 'submitted', index: slotIndex, slotId, activityId, submission },\n setGeneration,\n )\n }\n />\n );\n }\n return (\n <div className=\"lk-seq-unsupported\" role=\"note\">\n {s.unsupportedActivity}\n </div>\n );\n };\n\n const currentEntryKey = entryKeyOf(current);\n\n return (\n <div className=\"lk-seq\" lang={locale}>\n <div className=\"lk-seq-progress\" aria-live=\"polite\" role=\"status\">\n {s.questionProgress(index + 1, total)}\n </div>\n\n {/*\n Each group's stimulus is mounted ONCE and only hidden while the current\n question is outside its group. That — not re-rendering it per slot — is\n what makes the passage the same DOM node throughout, and what lets a\n recording keep its position between questions of one group.\n\n It sits BESIDE the question region, not inside it. Inside, every\n navigation dropped focus onto a container whose first content was the\n whole passage: the region promised \"Question 3 of 5\" and then began\n with the passage, keyboard users tabbed through the stimulus (audio\n controls included) before reaching the question, and the passage was a\n landmark nested inside another landmark. As a sibling it stays a\n landmark the learner can jump back to, while focus lands on the\n question that was actually navigated to.\n */}\n {stimulusMounts.map(({ entryKey, group, first, last }) => {\n // `setKey` leads for the same reason it does on a slot pane: entry keys\n // are short and repeat across papers, so a set change to a DIFFERENT\n // paper that happens to reuse an entry key would not remount this\n // panel — and a mount-only budget seed would leak into the next paper.\n const firstSlot = slots[first];\n const stimulusBinding =\n firstSlot === undefined\n ? undefined\n : bindingFor(stimulusMediaKey(firstSlot.slotId), firstSlot);\n return (\n <SequencePane\n className=\"lk-seq-stimulus\"\n hidden={entryKey !== currentEntryKey}\n key={`${setKey}::group-${entryKey}`}\n >\n <StimulusPanel\n stimulus={group.stimulus}\n range={{ first: first + 1, last: last + 1 }}\n renderMode={renderMode}\n {...(sanitizeHtml ? { sanitizeHtml } : {})}\n {...(locale ? { locale } : {})}\n {...(onInteraction ? { onInteraction } : {})}\n {...(disabled ? { disabled } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(stimulusBinding !== undefined ? { mediaBudget: stimulusBinding } : {})}\n />\n </SequencePane>\n );\n })}\n\n <section\n className=\"lk-seq-question\"\n ref={regionRef}\n tabIndex={-1}\n aria-label={s.questionProgress(index + 1, total)}\n >\n {/*\n Every slot stays MOUNTED; only the current one is visible. Rendering\n just the current activity unmounted the others, so navigating back to\n an answered question showed it blank and re-answerable — the learner\n silently lost their answer and a second submit fired completion\n again. `hidden` removes the inactive slots from the accessibility\n tree and from tab order, so only the current question is reachable.\n */}\n {slots.map((slot) => {\n // The slot id (authored position) plus the activity id: the same\n // activity may legitimately fill two slots, and each must keep its\n // own answer state; and a different activity in the same slot must\n // remount rather than inherit the previous one's state.\n //\n // `setKey` leads, so a set change remounts every child. Without it a\n // pure REORDER changed `setKey` — clearing the outcomes — while each\n // child kept its key and therefore its `completed` state. Those\n // slots could not be answered again and no outcome would ever refill\n // them, so the sequence could never finish. A reset has to reset\n // both halves or neither. A parent re-creating a structurally\n // identical array leaves `setKey` untouched, so answers still\n // survive that.\n const slotKey = slotKeyOf(setKey, slot);\n return (\n <SequencePane\n className=\"lk-seq-slot\"\n hidden={slot.index !== index}\n // A channel for every slot, not just the ones that record: its\n // capture group is empty until something joins it, and a pane\n // that asked whether its activity records would have to know the\n // type of a renderer the consumer supplied.\n channel={channelFor(slot)}\n key={slotKey}\n >\n {renderSlot(slot)}\n </SequencePane>\n );\n })}\n </section>\n\n <div className=\"lk-seq-nav\">\n <button\n type=\"button\"\n className=\"lk-seq-prev\"\n onClick={() => go(index - 1)}\n disabled={index === 0}\n >\n {s.previous}\n </button>\n <button\n type=\"button\"\n className=\"lk-seq-next\"\n onClick={() => go(index + 1)}\n disabled={index === total - 1}\n >\n {s.next}\n </button>\n </div>\n </div>\n );\n}\n"]}
|
package/dist/chunk-QRT2W5N5.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useAiExplanation, useAiHints } from './chunk-YIYMBCPV.js';
|
|
3
|
-
import { useRef, useEffect } from 'react';
|
|
4
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
function situation(input) {
|
|
7
|
-
const { data, response, submitted, renderMode, ai, locale, onInteraction } = input;
|
|
8
|
-
return {
|
|
9
|
-
data,
|
|
10
|
-
response,
|
|
11
|
-
submitted,
|
|
12
|
-
renderMode,
|
|
13
|
-
...ai !== void 0 ? { ai } : {},
|
|
14
|
-
...locale !== void 0 ? { locale } : {},
|
|
15
|
-
...onInteraction !== void 0 ? { onInteraction } : {}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function AiExplanation({
|
|
19
|
-
outcome,
|
|
20
|
-
...rest
|
|
21
|
-
}) {
|
|
22
|
-
const s = rest.strings;
|
|
23
|
-
const help = useAiExplanation({
|
|
24
|
-
...situation(rest),
|
|
25
|
-
...outcome !== void 0 ? { outcome } : {}
|
|
26
|
-
});
|
|
27
|
-
const buttonRef = useRef(null);
|
|
28
|
-
const panelRef = useRef(null);
|
|
29
|
-
const refocus = useRef(false);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (help.status === "shown" && refocus.current) {
|
|
32
|
-
refocus.current = false;
|
|
33
|
-
panelRef.current?.focus();
|
|
34
|
-
}
|
|
35
|
-
if (help.status === "unavailable") {
|
|
36
|
-
refocus.current = false;
|
|
37
|
-
}
|
|
38
|
-
}, [help.status]);
|
|
39
|
-
if (!help.offered) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
const ask = () => {
|
|
43
|
-
refocus.current = typeof document !== "undefined" && document.activeElement === buttonRef.current;
|
|
44
|
-
help.ask();
|
|
45
|
-
};
|
|
46
|
-
const loading = help.status === "loading";
|
|
47
|
-
return /* @__PURE__ */ jsxs("div", { className: "lk-ai", "data-state": help.status, children: [
|
|
48
|
-
help.explanation === null ? /* @__PURE__ */ jsx(
|
|
49
|
-
"button",
|
|
50
|
-
{
|
|
51
|
-
ref: buttonRef,
|
|
52
|
-
type: "button",
|
|
53
|
-
className: "lk-ai-button",
|
|
54
|
-
"aria-busy": loading || void 0,
|
|
55
|
-
"aria-disabled": loading || void 0,
|
|
56
|
-
onClick: ask,
|
|
57
|
-
children: loading ? s.aiExplaining : s.aiExplain
|
|
58
|
-
}
|
|
59
|
-
) : null,
|
|
60
|
-
/* @__PURE__ */ jsx("div", { "aria-live": "polite", children: help.explanation !== null ? /* @__PURE__ */ jsxs(
|
|
61
|
-
"section",
|
|
62
|
-
{
|
|
63
|
-
ref: panelRef,
|
|
64
|
-
className: "lk-ai-panel",
|
|
65
|
-
tabIndex: -1,
|
|
66
|
-
"aria-label": s.aiExplanation,
|
|
67
|
-
children: [
|
|
68
|
-
/* @__PURE__ */ jsx("p", { className: "lk-ai-heading", children: s.aiExplanation }),
|
|
69
|
-
/* @__PURE__ */ jsx("p", { className: "lk-ai-text", children: help.explanation.text }),
|
|
70
|
-
/* @__PURE__ */ jsx("p", { className: "lk-ai-notice", children: s.aiNotice })
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
) : help.status === "unavailable" ? /* @__PURE__ */ jsx("p", { className: "lk-ai-unavailable", children: s.aiExplanationUnavailable }) : null })
|
|
74
|
-
] });
|
|
75
|
-
}
|
|
76
|
-
function AiHints({ disabled, ...rest }) {
|
|
77
|
-
const s = rest.strings;
|
|
78
|
-
const help = useAiHints({ ...situation(rest), disabled });
|
|
79
|
-
const used = help.used;
|
|
80
|
-
if (rest.ai?.hint === void 0 || !help.offered && used === 0) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const loading = help.status === "loading";
|
|
84
|
-
return /* @__PURE__ */ jsxs("div", { className: "lk-ai lk-ai-hint-area", "data-state": help.status, children: [
|
|
85
|
-
/* @__PURE__ */ jsxs("div", { "aria-live": "polite", children: [
|
|
86
|
-
used > 0 ? /* @__PURE__ */ jsx("ol", { className: "lk-ai-hints", "aria-label": s.aiHints, children: help.hints.map((hint, index) => (
|
|
87
|
-
// Hints are only ever appended, so a position is a stable key.
|
|
88
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: an append-only list
|
|
89
|
-
/* @__PURE__ */ jsxs("li", { className: "lk-ai-hint", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("span", { className: "lk-ai-hint-label", children: s.aiHintNumber(index + 1) }),
|
|
91
|
-
" ",
|
|
92
|
-
/* @__PURE__ */ jsx("span", { className: "lk-ai-text", children: hint.text })
|
|
93
|
-
] }, index)
|
|
94
|
-
)) }) : null,
|
|
95
|
-
help.status === "unavailable" ? /* @__PURE__ */ jsx("p", { className: "lk-ai-unavailable", children: s.aiHintUnavailable }) : null
|
|
96
|
-
] }),
|
|
97
|
-
help.offered ? used < help.limit ? /* @__PURE__ */ jsx(
|
|
98
|
-
"button",
|
|
99
|
-
{
|
|
100
|
-
type: "button",
|
|
101
|
-
className: "lk-ai-button",
|
|
102
|
-
"aria-busy": loading || void 0,
|
|
103
|
-
"aria-disabled": loading || void 0,
|
|
104
|
-
onClick: help.ask,
|
|
105
|
-
children: loading ? s.aiHintLoading : s.aiHint
|
|
106
|
-
}
|
|
107
|
-
) : /* @__PURE__ */ jsx("p", { className: "lk-ai-note", children: s.aiNoMoreHints }) : null,
|
|
108
|
-
used > 0 ? /* @__PURE__ */ jsx("p", { className: "lk-ai-notice", children: s.aiNotice }) : null
|
|
109
|
-
] });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export { AiExplanation, AiHints };
|
|
113
|
-
//# sourceMappingURL=chunk-QRT2W5N5.js.map
|
|
114
|
-
//# sourceMappingURL=chunk-QRT2W5N5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/shared/AiHelp.tsx"],"names":[],"mappings":";;;;AAuBA,SAAS,UAAU,KAAA,EAQjB;AACA,EAAA,MAAM,EAAE,MAAM,QAAA,EAAU,SAAA,EAAW,YAAY,EAAA,EAAI,MAAA,EAAQ,eAAc,GAAI,KAAA;AAC7E,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAI,EAAA,KAAO,MAAA,GAAY,EAAE,EAAA,KAAO,EAAC;AAAA,IACjC,GAAI,MAAA,KAAW,MAAA,GAAY,EAAE,MAAA,KAAW,EAAC;AAAA,IACzC,GAAI,aAAA,KAAkB,MAAA,GAAY,EAAE,aAAA,KAAkB;AAAC,GACzD;AACF;AASO,SAAS,aAAA,CAAc;AAAA,EAC5B,OAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAqD;AACnD,EAAA,MAAM,IAAI,IAAA,CAAK,OAAA;AACf,EAAA,MAAM,OAAO,gBAAA,CAAiB;AAAA,IAC5B,GAAG,UAAU,IAAI,CAAA;AAAA,IACjB,GAAI,OAAA,KAAY,MAAA,GAAY,EAAE,OAAA,KAAY;AAAC,GAC5C,CAAA;AACD,EAAA,MAAM,SAAA,GAAY,OAA0B,IAAI,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW,OA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,CAAA,CAAE;AAAA;AAAA,wBAGjC,GAAA,CAAC,GAAA,EAAA,EAAE,WAAU,YAAA,EAAc,QAAA,EAAA,CAAA,CAAE,eAAc,CAAA,GAE3C,IAAA;AAAA,IACH,IAAA,GAAO,oBAAI,GAAA,CAAC,GAAA,EAAA,EAAE,WAAU,cAAA,EAAgB,QAAA,EAAA,CAAA,CAAE,UAAS,CAAA,GAAO;AAAA,GAAA,EAC7D,CAAA;AAEJ","file":"chunk-QRT2W5N5.js","sourcesContent":["'use client';\n\nimport type { InteractionEvent, ItemOutcome, LearnerResponse } from '@intellectif/lk-core';\nimport { useEffect, useRef } from 'react';\nimport type { LearnerAi } from '../../ai/LkAiProvider.js';\nimport { useAiExplanation, useAiHints } from '../../ai/useAiHelp.js';\nimport type { LkStrings } from '../../i18n/strings.js';\nimport type { RenderableActivity, RenderMode } from '../types.js';\n\ninterface Situation {\n ai: LearnerAi | undefined;\n data: RenderableActivity;\n renderMode: RenderMode;\n submitted: boolean;\n /** The learner's answer as it stands: submitted, restored, or being written. */\n response: LearnerResponse;\n /** The component's `locale`, the default language for what is written. */\n locale: string | undefined;\n onInteraction: ((event: InteractionEvent) => void) | undefined;\n strings: LkStrings;\n}\n\n/** What the hooks take, from what a component holds: the optional half, without `undefined` values. */\nfunction situation(input: Situation): {\n data: RenderableActivity;\n response: LearnerResponse;\n submitted: boolean;\n renderMode: RenderMode;\n ai?: LearnerAi;\n locale?: string;\n onInteraction?: (event: InteractionEvent) => void;\n} {\n const { data, response, submitted, renderMode, ai, locale, onInteraction } = input;\n return {\n data,\n response,\n submitted,\n renderMode,\n ...(ai !== undefined ? { ai } : {}),\n ...(locale !== undefined ? { locale } : {}),\n ...(onInteraction !== undefined ? { onInteraction } : {}),\n };\n}\n\n/**\n * \"Explain my answer\": the SDK's own surface over {@link useAiExplanation} — a\n * button, the explanation with who wrote it, and \"not available\" when a call\n * fails or its answer is refused.\n *\n * Nothing renders without a port, or where the rules say no explanation.\n */\nexport function AiExplanation({\n outcome,\n ...rest\n}: Situation & { outcome: ItemOutcome | undefined }) {\n const s = rest.strings;\n const help = useAiExplanation({\n ...situation(rest),\n ...(outcome !== undefined ? { outcome } : {}),\n });\n const buttonRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLElement>(null);\n const refocus = useRef(false);\n\n // The button that asked goes away when the explanation arrives; focus moves\n // to what it asked for rather than falling to the page.\n useEffect(() => {\n if (help.status === 'shown' && refocus.current) {\n refocus.current = false;\n panelRef.current?.focus();\n }\n if (help.status === 'unavailable') {\n refocus.current = false;\n }\n }, [help.status]);\n\n if (!help.offered) {\n return null;\n }\n\n const ask = (): void => {\n refocus.current =\n typeof document !== 'undefined' && document.activeElement === buttonRef.current;\n help.ask();\n };\n\n const loading = help.status === 'loading';\n return (\n <div className=\"lk-ai\" data-state={help.status}>\n {help.explanation === null ? (\n <button\n ref={buttonRef}\n type=\"button\"\n className=\"lk-ai-button\"\n aria-busy={loading || undefined}\n aria-disabled={loading || undefined}\n onClick={ask}\n >\n {loading ? s.aiExplaining : s.aiExplain}\n </button>\n ) : null}\n <div aria-live=\"polite\">\n {help.explanation !== null ? (\n <section\n ref={panelRef}\n className=\"lk-ai-panel\"\n tabIndex={-1}\n aria-label={s.aiExplanation}\n >\n <p className=\"lk-ai-heading\">{s.aiExplanation}</p>\n <p className=\"lk-ai-text\">{help.explanation.text}</p>\n <p className=\"lk-ai-notice\">{s.aiNotice}</p>\n </section>\n ) : help.status === 'unavailable' ? (\n <p className=\"lk-ai-unavailable\">{s.aiExplanationUnavailable}</p>\n ) : null}\n </div>\n </div>\n );\n}\n\n/**\n * \"Get a hint\": the SDK's own surface over {@link useAiHints} — a button, the\n * hints given so far as a numbered list, and who wrote them.\n *\n * The hints stay listed after submit, so the learner can see what they were\n * given, but no more can be asked for. Another question starts with none.\n */\nexport function AiHints({ disabled, ...rest }: Situation & { disabled: boolean }) {\n const s = rest.strings;\n const help = useAiHints({ ...situation(rest), disabled });\n const used = help.used;\n\n if (rest.ai?.hint === undefined || (!help.offered && used === 0)) {\n return null;\n }\n\n const loading = help.status === 'loading';\n return (\n <div className=\"lk-ai lk-ai-hint-area\" data-state={help.status}>\n <div aria-live=\"polite\">\n {used > 0 ? (\n <ol className=\"lk-ai-hints\" aria-label={s.aiHints}>\n {help.hints.map((hint, index) => (\n // Hints are only ever appended, so a position is a stable key.\n // biome-ignore lint/suspicious/noArrayIndexKey: an append-only list\n <li key={index} className=\"lk-ai-hint\">\n <span className=\"lk-ai-hint-label\">{s.aiHintNumber(index + 1)}</span>{' '}\n <span className=\"lk-ai-text\">{hint.text}</span>\n </li>\n ))}\n </ol>\n ) : null}\n {help.status === 'unavailable' ? (\n <p className=\"lk-ai-unavailable\">{s.aiHintUnavailable}</p>\n ) : null}\n </div>\n {help.offered ? (\n used < help.limit ? (\n <button\n type=\"button\"\n className=\"lk-ai-button\"\n aria-busy={loading || undefined}\n aria-disabled={loading || undefined}\n onClick={help.ask}\n >\n {loading ? s.aiHintLoading : s.aiHint}\n </button>\n ) : (\n <p className=\"lk-ai-note\">{s.aiNoMoreHints}</p>\n )\n ) : null}\n {used > 0 ? <p className=\"lk-ai-notice\">{s.aiNotice}</p> : null}\n </div>\n );\n}\n"]}
|
package/dist/chunk-RCMYEWBE.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
|
|
4
|
-
// src/components/shared/FeedbackRegion.tsx
|
|
5
|
-
function FeedbackRegion({ id, className, children }) {
|
|
6
|
-
return /* @__PURE__ */ jsx("div", { id, className, "aria-live": "polite", "aria-atomic": "true", children });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { FeedbackRegion };
|
|
10
|
-
//# sourceMappingURL=chunk-RCMYEWBE.js.map
|
|
11
|
-
//# sourceMappingURL=chunk-RCMYEWBE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/shared/FeedbackRegion.tsx"],"names":[],"mappings":";;;AAcO,SAAS,cAAA,CAAe,EAAE,EAAA,EAAI,SAAA,EAAW,UAAS,EAAwB;AAC/E,EAAA,uBACE,GAAA,CAAC,SAAI,EAAA,EAAQ,SAAA,EAAsB,aAAU,QAAA,EAAS,aAAA,EAAY,QAC/D,QAAA,EACH,CAAA;AAEJ","file":"chunk-RCMYEWBE.js","sourcesContent":["import type { ReactNode } from 'react';\n\nexport interface FeedbackRegionProps {\n /** Identifier so activity inputs can reference this region via aria. */\n id?: string;\n className?: string;\n children?: ReactNode;\n}\n\n/**\n * A polite ARIA live region. Screen readers announce content injected here\n * (score, feedback, state changes) without moving focus. Pure/presentational\n * — safe to render in any environment.\n */\nexport function FeedbackRegion({ id, className, children }: FeedbackRegionProps) {\n return (\n <div id={id} className={className} aria-live=\"polite\" aria-atomic=\"true\">\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/FillInTheBlanks/FillInTheBlanks.tsx","../src/components/FillInTheBlanks/index.tsx"],"names":["result","FillInTheBlanks","jsx"],"mappings":";;;;;;;;;;;;AAwCA,IAAM,WAAA,GAAc,0BAAA;AAIpB,SAAS,aAAa,OAAA,EAA4B;AAChD,EAAA,MAAM,WAAsB,EAAC;AAC7B,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAO,WAAW,CAAA;AACjC,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,OAAA,GAAU,CAAA;AACd,EAAA,IAAI,KAAA,GAAQ,EAAA,CAAG,IAAA,CAAK,OAAO,CAAA;AAC3B,EAAA,OAAO,UAAU,IAAA,EAAM;AACrB,IAAA,IAAI,KAAA,CAAM,QAAQ,IAAA,EAAM;AACtB,MAAA,QAAA,CAAS,IAAA,CAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,KAAA,EAAO,OAAA,CAAQ,KAAA,CAAM,IAAA,EAAM,KAAA,CAAM,KAAK,CAAA,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AG3D,EAAA,MAAM,OAAA,GAAU,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC1C,EAAA,uBACEC,GAAAA,CAAC,qBAAA,EAAA,EAAsB,aAAA,EAAe,KAAA,CAAM,IAAA,EAAM,KAAA,EAAO,OAAA,EACvD,QAAA,kBAAAA,GAAAA,CAAC,eAAA,EAAA,EAAqB,GAAG,OAAO,CAAA,EAClC,CAAA;AAEJ","file":"chunk-SEQTGOOU.js","sourcesContent":["'use client';\n\nimport {\n ActivitySchemaError,\n assertRedacted,\n type FillInTheBlanksData,\n type FillInTheBlanksLearnerResponse,\n type LearnerResponse,\n type ScoringDetail,\n type ScoringResult,\n score,\n validateActivity,\n xAPIBuilder,\n xapiDefinitionFor,\n} from '@intellectif/lk-core';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { useLearnerAi } from '../../ai/LkAiProvider.js';\nimport { useActivityState } from '../../hooks/useActivityState.js';\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ANONYMOUS_ACTOR, isDevelopment, objectIdFor } from '../_internal.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport { AiExplanation, AiHints } from '../shared/AiHelp.js';\nimport { FeedbackRegion } from '../shared/FeedbackRegion.js';\nimport type { ActivityProps } from '../types.js';\n\nexport interface FillInTheBlanksProps extends ActivityProps<FillInTheBlanksData> {\n /**\n * After submission, replace each incorrectly-answered blank with its first\n * accepted answer, styled distinctly (Req 5.7). Component-specific prop: it\n * is presentation, not activity data, and is outside the fixed Req-3.1 set.\n *\n * Ignored in `exam` mode — revealing the key is precisely what an exam must\n * not do, and on a `redact()` projection there is no key to reveal. In\n * `review` mode it applies only to blanks the supplied `outcome` marks\n * incorrect, and only when the caller passed data that still carries the key\n * (e.g. `redact(data, { reveal: 'after-submit' })`).\n */\n showCorrectAnswers?: boolean;\n}\n\nconst PLACEHOLDER = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\n\ntype Segment = { kind: 'text'; value: string } | { kind: 'blank'; id: string; ordinal: number };\n\nfunction parsePassage(passage: string): Segment[] {\n const segments: Segment[] = [];\n const re = new RegExp(PLACEHOLDER);\n let last = 0;\n let ordinal = 0;\n let match = re.exec(passage);\n while (match !== null) {\n if (match.index > last) {\n segments.push({ kind: 'text', value: passage.slice(last, match.index) });\n }\n ordinal += 1;\n segments.push({ kind: 'blank', id: match[1] as string, ordinal });\n last = match.index + match[0].length;\n match = re.exec(passage);\n }\n if (last < passage.length) {\n segments.push({ kind: 'text', value: passage.slice(last) });\n }\n return segments;\n}\n\n/** Shared empty map: keeps the \"no response supplied\" path allocation-free. */\nconst NO_ANSWERS: Record<string, string> = {};\n\n/**\n * Reads the answer map out of a `LearnerResponse`. A response of another\n * activity type is treated as \"no answers\" rather than throwing: a controlled\n * host that has not yet swapped its state on an activity change would\n * otherwise crash the attempt.\n */\nfunction answersOf(response: LearnerResponse | undefined): Record<string, string> {\n return response !== undefined && response.type === 'fill-in-the-blanks'\n ? response.answers\n : NO_ANSWERS;\n}\n\n/**\n * Per-item correctness keyed by blank id. Prefers the unambiguous `outcome`\n * field (always written by the built-in scorers since lk-core 0.3.0) and\n * falls back to the deprecated `correct` boolean so a 0.2-era\n * consumer-constructed `ItemOutcome` still marks correctly in `review`.\n */\nfunction correctnessByItem(details: readonly ScoringDetail[]): Map<string, boolean> {\n const map = new Map<string, boolean>();\n for (const detail of details) {\n map.set(\n detail.itemId,\n detail.outcome !== undefined ? detail.outcome === 'correct' : detail.correct,\n );\n }\n return map;\n}\n\nexport function FillInTheBlanks({\n data,\n onComplete,\n onSubmit,\n onChange,\n onInteraction,\n value,\n defaultValue,\n defaultSubmitted,\n renderMode = 'practice',\n outcome,\n sanitizeHtml,\n mediaBudget,\n mediaStrings,\n strings,\n theme,\n locale,\n disabled,\n showCorrectAnswers,\n ai: aiProp,\n}: FillInTheBlanksProps) {\n const isExam = renderMode === 'exam';\n const isReview = renderMode === 'review';\n\n // Dev-only boundary validation (Req 2.3); throws in render so the wrapping\n // ActivityErrorBoundary catches it. Re-runs only when data changes.\n const s = useLkStrings(strings);\n const ai = useLearnerAi(aiProp);\n\n const devError = useMemo(() => {\n if (!isDevelopment()) {\n return null;\n }\n if (data.redacted === true) {\n // A redact() projection cannot satisfy the full content schema — the\n // answer key is gone by design. Validate it against the STRICT redacted\n // schema instead, which additionally proves the payload is learner-safe.\n try {\n assertRedacted(data);\n return null;\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n }\n const result = validateActivity('fill-in-the-blanks', data);\n return result.success ? null : new ActivitySchemaError('fill-in-the-blanks', result.errors);\n }, [data]);\n\n const { state, start, complete, getTimeSpent, reset } = useActivityState(\n defaultSubmitted === true ? 'completed' : 'idle',\n );\n // Controlled when `value` is supplied: the answers rendered are ALWAYS the\n // caller's, and internal state is never read. Uncontrolled otherwise,\n // seeded from `defaultValue`.\n const isControlled = value !== undefined;\n const [internalAnswers, setInternalAnswers] = useState<Record<string, string>>(() =>\n answersOf(defaultValue),\n );\n const [revealed, setRevealed] = useState<Set<string>>(() => new Set());\n const [result, setResult] = useState<ScoringResult | null>(null);\n const [summary, setSummary] = useState<string | null>(null);\n const [feedbackHidden, setFeedbackHidden] = useState(false);\n\n const answers = isControlled ? answersOf(value) : internalAnswers;\n\n // `defaultValue` is read only by the reset effect, and it is commonly an\n // inline object literal — putting it in that effect's deps would re-seed\n // (and wipe) the learner's typing on every render. Mirror it into a ref in\n // its own effect, which commits before the reset effect below.\n const defaultValueRef = useRef(defaultValue);\n useEffect(() => {\n defaultValueRef.current = defaultValue;\n }, [defaultValue]);\n\n // Mirror `defaultSubmitted` so the reset below returns to the SEEDED state.\n // Resetting unconditionally to idle unlocked an item the learner had already\n // committed — which made `defaultSubmitted` a no-op here, since this effect\n // runs right after the first paint.\n const defaultSubmittedRef = useRef(defaultSubmitted);\n useEffect(() => {\n defaultSubmittedRef.current = defaultSubmitted;\n }, [defaultSubmitted]);\n\n // Identity guard so the MOUNT run is a no-op. Without it this effect fires\n // after the first paint and undoes every seed it was just given; with it,\n // only a real `data` change resets. A parent that rebuilds structurally\n // identical entries in render (`activities={raw.map(redact)}`) must not\n // unlock or revert a restored answer — the pager already remounts a slot\n // whose activity actually changed, via its key.\n const lastDataRef = useRef(data);\n // `data` is an intentional reset trigger (Req 3.7); it is already in the\n // dependency list. The identity guard below skips the mount run.\n useEffect(() => {\n if (lastDataRef.current === data) {\n return;\n }\n lastDataRef.current = data;\n setInternalAnswers(answersOf(defaultValueRef.current));\n setRevealed(new Set());\n setResult(null);\n setSummary(null);\n setFeedbackHidden(false);\n reset(defaultSubmittedRef.current === true ? 'completed' : 'idle');\n }, [data, reset]);\n\n /*\n * RICH TEXT — deliberate, documented limitation (see `sanitizeHtml`).\n *\n * Every other activity can render its `*Html` field through the caller's\n * sanitiser, because the rich text is a LEAF: the sanitised string is\n * handed to one `dangerouslySetInnerHTML` node and nothing is inserted into\n * it. A fill-in-the-blanks passage is not a leaf — it is the CONTAINER of\n * the React-controlled `<input>`s, one per `{{id}}` placeholder.\n *\n * Placing those inputs inside sanitised HTML means slicing the sanitised\n * string at the placeholders and injecting each slice as its own HTML\n * fragment, which is unsafe and broken on both counts:\n * 1. Broken: the slices are unbalanced. `<p>A {{x}} B</p>` yields `<p>A `\n * and ` B</p>`; the fragment parser auto-closes both, so the input\n * lands OUTSIDE the paragraph and the authored block structure is\n * destroyed.\n * 2. Unsafe: the sanitiser's guarantee covers the document it returned,\n * not arbitrary substrings of it. A placeholder inside an attribute\n * (`<img alt=\"{{x}}\">`) splits mid-attribute, and re-parsing the\n * halves in a fresh context is exactly the mutation (mXSS) class of\n * transformation that voids a sanitiser's output guarantee. An exam\n * runner must never depend on that.\n *\n * The safe alternative — parse the sanitised string once into a detached\n * DOM, split only TEXT nodes at placeholders, and portal the inputs into\n * anchors — needs a DOM at render time (no SSR) and a large imperative\n * subsystem. Until that lands, the plain-text `passage` is rendered (always\n * escaped by React), which is correct, answerable, and safe in every mode.\n * `data.passageHtml` is carried and redacted by lk-core regardless, so no\n * authored content is lost — only this component declines to render it.\n */\n useEffect(() => {\n if (isDevelopment() && sanitizeHtml !== undefined && data.passageHtml !== undefined) {\n console.warn(\n '[lk-react] FillInTheBlanks ignores `passageHtml`: the passage hosts the answer inputs, ' +\n 'so rich HTML cannot be split at {{placeholders}} without voiding the sanitiser. ' +\n 'Rendering the plain `passage` instead.',\n );\n }\n }, [sanitizeHtml, data.passageHtml]);\n\n const segments = useMemo(() => parsePassage(data.passage), [data.passage]);\n const blankById = useMemo(() => new Map(data.blanks.map((b) => [b.id, b])), [data.blanks]);\n\n if (devError) {\n throw devError;\n }\n // Practice grades locally, which a redacted projection cannot support: the\n // submit handler below calls `score()`, which throws RedactedScoringError —\n // from an event handler, where no error boundary can catch it, AFTER the\n // learner has typed their answers. Fail loudly at render instead, in\n // production too. This mirrors the identical guard in MultipleChoice;\n // without it the two built-ins disagreed about the same accident, and\n // wiring an exam item into the self-grading mode is precisely what\n // `renderMode` exists to prevent.\n if (data.redacted === true && renderMode === 'practice') {\n throw new Error(\n `Fill-in-the-Blanks \"${data.id}\" received redacted activity data in renderMode \"practice\", ` +\n 'which grades locally and has no answer key to grade against. ' +\n 'Render redacted data with renderMode=\"exam\" (server grades) or \"review\" (pass `outcome`).',\n );\n }\n\n const submitted = state === 'completed';\n const inactive = disabled === true || submitted || isReview;\n\n /**\n * Whether the component may show answer-key-derived information (per-blank\n * correctness, authored feedback, correct answers). NEVER in `exam`; in\n * `practice` only after the component scored locally; in `review` only once\n * the caller supplies a SCORED outcome — an item that is still awaiting a\n * grade must not have its key revealed just because it is being read back.\n */\n const revealing = isReview ? outcome?.status === 'scored' : !isExam && submitted;\n\n const fireInteraction = (\n type: 'blank-filled' | 'hint-requested' | 'submitted',\n payload: Record<string, unknown>,\n ): void => {\n onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });\n };\n\n const handleChange = (blankId: string, text: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n const next = { ...answers, [blankId]: text };\n if (!isControlled) {\n setInternalAnswers(next);\n }\n onChange?.({ type: 'fill-in-the-blanks', answers: next });\n fireInteraction('blank-filled', { blankId, value: text });\n };\n\n const toggleHint = (blankId: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n setRevealed((prev) => {\n const next = new Set(prev);\n if (next.has(blankId)) {\n next.delete(blankId);\n return next;\n }\n next.add(blankId);\n return next;\n });\n // Only a reveal is a \"hint requested\"; hiding is not a new request.\n if (!revealed.has(blankId)) {\n fireInteraction('hint-requested', { blankId });\n }\n };\n\n const handleSubmit = (event: React.FormEvent): void => {\n event.preventDefault();\n if (inactive) {\n return;\n }\n const response: FillInTheBlanksLearnerResponse = { type: 'fill-in-the-blanks', answers };\n // Fires in every submitting mode and always BEFORE onComplete, so an exam\n // runner can persist the raw response regardless of local grading.\n onSubmit?.(response);\n\n if (isExam) {\n // EXAM: the client neither grades nor reveals. No score()/evaluate(), no\n // read of any answer-key field, no onComplete — and no xAPI statement,\n // because its `correctResponsesPattern` IS the answer key. The server\n // owns the grade; it emits the statement.\n complete();\n setSummary(s.answerSubmitted);\n fireInteraction('submitted', { answers });\n return;\n }\n\n // PRACTICE: unchanged v1 behaviour. `data` carries the key here — exam\n // mode is the only path that may be handed a redact() projection.\n const scoringResult = score('fill-in-the-blanks', data as FillInTheBlanksData, response);\n complete();\n const timeSpent = getTimeSpent();\n const xapiStatement = xAPIBuilder.buildAnsweredStatement({\n actor: ANONYMOUS_ACTOR,\n object: {\n id: objectIdFor(data.id),\n name: { [data.locale ?? 'en-US']: data.title },\n ...xapiDefinitionFor(data),\n },\n scoringResult,\n timeSpentMs: timeSpent,\n response: JSON.stringify(answers),\n });\n setResult(scoringResult);\n onComplete?.({\n score: scoringResult.score,\n maxScore: scoringResult.maxScore,\n passed: scoringResult.passed,\n timeSpent,\n xapiStatement,\n });\n // Core selects the authored overall feedback on `passed` (B3 fix).\n const overall = scoringResult.feedback;\n setSummary(\n `${s.answerSubmitted} ${s.scoreAnnouncement(\n Math.round(scoringResult.score * 100),\n scoringResult.passed,\n )}${overall ? ` ${overall}` : ''}`,\n );\n fireInteraction('submitted', { answers, score: scoringResult.score });\n };\n\n const correctByBlank = useMemo(() => {\n if (isExam) {\n // Nothing is ever marked client-side in an exam.\n return new Map<string, boolean>();\n }\n if (isReview) {\n // Correctness comes ONLY from the server-computed outcome; the component\n // never scores in review, so an absent/ungraded outcome marks nothing.\n return outcome?.status === 'scored'\n ? correctnessByItem(outcome.details)\n : new Map<string, boolean>();\n }\n return correctnessByItem(result?.details ?? []);\n }, [isExam, isReview, outcome, result]);\n\n /** Review has no local score: its summary is read off `outcome`, or nothing. */\n const reviewSummary = useMemo(() => {\n if (!isReview || outcome === undefined) {\n return null;\n }\n if (outcome.status === 'scored') {\n return `${s.scoreAnnouncement(Math.round(outcome.score * 100), outcome.passed)}${\n outcome.feedback ? ` ${outcome.feedback}` : ''\n }`;\n }\n if (outcome.status === 'deferred') {\n return s.notGradedYet;\n }\n // `graded` used to fall into the arm below and announce \"No grade\n // available.\" over a grade that had come back. Normalised by maxScore so a\n // grader payload of 8.5 / 10 does not read as 850% — same guard as\n // `<WrittenResponse>`.\n if (outcome.status === 'graded') {\n const percent =\n outcome.maxScore > 0\n ? Math.round((outcome.score / outcome.maxScore) * 100)\n : Math.round(outcome.score * 100);\n return `${s.scoreAnnouncement(percent, outcome.passed)}${\n outcome.feedback ? ` ${outcome.feedback}` : ''\n }`;\n }\n return s.noGradeAvailable;\n }, [isReview, outcome, s]);\n\n return (\n <form\n className=\"lk-fib\"\n aria-label={data.title}\n lang={locale}\n data-render-mode={renderMode}\n style={theme as CSSProperties | undefined}\n onSubmit={handleSubmit}\n >\n {data.media ? (\n <ActivityMedia\n media={data.media}\n renderMode={renderMode}\n {...(mediaBudget !== undefined ? { mediaBudget } : {})}\n {...(mediaStrings !== undefined ? { mediaStrings } : {})}\n {...(strings !== undefined ? { strings } : {})}\n {...(onInteraction !== undefined ? { onInteraction } : {})}\n {...(locale !== undefined ? { locale } : {})}\n />\n ) : null}\n <fieldset disabled={inactive}>\n <p className=\"lk-fib-passage\">\n {segments.map((seg, i) => {\n if (seg.kind === 'text') {\n // biome-ignore lint/suspicious/noArrayIndexKey: passage segments are positional and static\n return <span key={`t${i}`}>{seg.value}</span>;\n }\n const blank = blankById.get(seg.id);\n if (!blank) {\n return null;\n }\n // `Renderable` only widens `scoringStrategy` at the type level, so\n // the answer-key fields still LOOK required here while a redact()\n // projection omits them at runtime. Read them defensively, and\n // never at all in exam mode.\n const acceptedAnswers: string[] | undefined = isExam\n ? undefined\n : blank.acceptedAnswers;\n const blankFeedback = isExam ? undefined : blank.feedback;\n const correctness = correctByBlank.get(seg.id);\n const hintId = `${data.id}-hint-${seg.id}`;\n const correctAnswer = acceptedAnswers?.[0];\n if (revealing && showCorrectAnswers && correctness === false && correctAnswer) {\n return (\n <span key={seg.id} className=\"lk-fib-answer\" data-correct=\"false\">\n {correctAnswer}\n </span>\n );\n }\n return (\n <span key={seg.id} className=\"lk-fib-blank\">\n <input\n type=\"text\"\n aria-label={s.blankLabel(seg.ordinal)}\n aria-describedby={blank.hint ? hintId : undefined}\n value={answers[seg.id] ?? ''}\n disabled={inactive}\n aria-disabled={inactive || undefined}\n data-correct={\n revealing && correctness !== undefined ? String(correctness) : undefined\n }\n onChange={(e) => handleChange(seg.id, e.target.value)}\n />\n {/*\n Hints stay available in exam mode by design: lk-core's field\n policy classifies `blanks.hint` as `public`, so it survives\n redact() and is not part of the answer key.\n */}\n {blank.hint ? (\n <>\n {/*\n Default affordance is an icon; the accessible NAME stays\n text via aria-label (screen readers + tests rely on it).\n The glyph is restylable/replaceable via .lk-fib-hint-btn.\n */}\n <button\n type=\"button\"\n className=\"lk-fib-hint-btn\"\n aria-controls={hintId}\n aria-expanded={revealed.has(seg.id)}\n aria-label={revealed.has(seg.id) ? s.hideHint : s.showHint}\n disabled={inactive}\n onClick={() => toggleHint(seg.id)}\n >\n <svg\n className=\"lk-fib-hint-icon\"\n viewBox=\"0 0 24 24\"\n width=\"16\"\n height=\"16\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 21h6v-1H9v1Zm3-19a7 7 0 0 0-4 12.74V17h8v-2.26A7 7 0 0 0 12 2Z\"\n />\n </svg>\n </button>\n {/*\n Not role=\"tooltip\": a real ARIA tooltip is a named\n hover/focus popup with strict WCAG 1.4.13 constraints.\n This is an accessible click-to-toggle disclosure that is\n the input's aria-describedby target and is announced via\n aria-live; the skin gives it a tooltip-like *visual*\n without the tooltip *semantics*. (Refines Task 15.3.)\n */}\n <span id={hintId} aria-live=\"polite\">\n {revealed.has(seg.id) ? blank.hint : ''}\n </span>\n </>\n ) : null}\n {revealing && !feedbackHidden && blankFeedback ? (\n <span\n className=\"lk-fib-blank-feedback\"\n role=\"note\"\n data-correct={correctness !== undefined ? String(correctness) : undefined}\n >\n {blankFeedback}\n </span>\n ) : null}\n </span>\n );\n })}\n </p>\n <AiHints\n ai={ai}\n data={data}\n renderMode={renderMode}\n submitted={submitted}\n disabled={disabled === true}\n response={{ type: 'fill-in-the-blanks', answers }}\n locale={locale}\n onInteraction={onInteraction}\n strings={s}\n />\n {/* Review is read-only: there is nothing to submit. */}\n {isReview ? null : (\n <button type=\"submit\" disabled={inactive}>\n {isExam ? s.submitAnswers : s.checkAnswers}\n </button>\n )}\n </fieldset>\n {revealing && data.blanks.some((b) => b.feedback) ? (\n <button\n type=\"button\"\n className=\"lk-fib-feedback-toggle\"\n aria-expanded={!feedbackHidden}\n onClick={() => setFeedbackHidden((h) => !h)}\n >\n {feedbackHidden ? s.showFeedback : s.hideFeedback}\n </button>\n ) : null}\n <FeedbackRegion id={`${data.id}-feedback`}>\n {isReview ? reviewSummary : summary}\n </FeedbackRegion>\n <AiExplanation\n ai={ai}\n data={data}\n renderMode={renderMode}\n submitted={submitted}\n response={{ type: 'fill-in-the-blanks', answers }}\n outcome={outcome}\n locale={locale}\n onInteraction={onInteraction}\n strings={s}\n />\n </form>\n );\n}\n","'use client';\n\nimport { useLkStrings } from '../../i18n/LkIntlProvider.js';\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport {\n FillInTheBlanks as FillInTheBlanksCore,\n type FillInTheBlanksProps,\n} from './FillInTheBlanks.js';\n\nexport type { FillInTheBlanksProps } from './FillInTheBlanks.js';\n\n/**\n * Public Fill-in-the-Blanks activity: the core wrapped in\n * `ActivityErrorBoundary` so a render failure (incl. the dev schema-validation\n * throw) degrades to an accessible fallback instead of crashing the host.\n */\nexport function FillInTheBlanks(props: FillInTheBlanksProps) {\n // Read here rather than in the boundary: a class component cannot call a\n // hook, and the fallback it renders is learner-facing text like any other.\n const strings = useLkStrings(props.strings);\n return (\n <ActivityErrorBoundary activityTitle={props.data?.title} strings={strings}>\n <FillInTheBlanksCore {...props} />\n </ActivityErrorBoundary>\n );\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ai/rules.ts","../src/ai/useAiHelp.ts"],"names":["aiSupports","aiAllowedByContent","isDevelopment","useContext","SequenceSlotContext","useLearnerAi","useState","useRef","useEffect","useCallback","aiExplanationRequest","checkAiExplanation","aiHintRequest","checkAiHint"],"mappings":";;;;;;;;AAmBA,IAAM,iBAAA,GAAoB,CAAA;AAC1B,IAAM,iBAAA,GAAoB,EAAA;AAGnB,SAAS,UAAU,EAAA,EAAmC;AAC3D,EAAA,MAAM,QAAQ,EAAA,EAAI,QAAA;AAClB,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,IAAK,KAAA,IAAS,CAAA,GACpE,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,iBAAiB,CAAA,GACjC,iBAAA;AACN;AAOO,SAAS,YAAY,KAAA,EAKhB;AACV,EAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,SAAA,EAAW,UAAS,GAAI,KAAA;AA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A,CAAQ;AAAA;AACtB,WACD,CAAA;AACD,UAAA;AAAA,QACF;AACA,QAAA,QAAA,CAAS,CAAC,KAAA,MAAW;AAAA,UACnB,GAAG,KAAA;AAAA,UACH,KAAA,EAAO,KAAA,CAAM,GAAA,KAAQ,GAAA,GAAM,CAAC,GAAG,KAAA,CAAM,KAAA,EAAO,OAAA,CAAQ,MAAM,CAAA,GAAI,KAAA,CAAM,KAAA;AAAA,UACpE,MAAA,EAAQ;AAAA,SACV,CAAE,CAAA;AACF,QAAA,MAAA,CAAO,OAAA,CAAQ,MAAM,aAAA,GAAgB;AAAA,UACnC,IAAA,EAAM,eAAA;AAAA,UACN,UAAA,EAAY,GAAA,CAAI,KAAA,CAAM,IAAA,CAAK,EAAA;AAAA,UAC3B,SAAA,EAAW,KAAK,GAAA,EAAI;AAAA,UACpB,OAAA,EAAS,EAAE,UAAA,EAAY,OAAA,CAAQ,YAAY,GAAG,YAAA,CAAa,OAAA,CAAQ,MAAM,CAAA;AAAE,SAC5E,CAAA;AAAA,MACH,CAAA;AAAA,MACA,MAAM;AACJ,QAAA,IAAI,GAAA,CAAI,YAAY,IAAA,EAAM;AACxB,UAAA,QAAA,CAAS,CAAC,KAAA,MAAW,EAAE,GAAG,KAAA,EAAO,MAAA,EAAQ,eAAc,CAAE,CAAA;AAAA,QAC3D;AAAA,MACF;AAAA,KACF;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,QAAQ,OAAA,CAAQ,MAAA;AAAA,IAChB,OAAO,OAAA,CAAQ,KAAA;AAAA,IACf,KAAA;AAAA,IACA,IAAA,EAAM,QAAQ,KAAA,CAAM,MAAA;AAAA,IACpB;AAAA,GACF;AACF","file":"chunk-SXU26SFO.cjs","sourcesContent":["/**\n * When AI help is offered, and what the SDK does with what a port answers.\n *\n * Internal: these are the rules behind {@link useAiHints} and\n * {@link useAiExplanation}, which are what a host calls. They live apart from\n * the hooks so the hooks' module exports nothing but the hooks themselves.\n */\nimport {\n type AiRefusal,\n aiAllowedByContent,\n aiSupports,\n type ItemOutcome,\n type LearnerResponse,\n} from '@intellectif/lk-core';\nimport { isDevelopment } from '../components/_internal.js';\nimport type { RenderableActivity, RenderMode } from '../components/types.js';\nimport type { LearnerAi } from './LkAiProvider.js';\n\n/** The most hints a question gives when the host names no number, and the most it may name. */\nconst DEFAULT_MAX_HINTS = 3;\nconst MAX_HINTS_CEILING = 10;\n\n/** `maxHints` as a whole number from 1 to 10; anything else is the default. */\nexport function hintLimit(ai: LearnerAi | undefined): number {\n const asked = ai?.maxHints;\n return typeof asked === 'number' && Number.isInteger(asked) && asked >= 1\n ? Math.min(asked, MAX_HINTS_CEILING)\n : DEFAULT_MAX_HINTS;\n}\n\n/**\n * Whether the learner may ask for a hint: `practice`, before submit, on a\n * question that is not disabled, of a type that takes hints, whose author left\n * hints on, and whole — a redacted item is an exam's, and gives none.\n */\nexport function hintOffered(input: {\n data: RenderableActivity;\n renderMode: RenderMode;\n submitted: boolean;\n disabled: boolean;\n}): boolean {\n const { data, renderMode, submitted, disabled } = input;\n return (\n renderMode === 'practice' &&\n !submitted &&\n !disabled &&\n data.redacted !== true &&\n aiSupports(data.type, 'hint') &&\n aiAllowedByContent(data, 'hint')\n );\n}\n\n/**\n * Whether the learner may ask for an explanation: of a graded answer — in\n * `practice` once submitted, or in `review` when the grade of record is\n * scored — of a type the SDK explains, whose author left explanations on.\n * Never in `exam`.\n */\nexport function explanationOffered(input: {\n data: RenderableActivity;\n renderMode: RenderMode;\n submitted: boolean;\n outcome: ItemOutcome | undefined;\n}): boolean {\n const { data, renderMode, submitted, outcome } = input;\n const graded =\n (renderMode === 'practice' && submitted) ||\n (renderMode === 'review' && outcome?.status === 'scored');\n return graded && aiSupports(data.type, 'explanation') && aiAllowedByContent(data, 'explanation');\n}\n\n/** Calls a port, turning a synchronous throw into a rejection. */\nexport function callPort<T>(call: () => Promise<T>): Promise<T> {\n try {\n return Promise.resolve(call());\n } catch (error) {\n return Promise.reject(error);\n }\n}\n\n/** Tells a developer why a port's answer was not shown. Silent in production. */\nexport function warnRefused(\n feature: 'explanation' | 'hint',\n activityId: string,\n reason: AiRefusal,\n): void {\n if (isDevelopment()) {\n console.warn(\n `learning-kit: the AI ${feature} for \"${activityId}\" was not shown (${reason}). The learner saw \"not available\" instead.`,\n );\n }\n}\n\n/** The language to write in: the host's choice for the learner, else the interface language. */\nexport const localeOf = (\n ai: LearnerAi | undefined,\n locale: string | undefined,\n): { learnerLocale?: string } => {\n const chosen = ai?.learnerLocale ?? locale;\n return chosen === undefined ? {} : { learnerLocale: chosen };\n};\n\n/** What an explanation is about: when any of it changes, the explanation shown no longer is. */\nexport function explanationKey(\n renderMode: RenderMode,\n submitted: boolean,\n response: LearnerResponse,\n outcome: ItemOutcome | undefined,\n): string {\n let graded = '';\n if (outcome !== undefined) {\n graded = `${outcome.status}:${'score' in outcome ? outcome.score : ''}`;\n }\n return `${renderMode}|${submitted}|${graded}|${JSON.stringify(response)}`;\n}\n","'use client';\n\nimport {\n type AiTextResult,\n aiExplanationRequest,\n aiHintRequest,\n checkAiExplanation,\n checkAiHint,\n type InteractionEvent,\n type ItemOutcome,\n type LearnerResponse,\n} from '@intellectif/lk-core';\nimport { useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { SequenceSlotContext } from '../components/shared/sequence-slot.js';\nimport type { RenderableActivity, RenderMode } from '../components/types.js';\nimport { type LearnerAi, useLearnerAi } from './LkAiProvider.js';\nimport {\n callPort,\n explanationKey,\n explanationOffered,\n hintLimit,\n hintOffered,\n localeOf,\n warnRefused,\n} from './rules.js';\n\n/**\n * The question AI help is being asked about, as the SDK's own components know\n * it. A host drawing its own question passes what it has; everything optional\n * defaults to what the components pass.\n */\nexport interface AiHelpSituation {\n /** The question, as `data` is given to any activity component. */\n data: RenderableActivity;\n /** The learner's answer as it stands: submitted, restored, or being written. */\n response: LearnerResponse;\n /** Whether the learner has committed that answer. */\n submitted: boolean;\n /**\n * Pass on the `renderMode` your question was given. Left out, the paper\n * around the question answers for it — a question inside `<ActivitySequence>`\n * or `<InteractiveVideo>` knows its mode — and `practice` only where there is\n * no paper at all. An `exam` around the question wins over anything passed\n * here.\n */\n renderMode?: RenderMode;\n /**\n * The AI ports to use, overriding {@link LkAiProvider}'s for this question.\n * A question inside `<ActivitySequence>` or `<InteractiveVideo>` is handed\n * the ports in force as `ai` — pass that straight in.\n */\n ai?: LearnerAi;\n /** The interface language: the default language for what a model writes. */\n locale?: string;\n /** Where `ai-hint-shown` and `ai-explanation-shown` go. */\n onInteraction?: (event: InteractionEvent) => void;\n}\n\nexport interface AiExplanationInput extends AiHelpSituation {\n /** The grade of record, which `review` explains. */\n outcome?: ItemOutcome;\n}\n\nexport interface AiExplanationHelp {\n /**\n * Whether to offer the learner an explanation at all: a port is present, the\n * answer is graded, the type is one the SDK explains, and the author left\n * explanations on. False in `exam`, always.\n */\n offered: boolean;\n status: 'idle' | 'loading' | 'shown' | 'unavailable';\n /** What to show, once it has arrived and been checked. Its `text` is text, never HTML. */\n explanation: AiTextResult | null;\n /**\n * Asks the port, when the learner presses something. Does nothing while a\n * call is on its way, and nothing at all where `offered` is false — so an\n * exam cannot reach a model through this hook, whatever ports are in scope.\n *\n * One identity for the life of the question, so it is safe in an effect's\n * dependencies.\n */\n ask: () => void;\n}\n\nexport interface AiHintsInput extends AiHelpSituation {\n /** A disabled question gives no hints, as it takes no answer. */\n disabled?: boolean;\n}\n\nexport interface AiHintsHelp {\n /**\n * Whether the learner may ask for hints here at all: a port is present, the\n * mode is `practice`, the answer is not in, the question is not disabled or\n * redacted, the type takes hints and the author left them on. It stays true\n * once `used` reaches `limit` — there are no more to give, but the question\n * is still one that gives them.\n */\n offered: boolean;\n status: 'idle' | 'loading' | 'unavailable';\n /** Every hint shown for this question, in the order they were given. */\n hints: readonly AiTextResult[];\n /** The host's `maxHints`, as a whole number from 1 to 10 (3 by default). */\n limit: number;\n /** How many hints have been shown. A refused hint is not counted. */\n used: number;\n /**\n * Asks for the next hint. Does nothing at the limit, while a call is on its\n * way, or where `offered` is false. One identity for the life of the\n * question.\n */\n ask: () => void;\n}\n\n/**\n * The mode a question is answered in: what the caller says, and what the paper\n * around it says.\n *\n * A host drawing its own question is given `renderMode` like every other prop\n * and is expected to pass it on, but nothing makes it — and a hook that took\n * `practice` on trust would offer hints on a paper of record, as soon as an\n * `LkAiProvider` sat anywhere above the pager. So an `exam` around the question\n * wins, and where the caller says nothing the paper answers for it. A question\n * standing on its own belongs to no paper, and is `practice` as before.\n */\nfunction modeInForce(asked: RenderMode | undefined, around: RenderMode | undefined): RenderMode {\n if (around === 'exam') {\n return 'exam';\n }\n return asked ?? around ?? 'practice';\n}\n\n/**\n * What the record of help a learner was shown carries beside the fact of it:\n * who wrote it, and what the call cost — both only where the port sent them.\n *\n * The text is deliberately absent. A host that wants to keep what a learner\n * read has it in its own port; an interaction is a record of what happened, and\n * is kept for every learner and every question.\n */\nfunction shownPayload(result: AiTextResult): Record<string, unknown> {\n return {\n ...(result.provenance !== undefined ? { provenance: result.provenance } : {}),\n ...(result.usage !== undefined ? { usage: result.usage } : {}),\n };\n}\n\ntype ExplanationState =\n | { key: string; status: 'idle' | 'loading' | 'unavailable' }\n | { key: string; status: 'shown'; result: AiTextResult };\n\n/**\n * \"Explain my answer\", without the SDK's own button and panel: the rules, the\n * call, the checks and the record, for a question you draw yourself.\n *\n * It is what `<MultipleChoice>` and the others use, so a host's own question\n * offers help on exactly the same terms: never in `exam`, never where the\n * item's author switched explanations off, and never an explanation whose\n * verdict contradicts the grade the SDK computed.\n *\n * ```tsx\n * const { offered, status, explanation, ask } = useAiExplanation({\n * data, response, submitted, renderMode, outcome, ai: question.ai,\n * });\n * if (!offered) return null;\n * return explanation === null ? (\n * <button type=\"button\" onClick={ask} aria-busy={status === 'loading'}>Explain my answer</button>\n * ) : (\n * <section>\n * <p>{explanation.text}</p>\n * <p>Written by AI. It can make mistakes.</p>\n * </section>\n * );\n * ```\n *\n * **Say who wrote it.** The SDK's own panel carries \"Written by AI. It can make\n * mistakes.\"; a page that drops that line passes a model's words off as the\n * course's.\n *\n * When the answer or its grade changes, the explanation is dropped and a call\n * still on its way is abandoned — a late explanation never lands beside an\n * answer it was not written for — as it is when the caller unmounts.\n */\nexport function useAiExplanation(input: AiExplanationInput): AiExplanationHelp {\n const { data, response, submitted, outcome } = input;\n const renderMode = modeInForce(input.renderMode, useContext(SequenceSlotContext)?.renderMode);\n const ai = useLearnerAi(input.ai);\n const resetKey = explanationKey(renderMode, submitted, response, outcome);\n const [state, setState] = useState<ExplanationState>({ key: resetKey, status: 'idle' });\n const run = useRef(0);\n const controller = useRef<AbortController | null>(null);\n const current: ExplanationState =\n state.key === resetKey ? state : { key: resetKey, status: 'idle' };\n const offered =\n ai?.explain !== undefined && explanationOffered({ data, renderMode, submitted, outcome });\n\n // What `ask` reads, as of this render, so `ask` itself can keep one identity\n // for the life of the question. The state goes in too: an event handler runs\n // after the render that set it, so the ref is what the learner last saw.\n const latest = useRef({ input, renderMode, ai, resetKey, offered, current });\n latest.current = { input, renderMode, ai, resetKey, offered, current };\n\n // Another answer, or the caller going away: abandon the call in flight.\n // biome-ignore lint/correctness/useExhaustiveDependencies: the key is the trigger — its cleanup runs when the answer changes\n useEffect(() => {\n return () => {\n run.current += 1;\n controller.current?.abort();\n controller.current = null;\n };\n }, [resetKey]);\n\n const ask = useCallback((): void => {\n const now = latest.current;\n const port = now.ai?.explain;\n if (port === undefined || !now.offered || now.current.status === 'loading') {\n return;\n }\n const key = now.resetKey;\n const request = aiExplanationRequest({\n data: now.input.data,\n response: now.input.response,\n ...(now.renderMode === 'review' && now.input.outcome !== undefined\n ? { outcome: now.input.outcome }\n : {}),\n ...localeOf(now.ai, now.input.locale),\n });\n if (request === null) {\n setState({ key, status: 'unavailable' });\n return;\n }\n run.current += 1;\n const mine = run.current;\n controller.current?.abort();\n const abort = new AbortController();\n controller.current = abort;\n setState({ key, status: 'loading' });\n callPort(() => port(request, { signal: abort.signal })).then(\n (raw) => {\n if (run.current !== mine) {\n return;\n }\n const checked = checkAiExplanation(raw, request);\n if (!checked.ok) {\n warnRefused('explanation', now.input.data.id, checked.refusal);\n setState({ key, status: 'unavailable' });\n latest.current.input.onInteraction?.({\n type: 'ai-help-refused',\n activityId: now.input.data.id,\n timestamp: Date.now(),\n payload: { feature: 'explanation', reason: checked.refusal },\n });\n return;\n }\n setState({ key, status: 'shown', result: checked.result });\n latest.current.input.onInteraction?.({\n type: 'ai-explanation-shown',\n activityId: now.input.data.id,\n timestamp: Date.now(),\n payload: shownPayload(checked.result),\n });\n },\n () => {\n if (run.current === mine) {\n setState({ key, status: 'unavailable' });\n }\n },\n );\n }, []);\n\n return {\n offered,\n status: current.status,\n explanation: current.status === 'shown' ? current.result : null,\n ask,\n };\n}\n\ninterface HintState {\n key: string;\n hints: AiTextResult[];\n status: 'idle' | 'loading' | 'unavailable';\n}\n\n/**\n * \"Get a hint\", without the SDK's own button and list: the rules, the call, the\n * checks and the record, for a question you draw yourself.\n *\n * It is what `<MultipleChoice>` and the others use, so a host's own question\n * gives hints on exactly the same terms: only in `practice` before submit, up\n * to the host's limit, never on a redacted item or a type the SDK does not hint\n * for, and never a hint that gives the answer away — which is refused rather\n * than shown, and not counted.\n *\n * ```tsx\n * const { offered, status, hints, used, limit, ask } = useAiHints({\n * data, response, submitted, renderMode, ai: question.ai,\n * });\n * ```\n *\n * **Say who wrote them**, as the SDK's own list does: \"Written by AI. It can\n * make mistakes.\"\n *\n * Keep the hints on screen after submit — the learner can see what they were\n * given — while `offered` turns false. Another question starts with none.\n */\nexport function useAiHints(input: AiHintsInput): AiHintsHelp {\n const { data, submitted } = input;\n const renderMode = modeInForce(input.renderMode, useContext(SequenceSlotContext)?.renderMode);\n const disabled = input.disabled === true;\n const ai = useLearnerAi(input.ai);\n const resetKey = data.id;\n const [state, setState] = useState<HintState>({ key: resetKey, hints: [], status: 'idle' });\n const run = useRef(0);\n const controller = useRef<AbortController | null>(null);\n const current: HintState =\n state.key === resetKey ? state : { key: resetKey, hints: [], status: 'idle' };\n const offered = ai?.hint !== undefined && hintOffered({ data, renderMode, submitted, disabled });\n const limit = hintLimit(ai);\n\n const latest = useRef({ input, renderMode, ai, offered, limit, current });\n latest.current = { input, renderMode, ai, offered, limit, current };\n\n // Another question, or the caller going away: abandon the call in flight.\n // biome-ignore lint/correctness/useExhaustiveDependencies: the key is the trigger — its cleanup runs when the question changes\n useEffect(() => {\n return () => {\n run.current += 1;\n controller.current?.abort();\n controller.current = null;\n };\n }, [resetKey]);\n\n // Submitted, or disabled, while a hint was on its way: it would arrive for an\n // answer that can no longer use it.\n useEffect(() => {\n if (!offered) {\n run.current += 1;\n controller.current?.abort();\n controller.current = null;\n setState((previous) =>\n previous.status === 'loading' ? { ...previous, status: 'idle' } : previous,\n );\n }\n }, [offered]);\n\n const ask = useCallback((): void => {\n const now = latest.current;\n const port = now.ai?.hint;\n const held = now.current;\n if (\n port === undefined ||\n !now.offered ||\n held.status === 'loading' ||\n held.hints.length >= now.limit\n ) {\n return;\n }\n const key = held.key;\n const request = aiHintRequest({\n data: now.input.data,\n response: now.input.response,\n previousHints: held.hints.map((hint) => hint.text),\n ...localeOf(now.ai, now.input.locale),\n });\n if (request === null) {\n setState({ ...held, status: 'unavailable' });\n return;\n }\n run.current += 1;\n const mine = run.current;\n controller.current?.abort();\n const abort = new AbortController();\n controller.current = abort;\n setState({ ...held, status: 'loading' });\n callPort(() => port(request, { signal: abort.signal })).then(\n (raw) => {\n if (run.current !== mine) {\n return;\n }\n const checked = checkAiHint(raw, request);\n if (!checked.ok) {\n warnRefused('hint', now.input.data.id, checked.refusal);\n setState((shown) => ({ ...shown, status: 'unavailable' }));\n latest.current.input.onInteraction?.({\n type: 'ai-help-refused',\n activityId: now.input.data.id,\n timestamp: Date.now(),\n payload: {\n feature: 'hint',\n reason: checked.refusal,\n hintNumber: request.hintNumber,\n },\n });\n return;\n }\n setState((shown) => ({\n ...shown,\n hints: shown.key === key ? [...shown.hints, checked.result] : shown.hints,\n status: 'idle',\n }));\n latest.current.input.onInteraction?.({\n type: 'ai-hint-shown',\n activityId: now.input.data.id,\n timestamp: Date.now(),\n payload: { hintNumber: request.hintNumber, ...shownPayload(checked.result) },\n });\n },\n () => {\n if (run.current === mine) {\n setState((shown) => ({ ...shown, status: 'unavailable' }));\n }\n },\n );\n }, []);\n\n return {\n offered,\n status: current.status,\n hints: current.hints,\n limit,\n used: current.hints.length,\n ask,\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/shared/sequence-slot.ts"],"names":[],"mappings":";;;AAiDO,IAAM,mBAAA,GAAsB,cAA0C,IAAI;AASjF,IAAI,QAAA,GAAW,CAAA;AAGR,SAAS,QAAA,GAAmB;AACjC,EAAA,QAAA,IAAY,CAAA;AACZ,EAAA,OAAO,QAAA;AACT;AAOA,IAAM,KAAA,uBAAY,OAAA,EAAwB;AAGnC,SAAS,SAAA,CAA4B,OAAU,IAAA,EAAiB;AACrE,EAAA,KAAA,CAAM,GAAA,CAAI,OAAO,IAAI,CAAA;AACrB,EAAA,OAAO,KAAA;AACT;AAGO,SAAS,OAAO,KAAA,EAAoC;AACzD,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,OAAO,KAAA,CAAM,GAAA,CAAI,KAAK,CAAA,GAAI,MAAA;AAC1E","file":"chunk-TEAVPUMX.js","sourcesContent":["'use client';\n\nimport { createContext } from 'react';\nimport type { RenderMode } from '../types.js';\n\n/**\n * How far a take that was handed in has got, as a pager deciding whether its\n * set is finished needs to know it.\n *\n * - `in-flight` — being stored or being judged. The set waits for it.\n * - `retryable` — it failed, and the learner is being offered another try at\n * the SAME take. The set waits for it while the learner is on that question.\n * - `settled` — nothing more will come of it: a grade, a take with no grade, a\n * failure nobody can retry, or a take the learner walked away from.\n */\nexport type TakeState = 'in-flight' | 'retryable' | 'settled';\n\n/**\n * What a pager hands the one slot it renders, and only through\n * {@link SequenceSlotContext} — never as a prop, so none of it can appear on a\n * public component's signature. A consumer string in any of it could stop\n * another component's microphone or finish another paper's set.\n */\nexport interface SequenceSlotChannel {\n /**\n * The capture-registry group whose captures stop when the slot's pane is\n * hidden. Minted per pager and per slot, so no two pagers share one.\n */\n readonly captureGroup: string;\n /**\n * The mode the PAPER around this question is being delivered in, read live.\n *\n * It is how the AI hooks know an exam they were not told about. A host that\n * draws its own question passes `renderMode` on to them, but nothing makes\n * it: the hooks would then default to `practice` and, under an\n * `LkAiProvider` somewhere above, offer hints on a paper of record. The set\n * around the question decides, and an `exam` here wins over anything the\n * caller passes or forgets to pass.\n */\n readonly renderMode: RenderMode;\n /**\n * Reports the state of the take numbered `take`, a number from\n * {@link mintTake}. A take numbered below the slot's latest is a take the\n * learner has since replaced, and the pager ignores it.\n */\n takeState(take: number, state: TakeState): void;\n}\n\n/** `null` outside a pager: a standalone component belongs to no slot. */\nexport const SequenceSlotContext = createContext<SequenceSlotChannel | null>(null);\n\n/**\n * The last take number handed out. Module-level and never reset, so a number\n * is unique for the life of the page: across mounts, across papers, and across\n * two pagers side by side. A result can therefore only ever match the take that\n * produced it, whatever slot and activity ids a later paper reuses — ids a host\n * chooses, and can repeat, never decide it.\n */\nlet lastTake = 0;\n\n/** A take number no other take on this page has had, or will have. */\nexport function mintTake(): number {\n lastTake += 1;\n return lastTake;\n}\n\n/**\n * The take each reported value belongs to. A `WeakMap` rather than a field, so\n * a response or a result a host receives carries no extra key it would persist\n * or compare, and the number never outlives the object.\n */\nconst takes = new WeakMap<object, number>();\n\n/** Marks `value` as produced by take `take`, and returns it. */\nexport function stampTake<T extends object>(value: T, take: number): T {\n takes.set(value, take);\n return value;\n}\n\n/** The take `value` was produced by, or `undefined` when nothing stamped it. */\nexport function takeOf(value: unknown): number | undefined {\n return typeof value === 'object' && value !== null ? takes.get(value) : undefined;\n}\n"]}
|