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

import Vue from 'vue';
import '../../chunks/index.js';
import { getAttach } from '../../utils/dom.js';
import _Dialog from './dialog.js';
import { l as log } from '../../chunks/log.js';
import '../../chunks/_commonjsHelpers-2e6815bd.js';
import 'raf';
import 'lodash/isString';
import '../../utils/easing.js';
import 'lodash/isNumber';
import 'lodash/throttle';
import '@ldesign/icons-vue';
import '../button/index.js';
import '../../utils/with-install.js';
import 'lodash';
import '../../config.js';
import '../button/button.js';
import '../loading/index.js';
import '../loading/loading.js';
import '../../utils/render-node.js';
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 '../loading/props.js';
import '../loading/icon/gradient.js';
import '../../chunks/defineProperty-838e4192.js';
import '../../chunks/set-style.js';
import '../../chunks/helper2.js';
import '../loading/style/css.js';
import '../loading/type.js';
import '../loading/plugin.js';
import '../../utils/ripple.js';
import '../button/props.js';
import '../button/style/css.js';
import '../button/type.js';
import '../../utils/event.js';
import '../../utils/helper.js';
import 'lodash/camelCase';
import '../../hooks/use-destroy-onclose.js';
import './props.js';
import './mixins/action.js';
import '../../chunks/helper.js';
import '../../chunks/_commonjsHelpers.js';
import 'lodash/isObject';
import './stack.js';

const createDialog = props => {
  const options = {
    ...props
  };
  const dialog = new _Dialog({
    propsData: {
      ...options,
      onClose: options.onClose || (() => {
        dialog.visible = false;
      })
    }
  }).$mount();
  dialog.visible = true;
  if (options.className) {
    options.className.split(" ").forEach(name => {
      dialog.$el.classList.add(name.trim());
    });
  }
  if (options.style) dialog.$el.style.cssText += options.style;
  const container = getAttach(options.attach);
  if (container) container.appendChild(dialog.$el);else log.error("DialogPlugin", "attach is not exist");
  const dialogNode = {
    show: () => {
      dialog.visible = true;
    },
    hide: () => {
      dialog.visible = false;
    },
    update: options2 => {
      Object.assign(dialog, options2);
    },
    destroy: () => {
      dialog.visible = false;
      container.contains(dialog.$el) && container.removeChild(dialog.$el);
    }
  };
  return dialogNode;
};
const confirm = props => createDialog(props);
const alert = props => {
  const options = {
    ...props
  };
  options.cancelBtn = null;
  return createDialog(options);
};
const extraApi = {
  confirm,
  alert
};
const _DialogPlugin = {
  install: () => {
    Vue.prototype.$dialog = createDialog;
    Object.keys(extraApi).forEach(funcName => {
      Vue.prototype.$dialog[funcName] = extraApi[funcName];
    });
  }
};
Object.keys(extraApi).forEach(funcName => {
  _DialogPlugin[funcName] = extraApi[funcName];
});
const DialogPlugin = _DialogPlugin;

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