class ConversionsHandler{siteId=0;heatmapSentTransaction=!1;heatmapThankYouHasSentTrx=!1;heatmapExecuteGTMDataLayerState=!1;sendLambdaDataLayerObject=!1;heatmapUpSellCount=0;tempHeatmapSiteId=0;tempHeatmapTrackerURL;heatmapNewVisitor=0;heatmapDoNotSend=!1;timeSincePageReady=0;HeatMapAuditKey="";clientVisitId=null;apiPaths={};dateObj=new Date;dataLayerObject=[];websitesList=[2055,337];constructor(e=0){this.siteId=e}init(){this.apiPaths={origin:window.location.origin,href:window.location.href,api:"https://dashboard.heatmap.com/",kinesis:"https://kns.heatmap.com/data",bigcommerce:"https://checkout-sdk.bigcommerce.com/v1/loader.js",recording:"wss://service.heatmap.com/ws/record/events?env=live",lambda:"https://dlayer.heatmap.com/data.layer"},this.apiPaths.trackerURL=`${this.apiPaths.api}heatmap.php`,this.HeatMapAuditKey=this.#a("_heat_audit"),this.clientVisitId=localStorage.getItem("_heatVid"),this.siteId=this.#b(),this.tempHeatmapSiteId=this.siteId,setTimeout(()=>{this.#c(),this.#d()},500)}#e(e){try{var t=document.createElement("script");t.type="text/javascript",t.src=e,t.async=!1,t.defer=!0,document.head.appendChild(t)}catch(r){}}#d(){try{let i=JSON.parse(localStorage.getItem("_heatmap_unsent"));Boolean(i)&&(navigator.sendBeacon(this.apiPaths.kinesis,JSON.stringify(i)),localStorage.removeItem("_heatmap_unsent"));let a=JSON.parse(localStorage.getItem("heat_last_record_before_unload_event"));if(Boolean(a)){this.#f(a);let n={Data:a.recording_record,PartitionKey:"partition"+10*Math.round((Math.floor(100*Math.random())+1)/10),StreamName:a.streamName};navigator.sendBeacon(`${a.streamGateway}`,JSON.stringify(n)),localStorage.removeItem("heat_last_record_before_unload_event")}}catch(s){}}#c(){if("undefined"!=typeof dataLayer)try{if(Boolean(this.sendLambdaDataLayerObject))return;let o=new Set(["checkoutSuccessful","transactionSuccess","purchase","complete","convert_purchase_usd","dl_purchase","success","checkout","transaction","vp_purchase","Checkout_Step_Completed","gtm-purchase","conversion"]);var c=dataLayer.filter(e=>{let t=e.event||e.vrio_event||"event"===e[0]&&e[1];return t&&o.has(t)});if(void 0===c||!c.length)return;c[0]._idv=localStorage.getItem("_heatVid"),c[0].created_at=this.dateObj.toISOString(),c[0].user_agent=navigator.userAgent,c[0]._id=this.#g(),c[0].device_type=this.#h(),c[0].parent_idv=localStorage.getItem("_heatVid");let d={method:"POST",body:JSON.stringify({idsite:this.siteId,layer:c,referrer:this.apiPaths.origin,href:this.#i(this.apiPaths.href),_idv:localStorage.getItem("_heatVid")})};("undefined"!=typeof checkoutKitLoader||(Boolean(/checkout/ig.test(window.location.href))||Boolean(/checkouts/ig.test(window.location.href)))&&this.websitesList.includes(this.siteId))&&this.heatmapProcessBCConversionData(c),window.fetch(this.apiPaths.lambda,d),this.sendLambdaDataLayerObject=!0}catch(u){}}#a(h){let p=localStorage.getItem(h);if(!Boolean(p))return null;let l=JSON.parse(p),m=this.dateObj.getTime();return m>l.expiry?(localStorage.removeItem(h),null):l.value}#b(){if("undefined"!=typeof preHeatmapSiteId)return this.siteId=preHeatmapSiteId,this.siteId;var y=document.body.innerHTML.replace(/&/g,"&"),v=document.head.innerHTML.replace(/&/g,"&"),f=/conversions\.js\?(?:.*&)?siteId=(\d+)|conversions-dev\.js\?(?:.*&)?siteId=(\d+)/g.exec(y+v);return Boolean(this.siteId)?this.siteId:f&&(f[1]||f[2])?parseInt(Boolean(f[1])?f[1]:f[2]):Boolean(this.siteId)||"undefined"==typeof preHeatmapSiteId?this.siteId:preHeatmapSiteId}#g(){localStorage.setItem("_user_agent",navigator.userAgent);var g=localStorage.getItem("_mr_vid");return Boolean(g)?(this.heatmapDoNotSend=!0,g):(document.cookie.split(";").forEach(e=>{var[t,r]=e.split("=");if(t.indexOf(`_pk_id.${this.siteId}`)>-1)return r.trim().split(".")[0]}),this.heatmapDoNotSend=!1,g)}#h(){return window.innerWidth<=480?3:window.innerWidth>=480&&window.innerWidth<=850?2:1}#f(I){try{if(Boolean(I)){let S=new WebSocket(this.apiPaths.recording);S.onopen=()=>{Boolean(S.readyState)&&S.readyState===WebSocket.OPEN&&(S.send(JSON.stringify(I.recording_record),"recordings"),localStorage.removeItem("heat_last_record_before_unload_event"))}}}catch(k){}}#j(){if("undefined"!=typeof preHeatmapSiteId)return this.siteId=preHeatmapSiteId,this.siteId;var T=document.body.innerHTML.replace(/&/g,"&"),b=document.head.innerHTML.replace(/&/g,"&"),C=/conversions\.js\?mode=leads&siteId=\d+/,q=C.exec(T),x=C.exec(b);return!!(Boolean(q)||Boolean(x))&&navigator.sendBeacon(this.apiPaths.trackerURL,JSON.stringify({idsite:this.siteId,url:this.apiPaths.origin,href:this.#i(this.apiPaths.href)}))}#k(P){if(Boolean(this.HeatMapAuditKey)){var L=JSON.parse(localStorage.getItem("_heat_audit_trans"))||[];L.push({_idorder:P,_heat_audit_key:this.HeatMapAuditKey}),localStorage.setItem("_heat_audit_trans",JSON.stringify(L))}}#l(H,O=null){if(!Boolean(localStorage.getItem(H)))return null;let _=localStorage.getItem(H);return null==O?_:Boolean((_=JSON.parse(_))[O])?_[O]:null}#m(U,B,Y="allHeatmapsIds"){let D=heatCleanUrl(U),w={},j=this.#l(`${Y}`);return Boolean(j)&&(w=JSON.parse(j)),w[D]=B,localStorage.setItem(`${Y}`,JSON.stringify(w))}#n(R,A,E,V="conversion"){let W=this.#l("_heatmapConfigs","_userJourney");try{let G=1;return W&&(G=Object.keys(W).length+1),W||(W={}),W[G]={event:V,pageUrl:E,idVisit:R,timeStamp:new Date().toISOString()},W[G].is_purchaser=!0,W[G].purchaser_value=A,localStorage.setItem("wPxIsGoalBuyer",1),localStorage.removeItem("heatWPx"),this.#m("_userJourney",W,"_heatmapConfigs"),navigator.sendBeacon(this.apiPaths.trackerURL,JSON.stringify({siteid:this.siteId,page_url:W[G].pageUrl,idVisit:R,userJourney:W}))}catch(M){}}#o(){let N=`${window.location.origin}${window.location.pathname}`;if(localStorage.getItem("wPxIsGoalBuyer"))return!0;if(localStorage.getItem("heatWPx")){let F=JSON.parse(localStorage.getItem("heatWPx"));if(Boolean(F.idsite))return this.siteId=F.idsite,F.wpx=JSON.parse(F.wpx),N=`${F.wpx.location.origin}${F.wpx.location.pathname}`,localStorage.setItem("heatIsGoalBuyer",1),localStorage.setItem("heatIsGoalBuyerCurrency",F.currency),localStorage.setItem("heatIsGoalBuyerValue",F.revenue),localStorage.setItem("_heatVid",F._idv),this.#n(F._idv,F.revenue,N,"conversion")}let J=localStorage.getItem("heatIsGoalBuyerValue"),K=localStorage.getItem("_heatVid");if(!K)return!0;["thank-you","post-purchase","thank_you"].forEach(e=>{if(RegExp(e,"ig").test(N))return this.#n(K,J,N,"conversion")})}#p(Q,z,X){let Z=window.innerWidth>850,ee=/Edge\/\d./i.test(navigator.userAgent),et=/Edg\/\d./i.test(navigator.userAgent),er=Object.entries(X).map(([e,t])=>"items"===e?`${encodeURIComponent(e)}=${encodeURIComponent(JSON.stringify(t))}`:`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");if(this.heatmapThankYouHasSentTrx=!0,Z&&ee||Z&&et)window.fetch(`${Q}&${er}`);else try{delete X.items,X.url=this.#i(window.location.href),X.date=this.dateObj.toISOString(),X.hasOwnProperty("type")||(X.type="heatmapConversion");let ei=new URLSearchParams(X).toString();navigator.sendBeacon(`${Q}&${ei}`,z)}catch(ea){window.fetch(`${Q}&${er}`)}this.tempHeatmapTrackerURL=Q,localStorage.removeItem("order"),localStorage.removeItem("vivo_transaction"),localStorage.removeItem("mage-cache-storage"),localStorage.removeItem("cheeseOrderDetail"),localStorage.removeItem("trackedCompleteOrderSourceId"),localStorage.setItem("tempHeatmapTrackerURL",Q),console.log(`%c ► Heatmap.com -: Transaction data successfully sent.`,"background-color: #43a047; color: #fff; padding: 5px;")}#i(en){let es=new URL(en);return es.searchParams.delete("orderDetails"),es.toString()}#q(eo,ec,ed,eu){if(!0==this.heatmapThankYouHasSentTrx)return!0;ec.referrer=this.#i(this.apiPaths.href),ec._idv=localStorage.getItem("_heatVid"),ec._id=this.#g(),ec.idsite=this.siteId,ec.quicktransaction=1,ec.agent=navigator.userAgent,ec.audit_key=this.HeatMapAuditKey,ec.created_at=this.dateObj.toISOString(),ec.device_type=this.#h(),ec.parent_idv=localStorage.getItem("_heatVid");let eh=`${this.clientVisitId}_${ec.revenue}`,ep=localStorage.getItem("lastTransaction");if(Boolean(ep)&&ep==eh)return this.heatmapThankYouHasSentTrx=!0,!0;"undefined"!=typeof Shopify&&void 0!==Shopify.country&&(ec.country=Shopify.country);try{ec.items_count=ec.items.length}catch(el){}let em=JSON.stringify(ec),ey=new Blob([em],{type:"application/x-www-form-urlencoded; charset=UTF-8"});this.#p(eo,ey,ec),this.#k(eu),this.tempHeatmapSiteId=ed,localStorage.setItem("heatIsGoalBuyer",1),localStorage.setItem("heatIsGoalBuyerCurrency",ec.currency),localStorage.setItem("heatIsGoalBuyerValue",ec.revenue),localStorage.setItem("lastTransaction",eh),localStorage.setItem("tempHeatmapSiteId",this.tempHeatmapSiteId);let ev=`${window.location.origin}${window.location.pathname}`;return this.#n(ec._idv,ec.revenue,ev)}#r(){var ef=0,eg=document.querySelector('[data-test="order-confirmation-order-number-text"]');if(eg){var eI=eg.querySelector("strong");null!=eI&&(ef=eI.textContent)}if(0==ef){var eS,e$=document.querySelector(".orderConfirmation-section");if(e$){ef=e$.innerHTML.match(/Order (\d+)/)[1]??0}}if(0==ef)for(var ek=document.getElementsByTagName("script"),e8=0;e8{e.forEach(function(e){var t={sku:e.sku,price:e.salePrice,quantity:e.quantity,title:e.name.replace(/['"]+/g,"")};eC.productsList.push(t)})};return eq(eb.lineItems.physicalItems),eq(eb.lineItems.digitalItems),eq(eb.lineItems.giftCertificates),this.heatmapTransactionId=eb.orderId,this.heatmapRawConversionTransaction(eC)}#t(){if(Boolean(this.heatmapThankYouHasSentTrx))return;var e9=document.querySelector(".order-summary-toggle__text--show");if(!Boolean(e9)||Boolean(Shopify.checkout)||Boolean(Shopify.order))return!0;e9.click();let ex=e=>{let t=document.querySelector(`[${e}]`);if(Boolean(t)){let r=t.innerText.match(/[0-9.]+/g),i=r?r.join(""):"";return i}if(e.includes("currency")||e.includes("order")){let a=document.getElementsByClassName(e),n=!!e.includes("currency");if(a.length>0){var s=a[0].innerText;return s=s.replace(/order/gi,"").trim(),n&&!s.length?"INR":s}}return 0},eP={discount:ex("data-checkout-discount-amount-target"),shipment:ex("data-checkout-total-shipping-target"),revenue:ex("data-checkout-payment-due-target"),currency:void 0!==Shopify.currency&&Boolean(Shopify.currency.active)?Shopify.currency.active:"INR",items:(()=>{let e=[],t=document.querySelector("tbody[data-order-summary-section]");return Boolean(t)&&t.querySelectorAll("tr[data-product-id]").forEach(t=>{let r=t.querySelector("span.product__description__name"),i=r?r.innerText.trim():"",a=t.querySelector("span.order-summary__price"),n=t.querySelector("span.product-thumbnail__quantity"),s=n?n.innerText:1,o=a?a.innerText.trim():"",c=o.replace(/[^\d.]/g,"");i.length&&e.push({title:i,price:c,quantity:s,sku:""})}),e})(),idorder:ex("os-order-number"),request_source:"heatmapCheckoutOrder"};return 0==eP.revenue||this.#q(`${this.apiPaths.trackerURL}?type=processToddlegram&siteId=${this.siteId}`,eP,this.siteId,eP.idorder)}#u(){if(Boolean(this.heatmapThankYouHasSentTrx))return;let eL=Boolean(localStorage.getItem("mage-cache-storage")),eH=/checkout/gi.test(window.location.href);if(Boolean(eL)&&Boolean(eH)){let eO={},e_=JSON.parse(localStorage.getItem("mage-cache-storage"))||JSON.parse(localStorage.getItem("vivo_transaction")),eU=e=>{Array.from(e.getElementsByTagName("script")).find(e=>e.src.includes("/api/v2/referreroffer/"))?.src.split("?")[1]?.split("&").forEach(e=>{let[t,r]=e.split("=");eO[t]=r})},eB=()=>{if(eH&&(e_||localStorage.getItem("vivo_transaction"))&&(e_||(e_=JSON.parse(localStorage.getItem("vivo_transaction")),localStorage.setItem("vivo_transaction",JSON.stringify(e_))),eU(document.head),Boolean(e_.cart)&&(eO.order_number||document.querySelector("body .orderDetailsRow")))){this.heatmapThankYouHasSentTrx=!1;let e=e_.cart.line_items.map(e=>({price:e.unit_price,quantity:e.quantity,title:e.name.replace(/['"]+/g,""),sku:e.sku_code})),t={idorder:eO.order_number,revenue:eO.order_total,items:e,discount:e_.cart.coupon_discount??0,shipment:e_.cart.shipping_cost??0,currency:eO.order_currency||"USD",request_source:"vivoTransaction"};return this.#q(`${this.apiPaths.trackerURL}?type=vivoTransaction&siteId=${this.siteId}`,t,this.siteId,t.idorder)}};setInterval(()=>{eB()},5e3)}}#v(){if("undefined"==typeof dataLayer||Boolean(this.heatmapThankYouHasSentTrx))return;let eY=dataLayer.find(e=>"fireEvent"===e.event),eD=dataLayer.find(e=>"fireConversion"===e.event),ew={},ej=[];if(eY){let eR=eY.ecommerce;ew={ecommerce:eR},ej=eR.purchase.products.map(function(e){return{price:e.price,quantity:e.quantity,title:e.name.replace(/['"]+/g,""),sku:e.id}})}if(eD){let{conversionValue:eA,conversionCurrency:eE,conversionOrderID:eV}=eD;ew={...ew,conversionValue:eA,conversionCurrency:eE,conversionOrderID:eV}}if(0===Object.keys(ew).length)return!0;let eW={idorder:ew.conversionOrderID,revenue:ew.conversionValue,items:ej,currency:void 0!==ew.conversionCurrency?ew.conversionCurrency:"USD",shipping:ew.ecommerce.purchase.actionField.shipping,request_source:"heatmapWikinggruppenSnippet"};return this.#q(`${this.apiPaths.trackerURL}?type=Wikinggruppen&siteId=${this.siteId}`,eW,this.siteId,eW.idorder)}#w(){if(!Boolean(this.heatmapThankYouHasSentTrx)){var e0=localStorage.getItem("cheeseOrderDetail"),eG=localStorage.getItem("trackedCompleteOrderSourceId");if(Boolean(e0)&&Boolean(eG)&&"null"!==eG){if(void 0===(e0=JSON.parse(e0))[0])return!0;let eM=[];eM=(e0=e0[0][2]).items.map(function(e){return{price:e.price,quantity:e.quantity,title:e.item_name.replace(/['"]+/g,""),sku:e.sku}});let eN={idorder:e0.cart_id,revenue:e0.value,items:eM,currency:e0.currency,request_source:"cheeseAndWineTransaction"};return this.#q(`${this.apiPaths.trackerURL}?type=cheeseAndWineTransaction&siteId=${this.siteId}`,eN,this.siteId,eN.idorder)}}}#x(){if(Boolean(this.heatmapThankYouHasSentTrx))return;var eF=new URLSearchParams(window.location.search),e3=eF.get("txid"),eJ=eF.get("ot");if(!Boolean(e3)||!Boolean(eJ))return!0;let eK=[{price:eJ,quantity:1,product:{title:"Weight Loss Subscription"},sku:Math.floor(this.dateObj.getTime()/1e3)}],e2={currency:"USD",idorder:Number(e3).toString(),revenue:eJ,created_at:this.dateObj.toISOString(),items:eK};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${e2.idorder}`,e2,this.siteId,e2.idorder)}#y(){try{if(!0==this.heatmapThankYouHasSentTrx)return!0;"undefined"!=typeof dataLayer&&"undefined"==typeof gtmProcessCheckout&&this.#e(`${this.apiPaths.api}conversions.php?siteId=${this.siteId}&dataLayer=populate`)}catch(e6){}}#z(){if(Boolean(this.heatmapThankYouHasSentTrx)||1906!==this.siteId)return;let e1=e=>{let t=Array.from(e.getElementsByTagName("span")).find(e=>e.textContent.trim().startsWith("$"));if(t){let r=parseFloat(t.textContent.trim().substring(1));return isNaN(r)?0:r}return 0};try{let e7=(()=>{let e=document.querySelectorAll("div");for(let t of e){let r=Array.from(t.getElementsByTagName("div")).find(e=>e.textContent.includes("Total:"));if(r){let i=r.nextElementSibling,a=i?e1(i):0;if(Boolean(a))return a}}return 0})();if(Boolean(e7)){let e5=[{price:e7,quantity:1,product:{title:"Weight Loss Subscription"},sku:Math.floor(this.dateObj.getTime()/1e3)}],e4={currency:"USD",idorder:this.dateObj.getTime().toString(),revenue:e7,items:e5};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${e4.idorder}`,e4,this.siteId,e4.idorder)}}catch(eQ){}}#A(){if(Boolean(this.heatmapThankYouHasSentTrx))return;let ez=document.querySelector('.cart__submit-controls input[name="checkout"]');var eX=localStorage.getItem("modifyHealthOrderDetail");Boolean(ez)&&Boolean(eX)&&(eX=JSON.parse(eX)[0],ez.addEventListener("click",()=>{let e=[];eX.productPrice.forEach((t,r)=>{e.push({price:t,quantity:eX.productQuantity[r],product:{title:eX.productName[r]},sku:eX.productSKU[r]})});let t={currency:eX.currency,revenue:eX.totalValue,idorder:this.dateObj.getTime().toString(),items:e};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${t.idorder}`,t,this.siteId,t.idorder)}))}#B(){!Boolean(this.heatmapThankYouHasSentTrx)&&1947===this.siteId&&"undefined"!=typeof jQuery&&$('div[data-page-element="Button/V1"] a[href="#submit-checkout-form"]').on("click",()=>{try{var e=document.querySelector(".elOrderSummaryTotalPrice");if(e){var t=e.querySelectorAll("font");if(2===t.length){var r=t[1].textContent.trim(),i=r.replace("$",""),a=[];if(a.push({price:i,quantity:1,product:{title:"In Shape Now"}}),r){let n={currency:"USD",revenue:i,idorder:this.dateObj.getTime().toString(),items:a};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${n.idorder}`,n,this.siteId,n.idorder)}}}}catch(s){}})}#C(){if(Boolean(this.heatmapThankYouHasSentTrx))return;let eZ=e=>!!document.querySelector(e)&&document.querySelector(e);if(eZ(".order-number")){var te=[];let tt=e=>{if(!e||!eZ(e))return 0;e=eZ(e).textContent.trim();let t=e.match(/\d+(\.\d+)?/);return t?parseFloat(t[0]):0},tr=document.querySelectorAll(".product-list-items");tr.length&&tr.forEach(e=>{let t=e.querySelectorAll(".product-line-item");t.forEach(e=>{let t=e.querySelector("[data-ga-product-info]");if(t)try{let r=t.getAttribute("data-ga-product-info");te.push(JSON.parse(r).items[0])}catch(i){}})});let ti={items:te,idorder:tt(".order-number"),tax:tt(".tax-total"),revenue:tt(".grand-total-sum"),shipment:tt(".shipping-total-cost"),currency:void 0!==te[0]?te[0].currency:"USD"};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${ti.idorder}`,ti,this.siteId,ti.idorder)}}#D(){if(!0==this.heatmapThankYouHasSentTrx)return!0;let ta=window.location.search;if(!ta.length||!window.location.search.includes("?orderDetails="))return!0;let tn=new URLSearchParams(ta),ts=JSON.parse(tn.get("orderDetails"));if(!ts)return!0;let to={items:ts.bookings[0].tickets.map(e=>({sku:e.reference,quantity:1,title:e.tier.name,price:e.total})),idorder:ts.id,revenue:ts.total,currency:ts.currency};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${to.idorder}`,to,this.siteId,to.idorder)}heatmapCustomGTMSnippet(e,t,r,i){return this.#q(e,t,r,i)}heatmapCustomConversion(e="heatmapConversion"){if(!0==this.heatmapThankYouHasSentTrx)return!0;if(void 0!==window.Shopify){let t=void 0!==window.Shopify.order?window.Shopify.order:window.Shopify.checkout;if(void 0!==t){if(!0==this.heatmapThankYouHasSentTrx)return!0;let r=[];r=void 0!==window.Shopify.order?t.lineItems.map(function(e){return{price:e.price,quantity:e.quantity,product:{title:e.title},sku:e.variant.sku}}):t.line_items.map(function(e){return{price:e.price,quantity:e.quantity,product:{title:e.title},sku:e.sku}});let i=void 0!==t.order_number?t.order_number:void 0!==t.order_id?t.order_id:t.id,a=0;void 0!==t.discounts&&null!==t.discounts?void 0!==t.discounts[0].amount&&(a=parseFloat(t.discounts[0].amount)):void 0!==t.discount&&null!==t.discount&&void 0!==t.discount.amount?a=t.discount.amount:void 0!==t.discount&&(a=t.discount);let n=0,s=this.dateObj.toISOString();Boolean(t.shipping)&&(n=t.shipping),Boolean(t.shipping_rate)&&(n=Boolean(t.shipping_rate.price)?t.shipping_rate.price:t.shipping_rate),void 0!==t.created_at&&(s=t.created_at);let o={currency:void 0!==t.currency?t.currency:"USD",idorder:Number(i).toString(),revenue:void 0!==t.totalPrice?t.totalPrice:t.total_price,created_at:s,shipping:n,discount:a,items:r};if(!o.idorder.length)return!0;this.#q(`${this.apiPaths.trackerURL}?type=${e}&siteId=${this.siteId}`,o,this.siteId,o.idorder)}}if("undefined"!=typeof betterCartData)return this.heatmapBetterCartSnippet(betterCartData);if(Boolean(localStorage.getItem("cleanco-cart"))||Boolean(localStorage.getItem("cleanco-cart"))){var c="";c=Boolean(localStorage.getItem("nutrisense:purchase"))?JSON.parse(localStorage.getItem("nutrisense:purchase")):JSON.parse(localStorage.getItem("cleanco-cart"));let d=[],u=0;if(void 0!==c.products){let h=c.products;for(var p=0;pa.indexOf(e.id)});if(0!==n.length){return n.map(function(e){return{price:e.price,quantity:e.quantity,product:{title:e.title.replace(/['"]+/g,"")},sku:e.variant.sku}}).reduce(function(e,t){return e+Number(t.price)},0),Number(e).toString(),this.heatmapThankYouHasSentTrx=!1,this.heatmapCustomConversion("heatmapProcessCheckoutAmended")}}#E(tc){var td=[],tu=[];return tc.map(e=>{void 0!==e[1]&&void 0!==e[2]?["purchase"].includes(e[1])&&(void 0!==e[2].page_type?tu=e:td=e):void 0!==e.event&&"purchase"===e.event&&void 0!==e.ecommerce&&(tu=e.ecommerce)}),tu||td}vetrinexlabsConversion(){if(Boolean(this.heatmapThankYouHasSentTrx))return;if(2184!==this.siteId)return!0;let e=()=>{var e;let t=document.querySelector(".elOrderSummaryV2");if(!t||!((e=t).offsetWidth>0&&e.offsetHeight>0))return[];let r=[],i=e=>{let t=e.match(/\d+/);return t?parseInt(t[0],10):null},a=t.querySelectorAll(".elOrderSummaryProduct");a.forEach(e=>{let t=e.querySelector(".elOrderSummaryProductInfoWrapper");if(!t)return;let a=t.querySelector("span:first-child"),n=t.querySelectorAll("div span");if(a&&n.length>=2){let s=a.textContent.trim(),o=i(n[1].textContent.trim()),c=i(n[2].textContent.trim().replace(/[^\d.-]/g,""));o&&c&&r.push({title:s,quantity:o,price:c,sku:s})}});let n=document.querySelector(".elOrderSummaryTotalWrapper"),s=n?parseFloat(n.textContent.trim().replace(/[^\d.-]/g,"")):0;return{products:r,revenue:s}},t=e=>e.offsetWidth>0&&e.offsetHeight>0&&"hidden"!==window.getComputedStyle(e).visibility,r=()=>{let e=document.querySelectorAll('[data-page-element="CheckoutStepButton/V1"] .elButton');for(let r of e)if(t(r))return r;return null},i=()=>{let t=e();var r={idorder:Math.floor(new Date().getTime()/1e3),request_source:"vetrinexlabsConversion",revenue:t.revenue,items:t.products,currency:"USD"};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${r.idorder}`,r,this.siteId,r.idorder)},a=()=>{var e=r();e&&e.addEventListener("click",i)};window.addEventListener("click",a)}processSkinnyrx(){if(Boolean(this.heatmapThankYouHasSentTrx))return;if(1910!==this.siteId)return!0;let e=()=>{let e=0,t=document.querySelectorAll("div");t.forEach(t=>{/\$\d/.test(t.innerHTML)&&(e=function e(t){let r=t.match(/\$([\d,]+)/);return r?parseFloat(r[1].replace(/,/g,"")):0}(t.innerHTML))}),console.log("Total Value:",e),e>0&&clearInterval(skinnyInterval)},t=t=>{let r=t.querySelectorAll('button[type="submit"]');r.forEach(t=>{if(t.innerHTML.includes("Checkout")){let r=function(i){e(),t.removeEventListener("click",r)};t.addEventListener("click",r)}})},r=document.querySelectorAll("form");r.forEach(e=>{let r=e.querySelector("#cardNumber"),i=e.querySelector("#cardHolderName");r&&i&&t(e)})}heatmapProcessBCConversionData(e=[]){var t=this.#r();if(void 0!==t&&0!==t&&(this.#e(this.apiPaths.bigcommerce),setTimeout(async()=>{if("undefined"!=typeof checkoutKitLoader){let e=await checkoutKitLoader.load("checkout-sdk"),r=e.createCheckoutService(),i=await r.loadOrder(t),a=i.data.getOrder();return this.#s(a)}},600)),"undefined"!=typeof checkoutKitLoader&&Boolean(/checkout/ig.test(window.location.href))){var r=this.#E(e),i=[];r[2].items.forEach(function(e){let t=void 0!==e.item_name?e.item_name:e.name;var r={sku:e.item_id,price:e.price,quantity:e.quantity,title:t.replace(/['"]+/g,"")};i.push(r)});var a={idorder:r[2].transaction_id,revenue:r[2].value,items:i,shipment:r[2].shipping,currency:r[2].currency};return this.#q(`${this.apiPaths.trackerURL}?siteId=${this.siteId}&idorder=${a.idorder}`,a,this.siteId,a.idorder)}}triggerCustomSiteSnippets(){this.#y(),this.#j(),this.#t(),this.#w(),this.#u(),this.#x(),this.#z(),this.#A(),this.#C(),this.#D(),this.#B(),this.#v(),this.#o()}}var convObj=[];Boolean(convObj.apiPaths)||(convObj=new ConversionsHandler).init();const heatmapRawConversionTransaction=(e,t,r)=>{convObj.heatmapRawConversionTransaction(r)},processSkinnyrx=e=>{convObj.processSkinnyrx(e)},vetrinexlabsConversion=e=>{convObj.vetrinexlabsConversion(e)},heatmapProcessBCConversionData=()=>{convObj.heatmapProcessBCConversionData([])},heatmapPushTransactionData=(e,t)=>{convObj.heatmapPushTransactionData(t)},heatmapCustomGTMSnippet=(e,t,r,i)=>{convObj.heatmapCustomGTMSnippet(e,t,r,i)},heatmapPushTransaction=()=>{},heatmapThankYouPushTransaction=()=>{},heatmapExecuteGTMDataLayer=()=>{},cheeseAndWineTransaction=()=>{convObj.triggerCustomSiteSnippets()};"function"==typeof Shopify&&"function"==typeof Shopify.on&&Shopify.on("CheckoutAmended",function(e,t){var r=window.Shopify.order;convObj.heatmapProcessCheckoutAmended(r.id,e,t)}),setTimeout(()=>{convObj.heatmapCustomConversion("heatmapThankYouPushTransaction"),convObj.triggerCustomSiteSnippets()},200);