UNPKG

@watone/wt-cli

Version:

watone tools

74 lines (73 loc) 35.3 kB
import{C,z as R,a as m,c as p,F as x,j as W,g as k,n as g,b,x as v,D as B,k as P,y as I,t as L,A as M,s as S,B as z,l as _}from"./index-ad22e409.js";var c={innerWidth(e){if(e){let t=e.offsetWidth,i=getComputedStyle(e);return t+=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),t}return 0},width(e){if(e){let t=e.offsetWidth,i=getComputedStyle(e);return t-=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),t}return 0},getWindowScrollTop(){let e=document.documentElement;return(window.pageYOffset||e.scrollTop)-(e.clientTop||0)},getWindowScrollLeft(){let e=document.documentElement;return(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)},getOuterWidth(e,t){if(e){let i=e.offsetWidth;if(t){let n=getComputedStyle(e);i+=parseFloat(n.marginLeft)+parseFloat(n.marginRight)}return i}return 0},getOuterHeight(e,t){if(e){let i=e.offsetHeight;if(t){let n=getComputedStyle(e);i+=parseFloat(n.marginTop)+parseFloat(n.marginBottom)}return i}return 0},getClientHeight(e,t){if(e){let i=e.clientHeight;if(t){let n=getComputedStyle(e);i+=parseFloat(n.marginTop)+parseFloat(n.marginBottom)}return i}return 0},getViewport(){let e=window,t=document,i=t.documentElement,n=t.getElementsByTagName("body")[0],r=e.innerWidth||i.clientWidth||n.clientWidth,s=e.innerHeight||i.clientHeight||n.clientHeight;return{width:r,height:s}},getOffset(e){if(e){let t=e.getBoundingClientRect();return{top:t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:t.left+(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0)}}return{top:"auto",left:"auto"}},index(e){if(e){let t=e.parentNode.childNodes,i=0;for(let n=0;n<t.length;n++){if(t[n]===e)return i;t[n].nodeType===1&&i++}}return-1},addMultipleClasses(e,t){if(e&&t)if(e.classList){let i=t.split(" ");for(let n=0;n<i.length;n++)e.classList.add(i[n])}else{let i=t.split(" ");for(let n=0;n<i.length;n++)e.className+=" "+i[n]}},addClass(e,t){e&&t&&(e.classList?e.classList.add(t):e.className+=" "+t)},removeClass(e,t){e&&t&&(e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," "))},hasClass(e,t){return e?e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className):!1},find(e,t){return this.isElement(e)?e.querySelectorAll(t):[]},findSingle(e,t){return this.isElement(e)?e.querySelector(t):null},getHeight(e){if(e){let t=e.offsetHeight,i=getComputedStyle(e);return t-=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom)+parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),t}return 0},getWidth(e){if(e){let t=e.offsetWidth,i=getComputedStyle(e);return t-=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight)+parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth),t}return 0},absolutePosition(e,t){if(e){let i=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e),n=i.height,r=i.width,s=t.offsetHeight,o=t.offsetWidth,a=t.getBoundingClientRect(),d=this.getWindowScrollTop(),l=this.getWindowScrollLeft(),h=this.getViewport(),u,y;a.top+s+n>h.height?(u=a.top+d-n,e.style.transformOrigin="bottom",u<0&&(u=d)):(u=s+a.top+d,e.style.transformOrigin="top"),a.left+r>h.width?y=Math.max(0,a.left+l+o-r):y=a.left+l,e.style.top=u+"px",e.style.left=y+"px"}},relativePosition(e,t){if(e){let i=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e);const n=t.offsetHeight,r=t.getBoundingClientRect(),s=this.getViewport();let o,a;r.top+n+i.height>s.height?(o=-1*i.height,e.style.transformOrigin="bottom",r.top+o<0&&(o=-1*r.top)):(o=n,e.style.transformOrigin="top"),i.width>s.width?a=r.left*-1:r.left+i.width>s.width?a=(r.left+i.width-s.width)*-1:a=0,e.style.top=o+"px",e.style.left=a+"px"}},getParents(e,t=[]){return e.parentNode===null?t:this.getParents(e.parentNode,t.concat([e.parentNode]))},getScrollableParents(e){let t=[];if(e){let i=this.getParents(e);const n=/(auto|scroll)/,r=s=>{let o=window.getComputedStyle(s,null);return n.test(o.getPropertyValue("overflow"))||n.test(o.getPropertyValue("overflowX"))||n.test(o.getPropertyValue("overflowY"))};for(let s of i){let o=s.nodeType===1&&s.dataset.scrollselectors;if(o){let a=o.split(",");for(let d of a){let l=this.findSingle(s,d);l&&r(l)&&t.push(l)}}s.nodeType!==9&&r(s)&&t.push(s)}}return t},getHiddenElementOuterHeight(e){if(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetHeight;return e.style.display="none",e.style.visibility="visible",t}return 0},getHiddenElementOuterWidth(e){if(e){e.style.visibility="hidden",e.style.display="block";let t=e.offsetWidth;return e.style.display="none",e.style.visibility="visible",t}return 0},getHiddenElementDimensions(e){if(e){let t={};return e.style.visibility="hidden",e.style.display="block",t.width=e.offsetWidth,t.height=e.offsetHeight,e.style.display="none",e.style.visibility="visible",t}return 0},fadeIn(e,t){if(e){e.style.opacity=0;let i=+new Date,n=0,r=function(){n=+e.style.opacity+(new Date().getTime()-i)/t,e.style.opacity=n,i=+new Date,+n<1&&(window.requestAnimationFrame&&requestAnimationFrame(r)||setTimeout(r,16))};r()}},fadeOut(e,t){if(e){let i=1,n=50,r=t,s=n/r,o=setInterval(()=>{i-=s,i<=0&&(i=0,clearInterval(o)),e.style.opacity=i},n)}},getUserAgent(){return navigator.userAgent},appendChild(e,t){if(this.isElement(t))t.appendChild(e);else if(t.el&&t.elElement)t.elElement.appendChild(e);else throw new Error("Cannot append "+t+" to "+e)},isElement(e){return typeof HTMLElement=="object"?e instanceof HTMLElement:e&&typeof e=="object"&&e!==null&&e.nodeType===1&&typeof e.nodeName=="string"},scrollInView(e,t){let i=getComputedStyle(e).getPropertyValue("borderTopWidth"),n=i?parseFloat(i):0,r=getComputedStyle(e).getPropertyValue("paddingTop"),s=r?parseFloat(r):0,o=e.getBoundingClientRect(),d=t.getBoundingClientRect().top+document.body.scrollTop-(o.top+document.body.scrollTop)-n-s,l=e.scrollTop,h=e.clientHeight,u=this.getOuterHeight(t);d<0?e.scrollTop=l+d:d+u>h&&(e.scrollTop=l+d-h+u)},clearSelection(){if(window.getSelection)window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().rangeCount>0&&window.getSelection().getRangeAt(0).getClientRects().length>0&&window.getSelection().removeAllRanges();else if(document.selection&&document.selection.empty)try{document.selection.empty()}catch{}},getSelection(){return window.getSelection?window.getSelection().toString():document.getSelection?document.getSelection().toString():document.selection?document.selection.createRange().text:null},calculateScrollbarWidth(){if(this.calculatedScrollbarWidth!=null)return this.calculatedScrollbarWidth;let e=document.createElement("div");e.className="p-scrollbar-measure",document.body.appendChild(e);let t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),this.calculatedScrollbarWidth=t,t},getBrowser(){if(!this.browser){let e=this.resolveUserAgent();this.browser={},e.browser&&(this.browser[e.browser]=!0,this.browser.version=e.version),this.browser.chrome?this.browser.webkit=!0:this.browser.webkit&&(this.browser.safari=!0)}return this.browser},resolveUserAgent(){let e=navigator.userAgent.toLowerCase(),t=/(chrome)[ ]([\w.]+)/.exec(e)||/(webkit)[ ]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ ]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},isVisible(e){return e&&e.offsetParent!=null},invokeElementMethod(e,t,i){e[t].apply(e,i)},isExist(e){return!!(e!==null&&typeof e<"u"&&e.nodeName&&e.parentNode)},isClient(){return!!(typeof window<"u"&&window.document&&window.document.createElement)},focus(e,t){e&&document.activeElement!==e&&e.focus(t)},isFocusableElement(e,t=""){return this.isElement(e)?e.matches(`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}`):!1},getFocusableElements(e,t=""){let i=this.find(e,`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}, [contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${t}`),n=[];for(let r of i)getComputedStyle(r).display!="none"&&getComputedStyle(r).visibility!="hidden"&&n.push(r);return n},getFirstFocusableElement(e,t){const i=this.getFocusableElements(e,t);return i.length>0?i[0]:null},getLastFocusableElement(e,t){const i=this.getFocusableElements(e,t);return i.length>0?i[i.length-1]:null},getNextFocusableElement(e,t,i){const n=this.getFocusableElements(e,i),r=n.length>0?n.findIndex(o=>o===t):-1,s=r>-1&&n.length>=r+1?r+1:-1;return s>-1?n[s]:null},isClickable(e){const t=e.nodeName,i=e.parentElement&&e.parentElement.nodeName;return t=="INPUT"||t=="BUTTON"||t=="A"||i=="INPUT"||i=="BUTTON"||i=="A"||this.hasClass(e,"p-button")||this.hasClass(e.parentElement,"p-button")||this.hasClass(e.parentElement,"p-checkbox")||this.hasClass(e.parentElement,"p-radiobutton")},applyStyle(e,t){if(typeof t=="string")e.style.cssText=t;else for(let i in t)e.style[i]=t[i]},isIOS(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream},isAndroid(){return/(android)/i.test(navigator.userAgent)},isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0},exportCSV(e,t){let i=new Blob([e],{type:"application/csv;charset=utf-8;"});if(window.navigator.msSaveOrOpenBlob)navigator.msSaveOrOpenBlob(i,t+".csv");else{let n=document.createElement("a");n.download!==void 0?(n.setAttribute("href",URL.createObjectURL(i)),n.setAttribute("download",t+".csv"),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n)):(e="data:text/csv;charset=utf-8,"+e,window.open(encodeURI(e)))}}};class fe{constructor(t,i=()=>{}){this.element=t,this.listener=i}bindScrollListener(){this.scrollableParents=c.getScrollableParents(this.element);for(let t=0;t<this.scrollableParents.length;t++)this.scrollableParents[t].addEventListener("scroll",this.listener)}unbindScrollListener(){if(this.scrollableParents)for(let t=0;t<this.scrollableParents.length;t++)this.scrollableParents[t].removeEventListener("scroll",this.listener)}destroy(){this.unbindScrollListener(),this.element=null,this.listener=null,this.scrollableParents=null}}function pe(){const e=new Map;return{on(t,i){let n=e.get(t);n?n.push(i):n=[i],e.set(t,n)},off(t,i){let n=e.get(t);n&&n.splice(n.indexOf(i)>>>0,1)},emit(t,i){let n=e.get(t);n&&n.slice().map(r=>{r(i)})}}}var f={equals(e,t,i){return i?this.resolveFieldData(e,i)===this.resolveFieldData(t,i):this.deepEquals(e,t)},deepEquals(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var i=Array.isArray(e),n=Array.isArray(t),r,s,o;if(i&&n){if(s=e.length,s!=t.length)return!1;for(r=s;r--!==0;)if(!this.deepEquals(e[r],t[r]))return!1;return!0}if(i!=n)return!1;var a=e instanceof Date,d=t instanceof Date;if(a!=d)return!1;if(a&&d)return e.getTime()==t.getTime();var l=e instanceof RegExp,h=t instanceof RegExp;if(l!=h)return!1;if(l&&h)return e.toString()==t.toString();var u=Object.keys(e);if(s=u.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,u[r]))return!1;for(r=s;r--!==0;)if(o=u[r],!this.deepEquals(e[o],t[o]))return!1;return!0}return e!==e&&t!==t},resolveFieldData(e,t){if(e&&Object.keys(e).length&&t){if(this.isFunction(t))return t(e);if(t.indexOf(".")===-1)return e[t];{let r=t.split("."),s=e;for(var i=0,n=r.length;i<n;++i){if(s==null)return null;s=s[r[i]]}return s}}else return null},isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},getItemValue(e,...t){return this.isFunction(e)?e(...t):e},filter(e,t,i){var n=[];if(e){for(let r of e)for(let s of t)if(String(this.resolveFieldData(r,s)).toLowerCase().indexOf(i.toLowerCase())>-1){n.push(r);break}}return n},reorderArray(e,t,i){e&&t!==i&&(i>=e.length&&(i%=e.length,t%=e.length),e.splice(i,0,e.splice(t,1)[0]))},findIndexInList(e,t){let i=-1;if(t){for(let n=0;n<t.length;n++)if(t[n]===e){i=n;break}}return i},contains(e,t){if(e!=null&&t&&t.length){for(let i of t)if(this.equals(e,i))return!0}return!1},insertIntoOrderedArray(e,t,i,n){if(i.length>0){let r=!1;for(let s=0;s<i.length;s++)if(this.findIndexInList(i[s],n)>t){i.splice(s,0,e),r=!0;break}r||i.push(e)}else i.push(e)},removeAccents(e){return e&&e.search(/[\xC0-\xFF]/g)>-1&&(e=e.replace(/[\xC0-\xC5]/g,"A").replace(/[\xC6]/g,"AE").replace(/[\xC7]/g,"C").replace(/[\xC8-\xCB]/g,"E").replace(/[\xCC-\xCF]/g,"I").replace(/[\xD0]/g,"D").replace(/[\xD1]/g,"N").replace(/[\xD2-\xD6\xD8]/g,"O").replace(/[\xD9-\xDC]/g,"U").replace(/[\xDD]/g,"Y").replace(/[\xDE]/g,"P").replace(/[\xE0-\xE5]/g,"a").replace(/[\xE6]/g,"ae").replace(/[\xE7]/g,"c").replace(/[\xE8-\xEB]/g,"e").replace(/[\xEC-\xEF]/g,"i").replace(/[\xF1]/g,"n").replace(/[\xF2-\xF6\xF8]/g,"o").replace(/[\xF9-\xFC]/g,"u").replace(/[\xFE]/g,"p").replace(/[\xFD\xFF]/g,"y")),e},getVNodeProp(e,t){let i=e.props;if(i){let n=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Object.prototype.hasOwnProperty.call(i,n)?n:t;return e.type.props[t].type===Boolean&&i[r]===""?!0:i[r]}return null},isEmpty(e){return e==null||e===""||Array.isArray(e)&&e.length===0||!(e instanceof Date)&&typeof e=="object"&&Object.keys(e).length===0},isNotEmpty(e){return!this.isEmpty(e)},isPrintableCharacter(e=""){return this.isNotEmpty(e)&&e.length===1&&e.match(/\S| /)},findLast(e,t){let i;if(this.isNotEmpty(e))try{i=e.findLast(t)}catch{i=[...e].reverse().find(t)}return i},findLastIndex(e,t){let i=-1;if(this.isNotEmpty(e))try{i=e.findLastIndex(t)}catch{i=e.lastIndexOf([...e].reverse().find(t))}return i}},F=0;function A(e="pv_id_"){return F++,`${e}${F}`}function U(){let e=[];const t=(o,a,d=999)=>{const l=r(o,a,d),h=l.value+(l.key===o?0:d)+1;return e.push({key:o,value:h}),h},i=o=>{e=e.filter(a=>a.value!==o)},n=(o,a)=>r(o,a).value,r=(o,a,d=0)=>[...e].reverse().find(l=>a?!0:l.key===o)||{key:o,value:d},s=o=>o&&parseInt(o.style.zIndex,10)||0;return{get:s,set:(o,a,d)=>{a&&(a.style.zIndex=String(t(o,!0,d)))},clear:o=>{o&&(i(s(o)),o.style.zIndex="")},getCurrent:o=>n(o,!0)}}var w=U();let E;function G(e){e.addEventListener("mousedown",T)}function q(e){e.removeEventListener("mousedown",T)}function Z(e){let t=document.createElement("span");t.className="p-ink",t.setAttribute("role","presentation"),t.setAttribute("aria-hidden","true"),e.appendChild(t),t.addEventListener("animationend",D)}function j(e){let t=O(e);t&&(q(e),t.removeEventListener("animationend",D),t.remove())}function T(e){let t=e.currentTarget,i=O(t);if(!i||getComputedStyle(i,null).display==="none")return;if(c.removeClass(i,"p-ink-active"),!c.getHeight(i)&&!c.getWidth(i)){let o=Math.max(c.getOuterWidth(t),c.getOuterHeight(t));i.style.height=o+"px",i.style.width=o+"px"}let n=c.getOffset(t),r=e.pageX-n.left+document.body.scrollTop-c.getWidth(i)/2,s=e.pageY-n.top+document.body.scrollLeft-c.getHeight(i)/2;i.style.top=s+"px",i.style.left=r+"px",c.addClass(i,"p-ink-active"),E=setTimeout(()=>{i&&c.removeClass(i,"p-ink-active")},401)}function D(e){E&&clearTimeout(E),c.removeClass(e.currentTarget,"p-ink-active")}function O(e){for(let t=0;t<e.children.length;t++)if(typeof e.children[t].className=="string"&&e.children[t].className.indexOf("p-ink")!==-1)return e.children[t];return null}const Y={mounted(e,t){t.instance.$primevue&&t.instance.$primevue.config&&t.instance.$primevue.config.ripple&&(Z(e),G(e))},unmounted(e){j(e)}};var K={name:"MenubarSub",emits:["item-mouseenter","item-click"],props:{items:{type:Array,default:null},root:{type:Boolean,default:!1},popup:{type:Boolean,default:!1},mobileActive:{type:Boolean,default:!1},template:{type:Function,default:null},exact:{type:Boolean,default:!0},level:{type:Number,default:0},menuId:{type:String,default:null},focusedItemId:{type:String,default:null},activeItemPath:{type:Object,default:null}},list:null,methods:{getItemId(e){return`${this.menuId}_${e.key}`},getItemKey(e){return this.getItemId(e)},getItemProp(e,t,i){return e&&e.item?f.getItemValue(e.item[t],i):void 0},getItemLabel(e){return this.getItemProp(e,"label")},isItemActive(e){return this.activeItemPath.some(t=>t.key===e.key)},isItemVisible(e){return this.getItemProp(e,"visible")!==!1},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemFocused(e){return this.focusedItemId===this.getItemId(e)},isItemGroup(e){return f.isNotEmpty(e.items)},onItemClick(e,t){this.getItemProp(t,"command",{originalEvent:e,item:t.item}),this.$emit("item-click",{originalEvent:e,processedItem:t,isFocus:!0})},onItemMouseEnter(e,t){this.$emit("item-mouseenter",{originalEvent:e,processedItem:t})},onItemActionClick(e,t){t&&t(e)},getAriaSetSize(){return this.items.filter(e=>this.isItemVisible(e)&&!this.getItemProp(e,"separator")).length},getAriaPosInset(e){return e-this.items.slice(0,e).filter(t=>this.isItemVisible(t)&&this.getItemProp(t,"separator")).length+1},getItemClass(e){return["p-menuitem",this.getItemProp(e,"class"),{"p-menuitem-active p-highlight":this.isItemActive(e),"p-focus":this.isItemFocused(e),"p-disabled":this.isItemDisabled(e)}]},getItemActionClass(e,t){return["p-menuitem-link",{"router-link-active":t&&t.isActive,"router-link-active-exact":this.exact&&t&&t.isExactActive}]},getItemIconClass(e){return["p-menuitem-icon",this.getItemProp(e,"icon")]},getSeparatorItemClass(e){return["p-menuitem-separator",this.getItemProp(e,"class")]},getSubmenuIcon(){return["p-submenu-icon pi",{"pi-angle-right":!this.root,"pi-angle-down":this.root}]}},computed:{containerClass(){return{"p-submenu-list":!this.root,"p-menubar-root-list":this.root}}},directives:{ripple:Y}};const X=["id","aria-label","aria-disabled","aria-expanded","aria-haspopup","aria-level","aria-setsize","aria-posinset"],J=["onClick","onMouseenter"],Q=["href","onClick"],$={class:"p-menuitem-text"},ee=["href","target"],te={class:"p-menuitem-text"},ie=["id"];function ne(e,t,i,n,r,s){const o=C("router-link"),a=C("MenubarSub",!0),d=R("ripple");return m(),p("ul",null,[(m(!0),p(x,null,W(i.items,(l,h)=>(m(),p(x,{key:s.getItemKey(l)},[s.isItemVisible(l)&&!s.getItemProp(l,"separator")?(m(),p("li",{key:0,id:s.getItemId(l),style:k(s.getItemProp(l,"style")),class:g(s.getItemClass(l)),role:"menuitem","aria-label":s.getItemLabel(l),"aria-disabled":s.isItemDisabled(l)||void 0,"aria-expanded":s.isItemGroup(l)?s.isItemActive(l):void 0,"aria-haspopup":s.isItemGroup(l)&&!s.getItemProp(l,"to")?"menu":void 0,"aria-level":i.level+1,"aria-setsize":s.getAriaSetSize(),"aria-posinset":s.getAriaPosInset(h)},[b("div",{class:"p-menuitem-content",onClick:u=>s.onItemClick(u,l),onMouseenter:u=>s.onItemMouseEnter(u,l)},[i.template?(m(),v(M(i.template),{key:1,item:l.item},null,8,["item"])):(m(),p(x,{key:0},[s.getItemProp(l,"to")&&!s.isItemDisabled(l)?(m(),v(o,{key:0,to:s.getItemProp(l,"to"),custom:""},{default:B(({navigate:u,href:y,isActive:V,isExactActive:H})=>[P((m(),p("a",{href:y,class:g(s.getItemActionClass(l,{isActive:V,isExactActive:H})),tabindex:"-1","aria-hidden":"true",onClick:N=>s.onItemActionClick(N,u)},[s.getItemProp(l,"icon")?(m(),p("span",{key:0,class:g(s.getItemIconClass(l))},null,2)):I("",!0),b("span",$,L(s.getItemLabel(l)),1)],10,Q)),[[d]])]),_:2},1032,["to"])):P((m(),p("a",{key:1,href:s.getItemProp(l,"url"),class:g(s.getItemActionClass(l)),target:s.getItemProp(l,"target"),tabindex:"-1","aria-hidden":"true"},[s.getItemProp(l,"icon")?(m(),p("span",{key:0,class:g(s.getItemIconClass(l))},null,2)):I("",!0),b("span",te,L(s.getItemLabel(l)),1),s.getItemProp(l,"items")?(m(),p("span",{key:1,class:g(s.getSubmenuIcon())},null,2)):I("",!0)],10,ee)),[[d]])],64))],40,J),s.isItemVisible(l)&&s.isItemGroup(l)?(m(),v(a,{key:0,menuId:i.menuId,role:"menu",class:"p-submenu-list",focusedItemId:i.focusedItemId,items:l.items,mobileActive:i.mobileActive,activeItemPath:i.activeItemPath,template:i.template,exact:i.exact,level:i.level+1,onItemClick:t[0]||(t[0]=u=>e.$emit("item-click",u)),onItemMouseenter:t[1]||(t[1]=u=>e.$emit("item-mouseenter",u))},null,8,["menuId","focusedItemId","items","mobileActive","activeItemPath","template","exact","level"])):I("",!0)],14,X)):I("",!0),s.isItemVisible(l)&&s.getItemProp(l,"separator")?(m(),p("li",{key:1,id:s.getItemId(l),style:k(s.getItemProp(l,"style")),class:g(s.getSeparatorItemClass(l)),role:"separator"},null,14,ie)):I("",!0)],64))),128))])}K.render=ne;var se={name:"Menubar",emits:["focus","blur"],props:{model:{type:Array,default:null},exact:{type:Boolean,default:!0},buttonProps:{type:null,default:null},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},data(){return{id:this.$attrs.id,mobileActive:!1,focused:!1,focusedItemInfo:{index:-1,level:0,parentKey:""},activeItemPath:[],dirty:!1}},watch:{"$attrs.id":function(e){this.id=e||A()},activeItemPath(e){f.isNotEmpty(e)?(this.bindOutsideClickListener(),this.bindResizeListener()):(this.unbindOutsideClickListener(),this.unbindResizeListener())}},outsideClickListener:null,container:null,menubar:null,mounted(){this.id=this.id||A()},beforeUnmount(){this.mobileActive=!1,this.unbindOutsideClickListener(),this.unbindResizeListener(),this.container&&w.clear(this.container),this.container=null},methods:{getItemProp(e,t){return e?f.getItemValue(e[t]):void 0},getItemLabel(e){return this.getItemProp(e,"label")},isItemDisabled(e){return this.getItemProp(e,"disabled")},isItemGroup(e){return f.isNotEmpty(this.getItemProp(e,"items"))},isItemSeparator(e){return this.getItemProp(e,"separator")},getProccessedItemLabel(e){return e?this.getItemLabel(e.item):void 0},isProccessedItemGroup(e){return e&&f.isNotEmpty(e.items)},toggle(e){this.mobileActive?(this.mobileActive=!1,w.clear(this.menubar),this.hide()):(this.mobileActive=!0,w.set("menu",this.menubar,this.$primevue.config.zIndex.menu),setTimeout(()=>{this.show()},0)),this.bindOutsideClickListener(),e.preventDefault()},show(){this.focusedItemInfo={index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},c.focus(this.menubar)},hide(e,t){this.mobileActive&&setTimeout(()=>{c.focus(this.$refs.menubutton)},0),this.activeItemPath=[],this.focusedItemInfo={index:-1,level:0,parentKey:""},t&&c.focus(this.menubar),this.dirty=!1},onFocus(e){this.focused=!0,this.focusedItemInfo=this.focusedItemInfo.index!==-1?this.focusedItemInfo:{index:this.findFirstFocusedItemIndex(),level:0,parentKey:""},this.$emit("focus",e)},onBlur(e){this.focused=!1,this.focusedItemInfo={index:-1,level:0,parentKey:""},this.searchValue="",this.dirty=!1,this.$emit("blur",e)},onKeyDown(e){const t=e.metaKey||e.ctrlKey;switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"ArrowLeft":this.onArrowLeftKey(e);break;case"ArrowRight":this.onArrowRightKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Space":this.onSpaceKey(e);break;case"Enter":this.onEnterKey(e);break;case"Escape":this.onEscapeKey(e);break;case"Tab":this.onTabKey(e);break;case"PageDown":case"PageUp":case"Backspace":case"ShiftLeft":case"ShiftRight":break;default:!t&&f.isPrintableCharacter(e.key)&&this.searchItems(e,e.key);break}},onItemChange(e){const{processedItem:t,isFocus:i}=e;if(f.isEmpty(t))return;const{index:n,key:r,level:s,parentKey:o,items:a}=t,d=f.isNotEmpty(a),l=this.activeItemPath.filter(h=>h.parentKey!==o&&h.parentKey!==r);d&&l.push(t),this.focusedItemInfo={index:n,level:s,parentKey:o},this.activeItemPath=l,d&&(this.dirty=!0),i&&c.focus(this.menubar)},onItemClick(e){const{originalEvent:t,processedItem:i}=e,n=this.isProccessedItemGroup(i),r=f.isEmpty(i.parent);if(this.isSelected(i)){const{index:o,key:a,level:d,parentKey:l}=i;this.activeItemPath=this.activeItemPath.filter(h=>a!==h.key&&a.startsWith(h.key)),this.focusedItemInfo={index:o,level:d,parentKey:l},this.dirty=!r,c.focus(this.menubar)}else if(n)this.onItemChange(e);else{const o=r?i:this.activeItemPath.find(a=>a.parentKey==="");this.hide(t),this.changeFocusedItemIndex(t,o?o.index:-1),this.mobileActive=!1,c.focus(this.menubar)}},onItemMouseEnter(e){!this.mobileActive&&this.dirty&&this.onItemChange(e)},menuButtonClick(e){this.toggle(e)},menuButtonKeydown(e){(e.code==="Enter"||e.code==="Space")&&this.menuButtonClick(e)},onArrowDownKey(e){const t=this.visibleItems[this.focusedItemInfo.index];if(t?f.isEmpty(t.parent):null)this.isProccessedItemGroup(t)&&(this.onItemChange({originalEvent:e,processedItem:t}),this.focusedItemInfo={index:-1,parentKey:t.key},this.onArrowRightKey(e));else{const n=this.focusedItemInfo.index!==-1?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(e,n),e.preventDefault()}},onArrowUpKey(e){const t=this.visibleItems[this.focusedItemInfo.index];if(f.isEmpty(t.parent)){if(this.isProccessedItemGroup(t)){this.onItemChange({originalEvent:e,processedItem:t}),this.focusedItemInfo={index:-1,parentKey:t.key};const r=this.findLastItemIndex();this.changeFocusedItemIndex(e,r)}}else{const n=this.activeItemPath.find(r=>r.key===t.parentKey);if(this.focusedItemInfo.index===0)this.focusedItemInfo={index:-1,parentKey:n?n.parentKey:""},this.searchValue="",this.onArrowLeftKey(e),this.activeItemPath=this.activeItemPath.filter(r=>r.parentKey!==this.focusedItemInfo.parentKey);else{const r=this.focusedItemInfo.index!==-1?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(e,r)}}e.preventDefault()},onArrowLeftKey(e){const t=this.visibleItems[this.focusedItemInfo.index],i=t?this.activeItemPath.find(n=>n.key===t.parentKey):null;if(i)this.onItemChange({originalEvent:e,processedItem:i}),this.activeItemPath=this.activeItemPath.filter(n=>n.parentKey!==this.focusedItemInfo.parentKey),e.preventDefault();else{const n=this.focusedItemInfo.index!==-1?this.findPrevItemIndex(this.focusedItemInfo.index):this.findLastFocusedItemIndex();this.changeFocusedItemIndex(e,n),e.preventDefault()}},onArrowRightKey(e){const t=this.visibleItems[this.focusedItemInfo.index];if(t?this.activeItemPath.find(n=>n.key===t.parentKey):null)this.isProccessedItemGroup(t)&&(this.onItemChange({originalEvent:e,processedItem:t}),this.focusedItemInfo={index:-1,parentKey:t.key},this.onArrowDownKey(e));else{const n=this.focusedItemInfo.index!==-1?this.findNextItemIndex(this.focusedItemInfo.index):this.findFirstFocusedItemIndex();this.changeFocusedItemIndex(e,n),e.preventDefault()}},onHomeKey(e){this.changeFocusedItemIndex(e,this.findFirstItemIndex()),e.preventDefault()},onEndKey(e){this.changeFocusedItemIndex(e,this.findLastItemIndex()),e.preventDefault()},onEnterKey(e){if(this.focusedItemInfo.index!==-1){const t=c.findSingle(this.menubar,`li[id="${`${this.focusedItemId}`}"]`),i=t&&c.findSingle(t,".p-menuitem-link");i?i.click():t&&t.click();const n=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(n)&&(this.focusedItemInfo.index=this.findFirstFocusedItemIndex())}e.preventDefault()},onSpaceKey(e){this.onEnterKey(e)},onEscapeKey(e){this.hide(e,!0),this.focusedItemInfo.index=this.findFirstFocusedItemIndex(),e.preventDefault()},onTabKey(e){if(this.focusedItemInfo.index!==-1){const t=this.visibleItems[this.focusedItemInfo.index];!this.isProccessedItemGroup(t)&&this.onItemChange({originalEvent:e,processedItem:t})}this.hide()},bindOutsideClickListener(){this.outsideClickListener||(this.outsideClickListener=e=>{const t=this.menubar!==e.target&&!this.menubar.contains(e.target),i=this.mobileActive&&this.$refs.menubutton!==e.target&&!this.$refs.menubutton.contains(e.target);t&&(i?this.mobileActive=!1:this.hide())},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindResizeListener(){this.resizeListener||(this.resizeListener=e=>{c.isTouchDevice()||this.hide(e,!0),this.mobileActive=!1},window.addEventListener("resize",this.resizeListener))},unbindResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},isItemMatched(e){return this.isValidItem(e)&&this.getProccessedItemLabel(e).toLocaleLowerCase().startsWith(this.searchValue.toLocaleLowerCase())},isValidItem(e){return!!e&&!this.isItemDisabled(e.item)&&!this.isItemSeparator(e.item)},isValidSelectedItem(e){return this.isValidItem(e)&&this.isSelected(e)},isSelected(e){return this.activeItemPath.some(t=>t.key===e.key)},findFirstItemIndex(){return this.visibleItems.findIndex(e=>this.isValidItem(e))},findLastItemIndex(){return f.findLastIndex(this.visibleItems,e=>this.isValidItem(e))},findNextItemIndex(e){const t=e<this.visibleItems.length-1?this.visibleItems.slice(e+1).findIndex(i=>this.isValidItem(i)):-1;return t>-1?t+e+1:e},findPrevItemIndex(e){const t=e>0?f.findLastIndex(this.visibleItems.slice(0,e),i=>this.isValidItem(i)):-1;return t>-1?t:e},findSelectedItemIndex(){return this.visibleItems.findIndex(e=>this.isValidSelectedItem(e))},findFirstFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findFirstItemIndex():e},findLastFocusedItemIndex(){const e=this.findSelectedItemIndex();return e<0?this.findLastItemIndex():e},searchItems(e,t){this.searchValue=(this.searchValue||"")+t;let i=-1,n=!1;return this.focusedItemInfo.index!==-1?(i=this.visibleItems.slice(this.focusedItemInfo.index).findIndex(r=>this.isItemMatched(r)),i=i===-1?this.visibleItems.slice(0,this.focusedItemInfo.index).findIndex(r=>this.isItemMatched(r)):i+this.focusedItemInfo.index):i=this.visibleItems.findIndex(r=>this.isItemMatched(r)),i!==-1&&(n=!0),i===-1&&this.focusedItemInfo.index===-1&&(i=this.findFirstFocusedItemIndex()),i!==-1&&this.changeFocusedItemIndex(e,i),this.searchTimeout&&clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{this.searchValue="",this.searchTimeout=null},500),n},changeFocusedItemIndex(e,t){this.focusedItemInfo.index!==t&&(this.focusedItemInfo.index=t,this.scrollInView())},scrollInView(e=-1){const t=e!==-1?`${this.id}_${e}`:this.focusedItemId,i=c.findSingle(this.menubar,`li[id="${t}"]`);i&&i.scrollIntoView&&i.scrollIntoView({block:"nearest",inline:"start"})},createProcessedItems(e,t=0,i={},n=""){const r=[];return e&&e.forEach((s,o)=>{const a=(n!==""?n+"_":"")+o,d={item:s,index:o,level:t,key:a,parent:i,parentKey:n};d.items=this.createProcessedItems(s.items,t+1,d,a),r.push(d)}),r},containerRef(e){this.container=e},menubarRef(e){this.menubar=e?e.$el:void 0}},computed:{containerClass(){return["p-menubar p-component",{"p-menubar-mobile-active":this.mobileActive}]},processedItems(){return this.createProcessedItems(this.model||[])},visibleItems(){const e=this.activeItemPath.find(t=>t.key===this.focusedItemInfo.parentKey);return e?e.items:this.processedItems},focusedItemId(){return this.focusedItemInfo.index!==-1?`${this.id}${f.isNotEmpty(this.focusedItemInfo.parentKey)?"_"+this.focusedItemInfo.parentKey:""}_${this.focusedItemInfo.index}`:null}},components:{MenubarSub:K}};const re={key:0,class:"p-menubar-start"},oe=["aria-haspopup","aria-expanded","aria-controls","aria-label"],le=b("i",{class:"pi pi-bars"},null,-1),ae=[le],de={key:2,class:"p-menubar-end"};function ue(e,t,i,n,r,s){const o=C("MenubarSub");return m(),p("div",{ref:s.containerRef,class:g(s.containerClass)},[e.$slots.start?(m(),p("div",re,[S(e.$slots,"start")])):I("",!0),i.model&&i.model.length>0?(m(),p("a",z({key:1,ref:"menubutton",role:"button",tabindex:"0",class:"p-menubar-button","aria-haspopup":!!(i.model.length&&i.model.length>0),"aria-expanded":r.mobileActive,"aria-controls":r.id,"aria-label":e.$primevue.config.locale.aria.navigation,onClick:t[0]||(t[0]=a=>s.menuButtonClick(a)),onKeydown:t[1]||(t[1]=a=>s.menuButtonKeydown(a))},i.buttonProps),ae,16,oe)):I("",!0),_(o,{ref:s.menubarRef,id:r.id,class:"p-menubar-root-list",role:"menubar",items:s.processedItems,template:e.$slots.item,root:!0,mobileActive:r.mobileActive,tabindex:"0","aria-activedescendant":r.focused?s.focusedItemId:void 0,menuId:r.id,focusedItemId:r.focused?s.focusedItemId:void 0,activeItemPath:r.activeItemPath,exact:i.exact,level:0,"aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel,onFocus:s.onFocus,onBlur:s.onBlur,onKeydown:s.onKeyDown,onItemClick:s.onItemClick,onItemMouseenter:s.onItemMouseEnter},null,8,["id","items","template","mobileActive","aria-activedescendant","menuId","focusedItemId","activeItemPath","exact","aria-labelledby","aria-label","onFocus","onBlur","onKeydown","onItemClick","onItemMouseenter"]),e.$slots.end?(m(),p("div",de,[S(e.$slots,"end")])):I("",!0)],2)}function ce(e,t){t===void 0&&(t={});var i=t.insertAt;if(!(!e||typeof document>"u")){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",i==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}var he=` .p-menubar { display: flex; align-items: center; } .p-menubar ul { margin: 0; padding: 0; list-style: none; } .p-menubar .p-menuitem-link { cursor: pointer; display: flex; align-items: center; text-decoration: none; overflow: hidden; position: relative; } .p-menubar .p-menuitem-text { line-height: 1; } .p-menubar .p-menuitem { position: relative; } .p-menubar-root-list { display: flex; align-items: center; flex-wrap: wrap; } .p-menubar-root-list > li ul { display: none; z-index: 1; } .p-menubar-root-list > .p-menuitem-active > .p-submenu-list { display: block; } .p-menubar .p-submenu-list { display: none; position: absolute; z-index: 1; } .p-menubar .p-submenu-list > .p-menuitem-active > .p-submenu-list { display: block; left: 100%; top: 0; } .p-menubar .p-submenu-list .p-menuitem .p-menuitem-content .p-menuitem-link .p-submenu-icon { margin-left: auto; } .p-menubar .p-menubar-end { margin-left: auto; align-self: center; } .p-menubar-button { display: none; cursor: pointer; align-items: center; justify-content: center; text-decoration: none; } `;ce(he);se.render=ue;export{fe as C,c as D,f as O,Y as R,A as U,w as Z,pe as p,se as s};