/*! * typeahead.js 0.11.1 * https://github.com/twitter/typeahead.js * Copyright 2013-2015 Twitter, Inc. and other contributors; Licensed MIT */ (function(t,e){"function"==typeof define&&define.amd?define("bloodhound",["jquery"],(function(r){return t.Bloodhound=e(r)})):"object"==typeof exports?module.exports=e(require("jquery")):t.Bloodhound=e(jQuery)})(this,(function(t){var e=(function(){"use strict";return{isMsie:function(){return!!/(msie|trident)/i.test(navigator.userAgent)&&navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2]},isBlankString:function(t){return!t||/^\s*$/.test(t)},escapeRegExChars:function(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isArray:t.isArray,isFunction:t.isFunction,isObject:t.isPlainObject,isUndefined:function(t){return void 0===t},isElement:function(t){return!(!t||1!==t.nodeType)},isJQuery:function(e){return e instanceof t},toStr:function(t){return e.isUndefined(t)||null===t?"":t+""},bind:t.proxy,each:function(e,r){t.each(e,(function(t,e){return r(e,t)}))},map:t.map,filter:t.grep,every:function(e,r){var i=!0;return e?(t.each(e,(function(t,n){if(!(i=r.call(null,n,t,e)))return!1})),!!i):i},some:function(e,r){var i=!1;return e?(t.each(e,(function(t,n){if(i=r.call(null,n,t,e))return!1})),!!i):i},mixin:t.extend,identity:function(t){return t},clone:function(e){return t.extend(!0,{},e)},getIdGenerator:function(){var t=0;return function(){return t++}},templatify:function(e){return t.isFunction(e)?e:function(){return String(e)}},defer:function(t){setTimeout(t,0)},debounce:function(t,e,r){var i,n;return function(){var s,o,u=this,c=arguments;return s=function(){i=null,r||(n=t.apply(u,c))},o=r&&!i,clearTimeout(i),i=setTimeout(s,e),o&&(n=t.apply(u,c)),n}},throttle:function(t,e){var r,i,n,s,o,u;return o=0,u=function(){o=new Date,n=null,s=t.apply(r,i)},function(){var c=new Date,a=e-(c-o);return r=this,i=arguments,a<=0?(clearTimeout(n),n=null,o=c,s=t.apply(r,i)):n||(n=setTimeout(u,a)),s}},stringify:function(t){return e.isString(t)?t:JSON.stringify(t)},noop:function(){}}})(),r=(function(){"use strict";return{nonword:r,whitespace:t,obj:{nonword:i(r),whitespace:i(t)}};function t(t){return(t=e.toStr(t))?t.split(/\s+/):[]}function r(t){return(t=e.toStr(t))?t.split(/\W+/):[]}function i(t){return function(r){return r=e.isArray(r)?r:[].slice.call(arguments,0),function(i){var n=[];return e.each(r,(function(r){n=n.concat(t(e.toStr(i[r])))})),n}}}})(),i=(function(){"use strict";function r(r){this.maxSize=e.isNumber(r)?r:100,this.reset(),this.maxSize<=0&&(this.set=this.get=t.noop)}function i(){this.head=this.tail=null}function n(t,e){this.key=t,this.val=e,this.prev=this.next=null}return e.mixin(r.prototype,{set:function(t,e){var r,i=this.list.tail;this.size>=this.maxSize&&(this.list.remove(i),delete this.hash[i.key],this.size--),(r=this.hash[t])?(r.val=e,this.list.moveToFront(r)):(r=new n(t,e),this.list.add(r),this.hash[t]=r,this.size++)},get:function(t){var e=this.hash[t];if(e)return this.list.moveToFront(e),e.val},reset:function(){this.size=0,this.hash={},this.list=new i}}),e.mixin(i.prototype,{add:function(t){this.head&&(t.next=this.head,this.head.prev=t),this.head=t,this.tail=this.tail||t},remove:function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev},moveToFront:function(t){this.remove(t),this.add(t)}}),r})(),n=(function(){"use strict";var r;try{(r=window.localStorage).setItem("~~~","!"),r.removeItem("~~~")}catch(t){r=null}function i(t,i){this.prefix=["__",t,"__"].join(""),this.ttlKey="__ttl__",this.keyMatcher=new RegExp("^"+e.escapeRegExChars(this.prefix)),this.ls=i||r,!this.ls&&this._noop()}return e.mixin(i.prototype,{_prefix:function(t){return this.prefix+t},_ttlKey:function(t){return this._prefix(t)+this.ttlKey},_noop:function(){this.get=this.set=this.remove=this.clear=this.isExpired=e.noop},_safeSet:function(t,e){try{this.ls.setItem(t,e)}catch(t){"QuotaExceededError"===t.name&&(this.clear(),this._noop())}},get:function(t){return this.isExpired(t)&&this.remove(t),o(this.ls.getItem(this._prefix(t)))},set:function(t,r,i){return e.isNumber(i)?this._safeSet(this._ttlKey(t),s(n()+i)):this.ls.removeItem(this._ttlKey(t)),this._safeSet(this._prefix(t),s(r))},remove:function(t){return this.ls.removeItem(this._ttlKey(t)),this.ls.removeItem(this._prefix(t)),this},clear:function(){var t,e=(function(t){var e,i,n=[],s=r.length;for(e=0;er)}}),i;function n(){return(new Date).getTime()}function s(t){return JSON.stringify(e.isUndefined(t)?null:t)}function o(e){return t.parseJSON(e)}})(),s=(function(){"use strict";var r=0,n={},s=6,o=new i(10);function u(t){t=t||{},this.cancelled=!1,this.lastReq=null,this._send=t.transport,this._get=t.limiter?t.limiter(this._get):this._get,this._cache=!1===t.cache?new i(0):o}return u.setMaxPendingRequests=function(t){s=t},u.resetCache=function(){o.reset()},e.mixin(u.prototype,{_fingerprint:function(e){return(e=e||{}).url+e.type+t.param(e.data||{})},_get:function(t,e){var i,o,u=this;function c(t){e(null,t),u._cache.set(i,t)}function a(){e(!0)}function h(){r--,delete n[i],u.onDeckRequestArgs&&(u._get.apply(u,u.onDeckRequestArgs),u.onDeckRequestArgs=null)}i=this._fingerprint(t),this.cancelled||i!==this.lastReq||((o=n[i])?o.done(c).fail(a):re[i]?i++:(n.push(t[r]),r++,i++);return n})(n,o):o})),n?e.map((function(t){for(var e={},r=[],i=0,n=t.length;i