{"version":3,"file":"view.cjs","names":["splitTask","store","getContext","getConfig","withSyncEvent","prefersReducedMotion","withScope","IMAGE_PRELOAD_DELAY","getElement"],"sources":["../../src/image/view.js"],"sourcesContent":["import {\n\tstore,\n\tgetContext,\n\tgetElement,\n\tgetConfig,\n\twithSyncEvent,\n\twithScope,\n\tsplitTask,\n} from '@wordpress/interactivity';\nimport { prefersReducedMotion } from '../utils/reduced-motion';\nimport { IMAGE_PRELOAD_DELAY } from './constants';\n\n/**\n * Tracks whether user is touching screen; used to differentiate behavior for\n * 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 differentiate behavior\n * for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\nconst touchStartEvent = {\n\tstartX: 0,\n\tstartY: 0,\n\tstartTime: 0,\n};\n\n/**\n * Elements made inert while the lightbox is open, so only those are restored\n * when it closes.\n *\n * @type {Element[]}\n */\nlet inertElements = [];\n\n/**\n * Per-gesture state for the in-progress horizontal drag on the lightbox.\n *\n * `direction` is null until the gesture exceeds a small disambiguation\n * threshold, then latches to 'horizontal' or 'vertical' for the rest of it;\n * vertical gestures bypass the drag-tracking path so native scroll suppression\n * keeps working unchanged.\n */\nconst touchDrag = {\n\tisDragging: false,\n\tdirection: null,\n\t// The elements the gesture moves. The drag offset is written on these\n\t// rather than on the overlay, whose `style` attribute is bound to\n\t// `state.overlayStyles`: the framework rewrites that attribute whole\n\t// whenever the bound value changes, so a resize part way through a gesture\n\t// used to wipe the drag out from under the finger. Nothing is bound to the\n\t// containers, so what is written here stays written.\n\tslideEls: [],\n\t// Animations currently running on `slideEls`, so an interrupted gesture can\n\t// stop them.\n\tanimations: [],\n\t// Finishes a committed swipe once its slide is over. Held so that a new\n\t// gesture can settle a swipe still in flight rather than stranding it.\n\tsettle: null,\n};\n\n// Duration of the commit slide and of the fade that follows it, in\n// milliseconds. These drive `element.animate()` directly, so they are the only\n// definition: nothing in `style.scss` has to be kept in step with them.\nconst SLIDE_DURATION_MS = 220;\nconst FADE_DURATION_MS = 300;\nconst SLIDE_EASING = 'cubic-bezier(0.2, 0.7, 0.2, 1)';\n\n// Movement (px) needed before a gesture latches to horizontal or vertical.\nconst DIRECTION_LATCH_THRESHOLD_PX = 10;\n\n// Horizontal movement must exceed vertical by this ratio to count as a swipe.\nconst HORIZONTAL_DOMINANCE_RATIO = 1.5;\n\n// Fraction of a slide a drag must pass to commit to the next image.\nconst COMMIT_DISTANCE_RATIO = 0.2;\n\n// A short, fast horizontal flick commits even below the distance threshold.\nconst FLICK_DISTANCE_PX = 50;\nconst FLICK_MAX_DURATION_MS = 300;\n\n/**\n * How far a committed swipe travels before the image is swapped.\n *\n * The enlarged image is centred in the viewport, so one viewport width is one\n * slide. Naming it keeps the commit distance and the commit threshold in step,\n * and marks the single place that would change if the images were ever laid\n * out as a strip rather than one at a time.\n *\n * @return {number} The slide pitch in pixels.\n */\nfunction getSlidePitch() {\n\treturn window.innerWidth;\n}\n\n/**\n * The transform that places a slide at a given horizontal offset from rest.\n *\n * Mirrors the `transform` the stylesheet gives `.lightbox-image-container`, so\n * an animation can start and end on values the element would hold on its own.\n *\n * @param {number} offset Offset from the resting position, in pixels.\n * @return {string} A CSS transform value.\n */\nfunction slideTransform( offset ) {\n\treturn `translate(calc(-50% + ${ offset }px), -50%)`;\n}\n\n/**\n * Places the slides at a horizontal offset from rest.\n *\n * @param {Element[]} els    The slide elements.\n * @param {number}    offset Offset in pixels; 0 returns them to rest.\n */\nfunction setDragOffset( els, offset ) {\n\tels.forEach( ( el ) => {\n\t\tif ( offset ) {\n\t\t\tel.style.setProperty(\n\t\t\t\t'--wp--lightbox-drag-offset',\n\t\t\t\t`${ offset }px`\n\t\t\t);\n\t\t} else {\n\t\t\tel.style.removeProperty( '--wp--lightbox-drag-offset' );\n\t\t}\n\t} );\n}\n\n/**\n * Stops whatever the gesture is animating.\n *\n * Cancelling drops a `fill`, so the slides fall back to the transform the\n * stylesheet gives them, which reads the offset set by `setDragOffset()`.\n */\nfunction stopDragAnimations() {\n\ttouchDrag.animations.forEach( ( animation ) => animation.cancel() );\n\ttouchDrag.animations = [];\n}\n\n/**\n * Clears the per-gesture drag state.\n *\n * A committed swipe still animating is left alone: it is started as a gesture\n * ends and holds its own references. `touchDrag.settle` deals with that side.\n */\nfunction resetTouchDrag() {\n\ttouchDrag.isDragging = false;\n\ttouchDrag.direction = null;\n\ttouchDrag.slideEls = [];\n}\n\n/**\n * Resolves once an image is ready to be painted.\n *\n * @param {HTMLImageElement|null} img The image to wait for.\n * @return {Promise<void>} Resolves when the image is decoded or has failed.\n */\nasync function waitForImage( img ) {\n\tawait splitTask();\n\ttry {\n\t\tawait img?.decode();\n\t} catch {\n\t\t// Fades the image in regardless.\n\t}\n}\n\nconst focusableSelectors = [\n\t'.wp-lightbox-close-button',\n\t'.wp-lightbox-navigation-button',\n];\n\n/**\n * Returns the appropriate src URL for an image.\n *\n * @param {string} uploadedSrc - Full size image src.\n * @return {string} The source URL.\n */\nfunction getImageSrc( { uploadedSrc } ) {\n\treturn (\n\t\tuploadedSrc ||\n\t\t'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\n\t);\n}\n\n/**\n * Returns the appropriate srcset for an image.\n *\n * @param {string} lightboxSrcset - Image srcset.\n * @return {string} The srcset value.\n */\nfunction getImageSrcset( { lightboxSrcset } ) {\n\treturn lightboxSrcset || '';\n}\n\n/**\n * Returns the metadata of the image with the passed ID. The ID comes from the\n * context, so only own properties of `state.metadata` are returned, never an\n * inherited one.\n *\n * @param {string} imageId Image ID.\n * @return {Object|undefined} The image metadata, if it exists.\n */\nfunction getImageMetadata( imageId ) {\n\t// Reads the property before the check so that the caller subscribes to it.\n\tconst metadata = state.metadata[ imageId ];\n\treturn Object.hasOwn( state.metadata, imageId ) ? metadata : undefined;\n}\n\nconst { state, actions, callbacks } = store(\n\t'core/image',\n\t{\n\t\tstate: {\n\t\t\tselectedImageId: null,\n\t\t\tselectedGalleryId: null,\n\t\t\tpreloadTimers: new Map(),\n\t\t\tpreloadedImageIds: new Set(),\n\t\t\tget galleryImages() {\n\t\t\t\tif ( ! state.selectedGalleryId ) {\n\t\t\t\t\treturn [ state.selectedImageId ];\n\t\t\t\t}\n\n\t\t\t\t// Get all images in this gallery and sort by galleryOrder\n\t\t\t\treturn Object.entries( state.metadata )\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( [ , value ] ) =>\n\t\t\t\t\t\t\tvalue.galleryId === state.selectedGalleryId\n\t\t\t\t\t)\n\t\t\t\t\t.sort( ( [ , a ], [ , b ] ) => {\n\t\t\t\t\t\tconst orderA = a.order ?? 0;\n\t\t\t\t\t\tconst orderB = b.order ?? 0;\n\t\t\t\t\t\treturn orderA - orderB;\n\t\t\t\t\t} )\n\t\t\t\t\t.map( ( [ key ] ) => key );\n\t\t\t},\n\t\t\tget selectedImageIndex() {\n\t\t\t\treturn state.galleryImages.findIndex(\n\t\t\t\t\t( id ) => id === state.selectedImageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget selectedImage() {\n\t\t\t\treturn getImageMetadata( state.selectedImageId );\n\t\t\t},\n\t\t\tget hasNavigationIcon() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'icon' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasNavigationText() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'text' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget thisImage() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn getImageMetadata( imageId );\n\t\t\t},\n\t\t\tget hasNavigation() {\n\t\t\t\treturn state.galleryImages.length > 1;\n\t\t\t},\n\t\t\tget hasNextImage() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImageIndex + 1 < state.galleryImages.length\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasPreviousImage() {\n\t\t\t\treturn state.selectedImageIndex - 1 >= 0;\n\t\t\t},\n\t\t\tget overlayOpened() {\n\t\t\t\treturn state.selectedImageId !== null;\n\t\t\t},\n\t\t\tget roleAttribute() {\n\t\t\t\treturn state.overlayOpened ? 'dialog' : null;\n\t\t\t},\n\t\t\tget ariaModal() {\n\t\t\t\treturn state.overlayOpened ? 'true' : null;\n\t\t\t},\n\t\t\tget ariaLabel() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImage.customAriaLabel ||\n\t\t\t\t\tgetConfig().defaultAriaLabel\n\t\t\t\t);\n\t\t\t},\n\t\t\tget closeButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().closeButtonText;\n\t\t\t},\n\t\t\tget prevButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().prevButtonText;\n\t\t\t},\n\t\t\tget nextButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().nextButtonText;\n\t\t\t},\n\t\t\tget enlargedSrc() {\n\t\t\t\treturn getImageSrc( state.selectedImage );\n\t\t\t},\n\t\t\tget enlargedSrcset() {\n\t\t\t\treturn getImageSrcset( state.selectedImage );\n\t\t\t},\n\t\t\tget figureStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.figureStyles?.replace(\n\t\t\t\t\t\t/margin[^;]*;?/g,\n\t\t\t\t\t\t''\n\t\t\t\t\t) };`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget imgStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.imgStyles?.replace(\n\t\t\t\t\t\t/;$/,\n\t\t\t\t\t\t''\n\t\t\t\t\t) }; object-fit:cover;`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentHidden() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentVisible() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\t! state.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tshowLightbox() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails out if the image has not loaded yet.\n\t\t\t\tif ( ! getImageMetadata( imageId )?.imageRef?.complete ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Stores the positions of the scroll to fix it until the overlay is\n\t\t\t\t// closed.\n\t\t\t\tstate.scrollTopReset = document.documentElement.scrollTop;\n\t\t\t\tstate.scrollLeftReset = document.documentElement.scrollLeft;\n\n\t\t\t\t// Sets the selected image and gallery and enables the overlay.\n\t\t\t\tstate.selectedImageId = imageId;\n\t\t\t\tconst { galleryId } = getContext( 'core/gallery' ) || {};\n\t\t\t\tstate.selectedGalleryId = galleryId || null;\n\t\t\t\tstate.overlayEnabled = true;\n\n\t\t\t\t// Computes the styles of the overlay for the animation.\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t},\n\t\t\thideLightbox() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tstate.overlayEnabled = false;\n\n\t\t\t\t\t// Waits until the close animation has completed before allowing a\n\t\t\t\t\t// user to scroll again. The duration of this animation is defined in\n\t\t\t\t\t// the `styles.scss` file, but in any case we should wait a few\n\t\t\t\t\t// milliseconds longer than the duration, otherwise a user may scroll\n\t\t\t\t\t// too soon and cause the animation to look sloppy.\n\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t// Delays before changing the focus. Otherwise the focus ring will\n\t\t\t\t\t\t// appear on Firefox before the image has finished animating, which\n\t\t\t\t\t\t// looks broken.\n\t\t\t\t\t\tstate.selectedImage.buttonRef.focus( {\n\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Resets the selected image and gallery ids.\n\t\t\t\t\t\tstate.selectedImageId = null;\n\t\t\t\t\t\tstate.selectedGalleryId = null;\n\t\t\t\t\t}, 450 );\n\t\t\t\t}\n\t\t\t},\n\t\t\tshowPreviousImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasPreviousImage\n\t\t\t\t\t? state.selectedImageIndex - 1\n\t\t\t\t\t: state.galleryImages.length - 1;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\tshowNextImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasNextImage\n\t\t\t\t\t? state.selectedImageIndex + 1\n\t\t\t\t\t: 0;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\thandleKeydown: withSyncEvent( ( event ) => {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\t\tactions.hideLightbox();\n\t\t\t\t\t} else if ( event.key === 'ArrowLeft' ) {\n\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t} else if ( event.key === 'ArrowRight' ) {\n\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t} else if ( event.key === 'Tab' ) {\n\t\t\t\t\t\t// Traps focus within the overlay.\n\t\t\t\t\t\tconst focusableElements = Array.from(\n\t\t\t\t\t\t\tdocument.querySelectorAll( focusableSelectors )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst firstFocusableElement = focusableElements[ 0 ];\n\t\t\t\t\t\tconst lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\tevent.target === firstFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tlastFocusableElement.focus();\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\tevent.target === lastFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tfirstFocusableElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchMove: withSyncEvent( ( event ) => {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Prevents triggering the scroll event because otherwise the page\n\t\t\t\t// jumps around when it resets the scroll position. This also means\n\t\t\t\t// that closing the lightbox requires a simple tap. May change in\n\t\t\t\t// the future with a better way to reset scroll during swipes.\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst t = event.touches && event.touches[ 0 ];\n\t\t\t\tif ( ! t || ! state.hasNavigation ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst deltaX = t.clientX - touchStartEvent.startX;\n\t\t\t\tconst deltaY = t.clientY - touchStartEvent.startY;\n\t\t\t\tconst absDeltaX = Math.abs( deltaX );\n\t\t\t\tconst absDeltaY = Math.abs( deltaY );\n\n\t\t\t\t// Latches direction once the user has moved past a small\n\t\t\t\t// disambiguation threshold, then sticks with that decision for the\n\t\t\t\t// rest of the gesture.\n\t\t\t\tif (\n\t\t\t\t\t! touchDrag.direction &&\n\t\t\t\t\t( absDeltaX > DIRECTION_LATCH_THRESHOLD_PX ||\n\t\t\t\t\t\tabsDeltaY > DIRECTION_LATCH_THRESHOLD_PX )\n\t\t\t\t) {\n\t\t\t\t\ttouchDrag.direction =\n\t\t\t\t\t\tabsDeltaX > absDeltaY ? 'horizontal' : 'vertical';\n\t\t\t\t\ttouchDrag.slideEls = Array.from(\n\t\t\t\t\t\tevent.currentTarget.querySelectorAll(\n\t\t\t\t\t\t\t'.lightbox-image-container'\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\ttouchDrag.direction === 'horizontal' &&\n\t\t\t\t\ttouchDrag.slideEls.length\n\t\t\t\t) {\n\t\t\t\t\ttouchDrag.isDragging = true;\n\t\t\t\t\tsetDragOffset( touchDrag.slideEls, deltaX );\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchStart( event ) {\n\t\t\t\tisTouching = true;\n\t\t\t\tif ( event.touches?.length > 1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst t = event.touches && event.touches[ 0 ];\n\t\t\t\tif ( t ) {\n\t\t\t\t\ttouchStartEvent.startX = t.clientX;\n\t\t\t\t\ttouchStartEvent.startY = t.clientY;\n\t\t\t\t\ttouchStartEvent.startTime = Date.now();\n\t\t\t\t}\n\t\t\t\t// Settles a swipe left over from the previous gesture, so this one\n\t\t\t\t// starts from an image at rest rather than part way through a\n\t\t\t\t// slide. Dropping it instead would leave the image parked\n\t\t\t\t// off-screen and never swap it for the next one.\n\t\t\t\ttouchDrag.settle?.();\n\t\t\t\tstopDragAnimations();\n\t\t\t\tresetTouchDrag();\n\t\t\t},\n\t\t\thandleTouchCancel() {\n\t\t\t\t// The gesture was interrupted — the browser cancelled the drag, or\n\t\t\t\t// a system gesture took over — so no `touchend` will arrive to\n\t\t\t\t// settle the image. Abandon the drag rather than committing it,\n\t\t\t\t// otherwise the offset stays on the slides, which outlive the\n\t\t\t\t// lightbox being closed and reopened.\n\t\t\t\tstopDragAnimations();\n\t\t\t\tsetDragOffset( touchDrag.slideEls, 0 );\n\t\t\t\tresetTouchDrag();\n\t\t\t\tlastTouchTime = Date.now();\n\t\t\t\tisTouching = false;\n\t\t\t},\n\t\t\thandleTouchEnd: withSyncEvent( ( event ) => {\n\t\t\t\t// Ignores fingers lifting while another is still down.\n\t\t\t\tif ( event.touches?.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst touchEndEvent =\n\t\t\t\t\t( event.changedTouches && event.changedTouches[ 0 ] ) ||\n\t\t\t\t\t( event.touches && event.touches[ 0 ] );\n\t\t\t\tconst now = Date.now();\n\n\t\t\t\tif (\n\t\t\t\t\ttouchEndEvent &&\n\t\t\t\t\tstate.overlayEnabled &&\n\t\t\t\t\ttouchDrag.isDragging\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\tconst deltaX =\n\t\t\t\t\t\ttouchEndEvent.clientX - touchStartEvent.startX;\n\t\t\t\t\tconst deltaY =\n\t\t\t\t\t\ttouchEndEvent.clientY - touchStartEvent.startY;\n\t\t\t\t\tconst absDeltaX = Math.abs( deltaX );\n\t\t\t\t\tconst absDeltaY = Math.abs( deltaY );\n\t\t\t\t\tconst elapsedMs = now - touchStartEvent.startTime;\n\t\t\t\t\tconst slidePitch = getSlidePitch();\n\t\t\t\t\tconst isHorizontalDominant =\n\t\t\t\t\t\tabsDeltaX > absDeltaY * HORIZONTAL_DOMINANCE_RATIO;\n\t\t\t\t\tconst pastDistanceThreshold =\n\t\t\t\t\t\tabsDeltaX > slidePitch * COMMIT_DISTANCE_RATIO;\n\t\t\t\t\tconst isFastFlick =\n\t\t\t\t\t\tabsDeltaX > FLICK_DISTANCE_PX &&\n\t\t\t\t\t\telapsedMs < FLICK_MAX_DURATION_MS;\n\t\t\t\t\tconst shouldCommit =\n\t\t\t\t\t\tisHorizontalDominant &&\n\t\t\t\t\t\t( pastDistanceThreshold || isFastFlick );\n\t\t\t\t\tconst showsNextImage = deltaX < 0;\n\n\t\t\t\t\tconst slideEls = touchDrag.slideEls;\n\t\t\t\t\tconst reducedMotion = prefersReducedMotion();\n\t\t\t\t\t// A committed swipe carries the image off the side it was\n\t\t\t\t\t// dragged towards; an uncommitted one falls back to rest.\n\t\t\t\t\tconst committedOffset = showsNextImage\n\t\t\t\t\t\t? -slidePitch\n\t\t\t\t\t\t: slidePitch;\n\t\t\t\t\tconst endOffset = shouldCommit ? committedOffset : 0;\n\n\t\t\t\t\t// Swaps the image and puts the slides back at rest, once the\n\t\t\t\t\t// slide has played out. Runs exactly once, whether it is\n\t\t\t\t\t// reached by the animation finishing or by the next gesture\n\t\t\t\t\t// settling it early.\n\t\t\t\t\tconst settle = () => {\n\t\t\t\t\t\tif ( touchDrag.settle !== settle ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttouchDrag.settle = null;\n\t\t\t\t\t\tstopDragAnimations();\n\t\t\t\t\t\tsetDragOffset( slideEls, 0 );\n\n\t\t\t\t\t\tif ( ! shouldCommit ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( showsNextImage ) {\n\t\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( reducedMotion ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Keeps the slides hidden until the image that replaced\n\t\t\t\t\t\t// the one carried off is ready. Fading straight away\n\t\t\t\t\t\t// plays the fade on an empty box while the image is\n\t\t\t\t\t\t// still loading, and the image then pops in when it\n\t\t\t\t\t\t// arrives.\n\t\t\t\t\t\t// Scripted animations take precedence over the overlay's\n\t\t\t\t\t\t// own CSS animations without touching its class list, so\n\t\t\t\t\t\t// this cannot disturb the zoom the lightbox plays when an\n\t\t\t\t\t\t// image is first opened.\n\t\t\t\t\t\tconst hold = slideEls.map( ( el ) =>\n\t\t\t\t\t\t\tel.animate( [ { opacity: 0 }, { opacity: 0 } ], {\n\t\t\t\t\t\t\t\tfill: 'forwards',\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttouchDrag.animations = hold;\n\t\t\t\t\t\tconst enlargedEl = slideEls[ slideEls.length - 1 ];\n\t\t\t\t\t\twaitForImage( enlargedEl.querySelector( 'img' ) ).then(\n\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\tif ( touchDrag.animations !== hold ) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstopDragAnimations();\n\t\t\t\t\t\t\t\t// Fades only the enlarged image, keeping the\n\t\t\t\t\t\t\t\t// thumbnail behind it hidden until the fade ends.\n\t\t\t\t\t\t\t\t// Fading both lets a thumbnail cropped to another\n\t\t\t\t\t\t\t\t// shape show through as a darker box.\n\t\t\t\t\t\t\t\ttouchDrag.animations = slideEls.map( ( el ) =>\n\t\t\t\t\t\t\t\t\tel.animate(\n\t\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t\t{ opacity: 0 },\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\topacity:\n\t\t\t\t\t\t\t\t\t\t\t\t\tel === enlargedEl ? 1 : 0,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tduration: FADE_DURATION_MS,\n\t\t\t\t\t\t\t\t\t\t\teasing: 'ease-out',\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t};\n\t\t\t\t\ttouchDrag.settle = settle;\n\n\t\t\t\t\tif ( reducedMotion ) {\n\t\t\t\t\t\tsettle();\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttouchDrag.animations = slideEls.map( ( el ) =>\n\t\t\t\t\t\t\tel.animate(\n\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t{ transform: slideTransform( deltaX ) },\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttransform: slideTransform( endOffset ),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tduration: SLIDE_DURATION_MS,\n\t\t\t\t\t\t\t\t\teasing: SLIDE_EASING,\n\t\t\t\t\t\t\t\t\t// Holds the end position until `settle()` has\n\t\t\t\t\t\t\t\t\t// moved the slides there itself.\n\t\t\t\t\t\t\t\t\tfill: 'forwards',\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\ttouchDrag.animations[ 0 ].onfinish =\n\t\t\t\t\t\t\twithScope( settle );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlastTouchTime = now;\n\t\t\t\tisTouching = false;\n\t\t\t\tresetTouchDrag();\n\t\t\t} ),\n\t\t\thandleScroll() {\n\t\t\t\t// Prevents scrolling behaviors that trigger content shift while the\n\t\t\t\t// lightbox is open. It would be better to accomplish through CSS alone,\n\t\t\t\t// but using overflow: hidden is currently the only way to do so and\n\t\t\t\t// that causes a layout to shift and prevents the zoom animation from\n\t\t\t\t// working in some cases because it's not possible to account for the\n\t\t\t\t// layout shift when doing the animation calculations. Instead, it uses\n\t\t\t\t// JavaScript to prevent and reset the scrolling behavior.\n\t\t\t\tif ( state.overlayOpened ) {\n\t\t\t\t\t// Avoids overriding the scroll behavior on mobile devices because\n\t\t\t\t\t// doing so breaks the pinch to zoom functionality, and users should\n\t\t\t\t\t// be able to zoom in further on the high-res image.\n\t\t\t\t\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t\t\t\t\t// It doesn't rely on `event.preventDefault()` to prevent scrolling\n\t\t\t\t\t\t// because the scroll event can't be canceled, so it resets the\n\t\t\t\t\t\t// position instead.\n\t\t\t\t\t\twindow.scrollTo(\n\t\t\t\t\t\t\tstate.scrollLeftReset,\n\t\t\t\t\t\t\tstate.scrollTopReset\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tpreloadImage() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails if it has already been preloaded. This could help\n\t\t\t\t// prevent unnecessary preloading of the same image multiple times,\n\t\t\t\t// leading to duplicate link elements in the document head.\n\t\t\t\tif ( state.preloadedImageIds.has( imageId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst imageMetadata = getImageMetadata( imageId );\n\t\t\t\tif ( ! imageMetadata ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Link element to preload the image.\n\t\t\t\tconst imageLink = document.createElement( 'link' );\n\t\t\t\timageLink.rel = 'preload';\n\t\t\t\timageLink.as = 'image';\n\t\t\t\timageLink.href = getImageSrc( imageMetadata );\n\n\t\t\t\t// Apply srcset if available for responsive preloading\n\t\t\t\tconst srcset = getImageSrcset( imageMetadata );\n\t\t\t\tif ( srcset ) {\n\t\t\t\t\timageLink.setAttribute( 'imagesrcset', srcset );\n\t\t\t\t\timageLink.setAttribute( 'imagesizes', '100vw' );\n\t\t\t\t}\n\n\t\t\t\tdocument.head.appendChild( imageLink );\n\t\t\t\tstate.preloadedImageIds.add( imageId );\n\t\t\t},\n\t\t\tpreloadImageWithDelay() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tactions.cancelPreload();\n\n\t\t\t\t// Set a new timer to preload the image after a short delay.\n\t\t\t\tconst timerId = setTimeout(\n\t\t\t\t\twithScope( () => {\n\t\t\t\t\t\tactions.preloadImage();\n\t\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t\t} ),\n\t\t\t\t\tIMAGE_PRELOAD_DELAY\n\t\t\t\t);\n\t\t\t\tstate.preloadTimers.set( imageId, timerId );\n\t\t\t},\n\t\t\tcancelPreload() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tif ( state.preloadTimers.has( imageId ) ) {\n\t\t\t\t\tclearTimeout( state.preloadTimers.get( imageId ) );\n\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tsetOverlayStyles() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth: originalWidth,\n\t\t\t\t\toffsetHeight: originalHeight,\n\t\t\t\t} = state.selectedImage.imageRef;\n\t\t\t\tlet { x: screenPosX, y: screenPosY } =\n\t\t\t\t\tstate.selectedImage.imageRef.getBoundingClientRect();\n\n\t\t\t\t// Natural ratio of the image clicked to open the lightbox.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Original ratio of the image clicked to open the lightbox.\n\t\t\t\tconst originalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// If it has object-fit: contain, recalculates the original sizes\n\t\t\t\t// and the screen position without the blank spaces.\n\t\t\t\tif ( state.selectedImage.scaleAttr === 'contain' ) {\n\t\t\t\t\tif ( naturalRatio > originalRatio ) {\n\t\t\t\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the top space.\n\t\t\t\t\t\tscreenPosY +=\n\t\t\t\t\t\t\t( originalHeight - heightWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalHeight = heightWithoutSpace;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the left space.\n\t\t\t\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalWidth = widthWithoutSpace;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Typically, it uses the image's full-sized dimensions. If those\n\t\t\t\t// dimensions have not been set (i.e. an external image with only one\n\t\t\t\t// size), the image's dimensions in the lightbox are the same\n\t\t\t\t// as those of the image in the content.\n\t\t\t\tconst imgMaxWidth = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetWidth &&\n\t\t\t\t\t\tstate.selectedImage.targetWidth !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetWidth\n\t\t\t\t\t\t: naturalWidth\n\t\t\t\t);\n\t\t\t\tconst imgMaxHeight = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetHeight &&\n\t\t\t\t\t\tstate.selectedImage.targetHeight !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetHeight\n\t\t\t\t\t\t: naturalHeight\n\t\t\t\t);\n\n\t\t\t\t// Ratio of the biggest image stored in the database.\n\t\t\t\tconst fullSizeRatio = imgMaxWidth / imgMaxHeight;\n\t\t\t\tlet containerWidth = imgMaxWidth;\n\t\t\t\tlet containerHeight = imgMaxHeight;\n\n\t\t\t\t// If the image has been pixelated on purpose, it keeps that size.\n\t\t\t\tif (\n\t\t\t\t\toriginalWidth > containerWidth ||\n\t\t\t\t\toriginalHeight > containerHeight\n\t\t\t\t) {\n\t\t\t\t\tcontainerWidth = originalWidth;\n\t\t\t\t\tcontainerHeight = originalHeight;\n\t\t\t\t}\n\n\t\t\t\t// Calculates the final lightbox image size and the scale factor.\n\t\t\t\t// MaxWidth is either the window container (accounting for padding) or\n\t\t\t\t// the image resolution.\n\n\t\t\t\t// 480px width or less\n\t\t\t\tlet horizontalPadding = 0;\n\t\t\t\tlet verticalPadding = 160;\n\t\t\t\t// Greater than 480px wide and less than or equal to 960px\n\t\t\t\tif ( 480 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = 80;\n\t\t\t\t\tverticalPadding = 160;\n\t\t\t\t}\n\t\t\t\t// Greater than 960px wide\n\t\t\t\tif ( 960 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = state.hasNavigation ? 320 : 80;\n\t\t\t\t\tverticalPadding = 80;\n\t\t\t\t}\n\n\t\t\t\tconst targetMaxWidth = Math.min(\n\t\t\t\t\twindow.innerWidth - horizontalPadding,\n\t\t\t\t\tcontainerWidth\n\t\t\t\t);\n\t\t\t\tconst targetMaxHeight = Math.min(\n\t\t\t\t\twindow.innerHeight - verticalPadding,\n\t\t\t\t\tcontainerHeight\n\t\t\t\t);\n\t\t\t\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\t\t\t\tif ( fullSizeRatio > targetContainerRatio ) {\n\t\t\t\t\t// If targetMaxWidth is reached before targetMaxHeight.\n\t\t\t\t\tcontainerWidth = targetMaxWidth;\n\t\t\t\t\tcontainerHeight = containerWidth / fullSizeRatio;\n\t\t\t\t} else {\n\t\t\t\t\t// If targetMaxHeight is reached before targetMaxWidth.\n\t\t\t\t\tcontainerHeight = targetMaxHeight;\n\t\t\t\t\tcontainerWidth = containerHeight * fullSizeRatio;\n\t\t\t\t}\n\n\t\t\t\tconst hasCroppedSource =\n\t\t\t\t\tnaturalRatio.toFixed( 2 ) !== fullSizeRatio.toFixed( 2 );\n\t\t\t\tconst sourceRatio = hasCroppedSource\n\t\t\t\t\t? naturalRatio\n\t\t\t\t\t: fullSizeRatio;\n\n\t\t\t\t// Include any crop already applied to the thumbnail file.\n\t\t\t\tconst containerScale = Math.max(\n\t\t\t\t\toriginalWidth / containerWidth,\n\t\t\t\t\toriginalHeight / containerHeight,\n\t\t\t\t\toriginalWidth / ( containerHeight * sourceRatio ),\n\t\t\t\t\t( originalHeight * sourceRatio ) / containerWidth\n\t\t\t\t);\n\t\t\t\tconst thumbnailWidth = originalWidth / containerScale;\n\t\t\t\tconst thumbnailHeight = originalHeight / containerScale;\n\t\t\t\tconst cropX = ( containerWidth - thumbnailWidth ) / 2;\n\t\t\t\tconst cropY = ( containerHeight - thumbnailHeight ) / 2;\n\t\t\t\tscreenPosX -= cropX * containerScale;\n\t\t\t\tscreenPosY -= cropY * containerScale;\n\n\t\t\t\t// As of this writing, using the calculations above will render the\n\t\t\t\t// lightbox with a small, erroneous whitespace on the left side of the\n\t\t\t\t// image in iOS Safari, perhaps due to an inconsistency in how browsers\n\t\t\t\t// handle absolute positioning and CSS transformation. In any case,\n\t\t\t\t// adding 1 pixel to the container width and height solves the problem,\n\t\t\t\t// though this can be removed if the issue is fixed in the future.\n\t\t\t\tstate.overlayStyles = `\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t\t\t--wp--lightbox-image-width: ${ containerWidth }px;\n\t\t\t\t\t--wp--lightbox-image-height: ${ containerHeight }px;\n\t\t\t\t\t--wp--lightbox-initial-clip: inset(${ cropY }px ${ cropX }px);\n\t\t\t\t\t--wp--lightbox-thumbnail-width: ${\n\t\t\t\t\t\thasCroppedSource ? thumbnailWidth : containerWidth\n\t\t\t\t\t}px;\n\t\t\t\t\t--wp--lightbox-thumbnail-height: ${\n\t\t\t\t\t\thasCroppedSource ? thumbnailHeight : containerHeight\n\t\t\t\t\t}px;\n\t\t\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t\t\t}px;\n\t\t\t\t`;\n\t\t\t},\n\t\t\tsetButtonStyles() {\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\t// This guard prevents errors in images with the `srcset`\n\t\t\t\t// attribute, which can dispatch `load` events even after DOM\n\t\t\t\t// removal. Preact doesn't automatically clean up `load` event\n\t\t\t\t// listeners on unmounted `img` elements (see\n\t\t\t\t// https://github.com/preactjs/preact/issues/3141).\n\t\t\t\tif ( ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst imageMetadata = getImageMetadata( imageId );\n\t\t\t\tif ( ! imageMetadata ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\timageMetadata.imageRef = ref;\n\t\t\t\timageMetadata.currentSrc = ref.currentSrc;\n\n\t\t\t\tconst {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth,\n\t\t\t\t\toffsetHeight,\n\t\t\t\t} = ref;\n\n\t\t\t\t// If the image isn't loaded yet, it can't calculate where the button\n\t\t\t\t// should be.\n\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// The image is not necessarily a direct child of the figure, as\n\t\t\t\t// plugins can wrap it, so it uses the container the button is\n\t\t\t\t// positioned against rather than the image's parent element.\n\t\t\t\tconst container = ref.closest( '.wp-lightbox-container' );\n\t\t\t\tif ( ! container ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst containerWidth = container.clientWidth;\n\n\t\t\t\t// It needs special handling for the height because a caption will cause\n\t\t\t\t// the container to be taller than the image, which means it needs to\n\t\t\t\t// account for that when calculating the placement of the button in the\n\t\t\t\t// top right corner of the image.\n\t\t\t\tlet containerHeight = container.clientHeight;\n\t\t\t\tconst caption = container.querySelector( 'figcaption' );\n\t\t\t\tif ( caption ) {\n\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\tif (\n\t\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontainerHeight =\n\t\t\t\t\t\t\tcontainerHeight -\n\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst buttonOffsetTop = containerHeight - offsetHeight;\n\t\t\t\tconst buttonOffsetRight = containerWidth - offsetWidth;\n\n\t\t\t\tlet buttonTop = buttonOffsetTop + 16;\n\t\t\t\tlet buttonRight = buttonOffsetRight + 16;\n\n\t\t\t\t// In the case of an image with object-fit: contain, the size of the\n\t\t\t\t// <img> element can be larger than the image itself, so it needs to\n\t\t\t\t// calculate where to place the button.\n\t\t\t\tif ( imageMetadata.scaleAttr === 'contain' ) {\n\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t// If it reaches the width first, it keeps the width and compute the\n\t\t\t\t\t\t// height.\n\t\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\tbuttonTop =\n\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t\tbuttonRight = buttonOffsetRight + 16;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If it reaches the height first, it keeps the height and compute\n\t\t\t\t\t\t// the width.\n\t\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\tbuttonTop = buttonOffsetTop + 16;\n\t\t\t\t\t\tbuttonRight =\n\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\timageMetadata.buttonTop = buttonTop;\n\t\t\t\timageMetadata.buttonRight = buttonRight;\n\t\t\t},\n\t\t\tsetOverlayFocus() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Moves the focus to the dialog when it opens.\n\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetInertElements() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\tinertElements.forEach( ( el ) =>\n\t\t\t\t\t\tel.removeAttribute( 'inert' )\n\t\t\t\t\t);\n\t\t\t\t\tinertElements = [];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Inerts the overlay's siblings at each level, not its ancestors.\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tlet node = ref;\n\t\t\t\twhile ( node && node !== document.body && node.parentElement ) {\n\t\t\t\t\tfor ( const sibling of node.parentElement.children ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsibling !== node &&\n\t\t\t\t\t\t\t! sibling.hasAttribute( 'inert' )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsibling.setAttribute( 'inert', '' );\n\t\t\t\t\t\t\tinertElements.push( sibling );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnode = node.parentElement;\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitTriggerButton() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tconst imageMetadata = getImageMetadata( imageId );\n\t\t\t\tif ( imageMetadata ) {\n\t\t\t\t\timageMetadata.buttonRef = ref;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAI,aAAa;;;;;;;AAQjB,IAAI,gBAAgB;AAEpB,MAAM,kBAAkB;CACvB,QAAQ;CACR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