import{a as x}from"./chunk-CP4WO7MM.mjs";import{a as u}from"./chunk-IHX4EDUF.mjs";async function b(r,t,a={}){let{timeout:p=5e3,maxRetries:e=10,retryDelay:f=1e3}=a,i=null;for(let n=0;n<e;n++){let l=new AbortController,c=setTimeout(()=>{l.abort()},p);try{let o=await fetch(r,{...t,signal:l.signal});if(clearTimeout(c),o.ok)return o;if(o.status===429||o.status>=500){let m=f+Math.pow(n,2)*50;await new Promise(s=>setTimeout(s,m));continue}if(o.status===403)throw new Error("Unauthorized");if(!o.ok){let m;try{m=(await o.json()).error||`HTTP error ${o.status}`}catch{m=`HTTP error ${o.status}`}throw new Error(m)}}catch(o){if(clearTimeout(c),i=o instanceof Error?o:new Error(String(o)),n===e-1)throw new Error(`Failed after ${e} retries. Last error: ${i.message}`);let m=f+Math.pow(n,2)*50;await new Promise(s=>setTimeout(s,m))}}throw new Error(`Failed after ${e} retries`)}function C({domain:r,key:t,pretty:a,searchParams:p}){if(!r)return"";let e=`https://${u(r)}${t&&t!=="_root"?`/${u(t)}`:""}`;if(p){let f=new URLSearchParams;for(let[i,n]of Object.entries(p))f.set(i,n);e+=`?${f.toString()}`}return a?e.replace(/^https?:\/\//,""):e}function U({domain:r,key:t}){return`https://${r}${t==="_root"?"":`/${t}`}`}var wr=r=>!r.periodStart||!r.periodEnd?"-":`${x(r.periodStart,{month:"short",year:new Date(r.periodStart).getUTCFullYear()===new Date(r.periodEnd).getUTCFullYear()?void 0:"numeric",timeZone:"utc"})}-${x(r.periodEnd,{month:"short",timeZone:"utc"})}`;export{wr as a,b,C as c,U as d};
