import { evaluate as k, getPaddingObject as q, getAlignmentAxis as B, getAlignment as C, clamp as F, getAxisLength as G } from "../../../../../../../@floating-ui_utils@0.2.10/node_modules/@floating-ui/utils/dist/floating-ui.utils.js";
const I = (i) => ({
  name: "arrow",
  options: i,
  async fn(c) {
    var y, j;
    const {
      x: M,
      y: v,
      placement: h,
      rects: n,
      platform: s,
      elements: l,
      middlewareData: z
    } = c, {
      element: g,
      padding: E = 0,
      offsetParent: H = "real"
    } = k(i, c) || {};
    if (g == null)
      return {};
    const A = q(E), d = {
      x: M,
      y: v
    }, e = B(h), t = G(e), r = await s.getDimensions(g), m = e === "y", L = m ? "top" : "left", R = m ? "bottom" : "right", O = m ? "clientHeight" : "clientWidth", S = n.reference[t] + n.reference[e] - d[e] - n.floating[t], T = d[e] - n.reference[e], W = H === "real" ? await ((y = s.getOffsetParent) == null ? void 0 : y.call(s, g)) : l.floating;
    let a = l.floating[O] || n.floating[t];
    (!a || !await ((j = s.isElement) == null ? void 0 : j.call(s, W))) && (a = l.floating[O] || n.floating[t]);
    const Y = S / 2 - T / 2, p = a / 2 - r[t] / 2 - 1, u = Math.min(A[L], p), b = Math.min(A[R], p), f = u, D = a - r[t] - b, o = a / 2 - r[t] / 2 + Y, P = F(f, o, D), w = !z.arrow && C(h) != null && o !== P && n.reference[t] / 2 - (o < f ? u : b) - r[t] / 2 < 0, x = w ? o < f ? o - f : o - D : 0;
    return {
      [e]: d[e] + x,
      data: {
        [e]: P,
        centerOffset: o - P - x,
        ...w && {
          alignmentOffset: x
        }
      },
      reset: w
    };
  }
}), K = (i, c) => ({
  ...I(i),
  options: [i, c]
});
export {
  K as arrow,
  I as baseArrow
};
