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