import{r as e}from"./rolldown-runtime-hePW80VL.js";import{di as t}from"./lucide-icons-6JcOMNkr.js";import{t as n}from"./useAppContext-DVsgK-HT.js";var r=e(t(),1);function i(e,t,n){if(!n||!e)return e;let r;try{r=new URL(n)}catch{return e}return r.protocol!==`https:`||e.startsWith(`data:`)||e.endsWith(`.svg`)||e.includes(`wsrv.nl`)||e.includes(n)?e:`${(r.origin+r.pathname).replace(/\/+$/,``)}/?${new URLSearchParams({url:e,w:String(t),output:`webp`,q:`75`,default:e}).toString()}`}async function a(e,t,n=1024,r=`pasted-image`){let i=e.startsWith(`data:`)?e:o(e,t||`https://wsrv.nl`,n),a=await fetch(i);if(!a.ok)throw Error(`Failed to fetch image (${a.status})`);let s=await a.blob();if(!s.type.startsWith(`image/`))throw Error(`Fetched resource is not an image`);let c=s.type===`image/png`?`.png`:s.type===`image/webp`?`.webp`:`.jpg`;return new File([s],`${r}${c}`,{type:s.type})}function o(e,t,n){let r;try{r=new URL(t)}catch{return e}return r.protocol===`https:`?`${(r.origin+r.pathname).replace(/\/+$/,``)}/?${new URLSearchParams({url:e,output:`png`,w:String(n),fit:`inside`}).toString()}`:e}function s(){let{config:e}=n(),t=e.imageProxy;return(0,r.useCallback)((e,n)=>i(e,n,t),[t])}export{a as n,s as t};