import {a}from'./chunk-YWNGCXKZ.js';import {TorchState,Camera,FrameSourceState}from'@scandit/web-datacapture-core';var h=(t=>(t.Started="started",t.Paused="paused",t.Stopped="stopped",t))(h||{}),c=class{constructor(e,i,t,s,o){this.viewState="paused";this.barcodeFindViewUiListener=null;this.torchState=TorchState.Off;this.sessionState=null;this.barcodeFindView=e,this.barcodeFind=t,this.context=i,this.viewSettings=s,this.cameraSettings=o,t.feedback=a.createWithOptions(this.viewSettings.soundEnabled,this.viewSettings.hapticEnabled);}async prepare(){await this.barcodeFind.setEnabled(false),this.barcodeFind.addPrivateListener(this);let e=Camera.default;await this.context.setFrameSource(e),await this.context.frameSource.applySettings(this.cameraSettings),this.isTorchAvailable=await e.isTorchAvailable();}async dispose(){await this.context.removeMode(this.barcodeFind),this.barcodeFind.removePrivateListener(this);}async didPauseSearch(e){this.barcodeFindView.switchToPaused(Object.values(this.customerItemsListState),e);}async didStartSearch(){this.barcodeFindView.switchToStarted();}async didStopSearch(e){var i;(i=this.barcodeFindViewUiListener)==null||i.didTapFinishButton(e);}async onSetItemList(e){this.customerItemsListState=e.reduce((i,t)=>(i[t.searchOptions.barcodeData]=t,i),{}),this.barcodeFind.feedback.itemListUpdated.emit(),this.barcodeFindView.updateProgressBar(0,Object.values(this.customerItemsListState).length);}onDidUpdateSession(e,i,t){this.sessionState=i,this.barcodeFindView.updateProgressBar(this.sessionState.allFoundItems.length),this.barcodeFindView.renderDots(this.sessionState);}async onShutterButtonClicked(){this.viewState==="paused"||this.viewState==="stopped"?await this.startSearching():await this.pauseSearching();}async onTorchButtonClicked(){this.isTorchAvailable&&(await this.context.frameSource.setDesiredTorchState(this.torchState===TorchState.Off?TorchState.On:TorchState.Off),this.torchState=this.torchState===TorchState.Off?TorchState.On:TorchState.Off,this.barcodeFindView.toggleTorchIcon(this.torchState));}onDotClick(e){var t,s;let i=(t=this.sessionState)==null?void 0:t.trackedBarcodes[e];if(i!=null){let o=this.customerItemsListState[(s=i.barcode.data)!=null?s:""];this.barcodeFindView.moveCardOnTheFront(o);}}onFinishButtonClicked(){this.stopSearching();}onFindListUpdatedFeedback(){this.barcodeFind.feedback.itemListUpdated.emit();}onFeedback(){this.barcodeFind.feedback.found.emit(),this.barcodeFindView.setShutterButtonPulse(true);}async pauseSearching(){var e;this.viewState="paused",await((e=this.context.frameSource)==null?void 0:e.switchToDesiredState(FrameSourceState.Standby)),await this.barcodeFind.setEnabled(false),await this.barcodeFind.pause(),this.barcodeFindView.setShutterButtonPulse(false);}async startSearching(){var e;this.viewState="started",await((e=this.context.frameSource)==null?void 0:e.switchToDesiredState(FrameSourceState.On)),await this.barcodeFind.setEnabled(true),await this.barcodeFind.start();}async stopSearching(){var e;this.viewState="stopped",await this.barcodeFind.setEnabled(false),await((e=this.context.frameSource)==null?void 0:e.switchToDesiredState(FrameSourceState.Off)),await this.barcodeFind.stop(),this.barcodeFindView.setShutterButtonPulse(false),this.sessionState=null;}};export{h as a,c as b};