function e(e){if(typeof e==`string`&&e)return e;if(!Array.isArray(e))return null;let t=e.map(e=>{if(!e||typeof e!=`object`)return``;let{loc:t,msg:n}=e,r=Array.isArray(t)?t.filter(e=>e!==`body`).join(`.`):``,i=typeof n==`string`?n:``;return r&&i?`${r}: ${i}`:r||i}).filter(Boolean);return t.length>0?t.join(`; `):null}var t=4;function n(r,i){if(!r||typeof r!=`object`)return null;let a=r,o=e(a.detail);if(o)return o;if(i<t&&a.detail&&typeof a.detail==`object`&&!Array.isArray(a.detail)){let e=n(a.detail,i+1);if(e)return e}if(typeof a.message==`string`&&a.message)return a.message;if(a.error&&typeof a.error==`object`){let e=a.error.message;if(typeof e==`string`&&e)return e}return null}function r(e){return n(e,0)}async function i(e,t=`Request failed`){try{let t=r(await e.json());if(t)return t}catch{}return`${t} (${e.status})`}export{e as n,i as r,r as t};