"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
var _ThemeContext = require("./ThemeContext");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/ThemeProvider/ThemeProvider.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/** ThemeProvider */
var ThemeProvider = /*#__PURE__*/function (_React$PureComponent) {
  function ThemeProvider() {
    (0, _classCallCheck2["default"])(this, ThemeProvider);
    return _callSuper(this, ThemeProvider, arguments);
  }
  (0, _inherits2["default"])(ThemeProvider, _React$PureComponent);
  return (0, _createClass2["default"])(ThemeProvider, [{
    key: "_parseTheme",
    value: function _parseTheme(theme) {
      var style = {};
      for (var _i = 0, _Object$entries = Object.entries(theme); _i < _Object$entries.length; _i++) {
        var _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2),
          key = _Object$entries$_i[0],
          value = _Object$entries$_i[1];
        if (key !== 'className' && key !== 'icons' && key !== 'componentWrapper') {
          style["--wsr-".concat((0, _kebabCase["default"])(key))] = value;
        }
      }
      return style;
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
        dataHook = _this$props.dataHook,
        _this$props$theme = _this$props.theme,
        theme = _this$props$theme === void 0 ? {} : _this$props$theme,
        children = _this$props.children;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: theme.className,
        style: this._parseTheme(theme),
        "data-hook": dataHook,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 25,
          columnNumber: 7
        }
      }, /*#__PURE__*/_react["default"].createElement(_ThemeContext.ThemeContext.Provider, {
        value: {
          icons: theme.icons,
          className: theme.className
        },
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 30,
          columnNumber: 9
        }
      }, theme.componentWrapper ? theme.componentWrapper({
        children: children
      }) : children));
    }
  }]);
}(_react["default"].PureComponent);
ThemeProvider.displayName = 'ThemeProvider';
ThemeProvider.defaultProps = {};
var _default = exports["default"] = ThemeProvider;