"use strict";window.rhCurrentScript=document.currentScript.src,function(){try{function R(e){!h("console_log")&&"localhost"!==window.location.hostname||console.log(e)}function O(e){"function"==typeof prqAddedAllToCartCallback&&prqAddedAllToCartCallback(e)}function M(t,o,n){R("embed.js - setCookie - "+t+" - "+o+" - "+n);var e,r="";n&&((e=new Date).setTime(e.getTime()+24*n*60*60*1e3),r="; expires="+e.toUTCString());try{document.cookie=t+"="+(o||"")+r+"; sameSite=Lax; path=/"}catch(e){console.warn("Failed to set cookie:",e),console.warn("cookie details:",t,o,n)}}function h(t){try{for(var e=t+"=",o=document.cookie.split(";"),n=0;n"+e.item_count+"",0===e.item_count?t.classList.add("hide"):t.classList.remove("hide")});o(document.getElementsByClassName("cart-item-count-header"));var e=document.getElementsByClassName("cart_count");o(e)}function W(e){R("embed.js - addProductsToCartBigCommerce"),R(e),window.addingToCart=!0;var t,r=[];for(t in e){var a="/cart.php?action=add&sku="+JSON.parse(t).sku+"&qty="+e[t];r.push(a)}R(r);!function t(o){var n;n=r[o],new Promise(function(e,t){var o=new XMLHttpRequest;o.open("GET",n,!0),o.onreadystatechange=function(){4==o.readyState&&(200==o.status?e(!0):t(Error(o.statusText)))},o.onerror=function(){t(Error("network error"))},o.send()}).then(function(e){R(r[o]),R(e),++o{R(j.response),"function"==typeof prqAddedOneToCartCallback&&prqAddedOneToCartCallback(w)},j.send()}if("add_all"===l.action&&"function"==typeof prqAddAllToCartCallback&&(R("embed.js - add_all"),prqAddAllToCartCallback(l)),"add_all"===l.action&&"ShopifyShop"===l.platform&&(R("embed.js - add_all Shopify"),window.addingToCart=!0,b=l.variantId.split("||"),d={},b.forEach(function(e){d[parseInt(e)]=1}),H("/cart/update.js",{updates:d},function(e){window.addingToCart=!1,N(),O(l)})),"add_all"===l.action&&"WoocommerceShop"===l.platform&&(R("embed.js - add_all WooCommerce"),window.addingToCart=!0,b=l.variantId.split("||"),function t(o){F({quantity:1,product_id:b[o]}).then(function(e){++o{R(I.response),P({action:"added_all"}),O(l)},I.send()}if("change_variant"===l.action){R("embed.js - change_variant");var b,v=(b=l.variantId.split("||"))[0],q=b[1];if(R(v),R(q),"ShopifyShop"===l.platform){var C,v=JSON.parse(v),q=JSON.parse(q);if(v.recharge)return R("ReCharge product"),R(C={id:v.variant_id,sellingPlanId:v.recharge.external_plan_id,sellingPlanGroupId:v.recharge.external_plan_group_id,isSubscription:!0}),void window.ReChargeWidget.api.postToCart(C);var _={};_[q.variant_id]=0,_[v.variant_id]=l.quantity,R("/cart/update.js"),R(_),H("/cart/update.js",{updates:_},function(e){R(e)})}"WoocommerceShop"===l.platform&&F(w={quantity:1,product_id:v})}if("remove_one"===l.action&&"function"==typeof prqRemoveOneFromCartCallback&&(R("remove_one callback"),prqRemoveOneFromCartCallback(l)),"remove_one"===l.action&&"ShopifyShop"===l.platform&&(R("remove_one Shopify"),c={},void 0!==l.quantity&&l.quantity||(l.quantity=0),c[l.variantId]=l.quantity,R("/cart/update.js"),R(c),H("/cart/update.js",{updates:c},function(e){R(e),N(),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(e)})),"remove_one"===l.action&&"WoocommerceShop"===l.platform){R("embed.js - remove_one WooCommerce");var S,k=new XMLHttpRequest,x=(k.open("POST","/?wc-ajax=remove_from_cart"),k.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),{cart_item_key:l.originId}),A=[];for(S in x){var T=encodeURIComponent(S),E=encodeURIComponent(x[S]);A.push(T+"="+E)}A=A.join("&"),k.onload=function(){R(k)},k.send(A)}if("remove_one"===l.action&&"MagentoShop"===l.platform){R("embed.js - remove_one Magento");var z,w={quantity:1,product_id:z=l.variantId||l.originId,product_sku:l.sku};const L=new XMLHttpRequest;L.responseType="json",L.open("GET","/productquiz/index/removequizproductstocart/product_id/"+z+"?"+U()),L.onload=()=>{R(L.response),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(w)},L.send()}}},!1);const p=()=>{for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",t="",o=0;o<6;o++)t+=e.charAt(Math.floor(Math.random()*e.length));return t};function U(){return"cachebuster="+p()}const l=e=>"[object Object]"===Object.prototype.toString.call(e),m=(e,t=!1,o=!1,n=!1,r=!1)=>{t=a(t,o,n,r),o=new URLSearchParams(t).toString();return e+(""===o?"":"?"+o)},f=e=>{var t,o;return R("shopifyCurrency"),R(e),"undefined"!=typeof Shopify&&Shopify&&Shopify.currency?({active:o,rate:t}=Shopify.currency,o=`currency_code=${o}¤cy_rate=`+t,e.includes("?")?e+"&"+o:e+"?"+o):e},a=function(e,t,o,n){R("embed.js - quizParameters");var r,a,i,d=new URLSearchParams(window.location.search),c={};e&&(t=c.popup="true"),o&&(c.popupWidth=o),n&&(c.popupHeight=n),t||(c.autoscroll="false"),l(window.prq_vars)&&(c=Object.assign(c,window.prq_vars)),R("URLSearchParams");for(r of d.entries())r[0].startsWith("prq_")&&(a=r[0].replace("prq_",""),i=r[1],R(r),c[a]=i);return c},r=function(e){return R("embed.js - isAutoScroll"),R(e),!e||"false"!==e.toLowerCase()},G=()=>null!==document.querySelector("body.smart-cart--enabled")&&"undefined"!=typeof Rebuy&&void 0!==Rebuy?.SmartCart,g=function(){document.querySelectorAll(".rh-widget iframe")&&document.querySelectorAll(".rh-widget iframe").forEach(function(e){e.remove()}),document.querySelectorAll(".rh-widget").forEach(function(e){var t=p(),o=e.dataset.url,o=m(o,!1,r(e.dataset.autoscroll)),o=f(o),n=(R("RenderInlineEmbed - shopifyCurrency"),R(o),document.createElement("iframe"));n.src=o,n.id=t,n.style.cssText="transform-style: preserve-3d; padding: 0; border: none; margin: 0 auto; height: 100%; flex-grow: 1; background: url(https://admin.revenuehunt.com/rolling.svg) no-repeat center;",n.setAttribute("data-hj-allow-iframe","true"),e.appendChild(n),document.getElementById(t).onload=function(){document.getElementById(t).contentWindow.focus()}})},w=()=>{let e="https://admin.revenuehunt.com";return/admin\-staging\.revenuehunt\.com/.test(window.rhCurrentScript)&&(e="https://admin-staging.revenuehunt.com"),/admin\-dev\.revenuehunt\.com/.test(window.rhCurrentScript)&&(e="https://admin-dev.revenuehunt.com"),e=/localhost/.test(window.rhCurrentScript)||/productrecommendationquizforwoocommerce/.test(document.URL)||/productrecommendationquiz.local/.test(document.URL)?"http://localhost:9528":e},y=function(){var e=w(),e='.rh-chat { width: 50px; height: 50px; bottom: 20px; right: 20px; cursor: pointer; position: fixed; border-radius: 25px; -webkit-border-radius: 25px; -moz-border-radius: 25px; -webkit-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); -moz-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); } .rh-greeting { padding: 8px; background-color: white; bottom: 29px; right: 80px; position: fixed; color: #666; font-size: 12px; border: 1px solid #eee; border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; -webkit-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); -moz-box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); box-shadow: 0 0 3px 0 rgba(0,0,0,0.1); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } span.rh-close { cursor: pointer; font-weight: bold; background-image: url(\''+e+"/close-x.svg'); background-size: cover; background-position: center; opacity: 0.25; width: 10px; height: 10px; margin-left: 4px; display: inline-block !important; } .rh-dot { width: 10px; height: 10px; background-color: #FF5500; border: 2px solid white; float: right; box-sizing: content-box; border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; display: block !important; } .rh-icon { width: 25px; height: 25px; position: absolute; margin: 12px; background-image: url('"+e+"/chat-quiz-white.svg'); background-size: cover; background-position: center; display: inline-block !important; }",t=document.createElement("style");t.innerText=e.replace(/[\r\n]+/gm,""),document.head.appendChild(t)},b=(window.rhCloseGreeting=function(){R("rhCloseGreeting"),document.getElementById("rh-greeting")&&(document.getElementById("rh-greeting").outerHTML="")},window.rhCloseNotification=function(){R("rhCloseNotification"),document.getElementById("rh-dot")&&(document.getElementById("rh-dot").outerHTML="")},window.rhClickChat=function(e,t,o){R("rhClickChat"),R(e),window.rhCloseGreeting(),window.rhCloseNotification(),window.openQuizPopup(e,t,o)},function(e,t,o,n,r,a){var i=document.createElement("div"),d=document.createElement("div"),c=document.createElement("div");d.classList.add("rh-chat"),d.style.backgroundColor=t,d.addEventListener("click",function(){window.rhClickChat(e,r,a)}),c.classList.add("rh-icon"),d.appendChild(c),o&&((t=document.createElement("div")).classList.add("rh-dot"),t.setAttribute("id","rh-dot"),d.appendChild(t)),i.appendChild(d),n&&(c=document.createElement("div"),o=document.createElement("span"),c.classList.add("rh-greeting"),c.setAttribute("id","rh-greeting"),c.textContent=n,o.classList.add("rh-close"),o.addEventListener("click",window.rhCloseGreeting),c.appendChild(o),i.appendChild(c)),document.body.appendChild(i)}),v=function(e,t,o,n,r){var a,i,d,c,l,s,u;o&&window.prqPopup?R("window.isPopup: "+o):(o&&(window.prqPopup=e,document.querySelector("body").style.overflow="hidden",M("auto-popup-"+e,"true",7)),a=w(),(i=document.createElement("div")).className="rh-modal",i.style.cssText="display: block; position: fixed; z-index: 9998 !important; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(254,254,254,0.6);",(d=document.createElement("span")).innerHTML="×",d.style.cssText="position: fixed; color: #aaaaaa; z-index: 9999 !important; font-size: 50px; font-weight: bold; right: 25px; top: 5px; cursor: pointer;",d.onclick=function(e){R("click X close quiz"),document.querySelector("body").style.overflow=null,window.prqPopup=!1,i.style.display="none",-1!==window.location.hash.indexOf("#quiz-")&&history.pushState("",document.title,window.location.pathname+window.location.search)},s=a+"/public/quiz/"+e,l=m(s,o,!1,n,r),void 0!==t&&!1!==t&&(c=!0,l=a+"/public/quiz/"+e+"/results/"+t),l=f(l),R("showQuiz - shopifyCurrency"),R(l),s=document.querySelectorAll(".rh-inline"),u=!1,c&&0v(n,!1,"true");t?(t.click(),setTimeout(o,200)):o()}if(e.match(/\#results\-/)){const r=e.split("#results-")[1].split("-");R("#results"),R(r),v(r[0],r[1],!1),document.querySelectorAll(".rh-inline").forEach(e=>{var t=e.dataset.url.split("/").pop();r[0]===t&&(document.querySelector("body").style.overflow=null,e.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"}))})}},J=e=>{document.querySelector("[id='"+e+"'] span").click()},X=e=>{if(!e||!e.dataset||"false"===e.dataset.autoscroll)return!1;var e=e.getBoundingClientRect(),t=e.y+window.pageYOffset;e&&e.y<0&&(R("scroll_to: "+t),window.scrollTo({top:t,left:0,behavior:"smooth"}))};window.openQuizPopup=function(e,t,o){v(e,!1,"true",t,o)};var t=function(){R("embed.js - prqApp"),c=".rh-inline, .rh-inline iframe{-webkit-transition: height 0.5s; -moz-transition: height 0.5s; -ms-transition: height 0.5s; -o-transition: height 0.5s; transition: height 0.5s;}",(a=document.createElement("style")).textContent=c,document.head.append(a),q("https://api.revenuehunt.com"),q("https://space.revenuehunt.com"),R("embed.js - GetAutomaticPopupData"),c=h("data-timeout"),o=Date.now(),r=n=!1,c&&(R("data-timeout cookie set:"),r=c.split("||")[0],n=parseInt(c.split("||")[1])),null!==document.getElementById("auto-popup")&&(a=document.getElementById("auto-popup"),d=parseFloat(a.getAttribute("data-timeout")),l=a.getAttribute("data-exit-intent")&&"true"===a.getAttribute("data-exit-intent").toLocaleLowerCase(),i=a.getAttribute("data-aggressive")&&"true"===a.getAttribute("data-aggressive").toLocaleLowerCase(),window.popupWidth=a.getAttribute("data-popup-width"),window.popupHeight=a.getAttribute("data-popup-height"),t=h("auto-popup-"+(r=a.getAttribute("data-quiz-id"))),i&&(t=h("prq-responseId-"+r)),n=1e3*(d=d&&d<=0?.5:d)+o),c||M("data-timeout",r+"||"+n,7),r&&l&&!t&&document.addEventListener("mouseout",e=>{e.toElement||e.relatedTarget||t||window.popupAlreadyShown||(window.popupAlreadyShown=r,v(r,!1,"true",window.popupWidth,window.popupHeight))}),R("timeTimeout:"),R((n-o)/1e3),R(r),r&&!t&&0{R("embed.js - detectHashChange"),C()}),/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&window.addEventListener("pageshow",function(){document.querySelectorAll(".rh-widget iframe").forEach(function(e){R("embed.js - is Safari, reload iframe"),e.src=e.src})}),"undefined"!=typeof Shopify&&Shopify&&Shopify.designMode){var p=document.querySelectorAll(".rh-quiz-list");for(let e=0;e{console.error("Error sending event data to Ahoy:",e)})}}();