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