// @ts-nocheck
import * as React from 'react';
import classNames from 'classnames';
import _compact from 'lodash/compact';
import _entries from 'lodash/entries';
function _slicedToArray(arr, i) {
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _nonIterableRest() {
  throw new TypeError('Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
}
function _unsupportedIterableToArray(o, minLen) {
  if (!o) return;
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
  if (typeof o === 'string') return _arrayLikeToArray(o, minLen);
  var n = Object.prototype.toString.call(o).slice(8, -1);
  if (n === 'Object' && o.constructor) n = o.constructor.name;
  if (n === 'Map' || n === 'Set') return Array.from(o);
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
  if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
  if (len == null || len > arr.length) len = arr.length;
  for (var i = 0, arr2 = new Array(len); i < len; i++) {
    arr2[i] = arr[i];
  }
  return arr2;
}
function _iterableToArrayLimit(arr, i) {
  if (typeof Symbol === 'undefined' || !(Symbol.iterator in Object(arr))) return;
  var _arr = [];
  var _n = true;
  var _d = false;
  var _e = undefined;
  try {
    for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
      _arr.push(_s.value);
      if (i && _arr.length === i) break;
    }
  } catch (err) {
    _d = true;
    _e = err;
  } finally {
    try {
      if (!_n && _i['return'] != null) _i['return']();
    } finally {
      // eslint-disable-next-line no-unsafe-finally
      if (_d) throw _e;
    }
  }
  return _arr;
}
function _arrayWithHoles(arr) {
  if (Array.isArray(arr)) return arr;
}
export var getModifyName = function getModifyName(modifyName, modifyValue) {
  switch (modifyValue) {
    case 'default':
      modifyName = '';
      break;
    case 'large':
      modifyName = 'lg';
      break;
    case 'middle':
      modifyName = 'md';
      break;
    case 'small':
      modifyName = 'sm';
      break;
    default:
      modifyName = modifyValue;
      break;
  }
  return modifyName;
};
export var getPrefixCls = function getPrefixCls() {
  var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'cyber';
  return function (suffix, prefixCls) {
    if (!prefixCls) {
      prefixCls = suffix ? ''.concat(prefix, '-').concat(suffix) : prefix;
    }
    return prefixCls;
  };
};
export var getPrettyCls = function getPrettyCls() {
  var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'cyber';
  return function (suffix, prefixCls, outerClassName) {
    prefixCls = getPrefixCls(prefix)(suffix, prefixCls);
    return function (modifiers, element, innerClassName) {
      if (typeof modifiers === 'string') {
        innerClassName = element;
        element = modifiers;
        modifiers = {};
      }
      var elementName = _compact([prefixCls, element]).join('-');
      var modifierNames = _entries(modifiers).reduce(function (acc, cur) {
        var _cur = _slicedToArray(cur, 2),
          key = _cur[0],
          value = _cur[1];
        var modifyName = key;
        if (typeof value === 'string') {
          modifyName = getModifyName(modifyName, value);
          if (modifyName) {
            acc[''.concat(elementName, '-').concat(modifyName)] = !!value;
          }
        } else {
          acc[''.concat(elementName, '-').concat(modifyName)] = !!value;
        }
        return acc;
      }, {});
      return classNames(elementName, modifierNames, outerClassName, innerClassName);
    };
  };
};
var ConfigContext = /*#__PURE__*/React.createContext({
  iconPrefix: 'icon-b',
  getPrefixCls: getPrefixCls(),
  getPrettyCls: getPrettyCls()
});
export var ConfigConsumer = ConfigContext.Consumer;
export var ConfigProvider = ConfigContext.Provider;
export default ConfigContext;