var e=`/api`,t=null;function n(e){t=e}function r(){t&&t()}var i=null;async function a(){return i||(i=fetch(`${e}/auth/refresh`,{method:`POST`,credentials:`include`}).then(e=>e.ok).catch(()=>!1).finally(()=>{i=null}),i)}async function o(n,r){let i={"Content-Type":`application/json`,...r?.headers},o=()=>fetch(`${e}${n}`,{...r,headers:i,credentials:`include`}),s=await o();if(s.status===401)if(await a())s=await o();else throw t?t():window.location.href=`/ui/auth/signin?returnUrl=${encodeURIComponent(window.location.pathname+window.location.search)}`,Error(`Session expired`);if(!s.ok){let e=await s.json().catch(()=>({error:s.statusText}));throw Error(e.error||s.statusText)}if(s.status!==204)return s.json()}async function s(n,r,i){let o=()=>fetch(`${e}${n}`,{method:`POST`,...i,body:r,credentials:`include`}),s=await o();if(s.status===401)if(await a())s=await o();else throw t?t():window.location.href=`/ui/auth/signin?returnUrl=${encodeURIComponent(window.location.pathname+window.location.search)}`,Error(`Session expired`);if(!s.ok){let e=await s.json().catch(()=>({error:s.statusText}));throw Error(e.error||s.statusText)}return s.json()}function c(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!=null&&r!==``&&t.set(n,String(r));let n=t.toString();return n?`?${n}`:``}function l(e){return e.results}function u(e){return{items:e.results,total:e.total}}export{r as a,u as c,s as i,c as n,a as o,o as r,l as s,n as t};