import{a as o,b as c}from"./chunk-LEE4YBB5.js";import{a as r,b as a,d as s}from"./chunk-J36J6JDY.js";import{k as t}from"./chunk-24IZEI4V.js";var d=class extends s{constructor(){super(...arguments),this._isSupported="BarcodeDetector"in window,this.errorVideoElementMissing="videoElement must be provided.",this.eventBarcodesScanned="barcodesScanned"}startScan(e){return t(this,null,function*(){if(!this._isSupported)throw this.createUnimplementedException();if(!e?.videoElement)throw new Error(this.errorVideoElementMissing);this.videoElement=e.videoElement,this.stream=yield navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:e?.lensFacing===c.Front?"user":"environment"}},audio:!1}),e.videoElement.srcObject=this.stream,yield e.videoElement.play();let i=new BarcodeDetector;this.intervalId=window.setInterval(()=>t(this,null,function*(){if(!e.videoElement)return;let n=yield i.detect(e.videoElement);n.length!==0&&this.handleScannedBarcodes(n)}),500)})}stopScan(){return t(this,null,function*(){if(!this._isSupported)throw this.createUnimplementedException();this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=void 0),this.videoElement&&(this.videoElement.srcObject=null,this.videoElement=void 0)})}readBarcodesFromImage(e){return t(this,null,function*(){throw this.createUnimplementedException()})}scan(){return t(this,null,function*(){throw this.createUnimplementedException()})}isSupported(){return t(this,null,function*(){return{supported:this._isSupported}})}enableTorch(){return t(this,null,function*(){throw this.createUnimplementedException()})}disableTorch(){return t(this,null,function*(){throw this.createUnimplementedException()})}toggleTorch(){return t(this,null,function*(){throw this.createUnimplementedException()})}isTorchEnabled(){return t(this,null,function*(){throw this.createUnimplementedException()})}isTorchAvailable(){return t(this,null,function*(){return{available:!1}})}setZoomRatio(e){return t(this,null,function*(){throw this.createUnimplementedException()})}getZoomRatio(){return t(this,null,function*(){throw this.createUnimplementedException()})}getMinZoomRatio(){return t(this,null,function*(){throw this.createUnimplementedException()})}getMaxZoomRatio(){return t(this,null,function*(){throw this.createUnimplementedException()})}openSettings(){return t(this,null,function*(){throw this.createUnimplementedException()})}isGoogleBarcodeScannerModuleAvailable(){return t(this,null,function*(){throw this.createUnimplementedException()})}installGoogleBarcodeScannerModule(){return t(this,null,function*(){throw this.createUnimplementedException()})}checkPermissions(){return t(this,null,function*(){try{return{camera:(yield navigator.permissions.query({name:"camera"})).state}}catch(e){return{camera:"prompt"}}})}requestPermissions(){return t(this,null,function*(){try{return(yield navigator.mediaDevices.getUserMedia({video:!0})).getTracks().forEach(i=>i.stop()),{camera:"granted"}}catch(e){return{camera:"denied"}}})}createUnimplementedException(){return new a("This method is not implemented on web.",r.Unimplemented)}handleScannedBarcodes(e){let i={barcodes:e.map(n=>({cornerPoints:[[n.cornerPoints[0].x,n.cornerPoints[0].y],[n.cornerPoints[1].x,n.cornerPoints[1].y],[n.cornerPoints[2].x,n.cornerPoints[2].y],[n.cornerPoints[3].x,n.cornerPoints[3].y]],displayValue:n.rawValue,rawValue:n.rawValue,format:n.format.toUpperCase(),valueType:o.Unknown}))};this.notifyListeners(this.eventBarcodesScanned,i)}};export{d as BarcodeScannerWeb};
