import {a as a$1}from'./chunk-CUHE565K.js';import {a}from'./chunk-SYDG6PPD.js';import {nativeHandle}from'@scandit/web-datacapture-core/build/js/private/nativeHandle.js';var s=class o{constructor(e){this.listeners=new Set;this.onWorkerMessageHandler=this.onWorkerMessage.bind(this);this.labelCaptureHandle=e[nativeHandle];}static async create(e){return new o(e)}async startFlow(){await a().workerCommand("receiptScanningHandlerStartFlow",{payload:{labelCaptureHandle:this.labelCaptureHandle}});}async finishFlow(){await a().workerCommand("receiptScanningHandlerFinishFlow",{payload:{labelCaptureHandle:this.labelCaptureHandle}});}addListener(e){this.listeners.add(e),this.listeners.size===1&&(a().addWorkerListener(this.onWorkerMessageHandler),a().workerCommand("receiptScanningHandlerAddListener",{payload:{labelCaptureHandle:this.labelCaptureHandle}}));}removeListener(e){this.listeners.delete(e),this.listeners.size===0&&(a().removeWorkerListener(this.onWorkerMessageHandler),a().workerCommand("receiptScanningHandlerRemoveListener",{payload:{labelCaptureHandle:this.labelCaptureHandle}}));}onWorkerMessage(e){switch(e.type){case "receiptScanningListenerOnReceiptScanned":{this.onReceiptScanned(e.payload.result);break}case "receiptScanningListenerOnReceiptScanningFailed":this.onReceiptScanningFailed();break;case "receiptScanningListenerOnProcessingStarted":this.onProcessingStarted();break}}onReceiptScanned(e){var n;let a=a$1.fromJSON(e);for(let t of this.listeners)(n=t.onReceiptScanned)==null||n.call(t,a);}onReceiptScanningFailed(){var e;for(let a of this.listeners)(e=a.onReceiptScanningFailed)==null||e.call(a);}onProcessingStarted(){var e;for(let a of this.listeners)(e=a.onProcessingStarted)==null||e.call(a);}};export{s as a};