/**
 * ldesign v0.4.6
 * (c) 2023 ldesign
 * @license MIT
 */

import isObject from 'lodash/isObject';
import mapKeys from 'lodash/mapKeys';
import isEqual from 'lodash/isEqual';
import { LoadingPlugin } from './plugin.js';
import '@babel/runtime/helpers/defineProperty';
import 'vue';
import '../config.js';
import '../utils/dom.js';
import 'raf';
import 'lodash/isString';
import '../utils/easing.js';
import './loading.js';
import '../utils/render-tnode.js';
import '@babel/runtime/helpers/typeof';
import '@vue/composition-api';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/transfer-dom.js';
import '../config-provider/config-receiver.js';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '../_chunks/dep-be599ec8.js';
import 'dayjs';
import '../_chunks/dep-67ff4010.js';
import '../config-provider/type.js';
import '../utils/mixins.js';
import './props.js';
import './icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import '@babel/runtime/helpers/slicedToArray';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import 'lodash/isArray';

var INSTANCE_KEY = Symbol("TdLoading");
var createInstance = function createInstance(el, binding) {
  var _binding$modifiers = binding.modifiers,
    fullscreen = _binding$modifiers.fullscreen,
    inheritColor = _binding$modifiers.inheritColor;
  var options = {
    attach: function attach() {
      return el;
    },
    fullscreen: fullscreen !== null && fullscreen !== void 0 ? fullscreen : false,
    inheritColor: inheritColor !== null && inheritColor !== void 0 ? inheritColor : false,
    loading: binding.value
  };
  if (isObject(binding.value)) {
    mapKeys(binding.value, function (value, key) {
      options[key] = value;
    });
  }
  el[INSTANCE_KEY] = {
    options: options,
    instance: LoadingPlugin(options)
  };
};
var vLoading = {
  inserted: function inserted(el, binding) {
    if (binding.value) createInstance(el, binding);
  },
  update: function update(el, binding) {
    var instance = el[INSTANCE_KEY];
    var value = binding.value,
      oldValue = binding.oldValue;
    if (!isEqual(value, oldValue)) {
      var _value$loading;
      var loading = (_value$loading = value === null || value === void 0 ? void 0 : value.loading) !== null && _value$loading !== void 0 ? _value$loading : value;
      if (loading) createInstance(el, binding);else instance === null || instance === void 0 ? void 0 : instance.instance.hide();
    }
  }
};

export { vLoading as default };
//# sourceMappingURL=directive.js.map
