var v=class extends Error{constructor(a,c){super(a.statusText),this.code=a.status,this.response=a,this.body=c}},O=!1,E=a=>{function c(r){if(typeof r!="object"||r===null)return!1;let o=r;for(;Object.getPrototypeOf(o)!==null;)o=Object.getPrototypeOf(o);return Object.getPrototypeOf(r)===o}return function(o,w){const{beforeRequest:h,customParser:p,...f}={...w};f.headers&&Object.keys(f.headers).forEach(e=>{const t=e.toLowerCase();t!==e&&(f.headers[t]=f.headers[e],delete f.headers[e])}),h==null||h(o,f);let{timeout:u=5e3,json:T,text:x,blob:m,buffer:P,headers:l={},...s}=f;if(s.method){const e=s.method.toUpperCase();["PUT","PATCH","DELETE"].includes(e)&&O&&(l={...l,"x-http-method-override":e},s.method="POST")}c(s.body)&&(l["content-type"]="application/json;charset=UTF-8",s.body=JSON.stringify(s.body)),s.headers=l;function b(e){let t=m?"blob":P?"arrayBuffer":T?"json":x?"text":void 0;if(t===void 0){const[n]=(e.headers.get("content-type")||"").split(";"),[d,i]=n.split("/");d==="application"?i==="json"?t="json":i==="octet-stream"?t=m?"blob":"arrayBuffer":t="text":t="text"}return e[t]().then(n=>({r:e,body:n}))}return new Promise((e,t)=>{let n;u>0&&(n=setTimeout(()=>{n=void 0,d.abort(),t(new Error(`fetch ${o} timeout for ${u}ms.`))},u));const d=a(o,s);d.then(i=>(n&&clearTimeout(n),p?p(i,b):b(i))).then(({r:i,body:y})=>{if(!i.ok){t(new v(i,y));return}e(y)}).catch(t)})}},g=E((a,c)=>{const r=new window.AbortController,o=window.fetch(a,{...c,signal:r.signal});return o.abort=()=>r.abort(),o}),j=g;export{j as i};
