import{o as e}from"./rolldown-runtime.C0FnF6B9.js";import{r as t}from"./emotion-is-prop-valid.esm.CuYlOKOk.js";import{a as n,i as r,t as i}from"./emotion-styled.browser.esm.Dj5rZcu_.js";import{t as a}from"./loglevel.xXLtmX_e.js";import{r as o}from"./StreamlitMarkdown.DYzuPhFL.js";import{n as s}from"./UriUtil.Wq-or4O5.js";import{t as c}from"./useCrossOriginAttribute.CkRekpDE.js";import{p as l}from"./ErrorElement.CZxpg0mG.js";import{t as u}from"./Toolbar.ButNSXx3.js";import{t as d}from"./useRequiredContext.DBsQavvD.js";import{n as f,t as p}from"./withFullScreenWrapper.rD4M9QAP.js";var m=e(t(),1),h=e(a(),1),g=i(`div`,{target:`ehg91i90`})(({theme:e,shouldStretch:t})=>({display:`flex`,flexDirection:`row`,flexWrap:`wrap`,rowGap:e.spacing.lg,maxWidth:`100%`,width:t?`100%`:`fit-content`})),_=i(`div`,{target:`ehg91i91`})(({theme:e,shouldStretch:t})=>({display:`flex`,flexDirection:`column`,alignItems:`stretch`,width:t?`100%`:`auto`,flexGrow:+!!t,">img":{borderRadius:e.radii.default}})),v=i(`div`,{target:`ehg91i92`})(({theme:e})=>({textAlign:`center`,marginTop:e.spacing.xs,wordWrap:`break-word`,padding:e.spacing.threeXS})),y=i(`a`,{target:`ehg91i93`})(({theme:e})=>({display:`block`,borderRadius:e.radii.default,overflow:`hidden`,"&:hover":{opacity:.85},"&:focus-visible":{boxShadow:e.shadows.focusRing}})),b=(0,h.getLogger)(`ImageList`);function x(e,t){if(e){if(e.useStretch)return t;if(e.useContent)return;if(e.pixelWidth)return e.pixelWidth}}var S=({itemKey:e,image:t,imgStyle:i,buildMediaURL:a,handleImageError:l,shouldStretch:u,link:d})=>{let f=c(t.url),p=d?s(d):!1,m=p?`#`:d,h=r(`img`,{style:i,src:a(t.url),alt:e,onError:l,crossOrigin:f});return n(_,{"data-testid":`stImageContainer`,shouldStretch:u,children:[m?r(y,{href:m,target:p?`_self`:`_blank`,rel:`noreferrer`,onClick:p?e=>e.preventDefault():void 0,"aria-label":t.caption||(p?void 0:d),"data-testid":`stImageLink`,children:h}):h,t.caption&&r(v,{"data-testid":`stImageCaption`,style:i,children:r(o,{source:t.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]})};function C({element:e,endpoints:t,widthConfig:i,disableFullscreenMode:a}){let{expanded:o,width:s,height:c,expand:p,collapse:m}=d(f),h=s||0,_=x(i,h),v=i?.useStretch??!1,y={};c&&o?(y.maxHeight=c,y.objectFit=`contain`,y.width=`100%`):(y.width=_??`100%`,y.maxWidth=`100%`);let C=e=>{let n=e.currentTarget.src;b.error(`Client Error: Image source error - ${n}`),t.sendClientErrorToHost(`Image`,`Image source failed to load`,`onerror triggered`,n)};return n(l,{width:h,height:c,useContainerWidth:o,topCentered:!0,children:[r(u,{target:l,isFullScreen:o,onExpand:p,onCollapse:m,disableFullscreenMode:a}),r(g,{className:`stImage`,"data-testid":`stImage`,shouldStretch:v,children:e.imgs.map((n,i)=>r(S,{itemKey:i.toString(),image:n,imgStyle:y,buildMediaURL:e=>t.buildMediaURL(e),handleImageError:C,shouldStretch:v,link:e.imgs.length===1?e.link:void 0},i))})]})}var w=p(C),T=(0,m.memo)(w);export{T as default};