'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-fd2bbf0b.js');
const hardwareBackButton = require('./overlays-de05dc6a.js');
require('./ionic-global-1340f737.js');
require('./helpers-c2496722.js');

const modalScannerCss = "modal-scanner .banner{background-color:var(--ion-color-secondary)}modal-scanner h1{color:#fff}modal-scanner p{margin:0 0 15px 0;color:rgba(255, 255, 255, 0.8);font-weight:normal}.modal-scanner{--width:700px;--max-width:700px}@media only screen and (max-width: 800px){.modal-scanner{--width:100%;--max-width:auto}}";

let ModalScanner = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.floodteamCloseModal = index.createEvent(this, "floodteamCloseModal", 7);
  }
  onReset(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-scanner");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        sendEmailModalEl.dismiss();
      }
    }
  }
  async onSuccess(event) {
    var _a;
    if (((_a = event.detail) === null || _a === void 0 ? void 0 : _a.endpoint) === "bulkUpdateUsers") {
      const sendEmailModalEl = document.querySelector("ion-modal.modal-scanner");
      if (sendEmailModalEl === null || sendEmailModalEl === void 0 ? void 0 : sendEmailModalEl.dismiss) {
        await sendEmailModalEl.dismiss();
        this.presentToast();
      }
    }
  }
  async presentToast() {
    const toast = await hardwareBackButton.toastController.create({
      message: `Scanning...`,
      duration: 2000,
    });
    toast.present();
  }
  onScanSuccess(decodedText, decodedResult) {
    // Handle on success condition with the decoded text or result.
    console.log(`Scan result: ${decodedText}`, decodedResult);
    // ...
    this.qrCodeScanner.clear();
    // ^ this will stop the scanner (video feed) and clear the scan area.
  }
  componentDidLoad() {
    if (!(index.Build === null || index.Build === void 0 ? void 0 : index.Build.isBrowser))
      return;
    setTimeout(() => {
      this.qrCodeScanner = new window.Html5QrcodeScanner("reader", {
        fps: 10,
        qrbox: 250,
      });
      this.qrCodeScanner.render(this.onScanSuccess.bind(this));
    }, 100);
  }
  render() {
    return [
      index.h("ion-header", null, index.h("ion-toolbar", null, index.h("ion-title", null, "Scan QR Code"), index.h("ion-buttons", { slot: "end" }, index.h("ion-button", { onClick: () => this.floodteamCloseModal.emit(), style: {
          "--color": "var(--ion-text-color)",
          "--color-hover": "var(--ion-color-danger",
        } }, index.h("ion-icon", { slot: "icon-only", name: "close-circle-outline" }))))),
      index.h("ion-content", null, index.h("div", { id: "reader" })),
    ];
  }
};
ModalScanner.style = modalScannerCss;

exports.modal_scanner = ModalScanner;

//# sourceMappingURL=modal-scanner.cjs.entry.js.map