var rate_my_post=function(exports,t){"use strict";class e{constructor(e,i){this.widgetContainer=e,this.socialEnabled=t.social,this.ratingRequired=t.positiveThreshold,this.rating=i,this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.socialWidget=document.querySelector(this.widgetContainer+".js-rmp-social-widget"),this.events()}events(){2!=this.socialEnabled||this.rating<=this.ratingRequired||(this.socialWidget?.classList?.add("rmp-social-widget--visible"),this.ratingWidget?.classList?.add("rmp-rating-widget--hidden"))}}class i{constructor(t,e){this.widgetContainer=t,this.successMsg=e.successMsg,this.errorMsg=e.errorMsg,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-msg"),this.input=document.querySelector(this.widgetContainer+".js-rmp-feedback-input"),this.button=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader=document.querySelector(this.widgetContainer+".js-rmp-feedback-loader"),this.events()}events(){if(this.loader.classList.remove("rmp-feedback-widget__loader--visible"),this.errorMsg.length)return this.msgContainer.classList.add("rmp-feedback-widget__msg--alert"),void(this.msgContainer.innerHTML=this.errorMsg.join("<br />"));this.msgContainer.classList.remove("rmp-feedback-widget__msg--alert"),this.msgContainer.textContent=this.successMsg,this.input.remove(),this.button.remove()}}class s{constructor(e,i,s,n,r){this.widgetContainer=e,this.postID=i,this.feedback=s,this.settings=t,this.duration=!1,this.ratingID=r,this.token=n,this.recaptcha=t.grecaptcha,this.recaptchaKey=t.siteKey,this.turnstile=t.turnstile,this.turnstileKey=t.turnstileSiteKey,this.turnstileTheme=t.turnstileTheme,this.turnstileSize=t.turnstileSize,this.data={action:"process_feedback",feedback:this.feedback,postID:this.postID,duration:this.duration,rating_id:this.ratingID,rating_token:this.token,nonce:this.settings.nonce},this.events()}events(){if(2==this.turnstile){const t=document.querySelector(this.widgetContainer).querySelector(".cf-turnstile-feedback");return void(t&&turnstile.ready((()=>{turnstile.render(t,{sitekey:this.turnstileKey,theme:this.turnstileTheme,size:this.turnstileSize,callback:t=>{this.data.turnstileToken=t,this.saveFeedback()}})})))}2==this.recaptcha?grecaptcha.ready((()=>{grecaptcha.execute(this.recaptchaKey,{action:"RMPfeedback"}).then((t=>{this.data.token=t,this.saveFeedback()}))})):this.saveFeedback()}async saveFeedback(){const t=new FormData;Object.keys(this.data).forEach((e=>t.append(e,this.data[e])));const e=await fetch(this.settings.admin_ajax,{method:"POST",body:t});if(!e.ok)return;const s=await e.json();new i(this.widgetContainer,s)}}class n{constructor(e,i,s,n,r){this.widgetContainer=e,this.postID=i,this.feedbackEnabled=t.feedback,this.maxRating=t.positiveThreshold,this.emptyFeedbackMsg=t.emptyFeedback,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-msg"),this.rating=s,this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.feedbackWidget=document.querySelector(this.widgetContainer+".js-rmp-feedback-widget"),this.inputContainer=document.querySelector(this.widgetContainer+".js-rmp-feedback-input"),this.submitButton=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader=document.querySelector(this.widgetContainer+".js-rmp-feedback-loader"),this.input=!1,this.token=n,this.ratingID=r,this.events()}events(){2!=this.feedbackEnabled||this.rating>this.maxRating||(this.feedbackWidget.classList.add("rmp-feedback-widget--visible"),this.ratingWidget.classList.add("rmp-rating-widget--hidden"),this.submitButton.addEventListener("click",(t=>this.submitButtonClicked())))}submitButtonClicked(){if(this.input=this.inputContainer.value,this.input.trim().length<1)return this.msgContainer.classList.add("rmp-feedback-widget__msg--alert"),void(this.msgContainer.textContent=this.emptyFeedbackMsg);this.submitButton.replaceWith(this.submitButton.cloneNode(!0)),this.submitButton=document.querySelector(this.widgetContainer+".js-rmp-feedback-button"),this.loader.classList.add("rmp-feedback-widget__loader--visible"),new s(this.widgetContainer,this.postID,this.input,this.token,this.ratingID)}}class r{constructor(){this.starsToBeReplaced=document.querySelectorAll(".js-rmp-replace-half-star"),this.starsToBeRemoved=document.querySelectorAll(".js-rmp-remove-half-star"),this.testElement=document.createElement("x-test"),this.supportTest=typeof this.testElement.style.webkitBackgroundClip,this.events()}events(){let t=!0;"undefined"===this.supportTest&&(t=!1),t||(this.starsToBeReplaced.forEach((t=>{t.classList.remove("rmp-icon--half-highlight"),t.classList.add("rmp-icon--full-highlight")})),this.starsToBeRemoved.forEach((t=>{t.classList.remove("rmp-icon--half-highlight")})))}}class a{constructor(e,i,s){this.postID=i,this.widgetContainer=e,this.avgRating=s,this.resultIcons=document.querySelectorAll(".js-rmp-results-widget--"+i+" .js-rmp-results-icon"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.hideRatings=t.notShowRating,this.events()}events(){let t=Math.floor(this.avgRating),e=!1,i=!1,s="",n=Math.round(this.avgRating%1*10);n>2&&n<8&&(e=!0),n>=8&&(i=!0),n>2&&n<5&&(s="js-rmp-remove-half-star"),n>=5&&n<8&&(s="js-rmp-replace-half-star"),this.resultIcons.forEach(((n,r)=>{r+1<=t&&n.classList.add("rmp-icon--full-highlight"),e&&r+1==t+1&&(n.classList.add("rmp-icon--half-highlight"),n.classList.add(s)),i&&r+1==t+1&&n.classList.add("rmp-icon--full-highlight")})),2!=this.hideRatings&&(this.ratingIcons.forEach(((n,r)=>{r+1<=t&&n.classList.add("rmp-icon--full-highlight"),e&&r+1==t+1&&(n.classList.add("rmp-icon--half-highlight"),n.classList.add(s)),i&&r+1==t+1&&n.classList.add("rmp-icon--full-highlight")})),new r)}}function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h,c={exports:{}};
var d,g=(h||(h=1,d=function(){function t(){for(var t=0,e={};t<arguments.length;t++){var i=arguments[t];for(var s in i)e[s]=i[s]}return e}function e(t){return t.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function i(s){function n(){}function r(e,i,r){if("undefined"!=typeof document){"number"==typeof(r=t({path:"/"},n.defaults,r)).expires&&(r.expires=new Date(1*new Date+864e5*r.expires)),r.expires=r.expires?r.expires.toUTCString():"";try{var a=JSON.stringify(i);/^[\{\[]/.test(a)&&(i=a)}catch(t){}i=s.write?s.write(i,e):encodeURIComponent(String(i)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var o="";for(var h in r)r[h]&&(o+="; "+h,!0!==r[h]&&(o+="="+r[h].split(";")[0]));return document.cookie=e+"="+i+o}}function a(t,i){if("undefined"!=typeof document){for(var n={},r=document.cookie?document.cookie.split("; "):[],a=0;a<r.length;a++){var o=r[a].split("="),h=o.slice(1).join("=");i||'"'!==h.charAt(0)||(h=h.slice(1,-1));try{var c=e(o[0]);if(h=(s.read||s)(h,c)||e(h),i)try{h=JSON.parse(h)}catch(t){}if(n[c]=h,t===c)break}catch(t){}}return t?n[t]:n}}return n.set=r,n.get=function(t){return a(t,!1)},n.getJSON=function(t){return a(t,!0)},n.remove=function(e,i){r(e,"",t(i,{expires:-1}))},n.defaults={},n.withConverter=i,n}((function(){}))},c.exports=d()),c.exports),l=o(g);class u{constructor(t){this.postID=t,this.existingCookie=l.get("rmp-rate"),this.events()}events(){if(void 0===this.existingCookie)return void l.set("rmp-rate",this.postID,{expires:20});l.remove("rmp-rate");let t=this.existingCookie.split(",");t.length>=20&&t.shift(),t.push(this.postID);let e=t.toString();l.set("rmp-rate",e,{expires:20})}}class m{constructor(t){this.commonAnalyticsTracker=typeof window.ga,this.MiAnalyticsTracker=typeof window.__gaTracker,this.rating=t,this.events()}events(){return"undefined"!==this.commonAnalyticsTracker?(ga("send","event","Rate my Post","Post Rated "+this.rating+"/5"),void console.log("ga analytics tracker")):"undefined"!==this.MiAnalyticsTracker?(__gaTracker("send","event","Rate my Post","Post Rated "+this.rating+"/5"),void console.log("__gaTracker analytics tracker")):void console.log("Analytics tracker not found")}}class p{constructor(e,i,s,n){this.postID=e,this.widgetContainer=i,this.voteCount=s.voteCount,this.avgRating=s.avgRating,this.errorMsg=s.errorMsg,this.token=s.token,this.id=s.id,this.avgRatingContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-avg-rating, .js-rmp-results-widget--"+e+" .js-rmp-avg-rating"),this.voteCountContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-vote-count, .js-rmp-results-widget--"+e+" .js-rmp-vote-count"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.resultIcons=document.querySelectorAll(".js-rmp-results-widget--"+e+" .js-rmp-results-icon"),this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.tnxMsg=t.afterVote,this.rating=n,this.hideRatings=t.notShowRating,this.events()}events(){if(this.errorMsg.length)return this.msgContainer.innerHTML=this.errorMsg.join("<br />"),this.msgContainer.classList.add("rmp-rating-widget__msg--alert"),void this.ratingIcons.forEach((t=>{t.classList.remove("rmp-icon--processing-rating","rmp-icon--hovered")}));this.avgRatingContainer&&this.avgRatingContainer.forEach((t=>{t.textContent=this.avgRating})),this.voteCountContainer&&this.voteCountContainer.forEach((t=>{t.textContent=this.voteCount})),this.toneDownIcons(),this.highlightIcons(),this.noVotesContainer?.classList?.add("rmp-rating-widget__not-rated--hidden"),this.resultsTextContainer?.classList?.remove("rmp-rating-widget__results--hidden"),this.msgContainer.textContent=this.tnxMsg,new e(this.widgetContainer,this.rating),new n(this.widgetContainer,this.postID,this.rating,this.token,this.id),new u(this.postID),new m(this.rating)}toneDownIcons(){this.ratingIcons.forEach((t=>{t.classList.remove("rmp-icon--full-highlight","rmp-icon--half-highlight","rmp-icon--processing-rating","rmp-icon--hovered","js-rmp-remove-half-star","js-rmp-replace-half-star")})),this.resultIcons.forEach((t=>{t.classList.remove("rmp-icon--full-highlight","rmp-icon--half-highlight","rmp-icon--processing-rating","js-rmp-remove-half-star","js-rmp-replace-half-star")}))}highlightIcons(){new a(this.widgetContainer,this.postID,this.avgRating)}}class v{constructor(e,i,s,n){this.postID=e,this.widgetContainer=i,this.rating=s,this.duration=Math.floor(Date.now()/1e3)-n,this.settings=t,this.recaptcha=t.grecaptcha,this.recaptchaKey=t.siteKey,this.turnstile=t.turnstile,this.turnstileKey=t.turnstileSiteKey,this.turnstileTheme=t.turnstileTheme,this.turnstileSize=t.turnstileSize,this.data={action:"process_rating",star_rating:this.rating,postID:this.postID,duration:this.duration,nonce:this.settings.nonce},this.events()}events(){if(2==this.turnstile){const t=document.querySelector(this.widgetContainer).querySelector(".cf-turnstile-rating");return void(t&&turnstile.ready((()=>{turnstile.render(t,{sitekey:this.turnstileKey,theme:this.turnstileTheme,size:this.turnstileSize,callback:t=>{this.data.turnstileToken=t,this.saveRating()}})})))}2==this.recaptcha?grecaptcha.ready((()=>{grecaptcha.execute(this.recaptchaKey,{action:"RMPrating"}).then((t=>{this.data.token=t,this.saveRating()}))})):this.saveRating()}async saveRating(){const t=new FormData;Object.keys(this.data).forEach((e=>t.append(e,this.data[e])));const e=await fetch(this.settings.admin_ajax,{method:"POST",body:t});if(!e.ok)return;const i=await e.json();new p(this.postID,this.widgetContainer,i,this.rating)}}class C{constructor(t){this.widgetContainer=t,this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.ratingTextContainer=document.querySelector(this.widgetContainer+".js-rmp-hover-text"),this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.events()}events(){this.ratingItems.forEach((t=>{t.replaceWith(t.cloneNode(!0))})),this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.submitBtn.replaceWith(this.submitBtn.cloneNode(!0)),this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.ratingItems.forEach((t=>{t.style.cursor="default"})),this.submitBtn.classList.remove("rmp-rating-widget__submit-btn--visible"),this.ratingTextContainer&&(this.ratingTextContainer.textContent="")}}class w{constructor(e,i){this.postID=i,this.widgetContainer=e,this.existingCookie=l.get("rmp-rate"),this.cookiesDisabled=t.cookieDisable,this.tnxMsg=t.afterVote,this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.ratingWidget=document.querySelector(this.widgetContainer+".js-rmp-rating-widget"),this.events()}events(){if(2==this.cookiesDisabled)return;if(void 0===this.existingCookie)return;this.existingCookie.split(",").includes(this.postID)&&(new C(this.widgetContainer),this.msgContainer&&(this.msgContainer.textContent=this.tnxMsg),this.ratingWidget?.classList?.add("rmp-rating-widget--has-rated"))}}class f{constructor(){this.is_not_votable=t.is_not_votable,this.ratingWidget=document.querySelectorAll(".js-rmp-rating-widget"),this.events()}events(){"true"===this.is_not_votable&&(new C(""),this.ratingWidget.forEach((t=>{t.classList.add("rmp-rating-widget--no-privilege")})))}}class y{constructor(e){this.postID=e,this.widgetContainer=".js-rmp-widgets-container--"+e+" ",this.resultsWidget=".js-rmp-results-widget--"+e,this.ratingItems=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-item"),this.ratingItemsList=document.querySelector(this.widgetContainer+".js-rmp-rating-icons-list"),this.ratingIcons=document.querySelectorAll(this.widgetContainer+".js-rmp-rating-icon"),this.ratingTextContainer=document.querySelector(this.widgetContainer+".js-rmp-hover-text"),this.ratingText=!1,this.hoveredItemOrder=0,this.rating=0,this.supportsHover=window.matchMedia("(hover: hover)"),this.startTime=Math.floor(Date.now()/1e3),this.preventAccidental=t.preventAccidental,this.hoverTexts=t.hoverTexts,this.submitBtn=document.querySelector(this.widgetContainer+".js-submit-rating-btn"),this.saveRating=!1,this.events()}events(){this.doubleWidgetCheck(),this.ratingItems.forEach((t=>{t.style.cursor="pointer",t.addEventListener("mouseover",(t=>this.hoverIcons(t))),t.addEventListener("mouseout",(t=>this.stopHoverIcons())),t.addEventListener("click",(t=>this.ratingIconClicked(t)))})),this.ratingItemsList.addEventListener("mouseleave",(t=>this.removeHoverTexts())),this.ratingItemsList.addEventListener("keydown",(t=>this.handleKeydown(t))),new w(this.widgetContainer,this.postID),new f}doubleWidgetCheck(){let t=document.querySelectorAll(this.widgetContainer),e=document.querySelectorAll(this.resultsWidget);(t.length>1||e.length>1)&&(t.forEach(((t,e)=>{e>0&&t.remove()})),e.forEach(((t,e)=>{e>0&&t.remove()})))}hoverIcons(t){this.hoveredItemOrder=parseInt(t.currentTarget.dataset.value,10),this.ratingText=t.currentTarget.dataset.descriptiveRating,this.ratingIcons.forEach(((t,e)=>{e<this.hoveredItemOrder?t.classList.add("rmp-icon--hovered"):t.classList.remove("rmp-icon--hovered"),this.supportsHover&&2==this.hoverTexts&&this.ratingTextContainer&&(this.ratingTextContainer.textContent=this.ratingText)}))}stopHoverIcons(){this.ratingIcons.forEach((t=>{t.classList.remove("rmp-icon--hovered")}))}removeHoverTexts(){this.ratingTextContainer&&(this.ratingTextContainer.textContent="")}handleKeydown(t){var e=Array.from(this.ratingItems),i=e.indexOf(document.activeElement);if(-1!==i){var s=i;switch(t.key){case"ArrowRight":case"ArrowDown":t.preventDefault(),s=(i+1)%e.length;break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),s=(i-1+e.length)%e.length;break;case"Enter":case" ":return t.preventDefault(),void e[i].click();case"Home":t.preventDefault(),s=0;break;case"End":t.preventDefault(),s=e.length-1;break;default:return}e[i].setAttribute("tabindex","-1"),e[s].setAttribute("tabindex","0"),e[s].focus(),2==this.hoverTexts&&this.ratingTextContainer&&(this.ratingTextContainer.textContent=e[s].dataset.descriptiveRating);var n=parseInt(e[s].dataset.value,10);this.ratingIcons.forEach((function(t,e){e<n?t.classList.add("rmp-icon--hovered"):t.classList.remove("rmp-icon--hovered")}))}}ratingIconClicked(t){this.rating=parseInt(t.currentTarget.dataset.value,10),this.ratingIcons.forEach(((t,e)=>{t.classList.remove("rmp-icon--processing-rating"),e<this.rating&&t.classList.add("rmp-icon--processing-rating")})),this.ratingItems.forEach((t=>{var e=parseInt(t.dataset.value,10);t.setAttribute("aria-checked",e===this.rating?"true":"false")})),2!=this.preventAccidental?(new C(this.widgetContainer),this.saveRating=new v(this.postID,this.widgetContainer,this.rating,this.startTime)):this.submitButtonHandler()}submitButtonHandler(){this.submitBtn.classList.add("rmp-rating-widget__submit-btn--visible"),this.submitBtn.addEventListener("click",(t=>{this.saveRating||(this.saveRating=new v(this.postID,this.widgetContainer,this.rating,this.startTime)),new C(this.widgetContainer)}))}}class b{constructor(e){this.postID=e,this.widgetContainer=".js-rmp-widgets-container--"+e+" ",this.settings=t,this.avgRatingContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-avg-rating, .js-rmp-results-widget--"+e+" .js-rmp-avg-rating"),this.voteCountContainer=document.querySelectorAll(this.widgetContainer+".js-rmp-vote-count, .js-rmp-results-widget--"+e+" .js-rmp-vote-count"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.noVotesContainer=document.querySelector(this.widgetContainer+".js-rmp-not-rated"),this.resultsTextContainer=document.querySelector(this.widgetContainer+".js-rmp-results"),this.msgContainer=document.querySelector(this.widgetContainer+".js-rmp-msg"),this.data={action:"load_results",postID:this.postID,nonce:this.settings.nonce},this.events()}async events(){const t=new FormData;Object.keys(this.data).forEach((e=>t.append(e,this.data[e])));const e=await fetch(this.settings.admin_ajax,{method:"POST",body:t});if(!e.ok)return;const i=await e.json();let s=i.voteCount,n=i.avgRating,r=i.errorMsg;this.loadResults(s,n,r)}loadResults(t,e,i){i.length?this.msgContainer&&(this.msgContainer.textContent=i,this.msgContainer.classList.add("rmp-rating-widget__msg--alert")):(this.avgRatingContainer&&this.avgRatingContainer.forEach((t=>{t.textContent=e})),this.voteCountContainer&&this.voteCountContainer.forEach((e=>{e.textContent=t})),new a(this.widgetContainer,this.postID,e),0===e?(this.noVotesContainer?.classList?.remove("rmp-rating-widget__not-rated--hidden"),this.resultsTextContainer?.classList?.add("rmp-rating-widget__results--hidden")):(this.noVotesContainer?.classList?.add("rmp-rating-widget__not-rated--hidden"),this.resultsTextContainer?.classList?.remove("rmp-rating-widget__results--hidden")),new r)}}class k{constructor(){this.ratingItems=document.querySelectorAll(".js-rmp-rating-item"),this.ratingItemsLists=document.querySelector(".js-rmp-rating-icons-list"),this.events()}events(){this.ratingItems.forEach((t=>{t.replaceWith(t.cloneNode(!0))})),this.ratingItems=document.querySelectorAll(".js-rmp-rating-item"),this.ratingItems.forEach((t=>{t.style.cursor="auto"})),this.ratingItemsLists.replaceWith(this.ratingItemsLists.cloneNode(!0)),this.ratingItemsLists=document.querySelector(".js-rmp-rating-icons-list")}}function I(){new r;let e=document.getElementsByClassName("js-rmp-rating-widget"),i=document.getElementsByClassName("js-rmp-results-widget"),s=document.getElementsByClassName("js-rmp-widgets-container");if(e.length<1&&i.length<1)return;let n=[];Array.from(s).forEach((t=>{let e=t.dataset.postId;n.push(e)}));let a=n.filter(((t,e)=>n.indexOf(t)===e));if(2==t.ajaxLoad)return new b(a[0]),void new y(a[0]);a.forEach((t=>{new y(t)}))}return"loading"!==document.readyState?I():document.addEventListener("DOMContentLoaded",I),exports.init_single_rate_my_post=function(t,e){e&&new b(t),new y(t)},exports.re_init=function(){console.log("re-init running"),new k,I()},exports}({},rmp_frontend);
if(typeof Object.create!=='function'){
Object.create=function(obj){
function F(){
}
F.prototype=obj;
return new F();
};}
(function($, window, document, undefined){
"use strict";
var Anchorific={
init: function(options, elem){
var self=this;
self.elem=elem;
self.$elem=$(elem);
self.opt=$.extend({}, this.opt, options);
self.headers=self.$elem.find(self.opt.headers);
self.previous=0;
if(self.headers.length!==0){
self.first=parseInt(self.headers.prop('nodeName').substring(1), null);
}
self.build();
},
opt: {
navigation: '.anchorific',
headers: 'h1, h2, h3, h4, h5, h6',
speed: 200,
anchorClass: 'anchor',
anchorText: '#',
top: '.top',
spy: true,
position: 'append',
spyOffset: ! 0 
},
build: function(){
var self=this, obj, navigations=function(){
};
if(self.opt.navigation){
$(self.opt.navigation).append('<ul />');
self.previous=$(self.opt.navigation).find('ul').last();
navigations=function(obj){
return self.navigations(obj);
};}
for(var i=0; i < self.headers.length; i ++){
obj=self.headers.eq(i);
navigations(obj);
self.anchor(obj);
}
if(self.opt.spy){
self.spy();
}
if(self.opt.top){
self.back();
}},
navigations: function(obj){
var self=this, link, list, which, name=self.name(obj);
if(obj.attr('id')!==undefined){
name=obj.attr('id');
}
link=$('<a />').attr('href', '#' + name).text(obj.text());
list=$('<li />').append(link);
which=parseInt(obj.prop('nodeName').substring(1), null);
list.attr('data-tag', which);
self.subheadings(which, list);
self.first=which;
},
subheadings: function(which, a){
var self=this, ul=$(self.opt.navigation).find('ul'),
li=$(self.opt.navigation).find('li');
if(which===self.first){
self.previous.append(a);
}else if(which > self.first){
li.last().append('<ul />');
$(self.opt.navigation).find('ul').last().append(a);
self.previous=a.parent();
}else{
$('li[data-tag=' + which + ']').last().parent().append(a);
self.previous=a.parent();
}},
name: function(obj){
var name=obj.text().replace(/[^\w\s]/gi, '')
.replace(/\s+/g, '-')
.toLowerCase();
return name;
},
anchor: function(obj){
var self=this, name=self.name(obj), anchor, text=self.opt.anchorText,
klass=self.opt.anchorClass, id;
if(obj.attr('id')===undefined){
obj.attr('id', name);
}
id=obj.attr('id');
anchor=$('<a />').attr('href', '#' + id).html(text).addClass(klass);
if(self.opt.position==='append'){
obj.append(anchor);
}else{
obj.prepend(anchor);
}},
back: function(){
var self=this, body=$('body, html'), top=$(self.opt.top);
top.on('click', function(e){
e.preventDefault();
body.animate({
'scrollTop': 0
}, self.opt.speed);
});
},
top: function(that){
var self=this, top=self.opt.top, back;
if(top!==false){
back=($(that).scrollTop() > 200) ?
$(top).fadeIn() :
$(top).fadeOut();
}},
spy: function(){
var self=this, previous, current, list, top, prev;
$(window).scroll(function(e){
self.top(this);
current=self.headers.map(function(e){
if(( $(this).offset().top - $(window).scrollTop()) < self.opt.spyOffset){
return this;
}});
current=$(current).eq(current.length - 1);
if(current&&current.length){
list=$('li:has(a[href="#' + current.attr('id') + '"])');
if(prev!==undefined){
prev.removeClass('active');
}
list.addClass('active');
prev=list;
}});
}};
$.fn.anchorific=function(options){
return this.each(function(){
if(! $.data(this, 'anchorific') ){
var anchor=Object.create(Anchorific);
anchor.init(options, this);
$.data(this, 'anchorific', anchor);
}});
};})(jQuery, window, document);
(function (){
'use strict';
var nav=document.querySelector('.ap-nav');
var toggle=nav&&nav.querySelector('.ap-nav__toggle');
if(toggle){
toggle.addEventListener('click', function (){
var open=nav.classList.toggle('is-open');
toggle.setAttribute('aria-expanded', open ? 'true':'false');
});
document.addEventListener('keydown', function (e){
if(e.key==='Escape'&&nav.classList.contains('is-open')){
nav.classList.remove('is-open');
toggle.setAttribute('aria-expanded', 'false');
toggle.focus();
}});
}
document.querySelectorAll('.ap-slider').forEach(function (slider){
var slides=slider.querySelectorAll('.ap-slide');
var dots=slider.querySelectorAll('.ap-slider__dot');
if(slides.length < 2){ return; }
var current=0;
var timer=null;
var speed=parseInt(slider.getAttribute('data-speed'), 10)||0;
var reduce=window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function show(i){
current=(i + slides.length) % slides.length;
slides.forEach(function (s, k){
var on=k===current;
s.classList.toggle('is-active', on);
if(on){ s.removeAttribute('aria-hidden'); }else{ s.setAttribute('aria-hidden', 'true'); }
s.querySelectorAll('a').forEach(function (a){
if(on){ a.removeAttribute('tabindex'); }else{ a.setAttribute('tabindex', '-1'); }});
});
dots.forEach(function (d, k){ d.setAttribute('aria-current', k===current ? 'true':'false'); });
var cur=slider.querySelector('.ap-slider__cur');
var fill=slider.querySelector('.ap-slider__fill');
if(cur){ cur.textContent=(current + 1 < 10 ? '0':'') + (current + 1); }
if(fill){ fill.style.width=((current + 1) / slides.length * 100) + '%'; }}
function start(){
if(!speed||reduce){ return; }
stop();
timer=window.setInterval(function (){ show(current + 1); }, speed * 1000);
}
function stop(){ if(timer){ window.clearInterval(timer); timer=null; }}
slider.querySelectorAll('.ap-slider__arrow').forEach(function (b){
b.addEventListener('click', function (){ show(current + parseInt(b.getAttribute('data-dir'), 10)); start(); });
});
dots.forEach(function (d){
d.addEventListener('click', function (){ show(parseInt(d.getAttribute('data-go'), 10)); start(); });
});
slider.addEventListener('mouseenter', stop);
slider.addEventListener('mouseleave', start);
slider.addEventListener('focusin', stop);
slider.addEventListener('focusout', start);
var x0=null;
var stage=slider.querySelector('.ap-slider__stage');
stage.addEventListener('touchstart', function (e){ x0=e.touches[0].clientX; stop(); }, { passive: true });
stage.addEventListener('touchend', function (e){
if(x0===null){ return; }
var dx=e.changedTouches[0].clientX - x0;
if(Math.abs(dx) > 40){ show(current + (dx < 0 ? 1:-1)); }
x0=null;
start();
});
start();
});
})();
(function (){
'use strict';
var root=document.querySelector('.ap-wa');
if(!root){ return; }
var btn=root.querySelector('.ap-wa__btn');
var pop=root.querySelector('.ap-wa__pop');
var close=root.querySelector('.ap-wa__close');
var KEY='apWaClosed';
var timer=null;
function store(get, val){
try {
if(get){ return window.sessionStorage.getItem(KEY); }
window.sessionStorage.setItem(KEY, val);
} catch (e){  }
return null;
}
function open(auto){
pop.hidden=false;
window.requestAnimationFrame(function (){ root.classList.add('is-open'); });
root.classList.add('is-opening');
btn.setAttribute('aria-expanded', 'true');
root.classList.remove('has-badge', 'has-hint');
pop.classList.add('is-typing');
window.clearTimeout(timer);
timer=window.setTimeout(function (){
pop.classList.remove('is-typing');
if(!auto){ root.querySelector('.ap-wa__cta').focus({ preventScroll: true });}}, 900);
}
function hide(remember){
root.classList.remove('has-badge', 'has-hint');
root.classList.remove('is-open');
btn.setAttribute('aria-expanded', 'false');
window.setTimeout(function (){ if(!root.classList.contains('is-open')){ pop.hidden=true; }}, 250);
if(remember){ store(false, '1'); }}
btn.addEventListener('click', function (){
if(root.classList.contains('is-open')){ hide(true); }else{ open(false); }});
root.querySelector('.ap-wa__hint').addEventListener('click', function (){ open(false); });
close.addEventListener('click', function (){ hide(true); btn.focus(); });
document.addEventListener('keydown', function (e){
if(e.key==='Escape'&&root.classList.contains('is-open')){ hide(true); btn.focus(); }});
root.querySelector('.ap-wa__cta').addEventListener('click', function (){ store(false, '1'); });
var delay=parseInt(root.getAttribute('data-delay'), 10)||0;
if(delay > 0&&!store(true)){
window.setTimeout(function (){
if(!root.classList.contains('is-open')){ root.classList.add('has-badge', 'has-hint'); }}, delay * 1000);
}
root.classList.add('is-ready');
}());