easyproctor-hml 2.5.18 → 2.5.19
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/esm/index.js +66 -36
- package/index.js +66 -36
- package/interfaces/ParamsConfig.d.ts +1 -1
- package/new-flow/proctoring/ProctoringSession.d.ts +3 -3
- package/new-flow/recorders/AlertRecorder.d.ts +1 -0
- package/new-flow/recorders/CameraRecorder.d.ts +1 -1
- package/package.json +1 -1
- package/proctoring/proctoring.d.ts +1 -0
- package/unpkg/easyproctor.min.js +4 -4
package/esm/index.js
CHANGED
|
@@ -12802,7 +12802,7 @@ var CameraRecorder = class {
|
|
|
12802
12802
|
}
|
|
12803
12803
|
}
|
|
12804
12804
|
async startRecording(options) {
|
|
12805
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h
|
|
12805
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h;
|
|
12806
12806
|
if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
|
|
12807
12807
|
await this.initializeDetectors();
|
|
12808
12808
|
}
|
|
@@ -12882,7 +12882,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12882
12882
|
this.filesToUpload = [];
|
|
12883
12883
|
if (this.options.proctoringType == "REALTIME") {
|
|
12884
12884
|
this.captureFrame();
|
|
12885
|
-
this.sendFrameInterval = setInterval(() => this.captureFrame(), 1e3 * ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.realtimeUploadInterval));
|
|
12886
12885
|
}
|
|
12887
12886
|
this.packageCount = 0;
|
|
12888
12887
|
}
|
|
@@ -12913,7 +12912,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12913
12912
|
clearInterval(this.imageInterval);
|
|
12914
12913
|
clearInterval(this.sendFrameInterval);
|
|
12915
12914
|
if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
|
|
12916
|
-
await this.sendPackage();
|
|
12915
|
+
await this.sendPackage(this.filesToUpload);
|
|
12916
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
12917
12917
|
}
|
|
12918
12918
|
this.volumeMeter && this.volumeMeter.stop();
|
|
12919
12919
|
this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
|
|
@@ -12983,23 +12983,29 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
12983
12983
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
12984
12984
|
return this.canvas.toDataURL("image/jpeg");
|
|
12985
12985
|
}
|
|
12986
|
-
//
|
|
12986
|
+
// captura um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
|
|
12987
12987
|
captureFrame() {
|
|
12988
|
-
var _a2;
|
|
12988
|
+
var _a2, _b;
|
|
12989
12989
|
let imageFile;
|
|
12990
12990
|
this.configImageCapture();
|
|
12991
|
+
let newCanvasWidth = this.videoOptions.width / 2;
|
|
12992
|
+
let newCanvasHeight = this.videoOptions.height / 2;
|
|
12993
|
+
if (newCanvasWidth < 320) newCanvasWidth = 320;
|
|
12994
|
+
if (newCanvasHeight < 180) newCanvasHeight = 180;
|
|
12995
|
+
this.canvas.width = newCanvasWidth;
|
|
12996
|
+
this.canvas.height = newCanvasHeight;
|
|
12991
12997
|
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
12992
|
-
|
|
12993
|
-
this.imageCount++;
|
|
12998
|
+
this.imageCount = 0;
|
|
12994
12999
|
this.imageInterval = setInterval(async () => {
|
|
13000
|
+
console.log("capturando frame " + this.imageCount);
|
|
12995
13001
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
12996
13002
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
12997
13003
|
if (this.proctoringId == void 0) return;
|
|
12998
|
-
if (
|
|
12999
|
-
initSend = true;
|
|
13004
|
+
if (packSize == this.imageCount) {
|
|
13000
13005
|
this.imageCount = 0;
|
|
13001
|
-
|
|
13002
|
-
this.sendPackage();
|
|
13006
|
+
const framesToSend = [...this.filesToUpload];
|
|
13007
|
+
this.sendPackage(framesToSend);
|
|
13008
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
13003
13009
|
}
|
|
13004
13010
|
let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
|
|
13005
13011
|
imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
|
|
@@ -13007,22 +13013,24 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
13007
13013
|
this.filesToUpload.push(imageFile);
|
|
13008
13014
|
this.imageCount++;
|
|
13009
13015
|
}
|
|
13010
|
-
}, 1e3);
|
|
13016
|
+
}, ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) * 1e3);
|
|
13011
13017
|
}
|
|
13012
13018
|
// envia pacote de imagens
|
|
13013
|
-
async sendPackage() {
|
|
13019
|
+
async sendPackage(framesToSend) {
|
|
13020
|
+
var _a2, _b;
|
|
13014
13021
|
let pending = false;
|
|
13015
13022
|
let undeliveredPackagesCount = 0;
|
|
13023
|
+
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
13024
|
+
const packCaptureInterval = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) + 1;
|
|
13016
13025
|
if (this.upload && this.backendToken && !pending && this.filesToUpload.length > 0) {
|
|
13017
13026
|
undeliveredPackagesCount = 0;
|
|
13018
13027
|
pending = true;
|
|
13019
13028
|
const zip = new import_jszip_min.default();
|
|
13020
|
-
const
|
|
13021
|
-
for (const file of files) {
|
|
13029
|
+
for (const file of framesToSend) {
|
|
13022
13030
|
zip.file(file.name, file);
|
|
13023
13031
|
}
|
|
13024
13032
|
const blob = await zip.generateAsync({ type: "blob" });
|
|
13025
|
-
let packageName = "realtime_package_" +
|
|
13033
|
+
let packageName = "realtime_package_" + packSize * packCaptureInterval * this.packageCount + ".zip";
|
|
13026
13034
|
const myPackage = new File(
|
|
13027
13035
|
[blob],
|
|
13028
13036
|
packageName,
|
|
@@ -13035,7 +13043,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
13035
13043
|
this.backendToken
|
|
13036
13044
|
);
|
|
13037
13045
|
if (uploadResult.uploaded == true) {
|
|
13038
|
-
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
13039
13046
|
this.packageCount++;
|
|
13040
13047
|
} else {
|
|
13041
13048
|
console.log("erro no upload do pacote");
|
|
@@ -15198,6 +15205,13 @@ var AlertRecorder = class {
|
|
|
15198
15205
|
// HANDLERS (Funções Arrow para preservar o 'this')
|
|
15199
15206
|
// ==========================================
|
|
15200
15207
|
// 1. LOST / RETURN FOCUS
|
|
15208
|
+
this.handleVisibilityChange = () => {
|
|
15209
|
+
if (document.visibilityState === "visible") {
|
|
15210
|
+
this.handleReturnFocus();
|
|
15211
|
+
} else {
|
|
15212
|
+
this.handleLostFocus();
|
|
15213
|
+
}
|
|
15214
|
+
};
|
|
15201
15215
|
this.handleLostFocus = () => {
|
|
15202
15216
|
if (this.getRelativeTime() > 1e4) {
|
|
15203
15217
|
const alertPayload = {
|
|
@@ -15230,7 +15244,7 @@ var AlertRecorder = class {
|
|
|
15230
15244
|
const windowWidth = window.outerWidth;
|
|
15231
15245
|
if (windowWidth < screenWidth * 0.85) {
|
|
15232
15246
|
const msg = `Split Screen Detectado: Janela ocupa ${(windowWidth / screenWidth * 100).toFixed(0)}% da tela`;
|
|
15233
|
-
this.createAlert(
|
|
15247
|
+
this.createAlert(43 /* SplitScreen */, 3 /* Screen */, msg);
|
|
15234
15248
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15235
15249
|
status: "ALERT",
|
|
15236
15250
|
description: msg,
|
|
@@ -15248,7 +15262,7 @@ var AlertRecorder = class {
|
|
|
15248
15262
|
this.handleCopy = (e3) => {
|
|
15249
15263
|
e3.preventDefault();
|
|
15250
15264
|
const msg = "Tentativa de Copiar (Clipboard)";
|
|
15251
|
-
this.createAlert(
|
|
15265
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15252
15266
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15253
15267
|
status: "ALERT",
|
|
15254
15268
|
description: msg,
|
|
@@ -15258,7 +15272,7 @@ var AlertRecorder = class {
|
|
|
15258
15272
|
this.handleCut = (e3) => {
|
|
15259
15273
|
e3.preventDefault();
|
|
15260
15274
|
const msg = "Tentativa de Recortar (Clipboard)";
|
|
15261
|
-
this.createAlert(
|
|
15275
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15262
15276
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15263
15277
|
status: "ALERT",
|
|
15264
15278
|
description: msg,
|
|
@@ -15268,7 +15282,7 @@ var AlertRecorder = class {
|
|
|
15268
15282
|
this.handlePaste = (e3) => {
|
|
15269
15283
|
e3.preventDefault();
|
|
15270
15284
|
const msg = "Tentativa de Colar (Clipboard)";
|
|
15271
|
-
this.createAlert(
|
|
15285
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
15272
15286
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15273
15287
|
status: "ALERT",
|
|
15274
15288
|
description: msg,
|
|
@@ -15304,8 +15318,7 @@ var AlertRecorder = class {
|
|
|
15304
15318
|
// ==========================================
|
|
15305
15319
|
attachListeners() {
|
|
15306
15320
|
if (this.optionsProctoring.captureScreen) {
|
|
15307
|
-
window.addEventListener("
|
|
15308
|
-
window.addEventListener("focus", this.handleReturnFocus);
|
|
15321
|
+
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
15309
15322
|
window.addEventListener("resize", this.handleResize);
|
|
15310
15323
|
window.document.addEventListener("copy", this.handleCopy);
|
|
15311
15324
|
window.document.addEventListener("cut", this.handleCut);
|
|
@@ -15313,8 +15326,7 @@ var AlertRecorder = class {
|
|
|
15313
15326
|
}
|
|
15314
15327
|
}
|
|
15315
15328
|
detachListeners() {
|
|
15316
|
-
window.removeEventListener("
|
|
15317
|
-
window.removeEventListener("focus", this.handleReturnFocus);
|
|
15329
|
+
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
15318
15330
|
window.removeEventListener("resize", this.handleResize);
|
|
15319
15331
|
window.document.removeEventListener("copy", this.handleCopy);
|
|
15320
15332
|
window.document.removeEventListener("cut", this.handleCut);
|
|
@@ -15349,7 +15361,7 @@ var AlertRecorder = class {
|
|
|
15349
15361
|
// }
|
|
15350
15362
|
// 4. BACKGROUND EVENTS (Eventos disparados manualmente)
|
|
15351
15363
|
addBackgroundEvent(description, category = 200 /* System */) {
|
|
15352
|
-
this.createAlert(category,
|
|
15364
|
+
this.createAlert(category, 3 /* Screen */, description);
|
|
15353
15365
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
15354
15366
|
status: "ALERT",
|
|
15355
15367
|
description,
|
|
@@ -21587,7 +21599,8 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
|
|
|
21587
21599
|
this.connection = new HubConnectionBuilder().withUrl(hubUrl, {
|
|
21588
21600
|
accessTokenFactory: () => this.context.token,
|
|
21589
21601
|
transport: HttpTransportType.WebSockets,
|
|
21590
|
-
withCredentials: false
|
|
21602
|
+
withCredentials: false,
|
|
21603
|
+
skipNegotiation: true
|
|
21591
21604
|
}).withAutomaticReconnect().configureLogging(LogLevel.Information).build();
|
|
21592
21605
|
this.connection.on(
|
|
21593
21606
|
"ReceiveMessage",
|
|
@@ -21804,8 +21817,8 @@ var Proctoring = class {
|
|
|
21804
21817
|
detectCellPhone: false,
|
|
21805
21818
|
detectNoise: false,
|
|
21806
21819
|
detectSpeech: false,
|
|
21807
|
-
realtimePackageSize:
|
|
21808
|
-
|
|
21820
|
+
realtimePackageSize: 10,
|
|
21821
|
+
realtimeCaptureInterval: 2
|
|
21809
21822
|
}
|
|
21810
21823
|
};
|
|
21811
21824
|
this.proctoringId = "";
|
|
@@ -21941,6 +21954,29 @@ var Proctoring = class {
|
|
|
21941
21954
|
return null;
|
|
21942
21955
|
}
|
|
21943
21956
|
}
|
|
21957
|
+
// metodo para fechar o alerta realtime e fica tentando verificar a face até 5 vezes
|
|
21958
|
+
async stopRealtimeAlert(alert) {
|
|
21959
|
+
const verifyMaxRetries = 3;
|
|
21960
|
+
const verifyFace = async (verifyCount) => {
|
|
21961
|
+
if (verifyCount > verifyMaxRetries) return;
|
|
21962
|
+
try {
|
|
21963
|
+
var response = await this.backend.stopRealtimeAlert({
|
|
21964
|
+
proctoringId: this.proctoringId,
|
|
21965
|
+
begin: alert.begin,
|
|
21966
|
+
end: alert.end,
|
|
21967
|
+
warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
|
|
21968
|
+
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
|
|
21969
|
+
retry: verifyCount < verifyMaxRetries - 1 ? true : false
|
|
21970
|
+
});
|
|
21971
|
+
console.log("response stopRealtimeAlert", response);
|
|
21972
|
+
return response;
|
|
21973
|
+
} catch (error) {
|
|
21974
|
+
console.log("error stopRealtimeAlert", error);
|
|
21975
|
+
return verifyFace(verifyCount + 1);
|
|
21976
|
+
}
|
|
21977
|
+
};
|
|
21978
|
+
await verifyFace(1);
|
|
21979
|
+
}
|
|
21944
21980
|
async onRealtimeAlerts(options = {}) {
|
|
21945
21981
|
this.setOnLostFocusAlertRecorderCallback();
|
|
21946
21982
|
this.setOnFocusAlertRecorderCallback();
|
|
@@ -21955,13 +21991,7 @@ var Proctoring = class {
|
|
|
21955
21991
|
alert: this.convertRealtimeCategoryToAlertCategory(response.category)
|
|
21956
21992
|
});
|
|
21957
21993
|
} else if (response.status === "OK") {
|
|
21958
|
-
await this.
|
|
21959
|
-
proctoringId: this.proctoringId,
|
|
21960
|
-
begin: response.begin,
|
|
21961
|
-
end: response.end,
|
|
21962
|
-
warningCategoryEnum: this.convertRealtimeTypeToWarningType(response.type),
|
|
21963
|
-
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64()
|
|
21964
|
-
});
|
|
21994
|
+
await this.stopRealtimeAlert(response);
|
|
21965
21995
|
}
|
|
21966
21996
|
}
|
|
21967
21997
|
};
|
package/index.js
CHANGED
|
@@ -30899,7 +30899,7 @@ var CameraRecorder = class {
|
|
|
30899
30899
|
}
|
|
30900
30900
|
}
|
|
30901
30901
|
async startRecording(options) {
|
|
30902
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h
|
|
30902
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h;
|
|
30903
30903
|
if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
|
|
30904
30904
|
await this.initializeDetectors();
|
|
30905
30905
|
}
|
|
@@ -30979,7 +30979,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
30979
30979
|
this.filesToUpload = [];
|
|
30980
30980
|
if (this.options.proctoringType == "REALTIME") {
|
|
30981
30981
|
this.captureFrame();
|
|
30982
|
-
this.sendFrameInterval = setInterval(() => this.captureFrame(), 1e3 * ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.realtimeUploadInterval));
|
|
30983
30982
|
}
|
|
30984
30983
|
this.packageCount = 0;
|
|
30985
30984
|
}
|
|
@@ -31010,7 +31009,8 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31010
31009
|
clearInterval(this.imageInterval);
|
|
31011
31010
|
clearInterval(this.sendFrameInterval);
|
|
31012
31011
|
if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
|
|
31013
|
-
await this.sendPackage();
|
|
31012
|
+
await this.sendPackage(this.filesToUpload);
|
|
31013
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31014
31014
|
}
|
|
31015
31015
|
this.volumeMeter && this.volumeMeter.stop();
|
|
31016
31016
|
this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
|
|
@@ -31080,23 +31080,29 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31080
31080
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
31081
31081
|
return this.canvas.toDataURL("image/jpeg");
|
|
31082
31082
|
}
|
|
31083
|
-
//
|
|
31083
|
+
// captura um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
|
|
31084
31084
|
captureFrame() {
|
|
31085
|
-
var _a2;
|
|
31085
|
+
var _a2, _b;
|
|
31086
31086
|
let imageFile;
|
|
31087
31087
|
this.configImageCapture();
|
|
31088
|
+
let newCanvasWidth = this.videoOptions.width / 2;
|
|
31089
|
+
let newCanvasHeight = this.videoOptions.height / 2;
|
|
31090
|
+
if (newCanvasWidth < 320) newCanvasWidth = 320;
|
|
31091
|
+
if (newCanvasHeight < 180) newCanvasHeight = 180;
|
|
31092
|
+
this.canvas.width = newCanvasWidth;
|
|
31093
|
+
this.canvas.height = newCanvasHeight;
|
|
31088
31094
|
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
31089
|
-
|
|
31090
|
-
this.imageCount++;
|
|
31095
|
+
this.imageCount = 0;
|
|
31091
31096
|
this.imageInterval = setInterval(async () => {
|
|
31097
|
+
console.log("capturando frame " + this.imageCount);
|
|
31092
31098
|
this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
|
31093
31099
|
const image_data_url = this.canvas.toDataURL("image/jpeg");
|
|
31094
31100
|
if (this.proctoringId == void 0) return;
|
|
31095
|
-
if (
|
|
31096
|
-
initSend = true;
|
|
31101
|
+
if (packSize == this.imageCount) {
|
|
31097
31102
|
this.imageCount = 0;
|
|
31098
|
-
|
|
31099
|
-
this.sendPackage();
|
|
31103
|
+
const framesToSend = [...this.filesToUpload];
|
|
31104
|
+
this.sendPackage(framesToSend);
|
|
31105
|
+
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31100
31106
|
}
|
|
31101
31107
|
let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
|
|
31102
31108
|
imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
|
|
@@ -31104,22 +31110,24 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31104
31110
|
this.filesToUpload.push(imageFile);
|
|
31105
31111
|
this.imageCount++;
|
|
31106
31112
|
}
|
|
31107
|
-
}, 1e3);
|
|
31113
|
+
}, ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) * 1e3);
|
|
31108
31114
|
}
|
|
31109
31115
|
// envia pacote de imagens
|
|
31110
|
-
async sendPackage() {
|
|
31116
|
+
async sendPackage(framesToSend) {
|
|
31117
|
+
var _a2, _b;
|
|
31111
31118
|
let pending = false;
|
|
31112
31119
|
let undeliveredPackagesCount = 0;
|
|
31120
|
+
const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
|
|
31121
|
+
const packCaptureInterval = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) + 1;
|
|
31113
31122
|
if (this.upload && this.backendToken && !pending && this.filesToUpload.length > 0) {
|
|
31114
31123
|
undeliveredPackagesCount = 0;
|
|
31115
31124
|
pending = true;
|
|
31116
31125
|
const zip = new import_jszip_min.default();
|
|
31117
|
-
const
|
|
31118
|
-
for (const file of files) {
|
|
31126
|
+
for (const file of framesToSend) {
|
|
31119
31127
|
zip.file(file.name, file);
|
|
31120
31128
|
}
|
|
31121
31129
|
const blob = await zip.generateAsync({ type: "blob" });
|
|
31122
|
-
let packageName = "realtime_package_" +
|
|
31130
|
+
let packageName = "realtime_package_" + packSize * packCaptureInterval * this.packageCount + ".zip";
|
|
31123
31131
|
const myPackage = new File(
|
|
31124
31132
|
[blob],
|
|
31125
31133
|
packageName,
|
|
@@ -31132,7 +31140,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
31132
31140
|
this.backendToken
|
|
31133
31141
|
);
|
|
31134
31142
|
if (uploadResult.uploaded == true) {
|
|
31135
|
-
await this.filesToUpload.splice(0, this.filesToUpload.length);
|
|
31136
31143
|
this.packageCount++;
|
|
31137
31144
|
} else {
|
|
31138
31145
|
console.log("erro no upload do pacote");
|
|
@@ -33295,6 +33302,13 @@ var AlertRecorder = class {
|
|
|
33295
33302
|
// HANDLERS (Funções Arrow para preservar o 'this')
|
|
33296
33303
|
// ==========================================
|
|
33297
33304
|
// 1. LOST / RETURN FOCUS
|
|
33305
|
+
this.handleVisibilityChange = () => {
|
|
33306
|
+
if (document.visibilityState === "visible") {
|
|
33307
|
+
this.handleReturnFocus();
|
|
33308
|
+
} else {
|
|
33309
|
+
this.handleLostFocus();
|
|
33310
|
+
}
|
|
33311
|
+
};
|
|
33298
33312
|
this.handleLostFocus = () => {
|
|
33299
33313
|
if (this.getRelativeTime() > 1e4) {
|
|
33300
33314
|
const alertPayload = {
|
|
@@ -33327,7 +33341,7 @@ var AlertRecorder = class {
|
|
|
33327
33341
|
const windowWidth = window.outerWidth;
|
|
33328
33342
|
if (windowWidth < screenWidth * 0.85) {
|
|
33329
33343
|
const msg = `Split Screen Detectado: Janela ocupa ${(windowWidth / screenWidth * 100).toFixed(0)}% da tela`;
|
|
33330
|
-
this.createAlert(
|
|
33344
|
+
this.createAlert(43 /* SplitScreen */, 3 /* Screen */, msg);
|
|
33331
33345
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33332
33346
|
status: "ALERT",
|
|
33333
33347
|
description: msg,
|
|
@@ -33345,7 +33359,7 @@ var AlertRecorder = class {
|
|
|
33345
33359
|
this.handleCopy = (e3) => {
|
|
33346
33360
|
e3.preventDefault();
|
|
33347
33361
|
const msg = "Tentativa de Copiar (Clipboard)";
|
|
33348
|
-
this.createAlert(
|
|
33362
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33349
33363
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33350
33364
|
status: "ALERT",
|
|
33351
33365
|
description: msg,
|
|
@@ -33355,7 +33369,7 @@ var AlertRecorder = class {
|
|
|
33355
33369
|
this.handleCut = (e3) => {
|
|
33356
33370
|
e3.preventDefault();
|
|
33357
33371
|
const msg = "Tentativa de Recortar (Clipboard)";
|
|
33358
|
-
this.createAlert(
|
|
33372
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33359
33373
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33360
33374
|
status: "ALERT",
|
|
33361
33375
|
description: msg,
|
|
@@ -33365,7 +33379,7 @@ var AlertRecorder = class {
|
|
|
33365
33379
|
this.handlePaste = (e3) => {
|
|
33366
33380
|
e3.preventDefault();
|
|
33367
33381
|
const msg = "Tentativa de Colar (Clipboard)";
|
|
33368
|
-
this.createAlert(
|
|
33382
|
+
this.createAlert(42 /* ClipBoardUse */, 3 /* Screen */, msg);
|
|
33369
33383
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33370
33384
|
status: "ALERT",
|
|
33371
33385
|
description: msg,
|
|
@@ -33401,8 +33415,7 @@ var AlertRecorder = class {
|
|
|
33401
33415
|
// ==========================================
|
|
33402
33416
|
attachListeners() {
|
|
33403
33417
|
if (this.optionsProctoring.captureScreen) {
|
|
33404
|
-
window.addEventListener("
|
|
33405
|
-
window.addEventListener("focus", this.handleReturnFocus);
|
|
33418
|
+
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
33406
33419
|
window.addEventListener("resize", this.handleResize);
|
|
33407
33420
|
window.document.addEventListener("copy", this.handleCopy);
|
|
33408
33421
|
window.document.addEventListener("cut", this.handleCut);
|
|
@@ -33410,8 +33423,7 @@ var AlertRecorder = class {
|
|
|
33410
33423
|
}
|
|
33411
33424
|
}
|
|
33412
33425
|
detachListeners() {
|
|
33413
|
-
window.removeEventListener("
|
|
33414
|
-
window.removeEventListener("focus", this.handleReturnFocus);
|
|
33426
|
+
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
33415
33427
|
window.removeEventListener("resize", this.handleResize);
|
|
33416
33428
|
window.document.removeEventListener("copy", this.handleCopy);
|
|
33417
33429
|
window.document.removeEventListener("cut", this.handleCut);
|
|
@@ -33446,7 +33458,7 @@ var AlertRecorder = class {
|
|
|
33446
33458
|
// }
|
|
33447
33459
|
// 4. BACKGROUND EVENTS (Eventos disparados manualmente)
|
|
33448
33460
|
addBackgroundEvent(description, category = 200 /* System */) {
|
|
33449
|
-
this.createAlert(category,
|
|
33461
|
+
this.createAlert(category, 3 /* Screen */, description);
|
|
33450
33462
|
this.onRealtimeAlertCallback && this.onRealtimeAlertCallback({
|
|
33451
33463
|
status: "ALERT",
|
|
33452
33464
|
description,
|
|
@@ -36836,7 +36848,8 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
|
|
|
36836
36848
|
this.connection = new import_signalr.HubConnectionBuilder().withUrl(hubUrl, {
|
|
36837
36849
|
accessTokenFactory: () => this.context.token,
|
|
36838
36850
|
transport: import_signalr.HttpTransportType.WebSockets,
|
|
36839
|
-
withCredentials: false
|
|
36851
|
+
withCredentials: false,
|
|
36852
|
+
skipNegotiation: true
|
|
36840
36853
|
}).withAutomaticReconnect().configureLogging(import_signalr.LogLevel.Information).build();
|
|
36841
36854
|
this.connection.on(
|
|
36842
36855
|
"ReceiveMessage",
|
|
@@ -37053,8 +37066,8 @@ var Proctoring = class {
|
|
|
37053
37066
|
detectCellPhone: false,
|
|
37054
37067
|
detectNoise: false,
|
|
37055
37068
|
detectSpeech: false,
|
|
37056
|
-
realtimePackageSize:
|
|
37057
|
-
|
|
37069
|
+
realtimePackageSize: 10,
|
|
37070
|
+
realtimeCaptureInterval: 2
|
|
37058
37071
|
}
|
|
37059
37072
|
};
|
|
37060
37073
|
this.proctoringId = "";
|
|
@@ -37190,6 +37203,29 @@ var Proctoring = class {
|
|
|
37190
37203
|
return null;
|
|
37191
37204
|
}
|
|
37192
37205
|
}
|
|
37206
|
+
// metodo para fechar o alerta realtime e fica tentando verificar a face até 5 vezes
|
|
37207
|
+
async stopRealtimeAlert(alert) {
|
|
37208
|
+
const verifyMaxRetries = 3;
|
|
37209
|
+
const verifyFace = async (verifyCount) => {
|
|
37210
|
+
if (verifyCount > verifyMaxRetries) return;
|
|
37211
|
+
try {
|
|
37212
|
+
var response = await this.backend.stopRealtimeAlert({
|
|
37213
|
+
proctoringId: this.proctoringId,
|
|
37214
|
+
begin: alert.begin,
|
|
37215
|
+
end: alert.end,
|
|
37216
|
+
warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
|
|
37217
|
+
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
|
|
37218
|
+
retry: verifyCount < verifyMaxRetries - 1 ? true : false
|
|
37219
|
+
});
|
|
37220
|
+
console.log("response stopRealtimeAlert", response);
|
|
37221
|
+
return response;
|
|
37222
|
+
} catch (error) {
|
|
37223
|
+
console.log("error stopRealtimeAlert", error);
|
|
37224
|
+
return verifyFace(verifyCount + 1);
|
|
37225
|
+
}
|
|
37226
|
+
};
|
|
37227
|
+
await verifyFace(1);
|
|
37228
|
+
}
|
|
37193
37229
|
async onRealtimeAlerts(options = {}) {
|
|
37194
37230
|
this.setOnLostFocusAlertRecorderCallback();
|
|
37195
37231
|
this.setOnFocusAlertRecorderCallback();
|
|
@@ -37204,13 +37240,7 @@ var Proctoring = class {
|
|
|
37204
37240
|
alert: this.convertRealtimeCategoryToAlertCategory(response.category)
|
|
37205
37241
|
});
|
|
37206
37242
|
} else if (response.status === "OK") {
|
|
37207
|
-
await this.
|
|
37208
|
-
proctoringId: this.proctoringId,
|
|
37209
|
-
begin: response.begin,
|
|
37210
|
-
end: response.end,
|
|
37211
|
-
warningCategoryEnum: this.convertRealtimeTypeToWarningType(response.type),
|
|
37212
|
-
alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64()
|
|
37213
|
-
});
|
|
37243
|
+
await this.stopRealtimeAlert(response);
|
|
37214
37244
|
}
|
|
37215
37245
|
}
|
|
37216
37246
|
};
|
|
@@ -25,7 +25,7 @@ export type VideoBehaviourParameters = {
|
|
|
25
25
|
retryEnabled?: boolean;
|
|
26
26
|
maxRetries?: number;
|
|
27
27
|
realtimePackageSize?: number;
|
|
28
|
-
|
|
28
|
+
realtimeCaptureInterval?: number;
|
|
29
29
|
};
|
|
30
30
|
export default interface IParamsConfig {
|
|
31
31
|
audioBehaviourParameters?: AudioBehaviourParameters;
|
|
@@ -25,7 +25,8 @@ export declare enum AlertCategory {
|
|
|
25
25
|
SpyDeviceDisconnected = 33,
|
|
26
26
|
StopSharingScreen = 34,
|
|
27
27
|
ChangeDevices = 39,
|
|
28
|
-
|
|
28
|
+
ClipBoardUse = 42,
|
|
29
|
+
SplitScreen = 43,
|
|
29
30
|
System = 200
|
|
30
31
|
}
|
|
31
32
|
export declare enum FinishRealtimeWarningCategory {
|
|
@@ -38,8 +39,7 @@ export declare enum AlertType {
|
|
|
38
39
|
Video = 2,
|
|
39
40
|
Screen = 3,
|
|
40
41
|
Image = 4,
|
|
41
|
-
Environment = 5
|
|
42
|
-
System = 6
|
|
42
|
+
Environment = 5
|
|
43
43
|
}
|
|
44
44
|
export interface Alert {
|
|
45
45
|
begin: number;
|
|
@@ -24,6 +24,7 @@ export declare class AlertRecorder implements IRecorder {
|
|
|
24
24
|
saveOnSession(session: ProctoringSession): Promise<void>;
|
|
25
25
|
private attachListeners;
|
|
26
26
|
private detachListeners;
|
|
27
|
+
private handleVisibilityChange;
|
|
27
28
|
private handleLostFocus;
|
|
28
29
|
private handleReturnFocus;
|
|
29
30
|
private handleResize;
|
|
@@ -66,7 +66,7 @@ export declare class CameraRecorder implements IRecorder {
|
|
|
66
66
|
getCurrentImageBase64(): Promise<string>;
|
|
67
67
|
packageCount: number;
|
|
68
68
|
captureFrame(): void;
|
|
69
|
-
sendPackage(): Promise<void>;
|
|
69
|
+
sendPackage(framesToSend: File[]): Promise<void>;
|
|
70
70
|
download(file: File): void;
|
|
71
71
|
saveOnSession(session: ProctoringSession): Promise<void>;
|
|
72
72
|
getFile(file: string, name: string, type: string): Promise<File>;
|
package/package.json
CHANGED
|
@@ -72,6 +72,7 @@ export declare class Proctoring {
|
|
|
72
72
|
onChangeDevices(options?: ProctoringChangeDevicesOptions): Promise<void>;
|
|
73
73
|
private convertRealtimeCategoryToAlertCategory;
|
|
74
74
|
private convertRealtimeTypeToWarningType;
|
|
75
|
+
private stopRealtimeAlert;
|
|
75
76
|
private onRealtimeAlertsCallback;
|
|
76
77
|
onRealtimeAlerts(options?: ProctoringRealtimeAlertsOptions): Promise<void>;
|
|
77
78
|
private onBufferSizeErrorCallback;
|
package/unpkg/easyproctor.min.js
CHANGED
|
@@ -68,7 +68,7 @@ Minimum version required to store current data is: `+o+`.
|
|
|
68
68
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[Cg]=this[Cg]={accessors:{}}).accessors,i=this.prototype;function o(s){let a=Lo(s);n[a]||(Qv(i,s),n[a]=!0)}return T.isArray(t)?t.forEach(o):o(t),this}};Ni.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);T.reduceDescriptors(Ni.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});T.freezeMethods(Ni);var at=Ni;function Fo(e,t){let r=this||Ui,n=t||r,i=at.from(n.headers),o=n.data;return T.forEach(e,function(a){o=a.call(r,o,i.normalize(),t?t.status:void 0)}),i.normalize(),o}function Mo(e){return!!(e&&e.__CANCEL__)}function xg(e,t,r){le.call(this,e??"canceled",le.ERR_CANCELED,t,r),this.name="CanceledError"}T.inherits(xg,le,{__CANCEL__:!0});var Br=xg;function Uo(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new le("Request failed with status code "+r.status,[le.ERR_BAD_REQUEST,le.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function ad(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function e_(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,o=0,s;return t=t!==void 0?t:1e3,function(c){let l=Date.now(),h=n[o];s||(s=l),r[i]=c,n[i]=l;let d=o,m=0;for(;d!==i;)m+=r[d++],d=d%e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),l-s<t)return;let p=h&&l-h;return p?Math.round(m*1e3/p):void 0}}var Ag=e_;function t_(e,t){let r=0,n=1e3/t,i,o,s=(l,h=Date.now())=>{r=h,i=null,o&&(clearTimeout(o),o=null),e.apply(null,l)};return[(...l)=>{let h=Date.now(),d=h-r;d>=n?s(l,h):(i=l,o||(o=setTimeout(()=>{o=null,s(i)},n-d)))},()=>i&&s(i)]}var Tg=t_;var zi=(e,t,r=3)=>{let n=0,i=Ag(50,250);return Tg(o=>{let s=o.loaded,a=o.lengthComputable?o.total:void 0,c=s-n,l=i(c),h=s<=a;n=s;let d={loaded:s,total:a,progress:a?s/a:void 0,bytes:c,rate:l||void 0,estimated:l&&a&&h?(a-s)/l:void 0,event:o,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(d)},r)},cd=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ld=e=>(...t)=>T.asap(()=>e(...t));var Ig=je.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,je.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(je.origin),je.navigator&&/(msie|trident)/i.test(je.navigator.userAgent)):()=>!0;var Rg=je.hasStandardBrowserEnv?{write(e,t,r,n,i,o){let s=[e+"="+encodeURIComponent(t)];T.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),T.isString(n)&&s.push("path="+n),T.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function hd(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function dd(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function No(e,t,r){let n=!hd(t);return e&&(n||r==!1)?dd(e,t):t}var Pg=e=>e instanceof at?{...e}:e;function br(e,t){t=t||{};let r={};function n(l,h,d,m){return T.isPlainObject(l)&&T.isPlainObject(h)?T.merge.call({caseless:m},l,h):T.isPlainObject(h)?T.merge({},h):T.isArray(h)?h.slice():h}function i(l,h,d,m){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l,d,m)}else return n(l,h,d,m)}function o(l,h){if(!T.isUndefined(h))return n(void 0,h)}function s(l,h){if(T.isUndefined(h)){if(!T.isUndefined(l))return n(void 0,l)}else return n(void 0,h)}function a(l,h,d){if(d in t)return n(l,h);if(d in e)return n(void 0,l)}let c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(l,h,d)=>i(Pg(l),Pg(h),d,!0)};return T.forEach(Object.keys(Object.assign({},e,t)),function(h){let d=c[h]||i,m=d(e[h],t[h],h);T.isUndefined(m)&&d!==a||(r[h]=m)}),r}var Ca=e=>{let t=br({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=t;t.headers=s=at.from(s),t.url=Bo(No(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let c;if(T.isFormData(r)){if(je.hasStandardBrowserEnv||je.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){let[l,...h]=c?c.split(";").map(d=>d.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...h].join("; "))}}if(je.hasStandardBrowserEnv&&(n&&T.isFunction(n)&&(n=n(t)),n||n!==!1&&Ig(t.url))){let l=i&&o&&Rg.read(o);l&&s.set(i,l)}return t};var r_=typeof XMLHttpRequest<"u",Dg=r_&&function(e){return new Promise(function(r,n){let i=Ca(e),o=i.data,s=at.from(i.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:l}=i,h,d,m,p,g;function f(){p&&p(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let b=new XMLHttpRequest;b.open(i.method.toUpperCase(),i.url,!0),b.timeout=i.timeout;function v(){if(!b)return;let S=at.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),x={data:!a||a==="text"||a==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:S,config:e,request:b};Uo(function(P){r(P),f()},function(P){n(P),f()},x),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(n(new le("Request aborted",le.ECONNABORTED,e,b)),b=null)},b.onerror=function(){n(new le("Network Error",le.ERR_NETWORK,e,b)),b=null},b.ontimeout=function(){let I=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",x=i.transitional||Sa;i.timeoutErrorMessage&&(I=i.timeoutErrorMessage),n(new le(I,x.clarifyTimeoutError?le.ETIMEDOUT:le.ECONNABORTED,e,b)),b=null},o===void 0&&s.setContentType(null),"setRequestHeader"in b&&T.forEach(s.toJSON(),function(I,x){b.setRequestHeader(x,I)}),T.isUndefined(i.withCredentials)||(b.withCredentials=!!i.withCredentials),a&&a!=="json"&&(b.responseType=i.responseType),l&&([m,g]=zi(l,!0),b.addEventListener("progress",m)),c&&b.upload&&([d,p]=zi(c),b.upload.addEventListener("progress",d),b.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=S=>{b&&(n(!S||S.type?new Br(null,e,b):S),b.abort(),b=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));let k=ad(i.url);if(k&&je.protocols.indexOf(k)===-1){n(new le("Unsupported protocol "+k+":",le.ERR_BAD_REQUEST,e));return}b.send(o||null)})};var n_=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,o=function(l){if(!i){i=!0,a();let h=l instanceof Error?l:this.reason;n.abort(h instanceof le?h:new Br(h instanceof Error?h.message:h))}},s=t&&setTimeout(()=>{s=null,o(new le(`timeout ${t} of ms exceeded`,le.ETIMEDOUT))},t),a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));let{signal:c}=n;return c.unsubscribe=()=>T.asap(a),c}},Og=n_;var i_=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},o_=async function*(e,t){for await(let r of s_(e))yield*i_(r,t)},s_=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},ud=(e,t,r,n)=>{let i=o_(e,t),o=0,s,a=c=>{s||(s=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:l,value:h}=await i.next();if(l){a(),c.close();return}let d=h.byteLength;if(r){let m=o+=d;r(m)}c.enqueue(new Uint8Array(h))}catch(l){throw a(l),l}},cancel(c){return a(c),i.return()}},{highWaterMark:2})};var Aa=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Lg=Aa&&typeof ReadableStream=="function",a_=Aa&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Fg=(e,...t)=>{try{return!!e(...t)}catch{return!1}},c_=Lg&&Fg(()=>{let e=!1,t=new Request(je.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Bg=64*1024,fd=Lg&&Fg(()=>T.isReadableStream(new Response("").body)),xa={stream:fd&&(e=>e.body)};Aa&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!xa[t]&&(xa[t]=T.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new le(`Response type '${t}' is not supported`,le.ERR_NOT_SUPPORT,n)})})})(new Response);var l_=async e=>{if(e==null)return 0;if(T.isBlob(e))return e.size;if(T.isSpecCompliantForm(e))return(await new Request(je.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(T.isArrayBufferView(e)||T.isArrayBuffer(e))return e.byteLength;if(T.isURLSearchParams(e)&&(e=e+""),T.isString(e))return(await a_(e)).byteLength},h_=async(e,t)=>{let r=T.toFiniteNumber(e.getContentLength());return r??l_(t)},Mg=Aa&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:o,timeout:s,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:h,withCredentials:d="same-origin",fetchOptions:m}=Ca(e);l=l?(l+"").toLowerCase():"text";let p=Og([i,o&&o.toAbortSignal()],s),g,f=p&&p.unsubscribe&&(()=>{p.unsubscribe()}),b;try{if(c&&c_&&r!=="get"&&r!=="head"&&(b=await h_(h,n))!==0){let x=new Request(t,{method:"POST",body:n,duplex:"half"}),O;if(T.isFormData(n)&&(O=x.headers.get("content-type"))&&h.setContentType(O),x.body){let[P,z]=cd(b,zi(ld(c)));n=ud(x.body,Bg,P,z)}}T.isString(d)||(d=d?"include":"omit");let v="credentials"in Request.prototype;g=new Request(t,{...m,signal:p,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:v?d:void 0});let k=await fetch(g),S=fd&&(l==="stream"||l==="response");if(fd&&(a||S&&f)){let x={};["status","statusText","headers"].forEach(Z=>{x[Z]=k[Z]});let O=T.toFiniteNumber(k.headers.get("content-length")),[P,z]=a&&cd(O,zi(ld(a),!0))||[];k=new Response(ud(k.body,Bg,P,()=>{z&&z(),f&&f()}),x)}l=l||"text";let I=await xa[T.findKey(xa,l)||"text"](k,e);return!S&&f&&f(),await new Promise((x,O)=>{Uo(x,O,{data:I,headers:at.from(k.headers),status:k.status,statusText:k.statusText,config:e,request:g})})}catch(v){throw f&&f(),v&&v.name==="TypeError"&&/fetch/i.test(v.message)?Object.assign(new le("Network Error",le.ERR_NETWORK,e,g),{cause:v.cause||v}):le.from(v,v&&v.code,e,g)}});var pd={http:_a,xhr:Dg,fetch:Mg};T.forEach(pd,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Ug=e=>`- ${e}`,d_=e=>T.isFunction(e)||e===null||e===!1,Ta={getAdapter:e=>{e=T.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let o=0;o<t;o++){r=e[o];let s;if(n=r,!d_(r)&&(n=pd[(s=String(r)).toLowerCase()],n===void 0))throw new le(`Unknown adapter '${s}'`);if(n)break;i[s||"#"+o]=n}if(!n){let o=Object.entries(i).map(([a,c])=>`adapter ${a} `+(c===!1?"is not supported by the environment":"is not available in the build")),s=t?o.length>1?`since :
|
|
69
69
|
`+o.map(Ug).join(`
|
|
70
70
|
`):" "+Ug(o[0]):"as no adapter specified";throw new le("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return n},adapters:pd};function md(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Br(null,e)}function Ia(e){return md(e),e.headers=at.from(e.headers),e.data=Fo.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ta.getAdapter(e.adapter||Ui.adapter)(e).then(function(n){return md(e),n.data=Fo.call(e,e.transformResponse,n),n.headers=at.from(n.headers),n},function(n){return Mo(n)||(md(e),n&&n.response&&(n.response.data=Fo.call(e,e.transformResponse,n.response),n.response.headers=at.from(n.response.headers))),Promise.reject(n)})}var Ra="1.8.4";var Pa={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Pa[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var Ng={};Pa.transitional=function(t,r,n){function i(o,s){return"[Axios v"+Ra+"] Transitional option '"+o+"'"+s+(n?". "+n:"")}return(o,s,a)=>{if(t===!1)throw new le(i(s," has been removed"+(r?" in "+r:"")),le.ERR_DEPRECATED);return r&&!Ng[s]&&(Ng[s]=!0,console.warn(i(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(o,s,a):!0}};Pa.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function u_(e,t,r){if(typeof e!="object")throw new le("options must be an object",le.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),i=n.length;for(;i-- >0;){let o=n[i],s=t[o];if(s){let a=e[o],c=a===void 0||s(a,o,e);if(c!==!0)throw new le("option "+o+" must be "+c,le.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new le("Unknown option "+o,le.ERR_BAD_OPTION)}}var zo={assertOptions:u_,validators:Pa};var Lr=zo.validators,ji=class{constructor(t){this.defaults=t,this.interceptors={request:new ed,response:new ed}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;let o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
71
|
-
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},zg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var jg=vd;function Vg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Vg(br(e,i))},r}var rt=Vg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=zg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=pn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=jg;rt.default=rt;var vr=rt;var{Axios:k5,AxiosError:E5,CanceledError:C5,isCancel:x5,CancelToken:A5,VERSION:T5,all:I5,Cancel:R5,isAxiosError:P5,spread:D5,toFormData:O5,AxiosHeaders:B5,HttpStatusCode:L5,formToJSON:F5,getAdapter:M5,mergeConfig:U5}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",Hg="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:Hg}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight}:{width:640,height:480}}var Wg={width:1280,height:720,minWidth:640,minHeight:480};function $g(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function mn(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Gg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),fe={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r=!1,n,i=!1){let o,s=!1,a,c,l;l=0;let h={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?h.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),i&&(h={mimeType:"audio/webm",audioBitsPerSecond:64*1e3});let d=new MediaRecorder(e,h);d.ondataavailable=v=>{l=l+v.data.size,v.data.size>0&&t.push(v.data),s?(i&&d.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),o&&o()):((c&&v.data.size===c.data.size||v.data.size===0)&&(Vo&&c&&v.data.size===c.data.size&&fe.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${v.data.size} Mb`),Vo&&v.data.size===0&&fe.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),n&&n()),c=v)};function m(){return new Promise(v=>{o=v,d.start(),l=0,s=!1,r&&(a=setInterval(async()=>{await d.requestData()},3e4))})}function p(){return new Promise(v=>{d.state=="recording"?(o=v,d.stop(),s=!0,clearInterval(a),e.getTracks().forEach(k=>{k.stop()})):v()})}function g(){return new Promise(v=>{d.state=="recording"&&d.pause(),v()})}function f(){return new Promise(v=>{d.state=="paused"&&d.resume(),v()})}function b(){return l}return{startRecording:m,stopRecording:p,pauseRecording:g,resumeRecording:f,recorderOptions:h,getBufferSize:b}}var Jr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw fe.registerError(this.proctoringId,`Failed to upload to AWS
|
|
71
|
+
`+o):n.stack=o}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=br(this.defaults,r);let{transitional:n,paramsSerializer:i,headers:o}=r;n!==void 0&&zo.assertOptions(n,{silentJSONParsing:Lr.transitional(Lr.boolean),forcedJSONParsing:Lr.transitional(Lr.boolean),clarifyTimeoutError:Lr.transitional(Lr.boolean)},!1),i!=null&&(T.isFunction(i)?r.paramsSerializer={serialize:i}:zo.assertOptions(i,{encode:Lr.function,serialize:Lr.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),zo.assertOptions(r,{baseUrl:Lr.spelling("baseURL"),withXsrfToken:Lr.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s=o&&T.merge(o.common,o[r.method]);o&&T.forEach(["delete","get","head","post","put","patch","common"],g=>{delete o[g]}),r.headers=at.concat(s,o);let a=[],c=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(r)===!1||(c=c&&f.synchronous,a.unshift(f.fulfilled,f.rejected))});let l=[];this.interceptors.response.forEach(function(f){l.push(f.fulfilled,f.rejected)});let h,d=0,m;if(!c){let g=[Ia.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,l),m=g.length,h=Promise.resolve(r);d<m;)h=h.then(g[d++],g[d++]);return h}m=a.length;let p=r;for(d=0;d<m;){let g=a[d++],f=a[d++];try{p=g(p)}catch(b){f.call(this,b);break}}try{h=Ia.call(this,p)}catch(g){return Promise.reject(g)}for(d=0,m=l.length;d<m;)h=h.then(l[d++],l[d++]);return h}getUri(t){t=br(this.defaults,t);let r=No(t.baseURL,t.url,t.allowAbsoluteUrls);return Bo(r,t.params,t.paramsSerializer)}};T.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(r,n){return this.request(br(n||{},{method:t,url:r,data:(n||{}).data}))}});T.forEach(["post","put","patch"],function(t){function r(n){return function(o,s,a){return this.request(br(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}ji.prototype[t]=r(),ji.prototype[t+"Form"]=r(!0)});var jo=ji;var gd=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(o){r=o});let n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o,s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},t(function(o,s,a){n.reason||(n.reason=new Br(o,s,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new e(function(i){t=i}),cancel:t}}},zg=gd;function yd(e){return function(r){return e.apply(null,r)}}function bd(e){return T.isObject(e)&&e.isAxiosError===!0}var vd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(vd).forEach(([e,t])=>{vd[t]=e});var jg=vd;function Vg(e){let t=new jo(e),r=Po(jo.prototype.request,t);return T.extend(r,jo.prototype,t,{allOwnKeys:!0}),T.extend(r,t,null,{allOwnKeys:!0}),r.create=function(i){return Vg(br(e,i))},r}var rt=Vg(Ui);rt.Axios=jo;rt.CanceledError=Br;rt.CancelToken=zg;rt.isCancel=Mo;rt.VERSION=Ra;rt.toFormData=pn;rt.AxiosError=le;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=yd;rt.isAxiosError=bd;rt.mergeConfig=br;rt.AxiosHeaders=at;rt.formToJSON=e=>ka(T.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=Ta.getAdapter;rt.HttpStatusCode=jg;rt.default=rt;var vr=rt;var{Axios:kC,AxiosError:EC,CanceledError:CC,isCancel:xC,CancelToken:AC,VERSION:TC,all:IC,Cancel:RC,isAxiosError:PC,spread:DC,toFormData:OC,AxiosHeaders:BC,HttpStatusCode:LC,formToJSON:FC,getAdapter:MC,mergeConfig:UC}=vr;var f_="https://proctoring-api-dev.easyproctor.tech/api",p_="https://proctoring-api-hml.easyproctor.tech/api",Hg="https://proctoring-api.easyproctor.tech/api",nr=class{constructor(t){this.options=t;this.baseUrl=this.selectBaseUrl(t.type),this.token=t.token}selectBaseUrl(t){return t==="dev"?f_:t==="homol"?p_:Hg}getSocketUrl(){return this.baseUrl.replace("/api","/hub/sockethub")}async loginAuth(t,r){return await this.makeRequest({path:"/Auth",method:"POST",body:{emailOrCpf:t,key:r}})}async externalCameraRegister(t){return await this.makeRequest({path:"/ExternalCamera/register",method:"POST",body:t,jwt:this.token})}async externalCameraCheckTransmission(t){return await this.makeRequest({path:`/ExternalCamera/send-action/${t}`,method:"POST",body:{command:"Check_Transmission"},jwt:this.token})}async externalCameraStartTransmission(t,r){return await this.makeRequest({path:`/ExternalCamera/start-transmission/${t}`,method:"POST",body:{proctoringId:r},jwt:this.token})}async externalCameraStartSession(){return await this.makeRequest({path:"/ExternalCamera/start-session",method:"POST",body:{},jwt:this.token})}async goToExternalCameraPositionStep(t){return await this.makeRequest({path:`/ExternalCamera/go-to-position-step/${t}`,method:"POST",body:{},jwt:this.token})}async externalCameraFinish(t){return await this.makeRequest({path:`/ExternalCamera/finish/${t}`,method:"POST",body:{},jwt:this.token})}async confirmStart(t,r,n,i){return await this.makeRequest({path:`/proctoring/start/${t.examId}`,method:"POST",body:{clientId:t.clientId,proctoringType:r.proctoringType,latitude:n,longitude:i,captureScreen:r.captureScreen},jwt:t.token})}async getParamsConfig(t){return(await this.makeRequestAxios({path:"/Client/params",method:"GET",jwt:t.token}).catch(n=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async getSignedUrlImage(t,r){return(await this.makeRequestAxios({path:"/upload/signed-url-batch",method:"POST",jwt:t,body:r})).data}async getSignedUrl(t,r,n){return(await this.makeRequestAxios({path:"/upload/signed-url",method:"POST",jwt:t,body:{objectName:`${n}/${r.name}`,contentType:r.type}})).data}async saveAlerts(t,r){await this.makeRequest({path:"/proctoring/save-alerts",method:"POST",jwt:t.token,body:{proctoringId:r.id,alerts:r.alerts}})}async finishAndSendUrls(t){return await this.makeRequest({path:`/proctoring/finish/${t.examId}`,method:"POST",body:{endDate:new Date().toISOString(),videoCameraUrl:"",audioCameraUrl:"",videoScreenUrl:""},jwt:t.token})}async log(t,r){let n;return r?.success!==null&&r?.success!==void 0?n=r.success?"4":"1":n="4",await this.makeRequest({path:"/Log",method:"POST",body:{entryType:n,eventName:t,message:r},jwt:this.token})}async signTerm(){return await this.makeRequest({path:"/User/sign-terms",method:"PATCH",body:{},jwt:this.token})}async signTermUrl(){return(await this.makeRequestAxios({path:"/User/sign-terms-url",method:"GET",jwt:this.token})).data}async startChallenge(t){return(await this.makeRequestAxios({path:"/Challenge/start",method:"POST",jwt:this.token,body:t})).data}async stopChallenge(t,r){return(await this.makeRequestAxios({path:`/Challenge/stop/${t}`,method:"POST",jwt:this.token,body:r})).data}async startRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/start-warning",method:"POST",jwt:this.token,body:t})).data}async stopRealtimeAlert(t){return(await this.makeRequestAxios({path:"/Realtime/stop-warning",method:"POST",jwt:this.token,body:t})).data}async verifyFace(t,r,n){return(await this.makeRequestAxios({path:"/Realtime/verify-face",method:"POST",jwt:this.token,body:{proctoringId:t,base64:r,retry:n}})).data}async getServerHour(t){return await this.makeRequest({path:"/Proctoring/server-hour",method:"GET",jwt:t})}async makeRequest(t){let{path:r,method:n,body:i,jwt:o}=t,s=await fetch(this.baseUrl+r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}async makeRequestPUT(t){let{url:r,method:n,body:i,jwt:o}=t,s=await fetch(r,{method:n,body:i!=null?JSON.stringify(i):void 0,headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","aeg-event-type":"Notification","Content-Type":"application/json","Cache-Control":"no-cache","x-ms-blob-type":"BlockBlob"}});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";let a=s.headers.get("content-type");return(a?a.includes("application/json"):!1)?await s.json():null}};var Da=class{constructor(){this.baseUrl="https://localhost:5080"}async isAlive(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-alive",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async isPluggedIn(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/is-plugged-in",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async ConnectAndScan(){return(await this.makeRequestAxios({path:"/api/usb-device-manager/connect-and-scan",method:"GET",jwt:this.token}).catch(r=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=[];return t&&i.push(`deviceType=${t}`),r&&i.push(`rssiThreshold=${r}`),n&&i.push(`packageRateThreshold=${n}`),(await this.makeRequestAxios({path:`/api/usb-device-manager/devices?${i.join("&")}`,method:"GET",jwt:this.token}).catch(s=>{throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde"})).data}async makeRequestAxios(t){let{path:r,method:n,body:i,jwt:o}=t,s=await vr.request({url:this.baseUrl+r,method:n,headers:{Authorization:`Bearer ${o}`,"Access-Control-Allow-Origin":"*"},data:i});if(s.status>=400)throw"N\xE3o foi poss\xEDvel realizar a requisi\xE7\xE3o, tente novamente mais tarde";return s}};var Hn=class{constructor(){this.sessionDuration=0;this.state="Created",this.startedAt=new Date,this.alerts=[],this.recordings=[]}get hasSomethingToUpload(){for(let t of this.recordings)if(!t.upload)return!0;return!1}start(){this.state="Recording",this.startedAt=new Date(Date.now())}pause(){this.state="Paused"}resume(){this.state="Recording"}stop(){this.state="Ended",this.sessionDuration=Date.now()-this.startedAt.getTime()}setProctoringId(t){this.id=t}setEndConfirmed(){this.state="EndConfirmed"}setUploaded(){this.state="Uploaded"}setUploadConfirmed(){this.state="UploadConfirmed"}addAlert(t){this.alerts.push(t)}addRecording(t){this.recordings.push(t)}};var Vi=class{constructor(t,r){this.backendService=new Da;this.scanInterval=5;this.options={};this.options=r,this.context=t,this.backend=new nr({type:t?.type||"prod",token:t.token}),this.currentIsPlugged=!0}setProctoringId(t){this.proctoringId=t}async isPluggedIn(t=!1){try{let r=await this.backendService.isPluggedIn();if(this.proctoringId&&t)if(r)this.currentIsPlugged||this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Dispositivo de varredura conectado.",status:"OK"});else{let n=new Hn;n.setProctoringId(this.proctoringId),n.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:33,type:5}),await this.backend.saveAlerts(this.context,n),this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam disconnected",description:"Nenhum dispositivo de varredura conectado.",status:"ALERT"})}return this.currentIsPlugged=r,this.currentIsPlugged}catch(r){throw r}}async isAlive(){try{return await this.backendService.isAlive()}catch(t){throw t}}connectAndScan(){return this.backendService.ConnectAndScan()}async devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n}){let i=await this.backendService.Devices({deviceType:t,rssiThreshold:r,packageRateThreshold:n});if(i.length>0&&(this.options.onRealtimeAlertsCallback?.({type:"spycam",message:"Spycam detected",description:"Dispositivo espi\xE3o detectado.",data:i}),this.proctoringId)){let o=new Hn;o.setProctoringId(this.proctoringId),o.addAlert({begin:Date.now()-this.startTime.getTime(),end:0,alert:32,type:5}),await this.backend.saveAlerts(this.context,o)}return i}async startCheckSpyCam(t,{deviceType:r,rssiThreshold:n,packageRateThreshold:i}){this.scanInterval=t,this.startTime=new Date(Date.now()),await this.isPluggedIn(!0),this.checkSpyCam=setInterval(async()=>{await this.isPluggedIn(!0)&&await this.devices({deviceType:r,rssiThreshold:n,packageRateThreshold:i})},this.scanInterval*6e4)}stopCheckSpyCam(){clearInterval(this.checkSpyCam)}};var ir={cameraId:void 0,microphoneId:void 0,allowMultipleMonitors:!1,allowOnlyFirstMonitor:!0,captureScreen:!0,noiseLimit:40,proctoringType:"IMAGE",insights:"",onBufferSizeError:!1,useGeolocation:!1,useSpyScan:!1,useExternalCamera:!1,useChallenge:!1,screenRecorderOptions:{width:1280,height:720}};function Oa(e){return e.width&&e.height?{width:e.width,height:e.height,minWidth:e.minWidth,minHeight:e.minHeight}:{width:640,height:480}}var Wg={width:1280,height:720,minWidth:640,minHeight:480};function $g(){let e=navigator.userAgent,t;return e.match(/chrome|chromium|crios/i)?t="chrome":e.match(/firefox|fxios/i)?t="firefox":e.match(/safari/i)?t="safari":e.match(/opr\//i)?t="opera":e.match(/edg/i)?t="edge":t="No browser detection",t}function mn(){if("userAgentData"in navigator){let e=navigator.userAgentData,t=e.mobile||!1,r=e.platform||"";return t||/Android|iOS/i.test(r)}return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)}var Ba,Gg=e=>(Ba=e,Ba),Pt={DEVICES_CHECKED:"devices_checked",START:"start",FINISH:"finish",ERROR:"error",UPLOAD:"upload",UPLOAD_FILE:"upload_file",DOWNLOAD_VIDEO:"download_video",BUFFER_SIZE:"buffer_size",ANOTHER_STREAM:"another_stream",CHANGE_DEVICE:"change_device",STOP_SHARING_SCREEN:"stop_sharing_screen",ERROR_RECORDER_RTC:"error_recorder_rtc",BROWSER_NOT_SUPPORTED:"browser_not_supported",SAVE_ON_SESSION:"save_on_session"},Dt=(e,t)=>Ba&&Ba.log(e,t),fe={registerDevicesChecked:(e,t,r)=>Dt(Pt.DEVICES_CHECKED,{proctoringId:e,success:t,description:r}),registerStart:(e,t,r)=>Dt(Pt.START,{proctoringId:e,success:t,description:r}),registerFinish:(e,t,r)=>Dt(Pt.FINISH,{proctoringId:e,success:t,description:r}),registerError:(e,t)=>Dt(Pt.ERROR,{proctoringId:e,description:t}),registerBrowserNotSupported:(e,t)=>Dt(Pt.BROWSER_NOT_SUPPORTED,{proctoringId:e,description:t}),registerUpload:(e,t,r,n,i)=>Dt(Pt.UPLOAD,{proctoringId:e,success:t,description:r,serviceType:n,uploadTime:i}),registerUploadFile:(e,t,r)=>Dt(Pt.UPLOAD_FILE,{proctoringId:e,description:t,fileType:r}),registerChangeDevice:(e,t,r)=>Dt(Pt.CHANGE_DEVICE,{proctoringId:e,inOrOut:t,description:r}),registerStopSharingScreen:(e,t)=>Dt(Pt.STOP_SHARING_SCREEN,{proctoringId:e,description:t}),registerErrorRecorderRTC:(e,t)=>Dt(Pt.ERROR_RECORDER_RTC,{proctoringId:e,description:t}),registerDownloadFile:(e,t)=>Dt(Pt.DOWNLOAD_VIDEO,{proctoringId:e,description:t}),registerOnBufferSizeError:(e,t)=>Dt(Pt.BUFFER_SIZE,{proctoringId:e,description:t}),registerAnotherStream:(e,t)=>Dt(Pt.ANOTHER_STREAM,{proctoringId:e,description:t}),registerSaveOnSession:(e,t)=>Dt(Pt.SAVE_ON_SESSION,{proctoringId:e,description:t})};var Vo;function La(e){Vo=e}function Wn(e,t,r=!1,n,i=!1){let o,s=!1,a,c,l;l=0;let h={mimeType:"video/webm",videoBitsPerSecond:128e3,audioBitsPerSecond:64*1e3};MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?h.mimeType="video/webm;codecs=vp9":console.warn("vp9 codec not supported. Using default mimeType without vp9."),i&&(h={mimeType:"audio/webm",audioBitsPerSecond:64*1e3});let d=new MediaRecorder(e,h);d.ondataavailable=v=>{l=l+v.data.size,v.data.size>0&&t.push(v.data),s?(i&&d.state=="inactive"&&(t=[new Blob(t,{type:"audio/webm"})]),o&&o()):((c&&v.data.size===c.data.size||v.data.size===0)&&(Vo&&c&&v.data.size===c.data.size&&fe.registerOnBufferSizeError(Vo,`onBufferSizeError: Recorder size freezed: ${v.data.size} Mb`),Vo&&v.data.size===0&&fe.registerOnBufferSizeError(Vo,"onBufferSizeError: Recorder size equal 0 Mb"),n&&n()),c=v)};function m(){return new Promise(v=>{o=v,d.start(),l=0,s=!1,r&&(a=setInterval(async()=>{await d.requestData()},3e4))})}function p(){return new Promise(v=>{d.state=="recording"?(o=v,d.stop(),s=!0,clearInterval(a),e.getTracks().forEach(k=>{k.stop()})):v()})}function g(){return new Promise(v=>{d.state=="recording"&&d.pause(),v()})}function f(){return new Promise(v=>{d.state=="paused"&&d.resume(),v()})}function b(){return l}return{startRecording:m,stopRecording:p,pauseRecording:g,resumeRecording:f,recorderOptions:h,getBufferSize:b}}var Jr=class{constructor(t,r){this.backend=r;this.imageUrlPackage=[];this.imageBatchNum=0;this.contImages=0;this.proctoringId=t}async uploadPackage(t,r){let{file:n,onProgress:i}=t;try{let o=c=>{let l=c.loadedBytes/n.size*100;i&&i(Math.round(l))},s=await this.backend.getSignedUrl(r,n,this.proctoringId),a=await vr.request({url:s,method:"PUT",headers:{"Content-Type":n.type,"x-ms-blob-type":"BlockBlob"},data:n,onUploadProgress:c=>{o({loadedBytes:c.loaded})}}).then(()=>!0).catch(()=>!1);return{storage:"upload",url:s,uploaded:a}}catch{throw fe.registerError(this.proctoringId,`Failed to upload to AWS
|
|
72
72
|
File name: ${n.name}
|
|
73
73
|
File type: ${n.type}
|
|
74
74
|
File size: ${n.size}`),new Error("Failed to upload to AWS")}}async uploadImages(t,r,n){let{file:i,onProgress:o}=t;try{let s=l=>{let h=l.loadedBytes/i.size*100;o&&o(Math.round(h))},a;if(this.imageBatchNum===this.contImages){let l=[];for(let d=this.imageBatchNum;d<this.imageBatchNum+60;d++){let m=`${this.proctoringId}/${this.proctoringId}_${d+1}.jpg`;(d+1)%n==0&&(m=`${this.proctoringId}/${this.proctoringId}_${d+1}_realtime.jpg`),l.push({objectName:m,contentType:"image/jpeg"})}(await this.backend.getSignedUrlImage(r,l)).map(d=>{this.imageUrlPackage.push(d)}),this.imageBatchNum+=60}let c=!1;return c=await vr.request({url:this.imageUrlPackage[this.contImages],method:"PUT",headers:{"Content-Type":i.type,"x-ms-blob-type":"BlockBlob"},data:i,onUploadProgress:l=>{s({loadedBytes:l.loaded})}}).then(l=>l.status==200||l.status==201?(this.contImages++,!0):!1).catch(()=>!1).finally(()=>{}),{storage:"upload",url:a,uploaded:c}}catch{throw fe.registerError(this.proctoringId,`Failed to upload to AWS
|
|
@@ -79,7 +79,7 @@ Minimum version required to store current data is: `+o+`.
|
|
|
79
79
|
File type: ${i.type}
|
|
80
80
|
File size: ${i.size}`),new Error("Failed to upload to AWS")}}};var qg="not_shared_first_screen",Kg="not_shared_screen",Fa="multiple_monitors_detected",Xg="proctoring_already_started",Ma="proctoring_not_started";var Jg="another_stream_active",Yg="stream_under_minimum_permitted",Zg="browser_not_supported",Qg="token_missing",e0="credentials_missing";var t0="spy_scan_api_not_found";var r0="external_camera_not_started";var Ua=class extends Bi{constructor(t,r,n="videoPreviewFrameDetection",i="liveViewFrameDetection"){super("ObjectDetector","https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite",t,r,n,i)}stopDetection(){super.stopDetection(),this.numPersonsSent>0&&this.handleOk("person_ok","person_detection_on_stream")}displayVideoDetections(t){for(let r of this.children)this.liveView.removeChild(r);this.children.splice(0);for(let r of t.detections){let n=window.innerWidth,i=window.innerHeight,o=this.video.offsetWidth,s=this.video.offsetHeight,a=o/n,c=s/i,l=o-r.boundingBox.width*a-r.boundingBox.originX*a,h=r.boundingBox.originY*c,d=(r.boundingBox.width-10)*a,m=r.boundingBox.height*c,p=document.createElement("p");p.innerText=r.categories[0].categoryName+" - with "+Math.round(parseFloat(r.categories[0].score)*100)+"% confidence.",p.style.right=l-20+"px",p.style.top=h+"px",p.style.width=d+"px";let g={zIndex:"2",position:"absolute",border:"1px dashed #fff"};Object.assign(p.style,{...g,margin:"0",fontSize:"9px",paddingBottom:"5px",paddingTop:"5px",color:"#fff",backgroundColor:"#007f8b"});let f=document.createElement("div");f.setAttribute("class","highlighter"),f.style.right=l-20+"px",f.style.top=h+"px",f.style.width=d+"px",f.style.height=m-20+"px",Object.assign(f.style,{...g,zIndex:"1",background:"rgba(0, 255, 0, 0.25)"}),this.liveView.appendChild(f),this.liveView.appendChild(p),this.children.push(f),this.children.push(p)}}verify(t){let r=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="person")).length,n=t.detections.filter(i=>i.categories.some(o=>o.categoryName==="cell phone")).length;this.paramsConfig.videoBehaviourParameters?.detectPerson&&r!==this.numPersonsSent&&(r===0?(this.handleAlert("no_person_detected","person_detection_on_stream"),this.numPersonsSent=r):r>1?(this.handleAlert("multiple_persons_detected","person_detection_on_stream"),this.numPersonsSent=r):(this.handleOk("person_ok","person_detection_on_stream"),this.numPersonsSent=r)),this.paramsConfig.videoBehaviourParameters?.detectCellPhone&&n!==this.numCellphoneSent&&(n>0?(this.handleAlert("cellphone_detected","mobile_detection_on_stream"),this.numCellphoneSent=n):(this.handleOk("cellphone_ok","mobile_detection_on_stream"),this.numCellphoneSent=n))}};var gn=class{constructor(t){this.volume=null;this.animationFrameId=null;this.stream=t}async start(t={}){return new Promise((r,n)=>{try{let i=new AudioContext;this.analyser=i.createAnalyser();let o=i.createMediaStreamSource(this.stream);this.analyser.smoothingTimeConstant=.8,this.analyser.fftSize=1024,o.connect(this.analyser);let s=()=>{let a=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(a);let l=a.reduce((h,d)=>h+d,0)/a.length;this.setVolume(l),t.setVolume&&t.setVolume(l),this.animationFrameId=requestAnimationFrame(s)};this.animationFrameId=requestAnimationFrame(s),r(!0)}catch(i){this.stop(),n(`Error: ${i}`)}})}stop(){this.animationFrameId!==null&&cancelAnimationFrame(this.animationFrameId)}getVolume(){return this.volume}setVolume(t){this.volume=t}};var s0=ul(i0()),Yr=class{constructor(t,r,n,i,o){this.blobs=[];this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectPerson:!1,detectFace:!1,detectCellPhone:!1}};this.options={cameraId:void 0,microphoneId:void 0,onBufferSizeError:!1,onBufferSizeErrorCallback:t=>{},proctoringType:"IMAGE",onChangeDevicesCallback:t=>{},onRealtimeAlertsCallback:t=>{}};this.videoOptions={width:640,height:480,minWidth:0,minHeight:0};this.blobsRTC=[];this.imageCount=0;this.filesToUpload=[];this.animationFrameId=null;this.isCanvasLoopActive=!1;this.hardwareStream=null;this.internalClonedStream=null;this.currentRetries=0;this.packageCount=0;this.noiseWait=20;this.options=t,this.videoOptions=r,this.backend=i,this.backendToken=o,n&&(this.paramsConfig=n)}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Jr(this.proctoringId,this.backend)),La(t)}async initializeDetectors(){og(),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&(this.objectDetection=new Ua({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.objectDetection.initializeDetector()),this.paramsConfig.videoBehaviourParameters?.detectFace&&(this.faceDetection=new Li({onRealtimeAlertsCallback:t=>this.options.onRealtimeAlertsCallback(t)},this.paramsConfig),await this.faceDetection.initializeDetector())}configImageCapture(){this.video=document.createElement("video"),this.canvas=document.createElement("canvas"),this.video.srcObject=this.cameraStream,this.video.play(),this.video.muted=!0,this.canvas.width=this.videoOptions.width,this.canvas.height=this.videoOptions.height}async bufferError(t){console.log("buffer error Camera Recorder params "+this.paramsConfig.videoBehaviourParameters);let r=this.paramsConfig.videoBehaviourParameters?.retryEnabled||!1,n=this.paramsConfig.videoBehaviourParameters?.maxRetries||3;r&&this.currentRetries<n?(await this.recordingStop(),await this.startRecording({retry:!0}),this.currentRetries++,this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback(this.cameraStream)):this.options.onBufferSizeErrorCallback&&this.options.onBufferSizeErrorCallback()}async startRecording(t){(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone||this.paramsConfig.videoBehaviourParameters?.detectFace)&&!t?.retry&&await this.initializeDetectors();let{cameraId:r,microphoneId:n,onBufferSizeErrorCallback:i}=this.options,o={audio:{deviceId:n},video:{deviceId:r,width:this.videoOptions.width,height:this.videoOptions.height,frameRate:15}};try{this.hardwareStream=await navigator.mediaDevices.getUserMedia(o)}catch(v){throw v.toString()=="NotReadableError: Could not start video source"?"N\xE3o foi poss\xEDvel conectar a camera, ela pode estar sendo utilizada por outro programa":v}this.cameraStream=this.hardwareStream;let a=this.cameraStream.getVideoTracks()[0].getSettings(),{width:c=0,height:l=0}=a,{startRecording:h,stopRecording:d,pauseRecording:m,resumeRecording:p,recorderOptions:g,getBufferSize:f}=Wn(this.cameraStream,this.blobs,this.options.onBufferSizeError,v=>this.bufferError(v),!1);if(this.recordingStart=h,this.recordingStop=d,this.recordingPause=m,this.recordingResume=p,this.recorderOptions=g,this.getBufferSize=f,this.recordingStart(),screen.orientation?.type.includes("portrait")&&mn()&&this.videoOptions.width==l&&this.videoOptions.height==c&&([c,l]=[l,c]),this.videoOptions.minWidth>c||this.videoOptions.minHeight>l)throw Yg;if(this.videoOptions.width!==c||this.videoOptions.height!==l)throw fe.registerAnotherStream(this.proctoringId,`Maybe have another stream active
|
|
81
81
|
Video Options: ${JSON.stringify(this.videoOptions,null,2)}
|
|
82
|
-
Setting: ${JSON.stringify(a,null,2)}`),Jg;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&
|
|
82
|
+
Setting: ${JSON.stringify(a,null,2)}`),Jg;this.paramsConfig.imageBehaviourParameters?.useUploadImage&&this.options.proctoringType=="IMAGE"&&this.photoShotsCycle(),this.paramsConfig.videoBehaviourParameters?.detectFace&&await this.faceDetection.enableCam(this.cameraStream),(this.paramsConfig.videoBehaviourParameters?.detectPerson||this.paramsConfig.videoBehaviourParameters?.detectCellPhone)&&await this.objectDetection.enableCam(this.cameraStream),this.filesToUpload=[],this.options.proctoringType=="REALTIME"&&this.captureFrame(),this.packageCount=0}async stopRecording(){this.isCanvasLoopActive=!1,this.recordingStop&&await this.recordingStop();try{this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.cameraStream&&this.cameraStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream&&(this.internalClonedStream.getTracks().forEach(t=>t.stop()),this.internalClonedStream=null),this.hardwareStream&&(this.hardwareStream.getTracks().forEach(t=>t.stop()),this.hardwareStream=null)}catch{console.error("Erro ao parar os streams de m\xEDdia.")}this.faceDetection&&this.faceDetection.detecting&&this.faceDetection.stopDetection(),this.objectDetection&&this.objectDetection.detecting&&this.objectDetection.stopDetection(),clearInterval(this.imageInterval),clearInterval(this.sendFrameInterval),this.options.proctoringType=="REALTIME"&&this.upload&&this.backendToken&&(await this.sendPackage(this.filesToUpload),await this.filesToUpload.splice(0,this.filesToUpload.length)),this.volumeMeter&&this.volumeMeter.stop(),this.intervalNoiseDetection&&clearInterval(this.intervalNoiseDetection)}async pauseRecording(){await this.recordingPause()}async resumeRecording(){await this.recordingResume()}photoShotsCycle(){let t;this.configImageCapture(),this.imageInterval=setInterval(async()=>{this.canvas.getContext("2d").drawImage(this.video,0,0,this.videoOptions.width,this.videoOptions.height);let r=this.canvas.toDataURL("image/jpeg");t=await this.getFile(r,`${this.proctoringId}_${this.imageCount+1}.jpg`,"image/jpeg"),t&&this.upload&&this.backendToken&&(this.upload.upload({file:t},this.backendToken,!0),this.imageCount++)},this.paramsConfig.imageBehaviourParameters.uploadInterval*1e3)}async getCurrentImageBase64(){return!this.video||!this.canvas?this.configImageCapture():this.video.srcObject!==this.cameraStream&&(this.video.srcObject=this.cameraStream,await this.video.play()),this.video.paused&&await this.video.play(),await new Promise(t=>{if(this.video.readyState>=2){t();return}let r=()=>{this.video.removeEventListener("loadedmetadata",r),setTimeout(()=>t(),50)};this.video.addEventListener("loadedmetadata",r),setTimeout(()=>{this.video.removeEventListener("loadedmetadata",r),t()},500)}),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height),this.canvas.toDataURL("image/jpeg")}captureFrame(){let t;this.configImageCapture();let r=this.videoOptions.width/2,n=this.videoOptions.height/2;r<320&&(r=320),n<180&&(n=180),this.canvas.width=r,this.canvas.height=n;let i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize;this.imageCount=0,this.imageInterval=setInterval(async()=>{console.log("capturando frame "+this.imageCount),this.canvas.getContext("2d").drawImage(this.video,0,0,this.canvas.width,this.canvas.height);let o=this.canvas.toDataURL("image/jpeg");if(this.proctoringId==null)return;if(i==this.imageCount){this.imageCount=0;let a=[...this.filesToUpload];this.sendPackage(a),await this.filesToUpload.splice(0,this.filesToUpload.length)}let s=`${this.proctoringId}_${this.imageCount+1}.jpg`;t=await this.getFile(o,s,"image/jpeg"),t&&t.size>10&&i>0&&(this.filesToUpload.push(t),this.imageCount++)},this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval*1e3)}async sendPackage(t){let r=!1,n=0,i=this.paramsConfig.videoBehaviourParameters?.realtimePackageSize,o=this.paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval+1;if(this.upload&&this.backendToken&&!r&&this.filesToUpload.length>0){n=0,r=!0;let s=new s0.default;for(let d of t)s.file(d.name,d);let a=await s.generateAsync({type:"blob"}),c="realtime_package_"+i*o*this.packageCount+".zip",l=new File([a],c,{type:"application/zip"});(await this.upload.uploadPackage({file:l},this.backendToken)).uploaded==!0?this.packageCount++:console.log("erro no upload do pacote"),r=!1}else if(r&&(n++,n==3)){n=0;let s=this.videoOptions.width/2,a=this.videoOptions.height/2;s<320&&(s=320),a<180&&(a=180),this.canvas.width=s,this.canvas.height=a}}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}async saveOnSession(t){this.blobs!=null&&fe.registerSaveOnSession(this.proctoringId,`Blobs Length: ${this.blobs.length} Buffer Size: ${this.getBufferSize()} `);let r=this.cameraStream.getVideoTracks()[0].getSettings(),n=this.cameraStream.getAudioTracks()[0].getSettings();(this.options.proctoringType=="VIDEO"||this.options.proctoringType=="REALTIME"||this.options.proctoringType=="IMAGE"&&this.paramsConfig.imageBehaviourParameters?.saveVideo)&&t.addRecording({device:`Audio
|
|
83
83
|
Sample Rate: ${n.sampleRate}
|
|
84
84
|
Sample Size: ${n.sampleSize}
|
|
85
85
|
|
|
@@ -432,7 +432,7 @@ Para iniciar um exame utilize uma outra c\xE2mera.`),o.setAttribute("class","che
|
|
|
432
432
|
File size: ${n.size}`),new Error("Error on machine download")}}};var Wa=class{constructor(t,r){this.session=t;this.recorders=r}async startAll(){this.session.start();for(let t of this.recorders)await t.startRecording({retry:!1})}async pauseAll(){this.session.pause();for(let t of this.recorders)await t.pauseRecording()}async resumeAll(){this.session.resume();for(let t of this.recorders)await t.resumeRecording()}async stopAll(){for(let t of this.recorders)await t.stopRecording();this.session.stop()}async saveAllOnSession(){for(let t of this.recorders)await t.saveOnSession(this.session)}};var $i=class{constructor(t,r,n){this.session=t;this.proctoringId=r;this.uploadServices=n}async upload(t,r){await this.uploadRecordings(t,r)}async uploadRecordings(t,r){await this.uploadAllFiles(t,r),this.session.hasSomethingToUpload||this.session.setUploaded()}async uploadAllFiles(t,r){for(let n=0;n<this.session.recordings.length;n++){let i=this.session.recordings[n];if(i.upload)continue;let o=a=>{let c=(n*100+a)/this.session.recordings.length;r&&r(c)},s=await this.uploadFile(i,t,o).catch(()=>{});s&&(i.upload||(i.upload={storage:"upload",awsUrl:"",azureUrl:""}),s.uploaded&&(i.upload.storage=s.storage),s.storage==="upload"?s.url&&(i.upload.azureUrl=s.url):s.url&&(i.upload.awsUrl=s.url))}r&&r(100)}async uploadFile(t,r,n){for await(let i of this.uploadServices){let o=await i.upload({file:t.file,onProgress:s=>{n&&n(s)}},r);if(o){let s="";return t.file.name.search("camera")!==-1?s="Camera":t.file.name.search("screen")!==-1?s="Screen":t.file.name.search("audio")!==-1&&(s="Audio"),fe.registerUploadFile(this.proctoringId,`Upload File
|
|
433
433
|
Name: ${t.file.name}
|
|
434
434
|
Type: ${t.file.type}
|
|
435
|
-
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var $a=class{constructor(t,r){this.alerts=[];this.lastActivityTime=Date.now();this.IDLE_THRESHOLD_MS=3e4;this.handleLostFocus=()=>{if(this.getRelativeTime()>1e4){let t={begin:this.getRelativeTime(),end:0,alert:25,type:3};this.onLostFocusCallback(t),this.alerts.push(t)}};this.handleReturnFocus=()=>{let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback({begin:t.begin,end:this.getRelativeTime(),alert:25,type:3}),t.end=this.getRelativeTime())};this.handleResize=()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{let t=window.screen.availWidth,r=window.outerWidth;if(r<t*.85){let n=`Split Screen Detectado: Janela ocupa ${(r/t*100).toFixed(0)}% da tela`;this.createAlert(200,3,n),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:n,type:"split_screen"})}},1e3)};this.handleUserActivity=t=>{this.lastActivityTime=Date.now(),console.log("\u{1F449} handleUserActivity",t)};this.handleCopy=t=>{t.preventDefault();let r="Tentativa de Copiar (Clipboard)";this.createAlert(100,6,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_copy"})};this.handleCut=t=>{t.preventDefault();let r="Tentativa de Recortar (Clipboard)";this.createAlert(100,6,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_cut"})};this.handlePaste=t=>{t.preventDefault();let r="Tentativa de Colar (Clipboard)";this.createAlert(100,6,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_paste"})};this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.onRealtimeAlertCallback=t.onRealtimeAlertCallback,this.optionsProctoring=r}async startRecording(){this.startTime=new Date(Date.now()),this.alerts=[],this.attachListeners()}async pauseRecording(){this.detachListeners()}async resumeRecording(){this.attachListeners()}async stopRecording(){this.detachListeners()}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}attachListeners(){this.optionsProctoring.captureScreen&&(window.addEventListener("blur",this.handleLostFocus),window.addEventListener("focus",this.handleReturnFocus),window.addEventListener("resize",this.handleResize),window.document.addEventListener("copy",this.handleCopy),window.document.addEventListener("cut",this.handleCut),window.document.addEventListener("paste",this.handlePaste))}detachListeners(){window.removeEventListener("blur",this.handleLostFocus),window.removeEventListener("focus",this.handleReturnFocus),window.removeEventListener("resize",this.handleResize),window.document.removeEventListener("copy",this.handleCopy),window.document.removeEventListener("cut",this.handleCut),window.document.removeEventListener("paste",this.handlePaste)}addBackgroundEvent(t,r=200){this.createAlert(r,6,t),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:t,type:"background_event"})}getRelativeTime(){return Date.now()-this.startTime.getTime()}createAlert(t,r,n){this.alerts.push({begin:this.getRelativeTime(),end:this.getRelativeTime(),alert:t,type:r})}addAlert({alert:t,type:r}){this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:Date.now()-this.startTime.getTime(),alert:t,type:r})}};var Ga=class{constructor(t,r){this.blobs=[];this.options={cameraId:void 0,microphoneId:void 0};this.audioParams={recordingBitrate:128};r&&(this.audioParams=r),t&&(this.options=t)}async startRecording(){let t={audio:{deviceId:this.options.microphoneId||"default"}};this.audioStream=await navigator.mediaDevices.getUserMedia(t);let{startRecording:r,stopRecording:n,pauseRecording:i,resumeRecording:o}=Wn(this.audioStream,this.blobs,void 0,void 0,!0);this.recordingStart=r,this.recordingStop=n,this.recordingPause=i,this.recordingResume=o,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t,r,n){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&n&&`${r}_${n}`||"0"}.webm`,{type:"audio/webm"}),origin:"Mic"})}};var Kn=typeof self<"u"?self:{};function $n(){throw Error("Invalid UTF8")}function l0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var qa,Cd,y_=typeof TextDecoder<"u",b_,v_=typeof TextEncoder<"u";function G0(e){if(v_)e=(b_||=new TextEncoder).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let i=0;i<e.length;i++){var t=e.charCodeAt(i);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&i<e.length){let o=e.charCodeAt(++i);if(o>=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}i--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var Hd,ec;e:{for(xd=["CLOSURE_FLAGS"],Ka=Kn,Xa=0;Xa<xd.length;Xa++)if((Ka=Ka[xd[Xa]])==null){ec=null;break e}ec=Ka}var xd,Ka,Xa,Jo,h0=ec&&ec[610401301];Hd=h0!=null&&h0;var d0=Kn.navigator;function Ld(e){return!!Hd&&!!Jo&&Jo.brands.some((({brand:t})=>t&&t.indexOf(e)!=-1))}function cr(e){var t;return(t=Kn.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function vn(){return!!Hd&&!!Jo&&Jo.brands.length>0}function Ad(){return vn()?Ld("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=d0&&d0.userAgentData||null;var __=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||Ad(),Ad(),cr("Safari")&&(Ad()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Ld("Microsoft Edge"):cr("Edg/"))||vn()&&Ld("Opera"));var q0={},$o=null;function w_(e){let t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);let n=new Uint8Array(r),i=0;return(function(o,s){function a(l){for(;c<o.length;){let h=o.charAt(c++),d=$o[h];if(d!=null)return d;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}K0();let c=0;for(;;){let l=a(-1),h=a(0),d=a(64),m=a(64);if(m===64&&l===-1)break;s(l<<2|h>>4),d!=64&&(s(h<<4&240|d>>2),m!=64&&s(d<<6&192|m))}})(e,(function(o){n[i++]=o})),i!==r?n.subarray(0,i):n}function K0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));q0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var X0=typeof Uint8Array<"u",J0=!__&&typeof btoa=="function";function u0(e){if(!J0){var t;t===void 0&&(t=0),K0(),t=q0[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var i=e[c],o=e[c+1],s=e[c+2],a=t[i>>2];i=t[(3&i)<<4|o>>4],o=t[(15&o)<<2|s>>6],s=t[63&s],r[l++]=a+i+o+s}switch(a=0,s=n,e.length-c){case 2:s=t[(15&(a=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|a>>4]+s+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f0=/[-_.]/g,S_={"-":"+",_:"/",".":"="};function k_(e){return S_[e]||""}function Y0(e){if(!J0)return w_(e);f0.test(e)&&(e=e.replace(f0,k_)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function hc(e){return X0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return E_||=new wn(null,Yi)}function Wd(e){Z0(Yi);var t=e.g;return(t=t==null||hc(t)?t:typeof t=="string"?Y0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Wd(this)||0)}constructor(e,t){if(Z0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},E_,C_;function Z0(e){if(e!==Yi)throw Error("illegal external caller")}function Q0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function p0(){let e=Error("int32");return Q0(e,"warning"),e}var dc=typeof Symbol=="function"&&typeof Symbol()=="symbol",x_=new Set;function uc(e,t,r=!1,n=!1){return e=typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t,r&&x_.add(e),e}var A_=uc("jas",void 0,!0,!0),Td=uc(void 0,"2ex"),Ho=uc(void 0,"1oa",!0),Qi=uc(void 0,Symbol(),!0),se=dc?A_:"M",e1={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},t1=Object.defineProperties;function $d(e,t){dc||se in e||t1(e,e1),e[se]|=t}function ct(e,t){dc||se in e||t1(e,e1),e[se]=t}function T_(e,t){ct(t,-30975&(0|e))}function Fd(e,t){ct(t,-30941&(34|e))}function Gd(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var qd,Zo={},I_={};function m0(e){return!(!e||typeof e!="object"||e.g!==I_)}function Kd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function r1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(hc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function tc(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var g0=[];function Yn(e){if(2&e)throw Error()}function Xd(e){return Qi?e[Qi]:void 0}ct(g0,55),qd=Object.freeze(g0);var n1=Object.freeze({}),Jd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Md=e=>Jd?e>=P_&&e<=O_:e[0]==="-"?y0(e,R_):y0(e,D_),R_=Number.MIN_SAFE_INTEGER.toString(),P_=Jd?BigInt(Number.MIN_SAFE_INTEGER):void 0,D_=Number.MAX_SAFE_INTEGER.toString(),O_=Jd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function y0(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],i=t[r];if(n>i)return!1;if(n<i)return!0}}var B_=typeof Uint8Array.prototype.slice=="function",i1,De=0,Ge=0;function b0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){b0(-e);let[t,r]=Qd(De,Ge);De=t>>>0,Ge=r>>>0}else b0(e)}function o1(e){let t=i1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Yd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function Zd(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Yd(e,t))=="number"?r?-e:e:r?"-"+e:e}function Yo(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Gd()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+v0(r)+v0(e));return r}function v0(e){return e=String(e),"0000000".slice(e.length)+e}function fc(e){if(e.length<16)eo(Number(e));else if(Gd())e=BigInt(e),De=Number(e&BigInt(4294967295))>>>0,Ge=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Ge=De=0;let r=e.length;for(let n=t,i=(r-t)%6+t;i<=r;n=i,i+=6){let o=Number(e.slice(n,i));Ge*=1e6,De=1e6*De+o,De>=4294967296&&(Ge+=Math.trunc(De/4294967296),Ge>>>=0,De>>>=0)}if(t){let[n,i]=Qd(De,Ge);De=n,Ge=i}}}function Qd(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var s1=typeof BigInt=="function"?BigInt.asIntN:void 0,L_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,pc=Number.isFinite,rc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function _0(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}var F_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function eu(e){switch(typeof e){case"bigint":return!0;case"number":return pc(e);case"string":return F_.test(e);default:return!1}}function Xn(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return pc(e)?0|e:void 0}function w0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function a1(e){return e=rc(e),Go(e)||(eo(e),e=Zd(De,Ge)),e}function c1(e){var t=rc(Number(e));if(Go(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),t=e.length,!(e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337))if(fc(e),e=De,2147483648&(t=Ge))if(Gd())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=Qd(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function Ud(e){return e==null?e:typeof e=="bigint"?(Md(e)?e=Number(e):(e=s1(64,e),e=Md(e)?Number(e):String(e)),e):eu(e)?typeof e=="number"?a1(e):c1(e):void 0}function M_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(L_(64,e));if(eu(e)){if(t==="string")return t=rc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),w0(e)||(fc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=rc(e))>=0&&Go(e)?e:(function(r){if(r<0){eo(r);var n=Yo(De,Ge);return r=Number(n),Go(r)?r:n}return w0(n=String(r))?n:(eo(r),Yd(De,Ge))})(e)}}function l1(e){if(typeof e!="string")throw Error();return e}function nc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function h1(e,t,r){if(e!=null&&typeof e=="object"&&e.B===Zo)return e;if(Array.isArray(e)){var n=0|e[se],i=n;return i===0&&(i|=32&r),(i|=2&r)!==n&&ct(e,i),new t(e)}}function d1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=tc(e)?void 0:i&&2&(0|e[se])?e:tu(e,t,r,n!==void 0,i);else if(Kd(e)){let o={};for(let s in e)o[s]=d1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function tu(e,t,r,n,i){let o=n||r?0|e[se]:0,s=n?!!(32&o):void 0;n=lr(e);for(let a=0;a<n.length;a++)n[a]=d1(n[a],t,r,s,i);return r&&((e=Xd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function U_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Md(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(tc(t))return}else{if(hc(t))return u0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=u0(r)}}}return t})(e)}function N_(e){return tu(e,U_,void 0,void 0,!1)}var u1,z_;function qo(e,t,r){return e=f1(e,t[0],t[1],r?1:2),t!==u1&&r&&$d(e,16384),e}function f1(e,t,r,n){if(e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-33521665&i|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(i=0|e[se]))throw Error("farr");if(64&i)return e;if(n===1||n===2||(i|=64),r&&(i|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let o=n-1;if(Kd(r[o])){if((t=o-(512&(i|=256)?0:-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(512&i?0:-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&t)<<15}}}return ct(e,i),e}function p1(e,t,r=Fd){if(e!=null){if(X0&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=0|e[se];return 2&n?e:(t&&=n===0||!!(32&n)&&!(64&n||!(16&n)),t?(ct(e,-12293&(34|n)),e):tu(e,p1,4&n?Fd:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(mc(r,n,!0))),e}}function m1(e){let t=e.l;return new e.constructor(mc(t,0|t[se],!1))}function mc(e,t,r){let n=r||2&t?Fd:T_,i=!!(32&t);return e=(function(o,s,a){let c=lr(o);var l=c.length;let h=256&s?c[l-1]:void 0;for(l+=h?-1:0,s=512&s?1:0;s<l;s++)c[s]=a(c[s]);if(h){s=c[s]={};for(let d in h)s[d]=a(h[d])}return(o=Xd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>p1(o,i,n))),$d(e,32|(r?2:0)),e}function ru(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(mc(t,r,!1)):e}function _r(e,t){return Zn(e=e.l,0|e[se],t)}function Zn(e,t,r,n){if(r===-1)return null;var i=r+(512&t?0:-1);let o=e.length-1;return i>=o&&256&t?e[o][r]:n&&256&t&&(t=e[o][r])!=null?(e[i]!=null&&Td!=null&&((i=(e=C_??={})[Td]||0)>=4||(e[Td]=i+1,Q0(e=Error(),"incident"),(function(s){Kn.setTimeout((()=>{throw s}),0)})(e))),t):i<=o?e[i]:void 0}function pt(e,t,r){let n=e.l,i=0|n[se];return Yn(i),lt(n,i,t,r),e}function lt(e,t,r,n){let i=512&t?0:-1,o=r+i;var s=e.length-1;return o>=s&&256&t?(e[s][r]=n,t):o<=s?(e[o]=n,256&t&&r in(e=e[s])&&delete e[r],t):(n!==void 0&&(r>=(s=t>>15&1023||536870912)?n!=null&&(e[s+i]={[r]:n},ct(e,t|=256)):e[o]=n),t)}function g1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=r1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function y1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=nu(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=Qr(a,e),e=lt(o,e,t,n));let c=0,l=0;for(;c<n.length;c++){let h=r(n[c]);h!=null&&(n[l++]=h)}l<c&&(n.length=l),a=iu(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Zr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Zr(a)&&(n=lr(n),a=Qr(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Zr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function nu(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:qd}function iu(e,t){return e===0&&(e=Qr(e,t)),1|e}function Zr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function S0(e,t,r){let n=0|(e=e.l)[se];if(Yn(n),r==null)lt(e,n,t);else{var i=0|r[se],o=i,s=Zr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=l1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=Qr(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function b1(e,t){let r=0|(e=e.l)[se];Yn(r),lt(e,r,2,t===""?void 0:t)}function es(e,t,r,n,i){Yn(t);var o=!(!(64&t)&&16384&t);let s=(i=nu(e,t,r,i))!==qd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Zr(a)||4&a&&!(32&a))&&(i=lr(i),a=Qr(a,t),t=lt(e,t,r,i)),a=-13&iu(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Id(e,t){var r=c2;return su(ou(e=e.l),e,0|e[se],r)===t?t:-1}function ou(e){if(dc)return e[Ho]??(e[Ho]=new Map);if(Ho in e)return e[Ho];let t=new Map;return Object.defineProperty(e,Ho,{value:t}),t}function v1(e,t,r,n){let i=ou(e),o=su(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function su(e,t,r,n){let i=e.get(n);if(i!=null)return i;i=0;for(let o=0;o<n.length;o++){let s=n[o];Zn(t,r,s)!=null&&(i!==0&&(r=lt(t,r,i)),i=s)}return e.set(n,i),i}function au(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=ru(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(mc(n,s,!1),t,!0):64&s?n:qo(i,t,!0)}else i=qo(void 0,t,!0);return i!==n&<(e,o,r,i),i}function _1(e,t,r,n){let i=0|(e=e.l)[se];return(t=h1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=_1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=ru(t);i!==t&<(e,n,r,t=i)}return t}function w1(e,t,r,n,i,o){e=e.l;var s=!!(2&t);let a=s?1:n;i=!!i,o&&=!s;var c=0|(n=nu(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=iu(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=h1(l[g],r,h);if(b instanceof r){if(!d){let v=!!(2&(0|b.l[se]));m&&=!v,p&&=v}l[f++]=b}}f<g&&(l.length=f),c|=4,c=p?16|c:-17&c,ct(l,c=m?8|c:-9&c),d&&Object.freeze(l)}if(o&&!(8&c||!n.length&&(a===1||a===4&&32&c))){for(Zr(c)&&(n=lr(n),c=Qr(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=ru(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Zr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Zr(c)&&(ct(n=lr(n),c=kn(c=Qr(c,t),t,i)),t=lt(e,t,1,n)),Zr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function cu(e,t){let r=0|e.l[se];return w1(e,r,t,n1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Rd(e,t,r){var n=i2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=ou(e);if(su(o,e,i,n)!==t)break e;o.set(n,0)}else i=v1(e,i,n,t);lt(e,i,t,r)}}function Qr(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function kn(e,t,r){return 32&t&&r||(e&=-33),e}function S1(e,t){var r=Eu;let n=0|e.l[se];Yn(n),e=w1(e,n,r,2,!0),t=t??new r,e.push(t),e[se]=2&(0|t.l[se])?-9&e[se]:-17&e[se]}function Ot(e,t,r){Yn(0|e.l[se]),y1(e,t,Sn,2,!0).push(l1(r))}function k1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function lu(){return Error("Failed to read varint, encoding is invalid.")}function E1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function hu(e){if(typeof e=="string")return{buffer:Y0(e),u:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),u:!1};if(e.constructor===Uint8Array)return{buffer:e,u:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),u:!1};if(e.constructor===wn)return{buffer:Wd(e)||new Uint8Array(0),u:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),u:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function du(e,t){let r,n=0,i=0,o=0,s=e.i,a=e.g;do r=s[a++],n|=(127&r)<<o,o+=7;while(o<32&&128&r);for(o>32&&(i|=(127&r)>>4),o=3;o<32&&128&r;o+=7)r=s[a++],i|=(127&r)<<o;if(qn(e,a),r<128)return t(n>>>0,i>>>0);throw lu()}function uu(e){let t=0,r=e.g,n=r+10,i=e.i;for(;r<n;){let o=i[r++];if(t|=o,(128&o)==0)return qn(e,r),!!(127&t)}throw lu()}function Bt(e){let t=e.i,r=e.g,n=t[r++],i=127&n;if(128&n&&(n=t[r++],i|=(127&n)<<7,128&n&&(n=t[r++],i|=(127&n)<<14,128&n&&(n=t[r++],i|=(127&n)<<21,128&n&&(n=t[r++],i|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw lu();return qn(e,r),i}function Nd(e){var t=e.i;let r=e.g,n=t[r],i=t[r+1],o=t[r+2];return t=t[r+3],qn(e,e.g+4),(n<<0|i<<8|o<<16|t<<24)>>>0}function zd(e){var t=Nd(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function j_(e){return Bt(e)}function Pd(e,t,{C:r=!1}={}){e.C=r,t&&(t=hu(t),e.i=t.buffer,e.m=t.u,e.s=0,e.j=e.i.length,e.g=e.s)}function qn(e,t){if(e.g=t,t>e.j)throw E1(e.j,t)}function C1(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.j)throw E1(t,e.j-r);return e.g=n,r}function x1(e,t){if(t==0)return Zi();var r=C1(e,t);return e.C&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?new Uint8Array(0):B_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var k0=[];function A1(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=Bt(e.g)>>>0;if(t=r>>>3,!((r&=7)>=0&&r<=5))throw k1(r,e.j);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function Za(e){switch(e.i){case 0:e.i!=0?Za(e):uu(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Za(e);else{var t=Bt(e.g)>>>0;qn(e=e.g,e.g+t)}break;case 5:qn(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!A1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Za(e)}break;default:throw k1(e.i,e.j)}}function gc(e,t,r){let n=e.g.j,i=Bt(e.g)>>>0,o=e.g.g+i,s=o-n;if(s<=0&&(e.g.j=o,r(t,e,void 0,void 0,void 0),s=o-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${i} bytes, instead read ${i-s} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=o,e.g.j=n}function fu(e){var t=Bt(e.g)>>>0,r=C1(e=e.g,t);if(e=e.i,y_){var n,i=e;(n=Cd)||(n=Cd=new TextDecoder("utf-8",{fatal:!0})),t=r+t,i=r===0&&t===i.length?i:i.subarray(r,t);try{var o=n.decode(i)}catch(a){if(qa===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),qa=!0}catch{qa=!1}}throw!qa&&(Cd=void 0),a}}else{t=(o=r)+t,r=[];let a,c=null;for(;o<t;){var s=e[o++];s<128?r.push(s):s<224?o>=t?$n():(a=e[o++],s<194||(192&a)!=128?(o--,$n()):r.push((31&s)<<6|63&a)):s<240?o>=t-1?$n():(a=e[o++],(192&a)!=128||s===224&&a<160||s===237&&a>=160||(192&(n=e[o++]))!=128?(o--,$n()):r.push((15&s)<<12|(63&a)<<6|63&n)):s<=244?o>=t-2?$n():(a=e[o++],(192&a)!=128||a-144+(s<<28)>>30!=0||(192&(n=e[o++]))!=128||(192&(i=e[o++]))!=128?(o--,$n()):(s=(7&s)<<18|(63&a)<<12|(63&n)<<6|63&i,s-=65536,r.push(55296+(s>>10&1023),56320+(1023&s)))):$n(),r.length>=8192&&(c=l0(c,r),r.length=0)}o=l0(c,r)}return o}function T1(e){let t=Bt(e.g)>>>0;return x1(e.g,t)}function pu(e,t,r){var n=Bt(e.g)>>>0;for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ja=[];function V_(e){return e}var Ki;function I1(e,t,r){t.g?t.j(e,t.g,t.i,r):t.j(e,t.i,r)}var Ue=class{constructor(e,t){this.l=f1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=N_),R1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function R1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=Kd(r);n?l--:r=void 0;var i=e;if(n){e:{var o,s=r,a=!1;if(s)for(let h in s)isNaN(+h)?(o??={})[h]=s[h]:(n=s[h],Array.isArray(n)&&(tc(n)||m0(n)&&n.size===0)&&(n=null),n==null&&(a=!0),n!=null&&((o??={})[h]=n));if(a||(o=s),o)for(let h in o){a=o;break e}a=null}s=a==null?r!=null:a!==r}for(;l>0&&((o=i[l-1])==null||tc(o)||m0(o)&&o.size===0);l--)var c=!0;(i!==e||s||c)&&(t?(c||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),c=i}else c=e}return c}function E0(e){return e?/^\d+$/.test(e)?(fc(e),new jd(De,Ge)):null:H_||=new jd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=V_,R1(this).toString()}finally{Ki=void 0}};var jd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;function C0(e){return e?/^-?\d+$/.test(e)?(fc(e),new Vd(De,Ge)):null:W_||=new Vd(0,0)}var Vd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},W_;function Xi(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function ts(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function yc(e,t){if(t>=0)ts(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function ic(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function to(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function kr(e,t,r){ts(e.g,8*t+r)}function bc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function vc(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function _c(e,t,r){kr(e,t,2),ts(e.g,r.length),to(e,e.g.end()),to(e,r)}function Er(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var mu=Er(),P1=Er(),gu=Er(),yu=Er(),D1=Er(),O1=Er(),B1=Er(),L1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=mu,this.j=!!e&&r===e||!1}};function bu(e,t){return new ro(e,t,mu)}function F1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}var $_=bu((function(e,t,r,n,i){return e.i===2&&(gc(e,au(t,n,r),i),!0)}),F1),G_=bu((function(e,t,r,n,i){return e.i===2&&(gc(e,au(t,n,r,!0),i),!0)}),F1),wc=Symbol(),vu=Symbol(),x0=Symbol(),A0=Symbol(),M1,U1;function Qn(e,t,r,n){var i=n[e];if(i)return i;(i={}).P=n,i.A=(function(d){switch(typeof d){case"boolean":return u1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?z_||=[0,void 0]:[-d,void 0];case"string":return[0,d];case"object":return d}})(n[0]);var o=n[1];let s=1;o&&o.constructor===Object&&(i.H=o,typeof(o=n[++s])=="function"&&(i.I=!0,M1??=o,U1??=n[s+1],o=n[s+=2]));let a={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;c<o.length;c++)a[o[c]]=o;o=n[++s]}for(c=1;o!==void 0;){let d;typeof o=="number"&&(c+=o,o=n[++s]);var l=void 0;if(o instanceof ro?d=o:(d=$_,s--),d?.j){o=n[++s],l=n;var h=s;typeof o=="function"&&(o=o(),l[h]=o),l=o}for(h=c+1,typeof(o=n[++s])=="number"&&o<0&&(h-=o,o=n[++s]);c<h;c++){let m=a[c];l?r(i,c,d,l,m):t(i,c,d,m)}}return n[e]=i}function N1(e){return Array.isArray(e)?e[0]instanceof ro?e:[G_,e]:[e,void 0]}function z1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function _u(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function wu(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(vu,_u,wu,n).A,s||=Su(n),i)}function Su(e){let t=e[x0];if(t!=null)return t;let r=Qn(vu,_u,wu,e);return t=r.I?(n,i)=>M1(n,i,r):(n,i)=>{let o=0|n[se];for(;A1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=q_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Za(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=x1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&$d(n,34),!0},e[x0]=t}function q_(e){let t=(e=N1(e))[0].g;if(e=e[1]){let r=Su(e),n=Qn(vu,_u,wu,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function Sc(e,t,r){e[t]=r.i}function kc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(wc,Sc,kc,n).A,i||=j1(n))}function j1(e){let t=e[A0];if(!t){let r=Qn(wc,Sc,kc,e);t=(n,i)=>V1(n,i,r),e[A0]=t}return t}function V1(e,t,r){for(var n=0|e[se],i=512&n?0:-1,o=e.length,s=512&n?1:0,a=o+(256&n?-1:0);s<a;s++){let c=e[s];if(c==null)continue;let l=s-i,h=T0(r,l);h&&h(t,c,l)}if(256&n){n=e[o-1];for(let c in n)i=+c,Number.isNaN(i)||(o=n[i])!=null&&(a=T0(r,i))&&a(t,o,i)}if(e=Xd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Wd(e[r])||new Uint8Array(0))}function T0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=N1(r))[0].i;if(r=r[1]){let i=j1(r),o=Qn(wc,Sc,kc,r).A;r=e.I?U1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function Ec(e,t){if(Array.isArray(t)){var r=0|t[se];if(4&r)return t;for(var n=0,i=0;n<t.length;n++){let o=e(t[n]);o!=null&&(t[i++]=o)}return i<n&&(t.length=i),ct(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function wt(e,t,r){return new ro(e,t,r)}function Cc(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function H1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(s1(64,n));if(eu(n)){if(i==="string")return c1(n);if(i==="number")return a1(n)}})(t),t!=null&&(typeof t=="string"&&C0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Vd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=C0(t),Xi(e.g,r.i,r.g)}}function W1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),yc(e.g,t))}function $1(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(kr(e,r,0),e.g.g.push(t?1:0))}function G1(e,t,r){(t=Sn(t))!=null&&_c(e,r,G0(t))}function q1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}function K1(e,t,r){(t=t==null||typeof t=="string"||hc(t)||t instanceof wn?t:void 0)!=null&&_c(e,r,hu(t).buffer)}var K_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=Nd(n);let i=Nd(n);n=2*(i>>31)+1;let o=i>>>20&2047;return e=4294967296*(1048575&i)+e,St(t,r,o==2047?e?NaN:n*(1/0):o==0?5e-324*n*e:n*Math.pow(2,o-1075)*(e+4503599627370496)),!0}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,1),e=e.g,(r=i1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),ic(e,De),ic(e,Ge))}),Er()),X1=wt((function(e,t,r){return e.i===5&&(St(t,r,zd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,o1(t),ic(e,De))}),O1),X_=Cc((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,zd,t):t.push(zd(e.g)),!0)}),(function(e,t,r){if((t=Ec(Qo,t))!=null&&t.length){kr(e,r,2),ts(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,o1(t[n]),ic(r,De)}}),O1),oc=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g,Zd)),!0)}),H1,D1),Dd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=du(e.g,Zd))===0?void 0:e),!0)}),H1,D1),J_=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g,Yd)),!0)}),(function(e,t,r){if((t=M_(t))!=null&&(typeof t=="string"&&E0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new jd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=E0(t),Xi(e.g,r.i,r.g)}}),Er()),En=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),W1,yu),ku=Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),yu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),W1,yu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,uu(e.g)),!0)}),$1,P1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=uu(e.g))===!1?void 0:e),!0)}),$1,P1),sr=Cc((function(e,t,r){return e.i===2&&(e=fu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=Ec(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&_c(n,i,G0(o))}}),gu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=fu(e))===""?void 0:e),!0)}),G1,gu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,fu(e)),!0)}),G1,gu),ar=(function(e,t,r=mu){return new ro(e,t,r)})((function(e,t,r,n,i){return e.i===2&&(n=qo(void 0,n,!0),es(t,0|t[se],r,!0).push(n),gc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)q1(e,t[o],r,n,i)})),ft=bu((function(e,t,r,n,i,o){return e.i===2&&(v1(t,0|t[se],o,r),gc(e,t=au(t,n,r),i),!0)}),q1),J1=wt((function(e,t,r){return e.i===2&&(St(t,r,T1(e)),!0)}),K1,B1),Y_=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g)>>>0)===0?void 0:e),!0)}),(function(e,t,r){t=(function(n){if(n==null)return n;if(typeof n=="string"&&n)n=+n;else if(typeof n!="number")return;return pc(n)?n>>>0:void 0})(t),t!=null&&t!=null&&(kr(e,r,0),ts(e.g,t))}),Er()),Jn=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),(function(e,t,r){(t=Xn(t))!=null&&(t=parseInt(t,10),kr(e,r,0),yc(e.g,t))}),L1),sc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function Y1(e,t){return(r,n)=>{if(Ja.length){let o=Ja.pop();o.o(n),Pd(o.g,r,n),r=o}else r=new class{constructor(o,s){if(k0.length){let a=k0.pop();Pd(a,o,s),o=a}else o=new class{constructor(a,c){this.i=null,this.m=!1,this.g=this.j=this.s=0,Pd(this,a,c)}clear(){this.i=null,this.m=!1,this.g=this.j=this.s=0,this.C=!1}}(o,s);this.g=o,this.j=this.g.g,this.i=this.m=-1,this.o(s)}o({G:o=!1}={}){this.G=o}}(r,n);try{let o=new e,s=o.l;Su(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Ja.length<100&&Ja.push(r)}return i}}var I0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=T1(e))===Zi()?void 0:e),!0)}),(function(e,t,r){if(t!=null){if(t instanceof Ue){let n=t.R;return void(n&&(t=n(t),t!=null&&_c(e,r,hu(t).buffer)))}if(Array.isArray(t))return}K1(e,t,r)}),B1)],Od,R0=globalThis.trustedTypes;function P0(e){Od===void 0&&(Od=(function(){let r=null;if(!R0)return r;try{let n=i=>i;r=R0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Od;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Z_(e,...t){if(t.length===0)return P0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return P0(r)}var Z1=[0,En,Jn,Wt,-1,ku,Jn,-1],Q_=class extends Ue{constructor(e){super(e)}},Q1=[0,Wt,Ze,Wt,Jn,-1,Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,j_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),L1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],e2=[0,Ze,-2],D0=class extends Ue{constructor(e){super(e)}},t2=[0],r2=[0,En,Wt,1,Wt,-3],n2=class extends Ue{constructor(e){super(e,2)}},xc={};xc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,t2,ft,Q1,ft,e2,ft,r2,ft,Z1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,ku],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var O0,B0=[0,Dd,-1,Ji,-3,Dd,ku,_n,Gi,Dd,-1,Ji,Gi,Ji,-2,_n],Eu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],L0=[0,Ze,1,Ko],F0=[0,Ze,sr,Ko],Cu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Cu.prototype.g=(O0=[-500,ar,[-500,_n,-1,sr,-3,[-2,xc,Wt],ar,I0,Gi,-1,L0,F0,ar,[0,_n,Ji],_n,B0,Gi,sr,987,sr],4,ar,[-500,Ze,-1,[-1,{}],998,Ze],ar,[-500,Ze,sr,-1,[-2,{},Wt],997,sr,-1],Gi,ar,[-500,Ze,sr,Ko,998,sr],sr,Gi,L0,F0,ar,[0,_n,-1,Ko],sr,-2,B0,_n,-1,Ji,[0,Ji,Y_],978,Ko,ar,I0],function(){let e=new class{constructor(){this.j=[],this.i=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let o=this.g;return this.g=[],o}}}};V1(this.l,e,Qn(wc,Sc,kc,O0)),to(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,n=r.length,i=0;for(let o=0;o<n;o++){let s=r[o];t.set(s,i),i+=s.length}return e.j=[t],t});var e3=class extends Ue{constructor(e){super(e)}},t3=class extends Ue{constructor(e){super(e)}g(){return cu(this,e3)}},r3=[0,ar,[0,En,X1,Ze,-1]],M0=class extends Ue{constructor(e){super(e)}},U0=class extends Ue{constructor(e){super(e)}},i2=[1,2,3,4,5],ac=class extends Ue{constructor(e){super(e)}g(){return g1(this)!=null}i(){return Sn(_r(this,2))!=null}},cc=class extends Ue{constructor(e){super(e)}},o2=class extends Ue{constructor(e){super(e)}},s2=[0,[0,J1,Ze,[0,En,oc,-1],[0,J_,oc]],Wt,[0,i2,ft,r2,ft,Q1,ft,Z1,ft,t2,ft,e2],Jn],n3=new sc(451755788,o2);xc[451755788]=[0,s2,[0,Ze,En,X1,sr,-1],K_];var N0=class extends Ue{constructor(e){super(e)}},a2=class extends Ue{constructor(e){super(e)}},i3=new sc(487277289,a2);xc[487277289]=[0,s2,[0,Wt,-1]];var o3=class extends Ue{constructor(e){super(e)}},s3=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,r3],oc]),z0=class extends Ue{constructor(e){super(e)}},a3=class extends Ue{constructor(e){super(e)}J(){let e=g1(this);return e??Zi()}},c3=class extends Ue{constructor(e){super(e)}},c2=[1,2],j0=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,c2,ft,[0,X_],ft,[0,J1],En,Ze],oc]);function l3(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!(function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")})(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function V0(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((r,n)=>{t.addEventListener("load",(()=>{r()}),!1),t.addEventListener("error",(i=>{n(i)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function ie(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.h.stringToNewUTF8(t)),e.h._free(t)}function H0(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let i=0;i<t.length;i++)n[i]=e.h.stringToNewUTF8(t[i]);t=e.h._malloc(4*n.length),e.h.HEAPU32.set(n,t>>2),r(t);for(let i of n)e.h._free(i);e.h._free(t)}function yn(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function Gn(e,t,r){let n=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(i,o,s)=>{o?(r(n,s),n=[]):n.push(i)}}var h3=(function(e){return class extends e{N(){this.h._registerModelResourcesGraphService()}}})(class{constructor(e,t){this.j=!0,this.h=e,this.g=null,this.i=0,this.m=typeof this.h._addIntToInputStream=="function",t!==void 0?this.h.canvas=t:l3()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.h._malloc(r);this.h.HEAPU8.set(e,n),t?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(e,t,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),ie(this,n||"input_audio",(o=>{ie(this,i=i||"audio_header",(s=>{this.h._configureAudio(o,s,e,t??0,r)}))}))}setAutoResizeCanvas(e){this.j=e}setAutoRenderToScreen(e){this.h._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.h.gpuOriginForWebTexturesIsBottomLeft=e}attachErrorListener(e){this.h.errorListener=e}attachEmptyPacketListener(e,t){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,i){let o=4*e.length;this.i!==o&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(o),this.i=o),this.h.HEAPF32.set(e,this.g/4),ie(this,n,(s=>{this.h._addAudioToInputStream(this.g,t,r,s,i)}))}addGpuBufferToStream(e,t,r){ie(this,t,(n=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");n?this.h._bindTextureToStream(n):this.h._bindTextureToCanvas();let i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);let[o,s]=e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height];!this.j||o===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=o,this.h.canvas.height=s);let[a,c]=[o,s];this.h._addBoundTextureToStream(n,a,c,r)}))}addBoolToStream(e,t,r){ie(this,t,(n=>{this.h._addBoolToInputStream(e,n,r)}))}addDoubleToStream(e,t,r){ie(this,t,(n=>{this.h._addDoubleToInputStream(e,n,r)}))}addFloatToStream(e,t,r){ie(this,t,(n=>{this.h._addFloatToInputStream(e,n,r)}))}addIntToStream(e,t,r){ie(this,t,(n=>{this.h._addIntToInputStream(e,n,r)}))}addUintToStream(e,t,r){ie(this,t,(n=>{this.h._addUintToInputStream(e,n,r)}))}addStringToStream(e,t,r){ie(this,t,(n=>{ie(this,e,(i=>{this.h._addStringToInputStream(i,n,r)}))}))}addStringRecordToStream(e,t,r){ie(this,t,(n=>{H0(this,Object.keys(e),(i=>{H0(this,Object.values(e),(o=>{this.h._addFlatHashMapToInputStream(i,o,Object.keys(e).length,n,r)}))}))}))}addProtoToStream(e,t,r,n){ie(this,r,(i=>{ie(this,t,(o=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputStream(s,e.length,o,i,n),this.h._free(s)}))}))}addEmptyPacketToStream(e,t){ie(this,e,(r=>{this.h._addEmptyPacketToInputStream(r,t)}))}addBoolVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.h._addBoolVectorEntry(i,o);this.h._addBoolVectorToInputStream(i,n,r)}))}addDoubleVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.h._addDoubleVectorEntry(i,o);this.h._addDoubleVectorToInputStream(i,n,r)}))}addFloatVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.h._addFloatVectorEntry(i,o);this.h._addFloatVectorToInputStream(i,n,r)}))}addIntVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.h._addIntVectorEntry(i,o);this.h._addIntVectorToInputStream(i,n,r)}))}addUintVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.h._addUintVectorEntry(i,o);this.h._addUintVectorToInputStream(i,n,r)}))}addStringVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let o of e)ie(this,o,(s=>{this.h._addStringVectorEntry(i,s)}));this.h._addStringVectorToInputStream(i,n,r)}))}addBoolToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addBoolToInputSidePacket(e,r)}))}addDoubleToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addDoubleToInputSidePacket(e,r)}))}addFloatToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addFloatToInputSidePacket(e,r)}))}addIntToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addIntToInputSidePacket(e,r)}))}addUintToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addUintToInputSidePacket(e,r)}))}addStringToInputSidePacket(e,t){ie(this,t,(r=>{ie(this,e,(n=>{this.h._addStringToInputSidePacket(n,r)}))}))}addProtoToInputSidePacket(e,t,r){ie(this,r,(n=>{ie(this,t,(i=>{let o=this.h._malloc(e.length);this.h.HEAPU8.set(e,o),this.h._addProtoToInputSidePacket(o,e.length,i,n),this.h._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let i of e)this.h._addBoolVectorEntry(n,i);this.h._addBoolVectorToInputSidePacket(n,r)}))}addDoubleVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let i of e)this.h._addDoubleVectorEntry(n,i);this.h._addDoubleVectorToInputSidePacket(n,r)}))}addFloatVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let i of e)this.h._addFloatVectorEntry(n,i);this.h._addFloatVectorToInputSidePacket(n,r)}))}addIntVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let i of e)this.h._addIntVectorEntry(n,i);this.h._addIntVectorToInputSidePacket(n,r)}))}addUintVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let i of e)this.h._addUintVectorEntry(n,i);this.h._addUintVectorToInputSidePacket(n,r)}))}addStringVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let i of e)ie(this,i,(o=>{this.h._addStringVectorEntry(n,o)}));this.h._addStringVectorToInputSidePacket(n,r)}))}attachBoolListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachBoolListener(r)}))}attachBoolVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachBoolVectorListener(r)}))}attachIntListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachIntListener(r)}))}attachIntVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachIntVectorListener(r)}))}attachUintListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachUintListener(r)}))}attachUintVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachUintVectorListener(r)}))}attachDoubleListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleListener(r)}))}attachDoubleVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleVectorListener(r)}))}attachFloatListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachFloatListener(r)}))}attachFloatVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachFloatVectorListener(r)}))}attachStringListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachStringListener(r)}))}attachStringVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachStringVectorListener(r)}))}attachProtoListener(e,t,r){yn(this,e,t),ie(this,e,(n=>{this.h._attachProtoListener(n,r||!1)}))}attachProtoVectorListener(e,t,r){Gn(this,e,t),ie(this,e,(n=>{this.h._attachProtoVectorListener(n,r||!1)}))}attachAudioListener(e,t,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),yn(this,e,((n,i)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,i)})),ie(this,e,(n=>{this.h._attachAudioListener(n,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),l2=class extends h3{};async function d3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await V0(i),!self.ModuleFactory||o&&(await V0(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((i=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new n(s,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:n=>n.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&n.endsWith(".data")?t.assetBinaryPath.toString():n}),await e.o(r),e}async function h2(e,t,r){return d3(e,t,r)}function Bd(e,t){let r=wr(e.baseOptions,ac,1)||new ac;typeof t=="string"?(pt(r,2,nc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,r1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function d2(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(wr(e.baseOptions,ac,1)?.g()||wr(e.baseOptions,ac,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(n,i){let o=wr(n.baseOptions,U0,3);if(!o){var s=o=new U0;Rd(s,4,new D0)}"delegate"in i&&(i.delegate==="GPU"?Rd(i=o,2,s=new Q_):Rd(i=o,4,s=new D0)),Sr(n.baseOptions,0,3,o)})(e,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then((n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)})).then((n=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Bd(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Bd(e,r.modelAssetBuffer);else if(r.modelAssetBuffer)return(async function(n){let i=[];for(var o=0;;){let{done:s,value:a}=await n.read();if(s)break;i.push(a),o+=a.length}if(i.length===0)return new Uint8Array(0);if(i.length===1)return i[0];n=new Uint8Array(o),o=0;for(let s of i)n.set(s,o),o+=s.length;return n})(r.modelAssetBuffer).then((n=>{Bd(e,n),e.v()}));return e.v(),Promise.resolve()}function W0(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.j.map((r=>r.message)).join(", "))}finally{e.j=[]}}function qi(e,t){e.s=Math.max(e.s,t)}var Qa=class{constructor(e){this.g=e,this.j=[],this.s=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener(((r,n)=>{this.j.push(Error(n))})),this.g.N(),this.g.setGraph(e,t),W0(this)}finishProcessing(){this.g.finishProcessing(),W0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return h2(e,t,r)}Qa.prototype.close=Qa.prototype.close,(function(e,t){e=e.split(".");var r,n=Kn;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t})("TaskRunner",Qa);var lc=class extends Qa{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function u3(e){let t={classifications:cu(e,o3).map((r=>(function(n,i=-1,o=""){return{categories:n.map((s=>{var a=Xn(_r(s,1))??0??-1;let c=s.l,l=0|c[se],h=Zn(c,l,2),d=Qo(h);return d!=null&&d!==h&<(c,l,2,d),{index:a,score:d??0??0,categoryName:Sn(_r(s,3))??""??"",displayName:Sn(_r(s,4))??""??""}})),headIndex:i,headName:o}})(wr(r,t3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return Ud(_r(e,2))!=null&&(t.timestampMs=Ud(_r(e,2))??0),t}lc.prototype.setDefaultSampleRate=lc.prototype.O;var or=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new o2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,M0,2);if(r=r?m1(r):new M0,e.displayNamesLocale!==void 0?pt(r,1,nc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!pc(n))throw p0();n|=0}pt(r,2,n)}else"maxResults"in e&&pt(r,2);if(e.scoreThreshold!==void 0){if((n=e.scoreThreshold)!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);pt(r,3,n)}else"scoreThreshold"in e&&pt(r,3);return e.categoryAllowlist!==void 0?S0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?S0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),d2(this,e)}K(e,t){return this.D(e,t??this.F,this.s+1)}D(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),[...this.m]}v(){var e=new Cu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new n2;I1(t,n3,this.i);let r=new Eu;b1(r,nc("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.o(t),S1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=s3(a),o.m.push(u3(a))}))})(this,n),qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_classifications",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function $0(e){return{embeddings:cu(e,c3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(_1(t,z0,Id(t,1))!==void 0)r.floatEmbedding=y1(wr(t,z0,Id(t,1)),1,Qo,n1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,a3,Id(t,2))?.J()?.i()??n}return r})),timestampMs:Ud(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return h2(or,e,{baseOptions:{modelAssetPath:t}})},or.createFromModelBuffer=function(e,t){return Xo(or,e,{baseOptions:{modelAssetBuffer:t}})},or.createFromOptions=function(e,t){return Xo(or,e,t)};var Fr=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new a2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,N0,2);return r=r?m1(r):new N0,e.l2Normalize!==void 0?pt(r,1,_0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,_0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),d2(this,e)}L(e,t){return this.D(e,t??this.F,this.s+1)}D(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),this.m}v(){var e=new Cu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new n2;I1(t,i3,this.i);let r=new Eu;b1(r,nc("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"EMBEDDINGS:embeddings_out"),Ot(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.o(t),S1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=j0(n),this.m.push($0(n)),qi(this,i)})),this.g.attachEmptyPacketListener("embeddings_out",(n=>{qi(this,n)})),this.g.attachProtoVectorListener("timestamped_embeddings_out",((n,i)=>{for(let o of n)n=j0(o),this.m.push($0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ya;Fr.prototype.embed=Fr.prototype.L,Fr.prototype.setOptions=Fr.prototype.o,Fr.createFromModelPath=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetPath:t}})},Fr.createFromModelBuffer=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetBuffer:t}})},Fr.createFromOptions=function(e,t){return Xo(Fr,e,t)};var f3=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function u2(){if(Ya===void 0)try{await WebAssembly.instantiate(f3),Ya=!0}catch{Ya=!1}return Ya}async function Wo(e,t=Z_``){let r=await u2()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var bn=class{};bn.forVisionTasks=function(e){return Wo("vision",e)},bn.forTextTasks=function(e){return Wo("text",e)},bn.forGenAiExperimentalTasks=function(e){return Wo("genai_experimental",e)},bn.forGenAiTasks=function(e){return Wo("genai",e)},bn.forAudioTasks=function(e){return Wo("audio",e)},bn.isSimdSupported=function(){return u2()};function p3(e,t){let r=e.reduce((a,c)=>a+c.length,0),n=new ArrayBuffer(44+r*2),i=new DataView(n),o=(a,c,l)=>{for(let h=0;h<l.length;h++)a.setUint8(c+h,l.charCodeAt(h))};o(i,0,"RIFF"),i.setUint32(4,36+r*2,!0),o(i,8,"WAVE"),o(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),o(i,36,"data"),i.setUint32(40,r*2,!0);let s=44;for(let a of e)for(let c=0;c<a.length;c++){let l=Math.max(-1,Math.min(1,a[c]));i.setInt16(s,l<0?l*32768:l*32767,!0),s+=2}return new Blob([i],{type:"audio/wav"})}var Ac=class{constructor(t,r,n,i,o,s,a){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.preRollBuffer=[];this.recordingChunks=[];this.PRE_ROLL_SECONDS=2;this.SAMPLE_RATE=16e3;this.MAX_PRE_ROLL_CHUNKS=4;this.lastNoiseTime=0;this.SILENCE_THRESHOLD=3e3;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=n,this.cameraRecorder=i,this.onRealtimeAlertsCallback=o,this.backend=s,this.backendToken=a}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Jr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new Ga(void 0,this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),200),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter&&this.volumeMeter.stop(),this.audioWorkletNode&&this.audioWorkletNode.disconnect()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.paramsConfig.audioBehaviourParameters?.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t*1.25);let n=r>=t;if(n&&(this.lastNoiseTime=Date.now()),n&&!this.recordingInProgress){this.recordingInProgress=!0,this.recordingChunks=[...this.preRollBuffer];let o=this.preRollBuffer.reduce((a,c)=>a+c.length,0)/this.SAMPLE_RATE*1e3,s=Date.now()-this.examStartTime;this.recordingStartTime=s-o,this.recordingStartTime<0&&(this.recordingStartTime=0)}else if(this.recordingInProgress){let i=Date.now()-this.lastNoiseTime,o=Date.now()-this.recordingStartTime;i>=this.SILENCE_THRESHOLD&&o>=3e3&&this.countLoopTimes>4&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&!this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Barulho detectado",type:"audio_detection_on_stream"}),this.paramsConfig.videoBehaviourParameters?.detectSpeech&&this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Fala detectada",type:"audio_detection_on_stream"}),this.recordingInProgress=!1,this.recordIndex++,this.countLoopTimes=0,this.isSpeech=!1),this.countLoopTimes++}}async stopSoundRecord(){if(!this.recordingInProgress&&this.recordingChunks.length===0||(this.recordingEndTime=Date.now()-this.examStartTime,this.optionsProctoring.proctoringType!=="REALTIME"))return;let t=p3(this.recordingChunks,this.SAMPLE_RATE),r=new File([t],`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.wav`,{type:"audio/wav"});this.uploadRecord(r),this.recordingChunks=[],this.recordingInProgress=!1}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}uploadRecord(t){t&&this.upload&&this.backendToken&&this.upload.upload({file:t},this.backendToken)}hasDesiredResult(t){if(t==null)return!1;for(let r of t){let n=r.name.toLowerCase().includes("speech");if(this.optionsProctoring.proctoringType!=="REALTIME")return n;let i=parseFloat(r.score)>.22;if(n&&i)return!0}return!1}async createAudioClassifier(){let t=await bn.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await or.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){this.context=new AudioContext({sampleRate:this.SAMPLE_RATE});try{await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([m3],{type:"text/javascript"})))}catch{throw new Error("\u274C Error loading audio worklet module")}let t=this.context.createMediaStreamSource(this.cameraRecorder.cameraStream);this.audioWorkletNode=new AudioWorkletNode(this.context,"audio-processor"),this.audioWorkletNode.port.onmessage=r=>{let n=r.data;this.preRollBuffer.push(n),this.preRollBuffer.length>this.MAX_PRE_ROLL_CHUNKS&&this.preRollBuffer.shift(),this.recordingInProgress&&this.recordingChunks.push(n);let o=this.audioClassifier.classify(n)[0].classifications[0].categories;o.length>0&&(this.audioClassificationResult=[{name:o[0].categoryName,score:o[0].score.toFixed(3)}])},t.connect(this.audioWorkletNode),this.audioWorkletNode.connect(this.context.destination)}},m3=`
|
|
435
|
+
Size: ${t.file.size}`,s),o}}throw new Error("Could not upload")}};var $a=class{constructor(t,r){this.alerts=[];this.lastActivityTime=Date.now();this.IDLE_THRESHOLD_MS=3e4;this.handleVisibilityChange=()=>{document.visibilityState==="visible"?this.handleReturnFocus():this.handleLostFocus()};this.handleLostFocus=()=>{if(this.getRelativeTime()>1e4){let t={begin:this.getRelativeTime(),end:0,alert:25,type:3};this.onLostFocusCallback(t),this.alerts.push(t)}};this.handleReturnFocus=()=>{let t=this.alerts[this.alerts.length-1];t&&(this.onFocusCallback({begin:t.begin,end:this.getRelativeTime(),alert:25,type:3}),t.end=this.getRelativeTime())};this.handleResize=()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{let t=window.screen.availWidth,r=window.outerWidth;if(r<t*.85){let n=`Split Screen Detectado: Janela ocupa ${(r/t*100).toFixed(0)}% da tela`;this.createAlert(43,3,n),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:n,type:"split_screen"})}},1e3)};this.handleUserActivity=t=>{this.lastActivityTime=Date.now(),console.log("\u{1F449} handleUserActivity",t)};this.handleCopy=t=>{t.preventDefault();let r="Tentativa de Copiar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_copy"})};this.handleCut=t=>{t.preventDefault();let r="Tentativa de Recortar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_cut"})};this.handlePaste=t=>{t.preventDefault();let r="Tentativa de Colar (Clipboard)";this.createAlert(42,3,r),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:r,type:"clipboard_paste"})};this.onLostFocusCallback=t.onLostFocusCallback,this.onFocusCallback=t.onFocusCallback,this.onRealtimeAlertCallback=t.onRealtimeAlertCallback,this.optionsProctoring=r}async startRecording(){this.startTime=new Date(Date.now()),this.alerts=[],this.attachListeners()}async pauseRecording(){this.detachListeners()}async resumeRecording(){this.attachListeners()}async stopRecording(){this.detachListeners()}async saveOnSession(t){this.alerts.forEach(r=>{t.addAlert(r)})}attachListeners(){this.optionsProctoring.captureScreen&&(window.addEventListener("visibilitychange",this.handleVisibilityChange),window.addEventListener("resize",this.handleResize),window.document.addEventListener("copy",this.handleCopy),window.document.addEventListener("cut",this.handleCut),window.document.addEventListener("paste",this.handlePaste))}detachListeners(){window.removeEventListener("visibilitychange",this.handleVisibilityChange),window.removeEventListener("resize",this.handleResize),window.document.removeEventListener("copy",this.handleCopy),window.document.removeEventListener("cut",this.handleCut),window.document.removeEventListener("paste",this.handlePaste)}addBackgroundEvent(t,r=200){this.createAlert(r,3,t),this.onRealtimeAlertCallback&&this.onRealtimeAlertCallback({status:"ALERT",description:t,type:"background_event"})}getRelativeTime(){return Date.now()-this.startTime.getTime()}createAlert(t,r,n){this.alerts.push({begin:this.getRelativeTime(),end:this.getRelativeTime(),alert:t,type:r})}addAlert({alert:t,type:r}){this.alerts.push({begin:Date.now()-this.startTime.getTime(),end:Date.now()-this.startTime.getTime(),alert:t,type:r})}};var Ga=class{constructor(t,r){this.blobs=[];this.options={cameraId:void 0,microphoneId:void 0};this.audioParams={recordingBitrate:128};r&&(this.audioParams=r),t&&(this.options=t)}async startRecording(){let t={audio:{deviceId:this.options.microphoneId||"default"}};this.audioStream=await navigator.mediaDevices.getUserMedia(t);let{startRecording:r,stopRecording:n,pauseRecording:i,resumeRecording:o}=Wn(this.audioStream,this.blobs,void 0,void 0,!0);this.recordingStart=r,this.recordingStop=n,this.recordingPause=i,this.recordingResume=o,this.recordingStart()}async pauseRecording(){}async resumeRecording(){}async stopRecording(){this.recordingStop&&await this.recordingStop()}async saveOnSession(t,r,n){t.addRecording({device:"",file:new File(this.blobs,`EP_${t.id}_audio_${r&&n&&`${r}_${n}`||"0"}.webm`,{type:"audio/webm"}),origin:"Mic"})}};var Kn=typeof self<"u"?self:{};function $n(){throw Error("Invalid UTF8")}function l0(e,t){return t=String.fromCharCode.apply(null,t),e==null?t:e+t}var qa,Cd,y_=typeof TextDecoder<"u",b_,v_=typeof TextEncoder<"u";function G0(e){if(v_)e=(b_||=new TextEncoder).encode(e);else{let r=0,n=new Uint8Array(3*e.length);for(let i=0;i<e.length;i++){var t=e.charCodeAt(i);if(t<128)n[r++]=t;else{if(t<2048)n[r++]=t>>6|192;else{if(t>=55296&&t<=57343){if(t<=56319&&i<e.length){let o=e.charCodeAt(++i);if(o>=56320&&o<=57343){t=1024*(t-55296)+o-56320+65536,n[r++]=t>>18|240,n[r++]=t>>12&63|128,n[r++]=t>>6&63|128,n[r++]=63&t|128;continue}i--}t=65533}n[r++]=t>>12|224,n[r++]=t>>6&63|128}n[r++]=63&t|128}}e=r===n.length?n:n.subarray(0,r)}return e}var Hd,ec;e:{for(xd=["CLOSURE_FLAGS"],Ka=Kn,Xa=0;Xa<xd.length;Xa++)if((Ka=Ka[xd[Xa]])==null){ec=null;break e}ec=Ka}var xd,Ka,Xa,Jo,h0=ec&&ec[610401301];Hd=h0!=null&&h0;var d0=Kn.navigator;function Ld(e){return!!Hd&&!!Jo&&Jo.brands.some((({brand:t})=>t&&t.indexOf(e)!=-1))}function cr(e){var t;return(t=Kn.navigator)&&(t=t.userAgent)||(t=""),t.indexOf(e)!=-1}function vn(){return!!Hd&&!!Jo&&Jo.brands.length>0}function Ad(){return vn()?Ld("Chromium"):(cr("Chrome")||cr("CriOS"))&&!(!vn()&&cr("Edge"))||cr("Silk")}Jo=d0&&d0.userAgentData||null;var __=!vn()&&(cr("Trident")||cr("MSIE"));!cr("Android")||Ad(),Ad(),cr("Safari")&&(Ad()||!vn()&&cr("Coast")||!vn()&&cr("Opera")||!vn()&&cr("Edge")||(vn()?Ld("Microsoft Edge"):cr("Edg/"))||vn()&&Ld("Opera"));var q0={},$o=null;function w_(e){let t=e.length,r=3*t/4;r%3?r=Math.floor(r):"=.".indexOf(e[t-1])!=-1&&(r="=.".indexOf(e[t-2])!=-1?r-2:r-1);let n=new Uint8Array(r),i=0;return(function(o,s){function a(l){for(;c<o.length;){let h=o.charAt(c++),d=$o[h];if(d!=null)return d;if(!/^[\s\xa0]*$/.test(h))throw Error("Unknown base64 encoding at char: "+h)}return l}K0();let c=0;for(;;){let l=a(-1),h=a(0),d=a(64),m=a(64);if(m===64&&l===-1)break;s(l<<2|h>>4),d!=64&&(s(h<<4&240|d>>2),m!=64&&s(d<<6&192|m))}})(e,(function(o){n[i++]=o})),i!==r?n.subarray(0,i):n}function K0(){if(!$o){$o={};var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=e.concat(t[r].split(""));q0[r]=n;for(let i=0;i<n.length;i++){let o=n[i];$o[o]===void 0&&($o[o]=i)}}}}var X0=typeof Uint8Array<"u",J0=!__&&typeof btoa=="function";function u0(e){if(!J0){var t;t===void 0&&(t=0),K0(),t=q0[t];var r=Array(Math.floor(e.length/3)),n=t[64]||"";let c=0,l=0;for(;c<e.length-2;c+=3){var i=e[c],o=e[c+1],s=e[c+2],a=t[i>>2];i=t[(3&i)<<4|o>>4],o=t[(15&o)<<2|s>>6],s=t[63&s],r[l++]=a+i+o+s}switch(a=0,s=n,e.length-c){case 2:s=t[(15&(a=e[c+1]))<<2]||n;case 1:e=e[c],r[l]=t[e>>2]+t[(3&e)<<4|a>>4]+s+n}return r.join("")}for(t="",r=0,n=e.length-10240;r<n;)t+=String.fromCharCode.apply(null,e.subarray(r,r+=10240));return t+=String.fromCharCode.apply(null,r?e.subarray(r):e),btoa(t)}var f0=/[-_.]/g,S_={"-":"+",_:"/",".":"="};function k_(e){return S_[e]||""}function Y0(e){if(!J0)return w_(e);f0.test(e)&&(e=e.replace(f0,k_)),e=atob(e);let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function hc(e){return X0&&e!=null&&e instanceof Uint8Array}var Yi={};function Zi(){return E_||=new wn(null,Yi)}function Wd(e){Z0(Yi);var t=e.g;return(t=t==null||hc(t)?t:typeof t=="string"?Y0(t):null)==null?t:e.g=t}var wn=class{i(){return new Uint8Array(Wd(this)||0)}constructor(e,t){if(Z0(t),this.g=e,e!=null&&e.length===0)throw Error("ByteString should be constructed with non-empty values")}},E_,C_;function Z0(e){if(e!==Yi)throw Error("illegal external caller")}function Q0(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function p0(){let e=Error("int32");return Q0(e,"warning"),e}var dc=typeof Symbol=="function"&&typeof Symbol()=="symbol",x_=new Set;function uc(e,t,r=!1,n=!1){return e=typeof Symbol=="function"&&typeof Symbol()=="symbol"?n&&Symbol.for&&e?Symbol.for(e):e!=null?Symbol(e):Symbol():t,r&&x_.add(e),e}var A_=uc("jas",void 0,!0,!0),Td=uc(void 0,"2ex"),Ho=uc(void 0,"1oa",!0),Qi=uc(void 0,Symbol(),!0),se=dc?A_:"M",e1={M:{value:0,configurable:!0,writable:!0,enumerable:!1}},t1=Object.defineProperties;function $d(e,t){dc||se in e||t1(e,e1),e[se]|=t}function ct(e,t){dc||se in e||t1(e,e1),e[se]=t}function T_(e,t){ct(t,-30975&(0|e))}function Fd(e,t){ct(t,-30941&(34|e))}function Gd(){return typeof BigInt=="function"}function lr(e){return Array.prototype.slice.call(e)}var qd,Zo={},I_={};function m0(e){return!(!e||typeof e!="object"||e.g!==I_)}function Kd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&e.constructor===Object}function r1(e,t){if(e!=null){if(typeof e=="string")e=e?new wn(e,Yi):Zi();else if(e.constructor!==wn)if(hc(e))e=e.length?new wn(new Uint8Array(e),Yi):Zi();else{if(!t)throw Error();e=void 0}}return e}function tc(e){return!(!Array.isArray(e)||e.length)&&!!(1&(0|e[se]))}var g0=[];function Yn(e){if(2&e)throw Error()}function Xd(e){return Qi?e[Qi]:void 0}ct(g0,55),qd=Object.freeze(g0);var n1=Object.freeze({}),Jd=typeof Kn.BigInt=="function"&&typeof Kn.BigInt(0)=="bigint",Md=e=>Jd?e>=P_&&e<=O_:e[0]==="-"?y0(e,R_):y0(e,D_),R_=Number.MIN_SAFE_INTEGER.toString(),P_=Jd?BigInt(Number.MIN_SAFE_INTEGER):void 0,D_=Number.MAX_SAFE_INTEGER.toString(),O_=Jd?BigInt(Number.MAX_SAFE_INTEGER):void 0;function y0(e,t){if(e.length>t.length)return!1;if(e.length<t.length||e===t)return!0;for(let r=0;r<e.length;r++){let n=e[r],i=t[r];if(n>i)return!1;if(n<i)return!0}}var B_=typeof Uint8Array.prototype.slice=="function",i1,De=0,Ge=0;function b0(e){let t=e>>>0;De=t,Ge=(e-t)/4294967296>>>0}function eo(e){if(e<0){b0(-e);let[t,r]=Qd(De,Ge);De=t>>>0,Ge=r>>>0}else b0(e)}function o1(e){let t=i1||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),Ge=0,De=t.getUint32(0,!0)}function Yd(e,t){let r=4294967296*t+(e>>>0);return Number.isSafeInteger(r)?r:Yo(e,t)}function Zd(e,t){let r=2147483648&t;return r&&(t=~t>>>0,(e=1+~e>>>0)==0&&(t=t+1>>>0)),typeof(e=Yd(e,t))=="number"?r?-e:e:r?"-"+e:e}function Yo(e,t){if(e>>>=0,(t>>>=0)<=2097151)var r=""+(4294967296*t+e);else Gd()?r=""+(BigInt(t)<<BigInt(32)|BigInt(e)):(e=(16777215&e)+6777216*(r=16777215&(e>>>24|t<<8))+6710656*(t=t>>16&65535),r+=8147497*t,t*=2,e>=1e7&&(r+=e/1e7>>>0,e%=1e7),r>=1e7&&(t+=r/1e7>>>0,r%=1e7),r=t+v0(r)+v0(e));return r}function v0(e){return e=String(e),"0000000".slice(e.length)+e}function fc(e){if(e.length<16)eo(Number(e));else if(Gd())e=BigInt(e),De=Number(e&BigInt(4294967295))>>>0,Ge=Number(e>>BigInt(32)&BigInt(4294967295));else{let t=+(e[0]==="-");Ge=De=0;let r=e.length;for(let n=t,i=(r-t)%6+t;i<=r;n=i,i+=6){let o=Number(e.slice(n,i));Ge*=1e6,De=1e6*De+o,De>=4294967296&&(Ge+=Math.trunc(De/4294967296),Ge>>>=0,De>>>=0)}if(t){let[n,i]=Qd(De,Ge);De=n,Ge=i}}}function Qd(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}var s1=typeof BigInt=="function"?BigInt.asIntN:void 0,L_=typeof BigInt=="function"?BigInt.asUintN:void 0,Go=Number.isSafeInteger,pc=Number.isFinite,rc=Math.trunc;function Qo(e){return e==null||typeof e=="number"?e:e==="NaN"||e==="Infinity"||e==="-Infinity"?Number(e):void 0}function _0(e){if(e!=null&&typeof e!="boolean"){var t=typeof e;throw Error(`Expected boolean but got ${t!="object"?t:e?Array.isArray(e)?"array":t:"null"}: ${e}`)}return e}var F_=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function eu(e){switch(typeof e){case"bigint":return!0;case"number":return pc(e);case"string":return F_.test(e);default:return!1}}function Xn(e){if(e==null)return e;if(typeof e=="string"&&e)e=+e;else if(typeof e!="number")return;return pc(e)?0|e:void 0}function w0(e){if(e[0]==="-")return!1;let t=e.length;return t<20||t===20&&Number(e.substring(0,6))<184467}function a1(e){return e=rc(e),Go(e)||(eo(e),e=Zd(De,Ge)),e}function c1(e){var t=rc(Number(e));if(Go(t))return String(t);if((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),t=e.length,!(e[0]==="-"?t<20||t===20&&Number(e.substring(0,7))>-922337:t<19||t===19&&Number(e.substring(0,6))<922337))if(fc(e),e=De,2147483648&(t=Ge))if(Gd())e=""+(BigInt(0|t)<<BigInt(32)|BigInt(e>>>0));else{let[r,n]=Qd(e,t);e="-"+Yo(r,n)}else e=Yo(e,t);return e}function Ud(e){return e==null?e:typeof e=="bigint"?(Md(e)?e=Number(e):(e=s1(64,e),e=Md(e)?Number(e):String(e)),e):eu(e)?typeof e=="number"?a1(e):c1(e):void 0}function M_(e){if(e==null)return e;var t=typeof e;if(t==="bigint")return String(L_(64,e));if(eu(e)){if(t==="string")return t=rc(Number(e)),Go(t)&&t>=0?e=String(t):((t=e.indexOf("."))!==-1&&(e=e.substring(0,t)),w0(e)||(fc(e),e=Yo(De,Ge))),e;if(t==="number")return(e=rc(e))>=0&&Go(e)?e:(function(r){if(r<0){eo(r);var n=Yo(De,Ge);return r=Number(n),Go(r)?r:n}return w0(n=String(r))?n:(eo(r),Yd(De,Ge))})(e)}}function l1(e){if(typeof e!="string")throw Error();return e}function nc(e){if(e!=null&&typeof e!="string")throw Error();return e}function Sn(e){return e==null||typeof e=="string"?e:void 0}function h1(e,t,r){if(e!=null&&typeof e=="object"&&e.B===Zo)return e;if(Array.isArray(e)){var n=0|e[se],i=n;return i===0&&(i|=32&r),(i|=2&r)!==n&&ct(e,i),new t(e)}}function d1(e,t,r,n,i){if(e!=null){if(Array.isArray(e))e=tc(e)?void 0:i&&2&(0|e[se])?e:tu(e,t,r,n!==void 0,i);else if(Kd(e)){let o={};for(let s in e)o[s]=d1(e[s],t,r,n,i);e=o}else e=t(e,n);return e}}function tu(e,t,r,n,i){let o=n||r?0|e[se]:0,s=n?!!(32&o):void 0;n=lr(e);for(let a=0;a<n.length;a++)n[a]=d1(n[a],t,r,s,i);return r&&((e=Xd(e))&&(n[Qi]=lr(e)),r(o,n)),n}function U_(e){return e.B===Zo?e.toJSON():(function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return Md(t)?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(tc(t))return}else{if(hc(t))return u0(t);if(t instanceof wn){let r=t.g;return r==null?"":typeof r=="string"?r:t.g=u0(r)}}}return t})(e)}function N_(e){return tu(e,U_,void 0,void 0,!1)}var u1,z_;function qo(e,t,r){return e=f1(e,t[0],t[1],r?1:2),t!==u1&&r&&$d(e,16384),e}function f1(e,t,r,n){if(e==null){var i=96;r?(e=[r],i|=512):e=[],t&&(i=-33521665&i|(1023&t)<<15)}else{if(!Array.isArray(e))throw Error("narr");if(2048&(i=0|e[se]))throw Error("farr");if(64&i)return e;if(n===1||n===2||(i|=64),r&&(i|=512,r!==e[0]))throw Error("mid");e:{if(n=(r=e).length){let o=n-1;if(Kd(r[o])){if((t=o-(512&(i|=256)?0:-1))>=1024)throw Error("pvtlmt");i=-33521665&i|(1023&t)<<15;break e}}if(t){if((t=Math.max(t,n-(512&i?0:-1)))>1024)throw Error("spvt");i=-33521665&i|(1023&t)<<15}}}return ct(e,i),e}function p1(e,t,r=Fd){if(e!=null){if(X0&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){var n=0|e[se];return 2&n?e:(t&&=n===0||!!(32&n)&&!(64&n||!(16&n)),t?(ct(e,-12293&(34|n)),e):tu(e,p1,4&n?Fd:r,!0,!0))}return e.B===Zo&&(e=2&(n=0|(r=e.l)[se])?e:new e.constructor(mc(r,n,!0))),e}}function m1(e){let t=e.l;return new e.constructor(mc(t,0|t[se],!1))}function mc(e,t,r){let n=r||2&t?Fd:T_,i=!!(32&t);return e=(function(o,s,a){let c=lr(o);var l=c.length;let h=256&s?c[l-1]:void 0;for(l+=h?-1:0,s=512&s?1:0;s<l;s++)c[s]=a(c[s]);if(h){s=c[s]={};for(let d in h)s[d]=a(h[d])}return(o=Xd(o))&&(c[Qi]=lr(o)),c})(e,t,(o=>p1(o,i,n))),$d(e,32|(r?2:0)),e}function ru(e){let t=e.l,r=0|t[se];return 2&r?new e.constructor(mc(t,r,!1)):e}function _r(e,t){return Zn(e=e.l,0|e[se],t)}function Zn(e,t,r,n){if(r===-1)return null;var i=r+(512&t?0:-1);let o=e.length-1;return i>=o&&256&t?e[o][r]:n&&256&t&&(t=e[o][r])!=null?(e[i]!=null&&Td!=null&&((i=(e=C_??={})[Td]||0)>=4||(e[Td]=i+1,Q0(e=Error(),"incident"),(function(s){Kn.setTimeout((()=>{throw s}),0)})(e))),t):i<=o?e[i]:void 0}function pt(e,t,r){let n=e.l,i=0|n[se];return Yn(i),lt(n,i,t,r),e}function lt(e,t,r,n){let i=512&t?0:-1,o=r+i;var s=e.length-1;return o>=s&&256&t?(e[s][r]=n,t):o<=s?(e[o]=n,256&t&&r in(e=e[s])&&delete e[r],t):(n!==void 0&&(r>=(s=t>>15&1023||536870912)?n!=null&&(e[s+i]={[r]:n},ct(e,t|=256)):e[o]=n),t)}function g1(e){let t=0|(e=e.l)[se],r=Zn(e,t,1),n=r1(r,!0);return n!=null&&n!==r&<(e,t,1,n),n}function y1(e,t,r,n,i){let o=e.l,s=2&(e=0|o[se])?1:n;i=!!i;let a=0|(n=nu(o,e,t))[se];if(!(4&a)){4&a&&(n=lr(n),a=Qr(a,e),e=lt(o,e,t,n));let c=0,l=0;for(;c<n.length;c++){let h=r(n[c]);h!=null&&(n[l++]=h)}l<c&&(n.length=l),a=iu(a,e),r=-4097&(20|a),a=r&=-8193,ct(n,a),2&a&&Object.freeze(n)}return s===1||s===4&&32&a?Zr(a)||(i=a,a|=2,a!==i&&ct(n,a),Object.freeze(n)):(s===2&&Zr(a)&&(n=lr(n),a=Qr(a,e),a=kn(a,e,i),ct(n,a),e=lt(o,e,t,n)),Zr(a)||(t=a,a=kn(a,e,i),a!==t&&ct(n,a))),n}function nu(e,t,r,n){return e=Zn(e,t,r,n),Array.isArray(e)?e:qd}function iu(e,t){return e===0&&(e=Qr(e,t)),1|e}function Zr(e){return!!(2&e)&&!!(4&e)||!!(2048&e)}function S0(e,t,r){let n=0|(e=e.l)[se];if(Yn(n),r==null)lt(e,n,t);else{var i=0|r[se],o=i,s=Zr(i),a=s||Object.isFrozen(r);for(s||(i=0),a||(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),i|=21,s=0;s<r.length;s++){let c=r[s],l=l1(c);Object.is(c,l)||(a&&(r=lr(r),o=0,i=kn(i=Qr(i,n),n,!0),a=!1),r[s]=l)}i!==o&&(a&&(r=lr(r),i=kn(i=Qr(i,n),n,!0)),ct(r,i)),lt(e,n,t,r)}}function b1(e,t){let r=0|(e=e.l)[se];Yn(r),lt(e,r,2,t===""?void 0:t)}function es(e,t,r,n,i){Yn(t);var o=!(!(64&t)&&16384&t);let s=(i=nu(e,t,r,i))!==qd;if(o||!s){let a=o=s?0|i[se]:0;(!s||2&a||Zr(a)||4&a&&!(32&a))&&(i=lr(i),a=Qr(a,t),t=lt(e,t,r,i)),a=-13&iu(a,t),a=kn(n?-17&a:16|a,t,!0),a!==o&&ct(i,a)}return i}function Id(e,t){var r=c2;return su(ou(e=e.l),e,0|e[se],r)===t?t:-1}function ou(e){if(dc)return e[Ho]??(e[Ho]=new Map);if(Ho in e)return e[Ho];let t=new Map;return Object.defineProperty(e,Ho,{value:t}),t}function v1(e,t,r,n){let i=ou(e),o=su(i,e,t,r);return o!==n&&(o&&(t=lt(e,t,o)),i.set(r,n)),t}function su(e,t,r,n){let i=e.get(n);if(i!=null)return i;i=0;for(let o=0;o<n.length;o++){let s=n[o];Zn(t,r,s)!=null&&(i!==0&&(r=lt(t,r,i)),i=s)}return e.set(n,i),i}function au(e,t,r,n){let i,o=0|e[se];if((n=Zn(e,o,r,n))!=null&&n.B===Zo)return(t=ru(n))!==n&<(e,o,r,t),t.l;if(Array.isArray(n)){let s=0|n[se];i=2&s?qo(mc(n,s,!1),t,!0):64&s?n:qo(i,t,!0)}else i=qo(void 0,t,!0);return i!==n&<(e,o,r,i),i}function _1(e,t,r,n){let i=0|(e=e.l)[se];return(t=h1(n=Zn(e,i,r,n),t,i))!==n&&t!=null&<(e,i,r,t),t}function wr(e,t,r){if((t=_1(e,t,r,!1))==null)return t;let n=0|(e=e.l)[se];if(!(2&n)){let i=ru(t);i!==t&<(e,n,r,t=i)}return t}function w1(e,t,r,n,i,o){e=e.l;var s=!!(2&t);let a=s?1:n;i=!!i,o&&=!s;var c=0|(n=nu(e,t,1))[se];if(!(s=!!(4&c))){var l=n,h=t;let d=!!(2&(c=iu(c,t)));d&&(h|=2);let m=!d,p=!0,g=0,f=0;for(;g<l.length;g++){let b=h1(l[g],r,h);if(b instanceof r){if(!d){let v=!!(2&(0|b.l[se]));m&&=!v,p&&=v}l[f++]=b}}f<g&&(l.length=f),c|=4,c=p?16|c:-17&c,ct(l,c=m?8|c:-9&c),d&&Object.freeze(l)}if(o&&!(8&c||!n.length&&(a===1||a===4&&32&c))){for(Zr(c)&&(n=lr(n),c=Qr(c,t),t=lt(e,t,1,n)),r=n,o=c,l=0;l<r.length;l++)(c=r[l])!==(h=ru(c))&&(r[l]=h);o|=8,ct(r,o=r.length?-17&o:16|o),c=o}return a===1||a===4&&32&c?Zr(c)||(t=c,(c|=!n.length||16&c&&(!s||32&c)?2:2048)!==t&&ct(n,c),Object.freeze(n)):(a===2&&Zr(c)&&(ct(n=lr(n),c=kn(c=Qr(c,t),t,i)),t=lt(e,t,1,n)),Zr(c)||(e=c,(c=kn(c,t,i))!==e&&ct(n,c))),n}function cu(e,t){let r=0|e.l[se];return w1(e,r,t,n1===void 0?2:4,!1,!(2&r))}function Sr(e,t,r,n){return n==null&&(n=void 0),pt(e,r,n)}function Rd(e,t,r){var n=i2;r==null&&(r=void 0);e:{let i=0|(e=e.l)[se];if(Yn(i),r==null){let o=ou(e);if(su(o,e,i,n)!==t)break e;o.set(n,0)}else i=v1(e,i,n,t);lt(e,i,t,r)}}function Qr(e,t){return-2049&(e=32|(2&t?2|e:-3&e))}function kn(e,t,r){return 32&t&&r||(e&=-33),e}function S1(e,t){var r=Eu;let n=0|e.l[se];Yn(n),e=w1(e,n,r,2,!0),t=t??new r,e.push(t),e[se]=2&(0|t.l[se])?-9&e[se]:-17&e[se]}function Ot(e,t,r){Yn(0|e.l[se]),y1(e,t,Sn,2,!0).push(l1(r))}function k1(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function lu(){return Error("Failed to read varint, encoding is invalid.")}function E1(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function hu(e){if(typeof e=="string")return{buffer:Y0(e),u:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),u:!1};if(e.constructor===Uint8Array)return{buffer:e,u:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),u:!1};if(e.constructor===wn)return{buffer:Wd(e)||new Uint8Array(0),u:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),u:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}function du(e,t){let r,n=0,i=0,o=0,s=e.i,a=e.g;do r=s[a++],n|=(127&r)<<o,o+=7;while(o<32&&128&r);for(o>32&&(i|=(127&r)>>4),o=3;o<32&&128&r;o+=7)r=s[a++],i|=(127&r)<<o;if(qn(e,a),r<128)return t(n>>>0,i>>>0);throw lu()}function uu(e){let t=0,r=e.g,n=r+10,i=e.i;for(;r<n;){let o=i[r++];if(t|=o,(128&o)==0)return qn(e,r),!!(127&t)}throw lu()}function Bt(e){let t=e.i,r=e.g,n=t[r++],i=127&n;if(128&n&&(n=t[r++],i|=(127&n)<<7,128&n&&(n=t[r++],i|=(127&n)<<14,128&n&&(n=t[r++],i|=(127&n)<<21,128&n&&(n=t[r++],i|=n<<28,128&n&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++]&&128&t[r++])))))throw lu();return qn(e,r),i}function Nd(e){var t=e.i;let r=e.g,n=t[r],i=t[r+1],o=t[r+2];return t=t[r+3],qn(e,e.g+4),(n<<0|i<<8|o<<16|t<<24)>>>0}function zd(e){var t=Nd(e);e=2*(t>>31)+1;let r=t>>>23&255;return t&=8388607,r==255?t?NaN:e*(1/0):r==0?1401298464324817e-60*e*t:e*Math.pow(2,r-150)*(t+8388608)}function j_(e){return Bt(e)}function Pd(e,t,{C:r=!1}={}){e.C=r,t&&(t=hu(t),e.i=t.buffer,e.m=t.u,e.s=0,e.j=e.i.length,e.g=e.s)}function qn(e,t){if(e.g=t,t>e.j)throw E1(e.j,t)}function C1(e,t){if(t<0)throw Error(`Tried to read a negative byte length: ${t}`);let r=e.g,n=r+t;if(n>e.j)throw E1(t,e.j-r);return e.g=n,r}function x1(e,t){if(t==0)return Zi();var r=C1(e,t);return e.C&&e.m?r=e.i.subarray(r,r+t):(e=e.i,r=r===(t=r+t)?new Uint8Array(0):B_?e.slice(r,t):new Uint8Array(e.subarray(r,t))),r.length==0?Zi():new wn(r,Yi)}var k0=[];function A1(e){var t=e.g;if(t.g==t.j)return!1;e.j=e.g.g;var r=Bt(e.g)>>>0;if(t=r>>>3,!((r&=7)>=0&&r<=5))throw k1(r,e.j);if(t<1)throw Error(`Invalid field number: ${t} (at position ${e.j})`);return e.m=t,e.i=r,!0}function Za(e){switch(e.i){case 0:e.i!=0?Za(e):uu(e.g);break;case 1:qn(e=e.g,e.g+8);break;case 2:if(e.i!=2)Za(e);else{var t=Bt(e.g)>>>0;qn(e=e.g,e.g+t)}break;case 5:qn(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!A1(e))throw Error("Unmatched start-group tag: stream EOF");if(e.i==4){if(e.m!=t)throw Error("Unmatched end-group tag");break}Za(e)}break;default:throw k1(e.i,e.j)}}function gc(e,t,r){let n=e.g.j,i=Bt(e.g)>>>0,o=e.g.g+i,s=o-n;if(s<=0&&(e.g.j=o,r(t,e,void 0,void 0,void 0),s=o-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${i} bytes, instead read ${i-s} bytes, either the data ended unexpectedly or the message misreported its own length`);e.g.g=o,e.g.j=n}function fu(e){var t=Bt(e.g)>>>0,r=C1(e=e.g,t);if(e=e.i,y_){var n,i=e;(n=Cd)||(n=Cd=new TextDecoder("utf-8",{fatal:!0})),t=r+t,i=r===0&&t===i.length?i:i.subarray(r,t);try{var o=n.decode(i)}catch(a){if(qa===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),qa=!0}catch{qa=!1}}throw!qa&&(Cd=void 0),a}}else{t=(o=r)+t,r=[];let a,c=null;for(;o<t;){var s=e[o++];s<128?r.push(s):s<224?o>=t?$n():(a=e[o++],s<194||(192&a)!=128?(o--,$n()):r.push((31&s)<<6|63&a)):s<240?o>=t-1?$n():(a=e[o++],(192&a)!=128||s===224&&a<160||s===237&&a>=160||(192&(n=e[o++]))!=128?(o--,$n()):r.push((15&s)<<12|(63&a)<<6|63&n)):s<=244?o>=t-2?$n():(a=e[o++],(192&a)!=128||a-144+(s<<28)>>30!=0||(192&(n=e[o++]))!=128||(192&(i=e[o++]))!=128?(o--,$n()):(s=(7&s)<<18|(63&a)<<12|(63&n)<<6|63&i,s-=65536,r.push(55296+(s>>10&1023),56320+(1023&s)))):$n(),r.length>=8192&&(c=l0(c,r),r.length=0)}o=l0(c,r)}return o}function T1(e){let t=Bt(e.g)>>>0;return x1(e.g,t)}function pu(e,t,r){var n=Bt(e.g)>>>0;for(n=e.g.g+n;e.g.g<n;)r.push(t(e.g))}var Ja=[];function V_(e){return e}var Ki;function I1(e,t,r){t.g?t.j(e,t.g,t.i,r):t.j(e,t.i,r)}var Ue=class{constructor(e,t){this.l=f1(e,t)}toJSON(){let e=!Ki;try{return e&&(Ki=N_),R1(this)}finally{e&&(Ki=void 0)}}u(){return!!(2&(0|this.l[se]))}};function R1(e){var t=e.l;{t=(e=Ki(t))!==t;let l=e.length;if(l){var r=e[l-1],n=Kd(r);n?l--:r=void 0;var i=e;if(n){e:{var o,s=r,a=!1;if(s)for(let h in s)isNaN(+h)?(o??={})[h]=s[h]:(n=s[h],Array.isArray(n)&&(tc(n)||m0(n)&&n.size===0)&&(n=null),n==null&&(a=!0),n!=null&&((o??={})[h]=n));if(a||(o=s),o)for(let h in o){a=o;break e}a=null}s=a==null?r!=null:a!==r}for(;l>0&&((o=i[l-1])==null||tc(o)||m0(o)&&o.size===0);l--)var c=!0;(i!==e||s||c)&&(t?(c||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),c=i}else c=e}return c}function E0(e){return e?/^\d+$/.test(e)?(fc(e),new jd(De,Ge)):null:H_||=new jd(0,0)}Ue.prototype.B=Zo,Ue.prototype.toString=function(){try{return Ki=V_,R1(this).toString()}finally{Ki=void 0}};var jd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},H_;function C0(e){return e?/^-?\d+$/.test(e)?(fc(e),new Vd(De,Ge)):null:W_||=new Vd(0,0)}var Vd=class{constructor(e,t){this.i=e>>>0,this.g=t>>>0}},W_;function Xi(e,t,r){for(;r>0||t>127;)e.g.push(127&t|128),t=(t>>>7|r<<25)>>>0,r>>>=7;e.g.push(t)}function ts(e,t){for(;t>127;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function yc(e,t){if(t>=0)ts(e,t);else{for(let r=0;r<9;r++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function ic(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function to(e,t){t.length!==0&&(e.j.push(t),e.i+=t.length)}function kr(e,t,r){ts(e.g,8*t+r)}function bc(e,t){return kr(e,t,2),t=e.g.end(),to(e,t),t.push(e.i),t}function vc(e,t){var r=t.pop();for(r=e.i+e.g.length()-r;r>127;)t.push(127&r|128),r>>>=7,e.i++;t.push(r),e.i++}function _c(e,t,r){kr(e,t,2),ts(e.g,r.length),to(e,e.g.end()),to(e,r)}function Er(){let e=class{constructor(){throw Error()}};return Object.setPrototypeOf(e,e.prototype),e}var mu=Er(),P1=Er(),gu=Er(),yu=Er(),D1=Er(),O1=Er(),B1=Er(),L1=Er(),ro=class{constructor(e,t,r){this.g=e,this.i=t,e=mu,this.j=!!e&&r===e||!1}};function bu(e,t){return new ro(e,t,mu)}function F1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}var $_=bu((function(e,t,r,n,i){return e.i===2&&(gc(e,au(t,n,r),i),!0)}),F1),G_=bu((function(e,t,r,n,i){return e.i===2&&(gc(e,au(t,n,r,!0),i),!0)}),F1),wc=Symbol(),vu=Symbol(),x0=Symbol(),A0=Symbol(),M1,U1;function Qn(e,t,r,n){var i=n[e];if(i)return i;(i={}).P=n,i.A=(function(d){switch(typeof d){case"boolean":return u1||=[0,void 0,!0];case"number":return d>0?void 0:d===0?z_||=[0,void 0]:[-d,void 0];case"string":return[0,d];case"object":return d}})(n[0]);var o=n[1];let s=1;o&&o.constructor===Object&&(i.H=o,typeof(o=n[++s])=="function"&&(i.I=!0,M1??=o,U1??=n[s+1],o=n[s+=2]));let a={};for(;o&&Array.isArray(o)&&o.length&&typeof o[0]=="number"&&o[0]>0;){for(var c=0;c<o.length;c++)a[o[c]]=o;o=n[++s]}for(c=1;o!==void 0;){let d;typeof o=="number"&&(c+=o,o=n[++s]);var l=void 0;if(o instanceof ro?d=o:(d=$_,s--),d?.j){o=n[++s],l=n;var h=s;typeof o=="function"&&(o=o(),l[h]=o),l=o}for(h=c+1,typeof(o=n[++s])=="number"&&o<0&&(h-=o,o=n[++s]);c<h;c++){let m=a[c];l?r(i,c,d,l,m):t(i,c,d,m)}}return n[e]=i}function N1(e){return Array.isArray(e)?e[0]instanceof ro?e:[G_,e]:[e,void 0]}function z1(e,t){return e instanceof Ue?e.l:Array.isArray(e)?qo(e,t,!1):void 0}function _u(e,t,r,n){let i=r.g;e[t]=n?(o,s,a)=>i(o,s,a,n):i}function wu(e,t,r,n,i){let o=r.g,s,a;e[t]=(c,l,h)=>o(c,l,h,a||=Qn(vu,_u,wu,n).A,s||=Su(n),i)}function Su(e){let t=e[x0];if(t!=null)return t;let r=Qn(vu,_u,wu,e);return t=r.I?(n,i)=>M1(n,i,r):(n,i)=>{let o=0|n[se];for(;A1(i)&&i.i!=4;){var s=i.m,a=r[s];if(a==null){var c=r.H;c&&(c=c[s])&&(c=q_(c))!=null&&(a=r[s]=c)}a!=null&&a(i,n,s)||(s=(a=i).j,Za(a),a.G?a=void 0:(c=a.g.g-s,a.g.g=s,a=x1(a.g,c)),s=n,a&&((c=s[Qi])?c.push(a):s[Qi]=[a]))}return 16384&o&&$d(n,34),!0},e[x0]=t}function q_(e){let t=(e=N1(e))[0].g;if(e=e[1]){let r=Su(e),n=Qn(vu,_u,wu,e).A;return(i,o,s)=>t(i,o,s,n,r)}return t}function Sc(e,t,r){e[t]=r.i}function kc(e,t,r,n){let i,o,s=r.i;e[t]=(a,c,l)=>s(a,c,l,o||=Qn(wc,Sc,kc,n).A,i||=j1(n))}function j1(e){let t=e[A0];if(!t){let r=Qn(wc,Sc,kc,e);t=(n,i)=>V1(n,i,r),e[A0]=t}return t}function V1(e,t,r){for(var n=0|e[se],i=512&n?0:-1,o=e.length,s=512&n?1:0,a=o+(256&n?-1:0);s<a;s++){let c=e[s];if(c==null)continue;let l=s-i,h=T0(r,l);h&&h(t,c,l)}if(256&n){n=e[o-1];for(let c in n)i=+c,Number.isNaN(i)||(o=n[i])!=null&&(a=T0(r,i))&&a(t,o,i)}if(e=Xd(e))for(to(t,t.g.end()),r=0;r<e.length;r++)to(t,Wd(e[r])||new Uint8Array(0))}function T0(e,t){var r=e[t];if(r)return r;if((r=e.H)&&(r=r[t])){var n=(r=N1(r))[0].i;if(r=r[1]){let i=j1(r),o=Qn(wc,Sc,kc,r).A;r=e.I?U1(o,i):(s,a,c)=>n(s,a,c,o,i)}else r=n;return e[t]=r}}function Ec(e,t){if(Array.isArray(t)){var r=0|t[se];if(4&r)return t;for(var n=0,i=0;n<t.length;n++){let o=e(t[n]);o!=null&&(t[i++]=o)}return i<n&&(t.length=i),ct(t,-12289&(5|r)),2&r&&Object.freeze(t),t}}function wt(e,t,r){return new ro(e,t,r)}function Cc(e,t,r){return new ro(e,t,r)}function St(e,t,r){lt(e,0|e[se],t,r)}function H1(e,t,r){if(t=(function(n){if(n==null)return n;let i=typeof n;if(i==="bigint")return String(s1(64,n));if(eu(n)){if(i==="string")return c1(n);if(i==="number")return a1(n)}})(t),t!=null&&(typeof t=="string"&&C0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new Vd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=C0(t),Xi(e.g,r.i,r.g)}}function W1(e,t,r){(t=Xn(t))!=null&&t!=null&&(kr(e,r,0),yc(e.g,t))}function $1(e,t,r){(t=t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0)!=null&&(kr(e,r,0),e.g.g.push(t?1:0))}function G1(e,t,r){(t=Sn(t))!=null&&_c(e,r,G0(t))}function q1(e,t,r,n,i){(t=z1(t,n))!=null&&(r=bc(e,r),i(t,e),vc(e,r))}function K1(e,t,r){(t=t==null||typeof t=="string"||hc(t)||t instanceof wn?t:void 0)!=null&&_c(e,r,hu(t).buffer)}var K_=wt((function(e,t,r){if(e.i!==1)return!1;var n=e.g;e=Nd(n);let i=Nd(n);n=2*(i>>31)+1;let o=i>>>20&2047;return e=4294967296*(1048575&i)+e,St(t,r,o==2047?e?NaN:n*(1/0):o==0?5e-324*n*e:n*Math.pow(2,o-1075)*(e+4503599627370496)),!0}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,1),e=e.g,(r=i1||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),De=r.getUint32(0,!0),Ge=r.getUint32(4,!0),ic(e,De),ic(e,Ge))}),Er()),X1=wt((function(e,t,r){return e.i===5&&(St(t,r,zd(e.g)),!0)}),(function(e,t,r){(t=Qo(t))!=null&&(kr(e,r,5),e=e.g,o1(t),ic(e,De))}),O1),X_=Cc((function(e,t,r){return(e.i===5||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,zd,t):t.push(zd(e.g)),!0)}),(function(e,t,r){if((t=Ec(Qo,t))!=null&&t.length){kr(e,r,2),ts(e.g,4*t.length);for(let n=0;n<t.length;n++)r=e.g,o1(t[n]),ic(r,De)}}),O1),oc=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g,Zd)),!0)}),H1,D1),Dd=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=du(e.g,Zd))===0?void 0:e),!0)}),H1,D1),J_=wt((function(e,t,r){return e.i===0&&(St(t,r,du(e.g,Yd)),!0)}),(function(e,t,r){if((t=M_(t))!=null&&(typeof t=="string"&&E0(t),t!=null))switch(kr(e,r,0),typeof t){case"number":e=e.g,eo(t),Xi(e,De,Ge);break;case"bigint":r=BigInt.asUintN(64,t),r=new jd(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),Xi(e.g,r.i,r.g);break;default:r=E0(t),Xi(e.g,r.i,r.g)}}),Er()),En=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),W1,yu),ku=Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,Bt,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),yu),Gi=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g))===0?void 0:e),!0)}),W1,yu),Wt=wt((function(e,t,r){return e.i===0&&(St(t,r,uu(e.g)),!0)}),$1,P1),Ji=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=uu(e.g))===!1?void 0:e),!0)}),$1,P1),sr=Cc((function(e,t,r){return e.i===2&&(e=fu(e),es(t,0|t[se],r,!1).push(e),!0)}),(function(e,t,r){if((t=Ec(Sn,t))!=null)for(let s=0;s<t.length;s++){var n=e,i=r,o=t[s];o!=null&&_c(n,i,G0(o))}}),gu),_n=wt((function(e,t,r){return e.i===2&&(St(t,r,(e=fu(e))===""?void 0:e),!0)}),G1,gu),Ze=wt((function(e,t,r){return e.i===2&&(St(t,r,fu(e)),!0)}),G1,gu),ar=(function(e,t,r=mu){return new ro(e,t,r)})((function(e,t,r,n,i){return e.i===2&&(n=qo(void 0,n,!0),es(t,0|t[se],r,!0).push(n),gc(e,n,i),!0)}),(function(e,t,r,n,i){if(Array.isArray(t))for(let o=0;o<t.length;o++)q1(e,t[o],r,n,i)})),ft=bu((function(e,t,r,n,i,o){return e.i===2&&(v1(t,0|t[se],o,r),gc(e,t=au(t,n,r),i),!0)}),q1),J1=wt((function(e,t,r){return e.i===2&&(St(t,r,T1(e)),!0)}),K1,B1),Y_=wt((function(e,t,r){return e.i===0&&(St(t,r,(e=Bt(e.g)>>>0)===0?void 0:e),!0)}),(function(e,t,r){t=(function(n){if(n==null)return n;if(typeof n=="string"&&n)n=+n;else if(typeof n!="number")return;return pc(n)?n>>>0:void 0})(t),t!=null&&t!=null&&(kr(e,r,0),ts(e.g,t))}),Er()),Jn=wt((function(e,t,r){return e.i===0&&(St(t,r,Bt(e.g)),!0)}),(function(e,t,r){(t=Xn(t))!=null&&(t=parseInt(t,10),kr(e,r,0),yc(e.g,t))}),L1),sc=class{constructor(t,r){this.i=t,this.g=r,this.j=Sr,this.defaultValue=void 0}};function Y1(e,t){return(r,n)=>{if(Ja.length){let o=Ja.pop();o.o(n),Pd(o.g,r,n),r=o}else r=new class{constructor(o,s){if(k0.length){let a=k0.pop();Pd(a,o,s),o=a}else o=new class{constructor(a,c){this.i=null,this.m=!1,this.g=this.j=this.s=0,Pd(this,a,c)}clear(){this.i=null,this.m=!1,this.g=this.j=this.s=0,this.C=!1}}(o,s);this.g=o,this.j=this.g.g,this.i=this.m=-1,this.o(s)}o({G:o=!1}={}){this.G=o}}(r,n);try{let o=new e,s=o.l;Su(t)(s,r);var i=o}finally{r.g.clear(),r.m=-1,r.i=-1,Ja.length<100&&Ja.push(r)}return i}}var I0=[0,_n,wt((function(e,t,r){return e.i===2&&(St(t,r,(e=T1(e))===Zi()?void 0:e),!0)}),(function(e,t,r){if(t!=null){if(t instanceof Ue){let n=t.R;return void(n&&(t=n(t),t!=null&&_c(e,r,hu(t).buffer)))}if(Array.isArray(t))return}K1(e,t,r)}),B1)],Od,R0=globalThis.trustedTypes;function P0(e){Od===void 0&&(Od=(function(){let r=null;if(!R0)return r;try{let n=i=>i;r=R0.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r})());var t=Od;return new class{constructor(r){this.g=r}toString(){return this.g+""}}(t?t.createScriptURL(e):e)}function Z_(e,...t){if(t.length===0)return P0(e[0]);let r=e[0];for(let n=0;n<t.length;n++)r+=encodeURIComponent(t[n])+e[n+1];return P0(r)}var Z1=[0,En,Jn,Wt,-1,ku,Jn,-1],Q_=class extends Ue{constructor(e){super(e)}},Q1=[0,Wt,Ze,Wt,Jn,-1,Cc((function(e,t,r){return(e.i===0||e.i===2)&&(t=es(t,0|t[se],r,!1,!1),e.i==2?pu(e,j_,t):t.push(Bt(e.g)),!0)}),(function(e,t,r){if((t=Ec(Xn,t))!=null&&t.length){r=bc(e,r);for(let n=0;n<t.length;n++)yc(e.g,t[n]);vc(e,r)}}),L1),Ze,-1,[0,Wt,-1],Jn,Wt,-1],e2=[0,Ze,-2],D0=class extends Ue{constructor(e){super(e)}},t2=[0],r2=[0,En,Wt,1,Wt,-3],n2=class extends Ue{constructor(e){super(e,2)}},xc={};xc[336783863]=[0,Ze,Wt,-1,En,[0,[1,2,3,4,5,6,7,8],ft,t2,ft,Q1,ft,e2,ft,r2,ft,Z1,ft,[0,Ze,-2],ft,[0,Ze,Jn],ft,[0,Jn,Ze]],[0,Ze],Wt,[0,[1,3],[2,4],ft,[0,ku],-1,ft,[0,sr],-1,ar,[0,Ze,-1]],Ze];var O0,B0=[0,Dd,-1,Ji,-3,Dd,ku,_n,Gi,Dd,-1,Ji,Gi,Ji,-2,_n],Eu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,7,e)}},Ko=[-1,{}],L0=[0,Ze,1,Ko],F0=[0,Ze,sr,Ko],Cu=class extends Ue{constructor(e){super(e,500)}o(e){return Sr(this,0,1001,e)}};Cu.prototype.g=(O0=[-500,ar,[-500,_n,-1,sr,-3,[-2,xc,Wt],ar,I0,Gi,-1,L0,F0,ar,[0,_n,Ji],_n,B0,Gi,sr,987,sr],4,ar,[-500,Ze,-1,[-1,{}],998,Ze],ar,[-500,Ze,sr,-1,[-2,{},Wt],997,sr,-1],Gi,ar,[-500,Ze,sr,Ko,998,sr],sr,Gi,L0,F0,ar,[0,_n,-1,Ko],sr,-2,B0,_n,-1,Ji,[0,Ji,Y_],978,Ko,ar,I0],function(){let e=new class{constructor(){this.j=[],this.i=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){let o=this.g;return this.g=[],o}}}};V1(this.l,e,Qn(wc,Sc,kc,O0)),to(e,e.g.end());let t=new Uint8Array(e.i),r=e.j,n=r.length,i=0;for(let o=0;o<n;o++){let s=r[o];t.set(s,i),i+=s.length}return e.j=[t],t});var e3=class extends Ue{constructor(e){super(e)}},t3=class extends Ue{constructor(e){super(e)}g(){return cu(this,e3)}},r3=[0,ar,[0,En,X1,Ze,-1]],M0=class extends Ue{constructor(e){super(e)}},U0=class extends Ue{constructor(e){super(e)}},i2=[1,2,3,4,5],ac=class extends Ue{constructor(e){super(e)}g(){return g1(this)!=null}i(){return Sn(_r(this,2))!=null}},cc=class extends Ue{constructor(e){super(e)}},o2=class extends Ue{constructor(e){super(e)}},s2=[0,[0,J1,Ze,[0,En,oc,-1],[0,J_,oc]],Wt,[0,i2,ft,r2,ft,Q1,ft,Z1,ft,t2,ft,e2],Jn],n3=new sc(451755788,o2);xc[451755788]=[0,s2,[0,Ze,En,X1,sr,-1],K_];var N0=class extends Ue{constructor(e){super(e)}},a2=class extends Ue{constructor(e){super(e)}},i3=new sc(487277289,a2);xc[487277289]=[0,s2,[0,Wt,-1]];var o3=class extends Ue{constructor(e){super(e)}},s3=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,1,En,Ze,r3],oc]),z0=class extends Ue{constructor(e){super(e)}},a3=class extends Ue{constructor(e){super(e)}J(){let e=g1(this);return e??Zi()}},c3=class extends Ue{constructor(e){super(e)}},c2=[1,2],j0=Y1(class extends Ue{constructor(e){super(e)}},[0,ar,[0,c2,ft,[0,X_],ft,[0,J1],En,Ze],oc]);function l3(){var e=navigator;return typeof OffscreenCanvas<"u"&&(!(function(t=navigator){return(t=t.userAgent).includes("Safari")&&!t.includes("Chrome")})(e)||!!((e=e.userAgent.match(/Version\/([\d]+).*Safari/))&&e.length>=1&&Number(e[1])>=17))}async function V0(e){if(typeof importScripts!="function"){let t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((r,n)=>{t.addEventListener("load",(()=>{r()}),!1),t.addEventListener("error",(i=>{n(i)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function ie(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),r(t=e.h.stringToNewUTF8(t)),e.h._free(t)}function H0(e,t,r){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");let n=new Uint32Array(t.length);for(let i=0;i<t.length;i++)n[i]=e.h.stringToNewUTF8(t[i]);t=e.h._malloc(4*n.length),e.h.HEAPU32.set(n,t>>2),r(t);for(let i of n)e.h._free(i);e.h._free(t)}function yn(e,t,r){e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=r}function Gn(e,t,r){let n=[];e.h.simpleListeners=e.h.simpleListeners||{},e.h.simpleListeners[t]=(i,o,s)=>{o?(r(n,s),n=[]):n.push(i)}}var h3=(function(e){return class extends e{N(){this.h._registerModelResourcesGraphService()}}})(class{constructor(e,t){this.j=!0,this.h=e,this.g=null,this.i=0,this.m=typeof this.h._addIntToInputStream=="function",t!==void 0?this.h.canvas=t:l3()?this.h.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.h.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.h._malloc(r);this.h.HEAPU8.set(e,n),t?this.h._changeBinaryGraph(r,n):this.h._changeTextGraph(r,n),this.h._free(n)}configureAudio(e,t,r,n,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),ie(this,n||"input_audio",(o=>{ie(this,i=i||"audio_header",(s=>{this.h._configureAudio(o,s,e,t??0,r)}))}))}setAutoResizeCanvas(e){this.j=e}setAutoRenderToScreen(e){this.h._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.h.gpuOriginForWebTexturesIsBottomLeft=e}attachErrorListener(e){this.h.errorListener=e}attachEmptyPacketListener(e,t){this.h.emptyPacketListeners=this.h.emptyPacketListeners||{},this.h.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,i){let o=4*e.length;this.i!==o&&(this.g&&this.h._free(this.g),this.g=this.h._malloc(o),this.i=o),this.h.HEAPF32.set(e,this.g/4),ie(this,n,(s=>{this.h._addAudioToInputStream(this.g,t,r,s,i)}))}addGpuBufferToStream(e,t,r){ie(this,t,(n=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");n?this.h._bindTextureToStream(n):this.h._bindTextureToCanvas();let i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);let[o,s]=e.videoWidth!==void 0?[e.videoWidth,e.videoHeight]:e.naturalWidth!==void 0?[e.naturalWidth,e.naturalHeight]:e.displayWidth!==void 0?[e.displayWidth,e.displayHeight]:[e.width,e.height];!this.j||o===this.h.canvas.width&&s===this.h.canvas.height||(this.h.canvas.width=o,this.h.canvas.height=s);let[a,c]=[o,s];this.h._addBoundTextureToStream(n,a,c,r)}))}addBoolToStream(e,t,r){ie(this,t,(n=>{this.h._addBoolToInputStream(e,n,r)}))}addDoubleToStream(e,t,r){ie(this,t,(n=>{this.h._addDoubleToInputStream(e,n,r)}))}addFloatToStream(e,t,r){ie(this,t,(n=>{this.h._addFloatToInputStream(e,n,r)}))}addIntToStream(e,t,r){ie(this,t,(n=>{this.h._addIntToInputStream(e,n,r)}))}addUintToStream(e,t,r){ie(this,t,(n=>{this.h._addUintToInputStream(e,n,r)}))}addStringToStream(e,t,r){ie(this,t,(n=>{ie(this,e,(i=>{this.h._addStringToInputStream(i,n,r)}))}))}addStringRecordToStream(e,t,r){ie(this,t,(n=>{H0(this,Object.keys(e),(i=>{H0(this,Object.values(e),(o=>{this.h._addFlatHashMapToInputStream(i,o,Object.keys(e).length,n,r)}))}))}))}addProtoToStream(e,t,r,n){ie(this,r,(i=>{ie(this,t,(o=>{let s=this.h._malloc(e.length);this.h.HEAPU8.set(e,s),this.h._addProtoToInputStream(s,e.length,o,i,n),this.h._free(s)}))}))}addEmptyPacketToStream(e,t){ie(this,e,(r=>{this.h._addEmptyPacketToInputStream(r,t)}))}addBoolVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateBoolVector(e.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.h._addBoolVectorEntry(i,o);this.h._addBoolVectorToInputStream(i,n,r)}))}addDoubleVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateDoubleVector(e.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.h._addDoubleVectorEntry(i,o);this.h._addDoubleVectorToInputStream(i,n,r)}))}addFloatVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateFloatVector(e.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.h._addFloatVectorEntry(i,o);this.h._addFloatVectorToInputStream(i,n,r)}))}addIntVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateIntVector(e.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.h._addIntVectorEntry(i,o);this.h._addIntVectorToInputStream(i,n,r)}))}addUintVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateUintVector(e.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.h._addUintVectorEntry(i,o);this.h._addUintVectorToInputStream(i,n,r)}))}addStringVectorToStream(e,t,r){ie(this,t,(n=>{let i=this.h._allocateStringVector(e.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let o of e)ie(this,o,(s=>{this.h._addStringVectorEntry(i,s)}));this.h._addStringVectorToInputStream(i,n,r)}))}addBoolToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addBoolToInputSidePacket(e,r)}))}addDoubleToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addDoubleToInputSidePacket(e,r)}))}addFloatToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addFloatToInputSidePacket(e,r)}))}addIntToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addIntToInputSidePacket(e,r)}))}addUintToInputSidePacket(e,t){ie(this,t,(r=>{this.h._addUintToInputSidePacket(e,r)}))}addStringToInputSidePacket(e,t){ie(this,t,(r=>{ie(this,e,(n=>{this.h._addStringToInputSidePacket(n,r)}))}))}addProtoToInputSidePacket(e,t,r){ie(this,r,(n=>{ie(this,t,(i=>{let o=this.h._malloc(e.length);this.h.HEAPU8.set(e,o),this.h._addProtoToInputSidePacket(o,e.length,i,n),this.h._free(o)}))}))}addBoolVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let i of e)this.h._addBoolVectorEntry(n,i);this.h._addBoolVectorToInputSidePacket(n,r)}))}addDoubleVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let i of e)this.h._addDoubleVectorEntry(n,i);this.h._addDoubleVectorToInputSidePacket(n,r)}))}addFloatVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let i of e)this.h._addFloatVectorEntry(n,i);this.h._addFloatVectorToInputSidePacket(n,r)}))}addIntVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let i of e)this.h._addIntVectorEntry(n,i);this.h._addIntVectorToInputSidePacket(n,r)}))}addUintVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let i of e)this.h._addUintVectorEntry(n,i);this.h._addUintVectorToInputSidePacket(n,r)}))}addStringVectorToInputSidePacket(e,t){ie(this,t,(r=>{let n=this.h._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let i of e)ie(this,i,(o=>{this.h._addStringVectorEntry(n,o)}));this.h._addStringVectorToInputSidePacket(n,r)}))}attachBoolListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachBoolListener(r)}))}attachBoolVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachBoolVectorListener(r)}))}attachIntListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachIntListener(r)}))}attachIntVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachIntVectorListener(r)}))}attachUintListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachUintListener(r)}))}attachUintVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachUintVectorListener(r)}))}attachDoubleListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleListener(r)}))}attachDoubleVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachDoubleVectorListener(r)}))}attachFloatListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachFloatListener(r)}))}attachFloatVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachFloatVectorListener(r)}))}attachStringListener(e,t){yn(this,e,t),ie(this,e,(r=>{this.h._attachStringListener(r)}))}attachStringVectorListener(e,t){Gn(this,e,t),ie(this,e,(r=>{this.h._attachStringVectorListener(r)}))}attachProtoListener(e,t,r){yn(this,e,t),ie(this,e,(n=>{this.h._attachProtoListener(n,r||!1)}))}attachProtoVectorListener(e,t,r){Gn(this,e,t),ie(this,e,(n=>{this.h._attachProtoVectorListener(n,r||!1)}))}attachAudioListener(e,t,r){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),yn(this,e,((n,i)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,i)})),ie(this,e,(n=>{this.h._attachAudioListener(n,r||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}}),l2=class extends h3{};async function d3(e,t,r){return e=await(async(n,i,o,s)=>{if(i&&await V0(i),!self.ModuleFactory||o&&(await V0(o),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&s&&((i=self.Module).locateFile=s.locateFile,s.mainScriptUrlOrBlob&&(i.mainScriptUrlOrBlob=s.mainScriptUrlOrBlob)),s=await self.ModuleFactory(self.Module||s),self.ModuleFactory=self.Module=void 0,new n(s,null)})(e,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:n=>n.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&n.endsWith(".data")?t.assetBinaryPath.toString():n}),await e.o(r),e}async function h2(e,t,r){return d3(e,t,r)}function Bd(e,t){let r=wr(e.baseOptions,ac,1)||new ac;typeof t=="string"?(pt(r,2,nc(t)),pt(r,1)):t instanceof Uint8Array&&(pt(r,1,r1(t,!1)),pt(r,2)),Sr(e.baseOptions,0,1,r)}function d2(e,t){let r=t.baseOptions||{};if(t.baseOptions?.modelAssetBuffer&&t.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(wr(e.baseOptions,ac,1)?.g()||wr(e.baseOptions,ac,1)?.i()||t.baseOptions?.modelAssetBuffer||t.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if((function(n,i){let o=wr(n.baseOptions,U0,3);if(!o){var s=o=new U0;Rd(s,4,new D0)}"delegate"in i&&(i.delegate==="GPU"?Rd(i=o,2,s=new Q_):Rd(i=o,4,s=new D0)),Sr(n.baseOptions,0,3,o)})(e,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then((n=>{if(n.ok)return n.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${n.status})`)})).then((n=>{try{e.g.h.FS_unlink("/model.dat")}catch{}e.g.h.FS_createDataFile("/","model.dat",new Uint8Array(n),!0,!1,!1),Bd(e,"/model.dat"),e.v()}));if(r.modelAssetBuffer instanceof Uint8Array)Bd(e,r.modelAssetBuffer);else if(r.modelAssetBuffer)return(async function(n){let i=[];for(var o=0;;){let{done:s,value:a}=await n.read();if(s)break;i.push(a),o+=a.length}if(i.length===0)return new Uint8Array(0);if(i.length===1)return i[0];n=new Uint8Array(o),o=0;for(let s of i)n.set(s,o),o+=s.length;return n})(r.modelAssetBuffer).then((n=>{Bd(e,n),e.v()}));return e.v(),Promise.resolve()}function W0(e){try{let t=e.j.length;if(t===1)throw Error(e.j[0].message);if(t>1)throw Error("Encountered multiple errors: "+e.j.map((r=>r.message)).join(", "))}finally{e.j=[]}}function qi(e,t){e.s=Math.max(e.s,t)}var Qa=class{constructor(e){this.g=e,this.j=[],this.s=0,this.g.setAutoRenderToScreen(!1)}setGraph(e,t){this.g.attachErrorListener(((r,n)=>{this.j.push(Error(n))})),this.g.N(),this.g.setGraph(e,t),W0(this)}finishProcessing(){this.g.finishProcessing(),W0(this)}close(){this.g.closeGraph()}};async function Xo(e,t,r){return h2(e,t,r)}Qa.prototype.close=Qa.prototype.close,(function(e,t){e=e.split(".");var r,n=Kn;for((e[0]in n)||n.execScript===void 0||n.execScript("var "+e[0]);e.length&&(r=e.shift());)e.length||t===void 0?n=n[r]&&n[r]!==Object.prototype[r]?n[r]:n[r]={}:n[r]=t})("TaskRunner",Qa);var lc=class extends Qa{constructor(){super(...arguments),this.F=48e3}O(e){this.F=e}};function u3(e){let t={classifications:cu(e,o3).map((r=>(function(n,i=-1,o=""){return{categories:n.map((s=>{var a=Xn(_r(s,1))??0??-1;let c=s.l,l=0|c[se],h=Zn(c,l,2),d=Qo(h);return d!=null&&d!==h&<(c,l,2,d),{index:a,score:d??0??0,categoryName:Sn(_r(s,3))??""??"",displayName:Sn(_r(s,4))??""??""}})),headIndex:i,headName:o}})(wr(r,t3,4)?.g()??[],Xn(_r(r,2))??0,Sn(_r(r,3))??"")))};return Ud(_r(e,2))!=null&&(t.timestampMs=Ud(_r(e,2))??0),t}lc.prototype.setDefaultSampleRate=lc.prototype.O;var or=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new o2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,M0,2);if(r=r?m1(r):new M0,e.displayNamesLocale!==void 0?pt(r,1,nc(e.displayNamesLocale)):e.displayNamesLocale===void 0&&pt(r,1),e.maxResults!==void 0){var n=e.maxResults;if(n!=null){if(typeof n!="number"||!pc(n))throw p0();n|=0}pt(r,2,n)}else"maxResults"in e&&pt(r,2);if(e.scoreThreshold!==void 0){if((n=e.scoreThreshold)!=null&&typeof n!="number")throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);pt(r,3,n)}else"scoreThreshold"in e&&pt(r,3);return e.categoryAllowlist!==void 0?S0(r,4,e.categoryAllowlist):"categoryAllowlist"in e&&pt(r,4),e.categoryDenylist!==void 0?S0(r,5,e.categoryDenylist):"categoryDenylist"in e&&pt(r,5),Sr(t,0,2,r),d2(this,e)}K(e,t){return this.D(e,t??this.F,this.s+1)}D(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),[...this.m]}v(){var e=new Cu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"timestamped_classifications");let t=new n2;I1(t,n3,this.i);let r=new Eu;b1(r,nc("mediapipe.tasks.audio.audio_classifier.AudioClassifierGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"TIMESTAMPED_CLASSIFICATIONS:timestamped_classifications"),r.o(t),S1(e,r),this.g.attachProtoVectorListener("timestamped_classifications",((n,i)=>{(function(o,s){s.forEach((a=>{a=s3(a),o.m.push(u3(a))}))})(this,n),qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_classifications",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function $0(e){return{embeddings:cu(e,c3).map((t=>{let r={headIndex:Xn(_r(t,3))??0??-1,headName:Sn(_r(t,4))??""??""};if(_1(t,z0,Id(t,1))!==void 0)r.floatEmbedding=y1(wr(t,z0,Id(t,1)),1,Qo,n1===void 0?2:4).slice();else{let n=new Uint8Array(0);r.quantizedEmbedding=wr(t,a3,Id(t,2))?.J()?.i()??n}return r})),timestampMs:Ud(_r(e,2))??0}}or.prototype.classify=or.prototype.K,or.prototype.setOptions=or.prototype.o,or.createFromModelPath=function(e,t){return h2(or,e,{baseOptions:{modelAssetPath:t}})},or.createFromModelBuffer=function(e,t){return Xo(or,e,{baseOptions:{modelAssetBuffer:t}})},or.createFromOptions=function(e,t){return Xo(or,e,t)};var Fr=class extends lc{constructor(e,t){super(new l2(e,t)),this.m=[],Sr(e=this.i=new a2,0,1,t=new cc)}get baseOptions(){return wr(this.i,cc,1)}set baseOptions(e){Sr(this.i,0,1,e)}o(e){var t=this.i,r=wr(this.i,N0,2);return r=r?m1(r):new N0,e.l2Normalize!==void 0?pt(r,1,_0(e.l2Normalize)):"l2Normalize"in e&&pt(r,1),e.quantize!==void 0?pt(r,2,_0(e.quantize)):"quantize"in e&&pt(r,2),Sr(t,0,2,r),d2(this,e)}L(e,t){return this.D(e,t??this.F,this.s+1)}D(e,t,r){return this.g.addDoubleToStream(t,"sample_rate",r),this.g.addAudioToStreamWithShape(e,1,e.length,"audio_in",r),this.m=[],this.finishProcessing(),this.m}v(){var e=new Cu;Ot(e,10,"audio_in"),Ot(e,10,"sample_rate"),Ot(e,15,"embeddings_out"),Ot(e,15,"timestamped_embeddings_out");let t=new n2;I1(t,i3,this.i);let r=new Eu;b1(r,nc("mediapipe.tasks.audio.audio_embedder.AudioEmbedderGraph")),Ot(r,3,"AUDIO:audio_in"),Ot(r,3,"SAMPLE_RATE:sample_rate"),Ot(r,4,"EMBEDDINGS:embeddings_out"),Ot(r,4,"TIMESTAMPED_EMBEDDINGS:timestamped_embeddings_out"),r.o(t),S1(e,r),this.g.attachProtoListener("embeddings_out",((n,i)=>{n=j0(n),this.m.push($0(n)),qi(this,i)})),this.g.attachEmptyPacketListener("embeddings_out",(n=>{qi(this,n)})),this.g.attachProtoVectorListener("timestamped_embeddings_out",((n,i)=>{for(let o of n)n=j0(o),this.m.push($0(n));qi(this,i)})),this.g.attachEmptyPacketListener("timestamped_embeddings_out",(n=>{qi(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}},Ya;Fr.prototype.embed=Fr.prototype.L,Fr.prototype.setOptions=Fr.prototype.o,Fr.createFromModelPath=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetPath:t}})},Fr.createFromModelBuffer=function(e,t){return Xo(Fr,e,{baseOptions:{modelAssetBuffer:t}})},Fr.createFromOptions=function(e,t){return Xo(Fr,e,t)};var f3=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function u2(){if(Ya===void 0)try{await WebAssembly.instantiate(f3),Ya=!0}catch{Ya=!1}return Ya}async function Wo(e,t=Z_``){let r=await u2()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${t}/${e}_${r}.js`,wasmBinaryPath:`${t}/${e}_${r}.wasm`}}var bn=class{};bn.forVisionTasks=function(e){return Wo("vision",e)},bn.forTextTasks=function(e){return Wo("text",e)},bn.forGenAiExperimentalTasks=function(e){return Wo("genai_experimental",e)},bn.forGenAiTasks=function(e){return Wo("genai",e)},bn.forAudioTasks=function(e){return Wo("audio",e)},bn.isSimdSupported=function(){return u2()};function p3(e,t){let r=e.reduce((a,c)=>a+c.length,0),n=new ArrayBuffer(44+r*2),i=new DataView(n),o=(a,c,l)=>{for(let h=0;h<l.length;h++)a.setUint8(c+h,l.charCodeAt(h))};o(i,0,"RIFF"),i.setUint32(4,36+r*2,!0),o(i,8,"WAVE"),o(i,12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,t,!0),i.setUint32(28,t*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),o(i,36,"data"),i.setUint32(40,r*2,!0);let s=44;for(let a of e)for(let c=0;c<a.length;c++){let l=Math.max(-1,Math.min(1,a[c]));i.setInt16(s,l<0?l*32768:l*32767,!0),s+=2}return new Blob([i],{type:"audio/wav"})}var Ac=class{constructor(t,r,n,i,o,s,a){this.recordingInProgress=!1;this.recordIndex=1;this.countLoopTimes=0;this.examStartTime=0;this.recordingStartTime=0;this.recordingEndTime=0;this.isSpeech=!1;this.preRollBuffer=[];this.recordingChunks=[];this.PRE_ROLL_SECONDS=2;this.SAMPLE_RATE=16e3;this.MAX_PRE_ROLL_CHUNKS=4;this.lastNoiseTime=0;this.SILENCE_THRESHOLD=3e3;this.optionsProctoring=t,this.proctoringSession=r,this.paramsConfig=n,this.cameraRecorder=i,this.onRealtimeAlertsCallback=o,this.backend=s,this.backendToken=a}setProctoringId(t){this.proctoringId=t,this.proctoringId&&this.backend&&(this.upload=new Jr(this.proctoringId,this.backend))}async startRecording(){this.examStartTime=Date.now(),await this.createAudioClassifier(),this.audioRecorder=new Ga(void 0,this.paramsConfig.audioBehaviourParameters),this.intervalNoiseDetection=setInterval(()=>this.onNoiseDetectedRecord(),200),this.streamingAudioClassification()}async stopRecording(){clearInterval(this.intervalNoiseDetection),await this.stopSoundRecord(),await this.volumeMeter&&this.volumeMeter.stop(),this.audioWorkletNode&&this.audioWorkletNode.disconnect()}async pauseRecording(){}async resumeRecording(){}async saveOnSession(t){}async onNoiseDetectedRecord(){!this.volumeMeter&&this.cameraRecorder.cameraStream&&(this.volumeMeter=new gn(this.cameraRecorder.cameraStream),this.volumeMeter.start().catch(i=>{console.log(i),this.volumeMeter=void 0}));let t=this.paramsConfig.audioBehaviourParameters?.noiseLimit||40,r=this.volumeMeter?.getVolume()||0;this.isSpeech=this.isSpeech||this.hasDesiredResult(this.audioClassificationResult),!this.isSpeech&&!this.recordingInProgress&&(t=t*1.25);let n=r>=t;if(n&&(this.lastNoiseTime=Date.now()),n&&!this.recordingInProgress){this.recordingInProgress=!0,this.recordingChunks=[...this.preRollBuffer];let o=this.preRollBuffer.reduce((a,c)=>a+c.length,0)/this.SAMPLE_RATE*1e3,s=Date.now()-this.examStartTime;this.recordingStartTime=s-o,this.recordingStartTime<0&&(this.recordingStartTime=0)}else if(this.recordingInProgress){let i=Date.now()-this.lastNoiseTime,o=Date.now()-this.recordingStartTime;i>=this.SILENCE_THRESHOLD&&o>=3e3&&this.countLoopTimes>4&&(await this.stopSoundRecord(),this.paramsConfig.videoBehaviourParameters?.detectNoise&&!this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Barulho detectado",type:"audio_detection_on_stream"}),this.paramsConfig.videoBehaviourParameters?.detectSpeech&&this.isSpeech&&this.onRealtimeAlertsCallback({status:"ALERT",description:"Fala detectada",type:"audio_detection_on_stream"}),this.recordingInProgress=!1,this.recordIndex++,this.countLoopTimes=0,this.isSpeech=!1),this.countLoopTimes++}}async stopSoundRecord(){if(!this.recordingInProgress&&this.recordingChunks.length===0||(this.recordingEndTime=Date.now()-this.examStartTime,this.optionsProctoring.proctoringType!=="REALTIME"))return;let t=p3(this.recordingChunks,this.SAMPLE_RATE),r=new File([t],`EP_${this.proctoringSession.id}_${this.recordingStartTime}_${this.recordingEndTime}_${this.isSpeech?"speech":"noise"}.wav`,{type:"audio/wav"});this.uploadRecord(r),this.recordingChunks=[],this.recordingInProgress=!1}download(t){let r=URL.createObjectURL(t),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=r,n.download=t.name,n.click(),window.URL.revokeObjectURL(r)}uploadRecord(t){t&&this.upload&&this.backendToken&&this.upload.upload({file:t},this.backendToken)}hasDesiredResult(t){if(t==null)return!1;for(let r of t){let n=r.name.toLowerCase().includes("speech");if(this.optionsProctoring.proctoringType!=="REALTIME")return n;let i=parseFloat(r.score)>.22;if(n&&i)return!0}return!1}async createAudioClassifier(){let t=await bn.forAudioTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-audio@0.10.0/wasm");this.audioClassifier=await or.createFromOptions(t,{scoreThreshold:.15,maxResults:1,baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/audio_classifier/yamnet/float32/1/yamnet.tflite"}})}async streamingAudioClassification(){this.context=new AudioContext({sampleRate:this.SAMPLE_RATE});try{await this.context.audioWorklet.addModule(URL.createObjectURL(new Blob([m3],{type:"text/javascript"})))}catch{throw new Error("\u274C Error loading audio worklet module")}let t=this.context.createMediaStreamSource(this.cameraRecorder.cameraStream);this.audioWorkletNode=new AudioWorkletNode(this.context,"audio-processor"),this.audioWorkletNode.port.onmessage=r=>{let n=r.data;this.preRollBuffer.push(n),this.preRollBuffer.length>this.MAX_PRE_ROLL_CHUNKS&&this.preRollBuffer.shift(),this.recordingInProgress&&this.recordingChunks.push(n);let o=this.audioClassifier.classify(n)[0].classifications[0].categories;o.length>0&&(this.audioClassificationResult=[{name:o[0].categoryName,score:o[0].score.toFixed(3)}])},t.connect(this.audioWorkletNode),this.audioWorkletNode.connect(this.context.destination)}},m3=`
|
|
436
436
|
class AudioProcessor extends AudioWorkletProcessor {
|
|
437
437
|
bufferSize;
|
|
438
438
|
inputBuffer;
|
|
@@ -500,7 +500,7 @@ registerProcessor("audio-processor", AudioProcessor);
|
|
|
500
500
|
<circle cx="10" cy="10" r="9" stroke="#16A34A" stroke-width="2" fill="none"/>
|
|
501
501
|
<path d="M6 10L9 13L14 7" stroke="#16A34A" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
502
502
|
</svg>
|
|
503
|
-
`,this.applyStyles(v,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let k=document.createElement("span");k.innerText=f,b.appendChild(v),b.appendChild(k),c.appendChild(b)}),s.appendChild(c);let h=document.createElement("button");h.innerText="Capturar foto",h.id="position-capture-button",this.applyStyles(h,{marginTop:"10px",padding:"12px 24px",fontSize:"14px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s",alignSelf:"flex-start"}),h.onclick=()=>{if(this.connection){let f=document.getElementById("photo-message");f&&(f.innerText="N\xE3o saia da posi\xE7\xE3o atual, estamos validando o ambiente..."),n.style.display="none",this.takePicture(!0,()=>{}),h.disabled=!0,this.applyStyles(h,{backgroundColor:"#9CA3AF",cursor:"not-allowed"})}},s.appendChild(h),i.appendChild(s),t.appendChild(i);let d=document.createElement("div");this.applyStyles(d,{marginTop:"10px",fontSize:"13px",color:"#666"});let m=document.createElement("span");m.innerText="Dica: ",m.style.fontWeight="bold";let p=document.createElement("span");p.innerText="mantenha o celular est\xE1vel durante todo o processo.",d.appendChild(m),d.appendChild(p),t.appendChild(d);let g=document.getElementById("external-camera-continue");g.disabled=!0,this.applyStyles(g,{color:"#ccc",cursor:"not-allowed"})}renderImageStep(t){t.innerHTML="";let r=document.createElement("img");r.src="data:image/jpeg;base64,"+this.capturePhotoUrl,this.applyStyles(r,{maxWidth:"100%",maxHeight:"300px",borderRadius:"8px"}),t.appendChild(r);let n=document.createElement("photo-message");n.id="photo-message",n.innerText="Verifica\xE7\xE3o finalizada com sucesso.",this.applyStyles(n,{textAlign:"center",color:"#555",marginTop:"20px"}),t.appendChild(n);let i=document.getElementById("external-camera-continue");i.disabled=!1,i.innerText="Concluir",this.applyStyles(i,{width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"0 0 10px 0",cursor:"pointer",borderLeft:"2px solid rgba(0, 0, 0, .1)"}),i.onclick=()=>{this.closeCheckExternalCamera(),this.resolvePromise({result:!0})}}nextState(){this.renderCurrentStep()}async initializeWebSocketConnection(){let t=this.backend.getSocketUrl();this.connection=new as().withUrl(t,{accessTokenFactory:()=>this.context.token,transport:Ve.WebSockets,withCredentials:!1}).withAutomaticReconnect().configureLogging(L.Information).build(),this.connection.on("ReceiveMessage",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{let o=_y[n];console.log("Mensagem -> ",o),this.handleWebSocketMessage(o)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}}),this.connection.on("ReceiveAction",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{this.handleWebSocketAction(n)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}});try{await this.connection.start(),console.log("Conectado ao Hub SignalR com sucesso!")}catch(r){throw console.error("Falha ao conectar ou entrar no grupo do SignalR: ",r),new Error("N\xE3o foi poss\xEDvel conectar ao servi\xE7o em tempo real.")}}handleWebSocketAction(t){let r=document.getElementById("position-capture-button"),n=document.getElementById("photo-message"),i=document.getElementById("photo-error-banner");switch(t.command){case"Capture_Error":r&&(this.applyStyles(r,{marginTop:"30px",padding:"12px 20px",fontSize:"16px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"}),r.disabled=!1),n&&(n.innerText=""+t.message),i&&(i.style.display="flex"),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,errorMessage:t.message,success:!1});break;case"CapturePhoto":this.capturePhotoUrl=""+t.message;let o=document.getElementById("photo-icon-container");if(o&&this.capturePhotoUrl&&this.capturePhotoUrl.trim()!==""){let s=document.getElementById("img-photo");s||(o.innerHTML="",s=document.createElement("img"),s.id="img-photo",this.applyStyles(s,{width:"100%",height:"100%",objectFit:"contain",objectPosition:"center",borderRadius:"8px",display:"block"}),o.appendChild(s));let a=this.capturePhotoUrl.startsWith("data:")?this.capturePhotoUrl:"data:image/jpeg;base64,"+this.capturePhotoUrl;s.src=a,s.onload=()=>{console.log("Image loaded successfully in icon container")},s.onerror=c=>{console.error("Error loading image:",c)}}this.waitingPositionValidation==!1&&this.onTakePictureCallback({photo:this.capturePhotoUrl});break;case"Check_Transmission":t.message=="Transmission_OK"&&(this.transmissionOk=!0);break;case"Cancel":this.closeCheckExternalCamera();break;case"EnvironmentAlert":this.onRealtimeAlertsCallback({status:"ALERT",description:t.message,type:"environment_alert"});break}}handleWebSocketMessage(t){switch(this.currentStep=t,t){case 1:this.currentStep===1&&(this.nextState(),this.onQrCodeReadedCallback(!0));break;case 2:this.nextState(),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,success:!0});break;case 3:this.closeCheckExternalCamera();break;case 9:console.error("Erro recebido do processo de c\xE2mera externa."),this.closeCheckExternalCamera(),this.resolvePromise({result:!1});break}}async disconnectWebSocket(){if(this.connection)try{await this.connection.stop(),console.log("Desconectado do SignalR.")}catch(t){console.error("Erro ao desconectar do SignalR:",t)}finally{this.connection=null}}closeCheckExternalCamera(){e.isModalOpen=!1,this.disconnectWebSocket(),document.querySelector("#externalCameraCheck")?.remove()}applyStyles(t,r){for(let n in r)t.style[n]=r[n]}};var cl=class{constructor(t){this.context=t;this.deviceData=null;this.sessionStartTime=0;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1,realtimePackageSize:20,realtimeUploadInterval:30}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onLostFocusAlertRecorderCallback=t=>{};this.onFocusCallback=()=>{};this.onFocusAlertRecorderCallback=t=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new nr({type:t.type||"prod",token:t.token}),this.repository=new rs("EasyProctorDb","exams2"),this.repositoryDevices=new rs("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new Ic(this.context.credentials.cpf,this.backend)),this.appChecker=new al(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{fe.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusAlertRecorderCallback(){this.onLostFocusAlertRecorderCallback=async t=>{this.onLostFocusCallback&&this.onLostFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"lost_focus",category:"lost_focus",description:"Perda de foco no exame",begin:t.begin,end:t.end,alert:25,status:"ALERT"})}}setOnFocusAlertRecorderCallback(){this.onFocusAlertRecorderCallback=async t=>{this.onFocusCallback&&this.onFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"focus",category:"focus",description:"Retorno de foco no exame",begin:t.begin,end:t.end,alert:25,status:"OK"})}}async setOnLostFocusCallback(t){this.onLostFocusCallback=async()=>await t(),this.setOnLostFocusAlertRecorderCallback()}async setOnFocusCallback(t){this.onFocusCallback=async()=>await t(),this.setOnFocusAlertRecorderCallback()}async onChangeDevices(t={}){new Ha(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=n=>t.status&&t.status(n)}convertRealtimeCategoryToAlertCategory(t){switch(t){case"no_face_detected":return 1;case"multiple_faces_detected":return 2;case"multiple_persons_detected":return 28;case"no_person_detected":return 29;case"lost_focus":return 25;case"focus":return 25;default:return null}}convertRealtimeTypeToWarningType(t){switch(t){case"face_detection_on_stream":return 0;case"person_detection_on_stream":return 1;case"lost_focus":return 2;case"focus":return 2;default:return null}}async onRealtimeAlerts(t={}){this.setOnLostFocusAlertRecorderCallback(),this.setOnFocusAlertRecorderCallback(),this.onRealtimeAlertsCallback=async r=>{t.data&&t.data(r),this.sessionOptions.proctoringType==="REALTIME"&&(r.type==="face_detection_on_stream"||r.type==="person_detection_on_stream"||r.type==="lost_focus"||r.type==="focus")&&(r.status==="ALERT"?await this.backend.startRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,alert:this.convertRealtimeCategoryToAlertCategory(r.category)}):r.status==="OK"&&await this.backend.stopRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,warningCategoryEnum:this.convertRealtimeTypeToWarningType(r.type),alertImageBase64:await this.allRecorders.cameraRecorder.getCurrentImageBase64()}))}}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=ir){this.onChangeDevices();let r=new Yr({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Tc({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,i=new $a({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new Ac(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,n,i].filter(Boolean);return s.push(o),this.recorder=new Wa(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw e0;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Qg;t.useChallenge&&(this.extensionEasycatcher=new Va),this.extension=new ja,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await ur();await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...ir,...t},this.videoOptions=Oa(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw t0}if(this.state!="Stop")throw Xg;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Hn,this.allRecorders=this.createRecorders(this.sessionOptions);let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,fe.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${JSON.stringify(i)}`);try{t?.useExternalCamera&&await this.appChecker.startTransmission(this.proctoringId)}catch{throw r0}this.sessionStartTime=Date.now(),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),await this.recorder.startAll(),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let l in navigator)s[l]=navigator[l];fe.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
503
|
+
`,this.applyStyles(v,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",flexShrink:"0"});let k=document.createElement("span");k.innerText=f,b.appendChild(v),b.appendChild(k),c.appendChild(b)}),s.appendChild(c);let h=document.createElement("button");h.innerText="Capturar foto",h.id="position-capture-button",this.applyStyles(h,{marginTop:"10px",padding:"12px 24px",fontSize:"14px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"6px",cursor:"pointer",transition:"background-color 0.2s",alignSelf:"flex-start"}),h.onclick=()=>{if(this.connection){let f=document.getElementById("photo-message");f&&(f.innerText="N\xE3o saia da posi\xE7\xE3o atual, estamos validando o ambiente..."),n.style.display="none",this.takePicture(!0,()=>{}),h.disabled=!0,this.applyStyles(h,{backgroundColor:"#9CA3AF",cursor:"not-allowed"})}},s.appendChild(h),i.appendChild(s),t.appendChild(i);let d=document.createElement("div");this.applyStyles(d,{marginTop:"10px",fontSize:"13px",color:"#666"});let m=document.createElement("span");m.innerText="Dica: ",m.style.fontWeight="bold";let p=document.createElement("span");p.innerText="mantenha o celular est\xE1vel durante todo o processo.",d.appendChild(m),d.appendChild(p),t.appendChild(d);let g=document.getElementById("external-camera-continue");g.disabled=!0,this.applyStyles(g,{color:"#ccc",cursor:"not-allowed"})}renderImageStep(t){t.innerHTML="";let r=document.createElement("img");r.src="data:image/jpeg;base64,"+this.capturePhotoUrl,this.applyStyles(r,{maxWidth:"100%",maxHeight:"300px",borderRadius:"8px"}),t.appendChild(r);let n=document.createElement("photo-message");n.id="photo-message",n.innerText="Verifica\xE7\xE3o finalizada com sucesso.",this.applyStyles(n,{textAlign:"center",color:"#555",marginTop:"20px"}),t.appendChild(n);let i=document.getElementById("external-camera-continue");i.disabled=!1,i.innerText="Concluir",this.applyStyles(i,{width:"100%",height:"70px",backgroundColor:"#FFF",border:"none",color:"rgba(0, 0, 0, .7)",fontWeight:"bold",borderRadius:"0 0 10px 0",cursor:"pointer",borderLeft:"2px solid rgba(0, 0, 0, .1)"}),i.onclick=()=>{this.closeCheckExternalCamera(),this.resolvePromise({result:!0})}}nextState(){this.renderCurrentStep()}async initializeWebSocketConnection(){let t=this.backend.getSocketUrl();this.connection=new as().withUrl(t,{accessTokenFactory:()=>this.context.token,transport:Ve.WebSockets,withCredentials:!1,skipNegotiation:!0}).withAutomaticReconnect().configureLogging(L.Information).build(),this.connection.on("ReceiveMessage",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{let o=_y[n];console.log("Mensagem -> ",o),this.handleWebSocketMessage(o)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}}),this.connection.on("ReceiveAction",(r,n)=>{if(console.log("sessionId: ",r),console.log("Message: ",n),r!==this.externalSessionId){console.warn("Sess\xE3o diferente!");return}try{this.handleWebSocketAction(n)}catch(i){console.error("Erro ao processar mensagem do WebSocket:",i)}});try{await this.connection.start(),console.log("Conectado ao Hub SignalR com sucesso!")}catch(r){throw console.error("Falha ao conectar ou entrar no grupo do SignalR: ",r),new Error("N\xE3o foi poss\xEDvel conectar ao servi\xE7o em tempo real.")}}handleWebSocketAction(t){let r=document.getElementById("position-capture-button"),n=document.getElementById("photo-message"),i=document.getElementById("photo-error-banner");switch(t.command){case"Capture_Error":r&&(this.applyStyles(r,{marginTop:"30px",padding:"12px 20px",fontSize:"16px",fontWeight:"bold",color:"white",backgroundColor:"#16A34A",border:"none",borderRadius:"8px",cursor:"pointer",transition:"background-color 0.2s"}),r.disabled=!1),n&&(n.innerText=""+t.message),i&&(i.style.display="flex"),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,errorMessage:t.message,success:!1});break;case"CapturePhoto":this.capturePhotoUrl=""+t.message;let o=document.getElementById("photo-icon-container");if(o&&this.capturePhotoUrl&&this.capturePhotoUrl.trim()!==""){let s=document.getElementById("img-photo");s||(o.innerHTML="",s=document.createElement("img"),s.id="img-photo",this.applyStyles(s,{width:"100%",height:"100%",objectFit:"contain",objectPosition:"center",borderRadius:"8px",display:"block"}),o.appendChild(s));let a=this.capturePhotoUrl.startsWith("data:")?this.capturePhotoUrl:"data:image/jpeg;base64,"+this.capturePhotoUrl;s.src=a,s.onload=()=>{console.log("Image loaded successfully in icon container")},s.onerror=c=>{console.error("Error loading image:",c)}}this.waitingPositionValidation==!1&&this.onTakePictureCallback({photo:this.capturePhotoUrl});break;case"Check_Transmission":t.message=="Transmission_OK"&&(this.transmissionOk=!0);break;case"Cancel":this.closeCheckExternalCamera();break;case"EnvironmentAlert":this.onRealtimeAlertsCallback({status:"ALERT",description:t.message,type:"environment_alert"});break}}handleWebSocketMessage(t){switch(this.currentStep=t,t){case 1:this.currentStep===1&&(this.nextState(),this.onQrCodeReadedCallback(!0));break;case 2:this.nextState(),this.waitingPositionValidation==!0&&this.onTakePictureCallback({photo:this.capturePhotoUrl,success:!0});break;case 3:this.closeCheckExternalCamera();break;case 9:console.error("Erro recebido do processo de c\xE2mera externa."),this.closeCheckExternalCamera(),this.resolvePromise({result:!1});break}}async disconnectWebSocket(){if(this.connection)try{await this.connection.stop(),console.log("Desconectado do SignalR.")}catch(t){console.error("Erro ao desconectar do SignalR:",t)}finally{this.connection=null}}closeCheckExternalCamera(){e.isModalOpen=!1,this.disconnectWebSocket(),document.querySelector("#externalCameraCheck")?.remove()}applyStyles(t,r){for(let n in r)t.style[n]=r[n]}};var cl=class{constructor(t){this.context=t;this.deviceData=null;this.sessionStartTime=0;this.paramsConfig={audioBehaviourParameters:{recordingBitrate:128,noiseLimit:40},imageBehaviourParameters:{useUploadImage:!0,uploadInterval:20,saveVideo:!0},videoBehaviourParameters:{detectFace:!1,detectPerson:!1,detectCellPhone:!1,detectNoise:!1,detectSpeech:!1,realtimePackageSize:10,realtimeCaptureInterval:2}};this.proctoringId="";this.insights=void 0;this.state="Stop";this.serviceType="Upload";this.onStopSharingScreenCallback=()=>{};this.onLostFocusCallback=()=>{};this.onLostFocusAlertRecorderCallback=t=>{};this.onFocusCallback=()=>{};this.onFocusAlertRecorderCallback=t=>{};this.onChangeDevicesCallback=t=>{};this.onRealtimeAlertsCallback=t=>{};this.onBufferSizeErrorCallback=t=>{};this.backend=new nr({type:t.type||"prod",token:t.token}),this.repository=new rs("EasyProctorDb","exams2"),this.repositoryDevices=new rs("EasyProctorDbDevices","devices"),this.context.credentials?.cpf&&(this.auth=new Ic(this.context.credentials.cpf,this.backend)),this.appChecker=new al(this.context,r=>this.onRealtimeAlertsCallback(r))}setOnStopSharingScreenCallback(t){this.onStopSharingScreenCallback=async()=>{fe.registerStopSharingScreen(this.proctoringId,"Stop sharing screen"),this.allRecorders?.alertRecorder?.addAlert({alert:34,type:3}),this.allRecorders?.screenRecorder?.stopRecording(),t()}}setOnLostFocusAlertRecorderCallback(){this.onLostFocusAlertRecorderCallback=async t=>{this.onLostFocusCallback&&this.onLostFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"lost_focus",category:"lost_focus",description:"Perda de foco no exame",begin:t.begin,end:t.end,alert:25,status:"ALERT"})}}setOnFocusAlertRecorderCallback(){this.onFocusAlertRecorderCallback=async t=>{this.onFocusCallback&&this.onFocusCallback(),this.sessionOptions.proctoringType==="REALTIME"&&await this.onRealtimeAlertsCallback({type:"focus",category:"focus",description:"Retorno de foco no exame",begin:t.begin,end:t.end,alert:25,status:"OK"})}}async setOnLostFocusCallback(t){this.onLostFocusCallback=async()=>await t(),this.setOnLostFocusAlertRecorderCallback()}async setOnFocusCallback(t){this.onFocusCallback=async()=>await t(),this.setOnFocusAlertRecorderCallback()}async onChangeDevices(t={}){new Ha(this.repositoryDevices,this.proctoringId,this.sessionOptions,this.allRecorders).startRecording(t),this.onChangeDevicesCallback=n=>t.status&&t.status(n)}convertRealtimeCategoryToAlertCategory(t){switch(t){case"no_face_detected":return 1;case"multiple_faces_detected":return 2;case"multiple_persons_detected":return 28;case"no_person_detected":return 29;case"lost_focus":return 25;case"focus":return 25;default:return null}}convertRealtimeTypeToWarningType(t){switch(t){case"face_detection_on_stream":return 0;case"person_detection_on_stream":return 1;case"lost_focus":return 2;case"focus":return 2;default:return null}}async stopRealtimeAlert(t){let n=async i=>{if(!(i>3))try{var o=await this.backend.stopRealtimeAlert({proctoringId:this.proctoringId,begin:t.begin,end:t.end,warningCategoryEnum:this.convertRealtimeTypeToWarningType(t.type),alertImageBase64:await this.allRecorders.cameraRecorder.getCurrentImageBase64(),retry:i<2});return console.log("response stopRealtimeAlert",o),o}catch(s){return console.log("error stopRealtimeAlert",s),n(i+1)}};await n(1)}async onRealtimeAlerts(t={}){this.setOnLostFocusAlertRecorderCallback(),this.setOnFocusAlertRecorderCallback(),this.onRealtimeAlertsCallback=async r=>{t.data&&t.data(r),this.sessionOptions.proctoringType==="REALTIME"&&(r.type==="face_detection_on_stream"||r.type==="person_detection_on_stream"||r.type==="lost_focus"||r.type==="focus")&&(r.status==="ALERT"?await this.backend.startRealtimeAlert({proctoringId:this.proctoringId,begin:r.begin,end:r.end,alert:this.convertRealtimeCategoryToAlertCategory(r.category)}):r.status==="OK"&&await this.stopRealtimeAlert(r))}}setOnBufferSizeErrorCallback(t){this.onBufferSizeErrorCallback=r=>t(r)}setDeviceCheckData(t){this.deviceData=t}createRecorders(t=ir){this.onChangeDevices();let r=new Yr({cameraId:this.sessionOptions.cameraId,microphoneId:this.sessionOptions.microphoneId,onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:a=>this.onBufferSizeErrorCallback(a),proctoringType:this.sessionOptions.proctoringType,onChangeDevicesCallback:a=>this.onChangeDevicesCallback(a),onRealtimeAlertsCallback:a=>this.onRealtimeAlertsCallback(a)},{width:this.videoOptions.width,height:this.videoOptions.height,minWidth:this.videoOptions.minWidth,minHeight:this.videoOptions.minHeight},this.paramsConfig,this.backend,this.context.token),n=this.sessionOptions.captureScreen?new Tc({allowOnlyFirstMonitor:this.sessionOptions.allowOnlyFirstMonitor??!0,allowMultipleMonitors:this.sessionOptions.allowMultipleMonitors??!0,screenRecorderOptions:this.sessionOptions.screenRecorderOptions,onStopSharingScreenCallback:()=>this.onStopSharingScreenCallback(),onBufferSizeError:this.sessionOptions.onBufferSizeError,onBufferSizeErrorCallback:()=>this.onBufferSizeErrorCallback()}):void 0,i=new $a({onFocusCallback:a=>this.onFocusAlertRecorderCallback(a),onLostFocusCallback:a=>this.onLostFocusAlertRecorderCallback(a),onRealtimeAlertCallback:a=>this.onRealtimeAlertsCallback(a)},t),o=new Ac(t,this.proctoringSession,this.paramsConfig,r,a=>this.onRealtimeAlertsCallback(a),this.backend,this.context.token),s=[r,n,i].filter(Boolean);return s.push(o),this.recorder=new Wa(this.proctoringSession,s),{cameraRecorder:r,screenRecorder:n,alertRecorder:i,noiseRecorder:o}}async login(){if(!this.context.credentials?.cpf)throw e0;this.context.token=await this.auth.login()}async start(t=ir,r={}){try{if(this.context.token===void 0)throw Qg;t.useChallenge&&(this.extensionEasycatcher=new Va),this.extension=new ja,this.extension.addEventListener();let n=this.backend.selectBaseUrl(this.context.type),i=await ur();await this.repositoryDevices.save({...i,id:"devices"}),this.sessionOptions={...ir,...t},this.videoOptions=Oa(r),await this.initConfig(t.useGeolocation),await this.verifyBrowser(),this.sessionOptions.captureScreen&&await this.verifyMultipleMonitors(this.sessionOptions);try{t?.useSpyScan&&await this.spyCam.isAlive()}catch{throw t0}if(this.state!="Stop")throw Xg;this.state="Starting",await this.repository.hasSessions()&&await this.repository.clear(),this.proctoringSession=new Hn,this.allRecorders=this.createRecorders(this.sessionOptions);let o=await this.backend.confirmStart({clientId:this.context.clientId,examId:this.context.examId,token:this.context.token},this.sessionOptions,this.geolocation?this.geolocation.coords.latitude:void 0,this.geolocation?this.geolocation.coords.longitude:void 0);this.proctoringId=o.id,fe.registerDevicesChecked(this.proctoringId,!!this.deviceData,`Devices checked: ${JSON.stringify(this.deviceData)} | Devices List: ${JSON.stringify(i)}`);try{t?.useExternalCamera&&await this.appChecker.startTransmission(this.proctoringId)}catch{throw r0}this.sessionStartTime=Date.now(),this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId),this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId),this.proctoringSession.setProctoringId(this.proctoringId),await this.recorder.startAll(),t?.useSpyScan&&(this.spyCam.setProctoringId(this.proctoringId),this.spyCam.startCheckSpyCam(this.paramsConfig.spyScanInterval??5,{deviceType:3})),await this.repository.save(this.proctoringSession);let s={};for(let l in navigator)s[l]=navigator[l];fe.registerStart(this.proctoringId,!0,`Version: ${ns()}
|
|
504
504
|
Navigator: ${JSON.stringify(s)}`),o.cameraStream=this.allRecorders.cameraRecorder.cameraStream,this.allRecorders.screenRecorder&&(o.screenStream=this.allRecorders.screenRecorder.screenStream),this.state="Recording";let a=0,c=!1;return this.verifyFirstFaceInterval=setInterval(async()=>{if(this.sessionOptions.proctoringType==="REALTIME"){if(c)return;c=!0,a++;try{var l=await this.backend.verifyFace(this.proctoringId,await this.allRecorders.cameraRecorder.getCurrentImageBase64(),!(a>5));c=!1,clearInterval(this.verifyFirstFaceInterval)}catch{c=!1;return}}},1500),o}catch(n){throw console.log(n),await this.cancel(),this.proctoringId&&fe.registerStart(this.proctoringId,!1,`Token: ${this.context.token}
|
|
505
505
|
Version: ${ns()}
|
|
506
506
|
Navigator: ${navigator}
|