@pie-players/pie-assessment-toolkit 0.3.74 → 0.3.75

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 (228) hide show
  1. package/README.md +349 -313
  2. package/dist/attempt/TestSession.d.ts +1 -20
  3. package/dist/attempt/TestSession.js +8 -99
  4. package/dist/components/ItemScope.custom-element.d.ts +1 -0
  5. package/dist/components/ItemScope.custom-element.js +1 -0
  6. package/dist/components/ItemToolBar.custom-element.js +1 -1
  7. package/dist/components/PieAssessmentToolkit.custom-element.js +14 -14
  8. package/dist/components/SectionToolBar.custom-element.js +1 -1
  9. package/dist/components/chunks/ItemToolBar-7tt7v2xp.js +4 -0
  10. package/dist/components/chunks/{ItemToolBar-gmrryv2v.js → ItemToolBar-97hx60z4.js} +1 -1
  11. package/dist/components/chunks/ItemToolBar-bxwyhr5p.js +2 -0
  12. package/dist/components/chunks/ItemToolBar-jx38w99s.js +2 -0
  13. package/dist/components/chunks/ItemToolBar-rd2bb4p6.js +40 -0
  14. package/dist/components/chunks/ItemToolBar-vdkyn9f3.js +2 -0
  15. package/dist/components/chunks/sre-engine-jd8cc08x.js +1 -0
  16. package/dist/components/item-scope-element.d.ts +2 -0
  17. package/dist/components/item-scope-element.js +2 -0
  18. package/dist/context/assessment-toolkit-context.d.ts +27 -6
  19. package/dist/index.d.ts +22 -47
  20. package/dist/index.js +12 -36
  21. package/dist/policy/core/PolicySource.d.ts +1 -1
  22. package/dist/policy/core/ToolPolicyEngine.d.ts +77 -32
  23. package/dist/policy/core/ToolPolicyEngine.js +136 -46
  24. package/dist/policy/core/compose-decision.d.ts +28 -7
  25. package/dist/policy/core/compose-decision.js +75 -54
  26. package/dist/policy/core/decision-types.d.ts +65 -34
  27. package/dist/policy/core/feature-decision.d.ts +16 -9
  28. package/dist/policy/core/feature-decision.js +14 -8
  29. package/dist/policy/core/pnp-policy-inputs.d.ts +24 -33
  30. package/dist/policy/core/pnp-policy-inputs.js +28 -56
  31. package/dist/policy/core/provenance.d.ts +9 -4
  32. package/dist/policy/core/provenance.js +1 -1
  33. package/dist/policy/engine.d.ts +7 -23
  34. package/dist/policy/engine.js +5 -20
  35. package/dist/policy/sources/PnpPolicySource.d.ts +44 -61
  36. package/dist/policy/sources/PnpPolicySource.js +117 -118
  37. package/dist/runtime/SectionControllerBinding.d.ts +279 -0
  38. package/dist/runtime/SectionControllerBinding.js +450 -0
  39. package/dist/runtime/SectionRuntimeEngine.d.ts +26 -289
  40. package/dist/runtime/SectionRuntimeEngine.js +30 -372
  41. package/dist/runtime/adapter/SectionEngineAdapter.d.ts +19 -80
  42. package/dist/runtime/adapter/SectionEngineAdapter.js +19 -92
  43. package/dist/runtime/adapter/dom-event-bridge.d.ts +15 -30
  44. package/dist/runtime/adapter/dom-event-bridge.js +17 -44
  45. package/dist/runtime/adapter/subscriber-fanout.d.ts +1 -2
  46. package/dist/runtime/adapter/subscriber-fanout.js +1 -2
  47. package/dist/runtime/catalog-context.d.ts +19 -0
  48. package/dist/runtime/catalog-context.js +28 -0
  49. package/dist/runtime/composition-emit-scheduler.d.ts +9 -15
  50. package/dist/runtime/composition-emit-scheduler.js +9 -15
  51. package/dist/runtime/content-language.d.ts +32 -0
  52. package/dist/runtime/content-language.js +46 -0
  53. package/dist/runtime/content-region.d.ts +17 -0
  54. package/dist/runtime/content-region.js +29 -0
  55. package/dist/runtime/content-registration.d.ts +13 -0
  56. package/dist/runtime/content-registration.js +25 -0
  57. package/dist/runtime/core/SectionEngineCore.d.ts +2 -2
  58. package/dist/runtime/core/SectionEngineCore.js +2 -2
  59. package/dist/runtime/core/cohort.d.ts +1 -1
  60. package/dist/runtime/core/cohort.js +1 -1
  61. package/dist/runtime/core/engine-input.d.ts +18 -30
  62. package/dist/runtime/core/engine-input.js +11 -12
  63. package/dist/runtime/core/engine-output.d.ts +16 -40
  64. package/dist/runtime/core/engine-output.js +9 -21
  65. package/dist/runtime/core/engine-readiness.d.ts +5 -37
  66. package/dist/runtime/core/engine-readiness.js +8 -41
  67. package/dist/runtime/core/engine-resolver.d.ts +46 -74
  68. package/dist/runtime/core/engine-resolver.js +18 -43
  69. package/dist/runtime/core/engine-state.d.ts +28 -36
  70. package/dist/runtime/core/engine-state.js +18 -21
  71. package/dist/runtime/core/engine-transition.d.ts +14 -19
  72. package/dist/runtime/core/engine-transition.js +71 -51
  73. package/dist/runtime/engine.d.ts +16 -19
  74. package/dist/runtime/engine.js +12 -19
  75. package/dist/runtime/page-warnings.d.ts +13 -0
  76. package/dist/runtime/page-warnings.js +22 -0
  77. package/dist/runtime/policy-input-forwarding.d.ts +25 -0
  78. package/dist/runtime/policy-input-forwarding.js +25 -0
  79. package/dist/runtime/registration-events.d.ts +11 -0
  80. package/dist/runtime/runtime-event-claim.d.ts +8 -0
  81. package/dist/runtime/runtime-event-claim.js +15 -0
  82. package/dist/runtime/shell-event-bridge.d.ts +45 -0
  83. package/dist/runtime/shell-event-bridge.js +127 -0
  84. package/dist/runtime/shell-registration.d.ts +73 -0
  85. package/dist/runtime/shell-registration.js +95 -0
  86. package/dist/runtime/shell-scope.d.ts +68 -0
  87. package/dist/runtime/shell-scope.js +188 -0
  88. package/dist/runtime/tool-host-contract.d.ts +8 -10
  89. package/dist/runtime/tool-host-contract.js +11 -11
  90. package/dist/runtime/unclaimed-registration-watch.d.ts +7 -0
  91. package/dist/runtime/unclaimed-registration-watch.js +23 -0
  92. package/dist/services/ElementToolStateStore.d.ts +14 -10
  93. package/dist/services/ElementToolStateStore.js +37 -13
  94. package/dist/services/HighlightCoordinator.d.ts +21 -21
  95. package/dist/services/HighlightCoordinator.js +431 -325
  96. package/dist/services/RangeSerializer.d.ts +10 -1
  97. package/dist/services/RangeSerializer.js +87 -14
  98. package/dist/services/TTSService.d.ts +117 -70
  99. package/dist/services/TTSService.js +668 -578
  100. package/dist/services/ToolCoordinator.d.ts +43 -60
  101. package/dist/services/ToolCoordinator.js +164 -206
  102. package/dist/services/ToolRegistry.d.ts +74 -57
  103. package/dist/services/ToolRegistry.js +104 -114
  104. package/dist/services/ToolkitCoordinator.d.ts +183 -189
  105. package/dist/services/ToolkitCoordinator.js +477 -431
  106. package/dist/services/audio-handoff.d.ts +6 -7
  107. package/dist/services/audio-handoff.js +20 -14
  108. package/dist/services/catalog-owner.d.ts +0 -1
  109. package/dist/services/framework-error-bus.d.ts +3 -6
  110. package/dist/services/framework-error-bus.js +3 -6
  111. package/dist/services/framework-error.d.ts +22 -7
  112. package/dist/services/framework-error.js +9 -7
  113. package/dist/services/interfaces.d.ts +158 -129
  114. package/dist/services/section-session-assignment.d.ts +21 -0
  115. package/dist/services/section-session-assignment.js +82 -0
  116. package/dist/services/spoken-audio-cards.d.ts +0 -2
  117. package/dist/services/spoken-audio-cards.js +0 -2
  118. package/dist/services/tool-config-defaults.d.ts +3 -3
  119. package/dist/services/tool-config-defaults.js +3 -3
  120. package/dist/services/tool-config-validation.d.ts +4 -5
  121. package/dist/services/tool-config-validation.js +36 -61
  122. package/dist/services/tool-context.d.ts +0 -8
  123. package/dist/services/tool-context.js +0 -12
  124. package/dist/services/tool-icons.d.ts +4 -3
  125. package/dist/services/tool-icons.js +4 -3
  126. package/dist/services/tool-instance-id.d.ts +0 -1
  127. package/dist/services/tool-instance-id.js +0 -6
  128. package/dist/services/tool-providers/TTSToolProvider.d.ts +18 -19
  129. package/dist/services/tool-providers/TTSToolProvider.js +37 -34
  130. package/dist/services/tool-providers/ToolProviderApi.d.ts +10 -4
  131. package/dist/services/tool-providers/ToolProviderRegistry.d.ts +30 -26
  132. package/dist/services/tool-providers/ToolProviderRegistry.js +119 -93
  133. package/dist/services/tool-request.d.ts +27 -12
  134. package/dist/services/tool-request.js +24 -14
  135. package/dist/services/toolbar-decided-tools.d.ts +15 -0
  136. package/dist/services/toolbar-decided-tools.js +28 -0
  137. package/dist/services/tools-config-normalizer.d.ts +17 -22
  138. package/dist/services/tools-config-normalizer.js +2 -10
  139. package/dist/services/tts/browser-provider.d.ts +38 -2
  140. package/dist/services/tts/browser-provider.js +276 -140
  141. package/dist/services/tts/flat-tree.d.ts +71 -0
  142. package/dist/services/tts/flat-tree.js +269 -0
  143. package/dist/services/tts/generated-speech/assemble-plan.d.ts +3 -1
  144. package/dist/services/tts/generated-speech/assemble-plan.js +3 -1
  145. package/dist/services/tts/generated-speech/dom/build-dom-plan.d.ts +2 -0
  146. package/dist/services/tts/generated-speech/dom/build-dom-plan.js +1 -1
  147. package/dist/services/tts/generated-speech/math-speech-cache.d.ts +3 -1
  148. package/dist/services/tts/generated-speech/math-speech-cache.js +5 -1
  149. package/dist/services/tts/highlight-pipeline/create-highlight-plan.js +12 -4
  150. package/dist/services/tts/highlight-pipeline/prose-boundary-resolver.js +6 -4
  151. package/dist/services/tts/highlight-pipeline/readable-region.js +3 -2
  152. package/dist/services/tts/highlight-pipeline/types.d.ts +5 -0
  153. package/dist/services/tts/highlight-pipeline/visible-map-range.d.ts +12 -0
  154. package/dist/services/tts/highlight-pipeline/visible-map-range.js +73 -7
  155. package/dist/services/tts/math-aware-text-processing.d.ts +5 -1
  156. package/dist/services/tts/math-aware-text-processing.js +32 -18
  157. package/dist/services/tts/math-control-names.d.ts +21 -0
  158. package/dist/services/tts/math-control-names.js +142 -0
  159. package/dist/services/tts/math-speech.d.ts +11 -0
  160. package/dist/services/tts/math-speech.js +51 -18
  161. package/dist/services/tts/provider-options.d.ts +41 -0
  162. package/dist/services/tts/provider-options.js +1 -0
  163. package/dist/services/tts/ssml/spoken-text.d.ts +2 -26
  164. package/dist/services/tts/ssml/spoken-text.js +29 -0
  165. package/dist/services/tts/start-failure.d.ts +11 -0
  166. package/dist/services/tts/start-failure.js +19 -0
  167. package/dist/services/tts/text-processing.d.ts +9 -0
  168. package/dist/services/tts/text-processing.js +46 -33
  169. package/dist/services/tts/text-segmentation.d.ts +7 -0
  170. package/dist/services/tts/text-segmentation.js +47 -0
  171. package/dist/services/tts-runtime-config.d.ts +25 -17
  172. package/dist/services/tts-runtime-config.js +16 -95
  173. package/dist/tools/content-capability-resolution.d.ts +7 -9
  174. package/dist/tools/content-capability-resolution.js +8 -45
  175. package/dist/tools/registration.d.ts +58 -0
  176. package/dist/tools/registration.js +54 -0
  177. package/dist/tools/registrations/toolbar-registration-helpers.js +2 -2
  178. package/dist/tools/tool-surface-host.d.ts +6 -10
  179. package/dist/tools/tool-surface-host.js +44 -42
  180. package/dist/tools/tool-tag-map.d.ts +5 -15
  181. package/dist/tools/tool-tag-map.js +6 -20
  182. package/dist/utils/structural-equality.d.ts +11 -0
  183. package/dist/utils/structural-equality.js +47 -0
  184. package/package.json +13 -29
  185. package/dist/attempt/adapters/activity-to-test-attempt-session.d.ts +0 -49
  186. package/dist/attempt/adapters/activity-to-test-attempt-session.js +0 -138
  187. package/dist/components/chunks/ItemToolBar-b9dz5jvd.js +0 -40
  188. package/dist/components/chunks/ItemToolBar-h4xap0t0.js +0 -4
  189. package/dist/components/chunks/ItemToolBar-wr2myaah.js +0 -2
  190. package/dist/components/chunks/sre-engine-wf9s43gg.js +0 -1
  191. package/dist/context/runtime-context-consumer.d.ts +0 -13
  192. package/dist/context/runtime-context-consumer.js +0 -18
  193. package/dist/item-loader.d.ts +0 -44
  194. package/dist/item-loader.js +0 -61
  195. package/dist/policy/core/engine-context.d.ts +0 -29
  196. package/dist/policy/core/engine-context.js +0 -27
  197. package/dist/policy/core/policy-source-tag.d.ts +0 -31
  198. package/dist/policy/core/policy-source-tag.js +0 -28
  199. package/dist/policy/internal.d.ts +0 -25
  200. package/dist/policy/internal.js +0 -25
  201. package/dist/runtime/adapter/coordinator-bridge.d.ts +0 -92
  202. package/dist/runtime/adapter/coordinator-bridge.js +0 -126
  203. package/dist/runtime/adapter/framework-error-bridge.d.ts +0 -36
  204. package/dist/runtime/adapter/framework-error-bridge.js +0 -46
  205. package/dist/runtime/adapter/instrumentation-bridge.d.ts +0 -31
  206. package/dist/runtime/adapter/instrumentation-bridge.js +0 -38
  207. package/dist/runtime/core/engine-stage-derivation.d.ts +0 -18
  208. package/dist/runtime/core/engine-stage-derivation.js +0 -29
  209. package/dist/runtime/engine-context.d.ts +0 -39
  210. package/dist/runtime/engine-context.js +0 -31
  211. package/dist/runtime/internal.d.ts +0 -43
  212. package/dist/runtime/internal.js +0 -45
  213. package/dist/runtime/section-runtime-engine-host-context.d.ts +0 -74
  214. package/dist/runtime/section-runtime-engine-host-context.js +0 -57
  215. package/dist/runtime/stage-emit-gate.d.ts +0 -92
  216. package/dist/runtime/stage-emit-gate.js +0 -82
  217. package/dist/services/I18nService.d.ts +0 -47
  218. package/dist/services/I18nService.js +0 -84
  219. package/dist/services/ThemeProvider.d.ts +0 -95
  220. package/dist/services/ThemeProvider.js +0 -334
  221. package/dist/services/defaultPersonalNeedsProfile.d.ts +0 -21
  222. package/dist/services/defaultPersonalNeedsProfile.js +0 -26
  223. package/dist/services/pnp-standard-features.d.ts +0 -238
  224. package/dist/services/pnp-standard-features.js +0 -338
  225. package/dist/tools/client.d.ts +0 -10
  226. package/dist/tools/client.js +0 -10
  227. package/dist/tools/internal.d.ts +0 -44
  228. package/dist/tools/internal.js +0 -39
