"use strict";window.rhScheduledMaintenance=!1,window.rhCurrentScript=document.currentScript.src,window.rhVersion="1.0.0",window.rhDate=new Date;var scriptUrl=new URL(window.rhCurrentScript),prqParams=new URLSearchParams(scriptUrl.search);function prqSetCookie(o,t,n){console_log("embed.js - prqSetCookie - "+o+" - "+t+" - "+n);var e,r="";n&&((e=new Date).setTime(e.getTime()+24*n*60*60*1e3),r="; expires="+e.toUTCString());try{document.cookie=o+"="+(t||"")+r+"; sameSite=Lax; path=/"}catch(e){console.warn("Failed to set cookie:",e),console.warn("cookie details:",o,t,n)}}function prqGetCookie(o){try{for(var e=o+"=",t=document.cookie.split(";"),n=0;n<t.length;n++){for(var r=t[n];" "===r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(e))return r.substring(e.length,r.length)}}catch(e){console.warn("Failed to read cookie:",e),console.warn("cookie name:",o)}return null}function console_log(e){return!(!prqGetCookie("console_log")&&"localhost"!==window.location.hostname||(console.log(e),0))}function iFrameEvent(e){console_log("embed.js - iFrameEvent - "+e);var o=document.querySelector(".rh-widget iframe"),e=JSON.stringify(e);o&&o.contentWindow&&o.contentWindow.postMessage&&o.contentWindow.postMessage(e,"*")}window.rhCurrentShop=prqParams.get("shop"),window.iFrameEvent=iFrameEvent,function(){try{function R(e){"function"==typeof prqAddedAllToCartCallback&&prqAddedAllToCartCallback(e)}window.addingToCart=!1,console_log("console_log enabled // "+window.rhVersion+" // "+window.rhDate);const n=(e,o)=>{const t=new XMLHttpRequest;t.onreadystatechange=()=>{4===t.readyState&&200===t.status&&o(JSON.parse(t.responseText))},t.open("GET",e,!0),t.send(null)},H=(e,o,t)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{4===n.readyState&&200===n.status&&t(JSON.parse(n.responseText))},n.open("POST",e,!0),n.setRequestHeader("Content-Type","application/json;charset=UTF-8"),n.send(JSON.stringify(o))};function t(t){t&&0<t.length&&n("/cart.js",function(e){for(var o=0;o<t.length;o++)t[o].innerHTML=e.item_count})}function O(o){console_log("embed.js - waitForPopulatedCart");var t=1;window.addingToCart?(console_log("start loop"),function e(){setTimeout(function(){window.addingToCart?(console_log("wait... "+t),++t<20&&e()):(console_log("redirecting to url..."),window.location.href=o)},2e3)}()):(console_log("redirecting to url..."),window.location.href=o)}function P(){var o=document.getElementById("CartCount");o&&n("/cart.js",function(e){o.innerHTML="<span>"+e.item_count+"</span>",0===e.item_count?o.classList.add("hide"):o.classList.remove("hide")});t(document.getElementsByClassName("cart-item-count-header"));var e=document.getElementsByClassName("cart_count");t(e)}function U(e){console_log("embed.js - addProductsToCartBigCommerce"),console_log(e),window.addingToCart=!0;var o,r=[];for(o in e){var a="/cart.php?action=add&sku="+encodeURIComponent(JSON.parse(o).sku)+"&qty="+encodeURIComponent(e[o]);r.push(a)}console_log(r);!function o(t){var n;n=r[t],new Promise(function(e,o){var t=new XMLHttpRequest;t.open("GET",n,!0),t.onreadystatechange=function(){4==t.readyState&&(200==t.status?e(!0):o(Error(t.statusText)))},t.onerror=function(){o(Error("network error"))},t.send()}).then(function(e){console_log(r[t]),console_log(e),++t<r.length?o(t):(console_log("embed.js - addProductsToCartBigCommerce - finished"),window.addingToCart=!1,a="/cart.php",window.location.href=a)})}(0)}function M(d){return console_log("embed.js - wcAddToCart"),new Promise(function(e,o){var t,n=new XMLHttpRequest,r=(window.rhCurrentShop&&null!==window.rhCurrentShop?n.open("POST","https://"+window.rhCurrentShop+"/?wc-ajax=add_to_cart"):n.open("POST","/?wc-ajax=add_to_cart"),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),[]);for(t in d){var a=encodeURIComponent(t),i=encodeURIComponent(d[t]);r.push(a+"="+i)}r=r.join("&"),n.onreadystatechange=function(){4==n.readyState&&(200==n.status?(e(JSON.parse(n.responseText)),iFrameEvent({action:"added_one",product:d}),"function"==typeof prqAddedOneToCartCallback&&prqAddedOneToCartCallback(d)):o(Error(n.statusText)))},n.onerror=function(){o(Error("network error"))},n.send(r)})}const r=()=>{console_log("embed.js - addWindowEventListenerMessage"),window.addEventListener("message",function(e){if("https://admin.revenuehunt.com"===e.origin||"https://admin-staging.revenuehunt.com"===e.origin||"http://localhost:9528"===e.origin||"admin-dev.revenuehunt.com"===e.origin){var o,t,n,r,a,i,d,l,c="object"==typeof e.data?e.data:JSON.parse(e.data);try{"gtag_event"===c.action&&(console_log("gtag_event"),console_log(c),_=c.gtag_id,b=c.gtag_action,v=c.gtag_category,i=c.gtag_label,"undefined"==typeof gtag?console.warn("RevenueHunt: make sure to load gtag, before the embed.js script"):(console_log("trigger gtag"),v={event_category:v,event_label:i},void 0!==_&&(console_log("set user defined gtag"),v.send_to=_),gtag("event",b,v)))}catch(c){console_log(c)}try{"fbpixel_event"===c.action&&(l=c.facebook_pixel,o=c.fbq_action,t=c.fbq_event,n=c.fbq_params,void 0===window.fbq&&l&&(q=window,C=document,q.fbq||(r=q.fbq=function(){r.callMethod?r.callMethod.apply(r,arguments):r.queue.push(arguments)},q._fbq||(q._fbq=r),(r.push=r).loaded=!0,r.version="2.0",r.queue=[],(q=C.createElement("script")).async=!0,q.src="https://connect.facebook.net/en_US/fbevents.js",(C=C.getElementsByTagName("script")[0]).parentNode.insertBefore(q,C)),window.fbq("init",l)),void 0!==window.fbq)&&(n?window.fbq(o,t,n):window.fbq(o,t))}catch(c){console_log(c)}if("iframe_height"===c.action){if(0===(a=document.querySelectorAll(".rh-inline")).length)return;for(let e=0;e<a.length;e++){var s=a[e].dataset.url.split("/").pop();c.quizid===s&&(f=(m=a[e]).querySelector(".rh-inline iframe"))}if(!m||!f)return;var u="true"===m.getAttribute("data-fixed-height");"response"===c.location&&(u=!1),0===c.height||u||(m.style.height=c.height+"px",f.style.height=c.height+"px")}if("quiz_callback"===c.action){console_log("embed.js - quiz_callback"),prqSetCookie("prq-responseId-"+c.quiz.id,c.response.id,7);var p=c;if(console_log("embed.js - tagCartWithResponseId"),p.responseId||p.quizAnswers){var h={};if(p.responseId&&(h.__prq_response_id=p.responseId,h.__prq_quiz_id=p.quizId),p.quizAnswers)for(var g in p.quizAnswers)h[g]=p.quizAnswers[g];console_log("/cart/update.js"),console_log(h),H("/cart/update.js",{attributes:h},function(e){console_log(e)})}"function"==typeof prqQuizCallback&&prqQuizCallback(c),console_log("set klaviyo identify"),console_log(c.klaviyoIdentify),c.klaviyoIdentify&&"object"==typeof klaviyo?klaviyo.push(["identify",c.klaviyoIdentify]):c.klaviyoIdentify&&"object"==typeof _learnq&&_learnq.push(["identify",c.klaviyoIdentify])}if("slide_callback"===c.action&&"function"==typeof prqSlideCallback&&(console_log("embed.js - slide_callback"),prqSlideCallback(c)),"view_product"===c.action&&(window.location.href=c.url),"proceed_to_cart"===c.action){console_log("embed.js - proceed_to_cart"),console_log(c);e="/cart";if("undefined"!=typeof Shopify&&Shopify&&Shopify.routes&&Shopify.routes.root&&(e=Shopify.routes.root+"cart"),"ShopifyShop"===c.platform&&c.discountcode&&(e="/discount/"+c.discountcode.trim()+"/?redirect=/cart"),"ShopifyShop"===c.platform&&e.includes("?")?e=e+"&locale="+c.locale:"ShopifyShop"===c.platform&&(e=e+"?locale="+c.locale),"MagentoShop"===c.platform&&(e="/checkout/cart/"),c.carturl&&"ShopifyShop"!==c.platform&&(e=(e="/"+(e=c.carturl)).replace("//","/")),c.quizid&&(e+=c.setutm),"BigcommerceShop"===c.platform)return void U(c.products);try{"ShopifyShop"!==c.platform?(console_log("embed.js - waitForPopulatedCart:"),console_log(e),O(e)):B()?(console_log("embed.js - Rebuy Cart"),Rebuy.SmartCart.show(),document.querySelector("rebuy-cart__flyout").style.zIndex=9999999999,iFrameEvent({action:"checking_out_false"})):(console_log("embed.js - Cart Redirect:"),console_log(e),window.location.href=e)}catch(c){console_log(c)}}if("retake_quiz"===c.action||"view_question"===c.action||"quiz_callback"===c.action){if(console_log("retake_quiz or view_question or quiz_callback"),console_log(c),0===(a=document.querySelectorAll(".rh-inline")).length)return;for(let e=0;e<a.length;e++){var m,f,s=a[e].dataset.url.split("/").pop();c.quizid===s&&(f=(m=a[e]).querySelector(".rh-inline iframe"))}if(!m||!f)return;(u="true"===m.getAttribute("data-fixed-height"))||(m.style.height="600px",f.style.height="600px"),N(m)}if("close_quiz"===c.action&&(console_log("embed.js - close_quiz"),W(c.quizid)),"add_one"===c.action&&"function"==typeof prqAddOneToCartCallback&&(console_log("embed.js - add_one callback"),prqAddOneToCartCallback(c)),"add_one"===c.action&&"ShopifyShop"===c.platform){if(console_log("embed.js - add_one Shopify"),console_log(c),c.recharge)return console_log("ReCharge product"),console_log(i={id:c.variantId,sellingPlanId:c.recharge.external_plan_id,sellingPlanGroupId:c.recharge.external_plan_group_id,isSubscription:!0}),void window.ReChargeWidget.api.postToCart(i);console_log("Shopify product"),H("/cart/add.js",{quantity:1,id:c.variantId},function(e){P(),"function"==typeof prqAddedOneToCartCallback&&prqAddedOneToCartCallback(e)})}if("add_one"===c.action&&"WoocommerceShop"===c.platform&&(console_log("embed.js - add_one WooCommerce"),z=c.variantId||c.originId,M(w={quantity:1,product_id:z,product_sku:c.sku})),"add_one"===c.action&&"MagentoShop"===c.platform){console_log("embed.js - add_one Magento");var w={quantity:1,product_id:z=c.variantId||c.originId,product_sku:c.sku};const j=new XMLHttpRequest;j.responseType="json",j.open("GET","/productquiz/index/addquizproductstocart/product_id/"+z+"?"+F()),j.onload=()=>{console_log(j.response),"function"==typeof prqAddedOneToCartCallback&&prqAddedOneToCartCallback(w)},j.send()}if("add_all"===c.action&&"function"==typeof prqAddAllToCartCallback&&(console_log("embed.js - add_all"),prqAddAllToCartCallback(c)),"add_all"===c.action&&"ShopifyShop"===c.platform&&(console_log("embed.js - add_all Shopify"),window.addingToCart=!0,y=c.variantId.split("||"),d={},y.forEach(function(e){d[parseInt(e)]=1}),H("/cart/update.js",{updates:d},function(e){window.addingToCart=!1,P(),R(c)})),"add_all"===c.action&&"WoocommerceShop"===c.platform&&(console_log("embed.js - add_all WooCommerce"),window.addingToCart=!0,y=c.variantId.split("||"),function o(t){M({quantity:1,product_id:y[t]}).then(function(e){++t<y.length?o(t):(window.addingToCart=!1,iFrameEvent({action:"added_all"}),R(c))})}(0)),"add_all"===c.action&&"MagentoShop"===c.platform){console_log("embed.js - add_all Magento");var _=c.variantId.replace(/\|\|/g,",");const I=new XMLHttpRequest;I.responseType="json",I.open("GET","/productquiz/index/addallquizproductstocart/product_ids/"+_+"?"+F()),I.onload=()=>{console_log(I.response),iFrameEvent({action:"added_all"}),R(c)},I.send()}if("change_variant"===c.action){console_log("embed.js - change_variant");var y,b=(y=c.variantId.split("||"))[0],v=y[1];if(console_log(b),console_log(v),"ShopifyShop"===c.platform){var q,b=JSON.parse(b),v=JSON.parse(v);if(b.recharge)return console_log("ReCharge product"),console_log(q={id:b.variant_id,sellingPlanId:b.recharge.external_plan_id,sellingPlanGroupId:b.recharge.external_plan_group_id,isSubscription:!0}),void window.ReChargeWidget.api.postToCart(q);var C={};C[v.variant_id]=0,C[b.variant_id]=c.quantity,console_log("/cart/update.js"),console_log(C),H("/cart/update.js",{updates:C},function(e){console_log(e)})}"WoocommerceShop"===c.platform&&M(w={quantity:1,product_id:b})}if("remove_one"===c.action&&"function"==typeof prqRemoveOneFromCartCallback&&(console_log("remove_one callback"),prqRemoveOneFromCartCallback(c)),"remove_one"===c.action&&"ShopifyShop"===c.platform&&(console_log("remove_one Shopify"),l={},void 0!==c.quantity&&c.quantity||(c.quantity=0),l[c.variantId]=c.quantity,console_log("/cart/update.js"),console_log(l),H("/cart/update.js",{updates:l},function(e){console_log(e),P(),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(e)})),"remove_one"===c.action&&"WoocommerceShop"===c.platform){console_log("embed.js - remove_one WooCommerce");var S,x=new XMLHttpRequest,k=(x.open("POST","/?wc-ajax=remove_from_cart"),x.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),{cart_item_key:c.originId}),E=[];for(S in k){var A=encodeURIComponent(S),T=encodeURIComponent(k[S]);E.push(A+"="+T)}E=E.join("&"),x.onload=function(){console_log(x)},x.send(E)}if("remove_one"===c.action&&"MagentoShop"===c.platform){console_log("embed.js - remove_one Magento");var z,w={quantity:1,product_id:z=c.variantId||c.originId,product_sku:c.sku};const L=new XMLHttpRequest;L.responseType="json",L.open("GET","/productquiz/index/removequizproductstocart/product_id/"+z+"?"+F()),L.onload=()=>{console_log(L.response),"function"==typeof prqRemovedOneFromCartCallback&&prqRemovedOneFromCartCallback(w)},L.send()}}},!1)},p=()=>{for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",o="",t=0;t<6;t++)o+=e.charAt(Math.floor(Math.random()*e.length));return o};function F(){return"cachebuster="+p()}const c=e=>"[object Object]"===Object.prototype.toString.call(e),h=(e,o=!1,t=!1,n=!1,r=!1)=>{o=a(o,t,n,r),t=new URLSearchParams(o).toString();return e+(""===t?"":"?"+t)},s=e=>{var o=e.indexOf("#quiz-");return-1!==o?e.substring(0,o)+e.substring(o+6):e},g=e=>{var o,t;return console_log("shopifyCurrency"),console_log(e),"undefined"!=typeof Shopify&&Shopify&&Shopify.currency?({active:t,rate:o}=Shopify.currency,t=`currency_code=${t}&currency_rate=`+o,e.includes("?")?e+"&"+t:e+"?"+t):e},a=function(e,o,t,n){console_log("embed.js - quizParameters");var r,a,i,d=new URLSearchParams(window.location.search),l={};e&&(o=l.popup="true"),t&&(l.popupWidth=t),n&&(l.popupHeight=n),o||(l.autoscroll="false"),c(window.prq_vars)&&(l=Object.assign(l,window.prq_vars)),console_log("URLSearchParams");for(r of d.entries())r[0].startsWith("prq_")&&(a=r[0].replace("prq_",""),i=r[1],console_log(r),l[a]=i);return l},i=function(e){return console_log("embed.js - isAutoScroll"),console_log(e),!e||"false"!==e.toLowerCase()},B=()=>null!==document.querySelector("body.smart-cart--enabled")&&"undefined"!=typeof Rebuy&&void 0!==Rebuy?.SmartCart,d=function(){document.querySelectorAll(".rh-widget iframe")&&document.querySelectorAll(".rh-widget iframe").forEach(function(e){e.remove()}),document.querySelectorAll(".rh-widget").forEach(function(e){e.style.backgroundColor="#aaa";var o=document.createElement("div"),t=(o.style.textAlign="center",o.style.display="flex",o.style.flexDirection="column",o.style.justifyContent="center",o.style.height="calc(100% - 60px)",o.style.width="calc(100% - 60px)",o.style.padding="30px",o.style.color="#fff",document.createElement("h2")),t=(t.textContent="Quiz Temporarily Unavailable",o.appendChild(t),document.createElement("p"));t.textContent="We're currently improving your experience! Please check back shortly after our brief maintenance period.",o.appendChild(t),e.appendChild(o)})},m=function(){document.querySelectorAll(".rh-widget iframe")&&document.querySelectorAll(".rh-widget iframe").forEach(function(e){e.remove()}),document.querySelectorAll(".rh-widget").forEach(function(e){var o=p(),t=e.dataset.url,t=s(t),t=h(t,!1,i(e.dataset.autoscroll)),t=g(t),n=(console_log("RenderInlineEmbed - shopifyCurrency"),console_log(t),document.createElement("iframe"));n.name="Product Recommendation Quiz",n.src=t,n.id=o,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(o).onload=function(){document.getElementById(o).contentWindow.focus()}})},l=function(){document.querySelectorAll("a").forEach(function(e){var o;e&&e.href&&"string"==typeof e.href&&e.href.match(/\#quiz\-/)&&(o=e.href.split("#quiz-")[1],e.addEventListener("click",function(e){e.preventDefault(),document.getElementById(o)&&document.getElementById(o).remove(),b(o,!1,"true")}))})},f=()=>{var e,o,t=window["rhCurrentScript"],n=document["URL"];for({regex:e,domain:o}of[{regex:/admin\-staging\.revenuehunt\.com/,domain:"https://admin-staging.revenuehunt.com"},{regex:/admin\-dev\.revenuehunt\.com/,domain:"https://admin-dev.revenuehunt.com"},{regex:/localhost|productrecommendationquizforwoocommerce|productrecommendationquiz.local/,domain:"http://localhost:9528"}])if(e.test(t)||e.test(n))return o;return"https://admin.revenuehunt.com"},u=function(){var e=f(),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;        }",o=document.createElement("style");o.innerText=e.replace(/[\r\n]+/gm,""),document.head.appendChild(o)},w=(window.rhCloseGreeting=function(){console_log("rhCloseGreeting"),document.getElementById("rh-greeting")&&(document.getElementById("rh-greeting").outerHTML="")},window.rhCloseNotification=function(){console_log("rhCloseNotification"),document.getElementById("rh-dot")&&(document.getElementById("rh-dot").outerHTML="")},window.rhClickChat=function(e,o,t){console_log("rhClickChat"),console_log(e),window.rhCloseGreeting(),window.rhCloseNotification(),window.openQuizPopup(e,o,t)},function(e,o,t,n,r,a){var i=document.createElement("div"),d=document.createElement("div"),l=document.createElement("div");d.classList.add("rh-chat"),d.style.backgroundColor=o,d.addEventListener("click",function(){window.rhClickChat(e,r,a)}),l.classList.add("rh-icon"),d.appendChild(l),t&&((o=document.createElement("div")).classList.add("rh-dot"),o.setAttribute("id","rh-dot"),d.appendChild(o)),i.appendChild(d),n&&(l=document.createElement("div"),t=document.createElement("span"),l.classList.add("rh-greeting"),l.setAttribute("id","rh-greeting"),l.textContent=n,t.classList.add("rh-close"),t.addEventListener("click",window.rhCloseGreeting),l.appendChild(t),i.appendChild(l)),document.body.appendChild(i)}),_=function(){var o=document.getElementById("rh-chat");if(null!==o){console_log("--------------------------------"),console_log("RenderChatEmbed");var t=o.getAttribute("data-quiz-id"),t=s(t),n=o.getAttribute("data-chat-color"),r=o.getAttribute("data-chat-dot")&&"true"===o.getAttribute("data-chat-dot").toLocaleLowerCase(),a=o.getAttribute("data-chat-hide")&&"true"===o.getAttribute("data-chat-hide").toLocaleLowerCase(),i=o.getAttribute("data-popup-width"),d=o.getAttribute("data-popup-height");let e=!1;o.getAttribute("data-chat-greeting")&&(e=o.getAttribute("data-chat-greeting"));o=prqGetCookie("prq-responseId-"+t);console_log(o),a&&o||(u(),w(t,n,r,e,i,d))}},y=function(){console_log("embed.js - GetAutomaticPopupData");var e,o,t,n,r,a,i=prqGetCookie("data-timeout"),d=Date.now(),l=!1,c=!1;i&&(console_log("data-timeout cookie set:"),c=i.split("||")[0],l=parseInt(i.split("||")[1])),null!==document.getElementById("auto-popup")&&(e=document.getElementById("auto-popup"),o=parseFloat(e.getAttribute("data-timeout")),t=e.getAttribute("data-exit-intent")&&"true"===e.getAttribute("data-exit-intent").toLocaleLowerCase(),n=e.getAttribute("data-aggressive")&&"true"===e.getAttribute("data-aggressive").toLocaleLowerCase(),window.popupWidth=e.getAttribute("data-popup-width"),window.popupHeight=e.getAttribute("data-popup-height"),c=e.getAttribute("data-quiz-id"),r=prqGetCookie("auto-popup-"+(c=s(c))),n&&(r=prqGetCookie("prq-responseId-"+c)),l=1e3*(o=o&&o<=0?.5:o)+d),i||prqSetCookie("data-timeout",c+"||"+l,7),c&&t&&!r&&document.addEventListener("mouseout",e=>{e.toElement||e.relatedTarget||r||window.popupAlreadyShown||(window.popupAlreadyShown=c,b(c,!1,"true",window.popupWidth,window.popupHeight))}),console_log("timeTimeout:"),console_log((l-d)/1e3),console_log(c),c&&!r&&0<l-d&&(console_log("setInterval TIMEOUT"),a=setInterval(function(){d=Date.now(),l-d<0&&!window.popupAlreadyShown&&(console_log("Show Quiz after timeout: "+c),window.popupAlreadyShown=c,b(c,!1,"true",window.popupWidth,window.popupHeight),clearInterval(a))},1e3))},b=function(e,o,t,n,r){var a,i,d,l,c,s,u;t&&window.prqPopup?console_log("window.isPopup: "+t):(t&&(window.prqPopup=e,document.querySelector("body").style.overflow="hidden",prqSetCookie("auto-popup-"+e,"true",7)),a=f(),(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="&times;",d.style.cssText="position: fixed; color: #888888; z-index: 9999 !important; font-size: 36px; line-height: 36px; text-align: center; font-weight: normal; right: 20px; top: 20px; cursor: pointer; width: 38px; height: 38px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; background-color: rgba(255,255,255,0.5)",d.onclick=function(e){console_log("click X close quiz");var o="[id='"+window.prqPopup+"'] iframe";document.querySelector(o)?iFrameEvent({action:"close_quiz"}):console.error("iFrame not found for ID: "+window.prqPopup),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,c=h(s,t,!1,n,r),void 0!==o&&!1!==o&&(l=!0,c=a+"/public/quiz/"+e+"/results/"+o),c=g(c),console_log("showQuiz - shopifyCurrency"),console_log(c),s=document.querySelectorAll(".rh-inline"),u=!1,l&&0<s.length&&(window.quizId=e,s.forEach(function(e){var o,t;e.dataset.url.split("/").pop()===window.quizId&&(u=!0,document.querySelector("body").style.overflow=null,e.querySelectorAll("iframe").forEach(function(e){e.remove()}),o=p(),(t=document.createElement("iframe")).name="Product Recommendation Quiz",t.src=c,t.id=o,t.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;",t.setAttribute("data-hj-allow-iframe","true"),e.appendChild(t),document.getElementById(o).onload=function(){document.getElementById(o).contentWindow.focus()})}),u)||((t=document.createElement("div")).id=e,t.className="rh-widget",t.dataset.url=c,t.style.cssText="display: flex; background-color: rgba(254,254,254,0.4); margin: 0; padding: 0; height: 100%;",t.style["flex-grow"]=1,window.onclick=function(e){e.target===i&&(i.style.display="none")},i.appendChild(t),t.appendChild(d),document.getElementsByTagName("body")[0].appendChild(i),m()))},v=e=>{var o=document.createElement("link");o.rel="dns-prefetch",o.href=e,document.head.appendChild(o)},q=function(){var e=window.location.hash;if(console_log("checkHash"),console_log("hash"),e.match(/\#quiz\-/)){const n=e.split("#quiz-")[1];var o=document.querySelector(".rh-widget span"),t=()=>b(n,!1,"true");o?(o.click(),setTimeout(t,200)):t()}if(e.match(/\#results\-/)){const r=e.split("#results-")[1].split("-");console_log("#results"),console_log(r),b(r[0],r[1],!1),document.querySelectorAll(".rh-inline").forEach(e=>{var o=e.dataset.url.split("/").pop();r[0]===o&&(document.querySelector("body").style.overflow=null,e.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"}))})}},W=e=>{document.querySelector(`[id='${e}'] span`).click()},N=e=>{if(!e||!e.dataset||"false"===e.dataset.autoscroll)return!1;var e=e.getBoundingClientRect(),o=e.y+window.pageYOffset;e&&e.y<0&&(console_log("scroll_to: "+o),window.scrollTo({top:o,left:0,behavior:"smooth"}))},C=()=>{window.addEventListener("hashchange",()=>{console_log("embed.js - detectHashChange"),q()})},S=()=>{/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&window.addEventListener("pageshow",function(){document.querySelectorAll(".rh-widget iframe").forEach(function(e){console_log("embed.js - is Safari, reload iframe"),e.src=e.src})})},x=e=>{var o=document.createElement("style");o.textContent=e,document.head.append(o)},k=(window.openQuizPopup=function(e,o,t){b(e,!1,"true",o,t)},`
  .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;}
  .mtop-20 { margin-top: 20px; }
  .mbot-20 { margin-bottom: 20px; }
  .rh-quiz-list { display: none; }
  .rh-info-box {
      background-color: #D8F0FE;
      color: #2c81b2;
      border: 1px dotted #2c81b2;
      padding: 15px;
      border-radius: 8px;
      -webkit-border-radius: 8px;
      -moz-border-radius: 8px;
  }
  .rh-inline { width: 100%; display: flex; }
  .rh-inline iframe { width: 100%; }
  .rh-fullwidth { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); }
`);function e(){console_log("embed.js # prqApp # 2024-01-24 # v001"),console_log("rhScheduledMaintenance: "+window.rhScheduledMaintenance),x(k),["https://api.revenuehunt.com","https://space.revenuehunt.com"].forEach(v)}function E(){setTimeout(function(){if(e(),y(),m(),l(),_(),S(),q(),C(),"undefined"!=typeof Shopify&&Shopify&&Shopify.designMode){var o=document.querySelectorAll(".rh-quiz-list");for(let e=0;e<o.length;e++)o[e].style.display="block"}r()},50)}void 0===window.prqAppLoaded&&(window.rhScheduledMaintenance?setTimeout(function(){e(),d(),S()},50):E(),window.prqAppLoaded=!0,"function"==typeof prqAppLoadedCallback)&&prqAppLoadedCallback()}catch(e){console.error(e),o={events:[{name:"Embed.js JavaScript Error",properties:{message:(o=e).toString(),location:window.location.href,stack:o.stack}}]},fetch("https://api.revenuehunt.com/ahoy/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).catch(e=>{console.error("Error sending event data to Ahoy:",e)})}var o}();