@privateid/ultrapass-web-sdk 1.3.1 → 1.3.2-1300478

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +75 -75
  2. package/dist/apiUtils.d.ts +46 -46
  3. package/dist/apiUtils.js +922 -922
  4. package/dist/application/index.d.ts +7 -7
  5. package/dist/application/index.js +27 -27
  6. package/dist/application/modules/core/document/DocumentService.d.ts +22 -22
  7. package/dist/application/modules/core/document/DocumentService.js +254 -254
  8. package/dist/application/modules/core/document/document.constants.d.ts +15 -15
  9. package/dist/application/modules/core/document/document.constants.js +21 -21
  10. package/dist/application/modules/core/document/document.domain.d.ts +7 -7
  11. package/dist/application/modules/core/document/document.domain.js +1 -1
  12. package/dist/application/modules/core/document/document.types.d.ts +17 -17
  13. package/dist/application/modules/core/document/document.types.js +1 -1
  14. package/dist/application/modules/core/document/document.utils.d.ts +3 -3
  15. package/dist/application/modules/core/document/document.utils.js +58 -58
  16. package/dist/application/modules/core/document/index.d.ts +3 -3
  17. package/dist/application/modules/core/document/index.js +1 -1
  18. package/dist/application/modules/core/face/FaceService.d.ts +33 -33
  19. package/dist/application/modules/core/face/FaceService.js +228 -221
  20. package/dist/application/modules/core/face/FaceService.js.map +1 -1
  21. package/dist/application/modules/core/face/face.constants.d.ts +53 -53
  22. package/dist/application/modules/core/face/face.constants.js +53 -53
  23. package/dist/application/modules/core/face/face.domain.d.ts +10 -10
  24. package/dist/application/modules/core/face/face.domain.js +1 -1
  25. package/dist/application/modules/core/face/face.types.d.ts +41 -38
  26. package/dist/application/modules/core/face/face.types.js +1 -1
  27. package/dist/application/modules/core/face/face.utils.d.ts +15 -15
  28. package/dist/application/modules/core/face/face.utils.js +101 -101
  29. package/dist/application/modules/core/face/index.d.ts +3 -3
  30. package/dist/application/modules/core/face/index.js +1 -1
  31. package/dist/application/modules/global/shared.constants.d.ts +2 -2
  32. package/dist/application/modules/global/shared.constants.js +2 -2
  33. package/dist/application/modules/global/shared.utils.d.ts +25 -25
  34. package/dist/application/modules/global/shared.utils.js +100 -100
  35. package/dist/application/modules/global/shared.utils.js.map +1 -1
  36. package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.d.ts +9 -0
  37. package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js +32 -0
  38. package/dist/application/modules/internal/feature-flag/LDFeatureFlagService.js.map +1 -0
  39. package/dist/application/modules/internal/feature-flag/feature-flag-init.d.ts +11 -0
  40. package/dist/application/modules/internal/feature-flag/feature-flag-init.js +24 -0
  41. package/dist/application/modules/internal/feature-flag/feature-flag-init.js.map +1 -0
  42. package/dist/application/modules/internal/feature-flag/feature-flag.domain.d.ts +10 -0
  43. package/dist/application/modules/internal/feature-flag/feature-flag.domain.js +7 -0
  44. package/dist/application/modules/internal/feature-flag/feature-flag.domain.js.map +1 -0
  45. package/dist/application/modules/internal/feature-flag/featureFlagInit.d.ts +11 -0
  46. package/dist/application/modules/internal/feature-flag/featureFlagInit.js +44 -0
  47. package/dist/application/modules/internal/feature-flag/featureFlagInit.js.map +1 -0
  48. package/dist/application/modules/internal/feature-flag/index.d.ts +2 -0
  49. package/dist/application/modules/internal/feature-flag/index.js +3 -0
  50. package/dist/application/modules/internal/feature-flag/index.js.map +1 -0
  51. package/dist/application/modules/internal/shared/index.d.ts +2 -0
  52. package/dist/application/modules/internal/shared/index.js +3 -0
  53. package/dist/application/modules/internal/shared/index.js.map +1 -0
  54. package/dist/application/modules/internal/shared/shared.constants.d.ts +2 -0
  55. package/dist/application/modules/internal/shared/shared.constants.js +3 -0
  56. package/dist/application/modules/internal/shared/shared.constants.js.map +1 -0
  57. package/dist/application/modules/internal/shared/shared.utils.d.ts +44 -0
  58. package/dist/application/modules/internal/shared/shared.utils.js +204 -0
  59. package/dist/application/modules/internal/shared/shared.utils.js.map +1 -0
  60. package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
  61. package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js +380 -0
  62. package/dist/application/modules/internal/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
  63. package/dist/application/modules/internal/wasm-orchestrator/index.d.ts +6 -0
  64. package/dist/application/modules/internal/wasm-orchestrator/index.js +9 -0
  65. package/dist/application/modules/internal/wasm-orchestrator/index.js.map +1 -0
  66. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.d.ts +28 -0
  67. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js +35 -0
  68. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
  69. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.d.ts +51 -0
  70. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
  71. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
  72. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.d.ts +142 -0
  73. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
  74. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
  75. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.d.ts +86 -0
  76. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js +201 -0
  77. package/dist/application/modules/internal/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
  78. package/dist/application/modules/support/camera/CameraServiceFactory.d.ts +10 -10
  79. package/dist/application/modules/support/camera/CameraServiceFactory.js +33 -33
  80. package/dist/application/modules/support/camera/CameraServiceFactory.js.map +1 -1
  81. package/dist/application/modules/support/camera/camera.constants.d.ts +9 -9
  82. package/dist/application/modules/support/camera/camera.constants.js +48 -48
  83. package/dist/application/modules/support/camera/camera.domain.d.ts +15 -15
  84. package/dist/application/modules/support/camera/camera.domain.js +1 -1
  85. package/dist/application/modules/support/camera/camera.types.d.ts +42 -42
  86. package/dist/application/modules/support/camera/camera.types.js +10 -10
  87. package/dist/application/modules/support/camera/camera.utils.d.ts +157 -157
  88. package/dist/application/modules/support/camera/camera.utils.js +623 -623
  89. package/dist/application/modules/support/camera/index.d.ts +24 -24
  90. package/dist/application/modules/support/camera/index.js +27 -27
  91. package/dist/application/modules/support/camera/services/BaseCameraService.d.ts +41 -41
  92. package/dist/application/modules/support/camera/services/BaseCameraService.js +278 -278
  93. package/dist/application/modules/support/camera/services/DesktopCameraService.d.ts +5 -5
  94. package/dist/application/modules/support/camera/services/DesktopCameraService.js +46 -46
  95. package/dist/application/modules/support/camera/services/FirefoxCameraService.d.ts +5 -5
  96. package/dist/application/modules/support/camera/services/FirefoxCameraService.js +46 -46
  97. package/dist/application/modules/support/camera/services/MacSafariCameraService.d.ts +5 -5
  98. package/dist/application/modules/support/camera/services/MacSafariCameraService.js +47 -47
  99. package/dist/application/modules/support/camera/services/MobileCameraService.d.ts +5 -5
  100. package/dist/application/modules/support/camera/services/MobileCameraService.js +133 -133
  101. package/dist/application/modules/support/engine/EngineService.d.ts +15 -0
  102. package/dist/application/modules/support/engine/EngineService.js +106 -0
  103. package/dist/application/modules/support/engine/EngineService.js.map +1 -0
  104. package/dist/application/modules/support/engine/engine.constants.d.ts +33 -0
  105. package/dist/application/modules/support/engine/engine.constants.js +35 -0
  106. package/dist/application/modules/support/engine/engine.constants.js.map +1 -0
  107. package/dist/application/modules/support/engine/engine.domain.d.ts +23 -0
  108. package/dist/application/modules/support/engine/engine.domain.js +2 -0
  109. package/dist/application/modules/support/engine/engine.domain.js.map +1 -0
  110. package/dist/application/modules/support/engine/engine.types.d.ts +32 -0
  111. package/dist/application/modules/support/engine/engine.types.js +2 -0
  112. package/dist/application/modules/support/engine/engine.types.js.map +1 -0
  113. package/dist/application/modules/support/engine/engine.utils.d.ts +65 -0
  114. package/dist/application/modules/support/engine/engine.utils.js +135 -0
  115. package/dist/application/modules/support/engine/engine.utils.js.map +1 -0
  116. package/dist/application/modules/support/engine/index.d.ts +3 -0
  117. package/dist/application/modules/support/engine/index.js +2 -0
  118. package/dist/application/modules/support/engine/index.js.map +1 -0
  119. package/dist/application/modules/support/permissions/PermissionsService.d.ts +55 -55
  120. package/dist/application/modules/support/permissions/PermissionsService.js +183 -183
  121. package/dist/application/modules/support/permissions/index.d.ts +4 -4
  122. package/dist/application/modules/support/permissions/index.js +2 -2
  123. package/dist/application/modules/support/permissions/permission.utils.d.ts +6 -6
  124. package/dist/application/modules/support/permissions/permission.utils.js +33 -33
  125. package/dist/application/modules/support/permissions/permissions.domain.d.ts +6 -6
  126. package/dist/application/modules/support/permissions/permissions.domain.js +1 -1
  127. package/dist/application/modules/support/permissions/permissions.types.d.ts +9 -9
  128. package/dist/application/modules/support/permissions/permissions.types.js +1 -1
  129. package/dist/application/modules/support/wasm/WasmService.d.ts +25 -25
  130. package/dist/application/modules/support/wasm/WasmService.js +156 -155
  131. package/dist/application/modules/support/wasm/WasmService.js.map +1 -1
  132. package/dist/application/modules/support/wasm/index.d.ts +6 -6
  133. package/dist/application/modules/support/wasm/index.js +8 -8
  134. package/dist/application/modules/support/wasm/wasm.constants.d.ts +78 -78
  135. package/dist/application/modules/support/wasm/wasm.constants.js +86 -86
  136. package/dist/application/modules/support/wasm/wasm.domain.d.ts +52 -52
  137. package/dist/application/modules/support/wasm/wasm.domain.js +1 -1
  138. package/dist/application/modules/support/wasm/wasm.types.d.ts +119 -118
  139. package/dist/application/modules/support/wasm/wasm.types.js +1 -1
  140. package/dist/application/modules/support/wasm/wasm.utils.d.ts +88 -88
  141. package/dist/application/modules/support/wasm/wasm.utils.js +243 -243
  142. package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.d.ts +28 -0
  143. package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js +324 -0
  144. package/dist/application/modules/support/wasm-orchestrator/WasmOrchestratorService.js.map +1 -0
  145. package/dist/application/modules/support/wasm-orchestrator/index.d.ts +6 -0
  146. package/dist/application/modules/support/wasm-orchestrator/index.js +9 -0
  147. package/dist/application/modules/support/wasm-orchestrator/index.js.map +1 -0
  148. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.d.ts +36 -0
  149. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js +44 -0
  150. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.constants.js.map +1 -0
  151. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.d.ts +47 -0
  152. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js +2 -0
  153. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.domain.js.map +1 -0
  154. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.d.ts +136 -0
  155. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js +2 -0
  156. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.types.js.map +1 -0
  157. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.d.ts +91 -0
  158. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js +250 -0
  159. package/dist/application/modules/support/wasm-orchestrator/wasm-orchestrator.utils.js.map +1 -0
  160. package/dist/application/workers/index.d.ts +42 -42
  161. package/dist/application/workers/index.js +8 -8
  162. package/dist/application/workers/wasm/WasmWorkerService.d.ts +66 -0
  163. package/dist/application/workers/wasm/WasmWorkerService.js +801 -0
  164. package/dist/application/workers/wasm/WasmWorkerService.js.map +1 -0
  165. package/dist/application/workers/wasm/index.d.ts +4 -0
  166. package/dist/application/workers/wasm/index.js +9 -0
  167. package/dist/application/workers/wasm/index.js.map +1 -0
  168. package/dist/application/workers/wasm/wasm-worker.constants.d.ts +5 -0
  169. package/dist/application/workers/wasm/wasm-worker.constants.js +6 -0
  170. package/dist/application/workers/wasm/wasm-worker.constants.js.map +1 -0
  171. package/dist/application/workers/wasm/wasm-worker.domain.d.ts +99 -0
  172. package/dist/application/workers/wasm/wasm-worker.domain.js +2 -0
  173. package/dist/application/workers/wasm/wasm-worker.domain.js.map +1 -0
  174. package/dist/application/workers/wasm/wasm-worker.types.d.ts +88 -0
  175. package/dist/application/workers/wasm/wasm-worker.types.js +2 -0
  176. package/dist/application/workers/wasm/wasm-worker.types.js.map +1 -0
  177. package/dist/application/workers/wasm/wasm-worker.utils.d.ts +10 -0
  178. package/dist/application/workers/wasm/wasm-worker.utils.js +130 -0
  179. package/dist/application/workers/wasm/wasm-worker.utils.js.map +1 -0
  180. package/dist/buildConfig.d.ts +3 -0
  181. package/dist/buildConfig.js +7 -0
  182. package/dist/buildConfig.js.map +1 -0
  183. package/dist/cameraUtils.d.ts +77 -77
  184. package/dist/cameraUtils.js +361 -361
  185. package/dist/constants.d.ts +9 -9
  186. package/dist/constants.js +13 -13
  187. package/dist/createCallback.d.ts +56 -56
  188. package/dist/createCallback.js +332 -331
  189. package/dist/createCallback.js.map +1 -1
  190. package/dist/dbUtils.d.ts +14 -14
  191. package/dist/dbUtils.js +148 -148
  192. package/dist/envUtils.d.ts +4 -4
  193. package/dist/envUtils.js +16 -16
  194. package/dist/faceModule.d.ts +196 -196
  195. package/dist/faceModule.js +978 -978
  196. package/dist/featureFlagInit.d.ts +11 -0
  197. package/dist/featureFlagInit.js +44 -0
  198. package/dist/featureFlagInit.js.map +1 -0
  199. package/dist/index.d.ts +38 -38
  200. package/dist/index.js +82 -82
  201. package/dist/main.d.ts +30 -30
  202. package/dist/main.js +84 -84
  203. package/dist/types.d.ts +139 -139
  204. package/dist/types.js +77 -77
  205. package/dist/utils.d.ts +84 -84
  206. package/dist/utils.js +580 -580
  207. package/package.json +102 -102
  208. package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
  209. package/wasm/ultra/nosimd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
  210. package/wasm/ultra/nosimd/version.json +2 -2
  211. package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.js +18 -18
  212. package/wasm/ultra/simd/{25.11.13-1357710 → 26.01.08-1300478}/privid_fhe_uber.wasm +0 -0
  213. package/wasm/ultra/simd/version.json +2 -2
  214. package/workers/comlink.min.js +7 -7
  215. package/workers/comlink.min.js.map +1 -1
  216. package/workers/wasm.worker.js +936 -924
