import { createVNode as _createVNode, resolveDirective as _resolveDirective } from "vue";
import PropTypes from './vue-types';
import { defineComponent, nextTick, onBeforeUnmount, onUpdated, Teleport } from 'vue';
export default defineComponent({
  name: 'Portal',
  inheritAttrs: false,
  props: {
    getContainer: PropTypes.func.isRequired,
    didUpdate: PropTypes.func
  },
  setup: function setup(props, _ref) {
    var slots = _ref.slots;
    // getContainer 不会改变，不用响应式
    var container = props.getContainer();
    onUpdated(function () {
      nextTick(function () {
        var _props$didUpdate;

        (_props$didUpdate = props.didUpdate) === null || _props$didUpdate === void 0 ? void 0 : _props$didUpdate.call(props, props);
      });
    });
    onBeforeUnmount(function () {
      if (container && container.parentNode) {
        container.parentNode.removeChild(container);
      }
    });
    return function () {
      return container ? _createVNode(Teleport, {
        "to": container
      }, slots) : null;
    };
  }
});