import { b9 as S, cJ as N, w as y, a0 as o, ba as O, bv as v, ey as z, bd as I, bB as T, ez as F, bf as J, U as W, P as a, V as t, eA as _, bx as A, bz as H, bE as $, bh as x, bi as d, bj as u, bg as b, bk as G, bl as K, bn as Q, bo as V, bp as X, eB as Y } from "./684d2f28.js";
import { ButtonCompWrapper as Z, Button100 as ee, buttonRefMethods as te } from "./926d8ea1.js";
import ne, { useState as s, useEffect as oe, useRef as ae, Suspense as se, useContext as h } from "react";
import "react-dom";
import "./d6402597.js";
const ie = S.div`
  color: #f5222d;
  height: 100px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
`, re = S.div`
  video,
  .ant-skeleton {
    height: 400px;
    max-height: 70vh;
    position: relative;
    object-fit: cover;
    background-color: #000;
  }
  .ant-skeleton {
    h3,
    li {
      background-color: transparent;
    }
  }
`, le = S(Y)`
  top: 10vh;
  .react-draggable {
    max-width: 100%;
    width: 500px;
  }
`, ce = ne.lazy(() => import("./7e042a22.js").then((m) => m.i)), de = function() {
  const m = {
    data: N("data"),
    text: y(O, o("scanner.text")),
    continuous: v,
    uniqueData: y(v, !0),
    maskClosable: y(v, !0),
    onEvent: z,
    disabled: I,
    style: T(F),
    viewRef: J
  };
  return new W(m, (e) => {
    const [r, f] = s(!1), [k, g] = s(""), [C, B] = s({
      facingMode: "environment"
    }), [D, R] = s([]), [P, M] = s(!1), [E, p] = s(!1);
    oe(() => {
      !r && E && e.onEvent("success");
    }, [E, r]);
    const i = ae([]), j = (n, l) => {
      if (l)
        if (e.continuous) {
          i.current = [...i.current, l.text];
          const w = e.uniqueData ? [...new Set(i.current)] : i.current;
          e.data.onChange(w), e.onEvent("success");
        } else
          e.data.onChange([l.text]), f(!1), p(!0);
      else
        p(!1);
    }, U = (n) => {
      typeof n == "string" ? g(n) : n.message === "getUserMedia is not implemented in this browser" ? g(o("scanner.errTip")) : g(n.message), p(!1);
    }, q = () => {
      navigator.mediaDevices.enumerateDevices().then((n) => {
        const w = n.filter((c) => c.kind === "videoinput").map((c, L) => ({
          label: c.label || o("scanner.camera", {
            index: L + 1
          }),
          key: c.deviceId
        }));
        R(w);
      });
    };
    return /* @__PURE__ */ a(Z, {
      disabled: e.disabled,
      children: [/* @__PURE__ */ t(ee, {
        ref: e.viewRef,
        $buttonStyle: e.style,
        disabled: e.disabled,
        onClick: () => {
          e.onEvent("click"), f(!0), i.current = [];
        },
        children: /* @__PURE__ */ t("span", {
          children: e.text
        })
      }), /* @__PURE__ */ t(le, {
        showOkButton: !1,
        showCancelButton: !1,
        open: r,
        maskClosable: e.maskClosable,
        destroyOnClose: !0,
        onCancel: () => {
          f(!1), e.onEvent("close");
        },
        children: k ? /* @__PURE__ */ t(ie, {
          children: k
        }) : r && /* @__PURE__ */ a(re, {
          children: [/* @__PURE__ */ t(se, {
            fallback: /* @__PURE__ */ t(_, {}),
            children: /* @__PURE__ */ t(ce, {
              delay: 1e3,
              onUpdate: j,
              onError: U,
              videoConstraints: C
            }, JSON.stringify(C))
          }), /* @__PURE__ */ t("div", {
            style: {
              height: "42px"
            },
            onClick: () => {
              M(!1);
            },
            children: /* @__PURE__ */ t(A, {
              placement: "bottomRight",
              trigger: ["click"],
              open: P,
              onOpenChange: (n) => M(n),
              dropdownRender: () => /* @__PURE__ */ t(H, {
                items: D,
                onClick: (n) => B({
                  ...C,
                  deviceId: n.key
                })
              }),
              children: /* @__PURE__ */ t($, {
                style: {
                  float: "right",
                  marginTop: "10px"
                },
                onClick: (n) => {
                  n.stopPropagation(), q();
                },
                children: o("scanner.changeCamera")
              })
            })
          })]
        })
      })]
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ a(x, {
    children: [/* @__PURE__ */ t(d, {
      name: u.basic,
      children: e.text.propertyView({
        label: o("text")
      })
    }), (h(b).editorModeStatus === "logic" || h(b).editorModeStatus === "both") && /* @__PURE__ */ a(x, {
      children: [/* @__PURE__ */ a(d, {
        name: u.interaction,
        children: [e.onEvent.getPropertyView(), G(e), K(e)]
      }), /* @__PURE__ */ a(d, {
        name: u.advanced,
        children: [e.continuous.propertyView({
          label: o("scanner.continuous")
        }), e.continuous.getView() && e.uniqueData.propertyView({
          label: o("scanner.uniqueData")
        }), e.maskClosable.propertyView({
          label: o("scanner.maskClosable")
        })]
      })]
    }), (h(b).editorModeStatus === "layout" || h(b).editorModeStatus === "both") && /* @__PURE__ */ t(x, {
      children: /* @__PURE__ */ t(d, {
        name: u.style,
        children: e.style.getPropertyView()
      })
    })]
  })).setExposeMethodConfigs(te).build();
}(), ge = Q(de, [new V("data", o("data")), new V("text", o("button.textDesc")), ...X]);
export {
  ge as ScannerComp
};