@@ -1,8 +1,3 @@
1
- export interface StorageLike {
2
- getItem(key: string): string | null;
3
- setItem(key: string, value: string): void;
4
- removeItem(key: string): void;
5
- }
6
1
  export interface TestAttemptSessionNavigationState {
7
2
  currentItemIndex: number;
8
3
  visitedItemIdentifiers: string[];
@@ -57,21 +52,6 @@ export interface TestAttemptSession {
57
52
  */
58
53
  contextVariables?: Record<string, any>;
59
54
  }
60
- export declare function createMemoryStorage(initial?: Record<string, string>): StorageLike;
61
- export declare function getBrowserLocalStorage(): StorageLike | null;
62
- export declare function getOrCreateAnonymousDeviceId(storage: StorageLike): string;
63
- export declare function createTestAttemptSessionIdentifier(args: {
64
- assessmentId: string;
65
- assignmentId?: string | null;
66
- userId?: string | null;
67
- storage: StorageLike;
68
- }): {
69
- testAttemptSessionIdentifier: string;
70
- seed: string;
71
- };
72
- export declare function getTestAttemptSessionStorageKey(testAttemptSessionIdentifier: string): string;
73
- export declare function loadTestAttemptSession(storage: StorageLike, testAttemptSessionIdentifier: string): TestAttemptSession | null;
74
- export declare function saveTestAttemptSession(storage: StorageLike, session: TestAttemptSession): void;
75
55
  export declare function createNewTestAttemptSession(args: {
76
56
  testAttemptSessionIdentifier: string;
77
57
  assessmentId: string;
@@ -89,3 +69,4 @@ export declare function upsertItemSessionFromPieSessionChange(session: TestAttem
89
69
  isCompleted?: boolean;
90
70
  session?: unknown;
91
71
  }): TestAttemptSession;
72
+ export declare function toItemSessionsRecord(testAttemptSession: TestAttemptSession): Record<string, unknown>;
@@ -1,106 +1,7 @@
1
1
  const TEST_ATTEMPT_SESSION_VERSION = 1;
2
- const STORAGE_PREFIX = "pieoneer:testAttemptSession:v1:";
3
- const ANON_DEVICE_ID_KEY = "pieoneer:anonymousDeviceId:v1";
4
- export function createMemoryStorage(initial = {}) {
5
- const store = new Map(Object.entries(initial));
6
- return {
7
- getItem: (k) => (store.has(k) ? store.get(k) : null),
8
- setItem: (k, v) => {
9
- store.set(k, v);
10
- },
11
- removeItem: (k) => {
12
- store.delete(k);
13
- },
14
- };
15
- }
16
- export function getBrowserLocalStorage() {
17
- try {
18
- // eslint-disable-next-line no-undef
19
- if (typeof window === "undefined")
20
- return null;
21
- // eslint-disable-next-line no-undef
22
- if (!window.localStorage)
23
- return null;
24
- // eslint-disable-next-line no-undef
25
- return window.localStorage;
26
- }
27
- catch {
28
- return null;
29
- }
30
- }
31
2
  function nowIso() {
32
3
  return new Date().toISOString();
33
4
  }
34
- // Lightweight, deterministic hash for IDs (no crypto dependency).
35
- function fnv1a32Hex(input) {
36
- let hash = 0x811c9dc5; // offset basis
37
- for (let i = 0; i < input.length; i++) {
38
- hash ^= input.charCodeAt(i);
39
- // hash *= 16777619 (with 32-bit overflow)
40
- hash =
41
- (hash +
42
- ((hash << 1) +
43
- (hash << 4) +
44
- (hash << 7) +
45
- (hash << 8) +
46
- (hash << 24))) >>>
47
- 0;
48
- }
49
- return hash.toString(16).padStart(8, "0");
50
- }
51
- function randomId() {
52
- const cryptoAny = globalThis?.crypto;
53
- const uuid = cryptoAny?.randomUUID?.();
54
- if (typeof uuid === "string" && uuid.length > 0) {
55
- return uuid;
56
- }
57
- return `anon_${Math.random().toString(16).slice(2)}_${Date.now().toString(16)}`;
58
- }
59
- export function getOrCreateAnonymousDeviceId(storage) {
60
- const existing = storage.getItem(ANON_DEVICE_ID_KEY);
61
- if (existing)
62
- return existing;
63
- const created = randomId();
64
- storage.setItem(ANON_DEVICE_ID_KEY, created);
65
- return created;
66
- }
67
- export function createTestAttemptSessionIdentifier(args) {
68
- const { assessmentId, assignmentId, userId, storage } = args;
69
- if (!assessmentId) {
70
- throw new Error("assessmentId is required to create a TestSession identifier");
71
- }
72
- const subject = userId || getOrCreateAnonymousDeviceId(storage);
73
- const source = `v1|${assessmentId}|${assignmentId || ""}|${subject}`;
74
- const seed = fnv1a32Hex(source);
75
- return { testAttemptSessionIdentifier: `tas_v1_${seed}`, seed };
76
- }
77
- export function getTestAttemptSessionStorageKey(testAttemptSessionIdentifier) {
78
- return `${STORAGE_PREFIX}${testAttemptSessionIdentifier}`;
79
- }
80
- export function loadTestAttemptSession(storage, testAttemptSessionIdentifier) {
81
- const raw = storage.getItem(getTestAttemptSessionStorageKey(testAttemptSessionIdentifier));
82
- if (!raw)
83
- return null;
84
- try {
85
- const parsed = JSON.parse(raw);
86
- if (!parsed || parsed.version !== TEST_ATTEMPT_SESSION_VERSION)
87
- return null;
88
- if (parsed.testAttemptSessionIdentifier !== testAttemptSessionIdentifier) {
89
- return null;
90
- }
91
- return parsed;
92
- }
93
- catch {
94
- return null;
95
- }
96
- }
97
- export function saveTestAttemptSession(storage, session) {
98
- const updated = {
99
- ...session,
100
- updatedAt: nowIso(),
101
- };
102
- storage.setItem(getTestAttemptSessionStorageKey(session.testAttemptSessionIdentifier), JSON.stringify(updated));
103
- }
104
5
  export function createNewTestAttemptSession(args) {
105
6
  const startedAt = nowIso();
106
7
  return {
@@ -173,3 +74,11 @@ export function upsertItemSessionFromPieSessionChange(session, args) {
173
74
  },
174
75
  };
175
76
  }
77
+ export function toItemSessionsRecord(testAttemptSession) {
78
+ return Object.entries(testAttemptSession.itemSessions).reduce((acc, [itemIdentifier, itemSession]) => {
79
+ if (itemSession.session) {
80
+ acc[itemIdentifier] = itemSession.session;
81
+ }
82
+ return acc;
83
+ }, {});
84
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{a as N,b as p,c as g,d as y,e as D,f as v,k as P}from"./chunks/ItemToolBar-vdkyn9f3.js";import{$ as YJ,C as t,E as JJ,F as E,H as F,L as QJ,N as ZJ,T as XJ,U as qJ,Z as WJ,_ as k,ca as r,da as d,ea as H,ha as S,ia as I,ja as UJ,ka as u,u as o,v as n,w as a,x as f,y as i,z as e}from"./chunks/ItemToolBar-7tt7v2xp.js";import"./chunks/ItemToolBar-97hx60z4.js";import{commitPendingSessions as zJ,createPieLogger as KJ,normalizeItemSessionChange as xJ}from"@pie-players/pie-players-shared";function OJ(Q){let J=Q&&typeof Q==="object"?{...Q}:Q;if(J&&typeof J==="object")delete J.timestamp,delete J.sourceRuntimeId;try{return JSON.stringify(J)}catch{return String(J)}}var wJ=(Q)=>Boolean(Q&&typeof Q==="object"&&Q.sessionCommitReason);function $(Q){let{host:J,kind:Z,identity:W,mode:z,send:Y}=Q,M=KJ(J.localName||"pie-shell",()=>!1),K="",O=(j)=>{let{itemId:U,canonicalItemId:x}=W();if(!U)return;Y(g,{itemId:U,session:j});let B=xJ({itemId:U,sessionDetail:j});if(B.intent==="metadata-only"||!B.session)return;let q={itemId:U,canonicalItemId:x||U,session:B.session,...B.sessionCommitReason?{sessionCommitReason:B.sessionCommitReason}:{}};H(J,y,q)},w=(j)=>{if(z()!=="section")return;if(j.stopPropagation(),Z!=="item")return;let U=j.detail,x=OJ(U);if(!wJ(U)&&x===K)return;K=x,O(U)},G=(j)=>{if(z()==="section")j.stopPropagation();let{itemId:U,canonicalItemId:x,contentKind:X}=W();if(!U)return;let B={itemId:U,canonicalItemId:x||U,contentKind:X,detail:j.detail};Y(D,B)},A=(j)=>{if(z()==="section")j.stopPropagation();let{itemId:U,canonicalItemId:x,contentKind:X}=W();if(!U)return;let B={itemId:U,canonicalItemId:x||U,contentKind:X,error:j.detail};Y(v,B)};return J.addEventListener("session-changed",w),J.addEventListener("load-complete",G),J.addEventListener("player-error",A),{disconnect:()=>{try{if(Z==="item"&&z()==="section")zJ(J,{reason:"teardown",logger:M})}finally{J.removeEventListener("session-changed",w),J.removeEventListener("load-complete",G),J.removeEventListener("player-error",A)}}}}import{ContextProvider as GJ}from"@pie-players/pie-context";function AJ(Q,J){return Q.kind===J.kind&&Q.host===J.host&&Q.itemId===J.itemId&&Q.canonicalItemId===J.canonicalItemId&&Q.contentKind===J.contentKind&&u(Q.settings,J.settings)}function h(Q){return P(Q.item,Q.kind)}function b(Q,J){return Q.isConnected||!J?Q:J.eventTarget}function _(Q,J,Z){let W={kind:J.kind,itemId:J.itemId,canonicalItemId:J.canonicalItemId,contentKind:J.contentKind,item:J.item,...J.settings?{settings:J.settings}:{},element:J.host,...Z?{runtimeId:Z.runtimeId}:{}};H(b(J.host,Z),Q,W)}function m(){let Q=null,J=null,Z;function W(){let Y=Q;if(!Y)return;let M=Z;Q=null,J=null,Z=void 0,_(p,Y,M)}function z(Y,M){if(!Y){W();return}if(Q&&Z?.runtimeId!==M?.runtimeId)W();if(Q&&AJ(Q,Y)){if(Q.item===Y.item)return;let K=h(Y);if(K!==null&&K===J){Q=Y;return}Q=Y,J=K,_(N,Y,M);return}Q=Y,J=h(Y),Z=M,_(N,Y,M)}return{sync:z,retire:W}}var fJ=50;function c(Q,J,Z){let W=new GJ(Q,{context:J,initialValue:Z});return W.connect(),{provider:W,value:Z}}function l(Q,J,Z){if(Z(Q.value,J))return;Q.value=J,Q.provider.setValue(J)}var kJ=(Q,J,Z)=>{if(Q===J)return!0;if(!Q||!J)return!1;if(Q.id!==J.id)return!1;let W=P(Q,Z);return W!==null&&W===P(J,Z)},LJ=(Q,J)=>Q.kind===J.kind&&Q.itemId===J.itemId&&Q.canonicalItemId===J.canonicalItemId&&Q.contentKind===J.contentKind&&Q.regionPolicy===J.regionPolicy&&Q.scopeElement===J.scopeElement&&kJ(Q.item,J.item,Q.kind),FJ=(Q,J)=>Q.scopeElement===J.scopeElement&&Q.ttsHighlightTargetResolver===J.ttsHighlightTargetResolver,R=(Q,J,Z)=>{if(Q.getAttribute(J)!==Z)Q.setAttribute(J,Z)};function s(){let Q=m(),J=Date.now(),Z=null,W=null,z=null,Y=null,M=null,K=null,O=[],w=null,G=()=>{if(M!==null)Q.sync(K,M)};function A(X,B){if(X===D)w=B;if(Z&&M!==null){H(b(Z,M),X,{...B,runtimeId:M.runtimeId});return}if(O.push({type:X,detail:B}),O.length>fJ)O.shift()}function j(X){if(X.runtimeId===M?.runtimeId)return;let B=M!==null;M={runtimeId:X.runtimeId,eventTarget:X.eventTarget},G();let q=O;O=[];for(let L of q)A(L.type,L.detail);if(B&&w)A(D,w)}function U(){for(let X of[W,z])X?.provider.disconnect();Y?.(),Y=null,M=null,O=[],w=null,K=null,W=null,z=null,Z=null}function x(X){if(!X){Q.sync(null),U();return}if(X.host!==Z)U();Z=X.host;let B=X.canonicalItemId||X.itemId,q=X.regionPolicy||"default",L=X.scopeElement||X.host,V={kind:X.kind,itemId:X.itemId,canonicalItemId:B,contentKind:X.contentKind,regionPolicy:q,scopeElement:L,item:X.item??null,contextVersion:J};if(W)l(W,V,LJ);else W=c(Z,r,V);let T={scopeElement:L,ttsHighlightTargetResolver:X.ttsHighlightTargetResolver??null};if(z)l(z,T,FJ);else z=c(Z,d,T);R(Z,"data-item-id",X.itemId),R(Z,"data-canonical-item-id",B),R(Z,"data-pie-shell-root",X.kind),R(Z,"data-region-policy",q);let C=K;if(K=X.itemId?{kind:X.kind,host:Z,itemId:X.itemId,canonicalItemId:B,contentKind:X.contentKind,item:X.item??null,settings:X.settings??null}:null,C&&(C.itemId!==K?.itemId||C.canonicalItemId!==K?.canonicalItemId))w=null;Y??=S(Z,j),G()}return{publish:x,retire:Q.retire,disconnect:U,send:A}}var HJ=(Q,J)=>{if(customElements.get(Q))return;try{customElements.define(Q,J)}catch(Z){if(!(Z instanceof DOMException&&Z.name==="NotSupportedError"||Z&&typeof Z==="object"&&Z.name==="NotSupportedError")||!customElements.get(Q))throw Z}},VJ=QJ('<div class="pie-item-scope-anchor svelte-980v5l" aria-hidden="true"></div> <!>',1),CJ={hash:"svelte-980v5l",code:".pie-item-scope-anchor.svelte-980v5l {display:none;}"};function MJ(Q,J){o(J,!0),qJ(Q,CJ);let Z=k(J,"itemId",7,""),W=k(J,"canonicalItemId",7,""),z=k(J,"contentKind",7,"assessment-item"),Y=k(J,"regionPolicy",7,"default"),M=k(J,"scopeElement",7,null),K=k(J,"ttsHighlightTargetResolver",7,null),O=k(J,"item",7,null),w=k(J,"settings",7,null),G=i(null),A=a(()=>{let q=F(G)?.getRootNode();return q instanceof ShadowRoot?q.host:null}),j=s();E(()=>{if(!F(A))return;let q=F(A),L=!1,V=!1,T=S(q,(jJ)=>{V=!0,L=jJ.sectionBound===!0}),C=setTimeout(()=>{if(V||!q.isConnected)return;UJ(q.ownerDocument,"itemScopeWithoutToolkit",`[pie-item-scope] No <pie-assessment-toolkit> has answered item "${Z()}" after ${I/1000} s, so the item is not registered and the tools inside the scope have no runtime. Place the scope inside the toolkit element; it keeps waiting for one. Reported once per page.`)},I),BJ=$({host:q,kind:"item",identity:()=>({itemId:Z(),canonicalItemId:W(),contentKind:z()}),mode:()=>L?"section":"plain",send:j.send});return()=>{clearTimeout(C);try{BJ.disconnect()}finally{T(),j.retire(),j.disconnect()}}}),E(()=>{j.publish(F(A)?{host:F(A),kind:"item",itemId:Z(),canonicalItemId:W(),contentKind:z(),regionPolicy:Y(),scopeElement:M(),ttsHighlightTargetResolver:K(),item:O(),settings:w()}:null)});var U={get itemId(){return Z()},set itemId(q){Z(q),f()},get canonicalItemId(){return W()},set canonicalItemId(q){W(q),f()},get contentKind(){return z()},set contentKind(q){z(q),f()},get regionPolicy(){return Y()},set regionPolicy(q){Y(q),f()},get scopeElement(){return M()},set scopeElement(q){M(q),f()},get ttsHighlightTargetResolver(){return K()},set ttsHighlightTargetResolver(q){K(q),f()},get item(){return O()},set item(q){O(q),f()},get settings(){return w()},set settings(q){w(q),f()}},x=VJ(),X=t(x);WJ(X,(q)=>e(G,q),()=>F(G));var B=JJ(X,2);return XJ(B,J,"default",{},null),ZJ(Q,x),n(U)}HJ("pie-item-scope",YJ(MJ,{itemId:{attribute:"item-id",type:"String"},canonicalItemId:{attribute:"canonical-item-id",type:"String"},contentKind:{attribute:"content-kind",type:"String"},regionPolicy:{attribute:"region-policy",type:"String"},scopeElement:{type:"Object"},ttsHighlightTargetResolver:{type:"Object"},item:{type:"Object"},settings:{type:"Object"}},["default"],[],{mode:"open"}));export{MJ as default};
@@ -1 +1 @@
1
- import{a}from"./chunks/ItemToolBar-b9dz5jvd.js";import"./chunks/ItemToolBar-h4xap0t0.js";import"./chunks/ItemToolBar-gmrryv2v.js";export{a as default};
1
+ import{l as a}from"./chunks/ItemToolBar-rd2bb4p6.js";import"./chunks/ItemToolBar-bxwyhr5p.js";import"./chunks/ItemToolBar-7tt7v2xp.js";import"./chunks/ItemToolBar-97hx60z4.js";export{a as default};