(function(){try{var g=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};g["__faroBundleId_hub-ui"]="1776361634403-2195cb2175"}catch(l){}})();import{i as w}from"./h60ueqql.js";import{A as T,g as k,h as E,i as b}from"./htibg8hi.js";import"./c2heove9.js";import{o as d,s as i,f as g,i as h,n as S,g as l}from"./c2kxmmw2.js";const A=d({profile:T,token:i()});function m(){return{queryKey:["profile"],queryFn:({signal:t})=>x(t),staleTime:15*1e3}}async function x(t){const e=await fetch("/auth/profile",{signal:t});if(!e.ok)return null;try{const s=A.safeParse(await e.json());return s.success?s.data:null}catch{return null}}let f;function P(t){f=t}const O=new Set(["GET","PUT","HEAD","DELETE","OPTIONS","TRACE"]),R=d({headers:h(Headers),status:S(),text:i().optional(),blob:h(Blob).optional(),body:g().optional(),requestedUrl:i(),url:i()});d({url:i(),method:i(),headers:h(Headers)});class C extends Error{constructor(e,s,c){super(e),this.request=s,this.response=c}request;response}const H=h(Error).and(d({response:R}));function U(t){return H.safeParse(t).success}async function D(t,e){if(typeof fetch!="function"||typeof window>"u")throw new Error("fetchWithAuth is not supported on the server.");const s=new Headers(e?.headers);s.set("Accept","application/json"),s.set("Content-Type","application/json"),s.set("x-docker-api-client",`hub-ui/fetchWithAuth-${k().appVersion}`),e?.password&&s.set("Docker-Hub-Password",b(e.password));{w(f);const o=await f.fetchQuery(m());o?.token&&s.set("Authorization",`Bearer ${o.token}`)}const{sessionId:c}=E();c&&s.set("x-docker-session-id",c);const r=O.has(e?.method?.toUpperCase()??"GET");let n=0,a=2;typeof e?.retry=="number"&&e.retry>=0&&(a=e.retry+1);const u=o=>e?.noThrowStatuses===void 0?!0:Array.isArray(e.noThrowStatuses)?!e.noThrowStatuses.includes(o):!e.noThrowStatuses(o);for(;;)try{n+=1;const o=await fetch(t,{...e,headers:s});if(!o.ok&&u(o.status))throw await p(t,e,o,s);return o}catch(o){if(r&&n0)){try{a.blob=await s.blob(),a.text=await a.blob.text()}catch{a.text="[Failed to read response]"}try{a.body=JSON.parse(a.text)}catch{a.text="[Failed to read response]"}}const u={url:typeof t=="string"?t:t.url,method:e?.method??"GET",headers:new Headers(c)};return new C("Fetch returned a non-OK status code",u,a)}export{L as a,D as f,U as i,P as s};