import{bV as oe,bW as de,bX as ue,a as s,o as n,r as q,p as y,b as h,K as B,t as k,n as m,x as ce,g as T,c as K,W as pe,ap as fe,m as ye,d as w,as as ve,q as b,am as ge,an as be,u as p,bY as R,e as c,a1 as F,F as P,a5 as U,aM as E,bZ as C,aq as me,b_ as he,aV as H,b$ as ke,by as we}from"./main-CJbVOHh0.js";import{_ as xe}from"./_plugin-vue_export-helper-DlAUqK2U.js";var ze=`
    .p-avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: dt('avatar.width');
        height: dt('avatar.height');
        font-size: dt('avatar.font.size');
        background: dt('avatar.background');
        color: dt('avatar.color');
        border-radius: dt('avatar.border.radius');
    }

    .p-avatar-image {
        background: transparent;
    }

    .p-avatar-circle {
        border-radius: 50%;
    }

    .p-avatar-circle img {
        border-radius: 50%;
    }

    .p-avatar-icon {
        font-size: dt('avatar.icon.size');
        width: dt('avatar.icon.size');
        height: dt('avatar.icon.size');
    }

    .p-avatar img {
        width: 100%;
        height: 100%;
    }

    .p-avatar-lg {
        width: dt('avatar.lg.width');
        height: dt('avatar.lg.width');
        font-size: dt('avatar.lg.font.size');
    }

    .p-avatar-lg .p-avatar-icon {
        font-size: dt('avatar.lg.icon.size');
        width: dt('avatar.lg.icon.size');
        height: dt('avatar.lg.icon.size');
    }

    .p-avatar-xl {
        width: dt('avatar.xl.width');
        height: dt('avatar.xl.width');
        font-size: dt('avatar.xl.font.size');
    }

    .p-avatar-xl .p-avatar-icon {
        font-size: dt('avatar.xl.icon.size');
        width: dt('avatar.xl.icon.size');
        height: dt('avatar.xl.icon.size');
    }

    .p-avatar-group {
        display: flex;
        align-items: center;
    }

    .p-avatar-group .p-avatar + .p-avatar {
        margin-inline-start: dt('avatar.group.offset');
    }

    .p-avatar-group .p-avatar {
        border: 2px solid dt('avatar.group.border.color');
    }

    .p-avatar-group .p-avatar-lg + .p-avatar-lg {
        margin-inline-start: dt('avatar.lg.group.offset');
    }

    .p-avatar-group .p-avatar-xl + .p-avatar-xl {
        margin-inline-start: dt('avatar.xl.group.offset');
    }
`,Se={root:function(r){var f=r.props;return["p-avatar p-component",{"p-avatar-image":f.image!=null,"p-avatar-circle":f.shape==="circle","p-avatar-lg":f.size==="large","p-avatar-xl":f.size==="xlarge"}]},label:"p-avatar-label",icon:"p-avatar-icon"},Re=oe.extend({name:"avatar",style:ze,classes:Se}),Pe={name:"BaseAvatar",extends:de,props:{label:{type:String,default:null},icon:{type:String,default:null},image:{type:String,default:null},size:{type:String,default:"normal"},shape:{type:String,default:"square"},ariaLabelledby:{type:String,default:null},ariaLabel:{type:String,default:null}},style:Re,provide:function(){return{$pcAvatar:this,$parentInstance:this}}};function A(t){"@babel/helpers - typeof";return A=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},A(t)}function I(t,r,f){return(r=Ce(r))in t?Object.defineProperty(t,r,{value:f,enumerable:!0,configurable:!0,writable:!0}):t[r]=f,t}function Ce(t){var r=Le(t,"string");return A(r)=="symbol"?r:r+""}function Le(t,r){if(A(t)!="object"||!t)return t;var f=t[Symbol.toPrimitive];if(f!==void 0){var v=f.call(t,r);if(A(v)!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var W={name:"Avatar",extends:Pe,inheritAttrs:!1,emits:["error"],methods:{onError:function(r){this.$emit("error",r)}},computed:{dataP:function(){return ue(I(I({},this.shape,this.shape),this.size,this.size))}}},Ae=["aria-labelledby","aria-label","data-p"],$e=["data-p"],Ve=["data-p"],Be=["src","alt","data-p"];function Ee(t,r,f,v,N,g){return n(),s("div",B({class:t.cx("root"),"aria-labelledby":t.ariaLabelledby,"aria-label":t.ariaLabel},t.ptmi("root"),{"data-p":g.dataP}),[q(t.$slots,"default",{},function(){return[t.label?(n(),s("span",B({key:0,class:t.cx("label")},t.ptm("label"),{"data-p":g.dataP}),k(t.label),17,$e)):t.$slots.icon?(n(),y(ce(t.$slots.icon),{key:1,class:m(t.cx("icon"))},null,8,["class"])):t.icon?(n(),s("span",B({key:2,class:[t.cx("icon"),t.icon]},t.ptm("icon"),{"data-p":g.dataP}),null,16,Ve)):t.image?(n(),s("img",B({key:3,src:t.image,alt:t.ariaLabel,onError:r[0]||(r[0]=function(){return g.onError&&g.onError.apply(g,arguments)})},t.ptm("image"),{"data-p":g.dataP}),null,16,Be)):h("",!0)]})],16,Ae)}W.render=Ee;const Me={class:"reusable-data-table-container"},Te=["onClick"],Fe={key:0,class:"flex items-center gap-3"},Ue={class:"flex flex-col gap-2"},Ne={key:0,class:"user-cell"},Oe={class:"user-info"},je={class:"user-name"},Ke={class:"user-sub"},He={key:1,class:"badge-cell"},Ie={key:2,class:"toggle-cell"},qe={key:3,class:"checkbox-cell"},We=["innerHTML"],Ye={key:5,class:"date-cell"},Xe={key:6,class:"default-cell"},Ze={key:0,class:"flex justify-center items-center gap-2 w-full"},Ge={key:1,class:"flex justify-center items-center gap-1 w-full"},Je={key:0,class:"ml-1"},Qe={class:"menu-list"},De={class:"menu-text"},_e=["onClick","disabled"],et={class:"menu-text"},tt={__name:"ReusableDataTable",props:{data:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},totalRecords:{type:Number,default:0},rows:{type:Number,default:10},rowsPerPageOptions:{type:Array,default:()=>[10,25,50]},sortField:{type:String,default:""},sortOrder:{type:Number,default:0},columns:{type:Array,required:!0},actions:{type:Array,default:()=>[]},paginator:{type:Boolean,default:!0},selectionMode:{type:String,default:null},selection:{type:Array,default:()=>[]},lazy:{type:Boolean,default:!0},dataKey:{type:String,default:"id"},reorderable:{type:Boolean,default:!1},frozenActions:{type:Boolean,default:!0},showIconsLimit:{type:Number,default:1},actionsColumnStyle:{type:Object,default:()=>({width:"120px",minWidth:"120px"})},expandable:{type:Boolean,default:!1},isRowExpandable:{type:Function,default:null},leadingSpacer:{type:Boolean,default:!1}},emits:["page","sort","update:selection","action-click","row-select","row-unselect","reorder","toggle-enabled","row-update","row-expand"],setup(t,{emit:r}){const f=t,v=r,N=T(),g=T({}),Y=a=>!!g.value[a[f.dataKey]],X=a=>{const l=a[f.dataKey],u={...g.value};u[l]?delete u[l]:(u[l]=!0,v("row-expand",a)),g.value=u},Z=K(()=>Array.from({length:5},(a,l)=>({id:l}))),d=T({visible:!1,x:0,y:0,rowData:null,index:null,actions:[]}),G=(a,l,u)=>{if(d.value.visible&&d.value.index===u){x();return}const e=M(l),i=a.currentTarget.getBoundingClientRect();d.value={visible:!0,x:i.left-130,y:i.bottom+window.scrollY+4,rowData:l,index:u,actions:e}},J=a=>{v("action-click",{action:a,rowData:d.value.rowData,index:d.value.index}),x()},x=()=>{d.value.visible=!1};pe(()=>{document.addEventListener("click",x),window.addEventListener("scroll",x,!0)}),fe(()=>{document.removeEventListener("click",x),window.removeEventListener("scroll",x,!0)});const M=a=>f.actions.filter(l=>typeof l.condition=="function"?l.condition(a):typeof l.show=="function"?l.show(a):!0),L=(a,l)=>typeof a.disabled=="function"?a.disabled(l):a.disabled||!1,z=(a,l)=>typeof a.label=="function"?a.label(l):a.label||"",O=(a,l)=>{const u=a.label||a.tooltip;return typeof u=="function"?u(l):u||a.action||""},$=(a,l)=>typeof a.icon=="function"?a.icon(l):a.icon||"",V=(a,l)=>typeof a.to=="function"?a.to(l):a.to||null,j=K({get:()=>f.selection,set:a=>v("update:selection",a)}),Q=a=>v("page",a),D=a=>v("sort",a),_=a=>v("reorder",{data:a.value}),ee=a=>v("row-select",a.data),te=a=>v("row-unselect",a.data),ae=a=>a?a.split(" ").map(l=>l[0]).slice(0,2).join("").toUpperCase():"",le=a=>{const l=["#6366f1","#8b5cf6","#10b981","#f59e0b","#ec4899","#3b82f6"];let u=0;if(a)for(let e=0;e<a.length;e++)u=a.charCodeAt(e)+((u<<5)-u);return l[Math.abs(u)%l.length]},ne=a=>a?"badge-active":"badge-gray",re=a=>a?a.replace(/_/g," "):"-",se=a=>a?new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"-",ie=a=>a||"-";return(a,l)=>{const u=ye("RouterLink");return n(),s("div",Me,[w(p(ke),{ref_key:"dt",ref:N,value:t.loading?Z.value:t.data,class:"premium-datatable",stripedRows:"",lazy:t.lazy,loading:!1,paginator:t.paginator,rows:t.rows,totalRecords:t.totalRecords,rowsPerPageOptions:t.rowsPerPageOptions,sortField:t.sortField,sortOrder:t.sortOrder,dataKey:t.dataKey,selection:j.value,"onUpdate:selection":l[0]||(l[0]=e=>j.value=e),expandedRows:g.value,"onUpdate:expandedRows":l[1]||(l[1]=e=>g.value=e),reorderableRows:t.reorderable,paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown",currentPageReportTemplate:"{first}-{last} of {totalRecords}",onPage:Q,onSort:D,onRowSelect:ee,onRowUnselect:te,onRowReorder:_},ve({empty:b(()=>[l[6]||(l[6]=c("div",{class:"empty-state"},[c("div",{class:"empty-icon-bg"},[c("i",{class:"pi pi-search",style:{"font-size":"1.25rem",color:"#64748b"}})]),c("h3",{class:"empty-title"},"No results found"),c("p",{class:"empty-desc"},"Try adjusting your search terms.")],-1))]),default:b(()=>[t.reorderable?(n(),y(p(R),{key:0,rowReorder:"",headerStyle:"width: 3rem",reorderableColumn:!1})):h("",!0),t.selectionMode==="checkbox"?(n(),y(p(R),{key:1,selectionMode:"multiple",headerStyle:"width: 3rem"})):h("",!0),t.leadingSpacer?(n(),y(p(R),{key:2,headerStyle:"width: 3rem",style:{width:"3rem"}},{body:b(()=>l[3]||(l[3]=[c("span",{style:{display:"inline-block",width:"28px",height:"1px"}},null,-1)])),_:1})):h("",!0),t.expandable?(n(),y(p(R),{key:3,headerStyle:"width: 3rem",style:{width:"3rem"}},{body:b(({data:e})=>[!t.loading&&(!t.isRowExpandable||t.isRowExpandable(e))?(n(),s("button",{key:0,type:"button",class:m(["rdt-expander",{"is-open":Y(e)}]),onClick:F(i=>X(e),["stop"])},l[4]||(l[4]=[c("i",{class:"pi pi-chevron-down"},null,-1)]),10,Te)):h("",!0)]),_:1})):h("",!0),(n(!0),s(P,null,U(t.columns,e=>(n(),y(p(R),{key:e.field,field:e.field,header:e.header,sortable:e.sortable&&!t.loading,style:E(e.style),class:m(e.class),alignHeader:e.alignHeader||"left",align:e.align||"left"},{body:b(({data:i})=>{var o;return[t.loading?(n(),s("div",Fe,[e.template==="user"?(n(),s(P,{key:0},[w(p(C),{shape:"circle",size:"2.5rem",class:"shrink-0"}),c("div",Ue,[w(p(C),{width:"8rem",height:"1rem"}),w(p(C),{width:"5rem",height:"0.75rem"})])],64)):e.template==="badge"?(n(),y(p(C),{key:1,width:"5rem",height:"1.5rem",borderRadius:"16px"})):(n(),y(p(C),{key:2,width:"80%",height:"1rem"}))])):(n(),s(P,{key:1},[e.template==="user"?(n(),s("div",Ne,[w(p(W),{label:ae(i[e.field]),class:"user-avatar",shape:"circle",style:E({backgroundColor:le(i[e.field]),color:"#fff"})},null,8,["label","style"]),c("div",Oe,[c("span",je,k(i[e.field]),1),c("span",Ke,k(i[e.subField]),1)])])):e.template==="badge"?(n(),s("div",He,[c("span",{class:m(["status-pill",ne(i[e.field])])},k(re(i[e.field])),3)])):e.template==="toggle"?(n(),s("div",Ie,[w(p(me),{modelValue:i[e.field]===(e.trueValue!==void 0?e.trueValue:!0),"true-value":!0,"false-value":!1,"onUpdate:modelValue":S=>{i[e.field]=S?e.trueValue!==void 0?e.trueValue:!0:e.falseValue!==void 0?e.falseValue:!1,a.$emit("toggle-enabled",i)}},null,8,["modelValue","onUpdate:modelValue"])])):e.template==="checkbox"?(n(),s("div",qe,[w(p(he),{modelValue:i[e.field],"onUpdate:modelValue":[S=>i[e.field]=S,S=>a.$emit("row-update",i)],binary:!0},null,8,["modelValue","onUpdate:modelValue"])])):e.template==="custom"?(n(),s("div",{key:4,innerHTML:(o=e.customHTML)==null?void 0:o.call(e,i),class:"custom-cell"},null,8,We)):e.type==="datetime"?(n(),s("div",Ye,k(se(i[e.field])),1)):(n(),s("span",Xe,k(ie(i[e.field])),1))],64))]}),_:2},1032,["field","header","sortable","style","class","alignHeader","align"]))),128)),t.actions&&t.actions.length>0?(n(),y(p(R),{key:4,exportable:!1,alignFrozen:t.frozenActions?"right":null,frozen:t.frozenActions,style:E(t.actionsColumnStyle),headerClass:"perfect-center-header",bodyClass:"perfect-center-body"},{header:b(()=>l[5]||(l[5]=[c("span",{class:"w-full text-center"},"Actions",-1)])),body:b(({data:e,index:i})=>[t.loading?(n(),s("div",Ze,[w(p(C),{shape:"circle",size:"2rem"})])):(n(),s("div",Ge,[M(e).length<=t.showIconsLimit?(n(!0),s(P,{key:0},U(M(e),(o,S)=>(n(),s(P,{key:S},[V(o,e)&&!L(o,e)?(n(),y(u,{key:0,to:V(o,e),title:o.tooltip,class:m(["p-button p-button-text p-button-icon-only action-link",z(o,e)?"action-btn-pill":"action-btn-circle"])},{default:b(()=>[c("i",{class:m($(o,e))},null,2),z(o,e)?(n(),s("span",Je,k(z(o,e)),1)):h("",!0)]),_:2},1032,["to","title","class"])):(n(),y(p(H),{key:1,icon:$(o,e),label:z(o,e),rounded:!z(o,e),text:"",severity:o.severity,class:m([z(o,e)?"action-btn-pill":"action-btn-circle"]),title:o.tooltip,disabled:L(o,e),onClick:at=>v("action-click",{action:o,rowData:e,index:i})},null,8,["icon","label","rounded","severity","class","title","disabled","onClick"]))],64))),128)):(n(),y(p(H),{key:1,icon:"pi pi-ellipsis-v",rounded:"",text:"",severity:"secondary",class:"action-btn-circle",onClick:F(o=>G(o,e,i),["stop"])},null,8,["onClick"]))]))]),_:1},8,["alignFrozen","frozen","style"])):h("",!0)]),_:2},[t.expandable?{name:"expansion",fn:b(e=>[q(a.$slots,"expansion",ge(be(e)),void 0,!0)]),key:"0"}:void 0]),1032,["value","lazy","paginator","rows","totalRecords","rowsPerPageOptions","sortField","sortOrder","dataKey","selection","expandedRows","reorderableRows"]),(n(),y(we,{to:"body"},[d.value.visible?(n(),s("div",{key:0,class:"custom-teleport-menu",style:E({top:d.value.y+"px",left:d.value.x+"px"}),onClick:l[2]||(l[2]=F(()=>{},["stop"]))},[c("ul",Qe,[(n(!0),s(P,null,U(d.value.actions,(e,i)=>(n(),s("li",{key:i,class:m(["menu-item",{"menu-item-disabled":L(e,d.value.rowData)}])},[V(e,d.value.rowData)&&!L(e,d.value.rowData)?(n(),y(u,{key:0,to:V(e,d.value.rowData),class:"menu-button",onClick:x},{default:b(()=>[c("i",{class:m([$(e,d.value.rowData),"menu-icon"])},null,2),c("span",De,k(O(e,d.value.rowData)),1)]),_:2},1032,["to"])):(n(),s("button",{key:1,onClick:o=>J(e),class:"menu-button",disabled:L(e,d.value.rowData)},[c("i",{class:m([$(e,d.value.rowData),"menu-icon"])},null,2),c("span",et,k(O(e,d.value.rowData)),1)],8,_e))],2))),128))])],4)):h("",!0)]))])}}},rt=xe(tt,[["__scopeId","data-v-dd1e6177"]]);export{rt as R};
