import{n as e}from"./BNTlsKDJ.js";var t=e({ApiError:()=>r,apiFetch:()=>i}),n=``,r=class extends Error{constructor(e,t,n){super(t),this.status=e,this.body=n,this.name=`ApiError`}};async function i(e,t,i=globalThis.fetch){let a={...t?.headers};t?.body&&(a[`Content-Type`]=a[`Content-Type`]??`application/json`);let o=await i(`${n}${e}`,{...t,headers:a});if(!o.ok){let t=await o.json().catch(()=>({error:o.statusText}));throw o.status===401&&typeof window<`u`&&!e.startsWith(`/api/auth/`)&&window.location.pathname!==`/login`&&(window.location.href=`/login`),new r(o.status,t.error??o.statusText,t)}return o.json()}export{t as n,i as t};