var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/hooks/usePopoverPosition.ts
var usePopoverPosition_exports = {};
__export(usePopoverPosition_exports, {
  usePopoverPosition: () => usePopoverPosition
});
module.exports = __toCommonJS(usePopoverPosition_exports);
var defaultPopoverPositionOptions = {
  edgePadding: 16,
  outerGap: 4,
  horizontalAlignment: "leftInside",
  verticalAlignment: "bottomOutside",
  disabled: false
};
var usePopoverPosition = (trigger, options) => {
  const {
    edgePadding,
    outerGap,
    verticalAlignment,
    horizontalAlignment,
    disabled
  } = { ...defaultPopoverPositionOptions, ...options };
  if (disabled || !trigger) {
    return {};
  }
  const left = {
    leftOutside: trigger.left - outerGap,
    leftInside: trigger.left,
    rightOutside: trigger.right + outerGap,
    rightInside: trigger.right,
    center: trigger.left + trigger.width / 2
  }[horizontalAlignment];
  const top = {
    topOutside: trigger.top - outerGap,
    topInside: trigger.top,
    bottomOutside: trigger.bottom + outerGap,
    bottomInside: trigger.bottom,
    center: trigger.top + trigger.height / 2
  }[verticalAlignment];
  const translateX = {
    leftOutside: "-100%",
    leftInside: void 0,
    rightOutside: void 0,
    rightInside: "-100%",
    center: "-50%"
  }[horizontalAlignment];
  const translateY = {
    topOutside: "-100%",
    topInside: void 0,
    bottomOutside: void 0,
    bottomInside: "-100%",
    center: "-50%"
  }[verticalAlignment];
  return {
    left: Math.max(left, edgePadding),
    top: Math.max(top, edgePadding),
    translate: [translateX ?? "0", translateY ?? "0"].join(" ")
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  usePopoverPosition
});
//# sourceMappingURL=usePopoverPosition.cjs.map