import{d as te,f as _,a as p,c as ae,s as d}from"../chunks/DktbhmWA.js";import{p as re,d as D,e as ie,u as oe,a as ne,c as s,s as o,b as F,r as t,g as n,h as j,t as G,f as ce,i as le}from"../chunks/CPWcrcMP.js";import{i as P}from"../chunks/0jvM7PZf.js";import{S as de,A as z,s as H,e as ve,i as me}from"../chunks/BxBMkMrU.js";import"../chunks/DUxDMF0-.js";import{G as pe}from"../chunks/CtdL8EMg.js";import{g as L}from"../chunks/Dulyqw6d.js";import{U as fe}from"../chunks/CP_-kVfK.js";var ue=_('<a class="btn btn-primary btn-sm">+ Add User</a>'),_e=(l,v)=>L("/users/"+v()),be=(l,v)=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),L("/users/"+v()))},xe=_('<div role="link" tabindex="0" class="mt-4 grid gap-8 lg:gap-12 border-2 border-primary p-2 rounded-xl cursor-pointer"><div class="flex justify-between items-center w-full"><h3 class="text-3xl font-semibold"> </h3> <div class="flex items-center gap-2"><span class="badge badge-success h-8"> </span> <a class="btn btn-primary btn-sm"> </a></div></div> <div><p class="mt-2 text-base font-medium"> </p> <p class="mt-2 text-base font-medium"> </p> <p class="mt-2 text-base font-medium"> </p></div></div>'),he=_('<h1 class="text-4xl text-error font-semibold">No access</h1>'),ge=_('<section><div class="container mx-auto"><div class="flex items-center gap-2 sticky bg-base-100 z-40" style="top:4.11rem"><!></div> <div class="flex justify-between text-left mb-2"><h2 class="text-4xl font-semibold">Users</h2> <!></div> <!></div></section>');function Ne(l,v){re(v,!0);const M=new de(["Users/#"]);let E=D(ie({})),N=D(0);const A=j(()=>!z.canEditUsers),q=j(()=>z.canViewUsers);oe(()=>{const a=M.getData(),e={};for(const[g,u]of Object.entries(a)){const m=g.split("/");if(m.length<3)continue;const[,i,r]=m;if(!(!i||!r)){e[i]||(e[i]={}),e[i].Id=parseInt(i);try{e[i][r]=u}catch(c){console.warn(`Failed to parse field "${r}" with value "${u}"`,c)}}}const f=Object.keys(e).map(Number);F(N,f.length>0?Math.max(...f)+1:1,!0),F(E,e,!0)});var b=ge(),O=s(b),x=s(O),B=s(x);pe(B,{}),t(x);var h=o(x,2),C=o(s(h),2);{var J=a=>{var e=ue();G(()=>H(e,"href","/users/new_"+n(N))),p(a,e)};P(C,a=>{n(A)||a(J)})}t(h);var K=o(h,2);{var Q=a=>{var e=ae(),f=ce(e);ve(f,17,()=>Object.entries(n(E)),me,(g,u)=>{var m=j(()=>le(n(u),2));let i=()=>n(m)[0],r=()=>n(m)[1];var c=xe();c.__click=[_e,i],c.__keydown=[be,i];var y=s(c),w=s(y),W=s(w,!0);t(w);var R=o(w,2),k=s(R),X=s(k,!0);t(k);var U=o(k,2),Y=s(U,!0);t(U),t(R),t(y);var S=o(y,2),I=s(S),Z=s(I);t(I);var $=o(I,2),ee=s($);t($);var V=o($,2),se=s(V);t(V),t(S),t(c),G(()=>{d(W,r().Username),d(X,r().Roles?fe[r().Roles]:""),H(U,"href","/users/"+i()),d(Y,n(A)?"View":"Edit"),d(Z,`Name: ${r().FirstName??""} ${r().LastName??""}`),d(ee,`Email: ${r().Email??""}`),d(se,`Phone: ${r().Phone??""}`)}),p(g,c)}),p(a,e)},T=a=>{var e=he();p(a,e)};P(K,a=>{n(q)?a(Q):a(T,!1)})}t(O),t(b),p(l,b),ne()}te(["click","keydown"]);export{Ne as component};
