import{Z as L,E as _,e as F,o as t,b as s,a as l,r as g,g as D,A as V,i as d,F as m,h as f,n as b,f as p,t as x,m as H,u as K,j as h,d as M,_ as z}from"./vendor-1-1-44.js";const E={key:0},I={class:"flex flex-col justify-center items-center text-center mx-auto max-w-[900px] bg-white rounded-md space-y-8 mt-8 lg:px-48 px-4 lg:py-10 py-5"},U={class:"w-full bg-white divide-y divide-gray-200 dark:divide-neutral-700"},q={key:0,class:"text-xs text-gray-700 text-left bg-gray-50 dark:bg-gray-700 dark:text-gray-400"},O={key:0,class:"px-4 py-3",scope:"col"},Z=["src","alt"],G={key:1},J=["colspan"],P={class:"flex flex-col rounded items-center justify-center p-4"},Q=["onMouseover","onMouseleave"],R={key:0,class:"px-4 py-3",scope:"col"},W=["value"],X=["onClick"],Y={key:2,class:"text-xs text-gray-700 bg-white dark:bg-gray-700 dark:text-gray-400"},ee=["colspan"],ae={__name:"MdrTable",props:{headers:{type:Array,required:!0},items:{type:[Array,Object],default:()=>[]},selectable:{type:Boolean,default:!1},selectableKey:{type:String,default:"id"},noDataText:{type:String,default:"Veri bulunamadı."},showHeader:{type:Boolean,default:!0}},emits:["selected","tr-clicked","tr-mouseover","tr-mouseleave"],setup(a,{emit:T}){const y=T,i=a,w=e=>e===i.headers.length-1,B=e=>e===i.items.length-1,$=h(()=>i.selectable?i.headers.length+1:i.headers.length),C=h(()=>{var e,n;return!!((n=(e=z())==null?void 0:e.vnode.props)!=null&&n.onTrClicked)}),k=L(),u=M([]),v=M(!1),N=h(()=>!!k.footer),S=h(()=>!!k.noData);return _(v,e=>{e?u.value=i.items.map(n=>n[i.selectableKey]):u.value=[]}),_(u,e=>{y("selected",e)}),(e,n)=>{const j=F("magnifying-glass-icon");return a.items.length===0&&S.value?(t(),s("div",E,[l("div",I,[g(e.$slots,"noData")])])):(t(),s("div",{key:1,class:b(`border rounded-lg overflow-x-auto overflow-y-hidden sm:overflow-x-hidden ${a.items.length===0?"p-1":"p-0"} dark:border-neutral-700`)},[g(e.$slots,"top"),l("table",U,[a.showHeader&&a.items.length>0?(t(),s("thead",q,[a.selectable?(t(),s("th",O,[D(l("input",{"onUpdate:modelValue":n[0]||(n[0]=o=>v.value=o),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"},null,512),[[V,v.value]])])):d("",!0),(t(!0),s(m,null,f(a.headers,(o,c)=>(t(),s("th",{key:c,scope:"col",class:b(`px-4 py-3 w-auto ${w(c)?"text-right":""} ${o.class?o.class:""} `)},[p(x(o.title)+" ",1),o.img?(t(),s("img",{key:0,src:o.img,alt:o.title,class:"size-8 rounded inline-block"},null,8,Z)):d("",!0)],2))),128))])):d("",!0),a.items.length===0?(t(),s("tbody",G,[l("tr",null,[l("td",{colspan:$.value},[l("div",P,[H(j,{class:"w-8 h-8"}),p(" "+x(a.noDataText),1)])],8,J)])])):d("",!0),l("tbody",null,[(t(!0),s(m,null,f(a.items,(o,c)=>(t(),s("tr",{key:c,class:b(`${C.value?"cursor-pointer":""} bg-white dark:bg-gray-800 ${B(c)?"":"border-b"} text-sm dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600`),onMouseover:r=>y("tr-mouseover",c),onMouseleave:r=>y("tr-mouseleave",c)},[a.selectable?(t(),s("td",R,[D(l("input",{"onUpdate:modelValue":n[1]||(n[1]=r=>u.value=r),type:"checkbox",class:"w-4 h-4 text-primary-800 bg-gray-100 border-gray-300 rounded focus:ring-primary-500 dark:focus:ring-primary-800 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600",value:o[a.selectableKey]},null,8,W),[[V,u.value]])])):d("",!0),(t(!0),s(m,null,f(a.headers,(r,A)=>(t(),s("td",{key:r.key,class:b(`px-4 py-3 w-auto ${w(A)?"text-right":""} ${r.class?r.class:""} `),scope:"col",onClick:te=>C.value?y("tr-clicked",o,r):!1},[K(k)[r.key]?g(e.$slots,r.key,{key:0,item:o,index:c}):(t(),s(m,{key:1},[p(x(o[r.key]),1)],64))],10,X))),128))],42,Q))),128))]),N.value?(t(),s("tfoot",Y,[l("tr",null,[l("td",{class:"px-4 py-4",colspan:$.value},[g(e.$slots,"footer")],8,ee)])])):d("",!0)]),g(e.$slots,"bottom")],2))}}};export{ae as _};
