@incodetech/core 2.0.0-alpha.10 → 2.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,17 @@
1
1
  import { a as __toDynamicImportESM } from "./chunk-C_Yo44FK.esm.js";
2
2
 
3
+ //#region ../infra/src/capabilities/platform.ts
4
+ function isIOS(userAgent) {
5
+ const ua = userAgent || (typeof navigator !== "undefined" ? navigator.userAgent : "");
6
+ const hasTouchPoints = typeof navigator !== "undefined" ? navigator.maxTouchPoints > 0 : false;
7
+ return /iPad|iPhone|iPod/.test(ua) || /Mac OS/.test(ua) && hasTouchPoints || /iPadOS/.test(ua);
8
+ }
9
+ function isAndroid(userAgent) {
10
+ const ua = userAgent || (typeof navigator !== "undefined" ? navigator.userAgent : "");
11
+ return /Android/i.test(ua);
12
+ }
13
+
14
+ //#endregion
3
15
  //#region ../infra/src/http/createApi.ts
4
16
  var FetchHttpError = class extends Error {
5
17
  constructor(status, statusText, url, method, headers, data) {
@@ -552,8 +564,15 @@ var StreamCanvasCapture = class {
552
564
  tick() {
553
565
  if (!this.ctx) return;
554
566
  if (this.video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) return;
567
+ const videoWidth = this.video.videoWidth;
568
+ const videoHeight = this.video.videoHeight;
569
+ if (videoWidth === 0 || videoHeight === 0) return;
570
+ if (this.canvas.width !== videoWidth || this.canvas.height !== videoHeight) {
571
+ this.canvas.width = videoWidth;
572
+ this.canvas.height = videoHeight;
573
+ }
555
574
  try {
556
- this.ctx.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
575
+ this.ctx.drawImage(this.video, 0, 0);
557
576
  this.hasFrame = true;
558
577
  } catch {
559
578
  this.hasFrame = false;
@@ -603,17 +622,528 @@ var StreamCanvasProcessingSession = class {
603
622
  }
604
623
  };
605
624
 
625
+ //#endregion
626
+ //#region ../infra/src/media/VideoTrimmer.ts
627
+ async function getDurationBySeek(videoBlob) {
628
+ const video = document.createElement("video");
629
+ video.preload = "metadata";
630
+ video.src = URL.createObjectURL(videoBlob);
631
+ try {
632
+ if (!Number.isFinite(video.duration)) {
633
+ video.currentTime = Number.MAX_SAFE_INTEGER;
634
+ await new Promise((resolve) => {
635
+ const onDurationChange = () => {
636
+ if (Number.isFinite(video.duration)) {
637
+ video.removeEventListener("durationchange", onDurationChange);
638
+ video.removeEventListener("timeupdate", onTimeUpdate);
639
+ resolve(video.duration);
640
+ }
641
+ };
642
+ const onTimeUpdate = () => {
643
+ if (Number.isFinite(video.duration)) {
644
+ video.removeEventListener("timeupdate", onTimeUpdate);
645
+ video.removeEventListener("durationchange", onDurationChange);
646
+ resolve(video.duration);
647
+ }
648
+ };
649
+ video.addEventListener("durationchange", onDurationChange);
650
+ video.addEventListener("timeupdate", onTimeUpdate);
651
+ });
652
+ }
653
+ const duration = video.duration;
654
+ return Number.isFinite(duration) ? duration : null;
655
+ } finally {
656
+ URL.revokeObjectURL(video.src);
657
+ video.src = "";
658
+ }
659
+ }
660
+ async function trimLastNSecondsUsingPlayback(videoBlob, seconds) {
661
+ console.log("[VideoTrimmer] Starting playback-based trimming...");
662
+ const video = document.createElement("video");
663
+ video.preload = "metadata";
664
+ video.playsInline = true;
665
+ video.muted = true;
666
+ const videoURL = URL.createObjectURL(videoBlob);
667
+ video.src = videoURL;
668
+ const duration = await getDurationBySeek(videoBlob);
669
+ console.log("[VideoTrimmer] Video duration:", duration);
670
+ if (!duration || duration < seconds) {
671
+ console.log("[VideoTrimmer] Video too short, returning original");
672
+ URL.revokeObjectURL(videoURL);
673
+ return videoBlob;
674
+ }
675
+ const startTime = Math.max(0, Math.floor(duration) - seconds);
676
+ console.log("[VideoTrimmer] Trimming from", startTime, "to", duration);
677
+ await new Promise((resolve) => {
678
+ if (video.readyState >= 2) resolve();
679
+ else video.addEventListener("loadedmetadata", () => resolve(), { once: true });
680
+ });
681
+ const canvas = document.createElement("canvas");
682
+ canvas.width = 230;
683
+ canvas.height = 320;
684
+ const captureFps = isAndroid() ? 15 : 24;
685
+ const stream = canvas.captureStream(captureFps);
686
+ const ctx = canvas.getContext("2d");
687
+ video.currentTime = startTime;
688
+ await new Promise((resolve) => {
689
+ video.addEventListener("seeked", () => resolve(), { once: true });
690
+ });
691
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
692
+ const mimeType = videoBlob.type || (MediaRecorder.isTypeSupported("video/webm") ? "video/webm" : "video/mp4");
693
+ const mediaRecorder = new MediaRecorder(stream.clone(), {
694
+ mimeType,
695
+ videoBitsPerSecond: 5e5,
696
+ bitsPerSecond: 5e5
697
+ });
698
+ const chunks = [];
699
+ mediaRecorder.ondataavailable = (event) => {
700
+ if (event.data.size > 0) chunks.push(event.data);
701
+ };
702
+ const recordingPromise = new Promise((resolve) => {
703
+ mediaRecorder.onstop = () => {
704
+ console.log("[VideoTrimmer] Recording stopped, chunks:", chunks.length);
705
+ const trimmedBlob = new Blob(chunks, { type: mimeType });
706
+ URL.revokeObjectURL(videoURL);
707
+ mediaRecorder.stream?.getTracks().forEach((track) => track.stop());
708
+ stream.getTracks().forEach((track) => track.stop());
709
+ video.src = "";
710
+ console.log("[VideoTrimmer] Playback-based trimming complete, size:", trimmedBlob.size);
711
+ resolve(trimmedBlob);
712
+ };
713
+ });
714
+ video.addEventListener("play", () => {
715
+ console.log("[VideoTrimmer] Video playing, starting recording...");
716
+ function drawVideo() {
717
+ if (video.currentTime >= duration) {
718
+ console.log("[VideoTrimmer] Reached end, stopping...");
719
+ mediaRecorder.stop();
720
+ video.pause();
721
+ return;
722
+ }
723
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
724
+ requestAnimationFrame(drawVideo);
725
+ }
726
+ drawVideo();
727
+ setTimeout(() => {
728
+ console.log("[VideoTrimmer] Starting MediaRecorder...");
729
+ mediaRecorder.start(100);
730
+ }, 500);
731
+ });
732
+ console.log("[VideoTrimmer] Starting video playback...");
733
+ video.play().catch((err) => {
734
+ console.error("[VideoTrimmer] Play failed:", err);
735
+ URL.revokeObjectURL(videoURL);
736
+ });
737
+ return await recordingPromise;
738
+ }
739
+ async function trimLastNSeconds(videoBlob, seconds) {
740
+ console.log(`[VideoTrimmer] trimLastNSeconds called (trim to ${seconds}s from ${videoBlob.size} bytes)`);
741
+ console.log("[VideoTrimmer] Using playback-based trimming");
742
+ return await trimLastNSecondsUsingPlayback(videoBlob, seconds);
743
+ }
744
+
745
+ //#endregion
746
+ //#region ../infra/src/providers/browser/DeepsightRecordingProvider.ts
747
+ function toBase64(videoBlob) {
748
+ return new Promise((resolve, reject) => {
749
+ const reader = new FileReader();
750
+ reader.onloadend = () => {
751
+ const base64 = reader.result.split(",")[1];
752
+ resolve(base64);
753
+ };
754
+ reader.onerror = () => reject(reader.error ?? /* @__PURE__ */ new Error("FileReader error"));
755
+ reader.readAsDataURL(videoBlob);
756
+ });
757
+ }
758
+ function getSupportedMediaRecorderMimeType() {
759
+ const possibleTypes = isIOS() ? [
760
+ "video/mp4",
761
+ "video/webm",
762
+ "video/webm;codecs=vp9",
763
+ "video/webm;codecs=vp8"
764
+ ] : [
765
+ "video/webm",
766
+ "video/webm;codecs=vp9",
767
+ "video/webm;codecs=vp8",
768
+ "video/mp4"
769
+ ];
770
+ for (const type of possibleTypes) if (MediaRecorder.isTypeSupported(type)) return type;
771
+ return "";
772
+ }
773
+ function getAdaptiveMediaRecorderOptions() {
774
+ const mimeType = getSupportedMediaRecorderMimeType();
775
+ if (isIOS()) return {
776
+ mimeType,
777
+ videoBitsPerSecond: 1e6,
778
+ bitsPerSecond: 1e6
779
+ };
780
+ return {
781
+ mimeType,
782
+ videoBitsPerSecond: 5e5,
783
+ bitsPerSecond: 5e5
784
+ };
785
+ }
786
+ var DeepsightRecordingProvider = class {
787
+ constructor() {
788
+ this.mediaRecorder = null;
789
+ this._isRecording = false;
790
+ this._hasError = false;
791
+ this._error = null;
792
+ this.mimeType = "";
793
+ this.stream = null;
794
+ this.pauseRecordingBound = this.pauseRecording.bind(this);
795
+ }
796
+ get isRecording() {
797
+ return this._isRecording;
798
+ }
799
+ get hasError() {
800
+ return this._hasError;
801
+ }
802
+ get error() {
803
+ return this._error;
804
+ }
805
+ startRecording(stream) {
806
+ this.reset();
807
+ this.registerEventListeners();
808
+ this.stream = stream;
809
+ try {
810
+ const options = getAdaptiveMediaRecorderOptions();
811
+ this.mimeType = options.mimeType;
812
+ const recorder = new MediaRecorder(stream.clone(), options);
813
+ recorder.onerror = (event) => {
814
+ this._error = `Recording error: ${event}`;
815
+ this._isRecording = false;
816
+ this._hasError = true;
817
+ };
818
+ recorder.start();
819
+ this.mediaRecorder = recorder;
820
+ this._isRecording = true;
821
+ this._error = null;
822
+ this._hasError = false;
823
+ } catch (err) {
824
+ console.error(`Failed to start recording: ${err}`);
825
+ this._error = `Failed to start recording: ${err}`;
826
+ this._hasError = true;
827
+ }
828
+ }
829
+ async stopRecording(trimSeconds, encrypt, generateChecksum) {
830
+ const recorder = this.mediaRecorder;
831
+ return new Promise((resolve, reject) => {
832
+ this.removeEventListeners();
833
+ if (recorder && this._isRecording) {
834
+ const chunks = [];
835
+ recorder.ondataavailable = (event) => {
836
+ if (event.data.size > 0) chunks.push(event.data);
837
+ };
838
+ recorder.onstop = async () => {
839
+ try {
840
+ const trimmedVideo = await trimLastNSeconds(new Blob(chunks, { type: this.mimeType }), trimSeconds);
841
+ const encryptedVideoBase64 = encrypt(await toBase64(trimmedVideo));
842
+ generateChecksum(await trimmedVideo.arrayBuffer());
843
+ this._isRecording = false;
844
+ resolve({
845
+ trimmedBlob: trimmedVideo,
846
+ encryptedVideo: encryptedVideoBase64
847
+ });
848
+ } catch (error) {
849
+ this._isRecording = false;
850
+ this._error = `Recording stop failed: ${error}`;
851
+ this._hasError = true;
852
+ reject(error);
853
+ }
854
+ };
855
+ recorder.stop();
856
+ this._isRecording = false;
857
+ } else resolve({
858
+ trimmedBlob: new Blob([], { type: this.mimeType }),
859
+ encryptedVideo: ""
860
+ });
861
+ recorder?.stream?.getTracks().forEach((track) => track.stop());
862
+ });
863
+ }
864
+ reset() {
865
+ this._isRecording = false;
866
+ this._error = null;
867
+ this._hasError = false;
868
+ }
869
+ pauseRecording() {
870
+ if (!this._isRecording) return;
871
+ if (this.mediaRecorder?.state === "recording") try {
872
+ this.mediaRecorder.pause();
873
+ } catch {}
874
+ }
875
+ registerEventListeners() {
876
+ document.addEventListener("visibilitychange", this.pauseRecordingBound);
877
+ }
878
+ removeEventListeners() {
879
+ document.removeEventListener("visibilitychange", this.pauseRecordingBound);
880
+ }
881
+ };
882
+
883
+ //#endregion
884
+ //#region ../infra/src/providers/browser/MotionSensorProvider.ts
885
+ var MotionSensorProvider = class {
886
+ constructor(thresholds) {
887
+ this._isRunning = false;
888
+ this._hasPermission = true;
889
+ this.acl = null;
890
+ this.gyro = null;
891
+ this.minNumberOfFrames = 3;
892
+ this.maxFrequency = 60;
893
+ this.emptyParams = {
894
+ meanX: 0,
895
+ meanY: 0,
896
+ meanZ: 0,
897
+ m2X: 0,
898
+ m2Y: 0,
899
+ m2Z: 0,
900
+ cumulativeAbsErrorX: 0,
901
+ cumulativeAbsErrorY: 0,
902
+ cumulativeAbsErrorZ: 0,
903
+ ptsNum: 0
904
+ };
905
+ this.paramsAcc = { ...this.emptyParams };
906
+ this.paramsGyro = { ...this.emptyParams };
907
+ this.paramsAccGrOld = { ...this.emptyParams };
908
+ this.paramsAccOld = { ...this.emptyParams };
909
+ this.paramsGyroscopeOld = { ...this.emptyParams };
910
+ this.paramsOrientationOld = { ...this.emptyParams };
911
+ this.deviceMotionListener = (event) => {
912
+ if (event.accelerationIncludingGravity) {
913
+ const accGrVal = {
914
+ x: event.accelerationIncludingGravity.x,
915
+ y: event.accelerationIncludingGravity.y,
916
+ z: event.accelerationIncludingGravity.z
917
+ };
918
+ if (this.checkFields(accGrVal)) {
919
+ this.paramsAccGrOld.ptsNum += 1;
920
+ this.updateParams(this.paramsAccGrOld, accGrVal);
921
+ }
922
+ }
923
+ if (event.acceleration) {
924
+ const accVal = {
925
+ x: event.acceleration.x,
926
+ y: event.acceleration.y,
927
+ z: event.acceleration.z
928
+ };
929
+ if (this.checkFields(accVal)) {
930
+ this.paramsAccOld.ptsNum += 1;
931
+ this.updateParams(this.paramsAccOld, accVal);
932
+ }
933
+ }
934
+ if (event.rotationRate) {
935
+ const gyroVal = {
936
+ x: event.rotationRate.alpha,
937
+ y: event.rotationRate.beta,
938
+ z: event.rotationRate.gamma
939
+ };
940
+ if (this.checkFields(gyroVal)) {
941
+ this.paramsGyroscopeOld.ptsNum += 1;
942
+ this.updateParams(this.paramsGyroscopeOld, gyroVal);
943
+ }
944
+ }
945
+ };
946
+ this.deviceOrientationListener = (event) => {
947
+ const orientationVal = {
948
+ x: event.alpha,
949
+ y: event.beta,
950
+ z: event.gamma
951
+ };
952
+ if (this.checkFields(orientationVal)) {
953
+ this.paramsOrientationOld.ptsNum += 1;
954
+ this.updateParams(this.paramsOrientationOld, orientationVal);
955
+ }
956
+ };
957
+ this.thresholds = {
958
+ accThreshold: thresholds?.accThreshold ?? .3,
959
+ gyroThreshold: thresholds?.gyroThreshold ?? .3,
960
+ accGrOldThreshold: thresholds?.accGrOldThreshold ?? .3,
961
+ accOldThreshold: thresholds?.accOldThreshold ?? .3,
962
+ gyroscopeOldThreshold: thresholds?.gyroscopeOldThreshold ?? 10,
963
+ orientationOldThreshold: thresholds?.orientationOldThreshold ?? 10,
964
+ maeAccThreshold: thresholds?.maeAccThreshold ?? .3,
965
+ maeGyroThreshold: thresholds?.maeGyroThreshold ?? .3,
966
+ maeAccGrOldThreshold: thresholds?.maeAccGrOldThreshold ?? .3,
967
+ maeAccOldThreshold: thresholds?.maeAccOldThreshold ?? .3,
968
+ maeGyroscopeOldThreshold: thresholds?.maeGyroscopeOldThreshold ?? 10,
969
+ maeOrientationOldThreshold: thresholds?.maeOrientationOldThreshold ?? 10
970
+ };
971
+ }
972
+ get isRunning() {
973
+ return this._isRunning;
974
+ }
975
+ get hasPermission() {
976
+ return this._hasPermission;
977
+ }
978
+ async requestPermission() {
979
+ if (typeof DeviceMotionEvent !== "undefined" && typeof DeviceMotionEvent.requestPermission === "function") {
980
+ sessionStorage.setItem("motionSensorsPermissionsRequested", String(true));
981
+ try {
982
+ if (await DeviceMotionEvent.requestPermission() !== "granted") {
983
+ this._hasPermission = false;
984
+ return "denied";
985
+ }
986
+ return "granted";
987
+ } catch {
988
+ this._hasPermission = false;
989
+ return "denied";
990
+ }
991
+ }
992
+ return "not-required";
993
+ }
994
+ initializeAccelerometer() {
995
+ if (!("Accelerometer" in window)) return;
996
+ try {
997
+ const AccelerometerConstructor = window.Accelerometer;
998
+ if (AccelerometerConstructor) {
999
+ this.acl = new AccelerometerConstructor({ frequency: this.maxFrequency });
1000
+ this.acl.addEventListener("reading", () => this.updateAcc());
1001
+ }
1002
+ } catch {}
1003
+ }
1004
+ initializeGyroscope() {
1005
+ if (!("Gyroscope" in window)) return;
1006
+ try {
1007
+ const GyroscopeConstructor = window.Gyroscope;
1008
+ if (GyroscopeConstructor) {
1009
+ this.gyro = new GyroscopeConstructor({ frequency: this.maxFrequency });
1010
+ this.gyro.addEventListener("reading", () => this.updateGyro());
1011
+ }
1012
+ } catch {}
1013
+ }
1014
+ async start() {
1015
+ if (this._isRunning || !this._hasPermission) return;
1016
+ try {
1017
+ this.initializeAccelerometer();
1018
+ if (this.acl) this.acl.start();
1019
+ } catch {}
1020
+ try {
1021
+ this.initializeGyroscope();
1022
+ if (this.gyro) this.gyro.start();
1023
+ } catch {}
1024
+ window.addEventListener("devicemotion", this.deviceMotionListener);
1025
+ window.addEventListener("deviceorientation", this.deviceOrientationListener);
1026
+ this._isRunning = true;
1027
+ }
1028
+ stop() {
1029
+ this._isRunning = false;
1030
+ if (this.acl) this.acl.stop();
1031
+ if (this.gyro) this.gyro.stop();
1032
+ window.removeEventListener("devicemotion", this.deviceMotionListener);
1033
+ window.removeEventListener("deviceorientation", this.deviceOrientationListener);
1034
+ this.paramsAcc = { ...this.emptyParams };
1035
+ this.paramsGyro = { ...this.emptyParams };
1036
+ this.paramsAccGrOld = { ...this.emptyParams };
1037
+ this.paramsAccOld = { ...this.emptyParams };
1038
+ this.paramsGyroscopeOld = { ...this.emptyParams };
1039
+ this.paramsOrientationOld = { ...this.emptyParams };
1040
+ }
1041
+ updateAcc() {
1042
+ if (!this._isRunning || !this.acl) return;
1043
+ this.paramsAcc.ptsNum += 1;
1044
+ const val = {
1045
+ x: this.acl.x,
1046
+ y: this.acl.y,
1047
+ z: this.acl.z
1048
+ };
1049
+ if (this.checkFields(val)) this.updateParams(this.paramsAcc, val);
1050
+ }
1051
+ updateGyro() {
1052
+ if (!this._isRunning || !this.gyro) return;
1053
+ this.paramsGyro.ptsNum += 1;
1054
+ const val = {
1055
+ x: this.gyro.x,
1056
+ y: this.gyro.y,
1057
+ z: this.gyro.z
1058
+ };
1059
+ if (this.checkFields(val)) this.updateParams(this.paramsGyro, val);
1060
+ }
1061
+ check() {
1062
+ if (!this._hasPermission) return "UNCLEAR";
1063
+ const result = this.checkStability();
1064
+ return result === null ? "UNCLEAR" : result ? "FAIL" : "PASS";
1065
+ }
1066
+ checkStability() {
1067
+ if (!this._isRunning) return null;
1068
+ const filteredStdChecks = [
1069
+ this.gyro ? this.isBelowStdThreshold(this.paramsGyro, this.thresholds.gyroThreshold) : null,
1070
+ this.acl ? this.isBelowStdThreshold(this.paramsAcc, this.thresholds.accThreshold) : null,
1071
+ this.isBelowStdThreshold(this.paramsAccGrOld, this.thresholds.accGrOldThreshold),
1072
+ this.isBelowStdThreshold(this.paramsAccOld, this.thresholds.accOldThreshold),
1073
+ this.isBelowStdThreshold(this.paramsGyroscopeOld, this.thresholds.gyroscopeOldThreshold),
1074
+ this.isBelowStdThreshold(this.paramsOrientationOld, this.thresholds.orientationOldThreshold)
1075
+ ].filter((check) => check !== null);
1076
+ const finalStdCheck = filteredStdChecks.length > 0 ? filteredStdChecks.every((check) => check) : null;
1077
+ const filteredMaeChecks = [
1078
+ this.gyro ? this.isBelowMaeThreshold(this.paramsGyro, this.thresholds.maeGyroThreshold) : null,
1079
+ this.acl ? this.isBelowMaeThreshold(this.paramsAcc, this.thresholds.maeAccThreshold) : null,
1080
+ this.isBelowMaeThreshold(this.paramsAccGrOld, this.thresholds.maeAccGrOldThreshold),
1081
+ this.isBelowMaeThreshold(this.paramsAccOld, this.thresholds.maeAccOldThreshold),
1082
+ this.isBelowMaeThreshold(this.paramsGyroscopeOld, this.thresholds.maeGyroscopeOldThreshold),
1083
+ this.isBelowMaeThreshold(this.paramsOrientationOld, this.thresholds.maeOrientationOldThreshold)
1084
+ ].filter((check) => check !== null);
1085
+ const finalMaeCheck = filteredMaeChecks.length > 0 ? filteredMaeChecks.every((check) => check) : null;
1086
+ return finalStdCheck === null ? finalMaeCheck === null ? null : finalMaeCheck : finalMaeCheck !== null ? finalStdCheck && finalMaeCheck : finalStdCheck;
1087
+ }
1088
+ updateParams(params, val) {
1089
+ const deltaX = val.x - params.meanX;
1090
+ const deltaY = val.y - params.meanY;
1091
+ const deltaZ = val.z - params.meanZ;
1092
+ params.meanX += deltaX / params.ptsNum;
1093
+ params.meanY += deltaY / params.ptsNum;
1094
+ params.meanZ += deltaZ / params.ptsNum;
1095
+ params.m2X += deltaX * (val.x - params.meanX);
1096
+ params.m2Y += deltaY * (val.y - params.meanY);
1097
+ params.m2Z += deltaZ * (val.z - params.meanZ);
1098
+ params.cumulativeAbsErrorX += Math.abs(val.x - params.meanX);
1099
+ params.cumulativeAbsErrorY += Math.abs(val.y - params.meanY);
1100
+ params.cumulativeAbsErrorZ += Math.abs(val.z - params.meanZ);
1101
+ }
1102
+ calculateStd(params) {
1103
+ const variance = {
1104
+ x: params.m2X / params.ptsNum,
1105
+ y: params.m2Y / params.ptsNum,
1106
+ z: params.m2Z / params.ptsNum
1107
+ };
1108
+ return {
1109
+ x: Math.sqrt(variance.x),
1110
+ y: Math.sqrt(variance.y),
1111
+ z: Math.sqrt(variance.z)
1112
+ };
1113
+ }
1114
+ calculateMae(params) {
1115
+ return {
1116
+ x: params.cumulativeAbsErrorX / params.ptsNum,
1117
+ y: params.cumulativeAbsErrorY / params.ptsNum,
1118
+ z: params.cumulativeAbsErrorZ / params.ptsNum
1119
+ };
1120
+ }
1121
+ checkFields(point) {
1122
+ return point.x !== null && point.y !== null && point.z !== null;
1123
+ }
1124
+ isBelowStdThreshold(params, threshold) {
1125
+ if (params.ptsNum < this.minNumberOfFrames) return null;
1126
+ const std = this.calculateStd(params);
1127
+ return std.x < threshold && std.y < threshold && std.z < threshold;
1128
+ }
1129
+ isBelowMaeThreshold(params, threshold) {
1130
+ if (params.ptsNum < this.minNumberOfFrames) return null;
1131
+ const mae = this.calculateMae(params);
1132
+ return mae.x < threshold && mae.y < threshold && mae.z < threshold;
1133
+ }
1134
+ };
1135
+
606
1136
  //#endregion
607
1137
  //#region ../infra/src/providers/browser/openviduLazy.ts
608
1138
  let openViduImport;
609
1139
  async function enableProdModeBeforeLoad() {
610
- const { OpenViduLogger } = await import("./OpenViduLogger-BdPfiZO6.esm.js").then(__toDynamicImportESM(1));
1140
+ const { OpenViduLogger } = await import("./OpenViduLogger-20ZYS-mT.esm.js").then(__toDynamicImportESM(1));
611
1141
  OpenViduLogger.getInstance().enableProdMode();
612
1142
  }
613
1143
  async function loadOpenVidu() {
614
1144
  if (openViduImport) return openViduImport;
615
1145
  await enableProdModeBeforeLoad();
616
- openViduImport = import("./lib-Bu9XGMBW.esm.js").then(__toDynamicImportESM(1));
1146
+ openViduImport = import("./lib-CykGFCEr.esm.js").then(__toDynamicImportESM(1));
617
1147
  return openViduImport;
618
1148
  }
619
1149
 
@@ -701,6 +1231,28 @@ var OpenViduRecordingProvider = class {
701
1231
  }
702
1232
  };
703
1233
 
1234
+ //#endregion
1235
+ //#region ../infra/src/providers/browser/VisibilityProvider.ts
1236
+ var VisibilityProvider = class {
1237
+ constructor() {
1238
+ this._wasBackgrounded = false;
1239
+ this.visibilityChangeHandler = this.onVisibilityChange.bind(this);
1240
+ document.addEventListener("visibilitychange", this.visibilityChangeHandler);
1241
+ }
1242
+ get wasBackgrounded() {
1243
+ return this._wasBackgrounded;
1244
+ }
1245
+ reset() {
1246
+ this._wasBackgrounded = false;
1247
+ }
1248
+ cleanup() {
1249
+ document.removeEventListener("visibilitychange", this.visibilityChangeHandler);
1250
+ }
1251
+ onVisibilityChange() {
1252
+ if (document.hidden) this._wasBackgrounded = true;
1253
+ }
1254
+ };
1255
+
704
1256
  //#endregion
705
1257
  //#region ../infra/src/wasm/IdCaptureModelType.ts
706
1258
  let IdCaptureModelType = /* @__PURE__ */ function(IdCaptureModelType$1) {
@@ -1129,6 +1681,10 @@ var MlWasmJSApi = class MlWasmJSApi {
1129
1681
  this.checkWasmInitialization("Unable to pc, cpp API hasn't been initialized");
1130
1682
  await this.wasmCallWrapper(this.utilityApi.pc.bind(this.utilityApi), [deviceId]);
1131
1683
  }
1684
+ ckvcks(data) {
1685
+ this.checkWasmInitialization("Unable to ckvcks, cpp API hasn't been initialized");
1686
+ this.utilityApi.ckvcks(data);
1687
+ }
1132
1688
  pipelineTypeToWasmEnum(type) {
1133
1689
  switch (type) {
1134
1690
  case WasmPipelineType.IdBlurGlarePipeline: return this.wasmModule.PipelineType.IdBlurGlarePipeline;
@@ -1632,8 +2188,77 @@ var WasmUtilProvider = class WasmUtilProvider extends BaseWasmProvider {
1632
2188
  await this.initializeBase(config, pipeline);
1633
2189
  }
1634
2190
  encryptImage(image) {
2191
+ this.ensureInitialized();
1635
2192
  return mlWasmJSApi_default.ens(image);
1636
2193
  }
2194
+ setSdkVersion(version) {
2195
+ this.ensureInitialized();
2196
+ mlWasmJSApi_default.setSdkVersion(version);
2197
+ }
2198
+ setSdkPlatform(platform) {
2199
+ this.ensureInitialized();
2200
+ mlWasmJSApi_default.setSdkPlatform(platform);
2201
+ }
2202
+ setDeviceInfo(deviceInfo, overrideExisting = true) {
2203
+ this.ensureInitialized();
2204
+ mlWasmJSApi_default.setDeviceInfo(deviceInfo, overrideExisting);
2205
+ }
2206
+ setBrowserInfo(browserInfo, overrideExisting = true) {
2207
+ this.ensureInitialized();
2208
+ mlWasmJSApi_default.setBrowserInfo(browserInfo, overrideExisting);
2209
+ }
2210
+ setCameraInfo(cameraInfo, overrideExisting = true) {
2211
+ this.ensureInitialized();
2212
+ mlWasmJSApi_default.setCameraInfo(cameraInfo, overrideExisting);
2213
+ }
2214
+ setMotionStatus(status) {
2215
+ this.ensureInitialized();
2216
+ mlWasmJSApi_default.setMotionStatus(status);
2217
+ }
2218
+ setBackgroundMode(backgroundMode) {
2219
+ this.ensureInitialized();
2220
+ mlWasmJSApi_default.setBackgroundMode(backgroundMode);
2221
+ }
2222
+ setZc(zc) {
2223
+ this.ensureInitialized();
2224
+ mlWasmJSApi_default.setZc(zc);
2225
+ }
2226
+ setInspectorOpened(opened) {
2227
+ this.ensureInitialized();
2228
+ mlWasmJSApi_default.setInspectorOpened(opened);
2229
+ }
2230
+ getMetadata() {
2231
+ this.ensureInitialized();
2232
+ return mlWasmJSApi_default.getMetadata();
2233
+ }
2234
+ async analyzeFrame(image) {
2235
+ this.ensureInitialized();
2236
+ await mlWasmJSApi_default.analyzeFrame(image);
2237
+ }
2238
+ getCheck() {
2239
+ this.ensureInitialized();
2240
+ return mlWasmJSApi_default.getCheck();
2241
+ }
2242
+ estimatePerformance() {
2243
+ this.ensureInitialized();
2244
+ return mlWasmJSApi_default.estimatePerformance();
2245
+ }
2246
+ isVirtualCamera(label) {
2247
+ this.ensureInitialized();
2248
+ return mlWasmJSApi_default.isVirtualCamera(label);
2249
+ }
2250
+ async poc(output) {
2251
+ this.ensureInitialized();
2252
+ await mlWasmJSApi_default.poc(output);
2253
+ }
2254
+ ckvcks(data) {
2255
+ this.ensureInitialized();
2256
+ mlWasmJSApi_default.ckvcks(data);
2257
+ }
2258
+ async getVersions() {
2259
+ this.ensureInitialized();
2260
+ return mlWasmJSApi_default.getVersions();
2261
+ }
1637
2262
  };
1638
2263
 
1639
2264
  //#endregion
@@ -1646,6 +2271,9 @@ function setClient(httpClient) {
1646
2271
  function setToken(token) {
1647
2272
  currentToken = token;
1648
2273
  }
2274
+ function getToken() {
2275
+ return currentToken;
2276
+ }
1649
2277
  function getApi() {
1650
2278
  if (!client) throw new Error("SDK not configured. Call setup({ apiURL: \"...\" }) first.");
1651
2279
  return client;
@@ -1692,6 +2320,7 @@ const endpoints = {
1692
2320
  recordingCreateSessionV2: "/omni/recordings/create-session/v2",
1693
2321
  recordingStartV2: "/omni/recordings/record-start/v2",
1694
2322
  recordingStopV2: "/omni/recordings/record-stop/v2",
2323
+ deepsightVideoImport: "/omni/recordings/import",
1695
2324
  phone: "/omni/add/phone",
1696
2325
  phoneInstant: "/omni/instant/add/phone",
1697
2326
  getPhone: "/omni/get/phone",
@@ -1703,4 +2332,4 @@ const endpoints = {
1703
2332
  };
1704
2333
 
1705
2334
  //#endregion
1706
- export { createApi_default as _, setClient as a, FaceDetectionProvider as c, StreamCanvasProcessingSession as d, StreamCanvasCapture as f, createManager as g, stopCameraStream as h, resetApi as i, warmupWasm as l, requestCameraAccess as m, api as n, setToken as o, queryCameraPermission as p, getApi as r, WasmUtilProvider as s, endpoints as t, OpenViduRecordingProvider as u };
2335
+ export { queryCameraPermission as _, resetApi as a, createManager as b, WasmUtilProvider as c, VisibilityProvider as d, OpenViduRecordingProvider as f, StreamCanvasCapture as g, StreamCanvasProcessingSession as h, getToken as i, FaceDetectionProvider as l, DeepsightRecordingProvider as m, api as n, setClient as o, MotionSensorProvider as p, getApi as r, setToken as s, endpoints as t, warmupWasm as u, requestCameraAccess as v, createApi_default as x, stopCameraStream as y };