import { ownerDocument as x } from "../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/owner.js";
import { getSide as E } from "../../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";
import { getWindow as S } from "../../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js";
const d = {
  sideX: "left",
  sideY: "top"
}, V = {
  name: "adaptiveOrigin",
  async fn(u) {
    var g, m;
    const {
      x: s,
      y: a,
      rects: {
        floating: h
      },
      elements: {
        floating: n
      },
      platform: t,
      strategy: p,
      placement: y
    } = u, e = S(n), c = e.getComputedStyle(n);
    if (!(c.transitionDuration !== "0s" && c.transitionDuration !== ""))
      return {
        x: s,
        y: a,
        data: d
      };
    const r = await ((g = t.getOffsetParent) == null ? void 0 : g.call(t, n));
    let i = {
      width: 0,
      height: 0
    };
    if (p === "fixed" && (e != null && e.visualViewport))
      i = {
        width: e.visualViewport.width,
        height: e.visualViewport.height
      };
    else if (r === e) {
      const w = x(n);
      i = {
        width: w.documentElement.clientWidth,
        height: w.documentElement.clientHeight
      };
    } else await ((m = t.isElement) == null ? void 0 : m.call(t, r)) && (i = await t.getDimensions(r));
    const o = E(y);
    let f = s, l = a;
    o === "left" && (f = i.width - (s + h.width)), o === "top" && (l = i.height - (a + h.height));
    const D = o === "left" ? "right" : d.sideX, v = o === "top" ? "bottom" : d.sideY;
    return {
      x: f,
      y: l,
      data: {
        sideX: D,
        sideY: v
      }
    };
  }
};
export {
  d as DEFAULT_SIDES,
  V as adaptiveOrigin
};
