import{j as l}from"./vendor-query-DoyCFZ4O.js";import{r as o}from"./vendor-react-Rhy2aEWQ.js";function m(t){const c=t.match(/^(https?:\/\/[^/]+\/storage\/[^/]+\/)([^.]+?)(?:-(large|medium|small))?\.(png|jpe?g|webp)$/i);if(c){const[,e,a]=c;return{webpSrcSet:[`${e}${a}-small.webp 400w`,`${e}${a}-medium.webp 800w`,`${e}${a}-large.webp 1600w`].join(", "),fallbackSrcSet:[`${e}${a}-small.jpg 400w`,`${e}${a}-medium.jpg 800w`,`${e}${a}-large.jpg 1600w`].join(", "),fallbackSrc:`${e}${a}-large.jpg`}}if(t.includes("images.unsplash.com")){const e=a=>t.replace(/w=\d+/,`w=${a}`).replace(/&h=\d+/,`&h=${Math.round(a*.75)}`);return{webpSrcSet:null,fallbackSrcSet:[`${e(400)} 400w`,`${e(800)} 800w`,`${e(1200)} 1200w`].join(", "),fallbackSrc:t}}return{webpSrcSet:null,fallbackSrcSet:null,fallbackSrc:t}}function g({src:t,alt:c,className:e="",sizes:a="100vw",loading:n="lazy",onError:s}){const[i,p]=o.useState(!1),r=m(t);if(i)return null;const S=()=>{p(!0),s==null||s()};return r.webpSrcSet?l.jsxs("picture",{children:[l.jsx("source",{type:"image/webp",srcSet:r.webpSrcSet,sizes:a}),r.fallbackSrcSet&&l.jsx("source",{type:"image/jpeg",srcSet:r.fallbackSrcSet,sizes:a}),l.jsx("img",{src:r.fallbackSrc,alt:c,className:e,loading:n,decoding:"async",onError:S})]}):l.jsx("img",{src:r.fallbackSrc,srcSet:r.fallbackSrcSet||void 0,sizes:r.fallbackSrcSet?a:void 0,alt:c,className:e,loading:n,decoding:"async",onError:S})}export{g as O};