@pie-players/pie-assessment-player 0.3.17 → 0.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,104 +1,507 @@
1
1
  import "@pie-players/pie-section-player/components/section-player-splitpane-element";
2
2
  import "@pie-players/pie-section-player/components/section-player-vertical-element";
3
- function d() {
3
+ function p(e, t) {
4
+ const s = `[${e}]`;
5
+ return {
6
+ debug: (n, ...i) => {
7
+ t() && console.debug(s, n, ...i);
8
+ },
9
+ info: (n, ...i) => console.info(s, n, ...i),
10
+ warn: (n, ...i) => console.warn(s, n, ...i),
11
+ error: (n, ...i) => console.error(s, n, ...i)
12
+ };
13
+ }
14
+ function f() {
15
+ return typeof window < "u" && window.PIE_DEBUG === !0;
16
+ }
17
+ var S;
18
+ (function(e) {
19
+ e.player = "player.js", e.clientPlayer = "client-player.js", e.editor = "editor.js";
20
+ })(S || (S = {}));
21
+ var w;
22
+ (function(e) {
23
+ e.loading = "loading", e.loaded = "loaded";
24
+ })(w || (w = {}));
25
+ function g(e) {
26
+ "@babel/helpers - typeof";
27
+ return g = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
28
+ return typeof t;
29
+ } : function(t) {
30
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
31
+ }, g(e);
32
+ }
33
+ function Y(e, t) {
34
+ if (g(e) != "object" || !e) return e;
35
+ var s = e[Symbol.toPrimitive];
36
+ if (s !== void 0) {
37
+ var n = s.call(e, t || "default");
38
+ if (g(n) != "object") return n;
39
+ throw new TypeError("@@toPrimitive must return a primitive value.");
40
+ }
41
+ return (t === "string" ? String : Number)(e);
42
+ }
43
+ function V(e) {
44
+ var t = Y(e, "string");
45
+ return g(t) == "symbol" ? t : t + "";
46
+ }
47
+ function a(e, t, s) {
48
+ return (t = V(t)) in e ? Object.defineProperty(e, t, {
49
+ value: s,
50
+ enumerable: !0,
51
+ configurable: !0,
52
+ writable: !0
53
+ }) : e[t] = s, e;
54
+ }
55
+ typeof window < "u" && !window.pieHelpers && (window.pieHelpers = {
56
+ loadingScripts: {},
57
+ loadingPromises: {}
58
+ });
59
+ var _ = "https://proxy.pie-api.com", q = `${_}/bundles/`;
60
+ function U(e) {
61
+ try {
62
+ const t = {
63
+ BASE_URL: "/",
64
+ DEV: !1,
65
+ MODE: "production",
66
+ PROD: !0,
67
+ SSR: !1
68
+ }[e];
69
+ if (typeof t == "string" && t.length > 0) return t;
70
+ } catch {
71
+ }
72
+ }
73
+ var xe = typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL || U("PUBLIC_BUILDER_ORIGIN_URL") || _, J = typeof window < "u" && window.PIE_BUILDER_BUNDLE_URL || U("PUBLIC_BUILDER_BUNDLE_URL") || q, N;
74
+ (function(e) {
75
+ e.SAVE = "save", e.MODEL = "model", e.SCORE = "score", e.MANUAL_SCORE = "manual-score";
76
+ })(N || (N = {}));
77
+ var C;
78
+ (function(e) {
79
+ e.AUTO = "auto", e.MANUAL = "manual";
80
+ })(C || (C = {}));
81
+ var A;
82
+ (function(e) {
83
+ e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
84
+ })(A || (A = {}));
85
+ var x;
86
+ (function(e) {
87
+ e.PENDING = "pending", e.IN_PROGRESS = "in_progress", e.COMPLETED = "completed", e.FAILED = "failed";
88
+ })(x || (x = {}));
89
+ var K = class B extends CustomEvent {
90
+ constructor(t, s = !1) {
91
+ super(B.TYPE, {
92
+ bubbles: !0,
93
+ detail: {
94
+ update: t,
95
+ reset: s
96
+ }
97
+ }), a(this, "update", void 0), a(this, "reset", void 0), this.update = t, this.reset = s;
98
+ }
99
+ };
100
+ a(K, "TYPE", "model.updated");
101
+ var W = class $ extends CustomEvent {
102
+ constructor(t, s) {
103
+ super($.TYPE, {
104
+ bubbles: !0,
105
+ detail: {
106
+ src: t,
107
+ done: s
108
+ }
109
+ }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
110
+ }
111
+ };
112
+ a(W, "TYPE", "delete.image");
113
+ var Z = class O extends CustomEvent {
114
+ constructor(t) {
115
+ super(O.TYPE, {
116
+ bubbles: !0,
117
+ detail: t
118
+ }), a(this, "handler", void 0), this.handler = t;
119
+ }
120
+ };
121
+ a(Z, "TYPE", "insert.image");
122
+ var Q = class M extends CustomEvent {
123
+ constructor(t, s) {
124
+ super(M.TYPE, {
125
+ bubbles: !0,
126
+ detail: {
127
+ src: t,
128
+ done: s
129
+ }
130
+ }), a(this, "src", void 0), a(this, "done", void 0), this.src = t, this.done = s;
131
+ }
132
+ };
133
+ a(Q, "TYPE", "delete.sound");
134
+ var X = class z extends CustomEvent {
135
+ constructor(t) {
136
+ super(z.TYPE, {
137
+ bubbles: !0,
138
+ detail: t
139
+ }), a(this, "handler", void 0), this.handler = t;
140
+ }
141
+ };
142
+ a(X, "TYPE", "insert.sound");
143
+ var ee = class F extends CustomEvent {
144
+ constructor(t, s) {
145
+ super(F.TYPE, {
146
+ bubbles: !0,
147
+ composed: !0,
148
+ detail: {
149
+ complete: s,
150
+ component: t
151
+ }
152
+ }), a(this, "component", void 0), a(this, "complete", void 0), this.component = t, this.complete = s;
153
+ }
154
+ };
155
+ a(ee, "TYPE", "session-changed");
156
+ var R;
157
+ (function(e) {
158
+ e[e.ROOT = 0] = "ROOT", e[e.SUBJECT = 1] = "SUBJECT", e[e.LEVEL = 2] = "LEVEL", e[e.STANDARD = 3] = "STANDARD";
159
+ })(R || (R = {}));
160
+ var Re = p("math-rendering", () => f()), Le = p("pie-scoring", () => f()), ke = p("pie-updates", () => f()), Te = p("pie-initialization", () => f()), De = {
161
+ buildServiceBase: J,
162
+ bundleType: S.player,
163
+ env: {
164
+ mode: "gather",
165
+ role: "student"
166
+ }
167
+ };
168
+ function G(e) {
169
+ if (!e || typeof e != "object") return !1;
170
+ const t = e;
171
+ return typeof t.providerId == "string" && typeof t.providerName == "string" && typeof t.initialize == "function" && typeof t.trackError == "function" && typeof t.trackEvent == "function" && typeof t.destroy == "function" && typeof t.isReady == "function";
172
+ }
173
+ var te = p("instrumentation-event-bridge", () => f());
174
+ function se(e) {
175
+ return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
176
+ }
177
+ function ne(e) {
178
+ te.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
179
+ }
180
+ function ie(e) {
181
+ try {
182
+ e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
183
+ component: e.component,
184
+ errorType: "InstrumentationBridgeError",
185
+ sourceEventName: e.sourceEventName
186
+ });
187
+ } catch {
188
+ }
189
+ }
190
+ function re(e) {
191
+ if (!e.host || !e.eventMap.length) return () => {
192
+ };
193
+ if (!e.instrumentationProvider) return () => {
194
+ };
195
+ if (!G(e.instrumentationProvider))
196
+ return e.debug && ne(e.component), () => {
197
+ };
198
+ const t = e.instrumentationProvider, s = [], n = Math.max(0, e.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), c = (o, r) => {
199
+ const d = [
200
+ r.assessmentId,
201
+ r.sectionId,
202
+ r.attemptId,
203
+ r.itemId,
204
+ r.canonicalItemId,
205
+ r.sourceRuntimeId
206
+ ].map((l) => String(l ?? "")).join("|");
207
+ return `${o.instrumentationEventName}|${d}`;
208
+ };
209
+ for (const o of e.eventMap) {
210
+ const r = (d) => {
211
+ try {
212
+ if (!t.isReady() || e.shouldTrackEvent && !e.shouldTrackEvent(d)) return;
213
+ const l = se(d.detail), h = (/* @__PURE__ */ new Date()).toISOString(), I = {
214
+ ...l,
215
+ ...e.staticAttributes,
216
+ component: e.component,
217
+ sourceEventName: o.sourceEventName,
218
+ timestamp: h
219
+ };
220
+ if (n > 0) {
221
+ const b = Date.now(), E = c(o, I), P = i.get(E);
222
+ if (typeof P == "number" && b - P < n) return;
223
+ i.set(E, b);
224
+ }
225
+ t.trackEvent(o.instrumentationEventName, { ...I });
226
+ } catch (l) {
227
+ ie({
228
+ provider: t,
229
+ component: e.component,
230
+ error: l,
231
+ sourceEventName: o.sourceEventName
232
+ });
233
+ }
234
+ };
235
+ e.host.addEventListener(o.sourceEventName, r), s.push(() => {
236
+ e.host?.removeEventListener(o.sourceEventName, r);
237
+ });
238
+ }
239
+ return () => {
240
+ for (const o of s) o();
241
+ };
242
+ }
243
+ var oe = class {
244
+ constructor() {
245
+ a(this, "initialized", !1), a(this, "config", void 0);
246
+ }
247
+ trackError(e, t) {
248
+ if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
249
+ const s = this.transformAttributes(t);
250
+ try {
251
+ this.doTrackError(e, s), this.config?.debug && console.log(`[${this.providerName}] Tracked error:`, e, s);
252
+ } catch (n) {
253
+ console.error(`[${this.providerName}] Error tracking error:`, n);
254
+ }
255
+ }
256
+ trackEvent(e, t) {
257
+ if (!this.guardedOperation("trackEvent", e, t) || !this.applyEventFilter(e, t) || !this.applySampling(e)) return;
258
+ let s = this.transformAttributes(t);
259
+ s.timestamp || (s = {
260
+ ...s,
261
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
262
+ });
263
+ try {
264
+ this.doTrackEvent(e, s), this.config?.debug && console.log(`[${this.providerName}] Tracked event:`, e, s);
265
+ } catch (n) {
266
+ console.error(`[${this.providerName}] Error tracking event:`, n);
267
+ }
268
+ }
269
+ trackMetric(e, t, s) {
270
+ this.trackEvent(`metric:${e}`, {
271
+ ...s,
272
+ metricValue: t,
273
+ metricName: e
274
+ });
275
+ }
276
+ setUserContext(e, t) {
277
+ if (this.guardedOperation("setUserContext", e, t))
278
+ try {
279
+ this.doSetUserContext(e, t), this.config?.debug && console.log(`[${this.providerName}] Set user context:`, e, t);
280
+ } catch (s) {
281
+ console.error(`[${this.providerName}] Error setting user context:`, s);
282
+ }
283
+ }
284
+ setGlobalAttributes(e) {
285
+ if (this.guardedOperation("setGlobalAttributes", e))
286
+ try {
287
+ this.doSetGlobalAttributes(e), this.config?.debug && console.log(`[${this.providerName}] Set global attributes:`, e);
288
+ } catch (t) {
289
+ console.error(`[${this.providerName}] Error setting global attributes:`, t);
290
+ }
291
+ }
292
+ guardedOperation(e, ...t) {
293
+ return this.isReady() ? !0 : (this.config?.debug && console.warn(`[${this.providerName}] Attempted to ${e} but provider not ready:`, ...t), !1);
294
+ }
295
+ applyErrorFilter(e, t) {
296
+ return this.config?.errorFilter && !this.config.errorFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Error filtered out:`, e, t), !1) : !0;
297
+ }
298
+ applyEventFilter(e, t) {
299
+ return this.config?.eventFilter && !this.config.eventFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Event filtered out:`, e, t), !1) : !0;
300
+ }
301
+ applySampling(e) {
302
+ return this.config?.sampleRate !== void 0 && this.config.sampleRate < 1 && Math.random() > this.config.sampleRate ? (this.config?.debug && console.log(`[${this.providerName}] Event sampled out:`, e), !1) : !0;
303
+ }
304
+ transformAttributes(e) {
305
+ return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
306
+ }
307
+ }, ae = class extends oe {
308
+ constructor(...e) {
309
+ super(...e), a(this, "providerId", "newrelic"), a(this, "providerName", "New Relic");
310
+ }
311
+ async initialize(e) {
312
+ this.config = e, typeof window < "u" && window.newrelic ? (this.initialized = !0, this.config?.debug && console.log("[NewRelicProvider] Initialized successfully")) : (this.config?.debug && console.warn("[NewRelicProvider] New Relic not available (window.newrelic not found)"), this.initialized = !1);
313
+ }
314
+ isReady() {
315
+ return this.initialized && typeof window < "u" && !!window.newrelic;
316
+ }
317
+ destroy() {
318
+ this.initialized = !1, this.config?.debug && console.log("[NewRelicProvider] Destroyed");
319
+ }
320
+ doTrackError(e, t) {
321
+ window.newrelic.noticeError(e, t);
322
+ }
323
+ doTrackEvent(e, t) {
324
+ window.newrelic.addPageAction(e, t);
325
+ }
326
+ doSetUserContext(e, t) {
327
+ const s = window.newrelic;
328
+ if (s.setUserId && s.setUserId(e), t && s.setCustomAttribute) for (const [n, i] of Object.entries(t)) s.setCustomAttribute(n, i);
329
+ }
330
+ doSetGlobalAttributes(e) {
331
+ const t = window.newrelic;
332
+ if (t.setCustomAttribute) for (const [s, n] of Object.entries(e)) t.setCustomAttribute(s, n);
333
+ }
334
+ };
335
+ function L(e) {
336
+ return e && typeof e == "object" ? e : {};
337
+ }
338
+ function k(e) {
339
+ const t = L(L(e).loaderConfig);
340
+ return Object.keys(t).length > 0 ? t : null;
341
+ }
342
+ function T(e) {
343
+ if (!e || !("instrumentationProvider" in e)) return { kind: "unset" };
344
+ const t = e.instrumentationProvider;
345
+ return t === null ? { kind: "null" } : typeof t > "u" ? { kind: "unset" } : {
346
+ kind: "value",
347
+ value: t
348
+ };
349
+ }
350
+ function D(e) {
351
+ if (!e || !("trackPageActions" in e)) return;
352
+ const t = e.trackPageActions;
353
+ return typeof t == "boolean" ? t : void 0;
354
+ }
355
+ function ce(e, t) {
356
+ return e.kind === "value" || e.kind === "null" ? e : t;
357
+ }
358
+ var v, de = p("instrumentation-provider-resolution", () => f());
359
+ function le() {
360
+ return v || (v = new ae(), v.initialize()), v;
361
+ }
362
+ function ue(e) {
363
+ const t = k(e.runtimePlayer), s = k(e.player), n = D(t), i = D(s), c = n ?? i ?? !1, o = ce(T(t), T(s));
364
+ if (o.kind !== "null") {
365
+ if (o.kind === "unset") return c ? le() : void 0;
366
+ if (G(o.value)) return o.value;
367
+ if (e.debug) {
368
+ const r = e.component ? `[${e.component}] ` : "";
369
+ de.warn(`${r}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
370
+ }
371
+ }
372
+ }
373
+ var he = [
374
+ {
375
+ sourceEventName: "assessment-controller-ready",
376
+ instrumentationEventName: "pie-assessment-controller-ready"
377
+ },
378
+ {
379
+ sourceEventName: "assessment-navigation-requested",
380
+ instrumentationEventName: "pie-assessment-navigation-requested"
381
+ },
382
+ {
383
+ sourceEventName: "assessment-route-changed",
384
+ instrumentationEventName: "pie-assessment-route-changed"
385
+ },
386
+ {
387
+ sourceEventName: "assessment-session-applied",
388
+ instrumentationEventName: "pie-assessment-session-applied"
389
+ },
390
+ {
391
+ sourceEventName: "assessment-session-changed",
392
+ instrumentationEventName: "pie-assessment-session-changed"
393
+ },
394
+ {
395
+ sourceEventName: "assessment-progress-changed",
396
+ instrumentationEventName: "pie-assessment-progress-changed"
397
+ },
398
+ {
399
+ sourceEventName: "assessment-submission-state-changed",
400
+ instrumentationEventName: "pie-assessment-submission-state-changed"
401
+ },
402
+ {
403
+ sourceEventName: "assessment-error",
404
+ instrumentationEventName: "pie-assessment-error"
405
+ }
406
+ ];
407
+ function m() {
4
408
  return Date.now();
5
409
  }
6
- function g(n) {
7
- return n.replace(/[^a-zA-Z0-9_-]/g, "-");
410
+ function y(e) {
411
+ return e.replace(/[^a-zA-Z0-9_-]/g, "-");
8
412
  }
9
- function y(n) {
10
- if (n.attemptId)
11
- return `aas_v1_${g(n.assessmentId)}_${g(n.attemptId)}`;
12
- const e = S(), t = e ? v(e) : "anon";
13
- return `aas_v1_${g(n.assessmentId)}_${g(t)}`;
413
+ function me(e) {
414
+ if (e.attemptId) return `aas_v1_${y(e.assessmentId)}_${y(e.attemptId)}`;
415
+ const t = j(), s = t ? pe(t) : "anon";
416
+ return `aas_v1_${y(e.assessmentId)}_${y(s)}`;
14
417
  }
15
- function S() {
418
+ function j() {
16
419
  try {
17
420
  return typeof window > "u" ? null : window.localStorage;
18
421
  } catch {
19
422
  return null;
20
423
  }
21
424
  }
22
- function v(n) {
23
- const e = "pie:assessment-player:anonymous-device-id", t = n.getItem(e);
24
- if (t) return t;
25
- const s = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
26
- return n.setItem(e, s), s;
425
+ function pe(e) {
426
+ const t = "pie:assessment-player:anonymous-device-id", s = e.getItem(t);
427
+ if (s) return s;
428
+ const n = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
429
+ return e.setItem(t, n), n;
27
430
  }
28
- function f() {
431
+ function H() {
29
432
  return (/* @__PURE__ */ new Date()).toISOString();
30
433
  }
31
- function I(n) {
32
- const e = f(), t = n.sectionIdentifiers[0];
434
+ function fe(e) {
435
+ const t = H(), s = e.sectionIdentifiers[0];
33
436
  return {
34
437
  version: 1,
35
- assessmentAttemptSessionIdentifier: n.assessmentAttemptSessionIdentifier,
36
- assessmentId: n.assessmentId,
37
- startedAt: e,
38
- updatedAt: e,
438
+ assessmentAttemptSessionIdentifier: e.assessmentAttemptSessionIdentifier,
439
+ assessmentId: e.assessmentId,
440
+ startedAt: t,
441
+ updatedAt: t,
39
442
  navigationState: {
40
443
  currentSectionIndex: 0,
41
- visitedSectionIdentifiers: t ? [t] : [],
42
- currentSectionIdentifier: t
444
+ visitedSectionIdentifiers: s ? [s] : [],
445
+ currentSectionIdentifier: s
43
446
  },
44
447
  realization: {
45
- seed: n.seed,
46
- sectionIdentifiers: n.sectionIdentifiers
448
+ seed: e.seed,
449
+ sectionIdentifiers: e.sectionIdentifiers
47
450
  },
48
451
  sectionSessions: {}
49
452
  };
50
453
  }
51
- function b(n, e) {
52
- const t = f();
454
+ function ge(e, t) {
455
+ const s = H();
53
456
  return {
54
- ...n,
55
- updatedAt: t,
457
+ ...e,
458
+ updatedAt: s,
56
459
  sectionSessions: {
57
- ...n.sectionSessions,
58
- [e.sectionIdentifier]: {
59
- sectionIdentifier: e.sectionIdentifier,
60
- updatedAt: t,
61
- session: e.sectionSession
460
+ ...e.sectionSessions,
461
+ [t.sectionIdentifier]: {
462
+ sectionIdentifier: t.sectionIdentifier,
463
+ updatedAt: s,
464
+ session: t.sectionSession
62
465
  }
63
466
  }
64
467
  };
65
468
  }
66
- function C(n, e) {
67
- const t = new Set(n.navigationState.visitedSectionIdentifiers || []);
68
- return e.currentSectionIdentifier && t.add(e.currentSectionIdentifier), {
69
- ...n,
469
+ function ve(e, t) {
470
+ const s = new Set(e.navigationState.visitedSectionIdentifiers || []);
471
+ return t.currentSectionIdentifier && s.add(t.currentSectionIdentifier), {
472
+ ...e,
70
473
  navigationState: {
71
- ...n.navigationState,
72
- currentSectionIndex: e.currentSectionIndex,
73
- currentSectionIdentifier: e.currentSectionIdentifier,
74
- visitedSectionIdentifiers: Array.from(t)
474
+ ...e.navigationState,
475
+ currentSectionIndex: t.currentSectionIndex,
476
+ currentSectionIdentifier: t.currentSectionIdentifier,
477
+ visitedSectionIdentifiers: Array.from(s)
75
478
  }
76
479
  };
77
480
  }
78
- function x(n) {
79
- if (!n) return [];
80
- const e = [], t = n.testParts || [];
81
- return t.length > 0 ? (t.forEach((s, i) => {
82
- (s.sections || []).forEach((o, r) => {
83
- e.push({
84
- stageIdentifier: s.identifier,
481
+ function ye(e) {
482
+ if (!e) return [];
483
+ const t = [], s = e.testParts || [];
484
+ return s.length > 0 ? (s.forEach((n, i) => {
485
+ (n.sections || []).forEach((c, o) => {
486
+ t.push({
487
+ stageIdentifier: n.identifier,
85
488
  stageIndex: i,
86
- sectionIndex: e.length,
87
- sectionIdentifier: o.identifier || `section-${i}-${r}`,
88
- section: o
489
+ sectionIndex: t.length,
490
+ sectionIdentifier: c.identifier || `section-${i}-${o}`,
491
+ section: c
89
492
  });
90
493
  });
91
- }), e) : ((n.sections || []).forEach((s, i) => {
92
- e.push({
494
+ }), t) : ((e.sections || []).forEach((n, i) => {
495
+ t.push({
93
496
  stageIdentifier: "default",
94
497
  stageIndex: 0,
95
498
  sectionIndex: i,
96
- sectionIdentifier: s.identifier || `section-${i}`,
97
- section: s
499
+ sectionIdentifier: n.identifier || `section-${i}`,
500
+ section: n
98
501
  });
99
- }), e);
502
+ }), t);
100
503
  }
101
- class w {
504
+ var Se = class {
102
505
  constructor(e) {
103
506
  this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.storageContext = {
104
507
  assessmentId: e.assessmentId,
@@ -109,45 +512,39 @@ class w {
109
512
  for (const t of this.listeners) t(e);
110
513
  }
111
514
  handleError(e, t, s) {
112
- const i = e instanceof Error ? e : new Error(String(e));
113
- this.args.hooks?.onError?.(i, { phase: t, details: s });
515
+ const n = e instanceof Error ? e : new Error(String(e));
516
+ this.args.hooks?.onError?.(n, {
517
+ phase: t,
518
+ details: s
519
+ });
114
520
  }
115
521
  async getPersistenceStrategy() {
116
522
  if (this.persistenceStrategy) return this.persistenceStrategy;
117
- const e = {
118
- createDefaultPersistence: () => {
119
- const t = S(), s = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
120
- return {
121
- async loadSession() {
122
- if (!t) return null;
123
- const i = t.getItem(s);
124
- if (!i) return null;
125
- try {
126
- return JSON.parse(i);
127
- } catch {
128
- return null;
129
- }
130
- },
131
- async saveSession(i, o) {
132
- t && t.setItem(s, JSON.stringify(o));
133
- },
134
- async clearSession() {
135
- t && t.removeItem(s);
523
+ const e = { createDefaultPersistence: () => {
524
+ const t = j(), s = `pie:assessment-controller:v1:${this.storageContext.assessmentId}:${this.storageContext.attemptId || "default"}`;
525
+ return {
526
+ async loadSession() {
527
+ if (!t) return null;
528
+ const n = t.getItem(s);
529
+ if (!n) return null;
530
+ try {
531
+ return JSON.parse(n);
532
+ } catch {
533
+ return null;
136
534
  }
137
- };
138
- }
139
- };
140
- return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(
141
- this.storageContext,
142
- e
143
- ) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
535
+ },
536
+ async saveSession(n, i) {
537
+ t && t.setItem(s, JSON.stringify(i));
538
+ },
539
+ async clearSession() {
540
+ t && t.removeItem(s);
541
+ }
542
+ };
543
+ } };
544
+ return this.persistenceStrategy = await this.args.hooks?.createAssessmentSessionPersistence?.(this.storageContext, e) ?? await e.createDefaultPersistence(), this.persistenceStrategy;
144
545
  }
145
546
  async createDeliveryPlan() {
146
- const e = {
147
- createDefaultDeliveryPlan: () => ({
148
- sections: x(this.args.assessment)
149
- })
150
- }, t = {
547
+ const e = { createDefaultDeliveryPlan: () => ({ sections: ye(this.args.assessment) }) }, t = {
151
548
  assessmentId: this.args.assessmentId,
152
549
  attemptId: this.args.attemptId,
153
550
  assessment: this.args.assessment
@@ -157,8 +554,8 @@ class w {
157
554
  ensureSession() {
158
555
  if (this.session) return this.session;
159
556
  const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
160
- return this.session = I({
161
- assessmentAttemptSessionIdentifier: y({
557
+ return this.session = fe({
558
+ assessmentAttemptSessionIdentifier: me({
162
559
  assessmentId: this.args.assessmentId,
163
560
  attemptId: this.args.attemptId
164
561
  }),
@@ -178,8 +575,11 @@ class w {
178
575
  this.readiness = "hydrating";
179
576
  try {
180
577
  await this.args.hooks?.onBeforeAssessmentHydrate?.(this.storageContext);
181
- const t = await (await this.getPersistenceStrategy()).loadSession(this.storageContext);
182
- t && (this.session = t, this.emit({ type: "assessment-session-applied", timestamp: d() })), this.ensureSession(), this.readiness = "ready";
578
+ const e = await (await this.getPersistenceStrategy()).loadSession(this.storageContext);
579
+ e && (this.session = e, this.emit({
580
+ type: "assessment-session-applied",
581
+ timestamp: m()
582
+ })), this.ensureSession(), this.readiness = "ready";
183
583
  } catch (e) {
184
584
  this.readiness = "error", this.handleError(e, "session-load");
185
585
  }
@@ -187,10 +587,7 @@ class w {
187
587
  async persist() {
188
588
  try {
189
589
  const e = await this.getPersistenceStrategy();
190
- await this.args.hooks?.onBeforeAssessmentPersist?.(
191
- this.storageContext,
192
- this.session
193
- ), await e.saveSession(this.storageContext, this.session);
590
+ await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), await e.saveSession(this.storageContext, this.session);
194
591
  } catch (e) {
195
592
  this.handleError(e, "session-save");
196
593
  }
@@ -212,17 +609,11 @@ class w {
212
609
  };
213
610
  }
214
611
  buildNavigationSnapshot() {
215
- const e = this.deliveryPlan.sections.length, t = Math.max(
216
- 0,
217
- Math.min(
218
- e > 0 ? e - 1 : 0,
219
- this.session?.navigationState.currentSectionIndex || 0
220
- )
221
- ), s = this.deliveryPlan.sections[t];
612
+ const e = this.deliveryPlan.sections.length, t = Math.max(0, Math.min(e > 0 ? e - 1 : 0, this.session?.navigationState.currentSectionIndex || 0));
222
613
  return {
223
614
  currentSectionIndex: t,
224
615
  totalSections: e,
225
- currentSectionId: s?.sectionIdentifier,
616
+ currentSectionId: this.deliveryPlan.sections[t]?.sectionIdentifier,
226
617
  canNext: t < e - 1,
227
618
  canPrevious: t > 0
228
619
  };
@@ -230,34 +621,34 @@ class w {
230
621
  setIndex(e) {
231
622
  const t = this.buildNavigationSnapshot();
232
623
  if (e < 0 || e >= t.totalSections) return !1;
233
- const s = t.currentSectionId, i = this.deliveryPlan.sections[e];
234
- this.session = C(this.ensureSession(), {
624
+ const s = t.currentSectionId, n = this.deliveryPlan.sections[e];
625
+ this.session = ve(this.ensureSession(), {
235
626
  currentSectionIndex: e,
236
- currentSectionIdentifier: i?.sectionIdentifier
627
+ currentSectionIdentifier: n?.sectionIdentifier
237
628
  });
238
- const o = this.buildNavigationSnapshot();
629
+ const i = this.buildNavigationSnapshot();
239
630
  return this.emit({
240
631
  type: "assessment-route-changed",
241
- timestamp: d(),
242
- currentSectionIndex: o.currentSectionIndex,
243
- totalSections: o.totalSections,
244
- currentSectionId: o.currentSectionId,
632
+ timestamp: m(),
633
+ currentSectionIndex: i.currentSectionIndex,
634
+ totalSections: i.totalSections,
635
+ currentSectionId: i.currentSectionId,
245
636
  previousSectionId: s,
246
- canNext: o.canNext,
247
- canPrevious: o.canPrevious
248
- }), this.emit({ type: "assessment-session-changed", timestamp: d() }), this.emit({
637
+ canNext: i.canNext,
638
+ canPrevious: i.canPrevious
639
+ }), this.emit({
640
+ type: "assessment-session-changed",
641
+ timestamp: m()
642
+ }), this.emit({
249
643
  type: "assessment-progress-changed",
250
- timestamp: d(),
644
+ timestamp: m(),
251
645
  visitedSectionCount: this.ensureSession().navigationState.visitedSectionIdentifiers.length,
252
- totalSections: o.totalSections
646
+ totalSections: i.totalSections
253
647
  }), !0;
254
648
  }
255
649
  navigateTo(e) {
256
- if (typeof e == "number")
257
- return this.setIndex(e);
258
- const t = this.deliveryPlan.sections.findIndex(
259
- (s) => s.sectionIdentifier === e
260
- );
650
+ if (typeof e == "number") return this.setIndex(e);
651
+ const t = this.deliveryPlan.sections.findIndex((s) => s.sectionIdentifier === e);
261
652
  return t < 0 ? !1 : this.setIndex(t);
262
653
  }
263
654
  navigateNext() {
@@ -271,7 +662,7 @@ class w {
271
662
  async submit() {
272
663
  this.submitted = !0, this.emit({
273
664
  type: "assessment-submission-state-changed",
274
- timestamp: d(),
665
+ timestamp: m(),
275
666
  submitted: !0
276
667
  }), await this.persist();
277
668
  }
@@ -289,13 +680,15 @@ class w {
289
680
  return this.ensureSession().sectionSessions[e]?.session || null;
290
681
  }
291
682
  updateSectionSession(e, t) {
292
- this.session = b(this.ensureSession(), {
683
+ this.session = ge(this.ensureSession(), {
293
684
  sectionIdentifier: e,
294
685
  sectionSession: t
295
- }), this.emit({ type: "assessment-session-changed", timestamp: d() });
686
+ }), this.emit({
687
+ type: "assessment-session-changed",
688
+ timestamp: m()
689
+ });
296
690
  }
297
- }
298
- const l = {
691
+ }, u = {
299
692
  controllerReady: "assessment-controller-ready",
300
693
  navigationRequested: "assessment-navigation-requested",
301
694
  submitRequested: "assessment-submit-requested",
@@ -305,52 +698,65 @@ const l = {
305
698
  progressChanged: "assessment-progress-changed",
306
699
  submissionStateChanged: "assessment-submission-state-changed",
307
700
  error: "assessment-error"
308
- }, P = "pie-section-player-splitpane", N = "pie-section-player-vertical";
309
- function A(n, e = !1) {
310
- if (n == null) return e;
311
- if (typeof n == "boolean") return n;
312
- const t = n.trim().toLowerCase();
313
- return t === "" || t === "true" || t === "1" || t === "yes";
701
+ }, Ie = "pie-section-player-splitpane", be = "pie-section-player-vertical";
702
+ function Ee(e, t = !1) {
703
+ if (e == null) return t;
704
+ if (typeof e == "boolean") return e;
705
+ const s = e.trim().toLowerCase();
706
+ return s === "" || s === "true" || s === "1" || s === "yes";
314
707
  }
315
- class E extends HTMLElement {
316
- constructor() {
317
- super(), this.assessmentId = "", this.attemptId = "", this.assessment = null, this.env = null, this.coordinator = null, this.hooks = null, this.showNavigation = !0, this.sectionPlayerLayout = "splitpane", this.playerType = "iife", this.controller = null, this.controllerReadyPromise = null, this.controllerReadyResolve = null, this.sectionHost = null, this.sectionControllerRef = null, this.readiness = {
318
- phase: "bootstrapping"
319
- }, this.controllerReadyPromise = new Promise((e) => {
320
- this.controllerReadyResolve = e;
321
- });
322
- }
708
+ var Pe = class extends HTMLElement {
323
709
  static get observedAttributes() {
324
710
  return [
325
711
  "assessment-id",
326
712
  "attempt-id",
327
713
  "show-navigation",
328
714
  "section-player-layout",
329
- "player-type"
715
+ "player-type",
716
+ "debug"
330
717
  ];
331
718
  }
719
+ constructor() {
720
+ super(), this.assessmentId = "", this.attemptId = "", this.assessment = null, this.env = null, this.coordinator = null, this.hooks = null, this.showNavigation = !0, this.sectionPlayerLayout = "splitpane", this.playerType = "iife", this._debug = void 0, this.controller = null, this.controllerReadyPromise = null, this.controllerReadyResolve = null, this.sectionHost = null, this.sectionControllerRef = null, this._sectionPlayerRuntime = null, this._sectionPlayerPlayer = null, this.readiness = { phase: "bootstrapping" }, this.controllerReadyPromise = new Promise((e) => {
721
+ this.controllerReadyResolve = e;
722
+ });
723
+ }
332
724
  attributeChangedCallback(e, t, s) {
333
- e === "assessment-id" && (this.assessmentId = s || ""), e === "attempt-id" && (this.attemptId = s || ""), e === "show-navigation" && (this.showNavigation = s), e === "section-player-layout" && (this.sectionPlayerLayout = s === "vertical" ? "vertical" : "splitpane"), e === "player-type" && (this.playerType = s || "iife"), this.isConnected && this.bootstrapController();
725
+ e === "assessment-id" && (this.assessmentId = s || ""), e === "attempt-id" && (this.attemptId = s || ""), e === "show-navigation" && (this.showNavigation = s), e === "section-player-layout" && (this.sectionPlayerLayout = s === "vertical" ? "vertical" : "splitpane"), e === "player-type" && (this.playerType = s || "iife"), e === "debug" && (this.debug = s), this.isConnected && this.bootstrapController();
726
+ }
727
+ get debug() {
728
+ return this._debug;
729
+ }
730
+ set debug(e) {
731
+ this._debug = e, this.applyDebugFlag();
732
+ }
733
+ get sectionPlayerRuntime() {
734
+ return this._sectionPlayerRuntime;
735
+ }
736
+ set sectionPlayerRuntime(e) {
737
+ this._sectionPlayerRuntime = e, this.isConnected && this.attachInstrumentationBridge();
738
+ }
739
+ get sectionPlayerPlayer() {
740
+ return this._sectionPlayerPlayer;
741
+ }
742
+ set sectionPlayerPlayer(e) {
743
+ this._sectionPlayerPlayer = e, this.isConnected && this.attachInstrumentationBridge();
334
744
  }
335
745
  connectedCallback() {
336
- this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation;
337
- const e = this.getAttribute("section-player-layout");
338
- this.sectionPlayerLayout = e === "vertical" ? "vertical" : this.sectionPlayerLayout;
339
- const t = this.getAttribute("player-type");
340
- t && (this.playerType = t), this.bootstrapController();
746
+ this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation, this.sectionPlayerLayout = this.getAttribute("section-player-layout") === "vertical" ? "vertical" : this.sectionPlayerLayout;
747
+ const e = this.getAttribute("player-type");
748
+ e && (this.playerType = e), this.debug = this.getAttribute("debug") ?? this.debug, this.attachInstrumentationBridge(), this.bootstrapController();
341
749
  }
342
750
  disconnectedCallback() {
343
- this.unsubscribeController?.(), this.hooks?.onAssessmentControllerDispose?.(this.controller || void 0);
751
+ this.unsubscribeController?.(), this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = void 0, this.hooks?.onAssessmentControllerDispose?.(this.controller || void 0);
344
752
  }
345
753
  dispatch(e, t, s = !1) {
346
- return this.dispatchEvent(
347
- new CustomEvent(e, {
348
- detail: t,
349
- bubbles: !0,
350
- composed: !0,
351
- cancelable: s
352
- })
353
- );
754
+ return this.dispatchEvent(new CustomEvent(e, {
755
+ detail: t,
756
+ bubbles: !0,
757
+ composed: !0,
758
+ cancelable: s
759
+ }));
354
760
  }
355
761
  async bootstrapController() {
356
762
  if (!this.assessmentId || !this.assessment) {
@@ -358,26 +764,40 @@ class E extends HTMLElement {
358
764
  return;
359
765
  }
360
766
  this.readiness = { phase: "bootstrapping" }, this.render();
361
- const e = new w({
767
+ const e = new Se({
362
768
  assessmentId: this.assessmentId,
363
769
  attemptId: this.attemptId || void 0,
364
770
  assessment: this.assessment,
365
771
  hooks: this.hooks || void 0
366
772
  });
367
773
  this.unsubscribeController?.(), this.controller = e, this.unsubscribeController = e.subscribe((t) => {
368
- t.type === "assessment-route-changed" && (this.dispatch(
369
- l.routeChanged,
370
- t
371
- ), this.render()), t.type === "assessment-session-applied" && this.dispatch(l.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(l.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(
372
- l.progressChanged,
373
- t
374
- ), t.type === "assessment-submission-state-changed" && this.dispatch(
375
- l.submissionStateChanged,
376
- t
377
- );
378
- }), await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(l.controllerReady, {
379
- controller: e
380
- }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
774
+ t.type === "assessment-route-changed" && (this.dispatch(u.routeChanged, t), this.render()), t.type === "assessment-session-applied" && this.dispatch(u.sessionApplied, t), t.type === "assessment-session-changed" && this.dispatch(u.sessionChanged, t), t.type === "assessment-progress-changed" && this.dispatch(u.progressChanged, t), t.type === "assessment-submission-state-changed" && this.dispatch(u.submissionStateChanged, t);
775
+ });
776
+ try {
777
+ await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(u.controllerReady, { controller: e }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
778
+ } catch (t) {
779
+ this.readiness = { phase: "error" }, this.dispatch(u.error, { error: t }), this.renderEmptyState("Failed to initialize assessment player");
780
+ }
781
+ }
782
+ resolveInstrumentationProvider() {
783
+ return ue({
784
+ runtimePlayer: this.sectionPlayerRuntime?.player,
785
+ player: this.sectionPlayerPlayer,
786
+ component: "pie-assessment-player-default"
787
+ });
788
+ }
789
+ attachInstrumentationBridge() {
790
+ this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = re({
791
+ host: this,
792
+ instrumentationProvider: this.resolveInstrumentationProvider(),
793
+ component: "pie-assessment-player-default",
794
+ eventMap: he,
795
+ staticAttributes: {
796
+ instrumentationLayer: "assessment",
797
+ assessmentId: this.assessmentId,
798
+ attemptId: this.attemptId || void 0
799
+ }
800
+ });
381
801
  }
382
802
  renderEmptyState(e) {
383
803
  this.innerHTML = "";
@@ -385,7 +805,7 @@ class E extends HTMLElement {
385
805
  t.className = "pie-assessment-player-empty", t.textContent = e, this.appendChild(t);
386
806
  }
387
807
  buildSectionPlayerTag() {
388
- return this.sectionPlayerLayout === "vertical" ? N : P;
808
+ return this.sectionPlayerLayout === "vertical" ? be : Ie;
389
809
  }
390
810
  syncCurrentSectionSessionIntoAssessment() {
391
811
  const e = this.controller;
@@ -393,28 +813,18 @@ class E extends HTMLElement {
393
813
  const t = this.sectionControllerRef || this.sectionHost?.firstElementChild?.getSectionController?.();
394
814
  if (!t?.getSession) return;
395
815
  const s = e.getCurrentSection();
396
- s && e.updateSectionSession(
397
- s.sectionIdentifier,
398
- t.getSession()
399
- );
816
+ s && e.updateSectionSession(s.sectionIdentifier, t.getSession());
400
817
  }
401
818
  attachSectionControllerReadyListener(e, t) {
402
819
  e.addEventListener("section-controller-ready", async (s) => {
403
- const i = s.detail;
404
- this.sectionControllerRef = i?.controller || null;
405
- const o = this.controller?.getSectionSession(t);
406
- o && this.sectionControllerRef?.applySession && await this.sectionControllerRef.applySession(o, { mode: "replace" });
407
- }), e.addEventListener(
408
- "session-changed",
409
- () => this.syncCurrentSectionSessionIntoAssessment()
410
- ), e.addEventListener(
411
- "item-session-changed",
412
- () => this.syncCurrentSectionSessionIntoAssessment()
413
- );
820
+ this.sectionControllerRef = s.detail?.controller || null;
821
+ const n = this.controller?.getSectionSession(t);
822
+ n && this.sectionControllerRef?.applySession && await this.sectionControllerRef.applySession(n, { mode: "replace" });
823
+ }), e.addEventListener("session-changed", () => this.syncCurrentSectionSessionIntoAssessment()), e.addEventListener("item-session-changed", () => this.syncCurrentSectionSessionIntoAssessment());
414
824
  }
415
825
  render() {
416
826
  const e = this.controller;
417
- this.innerHTML = "";
827
+ this.attachInstrumentationBridge(), this.innerHTML = "";
418
828
  const t = document.createElement("div");
419
829
  t.className = "pie-assessment-player-default";
420
830
  const s = document.createElement("style");
@@ -466,34 +876,39 @@ class E extends HTMLElement {
466
876
  overflow: hidden;
467
877
  }
468
878
  `, t.appendChild(s);
469
- const i = this.getSnapshot();
470
- if (A(this.showNavigation, !0)) {
471
- const c = document.createElement("div");
472
- c.className = "pie-assessment-player-navigation";
473
- const a = document.createElement("div");
474
- a.className = "pie-assessment-player-current-position", a.textContent = i.navigation.totalSections > 0 ? `Section ${i.navigation.currentIndex + 1} of ${i.navigation.totalSections}` : "No sections";
475
- const p = document.createElement("div");
476
- p.className = "pie-assessment-player-nav-controls";
477
- const u = document.createElement("button");
478
- u.className = "pie-assessment-player-nav-btn", u.textContent = "Back", u.disabled = !i.navigation.canPrevious, u.addEventListener("click", () => {
479
- this.navigatePrevious();
480
- });
481
- const m = document.createElement("button");
482
- m.className = "pie-assessment-player-nav-btn", m.textContent = "Next", m.disabled = !i.navigation.canNext, m.addEventListener("click", () => {
483
- this.navigateNext();
484
- }), p.appendChild(u), p.appendChild(m), c.appendChild(a), c.appendChild(p), t.appendChild(c);
879
+ const n = this.getSnapshot();
880
+ if (Ee(this.showNavigation, !0)) {
881
+ const o = document.createElement("div");
882
+ o.className = "pie-assessment-player-navigation";
883
+ const r = document.createElement("div");
884
+ r.className = "pie-assessment-player-current-position", r.textContent = n.navigation.totalSections > 0 ? `Section ${n.navigation.currentIndex + 1} of ${n.navigation.totalSections}` : "No sections";
885
+ const d = document.createElement("div");
886
+ d.className = "pie-assessment-player-nav-controls";
887
+ const l = document.createElement("button");
888
+ l.className = "pie-assessment-player-nav-btn", l.textContent = "Back", l.disabled = !n.navigation.canPrevious, l.addEventListener("click", () => void this.navigatePrevious());
889
+ const h = document.createElement("button");
890
+ h.className = "pie-assessment-player-nav-btn", h.textContent = "Next", h.disabled = !n.navigation.canNext, h.addEventListener("click", () => void this.navigateNext()), d.appendChild(l), d.appendChild(h), o.appendChild(r), o.appendChild(d), t.appendChild(o);
485
891
  }
486
- const r = document.createElement("div");
487
- r.className = "pie-assessment-player-section-host", this.sectionHost = r;
488
- const h = e?.getCurrentSection() || null;
489
- if (h) {
490
- const c = this.buildSectionPlayerTag(), a = document.createElement(c);
491
- a.setAttribute("assessment-id", this.assessmentId), a.setAttribute("section-id", h.sectionIdentifier), this.attemptId && a.setAttribute("attempt-id", this.attemptId), a.setAttribute("player-type", this.playerType), a.section = h.section, this.env && (a.env = this.env), this.coordinator && (a.coordinator = this.coordinator), this.attachSectionControllerReadyListener(
492
- a,
493
- h.sectionIdentifier
494
- ), r.appendChild(a);
892
+ const i = document.createElement("div");
893
+ i.className = "pie-assessment-player-section-host", this.sectionHost = i;
894
+ const c = e?.getCurrentSection() || null;
895
+ if (c) {
896
+ const o = this.buildSectionPlayerTag(), r = document.createElement(o);
897
+ if (r.setAttribute("assessment-id", this.assessmentId), r.setAttribute("section-id", c.sectionIdentifier), this.attemptId && r.setAttribute("attempt-id", this.attemptId), r.setAttribute("player-type", this.playerType), this.debug !== void 0 && this.debug !== null) {
898
+ const d = typeof this.debug == "boolean" ? String(this.debug) : this.debug;
899
+ r.setAttribute("debug", d);
900
+ }
901
+ r.section = c.section, this.env && (r.env = this.env), this.coordinator && (r.coordinator = this.coordinator), this.sectionPlayerRuntime && (r.runtime = this.sectionPlayerRuntime), this.sectionPlayerPlayer && (r.player = this.sectionPlayerPlayer), this.attachSectionControllerReadyListener(r, c.sectionIdentifier), i.appendChild(r);
902
+ }
903
+ t.appendChild(i), this.appendChild(t);
904
+ }
905
+ applyDebugFlag() {
906
+ if (this.debug === void 0 || this.debug === null || typeof window > "u") return;
907
+ const e = String(this.debug), t = !(e.toLowerCase() === "false" || e === "0" || e === "");
908
+ try {
909
+ window.PIE_DEBUG = t;
910
+ } catch {
495
911
  }
496
- t.appendChild(r), this.appendChild(t);
497
912
  }
498
913
  getSnapshot() {
499
914
  const e = this.controller?.getRuntimeState() || {
@@ -503,12 +918,11 @@ class E extends HTMLElement {
503
918
  currentSectionId: void 0,
504
919
  canNext: !1,
505
920
  canPrevious: !1,
506
- visitedSections: 0
921
+ visitedSections: 0,
922
+ submitted: !1
507
923
  };
508
924
  return {
509
- readiness: {
510
- phase: e.readiness
511
- },
925
+ readiness: { phase: e.readiness },
512
926
  navigation: {
513
927
  currentIndex: e.currentSectionIndex,
514
928
  totalSections: e.totalSections,
@@ -532,84 +946,69 @@ class E extends HTMLElement {
532
946
  return this.getSnapshot().progress;
533
947
  }
534
948
  navigateTo(e) {
535
- const t = this.selectNavigation(), s = t.currentIndex, i = t.currentSectionId;
536
- let o = s, r;
949
+ const t = this.selectNavigation(), s = t.currentIndex, n = t.currentSectionId;
950
+ let i = s, c;
537
951
  if (typeof e == "number")
538
- o = e, r = this.controller?.getSectionAt(o)?.sectionIdentifier;
539
- else if (r = e, this.controller?.getCurrentSection()?.sectionIdentifier === r) return !0;
540
- if (!this.dispatch(
541
- l.navigationRequested,
542
- {
543
- fromIndex: s,
544
- toIndex: o,
545
- fromSectionId: i,
546
- toSectionId: r,
547
- reason: "navigate-to"
548
- },
549
- !0
550
- )) return !1;
952
+ i = e, c = this.controller?.getSectionAt(i)?.sectionIdentifier;
953
+ else if (c = e, this.controller?.getCurrentSection()?.sectionIdentifier === c) return !0;
954
+ if (!this.dispatch(u.navigationRequested, {
955
+ fromIndex: s,
956
+ toIndex: i,
957
+ fromSectionId: n,
958
+ toSectionId: c,
959
+ reason: "navigate-to"
960
+ }, !0)) return !1;
551
961
  this.syncCurrentSectionSessionIntoAssessment();
552
- const c = this.controller?.navigateTo(e) === !0;
553
- return c && this.controller?.persist(), c;
962
+ const o = this.controller?.navigateTo(e) === !0;
963
+ return o && this.controller?.persist(), o;
554
964
  }
555
965
  navigateNext() {
556
966
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
557
- if (!this.dispatch(
558
- l.navigationRequested,
559
- {
560
- fromIndex: e.currentIndex,
561
- toIndex: e.currentIndex + 1,
562
- fromSectionId: e.currentSectionId,
563
- toSectionId: t?.sectionIdentifier,
564
- reason: "navigate-next"
565
- },
566
- !0
567
- )) return !1;
967
+ if (!this.dispatch(u.navigationRequested, {
968
+ fromIndex: e.currentIndex,
969
+ toIndex: e.currentIndex + 1,
970
+ fromSectionId: e.currentSectionId,
971
+ toSectionId: t?.sectionIdentifier,
972
+ reason: "navigate-next"
973
+ }, !0)) return !1;
568
974
  this.syncCurrentSectionSessionIntoAssessment();
569
- const i = this.controller?.navigateNext() === !0;
570
- return i && this.controller?.persist(), i;
975
+ const s = this.controller?.navigateNext() === !0;
976
+ return s && this.controller?.persist(), s;
571
977
  }
572
978
  navigatePrevious() {
573
979
  const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
574
- if (!this.dispatch(
575
- l.navigationRequested,
576
- {
577
- fromIndex: e.currentIndex,
578
- toIndex: e.currentIndex - 1,
579
- fromSectionId: e.currentSectionId,
580
- toSectionId: t?.sectionIdentifier,
581
- reason: "navigate-previous"
582
- },
583
- !0
584
- )) return !1;
980
+ if (!this.dispatch(u.navigationRequested, {
981
+ fromIndex: e.currentIndex,
982
+ toIndex: e.currentIndex - 1,
983
+ fromSectionId: e.currentSectionId,
984
+ toSectionId: t?.sectionIdentifier,
985
+ reason: "navigate-previous"
986
+ }, !0)) return !1;
585
987
  this.syncCurrentSectionSessionIntoAssessment();
586
- const i = this.controller?.navigatePrevious() === !0;
587
- return i && this.controller?.persist(), i;
988
+ const s = this.controller?.navigatePrevious() === !0;
989
+ return s && this.controller?.persist(), s;
588
990
  }
589
991
  getAssessmentController() {
590
992
  return this.controller;
591
993
  }
592
994
  async waitForAssessmentController(e = 5e3) {
593
995
  if (this.controller) return this.controller;
594
- const t = this.controllerReadyPromise || Promise.resolve(null), s = new Promise((i) => {
595
- setTimeout(() => i(null), e);
996
+ const t = this.controllerReadyPromise || Promise.resolve(null), s = new Promise((n) => {
997
+ setTimeout(() => n(null), e);
596
998
  });
597
999
  return Promise.race([t, s]);
598
1000
  }
1001
+ };
1002
+ customElements.get("pie-assessment-player-default") || customElements.define("pie-assessment-player-default", Pe);
1003
+ function we(e, t = !1) {
1004
+ if (e == null) return t;
1005
+ if (typeof e == "boolean") return e;
1006
+ const s = e.trim().toLowerCase();
1007
+ return s === "" || s === "true" || s === "1" || s === "yes";
599
1008
  }
600
- customElements.get("pie-assessment-player-default") || customElements.define(
601
- "pie-assessment-player-default",
602
- E
603
- );
604
- function R(n, e = !1) {
605
- if (n == null) return e;
606
- if (typeof n == "boolean") return n;
607
- const t = n.trim().toLowerCase();
608
- return t === "" || t === "true" || t === "1" || t === "yes";
609
- }
610
- class k extends HTMLElement {
611
- constructor() {
612
- super(...arguments), this.showNavigation = !0;
1009
+ var Ne = class extends HTMLElement {
1010
+ constructor(...e) {
1011
+ super(...e), this.showNavigation = !0;
613
1012
  }
614
1013
  static get observedAttributes() {
615
1014
  return ["show-navigation"];
@@ -621,7 +1020,7 @@ class k extends HTMLElement {
621
1020
  e === "show-navigation" && (this.showNavigation = s), this.render();
622
1021
  }
623
1022
  render() {
624
- const e = R(this.showNavigation, !0);
1023
+ const e = we(this.showNavigation, !0);
625
1024
  this.innerHTML = "";
626
1025
  const t = document.createElement("style");
627
1026
  t.textContent = `
@@ -644,16 +1043,16 @@ class k extends HTMLElement {
644
1043
  `;
645
1044
  const s = document.createElement("div");
646
1045
  if (s.className = "pie-assessment-player-shell", e) {
647
- const r = document.createElement("slot");
648
- r.name = "navigation", s.appendChild(r);
1046
+ const c = document.createElement("slot");
1047
+ c.name = "navigation", s.appendChild(c);
649
1048
  }
650
- const i = document.createElement("div");
651
- i.className = "pie-assessment-player-shell__body";
652
- const o = document.createElement("slot");
653
- i.appendChild(o), s.appendChild(i), this.appendChild(t), this.appendChild(s);
1049
+ const n = document.createElement("div");
1050
+ n.className = "pie-assessment-player-shell__body";
1051
+ const i = document.createElement("slot");
1052
+ n.appendChild(i), s.appendChild(n), this.appendChild(t), this.appendChild(s);
654
1053
  }
655
- }
656
- customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell", k);
1054
+ };
1055
+ customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell", Ne);
657
1056
  export {
658
- l as ASSESSMENT_PLAYER_PUBLIC_EVENTS
1057
+ u as ASSESSMENT_PLAYER_PUBLIC_EVENTS
659
1058
  };