import{z as u,r as L,W as C,o as x,j as i,R as E,q as b,V as v}from"./index.Drusyo5m.js";import{w as y,E as W}from"./withFullScreenWrapper.DfpAcJxf.js";import{S as p,T}from"./Toolbar.BHDNzWBx.js";const F=u("div",{target:"e1xt4yf90"})(({theme:e,shouldStretch:t})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",rowGap:e.spacing.lg,maxWidth:"100%",width:t?"100%":"fit-content"})),R=u("div",{target:"e1xt4yf91"})(({theme:e,shouldStretch:t})=>({display:"flex",flexDirection:"column",alignItems:"stretch",width:t?"100%":"auto",flexGrow:t?1:0,">img":{borderRadius:e.radii.default}})),j=u("div",{target:"e1xt4yf92"})(({theme:e})=>({textAlign:"center",marginTop:e.spacing.xs,wordWrap:"break-word",padding:e.spacing.threeXS})),H=v.getLogger("ImageList");function M(e,t,r){if(e){if(e.useStretch)return r;if(e.useContent)return;if(e.pixelWidth)return e.pixelWidth}if(t!=null)switch(t){case-1:case-3:case-4:return;case-2:case-5:return r;default:return t>0?t:void 0}}const G=({itemKey:e,image:t,imgStyle:r,buildMediaURL:l,handleImageError:s,shouldStretch:d})=>{const o=E(t.url);return x(R,{"data-testid":"stImageContainer",shouldStretch:d,children:[i("img",{style:r,src:l(t.url),alt:e,onError:s,crossOrigin:o}),t.caption&&i(j,{"data-testid":"stImageCaption",style:r,children:i(b,{source:t.caption,allowHTML:!1,isCaption:!0,isLabel:!0})})]})};function O({element:e,endpoints:t,widthConfig:r,disableFullscreenMode:l}){const{expanded:s,width:d,height:o,expand:f,collapse:h}=C(W),g=d||0,I=M(r,e.width,g),m=r?.useStretch||e.width===-5,a={};o&&s?(a.maxHeight=o,a.objectFit="contain",a.width="100%"):(a.width=I??"100%",a.maxWidth="100%");const w=c=>{const n=c.currentTarget.src;H.error(`Client Error: Image source error - ${n}`),t.sendClientErrorToHost("Image","Image source failed to load","onerror triggered",n)};return x(p,{width:g,height:o,useContainerWidth:s,topCentered:!0,children:[i(T,{target:p,isFullScreen:s,onExpand:f,onCollapse:h,disableFullscreenMode:l}),i(F,{className:"stImage","data-testid":"stImage",shouldStretch:m,children:e.imgs.map((c,n)=>i(G,{itemKey:n.toString(),image:c,imgStyle:a,buildMediaURL:S=>t.buildMediaURL(S),handleImageError:w,shouldStretch:m},n))})]})}const U=y(O),D=L.memo(U);export{D as default};
