xr+n?(t-=a,r.style.transform=`${l} scale(${t})`):Xi(r))),tr=s}},Fl=(e,r,i,a,n)=>{const t=lr(e);if(!t)return;const l=t.style.transform,g=Yi(l),p=nr()/8,s=nr()-p,d=Xr(t)?Yr()/4:Yr()/8,c=Yr()-d,f=80;t.style.transition="unset",(!w.clientX||!w.clientY)&&(w.clientX=e.clientX,w.clientY=e.clientY);const m=w.translateX+(e.clientX-w.clientX),y=w.translateY+(e.clientY-w.clientY),T=y-w.translateY>=0,S=m-w.translateX>=0,z=()=>{const k=w.imageRect.lefts&&!S,x=w.imageRect.topc&&!T;return k&&x},b=()=>{w.imageRect.top=w.imageRect.top+(y-w.translateY),w.imageRect.bottom=w.imageRect.bottom+(y-w.translateY),w.imageRect.left=w.imageRect.left+(m-w.translateX),w.imageRect.right=w.imageRect.right+(m-w.translateX),w.translateX=m,w.translateY=y,w.clientX=e.clientX,w.clientY=e.clientY},v=Math.abs(m)-Math.abs(w.translateX)>f;if(z())b(),t.style.transform=`translate3d(${m}px, ${y}px, 0px) scale(${g})`;else if(v){const k=n==="ltr"&&m<0||n==="rtl"&&m>0;!k&&i[a-1]?r(-1):k&&i[a+1]&&r(1)}},Ul=e=>{const r=lr(e);r&&(r.style.transition=w.imgOriginalTransition),Dl(e),w.clientX=null,w.clientY=null,N.length<2&&(tr=-1)},Vl=(e,r,i)=>{const a=window.getComputedStyle(r);w.durationStart=Date.now(),w.screenX=e.clientX,w.originalMarginLeft=+a[i].slice(0,-2),w.currentMarginLeft=+a[i].slice(0,-2),w.originalTransition=a.transition,r.style.transition="unset"},Gl=(e,r,i,a)=>{const t=e.clientX-w.screenX;w.currentMarginLeft=w.originalMarginLeft+t*(a==="ltr"?1:-1),r.style[i]=w.currentMarginLeft+"px",e.preventDefault()},Yl=(e,r,i,a,n)=>{const t=w.originalMarginLeft-w.currentMarginLeft,l=Date.now()-w.durationStart;Math.abs(t/nr())>.4||l<=300&&Math.abs(t)>5?i(t>0?1:-1):r.style[a]=-nr()*n+"px"};let Zr=[];const Qr=(e,r,i,a=void 0)=>{e.addEventListener(r,i,a),Zr.push([e,r,i,a])},Kl=()=>{Zr.forEach(e=>{const[r,i,a,n]=e;r.removeEventListener(i,a,n)}),Zr=[]};let X=0,Se="",sr,Or,xe;const dr=()=>window.innerWidth,j="wp-gallery-fullscreen-slider",Xl=(e,r,i,a=[],n="")=>{const t=a.map(()=>`
+
+
+
+
${Q(e,"gallery-loading-still")}
+
+
+
${Q(e,"gallery-loading-error")}
+
${Q(e,"gallery-loading-error-refresh")}
+
+
+ `.trim()).join("");return a.some((l,g)=>l.thumb===n?(X=g,!0):!1),Se=r,sr=e,Or=a,xe=i,`
+
+ `.trim()},Jl=e=>{const r=e.author?e.author:Q(sr,"gallery-unknown-author"),i=e.filePage;return`
+
+ `.trim()},Ji=(e,r=!1)=>{const i=e.querySelector(`.${j}-item-caption`),a=e.querySelector(`.${j}-item-caption-expand-cue`),n=e.querySelector(".expanded");a&&n||r&&a?(a.classList.remove("expanded"),i.style.maxHeight="95px"):a&&(a.classList.add("expanded"),i.style.maxHeight="241px")},Zi=(e,r=!1)=>{const i=e.querySelector("img"),a=e.querySelector(`.${j}-item-loading`),n=e.querySelector(`.${j}-item-loading-error`),t=e.querySelector(`.${j}-item-caption`);function l(){i.naturalWidth>0&&i.naturalHeight>0?t.style.visibility="visible":requestAnimationFrame(l)}if(l(),r&&(xe.querySelector(`.${j}`).querySelectorAll(`.${j}-item`).forEach(s=>{const d=s.querySelector("img"),c=s.querySelector(`.${j}-item-caption`),f=s.querySelector(`.${j}-item-attribution`);d&&s.removeChild(d),c&&s.removeChild(c),f&&s.removeChild(f)}),Te(0,!0),a.style.visibility="visible",n.style.visibility="hidden"),i.complete)a.style.visibility="hidden",n.style.visibility="hidden",i.style.visibility="visible";else{const g=e.querySelector(`.${j}-item-loading-text`),p=setTimeout(()=>{g.style.visibility="visible"},5e3);i.addEventListener("load",()=>{a.style.visibility="hidden",n.style.visibility="hidden",g.style.visibility="hidden",clearTimeout(p)}),i.addEventListener("error",()=>{const s=e.querySelector(`.${j}-item-loading-error-refresh`);if(a.style.visibility="hidden",i.style.visibility="hidden",!Ri()){const d=e.querySelector(`.${j}-item-loading-error-text`);d.innerText=Q(sr,"gallery-loading-error-offline"),n.classList.add("offline")}n.style.visibility="visible",clearTimeout(p),s.addEventListener("click",()=>{Zi(e,!0)})})}t.addEventListener("click",()=>{Ji(e)})},ei=(e,r=!1)=>{const n=xe.querySelector(`.${j}`).querySelectorAll(`.${j}-item`)[e];n&&Wl(sr,Or[e].title,t=>{const l=n.querySelector("img"),g=n.querySelector(`.${j}-item-attribution`);if(!l){const s=t.description?t.description:Or[e].caption?Or[e].caption:"",c=`
+ ${(dr()<400&&s.length>128?!0:dr()>400&&s.length>142)?`
`:""}
+
${s}
+
`;n.insertAdjacentHTML("beforeend",`${c}
`),Zi(n)}g||n.insertAdjacentHTML("beforeend",Jl(t))})},Te=(e=1,r=!1)=>{const i=xe.querySelector(`.${j}`),a=i.querySelectorAll(`.${j}-item`),n=i.querySelector(".next"),t=i.querySelector(".previous"),l=X+e,g=a[l],p=a[X].querySelector("img");g&&(Ji(a[X],!0),X+=e,n.style.visibility=X===a.length-1?"hidden":"visible",t.style.visibility=X===0?"hidden":"visible",Xi(p),ei(X,r),ei(X+1,r),ei(X-1,r)),i.style[Se==="ltr"?"marginLeft":"marginRight"]=-dr()*X+"px";const s=xe.querySelector(".wp-gallery-fullscreen-counter");s.textContent=X+1+"/"+a.length},ri=()=>{Te(-1)},Zl=()=>{const e=xe.querySelector(`.${j}`),r=Se==="ltr"?"marginLeft":"marginRight",i=e.querySelectorAll(`.${j}-item`);e.addEventListener("pointerdown",a=>{Kr(a,j)||(Hl(a),Jr()===1&&!Tr()&&Vl(a,e,r))}),e.addEventListener("pointermove",a=>{Kr(a,j)||(Jr()>1?Bl(a):Tr()?Fl(a,Te,i,X,Se):Gl(a,e,r,Se))}),e.addEventListener("pointerout",a=>{Kr(a,j)||(e.style.transition=w.originalTransition,Jr()===1&&!Tr()&&Yl(a,e,Te,r,X),Ul(a))})},Ql=()=>{xe.querySelector(".wp-gallery-fullscreen").classList.toggle("wp-gallery-fullscreen-focus-mode")},es=()=>{const e=xe.querySelector(`.${j}`),r=e.querySelectorAll(`.${j}-item`),i=e.querySelector(".next"),a=e.querySelector(".previous");let n=!1;Te(0),Zl(),e.addEventListener("click",g=>{(g.target.className===`${j}-item`||g.target.tagName==="IMG")&&(n?(clearTimeout(n),n=null,Il(g)):n=setTimeout(()=>{n=null,Ql()},300))});const t=function(g){g.style.transition="unset",g.style.marginLeft=-X*dr()+"px"};let l;Qr(window,"resize",()=>{const g=document.querySelector("."+j);t(g),clearTimeout(l),l=setTimeout(()=>{g.style.removeProperty("transition")},100)}),r.length===1?(a.style.visibility="hidden",i.style.visibility="hidden"):(i.addEventListener("click",()=>{Te()}),a.addEventListener("click",()=>{ri()}),Qr(window,"keydown",({key:g})=>{switch(g){case"ArrowRight":case"Right":Se==="ltr"?Te():ri();break;case"ArrowLeft":case"Left":Se==="ltr"?ri():Te();break}}))},Oe="wp-gallery-fullscreen",rs=(e,r)=>`
+
+ `.trim(),Qi=e=>{const r=e.querySelector(`.${Oe}`);e.removeChild(r),Kl()},ea=(e,r,i,a,n=document.body)=>{if(n.querySelector(`.${Oe}`))return;n.insertAdjacentHTML("beforeend",rs(i,a)),n.querySelector(`.${Oe}-main`).insertAdjacentHTML("beforeend",Xl(i,a,n,e,r)),n.querySelector(`.${Oe}-close`).addEventListener("click",()=>{Qi(n)}),Qr(window,"keydown",({key:l})=>{(l==="Escape"||l==="Esc")&&Qi(n)}),es()},is=e=>{let r=[],i=[];const a=(d,c)=>{const f=setTimeout(d,c);return i.push(f),f},n=()=>{i.forEach(d=>{clearTimeout(d)}),i=[]},t=(d,c,f,m=void 0)=>{d.addEventListener(c,f,m),r.push([d,c,f,m])},l=()=>{r.forEach(d=>{const[c,f,m,y]=d;c.removeEventListener(f,m,y)}),r=[]},g=d=>{const c=d.toElement||d.relatedTarget||d.target,f=e.element.currentTargetElement;if(c!==f&&!e.element.contains(c)){const m=a(e.hide,300),y=()=>{clearTimeout(m)};t(e.element,"mouseenter",y)}};return{onHide:()=>{e.lang=null,e.title=null,e.loading=!1;const d=e.element.querySelector(".wikipediapreview-body");d.style.transition="auto",l(),n()},onShow:d=>{if(d.component={body:d.querySelector(".wikipediapreview-body"),wikipediapreview:d.querySelector(".wikipediapreview"),wikipediapreviewHeaderImage:d.querySelector(".wikipediapreview-header-image"),wikipediapreviewGalleryImages:d.querySelectorAll(".wikipediapreview-gallery-image"),closeBtn:d.querySelector(".wikipediapreview-header-closebtn"),content:d.querySelector(".wikipediapreview-body > p"),scrollCue:d.querySelector(".wikipediapreview-scroll-cue")},d.component.wikipediapreviewGalleryImages&&d.component.wikipediapreviewGalleryImages.forEach(c=>{t(c,"click",f=>{const m=f.target.style.backgroundImage.slice(4,-1).replace(/"/g,"");ea(e.media,m,e.lang,e.dir)})}),d.component.wikipediapreviewHeaderImage&&t(d.component.wikipediapreviewHeaderImage,"click",()=>{ea(e.media,e.media[0].thumb,e.lang,e.dir)}),d.component.closeBtn&&t(d.component.closeBtn,"click",e.hide),se){const c=document.querySelector(".wp-dark-screen");t(c,"pointerup",e.hide,!0)}else t(d,"mouseleave",g),t(d.currentTargetElement,"mouseleave",g);d.component.scrollCue&&(bn(d.component.body)?t(d.component.body,"scroll",c=>{c.target.scrollTop>0&&d.component.scrollCue.remove()}):d.component.scrollCue.remove())}}},as=["top","right","bottom","left"],ra=["start","end"],ia=as.reduce((e,r)=>e.concat(r,r+"-"+ra[0],r+"-"+ra[1]),[]),ze=Math.min,ke=Math.max,zr=Math.round,$e=e=>({x:e,y:e}),ns={left:"right",right:"left",bottom:"top",top:"bottom"},ts={start:"end",end:"start"};function ii(e,r,i){return ke(e,ze(r,i))}function Ne(e,r){return typeof e=="function"?e(r):e}function Ae(e){return e.split("-")[0]}function ve(e){return e.split("-")[1]}function aa(e){return e==="x"?"y":"x"}function ai(e){return e==="y"?"height":"width"}function gr(e){return["top","bottom"].includes(Ae(e))?"y":"x"}function ni(e){return aa(gr(e))}function os(e,r,i){i===void 0&&(i=!1);const a=ve(e),n=ni(e),t=ai(n);let l=n==="x"?a===(i?"end":"start")?"right":"left":a==="start"?"bottom":"top";return r.reference[t]>r.floating[t]&&(l=na(l)),[l,na(l)]}function ls(e){return e.replace(/start|end/g,r=>ts[r])}function na(e){return e.replace(/left|right|bottom|top/g,r=>ns[r])}function ss(e){return I({top:0,right:0,bottom:0,left:0},e)}function ti(e){return typeof e!="number"?ss(e):{top:e,right:e,bottom:e,left:e}}function De(e){const{x:r,y:i,width:a,height:n}=e;return{width:a,height:n,top:i,left:r,right:r+a,bottom:i+n,x:r,y:i}}function ta(e,r,i){let{reference:a,floating:n}=e;const t=gr(r),l=ni(r),g=ai(l),p=Ae(r),s=t==="y",d=a.x+a.width/2-n.width/2,c=a.y+a.height/2-n.height/2,f=a[g]/2-n[g]/2;let m;switch(p){case"top":m={x:d,y:a.y-n.height};break;case"bottom":m={x:d,y:a.y+a.height};break;case"right":m={x:a.x+a.width,y:c};break;case"left":m={x:a.x-n.width,y:c};break;default:m={x:a.x,y:a.y}}switch(ve(r)){case"start":m[l]-=f*(i&&s?-1:1);break;case"end":m[l]+=f*(i&&s?-1:1);break}return m}const ds=(e,r,i)=>we(this,null,function*(){const{placement:a="bottom",strategy:n="absolute",middleware:t=[],platform:l}=i,g=t.filter(Boolean),p=yield l.isRTL==null?void 0:l.isRTL(r);let s=yield l.getElementRects({reference:e,floating:r,strategy:n}),{x:d,y:c}=ta(s,a,p),f=a,m={},y=0;for(let T=0;T({name:"arrow",options:e,fn(i){return we(this,null,function*(){const{x:a,y:n,placement:t,rects:l,platform:g,elements:p,middlewareData:s}=i,{element:d,padding:c=0}=Ne(e,i)||{};if(d==null)return{};const f=ti(c),m={x:a,y:n},y=ni(t),T=ai(y),S=yield g.getDimensions(d),z=y==="y",b=z?"top":"left",v=z?"bottom":"right",k=z?"clientHeight":"clientWidth",x=l.reference[T]+l.reference[y]-m[y]-l.floating[T],W=m[y]-l.reference[y],A=yield g.getOffsetParent==null?void 0:g.getOffsetParent(d);let D=A?A[k]:0;(!D||!(yield g.isElement==null?void 0:g.isElement(A)))&&(D=p.floating[k]||l.floating[T]);const ce=x/2-W/2,B=D/2-S[T]/2-1,$=ze(f[b],B),E=ze(f[v],B),R=$,oe=D-S[T]-E,re=D/2-S[T]/2+ce,_e=ii(R,re,oe),Pe=!s.arrow&&ve(t)!=null&&re!==_e&&l.reference[T]/2-(reve(n)===e),...i.filter(n=>ve(n)!==e)]:i.filter(n=>Ae(n)===n)).filter(n=>e?ve(n)===e||(r?ls(n)!==n:!1):!0)}const us=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,fn(i){return we(this,null,function*(){var a,n,t;const{rects:l,middlewareData:g,placement:p,platform:s,elements:d}=i,$=Ne(e,i),{crossAxis:c=!1,alignment:f,allowedPlacements:m=ia,autoAlignment:y=!0}=$,T=xi($,["crossAxis","alignment","allowedPlacements","autoAlignment"]),S=f!==void 0||m===ia?cs(f||null,y,m):m,z=yield oa(i,T),b=((a=g.autoPlacement)==null?void 0:a.index)||0,v=S[b];if(v==null)return{};const k=os(v,l,yield s.isRTL==null?void 0:s.isRTL(d.floating));if(p!==v)return{reset:{placement:S[0]}};const x=[z[Ae(v)],z[k[0]],z[k[1]]],W=[...((n=g.autoPlacement)==null?void 0:n.overflows)||[],{placement:v,overflows:x}],A=S[b+1];if(A)return{data:{index:b+1,overflows:W},reset:{placement:A}};const D=W.map(E=>{const R=ve(E.placement);return[E.placement,R&&c?E.overflows.slice(0,2).reduce((oe,re)=>oe+re,0):E.overflows[0],E.overflows]}).sort((E,R)=>E[1]-R[1]),B=((t=D.filter(E=>E[2].slice(0,ve(E[0])?2:3).every(R=>R<=0))[0])==null?void 0:t[0])||D[0][0];return B!==p?{data:{index:b+1,overflows:W},reset:{placement:B}}:{}})}}};function la(e){const r=ze(...e.map(t=>t.left)),i=ze(...e.map(t=>t.top)),a=ke(...e.map(t=>t.right)),n=ke(...e.map(t=>t.bottom));return{x:r,y:i,width:a-r,height:n-i}}function ps(e){const r=e.slice().sort((n,t)=>n.y-t.y),i=[];let a=null;for(let n=0;na.height/2?i.push([t]):i[i.length-1].push(t),a=t}return i.map(n=>De(la(n)))}const ms=function(e){return e===void 0&&(e={}),{name:"inline",options:e,fn(i){return we(this,null,function*(){const{placement:a,elements:n,rects:t,platform:l,strategy:g}=i,{padding:p=2,x:s,y:d}=Ne(e,i),c=Array.from((yield l.getClientRects==null?void 0:l.getClientRects(n.reference))||[]),f=ps(c),m=De(la(c)),y=ti(p);function T(){if(f.length===2&&f[0].left>f[1].right&&s!=null&&d!=null)return f.find(z=>s>z.left-y.left&&sz.top-y.top&&d=2){if(gr(a)==="y"){const $=f[0],E=f[f.length-1],R=Ae(a)==="top",oe=$.top,re=E.bottom,_e=R?$.left:E.left,Pe=R?$.right:E.right,Le=Pe-_e,mi=re-oe;return{top:oe,bottom:re,left:_e,right:Pe,width:Le,height:mi,x:_e,y:oe}}const z=Ae(a)==="left",b=ke(...f.map($=>$.right)),v=ze(...f.map($=>$.left)),k=f.filter($=>z?$.left===v:$.right===b),x=k[0].top,W=k[k.length-1].bottom,A=v,D=b,ce=D-A,B=W-x;return{top:x,bottom:W,left:A,right:D,width:ce,height:B,x:A,y:x}}return m}const S=yield l.getElementRects({reference:{getBoundingClientRect:T},floating:n.floating,strategy:g});return t.reference.x!==S.reference.x||t.reference.y!==S.reference.y||t.reference.width!==S.reference.width||t.reference.height!==S.reference.height?{reset:{rects:S}}:{}})}}};function fs(e,r){return we(this,null,function*(){const{placement:i,platform:a,elements:n}=e,t=yield a.isRTL==null?void 0:a.isRTL(n.floating),l=Ae(i),g=ve(i),p=gr(i)==="y",s=["left","top"].includes(l)?-1:1,d=t&&p?-1:1,c=Ne(r,e);let{mainAxis:f,crossAxis:m,alignmentAxis:y}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}:I({mainAxis:0,crossAxis:0,alignmentAxis:null},c);return g&&typeof y=="number"&&(m=g==="end"?y*-1:y),p?{x:m*d,y:f*s}:{x:f*s,y:m*d}})}const ys=function(e){return e===void 0&&(e=0),{name:"offset",options:e,fn(i){return we(this,null,function*(){var a,n;const{x:t,y:l,placement:g,middlewareData:p}=i,s=yield fs(i,e);return g===((a=p.offset)==null?void 0:a.placement)&&(n=p.arrow)!=null&&n.alignmentOffset?{}:{x:t+s.x,y:l+s.y,data:ye(I({},s),{placement:g})}})}}},ws=function(e){return e===void 0&&(e={}),{name:"shift",options:e,fn(i){return we(this,null,function*(){const{x:a,y:n,placement:t}=i,z=Ne(e,i),{mainAxis:l=!0,crossAxis:g=!1,limiter:p={fn:b=>{let{x:v,y:k}=b;return{x:v,y:k}}}}=z,s=xi(z,["mainAxis","crossAxis","limiter"]),d={x:a,y:n},c=yield oa(i,s),f=gr(Ae(t)),m=aa(f);let y=d[m],T=d[f];if(l){const b=m==="y"?"top":"left",v=m==="y"?"bottom":"right",k=y+c[b],x=y-c[v];y=ii(k,y,x)}if(g){const b=f==="y"?"top":"left",v=f==="y"?"bottom":"right",k=T+c[b],x=T-c[v];T=ii(k,T,x)}const S=p.fn(ye(I({},i),{[m]:y,[f]:T}));return ye(I({},S),{data:{x:S.x-a,y:S.y-n}})})}}};function Ie(e){return sa(e)?(e.nodeName||"").toLowerCase():"#document"}function ne(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function Ee(e){var r;return(r=(sa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function sa(e){return e instanceof Node||e instanceof ne(e).Node}function ue(e){return e instanceof Element||e instanceof ne(e).Element}function pe(e){return e instanceof HTMLElement||e instanceof ne(e).HTMLElement}function da(e){return typeof ShadowRoot=="undefined"?!1:e instanceof ShadowRoot||e instanceof ne(e).ShadowRoot}function cr(e){const{overflow:r,overflowX:i,overflowY:a,display:n}=de(e);return/auto|scroll|overlay|hidden|clip/.test(r+a+i)&&!["inline","contents"].includes(n)}function hs(e){return["table","td","th"].includes(Ie(e))}function oi(e){const r=li(),i=de(e);return i.transform!=="none"||i.perspective!=="none"||(i.containerType?i.containerType!=="normal":!1)||!r&&(i.backdropFilter?i.backdropFilter!=="none":!1)||!r&&(i.filter?i.filter!=="none":!1)||["transform","perspective","filter"].some(a=>(i.willChange||"").includes(a))||["paint","layout","strict","content"].some(a=>(i.contain||"").includes(a))}function ks(e){let r=Me(e);for(;pe(r)&&!He(r);){if(oi(r))return r;r=Me(r)}return null}function li(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function He(e){return["html","body","#document"].includes(Ie(e))}function de(e){return ne(e).getComputedStyle(e)}function $r(e){return ue(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.pageXOffset,scrollTop:e.pageYOffset}}function Me(e){if(Ie(e)==="html")return e;const r=e.assignedSlot||e.parentNode||da(e)&&e.host||Ee(e);return da(r)?r.host:r}function ga(e){const r=Me(e);return He(r)?e.ownerDocument?e.ownerDocument.body:e.body:pe(r)&&cr(r)?r:ga(r)}function si(e,r,i){var a;r===void 0&&(r=[]),i===void 0&&(i=!0);const n=ga(e),t=n===((a=e.ownerDocument)==null?void 0:a.body),l=ne(n);return t?r.concat(l,l.visualViewport||[],cr(n)?n:[],l.frameElement&&i?si(l.frameElement):[]):r.concat(n,si(n,[],i))}function ca(e){const r=de(e);let i=parseFloat(r.width)||0,a=parseFloat(r.height)||0;const n=pe(e),t=n?e.offsetWidth:i,l=n?e.offsetHeight:a,g=zr(i)!==t||zr(a)!==l;return g&&(i=t,a=l),{width:i,height:a,$:g}}function ua(e){return ue(e)?e:e.contextElement}function Be(e){const r=ua(e);if(!pe(r))return $e(1);const i=r.getBoundingClientRect(),{width:a,height:n,$:t}=ca(r);let l=(t?zr(i.width):i.width)/a,g=(t?zr(i.height):i.height)/n;return(!l||!Number.isFinite(l))&&(l=1),(!g||!Number.isFinite(g))&&(g=1),{x:l,y:g}}const vs=$e(0);function pa(e){const r=ne(e);return!li()||!r.visualViewport?vs:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function _s(e,r,i){return r===void 0&&(r=!1),!i||r&&i!==ne(e)?!1:r}function ur(e,r,i,a){r===void 0&&(r=!1),i===void 0&&(i=!1);const n=e.getBoundingClientRect(),t=ua(e);let l=$e(1);r&&(a?ue(a)&&(l=Be(a)):l=Be(e));const g=_s(t,i,a)?pa(t):$e(0);let p=(n.left+g.x)/l.x,s=(n.top+g.y)/l.y,d=n.width/l.x,c=n.height/l.y;if(t){const f=ne(t),m=a&&ue(a)?ne(a):a;let y=f,T=y.frameElement;for(;T&&a&&m!==y;){const S=Be(T),z=T.getBoundingClientRect(),b=de(T),v=z.left+(T.clientLeft+parseFloat(b.paddingLeft))*S.x,k=z.top+(T.clientTop+parseFloat(b.paddingTop))*S.y;p*=S.x,s*=S.y,d*=S.x,c*=S.y,p+=v,s+=k,y=ne(T),T=y.frameElement}}return De({width:d,height:c,x:p,y:s})}const bs=[":popover-open",":modal"];function di(e){return bs.some(r=>{try{return e.matches(r)}catch(i){return!1}})}function js(e){let{elements:r,rect:i,offsetParent:a,strategy:n}=e;const t=n==="fixed",l=Ee(a),g=r?di(r.floating):!1;if(a===l||g&&t)return i;let p={scrollLeft:0,scrollTop:0},s=$e(1);const d=$e(0),c=pe(a);if((c||!c&&!t)&&((Ie(a)!=="body"||cr(l))&&(p=$r(a)),pe(a))){const f=ur(a);s=Be(a),d.x=f.x+a.clientLeft,d.y=f.y+a.clientTop}return{width:i.width*s.x,height:i.height*s.y,x:i.x*s.x-p.scrollLeft*s.x+d.x,y:i.y*s.y-p.scrollTop*s.y+d.y}}function Ss(e){return Array.from(e.getClientRects())}function ma(e){return ur(Ee(e)).left+$r(e).scrollLeft}function xs(e){const r=Ee(e),i=$r(e),a=e.ownerDocument.body,n=ke(r.scrollWidth,r.clientWidth,a.scrollWidth,a.clientWidth),t=ke(r.scrollHeight,r.clientHeight,a.scrollHeight,a.clientHeight);let l=-i.scrollLeft+ma(e);const g=-i.scrollTop;return de(a).direction==="rtl"&&(l+=ke(r.clientWidth,a.clientWidth)-n),{width:n,height:t,x:l,y:g}}function Ts(e,r){const i=ne(e),a=Ee(e),n=i.visualViewport;let t=a.clientWidth,l=a.clientHeight,g=0,p=0;if(n){t=n.width,l=n.height;const s=li();(!s||s&&r==="fixed")&&(g=n.offsetLeft,p=n.offsetTop)}return{width:t,height:l,x:g,y:p}}function Os(e,r){const i=ur(e,!0,r==="fixed"),a=i.top+e.clientTop,n=i.left+e.clientLeft,t=pe(e)?Be(e):$e(1),l=e.clientWidth*t.x,g=e.clientHeight*t.y,p=n*t.x,s=a*t.y;return{width:l,height:g,x:p,y:s}}function fa(e,r,i){let a;if(r==="viewport")a=Ts(e,i);else if(r==="document")a=xs(Ee(e));else if(ue(r))a=Os(r,i);else{const n=pa(e);a=ye(I({},r),{x:r.x-n.x,y:r.y-n.y})}return De(a)}function ya(e,r){const i=Me(e);return i===r||!ue(i)||He(i)?!1:de(i).position==="fixed"||ya(i,r)}function zs(e,r){const i=r.get(e);if(i)return i;let a=si(e,[],!1).filter(g=>ue(g)&&Ie(g)!=="body"),n=null;const t=de(e).position==="fixed";let l=t?Me(e):e;for(;ue(l)&&!He(l);){const g=de(l),p=oi(l);!p&&g.position==="fixed"&&(n=null),(t?!p&&!n:!p&&g.position==="static"&&!!n&&["absolute","fixed"].includes(n.position)||cr(l)&&!p&&ya(e,l))?a=a.filter(d=>d!==l):n=g,l=Me(l)}return r.set(e,a),a}function $s(e){let{element:r,boundary:i,rootBoundary:a,strategy:n}=e;const l=[...i==="clippingAncestors"?di(r)?[]:zs(r,this._c):[].concat(i),a],g=l[0],p=l.reduce((s,d)=>{const c=fa(r,d,n);return s.top=ke(c.top,s.top),s.right=ze(c.right,s.right),s.bottom=ze(c.bottom,s.bottom),s.left=ke(c.left,s.left),s},fa(r,g,n));return{width:p.right-p.left,height:p.bottom-p.top,x:p.left,y:p.top}}function As(e){const{width:r,height:i}=ca(e);return{width:r,height:i}}function Es(e,r,i){const a=pe(r),n=Ee(r),t=i==="fixed",l=ur(e,!0,t,r);let g={scrollLeft:0,scrollTop:0};const p=$e(0);if(a||!a&&!t)if((Ie(r)!=="body"||cr(n))&&(g=$r(r)),a){const c=ur(r,!0,t,r);p.x=c.x+r.clientLeft,p.y=c.y+r.clientTop}else n&&(p.x=ma(n));const s=l.left+g.scrollLeft-p.x,d=l.top+g.scrollTop-p.y;return{x:s,y:d,width:l.width,height:l.height}}function gi(e){return de(e).position==="static"}function wa(e,r){return!pe(e)||de(e).position==="fixed"?null:r?r(e):e.offsetParent}function ha(e,r){const i=ne(e);if(di(e))return i;if(!pe(e)){let n=Me(e);for(;n&&!He(n);){if(ue(n)&&!gi(n))return n;n=Me(n)}return i}let a=wa(e,r);for(;a&&hs(a)&&gi(a);)a=wa(a,r);return a&&He(a)&&gi(a)&&!oi(a)?i:a||ks(e)||i}const Ms=function(e){return we(this,null,function*(){const r=this.getOffsetParent||ha,i=this.getDimensions,a=yield i(e.floating);return{reference:Es(e.reference,yield r(e.floating),e.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}})};function Ps(e){return de(e).direction==="rtl"}const Ls={convertOffsetParentRelativeRectToViewportRelativeRect:js,getDocumentElement:Ee,getClippingRect:$s,getOffsetParent:ha,getElementRects:Ms,getClientRects:Ss,getDimensions:As,getScale:Be,isElement:ue,isRTL:Ps},qs=ys,Ws=us,Rs=ws,Cs=gs,Ns=ms,Ds=(e,r,i)=>{const a=new Map,n=I({platform:Ls},i),t=ye(I({},n.platform),{_c:a});return ds(e,r,ye(I({},n),{platform:t}))};let Y,ci;const Ar=e=>e&&e+"px",Is=(e,r=window)=>{Y||(Y=r.document.createElement("div"),Y.classList.add("wp-popup"),Y.style.visibility="hidden",e.appendChild(Y),ci=r.document.createElement("div"),ci.classList.add("wp-popup-arrow"));const i={};return{show:(l,g,{x:p,y:s})=>{Y.innerHTML=l+ci.outerHTML;const d=Y.querySelector(".wp-popup-arrow");Ds(g,Y,{middleware:[Ns({x:p,y:s}),Rs(),Ws({allowedPlacements:["top","bottom"]}),qs(10),Cs({element:d})]}).then(({x:c,y:f,middlewareData:m,placement:y})=>{if(Y.style.top=Ar(f),Y.style.left=Ar(c),m.arrow&&d){const{x:T,y:S}=m.arrow;d.style.left=T!==null?Ar(T):"",d.style.top=S!==null?Ar(S):"",y==="left"?(d.style.right="-8px",d.style.transform="rotate(90deg)"):y==="right"?(d.style.left="-8px",d.style.transform="rotate(-90deg)"):y==="top"?(d.style.bottom="-8px",d.style.transform="rotate(180deg)"):y==="bottom"&&(d.style.top="-8px")}Y.currentTargetElement=g,Y.style.visibility="visible",i.onShow&&i.onShow(Y)})},hide:()=>{i.onHide&&i.onHide(Y),Y.style.visibility="hidden",Y.currentTargetElement=null},subscribe:(l={})=>{l.onShow&&(i.onShow=l.onShow),l.onHide&&(i.onHide=l.onHide)},element:Y}};let ge,ka;const Hs=e=>{if(!e.querySelector(".wp-dark-screen")){const r=e.createElement("div");r.classList.add("wp-dark-screen"),e.body.appendChild(r),ka=e.body.style.overflow,e.body.style.overflow="hidden"}},Bs=e=>{const r=e.getElementsByClassName("wp-dark-screen");e.body.removeChild(r[0]),e.body.style.overflow=ka},Fs=(e,r=window)=>{ge||(ge=r.document.createElement("div"),ge.classList.add("wp-touch-popup"),ge.style.visibility="hidden",e.appendChild(ge));const i={};return{show:l=>{ge.innerHTML=l,ge.style.visibility="visible",Hs(r.document),i.onShow&&i.onShow(ge)},hide:()=>{i.onHide&&i.onHide(ge),ge.style.visibility="hidden",Bs(r.document)},subscribe:(l={})=>{l.onShow&&(i.onShow=l.onShow),l.onHide&&(i.onHide=l.onHide)},element:ge}},Us=e=>{const r=document.createElement("div");return r.classList.add("wikipediapreview-gallery-row"),e&&e.forEach(i=>{const a=document.createElement("div");a.classList.add("wikipediapreview-gallery-image"),a.style.backgroundImage=`url(${i.thumb})`,r.appendChild(a)}),r.outerHTML},Vs=e=>e&&e.length<3?"":`${Us(e)}
`,pr=(e,r="",i=[])=>{const a=r!==""&&i.length>0&&i.length<3,n=r||i[0]&&i[0].thumb;return`
+
+`.trim()},ui=(e,r,i)=>`
+
+`.trim(),va=(e,r,i)=>``,mr=(e,r,i,a,n,t)=>{const l=t==="detect"?"":`wikipediapreview-${t}-theme`;return`
+
+ ${a}
+ ${n}
+
+ `.trim()},pi=(e,r,i,a)=>{const n=r.imgUrl,t=`
+ ${Vs(r.media)}
+
+ `.trim();return mr(e,i,r.dir,pr(e,n,r.media),t,a)},Gs=(e,r,i,a)=>{const n=`
+
+
+ `.trim();return mr(r,e,i,pr(r),n,a)},Ys=(e,r,i,a,n)=>{const t=`${Q(r,"preview-error-message")}`,l=va(r,i,e);return mr(r,e,a,pr(r),ui("error",t,l),n)},Ks=(e,r,i,a,n)=>{const t=`${Q(r,"preview-disambiguation-message",i)}`,l=va(r,i,e);return mr(r,e,a,pr(r),ui("disambiguation",t,l),n)},Xs=(e,r,i,a)=>{const n=`${Q(r,"preview-offline-message")}`,t=`${Q(r,"preview-offline-cta")}`;return mr(r,e,i,pr(r),ui("offline",n,t),a)},fr=(e,r,i)=>{const a=e&&e[r];if(a instanceof Function)try{a.apply(null,i)}catch(n){console.log("Error invoking Wikipedia Preview custom callback",n)}},Js=(e,r,i)=>{Vi(r,e,a=>{i(pi(r,a,se))})},_a=(e,r)=>{const i=[];(typeof e=="string"||e instanceof String)&&Array.prototype.forEach.call(document.querySelectorAll(e),a=>{i.push(a)}),(e instanceof Document||e instanceof Element)&&i.push(e),Array.isArray(e)&&e.forEach(a=>{a instanceof Element&&i.push(a)}),i.forEach(a=>r(a))};let ba,We;function Zs({root:e=document,selector:r="[data-wikipedia-preview]",lang:i="en",detectLinks:a=!1,popupContainer:n=document.body,events:t={},debug:l=!1,prefersColorScheme:g="detect"}){n=_n(n)||document.body;const p=i,s=se?Fs(n):Is(n),d=is(s),c={},f=[],m=[];We=g;const y=(b,v=!1)=>{b.preventDefault(),b.stopPropagation();const k=Date.now(),{currentTarget:x}=v?c:b,W=v?c.title:decodeURIComponent(x.getAttribute("data-wp-title")||x.textContent),A=v?c.lang:x.getAttribute("data-wp-lang")||p,D=v?c.pointerPosition:{x:b.clientX,y:b.clientY},ce=Ci(A);s.element.currentTargetElement===x&&!v||(ba=k,s.element.style.visibility==="visible"&&s.hide(),s.loading=!0,s.dir=ce,s.show(Gs(se,A,ce,We),x,D),Vi(A,W,B=>{if(k===ba&&s.loading){if(s.loading=!1,B.extractHtml){if(s.lang=A,s.title=W,B.type==="standard")s.show(pi(A,B,se,We),x,D),s.media=B.media,fr(t,"onShow",[W,A,"standard"]);else if(B.type==="disambiguation"){const E=B.extractHtml?pi(A,B,se,We):Ks(se,A,B.title,B.dir,We);s.show(E,x,D),fr(t,"onShow",[W,A,"disambiguation"])}}else if(Ri())s.show(Ys(se,A,W,ce,We),x,D),fr(t,"onShow",[W,A,"error"]);else{s.show(Xs(se,A,ce,We),x,D),fr(t,"onShow",[W,A,"offline"]);const E=document.querySelector(".wikipediapreview-body-action");c.lang=A,c.title=W,c.pointerPosition=D,c.target=x,E.addEventListener("click",R=>{y(R,!0)})}const $=s.element.querySelector(".wikipediapreview-footer-cta-readonwiki, .wikipediapreview-cta-readonwiki");if($&&$.addEventListener("click",()=>{fr(t,"onWikiRead",[W,A])}),x.tagName==="A"){const E=ar().split("="),R=new URL(x.href);R.searchParams.set(E[0],E[1]),x.href=R.href}}}))},T=b=>{y(b)},S=b=>{b.addEventListener("pointerenter",T)},z=b=>{let v=null;b.addEventListener("pointerdown",k=>{v=k.pointerType}),b.addEventListener("click",k=>{v==="touch"&&(k.preventDefault(),k.stopPropagation())})};_a(e,b=>{Array.prototype.forEach.call(b.querySelectorAll(r),v=>{S(v),f.push({text:v.textContent,title:v.getAttribute("data-wp-title")||v.textContent,lang:v.getAttribute("data-wp-lang")||p})})}),a&&_a(e,b=>{Array.prototype.forEach.call(b.querySelectorAll("a"),v=>{const k=yn(v.getAttribute("href"));k&&(v.setAttribute("data-wp-title",k.title),v.setAttribute("data-wp-lang",k.lang),S(v),z(v),m.push({text:v.textContent,title:k.title,lang:k.lang}))})}),s.subscribe(d),l&&(console.group("Wikipedia Preview [debug mode]"),console.group(`Searching for "${r}" inside ${e}, Total links found: ${f.length}`),f.forEach((b,v)=>{console.log(v+1,`${b.text} -> ${decodeURI(Sr(b.lang,b.title,se,!1))}`)}),console.groupEnd(),a&&(console.group(`Searching for links to Wikipedia, Total links found: ${m.length}`),m.forEach((b,v)=>{console.log(v+1,`${b.text} -> ${decodeURI(Sr(b.lang,b.title,se,!1))}`)}),console.groupEnd()),console.groupEnd())}return Hi(),{init:Zs,version:Hi,getPreviewHtml:Js,getSections:Ui}});
+//# sourceMappingURL=wikipedia-preview.umd.cjs.map