Current File : /home/resuelf/www/wp-content/plugins/gutenberg/build/block-library/blocks/image/view.min.js
!function(){"use strict";var t=window.wp.interactivity;const e=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];let n,i=!1,o=0;function l(t){!i&&Date.now()-o>450&&window.scrollTo(t.scrollLeftReset,t.scrollTopReset)}const{state:a,actions:d,callbacks:r}=(0,t.store)("core/image",{state:{windowWidth:window.innerWidth,windowHeight:window.innerHeight,get roleAttribute(){return(0,t.getContext)().lightboxEnabled?"dialog":null},get ariaModal(){return(0,t.getContext)().lightboxEnabled?"true":null},get dialogLabel(){const e=(0,t.getContext)();return e.lightboxEnabled?e.dialogLabel:null},get lightboxObjectFit(){if((0,t.getContext)().initialized)return"cover"},get enlargedImgSrc(){const e=(0,t.getContext)();return e.initialized?e.imageUploadedSrc:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="}},actions:{showLightbox(e){const i=(0,t.getContext)();i.imageLoaded&&(i.initialized=!0,i.lastFocusedElement=window.document.activeElement,i.scrollDelta=0,i.pointerType=e.pointerType,i.lightboxEnabled=!0,s(i,i.imageRef),i.scrollTopReset=window.pageYOffset||document.documentElement.scrollTop,i.scrollLeftReset=window.pageXOffset||document.documentElement.scrollLeft,n=l.bind(null,i),window.addEventListener("scroll",n,!1))},hideLightbox(){const e=(0,t.getContext)();e.hideAnimationEnabled=!0,e.lightboxEnabled&&(setTimeout((function(){window.removeEventListener("scroll",n),e.lightboxTriggerRef.focus({preventScroll:!0})}),450),e.lightboxEnabled=!1)},handleKeydown(e){const n=(0,t.getContext)();n.lightboxEnabled&&("Tab"!==e.key&&9!==e.keyCode||(e.shiftKey&&window.document.activeElement===n.firstFocusableElement?(e.preventDefault(),n.lastFocusableElement.focus()):e.shiftKey||window.document.activeElement!==n.lastFocusableElement||(e.preventDefault(),n.firstFocusableElement.focus())),"Escape"!==e.key&&27!==e.keyCode||d.hideLightbox(e))},handleLoad(){const e=(0,t.getContext)(),{ref:n}=(0,t.getElement)();e.imageLoaded=!0,e.imageCurrentSrc=n.currentSrc,r.setButtonStyles()},handleTouchStart(){i=!0},handleTouchMove(e){(0,t.getContext)().lightboxEnabled&&e.preventDefault()},handleTouchEnd(){o=Date.now(),i=!1}},callbacks:{initOriginImage(){const e=(0,t.getContext)(),{ref:n}=(0,t.getElement)();e.imageRef=n,n.complete&&(e.imageLoaded=!0,e.imageCurrentSrc=n.currentSrc)},initTriggerButton(){const e=(0,t.getContext)(),{ref:n}=(0,t.getElement)();e.lightboxTriggerRef=n},initLightbox(){const n=(0,t.getContext)(),{ref:i}=(0,t.getElement)();if(n.lightboxEnabled){const t=i.querySelectorAll(e);n.firstFocusableElement=t[0],n.lastFocusableElement=t[t.length-1],i.focus()}},setButtonStyles(){const{ref:e}=(0,t.getElement)(),{naturalWidth:n,naturalHeight:i,offsetWidth:o,offsetHeight:l}=e;if(0===n||0===i)return;const a=e.parentElement,d=e.parentElement.clientWidth;let r=e.parentElement.clientHeight;const s=a.querySelector("figcaption");if(s){const t=window.getComputedStyle(s);["absolute","fixed"].includes(t.position)||(r=r-s.offsetHeight-parseFloat(t.marginTop)-parseFloat(t.marginBottom))}const g=r-l,c=d-o,h=(0,t.getContext)();if("contain"===h.scaleAttr){const t=n/i;if(t>=o/l){const e=o/t;h.imageButtonTop=(l-e)/2+g+16,h.imageButtonRight=c+16}else{const e=l*t;h.imageButtonTop=g+16,h.imageButtonRight=(o-e)/2+c+16}}else h.imageButtonTop=g+16,h.imageButtonRight=c+16},setStylesOnResize(){const e=(0,t.getContext)(),{ref:n}=(0,t.getElement)();e.lightboxEnabled&&(a.windowWidth||a.windowHeight)&&s(e,n)}}});function s(t,e){let{naturalWidth:n,naturalHeight:i,offsetWidth:o,offsetHeight:l}=e,{x:a,y:d}=e.getBoundingClientRect();const r=n/i;let s=o/l;if("contain"===t.scaleAttr)if(r>s){const t=o/r;d+=(l-t)/2,l=t}else{const t=l*r;a+=(o-t)/2,o=t}s=o/l;let g=parseFloat("none"!==t.targetWidth?t.targetWidth:n),c=parseFloat("none"!==t.targetHeight?t.targetHeight:i),h=g/c,u=g,w=c,m=g,b=c;if(r.toFixed(2)!==h.toFixed(2)){if(r>h){const t=g/r;c-t>g?(c=t,g=t*r):c=g/r}else{const t=c*r;g-t>c?(g=t,c=t/r):g=c*r}m=g,b=c,h=g/c,s>h?(u=g,w=u/s):(w=c,u=w*s)}(o>m||l>b)&&(m=o,b=l);let f=0;window.innerWidth>480?f=80:window.innerWidth>1920&&(f=160);const x=Math.min(window.innerWidth-f,m),p=Math.min(window.innerHeight-80,b);s>x/p?(m=x,b=m/s):(b=p,m=b*s);const E=o/m,C=g*(m/u),y=c*(b/w);let A=document.getElementById("wp-lightbox-styles");A||(A=document.createElement("style"),A.id="wp-lightbox-styles",document.head.appendChild(A)),A.innerHTML=`\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${d}px;\n\t\t\t--wp--lightbox-initial-left-position: ${a}px;\n\t\t\t--wp--lightbox-container-width: ${m+1}px;\n\t\t\t--wp--lightbox-container-height: ${b+1}px;\n\t\t\t--wp--lightbox-image-width: ${C}px;\n\t\t\t--wp--lightbox-image-height: ${y}px;\n\t\t\t--wp--lightbox-scale: ${E};\n\t\t\t--wp--lightbox-scrollbar-width: ${window.innerWidth-document.documentElement.clientWidth}px;\n\t\t}\n\t`}window.addEventListener("resize",function(t,e=50){let n;return()=>{clearTimeout(n),n=setTimeout((()=>{n=null,t()}),e)}}((()=>{a.windowWidth=window.innerWidth,a.windowHeight=window.innerHeight})))}();
//# sourceMappingURL=view.min.js.map