"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ThemeProviderConsumerBackwardCompatible = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _ThemeContext = require("./ThemeContext");
var _excluded = ["defaultIcons"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/ThemeProvider/ThemeProviderConsumerBackwardCompatible.tsx";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
 * This is a utility for every component that uses an icon to declare its defaults but also replace it with the theme context
 * Usage Example:
 *
 * <ThemeProviderConsumerBackwardCompatible
 *   defaultIcons={{
 *     CloseButton: CloseIcon,
 *   }}
 * >
 *   {({ icons }) => {
 *      const CloseIcon = icons.CloseButton
 *      return <CloseIcon data-hook="additional-content"/>
 *     }
 *   }
 * </ThemeProviderConsumerBackwardCompatible>
 *
 * Note that this implementation is temporary and needed only to preserve backwards compatibility for components with built-in icons (like CloseButton).
 * It will be removed in the future once a <ThemeProvider/> will be required on the top of any theme, including the default one.
 * This will assist in creating smaller bundle size for themes that would override the default icons. */
var ThemeProviderConsumerBackwardCompatible = _ref => {
  var {
      defaultIcons = {}
    } = _ref,
    rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 29,
      columnNumber: 3
    }
  }, context => /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Provider, {
    value: {
      icons: _objectSpread(_objectSpread({}, defaultIcons), context && context.icons),
      className: context && context.className
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, (0, _extends2.default)({}, rest, {
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 37,
      columnNumber: 9
    }
  }))));
};
exports.ThemeProviderConsumerBackwardCompatible = ThemeProviderConsumerBackwardCompatible;
//# sourceMappingURL=ThemeProviderConsumerBackwardCompatible.js.map