text: /*!
   * enquire.js v2.1.2 - Awesome Media Queries in JavaScript
   * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js
   * License: MIT (http://www.opensource.org/licenses/mit-license.php)
   */
  
  /**
   * @license RequireJS text 2.0.12 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
   * Available via the MIT or new BSD license.
   * see: http://github.com/requirejs/text for details
   */
  
  /*!
   * typeahead.js 0.10.5
   * https://github.com/twitter/typeahead.js
   * Copyright 2013-2014 Twitter, Inc. and other contributors; Licensed MIT
   */
  
  !function(e,t,n){var i=window.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=n(i):"function"==typeof define&&define.amd?define("enquire",[],function(){return t[e]=n(i)}):t[e]=n(i)}("enquire",this,function(e){function t(e,t){var n,i=0,s=e.length;for(i;s>i&&(n=t(e[i],i),n!==!1);i++);}function n(e){return"[object Array]"===Object.prototype.toString.apply(e)}function i(e){return"function"==typeof e}function s(e){this.options=e,!e.deferSetup&&this.setup()}function r(t,n){this.query=t,this.isUnconditional=n,this.handlers=[],this.mql=e(t);var i=this;this.listener=function(e){i.mql=e,i.assess()},this.mql.addListener(this.listener)}function o(){if(!e)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!e("only all").matches}return s.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(e){return this.options===e||this.options.match===e}},r.prototype={addHandler:function(e){var t=new s(e);this.handlers.push(t),this.matches()&&t.on()},removeHandler:function(e){var n=this.handlers;t(n,function(t,i){return t.equals(e)?(t.destroy(),!n.splice(i,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){t(this.handlers,function(e){e.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var e=this.matches()?"on":"off";t(this.handlers,function(t){t[e]()})}},o.prototype={register:function(e,s,o){var a=this.queries,u=o&&this.browserIsIncapable;return a[e]||(a[e]=new r(e,u)),i(s)&&(s={match:s}),n(s)||(s=[s]),t(s,function(t){i(t)&&(t={match:t}),a[e].addHandler(t)}),this},unregister:function(e,t){var n=this.queries[e];return n&&(t?n.removeHandler(t):(n.clear(),delete this.queries[e])),this}},new o}),define("main_menu/models/menu_item_model",["backbone","underscore"],function(e){return e.Model.extend({})}),define("main_menu/models/menu_item_collection.js",["backbone","underscore","main_menu/models/menu_item_model"],function(e,t,n){return e.Collection.extend({urlRoot:"/node/",model:n,params:".json?deep-load-refs=1",initialize:function(){this.lmsUrl=this.getLmsUrl()},parse:function(e){return e},getLmsUrl:function(){return Drupal&&Drupal.settings?Drupal.settings.lmsBaseUrl:"/"},getSample:function(){var e=[{id:"courses",title:"Courses",url:"/course",classList:"",html:['<header class="tab-header">',"<h2>Courses by Subject</h2>",'<a href="/courses" class="btn btn-blue">View All Courses</a>',"</header>",'<div class="tab-content">','<div class="item-list">','<ul class="col-ul">','<li class="col-li">','<a href="/course/subject/architecture">Architecture</a>',"</li>",'<li class="col-li">','<a href="/course/subject/art-culture">Art &amp; Culture</a>',"</li>",'<li class="col-li">','<a href="/course/subject/biology-life-sciences">Biology &amp; Life Sciences</a>',"</li>",'<li class="col-li">','<a href="/course/subject/business-management">Business &amp; Management</a>',"</li>",'<li class="col-li">','<a href="/course/subject/chemistry">Chemistry</a>',"</li>",'<li class="col-li">','<a href="/course/subject/communication">Communication</a>',"</li>",'<li class="col-li">','<a href="/course/subject/computer-science">Computer Science</a>',"</li>",'<li class="col-li">','<a href="/course/subject/data-analysis-statistics">Data Analysis &amp; Statistics</a>',"</li>",'<li class="col-li">','<a href="/course/subject/design">Design</a>',"</li>",'<li class="col-li">','<a href="/course/subject/economics-finance">Economics &amp; Finance</a>',"</li>",'<li class="col-li">','<a href="/course/subject/education">Education</a>',"</li>",'<li class="col-li">','<a href="/course/subject/electronics">Electronics</a>',"</li>",'<li class="col-li">','<a href="/course/subject/energy-earth-sciences">Energy &amp; Earth Sciences</a>',"</li>",'<li class="col-li">','<a href="/course/subject/engineering">Engineering</a>',"</li>",'<li class="col-li">','<a href="/course/subject/environmental-studies">Environmental Studies</a>',"</li>",'<li class="col-li">','<a href="/course/subject/ethics">Ethics</a>',"</li>",'<li class="col-li">','<a href="/course/subject/food-nutrition">Food &amp; Nutrition</a>',"</li>",'<li class="col-li">','<a href="/course/subject/health-safety">Health &amp; Safety</a>',"</li>",'<li class="col-li">','<a href="/course/subject/history">History</a>',"</li>",'<li class="col-li">','<a href="/course/subject/humanities">Humanities</a>',"</li>",'<li class="col-li">','<a href="/course/subject/language">Language</a>',"</li>",'<li class="col-li">','<a href="/course/subject/law">Law</a>',"</li>",'<li class="col-li">','<a href="/course/subject/literature">Literature</a>',"</li>",'<li class="col-li">','<a href="/course/subject/math">Math</a>',"</li>",'<li class="col-li">','<a href="/course/subject/medicine">Medicine</a>',"</li>",'<li class="col-li">','<a href="/course/subject/music">Music</a>',"</li>",'<li class="col-li">','<a href="/course/subject/philanthropy">Philanthropy</a>',"</li>",'<li class="col-li">','<a href="/course/subject/philosophy-ethics">Philosophy &amp; Ethics</a>',"</li>",'<li class="col-li">','<a href="/course/subject/physics">Physics</a>',"</li>",'<li class="col-li">','<a href="/course/subject/science">Science</a>',"</li>",'<li class="col-li">','<a href="/course/subject/social-sciences">Social Sciences</a>',"</li>","</ul>","</div>","</div>"].join("")},{id:"how-it-works",title:"How It Works",url:"/how-it-works",classList:"",html:['<header class="tab-header">',"<h2>How It Works</h2>",'<a href="/courses" class="btn btn-blue">View All Courses</a>',"</header>",'<div class="tab-content">','<div class="icon-callout col-8">','<div class="edx-icon lg cert"></div>','<a href="/verified-certificate" class="edx-link-blk heading icon-title">Earn a Valuable Certificate &#187;</a>',"<p>Receive an official credential from the institution and signed by the instructor. The certificate verifies your achievement and can be used to highlight skills on your resume or LinkedIn profile.</p>","</div>",'<ul class="icon-list col-4 col-last">',"<li>",'<div class="edx-icon high-school"></div>','<a href="/high-school-initiative" class="edx-link-blk">Excel in High School &#187;</a>',"</li>","<li>",'<div class="edx-icon credit"></div>','<a href="/gfa" class="edx-link-blk">Earn University Credit &#187;</a>',"</li>","<li>",'<div class="edx-icon subject"></div>','<a href="/xseries" class="edx-link-blk">Explore an XSeries Program &#187;</a>',"</li>","<li>",'<div class="edx-icon career"></div>','<a href="/professional-education" class="edx-link-blk">Advance your Career &#187;</a>',"</li>","</ul>","</div>"].join("")},{id:"schools-and-partners",title:"Schools & Partners",url:"/schools-partners",classList:"",html:""},{id:"about-edx",title:"About",url:"/about-us",classList:"",html:['<div class="tab-content">','<div class="two-thirds-block col-8">','<header class="tab-header">',"<h2>Offering the best in education to the world</h2>",'<p class="copy">',"At edX, we take our mission of increasing global access to quality education seriously. We connect learners to the best universities and institutions from around the world. Join us!",'<a href="/about-us" class="link">More about edX &#187;</a>',"</p>","</header>",'<div class="menu-testimonial">','<img src="/sites/all/themes/atedx/images/people/about-dropdown-portrait.jpg" class="round" alt="" aria-hidden="true"/>','<div class="text">','<p class="quote">“With the skills I’ve been able to develop on my own, I’ve got paid internships, beating out other college kids, because they don’t usually have the same skill-sets I do when it comes to iOS app development.”</p>','<p class="source">Aakash Thumaty, California, USA</p>',"</div>","</div>","</div>",'<div class="sidebar col-4 col-last">',"<h2>Why edX?</h2>","<ul>",'<li><a href="/courses?availability=Self-paced">On your schedule &#187;</a></li>','<li><a href="/courses">Courses for everyone &#187;</a></li>','<li><a href="/verified-certificate">Valuable Credentials &#187;</a></li>','<li><a href="http://blog.edx.org/learner-stories/">Global Community &#187;</a></li>',"</ul>","</div>","</div>"].join("")}];this.set(e)}})}),define("main_menu/models/user_model",["backbone","jquery"],function(e,t){return e.Model.extend({initialize:function(){this.isLoggedIn=document.cookie.indexOf("edxloggedin")>=0,this.set({isLoggedIn:this.isLoggedIn,userDetails:this.getUserDetails(),cta:this.getCta()})},formatInfoCookie:function(){var e=document.cookie,n=this.getCookieName(),i=e.indexOf(n),s="",r=!1;i>-1&&(s=e.substr(e.indexOf(n)+n.length+1),r=s.substr(0,s.indexOf(";")),r=r.replace(/\\054/g,","));try{r=t.parseJSON(r)}catch(o){r=!1}return r},getCookieName:function(){return window.location.host.indexOf("stage")>-1?"stage-edx-user-info":"prod-edx-user-info"},getCta:function(){var e=Drupal.settings.lmsBaseUrl||!1,t=[];return this.isLoggedIn?t.push({text:"Dashboard",url:e+"/dashboard",classList:"btn-blue"}):t.push({text:"Sign In",url:e+"/login"},{text:"Register",url:e+"/register",classList:"btn-blue"}),t},getUserDetails:function(){var e=this.formatInfoCookie(),n=e?t.parseJSON(e):!1;return!n||n.header_urls&&n.header_urls.account_settings||(n=!1),n}})}),define("models/suggestion_engine_model",["backbone"],function(e){return e.Model.extend({initialize:function(e,t){var n=t.url||"/customizable_search/bundle/"+t.facet,i={prefetch:n,remote:n+"?query=%QUERY",dupDetector:this.dupDetector,datumTokenizer:Bloodhound.tokenizers.obj.whitespace("l"),queryTokenizer:Bloodhound.tokenizers.whitespace};this.set({engine:new Bloodhound(i)}),this.get("engine").initialize()},dupDetector:function(e,t){return e.id===t.id},ttAdapter:function(){return this.get("engine").ttAdapter()}})}),define("text",["module"],function(e){var t,n,i,s,r,o=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],a=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,u=/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,l="undefined"!=typeof location&&location.href,c=l&&location.protocol&&location.protocol.replace(/\:/,""),h=l&&location.hostname,d=l&&(location.port||void 0),f={},p=e.config&&e.config()||{};return t={version:"2.0.12",strip:function(e){if(e){e=e.replace(a,"");var t=e.match(u);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:p.createXhr||function(){var e,t,n;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;3>t;t+=1){n=o[t];try{e=new ActiveXObject(n)}catch(i){}if(e){o=[n];break}}return e},parseName:function(e){var t,n,i,s=!1,r=e.indexOf("."),o=0===e.indexOf("./")||0===e.indexOf("../");return-1!==r&&(!o||r>1)?(t=e.substring(0,r),n=e.substring(r+1,e.length)):t=e,i=n||t,r=i.indexOf("!"),-1!==r&&(s="strip"===i.substring(r+1),i=i.substring(0,r),n?n=i:t=i),{moduleName:t,ext:n,strip:s}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,n,i,s){var r,o,a,u=t.xdRegExp.exec(e);return u?(r=u[2],o=u[3],o=o.split(":"),a=o[1],o=o[0],!(r&&r!==n||o&&o.toLowerCase()!==i.toLowerCase()||(a||o)&&a!==s)):!0},finishLoad:function(e,n,i,s){i=n?t.strip(i):i,p.isBuild&&(f[e]=i),s(i)},load:function(e,n,i,s){if(s&&s.isBuild&&!s.inlineText)return void i();p.isBuild=s&&s.isBuild;var r=t.parseName(e),o=r.moduleName+(r.ext?"."+r.ext:""),a=n.toUrl(o),u=p.useXhr||t.useXhr;return 0===a.indexOf("empty:")?void i():void(!l||u(a,c,h,d)?t.get(a,function(n){t.finishLoad(e,r.strip,n,i)},function(e){i.error&&i.error(e)}):n([o],function(e){t.finishLoad(r.moduleName+"."+r.ext,r.strip,e,i)}))},write:function(e,n,i){if(f.hasOwnProperty(n)){var s=t.jsEscape(f[n]);i.asModule(e+"!"+n,"define(function () { return '"+s+"';});\n")}},writeFile:function(e,n,i,s,r){var o=t.parseName(n),a=o.ext?"."+o.ext:"",u=o.moduleName+a,l=i.toUrl(o.moduleName+a)+".js";t.load(u,i,function(){var n=function(e){return s(l,e)};n.asModule=function(e,t){return s.asModule(e,l,t)},t.write(e,u,n,r)},r)}},"node"===p.env||!p.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(n=require.nodeRequire("fs"),t.get=function(e,t,i){try{var s=n.readFileSync(e,"utf8");0===s.indexOf("﻿")&&(s=s.substring(1)),t(s)}catch(r){i&&i(r)}}):"xhr"===p.env||!p.env&&t.createXhr()?t.get=function(e,n,i,s){var r,o=t.createXhr();if(o.open("GET",e,!0),s)for(r in s)s.hasOwnProperty(r)&&o.setRequestHeader(r.toLowerCase(),s[r]);p.onXhr&&p.onXhr(o,e),o.onreadystatechange=function(){var t,s;4===o.readyState&&(t=o.status||0,t>399&&600>t?(s=new Error(e+" HTTP status: "+t),s.xhr=o,i&&i(s)):n(o.responseText),p.onXhrComplete&&p.onXhrComplete(o,e))},o.send(null)}:"rhino"===p.env||!p.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?t.get=function(e,t){var n,i,s="utf-8",r=new java.io.File(e),o=java.lang.System.getProperty("line.separator"),a=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(r),s)),u="";try{for(n=new java.lang.StringBuffer,i=a.readLine(),i&&i.length()&&65279===i.charAt(0)&&(i=i.substring(1)),null!==i&&n.append(i);null!==(i=a.readLine());)n.append(o),n.append(i);u=String(n.toString())}finally{a.close()}t(u)}:("xpconnect"===p.env||!p.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(i=Components.classes,s=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),r="@mozilla.org/windows-registry-key;1"in i,t.get=function(e,t){var n,o,a,u={};r&&(e=e.replace(/\//g,"\\")),a=new FileUtils.File(e);try{n=i["@mozilla.org/network/file-input-stream;1"].createInstance(s.nsIFileInputStream),n.init(a,1,0,!1),o=i["@mozilla.org/intl/converter-input-stream;1"].createInstance(s.nsIConverterInputStream),o.init(n,"utf-8",n.available(),s.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),o.readString(n.available(),u),o.close(),n.close(),t(u.value)}catch(l){throw new Error((a&&a.path||"")+": "+l)}}),t}),define("text!templates/course-search-bar.underscore",[],function(){return'<label for="edit-search-query-<%- id %>" class="element-invisible"><%- label %></label>\n<div class="form-item form-type-textfield form-item-search-query">\n  <input placeholder="<%- placeholder %>" class="js-search-bar edit-search-query form-text" id="edit-search-query-<%- id %>" type="text" name="search_query" value="" size="60" maxlength="128">\n</div>\n<button class="btn btn-transparent edit-submit form-submit js-search-button" type="submit" id="edit-submit">\n    <span class="sr"><%- action_label %></span>\n    <i class="icon fa fa-search" aria-hidden="true"></i>\n</button>'});var Drupal=Drupal||{t:function(e){return e},formatPlural:function(e,t,n){return 1===e?t:n}},gettext=function(e){return Drupal.t(e)},ungettext=function(e,t,n,i){var s=i?txtUtils.update.replacements(i):{},r=txtUtils.update.strVars(e),o=txtUtils.update.strVars(t);return Drupal.formatPlural(n,r,o,s)},sprintf=function(e,t){var e=txtUtils.update.strVars(e),n=txtUtils.update.replacements(t),i="";return i=Drupal.t(e,n),_.unescape(i)},txtUtils={update:{strVars:function(e){var t,n,i=e.split(" "),s=i.length;for(t=0;s>t;t++)n=i[t],"%("===n.substr(0,2)&&")s"===n.substr(n.length-2)&&(i[t]="@"+n.substr(2,n.length-4));return i.join(" ")},replacements:function(e){var t={};for(var n in e)t["@"+n]=e[n];return t}}};define("gettext",function(){}),function(e){var t=function(){return{isMsie:function(){return/(msie|trident)/i.test(navigator.userAgent)?navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]:!1},isBlankString:function(e){return!e||/^\s*$/.test(e)},escapeRegExChars:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isArray:e.isArray,isFunction:e.isFunction,isObject:e.isPlainObject,isUndefined:function(e){return"undefined"==typeof e},toStr:function(e){return t.isUndefined(e)||null===e?"":e+""},bind:e.proxy,each:function(t,n){function i(e,t){return n(t,e)}e.each(t,i)},map:e.map,filter:e.grep,every:function(t,n){var i=!0;return t?(e.each(t,function(e,s){return(i=n.call(null,s,e,t))?void 0:!1}),!!i):i},some:function(t,n){var i=!1;return t?(e.each(t,function(e,s){return(i=n.call(null,s,e,t))?!1:void 0}),!!i):i},mixin:e.extend,getUniqueId:function(){var e=0;return function(){return e++}}(),templatify:function(t){function n(){return String(t)}return e.isFunction(t)?t:n},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var i,s;return function(){var r,o,a=this,u=arguments;return r=function(){i=null,n||(s=e.apply(a,u))},o=n&&!i,clearTimeout(i),i=setTimeout(r,t),o&&(s=e.apply(a,u)),s}},throttle:function(e,t){var n,i,s,r,o,a;return o=0,a=function(){o=new Date,s=null,r=e.apply(n,i)},function(){var u=new Date,l=t-(u-o);return n=this,i=arguments,0>=l?(clearTimeout(s),s=null,o=u,r=e.apply(n,i)):s||(s=setTimeout(a,l)),r}},noop:function(){}}}(),n="0.10.5",i=function(){function e(e){return e=t.toStr(e),e?e.split(/\s+/):[]}function n(e){return e=t.toStr(e),e?e.split(/\W+/):[]}function i(e){return function(){var n=[].slice.call(arguments,0);return function(i){var s=[];return t.each(n,function(n){s=s.concat(e(t.toStr(i[n])))}),s}}}return{nonword:n,whitespace:e,obj:{nonword:i(n),whitespace:i(e)}}}(),s=function(){function n(n){this.maxSize=t.isNumber(n)?n:100,this.reset(),this.maxSize<=0&&(this.set=this.get=e.noop)}function i(){this.head=this.tail=null}function s(e,t){this.key=e,this.val=t,this.prev=this.next=null}return t.mixin(n.prototype,{set:function(e,t){var n,i=this.list.tail;this.size>=this.maxSize&&(this.list.remove(i),delete this.hash[i.key]),(n=this.hash[e])?(n.val=t,this.list.moveToFront(n)):(n=new s(e,t),this.list.add(n),this.hash[e]=n,this.size++)},get:function(e){var t=this.hash[e];return t?(this.list.moveToFront(t),t.val):void 0},reset:function(){this.size=0,this.hash={},this.list=new i}}),t.mixin(i.prototype,{add:function(e){this.head&&(e.next=this.head,this.head.prev=e),this.head=e,this.tail=this.tail||e},remove:function(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev},moveToFront:function(e){this.remove(e),this.add(e)}}),n}(),r=function(){function e(e){this.prefix=["__",e,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+t.escapeRegExChars(this.prefix))}function n(){return(new Date).getTime()}function i(e){return JSON.stringify(t.isUndefined(e)?null:e)}function s(e){return JSON.parse(e)}var r,o;try{r=window.localStorage,r.setItem("~~~","!"),r.removeItem("~~~")}catch(a){r=null}return o=r&&window.JSON?{_prefix:function(e){return this.prefix+e},_ttlKey:function(e){return this._prefix(e)+this.ttlKey},get:function(e){return this.isExpired(e)&&this.remove(e),s(r.getItem(this._prefix(e)))},set:function(e,s,o){return t.isNumber(o)?r.setItem(this._ttlKey(e),i(n()+o)):r.removeItem(this._ttlKey(e)),r.setItem(this._prefix(e),i(s))},remove:function(e){return r.removeItem(this._ttlKey(e)),r.removeItem(this._prefix(e)),this},clear:function(){var e,t,n=[],i=r.length;for(e=0;i>e;e++)(t=r.key(e)).match(this.keyMatcher)&&n.push(t.replace(this.keyMatcher,""));for(e=n.length;e--;)this.remove(n[e]);return this},isExpired:function(e){var i=s(r.getItem(this._ttlKey(e)));return t.isNumber(i)&&n()>i?!0:!1}}:{get:t.noop,set:t.noop,remove:t.noop,clear:t.noop,isExpired:t.noop},t.mixin(e.prototype,o),e}(),o=function(){function n(t){t=t||{},this.cancelled=!1,this.lastUrl=null,this._send=t.transport?i(t.transport):e.ajax,this._get=t.rateLimiter?t.rateLimiter(this._get):this._get,this._cache=t.cache===!1?new s(0):u}function i(n){return function(i,s){function r(e){t.defer(function(){a.resolve(e)})}function o(e){t.defer(function(){a.reject(e)})}var a=e.Deferred();return n(i,s,r,o),a}}var r=0,o={},a=6,u=new s(10);return n.setMaxPendingRequests=function(e){a=e},n.resetCache=function(){u.reset()},t.mixin(n.prototype,{_get:function(e,t,n){function i(t){n&&n(null,t),c._cache.set(e,t)}function s(){n&&n(!0)}function u(){r--,delete o[e],c.onDeckRequestArgs&&(c._get.apply(c,c.onDeckRequestArgs),c.onDeckRequestArgs=null)}var l,c=this;this.cancelled||e!==this.lastUrl||((l=o[e])?l.done(i).fail(s):a>r?(r++,o[e]=this._send(e,t).done(i).fail(s).always(u)):this.onDeckRequestArgs=[].slice.call(arguments,0))},get:function(e,n,i){var s;return t.isFunction(n)&&(i=n,n={}),this.cancelled=!1,this.lastUrl=e,(s=this._cache.get(e))?t.defer(function(){i&&i(null,s)}):this._get(e,n,i),!!s},cancel:function(){this.cancelled=!0}}),n}(),a=function(){function n(t){t=t||{},t.datumTokenizer&&t.queryTokenizer||e.error("datumTokenizer and queryTokenizer are both required"),this.datumTokenizer=t.datumTokenizer,this.queryTokenizer=t.queryTokenizer,this.reset()}function i(e){return e=t.filter(e,function(e){return!!e}),e=t.map(e,function(e){return e.toLowerCase()})}function s(){return{ids:[],children:{}}}function r(e){for(var t={},n=[],i=0,s=e.length;s>i;i++)t[e[i]]||(t[e[i]]=!0,n.push(e[i]));return n}function o(e,t){function n(e,t){return e-t}var i=0,s=0,r=[];e=e.sort(n),t=t.sort(n);for(var o=e.length,a=t.length;o>i&&a>s;)e[i]<t[s]?i++:e[i]>t[s]?s++:(r.push(e[i]),i++,s++);return r}return t.mixin(n.prototype,{bootstrap:function(e){this.datums=e.datums,this.trie=e.trie},add:function(e){var n=this;e=t.isArray(e)?e:[e],t.each(e,function(e){var r,o;r=n.datums.push(e)-1,o=i(n.datumTokenizer(e)),t.each(o,function(e){var t,i,o;for(t=n.trie,i=e.split("");o=i.shift();)t=t.children[o]||(t.children[o]=s()),t.ids.push(r)})})},get:function(e){var n,s,a=this;return n=i(this.queryTokenizer(e)),t.each(n,function(e){var t,n,i,r;if(s&&0===s.length)return!1;for(t=a.trie,n=e.split("");t&&(i=n.shift());)t=t.children[i];return t&&0===n.length?(r=t.ids.slice(0),void(s=s?o(s,r):r)):(s=[],!1)}),s?t.map(r(s),function(e){return a.datums[e]}):[]},reset:function(){this.datums=[],this.trie=s()},serialize:function(){return{datums:this.datums,trie:this.trie}}}),n}(),u=function(){function i(e){return e.local||null}function s(i){var s,r;return r={url:null,thumbprint:"",ttl:864e5,filter:null,ajax:{}},(s=i.prefetch||null)&&(s=t.isString(s)?{url:s}:s,s=t.mixin(r,s),s.thumbprint=n+s.thumbprint,s.ajax.type=s.ajax.type||"GET",s.ajax.dataType=s.ajax.dataType||"json",!s.url&&e.error("prefetch requires url to be set")),s}function r(n){function i(e){return function(n){return t.debounce(n,e)}}function s(e){return function(n){return t.throttle(n,e)}}var r,o;return o={url:null,cache:!0,wildcard:"%QUERY",replace:null,rateLimitBy:"debounce",rateLimitWait:300,send:null,filter:null,ajax:{}},(r=n.remote||null)&&(r=t.isString(r)?{url:r}:r,r=t.mixin(o,r),r.rateLimiter=/^throttle$/i.test(r.rateLimitBy)?s(r.rateLimitWait):i(r.rateLimitWait),r.ajax.type=r.ajax.type||"GET",r.ajax.dataType=r.ajax.dataType||"json",delete r.rateLimitBy,delete r.rateLimitWait,!r.url&&e.error("remote requires url to be set")),r}return{local:i,prefetch:s,remote:r}}();!function(n){function s(t){t&&(t.local||t.prefetch||t.remote)||e.error("one of local, prefetch, or remote is required"),this.limit=t.limit||5,this.sorter=l(t.sorter),this.dupDetector=t.dupDetector||c,this.local=u.local(t),this.prefetch=u.prefetch(t),this.remote=u.remote(t),this.cacheKey=this.prefetch?this.prefetch.cacheKey||this.prefetch.url:null,this.index=new a({datumTokenizer:t.datumTokenizer,queryTokenizer:t.queryTokenizer}),this.storage=this.cacheKey?new r(this.cacheKey):null}function l(e){function n(t){return t.sort(e)}function i(e){return e}return t.isFunction(e)?n:i}function c(){return!1}var h,d;return h=n.Bloodhound,d={data:"data",protocol:"protocol",thumbprint:"thumbprint"},n.Bloodhound=s,s.noConflict=function(){return n.Bloodhound=h,s},s.tokenizers=i,t.mixin(s.prototype,{_loadPrefetch:function(t){function n(e){r.clear(),r.add(t.filter?t.filter(e):e),r._saveToStorage(r.index.serialize(),t.thumbprint,t.ttl)}var i,s,r=this;return(i=this._readFromStorage(t.thumbprint))?(this.index.bootstrap(i),s=e.Deferred().resolve()):s=e.ajax(t.url,t.ajax).done(n),s},_getFromRemote:function(e,t){function n(e,n){t(e?[]:r.remote.filter?r.remote.filter(n):n)}var i,s,r=this;if(this.transport)return e=e||"",s=encodeURIComponent(e),i=this.remote.replace?this.remote.replace(this.remote.url,e):this.remote.url.replace(this.remote.wildcard,s),this.transport.get(i,this.remote.ajax,n)},_cancelLastRemoteRequest:function(){this.transport&&this.transport.cancel()},_saveToStorage:function(e,t,n){this.storage&&(this.storage.set(d.data,e,n),this.storage.set(d.protocol,location.protocol,n),this.storage.set(d.thumbprint,t,n))},_readFromStorage:function(e){var t,n={};return this.storage&&(n.data=this.storage.get(d.data),n.protocol=this.storage.get(d.protocol),n.thumbprint=this.storage.get(d.thumbprint)),t=n.thumbprint!==e||n.protocol!==location.protocol,n.data&&!t?n.data:null},_initialize:function(){function n(){s.add(t.isFunction(r)?r():r)}var i,s=this,r=this.local;return i=this.prefetch?this._loadPrefetch(this.prefetch):e.Deferred().resolve(),r&&i.done(n),this.transport=this.remote?new o(this.remote):null,this.initPromise=i.promise()},initialize:function(e){return!this.initPromise||e?this._initialize():this.initPromise},add:function(e){this.index.add(e)},get:function(e,n){function i(e){var i=r.slice(0);t.each(e,function(e){var n;return n=t.some(i,function(t){return s.dupDetector(e,t)}),!n&&i.push(e),i.length<s.limit}),n&&n(s.sorter(i))}var s=this,r=[],o=!1;r=this.index.get(e),r=this.sorter(r).slice(0,this.limit),r.length<this.limit?o=this._getFromRemote(e,i):this._cancelLastRemoteRequest(),o||(r.length>0||!this.transport)&&n&&n(r)},clear:function(){this.index.reset()},clearPrefetchCache:function(){this.storage&&this.storage.clear()},clearRemoteCache:function(){this.transport&&o.resetCache()},ttAdapter:function(){return t.bind(this.get,this)}}),s}(this);var l=function(){return{wrapper:'<span class="twitter-typeahead"></span>',dropdown:'<span class="tt-dropdown-menu"></span>',dataset:'<div class="tt-dataset-%CLASS%"></div>',suggestions:'<span class="tt-suggestions"></span>',suggestion:'<div class="tt-suggestion"></div>'}}(),c=function(){var e={wrapper:{position:"relative",display:"inline-block"},hint:{position:"absolute",top:"0",left:"0",borderColor:"transparent",boxShadow:"none",opacity:"1"},input:{position:"relative",verticalAlign:"top",backgroundColor:"transparent"},inputWithNoHint:{position:"relative",verticalAlign:"top"},dropdown:{position:"absolute",top:"100%",left:"0",zIndex:"100",display:"none"},suggestions:{display:"block"},suggestion:{whiteSpace:"nowrap",cursor:"pointer"},suggestionChild:{whiteSpace:"normal"},ltr:{left:"0",right:"auto"},rtl:{left:"auto",right:" 0"}};return t.isMsie()&&t.mixin(e.input,{backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"}),t.isMsie()&&t.isMsie()<=7&&t.mixin(e.input,{marginTop:"-1px"}),e}(),h=function(){function n(t){t&&t.el||e.error("EventBus initialized without el"),this.$el=e(t.el)}var i="typeahead:";return t.mixin(n.prototype,{trigger:function(e){var t=[].slice.call(arguments,1);this.$el.trigger(i+e,t)}}),n}(),d=function(){function e(e,t,n,i){var s;if(!n)return this;for(t=t.split(u),n=i?a(n,i):n,this._callbacks=this._callbacks||{};s=t.shift();)this._callbacks[s]=this._callbacks[s]||{sync:[],async:[]},this._callbacks[s][e].push(n);return this}function t(t,n,i){return e.call(this,"async",t,n,i)}function n(t,n,i){return e.call(this,"sync",t,n,i)}function i(e){var t;if(!this._callbacks)return this;for(e=e.split(u);t=e.shift();)delete this._callbacks[t];return this}function s(e){var t,n,i,s,o;if(!this._callbacks)return this;for(e=e.split(u),i=[].slice.call(arguments,1);(t=e.shift())&&(n=this._callbacks[t]);)s=r(n.sync,this,[t].concat(i)),o=r(n.async,this,[t].concat(i)),s()&&l(o);return this}function r(e,t,n){function i(){for(var i,s=0,r=e.length;!i&&r>s;s+=1)i=e[s].apply(t,n)===!1;return!i}return i}function o(){var e;return e=window.setImmediate?function(e){setImmediate(function(){e()})}:function(e){setTimeout(function(){e()},0)}}function a(e,t){return e.bind?e.bind(t):function(){e.apply(t,[].slice.call(arguments,0))}}var u=/\s+/,l=o();return{onSync:n,onAsync:t,off:i,trigger:s}}(),f=function(e){function n(e,n,i){for(var s,r=[],o=0,a=e.length;a>o;o++)r.push(t.escapeRegExChars(e[o]));return s=i?"\\b("+r.join("|")+")\\b":"("+r.join("|")+")",n?new RegExp(s):new RegExp(s,"i")}var i={node:null,pattern:null,tagName:"strong",className:null,wordsOnly:!1,caseSensitive:!1};return function(s){function r(t){var n,i,r;return(n=a.exec(t.data))&&(r=e.createElement(s.tagName),s.className&&(r.className=s.className),i=t.splitText(n.index),i.splitText(n[0].length),r.appendChild(i.cloneNode(!0)),t.parentNode.replaceChild(r,i)),!!n}function o(e,t){for(var n,i=3,s=0;s<e.childNodes.length;s++)n=e.childNodes[s],n.nodeType===i?s+=t(n)?1:0:o(n,t)}var a;s=t.mixin({},i,s),s.node&&s.pattern&&(s.pattern=t.isArray(s.pattern)?s.pattern:[s.pattern],a=n(s.pattern,s.caseSensitive,s.wordsOnly),o(s.node,r))}}(window.document),p=function(){function n(n){var s,r,a,u,l=this;n=n||{},n.input||e.error("input is missing"),s=t.bind(this._onBlur,this),r=t.bind(this._onFocus,this),a=t.bind(this._onKeydown,this),u=t.bind(this._onInput,this),this.$hint=e(n.hint),this.$input=e(n.input).on("blur.tt",s).on("focus.tt",r).on("keydown.tt",a),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=t.noop),t.isMsie()?this.$input.on("keydown.tt keypress.tt cut.tt paste.tt",function(e){o[e.which||e.keyCode]||t.defer(t.bind(l._onInput,l,e))}):this.$input.on("input.tt",u),this.query=this.$input.val(),this.$overflowHelper=i(this.$input)}function i(t){return e('<pre aria-hidden="true"></pre>').css({position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:t.css("font-family"),fontSize:t.css("font-size"),fontStyle:t.css("font-style"),fontVariant:t.css("font-variant"),fontWeight:t.css("font-weight"),wordSpacing:t.css("word-spacing"),letterSpacing:t.css("letter-spacing"),textIndent:t.css("text-indent"),textRendering:t.css("text-rendering"),textTransform:t.css("text-transform")}).insertAfter(t)}function s(e,t){return n.normalizeQuery(e)===n.normalizeQuery(t)}function r(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}var o;return o={9:"tab",27:"esc",37:"left",39:"right",13:"enter",38:"up",40:"down"},n.normalizeQuery=function(e){return(e||"").replace(/^\s*/g,"").replace(/\s{2,}/g," ")},t.mixin(n.prototype,d,{_onBlur:function(){this.resetInputValue(),this.trigger("blurred")},_onFocus:function(){this.trigger("focused")},_onKeydown:function(e){var t=o[e.which||e.keyCode];this._managePreventDefault(t,e),t&&this._shouldTrigger(t,e)&&this.trigger(t+"Keyed",e)},_onInput:function(){this._checkInputValue()},_managePreventDefault:function(e,t){var n,i,s;switch(e){case"tab":i=this.getHint(),s=this.getInputValue(),n=i&&i!==s&&!r(t);break;case"up":case"down":n=!r(t);break;default:n=!1}n&&t.preventDefault()},_shouldTrigger:function(e,t){var n;switch(e){case"tab":n=!r(t);break;default:n=!0}return n},_checkInputValue:function(){var e,t,n;e=this.getInputValue(),t=s(e,this.query),n=t?this.query.length!==e.length:!1,this.query=e,t?n&&this.trigger("whitespaceChanged",this.query):this.trigger("queryChanged",this.query)},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getQuery:function(){return this.query},setQuery:function(e){this.query=e},getInputValue:function(){return this.$input.val()},setInputValue:function(e,t){this.$input.val(e),t?this.clearHint():this._checkInputValue()},resetInputValue:function(){this.setInputValue(this.query,!0)},getHint:function(){return this.$hint.val()},setHint:function(e){this.$hint.val(e)},clearHint:function(){this.setHint("")},clearHintIfInvalid:function(){var e,t,n,i;e=this.getInputValue(),t=this.getHint(),n=e!==t&&0===t.indexOf(e),i=""!==e&&n&&!this.hasOverflow(),!i&&this.clearHint()
  },getLanguageDirection:function(){return(this.$input.css("direction")||"ltr").toLowerCase()},hasOverflow:function(){var e=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=e},isCursorAtEnd:function(){var e,n,i;return e=this.$input.val().length,n=this.$input[0].selectionStart,t.isNumber(n)?n===e:document.selection?(i=document.selection.createRange(),i.moveStart("character",-e),e===i.text.length):!0},destroy:function(){this.$hint.off(".tt"),this.$input.off(".tt"),this.$hint=this.$input=this.$overflowHelper=null}}),n}(),m=function(){function n(n){n=n||{},n.templates=n.templates||{},n.source||e.error("missing source"),n.name&&!r(n.name)&&e.error("invalid dataset name: "+n.name),this.query=null,this.highlight=!!n.highlight,this.name=n.name||t.getUniqueId(),this.source=n.source,this.displayFn=i(n.display||n.displayKey),this.templates=s(n.templates,this.displayFn),this.$el=e(l.dataset.replace("%CLASS%",this.name))}function i(e){function n(t){return t[e]}return e=e||"value",t.isFunction(e)?e:n}function s(e,n){function i(e){return"<p>"+n(e)+"</p>"}return{empty:e.empty&&t.templatify(e.empty),header:e.header&&t.templatify(e.header),footer:e.footer&&t.templatify(e.footer),suggestion:e.suggestion||i}}function r(e){return/^[_a-zA-Z0-9-]+$/.test(e)}var o="ttDataset",a="ttValue",u="ttDatum";return n.extractDatasetName=function(t){return e(t).data(o)},n.extractValue=function(t){return e(t).data(a)},n.extractDatum=function(t){return e(t).data(u)},t.mixin(n.prototype,d,{_render:function(n,i){function s(){return m.templates.empty({query:n,isEmpty:!0})}function r(){function s(t){var n;return n=e(l.suggestion).append(m.templates.suggestion(t)).data(o,m.name).data(a,m.displayFn(t)).data(u,t),n.children().each(function(){e(this).css(c.suggestionChild)}),n}var r,h;return r=e(l.suggestions).css(c.suggestions),h=t.map(i,s),r.append.apply(r,h),m.highlight&&f({className:"tt-highlight",node:r[0],pattern:n}),r}function h(){return m.templates.header({query:n,isEmpty:!p})}function d(){return m.templates.footer({query:n,isEmpty:!p})}if(this.$el){var p,m=this;this.$el.empty(),p=i&&i.length,!p&&this.templates.empty?this.$el.html(s()).prepend(m.templates.header?h():null).append(m.templates.footer?d():null):p&&this.$el.html(r()).prepend(m.templates.header?h():null).append(m.templates.footer?d():null),this.trigger("rendered")}},getRoot:function(){return this.$el},update:function(e){function t(t){n.canceled||e!==n.query||n._render(e,t)}var n=this;this.query=e,this.canceled=!1,this.source(e,t)},cancel:function(){this.canceled=!0},clear:function(){this.cancel(),this.$el.empty(),this.trigger("rendered")},isEmpty:function(){return this.$el.is(":empty")},destroy:function(){this.$el=null}}),n}(),g=function(){function n(n){var s,r,o,a=this;n=n||{},n.menu||e.error("menu is required"),this.isOpen=!1,this.isEmpty=!0,this.datasets=t.map(n.datasets,i),s=t.bind(this._onSuggestionClick,this),r=t.bind(this._onSuggestionMouseEnter,this),o=t.bind(this._onSuggestionMouseLeave,this),this.$menu=e(n.menu).on("click.tt",".tt-suggestion",s).on("mouseenter.tt",".tt-suggestion",r).on("mouseleave.tt",".tt-suggestion",o),t.each(this.datasets,function(e){a.$menu.append(e.getRoot()),e.onSync("rendered",a._onRendered,a)})}function i(e){return new m(e)}return t.mixin(n.prototype,d,{_onSuggestionClick:function(t){this.trigger("suggestionClicked",e(t.currentTarget))},_onSuggestionMouseEnter:function(t){this._removeCursor(),this._setCursor(e(t.currentTarget),!0)},_onSuggestionMouseLeave:function(){this._removeCursor()},_onRendered:function(){function e(e){return e.isEmpty()}this.isEmpty=t.every(this.datasets,e),this.isEmpty?this._hide():this.isOpen&&this._show(),this.trigger("datasetRendered")},_hide:function(){this.$menu.hide()},_show:function(){this.$menu.css("display","block")},_getSuggestions:function(){return this.$menu.find(".tt-suggestion")},_getCursor:function(){return this.$menu.find(".tt-cursor").first()},_setCursor:function(e,t){e.first().addClass("tt-cursor"),!t&&this.trigger("cursorMoved")},_removeCursor:function(){this._getCursor().removeClass("tt-cursor")},_moveCursor:function(e){var t,n,i,s;if(this.isOpen){if(n=this._getCursor(),t=this._getSuggestions(),this._removeCursor(),i=t.index(n)+e,i=(i+1)%(t.length+1)-1,-1===i)return void this.trigger("cursorRemoved");-1>i&&(i=t.length-1),this._setCursor(s=t.eq(i)),this._ensureVisible(s)}},_ensureVisible:function(e){var t,n,i,s;t=e.position().top,n=t+e.outerHeight(!0),i=this.$menu.scrollTop(),s=this.$menu.height()+parseInt(this.$menu.css("paddingTop"),10)+parseInt(this.$menu.css("paddingBottom"),10),0>t?this.$menu.scrollTop(i+t):n>s&&this.$menu.scrollTop(i+(n-s))},close:function(){this.isOpen&&(this.isOpen=!1,this._removeCursor(),this._hide(),this.trigger("closed"))},open:function(){this.isOpen||(this.isOpen=!0,!this.isEmpty&&this._show(),this.trigger("opened"))},setLanguageDirection:function(e){this.$menu.css("ltr"===e?c.ltr:c.rtl)},moveCursorUp:function(){this._moveCursor(-1)},moveCursorDown:function(){this._moveCursor(1)},getDatumForSuggestion:function(e){var t=null;return e.length&&(t={raw:m.extractDatum(e),value:m.extractValue(e),datasetName:m.extractDatasetName(e)}),t},getDatumForCursor:function(){return this.getDatumForSuggestion(this._getCursor().first())},getDatumForTopSuggestion:function(){return this.getDatumForSuggestion(this._getSuggestions().first())},update:function(e){function n(t){t.update(e)}t.each(this.datasets,n)},empty:function(){function e(e){e.clear()}t.each(this.datasets,e),this.isEmpty=!0},isVisible:function(){return this.isOpen&&!this.isEmpty},destroy:function(){function e(e){e.destroy()}this.$menu.off(".tt"),this.$menu=null,t.each(this.datasets,e)}}),n}(),v=function(){function n(n){var s,r,o;n=n||{},n.input||e.error("missing input"),this.isActivated=!1,this.autoselect=!!n.autoselect,this.minLength=t.isNumber(n.minLength)?n.minLength:1,this.$node=i(n.input,n.withHint),s=this.$node.find(".tt-dropdown-menu"),r=this.$node.find(".tt-input"),o=this.$node.find(".tt-hint"),r.on("blur.tt",function(e){var n,i,o;n=document.activeElement,i=s.is(n),o=s.has(n).length>0,t.isMsie()&&(i||o)&&(e.preventDefault(),e.stopImmediatePropagation(),t.defer(function(){r.focus()}))}),s.on("mousedown.tt",function(e){e.preventDefault()}),this.eventBus=n.eventBus||new h({el:r}),this.dropdown=new g({menu:s,datasets:n.datasets}).onSync("suggestionClicked",this._onSuggestionClicked,this).onSync("cursorMoved",this._onCursorMoved,this).onSync("cursorRemoved",this._onCursorRemoved,this).onSync("opened",this._onOpened,this).onSync("closed",this._onClosed,this).onAsync("datasetRendered",this._onDatasetRendered,this),this.input=new p({input:r,hint:o}).onSync("focused",this._onFocused,this).onSync("blurred",this._onBlurred,this).onSync("enterKeyed",this._onEnterKeyed,this).onSync("tabKeyed",this._onTabKeyed,this).onSync("escKeyed",this._onEscKeyed,this).onSync("upKeyed",this._onUpKeyed,this).onSync("downKeyed",this._onDownKeyed,this).onSync("leftKeyed",this._onLeftKeyed,this).onSync("rightKeyed",this._onRightKeyed,this).onSync("queryChanged",this._onQueryChanged,this).onSync("whitespaceChanged",this._onWhitespaceChanged,this),this._setLanguageDirection()}function i(t,n){var i,r,a,u;i=e(t),r=e(l.wrapper).css(c.wrapper),a=e(l.dropdown).css(c.dropdown),u=i.clone().css(c.hint).css(s(i)),u.val("").removeData().addClass("tt-hint").removeAttr("id name placeholder required").prop("readonly",!0).attr({autocomplete:"off",spellcheck:"false",tabindex:-1}),i.data(o,{dir:i.attr("dir"),autocomplete:i.attr("autocomplete"),spellcheck:i.attr("spellcheck"),style:i.attr("style")}),i.addClass("tt-input").attr({autocomplete:"off",spellcheck:!1}).css(n?c.input:c.inputWithNoHint);try{!i.attr("dir")&&i.attr("dir","auto")}catch(h){}return i.wrap(r).parent().prepend(n?u:null).append(a)}function s(e){return{backgroundAttachment:e.css("background-attachment"),backgroundClip:e.css("background-clip"),backgroundColor:e.css("background-color"),backgroundImage:e.css("background-image"),backgroundOrigin:e.css("background-origin"),backgroundPosition:e.css("background-position"),backgroundRepeat:e.css("background-repeat"),backgroundSize:e.css("background-size")}}function r(e){var n=e.find(".tt-input");t.each(n.data(o),function(e,i){t.isUndefined(e)?n.removeAttr(i):n.attr(i,e)}),n.detach().removeData(o).removeClass("tt-input").insertAfter(e),e.remove()}var o="ttAttrs";return t.mixin(n.prototype,{_onSuggestionClicked:function(e,t){var n;(n=this.dropdown.getDatumForSuggestion(t))&&this._select(n)},_onCursorMoved:function(){var e=this.dropdown.getDatumForCursor();this.input.setInputValue(e.value,!0),this.eventBus.trigger("cursorchanged",e.raw,e.datasetName)},_onCursorRemoved:function(){this.input.resetInputValue(),this._updateHint()},_onDatasetRendered:function(){this._updateHint()},_onOpened:function(){this._updateHint(),this.eventBus.trigger("opened")},_onClosed:function(){this.input.clearHint(),this.eventBus.trigger("closed")},_onFocused:function(){this.isActivated=!0,this.dropdown.open()},_onBlurred:function(){this.isActivated=!1,this.dropdown.empty(),this.dropdown.close()},_onEnterKeyed:function(e,t){var n,i;n=this.dropdown.getDatumForCursor(),i=this.dropdown.getDatumForTopSuggestion(),n?(this._select(n),t.preventDefault()):this.autoselect&&i&&(this._select(i),t.preventDefault())},_onTabKeyed:function(e,t){var n;(n=this.dropdown.getDatumForCursor())?(this._select(n),t.preventDefault()):this._autocomplete(!0)},_onEscKeyed:function(){this.dropdown.close(),this.input.resetInputValue()},_onUpKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorUp(),this.dropdown.open()},_onDownKeyed:function(){var e=this.input.getQuery();this.dropdown.isEmpty&&e.length>=this.minLength?this.dropdown.update(e):this.dropdown.moveCursorDown(),this.dropdown.open()},_onLeftKeyed:function(){"rtl"===this.dir&&this._autocomplete()},_onRightKeyed:function(){"ltr"===this.dir&&this._autocomplete()},_onQueryChanged:function(e,t){this.input.clearHintIfInvalid(),t.length>=this.minLength?this.dropdown.update(t):this.dropdown.empty(),this.dropdown.open(),this._setLanguageDirection()},_onWhitespaceChanged:function(){this._updateHint(),this.dropdown.open()},_setLanguageDirection:function(){var e;this.dir!==(e=this.input.getLanguageDirection())&&(this.dir=e,this.$node.css("direction",e),this.dropdown.setLanguageDirection(e))},_updateHint:function(){var e,n,i,s,r,o;e=this.dropdown.getDatumForTopSuggestion(),e&&this.dropdown.isVisible()&&!this.input.hasOverflow()?(n=this.input.getInputValue(),i=p.normalizeQuery(n),s=t.escapeRegExChars(i),r=new RegExp("^(?:"+s+")(.+$)","i"),o=r.exec(e.value),o?this.input.setHint(n+o[1]):this.input.clearHint()):this.input.clearHint()},_autocomplete:function(e){var t,n,i,s;t=this.input.getHint(),n=this.input.getQuery(),i=e||this.input.isCursorAtEnd(),t&&n!==t&&i&&(s=this.dropdown.getDatumForTopSuggestion(),s&&this.input.setInputValue(s.value),this.eventBus.trigger("autocompleted",s.raw,s.datasetName))},_select:function(e){this.input.setQuery(e.value),this.input.setInputValue(e.value,!0),this._setLanguageDirection(),this.eventBus.trigger("selected",e.raw,e.datasetName),this.dropdown.close(),t.defer(t.bind(this.dropdown.empty,this.dropdown))},open:function(){this.dropdown.open()},close:function(){this.dropdown.close()},setVal:function(e){e=t.toStr(e),this.isActivated?this.input.setInputValue(e):(this.input.setQuery(e),this.input.setInputValue(e,!0)),this._setLanguageDirection()},getVal:function(){return this.input.getQuery()},destroy:function(){this.input.destroy(),this.dropdown.destroy(),r(this.$node),this.$node=null}}),n}();!function(){var n,i,s;n=e.fn.typeahead,i="ttTypeahead",s={initialize:function(n,s){function r(){var r,o,a=e(this);t.each(s,function(e){e.highlight=!!n.highlight}),o=new v({input:a,eventBus:r=new h({el:a}),withHint:t.isUndefined(n.hint)?!0:!!n.hint,minLength:n.minLength,autoselect:n.autoselect,datasets:s}),a.data(i,o)}return s=t.isArray(s)?s:[].slice.call(arguments,1),n=n||{},this.each(r)},open:function(){function t(){var t,n=e(this);(t=n.data(i))&&t.open()}return this.each(t)},close:function(){function t(){var t,n=e(this);(t=n.data(i))&&t.close()}return this.each(t)},val:function(t){function n(){var n,s=e(this);(n=s.data(i))&&n.setVal(t)}function s(e){var t,n;return(t=e.data(i))&&(n=t.getVal()),n}return arguments.length?this.each(n):s(this.first())},destroy:function(){function t(){var t,n=e(this);(t=n.data(i))&&(t.destroy(),n.removeData(i))}return this.each(t)}},e.fn.typeahead=function(t){var n;return s[t]&&"initialize"!==t?(n=this.filter(function(){return!!e(this).data(i)}),s[t].apply(n,[].slice.call(arguments,1))):s.initialize.apply(this,arguments)},e.fn.typeahead.noConflict=function(){return e.fn.typeahead=n,this}}()}(window.jQuery),define("typeahead",["jquery"],function(e){return function(){var t;return t||e.typeahead}}(this)),define("views/course_search_bar_view",["backbone","jquery","underscore","text!templates/course-search-bar.underscore","gettext","typeahead"],function(e,t,n,i){return e.View.extend({tpl:n.template(i),events:{"click .js-search-button":"search","click .tt-dropdown-menu .view-all":"search","keydown .js-search-bar":"handleKeypress"},key:{tab:9,enter:13,esc:27,up:38,down:40},minLength:2,resultsUrl:"/course",suggestionSelected:!1,initialize:function(){this.render()},render:function(){this.$el.html(this.tpl(this.model.toJSON())),this.postRender()},postRender:function(){this.$input=this.$el.find(".js-search-bar"),this.$submit=this.$el.find(".js-search-button"),this.typeaheadLoad(this.minLength)},analyticsAllSearch:function(){window.analytics.track("edx.bi.user.search.submitted",{category:"search"})},analyticsSearch:function(e){window.analytics.track("edx.bi.user.query.submitted",{category:"search",label:e}),this.analyticsAllSearch()},formatQuery:function(e){var t=e?encodeURIComponent(e):!1;return t?t.replace(/%20/g,"+"):""},getValue:function(e){return e.l||e.value},handleKeypress:function(e){var t=e.keyCode;t!==this.key.enter||this.suggestionSelected?t!==this.key.tab||e.shiftKey||(e.preventDefault(),this.$submit.focus()):this.search(e)},search:function(e){var t=this.$input.val(),n=this.formatQuery(t),i=this.resultsUrl;e.preventDefault(),n.length>0&&(i+="?search_query="),this.analyticsSearch(t),window.location.href=i+n},typeaheadLoad:function(e){this.$input.typeahead({highlight:!0,hint:!1,minLength:e})}})}),define("views/typeahead_course_search_bar_view",["jquery","models/suggestion_engine_model","views/course_search_bar_view","gettext","typeahead"],function(e,t,n){return n.extend({events:{"click .js-search-button":"search","click .tt-dropdown-menu .view-all":"search","keydown .js-search-bar":"handleKeypress","typeahead:cursorchanged .js-search-bar":"highlightSuggestion","typeahead:selected .js-search-bar":"selectSuggestion"},sections:{subjects:{},schools:{},xseries:{},courses:{},level:{},languages:{}},postRender:function(){this.$input=this.$el.find(".js-search-bar"),this.$submit=this.$el.find(".js-search-button"),this.initSuggestionEngine(),this.typeaheadLoad(this.minLength)},analyticsSelect:function(e,t){window.analytics.track("edx.bi.user."+e+".picked",{category:"search",label:t}),this.analyticsAllSearch()},formatSuggestion:function(e){var t=e.l;return e.alias&&(t+=' <span class="alias">'+e.alias+"</span>"),t},highlightSuggestion:function(e,t){this.$input.val(this.getValue(t))},initSuggestionEngine:function(){this.sections.subjects=new t({},{facet:"subject"}),this.sections.schools=new t({},{facet:"school"}),this.sections.xseries=new t({},{facet:"xseries"}),this.sections.courses=new t({},{facet:"course"}),this.sections.level=new t({},{facet:"level"}),this.sections.languages=new t({},{facet:"languages",url:"/api/languages/v1/list"})},selectSuggestion:function(e,t,n){this.suggestionSelected=!0,this.$input.typeahead("val",this.getValue(t)),this.setUrl(e,t,n)},setAvailability:function(){var e=[{l:"Archived",value:"Archived"},{l:"Current",value:"Current"},{l:"Self-paced",value:"Self-paced"},{l:"Starting Soon",value:"Starting Soon"},{l:"Upcoming",value:"Upcoming"}];return{name:"s-availability",displayKey:"l",source:this.substringMatcher(e),templates:{header:'<h3 class="league-name">Availability</h3>'}}},setCourseType:function(){var e=[{l:"High School",value:"highschool"},{l:"XSeries Programs",value:"xseries"},{l:"Professional Education",value:"profed"},{l:"Credit",value:"credit"},{l:"Verified Courses",value:"verified"}];return{name:"s-type",displayKey:"l",source:this.substringMatcher(e),templates:{header:'<h3 class="league-name">Course Types</h3>'}}},setFooter:function(){return{name:"view-all",source:this.suggestionEngineEmpty,templates:{empty:'<a href="#" class="view-all">SEE ALL RESULTS</a>'}}},setLevel:function(){var e=[{l:"Introductory",value:"Introductory"},{l:"Intermediate",value:"Intermediate"},{l:"Advanced",value:"Advanced"}];return{name:"s-level",displayKey:"l",source:this.substringMatcher(e),templates:{header:'<h3 class="league-name">Level</h3>'}}},setSection:function(e){var t=e.toLowerCase();return"xseries programs"===t&&(t="xseries"),{name:"s-"+t,value:this.getValue,displayKey:this.formatSuggestion,source:this.sections[t].ttAdapter(),templates:{header:'<h3 class="league-name">'+e+"</h3>"}}},setUrl:function(e,t,n){var i={"s-availability":[this.resultsUrl,"?availability=",this.formatQuery(t.value)].join(""),"s-courses":["/node/",t.id].join(""),"s-xseries":["/node/",t.id].join(""),"s-languages":[this.resultsUrl,"?language=",this.formatQuery(t.l)].join(""),"s-level":[this.resultsUrl,"?level=",this.formatQuery(t.value)].join(""),"s-schools":[this.resultsUrl,"?school=",this.formatQuery(t.alias)].join(""),"s-subjects":[this.resultsUrl,"?subject=",this.formatQuery(t.l)].join(""),"s-type":[this.resultsUrl,"?type=",this.formatQuery(t.value)].join("")};this.analyticsSelect(n.substring(2),t.l),window.location.href=i[n]},substringMatcher:function(t){return function(n,i){var s,r;s=[],r=new RegExp(n,"i"),e.each(t,function(e,t){var n=t.l;r.test(n)&&s.push(t)}),i(s)}},suggestionEngineEmpty:function(e,t){return t([])},typeaheadLoad:function(e){this.$input.typeahead({highlight:!0,hint:!1,minLength:e},this.setSection("Courses"),this.setSection("XSeries Programs"),this.setSection("Subjects"),this.setSection("Schools"),this.setSection("Level"),this.setSection("Languages"),this.setAvailability(),this.setCourseType(),this.setLevel(),this.setFooter())}})}),define("main_menu/views/header_search_desktop_view",["views/typeahead_course_search_bar_view"],function(e){return e.extend({analyticsAllSearch:function(){window.analytics.track("edx.bi.header.search.submitted",{category:"search",mobile:!1})},analyticsSearch:function(e){window.analytics.track("edx.bi.header.query.submitted",{category:"search",label:e,mobile:!1}),this.analyticsAllSearch()},analyticsSelect:function(e,t){window.analytics.track("edx.bi.header."+e+".picked",{category:"search",label:t,mobile:!1}),this.analyticsAllSearch()}})}),define("main_menu/models/active_menu_model.js",["backbone"],function(e){return e.Model.extend({active:!1,mouseOverHeader:!1,mouseOverContent:!1})}),define("main_menu/views/header_search_mobile_view",["views/course_search_bar_view"],function(e){return e.extend({analyticsAllSearch:function(){window.analytics.track("edx.bi.header.search.submitted",{category:"search",mobile:!0})},analyticsSearch:function(e){window.analytics.track("edx.bi.header.query.submitted",{category:"search",label:e,mobile:!0}),this.analyticsAllSearch()}})}),define("text!templates/main-menu-tab.underscore",[],function(){return'<div class="js-tab-reverse" tabindex="0"></div>\n<div class="js-focus-first sr-is-focusable" aria-label="<%- title %> Menu" role="group" tabindex="-1"></div>\n<%= html %>\n<div class="js-focus-last sr-is-focusable" tabindex="0"></div>\n'}),define("main_menu/views/menu_tab_view.js",["backbone","jquery","underscore","text!templates/main-menu-tab.underscore","gettext"],function(e,t,n,i){return e.View.extend({keys:{tab:9,enter:13,esc:27,up:38,down:40},mouse:{rightClick:3},rightClick:!1,tpl:n.template(i),events:{"click a":"analyticsLinkClick","focus .js-focus-last":"focusOnMenuToggle","focus .js-tab-reverse":"focusOnMenuToggle",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",keydown:"listenForEsc",mousedown:"listenForRightClick"},initialize:function(e){this.html=e.html,this.$parent=e.parent,this.$link=e.link,this.activeModel=e.activeModel,this.activeModel.set({active:this.model.get("id")}),this.render()},render:function(){this.$el.html(this.tpl(this.model.toJSON())),this.$parent.after(this.$el),this.postRender()},postRender:function(){this.$menuButton=this.$link.find(".menu-btn"),this.$menuButton.attr("aria-pressed",!0).attr("aria-expanded",!0),this.$menuItem=this.$link.find(".menu-item"),this.$menuItem.addClass("is-open"),this.focusInView()},analyticsLinkClick:function(e){var n=t(e.target);window.analytics.track("edx.bi.link.header_navigation.clicked",{category:"navigation_secondary_"+this.model.get("id"),label:n.html().trim(),link:n.attr("href"),mobile:!1})},focusOnMenuToggle:function(){this.$menuButton.focus()},focusInView:function(){var e=this.$el.find(".js-focus-first");e.length>0&&e.focus()},hide:function(){this.$el.addClass("hidden"),this.$menuButton.attr("aria-pressed",!1).attr("aria-expanded",!1),this.$menuItem.removeClass("is-open"),this.activeModel.set({active:!1})},listenForEsc:function(e){var t=e.keyCode;t===this.keys.esc&&(e.preventDefault(),this.focusOnMenuToggle(),this.hide())},listenForRightClick:function(e){var t=e.which;t===this.mouse.rightClick&&(this.rightClick=!0)},onMouseEnter:function(){this.activeModel.set({mouseOverContent:!0})},onMouseLeave:function(){this.rightClick?this.rightClick=!1:this.activeModel.set({mouseOverContent:!1})},show:function(){this.$el.removeClass("hidden"),this.$menuButton.attr("aria-pressed",!0).attr("aria-expanded",!0),this.$menuItem.addClass("is-open"),this.activeModel.set({active:this.model.get("id")})}})}),define("models/search_bar_model",["backbone"],function(e){return e.Model.extend({defaults:{label:"Search",placeholder:"I want to learn about...",action_label:"Submit a course search",id:1},initialize:function(){this.setId()},getId:function(){var e=1,t=999999999;return Math.floor(Math.random()*(t-e))+e},setId:function(){this.set("id",this.getId())}})}),define("text!templates/main-menu-nav.underscore",[],function(){return'<nav class="main-menu-nav" role="navigation" aria-label="Main">\n    <button class="js-mobile-menu-button mobile-menu-button ai-hamburger-menu" aria-pressed="false" aria-expanded="false">\n        <span class="ai-line burger-top" aria-hidden="true"></span>\n        <span class="ai-line burger-middle x-backslash" aria-hidden="true"></span>\n        <span class="ai-line burger-middle x-forwardslash" aria-hidden="true"></span>\n        <span class="ai-line burger-bottom" aria-hidden="true"></span>\n        <span class="sr">Toggle mobile menu</span>\n    </button>\n    <ul class="menu primary-menu header-search clearfix">\n        <li class="js-focus-first sr-is-focusable sr" tabindex="-1"></li>\n        <li class="menu-link js-search-lite course-search-bar visible-mobile"></li>\n      <% if ( !user.isLoggedIn ) { %>\n        <li class="menu-link visible-mobile user-cta multiple">\n          <% _.each( user.cta, function( cta ) { %>\n            <a href="<%- cta.url %>" class="btn btn-blue"><%- cta.text %></a>\n          <% }); %>\n        </li>\n      <% } else { %>\n        <li class="menu-link visible-mobile user-cta"><a href="<%- user.cta[0].url %>" class="btn btn-blue"><%- user.cta[0].text %></a></li>\n      <% } %>\n\n      <% _.each( data, function( item ) { %>\n        <% if ( item.html.length ) { %>\n        <li class="menu-link menu-open<% if ( activeUrl === item.url ) {%> active<% } %>" data-id="<%- item.id %>">\n            <a href="<%- item.url %>" class="menu-item <%- item.classList %><% if ( activeUrl === item.url ) {%> active<% } %>">\n              <%- item.title %>\n            </a>\n            <button class="menu-btn" aria-pressed="false" aria-expanded="false">\n              <span class="sr"><%- item.title %> menu</span>\n              <i class="icon fa fa-caret-down" aria-hidden="true"></i>\n            </button>\n        <% } else { %>\n        <li class="menu-link<% if ( activeUrl === item.url ) {%> active<% } %>">\n            <a href="<%- item.url %>" class="menu-item <%- item.classList %> <% if ( activeUrl === item.url ) {%> active<% } %>"><%- item.title %></a>\n        <% } %>\n        </li>\n      <% }); %>\n\n      <% if ( user.isLoggedIn ) { %>\n        <% _.each( user.dropdown.items, function( link, index ) { %>\n            <% if ( index > 0 ) { %>\n                <li class="menu-link visible-mobile"><a href="<%- link.url %>"  class="menu-item"><%- link.text %></a></li>\n            <% } %>\n        <% }); %>\n      <% } %>\n    </ul>\n</nav>\n<button class="js-mobile-search btn mobile-search-btn">\n    <span class="sr">Search for a course</span>\n    <i class="icon fa fa-search" aria-hidden="true"></i>\n</button>\n'}),define("main_menu/views/nav_view",["backbone","enquire","jquery","underscore","main_menu/models/active_menu_model.js","main_menu/models/menu_item_collection.js","main_menu/views/header_search_mobile_view","main_menu/views/menu_tab_view.js","models/search_bar_model","text!templates/main-menu-nav.underscore","gettext"],function(e,t,n,i,s,r,o,a,u,l){return e.View.extend({el:"#primary-menu-bar",tpl:i.template(l),desktopEvents:{"mouseenter .menu-link.menu-open":"onMouseEnter","mouseleave .menu-link.menu-open":"clearMouseOverHeader","mouseleave .menu-open":"onMouseLeave","keydown .menu-btn":"keypressShowTab","click .menu-btn":"clickShowTab","click .primary-menu a":"analyticsLinkClick"},mobileEvents:{"click .js-mobile-menu-button":"mobileMenuClick","click .js-mobile-search":"openMobileSearch","click .primary-menu a":"analyticsLinkClick","keydown .js-mobile-menu-button":"mobileMenuButtonKeypress","keydown .primary-menu":"mobileMenuKeypress"},contentReady:!1,enterId:!1,activeUrl:!1,key:{tab:9,enter:13,space:32,esc:27,left:37,up:38,right:39,down:40},initialize:function(e){this.collection=new r,this.collection.on("sync",this.tabInit,this),this.collection.getSample(),this.model=new s,this.model.on("change:mouseOverContent",this.onMouseLeave,this),this.userModel=e.userModel,this.dropdownModel=e.dropdownModel,this.getActiveTab(),this.enableMobileView(),this.toggleEventHandlers(),this.dropdownModel.on("change",this.tabInit,this)},render:function(){var e=i.extend({},this.userModel.toJSON());return e.dropdown=this.dropdownModel.toJSON(),this.$el.html(this.tpl({data:this.collection.toJSON(),activeUrl:this.activeUrl,user:e})),this.postRender(),this},postRender:function(){this.$menu=this.$el.find(".primary-menu"),this.$menuButton=this.$el.find(".js-mobile-menu-button"),this.$mobileMenuFirst=this.$el.find(".js-focus-first"),this.$menuLastItem=this.$menu.find("li:last-of-type"),this.searchBar=new o({el:".js-search-lite",model:new u}),this.$search=this.searchBar.$el,this.analyticsLogoClickListener()},analyticsLinkClick:function(e){var t=n(e.target),i=this.$menu.hasClass("mobile-menu-show");window.analytics.track("edx.bi.link.header_navigation.clicked",{category:"navigation",label:t.html().trim(),link:t.attr("href"),mobile:i})},analyticsLogoClickListener:function(){n("#logo").on("click",function(e){var t=n(e.target).closest("a"),i="none"!==this.$menuButton.css("display");window.analytics.track("edx.bi.link.header_navigation.clicked",{category:"navigation",label:t.attr("title"),link:t.attr("href"),mobile:i})}.bind(this))},analyticsOpenTab:function(e){window.analytics.track("edx.bi.link.header_navigation.open",{category:"navigation_secondary",label:e})},clearMouseOverHeader:function(){this.model.set({mouseOverHeader:!1})},clickShowTab:function(e){var t=this.tabIsOpen(e);t?this.hideTab():this.showTab(e)},enableDesktopView:function(){this.delegateEvents(this.desktopEvents)},enableMobileView:function(){this.delegateEvents(this.mobileEvents)},focusInTab:function(){var e=this.model.get("active");e&&this[e].focusInView()},getActiveTab:function(){var e=this.$el.find(".primary-menu"),t=e.find(".active");t.length>0&&(this.activeUrl=t.find("a").attr("href"))},getView:function(e){var t=n(e.target);return t.hasClass("menu-open")||(t=t.closest(".menu-open")),t.data("id")},getMenuLi:function(e){var t=n(e.target);return t.hasClass(".menu-link")||(t=t.closest(".menu-link")),t},hideOpenMenuItems:function(){this.$menu.find("li .menu-item").removeClass("is-open")},hideOpenTabs:function(){var e=this.$el.find(".menu-tab");e.length>0&&(e.addClass("hidden"),this.hideOpenMenuItems())},hideTab:function(){var e=this.model.get("active"),t=this.model.get("mouseOverContent"),n=this.model.get("mouseOverHeader")===e;!e||t||n||this[e].hide()},isLastMenuItem:function(e){var t=e.hasClass("js-focus-first")?e:e.closest("li");return this.$menuLastItem.html()===t.html()},keypressInTab:function(e){var t,i=e.keyCode;i===this.key.esc&&(e.preventDefault(),t=this[this.model.get("active")],n(t.link).find(".menu-btn").focus(),t.hide())},keypressShowTab:function(e){var t=e.keyCode,n=this.tabIsOpen(e);n&&(t===this.key.tab||t===this.key.down||t===this.key.right?this.focusInTab():t===this.key.esc&&this.hideTab())},loadTab:function(e,t){var n="menu-tab menu-open "+e;this.hideOpenTabs(),this[e]=new a({model:this.collection.get(e),parent:this.$el,className:n,link:t,id:e,activeModel:this.model})},mobileMenuButtonKeypress:function(e){var t=e.keyCode,n=this.$menu.hasClass("mobile-menu-show");t===this.key.esc&&n?(e.preventDefault(),this.toggleMobileMenu(!1)):t===this.key.down&&n?(e.preventDefault(),this.nextMenuItem(this.$mobileMenuFirst)):t===this.key.up&&n&&(e.preventDefault(),this.$menuLastItem.find("a").focus())},mobileMenuClick:function(){var e=!this.$menuButton.hasClass("open");this.toggleMobileMenu(e),e&&this.$mobileMenuFirst.focus()},mobileMenuKeypress:function(e){var t=e.keyCode,i=n(e.target);t===this.key.esc?(e.preventDefault(),this.toggleMobileMenu(!1)):t===this.key.down?(e.preventDefault(),this.nextMenuItem(i)):t===this.key.up?(e.preventDefault(),this.previousMenuItem(i)):t===this.key.tab&&this.isLastMenuItem(i)&&(e.preventDefault(),this.$menuButton.focus())},nextMenuItem:function(e){var t=e.hasClass("js-focus-first")?e:e.closest("li"),n=t.next("li"),i=this.$menuLastItem.html()===t.html();t.hasClass("multiple")&&t.find(".btn:last-of-type").html()!==e.html()?e.next(".btn").focus():n.hasClass("multiple")?n.find("a").first().focus():i?this.$menuButton.focus():n.hasClass("js-search-lite")?this.$search.find("input").focus():n.find("a").focus()},onMouseEnter:function(e){var t=this.getMenuLi(e),n=!1;this.enterId&&(window.clearTimeout(this.enterId),this.enterId=!1),t.on("mouseleave",function(){n=!0}),this.model.set({mouseOverHeader:t.data("id")}),this.enterId=window.setTimeout(function(){var i=this.model.get("active"),s=this.model.get("mouseOverHeader");(!i&&!n||s===i)&&this.showTab(e),t.off()}.bind(this),200)},onMouseLeave:function(){window.setTimeout(function(){this.hideTab()}.bind(this),150)},openMobileSearch:function(){this.$menu.hasClass("mobile-menu-show")||this.toggleMobileMenu(!0),this.$search.find("input").focus()},previousMenuItem:function(e){var t=e.closest("li"),n=t.prev("li"),i=this.$mobileMenuFirst.html()===n.html()||t.hasClass("js-focus-first");t.hasClass("multiple")&&t.find(".btn:first-of-type").html()!==e.html()?e.prev(".btn").focus():n.hasClass("multiple")?n.find("a").last().focus():i?this.$menuButton.focus():n.hasClass("js-search-lite")?this.$search.find("input").focus():n.find("a").focus()},showTab:function(e){var t,i;this.contentReady&&(t=this.getView(e),i=this[t]||!1,this.hideOpenTabs(),i?(i.show(),i.$el.find(".js-focus-first").focus()):this.loadTab(t,n(e.target).closest("li")),this.analyticsOpenTab(t))},tabInit:function(){this.contentReady=!0,this.render()},tabIsOpen:function(e){var t=this.getView(e),n=this[t],i=!1;
  return n&&t===this.model.get("active")&&(i=!0),i},toggleEventHandlers:function(){t.register("screen and (min-width: 980px)",{match:function(){this.enableDesktopView()}.bind(this),unmatch:function(){this.enableMobileView()}.bind(this)})},toggleMobileMenu:function(e){var t=e?"addClass":"removeClass";this.$menu[t]("mobile-menu-show"),this.$menuButton[t]("open").attr("aria-pressed",e).attr("aria-expanded",e),e||this.$menuButton.focus()}})}),define("models/dropdown_model.js",["backbone"],function(e){return e.Model.extend({})}),define("text!templates/dropdown.underscore",[],function(){return'<a href="<%- main.url %>" class="user-title">\n    <span class="sr"><%- main.screenreader_label %> </span><%- main.text %>\n</a>\n<button type="button" class="button button-more has-dropdown js-dropdown-button" aria-haspopup="true" aria-expanded="false" aria-controls="edx-user-menu">\n    <span class="sr"><%- button_label %></span>\n</button>\n<ul class="dropdown-menu is-hidden" id="edx-user-menu" tabindex="-1">\n    <% _.each(items, function(item, index) { %>\n        <li class="dropdown-item<% if (items.length-1 === index) { %> last<% } %>">\n            <a href="<%- item.url %>" class="action<% if (items.length-1 === index) { %> last<% } %>"><%- item.text %></a>\n        </li>\n    <% }); %>\n</ul>\n'}),define("views/dropdown_view.js",["backbone","jquery","underscore","text!../templates/dropdown.underscore","gettext"],function(e,t,n,i){return e.View.extend({tpl:n.template(i),events:{"click .js-dropdown-button":"clickOpenDropdown","click a":"analyticsLinkClick",keydown:"viewKeypress"},menu:".dropdown-menu",key:{tab:9,enter:13,esc:27,up:38,down:40},initialize:function(e){this.$parent=t(e.parent),this.render()},className:function(){return this.options.className},render:function(){return this.$el.html(this.tpl(this.model.toJSON())),this.$parent.replaceWith(this.$el),this.postRender(),this},postRender:function(){this.$menu=this.$el.find(".dropdown-menu"),this.$page=t(document),this.$dropdownButton=t(".js-dropdown-button"),this.listenForPageKeypress()},analyticsLinkClick:function(e){var n=t(e.target),i=n.hasClass("user-title")?"Dashboard":n.html().trim();window.analytics.track("edx.bi.link.header_navigation.clicked",{category:"navigation",label:i,link:n.attr("href"),mobile:!1})},clickCloseDropdown:function(e,n){var i=t(e.target);i.hasClass("button-more")||i.hasClass("has-dropdown")||n.closeDropdownMenus()},clickOpenDropdown:function(e){e.preventDefault(),this.openMenu(t(e.target))},closeDropdownMenus:function(e){var t;t=e?this.$page.find(this.menu):this.$page.find(this.menu).not(":focus"),t.removeClass("is-visible").addClass("is-hidden"),this.$dropdownButton.removeClass("is-active").attr("aria-expanded","false")},focusFirstItem:function(){this.$menu.find(".action").first().focus()},handlerIsAction:function(e,t){e===this.key.up?this.previousMenuItemLink(t):e===this.key.down&&this.nextMenuItemLink(t)},handlerIsButton:function(e){e===this.key.down&&this.focusFirstItem()},handlerIsMenu:function(e){e===this.key.down?this.focusFirstItem():e===this.key.up&&this.$dropdownButton.focus()},handlerPageClicks:function(e){this.$page.off("click.dropdown"),this.$page.on("click.dropdown",function(t){e.clickCloseDropdown(t,e)})},viewKeypress:function(e){var n=e.keyCode,i=t(e.target);(n==this.key.up||n==this.key.down)&&e.preventDefault(),n===this.key.tab&&i.hasClass("last")?(e.preventDefault(),this.$dropdownButton.focus()):n===this.key.esc?(this.closeDropdownMenus(),this.$dropdownButton.focus()):i.hasClass("action")?this.handlerIsAction(n,i):i.hasClass("dropdown-menu")?this.handlerIsMenu(n):i.hasClass("has-dropdown")&&this.handlerIsButton(n)},listenForPageKeypress:function(){this.$page.on("keydown",function(e){var t=e.keyCode;t===this.key.esc&&this.closeDropdownMenus(!0)}.bind(this))},nextMenuItemLink:function(e){var t=this.$el.find(".dropdown-menu").children(".dropdown-item").find(".action"),n=t.length-1,i=t.index(e),s=i+1;i===n?this.$dropdownButton.focus():t.eq(s).focus()},openMenu:function(e){var t=this.$menu;t.hasClass("is-visible")?this.closeDropdownMenus():(e.addClass("is-active").attr("aria-expanded","true"),t.removeClass("is-hidden").addClass("is-visible"),t.focus(),this.setOrientation(),this.handlerPageClicks(this))},previousMenuItemLink:function(e){var t=this.$el.find(".dropdown-menu").children(".dropdown-item").find(".action"),n=t.index(e),i=n-1;0===n?this.$dropdownButton.focus():t.eq(i).focus()},setOrientation:function(){var e=t(window).width()/2,n=this.$dropdownButton.offset().left>e?"align-right":"align-left";this.$menu.removeClass("align-left align-right").addClass(n)}})}),define("text!templates/main-menu-ctas.underscore",[],function(){return'<% _.each(cta, function(action) { %>\n    <a href="<%- action.url %>" class="btn <%- action.classList %>"><%- action.text %></a>\n<% }); %>\n'}),define("main_menu/views/user_cta_view",["backbone","jquery","underscore","models/dropdown_model.js","views/dropdown_view.js","text!templates/main-menu-ctas.underscore","gettext"],function(e,t,n,i,s,r){return e.View.extend({el:".js-user-cta",tpl:n.template(r),events:{"click a":"analyticsLinkClick"},initialize:function(e){this.dropdownModel=e.dropdownModel,this.model.get("isLoggedIn")&&this.model.get("userDetails")?(this.dropdownModel.on("change",this.loadUserMenu,this),this.setDropdown()):(this.dropdownModel.trigger("change"),this.render())},render:function(){this.$el.html(this.tpl(this.model.toJSON()))},analyticsLinkClick:function(e){var n=t(e.target);window.analytics.track("edx.bi.link.header_navigation.clicked",{category:"navigation",label:n.html().trim(),link:n.attr("href"),mobile:!1})},loadUserMenu:function(){this.userMenu=new s({className:"wrapper-more-actions user-menu logged-in",model:this.dropdownModel,parent:".js-user-cta"})},setDropdown:function(){var e=this.model.get("userDetails"),t=this.model.get("cta")[0];this.dropdownModel.set({main:{text:e.username,url:t.url,screenreader_label:"Dashboard for:"},button_label:"User options dropdown",items:[{text:t.text,url:t.url},{text:"Profile",url:e.header_urls.learner_profile},{text:"Account",url:e.header_urls.account_settings},{text:"Sign Out",url:e.header_urls.logout}]})}})}),define("text!templates/main-menu.underscore",[],function(){return'<nav class="js-user-cta user-cta" role="navigation" aria-label="Account"></nav>\n<div class="js-course-search-bar course-search-bar"></div>\n'}),define("main_menu/views/main_menu_view",["backbone","enquire","jquery","underscore","main_menu/models/menu_item_collection.js","main_menu/models/user_model","main_menu/views/header_search_desktop_view","main_menu/views/nav_view","main_menu/views/user_cta_view","models/dropdown_model.js","models/search_bar_model","text!templates/main-menu.underscore","gettext"],function(e,t,n,i,s,r,o,a,u,l,c,h){return e.View.extend({el:".js-edx-header-ui",tpl:i.template(h),initialize:function(){this.userModel=new r,this.dropdownModel=new l,this.searchBarModel=new c,this.render()},render:function(){return this.$el.html(this.tpl()),this.postRender(),this},postRender:function(){this.navView=new a({userModel:this.userModel,dropdownModel:this.dropdownModel}),this.ctaView=new u({model:this.userModel,dropdownModel:this.dropdownModel}),0===n(".page-course").length&&(this.searchBar=new o({el:".js-course-search-bar",model:this.searchBarModel}))}})}),function(){var e={},t={};window.jQuery?define("jquery",[],function(){return window.jQuery}):e.jquery="../vendor/common/jquery-v1.11.2",window._?define("underscore",[],function(){return window._}):e.jquery="../vendor/common/underscore-min",window.Backbone?define("backbone",[],function(){return window.Backbone}):e.backbone="../vendor/common/backbone-min",window.addthis?define("addthis",[],function(){return window.addthis}):e.addthis="../vendor/addthis",t={paths:{addthis:"../vendor/addthis",async:"../async",backbone:"empty",enquire:"../vendor/enquire.min",gettext:"../shim/gettext",jquery:"../vendor/jquery-v1.11.2",jqueryCookie:"../vendor/jquery.cookie",text:"../text",typeahead:"../vendor/typeahead.bundle",underscore:"../vendor/underscore-min"},waitseconds:120,shim:{addthis:{exports:"addthis"},backbone:{deps:["underscore","jquery"],exports:"Backbone"},enquire:{exports:"enquire"},jqueryCookie:{deps:["jquery"],exports:"jqueryCookie"},typeahead:{deps:["jquery"],exports:"typeahead"},underscore:{exports:"_"}}};for(var n in e)({}).hasOwnProperty.call(e,n)&&(t.paths[n]=e[n]);require.config(t)}(),define("config",function(e){return function(){var t;return t||e.config}}(this)),function(){require(["main_menu/views/main_menu_view","config"],function(e){new e})}(),define("main_menu/main_menu",function(){});