"use strict";var wffnFunnel={isSetUpCached:function(){if(void 0!==window.wffnPublicVars.current_step&&"wc_checkout"===window.wffnPublicVars.current_step.type)return!1;var n=(new Date).getTime()/1e3;return 20<parseInt(n-parseInt(window.wffnPublicVars.setup_time))},setUpFunnel:function(){this.init()},init:function(){var n,i,e,t;this.isSetUpCached()?(console.log("cached setup found"),n=new XMLHttpRequest,i=this,n.open("POST",window.wffnfunnelVars.ajaxUrl+"?action=wffn_maybe_setup_funnel",!0),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.onreadystatechange=function(){var n,e,t;this.readyState===XMLHttpRequest.DONE&&200===this.status&&(n=JSON.parse(this.response),Object.hasOwnProperty.call(n,"hash")&&"undefined"!=typeof Cookies&&(Cookies.set("wffn_si",n.hash,{path:"/"}),e=n.hash,t=n.current_step.id,i.HandleAnalytics(e,t),i.maybeHandleEcommEvents()),Object.hasOwnProperty.call(n,"next_link")&&(window.wffnPublicVars.next_link=n.next_link))},e=encodeURIComponent,t=Object.keys(window.wffnfunnelEnvironment).map(function(n){return e(n)+"="+e(window.wffnfunnelEnvironment[n])}).join("&"),n.send(t)):"undefined"!=typeof Cookies&&(void 0!==Cookies.get("wffn_si")&&void 0!==window.wffnfunnelEnvironment&&Object.hasOwnProperty.call(window.wffnfunnelEnvironment,"post_type")&&-1!==["wffn_ty","wffn_oty"].indexOf(window.wffnfunnelEnvironment.post_type)?this.HandleAnalytics(Cookies.get("wffn_si"),window.wffnfunnelEnvironment.id,"onload",window.wffnfunnelEnvironment):void 0!==window.wffnPublicVars&&Object.hasOwnProperty.call(window.wffnfunnelData,"hash")&&(Cookies.set("wffn_si",window.wffnfunnelData.hash,{path:"/"}),this.HandleAnalytics(window.wffnfunnelData.hash,window.wffnfunnelData.current_step.id)),this.maybeHandleEcommEvents())},analyticsAlready:function(n,e){if(void 0!==Cookies.get("wffn_ay_"+n)&&""!==Cookies.get("wffn_ay_"+n)){n=JSON.parse(Cookies.get("wffn_ay_"+n));if(Array.isArray(n)&&0<=jQuery.inArray(parseInt(e),n))return!0}return!1},maybeHandleEcommEvents:function(){var n,e,t;"undefined"!=typeof wffnEvents&&0!==wffnEvents.length&&((n=new XMLHttpRequest).open("POST",window.wffnfunnelVars.ajaxUrl+"?action=wffn_tracking_events",!0),e="",(t={}).events_data=wffnEvents,"undefined"!=typeof wffnfunnelEnvironment&&(t.step_data=wffnfunnelEnvironment),e="data="+JSON.stringify(t),n.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),n.send(e))},getAnalyticsData:function(n){return void 0!==Cookies.get("wffn_ay_"+n)&&""!==Cookies.get("wffn_ay_"+n)?JSON.parse(Cookies.get("wffn_ay_"+n)):[]},HandleAnalytics:function(n,e){var t,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:"onload",f=3<arguments.length&&void 0!==arguments[3]?arguments[3]:"";void 0!==window.wffnPublicVars.is_preview&&1===window.wffnPublicVars.is_preview||"onload"===i&&""===window.wffnfunnelData.support_track||void 0!==n&&void 0!==e&&!0!==this.analyticsAlready(n,e)&&((t=new XMLHttpRequest).open("POST",window.wffnfunnelVars.ajaxUrl+"?action=wffn_frontend_analytics",!0),i="","undefined"!=typeof wffnEvents&&(i=wffnEvents),""!==f&&(""===i?i=[{current_step:f}]:i.push({current_step:f})),""!==i&&(i="data="+JSON.stringify(i)),window.wffnEvents=[],t.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),t.send(i),(i=this.getAnalyticsData(n)).push(parseInt(e)),Cookies.set("wffn_ay_"+n,JSON.stringify(i),{path:"/"}))},PlaceNextLink:function(){var n=document.querySelectorAll('a[href*="wffn-next-link=yes"]');0<n.length&&void 0!==window.wffnPublicVars&&""!==window.wffnPublicVars.next_link&&n.forEach(function(e){try{var n=new URL(e.href),t=new URLSearchParams(n.search);t.delete("wffn-next-link");var i=new URL(window.wffnPublicVars.next_link);i.search=t.toString(),e.setAttribute("href",i.toString()),e.classList.add("wffn-next-step-link")}catch(n){e.classList.add("wffn-next-step-link"),e.setAttribute("href",window.wffnPublicVars.next_link)}})}};window.wffnPublicVars=window.wffnfunnelData,wffnFunnel.setUpFunnel(),function(a){wffnFunnel.PlaceNextLink(),a(document).on("click",'a[href*="wffn-next-link=yes"]',function(n){if(n.preventDefault(),void 0===window.wffnPublicVars.is_preview||1!==window.wffnPublicVars.is_preview){if(""!==window.wffnPublicVars.next_link)try{var e=a(this).attr("href"),t=e.startsWith("http")?new URL(e):new URL(e,window.location.origin),i=new URLSearchParams(t.search);i.delete("wffn-next-link");var f=new URL(window.wffnPublicVars.next_link);f.search=i.toString(),window.location.href=f.toString()}catch(n){window.location.href=window.wffnPublicVars.next_link}}else n.stopPropagation()}),a(document.body).on("updated_checkout",function(){void 0!==window.wffnPublicVars.current_step.id&&void 0!==window.wffnPublicVars.hash&&wffnFunnel.HandleAnalytics(window.wffnPublicVars.hash,window.wffnPublicVars.current_step.id,"manual")})}(jQuery);