"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.composeStyles=void 0;var _objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf3=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_react=_interopRequireDefault(require("react")),_theme=require("../../config/theme"),_classnames=_interopRequireDefault(require("classnames")),_lodash=_interopRequireDefault(require("lodash")),_reactJss=_interopRequireDefault(require("react-jss")),withStyles=function(styles){return function(component){var StyledComponent=(0,_reactJss.default)(styles,{theming:_theme.theming})(component),Wrapper=/*#__PURE__*/function(_React$Component){function Wrapper(){var _getPrototypeOf2,_this;(0,_classCallCheck2.default)(this,Wrapper);for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];return _this=(0,_possibleConstructorReturn2.default)(this,(_getPrototypeOf2=(0,_getPrototypeOf3.default)(Wrapper)).call.apply(_getPrototypeOf2,[this].concat(args))),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"styledComponent",void 0),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"state",{classes:{}}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"_mergeClasses",function(props){// Merge classes generated by JSS and user classes
var oldClasses=_this.styledComponent.state.classes,userClasses=props.classes||{};Object.keys(oldClasses).forEach(function(classKey){oldClasses[classKey]=(0,_classnames.default)(oldClasses[classKey],userClasses[classKey])}),_this.setState({classes:oldClasses})}),_this}return(0,_inherits2.default)(Wrapper,_React$Component),(0,_createClass2.default)(Wrapper,[{key:"componentDidMount",value:function componentDidMount(){this._mergeClasses(this.props)}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){_lodash.default.isEqual(this.props.classes,prevProps.classes)||this._mergeClasses(this.props)}},{key:"render",value:function render(){var _this2=this,_this$props=this.props,classes=_this$props.classes,rest=(0,_objectWithoutProperties2.default)(_this$props,["classes"]);// eslint-disable-line
return _react.default.createElement(StyledComponent,(0,_extends2.default)({ref:function ref(_ref){_this2.styledComponent=_ref}},rest,{classes:this.state.classes}))}}]),Wrapper}(_react.default.Component);return(0,_defineProperty2.default)(Wrapper,"displayName",StyledComponent.displayName),Wrapper}},composeStyles=function(){for(var _len3=arguments.length,styles=Array(_len3),_key3=0;_key3<_len3;_key3++)styles[_key3]=arguments[_key3];return function(theme){var mergedStyles={};return styles.forEach(function(v){var style=v(theme);mergedStyles=(0,_objectSpread2.default)({},mergedStyles,style)}),mergedStyles}};exports.composeStyles=composeStyles;var _default=withStyles;exports.default=_default;