import{a as m,j as n,e as k,d as C}from"./antd.c323f587.js";import{u as z,g as I,I as L}from"./Link.e66d18a6.js";import{s as N,g as S}from"./index.a5de5d12.js";import{d as j,u as A,a as K,b as P,j as E}from"./index.5fa92bd5.js";import{r as G}from"./react.dcf569d1.js";function H({item:s,...o}){const r=E(s.ref,s.icon);return n(L,{name:r,...o})}function b({item:s,iconMode:o,iconSize:r,style:f}){var i,c,d;const{openLink:y}=z(),[p,a]=G.exports.useState(!1),t=A(),l=K();return P(()=>{(async()=>{let{permissions:e,roles:h}={...s.admittance};e||(e=await I(s.ref)),h||(h=l.map(g=>t[g.key])),Array.isArray(e)&&e.length>0?e.forEach(g=>{const[x,u]=g.split("@");if(u&&!t[u])return;S(u?t[u]:0,h).promise.then(M=>{const v=!!M.find(w=>w.key===x);a(v)})}):a(!0)})()},[s.admittance,t,l,s.ref]),p?n(k.Item,{onClick:e=>{e.stopPropagation(),y(s.ref)},children:m("div",{className:C("grid-item",o==="horizonal"?"horizonal":"vertical"),style:{...f,...(i=s.styles)==null?void 0:i.default},children:[n(H,{item:s,style:{...(c=s.styles)==null?void 0:c.icon,fontSize:r}}),n("span",{className:"title",style:(d=s.styles)==null?void 0:d.title,children:s.title})]})}):null}function O({item:s}){var a,t,l,i,c;j();const o=s.gutter===void 0?8:Math.min(Math.max(0,s.gutter),24),r=s.rowHeight===void 0?96:Math.min(Math.max(32,s.rowHeight),256),f=s.iconMode==="horizonal"?"1.5em":r*.5,y=s.iconMode||"vertical",p={...(a=s.styles)==null?void 0:a.link,height:r};return m("div",{className:N.grid,style:(t=s.styles)==null?void 0:t.default,children:[s.title&&n("div",{className:"grid-title",style:(l=s.styles)==null?void 0:l.title,children:s.title}),n(k,{columns:s.columns||3,gap:o,style:{alignContent:"start",padding:o,...(i=s.styles)==null?void 0:i.grid},children:(c=s.items)==null?void 0:c.map((d,e)=>n(b,{item:d,iconSize:f,iconMode:y,style:p},e))})]})}export{O as default};
