import {HintAnchor,HintIcon,HintTextAlignment,ToastHintStyle}from'@scandit/web-datacapture-core/build/js/worker/dataCaptureWorkerRelated.js';function v(r){return r.charAt(0).toUpperCase()+r.slice(1)}function u(r){return r}var p=class{constructor(e,t,i){this.barcodeFind=null;this.basicOverlay=null;this.transparentGuidanceHintStyle={backgroundColor:"00000000",cornerRadius:4,fitToText:false,isAnimatedToView:false,textAlignment:HintTextAlignment.Center,hintIcon:HintIcon.None,hintAnchor:HintAnchor.AboveViewFinder,hintAnchorOffset:-12,horizontalMargin:0,iconColor:"00000000",lineHeight:-1,maxLines:1,maxWidthFraction:.8,textColor:"ffffffff",textSize:15,textWeight:600};this.customerTransformation=u;this.coreEngine=e,this.Module=t,this.workerFunctions=i;}async forSettings(e){var c;(c=this.barcodeFind)==null||c.delete(),this.barcodeFind=new this.Module.BarcodeFind(this.coreEngine.context,JSON.stringify(e));let t=this.Module.Feedback.extend("Feedback",{emit:()=>{this.listUpdatedFeedback();}}),i=this.Module.Feedback.extend("Feedback",{emit:()=>{this.barcodeFindFeedback();}}),a=this.Module.BarcodeFindTransformer.extend("BarcodeFindTransformer",{transformBarcodeData:s=>this.customerTransformation(s)}),d=this.Module.BarcodeFindListener.extend("BarcodeFindListener",{didUpdateSession:(s,o,n)=>{let h=this.coreEngine.convertToLoadableFrameData(n);this.workerFunctions.postMessage({type:"barcodeFindDidUpdateSession",payload:{session:JSON.parse(o.toJson()),frameData:h}}),s.delete(),o.delete(),n.delete();},onSearchPaused:s=>{let o=[];for(let n=0;n<s.size();n++)o.push(s.get(n));this.workerFunctions.postMessage({type:"barcodeFindSearchPaused",payload:{foundItems:o}});},onSearchStopped:s=>{let o=[];for(let n=0;n<s.size();n++)o.push(s.get(n));this.workerFunctions.postMessage({type:"barcodeFindSearchStopped",payload:{foundItems:o}});},onSearchStarted:()=>{this.workerFunctions.postMessage({type:"barcodeFindSearchStarted",payload:{}});}});this.barcodeFind.setBarcodeFindTransformer(new a),this.barcodeFind.addListener(new d,1),this.barcodeFind.setItemListUpdatedFeedback(new t),this.barcodeFind.setFeedback(new i),this.Module.addBarcodeFindToContext(this.coreEngine.context,this.barcodeFind);}barcodeFindFeedback(){this.workerFunctions.postMessage({type:"barcodeFindFeedback",payload:{}});}start(){var e;(e=this.barcodeFind)==null||e.start();}stop(){var e;(e=this.barcodeFind)==null||e.stop();}pause(){var e;(e=this.barcodeFind)==null||e.pause();}setEnabled(e){var t;(t=this.barcodeFind)==null||t.setEnabled(e);}setItemList(e){var t;(t=this.barcodeFind)==null||t.setItemList(JSON.stringify(e));}async removeMode(){this.barcodeFind!=null&&this.Module.removeBarcodeFindFromContext(this.coreEngine.context,this.barcodeFind);}addBasicOverlay(){var e;(e=this.basicOverlay)==null||e.delete(),this.basicOverlay=null,this.barcodeFind!=null&&(this.basicOverlay=new this.Module.BarcodeFindBasicOverlay(this.barcodeFind)),this.coreEngine.view!=null&&this.basicOverlay!=null&&(this.basicOverlay.setGuidanceHandler(this.createWebFindGuidanceHandler()),this.Module.addBarcodeFindBasicOverlayToView(this.coreEngine.view,this.basicOverlay));}removeBasicOverlay(){this.coreEngine.view!=null&&this.basicOverlay!=null&&this.Module.removeBarcodeFindBasicOverlayFromView(this.coreEngine.view,this.basicOverlay);}async applySettings(e){var t;(t=this.barcodeFind)==null||t.applySettings(JSON.stringify(e));}updateBasicOverlay(e){let t=Object.entries(e).filter(([i,a])=>i!=="type");for(let[i,a]of t){let d=`set${v(i)}`;this.basicOverlay!=null&&typeof this.basicOverlay[d]=="function"&&a!=null&&this.basicOverlay[d](a);}}setTransformerFunction(e){this.customerTransformation=e!=null?e:u;}successFeedback(){this.workerFunctions.postMessage({type:"successFeedback"});}listUpdatedFeedback(){this.workerFunctions.postMessage({type:"barcodeFindListUpdatedFeedback",payload:{}});}setToast(e,t){let i=this.coreEngine.hintPresenterV2;e?i==null||i.showToast(JSON.stringify(t)):i==null||i.hideToast(t.tag);}setGuidance(e,t,i){let a={tag:i,text:t,hintStyle:this.transparentGuidanceHintStyle};this.workerFunctions.postMessage({type:e?"showGuidance":"hideGuidance",payload:a});}createWebFindGuidanceHandler(){let e=this.Module.BarcodeFindGuidanceHandler.extend("BarcodeFindGuidanceHandler",{setInitialGuidance:(t,i)=>{this.setGuidance(t,i,"InitialGuidance");},setMoveCloserGuidance:(t,i)=>{this.setGuidance(false,i,"InitialGuidance"),this.setGuidance(t,i,"MoveCloserGuidance");},setAllItemsFound:(t,i)=>{let a={text:i,toastHintStyle:ToastHintStyle.Success,tag:"AllItemsFound"};this.setToast(t,a);},setTapShutterToPause:(t,i)=>{this.setGuidance(false,i,"InitialGuidance"),this.setGuidance(t,i,"TapShutterToPause");},setTapShutterToResume:(t,i)=>{this.setGuidance(false,i,"InitialGuidance"),this.setGuidance(t,i,"TapShutterResume");},setItemListUpdated:(t,i)=>{let a={text:i,toastHintStyle:ToastHintStyle.Info,tag:"ItemListUpdated"};this.setToast(t,a);}});return new e}};export{p as a};