import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{n}from"./Helper-22ZAnvuN.js";var r=e(t(),1);function i(e,t,i){let[a,o]=(0,r.useState)([]),[s,c]=(0,r.useState)(0),[l,u]=(0,r.useState)(!i?.skip),[d,f]=(0,r.useState)(null),p=JSON.stringify(t??{}),m=(0,r.useCallback)(async()=>{if(!i?.skip){u(!0),f(null);try{let r;r=t&&Object.keys(t).length>0?await n(e,t):await n(e,{}),!Array.isArray(r)&&r?.count!==void 0&&c(r.count);let i=Array.isArray(r)?r:r?.results??[];o(i)}catch(e){f(e)}finally{u(!1)}}},[e,p,i?.skip]);return(0,r.useEffect)(()=>{m()},[m]),{data:a,isLoading:l,error:d,refetch:m,totalCount:s}}export{i as t};