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