@scandit/web-datacapture-core 8.5.0-beta.1 → 8.5.0

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 (40) hide show
  1. package/THIRD_PARTY.txt +45 -0
  2. package/build/js/Camera.js +1 -1
  3. package/build/js/{CameraManager-DskA2C7T.js → CameraManager-BTGb7HgX.js} +1 -1
  4. package/build/js/{DataCaptureContext-CbQes_57.js → DataCaptureContext-CVc_U_GE.js} +2 -2
  5. package/build/js/DataCaptureContext.js +1 -1
  6. package/build/js/DataCaptureVersion.js +1 -1
  7. package/build/js/DataCaptureView.js +1 -1
  8. package/build/js/ImageFrameSource.js +1 -1
  9. package/build/js/Vibration.js +1 -1
  10. package/build/js/{browserHelper-Dno5no9Z.d.ts → browserHelper-ChSOtve7.d.ts} +1 -0
  11. package/build/js/{browserHelper-BQPnAZ2Y.js → browserHelper-DuxFlAfF.js} +1 -1
  12. package/build/js/browserHelper.d.ts +1 -1
  13. package/build/js/browserHelper.js +1 -1
  14. package/build/js/controls/CameraFOVSwitchControl.js +1 -1
  15. package/build/js/controls/ZoomSwitchControl.js +1 -1
  16. package/build/js/{hybridDesktopPlatformHelpers-DPAJQLcX.js → hybridDesktopPlatformHelpers-OpmECgIg.js} +1 -1
  17. package/build/js/index.d.ts +1 -1
  18. package/build/js/index.js +1 -1
  19. package/build/js/private/CameraAccess.js +1 -1
  20. package/build/js/private/CameraManager.js +1 -1
  21. package/build/js/private/CoreModuleLicenseTextProvider.js +1 -1
  22. package/build/js/private/FrameReaders/FrameReader.js +1 -1
  23. package/build/js/private/FrameReaders/GrayScaleFrameReader.js +1 -1
  24. package/build/js/private/FrameReaders/index.js +1 -1
  25. package/build/js/private/OrientationObserver.js +1 -1
  26. package/build/js/private/SingleImageUploaderView.js +1 -1
  27. package/build/js/private/ViewControls_related.js +1 -1
  28. package/build/js/private/customHowler/Howl.js +1 -1
  29. package/build/js/private/customHowler/WebAudioContextManager.d.ts +2 -1
  30. package/build/js/private/customHowler/WebAudioContextManager.js +1 -1
  31. package/build/js/private/hybridDesktopPlatformHelpers.js +1 -1
  32. package/build/js/private/ui/molecules/CameraFOVSwitchButton.js +1 -1
  33. package/build/js/private/ui/molecules/CameraSwitchButton.js +1 -1
  34. package/build/js/private/ui/molecules/TorchSwitchIconButton.js +1 -1
  35. package/build/js/private/utils/polyfillLoader.js +1 -1
  36. package/build/js/private/utils/warnMultithreadingUnavailable.js +1 -1
  37. package/build/js/worker/dataCaptureLoader.js +1 -1
  38. package/package.json +1 -1
  39. package/sdc-lib/license/AUTHORS +606 -0
  40. package/sdc-lib/license/web-core-license.txt +14 -1
package/THIRD_PARTY.txt CHANGED
@@ -305,3 +305,48 @@
305
305
  ================================================================================
306
306
 
307
307
 
