import{C as we,r as o,f as C,b as Ee,P as _e,d as Ne,i as ke,U as je,D as y,I as Ce,g as Re,Q as De,c as Ae,af as Me,ag as Le,j as U}from"./index-BhJeFDTB.js";function K(){return K=Object.assign?Object.assign.bind():function(a){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(a[i]=n[i])}return a},K.apply(null,arguments)}function O(a){"@babel/helpers - typeof";return O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},O(a)}function Ue(a,e){if(O(a)!="object"||!a)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var i=n.call(a,e);if(O(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Ke(a){var e=Ue(a,"string");return O(e)=="symbol"?e:e+""}function Be(a,e,n){return(e=Ke(e))in a?Object.defineProperty(a,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):a[e]=n,a}function Fe(a){if(Array.isArray(a))return a}function $e(a,e){var n=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(n!=null){var i,l,g,p,u=[],d=!0,h=!1;try{if(g=(n=n.call(a)).next,e!==0)for(;!(d=(i=g.call(n)).done)&&(u.push(i.value),u.length!==e);d=!0);}catch(m){h=!0,l=m}finally{try{if(!d&&n.return!=null&&(p=n.return(),Object(p)!==p))return}finally{if(h)throw l}}return u}}function X(a,e){(e==null||e>a.length)&&(e=a.length);for(var n=0,i=Array(e);n<e;n++)i[n]=a[n];return i}function He(a,e){if(a){if(typeof a=="string")return X(a,e);var n={}.toString.call(a).slice(8,-1);return n==="Object"&&a.constructor&&(n=a.constructor.name),n==="Map"||n==="Set"?Array.from(a):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?X(a,e):void 0}}function We(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function q(a,e){return Fe(a)||$e(a,e)||He(a,e)||We()}var ze={icon:function(e){var n=e._icon;return C("p-menuitem-icon",n)},label:"p-menuitem-text",action:"p-menuitem-link",menuitem:function(e){var n=e._className,i=e.active,l=e.disabled;return C("p-tabmenuitem",{"p-highlight":i,"p-disabled":l},n)},inkbar:"p-tabmenu-ink-bar",menu:"p-tabmenu-nav p-reset",root:"p-tabmenu p-component"},Je=`
@layer primereact {
    .p-tabmenu {
        overflow-x: auto;
    }

    .p-tabmenu-nav {
        display: flex;
        margin: 0;
        padding: 0;
        list-style-type: none;
        flex-wrap: nowrap;
    }

    .p-tabmenu-nav a {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        position: relative;
        text-decoration: none;
        text-decoration: none;
        overflow: hidden;
    }

    .p-tabmenu-nav a:focus {
        z-index: 1;
    }

    .p-tabmenu-nav .p-menuitem-text {
        line-height: 1;
    }

    .p-tabmenu-ink-bar {
        display: none;
        z-index: 1;
    }

    .p-tabmenu::-webkit-scrollbar {
        display: none;
    }
}
`,j=we.extend({defaultProps:{__TYPE:"TabMenu",id:null,model:null,activeIndex:0,ariaLabel:null,ariaLabelledBy:null,style:null,className:null,onTabChange:null,children:void 0},css:{classes:ze,styles:Je}});function Q(a,e){var n=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);e&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(a,l).enumerable})),n.push.apply(n,i)}return n}function Y(a){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Q(Object(n),!0).forEach(function(i){Be(a,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(n)):Q(Object(n)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(n,i))})}return a}var G=o.memo(o.forwardRef(function(a,e){var n=Ee(),i=o.useContext(_e),l=j.getProps(a,i),g=o.useState(l.id),p=q(g,2),u=p[0],d=p[1],h=o.useState(l.activeIndex),m=q(h,2),x=m[0],b=m[1],S=o.useRef(null),v=o.useRef(null),f=o.useRef(null),V=o.useRef({}),B=l.onTabChange?l.activeIndex:x,F={props:l,state:{id:u,activeIndex:B}},R=j.setMetaData(Y({},F)),w=R.ptm,I=R.cx,Z=R.isUnstyled,E=function(t,r,c){return w(t,{parent:F,context:{item:r,index:c}})};Ne(j.css.styles,Z,{name:"tabmenu"});var D=function(t,r,c){if(r.disabled){t.preventDefault();return}r.command&&r.command({originalEvent:t,item:r}),l.onTabChange?l.onTabChange({originalEvent:t,value:r,index:c}):b(c),r.url||(t.preventDefault(),t.stopPropagation())},ee=function(t){return t===(B||0)},te=function(){if(l.model){for(var t=f.current.children,r=!1,c=0;c<t.length;c++){var T=t[c];y.getAttribute(T,"data-p-highlight")&&(v.current.style.width=y.getWidth(T)+"px",v.current.style.left=y.getOffset(T).left-y.getOffset(f.current).left+"px",r=!0)}r||(v.current.style.width="0px",v.current.style.left="0px")}};ke(function(){u||d(je())}),o.useImperativeHandle(e,function(){return{props:l,getElement:function(){return S.current}}}),o.useEffect(function(){te()});var ne=function(t,r,c){switch(t.code){case"ArrowRight":ae(t.target),t.preventDefault();break;case"ArrowLeft":re(t.target),t.preventDefault();break;case"Home":ie(t.target),t.preventDefault();break;case"End":le(t.target),t.preventDefault();break;case"Space":case"Enter":case"NumpadEnter":D(t,r,c),t.preventDefault();break;case"Tab":ce();break}},ae=function(t){var r=$(t);r&&_(t,r)},re=function(t){var r=H(t);r&&_(t,r)},ie=function(t){var r=oe();r&&_(t,r)},le=function(t){var r=se();r&&_(t,r)},$=function(t){var r=t.parentElement.nextElementSibling;return r?y.getAttribute(r,"data-p-disabled")===!0?$(r.children[0]):r.children[0]:null},H=function(t){var r=t.parentElement.previousElementSibling;return r?y.getAttribute(r,"data-p-disabled")===!0?H(r.children[0]):r.children[0]:null},oe=function(){var t=y.findSingle(f.current,'[data-pc-section="menuitem"][data-p-disabled="false"]');return t?t.children[0]:null},se=function(){var t=y.find(f.current,'[data-pc-section="menuitem"][data-p-disabled="false"]');return t?t[t.length-1].children[0]:null},_=function(t,r){t.tabIndex="-1",r.tabIndex="0",r.focus()},ce=function(){var t=y.findSingle(f.current,'[data-pc-section="menuitem"][data-p-disabled="false"][data-p-highlight="true"]'),r=y.findSingle(f.current,'[data-pc-section="action"][tabindex="0"]');r!==t.children[0]&&(t&&(t.children[0].tabIndex="0"),r.tabIndex="-1")},ue=function(t,r){if(t.visible===!1)return null;var c=t.className,T=t.style,N=t.disabled,A=t.icon,M=t.label,W=t.template,ve=t.url,ye=t.target,z=t.id||u+"_"+r,k=ee(r),ge=C("p-menuitem-icon",A),he=n({className:I("icon",{_icon:A})},E("icon",t,r)),Ie=Ce.getJSXIcon(A,Y({},he),{props:l}),xe=n({className:I("label")},E("label",t,r)),Se=M&&o.createElement("span",xe,M),Te=n({href:ve||"#",role:"menuitem","aria-label":M,tabIndex:k?"0":"-1",className:I("action"),target:ye,onClick:function(P){return D(P,t,r)}},E("action",t,r)),L=o.createElement("a",Te,Ie,Se,o.createElement(De,null));if(W){var Pe={onClick:function(P){return D(P,t,r)},className:"p-menuitem-link",labelClassName:"p-menuitem-text",iconClassName:ge,element:L,props:l,active:k,index:r,disabled:N};L=Re.getJSXElement(W,t,Pe)}var Oe=n({ref:V.current["tab_".concat(r)],id:z,onKeyDown:function(P){return ne(P,t,r)},className:I("menuitem",{_className:c,active:k,disabled:N}),style:T,role:"presentation","data-p-highlight":k,"data-p-disabled":N||!1,"aria-disabled":N},E("menuitem",t,r));return o.createElement("li",K({},Oe,{key:z}),L)},me=function(){return l.model.map(ue)};if(l.model){var fe=me(),pe=n({ref:v,role:"none",className:I("inkbar")},w("inkbar")),de=n({ref:f,"aria-label":l.ariaLabel,"aria-labelledby":l.ariaLabelledBy,className:I("menu"),role:"menubar"},w("menu")),be=n({id:l.id,ref:S,className:C(l.className,I("root")),style:l.style},j.getOtherProps(l),w("root"));return o.createElement("div",be,o.createElement("ul",de,fe,o.createElement("li",pe)))}return null}));G.displayName="TabMenu";const qe=a=>{const e=Ae.c(14),{items:n,basePath:i}=a,l=Me(),g=Le();let p;try{let b;if(e[0]!==i||e[1]!==n||e[2]!==l.location.pathname){let v=l.location.pathname.split(i)[1];v===""&&(v="/"),b=n.findIndex(f=>f.exact?"/"+f.to===v:v.startsWith("/"+f.to)),e[0]=i,e[1]=n,e[2]=l.location.pathname,e[3]=b}else b=e[3];p=b}catch{p=0}const u=p;let d;e[4]!==i||e[5]!==n||e[6]!==g?(d=b=>{const S=n[b].to;g({to:i+"/"+S})},e[4]=i,e[5]=n,e[6]=g,e[7]=d):d=e[7];const h=d;let m;e[8]!==h?(m=b=>h(b.index),e[8]=h,e[9]=m):m=e[9];let x;return e[10]!==u||e[11]!==n||e[12]!==m?(x=U.jsx(U.Fragment,{children:U.jsx(G,{model:n,activeIndex:u,onTabChange:m})}),e[10]=u,e[11]=n,e[12]=m,e[13]=x):x=e[13],x};export{qe as U};
