import { defineComponent, createVNode, computed } from 'vue';
import Trigger from '../../vc-trigger/src/Trigger.mjs';
import DropdownMenu from './DropdownMenu.mjs';

const BUILT_IN_PLACEMENTS = {
  bottomRight: {
    points: ["tl", "br"],
    offset: [0, 4],
    overflow: {
      adjustX: 0,
      adjustY: 1
    }
  },
  bottomLeft: {
    points: ["tr", "bl"],
    offset: [0, 4],
    overflow: {
      adjustX: 0,
      adjustY: 1
    }
  },
  topRight: {
    points: ["bl", "tr"],
    offset: [0, -4],
    overflow: {
      adjustX: 0,
      adjustY: 1
    }
  },
  topLeft: {
    points: ["br", "tl"],
    offset: [0, -4],
    overflow: {
      adjustX: 0,
      adjustY: 1
    }
  }
};
var KeywordTrigger = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "KeywordTrigger",
  props: {
    loading: {
      type: Boolean,
      default: void 0
    },
    options: {
      type: Array,
      default: () => []
    },
    prefixCls: String,
    placement: String,
    visible: {
      type: Boolean,
      default: void 0
    },
    transitionName: String,
    getPopupContainer: Function,
    direction: String,
    dropdownClassName: String
  },
  setup(props, {
    slots
  }) {
    const getDropdownPrefix = () => {
      return `${props.prefixCls}-dropdown`;
    };
    const getDropdownElement = () => {
      const {
        options
      } = props;
      return createVNode(DropdownMenu, {
        "prefixCls": getDropdownPrefix(),
        "options": options
      }, {
        notFoundContent: slots.notFoundContent,
        option: slots.option
      });
    };
    const popupPlacement = computed(() => {
      const {
        placement,
        direction
      } = props;
      let popupPlacement2 = "topRight";
      if (direction === "rtl")
        popupPlacement2 = placement === "top" ? "topLeft" : "bottomLeft";
      else
        popupPlacement2 = placement === "top" ? "topRight" : "bottomRight";
      return popupPlacement2;
    });
    return () => {
      const {
        visible,
        transitionName,
        getPopupContainer
      } = props;
      return createVNode(Trigger, {
        "prefixCls": getDropdownPrefix(),
        "popupVisible": visible,
        "popup": getDropdownElement(),
        "popupClassName": props.dropdownClassName,
        "popupPlacement": popupPlacement.value,
        "popupTransitionName": transitionName,
        "builtinPlacements": BUILT_IN_PLACEMENTS,
        "getPopupContainer": getPopupContainer
      }, {
        default: slots.default
      });
    };
  }
});

export { KeywordTrigger as default };
//# sourceMappingURL=KeywordTrigger.mjs.map
