!function(){"use strict";function a(a){if(!a)return console.error("Can't get freefocus dimensions for nothing"),{left:0,top:0,width:0,height:0};var b=l(a,!0,!1);return{left:b.x1,top:b.y1,width:b.x2-b.x1,height:b.y2-b.y1}}function b(a){return a?void l(a,!0,!0):void console.error("Can't populate freefocus cache for nothing")}function c(a){return a?void delete a.freefocusDimensions:void console.error("Can't invalidate freefocus cache for nothing")}function d(a){if(!a)return void console.error("Can't clear freefocus hint for nothing");for(var b in v)a.removeAttribute("data-nav-"+b)}function e(a,b,c){if(!a)return void console.error("Can't set freefocus hints for nothing");for(var d in b)c===!1&&a.getAttribute("data-nav-"+d)||a.setAttribute("data-nav-"+d,b[d])}function f(a,b,c){var d;if(!a)return console.error("Can't move freefocus from nothing"),d;if(!v[b])return console.error('Unknown freefocus direction "'+b+'"'),d;if(!c)return console.error("Can't move freefocus without candidates function"),d;p(a,b,x.cache);var e=g(a,b,c);if(e)if(e.length<=1)d=e[0];else{var f=function(){return e};d=h(a,b,f)}else d=h(a,b,c);return d&&q(d,b,x.cache),d}function g(a,b,c){var d=s(w,function(c){var d=c(a,b);return d&&d.trim()});return d&&(d=d.trim()),d?"none"===d?[]:s(d.split(/\s*;\s*/),function(a){if(a){var b=c(a);if(b.length)return b}}):void 0}function h(a,b,c){for(var d,e=m(l(a,x.cache,x.cache),b),f=c(),g=x.maxDistance,h=0,j=f.length;j>h;h++){var k=f[h];if(k!==a){var n=m(l(k,x.cache,x.cache),b);if(!(n.fwd1o&&(d=k,g=o)}}}return d}function i(a,b){var c,d=y.updatedInDirection,e={fwd:b.fwd1,ort:r(d.ort,b.ort1,b.ort2)},f=Math.abs(e.fwd-d.fwd),g=Math.abs(e.ort-d.ort);c=e.ort===d.ort?0:Math.sqrt(f*f+g*g);var h=j(a,b);return c+f+2*g-Math.sqrt(h)}function j(a,b){var c={ort1:a.ort1,ort2:a.ort2};b.ort1>c.ort1&&(c.ort1=b.ort1),b.ort2d&&(d=0),d}function k(a){var b=a.getBoundingClientRect();return{x1:b.left,y1:b.top,x2:b.right,y2:b.bottom}}function l(a,b,c){var d;return b&&(d=a.freefocusDimensions),d||(d=k(a)),c&&(a.freefocusDimensions=d),d}function m(a,b){var c=v[b].toUnified({x:a.x1,y:a.y1}),d=v[b].toUnified({x:a.x2,y:a.y2});return{fwd1:Math.min(c.fwd,d.fwd),ort1:Math.min(c.ort,d.ort),fwd2:Math.max(c.fwd,d.fwd),ort2:Math.max(c.ort,d.ort)}}function n(a,b){return{x:a.x+b.x1,y:a.y+b.y1}}function o(a,b){return{x:a.x-b.x1,y:a.y-b.y1}}function p(a,b,c){var d=l(a,c,c);a.freefocusId&&a.freefocusId===y.elementId||(y.elementId=t(a),y.box={x:(d.x2-d.x1)/2,y:(d.y2-d.y1)/2}),y.updatedInDirection=v[b].toUnified(n(y.box,d)),y.updatedInDirection.fwd=m(d,b).fwd2}function q(a,b,c){var d=l(a,c,c);y.elementId=t(a);var e=m(d,b),f={fwd:e.fwd1,ort:r(y.updatedInDirection.ort,e.ort1,e.ort2)};y.box=o(v[b].fromUnified(f),d)}function r(a,b,c){return Math.min(Math.max(a,b),c)}function s(a,b){for(var c=0,d=a.length;d>c;c++){var e=b(a[c]);if(e)return e}}function t(a){var b=a.freefocusId;return b||(b=a.freefocusId=++z),b}var u=window.freefocus={move:f,getDimensions:a,populateDimensionsCache:b,invalidateDimensionsCache:c,setHint:e,clearHint:d,configuration:void 0},v={left:{toUnified:function(a){return{fwd:-a.x,ort:-a.y}},fromUnified:function(a){return{x:-a.fwd,y:-a.ort}}},right:{toUnified:function(a){return{fwd:a.x,ort:a.y}},fromUnified:function(a){return{x:a.fwd,y:a.ort}}},up:{toUnified:function(a){return{fwd:-a.y,ort:a.x}},fromUnified:function(a){return{x:a.ort,y:-a.fwd}}},down:{toUnified:function(a){return{fwd:a.y,ort:-a.x}},fromUnified:function(a){return{x:-a.ort,y:a.fwd}}}},w=[function(a,b){return a.getAttribute("data-nav-"+b)}],x=u.configuration={maxDistance:1/0,cache:!1,directions:v,hintSources:w},y={freefocusId:-1},z=0}(),function(a){"use strict";function b(b){var c;if(!b.focusablesSelector)return console.error("Options should contain either focusablesSelector or targets"),[];if(b.hintSelector){var d=b.ignoreContextForHints?void 0:b.focusablesContext;c=a(b.hintSelector,d).filter(b.focusablesSelector)}else c=a(b.focusablesSelector,b.focusablesContext);return b.focusablesFilter&&(c=c.filter(b.focusablesFilter)),c.toArray()}function c(a){return a&&a.replace(/^([^#].*) ''$/,"#$1")}function d(a){var b={};return a.split(";").forEach(function(a){var c=a.split(":");c[1]&&(b[c[0].trim()]=c[1].trim())}),b}function e(){j.on.apply(j,arguments),i.push(arguments)}function f(){i.forEach(function(a){j.off.apply(j,a)}),i=[]}function g(b,c){if(document.createEvent&&b.dispatchEvent&&"focus"!==c){var d=document.createEvent("Event");d.initEvent(c,!0,!0),b.dispatchEvent(d)}else a(b).trigger(a.Event(c))}var h=window.freefocus;a.freefocus=function(b,c){if("remove"===b)return void f();if("cache"!==b){b=a.extend({},a.freefocus.setupOptions,b);var d=function(d){var e=a.extend({},c,{move:d});a(b.focusedSelector).freefocus(e)};"number"==typeof b.throttle&&(d=_.throttle(d,b.throttle)),e("keydown",function(b){var c=a.freefocus.keys[b.which];c&&(b.preventDefault(),d(c))}),b.hoverFocus&&(c.focusablesSelector||(console.error("focusablesSelector is required for hoverFocus"),c.focusablesSelector="zzz"),e("mouseenter",c.focusablesSelector,function(){var d=(c||{}).trigger||a.freefocus.moveOptions.trigger,e=a(this);return b.focusablesFilter&&(e=e.filter(b.focusablesFilter)),e.trigger(d)}))}else{var g=a.extend({},a.freefocus.cacheOptions,c),i=g.targets;a.isFunction(i)&&(i=i(g));for(var j=0,k=i.length;k>j;j++)h.populateDimensionsCache(i[j])}},a.fn.freefocus=function(c,d){if("dimensions"===c)return this.length?(this.length>1&&console.error("Can't use freefocus on multiple element jQuery object"),h.getDimensions(this[0])):(console.error("Can't get freefocus dimensions for empty jQuery object"),{left:0,top:0,width:0,height:0});if("moved"===c)return void this.each(function(){h.invalidateDimensionsCache(this)});if("nav"===c)return void("clear"===d?this.each(function(){h.clearHint(this)}):this.each(function(){h.setHint(this,d)}));if(!this.length)return c.debug&&console.warn("freefocus called on empty jQuery object"),this;this.length>1&&console.error("Can't use freefocus on multiple element jQuery object");var e=c.move;if(c=a.extend({},a.freefocus.moveOptions,c),h.configuration.cache=c.cache,h.configuration.maxDistance=c.maxDistance,!h.configuration.directions[e])return console.error('Unknown move direction "'+e+'"'),this;a.isFunction(c.targets)||a.isArray(c.targets)||c.targets.jquery||console.warn("Argument targets should be a function, array, or jQuery object");var f=function(d){if(d){var e=a.isFunction(c.targets)?c.targets:b,f=a.extend({},c,{hintSelector:d});return e(f)}var g=c.targets;return a.isFunction(g)&&(g=g(c)),g},i=h.move(this[0],e,f);return i?(c.preTrigger&&g(i,c.preTrigger),c.trigger&&g(i,c.trigger),a(i)):this},a.freefocus.moveOptions={targets:b,focusablesSelector:["a[href]","area[href]","input:enabled","select:enabled","textarea:enabled","button:enabled","iframe","object","embed","*[tabindex]","*[contenteditable]"].join(", "),focusablesFilter:":visible",focusablesContext:void 0,ignoreContextForHints:!0,trigger:"focus",preTrigger:!1,debug:!1,maxDistance:1/0},a.freefocus.setupOptions={focusedSelector:":focus",hoverFocus:!1,throttle:!1},a.freefocus.cacheOptions={targets:b},a.freefocus.keys={37:"left",38:"up",39:"right",40:"down"},h.configuration.hintSources.push(function(a,b){var d="nav"+b.charAt(0).toUpperCase()+b.slice(1),e=a.style[d];return c(e)},function(b,e){var f=a.trim(b.getAttribute("style")),g=f&&d(f)["nav-"+e];return c(g)});var i=[],j=a(document)}(jQuery);