var Mixdown=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var i,a,c=o((function(e,n){window,e.exports=function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,n){if(1&n&&(e=r(e)),8&n)return e;if(4&n&&"object"==t(e)&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)r.d(o,i,function(t){return e[t]}.bind(null,i));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,n){function r(){this.enabled=!1}function o(t){if(t){for(var e={},n=0,r=Object.keys(t);n<r.length;n++){var o=r[n];e[o.replace(/\s/g,"_")]=t[o]}return e}}n.r(e),n.d(e,"integrations",(function(){return d})),n.d(e,"defaultIntegrationConfig",(function(){return h})),n.d(e,"defaultConfig",(function(){return y})),r.prototype.checkEnabled=function(){return this.enabled=!!(window&&window._dcq&&window._dcq.push),this.enabled},r.prototype.push=function(t){return window._dcq.push(t)},r.prototype.track=function(t,e){this.push(["track",t,o(e)])},r.prototype.identify=function(t,e,n){(e=e||{}).email&&(n&&n.campaignId&&this.push(["subscribe",{campaign_id:n.campaignId,fields:e}]),this.push(["identify",{email:e.email,user_id:t}]))};var i=r;function a(){this.enabled=!1}a.prototype.checkEnabled=function(){return this.enabled=!(!window||!window.mixpanel),this.enabled},a.prototype.track=function(t,e){return window.mixpanel.track(t,e)},a.prototype.trackLinks=function(t,e,n){return window.mixpanel.track_links(t,e,n)},a.prototype.identify=function(t){return window.mixpanel.identify(t)};var c=a;function u(){this.enabled=!1}u.prototype.checkEnabled=function(){return this.enabled=!(!window||!window.dataLayer),this.enabled},u.prototype.push=function(t){return window.dataLayer.push(t)},u.prototype.track=function(t,e){e=e||{};var n={};for(var r in e)n[r]=e[r];n.event=t,this.push(n)};var p=u;function s(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=function(t,e){if(t){if("string"==typeof t)return f(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(t,e):void 0}}(t))){var e=0,n=function(){};return{s:n,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o,i=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var l,d={drip:new i,mixpanel:new c,gtm:new p},h={includeByDefault:!0},y={integrations:{drip:{includeByDefault:!1},mixpanel:null,gtm:{includeByDefault:!1}}};function g(t){this.setConfig(t)}g.prototype.setConfig=function(t){this.config=t||y,this.integrations={};for(var e=0,n=Object.keys(this.config.integrations);e<n.length;e++){var r=n[e],o=d[r];this.integrations[r]=o}},g.prototype.caller=function(t,e,n){var r,o=s(this.getTargetIntegrations(n));try{var i=function(){var n=r.value;setTimeout((function(){if(n.checkEnabled()&&n[t])try{n[t].apply(n,e)}catch(t){}}))};for(o.s();!(r=o.n()).done;)i()}catch(t){o.e(t)}finally{o.f()}},g.prototype.getTargetIntegrations=function(t){for(var e=t&&t.integrations||{},n=[],r=0,o=Object.keys(this.integrations);r<o.length;r++){var i=o[r];!0!==(this.config.integrations[i]||h).includeByDefault&&!0!==e[i]||n.push(this.integrations[i])}return n},g.prototype.track=function(t,e,n){return this.caller("track",[t,e,n],n)},g.prototype.trackLinks=function(t,e,n,r){return this.caller("trackLinks",[t,e,n,r],r)},g.prototype.identify=function(t,e,n){return this.caller("identify",[t,e,n],n)},g.getInstance=function(){return l||(l=new g),l},e.default=g}])}(a={path:i,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&a.path)}},a.exports),a.exports)).getInstance(),u=["eventCache","profileCache"];function p(t,e,n){this.mixpanel=t,this.token=e,this.currentUserTrackingStatus=n,this._initiateCache(u)}return p.prototype._registerTrackingStatus=function(t){this.mixpanel.register({userTrackingStatus:t}),this.currentUserTrackingStatus=t},p.prototype._getSuperProps=function(t){if(window.document&&document.cookie){var e=document.cookie.split(";").reduce((function(t,e){var n=e.indexOf("="),r=e.substring(0,n).trim(),o=e.substring(n+1);return t[r]=o,t}),{})["mp_".concat(t,"_mixpanel")]||null;return JSON.parse(decodeURIComponent(e))}},p.prototype._initiateCache=function(t){this.currentUserTrackingStatus||this._registerTrackingStatus("pre-identify"),"post-identify"!==this.currentUserTrackingStatus&&t.forEach((function(t){null===window.localStorage.getItem(t)&&window.localStorage.setItem(t,"[]")}))},p.prototype._getAndSetCache=function(t,e){var n=JSON.parse(window.localStorage.getItem(t))||[];n.push(e),window.localStorage.setItem(t,JSON.stringify(n))},p.prototype._processCache=function(t,e,n){for(var r=JSON.parse(window.localStorage.getItem(e))||[],o=[],i=function(){var i=r.splice(0,n),a=fetch("https://api.mixpanel.com/".concat(t,"?data=").concat(encodeURIComponent(JSON.stringify(i))),{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then((function(t){return 200===t.status?t.json():{}})).then((function(t){if(0===t)throw new Error("Mixdown ".concat(e," batch failed"),i);return i})).catch((function(t){return null}));o.push(a)};r.length>0;)i();return window.localStorage.removeItem(e),Promise.all(o)},p.prototype.track=function(t,e){this._handleEvent(t,e)},p.prototype.trackLinks=function(t,e,n){this._handleEvent(e,n,t)},p.prototype._handleEvent=function(t,e,n){var r;((e=e||{}).time=Date.now(),window&&document)&&(e.$current_url=window.location.href||"",e.$referrer=(null===(r=window.lp_mix)||void 0===r?void 0:r.referrer)||document.referrer||"");this.mixpanel&&"post-identify"===this.currentUserTrackingStatus?this._forwardEvent(t,e,n):this._prepareForEventCaching(t,e,n)},p.prototype._prepareForEventCaching=function(t,e,n){e.token=this.token;var o=this._getSuperProps(this.token),i=n?{event:t,properties:r(r({},e),o),query:n}:{event:t,properties:r(r({},e),o)};this._getAndSetCache("eventCache",i)},p.prototype._forwardEvent=function(t,e,n){n?c.trackLinks(n,t,e):c.track(t,e)},p.prototype.peopleSet=function(t){this._handleProfileUpdate(t)},p.prototype.peopleSetOnce=function(t){this._handleProfileUpdate(t,"once")},p.prototype._handleProfileUpdate=function(t,e){this.mixpanel&&"post-identify"===this.currentUserTrackingStatus?("once"===e?this.mixpanel.people.set_once(t):this.mixpanel.people.set(t),this.mixpanel.identify()):this._prepareForProfileUpdateCaching(t,e)},p.prototype._prepareForProfileUpdateCaching=function(t,e){var n={};n.$token=this.token,n.$distinct_id=this.mixpanel.get_distinct_id(),n.$time=Date.now();var o=r(r({},n),{},"once"===e?{$set_once:r({},t)}:{$set:r({},t)});this._getAndSetCache("profileCache",o)},p.prototype.identify=function(){this.mixpanel&&(this._registerTrackingStatus("post-identify"),this._processCache("track","eventCache",10),this._processCache("engage","profileCache",1),this.mixpanel.identify())},p}();