/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Vue = require('vue');
var components_imageViewer_props = require('../props.js');
var utils_dom = require('../../../utils/dom.js');
require('raf');
require('lodash/isString');
require('../../../chunks/log.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../utils/easing.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

var Container = Vue__default["default"].extend({
  props: {
    mode: components_imageViewer_props["default"].mode,
    renderModal: Function,
    renderViewer: Function
  },
  data() {
    return {
      content: null
    };
  },
  methods: {
    mountContent() {
      if (this.content) return;
      const _this = this;
      const elm = document.createElement("div");
      elm.style.cssText = "position: absolute; top: 0px; left: 0px; width: 100%";
      this.content = new this.$root.constructor({
        render() {
          return _this.mode === "modeless" ? _this.renderModal() : _this.renderViewer();
        },
        destroyed() {
          if (_this.content.$el) utils_dom.removeDom(_this.content.$el);
          _this.content = null;
        }
      });
      utils_dom.getAttach(document.body).appendChild(elm);
      this.content.$mount(elm);
    },
    unmountContent() {
      var _this$content, _this$content$$destro;
      (_this$content = this.content) === null || _this$content === void 0 ? void 0 : (_this$content$$destro = _this$content.$destroy) === null || _this$content$$destro === void 0 ? void 0 : _this$content$$destro.call(_this$content);
    }
  },
  render() {
    var _children$;
    const h = arguments[0];
    const children = this.$slots.default || [];
    if (children.length > 1 || !((_children$ = children[0]) !== null && _children$ !== void 0 && _children$.tag)) return h("span", [children]);
    return children[0];
  }
});

exports["default"] = Container;
//# sourceMappingURL=Container.js.map
