import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import debounce from"lodash.debounce";if("undefined"!=typeof window){var matchMediaPolyfill=function(e){return{media:e,matches:!1,addListener:function(){},removeListener:function(){}}};window.matchMedia=window.matchMedia||matchMediaPolyfill}var SlickCarousel=require("react-slick").default,Carousel=function(e){function i(e){_classCallCheck(this,i);var t=_possibleConstructorReturn(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return t.onWindowResized=function(){t.props.autoplay&&t.slick&&t.slick.innerSlider&&t.slick.innerSlider.autoPlay&&t.slick.innerSlider.autoPlay()},t.saveSlick=function(e){t.slick=e},t.onWindowResized=debounce(t.onWindowResized,500,{leading:!1}),t}return _inherits(i,e),_createClass(i,[{key:"componentDidMount",value:function(){this.props.autoplay&&window.addEventListener("resize",this.onWindowResized),this.innerSlider=this.slick&&this.slick.innerSlider}},{key:"componentWillUnmount",value:function(){this.props.autoplay&&(window.removeEventListener("resize",this.onWindowResized),this.onWindowResized.cancel())}},{key:"next",value:function(){this.slick.slickNext()}},{key:"prev",value:function(){this.slick.slickPrev()}},{key:"goTo",value:function(e){this.slick.slickGoTo(e)}},{key:"render",value:function(){var e=_extends({},this.props);"fade"===e.effect&&(e.fade=!0);var i=e.prefixCls;return e.vertical&&(i=i+" "+i+"-vertical"),React.createElement("div",{className:i},React.createElement(SlickCarousel,_extends({ref:this.saveSlick},e)))}}]),i}(React.Component);export default Carousel;Carousel.defaultProps={dots:!0,arrows:!1,prefixCls:"dt-carousel",draggable:!1};