import l from "./index-getBasePlacement.js";
import f from "./index-getVariation.js";
import x from "./index-getMainAxisFromPlacement.js";
import { left as y, right as g, bottom as p, top as u, end as v, start as b } from "./index-enums.js";
function A(o) {
  var e = o.reference, a = o.element, i = o.placement, n = i ? l(i) : null, s = i ? f(i) : null, c = e.x + e.width / 2 - a.width / 2, h = e.y + e.height / 2 - a.height / 2, t;
  switch (n) {
    case u:
      t = {
        x: c,
        y: e.y - a.height
      };
      break;
    case p:
      t = {
        x: c,
        y: e.y + e.height
      };
      break;
    case g:
      t = {
        x: e.x + e.width,
        y: h
      };
      break;
    case y:
      t = {
        x: e.x - a.width,
        y: h
      };
      break;
    default:
      t = {
        x: e.x,
        y: e.y
      };
  }
  var r = n ? x(n) : null;
  if (r != null) {
    var m = r === "y" ? "height" : "width";
    switch (s) {
      case b:
        t[r] = t[r] - (e[m] / 2 - a[m] / 2);
        break;
      case v:
        t[r] = t[r] + (e[m] / 2 - a[m] / 2);
        break;
    }
  }
  return t;
}
export {
  A as default
};
