/**
 * 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 log = require('../../chunks/log.js');
var config = require('../../config.js');
var utils_dom = require('../../utils/dom.js');
var components_loading_loading = require('./loading.js');
require('../../chunks/_commonjsHelpers-2e6815bd.js');
require('raf');
require('lodash/isString');
require('../../utils/easing.js');
require('../../utils/render-node.js');
require('lodash');
require('../../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');
require('../../utils/mixins.js');
require('./props.js');
require('./icon/gradient.js');
require('../../chunks/defineProperty-838e4192.js');
require('../../chunks/set-style.js');
require('../../chunks/helper2.js');

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

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

const lockClass = `${config.PREFIX}-loading--lock`;
let fullScreenLoadingInstance = null;
function createLoading(options) {
  const props = {
    ...options
  };
  const loading = new components_loading_loading["default"]({
    propsData: {
      ...props
    }
  }).$mount();
  const attach = utils_dom.getAttach(props.attach);
  if (attach) attach.appendChild(loading.$el);else log.log.error("LoadingPlugin", "attach is not exist");
  const loadingInstance = {
    hide: () => {
      loading.loading = false;
      loading.$el.parentNode.removeChild(loading.$el);
    }
  };
  return loadingInstance;
}
function produceLoading(props) {
  if (props === true) {
    fullScreenLoadingInstance = createLoading({
      fullscreen: true,
      loading: true,
      attach: "body"
    });
    return fullScreenLoadingInstance;
  }
  if (props === false) {
    utils_dom.removeClass(document.body, lockClass);
    fullScreenLoadingInstance.hide();
    fullScreenLoadingInstance = null;
    return;
  }
  return createLoading(props);
}
const LoadingPlugin = produceLoading;
LoadingPlugin.install = () => {
  Vue__default["default"].prototype.$loading = produceLoading;
};

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