"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _vue = require("vue");

var _vueTypes = _interopRequireDefault(require("./vue-types"));

var _default2 = (0, _vue.defineComponent)({
  name: 'Portal',
  inheritAttrs: false,
  props: {
    getContainer: _vueTypes.default.func.isRequired,
    didUpdate: _vueTypes.default.func
  },
  setup: function setup(props, _ref) {
    var slots = _ref.slots;
    var container = (0, _vue.ref)();
    (0, _vue.onMounted)(function () {
      container.value = props.getContainer();
    });
    (0, _vue.onUpdated)(function () {
      (0, _vue.nextTick)(function () {
        var _props$nextTick;

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

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

exports.default = _default2;