Files
vat-api.eu/node_modules/@nuxt/devtools/dist/client/_nuxt/dist-joij2tdx.js
2026-02-13 22:02:30 +01:00

1 line
5.6 KiB
JavaScript

import{r as e}from"./rolldown-runtime-oipoa1or.js";import{Ln as t,Rn as n,zn as r}from"#entry";var i=class extends Error{constructor(e,t){super(e,t),this.name=`FetchError`,t?.cause&&!this.cause&&(this.cause=t.cause)}};function a(e){let t=e.error?.message||e.error?.toString()||``,n=e.request?.method||e.options?.method||`GET`,r=e.request?.url||String(e.request)||`/`,a=new i(`${`[${n}] ${JSON.stringify(r)}`}: ${e.response?`${e.response.status} ${e.response.statusText}`:`<no response>`}${t?` ${t}`:``}`,e.error?{cause:e.error}:void 0);for(let t of[`request`,`options`,`response`])Object.defineProperty(a,t,{get(){return e[t]}});for(let[t,n]of[[`data`,`_data`],[`status`,`status`],[`statusCode`,`status`],[`statusText`,`statusText`],[`statusMessage`,`statusText`]])Object.defineProperty(a,t,{get(){return e.response&&e.response[n]}});return a}var o=new Set(Object.freeze([`PATCH`,`POST`,`PUT`,`DELETE`]));function s(e=`GET`){return o.has(e.toUpperCase())}function c(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer||e instanceof FormData||e instanceof URLSearchParams?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}var l=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]),u=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function d(e=``){if(!e)return`json`;let t=e.split(`;`).shift()||``;return u.test(t)?`json`:t===`text/event-stream`?`stream`:l.has(t)||t.startsWith(`text/`)?`text`:`blob`}function f(e,t,n,r){let i=p(t?.headers??e?.headers,n?.headers,r),a;return(n?.query||n?.params||t?.params||t?.query)&&(a={...n?.params,...n?.query,...t?.params,...t?.query}),{...n,...t,query:a,params:a,headers:i}}function p(e,t,n){if(!t)return new n(e);let r=new n(t);if(e)for(let[t,i]of Symbol.iterator in e||Array.isArray(e)?e:new n(e))r.set(t,i);return r}async function m(e,t){if(t)if(Array.isArray(t))for(let n of t)await n(e);else await t(e)}var h=new Set([408,409,425,429,500,502,503,504]),g=new Set([101,204,205,304]);function _(e={}){let{fetch:i=globalThis.fetch,Headers:o=globalThis.Headers,AbortController:l=globalThis.AbortController}=e;async function u(e){let t=e.error&&e.error.name===`AbortError`&&!e.options.timeout||!1;if(e.options.retry!==!1&&!t){let t;t=typeof e.options.retry==`number`?e.options.retry:s(e.options.method)?0:1;let n=e.response&&e.response.status||500;if(t>0&&(Array.isArray(e.options.retryStatusCodes)?e.options.retryStatusCodes.includes(n):h.has(n))){let n=typeof e.options.retryDelay==`function`?e.options.retryDelay(e):e.options.retryDelay||0;return n>0&&await new Promise(e=>setTimeout(e,n)),p(e.request,{...e.options,retry:t-1})}}let n=a(e);throw Error.captureStackTrace&&Error.captureStackTrace(n,p),n}let p=async function(a,p={}){let h={request:a,options:f(a,p,e.defaults,o),response:void 0,error:void 0};if(h.options.method&&(h.options.method=h.options.method.toUpperCase()),h.options.onRequest&&(await m(h,h.options.onRequest),h.options.headers instanceof o||(h.options.headers=new o(h.options.headers||{}))),typeof h.request==`string`&&(h.options.baseURL&&(h.request=t(h.request,h.options.baseURL)),h.options.query&&(h.request=n(h.request,h.options.query),delete h.options.query),`query`in h.options&&delete h.options.query,`params`in h.options&&delete h.options.params),h.options.body&&s(h.options.method))if(c(h.options.body)){let e=h.options.headers.get(`content-type`);typeof h.options.body!=`string`&&(h.options.body=e===`application/x-www-form-urlencoded`?new URLSearchParams(h.options.body).toString():JSON.stringify(h.options.body)),e||h.options.headers.set(`content-type`,`application/json`),h.options.headers.has(`accept`)||h.options.headers.set(`accept`,`application/json`)}else (`pipeTo`in h.options.body&&typeof h.options.body.pipeTo==`function`||typeof h.options.body.pipe==`function`)&&(`duplex`in h.options||(h.options.duplex=`half`));let _;if(!h.options.signal&&h.options.timeout){let e=new l;_=setTimeout(()=>{let t=Error(`[TimeoutError]: The operation was aborted due to timeout`);t.name=`TimeoutError`,t.code=23,e.abort(t)},h.options.timeout),h.options.signal=e.signal}try{h.response=await i(h.request,h.options)}catch(e){return h.error=e,h.options.onRequestError&&await m(h,h.options.onRequestError),await u(h)}finally{_&&clearTimeout(_)}if((h.response.body||h.response._bodyInit)&&!g.has(h.response.status)&&h.options.method!==`HEAD`){let e=(h.options.parseResponse?`json`:h.options.responseType)||d(h.response.headers.get(`content-type`)||``);switch(e){case`json`:{let e=await h.response.text(),t=h.options.parseResponse||r;h.response._data=t(e);break}case`stream`:h.response._data=h.response.body||h.response._bodyInit;break;default:h.response._data=await h.response[e]()}}return h.options.onResponse&&await m(h,h.options.onResponse),!h.options.ignoreResponseError&&h.response.status>=400&&h.response.status<600?(h.options.onResponseError&&await m(h,h.options.onResponseError),await u(h)):h.response},v=async function(e,t){return(await p(e,t))._data};return v.raw=p,v.native=(...e)=>i(...e),v.create=(t={},n={})=>_({...e,...n,defaults:{...e.defaults,...n.defaults,...t}}),v}var v=e({$fetch:()=>w,AbortController:()=>S,Headers:()=>x,createFetch:()=>_,fetch:()=>b,ofetch:()=>C}),y=(function(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`unable to locate global object`)})(),b=y.fetch?(...e)=>y.fetch(...e):()=>Promise.reject(Error(`[ofetch] global.fetch is not supported!`)),x=y.Headers,S=y.AbortController,C=_({fetch:b,Headers:x,AbortController:S}),w=C;export{v as n,w as t};