{"version":3,"sources":["source/js/imports/typeahead.bundle-0.11.1.min.js","source/js/imports/funnelback.autocompletion-2.6.0.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"autocomplete.min.js","sourcesContent":["/*!\n * typeahead.js 0.11.1\n * https://github.com/twitter/typeahead.js\n * Copyright 2013-2015 Twitter, Inc. and other contributors; Licensed MIT\n*/\n!function(t,e){\"function\"==typeof define&&define.amd?define(\"bloodhound\",[\"jquery\"],function(n){return t.Bloodhound=e(n)}):\"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,n){t.each(e,function(t,e){return n(e,t)})},map:t.map,filter:t.grep,every:function(e,n){var i=!0;return e?(t.each(e,function(t,r){if(!(i=n.call(null,r,t,e)))return!1}),!!i):i},some:function(e,n){var i=!1;return e?(t.each(e,function(t,r){if(i=n.call(null,r,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,n){var i,r;return function(){var s,o,u=this,a=arguments;return s=function(){i=null,n||(r=t.apply(u,a))},o=n&&!i,clearTimeout(i),i=setTimeout(s,e),o&&(r=t.apply(u,a)),r}},throttle:function(t,e){var n,i,r,s,o,u;return o=0,u=function(){o=new Date,r=null,s=t.apply(n,i)},function(){var a=new Date,c=e-(a-o);return n=this,i=arguments,c<=0?(clearTimeout(r),r=null,o=a,s=t.apply(n,i)):r||(r=setTimeout(u,c)),s}},stringify:function(t){return e.isString(t)?t:JSON.stringify(t)},noop:function(){}}}(),n=\"0.11.1\",i=function(){\"use strict\";return{nonword:n,whitespace:t,obj:{nonword:i(n),whitespace:i(t)}};function t(t){return(t=e.toStr(t))?t.split(/\\s+/):[]}function n(t){return(t=e.toStr(t))?t.split(/\\W+/):[]}function i(t){return function(n){return n=e.isArray(n)?n:[].slice.call(arguments,0),function(i){var r=[];return e.each(n,function(n){r=r.concat(t(e.toStr(i[n])))}),r}}}}(),r=function(){\"use strict\";function n(n){this.maxSize=e.isNumber(n)?n:100,this.reset(),this.maxSize<=0&&(this.set=this.get=t.noop)}function i(){this.head=this.tail=null}return e.mixin(n.prototype,{set:function(t,e){var n,i=this.list.tail;this.size>=this.maxSize&&(this.list.remove(i),delete this.hash[i.key],this.size--),(n=this.hash[t])?(n.val=e,this.list.moveToFront(n)):(n=new function(t,e){this.key=t,this.val=e,this.prev=this.next=null}(t,e),this.list.add(n),this.hash[t]=n,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)}}),n}(),s=function(){\"use strict\";var n;try{(n=window.localStorage).setItem(\"~~~\",\"!\"),n.removeItem(\"~~~\")}catch(t){n=null}function i(t,i){this.prefix=[\"__\",t,\"__\"].join(\"\"),this.ttlKey=\"__ttl__\",this.keyMatcher=new RegExp(\"^\"+e.escapeRegExChars(this.prefix)),this.ls=i||n,!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,n,i){return e.isNumber(i)?this._safeSet(this._ttlKey(t),s(r()+i)):this.ls.removeItem(this._ttlKey(t)),this._safeSet(this._prefix(t),s(n))},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,r=[],s=n.length;for(e=0;en)}}),i;function r(){return(new Date).getTime()}function s(t){return JSON.stringify(e.isUndefined(t)?null:t)}function o(e){return t.parseJSON(e)}}(),o=function(){\"use strict\";var n=0,i={},s=6,o=new r(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 r(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 r,o,u=this;function a(t){e(null,t),u._cache.set(r,t)}function c(){e(!0)}r=this._fingerprint(t),this.cancelled||r!==this.lastReq||((o=i[r])?o.done(a).fail(c):ne[i]?i++:(r.push(t[n]),n++,i++);return r}(o,a):a}),o?e.map(function(t){for(var e={},n=[],i=0,r=t.length;i',menu:'
'}),selectors:(s=r,o={},e.each(s,function(t,e){o[e]=\".\"+t}),o)}).css,html:i.html,classes:i.classes,selectors:i.selectors,mixin:function(t){e.mixin(t,i)}};var s,o;var u;var a}}(),i=function(){\"use strict\";var n,i;function r(e){e&&e.el||t.error(\"EventBus initialized without el\"),this.$el=t(e.el)}return n=\"typeahead:\",i={render:\"rendered\",cursorchange:\"cursorchanged\",select:\"selected\",autocomplete:\"autocompleted\"},e.mixin(r.prototype,{_trigger:function(e,i){var r;return r=t.Event(n+e),(i=i||[]).unshift(r),this.$el.trigger.apply(this.$el,i),r},after:function(t){var e;return e=[].slice.call(arguments,1),this._trigger(\"after\"+t,e).isDefaultPrevented()},before:function(t){var e;return e=[].slice.call(arguments,1),this._trigger(\"before\"+t,e).isDefaultPrevented()},trigger:function(t){var e;this._trigger(t,[].slice.call(arguments,1)),(e=i[t])&&this._trigger(e,[].slice.call(arguments,1))}}),r}(),r=function(){\"use strict\";var t=/\\s+/,e=function(){var t;t=window.setImmediate?function(t){setImmediate(function(){t()})}:function(t){setTimeout(function(){t()},0)};return t}();return{onSync:function(t,e,i){return n.call(this,\"sync\",t,e,i)},onAsync:function(t,e,i){return n.call(this,\"async\",t,e,i)},off:function(e){var n;if(!this._callbacks)return this;e=e.split(t);for(;n=e.shift();)delete this._callbacks[n];return this},trigger:function(n){var r,s,o,u,a;if(!this._callbacks)return this;n=n.split(t),o=[].slice.call(arguments,1);for(;(r=n.shift())&&(s=this._callbacks[r]);)u=i(s.sync,this,[r].concat(o)),a=i(s.async,this,[r].concat(o)),u()&&e(a);return this}};function n(e,n,i,r){var s,o,u;if(!i)return this;for(n=n.split(t),i=r?(u=r,(o=i).bind?o.bind(u):function(){o.apply(u,[].slice.call(arguments,0))}):i,this._callbacks=this._callbacks||{};s=n.shift();)this._callbacks[s]=this._callbacks[s]||{sync:[],async:[]},this._callbacks[s][e].push(i);return this}function i(t,e,n){return function(){for(var i,r=0,s=t.length;!i&&r').css({position:\"absolute\",visibility:\"hidden\",whiteSpace:\"pre\",fontFamily:r.css(\"font-family\"),fontSize:r.css(\"font-size\"),fontStyle:r.css(\"font-style\"),fontVariant:r.css(\"font-variant\"),fontWeight:r.css(\"font-weight\"),wordSpacing:r.css(\"word-spacing\"),letterSpacing:r.css(\"letter-spacing\"),textIndent:r.css(\"text-indent\"),textRendering:r.css(\"text-rendering\"),textTransform:r.css(\"text-transform\")}).insertAfter(r)),this._checkLanguageDirection(),0===this.$hint.length&&(this.setHint=this.getHint=this.clearHint=this.clearHintIfInvalid=e.noop)}return n={9:\"tab\",27:\"esc\",37:\"left\",39:\"right\",13:\"enter\",38:\"up\",40:\"down\"},i.normalizeQuery=function(t){return e.toStr(t).replace(/^\\s*/g,\"\").replace(/\\s{2,}/g,\" \")},e.mixin(i.prototype,r,{_onBlur:function(){this.resetInputValue(),this.trigger(\"blurred\")},_onFocus:function(){this.queryWhenFocused=this.query,this.trigger(\"focused\")},_onKeydown:function(t){var e=n[t.which||t.keyCode];this._managePreventDefault(e,t),e&&this._shouldTrigger(e,t)&&this.trigger(e+\"Keyed\",t)},_onInput:function(){this._setQuery(this.getInputValue()),this.clearHintIfInvalid(),this._checkLanguageDirection()},_managePreventDefault:function(t,e){var n;switch(t){case\"up\":case\"down\":n=!s(e);break;default:n=!1}n&&e.preventDefault()},_shouldTrigger:function(t,e){var n;switch(t){case\"tab\":n=!s(e);break;default:n=!0}return n},_checkLanguageDirection:function(){var t=(this.$input.css(\"direction\")||\"ltr\").toLowerCase();this.dir!==t&&(this.dir=t,this.$hint.attr(\"dir\",t),this.trigger(\"langDirChanged\",t))},_setQuery:function(t,e){var n,r,s,o;s=t,o=this.query,r=!!(n=i.normalizeQuery(s)===i.normalizeQuery(o))&&this.query.length!==t.length,this.query=t,e||n?!e&&r&&this.trigger(\"whitespaceChanged\",this.query):this.trigger(\"queryChanged\",this.query)},bind:function(){var t,i,r,s,o=this;return t=e.bind(this._onBlur,this),i=e.bind(this._onFocus,this),r=e.bind(this._onKeydown,this),s=e.bind(this._onInput,this),this.$input.on(\"blur.tt\",t).on(\"focus.tt\",i).on(\"keydown.tt\",r),!e.isMsie()||e.isMsie()>9?this.$input.on(\"input.tt\",s):this.$input.on(\"keydown.tt keypress.tt cut.tt paste.tt\",function(t){n[t.which||t.keyCode]||e.defer(e.bind(o._onInput,o,t))}),this},focus:function(){this.$input.focus()},blur:function(){this.$input.blur()},getLangDir:function(){return this.dir},getQuery:function(){return this.query||\"\"},setQuery:function(t,e){this.setInputValue(t),this._setQuery(t,e)},hasQueryChangedSinceLastFocus:function(){return this.query!==this.queryWhenFocused},getInputValue:function(){return this.$input.val()},setInputValue:function(t){this.$input.val(t),this.clearHintIfInvalid(),this._checkLanguageDirection()},resetInputValue:function(){this.setInputValue(this.query)},getHint:function(){return this.$hint.val()},setHint:function(t){this.$hint.val(t)},clearHint:function(){this.setHint(\"\")},clearHintIfInvalid:function(){var t,e,n;n=(t=this.getInputValue())!==(e=this.getHint())&&0===e.indexOf(t),!(\"\"!==t&&n&&!this.hasOverflow())&&this.clearHint()},hasFocus:function(){return this.$input.is(\":focus\")},hasOverflow:function(){var t=this.$input.width()-2;return this.$overflowHelper.text(this.getInputValue()),this.$overflowHelper.width()>=t},isCursorAtEnd:function(){var t,n,i;return t=this.$input.val().length,n=this.$input[0].selectionStart,e.isNumber(n)?n===t:!document.selection||((i=document.selection.createRange()).moveStart(\"character\",-t),t===i.text.length)},destroy:function(){this.$hint.off(\".tt\"),this.$input.off(\".tt\"),this.$overflowHelper.remove(),this.$hint=this.$input=this.$overflowHelper=t(\"
\")}}),i;function s(t){return t.altKey||t.ctrlKey||t.metaKey||t.shiftKey}}(),u=function(){\"use strict\";var n,i;function o(n,r){var s;(n=n||{}).templates=n.templates||{},n.templates.notFound=n.templates.notFound||n.templates.empty,n.source||t.error(\"missing source\"),n.node||t.error(\"missing node\"),n.name&&(s=n.name,!/^[_a-zA-Z0-9-]+$/.test(s))&&t.error(\"invalid dataset name: \"+n.name),r.mixin(this),this.highlight=!!n.highlight,this.name=n.name||i(),this.limit=n.limit||5,this.displayFn=function(t){return t=t||e.stringify,e.isFunction(t)?t:function(e){return e[t]}}(n.display||n.displayKey),this.templates=function(n,i){return{notFound:n.notFound&&e.templatify(n.notFound),pending:n.pending&&e.templatify(n.pending),header:n.header&&e.templatify(n.header),footer:n.footer&&e.templatify(n.footer),suggestion:n.suggestion||function(e){return t(\"
\").text(i(e))},group:n.group||function(e){return t(\"
\").text(i(e))}}}(n.templates,this.displayFn),this.source=n.source.__ttAdapter?n.source.__ttAdapter():n.source,this.async=e.isUndefined(n.async)?this.source.length>2:!!n.async,this._resetLastSuggestion(),this.$el=t(n.node).addClass(this.classes.dataset).addClass(this.classes.dataset+\"-\"+this.name)}return n={val:\"tt-selectable-display\",obj:\"tt-selectable-object\"},i=e.getIdGenerator(),o.extractData=function(e){var i=t(e);return i.data(n.obj)?{val:i.data(n.val)||\"\",obj:i.data(n.obj)||null}:null},e.mixin(o.prototype,r,{_overwrite:function(t,e){(e=e||[]).length?this._renderSuggestions(t,e):this.async&&this.templates.pending?this._renderPending(t):!this.async&&this.templates.notFound?this._renderNotFound(t):this._empty(),this.trigger(\"rendered\",this.name,e,!1)},_append:function(t,e){(e=e||[]).length&&this.$lastSuggestion.length?this._appendSuggestions(t,e):e.length?this._renderSuggestions(t,e):!this.$lastSuggestion.length&&this.templates.notFound&&this._renderNotFound(t),this.trigger(\"rendered\",this.name,e,!0)},_renderSuggestions:function(t,e){var n;n=this._getSuggestionsFragment(t,e),this.$lastSuggestion=n.children().last(),this.$el.html(n).prepend(this._getHeader(t,e)).append(this._getFooter(t,e))},_appendSuggestions:function(t,e){var n,i;i=(n=this._getSuggestionsFragment(t,e)).children().last(),this.$lastSuggestion.after(n),this.$lastSuggestion=i},_renderPending:function(t){var e=this.templates.pending;this._resetLastSuggestion(),e&&this.$el.html(e({query:t,dataset:this.name}))},_renderNotFound:function(t){var e=this.templates.notFound;this._resetLastSuggestion(),e&&this.$el.html(e({query:t,dataset:this.name}))},_empty:function(){this.$el.empty(),this._resetLastSuggestion()},_getSuggestionsFragment:function(i,r){var o,u=this;return o=document.createDocumentFragment(),e.each(r,function(e){var r,s;s=u._injectQuery(i,e),r=e.value?t(u.templates.suggestion(s)).data(n.obj,e).data(n.val,u.displayFn(e)).addClass(u.classes.suggestion+\" \"+u.classes.selectable):t(u.templates.group(s)).addClass(u.classes.group),o.appendChild(r[0])}),this.highlight&&s({className:this.classes.highlight,node:o,pattern:i}),t(o)},_getFooter:function(t,e){return this.templates.footer?this.templates.footer({query:t,suggestions:e,dataset:this.name}):null},_getHeader:function(t,e){return this.templates.header?this.templates.header({query:t,suggestions:e,dataset:this.name}):null},_resetLastSuggestion:function(){this.$lastSuggestion=t()},_injectQuery:function(t,n){return e.isObject(n)?e.mixin({_query:t},n):n},update:function(e){var n=this,i=!1,r=!1,s=0;function o(t){r||(r=!0,t=(t||[]).slice(0,n.limit),s=t.length,n._overwrite(e,t),s\")}}),o}(),a=function(){\"use strict\";function n(n,i){var r=this;(n=n||{}).node||t.error(\"node is required\"),i.mixin(this),this.$node=t(n.node),this.query=null,this.datasets=e.map(n.datasets,function(e){var n=r.$node.find(e.node).first();return e.node=n.length?n:t(\"
\").appendTo(r.$node),new u(e,i)})}return e.mixin(n.prototype,r,{_onSelectableClick:function(e){this.trigger(\"selectableClicked\",t(e.currentTarget))},_onRendered:function(t,e,n,i){this.$node.toggleClass(this.classes.empty,this._allDatasetsEmpty()),this.trigger(\"datasetRendered\",e,n,i)},_onCleared:function(){this.$node.toggleClass(this.classes.empty,this._allDatasetsEmpty()),this.trigger(\"datasetCleared\")},_propagate:function(){this.trigger.apply(this,arguments)},_allDatasetsEmpty:function(){return e.every(this.datasets,function(t){return t.isEmpty()})},_getSelectables:function(){return this.$node.find(this.selectors.selectable)},_removeCursor:function(){var t=this.getActiveSelectable();t&&t.removeClass(this.classes.cursor)},_ensureVisible:function(t){var e,n,i,r;n=(e=t.position().top)+t.outerHeight(!0),i=this.$node.scrollTop(),r=this.$node.height()+parseInt(this.$node.css(\"paddingTop\"),10)+parseInt(this.$node.css(\"paddingBottom\"),10),e<0?this.$node.scrollTop(i+e):r\"),e.each(this.datasets,function(t){t.destroy()})}}),n}(),c=function(){\"use strict\";var t=a.prototype;function n(){a.apply(this,[].slice.call(arguments,0))}return e.mixin(n.prototype,a.prototype,{open:function(){return!this._allDatasetsEmpty()&&this._show(),t.open.apply(this,[].slice.call(arguments,0))},close:function(){return this._hide(),t.close.apply(this,[].slice.call(arguments,0))},_onRendered:function(){return this._allDatasetsEmpty()?this._hide():this.isOpen()&&this._show(),t._onRendered.apply(this,[].slice.call(arguments,0))},_onCleared:function(){return this._allDatasetsEmpty()?this._hide():this.isOpen()&&this._show(),t._onCleared.apply(this,[].slice.call(arguments,0))},setLanguageDirection:function(e){return this.$node.css(\"ltr\"===e?this.css.ltr:this.css.rtl),t.setLanguageDirection.apply(this,[].slice.call(arguments,0))},_hide:function(){this.$node.hide()},_show:function(){this.$node.css(\"display\",\"block\")}}),n}(),h=function(){\"use strict\";function n(n,r){var s,o,u,a,c,h,l,f,d,p,g;(n=n||{}).input||t.error(\"missing input\"),n.menu||t.error(\"missing menu\"),n.eventBus||t.error(\"missing event bus\"),r.mixin(this),this.eventBus=n.eventBus,this.minLength=e.isNumber(n.minLength)?n.minLength:1,this.input=n.input,this.menu=n.menu,this.enabled=!0,this.active=!1,this.input.hasFocus()&&this.activate(),this.dir=this.input.getLangDir(),this._hacks(),this.menu.bind().onSync(\"selectableClicked\",this._onSelectableClicked,this).onSync(\"asyncRequested\",this._onAsyncRequested,this).onSync(\"asyncCanceled\",this._onAsyncCanceled,this).onSync(\"asyncReceived\",this._onAsyncReceived,this).onSync(\"datasetRendered\",this._onDatasetRendered,this).onSync(\"datasetCleared\",this._onDatasetCleared,this),s=i(this,\"activate\",\"open\",\"_onFocused\"),o=i(this,\"deactivate\",\"_onBlurred\"),u=i(this,\"isActive\",\"isOpen\",\"_onEnterKeyed\"),a=i(this,\"isActive\",\"isOpen\",\"_onTabKeyed\"),c=i(this,\"isActive\",\"_onEscKeyed\"),h=i(this,\"isActive\",\"open\",\"_onUpKeyed\"),l=i(this,\"isActive\",\"open\",\"_onDownKeyed\"),f=i(this,\"isActive\",\"isOpen\",\"_onLeftKeyed\"),d=i(this,\"isActive\",\"isOpen\",\"_onRightKeyed\"),p=i(this,\"_openIfActive\",\"_onQueryChanged\"),g=i(this,\"_openIfActive\",\"_onWhitespaceChanged\"),this.input.bind().onSync(\"focused\",s,this).onSync(\"blurred\",o,this).onSync(\"enterKeyed\",u,this).onSync(\"tabKeyed\",a,this).onSync(\"escKeyed\",c,this).onSync(\"upKeyed\",h,this).onSync(\"downKeyed\",l,this).onSync(\"leftKeyed\",f,this).onSync(\"rightKeyed\",d,this).onSync(\"queryChanged\",p,this).onSync(\"whitespaceChanged\",g,this).onSync(\"langDirChanged\",this._onLangDirChanged,this)}return e.mixin(n.prototype,{_hacks:function(){var n,i;n=this.input.$input||t(\"
\"),i=this.menu.$node||t(\"
\"),n.on(\"blur.tt\",function(t){var r,s,o;r=document.activeElement,s=i.is(r),o=i.has(r).length>0,e.isMsie()&&(s||o)&&(t.preventDefault(),t.stopImmediatePropagation(),e.defer(function(){n.focus()}))}),i.on(\"mousedown.tt\",function(t){t.preventDefault()})},_onSelectableClicked:function(t,e){this.select(e)},_onDatasetCleared:function(){this._updateHint()},_onDatasetRendered:function(t,e,n,i){this._updateHint(),this.eventBus.trigger(\"render\",n,i,e)},_onAsyncRequested:function(t,e,n){this.eventBus.trigger(\"asyncrequest\",n,e)},_onAsyncCanceled:function(t,e,n){this.eventBus.trigger(\"asynccancel\",n,e)},_onAsyncReceived:function(t,e,n){this.eventBus.trigger(\"asyncreceive\",n,e)},_onFocused:function(){this._minLengthMet()&&this.menu.update(this.input.getQuery())},_onBlurred:function(){this.input.hasQueryChangedSinceLastFocus()&&this.eventBus.trigger(\"change\",this.input.getQuery())},_onEnterKeyed:function(t,e){var n;(n=this.menu.getActiveSelectable())&&this.select(n)&&e.preventDefault()},_onTabKeyed:function(t,e){var n;(n=this.menu.getActiveSelectable())?this.select(n)&&e.preventDefault():(n=this.menu.getTopSelectable())&&this.autocomplete(n)&&e.preventDefault()},_onEscKeyed:function(){this.close()},_onUpKeyed:function(){this.moveCursor(-1)},_onDownKeyed:function(){this.moveCursor(1)},_onLeftKeyed:function(){\"rtl\"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onRightKeyed:function(){\"ltr\"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onQueryChanged:function(t,e){this._minLengthMet(e)?this.menu.update(e):this.menu.empty()},_onWhitespaceChanged:function(){this._updateHint()},_onLangDirChanged:function(t,e){this.dir!==e&&(this.dir=e,this.menu.setLanguageDirection(e))},_openIfActive:function(){this.isActive()&&this.open()},_minLengthMet:function(t){return(t=e.isString(t)?t:this.input.getQuery()||\"\").length>=this.minLength},_updateHint:function(){var t,n,i,r,s,u;t=this.menu.getTopSelectable(),n=this.menu.getSelectableData(t),i=this.input.getInputValue(),!n||e.isBlankString(i)||this.input.hasOverflow()?this.input.clearHint():(r=o.normalizeQuery(i),s=e.escapeRegExChars(r),(u=new RegExp(\"^(?:\"+s+\")(.+$)\",\"i\").exec(n.val))&&this.input.setHint(i+u[1]))},isEnabled:function(){return this.enabled},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},isActive:function(){return this.active},activate:function(){return!!this.isActive()||!(!this.isEnabled()||this.eventBus.before(\"active\"))&&(this.active=!0,this.eventBus.trigger(\"active\"),!0)},deactivate:function(){return!this.isActive()||!this.eventBus.before(\"idle\")&&(this.active=!1,this.close(),this.eventBus.trigger(\"idle\"),!0)},isOpen:function(){return this.menu.isOpen()},open:function(){return this.isOpen()||this.eventBus.before(\"open\")||(this.menu.open(),this._updateHint(),this.eventBus.trigger(\"open\")),this.isOpen()},close:function(){return this.isOpen()&&!this.eventBus.before(\"close\")&&(this.menu.close(),this.input.clearHint(),this.input.resetInputValue(),this.eventBus.trigger(\"close\")),!this.isOpen()},setVal:function(t){this.input.setQuery(e.toStr(t))},getVal:function(){return this.input.getQuery()},select:function(t){var e=this.menu.getSelectableData(t);return!(!e||this.eventBus.before(\"select\",e.obj))&&(this.input.setQuery(e.val,!0),this.eventBus.trigger(\"select\",e.obj),this.close(),this.eventBus.after(\"select\",e.obj),!0)},autocomplete:function(t){var e,n;return e=this.input.getQuery(),!(!((n=this.menu.getSelectableData(t))&&e!==n.val)||this.eventBus.before(\"autocomplete\",n.obj))&&(this.input.setQuery(n.val),this.eventBus.trigger(\"autocomplete\",n.obj),!0)},moveCursor:function(t){var e,n,i,r;return e=this.input.getQuery(),n=this.menu.selectableRelativeToCursor(t),r=(i=this.menu.getSelectableData(n))?i.obj:null,!(this._minLengthMet()&&this.menu.update(e))&&!this.eventBus.before(\"cursorchange\",r)&&(this.menu.setCursor(n),i?this.input.setInputValue(i.val):(this.input.resetInputValue(),this._updateHint()),this.eventBus.trigger(\"cursorchange\",r),!0)},destroy:function(){this.input.destroy(),this.menu.destroy()}}),n;function i(t){var n=[].slice.call(arguments,1);return function(){var i=[].slice.call(arguments);e.each(n,function(e){return t[e].apply(t,i)})}}}();!function(){\"use strict\";var r,s,u;function l(e,n){e.each(function(){var e,i=t(this);(e=i.data(s.typeahead))&&n(e,i)})}function f(n){var i;return(i=e.isJQuery(n)||e.isElement(n)?t(n).first():[]).length?i:null}r=t.fn.typeahead,s={www:\"tt-www\",attrs:\"tt-attrs\",typeahead:\"tt-typeahead\"},u={initialize:function(r,u){var l;return u=e.isArray(u)?u:[].slice.call(arguments,1),l=n((r=r||{}).classNames),this.each(function(){var n,d,p,g,m,y,v,_,b,w,S;e.each(u,function(t){t.highlight=!!r.highlight}),n=t(this),d=t(l.html.wrapper),p=f(r.hint),g=f(r.menu),m=!1!==r.hint&&!p,y=!1!==r.menu&&!g,m&&(x=n,A=l,p=x.clone().addClass(A.classes.hint).removeData().css(A.css.hint).css((k=x,{backgroundAttachment:k.css(\"background-attachment\"),backgroundClip:k.css(\"background-clip\"),backgroundColor:k.css(\"background-color\"),backgroundImage:k.css(\"background-image\"),backgroundOrigin:k.css(\"background-origin\"),backgroundPosition:k.css(\"background-position\"),backgroundRepeat:k.css(\"background-repeat\"),backgroundSize:k.css(\"background-size\")})).prop(\"readonly\",!0).removeAttr(\"id name placeholder required\").attr({autocomplete:\"off\",spellcheck:\"false\",tabindex:-1})),y&&(g=t(l.html.menu).css(l.css.menu)),p&&p.val(\"\"),n=function(t,e){t.data(s.attrs,{dir:t.attr(\"dir\"),autocomplete:t.attr(\"autocomplete\"),spellcheck:t.attr(\"spellcheck\"),style:t.attr(\"style\")}),t.addClass(e.classes.input).attr({autocomplete:\"off\",spellcheck:!1});try{!t.attr(\"dir\")&&t.attr(\"dir\",\"auto\")}catch(t){}return t}(n,l),(m||y)&&(d.css(l.css.wrapper),n.css(m?l.css.input:l.css.inputWithNoHint),n.wrap(d).parent().prepend(m?p:null).append(y?g:null));var x,A,k;S=y?c:a,v=new i({el:n}),_=new o({hint:p,input:n},l),b=new S({node:g,datasets:u},l),w=new h({input:_,menu:b,eventBus:v,minLength:r.minLength},l),n.data(s.www,l),n.data(s.typeahead,w)})},isEnabled:function(){var t;return l(this.first(),function(e){t=e.isEnabled()}),t},enable:function(){return l(this,function(t){t.enable()}),this},disable:function(){return l(this,function(t){t.disable()}),this},isActive:function(){var t;return l(this.first(),function(e){t=e.isActive()}),t},activate:function(){return l(this,function(t){t.activate()}),this},deactivate:function(){return l(this,function(t){t.deactivate()}),this},isOpen:function(){var t;return l(this.first(),function(e){t=e.isOpen()}),t},open:function(){return l(this,function(t){t.open()}),this},close:function(){return l(this,function(t){t.close()}),this},select:function(e){var n=!1,i=t(e);return l(this.first(),function(t){n=t.select(i)}),n},autocomplete:function(e){var n=!1,i=t(e);return l(this.first(),function(t){n=t.autocomplete(i)}),n},moveCursor:function(t){var e=!1;return l(this.first(),function(n){e=n.moveCursor(t)}),e},val:function(t){var e;return arguments.length?(l(this,function(e){e.setVal(t)}),this):(l(this.first(),function(t){e=t.getVal()}),e)},destroy:function(){return l(this,function(t,n){var i,r,o;r=(i=n).data(s.www),o=i.parent().filter(r.selectors.wrapper),e.each(i.data(s.attrs),function(t,n){e.isUndefined(t)?i.removeAttr(n):i.attr(n,t)}),i.removeData(s.typeahead).removeData(s.www).removeData(s.attr).removeClass(r.classes.input),o.length&&(i.detach().insertAfter(o),o.remove()),t.destroy()}),this}},t.fn.typeahead=function(t){return u[t]?u[t].apply(this,[].slice.call(arguments,1)):u.initialize.apply(this,arguments)},t.fn.typeahead.noConflict=function(){return t.fn.typeahead=r,this}}()});","/*\n * Funnelback auto-completion plugin\n * version 2.6.0\n *\n * author: Liliana Nowak\n * Copyright Funnelback, 2015-2017\n *\n * @requires jQuery https://jquery.com@1.10.2\n * @requires Typeahead https://twitter.github.io/typeahead.js@0.11.1\n * @requires Handlebars https://handlebarsjs.com@4.0.5\n */\n(function($) {\n 'use strict';\n\n\tvar autocompletion = function(element, options) {\n\t\t// Global references\n\t\tthis.$element = $(element);\n\t\tthis.options = options;\n\n\t\tthis.init();\n\t}\n\n\t// Default options\n\tautocompletion.defaults = {\n\t\t// set configuration\n\t\tdatasets : null,\t\t\t\t// {set1: {url: ''}, set2: {...}, set3: {...}}\n\t\t/*\n\t\tdefaultCall : {\t\t\t\t// 'string'|[]|{}; use to trigger auto-completion when input value is empty and length=0\n\t\t\tparams : {},\t\t\t\t\t\t// {}; list of parameters added to request\n\t\t\turl : '' \t\t\t\t\t\t// 'string'; URL to call request\n\t\t\ttransform : customFunctionToMapData,// function(set, data); transform function used to map response data\n\t\t},\n\t\tdefaultCall : '',\t\t\t\t// 'string'; query to replace empty value and call request\n\t\tdefaultCall : [],\t\t\t\t// [{value: '', label: ''}, {value: '', label: ''}]; list of hardcoded data to fulfill dropdown menu\n\t\tdefaultCall : {\n\t\t\tdata : [],\t\t\t\t// []; list of hardcoded data\n\t\t\ttransform : function \t\t// function(set, data); transform function used to map hardcoded data\n\t\t},\n\t\t*/\n\t\tcallback \t\t: null,\t\t\t// function(set, suggestions); callback function applied to suggestions before returning them to typeahead plugin\n\t\tgroup \t\t\t: false,\t\t// true|false; enable grouping suggestions based on parameter itemGroup\n\t\tgroupOrder \t\t: [],\t\t\t// []; list of group headers used to sort grouped suggestions in that order\n\t\tfacets \t\t\t: {\t\t\t\t// {}; list of parameters applied when default search-based auto-completion is enabled\n\t\t\tblacklist\t: [],\t// []; list of facet categories names not to displayed\n\t\t\twhitelist\t: [],\t// []; list of facet categories names to display\n\t\t\tshow\t\t: 2,\t// integer; maximum number of facets values to display per facet category; if not set will display all facet category values\n\t\t\turl \t\t: null, // string; the target URL to apply facets parameters to; By default it'll be current location\n\t\t},\n\t\titemGroup \t\t: 'category',\t// 'string'; the name of field used to group suggestions and display as group header in dropdown\n\t\titemLabel \t\t: 'value',\t\t// 'string'; the name of a field to be displayed in input field\n\t\ttemplate \t\t: {\t\t\t\t// {notFound: '', pending: '', header: '', footer: '', group: '', suggestion: ''}\n\t\t\tgroup: function(context) { return $('
').html(String(context.label)); },\n\t\t\tsuggestion: function(context) { return $('
').html(String(context.label)); }\n\t\t},\n\t\ttemplateMerge \t: true,\t\t\t// true|false; to wrap notFound and pending template with header and footer template\n\t\ttransform \t\t: _processSetData, // function(set, suggestion, index); transform function used to map response data\n\n\t\t// URL settings\n\t\tcollection \t\t: null,\t\t\t// 'string'; the collection name\n\t\tdataType \t\t: 'json',\t\t// 'json'|'jsonp'; the type of data returned back from the server\n\t\talpha \t\t\t: '0.5',\t\t// 'string'; adjust the balance between length and relevancy for spelling based suggestions\n\t\tformat \t\t\t: 'extended',\t// 'simple|extended'; mapping into 'json' or 'json++'\n\t\tparams \t\t\t: null,\t\t\t// {}; custom URL parameters\n\t\tprofile \t\t: '_default',\t// 'string'; the profile name\n\t\tprogram \t\t: '/s/suggest.json', // 'string'; program/URL used to generate auto-completion suggestions\n\t\tshow \t\t\t: 10,\t\t\t// integer; maximum number of suggestions to diplay in dropdown per set\n\t\tsort \t\t\t: 0,\t\t\t// integer; set the auto-completion suggestions sort order when program='/s/suggest.json'\n\t\tqueryKey \t\t: 'partial_query', // 'string'; the name of URL parameter to run search query\n\t\tqueryVal \t\t: '%QUERY',\t\t// 'string'; the value to be replaced in url with the URI encoded query\n\n\t\t// display settings\n\t\tlength \t: 3,\t\t\t// integer; the minimum character length to trigger query completion\n\t\thorizontal \t: false,\t\t// true|false; if true, display datasets in columns, else one below the other\n\t\tscrollable \t: false,\t\t// true|false; to limit height of a menu dropdown to maxheight by adding vertical scroll\n\n\t\t// logs\n\t\tlogging \t\t: true,\n\t\tinteractionLog \t: '/s/log',\n\n\t\t//typeahead settings\n\t\ttypeahead: {\n\t\t\tclassNames : {},\t\t\t// {}; to override any of default classes, more https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md#class-names\n\t\t\thighlight : true,\t\t\t// true|false; when suggestions are rendered, pattern matches for the current query in text nodes will be wrapped in a strong element with its class set to {{classNames.highlight}}\n\t\t\thint : false,\t\t// true|false; to show a hint in input field,\n\t\t\tevents : {\t\t\t\t// {eventName: function}; events get triggered on the input element during the life-cycle of a typeahead\n\t\t\t\tselect : function(event, suggestion) {\n\t\t\t\t\t_selectItem(suggestion, $(event.target));\n\t\t\t\t},\n\t\t\t\tafterselect: function(event, suggestion) {\n\t\t\t\t\tif (suggestion.extra.action_t == 'E') $(event.target).focus();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n\n\t/* Public methods */\n\t\n\tautocompletion.prototype.init = function() {\n\t\tthis.option(this.options);\n\n\t\tif (_isEnabled(this.options)) this.initTypeahead();\n\t\telse this.destroy();\n\t}\n\n\tautocompletion.prototype.destroy = function () {\n\t\tthis.destroyTypeahead;\n\n\t\tthis.$element = null;\n\t\tthis.options = {};\n\t}\n\n\tautocompletion.prototype.option = function(key, val) {\n\t\tif (arguments.length === 0) {\n\t\t\treturn this.options;\n\t\t}\n\n\t\tvar that = this, options = $.isObject(key) ? key : {}, parts;\n\t\tif ($.isString(key)) {\n\t\t\tif (arguments.length === 1 || !$.isDefinied(val)) {\n\t\t\t\treturn $.dataVals($.extend({}, that.options), key);\n\t\t\t}\n\n\t\t\toptions[key] = val;\n\t\t}\n\n\t\tfor (var k in options) _setOption(k, options[k]);\n\n\t\tfunction _setOption(key, val) {\n\t\t\tif (key === 'datasets') that.options[key] = _mapOptions(that.options, val);\n\t\t\tif (key === 'debug') _debug = val;\n\t\t\tif (key === 'horizontal' && val) {\n\t\t\t\tthat.setTypeaheadClass('menu', 'tt-horizontal');\n\n\t\t\t\tthat.options.typeahead.events.render = function(event) {\n\t\t\t\t\t_renderSetWidth(that.getTypeaheadMenu(), 'tt-horizontal', 'tt-dataset');\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (key === 'scrollable' && val) that.setTypeaheadClass('menu', 'tt-scrollable');\n\t\t}\n\t}\n\n\tautocompletion.prototype.horizontal = function(val) {\n\t\treturn this.option('horizontal', val);\n\t}\n\n\tautocompletion.prototype.scrollable = function(val) {\n\t\treturn this.option('scrollable', val);\n\t}\n\n\t// Typeahead\n\tautocompletion.prototype.initTypeahead = function() {\n\t\tvar that = this, data = [];\n\n\t\t$.each(that.options.datasets, function(name, set) {\n\t\t\tdata.push(_getSetData(set, name));\n\t\t});\n\n\t\tthat.$element.typeahead({\n\t\t\tminLength : parseInt(that.options.length),\n\t\t\thint : that.options.typeahead.hint,\n\t\t\thighlight : that.options.typeahead.highlight,\n\t\t\tclassNames: that.options.typeahead.classNames\n\t\t}, data);\n\n\t\tif (that.options.typeahead.events) {\n\t\t\t$.each(that.options.typeahead.events, function(eventName, func) {\n\t\t\t\tthat.$element.on('typeahead:' + eventName, func);\n\t\t\t});\n\t\t}\n\n\t\tif (that.options.horizontal) {\n\t\t\tvar data = that.$element.data(), menu = that.getTypeaheadMenu();\n\n\t\t\t/* \n\t\t\t * 37 - code for left arrow key\n\t\t\t * 38 - code for up arrow key\n\t\t\t * 39 - code for right arrow key\n\t\t\t * 40 - code for down arrow key\n\t\t\t */\n\t\t\tdata.ttTypeahead._onDownKeyed = function() {\n\t\t\t\t_navCursorUD(40, menu, that.$element);\n\t\t\t};\n\t\t\tdata.ttTypeahead._onUpKeyed = function() {\n\t\t\t\t_navCursorUD(38, menu, that.$element);\n\t\t\t}\n\n\t\t\tvar cols = menu.children('.tt-dataset');\n\t\t\tif (cols.size() > 1) {\n\t\t\t\tdata.ttTypeahead._onLeftKeyed = function() {\n\t\t\t\t\t_navCursorLR(37, cols, that.$element);\n\t\t\t\t};\n\t\t\t\tdata.ttTypeahead._onRightKeyed = function() {\n\t\t\t\t\t_navCursorLR(39, cols, that.$element);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthat.$element.on('keydown', function(event) {\n\t\t\t\tvar code = event.keyCode || event.which;\n\t\t\t\tif (code == 38 || code == 40) return false;\n\t\t\t\tif ((code == 37 || code == 39) && $.exist(_navCols.cursor)) return false;\n\t\t\t});\n\t\t}\n\n\t\t// Log interactions\n\t\tif (!that.options.logging) return;\n\t\tthat.$element.on('typeahead:select', function(event, suggestion) {\n\t\t\tlogInteraction(that.options, suggestion, $(event.target), 'select');\n\t\t});\n\t}\n\n\tautocompletion.prototype.destroyTypeahead = function() {\n\t\tthis.$element.typeahead('destroy');\n\t}\n\n\tautocompletion.prototype.getTypeaheadMenu = function() {\n\t\treturn this.$element.siblings('.tt-menu');\n\t}\n\n\tautocompletion.prototype.setTypeaheadClass = function(name, className) {\n\t\tif (!$.exist(this.options.typeahead.classNames[name], true)) this.options.typeahead.classNames[name] = 'tt-' + name; // default class\n\t\tthis.options.typeahead.classNames[name] += ' ' + className;\n\t}\n\n\t/* Private variables */\n\tvar _debug = false,\n\t_mapKeys = ['collection', 'callback', 'dataType', 'alpha', 'facets', 'transform', 'format', 'group', 'groupOrder', 'itemGroup', 'itemLabel', 'params', 'profile', 'program', 'show', 'sort', 'queryKey', 'queryVal', 'template', 'templateMerge'],\n\t_navCols = {cursor : null, query : ''};\n\n\t/* Private methods */\n\t\n\t// Check if there is enough data to trigger auto-completion\n\tfunction _isEnabled(options) {\n\t\tvar bState = false;\n\n\t\tif (!$.isObject(options.datasets)) return bState;\n\n\t\t$.each(options.datasets, function(name, set) {\n\t\t\tif ($.exist(set.collection, true)) bState = true;\n\t\t});\n\n\t\treturn bState;\n\t}\n\n\t// Map global options per dataset\n\tfunction _mapOptions(options, datasets) {\n\t\tvar map = {};\n\t\t$.each(_mapKeys, function(i, key) { map[key] = options[key] });\n\t\t$.each(datasets, function(name, set) { datasets[name] = $.extend(true, {}, map, set) });\n\t\treturn datasets;\n\t}\n\n\t// Handle set\n\tfunction _getSetData(set, name) {\n\t\tvar engine = new Bloodhound({\n\t\t\tdatumTokenizer : Bloodhound.tokenizers.obj.whitespace('value'),\n\t\t\tqueryTokenizer : Bloodhound.tokenizers.whitespace,\n\t\t\tremote : getBloodhoundRemote()\n\t\t});\n\t\tengine.initialize();\n\n\t\treturn {\n\t\t\tname \t: name,\n\t\t\tlimit \t: 10000, // hack to display all returned data\n\t\t\tsource \t: source,\n\t\t\tdisplay : displayVal,\n\t\t\ttemplates : _renderSetTemplate(set)\n\t\t}\n\n\t\tfunction displayVal(suggestion) {\n\t\t\treturn $.isFunction(set.itemLabel) ? set.itemLabel.call(undefined, suggestion) : $.dataVals(suggestion, set.itemLabel);\n\t\t}\n\n\t\tfunction getBloodhoundRemote() {\n\t\t\tvar remote = {\n\t\t\t\turl : set.url ? set.url : _getSetUrl(set),\n\t\t\t\tfilter : function (response) {\n\t\t\t\t\tvar query = getQuery($(this).get(0).transport.lastReq);\n\t\t\t\t\treturn _handleSetData(set, $.map(response, function(suggestion, i) { return set.transform(set, suggestion, i, name, query) }));\n\t\t\t\t}\n\t\t\t};\n\t\t\tif (set.dataType === 'jsonp') {\n\t\t\t\tremote['prepare'] = function(query, settings) {\n\t\t\t\t\tsettings.dataType = 'jsonp';\n\t\t\t\t\tsettings.url = settings.url.replace(set.queryVal, query);\n\t\t\t\t\treturn settings;\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tremote['wildcard'] = set.queryVal;\n\t\t\t}\n\t\t\treturn remote;\n\t\t}\n\n\t\tfunction getQuery(str) {\n\t\t\tif (!$.exist(str, true)) return str;\n\t\t\tstr = decodeURIComponent(str);\n\t\t\treturn str.substring(str.lastIndexOf(set.queryKey + '=') + (set.queryKey.length + 1), str.lastIndexOf('GET'));\n\t\t}\n\n\t\tfunction displayVal(suggestion) {\n\t\t\treturn $.isFunction(set.itemLabel) ? set.itemLabel.call(undefined, suggestion) : $.dataVals(suggestion, set.itemLabel);\n\t\t}\n\n\t\tfunction source(query, sync, async) {\n\t\t\tif (query.length < 1 && set.defaultCall) {\n\t\t\t\tif ($.isString(set.defaultCall)) {\n\t\t\t\t\tquery = set.defaultCall;\n\t\t\t\t}\n\t\t\t\telse if ($.isArray(set.defaultCall)) {\n\t\t\t\t\tsync(_handleSetData(set, set.defaultCall));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if ($.exist(set.defaultCall.data)) {\n\t\t\t\t\tsync(_handleSetData(set, set.defaultCall.transform(set, set.defaultCall.data)));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if ($.exist(set.defaultCall.url, true)) {\n\t\t\t\t\t$.get(set.defaultCall.url, set.defaultCall.params, function(data) {\n\t\t\t\t\t\tasync(_handleSetData(set.defaultCall.transform(set, data)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tengine.search(query, sync, async);\n\t\t}\n\t}\n\n\t// Returned request URL based on provided parameters\n\tfunction _getSetUrl(set) {\n\t\tvar params = {collection: set.collection};\n\n\t\tif ($.exist(set.format, true)) params['fmt'] = set.format == 'simple' ? 'json' : 'json++';\n\t\tif ($.exist(set.alpha, true)) params['alpha'] = set.alpha;\n\t\tif ($.exist(set.profile, true)) params['profile'] = set.profile;\n\t\tif ($.exist(set.show, true)) params['show'] = set.show;\n\t\tif ($.exist(set.sort, true)) params['sort'] = set.sort;\n\t\tif ($.isObject(set.param)) params = $.extend(true, {}, params, set.params);\n\n\t\treturn set.program + '?' + $.param(params) + '&' + set.queryKey + '=' + set.queryVal;\n\t}\n\n\t// Group results into categories\n\tfunction _groupSetData(set, results) {\n\t\tvar grouped = {'':[]}, i, len;\n\n\t\tif ($.exist(set.groupOrder)) {\n\t\t\tfor (i = 0, len = set.groupOrder.length; i < len; i++) {\n\t\t\t\tgrouped[set.groupOrder[i]] = [{label: set.groupOrder[i]}];\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, len = results.length; i < len; i++) {\n\t\t\tif (!$.exist(grouped[results[i][set.itemGroup]])) grouped[results[i][set.itemGroup]] = [{label: results[i][set.itemGroup]}];\n\t\t\tgrouped[results[i][set.itemGroup]].push(results[i]);\n\t\t}\n\n\t\tresults = [];\n\t\t$.each(grouped, function(groupName, group) {\n\t\t\tif (group.length > 1) {\n\t\t\t\tif (!$.exist(groupName, true)) group.splice(0, 1);\n\t\t\t\t$.merge(results, group);\n\t\t\t}\n\t\t});\n\n\t\treturn results;\n\t}\n\n\t// Limit number of returned results\n\t// Trigger grouping them or apply custom callback\n\tfunction _handleSetData(set, results) {\n\t\tresults = results.slice(0, set.show);\n\t\tif (set.callback && $.isFunction(set.callback)) results = set.callback.call(undefined, set, results) || [];\n\t\tif (!set.group) return results;\n\t\treturn _groupSetData(set, results);\n\t}\n\n\tfunction _processSetData(set, suggestion, i, name, query) {\n\t\treturn $.autocompletion.processSetData(set, suggestion, i, name, query);\n\t}\n\n\t// Adjust columns width depends on columns number\n\t// If column has assigned CSS \"width\" property with \"!important\" declaration, this will be respected\n\tfunction _renderSetWidth(menu, classWrapper, className) {\n\t\tvar cols = 0, colsW = 0, styles, parts, menuW = menu.width();\n\t\tclassName \t = '.' + className;\n\t\tclassWrapper = '.' + classWrapper;\n\n\t\t$.each(menu.children(className), function() {\n\t\t\tparts = $(this).attr('class').split(' ');\n\t\t\tstyles = $.cssStyle(classWrapper + ' .' + parts[1]) || $.cssStyle(classWrapper + ' .' + parts.join('.'));\n\n\t\t\tif (styles.width && styles.width.indexOf('important') && styles.width.indexOf('auto') < 0 && styles.width.indexOf('initial') < 0 && styles.width.indexOf('inherit') < 0) {\n\t\t\t\tif (styles.width.indexOf('%') > 0) colsW += menuW * parseFloat(styles.width) / 100;\n\t\t\t\telse colsW += parseFloat(styles.width);\n\t\t\t}\n\t\t\telse if ($.hasContent($(this))) cols++;\n\t\t});\n\n\t\tif (cols) {\n\t\t\tmenuW -= colsW + 0.5;\n\t\t\tvar minW = parseFloat(menu.children(className).css('min-width')), colW = menuW / cols;\n\t\t\tif (minW <= colW) menu.children(className).css('width', colW + 'px');\n\t\t}\n\t}\n\n\t// Pre-compile templates using Handlebars\n\tfunction _renderSetTemplate(set) {\n\t\t_setSetTemplateHeader(set);\n\n\t\tif (!set.template || $.isEmptyObject(set.template)) return {};\n\n\t\t$.each(set.template, function(k, obj) {\n\t\t\tif ($.isObject(obj)) set.template[k] = obj.prop('outerHTML');\n\t\t});\n\n\t\tif (set.templateMerge) {\n\t\t\ttemplateMerge('notFound');\n\t\t\ttemplateMerge('pending');\n\t\t}\n\n\t\t$.each(set.template, function(k, obj) {\n\t\t\tif ($.isString(obj)) set.template[k] = Handlebars.compile(obj);\n\t\t});\n\n\t\treturn set.template;\n\n\t\tfunction templateMerge(temp) {\n\t\t\tif (set.template[temp] && $.isString(set.template[temp])) {\n\t\t\t\tif (set.template.header && $.isString(set.template.header)) set.template[temp] = set.template.header + set.template[temp];\n\t\t\t\tif (set.template.footer && $.isString(set.template.footer)) set.template[temp] += set.template.footer;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Set default template to display column header if column name is defined\n\tfunction _setSetTemplateHeader(set) {\n\t\tif (!set.template.header && $.exist(set.name, true)) set.template.header = '
' + set.name + '
';\n\t}\n\n\t// Handle selected item based on \"action_t\" parameter\n\tfunction _selectItem(item, target) {\n\t\tif ($.exist(item.extra)) {\n\t\t\tswitch(item.extra.action_t) {\n\t\t\t\tcase 'C':\n\t\t\t\t\teval(item.extra.action); break;\n\t\t\t\tcase 'U':\n\t\t\t\t\tdocument.location = item.extra.action; break;\n\t\t\t\tcase 'E':\n\t\t\t\t\ttarget.typeahead('val', item.extra.action); break;\n\t\t\t\tcase undefined:\n\t\t\t\tcase '':\n\t\t\t\tcase 'S':\n\t\t\t\tcase 'Q':\n\t\t\t\tdefault:\n\t\t\t\t\tformSend(item.value); break;\n\t\t\t}\n\t\t} else {\n\t\t\tformSend(item.value);\n\t\t}\n\n\t\tfunction formSend(val) { // Submit form on select\n\t\t\ttarget.val(val);\n\t\t\ttarget.closest('form').submit();\n\t\t}\n\t}\n\n\tfunction _getSelectableLabel(item) {\n\t\treturn $.exist(item.data()) ? item.data().ttSelectableDisplay : item.text();\n\t}\n\n\t/* Handle Typeahead navigation */\n\t\n\t// Navigate dropdown list left - right (switching between columns)\n\tfunction _navCursorLR(code, cols, target) {\n\t\tif (!$.exist(_navCols.cursor)) return;\n\n\t\tvar currCol = _navCols.cursor.parent(),\n\t\t\tcurrColIdx = cols.index(currCol),\n\t\t\tdelta = code == 37 ? -1 : 1,\n\t\t\tnextColItems = getNextColItems(currColIdx),\n\t\t\tcursorIdx = $(currCol).children('.tt-selectable').index(_navCols.cursor),\n\t\t\tnextCursor = $.exist(nextColItems[cursorIdx]) ? nextColItems[cursorIdx] : nextColItems[nextColItems.length - 1];\n\n\t\t$(_navCols.cursor).removeClass('tt-cursor');\n\t\t_navCols.cursor = $(nextCursor).addClass('tt-cursor');\n\t\ttarget.data().ttTypeahead.input.setInputValue(_getSelectableLabel(_navCols.cursor));\n\n\t\tfunction getNextColItems(currColIdx) {\n\t\t\tvar nextColIdx = code == 37\n\t\t\t\t? $.exist(cols[currColIdx - 1]) ? currColIdx - 1 : cols.length - 1\n\t\t\t\t: $.exist(cols[currColIdx + 1]) ? currColIdx + 1 : 0,\n\t\t\t\tnextColItems = $(cols[nextColIdx]).children('.tt-selectable');\n\n\t\t\treturn $.exist(nextColItems) ? nextColItems : getNextColItems(nextColIdx);\n\t\t}\n\t}\n\n\t// Navigate dropdown list up - down\n\tfunction _navCursorUD(code, menu, target) {\n\t\tif (!$.exist(menu.find('.tt-cursor'))) {\n\t\t\t_navCols.cursor = code == 38 ? menu.find('.tt-selectable').last() : menu.find('.tt-selectable').first();\n\t\t\t_navCols.cursor.addClass('tt-cursor');\n\t\t\t_navCols.query = target.val();\n\t\t\ttarget.data().ttTypeahead.input.setInputValue(_getSelectableLabel(_navCols.cursor));\n\t\t\treturn;\n\t\t}\n\n\t\tvar currCol = _navCols.cursor.parent(),\n\t\t\tcurrColItems = $(currCol).children('.tt-selectable');\n\n\t\tif(!$.exist(currColItems)) return;\n\n\t\tvar cursorIdx = currColItems.index(_navCols.cursor), delta = code == 38 ? -1 : 1;\n\n\t\t$(_navCols.cursor).removeClass('tt-cursor');\n\n\t\tif (!$.exist(currColItems[cursorIdx + delta])) {\n\t\t\t_navCols.cursor = null;\n\t\t\ttarget.data().ttTypeahead.input.resetInputValue();\n\t\t\ttarget.data().ttTypeahead._updateHint();\n\t\t}\n\t\telse {\n\t\t\t_navCols.cursor = $(currColItems[cursorIdx + delta]).addClass('tt-cursor');\n\t\t\ttarget.data().ttTypeahead.input.setInputValue(_getSelectableLabel(_navCols.cursor));\n\t\t}\n\t}\n\n\t// Debug\n\tfunction logDebug(options, input, output, msg) {\n\t\tif (!_debug || !window.console) return;\n\n\t\tconsole.log(msg);\n\t\tconsole.log('Options: ', options);\n\t\tconsole.log('Input: ', input);\n\t\tconsole.log('Output: ', output);\n\t\tconsole.log('--------');\n\t}\n\n\tfunction logInteraction(options, input, target, event) {\n\t\tif (!options.logging || !$.exist(options.interactionLog, true)) return;\n\t\tif (!input.dataset || !options.datasets[input.dataset]) return;\n\n\t\t$.ajax({\n\t\t\tdataType: 'jsonp',\n\t\t\ttype: 'GET',\n\t\t\turl: getInteractionUrl(options.datasets[input.dataset], input),\n\t\t}).fail(function(qXHR, textStatus, errorThrown) {\n\t\t\tlogDebug(options, input, qXHR, 'Interaction log error: ' + textStatus + ' ' + errorThrown);\n\t\t});\n\n\t\tfunction getInteractionUrl(set, suggestion) {\n\t\t\tvar params = {\n\t\t\t\tcollection: set.collection,\n\t\t\t\ttype: event,\n\t\t\t\tpartial_query: suggestion.query,\n\t\t\t\tclient_time: new Date().getTime()\n\t\t\t};\n\n\t\t\tif ($.exist(set.profile, true)) params['profile'] = set.profile;\n\t\t\tif ($.exist(suggestion.extra)) params = $.extend(true, {}, params, suggestion.extra);\n\n\t\t\treturn options.interactionLog + '?' + $.param(params);\n\t\t}\n\t}\n\n\t// Generate plugin\n\tfunction Plugin() {\n\t\tvar args = [].slice.call(arguments), option = args.shift();\n\n\t\treturn this.each(function () {\n\t\t\tvar $this = $(this),\n\t\t\t\tdata = $this.data('flb.autocompletion'),\n\t\t\t\toptions = $.extend(true, {}, autocompletion.defaults, data || {}, $.isObject(option) && option);\n\n\t\t\tif (!data && /destroy|hide/.test(option)) return;\n\t\t\tif (!data) $this.data('flb.autocompletion', (data = new autocompletion(this, options)));\n\t\t\tif ($.isString(option) && $.isFunction(data[option])) data[option].apply($this, args);\n\t\t});\n\t}\n\n\t$.fn.autocompletion = Plugin;\n\t$.fn.autocompletion.Constructor = autocompletion;\n\n\t// List of predefined mapping functions\n\t$.autocompletion = {\n\t\t// Map /s/suggest.json output\n\t\tprocessSetData: function(set, suggestion, i, name, query) {\n\t\t\tvar value = suggestion.key, label = suggestion.key;\n\t\t\tif (suggestion.action_t == 'Q') value = suggestion.action;\n\t\t\tif (suggestion.action_t == 'S') value = suggestion.disp;\n\t\t\tif (suggestion.disp_t == 'C') label = eval(suggestion.disp);\n\t\t\telse if (suggestion.disp) label = suggestion.disp;\n\n\t\t\treturn {\n\t\t\t\tlabel : label,\n\t\t\t\tvalue : value,\n\t\t\t\textra : suggestion,\n\t\t\t\tcategory : suggestion.cat ? suggestion.cat : '',\n\t\t\t\trank : i + 1,\n\t\t\t\tdataset\t : name,\n\t\t\t\tquery : query\n\t\t\t};\n\t\t},\n\n\t\t// Map /s/search.json output\n\t\tprocessSetDataFacets: function(set, suggestion, i, name, query) {\n\t\t\tif (i !== 'response' || !$.exist(suggestion.facets)) return;\n\n\t\t\tvar suggestions = [], rank = 1;\n\t\t\tfor (var i = 0, leni = suggestion.facets.length; i < leni; i++) {\n\t\t\t\tvar facet = suggestion.facets[i];\n\n\t\t\t\tif (!$.exist(facet.allValues)) continue;\n\t\t\t\tif ($.exist(set.facets.blacklist) && set.facets.blacklist.indexOf(facet.name) > -1) continue;\n\t\t\t\tif ($.exist(set.facets.whitelist) && set.facets.whitelist.indexOf(facet.name) < 0) continue;\n\n\t\t\t\tfor (var j = 0, lenj = facet.allValues.length; j < lenj; j++) {\n\t\t\t\t\tif ($.exist(set.facets.show) && j > parseInt(set.facets.show) - 1) break;\n\t\t\t\t\tif (!facet.allValues[j].count) continue;\n\n\t\t\t\t\tsuggestions.push({\n\t\t\t\t\t\tlabel : facet.allValues[j].label,\n\t\t\t\t\t\tvalue : facet.allValues[j].data,\n\t\t\t\t\t\textra : {\n\t\t\t\t\t\t\taction : getUrl(facet.allValues[j]),\n\t\t\t\t\t\t\taction_t: 'U'\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcategory: facet.name,\n\t\t\t\t\t\trank : rank++,\n\t\t\t\t\t\tdataset\t: name,\n\t\t\t\t\t\tquery : query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn suggestions;\n\n\t\t\tfunction getUrl(facet) {\n\t\t\t\treturn ($.exist(set.facets.url, true) ? set.facets.url : window.location.origin + window.location.pathname) + facet.toggleUrl;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Helpers\n\t$.exist = function(obj, bString) { if (!$.isDefinied(bString)) bString = false; var obj = bString ? obj : $(obj); return $.isDefinied(obj) && obj != null && ($.isString(obj) ? obj + '' : obj).length > 0; }\n\t$.hasContent = function(obj) { return obj.html().trim().length ? true : false; }\n\t$.isDefinied = function(obj) { return typeof(obj) !== 'undefined'; }\n\t$.isFunction = function(obj) { return typeof(obj) === 'function'; }\n\t$.isString = function(obj) { return typeof(obj) === 'string'; }\n\t$.isObject = function(obj) { return typeof(obj) === 'object'; }\n\t$.dataKeys = function(obj) { return iterateKeys(obj, ''); function iterateKeys(obj, prefix) { return $.map(Object.keys(obj), function(key) { if(obj[key] && $.isObject(obj[key])) return iterateKeys(obj[key], key); else return (prefix ? prefix + '-' + key : key);}); }}\n\t$.dataVals = function(obj, key) { var parts = key.split('.'), key = parts.shift(); if (parts.length) { for (var i = 0, len = parts.length; i < len; i++) { obj = obj[key] || {}; key = parts[i]; } } return obj[key]; }\n\t$.cssStyle\t = function(className) {\n\t\tvar styleSheets = window.document.styleSheets, styles = {};\n\t\tfor(var i = 0, leni = styleSheets.length; i < leni; i++){\n\t\t\tif (styleSheets[i].href && styleSheets[i].href.indexOf(window.location.host) < 0) continue;\n\n\t\t\tvar classes = styleSheets[i].rules || styleSheets[i].cssRules;\n\t\t\tif (!classes) continue;\n\n\t\t\tfor (var j = 0, lenj = classes.length; j < lenj; j++) {\n\t\t\t\tif (classes[j].selectorText != className) continue;\n\n\t\t\t\tvar properties = classes[j].style.cssText.split(';');\n\t\t\t\tfor (var k = 0, lenk = properties.length; k < lenk; k++) {\n\t\t\t\t\tvar part = properties[k].split(':');\n\t\t\t\t\tif (part.length == 2) styles[part[0].trim()] = part[1].trim();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn styles;\n\t}\n\n}(jQuery));\n\nString.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1); }\n"]}