import{_ as __rest,a as __assign}from"./tslib.es6-bjGg6Bxl.js";import React__default,{useContext,useState,useEffect}from"react";import{a as NavigationContext}from"./Navigation.component-Q2fi8-qR.js";import{I as Icon}from"./Icon.component-7-ap-6Ys.js";var itemStyles="\n  jn-flex\n  jn-items-center\n",disabledStyles="\n  jn-opacity-50\n  jn-cursor-not-allowed\n",NavigationItem=function(a){var b=a.active,c=void 0!==b&&b,d=a.activeItemStyles,e=void 0===d?"":d,f=a.ariaLabel,g=void 0===f?"":f,h=a.children,i=void 0===h?null:h,j=a.className,k=void 0===j?"":j,l=a.disabled,m=void 0!==l&&l,n=a.icon,o=void 0===n?null:n,p=a.inactiveItemStyles,q=void 0===p?"":p,r=a.label,s=void 0===r?"":r,t=a.href,u=void 0===t?"":t,v=a.onClick,w=a.value,x=void 0===w?"":w,y=a.wrapperClassName,z=void 0===y?"":y,A=__rest(a,["active","activeItemStyles","ariaLabel","children","className","disabled","icon","inactiveItemStyles","label","href","onClick","value","wrapperClassName"]),B=function(a){return"string"!=typeof a||0!==a.trim().length},C=useContext(NavigationContext),D=x||i||s,E=C||{},F=E.activeItem,G=E.addItem,H=E.handleActiveItemChange,I=E.navigationDisabled,J=E.navigationRole,K=function(){return(null===C||void 0===C?void 0:C.activeItem)&&B(null===C||void 0===C?void 0:C.activeItem)?F===D:c},L=useState(function(){return K()}),M=L[0],N=L[1];useEffect(function(){G?G(D,i,s,x):void 0},[i,s,x]),useEffect(function(){return F?void(F===D?N(!0):N(!1)):void N(c)},[F,c]);var O=function(a){m?a.preventDefault():(!M&&H&&"function"==typeof H&&H(D),v&&v(a))};return React__default.createElement("li",{className:"juno-navigation-item-wrapper ".concat(z)},u&&u.length?(React__default.createElement("a",__assign({"aria-disabled":!!(I||m)||void 0,"aria-label":g&&g.length?g:void 0,"aria-selected":!!M||void 0,className:"\n            juno-navigation-item \n            ".concat(itemStyles,"\n            ").concat(J?"juno-"+J.toLowerCase()+"-item "+(M?"juno-"+J.toLowerCase()+"-item-active":""):"","\n            ").concat(M?"juno-navigation-item-active "+e:q,"\n            ").concat(I||m?"juno-navigation-item-disabled "+disabledStyles:"","\n            ").concat(k),"data-value":x&&x.length?x:null,href:u,onClick:O},A),o?React__default.createElement(Icon,{icon:o,size:"18",className:"jn-mr-2"}):"",i||s||x)):(React__default.createElement("button",__assign({"aria-disabled":!!(I||m)||void 0,"aria-label":g&&g.length?g:void 0,"aria-selected":!!M||void 0,className:"\n            juno-navigation-item \n            ".concat(itemStyles,"\n            ").concat(J?"juno-"+J.toLowerCase()+"-item "+(M?"juno-"+J.toLowerCase()+"-item-active":""):"","\n            ").concat(M?"juno-navigation-item-active "+e:q,"\n            ").concat(I||m?"juno-navigation-item-disabled "+disabledStyles:"","\n            ").concat(k),"data-value":x&&x.length?x:null,disabled:I||m,onClick:O},A),o?React__default.createElement(Icon,{icon:o,size:"18",className:"jn-mr-2"}):"",i||s||x)))};export{NavigationItem as N};