import { b as l, Y as z, x as p, j as t, aP as B } from "./index-c65ca4a4.mjs";
const N = (e) => {
  var o;
  return ((o = e == null ? void 0 : e.closest(".innerZoomElementWrapper")) == null ? void 0 : o.getBoundingClientRect()) || { x: 0, y: 0 };
}, Y = ({
  trigger: e,
  children: o,
  position: g = "left",
  closeOnItemClick: x
}) => {
  var d;
  const [r, i] = l(!1), [u, h] = l(0), [k, C] = l(0), s = z(null), m = () => {
    if (!r && s.current) {
      const n = N(s.current);
      let { x: a, y: f, width: y, height: R } = s.current.getBoundingClientRect();
      a -= n.x, f -= n.y;
      const w = g === "left" ? a : a - y;
      i(!0), h(w), C(f + R);
    } else
      i(!1);
  }, v = {
    top: `${k}px`,
    left: `${u}px`
  }, b = (n) => {
    n.target === n.currentTarget && i(!1);
  }, j = () => {
    x && i(!1);
  };
  let c = "";
  c = p(
    "fixed z-50 mt-2 origin-top-right rounded bg-white shadow-md ring-1 ring-[rgba(0,0,0,0.01)] focus:outline-none",
    c
  );
  const P = p(
    "fixed inset-0 z-40",
    r ? "block" : "hidden"
  );
  return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
    /* @__PURE__ */ t.jsx("div", { ref: s, onClick: m, children: e }),
    r && B(/* @__PURE__ */ t.jsxs("div", { className: "fixed z-[9999] inline-block", onClick: j, children: [
      /* @__PURE__ */ t.jsx("div", { className: P, "data-testid": "popover-overlay", onClick: b }),
      /* @__PURE__ */ t.jsx("div", { className: c, "data-testid": "popover-content", style: v, children: o })
    ] }), ((d = s.current) == null ? void 0 : d.closest(".admin-x-settings")) || document.body)
  ] });
};
export {
  Y as P
};
//# sourceMappingURL=Popover-016ae0d0.mjs.map
