@scandit/web-datacapture-core 8.3.0-beta.1 → 8.3.1

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 (141) hide show
  1. package/build/js/{Camera-BnPnXqAt.d.ts → Camera-Cc__1Nc-.d.ts} +2 -0
  2. package/build/js/Camera.d.ts +1 -1
  3. package/build/js/Camera.js +1 -1
  4. package/build/js/CameraRelated.d.ts +1 -1
  5. package/build/js/{DataCaptureContext-LM_Re1B4.d.ts → DataCaptureContext-BcSpF9Dt.d.ts} +2 -1
  6. package/build/js/DataCaptureContext.d.ts +2 -2
  7. package/build/js/DataCaptureContext.js +1 -1
  8. package/build/js/DataCaptureContextRelated.d.ts +2 -2
  9. package/build/js/DataCaptureVersion.js +1 -1
  10. package/build/js/DataCaptureView.d.ts +2 -2
  11. package/build/js/DataCaptureView.js +1 -1
  12. package/build/js/Feedback.js +1 -1
  13. package/build/js/FrameData.d.ts +2 -2
  14. package/build/js/ImageFrameSource.d.ts +1 -1
  15. package/build/js/ImageFrameSource.js +1 -1
  16. package/build/js/NotificationPresenter/index.d.ts +2 -2
  17. package/build/js/NotificationPresenter/private/ConcreteNotificationPresenter.d.ts +2 -2
  18. package/build/js/NotificationPresenter/private/presets.d.ts +2 -2
  19. package/build/js/ScanditIconBuilder.js +1 -1
  20. package/build/js/SingleImageUploader.d.ts +1 -1
  21. package/build/js/Sound.d.ts +4 -0
  22. package/build/js/Sound.js +1 -1
  23. package/build/js/chunks/{chunk-BQO4QYI6.js → chunk-2N546PXQ.js} +1 -1
  24. package/build/js/chunks/{chunk-H7FKC2FI.js → chunk-35JLCTLQ.js} +1 -1
  25. package/build/js/chunks/chunk-3JLTBSEJ.js +1 -0
  26. package/build/js/chunks/chunk-5DKZR6UB.js +1 -0
  27. package/build/js/chunks/{chunk-OCKYBUXO.js → chunk-5VJXJTUX.js} +1 -1
  28. package/build/js/chunks/chunk-AAPD5YU3.js +1 -0
  29. package/build/js/chunks/chunk-ATSAENLJ.js +6 -0
  30. package/build/js/chunks/{chunk-KVRNF3VA.js → chunk-DTREAYZQ.js} +1 -1
  31. package/build/js/chunks/chunk-FK5L5YTR.js +1 -0
  32. package/build/js/chunks/{chunk-YXXMWHFX.js → chunk-GZCWMFWA.js} +1 -1
  33. package/build/js/chunks/{chunk-RYXKMXTY.js → chunk-HILZP6OW.js} +1 -1
  34. package/build/js/chunks/chunk-INVYPEGF.js +1 -0
  35. package/build/js/chunks/chunk-KYAHE2Q3.js +1 -0
  36. package/build/js/chunks/chunk-LV6LGCDC.js +1 -0
  37. package/build/js/chunks/chunk-MBF27IWL.js +1 -0
  38. package/build/js/chunks/chunk-NYYGU4ZV.js +1 -0
  39. package/build/js/chunks/{chunk-XVH5A2QH.js → chunk-PDJEYYPX.js} +1 -1
  40. package/build/js/chunks/chunk-QHBYNYWX.js +1 -0
  41. package/build/js/chunks/chunk-SJIN27Q5.js +1 -0
  42. package/build/js/chunks/chunk-TNIR74NN.js +1 -0
  43. package/build/js/chunks/{chunk-M2ZQCUEL.js → chunk-U2VELHGX.js} +1 -1
  44. package/build/js/chunks/chunk-U6MNF7M6.js +35 -0
  45. package/build/js/chunks/{chunk-2OCDIZIS.js → chunk-UQVVJP5Z.js} +1 -1
  46. package/build/js/chunks/{chunk-IVQL2BYY.js → chunk-XDTXM6UX.js} +1 -1
  47. package/build/js/chunks/{chunk-7ZU6DPLL.js → chunk-XV75QMNK.js} +1 -1
  48. package/build/js/chunks/chunk-Y3TODCJD.js +1 -0
  49. package/build/js/chunks/{chunk-7EGT56UE.js → chunk-Z6CZGU5N.js} +1 -1
  50. package/build/js/chunks/chunk-ZAXZRQYF.js +1 -0
  51. package/build/js/controls/CameraFOVSwitchControl.d.ts +2 -2
  52. package/build/js/controls/CameraFOVSwitchControl.js +1 -1
  53. package/build/js/controls/CameraSwitchControl.d.ts +2 -2
  54. package/build/js/controls/CameraSwitchControl.js +1 -1
  55. package/build/js/controls/TorchSwitchControl.d.ts +2 -2
  56. package/build/js/controls/TorchSwitchControl.js +1 -1
  57. package/build/js/controls/common.d.ts +2 -2
  58. package/build/js/controls/index.d.ts +2 -2
  59. package/build/js/controls/index.js +1 -1
  60. package/build/js/defaults/DefaultsCamera.d.ts +2 -2
  61. package/build/js/defaults/DefaultsCameraSettings.d.ts +1 -1
  62. package/build/js/defaults/DefaultsDataCaptureView.js +1 -1
  63. package/build/js/global.d.d.ts +1 -0
  64. package/build/js/index.d.ts +2 -2
  65. package/build/js/index.js +1 -1
  66. package/build/js/moduleLoader.d.ts +2 -2
  67. package/build/js/private/CameraAccess.d.ts +1 -1
  68. package/build/js/private/CameraManager.d.ts +2 -2
  69. package/build/js/private/CameraManager.js +1 -1
  70. package/build/js/private/CameraPool.d.ts +3 -2
  71. package/build/js/private/CameraPool.js +1 -1
  72. package/build/js/private/CanvasDrawerWithMetrics.d.ts +2 -2
  73. package/build/js/private/CoreModuleLicenseTextProvider.d.ts +2 -2
  74. package/build/js/private/CoreModuleLicenseTextProvider.js +1 -1
  75. package/build/js/private/CustomLocationsView.js +1 -1
  76. package/build/js/private/DataCaptureContextRelated.d.ts +2 -2
  77. package/build/js/private/FrameReaders/FrameReader.d.ts +2 -2
  78. package/build/js/private/FrameReaders/FrameReader.js +1 -1
  79. package/build/js/private/FrameReaders/FrameReaderAbstract.d.ts +2 -2
  80. package/build/js/private/FrameReaders/GrayScaleFrameReader.d.ts +2 -2
  81. package/build/js/private/FrameReaders/GrayScaleFrameReader.js +1 -1
  82. package/build/js/private/FrameReaders/index.d.ts +2 -2
  83. package/build/js/private/FrameReaders/index.js +1 -1
  84. package/build/js/private/NormalizedModuleLoaderOptions.d.ts +2 -2
  85. package/build/js/private/SingleImageUploaderView.d.ts +2 -2
  86. package/build/js/private/SingleImageUploaderView.js +1 -1
  87. package/build/js/private/ViewControls+related.js +1 -1
  88. package/build/js/private/ViewControls_related.d.ts +2 -2
  89. package/build/js/private/ViewsRegistry.d.ts +2 -2
  90. package/build/js/private/customHowler/AudioCache.d.ts +37 -0
  91. package/build/js/private/customHowler/AudioCache.js +1 -0
  92. package/build/js/private/customHowler/Howl.d.ts +189 -0
  93. package/build/js/private/customHowler/Howl.js +1 -0
  94. package/build/js/private/customHowler/HowlRegistry.d.ts +18 -0
  95. package/build/js/private/customHowler/HowlRegistry.js +1 -0
  96. package/build/js/private/customHowler/Html5Sound.d.ts +52 -0
  97. package/build/js/private/customHowler/Html5Sound.js +1 -0
  98. package/build/js/private/customHowler/UnlockManager.d.ts +39 -0
  99. package/build/js/private/customHowler/UnlockManager.js +1 -0
  100. package/build/js/private/customHowler/WebAudioContextManager.d.ts +161 -0
  101. package/build/js/private/customHowler/WebAudioContextManager.js +1 -0
  102. package/build/js/private/customHowler/debug.d.ts +28 -0
  103. package/build/js/private/customHowler/debug.js +1 -0
  104. package/build/js/private/customHowler/index.d.ts +2 -0
  105. package/build/js/private/customHowler/index.js +1 -0
  106. package/build/js/private/customHowler/setup.d.ts +55 -0
  107. package/build/js/private/customHowler/setup.js +1 -0
  108. package/build/js/private/ui/atoms/Toast.d.ts +2 -2
  109. package/build/js/private/ui/atoms/Toast.js +1 -1
  110. package/build/js/private/ui/molecules/CameraFOVSwitchButton.js +1 -1
  111. package/build/js/private/ui/molecules/CameraSwitchButton.js +1 -1
  112. package/build/js/private/ui/molecules/HintPresenter.d.ts +2 -2
  113. package/build/js/private/ui/molecules/HintPresenter.js +1 -1
  114. package/build/js/private/ui/molecules/TorchSwitchIconButton.d.ts +1 -1
  115. package/build/js/private/ui/molecules/TorchSwitchIconButton.js +1 -1
  116. package/build/js/private/utils/replaceImagesInViewUtils.d.ts +2 -2
  117. package/build/js/worker/ImageConverterForwarder.d.ts +2 -2
  118. package/build/js/worker/ViewInfoHelper.d.ts +2 -2
  119. package/build/js/worker/WorkerMain.d.ts +2 -2
  120. package/build/js/worker/WorkerMain.js +1 -1
  121. package/build/js/worker/coreCapture.inlineWorker.d.ts +2 -2
  122. package/build/js/worker/coreCapture.inlineWorker.js +1 -1
  123. package/build/js/worker/dataCaptureEngine.d.ts +2 -2
  124. package/build/js/worker/dataCaptureEngine.js +1 -1
  125. package/build/js/worker/dataCaptureLoader.d.ts +2 -2
  126. package/build/js/worker/dataCaptureWorkerRelated.d.ts +2 -2
  127. package/build/js/worker/index.d.ts +2 -2
  128. package/build/js/worker/index.js +1 -1
  129. package/package.json +1 -1
  130. package/build/js/chunks/chunk-7JVAQ2A3.js +0 -1
  131. package/build/js/chunks/chunk-BV63CXZF.js +0 -1
  132. package/build/js/chunks/chunk-E7IMQECS.js +0 -35
  133. package/build/js/chunks/chunk-IBDUCVB4.js +0 -1
  134. package/build/js/chunks/chunk-KUAZYGPM.js +0 -1
  135. package/build/js/chunks/chunk-WBYBTOBZ.js +0 -1
  136. package/build/js/chunks/chunk-XW3Z6KKS.js +0 -1
  137. package/build/js/chunks/chunk-YMM2PV73.js +0 -6
  138. package/build/js/private/customHowler.d.ts +0 -27
  139. package/build/js/private/customHowler.js +0 -1
  140. /package/build/js/chunks/{chunk-FHNMZZV2.js → chunk-YRQQE3NR.js} +0 -0
  141. /package/build/js/chunks/{chunk-DQ5X7FNV.js → chunk-ZCEA7BEH.js} +0 -0
