/**
 * Theme Name: errigal
 * Theme URI: https://projecterrigal.com/themes/errigal/
 * Author: Project errigal
 * Author URI: https://projecterrigal.com/
 * Version: 1.2.1
 */
/* eslint-disable no-unused-expressions */
/* eslint-disable eqeqeq */
/* eslint-disable no-mixed-operators */
/* eslint-disable no-nested-ternary */
( function() {
	'use strict';

	var EVENT_PREVIEW_READY = 'preview-ready';
	var OBJECT_NAME_WP = 'wp';
	var EMPTY_ARRAY = [];
	var NULL_OBJECT = null;
	var INDEX_FIRST = 0;

	function isFunction( value ) {
		return value instanceof Function;
	}

	function isHTMLCollection( elements ) {
		return elements instanceof HTMLCollection;
	}

	function isObjectType( value, expectedType ) {
		return Object.prototype.toString.call( value ) === '[object '.concat( expectedType, ']' );
	}

	function isNumber( value ) {
		return ! isNaN( value ) && isObjectType( value, 'Number' ) && isFinite( value );
	}

	function isPositiveNumber( value ) {
		return isNumber( value ) && value > 0;
	}

	function isIterable( items ) {
		return !! items && isPositiveNumber( items.length );
	}

	function isTrue( value ) {
		return value === true;
	}

	function forEach( items, callback ) {
		if ( ! isIterable( items ) || ! isFunction( callback ) ) {
			return false;
		}

		if ( isHTMLCollection( items ) ) {
			items = Array.prototype.slice.call( items );
		}

		for ( var i = INDEX_FIRST; i < items.length; i++ ) {
			if ( isTrue( callback( items[ i ], i, items ) ) ) {
				return true;
			}
		}

		return false;
	}

	var NULL_VALUE = null;

	function isObject( value ) {
		return value instanceof Object;
	}

	function getObjectValue( obj, key ) {
		return isObject( obj ) && key in obj ? obj[ key ] : NULL_VALUE;
	}

	function hasObjectKey( value, index ) {
		return !! value && !! index && isTrue( Object.prototype.hasOwnProperty.call( value, index ) );
	}

	var EMPTY_STRING = '';

	function isString( value ) {
		return isObjectType( value, 'String' );
	}

	function isNonEmptyString( value ) {
		return isString( value ) && isFunction( value.trim ) && value.trim() !== EMPTY_STRING;
	}

	function isStringArray( items ) {
		return Array.isArray( items ) && isIterable( items ) ? ! forEach( items, function( item ) {
			return ! isNonEmptyString( item );
		} ) : false;
	}

	function getGlobalObject( objectName ) {
		var expectedKeys = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : EMPTY_ARRAY;

		if ( ! ( expectedKeys === EMPTY_ARRAY || isStringArray( expectedKeys ) ) ) {
			return NULL_OBJECT;
		}

		var GLOBAL_OBJECT = getObjectValue( window, objectName );

		if ( ! isObject( GLOBAL_OBJECT ) ) {
			return NULL_OBJECT;
		}

		if ( ! isPositiveNumber( expectedKeys.length ) ) {
			return GLOBAL_OBJECT;
		}

		var HAS_EXPECTED_KEYS = ! forEach( expectedKeys, function( key ) {
			return ! hasObjectKey( GLOBAL_OBJECT, key );
		} );

		return isTrue( HAS_EXPECTED_KEYS ) ? GLOBAL_OBJECT : NULL_OBJECT;
	}

	function getWp() {
		return getGlobalObject( OBJECT_NAME_WP );
	}

	function isWpCustomise( wpObj ) {
		return !! wpObj && isFunction( wpObj.customize ) && isFunction( wpObj.customize.bind );
	}

	function bindCustomEvent( eventType, callback ) {
		if ( ! isNonEmptyString( eventType ) || ! isFunction( callback ) ) {
			return;
		}

		var WP = getWp();

		if ( ! isWpCustomise( WP ) ) {
			return;
		}

		WP.customize.bind( eventType, callback );
	}

	function onCustomisePreviewReady( callback ) {
		bindCustomEvent( EVENT_PREVIEW_READY, callback );
	}

	var CLASS_CUSTOM_SUFFIX_HEADING_STYLE = '-headings';
	var CUSTOM_ID_HEADING_STYLE = 'heading_style';
	var CLASS_SECTION_ENTRY_CONTENT = 'entry-content';

	function getFirstItem( items ) {
		return isIterable( items ) ? items[ INDEX_FIRST ] : NULL_VALUE;
	}

	var NULL_ELEMENT = null;

	function hasClassList( element ) {
		return !! element && element.classList instanceof DOMTokenList && isFunction( element.classList.contains );
	}

	function isHTMLElement( element ) {
		if ( ! ( element instanceof HTMLElement ) ) {
			return false;
		}

		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return hasClassList( element ) && ! forEach( classNames, function( className ) {
			return ! element.classList.contains( className );
		} );
	}

	function isDocument( element ) {
		return element instanceof Document;
	}

	function isisHTMLElementOrDocument( element ) {
		return isHTMLElement( element ) || isDocument( element );
	}

	function callElementMethod( methodName, nameOrSelectors, rootElement ) {
		return isNonEmptyString( methodName ) && isNonEmptyString( nameOrSelectors ) && isisHTMLElementOrDocument( rootElement ) && isFunction( rootElement[ methodName ] ) ? rootElement[ methodName ]( nameOrSelectors ) : NULL_ELEMENT;
	}

	function getElementsByClassName( className ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;
		var ELEMENTS = callElementMethod( 'getElementsByClassName', className, rootElement );

		return isHTMLCollection( ELEMENTS ) ? ELEMENTS : NULL_ELEMENT;
	}

	function getElementByClassName( className ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return getFirstItem( getElementsByClassName( className, rootElement ) );
	}

	function getEntryContent() {
		return getElementByClassName( CLASS_SECTION_ENTRY_CONTENT );
	}

	function isWpCustomisePreview( wpObj ) {
		return !! wpObj && isFunction( wpObj.customize ) && isObject( wpObj.customize.preview ) && isFunction( wpObj.customize.preview.bind ) && isObject( wpObj.customize.selectiveRefresh ) && isFunction( wpObj.customize.selectiveRefresh.bind ) && isFunction( wpObj.customize.selectiveRefresh.partial ) && isFunction( wpObj.customize.selectiveRefresh.requestFullRefresh );
	}

	function isCustomPartial( partial ) {
		return !! partial && isObject( partial.params ) && isString( partial.params.selector ) && isFunction( partial.ready );
	}

	function getCustomPartial( id ) {
		if ( ! isNonEmptyString( id ) ) {
			return NULL_OBJECT;
		}

		var WP = getWp();

		if ( ! isWpCustomisePreview( WP ) ) {
			return NULL_OBJECT;
		}

		var PARTIAL = WP.customize.selectiveRefresh.partial( id );

		return isCustomPartial( PARTIAL ) ? PARTIAL : NULL_OBJECT;
	}

	function getCustomSelectiveRefreshSelector( id ) {
		var PARTIAL = getCustomPartial( id );

		return !! PARTIAL ? PARTIAL.params.selector : EMPTY_STRING;
	}

	function requestFullRefresh() {
		var WP = getWp();

		if ( ! isWpCustomisePreview( WP ) ) {
			return;
		}

		WP.customize.selectiveRefresh.requestFullRefresh();
	}

	function resetCustomSelectiveRefreshSelector( id ) {
		var PARTIAL = getCustomPartial( id );

		if ( ! PARTIAL ) {
			requestFullRefresh();

			return false;
		}

		PARTIAL.params.selector = EMPTY_STRING;

		return true;
	}

	var CLASS_CUSTOM_PARTIAL_REFRESHING = 'customize-partial-refreshing';
	var DELAY_PARTIAL_REFRESHING = 250;

	function addClass( element, className ) {
		if ( ! isHTMLElement( element ) || ! hasClassList( element ) || ! isFunction( element.classList.add ) || ! isNonEmptyString( className ) ) {
			return;
		}

		element.classList.add( className );
	}

	function removeClass( element, className ) {
		if ( ! isHTMLElement( element ) || ! hasClassList( element ) || ! isFunction( element.classList.remove ) || ! isNonEmptyString( className ) ) {
			return;
		}

		element.classList.remove( className );
	}

	function callIfFunction( callback ) {
		if ( ! isFunction( callback ) ) {
			return;
		}

		callback();
	}

	function isBoolean( value ) {
		return isObjectType( value, 'Boolean' );
	}

	function simulateCustomPartialRefresh( element, callback ) {
		var shouldExecuteCallbackAfterRefresh = arguments.length > 2 && arguments[ 2 ] !== undefined ? arguments[ 2 ] : false;

		if ( ! isHTMLElement( element ) || ! isFunction( callback ) || ! isBoolean( shouldExecuteCallbackAfterRefresh ) ) {
			return;
		}

		var REMOVE_CLASS = removeClass.bind( null, element, CLASS_CUSTOM_PARTIAL_REFRESHING );
		var CALLBACKS = isTrue( shouldExecuteCallbackAfterRefresh ) ? [ REMOVE_CLASS, callback ] : [ callback, REMOVE_CLASS ];

		addClass( element, CLASS_CUSTOM_PARTIAL_REFRESHING );
		setTimeout( function() {
			return forEach( CALLBACKS, callIfFunction );
		}, DELAY_PARTIAL_REFRESHING );
	}

	function updateCustomSelectiveRefreshSelector( id, selector ) {
		if ( ! isNonEmptyString( selector ) ) {
			return;
		}

		var PARTIAL = getCustomPartial( id );

		if ( ! PARTIAL ) {
			return;
		}

		PARTIAL.params.selector = selector;
	}

	function isCustomSetting( setting ) {
		return isFunction( setting ) && isNonEmptyString( setting.id ) && isFunction( setting.bind );
	}

	function bindCustomSetting( id, callback ) {
		if ( ! isNonEmptyString( id ) || ! isFunction( callback ) ) {
			return;
		}

		var WP = getWp();

		if ( ! isWpCustomise( WP ) ) {
			return;
		}

		WP.customize( id, function( setting ) {
			if ( ! isCustomSetting( setting ) ) {
				return;
			}

			setting.bind( function( value ) {
				return callback( value, id );
			} );
		} );
	}

	function onCustomisePreviewOptionChange( id, callback ) {
		bindCustomSetting( id, callback );
	}

	function stringEndsWith( fullString, partialString ) {
		return isNonEmptyString( fullString ) && isNonEmptyString( partialString ) && fullString.substr( fullString.length - partialString.length, partialString.length ) === partialString;
	}

	function isHeadingStyle( id ) {
		return id === CUSTOM_ID_HEADING_STYLE;
	}

	function updateContentHeadingStyle( headingStyle, id ) {
		if ( ! isString( headingStyle ) || ! isHeadingStyle( id ) ) {
			return;
		}

		var SELECTOR = getCustomSelectiveRefreshSelector( id );

		if ( ! isNonEmptyString( SELECTOR ) || ! resetCustomSelectiveRefreshSelector( id ) ) {
			return;
		}

		var ENTRY_CONTENT = getEntryContent();

		if ( ! ENTRY_CONTENT ) {
			return;
		}

		var headingsClassName = EMPTY_STRING;

		forEach( ENTRY_CONTENT.classList, function( className ) {
			if ( stringEndsWith( className, CLASS_CUSTOM_SUFFIX_HEADING_STYLE ) ) {
				headingsClassName = className;

				return true;
			}

			return false;
		} );

		if ( ! isNonEmptyString( headingStyle ) ) {
			return;
		}

		simulateCustomPartialRefresh( ENTRY_CONTENT, function() {
			if ( isNonEmptyString( headingsClassName ) ) {
				removeClass( ENTRY_CONTENT, headingsClassName );
			}

			if ( isNonEmptyString( headingStyle ) ) {
				addClass( ENTRY_CONTENT, headingStyle + CLASS_CUSTOM_SUFFIX_HEADING_STYLE );
			}

			updateCustomSelectiveRefreshSelector( id, SELECTOR );
		} );
	}

	function addHeadingStyleChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_HEADING_STYLE, updateContentHeadingStyle );
	}

	function addHeadingStyleEvents() {
		addHeadingStyleChangeEvent();
	}

	var CLASS_CUSTOM_PREFIX_SITE_HEADER = 'site-header-';
	var CUSTOM_ID_SITE_HEADER_COLOUR = 'site_header_colour';
	var CLASS_SECTION_SITE_HEADER = 'site-header';

	function getSiteHeader() {
		return getElementByClassName( CLASS_SECTION_SITE_HEADER );
	}

	function stringStartsWith( fullString, partialString ) {
		return isNonEmptyString( fullString ) && isNonEmptyString( partialString ) && fullString.indexOf( partialString ) === INDEX_FIRST;
	}

	function isSiteHeaderColour( id ) {
		return id === CUSTOM_ID_SITE_HEADER_COLOUR;
	}

	function updateSiteHeaderColour( siteHeaderColour, id ) {
		if ( ! isNonEmptyString( siteHeaderColour ) || ! isSiteHeaderColour( id ) ) {
			return;
		}

		var SELECTOR = getCustomSelectiveRefreshSelector( id );

		if ( ! isNonEmptyString( SELECTOR ) || ! resetCustomSelectiveRefreshSelector( id ) ) {
			return;
		}

		var SITE_HEADER = getSiteHeader();

		if ( ! SITE_HEADER ) {
			return;
		}

		var siteHeaderColourClassName = EMPTY_STRING;

		forEach( SITE_HEADER.classList, function( className ) {
			if ( stringStartsWith( className, CLASS_CUSTOM_PREFIX_SITE_HEADER ) ) {
				siteHeaderColourClassName = className;

				return true;
			}

			return false;
		} );

		if ( ! isNonEmptyString( siteHeaderColourClassName ) ) {
			return;
		}

		simulateCustomPartialRefresh( SITE_HEADER, function() {
			removeClass( SITE_HEADER, siteHeaderColourClassName );
			addClass( SITE_HEADER, CLASS_CUSTOM_PREFIX_SITE_HEADER + siteHeaderColour );
			updateCustomSelectiveRefreshSelector( id, SELECTOR );
		} );
	}

	function addSiteHeaderColourChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_SITE_HEADER_COLOUR, updateSiteHeaderColour );
	}

	function addSiteHeaderColourEvents() {
		addSiteHeaderColourChangeEvent();
	}

	var ATTRIBUTE_HREF = 'href';
	var CUSTOM_ID_WEBSITE_COLOUR_SCHEME = 'colour_scheme';
	var ID_ERRIGAL_CSS_STYLE = 'errigal-style-css';
	var TAG_LINK = 'link';
	var SELECTOR_CUSTOMISER_ERRIGAL_CSS_STYLE = ''.concat( TAG_LINK, '#' ).concat( ID_ERRIGAL_CSS_STYLE );

	function querySelector( selectors ) {
		var rootElement = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : document;

		return callElementMethod( 'querySelector', selectors, rootElement );
	}

	function getErrigalCssStyle() {
		return querySelector( SELECTOR_CUSTOMISER_ERRIGAL_CSS_STYLE );
	}

	function getAttribute( element, name ) {
		return isHTMLElement( element ) && isFunction( element.getAttribute ) ? element.getAttribute( name ) : NULL_VALUE;
	}

	function setAttribute( element, name, value ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.setAttribute ) || ! isNonEmptyString( name ) ) {
			return;
		}

		element.setAttribute( name, value );
	}

	function updateWebsiteColourScheme( websiteColourScheme ) {
		var CSS_STYLE = getErrigalCssStyle();

		if ( ! CSS_STYLE ) {
			return;
		}

		var CSS_STYLE_HREF = getAttribute( CSS_STYLE, ATTRIBUTE_HREF );

		if ( ! isNonEmptyString( CSS_STYLE_HREF ) ) {
			return;
		}

		var CSS_FILE_NAME = isNonEmptyString( websiteColourScheme ) ? 'style-'.concat( websiteColourScheme, '.min.css' ) : 'style.min.css';

		setAttribute( CSS_STYLE, ATTRIBUTE_HREF, CSS_STYLE_HREF.replace( /style.*.min.css/, CSS_FILE_NAME ) );
	}

	function addWebsiteColourSchemeChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_WEBSITE_COLOUR_SCHEME, updateWebsiteColourScheme );
	}

	function addWebsiteColourSchemeEvents() {
		addWebsiteColourSchemeChangeEvent();
	}

	function addAppearanceEvents() {
		addWebsiteColourSchemeEvents();
		addSiteHeaderColourEvents();
		addHeadingStyleEvents();
	}

	var CUSTOM_ID_BREADCRUMB = 'breadcrumb';
	var EVENT_PARTIAL_CONTENT_RENDERED = 'partial-content-rendered';

	function isCustomPlacement( placement ) {
		return !! placement && isObject( placement.container ) && isObject( placement.partial ) && isNonEmptyString( placement.partial.id ) && isObject( placement.partial.params ) && isString( placement.partial.params.selector );
	}

	function onCustomPartialContentRendered( callback ) {
		if ( ! isFunction( callback ) ) {
			return;
		}

		var WP = getWp();

		if ( ! isWpCustomisePreview( WP ) ) {
			return;
		}

		WP.customize.selectiveRefresh.bind( EVENT_PARTIAL_CONTENT_RENDERED, function( placement ) {
			if ( ! isCustomPlacement( placement ) ) {
				return;
			}

			callback( placement.partial.id, placement );
		} );
	}

	var CLASS_SHARED_COLLAPSED = 'collapsed';
	var CLASS_NAV_BREADCRUMB_LIST = 'errigal-breadcrumb__list';

	function getBreadcrumbList() {
		return getElementByClassName( CLASS_NAV_BREADCRUMB_LIST );
	}

	var CLASS_NAV_BREADCRUMB_LIST_ITEM = 'errigal-breadcrumb__list-item';

	function getBreadcrumbListItems() {
		return getElementsByClassName( CLASS_NAV_BREADCRUMB_LIST_ITEM );
	}

	var RECT_WIDTH = 'width';
	var PIXEL_ZERO = 0;

	function getRectProp( element, property ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.getBoundingClientRect ) ) {
			return PIXEL_ZERO;
		}

		var RECT_PROP = getObjectValue( element.getBoundingClientRect(), property );

		return isNumber( RECT_PROP ) ? RECT_PROP : PIXEL_ZERO;
	}

	function getWidth( element ) {
		return getRectProp( element, RECT_WIDTH );
	}

	function toggleClass( add, element, className ) {
		if ( ! isBoolean( add ) ) {
			return;
		}

		var TOGGLE_CLASS = isTrue( add ) ? addClass : removeClass;

		TOGGLE_CLASS( element, className );
	}

	var CLASS_NAV_BREADCRUMB_LIST_ITEM_ANCESTOR = 'errigal-breadcrumb__ancestor';

	function getBreadcrumbAncestorListItems() {
		return getElementsByClassName( CLASS_NAV_BREADCRUMB_LIST_ITEM_ANCESTOR );
	}

	var CLASS_NAV_BREADCRUMB_REVEAL_BUTTON = 'errigal-breadcrumb__reveal-button';

	function getBreadcrumbRevealButton() {
		return getElementByClassName( CLASS_NAV_BREADCRUMB_REVEAL_BUTTON );
	}

	var CLASS_NAV_BREADCRUMB_LIST_ITEM_REVEAL = 'errigal-breadcrumb__reveal';

	function getBreadcrumbRevealListItem() {
		return getElementByClassName( CLASS_NAV_BREADCRUMB_LIST_ITEM_REVEAL );
	}

	var ATTRIBUTE_ARIA_EXPANDED = 'aria-expanded';

	function toggleAriaExpanded( expanded ) {
		if ( ! isBoolean( expanded ) ) {
			return;
		}

		for ( var _len = arguments.length, elements = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			elements[ _key - 1 ] = arguments[ _key ];
		}

		forEach( elements, function( element ) {
			return setAttribute( element, ATTRIBUTE_ARIA_EXPANDED, isTrue( expanded ) );
		} );
	}

	var ATTRIBUTE_ARIA_HIDDEN = 'aria-hidden';

	function toggleAriaHidden( hidden ) {
		if ( ! isBoolean( hidden ) ) {
			return;
		}

		for ( var _len = arguments.length, elements = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			elements[ _key - 1 ] = arguments[ _key ];
		}

		forEach( elements, function( element ) {
			return setAttribute( element, ATTRIBUTE_ARIA_HIDDEN, isTrue( hidden ) );
		} );
	}

	function _toConsumableArray( r ) {
		return _arrayWithoutHoles( r ) || _iterableToArray( r ) || _unsupportedIterableToArray( r ) || _nonIterableSpread();
	}

	function _nonIterableSpread() {
		throw new TypeError( 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' );
	}

	function _unsupportedIterableToArray( r, a ) {
		if ( r ) {
			if ( 'string' === typeof r ) {
				return _arrayLikeToArray( r, a );
			} var t = {}.toString.call( r ).slice( 8, -1 ); return 'Object' === t && r.constructor && ( t = r.constructor.name ), 'Map' === t || 'Set' === t ? Array.from( r ) : 'Arguments' === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test( t ) ? _arrayLikeToArray( r, a ) : void 0;
		}
	}

	function _iterableToArray( r ) {
		if ( 'undefined' !== typeof Symbol && null != r[ Symbol.iterator ] || null != r[ '@@iterator' ] ) {
			return Array.from( r );
		}
	}

	function _arrayWithoutHoles( r ) {
		if ( Array.isArray( r ) ) {
			return _arrayLikeToArray( r );
		}
	}

	function _arrayLikeToArray( r, a ) {
		( null == a || a > r.length ) && ( a = r.length ); for ( var e = 0, n = Array( a ); e < a; e++ ) {
			n[ e ] = r[ e ];
		} return n;
	}

	function toggleBreadcrumbRevealAndAncestorAriaAttributes( isAncestorHidden ) {
		toggleAriaExpanded( ! isAncestorHidden, getBreadcrumbRevealButton() );
		toggleAriaHidden( ! isAncestorHidden, getBreadcrumbRevealListItem() );
		toggleAriaHidden.apply( void 0, [ isAncestorHidden ].concat( _toConsumableArray( getBreadcrumbAncestorListItems() ) ) );
	}

	function isBreadcrumbListWrapped() {
		var totalWidth = 0;
		var BREADCRUMB_LIST_WIDTH = getWidth( getBreadcrumbList() );

		return forEach( getBreadcrumbListItems(), function( item ) {
			return ( totalWidth += getWidth( item ) ) >= BREADCRUMB_LIST_WIDTH;
		} );
	}

	function toggleBreadcrumbAncestor() {
		var IS_BREADCRUMB_LIST_WRAPPED = isBreadcrumbListWrapped();

		toggleClass( IS_BREADCRUMB_LIST_WRAPPED, getBreadcrumbList(), CLASS_SHARED_COLLAPSED );
		toggleBreadcrumbRevealAndAncestorAriaAttributes( IS_BREADCRUMB_LIST_WRAPPED );
	}

	function isBreadcrumb( id ) {
		return id === CUSTOM_ID_BREADCRUMB;
	}

	function updateBreadcrumbAncestorVisibility( id ) {
		if ( ! isBreadcrumb( id ) ) {
			return;
		}

		toggleBreadcrumbAncestor();
	}

	function addBreadcrumbChangeEvent() {
		onCustomPartialContentRendered( updateBreadcrumbAncestorVisibility );
	}

	function addBreadcrumbEvents() {
		addBreadcrumbChangeEvent();
	}

	var CUSTOM_ID_BASE_FONT = 'base_font';
	var ID_ERRIGAL_CSS_BASE_FONT_STYLE = 'errigal-base-google-font-style-css';
	var SELECTOR_CUSTOMISER_ERRIGAL_CSS_BASE_FONT_STYLE = ''.concat( TAG_LINK, '#' ).concat( ID_ERRIGAL_CSS_BASE_FONT_STYLE );

	function getErrigalCssBaseFontStyle() {
		return querySelector( SELECTOR_CUSTOMISER_ERRIGAL_CSS_BASE_FONT_STYLE );
	}

	var CSS_FONT_FAMILY = 'font-family';
	var CUSTOM_TYPOGRAPHY_GOOGLE_FONT_FAMILY_URL = '//fonts.googleapis.com/css?family=';
	var FONT_FALLBACK = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif';
	var ID_ERRIGAL_CSS_INLINE_STYLE = 'errigal-style-inline-css';
	var TAG_STYLE = 'style';
	var SELECTOR_CUSTOMISER_ERRIGAL_CSS_INLINE_STYLE = ''.concat( TAG_STYLE, '#' ).concat( ID_ERRIGAL_CSS_INLINE_STYLE );

	function toLowerCase( value ) {
		return isNonEmptyString( value ) && isFunction( value.toLowerCase ) ? value.toLowerCase() : EMPTY_STRING;
	}

	function areStringsEqualIgnoreCase( str1, str2 ) {
		return toLowerCase( str1 ) === toLowerCase( str2 );
	}

	function hasTagName( element ) {
		return !! element && isNonEmptyString( element.tagName );
	}

	function isElementOfType( element, tagName ) {
		return hasTagName( element ) && isNonEmptyString( tagName ) && areStringsEqualIgnoreCase( element.tagName, tagName );
	}

	function isHTMLElementOfType( tagName, element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 2 ? _len - 2 : 0 ), _key = 2; _key < _len; _key++ ) {
			classNames[ _key - 2 ] = arguments[ _key ];
		}

		return isHTMLElement.apply( void 0, [ element ].concat( classNames ) ) && isElementOfType( element, tagName );
	}

	function isStyleElement( element ) {
		return isHTMLElementOfType( TAG_STYLE, element );
	}

	function isCssRuleList( element ) {
		return element instanceof CSSRuleList;
	}

	function isCssStyleSheet( element ) {
		return element instanceof CSSStyleSheet;
	}

	function isCssInlineStyle( element ) {
		return isStyleElement( element ) && isCssStyleSheet( element.sheet ) && isCssRuleList( element.sheet.cssRules ) && isIterable( element.sheet.cssRules );
	}

	function getErrigalCssInlineStyle() {
		var CSS_INLINE_STYLE = querySelector( SELECTOR_CUSTOMISER_ERRIGAL_CSS_INLINE_STYLE );

		return isCssInlineStyle( CSS_INLINE_STYLE ) ? CSS_INLINE_STYLE : NULL_ELEMENT;
	}

	var OBJECT_NAME_FONT_FAMILIES = 'ERRIGAL_FONT_FAMILIES';

	function getFontFamiliesObject() {
		return getGlobalObject( OBJECT_NAME_FONT_FAMILIES );
	}

	var OBJECT_NAME_FONT_NAMES = 'ERRIGAL_FONT_NAMES';

	function getFontNamesObject() {
		return getGlobalObject( OBJECT_NAME_FONT_NAMES );
	}

	function isCssStyleRule( element ) {
		return element instanceof CSSStyleRule;
	}

	function getCssStyleRule( cssInlineStyle, cssRuleId ) {
		if ( ! isCssInlineStyle( cssInlineStyle ) ) {
			return NULL_OBJECT;
		}

		var CSS_STYLE_RULE = getObjectValue( cssInlineStyle.sheet.cssRules, cssRuleId );

		return isCssStyleRule( CSS_STYLE_RULE ) ? CSS_STYLE_RULE : NULL_OBJECT;
	}

	function hasStyle( element ) {
		return !! element && element.style instanceof CSSStyleDeclaration && isFunction( element.style.setProperty );
	}

	function isStyleProperty( property ) {
		return isString( property ) && hasStyle( document.documentElement ) && property in document.documentElement.style;
	}

	function updateInlineStyle( element, property, value, isPriority ) {
		if ( ! element || ! hasStyle( element ) || ! isStyleProperty( property ) || ! ( isString( value ) || isNumber( value ) ) || ! isBoolean( isPriority ) ) {
			return;
		}

		if ( isTrue( isPriority ) ) {
			element.style.setProperty( property, value, 'important' );

			return;
		}

		element.style.setProperty( property, value );
	}

	function updateCssInlineStyle( cssInlineStyle, cssRuleId, property, value ) {
		var isPriority = arguments.length > 4 && arguments[ 4 ] !== undefined ? arguments[ 4 ] : false;

		updateInlineStyle( getCssStyleRule( cssInlineStyle, cssRuleId ), property, value, isPriority );
	}

	function getFontName( fontName ) {
		var FONT_NAME = getObjectValue( getFontNamesObject(), fontName );

		return isNonEmptyString( FONT_NAME ) ? FONT_NAME : EMPTY_STRING;
	}

	function getFontFamily( fontName ) {
		var FONT_FAMILY = getObjectValue( getFontFamiliesObject(), fontName );

		return isNonEmptyString( FONT_FAMILY ) ? FONT_FAMILY : EMPTY_STRING;
	}

	function updateInlineFontStyle( fontName, cssFontStyleElement, cssRuleId ) {
		if ( ! isHTMLElement( cssFontStyleElement ) || ! isNumber( cssRuleId ) ) {
			return;
		}

		var FONT_FAMILY = getFontFamily( fontName );

		if ( ! isNonEmptyString( FONT_FAMILY ) ) {
			return;
		}

		var FONT_NAME = getFontName( fontName );

		if ( ! isNonEmptyString( FONT_NAME ) ) {
			return;
		}

		var CSS_INLINE_STYLE = getErrigalCssInlineStyle();

		if ( ! CSS_INLINE_STYLE ) {
			return;
		}

		setAttribute( cssFontStyleElement, ATTRIBUTE_HREF, CUSTOM_TYPOGRAPHY_GOOGLE_FONT_FAMILY_URL + FONT_FAMILY );
		updateCssInlineStyle( CSS_INLINE_STYLE, cssRuleId, CSS_FONT_FAMILY, '"'.concat( FONT_NAME, '", ' ).concat( FONT_FALLBACK ) );
	}

	function updateBaseFont( fontName ) {
		updateInlineFontStyle( fontName, getErrigalCssBaseFontStyle(), INDEX_FIRST );
	}

	function addBaseFontChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_BASE_FONT, updateBaseFont );
	}

	function addBaseFontEvents() {
		addBaseFontChangeEvent();
	}

	var CUSTOM_ID_FONT_SIZE = 'font_size';
	var OBJECT_NAME_FONT_SIZES = 'ERRIGAL_FONT_SIZES';

	function getFontSizesObject() {
		var FONT_SIZES = getGlobalObject( OBJECT_NAME_FONT_SIZES );

		return isStringArray( FONT_SIZES ) ? FONT_SIZES : NULL_OBJECT;
	}

	function updateFontSize( fontSize ) {
		if ( ! isNonEmptyString( fontSize ) ) {
			return;
		}

		var FONT_SIZES = getFontSizesObject();

		if ( ! FONT_SIZES || ! FONT_SIZES.includes( fontSize ) ) {
			return;
		}

		forEach( FONT_SIZES, function( fontSize ) {
			return removeClass( document.documentElement, fontSize );
		} );
		addClass( document.documentElement, fontSize );
	}

	function addFontSizeChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_FONT_SIZE, updateFontSize );
	}

	function addFontSizeEvents() {
		addFontSizeChangeEvent();
	}

	var CUSTOM_ID_HEADING_FONT = 'heading_font';
	var INDEX_SECOND = 1;
	var ID_ERRIGAL_CSS_HEADING_FONT_STYLE = 'errigal-heading-google-font-style-css';
	var SELECTOR_CUSTOMISER_ERRIGAL_CSS_HEADING_FONT_STYLE = ''.concat( TAG_LINK, '#' ).concat( ID_ERRIGAL_CSS_HEADING_FONT_STYLE );

	function getErrigalCssHeadingFontStyle() {
		return querySelector( SELECTOR_CUSTOMISER_ERRIGAL_CSS_HEADING_FONT_STYLE );
	}

	function updateHeadingFont( fontName ) {
		updateInlineFontStyle( fontName, getErrigalCssHeadingFontStyle(), INDEX_SECOND );
	}

	function addHeadingFontChangeEvent() {
		onCustomisePreviewOptionChange( CUSTOM_ID_HEADING_FONT, updateHeadingFont );
	}

	function addHeadingFontEvents() {
		addHeadingFontChangeEvent();
	}

	function addFontSettingsEvents() {
		addBaseFontEvents();
		addHeadingFontEvents();
		addFontSizeEvents();
	}

	var CUSTOMISER_SECTION_ID_FOOTER = 'footer';
	var CLASS_SECTION_SITE_FOOTER = 'site-footer';

	function getSiteFooter() {
		return getElementByClassName( CLASS_SECTION_SITE_FOOTER );
	}

	var EVENT_SECTION_TOGGLE = 'section-toggle';

	function isCustomiseSectionToggleMessage( message, sectionId ) {
		return !! message && isNonEmptyString( sectionId ) && message.sectionId === sectionId && isBoolean( message.isExpanded );
	}

	function onCustomisePreviewSectionToggle( sectionId, callback ) {
		if ( ! isNonEmptyString( sectionId ) || ! isFunction( callback ) ) {
			return;
		}

		var WP = getWp();

		if ( ! isWpCustomisePreview( WP ) ) {
			return;
		}

		WP.customize.preview.bind( EVENT_SECTION_TOGGLE, function( message ) {
			if ( ! isCustomiseSectionToggleMessage( message, sectionId ) ) {
				return;
			}

			callback( message.isExpanded );
		} );
	}

	var POSITION_ZERO = 0;
	var SCROLL_DISTANCE_LONG = 2000;
	var SCROLL_DISTANCE_MODERATE = 1000;
	var SCROLL_DISTANCE_SHORT = 200;
	var SCROLL_DURATION_MODERATE = 200;
	var SCROLL_DURATION_NORMAL = 300;
	var SCROLL_DURATION_SLOW = 400;
	var SCROLL_DURATION_SWIFT = 50;
	var CLASS_ACCESSIBILITY_SKIP_LINK = 'skip-link';

	function getSkipLink() {
		return getElementByClassName( CLASS_ACCESSIBILITY_SKIP_LINK );
	}

	var TAG_A = 'a';

	function isAnchorElement( element ) {
		for ( var _len = arguments.length, classNames = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			classNames[ _key - 1 ] = arguments[ _key ];
		}

		return isHTMLElementOfType.apply( void 0, [ TAG_A, element ].concat( classNames ) );
	}

	var ATTRIBUTE_TABINDEX = 'tabIndex';
	var ATTRIBUTE_VALUE_MINUS_ONE = '-1';

	function setTabIndex( element ) {
		setAttribute( element, ATTRIBUTE_TABINDEX, ATTRIBUTE_VALUE_MINUS_ONE );
	}

	function getPageHeight() {
		return Math.max( document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight );
	}

	function isIe() {
		return !! window.MSInputMethodContext && !! document.documentMode;
	}

	function getScrollLeft() {
		return isIe() ? window.pageXOffset : window.scrollX || document.documentElement.scrollLeft;
	}

	function getScrollTop() {
		return isIe() ? window.pageYOffset : window.scrollY || document.documentElement.scrollTop;
	}

	function getViewportHeight() {
		return window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
	}

	var NUMBER_ZERO = 0;
	var RADIX_DECIMAL = 10;

	function parseDecimalInt( value ) {
		var PARSED_INT = parseInt( value, RADIX_DECIMAL );

		return isNumber( PARSED_INT ) ? PARSED_INT : NUMBER_ZERO;
	}

	var TAG_BUTTON = 'button';
	var TAG_INPUT = 'input';
	var TAG_SELECT = 'select';
	var TAG_TEXTAREA = 'textarea';
	var TAGS_FOCUSABLE_ELEMENTS = [ TAG_A, TAG_BUTTON, TAG_INPUT, TAG_SELECT, TAG_TEXTAREA ];

	function isFocusableElement( element ) {
		if ( ! isHTMLElement( element ) || ! hasTagName( element ) ) {
			return false;
		}

		var TAG_NAME = element.tagName;

		return forEach( TAGS_FOCUSABLE_ELEMENTS, function( tagName ) {
			return areStringsEqualIgnoreCase( tagName, TAG_NAME );
		} );
	}

	function isNullOrEmpty( value ) {
		return ! value || value === EMPTY_STRING;
	}

	var CALLBACK_INITIAL_ATTEMPT_COUNT = 0;
	var CALLBACK_INITIAL_INTERVAL = 0;
	var CALLBACK_INTERVAL = 50;
	var CALLBACK_MAX_ATTEMPT_COUNT = 20;

	function focusElement( element ) {
		var attemptCount = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : CALLBACK_INITIAL_ATTEMPT_COUNT;
		var interval = arguments.length > 2 && arguments[ 2 ] !== undefined ? arguments[ 2 ] : CALLBACK_INITIAL_INTERVAL;

		if ( ! isHTMLElement( element ) || ! isFunction( element.focus ) || ! isNumber( attemptCount ) || ! isNumber( interval ) || attemptCount === CALLBACK_MAX_ATTEMPT_COUNT ) {
			return;
		}

		element.focus();
		setTimeout( function() {
			if ( element === document.activeElement ) {
				return;
			}

			focusElement( element, ++attemptCount, CALLBACK_INTERVAL );
		}, interval );
	}

	var DISTANCE_REM_LG = 2;
	var RECT_TOP = 'top';

	function getViewportTop( element ) {
		return getRectProp( element, RECT_TOP );
	}

	function getPageTop( element ) {
		return getViewportTop( element ) + getScrollTop();
	}

	var CSS_FONT_SIZE = 'font-size';

	function getStyleProp( element, property ) {
		if ( ! isHTMLElement( element ) ) {
			return NULL_VALUE;
		}

		var STYLE_PROP = getObjectValue( window.getComputedStyle( element ), property );

		return isString( STYLE_PROP ) ? STYLE_PROP : NULL_VALUE;
	}

	function getStylePropFloat( element, property ) {
		var STYLE_PROP = parseFloat( getStyleProp( element, property ) );

		return isNumber( STYLE_PROP ) ? STYLE_PROP : PIXEL_ZERO;
	}

	function convertRemToPx( rem ) {
		return isNumber( rem ) ? getStylePropFloat( document.documentElement, CSS_FONT_SIZE ) * rem : PIXEL_ZERO;
	}

	var CLASS_SHARED_STICKY = 'sticky';

	function isSiteHeader( element ) {
		return isHTMLElement( element, CLASS_SECTION_SITE_HEADER );
	}

	var RECT_HEIGHT = 'height';

	function getHeight( element ) {
		return getRectProp( element, RECT_HEIGHT );
	}

	var RECT_BOTTOM = 'bottom';

	function getViewportBottom( element ) {
		return getRectProp( element, RECT_BOTTOM );
	}

	function getLastItem( items ) {
		return isIterable( items ) ? items[ items.length - 1 ] : NULL_VALUE;
	}

	var CSS_POSITION = 'position';
	var CSS_VALUE_FIXED = 'fixed';

	function isFixedElement( element ) {
		return areStringsEqualIgnoreCase( getStyleProp( element, CSS_POSITION ), CSS_VALUE_FIXED );
	}

	function getSiteHeaderStickyElements( siteHeader ) {
		return isSiteHeader( siteHeader ) ? getElementsByClassName( CLASS_SHARED_STICKY, siteHeader ) : NULL_ELEMENT;
	}

	function getFixedElementHeight() {
		var SITE_HEADER = getSiteHeader();

		if ( ! SITE_HEADER ) {
			return PIXEL_ZERO;
		}

		return isFixedElement( SITE_HEADER ) ? getHeight( SITE_HEADER ) : getViewportBottom( getLastItem( getSiteHeaderStickyElements( SITE_HEADER ) ) );
	}

	function getClearTopOffset() {
		return convertRemToPx( DISTANCE_REM_LG );
	}

	function getAdjustedElementPageTop( element ) {
		var TARGET_ELEMENT_PAGE_TOP = getPageTop( element );

		return TARGET_ELEMENT_PAGE_TOP === POSITION_ZERO ? TARGET_ELEMENT_PAGE_TOP : TARGET_ELEMENT_PAGE_TOP - getFixedElementHeight() - getClearTopOffset();
	}

	function getStartTime() {
		return performance.now();
	}

	function focusScrollTargetElement( element ) {
		if ( ! isHTMLElement( element ) ) {
			return;
		}

		if ( ! isFocusableElement( element ) ) {
			setTabIndex( element );
		}

		var SCROLL_LEFT = getScrollLeft();
		var SCROLL_TOP = getScrollTop();

		focusElement( element );
		window.scrollTo( SCROLL_LEFT, SCROLL_TOP );
	}

	function isBackToTopDestinationElement( element ) {
		return isHTMLElement( element ) || isAnchorElement( element ) ? element === document.documentElement || element === getSkipLink() : false;
	}

	function isPageScrolledToBottom() {
		return getViewportHeight() + getScrollTop() >= getPageHeight();
	}

	function isAtDestination( element ) {
		return parseDecimalInt( getScrollTop() ) === parseDecimalInt( getAdjustedElementPageTop( element ) );
	}

	function shouldScroll( element ) {
		return isHTMLElement( element ) ? ! ( isAtDestination( element ) || isPageScrolledToBottom() ) || isBackToTopDestinationElement( element ) : false;
	}

	function scrollTo( element, duration ) {
		if ( ! isHTMLElement( element ) ) {
			return;
		}

		if ( ! shouldScroll( element ) ) {
			focusScrollTargetElement( element );

			return;
		}

		if ( ! isNumber( duration ) ) {
			var DISTANCE = Math.abs( getScrollTop() - getAdjustedElementPageTop( element ) );

			switch ( true ) {
				case DISTANCE < SCROLL_DISTANCE_SHORT:
					duration = SCROLL_DURATION_SWIFT;
					break;
				case DISTANCE < SCROLL_DISTANCE_MODERATE:
					duration = SCROLL_DURATION_MODERATE;
					break;
				case DISTANCE < SCROLL_DISTANCE_LONG:
					duration = SCROLL_DURATION_NORMAL;
					break;
				default:
					duration = SCROLL_DURATION_SLOW;
			}
		}

		var START_TIME = getStartTime();

		step( START_TIME, element, START_TIME, parseDecimalInt( duration ) );

		function step( timeStamp, element, startTime, duration ) {
			if ( isNullOrEmpty( timeStamp ) ) {
				timeStamp = startTime;
			}

			if ( ! isNumber( timeStamp ) || ! isHTMLElement( element ) || ! isNumber( startTime ) || ! isNumber( duration ) ) {
				return;
			}

			var DESTINATION_ELEMENT_PAGE_TOP = getAdjustedElementPageTop( element );
			var PROGRESSED_TIME = timeStamp - startTime;

			if ( PROGRESSED_TIME < duration && duration !== PIXEL_ZERO ) {
				var SCROLL_TOP = getScrollTop();
				var TIME = Math.min( 1, PROGRESSED_TIME / duration );
				var _DISTANCE = ( DESTINATION_ELEMENT_PAGE_TOP - SCROLL_TOP ) * TIME;

				window.scrollTo( POSITION_ZERO, SCROLL_TOP + _DISTANCE );
				requestAnimationFrame( function( currentTime ) {
					return step( currentTime, element, startTime, duration );
				} );

				return;
			}

			window.scrollTo( POSITION_ZERO, DESTINATION_ELEMENT_PAGE_TOP );
			focusScrollTargetElement( element );

			if ( ! isNonEmptyString( element.id ) ) {
				return;
			}

			history.pushState( null, '', '#'.concat( element.id ) );
		}
	}

	function scrollToSiteFooter( isExpanded ) {
		if ( isTrue( isExpanded ) ) {
			scrollTo( getSiteFooter() );
		}
	}

	function addFooterSectionToggleEvent() {
		onCustomisePreviewSectionToggle( CUSTOMISER_SECTION_ID_FOOTER, scrollToSiteFooter );
	}

	function addFooterEvents() {
		addFooterSectionToggleEvent();
	}

	var CUSTOM_ID_TAGLINE = 'blogdescription';
	var CUSTOM_ID_SITE_TITLE = 'blogname';
	var CUSTOM_IDS_SITE_IDENTITY_TEXTS = [ CUSTOM_ID_SITE_TITLE, CUSTOM_ID_TAGLINE ];
	var CUSTOM_ID_LOGO = 'custom_logo';

	function isLogo( id ) {
		return id === CUSTOM_ID_LOGO;
	}

	function filter( items, callback ) {
		return !! items && isFunction( items.filter ) && isFunction( callback ) ? items.filter( callback ) : NULL_VALUE;
	}

	function addCustomPartialEditShortcut( id ) {
		var PARTIAL = getCustomPartial( id );

		if ( ! PARTIAL ) {
			return;
		}

		PARTIAL.ready();
	}

	function addCustomPartialEditShortcuts( ids ) {
		var excludeId = arguments.length > 1 && arguments[ 1 ] !== undefined ? arguments[ 1 ] : null;

		forEach( filter( ids, function( id ) {
			return isNonEmptyString( id ) && id !== excludeId;
		} ), addCustomPartialEditShortcut );
	}

	function addSiteIdentityTextEditShortcuts( id ) {
		if ( ! isLogo( id ) ) {
			return;
		}

		addCustomPartialEditShortcuts( CUSTOM_IDS_SITE_IDENTITY_TEXTS, id );
	}

	function addLogoChangeEvent() {
		onCustomPartialContentRendered( addSiteIdentityTextEditShortcuts );
	}

	function addLogoEvents() {
		addLogoChangeEvent();
	}

	var CSS_MARGIN_TOP = 'margin-top';
	var CSS_VALUE_ZERO = 0;
	var CLASS_CUSTOM_SITE_IDENTITY_TAGLINE = 'brand-tagline';

	function getSiteIdentityTagline() {
		return getElementByClassName( CLASS_CUSTOM_SITE_IDENTITY_TAGLINE );
	}

	var ATTRIBUTE_STYLE = 'style';

	function removeAttribute( element ) {
		if ( ! isHTMLElement( element ) || ! isFunction( element.removeAttribute ) ) {
			return;
		}

		for ( var _len = arguments.length, names = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			names[ _key - 1 ] = arguments[ _key ];
		}

		forEach( names, function( name ) {
			return element.removeAttribute( name );
		} );
	}

	function resetElementInlineStyle( element ) {
		if ( ! isHTMLElement( element ) || ! hasStyle( element ) ) {
			return;
		}

		for ( var _len = arguments.length, properties = new Array( _len > 1 ? _len - 1 : 0 ), _key = 1; _key < _len; _key++ ) {
			properties[ _key - 1 ] = arguments[ _key ];
		}

		forEach( filter( properties, function( property ) {
			return property in element.style;
		} ), function( property ) {
			return element.style[ property ] = EMPTY_STRING;
		} );

		if ( ! isNonEmptyString( element.style.cssText ) ) {
			removeAttribute( element, ATTRIBUTE_STYLE );
		}
	}

	function updateElementInlineStyle( element, property, value ) {
		var isPriority = arguments.length > 3 && arguments[ 3 ] !== undefined ? arguments[ 3 ] : false;

		if ( ! isHTMLElement( element ) ) {
			return;
		}

		updateInlineStyle( element, property, value, isPriority );
	}

	var EVENT_LOAD = 'load';

	function isUndefined( value ) {
		return isObjectType( value, 'Undefined' );
	}

	function onWindowEvent( eventType, callback, options ) {
		if ( ! isNonEmptyString( eventType ) || ! isFunction( callback ) || ! ( isUndefined( options ) || isObject( options ) || isBoolean( options ) ) ) {
			return;
		}

		window.addEventListener( eventType, callback, options || false );
	}

	function onWindowLoad( callback, options ) {
		onWindowEvent( EVENT_LOAD, callback, options );
	}

	function hasTextContent( element ) {
		return !! element && isNonEmptyString( element.textContent );
	}

	function toggleTaglineMarginTop() {
		var SITE_IDENTITY_TAGLINE = getSiteIdentityTagline();

		if ( ! SITE_IDENTITY_TAGLINE ) {
			return;
		}

		if ( ! hasTextContent( SITE_IDENTITY_TAGLINE ) ) {
			updateElementInlineStyle( SITE_IDENTITY_TAGLINE, CSS_MARGIN_TOP, CSS_VALUE_ZERO );

			return;
		}

		resetElementInlineStyle( SITE_IDENTITY_TAGLINE, CSS_MARGIN_TOP );
	}

	function isTagline( id ) {
		return id === CUSTOM_ID_TAGLINE;
	}

	function updateTaglineMarginTop( id ) {
		if ( ! ( isTagline( id ) || isLogo( id ) ) ) {
			return;
		}

		toggleTaglineMarginTop();
	}

	function addTaglineChangeEvent() {
		onCustomPartialContentRendered( updateTaglineMarginTop );
	}

	function addTaglineEvents() {
		addTaglineChangeEvent();
		onWindowLoad( toggleTaglineMarginTop );
	}

	function addSiteIdentityEvents() {
		addLogoEvents();
		addTaglineEvents();
	}

	function addCustomisePreviewEvents() {
		onCustomisePreviewReady( function() {
			addSiteIdentityEvents();
			addAppearanceEvents();
			addFontSettingsEvents();
			addBreadcrumbEvents();
			addFooterEvents();
		} );
	}

	addCustomisePreviewEvents();
}() );
