import {AsyncStateMachine}from'@scandit/web-datacapture-core/build/js/private/utils/AsyncStateMachine.js';var l=(e=>(e.IDLE="idle",e.PROCESSING="processing",e))(l||{}),o=(a=>(a.Initial="initial",a.Scanning="scanning",a.CloudBackup="cloudBackup",a.Validated="validated",a.Error="error",a))(o||{}),i=class{constructor(){this.validationFlowState=0;this.currentInputName=null;this.cloudBackupFields=new Set;this.fieldStates=new Map;this.scanResultMap=new Map;this.cloudBackupStateMachine=new AsyncStateMachine("idle",[{from:"idle",to:"processing"},{from:"processing",to:"idle"}]);}get validationFlowHandlerState(){return this.validationFlowState}set validationFlowHandlerState(t){this.validationFlowState=t;}get isScanning(){return this.validationFlowState===2||this.validationFlowState===1}get isScanningOrCloudBackup(){return this.isCloudBackupProcessing||this.isScanning}get isPaused(){return this.validationFlowState===3}get isFinished(){return this.validationFlowState===4}get isIdle(){return this.validationFlowState===0}get cloudBackupState(){return this.cloudBackupStateMachine.currentState}get isCloudBackupProcessing(){return this.cloudBackupStateMachine.currentState==="processing"}get hasCurrentInputName(){return this.currentInputName!==null}getCurrentInputName(){return this.currentInputName}setCurrentInputName(t){this.currentInputName=t;}clearCurrentInputName(){this.currentInputName=null;}startCloudBackup(t){this.cloudBackupFields=new Set(t),this.cloudBackupStateMachine.currentState==="idle"&&this.cloudBackupStateMachine.transitionTo("processing");}stopCloudBackup(){this.cloudBackupFields.clear(),this.cloudBackupStateMachine.transitionTo("idle");}cancelCloudBackupForField(t){this.cloudBackupFields.delete(t),this.cloudBackupFields.size===0&&this.cloudBackupStateMachine.currentState==="processing"&&this.cloudBackupStateMachine.transitionTo("idle");}uncancelCloudBackupForField(t){this.cloudBackupFields.add(t),this.cloudBackupStateMachine.currentState==="idle"&&this.cloudBackupStateMachine.transitionTo("processing");}isFieldInCloudBackup(t){return this.cloudBackupFields.has(t)}getCloudBackupFields(){return Array.from(this.cloudBackupFields)}onCloudBackupStateChange(t){this.cloudBackupStateMachine.addListener(t);}offCloudBackupStateChange(t){this.cloudBackupStateMachine.removeListener(t);}registerFields(t){for(let e of t)this.fieldStates.has(e)||this.fieldStates.set(e,"initial");}clearFields(){this.fieldStates.clear();}setInputState(t,e){let n=this.currentInputName===t&&(e==="scanning"||e==="cloudBackup")?"initial":e;this.fieldStates.set(t,n);}getInputState(t){var e;return (e=this.fieldStates.get(t))!=null?e:"initial"}isCurrentInputName(t){return this.currentInputName===t}setScanResults(t){this.scanResultMap.clear();for(let e of t)this.scanResultMap.set(e.getLabelField().name,e);}updateScanResults(t){for(let e of t)this.scanResultMap.set(e.getLabelField().name,e);}deleteScanResult(t){this.scanResultMap.delete(t);}getScanResult(t){return this.scanResultMap.get(t)}clearScanResults(){this.scanResultMap.clear();}};export{l as a,o as b,i as c};