const e=require("../../../_util/type.js"),t=require("../../../_util/classNames.js"),n=require("../../../_util/vue-types/index.js"),r=require("../../../_util/KeyCode.js"),i=require("../../../_util/hooks/useState.js"),a=require("../../../menu/src/MenuItem.js"),o=require("../../../menu/src/OverrideContext.js"),s=require("../../../menu/index.js"),c=require("../../../vc-dropdown/index.js"),l=require("./AddButton.js");let u=require("vue"),d=require("@antsoo-lib/icons");var f={prefixCls:{type:String},id:{type:String},tabs:{type:Object},rtl:{type:Boolean},tabBarGutter:{type:Number},activeKey:{type:[String,Number]},mobile:{type:Boolean},moreIcon:n.default.any,moreTransitionName:{type:String},editable:{type:Object},locale:{type:Object,default:void 0},removeAriaLabel:String,onTabClick:{type:Function},popupClassName:String,getPopupContainer:e.functionType()},p=(0,u.defineComponent)({compatConfig:{MODE:3},name:`OperationNode`,inheritAttrs:!1,props:f,emits:[`tabClick`],slots:Object,setup(e,{attrs:n,slots:f}){let[p,m]=i.default(!1),[h,g]=i.default(null),_=t=>{let n=e.tabs.filter(e=>!e.disabled),r=n.findIndex(e=>e.key===h.value)||0,i=n.length;for(let e=0;e<i;e+=1){r=(r+t+i)%i;let e=n[r];if(!e.disabled){g(e.key);return}}},v=t=>{let{which:n}=t;if(!p.value){[r.default.DOWN,r.default.SPACE,r.default.ENTER].includes(n)&&(m(!0),t.preventDefault());return}switch(n){case r.default.UP:_(-1),t.preventDefault();break;case r.default.DOWN:_(1),t.preventDefault();break;case r.default.ESC:m(!1);break;case r.default.SPACE:case r.default.ENTER:h.value!==null&&e.onTabClick(h.value,t);break}},y=(0,u.computed)(()=>`${e.id}-more-popup`),b=(0,u.computed)(()=>h.value===null?null:`${y.value}-${h.value}`),x=(t,n)=>{t.preventDefault(),t.stopPropagation(),e.editable.onEdit(`remove`,{key:n,event:t})};return(0,u.onMounted)(()=>{(0,u.watch)(h,()=>{let e=document.getElementById(b.value);e&&e.scrollIntoView&&e.scrollIntoView(!1)},{flush:`post`,immediate:!0})}),(0,u.watch)(p,()=>{p.value||g(null)}),o.useProvideOverride({}),()=>{let{prefixCls:r,id:i,tabs:o,locale:g,mobile:_,moreIcon:S=f.moreIcon?.()||(0,u.createVNode)(d.EllipsisOutlined,null,null),moreTransitionName:C,editable:w,tabBarGutter:T,rtl:E,onTabClick:D,popupClassName:O}=e;if(!o.length)return null;let k=`${r}-dropdown`,A=g?.dropdownAriaLabel,j={[E?`marginRight`:`marginLeft`]:T};o.length||(j.visibility=`hidden`,j.order=1);let M=t.default({[`${k}-rtl`]:E,[`${O}`]:!0}),N=_?null:(0,u.createVNode)(c.default,{prefixCls:k,trigger:[`hover`],visible:p.value,transitionName:C,onVisibleChange:m,overlayClassName:M,mouseEnterDelay:.1,mouseLeaveDelay:.1,getPopupContainer:e.getPopupContainer},{overlay:()=>(0,u.createVNode)(s.default,{onClick:({key:e,domEvent:t})=>{D(e,t),m(!1)},id:y.value,tabindex:-1,role:`listbox`,"aria-activedescendant":b.value,selectedKeys:[h.value],"aria-label":A===void 0?`expanded dropdown`:A},{default:()=>[o.map(t=>{let n=w&&t.closable!==!1&&!t.disabled;return(0,u.createVNode)(a.default,{key:t.key,id:`${y.value}-${t.key}`,role:`option`,"aria-controls":i&&`${i}-panel-${t.key}`,disabled:t.disabled},{default:()=>[(0,u.createVNode)(`span`,null,[typeof t.tab==`function`?t.tab():t.tab]),n&&(0,u.createVNode)(`button`,{type:`button`,"aria-label":e.removeAriaLabel||`remove`,tabindex:0,class:`${k}-menu-item-remove`,onClick:e=>{e.stopPropagation(),x(e,t.key)}},[t.closeIcon?.()||w.removeIcon?.()||`×`])]})})]}),default:()=>(0,u.createVNode)(`button`,{type:`button`,class:`${r}-nav-more`,style:j,tabindex:-1,"aria-hidden":`true`,"aria-haspopup":`listbox`,"aria-controls":y.value,id:`${i}-more`,"aria-expanded":p.value,onKeydown:v},[S])});return(0,u.createVNode)(`div`,{class:t.default(`${r}-nav-operations`,n.class),style:n.style},[N,(0,u.createVNode)(l.default,{prefixCls:r,locale:g,editable:w},null)])}}});exports.default=p,exports.operationNodeProps=f;