1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t}from"./jsx-runtime-D3F0h15I.js";import{eo as n}from"./render-BygeE92-.js";import{r}from"./defineProperty-DHAZOe13.js";import{o as i}from"./typed_functions-CSTmTKlX.js";import{C as a}from"./accounts_typed-BHmKS1z2.js";import{n as o}from"./index.module-DGdcFisy.js";import{n as s}from"./useAccountId-DmbiXN71.js";var c=e(t());function l({onSettled:e,filterResults:t,resetOnInputClear:l=!0,withRelationships:u=!1,withDefaultFollows:d=!1}={}){let f=i(),[p,m]=(0,c.useState)([]),[h,g]=(0,c.useState)(`idle`),_=(0,c.useRef)(null),v=o(async t=>{if(_.current&&_.current.abort(),t.trim().length===0){e?.(``),l&&m([]);return}g(`loading`),_.current=new AbortController;try{let i=await r(`GET`,`v1/accounts/search`,{signal:_.current.signal,params:{q:t,resolve:!0}}),o=i.map(e=>e.id);f(a(i)),u&&f(n(o)),m(i),g(`idle`),e?.(t)}catch{g(`error`),e?.(t)}},500,{leading:!0,trailing:!0}),y=(0,c.useCallback)(e=>{v(e)},[v]),b=(0,c.useCallback)(()=>{m([])},[]),x=s(),[S,C]=(0,c.useState)(null);(0,c.useEffect)(()=>{if(!x||h!==`idle`||S!==null||!d)return;async function e(){g(`loading`);try{let e=await r(`GET`,`v1/accounts/${x}/following`,{params:{limit:40}}),t=e.map(e=>e.id);f(a(e)),u&&f(n(t)),C(e),g(`idle`)}catch{g(`error`)}}e()},[x,p,f,t,h,u,S,d]);let w=p.length===0&&d?S??[]:p;return{searchAccounts:y,resetAccounts:b,accounts:t?w.filter(t):w,isLoading:h===`loading`,isError:h===`error`}}export{l as t}; 2//# sourceMappingURL=useSearchAccounts-IVu8Yjyt.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.