import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{A as t,Ft as n,G as r,Lt as i,Nt as a,O as o,Ot as s,R as c,_ as l,et as u,j as d,pt as f,ut as p,vt as m,zt as h}from"./vendor-vue-core-IZuWV8u3.js";import{B as g}from"./vendor-vueuse-ChbGLbpR.js";import{t as _}from"./src-ztBDyvoF.js";var v=[`placeholder`,`autofocus`],y=[`aria-label`],b=c({__name:`FormSearchInput`,props:r({searcher:{type:Function,default:async()=>{}},updateKey:{},autofocus:{type:Boolean,default:!1},class:{}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let r=p(e,`modelValue`),c=s(!1),b=g(r,250,{maxWait:1e3});f(r,e=>{c.value=e!==b.value}),f([b,a(()=>n(e.updateKey))],(t,n,r)=>{let i=!1,a;r(()=>{i=!0,a?.()}),e.searcher(b.value,e=>a=e).catch(e=>{console.error(`[SidePanelSearch] searcher failed`,e)}).finally(()=>{i||(c.value=!1)})},{immediate:!0});function handleFocus(e){let t=e.target;t instanceof HTMLInputElement&&t.select()}return(n,a)=>(u(),d(`label`,{class:h(i(_)(`group`,`bg-component-node-widget-background rounded-lg transition-all duration-150`,`flex-1 flex items-center`,`text-base-foreground border-0`,`focus-within:ring focus-within:ring-component-node-widget-background-highlighted/80`,e.class))},[o(`i`,{class:h(i(_)(`size-4 ml-2 shrink-0 transition-colors duration-150`,c.value?`icon-[lucide--loader-circle] animate-spin`:`icon-[lucide--search]`,r.value?.trim()===``?`text-muted-foreground group-hover:text-base-foreground group-focus-within:text-base-foreground`:`text-base-foreground`))},null,2),m(o(`input`,{"onUpdate:modelValue":a[0]||=e=>r.value=e,type:`text`,class:`bg-transparent border-0 outline-0 ring-0 h-5 w-full my-1.5 mx-2 min-w-0`,placeholder:n.$t(`g.searchPlaceholder`,{subject:``}),autofocus:n.autofocus,onFocus:handleFocus},null,40,v),[[l,r.value]]),r.value.trim().length>0?(u(),d(`button`,{key:0,class:`text-muted-foreground hover:text-base-foreground bg-transparent shrink-0 border-0 outline-0 ring-0 p-0 m-0 pr-3 pl-1 flex items-center justify-center transition-all duration-150 hover:scale-108`,"aria-label":n.$t(`g.clear`),onClick:a[1]||=e=>r.value=``},[o(`i`,{class:h(i(_)(`icon-[lucide--delete] size-4 cursor-pointer`))},null,2)],8,y)):t(``,!0)],2))}});export{b as t};
//# sourceMappingURL=FormSearchInput-DUKqVfB9.js.map