import {a as a$1}from'./chunk-F5NT65XG.js';import {a}from'./chunk-SYDG6PPD.js';import {a as a$2}from'./chunk-36FUBGEZ.js';import {a as a$3}from'./chunk-MQ3C6JQR.js';import {Logger,RectangularViewfinder,AimerViewfinder}from'@scandit/web-datacapture-core';import {nativeHandle}from'@scandit/web-datacapture-core/build/js/private/nativeHandle.js';function f(d){return d instanceof RectangularViewfinder||d instanceof AimerViewfinder}var p=class p{constructor(e){this.listeners=new Set;this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this[nativeHandle]=e;}static async withLabelCapture(e){let t=await a().workerCommand("labelCaptureBasicOverlayForLabelCapture",{payload:{labelCaptureHandle:e[nativeHandle]}});return new p(t)}static async withLabelCaptureForView(e,t){let i=await a().workerCommand("labelCaptureBasicOverlayForLabelCapture",{payload:{labelCaptureHandle:e[nativeHandle]}}),s=new p(i);return await t.addOverlay(s),s}toJSONObject(){return {type:this[nativeHandle].className,nativeHandle:this[nativeHandle]}}async getListener(){return this.listeners.size===0?null:[...this.listeners.values()][0]}async setListener(e){if(!e){this.listeners.clear(),a().removeWorkerListener(this.onWorkerMessageHandler),await a().workerCommand("labelCaptureBasicOverlaySetListener",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],value:false}});return}this.listeners.size===0&&(this.listeners.add(e),a().addWorkerListener(this.onWorkerMessageHandler),await a().workerCommand("labelCaptureBasicOverlaySetListener",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],value:true}}));}async getDefaultFieldBrush(e){return await a().workerCommand("labelCaptureBasicOverlayGetDefaultFieldBrush",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],labelFieldState:e}})}async setDefaultFieldBrush(e,t){return await a().workerCommand("labelCaptureBasicOverlaySetDefaultFieldBrush",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],labelFieldState:t,brush:e.toJSONObject()}})}async getDefaultLabelBrush(){return await a().workerCommand("labelCaptureBasicOverlayGetDefaultLabelBrush",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle]}})}async setDefaultLabelBrush(e){return await a().workerCommand("labelCaptureBasicOverlaySetDefaultLabelBrush",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],brush:e.toJSONObject()}})}async setBrushForField(e,t,i){return await a().workerCommand("labelCaptureBasicOverlaySetBrushForField",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],fieldJSON:t.toJSONObject(),labelJSON:i.toJSONObject(),brush:e.toJSONObject()}})}async setBrushForLabel(e,t){return await a().workerCommand("labelCaptureBasicOverlaySetBrushForLabel",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],labelJSON:t.toJSONObject(),brush:e.toJSONObject()}})}async getShouldShowScanAreaGuides(){return await a().workerCommand("labelCaptureBasicOverlayGetShouldShowScanAreaGuides",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle]}})}async setShouldShowScanAreaGuides(e){return await a().workerCommand("labelCaptureBasicOverlaySetShouldShowScanAreaGuides",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],show:e}})}async getViewfinder(){return await a().workerCommand("labelCaptureBasicOverlayGetViewfinder",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle]}})}async setViewfinder(e){if(!f(e)){Logger.error("Supported viewfinder types are RectangularViewfinder and AimerViewfinder",e);return}return this.proxiedViewFinder=a$1(this,a(),e),await a().workerCommand("labelCaptureBasicOverlayUpdateViewfinder",{payload:{labelCaptureBasicOverlayHandle:this[nativeHandle],viewfinderJSON:e==null?void 0:e.toJSONObject()}})}onWorkerMessage(e){var t,i,s;switch(e.type){case "labelCaptureBasicOverlayOnLabelTapped":{for(let l of this.listeners)(t=l.onLabelTapped)==null||t.call(l,this,a$2.fromJSON(e.payload.labelJSON));break}case "labelCaptureBasicOverlayBrushForField":{for(let l of this.listeners){let o=a$3.fromJSON(e.payload.fieldJSON),u=a$2.fromJSON(e.payload.labelJSON),b=(i=l.brushForField)==null?void 0:i.call(l,this,o,u);b&&this.setBrushForField(b,o,u);}break}case "labelCaptureBasicOverlayBrushForLabel":{for(let l of this.listeners){let o=a$2.fromJSON(e.payload.labelJSON),u=(s=l.brushForLabel)==null?void 0:s.call(l,this,o);u&&this.setBrushForLabel(u,o);}break}}}},m=p;export{m as a};