1import{b as o,c}from"./chunk-HNIQUNPL.js";import{a as n,b as r,e as s}from"./chunk-MWGXSEMM.js";import{h as t}from"./chunk-B7O3QC5Z.js";var l=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.createUnavailableException();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 a=yield i.detect(e.videoElement);a.length!==0&&this.handleScannedBarcodes(a)}),500)})}stopScan(){return t(this,null,function*(){if(!this._isSupported)throw this.createUnavailableException();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.createUnavailableException()})}scan(){return t(this,null,function*(){throw this.createUnavailableException()})}isSupported(){return t(this,null,function*(){return{supported:this._isSupported}})}enableTorch(){return t(this,null,function*(){throw this.createUnavailableException()})}disableTorch(){return t(this,null,function*(){throw this.createUnavailableException()})}toggleTorch(){return t(this,null,function*(){throw this.createUnavailableException()})}isTorchEnabled(){return t(this,null,function*(){throw this.createUnavailableException})}isTorchAvailable(){return t(this,null,function*(){return{available:!1}})}setZoomRatio(e){return t(this,null,function*(){throw this.createUnavailableException()})}getZoomRatio(){return t(this,null,function*(){throw this.createUnavailableException()})}getMinZoomRatio(){return t(this,null,function*(){throw this.createUnavailableException()})}getMaxZoomRatio(){return t(this,null,function*(){throw this.createUnavailableException()})}openSettings(){return t(this,null,function*(){throw this.createUnavailableException()})}isGoogleBarcodeScannerModuleAvailable(){return t(this,null,function*(){throw this.createUnavailableException()})}installGoogleBarcodeScannerModule(){return t(this,null,function*(){throw this.createUnavailableException()})}checkPermissions(){return t(this,null,function*(){try{return{camera:(yield navigator.permissions.query({name:"camera"})).state}}catch{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{return{camera:"denied"}}})}createUnavailableException(){return new r("This plugin method is not available on this platform.",n.Unavailable)}handleScannedBarcodes(e){let i={barcodes:e.map(a=>({cornerPoints:[[a.cornerPoints[0].x,a.cornerPoints[0].y],[a.cornerPoints[1].x,a.cornerPoints[1].y],[a.cornerPoints[2].x,a.cornerPoints[2].y],[a.cornerPoints[3].x,a.cornerPoints[3].y]],displayValue:a.rawValue,rawValue:a.rawValue,format:a.format.toUpperCase(),valueType:o.Unknown}))};this.notifyListeners(this.eventBarcodesScanned,i)}};export{l as BarcodeScannerWeb};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.