import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { createVNode as _createVNode } from "vue";
import { defineComponent, ref, Transition } from 'vue';
import { flattenChildren } from '../../_util/props-util';
import classNames from '../../_util/classNames';
import { mobileProps } from './interface';
export default defineComponent({
  name: 'MobilePopupInner',
  inheritAttrs: false,
  props: mobileProps,
  emits: ['mouseenter', 'mouseleave', 'mousedown', 'touchstart', 'align'],
  setup: function setup(props, _ref) {
    var expose = _ref.expose,
      slots = _ref.slots;
    var elementRef = ref();
    expose({
      forceAlign: function forceAlign() {},
      getElement: function getElement() {
        return elementRef.value;
      }
    });
    return function () {
      var _slots$default;
      var zIndex = props.zIndex,
        visible = props.visible,
        prefixCls = props.prefixCls,
        _props$mobile = props.mobile;
      _props$mobile = _props$mobile === void 0 ? {} : _props$mobile;
      var popupClassName = _props$mobile.popupClassName,
        popupStyle = _props$mobile.popupStyle,
        _props$mobile$popupMo = _props$mobile.popupMotion,
        popupMotion = _props$mobile$popupMo === void 0 ? {} : _props$mobile$popupMo,
        popupRender = _props$mobile.popupRender;
      // ======================== Render ========================
      var mergedStyle = _objectSpread({
        zIndex: zIndex
      }, popupStyle);
      var childNode = flattenChildren((_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots));
      // Wrapper when multiple children
      if (childNode.length > 1) {
        var _childNode = function () {
          return childNode;
        }();
        childNode = _createVNode("div", {
          "class": "".concat(prefixCls, "-content")
        }, [childNode]);
      }
      // Mobile support additional render
      if (popupRender) {
        childNode = popupRender(childNode);
      }
      var mergedClassName = classNames(prefixCls, popupClassName);
      return _createVNode(Transition, _objectSpread({
        "ref": elementRef
      }, popupMotion), {
        default: function _default() {
          return [visible ? _createVNode("div", {
            "class": mergedClassName,
            "style": mergedStyle
          }, [childNode]) : null];
        }
      });
    };
  }
});