import{c as e,i as t}from"./preload-helper-B45gAKPr.js";import{pn as n,t as r}from"./iframe-NOj5DEP4.js";function i({width:e=`100%`,height:t=`100%`,aspectRatio:n=`16 / 9`,className:r}){return(0,a.jsx)(`div`,{style:{width:e,height:t,aspectRatio:n},className:r,children:(0,a.jsx)(`svg`,{width:e,height:t,viewBox:`0 0 200 200`,xmlns:`http://www.w3.org/2000/svg`,role:`img`,fill:`none`,rx:`10`,ry:`10`,style:{display:`block`},"aria-label":`Изображение недоступно`,children:(0,a.jsxs)(`g`,{fill:`var(--surface-0)`,children:[(0,a.jsx)(`rect`,{x:`40`,y:`50`,width:`120`,height:`100`,rx:`10`}),(0,a.jsx)(`circle`,{cx:`60`,cy:`70`,r:`8`,fill:`var(--surface-2)`}),(0,a.jsx)(`path`,{d:`M50 130 L75 100 L100 130 Z`,fill:`var(--surface-2)`}),(0,a.jsx)(`path`,{d:`M90 130 L120 90 L150 130 Z`,fill:`var(--surface-2)`}),(0,a.jsx)(`line`,{x1:`160`,y1:`40`,x2:`40`,y2:`160`,stroke:`var(--surface-0)`,strokeWidth:`15`,strokeLinecap:`round`}),(0,a.jsx)(`line`,{x1:`160`,y1:`40`,x2:`40`,y2:`160`,stroke:`var(--surface-2)`,strokeWidth:`5`,strokeLinecap:`round`})]})})})}var a,o=t((()=>{a=r(),i.__docgenInfo={description:``,methods:[],displayName:`ImagePlaceholder`,props:{width:{required:!1,tsType:{name:`union`,raw:`number | string`,elements:[{name:`number`},{name:`string`}]},description:``,defaultValue:{value:`"100%"`,computed:!1}},height:{required:!1,tsType:{name:`union`,raw:`number | string`,elements:[{name:`number`},{name:`string`}]},description:``,defaultValue:{value:`"100%"`,computed:!1}},aspectRatio:{required:!1,tsType:{name:`union`,raw:`string | "unset"`,elements:[{name:`string`},{name:`literal`,value:`"unset"`}]},description:``,defaultValue:{value:`"16 / 9"`,computed:!1}},className:{required:!1,tsType:{name:`string`},description:``}}}}));function s({src:e,sources:t,alt:n,role:r,ariaLabel:a,caption:o,fallback:s,useFigure:u=!1,layout:d=`cover`,width:f=`100%`,height:p=`100%`,aspectRatio:m,intrinsicWidth:h,intrinsicHeight:g,onLoad:_,onError:v,style:y,wrapperStyle:b,...x}){let S=(0,c.useRef)(null),[C,w]=(0,c.useState)(0),[T,E]=(0,c.useState)(!1),[D,O]=(0,c.useState)(!1),[k,A]=(0,c.useState)(!1);(0,c.useEffect)(()=>{if(typeof IntersectionObserver>`u`){let e=window.setTimeout(()=>E(!0),0);return()=>window.clearTimeout(e)}let e=new IntersectionObserver(([t])=>{if(t.isIntersecting){let n=Math.round(t.boundingClientRect.width);w(n),E(!0),e.disconnect()}},{rootMargin:`100px`,threshold:.01});return S.current&&e.observe(S.current),()=>e.disconnect()},[]);let j=d===`intrinsic`,M=j?`auto`:p,N=h&&g?`${h} / ${g}`:void 0,P=j?N??m??`auto`:m??`16 / 9`,F=j&&P!==`auto`&&P!==`unset`?`100%`:M,I=C?`${C}px`:`100vw`,L=(0,l.jsx)(i,{width:f,height:F,aspectRatio:P}),R=j?{...y,display:`block`,width:`100%`,height:`auto`,objectFit:void 0}:{display:`block`,width:`100%`,height:`100%`,objectFit:d,...y},z=(0,l.jsxs)(l.Fragment,{children:[!D&&!k&&(s||L),T&&!k&&(0,l.jsxs)(`picture`,{children:[t?.map(e=>(0,l.jsx)(`source`,{srcSet:e.srcSet,type:e.type,sizes:e.sizes??I},`${e.type??`source`}-${e.srcSet}`)),(0,l.jsx)(`img`,{src:e,alt:n,role:r,"aria-label":a,onLoad:e=>{O(!0),_?.(e)},onError:e=>{A(!0),v?.(e)},style:D?R:{display:`none`},"aria-busy":!D,width:h,height:g,...x})]}),k&&L]}),B=(0,l.jsx)(`div`,{ref:S,style:{width:f,height:M,aspectRatio:P,...b},children:z});return u?(0,l.jsxs)(`figure`,{className:`relative`,children:[B,o&&(0,l.jsx)(`figcaption`,{style:{bottom:2,right:2,maxWidth:`calc(100% - 4px)`},className:`absolute paddingInlineMd textRight radiusSm fontSizeSm`,children:o})]}):B}var c,l,u=t((()=>{c=e(n(),1),o(),l=r(),s.__docgenInfo={description:`Базовый рендер изображения: lazy-появление, placeholder, обработка ошибки и figure/caption.
Компонент не знает, как устроено хранилище и какие форматы/размеры доступны.`,methods:[],displayName:`ImageRenderer`,props:{src:{required:!0,tsType:{name:`string`},description:``},sources:{required:!1,tsType:{name:`unknown`},description:``},layout:{required:!1,tsType:{name:`union`,raw:`"cover" | "contain" | "intrinsic"`,elements:[{name:`literal`,value:`"cover"`},{name:`literal`,value:`"contain"`},{name:`literal`,value:`"intrinsic"`}]},description:``,defaultValue:{value:`"cover"`,computed:!1}},alt:{required:!1,tsType:{name:`string`},description:``},role:{required:!1,tsType:{name:`string`},description:``},ariaLabel:{required:!1,tsType:{name:`string`},description:``},caption:{required:!1,tsType:{name:`string`},description:``},fallback:{required:!1,tsType:{name:`ReactNode`},description:``},useFigure:{required:!1,tsType:{name:`boolean`},description:``,defaultValue:{value:`false`,computed:!1}},aspectRatio:{required:!1,tsType:{name:`union`,raw:`string | "unset"`,elements:[{name:`string`},{name:`literal`,value:`"unset"`}]},description:``},width:{required:!1,tsType:{name:`CSSProperties["width"]`,raw:`CSSProperties["width"]`},description:``,defaultValue:{value:`"100%"`,computed:!1}},height:{required:!1,tsType:{name:`CSSProperties["height"]`,raw:`CSSProperties["height"]`},description:``,defaultValue:{value:`"100%"`,computed:!1}},intrinsicWidth:{required:!1,tsType:{name:`number`},description:``},intrinsicHeight:{required:!1,tsType:{name:`number`},description:``},wrapperStyle:{required:!1,tsType:{name:`CSSProperties`},description:``}},composes:[`Omit`]}}));export{u as n,s as t};