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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var isObject = require('lodash/isObject');
var mapKeys = require('lodash/mapKeys');
var isEqual = require('lodash/isEqual');
var loading_plugin = require('./plugin.js');
require('@babel/runtime/helpers/defineProperty');
require('vue');
require('../config.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('./loading.js');
require('../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('@vue/composition-api');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/transfer-dom.js');
require('../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-7c884501.js');
require('dayjs');
require('../utils/mixins.js');
require('./props.js');
require('./icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');
require('lodash/isArray');

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

var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
var mapKeys__default = /*#__PURE__*/_interopDefaultLegacy(mapKeys);
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);

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__default["default"](binding.value)) {
    mapKeys__default["default"](binding.value, function (value, key) {
      options[key] = value;
    });
  }
  el[INSTANCE_KEY] = {
    options: options,
    instance: loading_plugin.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__default["default"](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();
    }
  }
};

exports["default"] = vLoading;
//# sourceMappingURL=directive.js.map