@@ -307,6 +307,7 @@ declare class Camera implements FrameSource, Serializable<CameraJSON> {
307
307
  private _isAndroidWebView?;
308
308
  [INTERNAL_ACCESS]: {
309
309
  markAsUnmappedToDeviceCameras: () => void;
310
+ resetUnmappedState: () => void;
310
311
  setDeviceId: (deviceId: string) => void;
311
312
  setLabel: (label: string) => void;
312
313
  markAsBestGuess: () => void;
@@ -369,6 +370,7 @@ declare class Camera implements FrameSource, Serializable<CameraJSON> {
369
370
  */
370
371
  private setupCamera;
371
372
  private markAsUnmappedToDeviceCameras;
373
+ private resetUnmappedState;
372
374
  private markAsBestGuess;
373
375
  private notifyContext;
374
376
  private notifyListeners;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="emscripten" />
2
- export { C as Camera, a as CameraJSON, V as VideoFrameResolution } from './Camera-BnPnXqAt.js';
2
+ export { C as Camera, a as CameraJSON, V as VideoFrameResolution } from './Camera-Cc__1Nc-.js';
3
3
  import './commons/Rect.js';
4
4
  import './private/privateAccess.js';
5
5
  import './private/Serializable.js';
@@ -1 +1 @@
1
- export{a as Camera}from'./chunks/chunk-XW3Z6KKS.js';
1
+ export{a as Camera}from'./chunks/chunk-5DKZR6UB.js';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="emscripten" />
2
- export { b as CameraPosition, c as CameraSettings, d as CameraSettingsFromJSON, e as CameraSettingsJSON, f as CameraSettingsJSONBase, F as FocusGestureStrategy, g as FrameSource, h as FrameSourceJSON, i as FrameSourceListener, j as FrameSourceState, P as PrivateCameraExtraProperties, T as TorchState, k as VideoResolution, l as isCameraFrameSource } from './Camera-BnPnXqAt.js';
2
+ export { b as CameraPosition, c as CameraSettings, d as CameraSettingsFromJSON, e as CameraSettingsJSON, f as CameraSettingsJSONBase, F as FocusGestureStrategy, g as FrameSource, h as FrameSourceJSON, i as FrameSourceListener, j as FrameSourceState, P as PrivateCameraExtraProperties, T as TorchState, k as VideoResolution, l as isCameraFrameSource } from './Camera-Cc__1Nc-.js';
3
3
  import './private/Serializable.js';
4
4
  import './commons/Rect.js';
5
5
  import './commons/Point.js';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="emscripten" />
2
- import { C as Camera, D as DeviceCamera, c as CameraSettings, b as CameraPosition, g as FrameSource, h as FrameSourceJSON } from './Camera-BnPnXqAt.js';
2
+ import { C as Camera, D as DeviceCamera, c as CameraSettings, b as CameraPosition, g as FrameSource, h as FrameSourceJSON } from './Camera-Cc__1Nc-.js';
3
3
  import { DataCaptureContextSettingsJSON, DataCaptureContextSettings } from './DataCaptureContextSettings.js';
4
4
  import { LogoStyle, FocusGestureJSON, ZoomGestureJSON, FocusGesture, ZoomGesture } from './DataCaptureViewPlusRelated.js';
5
5
  import { NotificationPresenter } from './NotificationPresenter/NotificationPresenter.js';
@@ -1178,6 +1178,7 @@ declare class CameraManager {
1178
1178
  private get canvas2dContext();
1179
1179
  private get canvasWebGLContext();
1180
1180
  static instance(): CameraManager;
1181
+ dispose(): void;
1181
1182
  recycle(pixelsData: Uint8ClampedArray): void;
1182
1183
  getCurrentFrame(): FrameCapture | undefined;
1183
1184
  requestVideoFrame(scheduledFunction: FrameRequestCallback | VideoFrameRequestCallback, videoElement?: HTMLVideoElement): number;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="emscripten" />
2
- import './Camera-BnPnXqAt.js';
3
- export { b as Change, D as DataCaptureComponent, e as DataCaptureComponentJSON, f as DataCaptureContext, g as DataCaptureContextCreationOptions, h as DataCaptureContextJSON, j as DataCaptureContextState, m as DataCaptureMode, n as DataCaptureModeJSON, t as ModuleLoaderOptions, P as PrivateCapabilityInfo, u as PrivateChangeSet, v as PrivateDataCaptureComponent, w as PrivateDataCaptureContext, x as PrivateDataCaptureContextOptions, y as PrivateDataCaptureMode, z as PrivateFrameHandler, A as PrivateFrameHandlerResponse } from './DataCaptureContext-LM_Re1B4.js';
2
+ import './Camera-Cc__1Nc-.js';
3
+ export { b as Change, D as DataCaptureComponent, e as DataCaptureComponentJSON, f as DataCaptureContext, g as DataCaptureContextCreationOptions, h as DataCaptureContextJSON, j as DataCaptureContextState, m as DataCaptureMode, n as DataCaptureModeJSON, t as ModuleLoaderOptions, P as PrivateCapabilityInfo, u as PrivateChangeSet, v as PrivateDataCaptureComponent, w as PrivateDataCaptureContext, x as PrivateDataCaptureContextOptions, y as PrivateDataCaptureMode, z as PrivateFrameHandler, A as PrivateFrameHandlerResponse } from './DataCaptureContext-BcSpF9Dt.js';
4
4
  import './DataCaptureContextSettings.js';
5
5
  import './commons/JSONType.js';
6
6
  import './commons/Orientation.js';
@@ -1 +1 @@
1
- export{b as DataCaptureContext}from'./chunks/chunk-YMM2PV73.js';
1
+ export{b as DataCaptureContext}from'./chunks/chunk-ATSAENLJ.js';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="emscripten" />
2
- export { c as ContextStatus, d as ContextStatusJSON, i as DataCaptureContextListener, E as PrivateMirrorAxis } from './DataCaptureContext-LM_Re1B4.js';
3
- import './Camera-BnPnXqAt.js';
2
+ export { c as ContextStatus, d as ContextStatusJSON, i as DataCaptureContextListener, E as PrivateMirrorAxis } from './DataCaptureContext-BcSpF9Dt.js';
3
+ import './Camera-Cc__1Nc-.js';
4
4
  import './ScanditIcon.js';
5
5
  import './DataCaptureContextSettings.js';
6
6
  import './commons/JSONType.js';
@@ -1 +1 @@
1
- export{a as DataCaptureVersion}from'./chunks/chunk-7JVAQ2A3.js';
1
+ export{a as DataCaptureVersion}from'./chunks/chunk-KYAHE2Q3.js';
@@ -1,6 +1,6 @@
1
1
  /// <reference types="emscripten" />
2
- import './Camera-BnPnXqAt.js';
3
- export { o as DataCaptureOverlay, p as DataCaptureView, q as DataCaptureViewConnectOptions, r as DataCaptureViewJSON, s as DataCaptureViewListener } from './DataCaptureContext-LM_Re1B4.js';
2
+ import './Camera-Cc__1Nc-.js';
3
+ export { o as DataCaptureOverlay, p as DataCaptureView, q as DataCaptureViewConnectOptions, r as DataCaptureViewJSON, s as DataCaptureViewListener } from './DataCaptureContext-BcSpF9Dt.js';
4
4
  import './DataCaptureViewPlusRelated.js';
5
5
  import './NotificationPresenter/NotificationPresenter.js';
6
6
  import './commons/Anchor.js';
@@ -1 +1 @@
1
- export{a as DataCaptureView}from'./chunks/chunk-BQO4QYI6.js';
1
+ export{a as DataCaptureView}from'./chunks/chunk-2N546PXQ.js';
@@ -1 +1 @@
1
- export{a as Feedback}from'./chunks/chunk-7EGT56UE.js';
1
+ export{a as Feedback}from'./chunks/chunk-Z6CZGU5N.js';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="emscripten" />
2
- export { F as FrameData, B as PrivateLoadableFrameData, G as convertToPublicFrameData } from './DataCaptureContext-LM_Re1B4.js';
2
+ export { F as FrameData, B as PrivateLoadableFrameData, G as convertToPublicFrameData } from './DataCaptureContext-BcSpF9Dt.js';
3
3
  import './ScanditIcon.js';
4
- import './Camera-BnPnXqAt.js';
4
+ import './Camera-Cc__1Nc-.js';
5
5
  import './commons/Rect.js';
6
6
  import './private/Serializable.js';
7
7
  import './commons/Point.js';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="emscripten" />
2
- import { g as FrameSource, j as FrameSourceState, i as FrameSourceListener } from './Camera-BnPnXqAt.js';
2
+ import { g as FrameSource, j as FrameSourceState, i as FrameSourceListener } from './Camera-Cc__1Nc-.js';
3
3
  import { Serializable } from './private/Serializable.js';
4
4
  import './commons/Rect.js';
5
5
  import './commons/Point.js';
@@ -1 +1 @@
1
- export{a as ImageFrameSource}from'./chunks/chunk-OCKYBUXO.js';
1
+ export{a as ImageFrameSource}from'./chunks/chunk-5VJXJTUX.js';
@@ -8,8 +8,8 @@ import '../commons/Color.js';
8
8
  import '../private/Serializable.js';
9
9
  import '../ScanditIcon.js';
10
10
  import '../private/utils/ScanditHTMLElement.js';
11
- import '../DataCaptureContext-LM_Re1B4.js';
12
- import '../Camera-BnPnXqAt.js';
11
+ import '../DataCaptureContext-BcSpF9Dt.js';
12
+ import '../Camera-Cc__1Nc-.js';
13
13
  import '../commons/Rect.js';
14
14
  import '../commons/Point.js';
15
15
  import '../commons/Size.js';
@@ -1,8 +1,8 @@
1
1
  /// <reference types="emscripten" />
2
- import { H as HintPresenter } from '../../DataCaptureContext-LM_Re1B4.js';
2
+ import { H as HintPresenter } from '../../DataCaptureContext-BcSpF9Dt.js';
3
3
  import { NotificationConfiguration } from '../NotificationConfiguration.js';
4
4
  import { NotificationPresenter } from '../NotificationPresenter.js';
5
- import '../../Camera-BnPnXqAt.js';
5
+ import '../../Camera-Cc__1Nc-.js';
6
6
  import '../../commons/Rect.js';
7
7
  import '../../private/Serializable.js';
8
8
  import '../../commons/Point.js';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="emscripten" />
2
- import { N as GenericHint } from '../../DataCaptureContext-LM_Re1B4.js';
2
+ import { N as GenericHint } from '../../DataCaptureContext-BcSpF9Dt.js';
3
3
  import { NotificationConfiguration } from '../NotificationConfiguration.js';
4
- import '../../Camera-BnPnXqAt.js';
4
+ import '../../Camera-Cc__1Nc-.js';
5
5
  import '../../commons/Rect.js';
6
6
  import '../../private/Serializable.js';
7
7
  import '../../commons/Point.js';
@@ -1 +1 @@
1
- export{c as ScanditIconBuilder,b as ScanditIconForIconType,a as ScanditIconType}from'./chunks/chunk-DQ5X7FNV.js';export{a as ScanditIconShape}from'./chunks/chunk-FMOB7R2T.js';
1
+ export{c as ScanditIconBuilder,b as ScanditIconForIconType,a as ScanditIconType}from'./chunks/chunk-ZCEA7BEH.js';export{a as ScanditIconShape}from'./chunks/chunk-FMOB7R2T.js';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="emscripten" />
2
- import { g as FrameSource, h as FrameSourceJSON, j as FrameSourceState, i as FrameSourceListener } from './Camera-BnPnXqAt.js';
2
+ import { g as FrameSource, h as FrameSourceJSON, j as FrameSourceState, i as FrameSourceListener } from './Camera-Cc__1Nc-.js';
3
3
  import { SingleImageUploaderSettingsJSON, SingleImageUploaderSettings } from './SingleImageUploaderSettings.js';
4
4
  import { Serializable } from './private/Serializable.js';
5
5
  import './commons/Rect.js';
@@ -11,6 +11,10 @@ declare class Sound implements Serializable<SoundJSON> {
11
11
  constructor(resource: string | null);
12
12
  static get defaultSound(): Sound;
13
13
  toJSONObject(): SoundJSON;
14
+ /**
15
+ * Play the sound using Web Audio API.
16
+ * Audio operations run off the main thread for smooth performance.
17
+ */
14
18
  private play;
15
19
  }
16
20
 
package/build/js/Sound.js CHANGED
@@ -1 +1 @@
1
- export{a as Sound}from'./chunks/chunk-BV63CXZF.js';
1
+ export{a as Sound}from'./chunks/chunk-FK5L5YTR.js';
@@ -1 +1 @@
1
- import {a as a$9}from'./chunk-GS7VZDY5.js';import {b as b$2}from'./chunk-RYXKMXTY.js';import {a as a$a}from'./chunk-ARODHCN7.js';import {a as a$j}from'./chunk-A5G2NHT2.js';import {b,a as a$4}from'./chunk-RXDVYEE5.js';import {a as a$h}from'./chunk-IVQL2BYY.js';import {a as a$b}from'./chunk-TPHGDMKG.js';import {a as a$f}from'./chunk-GPPCTFZF.js';import {a as a$l}from'./chunk-Y7V35LNT.js';import {b as b$1}from'./chunk-24MGHMOY.js';import {a as a$e}from'./chunk-KVRNF3VA.js';import {a as a$g}from'./chunk-XIAF6V7E.js';import {a as a$c}from'./chunk-KYNYQBNF.js';import {a as a$7}from'./chunk-RSQRPDVQ.js';import {a}from'./chunk-2OCDIZIS.js';import {a as a$6}from'./chunk-IJQG3OU6.js';import {a as a$8}from'./chunk-I6SWF3FQ.js';import {a as a$o}from'./chunk-LFJUGRQV.js';import {a as a$3}from'./chunk-N5YZEC56.js';import {a as a$2}from'./chunk-VJB527QZ.js';import {a as a$1}from'./chunk-GHTCNOQN.js';import {a as a$d}from'./chunk-UWBNF47P.js';import {g}from'./chunk-E7IMQECS.js';import {a as a$5}from'./chunk-KAFNKP6O.js';import {a as a$n}from'./chunk-E4XJ4GKD.js';import {a as a$k}from'./chunk-QOCHMKNY.js';import {a as a$i}from'./chunk-XR65N6EG.js';import {a as a$m}from'./chunk-WUHKODFA.js';var P="core.camera.recovery",K;K=a$o;var L=class L{constructor(){this.focusGesture=a.focusGesture;this.zoomGesture=a.zoomGesture;this._scanAreaMargins=a.scanAreaMargins;this._pointOfInterest=a.pointOfInterest;this._logoStyle=a.logoStyle;this._logoAnchor=a.logoAnchor;this._logoOffset=a.logoOffset;this._context=null;this.overlays=new Set;this.controls=new Set;this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)};this._previewCamera=null;this.isConnected=false;this.controlsElement=void 0;this.frozenFrameCanvas=document.createElement("canvas");this.listeners=[];this.isVideoElementDetached=false;this.orientation="portrait";this.hiddenProperties={stopVideoTracksOnVisibilityChange:true,freezeFrameWhenStoppingFrameSource:true};this.orientationObserver=new b;this.onOrientationChangeListener=this.onOrientationChange.bind(this);this.onHintPresenterUpdateHandler=this.onHintPresenterUpdate.bind(this);this.onViewFinderUpdateRequestedHandler=this.onViewFinderUpdateRequested.bind(this);this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this.htmlElementDidChangeHandler=this.htmlElementDidChange.bind(this);this.htmlElementDisconnectedHandler=this.htmlElementDisconnected.bind(this);this.notificationPresenter=null;this[K]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this)};this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),a$1.getInstance().updateIfMissing(a$2);}get videoElement(){return g.instance().getVideoElement()}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var t;this._scanAreaMargins=e,(t=this.privateContext)==null||t.update();}get pointOfInterest(){return this._pointOfInterest}set pointOfInterest(e){var t;this._pointOfInterest=e,(t=this.privateContext)==null||t.update();}get logoStyle(){return this._logoStyle}set logoStyle(e){var t;this._logoStyle=e,(t=this.privateContext)==null||t.update();}get logoAnchor(){return this._logoAnchor}set logoAnchor(e){var t;this._logoAnchor=e,(t=this.privateContext)==null||t.update();}get logoOffset(){return this._logoOffset}set logoOffset(e){var t;this._logoOffset=e,(t=this.privateContext)==null||t.update();}get cameraRecoveryText(){return a$1.getInstance().get(P)}get width(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.width)!=null?t:0)}get height(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.height)!=null?t:0)}get canvasDrawer(){return !this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new b$1(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get privateContext(){return this._context}static async forContext(e){let t=new L;return await t.setContext(e),t}showProgressBar(){var e;(e=this.loadingOverlay)==null||e.show();}hideProgressBar(){var e;(e=this.loadingOverlay)==null||e.hide();}setProgressBarPercentage(e){this.loadingOverlay&&(this.loadingOverlay.progress=e);}setProgressBarMessage(e){this.loadingOverlay&&(this.loadingOverlay.message=e);}getContext(){return this._context}async setContext(e){var t,i,a;if(this._context=e,e){if(this.overlays.size>0&&!((t=this.privateContext)!=null&&t.hasModes()))throw new Error(["Cannot assign this view to this context. This view has overlays but the context does not have any mode attached matching these overlays.","Remove the overlays first before attaching the view to the context, or add the corresponding mode to the context before attaching this view."].join(" "));await e.setView(this),(i=this.privateContext)==null||i.subscribeToWorkerMessages(this.onWorkerMessageHandler),(a=this._context)!=null&&a.frameSource&&await this.onFrameSourceChange(this._context.frameSource);}}connectToElement(e,t){var i,a,r,n;this.isConnected||(this.orientationObserver.register(),this.setupHtmlElement(e),(i=this.canvasDrawer)==null||i.startObservingCanvasResize(),this.htmlElementDidChange(),a$3.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(a$4,this.onOrientationChangeListener),(a=this.hintPresenter)==null||a.addEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(r=this.hintPresenter)==null||r.addEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=a$1.getInstance().subscribe(s=>{s[P]!=null&&(this.cameraRecoveryElement.textContent=s[P]);}),this._previewCamera=(n=t==null?void 0:t.camera)!=null?n:null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),this.isConnected=true);}detachFromElement(){var e,t,i,a,r,n,s,h;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener("visibilitychange",this.visibilityListener);for(let m of ["touchend","mousedown"])this.cameraRecoveryElement.removeEventListener(m,this.cameraRecoveryListener);(i=this.loadingOverlay)==null||i.remove(),(a=this.customLocationsView)==null||a.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),(r=this.gestureRecognizer)==null||r.removeAllListeners(),this.clearHtmlElementContent(),a$3.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(a$4,this.onOrientationChangeListener),(n=this.hintPresenter)==null||n.removeEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(s=this.hintPresenter)==null||s.removeEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),(h=this.localizationSubscription)==null||h.cancel(),g.instance().disconnectedCallback(),this._previewCamera&&(this._previewCamera.removeListener(this.frameSourceListener),this._previewCamera=null);for(let m of this.controls)this.removeControl(m);this.isConnected=false;}}async addOverlay(e){var t;this.overlays.has(e)||(this.overlays.add(e),await((t=this.privateContext)==null?void 0:t.update([{type:"addOverlay",newValue:e,view:this}])));}async removeOverlay(e){var t;this.overlays.has(e)&&(await((t=this.privateContext)==null?void 0:t.update([{type:"removeOverlay",newValue:e,view:this}])),this.overlays.delete(e));}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}viewPointForFramePoint(e){var u,V,D,R,F,A,M,I;let t={width:(V=(u=this.htmlElementState)==null?void 0:u.width)!=null?V:0,height:(R=(D=this.htmlElementState)==null?void 0:D.height)!=null?R:0},i={width:(A=(F=this.videoElement)==null?void 0:F.videoWidth)!=null?A:0,height:(I=(M=this.videoElement)==null?void 0:M.videoHeight)!=null?I:0},a=t.width/t.height,r=i.width/i.height,n=a>r?t.width/i.width:t.height/i.height,s={x:e.x*n,y:e.y*n},h=(i.width*n-t.width)/2,m=(i.height*n-t.height)/2;return new a$5(s.x-h,s.y-m)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),a=this.viewPointForFramePoint(e.bottomLeft),r=this.viewPointForFramePoint(e.bottomRight);return new a$6(t,i,r,a)}addControl(e){this.controls.has(e)||(this.controls.add(e),e.install(this).then(t=>{var i;t&&((i=this.privateContext)==null||i.update([{type:"addControl",newValue:e}]));}));}removeControl(e){var t;this.controls.has(e)&&(e.remove(true),this.controls.delete(e),(t=this.privateContext)==null||t.update([{type:"removeControl",newValue:e}]));}toJSONObject(){var e;return {scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:(e=this.logoHidden)!=null?e:false,logoStyle:this.logoStyle,overlays:[...this.overlays].map(t=>t.toJSONObject()),controls:[...this.controls].map(t=>t.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGesture:this.zoomGesture?this.zoomGesture.toJSONObject():null}}isCameraRecoveryVisible(){return !this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e;}async allowPictureInPicture(e){await g.instance().allowPictureInPicture(e);}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),a=this.viewPointForFramePoint(e.bottomLeft),r=this.viewPointForFramePoint(e.bottomRight),n=this.viewPointForFramePoint(e.centerLeft),s=this.viewPointForFramePoint(e.centerRight),h=this.viewPointForFramePoint(e.topCenter),m=this.viewPointForFramePoint(e.bottomCenter),u=this.viewPointForFramePoint(e.center);return new a$7(t,i,r,a,n,h,s,m,u)}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e);}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(g.instance().isMirrorImageEnabled()),Object.keys(e).includes("removedIds")?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e));}getNotificationPresenter(){var e;if(!this.notificationPresenter){let t=(e=this.htmlElement)==null?void 0:e.querySelector(b$2.tag);if(!t)throw new Error("Notification presenter cannot be found. Please ensure the DataCaptureView is connected.");this.notificationPresenter=new a$8(t);}return this.notificationPresenter}removeStyles(){for(let e of document.querySelectorAll("style[scandit]"))e.remove();}onHintPresenterUpdate(e){var t;(t=this.privateContext)==null||t.workerCommand("hintPresenterV2update",{});}async onViewFinderUpdateRequested(e){var i;let t=await((i=this.privateContext)==null?void 0:i.workerCommand("getViewfinderInfo",{}));t!=null&&this.updateHintPresenterViewFinderRect(t.rect);}clearHtmlElementContent(){var e;this.htmlElement&&((e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML="",this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0);}setupHtmlElement(e){var r,n,s;this.createStyles(),this.htmlElement=e,b$2.register(),a$9.register(),a$a.register();let t=a$d`<div class="${a$b.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${a$b.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${a$b.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${a$b.FROZEN_FRAME}" data-js-id="frozen-frame" alt="Last captured camera frame shown while camera is on standby" hidden /><canvas></canvas><div data-js-id="${a$c.CUSTOM_VIEW_CONTAINER}"></div><${b$2.tag}></${b$2.tag}><${a$9.tag}></${a$9.tag}><div class="${a$b.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${a$b.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${a$b.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=t,g.instance().connectedCallback(this.htmlElement.querySelector('[data-js-id="video-container"]')),this.isVideoElementDetached=false,this.hintPresenter=this.htmlElement.querySelector(b$2.tag),this.notificationPresenter=this.hintPresenter?new a$8(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=a$a.create(),this.loadingOverlay.hide(),(r=this.htmlElement.querySelector('[data-js-id="loading-overlay"]'))==null||r.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new a$e,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${a$c.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=h=>this.viewAnchorPositionsForFrameAnchorPositions(h),this.containerElement=this.htmlElement.querySelector(`.${a$b.CONTAINER_CLASS_NAME}`),this.cameraPaintboardElement=this.containerElement.querySelector('[data-js-id="camera-paintboard"]'),this.singleImageUploaderPaintboardElement=this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]');let i=this.cameraPaintboardElement.querySelector("canvas");this.canvasElement==null?this.canvasElement=i:i.replaceWith(this.canvasElement);let a=this.cameraPaintboardElement.querySelector('[data-js-id="frozen-frame"]');this.frozenFrame==null?this.frozenFrame=a:a.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(a$9.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${a$b.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${a$b.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null&&((s=(n=this._context)==null?void 0:n.frameSource)==null||s.switchToDesiredState(this.lastFrameSourceState)),document.addEventListener("visibilitychange",this.visibilityListener);for(let h of ["touchend","mousedown"])this.cameraRecoveryElement.addEventListener(h,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new a$f(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new a$g(this.htmlElement),this.gestureRecognizer.addListener({onTap:async h=>{var m;(m=this.privateContext)==null||m.workerCommand("onTap",{point:h.toJSONObject()});}});}setupHtmlElementSingleImageUploader(e){var i;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new a$h(e),this.singleImageUploaderView.mount(this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]'));let t=(i=this._context)==null?void 0:i.frameSource;this.singleImageUploaderView.onInputCheck(a=>{t.getCurrentState()!=="starting"&&a.preventDefault();}),this.singleImageUploaderView.onBeforeFileRead(()=>{t._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=t._context.hasEnabledMode());}),this.singleImageUploaderView.onImageLoadError(()=>{t.currentState="starting",a$i.log(a$i.Level.Error,"Could not load image from selected file");}),this.singleImageUploaderView.onFileReaderError(a=>{var n,s;let r=a.target;t.currentState="starting",a$i.log(a$i.Level.Error,`Error while reading the file: ${(s=(n=r.error)==null?void 0:n.toString())!=null?s:""}`);}),this.singleImageUploaderView.onCaptureReady(async a=>{await t.processUploadedFileCapture(a);}),this.singleImageUploaderView.setButtonState(t.getCurrentState()==="starting"?"enabled":"disabled"),t.addView(this.singleImageUploaderView);}setupHtmlElementVisibility(e){this.cameraPaintboardElement!=null&&(this.cameraPaintboardElement.hidden=e!=="camera"),this.singleImageUploaderPaintboardElement!=null&&(this.singleImageUploaderPaintboardElement.hidden=e!=="singleImageUploader");}createStyles(){if(document.querySelector("style[scandit]")===null){let e=a$j();for(let[t,i]of Object.entries(e))i.setAttribute("scandit",`data-capture-sdk-${t}`),document.head.append(i);}}async onOrientationChange(e){var t,i;this.orientation=e.detail.value,await((i=this.privateContext)==null?void 0:i.update([{type:"viewChange",newValue:{...(t=this.htmlElementState)==null?void 0:t.toJSONObject(),orientation:this.orientation}}]));}htmlElementDidChange(){var i,a;if(!this.htmlElementState)return;let e=this.htmlElementState,t=e.toJSONObject();if(!a$f.areEquivalentJSONStates(this.lastHtmlElementState,t)){this.orientation=this.orientationObserver.orientation.value,(i=this.privateContext)==null||i.update([{type:"viewChange",newValue:{...e.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=t,(a=this.canvasDrawer)==null||a.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(t.visible);for(let r of this.listeners)typeof r.didChangeSize=="function"&&r.didChangeSize(this,new a$k(t.size.width.value,t.size.height.value),this.orientation);}}async htmlElementDisconnected(){var e,t,i,a,r,n;g.instance().disconnectedCallback(),this.lastFrameSourceState=(t=(e=this._context)==null?void 0:e.frameSource)==null?void 0:t.getCurrentState(),await((a=(i=this._context)==null?void 0:i.frameSource)==null?void 0:a.switchToDesiredState("off")),await((n=this.privateContext)==null?void 0:n.update([{type:"viewChange",newValue:{...(r=this.htmlElementState)==null?void 0:r.toJSONObject(),orientation:this.orientation}}])),this.isConnected=false;}attachAdditionalLayer(e,t){var i;t==="above-controls"&&((i=this.controlsElement)==null||i.insertAdjacentElement("afterend",e));}handleVideoDisplay(e){this.videoElement==null||this.cameraPaintboardElement==null||(!e&&!this.isVideoElementDetached?(this.videoElement.width=0,this.videoElement.height=0,this.videoElement.style.opacity="0",this.videoElement.style.visibility="hidden",document.body.append(this.videoElement),this.isVideoElementDetached=true):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement("afterbegin",this.videoElement),this.isVideoElementDetached=false,this.videoElement.style.removeProperty("visibility"),this.videoElement.removeAttribute("width"),this.videoElement.removeAttribute("height"),this.videoElement.style.removeProperty("opacity")));}isCanvasDrawerWithMetrics(e){return e instanceof a$l}onWorkerMessage(e){var t,i;switch(e.type){case "draw":{this.drawEngineCommands(e.payload);break}case "performanceMetricsReport":{let a=this._canvasDrawer;a!=null&&this.isCanvasDrawerWithMetrics(a)&&a.setPerformanceMetrics(e.payload);break}case "contextDidChangeStatus":{let a=a$m.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),a.isValid?(this.clearError(),this.setVideoElementOpacity("1")):this.displayError(a);break}case "viewSizeChanged":{let a=e.payload;if(a==null)return;this.onSDCViewSizeChangedCallback(a);break}default:{(i=this.hintPresenter)==null||i.handleMessage(e);break}}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect);}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new a$n(new a$5(e.origin.x,e.origin.y),new a$k(e.size.width,e.size.height)));}drawEngineCommands(e){var t;(t=this.canvasDrawer)==null||t.draw(e);}displayError(e){this.errorElement.textContent=`Error ${e.code}: ${e.message}`,this.errorElement.hidden=false;}clearError(){this.errorElement.textContent="",this.errorElement.hidden=true;}updateControls(){var e;for(let t of this.controls)(e=t.update)==null||e.call(t,this);}async onFrameSourceChange(e){let t=e==null?void 0:e.type;if(this.setupHtmlElementVisibility(t),t==="camera"){let i=e==null?void 0:e.getCurrentState();i!=null&&await this.onCameraStateChanged(i);}else t==="singleImageUploader"&&this.setupHtmlElementSingleImageUploader(e.settings);}async onCameraStateChanged(e){var t;switch((t=this.cameraPaintboardElement)==null||t.classList.toggle(a$b.PAINTBOARD_CLASS_NAME_STATE_ON,e==="on"),e){case "stopping":{this.hiddenProperties.freezeFrameWhenStoppingFrameSource&&this.freezeFrame(),this.setVideoElementOpacity("0");return}case "starting":case "bootingUp":case "wakingUp":{if(!this.htmlElement){a$i.error("cannot set frame source stream before connecting view to an HTML element");return}this.videoElement&&(g.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),g.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity("0"));return}case "off":{this.setVideoElementOpacity("0"),this.updateControls();return}case "on":{await g.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity("1");break}case "goingToSleep":{this.freezeFrame();break}}}setVideoElementOpacity(e){this.videoElement&&(this.videoElement.style.opacity=e),this.canvasElement&&(this.canvasElement.style.opacity=e);}onSingleImageUploaderSettingsChange(e){this.setupHtmlElementSingleImageUploader(e);}setHiddenProperty(e,t){this.hiddenProperties[e]=t;}async onVisibilityChange(){var t,i;let e=(t=this.videoElement)==null?void 0:t.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState==="hidden"&&g.instance().stopVideoTracks(),document.visibilityState==="visible"&&g.instance().activeCamera!=null&&e!=null))if(!e.active||(i=e.getVideoTracks()[0])!=null&&i.muted)try{a$i.debug('Detected visibility change ("visible") event with inactive video source, try to reinitialize camera'),await g.instance().reinitializeCamera();}catch{}else a$i.debug('Detected visibility change ("visible") event with active video source, replay video'),g.instance().playVideo();}async cameraRecovery(e){e.preventDefault(),g.instance().activeCamera=g.instance().selectedCamera,await g.instance().reinitializeCamera();}freezeFrame(){var i;if(!this.frozenFrame)return;let e=g.instance().getCurrentFrame();if(!e)return;let t=new ImageData(e.data,e.width,e.height);this.frozenFrameCanvas.width=t.width,this.frozenFrameCanvas.height=t.height,this.frozenFrame.width=t.width,this.frozenFrame.height=t.height,(i=this.frozenFrameCanvas.getContext("2d"))==null||i.putImageData(t,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL("image/jpeg",.4),this.frozenFrame.classList.toggle(a$b.MIRRORED_CLASS_NAME,g.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=false;}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src="",this.frozenFrame.hidden=true);}},B=L;export{B as a};
1
+ import {a as a$9}from'./chunk-GS7VZDY5.js';import {b as b$2}from'./chunk-HILZP6OW.js';import {a as a$a}from'./chunk-ARODHCN7.js';import {a as a$j}from'./chunk-A5G2NHT2.js';import {b,a as a$4}from'./chunk-RXDVYEE5.js';import {a as a$h}from'./chunk-XDTXM6UX.js';import {a as a$b}from'./chunk-TPHGDMKG.js';import {a as a$f}from'./chunk-GPPCTFZF.js';import {a as a$l}from'./chunk-Y7V35LNT.js';import {b as b$1}from'./chunk-24MGHMOY.js';import {a as a$e}from'./chunk-DTREAYZQ.js';import {a as a$g}from'./chunk-XIAF6V7E.js';import {a as a$c}from'./chunk-KYNYQBNF.js';import {a}from'./chunk-UQVVJP5Z.js';import {a as a$7}from'./chunk-RSQRPDVQ.js';import {a as a$6}from'./chunk-IJQG3OU6.js';import {a as a$8}from'./chunk-I6SWF3FQ.js';import {a as a$3}from'./chunk-N5YZEC56.js';import {a as a$2}from'./chunk-VJB527QZ.js';import {a as a$1}from'./chunk-GHTCNOQN.js';import {a as a$d}from'./chunk-UWBNF47P.js';import {g}from'./chunk-U6MNF7M6.js';import {a as a$o}from'./chunk-LFJUGRQV.js';import {a as a$n}from'./chunk-E4XJ4GKD.js';import {a as a$k}from'./chunk-QOCHMKNY.js';import {a as a$5}from'./chunk-KAFNKP6O.js';import {a as a$i}from'./chunk-XR65N6EG.js';import {a as a$m}from'./chunk-WUHKODFA.js';var P="core.camera.recovery",K;K=a$o;var L=class L{constructor(){this.focusGesture=a.focusGesture;this.zoomGesture=a.zoomGesture;this._scanAreaMargins=a.scanAreaMargins;this._pointOfInterest=a.pointOfInterest;this._logoStyle=a.logoStyle;this._logoAnchor=a.logoAnchor;this._logoOffset=a.logoOffset;this._context=null;this.overlays=new Set;this.controls=new Set;this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)};this._previewCamera=null;this.isConnected=false;this.controlsElement=void 0;this.frozenFrameCanvas=document.createElement("canvas");this.listeners=[];this.isVideoElementDetached=false;this.orientation="portrait";this.hiddenProperties={stopVideoTracksOnVisibilityChange:true,freezeFrameWhenStoppingFrameSource:true};this.orientationObserver=new b;this.onOrientationChangeListener=this.onOrientationChange.bind(this);this.onHintPresenterUpdateHandler=this.onHintPresenterUpdate.bind(this);this.onViewFinderUpdateRequestedHandler=this.onViewFinderUpdateRequested.bind(this);this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this.htmlElementDidChangeHandler=this.htmlElementDidChange.bind(this);this.htmlElementDisconnectedHandler=this.htmlElementDisconnected.bind(this);this.notificationPresenter=null;this[K]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this)};this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),a$1.getInstance().updateIfMissing(a$2);}get videoElement(){return g.instance().getVideoElement()}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var t;this._scanAreaMargins=e,(t=this.privateContext)==null||t.update();}get pointOfInterest(){return this._pointOfInterest}set pointOfInterest(e){var t;this._pointOfInterest=e,(t=this.privateContext)==null||t.update();}get logoStyle(){return this._logoStyle}set logoStyle(e){var t;this._logoStyle=e,(t=this.privateContext)==null||t.update();}get logoAnchor(){return this._logoAnchor}set logoAnchor(e){var t;this._logoAnchor=e,(t=this.privateContext)==null||t.update();}get logoOffset(){return this._logoOffset}set logoOffset(e){var t;this._logoOffset=e,(t=this.privateContext)==null||t.update();}get cameraRecoveryText(){return a$1.getInstance().get(P)}get width(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.width)!=null?t:0)}get height(){var e,t;return Math.round((t=(e=this.htmlElementState)==null?void 0:e.height)!=null?t:0)}get canvasDrawer(){return !this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new b$1(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get privateContext(){return this._context}static async forContext(e){let t=new L;return await t.setContext(e),t}showProgressBar(){var e;(e=this.loadingOverlay)==null||e.show();}hideProgressBar(){var e;(e=this.loadingOverlay)==null||e.hide();}setProgressBarPercentage(e){this.loadingOverlay&&(this.loadingOverlay.progress=e);}setProgressBarMessage(e){this.loadingOverlay&&(this.loadingOverlay.message=e);}getContext(){return this._context}async setContext(e){var t,i,a;if(this._context=e,e){if(this.overlays.size>0&&!((t=this.privateContext)!=null&&t.hasModes()))throw new Error(["Cannot assign this view to this context. This view has overlays but the context does not have any mode attached matching these overlays.","Remove the overlays first before attaching the view to the context, or add the corresponding mode to the context before attaching this view."].join(" "));await e.setView(this),(i=this.privateContext)==null||i.subscribeToWorkerMessages(this.onWorkerMessageHandler),(a=this._context)!=null&&a.frameSource&&await this.onFrameSourceChange(this._context.frameSource);}}connectToElement(e,t){var i,a,r,n;this.isConnected||(this.orientationObserver.register(),this.setupHtmlElement(e),(i=this.canvasDrawer)==null||i.startObservingCanvasResize(),this.htmlElementDidChange(),a$3.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(a$4,this.onOrientationChangeListener),(a=this.hintPresenter)==null||a.addEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(r=this.hintPresenter)==null||r.addEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=a$1.getInstance().subscribe(s=>{s[P]!=null&&(this.cameraRecoveryElement.textContent=s[P]);}),this._previewCamera=(n=t==null?void 0:t.camera)!=null?n:null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),this.isConnected=true);}detachFromElement(){var e,t,i,a,r,n,s,h;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener("visibilitychange",this.visibilityListener);for(let m of ["touchend","mousedown"])this.cameraRecoveryElement.removeEventListener(m,this.cameraRecoveryListener);(i=this.loadingOverlay)==null||i.remove(),(a=this.customLocationsView)==null||a.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),(r=this.gestureRecognizer)==null||r.removeAllListeners(),this.clearHtmlElementContent(),a$3.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(a$4,this.onOrientationChangeListener),(n=this.hintPresenter)==null||n.removeEventListener("hintpresenterupdate",this.onHintPresenterUpdateHandler),(s=this.hintPresenter)==null||s.removeEventListener("hintpresenterviewfinderupdaterequested",this.onViewFinderUpdateRequestedHandler),(h=this.localizationSubscription)==null||h.cancel(),g.instance().disconnectedCallback(),this._previewCamera&&(this._previewCamera.removeListener(this.frameSourceListener),this._previewCamera=null);for(let m of this.controls)this.removeControl(m);this.isConnected=false;}}async addOverlay(e){var t;this.overlays.has(e)||(this.overlays.add(e),await((t=this.privateContext)==null?void 0:t.update([{type:"addOverlay",newValue:e,view:this}])));}async removeOverlay(e){var t;this.overlays.has(e)&&(await((t=this.privateContext)==null?void 0:t.update([{type:"removeOverlay",newValue:e,view:this}])),this.overlays.delete(e));}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}viewPointForFramePoint(e){var u,V,D,R,F,A,M,I;let t={width:(V=(u=this.htmlElementState)==null?void 0:u.width)!=null?V:0,height:(R=(D=this.htmlElementState)==null?void 0:D.height)!=null?R:0},i={width:(A=(F=this.videoElement)==null?void 0:F.videoWidth)!=null?A:0,height:(I=(M=this.videoElement)==null?void 0:M.videoHeight)!=null?I:0},a=t.width/t.height,r=i.width/i.height,n=a>r?t.width/i.width:t.height/i.height,s={x:e.x*n,y:e.y*n},h=(i.width*n-t.width)/2,m=(i.height*n-t.height)/2;return new a$5(s.x-h,s.y-m)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),a=this.viewPointForFramePoint(e.bottomLeft),r=this.viewPointForFramePoint(e.bottomRight);return new a$6(t,i,r,a)}addControl(e){this.controls.has(e)||(this.controls.add(e),e.install(this).then(t=>{var i;t&&((i=this.privateContext)==null||i.update([{type:"addControl",newValue:e}]));}));}removeControl(e){var t;this.controls.has(e)&&(e.remove(true),this.controls.delete(e),(t=this.privateContext)==null||t.update([{type:"removeControl",newValue:e}]));}toJSONObject(){var e;return {scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:(e=this.logoHidden)!=null?e:false,logoStyle:this.logoStyle,overlays:[...this.overlays].map(t=>t.toJSONObject()),controls:[...this.controls].map(t=>t.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGesture:this.zoomGesture?this.zoomGesture.toJSONObject():null}}isCameraRecoveryVisible(){return !this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e;}async allowPictureInPicture(e){await g.instance().allowPictureInPicture(e);}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),i=this.viewPointForFramePoint(e.topRight),a=this.viewPointForFramePoint(e.bottomLeft),r=this.viewPointForFramePoint(e.bottomRight),n=this.viewPointForFramePoint(e.centerLeft),s=this.viewPointForFramePoint(e.centerRight),h=this.viewPointForFramePoint(e.topCenter),m=this.viewPointForFramePoint(e.bottomCenter),u=this.viewPointForFramePoint(e.center);return new a$7(t,i,r,a,n,h,s,m,u)}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e);}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(g.instance().isMirrorImageEnabled()),Object.keys(e).includes("removedIds")?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e));}getNotificationPresenter(){var e;if(!this.notificationPresenter){let t=(e=this.htmlElement)==null?void 0:e.querySelector(b$2.tag);if(!t)throw new Error("Notification presenter cannot be found. Please ensure the DataCaptureView is connected.");this.notificationPresenter=new a$8(t);}return this.notificationPresenter}removeStyles(){for(let e of document.querySelectorAll("style[scandit]"))e.remove();}onHintPresenterUpdate(e){var t;(t=this.privateContext)==null||t.workerCommand("hintPresenterV2update",{});}async onViewFinderUpdateRequested(e){var i;let t=await((i=this.privateContext)==null?void 0:i.workerCommand("getViewfinderInfo",{}));t!=null&&this.updateHintPresenterViewFinderRect(t.rect);}clearHtmlElementContent(){var e;this.htmlElement&&((e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML="",this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0);}setupHtmlElement(e){var r,n,s;this.createStyles(),this.htmlElement=e,b$2.register(),a$9.register(),a$a.register();let t=a$d`<div class="${a$b.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${a$b.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${a$b.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${a$b.FROZEN_FRAME}" data-js-id="frozen-frame" alt="Last captured camera frame shown while camera is on standby" hidden /><canvas></canvas><div data-js-id="${a$c.CUSTOM_VIEW_CONTAINER}"></div><${b$2.tag}></${b$2.tag}><${a$9.tag}></${a$9.tag}><div class="${a$b.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${a$b.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${a$b.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=t,g.instance().connectedCallback(this.htmlElement.querySelector('[data-js-id="video-container"]')),this.isVideoElementDetached=false,this.hintPresenter=this.htmlElement.querySelector(b$2.tag),this.notificationPresenter=this.hintPresenter?new a$8(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=a$a.create(),this.loadingOverlay.hide(),(r=this.htmlElement.querySelector('[data-js-id="loading-overlay"]'))==null||r.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new a$e,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${a$c.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=h=>this.viewAnchorPositionsForFrameAnchorPositions(h),this.containerElement=this.htmlElement.querySelector(`.${a$b.CONTAINER_CLASS_NAME}`),this.cameraPaintboardElement=this.containerElement.querySelector('[data-js-id="camera-paintboard"]'),this.singleImageUploaderPaintboardElement=this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]');let i=this.cameraPaintboardElement.querySelector("canvas");this.canvasElement==null?this.canvasElement=i:i.replaceWith(this.canvasElement);let a=this.cameraPaintboardElement.querySelector('[data-js-id="frozen-frame"]');this.frozenFrame==null?this.frozenFrame=a:a.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(a$9.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${a$b.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${a$b.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null&&((s=(n=this._context)==null?void 0:n.frameSource)==null||s.switchToDesiredState(this.lastFrameSourceState)),document.addEventListener("visibilitychange",this.visibilityListener);for(let h of ["touchend","mousedown"])this.cameraRecoveryElement.addEventListener(h,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new a$f(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new a$g(this.htmlElement),this.gestureRecognizer.addListener({onTap:async h=>{var m;(m=this.privateContext)==null||m.workerCommand("onTap",{point:h.toJSONObject()});}});}setupHtmlElementSingleImageUploader(e){var i;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new a$h(e),this.singleImageUploaderView.mount(this.containerElement.querySelector('[data-js-id="singleimage-paintboard"]'));let t=(i=this._context)==null?void 0:i.frameSource;this.singleImageUploaderView.onInputCheck(a=>{t.getCurrentState()!=="starting"&&a.preventDefault();}),this.singleImageUploaderView.onBeforeFileRead(()=>{t._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=t._context.hasEnabledMode());}),this.singleImageUploaderView.onImageLoadError(()=>{t.currentState="starting",a$i.log(a$i.Level.Error,"Could not load image from selected file");}),this.singleImageUploaderView.onFileReaderError(a=>{var n,s;let r=a.target;t.currentState="starting",a$i.log(a$i.Level.Error,`Error while reading the file: ${(s=(n=r.error)==null?void 0:n.toString())!=null?s:""}`);}),this.singleImageUploaderView.onCaptureReady(async a=>{await t.processUploadedFileCapture(a);}),this.singleImageUploaderView.setButtonState(t.getCurrentState()==="starting"?"enabled":"disabled"),t.addView(this.singleImageUploaderView);}setupHtmlElementVisibility(e){this.cameraPaintboardElement!=null&&(this.cameraPaintboardElement.hidden=e!=="camera"),this.singleImageUploaderPaintboardElement!=null&&(this.singleImageUploaderPaintboardElement.hidden=e!=="singleImageUploader");}createStyles(){if(document.querySelector("style[scandit]")===null){let e=a$j();for(let[t,i]of Object.entries(e))i.setAttribute("scandit",`data-capture-sdk-${t}`),document.head.append(i);}}async onOrientationChange(e){var t,i;this.orientation=e.detail.value,await((i=this.privateContext)==null?void 0:i.update([{type:"viewChange",newValue:{...(t=this.htmlElementState)==null?void 0:t.toJSONObject(),orientation:this.orientation}}]));}htmlElementDidChange(){var i,a;if(!this.htmlElementState)return;let e=this.htmlElementState,t=e.toJSONObject();if(!a$f.areEquivalentJSONStates(this.lastHtmlElementState,t)){this.orientation=this.orientationObserver.orientation.value,(i=this.privateContext)==null||i.update([{type:"viewChange",newValue:{...e.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=t,(a=this.canvasDrawer)==null||a.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(t.visible);for(let r of this.listeners)typeof r.didChangeSize=="function"&&r.didChangeSize(this,new a$k(t.size.width.value,t.size.height.value),this.orientation);}}async htmlElementDisconnected(){var e,t,i,a,r,n;g.instance().disconnectedCallback(),this.lastFrameSourceState=(t=(e=this._context)==null?void 0:e.frameSource)==null?void 0:t.getCurrentState(),await((a=(i=this._context)==null?void 0:i.frameSource)==null?void 0:a.switchToDesiredState("off")),await((n=this.privateContext)==null?void 0:n.update([{type:"viewChange",newValue:{...(r=this.htmlElementState)==null?void 0:r.toJSONObject(),orientation:this.orientation}}])),this.isConnected=false;}attachAdditionalLayer(e,t){var i;t==="above-controls"&&((i=this.controlsElement)==null||i.insertAdjacentElement("afterend",e));}handleVideoDisplay(e){this.videoElement==null||this.cameraPaintboardElement==null||(!e&&!this.isVideoElementDetached?(this.videoElement.width=0,this.videoElement.height=0,this.videoElement.style.opacity="0",this.videoElement.style.visibility="hidden",document.body.append(this.videoElement),this.isVideoElementDetached=true):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement("afterbegin",this.videoElement),this.isVideoElementDetached=false,this.videoElement.style.removeProperty("visibility"),this.videoElement.removeAttribute("width"),this.videoElement.removeAttribute("height"),this.videoElement.style.removeProperty("opacity")));}isCanvasDrawerWithMetrics(e){return e instanceof a$l}onWorkerMessage(e){var t,i;switch(e.type){case "draw":{this.drawEngineCommands(e.payload);break}case "performanceMetricsReport":{let a=this._canvasDrawer;a!=null&&this.isCanvasDrawerWithMetrics(a)&&a.setPerformanceMetrics(e.payload);break}case "contextDidChangeStatus":{let a=a$m.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),a.isValid?(this.clearError(),this.setVideoElementOpacity("1")):this.displayError(a);break}case "viewSizeChanged":{let a=e.payload;if(a==null)return;this.onSDCViewSizeChangedCallback(a);break}default:{(i=this.hintPresenter)==null||i.handleMessage(e);break}}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect);}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new a$n(new a$5(e.origin.x,e.origin.y),new a$k(e.size.width,e.size.height)));}drawEngineCommands(e){var t;(t=this.canvasDrawer)==null||t.draw(e);}displayError(e){this.errorElement.textContent=`Error ${e.code}: ${e.message}`,this.errorElement.hidden=false;}clearError(){this.errorElement.textContent="",this.errorElement.hidden=true;}updateControls(){var e;for(let t of this.controls)(e=t.update)==null||e.call(t,this);}async onFrameSourceChange(e){let t=e==null?void 0:e.type;if(this.setupHtmlElementVisibility(t),t==="camera"){let i=e==null?void 0:e.getCurrentState();i!=null&&await this.onCameraStateChanged(i);}else t==="singleImageUploader"&&this.setupHtmlElementSingleImageUploader(e.settings);}async onCameraStateChanged(e){var t;switch((t=this.cameraPaintboardElement)==null||t.classList.toggle(a$b.PAINTBOARD_CLASS_NAME_STATE_ON,e==="on"),e){case "stopping":{this.hiddenProperties.freezeFrameWhenStoppingFrameSource&&this.freezeFrame(),this.setVideoElementOpacity("0");return}case "starting":case "bootingUp":case "wakingUp":{if(!this.htmlElement){a$i.error("cannot set frame source stream before connecting view to an HTML element");return}this.videoElement&&(g.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),g.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity("0"));return}case "off":{this.setVideoElementOpacity("0"),this.updateControls();return}case "on":{await g.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity("1");break}case "goingToSleep":{this.freezeFrame();break}}}setVideoElementOpacity(e){this.videoElement&&(this.videoElement.style.opacity=e),this.canvasElement&&(this.canvasElement.style.opacity=e);}onSingleImageUploaderSettingsChange(e){this.setupHtmlElementSingleImageUploader(e);}setHiddenProperty(e,t){this.hiddenProperties[e]=t;}async onVisibilityChange(){var t,i;let e=(t=this.videoElement)==null?void 0:t.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState==="hidden"&&g.instance().stopVideoTracks(),document.visibilityState==="visible"&&g.instance().activeCamera!=null&&e!=null))if(!e.active||(i=e.getVideoTracks()[0])!=null&&i.muted)try{a$i.debug('Detected visibility change ("visible") event with inactive video source, try to reinitialize camera'),await g.instance().reinitializeCamera();}catch{}else a$i.debug('Detected visibility change ("visible") event with active video source, replay video'),g.instance().playVideo();}async cameraRecovery(e){e.preventDefault(),g.instance().activeCamera=g.instance().selectedCamera,await g.instance().reinitializeCamera();}freezeFrame(){var i;if(!this.frozenFrame)return;let e=g.instance().getCurrentFrame();if(!e)return;let t=new ImageData(e.data,e.width,e.height);this.frozenFrameCanvas.width=t.width,this.frozenFrameCanvas.height=t.height,this.frozenFrame.width=t.width,this.frozenFrame.height=t.height,(i=this.frozenFrameCanvas.getContext("2d"))==null||i.putImageData(t,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL("image/jpeg",.4),this.frozenFrame.classList.toggle(a$b.MIRRORED_CLASS_NAME,g.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=false;}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src="",this.frozenFrame.hidden=true);}},B=L;export{B as a};
@@ -1 +1 @@
1
- import {a}from'./chunk-XW3Z6KKS.js';import {d}from'./chunk-YUZDO2PC.js';import {f,g}from'./chunk-3D2HNEVH.js';var u=class{constructor(){this.type="camera";this.customImages={idle:"",pressed:""};this.cameraSwitchButton=void 0;this.CameraSwitchButtonClass=void 0;this.currentFrameSource=null;this.view=void 0;this.onCameraSwitched=this.handleCameraSwitched.bind(this);this.isTransitioning=false;}get idleImage(){return this.customImages.idle}set idleImage(t){this.customImages.idle=t,this.applyCustomImagesToButton();}get pressedImage(){return this.customImages.pressed}set pressedImage(t){this.customImages.pressed=t,this.applyCustomImagesToButton();}toJSONObject(){return {type:this.type}}async install(t){var i,r,s;this.CameraSwitchButtonClass||(this.CameraSwitchButtonClass=await import('../private/ui/molecules/CameraSwitchButton.js').then(l=>l.CameraSwitchButton),(i=this.CameraSwitchButtonClass)==null||i.register()),this.view=t,this.currentFrameSource=(s=(r=t.getContext())==null?void 0:r.frameSource)!=null?s:null,this.cameraSwitchButton=this.CameraSwitchButtonClass.create(),this.cameraSwitchButton.slot="topRight",this.cameraSwitchButton.hidden=true,this.cameraSwitchButton.addEventListener("camera-switched",this.onCameraSwitched);let e=t.controlsElement;e&&e.append(this.cameraSwitchButton),this.applyCustomImagesToButton();let a=await this.canShow();return this.updateButtonVisibility(a),true}remove(t){t&&this.cameraSwitchButton&&(this.cameraSwitchButton.removeEventListener("camera-switched",this.onCameraSwitched),this.cameraSwitchButton.remove(),this.cameraSwitchButton=null,this.currentFrameSource=null,this.view=void 0);}async update(t){var a,i;this.currentFrameSource=(i=(a=t.getContext())==null?void 0:a.frameSource)!=null?i:null,this.view=t;let e=await this.canShow();this.updateButtonVisibility(e);}updateButtonVisibility(t){this.cameraSwitchButton&&(this.cameraSwitchButton.hidden=!t);}applyCustomImagesToButton(){if(!this.cameraSwitchButton)return;this.customImages.idle||this.customImages.pressed?this.cameraSwitchButton.setCustomImages(this.customImages):this.cameraSwitchButton.useCustomImages=false;}async canShow(){if(!f(this.currentFrameSource)||this.currentFrameSource.getCurrentState()!=="on")return false;try{return (await d.getCameras(false,true)).length>1}catch{return false}}handleCameraSwitched(t){let{currentMode:e}=t.detail,a=e==="back"?"front":"back";this.cameraSwitchButton.mode=a,this.handleCameraSwitch();}async handleCameraSwitch(){if(this.isTransitioning)return;let t=await this.getNextDeviceCamera();t&&await this.switchCameras(t);}async getNextDeviceCamera(){var r;let t=await a.getAll(false,true),e=this.currentFrameSource?this.currentFrameSource:null,a$1=e==null?void 0:e.deviceId,i=t.findIndex(s=>s.deviceId===a$1);return i>-1?(r=t[i+1])!=null?r:t[0]:t.length>0?t[0]:null}async switchCameras(t){var s;this.isTransitioning=true;let e=(s=this.view)==null?void 0:s.getContext(),a=e==null?void 0:e.frameSource,i,r;a!=null&&(i=new g(a.settings),r=a.desiredState),await(a==null?void 0:a.switchToDesiredState("off")),i!=null&&await t.applySettings(i),await(e==null?void 0:e.setFrameSource(t)),await(e==null?void 0:e.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{u as a};
1
+ import {a}from'./chunk-5DKZR6UB.js';import {d}from'./chunk-YUZDO2PC.js';import {f,g}from'./chunk-3D2HNEVH.js';var u=class{constructor(){this.type="camera";this.customImages={idle:"",pressed:""};this.cameraSwitchButton=void 0;this.CameraSwitchButtonClass=void 0;this.currentFrameSource=null;this.view=void 0;this.onCameraSwitched=this.handleCameraSwitched.bind(this);this.isTransitioning=false;}get idleImage(){return this.customImages.idle}set idleImage(t){this.customImages.idle=t,this.applyCustomImagesToButton();}get pressedImage(){return this.customImages.pressed}set pressedImage(t){this.customImages.pressed=t,this.applyCustomImagesToButton();}toJSONObject(){return {type:this.type}}async install(t){var i,r,s;this.CameraSwitchButtonClass||(this.CameraSwitchButtonClass=await import('../private/ui/molecules/CameraSwitchButton.js').then(l=>l.CameraSwitchButton),(i=this.CameraSwitchButtonClass)==null||i.register()),this.view=t,this.currentFrameSource=(s=(r=t.getContext())==null?void 0:r.frameSource)!=null?s:null,this.cameraSwitchButton=this.CameraSwitchButtonClass.create(),this.cameraSwitchButton.slot="topRight",this.cameraSwitchButton.hidden=true,this.cameraSwitchButton.addEventListener("camera-switched",this.onCameraSwitched);let e=t.controlsElement;e&&e.append(this.cameraSwitchButton),this.applyCustomImagesToButton();let a=await this.canShow();return this.updateButtonVisibility(a),true}remove(t){t&&this.cameraSwitchButton&&(this.cameraSwitchButton.removeEventListener("camera-switched",this.onCameraSwitched),this.cameraSwitchButton.remove(),this.cameraSwitchButton=null,this.currentFrameSource=null,this.view=void 0);}async update(t){var a,i;this.currentFrameSource=(i=(a=t.getContext())==null?void 0:a.frameSource)!=null?i:null,this.view=t;let e=await this.canShow();this.updateButtonVisibility(e);}updateButtonVisibility(t){this.cameraSwitchButton&&(this.cameraSwitchButton.hidden=!t);}applyCustomImagesToButton(){if(!this.cameraSwitchButton)return;this.customImages.idle||this.customImages.pressed?this.cameraSwitchButton.setCustomImages(this.customImages):this.cameraSwitchButton.useCustomImages=false;}async canShow(){if(!f(this.currentFrameSource)||this.currentFrameSource.getCurrentState()!=="on")return false;try{return (await d.getCameras(false,true)).length>1}catch{return false}}handleCameraSwitched(t){let{currentMode:e}=t.detail,a=e==="back"?"front":"back";this.cameraSwitchButton.mode=a,this.handleCameraSwitch();}async handleCameraSwitch(){if(this.isTransitioning)return;let t=await this.getNextDeviceCamera();t&&await this.switchCameras(t);}async getNextDeviceCamera(){var r;let t=await a.getAll(false,true),e=this.currentFrameSource?this.currentFrameSource:null,a$1=e==null?void 0:e.deviceId,i=t.findIndex(s=>s.deviceId===a$1);return i>-1?(r=t[i+1])!=null?r:t[0]:t.length>0?t[0]:null}async switchCameras(t){var s;this.isTransitioning=true;let e=(s=this.view)==null?void 0:s.getContext(),a=e==null?void 0:e.frameSource,i,r;a!=null&&(i=new g(a.settings),r=a.desiredState),await(a==null?void 0:a.switchToDesiredState("off")),i!=null&&await t.applySettings(i),await(e==null?void 0:e.setFrameSource(t)),await(e==null?void 0:e.frameSource).switchToDesiredState(r!=null?r:"on"),this.isTransitioning=false;}};export{u as a};
@@ -0,0 +1 @@
1
+ import {b,c,d}from'./chunk-TNIR74NN.js';function n(){b();}function p(){c();}function i(){d();}export{n as a,p as b,i as c};
@@ -0,0 +1 @@
1
+ import {g as g$1}from'./chunk-U6MNF7M6.js';import {d}from'./chunk-YUZDO2PC.js';import {b}from'./chunk-QHBYNYWX.js';import {a as a$1}from'./chunk-LFJUGRQV.js';import {b as b$1}from'./chunk-YONR3EGV.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {g}from'./chunk-3D2HNEVH.js';import {a}from'./chunk-6LHGFWQI.js';import {a as a$2}from'./chunk-QCZSSQAQ.js';d.addVideoDevicesListener(w=>{b.integrateIncomingVideoDevices(w.map(e=>u.fromDeviceCamera(e)));});var C;C=a$1;var s=class s{constructor(e){this._label="";this._deviceId="";this._notFoundOnDevice=false;this._isBestGuess=false;this.type="camera";this._currentState="off";this._settings=new g;this._desiredTorchState="off";this._desiredState="off";this.listeners=[];this._context=null;this[C]={markAsUnmappedToDeviceCameras:this.markAsUnmappedToDeviceCameras.bind(this),resetUnmappedState:this.resetUnmappedState.bind(this),setDeviceId:this.setDeviceId.bind(this),setLabel:this.setLabel.bind(this),markAsBestGuess:this.markAsBestGuess.bind(this)};this._captureAndSendBound=this.captureAndSend.bind(this);this.stateTransitionStrategyMap={off:{on:this.transitionFromStateOffToOn.bind(this),standby:this.transitionFromStateOffToStandby.bind(this)},on:{off:this.transitionFromStateOnToOff.bind(this),standby:this.transitionFromStateOnToStandby.bind(this)},standby:{off:this.transitionFromStateStandbyToOff.bind(this),on:this.transitionFromStateStandbyToOn.bind(this)}};this.cameraManager=e!=null?e:g$1.instance();}static pickBestGuess(){return s.getOrCreate({position:"worldFacing",bestGuess:true})}static pickBestGuessForPosition(e){if(!a.availablePositions.includes(e))throw new Error(`Invalid camera position: "${e}"`);return s.getOrCreate({position:e})}static forDeviceId(e){return s.getOrCreate({deviceId:e})}static async getAll(e,t){return await d.getCameras(e!=null?e:false,t!=null?t:false),[...b.get()]}static getOrCreate(e){let{deviceId:t,position:r,bestGuess:i}=e,n=new s;return n._deviceId=t!=null?t:"",n.position=r!=null?r:"worldFacing",i&&n[a$1].markAsBestGuess(),b.getOrCreate(n)}static fromDeviceCamera(e){let t=new s;return t.position=e.position,t._deviceId=e.deviceId,t._label=e.label,t}get deviceId(){return this._deviceId}get label(){return this._label}get desiredState(){return this._desiredState}get settings(){return this._settings}get currentResolution(){var e;return (e=this._currentResolution)!=null?e:null}setDeviceId(e){this._deviceId=e;}setLabel(e){this._label=e;}get context(){return this._context}set context(e){this._context=e,this._context&&this.currentState==="on"&&this.startSendingCapturesToWorker();}get currentState(){return this._currentState}async switchToDesiredState(e){var t,r;if(this.currentTransitionStrategyPromise&&await this.currentTransitionStrategyPromise,this._notFoundOnDevice&&(e==="on"||e==="standby"))throw new a$2({message:`Cannot switch state to ${e}. This camera could not be mapped to a detected camera on the device. Please use another camera and delete this one.`,name:"Unmapped Camera"});return this.currentTransitionStrategyPromise=(r=(t=this.stateTransitionStrategyMap[this.currentState])==null?void 0:t[e])==null?void 0:r.call(t).catch(i=>{if(i instanceof DOMException&&i.message==="The associated Track is in an invalid state"){a$3.log(a$3.Level.Warn,i);return}throw i}),this.currentTransitionStrategyPromise}getDesiredTorchState(){return this._desiredTorchState}async setDesiredTorchState(e){this._desiredTorchState=e,await this.cameraManager.setTorchEnabled(this._desiredTorchState==="on"),await this.notifyContext({type:"torchState",newValue:this._desiredTorchState});}async isTorchAvailable(){return this.cameraManager.isTorchAvailable()}addListener(e){e!=null&&(this.listeners.includes(e)||this.listeners.push(e));}removeListener(e){e!=null&&this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}async applySettings(e){var r;this._settings=new g(e);let t=this.settings.getProperty("grayScaleFrameReader");if(this.cameraManager.setFrameReaderType(t===true?"GRAYSCALE":"RGBA"),this.currentState==="on"||this.currentState==="standby"){let i=this.cameraManager.activeCameraSettings;(i==null?void 0:i.preferredResolution)!==this.settings.preferredResolution&&(await this.cameraManager.applyCameraSettings(this.settings),(r=this.cameraManager.activeCamera)!=null&&r.currentResolution&&(this._currentResolution={width:this.cameraManager.activeCamera.currentResolution.width,height:this.cameraManager.activeCamera.currentResolution.height})),await this.cameraManager.setZoom(this.settings.zoomFactor);let n=this.settings.getProperty("minFrameRate"),h=this.settings.getProperty("maxFrameRate");(n!=null||h!=null)&&await this.cameraManager.setFrameRate({min:n,max:h});let l=this.settings.getProperty("manualLensPosition");l!=null&&await this.cameraManager.setFocus(l);let p=this.settings.getProperty("exposureTargetBias"),S=this.settings.getProperty("exposureDuration");(p!=null||S!=null)&&await this.cameraManager.setExposure({compensation:p,time:S});}return this.notifyContext({type:"cameraSettings",newValue:this.settings})}toJSONObject(){return {type:this.type,position:this.position,settings:this.settings.toJSONObject(),desiredState:this.desiredState,desiredTorchState:this._desiredTorchState}}getMirrorImageEnabled(){var e;return (e=this._desiredMirrorImageEnabled)!=null?e:this.cameraManager.isMirrorImageEnabled()}async setMirrorImageEnabled(e){this._desiredMirrorImageEnabled=e,this.cameraManager.setMirrorImageEnabled(e,true),this.context&&await this.context.setFrameSource(this);}getCurrentState(){return this._currentState}async setClipArea(e){await this.cameraManager.setClipArea(e);}async setCurrentState(e){if(e!==this._currentState){this._currentState=e,this.notifyListeners();try{await this.notifyContext({type:"frameSourceState",newValue:e}),e==="on"&&this.startSendingCapturesToWorker();}catch{a$3.warn("Error while notifying context about new state of Camera");}}}async setupCamera(){if(this.cameraManager.setSelectedCameraSettings(this.settings),this.deviceId==="")this.cameraManager.setSelectedCamera(),this.cameraManager.setInitialCameraPosition(this.position);else {let t=(await d.getCameras()).find(r=>r.deviceId===this.deviceId);t&&(this.cameraManager.setInitialCameraPosition(t.position),this.cameraManager.setSelectedCamera(t));}await this.cameraManager.setupCameras(),typeof this._desiredMirrorImageEnabled=="boolean"?this.cameraManager.setMirrorImageEnabled(this._desiredMirrorImageEnabled,true):this.cameraManager.setMirrorImageEnabled(this.cameraManager.isMirrorImageEnabled(),false),this.context&&await this.context.setFrameSource(this),this.cameraManager.activeCamera&&(this._deviceId=this.cameraManager.activeCamera.deviceId,this._label=this.cameraManager.activeCamera.label,this.position=this.cameraManager.activeCamera.position,this._currentResolution=this.cameraManager.activeCamera.currentResolution);}markAsUnmappedToDeviceCameras(){this._notFoundOnDevice=true;}resetUnmappedState(){this._notFoundOnDevice=false;}markAsBestGuess(){this._isBestGuess=true;}async notifyContext(e){if(this.context)return this.context.update([e])}notifyListeners(){for(let e of this.listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}updateCanvasVideoImage(){this.currentState==="on"&&this.context&&(this.cameraManager.updateCanvasVideoImage(),this._lastCanvasVideoPreviewAnimationFrame=this.cameraManager.requestVideoFrame(this.updateCanvasVideoImage.bind(this)));}async captureAndSend(){if(this.currentState!=="on"||!this.context)return;if(!this.context.hasEnabledMode()){this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);return}let e=null;try{e=this.cameraManager.captureImage();}catch(t){a$3.warn("Camera: error while capturing image.",t);}finally{if(e!=null)if(this.cameraManager.synchronousFrameHandling){let t=await this.context.sendFrameToProcessor(e);this.cameraManager.recycle(t.data);}else this.context.sendFrameToProcessor(e).then(t=>(this.cameraManager.recycle(t.data),null)).catch(t=>{a$3.warn("error while recycling uint8array",t);});this._lastCaptureRequestAnimationFrame=this.cameraManager.requestVideoFrame(this._captureAndSendBound);}}startSendingCapturesToWorker(){this.stopSendingCapturesToWorker(),this.captureAndSend();}stopSendingCapturesToWorker(){this._lastCanvasVideoPreviewAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCanvasVideoPreviewAnimationFrame),this._lastCaptureRequestAnimationFrame!=null&&this.cameraManager.cancelVideoFrame(this._lastCaptureRequestAnimationFrame);}async transitionFromStateOffToOn(){if(!(this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp")){this._desiredState="on",await this.setCurrentState("starting");try{await this.setupCamera(),await this.setCurrentState("on");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}}}async transitionFromStateOffToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "On".'),await this.transitionFromStateOffToOn();return}this._desiredState="standby",await this.setCurrentState("bootingUp");try{await this.setupCamera(),this.cameraManager.pauseStream(),await this.setCurrentState("standby");}catch(e){throw a$3.log(a$3.Level.Error,e),await this.setCurrentState("off"),e}await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateOnToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("stopping"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateOnToStandby(){if(!(this.currentState==="standby"||this.currentState==="bootingUp"||this.currentState==="goingToSleep")){if(await this.isAndroidWebView()){a$3.log(a$3.Level.Warn,'Warning: "Standby" state does not work inside web views. Falling back to state "Off".'),await this.transitionFromStateOnToOff();return}this._desiredState="standby",await this.setCurrentState("goingToSleep"),this.cameraManager.pauseStream(),await this.setCurrentState("standby"),await this.setDesiredTorchState("off");}}async transitionFromStateStandbyToOff(){this.currentState==="off"||this.currentState==="stopping"||(this._desiredState="off",await this.setCurrentState("shuttingDown"),await this.cameraManager.stopStream(),await this.setCurrentState("off"),await this.setDesiredTorchState("off"));}async transitionFromStateStandbyToOn(){this.currentState==="on"||this.currentState==="starting"||this.currentState==="wakingUp"||(this._desiredState="on",await this.setCurrentState("wakingUp"),this.cameraManager.resumeStream(),await this.setCurrentState("on"));}async isAndroidWebView(){return this._isAndroidWebView==null&&(this._isAndroidWebView=await b$1.isAndroidWebView()),this._isAndroidWebView}isZoomAvailable(){var e;return ((e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom)!=null}},u=s;export{u as a};
@@ -1 +1 @@
1
- import {e}from'./chunk-E7IMQECS.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a}from'./chunk-QCZSSQAQ.js';var m=class i{constructor(){this.type="imageFrameSource";this._listeners=new Set;this._currentState="off";this._desiredState="off";this._context=null;this._imageData=null;}get desiredState(){return this._desiredState}get context(){return this._context}set context(e){this._context=e;}get currentState(){return this._currentState}static async fromFile(e){let r=URL.createObjectURL(e),t=new Image;t.src=r;try{await t.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted file is not an image"})}finally{URL.revokeObjectURL(r);}return i.fromImage(t)}static async fromImage(e){let r=new i;try{await e.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted image cannot be decoded"})}let t=r.getCanvasAndContext(e.width,e.height);return t.drawImage(e,0,0),r._imageData=t.getImageData(0,0,e.width,e.height,{colorSpace:"srgb"}),r}static async fromImageData(e){let r=new i,t=r.getCanvasAndContext(e.width,e.height);try{t.putImageData(e,0,0);}catch(n){throw new a({name:"InvalidImageError",message:`Submitted image data does not seem valid (details: ${n})`})}return r._imageData=e,r}async switchToDesiredState(e){if(e==="on"){if(this.currentState==="on")return}else if(this.currentState==="off")return;if(this._desiredState=e,e==="off"){await this.setCurrentState("off");return}return this._imageData==null?(a$1.log(a$1.Level.Warn,"No image data to process."),this.processSubmittedImage({data:new Uint8ClampedArray(0),width:0,height:0,colorSpace:"srgb"})):this.processSubmittedImage(this._imageData)}addListener(e){e!=null&&this._listeners.add(e);}removeListener(e){e!=null&&this._listeners.delete(e);}toJSONObject(){return {type:this.type}}getCurrentState(){return this._currentState}getCanvasAndContext(e,r){let t=document.createElement("canvas");t.width=e,t.height=r;let n=t.getContext("2d");if(n==null)throw new a({name:"ImageFrameSourceError",message:"Could not generate a canvas context to get image data"});return n}async setCurrentState(e){if(e!==this._currentState)return this._currentState=e,this.notifyListeners(),this.notifyContext({type:"frameSourceState",newValue:e})}async notifyContext(e){if(this._context)return this._context.update([e])}notifyListeners(){for(let e of this._listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}async processSubmittedImage(e$1){var t;await this.setCurrentState("on");let r={data:e$1.data,width:e$1.width,height:e$1.height,frameId:e()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState("off");}};export{m as a};
1
+ import {e}from'./chunk-U6MNF7M6.js';import {a as a$1}from'./chunk-XR65N6EG.js';import {a}from'./chunk-QCZSSQAQ.js';var m=class i{constructor(){this.type="imageFrameSource";this._listeners=new Set;this._currentState="off";this._desiredState="off";this._context=null;this._imageData=null;}get desiredState(){return this._desiredState}get context(){return this._context}set context(e){this._context=e;}get currentState(){return this._currentState}static async fromFile(e){let r=URL.createObjectURL(e),t=new Image;t.src=r;try{await t.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted file is not an image"})}finally{URL.revokeObjectURL(r);}return i.fromImage(t)}static async fromImage(e){let r=new i;try{await e.decode();}catch{throw new a({name:"InvalidImageError",message:"Submitted image cannot be decoded"})}let t=r.getCanvasAndContext(e.width,e.height);return t.drawImage(e,0,0),r._imageData=t.getImageData(0,0,e.width,e.height,{colorSpace:"srgb"}),r}static async fromImageData(e){let r=new i,t=r.getCanvasAndContext(e.width,e.height);try{t.putImageData(e,0,0);}catch(n){throw new a({name:"InvalidImageError",message:`Submitted image data does not seem valid (details: ${n})`})}return r._imageData=e,r}async switchToDesiredState(e){if(e==="on"){if(this.currentState==="on")return}else if(this.currentState==="off")return;if(this._desiredState=e,e==="off"){await this.setCurrentState("off");return}return this._imageData==null?(a$1.log(a$1.Level.Warn,"No image data to process."),this.processSubmittedImage({data:new Uint8ClampedArray(0),width:0,height:0,colorSpace:"srgb"})):this.processSubmittedImage(this._imageData)}addListener(e){e!=null&&this._listeners.add(e);}removeListener(e){e!=null&&this._listeners.delete(e);}toJSONObject(){return {type:this.type}}getCurrentState(){return this._currentState}getCanvasAndContext(e,r){let t=document.createElement("canvas");t.width=e,t.height=r;let n=t.getContext("2d");if(n==null)throw new a({name:"ImageFrameSourceError",message:"Could not generate a canvas context to get image data"});return n}async setCurrentState(e){if(e!==this._currentState)return this._currentState=e,this.notifyListeners(),this.notifyContext({type:"frameSourceState",newValue:e})}async notifyContext(e){if(this._context)return this._context.update([e])}notifyListeners(){for(let e of this._listeners)e.didChangeState&&e.didChangeState(this,this.currentState);}async processSubmittedImage(e$1){var t;await this.setCurrentState("on");let r={data:e$1.data,width:e$1.width,height:e$1.height,frameId:e()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState("off");}};export{m as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-SJIN27Q5.js';import {a as a$1}from'./chunk-CX2R2XQK.js';var d=class{constructor(e,n){this._paused=true;this._ended=false;this._seek=0;this.onEndedHandler=this.onEnded.bind(this);this.onPauseHandler=this.onPause.bind(this);this.onPlayHandler=this.onPlay.bind(this);this.node=new Audio,this.node.src=e,this.onInactive=n,this.node.addEventListener("ended",this.onEndedHandler),this.node.addEventListener("pause",this.onPauseHandler),this.node.addEventListener("play",this.onPlayHandler);}onEnded(){var e,n;this._paused=true,this._ended=true,(e=a)==null||e("\u{1F3B5} HTML5Sound: Playback ended"),(n=this.onInactive)==null||n.call(this,this);}onPause(){var e,n;this._paused=true,(e=a)==null||e("\u{1F3B5} HTML5Sound: Paused"),(n=this.onInactive)==null||n.call(this,this);}onPlay(){var e;this._paused=false,this._ended=false,(e=a)==null||e("\u{1F3B5} HTML5Sound: Playing");}play(){this._seek=0,this._paused=false,this._ended=false,this.node.currentTime=0,this.node.volume=1,a$1(()=>{let e=this.node.play();e&&e.catch(n=>{var s;n instanceof DOMException&&n.name==="AbortError"||(s=a)==null||s(`\u274C HTML5Sound.play() failed: ${n instanceof Error?n.message:String(n)}`);});});}pause(){this._paused||(this._paused=true,this._seek=this.node.currentTime,this.node.pause());}stop(){this._paused=true,this._ended=true,this._seek=0,this.node.currentTime=0,this.node.pause();}dispose(){var e;this.node.removeEventListener("ended",this.onEndedHandler),this.node.removeEventListener("pause",this.onPauseHandler),this.node.removeEventListener("play",this.onPlayHandler),(e=a)==null||e("\u{1F3B5} HTML5Sound: Disposed");}};export{d as a};
@@ -0,0 +1,6 @@
1
+ import {a as a$7}from'./chunk-O5D4KVS5.js';import {a as a$4}from'./chunk-ACFJP5SR.js';import {a as a$a,c as c$3,b as b$3}from'./chunk-L66S4DN2.js';import {a as a$j}from'./chunk-BA3RP6L2.js';import {a as a$8}from'./chunk-AIC4H5KG.js';import {a as a$h}from'./chunk-KSCFPJAW.js';import {a as a$f}from'./chunk-W3X3ZRQZ.js';import {a as a$d}from'./chunk-JS3T7K2Z.js';import {b as b$2}from'./chunk-6H6FKGVE.js';import {a as a$c}from'./chunk-N5YZEC56.js';import {a as a$6}from'./chunk-VJB527QZ.js';import {a as a$5}from'./chunk-GHTCNOQN.js';import {a as a$1}from'./chunk-LXOZUOZU.js';import {a as a$g}from'./chunk-FGO2SSRS.js';import {c as c$1,a as a$e}from'./chunk-3JLTBSEJ.js';import {g,e as e$1}from'./chunk-U6MNF7M6.js';import {a as a$9}from'./chunk-GPJEB376.js';import {b as b$1}from'./chunk-YONR3EGV.js';import {c as c$2,e}from'./chunk-SBC5K7IT.js';import {a as a$3}from'./chunk-XR65N6EG.js';import {f as f$1}from'./chunk-3D2HNEVH.js';import {a as a$i}from'./chunk-WUHKODFA.js';import {a as a$2}from'./chunk-7SW2PEHB.js';import {a as a$b}from'./chunk-QCZSSQAQ.js';import {c}from'./chunk-TR3NGINC.js';var Q=[{from:"unconfigured",to:"configuring"},{from:"configuring",to:"configured"},{from:"configuring",to:"unconfigured"},{from:"configured",to:"creating-context"},{from:"creating-context",to:"ready"},{from:"creating-context",to:"unconfigured"},{from:"ready",to:"unconfigured"},{from:"configured",to:"unconfigured"}];function v(C,e,t){let r=t.value;return t.value=function(...n){let i=f.stateMachine;return i.currentState==="ready"&&f.mainDataCaptureLoader!=null?r.apply(this,n):i.isInitializing||i.currentState==="configured"?i.waitForState("ready").then(()=>r.apply(this,n)):Promise.reject(new Error(`Please call DataCaptureContext.forLicenseKey() before calling ${String(e)}`))},t}function G(C){return C[a$j]!=null}function x(C){return "skipSerialization"in C||C[a$j]!=null}var q,Y,_,a=class a{constructor(){this._asyncImageConverterInstance=void 0;this.framework="web";this.runtimeEnvironment={deviceOS:(q=b$1.getUserAgentInfo().getOS().name)!=null?q:"",browser:(Y=b$1.getUserAgentInfo().getBrowser().name)!=null?Y:"",browserVersion:(_=b$1.getUserAgentInfo().getBrowser().version)!=null?_:"",get deviceModelName(){let{model:e,vendor:t}=b$1.getUserAgentInfo().getDevice();return (t==null||t==="")&&(t="Unknown"),(e==null||e==="")&&(e="Unknown"),[t,e].join(" ")}};this.settings=new a$2;this._frameSource=null;this._view=null;this.modes=new Set;this.components=[];this.listeners=[];this.updateListeners=new Set;this.cameraPropertiesReportListener=this.reportCameraProperties.bind(this);this.cameraAccessErrorListener=this.onCameraAccessError.bind(this);this.onWorkerMessageListener=this.onWorkerMessage.bind(this);this.onVisibilityChangeListener=this.onVisibilityChange.bind(this);this.batteryChangeListener=this.onBatteryChange.bind(this);this.pendingWorkerMessageListeners=new Set;this.delayedRegistration=false;this.highEndBlurryRecognition=false;this._frameHandlers=[];this._useSynchronousFrameFlow=false;}static get moduleLicenseTextProviders(){return [new b]}static get sharedInstance(){return a._sharedInstance==null&&(a._sharedInstance=new a),a._sharedInstance}static get currentState(){return a.stateMachine.currentState}static get isReady(){return a.stateMachine.currentState==="ready"}static get isInitializing(){return a.stateMachine.isInitializing}static addStateListener(e){a.stateMachine.addListener(e);}static removeStateListener(e){a.stateMachine.removeListener(e);}async initializeWithOptions(e){var t,r,n,i,s,o,u,c,l;a.deviceID===""&&(a.deviceID=await b$1.getDeviceId()),this.licenseKey=(r=(t=e.licenseKey)!=null?t:a.userLicenseKey)!=null?r:"",this.deviceName=(n=e.deviceName)!=null?n:"",this.dataCaptureInstance=(i=e.dataCaptureInstance)!=null?i:a.mainDataCaptureLoader,this.delayedRegistration=(s=e.delayedRegistration)!=null?s:false,e.settings!=null&&(this.settings=e.settings),this.highEndBlurryRecognition=(l=(c=(o=e.dataCaptureInstance)==null?void 0:o.highEndBlurryRecognition)!=null?c:(u=a.mainDataCaptureLoader)==null?void 0:u.highEndBlurryRecognition)!=null?l:false;for(let S of this.pendingWorkerMessageListeners)this.dataCaptureInstance.addWorkerListener(S);this.pendingWorkerMessageListeners.clear(),this.settings!=null&&await this.applySettings(this.settings),await this.createContext();}get frameSource(){return this._frameSource}get workerCommand(){if(this.dataCaptureInstance==null)throw new Error("Cannot call workerCommand before dataCaptureInstance is set");return this.dataCaptureInstance.workerCommand.bind(this.dataCaptureInstance)}static async forLicenseKey(e,t){return a$3.debug(`forLicenseKey called, current state: ${a.stateMachine.currentState}`),a.stateMachine.currentState==="ready"?(a$3.debug("DataCaptureContext is already ready, returning existing instance"),a.sharedInstance):a.stateMachine.isInitializing?(a$3.debug("DataCaptureContext is already initializing, waiting for completion"),await a.stateMachine.waitForState("ready"),a.sharedInstance):(a.stateMachine.currentState==="unconfigured"&&(a$3.debug("Starting initialization from unconfigured state"),await a.stateMachine.executeAsyncTransition({targetState:"configuring",action:async()=>{await a.internalConfigure(e,t);},onSuccess:"configured",onError:"unconfigured"}),await a.stateMachine.executeAsyncTransition({targetState:"creating-context",action:async()=>{await a.sharedInstance.initializeWithOptions({licenseKey:e,deviceName:t.deviceName,settings:t.settings});},onSuccess:"ready",onError:"unconfigured"})),a.sharedInstance)}static async internalConfigure(e$1,t){var S;a$4(),c$1(),a$5.getInstance().updateIfMissing(a$6);let{forceAllPolyfills:r,overrideThreadsSupport:n,overrideSimdSupport:i}=a.getOverridesFromQueryString(),[s,o,u]=await Promise.all([a$7({forceAllPolyfills:r}),c$2(),e()]);n!=="auto"&&(a$3.warn(`Threads support override: was ${u} is now ${n==="on"}`),u=n==="on"),i!=="auto"&&(a$3.warn(`SIMD support override: was ${o} is now ${i==="on"}`),o=i==="on"),a.capabilityInfo={simdSupport:o,threadsSupport:u},a$3.debug(`Capability info detected - SIMD: ${o}, Threads: ${u}`),await a.validateOptions({...t,licenseKey:e$1});let c={licenseKey:e$1,libraryLocation:a$8(t.libraryLocation),moduleLoaders:t.moduleLoaders,logLevel:(S=t.logLevel)!=null?S:a$3.Level.Debug,verifyResponseHash:true,loadProgressNotifier:b$2.notify.bind(b$2),simdSupport:o,threadsSupport:u};a$3.setLevel(c.logLevel),a.userLicenseKey=c.licenseKey,a.libraryLocation=c.libraryLocation,b$2.subscribe(a.updateViewsWithProgress);let l=b$1.checkBrowserCompatibility();if(!l.fullSupport&&!l.scannerSupport)throw new a$9(l);b$1.isSupportedIOSVersion()||a$3.warn(`Warning: Minimum supported iOS version is 14.6.
2
+ Please check the minimum system requirements here:
3
+ https://docs.scandit.com/system-requirements#browser-compatibility`),a.dataCaptureLoaders=await a.loadModules(c.moduleLoaders,c),a.mainDataCaptureLoader=[...a.dataCaptureLoaders.entries()][0][1],b$2.unsubscribe(a.updateViewsWithProgress);}static async forLicenseKeyInElectronPath(e,t){if(!a$a())throw new a$b({name:"MisconfigurationError",message:"forLicenseKeyInElectronPath can only be used in Electron applications"});let r=await c$3({licenseDataPath:e});if(r==null)throw new a$b({name:"NoLicenseKeyError",message:`Cannot retrieve license key for Electron app at ${e}`});return a.forLicenseKey(r.licenseKey,{...t})}static updateViewsWithProgress({percentage:e}){for(let t of a$c.values())t.setProgressBarPercentage(e);}static getOverridesFromQueryString(){var s,o,u;function e(c){return ["auto","off","on"].includes(c)}let t=new URLSearchParams(window.location.search),[r="auto",n="auto",i=false]=[(s=t.get("pthreads"))==null?void 0:s.toLowerCase(),(o=t.get("simd"))==null?void 0:o.toLowerCase(),((u=t.get("forceAllPolyfills"))==null?void 0:u.toLowerCase())==="true"];return {overrideThreadsSupport:e(r)?r:"auto",overrideSimdSupport:e(n)?n:"auto",forceAllPolyfills:i}}static async validateOptions(e){if(e.licenseKey==null||e.licenseKey.trim().length<64)throw new a$b({name:"NoLicenseKeyError",message:"No license key provided"});if(typeof e.libraryLocation!="string")throw new a$b({name:"MisconfigurationError",message:'Option "libraryLocation" was not provided'});if(!Array.isArray(e.moduleLoaders)||e.moduleLoaders.length===0)throw new a$b({name:"MisconfigurationError",message:'Option "moduleLoaders" is missing or empty'});let t=e.moduleLoaders.map(r=>r.moduleName);if(!["BarcodeCapture","IdCapture","LabelCapture"].includes(t[0]))throw new a$b({name:"MisconfigurationError",message:'Main modules must be loaded before side modules. For example "BarcodeCapture" must be loaded before "Parser".'})}static async loadModules(e,t){let r=new Map,n=new Map;for(let i of e)n.set(i.moduleName,i.load(t));await Promise.all(n.values());for(let[i,s]of n)r.set(i,await s);return r}static async getOpenSourceSoftwareLicenseInfo(){let e=[];for(let r of a.moduleLicenseTextProviders){let n=await r.getLicenseText();e.push(n);}let t=e.join(`
4
+
5
+ `);return new a$d(t)}async setFrameSource(e){let t=e!==this._frameSource;if(this._frameSource!==null&&(this._frameSource.context=null),this._frameSource=e!=null?e:null,e&&(e.context=this,await this.workerCommand("setFrameSource",{mirrorAxis:this.getMirrorAxisForFrameSource(e),isCameraFrameSource:f$1(e)})),await this.update([{type:"frameSourceState",newValue:this.frameSource}]),t)for(let r of this.listeners)r.didChangeFrameSource&&r.didChangeFrameSource(this,this._frameSource);}addListener(e){this.listeners.includes(e)||this.listeners.push(e);}async flushAnalytics(){await this.workerCommand("flushAnalytics",{});}removeListener(e){this.listeners.includes(e)&&this.listeners.splice(this.listeners.indexOf(e),1);}async addMode(e){this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async removeMode(e){this.modes.delete(e),await e.detachedFromContext(),this.updateCameraFrameFlow(),await this.update([],{updateContext:!x(e)});}async setMode(e){this.modes.has(e)||(this.modes.clear(),this.modes.add(e),await e.attachedToContext(this),this.updateCameraFrameFlow(),await this.update());}async removeCurrentMode(){for(let e of this.modes)await e.detachedFromContext();this.modes.clear(),await this.update();}async removeAllModes(){let e=Array.from(this.modes);for(let t of e)await this.removeMode(t);}async dispose(){if(a.stateMachine.currentState!=="unconfigured")try{await a.stateMachine.executeAsyncTransition({targetState:"unconfigured",action:async()=>{g.instance().removeListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().removeListener("cameraAccessError",this.cameraAccessErrorListener),this.unsubscribeToVisibilityChange(this.onVisibilityChangeListener);for(let e of this.modes)await e.detachedFromContext();this._view&&(await this._view.setContext(null),this._view=null),this.dataCaptureInstance&&(await this.dataCaptureInstance.terminateDataCaptureWorker(true).catch(()=>{}),this.dataCaptureInstance=void 0),this.webBatteryInterface&&(this.webBatteryInterface.dispose(),this.webBatteryInterface=void 0),a.deviceID="";},onSuccess:"unconfigured",onError:"unconfigured"});}catch(e){if(a.stateMachine.currentState==="unconfigured")return;throw e}finally{this.modes.clear(),this.listeners=[],this.components.length=0,this.updateListeners.clear(),this.pendingWorkerMessageListeners.clear(),this.delayedRegistration=false,this.highEndBlurryRecognition=false,this._frameHandlers.length=0,this.frameSource&&(this.frameSource.context=null,this._frameSource=null),g.instance().dispose(),this.licenseKey="",this.deviceName="",a$e();}}async applySettings(e){this.settings=e,await this.update();}toJSONObject(){var e,t;return {licenseKey:this.licenseKey,framework:this.framework,deviceName:this.deviceName,...this.runtimeEnvironment,modes:[...this.modes].filter(r=>!x(r)).map(r=>r.toJSONObject()),components:this.components.map(r=>r.toJSONObject()),frameSource:this.frameSource?this.frameSource.toJSONObject():null,settings:this.settings.toJSONObject(),view:(t=(e=this._view)==null?void 0:e.toJSONObject())!=null?t:null}}getView(){return this._view}async setView(e){return this._view=e,this.update([{type:"viewSet",newValue:e}])}async getAppName(){let e=null;if(a$a()){let t=await b$3();if((t==null?void 0:t.appName)==null||t.appName==="")throw new Error("Cannot retrieve electron appName. Did you set it up in package.json? https://www.electronjs.org/docs/latest/api/app#appgetname");e=t.appName;}return e}urlToHostname(e){try{return new URL(e!=null?e:"").hostname}catch{return ""}}getParentDomain(){var t;let e="";return parent!==window&&(e||(e=this.urlToHostname((t=location.ancestorOrigins)==null?void 0:t[0])),e||(e=this.urlToHostname(document.referrer)),e||(e="")),e.startsWith("[")&&e.endsWith("]")&&(e=e.slice(1,-1)),e}async createContext(){this.webBatteryInterface=await a$f.create();let e=this.webBatteryInterface.getBatteryInfo();await this.workerCommand("createContext",{context:this.toJSONObject(),deviceId:a.deviceID,delayedRegistration:this.delayedRegistration,highEndBlurryRecognition:this.highEndBlurryRecognition,appName:await this.getAppName(),parentDomain:this.getParentDomain(),isTablet:b$1.isTablet(),batteryInfo:e}),this.webBatteryInterface.addBatteryChangeListener(this.batteryChangeListener),this.subscribeToWorkerMessages(this.onWorkerMessageListener),this.subscribeToCameraManagerEvents(),this.subscribeToVisibilityChange(this.onVisibilityChangeListener),this._view!=null&&await this.setView(this._view),this.frameSource!=null&&await this.setFrameSource(this.frameSource);}subscribeToVisibilityChange(e){document.addEventListener("visibilitychange",e);}unsubscribeToVisibilityChange(e){document.removeEventListener("visibilitychange",e);}async requestFrameData(e){return this.workerCommand("requestFrameData",{frameId:e})}performanceMark(e){a$g(globalThis.performance)&&typeof globalThis.performance.mark=="function"&&performance.mark(e);}async sendFrameToProcessor(e){var n,i;let t=e instanceof ImageData?{data:e.data,width:e.width,height:e.height,frameId:(n=e.frameId)!=null?n:e$1(),colorType:(i=e.colorType)!=null?i:"RGBA"}:e,r=await this.sendFrameToHandlers(t);return t.data=r.capture.data,r.skip?r.capture:(this.performanceMark("processFrameBeforeSDC"),this.sendFrameToSDC(t))}async sendFrameToHandlers(e){for(let t of this._frameHandlers)if((await t(e)).action==="skip")return {skip:true,capture:e};return {skip:false,capture:e}}async sendFrameToSDC(e){return this.workerCommand("processFrame",e,[e.data.buffer])}registerFrameHandler(e){this._frameHandlers.includes(e)||this._frameHandlers.push(e);}unregisterFrameHandler(e){this._frameHandlers.includes(e)&&this._frameHandlers.splice(this._frameHandlers.indexOf(e),1);}onBatteryChange(e){this.workerCommand("updateBatteryInfo",{batteryInfo:e});}onVisibilityChange(){this.workerCommand("documentVisibility",{state:document.visibilityState});}getImageConverterInstance(e){return this._asyncImageConverterInstance==null&&(this._asyncImageConverterInstance=new a$h(e)),this._asyncImageConverterInstance}onWorkerMessage(e){if(e.type==="contextDidChangeStatus"){e.payload.isValid||a$3.error(e.payload);for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON(e.payload));}if(e.type==="didStartObservingContext")for(let t of this.listeners)t.didStartObservingContext&&t.didStartObservingContext(this);e.type==="onFrameProcessingFinished"&&this.performanceMark("processFrameAfterSDC"),e.type==="convertToJPEG"&&this.convertImageToJPEG(e);}async convertImageToJPEG(e){let{imageId:t,width:r,height:n,data:i,planes:s,orientation:o,quality:u}=e,c={getWidth:()=>r,getHeight:()=>n,getPlanes:()=>s,toBitmap:()=>i,getBitmapRepresentationFromYUV:()=>{throw new Error("Not implemented")},deepCopy:()=>{throw new Error("Not implemented")}},l=await this.getImageConverterInstance({quality:u}).convertToJpeg(c,o);return this.workerCommand("convertToJPEGResult",{imageId:t,result:l})}subscribeToCameraManagerEvents(){g.instance().addListener("cameraProperties",this.cameraPropertiesReportListener),g.instance().addListener("cameraAccessError",this.cameraAccessErrorListener);}async reportCameraProperties(e){return this.workerCommand("reportCameraProperties",e)}onCameraAccessError(e){for(let t of this.listeners)t.didChangeStatus&&t.didChangeStatus(this,a$i.fromJSON({code:33794,isValid:true,message:typeof(e==null?void 0:e.toString)=="function"?e.toString():"Unknown error"}));}async update(e=[],{updateContext:t=true}={}){var r,n;t&&await this.updateContext();for(let i of e){switch(i.type){case "frameSourceState":{await((r=this._view)==null?void 0:r.onFrameSourceChange(this.frameSource));break}case "singleImageModeUploaderSettings":{(n=this._view)==null||n.onSingleImageUploaderSettingsChange(i.newValue);break}case "addOverlay":{await this.addNativeOverlay(i.newValue);break}case "removeOverlay":{await this.removeNativeOverlay(i.newValue);break}}for(let s of this.updateListeners){let o=s(i);o instanceof Promise&&await o;}}}async updateContext(){await this.workerCommand("updateContext",{context:this.toJSONObject(),...this.getViewInfo()}).catch(e=>a$3.warn("Error while updating context:",e,this.toJSONObject()));}getViewInfo(){return this._view!=null?{view:{width:this._view.width,height:this._view.height,visible:this._view.width>0&&this._view.height>0,orientation:this._view.orientation}}:{view:null}}getMirrorAxisForFrameSource(e){let t="None";return f$1(e)&&e.getMirrorImageEnabled()&&(t="Y"),t}async addComponent(e){if(!this.components.includes(e))return this.components.push(e),e._context=this,this.update()}async addNativeOverlay(e){if(G(e))return this.workerCommand("addNativeOverlay",{overlayHandle:e[a$j]})}async removeNativeOverlay(e){if(G(e))return this.workerCommand("removeNativeOverlay",{overlayHandle:e[a$j]})}subscribeToWorkerMessages(e){this.dataCaptureInstance?this.dataCaptureInstance.addWorkerListener(e):this.pendingWorkerMessageListeners.add(e);}unsubscribeToWorkerMessages(e){this.dataCaptureInstance&&this.dataCaptureInstance.removeWorkerListener(e),this.pendingWorkerMessageListeners.delete(e);}hasEnabledMode(){return [...this.modes].some(e=>e.isEnabled())}updateCameraFrameFlow(){let e=[...this.modes].some(t=>t._synchronousFrameFlow===true);g.instance().setFrameHandling(e);}async isFeatureSupported(e){return (await this.workerCommand("isFeatureSupported",{feature:e})).supported}};a.deviceID="",a.stateMachine=new a$1("unconfigured",Q),a.mainDataCaptureLoader=void 0,a.dataCaptureLoaders=new Map,a.libraryLocation=void 0,a.userLicenseKey=null,a.capabilityInfo=void 0,c([v],a.prototype,"setFrameSource",1),c([v],a.prototype,"addMode",1),c([v],a.prototype,"removeMode",1),c([v],a.prototype,"setMode",1),c([v],a.prototype,"removeCurrentMode",1),c([v],a.prototype,"isFeatureSupported",1);var f=a;var b=class{constructor(e=f,t=a$3,r=globalThis.fetch.bind(globalThis)){this.staticContext=f;this.staticContext=e,this.logger=t,this.fetch=r;}get workerCommand(){var e;return (e=this.staticContext.mainDataCaptureLoader)==null?void 0:e.workerCommand.bind(this.staticContext.mainDataCaptureLoader)}async getLicenseText(){var i,s;let e=this.staticContext.stateMachine.currentState;if(e==="unconfigured"||e==="configuring")return this.logger.warn('You must call "DataCaptureContext.forLicenseKey" before retrieving open source license text info.'),"";let t=new URL(`${((i=this.staticContext.libraryLocation)!=null?i:"").replace(/\/$/,"")}/license/web-core-license.txt`),[r,n]=await Promise.all([(s=this.workerCommand)==null?void 0:s.call(this,"getOpenSourceSoftwareLicenseInfo",{}),this.fetchWebLicenseText(t.toString())]);return [r==null?void 0:r.licenseText,n].filter(o=>o!=null).join(`
6
+ `)}async fetchWebLicenseText(e){return this.fetch(e,{mode:"cors",credentials:"include",headers:{"Content-Type":"text/plain"}}).then(async t=>{if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.text()}).catch(t=>(this.logger.warn(`Failed to fetch license from ${e}: ${t.toString()}`),null))}};export{b as a,f as b};
@@ -1 +1 @@
1
- import {a as a$3}from'./chunk-XIAF6V7E.js';import {b,a as a$2}from'./chunk-KYNYQBNF.js';import {a as a$4}from'./chunk-KAFNKP6O.js';import {a as a$1}from'./chunk-QOCHMKNY.js';var z={bottomLeft:"bottomRight",bottomRight:"bottomLeft",topLeft:"topRight",topRight:"topLeft",centerLeft:"centerRight",centerRight:"centerLeft",center:"center",topCenter:"topCenter",bottomCenter:"bottomCenter"},a=class a{constructor(){this.listener=null;this._mounted=false;this._mirrored=false;this._cachedSize=new a$1(0,0);this.resizeObserver=null;this.mapViewAnchorPositionsForFramePoint=t=>t;}get size(){return this._cachedSize}setMirrored(t){this._mounted&&(this._mirrored=t);}mount(t){var n;if(this._mounted)return;if(!document.head.querySelector(`[data-component=${a.componentName}]`)){let i=document.createElement("style");i.dataset.component=a.componentName,i.append(document.createTextNode(b)),document.head.append(i);}let r=document.createElement("div");r.classList.add(a$2.CUSTOM_VIEW_CONTAINER),(n=t.parentNode)==null||n.replaceChild(r,t),this._htmlRoot=r,this.gestureRecognizer=new a$3(this._htmlRoot),this.gestureRecognizer.addListener({onTap:(i,o)=>{var s,e;let m=(s=o.target.dataset.identifier)!=null?s:"";m!==""&&((e=this.listener)==null||e.didTapView(Number.parseInt(m,10)));}}),this.resizeObserver=new ResizeObserver(([i])=>{this._cachedSize=new a$1(i.contentRect.width,i.contentRect.height);}),this.resizeObserver.observe(this._htmlRoot),this._cachedSize=new a$1(this._htmlRoot.clientWidth,this._htmlRoot.clientHeight),this._mounted=true;}unmount(){var t,r,n,i;this._mounted&&(this.removeChildren(),(t=this.gestureRecognizer)==null||t.removeAllListeners(),(r=this.resizeObserver)==null||r.disconnect(),(n=this._htmlRoot)==null||n.remove(),this._htmlRoot=null,this.gestureRecognizer=null,(i=document.head.querySelector(`[data-component=${a.componentName}]`))==null||i.remove(),this.listener=null,this._mounted=false);}render(t){var n,i,o,m,s;if(t.elements.length===0){this.removeChildren();return}for(let e of t.removedIds)(i=(n=this._htmlRoot)==null?void 0:n.querySelector(`#${a.elementSelectorPrefix}${e}`))==null||i.remove();let r=document.createDocumentFragment();for(let e of t.elements){let c=`${a.elementSelectorPrefix}${e.identifier}`,p=(o=this._htmlRoot)==null?void 0:o.querySelector(`#${c}`),l=p;if(p==null&&(l=new Image(e.view.options.size.width,e.view.options.size.height),l.id=c,l.dataset.identifier=String(e.identifier),r.append(l)),l){l.src=e.view.data;let h=this.mapViewAnchorPositionsForFramePoint(e.anchorPositions)[this._mirrored?z[e.anchor]:e.anchor];this._mirrored&&(h=a$4.mirrorX(h,this.size));let{x:u,y:P}=this.adjustCoordinatesWithOffset(h,{elementSize:e.view.options.size,offset:e.offset}),v=(m=e.view.options.scale)!=null?m:1;l.style.scale=`${v}`,l.style.transform=`translate3d(${u/v}px, ${P/v}px, 0px)`;}}(s=this._htmlRoot)==null||s.append(r);}renderDomView(t){var n,i;if(t.elements.length===0){this.removeChildren();return}let r=document.createDocumentFragment();for(let o of t.elements){let m=`${a.elementSelectorPrefix}${o.identifier}`,s=(n=this._htmlRoot)==null?void 0:n.querySelector(`#${m}`),{view:e}=o;if(e!=null){e.id=m,s&&s!==e&&s.replaceWith(e);let c=this.mapViewAnchorPositionsForFramePoint(o.anchorPositions)[this._mirrored?z[o.anchor]:o.anchor];this._mirrored&&(c=a$4.mirrorX(c,this.size));let{width:p,height:l}=e.getBoundingClientRect(),{x:h,y:u}=this.adjustCoordinatesWithOffset(c,{elementSize:{width:p,height:l},offset:o.offset});e.style.position="absolute",e.style.transform=`translate3d(calc(${h}px - 50%), calc(${u}px - 50%), 0px)`,r.append(e);}}(i=this._htmlRoot)==null||i.append(r);}removeChildren(){var t;for(;(t=this._htmlRoot)!=null&&t.firstChild;)this._htmlRoot.firstChild.remove();}adjustCoordinatesWithOffset(t,r){let n=t,{elementSize:i,offset:o}=r,m=t.x-i.width/2,s=t.y-i.height/2;return o.x.unit==="pixel"&&(n=new a$4(m+o.x.value,s+o.y.value)),o.x.unit==="fraction"&&(n=new a$4(m+i.width*o.x.value,s+i.height*o.y.value)),n}};a.componentName="CustomLocationsView",a.elementSelectorPrefix="scandit-view-";var S=a;export{S as a};
1
+ import {a as a$3}from'./chunk-XIAF6V7E.js';import {b,a as a$2}from'./chunk-KYNYQBNF.js';import {a as a$1}from'./chunk-QOCHMKNY.js';import {a as a$4}from'./chunk-KAFNKP6O.js';var z={bottomLeft:"bottomRight",bottomRight:"bottomLeft",topLeft:"topRight",topRight:"topLeft",centerLeft:"centerRight",centerRight:"centerLeft",center:"center",topCenter:"topCenter",bottomCenter:"bottomCenter"},a=class a{constructor(){this.listener=null;this._mounted=false;this._mirrored=false;this._cachedSize=new a$1(0,0);this.resizeObserver=null;this.mapViewAnchorPositionsForFramePoint=t=>t;}get size(){return this._cachedSize}setMirrored(t){this._mounted&&(this._mirrored=t);}mount(t){var n;if(this._mounted)return;if(!document.head.querySelector(`[data-component=${a.componentName}]`)){let i=document.createElement("style");i.dataset.component=a.componentName,i.append(document.createTextNode(b)),document.head.append(i);}let r=document.createElement("div");r.classList.add(a$2.CUSTOM_VIEW_CONTAINER),(n=t.parentNode)==null||n.replaceChild(r,t),this._htmlRoot=r,this.gestureRecognizer=new a$3(this._htmlRoot),this.gestureRecognizer.addListener({onTap:(i,o)=>{var s,e;let m=(s=o.target.dataset.identifier)!=null?s:"";m!==""&&((e=this.listener)==null||e.didTapView(Number.parseInt(m,10)));}}),this.resizeObserver=new ResizeObserver(([i])=>{this._cachedSize=new a$1(i.contentRect.width,i.contentRect.height);}),this.resizeObserver.observe(this._htmlRoot),this._cachedSize=new a$1(this._htmlRoot.clientWidth,this._htmlRoot.clientHeight),this._mounted=true;}unmount(){var t,r,n,i;this._mounted&&(this.removeChildren(),(t=this.gestureRecognizer)==null||t.removeAllListeners(),(r=this.resizeObserver)==null||r.disconnect(),(n=this._htmlRoot)==null||n.remove(),this._htmlRoot=null,this.gestureRecognizer=null,(i=document.head.querySelector(`[data-component=${a.componentName}]`))==null||i.remove(),this.listener=null,this._mounted=false);}render(t){var n,i,o,m,s;if(t.elements.length===0){this.removeChildren();return}for(let e of t.removedIds)(i=(n=this._htmlRoot)==null?void 0:n.querySelector(`#${a.elementSelectorPrefix}${e}`))==null||i.remove();let r=document.createDocumentFragment();for(let e of t.elements){let c=`${a.elementSelectorPrefix}${e.identifier}`,p=(o=this._htmlRoot)==null?void 0:o.querySelector(`#${c}`),l=p;if(p==null&&(l=new Image(e.view.options.size.width,e.view.options.size.height),l.id=c,l.dataset.identifier=String(e.identifier),r.append(l)),l){l.src=e.view.data;let h=this.mapViewAnchorPositionsForFramePoint(e.anchorPositions)[this._mirrored?z[e.anchor]:e.anchor];this._mirrored&&(h=a$4.mirrorX(h,this.size));let{x:u,y:P}=this.adjustCoordinatesWithOffset(h,{elementSize:e.view.options.size,offset:e.offset}),v=(m=e.view.options.scale)!=null?m:1;l.style.scale=`${v}`,l.style.transform=`translate3d(${u/v}px, ${P/v}px, 0px)`;}}(s=this._htmlRoot)==null||s.append(r);}renderDomView(t){var n,i;if(t.elements.length===0){this.removeChildren();return}let r=document.createDocumentFragment();for(let o of t.elements){let m=`${a.elementSelectorPrefix}${o.identifier}`,s=(n=this._htmlRoot)==null?void 0:n.querySelector(`#${m}`),{view:e}=o;if(e!=null){e.id=m,s&&s!==e&&s.replaceWith(e);let c=this.mapViewAnchorPositionsForFramePoint(o.anchorPositions)[this._mirrored?z[o.anchor]:o.anchor];this._mirrored&&(c=a$4.mirrorX(c,this.size));let{width:p,height:l}=e.getBoundingClientRect(),{x:h,y:u}=this.adjustCoordinatesWithOffset(c,{elementSize:{width:p,height:l},offset:o.offset});e.style.position="absolute",e.style.transform=`translate3d(calc(${h}px - 50%), calc(${u}px - 50%), 0px)`,r.append(e);}}(i=this._htmlRoot)==null||i.append(r);}removeChildren(){var t;for(;(t=this._htmlRoot)!=null&&t.firstChild;)this._htmlRoot.firstChild.remove();}adjustCoordinatesWithOffset(t,r){let n=t,{elementSize:i,offset:o}=r,m=t.x-i.width/2,s=t.y-i.height/2;return o.x.unit==="pixel"&&(n=new a$4(m+o.x.value,s+o.y.value)),o.x.unit==="fraction"&&(n=new a$4(m+i.width*o.x.value,s+i.height*o.y.value)),n}};a.componentName="CustomLocationsView",a.elementSelectorPrefix="scandit-view-";var S=a;export{S as a};
@@ -0,0 +1 @@
1
+ import {a as a$2}from'./chunk-MBF27IWL.js';import {a as a$1}from'./chunk-XR65N6EG.js';var a=new Map;a.set("default",()=>import('../assets/beepSound.js'));var e=class e{constructor(r){this.resource=null;this.resource=r;}static get defaultSound(){return e._defaultSound instanceof e||(e._defaultSound=new e("default")),e._defaultSound}toJSONObject(){return this.resource!==null?{resource:this.resource}:{}}async play(){var r,t,i;if(this.resource==null||this.resource===""){a$1.warn("Sound resource is null or empty string. Cannot be played.");return}if(!this.audio){let l=await((i=(t=(r=a.get(this.resource))==null?void 0:r())==null?void 0:t.then(o=>(o==null?void 0:o.beepSound)||this.resource))!=null?i:Promise.resolve(this.resource));this.audio=new a$2({src:l});}this.audio.play();}};e._defaultSound=null;var s=e;export{s as a};
@@ -1 +1 @@
1
- import {a as a$2}from'./chunk-SEAVQZN6.js';import {a}from'./chunk-M2ZQCUEL.js';import {a as a$5}from'./chunk-AIRWHLJH.js';import {a as a$4}from'./chunk-FGO2SSRS.js';import {a as a$1}from'./chunk-QCRFVRSS.js';import {b}from'./chunk-FTD535WI.js';import {a as a$3}from'./chunk-XR65N6EG.js';var h=class{constructor(a$3,e){this.onMessageListener=this.onMessage.bind(this);this.workerSelf=a$3,this.dataCaptureInstance=new a(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),a$1(a$3)&&(a$2(a$3),this.listenToMessages());}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",a=>{a$3.log(a$3.Level.Error,a);}),this.workerSelf.addEventListener("messageerror",a=>{a$3.log(a$3.Level.Error,a);});}postMessage(a,e){this.workerSelf.postMessage(a,e!=null?e:[]);}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(a){return a$4(a)&&"payload"in a}hasTransferables(a){return a$4(a)&&Array.isArray(a.transferables)}async respondWith(a,e,l){let r=null,t;try{t=l(),t instanceof Promise&&(t=await t);}catch(m){t=void 0,r=a$5(m);}let i={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(t)?t.payload:void 0};r!=null&&(i.error=r),this.postMessage(i,this.hasTransferables(t)?t.transferables:[]);}onMessage(a){switch(a.data.command){case "loadLibrary":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}));}break}case "onTap":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point);});}break}case "hintPresenterV2update":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update();});}break}case "createContext":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.createContext({context:e.context,deviceId:e.deviceId,delayedRegistration:e.delayedRegistration,highEndBlurryRecognition:e.highEndBlurryRecognition,appName:e.appName,parentDomain:e.parentDomain,isTablet:e.isTablet,batteryInfo:e.batteryInfo}));}break}case "setFrameSource":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource));}break}case "processFrame":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.processFrame({data:e.data,frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType}));}break}case "requestFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId));}break}case "deleteFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId);});}break}case "updateContext":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e));}break}case "dispose":{this.respondWith(a.data.command,a.data.id,()=>this.dataCaptureInstance.dispose());break}case "flushAnalytics":{this.respondWith(a.data.command,a.data.id,()=>{this.dataCaptureInstance.flushAnalytics();});break}case "reportCameraProperties":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e));}break}case "setLogLevel":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{a$3.setLevel(e.level);});}break}case "updateBatteryInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo);});}break}case "extractCentaurusLicense":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey));}break}case "documentVisibility":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state);});}break}case "isFeatureSupported":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature));}break}case "getViewfinderInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo());}break}case "getOpenSourceSoftwareLicenseInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo());}break}case "addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(a);break;case "removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(a);break;case "convertToJPEGResult":{{let{data:e}=a;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result);}break}default:return b(a.data),false}return true}};export{h as a};
1
+ import {a as a$2}from'./chunk-SEAVQZN6.js';import {a}from'./chunk-U2VELHGX.js';import {a as a$5}from'./chunk-AIRWHLJH.js';import {a as a$4}from'./chunk-FGO2SSRS.js';import {a as a$1}from'./chunk-QCRFVRSS.js';import {b}from'./chunk-FTD535WI.js';import {a as a$3}from'./chunk-XR65N6EG.js';var h=class{constructor(a$3,e){this.onMessageListener=this.onMessage.bind(this);this.workerSelf=a$3,this.dataCaptureInstance=new a(e,{postMessage:this.postMessage.bind(this),getOffscreenCanvas:this.getOffscreenCanvas.bind(this)}),a$1(a$3)&&(a$2(a$3),this.listenToMessages());}listenToMessages(){this.workerSelf.addEventListener("message",this.onMessageListener),this.workerSelf.addEventListener("error",a=>{a$3.log(a$3.Level.Error,a);}),this.workerSelf.addEventListener("messageerror",a=>{a$3.log(a$3.Level.Error,a);});}postMessage(a,e){this.workerSelf.postMessage(a,e!=null?e:[]);}getOffscreenCanvas(){if(this.isOffscreenCanvasSupported())return new this.workerSelf.OffscreenCanvas(32,32)}isOffscreenCanvasSupported(){return typeof this.workerSelf.OffscreenCanvas=="function"}hasPayload(a){return a$4(a)&&"payload"in a}hasTransferables(a){return a$4(a)&&Array.isArray(a.transferables)}async respondWith(a,e,l){let r=null,t;try{t=l(),t instanceof Promise&&(t=await t);}catch(m){t=void 0,r=a$5(m);}let i={type:"workerTaskId",command:a,id:e,payload:this.hasPayload(t)?t.payload:void 0};r!=null&&(i.error=r),this.postMessage(i,this.hasTransferables(t)?t.transferables:[]);}onMessage(a){switch(a.data.command){case "loadLibrary":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.loadLibrary({libraryLocation:e.libraryLocation,locationPath:e.locationPath,referredOrigin:e.referredOrigin,writableDataPathOverride:e.writableDataPathOverride,threadsSupport:e.threadsSupport,simdSupport:e.simdSupport,verifyResponseHash:e.verifyResponseHash,fixedWasmMemory:e.fixedWasmMemory,indexedDBTimeoutMs:e.indexedDBTimeoutMs}));}break}case "onTap":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.onTap(e.point);});}break}case "hintPresenterV2update":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>{this.dataCaptureInstance.hintPresenterV2Update();});}break}case "createContext":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.createContext({context:e.context,deviceId:e.deviceId,delayedRegistration:e.delayedRegistration,highEndBlurryRecognition:e.highEndBlurryRecognition,appName:e.appName,parentDomain:e.parentDomain,isTablet:e.isTablet,batteryInfo:e.batteryInfo}));}break}case "setFrameSource":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.setFrameSource(e.mirrorAxis,e.isCameraFrameSource));}break}case "processFrame":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.processFrame({data:e.data,frameId:e.frameId,width:e.width,height:e.height,colorType:e.colorType}));}break}case "requestFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.requestFrameData(e.frameId));}break}case "deleteFrameData":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.deleteFrameData(e.frameId);});}break}case "updateContext":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.updateContext(e));}break}case "dispose":{this.respondWith(a.data.command,a.data.id,()=>this.dataCaptureInstance.dispose());break}case "flushAnalytics":{this.respondWith(a.data.command,a.data.id,()=>{this.dataCaptureInstance.flushAnalytics();});break}case "reportCameraProperties":{{let{data:e}=a;this.respondWith(e.command,e.id,async()=>this.dataCaptureInstance.reportCameraProperties(e));}break}case "setLogLevel":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{a$3.setLevel(e.level);});}break}case "updateBatteryInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.updateBatteryInfo(e.batteryInfo);});}break}case "extractCentaurusLicense":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.extractCentaurusLicense(e.licenseKey));}break}case "documentVisibility":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>{this.dataCaptureInstance.onDocumentVisibilityChange(e.state);});}break}case "isFeatureSupported":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.isFeatureSupported(e.feature));}break}case "getViewfinderInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getViewfinderInfo());}break}case "getOpenSourceSoftwareLicenseInfo":{{let{data:e}=a;this.respondWith(e.command,e.id,()=>this.dataCaptureInstance.getOpenSourceSoftwareLicenseInfo());}break}case "addNativeOverlay":this.dataCaptureInstance.addNativeOverlay(a);break;case "removeNativeOverlay":this.dataCaptureInstance.removeNativeOverlay(a);break;case "convertToJPEGResult":{{let{data:e}=a;this.dataCaptureInstance.convertToJPEGResult(e.imageId,e.result);}break}default:return b(a.data),false}return true}};export{h as a};
@@ -1 +1 @@
1
- import {b as b$1}from'./chunk-XVH5A2QH.js';import {a as a$5}from'./chunk-2SGKGZ6F.js';import {a as a$6}from'./chunk-2LSO6JEZ.js';import {a as a$2}from'./chunk-UWBNF47P.js';import {a as a$1}from'./chunk-EV4OEANA.js';import {a as a$4}from'./chunk-3A4KLILV.js';import {a as a$3}from'./chunk-LSZZVJ6B.js';var s="--view-finder-top",d="--view-finder-bottom",c="--hint-anchor-offset",T="--max-width-fraction",w="--horizontal-margin",f="--max-width-ratio-adjust",b=(t=>(t.Update="hintpresenterupdate",t.ViewFinderUpdateRequested="hintpresenterviewfinderupdaterequested",t))(b||{});function S(l,h=100){return typeof l=="string"?l.slice(0,h):""}var a=class a extends a$1{constructor(){super();this.onDidToastHideHandler=this.onDidToastHide.bind(this);let t=this.attachShadow({mode:"open"});t.innerHTML=a$2`<div id="root"><slot></slot></div>`,t.append(a.createStyleElement().cloneNode(true)),this.root=t.querySelector("#root");}static createStyleElement(){return a$3`:host{pointer-events:none}:host #root{inset:0;position:absolute;width:100%;${s}:0;${d}:0;${f}:1;z-index:1}::slotted(${b$1.tag}){left:50%;max-width:calc(var(${T})*var(${f})*100% - var(${w}));position:absolute;transform:translate(-50%);width:100%}::slotted(${b$1.tag}.${"aboveViewFinder"}){transform:translate(-50%,calc(-100% + var(${s}) - var(${c})))}::slotted(${b$1.tag}.${"belowViewFinder"}){transform:translate(-50%,calc(var(${d}) + var(${c})))}::slotted(${b$1.tag}.${"top"}){top:calc(var(${c}))}::slotted(${b$1.tag}.${"center"}){top:50%;transform:translate(-50%,-50%)}::slotted(${b$1.tag}.fitToText){width:fit-content}`}static register(){a$4({[a.tag]:a});}static create(){return a.register(),document.createElement(a.tag)}connectedCallback(){this.addEventListener("didhide",this.onDidToastHideHandler),this._viewFinderRect==null&&(this.root.style.setProperty(s,`${this.root.clientHeight/2}px`),this.root.style.setProperty(d,`${this.root.clientHeight/2+1}px`));}disconnectedCallback(){this.removeEventListener("didhide",this.onDidToastHideHandler);}setViewFinderRect(t){if(t===null){this.root.style.removeProperty(s),this.root.style.removeProperty(d);return}this._viewFinderRect=t;let{origin:{y:e},size:{height:i}}=this._viewFinderRect;this.root.style.setProperty(s,`${e}px`),this.root.style.setProperty(d,`${e+i}px`);}async handleMessage(t){let{type:e}=t;switch(e){case "showToast":{await this.showToast(t.payload);break}case "hideToast":{await this.hideToast(t.payload);break}case "showGuidance":{await this.showGuidance(t.payload);break}case "hideGuidance":{await this.hideGuidance(t.payload);break}case "startUpdateTimer":{this.startUpdateTimer(t.payload.duration.value);break}case "stopUpdateTimer":{this.stopUpdateTimer();break}}}setHintStyleToToast(t,e){t.textContent=e.text,t.hintStyle=e.hintStyle,t.className="",t.style.setProperty(c,`${t.hintStyle.hintAnchorOffset/16}rem`),t.style.setProperty(T,e.hintStyle.maxWidthFraction.toString()),t.style.setProperty(w,`${e.hintStyle.horizontalMargin/16}rem`),t.classList.add(e.hintStyle.hintAnchor),t.classList.toggle("fitToText",e.hintStyle.fitToText);}onDidToastHide(t){t.stopPropagation(),t.detail.target.remove();}getToastElementFromIdOrTag({id:t,tag:e}){var i;return (i=this.querySelector(`[data-id="${t}"]`))!=null?i:this.querySelector(`[data-tag="${e}"]`)}async showToast(t){var r;this.ensureViewFinderRectIsSet();let e=this.idFromHint(t),i=this.getToastElementFromIdOrTag({id:e,tag:(r=t.tag)!=null?r:""});if(i||(i=b$1.create(),i.dataset.id=e,t.tag!==""&&(i.dataset.tag=t.tag),this.append(i)),this.setHintStyleToToast(i,t),t.tag==="MoveCloserGuidance"){let n=a$5.create();n.setAttribute("slot","first-child"),i.append(n),i.setAttribute("direction","column");}return i.show()}showToastWithCustomIcon(t,e){var n;let i=this.idFromHint(t),r=this.getToastElementFromIdOrTag({id:i,tag:(n=t.tag)!=null?n:""});return r||(r=b$1.create(),r.dataset.id=i,t.tag!==""&&(r.dataset.tag=t.tag),this.append(r)),r.customIcon=e,this.setHintStyleToToast(r,t),r.show()}async hideToast(t){var i;let e=this.getToastElementFromIdOrTag({id:this.idFromHint(t),tag:(i=t.tag)!=null?i:""});return e==null?void 0:e.hide()}async showGuidance(t){return this.showToast(t)}async hideGuidance(t){return this.hideToast(t)}startUpdateTimer(t){this.intervalId=setInterval(()=>{this.dispatchEvent(new CustomEvent("hintpresenterupdate"));},t);}stopUpdateTimer(){clearInterval(this.intervalId);}ensureViewFinderRectIsSet(){(this._viewFinderRect==null||this._viewFinderRect.origin.x===0&&this._viewFinderRect.origin.y===0)&&this.dispatchEvent(new CustomEvent("hintpresenterviewfinderupdaterequested"));}idFromHint(t){var e;return a$6([t.hintStyle.textColor,t.hintStyle.backgroundColor,t.hintStyle.hintAnchor,(e=t.tag)!=null?e:"",S(t.text,30),t.hintStyle.textAlignment],"hint")}};a.tag="scandit-hints";var H=a;export{b as a,H as b};
1
+ import {b as b$1}from'./chunk-PDJEYYPX.js';import {a as a$5}from'./chunk-2SGKGZ6F.js';import {a as a$6}from'./chunk-2LSO6JEZ.js';import {a as a$2}from'./chunk-UWBNF47P.js';import {a as a$1}from'./chunk-EV4OEANA.js';import {a as a$4}from'./chunk-3A4KLILV.js';import {a as a$3}from'./chunk-LSZZVJ6B.js';var s="--view-finder-top",d="--view-finder-bottom",c="--hint-anchor-offset",T="--max-width-fraction",w="--horizontal-margin",f="--max-width-ratio-adjust",b=(t=>(t.Update="hintpresenterupdate",t.ViewFinderUpdateRequested="hintpresenterviewfinderupdaterequested",t))(b||{});function S(l,h=100){return typeof l=="string"?l.slice(0,h):""}var a=class a extends a$1{constructor(){super();this.onDidToastHideHandler=this.onDidToastHide.bind(this);let t=this.attachShadow({mode:"open"});t.innerHTML=a$2`<div id="root"><slot></slot></div>`,t.append(a.createStyleElement().cloneNode(true)),this.root=t.querySelector("#root");}static createStyleElement(){return a$3`:host{pointer-events:none}:host #root{inset:0;position:absolute;width:100%;${s}:0;${d}:0;${f}:1;z-index:1}::slotted(${b$1.tag}){left:50%;max-width:calc(var(${T})*var(${f})*100% - var(${w}));position:absolute;transform:translate(-50%);width:100%}::slotted(${b$1.tag}.${"aboveViewFinder"}){transform:translate(-50%,calc(-100% + var(${s}) - var(${c})))}::slotted(${b$1.tag}.${"belowViewFinder"}){transform:translate(-50%,calc(var(${d}) + var(${c})))}::slotted(${b$1.tag}.${"top"}){top:calc(var(${c}))}::slotted(${b$1.tag}.${"center"}){top:50%;transform:translate(-50%,-50%)}::slotted(${b$1.tag}.fitToText){width:fit-content}`}static register(){a$4({[a.tag]:a});}static create(){return a.register(),document.createElement(a.tag)}connectedCallback(){this.addEventListener("didhide",this.onDidToastHideHandler),this._viewFinderRect==null&&(this.root.style.setProperty(s,`${this.root.clientHeight/2}px`),this.root.style.setProperty(d,`${this.root.clientHeight/2+1}px`));}disconnectedCallback(){this.removeEventListener("didhide",this.onDidToastHideHandler);}setViewFinderRect(t){if(t===null){this.root.style.removeProperty(s),this.root.style.removeProperty(d);return}this._viewFinderRect=t;let{origin:{y:e},size:{height:i}}=this._viewFinderRect;this.root.style.setProperty(s,`${e}px`),this.root.style.setProperty(d,`${e+i}px`);}async handleMessage(t){let{type:e}=t;switch(e){case "showToast":{await this.showToast(t.payload);break}case "hideToast":{await this.hideToast(t.payload);break}case "showGuidance":{await this.showGuidance(t.payload);break}case "hideGuidance":{await this.hideGuidance(t.payload);break}case "startUpdateTimer":{this.startUpdateTimer(t.payload.duration.value);break}case "stopUpdateTimer":{this.stopUpdateTimer();break}}}setHintStyleToToast(t,e){t.textContent=e.text,t.hintStyle=e.hintStyle,t.className="",t.style.setProperty(c,`${t.hintStyle.hintAnchorOffset/16}rem`),t.style.setProperty(T,e.hintStyle.maxWidthFraction.toString()),t.style.setProperty(w,`${e.hintStyle.horizontalMargin/16}rem`),t.classList.add(e.hintStyle.hintAnchor),t.classList.toggle("fitToText",e.hintStyle.fitToText);}onDidToastHide(t){t.stopPropagation(),t.detail.target.remove();}getToastElementFromIdOrTag({id:t,tag:e}){var i;return (i=this.querySelector(`[data-id="${t}"]`))!=null?i:this.querySelector(`[data-tag="${e}"]`)}async showToast(t){var r;this.ensureViewFinderRectIsSet();let e=this.idFromHint(t),i=this.getToastElementFromIdOrTag({id:e,tag:(r=t.tag)!=null?r:""});if(i||(i=b$1.create(),i.dataset.id=e,t.tag!==""&&(i.dataset.tag=t.tag),this.append(i)),this.setHintStyleToToast(i,t),t.tag==="MoveCloserGuidance"){let n=a$5.create();n.setAttribute("slot","first-child"),i.append(n),i.setAttribute("direction","column");}return i.show()}showToastWithCustomIcon(t,e){var n;let i=this.idFromHint(t),r=this.getToastElementFromIdOrTag({id:i,tag:(n=t.tag)!=null?n:""});return r||(r=b$1.create(),r.dataset.id=i,t.tag!==""&&(r.dataset.tag=t.tag),this.append(r)),r.customIcon=e,this.setHintStyleToToast(r,t),r.show()}async hideToast(t){var i;let e=this.getToastElementFromIdOrTag({id:this.idFromHint(t),tag:(i=t.tag)!=null?i:""});return e==null?void 0:e.hide()}async showGuidance(t){return this.showToast(t)}async hideGuidance(t){return this.hideToast(t)}startUpdateTimer(t){this.intervalId=setInterval(()=>{this.dispatchEvent(new CustomEvent("hintpresenterupdate"));},t);}stopUpdateTimer(){clearInterval(this.intervalId);}ensureViewFinderRectIsSet(){(this._viewFinderRect==null||this._viewFinderRect.origin.x===0&&this._viewFinderRect.origin.y===0)&&this.dispatchEvent(new CustomEvent("hintpresenterviewfinderupdaterequested"));}idFromHint(t){var e;return a$6([t.hintStyle.textColor,t.hintStyle.backgroundColor,t.hintStyle.hintAnchor,(e=t.tag)!=null?e:"",S(t.text,30),t.hintStyle.textAlignment],"hint")}};a.tag="scandit-hints";var H=a;export{b as a,H as b};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-GZCWMFWA.js';var t=new a(globalThis,{get:()=>globalThis.Module,set:e=>{globalThis.Module=e;}});function l(e){}export{t as a,l as b};
@@ -0,0 +1 @@
1
+ var e;(o=>{function i(){let r="8.3.1";return r}o.sdkVersion=i;})(e||(e={}));export{e as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-SJIN27Q5.js';var i=class{constructor(e){this.setupComplete=false;this.handler=null;this.events=["touchstart","touchend","click","keydown"];this.doc=e!=null?e:typeof document<"u"?document:void 0;}isSetupComplete(){return this.setupComplete}markSetupComplete(){this.setupComplete=true;}setup(e){this.handler=e;let n=this.doc;n&&this.events.forEach(t=>{var o;n.addEventListener(t,e,true),(o=a)==null||o(`\u{1F3A7} Added '${t}' listener for audio unlock`);});}reset(){var e;this.removeListeners(),this.handler=null,this.setupComplete=false,(e=a)==null||e("\u{1F3A7} UnlockManager reset");}removeListeners(){var e;this.handler&&this.doc&&(this.events.forEach(n=>{var t;(t=this.doc)==null||t.removeEventListener(n,this.handler,true);}),(e=a)==null||e("\u{1F3A7} Unlock event listeners removed"));}};export{i as a};
@@ -0,0 +1 @@
1
+ import {d,a as a$2}from'./chunk-TNIR74NN.js';import {b as b$1}from'./chunk-Y3TODCJD.js';import {a as a$1,b as b$2}from'./chunk-ZAXZRQYF.js';import {a as a$3}from'./chunk-AAPD5YU3.js';import {a}from'./chunk-SJIN27Q5.js';import {b}from'./chunk-YONR3EGV.js';var A=class{constructor(t){this.audioBuffer=null;this.loadPromise=null;this.soundPool=[];this.soundPoolSize=25;this.inactiveSounds=new Set;var e;this.src=Array.isArray(t.src)?t.src[0]:t.src,t.html5!==void 0?this.html5=t.html5:this.html5=b.isIOS(),(e=a)==null||e(`\u{1F3B5} Howl created: using ${this.html5?"HTML5 <audio> (BLOCKING)":"Web Audio API (non-blocking)"}`),a$1(this),d();}async load(){if(this.loadPromise)return this.loadPromise;if(this.audioBuffer)return this.audioBuffer;let t=b$1().get(this.src);return t?(this.loadPromise=t,this.audioBuffer=await t,this.audioBuffer):(this.loadPromise=(async()=>{var e,i,s;try{let n=a$2().getContext(),a$1;if(this.src.startsWith("data:")){(e=a)==null||e("\u{1F50A} Decoding data URI directly (bypassing fetch)");let c=this.src.split(",")[1],r=atob(c),d=new Uint8Array(r.length);for(let l=0;l<r.length;l++)d[l]=r.charCodeAt(l);a$1=d.buffer;}else (i=a)==null||i(`\u{1F50A} Fetching audio from URL: ${this.src}`),a$1=await(await fetch(this.src)).arrayBuffer();let u=await n.decodeAudioData(a$1);return this.audioBuffer=u,u}catch(n){throw (s=a)==null||s(`Failed to load audio: ${n instanceof Error?n.message:String(n)}`),n}})(),b$1().set(this.src,this.loadPromise),this.loadPromise)}getSoundFromPool(){var e,i,s;if(this.inactiveSounds.size>0){let n=[...this.inactiveSounds][0];return this.inactiveSounds.delete(n),(e=a)==null||e(`\u{1F3B5} HTML5: Reusing sound from pool [${this.inactiveSounds.size} inactive, ${this.soundPool.length} total]`),n}if(this.soundPool.length<this.soundPoolSize){let n=new a$3(this.src,a=>{this.inactiveSounds.add(a);});return this.soundPool.push(n),(i=a)==null||i(`\u{1F3B5} HTML5: Created new sound, pool size: ${this.soundPool.length}/${this.soundPoolSize}`),n}(s=a)==null||s(`\u26A0\uFE0F HTML5: Sound pool exhausted (${this.soundPool.length}/${this.soundPoolSize}), force reusing first sound`);let t=this.soundPool[0];return this.inactiveSounds.delete(t),t}verifyAudioBuffer(t){if(!a)return;let e=t.getChannelData(0),i=0;for(let s=0;s<Math.min(1e3,e.length);s++)i=Math.max(i,Math.abs(e[s]));a(`\u{1F50A} Audio data check: max sample value = ${i.toFixed(4)} (first 1000 samples)`),i<.001&&a("\u274C WARNING: Audio appears to be SILENT - all samples near zero!");}handlePlaybackError(t){var e,i,s;t instanceof DOMException?t.name==="NotAllowedError"?(e=a)==null||e("\u274C Sound playback blocked by autoplay policy."):t.name!=="AbortError"&&((i=a)==null||i(`\u274C Sound playback failed: ${t.name} - ${t.message}`)):(s=a)==null||s(`\u274C Sound playback failed: ${t instanceof Error?t.message:String(t)}`);}async prepareAudioContext(t){var i,s,n,a$1;t.unlocked||((i=a)==null||i("\u26A0\uFE0F AudioContext not unlocked, attempting unlock..."),await t.unlock()),t.checkAndRecreateContextIfSampleRateChanged();let e=t.getContext();return (s=a)==null||s(`\u{1F50A} AudioContext state before play: ${e.state}`),e.state==="suspended"&&((n=a)==null||n("\u26A0\uFE0F AudioContext is suspended, resuming..."),await e.resume(),(a$1=a)==null||a$1(`\u{1F50A} AudioContext state after resume: ${e.state}`)),e}playHTML5(){var t,e;try{let i=this.getSoundFromPool();(t=a)==null||t(`\u{1F50A} HTML5: Playing [pool: ${this.soundPool.length}]`),i.play();}catch(i){(e=a)==null||e(`\u274C HTML5: Failed to setup playback: ${i instanceof Error?i.message:String(i)}`);}}play(){this.playAsync();}async playAsync(){var t,e,i,s,n,a$1;try{if(this.html5)return this.playHTML5();let u=a$2(),c=await this.prepareAudioContext(u),r=await this.load();this.verifyAudioBuffer(r);let d=c.createBufferSource();d.buffer=r,d.loop=false;let l=c.createGain();l.gain.value=1,(t=a)==null||t(`\u{1F50A} Setting gain to ${l.gain.value}`),d.connect(l);let b$1=u.getDestination();l.connect(b$1),(e=a)==null||e(`\u{1F50A} Connected to ${b.isIOS()?"MediaStreamDestination (iOS workaround)":"standard destination"}`),(i=a)==null||i(`\u{1F50A} Starting playback: ${r.duration}s, ${r.numberOfChannels}ch, ${r.sampleRate}Hz`),(s=a)==null||s(`\u{1F50A} Destination: ${c.destination.maxChannelCount}ch max, context SR: ${c.sampleRate}Hz`),(n=a)==null||n(`\u{1F50A} Gain value: ${l.gain.value}, Buffer length: ${r.length} samples`),d.onended=()=>{var m;d.disconnect(),(m=a)==null||m("\u{1F50A} Audio playback ended - source node disconnected");},d.start(0),(a$1=a)==null||a$1("\u2705 source.start(0) called successfully");}catch(u){this.handlePlaybackError(u);}}dispose(){var t;for(let e of this.soundPool)e.stop(),e.dispose();this.soundPool=[],this.inactiveSounds.clear(),(t=a)==null||t("\u{1F3B5} HTML5 sound pool cleared during Howl disposal"),b$2(this);}};export{A as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-SJIN27Q5.js';var i=class{constructor(){this.cache=new Map;}get(e){return this.cache.get(e)}set(e,s){this.cache.set(e,s);}clear(){var e;this.cache.clear(),(e=a)==null||e("\u{1F3A7} Audio buffer cache cleared");}size(){return this.cache.size}};export{i as a};