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

import Vue from 'vue';
import '../../chunks/index.js';
import { PREFIX } from '../../config.js';
import { getAttach, removeClass } from '../../utils/dom.js';
import _Loading from './loading.js';
import { l as log } from '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import '../../utils/render-node.js';
import 'lodash';
import '../../utils/transfer-dom.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';
import '../../utils/mixins.js';
import './props.js';
import './icon/gradient.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';

const lockClass = `${PREFIX}-loading--lock`;
let fullScreenLoadingInstance = null;
function createLoading(options) {
  const props = {
    ...options
  };
  const loading = new _Loading({
    propsData: {
      ...props
    }
  }).$mount();
  const attach = getAttach(props.attach);
  if (attach) attach.appendChild(loading.$el);else 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) {
    removeClass(document.body, lockClass);
    fullScreenLoadingInstance.hide();
    fullScreenLoadingInstance = null;
    return;
  }
  return createLoading(props);
}
const LoadingPlugin = produceLoading;
LoadingPlugin.install = () => {
  Vue.prototype.$loading = produceLoading;
};

export { LoadingPlugin, LoadingPlugin as default };
//# sourceMappingURL=plugin.js.map
