import { createVNode as _createVNode } from "vue";
import PropTypes from './vue-types';
import { defineComponent, nextTick, onBeforeUnmount, onMounted, onUpdated, ref, 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;
    var container = ref();
    onMounted(function () {
      container.value = props.getContainer();
    });
    onUpdated(function () {
      nextTick(function () {
        var _props$nextTick;

        (_props$nextTick = props.nextTick) === null || _props$nextTick === void 0 ? void 0 : _props$nextTick.call(props, props);
      });
    });
    onBeforeUnmount(function () {
      if (container.value && container.value.parentNode) {
        container.value.parentNode.removeChild(container.value);
      }
    });
    return function () {
      var _slots$default;

      return container.value ? _createVNode(Teleport, {
        "to": container.value
      }, {
        default: function _default() {
          return [(_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
        }
      }) : null;
    };
  }
});