import{r as p,u as k}from"./react.dcf569d1.js";import{j as s,a as v,b as A,F as D,S as j}from"./antd.c323f587.js";import{O as w,G as L,u as R,a as N,b as z,L as K,_ as f,c as T,P as V}from"./index.5fa92bd5.js";const B="_page_1h5f3_1",$="_grid_1h5f3_26",G="_user-bar_1h5f3_52",F="_user-card_1h5f3_97",M="_group-picker_1h5f3_144",U="_role-picker_1h5f3_147",q={page:B,grid:$,userBar:G,userCard:F,groupPicker:M,rolePicker:U};function J(e,r){for(;e.length<r;)e="0"+e;return e}function l(e,r){var t,n,o;if(r.length===0)return e;for(t=0,o=r.length;t<o;t++)n=r.charCodeAt(t),e=(e<<5)-e+n,e|=0;return e<0?e*-2:e}function Q(e,r,t){return Object.keys(r).sort().reduce(n,e);function n(o,i){return E(o,r[i],i,t)}}function E(e,r,t,n){var o=l(l(l(e,t),W(r)),typeof r);if(r===null)return l(o,"null");if(r===void 0)return l(o,"undefined");if(typeof r=="object"||typeof r=="function"){if(n.indexOf(r)!==-1)return l(o,"[Circular]"+t);n.push(r);var i=Q(o,r,n);if(!("valueOf"in r)||typeof r.valueOf!="function")return i;try{return l(i,String(r.valueOf()))}catch(a){return l(i,"[valueOf exception]"+(a.stack||a.message))}}return l(o,r.toString())}function W(e){return Object.prototype.toString.call(e)}function X(e){return J(E(0,e,"",[]).toString(16),8)}var Y=X;let g=new Map;function Z(e,r=[]){const t=Date.now();g.forEach((i,a)=>i.expires<t&&g.delete(a));const n=Y({groupId:e,roleIds:r});let o=g.get(n);if(!o){const i=new w(`Permissions@${e}/${r.join(",")}`),a={pp:"-1"};e&&(a.group=String(e)),r&&r.length>0&&(a.role$=r.join(","));const m=L().get({path:"/api/v1/current-user/permissions",query:a}).then(({permissions:d})=>d).catch(d=>(console.debug(`getPermissionContext ${String(d)}`),[]));m.then(d=>{i.$notify("update",d)}),o={promise:m,ob:i,expires:t+3e6},g.set(n,o)}return o}const I=p.exports.lazy(()=>f(()=>import("./Divider.f7edd7df.js"),["Divider.f7edd7df.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js"],import.meta.url)),H=p.exports.lazy(()=>f(()=>import("./UserBar.9f68d95f.js"),["UserBar.9f68d95f.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js","Link.e66d18a6.js","index.5fa92bd5.js","index.c9232e81.css","Mustache.3156ce03.js","Groups.164b9901.js","Roles.b29dacff.js"],import.meta.url)),ee=p.exports.lazy(()=>f(()=>import("./UserCard.4028eb5f.js"),["UserCard.4028eb5f.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js","Link.e66d18a6.js","index.5fa92bd5.js","index.c9232e81.css","Mustache.3156ce03.js","Groups.164b9901.js","Roles.b29dacff.js"],import.meta.url)),re=p.exports.lazy(()=>f(()=>import("./Grid.e01473bd.js"),["Grid.e01473bd.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js","Link.e66d18a6.js","index.5fa92bd5.js","index.c9232e81.css"],import.meta.url)),te=p.exports.lazy(()=>f(()=>import("./GroupPicker.936a25c4.js"),["GroupPicker.936a25c4.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js","Groups.164b9901.js","index.5fa92bd5.js","index.c9232e81.css"],import.meta.url)),oe=p.exports.lazy(()=>f(()=>import("./RolePicker.3a773865.js"),["RolePicker.3a773865.js","antd.c323f587.js","antd.d7225b1d.css","react.dcf569d1.js","Roles.b29dacff.js","index.5fa92bd5.js","index.c9232e81.css"],import.meta.url)),ne={divider:I,grid:re,"user-bar":H,"user-card":ee,"group-picker":te,"role-picker":oe};function h({item:e}){const r=ne[e.type];return r?s(r,{item:e}):null}function ie({page:e,header:r,footer:t}){var m,d,P,x;const[n,o]=p.exports.useState(),i=R(),a=N();return z(()=>{let{permissions:c,roles:u}={...e.admittance};u||(u=a.map(y=>i[y.key])),Array.isArray(c)&&c.length>0?c.forEach(y=>{const[O,_]=y.split("@");if(_&&!i[_])return;Z(_?i[_]:0,u).promise.then(S=>{const C=!!S.find(b=>b.key===O);o(C)})}):o(!0)},[e.admittance,i,a]),n===void 0?s(K,{}):v("div",{className:q.page,style:{...(m=e.styles)==null?void 0:m.default},children:[e.header!==!1&&r&&s("div",{className:"header",children:(d=r.items)==null?void 0:d.map((c,u)=>s(h,{item:c},u))}),n?s("div",{className:"body",children:(P=e.items)==null?void 0:P.map((c,u)=>s(h,{item:c},u))}):v("div",{className:"result",children:[s("div",{className:"icon",children:s(A,{})}),s("div",{className:"title",children:"\u60A8\u6CA1\u6709\u6743\u9650\u8BBF\u95EE\u8BE5\u9875\u9762"})]}),e.footer!==!1&&t&&s("div",{className:"footer",children:(x=t.items)==null?void 0:x.map((c,u)=>s(h,{item:c},u))})]})}function se(){const e=T(),r=k(),t=p.exports.useMemo(()=>{const n=(r==null?void 0:r.page)||".home";return n&&(e==null?void 0:e.pages)&&e.pages.find(o=>o.key===n)},[r.page,e==null?void 0:e.pages]);return p.exports.useEffect(()=>{t&&(document.title=t.title||"\u672A\u547D\u540D")},[t]),s(D,{children:t?s(V,{page:t,children:s(ie,{page:t,header:e==null?void 0:e.header,footer:e==null?void 0:e.footer})}):s("div",{className:"container-loading",children:s(j,{})})})}const pe=Object.freeze(Object.defineProperty({__proto__:null,default:se},Symbol.toStringTag,{value:"Module"}));export{Z as g,Y as h,pe as i,q as s};
