import e from"../Divider.mjs";import t from"../ItemGroup.mjs";import n from"../MenuItem.mjs";import r from"../SubMenu.mjs";import{createVNode as i,ref as a,shallowRef as o,watch as s}from"vue";function c(o,s,l){return(o||[]).map((o,u)=>{if(o&&typeof o==`object`){let{label:d,children:f,key:p,type:m,...h}=o,g=p??`tmp-${u}`,_=l?l.parentKeys.slice():[],v=[],y={eventKey:g,key:g,parentEventKeys:a(_),parentKeys:a(_),childrenEventKeys:a(v),isLeaf:!1};if(f||m===`group`){if(m===`group`){let e=c(f,s,l);return i(t,{key:g,...h,title:d,originItemValue:o},{default:()=>[e]})}s.set(g,y),l&&l.childrenEventKeys.push(g);let e=c(f,s,{childrenEventKeys:v,parentKeys:[].concat(_,g)});return i(r,{key:g,...h,title:d,originItemValue:o},{default:()=>[e]})}return m===`divider`?i(e,{key:g,...h},null):(y.isLeaf=!0,s.set(g,y),i(n,{key:g,...h,originItemValue:o},{default:()=>[d]}))}return null}).filter(e=>e)}function l(e){let t=o([]),n=o(!1),r=o(new Map);return s(()=>e.items,()=>{let i=new Map;n.value=!1,e.items?(n.value=!0,t.value=c(e.items,i)):t.value=void 0,r.value=i},{immediate:!0,deep:!0}),{itemsNodes:t,store:r,hasItmes:n}}export{l as default};