import u from "./index-getBasePlacement.js";
import { placements as l, left as d, right as v, top as x } from "./index-enums.js";
function O(s, e, n) {
  var i = u(s), f = [d, x].indexOf(i) >= 0 ? -1 : 1, o = typeof n == "function" ? n(Object.assign({}, e, {
    placement: s
  })) : n, t = o[0], a = o[1];
  return t = t || 0, a = (a || 0) * f, [d, v].indexOf(i) >= 0 ? {
    x: a,
    y: t
  } : {
    x: t,
    y: a
  };
}
function y(s) {
  var e = s.state, n = s.options, i = s.name, f = n.offset, o = f === void 0 ? [0, 0] : f, t = l.reduce(function(r, p) {
    return r[p] = O(p, e.rects, o), r;
  }, {}), a = t[e.placement], m = a.x, c = a.y;
  e.modifiersData.popperOffsets != null && (e.modifiersData.popperOffsets.x += m, e.modifiersData.popperOffsets.y += c), e.modifiersData[i] = t;
}
const $ = {
  name: "offset",
  enabled: !0,
  phase: "main",
  requires: ["popperOffsets"],
  fn: y
};
export {
  $ as default,
  O as distanceAndSkiddingToXY
};
