(function (factory) {
  typeof define === 'function' && define.amd ? define(factory) :
  factory();
}((function () { 'use strict';

  /**
   * EdGEL loading spinner.
   */
  if (!document.body) {
    throw new Error('The preloader.js script should be loaded in the body.')
  }

  // Hide the body content.
  document.body.classList.add('preloader');

  // Add the preloader to the body.
  // TODO: Improve accessibility with aria-live/aria-relevant?  Post load notification required?
  document.write('<div role="alert" aria-label="Please wait, content loading" class="preloader-spinner"><div></div><div></div><div></div><div></div></div>');

  // Remove the preloader and stop hiding content when we receive the edgelPageRendered custom event.
  // This is raised by the EdGelPageElement lit-element.
  window.addEventListener('edgelPageRendered', () => {
    document.body.classList.remove('preloader');
    const elements = document.getElementsByClassName('preloader-spinner');

    if (elements.length) {
      const spinner = elements[0];
      spinner.remove();
    }
  });

})));
//# sourceMappingURL=preloader.js.map
