import T from "../utils/getBasePlacement.es.js";
import H from "../dom-utils/getLayoutRect.es.js";
import M from "../dom-utils/contains.es.js";
import V from "../dom-utils/getOffsetParent.es.js";
import L from "../utils/getMainAxisFromPlacement.es.js";
import { within as N } from "../utils/within.es.js";
import S from "../utils/mergePaddingObject.es.js";
import $ from "../utils/expandToHashMap.es.js";
import { basePlacements as q, top as R, left as d, bottom as G, right as O } from "../enums.es.js";
import { isHTMLElement as z } from "../dom-utils/instanceOf.es.js";
var A = function(e, r) {
  return e = typeof e == "function" ? e(Object.assign({}, r.rects, {
    placement: r.placement
  })) : e, S(typeof e != "number" ? e : $(e, q));
};
function B(a) {
  var e, r = a.state, n = a.name, t = a.options, s = r.elements.arrow, m = r.modifiersData.popperOffsets, p = T(r.placement), o = L(p), P = [d, O].indexOf(p) >= 0, i = P ? "height" : "width";
  if (!(!s || !m)) {
    var c = A(t.padding, r), l = H(s), b = o === "y" ? R : d, h = o === "y" ? G : O, E = r.rects.reference[i] + r.rects.reference[o] - m[o] - r.rects.popper[i], g = m[o] - r.rects.reference[o], f = V(s), v = f ? o === "y" ? f.clientHeight || 0 : f.clientWidth || 0 : 0, x = E / 2 - g / 2, y = c[b], j = v - l[i] - c[h], u = v / 2 - l[i] / 2 + x, w = N(y, u, j), D = o;
    r.modifiersData[n] = (e = {}, e[D] = w, e.centerOffset = w - u, e);
  }
}
function F(a) {
  var e = a.state, r = a.options, n = r.element, t = n === void 0 ? "[data-popper-arrow]" : n;
  if (t != null && !(typeof t == "string" && (t = e.elements.popper.querySelector(t), !t))) {
    if (process.env.NODE_ENV !== "production" && (z(t) || console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', "To use an SVG arrow, wrap it in an HTMLElement that will be used as", "the arrow."].join(" "))), !M(e.elements.popper, t)) {
      process.env.NODE_ENV !== "production" && console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', "element."].join(" "));
      return;
    }
    e.elements.arrow = t;
  }
}
const Y = {
  name: "arrow",
  enabled: !0,
  phase: "main",
  fn: B,
  effect: F,
  requires: ["popperOffsets"],
  requiresIfExists: ["preventOverflow"]
};
export {
  Y as default
};
//# sourceMappingURL=arrow.es.js.map
