"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.default = exports.CustomConsumer = exports.CustomContext = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));

var _react = _interopRequireDefault(require("react"));

var _prefix = require("../utils/prefix");

var CustomContext = /*#__PURE__*/_react.default.createContext({});

exports.CustomContext = CustomContext;
var Consumer = CustomContext.Consumer,
    Provider = CustomContext.Provider;
exports.CustomConsumer = Consumer;

var CustomProvider = function CustomProvider(props) {
  var children = props.children,
      _props$classPrefix = props.classPrefix,
      classPrefix = _props$classPrefix === void 0 ? (0, _prefix.getClassNamePrefix)() : _props$classPrefix,
      rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["children", "classPrefix"]);

  var value = _react.default.useMemo(function () {
    return (0, _extends2.default)({
      classPrefix: classPrefix
    }, rest);
  }, [classPrefix, rest]);

  return /*#__PURE__*/_react.default.createElement(Provider, {
    value: value
  }, children);
};

var _default = CustomProvider;
exports.default = _default;