308
+
309
+
310
+ ================================================================================
311
+
312
+
313
+ Copyright (c) 2014 Arnout Kazemier
314
+ Copyright (c) 2018 Copyright 2018 Klaus Hartl, Fagner Brack, GitHub Contributors
315
+ Copyright (c) 2013-2020 James Simpson and GoldFire Studios, Inc.
316
+ Copyright (c) 2012-2024 Faisal Salman <f@faisalman.com>
317
+ Copyright (c) 2017-2018 Fredrik Nicol
318
+ Copyright (c) 2005-2014 Rich Felker, et al.
319
+ Copyright (c) 2010-2014 Emscripten authors, see AUTHORS file.
320
+
321
+ Permission is hereby granted, free of charge, to any person
322
+ obtaining a copy of this software and associated documentation
323
+ files (the "Software"), to deal in the Software without
324
+ restriction, including without limitation the rights to use, copy,
325
+ modify, merge, publish, distribute, sublicense, and/or sell copies
326
+ of the Software, and to permit persons to whom the Software is
327
+ furnished to do so, subject to the following conditions:
328
+
329
+ The above copyright notice and this permission notice shall be
330
+ included in all copies or substantial portions of the Software.
331
+
332
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
333
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
334
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
335
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
336
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
337
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
338
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
339
+ SOFTWARE.
340
+
341
+
342
+ ================================================================================
343
+
344
+
345
+ This project is licensed under the MIT license.
346
+ Copyrights are respective of each contributor listed at the beginning of each definition file.
347
+
348
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
349
+
350
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
351
+
352
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1 +1 @@
1
- import{t as e}from"./browserHelper-BQPnAZ2Y.js";import{Logger as t}from"./logger.js";import{defaultCamera as n}from"./defaults/DefaultsCamera.js";import{CameraSettings as r}from"./CameraRelated.js";import{DataCaptureError as i}from"./DataCaptureError.js";import{CameraAccess as a}from"./private/CameraAccess.js";import"./private/FrameReaders/ColorType.js";import{t as o}from"./CameraManager-DskA2C7T.js";import{INTERNAL_ACCESS as s}from"./private/privateAccess.js";import{cameraPool as c}from"./private/CameraPool.js";import{areEqualArrays as l}from"./private/utils/areEqualArrays.js";a.addVideoDevicesListener(e=>{c.integrateIncomingVideoDevices(e.map(e=>u.fromDeviceCamera(e)))});var u=class u{constructor(e){this._label=``,this._deviceId=``,this._notFoundOnDevice=!1,this._isBestGuess=!1,this.type=`camera`,this._currentState=`off`,this._settings=new r,this._desiredTorchState=`off`,this._desiredState=`off`,this.listeners=[],this.zoomListeners=new Set,this._context=null,this[s]={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??o.instance()}static pickBestGuess(){return u.getOrCreate({position:`worldFacing`,bestGuess:!0})}static pickBestGuessForPosition(e){if(!n.availablePositions.includes(e))throw Error(`Invalid camera position: "${e}"`);return u.getOrCreate({position:e})}static forDeviceId(e){return u.getOrCreate({deviceId:e})}static async getAll(e,t){return await a.getCameras(e??!1,t??!1),[...c.get()]}static getOrCreate(e){let{deviceId:t,position:n,bestGuess:r}=e,i=new u;return i._deviceId=t??``,i.position=n??`worldFacing`,r&&i[s].markAsBestGuess(),c.getOrCreate(i)}static fromDeviceCamera(e){let t=new u;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(){return this._currentResolution??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 n,r;if(this.currentTransitionStrategyPromise&&await this.currentTransitionStrategyPromise,this._notFoundOnDevice&&(e===`on`||e===`standby`))throw new i({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=(n=this.stateTransitionStrategyMap[this.currentState])==null||(r=n[e])==null?void 0:r.call(n).catch(e=>{if(e instanceof DOMException&&e.message===`The associated Track is in an invalid state`){t.log(t.Level.Warn,e);return}throw e}),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)}addZoomListener(e){this.zoomListeners.add(e)}removeZoomListener(e){this.zoomListeners.delete(e)}isZoomAvailable(){var e;return((e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom)!=null}async getZoomRange(){var e;await this.cameraManager.waitForCapabilities();let t=(e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom;return t?{min:t.min??null,max:t.max??null}:null}async setZoomFactor(e){let t=this._settings.zoomFactor;this._settings.zoomFactor=e,t!==e&&((this._currentState===`on`||this._currentState===`standby`)&&await this.cameraManager.setZoom(e),this.notifyZoomListeners(t,e)),await this.notifyContext({type:`cameraSettings`,newValue:this._settings})}async applySettings(e){let t=this._settings.zoomFactor,n=this._settings.zoomLevels;this._settings=new r(e);let i=this.settings.getProperty(`grayScaleFrameReader`);if(this.cameraManager.setFrameReaderType(i===!0?`GRAYSCALE`:`RGBA`),this.currentState===`on`||this.currentState===`standby`){let e=this.cameraManager.activeCameraSettings;if((e==null?void 0:e.preferredResolution)!==this.settings.preferredResolution){var a;await this.cameraManager.applyCameraSettings(this.settings),(a=this.cameraManager.activeCamera)!=null&&a.currentResolution&&(this._currentResolution={width:this.cameraManager.activeCamera.currentResolution.width,height:this.cameraManager.activeCamera.currentResolution.height})}await this.cameraManager.setZoom(this.settings.zoomFactor),t!==this.settings.zoomFactor&&this.notifyZoomListeners(t,this.settings.zoomFactor);let n=this.settings.getProperty(`minFrameRate`),r=this.settings.getProperty(`maxFrameRate`);(n!=null||r!=null)&&await this.cameraManager.setFrameRate({min:n,max:r});let i=this.settings.getProperty(`manualLensPosition`);i!=null&&await this.cameraManager.setFocus(i);let o=this.settings.getProperty(`exposureTargetBias`),s=this.settings.getProperty(`exposureDuration`);(o!=null||s!=null)&&await this.cameraManager.setExposure({compensation:o,time:s})}return this.notifyListenersOfZoomLevelChange(n,this.settings.zoomLevels),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(){return this._desiredMirrorImageEnabled??this.cameraManager.isMirrorImageEnabled()}async setMirrorImageEnabled(e){this._desiredMirrorImageEnabled=e,this.cameraManager.setMirrorImageEnabled(e,!0),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{t.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 e=(await a.getCameras()).find(e=>e.deviceId===this.deviceId);e&&(this.cameraManager.setInitialCameraPosition(e.position),this.cameraManager.setSelectedCamera(e))}await this.cameraManager.setupCameras(),typeof this._desiredMirrorImageEnabled==`boolean`?this.cameraManager.setMirrorImageEnabled(this._desiredMirrorImageEnabled,!0):this.cameraManager.setMirrorImageEnabled(this.cameraManager.isMirrorImageEnabled(),!1),this.context&&await this.context.setFrameSource(this),this.cameraManager.activeCamera&&(c.rebindToDeviceId(this,{deviceId:this.cameraManager.activeCamera.deviceId,label:this.cameraManager.activeCamera.label,position:this.cameraManager.activeCamera.position}),this._currentResolution=this.cameraManager.activeCamera.currentResolution)}markAsUnmappedToDeviceCameras(){this._notFoundOnDevice=!0}resetUnmappedState(){this._notFoundOnDevice=!1}markAsBestGuess(){this._isBestGuess=!0}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(e){t.warn(`Camera: error while capturing image.`,e)}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(e=>(this.cameraManager.recycle(e.data),null)).catch(e=>{t.warn(`error while recycling uint8array`,e)});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 t.log(t.Level.Error,e),await this.setCurrentState(`off`),e}}}async transitionFromStateOffToStandby(){if(!(this.currentState===`standby`||this.currentState===`bootingUp`||this.currentState===`goingToSleep`)){if(await this.isAndroidWebView()){t.log(t.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 t.log(t.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()){t.log(t.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??=await e.isAndroidWebView(),this._isAndroidWebView}notifyZoomListeners(e,t){for(let n of this.zoomListeners)n.onZoomLevelChanged(this,e,t)}notifyListenersOfZoomLevelChange(e,t){if(!l(e,t))for(let e of this.zoomListeners){var n;(n=e.onZoomLevelsChanged)==null||n.call(e,this,t)}}};export{u as Camera};
1
+ import{t as e}from"./browserHelper-DuxFlAfF.js";import{Logger as t}from"./logger.js";import{defaultCamera as n}from"./defaults/DefaultsCamera.js";import{CameraSettings as r}from"./CameraRelated.js";import{DataCaptureError as i}from"./DataCaptureError.js";import{CameraAccess as a}from"./private/CameraAccess.js";import"./private/FrameReaders/ColorType.js";import{t as o}from"./CameraManager-BTGb7HgX.js";import{INTERNAL_ACCESS as s}from"./private/privateAccess.js";import{cameraPool as c}from"./private/CameraPool.js";import{areEqualArrays as l}from"./private/utils/areEqualArrays.js";a.addVideoDevicesListener(e=>{c.integrateIncomingVideoDevices(e.map(e=>u.fromDeviceCamera(e)))});var u=class u{constructor(e){this._label=``,this._deviceId=``,this._notFoundOnDevice=!1,this._isBestGuess=!1,this.type=`camera`,this._currentState=`off`,this._settings=new r,this._desiredTorchState=`off`,this._desiredState=`off`,this.listeners=[],this.zoomListeners=new Set,this._context=null,this[s]={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??o.instance()}static pickBestGuess(){return u.getOrCreate({position:`worldFacing`,bestGuess:!0})}static pickBestGuessForPosition(e){if(!n.availablePositions.includes(e))throw Error(`Invalid camera position: "${e}"`);return u.getOrCreate({position:e})}static forDeviceId(e){return u.getOrCreate({deviceId:e})}static async getAll(e,t){return await a.getCameras(e??!1,t??!1),[...c.get()]}static getOrCreate(e){let{deviceId:t,position:n,bestGuess:r}=e,i=new u;return i._deviceId=t??``,i.position=n??`worldFacing`,r&&i[s].markAsBestGuess(),c.getOrCreate(i)}static fromDeviceCamera(e){let t=new u;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(){return this._currentResolution??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 n,r;if(this.currentTransitionStrategyPromise&&await this.currentTransitionStrategyPromise,this._notFoundOnDevice&&(e===`on`||e===`standby`))throw new i({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=(n=this.stateTransitionStrategyMap[this.currentState])==null||(r=n[e])==null?void 0:r.call(n).catch(e=>{if(e instanceof DOMException&&e.message===`The associated Track is in an invalid state`){t.log(t.Level.Warn,e);return}throw e}),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)}addZoomListener(e){this.zoomListeners.add(e)}removeZoomListener(e){this.zoomListeners.delete(e)}isZoomAvailable(){var e;return((e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom)!=null}async getZoomRange(){var e;await this.cameraManager.waitForCapabilities();let t=(e=this.cameraManager.mediaTrackCapabilities)==null?void 0:e.zoom;return t?{min:t.min??null,max:t.max??null}:null}async setZoomFactor(e){let t=this._settings.zoomFactor;this._settings.zoomFactor=e,t!==e&&((this._currentState===`on`||this._currentState===`standby`)&&await this.cameraManager.setZoom(e),this.notifyZoomListeners(t,e)),await this.notifyContext({type:`cameraSettings`,newValue:this._settings})}async applySettings(e){let t=this._settings.zoomFactor,n=this._settings.zoomLevels;this._settings=new r(e);let i=this.settings.getProperty(`grayScaleFrameReader`);if(this.cameraManager.setFrameReaderType(i===!0?`GRAYSCALE`:`RGBA`),this.currentState===`on`||this.currentState===`standby`){let e=this.cameraManager.activeCameraSettings;if((e==null?void 0:e.preferredResolution)!==this.settings.preferredResolution){var a;await this.cameraManager.applyCameraSettings(this.settings),(a=this.cameraManager.activeCamera)!=null&&a.currentResolution&&(this._currentResolution={width:this.cameraManager.activeCamera.currentResolution.width,height:this.cameraManager.activeCamera.currentResolution.height})}await this.cameraManager.setZoom(this.settings.zoomFactor),t!==this.settings.zoomFactor&&this.notifyZoomListeners(t,this.settings.zoomFactor);let n=this.settings.getProperty(`minFrameRate`),r=this.settings.getProperty(`maxFrameRate`);(n!=null||r!=null)&&await this.cameraManager.setFrameRate({min:n,max:r});let i=this.settings.getProperty(`manualLensPosition`);i!=null&&await this.cameraManager.setFocus(i);let o=this.settings.getProperty(`exposureTargetBias`),s=this.settings.getProperty(`exposureDuration`);(o!=null||s!=null)&&await this.cameraManager.setExposure({compensation:o,time:s})}return this.notifyListenersOfZoomLevelChange(n,this.settings.zoomLevels),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(){return this._desiredMirrorImageEnabled??this.cameraManager.isMirrorImageEnabled()}async setMirrorImageEnabled(e){this._desiredMirrorImageEnabled=e,this.cameraManager.setMirrorImageEnabled(e,!0),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{t.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 e=(await a.getCameras()).find(e=>e.deviceId===this.deviceId);e&&(this.cameraManager.setInitialCameraPosition(e.position),this.cameraManager.setSelectedCamera(e))}await this.cameraManager.setupCameras(),typeof this._desiredMirrorImageEnabled==`boolean`?this.cameraManager.setMirrorImageEnabled(this._desiredMirrorImageEnabled,!0):this.cameraManager.setMirrorImageEnabled(this.cameraManager.isMirrorImageEnabled(),!1),this.context&&await this.context.setFrameSource(this),this.cameraManager.activeCamera&&(c.rebindToDeviceId(this,{deviceId:this.cameraManager.activeCamera.deviceId,label:this.cameraManager.activeCamera.label,position:this.cameraManager.activeCamera.position}),this._currentResolution=this.cameraManager.activeCamera.currentResolution)}markAsUnmappedToDeviceCameras(){this._notFoundOnDevice=!0}resetUnmappedState(){this._notFoundOnDevice=!1}markAsBestGuess(){this._isBestGuess=!0}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(e){t.warn(`Camera: error while capturing image.`,e)}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(e=>(this.cameraManager.recycle(e.data),null)).catch(e=>{t.warn(`error while recycling uint8array`,e)});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 t.log(t.Level.Error,e),await this.setCurrentState(`off`),e}}}async transitionFromStateOffToStandby(){if(!(this.currentState===`standby`||this.currentState===`bootingUp`||this.currentState===`goingToSleep`)){if(await this.isAndroidWebView()){t.log(t.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 t.log(t.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()){t.log(t.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??=await e.isAndroidWebView(),this._isAndroidWebView}notifyZoomListeners(e,t){for(let n of this.zoomListeners)n.onZoomLevelChanged(this,e,t)}notifyListenersOfZoomLevelChange(e,t){if(!l(e,t))for(let e of this.zoomListeners){var n;(n=e.onZoomLevelsChanged)==null||n.call(e,this,t)}}};export{u as Camera};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./browserHelper-BQPnAZ2Y.js";import{Logger as t}from"./logger.js";import"./browserCompatibility.js";import"./CameraRelated.js";import{DataCaptureError as n}from"./DataCaptureError.js";import{CameraAccess as r}from"./private/CameraAccess.js";import"./private/FrameReaders/ColorType.js";import{FrameReaderAbstract as i}from"./private/FrameReaders/FrameReaderAbstract.js";import{WatermarkStack as a}from"./private/FrameReaders/WatermarkStack.js";import{createProgram as o,createShader as s}from"./private/FrameReaders/webglUtilities.js";import{getTimestamp as c}from"./private/utils/getTimestamp.js";import{Point as l}from"./commons/Point.js";import{Rect as u}from"./commons/Rect.js";import{Size as d}from"./commons/Size.js";import{defaultViewClassnames as f}from"./DefaultViewClassnames.js";import{cameraPool as p}from"./private/CameraPool.js";import{debounce as m}from"./private/utils/debounce.js";import{cancelSafeRequestAnimationFrame as h,safeRequestAnimationFrame as g}from"./private/utils/safeRequestAnimationFrame.js";import{assertUnreachable as _}from"./tsHelper.js";import{transparentPixelImage as v}from"./assets/transparentPixelImage.js";var y=class extends i{constructor(...e){super(...e),this.colorType=`RGBA`}get _initialized(){return this._texture!=null&&this._framebuffer!=null}readFromSource(e){this._initialized||this.setup(),this.updateFrameSizeIfNeeded();let t=this._framePool.pop();return this._contextWebGL.texImage2D(this._contextWebGL.TEXTURE_2D,0,this._contextWebGL.RGBA,this._contextWebGL.RGBA,this._contextWebGL.UNSIGNED_BYTE,e),this._contextWebGL.readPixels(0,0,this._contextWebGL.drawingBufferWidth,this._contextWebGL.drawingBufferHeight,this._contextWebGL.RGBA,this._contextWebGL.UNSIGNED_BYTE,t),{width:this._contextWebGL.drawingBufferWidth,height:this._contextWebGL.drawingBufferHeight,data:t,frameId:C(),colorType:this.colorType}}setup(){this._texture=this._contextWebGL.createTexture(),this._texture??t.warn(`Could not create texture from WebGLRenderingContext`),this._contextWebGL.bindTexture(this._contextWebGL.TEXTURE_2D,this._texture),this._framebuffer=this._contextWebGL.createFramebuffer(),this._framebuffer??t.warn(`Could not create frameBuffer from WebGLRenderingContext`),this._contextWebGL.bindFramebuffer(this._contextWebGL.FRAMEBUFFER,this._framebuffer),this._contextWebGL.framebufferTexture2D(this._contextWebGL.FRAMEBUFFER,this._contextWebGL.COLOR_ATTACHMENT0,this._contextWebGL.TEXTURE_2D,this._texture,0),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_WRAP_S,this._contextWebGL.CLAMP_TO_EDGE),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_WRAP_T,this._contextWebGL.CLAMP_TO_EDGE),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_MIN_FILTER,this._contextWebGL.NEAREST),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_MAG_FILTER,this._contextWebGL.NEAREST)}dispose(){var e;this._texture!=null&&(this._contextWebGL.deleteTexture(this._texture),this._texture=null),this._framebuffer!=null&&(this._contextWebGL.deleteFramebuffer(this._framebuffer),this._framebuffer=null),(e=this._framePool)==null||e.empty()}updateFrameSizeIfNeeded(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this._contextWebGL,n=e*t*4;if(this._frameSize!==n){var r;this._frameSize=n,(r=this._framePool)==null||r.empty(),this._framePool=new a({capacity:this._maxPoolCapacity,lowWaterMark:this._minPoolCapacity,createItem:()=>new Uint8ClampedArray(this._frameSize)})}}},b=class extends i{constructor(e,t){super(e,t),this.colorType=`GRAYSCALE`,this._useRgbaFallback=!1,this._positions=new Float32Array([-1,-1,-1,1,1,-1,1,-1,-1,1,1,1]),this._canvas=document.createElement(`canvas`)}get _webglContext(){if(!this._ctx){var e;if(this._ctx=(e=this._canvas)==null?void 0:e.getContext(`webgl`,{antialias:!1}),!this._ctx)throw Error(`Cannot get WebGL context`);this.setup()}return this._ctx}readFromSource(e){var n;let r=(e==null?void 0:e.videoWidth)??this._contextWebGL.drawingBufferWidth,i=r%4!=0;if(i!==this._useRgbaFallback&&(i?(t.debug(`[GrayScaleFrameReader] Video width not divisible by 4, falling back to RGBA reader for better performance`,{width:r}),this._rgbaFallbackReader||(this._rgbaFallbackReader=new y(this._contextWebGL,{minPoolCapacity:this._minPoolCapacity,maxPoolCapacity:this._maxPoolCapacity}),this._rgbaFallbackReader.setup())):t.log(t.Level.Info,`[GrayScaleFrameReader] Video width now divisible by 4, using optimized grayscale reader`,{width:r}),this._useRgbaFallback=i),this._useRgbaFallback&&this._rgbaFallbackReader)return this._rgbaFallbackReader.readFromSource(e);this.updateCanvasSizeIfNeeded(),this.updateFrameSizeIfNeeded();let{drawingBufferWidth:a,drawingBufferHeight:o,TEXTURE_2D:s,RGBA:c,UNSIGNED_BYTE:l,TRIANGLES:u}=this._webglContext;this._webglContext.viewport(0,0,a,o);let d=this._webglContext.getUniformLocation(this._shaderProgram,`x_spacing`),f=1/r;this._webglContext.uniform1f(d,f),this._webglContext.texImage2D(s,0,c,c,l,e),this._webglContext.drawArrays(u,0,6);let p=(n=this._framePool)==null?void 0:n.pop();if(!p)throw Error(`Frame pool found empty!`);let m=a*o*4;return p.length!==m&&(t.warn(`[GrayScaleFrameReader] Buffer from pool has wrong size, allocating new one`,{bufferLength:p.length,requiredSize:m}),p=new Uint8ClampedArray(m)),this._webglContext.readPixels(0,0,a,o,c,l,p),{width:r,height:o,data:new Uint8ClampedArray(p.buffer,0,r*o),frameId:C(),colorType:`GRAYSCALE`}}setup(){this.initShaderProgram(),this.initBuffers(),this.initTexture()}dispose(){var e;this._ctx&&=(this._shaderProgram&&=(this._ctx.deleteProgram(this._shaderProgram),null),this._positionBuffer&&=(this._ctx.deleteBuffer(this._positionBuffer),null),this._texture&&=(this._ctx.deleteTexture(this._texture),null),null),this._rgbaFallbackReader&&=(this._rgbaFallbackReader.dispose(),null),(e=this._framePool)==null||e.empty(),this._canvas=void 0}updateCanvasSizeIfNeeded(){if(!this._canvas)return;let e=Math.ceil(this._contextWebGL.drawingBufferWidth/4);(this._canvas.width!==e||this._canvas.height!==this._contextWebGL.drawingBufferHeight)&&(this._canvas.width=e,this._canvas.height=this._contextWebGL.drawingBufferHeight)}updateFrameSizeIfNeeded(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this._webglContext,n=e*t*4;this._frameSize!==n&&(this._frameSize=n,this._framePool&&this._framePool.empty(),this._framePool=new a({capacity:this._maxPoolCapacity,lowWaterMark:this._minPoolCapacity,createItem:()=>new Uint8ClampedArray(this._frameSize)}))}initShaderProgram(){let e=s(this._webglContext,this._webglContext.VERTEX_SHADER,`
1
+ import{t as e}from"./browserHelper-DuxFlAfF.js";import{Logger as t}from"./logger.js";import"./browserCompatibility.js";import"./CameraRelated.js";import{DataCaptureError as n}from"./DataCaptureError.js";import{CameraAccess as r}from"./private/CameraAccess.js";import"./private/FrameReaders/ColorType.js";import{FrameReaderAbstract as i}from"./private/FrameReaders/FrameReaderAbstract.js";import{WatermarkStack as a}from"./private/FrameReaders/WatermarkStack.js";import{createProgram as o,createShader as s}from"./private/FrameReaders/webglUtilities.js";import{getTimestamp as c}from"./private/utils/getTimestamp.js";import{Point as l}from"./commons/Point.js";import{Rect as u}from"./commons/Rect.js";import{Size as d}from"./commons/Size.js";import{defaultViewClassnames as f}from"./DefaultViewClassnames.js";import{cameraPool as p}from"./private/CameraPool.js";import{debounce as m}from"./private/utils/debounce.js";import{cancelSafeRequestAnimationFrame as h,safeRequestAnimationFrame as g}from"./private/utils/safeRequestAnimationFrame.js";import{assertUnreachable as _}from"./tsHelper.js";import{transparentPixelImage as v}from"./assets/transparentPixelImage.js";var y=class extends i{constructor(...e){super(...e),this.colorType=`RGBA`}get _initialized(){return this._texture!=null&&this._framebuffer!=null}readFromSource(e){this._initialized||this.setup(),this.updateFrameSizeIfNeeded();let t=this._framePool.pop();return this._contextWebGL.texImage2D(this._contextWebGL.TEXTURE_2D,0,this._contextWebGL.RGBA,this._contextWebGL.RGBA,this._contextWebGL.UNSIGNED_BYTE,e),this._contextWebGL.readPixels(0,0,this._contextWebGL.drawingBufferWidth,this._contextWebGL.drawingBufferHeight,this._contextWebGL.RGBA,this._contextWebGL.UNSIGNED_BYTE,t),{width:this._contextWebGL.drawingBufferWidth,height:this._contextWebGL.drawingBufferHeight,data:t,frameId:C(),colorType:this.colorType}}setup(){this._texture=this._contextWebGL.createTexture(),this._texture??t.warn(`Could not create texture from WebGLRenderingContext`),this._contextWebGL.bindTexture(this._contextWebGL.TEXTURE_2D,this._texture),this._framebuffer=this._contextWebGL.createFramebuffer(),this._framebuffer??t.warn(`Could not create frameBuffer from WebGLRenderingContext`),this._contextWebGL.bindFramebuffer(this._contextWebGL.FRAMEBUFFER,this._framebuffer),this._contextWebGL.framebufferTexture2D(this._contextWebGL.FRAMEBUFFER,this._contextWebGL.COLOR_ATTACHMENT0,this._contextWebGL.TEXTURE_2D,this._texture,0),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_WRAP_S,this._contextWebGL.CLAMP_TO_EDGE),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_WRAP_T,this._contextWebGL.CLAMP_TO_EDGE),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_MIN_FILTER,this._contextWebGL.NEAREST),this._contextWebGL.texParameteri(this._contextWebGL.TEXTURE_2D,this._contextWebGL.TEXTURE_MAG_FILTER,this._contextWebGL.NEAREST)}dispose(){var e;this._texture!=null&&(this._contextWebGL.deleteTexture(this._texture),this._texture=null),this._framebuffer!=null&&(this._contextWebGL.deleteFramebuffer(this._framebuffer),this._framebuffer=null),(e=this._framePool)==null||e.empty()}updateFrameSizeIfNeeded(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this._contextWebGL,n=e*t*4;if(this._frameSize!==n){var r;this._frameSize=n,(r=this._framePool)==null||r.empty(),this._framePool=new a({capacity:this._maxPoolCapacity,lowWaterMark:this._minPoolCapacity,createItem:()=>new Uint8ClampedArray(this._frameSize)})}}},b=class extends i{constructor(e,t){super(e,t),this.colorType=`GRAYSCALE`,this._useRgbaFallback=!1,this._positions=new Float32Array([-1,-1,-1,1,1,-1,1,-1,-1,1,1,1]),this._canvas=document.createElement(`canvas`)}get _webglContext(){if(!this._ctx){var e;if(this._ctx=(e=this._canvas)==null?void 0:e.getContext(`webgl`,{antialias:!1}),!this._ctx)throw Error(`Cannot get WebGL context`);this.setup()}return this._ctx}readFromSource(e){var n;let r=(e==null?void 0:e.videoWidth)??this._contextWebGL.drawingBufferWidth,i=r%4!=0;if(i!==this._useRgbaFallback&&(i?(t.debug(`[GrayScaleFrameReader] Video width not divisible by 4, falling back to RGBA reader for better performance`,{width:r}),this._rgbaFallbackReader||(this._rgbaFallbackReader=new y(this._contextWebGL,{minPoolCapacity:this._minPoolCapacity,maxPoolCapacity:this._maxPoolCapacity}),this._rgbaFallbackReader.setup())):t.log(t.Level.Info,`[GrayScaleFrameReader] Video width now divisible by 4, using optimized grayscale reader`,{width:r}),this._useRgbaFallback=i),this._useRgbaFallback&&this._rgbaFallbackReader)return this._rgbaFallbackReader.readFromSource(e);this.updateCanvasSizeIfNeeded(),this.updateFrameSizeIfNeeded();let{drawingBufferWidth:a,drawingBufferHeight:o,TEXTURE_2D:s,RGBA:c,UNSIGNED_BYTE:l,TRIANGLES:u}=this._webglContext;this._webglContext.viewport(0,0,a,o);let d=this._webglContext.getUniformLocation(this._shaderProgram,`x_spacing`),f=1/r;this._webglContext.uniform1f(d,f),this._webglContext.texImage2D(s,0,c,c,l,e),this._webglContext.drawArrays(u,0,6);let p=(n=this._framePool)==null?void 0:n.pop();if(!p)throw Error(`Frame pool found empty!`);let m=a*o*4;return p.length!==m&&(t.warn(`[GrayScaleFrameReader] Buffer from pool has wrong size, allocating new one`,{bufferLength:p.length,requiredSize:m}),p=new Uint8ClampedArray(m)),this._webglContext.readPixels(0,0,a,o,c,l,p),{width:r,height:o,data:new Uint8ClampedArray(p.buffer,0,r*o),frameId:C(),colorType:`GRAYSCALE`}}setup(){this.initShaderProgram(),this.initBuffers(),this.initTexture()}dispose(){var e;this._ctx&&=(this._shaderProgram&&=(this._ctx.deleteProgram(this._shaderProgram),null),this._positionBuffer&&=(this._ctx.deleteBuffer(this._positionBuffer),null),this._texture&&=(this._ctx.deleteTexture(this._texture),null),null),this._rgbaFallbackReader&&=(this._rgbaFallbackReader.dispose(),null),(e=this._framePool)==null||e.empty(),this._canvas=void 0}updateCanvasSizeIfNeeded(){if(!this._canvas)return;let e=Math.ceil(this._contextWebGL.drawingBufferWidth/4);(this._canvas.width!==e||this._canvas.height!==this._contextWebGL.drawingBufferHeight)&&(this._canvas.width=e,this._canvas.height=this._contextWebGL.drawingBufferHeight)}updateFrameSizeIfNeeded(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this._webglContext,n=e*t*4;this._frameSize!==n&&(this._frameSize=n,this._framePool&&this._framePool.empty(),this._framePool=new a({capacity:this._maxPoolCapacity,lowWaterMark:this._minPoolCapacity,createItem:()=>new Uint8ClampedArray(this._frameSize)}))}initShaderProgram(){let e=s(this._webglContext,this._webglContext.VERTEX_SHADER,`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_texcoord;
4
4
 
@@ -1,5 +1,5 @@
1
- import{t as e}from"./browserHelper-BQPnAZ2Y.js";import{Logger as t}from"./logger.js";import{n,r}from"./multithreadSimdHelper-BrYdWJgw.js";import{isCameraFrameSource as i}from"./CameraRelated.js";import{DataCaptureError as a}from"./DataCaptureError.js";import{UnsupportedBrowserError as o}from"./private/unsupportedBrowserError.js";import"./private/FrameReaders/ColorType.js";import{a as s,t as c}from"./CameraManager-DskA2C7T.js";import{INTERNAL_ACCESS as l}from"./private/privateAccess.js";import{ContextStatus as u}from"./DataCaptureContextRelated.js";import{DataCaptureContextSettings as d}from"./DataCaptureContextSettings.js";import{Localization as f}from"./Localization.js";import{OpenSourceSoftwareLicenseInfo as p}from"./license/OpenSourceSoftwareLicenseInfo.js";import{WebBatteryInterface as m}from"./private/BatteryInterface.js";import{normalizeLibraryLocation as h}from"./private/Helper.js";import{disposeGlobalAudioContext as g,ensureUnlockSetup as _}from"./private/customHowler/index.js";import{loadPolyfills as v}from"./private/utils/polyfillLoader.js";import{translations as y}from"./translations.js";import"./worker/OverrideState.js";import b from"./LoadingStatus.js";import x from"./private/ViewsRegistry.js";import{n as S,r as C,t as w}from"./hybridDesktopPlatformHelpers-DPAJQLcX.js";import{ImageConverterMainThread as T}from"./private/ImageConverterMainThread.js";import{nativeHandle as E}from"./private/nativeHandle.js";import{AsyncStateMachine as D}from"./private/utils/AsyncStateMachine.js";import{isObject as O}from"./private/utils/isObject.js";import{ensureGlobalThisPolyfill as k}from"./private/utils/globalThisPolyfill.js";var A=class{constructor(e=I,n=t,r=globalThis.fetch.bind(globalThis)){this.staticContext=I,this.staticContext=e,this.logger=n,this.fetch=r}get workerCommand(){var e;return(e=this.staticContext.mainDataCaptureLoader)==null?void 0:e.workerCommand.bind(this.staticContext.mainDataCaptureLoader)}async getLicenseText(){var e;let t=this.staticContext.stateMachine.currentState;if(t===`unconfigured`||t===`configuring`)return this.logger.warn(`You must call "DataCaptureContext.forLicenseKey" before retrieving open source license text info.`),``;let n=new URL(`${(this.staticContext.libraryLocation??``).replace(/\/$/,``)}/license/web-core-license.txt`),[r,i]=await Promise.all([(e=this.workerCommand)==null?void 0:e.call(this,`getOpenSourceSoftwareLicenseInfo`,{}),this.fetchWebLicenseText(n.toString())]);return[r==null?void 0:r.licenseText,i].filter(e=>e!=null).join(`
2
- `)}async fetchWebLicenseText(e){return this.fetch(e,{mode:`cors`,credentials:`include`,headers:{"Content-Type":`text/plain`}}).then(async e=>{if(!e.ok)throw Error(`${e.status} ${e.statusText}`);return e.text()}).catch(t=>(this.logger.warn(`Failed to fetch license from ${e}: ${t.toString()}`),null))}};function j(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const M=[{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 N(e,t,n){let r=n.value;return n.value=function(...e){let n=I.stateMachine;return n.currentState===`ready`&&I.mainDataCaptureLoader!=null?r.apply(this,e):n.isInitializing||n.currentState===`configured`?n.waitForState(`ready`).then(()=>r.apply(this,e)):Promise.reject(Error(`Please call DataCaptureContext.forLicenseKey() before calling ${String(t)}`))},n}function P(e){return e[E]!=null}function F(e){return`skipSerialization`in e||e[E]!=null}var I=class D{constructor(){this._asyncImageConverterInstance=void 0,this.framework=`web`,this.runtimeEnvironment={deviceOS:e.getUserAgentInfo().getOS().name??``,browser:e.getUserAgentInfo().getBrowser().name??``,browserVersion:e.getUserAgentInfo().getBrowser().version??``,get deviceModelName(){let{model:t,vendor:n}=e.getUserAgentInfo().getDevice();return(n==null||n===``)&&(n=`Unknown`),(t==null||t===``)&&(t=`Unknown`),[n,t].join(` `)}},this.settings=new d,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=!1,this.highEndBlurryRecognition=!1,this._frameHandlers=[],this._useSynchronousFrameFlow=!1,this[l]={hasModes:this.hasModes.bind(this)}}static get moduleLicenseTextProviders(){return[new A]}static get sharedInstance(){return D._sharedInstance??=new D,D._sharedInstance}static get currentState(){return D.stateMachine.currentState}static get isReady(){return D.stateMachine.currentState===`ready`}static get isInitializing(){return D.stateMachine.isInitializing}static addStateListener(e){D.stateMachine.addListener(e)}static removeStateListener(e){D.stateMachine.removeListener(e)}async initializeWithOptions(t){var n,r;D.deviceID===``&&(D.deviceID=await e.getDeviceId()),this.licenseKey=t.licenseKey??D.userLicenseKey??``,this.deviceName=t.deviceName??``,this.dataCaptureInstance=t.dataCaptureInstance??D.mainDataCaptureLoader,this.delayedRegistration=t.delayedRegistration??!1,t.settings!=null&&(this.settings=t.settings),this.highEndBlurryRecognition=((n=t.dataCaptureInstance)==null?void 0:n.highEndBlurryRecognition)??((r=D.mainDataCaptureLoader)==null?void 0:r.highEndBlurryRecognition)??!1;for(let e of this.pendingWorkerMessageListeners)this.dataCaptureInstance.addWorkerListener(e);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 Error(`Cannot call workerCommand before dataCaptureInstance is set`);return this.dataCaptureInstance.workerCommand.bind(this.dataCaptureInstance)}static async forLicenseKey(e,n){return t.debug(`forLicenseKey called, current state: ${D.stateMachine.currentState}`),D.stateMachine.currentState===`ready`?(t.debug(`DataCaptureContext is already ready, returning existing instance`),D.sharedInstance):D.stateMachine.isInitializing?(t.debug(`DataCaptureContext is already initializing, waiting for completion`),await D.stateMachine.waitForState(`ready`),D.sharedInstance):D.stateMachine.currentState===`unconfigured`?(t.debug(`Starting initialization from unconfigured state`),await D.stateMachine.executeAsyncTransition({targetState:`configuring`,action:async()=>{await D.internalConfigure(e,n)},onSuccess:`configured`,onError:`unconfigured`}),await D.stateMachine.executeAsyncTransition({targetState:`creating-context`,action:async()=>{await D.sharedInstance.initializeWithOptions({licenseKey:e,deviceName:n.deviceName,settings:n.settings})},onSuccess:`ready`,onError:`unconfigured`}),D.sharedInstance):D.sharedInstance}static async internalConfigure(i,a){k(),_(),f.getInstance().updateIfMissing(y);let{forceAllPolyfills:s,overrideThreadsSupport:c,overrideSimdSupport:l}=D.getOverridesFromQueryString(),[u,d,p]=await Promise.all([v({forceAllPolyfills:s}),r(),n()]);c!==`auto`&&(t.warn(`Threads support override: was ${p} is now ${c===`on`}`),p=c===`on`),l!==`auto`&&(t.warn(`SIMD support override: was ${d} is now ${l===`on`}`),d=l===`on`),D.capabilityInfo={simdSupport:d,threadsSupport:p},t.debug(`Capability info detected - SIMD: ${d}, Threads: ${p}`),await D.validateOptions({...a,licenseKey:i});let m={licenseKey:i,libraryLocation:h(a.libraryLocation),moduleLoaders:a.moduleLoaders,logLevel:a.logLevel??t.Level.Debug,verifyResponseHash:!0,loadProgressNotifier:b.notify.bind(b),simdSupport:d,threadsSupport:p};t.setLevel(m.logLevel),D.userLicenseKey=m.licenseKey,D.libraryLocation=m.libraryLocation,b.subscribe(D.updateViewsWithProgress);let g=e.checkBrowserCompatibility();if(!g.fullSupport&&!g.scannerSupport)throw new o(g);e.isSupportedIOSVersion()||t.warn(`Warning: Minimum supported iOS version is 14.6.
1
+ import{t as e}from"./browserHelper-DuxFlAfF.js";import{Logger as t}from"./logger.js";import{n,r}from"./multithreadSimdHelper-BrYdWJgw.js";import{isCameraFrameSource as i}from"./CameraRelated.js";import{DataCaptureError as a}from"./DataCaptureError.js";import{UnsupportedBrowserError as o}from"./private/unsupportedBrowserError.js";import"./private/FrameReaders/ColorType.js";import{a as s,t as c}from"./CameraManager-BTGb7HgX.js";import{INTERNAL_ACCESS as l}from"./private/privateAccess.js";import{ContextStatus as u}from"./DataCaptureContextRelated.js";import{DataCaptureContextSettings as d}from"./DataCaptureContextSettings.js";import{Localization as f}from"./Localization.js";import{OpenSourceSoftwareLicenseInfo as p}from"./license/OpenSourceSoftwareLicenseInfo.js";import{WebBatteryInterface as m}from"./private/BatteryInterface.js";import{normalizeLibraryLocation as h}from"./private/Helper.js";import{disposeGlobalAudioContext as g,ensureUnlockSetup as _}from"./private/customHowler/index.js";import{loadPolyfills as v}from"./private/utils/polyfillLoader.js";import{translations as y}from"./translations.js";import"./worker/OverrideState.js";import b from"./LoadingStatus.js";import x from"./private/ViewsRegistry.js";import{n as S,r as C,t as w}from"./hybridDesktopPlatformHelpers-OpmECgIg.js";import{ImageConverterMainThread as T}from"./private/ImageConverterMainThread.js";import{nativeHandle as E}from"./private/nativeHandle.js";import{AsyncStateMachine as D}from"./private/utils/AsyncStateMachine.js";import{isObject as O}from"./private/utils/isObject.js";import{ensureGlobalThisPolyfill as k}from"./private/utils/globalThisPolyfill.js";var A=class{constructor(e=I,n=t,r=globalThis.fetch.bind(globalThis)){this.staticContext=I,this.staticContext=e,this.logger=n,this.fetch=r}get workerCommand(){var e;return(e=this.staticContext.mainDataCaptureLoader)==null?void 0:e.workerCommand.bind(this.staticContext.mainDataCaptureLoader)}async getLicenseText(){var e;let t=this.staticContext.stateMachine.currentState;if(t===`unconfigured`||t===`configuring`)return this.logger.warn(`You must call "DataCaptureContext.forLicenseKey" before retrieving open source license text info.`),``;let n=new URL(`${(this.staticContext.libraryLocation??``).replace(/\/$/,``)}/license/web-core-license.txt`),[r,i]=await Promise.all([(e=this.workerCommand)==null?void 0:e.call(this,`getOpenSourceSoftwareLicenseInfo`,{}),this.fetchWebLicenseText(n.toString())]);return[r==null?void 0:r.licenseText,i].filter(e=>e!=null).join(`
2
+ `)}async fetchWebLicenseText(e){return this.fetch(e,{mode:`cors`,credentials:`include`,headers:{"Content-Type":`text/plain`}}).then(async e=>{if(!e.ok)throw Error(`${e.status} ${e.statusText}`);return e.text()}).catch(t=>(this.logger.warn(`Failed to fetch license from ${e}: ${t.toString()}`),null))}};function j(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const M=[{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 N(e,t,n){let r=n.value;return n.value=function(...e){let n=I.stateMachine;return n.currentState===`ready`&&I.mainDataCaptureLoader!=null?r.apply(this,e):n.isInitializing||n.currentState===`configured`?n.waitForState(`ready`).then(()=>r.apply(this,e)):Promise.reject(Error(`Please call DataCaptureContext.forLicenseKey() before calling ${String(t)}`))},n}function P(e){return e[E]!=null}function F(e){return`skipSerialization`in e||e[E]!=null}var I=class D{constructor(){this._asyncImageConverterInstance=void 0,this.framework=`web`,this.runtimeEnvironment={deviceOS:e.getUserAgentInfo().getOS().name??``,browser:e.getUserAgentInfo().getBrowser().name??``,browserVersion:e.getUserAgentInfo().getBrowser().version??``,get deviceModelName(){let{model:t,vendor:n}=e.getUserAgentInfo().getDevice();return(n==null||n===``)&&(n=`Unknown`),(t==null||t===``)&&(t=`Unknown`),[n,t].join(` `)}},this.settings=new d,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=!1,this.highEndBlurryRecognition=!1,this._frameHandlers=[],this._useSynchronousFrameFlow=!1,this[l]={hasModes:this.hasModes.bind(this)}}static get moduleLicenseTextProviders(){return[new A]}static get sharedInstance(){return D._sharedInstance??=new D,D._sharedInstance}static get currentState(){return D.stateMachine.currentState}static get isReady(){return D.stateMachine.currentState===`ready`}static get isInitializing(){return D.stateMachine.isInitializing}static addStateListener(e){D.stateMachine.addListener(e)}static removeStateListener(e){D.stateMachine.removeListener(e)}async initializeWithOptions(t){var n,r;D.deviceID===``&&(D.deviceID=await e.getDeviceId()),this.licenseKey=t.licenseKey??D.userLicenseKey??``,this.deviceName=t.deviceName??``,this.dataCaptureInstance=t.dataCaptureInstance??D.mainDataCaptureLoader,this.delayedRegistration=t.delayedRegistration??!1,t.settings!=null&&(this.settings=t.settings),this.highEndBlurryRecognition=((n=t.dataCaptureInstance)==null?void 0:n.highEndBlurryRecognition)??((r=D.mainDataCaptureLoader)==null?void 0:r.highEndBlurryRecognition)??!1;for(let e of this.pendingWorkerMessageListeners)this.dataCaptureInstance.addWorkerListener(e);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 Error(`Cannot call workerCommand before dataCaptureInstance is set`);return this.dataCaptureInstance.workerCommand.bind(this.dataCaptureInstance)}static async forLicenseKey(e,n){return t.debug(`forLicenseKey called, current state: ${D.stateMachine.currentState}`),D.stateMachine.currentState===`ready`?(t.debug(`DataCaptureContext is already ready, returning existing instance`),D.sharedInstance):D.stateMachine.isInitializing?(t.debug(`DataCaptureContext is already initializing, waiting for completion`),await D.stateMachine.waitForState(`ready`),D.sharedInstance):D.stateMachine.currentState===`unconfigured`?(t.debug(`Starting initialization from unconfigured state`),await D.stateMachine.executeAsyncTransition({targetState:`configuring`,action:async()=>{await D.internalConfigure(e,n)},onSuccess:`configured`,onError:`unconfigured`}),await D.stateMachine.executeAsyncTransition({targetState:`creating-context`,action:async()=>{await D.sharedInstance.initializeWithOptions({licenseKey:e,deviceName:n.deviceName,settings:n.settings})},onSuccess:`ready`,onError:`unconfigured`}),D.sharedInstance):D.sharedInstance}static async internalConfigure(i,a){k(),_(),f.getInstance().updateIfMissing(y);let{forceAllPolyfills:s,overrideThreadsSupport:c,overrideSimdSupport:l}=D.getOverridesFromQueryString(),[u,d,p]=await Promise.all([v({forceAllPolyfills:s}),r(),n()]);c!==`auto`&&(t.warn(`Threads support override: was ${p} is now ${c===`on`}`),p=c===`on`),l!==`auto`&&(t.warn(`SIMD support override: was ${d} is now ${l===`on`}`),d=l===`on`),d&&e.isSIMDBroken()&&(t.warn(`WebKit 26.x SIMD v128 corruption bug detected — disabling SIMD, using scalar WASM`),d=!1),D.capabilityInfo={simdSupport:d,threadsSupport:p},t.debug(`Capability info detected - SIMD: ${d}, Threads: ${p}`),await D.validateOptions({...a,licenseKey:i});let m={licenseKey:i,libraryLocation:h(a.libraryLocation),moduleLoaders:a.moduleLoaders,logLevel:a.logLevel??t.Level.Debug,verifyResponseHash:!0,loadProgressNotifier:b.notify.bind(b),simdSupport:d,threadsSupport:p};t.setLevel(m.logLevel),D.userLicenseKey=m.licenseKey,D.libraryLocation=m.libraryLocation,b.subscribe(D.updateViewsWithProgress);let g=e.checkBrowserCompatibility();if(!g.fullSupport&&!g.scannerSupport)throw new o(g);e.isSupportedIOSVersion()||t.warn(`Warning: Minimum supported iOS version is 14.6.
3
3
  Please check the minimum system requirements here:
4
4
  https://docs.scandit.com/system-requirements#browser-compatibility`),D.dataCaptureLoaders=await D.loadModules(m.moduleLoaders,m);let x=m.moduleLoaders[0].moduleName;D.mainDataCaptureLoader=D.dataCaptureLoaders.get(x),b.unsubscribe(D.updateViewsWithProgress)}static async forLicenseKeyInElectronPath(e,t){if(!C())throw new a({name:`MisconfigurationError`,message:`forLicenseKeyInElectronPath can only be used in Electron applications`});let n=await S({licenseDataPath:e});if(n==null)throw new a({name:`NoLicenseKeyError`,message:`Cannot retrieve license key for Electron app at ${e}`});return D.forLicenseKey(n.licenseKey,{...t})}static updateViewsWithProgress({percentage:e}){for(let t of x.values())t.setProgressBarPercentage(e)}static getOverridesFromQueryString(){var e,t,n;function r(e){return[`auto`,`off`,`on`].includes(e)}let i=new URLSearchParams(window.location.search),[a=`auto`,o=`auto`,s=!1]=[(e=i.get(`pthreads`))==null?void 0:e.toLowerCase(),(t=i.get(`simd`))==null?void 0:t.toLowerCase(),((n=i.get(`forceAllPolyfills`))==null?void 0:n.toLowerCase())===`true`];return{overrideThreadsSupport:r(a)?a:`auto`,overrideSimdSupport:r(o)?o:`auto`,forceAllPolyfills:s}}static async validateOptions(e){if(e.licenseKey==null||e.licenseKey.trim().length<64)throw new a({name:`NoLicenseKeyError`,message:`No license key provided`});if(typeof e.libraryLocation!=`string`)throw new a({name:`MisconfigurationError`,message:`Option "libraryLocation" was not provided`});if(!Array.isArray(e.moduleLoaders)||e.moduleLoaders.length===0)throw new a({name:`MisconfigurationError`,message:`Option "moduleLoaders" is missing or empty`});let t=e.moduleLoaders.map(e=>e.moduleName);if(![`BarcodeCapture`,`IdCapture`,`LabelCapture`].includes(t[0]))throw new a({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 n=new Map,r=new Map;for(let n of e)r.set(n.moduleName,n.load(t));await Promise.all(r.values());for(let[e,t]of r)n.set(e,await t);return n}static async getOpenSourceSoftwareLicenseInfo(){let e=[];for(let t of D.moduleLicenseTextProviders){let n=await t.getLicenseText();e.push(n)}return new p(e.join(`
5
5
 
@@ -1 +1 @@
1
- import{t as e}from"./DataCaptureContext-CbQes_57.js";export{e as DataCaptureContext};
1
+ import{t as e}from"./DataCaptureContext-CVc_U_GE.js";export{e as DataCaptureContext};
@@ -1 +1 @@
1
- import{DataCaptureError as e}from"./DataCaptureError.js";let t;(function(t){function n(){let t=`8.5.0-beta.1`;if(t==null)throw new e({name:`Invalid library version`,message:`Library version is not defined or empty.`});return t}t.sdkVersion=n})(t||={});export{t as DataCaptureVersion};
1
+ import{DataCaptureError as e}from"./DataCaptureError.js";let t;(function(t){function n(){let t=`8.5.0`;if(t==null)throw new e({name:`Invalid library version`,message:`Library version is not defined or empty.`});return t}t.sdkVersion=n})(t||={});export{t as DataCaptureVersion};
@@ -1 +1 @@
1
- import{NumberWithUnit as e}from"./commons/NumberWithUnit.js";import{Logger as t}from"./logger.js";import"./CameraRelated.js";import{t as n}from"./CameraManager-DskA2C7T.js";import{Point as r}from"./commons/Point.js";import{Rect as i}from"./commons/Rect.js";import{Size as a}from"./commons/Size.js";import{INTERNAL_ACCESS as o}from"./private/privateAccess.js";import{ContextStatus as s}from"./DataCaptureContextRelated.js";import{Localization as c}from"./Localization.js";import{translations as l}from"./translations.js";import u from"./private/ViewsRegistry.js";import{Timeout as d}from"./private/utils/timeout.js";import{html as f}from"./private/utils/html.js";import"./worker/dataCaptureWorkerRelated.js";import{ConcreteNotificationPresenter as p}from"./NotificationPresenter/private/ConcreteNotificationPresenter.js";import"./commons/MeasureUnit.js";import{MarginsWithUnit as m}from"./commons/MarginsWithUnit.js";import"./commons/Orientation.js";import{Quadrilateral as h}from"./commons/Quadrilateral.js";import{PrivateCanvasDrawer as g}from"./private/CanvasDrawer.js";import{PrivateCanvasDrawerWithMetrics as _}from"./private/CanvasDrawerWithMetrics.js";import{classNames as v}from"./private/CustomLocationsViewStyles.js";import{GestureRecognizer as y}from"./private/GestureRecognizer/GestureRecognizer.js";import{CustomLocationsView as b}from"./private/CustomLocationsView.js";import{HTMLElementState as x}from"./private/HtmlElementState.js";import{OrientationObserver as S,orientationChangeEvent as C}from"./private/OrientationObserver.js";import{ViewClassNames as w}from"./private/ViewClassNames.js";import{getDataCaptureViewStyles as T}from"./private/ViewStyles.js";import{gray900 as E,neutrals as D}from"./private/ui/colors.js";import{ControlsLayout as O}from"./private/ui/molecules/ControlsLayout.js";import{HintPresenter as k}from"./private/ui/molecules/HintPresenter.js";import{LoadingOverlay as A}from"./private/ui/molecules/LoadingOverlay.js";import{AnchorPositions as j}from"./private/AnchorPositions.js";import{SingleImageUploaderView as M}from"./private/SingleImageUploaderView.js";import{defaultDataCaptureView as N}from"./defaults/DefaultsDataCaptureView.js";import"./private/AdditionalLayerPosition.js";const P=`core.camera.recovery`;var F=class F{get zoomGestures(){return this._zoomGestures}set zoomGestures(e){this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),this._zoomGestures=e,this.addSwipeToZoomListener(),this.addPinchToZoomListener()}get videoElement(){return n.instance().getVideoElement()}constructor(){this.focusGesture=N.focusGesture,this.shouldShowZoomNotification=!0,this._zoomGestures=N.zoomGestures,this.swipeToZoomGesture=null,this.pinchToZoomGesture=null,this._scanAreaMargins=N.scanAreaMargins,this._pointOfInterest=N.pointOfInterest,this._logoStyle=N.logoStyle,this._logoAnchor=N.logoAnchor,this._logoOffset=N.logoOffset,this._context=null,this.overlays=new Set,this.controlMap=new Map,this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)},this._previewCamera=null,this.isConnected=!1,this.controlsElement=void 0,this.frozenFrameCanvas=document.createElement(`canvas`),this.listeners=[],this.isVideoElementDetached=!1,this.orientation=`portrait`,this.hiddenProperties={stopVideoTracksOnVisibilityChange:!0,freezeFrameWhenStoppingFrameSource:!0,forceScanAreaMarginsToPixels:!1},this.orientationObserver=new S,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.zoomNotificationDuration=4e3,this.zoomNotificationTimeout=null,this[o]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this),freezeFrame:this.freezeFrame.bind(this),unfreezeFrame:this.unfreezeFrame.bind(this),overlays:this.overlays},this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),c.getInstance().updateIfMissing(l),this.zoomGestures=[...N.zoomGestures]}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var t;let n=this.hiddenProperties.forceScanAreaMarginsToPixels?this.marginsToPixels(e):e,r=this._scanAreaMargins;this._scanAreaMargins=n;for(let e of this.listeners){var i;(i=e.willChangeScanAreaMargins)==null||i.call(e,this,r,n)}(((t=this.privateContext)==null?void 0:t.update())??Promise.resolve()).then(()=>{for(let t of this.listeners){var e;(e=t.didChangeScanAreaMargins)==null||e.call(t,this,n)}})}marginsToPixels(t){let{width:n,height:r}=this;if(n===0&&r===0)return t;let i=(t,n)=>t.unit===`pixel`?t:new e(t.value*n,`pixel`);return new m(i(t.left,n),i(t.top,r),i(t.right,n),i(t.bottom,r))}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 c.getInstance().get(P)}get width(){var e;return Math.round(((e=this.htmlElementState)==null?void 0:e.width)??0)}get height(){var e;return Math.round(((e=this.htmlElementState)==null?void 0:e.height)??0)}get canvasDrawer(){return!this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new g(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get controls(){return this.controlMap.values()}get privateContext(){return this._context}static async forContext(e){let t=new F;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){if(this._context!==e&&(this._context=e,e)){var t,n,r;if(this.overlays.size>0&&!((t=this._context)!=null&&t[o].hasModes()))throw 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),(n=this.privateContext)==null||n.subscribeToWorkerMessages(this.onWorkerMessageHandler),(r=this._context)!=null&&r.frameSource&&await this.onFrameSourceChange(this._context.frameSource)}}connectToElement(e,t){var n,r,i;this.isConnected||=(this.orientationObserver.register(),this.setupHtmlElement(e),(n=this.canvasDrawer)==null||n.startObservingCanvasResize(),this.htmlElementDidChange(),u.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(C,this.onOrientationChangeListener),(r=this.hintPresenter)==null||r.addEventListener(`hintpresenterupdate`,this.onHintPresenterUpdateHandler),(i=this.hintPresenter)==null||i.addEventListener(`hintpresenterviewfinderupdaterequested`,this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=c.getInstance().subscribe(e=>{e[P]!=null&&(this.cameraRecoveryElement.textContent=e[P])}),this._previewCamera=(t==null?void 0:t.camera)??null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),!0)}detachFromElement(){var e,t,r,i,a,o,s,c,l;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener(`visibilitychange`,this.visibilityListener);for(let e of[`touchend`,`mousedown`])this.cameraRecoveryElement.removeEventListener(e,this.cameraRecoveryListener);(r=this.loadingOverlay)==null||r.remove(),(i=this.customLocationsView)==null||i.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),(a=this.gestureRecognizer)==null||a.removeListener(this),this.clearHtmlElementContent(),u.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(C,this.onOrientationChangeListener),(o=this.hintPresenter)==null||o.removeEventListener(`hintpresenterupdate`,this.onHintPresenterUpdateHandler),(s=this.hintPresenter)==null||s.removeEventListener(`hintpresenterviewfinderupdaterequested`,this.onViewFinderUpdateRequestedHandler),(c=this.localizationSubscription)==null||c.cancel(),n.instance().disconnectedCallback(),this._previewCamera&&=(this._previewCamera.removeListener(this.frameSourceListener),null),(l=this.zoomNotificationTimeout)==null||l.stop(),this.zoomNotificationTimeout=null;for(let e of this.controls)this.removeControl(e);this.isConnected=!1}}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 t,n,i,a;let o={width:((t=this.htmlElementState)==null?void 0:t.width)??0,height:((n=this.htmlElementState)==null?void 0:n.height)??0},s={width:((i=this.videoElement)==null?void 0:i.videoWidth)??0,height:((a=this.videoElement)==null?void 0:a.videoHeight)??0},c=o.width/o.height>s.width/s.height?o.width/s.width:o.height/s.height,l={x:e.x*c,y:e.y*c},u=(s.width*c-o.width)/2,d=(s.height*c-o.height)/2;return new r(l.x-u,l.y-d)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),n=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft);return new h(t,n,this.viewPointForFramePoint(e.bottomRight),r)}addControl(e){let t=e.toJSONObject().type;if(!this.controlMap.has(t)&&!(t===`camera-fov`&&this.controlMap.has(`zoom`))){if(t===`zoom`){let e=this.controlMap.get(`camera-fov`);e&&this.removeControl(e)}this.controlMap.set(t,e),e.install(this).then(t=>{if(t){var n;(n=this.privateContext)==null||n.update([{type:`addControl`,newValue:e}])}})}}removeControl(e){let t=e.toJSONObject().type;if(this.controlMap.has(t)){var n;e.remove(!0),this.controlMap.delete(t),(n=this.privateContext)==null||n.update([{type:`removeControl`,newValue:e}])}}toJSONObject(){return{scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:this.logoHidden??!1,logoStyle:this.logoStyle,overlays:[...this.overlays].map(e=>e.toJSONObject()),controls:[...this.controls].map(e=>e.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGestures:this._zoomGestures.map(e=>e.toJSONObject())}}isCameraRecoveryVisible(){return!this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e}async allowPictureInPicture(e){await n.instance().allowPictureInPicture(e)}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),n=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),i=this.viewPointForFramePoint(e.bottomRight),a=this.viewPointForFramePoint(e.centerLeft),o=this.viewPointForFramePoint(e.centerRight);return new j(t,n,i,r,a,this.viewPointForFramePoint(e.topCenter),o,this.viewPointForFramePoint(e.bottomCenter),this.viewPointForFramePoint(e.center))}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e)}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(n.instance().isMirrorImageEnabled()),Object.keys(e).includes(`removedIds`)?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e))}getNotificationPresenter(){if(!this.notificationPresenter){var e;let t=(e=this.htmlElement)==null?void 0:e.querySelector(k.tag);if(!t)throw Error(`Notification presenter cannot be found. Please ensure the DataCaptureView is connected.`);this.notificationPresenter=new p(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 t;let n=await((t=this.privateContext)==null?void 0:t.workerCommand(`getViewfinderInfo`,{}));n!=null&&this.updateHintPresenterViewFinderRect(n.rect)}clearHtmlElementContent(){if(this.htmlElement){var e;(e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML=``,this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0}}setupHtmlElement(e){var t;this.createStyles(),this.htmlElement=e,k.register(),O.register(),A.register();let r=f`<div class="${w.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${w.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${w.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${w.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="${v.CUSTOM_VIEW_CONTAINER}"></div><${k.tag}></${k.tag}><${O.tag}></${O.tag}><div class="${w.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${w.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${w.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=r,n.instance().connectedCallback(this.htmlElement.querySelector(`[data-js-id="video-container"]`)),this.isVideoElementDetached=!1,this.hintPresenter=this.htmlElement.querySelector(k.tag),this.notificationPresenter=this.hintPresenter?new p(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=A.create(),this.loadingOverlay.hide(),(t=this.htmlElement.querySelector(`[data-js-id="loading-overlay"]`))==null||t.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new b,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${v.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=e=>this.viewAnchorPositionsForFrameAnchorPositions(e),this.containerElement=this.htmlElement.querySelector(`.${w.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"]`);if(this.frozenFrame==null?this.frozenFrame=a:a.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(O.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${w.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${w.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null){var o;(o=this._context)==null||(o=o.frameSource)==null||o.switchToDesiredState(this.lastFrameSourceState)}document.addEventListener(`visibilitychange`,this.visibilityListener);for(let e of[`touchend`,`mousedown`])this.cameraRecoveryElement.addEventListener(e,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new x(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new y(this.htmlElement),this.gestureRecognizer.addListener(this),this.addSwipeToZoomListener(),this.addPinchToZoomListener()}setupHtmlElementSingleImageUploader(e){var n;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new M(e),this.singleImageUploaderView.mount(this.containerElement.querySelector(`[data-js-id="singleimage-paintboard"]`));let r=(n=this._context)==null?void 0:n.frameSource;this.singleImageUploaderView.onInputCheck(e=>{r.getCurrentState()!==`starting`&&e.preventDefault()}),this.singleImageUploaderView.onBeforeFileRead(()=>{r._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=r._context.hasEnabledMode())}),this.singleImageUploaderView.onImageLoadError(()=>{r.currentState=`starting`,t.log(t.Level.Error,`Could not load image from selected file`)}),this.singleImageUploaderView.onFileReaderError(e=>{var n;let i=e.target;r.currentState=`starting`,t.log(t.Level.Error,`Error while reading the file: ${((n=i.error)==null?void 0:n.toString())??``}`)}),this.singleImageUploaderView.onCaptureReady(async e=>{await r.processUploadedFileCapture(e)}),this.singleImageUploaderView.setButtonState(r.getCurrentState()===`starting`?`enabled`:`disabled`),r.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=T();for(let[t,n]of Object.entries(e))n.setAttribute(`scandit`,`data-capture-sdk-${t}`),document.head.append(n)}}async onOrientationChange(e){var t,n;this.orientation=e.detail.value,await((t=this.privateContext)==null?void 0:t.update([{type:`viewChange`,newValue:{...(n=this.htmlElementState)==null?void 0:n.toJSONObject(),orientation:this.orientation}}]))}htmlElementDidChange(){var e,t;if(!this.htmlElementState)return;let n=this.htmlElementState,r=n.toJSONObject();if(!x.areEquivalentJSONStates(this.lastHtmlElementState,r)){this.orientation=this.orientationObserver.orientation.value,(e=this.privateContext)==null||e.update([{type:`viewChange`,newValue:{...n.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=r,(t=this.canvasDrawer)==null||t.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(r.visible);for(let e of this.listeners)typeof e.didChangeSize==`function`&&e.didChangeSize(this,new a(r.size.width.value,r.size.height.value),this.orientation)}}async htmlElementDisconnected(){var e,t,r,i;n.instance().disconnectedCallback(),this.lastFrameSourceState=(e=this._context)==null||(e=e.frameSource)==null?void 0:e.getCurrentState(),await((t=this._context)==null||(t=t.frameSource)==null?void 0:t.switchToDesiredState(`off`)),await((r=this.privateContext)==null?void 0:r.update([{type:`viewChange`,newValue:{...(i=this.htmlElementState)==null?void 0:i.toJSONObject(),orientation:this.orientation}}])),this.isConnected=!1}attachAdditionalLayer(e,t){if(t===`above-controls`){var n;(n=this.controlsElement)==null||n.insertAdjacentElement(`afterend`,e)}else t===`overlay-container`&&this.containerElement.append(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=!0):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement(`afterbegin`,this.videoElement),this.isVideoElementDetached=!1,this.videoElement.style.removeProperty(`visibility`),this.videoElement.removeAttribute(`width`),this.videoElement.removeAttribute(`height`),this.videoElement.style.removeProperty(`opacity`)))}isCanvasDrawerWithMetrics(e){return e instanceof _}onWorkerMessage(e){switch(e.type){case`draw`:this.drawEngineCommands(e.payload);break;case`performanceMetricsReport`:{let t=this._canvasDrawer;t!=null&&this.isCanvasDrawerWithMetrics(t)&&t.setPerformanceMetrics(e.payload);break}case`contextDidChangeStatus`:{var t;let n=s.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),n.isValid?(this.clearError(),this.setVideoElementOpacity(`1`)):this.displayError(n);break}case`viewSizeChanged`:{let t=e.payload;if(t==null)return;this.onSDCViewSizeChangedCallback(t);break}default:var n;(n=this.hintPresenter)==null||n.handleMessage(e);break}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect)}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new i(new r(e.origin.x,e.origin.y),new a(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=!1}clearError(){this.errorElement.textContent=``,this.errorElement.hidden=!0}updateControls(){for(let t of this.controls){var e;(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 t=e==null?void 0:e.getCurrentState();t!=null&&await this.onCameraStateChanged(t)}else t===`singleImageUploader`&&this.setupHtmlElementSingleImageUploader(e.settings)}async onCameraStateChanged(e){var r;switch((r=this.cameraPaintboardElement)==null||r.classList.toggle(w.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){t.error(`cannot set frame source stream before connecting view to an HTML element`);return}this.videoElement&&(n.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),n.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity(`0`));return;case`off`:this.setVideoElementOpacity(`0`),this.updateControls();return;case`on`:await n.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity(`1`);break;case`goingToSleep`:this.freezeFrame();break;default:}}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 e;let r=(e=this.videoElement)==null?void 0:e.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState===`hidden`&&n.instance().stopVideoTracks(),document.visibilityState===`visible`&&n.instance().activeCamera!=null&&r!=null)){var i;if(!r.active||(i=r.getVideoTracks()[0])!=null&&i.muted)try{t.debug(`Detected visibility change ("visible") event with inactive video source, try to reinitialize camera`),await n.instance().reinitializeCamera()}catch{}else t.debug(`Detected visibility change ("visible") event with active video source, replay video`),n.instance().playVideo()}}async cameraRecovery(e){e.preventDefault(),n.instance().activeCamera=n.instance().selectedCamera,await n.instance().reinitializeCamera()}freezeFrame(){var e;if(!this.frozenFrame)return;let t=n.instance().getCurrentFrame();if(!t)return;let r=new ImageData(t.data,t.width,t.height);this.frozenFrameCanvas.width=r.width,this.frozenFrameCanvas.height=r.height,this.frozenFrame.width=r.width,this.frozenFrame.height=r.height,(e=this.frozenFrameCanvas.getContext(`2d`))==null||e.putImageData(r,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL(`image/jpeg`,.4),this.frozenFrame.classList.toggle(w.MIRRORED_CLASS_NAME,n.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=!1}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src=``,this.frozenFrame.hidden=!0)}onTap(e){var t;(t=this.privateContext)==null||t.workerCommand(`onTap`,{point:e.toJSONObject()})}onSwipeUp(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomIn()}onSwipeDown(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomOut()}onPinchIn(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomIn()}onPinchOut(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomOut()}didZoomInGesture(){this.performZoomIn()}didZoomOutGesture(){this.performZoomOut()}addSwipeToZoomListener(){let e=this._zoomGestures.find(e=>e.toJSONObject().type===`swipeToZoom`);e&&(this.swipeToZoomGesture=e,e.addListener(this))}removeSwipeToZoomListener(){var e;(e=this.swipeToZoomGesture)==null||e.removeListener(this),this.swipeToZoomGesture=null}addPinchToZoomListener(){let e=this._zoomGestures.find(e=>e.toJSONObject().type===`pinchToZoom`);e&&(this.pinchToZoomGesture=e,e.addListener(this))}removePinchToZoomListener(){var e;(e=this.pinchToZoomGesture)==null||e.removeListener(this),this.pinchToZoomGesture=null}async performZoomIn(){var e;let t=(e=this._context)==null?void 0:e.frameSource;if(!(t!=null&&t.settings))return;let n=t.settings.zoomFactor,r=[...t.settings.zoomLevels].sort((e,t)=>e-t).find(e=>e>n);r!=null&&(await t.setZoomFactor(r),this.showZoomNotification(r))}async performZoomOut(){var e;let t=(e=this._context)==null?void 0:e.frameSource;if(!(t!=null&&t.settings))return;let n=t.settings.zoomFactor,r=[...[...t.settings.zoomLevels].sort((e,t)=>e-t)].reverse().find(e=>e<n);r!=null&&(await t.setZoomFactor(r),this.showZoomNotification(r))}async showZoomNotification(e){var t,n;if(!this.shouldShowZoomNotification)return;let r=E.toJSON(),i={tag:`zoomNotification`,text:this.formatZoomFactor(e),hintStyle:{textColor:r,backgroundColor:D.neutralWhite.withAlpha(.8).toJSON(),textAlignment:`center`,hintIcon:`none`,iconColor:r,isAnimatedToView:!0,hintAnchor:`top`,hintAnchorOffset:16,horizontalMargin:16,maxWidthFraction:1,textSize:14,textWeight:700,lineHeight:24,maxLines:3,cornerRadius:4,fitToText:!0}};(t=this.zoomNotificationTimeout)==null||t.stop(),this.zoomNotificationTimeout=new d(this.zoomNotificationDuration,()=>{var e;(e=this.hintPresenter)==null||e.hideToast(i)}),await((n=this.hintPresenter)==null?void 0:n.showToast(i)),this.zoomNotificationTimeout.start()}formatZoomFactor(e){let t=Math.ceil(e*100)/100;return parseFloat(t.toPrecision(3))+`x`}};export{F as DataCaptureView};
1
+ import{NumberWithUnit as e}from"./commons/NumberWithUnit.js";import{Logger as t}from"./logger.js";import"./CameraRelated.js";import{t as n}from"./CameraManager-BTGb7HgX.js";import{Point as r}from"./commons/Point.js";import{Rect as i}from"./commons/Rect.js";import{Size as a}from"./commons/Size.js";import{INTERNAL_ACCESS as o}from"./private/privateAccess.js";import{ContextStatus as s}from"./DataCaptureContextRelated.js";import{Localization as c}from"./Localization.js";import{translations as l}from"./translations.js";import u from"./private/ViewsRegistry.js";import{Timeout as d}from"./private/utils/timeout.js";import{html as f}from"./private/utils/html.js";import"./worker/dataCaptureWorkerRelated.js";import{ConcreteNotificationPresenter as p}from"./NotificationPresenter/private/ConcreteNotificationPresenter.js";import"./commons/MeasureUnit.js";import{MarginsWithUnit as m}from"./commons/MarginsWithUnit.js";import"./commons/Orientation.js";import{Quadrilateral as h}from"./commons/Quadrilateral.js";import{PrivateCanvasDrawer as g}from"./private/CanvasDrawer.js";import{PrivateCanvasDrawerWithMetrics as _}from"./private/CanvasDrawerWithMetrics.js";import{classNames as v}from"./private/CustomLocationsViewStyles.js";import{GestureRecognizer as y}from"./private/GestureRecognizer/GestureRecognizer.js";import{CustomLocationsView as b}from"./private/CustomLocationsView.js";import{HTMLElementState as x}from"./private/HtmlElementState.js";import{OrientationObserver as S,orientationChangeEvent as C}from"./private/OrientationObserver.js";import{ViewClassNames as w}from"./private/ViewClassNames.js";import{getDataCaptureViewStyles as T}from"./private/ViewStyles.js";import{gray900 as E,neutrals as D}from"./private/ui/colors.js";import{ControlsLayout as O}from"./private/ui/molecules/ControlsLayout.js";import{HintPresenter as k}from"./private/ui/molecules/HintPresenter.js";import{LoadingOverlay as A}from"./private/ui/molecules/LoadingOverlay.js";import{AnchorPositions as j}from"./private/AnchorPositions.js";import{SingleImageUploaderView as M}from"./private/SingleImageUploaderView.js";import{defaultDataCaptureView as N}from"./defaults/DefaultsDataCaptureView.js";import"./private/AdditionalLayerPosition.js";const P=`core.camera.recovery`;var F=class F{get zoomGestures(){return this._zoomGestures}set zoomGestures(e){this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),this._zoomGestures=e,this.addSwipeToZoomListener(),this.addPinchToZoomListener()}get videoElement(){return n.instance().getVideoElement()}constructor(){this.focusGesture=N.focusGesture,this.shouldShowZoomNotification=!0,this._zoomGestures=N.zoomGestures,this.swipeToZoomGesture=null,this.pinchToZoomGesture=null,this._scanAreaMargins=N.scanAreaMargins,this._pointOfInterest=N.pointOfInterest,this._logoStyle=N.logoStyle,this._logoAnchor=N.logoAnchor,this._logoOffset=N.logoOffset,this._context=null,this.overlays=new Set,this.controlMap=new Map,this.frameSourceListener={didChangeState:this.onFrameSourceChange.bind(this)},this._previewCamera=null,this.isConnected=!1,this.controlsElement=void 0,this.frozenFrameCanvas=document.createElement(`canvas`),this.listeners=[],this.isVideoElementDetached=!1,this.orientation=`portrait`,this.hiddenProperties={stopVideoTracksOnVisibilityChange:!0,freezeFrameWhenStoppingFrameSource:!0,forceScanAreaMarginsToPixels:!1},this.orientationObserver=new S,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.zoomNotificationDuration=4e3,this.zoomNotificationTimeout=null,this[o]={attachAdditionalLayer:this.attachAdditionalLayer.bind(this),freezeFrame:this.freezeFrame.bind(this),unfreezeFrame:this.unfreezeFrame.bind(this),overlays:this.overlays},this.visibilityListener=this.onVisibilityChange.bind(this),this.cameraRecoveryListener=this.cameraRecovery.bind(this),c.getInstance().updateIfMissing(l),this.zoomGestures=[...N.zoomGestures]}get scanAreaMargins(){return this._scanAreaMargins}set scanAreaMargins(e){var t;let n=this.hiddenProperties.forceScanAreaMarginsToPixels?this.marginsToPixels(e):e,r=this._scanAreaMargins;this._scanAreaMargins=n;for(let e of this.listeners){var i;(i=e.willChangeScanAreaMargins)==null||i.call(e,this,r,n)}(((t=this.privateContext)==null?void 0:t.update())??Promise.resolve()).then(()=>{for(let t of this.listeners){var e;(e=t.didChangeScanAreaMargins)==null||e.call(t,this,n)}})}marginsToPixels(t){let{width:n,height:r}=this;if(n===0&&r===0)return t;let i=(t,n)=>t.unit===`pixel`?t:new e(t.value*n,`pixel`);return new m(i(t.left,n),i(t.top,r),i(t.right,n),i(t.bottom,r))}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 c.getInstance().get(P)}get width(){var e;return Math.round(((e=this.htmlElementState)==null?void 0:e.width)??0)}get height(){var e;return Math.round(((e=this.htmlElementState)==null?void 0:e.height)??0)}get canvasDrawer(){return!this._canvasDrawer&&this.canvasElement!=null&&(this._canvasDrawer=new g(this.canvasElement),this._canvasDrawer.startObservingCanvasResize()),this._canvasDrawer}get controls(){return this.controlMap.values()}get privateContext(){return this._context}static async forContext(e){let t=new F;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){if(this._context!==e&&(this._context=e,e)){var t,n,r;if(this.overlays.size>0&&!((t=this._context)!=null&&t[o].hasModes()))throw 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),(n=this.privateContext)==null||n.subscribeToWorkerMessages(this.onWorkerMessageHandler),(r=this._context)!=null&&r.frameSource&&await this.onFrameSourceChange(this._context.frameSource)}}connectToElement(e,t){var n,r,i;this.isConnected||=(this.orientationObserver.register(),this.setupHtmlElement(e),(n=this.canvasDrawer)==null||n.startObservingCanvasResize(),this.htmlElementDidChange(),u.add(this),this.orientation=this.orientationObserver.orientation.value,this.orientationObserver.addEventListener(C,this.onOrientationChangeListener),(r=this.hintPresenter)==null||r.addEventListener(`hintpresenterupdate`,this.onHintPresenterUpdateHandler),(i=this.hintPresenter)==null||i.addEventListener(`hintpresenterviewfinderupdaterequested`,this.onViewFinderUpdateRequestedHandler),this.localizationSubscription=c.getInstance().subscribe(e=>{e[P]!=null&&(this.cameraRecoveryElement.textContent=e[P])}),this._previewCamera=(t==null?void 0:t.camera)??null,this._previewCamera&&(this._previewCamera.addListener(this.frameSourceListener),this.onFrameSourceChange(this._previewCamera)),this.updateControls(),!0)}detachFromElement(){var e,t,r,i,a,o,s,c,l;if(this.isConnected){(e=this.htmlElementState)==null||e.removeListeners(),this.removeStyles(),(t=this.canvasDrawer)==null||t.endObservingCanvasResize(),document.removeEventListener(`visibilitychange`,this.visibilityListener);for(let e of[`touchend`,`mousedown`])this.cameraRecoveryElement.removeEventListener(e,this.cameraRecoveryListener);(r=this.loadingOverlay)==null||r.remove(),(i=this.customLocationsView)==null||i.unmount(),this.notificationPresenter=null,this.htmlElementDidChange(),this.removeSwipeToZoomListener(),this.removePinchToZoomListener(),(a=this.gestureRecognizer)==null||a.removeListener(this),this.clearHtmlElementContent(),u.delete(this),this.orientationObserver.unregister(),this.orientationObserver.removeEventListener(C,this.onOrientationChangeListener),(o=this.hintPresenter)==null||o.removeEventListener(`hintpresenterupdate`,this.onHintPresenterUpdateHandler),(s=this.hintPresenter)==null||s.removeEventListener(`hintpresenterviewfinderupdaterequested`,this.onViewFinderUpdateRequestedHandler),(c=this.localizationSubscription)==null||c.cancel(),n.instance().disconnectedCallback(),this._previewCamera&&=(this._previewCamera.removeListener(this.frameSourceListener),null),(l=this.zoomNotificationTimeout)==null||l.stop(),this.zoomNotificationTimeout=null;for(let e of this.controls)this.removeControl(e);this.isConnected=!1}}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 t,n,i,a;let o={width:((t=this.htmlElementState)==null?void 0:t.width)??0,height:((n=this.htmlElementState)==null?void 0:n.height)??0},s={width:((i=this.videoElement)==null?void 0:i.videoWidth)??0,height:((a=this.videoElement)==null?void 0:a.videoHeight)??0},c=o.width/o.height>s.width/s.height?o.width/s.width:o.height/s.height,l={x:e.x*c,y:e.y*c},u=(s.width*c-o.width)/2,d=(s.height*c-o.height)/2;return new r(l.x-u,l.y-d)}viewQuadrilateralForFrameQuadrilateral(e){let t=this.viewPointForFramePoint(e.topLeft),n=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft);return new h(t,n,this.viewPointForFramePoint(e.bottomRight),r)}addControl(e){let t=e.toJSONObject().type;if(!this.controlMap.has(t)&&!(t===`camera-fov`&&this.controlMap.has(`zoom`))){if(t===`zoom`){let e=this.controlMap.get(`camera-fov`);e&&this.removeControl(e)}this.controlMap.set(t,e),e.install(this).then(t=>{if(t){var n;(n=this.privateContext)==null||n.update([{type:`addControl`,newValue:e}])}})}}removeControl(e){let t=e.toJSONObject().type;if(this.controlMap.has(t)){var n;e.remove(!0),this.controlMap.delete(t),(n=this.privateContext)==null||n.update([{type:`removeControl`,newValue:e}])}}toJSONObject(){return{scanAreaMargins:this.scanAreaMargins.toJSONObject(),pointOfInterest:this.pointOfInterest.toJSONObject(),logoAnchor:this.logoAnchor,logoOffset:this.logoOffset.toJSONObject(),logoHidden:this.logoHidden??!1,logoStyle:this.logoStyle,overlays:[...this.overlays].map(e=>e.toJSONObject()),controls:[...this.controls].map(e=>e.toJSONObject()),focusGesture:this.focusGesture?this.focusGesture.toJSONObject():null,zoomGestures:this._zoomGestures.map(e=>e.toJSONObject())}}isCameraRecoveryVisible(){return!this.cameraRecoveryElement.hidden}setCameraRecoveryVisible(e){this.cameraRecoveryElement.hidden=!e}async allowPictureInPicture(e){await n.instance().allowPictureInPicture(e)}viewAnchorPositionsForFrameAnchorPositions(e){let t=this.viewPointForFramePoint(e.topLeft),n=this.viewPointForFramePoint(e.topRight),r=this.viewPointForFramePoint(e.bottomLeft),i=this.viewPointForFramePoint(e.bottomRight),a=this.viewPointForFramePoint(e.centerLeft),o=this.viewPointForFramePoint(e.centerRight);return new j(t,n,i,r,a,this.viewPointForFramePoint(e.topCenter),o,this.viewPointForFramePoint(e.bottomCenter),this.viewPointForFramePoint(e.center))}setDidTapCustomLocationsViewListener(e){this.customLocationsView&&this.customLocationsView.listener===null&&(this.customLocationsView.listener=e)}renderCustomLocationsView(e){this.customLocationsView!=null&&(this.customLocationsView.setMirrored(n.instance().isMirrorImageEnabled()),Object.keys(e).includes(`removedIds`)?this.customLocationsView.render(e):this.customLocationsView.renderDomView(e))}getNotificationPresenter(){if(!this.notificationPresenter){var e;let t=(e=this.htmlElement)==null?void 0:e.querySelector(k.tag);if(!t)throw Error(`Notification presenter cannot be found. Please ensure the DataCaptureView is connected.`);this.notificationPresenter=new p(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 t;let n=await((t=this.privateContext)==null?void 0:t.workerCommand(`getViewfinderInfo`,{}));n!=null&&this.updateHintPresenterViewFinderRect(n.rect)}clearHtmlElementContent(){if(this.htmlElement){var e;(e=this.canvasDrawer)==null||e.endObservingCanvasResize(),this.htmlElement.innerHTML=``,this.cameraPaintboardElement=void 0,this.singleImageUploaderPaintboardElement=void 0,this.htmlElement=void 0}}setupHtmlElement(e){var t;this.createStyles(),this.htmlElement=e,k.register(),O.register(),A.register();let r=f`<div class="${w.CONTAINER_CLASS_NAME}" role="main" aria-label="Data capture view"><div class="${w.PAINTBOARDS_CONTAINER_CLASS_NAME}"><div data-js-id="loading-overlay"></div><div class="${w.PAINTBOARD_CLASS_NAME}" data-js-id="camera-paintboard"><div data-js-id="video-container"></div><img class="${w.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="${v.CUSTOM_VIEW_CONTAINER}"></div><${k.tag}></${k.tag}><${O.tag}></${O.tag}><div class="${w.CAMERA_RECOVERY_CLASS_NAME}" role="alert" aria-live="polite" aria-atomic="true" hidden>${this.cameraRecoveryText}</div><div class="${w.ERROR_CLASS_NAME}" role="alert" aria-live="assertive" aria-atomic="true" hidden></div></div><div class="${w.PAINTBOARD_CLASS_NAME}" data-js-id="singleimage-paintboard"></div></div></div>`;this.htmlElement.innerHTML=r,n.instance().connectedCallback(this.htmlElement.querySelector(`[data-js-id="video-container"]`)),this.isVideoElementDetached=!1,this.hintPresenter=this.htmlElement.querySelector(k.tag),this.notificationPresenter=this.hintPresenter?new p(this.hintPresenter):null,this.loadingOverlay&&this.loadingOverlay.remove(),this.loadingOverlay=A.create(),this.loadingOverlay.hide(),(t=this.htmlElement.querySelector(`[data-js-id="loading-overlay"]`))==null||t.replaceWith(this.loadingOverlay),this.customLocationsView&&this.customLocationsView.unmount(),this.customLocationsView=new b,this.customLocationsView.mount(this.htmlElement.querySelector(`[data-js-id="${v.CUSTOM_VIEW_CONTAINER}"]`)),this.customLocationsView.mapViewAnchorPositionsForFramePoint=e=>this.viewAnchorPositionsForFrameAnchorPositions(e),this.containerElement=this.htmlElement.querySelector(`.${w.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"]`);if(this.frozenFrame==null?this.frozenFrame=a:a.replaceWith(this.frozenFrame),this.controlsElement=this.cameraPaintboardElement.querySelector(O.tag),this.cameraRecoveryElement=this.cameraPaintboardElement.querySelector(`.${w.CAMERA_RECOVERY_CLASS_NAME}`),this.errorElement=this.cameraPaintboardElement.querySelector(`.${w.ERROR_CLASS_NAME}`),this.lastFrameSourceState!=null){var o;(o=this._context)==null||(o=o.frameSource)==null||o.switchToDesiredState(this.lastFrameSourceState)}document.addEventListener(`visibilitychange`,this.visibilityListener);for(let e of[`touchend`,`mousedown`])this.cameraRecoveryElement.addEventListener(e,this.cameraRecoveryListener);this.htmlElementState&&this.htmlElementState.removeListeners(),this.htmlElementState=new x(this.htmlElement),this.htmlElementState.onStateChanged(this.htmlElementDidChangeHandler),this.htmlElementState.onDisconnected(this.htmlElementDisconnectedHandler),this.gestureRecognizer=new y(this.htmlElement),this.gestureRecognizer.addListener(this),this.addSwipeToZoomListener(),this.addPinchToZoomListener()}setupHtmlElementSingleImageUploader(e){var n;if(this.singleImageUploaderPaintboardElement==null)return;this.singleImageUploaderView&&this.singleImageUploaderView.unmount(),this.singleImageUploaderView=new M(e),this.singleImageUploaderView.mount(this.containerElement.querySelector(`[data-js-id="singleimage-paintboard"]`));let r=(n=this._context)==null?void 0:n.frameSource;this.singleImageUploaderView.onInputCheck(e=>{r.getCurrentState()!==`starting`&&e.preventDefault()}),this.singleImageUploaderView.onBeforeFileRead(()=>{r._context&&this.singleImageUploaderView&&(this.singleImageUploaderView.canUploadFile=r._context.hasEnabledMode())}),this.singleImageUploaderView.onImageLoadError(()=>{r.currentState=`starting`,t.log(t.Level.Error,`Could not load image from selected file`)}),this.singleImageUploaderView.onFileReaderError(e=>{var n;let i=e.target;r.currentState=`starting`,t.log(t.Level.Error,`Error while reading the file: ${((n=i.error)==null?void 0:n.toString())??``}`)}),this.singleImageUploaderView.onCaptureReady(async e=>{await r.processUploadedFileCapture(e)}),this.singleImageUploaderView.setButtonState(r.getCurrentState()===`starting`?`enabled`:`disabled`),r.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=T();for(let[t,n]of Object.entries(e))n.setAttribute(`scandit`,`data-capture-sdk-${t}`),document.head.append(n)}}async onOrientationChange(e){var t,n;this.orientation=e.detail.value,await((t=this.privateContext)==null?void 0:t.update([{type:`viewChange`,newValue:{...(n=this.htmlElementState)==null?void 0:n.toJSONObject(),orientation:this.orientation}}]))}htmlElementDidChange(){var e,t;if(!this.htmlElementState)return;let n=this.htmlElementState,r=n.toJSONObject();if(!x.areEquivalentJSONStates(this.lastHtmlElementState,r)){this.orientation=this.orientationObserver.orientation.value,(e=this.privateContext)==null||e.update([{type:`viewChange`,newValue:{...n.toJSONObject(),orientation:this.orientation}}]),this.lastHtmlElementState=r,(t=this.canvasDrawer)==null||t.updateCanvasSizeAttributes(this.width,this.height),this.handleVideoDisplay(r.visible);for(let e of this.listeners)typeof e.didChangeSize==`function`&&e.didChangeSize(this,new a(r.size.width.value,r.size.height.value),this.orientation)}}async htmlElementDisconnected(){var e,t,r,i;n.instance().disconnectedCallback(),this.lastFrameSourceState=(e=this._context)==null||(e=e.frameSource)==null?void 0:e.getCurrentState(),await((t=this._context)==null||(t=t.frameSource)==null?void 0:t.switchToDesiredState(`off`)),await((r=this.privateContext)==null?void 0:r.update([{type:`viewChange`,newValue:{...(i=this.htmlElementState)==null?void 0:i.toJSONObject(),orientation:this.orientation}}])),this.isConnected=!1}attachAdditionalLayer(e,t){if(t===`above-controls`){var n;(n=this.controlsElement)==null||n.insertAdjacentElement(`afterend`,e)}else t===`overlay-container`&&this.containerElement.append(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=!0):e&&this.isVideoElementDetached&&(this.cameraPaintboardElement.insertAdjacentElement(`afterbegin`,this.videoElement),this.isVideoElementDetached=!1,this.videoElement.style.removeProperty(`visibility`),this.videoElement.removeAttribute(`width`),this.videoElement.removeAttribute(`height`),this.videoElement.style.removeProperty(`opacity`)))}isCanvasDrawerWithMetrics(e){return e instanceof _}onWorkerMessage(e){switch(e.type){case`draw`:this.drawEngineCommands(e.payload);break;case`performanceMetricsReport`:{let t=this._canvasDrawer;t!=null&&this.isCanvasDrawerWithMetrics(t)&&t.setPerformanceMetrics(e.payload);break}case`contextDidChangeStatus`:{var t;let n=s.fromJSON(e.payload);(t=this.loadingOverlay)==null||t.hide(),n.isValid?(this.clearError(),this.setVideoElementOpacity(`1`)):this.displayError(n);break}case`viewSizeChanged`:{let t=e.payload;if(t==null)return;this.onSDCViewSizeChangedCallback(t);break}default:var n;(n=this.hintPresenter)==null||n.handleMessage(e);break}}onSDCViewSizeChangedCallback(e){this.updateHintPresenterViewFinderRect(e.viewFinderRect)}updateHintPresenterViewFinderRect(e){var t;(t=this.hintPresenter)==null||t.setViewFinderRect(new i(new r(e.origin.x,e.origin.y),new a(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=!1}clearError(){this.errorElement.textContent=``,this.errorElement.hidden=!0}updateControls(){for(let t of this.controls){var e;(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 t=e==null?void 0:e.getCurrentState();t!=null&&await this.onCameraStateChanged(t)}else t===`singleImageUploader`&&this.setupHtmlElementSingleImageUploader(e.settings)}async onCameraStateChanged(e){var r;switch((r=this.cameraPaintboardElement)==null||r.classList.toggle(w.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){t.error(`cannot set frame source stream before connecting view to an HTML element`);return}this.videoElement&&(n.instance().gui.isCameraRecoveryVisible=this.isCameraRecoveryVisible.bind(this),n.instance().gui.setCameraRecoveryVisible=this.setCameraRecoveryVisible.bind(this),this.setVideoElementOpacity(`0`));return;case`off`:this.setVideoElementOpacity(`0`),this.updateControls();return;case`on`:await n.instance().waitForCapabilities(),this.updateControls(),this.unfreezeFrame(),this.setVideoElementOpacity(`1`);break;case`goingToSleep`:this.freezeFrame();break;default:}}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 e;let r=(e=this.videoElement)==null?void 0:e.srcObject;if(this.hiddenProperties.stopVideoTracksOnVisibilityChange&&(document.visibilityState===`hidden`&&n.instance().stopVideoTracks(),document.visibilityState===`visible`&&n.instance().activeCamera!=null&&r!=null)){var i;if(!r.active||(i=r.getVideoTracks()[0])!=null&&i.muted)try{t.debug(`Detected visibility change ("visible") event with inactive video source, try to reinitialize camera`),await n.instance().reinitializeCamera()}catch{}else t.debug(`Detected visibility change ("visible") event with active video source, replay video`),n.instance().playVideo()}}async cameraRecovery(e){e.preventDefault(),n.instance().activeCamera=n.instance().selectedCamera,await n.instance().reinitializeCamera()}freezeFrame(){var e;if(!this.frozenFrame)return;let t=n.instance().getCurrentFrame();if(!t)return;let r=new ImageData(t.data,t.width,t.height);this.frozenFrameCanvas.width=r.width,this.frozenFrameCanvas.height=r.height,this.frozenFrame.width=r.width,this.frozenFrame.height=r.height,(e=this.frozenFrameCanvas.getContext(`2d`))==null||e.putImageData(r,0,0),this.frozenFrame.src=this.frozenFrameCanvas.toDataURL(`image/jpeg`,.4),this.frozenFrame.classList.toggle(w.MIRRORED_CLASS_NAME,n.instance().isMirrorImageEnabled()),this.frozenFrame.hidden=!1}unfreezeFrame(){this.frozenFrame&&(this.frozenFrame.src=``,this.frozenFrame.hidden=!0)}onTap(e){var t;(t=this.privateContext)==null||t.workerCommand(`onTap`,{point:e.toJSONObject()})}onSwipeUp(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomIn()}onSwipeDown(){var e;(e=this.swipeToZoomGesture)==null||e.triggerZoomOut()}onPinchIn(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomIn()}onPinchOut(){var e;(e=this.pinchToZoomGesture)==null||e.triggerZoomOut()}didZoomInGesture(){this.performZoomIn()}didZoomOutGesture(){this.performZoomOut()}addSwipeToZoomListener(){let e=this._zoomGestures.find(e=>e.toJSONObject().type===`swipeToZoom`);e&&(this.swipeToZoomGesture=e,e.addListener(this))}removeSwipeToZoomListener(){var e;(e=this.swipeToZoomGesture)==null||e.removeListener(this),this.swipeToZoomGesture=null}addPinchToZoomListener(){let e=this._zoomGestures.find(e=>e.toJSONObject().type===`pinchToZoom`);e&&(this.pinchToZoomGesture=e,e.addListener(this))}removePinchToZoomListener(){var e;(e=this.pinchToZoomGesture)==null||e.removeListener(this),this.pinchToZoomGesture=null}async performZoomIn(){var e;let t=(e=this._context)==null?void 0:e.frameSource;if(!(t!=null&&t.settings))return;let n=t.settings.zoomFactor,r=[...t.settings.zoomLevels].sort((e,t)=>e-t).find(e=>e>n);r!=null&&(await t.setZoomFactor(r),this.showZoomNotification(r))}async performZoomOut(){var e;let t=(e=this._context)==null?void 0:e.frameSource;if(!(t!=null&&t.settings))return;let n=t.settings.zoomFactor,r=[...[...t.settings.zoomLevels].sort((e,t)=>e-t)].reverse().find(e=>e<n);r!=null&&(await t.setZoomFactor(r),this.showZoomNotification(r))}async showZoomNotification(e){var t,n;if(!this.shouldShowZoomNotification)return;let r=E.toJSON(),i={tag:`zoomNotification`,text:this.formatZoomFactor(e),hintStyle:{textColor:r,backgroundColor:D.neutralWhite.withAlpha(.8).toJSON(),textAlignment:`center`,hintIcon:`none`,iconColor:r,isAnimatedToView:!0,hintAnchor:`top`,hintAnchorOffset:16,horizontalMargin:16,maxWidthFraction:1,textSize:14,textWeight:700,lineHeight:24,maxLines:3,cornerRadius:4,fitToText:!0}};(t=this.zoomNotificationTimeout)==null||t.stop(),this.zoomNotificationTimeout=new d(this.zoomNotificationDuration,()=>{var e;(e=this.hintPresenter)==null||e.hideToast(i)}),await((n=this.hintPresenter)==null?void 0:n.showToast(i)),this.zoomNotificationTimeout.start()}formatZoomFactor(e){let t=Math.ceil(e*100)/100;return parseFloat(t.toPrecision(3))+`x`}};export{F as DataCaptureView};
@@ -1 +1 @@
1
- import{Logger as e}from"./logger.js";import"./CameraRelated.js";import{DataCaptureError as t}from"./DataCaptureError.js";import{a as n}from"./CameraManager-DskA2C7T.js";var r=class r{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 n=URL.createObjectURL(e),i=new Image;i.src=n;try{await i.decode()}catch{throw new t({name:`InvalidImageError`,message:`Submitted file is not an image`})}finally{URL.revokeObjectURL(n)}return r.fromImage(i)}static async fromImage(e){let n=new r;try{await e.decode()}catch{throw new t({name:`InvalidImageError`,message:`Submitted image cannot be decoded`})}let i=n.getCanvasAndContext(e.width,e.height);return i.drawImage(e,0,0),n._imageData=i.getImageData(0,0,e.width,e.height,{colorSpace:`srgb`}),n}static async fromImageData(e){let n=new r,i=n.getCanvasAndContext(e.width,e.height);try{i.putImageData(e,0,0)}catch(e){throw new t({name:`InvalidImageError`,message:`Submitted image data does not seem valid (details: ${e})`})}return n._imageData=e,n}async switchToDesiredState(t){if(t===`on`){if(this.currentState===`on`)return}else if(this.currentState===`off`)return;if(this._desiredState=t,t===`off`){await this.setCurrentState(`off`);return}return this._imageData==null?(e.log(e.Level.Warn,`No image data to process.`),this.processSubmittedImage({data:new Uint8ClampedArray,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,n){let r=document.createElement(`canvas`);r.width=e,r.height=n;let i=r.getContext(`2d`);if(i==null)throw new t({name:`ImageFrameSourceError`,message:`Could not generate a canvas context to get image data`});return i}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){var t;await this.setCurrentState(`on`);let r={data:e.data,width:e.width,height:e.height,frameId:n()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState(`off`)}};export{r as ImageFrameSource};
1
+ import{Logger as e}from"./logger.js";import"./CameraRelated.js";import{DataCaptureError as t}from"./DataCaptureError.js";import{a as n}from"./CameraManager-BTGb7HgX.js";var r=class r{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 n=URL.createObjectURL(e),i=new Image;i.src=n;try{await i.decode()}catch{throw new t({name:`InvalidImageError`,message:`Submitted file is not an image`})}finally{URL.revokeObjectURL(n)}return r.fromImage(i)}static async fromImage(e){let n=new r;try{await e.decode()}catch{throw new t({name:`InvalidImageError`,message:`Submitted image cannot be decoded`})}let i=n.getCanvasAndContext(e.width,e.height);return i.drawImage(e,0,0),n._imageData=i.getImageData(0,0,e.width,e.height,{colorSpace:`srgb`}),n}static async fromImageData(e){let n=new r,i=n.getCanvasAndContext(e.width,e.height);try{i.putImageData(e,0,0)}catch(e){throw new t({name:`InvalidImageError`,message:`Submitted image data does not seem valid (details: ${e})`})}return n._imageData=e,n}async switchToDesiredState(t){if(t===`on`){if(this.currentState===`on`)return}else if(this.currentState===`off`)return;if(this._desiredState=t,t===`off`){await this.setCurrentState(`off`);return}return this._imageData==null?(e.log(e.Level.Warn,`No image data to process.`),this.processSubmittedImage({data:new Uint8ClampedArray,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,n){let r=document.createElement(`canvas`);r.width=e,r.height=n;let i=r.getContext(`2d`);if(i==null)throw new t({name:`ImageFrameSourceError`,message:`Could not generate a canvas context to get image data`});return i}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){var t;await this.setCurrentState(`on`);let r={data:e.data,width:e.width,height:e.height,frameId:n()};await((t=this._context)==null?void 0:t.sendFrameToProcessor(r)),await this.setCurrentState(`off`)}};export{r as ImageFrameSource};
@@ -1 +1 @@
1
- import{t as e}from"./browserHelper-BQPnAZ2Y.js";import{defaultFeedback as t}from"./defaults/DefaultsFeedback.js";var n=class n{constructor(n,r=t.defaultVibrationPattern){this.type=n,this.pattern=r;let i=e.getSupportedVibrationMethod();i&&(this._vibrate=i.bind(navigator))}static get defaultVibration(){return new n(`default`)}static withPattern(e){return new n(`default`,e)}toJSONObject(){return{type:this.type}}vibrate(){var e;return(e=this._vibrate)==null?void 0:e.call(this,this.pattern)}};export{n as Vibration};
1
+ import{t as e}from"./browserHelper-DuxFlAfF.js";import{defaultFeedback as t}from"./defaults/DefaultsFeedback.js";var n=class n{constructor(n,r=t.defaultVibrationPattern){this.type=n,this.pattern=r;let i=e.getSupportedVibrationMethod();i&&(this._vibrate=i.bind(navigator))}static get defaultVibration(){return new n(`default`)}static withPattern(e){return new n(`default`,e)}toJSONObject(){return{type:this.type}}vibrate(){var e;return(e=this._vibrate)==null?void 0:e.call(this,this.pattern)}};export{n as Vibration};
@@ -218,6 +218,7 @@ declare namespace BrowserHelper {
218
218
  */
219
219
  export function isPwaDisplayMode(displayMode: DisplayMode): boolean;
220
220
  export function isFixedMemoryRequired(): boolean;
221
+ export function isSIMDBroken(): boolean;
221
222
  export {};
222
223
  }
223
224
  //#endregion
@@ -1 +1 @@
1
- import{getCookieStore as e}from"./private/utils/cookieStore.js";import{SafeStorage as t}from"./private/utils/safeStorage.js";import"./browserCompatibility.js";import{a as n,i as r,n as i,o as a,r as o}from"./multithreadSimdHelper-BrYdWJgw.js";var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},h=((e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(p(((e,t)=>{(function(n,r){var i=`1.0.40`,a=``,o=`?`,s=`function`,c=`undefined`,l=`object`,u=`string`,d=`major`,f=`model`,p=`name`,m=`type`,h=`vendor`,g=`version`,_=`architecture`,v=`console`,y=`mobile`,b=`tablet`,x=`smarttv`,S=`wearable`,C=`embedded`,w=500,T=`Amazon`,E=`Apple`,D=`ASUS`,O=`BlackBerry`,k=`Browser`,A=`Chrome`,ee=`Edge`,j=`Firefox`,M=`Google`,N=`Huawei`,P=`LG`,F=`Microsoft`,I=`Motorola`,L=`Opera`,R=`Samsung`,z=`Sharp`,B=`Sony`,V=`Xiaomi`,H=`Zebra`,U=`Facebook`,W=`Chromium OS`,G=`Mac OS`,te=` Browser`,ne=function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},K=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},re=function(e,t){return typeof e===u?q(t).indexOf(q(e))!==-1:!1},q=function(e){return e.toLowerCase()},ie=function(e){return typeof e===u?e.replace(/[^\d\.]/g,a).split(`.`)[0]:r},J=function(e,t){if(typeof e===u)return e=e.replace(/^\s\s*/,a),typeof t===c?e:e.substring(0,w)},Y=function(e,t){for(var n=0,i,a,o,c,u,d;n<t.length&&!u;){var f=t[n],p=t[n+1];for(i=a=0;i<f.length&&!u&&f[i];)if(u=f[i++].exec(e),u)for(o=0;o<p.length;o++)d=u[++a],c=p[o],typeof c===l&&c.length>0?c.length===2?typeof c[1]==s?this[c[0]]=c[1].call(this,d):this[c[0]]=c[1]:c.length===3?typeof c[1]===s&&!(c[1].exec&&c[1].test)?this[c[0]]=d?c[1].call(this,d,c[2]):r:this[c[0]]=d?d.replace(c[1],c[2]):r:c.length===4&&(this[c[0]]=d?c[3].call(this,d.replace(c[1],c[2])):r):this[c]=d||r;n+=2}},X=function(e,t){for(var n in t)if(typeof t[n]===l&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(re(t[n][i],e))return n===o?r:n}else if(re(t[n],e))return n===o?r:n;return t.hasOwnProperty(`*`)?t[`*`]:e},ae={"1.0":`/8`,"1.2":`/1`,"1.3":`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},oe={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,"8.1":`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},se={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[g,[p,`Chrome`]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[g,[p,`Edge`]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[p,g],[/opios[\/ ]+([\w\.]+)/i],[g,[p,L+` Mini`]],[/\bop(?:rg)?x\/([\w\.]+)/i],[g,[p,L+` GX`]],[/\bopr\/([\w\.]+)/i],[g,[p,L]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[g,[p,`Baidu`]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[g,[p,`Maxthon`]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[p,g],[/quark(?:pc)?\/([-\w\.]+)/i],[g,[p,`Quark`]],[/\bddg\/([\w\.]+)/i],[g,[p,`DuckDuckGo`]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[g,[p,`UC`+k]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[g,[p,`WeChat`]],[/konqueror\/([\w\.]+)/i],[g,[p,`Konqueror`]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[g,[p,`IE`]],[/ya(?:search)?browser\/([\w\.]+)/i],[g,[p,`Yandex`]],[/slbrowser\/([\w\.]+)/i],[g,[p,`Smart Lenovo `+k]],[/(avast|avg)\/([\w\.]+)/i],[[p,/(.+)/,`$1 Secure `+k],g],[/\bfocus\/([\w\.]+)/i],[g,[p,j+` Focus`]],[/\bopt\/([\w\.]+)/i],[g,[p,L+` Touch`]],[/coc_coc\w+\/([\w\.]+)/i],[g,[p,`Coc Coc`]],[/dolfin\/([\w\.]+)/i],[g,[p,`Dolphin`]],[/coast\/([\w\.]+)/i],[g,[p,L+` Coast`]],[/miuibrowser\/([\w\.]+)/i],[g,[p,`MIUI`+te]],[/fxios\/([\w\.-]+)/i],[g,[p,j]],[/\bqihoobrowser\/?([\w\.]*)/i],[g,[p,`360`]],[/\b(qq)\/([\w\.]+)/i],[[p,/(.+)/,`$1Browser`],g],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[p,/(.+)/,`$1`+te],g],[/samsungbrowser\/([\w\.]+)/i],[g,[p,R+` Internet`]],[/metasr[\/ ]?([\d\.]+)/i],[g,[p,`Sogou Explorer`]],[/(sogou)mo\w+\/([\d\.]+)/i],[[p,`Sogou Mobile`],g],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[p,g],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[p],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[g,p],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[p,U],g],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[p,g],[/\bgsa\/([\w\.]+) .*safari\//i],[g,[p,`GSA`]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[g,[p,`TikTok`]],[/headlesschrome(?:\/([\w\.]+)| )/i],[g,[p,A+` Headless`]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[p,A+` WebView`],g],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[g,[p,`Android `+k]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[p,g],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[g,[p,`Mobile Safari`]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[g,p],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[p,[g,X,ae]],[/(webkit|khtml)\/([\w\.]+)/i],[p,g],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[p,`Netscape`],g],[/(wolvic|librewolf)\/([\w\.]+)/i],[p,g],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[g,[p,j+` Reality`]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[p,[g,/_/g,`.`]],[/(cobalt)\/([\w\.]+)/i],[p,[g,/master.|lts./,``]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[_,`amd64`]],[/(ia32(?=;))/i],[[_,q]],[/((?:i[346]|x)86)[;\)]/i],[[_,`ia32`]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[_,`arm64`]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[_,`armhf`]],[/windows (ce|mobile); ppc;/i],[[_,`arm`]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[_,/ower/,a,q]],[/(sun4\w)[;\)]/i],[[_,`sparc`]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[_,q]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[f,[h,R],[m,b]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[f,[h,R],[m,y]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[f,[h,E],[m,y]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[f,[h,E],[m,b]],[/(macintosh);/i],[f,[h,E]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[f,[h,z],[m,y]],[/(?:honor)([-\w ]+)[;\)]/i],[f,[h,`Honor`],[m,y]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[f,[h,N],[m,b]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[f,[h,N],[m,y]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[f,/_/g,` `],[h,V],[m,y]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[f,/_/g,` `],[h,V],[m,b]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[f,[h,`OPPO`],[m,y]],[/\b(opd2\d{3}a?) bui/i],[f,[h,`OPPO`],[m,b]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[f,[h,`Vivo`],[m,y]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[f,[h,`Realme`],[m,y]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[f,[h,I],[m,y]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[f,[h,I],[m,b]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[f,[h,P],[m,b]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[f,[h,P],[m,y]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[f,[h,`Lenovo`],[m,b]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[f,/_/g,` `],[h,`Nokia`],[m,y]],[/(pixel c)\b/i],[f,[h,M],[m,b]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[f,[h,M],[m,y]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[f,[h,B],[m,y]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[f,`Xperia Tablet`],[h,B],[m,b]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[f,[h,`OnePlus`],[m,y]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[f,[h,T],[m,b]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[f,/(.+)/g,`Fire Phone $1`],[h,T],[m,y]],[/(playbook);[-\w\),; ]+(rim)/i],[f,h,[m,b]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[f,[h,O],[m,y]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[f,[h,D],[m,b]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[f,[h,D],[m,y]],[/(nexus 9)/i],[f,[h,`HTC`],[m,b]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[f,/_/g,` `],[m,y]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[f,[h,`TCL`],[m,b]],[/(itel) ((\w+))/i],[[h,q],f,[m,X,{tablet:[`p10001l`,`w7001`],"*":`mobile`}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[f,[h,`Acer`],[m,b]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[f,[h,`Meizu`],[m,y]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[f,[h,`Ulefone`],[m,y]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[f,[h,`Energizer`],[m,y]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[f,[h,`Cat`],[m,y]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[f,[h,`Smartfren`],[m,y]],[/droid.+; (a(?:015|06[35]|142p?))/i],[f,[h,`Nothing`],[m,y]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,f,[m,y]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,f,[m,b]],[/(surface duo)/i],[f,[h,F],[m,b]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[f,[h,`Fairphone`],[m,y]],[/(u304aa)/i],[f,[h,`AT&T`],[m,y]],[/\bsie-(\w*)/i],[f,[h,`Siemens`],[m,y]],[/\b(rct\w+) b/i],[f,[h,`RCA`],[m,b]],[/\b(venue[\d ]{2,7}) b/i],[f,[h,`Dell`],[m,b]],[/\b(q(?:mv|ta)\w+) b/i],[f,[h,`Verizon`],[m,b]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[f,[h,`Barnes & Noble`],[m,b]],[/\b(tm\d{3}\w+) b/i],[f,[h,`NuVision`],[m,b]],[/\b(k88) b/i],[f,[h,`ZTE`],[m,b]],[/\b(nx\d{3}j) b/i],[f,[h,`ZTE`],[m,y]],[/\b(gen\d{3}) b.+49h/i],[f,[h,`Swiss`],[m,y]],[/\b(zur\d{3}) b/i],[f,[h,`Swiss`],[m,b]],[/\b((zeki)?tb.*\b) b/i],[f,[h,`Zeki`],[m,b]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,`Dragon Touch`],f,[m,b]],[/\b(ns-?\w{0,9}) b/i],[f,[h,`Insignia`],[m,b]],[/\b((nxa|next)-?\w{0,9}) b/i],[f,[h,`NextBook`],[m,b]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,`Voice`],f,[m,y]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,`LvTel`],f,[m,y]],[/\b(ph-1) /i],[f,[h,`Essential`],[m,y]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[f,[h,`Envizen`],[m,b]],[/\b(trio[-\w\. ]+) b/i],[f,[h,`MachSpeed`],[m,b]],[/\btu_(1491) b/i],[f,[h,`Rotor`],[m,b]],[/(shield[\w ]+) b/i],[f,[h,`Nvidia`],[m,b]],[/(sprint) (\w+)/i],[h,f,[m,y]],[/(kin\.[onetw]{3})/i],[[f,/\./g,` `],[h,F],[m,y]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[f,[h,H],[m,b]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[f,[h,H],[m,y]],[/smart-tv.+(samsung)/i],[h,[m,x]],[/hbbtv.+maple;(\d+)/i],[[f,/^/,`SmartTV`],[h,R],[m,x]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[m,x]],[/(apple) ?tv/i],[h,[f,E+` TV`],[m,x]],[/crkey/i],[[f,A+`cast`],[h,M],[m,x]],[/droid.+aft(\w+)( bui|\))/i],[f,[h,T],[m,x]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[f,[h,z],[m,x]],[/(bravia[\w ]+)( bui|\))/i],[f,[h,B],[m,x]],[/(mitv-\w{5}) bui/i],[f,[h,V],[m,x]],[/Hbbtv.*(technisat) (.*);/i],[h,f,[m,x]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,J],[f,J],[m,x]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[m,x]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,f,[m,v]],[/droid.+; (shield) bui/i],[f,[h,`Nvidia`],[m,v]],[/(playstation [345portablevi]+)/i],[f,[h,B],[m,v]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[f,[h,F],[m,v]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[f,[h,R],[m,S]],[/((pebble))app/i],[h,f,[m,S]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[f,[h,E],[m,S]],[/droid.+; (glass) \d/i],[f,[h,M],[m,S]],[/droid.+; (wt63?0{2,3})\)/i],[f,[h,H],[m,S]],[/droid.+; (glass) \d/i],[f,[h,M],[m,S]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,f,[m,S]],[/; (quest( \d| pro)?)/i],[f,[h,U],[m,S]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[m,C]],[/(aeobc)\b/i],[f,[h,T],[m,C]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[f,[m,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[f,[m,b]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[m,b]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[m,y]],[/(android[-\w\. ]{0,9});.+buil/i],[f,[h,`Generic`]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[g,[p,ee+`HTML`]],[/(arkweb)\/([\w\.]+)/i],[p,g],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[g,[p,`Blink`]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[p,g],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[g,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,g],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[p,[g,X,oe]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[g,X,oe],[p,`Windows`]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[g,/_/g,`.`],[p,`iOS`]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[p,G],[g,/_/g,`.`]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[g,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[p,g],[/\(bb(10);/i],[g,[p,O]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[g,[p,`Symbian`]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[g,[p,j+` OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[g,[p,`webOS`]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[g,[p,`watchOS`]],[/crkey\/([\d\.]+)/i],[g,[p,A+`cast`]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[p,W],g],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[p,g],[/(sunos) ?([\w\.\d]*)/i],[[p,`Solaris`],g],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[p,g]]},Z=function(e,t){if(typeof e===l&&(t=e,e=r),!(this instanceof Z))return new Z(e,t).getResult();var i=typeof n!==c&&n.navigator?n.navigator:r,o=e||(i&&i.userAgent?i.userAgent:a),v=i&&i.userAgentData?i.userAgentData:r,x=t?ne(se,t):se,S=i&&i.userAgent==o;return this.getBrowser=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.browser),e[d]=ie(e[g]),S&&i&&i.brave&&typeof i.brave.isBrave==s&&(e[p]=`Brave`),e},this.getCPU=function(){var e={};return e[_]=r,Y.call(e,o,x.cpu),e},this.getDevice=function(){var e={};return e[h]=r,e[f]=r,e[m]=r,Y.call(e,o,x.device),S&&!e[m]&&v&&v.mobile&&(e[m]=y),S&&e[f]==`Macintosh`&&i&&typeof i.standalone!==c&&i.maxTouchPoints&&i.maxTouchPoints>2&&(e[f]=`iPad`,e[m]=b),e},this.getEngine=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.engine),e},this.getOS=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.os),S&&!e[p]&&v&&v.platform&&v.platform!=`Unknown`&&(e[p]=v.platform.replace(/chrome os/i,W).replace(/macos/i,G)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return o},this.setUA=function(e){return o=typeof e===u&&e.length>w?J(e,w):e,this},this.setUA(o),this};Z.VERSION=i,Z.BROWSER=K([p,g,d]),Z.CPU=K([_]),Z.DEVICE=K([f,h,m,v,y,x,b,S,C]),Z.ENGINE=Z.OS=K([p,g]),typeof e===c?typeof define===s&&define.amd?define(function(){return Z}):typeof n!==c&&(n.UAParser=Z):(typeof t!==c&&t.exports&&(e=t.exports=Z),e.UAParser=Z);var Q=typeof n!==c&&(n.jQuery||n.Zepto);if(Q&&!Q.ua){var $=new Z;Q.ua=$.getResult(),Q.ua.get=function(){return $.getUA()},Q.ua.set=function(e){$.setUA(e);var t=$.getResult();for(var n in t)Q.ua[n]=t[n]}}})(typeof window==`object`?window:e)}))(),1);let g=function(e){return e.Standalone=`standalone`,e.Fullscreen=`fullscreen`,e.MinimalUI=`minimal-ui`,e.Browser=`browser`,e}({}),_;(function(s){let c;function l(){return c??=new h.default(navigator.userAgent),c}s.getUserAgentInfo=l;function u(){var e,t;if(`orientation`in window)return!1;let n=`(any-pointer: coarse)`,r=(e=(t=window).matchMedia)==null?void 0:e.call(t,n);return navigator.maxTouchPoints===0||(r==null?void 0:r.media)===n&&!(r!=null&&r.matches)}s.isDesktopDevice=u;function d(){return l().getDevice().model===`iPhone`}s.isIPhone=d;function f(){var e,t;let n=l(),r=((e=n.getOS().name)==null?void 0:e.toLowerCase())??``,i=n.getDevice(),a=((t=i.model)==null?void 0:t.toLowerCase())??``,o=i.type;return r.includes(`ios`)&&(o===`tablet`||a.includes(`ipad`))}s.isIPad=f;function p(){var e,t;let n=((e=l().getOS().name)==null?void 0:e.toLowerCase())??``,r=l().getDevice(),i=r.type,a=((t=r.model)==null?void 0:t.toLowerCase())??``;return n.includes(`mac`)&&(i===`laptop`||a.includes(`macintosh`))}s.isMacBook=p;function m(){return d()||f()||p()}s.isAppleDevice=m;function g(){let e=l().getOS();return e.name===`iOS`&&e.version!=null&&e.version.localeCompare(`16.3`,void 0,{numeric:!0})>=0}s.isIOSDeviceWithExtendedCameraAccess=g;function v(){return`document`in window?window.document.createElement(`canvas`):null}s.getCanvas=v;function y(e){return e.name===`iOS`&&e.version!=null&&[`11.2.2`,`11.2.5`,`11.2.6`].includes(e.version)}async function b(){return o()}s.hasSIMDSupport=b;async function x(){return n()}s.hasThreadsSupport=x;function S(e,t,n){let r=e[t[0]];return r==null?!1:t.length===1?typeof r===n:(typeof r==`function`||typeof r==`object`)&&S(r,t.slice(1),n)}function C(){let e=!0,t=null,n=null,r=null,i=null;try{if(t=_.getCanvas(),n=_.getCanvas(),r=t==null?void 0:t.getContext(`webgl`),i=n==null?void 0:n.getContext(`experimental-webgl`),!S(window,[`WebGLRenderingContext`],`function`)||r==null&&i==null)throw Error(`WebGLRenderingContext is not supported`)}catch{e=!1}finally{for(let e of[r,i])if(typeof(e==null?void 0:e.getExtension)==`function`){var a;(a=e.getExtension(`WEBGL_lose_context`))==null||a.loseContext()}r=null,i=null,t=null,n=null}return e}function w(){let e=!0,t=!0,n=new Set;return location.protocol.startsWith(`http`)||n.add(`httpProtocol`),S(window,[`isSecureContext`],`boolean`)&&!window.isSecureContext&&n.add(`secureContext`),!S(navigator,[`mediaDevices`,`getUserMedia`],`function`)&&!S(navigator,[`enumerateDevices`],`function`)&&!S(window,[`MediaStreamTrack`,`getSources`],`function`)&&(n.add(`mediaDevices`),e=!1),S(window,[`Worker`],`function`)||(n.add(`webWorkers`),e=!1,t=!1),S(window,[`WebAssembly`],`object`)||(n.add(`webAssembly`),e=!1,t=!1),S(window,[`Blob`],`function`)||(n.add(`blob`),e=!1,t=!1),S(window,[`URL`,`createObjectURL`],`function`)||(n.add(`urlObject`),e=!1,t=!1),S(window,[`OffscreenCanvas`],`function`)||n.add(`offscreenCanvas`),C()||n.add(`webGL`),y(l().getOS())&&(n.add(`webAssemblyErrorFree`),e=!1,t=!1),r()||n.add(`sharedArrayBuffer`),a()||n.add(`crossOriginIsolated`),R()||n.add(`animationApi`),{fullSupport:e,scannerSupport:t,missingFeatures:[...n]}}s.checkBrowserCompatibility=w;async function T(){return i()}s.checkMultithreadingSupport=T;async function E(){let n=`scandit-device-id`,r=t.getInstanceFor(`localStorage`),i=r.getItem(n);if(i!=null&&i!==``)return i;let a=await e().get(n);if(i=a==null?void 0:a.value,i!=null&&i!==``)return r.setItem(n,i),i;let o=new Uint8Array(20);return crypto.getRandomValues(o),i=[...o].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``),r.setItem(n,i),i}s.getDeviceId=E;function D(e){return e instanceof HTMLElement||typeof e==`object`&&!!e&&typeof e.tagName==`string`}s.isValidHTMLElement=D;function O(){var e;let t=l().getOS();if(t.name!==`iOS`)return!0;let[n,r]=((e=t.version)==null?void 0:e.split(`.`).map(Number))??[];return n>14||n===14&&r>=6}s.isSupportedIOSVersion=O;function k(){var e;return((e=l().getBrowser().name)==null?void 0:e.toLowerCase().includes(`safari`))??!1}s.isSafari=k;function A(){var e;return/iphone|ipod|ipad/.test(((e=l().getDevice().model)==null?void 0:e.toLowerCase())??``)&&!k()}s.isIosWebView=A;function ee(){var e;return((e=l().getOS().name)==null?void 0:e.toLowerCase())===`android`}s.isAndroid=ee;function j(){return u()||d()?!1:l().getDevice().type===`tablet`}s.isTablet=j;async function M(){var e;return((e=l().getOS().name)==null?void 0:e.toLowerCase())===`android`?l().getUA().includes(`wv`)?!0:[...(await fetch(document.location.toString(),{method:`HEAD`})).headers].some(([e])=>e.toLowerCase()===`x-requested-with`):!1}s.isAndroidWebView=M;function N(){return l().getOS().name===`Windows`}s.isWindows=N;function P(){return l().getBrowser().name===`Firefox`}s.isFirefox=P;function F(){if(`navigator`in globalThis){for(let e of[`vibrate`,`webkitVibrate`,`msVibrate`,`mozVibrate`])if(typeof navigator[e]==`function`)return navigator[e]}}s.getSupportedVibrationMethod=F;function I(){return F()!=null&&!u()&&!N()&&!P()}s.isVibrationAvailable=I;function L(){return l().getOS().name===`iOS`}s.isIOS=L;function R(){return globalThis.Animation!==void 0&&globalThis.KeyframeEffect!==void 0&&globalThis.Element.prototype.animate!==void 0}s.isAnimationApiSupported=R;function z(){return`virtualKeyboard`in navigator}s.hasVirtualKeyboardSupport=z;function B(e){var t,n;let r=`(display-mode: ${e})`,i=(t=(n=globalThis).matchMedia)==null?void 0:t.call(n,r);return(i==null?void 0:i.matches)===!0?!0:e===`standalone`&&typeof navigator==`object`&&`standalone`in navigator&&typeof navigator.standalone==`boolean`?navigator.standalone===!0:!1}s.isPwaDisplayMode=B;function V(e,t,n){let r=e=>e.split(`.`).map(e=>Number.parseInt(e,10)||0),i=r(e),a=r(t),o=r(n),s=(e,t)=>{let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]??0,i=t[r]??0;if(n>i)return 1;if(n<i)return-1}return 0},c=s(i,a)>=0,l=s(i,o)<0;return c&&l}function H(){if(m()){let e=l(),t=e.getOS(),n=e.getBrowser(),r=k()?n.version:t.version;return r?V(r,`26`,`26.3`):!1}return!1}s.isFixedMemoryRequired=H})(_||={});export{g as n,_ as t};
1
+ import{getCookieStore as e}from"./private/utils/cookieStore.js";import{SafeStorage as t}from"./private/utils/safeStorage.js";import"./browserCompatibility.js";import{a as n,i as r,n as i,o as a,r as o}from"./multithreadSimdHelper-BrYdWJgw.js";var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},h=((e,t,n)=>(n=e==null?{}:s(d(e)),m(t||!e||!e.__esModule?c(n,`default`,{value:e,enumerable:!0}):n,e)))(p(((e,t)=>{(function(n,r){var i=`1.0.40`,a=``,o=`?`,s=`function`,c=`undefined`,l=`object`,u=`string`,d=`major`,f=`model`,p=`name`,m=`type`,h=`vendor`,g=`version`,_=`architecture`,v=`console`,y=`mobile`,b=`tablet`,x=`smarttv`,S=`wearable`,C=`embedded`,w=500,T=`Amazon`,E=`Apple`,D=`ASUS`,O=`BlackBerry`,k=`Browser`,A=`Chrome`,ee=`Edge`,j=`Firefox`,M=`Google`,N=`Huawei`,P=`LG`,F=`Microsoft`,I=`Motorola`,L=`Opera`,R=`Samsung`,z=`Sharp`,B=`Sony`,V=`Xiaomi`,H=`Zebra`,U=`Facebook`,W=`Chromium OS`,G=`Mac OS`,te=` Browser`,ne=function(e,t){var n={};for(var r in e)t[r]&&t[r].length%2==0?n[r]=t[r].concat(e[r]):n[r]=e[r];return n},K=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},re=function(e,t){return typeof e===u?q(t).indexOf(q(e))!==-1:!1},q=function(e){return e.toLowerCase()},ie=function(e){return typeof e===u?e.replace(/[^\d\.]/g,a).split(`.`)[0]:r},J=function(e,t){if(typeof e===u)return e=e.replace(/^\s\s*/,a),typeof t===c?e:e.substring(0,w)},Y=function(e,t){for(var n=0,i,a,o,c,u,d;n<t.length&&!u;){var f=t[n],p=t[n+1];for(i=a=0;i<f.length&&!u&&f[i];)if(u=f[i++].exec(e),u)for(o=0;o<p.length;o++)d=u[++a],c=p[o],typeof c===l&&c.length>0?c.length===2?typeof c[1]==s?this[c[0]]=c[1].call(this,d):this[c[0]]=c[1]:c.length===3?typeof c[1]===s&&!(c[1].exec&&c[1].test)?this[c[0]]=d?c[1].call(this,d,c[2]):r:this[c[0]]=d?d.replace(c[1],c[2]):r:c.length===4&&(this[c[0]]=d?c[3].call(this,d.replace(c[1],c[2])):r):this[c]=d||r;n+=2}},X=function(e,t){for(var n in t)if(typeof t[n]===l&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(re(t[n][i],e))return n===o?r:n}else if(re(t[n],e))return n===o?r:n;return t.hasOwnProperty(`*`)?t[`*`]:e},ae={"1.0":`/8`,"1.2":`/1`,"1.3":`/3`,"2.0":`/412`,"2.0.2":`/416`,"2.0.3":`/417`,"2.0.4":`/419`,"?":`/`},oe={ME:`4.90`,"NT 3.11":`NT3.51`,"NT 4.0":`NT4.0`,2e3:`NT 5.0`,XP:[`NT 5.1`,`NT 5.2`],Vista:`NT 6.0`,7:`NT 6.1`,8:`NT 6.2`,"8.1":`NT 6.3`,10:[`NT 6.4`,`NT 10.0`],RT:`ARM`},se={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[g,[p,`Chrome`]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[g,[p,`Edge`]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[p,g],[/opios[\/ ]+([\w\.]+)/i],[g,[p,L+` Mini`]],[/\bop(?:rg)?x\/([\w\.]+)/i],[g,[p,L+` GX`]],[/\bopr\/([\w\.]+)/i],[g,[p,L]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[g,[p,`Baidu`]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[g,[p,`Maxthon`]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[p,g],[/quark(?:pc)?\/([-\w\.]+)/i],[g,[p,`Quark`]],[/\bddg\/([\w\.]+)/i],[g,[p,`DuckDuckGo`]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[g,[p,`UC`+k]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[g,[p,`WeChat`]],[/konqueror\/([\w\.]+)/i],[g,[p,`Konqueror`]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[g,[p,`IE`]],[/ya(?:search)?browser\/([\w\.]+)/i],[g,[p,`Yandex`]],[/slbrowser\/([\w\.]+)/i],[g,[p,`Smart Lenovo `+k]],[/(avast|avg)\/([\w\.]+)/i],[[p,/(.+)/,`$1 Secure `+k],g],[/\bfocus\/([\w\.]+)/i],[g,[p,j+` Focus`]],[/\bopt\/([\w\.]+)/i],[g,[p,L+` Touch`]],[/coc_coc\w+\/([\w\.]+)/i],[g,[p,`Coc Coc`]],[/dolfin\/([\w\.]+)/i],[g,[p,`Dolphin`]],[/coast\/([\w\.]+)/i],[g,[p,L+` Coast`]],[/miuibrowser\/([\w\.]+)/i],[g,[p,`MIUI`+te]],[/fxios\/([\w\.-]+)/i],[g,[p,j]],[/\bqihoobrowser\/?([\w\.]*)/i],[g,[p,`360`]],[/\b(qq)\/([\w\.]+)/i],[[p,/(.+)/,`$1Browser`],g],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[p,/(.+)/,`$1`+te],g],[/samsungbrowser\/([\w\.]+)/i],[g,[p,R+` Internet`]],[/metasr[\/ ]?([\d\.]+)/i],[g,[p,`Sogou Explorer`]],[/(sogou)mo\w+\/([\d\.]+)/i],[[p,`Sogou Mobile`],g],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[p,g],[/(lbbrowser|rekonq)/i,/\[(linkedin)app\]/i],[p],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[g,p],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[p,U],g],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[p,g],[/\bgsa\/([\w\.]+) .*safari\//i],[g,[p,`GSA`]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[g,[p,`TikTok`]],[/headlesschrome(?:\/([\w\.]+)| )/i],[g,[p,A+` Headless`]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[p,A+` WebView`],g],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[g,[p,`Android `+k]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[p,g],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[g,[p,`Mobile Safari`]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[g,p],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[p,[g,X,ae]],[/(webkit|khtml)\/([\w\.]+)/i],[p,g],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[p,`Netscape`],g],[/(wolvic|librewolf)\/([\w\.]+)/i],[p,g],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[g,[p,j+` Reality`]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[p,[g,/_/g,`.`]],[/(cobalt)\/([\w\.]+)/i],[p,[g,/master.|lts./,``]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[_,`amd64`]],[/(ia32(?=;))/i],[[_,q]],[/((?:i[346]|x)86)[;\)]/i],[[_,`ia32`]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[_,`arm64`]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[_,`armhf`]],[/windows (ce|mobile); ppc;/i],[[_,`arm`]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[_,/ower/,a,q]],[/(sun4\w)[;\)]/i],[[_,`sparc`]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[_,q]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[f,[h,R],[m,b]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[f,[h,R],[m,y]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[f,[h,E],[m,y]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[f,[h,E],[m,b]],[/(macintosh);/i],[f,[h,E]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[f,[h,z],[m,y]],[/(?:honor)([-\w ]+)[;\)]/i],[f,[h,`Honor`],[m,y]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[f,[h,N],[m,b]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[f,[h,N],[m,y]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[f,/_/g,` `],[h,V],[m,y]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[f,/_/g,` `],[h,V],[m,b]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[f,[h,`OPPO`],[m,y]],[/\b(opd2\d{3}a?) bui/i],[f,[h,`OPPO`],[m,b]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[f,[h,`Vivo`],[m,y]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[f,[h,`Realme`],[m,y]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[f,[h,I],[m,y]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[f,[h,I],[m,b]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[f,[h,P],[m,b]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[f,[h,P],[m,y]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[f,[h,`Lenovo`],[m,b]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[f,/_/g,` `],[h,`Nokia`],[m,y]],[/(pixel c)\b/i],[f,[h,M],[m,b]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[f,[h,M],[m,y]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[f,[h,B],[m,y]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[f,`Xperia Tablet`],[h,B],[m,b]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[f,[h,`OnePlus`],[m,y]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[f,[h,T],[m,b]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[f,/(.+)/g,`Fire Phone $1`],[h,T],[m,y]],[/(playbook);[-\w\),; ]+(rim)/i],[f,h,[m,b]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[f,[h,O],[m,y]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[f,[h,D],[m,b]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[f,[h,D],[m,y]],[/(nexus 9)/i],[f,[h,`HTC`],[m,b]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[f,/_/g,` `],[m,y]],[/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])\w*(\)| bui)/i],[f,[h,`TCL`],[m,b]],[/(itel) ((\w+))/i],[[h,q],f,[m,X,{tablet:[`p10001l`,`w7001`],"*":`mobile`}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[f,[h,`Acer`],[m,b]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[f,[h,`Meizu`],[m,y]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[f,[h,`Ulefone`],[m,y]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[f,[h,`Energizer`],[m,y]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[f,[h,`Cat`],[m,y]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[f,[h,`Smartfren`],[m,y]],[/droid.+; (a(?:015|06[35]|142p?))/i],[f,[h,`Nothing`],[m,y]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,f,[m,y]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,f,[m,b]],[/(surface duo)/i],[f,[h,F],[m,b]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[f,[h,`Fairphone`],[m,y]],[/(u304aa)/i],[f,[h,`AT&T`],[m,y]],[/\bsie-(\w*)/i],[f,[h,`Siemens`],[m,y]],[/\b(rct\w+) b/i],[f,[h,`RCA`],[m,b]],[/\b(venue[\d ]{2,7}) b/i],[f,[h,`Dell`],[m,b]],[/\b(q(?:mv|ta)\w+) b/i],[f,[h,`Verizon`],[m,b]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[f,[h,`Barnes & Noble`],[m,b]],[/\b(tm\d{3}\w+) b/i],[f,[h,`NuVision`],[m,b]],[/\b(k88) b/i],[f,[h,`ZTE`],[m,b]],[/\b(nx\d{3}j) b/i],[f,[h,`ZTE`],[m,y]],[/\b(gen\d{3}) b.+49h/i],[f,[h,`Swiss`],[m,y]],[/\b(zur\d{3}) b/i],[f,[h,`Swiss`],[m,b]],[/\b((zeki)?tb.*\b) b/i],[f,[h,`Zeki`],[m,b]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,`Dragon Touch`],f,[m,b]],[/\b(ns-?\w{0,9}) b/i],[f,[h,`Insignia`],[m,b]],[/\b((nxa|next)-?\w{0,9}) b/i],[f,[h,`NextBook`],[m,b]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,`Voice`],f,[m,y]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,`LvTel`],f,[m,y]],[/\b(ph-1) /i],[f,[h,`Essential`],[m,y]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[f,[h,`Envizen`],[m,b]],[/\b(trio[-\w\. ]+) b/i],[f,[h,`MachSpeed`],[m,b]],[/\btu_(1491) b/i],[f,[h,`Rotor`],[m,b]],[/(shield[\w ]+) b/i],[f,[h,`Nvidia`],[m,b]],[/(sprint) (\w+)/i],[h,f,[m,y]],[/(kin\.[onetw]{3})/i],[[f,/\./g,` `],[h,F],[m,y]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[f,[h,H],[m,b]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[f,[h,H],[m,y]],[/smart-tv.+(samsung)/i],[h,[m,x]],[/hbbtv.+maple;(\d+)/i],[[f,/^/,`SmartTV`],[h,R],[m,x]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,P],[m,x]],[/(apple) ?tv/i],[h,[f,E+` TV`],[m,x]],[/crkey/i],[[f,A+`cast`],[h,M],[m,x]],[/droid.+aft(\w+)( bui|\))/i],[f,[h,T],[m,x]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[f,[h,z],[m,x]],[/(bravia[\w ]+)( bui|\))/i],[f,[h,B],[m,x]],[/(mitv-\w{5}) bui/i],[f,[h,V],[m,x]],[/Hbbtv.*(technisat) (.*);/i],[h,f,[m,x]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,J],[f,J],[m,x]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[m,x]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,f,[m,v]],[/droid.+; (shield) bui/i],[f,[h,`Nvidia`],[m,v]],[/(playstation [345portablevi]+)/i],[f,[h,B],[m,v]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[f,[h,F],[m,v]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[f,[h,R],[m,S]],[/((pebble))app/i],[h,f,[m,S]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[f,[h,E],[m,S]],[/droid.+; (glass) \d/i],[f,[h,M],[m,S]],[/droid.+; (wt63?0{2,3})\)/i],[f,[h,H],[m,S]],[/droid.+; (glass) \d/i],[f,[h,M],[m,S]],[/(pico) (4|neo3(?: link|pro)?)/i],[h,f,[m,S]],[/; (quest( \d| pro)?)/i],[f,[h,U],[m,S]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[m,C]],[/(aeobc)\b/i],[f,[h,T],[m,C]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[f,[m,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[f,[m,b]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[m,b]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[m,y]],[/(android[-\w\. ]{0,9});.+buil/i],[f,[h,`Generic`]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[g,[p,ee+`HTML`]],[/(arkweb)\/([\w\.]+)/i],[p,g],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[g,[p,`Blink`]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[p,g],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[g,p]],os:[[/microsoft (windows) (vista|xp)/i],[p,g],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[p,[g,X,oe]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[g,X,oe],[p,`Windows`]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[g,/_/g,`.`],[p,`iOS`]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[p,G],[g,/_/g,`.`]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[g,p],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[p,g],[/\(bb(10);/i],[g,[p,O]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[g,[p,`Symbian`]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[g,[p,j+` OS`]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[g,[p,`webOS`]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[g,[p,`watchOS`]],[/crkey\/([\d\.]+)/i],[g,[p,A+`cast`]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[p,W],g],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[p,g],[/(sunos) ?([\w\.\d]*)/i],[[p,`Solaris`],g],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[p,g]]},Z=function(e,t){if(typeof e===l&&(t=e,e=r),!(this instanceof Z))return new Z(e,t).getResult();var i=typeof n!==c&&n.navigator?n.navigator:r,o=e||(i&&i.userAgent?i.userAgent:a),v=i&&i.userAgentData?i.userAgentData:r,x=t?ne(se,t):se,S=i&&i.userAgent==o;return this.getBrowser=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.browser),e[d]=ie(e[g]),S&&i&&i.brave&&typeof i.brave.isBrave==s&&(e[p]=`Brave`),e},this.getCPU=function(){var e={};return e[_]=r,Y.call(e,o,x.cpu),e},this.getDevice=function(){var e={};return e[h]=r,e[f]=r,e[m]=r,Y.call(e,o,x.device),S&&!e[m]&&v&&v.mobile&&(e[m]=y),S&&e[f]==`Macintosh`&&i&&typeof i.standalone!==c&&i.maxTouchPoints&&i.maxTouchPoints>2&&(e[f]=`iPad`,e[m]=b),e},this.getEngine=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.engine),e},this.getOS=function(){var e={};return e[p]=r,e[g]=r,Y.call(e,o,x.os),S&&!e[p]&&v&&v.platform&&v.platform!=`Unknown`&&(e[p]=v.platform.replace(/chrome os/i,W).replace(/macos/i,G)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return o},this.setUA=function(e){return o=typeof e===u&&e.length>w?J(e,w):e,this},this.setUA(o),this};Z.VERSION=i,Z.BROWSER=K([p,g,d]),Z.CPU=K([_]),Z.DEVICE=K([f,h,m,v,y,x,b,S,C]),Z.ENGINE=Z.OS=K([p,g]),typeof e===c?typeof define===s&&define.amd?define(function(){return Z}):typeof n!==c&&(n.UAParser=Z):(typeof t!==c&&t.exports&&(e=t.exports=Z),e.UAParser=Z);var Q=typeof n!==c&&(n.jQuery||n.Zepto);if(Q&&!Q.ua){var $=new Z;Q.ua=$.getResult(),Q.ua.get=function(){return $.getUA()},Q.ua.set=function(e){$.setUA(e);var t=$.getResult();for(var n in t)Q.ua[n]=t[n]}}})(typeof window==`object`?window:e)}))(),1);let g=function(e){return e.Standalone=`standalone`,e.Fullscreen=`fullscreen`,e.MinimalUI=`minimal-ui`,e.Browser=`browser`,e}({}),_;(function(s){let c;function l(){return c??=new h.default(navigator.userAgent),c}s.getUserAgentInfo=l;function u(){var e,t;if(`orientation`in window)return!1;let n=`(any-pointer: coarse)`,r=(e=(t=window).matchMedia)==null?void 0:e.call(t,n);return navigator.maxTouchPoints===0||(r==null?void 0:r.media)===n&&!(r!=null&&r.matches)}s.isDesktopDevice=u;function d(){return l().getDevice().model===`iPhone`}s.isIPhone=d;function f(){var e,t;let n=l(),r=((e=n.getOS().name)==null?void 0:e.toLowerCase())??``,i=n.getDevice(),a=((t=i.model)==null?void 0:t.toLowerCase())??``,o=i.type;return r.includes(`ios`)&&(o===`tablet`||a.includes(`ipad`))}s.isIPad=f;function p(){var e,t;let n=((e=l().getOS().name)==null?void 0:e.toLowerCase())??``,r=l().getDevice(),i=r.type,a=((t=r.model)==null?void 0:t.toLowerCase())??``;return n.includes(`mac`)&&(i===`laptop`||a.includes(`macintosh`))}s.isMacBook=p;function m(){return d()||f()||p()}s.isAppleDevice=m;function g(){let e=l().getOS();return e.name===`iOS`&&e.version!=null&&e.version.localeCompare(`16.3`,void 0,{numeric:!0})>=0}s.isIOSDeviceWithExtendedCameraAccess=g;function v(){return`document`in window?window.document.createElement(`canvas`):null}s.getCanvas=v;function y(e){return e.name===`iOS`&&e.version!=null&&[`11.2.2`,`11.2.5`,`11.2.6`].includes(e.version)}async function b(){return o()}s.hasSIMDSupport=b;async function x(){return n()}s.hasThreadsSupport=x;function S(e,t,n){let r=e[t[0]];return r==null?!1:t.length===1?typeof r===n:(typeof r==`function`||typeof r==`object`)&&S(r,t.slice(1),n)}function C(){let e=!0,t=null,n=null,r=null,i=null;try{if(t=_.getCanvas(),n=_.getCanvas(),r=t==null?void 0:t.getContext(`webgl`),i=n==null?void 0:n.getContext(`experimental-webgl`),!S(window,[`WebGLRenderingContext`],`function`)||r==null&&i==null)throw Error(`WebGLRenderingContext is not supported`)}catch{e=!1}finally{for(let e of[r,i])if(typeof(e==null?void 0:e.getExtension)==`function`){var a;(a=e.getExtension(`WEBGL_lose_context`))==null||a.loseContext()}r=null,i=null,t=null,n=null}return e}function w(){let e=!0,t=!0,n=new Set;return location.protocol.startsWith(`http`)||n.add(`httpProtocol`),S(window,[`isSecureContext`],`boolean`)&&!window.isSecureContext&&n.add(`secureContext`),!S(navigator,[`mediaDevices`,`getUserMedia`],`function`)&&!S(navigator,[`enumerateDevices`],`function`)&&!S(window,[`MediaStreamTrack`,`getSources`],`function`)&&(n.add(`mediaDevices`),e=!1),S(window,[`Worker`],`function`)||(n.add(`webWorkers`),e=!1,t=!1),S(window,[`WebAssembly`],`object`)||(n.add(`webAssembly`),e=!1,t=!1),S(window,[`Blob`],`function`)||(n.add(`blob`),e=!1,t=!1),S(window,[`URL`,`createObjectURL`],`function`)||(n.add(`urlObject`),e=!1,t=!1),S(window,[`OffscreenCanvas`],`function`)||n.add(`offscreenCanvas`),C()||n.add(`webGL`),y(l().getOS())&&(n.add(`webAssemblyErrorFree`),e=!1,t=!1),r()||n.add(`sharedArrayBuffer`),a()||n.add(`crossOriginIsolated`),R()||n.add(`animationApi`),{fullSupport:e,scannerSupport:t,missingFeatures:[...n]}}s.checkBrowserCompatibility=w;async function T(){return i()}s.checkMultithreadingSupport=T;async function E(){let n=`scandit-device-id`,r=t.getInstanceFor(`localStorage`),i=r.getItem(n);if(i!=null&&i!==``)return i;let a=await e().get(n);if(i=a==null?void 0:a.value,i!=null&&i!==``)return r.setItem(n,i),i;let o=new Uint8Array(20);return crypto.getRandomValues(o),i=[...o].map(e=>{let t=e.toString(16);return t.length===1?`0${t}`:t}).join(``),r.setItem(n,i),i}s.getDeviceId=E;function D(e){return e instanceof HTMLElement||typeof e==`object`&&!!e&&typeof e.tagName==`string`}s.isValidHTMLElement=D;function O(){var e;let t=l().getOS();if(t.name!==`iOS`)return!0;let[n,r]=((e=t.version)==null?void 0:e.split(`.`).map(Number))??[];return n>14||n===14&&r>=6}s.isSupportedIOSVersion=O;function k(){var e;return((e=l().getBrowser().name)==null?void 0:e.toLowerCase().includes(`safari`))??!1}s.isSafari=k;function A(){var e;return/iphone|ipod|ipad/.test(((e=l().getDevice().model)==null?void 0:e.toLowerCase())??``)&&!k()}s.isIosWebView=A;function ee(){var e;return((e=l().getOS().name)==null?void 0:e.toLowerCase())===`android`}s.isAndroid=ee;function j(){return u()||d()?!1:l().getDevice().type===`tablet`}s.isTablet=j;async function M(){var e;return((e=l().getOS().name)==null?void 0:e.toLowerCase())===`android`?l().getUA().includes(`wv`)?!0:[...(await fetch(document.location.toString(),{method:`HEAD`})).headers].some(([e])=>e.toLowerCase()===`x-requested-with`):!1}s.isAndroidWebView=M;function N(){return l().getOS().name===`Windows`}s.isWindows=N;function P(){return l().getBrowser().name===`Firefox`}s.isFirefox=P;function F(){if(`navigator`in globalThis){for(let e of[`vibrate`,`webkitVibrate`,`msVibrate`,`mozVibrate`])if(typeof navigator[e]==`function`)return navigator[e]}}s.getSupportedVibrationMethod=F;function I(){return F()!=null&&!u()&&!N()&&!P()}s.isVibrationAvailable=I;function L(){return l().getOS().name===`iOS`}s.isIOS=L;function R(){return globalThis.Animation!==void 0&&globalThis.KeyframeEffect!==void 0&&globalThis.Element.prototype.animate!==void 0}s.isAnimationApiSupported=R;function z(){return`virtualKeyboard`in navigator}s.hasVirtualKeyboardSupport=z;function B(e){var t,n;let r=`(display-mode: ${e})`,i=(t=(n=globalThis).matchMedia)==null?void 0:t.call(n,r);return(i==null?void 0:i.matches)===!0?!0:e===`standalone`&&typeof navigator==`object`&&`standalone`in navigator&&typeof navigator.standalone==`boolean`?navigator.standalone===!0:!1}s.isPwaDisplayMode=B;function V(e,t,n){let r=e=>e.split(`.`).map(e=>Number.parseInt(e,10)||0),i=r(e),a=r(t),o=r(n),s=(e,t)=>{let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]??0,i=t[r]??0;if(n>i)return 1;if(n<i)return-1}return 0},c=s(i,a)>=0,l=s(i,o)<0;return c&&l}function H(){if(m()){let e=l(),t=e.getOS(),n=e.getBrowser(),r=k()?n.version:t.version;return r?V(r,`26`,`27`):!1}return!1}s.isFixedMemoryRequired=H;function U(){if(m()){let e=l(),t=e.getOS(),n=e.getBrowser(),r=k()?n.version:t.version;return r?V(r,`26`,`27`):!1}return!1}s.isSIMDBroken=U})(_||={});export{g as n,_ as t};
@@ -1,2 +1,2 @@
1
- import { n as DisplayMode, t as BrowserHelper } from "./browserHelper-Dno5no9Z.js";
1
+ import { n as DisplayMode, t as BrowserHelper } from "./browserHelper-ChSOtve7.js";
2
2
  export { BrowserHelper, DisplayMode };
@@ -1 +1 @@
1
- import{n as e,t}from"./browserHelper-BQPnAZ2Y.js";export{t as BrowserHelper,e as DisplayMode};
1
+ import{n as e,t}from"./browserHelper-DuxFlAfF.js";export{t as BrowserHelper,e as DisplayMode};
@@ -1 +1 @@
1
- import{t as e}from"../browserHelper-BQPnAZ2Y.js";import{CameraSettings as t,isCameraFrameSource as n}from"../CameraRelated.js";import{CameraAccess as r}from"../private/CameraAccess.js";import{Camera as i}from"../Camera.js";var a=class{constructor(){this.type=`camera-fov`,this.customIcons={wide:{idle:``,pressed:``},ultraWide:{idle:``,pressed:``}},this.fovSwitchButton=void 0,this.CameraFOVSwitchButtonClass=void 0,this.currentFrameSource=null,this.view=void 0,this.onCameraFOVChanged=this.handleCameraFOVChanged.bind(this),this.isTransitioning=!1}get cameraFOVWideImage(){return this.customIcons.wide.idle}set cameraFOVWideImage(e){this.customIcons.wide.idle=e,this.applyCustomImagesToButton()}get cameraFOVWidePressedImage(){return this.customIcons.wide.pressed}set cameraFOVWidePressedImage(e){this.customIcons.wide.pressed=e,this.applyCustomImagesToButton()}get cameraFOVUltraWideImage(){return this.customIcons.ultraWide.idle}set cameraFOVUltraWideImage(e){this.customIcons.ultraWide.idle=e,this.applyCustomImagesToButton()}get cameraFOVUltraWidePressedImage(){return this.customIcons.ultraWide.pressed}set cameraFOVUltraWidePressedImage(e){this.customIcons.ultraWide.pressed=e,this.applyCustomImagesToButton()}toJSONObject(){return{type:this.type}}async install(e){var t;if(!this.CameraFOVSwitchButtonClass){var n;this.CameraFOVSwitchButtonClass=await import(`../private/ui/molecules/CameraFOVSwitchButton.js`).then(e=>e.CameraFOVSwitchButton),(n=this.CameraFOVSwitchButtonClass)==null||n.register()}this.view=e,this.currentFrameSource=((t=e.getContext())==null?void 0:t.frameSource)??null,this.fovSwitchButton=this.CameraFOVSwitchButtonClass.create(),this.fovSwitchButton.slot=`bottomRight`,this.fovSwitchButton.hidden=!0,this.updateButtonMode(),this.fovSwitchButton.addEventListener(`camera-fov-changed`,this.onCameraFOVChanged);let r=e.controlsElement;return r&&r.append(this.fovSwitchButton),this.applyCustomImagesToButton(),await this.canShow()&&(await this.setInitialWideCamera(),this.updateButtonVisibility(!0)),!0}remove(e){e&&this.fovSwitchButton&&(this.fovSwitchButton.removeEventListener(`camera-fov-changed`,this.onCameraFOVChanged),this.fovSwitchButton.remove(),this.fovSwitchButton=null,this.currentFrameSource=null,this.view=void 0)}async update(e){var t;this.currentFrameSource=((t=e.getContext())==null?void 0:t.frameSource)??null,this.view=e,this.updateButtonMode();let n=await this.canShow();this.updateButtonVisibility(n)}updateButtonMode(){if(!this.fovSwitchButton)return;let e=this.isUltraWideBackCamera()?`0.5x`:`1.0x`;this.fovSwitchButton.mode=e}applyCustomImagesToButton(){this.fovSwitchButton&&(this.customIcons.wide.idle||this.customIcons.wide.pressed||this.customIcons.ultraWide.idle||this.customIcons.ultraWide.pressed?this.fovSwitchButton.setCustomImages(this.customIcons):this.fovSwitchButton.useCustomImages=!1)}updateButtonVisibility(e){this.fovSwitchButton&&(this.fovSwitchButton.hidden=!e)}async canShow(){if(!e.isIOSDeviceWithExtendedCameraAccess())return!1;let t=this.currentFrameSource;return t===null||!n(t)?!1:r.isIOSBackDualWideCameraLabel(t.label)||r.isIOSBackCameraLabel(t.label)||r.isIOSUltraWideBackCameraLabel(t.label)}isUltraWideBackCamera(){let e=this.currentFrameSource;return n(e)?r.isIOSUltraWideBackCameraLabel(e.label):!1}async handleCameraFOVChanged(e){await this.handleCameraFOVSwitch(),this.updateButtonMode()}async setInitialWideCamera(){var e;if(!this.isTransitioning&&!r.isIOSBackCameraLabel(((e=this.currentFrameSource)==null?void 0:e.label)??``)){let e=(await i.getAll()).find(e=>r.isIOSBackCameraLabel(e.label));e&&await this.switchCameras(e)}}async handleCameraFOVSwitch(){if(this.isTransitioning)return!1;let e=await this.getAlternativeCamera();return e?(await this.switchCameras(e),!0):!1}async getAlternativeCamera(){return(await i.getAll()).find(e=>this.isUltraWideBackCamera()?r.isIOSBackCameraLabel(e.label):r.isIOSUltraWideBackCameraLabel(e.label))}async switchCameras(e){var n;this.isTransitioning=!0;let r=(n=this.view)==null?void 0:n.getContext(),i=r==null?void 0:r.frameSource,a,o;i!=null&&(a=new t(i.settings),o=i.desiredState),await(i==null?void 0:i.switchToDesiredState(`off`)),a!=null&&await e.applySettings(a),await(r==null?void 0:r.setFrameSource(e)),await(r==null?void 0:r.frameSource).switchToDesiredState(o??`on`),this.isTransitioning=!1}};export{a as CameraFOVSwitchControl};
1
+ import{t as e}from"../browserHelper-DuxFlAfF.js";import{CameraSettings as t,isCameraFrameSource as n}from"../CameraRelated.js";import{CameraAccess as r}from"../private/CameraAccess.js";import{Camera as i}from"../Camera.js";var a=class{constructor(){this.type=`camera-fov`,this.customIcons={wide:{idle:``,pressed:``},ultraWide:{idle:``,pressed:``}},this.fovSwitchButton=void 0,this.CameraFOVSwitchButtonClass=void 0,this.currentFrameSource=null,this.view=void 0,this.onCameraFOVChanged=this.handleCameraFOVChanged.bind(this),this.isTransitioning=!1}get cameraFOVWideImage(){return this.customIcons.wide.idle}set cameraFOVWideImage(e){this.customIcons.wide.idle=e,this.applyCustomImagesToButton()}get cameraFOVWidePressedImage(){return this.customIcons.wide.pressed}set cameraFOVWidePressedImage(e){this.customIcons.wide.pressed=e,this.applyCustomImagesToButton()}get cameraFOVUltraWideImage(){return this.customIcons.ultraWide.idle}set cameraFOVUltraWideImage(e){this.customIcons.ultraWide.idle=e,this.applyCustomImagesToButton()}get cameraFOVUltraWidePressedImage(){return this.customIcons.ultraWide.pressed}set cameraFOVUltraWidePressedImage(e){this.customIcons.ultraWide.pressed=e,this.applyCustomImagesToButton()}toJSONObject(){return{type:this.type}}async install(e){var t;if(!this.CameraFOVSwitchButtonClass){var n;this.CameraFOVSwitchButtonClass=await import(`../private/ui/molecules/CameraFOVSwitchButton.js`).then(e=>e.CameraFOVSwitchButton),(n=this.CameraFOVSwitchButtonClass)==null||n.register()}this.view=e,this.currentFrameSource=((t=e.getContext())==null?void 0:t.frameSource)??null,this.fovSwitchButton=this.CameraFOVSwitchButtonClass.create(),this.fovSwitchButton.slot=`bottomRight`,this.fovSwitchButton.hidden=!0,this.updateButtonMode(),this.fovSwitchButton.addEventListener(`camera-fov-changed`,this.onCameraFOVChanged);let r=e.controlsElement;return r&&r.append(this.fovSwitchButton),this.applyCustomImagesToButton(),await this.canShow()&&(await this.setInitialWideCamera(),this.updateButtonVisibility(!0)),!0}remove(e){e&&this.fovSwitchButton&&(this.fovSwitchButton.removeEventListener(`camera-fov-changed`,this.onCameraFOVChanged),this.fovSwitchButton.remove(),this.fovSwitchButton=null,this.currentFrameSource=null,this.view=void 0)}async update(e){var t;this.currentFrameSource=((t=e.getContext())==null?void 0:t.frameSource)??null,this.view=e,this.updateButtonMode();let n=await this.canShow();this.updateButtonVisibility(n)}updateButtonMode(){if(!this.fovSwitchButton)return;let e=this.isUltraWideBackCamera()?`0.5x`:`1.0x`;this.fovSwitchButton.mode=e}applyCustomImagesToButton(){this.fovSwitchButton&&(this.customIcons.wide.idle||this.customIcons.wide.pressed||this.customIcons.ultraWide.idle||this.customIcons.ultraWide.pressed?this.fovSwitchButton.setCustomImages(this.customIcons):this.fovSwitchButton.useCustomImages=!1)}updateButtonVisibility(e){this.fovSwitchButton&&(this.fovSwitchButton.hidden=!e)}async canShow(){if(!e.isIOSDeviceWithExtendedCameraAccess())return!1;let t=this.currentFrameSource;return t===null||!n(t)?!1:r.isIOSBackDualWideCameraLabel(t.label)||r.isIOSBackCameraLabel(t.label)||r.isIOSUltraWideBackCameraLabel(t.label)}isUltraWideBackCamera(){let e=this.currentFrameSource;return n(e)?r.isIOSUltraWideBackCameraLabel(e.label):!1}async handleCameraFOVChanged(e){await this.handleCameraFOVSwitch(),this.updateButtonMode()}async setInitialWideCamera(){var e;if(!this.isTransitioning&&!r.isIOSBackCameraLabel(((e=this.currentFrameSource)==null?void 0:e.label)??``)){let e=(await i.getAll()).find(e=>r.isIOSBackCameraLabel(e.label));e&&await this.switchCameras(e)}}async handleCameraFOVSwitch(){if(this.isTransitioning)return!1;let e=await this.getAlternativeCamera();return e?(await this.switchCameras(e),!0):!1}async getAlternativeCamera(){return(await i.getAll()).find(e=>this.isUltraWideBackCamera()?r.isIOSBackCameraLabel(e.label):r.isIOSUltraWideBackCameraLabel(e.label))}async switchCameras(e){var n;this.isTransitioning=!0;let r=(n=this.view)==null?void 0:n.getContext(),i=r==null?void 0:r.frameSource,a,o;i!=null&&(a=new t(i.settings),o=i.desiredState),await(i==null?void 0:i.switchToDesiredState(`off`)),a!=null&&await e.applySettings(a),await(r==null?void 0:r.setFrameSource(e)),await(r==null?void 0:r.frameSource).switchToDesiredState(o??`on`),this.isTransitioning=!1}};export{a as CameraFOVSwitchControl};
@@ -1 +1 @@
1
- import{t as e}from"../browserHelper-BQPnAZ2Y.js";import{CameraSettings as t,isCameraFrameSource as n}from"../CameraRelated.js";import{CameraAccess as r}from"../private/CameraAccess.js";import{Camera as i}from"../Camera.js";import{clamp as a}from"../private/utils/clamp.js";import"../ZoomSwitchOrientation.js";const o=.5;function s(e){return Math.round(e*10)/10}var c=class{constructor(){this.type=`zoom`,this._zoomLevels=new Set,this._orientation=`default`,this._isAlwaysExpanded=!1,this._selectedZoomLevel=1,this._accessibilityLabel=`Zoom`,this.isApplyingZoomLevel=!1,this.handlerForZoomStrategy={setZoomForCurrentCamera:async e=>{await this.currentCamera.setZoomFactor(e)},switchToUltrawideCameraAndSetZoom:async e=>{await this.switchToUltraWideCamera(),await this.currentCamera.setZoomFactor(e/o)},setZoomForUltrawideCamera:async e=>{await this.currentCamera.setZoomFactor(e/o)},switchToWideCameraAndSetZoom:async e=>{await this.switchToWideCamera(),await this.currentCamera.setZoomFactor(e)},setZoomForWideCamera:async e=>{await this.currentCamera.setZoomFactor(e)}},this.onZoomLevelSelected=this.handleZoomLevelSelected.bind(this)}get currentCamera(){var e;let t=(e=this.view)==null?void 0:e.getContext(),r=t==null?void 0:t.frameSource;return n(r)?r:null}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.zoomSwitchPill&&(this.zoomSwitchPill.orientation=this.resolveOrientation())}get isAlwaysExpanded(){return this._isAlwaysExpanded}set isAlwaysExpanded(e){this._isAlwaysExpanded=e,this.zoomSwitchPill&&(this.zoomSwitchPill.isAlwaysExpanded=e)}get isExpanded(){var e;return((e=this.zoomSwitchPill)==null?void 0:e.expanded)??!1}set isExpanded(e){!this._isAlwaysExpanded&&this.zoomSwitchPill&&(this.zoomSwitchPill.expanded=e)}get selectedZoomLevel(){return this._selectedZoomLevel}get accessibilityLabel(){return this._accessibilityLabel}set accessibilityLabel(e){var t;this._accessibilityLabel=e,(t=this.zoomSwitchPill)==null||t.setAttribute(`aria-label`,e)}async selectZoomLevel(e){var t;let n=await((t=this.currentCamera)==null?void 0:t.getZoomRange()),r=[...this._zoomLevels],i=(n==null?void 0:n.min)??Math.min(...r),o=(n==null?void 0:n.max)??Math.max(...r),c=s(n==null?e:a(e,i,o));return await this.applyZoomLevelToCamera(c),this.updateSelectedLevelInUI(c),c}toJSONObject(){return{type:this.type}}onZoomLevelChanged(e,t,n){this.zoomSwitchPill&&(this.zoomSwitchPill.expanded=!1),this.updateSelectedLevelInUI(s(n))}onZoomLevelsChanged(e,t){this._zoomLevels=new Set(t),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels])}async install(e){var t;if(!this.ZoomSwitchPill){var n;let{ZoomSwitchPill:e}=await import(`../private/ui/molecules/ZoomSwitchPill.js`);this.ZoomSwitchPill=e,(n=this.ZoomSwitchPill)==null||n.register()}this.view=e,this.zoomSwitchPill=this.ZoomSwitchPill.create(),this.zoomSwitchPill.slot=`bottomRight`,this.zoomSwitchPill.hidden=!0,this.zoomSwitchPill.zoomLevels=[...this._zoomLevels],this.zoomSwitchPill.selectedLevel=this._selectedZoomLevel,this.zoomSwitchPill.orientation=this.resolveOrientation(),this.zoomSwitchPill.isAlwaysExpanded=this._isAlwaysExpanded,this.zoomSwitchPill.setAttribute(`aria-label`,this._accessibilityLabel),this.zoomSwitchPill.addEventListener(`zoom-level-selected`,this.onZoomLevelSelected);let r=await this.canShow();this.zoomSwitchPill.hidden=!r;let i=e.controlsElement;return i==null||i.append(this.zoomSwitchPill),(t=this.currentCamera)==null||t.addZoomListener(this),this.syncZoomLevelsFromCamera(),!0}remove(){var e,t,n;(e=this.zoomSwitchPill)==null||e.removeEventListener(`zoom-level-selected`,this.onZoomLevelSelected),(t=this.currentCamera)==null||t.removeZoomListener(this),(n=this.zoomSwitchPill)==null||n.remove(),this.zoomSwitchPill=void 0,this.view=void 0}async update(e){let t=this.currentCamera;this.view=e;let n=this.currentCamera;if(t!==n&&(t==null||t.removeZoomListener(this),n==null||n.addZoomListener(this),n!=null&&(this.syncZoomLevelsFromCamera(),this.updateSelectedLevelInUI(s(n.settings.zoomFactor)))),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels],this.zoomSwitchPill.selectedLevel=this._selectedZoomLevel,!this.isApplyingZoomLevel)){let e=await this.canShow();this.zoomSwitchPill.hidden=!e}}async canShow(){let e=this.currentCamera;return await(e==null?void 0:e.getZoomRange())!==null}async handleZoomLevelSelected({detail:{selectedLevel:e}}){this.zoomSwitchPill&&(this._selectedZoomLevel=e,this.zoomSwitchPill.temporaryLevel=null,this.zoomSwitchPill.selectedLevel=e,await this.applyZoomLevelToCamera(e))}updateSelectedLevelInUI(e){if(this.zoomSwitchPill){let t=s(e);this._selectedZoomLevel=t;let n=this._zoomLevels.has(t)?null:t;this.zoomSwitchPill.temporaryLevel=n,this.zoomSwitchPill.selectedLevel=t}}zoomStrategyForLevel(t){if(!e.isIOSDeviceWithExtendedCameraAccess())return`setZoomForCurrentCamera`;let n=r.isIOSUltraWideBackCameraLabel(this.currentCamera.label);return t<1?n?`setZoomForUltrawideCamera`:`switchToUltrawideCameraAndSetZoom`:n?`switchToWideCameraAndSetZoom`:`setZoomForWideCamera`}isCameraSwitchingStrategy(e){return e===`switchToUltrawideCameraAndSetZoom`||e===`switchToWideCameraAndSetZoom`}async applyZoomLevelToCamera(e){if(!this.currentCamera||this.isApplyingZoomLevel)return;this.isApplyingZoomLevel=!0;let t=this.zoomStrategyForLevel(e);this.isCameraSwitchingStrategy(t)&&this.zoomSwitchPill&&(this.zoomSwitchPill.loading=!0);try{var n;let r=this.handlerForZoomStrategy[t];await r(e),await((n=this.view)==null?void 0:n.showZoomNotification(e))}finally{this.isApplyingZoomLevel=!1,this.zoomSwitchPill&&(this.zoomSwitchPill.loading=!1)}}async switchToUltraWideCamera(){let e=(await i.getAll()).find(e=>r.isIOSUltraWideBackCameraLabel(e.label));e&&await this.switchCameras(e)}async switchToWideCamera(){let e=(await i.getAll()).find(e=>r.isIOSBackCameraLabel(e.label));e&&await this.switchCameras(e)}async switchCameras(e){var n,r;let i,a;this.currentCamera!=null&&(i=new t(this.currentCamera.settings),a=this.currentCamera.desiredState),await((n=this.currentCamera)==null?void 0:n.switchToDesiredState(`off`)),i!=null&&await e.applySettings(i);let o=(r=this.view)==null?void 0:r.getContext();await(o==null?void 0:o.setFrameSource(e));let s=a??`on`;await e.switchToDesiredState(s)}resolveOrientation(){var e;if(this._orientation!==`default`)return this._orientation;let t=(e=this.zoomSwitchPill)==null?void 0:e.slot;return t===`topCenter`||t===`bottomCenter`?`horizontal`:`vertical`}syncZoomLevelsFromCamera(){var e;let t=(e=this.currentCamera)==null||(e=e.settings)==null?void 0:e.zoomLevels;t!=null&&t.length>0&&(this._zoomLevels=new Set(t),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels]))}};export{c as ZoomSwitchControl};
1
+ import{t as e}from"../browserHelper-DuxFlAfF.js";import{CameraSettings as t,isCameraFrameSource as n}from"../CameraRelated.js";import{CameraAccess as r}from"../private/CameraAccess.js";import{Camera as i}from"../Camera.js";import{clamp as a}from"../private/utils/clamp.js";import"../ZoomSwitchOrientation.js";const o=.5;function s(e){return Math.round(e*10)/10}var c=class{constructor(){this.type=`zoom`,this._zoomLevels=new Set,this._orientation=`default`,this._isAlwaysExpanded=!1,this._selectedZoomLevel=1,this._accessibilityLabel=`Zoom`,this.isApplyingZoomLevel=!1,this.handlerForZoomStrategy={setZoomForCurrentCamera:async e=>{await this.currentCamera.setZoomFactor(e)},switchToUltrawideCameraAndSetZoom:async e=>{await this.switchToUltraWideCamera(),await this.currentCamera.setZoomFactor(e/o)},setZoomForUltrawideCamera:async e=>{await this.currentCamera.setZoomFactor(e/o)},switchToWideCameraAndSetZoom:async e=>{await this.switchToWideCamera(),await this.currentCamera.setZoomFactor(e)},setZoomForWideCamera:async e=>{await this.currentCamera.setZoomFactor(e)}},this.onZoomLevelSelected=this.handleZoomLevelSelected.bind(this)}get currentCamera(){var e;let t=(e=this.view)==null?void 0:e.getContext(),r=t==null?void 0:t.frameSource;return n(r)?r:null}get orientation(){return this._orientation}set orientation(e){this._orientation=e,this.zoomSwitchPill&&(this.zoomSwitchPill.orientation=this.resolveOrientation())}get isAlwaysExpanded(){return this._isAlwaysExpanded}set isAlwaysExpanded(e){this._isAlwaysExpanded=e,this.zoomSwitchPill&&(this.zoomSwitchPill.isAlwaysExpanded=e)}get isExpanded(){var e;return((e=this.zoomSwitchPill)==null?void 0:e.expanded)??!1}set isExpanded(e){!this._isAlwaysExpanded&&this.zoomSwitchPill&&(this.zoomSwitchPill.expanded=e)}get selectedZoomLevel(){return this._selectedZoomLevel}get accessibilityLabel(){return this._accessibilityLabel}set accessibilityLabel(e){var t;this._accessibilityLabel=e,(t=this.zoomSwitchPill)==null||t.setAttribute(`aria-label`,e)}async selectZoomLevel(e){var t;let n=await((t=this.currentCamera)==null?void 0:t.getZoomRange()),r=[...this._zoomLevels],i=(n==null?void 0:n.min)??Math.min(...r),o=(n==null?void 0:n.max)??Math.max(...r),c=s(n==null?e:a(e,i,o));return await this.applyZoomLevelToCamera(c),this.updateSelectedLevelInUI(c),c}toJSONObject(){return{type:this.type}}onZoomLevelChanged(e,t,n){this.zoomSwitchPill&&(this.zoomSwitchPill.expanded=!1),this.updateSelectedLevelInUI(s(n))}onZoomLevelsChanged(e,t){this._zoomLevels=new Set(t),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels])}async install(e){var t;if(!this.ZoomSwitchPill){var n;let{ZoomSwitchPill:e}=await import(`../private/ui/molecules/ZoomSwitchPill.js`);this.ZoomSwitchPill=e,(n=this.ZoomSwitchPill)==null||n.register()}this.view=e,this.zoomSwitchPill=this.ZoomSwitchPill.create(),this.zoomSwitchPill.slot=`bottomRight`,this.zoomSwitchPill.hidden=!0,this.zoomSwitchPill.zoomLevels=[...this._zoomLevels],this.zoomSwitchPill.selectedLevel=this._selectedZoomLevel,this.zoomSwitchPill.orientation=this.resolveOrientation(),this.zoomSwitchPill.isAlwaysExpanded=this._isAlwaysExpanded,this.zoomSwitchPill.setAttribute(`aria-label`,this._accessibilityLabel),this.zoomSwitchPill.addEventListener(`zoom-level-selected`,this.onZoomLevelSelected);let r=await this.canShow();this.zoomSwitchPill.hidden=!r;let i=e.controlsElement;return i==null||i.append(this.zoomSwitchPill),(t=this.currentCamera)==null||t.addZoomListener(this),this.syncZoomLevelsFromCamera(),!0}remove(){var e,t,n;(e=this.zoomSwitchPill)==null||e.removeEventListener(`zoom-level-selected`,this.onZoomLevelSelected),(t=this.currentCamera)==null||t.removeZoomListener(this),(n=this.zoomSwitchPill)==null||n.remove(),this.zoomSwitchPill=void 0,this.view=void 0}async update(e){let t=this.currentCamera;this.view=e;let n=this.currentCamera;if(t!==n&&(t==null||t.removeZoomListener(this),n==null||n.addZoomListener(this),n!=null&&(this.syncZoomLevelsFromCamera(),this.updateSelectedLevelInUI(s(n.settings.zoomFactor)))),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels],this.zoomSwitchPill.selectedLevel=this._selectedZoomLevel,!this.isApplyingZoomLevel)){let e=await this.canShow();this.zoomSwitchPill.hidden=!e}}async canShow(){let e=this.currentCamera;return await(e==null?void 0:e.getZoomRange())!==null}async handleZoomLevelSelected({detail:{selectedLevel:e}}){this.zoomSwitchPill&&(this._selectedZoomLevel=e,this.zoomSwitchPill.temporaryLevel=null,this.zoomSwitchPill.selectedLevel=e,await this.applyZoomLevelToCamera(e))}updateSelectedLevelInUI(e){if(this.zoomSwitchPill){let t=s(e);this._selectedZoomLevel=t;let n=this._zoomLevels.has(t)?null:t;this.zoomSwitchPill.temporaryLevel=n,this.zoomSwitchPill.selectedLevel=t}}zoomStrategyForLevel(t){if(!e.isIOSDeviceWithExtendedCameraAccess())return`setZoomForCurrentCamera`;let n=r.isIOSUltraWideBackCameraLabel(this.currentCamera.label);return t<1?n?`setZoomForUltrawideCamera`:`switchToUltrawideCameraAndSetZoom`:n?`switchToWideCameraAndSetZoom`:`setZoomForWideCamera`}isCameraSwitchingStrategy(e){return e===`switchToUltrawideCameraAndSetZoom`||e===`switchToWideCameraAndSetZoom`}async applyZoomLevelToCamera(e){if(!this.currentCamera||this.isApplyingZoomLevel)return;this.isApplyingZoomLevel=!0;let t=this.zoomStrategyForLevel(e);this.isCameraSwitchingStrategy(t)&&this.zoomSwitchPill&&(this.zoomSwitchPill.loading=!0);try{var n;let r=this.handlerForZoomStrategy[t];await r(e),await((n=this.view)==null?void 0:n.showZoomNotification(e))}finally{this.isApplyingZoomLevel=!1,this.zoomSwitchPill&&(this.zoomSwitchPill.loading=!1)}}async switchToUltraWideCamera(){let e=(await i.getAll()).find(e=>r.isIOSUltraWideBackCameraLabel(e.label));e&&await this.switchCameras(e)}async switchToWideCamera(){let e=(await i.getAll()).find(e=>r.isIOSBackCameraLabel(e.label));e&&await this.switchCameras(e)}async switchCameras(e){var n,r;let i,a;this.currentCamera!=null&&(i=new t(this.currentCamera.settings),a=this.currentCamera.desiredState),await((n=this.currentCamera)==null?void 0:n.switchToDesiredState(`off`)),i!=null&&await e.applySettings(i);let o=(r=this.view)==null?void 0:r.getContext();await(o==null?void 0:o.setFrameSource(e));let s=a??`on`;await e.switchToDesiredState(s)}resolveOrientation(){var e;if(this._orientation!==`default`)return this._orientation;let t=(e=this.zoomSwitchPill)==null?void 0:e.slot;return t===`topCenter`||t===`bottomCenter`?`horizontal`:`vertical`}syncZoomLevelsFromCamera(){var e;let t=(e=this.currentCamera)==null||(e=e.settings)==null?void 0:e.zoomLevels;t!=null&&t.length>0&&(this._zoomLevels=new Set(t),this.zoomSwitchPill&&(this.zoomSwitchPill.zoomLevels=[...this._zoomLevels]))}};export{c as ZoomSwitchControl};