function defineGlobalNameSpace(globalObject, globalName) {
  return globalObject || defineGlobalObject(globalName);
}
function defineGlobalObject(globalName) {
  var globalNameSpace = {
    globalName: globalName,
    namespace: function namespace(newNamespace, parent) {
      parent = parent || this.globalObject;
      var parts = newNamespace.split('.');
      var startIndex = parts[0] === this.globalName ? 1 : 0;
      for (var j = startIndex; j < parts.length; j++) {
        var part = parts[j];
        parent[part] = parent[part] || {};
        parent = parent[part];
      }
      return parent;
    }
  };
  globalNameSpace.globalObject = globalNameSpace;
  return globalNameSpace;
}
var GALE = defineGlobalNameSpace(GALE, 'GALE');
var AUTH = defineGlobalNameSpace(AUTH, 'AUTH');
var StorageUtil = {
  NAMESPACE: 'galeApps',
  getLocalStorageData: function getLocalStorageData(key) {
    return this.getLocalStorage().get(key);
  },
  setLocalStorageData: function setLocalStorageData(key, value) {
    this.getLocalStorage().set(key, value);
  },
  getLocalStorage: function getLocalStorage() {
    if (!this.localStorage) {
      this.localStorage = this.getNamespace().localStorage;
    }
    return this.localStorage;
  },
  getNamespace: function getNamespace() {
    return Storages.initNamespaceStorage(this.NAMESPACE); // eslint-disable-line no-undef
  }
};
(function ($, _parent) {
  function getLocationHostname() {
    return getWindow().location.hostname;
  }
  function getLocationHref() {
    return getWindow().location.href;
  }
  function getLocationPort() {
    return getWindow().location.port;
  }
  function getLocationSearch() {
    return getWindow().location.search;
  }
  function getTimezone() {
    return getWindow().moment.tz.guess(true);
  }
  function redirectToPage(url) {
    getWindow().location.href = url;
  }
  function getWindow() {
    return window; // eslint-disable-line no-undef
  }
  _parent.uriUtils = {
    getLocationHostname: getLocationHostname,
    getLocationHref: getLocationHref,
    getLocationPort: getLocationPort,
    getLocationSearch: getLocationSearch,
    getTimezone: getTimezone,
    redirectToPage: redirectToPage
  };
})(jQuery, GALE);
(function ($, _parent) {
  function getFullYear(date) {
    var dateObj = date ? new Date(date) : new Date();
    return dateObj.getFullYear();
  }
  _parent.DateUtils = {
    getFullYear: getFullYear
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    $(document).on('click', '.js-shibboleth-auth-link', function (e) {
      e.preventDefault();
      var redirectUrl = $('.js-shibboleth-auth-link').attr('data-url');
      GALE.additionalShibbolethPrompt.getWindow().location.href = decodeURIComponent(redirectUrl);
    });
  }

  /* istanbul ignore next */
  function getWindow() {
    return window;
  }
  _parent.additionalShibbolethPrompt = {
    init: init,
    getWindow: getWindow
  };
})(jQuery, GALE);
(function ($, _parent) {
  var CATEGORY_PRODUCTS_SELECTOR = '.js-category-products';
  var PRODUCT_CATEGORY_OPTIONS_SELECTOR = '.js-product-category-options';
  var PRODUCT_CATEGORY_OPTION_SELECTOR = '.js-product-category-option';
  function init() {
    GALE.menu.initBranding();
    $(PRODUCT_CATEGORY_OPTIONS_SELECTOR).on('click', PRODUCT_CATEGORY_OPTION_SELECTOR, function () {
      $(CATEGORY_PRODUCTS_SELECTOR).addClass('hide');
      $(PRODUCT_CATEGORY_OPTION_SELECTOR).attr('aria-selected', false);
      $(this).attr('aria-selected', true);
      $("".concat(CATEGORY_PRODUCTS_SELECTOR, ".").concat($(this).data('productCategory'))).removeClass('hide');
    });
    GALE.languageDropDown.init();
  }
  _parent.adultLearning = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    $(document).on('click', '.js_ag_submit__btn', function (e) {
      e.preventDefault();
      var minAgeGate = $('.js-min-age').val();
      $('.js-udemy-age, .js-udemy-terms').empty();
      var birthYear = $('.birth-18').val();
      if (birthYear === "") {
        $('.js-udemy-age').html('<p>* Please enter your birth year.</p>');
        return false;
      }
      if (GALE.DateUtils.getFullYear() - GALE.DateUtils.getFullYear(birthYear) < minAgeGate) {
        $('.js-udemy-age').html("<p>* Must be ".concat(minAgeGate, " years of age or older to sign up.</p>"));
        return false;
      }
      if ($('.js_privacy').prop('checked') !== true) {
        $('.js-udemy-terms').html('<p>* To create an account, you must accept the terms of use.</p>');
        return false;
      }
      $("#age-form").trigger('submit');
    });
  }
  _parent.ageGate = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function trackEvent(action, label) {
    window.dataLayer = window.dataLayer || [];
    var trackingData = getTrackingParams('Auth', action, label);
    window.dataLayer.push(trackingData);
  }
  function getTrackingParams(category, action, label) {
    return {
      event: 'ga-click',
      eventCategory: category,
      eventAction: action,
      eventLabel: label
    };
  }
  function onReady() {
    function parseQueryString() {
      var parsedParameters = {},
        uriParameters = GALE.uriUtils.getLocationSearch().substr(1).split('&');
      for (var i = 0; i < uriParameters.length; i++) {
        var parameter = uriParameters[i].split('=');
        parsedParameters[parameter[0]] = decodeURIComponent(parameter[1]);
      }
      return parsedParameters;
    }
    var pageName = document.body.id;
    var isReattempt = parseQueryString().isReattempt;
    if (isReattempt === 'true') {
      if (pageName === 'authenticateUserGroup') {
        trackEvent('LoginFailed', 'InvalidPassword');
      }
      if (pageName === 'identifyUserGroup') {
        trackEvent('LoginFailed', 'InvalidUserGroupName');
      }
    }
  }
  $(document).ready(onReady);
  _parent.analytics = {
    trackEvent: trackEvent,
    onReady: onReady
  };
})(jQuery, AUTH);
(function ($, _parent) {
  function init() {
    attachExcelDownloadButton();
  }
  function attachExcelDownloadButton() {
    $('.js-excel-download').on('click', function (e) {
      e.preventDefault();
      var contextPath = $('head').data('contextPath');
      var fileName = $('.js-audit-file').val();
      GALE.uriUtils.redirectToPage("".concat(contextPath, "/usage/downloadUsage.xls?fileName=").concat(fileName));
    });
  }
  _parent.audit = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    var $input = $('input[name="consumer_loc_data"]');
    $input.val(decodeURIComponent($input.val()).replace(/\+/g, ' '));
    $('#blti-form').trigger('submit');
  }
  _parent.bltiLauncher = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  _.mixin(_.str.exports());
  function init() {
    var $box = $('.new-home').find('#box');
    if ($box.length > 0) {
      resetHeight();
      $(window).on('resize', function () {
        setTimeout(resetHeight, 500);
      });
    }
    $('.js-open-modal').on('click', function () {
      $('.js-lightbox-modal').show();
      handleModal();
    });
    $('.js-modal-close').on('click', function () {
      $('.js-lightbox-modal').hide();
      $('.js-open-modal').trigger('focus');
    });
    function resetHeight() {
      var WRAPPER_MIN_HEIGHT = 934;
      var contentWrapperHeight = $('#content-wrapper').innerHeight();
      if (contentWrapperHeight > WRAPPER_MIN_HEIGHT) {
        var headerHeight = $('#masthead').innerHeight();
        var footerHeight = $('#footer-corporate').innerHeight();
        var newBoxHeight = contentWrapperHeight - (headerHeight + footerHeight);
        $box.innerHeight(newBoxHeight);
      }
    }
    function handleModal() {
      var tabbableInputs = $('.js-modal').find('.js-modal-focus').filter(':visible, :not([disabled])');
      var firstTabbable = tabbableInputs.first();
      var lastTabbable = tabbableInputs.last();
      $('.js-modal-focus').first().trigger('focus');
      lastTabbable.on('keydown', function (e) {
        if (e.key === 'tab' && !e.shiftKey) {
          e.preventDefault();
          firstTabbable.trigger('focus');
        }
      });
      firstTabbable.on('keydown', function (e) {
        if (e.key === 'tab' && e.shiftKey) {
          e.preventDefault();
          lastTabbable.trigger('focus');
        }
      });
      $('.js-modal').on('keydown', function (e) {
        if (e.key === 'Escape') {
          $('.js-modal-close').trigger('click');
        }
      });
    }
  }
  _parent.common = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    window.dataLayer = window.dataLayer || [];
    $('.gtm-event').each(function () {
      addGtmEvent($(this));
    });
    $('body').on('click', '.gtm-click-event', function () {
      registerGtmEvent($(this));
    });
    $('.js-gtm-sign-in-event').click(function () {
      addGtmEvent($('.' + $(this).data('galabel') + '-sign-in-event'));
    });
  }
  function registerGtmEvent(element) {
    window.dataLayer = window.dataLayer || [];
    var gtmFeature = element.data('gtm-feature');
    if (gtmFeature) {
      addGtmFeatureEvent(element);
    }
    var gtmSelectorElement = element.data('gtm-event-selector');
    if (gtmSelectorElement) {
      addGtmEvent($(gtmSelectorElement));
    } else {
      var gtmEvent = {
        'event': element.data('event-name')
      };
      if (element.data('event-value')) {
        gtmEvent['data'] = element.data('event-value');
      }
      window.dataLayer.push(gtmEvent);
    }
  }
  function addGtmEvent(element) {
    var gtmEvent = {
      'event': element.data('event-name')
    };
    if (element.length > 0) {
      element.serializeArray().forEach(function (data) {
        gtmEvent[data.name] = data.value === '' ? undefined : data.value;
      });
      window.dataLayer.push(gtmEvent);
    }
  }
  function addGtmFeatureEvent(element) {
    var gtmEvent = {
      'event': element.data('event-name')
    };
    gtmEvent['documentFeature'] = element.data('gtm-feature');
    var gtmSelectorElement = element.data('gtm-event-selector');
    if (gtmSelectorElement && $(gtmSelectorElement).length === 1) {
      $(gtmSelectorElement).serializeArray().forEach(function (data) {
        gtmEvent[data.name] = data.value === '' ? undefined : data.value;
      });
      window.dataLayer.push(gtmEvent);
    }
  }
  _parent.galeGtm = {
    init: init,
    addGtmEvent: addGtmEvent,
    registerGtmEvent: registerGtmEvent
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    attachLanguageClickEvent();
    attachEscKeyOnLanguageSelection();
    closeOnClickOutside();
    initToolTips();
  }
  function attachEscKeyOnLanguageSelection() {
    $('.js-lang-link, .js-lang-button').on('keyup', function (e) {
      if (e.key === 'Escape') {
        e.preventDefault();
        collapseLanguageContainer();
        $('.js-lang-button').trigger('focus');
      }
    });
  }
  function closeOnClickOutside() {
    $(document).on('click', function (event) {
      if ($(event.target).attr('id') !== 'currentLang') {
        collapseLanguageContainer();
      }
    });
  }
  function collapseLanguageContainer() {
    $('.js-lang-container').removeClass('visible active');
    $('.js-lang-button').attr('aria-expanded', 'false');
  }
  function attachLanguageClickEvent() {
    $('#currentLang').on('click', function () {
      var $language = $(this);
      $language.attr('aria-expanded', $language.attr('aria-expanded') === 'false');
      $('.lang-translation').toggleClass('visible active');
    });
  }
  function initToolTips() {
    GALE.toolTip.init(['utilbar-right', 'utilbar-left']);
  }
  _parent.languageDropDown = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  var locationListTemplate;
  var FIND_LOCATION_BY_NAME_URL = '/apps/blis/findLocDetailByName?';
  var FIND_LOCATION__BY_LAT_LONG_URL = '/apps/blis/findLocDetailByLatLong?';
  var MAX_LOCATIONS_TO_DISPLAY = 10;
  var RESULT_CONTAINER_SELECTOR = '.js-result-container';
  var DYNAMIC_ACCESS_CONTAINER_SELECTOR = '.js-dynamic-access-container';
  var DYNAMIC_ACCESS_KEY = 'galeapps_recentInstitutions';
  function init() {
    showDynamicAccess();
    bindRemoveRecentAccess();
    bindLocationSearch();
    bindLocationAutoComplete();
    bindUseYourLocation();
    bindLocationLinkClick();
    bindLibraryTypeClick();
    registerHelper();
  }
  function getLocalStorageData() {
    return JSON.parse(StorageUtil.getLocalStorageData(DYNAMIC_ACCESS_KEY) || '{}'); // eslint-disable-line no-undef
  }
  function setLocalStorageData(data) {
    StorageUtil.setLocalStorageData(DYNAMIC_ACCESS_KEY, JSON.stringify(data)); // eslint-disable-line no-undef
  }
  function showDynamicAccess() {
    var handlebarsTemplate = Handlebars.compile($('#js-institution-entry-template').html());
    var data = Object.values(getLocalStorageData());
    $(DYNAMIC_ACCESS_CONTAINER_SELECTOR).html('');
    data.forEach(function (entry) {
      $(DYNAMIC_ACCESS_CONTAINER_SELECTOR).append(handlebarsTemplate({
        name: entry.locationName,
        url: entry.locationUrl
      }));
    });
    displayInstructions(data.length);
  }
  function displayInstructions(hasEntires) {
    if (hasEntires) {
      $(DYNAMIC_ACCESS_CONTAINER_SELECTOR).prepend("<div class=\"dynamic-access__instructions\">Choose a recent institution:</div>");
      $(DYNAMIC_ACCESS_CONTAINER_SELECTOR).append("<div class=\"dynamic-access__instructions\">Or find another institution:</div>");
    }
  }
  function bindRemoveRecentAccess() {
    $(DYNAMIC_ACCESS_CONTAINER_SELECTOR).on('click', '.js-removeInstitution', function () {
      var institutionNameForRemoval = $(this).siblings('.js-institutionName').text();
      var data = Object.values(getLocalStorageData());
      data = data.filter(function (entry) {
        return entry.locationName !== institutionNameForRemoval;
      });
      saveDynamicAccessData(data);
      showDynamicAccess();
    });
  }
  function saveDynamicAccessData(data) {
    var newStorage = {};
    data.forEach(function (entry) {
      newStorage[entry.locationId] = entry;
    });
    setLocalStorageData(newStorage);
  }
  function registerHelper() {
    Handlebars.registerHelper('if_eq', function (context, options) {
      if (context === options.hash.compare) {
        return options.fn(this);
      }
      return options.inverse(this);
    });
  }
  function bindLibraryTypeClick() {
    $('.libtype').click(function () {
      AUTH.analytics.trackEvent('Customer Class', getSelectedLibraryType());
    });
  }
  function searchLocation() {
    /* eslint-disable no-useless-escape */
    var value = $('#locAutoComplete').val();
    if (value) {
      $('#locAutoComplete').val(value.replace(/<\s*(html|script|iframe|img)(?:[^\>]*\>\s*.*?\s*<\/\s*\1\s*>|[^>]*\/\s*>)/gim, ' ').trim());
    }
    /* eslint-enable no-useless-escape */
    AUTH.analytics.trackEvent(getSelectedLibraryType(), 'InstitutionName:' + getTypedLocation());
    getLocations(FIND_LOCATION_BY_NAME_URL);
  }
  function bindLocationSearch() {
    $('#locAutoComplete').trigger('focus');
    $('#locAutoComplete').on('keypress', function (e) {
      if (e.which === 13) {
        searchLocation();
      }
    });
    $('#js-search-button').click(function () {
      searchLocation();
    });
  }
  function bindLocationLinkClick() {
    $(RESULT_CONTAINER_SELECTOR).on('click', '.js-location-link', function () {
      var locationId = $(this).attr('data-id');
      var locationName = $(this).text();
      var locationUrl = $(this).attr('href');
      var data = updateStoredAccess(locationId, locationName, locationUrl);
      saveDynamicAccessDataToMostRecent(data);
      AUTH.analytics.trackEvent('Click on Institution', "".concat(locationName, ":").concat(locationId));
    });
  }
  function saveDynamicAccessDataToMostRecent(data) {
    data.sort(function (a, b) {
      return (b.timestamp > a.timestamp) - (a.timestamp > b.timestamp);
    });
    saveDynamicAccessData(data.splice(0, 5));
  }
  function updateStoredAccess(locationId, locationName, locationUrl) {
    var storedAccess = getLocalStorageData();
    storedAccess[locationId] = {
      locationId: locationId,
      locationName: locationName,
      locationUrl: locationUrl,
      timestamp: new Date().getTime()
    };
    return Object.values(storedAccess);
  }
  function bindLocationAutoComplete() {
    $('#locAutoComplete').autocomplete({
      minLength: 1,
      source: function source(request, response) {
        // eslint-disable-line no-unused-vars
        $.getJSON('/apps/blis/autoCompleteLocation?', {
          p: getProdId(),
          ty: getSelectedLibraryType(),
          q: getTypedLocation()
        }, function (data) {
          response(data.LOCATIONS);
        });
      },
      select: function select(e, ui) {
        // eslint-disable-line no-unused-vars
        $('#locAutoComplete').val(ui.item.value);
        AUTH.analytics.trackEvent(getSelectedLibraryType(), 'InstitutionName:' + getTypedLocation());
        getLocations(FIND_LOCATION_BY_NAME_URL);
        return false;
      },
      focus: function focus(e, ui) {
        e.preventDefault();
        $('#locAutoComplete').val(ui.item.value);
      }
    }).data('ui-autocomplete')._renderItem = function (ul, item) {
      return $('<li class="locationItem">').append('<a class="locationLink">' + item.value + '</a>').appendTo(ul);
    };
  }
  function getSelectedLibraryType() {
    return $('input[name="libtype"]:checked').val();
  }
  function getTypedLocation() {
    return $('#locAutoComplete').val();
  }
  function getProdId() {
    return $('#identifyUserGroup .prodId').val();
  }
  function getLocations(url) {
    var params = {
      prodId: getProdId(),
      ty: getSelectedLibraryType(),
      ln: getTypedLocation(),
      query: getTypedLocation(),
      lat: $('#clientLat').val(),
      long: $('#clientLong').val()
    };
    displayLoadingContainer();
    $.getJSON(url, params, GALE.locationFinder.displayLocation);
  }
  function displayLoadingContainer() {
    clearResultContainer();
    $(RESULT_CONTAINER_SELECTOR).append('<div class="loading-area"><span class="loading-text">Searching for Institutions....</span><span class="loading-image"></span></div>');
  }
  function displayLocation(data) {
    var allLocations = data.LOCATIONS;
    var locationSize = allLocations.length;
    var html;
    clearResultContainer();
    AUTH.analytics.trackEvent(locationSize === 0 ? 'FailedSearch' : 'SuccessSearch', getSelectedLibraryType() + ':InstitutionName:' + getTypedLocation());
    if (!locationListTemplate) {
      locationListTemplate = $('#locationListTemplate').html();
    }
    html = Handlebars.compile(locationListTemplate)({
      hasLocations: locationSize > 0,
      locations: GALE.locationFinder.convertLocationData(allLocations),
      header: getMessage(locationSize)
    });
    $(RESULT_CONTAINER_SELECTOR).html(html);
  }
  function getLocationURL() {
    return location.href;
  }
  function removeJunkValue(locationData) {
    if (locationData && (locationData.toUpperCase() === 'UNKNOWN' || locationData === ' ')) {
      return '';
    }
    return locationData;
  }
  function convertLocationData(data) {
    var list = [];
    var url = GALE.locationFinder.getLocationURL();
    var locationData = data.slice(0, MAX_LOCATIONS_TO_DISPLAY);
    var maxZipLength = 9;
    if (url.indexOf('userGroupName=&') === 0) {
      url = url.replace('?', '?userGroupName=');
    } else {
      url = url.indexOf('?') === -1 ? url.concat('?') : url.concat('&');
      url = url.concat('userGroupName=');
    }
    $.each(locationData, function (index, item) {
      // eslint-disable-line no-unused-vars
      var location = item;
      var itemUrl;
      if (location.zip && location.zip.length === maxZipLength) {
        location.zip = location.zip.substring(0, 5) + '-' + location.zip.substring(5, maxZipLength);
      }
      location.city = removeJunkValue(location.city);
      location.state = removeJunkValue(location.state);
      if (location.name) {
        location.name = location.name.toLowerCase();
      }
      if (item.proxyType === 'EZProxy') {
        itemUrl = '/apps/proxyRedirect?locationId=' + item.id + '&proxyUrl=' + encodeURIComponent(item.proxyUrl);
      } else {
        itemUrl = url.replace('userGroupName=', 'userGroupName=' + item.id);
      }
      location.url = itemUrl;
      if (typeof location.zip === 'undefined') {
        location.zip = '';
      }
      list.push(location);
    });
    return list;
  }
  function getMessage(locationSize) {
    var selectedType = $("input[name='libtype']:checked");
    var selectedTypeLabel = selectedType.next().text();
    if (locationSize === 0) {
      return 'Sorry, we could not find any <span class="location-type-label">' + selectedTypeLabel + '</span> location(s)' + appendLocationSearchTermIfAny();
    }
    return 'We found <span class="location-type-label">' + insertLocationSize(locationSize) + selectedTypeLabel + '</span> location(s)' + appendLocationSearchTermIfAny();
  }
  function insertLocationSize(locationSize) {
    return locationSize > MAX_LOCATIONS_TO_DISPLAY ? ' more than ' + MAX_LOCATIONS_TO_DISPLAY + ' ' : ' ' + locationSize + ' ';
  }
  function appendLocationSearchTermIfAny() {
    var searchedLocation = getTypedLocation();
    return searchedLocation.length === 0 ? ':' : ' matching <q class="location-search-term">' + searchedLocation + '</q>:';
  }
  function clearResultContainer() {
    $(RESULT_CONTAINER_SELECTOR).empty();
  }
  function bindUseYourLocation() {
    $('#js-btn-lat-long').click(function () {
      GALE.locationFinder.getGeoLocation();
    });
  }
  function getGeoLocation() {
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(getGeoLocationSuccessCallback, getGeoLocationErrorCallback, {
        maximumAge: 60000,
        timeout: 5000,
        enableHighAccuracy: true
      });
    }
  }
  function getGeoLocationSuccessCallback(position) {
    $('#clientLat').val(position.coords.latitude);
    $('#clientLong').val(position.coords.longitude);
    AUTH.analytics.trackEvent('User Accepted Geolocation', getSelectedLibraryType());
    AUTH.analytics.trackEvent('Request Lat Long', '(' + $('#clientLat').val() + ')(' + $('#clientLong').val() + ')');
    getLocations(FIND_LOCATION__BY_LAT_LONG_URL);
  }
  function getGeoLocationErrorCallback() {
    var url = GALE.locationFinder.getLocationURL();
    $(RESULT_CONTAINER_SELECTOR).html('<div class="header-message header-message--error">This site has been blocked from tracking your location. Please update your browse setting to use your location</div>');
    if (url.indexOf('https:') === 0) {
      AUTH.analytics.trackEvent('User Denied Geolocation', getSelectedLibraryType());
    }
  }
  _parent.locationFinder = {
    init: init,
    displayLocation: displayLocation,
    convertLocationData: convertLocationData,
    getLocationURL: getLocationURL,
    getGeoLocation: getGeoLocation,
    _privateData: {
      showDynamicAccess: showDynamicAccess
    }
  };
})(jQuery, GALE);
(function ($, _parent) {
  function initBranding() {
    $('#brandingTrigger, .js-brandingTrigger, #brandingClose').on('click', function () {
      $('#locationBrandingContainer').toggle();
      if ($('#locationBrandingContainer').is(':visible')) {
        //OMNI.a11yTabTrap.init($('.js-branding-container'), $('.js-close-branding')); // eslint-disable-line no-undef
        $('.js-brandingTrigger').attr('aria-expanded', true);
      } else {
        $('.js-brandingTrigger').attr('aria-expanded', false);
        $('.js-brandingTrigger').trigger('focus');
      }
    });
  }
  function initGRC() {
    initBranding();
    $('.js-group-nav').on('click', function () {
      var group = $(this).data('family');
      $('.js-group-nav').removeClass('active');
      $('.js-group-container').removeClass('active');
      $(this).addClass('active');
      $('.js-group-' + group).addClass('active');
      $('.js-link-additional').hide();
    });
    $(document).on('submit', '#js-package-all', function () {
      $('.js-group-nav').removeClass('active');
      $('.js-group-container').removeClass('active');
      $(this).addClass('active');
      $('.js-group-All_Databases').addClass('active');
    });
    $('#js-crossdb').on('click', function () {
      $('.js-group-nav').removeClass('active');
      $('.js-group-container').removeClass('active');
      $(this).addClass('active');
      $('.js-crossdb').addClass('active');
    });
    $('.js-cross-search-button').on('click', function () {
      var pack = $(this).data('package');
      if ($('#cs-' + pack).val() === '') {
        $('#cs-' + pack).prop("placeholder", "Please Enter Search Term");
        $('#cs-' + pack).trigger('focus');
        return false;
      }
      $('.js-dblist-' + pack).val($('.js-prodsForDb-' + pack).val());
      return true;
    });
    $('.js-product-filter').each(function () {
      var $this = $(this);
      var group = $this.data('group');
      $this.fastLiveFilter('.js-database-container-' + group, {
        parentLevel: true,
        callback: function callback(num) {
          var $noResultsContainer = $('.js-group-' + group + ' .js-no-results-container');
          if (num === 0) {
            $noResultsContainer.show();
          } else {
            $noResultsContainer.hide();
          }
        }
      });
    });
    $('.js-product-link').on('click', function (e) {
      var ltiContext = $('.js-lti-context').val();
      var productUrl = $(this).attr('data-product-url');
      if (ltiContext && productUrl) {
        e.preventDefault();
        $('#open-product-form').attr('target', '').attr('action', productUrl).trigger('submit');
      }
    });
  }
  _parent.menu = {
    initGRC: initGRC,
    initBranding: initBranding
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    $('.thirdPartySigninLink').one('click', function () {
      var $link = $(this);
      $link.attr('href', updateHref($link));
      return true;
    });
    bindJsonGenerator();
    bindCopyJson();
  }
  function bindCopyJson() {
    $(document).on('click', '#js-copy-json', function () {
      var copyTextarea = $('.js-json-response');
      copyTextarea.trigger('focus');
      copyTextarea.trigger('select');
      document.execCommand('copy');
    });
  }
  function bindJsonGenerator() {
    $(document).on('click', '#js-generateJSON', function () {
      $('.js-json-response').val('');
      $('#js-copy-json').addClass('hide');
      var url = $(this).attr('data-url');
      var title = $('#js-title').val();
      var description = $('#js-description').val();
      var productCode = $('#js-productCode').val();
      var key = $('#js-consumer-key').val();
      var secret = $('#js-secret').val();
      $.ajax({
        url: url,
        data: {
          title: title,
          description: description,
          productCode: productCode,
          consumerKey: key,
          secret: secret
        },
        dataType: 'json',
        success: function success(jsonResponse) {
          $('.js-json-response').val(JSON.stringify(jsonResponse, null, 4));
          $('#js-copy-json').removeClass('hide');
        }
      });
    });
  }
  function getBaseUrl($link) {
    var baseUrl = $link.attr('data-base-url') || '';
    return decodeURIComponent(baseUrl);
  }
  function constructBaseUrlWithProxy() {
    var hostName = GALE.uriUtils.getLocationHostname();
    var redirectUrl = "https://".concat(hostName);
    var port = GALE.uriUtils.getLocationPort();
    if (port != "" && port != "80") {
      redirectUrl += ":".concat(port);
    }
    return redirectUrl;
  }
  function createOauthUrl($link) {
    var baseUrl = getBaseUrl($link);
    var relativeUrl = $link.attr('href');
    if (!_(baseUrl).isBlank()) {
      return baseUrl + relativeUrl;
    }
    return constructBaseUrlWithProxy() + relativeUrl;
  }
  function updateHref($link) {
    var oauthUrl = createOauthUrl($link);
    var returnUrl = $('#returnUrl').length > 0 ? $('#returnUrl').val() : GALE.uriUtils.getLocationHref();
    var params = $.deparam(GALE.uriUtils.getLocationSearch().substring(1));
    if (_(params.u).isBlank() && _(params.userGroupName).isBlank() && !_($('.userGroupName').val()).isBlank()) {
      returnUrl = returnUrl + '&u=' + $('.userGroupName').val();
    }
    returnUrl = appendProvider(oauthUrl, returnUrl);
    returnUrl = returnUrl + '&tz=' + GALE.uriUtils.getTimezone();
    returnUrl = returnUrl + '&piu=' + encodeURIComponent(constructBaseUrlWithProxy());
    return oauthUrl + encodeURIComponent(returnUrl);
  }
  function appendProvider(oauthUrl, returnUrl) {
    var urlParts = oauthUrl.split('?');
    if (urlParts.length > 1) {
      var params = $.deparam(urlParts[1]);
      if (!_(params.provider).isBlank()) {
        returnUrl = returnUrl + '&provider=' + params.provider;
      }
    }
    return returnUrl;
  }
  function redirect() {
    var redirectUrl = $('#redirectUrl').val();
    if (redirectUrl && redirectUrl.indexOf('cookie_pass_through') > -1) {
      GALE.uriUtils.redirectToPage(redirectUrl);
    } else {
      $('#redirect-form').trigger('submit');
    }
  }
  _parent.oauth = {
    init: init,
    redirect: redirect
  };
})(jQuery, GALE);
(function ($, _parent) {
  $(document).ready(onReady);
  function onReady() {
    $(document).on('click', 'a', function () {
      var $this = $(this);
      var gaAction = $this.data('gaaction');
      if (gaAction && gaAction.length > 0) {
        var gaLabel = $this.data('galabel');
        AUTH.analytics.trackEvent(gaAction, gaLabel);
      }
    });
    $(document).on('submit', 'form', function () {
      var $this = $(this);
      var gaAction = $this.data('gaaction');
      if (gaAction && gaAction.length > 0) {
        var gaLabel = $this.data('galabel');
        AUTH.analytics.trackEvent(gaAction, gaLabel);
      }
    });
  }
  _parent.passwordPrompt = {
    onReady: onReady
  };
})(jQuery, GALE);
(function ($, _parent) {
  var HOME_PAGE_IMG = '#home-page-image';
  var STAGE_WRAPPER = '.js-stage-wrapper';
  function init() {
    var imageAssetUrl = $(STAGE_WRAPPER).attr('image-asset-url');
    var productCode = $(STAGE_WRAPPER).attr('product-code');
    if (productCode) {
      productCode = productCode.toLowerCase();
    }
    var genericImageUrl = imageAssetUrl + 'auth-generic.jpg';
    var homepageImageUrl = imageAssetUrl + productCode + '-hero.jpg?x=' + Date.now();
    detectImageError(genericImageUrl);
    bindImageLoadHandler(homepageImageUrl, genericImageUrl);
    loadImage(homepageImageUrl);
  }
  function loadImage(homePageImageUrl) {
    $(HOME_PAGE_IMG).attr('src', homePageImageUrl);
  }
  function detectImageError(genericImageUrl) {
    $(HOME_PAGE_IMG).on('error', function () {
      $(STAGE_WRAPPER).css('background-image', 'url(' + genericImageUrl + ')');
      $(HOME_PAGE_IMG).remove();
    });
  }
  function bindImageLoadHandler(homePageImageUrl, genericImageUrl) {
    $(HOME_PAGE_IMG).on('load', function () {
      var srcUrl = homePageImageUrl;
      var width = $(HOME_PAGE_IMG).width();
      if (width !== null && width < 100) {
        srcUrl = genericImageUrl;
      }
      $(STAGE_WRAPPER).css('background-image', 'url(' + srcUrl + ')');
      $(HOME_PAGE_IMG).remove();
    });
  }
  _parent.productImage = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function init() {
    $('.js-alphabet-button').click(function () {
      $('.js-alphabet-button').removeClass('selected-letter');
      var letter = $(this).attr('id');
      $('.js-filter-by-letter').val(letter);
      $('.js-filter-by-letter').trigger('change');
      $(this).addClass('selected-letter');
    });
    $('.js-thirdparty').click(function () {
      $('.js-filter-container').hide();
      $('tr.third-party').show();
    });
    filterResults('.js-filter-product', '.js-filter-container', callback_searchAndFilter);
    filterResults('.js-filter-by-letter', '.js-filter-container', callback_searchAndFilter, true);
  }
  var callback_searchAndFilter = function callBack(num) {
    $('.js-no-results-container').hide();
    showNoResults();
  };
  function showNoResults() {
    if ($('.js-database-container .js-prod-id:visible').length === 0) {
      $('.js-no-results-container').show();
    }
  }
  function filterResults(input, container, callback, startsWith) {
    $(input).fastLiveFilter(container, {
      callback: callback,
      startsWith: startsWith,
      parentLevel: true
    });
  }
  _parent.support = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  var config = {
    default: {
      selector: '[data-tooltip]',
      content: {
        attr: 'data-tooltip'
      },
      style: {
        classes: 'qtip-tipsy'
      },
      position: {
        my: 'bottom center',
        at: 'top center',
        viewport: $('.page-wrapper'),
        adjust: {
          method: 'shift shift'
        }
      }
    },
    'utilbar-left': {
      selector: '.js-qtip-utilbar-left',
      content: {
        attr: 'data-qtip'
      },
      style: {
        classes: 'qtip-tipsy qtip-utilbar-left'
      },
      position: {
        my: 'top left',
        at: 'bottom center'
      }
    },
    'utilbar-right': {
      selector: '.js-qtip-utilbar-right',
      content: {
        attr: 'data-qtip'
      },
      style: {
        classes: 'qtip-tipsy qtip-utilbar-right'
      },
      position: {
        my: 'top right',
        at: 'bottom center'
      }
    }
  };
  function init() {
    var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['default'];
    if ($.fn.qtip) {
      _.each(settings, function (setting) {
        var options = _.defaults(config[setting], config.default);
        $(options.selector).qtip(options);
        attachClickEventForToggleControl(options);
      });
    }
  }
  function attachClickEventForToggleControl(options) {
    $("".concat(options.selector, "[aria-expanded]")).on('click', function () {
      var isExpanded = $(this).attr('aria-expanded') === 'true';
      $(this).qtip(isExpanded ? 'destroy' : options);
    });
  }
  _parent.toolTip = {
    init: init
  };
})(jQuery, GALE);
(function ($, _parent) {
  function initForm() {
    if ($('#requestPath').val() !== '/apps/ui/inter') {
      $('#saml-form').trigger('submit');
    }
  }
  function initLogin() {
    $('.js-open-modal').addClass('hide');
    $.ajax({
      url: 'https://' + decodeURIComponent($('#directLinkingDomain').val()) + "/authorize/detectUser?" + ($('#ipParam').val() || ''),
      dataType: 'text',
      success: function success(detectedUser) {
        var $returnUrl = $('#returnUrl');
        $returnUrl.val($returnUrl.val() + '&detectedUser=' + encodeURIComponent(detectedUser));
        $('.js-open-modal').removeClass('hide');
      }
    });
  }
  function initManageUsers() {
    $('.datepicker').datepicker();
    $('#view_users').click(function () {
      var $downloadUserForm = $('#downloadUserForm');
      var action = $downloadUserForm.attr('action');
      $downloadUserForm.attr('action', _(action).strLeftBack('/') + '/viewUsers');
      $downloadUserForm.attr('target', '_blank');
    });
    $('#download_users').click(function () {
      var $downloadUserForm = $('#downloadUserForm');
      var action = $downloadUserForm.attr('action');
      $downloadUserForm.attr('action', _(action).strLeftBack('/') + '/downloadUsers');
    });
  }
  _parent.udemy = {
    initManageUsers: initManageUsers,
    initForm: initForm,
    initLogin: initLogin
  };
})(jQuery, GALE);/*! GaleApps-all Tue Oct 22 2024 17:40:11 GMT-0400 (Eastern Daylight Time) */

//# sourceMappingURL=GaleApps-all.min.js.map
