var x=(v,c,u)=>new Promise((p,t)=>{var m=a=>{try{o(u.next(a))}catch(i){t(i)}},f=a=>{try{o(u.throw(a))}catch(i){t(i)}},o=a=>a.done?p(a.value):Promise.resolve(a.value).then(m,f);o((u=u.apply(v,c)).next())});import{u as R}from"./warehouses-BnkLPhlE.js";import{bV as C,c9 as y,c8 as D}from"./bootstrap-Bqxdt4iG.js";import{T as k}from"./index-axp3BSAN.js";import{a1 as U,E as d,L as W,aa as z,ap as g,aj as n,az as l,an as b,ay as _,ai as w,ak as I,ax as N,a9 as S,F as E,aq as G}from"../jse/index-index-BUJ_4tQs.js";const L="/logo/logo-icon.png",M={class:"rounded-lg border border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-900"},T={class:"flex items-center gap-4"},V={class:"flex-1"},j={class:"text-sm text-gray-500 dark:text-gray-400"},F={class:"flex items-center gap-2"},O={class:"text-xl font-semibold"},q={key:0,class:"mt-2 flex flex-wrap items-center gap-1 text-sm"},H={key:0,class:"font-medium text-gray-700 dark:text-gray-200"},P={key:1,class:"italic text-gray-400"},Z=U({__name:"user-welcome",setup(v){const c=C(),u=R(),p=d(()=>{var e,s;return((e=c.userInfo)==null?void 0:e.realName)||((s=c.userInfo)==null?void 0:s.username)||"User"}),t=d(()=>{var e,s,r;return(r=(s=(e=c.userInfo)==null?void 0:e.roles)==null?void 0:s[0])!=null?r:""}),m=d(()=>t.value===y.SUPER_ADMIN||t.value===y.ADMIN),f=d(()=>!!t.value),o=W([]);z(()=>x(null,null,function*(){var s,r;if(!f.value||m.value)return;const e=(r=(s=c.userInfo)==null?void 0:s.warehouseIds)!=null?r:[];if(e.length===0){o.value=[];return}try{const h=yield u.fetchOptions(),A=new Set(e);o.value=h.filter(B=>A.has(B.value))}catch(h){o.value=[]}}));const a=e=>D.find(s=>s.value===e)||{label:e.replaceAll("_"," "),color:"default"},i=d(()=>{const e=new Date().getHours();return e<12?"Good morning":e<18?"Good afternoon":"Good evening"});return(e,s)=>(n(),g("div",M,[l("div",T,[s[1]||(s[1]=l("img",{src:L,alt:"Logo",class:"size-14 shrink-0 rounded-lg object-contain"},null,-1)),l("div",V,[l("div",j,_(i.value)+", ",1),l("div",F,[l("span",O,_(p.value),1),t.value?(n(),w(S(k),{key:0,color:a(t.value).color,class:"capitalize"},{default:I(()=>[N(_(a(t.value).label),1)]),_:1},8,["color"])):b("",!0)]),f.value?(n(),g("div",q,[s[0]||(s[0]=l("span",{class:"text-gray-500 dark:text-gray-400"}," Warehouse access: ",-1)),m.value?(n(),g("span",H," All warehouses ")):o.value.length===0?(n(),g("span",P," None assigned ")):(n(!0),g(E,{key:2},G(o.value,r=>(n(),w(S(k),{key:r.value,class:"m-0"},{default:I(()=>[N(_(r.label),1)]),_:2},1024))),128))])):b("",!0)])])]))}});export{Z as _};
