import{Z as F,E as _,e as H,o as s,b as a,a as l,r as d,g as D,A as V,i as u,F as g,h as f,n as b,u as M,f as p,t as x,m as K,j as h,d as T,_ as z}from"./vendor-1-1-45.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(o,{emit:B}){const m=B,i=o,w=e=>e===i.headers.length-1,N=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=F(),y=T([]),v=T(!1),S=h(()=>!!k.footer),j=h(()=>!!k.noData);return _(v,e=>{e?y.value=i.items.map(n=>n[i.selectableKey]):y.value=[]}),_(y,e=>{m("selected",e)}),(e,n)=>{const A=H("magnifying-glass-icon");return o.items.length===0&&j.value?(s(),a("div",E,[l("div",I,[d(e.$slots,"noData")])])):(s(),a("div",{key:1,class:b(`border rounded-lg overflow-x-auto overflow-y-hidden sm:overflow-x-hidden ${o.items.length===0?"p-1":"p-0"} dark:border-neutral-700`)},[d(e.$slots,"top"),l("table",U,[o.showHeader&&o.items.length>0?(s(),a("thead",q,[o.selectable?(s(),a("th",O,[D(l("input",{"onUpdate:modelValue":n[0]||(n[0]=t=>v.value=t),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]])])):u("",!0),(s(!0),a(g,null,f(o.headers,(t,c)=>(s(),a("th",{key:c,scope:"col",class:b(`px-4 py-3 w-auto ${w(c)?"text-right":""} ${t.class?t.class:""} `)},[M(k)[`${t.key}-header`]?d(e.$slots,`${t.key}-header`,{key:0,header:t}):(s(),a(g,{key:1},[p(x(t.title)+" ",1),t.img?(s(),a("img",{key:0,src:t.img,alt:t.title,class:"size-8 rounded inline-block"},null,8,Z)):u("",!0)],64))],2))),128))])):u("",!0),o.items.length===0?(s(),a("tbody",G,[l("tr",null,[l("td",{colspan:$.value},[l("div",P,[K(A,{class:"w-8 h-8"}),p(" "+x(o.noDataText),1)])],8,J)])])):u("",!0),l("tbody",null,[(s(!0),a(g,null,f(o.items,(t,c)=>(s(),a("tr",{key:c,class:b(`${C.value?"cursor-pointer":""} bg-white dark:bg-gray-800 ${N(c)?"":"border-b"} text-sm dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600`),onMouseover:r=>m("tr-mouseover",c),onMouseleave:r=>m("tr-mouseleave",c)},[o.selectable?(s(),a("td",R,[D(l("input",{"onUpdate:modelValue":n[1]||(n[1]=r=>y.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:t[o.selectableKey]},null,8,W),[[V,y.value]])])):u("",!0),(s(!0),a(g,null,f(o.headers,(r,L)=>(s(),a("td",{key:r.key,class:b(`px-4 py-3 w-auto ${w(L)?"text-right":""} ${r.class?r.class:""} `),scope:"col",onClick:te=>C.value?m("tr-clicked",t,r):!1},[M(k)[r.key]?d(e.$slots,r.key,{key:0,item:t,index:c}):(s(),a(g,{key:1},[p(x(t[r.key]),1)],64))],10,X))),128))],42,Q))),128))]),S.value?(s(),a("tfoot",Y,[l("tr",null,[l("td",{class:"px-4 py-4",colspan:$.value},[d(e.$slots,"footer")],8,ee)])])):u("",!0)]),d(e.$slots,"bottom")],2))}}};export{ae as _};
