import { h, render } from "vue";
import _sfc_main from "./OLoading.vue.mjs";
let vLoadingOption = {};
const setVLoadingOption = (option) => {
  vLoadingOption = option;
};
const vLoading = {
  mounted(el, binding) {
    const vnode = h(
      _sfc_main,
      Object.assign(vLoadingOption, {
        visible: binding.value,
        wrapper: binding.modifiers.body ? "body" : null,
        mask: !binding.modifiers.nomask
      })
    );
    if (binding.modifiers.body) {
      render(vnode, document.body);
    } else {
      render(vnode, el);
    }
    const vm = vnode.component;
    el.__loading_data = {
      instance: vm
    };
  },
  updated(el, binding) {
    if (binding.value !== binding.oldValue) {
      const data = el.__loading_data;
      if (data) {
        data.instance.exposed.toggle(!!binding.value);
      }
    }
  }
};
export {
  setVLoadingOption,
  vLoading
};
