import{d as C,aJ as B,r as u,G as F,Y as E,o as i,c as V,b as m,n as _,w as o,a as d,e as f,F as M,l as N,j as U,t as j,A,a3 as K,m as T,M as W,p as Z,g as $,_ as D}from"./index-207e8178.js";import{b as G,a as J,j as P,k as R}from"./VTextField-b712f4db.js";import{V as Y}from"./VMenu-a5999549.js";const y=t=>(Z("data-v-a08bc361"),t=t(),$(),t),q={class:"searchfield-container"},z=y(()=>m("div",{id:"autocomplete"},null,-1)),H={class:"d-flex"},O=y(()=>m("span",{class:"btn-text"},"Zoek",-1)),Q=C({__name:"Searchbar",props:{placeholder:String,modelValue:String,autocompleteList:{type:Array,default:()=>[]},disabledWhenEmpty:{type:Boolean,default:!1}},emits:["update:modelValue","search","clear"],setup(t,{expose:k,emit:s}){const a=t,x=B(a),r=u(null),p=u(!1),l=u(!1),I=u(null),h=F(()=>(!a.modelValue||a.modelValue.trim().length===0)&&a.disabledWhenEmpty);E([x.autocompleteList,p],()=>{p.value&&a.autocompleteList.length>0&&(l.value=!0)});const g=e=>{s("update:modelValue",e)},v=()=>{var e;a.disabledWhenEmpty&&h.value||(l.value=!1,(e=r.value)==null||e.blur(),s("search"))},S=()=>{l.value=!1,s("clear")},w=e=>{const n=(a.modelValue??"").split(" ").slice(0,-1);n.push(e),s("update:modelValue",n.join(" ")),s("search"),l.value=!1},L=e=>{p.value=e};return k({focusInput:()=>{var e;(e=r.value)==null||e.focus()},scrollIntoView:()=>{var e;(e=r.value)==null||e.scrollIntoView({behavior:"smooth"})}}),(e,n)=>(i(),V("div",q,[z,m("div",H,[t.autocompleteList.length>0?(i(),_(Y,{key:0,modelValue:l.value,"onUpdate:modelValue":n[0]||(n[0]=c=>l.value=c),activator:"#searchbar-text-field","close-on-content-click":"","open-on-click":!1,"open-on-focus":!l.value,"scroll-strategy":"none",attach:!0},{default:o(()=>[d(f(G),{ref_key:"vlist",ref:I},{default:o(()=>[(i(!0),V(M,null,N(a.autocompleteList,(c,b)=>(i(),_(f(J),{key:b,value:c,onClick:ae=>w(c),"data-item":`autocomplete-item-${b}`,tabindex:"2"},{default:o(()=>[d(P,null,{default:o(()=>[U(j(c),1)]),_:2},1024)]),_:2},1032,["value","onClick","data-item"]))),128))]),_:1},512)]),_:1},8,["modelValue","open-on-focus"])):A("",!0),d(f(R),{class:"searchbar-text-field",id:"searchbar-text-field",value:a.modelValue,ref_key:"refInput",ref:r,"onUpdate:modelValue":g,"onUpdate:focused":L,"onClick:clear":S,onKeyup:K(v,["enter"]),density:"comfortable",placeholder:t.placeholder,"aria-label":t.placeholder,clearable:"","persistent-clear":"",dirty:(a.modelValue??"").length>0,variant:"solo",autocomplete:t.autocompleteList.length>0?"off":"on","hide-details":"",tabindex:l.value?1:void 0},null,8,["value","onKeyup","placeholder","aria-label","dirty","autocomplete","tabindex"]),d(W,{variant:"flat",id:"search-button",disabled:h.value,onClick:v,"aria-label":"Zoek","append-icon":"mdi-magnify"},{append:o(()=>[d(T,{color:"white"})]),default:o(()=>[O]),_:1},8,["disabled"])])]))}});const se=D(Q,[["__scopeId","data-v-a08bc361"]]);export{se as S};