@@ -1,362 +1,362 @@
1
- /* eslint-disable */
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- import { UAParser } from 'ua-parser-js';
12
- import { FacingMode } from './types';
13
- import { PORTRAIT } from './constants';
14
- import { getScreenOrientation } from './utils';
15
- const cameraLowResHeight = 480;
16
- const cameraLowResWidth = 1920;
17
- const mobileCameraResWidth = 1200;
18
- const mobileCameraResHeight = 1440;
19
- export function getUserAgent() {
20
- const userAgent = typeof window !== 'undefined' && navigator && window.navigator.userAgent;
21
- return userAgent || undefined;
22
- }
23
- export function parseUserAgent() {
24
- // This maybe evaluated in next.js Node rather than in Browser
25
- if (!getUserAgent()) {
26
- return undefined;
27
- }
28
- const parser = new UAParser();
29
- return parser.getResult();
30
- }
31
- export function isPortrait() {
32
- return getScreenOrientation() === PORTRAIT;
33
- }
34
- export function isBackCameraAndPortrait(faceMode) {
35
- return isPortrait();
36
- }
37
- export function isMobileUA() {
38
- const result = parseUserAgent();
39
- if (!result || !result.device || !result.device.type) {
40
- return false;
41
- }
42
- return ['mobile', 'tablet'].includes(result.device.type);
43
- }
44
- export function isFirefoxUA() {
45
- var _a;
46
- const result = parseUserAgent();
47
- return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Firefox';
48
- }
49
- export function isSafariUA() {
50
- var _a;
51
- const result = parseUserAgent();
52
- return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Safari';
53
- }
54
- export function isChromeUA() {
55
- var _a;
56
- const result = parseUserAgent();
57
- return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Chrome';
58
- }
59
- export function isSamsungUA() {
60
- var _a;
61
- const result = parseUserAgent();
62
- return ((_a = result === null || result === void 0 ? void 0 : result.device) === null || _a === void 0 ? void 0 : _a.vendor) === 'Samsung';
63
- }
64
- export function isAndroid() {
65
- var _a;
66
- const result = parseUserAgent();
67
- return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android';
68
- }
69
- /**
70
- * See https://developer.chrome.com/docs/multidevice/user-agent/#webview_user_agent
71
- * This onloy detects the WebView after Android 4.4. It'd return false for older
72
- * Android version.
73
- */
74
- export function isAndroidWebView() {
75
- var _a, _b;
76
- const result = parseUserAgent();
77
- // If the user-agent string contains "wv", 'ua-parser-js' will return the
78
- // string "WebView" as part of its browser name.
79
- return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android' && /WebView/.test(String((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.name));
80
- }
81
- export function isAndroid12OrAbove() {
82
- return getMajorAndroidVersion() >= 12;
83
- }
84
- export function isIOSUA() {
85
- var _a;
86
- const result = parseUserAgent();
87
- return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'iOS';
88
- }
89
- export function getMajorAndroidVersion() {
90
- var _a, _b;
91
- const result = parseUserAgent();
92
- const matched = ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android' ? String(((_b = result === null || result === void 0 ? void 0 : result.os) === null || _b === void 0 ? void 0 : _b.version) || '').match(/^\d+/) : null;
93
- return matched ? parseInt(matched[0], 10) : NaN;
94
- }
95
- export function getMajorSafariVersion() {
96
- var _a, _b;
97
- const result = parseUserAgent();
98
- const name = (_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name;
99
- if (name === 'Safari' || name === 'Mobile Safari') {
100
- return parseInt(((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.version) || '', 10);
101
- }
102
- return NaN;
103
- }
104
- export function getMajorChromeVersion() {
105
- var _a, _b;
106
- const result = parseUserAgent();
107
- return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name.includes('Chrome')) ? parseInt(((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.version) || '', 10) : NaN;
108
- }
109
- export function getMajorIOSVersion() {
110
- var _a, _b;
111
- const result = parseUserAgent();
112
- const matched = ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'iOS' ? String(((_b = result === null || result === void 0 ? void 0 : result.os) === null || _b === void 0 ? void 0 : _b.version) || '').match(/^\d+/) : null;
113
- return matched ? parseInt(matched[0], 10) : NaN;
114
- }
115
- export function getMajorMinorOsVersion() {
116
- var _a;
117
- const result = parseUserAgent();
118
- const version = String(((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.version) || '');
119
- const matched = version.match(/(^\d+)(\.\d+)?/);
120
- return (matched && matched[0]) || 'unknown';
121
- }
122
- export function isWindows() {
123
- var _a, _b;
124
- return getPlatform() === 'desktop' && ((_b = (_a = parseUserAgent()) === null || _a === void 0 ? void 0 : _a.os) === null || _b === void 0 ? void 0 : _b.name) === 'Windows';
125
- }
126
- export function isMac() {
127
- var _a, _b;
128
- return getPlatform() === 'desktop' && ((_b = (_a = parseUserAgent()) === null || _a === void 0 ? void 0 : _a.os) === null || _b === void 0 ? void 0 : _b.name) === 'Mac OS';
129
- }
130
- export function isLinux() {
131
- var _a;
132
- const ua = parseUserAgent();
133
- return ((_a = ua === null || ua === void 0 ? void 0 : ua.os) === null || _a === void 0 ? void 0 : _a.name) === 'Linux';
134
- }
135
- // This returns the "platform"- iphone vs android vs desktop used for reporting metrics.
136
- // Do not make this into something with high cardinality- that will impact SignalFX.
137
- // If you need to alter/add to these values, please make sure to update the relevant
138
- // SignalFX metrics as well.
139
- export function getPlatform() {
140
- if (isAndroid()) {
141
- return 'android';
142
- }
143
- if (isIOSUA()) {
144
- return 'iphone';
145
- }
146
- return 'desktop';
147
- }
148
- export function isMobileDevice() {
149
- return isMobileUA() || isAndroidDesktop() || isIOSDesktop();
150
- }
151
- // Whether it's an IOS browser requesting desktop site.
152
- export function isIOSDesktop() {
153
- // IOS browser => Request Desktop Site.
154
- return isMac() && window.navigator.maxTouchPoints > 1;
155
- }
156
- export function isIOS() {
157
- return isIOSUA() || isIOSDesktop();
158
- }
159
- export function isIOS15OrGreater() {
160
- if (isIOSDesktop()) {
161
- // In the past, the version of Safari has been in sync with the version of
162
- // iOS. Therefore, we could use Safari's version as a proxy to determine
163
- // the version of iOS. However, it's not possible to determine the iOS
164
- // version using other types of browsers.
165
- return getMajorSafariVersion() >= 15;
166
- }
167
- // iOS Mobile.
168
- return getMajorIOSVersion() >= 15;
169
- }
170
- // Whether it's an Android browser requesting desktop site.
171
- export function isAndroidDesktop() {
172
- // Android browser => Request Desktop Site.
173
- return isLinux() && window.navigator.maxTouchPoints > 1;
174
- }
175
- const BACK_CAMERA_WORDS = [
176
- 'rear',
177
- 'back',
178
- 'rück',
179
- 'arrière',
180
- 'trasera',
181
- 'trás',
182
- 'traseira',
183
- 'posteriore',
184
- '后面',
185
- '後面',
186
- '背面',
187
- '后置',
188
- '後置',
189
- '背置',
190
- 'задней',
191
- 'الخلفية',
192
- '후',
193
- 'arka',
194
- 'achterzijde',
195
- 'หลัง',
196
- 'baksidan',
197
- 'bagside',
198
- 'sau',
199
- 'bak',
200
- 'tylny',
201
- 'takakamera',
202
- 'belakang',
203
- 'אחורית',
204
- 'πίσω',
205
- 'spate',
206
- 'hátsó',
207
- 'zadní',
208
- 'darrere',
209
- 'zadná',
210
- 'задня',
211
- 'stražnja',
212
- 'belakang',
213
- 'बैक',
214
- ];
215
- export const isBackCameraLabel = (label) => {
216
- const lowerCase = (label === null || label === void 0 ? void 0 : label.toLowerCase()) || '';
217
- return BACK_CAMERA_WORDS.some((keyword) => lowerCase === null || lowerCase === void 0 ? void 0 : lowerCase.includes(keyword));
218
- };
219
- export const isMobileBackCameraPortrait = ({ label, facingMode }) => {
220
- const isBackCamera = isBackCameraLabel(label) || (facingMode === null || facingMode === void 0 ? void 0 : facingMode.includes(FacingMode.environment));
221
- return isMobileDevice() && isBackCamera && isPortrait();
222
- };
223
- export const isFaceTimeCamera = (label, isDocumentScan) => isMac() && label.includes('FaceTime') && isDocumentScan;
224
- export const getCameraList = (backOnly) => __awaiter(void 0, void 0, void 0, function* () {
225
- try {
226
- if (!navigator.mediaDevices) {
227
- return [];
228
- }
229
- let cameraList = yield navigator.mediaDevices.enumerateDevices().then((devices) => {
230
- const filteredDevices = devices.filter((device) => {
231
- let filteredLabels = true;
232
- if (!backOnly) {
233
- filteredLabels = !isBackCameraLabel(device.label);
234
- }
235
- return device.kind === 'videoinput' && filteredLabels;
236
- });
237
- return filteredDevices.map((device) => {
238
- // @ts-ignore
239
- if (device === null || device === void 0 ? void 0 : device.getCapabilities) {
240
- // @ts-ignore
241
- return Object.assign(Object.assign({}, device === null || device === void 0 ? void 0 : device.getCapabilities()), { deviceId: device.deviceId, label: device.label });
242
- }
243
- return { deviceId: device.deviceId, label: device.label };
244
- });
245
- });
246
- if (isAndroid()) {
247
- cameraList = cameraList.sort((a, b) => (a.label < b.label ? -1 : 1));
248
- }
249
- return cameraList;
250
- }
251
- catch (error) {
252
- // handleException(error, 'error listing cameras');
253
- return [];
254
- }
255
- });
256
- export const getVideoConstraints = (availableDevices, faceMode, requireHD, isDocumentScan, canvasResolution, hasError = false) => {
257
- // Use 1.5 ratio. US DL are 1.58, passport are 1.42, so take something in the middle
258
- let deviceId = availableDevices[0];
259
- if (isIOS() && isDocumentScan && (availableDevices === null || availableDevices === void 0 ? void 0 : availableDevices.length) > 2) {
260
- const ultraWideDevice = availableDevices.find(({ label }) => label.includes('Dual Wide') || label.includes('Back Triple'));
261
- deviceId = ultraWideDevice || availableDevices[0];
262
- }
263
- let resizeMode = 'crop-and-scale';
264
- if (isMobileDevice()) {
265
- // Known cases that 'crop-and-scale' does not work.
266
- if (
267
- // Chrome 107+ on Android shows broken video in 'crop-and-scale'.
268
- (isAndroid() && getMajorChromeVersion() >= 107) ||
269
- // Samsung video driver has a bug when using resizeMode
270
- (isSamsungUA() && !isAndroid12OrAbove())) {
271
- resizeMode = 'none';
272
- }
273
- let videoWidth;
274
- let videoHeight;
275
- let aspectRatio;
276
- if ((canvasResolution === null || canvasResolution === void 0 ? void 0 : canvasResolution.width) && (canvasResolution === null || canvasResolution === void 0 ? void 0 : canvasResolution.height)) {
277
- videoWidth = canvasResolution.width;
278
- videoHeight = canvasResolution.height;
279
- aspectRatio = 1.7777777778;
280
- }
281
- else {
282
- videoWidth = isBackCameraAndPortrait(faceMode)
283
- ? // ? { min: cameraLowResHeight, max: mobileCameraResHeight }
284
- { ideal: mobileCameraResHeight }
285
- : { ideal: cameraLowResWidth };
286
- videoHeight = isBackCameraAndPortrait(faceMode)
287
- ? // ? { min: cameraLowResHeight, max: mobileCameraResHeight }
288
- { ideal: mobileCameraResHeight }
289
- : undefined;
290
- aspectRatio = isBackCameraAndPortrait(faceMode) ? 1 : 1.7777777778;
291
- }
292
- return {
293
- audio: false,
294
- video: {
295
- facingMode: faceMode,
296
- resizeMode,
297
- width: videoWidth,
298
- height: videoHeight,
299
- deviceId: deviceId ? deviceId.deviceId : undefined,
300
- aspectRatio,
301
- focusMode: 'continuous',
302
- },
303
- };
304
- }
305
- return {
306
- audio: false,
307
- video: {
308
- aspectRatio: 1.5,
309
- // deviceId: deviceId ? deviceId.deviceId : undefined,
310
- height: { min: cameraLowResHeight },
311
- resizeMode,
312
- },
313
- };
314
- };
315
- export function scaleImageData(imageData, scaleFactor) {
316
- const { width, height, data } = imageData;
317
- // Create a new canvas and context for temporary scaling
318
- const tempCanvas = document.createElement('canvas');
319
- const tempCtx = tempCanvas.getContext('2d');
320
- // Set the dimensions of the temporary canvas
321
- tempCanvas.width = width * scaleFactor;
322
- tempCanvas.height = height * scaleFactor;
323
- // Draw the original image data onto the temporary canvas
324
- tempCtx.putImageData(imageData, 0, 0);
325
- // Get the scaled image data from the temporary canvas
326
- const scaledImageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
327
- return scaledImageData;
328
- }
329
- export function zoomInCanvasImage(canvas, scaleFactor) {
330
- // Get the current width and height of the canvas
331
- const originalWidth = canvas.width;
332
- const originalHeight = canvas.height;
333
- // Calculate the new dimensions after applying the scale factor
334
- const newWidth = Math.round(originalWidth / scaleFactor);
335
- const newHeight = Math.round(originalHeight / scaleFactor);
336
- // Calculate the amount of width and height to be cropped
337
- const cropWidth = originalWidth - newWidth;
338
- const cropHeight = originalHeight - newHeight;
339
- // Create an offscreen canvas to hold the cropped image
340
- const offscreenCanvas = document.createElement('canvas');
341
- const offscreenCtx = offscreenCanvas.getContext('2d');
342
- // Set the dimensions for the offscreen canvas
343
- offscreenCanvas.width = originalWidth;
344
- offscreenCanvas.height = originalHeight;
345
- const centerX = originalWidth / 2;
346
- const centerY = originalHeight / 2;
347
- const sx = centerX - newWidth / (2 * scaleFactor);
348
- const sy = centerY - newHeight / (2 * scaleFactor);
349
- offscreenCtx.drawImage(canvas, sx, sy, newWidth / scaleFactor, newHeight / scaleFactor,
350
- // cropWidth / 2,
351
- // cropHeight / 2, // sourceX, sourceY
352
- // originalWidth - cropWidth,
353
- // originalHeight - cropHeight, // sourceWidth, sourceHeight
354
- 0, 0, // destinationX, destinationY
355
- // changing this for testing
356
- newWidth, newHeight);
357
- // Get the image data from the offscreen canvas
358
- const imageData = offscreenCtx.getImageData(0, 0, newWidth, newHeight);
359
- // Return the image data
360
- return imageData;
361
- }
1
+ /* eslint-disable */
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { UAParser } from 'ua-parser-js';
12
+ import { FacingMode } from './types';
13
+ import { PORTRAIT } from './constants';
14
+ import { getScreenOrientation } from './utils';
15
+ const cameraLowResHeight = 480;
16
+ const cameraLowResWidth = 1920;
17
+ const mobileCameraResWidth = 1200;
18
+ const mobileCameraResHeight = 1440;
19
+ export function getUserAgent() {
20
+ const userAgent = typeof window !== 'undefined' && navigator && window.navigator.userAgent;
21
+ return userAgent || undefined;
22
+ }
23
+ export function parseUserAgent() {
24
+ // This maybe evaluated in next.js Node rather than in Browser
25
+ if (!getUserAgent()) {
26
+ return undefined;
27
+ }
28
+ const parser = new UAParser();
29
+ return parser.getResult();
30
+ }
31
+ export function isPortrait() {
32
+ return getScreenOrientation() === PORTRAIT;
33
+ }
34
+ export function isBackCameraAndPortrait(faceMode) {
35
+ return isPortrait();
36
+ }
37
+ export function isMobileUA() {
38
+ const result = parseUserAgent();
39
+ if (!result || !result.device || !result.device.type) {
40
+ return false;
41
+ }
42
+ return ['mobile', 'tablet'].includes(result.device.type);
43
+ }
44
+ export function isFirefoxUA() {
45
+ var _a;
46
+ const result = parseUserAgent();
47
+ return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Firefox';
48
+ }
49
+ export function isSafariUA() {
50
+ var _a;
51
+ const result = parseUserAgent();
52
+ return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Safari';
53
+ }
54
+ export function isChromeUA() {
55
+ var _a;
56
+ const result = parseUserAgent();
57
+ return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name) === 'Chrome';
58
+ }
59
+ export function isSamsungUA() {
60
+ var _a;
61
+ const result = parseUserAgent();
62
+ return ((_a = result === null || result === void 0 ? void 0 : result.device) === null || _a === void 0 ? void 0 : _a.vendor) === 'Samsung';
63
+ }
64
+ export function isAndroid() {
65
+ var _a;
66
+ const result = parseUserAgent();
67
+ return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android';
68
+ }
69
+ /**
70
+ * See https://developer.chrome.com/docs/multidevice/user-agent/#webview_user_agent
71
+ * This onloy detects the WebView after Android 4.4. It'd return false for older
72
+ * Android version.
73
+ */
74
+ export function isAndroidWebView() {
75
+ var _a, _b;
76
+ const result = parseUserAgent();
77
+ // If the user-agent string contains "wv", 'ua-parser-js' will return the
78
+ // string "WebView" as part of its browser name.
79
+ return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android' && /WebView/.test(String((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.name));
80
+ }
81
+ export function isAndroid12OrAbove() {
82
+ return getMajorAndroidVersion() >= 12;
83
+ }
84
+ export function isIOSUA() {
85
+ var _a;
86
+ const result = parseUserAgent();
87
+ return ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'iOS';
88
+ }
89
+ export function getMajorAndroidVersion() {
90
+ var _a, _b;
91
+ const result = parseUserAgent();
92
+ const matched = ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'Android' ? String(((_b = result === null || result === void 0 ? void 0 : result.os) === null || _b === void 0 ? void 0 : _b.version) || '').match(/^\d+/) : null;
93
+ return matched ? parseInt(matched[0], 10) : NaN;
94
+ }
95
+ export function getMajorSafariVersion() {
96
+ var _a, _b;
97
+ const result = parseUserAgent();
98
+ const name = (_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name;
99
+ if (name === 'Safari' || name === 'Mobile Safari') {
100
+ return parseInt(((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.version) || '', 10);
101
+ }
102
+ return NaN;
103
+ }
104
+ export function getMajorChromeVersion() {
105
+ var _a, _b;
106
+ const result = parseUserAgent();
107
+ return ((_a = result === null || result === void 0 ? void 0 : result.browser) === null || _a === void 0 ? void 0 : _a.name.includes('Chrome')) ? parseInt(((_b = result === null || result === void 0 ? void 0 : result.browser) === null || _b === void 0 ? void 0 : _b.version) || '', 10) : NaN;
108
+ }
109
+ export function getMajorIOSVersion() {
110
+ var _a, _b;
111
+ const result = parseUserAgent();
112
+ const matched = ((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.name) === 'iOS' ? String(((_b = result === null || result === void 0 ? void 0 : result.os) === null || _b === void 0 ? void 0 : _b.version) || '').match(/^\d+/) : null;
113
+ return matched ? parseInt(matched[0], 10) : NaN;
114
+ }
115
+ export function getMajorMinorOsVersion() {
116
+ var _a;
117
+ const result = parseUserAgent();
118
+ const version = String(((_a = result === null || result === void 0 ? void 0 : result.os) === null || _a === void 0 ? void 0 : _a.version) || '');
119
+ const matched = version.match(/(^\d+)(\.\d+)?/);
120
+ return (matched && matched[0]) || 'unknown';
121
+ }
122
+ export function isWindows() {
123
+ var _a, _b;
124
+ return getPlatform() === 'desktop' && ((_b = (_a = parseUserAgent()) === null || _a === void 0 ? void 0 : _a.os) === null || _b === void 0 ? void 0 : _b.name) === 'Windows';
125
+ }
126
+ export function isMac() {
127
+ var _a, _b;
128
+ return getPlatform() === 'desktop' && ((_b = (_a = parseUserAgent()) === null || _a === void 0 ? void 0 : _a.os) === null || _b === void 0 ? void 0 : _b.name) === 'Mac OS';
129
+ }
130
+ export function isLinux() {
131
+ var _a;
132
+ const ua = parseUserAgent();
133
+ return ((_a = ua === null || ua === void 0 ? void 0 : ua.os) === null || _a === void 0 ? void 0 : _a.name) === 'Linux';
134
+ }
135
+ // This returns the "platform"- iphone vs android vs desktop used for reporting metrics.
136
+ // Do not make this into something with high cardinality- that will impact SignalFX.
137
+ // If you need to alter/add to these values, please make sure to update the relevant
138
+ // SignalFX metrics as well.
139
+ export function getPlatform() {
140
+ if (isAndroid()) {
141
+ return 'android';
142
+ }
143
+ if (isIOSUA()) {
144
+ return 'iphone';
145
+ }
146
+ return 'desktop';
147
+ }
148
+ export function isMobileDevice() {
149
+ return isMobileUA() || isAndroidDesktop() || isIOSDesktop();
150
+ }
151
+ // Whether it's an IOS browser requesting desktop site.
152
+ export function isIOSDesktop() {
153
+ // IOS browser => Request Desktop Site.
154
+ return isMac() && window.navigator.maxTouchPoints > 1;
155
+ }
156
+ export function isIOS() {
157
+ return isIOSUA() || isIOSDesktop();
158
+ }
159
+ export function isIOS15OrGreater() {
160
+ if (isIOSDesktop()) {
161
+ // In the past, the version of Safari has been in sync with the version of
162
+ // iOS. Therefore, we could use Safari's version as a proxy to determine
163
+ // the version of iOS. However, it's not possible to determine the iOS
164
+ // version using other types of browsers.
165
+ return getMajorSafariVersion() >= 15;
166
+ }
167
+ // iOS Mobile.
168
+ return getMajorIOSVersion() >= 15;
169
+ }
170
+ // Whether it's an Android browser requesting desktop site.
171
+ export function isAndroidDesktop() {
172
+ // Android browser => Request Desktop Site.
173
+ return isLinux() && window.navigator.maxTouchPoints > 1;
174
+ }
175
+ const BACK_CAMERA_WORDS = [
176
+ 'rear',
177
+ 'back',
178
+ 'rück',
179
+ 'arrière',
180
+ 'trasera',
181
+ 'trás',
182
+ 'traseira',
183
+ 'posteriore',
184
+ '后面',
185
+ '後面',
186
+ '背面',
187
+ '后置',
188
+ '後置',
189
+ '背置',
190
+ 'задней',
191
+ 'الخلفية',
192
+ '후',
193
+ 'arka',
194
+ 'achterzijde',
195
+ 'หลัง',
196
+ 'baksidan',
197
+ 'bagside',
198
+ 'sau',
199
+ 'bak',
200
+ 'tylny',
201
+ 'takakamera',
202
+ 'belakang',
203
+ 'אחורית',
204
+ 'πίσω',
205
+ 'spate',
206
+ 'hátsó',
207
+ 'zadní',
208
+ 'darrere',
209
+ 'zadná',
210
+ 'задня',
211
+ 'stražnja',
212
+ 'belakang',
213
+ 'बैक',
214
+ ];
215
+ export const isBackCameraLabel = (label) => {
216
+ const lowerCase = (label === null || label === void 0 ? void 0 : label.toLowerCase()) || '';
217
+ return BACK_CAMERA_WORDS.some((keyword) => lowerCase === null || lowerCase === void 0 ? void 0 : lowerCase.includes(keyword));
218
+ };
219
+ export const isMobileBackCameraPortrait = ({ label, facingMode }) => {
220
+ const isBackCamera = isBackCameraLabel(label) || (facingMode === null || facingMode === void 0 ? void 0 : facingMode.includes(FacingMode.environment));
221
+ return isMobileDevice() && isBackCamera && isPortrait();
222
+ };
223
+ export const isFaceTimeCamera = (label, isDocumentScan) => isMac() && label.includes('FaceTime') && isDocumentScan;
224
+ export const getCameraList = (backOnly) => __awaiter(void 0, void 0, void 0, function* () {
225
+ try {
226
+ if (!navigator.mediaDevices) {
227
+ return [];
228
+ }
229
+ let cameraList = yield navigator.mediaDevices.enumerateDevices().then((devices) => {
230
+ const filteredDevices = devices.filter((device) => {
231
+ let filteredLabels = true;
232
+ if (!backOnly) {
233
+ filteredLabels = !isBackCameraLabel(device.label);
234
+ }
235
+ return device.kind === 'videoinput' && filteredLabels;
236
+ });
237
+ return filteredDevices.map((device) => {
238
+ // @ts-ignore
239
+ if (device === null || device === void 0 ? void 0 : device.getCapabilities) {
240
+ // @ts-ignore
241
+ return Object.assign(Object.assign({}, device === null || device === void 0 ? void 0 : device.getCapabilities()), { deviceId: device.deviceId, label: device.label });
242
+ }
243
+ return { deviceId: device.deviceId, label: device.label };
244
+ });
245
+ });
246
+ if (isAndroid()) {
247
+ cameraList = cameraList.sort((a, b) => (a.label < b.label ? -1 : 1));
248
+ }
249
+ return cameraList;
250
+ }
251
+ catch (error) {
252
+ // handleException(error, 'error listing cameras');
253
+ return [];
254
+ }
255
+ });
256
+ export const getVideoConstraints = (availableDevices, faceMode, requireHD, isDocumentScan, canvasResolution, hasError = false) => {
257
+ // Use 1.5 ratio. US DL are 1.58, passport are 1.42, so take something in the middle
258
+ let deviceId = availableDevices[0];
259
+ if (isIOS() && isDocumentScan && (availableDevices === null || availableDevices === void 0 ? void 0 : availableDevices.length) > 2) {
260
+ const ultraWideDevice = availableDevices.find(({ label }) => label.includes('Dual Wide') || label.includes('Back Triple'));
261
+ deviceId = ultraWideDevice || availableDevices[0];
262
+ }
263
+ let resizeMode = 'crop-and-scale';
264
+ if (isMobileDevice()) {
265
+ // Known cases that 'crop-and-scale' does not work.
266
+ if (
267
+ // Chrome 107+ on Android shows broken video in 'crop-and-scale'.
268
+ (isAndroid() && getMajorChromeVersion() >= 107) ||
269
+ // Samsung video driver has a bug when using resizeMode
270
+ (isSamsungUA() && !isAndroid12OrAbove())) {
271
+ resizeMode = 'none';
272
+ }
273
+ let videoWidth;
274
+ let videoHeight;
275
+ let aspectRatio;
276
+ if ((canvasResolution === null || canvasResolution === void 0 ? void 0 : canvasResolution.width) && (canvasResolution === null || canvasResolution === void 0 ? void 0 : canvasResolution.height)) {
277
+ videoWidth = canvasResolution.width;
278
+ videoHeight = canvasResolution.height;
279
+ aspectRatio = 1.7777777778;
280
+ }
281
+ else {
282
+ videoWidth = isBackCameraAndPortrait(faceMode)
283
+ ? // ? { min: cameraLowResHeight, max: mobileCameraResHeight }
284
+ { ideal: mobileCameraResHeight }
285
+ : { ideal: cameraLowResWidth };
286
+ videoHeight = isBackCameraAndPortrait(faceMode)
287
+ ? // ? { min: cameraLowResHeight, max: mobileCameraResHeight }
288
+ { ideal: mobileCameraResHeight }
289
+ : undefined;
290
+ aspectRatio = isBackCameraAndPortrait(faceMode) ? 1 : 1.7777777778;
291
+ }
292
+ return {
293
+ audio: false,
294
+ video: {
295
+ facingMode: faceMode,
296
+ resizeMode,
297
+ width: videoWidth,
298
+ height: videoHeight,
299
+ deviceId: deviceId ? deviceId.deviceId : undefined,
300
+ aspectRatio,
301
+ focusMode: 'continuous',
302
+ },
303
+ };
304
+ }
305
+ return {
306
+ audio: false,
307
+ video: {
308
+ aspectRatio: 1.5,
309
+ // deviceId: deviceId ? deviceId.deviceId : undefined,
310
+ height: { min: cameraLowResHeight },
311
+ resizeMode,
312
+ },
313
+ };
314
+ };
315
+ export function scaleImageData(imageData, scaleFactor) {
316
+ const { width, height, data } = imageData;
317
+ // Create a new canvas and context for temporary scaling
318
+ const tempCanvas = document.createElement('canvas');
319
+ const tempCtx = tempCanvas.getContext('2d');
320
+ // Set the dimensions of the temporary canvas
321
+ tempCanvas.width = width * scaleFactor;
322
+ tempCanvas.height = height * scaleFactor;
323
+ // Draw the original image data onto the temporary canvas
324
+ tempCtx.putImageData(imageData, 0, 0);
325
+ // Get the scaled image data from the temporary canvas
326
+ const scaledImageData = tempCtx.getImageData(0, 0, tempCanvas.width, tempCanvas.height);
327
+ return scaledImageData;
328
+ }
329
+ export function zoomInCanvasImage(canvas, scaleFactor) {
330
+ // Get the current width and height of the canvas
331
+ const originalWidth = canvas.width;
332
+ const originalHeight = canvas.height;
333
+ // Calculate the new dimensions after applying the scale factor
334
+ const newWidth = Math.round(originalWidth / scaleFactor);
335
+ const newHeight = Math.round(originalHeight / scaleFactor);
336
+ // Calculate the amount of width and height to be cropped
337
+ const cropWidth = originalWidth - newWidth;
338
+ const cropHeight = originalHeight - newHeight;
339
+ // Create an offscreen canvas to hold the cropped image
340
+ const offscreenCanvas = document.createElement('canvas');
341
+ const offscreenCtx = offscreenCanvas.getContext('2d');
342
+ // Set the dimensions for the offscreen canvas
343
+ offscreenCanvas.width = originalWidth;
344
+ offscreenCanvas.height = originalHeight;
345
+ const centerX = originalWidth / 2;
346
+ const centerY = originalHeight / 2;
347
+ const sx = centerX - newWidth / (2 * scaleFactor);
348
+ const sy = centerY - newHeight / (2 * scaleFactor);
349
+ offscreenCtx.drawImage(canvas, sx, sy, newWidth / scaleFactor, newHeight / scaleFactor,
350
+ // cropWidth / 2,
351
+ // cropHeight / 2, // sourceX, sourceY
352
+ // originalWidth - cropWidth,
353
+ // originalHeight - cropHeight, // sourceWidth, sourceHeight
354
+ 0, 0, // destinationX, destinationY
355
+ // changing this for testing
356
+ newWidth, newHeight);
357
+ // Get the image data from the offscreen canvas
358
+ const imageData = offscreenCtx.getImageData(0, 0, newWidth, newHeight);
359
+ // Return the image data
360
+ return imageData;
361
+ }
362
362
  //# sourceMappingURL=cameraUtils.js.map