import{T as M,A as U,m as V,h as q,o as d,c,b as s,a as h,t as i,w as A,d as u,f as S,u as n,F as k,r as O,v as P,I as j,O as T}from"./app-13978987.js";import{_ as $}from"./SpinnerBtn-899a94c2.js";const B={class:"flex items-stretch justify-end gap-x-2"},D={class:"dropdown","data-placement":"bottom-end"},I={class:"dropdown-toggle"},L={type:"button",class:"btn bg-white font-medium shadow-sm dark:bg-slate-800"},E={class:"dropdown-content w-72 !overflow-visible"},N={class:"dropdown-list space-y-4 p-4"},R={key:0,class:"dropdown-list-item"},z={class:"mb-1 capitalize"},K={value:"",disabled:"",selected:""},Q=["value"],G={key:1,class:"dropdown-list-item"},H={class:"mb-1"},J={class:"dropdown-list-item"},W={class:"mb-1"},X=["value","selected"],Y={class:"dropdown-list-item"},Z=s("i",{class:"bx bx-x"},null,-1),se={__name:"FilterDropdown",props:{action:{type:String,required:!1,default:""},appends:{type:Object,required:!1,default:{}},options:{type:[Array,Object],required:!1,default:[{value:"id",label:"id",selected:!0}]},formOptions:{type:Object,default:{}}},setup(v){var f,y,w,_,g,x;const r=v,m=()=>{const t={},o=new URLSearchParams(window.location.search);for(const[l,e]of o)t.hasOwnProperty(l)?Array.isArray(t[l])?t[l].push(e):t[l]=[t[l],e]:t[l]=e;return t},a=M({search:((f=m())==null?void 0:f.search)??"",type:((y=m())==null?void 0:y.type)??((_=(w=r.options)==null?void 0:w.find(t=>t.selected))==null?void 0:_.value)??((x=(g=r.options)==null?void 0:g[0])==null?void 0:x.value)??""}),C=()=>{let t=r.action,o="?"+new URLSearchParams(r.appends).toString();a.get(t+o,r.formOptions)},F=()=>{T.get(location.pathname,r.formOptions)},p=U(()=>r.options&&a.type?r.options.find(t=>t.value==a.type):!1),b=V(!1);return(t,o)=>{const l=q("Icon");return d(),c("div",B,[s("div",D,[s("div",I,[s("button",L,[h(l,{class:"text-xl text-slate-400",icon:"material-symbols:filter-alt-outline-sharp"}),s("span",null,i(t.trans("Search")),1),h(l,{class:"text-xl text-slate-400",icon:"tdesign:chevron-down"})])]),s("div",E,[s("form",{onSubmit:A(C,["prevent"])},[s("ul",N,[p.value&&p.value.options?(d(),c("li",R,[s("label",z,i(p.value.label),1),u(s("select",{class:"select","onUpdate:modelValue":o[0]||(o[0]=e=>n(a).search=e)},[s("option",K,i(t.trans("Select")),1),(d(!0),c(k,null,O(p.value.options,e=>(d(),c("option",{key:e.value,value:e.value},i(e.label),9,Q))),128))],512),[[S,n(a).search]])])):(d(),c("li",G,[s("label",H,i(t.trans("Search Keyword")),1),u(s("input",{type:"text","onUpdate:modelValue":o[1]||(o[1]=e=>n(a).search=e),class:"input",placeholder:"enter search keyword"},null,512),[[P,n(a).search]])])),s("li",J,[s("label",W,i(t.trans("Search Type")),1),u(s("select",{class:"select",onChange:o[2]||(o[2]=e=>n(a).reset("search")),"onUpdate:modelValue":o[3]||(o[3]=e=>n(a).type=e)},[(d(!0),c(k,null,O(v.options,e=>(d(),c("option",{key:e.value,value:e.value,selected:e.selected},i(e.label),9,X))),128))],544),[[S,n(a).type]])]),s("li",Y,[h($,{disabled:n(a).search.length===0,type:"submit",processing:n(a).processing,"btn-text":t.trans("Search"),class:"btn btn-primary w-full",icon:"bx bx-search"},null,8,["disabled","processing","btn-text"])])])],32)])]),u(s("button",{onClick:F,onMouseover:o[4]||(o[4]=e=>b.value=!0),onMouseout:o[5]||(o[5]=e=>b.value=!1),class:"btn flex items-center border bg-gray-300 dark:border-dark-700 dark:bg-dark-800",title:"clear filter"},[Z,u(s("span",null,i(t.trans("Clear")),513),[[j,b.value]])],544),[[j,m().search]])])}}};export{se as _};
