"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),i=require("primereact/ripple"),n=require("primereact/api"),s=require("primereact/csstransition"),r=require("primereact/portal");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(e),l=a(n);function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var i=0;ie.length)&&(t=e.length);for(var i=0,n=new Array(t);ithis.props.value.length-1?i=this.state.numVisible-this.props.value.length:e>0&&i>0&&(i=0),this.props.circular&&(e<0&&this.props.value.length-1===this.props.activeItemIndex?i=0:e>0&&0===this.props.activeItemIndex&&(i=this.state.numVisible-this.props.value.length)),this.itemsContainer&&(t.DomHandler.removeClass(this.itemsContainer,"p-items-hidden"),this.itemsContainer.style.transform=this.props.isVertical?"translate3d(0, ".concat(i*(100/this.state.numVisible),"%, 0)"):"translate3d(".concat(i*(100/this.state.numVisible),"%, 0, 0)"),this.itemsContainer.style.transition="transform 500ms ease 0s"),this.setState({totalShiftedItems:i})}},{key:"stopSlideShow",value:function(){this.props.slideShowActive&&this.props.stopSlideShow&&this.props.stopSlideShow()}},{key:"getMedianItemIndex",value:function(){var e=Math.floor(this.state.numVisible/2);return this.state.numVisible%2?e:e-1}},{key:"navBackward",value:function(e){this.stopSlideShow();var t=0!==this.props.activeItemIndex?this.props.activeItemIndex-1:0;this.state.numVisible-(t+this.state.totalShiftedItems)-1>this.getMedianItemIndex()&&(-1*this.state.totalShiftedItems!=0||this.props.circular)&&this.step(1),this.props.onActiveItemChange({index:this.props.circular&&0===this.props.activeItemIndex?this.props.value.length-1:t}),e.cancelable&&e.preventDefault()}},{key:"navForward",value:function(e){this.stopSlideShow();var t=this.props.activeItemIndex+1;t+this.state.totalShiftedItems>this.getMedianItemIndex()&&(-1*this.state.totalShiftedItems0&&-1*this.state.totalShiftedItems!=0&&this.step(n):(n=this.getMedianItemIndex()-i)<0&&-1*this.state.totalShiftedItemsthis.state.numVisible?this.props.value.length-this.state.numVisible+1:0}},{key:"createStyle",value:function(){this.thumbnailsStyle||(this.thumbnailsStyle=t.DomHandler.createInlineStyle(l.default.nonce));var e,i="\n .p-galleria-thumbnail-items[".concat(this.attributeSelector,"] .p-galleria-thumbnail-item {\n flex: 1 0 ").concat(100/this.state.numVisible,"%\n }\n ");if(this.props.responsiveOptions){this.responsiveOptions=x(e=this.props.responsiveOptions)||E(e)||C(e)||N(),this.responsiveOptions.sort((function(e,t){var i=e.breakpoint,n=t.breakpoint;return-1*(null==i&&null!=n?-1:null!=i&&null==n?1:null==i&&null==n?0:"string"==typeof i&&"string"==typeof n?i.localeCompare(n,void 0,{numeric:!0}):in?1:0)}));for(var n=0;n=e&&(t=n)}this.state.numVisible!==t.numVisible&&this.setState({numVisible:t.numVisible})}}},{key:"bindDocumentListeners",value:function(){var e=this;this.documentResizeListener||(this.documentResizeListener=function(){e.calculatePosition()},window.addEventListener("resize",this.documentResizeListener))}},{key:"unbindDocumentListeners",value:function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)}},{key:"componentDidMount",value:function(){this.itemsContainer&&this.itemsContainer.setAttribute(this.attributeSelector,""),this.createStyle(),this.calculatePosition(),this.props.responsiveOptions&&this.bindDocumentListeners()}},{key:"componentDidUpdate",value:function(e,i){var n=this.state.totalShiftedItems;i.numVisible===this.state.numVisible&&e.activeItemIndex===this.props.activeItemIndex||((n=this.props.activeItemIndex<=this.getMedianItemIndex()?0:this.props.value.length-this.state.numVisible+this.getMedianItemIndex()=i,start:n===i,end:s===i,onItemClick:e.onItemClick,current:e.props.activeItemIndex===i})}))}},{key:"renderBackwardNavigator",value:function(){if(this.props.showThumbnailNavigators){var e=!this.props.circular&&0===this.props.activeItemIndex||this.props.value.length<=this.state.numVisible,n=t.classNames("p-galleria-thumbnail-prev p-link",{"p-disabled":e}),s=t.classNames("p-galleria-thumbnail-prev-icon pi",{"pi-chevron-left":!this.props.isVertical,"pi-chevron-up":this.props.isVertical});return o.default.createElement("button",{className:n,onClick:this.navBackward,disabled:e},o.default.createElement("span",{className:s}),o.default.createElement(i.Ripple,null))}return null}},{key:"renderForwardNavigator",value:function(){if(this.props.showThumbnailNavigators){var e=!this.props.circular&&this.props.activeItemIndex===this.props.value.length-1||this.props.value.length<=this.state.numVisible,n=t.classNames("p-galleria-thumbnail-next p-link",{"p-disabled":e}),s=t.classNames("p-galleria-thumbnail-next-icon pi",{"pi-chevron-right":!this.props.isVertical,"pi-chevron-down":this.props.isVertical});return o.default.createElement("button",{className:n,onClick:this.navForward,disabled:e},o.default.createElement("span",{className:s}),o.default.createElement(i.Ripple,null))}return null}},{key:"renderContent",value:function(){var e=this,t=this.renderItems(),i=this.props.isVertical?this.props.contentHeight:"",n=this.renderBackwardNavigator(),s=this.renderForwardNavigator();return o.default.createElement("div",{className:"p-galleria-thumbnail-container"},n,o.default.createElement("div",{className:"p-galleria-thumbnail-items-container",style:{height:i}},o.default.createElement("div",{ref:function(t){return e.itemsContainer=t},className:"p-galleria-thumbnail-items",onTransitionEnd:this.onTransitionEnd,onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd},t)),s)}},{key:"render",value:function(){var e=this.renderContent();return o.default.createElement("div",{className:"p-galleria-thumbnail-wrapper"},e)}}]),r}();function A(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function R(e){for(var t=1;t0&&this.renderGalleria()}}]),v}();I(j,"defaultProps",{id:null,value:null,activeIndex:0,fullScreen:!1,item:null,thumbnail:null,indicator:null,caption:null,className:null,style:null,header:null,footer:null,numVisible:3,responsiveOptions:null,showItemNavigators:!1,showThumbnailNavigators:!0,showItemNavigatorsOnHover:!1,changeItemOnIndicatorHover:!1,circular:!1,autoPlay:!1,transitionInterval:4e3,showThumbnails:!0,thumbnailsPosition:"bottom",verticalThumbnailViewPortHeight:"300px",showIndicators:!1,showIndicatorsOnItem:!1,indicatorsPosition:"bottom",baseZIndex:0,transitionOptions:null,onItemChange:null}),exports.Galleria=j;