!function(){"use strict";let t;const e=function(t){return"json"===this.responseType||!0===this.json?t({message:this.statusText},!1):"text"===this.responseType?t(this.statusText):void console.error(this)},i=function(t){if(0===this.status||this.status>=200&&this.status<300||304===this.status){if("json"===this.responseType)return t(this.response.data,this.response.success);if("text"===this.responseType)return t(this.responseText);if(!0===this.json){const e=JSON.parse(this.response);return t(e.data,e.success)}console.info(this)}else e.bind(this,t)},s=t=>{let e=new FormData;const i=Object.prototype.toString.call(t);return"[object FormData]"===i&&(e=t),"[object HTMLFormElement]"===i&&(e=new FormData(t)),"[object Object]"===i&&Object.keys(t).forEach((i=>e.append(i,t[i]))),e.append("action",GLSR.action),e.append("_ajax_request",!0),e},n=s=>{t=new XMLHttpRequest,t.addEventListener("load",i.bind(t,s)),t.addEventListener("error",e.bind(t,s))},r=e=>{(e=e||{})["X-Requested-With"]="XMLHttpRequest";for(let i in e)e.hasOwnProperty(i)&&t.setRequestHeader(i,e[i])};var a={data:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};e._action=t;for(let t of Object.keys(e))i[`${GLSR.nameprefix}[${t}]`]=e[t];return i},get:(e,i,s)=>{n(i),t.open("GET",e,!0),t.responseType="text",r(s),t.send()},post:(e,i,a)=>{n(i),t.open("POST",GLSR.ajaxurl,!0),t.responseType="json",t.json=!0,r(a),t.send(s(e))}};const o={},l=function(t,e){const i=o[t]||[],s=[];e&&[].forEach.call(i,(t=>{e!==t.fn&&e!==t.fn.once&&s.push(t)})),s.length?o[t]=s:delete o[t]},c=function(t,e,i){(o[t]||(o[t]=[])).push({fn:e,context:i})};var h={events:o,off:l,on:c,once:function(t,e,i){const s=function(){l(t,s),e.apply(i,arguments)};s.once=e,c(t,s,i)},trigger:function(t){const e=[].slice.call(arguments,1),i=(o[t]||[]).slice();[].forEach.call(i,(t=>t.fn.apply(t.context,e)))}};const d="function",u="isNode",p=(t,e)=>typeof t===e,f=(t,e)=>{null!==e&&(Array.isArray(e)?e.map((e=>f(t,e))):(v[u](e)||(e=document.createTextNode(e)),t.appendChild(e)))};function v(t,e){let i,s,n=arguments,r=1;if(!v.isElement(t)){let e=~["svg","line","path","rect","mask","radialGradient","stop"].indexOf(t)?"2000/svg":"1999/xhtml";t=document.createElementNS(`http://www.w3.org/${e}`,t)}if("string"==typeof e&&(e={class:e}),p(e,"object")&&!v[u](e)&&!Array.isArray(e))for(i in r++,e)s=e[i],i=v.attrMap[i]||i,p(i,d)?i(t,s):p(s,d)?t[i]=s:t.setAttribute(i,s);for(;rt instanceof Element,v[u]=t=>t instanceof Node;const g="glsr-read-more",m=".glsr-hidden-text",w=".glsr-tag-value";class y{constructor(t){this.events={click:this._onClick.bind(this)},(t||document).querySelectorAll(m).forEach((t=>this.init(t)))}init(t){const e=this._insertLink(t);e&&("expand"===t.dataset.trigger&&(e.dataset.text=t.dataset.showLess,e.removeEventListener("click",this.events.click),e.addEventListener("click",this.events.click)),"modal"===t.dataset.trigger&&(e.dataset.glsrTrigger="glsr-modal-review"))}_insertLink(t){let e=t.parentElement.querySelector("."+g);e&&e.parentElement.removeChild(e);const i=v("a",{href:"#"},t.dataset.showMore),s=v("span",{class:g},i);return t.appendChild(s).querySelector("a")}_onClick(t){t.preventDefault();const e=t.currentTarget,i=e.parentElement,s=e.closest(w),n=s.querySelector(m),r=e.dataset.text,a=e.innerText;e.dataset.text=a,e.innerText=r,e.removeEventListener("click",this.events.click),"false"===s.dataset.expanded?(s.querySelector("p:last-of-type").appendChild(i),s.dataset.expanded=!0):(n.appendChild(i),s.dataset.expanded=!1),e.addEventListener("click",this.events.click),e.focus()}}var _=t=>({el:t,loading:()=>{"false"===t.getAttribute("aria-busy")&&(t.setAttribute("aria-busy",!0),t.setAttribute("disabled",""),t.dataset.text=t.innerText,t.innerHTML=''+(t.dataset.loading||t.dataset.text))},loaded:()=>{"true"===t.getAttribute("aria-busy")&&(t.innerHTML=t.dataset.text,t.setAttribute("aria-busy",!1),t.removeAttribute("data-text"),t.removeAttribute("disabled"))}});class b{constructor(t){this.Form=t,this.captcha={friendlycaptcha:"friendlyChallenge",hcaptcha:"hcaptcha",recaptcha_v2_invisible:"grecaptcha",recaptcha_v3:"grecaptcha",turnstile:"turnstile"}[GLSR.captcha.type],this.captchaEl=!1,this.containerEl=this.Form.form.querySelector(".glsr-captcha-holder"),this.loaded=!1,this.token=null,this.widget=-1,this.fixCompatibility()}execute(){if(this.captchaEl&&this.isWidgetLoaded())try{this["execute_"+GLSR.captcha.type]()}catch(t){console.error(t),this.Form.submitForm()}else this.Form.submitForm()}execute_friendlycaptcha(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):this.token?this.Form.submitForm():setTimeout((()=>this.execute_friendlycaptcha()),100)}execute_hcaptcha(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):this.token?this._submitFormWithToken(this.token):window[this.captcha].execute(this.widget,{action:"submit_review",async:!0}).then((t=>{let{response:e}=t;this._submitFormWithToken(e)})).catch((t=>{console.error(t)}))}execute_recaptcha_v2_invisible(){this.execute_recaptcha_v3()}execute_recaptcha_v3(){1==+this.captchaEl.dataset.error?this._submitFormWithToken("sitekey_invalid"):window[this.captcha].execute(this.widget,{action:"submit_review"})}execute_turnstile(){let t=window[this.captcha].getResponse(this.widget);1==+this.captchaEl.dataset.error||this.token||void 0===t?this.Form.submitForm():setTimeout((()=>this.execute_turnstile()),100)}fixCompatibility(){"hcaptcha"===GLSR.captcha.type&&void 0!==window.hCaptchaOnLoad&&document.body.click()}isLoaded(t){for(let e=0;e{if(void 0===t||this.isLoaded(t))e();else{const s=document.createElement("script");s.onload=e,s.onerror=i,s.src=t,s.type="text/javascript",GLSR.captcha.urls.length>1&&(-1!==t.indexOf("module")?s.type="module":s.setAttribute("nomodule","")),s.setAttribute("defer",""),document.head.append(s)}}))}render(){if(this.Form.form.onsubmit=null,this.containerEl&&!this.isWidgetLoaded())if(void 0===window[this.captcha])this.loaded?setTimeout((()=>this.render()),50):this.load(GLSR.captcha.urls[0]).then((()=>{this.load(GLSR.captcha.urls[1])})).then((()=>this.loaded=!0)).then((()=>setTimeout((()=>this.render()),100))).catch((t=>console.error(t)));else{this.reset(),this._buildContainer();try{this["render_"+GLSR.captcha.type]()}catch(t){this.captchaEl.dataset.error=1,console.error(t)}}}render_friendlycaptcha(){this.widget=new window[this.captcha].WidgetInstance(this.captchaEl,{doneCallback:t=>this.token=t,errorCallback:t=>{console.error(t),this.captchaEl.dataset.error=1}})}render_hcaptcha(){var t;void 0!==(null===(t=window[this.captcha])||void 0===t?void 0:t.render)?this.widget=window[this.captcha].render(this.captchaEl,{callback:t=>this.token=t,"chalexpired-callback":()=>this.reset(),"close-callback":()=>this.Form.button.loaded(),"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset()}):setTimeout((()=>this.render_hcaptcha()),100)}render_recaptcha_v2_invisible(){this.render_recaptcha_v3()}render_recaptcha_v3(){var t;void 0!==(null===(t=window[this.captcha])||void 0===t?void 0:t.render)?this.widget=window[this.captcha].render(this.captchaEl,{callback:t=>this._submitFormWithToken(t),"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset(),isolated:!0}):setTimeout((()=>this.render_recaptcha_v3()),100)}render_turnstile(){this.widget=window[this.captcha].render(this.captchaEl,{action:"submit_review",callback:t=>this.token=t,"error-callback":()=>this.captchaEl.dataset.error=1,"expired-callback":()=>this.reset(),sitekey:GLSR.captcha.sitekey,theme:GLSR.captcha.theme})}reset(){this.token=null,this.captchaEl&&(this.captchaEl.dataset.error=0),this.isWidgetLoaded()&&("friendlycaptcha"===GLSR.captcha.type?this.widget.reset():window[this.captcha].reset(this.widget))}_buildContainer(){"friendlycaptcha"===GLSR.captcha.type&&this.isWidgetLoaded()&&this.widget.destroy(),Array.from(this.containerEl.getElementsByClassName(GLSR.captcha.class)).forEach((t=>t.remove())),this.captchaEl=v("div",{class:GLSR.captcha.class,"data-badge":GLSR.captcha.badge,"data-lang":GLSR.captcha.language,"data-isolated":!0,"data-sitekey":GLSR.captcha.sitekey,"data-size":GLSR.captcha.size,"data-theme":GLSR.captcha.theme}),this.containerEl.appendChild(this.captchaEl)}_submitFormWithToken(t){["frc-captcha-solution","g-recaptcha-response","h-captcha-response"].forEach((e=>{this.Form.form[e]&&t&&(this.Form.form[e].value=t)})),this.Form.submitForm()}}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function L(t,e){for(var i=0;i0&&e.push({index:t.index,text:t.text,value:i})})),e.sort((function(t,e){return t.value-e.value}))}(e),this.widgetEl=null,this.el.widget&&this.el.widget.destroy(),s=this.values.length,n=1,r=this.props.maxStars,/^\d+$/.test(s)&&n<=s&&s<=r?this.build():this.destroy()}return S(t,[{key:"build",value:function(){this.destroy(),this.buildWidget(),this.selectValue(this.indexSelected=this.selected(),!1),this.handleEvents("add"),this.el.widget=this}},{key:"buildWidget",value:function(){var t,e,i=this;this.props.prebuilt?(t=this.el.parentNode,e=t.querySelector("."+this.props.classNames.base+"--stars")):((t=T(this.el,!1,{class:this.props.classNames.base})).appendChild(this.el),e=T(this.el,!0,{class:this.props.classNames.base+"--stars"}),this.values.forEach((function(t,s){var n=R({"data-index":s,"data-value":t.value});"function"==typeof i.props.stars&&i.props.stars.call(i,n,t,s),[].forEach.call(n.children,(function(t){return t.style.pointerEvents="none"})),e.innerHTML+=n.outerHTML}))),t.dataset.starRating="",t.classList.add(this.props.classNames.base+"--"+this.direction),this.props.tooltip&&e.setAttribute("role","tooltip"),this.widgetEl=e}},{key:"changeIndexTo",value:function(t,e){var i=this;if(this.indexActive!==t||e){if([].forEach.call(this.widgetEl.children,(function(e,s){k(e,s<=t,i.props.classNames.active),k(e,s===i.indexSelected,i.props.classNames.selected)})),this.widgetEl.setAttribute("data-rating",t+1),"function"==typeof this.props.stars||this.props.prebuilt||(this.widgetEl.classList.remove("s"+10*(this.indexActive+1)),this.widgetEl.classList.add("s"+10*(t+1))),this.props.tooltip){var s,n=t<0?this.props.tooltip:null===(s=this.values[t])||void 0===s?void 0:s.text;this.widgetEl.setAttribute("aria-label",n)}this.indexActive=t}this.ticking=!1}},{key:"destroy",value:function(){this.indexActive=null,this.indexSelected=this.selected();var t=this.el.parentNode;t.classList.contains(this.props.classNames.base)&&(this.props.prebuilt?(this.widgetEl=t.querySelector("."+this.props.classNames.base+"--stars"),t.classList.remove(this.props.classNames.base+"--"+this.direction),delete t.dataset.starRating):t.parentNode.replaceChild(this.el,t),this.handleEvents("remove")),delete this.el.widget}},{key:"eventListener",value:function(t,e,i,s){var n=this;i.forEach((function(i){return t[e+"EventListener"](i,n.events[i],s||!1)}))}},{key:"handleEvents",value:function(t){var e=this.el.closest("form");e&&"FORM"===e.tagName&&this.eventListener(e,t,["reset"]),this.eventListener(this.el,t,["change"]),"add"===t&&this.el.disabled||(this.eventListener(this.el,t,["keydown"]),this.eventListener(this.widgetEl,t,["mousedown","mouseleave","mousemove","touchend","touchmove"],!1))}},{key:"indexFromEvent",value:function(t){var e,i,s=(null===(e=t.touches)||void 0===e?void 0:e[0])||(null===(i=t.changedTouches)||void 0===i?void 0:i[0])||t,n=document.elementFromPoint(s.clientX,s.clientY);return n.parentNode===this.widgetEl?[].slice.call(n.parentNode.children).indexOf(n):this.indexActive}},{key:"onChange",value:function(){this.changeIndexTo(this.selected(),!0)}},{key:"onKeyDown",value:function(t){var e=t.key.slice(5);if(~["Left","Right"].indexOf(e)){t.preventDefault();var i="Left"===e?-1:1;"rtl"===this.direction&&(i*=-1);var s=this.values.length-1,n=Math.min(Math.max(this.selected()+i,-1),s);this.selectValue(n,!0)}}},{key:"onPointerDown",value:function(t){t.preventDefault();var e=this.indexFromEvent(t);this.props.clearable&&e===this.indexSelected&&(e=-1),this.selectValue(e,!0)}},{key:"onPointerLeave",value:function(t){var e=this;t.preventDefault(),cancelAnimationFrame(this.tick),requestAnimationFrame((function(){return e.changeIndexTo(e.indexSelected)}))}},{key:"onPointerMove",value:function(t){var e=this;t.preventDefault(),this.ticking||(this.tick=requestAnimationFrame((function(){return e.changeIndexTo(e.indexFromEvent(t))})),this.ticking=!0)}},{key:"onReset",value:function(){var t,e=this.valueIndex(null===(t=this.el.querySelector("[selected]"))||void 0===t?void 0:t.value);this.selectValue(e||-1,!1)}},{key:"selected",value:function(){return this.valueIndex(this.el.value)}},{key:"selectValue",value:function(t,e){var i;this.el.value=(null===(i=this.values[t])||void 0===i?void 0:i.value)||"",this.indexSelected=this.selected(),!1===e?this.changeIndexTo(this.selected(),!0):this.el.dispatchEvent(new Event("change"))}},{key:"valueIndex",value:function(t){return this.values.findIndex((function(e){return e.value===+t}))}}]),t}(),N=function(){function t(e,i){E(this,t),this.destroy=this.destroy.bind(this),this.props=i,this.rebuild=this.rebuild.bind(this),this.selector=e,this.widgets=[],this.build()}return S(t,[{key:"build",value:function(){var t=this;this.queryElements(this.selector).forEach((function(e){var i=G(x,t.props,JSON.parse(e.getAttribute("data-options")));"SELECT"!==e.tagName||e.widget||(!i.prebuilt&&e.parentNode.classList.contains(i.classNames.base)&&t.unwrap(e),t.widgets.push(new F(e,i)))}))}},{key:"destroy",value:function(){this.widgets.forEach((function(t){return t.destroy()})),this.widgets=[]}},{key:"queryElements",value:function(t){return"HTMLSelectElement"===A(t)?[t]:"NodeList"===A(t)?[].slice.call(t):"String"===A(t)?[].slice.call(document.querySelectorAll(t)):[]}},{key:"rebuild",value:function(){this.destroy(),this.build()}},{key:"unwrap",value:function(t){var e=t.parentNode,i=e.parentNode;i.insertBefore(t,e),i.removeChild(e)}}]),t}();const O={classNames:{base:"glsr-star-rating"},clearable:!1,tooltip:!1};const M=(t,e,i)=>{t&&e.split(" ").forEach((e=>{t.classList[i?"add":"remove"](e)}))},C=t=>"."+t.trim().split(" ").join("."),q=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200,i=null;return function(){clearTimeout(i);for(var s=arguments.length,n=new Array(s),r=0;r{let e='input[name="'+t.getAttribute("name")+'"]:checked';return t.validation.form.querySelectorAll(e).length},P={email:{fn:function(t){return!t||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}},max:{fn:function(t,e){return!t||("checkbox"===this.type?j(this)<=parseInt(e):parseFloat(t)<=parseFloat(e))}},maxlength:{fn:function(t,e){return!t||t.length<=parseInt(e)}},min:{fn:function(t,e){return!t||("checkbox"===this.type?j(this)>=parseInt(e):parseFloat(t)>=parseFloat(e))}},minlength:{fn:function(t,e){return!t||t.length>=parseInt(e)}},number:{fn:function(t){return!t||!isNaN(parseFloat(t))},priority:2},pattern:{fn:function(t,e){let i=e.match(new RegExp("^/(.*?)/([gimy]*)$"));return!t||new RegExp(i[1],i[2]).test(t)}},required:{fn:function(t){return"radio"===this.type||"checkbox"===this.type?j(this):void 0!==t&&""!==t},priority:99,halt:!0},tel:{fn:function(t){let e=t.replace(/[^0-9]/g,"").length;return!t||4<=e&&15>=e&&new RegExp("^[+]?[\\d\\s()-]*$").test(t)}},url:{fn:function(t){return!t||new RegExp("^(https?)://([\\p{L}\\p{N}\\p{S}\\-_.])+(.?([\\p{L}\\p{N}]|xn--[\\p{L}\\p{N}\\-]+)+.?)(:[0-9]+)?(?:/(?:[\\p{L}\\p{N}\\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*(?:\\?(?:[\\p{L}\\p{N}\\-._~!$&'\\[\\]()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?(?:#(?:[\\p{L}\\p{N}\\-._~!$&'()*+,;=:@/?]|%[0-9A-Fa-f]{2})*)?$","iu").test(t)}}},H=["required","max","maxlength","min","minlength","pattern"];class D{constructor(t){this.config=GLSR.validationconfig,this.fields=[],this.form=t,this.form.setAttribute("novalidate",""),this.strings=GLSR.validationstrings,this.validateEvent=this._onChange.bind(this)}destroy(){for(this.reset();this.fields.length;){const t=this.fields.shift();this._removeEvent(t.input),delete t.input.validation}}init(){this.form.querySelectorAll("input:not([type^=hidden]):not([type^=submit]), select, textarea, [data-glsr-validate]").forEach((t=>{if(this.fields.find((e=>e.input.name===t.name&&!t.name.endsWith("[]"))))return;let e=t.closest(C(this.config.field));e&&"none"!==e.style.display&&this.fields.push(this._initField(t))}))}reset(){for(let t in this.fields){if(!this.fields.hasOwnProperty(t))continue;this.fields[t].errorElements=null;let e=this.fields[t].input.closest(C(this.config.field));M(this.fields[t].input,this.config.input_error,!1),M(this.fields[t].input,this.config.input_valid,!1),M(e,this.config.field_error,!1),M(e,this.config.field_valid,!1)}}setErrors(t,e){t.hasOwnProperty("validation")&&this._initField(t),t.validation.errors=e}toggleError(t,e){let i=t.input.closest(C(this.config.field));if(M(t.input,this.config.input_error,e),M(t.input,this.config.input_valid,!e),i){M(i,this.config.field_error,e),M(i,this.config.field_valid,!e);let s=i.querySelector(C(this.config.field_message));s&&(s.innerHTML=e?t.errors.join("
"):"",s.style.display=e?"":"none")}}validate(t){let e=!0,i=this.fields;t instanceof HTMLElement&&(i=[t.validation]);for(let t in i){if(!i.hasOwnProperty(t))continue;const s=i[t];this._validateField(s)?this.toggleError(s,!1):(e=!1,this.toggleError(s,!0))}return e}_addEvent(t){t.addEventListener(this._getEventName(t),this.validateEvent)}_addValidators(t,e,i){[].forEach.call(t,(t=>{let s=t.name.replace("data-","");~H.indexOf(s)?this._addValidatorToField(e,i,s,t.value):"type"===t.name&&this._addValidatorToField(e,i,t.value)}))}_addValidatorToField(t,e,i,s){if(P[i]&&(P[i].name=i,t.push(P[i]),s)){var n="pattern"===i?[s]:s.split(",");n.unshift(null),e[i]=n}}_onChange(t){this.validate(t.currentTarget)}_removeEvent(t){t.removeEventListener(this._getEventName(t),this.validateEvent)}_getEventName(t){return~["radio","checkbox"].indexOf(t.getAttribute("type"))||"SELECT"===t.nodeName?"change":"input"}_initField(t){let e={},i=[];return null!==t.offsetParent&&(this._addValidators(t.attributes,i,e),this._sortValidators(i),this._addEvent(t)),t.validation={form:this.form,input:t,params:e,validate:()=>this.validate(t),validators:i}}_sortValidators(t){t.sort(((t,e)=>(e.priority||1)-(t.priority||1)))}_validateField(t){let e=[],i=!0;for(let s in t.validators){if(!t.validators.hasOwnProperty(s))continue;let n=t.validators[s],r=t.params[n.name]?t.params[n.name]:[];if(r[0]=t.input.value,!n.fn.apply(t.input,r)){i=!1;let t=this.strings[n.name];if(e.push(t.replace(/(\%s)/g,r[1])),!0===n.halt)break}}return t.errors=e,i}}class I{constructor(t,e){var i,s;this.button=_(e),this.config=GLSR.validationconfig,this.events={submit:this._onSubmit.bind(this)},this.form=t,this.isActive=!1,this.stars=(()=>{let t=null;const e=()=>!!t&&(t.rebuild(),!0);return{init:function(i){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e()||(t=new N(i,Object.assign({},O,s))),t},destroy:()=>!!t&&(t.destroy(),!0),rebuild:e}})(),this.strings=GLSR.validationstrings,this.captcha=new b(this),this.validation=new D(t),this.reviewsEl=document.getElementById(null===(i=t.closest(".glsr"))||void 0===i||null===(s=i.dataset)||void 0===s?void 0:s.reviews_id)}destroy(){this._destroyForm(),this.stars.destroy(),this.captcha.reset(),this.isActive=!1}init(){this.isActive||(this._initForm(),this.stars.init(this.form.querySelectorAll(".glsr-field-rating select"),GLSR.starsconfig),this.captcha.render(),this.isActive=!0)}submitForm(){this.button.loading(),GLSR.ajax.post(this._data(),this._handleResponse.bind(this))}_data(){const t=new FormData(this.form);if(this.reviewsEl&&this.reviewsEl.classList.contains("glsr"))try{const e=JSON.parse(JSON.stringify(this.reviewsEl.dataset));for(let i of Object.keys(e)){let s;try{s=JSON.parse(e[i])}catch(t){s=e[i]}t.append(`${GLSR.nameprefix}[_reviews_atts][${i}]`,s)}t.append([`${GLSR.nameprefix}[_pagination_atts][page]`],1),t.append([`${GLSR.nameprefix}[_pagination_atts][url]`],location.href)}catch(t){console.error(t)}return t}_destroyForm(){this.form.removeEventListener("submit",this.events.submit),this._resetErrors(),this.validation.destroy()}_handleResponse(t,e){const i=!0===e;if(this.captcha.reset(),i&&this.form.reset(),this._showFieldErrors(t.errors),this._showResults(t.message,i),this.button.loaded(),GLSR.Event.trigger("site-reviews/form/handle",t,this.form),i){if(t.redirect&&""!==t.redirect)return void(window.location=t.redirect);if(this.reviewsEl&&t.reviews){if(this.reviewsEl.innerHTML=t.reviews,GLSR.urlparameter){let t=new URL(location.href);t.searchParams.delete(GLSR.urlparameter),window.history.replaceState({},"",t.toString())}GLSR.Event.trigger("site-reviews/pagination/init")}}}_initForm(){this._destroyForm(),this.form.addEventListener("submit",this.events.submit),this.validation.init()}_onSubmit(t){if(!this.validation.validate())return t.preventDefault(),void this._showResults(this.strings.errors,!1);t.preventDefault(),this._resetErrors(),this.button.loading(),this.captcha.execute()}_resetErrors(){M(this.form,this.config.form_error,!1),this._showResults("",null),this.validation.reset()}_showFieldErrors(t){if(t)for(let e in t){if(!t.hasOwnProperty(e))continue;const i=GLSR.nameprefix?GLSR.nameprefix+"["+e+"]":e,s=this.form.querySelector('[name="'+i+'"]');s&&(this.validation.setErrors(s,t[e]),this.validation.toggleError(s.validation,"add"))}}_showResults(t,e){const i=this.form.querySelector(C(this.config.form_message));null!==i&&(M(this.form,this.config.form_error,!1===e),M(i,this.config.form_message_failed,!1===e),M(i,this.config.form_message_success,!0===e),i.innerHTML=t)}}var W=function(){return"undefined"==typeof window},V=function(t){t=t||navigator.userAgent;var e=/(iPad).*OS\s([\d_]+)/.test(t);return{ios:!e&&/(iPhone\sOS)\s([\d_]+)/.test(t)||e,android:/(Android);?[\s/]+([\d.]+)?/.test(t)}};var $=0,Y=0,J=0,B=null,K=!1,X=[],z=function(t){if(W())return!1;if(!t)throw new Error("options must be provided");var e=!1,i={get passive(){e=!0}},s=function(){},n="__TUA_BSL_TEST_PASSIVE__";window.addEventListener(n,s,i),window.removeEventListener(n,s,i);var r=t.capture;return e?t:void 0!==r&&r}({passive:!1}),U=!W()&&"scrollBehavior"in document.documentElement.style,Q=function(t){t.cancelable&&t.preventDefault()},Z=function(t){t||null!==t&&"production"!==process.env.NODE_ENV&&console.warn("If scrolling is also required in the floating layer, the target element must be provided.")},tt=function(t,e){if(!W()){if(Z(t),V().ios){if(t)(Array.isArray(t)?t:[t]).forEach((function(t){t&&-1===X.indexOf(t)&&(t.ontouchstart=function(t){Y=t.targetTouches[0].clientY,J=t.targetTouches[0].clientX},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){if(e){var i=e.scrollTop,s=e.scrollLeft,n=e.scrollWidth,r=e.scrollHeight,a=e.clientWidth,o=e.clientHeight,l=t.targetTouches[0].clientX-J,c=t.targetTouches[0].clientY-Y,h=Math.abs(c)>Math.abs(l);if(h&&(c>0&&0===i||c<0&&i+o+1>=r)||!h&&(l>0&&0===s||l<0&&s+a+1>=n))return Q(t)}t.stopPropagation()}(e,t)},X.push(t))}));K||(document.addEventListener("touchmove",Q,z),K=!0)}else $<=0&&(B=V().android?function(t){var e=document.documentElement,i=document.body,s=e.scrollTop||i.scrollTop,n=Object.assign({},e.style),r=Object.assign({},i.style);return e.style.height="100%",e.style.overflow="hidden",i.style.top="-".concat(s,"px"),i.style.width="100%",i.style.height="auto",i.style.position="fixed",i.style.overflow=(null==t?void 0:t.overflowType)||"hidden",function(){e.style.height=n.height||"",e.style.overflow=n.overflow||"",["top","width","height","overflow","position"].forEach((function(t){i.style[t]=r[t]||""}));var t={top:s,behavior:"instant"};U?window.scrollTo(t):window.scrollTo(0,s)}}(e):(i=document.documentElement,s=Object.assign({},i.style),n=window.innerWidth-i.clientWidth,r=parseInt(window.getComputedStyle(i).paddingRight,10),i.style.overflow="hidden",i.style.boxSizing="border-box",i.style.paddingRight="".concat(n+r,"px"),function(){["overflow","boxSizing","paddingRight"].forEach((function(t){i.style[t]=s[t]||""}))}));var i,s,n,r;$+=1}};const et=["[contenteditable]",'[tabindex]:not([tabindex^="-"])',"a[href]","button:not([disabled]):not([aria-hidden])",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])"],it={focus:!1,onClose:()=>{},onOpen:()=>{}},st="data-glsr-close",nt="glsr-modal",rt="is-open",at="data-glsr-trigger",ot=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.class=nt+"__"+t,e};class lt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.events={_open:this._openModal.bind(this),mouseup:this._onClick.bind(this),keydown:this._onKeydown.bind(this),touchstart:this._onClick.bind(this)},this.id=t,this.triggers=[],this._config(e),this._reset()}_closeModal(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;var e;t&&(t.preventDefault(),t.stopPropagation()),this.root.setAttribute("aria-hidden","true"),this._eventHandler("remove"),e=this.content,W()||(Z(e),($-=1)>0)||(V().ios||"function"!=typeof B?(e&&(Array.isArray(e)?e:[e]).forEach((function(t){var e=X.indexOf(t);-1!==e&&(t.ontouchmove=null,t.ontouchstart=null,X.splice(e,1))})),K&&(document.removeEventListener("touchmove",Q,z),K=!1)):B()),this.trigger&&this.trigger.focus&&this.trigger.focus();const i=()=>{this.root.removeEventListener("animationend",i,!1),this.root.classList.remove(rt),ht.pop(),this.config.onClose(this,t),GLSR.Event.trigger("site-reviews/modal/close",this.root,this.trigger,t),q((()=>this._reset()))()};this.root.addEventListener("animationend",i,!1)}_config(t){return this.config=Object.assign({},it,t),this}_eventHandler(t){this._eventListener(this.close,t,["keydown"]),this._eventListener(this.root,t,["mouseup","touchstart"]),this._eventListener(document,t,["keydown"])}_eventListener(t,e,i){t&&i.forEach((i=>t[e+"EventListener"](i,this.events[i])))}_focusableNodes(){return[].slice.call(this.root.querySelectorAll(et))}_insertModal(){const t=v("button",ot("close",{"aria-label":GLSR.text.closemodal,"data-glsr-close":""})),e=v("div",ot("content",{tabindex:-1})),i=v("div",ot("header")),s=v("div",ot("footer")),n=v("div",{class:nt,id:this.id,"aria-hidden":!0},v("div",ot("overlay",{tabindex:-1,"data-glsr-close":""}),v("div",ot("dialog",{"aria-modal":!0,role:"dialog"}),t,i,e,s)));this.close=t,this.content=e,this.footer=s,this.header=i,this.root=document.body.appendChild(n)}_onClick(t){t.target.hasAttribute(st)&&this._closeModal(t)}_onKeydown(t){~[13,32].indexOf(t.keyCode)&&t.target===this.close&&this._closeModal(t),27===t.keyCode&&ht.slice(-1)[0]===this.id&&this._closeModal(t),9===t.keyCode&&this._retainFocus(t)}_openModal(t){ht.push(this.id),this.trigger=document.activeElement,t&&(t.preventDefault(),this.trigger=t.currentTarget),this._insertModal(),tt(this.content),this.config.onOpen(this,t),GLSR.Event.trigger("site-reviews/modal/open",this.root,this.trigger,t),this.root.setAttribute("aria-hidden","false"),this.root.classList.add(rt),this._eventHandler("add");const e=()=>{this.root.removeEventListener("animationend",e,!1),this._setFocusToFirstNode()};this.root.addEventListener("animationend",e,!1)}_registerTrigger(t){this._removeTrigger(t),t.addEventListener("click",this.events._open),this.triggers.push(t)}_removeTrigger(t){this.triggers.filter((e=>e!==t)),t.removeEventListener("click",this.events._open)}_removeTriggers(){this.triggers.forEach((t=>this._removeTrigger(t))),this.triggers=[]}_reset(){this.root&&this.root.remove(),this.close=null,this.content=null,this.footer=null,this.header=null,this.root=null,this.trigger=null}_retainFocus(t){let e=this._focusableNodes();if(0!==e.length)if(e=e.filter((t=>null!==t.offsetParent)),this.root.contains(document.activeElement)){const i=e.indexOf(document.activeElement);t.shiftKey&&0===i?(e[e.length-1].focus(),t.preventDefault()):!t.shiftKey&&e.length>0&&i===e.length-1&&(e[0].focus(),t.preventDefault())}else e[0].focus()}_setFocusToFirstNode(){if(!this.config.focus)return;const t=this._focusableNodes();if(0===t.length)return;const e=t.filter((t=>!t.hasAttribute(st)));e.length>0?e[0].focus():0===e.length&&t[0].focus()}}const ct={},ht=[];var dt={close:t=>{if(t)ct[t]&&ct[t]._closeModal();else for(let t in ct)ct[t]._closeModal()},init:(t,e)=>{let i;return ct[t]?(i=ct[t],i._removeTriggers(),e&&i._config(e)):i=new lt(t,e),document.querySelectorAll("["+at+"]").forEach((e=>{t===e.attributes[at].value&&i._registerTrigger(e)})),ct[t]=i,ct},open:(t,e)=>{let i;ct[t]?(i=ct[t],i.root&&i._eventHandler("remove"),e&&i._config(e)):i=new lt(t,e),ct[t]=i,i._openModal()}};const ut="glsr-hide",pt=16,ft=468,vt="button.glsr-button-loadmore",gt=".glsr-pagination a[data-page]",mt=".glsr-reviews, [data-reviews]";class wt{constructor(t,e){this.events={button:{click:this._onLoadMore.bind(this)},link:{click:this._onPaginate.bind(this)},window:{popstate:this._onPopstate.bind(this)}},this.paginationEl=e,this.reviewsEl=t.querySelector(mt),this.wrapperEl=t}destroy(){this._eventHandler("remove")}init(){this._eventHandler("add");const t=this.paginationEl.querySelector(".current");if(t){const e=this._data(t),i=t.nextElementSibling;e&&i&&2==+i.dataset.page&&GLSR.urlparameter&&window.history.replaceState(e,"",window.location)}}_data(t){try{const i=JSON.parse(JSON.stringify(this.paginationEl.dataset)),s={page:t.dataset.page||1,schema:!1,url:t.href||location.href};for(var e of Object.keys(i)){let t;try{t=JSON.parse(i[e])}catch(s){t=i[e]}s[`atts][${e}`]=t}return GLSR.ajax.data("fetch-paged-reviews",s)}catch(t){return console.error("Invalid pagination config."),!1}}_eventHandler(t){this._eventListener(window,t,this.events.window),this.wrapperEl.querySelectorAll(vt).forEach((e=>{this._eventListener(e,t,this.events.button)})),this.wrapperEl.querySelectorAll(gt).forEach((e=>{this._eventListener(e,t,this.events.link)}))}_eventListener(t,e,i){Object.keys(i).forEach((s=>t[e+"EventListener"](s,i[s])))}_handleLoadMore(t,e,i,s){s?(t.loaded(),this.destroy(),this.paginationEl.innerHTML=i.pagination,this.reviewsEl.insertAdjacentHTML("beforeend",i.reviews),this.init(),GLSR.Event.trigger("site-reviews/pagination/handle",i,this)):window.location=location}_handlePagination(t,e,i,s){s?(this._paginate(i),GLSR.urlparameter&&window.history.pushState(e,"",t.href)):window.location=t.href}_handlePopstate(t,e,i){i?this._paginate(e):console.error(e)}_loaded(){const t=this.paginationEl.querySelector(".glsr-spinner");t&&this.paginationEl.removeChild(t),this.wrapperEl.classList.remove(ut)}_loading(){this.wrapperEl.classList.add(ut),this.paginationEl.insertAdjacentHTML("beforeend",'
')}_onLoadMore(t){const e=t.currentTarget,i=this._data(e);if(i){const s=_(e);s.loading(),t.preventDefault(),GLSR.ajax.post(i,this._handleLoadMore.bind(this,s,i))}}_onPaginate(t){const e=t.currentTarget,i=this._data(e);i&&(this._loading(),t.preventDefault(),GLSR.ajax.post(i,this._handlePagination.bind(this,e,i)))}_onPopstate(t){GLSR.Event.trigger("site-reviews/pagination/popstate",t,this),t.state&&t.state[`${GLSR.nameprefix}[_action]`]&&(this._loading(),GLSR.ajax.post(t.state,this._handlePopstate.bind(this,t.state)))}_paginate(t){this.destroy(),this.paginationEl.innerHTML=t.pagination,this.reviewsEl.innerHTML=t.reviews,this.init(),this._scrollToTop(),this._loaded(),GLSR.Event.trigger("site-reviews/pagination/handle",t,this)}_scrollStep(t){const e=Math.min(1,(window.performance.now()-t.startTime)/ft),i=.5*(1-Math.cos(Math.PI*e)),s=t.startY+(t.endY-t.startY)*i;window.scroll(0,t.offset+s),s!==t.endY&&window.requestAnimationFrame(this._scrollStep.bind(this,t))}_scrollToTop(){let t=pt;[].forEach.call(GLSR.ajaxpagination,(e=>{const i=document.querySelector(e);i&&"fixed"===window.getComputedStyle(i).getPropertyValue("position")&&(t+=i.clientHeight)}));const e=this.reviewsEl.getBoundingClientRect().top-t;e>0||this._scrollStep({endY:e,offset:window.pageYOffset,startTime:window.performance.now(),startY:this.reviewsEl.scrollTop})}}const yt="site-reviews/excerpts/init",_t="site-reviews/forms/init",bt="site-reviews/init",Et="site-reviews/loaded",Lt="site-reviews/modal/init",St="site-reviews/pagination/init";window.hasOwnProperty("GLSR")||(window.GLSR={}),window.GLSR.ajax=a,window.GLSR.forms=[],window.GLSR.pagination=[],window.GLSR.Event=h,window.GLSR.Modal=dt,window.GLSR.Utils={debounce:q,dom:v},h.on(yt,(t=>{new y(t),h.trigger(Lt)})),h.on(_t,(()=>{GLSR.forms=GLSR.forms.filter((t=>!!t.form.closest("body"))),document.querySelectorAll("form.glsr-review-form").forEach((t=>{const e=t.querySelector("[type=submit]");if(e){let i,s=GLSR.forms.findIndex((e=>e.form===t));-1!==s?(i=GLSR.forms[s],i.destroy()):(i=new I(t,e),GLSR.forms.push(i)),i.init()}}))})),h.on(Lt,(()=>{GLSR.Modal.init("glsr-modal-review",{onOpen:t=>{const e=t.trigger.closest(".glsr").cloneNode(!0),i=t.trigger.closest(".glsr-review").cloneNode(!0);i.querySelectorAll('[data-expanded="false"]').forEach((t=>{t.dataset.expanded="true"})),e.innerHTML="",e.appendChild(i),t.content.appendChild(e)}})})),h.on(St,(()=>{GLSR.pagination.forEach((t=>t.destroy())),GLSR.pagination=[],document.querySelectorAll(".glsr").forEach((t=>{const e=t.querySelector(".glsr-pagination");if(e&&(e.classList.contains("glsr-ajax-loadmore")||e.classList.contains("glsr-ajax-pagination"))){const i=new wt(t,e);i.init(),GLSR.pagination.push(i)}}))})),h.on(bt,(()=>{document.querySelectorAll(".glsr").forEach((t=>{const e="glsr-"+window.getComputedStyle(t,null).getPropertyValue("direction");t.classList.add(e)})),h.trigger(yt),h.trigger(_t),h.trigger(St),h.trigger(Et)})),h.on("site-reviews/pagination/handle",((t,e)=>{h.trigger(yt,e.wrapperEl)})),document.addEventListener("DOMContentLoaded",(()=>{setTimeout((()=>h.trigger(bt)),5),setTimeout((()=>(()=>{let t=new URL(location.href);if(!t.searchParams.has("review_id")||!t.searchParams.has("verified"))return;let e=["form","review_id","theme","verified"],i={};e.forEach((e=>{t.searchParams.has(e)&&(i[e]=t.searchParams.get(e))})),GLSR.ajax.post(GLSR.ajax.data("verified-review",i),((s,n)=>{n?GLSR.Modal.open("glsr-modal-verified",{onClose:i=>{e.forEach((e=>t.searchParams.delete(e))),history.pushState({},"",t.href)},onOpen:t=>{const e=v("p"),i=v("div",s.attributes);e.innerHTML=s.message,i.innerHTML=s.review,i.querySelectorAll('[data-expanded="false"]').forEach((t=>{t.dataset.expanded="true"})),t.content.appendChild(i),t.footer.appendChild(e)}}):console.error({request:i,response:s})}))})()),10)}))}();