@pie-players/pie-assessment-toolkit 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/README.md +200 -67
  2. package/dist/attempt/TestSession.d.ts +23 -21
  3. package/dist/attempt/TestSession.d.ts.map +1 -1
  4. package/dist/attempt/TestSession.js +17 -15
  5. package/dist/attempt/TestSession.js.map +1 -1
  6. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +50 -0
  7. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts.map +1 -0
  8. package/dist/attempt/adapters/activity-to-test-attempt-session.js +135 -0
  9. package/dist/attempt/adapters/activity-to-test-attempt-session.js.map +1 -0
  10. package/dist/components/ItemToolBar.custom-element.js +628 -0
  11. package/dist/components/PieAssessmentToolkit.custom-element.js +670 -0
  12. package/dist/components/item-toolbar-element.d.ts +3 -0
  13. package/dist/components/item-toolbar-element.d.ts.map +1 -0
  14. package/dist/components/item-toolbar-element.js +2 -0
  15. package/dist/components/item-toolbar-element.js.map +1 -0
  16. package/dist/components/pie-assessment-toolkit-element.d.ts +3 -0
  17. package/dist/components/pie-assessment-toolkit-element.d.ts.map +1 -0
  18. package/dist/components/pie-assessment-toolkit-element.js +2 -0
  19. package/dist/components/pie-assessment-toolkit-element.js.map +1 -0
  20. package/dist/context/assessment-toolkit-context.d.ts +52 -0
  21. package/dist/context/assessment-toolkit-context.d.ts.map +1 -0
  22. package/dist/context/assessment-toolkit-context.js +6 -0
  23. package/dist/context/assessment-toolkit-context.js.map +1 -0
  24. package/dist/context/runtime-context-consumer.d.ts +14 -0
  25. package/dist/context/runtime-context-consumer.d.ts.map +1 -0
  26. package/dist/context/runtime-context-consumer.js +52 -0
  27. package/dist/context/runtime-context-consumer.js.map +1 -0
  28. package/dist/index.d.ts +16 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +13 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/runtime/RuntimeRegistry.d.ts +13 -0
  33. package/dist/runtime/RuntimeRegistry.d.ts.map +1 -0
  34. package/dist/runtime/RuntimeRegistry.js +50 -0
  35. package/dist/runtime/RuntimeRegistry.js.map +1 -0
  36. package/dist/runtime/SectionRuntimeEngine.d.ts +45 -0
  37. package/dist/runtime/SectionRuntimeEngine.d.ts.map +1 -0
  38. package/dist/runtime/SectionRuntimeEngine.js +81 -0
  39. package/dist/runtime/SectionRuntimeEngine.js.map +1 -0
  40. package/dist/runtime/registration-events.d.ts +19 -0
  41. package/dist/runtime/registration-events.d.ts.map +1 -0
  42. package/dist/runtime/registration-events.js +4 -0
  43. package/dist/runtime/registration-events.js.map +1 -0
  44. package/dist/runtime/runtime-event-guards.d.ts +3 -0
  45. package/dist/runtime/runtime-event-guards.d.ts.map +1 -0
  46. package/dist/runtime/runtime-event-guards.js +9 -0
  47. package/dist/runtime/runtime-event-guards.js.map +1 -0
  48. package/dist/runtime/tool-host-contract.d.ts +30 -0
  49. package/dist/runtime/tool-host-contract.d.ts.map +1 -0
  50. package/dist/runtime/tool-host-contract.js +48 -0
  51. package/dist/runtime/tool-host-contract.js.map +1 -0
  52. package/dist/services/TTSService.d.ts +3 -1
  53. package/dist/services/TTSService.d.ts.map +1 -1
  54. package/dist/services/TTSService.js +13 -12
  55. package/dist/services/TTSService.js.map +1 -1
  56. package/dist/services/ThemeProvider.d.ts +1 -0
  57. package/dist/services/ThemeProvider.d.ts.map +1 -1
  58. package/dist/services/ThemeProvider.js +82 -46
  59. package/dist/services/ThemeProvider.js.map +1 -1
  60. package/dist/services/ToolConfigResolver.d.ts +1 -1
  61. package/dist/services/ToolConfigResolver.js +1 -1
  62. package/dist/services/ToolCoordinator.d.ts +1 -1
  63. package/dist/services/ToolCoordinator.d.ts.map +1 -1
  64. package/dist/services/ToolRegistry.d.ts +64 -67
  65. package/dist/services/ToolRegistry.d.ts.map +1 -1
  66. package/dist/services/ToolRegistry.js +72 -22
  67. package/dist/services/ToolRegistry.js.map +1 -1
  68. package/dist/services/ToolkitCoordinator.d.ts +106 -8
  69. package/dist/services/ToolkitCoordinator.d.ts.map +1 -1
  70. package/dist/services/ToolkitCoordinator.js +502 -71
  71. package/dist/services/ToolkitCoordinator.js.map +1 -1
  72. package/dist/services/createDefaultToolRegistry.d.ts +12 -7
  73. package/dist/services/createDefaultToolRegistry.d.ts.map +1 -1
  74. package/dist/services/createDefaultToolRegistry.js +6 -10
  75. package/dist/services/createDefaultToolRegistry.js.map +1 -1
  76. package/dist/services/defaultPersonalNeedsProfile.d.ts +4 -0
  77. package/dist/services/defaultPersonalNeedsProfile.d.ts.map +1 -0
  78. package/dist/services/defaultPersonalNeedsProfile.js +25 -0
  79. package/dist/services/defaultPersonalNeedsProfile.js.map +1 -0
  80. package/dist/services/interfaces.d.ts +61 -1
  81. package/dist/services/interfaces.d.ts.map +1 -1
  82. package/dist/services/interfaces.js.map +1 -1
  83. package/dist/services/pnp-standard-features.d.ts +3 -4
  84. package/dist/services/pnp-standard-features.d.ts.map +1 -1
  85. package/dist/services/pnp-standard-features.js +0 -3
  86. package/dist/services/pnp-standard-features.js.map +1 -1
  87. package/dist/services/section-controller-types.d.ts +32 -0
  88. package/dist/services/section-controller-types.d.ts.map +1 -0
  89. package/dist/services/section-controller-types.js +2 -0
  90. package/dist/services/section-controller-types.js.map +1 -0
  91. package/dist/services/tool-context.d.ts +4 -4
  92. package/dist/services/tool-context.d.ts.map +1 -1
  93. package/dist/services/tool-context.js +106 -17
  94. package/dist/services/tool-context.js.map +1 -1
  95. package/dist/services/tool-instance-id.d.ts +17 -0
  96. package/dist/services/tool-instance-id.d.ts.map +1 -0
  97. package/dist/services/tool-instance-id.js +61 -0
  98. package/dist/services/tool-instance-id.js.map +1 -0
  99. package/dist/services/tool-providers/IToolProvider.d.ts +2 -3
  100. package/dist/services/tool-providers/IToolProvider.d.ts.map +1 -1
  101. package/dist/services/tool-providers/IToolProvider.js +1 -2
  102. package/dist/services/tool-providers/IToolProvider.js.map +1 -1
  103. package/dist/services/tool-providers/MathJsToolProvider.d.ts +25 -0
  104. package/dist/services/tool-providers/MathJsToolProvider.d.ts.map +1 -0
  105. package/dist/services/tool-providers/MathJsToolProvider.js +53 -0
  106. package/dist/services/tool-providers/MathJsToolProvider.js.map +1 -0
  107. package/dist/services/tool-providers/index.d.ts +2 -0
  108. package/dist/services/tool-providers/index.d.ts.map +1 -1
  109. package/dist/services/tool-providers/index.js +1 -0
  110. package/dist/services/tool-providers/index.js.map +1 -1
  111. package/dist/services/tools-config-normalizer.d.ts +26 -0
  112. package/dist/services/tools-config-normalizer.d.ts.map +1 -0
  113. package/dist/services/tools-config-normalizer.js +63 -0
  114. package/dist/services/tools-config-normalizer.js.map +1 -0
  115. package/dist/tools/calculators/ti-provider.d.ts.map +1 -1
  116. package/dist/tools/calculators/ti-provider.js +127 -4
  117. package/dist/tools/calculators/ti-provider.js.map +1 -1
  118. package/dist/tools/client.d.ts +2 -1
  119. package/dist/tools/client.d.ts.map +1 -1
  120. package/dist/tools/client.js +2 -1
  121. package/dist/tools/client.js.map +1 -1
  122. package/dist/tools/default-tool-module-loaders.d.ts +9 -0
  123. package/dist/tools/default-tool-module-loaders.d.ts.map +1 -0
  124. package/dist/tools/default-tool-module-loaders.js +17 -0
  125. package/dist/tools/default-tool-module-loaders.js.map +1 -0
  126. package/dist/tools/index.d.ts +2 -1
  127. package/dist/tools/index.d.ts.map +1 -1
  128. package/dist/tools/index.js +2 -1
  129. package/dist/tools/index.js.map +1 -1
  130. package/dist/tools/library-loader.d.ts +1 -1
  131. package/dist/tools/library-loader.d.ts.map +1 -1
  132. package/dist/tools/library-loader.js +7 -2
  133. package/dist/tools/library-loader.js.map +1 -1
  134. package/dist/tools/registrations/accessibility-tools.d.ts +1 -9
  135. package/dist/tools/registrations/accessibility-tools.d.ts.map +1 -1
  136. package/dist/tools/registrations/accessibility-tools.js +95 -113
  137. package/dist/tools/registrations/accessibility-tools.js.map +1 -1
  138. package/dist/tools/registrations/calculator.d.ts +2 -2
  139. package/dist/tools/registrations/calculator.d.ts.map +1 -1
  140. package/dist/tools/registrations/calculator.js +34 -55
  141. package/dist/tools/registrations/calculator.js.map +1 -1
  142. package/dist/tools/registrations/interaction-tools.d.ts.map +1 -1
  143. package/dist/tools/registrations/interaction-tools.js +77 -52
  144. package/dist/tools/registrations/interaction-tools.js.map +1 -1
  145. package/dist/tools/registrations/measurement-tools.d.ts.map +1 -1
  146. package/dist/tools/registrations/measurement-tools.js +63 -38
  147. package/dist/tools/registrations/measurement-tools.js.map +1 -1
  148. package/dist/tools/registrations/subject-specific-tools.d.ts.map +1 -1
  149. package/dist/tools/registrations/subject-specific-tools.js +63 -38
  150. package/dist/tools/registrations/subject-specific-tools.js.map +1 -1
  151. package/dist/tools/registrations/tts.d.ts +1 -1
  152. package/dist/tools/registrations/tts.d.ts.map +1 -1
  153. package/dist/tools/registrations/tts.js +27 -41
  154. package/dist/tools/registrations/tts.js.map +1 -1
  155. package/dist/tools/response-discovery.d.ts +12 -14
  156. package/dist/tools/response-discovery.d.ts.map +1 -1
  157. package/dist/tools/response-discovery.js +23 -80
  158. package/dist/tools/response-discovery.js.map +1 -1
  159. package/dist/tools/tool-tag-map.d.ts +3 -3
  160. package/dist/tools/tool-tag-map.d.ts.map +1 -1
  161. package/dist/tools/tool-tag-map.js +2 -3
  162. package/dist/tools/tool-tag-map.js.map +1 -1
  163. package/dist/tools/types.d.ts +3 -1
  164. package/dist/tools/types.d.ts.map +1 -1
  165. package/package.json +25 -28
  166. package/src/README.md +16 -32
  167. package/src/components/ItemToolBar.svelte +489 -0
  168. package/src/components/PNPProvenanceViewer.svelte +14 -4
  169. package/src/components/PieAssessmentToolkit.svelte +517 -0
  170. package/src/components/ToolButton.svelte +11 -11
  171. package/src/components/ToolButtonGroup.svelte +27 -11
  172. package/src/tools/README.md +6 -5
  173. package/src/tools/calculators/README.md +4 -4
  174. package/dist/player/AssessmentPlayer.d.ts +0 -397
  175. package/dist/player/AssessmentPlayer.d.ts.map +0 -1
  176. package/dist/player/AssessmentPlayer.js +0 -974
  177. package/dist/player/AssessmentPlayer.js.map +0 -1
  178. package/dist/player/index.d.ts +0 -17
  179. package/dist/player/index.d.ts.map +0 -1
  180. package/dist/player/index.js +0 -15
  181. package/dist/player/index.js.map +0 -1
  182. package/dist/player/navigation-types.d.ts +0 -63
  183. package/dist/player/navigation-types.d.ts.map +0 -1
  184. package/dist/player/navigation-types.js +0 -7
  185. package/dist/player/navigation-types.js.map +0 -1
  186. package/dist/player/qti-navigation.d.ts +0 -29
  187. package/dist/player/qti-navigation.d.ts.map +0 -1
  188. package/dist/player/qti-navigation.js +0 -160
  189. package/dist/player/qti-navigation.js.map +0 -1
  190. package/dist/reference-layout/index.d.ts +0 -19
  191. package/dist/reference-layout/index.d.ts.map +0 -1
  192. package/dist/reference-layout/index.js +0 -20
  193. package/dist/reference-layout/index.js.map +0 -1
  194. package/dist/services/AnnotationToolbarConfig.d.ts +0 -134
  195. package/dist/services/AnnotationToolbarConfig.d.ts.map +0 -1
  196. package/dist/services/AnnotationToolbarConfig.js +0 -100
  197. package/dist/services/AnnotationToolbarConfig.js.map +0 -1
  198. package/dist/services/AssessmentAuthoringService.d.ts +0 -60
  199. package/dist/services/AssessmentAuthoringService.d.ts.map +0 -1
  200. package/dist/services/AssessmentAuthoringService.js +0 -183
  201. package/dist/services/AssessmentAuthoringService.js.map +0 -1
  202. package/dist/services/PNPMapper.d.ts +0 -81
  203. package/dist/services/PNPMapper.d.ts.map +0 -1
  204. package/dist/services/PNPMapper.js +0 -108
  205. package/dist/services/PNPMapper.js.map +0 -1
  206. package/src/components/PNPProfileTester.example.svelte +0 -188
  207. package/src/components/PNPProfileTester.svelte +0 -397
  208. package/src/components/QuestionToolBar.svelte +0 -483
  209. package/src/player/AssessmentLayout.svelte +0 -68
  210. package/src/player/README.md +0 -154
  211. package/src/reference-layout/README.md +0 -135
  212. package/src/reference-layout/ReferenceLayout.svelte +0 -201
  213. package/src/reference-layout/components/AssessmentContent.svelte +0 -259
  214. package/src/reference-layout/components/AssessmentFooter.svelte +0 -89
  215. package/src/reference-layout/components/AssessmentHeader.svelte +0 -250
  216. package/src/reference-layout/components/AssessmentNavigation.svelte +0 -134
  217. package/src/reference-layout/components/AssessmentToolsBar.svelte +0 -176
  218. package/src/reference-layout/components/ItemPanel.svelte +0 -200
  219. package/src/reference-layout/components/NotesPanel.svelte +0 -179
  220. package/src/reference-layout/components/PassagePanel.svelte +0 -76
