this.primereact=this.primereact||{},this.primereact.tabview=function(e,t,n,r){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=a(t);function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e}))||n.reverse().find((function(t){return!t.tab.props.disabled&&e>t.index}))}},{key:"onTabHeaderClose",value:function(e,t){var n,r=this,a=[].concat(l(n=this.state.hiddenTabs)||s(n)||c(n)||u(),[t]);this.setState({hiddenTabs:a},(function(){var n=r.findVisibleActiveTab(t);n&&r.onTabHeaderClick(e,n.tab,n.index)})),this.props.onTabClose&&this.props.onTabClose({originalEvent:e,index:t}),e.preventDefault()}},{key:"onTabHeaderClick",value:function(e,t,n){t.props.disabled||(this.props.onTabChange?this.props.onTabChange({originalEvent:e,index:n}):this.setState({activeIndex:n})),this.updateScrollBar(n),e.preventDefault()}},{key:"onKeyDown",value:function(e,t,n){"Enter"===e.code&&this.onTabHeaderClick(e,t,n)}},{key:"updateInkBar",value:function(){var e=this.getActiveIndex(),t=this["tab_".concat(e)];this.inkbar.style.width=n.DomHandler.getWidth(t)+"px",this.inkbar.style.left=n.DomHandler.getOffset(t).left-n.DomHandler.getOffset(this.nav).left+"px"}},{key:"updateScrollBar",value:function(e){var t=this["tab_".concat(e)];t&&t.scrollIntoView({block:"nearest"})}},{key:"updateButtonState",value:function(){var e=this.content,t=e.scrollLeft,r=e.scrollWidth,a=n.DomHandler.getWidth(e);this.setState({backwardIsDisabled:0===t}),this.setState({forwardIsDisabled:t===r-a})}},{key:"onScroll",value:function(e){this.props.scrollable&&this.updateButtonState(),e.preventDefault()}},{key:"getVisibleButtonWidths",value:function(){return[this.prevBtn,this.nextBtn].reduce((function(e,t){return t?e+n.DomHandler.getWidth(t):e}),0)}},{key:"navBackward",value:function(){var e=this.content,t=n.DomHandler.getWidth(e)-this.getVisibleButtonWidths(),r=e.scrollLeft-t;e.scrollLeft=r<=0?0:r}},{key:"navForward",value:function(){var e=this.content,t=n.DomHandler.getWidth(e)-this.getVisibleButtonWidths(),r=e.scrollLeft+t,a=e.scrollWidth-t;e.scrollLeft=r>=a?a:r}},{key:"reset",value:function(){var e={backwardIsDisabled:!0,forwardIsDisabled:!1,hiddenTabs:[]};this.props.onTabChange?this.props.onTabChange({index:this.props.activeIndex}):e=T(T({},e),{},{activeIndex:this.props.activeIndex}),this.setState(e)}},{key:"componentDidMount",value:function(){this.state.id||this.setState({id:n.UniqueComponentId()}),this.updateInkBar()}},{key:"componentDidUpdate",value:function(e){this.updateInkBar(),e.activeIndex!==this.props.activeIndex&&this.updateScrollBar(this.props.activeIndex)}},{key:"renderTabHeader",value:function(e,t){var a=this,o=this.isSelected(t),l=T(T({},e.props.headerStyle||{}),e.props.style||{}),s=n.classNames("p-unselectable-text",{"p-tabview-selected p-highlight":o,"p-disabled":e.props.disabled},e.props.headerClassName,e.props.className),c=this.state.id+"_header_"+t,u=this.state.id+"_content_"+t,p=e.props.disabled?null:0,d=e.props.leftIcon&&i.default.createElement("i",{className:e.props.leftIcon}),f=i.default.createElement("span",{className:"p-tabview-title"},e.props.header),b=e.props.rightIcon&&i.default.createElement("i",{className:e.props.rightIcon}),h=i.default.createElement("a",{role:"tab",className:"p-tabview-nav-link",onClick:function(n){return a.onTabHeaderClick(n,e,t)},id:c,onKeyDown:function(n){return a.onKeyDown(n,e,t)},"aria-controls":u,"aria-selected":o,tabIndex:p},d,f,b,e.props.closable&&i.default.createElement("i",{className:"p-tabview-close pi pi-times",onClick:function(e){return a.onTabHeaderClose(e,t)}}),i.default.createElement(r.Ripple,null));e.props.headerTemplate&&(h=n.ObjectUtils.getJSXElement(e.props.headerTemplate,{className:"p-tabview-nav-link",titleClassName:"p-tabview-title",onClick:function(n){return a.onTabHeaderClick(n,e,t)},onKeyDown:function(n){return a.onKeyDown(n,e,t)},leftIconElement:d,titleElement:f,rightIconElement:b,element:h,props:this.props,index:t,selected:o,ariaControls:u}));return i.default.createElement("li",{ref:function(e){return a["tab_".concat(t)]=e},className:s,style:l,role:"presentation"},h)}},{key:"renderTabHeaders",value:function(){var e=this;return i.default.Children.map(this.props.children,(function(t,n){if(e.shouldTabRender(t,n))return e.renderTabHeader(t,n)}))}},{key:"renderNavigator",value:function(){var e=this,t=this.renderTabHeaders();return i.default.createElement("div",{ref:function(t){return e.content=t},id:this.props.id,className:"p-tabview-nav-content",style:this.props.style,onScroll:this.onScroll},i.default.createElement("ul",{ref:function(t){return e.nav=t},className:"p-tabview-nav",role:"tablist"},t,i.default.createElement("li",{ref:function(t){return e.inkbar=t},className:"p-tabview-ink-bar"})))}},{key:"renderContent",value:function(){var e=this,t=i.default.Children.map(this.props.children,(function(t,n){if(e.shouldTabRender(t,n)&&(!e.props.renderActiveOnly||e.isSelected(n)))return e.createContent(t,n)}));return i.default.createElement("div",{className:"p-tabview-panels"},t)}},{key:"createContent",value:function(e,t){var r=this.isSelected(t),a=T(T({},e.props.contentStyle||{}),e.props.style||{}),o=n.classNames(e.props.contentClassName,e.props.className,"p-tabview-panel",{"p-hidden":!r});return i.default.createElement("div",{id:this.state.id+"_content_"+t,"aria-labelledby":this.state.id+"_header_"+t,"aria-hidden":!r,className:o,style:a,role:"tabpanel"},this.props.renderActiveOnly?r&&e.props.children:e.props.children)}},{key:"renderPrevButton",value:function(){var e=this;return this.props.scrollable&&!this.state.backwardIsDisabled?i.default.createElement("button",{ref:function(t){return e.prevBtn=t},className:"p-tabview-nav-prev p-tabview-nav-btn p-link",onClick:this.navBackward,type:"button"},i.default.createElement("span",{className:"pi pi-chevron-left"}),i.default.createElement(r.Ripple,null)):null}},{key:"renderNextButton",value:function(){var e=this;if(this.props.scrollable&&!this.state.forwardIsDisabled)return i.default.createElement("button",{ref:function(t){return e.nextBtn=t},className:"p-tabview-nav-next p-tabview-nav-btn p-link",onClick:this.navForward,type:"button"},i.default.createElement("span",{className:"pi pi-chevron-right"}),i.default.createElement(r.Ripple,null))}},{key:"render",value:function(){var e=n.classNames("p-tabview p-component",this.props.className,{"p-tabview-scrollable":this.props.scrollable}),t=this.renderNavigator(),r=this.renderContent(),a=this.renderPrevButton(),o=this.renderNextButton();return i.default.createElement("div",{className:e},i.default.createElement("div",{className:"p-tabview-nav-container"},a,t,o),r)}}]),a}(t.Component);return k(S,"defaultProps",{id:null,activeIndex:0,style:null,className:null,renderActiveOnly:!0,onTabChange:null,onTabClose:null,scrollable:!1}),e.TabPanel=O,e.TabView=S,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple);