(function(n){"use strict";typeof module=="object"&&typeof module.exports=="object"?n(require("jquery"),window,document):n(jQuery,window,document)})(function(n,t,i,r){"use strict";if(!t.history.pushState){n.fn.smoothState=function(){return this};n.fn.smoothState.options={};return}if(!n.fn.smoothState){var e=n("html, body"),f=t.console,o={debug:!1,anchors:"a",hrefRegex:"",forms:"form",allowFormCaching:!1,repeatDelay:500,blacklist:".no-smoothState",prefetch:!1,prefetchOn:"mouseover touchstart",prefetchBlacklist:".no-prefetch",locationHeader:"X-SmoothState-Location",cacheLength:0,loadingClass:"is-loading",scroll:!0,alterRequest:function(n){return n},alterChangeState:function(n){return n},onBefore:function(){},onStart:{duration:0,render:function(){}},onProgress:{duration:0,render:function(){}},onReady:{duration:0,render:function(n,t){n.html(t)}},onAfter:function(){}},u={isExternal:function(n){var i=n.match(/^([^:\/?#]+:)?(?:\/\/([^\/?#]*))?([^?#]+)?(\?[^#]*)?(#.*)?/);return typeof i[1]=="string"&&i[1].length>0&&i[1].toLowerCase()!==t.location.protocol?!0:typeof i[2]=="string"&&i[2].length>0&&i[2].replace(new RegExp(":("+{"http:":80,"https:":443}[t.location.protocol]+")?$"),"")!==t.location.host?!0:!1},stripHash:function(n){return n.replace(/#.*/,"")},isHash:function(n,i){i=i||t.location.href;var r=n.indexOf("#")>-1?!0:!1,f=u.stripHash(n)===u.stripHash(i)?!0:!1;return r&&f},translate:function(t){var i={dataType:"html",type:"GET"};return typeof t=="string"?n.extend({},i,{url:t}):n.extend({},i,t)},shouldLoadAnchor:function(n,t,i){var f=n.prop("href");return!u.isExternal(f)&&!u.isHash(f)&&!n.is(t)&&!n.prop("target")&&(typeof i===r||i===""||n.prop("href").search(i)!==-1)},clearIfOverCapacity:function(n,t){return Object.keys||(Object.keys=function(n){var t=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&t.push(i);return t}),Object.keys(n).length>t&&(n={}),n},storePageIn:function(t,i,r,u,f,e){var o=n("<html><\/html>").append(n(r));return typeof f=="undefined"&&(f={}),typeof e=="undefined"&&(e=i),t[i]={status:"loaded",title:o.find("title").first().text(),html:o.find("#"+u),doc:r,state:f,destUrl:e},t},triggerAllAnimationEndEvent:function(t,i){i=" "+i||"";var r=0,f="allanimationend",e=function(i){n(i.delegateTarget).is(t)&&(i.stopPropagation(),r++)},o=function(i){n(i.delegateTarget).is(t)&&(i.stopPropagation(),r--,r===0&&t.trigger(f))};t.on("animationstart webkitAnimationStart oanimationstart MSAnimationStart",e);t.on("animationend webkitAnimationEnd oanimationend MSAnimationEnd",o);t.on("allanimationend"+i,function(){r=0;u.redraw(t)})},redraw:function(n){n.height()}},s=function(i){if(i.state!==null){var f=t.location.href,o=n("#"+i.state.id),r=o.data("smoothState"),s=typeof r!="undefined"&&typeof r.href!="undefined"&&r.href!==f&&!u.isHash(f,r.href),e=typeof r!="undefined"&&typeof r.href!="undefined"&&i.state!==r.cache[r.href].state;(s||e)&&(e&&r.clear(r.href),r.load(f,!1))}},h=function(o,s){var c=n(o),a=c.prop("id"),v=null,y=!1,h={},l={},p=t.location.href,w=function(n){n=n||!1;n&&h.hasOwnProperty(n)?delete h[n]:h={};c.data("smoothState").cache=h},b=function(t,i){var r,f;(i=i||n.noop,r=u.translate(t),h=u.clearIfOverCapacity(h,s.cacheLength),h.hasOwnProperty(r.url)&&typeof r.data=="undefined")||(h[r.url]={status:"fetching"},f=n.ajax(r),f.done(function(n){u.storePageIn(h,r.url,n,a);c.data("smoothState").cache=h}),f.fail(function(){h[r.url].status="error"}),s.locationHeader&&f.always(function(n,t,i){var f=n.statusCode?n:i,u=f.getResponseHeader(s.locationHeader);u&&(h[r.url].destUrl=u)}),i&&f.always(i))},rt=function(){var t,i;v&&(t=n(v,c),t.length&&(i=t.offset().top,e.scrollTop(i)),v=null)},d=function(r){var o="#"+a,u=h[r]?n(h[r].html.html()):null;if(u.length){i.title=h[r].title;c.data("smoothState").href=r;s.loadingClass&&e.removeClass(s.loadingClass);s.onReady.render(c,u);c.one("ss.onReadyEnd",function(){y=!1;s.onAfter(c,u);s.scroll&&rt();it(c)});t.setTimeout(function(){c.trigger("ss.onReadyEnd")},s.onReady.duration)}else!u&&s.debug&&f?f.warn("No element with an id of "+o+" in response from "+r+" in "+h):t.location=r},k=function(n,i,r){var o=u.translate(n);typeof i=="undefined"&&(i=!0);typeof r=="undefined"&&(r=!0);var v=!1,y=!1,p={loaded:function(){var u=v?"ss.onProgressEnd":"ss.onStartEnd",n;if(y&&v)y&&d(o.url);else c.one(u,function(){d(o.url);r||w(o.url)});i&&(n=h[o.url].destUrl,n.indexOf("?")!==-1&&(n=n.substring(0,n.indexOf("?"))),l=s.alterChangeState({id:a},h[o.url].title,n),h[o.url].state=l,t.history.pushState(l,h[o.url].title,n));y&&!r&&w(o.url)},fetching:function(){if(!v){v=!0;c.one("ss.onStartEnd",function(){s.loadingClass&&e.addClass(s.loadingClass);s.onProgress.render(c);t.setTimeout(function(){c.trigger("ss.onProgressEnd");y=!0},s.onProgress.duration)})}t.setTimeout(function(){h.hasOwnProperty(o.url)&&p[h[o.url].status]()},10)},error:function(){s.debug&&f?f.log("There was an error loading: "+o.url):t.location=o.url}};h.hasOwnProperty(o.url)||b(o);s.onStart.render(c);t.setTimeout(function(){s.scroll&&e.scrollTop(0);c.trigger("ss.onStartEnd")},s.onStart.duration);p[h[o.url].status]()},ut=function(t){var i,r=n(t.currentTarget);u.shouldLoadAnchor(r,s.blacklist,s.hrefRegex)&&!y&&(t.stopPropagation(),i=u.translate(r.prop("href")),i=s.alterRequest(i),b(i))},ft=function(t){var i=n(t.currentTarget),r;if(!t.metaKey&&!t.ctrlKey&&u.shouldLoadAnchor(i,s.blacklist,s.hrefRegex)&&(t.stopPropagation(),t.preventDefault(),!nt())){tt();r=u.translate(i.prop("href"));y=!0;v=i.prop("hash");r=s.alterRequest(r);s.onBefore(i,c);k(r)}},et=function(t){var u=n(t.currentTarget),i;if(!u.is(s.blacklist)&&(t.preventDefault(),t.stopPropagation(),!nt())){tt();i={url:u.prop("action"),data:u.serialize(),type:u.prop("method")};y=!0;i=s.alterRequest(i);i.type.toLowerCase()==="get"&&(i.url=i.url+"?"+i.data);s.onBefore(u,c);k(i,r,s.allowFormCaching)}},g=0,nt=function(){var n=s.repeatDelay===null,t=parseInt(Date.now())>g;return!(n||t)},tt=function(){g=parseInt(Date.now())+parseInt(s.repeatDelay)},it=function(n){if(s.anchors&&s.prefetch)n.find(s.anchors).not(s.prefetchBlacklist).on(s.prefetchOn,null,ut)},ot=function(n){if(s.anchors){n.on("click",s.anchors,ft);it(n)}if(s.forms)n.on("submit",s.forms,et)},st=function(){var n=c.prop("class");c.removeClass(n);u.redraw(c);c.addClass(n)};return s=n.extend({},n.fn.smoothState.options,s),t.history.state===null?(l=s.alterChangeState({id:a},i.title,p),t.history.replaceState(l,i.title,p)):l={},u.storePageIn(h,p,i.documentElement.outerHTML,a,l),u.triggerAllAnimationEndEvent(c,"ss.onStartEnd ss.onProgressEnd ss.onEndEnd"),ot(c),{href:p,cache:h,clear:w,load:k,fetch:b,restartCSSAnimations:st}},c=function(t){return this.each(function(){var i=this.tagName.toLowerCase();this.id&&i!=="body"&&i!=="html"&&!n.data(this,"smoothState")?n.data(this,"smoothState",new h(this,t)):!this.id&&f?f.warn("Every smoothState container needs an id but the following one does not have one:",this):(i==="body"||i==="html")&&f&&f.warn("The smoothstate container cannot be the "+this.tagName+" tag")})};t.onpopstate=s;n.smoothStateUtility=u;n.fn.smoothState=c;n.fn.smoothState.options=o}})