const e=require("../../_util/type.js"),t=require("../../_util/props-util/index.js"),n=require("../../_util/vue-types/index.js"),r=require("../../vc-util/devWarning.js"),i=require("../../_util/KeyCode.js"),a=require("../../_util/vnode.js"),o=require("../../vc-overflow/index.js"),s=require("../../tooltip/index.js"),c=require("./hooks/useMenuContext.js"),l=require("./hooks/useKeyPath.js"),u=require("./hooks/useDirectionStyle.js");let d=require("vue");var f=0,p=()=>({id:String,role:String,disabled:Boolean,danger:Boolean,title:{type:[String,Boolean],default:void 0},icon:n.default.any,onMouseenter:Function,onMouseleave:Function,onClick:Function,onKeydown:Function,onFocus:Function,originItemValue:e.objectType()}),m=(0,d.defineComponent)({compatConfig:{MODE:3},name:`AMenuItem`,inheritAttrs:!1,props:p(),slots:Object,setup(e,{slots:n,emit:p,attrs:m}){let h=(0,d.getCurrentInstance)(),g=l.useMeasure(),_=typeof h.vnode.key==`symbol`?String(h.vnode.key):h.vnode.key;r.default(typeof h.vnode.key!=`symbol`,`MenuItem`,`MenuItem \`:key="${String(_)}"\` not support Symbol type`);let v=`menu_item_${++f}_$$_${_}`,{parentEventKeys:y,parentKeys:b}=l.useInjectKeyPath(),{prefixCls:x,activeKeys:S,disabled:C,changeActiveKeys:w,rtl:T,inlineCollapsed:E,siderCollapsed:D,onItemClick:O,selectedKeys:k,registerMenuInfo:A,unRegisterMenuInfo:j}=c.useInjectMenu(),M=c.useInjectFirstLevel(),N=(0,d.shallowRef)(!1),P=(0,d.computed)(()=>[...b.value,_]);A(v,{eventKey:v,key:_,parentEventKeys:y,parentKeys:b,isLeaf:!0}),(0,d.onBeforeUnmount)(()=>{j(v)}),(0,d.watch)(S,()=>{N.value=!!S.value.find(e=>e===_)},{immediate:!0});let F=(0,d.computed)(()=>C.value||e.disabled),I=(0,d.computed)(()=>k.value.includes(_)),L=(0,d.computed)(()=>{let t=`${x.value}-item`;return{[`${t}`]:!0,[`${t}-danger`]:e.danger,[`${t}-active`]:N.value,[`${t}-selected`]:I.value,[`${t}-disabled`]:F.value}}),R=t=>({key:_,eventKey:v,keyPath:P.value,eventKeyPath:[...y.value,v],domEvent:t,item:{...e,...m}}),z=e=>{if(F.value)return;let t=R(e);p(`click`,e),O(t)},B=e=>{F.value||(w(P.value),p(`mouseenter`,e))},V=e=>{F.value||(w([]),p(`mouseleave`,e))},H=e=>{if(p(`keydown`,e),e.which===i.default.ENTER){let t=R(e);p(`click`,e),O(t)}},U=e=>{w(P.value),p(`focus`,e)},W=(e,n)=>{let r=(0,d.createVNode)(`span`,{class:`${x.value}-title-content`},[n]);return(!e||t.isValidElement(n)&&n.type===`span`)&&n&&E.value&&M&&typeof n==`string`?(0,d.createVNode)(`div`,{class:`${x.value}-inline-collapsed-noicon`},[n.charAt(0)]):r},G=u.default((0,d.computed)(()=>P.value.length));return()=>{if(g)return null;let r=e.title??n.title?.(),i=t.flattenChildren(n.default?.()),c=i.length,l=r;r===void 0?l=M&&c?i:``:r===!1&&(l=``);let u={title:l};!D.value&&!E.value&&(u.title=null,u.open=!1);let f={};e.role===`option`&&(f[`aria-selected`]=I.value);let p=e.icon??n.icon?.(e);return(0,d.createVNode)(s.default,{...u,placement:T.value?`left`:`right`,overlayClassName:`${x.value}-inline-collapsed-tooltip`},{default:()=>[(0,d.createVNode)(o.default.Item,{component:`li`,...m,id:e.id,style:{...m.style||{},...G.value},class:[L.value,{[`${m.class}`]:!!m.class,[`${x.value}-item-only-child`]:(p?c+1:c)===1}],role:e.role||`menuitem`,tabindex:e.disabled?null:-1,"data-menu-id":_,"aria-disabled":e.disabled,...f,onMouseenter:B,onMouseleave:V,onClick:z,onKeydown:H,onFocus:U,title:typeof r==`string`?r:void 0},{default:()=>[a.cloneElement(typeof p==`function`?p(e.originItemValue):p,{class:`${x.value}-item-icon`},!1),W(p,i)]})]})}}});exports.default=m,exports.menuItemProps=p;