{"version":3,"file":"ngx-html5-qrcode.mjs","sources":["../../../projects/ngx-html5-qrcode/src/lib/ngx-html5-qrcode.component.ts","../../../projects/ngx-html5-qrcode/src/lib/ngx-html5-qrcode.module.ts","../../../projects/ngx-html5-qrcode/src/public-api.ts","../../../projects/ngx-html5-qrcode/src/ngx-html5-qrcode.ts"],"sourcesContent":["import {\n  AfterViewInit,\n  Component,\n  ElementRef,\n  OnDestroy,\n  OnInit,\n  Renderer2,\n  ViewChild,\n  Output,\n  Input,\n  EventEmitter\n} from '@angular/core';\nimport {Html5Qrcode} from \"html5-qrcode\";\nimport {Html5QrcodeCameraScanConfig} from \"html5-qrcode/esm/html5-qrcode\";\nimport {Html5QrcodeResult} from \"html5-qrcode/esm/core\";\n\n@Component({\n  selector: 'html5-qrcode',\n  template: `\n    <div #reader id=\"reader\" width=\"600px\"></div>\n  `,\n  styles: []\n})\nexport class NgxHtml5QrcodeComponent implements OnInit, AfterViewInit, OnDestroy {\n\n  @ViewChild('reader') reader: ElementRef | undefined;\n  html5QrCode!: Html5Qrcode;\n  cameraId: string = '';\n\n  @Input() useFrontCamera: boolean = false;\n  @Input() config: Html5QrcodeCameraScanConfig = {fps: 10, qrbox: {width: 250, height: 250}};\n  @Output() decodedText: EventEmitter<string> = new EventEmitter<string>();\n  @Output() decodedResult: EventEmitter<Html5QrcodeResult> = new EventEmitter<Html5QrcodeResult>();\n\n  constructor() {\n  }\n\n  ngOnInit(): void {\n  }\n\n  ngAfterViewInit() {\n\n    // This method will trigger user permissions\n    Html5Qrcode.getCameras().then(devices => {\n      if (devices && devices.length) {\n        // .. use this to start scanning.\n        this.cameraId = this.useFrontCamera ? devices[1].id : devices[0].id;\n        this.startHtmlQrCode();\n      }\n    }).catch(err => {\n      console.log(err);\n    });\n  }\n\n  qrCodeSuccessCallback(decodedText: any, decodedResult: Html5QrcodeResult) {\n    /* handle success */\n    this.decodedText.emit(decodedText);\n    this.decodedResult.emit(decodedResult);\n  }\n\n  qrCodeErrorCallback(errorMessage: any) {\n    /* handle success */\n    console.error(errorMessage);\n  }\n\n  startHtmlQrCode() {\n    this.html5QrCode = new Html5Qrcode(this.reader?.nativeElement?.id);\n\n    this.html5QrCode.start(\n      {deviceId: {exact: this.cameraId}},\n      this.config,\n      this.qrCodeSuccessCallback,\n      this.qrCodeErrorCallback)\n      .catch((err) => {\n        // Start failed, handle it.\n        console.log(err);\n      });\n  }\n\n  ngOnDestroy() {\n    this.html5QrCode.stop().then((ignore) => {\n      // QR Code scanning is stopped.\n    }).catch((err) => {\n      // Stop failed, handle it.\n    });\n  }\n\n}\n","import {NgModule} from '@angular/core';\nimport {NgxHtml5QrcodeComponent} from './ngx-html5-qrcode.component';\n\n\n@NgModule({\n  declarations: [\n    NgxHtml5QrcodeComponent\n  ],\n  imports: [],\n  exports: [\n    NgxHtml5QrcodeComponent\n  ]\n})\nexport class NgxHtml5QrcodeModule {\n}\n","/*\n * Public API Surface of ngx-html5-qrcode\n */\n\nexport * from './lib/ngx-html5-qrcode.component';\nexport * from './lib/ngx-html5-qrcode.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAuBa,uBAAuB;IAWlC;QAPA,aAAQ,GAAW,EAAE,CAAC;QAEb,mBAAc,GAAY,KAAK,CAAC;QAChC,WAAM,GAAgC,EAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAC,EAAC,CAAC;QACjF,gBAAW,GAAyB,IAAI,YAAY,EAAU,CAAC;QAC/D,kBAAa,GAAoC,IAAI,YAAY,EAAqB,CAAC;KAGhG;IAED,QAAQ;KACP;IAED,eAAe;;QAGb,WAAW,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,OAAO;YACnC,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE;;gBAE7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,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