import{r as o,c as C,P as we,U as ke,D as y,I as Ne,O as je,j as Re,u as Ce,p as De,k as K}from"./iframe-B4rglaWu.js";import{C as Ae,u as Me,a as Le,c as Ue}from"./componentbase.esm-O764U3c0.js";import{R as Ke}from"./ripple.esm-Bd7Vm0vw.js";import"./preload-helper-PPVm8Dsz.js";function B(){return B=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},B.apply(null,arguments)}function _(a){"@babel/helpers - typeof";return _=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},_(a)}function Be(a,e){if(_(a)!="object"||!a)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var i=n.call(a,e);if(_(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Fe(a){var e=Be(a,"string");return _(e)=="symbol"?e:e+""}function $e(a,e,n){return(e=Fe(e))in a?Object.defineProperty(a,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):a[e]=n,a}function qe(a){if(Array.isArray(a))return a}function He(a,e){var n=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(n!=null){var i,l,g,f,c=[],d=!0,h=!1;try{if(g=(n=n.call(a)).next,e!==0)for(;!(d=(i=g.call(n)).done)&&(c.push(i.value),c.length!==e);d=!0);}catch(m){h=!0,l=m}finally{try{if(!d&&n.return!=null&&(f=n.return(),Object(f)!==f))return}finally{if(h)throw l}}return c}}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 We(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 ze(){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 Y(a,e){return qe(a)||He(a,e)||We(a,e)||ze()}var Je={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"},Xe=`
@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=Ae.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:Je,styles:Xe}});function G(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 Q(a){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G(Object(n),!0).forEach(function(i){$e(a,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(n)):G(Object(n)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(n,i))})}return a}var V=o.memo(o.forwardRef(function(a,e){var n=Me(),i=o.useContext(we),l=j.getProps(a,i),g=o.useState(l.id),f=Y(g,2),c=f[0],d=f[1],h=o.useState(l.activeIndex),m=Y(h,2),x=m[0],b=m[1],T=o.useRef(null),v=o.useRef(null),p=o.useRef(null),ee=o.useRef({}),F=l.onTabChange?l.activeIndex:x,$={props:l,state:{id:c,activeIndex:F}},D=j.setMetaData(Q({},$)),E=D.ptm,I=D.cx,te=D.isUnstyled,O=function(t,r,u){return E(t,{parent:$,context:{item:r,index:u}})};Le(j.css.styles,te,{name:"tabmenu"});var A=function(t,r,u){if(r.disabled){t.preventDefault();return}r.command&&r.command({originalEvent:t,item:r}),l.onTabChange?l.onTabChange({originalEvent:t,value:r,index:u}):b(u),r.url||(t.preventDefault(),t.stopPropagation())},ne=function(t){return t===(F||0)},ae=function(){if(l.model){for(var t=p.current.children,r=!1,u=0;u<t.length;u++){var S=t[u];y.getAttribute(S,"data-p-highlight")&&(v.current.style.width=y.getWidth(S)+"px",v.current.style.left=y.getOffset(S).left-y.getOffset(p.current).left+"px",r=!0)}r||(v.current.style.width="0px",v.current.style.left="0px")}};Ue(function(){c||d(ke())}),o.useImperativeHandle(e,function(){return{props:l,getElement:function(){return T.current}}}),o.useEffect(function(){ae()});var re=function(t,r,u){switch(t.code){case"ArrowRight":ie(t.target),t.preventDefault();break;case"ArrowLeft":le(t.target),t.preventDefault();break;case"Home":oe(t.target),t.preventDefault();break;case"End":se(t.target),t.preventDefault();break;case"Space":case"Enter":case"NumpadEnter":A(t,r,u),t.preventDefault();break;case"Tab":me();break}},ie=function(t){var r=q(t);r&&w(t,r)},le=function(t){var r=H(t);r&&w(t,r)},oe=function(t){var r=ue();r&&w(t,r)},se=function(t){var r=ce();r&&w(t,r)},q=function(t){var r=t.parentElement.nextElementSibling;return r?y.getAttribute(r,"data-p-disabled")===!0?q(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},ue=function(){var t=y.findSingle(p.current,'[data-pc-section="menuitem"][data-p-disabled="false"]');return t?t.children[0]:null},ce=function(){var t=y.find(p.current,'[data-pc-section="menuitem"][data-p-disabled="false"]');return t?t[t.length-1].children[0]:null},w=function(t,r){t.tabIndex="-1",r.tabIndex="0",r.focus()},me=function(){var t=y.findSingle(p.current,'[data-pc-section="menuitem"][data-p-disabled="false"][data-p-highlight="true"]'),r=y.findSingle(p.current,'[data-pc-section="action"][tabindex="0"]');r!==t.children[0]&&(t&&(t.children[0].tabIndex="0"),r.tabIndex="-1")},pe=function(t,r){if(t.visible===!1)return null;var u=t.className,S=t.style,k=t.disabled,M=t.icon,L=t.label,W=t.template,ge=t.url,he=t.target,z=t.id||c+"_"+r,N=ne(r),Ie=C("p-menuitem-icon",M),xe=n({className:I("icon",{_icon:M})},O("icon",t,r)),Te=Ne.getJSXIcon(M,Q({},xe),{props:l}),Se=n({className:I("label")},O("label",t,r)),Pe=L&&o.createElement("span",Se,L),_e=n({href:ge||"#",role:"menuitem","aria-label":L,tabIndex:N?"0":"-1",className:I("action"),target:he,onClick:function(P){return A(P,t,r)}},O("action",t,r)),U=o.createElement("a",_e,Te,Pe,o.createElement(Ke,null));if(W){var Ee={onClick:function(P){return A(P,t,r)},className:"p-menuitem-link",labelClassName:"p-menuitem-text",iconClassName:Ie,element:U,props:l,active:N,index:r,disabled:k};U=je.getJSXElement(W,t,Ee)}var Oe=n({ref:ee.current["tab_".concat(r)],id:z,onKeyDown:function(P){return re(P,t,r)},className:I("menuitem",{_className:u,active:N,disabled:k}),style:S,role:"presentation","data-p-highlight":N,"data-p-disabled":k||!1,"aria-disabled":k},O("menuitem",t,r));return o.createElement("li",B({},Oe,{key:z}),U)},fe=function(){return l.model.map(pe)};if(l.model){var de=fe(),be=n({ref:v,role:"none",className:I("inkbar")},E("inkbar")),ve=n({ref:p,"aria-label":l.ariaLabel,"aria-labelledby":l.ariaLabelledBy,className:I("menu"),role:"menubar"},E("menu")),ye=n({id:l.id,ref:T,className:C(l.className,I("root")),style:l.style},j.getOtherProps(l),E("root"));return o.createElement("div",ye,o.createElement("ul",ve,de,o.createElement("li",be)))}return null}));V.displayName="TabMenu";const Z=a=>{const e=Re.c(14),{items:n,basePath:i}=a,l=Ce(),g=De();let f;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(p=>p.exact?"/"+p.to===v:v.startsWith("/"+p.to)),e[0]=i,e[1]=n,e[2]=l.location.pathname,e[3]=b}else b=e[3];f=b}catch{f=0}const c=f;let d;e[4]!==i||e[5]!==n||e[6]!==g?(d=b=>{const T=n[b].to;g({to:i+"/"+T})},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]!==c||e[11]!==n||e[12]!==m?(x=K.jsx(K.Fragment,{children:K.jsx(V,{model:n,activeIndex:c,onTabChange:m})}),e[10]=c,e[11]=n,e[12]=m,e[13]=x):x=e[13],x};Z.__docgenInfo={description:"",methods:[],displayName:"UiTabRouterMenu",props:{basePath:{required:!0,tsType:{name:"string"},description:""},items:{required:!0,tsType:{name:"Array",elements:[{name:"signature",type:"object",raw:`{
  label: string
  to: string
  exact?: boolean
}`,signature:{properties:[{key:"label",value:{name:"string",required:!0}},{key:"to",value:{name:"string",required:!0}},{key:"exact",value:{name:"boolean",required:!1}}]}}],raw:`Array<{
  label: string
  to: string
  exact?: boolean
}>`},description:""}}};const Ze={title:"Components/UiTabRouterMenu",component:Z},R={args:{items:[{label:"Item 1",to:"",exact:!0},{label:"Item 2",to:""},{label:"Item 3",to:""},{label:"Item 4",to:""},{label:"Item 5",to:""}],basePath:"/"}};R.parameters={...R.parameters,docs:{...R.parameters?.docs,source:{originalSource:`{
  args: {
    items: [{
      label: 'Item 1',
      to: '',
      exact: true
    }, {
      label: 'Item 2',
      to: ''
    }, {
      label: 'Item 3',
      to: ''
    }, {
      label: 'Item 4',
      to: ''
    }, {
      label: 'Item 5',
      to: ''
    }],
    basePath: '/'
  }
}`,...R.parameters?.docs?.source}}};const et=["Example"];export{R as Example,et as __namedExportsOrder,Ze as default};
