PageSourceSearch

https://skyjake.fi/packs/useSearchAccounts-Bc9BlrPS.js

js skyjake.fi collected 2026-09-24 18:26:15 UTC 1,495 bytes, 2 lines download raw bytes

1import{o as e}from"./chunk-CMxvf4Kt.js";import{n as t}from"./jsx-runtime-SsSjplwM.js";import{la as n}from"./render-Gl4Q1vIP.js";import{r}from"./defineProperty-ClgyJMzY.js";import{C as i}from"./accounts_typed-CIc-5GGi.js";import{o as a}from"./typed_functions-CyAHd4bl.js";import{n as o}from"./useAccountId-BSm17QNl.js";import{t as s}from"./index.module-3tq1TBjm.js";var c=e(t());function l({onSettled:e,filterResults:t,resetOnInputClear:l=!0,withRelationships:u=!1,withDefaultFollows:d=!1}={}){let f=a(),[p,m]=(0,c.useState)([]),[h,g]=(0,c.useState)(`idle`),_=(0,c.useRef)(null),v=s(async t=>{if(_.current&&_.current.abort(),t.trim().length===0){e?.(``),l&&m([]);return}g(`loading`),_.current=new AbortController;try{let a=await r(`GET`,`v1/accounts/search`,{signal:_.current.signal,params:{q:t,resolve:!0}}),o=a.map(e=>e.id);f(i(a)),u&&f(n(o)),m(a),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=o(),[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(i(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-Bc9BlrPS.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.