@@ -0,0 +1,670 @@
1
+ // @ts-nocheck
2
+ import 'svelte/internal/disclose-version';
3
+ import * as $ from 'svelte/internal/client';
4
+ import { ContextProvider, ContextRoot, requestContext } from "@pie-players/pie-context";
5
+
6
+ import {
7
+ assessmentToolkitHostRuntimeContext,
8
+ assessmentToolkitRuntimeContext
9
+ } from "../context/assessment-toolkit-context.js";
10
+
11
+ import { connectAssessmentToolkitHostRuntimeContext } from "../context/runtime-context-consumer.js";
12
+ import { ToolkitCoordinator } from "../services/ToolkitCoordinator.js";
13
+
14
+ import {
15
+ PIE_ITEM_SESSION_CHANGED_EVENT,
16
+ PIE_REGISTER_EVENT,
17
+ PIE_UNREGISTER_EVENT
18
+ } from "../runtime/registration-events.js";
19
+
20
+ import { dispatchCrossBoundaryEvent } from "../runtime/tool-host-contract.js";
21
+ import { SectionRuntimeEngine } from "../runtime/SectionRuntimeEngine.js";
22
+ import { createRuntimeId, shouldHandleBySourceRuntime } from "../runtime/runtime-event-guards.js";
23
+
24
+ var root = $.from_html(`<div class="pie-assessment-toolkit-anchor svelte-vpe4u2" aria-hidden="true"></div> <!>`, 1);
25
+
26
+ const $$css = {
27
+ hash: 'svelte-vpe4u2',
28
+ code: '.pie-assessment-toolkit-anchor.svelte-vpe4u2 {display:none;}'
29
+ };
30
+
31
+ export default function PieAssessmentToolkit($$anchor, $$props) {
32
+ $.push($$props, true);
33
+ $.append_styles($$anchor, $$css);
34
+
35
+ const runtimeId = createRuntimeId("toolkit");
36
+ const sectionEngine = new SectionRuntimeEngine();
37
+
38
+ const DEFAULT_ITEM_PLAYER_BY_TYPE = {
39
+ iife: "pie-iife-player",
40
+ esm: "pie-esm-player",
41
+ fixed: "pie-fixed-player",
42
+ custom: ""
43
+ };
44
+
45
+ let assessmentId = $.prop($$props, 'assessmentId', 7, ""),
46
+ section = $.prop($$props, 'section', 7, null),
47
+ sectionId = $.prop($$props, 'sectionId', 7, ""),
48
+ attemptId = $.prop($$props, 'attemptId', 7, ""),
49
+ view = $.prop($$props, 'view', 7, "candidate"),
50
+ env = $.prop($$props, 'env', 23, () => ({})),
51
+ lazyInit = $.prop($$props, 'lazyInit', 7, true),
52
+ tools = $.prop($$props, 'tools', 23, () => ({})),
53
+ accessibility = $.prop($$props, 'accessibility', 23, () => ({})),
54
+ player = $.prop($$props, 'player', 7, null),
55
+ playerType = $.prop($$props, 'playerType', 7, ""),
56
+ coordinator = $.prop($$props, 'coordinator', 7, null),
57
+ createSectionController = $.prop($$props, 'createSectionController', 7, null),
58
+ isolation = $.prop($$props, 'isolation', 7, "inherit");
59
+
60
+ let anchor = $.state(null);
61
+ let ownedCoordinator = $.state(null);
62
+ let inheritedRuntime = $.state(null);
63
+ let lastOwnership = $.state(null);
64
+ let provider = null;
65
+ let contextRoot = null;
66
+ let hostRuntimeProvider = null;
67
+ let hostRuntimeRoot = null;
68
+ let compositionVersion = $.state(0);
69
+ let compositionModel = $.state(null);
70
+ let runtimeError = $.state(null);
71
+ let lastCompositionSignature = $.state("");
72
+
73
+ function getHostElement() {
74
+ if (!$.get(anchor)) return null;
75
+
76
+ const rootNode = $.get(anchor).getRootNode();
77
+
78
+ if (rootNode && "host" in rootNode) {
79
+ return rootNode.host;
80
+ }
81
+
82
+ return $.get(anchor).parentElement;
83
+ }
84
+
85
+ const host = $.derived(() => getHostElement());
86
+
87
+ function emit(name, detail) {
88
+ if (!$.get(host)) return;
89
+
90
+ dispatchCrossBoundaryEvent($.get(host), name, detail);
91
+ }
92
+
93
+ function isKnownPlayerType(value) {
94
+ return value === "iife" || value === "esm" || value === "fixed" || value === "custom";
95
+ }
96
+
97
+ function normalizeItemPlayerConfig(hostPlayer, hostPlayerType) {
98
+ const typeFromConfig = hostPlayer?.type;
99
+
100
+ const rawType = isKnownPlayerType(typeFromConfig)
101
+ ? typeFromConfig
102
+ : isKnownPlayerType(hostPlayerType)
103
+ ? hostPlayerType
104
+ : hostPlayer?.tagName ? "custom" : "iife";
105
+
106
+ const requestedTagName = hostPlayer?.tagName?.trim();
107
+
108
+ if (rawType === "custom" && !requestedTagName) {
109
+ return {
110
+ type: "iife",
111
+ tagName: DEFAULT_ITEM_PLAYER_BY_TYPE.iife,
112
+ version: undefined,
113
+ source: undefined,
114
+ isDefault: true
115
+ };
116
+ }
117
+
118
+ return {
119
+ type: rawType,
120
+ tagName: requestedTagName || DEFAULT_ITEM_PLAYER_BY_TYPE[rawType],
121
+ version: hostPlayer?.version,
122
+ source: hostPlayer?.source,
123
+ isDefault: !hostPlayer && !hostPlayerType
124
+ };
125
+ }
126
+
127
+ async function createDefaultSectionController() {
128
+ if (createSectionController()) {
129
+ return createSectionController()();
130
+ }
131
+
132
+ throw new Error("pie-assessment-toolkit requires createSectionController when no coordinator hook provides one");
133
+ }
134
+
135
+ function buildOwnedCoordinator() {
136
+ const fallbackAssessmentId = assessmentId() || section()?.identifier || `assessment-${Math.random().toString(16).slice(2)}`;
137
+
138
+ return new ToolkitCoordinator({
139
+ assessmentId: fallbackAssessmentId,
140
+ lazyInit: lazyInit(),
141
+ tools: tools(),
142
+ accessibility: accessibility()
143
+ });
144
+ }
145
+
146
+ const effectiveCoordinator = $.derived(() => {
147
+ if (isolation() !== "force" && $.get(inheritedRuntime)?.coordinator) {
148
+ return $.get(inheritedRuntime).coordinator;
149
+ }
150
+
151
+ return coordinator() || $.get(ownedCoordinator);
152
+ });
153
+
154
+ $.user_effect(() => {
155
+ if (coordinator()) {
156
+ if ($.get(ownedCoordinator)) {
157
+ $.set(ownedCoordinator, null);
158
+ }
159
+
160
+ return;
161
+ }
162
+
163
+ if (isolation() !== "force" && $.get(inheritedRuntime)?.coordinator) {
164
+ if ($.get(ownedCoordinator)) {
165
+ $.set(ownedCoordinator, null);
166
+ }
167
+
168
+ return;
169
+ }
170
+
171
+ if (!$.get(ownedCoordinator)) {
172
+ $.set(ownedCoordinator, buildOwnedCoordinator(), true);
173
+ }
174
+ });
175
+
176
+ const effectiveAssessmentId = $.derived(() => assessmentId() || $.get(effectiveCoordinator)?.assessmentId || "");
177
+ const effectiveSectionId = $.derived(() => sectionId() || section()?.identifier || `section-${$.get(effectiveAssessmentId) || "default"}`);
178
+ const effectiveItemPlayer = $.derived(() => normalizeItemPlayerConfig(player(), playerType()));
179
+
180
+ const runtimeContextValue = $.derived(() => {
181
+ if (!$.get(effectiveCoordinator)) return null;
182
+
183
+ const services = $.get(effectiveCoordinator).getServiceBundle();
184
+
185
+ return {
186
+ toolkitCoordinator: $.get(effectiveCoordinator),
187
+ toolCoordinator: $.get(effectiveCoordinator).toolCoordinator,
188
+ ttsService: services.ttsService,
189
+ highlightCoordinator: services.highlightCoordinator,
190
+ catalogResolver: services.catalogResolver,
191
+ elementToolStateStore: services.elementToolStateStore,
192
+ assessmentId: $.get(effectiveAssessmentId),
193
+ sectionId: $.get(effectiveSectionId),
194
+ itemPlayer: $.get(effectiveItemPlayer),
195
+ reportSessionChanged: (itemId, detail) => {
196
+ const result = sectionEngine.handleItemSessionChanged(itemId, detail);
197
+ const normalized = result?.eventDetail || detail;
198
+
199
+ emit("session-changed", { ...normalized, sourceRuntimeId: runtimeId });
200
+ }
201
+ };
202
+ });
203
+
204
+ const hostRuntimeContextValue = $.derived(() => {
205
+ if (!$.get(effectiveCoordinator)) return null;
206
+
207
+ return { runtimeId, coordinator: $.get(effectiveCoordinator) };
208
+ });
209
+
210
+ function getCompositionSignature(model) {
211
+ const typed = model;
212
+ const itemIds = Array.isArray(typed?.items) ? typed.items.map((item) => item?.id || "") : [];
213
+ const passageIds = Array.isArray(typed?.passages) ? typed.passages.map((item) => item?.id || "") : [];
214
+
215
+ const sessionByItem = typed?.itemSessionsByItemId
216
+ ? Object.entries(typed.itemSessionsByItemId).sort(([left], [right]) => left.localeCompare(right)).map(([itemId, session]) => [itemId, JSON.stringify(session ?? null)])
217
+ : [];
218
+
219
+ return JSON.stringify({
220
+ sectionId: typed?.section?.identifier || typed?.sectionId || "",
221
+ currentItemIndex: typed?.currentItemIndex ?? -1,
222
+ itemIds,
223
+ passageIds,
224
+ sessionByItem
225
+ });
226
+ }
227
+
228
+ function emitCompositionChanged() {
229
+ const nextModel = sectionEngine.getCompositionModel();
230
+ const signature = getCompositionSignature(nextModel);
231
+
232
+ if (signature === $.get(lastCompositionSignature)) {
233
+ return;
234
+ }
235
+
236
+ $.set(lastCompositionSignature, signature, true);
237
+ $.set(compositionVersion, $.get(compositionVersion) + 1);
238
+ $.set(compositionModel, nextModel, true);
239
+
240
+ emit("composition-changed", {
241
+ composition: $.get(compositionModel),
242
+ version: $.get(compositionVersion)
243
+ });
244
+ }
245
+
246
+ function isLocalToCurrentRuntime(eventTarget) {
247
+ if (!(eventTarget instanceof HTMLElement)) return false;
248
+
249
+ const sourceRuntime = requestContext(eventTarget, assessmentToolkitHostRuntimeContext);
250
+
251
+ return sourceRuntime?.runtimeId === runtimeId;
252
+ }
253
+
254
+ $.user_effect(() => {
255
+ if (!$.get(host)) return;
256
+
257
+ if (isolation() === "force") {
258
+ $.set(inheritedRuntime, null);
259
+
260
+ return;
261
+ }
262
+
263
+ return connectAssessmentToolkitHostRuntimeContext($.get(host), (value) => {
264
+ if (value.runtimeId === runtimeId) {
265
+ return;
266
+ }
267
+
268
+ $.set(inheritedRuntime, value, true);
269
+ });
270
+ });
271
+
272
+ $.user_effect(() => {
273
+ const parentRuntimeId = isolation() !== "force" && $.get(inheritedRuntime) ? $.get(inheritedRuntime).runtimeId : null;
274
+ const ownership = parentRuntimeId ? "inherited" : "owned";
275
+
276
+ if (ownership !== $.get(lastOwnership)) {
277
+ $.set(lastOwnership, ownership, true);
278
+ emit(ownership === "inherited" ? "runtime-inherited" : "runtime-owned", { runtimeId, parentRuntimeId });
279
+ }
280
+ });
281
+
282
+ $.user_effect(() => {
283
+ if (!$.get(host) || !$.get(hostRuntimeContextValue)) return;
284
+
285
+ hostRuntimeProvider = new ContextProvider($.get(host), {
286
+ context: assessmentToolkitHostRuntimeContext,
287
+ initialValue: $.get(hostRuntimeContextValue)
288
+ });
289
+
290
+ hostRuntimeProvider.connect();
291
+ hostRuntimeRoot = new ContextRoot($.get(host));
292
+ hostRuntimeRoot.attach();
293
+
294
+ return () => {
295
+ hostRuntimeRoot?.detach();
296
+ hostRuntimeRoot = null;
297
+ hostRuntimeProvider?.disconnect();
298
+ hostRuntimeProvider = null;
299
+ };
300
+ });
301
+
302
+ $.user_effect(() => {
303
+ if (!$.get(hostRuntimeContextValue)) return;
304
+
305
+ hostRuntimeProvider?.setValue($.get(hostRuntimeContextValue));
306
+ });
307
+
308
+ $.user_effect(() => {
309
+ if (!$.get(host)) return;
310
+
311
+ $.get(host).setAttribute("data-item-player-type", $.get(effectiveItemPlayer).type);
312
+ $.get(host).setAttribute("data-item-player-tag", $.get(effectiveItemPlayer).tagName);
313
+ $.get(host).setAttribute("data-env-mode", String(env()?.mode || ""));
314
+ $.get(host).setAttribute("data-env-role", String(env()?.role || ""));
315
+ });
316
+
317
+ $.user_effect(() => {
318
+ if (!$.get(host) || !$.get(runtimeContextValue)) return;
319
+
320
+ provider = new ContextProvider($.get(host), {
321
+ context: assessmentToolkitRuntimeContext,
322
+ initialValue: $.get(runtimeContextValue)
323
+ });
324
+
325
+ provider.connect();
326
+ contextRoot = new ContextRoot($.get(host));
327
+ contextRoot.attach();
328
+
329
+ return () => {
330
+ contextRoot?.detach();
331
+ contextRoot = null;
332
+ provider?.disconnect();
333
+ provider = null;
334
+ };
335
+ });
336
+
337
+ $.user_effect(() => {
338
+ if ($.get(runtimeContextValue)) {
339
+ provider?.setValue($.get(runtimeContextValue));
340
+ }
341
+ });
342
+
343
+ $.user_effect(() => {
344
+ if (!section() || !$.get(effectiveCoordinator)) return;
345
+
346
+ let cancelled = false;
347
+
348
+ void sectionEngine.initialize({
349
+ coordinator: $.get(effectiveCoordinator),
350
+ section: section(),
351
+ sectionId: $.get(effectiveSectionId),
352
+ assessmentId: $.get(effectiveAssessmentId),
353
+ attemptId: attemptId() || undefined,
354
+ view: view(),
355
+ createDefaultController: createDefaultSectionController,
356
+ onCompositionChanged: (nextComposition) => {
357
+ if (cancelled) return;
358
+
359
+ $.set(compositionModel, nextComposition, true);
360
+ emitCompositionChanged();
361
+ }
362
+ }).then(() => {
363
+ if (cancelled) return;
364
+
365
+ emit("toolkit-ready", {
366
+ runtimeId,
367
+ assessmentId: $.get(effectiveAssessmentId),
368
+ sectionId: $.get(effectiveSectionId),
369
+ itemPlayer: $.get(effectiveItemPlayer)
370
+ });
371
+
372
+ emit("section-ready", { sectionId: $.get(effectiveSectionId) });
373
+ }).catch((error) => {
374
+ $.set(runtimeError, error, true);
375
+ emit("runtime-error", { runtimeId, error });
376
+ });
377
+
378
+ return () => {
379
+ cancelled = true;
380
+ };
381
+ });
382
+
383
+ $.user_effect(() => {
384
+ if (!$.get(host)) return;
385
+
386
+ const localHost = $.get(host);
387
+
388
+ const onRegister = (event) => {
389
+ if (!isLocalToCurrentRuntime(event.target)) return;
390
+
391
+ const detail = event.detail;
392
+
393
+ if (!detail?.element || !detail?.itemId) return;
394
+
395
+ const changed = sectionEngine.register(detail);
396
+
397
+ if (changed) emitCompositionChanged();
398
+ };
399
+
400
+ const onUnregister = (event) => {
401
+ if (!isLocalToCurrentRuntime(event.target)) return;
402
+
403
+ const detail = event.detail;
404
+ const changed = detail?.element ? sectionEngine.unregister(detail.element) : false;
405
+
406
+ if (changed) emitCompositionChanged();
407
+ };
408
+
409
+ const onItemSessionChanged = (event) => {
410
+ if (!isLocalToCurrentRuntime(event.target)) return;
411
+
412
+ const detail = event.detail;
413
+
414
+ if (!detail?.itemId) return;
415
+ if (!shouldHandleBySourceRuntime(detail.sourceRuntimeId, runtimeId)) return;
416
+
417
+ const result = sectionEngine.handleItemSessionChanged(detail.itemId, detail.session);
418
+ const normalized = result?.eventDetail || detail.session;
419
+
420
+ emit("session-changed", {
421
+ ...normalized,
422
+ itemId: detail.itemId,
423
+ canonicalItemId: detail.canonicalItemId || detail.itemId,
424
+ sourceRuntimeId: runtimeId
425
+ });
426
+ };
427
+
428
+ localHost.addEventListener(PIE_REGISTER_EVENT, onRegister);
429
+ localHost.addEventListener(PIE_UNREGISTER_EVENT, onUnregister);
430
+ localHost.addEventListener(PIE_ITEM_SESSION_CHANGED_EVENT, onItemSessionChanged);
431
+
432
+ return () => {
433
+ localHost.removeEventListener(PIE_REGISTER_EVENT, onRegister);
434
+ localHost.removeEventListener(PIE_UNREGISTER_EVENT, onUnregister);
435
+ localHost.removeEventListener(PIE_ITEM_SESSION_CHANGED_EVENT, onItemSessionChanged);
436
+ };
437
+ });
438
+
439
+ async function waitUntilReady() {
440
+ if (!$.get(effectiveCoordinator)) {
441
+ throw new Error("Coordinator not initialized");
442
+ }
443
+
444
+ await $.get(effectiveCoordinator).waitUntilReady();
445
+ }
446
+
447
+ function getServiceBundle() {
448
+ if (!$.get(effectiveCoordinator)) {
449
+ throw new Error("Coordinator not initialized");
450
+ }
451
+
452
+ return $.get(effectiveCoordinator).getServiceBundle();
453
+ }
454
+
455
+ function setHooks(hooks) {
456
+ if (!$.get(effectiveCoordinator)) {
457
+ throw new Error("Coordinator not initialized");
458
+ }
459
+
460
+ $.get(effectiveCoordinator).setHooks(hooks);
461
+ }
462
+
463
+ function navigateToItem(index) {
464
+ return sectionEngine.navigateToItem(index);
465
+ }
466
+
467
+ function getCompositionModel() {
468
+ return sectionEngine.getCompositionModel();
469
+ }
470
+
471
+ function getItemPlayerConfig() {
472
+ return $.get(effectiveItemPlayer);
473
+ }
474
+
475
+ async function persist() {
476
+ await sectionEngine.persist();
477
+ }
478
+
479
+ async function hydrate() {
480
+ await sectionEngine.hydrate();
481
+ }
482
+
483
+ $.user_effect(() => {
484
+ return () => {
485
+ void sectionEngine.dispose().catch((error) => {
486
+ $.set(runtimeError, error, true);
487
+ });
488
+ };
489
+ });
490
+
491
+ var $$exports = {
492
+ waitUntilReady,
493
+ getServiceBundle,
494
+ setHooks,
495
+ navigateToItem,
496
+ getCompositionModel,
497
+ getItemPlayerConfig,
498
+ persist,
499
+ hydrate,
500
+ get assessmentId() {
501
+ return assessmentId();
502
+ },
503
+
504
+ set assessmentId($$value) {
505
+ assessmentId($$value);
506
+ $.flush();
507
+ },
508
+
509
+ get section() {
510
+ return section();
511
+ },
512
+
513
+ set section($$value) {
514
+ section($$value);
515
+ $.flush();
516
+ },
517
+
518
+ get sectionId() {
519
+ return sectionId();
520
+ },
521
+
522
+ set sectionId($$value) {
523
+ sectionId($$value);
524
+ $.flush();
525
+ },
526
+
527
+ get attemptId() {
528
+ return attemptId();
529
+ },
530
+
531
+ set attemptId($$value) {
532
+ attemptId($$value);
533
+ $.flush();
534
+ },
535
+
536
+ get view() {
537
+ return view();
538
+ },
539
+
540
+ set view($$value) {
541
+ view($$value);
542
+ $.flush();
543
+ },
544
+
545
+ get env() {
546
+ return env();
547
+ },
548
+
549
+ set env($$value) {
550
+ env($$value);
551
+ $.flush();
552
+ },
553
+
554
+ get lazyInit() {
555
+ return lazyInit();
556
+ },
557
+
558
+ set lazyInit($$value) {
559
+ lazyInit($$value);
560
+ $.flush();
561
+ },
562
+
563
+ get tools() {
564
+ return tools();
565
+ },
566
+
567
+ set tools($$value) {
568
+ tools($$value);
569
+ $.flush();
570
+ },
571
+
572
+ get accessibility() {
573
+ return accessibility();
574
+ },
575
+
576
+ set accessibility($$value) {
577
+ accessibility($$value);
578
+ $.flush();
579
+ },
580
+
581
+ get player() {
582
+ return player();
583
+ },
584
+
585
+ set player($$value) {
586
+ player($$value);
587
+ $.flush();
588
+ },
589
+
590
+ get playerType() {
591
+ return playerType();
592
+ },
593
+
594
+ set playerType($$value) {
595
+ playerType($$value);
596
+ $.flush();
597
+ },
598
+
599
+ get coordinator() {
600
+ return coordinator();
601
+ },
602
+
603
+ set coordinator($$value) {
604
+ coordinator($$value);
605
+ $.flush();
606
+ },
607
+
608
+ get createSectionController() {
609
+ return createSectionController();
610
+ },
611
+
612
+ set createSectionController($$value) {
613
+ createSectionController($$value);
614
+ $.flush();
615
+ },
616
+
617
+ get isolation() {
618
+ return isolation();
619
+ },
620
+
621
+ set isolation($$value) {
622
+ isolation($$value);
623
+ $.flush();
624
+ }
625
+ };
626
+
627
+ var fragment = root();
628
+ var div = $.first_child(fragment);
629
+
630
+ $.bind_this(div, ($$value) => $.set(anchor, $$value), () => $.get(anchor));
631
+
632
+ var node = $.sibling(div, 2);
633
+
634
+ $.slot(node, $$props, 'default', {}, null);
635
+ $.append($$anchor, fragment);
636
+
637
+ return $.pop($$exports);
638
+ }
639
+
640
+ customElements.define('pie-assessment-toolkit', $.create_custom_element(
641
+ PieAssessmentToolkit,
642
+ {
643
+ assessmentId: { attribute: 'assessment-id', type: 'String' },
644
+ section: { attribute: 'section', type: 'Object' },
645
+ sectionId: { attribute: 'section-id', type: 'String' },
646
+ attemptId: { attribute: 'attempt-id', type: 'String' },
647
+ view: { attribute: 'view', type: 'String' },
648
+ env: { attribute: 'env', type: 'Object' },
649
+ lazyInit: { attribute: 'lazy-init', type: 'Boolean' },
650
+ tools: { attribute: 'tools', type: 'Object' },
651
+ accessibility: { attribute: 'accessibility', type: 'Object' },
652
+ player: { attribute: 'player', type: 'Object' },
653
+ playerType: { attribute: 'player-type', type: 'String' },
654
+ coordinator: { type: 'Object' },
655
+ createSectionController: { type: 'Object' },
656
+ isolation: { attribute: 'isolation', type: 'String' }
657
+ },
658
+ ['default'],
659
+ [
660
+ 'waitUntilReady',
661
+ 'getServiceBundle',
662
+ 'setHooks',
663
+ 'navigateToItem',
664
+ 'getCompositionModel',
665
+ 'getItemPlayerConfig',
666
+ 'persist',
667
+ 'hydrate'
668
+ ],
669
+ { mode: 'open' }
670
+ ));
@@ -0,0 +1,3 @@
1
+ import "./ItemToolBar.custom-element.js";
2
+ export {};
3
+ //# sourceMappingURL=item-toolbar-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-toolbar-element.d.ts","sourceRoot":"","sources":["../../src/components/item-toolbar-element.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import "./ItemToolBar.custom-element.js";
2
+ //# sourceMappingURL=item-toolbar-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-toolbar-element.js","sourceRoot":"","sources":["../../src/components/item-toolbar-element.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import "./PieAssessmentToolkit.custom-element.js";
2
+ export {};
3
+ //# sourceMappingURL=pie-assessment-toolkit-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-assessment-toolkit-element.d.ts","sourceRoot":"","sources":["../../src/components/pie-assessment-toolkit-element.ts"],"names":[],"mappings":"AAAA,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import "./PieAssessmentToolkit.custom-element.js";
2
+ //# sourceMappingURL=pie-assessment-toolkit-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-assessment-toolkit-element.js","sourceRoot":"","sources":["../../src/components/pie-assessment-toolkit-element.ts"],"names":[],"mappings":"AAAA,OAAO,0CAA0C,CAAC"}