var $wzrkjscomp = $wzrkjscomp || {}; $wzrkjscomp.scope = {}; $wzrkjscomp.createTemplateTagFirstArg = function (a) { return a.raw = a }; $wzrkjscomp.createTemplateTagFirstArgWithRaw = function (a, b) { a.raw = b; return a }; $wzrkjscomp.arrayIteratorImpl = function (a) { var b = 0; return function () { return b < a.length ? { done: !1, value: a[b++] } : { done: !0 } } }; $wzrkjscomp.arrayIterator = function (a) { return { next: $wzrkjscomp.arrayIteratorImpl(a) } }; $wzrkjscomp.makeIterator = function (a) { var b = "undefined" != typeof Symbol && Symbol.iterator && a[Symbol.iterator]; return b ? b.call(a) : $wzrkjscomp.arrayIterator(a) }; $wzrkjscomp.arrayFromIterator = function (a) { for (var b, d = []; !(b = a.next()).done;)d.push(b.value); return d }; $wzrkjscomp.arrayFromIterable = function (a) { return a instanceof Array ? a : $wzrkjscomp.arrayFromIterator($wzrkjscomp.makeIterator(a)) }; $wzrkjscomp.ASSUME_ES5 = !1; $wzrkjscomp.ASSUME_NO_NATIVE_MAP = !1; $wzrkjscomp.ASSUME_NO_NATIVE_SET = !1; $wzrkjscomp.SIMPLE_FROUND_POLYFILL = !1; $wzrkjscomp.ISOLATE_POLYFILLS = !1; $wzrkjscomp.FORCE_POLYFILL_PROMISE = !1; $wzrkjscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION = !1; $wzrkjscomp.getGlobal = function (a) { a = ["object" == typeof globalThis && globalThis, a, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global]; for (var b = 0; b < a.length; ++b) { var d = a[b]; if (d && d.Math == Math) return d } throw Error("Cannot find global object"); }; $wzrkjscomp.global = $wzrkjscomp.getGlobal(this); $wzrkjscomp.defineProperty = $wzrkjscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function (a, b, d) { if (a == Array.prototype || a == Object.prototype) return a; a[b] = d.value; return a }; $wzrkjscomp.IS_SYMBOL_NATIVE = "function" === typeof Symbol && "symbol" === typeof Symbol("x"); $wzrkjscomp.TRUST_ES6_POLYFILLS = !$wzrkjscomp.ISOLATE_POLYFILLS || $wzrkjscomp.IS_SYMBOL_NATIVE; $wzrkjscomp.polyfills = {}; $wzrkjscomp.propertyToPolyfillSymbol = {}; $wzrkjscomp.POLYFILL_PREFIX = "$jscp$"; var $wzrkjscomp$lookupPolyfilledValue = function (a, b) { var d = $wzrkjscomp.propertyToPolyfillSymbol[b]; if (null == d) return a[b]; d = a[d]; return void 0 !== d ? d : a[b] }; $wzrkjscomp.polyfill = function (a, b, d, f) { b && ($wzrkjscomp.ISOLATE_POLYFILLS ? $wzrkjscomp.polyfillIsolated(a, b, d, f) : $wzrkjscomp.polyfillUnisolated(a, b, d, f)) }; $wzrkjscomp.polyfillUnisolated = function (a, b, d, f) { d = $wzrkjscomp.global; a = a.split("."); for (f = 0; f < a.length - 1; f++) { var e = a[f]; if (!(e in d)) return; d = d[e] } a = a[a.length - 1]; f = d[a]; b = b(f); b != f && null != b && $wzrkjscomp.defineProperty(d, a, { configurable: !0, writable: !0, value: b }) }; $wzrkjscomp.polyfillIsolated = function (a, b, d, f) { var e = a.split("."); a = 1 === e.length; f = e[0]; f = !a && f in $wzrkjscomp.polyfills ? $wzrkjscomp.polyfills : $wzrkjscomp.global; for (var l = 0; l < e.length - 1; l++) { var c = e[l]; if (!(c in f)) return; f = f[c] } e = e[e.length - 1]; d = $wzrkjscomp.IS_SYMBOL_NATIVE && "es6" === d ? f[e] : null; b = b(d); null != b && (a ? $wzrkjscomp.defineProperty($wzrkjscomp.polyfills, e, { configurable: !0, writable: !0, value: b }) : b !== d && (void 0 === $wzrkjscomp.propertyToPolyfillSymbol[e] && (d = 1E9 * Math.random() >>> 0, $wzrkjscomp.propertyToPolyfillSymbol[e] = $wzrkjscomp.IS_SYMBOL_NATIVE ? $wzrkjscomp.global.Symbol(e) : $wzrkjscomp.POLYFILL_PREFIX + d + "$" + e), $wzrkjscomp.defineProperty(f, $wzrkjscomp.propertyToPolyfillSymbol[e], { configurable: !0, writable: !0, value: b }))) }; $wzrkjscomp.polyfill("Promise", function (a) { function b() { this.batch_ = null } function d(c) { return c instanceof e ? c : new e(function (g, h) { g(c) }) } if (a && (!($wzrkjscomp.FORCE_POLYFILL_PROMISE || $wzrkjscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION && "undefined" === typeof $wzrkjscomp.global.PromiseRejectionEvent) || !$wzrkjscomp.global.Promise || -1 === $wzrkjscomp.global.Promise.toString().indexOf("[native code]"))) return a; b.prototype.asyncExecute = function (c) { if (null == this.batch_) { this.batch_ = []; var g = this; this.asyncExecuteFunction(function () { g.executeBatch_() }) } this.batch_.push(c) }; var f = $wzrkjscomp.global.setTimeout; b.prototype.asyncExecuteFunction = function (c) { f(c, 0) }; b.prototype.executeBatch_ = function () { for (; this.batch_ && this.batch_.length;) { var c = this.batch_; this.batch_ = []; for (var g = 0; g < c.length; ++g) { var h = c[g]; c[g] = null; try { h() } catch (k) { this.asyncThrow_(k) } } } this.batch_ = null }; b.prototype.asyncThrow_ = function (c) { this.asyncExecuteFunction(function () { throw c; }) }; var e = function (c) { this.state_ = 0; this.result_ = void 0; this.onSettledCallbacks_ = []; this.isRejectionHandled_ = !1; var g = this.createResolveAndReject_(); try { c(g.resolve, g.reject) } catch (h) { g.reject(h) } }; e.prototype.createResolveAndReject_ = function () { function c(k) { return function (m) { h || (h = !0, k.call(g, m)) } } var g = this, h = !1; return { resolve: c(this.resolveTo_), reject: c(this.reject_) } }; e.prototype.resolveTo_ = function (c) { if (c === this) this.reject_(new TypeError("A Promise cannot resolve to itself")); else if (c instanceof e) this.settleSameAsPromise_(c); else { a: switch (typeof c) { case "object": var g = null != c; break a; case "function": g = !0; break a; default: g = !1 }g ? this.resolveToNonPromiseObj_(c) : this.fulfill_(c) } }; e.prototype.resolveToNonPromiseObj_ = function (c) { var g = void 0; try { g = c.then } catch (h) { this.reject_(h); return } "function" == typeof g ? this.settleSameAsThenable_(g, c) : this.fulfill_(c) }; e.prototype.reject_ = function (c) { this.settle_(2, c) }; e.prototype.fulfill_ = function (c) { this.settle_(1, c) }; e.prototype.settle_ = function (c, g) { if (0 != this.state_) throw Error("Cannot settle(" + c + ", " + g + "): Promise already settled in state" + this.state_); this.state_ = c; this.result_ = g; 2 === this.state_ && this.scheduleUnhandledRejectionCheck_(); this.executeOnSettledCallbacks_() }; e.prototype.scheduleUnhandledRejectionCheck_ = function () { var c = this; f(function () { if (c.notifyUnhandledRejection_()) { var g = $wzrkjscomp.global.console; "undefined" !== typeof g && g.error(c.result_) } }, 1) }; e.prototype.notifyUnhandledRejection_ = function () { if (this.isRejectionHandled_) return !1; var c = $wzrkjscomp.global.CustomEvent, g = $wzrkjscomp.global.Event, h = $wzrkjscomp.global.dispatchEvent; if ("undefined" === typeof h) return !0; "function" === typeof c ? c = new c("unhandledrejection", { cancelable: !0 }) : "function" === typeof g ? c = new g("unhandledrejection", { cancelable: !0 }) : (c = $wzrkjscomp.global.document.createEvent("CustomEvent"), c.initCustomEvent("unhandledrejection", !1, !0, c)); c.promise = this; c.reason = this.result_; return h(c) }; e.prototype.executeOnSettledCallbacks_ = function () { if (null != this.onSettledCallbacks_) { for (var c = 0; c < this.onSettledCallbacks_.length; ++c)l.asyncExecute(this.onSettledCallbacks_[c]); this.onSettledCallbacks_ = null } }; var l = new b; e.prototype.settleSameAsPromise_ = function (c) { var g = this.createResolveAndReject_(); c.callWhenSettled_(g.resolve, g.reject) }; e.prototype.settleSameAsThenable_ = function (c, g) { var h = this.createResolveAndReject_(); try { c.call(g, h.resolve, h.reject) } catch (k) { h.reject(k) } }; e.prototype.then = function (c, g) { function h(n, p) { return "function" == typeof n ? function (q) { try { k(n(q)) } catch (r) { m(r) } } : p } var k, m, t = new e(function (n, p) { k = n; m = p }); this.callWhenSettled_(h(c, k), h(g, m)); return t }; e.prototype.catch = function (c) { return this.then(void 0, c) }; e.prototype.callWhenSettled_ = function (c, g) { function h() { switch (k.state_) { case 1: c(k.result_); break; case 2: g(k.result_); break; default: throw Error("Unexpected state: " + k.state_); } } var k = this; null == this.onSettledCallbacks_ ? l.asyncExecute(h) : this.onSettledCallbacks_.push(h); this.isRejectionHandled_ = !0 }; e.resolve = d; e.reject = function (c) { return new e(function (g, h) { h(c) }) }; e.race = function (c) { return new e(function (g, h) { for (var k = $wzrkjscomp.makeIterator(c), m = k.next(); !m.done; m = k.next())d(m.value).callWhenSettled_(g, h) }) }; e.all = function (c) { var g = $wzrkjscomp.makeIterator(c), h = g.next(); return h.done ? d([]) : new e(function (k, m) { function t(q) { return function (r) { n[q] = r; p--; 0 == p && k(n) } } var n = [], p = 0; do n.push(void 0), p++, d(h.value).callWhenSettled_(t(n.length - 1), m), h = g.next(); while (!h.done) }) }; return e }, "es6", "es3"); var LOCAL_STORAGE_TTL = 1728E5, CT_PROXY_PATH = "/a/s"; if ("undefined" === typeof clevertap) var clevertap = { event: [], profile: [], account: [], notifications: [], onUserLogin: [], privacy: [] }; function getLastChargedItems() { var a = []; try { var b = JSON.parse(localStorage.getItem("WZRK_LST_CHID") || "[]"), d = (new Date).getTime(); a = b.filter(function (f) { return d < f.expiry }) } catch (f) { b = localStorage.getItem("WZRK_LST_CHID"), null !== b && (a = [{ chargedId: b, expiry: (new Date).getTime() + LOCAL_STORAGE_TTL }]) } localStorage.setItem("WZRK_LST_CHID", JSON.stringify(a)); return a } function insertChargedId(a) { if (localStorage) { var b = getLastChargedItems(); a = { chargedId: a, expiry: (new Date).getTime() + LOCAL_STORAGE_TTL }; localStorage.setItem("WZRK_LST_CHID", JSON.stringify([].concat($wzrkjscomp.arrayFromIterable(b), [a]))) } } function handleCharged(a, b) { if ("undefined" !== typeof Shopify.checkout && "W88-4Z5-9Z6Z" !== a) { a = !0; var d = "" + Shopify.checkout.order_id; localStorage && null !== localStorage.getItem("WZRK_LST_CHID") && (a = !getLastChargedItems().some(function (f) { return f.chargedId === d })); a && (profile_push_checkout(), push_checkout(b), insertChargedId(d)) } } var push_checkout = function (a) { var b = Shopify.checkout.line_items.length, d = []; for (i = 0; i < b; i++) { var f = {}; f.Product_id = Shopify.checkout.line_items[i].product_id; f.Title = Shopify.checkout.line_items[i].title; f.Quantity = Shopify.checkout.line_items[i].quantity; f.Vendor = Shopify.checkout.line_items[i].vendor; d.push(f) } b = "Charged"; var e = Shopify.checkout; if ("undefined" !== typeof e) { f = e.shipping_address; var l = e.total_price; "number" !== typeof l && (l = parseFloat(l)); d = { Amount: l, Currency: e.currency, Email: e.email, "Charged ID": e.order_id, Items: d, "CT Source": "Shopify" }; "undefined" !== a && "" !== a && 1 == a && (b = "Charged SDK", delete d.Items); "undefined" !== typeof f && (d.Ship_country = f.country, d.Ship_region = f.province, d.Ship_city = f.city); clevertap.event.push(b, d) } }, profile_push_checkout = function () { null != Shopify.checkout && clevertap.profile.push({ Site: { Email: Shopify.checkout.email, Phone: Shopify.checkout.phone } }) }; function scriptLoad(a, b) { var d = document.createElement("script"); d.type = "text/javascript"; d.readyState ? d.onreadystatechange = function () { if ("loaded" === d.readyState || "complete" === d.readyState) d.onreadystatechange = null, "undefined" !== typeof b && null !== b && b() } : d.onload = function () { "undefined" !== typeof b && null !== b && b() }; d.src = a; document.getElementsByTagName("head")[0].appendChild(d) } function loadWidget() { var a = !1; navigator.serviceWorker.getRegistrations().then(function (d) { d.forEach(function (f) { -1 < f.scope.indexOf(CT_PROXY_PATH) && (a = !0) }) }); !a && localStorage && localStorage.removeItem("WZRK_WPR"); var b = document.createElement("iframe"); b.setAttribute("src", CT_PROXY_PATH + "/widget.html"); b.setAttribute("id", "clevertap-frame"); b.setAttribute("frameborder", "0"); b.style.width = "400px"; b.style.height = "250px"; document.body.appendChild(b) } function initWebSdk(a, b, d, f) { clevertap.account.push({ id: a }); clevertap.enablePersonalization = !0; clevertap.plugin = "shop"; "undefined" !== typeof b && "" !== b && (clevertap.region = b); clevertap.privacy.push({ useIP: d }); a = document.createElement("script"); a.type = "text/javascript"; a.async = !0; b = document.getElementsByTagName("script")[0]; b.parentNode.insertBefore(a, b); a.onload = function () { f && clevertap.getLocation() }; a.src = ("https:" == document.location.protocol ? "https://d2r1yp2w7bby2u.cloudfront.net" : "http://static.clevertap.com") + "/js/clevertap.min.js" } function wzrkShopify(a, b, d, f, e) { clevertap.account.push({ id: a }); clevertap.enablePersonalization = !0; clevertap.plugin = "shop"; "undefined" !== typeof b && "" !== b && (clevertap.region = b); clevertap.privacy.push({ useIP: f }); a = document.createElement("script"); a.type = "text/javascript"; a.async = !0; b = document.getElementsByTagName("script")[0]; b.parentNode.insertBefore(a, b); a.onload = function () { scriptLoad(CT_PROXY_PATH + "/shopifyEvents.js", d ? loadWidget : null); e && clevertap.getLocation() }; a.src = ("https:" == document.location.protocol ? "https://d2r1yp2w7bby2u.cloudfront.net" : "http://static.clevertap.com") + "/js/clevertap.min.js" } function checkAndUpdateShpfyProxy() { function a(b) { if (100 < b) return console.error("Failed to find valid proxy path"), Promise.resolve(); var d = 0 === b ? CT_PROXY_PATH : "/a/s-" + b; return fetch(d + "/shopifyEvents.js", { method: "HEAD" }).then(function (f) { return f.ok && "application/javascript" === f.headers.get("Content-Type") ? (CT_PROXY_PATH = d, clevertap.shpfyProxyPath = CT_PROXY_PATH, console.log((0 === b ? "Current" : "Updated") + " proxy path: " + d), Promise.resolve()) : a(b + 1) }).catch(function () { return a(b + 1) }) } return a(0) } var useIP = __wzrk_useIp || !1, captureLatLong = __wzrk_captureLatLong || !1; if ("undefined" !== typeof __wzrk_account_id) "undefined" === typeof __wzrk_region && (__wzrk_region = ""), checkAndUpdateShpfyProxy().then(function () { wzrkShopify(__wzrk_account_id, __wzrk_region, __wzrk_web_push_enabled, useIP, captureLatLong) }); else if ("undefined" !== typeof Shopify) { var shopInfo = ""; window.location.href.indexOf("/checkouts/") && localStorage && (shopInfo = localStorage.getItem("WZRK_SHOP_INFO")); if ("" !== shopInfo) { var shop = JSON.parse(shopInfo); initWebSdk(shop.acct_id, shop.region, useIP, captureLatLong); handleCharged(shop.acct_id, shop.webhookEnabled) } else (function () { var a = Shopify.shop, b = document.createElement("script"); b.type = "text/javascript"; b.async = !0; b.src = "https://api.clevertap.com/js/wzrk-shopify.js?shop=" + a; a = document.getElementsByTagName("script")[0]; a.parentNode.insertBefore(b, a) })() };