"use strict";define("slideShowGallery",["lodash","core","skins","santaProps","utils","coreUtils","siteUtils","galleriesCommon","displayer"],function(t,e,i,s,o,a,n,r,p){function l(t,e){return d(t+1,e)}function h(t,e){return d(t-1,e)}function d(t,e){return(t%e+e)%e}function u(t,e){return String(t+1)+"/"+String(e)}function c(t,e,i){return"flexibleHeight"===e?t.displayerSize.height:i}function m(e){return{currentIndex:t.get(e,"currentIndex",0),isPlaying:"autoplayOn"===t.get(e,"$slideshow","autoplayOff")}}var g=e.compMixins,y=a.matrix.scalingCalculations,f=r.utils.galleriesHelperFunctions,S=o.galleriesCommonLayout;return{displayName:"SlideShowGallery",mixins:[g.skinBasedComp,r.mixins.galleryAutoPlayMixin,g.animationsMixin,g.timeoutsMixin,g.skinInfo,g.compStateMixin(m)],statics:{useSantaTypes:!0,behaviors:{nextSlide:{methodName:"next"},prevSlide:{methodName:"prev"}}},propTypes:t.assign({id:s.Types.Component.id.isRequired,compData:s.Types.Component.compData.isRequired,compProp:s.Types.Component.compData.isRequired,skin:s.Types.Component.skin.isRequired,style:s.Types.Component.style.isRequired,currentUrlPageId:s.Types.currentUrlPageId.isRequired,isMobileView:s.Types.isMobileView.isRequired,isMobileDevice:s.Types.Device.isMobileDevice.isRequired,isTabletDevice:s.Types.Device.isTabletDevice.isRequired,isZoomOpened:s.Types.isZoomOpened.isRequired,isPlayingAllowed:s.Types.RenderFlags.isPlayingAllowed.isRequired,shouldResetGalleryToOriginalState:s.Types.RenderFlags.shouldResetGalleryToOriginalState.isRequired,windowTouchEvents:s.Types.SiteAspects.windowTouchEvents.isRequired},s.santaTypesUtils.getSantaTypesByDefinition(p)),getInitialState:function(){return this.getInitStateAndResetInstance(this.props)},getInitStateAndResetInstance:function(e){var i=e||this.props;return this.shouldResetGalleryToOriginalState=i.shouldResetGalleryToOriginalState,i.windowTouchEvents.registerToWindowTouchEvent("touchStart",this),this.isAnimating=!1,this.getButtonsState=this.getButtonsState||t.noop,t.assign(m(),{$mobile:i.isMobileDevice||i.isTabletDevice?"mobile":"notMobile",$displayDevice:i.isMobileView?"mobileView":"desktopView",displayerPanelState:"notShowPanel",$touchRollOverSupport:"touchRollOut",$animationInProcess:null},this.getButtonsState())},componentDidMount:function(){this.updateAutoplayState()},componentWillReceiveProps:function(e){var i=!1,s={$mobile:e.isMobileDevice||e.isTabletDevice?"mobile":"notMobile",$displayDevice:e.isMobileView?"mobileView":"desktopView"};if(this.props.compProp.autoplay!==e.compProp.autoplay){var o=e.compProp.autoplay&&!this.props.isZoomOpened&&this.props.isPlayingAllowed?"autoplayOn":"autoplayOff";i=!0,s.shouldAutoPlay=e.compProp.autoplay,s.$slideshow=o}t.assign(s,this.getButtonsState()),this.setState(s,function(){i&&(this.updateAutoplayState(),this.handleAction(s.$slideshow))}.bind(this)),this.shouldResetGalleryToOriginalState!==e.shouldResetGalleryToOriginalState&&(this.shouldResetGalleryToOriginalState&&"flexibleHeight"===this.props.compProp.imageMode&&this.resetGalleryState&&this.resetGalleryState(e),this.shouldResetGalleryToOriginalState=e.shouldResetGalleryToOriginalState)},componentWillUnmount:function(){this.props.windowTouchEvents.unregisterFromWindowTouchEvent("touchStart",this)},getSkinProperties:function(){var e,i,s=this.props.compData,o=s.items&&s.items.length>0;o&&(e=s.items[this.state.currentIndex],i=c(this.getDisplayerSizeAfterScaling(e),this.props.compProp.imageMode,this.props.style.height));var a=o?this.hideShowPanel:t.noop,n={itemsContainer:{children:o?this.generateNextPagesIfNeeded().concat([this.createDisplayer(e,this.state.currentIndex)]):[],style:{height:"100%"},"data-gallery-id":this.props.id},buttonPrev:{onClick:this.prev,style:{visibility:!this.props.compProp.isHidden&&o&&this.props.compProp.showNavigation?"visible":"hidden"},"data-gallery-id":this.props.id},buttonNext:{onClick:this.next,style:{visibility:!this.props.compProp.isHidden&&o&&this.props.compProp.showNavigation?"visible":"hidden"},"data-gallery-id":this.props.id},counter:{children:u(this.state.currentIndex,this.props.compData.items.length),style:{visibility:!this.props.compProp.isHidden&&this.props.compProp.showCounter?"visible":"hidden"},"data-gallery-id":this.props.id},border:{style:{height:i},"data-gallery-id":this.props.id},autoplay:{onClick:this.toggleAutoPlay,style:{cursor:"pointer",visibility:this.shouldShowAutoPlay()?"visible":"hidden"},"data-gallery-id":this.props.id},"":{style:{height:i,overflow:"hidden"},onMouseEnter:a,onMouseLeave:a,onMouseMove:a,onTouchStart:this.onComponentTouchStart,"data-gallery-id":this.props.id,"data-height-diff":f.getSkinHeightDiff(this.props.skin),"data-width-diff":f.getSkinWidthDiff(this.props.skin),"data-text-alignment":this.props.compProp.alignText}};return"flexibleHeight"===this.props.compProp.imageMode&&S.updateSkinPropsForFlexibleHeightGallery(n,i),n},onComponentTouchStart:function(t){this.hideShowPanel(t),"touchRollOut"===this.state.$touchRollOverSupport&&this.setState({$touchRollOverSupport:"touchRollOver"})},onWindowTouchStart:function(t){"touchRollOver"===this.state.$touchRollOverSupport&&t.target.getAttribute("data-gallery-id")!==this.props.id&&(this.hideShowPanel({type:"mouseleave",target:t.target}),this.setState({$touchRollOverSupport:"touchRollOut"}))},hideShowPanel:function(t,e,i){var s="mouseleave"===t.type?"notShowPanel":"showPanel",o=this.props.compData.items[this.state.currentIndex].id;this.refs[o].getPanelState()!==s&&this.refs[o].setPanelState(s),i||s===this.state.displayerPanelState||this.setState({displayerPanelState:s})},prev:function(t){var e=this.props.compProp.reverse;this.moveSlide(!e,t)},next:function(t){var e=this.props.compProp.reverse;this.moveSlide(e,t)},moveSlide:function(t,e){if(this.isAnimating)return!1;var i=t?h(this.state.currentIndex,this.props.compData.items.length):l(this.state.currentIndex,this.props.compData.items.length);if(this.state.currentIndex===i)return!1;this.hideShowPanel({type:"mouseleave",target:{id:""}},{},!0);var s=this.props.compData.items[i].id,o=s,a=this.props.compData.items[this.state.currentIndex].id;this.setImageTransitionPhase(i,"transIn"),this.setImageTransitionPhase(this.state.currentIndex,"transOut");var n={swipeVertical:"SlideVertical",swipeHorizontal:"SlideHorizontal",crossfade:"CrossFade",outIn:"OutIn",none:"NoTransition"},r="none"===this.props.compProp.transition?0:this.props.compProp.transDuration;this.setState({$animationInProcess:"animationInProcess"});var p=this.sequence();if("flexibleHeight"===this.props.compProp.imageMode){var d=this.getDisplayerSizeAfterScaling(s);p.add("","BaseDimensions",this.props.compProp.transDuration,0,{to:{height:d.displayerSize.height}})}p.add("itemsContainer","BaseDimensions",0,0,{to:{zIndex:0}},0).add({sourceRefs:a,destRefs:o},n[this.props.compProp.transition],r,0,{reverse:t},0).add("itemsContainer","BaseDimensions",0,0,{to:{clearProps:"zIndex",immediateRender:!1}}).onStartAll(function(){this.isAnimating=!0}.bind(this)).onCompleteAll(function(){this.animationCompleteCallback(i,e)}.bind(this)).execute()},setImageTransitionPhase:function(t,e){var i=this.props.compData.items[t].id;this.refs[i].setTransitionPhase(e)},animationCompleteCallback:function(e,i){this.isAnimating=!1,this.registerReLayout(),this.setImageTransitionPhase(e,"noTransition"),this.setImageTransitionPhase(this.state.currentIndex,"noTransition"),this.setState({currentIndex:e,$animationInProcess:null},function(){this.updateAutoplayState();var e=this.props.compData.items[this.state.currentIndex];this.handleAction(n.constants.ACTION_TYPES.IMAGE_CHANGED,{item:e,imageIndex:this.state.currentIndex}),t.isFunction(i)&&i()}.bind(this))},getDisplayerSizeAfterScaling:function(t){return y.getSizeAfterScaling({itemHeight:this.props.style.height-f.getSkinHeightDiff(this.props.skin),itemWidth:this.props.style.width-f.getSkinWidthDiff(this.props.skin),displayerData:t,imageMode:this.props.compProp.imageMode,heightDiff:this.getDisplayerHeightDiff(),widthDiff:this.getDisplayerWidthDiff(),bottomGap:this.getBottomGap()})},generateNextPagesIfNeeded:function(){var t,e,i=[],s=l(this.state.currentIndex,this.props.compData.items.length);s!==this.state.currentIndex&&(t=this.props.compData.items[s]);var o=h(this.state.currentIndex,this.props.compData.items.length);o!==this.state.currentIndex&&o!==s&&(e=this.props.compData.items[o]);var a={visibility:"hidden",opacity:0};return t&&i.push(this.createDisplayer(t,s,a)),e&&i.push(this.createDisplayer(e,o,a)),i},createDisplayer:function(e,i,s){var o=this.getDisplayerSizeAfterScaling(e);return this.createChildComponent(e,"wysiwyg.viewer.components.Displayer","imageItem",{key:e.id,ref:e.id,id:this.props.id+e.id,currentUrlPageId:this.props.currentUrlPageId,galleryDataId:this.props.compData.id,galleryId:this.props.id,imageWrapperSize:o.imageWrapperSize,showPanelState:s?"notShowPanel":this.state.displayerPanelState,heightDiff:this.getDisplayerHeightDiff(),widthDiff:this.getDisplayerWidthDiff(),bottomGap:this.getBottomGap(),imageIndex:i,style:t.merge({width:o.displayerSize.width,height:o.displayerSize.height,position:"absolute",left:0,top:0},s)})},getDisplayerHeightDiff:function(){var t=this.getSkinExports().imageItem.skin,e=this.getParams(["topPadding","imgHeightDiff"],t);return f.getDisplayerHeightDiff(i.skins[t],e,this.state.$displayDevice)},getDisplayerWidthDiff:function(){var t=this.getSkinExports().imageItem.skin;return f.getDisplayerWidthDiff(i.skins[t],this.state.$displayDevice)},getBottomGap:function(){var t=i.skins[this.props.skin];return t.exports&&t.exports.bottomGap||0}}}); //# sourceMappingURL=slideShowGallery.min.js.map