import{a as e,o as t,r as n,t as r}from"./i18n-CjHYiQIU.js";import{C as i,b as a,w as o,x as s}from"./index-D2kkGKae.js";var c=t(),l=e();function u({image:e,thumb:t,solved:u,total:d,revealed:f,compact:p=!1}){let{strings:m}=r(),h=f?s:o(u,d),g=i(s),_=(0,c.useRef)(null),[v,y]=(0,c.useState)(()=>!p||typeof window>`u`||!(`IntersectionObserver`in window)),b=p&&t?t:e;return(0,c.useEffect)(()=>{if(!p||v||!_.current)return;let e=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&(y(!0),e.disconnect())});return e.observe(_.current),()=>e.disconnect()},[p,v]),(0,l.jsx)(`span`,{ref:_,className:`chapter-mosaic${f?` is-complete`:``}${p?` is-compact`:``}`,"data-testid":`chapter-mosaic`,"data-open":h,role:`img`,"aria-label":n(m.resultScreen.chapterMosaicLabel,{open:h,tiles:s}),style:{backgroundImage:v?`url(${b})`:void 0,"--mosaic-columns":a},children:g.map((e,t)=>(0,l.jsx)(`span`,{className:`chapter-mosaic-tile${t<h?` is-open`:``}`,style:{gridArea:`${Math.floor(e/a)+1} / ${e%a+1}`,transitionDelay:`${Math.min(t,6)*45}ms`},"aria-hidden":`true`},e))})}export{u as t};