Current File : /home/resuelf/www/wp-content/plugins/gutenberg/build/block-library/blocks/image/view.min.js.map |
{"version":3,"file":"./build/block-library/blocks/image/view.min.js","mappings":"yBAAA,IAAI,EAA+BA,OAAW,GAAiB,cCK/D,MAAMC,EAAqB,CAC1B,UACA,aACA,gEACA,4CACA,8CACA,4CACA,SACA,SACA,QACA,oBACA,mCAgBD,IAAIC,EAQAC,GAAa,EAQbC,EAAgB,EAoBpB,SAASC,EAAcC,IAIfH,GAAcI,KAAKC,MAAQJ,EAAgB,KAGjDJ,OAAOS,SAAUH,EAAII,gBAAiBJ,EAAIK,eAE5C,CAEA,MAAM,MAAEC,EAAK,QAAEC,EAAO,UAAEC,IAAcC,EAAAA,EAAAA,OAAO,aAAc,CAC1DH,MAAO,CACNI,YAAahB,OAAOiB,WACpBC,aAAclB,OAAOmB,YACrB,iBAAIC,GAEH,OADYC,EAAAA,EAAAA,cACDC,gBAAkB,SAAW,IACzC,EACA,aAAIC,GAEH,OADYF,EAAAA,EAAAA,cACDC,gBAAkB,OAAS,IACvC,EACA,eAAIE,GACH,MAAMlB,GAAMe,EAAAA,EAAAA,cACZ,OAAOf,EAAIgB,gBAAkBhB,EAAIkB,YAAc,IAChD,EACA,qBAAIC,GAEH,IADYJ,EAAAA,EAAAA,cACHK,YACR,MAAO,OAET,EACA,kBAAIC,GACH,MAAMrB,GAAMe,EAAAA,EAAAA,cACZ,OAAOf,EAAIoB,YACRpB,EAAIsB,iBACJ,4DACJ,GAEDf,QAAS,CACRgB,YAAAA,CAAcC,GACb,MAAMxB,GAAMe,EAAAA,EAAAA,cAGLf,EAAIyB,cAGXzB,EAAIoB,aAAc,EAClBpB,EAAI0B,mBAAqBhC,OAAOiC,SAASC,cACzC5B,EAAI6B,YAAc,EAClB7B,EAAI8B,YAAcN,EAAMM,YAExB9B,EAAIgB,iBAAkB,EACtBe,EAAW/B,EAAKA,EAAIgC,UAEpBhC,EAAIK,eACHX,OAAOuC,aAAeN,SAASO,gBAAgBC,UAIhDn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ApMCI,EAAU,KACTtI,EAAMI,YAAchB,OAAOiB,WAC3BL,EAAMM,aAAelB,OAAOmB,WAAW,I","sources":["webpack://wp/external window [\"wp\",\"interactivity\"]","webpack://wp/./packages/block-library/build-module/image/@wordpress/block-library/src/image/view.js"],"sourcesContent":["var __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"interactivity\"];","/**\n * WordPress dependencies\n */\nimport { store, getContext, getElement } from '@wordpress/interactivity';\n\nconst focusableSelectors = [\n\t'a[href]',\n\t'area[href]',\n\t'input:not([disabled]):not([type=\"hidden\"]):not([aria-hidden])',\n\t'select:not([disabled]):not([aria-hidden])',\n\t'textarea:not([disabled]):not([aria-hidden])',\n\t'button:not([disabled]):not([aria-hidden])',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'[contenteditable]',\n\t'[tabindex]:not([tabindex^=\"-\"])',\n];\n\n/**\n * Stores a context-bound scroll handler.\n *\n * This callback could be defined inline inside of the store\n * object but it's created externally to avoid confusion about\n * how its logic is called. This logic is not referenced directly\n * by the directives in the markup because the scroll event we\n * need to listen to is triggered on the window; so by defining it\n * outside of the store, we signal that the behavior here is different.\n * If we find a compelling reason to move it to the store, feel free.\n *\n * @type {Function}\n */\nlet scrollCallback;\n\n/**\n * Tracks whether user is touching screen; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/**\n * Tracks the last time the screen was touched; used to\n * differentiate behavior for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\n/**\n * Lightbox page-scroll handler: prevents scrolling.\n *\n * This handler is added to prevent scrolling behaviors that\n * trigger content shift while the lightbox is open.\n *\n * It would be better to accomplish this through CSS alone, but\n * using overflow: hidden is currently the only way to do so, and\n * that causes the layout to shift and prevents the zoom animation\n * from working in some cases because we're unable to account for\n * the layout shift when doing the animation calculations. Instead,\n * here we use JavaScript to prevent and reset the scrolling\n * behavior. In the future, we may be able to use CSS or overflow: hidden\n * instead to not rely on JavaScript, but this seems to be the best approach\n * for now that provides the best visual experience.\n *\n * @param {Object} ctx Context object with the `core/image` namespace.\n */\nfunction handleScroll( ctx ) {\n\t// We can't override the scroll behavior on mobile devices\n\t// because doing so breaks the pinch to zoom functionality, and we\n\t// want to allow users to zoom in further on the high-res image.\n\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t// We are unable to use event.preventDefault() to prevent scrolling\n\t\t// because the scroll event can't be canceled, so we reset the position instead.\n\t\twindow.scrollTo( ctx.scrollLeftReset, ctx.scrollTopReset );\n\t}\n}\n\nconst { state, actions, callbacks } = store( 'core/image', {\n\tstate: {\n\t\twindowWidth: window.innerWidth,\n\t\twindowHeight: window.innerHeight,\n\t\tget roleAttribute() {\n\t\t\tconst ctx = getContext();\n\t\t\treturn ctx.lightboxEnabled ? 'dialog' : null;\n\t\t},\n\t\tget ariaModal() {\n\t\t\tconst ctx = getContext();\n\t\t\treturn ctx.lightboxEnabled ? 'true' : null;\n\t\t},\n\t\tget dialogLabel() {\n\t\t\tconst ctx = getContext();\n\t\t\treturn ctx.lightboxEnabled ? ctx.dialogLabel : null;\n\t\t},\n\t\tget lightboxObjectFit() {\n\t\t\tconst ctx = getContext();\n\t\t\tif ( ctx.initialized ) {\n\t\t\t\treturn 'cover';\n\t\t\t}\n\t\t},\n\t\tget enlargedImgSrc() {\n\t\t\tconst ctx = getContext();\n\t\t\treturn ctx.initialized\n\t\t\t\t? ctx.imageUploadedSrc\n\t\t\t\t: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';\n\t\t},\n\t},\n\tactions: {\n\t\tshowLightbox( event ) {\n\t\t\tconst ctx = getContext();\n\t\t\t// We can't initialize the lightbox until the reference\n\t\t\t// image is loaded, otherwise the UX is broken.\n\t\t\tif ( ! ctx.imageLoaded ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.initialized = true;\n\t\t\tctx.lastFocusedElement = window.document.activeElement;\n\t\t\tctx.scrollDelta = 0;\n\t\t\tctx.pointerType = event.pointerType;\n\n\t\t\tctx.lightboxEnabled = true;\n\t\t\tsetStyles( ctx, ctx.imageRef );\n\n\t\t\tctx.scrollTopReset =\n\t\t\t\twindow.pageYOffset || document.documentElement.scrollTop;\n\n\t\t\t// In most cases, this value will be 0, but this is included\n\t\t\t// in case a user has created a page with horizontal scrolling.\n\t\t\tctx.scrollLeftReset =\n\t\t\t\twindow.pageXOffset || document.documentElement.scrollLeft;\n\n\t\t\t// We define and bind the scroll callback here so\n\t\t\t// that we can pass the context and as an argument.\n\t\t\t// We may be able to change this in the future if we\n\t\t\t// define the scroll callback in the store instead, but\n\t\t\t// this approach seems to tbe clearest for now.\n\t\t\tscrollCallback = handleScroll.bind( null, ctx );\n\n\t\t\t// We need to add a scroll event listener to the window\n\t\t\t// here because we are unable to otherwise access it via\n\t\t\t// the Interactivity API directives. If we add a native way\n\t\t\t// to access the window, we can remove this.\n\t\t\twindow.addEventListener( 'scroll', scrollCallback, false );\n\t\t},\n\t\thideLightbox() {\n\t\t\tconst ctx = getContext();\n\t\t\tctx.hideAnimationEnabled = true;\n\t\t\tif ( ctx.lightboxEnabled ) {\n\t\t\t\t// We want to wait until the close animation is completed\n\t\t\t\t// before allowing a user to scroll again. The duration of this\n\t\t\t\t// animation is defined in the styles.scss and depends on if the\n\t\t\t\t// animation is 'zoom' or 'fade', but in any case we should wait\n\t\t\t\t// a few milliseconds longer than the duration, otherwise a user\n\t\t\t\t// may scroll too soon and cause the animation to look sloppy.\n\t\t\t\tsetTimeout( function () {\n\t\t\t\t\twindow.removeEventListener( 'scroll', scrollCallback );\n\t\t\t\t\t// If we don't delay before changing the focus,\n\t\t\t\t\t// the focus ring will appear on Firefox before\n\t\t\t\t\t// the image has finished animating, which looks broken.\n\t\t\t\t\tctx.lightboxTriggerRef.focus( {\n\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t} );\n\t\t\t\t}, 450 );\n\n\t\t\t\tctx.lightboxEnabled = false;\n\t\t\t}\n\t\t},\n\t\thandleKeydown( event ) {\n\t\t\tconst ctx = getContext();\n\t\t\tif ( ctx.lightboxEnabled ) {\n\t\t\t\tif ( event.key === 'Tab' || event.keyCode === 9 ) {\n\t\t\t\t\t// If shift + tab it change the direction\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\tctx.firstFocusableElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tctx.lastFocusableElement.focus();\n\t\t\t\t\t} else if (\n\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\twindow.document.activeElement ===\n\t\t\t\t\t\t\tctx.lastFocusableElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tctx.firstFocusableElement.focus();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( event.key === 'Escape' || event.keyCode === 27 ) {\n\t\t\t\t\tactions.hideLightbox( event );\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// This is fired just by lazily loaded\n\t\t// images on the page, not all images.\n\t\thandleLoad() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tctx.imageLoaded = true;\n\t\t\tctx.imageCurrentSrc = ref.currentSrc;\n\t\t\tcallbacks.setButtonStyles();\n\t\t},\n\t\thandleTouchStart() {\n\t\t\tisTouching = true;\n\t\t},\n\t\thandleTouchMove( event ) {\n\t\t\tconst ctx = getContext();\n\t\t\t// On mobile devices, we want to prevent triggering the\n\t\t\t// scroll event because otherwise the page jumps around as\n\t\t\t// we reset the scroll position. This also means that closing\n\t\t\t// the lightbox requires that a user perform a simple tap. This\n\t\t\t// may be changed in the future if we find a better alternative\n\t\t\t// to override or reset the scroll position during swipe actions.\n\t\t\tif ( ctx.lightboxEnabled ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t},\n\t\thandleTouchEnd() {\n\t\t\t// We need to wait a few milliseconds before resetting\n\t\t\t// to ensure that pinch to zoom works consistently\n\t\t\t// on mobile devices when the lightbox is open.\n\t\t\tlastTouchTime = Date.now();\n\t\t\tisTouching = false;\n\t\t},\n\t},\n\tcallbacks: {\n\t\tinitOriginImage() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tctx.imageRef = ref;\n\t\t\tif ( ref.complete ) {\n\t\t\t\tctx.imageLoaded = true;\n\t\t\t\tctx.imageCurrentSrc = ref.currentSrc;\n\t\t\t}\n\t\t},\n\t\tinitTriggerButton() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tctx.lightboxTriggerRef = ref;\n\t\t},\n\t\tinitLightbox() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tif ( ctx.lightboxEnabled ) {\n\t\t\t\tconst focusableElements =\n\t\t\t\t\tref.querySelectorAll( focusableSelectors );\n\t\t\t\tctx.firstFocusableElement = focusableElements[ 0 ];\n\t\t\t\tctx.lastFocusableElement =\n\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\n\t\t\t\t// Move focus to the dialog when opening it.\n\t\t\t\tref.focus();\n\t\t\t}\n\t\t},\n\t\tsetButtonStyles() {\n\t\t\tconst { ref } = getElement();\n\t\t\tconst { naturalWidth, naturalHeight, offsetWidth, offsetHeight } =\n\t\t\t\tref;\n\n\t\t\t// If the image isn't loaded yet, we can't\n\t\t\t// calculate where the button should be.\n\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst figure = ref.parentElement;\n\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t// We need special handling for the height because\n\t\t\t// a caption will cause the figure to be taller than\n\t\t\t// the image, which means we need to account for that\n\t\t\t// when calculating the placement of the button in the\n\t\t\t// top right corner of the image.\n\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\tif ( caption ) {\n\t\t\t\tconst captionComputedStyle = window.getComputedStyle( caption );\n\t\t\t\tif (\n\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\tconst ctx = getContext();\n\n\t\t\t// In the case of an image with object-fit: contain, the\n\t\t\t// size of the <img> element can be larger than the image itself,\n\t\t\t// so we need to calculate where to place the button.\n\t\t\tif ( ctx.scaleAttr === 'contain' ) {\n\t\t\t\t// Natural ratio of the image.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Offset ratio of the image.\n\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t// If it reaches the width first, keep\n\t\t\t\t\t// the width and compute the height.\n\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\tctx.imageButtonTop =\n\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t16;\n\t\t\t\t\tctx.imageButtonRight = buttonOffsetRight + 16;\n\t\t\t\t} else {\n\t\t\t\t\t// If it reaches the height first, keep\n\t\t\t\t\t// the height and compute the width.\n\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\tctx.imageButtonTop = buttonOffsetTop + 16;\n\t\t\t\t\tctx.imageButtonRight =\n\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t16;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tctx.imageButtonTop = buttonOffsetTop + 16;\n\t\t\t\tctx.imageButtonRight = buttonOffsetRight + 16;\n\t\t\t}\n\t\t},\n\t\tsetStylesOnResize() {\n\t\t\tconst ctx = getContext();\n\t\t\tconst { ref } = getElement();\n\t\t\tif (\n\t\t\t\tctx.lightboxEnabled &&\n\t\t\t\t( state.windowWidth || state.windowHeight )\n\t\t\t) {\n\t\t\t\tsetStyles( ctx, ref );\n\t\t\t}\n\t\t},\n\t},\n} );\n\nwindow.addEventListener(\n\t'resize',\n\tdebounce( () => {\n\t\tstate.windowWidth = window.innerWidth;\n\t\tstate.windowHeight = window.innerHeight;\n\t} )\n);\n\n/**\n * Computes styles for the lightbox and adds them to the document.\n *\n * @function\n * @param {Object} ctx - Context for the `core/image` namespace.\n * @param {Object} ref - The element reference.\n */\nfunction setStyles( ctx, ref ) {\n\t// The reference img element lies adjacent\n\t// to the event target button in the DOM.\n\tlet {\n\t\tnaturalWidth,\n\t\tnaturalHeight,\n\t\toffsetWidth: originalWidth,\n\t\toffsetHeight: originalHeight,\n\t} = ref;\n\tlet { x: screenPosX, y: screenPosY } = ref.getBoundingClientRect();\n\n\t// Natural ratio of the image clicked to open the lightbox.\n\tconst naturalRatio = naturalWidth / naturalHeight;\n\t// Original ratio of the image clicked to open the lightbox.\n\tlet originalRatio = originalWidth / originalHeight;\n\n\t// If it has object-fit: contain, recalculate the original sizes\n\t// and the screen position without the blank spaces.\n\tif ( ctx.scaleAttr === 'contain' ) {\n\t\tif ( naturalRatio > originalRatio ) {\n\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t// Recalculate screen position without the top space.\n\t\t\tscreenPosY += ( originalHeight - heightWithoutSpace ) / 2;\n\t\t\toriginalHeight = heightWithoutSpace;\n\t\t} else {\n\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t// Recalculate screen position without the left space.\n\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\toriginalWidth = widthWithoutSpace;\n\t\t}\n\t}\n\toriginalRatio = originalWidth / originalHeight;\n\n\t// Typically, we use the image's full-sized dimensions. If those\n\t// dimensions have not been set (i.e. an external image with only one size),\n\t// the image's dimensions in the lightbox are the same\n\t// as those of the image in the content.\n\tlet imgMaxWidth = parseFloat(\n\t\tctx.targetWidth !== 'none' ? ctx.targetWidth : naturalWidth\n\t);\n\tlet imgMaxHeight = parseFloat(\n\t\tctx.targetHeight !== 'none' ? ctx.targetHeight : naturalHeight\n\t);\n\n\t// Ratio of the biggest image stored in the database.\n\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\tlet containerMaxWidth = imgMaxWidth;\n\tlet containerMaxHeight = imgMaxHeight;\n\tlet containerWidth = imgMaxWidth;\n\tlet containerHeight = imgMaxHeight;\n\t// Check if the target image has a different ratio than the original one (thumbnail).\n\t// Recalculate the width and height.\n\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t// If the width is reached before the height, we keep the maxWidth\n\t\t\t// and recalculate the height.\n\t\t\t// Unless the difference between the maxHeight and the reducedHeight\n\t\t\t// is higher than the maxWidth, where we keep the reducedHeight and\n\t\t\t// recalculate the width.\n\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t}\n\t\t} else {\n\t\t\t// If the height is reached before the width, we keep the maxHeight\n\t\t\t// and recalculate the width.\n\t\t\t// Unless the difference between the maxWidth and the reducedWidth\n\t\t\t// is higher than the maxHeight, where we keep the reducedWidth and\n\t\t\t// recalculate the height.\n\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t} else {\n\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t}\n\t\t}\n\t\tcontainerWidth = imgMaxWidth;\n\t\tcontainerHeight = imgMaxHeight;\n\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t// Calculate the max size of the container.\n\t\tif ( originalRatio > imgRatio ) {\n\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t} else {\n\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t}\n\t}\n\n\t// If the image has been pixelated on purpose, keep that size.\n\tif ( originalWidth > containerWidth || originalHeight > containerHeight ) {\n\t\tcontainerWidth = originalWidth;\n\t\tcontainerHeight = originalHeight;\n\t}\n\n\t// Calculate the final lightbox image size and the\n\t// scale factor. MaxWidth is either the window container\n\t// (accounting for padding) or the image resolution.\n\tlet horizontalPadding = 0;\n\tif ( window.innerWidth > 480 ) {\n\t\thorizontalPadding = 80;\n\t} else if ( window.innerWidth > 1920 ) {\n\t\thorizontalPadding = 160;\n\t}\n\tconst verticalPadding = 80;\n\n\tconst targetMaxWidth = Math.min(\n\t\twindow.innerWidth - horizontalPadding,\n\t\tcontainerWidth\n\t);\n\tconst targetMaxHeight = Math.min(\n\t\twindow.innerHeight - verticalPadding,\n\t\tcontainerHeight\n\t);\n\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\tif ( originalRatio > targetContainerRatio ) {\n\t\t// If targetMaxWidth is reached before targetMaxHeight\n\t\tcontainerWidth = targetMaxWidth;\n\t\tcontainerHeight = containerWidth / originalRatio;\n\t} else {\n\t\t// If targetMaxHeight is reached before targetMaxWidth\n\t\tcontainerHeight = targetMaxHeight;\n\t\tcontainerWidth = containerHeight * originalRatio;\n\t}\n\n\tconst containerScale = originalWidth / containerWidth;\n\tconst lightboxImgWidth =\n\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\tconst lightboxImgHeight =\n\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t// Add the CSS variables needed.\n\tlet styleTag = document.getElementById( 'wp-lightbox-styles' );\n\tif ( ! styleTag ) {\n\t\tstyleTag = document.createElement( 'style' );\n\t\tstyleTag.id = 'wp-lightbox-styles';\n\t\tdocument.head.appendChild( styleTag );\n\t}\n\n\t// As of this writing, using the calculations above will render the lightbox\n\t// with a small, erroneous whitespace on the left side of the image in iOS Safari,\n\t// perhaps due to an inconsistency in how browsers handle absolute positioning and CSS\n\t// transformation. In any case, adding 1 pixel to the container width and height solves\n\t// the problem, though this can be removed if the issue is fixed in the future.\n\tstyleTag.innerHTML = `\n\t\t:root {\n\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t}px;\n\t\t}\n\t`;\n}\n\n/**\n * Debounces a function call.\n *\n * @function\n * @param {Function} func - A function to be called\n * @param {number} wait - The time to wait before calling the function\n */\nfunction debounce( func, wait = 50 ) {\n\tlet timeout;\n\treturn () => {\n\t\tconst later = () => {\n\t\t\ttimeout = null;\n\t\t\tfunc();\n\t\t};\n\t\tclearTimeout( timeout );\n\t\ttimeout = setTimeout( later, wait );\n\t};\n}\n"],"names":["window","focusableSelectors","scrollCallback","isTouching","lastTouchTime","handleScroll","ctx","Date","now","scrollTo","scrollLeftReset","scrollTopReset","state","actions","callbacks","store","windowWidth","innerWidth","windowHeight","innerHeight","roleAttribute","getContext","lightboxEnabled","ariaModal","dialogLabel","lightboxObjectFit","initialized","enlargedImgSrc","imageUploadedSrc","showLightbox","event","imageLoaded","lastFocusedElement","document","activeElement","scrollDelta","pointerType","setStyles","imageRef","pageYOffset","documentElement","scrollTop","pageXOffset","scrollLeft","bind","addEventListener","hideLightbox","hideAnimationEnabled","setTimeout","removeEventListener","lightboxTriggerRef","focus","preventScroll","handleKeydown","key","keyCode","shiftKey","firstFocusableElement","preventDefault","lastFocusableElement","handleLoad","ref","getElement","imageCurrentSrc","currentSrc","setButtonStyles","handleTouchStart","handleTouchMove","handleTouchEnd","initOriginImage","complete","initTriggerButton","initLightbox","focusableElements","querySelectorAll","length","naturalWidth","naturalHeight","offsetWidth","offsetHeight","figure","parentElement","figureWidth","clientWidth","figureHeight","clientHeight","caption","querySelector","captionComputedStyle","getComputedStyle","includes","position","parseFloat","marginTop","marginBottom","buttonOffsetTop","buttonOffsetRight","scaleAttr","naturalRatio","referenceHeight","imageButtonTop","imageButtonRight","referenceWidth","setStylesOnResize","originalWidth","originalHeight","x","screenPosX","y","screenPosY","getBoundingClientRect","originalRatio","heightWithoutSpace","widthWithoutSpace","imgMaxWidth","targetWidth","imgMaxHeight","targetHeight","imgRatio","containerMaxWidth","containerMaxHeight","containerWidth","containerHeight","toFixed","reducedHeight","reducedWidth","horizontalPadding","targetMaxWidth","Math","min","targetMaxHeight","containerScale","lightboxImgWidth","lightboxImgHeight","styleTag","getElementById","createElement","id","head","appendChild","innerHTML","func","wait","timeout","clearTimeout","later","debounce"],"sourceRoot":""}