import{At as e,B as t,C as n,Ct as r,L as i,Ot as a,T as o,Tt as s,U as c,g as l,gt as u,jt as d,o as f,ot as p,tt as m,v as h,y as g}from"./D2zWjF09.js";import{Vt as _}from"./C-b6hTTf.js";import{Ct as v,D as y,jt as b,o as x}from"./Co3OAyKc.js";import{t as S}from"./CHHO6nw6.js";var C=[`src`],w={key:0,class:`loading-state`},T={key:1,class:`error-state`},E={class:`error-header`},D={class:`error-type`},O={class:`error-message`},k={key:0,class:`error-stack`},A=Object.assign(S(o({__name:`ImageLoader`,props:{src:{},aspectRatio:{},maxHeight:{},maxWidth:{},minHeight:{}},emits:[`load`],setup(t,{emit:o}){let _=t,v=o,b=u(!1),S=u(!1),A=u(!1),j=u(0),M;m(()=>_.src,()=>{S.value=!0,A.value=!1,b.value=!1,j.value=Date.now(),clearTimeout(M),M=setTimeout(()=>{S.value&&(A.value=!0)},200)},{immediate:!0});function N(){S.value=!1,A.value=!1,clearTimeout(M),v(`load`,{timeTaken:Date.now()-j.value,sizeKb:``})}i(()=>clearTimeout(M));function P(){S.value=!1,A.value=!1,clearTimeout(M),$fetch(_.src).catch(e=>{b.value=e.data?.stack||[`Failed to load image`]})}return(i,o)=>{let u=y;return c(),g(`div`,{class:a([`image-loader`,{"is-valid":!s(b)&&!s(S),"is-error":s(b)}]),style:e({aspectRatio:t.aspectRatio,minHeight:t.minHeight})},[p(l(`img`,{src:t.src,style:e({aspectRatio:t.aspectRatio,maxWidth:`${s(r)(s(x).width)||1200}px`}),onLoad:N,onError:P},null,44,C),[[f,!s(S)&&!s(b)]]),s(A)?(c(),g(`div`,w,[...o[0]||=[l(`div`,{class:`loading-spinner`},null,-1)]])):h(``,!0),s(b)?(c(),g(`div`,T,[l(`div`,E,[n(u,{name:`carbon:warning`,class:`error-icon`}),l(`span`,D,d(s(b).join(`
`).includes(`satori`)?`SatoriError`:`ImageError`),1)]),l(`p`,O,d(s(b)[0]?.replace(`Error:`,``)),1),s(b).length>1?(c(),g(`pre`,k,d(s(b).slice(1).join(`
`)),1)):h(``,!0)])):h(``,!0)],6)}}}),[[`__scopeId`,`data-v-7f953e88`]]),{__name:`ImageLoader`}),j=Object.assign(S(o({__name:`IFrameLoader`,props:{src:{},aspectRatio:{}},emits:[`load`],setup(n,{emit:i}){let a=n,o=i,d=u(),f=u(),p=u(),h=b(()=>{let e=f.value;if(!e||!d.value)return;let t=Date.now();e.src=``;let n=r(x.value.width)||1200,i=p.value?.offsetWidth,a=i?Math.min(1,i/n):1;e.style.opacity=`0`,e.onload=()=>{e.style.opacity=`1`,o(`load`,{timeTaken:Date.now()-t})},e.src=_(d.value,{scale:a})},200);return t(()=>{m(()=>a.src,e=>{d.value!==e&&f.value&&(d.value=e,h())},{immediate:!0}),m(f,()=>{h()})}),v(p,()=>{d.value&&h()}),m(()=>r(x.value.width),()=>{d.value&&h()},{flush:`post`}),(t,i)=>(c(),g(`div`,{ref_key:`container`,ref:p,class:`iframe-loader`,style:e({aspectRatio:n.aspectRatio,maxWidth:`${s(r)(s(x).width)||1200}px`})},[l(`iframe`,{ref_key:`iframe`,ref:f},null,512)],4))}}),[[`__scopeId`,`data-v-6929e48a`]]),{__name:`IFrameLoader`});export{A as n,j as t};