import{r as n,aJ as c}from"./@ui-core-DKdciH1Z.js";import{bT as x,aA as g,I as j,c as b,av as N}from"./index-D7KLAbvI.js";import{c as P,f as v}from"./@react-router-DaIuhn3X.js";const y=["equals:","contains:","startswith:","endswith:","gte:","gt:","lte:","lt:"];function w(t){const a=y.find(s=>t.startsWith(s));return a?t.slice(a.length):t}const E=n.forwardRef(({searchParams:t,searchContains:a=!0,inMemoryHandler:s,className:o,...l},u)=>{const f=P(),[m]=v(),[h,p]=n.useState(w(t.name||"")||""),i=n.useMemo(()=>x(d,500),[]);n.useEffect(()=>()=>{i.cancel()},[i]);function d(r){if(s){s(r);return}const e=new URLSearchParams({...Object.fromEntries(m),...g(t)});e.delete("logical_operator"),r?(e.set("name",a?`contains:${r}`:`${r}`),e.set("operator","or"),e.set("page","1")):(e.delete("name"),e.delete("operator")),f(`?${e.toString()}`,{preventScrollReset:!0,replace:!0})}function S(r){const{value:e}=r.target;p(e),i(e)}return c.jsxs("div",{className:"relative",children:[c.jsx(j,{className:b("pl-[36px]",o),...l,ref:u,value:h,onChange:S,placeholder:"Search...",inputSize:"md"}),c.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-1",children:c.jsx(N,{className:"size-4 fill-neutral-400"})})]})});E.displayName="SearchField";export{E as S};
