import{h as c}from"./codemirror-core-vkcnXJgD.js";import{V as d}from"./index-BCSjj6Us.js";function f(){const n=()=>()=>{};return c.useSyncExternalStore(n,()=>!0,()=>!1)}function I(n={}){const{onLoad:u,onError:o,ignoreFallback:i}=n,t=f(),e=c.useRef(t?new Image:null),[a,s]=c.useState("pending");c.useEffect(()=>{e.current&&(e.current.onload=l=>{r(),s("loaded"),u==null||u(l)},e.current.onerror=l=>{r(),s("failed"),o==null||o(l)})},[e.current]);const r=()=>{e.current&&(e.current.onload=null,e.current.onerror=null,e.current=null)};return d(()=>{t&&s(g(n,e))},[t]),i?"loaded":a}function g(n,u){const{loading:o,src:i,srcSet:t,crossOrigin:e,sizes:a,ignoreFallback:s}=n;if(!i)return"pending";if(s)return"loaded";const r=new Image;return r.src=i,e&&(r.crossOrigin=e),t&&(r.srcset=t),a&&(r.sizes=a),o&&(r.loading=o),u.current=r,r.complete&&r.naturalWidth?"loaded":"loading"}export{I as u};
