import { a3 as S, db as L, w as y, a4 as a, X as N, V as v, eH as O, bX as H, a5 as T, bZ as W, S as X, U as _, ad as o, b_ as $, H as t, b$ as F, cX as z, ao as J, as as Z, c8 as A, I as x, ae as d, af as u, am as h, c0 as G, ag as K, c7 as Q, ah as Y, aj as D, c1 as ee, cW as te } from "./56c67d3b.js";
import ne, { useState as s, useEffect as ae, useRef as oe, Suspense as se, useContext as m } from "react";
import "react-dom";
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(te)`
  top: 10vh;
  .react-draggable {
    max-width: 100%;
    width: 500px;
  }
`, ce = ne.lazy(() => import("./db794bd5.js").then((f) => f.i)), de = function() {
  const f = {
    data: L("data"),
    text: y(N, a("scanner.text")),
    continuous: v,
    uniqueData: y(v, !0),
    maskClosable: y(v, !0),
    onEvent: O,
    disabled: H,
    style: T(W, "style"),
    viewRef: X
  };
  return new _(f, (e) => {
    const [r, g] = s(!1), [k, C] = s(""), [b, V] = s({
      facingMode: "environment"
    }), [B, R] = s([]), [P, M] = s(!1), [E, p] = s(!1);
    ae(() => {
      !r && E && e.onEvent("success");
    }, [E, r]);
    const i = oe([]), 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]), g(!1), p(!0);
      else
        p(!1);
    }, U = (n) => {
      typeof n == "string" ? C(n) : n.message === "getUserMedia is not implemented in this browser" ? C(a("scanner.errTip")) : C(n.message), p(!1);
    }, q = () => {
      navigator.mediaDevices.enumerateDevices().then((n) => {
        const w = n.filter((c) => c.kind === "videoinput").map((c, I) => ({
          label: c.label || a("scanner.camera", {
            index: I + 1
          }),
          key: c.deviceId
        }));
        R(w);
      });
    };
    return /* @__PURE__ */ o($, {
      $disabled: e.disabled,
      children: [/* @__PURE__ */ t(F, {
        ref: e.viewRef,
        $buttonStyle: e.style,
        disabled: e.disabled,
        onClick: () => {
          e.onEvent("click"), g(!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: () => {
          g(!1), e.onEvent("close");
        },
        children: k ? /* @__PURE__ */ t(ie, {
          children: k
        }) : r && /* @__PURE__ */ o(re, {
          children: [/* @__PURE__ */ t(se, {
            fallback: /* @__PURE__ */ t(z, {}),
            children: /* @__PURE__ */ t(ce, {
              delay: 1e3,
              onUpdate: j,
              onError: U,
              videoConstraints: b
            }, JSON.stringify(b))
          }), /* @__PURE__ */ t("div", {
            style: {
              height: "42px"
            },
            onClick: () => {
              M(!1);
            },
            children: /* @__PURE__ */ t(J, {
              placement: "bottomRight",
              trigger: ["click"],
              open: P,
              onOpenChange: (n) => M(n),
              dropdownRender: () => /* @__PURE__ */ t(Z, {
                items: B,
                onClick: (n) => V({
                  ...b,
                  deviceId: n.key
                })
              }),
              children: /* @__PURE__ */ t(A, {
                style: {
                  float: "right",
                  marginTop: "10px"
                },
                onClick: (n) => {
                  n.stopPropagation(), q();
                },
                children: a("scanner.changeCamera")
              })
            })
          })]
        })
      })]
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ o(x, {
    children: [/* @__PURE__ */ t(d, {
      name: u.basic,
      children: e.text.propertyView({
        label: a("text")
      })
    }), (m(h).editorModeStatus === "logic" || m(h).editorModeStatus === "both") && /* @__PURE__ */ o(x, {
      children: [/* @__PURE__ */ o(d, {
        name: u.interaction,
        children: [e.onEvent.getPropertyView(), G(e), K(e)]
      }), /* @__PURE__ */ o(d, {
        name: u.advanced,
        children: [e.continuous.propertyView({
          label: a("scanner.continuous")
        }), e.continuous.getView() && e.uniqueData.propertyView({
          label: a("scanner.uniqueData")
        }), e.maskClosable.propertyView({
          label: a("scanner.maskClosable")
        })]
      })]
    }), (m(h).editorModeStatus === "layout" || m(h).editorModeStatus === "both") && /* @__PURE__ */ t(x, {
      children: /* @__PURE__ */ t(d, {
        name: u.style,
        children: e.style.getPropertyView()
      })
    })]
  })).setExposeMethodConfigs(Q).build();
}(), fe = Y(de, [new D("data", a("data")), new D("text", a("button.textDesc")), ...ee]);
export {
  fe as ScannerComp
};
