import{h as d,j as S}from"./codemirror-core-DIzFijqu.js";import{t as U,c as V,d as q}from"./index-DiFbo-KR.js";import{D as J,bg as z,H as Q,x as C,r as A,v as X}from"./react-dom-C0IJc3nR.js";function Y(){const o=()=>()=>{};return d.useSyncExternalStore(o,()=>!0,()=>!1)}function ee(o={}){const{onLoad:l,onError:a,ignoreFallback:i}=o,e=Y(),r=d.useRef(e?new Image:null),[u,n]=d.useState("pending");d.useEffect(()=>{r.current&&(r.current.onload=m=>{s(),n("loaded"),l==null||l(m)},r.current.onerror=m=>{s(),n("failed"),a==null||a(m)})},[r.current]);const s=()=>{r.current&&(r.current.onload=null,r.current.onerror=null,r.current=null)};return U(()=>{e&&n(se(o,r))},[e]),i?"loaded":u}function se(o,l){const{loading:a,src:i,srcSet:e,crossOrigin:r,sizes:u,ignoreFallback:n}=o;if(!i)return"pending";if(n)return"loaded";const s=new Image;return s.src=i,r&&(s.crossOrigin=r),e&&(s.srcset=e),u&&(s.sizes=u),a&&(s.loading=a),l.current=s,s.complete&&s.naturalWidth?"loaded":"loading"}function re(o){var l,a;const i=V(),[e,r]=J(o,z.variantKeys),{ref:u,as:n,src:s,className:m,classNames:t,loading:b,isBlurred:v,fallbackSrc:g,isLoading:c,disableSkeleton:p=!!g,removeWrapper:B=!1,onError:F,onLoad:H,srcSet:x,sizes:w,crossOrigin:y,...I}=e,k=ee({src:s,loading:b,onError:F,onLoad:H,ignoreFallback:!1,srcSet:x,sizes:w,crossOrigin:y}),N=(a=(l=o.disableAnimation)!=null?l:i==null?void 0:i.disableAnimation)!=null?a:!1,P=k==="loaded"&&!c,E=k==="loading"||c,O=o.isZoomed,D=n||"img",W=q(u),{w:j,h:M}=d.useMemo(()=>({w:e.width?typeof e.width=="number"?`${e.width}px`:e.width:"fit-content",h:e.height?typeof e.height=="number"?`${e.height}px`:e.height:"auto"}),[e==null?void 0:e.width,e==null?void 0:e.height]),L=(!s||!P)&&!!g,R=E&&!p,f=d.useMemo(()=>z({...r,disableAnimation:N,showSkeleton:R}),[Q(r),N,R]),Z=C(m,t==null?void 0:t.img),_=(h={})=>{const T=C(Z,h==null?void 0:h.className);return{src:s,ref:W,"data-loaded":A(P),className:f.img({class:T}),loading:b,srcSet:x,sizes:w,crossOrigin:y,...I,style:{...(I==null?void 0:I.height)&&{height:M},...h.style,...I.style}}},G=d.useCallback(()=>{const h=L?{backgroundImage:`url(${g})`}:{};return{className:f.wrapper({class:t==null?void 0:t.wrapper}),style:{...h,maxWidth:j}}},[f,L,g,t==null?void 0:t.wrapper,j]),K=d.useCallback(()=>({src:s,"aria-hidden":A(!0),className:f.blurredImg({class:t==null?void 0:t.blurredImg})}),[f,s,t==null?void 0:t.blurredImg]);return{Component:D,domRef:W,slots:f,classNames:t,isBlurred:v,disableSkeleton:p,fallbackSrc:g,removeWrapper:B,isZoomed:O,isLoading:E,getImgProps:_,getWrapperProps:G,getBlurredImgProps:K}}var $=X((o,l)=>{const{Component:a,domRef:i,slots:e,classNames:r,isBlurred:u,isZoomed:n,fallbackSrc:s,removeWrapper:m,disableSkeleton:t,getImgProps:b,getWrapperProps:v,getBlurredImgProps:g}=re({...o,ref:l}),c=S.jsx(a,{ref:i,...b()});if(m)return c;const p=S.jsx("div",{className:e.zoomedWrapper({class:r==null?void 0:r.zoomedWrapper}),children:c});return u?S.jsxs("div",{...v(),children:[n?p:c,d.cloneElement(c,g())]}):n||!t||s?S.jsxs("div",{...v(),children:[" ",n?p:c]}):c});$.displayName="HeroUI.Image";var ae=$;export{ae as i,ee as u};
