// Stores a list of z-index values in a central location.  For clarity, when a
// specific value is needed, add a comment explaining why (what other rules the
// value is designed to work with).

$z-layers: (
	'.editor-block-switcher__arrow': 1,
	'.editor-block-list__block-edit:before': -1,
	'.editor-block-list__block .wp-block-more:before': -1,
	'.editor-block-list__block {core/image aligned left or right}': 20,
	'.editor-block-list__block {core/image aligned wide or fullwide}': 20,
	'.freeform-toolbar': 10,
	'.editor-warning': 1,
	'.components-form-toggle__input': 1,
	'.editor-format-list__menu': 1,
	'.editor-inserter__tabs': 1,
	'.editor-inserter__tab.is-active': 1,
	'.components-panel__header': 1,
	'.edit-post-meta-boxes-area.is-loading:before': 1,
	'.edit-post-meta-boxes-area .spinner': 5,
	'.editor-block-contextual-toolbar': 21,
	'.editor-block-switcher__menu': 5,
	'.components-popover__close': 5,
	'.editor-block-list__insertion-point': 5,
	'.blocks-format-toolbar__link-modal': 81, // should appear above block controls
	'.blocks-gallery-item__inline-menu': 20,
	'.editor-block-settings-menu__popover': 21, // Below the header, but above the block toolbar
	'.blocks-url-input__suggestions': 30,
	'.edit-post-header': 30,
	'.blocks-button__inline-link .blocks-url-input__suggestions': 6, // URL suggestions for button block above sibling inserter
	'.wp-block-image__resize-handlers': 1, // Resize handlers above sibling inserter

	// Should have lower index than anything else positioned inside the block containers
	'.editor-block-list__block-draggable': 0,

	// The draggable element should show up above the entire UI
	'.components-draggable__clone': 1000000000,

	// Should have higher index than the inset/underlay used for dragging
	'.components-placeholder__fieldset': 1,
	'.editor-block-list__block-edit .shared-block-edit-panel *': 1,

	// Show drop zone above most standard content, but below any overlays
	'.components-drop-zone': 100,
	'.components-drop-zone__content': 110,

	// Block controls, particularly in nested contexts, floats aside block and
	// should overlap most block content.
	'.editor-block-list__block.is-{selected,hovered} .editor-block-{settings-menu,mover}': 80,

	// Show sidebar above wp-admin navigation bar for mobile viewports:
	// #wpadminbar { z-index: 99999 }
	'.edit-post-sidebar': 100000,
	'.edit-post-layout .edit-post-post-publish-panel': 100001,

	// Show sidebar in greater than small viewports above editor related elements
	// but bellow #adminmenuback { z-index: 100 }
	'.edit-post-sidebar {greater than small}': 90,

	// Show notices below expanded wp-admin submenus:
	// #adminmenuwrap { z-index: 9990 }
	'.components-notice-list': 9989,

	// Show popovers above wp-admin menus and submenus and sidebar:
	// #adminmenuwrap { z-index: 9990 }
	'.components-popover': 1000000,

	// Shows adminbar quicklink submenu above bottom popover:
	// #wpadminbar ul li {z-index: 99999;}
	'.components-popover.is-bottom': 99990,

	'.components-autocomplete__results': 1000000,

	'.skip-to-selected-block': 100000,
);

@function z-index( $key ) {
	@if map-has-key( $z-layers, $key ) {
		@return map-get( $z-layers, $key );
	}

	@error "Error: Specified z-index `#{$key}` does not exist in the mapping";
}
