import {a as a$3}from'./chunk-MMRF53YY.js';import {a as a$2}from'./chunk-NDYVHCIR.js';import {a}from'./chunk-XETUH5HN.js';import {a as a$4}from'./chunk-2K4IDUBI.js';import {a as a$1}from'./chunk-SYDG6PPD.js';import {CameraSettings,FocusGestureStrategy,VideoResolution,convertToPublicFrameData}from'@scandit/web-datacapture-core';import {nativeHandle}from'@scandit/web-datacapture-core/build/js/private/nativeHandle.js';import {warnMultithreadingUnavailable}from'@scandit/web-datacapture-core/build/js/private/utils/warnMultithreadingUnavailable.js';var n=class n{constructor(e,a$1){this.skipSerialization=true;this.context=null;this.listeners=new Set;this._receiptScanningHandler=null;this.workerListener=this.onWorkerMessage.bind(this);this._isEnabled=true;this._feedback=a.default;this[nativeHandle]=e,this.context=a$1;}toJSONObject(){return {type:"labelCapture",enabled:this.isEnabled(),settings:{}}}async unsetValidationFlowHandler(){await a$1().workerCommand("labelCaptureModeUnsetValidationFlowHandler",{payload:{labelCaptureHandle:this[nativeHandle]}});}async validationFlowHandler(){return await a$2.create(this)}async receiptScanningHandler(){return this._receiptScanningHandler||(this._receiptScanningHandler=await a$3.create(this)),this._receiptScanningHandler}static createRecommendedCameraSettings(){return CameraSettings.fromJSON({preferredResolution:VideoResolution.FullHD,zoomFactor:1,zoomGestureZoomFactor:1,focusGestureStrategy:FocusGestureStrategy.ManualUntilCapture,grayScaleFrameReader:true})}static async forContext(e,a){warnMultithreadingUnavailable();let i=await a$1().workerCommand("labelCaptureModeCreate",{payload:{settingsHandle:a[nativeHandle]}}),o=new n(i,e);return await e.addMode(o),o}async attachedToContext(e){this.context=e,await a$1().workerCommand("labelCaptureModeAddToContext",{payload:{labelCaptureHandle:this[nativeHandle]}});}async detachedFromContext(){await a$1().workerCommand("labelCaptureModeRemoveFromContext",{payload:{labelCaptureHandle:this[nativeHandle]}}),this.context=null;}get feedback(){return this._feedback}set feedback(e){this._feedback=e;}isEnabled(){return this._isEnabled}async setEnabled(e){var a;this._isEnabled=e;try{await a$1().workerCommand("labelCaptureModeSetEnabled",{payload:{enabled:e,labelCaptureHandle:this[nativeHandle]}}),await((a=this.context)==null?void 0:a.update([{type:"modeEnabled",newValue:e}],{updateContext:false}));}catch(i){throw this._isEnabled=!e,i}}async applySettings(e){await a$1().workerCommand("labelCaptureModeApplySettings",{payload:{settingsHandle:e[nativeHandle],labelCaptureHandle:this[nativeHandle]}});}addListener(e){var a;this.listeners.add(e),(a=e.didStartObservingLabelCapture)==null||a.call(e,this),this.listeners.size===1&&(a$1().addWorkerListener(this.workerListener),a$1().workerCommand("labelCaptureModeAddListener",{payload:{labelCaptureHandle:this[nativeHandle]}}));}removeListener(e){var a;this.listeners.delete(e),(a=e.didStopObservingLabelCapture)==null||a.call(e,this),this.listeners.size===0&&(a$1().removeWorkerListener(this.workerListener),a$1().workerCommand("labelCaptureModeRemoveListener",{payload:{labelCaptureHandle:this[nativeHandle]}}));}onWorkerMessage(e){switch(e.type){case "labelCaptureOnObservationStarted":this.didStartObservingLabelCapture();break;case "labelCaptureOnObservationStopped":this.didStopObservingLabelCapture();break;case "labelCaptureOnSessionUpdated":this.didUpdateSession(e.payload.session,e.payload.data);break}}didStartObservingLabelCapture(){var e;for(let a of this.listeners)(e=a.didStartObservingLabelCapture)==null||e.call(a,this);}didStopObservingLabelCapture(){var e;for(let a of this.listeners)(e=a.didStopObservingLabelCapture)==null||e.call(a,this);}didUpdateSession(e,a){var l;let i=a$4.fromJSON(e),o=convertToPublicFrameData(a,this.context);i.capturedLabels.length>0&&this.emitFeedback();for(let s of this.listeners)(l=s.didUpdateSession)==null||l.call(s,this,i,o);}emitFeedback(){var e;(e=this._feedback)!=null&&e.success&&this._feedback.success.emit();}},c=n;export{c as a};