@pie-players/pie-assessment-player 0.3.19 → 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.
- package/dist/pie-assessment-player.js +503 -635
- package/package.json +5 -5
|
@@ -1,252 +1,286 @@
|
|
|
1
|
-
var M = Object.defineProperty;
|
|
2
|
-
var z = (s, e, t) => e in s ? M(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var f = (s, e, t) => z(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
1
|
import "@pie-players/pie-section-player/components/section-player-splitpane-element";
|
|
5
2
|
import "@pie-players/pie-section-player/components/section-player-vertical-element";
|
|
6
|
-
function
|
|
7
|
-
const
|
|
3
|
+
function p(e, t) {
|
|
4
|
+
const s = `[${e}]`;
|
|
8
5
|
return {
|
|
9
|
-
// Only debug method checks debugEnabledFn - it's checked dynamically on every call
|
|
10
6
|
debug: (n, ...i) => {
|
|
11
|
-
|
|
7
|
+
t() && console.debug(s, n, ...i);
|
|
12
8
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error: (n, ...i) => console.error(t, n, ...i)
|
|
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)
|
|
17
12
|
};
|
|
18
13
|
}
|
|
19
|
-
function
|
|
14
|
+
function f() {
|
|
20
15
|
return typeof window < "u" && window.PIE_DEBUG === !0;
|
|
21
16
|
}
|
|
22
|
-
var
|
|
23
|
-
(function(
|
|
24
|
-
|
|
25
|
-
})(
|
|
26
|
-
var
|
|
27
|
-
(function(
|
|
28
|
-
|
|
29
|
-
})(
|
|
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
|
+
}
|
|
30
55
|
typeof window < "u" && !window.pieHelpers && (window.pieHelpers = {
|
|
31
56
|
loadingScripts: {},
|
|
32
57
|
loadingPromises: {}
|
|
33
58
|
});
|
|
34
|
-
|
|
35
|
-
function
|
|
59
|
+
var _ = "https://proxy.pie-api.com", q = `${_}/bundles/`;
|
|
60
|
+
function U(e) {
|
|
36
61
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
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;
|
|
40
70
|
} catch {
|
|
41
71
|
}
|
|
42
72
|
}
|
|
43
|
-
typeof window < "u" && window.PIE_BUILDER_ORIGIN_URL ||
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(function(s) {
|
|
47
|
-
s.SAVE = "save", s.MODEL = "model", s.SCORE = "score", s.MANUAL_SCORE = "manual-score";
|
|
48
|
-
})(w || (w = {}));
|
|
49
|
-
var P;
|
|
50
|
-
(function(s) {
|
|
51
|
-
s.AUTO = "auto", s.MANUAL = "manual";
|
|
52
|
-
})(P || (P = {}));
|
|
53
|
-
var N;
|
|
54
|
-
(function(s) {
|
|
55
|
-
s.GATHER = "gather", s.VIEW = "view", s.EVALUATE = "evaluate";
|
|
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";
|
|
56
76
|
})(N || (N = {}));
|
|
57
77
|
var C;
|
|
58
|
-
(function(
|
|
59
|
-
|
|
78
|
+
(function(e) {
|
|
79
|
+
e.AUTO = "auto", e.MANUAL = "manual";
|
|
60
80
|
})(C || (C = {}));
|
|
61
81
|
var A;
|
|
62
|
-
(function(
|
|
63
|
-
|
|
82
|
+
(function(e) {
|
|
83
|
+
e.GATHER = "gather", e.VIEW = "view", e.EVALUATE = "evaluate";
|
|
64
84
|
})(A || (A = {}));
|
|
65
|
-
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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";
|
|
71
172
|
}
|
|
72
|
-
|
|
73
|
-
function
|
|
74
|
-
return
|
|
173
|
+
var te = p("instrumentation-event-bridge", () => f());
|
|
174
|
+
function se(e) {
|
|
175
|
+
return e && typeof e == "object" ? e : typeof e > "u" ? {} : { value: e };
|
|
75
176
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
177
|
+
function ne(e) {
|
|
178
|
+
te.warn(`[InstrumentationEventBridge:${e}] Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
|
|
78
179
|
}
|
|
79
|
-
function
|
|
180
|
+
function ie(e) {
|
|
80
181
|
try {
|
|
81
|
-
|
|
82
|
-
component:
|
|
182
|
+
e.provider.trackError(e.error instanceof Error ? e.error : new Error(String(e.error ?? "Unknown instrumentation bridge error")), {
|
|
183
|
+
component: e.component,
|
|
83
184
|
errorType: "InstrumentationBridgeError",
|
|
84
|
-
sourceEventName:
|
|
185
|
+
sourceEventName: e.sourceEventName
|
|
85
186
|
});
|
|
86
187
|
} catch {
|
|
87
188
|
}
|
|
88
189
|
}
|
|
89
|
-
function
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (!U(s.instrumentationProvider))
|
|
97
|
-
return s.debug && j(s.component), () => {
|
|
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), () => {
|
|
98
197
|
};
|
|
99
|
-
const
|
|
198
|
+
const t = e.instrumentationProvider, s = [], n = Math.max(0, e.dedupeWindowMs ?? 0), i = /* @__PURE__ */ new Map(), c = (o, r) => {
|
|
100
199
|
const d = [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
].map((
|
|
108
|
-
return `${
|
|
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}`;
|
|
109
208
|
};
|
|
110
|
-
for (const
|
|
111
|
-
const
|
|
209
|
+
for (const o of e.eventMap) {
|
|
210
|
+
const r = (d) => {
|
|
112
211
|
try {
|
|
113
|
-
if (!
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
timestamp: m
|
|
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
|
|
121
219
|
};
|
|
122
220
|
if (n > 0) {
|
|
123
|
-
const
|
|
124
|
-
if (typeof
|
|
125
|
-
|
|
126
|
-
i.set(I, S);
|
|
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);
|
|
127
224
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
error: a,
|
|
136
|
-
sourceEventName: r.sourceEventName
|
|
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
|
|
137
232
|
});
|
|
138
233
|
}
|
|
139
234
|
};
|
|
140
|
-
|
|
141
|
-
|
|
235
|
+
e.host.addEventListener(o.sourceEventName, r), s.push(() => {
|
|
236
|
+
e.host?.removeEventListener(o.sourceEventName, r);
|
|
142
237
|
});
|
|
143
238
|
}
|
|
144
239
|
return () => {
|
|
145
|
-
for (const
|
|
146
|
-
r();
|
|
240
|
+
for (const o of s) o();
|
|
147
241
|
};
|
|
148
242
|
}
|
|
149
|
-
class
|
|
243
|
+
var oe = class {
|
|
150
244
|
constructor() {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
// ============================================================================
|
|
155
|
-
// Public API methods (template methods)
|
|
156
|
-
// ============================================================================
|
|
157
|
-
/**
|
|
158
|
-
* Track an error with the instrumentation provider
|
|
159
|
-
*
|
|
160
|
-
* Template method that:
|
|
161
|
-
* 1. Checks if provider is ready
|
|
162
|
-
* 2. Applies error filter if configured
|
|
163
|
-
* 3. Transforms attributes if configured
|
|
164
|
-
* 4. Delegates to concrete provider implementation (doTrackError)
|
|
165
|
-
*
|
|
166
|
-
* @param error The error to track
|
|
167
|
-
* @param attributes Contextual attributes
|
|
168
|
-
*/
|
|
245
|
+
a(this, "initialized", !1), a(this, "config", void 0);
|
|
246
|
+
}
|
|
169
247
|
trackError(e, t) {
|
|
170
|
-
if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t))
|
|
171
|
-
|
|
172
|
-
const n = this.transformAttributes(t);
|
|
248
|
+
if (!this.guardedOperation("trackError", e, t) || !this.applyErrorFilter(e, t)) return;
|
|
249
|
+
const s = this.transformAttributes(t);
|
|
173
250
|
try {
|
|
174
|
-
this.doTrackError(e,
|
|
175
|
-
} catch (
|
|
176
|
-
console.error(`[${this.providerName}] Error tracking error:`,
|
|
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);
|
|
177
254
|
}
|
|
178
255
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Track a custom event with the instrumentation provider
|
|
181
|
-
*
|
|
182
|
-
* Template method that:
|
|
183
|
-
* 1. Checks if provider is ready
|
|
184
|
-
* 2. Applies event filter if configured
|
|
185
|
-
* 3. Applies sampling if configured
|
|
186
|
-
* 4. Transforms attributes if configured
|
|
187
|
-
* 5. Adds timestamp if not present
|
|
188
|
-
* 6. Delegates to concrete provider implementation (doTrackEvent)
|
|
189
|
-
*
|
|
190
|
-
* @param eventName Name of the event
|
|
191
|
-
* @param attributes Event attributes
|
|
192
|
-
*/
|
|
193
256
|
trackEvent(e, t) {
|
|
194
|
-
if (!this.guardedOperation("trackEvent", e, t) || !this.applyEventFilter(e, t) || !this.applySampling(e))
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
...n,
|
|
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,
|
|
199
261
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
200
262
|
});
|
|
201
263
|
try {
|
|
202
|
-
this.doTrackEvent(e,
|
|
203
|
-
} catch (
|
|
204
|
-
console.error(`[${this.providerName}] Error tracking event:`,
|
|
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);
|
|
205
267
|
}
|
|
206
268
|
}
|
|
207
|
-
|
|
208
|
-
* Track a performance metric
|
|
209
|
-
*
|
|
210
|
-
* Default implementation tracks metrics as events with a `metric:` prefix.
|
|
211
|
-
* Concrete providers can override this method if their backend has a
|
|
212
|
-
* dedicated metric API.
|
|
213
|
-
*
|
|
214
|
-
* @param metricName Name of the metric
|
|
215
|
-
* @param value Numeric value
|
|
216
|
-
* @param attributes Optional metric attributes
|
|
217
|
-
*/
|
|
218
|
-
trackMetric(e, t, n) {
|
|
269
|
+
trackMetric(e, t, s) {
|
|
219
270
|
this.trackEvent(`metric:${e}`, {
|
|
220
|
-
...
|
|
271
|
+
...s,
|
|
221
272
|
metricValue: t,
|
|
222
273
|
metricName: e
|
|
223
274
|
});
|
|
224
275
|
}
|
|
225
|
-
/**
|
|
226
|
-
* Set user context for session tracking
|
|
227
|
-
*
|
|
228
|
-
* Template method that checks if provider is ready then delegates
|
|
229
|
-
* to concrete provider implementation.
|
|
230
|
-
*
|
|
231
|
-
* @param userId User identifier
|
|
232
|
-
* @param attributes Optional user attributes
|
|
233
|
-
*/
|
|
234
276
|
setUserContext(e, t) {
|
|
235
277
|
if (this.guardedOperation("setUserContext", e, t))
|
|
236
278
|
try {
|
|
237
279
|
this.doSetUserContext(e, t), this.config?.debug && console.log(`[${this.providerName}] Set user context:`, e, t);
|
|
238
|
-
} catch (
|
|
239
|
-
console.error(`[${this.providerName}] Error setting user context:`,
|
|
280
|
+
} catch (s) {
|
|
281
|
+
console.error(`[${this.providerName}] Error setting user context:`, s);
|
|
240
282
|
}
|
|
241
283
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Set global custom attributes
|
|
244
|
-
*
|
|
245
|
-
* Template method that checks if provider is ready then delegates
|
|
246
|
-
* to concrete provider implementation.
|
|
247
|
-
*
|
|
248
|
-
* @param attributes Attributes to set globally
|
|
249
|
-
*/
|
|
250
284
|
setGlobalAttributes(e) {
|
|
251
285
|
if (this.guardedOperation("setGlobalAttributes", e))
|
|
252
286
|
try {
|
|
@@ -255,191 +289,88 @@ class W {
|
|
|
255
289
|
console.error(`[${this.providerName}] Error setting global attributes:`, t);
|
|
256
290
|
}
|
|
257
291
|
}
|
|
258
|
-
// ============================================================================
|
|
259
|
-
// Protected utility methods (shared logic)
|
|
260
|
-
// ============================================================================
|
|
261
|
-
/**
|
|
262
|
-
* Guard operation - check if provider is ready
|
|
263
|
-
*
|
|
264
|
-
* Returns false if provider is not ready, logging a warning in debug mode.
|
|
265
|
-
*
|
|
266
|
-
* @param operation Name of the operation for logging
|
|
267
|
-
* @param args Arguments for logging
|
|
268
|
-
* @returns true if provider is ready, false otherwise
|
|
269
|
-
*/
|
|
270
292
|
guardedOperation(e, ...t) {
|
|
271
293
|
return this.isReady() ? !0 : (this.config?.debug && console.warn(`[${this.providerName}] Attempted to ${e} but provider not ready:`, ...t), !1);
|
|
272
294
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Apply error filter if configured
|
|
275
|
-
*
|
|
276
|
-
* Returns false if error should be filtered out, logging in debug mode.
|
|
277
|
-
*
|
|
278
|
-
* @param error The error
|
|
279
|
-
* @param attributes Error attributes
|
|
280
|
-
* @returns true if error should be tracked, false if filtered out
|
|
281
|
-
*/
|
|
282
295
|
applyErrorFilter(e, t) {
|
|
283
296
|
return this.config?.errorFilter && !this.config.errorFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Error filtered out:`, e, t), !1) : !0;
|
|
284
297
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Apply event filter if configured
|
|
287
|
-
*
|
|
288
|
-
* Returns false if event should be filtered out, logging in debug mode.
|
|
289
|
-
*
|
|
290
|
-
* @param eventName Event name
|
|
291
|
-
* @param attributes Event attributes
|
|
292
|
-
* @returns true if event should be tracked, false if filtered out
|
|
293
|
-
*/
|
|
294
298
|
applyEventFilter(e, t) {
|
|
295
299
|
return this.config?.eventFilter && !this.config.eventFilter(e, t) ? (this.config?.debug && console.log(`[${this.providerName}] Event filtered out:`, e, t), !1) : !0;
|
|
296
300
|
}
|
|
297
|
-
/**
|
|
298
|
-
* Apply sampling if configured
|
|
299
|
-
*
|
|
300
|
-
* Returns false if event should be sampled out, logging in debug mode.
|
|
301
|
-
*
|
|
302
|
-
* @param eventName Event name for logging
|
|
303
|
-
* @returns true if event should be tracked, false if sampled out
|
|
304
|
-
*/
|
|
305
301
|
applySampling(e) {
|
|
306
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;
|
|
307
303
|
}
|
|
308
|
-
/**
|
|
309
|
-
* Transform attributes if transformer is configured
|
|
310
|
-
*
|
|
311
|
-
* @param attributes Original attributes
|
|
312
|
-
* @returns Transformed attributes or original if no transformer
|
|
313
|
-
*/
|
|
314
304
|
transformAttributes(e) {
|
|
315
305
|
return this.config?.attributeTransformer ? this.config.attributeTransformer(e) : e;
|
|
316
306
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Initialize the New Relic provider
|
|
326
|
-
*
|
|
327
|
-
* Checks if the New Relic Browser Agent is available via `window.newrelic`.
|
|
328
|
-
* If not available, initialization succeeds but `isReady()` will return false.
|
|
329
|
-
*
|
|
330
|
-
* @param config Optional configuration
|
|
331
|
-
*/
|
|
332
|
-
async initialize(t) {
|
|
333
|
-
this.config = t, 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);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Check if provider is ready
|
|
337
|
-
*
|
|
338
|
-
* @returns true if New Relic is available and initialized
|
|
339
|
-
*/
|
|
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
|
+
}
|
|
340
314
|
isReady() {
|
|
341
315
|
return this.initialized && typeof window < "u" && !!window.newrelic;
|
|
342
316
|
}
|
|
343
|
-
/**
|
|
344
|
-
* Cleanup provider resources
|
|
345
|
-
*
|
|
346
|
-
* Marks provider as uninitialized. The global `window.newrelic` object
|
|
347
|
-
* is not modified.
|
|
348
|
-
*/
|
|
349
317
|
destroy() {
|
|
350
318
|
this.initialized = !1, this.config?.debug && console.log("[NewRelicProvider] Destroyed");
|
|
351
319
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
*
|
|
355
|
-
* Calls `newrelic.noticeError(error, attributes)`
|
|
356
|
-
*
|
|
357
|
-
* @param error The error to track
|
|
358
|
-
* @param attributes Transformed attributes (already filtered and transformed by base class)
|
|
359
|
-
*/
|
|
360
|
-
doTrackError(t, n) {
|
|
361
|
-
window.newrelic.noticeError(t, n);
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Track a custom event/page action with New Relic
|
|
365
|
-
*
|
|
366
|
-
* Calls `newrelic.addPageAction(eventName, attributes)`
|
|
367
|
-
*
|
|
368
|
-
* @param eventName Name of the event
|
|
369
|
-
* @param attributes Transformed attributes (already filtered and transformed by base class)
|
|
370
|
-
*/
|
|
371
|
-
doTrackEvent(t, n) {
|
|
372
|
-
window.newrelic.addPageAction(t, n);
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Set user context for session tracking
|
|
376
|
-
*
|
|
377
|
-
* Calls `newrelic.setUserId()` and `newrelic.setCustomAttribute()` for user attributes.
|
|
378
|
-
*
|
|
379
|
-
* @param userId User identifier
|
|
380
|
-
* @param attributes Optional user attributes
|
|
381
|
-
*/
|
|
382
|
-
doSetUserContext(t, n) {
|
|
383
|
-
const i = window.newrelic;
|
|
384
|
-
if (i.setUserId && i.setUserId(t), n && i.setCustomAttribute)
|
|
385
|
-
for (const [o, r] of Object.entries(n))
|
|
386
|
-
i.setCustomAttribute(o, r);
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Set global custom attributes
|
|
390
|
-
*
|
|
391
|
-
* Calls `newrelic.setCustomAttribute()` for each attribute.
|
|
392
|
-
*
|
|
393
|
-
* @param attributes Attributes to set globally
|
|
394
|
-
*/
|
|
395
|
-
doSetGlobalAttributes(t) {
|
|
396
|
-
const n = window.newrelic;
|
|
397
|
-
if (n.setCustomAttribute)
|
|
398
|
-
for (const [i, o] of Object.entries(t))
|
|
399
|
-
n.setCustomAttribute(i, o);
|
|
320
|
+
doTrackError(e, t) {
|
|
321
|
+
window.newrelic.noticeError(e, t);
|
|
400
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 : {};
|
|
401
337
|
}
|
|
402
|
-
function
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
function R(s) {
|
|
406
|
-
const e = x(s), t = x(e.loaderConfig);
|
|
338
|
+
function k(e) {
|
|
339
|
+
const t = L(L(e).loaderConfig);
|
|
407
340
|
return Object.keys(t).length > 0 ? t : null;
|
|
408
341
|
}
|
|
409
|
-
function
|
|
410
|
-
if (!
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
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
|
+
};
|
|
414
349
|
}
|
|
415
|
-
function
|
|
416
|
-
if (!
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return typeof e == "boolean" ? e : void 0;
|
|
350
|
+
function D(e) {
|
|
351
|
+
if (!e || !("trackPageActions" in e)) return;
|
|
352
|
+
const t = e.trackPageActions;
|
|
353
|
+
return typeof t == "boolean" ? t : void 0;
|
|
420
354
|
}
|
|
421
|
-
function
|
|
422
|
-
return
|
|
355
|
+
function ce(e, t) {
|
|
356
|
+
return e.kind === "value" || e.kind === "null" ? e : t;
|
|
423
357
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return g || (g = new K(), g.initialize()), g;
|
|
358
|
+
var v, de = p("instrumentation-provider-resolution", () => f());
|
|
359
|
+
function le() {
|
|
360
|
+
return v || (v = new ae(), v.initialize()), v;
|
|
428
361
|
}
|
|
429
|
-
function
|
|
430
|
-
const
|
|
431
|
-
if (
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
if (
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const c = s.component ? `[${s.component}] ` : "";
|
|
438
|
-
Z.warn(`${c}Ignoring invalid instrumentation provider; expected InstrumentationProvider contract`);
|
|
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`);
|
|
439
370
|
}
|
|
440
371
|
}
|
|
441
372
|
}
|
|
442
|
-
|
|
373
|
+
var he = [
|
|
443
374
|
{
|
|
444
375
|
sourceEventName: "assessment-controller-ready",
|
|
445
376
|
instrumentationEventName: "pie-assessment-controller-ready"
|
|
@@ -473,105 +404,104 @@ const ee = [
|
|
|
473
404
|
instrumentationEventName: "pie-assessment-error"
|
|
474
405
|
}
|
|
475
406
|
];
|
|
476
|
-
function
|
|
407
|
+
function m() {
|
|
477
408
|
return Date.now();
|
|
478
409
|
}
|
|
479
|
-
function
|
|
480
|
-
return
|
|
410
|
+
function y(e) {
|
|
411
|
+
return e.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
481
412
|
}
|
|
482
|
-
function
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return `aas_v1_${v(s.assessmentId)}_${v(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)}`;
|
|
487
417
|
}
|
|
488
|
-
function
|
|
418
|
+
function j() {
|
|
489
419
|
try {
|
|
490
420
|
return typeof window > "u" ? null : window.localStorage;
|
|
491
421
|
} catch {
|
|
492
422
|
return null;
|
|
493
423
|
}
|
|
494
424
|
}
|
|
495
|
-
function
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
425
|
+
function pe(e) {
|
|
426
|
+
const t = "pie:assessment-player:anonymous-device-id", s = e.getItem(t);
|
|
427
|
+
if (s) return s;
|
|
498
428
|
const n = `anon-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
|
|
499
|
-
return
|
|
429
|
+
return e.setItem(t, n), n;
|
|
500
430
|
}
|
|
501
|
-
function
|
|
431
|
+
function H() {
|
|
502
432
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
503
433
|
}
|
|
504
|
-
function
|
|
505
|
-
const
|
|
434
|
+
function fe(e) {
|
|
435
|
+
const t = H(), s = e.sectionIdentifiers[0];
|
|
506
436
|
return {
|
|
507
437
|
version: 1,
|
|
508
|
-
assessmentAttemptSessionIdentifier:
|
|
509
|
-
assessmentId:
|
|
510
|
-
startedAt:
|
|
511
|
-
updatedAt:
|
|
438
|
+
assessmentAttemptSessionIdentifier: e.assessmentAttemptSessionIdentifier,
|
|
439
|
+
assessmentId: e.assessmentId,
|
|
440
|
+
startedAt: t,
|
|
441
|
+
updatedAt: t,
|
|
512
442
|
navigationState: {
|
|
513
443
|
currentSectionIndex: 0,
|
|
514
|
-
visitedSectionIdentifiers:
|
|
515
|
-
currentSectionIdentifier:
|
|
444
|
+
visitedSectionIdentifiers: s ? [s] : [],
|
|
445
|
+
currentSectionIdentifier: s
|
|
516
446
|
},
|
|
517
447
|
realization: {
|
|
518
|
-
seed:
|
|
519
|
-
sectionIdentifiers:
|
|
448
|
+
seed: e.seed,
|
|
449
|
+
sectionIdentifiers: e.sectionIdentifiers
|
|
520
450
|
},
|
|
521
451
|
sectionSessions: {}
|
|
522
452
|
};
|
|
523
453
|
}
|
|
524
|
-
function
|
|
525
|
-
const
|
|
454
|
+
function ge(e, t) {
|
|
455
|
+
const s = H();
|
|
526
456
|
return {
|
|
527
|
-
...
|
|
528
|
-
updatedAt:
|
|
457
|
+
...e,
|
|
458
|
+
updatedAt: s,
|
|
529
459
|
sectionSessions: {
|
|
530
|
-
...
|
|
531
|
-
[
|
|
532
|
-
sectionIdentifier:
|
|
533
|
-
updatedAt:
|
|
534
|
-
session:
|
|
460
|
+
...e.sectionSessions,
|
|
461
|
+
[t.sectionIdentifier]: {
|
|
462
|
+
sectionIdentifier: t.sectionIdentifier,
|
|
463
|
+
updatedAt: s,
|
|
464
|
+
session: t.sectionSession
|
|
535
465
|
}
|
|
536
466
|
}
|
|
537
467
|
};
|
|
538
468
|
}
|
|
539
|
-
function
|
|
540
|
-
const
|
|
541
|
-
return
|
|
542
|
-
...
|
|
469
|
+
function ve(e, t) {
|
|
470
|
+
const s = new Set(e.navigationState.visitedSectionIdentifiers || []);
|
|
471
|
+
return t.currentSectionIdentifier && s.add(t.currentSectionIdentifier), {
|
|
472
|
+
...e,
|
|
543
473
|
navigationState: {
|
|
544
|
-
...
|
|
545
|
-
currentSectionIndex:
|
|
546
|
-
currentSectionIdentifier:
|
|
547
|
-
visitedSectionIdentifiers: Array.from(
|
|
474
|
+
...e.navigationState,
|
|
475
|
+
currentSectionIndex: t.currentSectionIndex,
|
|
476
|
+
currentSectionIdentifier: t.currentSectionIdentifier,
|
|
477
|
+
visitedSectionIdentifiers: Array.from(s)
|
|
548
478
|
}
|
|
549
479
|
};
|
|
550
480
|
}
|
|
551
|
-
function
|
|
552
|
-
if (!
|
|
553
|
-
const
|
|
554
|
-
return
|
|
555
|
-
(n.sections || []).forEach((
|
|
556
|
-
|
|
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({
|
|
557
487
|
stageIdentifier: n.identifier,
|
|
558
488
|
stageIndex: i,
|
|
559
|
-
sectionIndex:
|
|
560
|
-
sectionIdentifier:
|
|
561
|
-
section:
|
|
489
|
+
sectionIndex: t.length,
|
|
490
|
+
sectionIdentifier: c.identifier || `section-${i}-${o}`,
|
|
491
|
+
section: c
|
|
562
492
|
});
|
|
563
493
|
});
|
|
564
|
-
}),
|
|
565
|
-
|
|
494
|
+
}), t) : ((e.sections || []).forEach((n, i) => {
|
|
495
|
+
t.push({
|
|
566
496
|
stageIdentifier: "default",
|
|
567
497
|
stageIndex: 0,
|
|
568
498
|
sectionIndex: i,
|
|
569
499
|
sectionIdentifier: n.identifier || `section-${i}`,
|
|
570
500
|
section: n
|
|
571
501
|
});
|
|
572
|
-
}),
|
|
502
|
+
}), t);
|
|
573
503
|
}
|
|
574
|
-
class
|
|
504
|
+
var Se = class {
|
|
575
505
|
constructor(e) {
|
|
576
506
|
this.args = e, this.listeners = /* @__PURE__ */ new Set(), this.deliveryPlan = { sections: [] }, this.session = null, this.readiness = "bootstrapping", this.submitted = !1, this.storageContext = {
|
|
577
507
|
assessmentId: e.assessmentId,
|
|
@@ -581,46 +511,40 @@ class ae {
|
|
|
581
511
|
emit(e) {
|
|
582
512
|
for (const t of this.listeners) t(e);
|
|
583
513
|
}
|
|
584
|
-
handleError(e, t,
|
|
585
|
-
const
|
|
586
|
-
this.args.hooks?.onError?.(
|
|
514
|
+
handleError(e, t, 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
|
+
});
|
|
587
520
|
}
|
|
588
521
|
async getPersistenceStrategy() {
|
|
589
522
|
if (this.persistenceStrategy) return this.persistenceStrategy;
|
|
590
|
-
const e = {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
return null;
|
|
602
|
-
}
|
|
603
|
-
},
|
|
604
|
-
async saveSession(i, o) {
|
|
605
|
-
t && t.setItem(n, JSON.stringify(o));
|
|
606
|
-
},
|
|
607
|
-
async clearSession() {
|
|
608
|
-
t && t.removeItem(n);
|
|
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;
|
|
609
534
|
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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;
|
|
617
545
|
}
|
|
618
546
|
async createDeliveryPlan() {
|
|
619
|
-
const e = {
|
|
620
|
-
createDefaultDeliveryPlan: () => ({
|
|
621
|
-
sections: oe(this.args.assessment)
|
|
622
|
-
})
|
|
623
|
-
}, t = {
|
|
547
|
+
const e = { createDefaultDeliveryPlan: () => ({ sections: ye(this.args.assessment) }) }, t = {
|
|
624
548
|
assessmentId: this.args.assessmentId,
|
|
625
549
|
attemptId: this.args.attemptId,
|
|
626
550
|
assessment: this.args.assessment
|
|
@@ -630,8 +554,8 @@ class ae {
|
|
|
630
554
|
ensureSession() {
|
|
631
555
|
if (this.session) return this.session;
|
|
632
556
|
const e = this.deliveryPlan.sections.map((t) => t.sectionIdentifier);
|
|
633
|
-
return this.session =
|
|
634
|
-
assessmentAttemptSessionIdentifier:
|
|
557
|
+
return this.session = fe({
|
|
558
|
+
assessmentAttemptSessionIdentifier: me({
|
|
635
559
|
assessmentId: this.args.assessmentId,
|
|
636
560
|
attemptId: this.args.attemptId
|
|
637
561
|
}),
|
|
@@ -651,8 +575,11 @@ class ae {
|
|
|
651
575
|
this.readiness = "hydrating";
|
|
652
576
|
try {
|
|
653
577
|
await this.args.hooks?.onBeforeAssessmentHydrate?.(this.storageContext);
|
|
654
|
-
const
|
|
655
|
-
|
|
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";
|
|
656
583
|
} catch (e) {
|
|
657
584
|
this.readiness = "error", this.handleError(e, "session-load");
|
|
658
585
|
}
|
|
@@ -660,10 +587,7 @@ class ae {
|
|
|
660
587
|
async persist() {
|
|
661
588
|
try {
|
|
662
589
|
const e = await this.getPersistenceStrategy();
|
|
663
|
-
await this.args.hooks?.onBeforeAssessmentPersist?.(
|
|
664
|
-
this.storageContext,
|
|
665
|
-
this.session
|
|
666
|
-
), await e.saveSession(this.storageContext, this.session);
|
|
590
|
+
await this.args.hooks?.onBeforeAssessmentPersist?.(this.storageContext, this.session), await e.saveSession(this.storageContext, this.session);
|
|
667
591
|
} catch (e) {
|
|
668
592
|
this.handleError(e, "session-save");
|
|
669
593
|
}
|
|
@@ -685,17 +609,11 @@ class ae {
|
|
|
685
609
|
};
|
|
686
610
|
}
|
|
687
611
|
buildNavigationSnapshot() {
|
|
688
|
-
const e = this.deliveryPlan.sections.length, t = Math.max(
|
|
689
|
-
0,
|
|
690
|
-
Math.min(
|
|
691
|
-
e > 0 ? e - 1 : 0,
|
|
692
|
-
this.session?.navigationState.currentSectionIndex || 0
|
|
693
|
-
)
|
|
694
|
-
), n = 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));
|
|
695
613
|
return {
|
|
696
614
|
currentSectionIndex: t,
|
|
697
615
|
totalSections: e,
|
|
698
|
-
currentSectionId:
|
|
616
|
+
currentSectionId: this.deliveryPlan.sections[t]?.sectionIdentifier,
|
|
699
617
|
canNext: t < e - 1,
|
|
700
618
|
canPrevious: t > 0
|
|
701
619
|
};
|
|
@@ -703,34 +621,34 @@ class ae {
|
|
|
703
621
|
setIndex(e) {
|
|
704
622
|
const t = this.buildNavigationSnapshot();
|
|
705
623
|
if (e < 0 || e >= t.totalSections) return !1;
|
|
706
|
-
const
|
|
707
|
-
this.session =
|
|
624
|
+
const s = t.currentSectionId, n = this.deliveryPlan.sections[e];
|
|
625
|
+
this.session = ve(this.ensureSession(), {
|
|
708
626
|
currentSectionIndex: e,
|
|
709
|
-
currentSectionIdentifier:
|
|
627
|
+
currentSectionIdentifier: n?.sectionIdentifier
|
|
710
628
|
});
|
|
711
|
-
const
|
|
629
|
+
const i = this.buildNavigationSnapshot();
|
|
712
630
|
return this.emit({
|
|
713
631
|
type: "assessment-route-changed",
|
|
714
|
-
timestamp:
|
|
715
|
-
currentSectionIndex:
|
|
716
|
-
totalSections:
|
|
717
|
-
currentSectionId:
|
|
718
|
-
previousSectionId:
|
|
719
|
-
canNext:
|
|
720
|
-
canPrevious:
|
|
721
|
-
}), this.emit({
|
|
632
|
+
timestamp: m(),
|
|
633
|
+
currentSectionIndex: i.currentSectionIndex,
|
|
634
|
+
totalSections: i.totalSections,
|
|
635
|
+
currentSectionId: i.currentSectionId,
|
|
636
|
+
previousSectionId: s,
|
|
637
|
+
canNext: i.canNext,
|
|
638
|
+
canPrevious: i.canPrevious
|
|
639
|
+
}), this.emit({
|
|
640
|
+
type: "assessment-session-changed",
|
|
641
|
+
timestamp: m()
|
|
642
|
+
}), this.emit({
|
|
722
643
|
type: "assessment-progress-changed",
|
|
723
|
-
timestamp:
|
|
644
|
+
timestamp: m(),
|
|
724
645
|
visitedSectionCount: this.ensureSession().navigationState.visitedSectionIdentifiers.length,
|
|
725
|
-
totalSections:
|
|
646
|
+
totalSections: i.totalSections
|
|
726
647
|
}), !0;
|
|
727
648
|
}
|
|
728
649
|
navigateTo(e) {
|
|
729
|
-
if (typeof e == "number")
|
|
730
|
-
|
|
731
|
-
const t = this.deliveryPlan.sections.findIndex(
|
|
732
|
-
(n) => n.sectionIdentifier === e
|
|
733
|
-
);
|
|
650
|
+
if (typeof e == "number") return this.setIndex(e);
|
|
651
|
+
const t = this.deliveryPlan.sections.findIndex((s) => s.sectionIdentifier === e);
|
|
734
652
|
return t < 0 ? !1 : this.setIndex(t);
|
|
735
653
|
}
|
|
736
654
|
navigateNext() {
|
|
@@ -744,7 +662,7 @@ class ae {
|
|
|
744
662
|
async submit() {
|
|
745
663
|
this.submitted = !0, this.emit({
|
|
746
664
|
type: "assessment-submission-state-changed",
|
|
747
|
-
timestamp:
|
|
665
|
+
timestamp: m(),
|
|
748
666
|
submitted: !0
|
|
749
667
|
}), await this.persist();
|
|
750
668
|
}
|
|
@@ -762,13 +680,15 @@ class ae {
|
|
|
762
680
|
return this.ensureSession().sectionSessions[e]?.session || null;
|
|
763
681
|
}
|
|
764
682
|
updateSectionSession(e, t) {
|
|
765
|
-
this.session =
|
|
683
|
+
this.session = ge(this.ensureSession(), {
|
|
766
684
|
sectionIdentifier: e,
|
|
767
685
|
sectionSession: t
|
|
768
|
-
}), this.emit({
|
|
686
|
+
}), this.emit({
|
|
687
|
+
type: "assessment-session-changed",
|
|
688
|
+
timestamp: m()
|
|
689
|
+
});
|
|
769
690
|
}
|
|
770
|
-
}
|
|
771
|
-
const l = {
|
|
691
|
+
}, u = {
|
|
772
692
|
controllerReady: "assessment-controller-ready",
|
|
773
693
|
navigationRequested: "assessment-navigation-requested",
|
|
774
694
|
submitRequested: "assessment-submit-requested",
|
|
@@ -778,21 +698,14 @@ const l = {
|
|
|
778
698
|
progressChanged: "assessment-progress-changed",
|
|
779
699
|
submissionStateChanged: "assessment-submission-state-changed",
|
|
780
700
|
error: "assessment-error"
|
|
781
|
-
},
|
|
782
|
-
function
|
|
783
|
-
if (
|
|
784
|
-
if (typeof
|
|
785
|
-
const
|
|
786
|
-
return
|
|
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";
|
|
787
707
|
}
|
|
788
|
-
class
|
|
789
|
-
constructor() {
|
|
790
|
-
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 = {
|
|
791
|
-
phase: "bootstrapping"
|
|
792
|
-
}, this.controllerReadyPromise = new Promise((e) => {
|
|
793
|
-
this.controllerReadyResolve = e;
|
|
794
|
-
});
|
|
795
|
-
}
|
|
708
|
+
var Pe = class extends HTMLElement {
|
|
796
709
|
static get observedAttributes() {
|
|
797
710
|
return [
|
|
798
711
|
"assessment-id",
|
|
@@ -803,8 +716,13 @@ class ue extends HTMLElement {
|
|
|
803
716
|
"debug"
|
|
804
717
|
];
|
|
805
718
|
}
|
|
806
|
-
|
|
807
|
-
|
|
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
|
+
}
|
|
724
|
+
attributeChangedCallback(e, t, s) {
|
|
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();
|
|
808
726
|
}
|
|
809
727
|
get debug() {
|
|
810
728
|
return this._debug;
|
|
@@ -825,24 +743,20 @@ class ue extends HTMLElement {
|
|
|
825
743
|
this._sectionPlayerPlayer = e, this.isConnected && this.attachInstrumentationBridge();
|
|
826
744
|
}
|
|
827
745
|
connectedCallback() {
|
|
828
|
-
this.assessmentId || (this.assessmentId = this.getAttribute("assessment-id") || ""), this.attemptId || (this.attemptId = this.getAttribute("attempt-id") || ""), this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation;
|
|
829
|
-
const e = this.getAttribute("
|
|
830
|
-
this.
|
|
831
|
-
const t = this.getAttribute("player-type");
|
|
832
|
-
t && (this.playerType = t), this.debug = this.getAttribute("debug") ?? this.debug, this.attachInstrumentationBridge(), 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();
|
|
833
749
|
}
|
|
834
750
|
disconnectedCallback() {
|
|
835
751
|
this.unsubscribeController?.(), this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = void 0, this.hooks?.onAssessmentControllerDispose?.(this.controller || void 0);
|
|
836
752
|
}
|
|
837
|
-
dispatch(e, t,
|
|
838
|
-
return this.dispatchEvent(
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
})
|
|
845
|
-
);
|
|
753
|
+
dispatch(e, t, s = !1) {
|
|
754
|
+
return this.dispatchEvent(new CustomEvent(e, {
|
|
755
|
+
detail: t,
|
|
756
|
+
bubbles: !0,
|
|
757
|
+
composed: !0,
|
|
758
|
+
cancelable: s
|
|
759
|
+
}));
|
|
846
760
|
}
|
|
847
761
|
async bootstrapController() {
|
|
848
762
|
if (!this.assessmentId || !this.assessment) {
|
|
@@ -850,47 +764,34 @@ class ue extends HTMLElement {
|
|
|
850
764
|
return;
|
|
851
765
|
}
|
|
852
766
|
this.readiness = { phase: "bootstrapping" }, this.render();
|
|
853
|
-
const e = new
|
|
767
|
+
const e = new Se({
|
|
854
768
|
assessmentId: this.assessmentId,
|
|
855
769
|
attemptId: this.attemptId || void 0,
|
|
856
770
|
assessment: this.assessment,
|
|
857
771
|
hooks: this.hooks || void 0
|
|
858
772
|
});
|
|
859
773
|
this.unsubscribeController?.(), this.controller = e, this.unsubscribeController = e.subscribe((t) => {
|
|
860
|
-
t.type === "assessment-route-changed" && (this.dispatch(
|
|
861
|
-
l.routeChanged,
|
|
862
|
-
t
|
|
863
|
-
), 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(
|
|
864
|
-
l.progressChanged,
|
|
865
|
-
t
|
|
866
|
-
), t.type === "assessment-submission-state-changed" && this.dispatch(
|
|
867
|
-
l.submissionStateChanged,
|
|
868
|
-
t
|
|
869
|
-
);
|
|
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);
|
|
870
775
|
});
|
|
871
776
|
try {
|
|
872
|
-
await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(
|
|
873
|
-
controller: e
|
|
874
|
-
}), this.hooks?.onAssessmentControllerReady?.(e), this.render();
|
|
777
|
+
await e.initialize(), this.readiness = { phase: "ready" }, this.controllerReadyResolve?.(e), this.dispatch(u.controllerReady, { controller: e }), this.hooks?.onAssessmentControllerReady?.(e), this.render();
|
|
875
778
|
} catch (t) {
|
|
876
|
-
this.readiness = { phase: "error" }, this.dispatch(
|
|
877
|
-
error: t
|
|
878
|
-
}), this.renderEmptyState("Failed to initialize assessment player");
|
|
779
|
+
this.readiness = { phase: "error" }, this.dispatch(u.error, { error: t }), this.renderEmptyState("Failed to initialize assessment player");
|
|
879
780
|
}
|
|
880
781
|
}
|
|
881
782
|
resolveInstrumentationProvider() {
|
|
882
|
-
return
|
|
783
|
+
return ue({
|
|
883
784
|
runtimePlayer: this.sectionPlayerRuntime?.player,
|
|
884
785
|
player: this.sectionPlayerPlayer,
|
|
885
786
|
component: "pie-assessment-player-default"
|
|
886
787
|
});
|
|
887
788
|
}
|
|
888
789
|
attachInstrumentationBridge() {
|
|
889
|
-
this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge =
|
|
790
|
+
this.detachInstrumentationBridge?.(), this.detachInstrumentationBridge = re({
|
|
890
791
|
host: this,
|
|
891
792
|
instrumentationProvider: this.resolveInstrumentationProvider(),
|
|
892
793
|
component: "pie-assessment-player-default",
|
|
893
|
-
eventMap:
|
|
794
|
+
eventMap: he,
|
|
894
795
|
staticAttributes: {
|
|
895
796
|
instrumentationLayer: "assessment",
|
|
896
797
|
assessmentId: this.assessmentId,
|
|
@@ -904,40 +805,30 @@ class ue extends HTMLElement {
|
|
|
904
805
|
t.className = "pie-assessment-player-empty", t.textContent = e, this.appendChild(t);
|
|
905
806
|
}
|
|
906
807
|
buildSectionPlayerTag() {
|
|
907
|
-
return this.sectionPlayerLayout === "vertical" ?
|
|
808
|
+
return this.sectionPlayerLayout === "vertical" ? be : Ie;
|
|
908
809
|
}
|
|
909
810
|
syncCurrentSectionSessionIntoAssessment() {
|
|
910
811
|
const e = this.controller;
|
|
911
812
|
if (!e) return;
|
|
912
813
|
const t = this.sectionControllerRef || this.sectionHost?.firstElementChild?.getSectionController?.();
|
|
913
814
|
if (!t?.getSession) return;
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
n.sectionIdentifier,
|
|
917
|
-
t.getSession()
|
|
918
|
-
);
|
|
815
|
+
const s = e.getCurrentSection();
|
|
816
|
+
s && e.updateSectionSession(s.sectionIdentifier, t.getSession());
|
|
919
817
|
}
|
|
920
818
|
attachSectionControllerReadyListener(e, t) {
|
|
921
|
-
e.addEventListener("section-controller-ready", async (
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}), e.addEventListener(
|
|
927
|
-
"session-changed",
|
|
928
|
-
() => this.syncCurrentSectionSessionIntoAssessment()
|
|
929
|
-
), e.addEventListener(
|
|
930
|
-
"item-session-changed",
|
|
931
|
-
() => this.syncCurrentSectionSessionIntoAssessment()
|
|
932
|
-
);
|
|
819
|
+
e.addEventListener("section-controller-ready", async (s) => {
|
|
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());
|
|
933
824
|
}
|
|
934
825
|
render() {
|
|
935
826
|
const e = this.controller;
|
|
936
827
|
this.attachInstrumentationBridge(), this.innerHTML = "";
|
|
937
828
|
const t = document.createElement("div");
|
|
938
829
|
t.className = "pie-assessment-player-default";
|
|
939
|
-
const
|
|
940
|
-
|
|
830
|
+
const s = document.createElement("style");
|
|
831
|
+
s.textContent = `
|
|
941
832
|
:host {
|
|
942
833
|
display: block;
|
|
943
834
|
height: 100%;
|
|
@@ -984,39 +875,32 @@ class ue extends HTMLElement {
|
|
|
984
875
|
height: 100%;
|
|
985
876
|
overflow: hidden;
|
|
986
877
|
}
|
|
987
|
-
`, t.appendChild(
|
|
988
|
-
const
|
|
989
|
-
if (
|
|
878
|
+
`, t.appendChild(s);
|
|
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";
|
|
990
885
|
const d = document.createElement("div");
|
|
991
|
-
d.className = "pie-assessment-player-
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
const u = document.createElement("div");
|
|
995
|
-
u.className = "pie-assessment-player-nav-controls";
|
|
996
|
-
const m = document.createElement("button");
|
|
997
|
-
m.className = "pie-assessment-player-nav-btn", m.textContent = "Back", m.disabled = !i.navigation.canPrevious, m.addEventListener("click", () => {
|
|
998
|
-
this.navigatePrevious();
|
|
999
|
-
});
|
|
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());
|
|
1000
889
|
const h = document.createElement("button");
|
|
1001
|
-
h.className = "pie-assessment-player-nav-btn", h.textContent = "Next", h.disabled = !
|
|
1002
|
-
this.navigateNext();
|
|
1003
|
-
}), u.appendChild(m), u.appendChild(h), d.appendChild(a), d.appendChild(u), t.appendChild(d);
|
|
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);
|
|
1004
891
|
}
|
|
1005
|
-
const
|
|
1006
|
-
|
|
892
|
+
const i = document.createElement("div");
|
|
893
|
+
i.className = "pie-assessment-player-section-host", this.sectionHost = i;
|
|
1007
894
|
const c = e?.getCurrentSection() || null;
|
|
1008
895
|
if (c) {
|
|
1009
|
-
const
|
|
1010
|
-
if (
|
|
1011
|
-
const
|
|
1012
|
-
|
|
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);
|
|
1013
900
|
}
|
|
1014
|
-
|
|
1015
|
-
a,
|
|
1016
|
-
c.sectionIdentifier
|
|
1017
|
-
), r.appendChild(a);
|
|
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);
|
|
1018
902
|
}
|
|
1019
|
-
t.appendChild(
|
|
903
|
+
t.appendChild(i), this.appendChild(t);
|
|
1020
904
|
}
|
|
1021
905
|
applyDebugFlag() {
|
|
1022
906
|
if (this.debug === void 0 || this.debug === null || typeof window > "u") return;
|
|
@@ -1034,12 +918,11 @@ class ue extends HTMLElement {
|
|
|
1034
918
|
currentSectionId: void 0,
|
|
1035
919
|
canNext: !1,
|
|
1036
920
|
canPrevious: !1,
|
|
1037
|
-
visitedSections: 0
|
|
921
|
+
visitedSections: 0,
|
|
922
|
+
submitted: !1
|
|
1038
923
|
};
|
|
1039
924
|
return {
|
|
1040
|
-
readiness: {
|
|
1041
|
-
phase: e.readiness
|
|
1042
|
-
},
|
|
925
|
+
readiness: { phase: e.readiness },
|
|
1043
926
|
navigation: {
|
|
1044
927
|
currentIndex: e.currentSectionIndex,
|
|
1045
928
|
totalSections: e.totalSections,
|
|
@@ -1063,84 +946,69 @@ class ue extends HTMLElement {
|
|
|
1063
946
|
return this.getSnapshot().progress;
|
|
1064
947
|
}
|
|
1065
948
|
navigateTo(e) {
|
|
1066
|
-
const t = this.selectNavigation(),
|
|
1067
|
-
let
|
|
949
|
+
const t = this.selectNavigation(), s = t.currentIndex, n = t.currentSectionId;
|
|
950
|
+
let i = s, c;
|
|
1068
951
|
if (typeof e == "number")
|
|
1069
|
-
|
|
1070
|
-
else if (
|
|
1071
|
-
if (!this.dispatch(
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
reason: "navigate-to"
|
|
1079
|
-
},
|
|
1080
|
-
!0
|
|
1081
|
-
)) 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;
|
|
1082
961
|
this.syncCurrentSectionSessionIntoAssessment();
|
|
1083
|
-
const
|
|
1084
|
-
return
|
|
962
|
+
const o = this.controller?.navigateTo(e) === !0;
|
|
963
|
+
return o && this.controller?.persist(), o;
|
|
1085
964
|
}
|
|
1086
965
|
navigateNext() {
|
|
1087
966
|
const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex + 1);
|
|
1088
|
-
if (!this.dispatch(
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
reason: "navigate-next"
|
|
1096
|
-
},
|
|
1097
|
-
!0
|
|
1098
|
-
)) 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;
|
|
1099
974
|
this.syncCurrentSectionSessionIntoAssessment();
|
|
1100
|
-
const
|
|
1101
|
-
return
|
|
975
|
+
const s = this.controller?.navigateNext() === !0;
|
|
976
|
+
return s && this.controller?.persist(), s;
|
|
1102
977
|
}
|
|
1103
978
|
navigatePrevious() {
|
|
1104
979
|
const e = this.selectNavigation(), t = this.controller?.getSectionAt(e.currentIndex - 1);
|
|
1105
|
-
if (!this.dispatch(
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
reason: "navigate-previous"
|
|
1113
|
-
},
|
|
1114
|
-
!0
|
|
1115
|
-
)) 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;
|
|
1116
987
|
this.syncCurrentSectionSessionIntoAssessment();
|
|
1117
|
-
const
|
|
1118
|
-
return
|
|
988
|
+
const s = this.controller?.navigatePrevious() === !0;
|
|
989
|
+
return s && this.controller?.persist(), s;
|
|
1119
990
|
}
|
|
1120
991
|
getAssessmentController() {
|
|
1121
992
|
return this.controller;
|
|
1122
993
|
}
|
|
1123
994
|
async waitForAssessmentController(e = 5e3) {
|
|
1124
995
|
if (this.controller) return this.controller;
|
|
1125
|
-
const t = this.controllerReadyPromise || Promise.resolve(null),
|
|
1126
|
-
setTimeout(() =>
|
|
996
|
+
const t = this.controllerReadyPromise || Promise.resolve(null), s = new Promise((n) => {
|
|
997
|
+
setTimeout(() => n(null), e);
|
|
1127
998
|
});
|
|
1128
|
-
return Promise.race([t,
|
|
999
|
+
return Promise.race([t, s]);
|
|
1129
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";
|
|
1130
1008
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
);
|
|
1135
|
-
function he(s, e = !1) {
|
|
1136
|
-
if (s == null) return e;
|
|
1137
|
-
if (typeof s == "boolean") return s;
|
|
1138
|
-
const t = s.trim().toLowerCase();
|
|
1139
|
-
return t === "" || t === "true" || t === "1" || t === "yes";
|
|
1140
|
-
}
|
|
1141
|
-
class me extends HTMLElement {
|
|
1142
|
-
constructor() {
|
|
1143
|
-
super(...arguments), this.showNavigation = !0;
|
|
1009
|
+
var Ne = class extends HTMLElement {
|
|
1010
|
+
constructor(...e) {
|
|
1011
|
+
super(...e), this.showNavigation = !0;
|
|
1144
1012
|
}
|
|
1145
1013
|
static get observedAttributes() {
|
|
1146
1014
|
return ["show-navigation"];
|
|
@@ -1148,11 +1016,11 @@ class me extends HTMLElement {
|
|
|
1148
1016
|
connectedCallback() {
|
|
1149
1017
|
this.showNavigation = this.getAttribute("show-navigation") ?? this.showNavigation, this.render();
|
|
1150
1018
|
}
|
|
1151
|
-
attributeChangedCallback(e, t,
|
|
1152
|
-
e === "show-navigation" && (this.showNavigation =
|
|
1019
|
+
attributeChangedCallback(e, t, s) {
|
|
1020
|
+
e === "show-navigation" && (this.showNavigation = s), this.render();
|
|
1153
1021
|
}
|
|
1154
1022
|
render() {
|
|
1155
|
-
const e =
|
|
1023
|
+
const e = we(this.showNavigation, !0);
|
|
1156
1024
|
this.innerHTML = "";
|
|
1157
1025
|
const t = document.createElement("style");
|
|
1158
1026
|
t.textContent = `
|
|
@@ -1173,18 +1041,18 @@ class me extends HTMLElement {
|
|
|
1173
1041
|
overflow: hidden;
|
|
1174
1042
|
}
|
|
1175
1043
|
`;
|
|
1176
|
-
const
|
|
1177
|
-
if (
|
|
1178
|
-
const
|
|
1179
|
-
|
|
1044
|
+
const s = document.createElement("div");
|
|
1045
|
+
if (s.className = "pie-assessment-player-shell", e) {
|
|
1046
|
+
const c = document.createElement("slot");
|
|
1047
|
+
c.name = "navigation", s.appendChild(c);
|
|
1180
1048
|
}
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
const
|
|
1184
|
-
|
|
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);
|
|
1185
1053
|
}
|
|
1186
|
-
}
|
|
1187
|
-
customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell",
|
|
1054
|
+
};
|
|
1055
|
+
customElements.get("pie-assessment-player-shell") || customElements.define("pie-assessment-player-shell", Ne);
|
|
1188
1056
|
export {
|
|
1189
|
-
|
|
1057
|
+
u as ASSESSMENT_PLAYER_PUBLIC_EVENTS
|
|
1190
1058
|
};
|