import {a as a$1}from'./chunk-A6QIZJQN.js';import {a}from'./chunk-SYDG6PPD.js';import {nativeHandle}from'@scandit/web-datacapture-core/build/js/private/nativeHandle.js';var s=class s{constructor(a,r){this.validationFlowListeners=new Set;this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this[nativeHandle]=a,this.labelCaptureWorkerManager=r;}static async create(a$1){let r=a(),n=await r.workerCommand("validationFlowHandlerCreate",{payload:{labelCaptureHandle:a$1[nativeHandle]}});return new s(n,r)}async startCompleteLabelScan(a){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerStartCompleteLabelScan",{payload:{labelCaptureHandle:this[nativeHandle],labelName:a}});}async startPartialLabelScan(a){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerStartPartialLabelScan",{payload:{labelCaptureHandle:this[nativeHandle],fieldNames:a}});}async updateFieldValue(a,r){return await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerUpdateFieldValue",{payload:{labelCaptureHandle:this[nativeHandle],fieldName:a,value:r}})}async onFinishFlowRequested(){return await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerFinishFlow",{payload:{labelCaptureHandle:this[nativeHandle]}})}async pauseScan(){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerPauseScan",{payload:{labelCaptureHandle:this[nativeHandle]}});}async reset(){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerReset",{payload:{labelCaptureHandle:this[nativeHandle]}});}async resumeScan(){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerResumeScan",{payload:{labelCaptureHandle:this[nativeHandle]}});}async validationFlowFields(){return (await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerGetValidationFlowFields",{payload:{labelCaptureHandle:this[nativeHandle]}})).map(r=>a$1.fromJSONObject(r))}async clearAllFields(){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerClearAllFields",{payload:{labelCaptureHandle:this[nativeHandle]}});}async cancelCloudBackupTaskForField(a){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerCancelCloudBackupTaskForField",{payload:{labelCaptureHandle:this[nativeHandle],fieldName:a}});}async uncancelCloudBackupTaskForField(a){await this.labelCaptureWorkerManager.workerCommand("validationFlowHandlerUncancelCloudBackupTaskForField",{payload:{labelCaptureHandle:this[nativeHandle],fieldName:a}});}addListener(a){this.validationFlowListeners.size===0&&this.labelCaptureWorkerManager.addWorkerListener(this.onWorkerMessageHandler),this.validationFlowListeners.add(a);}removeListener(a){this.validationFlowListeners.delete(a),this.validationFlowListeners.size===0&&this.labelCaptureWorkerManager.removeWorkerListener(this.onWorkerMessageHandler);}async onWorkerMessage(a){var r,n,d,p,u,c,w,F;if(this.validationFlowListeners.size!==0)switch(a.type){case "validationFlowListenerOnFieldsScanned":{let i=a.payload.fields.map(e=>a$1.fromJSONObject(e));for(let e of this.validationFlowListeners)(r=e.onFieldsScanned)==null||r.call(e,i);break}case "validationFlowListenerOnScanTimeout":{let i=[];for(let e of this.validationFlowListeners)i.push((n=e.onScanTimeout)==null?void 0:n.call(e));await Promise.all(i);break}case "validationFlowListenerOnLabelIsMissingRequiredField":{let i=a.payload.fields.map(o=>a$1.fromJSONObject(o)),e=[];for(let o of this.validationFlowListeners)e.push((d=o.onLabelIsMissingRequiredField)==null?void 0:d.call(o,i));await Promise.all(e);break}case "validationFlowListenerOnManualInput":{let i=a$1.fromJSONObject(a.payload.field);for(let e of this.validationFlowListeners)(p=e.onManualInput)==null||p.call(e,i,a.payload.oldValue,a.payload.newValue);break}case "validationFlowListenerOnStateChanged":{let i=a.payload.state,e=[];for(let o of this.validationFlowListeners)e.push((u=o.onStateChanged)==null?void 0:u.call(o,i));await Promise.all(e);break}case "validationFlowListenerOnCloudBackupServiceStarted":{let i=[];for(let e of this.validationFlowListeners)i.push((c=e.onCloudBackupServiceStarted)==null?void 0:c.call(e));await Promise.all(i);break}case "validationFlowListenerOnCloudBackupServiceStopped":{for(let i of this.validationFlowListeners)(w=i.onCloudBackupServiceStopped)==null||w.call(i);break}case "validationFlowListenerOnResultUpdate":{let i=a.payload.updateType,e=a.payload.fields.map(o=>a$1.fromJSONObject(o));for(let o of this.validationFlowListeners)(F=o.onResultUpdate)==null||F.call(o,i,e);break}}}},b=s;export{b as a};