@esri/telemetry-amazon 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1029,7 +1029,7 @@
1029
1029
  }));
1030
1030
  }(encHex));
1031
1031
 
1032
- const storage$1 = {
1032
+ const storage = {
1033
1033
  storage: {},
1034
1034
  memory: true,
1035
1035
  get(key) {
@@ -1086,7 +1086,7 @@
1086
1086
  function getCredentials(IdentityPoolId, options = {}) {
1087
1087
  const fipsSubdomainSuffix = options.fips === true ? '-fips' : '';
1088
1088
  const COGNITO_URL = `https://cognito-identity${fipsSubdomainSuffix}.us-east-1.amazonaws.com/`;
1089
- let cached = storage$1.get(COGNITO_KEY);
1089
+ let cached = storage.get(COGNITO_KEY);
1090
1090
  if (cached && Date.now() / 1000 < cached.Expiration)
1091
1091
  return Promise.resolve(cached);
1092
1092
  const fetchOptions = {
@@ -1123,7 +1123,7 @@
1123
1123
  return response.json();
1124
1124
  })
1125
1125
  .then(({ Credentials }) => {
1126
- storage$1.set(COGNITO_KEY, Credentials);
1126
+ storage.set(COGNITO_KEY, Credentials);
1127
1127
  return Credentials;
1128
1128
  });
1129
1129
  }
@@ -1240,4681 +1240,29 @@
1240
1240
 
1241
1241
  }(dlv_umd));
1242
1242
 
1243
- var dotProp = dlv_umd.exports;
1243
+ var i$3 = dlv_umd.exports;
1244
1244
 
1245
- var F$2="undefined"!=typeof process?process:{};F$2.env&&F$2.env.NODE_ENV||"";var $$2="undefined"!=typeof window;null!=F$2.versions&&null!=F$2.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$2&&"nodejs"===window.name||"undefined"!=typeof navigator&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$3(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$1=M$3.bind(null,"toUpperCase"),H$3=M$3.bind(null,"toLowerCase");function J$2(n){return Y$1(n)?U$1("null"):"object"==typeof n?yn$1(n):Object.prototype.toString.call(n).slice(8,-1)}function R$1(n,t){void 0===t&&(t=!0);var e=J$2(n);return t?H$3(e):e}function V$1(n,t){return typeof t===n}var W$1=V$1.bind(null,"function"),q$1=V$1.bind(null,"string");V$1.bind(null,"undefined");V$1.bind(null,"boolean");V$1.bind(null,"symbol");function Y$1(n){return null===n}function nn$1(n){return "number"===R$1(n)&&!isNaN(n)}function yn$1(n){return W$1(n.constructor)?n.constructor.name:null}function hn$1(n){return n instanceof Error||q$1(n.message)&&n.constructor&&nn$1(n.constructor.stackTraceLimit)}function On$1(n,t){if("object"!=typeof t||Y$1(t))return !1;if(t instanceof n)return !0;var e=R$1(new n(""));if(hn$1(t))for(;t;){if(R$1(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On$1.bind(null,TypeError);On$1.bind(null,SyntaxError);function $n$1(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$1(n,t):e}function Tn$1(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$1(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$1($n$1,"form");_n$1($n$1,"button");_n$1($n$1,"input");_n$1($n$1,"select");
1245
+ var F$5="undefined"!=typeof process?process:{};F$5.env&&F$5.env.NODE_ENV||"";var $$4="undefined"!=typeof document;null!=F$5.versions&&null!=F$5.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$4&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$4(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$4=M$4.bind(null,"toUpperCase"),H$4=M$4.bind(null,"toLowerCase");function J$5(n){return Y$4(n)?U$4("null"):"object"==typeof n?yn$3(n):Object.prototype.toString.call(n).slice(8,-1)}function R$4(n,t){void 0===t&&(t=!0);var e=J$5(n);return t?H$4(e):e}function V$4(n,t){return typeof t===n}var W$4=V$4.bind(null,"function"),q$4=V$4.bind(null,"string");V$4.bind(null,"undefined");V$4.bind(null,"boolean");V$4.bind(null,"symbol");function Y$4(n){return null===n}function nn$3(n){return "number"===R$4(n)&&!isNaN(n)}function yn$3(n){return W$4(n.constructor)?n.constructor.name:null}function hn$3(n){return n instanceof Error||q$4(n.message)&&n.constructor&&nn$3(n.constructor.stackTraceLimit)}function On$3(n,t){if("object"!=typeof t||Y$4(t))return !1;if(t instanceof n)return !0;var e=R$4(new n(""));if(hn$3(t))for(;t;){if(R$4(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On$3.bind(null,TypeError);On$3.bind(null,SyntaxError);function $n$3(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$3(n,t):e}function Tn$3(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$3(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$3($n$3,"form");_n$3($n$3,"button");_n$3($n$3,"input");_n$3($n$3,"select");
1246
1246
 
1247
- function n$3(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o$2(){if($$2){var r=navigator,t=r.languages;return r.userLanguage||(t&&t.length?t[0]:r.language)}}function a$3(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}}function s(r){return function(e){for(var r,t=Object.create(null),o=/([^&=]+)=?([^&]*)/g;r=o.exec(e);){var a=n$3(r[1]),i=n$3(r[2]);"[]"===a.substring(a.length-2)?(t[a=a.substring(0,a.length-2)]||(t[a]=[])).push(i):t[a]=""===i||i;}for(var u in t){var c=u.split("[");c.length>1&&(m(t,c.map(function(e){return e.replace(/[?[\]\\ ]/g,"")}),t[u]),delete t[u]);}return t}(function(r){if(r){var t=r.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return $$2&&window.location.search.substring(1)}(r))}function m(e,r,t){for(var n=r.length-1,o=0;o<n;++o){var a=r[o];if("__proto__"===a||"constructor"===a)break;a in e||(e[a]={}),e=e[a];}e[r[n]]=t;}function y(){for(var e="",r=0,t=4294967295*Math.random()|0;r++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r-1],o=15&t;e+="-"==n||"4"==n?n:("x"==n?o:3&o|8).toString(16),t=r%8==0?4294967295*Math.random()|0:t>>4;}return e}
1247
+ function n$1(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o$2(){if($$4){var r=navigator,t=r.languages;return r.userLanguage||(t&&t.length?t[0]:r.language)}}function a$3(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}}function s(r){return function(e){for(var r,t=Object.create(null),o=/([^&=]+)=?([^&]*)/g;r=o.exec(e);){var a=n$1(r[1]),i=n$1(r[2]);"[]"===a.substring(a.length-2)?(t[a=a.substring(0,a.length-2)]||(t[a]=[])).push(i):t[a]=""===i||i;}for(var u in t){var c=u.split("[");c.length>1&&(m$1(t,c.map(function(e){return e.replace(/[?[\]\\ ]/g,"")}),t[u]),delete t[u]);}return t}(function(r){if(r){var t=r.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return $$4&&window.location.search.substring(1)}(r))}function m$1(e,r,t){for(var n=r.length-1,o=0;o<n;++o){var a=r[o];if("__proto__"===a||"constructor"===a)break;a in e||(e[a]={}),e=e[a];}e[r[n]]=t;}function y$1(){for(var e="",r=0,t=4294967295*Math.random()|0;r++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r-1],o=15&t;e+="-"==n||"4"==n?n:("x"==n?o:3&o|8).toString(16),t=r%8==0?4294967295*Math.random()|0:t>>4;}return e}
1248
1248
 
1249
- var e="undefined",o$1="object",j="__",F$1="undefined"!=typeof process?process:{};F$1.env&&F$1.env.NODE_ENV||"";var $$1="undefined"!=typeof window;null!=F$1.versions&&null!=F$1.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$1&&"nodejs"===window.name||"undefined"!=typeof navigator&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$2(n,t){return t.charAt(0)[n]()+t.slice(1)}var U=M$2.bind(null,"toUpperCase"),H$2=M$2.bind(null,"toLowerCase");function J$1(n){return Y(n)?U("null"):"object"==typeof n?yn(n):Object.prototype.toString.call(n).slice(8,-1)}function R(n,t){void 0===t&&(t=!0);var e=J$1(n);return t?H$2(e):e}function V(n,t){return typeof t===n}var W=V.bind(null,"function"),q=V.bind(null,"string");V.bind(null,"undefined");V.bind(null,"boolean");V.bind(null,"symbol");function Y(n){return null===n}function nn(n){return "number"===R(n)&&!isNaN(n)}function yn(n){return W(n.constructor)?n.constructor.name:null}function hn(n){return n instanceof Error||q(n.message)&&n.constructor&&nn(n.constructor.stackTraceLimit)}function On(n,t){if("object"!=typeof t||Y(t))return !1;if(t instanceof n)return !0;var e=R(new n(""));if(hn(t))for(;t;){if(R(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On.bind(null,TypeError);On.bind(null,SyntaxError);function $n(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn(n,t):e}function Tn(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n($n,"form");_n($n,"button");_n($n,"input");_n($n,"select");
1249
+ var e="undefined",o$1="object",j$1="__",F$4="undefined"!=typeof process?process:{};F$4.env&&F$4.env.NODE_ENV||"";var $$3="undefined"!=typeof document;null!=F$4.versions&&null!=F$4.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$3&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$3(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$3=M$3.bind(null,"toUpperCase"),H$3=M$3.bind(null,"toLowerCase");function J$4(n){return Y$3(n)?U$3("null"):"object"==typeof n?yn$2(n):Object.prototype.toString.call(n).slice(8,-1)}function R$3(n,t){void 0===t&&(t=!0);var e=J$4(n);return t?H$3(e):e}function V$3(n,t){return typeof t===n}var W$3=V$3.bind(null,"function"),q$3=V$3.bind(null,"string");V$3.bind(null,"undefined");V$3.bind(null,"boolean");V$3.bind(null,"symbol");function Y$3(n){return null===n}function nn$2(n){return "number"===R$3(n)&&!isNaN(n)}function yn$2(n){return W$3(n.constructor)?n.constructor.name:null}function hn$2(n){return n instanceof Error||q$3(n.message)&&n.constructor&&nn$2(n.constructor.stackTraceLimit)}function On$2(n,t){if("object"!=typeof t||Y$3(t))return !1;if(t instanceof n)return !0;var e=R$3(new n(""));if(hn$2(t))for(;t;){if(R$3(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On$2.bind(null,TypeError);On$2.bind(null,SyntaxError);function $n$2(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$2(n,t):e}function Tn$2(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$2(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$2($n$2,"form");_n$2($n$2,"button");_n$2($n$2,"input");_n$2($n$2,"select");
1250
1250
 
1251
- var l$1="global",o=j+"global"+j,n$2=typeof self===o$1&&self.self===self&&self||typeof global===o$1&&global.global===global&&global||void 0;function a$2(t){return n$2[o][t]}function f$1(t,e){return n$2[o][t]=e}function i$2(t){delete n$2[o][t];}function u$1(t,e,r){var l;try{if(b$1(t)){var o=window[t];l=o[e].bind(o);}}catch(t){}return l||r}n$2[o]||(n$2[o]={});var c$1={};function b$1(t){if(typeof c$1[t]!==e)return c$1[t];try{var e$1=window[t];e$1.setItem(e,e),e$1.removeItem(e);}catch(e){return c$1[t]=!1}return c$1[t]=!0}
1251
+ var l="global",o=j$1+"global"+j$1,n=typeof self===o$1&&self.self===self&&self||typeof global===o$1&&global.global===global&&global||void 0;function a$2(t){return n[o][t]}function f(t,e){return n[o][t]=e}function i$2(t){delete n[o][t];}function u$1(t,e,r){var l;try{if(b$3(t)){var o=window[t];l=o[e].bind(o);}}catch(t){}return l||r}n[o]||(n[o]={});var c$1={};function b$3(t){if(typeof c$1[t]!==e)return c$1[t];try{var e$1=window[t];e$1.setItem(e,e),e$1.removeItem(e);}catch(e){return c$1[t]=!1}return c$1[t]=!0}
1252
1252
 
1253
- var n$1,p="__",h$2="undefined"!=typeof process?process:{};(null==(n$1=h$2.env)?void 0:n$1.NODE_ENV)||"";var z$1="undefined"!=typeof window;null!=h$2.versions&&null!=h$2.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;z$1&&"nodejs"===window.name||"undefined"!=typeof navigator&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function C$2(n,e){return typeof e===n}var _=C$2.bind(null,"function"),L$2=C$2.bind(null,"string");C$2.bind(null,"undefined");var x$1=C$2.bind(null,"boolean");function G$1(n){return "[object Array]"===Object.prototype.toString.call(n)}function H$1(n){return n&&("object"==typeof n||null!==n)}function M$1(n){if(!H$1(n))return !1;for(var e=n;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}
1253
+ var j="__",F$3="undefined"!=typeof process?process:{};F$3.env&&F$3.env.NODE_ENV||"";var $$2="undefined"!=typeof document;null!=F$3.versions&&null!=F$3.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$2&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$2(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$2=M$2.bind(null,"toUpperCase"),H$2=M$2.bind(null,"toLowerCase");function J$3(n){return Y$2(n)?U$2("null"):"object"==typeof n?yn$1(n):Object.prototype.toString.call(n).slice(8,-1)}function R$2(n,t){void 0===t&&(t=!0);var e=J$3(n);return t?H$2(e):e}function V$2(n,t){return typeof t===n}var W$2=V$2.bind(null,"function"),q$2=V$2.bind(null,"string");V$2.bind(null,"undefined");var Q$1=V$2.bind(null,"boolean");V$2.bind(null,"symbol");function Y$2(n){return null===n}function nn$1(n){return "number"===R$2(n)&&!isNaN(n)}function rn(n){return "array"===R$2(n)}function on$1(n){if(!un$1(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un$1(n){return n&&("object"==typeof n||null!==n)}function yn$1(n){return W$2(n.constructor)?n.constructor.name:null}function hn$1(n){return n instanceof Error||q$2(n.message)&&n.constructor&&nn$1(n.constructor.stackTraceLimit)}function On$1(n,t){if("object"!=typeof t||Y$2(t))return !1;if(t instanceof n)return !0;var e=R$2(new n(""));if(hn$1(t))for(;t;){if(R$2(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On$1.bind(null,TypeError);On$1.bind(null,SyntaxError);function $n$1(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$1(n,t):e}function Tn$1(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$1(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$1($n$1,"form");_n$1($n$1,"button");_n$1($n$1,"input");_n$1($n$1,"select");
1254
1254
 
1255
- function _arrayLikeToArray(arr, len) {
1256
- if (len == null || len > arr.length) len = arr.length;
1255
+ function v(){return v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);}return e},v.apply(this,arguments)}var y="function",b$2="undefined",I$2="@@redux/"+Math.random().toString(36),w=/* #__PURE__ */function(){return typeof Symbol===y&&Symbol.observable||"@@observable"}(),E$1=" != "+y;function P(e,n,t){var r;if(typeof n===y&&typeof t===b$2&&(t=n,n=void 0),typeof t!==b$2){if(typeof t!==y)throw new Error("enhancer"+E$1);return t(P)(e,n)}if(typeof e!==y)throw new Error("reducer"+E$1);var i=e,a=n,o=[],u=o,c=!1;function s(){u===o&&(u=o.slice());}function f(){return a}function d(e){if(typeof e!==y)throw new Error("Listener"+E$1);var n=!0;return s(),u.push(e),function(){if(n){n=!1,s();var t=u.indexOf(e);u.splice(t,1);}}}function p(e){if(!on$1(e))throw new Error("Act != obj");if(typeof e.type===b$2)throw new Error("ActType "+b$2);if(c)throw new Error("Dispatch in reducer");try{c=!0,a=i(a,e);}finally{c=!1;}for(var n=o=u,t=0;t<n.length;t++)(0, n[t])();return e}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:d,getState:f,replaceReducer:function(e){if(typeof e!==y)throw new Error("next reducer"+E$1);i=e,p({type:"@@redux/INIT"});}})[w]=function(){var e,n=d;return (e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function t(){e.next&&e.next(f());}return t(),{unsubscribe:n(t)}}})[w]=function(){return this},e},r}function S(e,n){var t=n&&n.type;return "action "+(t&&t.toString()||"?")+"reducer "+e+" returns "+b$2}function N$1(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function O$1(){var e=arguments;return function(n){return function(t,r,i){var a,o=n(t,r,i),u=o.dispatch,c={getState:o.getState,dispatch:function(e){return u(e)}};return a=[].slice.call(e).map(function(e){return e(c)}),v({},o,{dispatch:u=N$1.apply(void 0,a)(o.dispatch)})}}}var A$1=j+"anon_id",_=j+"user_id",x$1=j+"user_traits",k$1="userId",T="anonymousId",z=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],M$1=["name","EVENTS","config","loaded"],q$1=z.reduce(function(e,n){return e[n]=n,e},{registerPluginType:function(e){return "registerPlugin:"+e},pluginReadyType:function(e){return "ready:"+e}}),U$1=/^utm_/,V$1=/^an_prop_/,L$1=/^an_trait_/;function C$1(e){var n=e.storage.setItem;return function(t){return function(r){return function(i){if(i.type===q$1.bootstrap){var a=i.params,o=i.user,u=i.persistedUser,c=i.initialUser,s=u.userId===o.userId;u.anonymousId!==o.anonymousId&&n(A$1,o.anonymousId),s||n(_,o.userId),c.traits&&n(x$1,v({},s&&u.traits?u.traits:{},c.traits));var l=Object.keys(i.params);if(l.length){var f=a.an_uid,d=a.an_event,p=l.reduce(function(e,n){if(n.match(U$1)||n.match(/^(d|g)clid/)){var t=n.replace(U$1,"");e.campaign["campaign"===t?"name":t]=a[n];}return n.match(V$1)&&(e.props[n.replace(V$1,"")]=a[n]),n.match(L$1)&&(e.traits[n.replace(L$1,"")]=a[n]),e},{campaign:{},props:{},traits:{}});t.dispatch(v({type:q$1.params,raw:a},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&t.dispatch({type:q$1.campaign,campaign:p.campaign});}}return r(i)}}}}function R$1(e){return function(n,t){if(void 0===n&&(n={}),void 0===t&&(t={}),t.type===q$1.setItemEnd){if(t.key===A$1)return v({},n,{anonymousId:t.value});if(t.key===_)return v({},n,{userId:t.value})}switch(t.type){case q$1.identify:return Object.assign({},n,{userId:t.userId,traits:v({},n.traits,t.traits)});case q$1.reset:return [_,A$1,x$1].forEach(function(n){e.removeItem(n);}),Object.assign({},n,{userId:null,anonymousId:null,traits:{}});default:return n}}}function $$1(e){return {userId:e.getItem(_),anonymousId:e.getItem(A$1),traits:e.getItem(x$1)}}var D=function(e){return j+"TEMP"+j+e};function B(n){var t=n.storage,r=t.setItem,i=t.removeItem,a=t.getItem;return function(n){return function(t){return function(u){var c=u.userId,s=u.traits,l=u.options;if(u.type===q$1.reset&&([_,x$1,A$1].forEach(function(e){i(e);}),[k$1,T,"traits"].forEach(function(e){i$2(D(e));})),u.type===q$1.identify){a(A$1)||r(A$1,y$1());var f=a(_),d=a(x$1)||{};f&&f!==c&&n.dispatch({type:q$1.userIdChanged,old:{userId:f,traits:d},new:{userId:c,traits:s},options:l}),c&&r(_,c),s&&r(x$1,v({},d,s));}return t(u)}}}}var X={};function J$2(e,n){X[e]&&W$2(X[e])&&(X[e](n),delete X[e]);}function W$1(e,n,t){return new Promise(function(r,i){return n()?r(e):t<1?i(v({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(a){return W$1(e,n,t-10).then(r,i)})})}function H$1(e,n,t){var r=n(),i=e.getState(),a=i.plugins,o=i.queue,u=i.user;if(!i.context.offline&&o&&o.actions&&o.actions.length){var c=o.actions.reduce(function(e,n,t){return a[n.plugin].loaded?(e.process.push(n),e.processIndex.push(t)):(e.requeue.push(n),e.requeueIndex.push(t)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(c.processIndex&&c.processIndex.length){c.processIndex.forEach(function(n){var i=o.actions[n],c=i.plugin,s=i.payload.type,l=r[c][s];if(l&&W$2(l)){var f=function(e,n){return void 0===e&&(e={}),void 0===n&&(n={}),[k$1,T].reduce(function(t,r){return e.hasOwnProperty(r)&&n[r]&&n[r]!==e[r]&&(t[r]=n[r]),t},e)}(i.payload,u);l({payload:f,config:a[c].config,instance:t});var p=s+":"+c;e.dispatch(v({},f,{type:p,_:{called:p,from:"queueDrain"}}));}});var s=o.actions.filter(function(e,n){return !~c.processIndex.indexOf(n)});o.actions=s;}}}var F$2=function(e){var n=e.data,t=e.action,r=e.instance,i=e.state,a=e.allPlugins,o=e.allMatches,u=e.store,c=e.EVENTS;try{var s=i.plugins,f=i.context,p=t.type,m=p.match(G$1),g=n.exact.map(function(e){return e.pluginName});m&&(g=o.during.map(function(e){return e.pluginName}));var h=function(e,n){return function(t,r,i){var a=r.config,o=r.name,u=o+"."+t.type;i&&(u=i.event);var c=t.type.match(G$1)?function(e,n,t,r,i){return function(a,o){var u=r?r.name:e,c=o&&ie(o)?o:t;if(r&&(!(c=o&&ie(o)?o:[e]).includes(e)||1!==c.length))throw new Error("Method "+n+" can only abort "+e+" plugin. "+JSON.stringify(c)+" input valid");return v({},i,{abort:{reason:a,plugins:c,caller:n,_:u}})}}(o,u,n,i,t):function(e,n){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+n)}}(t,u);return {payload:ue(t),instance:e,config:a||{},abort:c}}}(r,g),y=n.exact.reduce(function(e,n){var t=n.pluginName,r=n.methodName,i=!1;return r.match(/^initialize/)||r.match(/^reset/)||(i=!s[t].loaded),f.offline&&r.match(/^(page|track|identify)/)&&(i=!0),e[""+t]=i,e},{});return Promise.resolve(n.exact.reduce(function(e,i,o){try{var u=i.pluginName;return Promise.resolve(e).then(function(e){function i(){return Promise.resolve(e)}var o=function(){if(n.namespaced&&n.namespaced[u])return Promise.resolve(n.namespaced[u].reduce(function(e,n,t){try{return Promise.resolve(e).then(function(e){return n.method&&W$2(n.method)?(function(e,n){var t=oe(e);if(t&&t.name===n){var r=oe(t.method);throw new Error([n+" plugin is calling method "+e,"Plugins cant call self","Use "+t.method+" "+(r?"or "+r.method:"")+" in "+n+" plugin insteadof "+e].join("\n"))}}(n.methodName,n.pluginName),Promise.resolve(n.method({payload:e,instance:r,abort:(t=e,i=u,o=n.pluginName,function(e,n){return v({},t,{abort:{reason:e,plugins:n||[i],caller:p,from:o||i}})}),config:Z(n.pluginName,s,a),plugins:s})).then(function(n){var t=on$1(n)?n:{};return Promise.resolve(v({},e,t))})):e;var t,i,o;})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(n){e[u]=n;});e[u]=t;}();return o&&o.then?o.then(i):i()})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(e){return Promise.resolve(n.exact.reduce(function(t,i,o){try{var c=n.exact.length===o+1,f=i.pluginName,d=a[f];return Promise.resolve(t).then(function(n){var t=e[f]?e[f]:{};if(m&&(t=n),te(t,f))return Y$1({data:t,method:p,instance:r,pluginName:f,store:u}),Promise.resolve(n);if(te(n,f))return c&&Y$1({data:n,method:p,instance:r,store:u}),Promise.resolve(n);if(y.hasOwnProperty(f)&&!0===y[f])return u.dispatch({type:"queue",plugin:f,payload:t,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(n);var i=h(e[f],a[f]);return Promise.resolve(d[p]({abort:i.abort,payload:t,instance:r,config:Z(f,s,a),plugins:s})).then(function(i){var a=on$1(i)?i:{},o=v({},n,a),c=e[f];if(te(c,f))Y$1({data:c,method:p,instance:r,pluginName:f,store:u});else {var s=p+":"+f;(s.match(/:/g)||[]).length<2&&!p.match(K)&&!p.match(Q)&&r.dispatch(v({},m?o:t,{type:s,_:{called:s,from:"submethod"}}));}return Promise.resolve(o)})})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(e){if(!(p.match(G$1)||p.match(/^registerPlugin/)||p.match(Q)||p.match(K)||p.match(/^params/)||p.match(/^userIdChanged/))){if(c.plugins.includes(p),e._&&e._.originalAction===p)return e;var t=v({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});re(e,n.exact.length)&&!p.match(/End$/)&&(t=v({},t,{type:e.type+"Aborted"})),u.dispatch(t);}return e})})}catch(e){return Promise.reject(e)}},G$1=/Start$/,K=/^bootstrap/,Q=/^ready/;function Y$1(e){var n=e.pluginName,t=e.method+"Aborted"+(n?":"+n:"");e.store.dispatch(v({},e.data,{type:t,_:{called:t,from:"abort"}}));}function Z(e,n,t){var r=n[e]||t[e];return r&&r.config?r.config:{}}function ee(e,n){return n.reduce(function(n,t){return t[e]?n.concat({methodName:e,pluginName:t.name,method:t[e]}):n},[])}function ne(e,n){var t=e.replace(G$1,""),r=n?":"+n:"";return [""+e+r,""+t+r,t+"End"+r]}function te(e,n){var t=e.abort;return !!t&&(!0===t||ae(t,n)||t&&ae(t.plugins,n))}function re(e,n){var t=e.abort;if(!t)return !1;if(!0===t||q$2(t))return !0;var r=t.plugins;return ie(t)&&t.length===n||ie(r)&&r.length===n}function ie(e){return Array.isArray(e)}function ae(e,n){return !(!e||!ie(e))&&e.includes(n)}function oe(e){var n=e.match(/(.*):(.*)/);return !!n&&{method:n[1],name:n[2]}}function ue(e){return Object.keys(e).reduce(function(n,t){return "type"===t||(n[t]=on$1(e[t])?Object.assign({},e[t]):e[t]),n},{})}function ce(e,n,t){var r={};return function(i){return function(a){return function(o){try{var u,c=function(e){return u?e:a(f)},s=o.type,l=o.plugins,f=o;if(o.abort)return Promise.resolve(a(o));if(s===q$1.enablePlugin&&i.dispatch({type:q$1.initializeStart,plugins:l,disabled:[],fromEnable:!0,meta:o.meta}),s===q$1.disablePlugin&&setTimeout(function(){return J$2(o.meta.rid,{payload:o})},0),s===q$1.initializeEnd){var m=n(),g=Object.keys(m),h=g.filter(function(e){return l.includes(e)}).map(function(e){return m[e]}),y=[],b=[],I=o.disabled,w=h.map(function(e){var n=e.loaded,t=e.name,a=e.config;return W$1(e,function(){return n({config:a})},1e4).then(function(n){return r[t]||(i.dispatch({type:q$1.pluginReadyType(t),name:t,events:Object.keys(e).filter(function(e){return !M$1.includes(e)})}),r[t]=!0),y=y.concat(t),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return b=b.concat(e.name),e})});Promise.all(w).then(function(e){var n={plugins:y,failed:b,disabled:I};setTimeout(function(){g.length===w.length+I.length&&i.dispatch(v({},{type:q$1.ready},n));},0);});}var E=function(){if(s!==q$1.bootstrap)return /^ready:([^:]*)$/.test(s)&&setTimeout(function(){return H$1(i,n,e)},0),Promise.resolve(function(e,n,t,r,i){try{var a=W$2(n)?n():n,o=e.type,u=o.replace(G$1,"");if(e._&&e._.called)return Promise.resolve(e);var c=t.getState(),s=(m=a,void 0===(g=c.plugins)&&(g={}),void 0===(h=e.options)&&(h={}),Object.keys(m).filter(function(e){var n=h.plugins||{};return Q$1(n[e])?n[e]:!1!==n.all&&(!g[e]||!1!==g[e].enabled)}).map(function(e){return m[e]}));o===q$1.initializeStart&&e.fromEnable&&(s=Object.keys(c.plugins).filter(function(n){var t=c.plugins[n];return e.plugins.includes(n)&&!t.initialized}).map(function(e){return a[e]}));var l=s.map(function(e){return e.name}),f=function(e,n,t){var r=ne(e).map(function(e){return ee(e,n)});return n.reduce(function(t,r){var i=r.name,a=ne(e,i).map(function(e){return ee(e,n)}),o=a[0],u=a[1],c=a[2];return o.length&&(t.beforeNS[i]=o),u.length&&(t.duringNS[i]=u),c.length&&(t.afterNS[i]=c),t},{before:r[0],beforeNS:{},during:r[1],duringNS:{},after:r[2],afterNS:{}})}(o,s);return Promise.resolve(F$2({action:e,data:{exact:f.before,namespaced:f.beforeNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){function n(){var n=function(){if(o.match(G$1))return Promise.resolve(F$2({action:v({},s,{type:u+"End"}),data:{exact:f.after,namespaced:f.afterNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&J$2(e.meta.rid,{payload:e});})}();return n&&n.then?n.then(function(){return e}):e}if(re(e,l.length))return e;var s,d=function(){if(o!==u)return Promise.resolve(F$2({action:v({},e,{type:u}),data:{exact:f.during,namespaced:f.duringNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){s=e;});s=e;}();return d&&d.then?d.then(n):n()})}catch(e){return Promise.reject(e)}var m,g,h;}(o,n,e,i,t)).then(function(e){return u=1,a(e)})}();return Promise.resolve(E&&E.then?E.then(c):c(E))}catch(e){return Promise.reject(e)}}}}}function se(e){return function(n){return function(n){return function(t){var r=t.type,i=t.key,a=t.value,o=t.options;if(r===q$1.setItem||r===q$1.removeItem){if(t.abort)return n(t);r===q$1.setItem?e.setItem(i,a,o):e.removeItem(i,o);}return n(t)}}}}var le=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(n,t){e[t]=e[t].concat(n);},this.removeMiddleware=function(n,t){var r=e[t].findIndex(function(e){return e===n});-1!==r&&(e[t]=[].concat(e[t].slice(0,r),e[t].slice(r+1)));},this.dynamicMiddlewares=function(n){return function(t){return function(r){return function(i){var a={getState:t.getState,dispatch:function(e){return t.dispatch(e)}},o=e[n].map(function(e){return e(a)});return N$1.apply(void 0,o)(r)(i)}}}};};function fe(e){return function(n,t){void 0===n&&(n={});var r={};if("initialize:aborted"===t.type)return n;if(/^registerPlugin:([^:]*)$/.test(t.type)){var i=de(t.type,"registerPlugin"),a=e()[i];if(!a||!i)return n;var o=t.enabled,u=a.config;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded({config:u})),config:u},v({},n,r)}if(/^initialize:([^:]*)$/.test(t.type)){var c=de(t.type,q$1.initialize),s=e()[c];return s&&c?(r[c]=v({},n[c],{initialized:!0,loaded:Boolean(s.loaded({config:s.config}))}),v({},n,r)):n}if(/^ready:([^:]*)$/.test(t.type))return r[t.name]=v({},n[t.name],{loaded:!0}),v({},n,r);switch(t.type){case q$1.disablePlugin:return v({},n,pe(t.plugins,!1,n));case q$1.enablePlugin:return v({},n,pe(t.plugins,!0,n));default:return n}}}function de(e,n){return e.substring(n.length+1,e.length)}function pe(e,n,t){return e.reduce(function(e,r){return e[r]=v({},t[r],{enabled:n}),e},t)}function me(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var ge={last:{},history:[]};function he(e,n){void 0===e&&(e=ge);var t=n.options,r=n.meta;if(n.type===q$1.track){var i=me(v({event:n.event,properties:n.properties},Object.keys(t).length&&{options:t},{meta:r}));return v({},e,{last:i,history:e.history.concat(i)})}return e}var ve={actions:[]};function ye(e,n){void 0===e&&(e=ve);var t=n.payload;switch(n.type){case"queue":var r;return r=t&&t.type&&t.type===q$1.identify?[n].concat(e.actions):e.actions.concat(n),v({},e,{actions:r});case"dequeue":return [];default:return e}}var be=/#.*$/;function Ie(e){var n=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(n&&n[3]?n[3].split("?")[0].replace(be,""):"")}var we,Ee,Pe,Se,Ne=function(e){if(void 0===e&&(e={}),!$$2)return e;var n=document,t=n.title,r=n.referrer,i=window,a=i.location,o=i.innerWidth,u=i.innerHeight,c=a.hash,s=a.search,l=function(e){var n=function(){if($$2)for(var e,n=document.getElementsByTagName("link"),t=0;e=n[t];t++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return n?n.match(/\?/)?n:n+e:window.location.href.replace(be,"")}(s),f={title:t,url:l,path:Ie(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),v({},f,e)},Oe={last:{},history:[]};function Ae(e,n){void 0===e&&(e=Oe);var t=n.options;if(n.type===q$1.page){var r=me(v({properties:n.properties,meta:n.meta},Object.keys(t).length&&{options:t}));return v({},e,{last:r,history:e.history.concat(r)})}return e}we=function(){if(!$$2)return !1;var e=navigator.appVersion;return ~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Ee=$$2?document.referrer:null,Pe=o$2(),Se=a$3();var _e={initialized:!1,sessionId:y$1(),app:null,version:null,debug:!1,offline:!!$$2&&!navigator.onLine,os:{name:we},userAgent:$$2?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.5"},timezone:Se,locale:Pe,campaign:{},referrer:Ee};function xe(e,n){void 0===e&&(e=_e);var t=e.initialized,r=n.campaign;switch(n.type){case q$1.campaign:return v({},e,{campaign:r});case q$1.offline:return v({},e,{offline:!0});case q$1.online:return v({},e,{offline:!1});default:return t?e:v({},_e,e,{initialized:!0})}}var je=["plugins","reducers","storage"];function ke(e,n,t){if($$2){var r=window[(t?"add":"remove")+"EventListener"];e.split(" ").forEach(function(e){r(e,n);});}}function Te(e){var n=ke.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return n(!0),function(e){return n(!1)}}function ze(){return f("analytics",[]),function(e){return function(n$1,t,r){var i=e(n$1,t,r),a=i.dispatch;return Object.assign(i,{dispatch:function(e){return n[o].analytics.push(e.action||e),a(e)}})}}}function Me(e){return function(){return N$1(N$1.apply(null,arguments),ze())}}function qe(e){return e?rn(e)?e:[e]:[]}function Ue(n,t,r){void 0===n&&(n={});var i,a,o=y$1();return t&&(X[o]=(i=t,a=function(e){for(var n,t=e||Array.prototype.slice.call(arguments),r=0;r<t.length;r++)if(W$2(t[r])){n=t[r];break}return n}(r),function(e){a&&a(e),i(e);})),v({},n,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function Ve(n){void 0===n&&(n={});var t=n.reducers||{},c=n.initialUser||{},s$1=(n.plugins||[]).reduce(function(e,n){if(W$2(n))return e.middlewares=e.middlewares.concat(n),e;if(n.NAMESPACE&&(n.name=n.NAMESPACE),!n.name)throw new Error("https://lytics.dev/errors/1");n.config||(n.config={});var t=n.EVENTS?Object.keys(n.EVENTS).map(function(e){return n.EVENTS[e]}):[];e.pluginEnabled[n.name]=!(!1===n.enabled||!1===n.config.enabled),delete n.enabled,n.methods&&(e.methods[n.name]=Object.keys(n.methods).reduce(function(e,t){var r;return e[t]=(r=n.methods[t],function(){for(var e=Array.prototype.slice.call(arguments),n=new Array(r.length),t=0;t<e.length;t++)n[t]=e[t];return n[n.length]=Q,r.apply({instance:Q},n)}),e},{}),delete n.methods);var r=Object.keys(n).concat(t),i=new Set(e.events.concat(r));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(n),e.plugins[n.name])throw new Error(n.name+"AlreadyLoaded");return e.plugins[n.name]=n,e.plugins[n.name].loaded||(e.plugins[n.name].loaded=function(){return !0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),f$1=n.storage?n.storage:{getItem:a$2,setItem:f,removeItem:i$2},p=function(e){return function(n,t,r){return t.getState("user")[n]||(r&&on$1(r)&&r[n]?r[n]:$$1(e)[n]||a$2(D(n))||null)}}(f$1),h=s$1.plugins,w=s$1.events.filter(function(e){return !M$1.includes(e)}).sort(),E=new Set(w.concat(z).filter(function(e){return !M$1.includes(e)})),_=Array.from(E).sort(),x=function(){return h},j=new le,U=j.addMiddleware,V=j.removeMiddleware,L=j.dynamicMiddlewares,X=function(){throw new Error("Abort disabled inListener")},J=s(),W=$$1(f$1),F=v({},W,c,J.an_uid?{userId:J.an_uid}:{},J.an_aid?{anonymousId:J.an_aid}:{});F.anonymousId||(F.anonymousId=y$1());var G=v({enable:function(e,n){return new Promise(function(t){ue.dispatch({type:q$1.enablePlugin,plugins:qe(e),_:{originalAction:q$1.enablePlugin}},t,[n]);})},disable:function(e,n){return new Promise(function(t){ue.dispatch({type:q$1.disablePlugin,plugins:qe(e),_:{originalAction:q$1.disablePlugin}},t,[n]);})}},s$1.methods),K=!1,Q={identify:function(e,n,t,r){try{var i=q$2(e)?e:null,a=on$1(e)?e:n,o=t||{},c=Q.user();f(D(k$1),i);var s=i||a.userId||p(k$1,Q,a);return Promise.resolve(new Promise(function(e){ue.dispatch(v({type:q$1.identifyStart,userId:s,traits:a||{},options:o,anonymousId:c.anonymousId},c.id&&c.id!==i&&{previousId:c.id}),e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},track:function(e,n,t,r){try{var i=on$1(e)?e.event:e;if(!i||!q$2(i))throw new Error("EventMissing");var a=on$1(e)?e:n||{},o=on$1(t)?t:{};return Promise.resolve(new Promise(function(e){ue.dispatch({type:q$1.trackStart,event:i,properties:a,options:o,userId:p(k$1,Q,n),anonymousId:p(T,Q,n)},e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},page:function(e,n,t){try{var r=on$1(e)?e:{},i=on$1(n)?n:{};return Promise.resolve(new Promise(function(a){ue.dispatch({type:q$1.pageStart,properties:Ne(r),options:i,userId:p(k$1,Q,r),anonymousId:p(T,Q,r)},a,[e,n,t]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===k$1||"id"===e)return p(k$1,Q);if(e===T||"anonId"===e)return p(T,Q);var n=Q.getState("user");return e?i$3(n,e):n},reset:function(e){return new Promise(function(n){ue.dispatch({type:q$1.resetStart},n,e);})},ready:function(e){return K&&e({plugins:G,instance:Q}),Q.on(q$1.ready,function(n){e(n),K=!0;})},on:function(e,n){if(!e||!W$2(n))return !1;if(e===q$1.bootstrap)throw new Error(".on disabled for "+e);var t=/Start$|Start:/;if("*"===e){var r=function(e){return function(e){return function(r){return r.type.match(t)&&n({payload:r,instance:Q,plugins:h}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(t)||n({payload:r,instance:Q,plugins:h}),e(r)}}};return U(r,Le),U(i,Ce),function(){V(r,Le),V(i,Ce);}}var a=e.match(t)?Le:Ce,o=function(t){return function(t){return function(r){return r.type===e&&n({payload:r,instance:Q,plugins:h,abort:X}),t(r)}}};return U(o,a),function(){return V(o,a)}},once:function(e,n){if(!e||!W$2(n))return !1;if(e===q$1.bootstrap)throw new Error(".once disabled for "+e);var t=Q.on(e,function(e){n({payload:e.payload,instance:Q,plugins:h,abort:X}),t();});return t},getState:function(e){var n=ue.getState();return e?i$3(n,e):Object.assign({},n)},dispatch:function(e){var n=q$2(e)?{type:e}:e;if(z.includes(n.type))throw new Error("reserved action "+n.type);var t=v({},n,{_:v({originalAction:n.type},e._||{})});ue.dispatch(t);},enablePlugin:G.enable,disablePlugin:G.disable,plugins:G,storage:{getItem:f$1.getItem,setItem:function(e,n,t){ue.dispatch({type:q$1.setItemStart,key:e,value:n,options:t});},removeItem:function(e,n){ue.dispatch({type:q$1.removeItemStart,key:e,options:n});}},setAnonymousId:function(e,n){Q.storage.setItem(A$1,e,n);},events:{core:z,plugins:w}},Y=s$1.middlewares.concat([function(e){return function(e){return function(n){return n.meta||(n.meta=Ue()),e(n)}}},L(Le),ce(Q,x,{all:_,plugins:w}),se(f$1),C$1(Q),B(Q),L(Ce)]),Z={context:xe,user:R$1(f$1),page:Ae,track:he,plugins:fe(x),queue:ye},ee=N$1,ne=N$1;if($$2&&n.debug){var te=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;te&&(ee=te({trace:!0,traceLimit:25})),ne=function(){return 0===arguments.length?ze():on$1(typeof arguments[0])?Me():Me().apply(null,arguments)};}var re,ie=function(e){return Object.keys(e).reduce(function(n,t){return je.includes(t)||(n[t]=e[t]),n},{})}(n),ae=s$1.pluginsArray.reduce(function(e,n){var t=n.name,r=n.config,i=n.loaded,a=s$1.pluginEnabled[t];return e[t]={enabled:a,initialized:!!a&&Boolean(!n.initialize),loaded:Boolean(i({config:r})),config:r},e},{}),oe={context:ie,user:F,plugins:ae},ue=P(function(e){for(var n=Object.keys(e),t={},r=0;r<n.length;r++){var i=n[r];typeof e[i]===y&&(t[i]=e[i]);}var a,o=Object.keys(t);try{!function(e){Object.keys(e).forEach(function(n){var t=e[n];if(typeof t(void 0,{type:"@@redux/INIT"})===b$2||typeof t(void 0,{type:I$2})===b$2)throw new Error("reducer "+n+" "+b$2)});}(t);}catch(e){a=e;}return function(e,n){if(void 0===e&&(e={}),a)throw a;for(var r=!1,i={},u=0;u<o.length;u++){var c=o[u],s=e[c],l=(0, t[c])(s,n);if(typeof l===b$2){var f=S(c,n);throw new Error(f)}i[c]=l,r=r||l!==s;}return r?i:e}}(v({},Z,t)),oe,ne(ee(O$1.apply(void 0,Y))));ue.dispatch=(re=ue.dispatch,function(e,n,t){var r=v({},e,{meta:Ue(e.meta,n,qe(t))});return re.apply(null,[r])});var de=Object.keys(h);ue.dispatch({type:q$1.bootstrap,plugins:de,config:ie,params:J,user:F,initialUser:c,persistedUser:W});var pe=de.filter(function(e){return s$1.pluginEnabled[e]}),me=de.filter(function(e){return !s$1.pluginEnabled[e]});return ue.dispatch({type:q$1.registerPlugins,plugins:de,enabled:s$1.pluginEnabled}),s$1.pluginsArray.map(function(e,n){var t=e.bootstrap,r=e.config,i=e.name;t&&W$2(t)&&t({instance:Q,config:r,payload:e}),ue.dispatch({type:q$1.registerPluginType(i),name:i,enabled:s$1.pluginEnabled[i],plugin:e}),s$1.pluginsArray.length===n+1&&ue.dispatch({type:q$1.initializeStart,plugins:pe,disabled:me});}),Te(function(e){ue.dispatch({type:e?q$1.offline:q$1.online});}),function(e,n,t){setInterval(function(){return H$1(e,n,t)},3e3);}(ue,x,Q),Q}var Le="before",Ce="after";
1257
1256
 
1258
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
1259
- arr2[i] = arr[i];
1260
- }
1261
-
1262
- return arr2;
1263
- }
1264
-
1265
- function _arrayWithoutHoles(arr) {
1266
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1267
- }
1268
-
1269
- function _iterableToArray(iter) {
1270
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1271
- }
1272
-
1273
- function _unsupportedIterableToArray(o, minLen) {
1274
- if (!o) return;
1275
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1276
- var n = Object.prototype.toString.call(o).slice(8, -1);
1277
- if (n === "Object" && o.constructor) n = o.constructor.name;
1278
- if (n === "Map" || n === "Set") return Array.from(o);
1279
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1280
- }
1281
-
1282
- function _nonIterableSpread() {
1283
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1284
- }
1285
-
1286
- function _toConsumableArray(arr) {
1287
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1288
- }
1289
-
1290
- function _typeof(obj) {
1291
- "@babel/helpers - typeof";
1292
-
1293
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1294
- return typeof obj;
1295
- } : function (obj) {
1296
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1297
- }, _typeof(obj);
1298
- }
1299
-
1300
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1301
- try {
1302
- var info = gen[key](arg);
1303
- var value = info.value;
1304
- } catch (error) {
1305
- reject(error);
1306
- return;
1307
- }
1308
-
1309
- if (info.done) {
1310
- resolve(value);
1311
- } else {
1312
- Promise.resolve(value).then(_next, _throw);
1313
- }
1314
- }
1315
-
1316
- function _asyncToGenerator(fn) {
1317
- return function () {
1318
- var self = this,
1319
- args = arguments;
1320
- return new Promise(function (resolve, reject) {
1321
- var gen = fn.apply(self, args);
1322
-
1323
- function _next(value) {
1324
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1325
- }
1326
-
1327
- function _throw(err) {
1328
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1329
- }
1330
-
1331
- _next(undefined);
1332
- });
1333
- };
1334
- }
1335
-
1336
- function _defineProperty$1(obj, key, value) {
1337
- if (key in obj) {
1338
- Object.defineProperty(obj, key, {
1339
- value: value,
1340
- enumerable: true,
1341
- configurable: true,
1342
- writable: true
1343
- });
1344
- } else {
1345
- obj[key] = value;
1346
- }
1347
-
1348
- return obj;
1349
- }
1350
-
1351
- function ownKeys$1(object, enumerableOnly) {
1352
- var keys = Object.keys(object);
1353
-
1354
- if (Object.getOwnPropertySymbols) {
1355
- var symbols = Object.getOwnPropertySymbols(object);
1356
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1357
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1358
- })), keys.push.apply(keys, symbols);
1359
- }
1360
-
1361
- return keys;
1362
- }
1363
-
1364
- function _objectSpread2$1(target) {
1365
- for (var i = 1; i < arguments.length; i++) {
1366
- var source = null != arguments[i] ? arguments[i] : {};
1367
- i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
1368
- _defineProperty$1(target, key, source[key]);
1369
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
1370
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1371
- });
1372
- }
1373
-
1374
- return target;
1375
- }
1376
-
1377
- var runtime = {exports: {}};
1378
-
1379
- (function (module) {
1380
- var runtime = function (exports) {
1381
-
1382
- var Op = Object.prototype;
1383
- var hasOwn = Op.hasOwnProperty;
1384
- var undefined$1; // More compressible than void 0.
1385
-
1386
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
1387
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
1388
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
1389
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
1390
-
1391
- function define(obj, key, value) {
1392
- Object.defineProperty(obj, key, {
1393
- value: value,
1394
- enumerable: true,
1395
- configurable: true,
1396
- writable: true
1397
- });
1398
- return obj[key];
1399
- }
1400
-
1401
- try {
1402
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
1403
- define({}, "");
1404
- } catch (err) {
1405
- define = function (obj, key, value) {
1406
- return obj[key] = value;
1407
- };
1408
- }
1409
-
1410
- function wrap(innerFn, outerFn, self, tryLocsList) {
1411
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
1412
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
1413
- var generator = Object.create(protoGenerator.prototype);
1414
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
1415
- // .throw, and .return methods.
1416
-
1417
- generator._invoke = makeInvokeMethod(innerFn, self, context);
1418
- return generator;
1419
- }
1420
-
1421
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
1422
- // record like context.tryEntries[i].completion. This interface could
1423
- // have been (and was previously) designed to take a closure to be
1424
- // invoked without arguments, but in all the cases we care about we
1425
- // already have an existing method we want to call, so there's no need
1426
- // to create a new function object. We can even get away with assuming
1427
- // the method takes exactly one argument, since that happens to be true
1428
- // in every case, so we don't have to touch the arguments object. The
1429
- // only additional allocation required is the completion record, which
1430
- // has a stable shape and so hopefully should be cheap to allocate.
1431
-
1432
- function tryCatch(fn, obj, arg) {
1433
- try {
1434
- return {
1435
- type: "normal",
1436
- arg: fn.call(obj, arg)
1437
- };
1438
- } catch (err) {
1439
- return {
1440
- type: "throw",
1441
- arg: err
1442
- };
1443
- }
1444
- }
1445
-
1446
- var GenStateSuspendedStart = "suspendedStart";
1447
- var GenStateSuspendedYield = "suspendedYield";
1448
- var GenStateExecuting = "executing";
1449
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
1450
- // breaking out of the dispatch switch statement.
1451
-
1452
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
1453
- // .constructor.prototype properties for functions that return Generator
1454
- // objects. For full spec compliance, you may wish to configure your
1455
- // minifier not to mangle the names of these two functions.
1456
-
1457
- function Generator() {}
1458
-
1459
- function GeneratorFunction() {}
1460
-
1461
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
1462
- // don't natively support it.
1463
-
1464
-
1465
- var IteratorPrototype = {};
1466
- define(IteratorPrototype, iteratorSymbol, function () {
1467
- return this;
1468
- });
1469
- var getProto = Object.getPrototypeOf;
1470
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
1471
-
1472
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
1473
- // This environment has a native %IteratorPrototype%; use it instead
1474
- // of the polyfill.
1475
- IteratorPrototype = NativeIteratorPrototype;
1476
- }
1477
-
1478
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
1479
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
1480
- define(Gp, "constructor", GeneratorFunctionPrototype);
1481
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
1482
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
1483
- // Iterator interface in terms of a single ._invoke method.
1484
-
1485
- function defineIteratorMethods(prototype) {
1486
- ["next", "throw", "return"].forEach(function (method) {
1487
- define(prototype, method, function (arg) {
1488
- return this._invoke(method, arg);
1489
- });
1490
- });
1491
- }
1492
-
1493
- exports.isGeneratorFunction = function (genFun) {
1494
- var ctor = typeof genFun === "function" && genFun.constructor;
1495
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
1496
- // do is to check its .name property.
1497
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
1498
- };
1499
-
1500
- exports.mark = function (genFun) {
1501
- if (Object.setPrototypeOf) {
1502
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
1503
- } else {
1504
- genFun.__proto__ = GeneratorFunctionPrototype;
1505
- define(genFun, toStringTagSymbol, "GeneratorFunction");
1506
- }
1507
-
1508
- genFun.prototype = Object.create(Gp);
1509
- return genFun;
1510
- }; // Within the body of any async function, `await x` is transformed to
1511
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
1512
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
1513
- // meant to be awaited.
1514
-
1515
-
1516
- exports.awrap = function (arg) {
1517
- return {
1518
- __await: arg
1519
- };
1520
- };
1521
-
1522
- function AsyncIterator(generator, PromiseImpl) {
1523
- function invoke(method, arg, resolve, reject) {
1524
- var record = tryCatch(generator[method], generator, arg);
1525
-
1526
- if (record.type === "throw") {
1527
- reject(record.arg);
1528
- } else {
1529
- var result = record.arg;
1530
- var value = result.value;
1531
-
1532
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
1533
- return PromiseImpl.resolve(value.__await).then(function (value) {
1534
- invoke("next", value, resolve, reject);
1535
- }, function (err) {
1536
- invoke("throw", err, resolve, reject);
1537
- });
1538
- }
1539
-
1540
- return PromiseImpl.resolve(value).then(function (unwrapped) {
1541
- // When a yielded Promise is resolved, its final value becomes
1542
- // the .value of the Promise<{value,done}> result for the
1543
- // current iteration.
1544
- result.value = unwrapped;
1545
- resolve(result);
1546
- }, function (error) {
1547
- // If a rejected Promise was yielded, throw the rejection back
1548
- // into the async generator function so it can be handled there.
1549
- return invoke("throw", error, resolve, reject);
1550
- });
1551
- }
1552
- }
1553
-
1554
- var previousPromise;
1555
-
1556
- function enqueue(method, arg) {
1557
- function callInvokeWithMethodAndArg() {
1558
- return new PromiseImpl(function (resolve, reject) {
1559
- invoke(method, arg, resolve, reject);
1560
- });
1561
- }
1562
-
1563
- return previousPromise = // If enqueue has been called before, then we want to wait until
1564
- // all previous Promises have been resolved before calling invoke,
1565
- // so that results are always delivered in the correct order. If
1566
- // enqueue has not been called before, then it is important to
1567
- // call invoke immediately, without waiting on a callback to fire,
1568
- // so that the async generator function has the opportunity to do
1569
- // any necessary setup in a predictable way. This predictability
1570
- // is why the Promise constructor synchronously invokes its
1571
- // executor callback, and why async functions synchronously
1572
- // execute code before the first await. Since we implement simple
1573
- // async functions in terms of async generators, it is especially
1574
- // important to get this right, even though it requires care.
1575
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
1576
- // invocations of the iterator.
1577
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
1578
- } // Define the unified helper method that is used to implement .next,
1579
- // .throw, and .return (see defineIteratorMethods).
1580
-
1581
-
1582
- this._invoke = enqueue;
1583
- }
1584
-
1585
- defineIteratorMethods(AsyncIterator.prototype);
1586
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
1587
- return this;
1588
- });
1589
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
1590
- // AsyncIterator objects; they just return a Promise for the value of
1591
- // the final result produced by the iterator.
1592
-
1593
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
1594
- if (PromiseImpl === void 0) PromiseImpl = Promise;
1595
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
1596
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
1597
- : iter.next().then(function (result) {
1598
- return result.done ? result.value : iter.next();
1599
- });
1600
- };
1601
-
1602
- function makeInvokeMethod(innerFn, self, context) {
1603
- var state = GenStateSuspendedStart;
1604
- return function invoke(method, arg) {
1605
- if (state === GenStateExecuting) {
1606
- throw new Error("Generator is already running");
1607
- }
1608
-
1609
- if (state === GenStateCompleted) {
1610
- if (method === "throw") {
1611
- throw arg;
1612
- } // Be forgiving, per 25.3.3.3.3 of the spec:
1613
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
1614
-
1615
-
1616
- return doneResult();
1617
- }
1618
-
1619
- context.method = method;
1620
- context.arg = arg;
1621
-
1622
- while (true) {
1623
- var delegate = context.delegate;
1624
-
1625
- if (delegate) {
1626
- var delegateResult = maybeInvokeDelegate(delegate, context);
1627
-
1628
- if (delegateResult) {
1629
- if (delegateResult === ContinueSentinel) continue;
1630
- return delegateResult;
1631
- }
1632
- }
1633
-
1634
- if (context.method === "next") {
1635
- // Setting context._sent for legacy support of Babel's
1636
- // function.sent implementation.
1637
- context.sent = context._sent = context.arg;
1638
- } else if (context.method === "throw") {
1639
- if (state === GenStateSuspendedStart) {
1640
- state = GenStateCompleted;
1641
- throw context.arg;
1642
- }
1643
-
1644
- context.dispatchException(context.arg);
1645
- } else if (context.method === "return") {
1646
- context.abrupt("return", context.arg);
1647
- }
1648
-
1649
- state = GenStateExecuting;
1650
- var record = tryCatch(innerFn, self, context);
1651
-
1652
- if (record.type === "normal") {
1653
- // If an exception is thrown from innerFn, we leave state ===
1654
- // GenStateExecuting and loop back for another invocation.
1655
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
1656
-
1657
- if (record.arg === ContinueSentinel) {
1658
- continue;
1659
- }
1660
-
1661
- return {
1662
- value: record.arg,
1663
- done: context.done
1664
- };
1665
- } else if (record.type === "throw") {
1666
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
1667
- // context.dispatchException(context.arg) call above.
1668
-
1669
- context.method = "throw";
1670
- context.arg = record.arg;
1671
- }
1672
- }
1673
- };
1674
- } // Call delegate.iterator[context.method](context.arg) and handle the
1675
- // result, either by returning a { value, done } result from the
1676
- // delegate iterator, or by modifying context.method and context.arg,
1677
- // setting context.delegate to null, and returning the ContinueSentinel.
1678
-
1679
-
1680
- function maybeInvokeDelegate(delegate, context) {
1681
- var method = delegate.iterator[context.method];
1682
-
1683
- if (method === undefined$1) {
1684
- // A .throw or .return when the delegate iterator has no .throw
1685
- // method always terminates the yield* loop.
1686
- context.delegate = null;
1687
-
1688
- if (context.method === "throw") {
1689
- // Note: ["return"] must be used for ES3 parsing compatibility.
1690
- if (delegate.iterator["return"]) {
1691
- // If the delegate iterator has a return method, give it a
1692
- // chance to clean up.
1693
- context.method = "return";
1694
- context.arg = undefined$1;
1695
- maybeInvokeDelegate(delegate, context);
1696
-
1697
- if (context.method === "throw") {
1698
- // If maybeInvokeDelegate(context) changed context.method from
1699
- // "return" to "throw", let that override the TypeError below.
1700
- return ContinueSentinel;
1701
- }
1702
- }
1703
-
1704
- context.method = "throw";
1705
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
1706
- }
1707
-
1708
- return ContinueSentinel;
1709
- }
1710
-
1711
- var record = tryCatch(method, delegate.iterator, context.arg);
1712
-
1713
- if (record.type === "throw") {
1714
- context.method = "throw";
1715
- context.arg = record.arg;
1716
- context.delegate = null;
1717
- return ContinueSentinel;
1718
- }
1719
-
1720
- var info = record.arg;
1721
-
1722
- if (!info) {
1723
- context.method = "throw";
1724
- context.arg = new TypeError("iterator result is not an object");
1725
- context.delegate = null;
1726
- return ContinueSentinel;
1727
- }
1728
-
1729
- if (info.done) {
1730
- // Assign the result of the finished delegate to the temporary
1731
- // variable specified by delegate.resultName (see delegateYield).
1732
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
1733
-
1734
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
1735
- // exception, let the outer generator proceed normally. If
1736
- // context.method was "next", forget context.arg since it has been
1737
- // "consumed" by the delegate iterator. If context.method was
1738
- // "return", allow the original .return call to continue in the
1739
- // outer generator.
1740
-
1741
- if (context.method !== "return") {
1742
- context.method = "next";
1743
- context.arg = undefined$1;
1744
- }
1745
- } else {
1746
- // Re-yield the result returned by the delegate method.
1747
- return info;
1748
- } // The delegate iterator is finished, so forget it and continue with
1749
- // the outer generator.
1750
-
1751
-
1752
- context.delegate = null;
1753
- return ContinueSentinel;
1754
- } // Define Generator.prototype.{next,throw,return} in terms of the
1755
- // unified ._invoke helper method.
1756
-
1757
-
1758
- defineIteratorMethods(Gp);
1759
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
1760
- // @@iterator function is called on it. Some browsers' implementations of the
1761
- // iterator prototype chain incorrectly implement this, causing the Generator
1762
- // object to not be returned from this call. This ensures that doesn't happen.
1763
- // See https://github.com/facebook/regenerator/issues/274 for more details.
1764
-
1765
- define(Gp, iteratorSymbol, function () {
1766
- return this;
1767
- });
1768
- define(Gp, "toString", function () {
1769
- return "[object Generator]";
1770
- });
1771
-
1772
- function pushTryEntry(locs) {
1773
- var entry = {
1774
- tryLoc: locs[0]
1775
- };
1776
-
1777
- if (1 in locs) {
1778
- entry.catchLoc = locs[1];
1779
- }
1780
-
1781
- if (2 in locs) {
1782
- entry.finallyLoc = locs[2];
1783
- entry.afterLoc = locs[3];
1784
- }
1785
-
1786
- this.tryEntries.push(entry);
1787
- }
1788
-
1789
- function resetTryEntry(entry) {
1790
- var record = entry.completion || {};
1791
- record.type = "normal";
1792
- delete record.arg;
1793
- entry.completion = record;
1794
- }
1795
-
1796
- function Context(tryLocsList) {
1797
- // The root entry object (effectively a try statement without a catch
1798
- // or a finally block) gives us a place to store values thrown from
1799
- // locations where there is no enclosing try statement.
1800
- this.tryEntries = [{
1801
- tryLoc: "root"
1802
- }];
1803
- tryLocsList.forEach(pushTryEntry, this);
1804
- this.reset(true);
1805
- }
1806
-
1807
- exports.keys = function (object) {
1808
- var keys = [];
1809
-
1810
- for (var key in object) {
1811
- keys.push(key);
1812
- }
1813
-
1814
- keys.reverse(); // Rather than returning an object with a next method, we keep
1815
- // things simple and return the next function itself.
1816
-
1817
- return function next() {
1818
- while (keys.length) {
1819
- var key = keys.pop();
1820
-
1821
- if (key in object) {
1822
- next.value = key;
1823
- next.done = false;
1824
- return next;
1825
- }
1826
- } // To avoid creating an additional object, we just hang the .value
1827
- // and .done properties off the next function object itself. This
1828
- // also ensures that the minifier will not anonymize the function.
1829
-
1830
-
1831
- next.done = true;
1832
- return next;
1833
- };
1834
- };
1835
-
1836
- function values(iterable) {
1837
- if (iterable) {
1838
- var iteratorMethod = iterable[iteratorSymbol];
1839
-
1840
- if (iteratorMethod) {
1841
- return iteratorMethod.call(iterable);
1842
- }
1843
-
1844
- if (typeof iterable.next === "function") {
1845
- return iterable;
1846
- }
1847
-
1848
- if (!isNaN(iterable.length)) {
1849
- var i = -1,
1850
- next = function next() {
1851
- while (++i < iterable.length) {
1852
- if (hasOwn.call(iterable, i)) {
1853
- next.value = iterable[i];
1854
- next.done = false;
1855
- return next;
1856
- }
1857
- }
1858
-
1859
- next.value = undefined$1;
1860
- next.done = true;
1861
- return next;
1862
- };
1863
-
1864
- return next.next = next;
1865
- }
1866
- } // Return an iterator with no values.
1867
-
1868
-
1869
- return {
1870
- next: doneResult
1871
- };
1872
- }
1873
-
1874
- exports.values = values;
1875
-
1876
- function doneResult() {
1877
- return {
1878
- value: undefined$1,
1879
- done: true
1880
- };
1881
- }
1882
-
1883
- Context.prototype = {
1884
- constructor: Context,
1885
- reset: function (skipTempReset) {
1886
- this.prev = 0;
1887
- this.next = 0; // Resetting context._sent for legacy support of Babel's
1888
- // function.sent implementation.
1889
-
1890
- this.sent = this._sent = undefined$1;
1891
- this.done = false;
1892
- this.delegate = null;
1893
- this.method = "next";
1894
- this.arg = undefined$1;
1895
- this.tryEntries.forEach(resetTryEntry);
1896
-
1897
- if (!skipTempReset) {
1898
- for (var name in this) {
1899
- // Not sure about the optimal order of these conditions:
1900
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1901
- this[name] = undefined$1;
1902
- }
1903
- }
1904
- }
1905
- },
1906
- stop: function () {
1907
- this.done = true;
1908
- var rootEntry = this.tryEntries[0];
1909
- var rootRecord = rootEntry.completion;
1910
-
1911
- if (rootRecord.type === "throw") {
1912
- throw rootRecord.arg;
1913
- }
1914
-
1915
- return this.rval;
1916
- },
1917
- dispatchException: function (exception) {
1918
- if (this.done) {
1919
- throw exception;
1920
- }
1921
-
1922
- var context = this;
1923
-
1924
- function handle(loc, caught) {
1925
- record.type = "throw";
1926
- record.arg = exception;
1927
- context.next = loc;
1928
-
1929
- if (caught) {
1930
- // If the dispatched exception was caught by a catch block,
1931
- // then let that catch block handle the exception normally.
1932
- context.method = "next";
1933
- context.arg = undefined$1;
1934
- }
1935
-
1936
- return !!caught;
1937
- }
1938
-
1939
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1940
- var entry = this.tryEntries[i];
1941
- var record = entry.completion;
1942
-
1943
- if (entry.tryLoc === "root") {
1944
- // Exception thrown outside of any try block that could handle
1945
- // it, so set the completion value of the entire function to
1946
- // throw the exception.
1947
- return handle("end");
1948
- }
1949
-
1950
- if (entry.tryLoc <= this.prev) {
1951
- var hasCatch = hasOwn.call(entry, "catchLoc");
1952
- var hasFinally = hasOwn.call(entry, "finallyLoc");
1953
-
1954
- if (hasCatch && hasFinally) {
1955
- if (this.prev < entry.catchLoc) {
1956
- return handle(entry.catchLoc, true);
1957
- } else if (this.prev < entry.finallyLoc) {
1958
- return handle(entry.finallyLoc);
1959
- }
1960
- } else if (hasCatch) {
1961
- if (this.prev < entry.catchLoc) {
1962
- return handle(entry.catchLoc, true);
1963
- }
1964
- } else if (hasFinally) {
1965
- if (this.prev < entry.finallyLoc) {
1966
- return handle(entry.finallyLoc);
1967
- }
1968
- } else {
1969
- throw new Error("try statement without catch or finally");
1970
- }
1971
- }
1972
- }
1973
- },
1974
- abrupt: function (type, arg) {
1975
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1976
- var entry = this.tryEntries[i];
1977
-
1978
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1979
- var finallyEntry = entry;
1980
- break;
1981
- }
1982
- }
1983
-
1984
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1985
- // Ignore the finally entry if control is not jumping to a
1986
- // location outside the try/catch block.
1987
- finallyEntry = null;
1988
- }
1989
-
1990
- var record = finallyEntry ? finallyEntry.completion : {};
1991
- record.type = type;
1992
- record.arg = arg;
1993
-
1994
- if (finallyEntry) {
1995
- this.method = "next";
1996
- this.next = finallyEntry.finallyLoc;
1997
- return ContinueSentinel;
1998
- }
1999
-
2000
- return this.complete(record);
2001
- },
2002
- complete: function (record, afterLoc) {
2003
- if (record.type === "throw") {
2004
- throw record.arg;
2005
- }
2006
-
2007
- if (record.type === "break" || record.type === "continue") {
2008
- this.next = record.arg;
2009
- } else if (record.type === "return") {
2010
- this.rval = this.arg = record.arg;
2011
- this.method = "return";
2012
- this.next = "end";
2013
- } else if (record.type === "normal" && afterLoc) {
2014
- this.next = afterLoc;
2015
- }
2016
-
2017
- return ContinueSentinel;
2018
- },
2019
- finish: function (finallyLoc) {
2020
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2021
- var entry = this.tryEntries[i];
2022
-
2023
- if (entry.finallyLoc === finallyLoc) {
2024
- this.complete(entry.completion, entry.afterLoc);
2025
- resetTryEntry(entry);
2026
- return ContinueSentinel;
2027
- }
2028
- }
2029
- },
2030
- "catch": function (tryLoc) {
2031
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
2032
- var entry = this.tryEntries[i];
2033
-
2034
- if (entry.tryLoc === tryLoc) {
2035
- var record = entry.completion;
2036
-
2037
- if (record.type === "throw") {
2038
- var thrown = record.arg;
2039
- resetTryEntry(entry);
2040
- }
2041
-
2042
- return thrown;
2043
- }
2044
- } // The context.catch method must only be called with a location
2045
- // argument that corresponds to a known catch block.
2046
-
2047
-
2048
- throw new Error("illegal catch attempt");
2049
- },
2050
- delegateYield: function (iterable, resultName, nextLoc) {
2051
- this.delegate = {
2052
- iterator: values(iterable),
2053
- resultName: resultName,
2054
- nextLoc: nextLoc
2055
- };
2056
-
2057
- if (this.method === "next") {
2058
- // Deliberately forget the last sent value so that we don't
2059
- // accidentally pass it on to the delegate.
2060
- this.arg = undefined$1;
2061
- }
2062
-
2063
- return ContinueSentinel;
2064
- }
2065
- }; // Regardless of whether this script is executing as a CommonJS module
2066
- // or not, return the runtime object so that we can declare the variable
2067
- // regeneratorRuntime in the outer scope, which allows this module to be
2068
- // injected easily by `bin/regenerator --include-runtime script.js`.
2069
-
2070
- return exports;
2071
- }( // If this script is executing as a CommonJS module, use module.exports
2072
- // as the regeneratorRuntime namespace. Otherwise create a new empty
2073
- // object. Either way, the resulting object will be used to initialize
2074
- // the regeneratorRuntime variable at the top of this file.
2075
- module.exports );
2076
-
2077
- try {
2078
- regeneratorRuntime = runtime;
2079
- } catch (accidentalStrictMode) {
2080
- // This module should not be running in strict mode, so the above
2081
- // assignment should always work unless something is misconfigured. Just
2082
- // in case runtime.js accidentally runs in strict mode, in modern engines
2083
- // we can explicitly access globalThis. In older engines we can escape
2084
- // strict mode using a global Function call. This could conceivably fail
2085
- // if a Content Security Policy forbids using Function, but in that case
2086
- // the proper solution is to fix the accidental strict mode problem. If
2087
- // you've misconfigured your bundler to force strict mode and applied a
2088
- // CSP to forbid Function, and you're not willing to fix either of those
2089
- // problems, please detail your unique predicament in a GitHub issue.
2090
- if (typeof globalThis === "object") {
2091
- globalThis.regeneratorRuntime = runtime;
2092
- } else {
2093
- Function("r", "regeneratorRuntime = r")(runtime);
2094
- }
2095
- }
2096
- }(runtime));
2097
-
2098
- var regenerator = runtime.exports;
2099
-
2100
- var FUNC = 'function';
2101
- var UNDEF = 'undefined';
2102
- var REDUCER = 'reducer';
2103
- var base = '@@redux/';
2104
- var ACTION_INIT = base + 'INIT';
2105
- var ACTION_TEST = base + Math.random().toString(36);
2106
-
2107
- var $$observable = /* #__PURE__ */function () {
2108
- return (typeof Symbol === "undefined" ? "undefined" : _typeof(Symbol)) === FUNC && Symbol.observable || '@@observable';
2109
- }();
2110
- /*
2111
- * Creates a Redux store that holds the state tree.
2112
- * The only way to change the data in the store is to call `dispatch()` on it.
2113
- *
2114
- * There should only be a single store in your app. To specify how different
2115
- * parts of the state tree respond to actions, you may combine several reducers
2116
- * into a single reducer function by using `combineReducers`.
2117
- *
2118
- * @param {Function} reducer A function that returns the next state tree, given
2119
- * the current state tree and the action to handle.
2120
- *
2121
- * @param {any} [preloadedState] The initial state. You may optionally specify it
2122
- * to hydrate the state from the server in universal apps, or to restore a
2123
- * previously serialized user session.
2124
- * If you use `combineReducers` to produce the root reducer function, this must be
2125
- * an object with the same shape as `combineReducers` keys.
2126
- *
2127
- * @param {Function} [enhancer] The store enhancer. You may optionally specify it
2128
- * to enhance the store with third-party capabilities such as middleware,
2129
- * time travel, persistence, etc. The only store enhancer that ships with Redux
2130
- * is `applyMiddleware()`.
2131
- *
2132
- * @returns {Store} A Redux store that lets you read the state, dispatch actions
2133
- * and subscribe to changes.
2134
- */
2135
-
2136
-
2137
- var msg = ' != ' + FUNC;
2138
- function createStore(reducer, preloadedState, enhancer) {
2139
- if (_typeof(preloadedState) === FUNC && _typeof(enhancer) === UNDEF) {
2140
- enhancer = preloadedState;
2141
- preloadedState = undefined;
2142
- }
2143
-
2144
- if (_typeof(enhancer) !== UNDEF) {
2145
- if (_typeof(enhancer) !== FUNC) {
2146
- throw new Error('enhancer' + msg);
2147
- }
2148
-
2149
- return enhancer(createStore)(reducer, preloadedState);
2150
- }
2151
-
2152
- if (_typeof(reducer) !== FUNC) {
2153
- throw new Error(REDUCER + msg);
2154
- }
2155
-
2156
- var currentReducer = reducer;
2157
- var currentState = preloadedState;
2158
- var currentListeners = [];
2159
- var nextListeners = currentListeners;
2160
- var isDispatching = false;
2161
-
2162
- function ensureCanMutateNextListeners() {
2163
- if (nextListeners === currentListeners) {
2164
- nextListeners = currentListeners.slice();
2165
- }
2166
- }
2167
- /*
2168
- * Reads the state tree managed by the store.
2169
- *
2170
- * @returns {any} The current state tree of your application.
2171
- */
2172
-
2173
-
2174
- function getState() {
2175
- return currentState;
2176
- }
2177
- /*
2178
- * Adds a change listener. It will be called any time an action is dispatched,
2179
- * and some part of the state tree may potentially have changed. You may then
2180
- * call `getState()` to read the current state tree inside the callback.
2181
- *
2182
- * You may call `dispatch()` from a change listener, with the following
2183
- * caveats:
2184
- *
2185
- * 1. The subscriptions are snapshotted just before every `dispatch()` call.
2186
- * If you subscribe or unsubscribe while the listeners are being invoked, this
2187
- * will not have any effect on the `dispatch()` that is currently in progress.
2188
- * However, the next `dispatch()` call, whether nested or not, will use a more
2189
- * recent snapshot of the subscription list.
2190
- *
2191
- * 2. The listener should not expect to see all state changes, as the state
2192
- * might have been updated multiple times during a nested `dispatch()` before
2193
- * the listener is called. It is, however, guaranteed that all subscribers
2194
- * registered before the `dispatch()` started will be called with the latest
2195
- * state by the time it exits.
2196
- *
2197
- * @param {Function} listener A callback to be invoked on every dispatch.
2198
- * @returns {Function} A function to remove this change listener.
2199
- */
2200
-
2201
-
2202
- function subscribe(listener) {
2203
- if (_typeof(listener) !== FUNC) {
2204
- throw new Error('Listener' + msg);
2205
- }
2206
-
2207
- var isSubscribed = true;
2208
- ensureCanMutateNextListeners();
2209
- nextListeners.push(listener);
2210
- return function unsubscribe() {
2211
- if (!isSubscribed) {
2212
- return;
2213
- }
2214
-
2215
- isSubscribed = false;
2216
- ensureCanMutateNextListeners();
2217
- var index = nextListeners.indexOf(listener);
2218
- nextListeners.splice(index, 1);
2219
- };
2220
- }
2221
- /**
2222
- * Dispatches an action. It is the only way to trigger a state change.
2223
- *
2224
- * The `reducer` function, used to create the store, will be called with the
2225
- * current state tree and the given `action`. Its return value will
2226
- * be considered the **next** state of the tree, and the change listeners
2227
- * will be notified.
2228
- *
2229
- * The base implementation only supports plain object actions. If you want to
2230
- * dispatch a Promise, an Observable, a thunk, or something else, you need to
2231
- * wrap your store creating function into the corresponding middleware. For
2232
- * example, see the documentation for the `redux-thunk` package. Even the
2233
- * middleware will eventually dispatch plain object actions using this method.
2234
- *
2235
- * @param {Object} action A plain object representing “what changed”. It is
2236
- * a good idea to keep actions serializable so you can record and replay user
2237
- * sessions, or use the time travelling `redux-devtools`. An action must have
2238
- * a `type` property which may not be `undefined`. It is a good idea to use
2239
- * string constants for action types.
2240
- *
2241
- * @returns {Object} For convenience, the same action object you dispatched.
2242
- *
2243
- * Note that, if you use a custom middleware, it may wrap `dispatch()` to
2244
- * return something else (for example, a Promise you can await).
2245
- */
2246
-
2247
-
2248
- function dispatch(action) {
2249
- /* // add default info to actions...
2250
- console.log('dispatch before', _action)
2251
- const action = {
2252
- ..._action,
2253
- ...{
2254
- action: {
2255
- ..._action.action,
2256
- ...{ customInfo: 'yoooo'}
2257
- }
2258
- }
2259
- }
2260
- console.log('dispatch after', action)
2261
- /** */
2262
- if (!M$1(action)) {
2263
- throw new Error('Act != obj');
2264
- }
2265
-
2266
- if (_typeof(action.type) === UNDEF) {
2267
- throw new Error('ActType ' + UNDEF);
2268
- }
2269
-
2270
- if (isDispatching) {
2271
- throw new Error('Dispatch in ' + REDUCER);
2272
- }
2273
-
2274
- try {
2275
- isDispatching = true;
2276
- currentState = currentReducer(currentState, action);
2277
- } finally {
2278
- isDispatching = false;
2279
- }
2280
-
2281
- var listeners = currentListeners = nextListeners;
2282
-
2283
- for (var i = 0; i < listeners.length; i++) {
2284
- var listener = listeners[i];
2285
- listener();
2286
- }
2287
-
2288
- return action;
2289
- }
2290
- /**
2291
- * Replaces the reducer currently used by the store to calculate the state.
2292
- *
2293
- * You might need this if your app implements code splitting and you want to
2294
- * load some of the reducers dynamically. You might also need this if you
2295
- * implement a hot reloading mechanism for Redux.
2296
- *
2297
- * @param {Function} nextReducer The reducer for the store to use instead.
2298
- * @returns {void}
2299
- */
2300
-
2301
-
2302
- function replaceReducer(nextReducer) {
2303
- if (_typeof(nextReducer) !== FUNC) {
2304
- throw new Error('next ' + REDUCER + msg);
2305
- }
2306
-
2307
- currentReducer = nextReducer;
2308
- dispatch({
2309
- type: ACTION_INIT
2310
- });
2311
- }
2312
- /**
2313
- * Interoperability point for observable/reactive libraries.
2314
- * @returns {observable} A minimal observable of state changes.
2315
- * For more information, see the observable proposal:
2316
- * https://github.com/tc39/proposal-observable
2317
- */
2318
-
2319
-
2320
- function observable() {
2321
- var outerSubscribe = subscribe;
2322
- return _defineProperty$1({
2323
- /*
2324
- * The minimal observable subscription method.
2325
- * @param {Object} observer Any object that can be used as an observer.
2326
- * The observer object should have a `next` method.
2327
- * @returns {subscription} An object with an `unsubscribe` method that can
2328
- * be used to unsubscribe the observable from the store, and prevent further
2329
- * emission of values from the observable.
2330
- */
2331
- subscribe: function subscribe(observer) {
2332
- if (_typeof(observer) !== 'object') {
2333
- throw new TypeError('Observer != obj');
2334
- }
2335
-
2336
- function observeState() {
2337
- if (observer.next) {
2338
- observer.next(getState());
2339
- }
2340
- }
2341
-
2342
- observeState();
2343
- var unsubscribe = outerSubscribe(observeState);
2344
- return {
2345
- unsubscribe: unsubscribe
2346
- };
2347
- }
2348
- }, $$observable, function () {
2349
- return this;
2350
- });
2351
- } // When a store is created, an "INIT" action is dispatched so that every
2352
- // reducer returns their initial state. This effectively populates
2353
- // the initial state tree.
2354
-
2355
-
2356
- dispatch({
2357
- type: ACTION_INIT
2358
- });
2359
- return _defineProperty$1({
2360
- dispatch: dispatch,
2361
- subscribe: subscribe,
2362
- getState: getState,
2363
- replaceReducer: replaceReducer
2364
- }, $$observable, observable);
2365
- }
2366
-
2367
- function getUndefinedStateErrorMessage(key, action) {
2368
- var actionType = action && action.type;
2369
- var actionName = actionType && actionType.toString() || '?';
2370
- return 'action ' + actionName + REDUCER + ' ' + key + ' returns ' + UNDEF;
2371
- }
2372
-
2373
- function assertReducerShape(reducers) {
2374
- Object.keys(reducers).forEach(function (key) {
2375
- var reducer = reducers[key];
2376
- var initialState = reducer(undefined, {
2377
- type: ACTION_INIT
2378
- });
2379
-
2380
- if (_typeof(initialState) === UNDEF || _typeof(reducer(undefined, {
2381
- type: ACTION_TEST
2382
- })) === UNDEF) {
2383
- throw new Error(REDUCER + ' ' + key + ' ' + UNDEF);
2384
- }
2385
- });
2386
- }
2387
- /**
2388
- * Turns an object whose values are different reducer functions, into a single
2389
- * reducer function. It will call every child reducer, and gather their results
2390
- * into a single state object, whose keys correspond to the keys of the passed
2391
- * reducer functions.
2392
- *
2393
- * @param {Object} reducers An object whose values correspond to different
2394
- * reducer functions that need to be combined into one. One handy way to obtain
2395
- * it is to use ES6 `import * as reducers` syntax. The reducers may never return
2396
- * undefined for any action. Instead, they should return their initial state
2397
- * if the state passed to them was undefined, and the current state for any
2398
- * unrecognized action.
2399
- *
2400
- * @returns {Function} A reducer function that invokes every reducer inside the
2401
- * passed object, and builds a state object with the same shape.
2402
- */
2403
-
2404
-
2405
- function combineReducers(reducers) {
2406
- var reducerKeys = Object.keys(reducers);
2407
- var finalReducers = {};
2408
-
2409
- for (var i = 0; i < reducerKeys.length; i++) {
2410
- var key = reducerKeys[i];
2411
-
2412
- if (_typeof(reducers[key]) === FUNC) {
2413
- finalReducers[key] = reducers[key];
2414
- }
2415
- }
2416
-
2417
- var finalReducerKeys = Object.keys(finalReducers);
2418
-
2419
- var shapeAssertionError;
2420
-
2421
- try {
2422
- assertReducerShape(finalReducers);
2423
- } catch (e) {
2424
- shapeAssertionError = e;
2425
- }
2426
-
2427
- return function combination() {
2428
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2429
- var action = arguments.length > 1 ? arguments[1] : undefined;
2430
-
2431
- if (shapeAssertionError) {
2432
- throw shapeAssertionError;
2433
- }
2434
-
2435
- var hasChanged = false;
2436
- var nextState = {};
2437
-
2438
- for (var _i = 0; _i < finalReducerKeys.length; _i++) {
2439
- var _key = finalReducerKeys[_i];
2440
- var reducer = finalReducers[_key];
2441
- var previousStateForKey = state[_key];
2442
- var nextStateForKey = reducer(previousStateForKey, action);
2443
-
2444
- if (_typeof(nextStateForKey) === UNDEF) {
2445
- var errorMessage = getUndefinedStateErrorMessage(_key, action);
2446
- throw new Error(errorMessage);
2447
- }
2448
-
2449
- nextState[_key] = nextStateForKey;
2450
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2451
- }
2452
-
2453
- return hasChanged ? nextState : state;
2454
- };
2455
- }
2456
-
2457
- function compose() {
2458
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
2459
- funcs[_key] = arguments[_key];
2460
- }
2461
-
2462
- if (funcs.length === 0) {
2463
- return function (arg) {
2464
- return arg;
2465
- };
2466
- }
2467
-
2468
- if (funcs.length === 1) {
2469
- return funcs[0];
2470
- }
2471
-
2472
- return funcs.reduce(function (a, b) {
2473
- return function () {
2474
- return a(b.apply(void 0, arguments));
2475
- };
2476
- });
2477
- }
2478
-
2479
- /**
2480
- * Creates a store enhancer that applies middleware to the dispatch method
2481
- * of the Redux store. This is handy for a variety of tasks, such as expressing
2482
- * asynchronous actions in a concise manner, or logging every action payload.
2483
- *
2484
- * See `redux-thunk` package as an example of the Redux middleware.
2485
- *
2486
- * Because middleware is potentially asynchronous, this should be the first
2487
- * store enhancer in the composition chain.
2488
- *
2489
- * Note that each middleware will be given the `dispatch` and `getState` functions
2490
- * as named arguments.
2491
- *
2492
- * @param {...Function} middlewares The middleware chain to be applied.
2493
- * @returns {Function} A store enhancer applying the middleware.
2494
- */
2495
-
2496
- function applyMiddleware() {
2497
- for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
2498
- middlewares[_key] = arguments[_key];
2499
- }
2500
-
2501
- return function (createStore) {
2502
- return function (reducer, preloadedState, enhancer) {
2503
- var store = createStore(reducer, preloadedState, enhancer);
2504
- var _dispatch = store.dispatch;
2505
- var chain = [];
2506
- var middlewareAPI = {
2507
- getState: store.getState,
2508
- dispatch: function dispatch(action) {
2509
- return _dispatch(action);
2510
- }
2511
- };
2512
- chain = middlewares.map(function (middleware) {
2513
- return middleware(middlewareAPI);
2514
- });
2515
- _dispatch = compose.apply(void 0, _toConsumableArray(chain))(store.dispatch);
2516
- return _objectSpread2$1(_objectSpread2$1({}, store), {}, {
2517
- dispatch: _dispatch
2518
- });
2519
- };
2520
- };
2521
- }
2522
-
2523
- /**
2524
- * Anonymous visitor Id localstorage key
2525
- * @typedef {String} ANON_ID
2526
- */
2527
-
2528
- var ANON_ID = p + 'anon_id'; // __anon_id
2529
-
2530
- /**
2531
- * Visitor Id localstorage key
2532
- * @typedef {String} USER_ID
2533
- */
2534
-
2535
- var USER_ID = p + 'user_id'; // __user_id
2536
-
2537
- /**
2538
- * Visitor traits localstorage key
2539
- * @typedef {String} USER_TRAITS
2540
- */
2541
-
2542
- var USER_TRAITS = p + 'user_traits'; // __user_traits
2543
-
2544
- var LIB_NAME = 'analytics';
2545
- var ID = 'userId';
2546
- var ANONID = 'anonymousId';
2547
- var ERROR_URL = 'https://lytics.dev/errors/';
2548
-
2549
- var coreEvents = [
2550
- /**
2551
- * `bootstrap` - Fires when analytics library starts up.
2552
- * This is the first event fired. '.on/once' listeners are not allowed on bootstrap
2553
- * Plugins can attach logic to this event
2554
- */
2555
- 'bootstrap',
2556
- /**
2557
- * `params` - Fires when analytics parses URL parameters
2558
- */
2559
- 'params',
2560
- /**
2561
- * `campaign` - Fires if params contain "utm" parameters
2562
- */
2563
- 'campaign',
2564
- /**
2565
- * `initializeStart` - Fires before 'initialize', allows for plugins to cancel loading of other plugins
2566
- */
2567
- 'initializeStart',
2568
- /**
2569
- * `initialize` - Fires when analytics loads plugins
2570
- */
2571
- 'initialize',
2572
- /**
2573
- * `initializeEnd` - Fires after initialize, allows for plugins to run logic after initialization methods run
2574
- */
2575
- 'initializeEnd',
2576
- /**
2577
- * `ready` - Fires when all analytic providers are fully loaded. This waits for 'initialize' and 'loaded' to return true
2578
- */
2579
- 'ready',
2580
- /**
2581
- * `resetStart` - Fires if analytic.reset() is called.
2582
- * Use this event to cancel reset based on a specific condition
2583
- */
2584
- 'resetStart',
2585
- /**
2586
- * `reset` - Fires if analytic.reset() is called.
2587
- * Use this event to run custom cleanup logic (if needed)
2588
- */
2589
- 'reset',
2590
- /**
2591
- * `resetEnd` - Fires after analytic.reset() is called.
2592
- * Use this event to run a callback after user data is reset
2593
- */
2594
- 'resetEnd',
2595
- /******************
2596
- * Page Events
2597
- ******************/
2598
-
2599
- /**
2600
- * `pageStart` - Fires before 'page' events fire.
2601
- * This allows for dynamic page view cancellation based on current state of user or options passed in.
2602
- */
2603
- 'pageStart',
2604
- /**
2605
- * `page` - Core analytics hook for page views.
2606
- * If your plugin or integration tracks page views, this is the event to fire on.
2607
- */
2608
- 'page',
2609
- /**
2610
- * `pageEnd` - Fires after all registered 'page' methods fire.
2611
- */
2612
- 'pageEnd',
2613
- /**
2614
- * `pageAborted` - Fires if 'page' call is cancelled by a plugin
2615
- */
2616
- 'pageAborted',
2617
- /****************
2618
- * Track Events
2619
- ***************/
2620
-
2621
- /**
2622
- * `trackStart` - Called before the 'track' events fires.
2623
- * This allows for dynamic page view cancellation based on current state of user or options passed in.
2624
- */
2625
- 'trackStart',
2626
- /**
2627
- * `track` - Core analytics hook for event tracking.
2628
- * If your plugin or integration tracks custom events, this is the event to fire on.
2629
- */
2630
- 'track',
2631
- /**
2632
- * `trackEnd` - Fires after all registered 'track' events fire from plugins.
2633
- */
2634
- 'trackEnd',
2635
- /**
2636
- * `trackAborted` - Fires if 'track' call is cancelled by a plugin
2637
- */
2638
- 'trackAborted',
2639
- /******************
2640
- * Identify Events
2641
- ******************/
2642
-
2643
- /**
2644
- * `identifyStart` - Called before the 'identify' events fires.
2645
- * This allows for dynamic page view cancellation based on current state of user or options passed in.
2646
- */
2647
- 'identifyStart',
2648
- /**
2649
- * `identify` - Core analytics hook for user identification.
2650
- * If your plugin or integration identifies users or user traits, this is the event to fire on.
2651
- */
2652
- 'identify',
2653
- /**
2654
- * `identifyEnd` - Fires after all registered 'identify' events fire from plugins.
2655
- */
2656
- 'identifyEnd',
2657
- /**
2658
- * `identifyAborted` - Fires if 'track' call is cancelled by a plugin
2659
- */
2660
- 'identifyAborted',
2661
- /**
2662
- * `userIdChanged` - Fires when a user id is updated
2663
- */
2664
- 'userIdChanged',
2665
- /******************
2666
- * Plugin Events
2667
- ******************/
2668
-
2669
- /**
2670
- * `registerPlugins` - Fires when analytics is registering plugins
2671
- */
2672
- 'registerPlugins',
2673
- /**
2674
- * `enablePlugin` - Fires when 'analytics.plugins.enable()' is called
2675
- */
2676
- 'enablePlugin',
2677
- /**
2678
- * `disablePlugin` - Fires when 'analytics.plugins.disable()' is called
2679
- */
2680
- 'disablePlugin',
2681
- /*
2682
- * `loadPlugin` - Fires when 'analytics.loadPlugin()' is called
2683
- */
2684
- // 'loadPlugin',
2685
-
2686
- /******************
2687
- * Browser activity events
2688
- ******************/
2689
-
2690
- /**
2691
- * `online` - Fires when browser network goes online.
2692
- * This fires only when coming back online from an offline state.
2693
- */
2694
- 'online',
2695
- /**
2696
- * `offline` - Fires when browser network goes offline.
2697
- */
2698
- 'offline',
2699
- /******************
2700
- * Storage events
2701
- ******************/
2702
-
2703
- /**
2704
- * `setItemStart` - Fires when analytics.storage.setItem is initialized.
2705
- * This event gives plugins the ability to intercept keys & values and alter them before they are persisted.
2706
- */
2707
- 'setItemStart',
2708
- /**
2709
- * `setItem` - Fires when analytics.storage.setItem is called.
2710
- * This event gives plugins the ability to intercept keys & values and alter them before they are persisted.
2711
- */
2712
- 'setItem',
2713
- /**
2714
- * `setItemEnd` - Fires when setItem storage is complete.
2715
- */
2716
- 'setItemEnd',
2717
- /**
2718
- * `setItemAborted` - Fires when setItem storage is cancelled by a plugin.
2719
- */
2720
- 'setItemAborted',
2721
- /**
2722
- * `removeItemStart` - Fires when analytics.storage.removeItem is initialized.
2723
- * This event gives plugins the ability to intercept removeItem calls and abort / alter them.
2724
- */
2725
- 'removeItemStart',
2726
- /**
2727
- * `removeItem` - Fires when analytics.storage.removeItem is called.
2728
- * This event gives plugins the ability to intercept removeItem calls and abort / alter them.
2729
- */
2730
- 'removeItem',
2731
- /**
2732
- * `removeItemEnd` - Fires when removeItem storage is complete.
2733
- */
2734
- 'removeItemEnd',
2735
- /**
2736
- * `removeItemAborted` - Fires when removeItem storage is cancelled by a plugin.
2737
- */
2738
- 'removeItemAborted'];
2739
- /* Keys on a plugin that are not considered events */
2740
-
2741
- var nonEvents = ['name', 'EVENTS', 'config', 'loaded'];
2742
- var pluginEvents = {
2743
- registerPluginType: function registerPluginType(name) {
2744
- return "registerPlugin:".concat(name);
2745
- },
2746
- pluginReadyType: function pluginReadyType(name) {
2747
- return "ready:".concat(name);
2748
- }
2749
- };
2750
- var EVENTS = coreEvents.reduce(function (acc, curr) {
2751
- acc[curr] = curr;
2752
- return acc;
2753
- }, pluginEvents);
2754
- var EVENTS$1 = EVENTS;
2755
- function isReservedAction(type) {
2756
- return coreEvents.includes(type);
2757
- }
2758
-
2759
- var utmRegex = /^utm_/;
2760
- var propRegex = /^an_prop_/;
2761
- var traitRegex = /^an_trait_/; // Middleware runs during EVENTS.initialize
2762
-
2763
- function initializeMiddleware(instance) {
2764
- var setItem = instance.storage.setItem;
2765
- return function (store) {
2766
- return function (next) {
2767
- return function (action) {
2768
- /* Handle bootstrap event */
2769
- if (action.type === EVENTS$1.bootstrap) {
2770
- var params = action.params,
2771
- user = action.user,
2772
- persistedUser = action.persistedUser,
2773
- initialUser = action.initialUser;
2774
- var isKnownId = persistedUser.userId === user.userId;
2775
- /* 1. Set anonymous ID */
2776
-
2777
- if (persistedUser.anonymousId !== user.anonymousId) {
2778
- setItem(ANON_ID, user.anonymousId);
2779
- }
2780
- /* 2. Set userId */
2781
-
2782
-
2783
- if (!isKnownId) {
2784
- setItem(USER_ID, user.userId);
2785
- }
2786
- /* 3. Set traits if they are different */
2787
-
2788
-
2789
- if (initialUser.traits) {
2790
- setItem(USER_TRAITS, _objectSpread2$1(_objectSpread2$1({}, isKnownId && persistedUser.traits ? persistedUser.traits : {}), initialUser.traits));
2791
- /* TODO multi user setup
2792
- setItem(`${USER_TRAITS}.${user.userId}`, {
2793
- ...(isKnownId) ? existingTraits : {},
2794
- ...initialUser.traits
2795
- })
2796
- */
2797
- }
2798
- /* 4. Parse url params */
2799
-
2800
-
2801
- var paramsArray = Object.keys(action.params);
2802
-
2803
- if (paramsArray.length) {
2804
- var an_uid = params.an_uid,
2805
- an_event = params.an_event;
2806
- var groupedParams = paramsArray.reduce(function (acc, key) {
2807
- // match utm params & dclid (display) & gclid (cpc)
2808
- if (key.match(utmRegex) || key.match(/^(d|g)clid/)) {
2809
- var cleanName = key.replace(utmRegex, '');
2810
- var keyName = cleanName === 'campaign' ? 'name' : cleanName;
2811
- acc.campaign[keyName] = params[key];
2812
- }
2813
-
2814
- if (key.match(propRegex)) {
2815
- acc.props[key.replace(propRegex, '')] = params[key];
2816
- }
2817
-
2818
- if (key.match(traitRegex)) {
2819
- acc.traits[key.replace(traitRegex, '')] = params[key];
2820
- }
2821
-
2822
- return acc;
2823
- }, {
2824
- campaign: {},
2825
- props: {},
2826
- traits: {}
2827
- });
2828
- store.dispatch(_objectSpread2$1(_objectSpread2$1({
2829
- type: EVENTS$1.params,
2830
- raw: params
2831
- }, groupedParams), an_uid ? {
2832
- userId: an_uid
2833
- } : {}));
2834
- /* If userId set, call identify */
2835
-
2836
- if (an_uid) {
2837
- // timeout to debounce and make sure integration is registered. Todo refactor
2838
- setTimeout(function () {
2839
- return instance.identify(an_uid, groupedParams.traits);
2840
- }, 0);
2841
- }
2842
- /* If tracking event set, call track */
2843
-
2844
-
2845
- if (an_event) {
2846
- // timeout to debounce and make sure integration is registered. Todo refactor
2847
- setTimeout(function () {
2848
- return instance.track(an_event, groupedParams.props);
2849
- }, 0);
2850
- } // if url has utm params
2851
-
2852
-
2853
- if (Object.keys(groupedParams.campaign).length) {
2854
- store.dispatch({
2855
- type: EVENTS$1.campaign,
2856
- campaign: groupedParams.campaign
2857
- });
2858
- }
2859
- }
2860
- }
2861
-
2862
- return next(action);
2863
- };
2864
- };
2865
- };
2866
- }
2867
-
2868
- /* user reducer */
2869
-
2870
- function userReducer(storage) {
2871
- return function user() {
2872
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2873
- var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2874
-
2875
- if (action.type === EVENTS$1.setItemEnd) {
2876
- // Set anonymousId if changed by storage.setItem
2877
- if (action.key === ANON_ID) {
2878
- return _objectSpread2$1(_objectSpread2$1({}, state), {
2879
- anonymousId: action.value
2880
- });
2881
- } // Set userId if changed by storage.setItem
2882
-
2883
-
2884
- if (action.key === USER_ID) {
2885
- return _objectSpread2$1(_objectSpread2$1({}, state), {
2886
- userId: action.value
2887
- });
2888
- }
2889
- }
2890
-
2891
- switch (action.type) {
2892
- case EVENTS$1.identify:
2893
- return Object.assign({}, state, {
2894
- userId: action.userId,
2895
- traits: _objectSpread2$1(_objectSpread2$1({}, state.traits), action.traits)
2896
- });
2897
-
2898
- case EVENTS$1.reset:
2899
- // Side effect to fix race condition in Node. TODO refactor
2900
- // This is from default storage.removeItem: (key) => globalContext[key] = undefined
2901
- [USER_ID, ANON_ID, USER_TRAITS].forEach(function (key) {
2902
- // sync storage, not instance.storage
2903
- storage.removeItem(key);
2904
- });
2905
- return Object.assign({}, state, {
2906
- userId: null,
2907
- // TODO reset anon id automatically?
2908
- anonymousId: null,
2909
- traits: {}
2910
- });
2911
-
2912
- default:
2913
- return state;
2914
- }
2915
- };
2916
- }
2917
- function getPersistedUserData(storage) {
2918
- return {
2919
- userId: storage.getItem(USER_ID),
2920
- anonymousId: storage.getItem(ANON_ID),
2921
- traits: storage.getItem(USER_TRAITS)
2922
- };
2923
- }
2924
- var tempKey = function tempKey(key) {
2925
- return p + 'TEMP' + p + key;
2926
- };
2927
- function getUserPropFunc(storage) {
2928
- return function getUserProp(key, instance, payload) {
2929
- /* 1. Try current state */
2930
- var currentId = instance.getState('user')[key];
2931
-
2932
- if (currentId) {
2933
- /*
2934
- console.log(`from state ${key}`, currentId)
2935
- /** */
2936
- return currentId;
2937
- }
2938
- /* 2. Try event payload */
2939
-
2940
-
2941
- if (payload && M$1(payload) && payload[key]) {
2942
- /*
2943
- console.log(`from payload ${key}`, payload[key])
2944
- /** */
2945
- return payload[key];
2946
- }
2947
- /* 3. Try persisted data */
2948
-
2949
-
2950
- var persistedInfo = getPersistedUserData(storage)[key];
2951
-
2952
- if (persistedInfo) {
2953
- /*
2954
- console.log(`from persistedInfo ${key}`, persistedInfo)
2955
- /** */
2956
- return persistedInfo;
2957
- }
2958
- /* 4. Else, try to get in memory placeholder. TODO watch this for future issues */
2959
-
2960
-
2961
- return a$2(tempKey(key)) || null;
2962
- };
2963
- }
2964
-
2965
- function identifyMiddleware(instance) {
2966
- var _instance$storage = instance.storage,
2967
- setItem = _instance$storage.setItem,
2968
- removeItem = _instance$storage.removeItem,
2969
- getItem = _instance$storage.getItem;
2970
- return function (store) {
2971
- return function (next) {
2972
- return function (action) {
2973
- var userId = action.userId,
2974
- traits = action.traits,
2975
- options = action.options;
2976
- /* Reset user id and traits */
2977
-
2978
- if (action.type === EVENTS$1.reset) {
2979
- // Remove stored data
2980
- [USER_ID, USER_TRAITS, ANON_ID].forEach(function (key) {
2981
- // Fires async removeItem dispatch
2982
- removeItem(key);
2983
- });
2984
- [ID, ANONID, 'traits'].forEach(function (key) {
2985
- // Remove from global context
2986
- i$2(tempKey(key));
2987
- });
2988
- }
2989
-
2990
- if (action.type === EVENTS$1.identify) {
2991
- /* If no anon id. Set it! */
2992
- if (!getItem(ANON_ID)) {
2993
- setItem(ANON_ID, y());
2994
- }
2995
-
2996
- var currentId = getItem(USER_ID);
2997
- var currentTraits = getItem(USER_TRAITS) || {};
2998
-
2999
- if (currentId && currentId !== userId) {
3000
- store.dispatch({
3001
- type: EVENTS$1.userIdChanged,
3002
- old: {
3003
- userId: currentId,
3004
- traits: currentTraits
3005
- },
3006
- "new": {
3007
- userId: userId,
3008
- traits: traits
3009
- },
3010
- options: options
3011
- });
3012
- }
3013
- /* Save user id */
3014
-
3015
-
3016
- if (userId) {
3017
- setItem(USER_ID, userId);
3018
- }
3019
- /* Save user traits */
3020
-
3021
-
3022
- if (traits) {
3023
- setItem(USER_TRAITS, _objectSpread2$1(_objectSpread2$1({}, currentTraits), traits));
3024
- }
3025
- }
3026
-
3027
- return next(action);
3028
- };
3029
- };
3030
- };
3031
- }
3032
-
3033
- var stack = {};
3034
-
3035
- function runCallback(id, payload) {
3036
- if (stack[id] && _(stack[id])) {
3037
- // console.log(`run ${id}`)
3038
- stack[id](payload);
3039
- delete stack[id];
3040
- }
3041
- }
3042
-
3043
- function waitForReady(data, predicate, timeout) {
3044
- return new Promise(function (resolve, reject) {
3045
- if (predicate()) {
3046
- return resolve(data);
3047
- } // Timeout. Add to queue
3048
-
3049
-
3050
- if (timeout < 1) {
3051
- return reject(_objectSpread2$1(_objectSpread2$1({}, data), {}, {
3052
- queue: true
3053
- })); // eslint-disable-line
3054
- } // Else recursive retry
3055
-
3056
-
3057
- return pause(10).then(function (_) {
3058
- return waitForReady(data, predicate, timeout - 10).then(resolve, reject);
3059
- });
3060
- });
3061
- }
3062
-
3063
- function pause(ms) {
3064
- return new Promise(function (resolve) {
3065
- return setTimeout(resolve, ms);
3066
- });
3067
- }
3068
-
3069
- function processQueue(store, getPlugins, instance) {
3070
- var pluginMethods = getPlugins();
3071
-
3072
- var _store$getState = store.getState(),
3073
- plugins = _store$getState.plugins,
3074
- context = _store$getState.context,
3075
- queue = _store$getState.queue,
3076
- user = _store$getState.user;
3077
-
3078
- var isOnline = !context.offline;
3079
- /* If network connection found and there is items in queue, process them all */
3080
-
3081
- if (isOnline && queue && queue.actions && queue.actions.length) {
3082
- var pipeline = queue.actions.reduce(function (acc, item, index) {
3083
- var isLoaded = plugins[item.plugin].loaded;
3084
-
3085
- if (isLoaded) {
3086
- acc.process.push(item);
3087
- acc.processIndex.push(index);
3088
- } else {
3089
- acc.requeue.push(item);
3090
- acc.requeueIndex.push(index);
3091
- }
3092
-
3093
- return acc;
3094
- }, {
3095
- processIndex: [],
3096
- process: [],
3097
- requeue: [],
3098
- requeueIndex: []
3099
- });
3100
-
3101
- if (pipeline.processIndex && pipeline.processIndex.length) {
3102
- pipeline.processIndex.forEach(function (i) {
3103
- var processAction = queue.actions[i]; // console.log('RePROCESS THIS>', processAction)
3104
- // Call methods directly right now
3105
-
3106
- var currentPlugin = processAction.plugin;
3107
- var currentMethod = processAction.payload.type;
3108
- var method = pluginMethods[currentPlugin][currentMethod];
3109
-
3110
- if (method && _(method)) {
3111
- /* enrich queued payload with userId / anon id if missing */
3112
-
3113
- /* TODO hoist enrich into where action queued? */
3114
- // console.log('before', processAction.payload)
3115
- var enrichedPayload = enrich(processAction.payload, user); // console.log('user.userId', user.userId)
3116
- // console.log('user.anonymousId', user.anonymousId)
3117
- // console.log('after enrich', enrichedPayload)
3118
-
3119
- method({
3120
- payload: enrichedPayload,
3121
- config: plugins[currentPlugin].config,
3122
- instance: instance
3123
- });
3124
- /* Then redispatch for .on listeners / other middleware */
3125
-
3126
- var pluginEvent = "".concat(currentMethod, ":").concat(currentPlugin);
3127
- store.dispatch(_objectSpread2$1(_objectSpread2$1({}, enrichedPayload), {}, {
3128
- type: pluginEvent,
3129
-
3130
- /* Internal data for analytics engine */
3131
- _: {
3132
- called: pluginEvent,
3133
- from: 'queueDrain'
3134
- }
3135
- }));
3136
- }
3137
- });
3138
- /* Removed processed actions */
3139
-
3140
- var reQueueActions = queue.actions.filter(function (value, index) {
3141
- // note !~ === return pipeline.processIndex.indexOf(index) === -1
3142
- return !~pipeline.processIndex.indexOf(index);
3143
- });
3144
- /* Set queue actions. TODO refactor to non mutatable or move out of redux */
3145
-
3146
- queue.actions = reQueueActions;
3147
- }
3148
- }
3149
- }
3150
- /* Heartbeat retries queued events */
3151
-
3152
- function heartBeat(store, getPlugins, instance) {
3153
- // 3e3 === 3000 ms
3154
- return setInterval(function () {
3155
- return processQueue(store, getPlugins, instance);
3156
- }, 3e3);
3157
- } // Assign userId && anonymousId values if present in payload but null
3158
-
3159
- function enrich() {
3160
- var payload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3161
- var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3162
- return [ID, ANONID].reduce(function (acc, key) {
3163
- if (payload.hasOwnProperty(key) && user[key] && user[key] !== payload[key]) {
3164
- // console.log(`${key} stale update with ${user[key]}`)
3165
- acc[key] = user[key];
3166
- }
3167
-
3168
- return acc;
3169
- }, payload);
3170
- }
3171
-
3172
- function _arrayWithHoles(arr) {
3173
- if (Array.isArray(arr)) return arr;
3174
- }
3175
-
3176
- function _iterableToArrayLimit(arr, i) {
3177
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
3178
-
3179
- if (_i == null) return;
3180
- var _arr = [];
3181
- var _n = true;
3182
- var _d = false;
3183
-
3184
- var _s, _e;
3185
-
3186
- try {
3187
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
3188
- _arr.push(_s.value);
3189
-
3190
- if (i && _arr.length === i) break;
3191
- }
3192
- } catch (err) {
3193
- _d = true;
3194
- _e = err;
3195
- } finally {
3196
- try {
3197
- if (!_n && _i["return"] != null) _i["return"]();
3198
- } finally {
3199
- if (_d) throw _e;
3200
- }
3201
- }
3202
-
3203
- return _arr;
3204
- }
3205
-
3206
- function _nonIterableRest() {
3207
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
3208
- }
3209
-
3210
- function _slicedToArray(arr, i) {
3211
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
3212
- }
3213
-
3214
- function fitlerDisabledPlugins(allPlugins) {
3215
- var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3216
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3217
- return Object.keys(allPlugins).filter(function (name) {
3218
- var fromCallOptions = options.plugins || {}; // If enabled/disabled by options. Override settings
3219
-
3220
- if (x$1(fromCallOptions[name])) {
3221
- return fromCallOptions[name];
3222
- } // If all: false disable everything unless true explicitly set
3223
-
3224
-
3225
- if (fromCallOptions.all === false) {
3226
- return false;
3227
- } // else use state.plugin settings
3228
-
3229
-
3230
- if (settings[name] && settings[name].enabled === false) {
3231
- return false;
3232
- }
3233
-
3234
- return true;
3235
- }).map(function (name) {
3236
- return allPlugins[name];
3237
- });
3238
- }
3239
-
3240
- var endsWithStartRegex = /Start$/;
3241
- var bootstrapRegex = /^bootstrap/;
3242
- var readyRegex = /^ready/;
3243
- function runPlugins (_x, _x2, _x3, _x4, _x5) {
3244
- return _ref.apply(this, arguments);
3245
- }
3246
- /**
3247
- * Async reduce over matched plugin methods
3248
- * Fires plugin functions
3249
- */
3250
-
3251
- function _ref() {
3252
- _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(action, getPlugins, instance, store, eventsInfo) {
3253
- var pluginObject, originalType, updatedType, state, activePlugins, allActivePluginKeys, allMatches, actionBefore, actionDuring, afterName, actionAfter;
3254
- return regenerator.wrap(function _callee$(_context) {
3255
- while (1) {
3256
- switch (_context.prev = _context.next) {
3257
- case 0:
3258
- pluginObject = _(getPlugins) ? getPlugins() : getPlugins;
3259
- originalType = action.type;
3260
- updatedType = originalType.replace(endsWithStartRegex, '');
3261
- /* If action already dispatched exit early. This makes it so plugin methods are not fired twice. */
3262
-
3263
- if (!(action._ && action._.called)) {
3264
- _context.next = 5;
3265
- break;
3266
- }
3267
-
3268
- return _context.abrupt("return", action);
3269
-
3270
- case 5:
3271
- state = instance.getState();
3272
- /* Remove plugins that are disabled by options or by settings */
3273
-
3274
- activePlugins = fitlerDisabledPlugins(pluginObject, state.plugins, action.options);
3275
- /* If analytics.plugin.enable calls do special behavior */
3276
-
3277
- if (originalType === EVENTS$1.initializeStart && action.fromEnable) {
3278
- // Return list of all enabled plugins that have NOT been initialized yet
3279
- activePlugins = Object.keys(state.plugins).filter(function (name) {
3280
- var info = state.plugins[name];
3281
- return action.plugins.includes(name) && !info.initialized;
3282
- }).map(function (name) {
3283
- return pluginObject[name];
3284
- });
3285
- } // console.log(`engine activePlugins ${action.type}`, activePlugins)
3286
-
3287
-
3288
- allActivePluginKeys = activePlugins.map(function (p) {
3289
- return p.name;
3290
- }); // console.log('allActivePluginKeys', allActivePluginKeys)
3291
-
3292
- allMatches = getAllMatchingCalls(originalType, activePlugins); // console.log('allMatches', allMatches)
3293
-
3294
- /* @TODO cache matches and purge on enable/disable/add plugin */
3295
-
3296
- /**
3297
- * Process all 'actionBefore' hooks
3298
- * Example:
3299
- * This is processes 'pageStart' methods from plugins and update the event to send through the chain
3300
- */
3301
-
3302
- _context.next = 12;
3303
- return processEvent({
3304
- action: action,
3305
- data: {
3306
- exact: allMatches.before,
3307
- namespaced: allMatches.beforeNS
3308
- },
3309
- state: state,
3310
- allPlugins: pluginObject,
3311
- allMatches: allMatches,
3312
- instance: instance,
3313
- store: store,
3314
- EVENTS: eventsInfo
3315
- });
3316
-
3317
- case 12:
3318
- actionBefore = _context.sent;
3319
-
3320
- if (!shouldAbortAll(actionBefore, allActivePluginKeys.length)) {
3321
- _context.next = 15;
3322
- break;
3323
- }
3324
-
3325
- return _context.abrupt("return", actionBefore);
3326
-
3327
- case 15:
3328
- if (!(originalType === updatedType)) {
3329
- _context.next = 19;
3330
- break;
3331
- }
3332
-
3333
- /* If type the same don't double process */
3334
- actionDuring = actionBefore;
3335
- _context.next = 22;
3336
- break;
3337
-
3338
- case 19:
3339
- _context.next = 21;
3340
- return processEvent({
3341
- action: _objectSpread2$1(_objectSpread2$1({}, actionBefore), {}, {
3342
- type: updatedType
3343
- }),
3344
- data: {
3345
- exact: allMatches.during,
3346
- namespaced: allMatches.duringNS
3347
- },
3348
- state: state,
3349
- allPlugins: pluginObject,
3350
- allMatches: allMatches,
3351
- instance: instance,
3352
- store: store,
3353
- EVENTS: eventsInfo
3354
- });
3355
-
3356
- case 21:
3357
- actionDuring = _context.sent;
3358
-
3359
- case 22:
3360
- if (!originalType.match(endsWithStartRegex)) {
3361
- _context.next = 28;
3362
- break;
3363
- }
3364
-
3365
- afterName = "".concat(updatedType, "End");
3366
- _context.next = 26;
3367
- return processEvent({
3368
- action: _objectSpread2$1(_objectSpread2$1({}, actionDuring), {}, {
3369
- type: afterName
3370
- }),
3371
- data: {
3372
- exact: allMatches.after,
3373
- namespaced: allMatches.afterNS
3374
- },
3375
- state: state,
3376
- allPlugins: pluginObject,
3377
- allMatches: allMatches,
3378
- instance: instance,
3379
- store: store,
3380
- EVENTS: eventsInfo
3381
- });
3382
-
3383
- case 26:
3384
- actionAfter = _context.sent;
3385
-
3386
- // console.log('____ actionAfter', actionAfter)
3387
-
3388
- /* Fire callback if supplied */
3389
- if (actionAfter.meta && actionAfter.meta.hasCallback) {
3390
- /*
3391
- console.log('End of engine action has callback')
3392
- console.log(actionAfter.meta)
3393
- console.log('stack', stack)
3394
- /** */
3395
- // @TODO figure out exact args calls and .on will get
3396
- runCallback(actionAfter.meta.rid, {
3397
- payload: actionAfter
3398
- });
3399
- }
3400
-
3401
- case 28:
3402
- return _context.abrupt("return", actionBefore);
3403
-
3404
- case 29:
3405
- case "end":
3406
- return _context.stop();
3407
- }
3408
- }
3409
- }, _callee);
3410
- }));
3411
- return _ref.apply(this, arguments);
3412
- }
3413
-
3414
- function processEvent(_x6) {
3415
- return _processEvent.apply(this, arguments);
3416
- }
3417
-
3418
- function _processEvent() {
3419
- _processEvent = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(_ref2) {
3420
- var data, action, instance, state, allPlugins, allMatches, store, EVENTS, plugins, context, method, isStartEvent, abortable, makeArgs, queueData, payloads, resolvedAction, endAction;
3421
- return regenerator.wrap(function _callee5$(_context5) {
3422
- while (1) {
3423
- switch (_context5.prev = _context5.next) {
3424
- case 0:
3425
- data = _ref2.data, action = _ref2.action, instance = _ref2.instance, state = _ref2.state, allPlugins = _ref2.allPlugins, allMatches = _ref2.allMatches, store = _ref2.store, EVENTS = _ref2.EVENTS;
3426
- plugins = state.plugins, context = state.context;
3427
- method = action.type;
3428
- isStartEvent = method.match(endsWithStartRegex); // console.log(`data ${method}`, data)
3429
- // console.log(`data allMatches ${method}`, allMatches)
3430
-
3431
- abortable = data.exact.map(function (x) {
3432
- return x.pluginName;
3433
- });
3434
- /* If abort is called from xyzStart */
3435
-
3436
- if (isStartEvent) {
3437
- abortable = allMatches.during.map(function (x) {
3438
- return x.pluginName;
3439
- });
3440
- }
3441
- /* make args for functions to concume */
3442
-
3443
-
3444
- makeArgs = argumentFactory(instance, abortable); // console.log('makeArgs', makeArgs)
3445
-
3446
- /* Check if plugin loaded, if not mark action for queue */
3447
-
3448
- queueData = data.exact.reduce(function (acc, thing) {
3449
- var pluginName = thing.pluginName,
3450
- methodName = thing.methodName;
3451
- var addToQueue = false; // Queue actions if plugin not loaded except for initialize and reset
3452
-
3453
- if (!methodName.match(/^initialize/) && !methodName.match(/^reset/)) {
3454
- addToQueue = !plugins[pluginName].loaded;
3455
- }
3456
- /* If offline and its a core method. Add to queue */
3457
-
3458
-
3459
- if (context.offline && methodName.match(/^(page|track|identify)/)) {
3460
- addToQueue = true;
3461
- }
3462
-
3463
- acc["".concat(pluginName)] = addToQueue;
3464
- return acc;
3465
- }, {});
3466
- /* generate plugin specific payloads */
3467
-
3468
- _context5.next = 10;
3469
- return data.exact.reduce( /*#__PURE__*/function () {
3470
- var _ref6 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(scoped, curr, i) {
3471
- var pluginName, curScope, scopedPayload;
3472
- return regenerator.wrap(function _callee3$(_context3) {
3473
- while (1) {
3474
- switch (_context3.prev = _context3.next) {
3475
- case 0:
3476
- pluginName = curr.pluginName;
3477
- _context3.next = 3;
3478
- return scoped;
3479
-
3480
- case 3:
3481
- curScope = _context3.sent;
3482
-
3483
- if (!(data.namespaced && data.namespaced[pluginName])) {
3484
- _context3.next = 11;
3485
- break;
3486
- }
3487
-
3488
- _context3.next = 7;
3489
- return data.namespaced[pluginName].reduce( /*#__PURE__*/function () {
3490
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(acc, p, count) {
3491
- var curScopeData, genAbort, val, returnValue;
3492
- return regenerator.wrap(function _callee2$(_context2) {
3493
- while (1) {
3494
- switch (_context2.prev = _context2.next) {
3495
- case 0:
3496
- genAbort = function _genAbort(currentAct, pname, otherPlug) {
3497
- return function (reason, plugins) {
3498
- var callsite = otherPlug || pname; // console.log(`__abort msg: ${reason}`)
3499
- // console.log(`__abort ${pname}`)
3500
- // console.log(`__abort xxx: ${plugins}`)
3501
- // console.log(`__abort otherPlug`, otherPlug)
3502
-
3503
- // console.log(`__abort msg: ${reason}`)
3504
- // console.log(`__abort ${pname}`)
3505
- // console.log(`__abort xxx: ${plugins}`)
3506
- // console.log(`__abort otherPlug`, otherPlug)
3507
- return _objectSpread2$1(_objectSpread2$1({}, currentAct), {}, {
3508
- abort: {
3509
- reason: reason,
3510
- plugins: plugins || [pname],
3511
- caller: method,
3512
- from: callsite
3513
- }
3514
- });
3515
- };
3516
- };
3517
-
3518
- _context2.next = 3;
3519
- return acc;
3520
-
3521
- case 3:
3522
- curScopeData = _context2.sent;
3523
-
3524
- if (!(!p.method || !_(p.method))) {
3525
- _context2.next = 6;
3526
- break;
3527
- }
3528
-
3529
- return _context2.abrupt("return", curScopeData);
3530
-
3531
- case 6:
3532
- /* Make sure plugins don’t call themselves */
3533
- validateMethod(p.methodName, p.pluginName);
3534
- _context2.next = 9;
3535
- return p.method({
3536
- payload: curScopeData,
3537
- instance: instance,
3538
- abort: genAbort(curScopeData, pluginName, p.pluginName),
3539
- config: getConfig(p.pluginName, plugins, allPlugins),
3540
- plugins: plugins
3541
- });
3542
-
3543
- case 9:
3544
- val = _context2.sent;
3545
- returnValue = M$1(val) ? val : {};
3546
- return _context2.abrupt("return", Promise.resolve(_objectSpread2$1(_objectSpread2$1({}, curScopeData), returnValue)));
3547
-
3548
- case 12:
3549
- case "end":
3550
- return _context2.stop();
3551
- }
3552
- }
3553
- }, _callee2);
3554
- }));
3555
-
3556
- return function (_x10, _x11, _x12) {
3557
- return _ref7.apply(this, arguments);
3558
- };
3559
- }(), Promise.resolve(action));
3560
-
3561
- case 7:
3562
- scopedPayload = _context3.sent;
3563
-
3564
- /* Set scoped payload */
3565
- curScope[pluginName] = scopedPayload;
3566
- _context3.next = 12;
3567
- break;
3568
-
3569
- case 11:
3570
- /* Set payload as default action */
3571
- curScope[pluginName] = action;
3572
-
3573
- case 12:
3574
- return _context3.abrupt("return", Promise.resolve(curScope));
3575
-
3576
- case 13:
3577
- case "end":
3578
- return _context3.stop();
3579
- }
3580
- }
3581
- }, _callee3);
3582
- }));
3583
-
3584
- return function (_x7, _x8, _x9) {
3585
- return _ref6.apply(this, arguments);
3586
- };
3587
- }(), Promise.resolve({}));
3588
-
3589
- case 10:
3590
- payloads = _context5.sent;
3591
- _context5.next = 13;
3592
- return data.exact.reduce( /*#__PURE__*/function () {
3593
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(promise, curr, i) {
3594
- var lastLoop, pluginName, currentPlugin, currentActionValue, payloadValue, funcArgs, val, returnValue, merged, scopedPayload, nameSpaceEvent, actionDepth, updatedPayload;
3595
- return regenerator.wrap(function _callee4$(_context4) {
3596
- while (1) {
3597
- switch (_context4.prev = _context4.next) {
3598
- case 0:
3599
- lastLoop = data.exact.length === i + 1;
3600
- pluginName = curr.pluginName;
3601
- currentPlugin = allPlugins[pluginName];
3602
- _context4.next = 5;
3603
- return promise;
3604
-
3605
- case 5:
3606
- currentActionValue = _context4.sent;
3607
- payloadValue = payloads[pluginName] ? payloads[pluginName] : {};
3608
- /* If eventStart, allow for value merging */
3609
-
3610
- /* If eventStart, allow for value merging */
3611
- if (isStartEvent) {
3612
- payloadValue = currentActionValue;
3613
- }
3614
-
3615
- if (!shouldAbort(payloadValue, pluginName)) {
3616
- _context4.next = 11;
3617
- break;
3618
- }
3619
-
3620
- // console.log(`> Abort from payload specific "${pluginName}" abort value`, payloadValue)
3621
- abortDispatch({
3622
- data: payloadValue,
3623
- method: method,
3624
- instance: instance,
3625
- pluginName: pluginName,
3626
- store: store
3627
- });
3628
- return _context4.abrupt("return", Promise.resolve(currentActionValue));
3629
-
3630
- case 11:
3631
- if (!shouldAbort(currentActionValue, pluginName)) {
3632
- _context4.next = 14;
3633
- break;
3634
- }
3635
-
3636
- // console.log(`> Abort from ${method} abort value`, currentActionValue)
3637
- if (lastLoop) {
3638
- abortDispatch({
3639
- data: currentActionValue,
3640
- method: method,
3641
- instance: instance,
3642
- // pluginName,
3643
- store: store
3644
- });
3645
- }
3646
-
3647
- return _context4.abrupt("return", Promise.resolve(currentActionValue));
3648
-
3649
- case 14:
3650
- if (!(queueData.hasOwnProperty(pluginName) && queueData[pluginName] === true)) {
3651
- _context4.next = 17;
3652
- break;
3653
- }
3654
-
3655
- // console.log('Queue this instead', pluginName)
3656
- store.dispatch({
3657
- type: "queue",
3658
- plugin: pluginName,
3659
- payload: payloadValue,
3660
-
3661
- /* Internal data for analytics engine */
3662
- _: {
3663
- called: "queue",
3664
- from: 'queueMechanism' // for debugging
3665
-
3666
- }
3667
- });
3668
- return _context4.abrupt("return", Promise.resolve(currentActionValue));
3669
-
3670
- case 17:
3671
- /*
3672
- const checkForLoaded = () => {
3673
- const p = instance.getState('plugins')
3674
- return p[currentPlugin.name].loaded
3675
- }
3676
- // const p = instance.getState('plugins')
3677
- console.log(`loaded "${currentPlugin.name}" > ${method}:`, p[currentPlugin.name].loaded)
3678
- // await waitForReady(currentPlugin, checkForLoaded, 10000).then((d) => {
3679
- // console.log(`Loaded ${method}`, currentPlugin.name)
3680
- // }).catch((e) => {
3681
- // console.log(`Error ${method} ${currentPlugin.name}`, e)
3682
- // // TODO dispatch failure
3683
- // })
3684
- */
3685
- // @TODO figure out if we want queuing semantics
3686
- funcArgs = makeArgs(payloads[pluginName], allPlugins[pluginName]); // console.log(`funcArgs ${method} ${pluginName}`, funcArgs)
3687
-
3688
- /* Run the plugin function */
3689
-
3690
- _context4.next = 20;
3691
- return currentPlugin[method]({
3692
- // currentPlugin: pluginName,
3693
- abort: funcArgs.abort,
3694
- // Send in original action value or scope payload
3695
- payload: payloadValue,
3696
- instance: instance,
3697
- config: getConfig(pluginName, plugins, allPlugins),
3698
- plugins: plugins
3699
- });
3700
-
3701
- case 20:
3702
- val = _context4.sent;
3703
- returnValue = M$1(val) ? val : {};
3704
- merged = _objectSpread2$1(_objectSpread2$1({}, currentActionValue), returnValue);
3705
- scopedPayload = payloads[pluginName]; // || currentActionValue
3706
-
3707
- // || currentActionValue
3708
- if (shouldAbort(scopedPayload, pluginName)) {
3709
- // console.log(`>> HANDLE abort ${method} ${pluginName}`)
3710
- abortDispatch({
3711
- data: scopedPayload,
3712
- method: method,
3713
- instance: instance,
3714
- pluginName: pluginName,
3715
- store: store
3716
- });
3717
- } else {
3718
- nameSpaceEvent = "".concat(method, ":").concat(pluginName);
3719
- actionDepth = (nameSpaceEvent.match(/:/g) || []).length;
3720
-
3721
- if (actionDepth < 2 && !method.match(bootstrapRegex) && !method.match(readyRegex)) {
3722
- updatedPayload = isStartEvent ? merged : payloadValue; // Dispatched for `.on('xyz') listeners.
3723
-
3724
- // Dispatched for `.on('xyz') listeners.
3725
- instance.dispatch(_objectSpread2$1(_objectSpread2$1({}, updatedPayload), {}, {
3726
- type: nameSpaceEvent,
3727
- _: {
3728
- called: nameSpaceEvent,
3729
- from: 'submethod'
3730
- }
3731
- }));
3732
- }
3733
- } // console.log('merged', merged)
3734
-
3735
-
3736
- return _context4.abrupt("return", Promise.resolve(merged));
3737
-
3738
- case 26:
3739
- case "end":
3740
- return _context4.stop();
3741
- }
3742
- }
3743
- }, _callee4);
3744
- }));
3745
-
3746
- return function (_x13, _x14, _x15) {
3747
- return _ref8.apply(this, arguments);
3748
- };
3749
- }(), Promise.resolve(action));
3750
-
3751
- case 13:
3752
- resolvedAction = _context5.sent;
3753
-
3754
- if (!(!method.match(endsWithStartRegex) && !method.match(/^registerPlugin/) && // !method.match(/^disablePlugin/) &&
3755
- // !method.match(/^enablePlugin/) &&
3756
- !method.match(readyRegex) && !method.match(bootstrapRegex) && !method.match(/^params/) && !method.match(/^userIdChanged/))) {
3757
- _context5.next = 21;
3758
- break;
3759
- }
3760
-
3761
- if (EVENTS.plugins.includes(method)) ;
3762
- /*
3763
- Verify this original action setup.
3764
- It's intended to keep actions from double dispatching themselves
3765
- */
3766
-
3767
-
3768
- if (!(resolvedAction._ && resolvedAction._.originalAction === method)) {
3769
- _context5.next = 18;
3770
- break;
3771
- }
3772
-
3773
- return _context5.abrupt("return", resolvedAction);
3774
-
3775
- case 18:
3776
- endAction = _objectSpread2$1(_objectSpread2$1({}, resolvedAction), {
3777
- _: {
3778
- originalAction: resolvedAction.type,
3779
- called: resolvedAction.type,
3780
- from: 'engineEnd'
3781
- }
3782
- });
3783
- /* If all plugins are aborted, dispatch xAborted */
3784
-
3785
- if (shouldAbortAll(resolvedAction, data.exact.length) && !method.match(/End$/)) {
3786
- endAction = _objectSpread2$1(_objectSpread2$1({}, endAction), {
3787
- type: resolvedAction.type + 'Aborted'
3788
- });
3789
- }
3790
-
3791
- store.dispatch(endAction);
3792
-
3793
- case 21:
3794
- return _context5.abrupt("return", resolvedAction);
3795
-
3796
- case 22:
3797
- case "end":
3798
- return _context5.stop();
3799
- }
3800
- }
3801
- }, _callee5);
3802
- }));
3803
- return _processEvent.apply(this, arguments);
3804
- }
3805
-
3806
- function abortDispatch(_ref3) {
3807
- var data = _ref3.data,
3808
- method = _ref3.method;
3809
- _ref3.instance;
3810
- var pluginName = _ref3.pluginName,
3811
- store = _ref3.store;
3812
- var postFix = pluginName ? ':' + pluginName : '';
3813
- var abortEvent = method + 'Aborted' + postFix;
3814
- store.dispatch(_objectSpread2$1(_objectSpread2$1({}, data), {}, {
3815
- type: abortEvent,
3816
- _: {
3817
- called: abortEvent,
3818
- from: 'abort'
3819
- }
3820
- }));
3821
- }
3822
-
3823
- function getConfig(name, pluginState, allPlugins) {
3824
- var pluginData = pluginState[name] || allPlugins[name];
3825
-
3826
- if (pluginData && pluginData.config) {
3827
- return pluginData.config;
3828
- }
3829
-
3830
- return {};
3831
- }
3832
-
3833
- function getPluginFunctions(methodName, plugins) {
3834
- return plugins.reduce(function (arr, plugin) {
3835
- return !plugin[methodName] ? arr : arr.concat({
3836
- methodName: methodName,
3837
- pluginName: plugin.name,
3838
- method: plugin[methodName]
3839
- });
3840
- }, []);
3841
- }
3842
-
3843
- function formatMethod(type) {
3844
- return type.replace(endsWithStartRegex, '');
3845
- }
3846
- /**
3847
- * Return array of event names
3848
- * @param {String} eventType - original event type
3849
- * @param {String} namespace - optional namespace postfix
3850
- * @return {array} - type, method, end
3851
- */
3852
-
3853
-
3854
- function getEventNames(eventType, namespace) {
3855
- var method = formatMethod(eventType);
3856
- var postFix = namespace ? ":".concat(namespace) : ''; // `typeStart:pluginName`
3857
-
3858
- var type = "".concat(eventType).concat(postFix); // `type:pluginName`
3859
-
3860
- var methodName = "".concat(method).concat(postFix); // `typeEnd:pluginName`
3861
-
3862
- var end = "".concat(method, "End").concat(postFix);
3863
- return [type, methodName, end];
3864
- }
3865
- /* Collect all calls for a given event in the system */
3866
-
3867
-
3868
- function getAllMatchingCalls(eventType, activePlugins, allPlugins) {
3869
- var eventNames = getEventNames(eventType); // console.log('eventNames', eventNames)
3870
- // 'eventStart', 'event', & `eventEnd`
3871
-
3872
- var core = eventNames.map(function (word) {
3873
- return getPluginFunctions(word, activePlugins);
3874
- }); // Gather nameSpaced Events
3875
-
3876
- return activePlugins.reduce(function (acc, plugin) {
3877
- var name = plugin.name;
3878
- var nameSpacedEvents = getEventNames(eventType, name); // console.log('eventNames namespaced', nameSpacedEvents)
3879
-
3880
- var _nameSpacedEvents$map = nameSpacedEvents.map(function (word) {
3881
- return getPluginFunctions(word, activePlugins);
3882
- }),
3883
- _nameSpacedEvents$map2 = _slicedToArray(_nameSpacedEvents$map, 3),
3884
- beforeFuncs = _nameSpacedEvents$map2[0],
3885
- duringFuncs = _nameSpacedEvents$map2[1],
3886
- afterFuncs = _nameSpacedEvents$map2[2];
3887
-
3888
- if (beforeFuncs.length) {
3889
- acc.beforeNS[name] = beforeFuncs;
3890
- }
3891
-
3892
- if (duringFuncs.length) {
3893
- acc.duringNS[name] = duringFuncs;
3894
- }
3895
-
3896
- if (afterFuncs.length) {
3897
- acc.afterNS[name] = afterFuncs;
3898
- }
3899
-
3900
- return acc;
3901
- }, {
3902
- before: core[0],
3903
- beforeNS: {},
3904
- during: core[1],
3905
- duringNS: {},
3906
- after: core[2],
3907
- afterNS: {}
3908
- });
3909
- }
3910
-
3911
- function shouldAbort(_ref4, pluginName) {
3912
- var abort = _ref4.abort;
3913
- if (!abort) return false;
3914
- if (abort === true) return true;
3915
- return includes(abort, pluginName) || abort && includes(abort.plugins, pluginName);
3916
- }
3917
-
3918
- function shouldAbortAll(_ref5, pluginsCount) {
3919
- var abort = _ref5.abort;
3920
- if (!abort) return false;
3921
- if (abort === true || L$2(abort)) return true;
3922
- var plugins = abort.plugins;
3923
- return isArray(abort) && abort.length === pluginsCount || isArray(plugins) && plugins.length === pluginsCount;
3924
- }
3925
-
3926
- function isArray(arr) {
3927
- return Array.isArray(arr);
3928
- }
3929
-
3930
- function includes(arr, name) {
3931
- if (!arr || !isArray(arr)) return false;
3932
- return arr.includes(name);
3933
- }
3934
- /**
3935
- * Generate arguments to pass to plugin methods
3936
- * @param {Object} instance - analytics instance
3937
- * @param {array} abortablePlugins - plugins that can be cancelled by caller
3938
- * @return {*} function to inject plugin params
3939
- */
3940
-
3941
-
3942
- function argumentFactory(instance, abortablePlugins) {
3943
- // console.log('abortablePlugins', abortablePlugins)
3944
- return function (action, plugin, otherPlugin) {
3945
- var config = plugin.config,
3946
- name = plugin.name;
3947
- var method = "".concat(name, ".").concat(action.type);
3948
-
3949
- if (otherPlugin) {
3950
- method = otherPlugin.event;
3951
- }
3952
-
3953
- var abortF = action.type.match(endsWithStartRegex) ? abortFunction(name, method, abortablePlugins, otherPlugin, action) : notAbortableError(action, method);
3954
- return {
3955
- /* self: plugin, for future maybe */
3956
- // clone objects to avoid reassign
3957
- payload: formatPayload(action),
3958
- instance: instance,
3959
- config: config || {},
3960
- abort: abortF
3961
- };
3962
- };
3963
- }
3964
-
3965
- function abortFunction(pluginName, method, abortablePlugins, otherPlugin, action) {
3966
- return function (reason, plugins) {
3967
- var caller = otherPlugin ? otherPlugin.name : pluginName;
3968
- var pluginsToAbort = plugins && isArray(plugins) ? plugins : abortablePlugins;
3969
-
3970
- if (otherPlugin) {
3971
- pluginsToAbort = plugins && isArray(plugins) ? plugins : [pluginName];
3972
-
3973
- if (!pluginsToAbort.includes(pluginName) || pluginsToAbort.length !== 1) {
3974
- throw new Error("Method ".concat(method, " can only abort ").concat(pluginName, " plugin. ").concat(JSON.stringify(pluginsToAbort), " input valid"));
3975
- }
3976
- }
3977
-
3978
- return _objectSpread2$1(_objectSpread2$1({}, action), {}, {
3979
- // 🔥 todo verify this merge is ok
3980
- abort: {
3981
- reason: reason,
3982
- plugins: pluginsToAbort,
3983
- caller: method,
3984
- _: caller
3985
- }
3986
- });
3987
- };
3988
- }
3989
-
3990
- function notAbortableError(action, method) {
3991
- return function () {
3992
- throw new Error(action.type + ' action not cancellable. Remove abort in ' + method);
3993
- };
3994
- }
3995
- /**
3996
- * Verify plugin is not calling itself with whatever:myPluginName self refs
3997
- */
3998
-
3999
-
4000
- function validateMethod(actionName, pluginName) {
4001
- var text = getNameSpacedAction(actionName);
4002
- var methodCallMatchesPluginNamespace = text && text.name === pluginName;
4003
-
4004
- if (methodCallMatchesPluginNamespace) {
4005
- var sub = getNameSpacedAction(text.method);
4006
- var subText = sub ? 'or ' + sub.method : '';
4007
- throw new Error([pluginName + ' plugin is calling method ' + actionName, 'Plugins cant call self', "Use ".concat(text.method, " ").concat(subText, " in ").concat(pluginName, " plugin insteadof ").concat(actionName)].join('\n'));
4008
- }
4009
- }
4010
-
4011
- function getNameSpacedAction(event) {
4012
- var split = event.match(/(.*):(.*)/);
4013
-
4014
- if (!split) {
4015
- return false;
4016
- }
4017
-
4018
- return {
4019
- method: split[1],
4020
- name: split[2]
4021
- };
4022
- }
4023
-
4024
- function formatPayload(action) {
4025
- return Object.keys(action).reduce(function (acc, key) {
4026
- // redact type from { payload }
4027
- if (key === 'type') {
4028
- return acc;
4029
- }
4030
-
4031
- if (M$1(action[key])) {
4032
- acc[key] = Object.assign({}, action[key]);
4033
- } else {
4034
- acc[key] = action[key];
4035
- }
4036
-
4037
- return acc;
4038
- }, {});
4039
- }
4040
- /*
4041
- function getMatchingMethods(eventType, activePlugins) {
4042
- const exact = getPluginFunctions(eventType, activePlugins)
4043
- // console.log('exact', exact)
4044
- // Gather nameSpaced Events
4045
- return activePlugins.reduce((acc, plugin) => {
4046
- const { name } = plugin
4047
- const clean = getPluginFunctions(`${eventType}:${name}`, activePlugins)
4048
- if (clean.length) {
4049
- acc.namespaced[name] = clean
4050
- }
4051
- return acc
4052
- }, {
4053
- exact: exact,
4054
- namespaced: {}
4055
- })
4056
- }
4057
- */
4058
-
4059
- function pluginMiddleware(instance, getPlugins, systemEvents) {
4060
- var isReady = {};
4061
- return function (store) {
4062
- return function (next) {
4063
- return /*#__PURE__*/function () {
4064
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(action) {
4065
- var type, abort, plugins, updatedAction, allPlugins, pluginsArray, allRegisteredPlugins, completed, failed, disabled, waitForPluginsToLoad, updated;
4066
- return regenerator.wrap(function _callee$(_context) {
4067
- while (1) {
4068
- switch (_context.prev = _context.next) {
4069
- case 0:
4070
- type = action.type, abort = action.abort, plugins = action.plugins;
4071
- updatedAction = action;
4072
-
4073
- if (!abort) {
4074
- _context.next = 4;
4075
- break;
4076
- }
4077
-
4078
- return _context.abrupt("return", next(action));
4079
-
4080
- case 4:
4081
- /* Analytics.plugins.enable called, we need to init the plugins */
4082
- if (type === EVENTS$1.enablePlugin) {
4083
- store.dispatch({
4084
- type: EVENTS$1.initializeStart,
4085
- plugins: plugins,
4086
- disabled: [],
4087
- fromEnable: true,
4088
- meta: action.meta
4089
- });
4090
- }
4091
-
4092
- if (type === EVENTS$1.disablePlugin) {
4093
- // If cached callback, resolve promise/run callback. debounced to fix race condition
4094
- setTimeout(function () {
4095
- return runCallback(action.meta.rid, {
4096
- payload: action
4097
- });
4098
- }, 0);
4099
- }
4100
- /* @TODO implement
4101
- if (type === EVENTS.loadPlugin) {
4102
- // Rerun initialize calls in plugins
4103
- const allPlugins = getPlugins()
4104
- const pluginsToLoad = Object.keys(allPlugins).filter((name) => {
4105
- return plugins.includes(name)
4106
- }).reduce((acc, curr) => {
4107
- acc[curr] = allPlugins[curr]
4108
- return acc
4109
- }, {})
4110
- const initializeAction = {
4111
- type: EVENTS.initializeStart,
4112
- plugins: plugins
4113
- }
4114
- const updated = await runPlugins(initializeAction, pluginsToLoad, instance, store, systemEvents)
4115
- return next(updated)
4116
- }
4117
- */
4118
- // || type.match(/^initializeAbort:/)
4119
-
4120
-
4121
- if (type === EVENTS$1.initializeEnd) {
4122
- allPlugins = getPlugins();
4123
- pluginsArray = Object.keys(allPlugins);
4124
- allRegisteredPlugins = pluginsArray.filter(function (name) {
4125
- return plugins.includes(name);
4126
- }).map(function (name) {
4127
- return allPlugins[name];
4128
- });
4129
- completed = [];
4130
- failed = [];
4131
- disabled = action.disabled; // console.log('allRegisteredPlugins', allRegisteredPlugins)
4132
-
4133
- waitForPluginsToLoad = allRegisteredPlugins.map(function (plugin) {
4134
- var loaded = plugin.loaded,
4135
- name = plugin.name;
4136
- /* Plugins will abort trying to load after 10 seconds. 1e4 === 10000 MS */
4137
-
4138
- return waitForReady(plugin, loaded, 1e4).then(function (d) {
4139
- if (!isReady[name]) {
4140
- // only dispatch namespaced rdy once
4141
- store.dispatch({
4142
- type: EVENTS$1.pluginReadyType(name),
4143
- // `ready:${name}`
4144
- name: name,
4145
- events: Object.keys(plugin).filter(function (name) {
4146
- return !nonEvents.includes(name);
4147
- })
4148
- });
4149
- isReady[name] = true;
4150
- }
4151
-
4152
- completed = completed.concat(name);
4153
- return plugin; // It's loaded! run the command
4154
- })["catch"](function (e) {
4155
- // Timeout Add to queue
4156
- // console.log('Error generic waitForReady. Push this to queue', e)
4157
- if (e instanceof Error) {
4158
- throw new Error(e);
4159
- }
4160
-
4161
- failed = failed.concat(e.name); // Failed to fire, add to queue
4162
-
4163
- return e;
4164
- });
4165
- });
4166
- Promise.all(waitForPluginsToLoad).then(function (calls) {
4167
- // setTimeout to ensure runs after 'page'
4168
- var payload = {
4169
- plugins: completed,
4170
- failed: failed,
4171
- disabled: disabled
4172
- };
4173
- setTimeout(function () {
4174
- if (pluginsArray.length === waitForPluginsToLoad.length + disabled.length) {
4175
- store.dispatch(_objectSpread2$1(_objectSpread2$1({}, {
4176
- type: EVENTS$1.ready
4177
- }), payload));
4178
- }
4179
- }, 0);
4180
- });
4181
- }
4182
- /* New plugin system */
4183
-
4184
-
4185
- if (!(type !== EVENTS$1.bootstrap)) {
4186
- _context.next = 13;
4187
- break;
4188
- }
4189
-
4190
- if (/^ready:([^:]*)$/.test(type)) {
4191
- // Immediately flush queue
4192
- setTimeout(function () {
4193
- return processQueue(store, getPlugins, instance);
4194
- }, 0);
4195
- }
4196
-
4197
- _context.next = 11;
4198
- return runPlugins(action, getPlugins, instance, store, systemEvents);
4199
-
4200
- case 11:
4201
- updated = _context.sent;
4202
- return _context.abrupt("return", next(updated));
4203
-
4204
- case 13:
4205
- return _context.abrupt("return", next(updatedAction));
4206
-
4207
- case 14:
4208
- case "end":
4209
- return _context.stop();
4210
- }
4211
- }
4212
- }, _callee);
4213
- }));
4214
-
4215
- return function (_x) {
4216
- return _ref.apply(this, arguments);
4217
- };
4218
- }();
4219
- };
4220
- };
4221
- }
4222
-
4223
- function storageMiddleware(storage) {
4224
- return function (store) {
4225
- return function (next) {
4226
- return function (action) {
4227
- var type = action.type,
4228
- key = action.key,
4229
- value = action.value,
4230
- options = action.options;
4231
-
4232
- if (type === EVENTS$1.setItem || type === EVENTS$1.removeItem) {
4233
- if (action.abort) {
4234
- return next(action);
4235
- } // Run storage set or remove
4236
-
4237
-
4238
- if (type === EVENTS$1.setItem) {
4239
- storage.setItem(key, value, options);
4240
- } else {
4241
- storage.removeItem(key, options);
4242
- }
4243
- }
4244
-
4245
- return next(action);
4246
- };
4247
- };
4248
- };
4249
- }
4250
- /*
4251
- Todo: emit events for keys we care about
4252
- window.addEventListener('storage', (event) => console.log(event));
4253
- */
4254
-
4255
- function _defineProperties(target, props) {
4256
- for (var i = 0; i < props.length; i++) {
4257
- var descriptor = props[i];
4258
- descriptor.enumerable = descriptor.enumerable || false;
4259
- descriptor.configurable = true;
4260
- if ("value" in descriptor) descriptor.writable = true;
4261
- Object.defineProperty(target, descriptor.key, descriptor);
4262
- }
4263
- }
4264
-
4265
- function _createClass(Constructor, protoProps, staticProps) {
4266
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4267
- if (staticProps) _defineProperties(Constructor, staticProps);
4268
- Object.defineProperty(Constructor, "prototype", {
4269
- writable: false
4270
- });
4271
- return Constructor;
4272
- }
4273
-
4274
- function _classCallCheck(instance, Constructor) {
4275
- if (!(instance instanceof Constructor)) {
4276
- throw new TypeError("Cannot call a class as a function");
4277
- }
4278
- }
4279
-
4280
- /* Class to fix dynamic middlewares from conflicting with each other
4281
- if more than one analytic instance is active */
4282
-
4283
- var DynamicMiddleware = /*#__PURE__*/_createClass(function DynamicMiddleware() {
4284
- var _this = this;
4285
-
4286
- _classCallCheck(this, DynamicMiddleware);
4287
-
4288
- _defineProperty$1(this, "before", []);
4289
-
4290
- _defineProperty$1(this, "after", []);
4291
-
4292
- _defineProperty$1(this, "addMiddleware", function (middlewares, position) {
4293
- _this[position] = _this[position].concat(middlewares);
4294
- });
4295
-
4296
- _defineProperty$1(this, "removeMiddleware", function (middleware, position) {
4297
- var index = _this[position].findIndex(function (d) {
4298
- return d === middleware;
4299
- });
4300
-
4301
- if (index === -1) return;
4302
- _this[position] = [].concat(_toConsumableArray(_this[position].slice(0, index)), _toConsumableArray(_this[position].slice(index + 1)));
4303
- });
4304
-
4305
- _defineProperty$1(this, "dynamicMiddlewares", function (position) {
4306
- return function (store) {
4307
- return function (next) {
4308
- return function (action) {
4309
- var middlewareAPI = {
4310
- getState: store.getState,
4311
- dispatch: function dispatch(act) {
4312
- return store.dispatch(act);
4313
- }
4314
- };
4315
-
4316
- var chain = _this[position].map(function (middleware) {
4317
- return middleware(middlewareAPI);
4318
- });
4319
-
4320
- return compose.apply(void 0, _toConsumableArray(chain))(next)(action);
4321
- };
4322
- };
4323
- };
4324
- });
4325
- });
4326
-
4327
- function createReducer(getPlugins) {
4328
- return function plugins() {
4329
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4330
- var action = arguments.length > 1 ? arguments[1] : undefined;
4331
- var newState = {};
4332
-
4333
- if (action.type === 'initialize:aborted') {
4334
- return state;
4335
- }
4336
-
4337
- if (/^registerPlugin:([^:]*)$/.test(action.type)) {
4338
- var name = getNameFromEventType(action.type, 'registerPlugin');
4339
- var plugin = getPlugins()[name];
4340
-
4341
- if (!plugin || !name) {
4342
- return state;
4343
- }
4344
-
4345
- var isEnabled = action.enabled;
4346
- newState[name] = {
4347
- enabled: isEnabled,
4348
-
4349
- /* if no initialization method. Set initialized true */
4350
- initialized: isEnabled ? Boolean(!plugin.initialize) : false,
4351
-
4352
- /* If plugin enabled === false, set loaded to false, else check plugin.loaded function */
4353
- loaded: isEnabled ? Boolean(plugin.loaded()) : false,
4354
- config: plugin.config || {}
4355
- };
4356
- return _objectSpread2$1(_objectSpread2$1({}, state), newState);
4357
- }
4358
-
4359
- if (/^initialize:([^:]*)$/.test(action.type)) {
4360
- var _name = getNameFromEventType(action.type, EVENTS$1.initialize);
4361
-
4362
- var _plugin = getPlugins()[_name];
4363
-
4364
- if (!_plugin || !_name) {
4365
- return state;
4366
- }
4367
-
4368
- newState[_name] = _objectSpread2$1(_objectSpread2$1({}, state[_name]), {
4369
- initialized: true,
4370
-
4371
- /* check plugin.loaded function */
4372
- loaded: Boolean(_plugin.loaded())
4373
- });
4374
- return _objectSpread2$1(_objectSpread2$1({}, state), newState);
4375
- }
4376
-
4377
- if (/^ready:([^:]*)$/.test(action.type)) {
4378
- // const name = getNameFromEventType(action.type, 'ready')
4379
- newState[action.name] = _objectSpread2$1(_objectSpread2$1({}, state[action.name]), {
4380
- loaded: true
4381
- });
4382
- return _objectSpread2$1(_objectSpread2$1({}, state), newState);
4383
- }
4384
-
4385
- switch (action.type) {
4386
- /* case EVENTS.pluginFailed:
4387
- // console.log('PLUGIN_FAILED', action.name)
4388
- newState[action.name] = {
4389
- ...state[action.name],
4390
- ...{ loaded: false }
4391
- }
4392
- return { ...state, ...newState }
4393
- */
4394
-
4395
- /* When analytics.plugins.disable called */
4396
- case EVENTS$1.disablePlugin:
4397
- return _objectSpread2$1(_objectSpread2$1({}, state), togglePluginStatus(action.plugins, false, state));
4398
-
4399
- /* When analytics.plugins.enable called */
4400
-
4401
- case EVENTS$1.enablePlugin:
4402
- return _objectSpread2$1(_objectSpread2$1({}, state), togglePluginStatus(action.plugins, true, state));
4403
-
4404
- default:
4405
- return state;
4406
- }
4407
- };
4408
- }
4409
-
4410
- function getNameFromEventType(type, baseName) {
4411
- return type.substring(baseName.length + 1, type.length);
4412
- }
4413
-
4414
- function togglePluginStatus(plugins, status, currentState) {
4415
- return plugins.reduce(function (acc, pluginKey) {
4416
- acc[pluginKey] = _objectSpread2$1(_objectSpread2$1({}, currentState[pluginKey]), {
4417
- enabled: status
4418
- });
4419
- return acc;
4420
- }, currentState);
4421
- }
4422
-
4423
- function serialize(obj) {
4424
- try {
4425
- return JSON.parse(JSON.stringify(obj));
4426
- } catch (err) {}
4427
-
4428
- return obj;
4429
- }
4430
-
4431
- var initialState$3 = {
4432
- last: {},
4433
- history: []
4434
- }; // track reducer
4435
-
4436
- function trackReducer() {
4437
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$3;
4438
- var action = arguments.length > 1 ? arguments[1] : undefined;
4439
- var type = action.type,
4440
- event = action.event,
4441
- properties = action.properties,
4442
- options = action.options,
4443
- meta = action.meta;
4444
-
4445
- switch (type) {
4446
- case EVENTS$1.track:
4447
- var trackEvent = serialize(_objectSpread2$1(_objectSpread2$1({
4448
- event: event,
4449
- properties: properties
4450
- }, Object.keys(options).length && {
4451
- options: options
4452
- }), {}, {
4453
- meta: meta
4454
- }));
4455
- return _objectSpread2$1(_objectSpread2$1({}, state), {
4456
- last: trackEvent,
4457
- // Todo prevent LARGE arrays https://bit.ly/2MnBwPT
4458
- history: state.history.concat(trackEvent)
4459
- });
4460
-
4461
- default:
4462
- return state;
4463
- }
4464
- }
4465
-
4466
- /*
4467
- TODO figure out if this should live in state...
4468
- Queue could be in mermory as well.
4469
- But also needs to be persisted to storage
4470
- */
4471
-
4472
- var initialState$2 = {
4473
- actions: []
4474
- };
4475
- function queueReducer() {
4476
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$2;
4477
- var action = arguments.length > 1 ? arguments[1] : undefined;
4478
- var type = action.type,
4479
- payload = action.payload;
4480
-
4481
- switch (type) {
4482
- case 'queue':
4483
- var actionChain;
4484
- /* prioritize identify in event queue */
4485
-
4486
- if (payload && payload.type && payload.type === EVENTS$1.identify) {
4487
- actionChain = [action].concat(state.actions);
4488
- } else {
4489
- actionChain = state.actions.concat(action);
4490
- }
4491
-
4492
- return _objectSpread2$1(_objectSpread2$1({}, state), {}, {
4493
- actions: actionChain
4494
- });
4495
-
4496
- case 'dequeue':
4497
- return [];
4498
- // todo push events to history
4499
-
4500
- default:
4501
- return state;
4502
- }
4503
- }
4504
-
4505
- var hashRegex = /#.*$/;
4506
-
4507
- function canonicalUrl() {
4508
- if (!z$1) return;
4509
- var tags = document.getElementsByTagName('link');
4510
-
4511
- for (var i = 0, tag; tag = tags[i]; i++) {
4512
- if (tag.getAttribute('rel') === 'canonical') {
4513
- return tag.getAttribute('href');
4514
- }
4515
- }
4516
- }
4517
-
4518
- function urlPath(url) {
4519
- var regex = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g;
4520
- var matches = regex.exec(url);
4521
- var pathMatch = matches && matches[3] ? matches[3].split('?')[0].replace(hashRegex, '') : '';
4522
- return '/' + pathMatch;
4523
- }
4524
- /**
4525
- * Return the canonical URL and rmove the hash.
4526
- * @param {string} search - search param
4527
- * @return {string} return current canonical URL
4528
- */
4529
-
4530
-
4531
- function currentUrl(search) {
4532
- var canonical = canonicalUrl();
4533
- if (!canonical) return window.location.href.replace(hashRegex, '');
4534
- return canonical.match(/\?/) ? canonical : canonical + search;
4535
- }
4536
- /**
4537
- * Page data for overides
4538
- * @typedef {object} PageData
4539
- * @property {string} [title] - Page title
4540
- * @property {string} [url] - Page url
4541
- * @property {string} [path] - Page path
4542
- * @property {string} [search] - Page search
4543
- * @property {string} [width] - Page width
4544
- * @property {string} [height] - Page height
4545
- */
4546
-
4547
- /**
4548
- * Get information about current page
4549
- * @typedef {Function} getPageData
4550
- * @param {PageData} [pageData = {}] - Page data overides
4551
- * @return {PageData} resolved page data
4552
- */
4553
-
4554
-
4555
- var getPageData = function getPageData() {
4556
- var pageData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4557
- if (!z$1) return pageData;
4558
- var _document = document,
4559
- title = _document.title,
4560
- referrer = _document.referrer;
4561
- var _window = window,
4562
- location = _window.location,
4563
- innerWidth = _window.innerWidth,
4564
- innerHeight = _window.innerHeight;
4565
- var hash = location.hash,
4566
- search = location.search;
4567
- var url = currentUrl(search);
4568
- var page = {
4569
- title: title,
4570
- url: url,
4571
- path: urlPath(url),
4572
- hash: hash,
4573
- search: search,
4574
- width: innerWidth,
4575
- height: innerHeight
4576
- };
4577
-
4578
- if (referrer && referrer !== '') {
4579
- page.referrer = referrer;
4580
- }
4581
-
4582
- return _objectSpread2$1(_objectSpread2$1({}, page), pageData);
4583
- };
4584
- var initialState$1 = {
4585
- last: {},
4586
- history: []
4587
- }; // page reducer
4588
-
4589
- function page() {
4590
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$1;
4591
- var action = arguments.length > 1 ? arguments[1] : undefined;
4592
- var properties = action.properties,
4593
- options = action.options,
4594
- meta = action.meta;
4595
-
4596
- switch (action.type) {
4597
- case EVENTS$1.page:
4598
- var viewData = serialize(_objectSpread2$1({
4599
- properties: properties,
4600
- meta: meta
4601
- }, Object.keys(options).length && {
4602
- options: options
4603
- }));
4604
- return _objectSpread2$1(_objectSpread2$1({}, state), {
4605
- last: viewData,
4606
- // Todo prevent LARGE arrays https://bit.ly/2MnBwPT
4607
- history: state.history.concat(viewData)
4608
- });
4609
-
4610
- default:
4611
- return state;
4612
- }
4613
- }
4614
-
4615
- function getBrowserOS() {
4616
- if (!z$1) return false;
4617
- var os = navigator.appVersion; // ~os bitwise operator to check if in navigator
4618
-
4619
- if (~os.indexOf('Win')) return 'Windows';
4620
- if (~os.indexOf('Mac')) return 'MacOS';
4621
- if (~os.indexOf('X11')) return 'UNIX';
4622
- if (~os.indexOf('Linux')) return 'Linux'; // default
4623
-
4624
- return 'Unknown OS';
4625
- }
4626
-
4627
- var osName;
4628
- var referrer;
4629
- var locale;
4630
- var timeZone;
4631
-
4632
- {
4633
- osName = getBrowserOS();
4634
- referrer = z$1 ? document.referrer : null;
4635
- locale = o$2();
4636
- timeZone = a$3();
4637
- }
4638
-
4639
- var initialState = {
4640
- initialized: false,
4641
- sessionId: y(),
4642
- app: null,
4643
- version: null,
4644
- debug: false,
4645
- offline: z$1 ? !navigator.onLine : false,
4646
- // use node network is-online
4647
- os: {
4648
- name: osName
4649
- },
4650
- userAgent: z$1 ? navigator.userAgent : 'node',
4651
- // https://github.com/bestiejs/platform.js
4652
- library: {
4653
- name: LIB_NAME,
4654
- // TODO fix version number. npm run publish:patch has wrong version
4655
- version: "0.10.22"
4656
- },
4657
- timezone: timeZone,
4658
- locale: locale,
4659
- campaign: {},
4660
- referrer: referrer
4661
- }; // context reducer
4662
-
4663
- function context() {
4664
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
4665
- var action = arguments.length > 1 ? arguments[1] : undefined;
4666
- var initialized = state.initialized;
4667
- var type = action.type,
4668
- campaign = action.campaign;
4669
-
4670
- switch (type) {
4671
- case EVENTS$1.campaign:
4672
- return _objectSpread2$1(_objectSpread2$1({}, state), {
4673
- campaign: campaign
4674
- });
4675
-
4676
- case EVENTS$1.offline:
4677
- return _objectSpread2$1(_objectSpread2$1({}, state), {
4678
- offline: true
4679
- });
4680
-
4681
- case EVENTS$1.online:
4682
- return _objectSpread2$1(_objectSpread2$1({}, state), {
4683
- offline: false
4684
- });
4685
-
4686
- default:
4687
- if (!initialized) {
4688
- return _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, initialState), state), {
4689
- initialized: true
4690
- });
4691
- }
4692
-
4693
- return state;
4694
- }
4695
- }
4696
- var excludeItems = ['plugins', 'reducers', 'storage']; // Pull plugins and reducers off intital config
4697
-
4698
- function makeContext(config) {
4699
- return Object.keys(config).reduce(function (acc, current) {
4700
- if (excludeItems.includes(current)) {
4701
- return acc;
4702
- }
4703
-
4704
- acc[current] = config[current];
4705
- return acc;
4706
- }, {});
4707
- }
4708
-
4709
- function listen(events, func, toAdd) {
4710
- if (!z$1) return;
4711
- var fn = window[(toAdd ? 'add' : 'remove') + 'EventListener'];
4712
- events.split(' ').forEach(function (ev) {
4713
- fn(ev, func);
4714
- });
4715
- }
4716
-
4717
- function check() {
4718
- return Promise.resolve(!navigator.onLine);
4719
- }
4720
- function watch(cb) {
4721
- var fn = function fn(_) {
4722
- return check().then(cb);
4723
- };
4724
-
4725
- var listener = listen.bind(null, 'online offline', fn);
4726
- listener(true); // return unsubscribe function
4727
-
4728
- return function (_) {
4729
- return listener(false);
4730
- };
4731
- }
4732
-
4733
- function Debug() {
4734
- // Global key is window.__global__.analytics
4735
- f$1(LIB_NAME, []); // Return debugger
4736
-
4737
- return function (createStore) {
4738
- return function (reducer, preloadedState, enhancer) {
4739
- var store = createStore(reducer, preloadedState, enhancer);
4740
- var origDispatch = store.dispatch;
4741
-
4742
- var dispatch = function dispatch(action) {
4743
- var a = action.action || action;
4744
- n$2[o][LIB_NAME].push(a);
4745
- return origDispatch(action);
4746
- };
4747
-
4748
- return Object.assign(store, {
4749
- dispatch: dispatch
4750
- });
4751
- };
4752
- };
4753
- }
4754
- function composeWithDebug(config) {
4755
- return function () {
4756
- return compose(compose.apply(null, arguments), Debug());
4757
- };
4758
- }
4759
-
4760
- function ensureArray(singleOrArray) {
4761
- if (!singleOrArray) return [];
4762
- if (G$1(singleOrArray)) return singleOrArray;
4763
- return [singleOrArray];
4764
- }
4765
-
4766
- /**
4767
- * Grab first function found from arguments
4768
- * @param {array} [argArray] - arguments array to find first function
4769
- * @returns {Function|undefined}
4770
- */
4771
-
4772
- function getCallbackFromArgs(argArray) {
4773
- var args = argArray || Array.prototype.slice.call(arguments);
4774
- var cb;
4775
-
4776
- for (var i = 0; i < args.length; i++) {
4777
- if (_(args[i])) {
4778
- cb = args[i];
4779
- break;
4780
- }
4781
- }
4782
-
4783
- return cb;
4784
- }
4785
-
4786
- function timeStamp() {
4787
- return new Date().getTime();
4788
- }
4789
-
4790
- function deferredPromiseResolver(resolver, callback) {
4791
- return function (data) {
4792
- if (callback) callback(data);
4793
- resolver(data);
4794
- };
4795
- }
4796
-
4797
- function generateMeta() {
4798
- var meta = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4799
- var resolve = arguments.length > 1 ? arguments[1] : undefined;
4800
- var possibleCallbacks = arguments.length > 2 ? arguments[2] : undefined;
4801
- var rid = y();
4802
-
4803
- if (resolve) {
4804
- // stack[`${rid}-info`] = meta
4805
- stack[rid] = deferredPromiseResolver(resolve, getCallbackFromArgs(possibleCallbacks));
4806
- }
1257
+ var t="cookie",i$1=a$1(),r$1=d$1,c=d$1;function u(o){return i$1?d$1(o,"",-1):i$2(o)}function a$1(){if(void 0!==i$1)return i$1;var e="cookiecookie";try{d$1(e,e),i$1=-1!==document.cookie.indexOf(e),u(e);}catch(e){i$1=!1;}return i$1}function d$1(e,t,r,c,u,a){if("undefined"!=typeof window){var d=arguments.length>1;return !1===i$1&&(d?f(e,t):a$2(e)),d?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(c?"; path="+c:"")+(u?"; domain="+u:"")+(a?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}
4807
1258
 
4808
- return _objectSpread2$1(_objectSpread2$1({}, meta), {}, {
4809
- rid: rid,
4810
- ts: timeStamp()
4811
- }, !resolve ? {} : {
4812
- hasCallback: true
4813
- });
4814
- }
4815
-
4816
- /**
4817
- * Analytics library configuration
4818
- *
4819
- * After the library is initialized with config, the core API is exposed & ready for use in the application.
4820
- *
4821
- * @param {object} config - analytics core config
4822
- * @param {string} [config.app] - Name of site / app
4823
- * @param {string} [config.version] - Version of your app
4824
- * @param {boolean} [config.debug] - Should analytics run in debug mode
4825
- * @param {Array.<AnalyticsPlugin>} [config.plugins] - Array of analytics plugins
4826
- * @return {AnalyticsInstance} Analytics Instance
4827
- * @example
4828
- *
4829
- * import Analytics from 'analytics'
4830
- * import pluginABC from 'analytics-plugin-abc'
4831
- * import pluginXYZ from 'analytics-plugin-xyz'
4832
- *
4833
- * // initialize analytics
4834
- * const analytics = Analytics({
4835
- * app: 'my-awesome-app',
4836
- * plugins: [
4837
- * pluginABC,
4838
- * pluginXYZ
4839
- * ]
4840
- * })
4841
- *
4842
- */
4843
-
4844
- function analytics() {
4845
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4846
- var customReducers = config.reducers || {};
4847
- var initialUser = config.initialUser || {}; // @TODO add custom value reolvers for userId and anonId
4848
- // const resolvers = config.resolvers || {}
4849
-
4850
- /* Parse plugins array */
4851
-
4852
- var parsedOptions = (config.plugins || []).reduce(function (acc, plugin) {
4853
- if (_(plugin)) {
4854
- /* Custom redux middleware */
4855
- acc.middlewares = acc.middlewares.concat(plugin);
4856
- return acc;
4857
- } // Legacy plugin with name
4858
-
4859
-
4860
- if (plugin.NAMESPACE) plugin.name = plugin.NAMESPACE;
4861
-
4862
- if (!plugin.name) {
4863
- /* Plugins must supply a "name" property. See error url for more details */
4864
- throw new Error(ERROR_URL + '1');
4865
- } // if plugin exposes EVENTS capture available events
4866
-
4867
-
4868
- var definedEvents = plugin.EVENTS ? Object.keys(plugin.EVENTS).map(function (k) {
4869
- return plugin.EVENTS[k];
4870
- }) : [];
4871
- var enabledFromMerge = !(plugin.enabled === false);
4872
- var enabledFromPluginConfig = !(plugin.config && plugin.config.enabled === false); // top level { enabled: false } takes presidence over { config: enabled: false }
4873
-
4874
- acc.pluginEnabled[plugin.name] = enabledFromMerge && enabledFromPluginConfig;
4875
- delete plugin.enabled;
4876
-
4877
- if (plugin.methods) {
4878
- acc.methods[plugin.name] = Object.keys(plugin.methods).reduce(function (a, c) {
4879
- // enrich methods with analytics instance
4880
- a[c] = appendArguments(plugin.methods[c]);
4881
- return a;
4882
- }, {}); // Remove additional methods from plugins
4883
-
4884
- delete plugin.methods;
4885
- } // Convert available methods into events
4886
-
4887
-
4888
- var methodsToEvents = Object.keys(plugin); // Combine events
4889
-
4890
- var allEvents = methodsToEvents.concat(definedEvents); // Dedupe events list
4891
-
4892
- var allEventsUnique = new Set(acc.events.concat(allEvents));
4893
- acc.events = Array.from(allEventsUnique);
4894
- acc.pluginsArray = acc.pluginsArray.concat(plugin);
4895
-
4896
- if (acc.plugins[plugin.name]) {
4897
- throw new Error(plugin.name + 'AlreadyLoaded');
4898
- }
4899
-
4900
- acc.plugins[plugin.name] = plugin;
4901
-
4902
- if (!acc.plugins[plugin.name].loaded) {
4903
- // set default loaded func
4904
- acc.plugins[plugin.name].loaded = function () {
4905
- return true;
4906
- };
4907
- }
4908
-
4909
- return acc;
4910
- }, {
4911
- plugins: {},
4912
- pluginEnabled: {},
4913
- methods: {},
4914
- pluginsArray: [],
4915
- middlewares: [],
4916
- events: []
4917
- });
4918
- /* Storage by default is set to global & is not persisted */
4919
-
4920
- var storage = config.storage ? config.storage : {
4921
- getItem: a$2,
4922
- setItem: f$1,
4923
- removeItem: i$2
4924
- };
4925
- var getUserProp = getUserPropFunc(storage); // mutable intregrations object for dynamic loading
4926
-
4927
- var customPlugins = parsedOptions.plugins;
4928
- /* Grab all registered events from plugins loaded */
4929
-
4930
- var allPluginEvents = parsedOptions.events.filter(function (name) {
4931
- return !nonEvents.includes(name);
4932
- }).sort();
4933
- var uniqueEvents = new Set(allPluginEvents.concat(coreEvents).filter(function (name) {
4934
- return !nonEvents.includes(name);
4935
- }));
4936
- var allSystemEvents = Array.from(uniqueEvents).sort();
4937
- /* plugin methods(functions) must be kept out of state. thus they live here */
4938
-
4939
- var getPlugins = function getPlugins() {
4940
- return customPlugins;
4941
- };
4942
-
4943
- var _DynamicMiddleware = new DynamicMiddleware(),
4944
- addMiddleware = _DynamicMiddleware.addMiddleware,
4945
- removeMiddleware = _DynamicMiddleware.removeMiddleware,
4946
- dynamicMiddlewares = _DynamicMiddleware.dynamicMiddlewares;
4947
-
4948
- var nonAbortable = function nonAbortable() {
4949
- // throw new Error(`${ERROR_URL}3`)
4950
- throw new Error('Abort disabled inListener');
4951
- }; // Parse URL parameters
4952
-
4953
-
4954
- var params = s(); // Initialize visitor information
4955
-
4956
- var persistedUser = getPersistedUserData(storage);
4957
-
4958
- var visitorInfo = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, persistedUser), initialUser), !params.an_uid ? {} : {
4959
- userId: params.an_uid
4960
- }), !params.an_aid ? {} : {
4961
- anonymousId: params.an_aid
4962
- }); // If no anon id set, create one
4963
-
4964
-
4965
- if (!visitorInfo.anonymousId) {
4966
- visitorInfo.anonymousId = y();
4967
- }
4968
- /**
4969
- * Async Management methods for plugins.
4970
- *
4971
- * This is also where [custom methods](https://bit.ly/329vFXy) are loaded into the instance.
4972
- * @typedef {Object} Plugins
4973
- * @property {EnablePlugin} enable - Set storage value
4974
- * @property {DisablePlugin} disable - Remove storage value
4975
- * @example
4976
- *
4977
- * // Enable a plugin by namespace
4978
- * analytics.plugins.enable('keenio')
4979
- *
4980
- * // Disable a plugin by namespace
4981
- * analytics.plugins.disable('google-analytics')
4982
- */
4983
-
4984
-
4985
- var plugins = _objectSpread2$1({
4986
- /**
4987
- * Enable analytics plugin
4988
- * @typedef {Function} EnablePlugin
4989
- * @param {string|string[]} plugins - name of plugins(s) to disable
4990
- * @param {Function} [callback] - callback after enable runs
4991
- * @returns {Promise}
4992
- * @example
4993
- *
4994
- * analytics.plugins.enable('google-analytics').then(() => {
4995
- * console.log('do stuff')
4996
- * })
4997
- *
4998
- * // Enable multiple plugins at once
4999
- * analytics.plugins.enable(['google-analytics', 'segment']).then(() => {
5000
- * console.log('do stuff')
5001
- * })
5002
- */
5003
- enable: function enable(plugins, callback) {
5004
- return new Promise(function (resolve) {
5005
- store.dispatch({
5006
- type: EVENTS$1.enablePlugin,
5007
- plugins: ensureArray(plugins),
5008
- _: {
5009
- originalAction: EVENTS$1.enablePlugin
5010
- }
5011
- }, resolve, [callback]);
5012
- });
5013
- },
5014
-
5015
- /**
5016
- * Disable analytics plugin
5017
- * @typedef {Function} DisablePlugin
5018
- * @param {string|string[]} plugins - name of integration(s) to disable
5019
- * @param {Function} callback - callback after disable runs
5020
- * @returns {Promise}
5021
- * @example
5022
- *
5023
- * analytics.plugins.disable('google').then(() => {
5024
- * console.log('do stuff')
5025
- * })
5026
- *
5027
- * analytics.plugins.disable(['google', 'segment']).then(() => {
5028
- * console.log('do stuff')
5029
- * })
5030
- */
5031
- disable: function disable(plugins, callback) {
5032
- return new Promise(function (resolve) {
5033
- store.dispatch({
5034
- type: EVENTS$1.disablePlugin,
5035
- plugins: ensureArray(plugins),
5036
- _: {
5037
- originalAction: EVENTS$1.disablePlugin
5038
- }
5039
- }, resolve, [callback]);
5040
- });
5041
- }
5042
- }, parsedOptions.methods);
5043
- /**
5044
- * Analytic instance returned from initialization
5045
- * @typedef {Object} AnalyticsInstance
5046
- * @property {Identify} identify - Identify a user
5047
- * @property {Track} track - Track an analytics event
5048
- * @property {Page} page - Trigger page view
5049
- * @property {User} user - Get user data
5050
- * @property {Reset} reset - Clear information about user & reset analytics
5051
- * @property {Ready} ready - Fire callback on analytics ready event
5052
- * @property {On} on - Fire callback on analytics lifecycle events.
5053
- * @property {Once} once - Fire callback on analytics lifecycle events once.
5054
- * @property {GetState} getState - Get data about user, activity, or context.
5055
- * @property {Storage} storage - storage methods
5056
- * @property {Plugins} plugins - plugin methods
5057
- */
5058
-
5059
-
5060
- var instance = {
5061
- /**
5062
- * Identify a user. This will trigger `identify` calls in any installed plugins and will set user data in localStorage
5063
- * @typedef {Function} Identify
5064
- * @param {String} userId - Unique ID of user
5065
- * @param {Object} [traits] - Object of user traits
5066
- * @param {Object} [options] - Options to pass to identify call
5067
- * @param {Function} [callback] - Callback function after identify completes
5068
- * @returns {Promise}
5069
- * @api public
5070
- *
5071
- * @example
5072
- *
5073
- * // Basic user id identify
5074
- * analytics.identify('xyz-123')
5075
- *
5076
- * // Identify with additional traits
5077
- * analytics.identify('xyz-123', {
5078
- * name: 'steve',
5079
- * company: 'hello-clicky'
5080
- * })
5081
- *
5082
- * // Fire callback with 2nd or 3rd argument
5083
- * analytics.identify('xyz-123', () => {
5084
- * console.log('do this after identify')
5085
- * })
5086
- *
5087
- * // Disable sending user data to specific analytic tools
5088
- * analytics.identify('xyz-123', {}, {
5089
- * plugins: {
5090
- * // disable sending this identify call to segment
5091
- * segment: false
5092
- * }
5093
- * })
5094
- *
5095
- * // Send user data to only to specific analytic tools
5096
- * analytics.identify('xyz-123', {}, {
5097
- * plugins: {
5098
- * // disable this specific identify in all plugins except customerio
5099
- * all: false,
5100
- * customerio: true
5101
- * }
5102
- * })
5103
- */
5104
- identify: function () {
5105
- var _identify = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(userId, traits, options, callback) {
5106
- var id, data, opts, user, resolvedId;
5107
- return regenerator.wrap(function _callee$(_context) {
5108
- while (1) {
5109
- switch (_context.prev = _context.next) {
5110
- case 0:
5111
- id = L$2(userId) ? userId : null;
5112
- data = M$1(userId) ? userId : traits;
5113
- opts = options || {};
5114
- user = instance.user();
5115
- /* sets temporary in memory id. Not to be relied on */
5116
-
5117
- f$1(tempKey(ID), id);
5118
- resolvedId = id || data.userId || getUserProp(ID, instance, data);
5119
- return _context.abrupt("return", new Promise(function (resolve) {
5120
- store.dispatch(_objectSpread2$1({
5121
- type: EVENTS$1.identifyStart,
5122
- userId: resolvedId,
5123
- traits: data || {},
5124
- options: opts,
5125
- anonymousId: user.anonymousId
5126
- }, user.id && user.id !== id && {
5127
- previousId: user.id
5128
- }), resolve, [traits, options, callback]);
5129
- }));
5130
-
5131
- case 7:
5132
- case "end":
5133
- return _context.stop();
5134
- }
5135
- }
5136
- }, _callee);
5137
- }));
5138
-
5139
- function identify(_x, _x2, _x3, _x4) {
5140
- return _identify.apply(this, arguments);
5141
- }
5142
-
5143
- return identify;
5144
- }(),
5145
-
5146
- /**
5147
- * Track an analytics event. This will trigger `track` calls in any installed plugins
5148
- * @typedef {Function} Track
5149
- * @param {String} eventName - Event name
5150
- * @param {Object} [payload] - Event payload
5151
- * @param {Object} [options] - Event options
5152
- * @param {Function} [callback] - Callback to fire after tracking completes
5153
- * @returns {Promise}
5154
- * @api public
5155
- *
5156
- * @example
5157
- *
5158
- * // Basic event tracking
5159
- * analytics.track('buttonClicked')
5160
- *
5161
- * // Event tracking with payload
5162
- * analytics.track('itemPurchased', {
5163
- * price: 11,
5164
- * sku: '1234'
5165
- * })
5166
- *
5167
- * // Fire callback with 2nd or 3rd argument
5168
- * analytics.track('newsletterSubscribed', () => {
5169
- * console.log('do this after track')
5170
- * })
5171
- *
5172
- * // Disable sending this event to specific analytic tools
5173
- * analytics.track('cartAbandoned', {
5174
- * items: ['xyz', 'abc']
5175
- * }, {
5176
- * plugins: {
5177
- * // disable track event for segment
5178
- * segment: false
5179
- * }
5180
- * })
5181
- *
5182
- * // Send event to only to specific analytic tools
5183
- * analytics.track('customerIoOnlyEventExample', {
5184
- * price: 11,
5185
- * sku: '1234'
5186
- * }, {
5187
- * plugins: {
5188
- * // disable this specific track call all plugins except customerio
5189
- * all: false,
5190
- * customerio: true
5191
- * }
5192
- * })
5193
- */
5194
- track: function () {
5195
- var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(eventName, payload, options, callback) {
5196
- var name, data, opts;
5197
- return regenerator.wrap(function _callee2$(_context2) {
5198
- while (1) {
5199
- switch (_context2.prev = _context2.next) {
5200
- case 0:
5201
- name = M$1(eventName) ? eventName.event : eventName;
5202
-
5203
- if (!(!name || !L$2(name))) {
5204
- _context2.next = 3;
5205
- break;
5206
- }
5207
-
5208
- throw new Error('EventMissing');
5209
-
5210
- case 3:
5211
- data = M$1(eventName) ? eventName : payload || {};
5212
- opts = M$1(options) ? options : {};
5213
- return _context2.abrupt("return", new Promise(function (resolve) {
5214
- store.dispatch({
5215
- type: EVENTS$1.trackStart,
5216
- event: name,
5217
- properties: data,
5218
- options: opts,
5219
- userId: getUserProp(ID, instance, payload),
5220
- anonymousId: getUserProp(ANONID, instance, payload)
5221
- }, resolve, [payload, options, callback]);
5222
- }));
5223
-
5224
- case 6:
5225
- case "end":
5226
- return _context2.stop();
5227
- }
5228
- }
5229
- }, _callee2);
5230
- }));
5231
-
5232
- function track(_x5, _x6, _x7, _x8) {
5233
- return _track.apply(this, arguments);
5234
- }
5235
-
5236
- return track;
5237
- }(),
5238
-
5239
- /**
5240
- * Trigger page view. This will trigger `page` calls in any installed plugins
5241
- * @typedef {Function} Page
5242
- * @param {PageData} [data] - Page data overrides.
5243
- * @param {Object} [options] - Page tracking options
5244
- * @param {Function} [callback] - Callback to fire after page view call completes
5245
- * @returns {Promise}
5246
- * @api public
5247
- *
5248
- * @example
5249
- *
5250
- * // Basic page tracking
5251
- * analytics.page()
5252
- *
5253
- * // Page tracking with page data overrides
5254
- * analytics.page({
5255
- * url: 'https://google.com'
5256
- * })
5257
- *
5258
- * // Fire callback with 1st, 2nd or 3rd argument
5259
- * analytics.page(() => {
5260
- * console.log('do this after page')
5261
- * })
5262
- *
5263
- * // Disable sending this pageview to specific analytic tools
5264
- * analytics.page({}, {
5265
- * plugins: {
5266
- * // disable page tracking event for segment
5267
- * segment: false
5268
- * }
5269
- * })
5270
- *
5271
- * // Send pageview to only to specific analytic tools
5272
- * analytics.page({}, {
5273
- * plugins: {
5274
- * // disable this specific page in all plugins except customerio
5275
- * all: false,
5276
- * customerio: true
5277
- * }
5278
- * })
5279
- */
5280
- page: function () {
5281
- var _page = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(data, options, callback) {
5282
- var d, opts;
5283
- return regenerator.wrap(function _callee3$(_context3) {
5284
- while (1) {
5285
- switch (_context3.prev = _context3.next) {
5286
- case 0:
5287
- d = M$1(data) ? data : {};
5288
- opts = M$1(options) ? options : {};
5289
- /*
5290
- // @TODO add custom value reolvers for userId and anonId
5291
- if (resolvers.getUserId) {
5292
- const asyncUserId = await resolvers.getUserId()
5293
- console.log('x', x)
5294
- }
5295
- */
5296
-
5297
- return _context3.abrupt("return", new Promise(function (resolve) {
5298
- store.dispatch({
5299
- type: EVENTS$1.pageStart,
5300
- properties: getPageData(d),
5301
- options: opts,
5302
- userId: getUserProp(ID, instance, d),
5303
- anonymousId: getUserProp(ANONID, instance, d)
5304
- }, resolve, [data, options, callback]);
5305
- }));
5306
-
5307
- case 3:
5308
- case "end":
5309
- return _context3.stop();
5310
- }
5311
- }
5312
- }, _callee3);
5313
- }));
5314
-
5315
- function page(_x9, _x10, _x11) {
5316
- return _page.apply(this, arguments);
5317
- }
5318
-
5319
- return page;
5320
- }(),
5321
-
5322
- /**
5323
- * Get user data
5324
- * @typedef {Function} User
5325
- * @param {string} [key] - dot.prop.path of user data. Example: 'traits.company.name'
5326
- * @returns {string|object} value of user data or null
5327
- *
5328
- * @example
5329
- *
5330
- * // Get all user data
5331
- * const userData = analytics.user()
5332
- *
5333
- * // Get user id
5334
- * const userId = analytics.user('userId')
5335
- *
5336
- * // Get user company name
5337
- * const companyName = analytics.user('traits.company.name')
5338
- */
5339
- user: function user(key) {
5340
- if (key === ID || key === 'id') {
5341
- return getUserProp(ID, instance);
5342
- }
5343
-
5344
- if (key === ANONID || key === 'anonId') {
5345
- return getUserProp(ANONID, instance);
5346
- }
5347
-
5348
- var user = instance.getState('user');
5349
- if (!key) return user;
5350
- return dotProp(user, key);
5351
- },
5352
-
5353
- /**
5354
- * Clear all information about the visitor & reset analytic state.
5355
- * @typedef {Function} Reset
5356
- * @param {Function} [callback] - Handler to run after reset
5357
- * @returns {Promise}
5358
- * @example
5359
- *
5360
- * // Reset current visitor
5361
- * analytics.reset()
5362
- */
5363
- reset: function reset(callback) {
5364
- return new Promise(function (resolve) {
5365
- store.dispatch({
5366
- type: EVENTS$1.resetStart
5367
- }, resolve, callback);
5368
- });
5369
- },
5370
-
5371
- /**
5372
- * Fire callback on analytics ready event
5373
- * @typedef {Function} Ready
5374
- * @param {Function} callback - function to trigger when all providers have loaded
5375
- * @returns {DetachListeners} - Function to detach listener
5376
- *
5377
- * @example
5378
- *
5379
- * analytics.ready((payload) => {
5380
- * console.log('all plugins have loaded or were skipped', payload);
5381
- * })
5382
- */
5383
- ready: function ready(callback) {
5384
- return instance.on(EVENTS$1.ready, callback);
5385
- },
5386
-
5387
- /**
5388
- * Attach an event handler function for analytics lifecycle events.
5389
- * @typedef {Function} On
5390
- * @param {String} name - Name of event to listen to
5391
- * @param {Function} callback - function to fire on event
5392
- * @return {DetachListeners} - Function to detach listener
5393
- *
5394
- * @example
5395
- *
5396
- * // Fire function when 'track' calls happen
5397
- * analytics.on('track', ({ payload }) => {
5398
- * console.log('track call just happened. Do stuff')
5399
- * })
5400
- *
5401
- * // Remove listener before it is called
5402
- * const removeListener = analytics.on('track', ({ payload }) => {
5403
- * console.log('This will never get called')
5404
- * })
5405
- *
5406
- * // cleanup .on listener
5407
- * removeListener()
5408
- */
5409
- on: function on(name, callback) {
5410
- if (!name || !_(callback)) {
5411
- return false;
5412
- }
5413
-
5414
- if (name === EVENTS$1.bootstrap) {
5415
- throw new Error('.on disabled for ' + name);
5416
- }
5417
-
5418
- var startRegex = /Start$|Start:/;
5419
-
5420
- if (name === '*') {
5421
- var beforeHandler = function beforeHandler(store) {
5422
- return function (next) {
5423
- return function (action) {
5424
- if (action.type.match(startRegex)) {
5425
- callback({
5426
- // eslint-disable-line
5427
- payload: action,
5428
- instance: instance,
5429
- plugins: customPlugins
5430
- });
5431
- }
5432
-
5433
- return next(action);
5434
- };
5435
- };
5436
- };
5437
-
5438
- var afterHandler = function afterHandler(store) {
5439
- return function (next) {
5440
- return function (action) {
5441
- if (!action.type.match(startRegex)) {
5442
- callback({
5443
- // eslint-disable-line
5444
- payload: action,
5445
- instance: instance,
5446
- plugins: customPlugins
5447
- });
5448
- }
5449
-
5450
- return next(action);
5451
- };
5452
- };
5453
- };
1259
+ var r="localStorage",g=b$3.bind(null,"localStorage");u$1("localStorage","getItem",a$2);u$1("localStorage","setItem",f);u$1("localStorage","removeItem",i$2);
5454
1260
 
5455
- addMiddleware(beforeHandler, before);
5456
- addMiddleware(afterHandler, after);
5457
- /**
5458
- * Detach listeners
5459
- * @typedef {Function} DetachListeners
5460
- */
5461
-
5462
- return function () {
5463
- removeMiddleware(beforeHandler, before);
5464
- removeMiddleware(afterHandler, after);
5465
- };
5466
- }
5467
-
5468
- var position = name.match(startRegex) ? before : after; // eslint-disable-line
5469
-
5470
- var handler = function handler(store) {
5471
- return function (next) {
5472
- return function (action) {
5473
- // Subscribe to EVERYTHING
5474
- if (action.type === name) {
5475
- callback({
5476
- // eslint-disable-line
5477
- payload: action,
5478
- instance: instance,
5479
- plugins: customPlugins,
5480
- abort: nonAbortable
5481
- });
5482
- }
5483
- /* For future matching of event subpaths `track:*` etc
5484
- } else if (name.match(/\*$/)) {
5485
- const match = (name === '*') ? '.' : name
5486
- const regex = new RegExp(`${match}`, 'g')
5487
- } */
5488
-
5489
-
5490
- return next(action);
5491
- };
5492
- };
5493
- };
5494
-
5495
- addMiddleware(handler, position);
5496
- return function () {
5497
- return removeMiddleware(handler, position);
5498
- };
5499
- },
5500
-
5501
- /**
5502
- * Attach a handler function to an event and only trigger it only once.
5503
- * @typedef {Function} Once
5504
- * @param {String} name - Name of event to listen to
5505
- * @param {Function} callback - function to fire on event
5506
- * @return {DetachListeners} - Function to detach listener
5507
- *
5508
- * @example
5509
- *
5510
- * // Fire function only once 'track'
5511
- * analytics.once('track', ({ payload }) => {
5512
- * console.log('This will only triggered once when analytics.track() fires')
5513
- * })
5514
- *
5515
- * // Remove listener before it is called
5516
- * const listener = analytics.once('track', ({ payload }) => {
5517
- * console.log('This will never get called b/c listener() is called')
5518
- * })
5519
- *
5520
- * // cleanup .once listener before it fires
5521
- * listener()
5522
- */
5523
- once: function once(name, callback) {
5524
- if (!name || !_(callback)) {
5525
- return false;
5526
- }
5527
-
5528
- if (name === EVENTS$1.bootstrap) {
5529
- throw new Error('.once disabled for ' + name);
5530
- }
5531
-
5532
- var detachListener = instance.on(name, function (_ref) {
5533
- var payload = _ref.payload;
5534
- callback({
5535
- // eslint-disable-line
5536
- payload: payload,
5537
- instance: instance,
5538
- plugins: customPlugins,
5539
- abort: nonAbortable
5540
- }); // detach listener after its called once
5541
-
5542
- detachListener();
5543
- });
5544
- return detachListener;
5545
- },
5546
-
5547
- /**
5548
- * Get data about user, activity, or context. Access sub-keys of state with `dot.prop` syntax.
5549
- * @typedef {Function} GetState
5550
- * @param {string} [key] - dot.prop.path value of state
5551
- * @return {any}
5552
- *
5553
- * @example
5554
- *
5555
- * // Get the current state of analytics
5556
- * analytics.getState()
5557
- *
5558
- * // Get a subpath of state
5559
- * analytics.getState('context.offline')
5560
- */
5561
- getState: function getState(key) {
5562
- var state = store.getState();
5563
- if (key) return dotProp(state, key);
5564
- return Object.assign({}, state);
5565
- },
5566
-
5567
- /*
5568
- * Emit events for other plugins or middleware to react to.
5569
- * @param {Object} action - event to dispatch
5570
- */
5571
- dispatch: function dispatch(action) {
5572
- var actionData = L$2(action) ? {
5573
- type: action
5574
- } : action;
5575
-
5576
- if (isReservedAction(actionData.type)) {
5577
- throw new Error('reserved action ' + actionData.type);
5578
- }
5579
-
5580
- var _private = action._ || {}; // Dispatch actionStart
5581
- // const autoPrefixType = `${actionData.type.replace(/Start$/, '')}Start`
5582
-
5583
-
5584
- var dispatchData = _objectSpread2$1(_objectSpread2$1({}, actionData), {}, {
5585
- _: _objectSpread2$1({
5586
- originalAction: actionData.type
5587
- }, _private) // type: `${autoPrefixType}`
5588
-
5589
- });
5590
-
5591
- store.dispatch(dispatchData);
5592
- },
5593
- // Do not use. Will be removed. Here for Backwards compatiblity.
5594
- // Moved to analytics.plugins.enable
5595
- enablePlugin: plugins.enable,
5596
- /// Do not use. Will be removed. Here for Backwards compatiblity.
5597
- /// Moved to analytics.plugins.disable
5598
- disablePlugin: plugins.disable,
5599
- // Do not use. Will be removed. Here for Backwards compatiblity.
5600
- // New plugins api
5601
- plugins: plugins,
5602
-
5603
- /**
5604
- * Storage utilities for persisting data.
5605
- * These methods will allow you to save data in localStorage, cookies, or to the window.
5606
- * @typedef {Object} Storage
5607
- * @property {GetItem} getItem - Get value from storage
5608
- * @property {SetItem} setItem - Set storage value
5609
- * @property {RemoveItem} removeItem - Remove storage value
5610
- *
5611
- * @example
5612
- *
5613
- * // Pull storage off analytics instance
5614
- * const { storage } = analytics
5615
- *
5616
- * // Get value
5617
- * storage.getItem('storage_key')
5618
- *
5619
- * // Set value
5620
- * storage.setItem('storage_key', 'value')
5621
- *
5622
- * // Remove value
5623
- * storage.removeItem('storage_key')
5624
- */
5625
- storage: {
5626
- /**
5627
- * Get value from storage
5628
- * @typedef {Function} GetItem
5629
- * @param {String} key - storage key
5630
- * @param {Object} [options] - storage options
5631
- * @return {Any}
5632
- *
5633
- * @example
5634
- *
5635
- * analytics.storage.getItem('storage_key')
5636
- */
5637
- getItem: storage.getItem,
5638
-
5639
- /**
5640
- * Set storage value
5641
- * @typedef {Function} SetItem
5642
- * @param {String} key - storage key
5643
- * @param {any} value - storage value
5644
- * @param {Object} [options] - storage options
5645
- *
5646
- * @example
5647
- *
5648
- * analytics.storage.setItem('storage_key', 'value')
5649
- */
5650
- setItem: function setItem(key, value, options) {
5651
- store.dispatch({
5652
- type: EVENTS$1.setItemStart,
5653
- key: key,
5654
- value: value,
5655
- options: options
5656
- });
5657
- },
5658
-
5659
- /**
5660
- * Remove storage value
5661
- * @typedef {Function} RemoveItem
5662
- * @param {String} key - storage key
5663
- * @param {Object} [options] - storage options
5664
- *
5665
- * @example
5666
- *
5667
- * analytics.storage.removeItem('storage_key')
5668
- */
5669
- removeItem: function removeItem(key, options) {
5670
- store.dispatch({
5671
- type: EVENTS$1.removeItemStart,
5672
- key: key,
5673
- options: options
5674
- });
5675
- }
5676
- },
5677
-
5678
- /*
5679
- * Set the anonymous ID of the visitor
5680
- * @param {String} anonymousId - anonymous Id to set
5681
- * @param {Object} [options] - storage options
5682
- *
5683
- * @example
5684
- *
5685
- * // Set anonymous ID
5686
- * analytics.setAnonymousId('1234567')
5687
- */
5688
- setAnonymousId: function setAnonymousId(anonymousId, options) {
5689
- /* sets temporary in memory id. Not to be relied on */
5690
- // set(tempKey(ANONID), anonymousId)
5691
- instance.storage.setItem(ANON_ID, anonymousId, options);
5692
- },
5693
-
5694
- /*
5695
- * Events exposed by core analytics library and all loaded plugins
5696
- * @type {Array}
5697
- */
5698
- events: {
5699
- all: allSystemEvents,
5700
- core: coreEvents,
5701
- plugins: allPluginEvents // byType: (type) => {} @Todo grab logic from engine and give inspectable events
5702
-
5703
- }
5704
- };
5705
-
5706
- var enrichMiddleware = function enrichMiddleware(storeAPI) {
5707
- return function (next) {
5708
- return function (action) {
5709
- if (!action.meta) {
5710
- action.meta = generateMeta();
5711
- }
5712
-
5713
- return next(action);
5714
- };
5715
- };
5716
- };
5717
-
5718
- var middlewares = parsedOptions.middlewares.concat([enrichMiddleware,
5719
- /* Core analytics middleware */
5720
- dynamicMiddlewares(before), // Before dynamic middleware <-- fixed pageStart .on listener
5721
-
5722
- /* Plugin engine */
5723
- pluginMiddleware(instance, getPlugins, {
5724
- all: allSystemEvents,
5725
- plugins: allPluginEvents
5726
- }), storageMiddleware(storage), initializeMiddleware(instance), identifyMiddleware(instance),
5727
- /* after dynamic middleware */
5728
- dynamicMiddlewares(after)]);
5729
- /* Initial analytics state keys */
5730
-
5731
- var coreReducers = {
5732
- context: context,
5733
- user: userReducer(storage),
5734
- page: page,
5735
- track: trackReducer,
5736
- plugins: createReducer(getPlugins),
5737
- queue: queueReducer
5738
- };
5739
- var composeEnhancers = compose;
5740
- var composeWithGlobalDebug = compose;
5741
-
5742
- if (z$1 && config.debug) {
5743
- var devTools = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
5744
-
5745
- if (devTools) {
5746
- composeEnhancers = devTools({
5747
- trace: true,
5748
- traceLimit: 25
5749
- });
5750
- }
5751
-
5752
- composeWithGlobalDebug = function composeWithGlobalDebug() {
5753
- if (arguments.length === 0) return Debug();
5754
- if (M$1(_typeof(arguments[0]))) return composeWithDebug();
5755
- return composeWithDebug().apply(null, arguments);
5756
- };
5757
- }
5758
-
5759
- var initialConfig = makeContext(config);
5760
- var intialPluginState = parsedOptions.pluginsArray.reduce(function (acc, plugin) {
5761
- var name = plugin.name,
5762
- config = plugin.config,
5763
- loaded = plugin.loaded;
5764
- var isEnabled = parsedOptions.pluginEnabled[name];
5765
- acc[name] = {
5766
- enabled: isEnabled,
5767
- // If plugin enabled & has no initialize method, set initialized to true, else false
5768
- initialized: isEnabled ? Boolean(!plugin.initialize) : false,
5769
- loaded: Boolean(loaded()),
5770
- config: config || {}
5771
- };
5772
- return acc;
5773
- }, {});
5774
- var initialState = {
5775
- context: initialConfig,
5776
- user: visitorInfo,
5777
- plugins: intialPluginState // Todo allow for more userland defined initial state?
5778
-
5779
- };
5780
- /* Create analytics store! */
5781
-
5782
- var store = createStore( // register reducers
5783
- combineReducers(_objectSpread2$1(_objectSpread2$1({}, coreReducers), customReducers)), // set user defined initial state
5784
- initialState, // register middleware & plugins used
5785
- composeWithGlobalDebug(composeEnhancers(applyMiddleware.apply(void 0, _toConsumableArray(middlewares)))));
5786
- /* Supe up dispatch with callback promise resolver. Happens in enrichMeta */
5787
-
5788
- function enhanceDispatch(fn) {
5789
- return function (event, resolver, callbacks) {
5790
- // console.log('original event', event)
5791
- var meta = generateMeta(event.meta, resolver, ensureArray(callbacks)); // if (resolver) console.log('dispatch resolver', resolver)
5792
- // if (callbacks) console.log('dispatch callbacks', callbacks)
5793
-
5794
- var newEvent = _objectSpread2$1(_objectSpread2$1({}, event), {
5795
- meta: meta
5796
- }); // console.log('newEvent', newEvent)
5797
-
5798
-
5799
- return fn.apply(null, [newEvent]);
5800
- };
5801
- } // Automatically apply meta to dispatch calls
5802
-
5803
-
5804
- store.dispatch = enhanceDispatch(store.dispatch);
5805
- /* Synchronously call bootstrap & register Plugin methods */
5806
-
5807
- var pluginKeys = Object.keys(customPlugins);
5808
- /* Bootstrap analytic plugins */
5809
-
5810
- store.dispatch({
5811
- type: EVENTS$1.bootstrap,
5812
- plugins: pluginKeys,
5813
- config: initialConfig,
5814
- params: params,
5815
- user: visitorInfo,
5816
- initialUser: initialUser,
5817
- persistedUser: persistedUser
5818
- });
5819
- var enabledPlugins = pluginKeys.filter(function (name) {
5820
- return parsedOptions.pluginEnabled[name];
5821
- });
5822
- var disabledPlugins = pluginKeys.filter(function (name) {
5823
- return !parsedOptions.pluginEnabled[name];
5824
- });
5825
- /* Register analytic plugins */
5826
-
5827
- store.dispatch({
5828
- type: EVENTS$1.registerPlugins,
5829
- plugins: pluginKeys,
5830
- enabled: parsedOptions.pluginEnabled
5831
- });
5832
- /* dispatch register for individual plugins */
5833
-
5834
- parsedOptions.pluginsArray.map(function (plugin, i) {
5835
- var bootstrap = plugin.bootstrap,
5836
- config = plugin.config,
5837
- name = plugin.name;
5838
-
5839
- if (bootstrap && _(bootstrap)) {
5840
- bootstrap({
5841
- instance: instance,
5842
- config: config,
5843
- payload: plugin
5844
- });
5845
- }
5846
- /* Register plugins */
5847
-
5848
-
5849
- store.dispatch({
5850
- type: EVENTS$1.registerPluginType(name),
5851
- name: name,
5852
- enabled: parsedOptions.pluginEnabled[name],
5853
- plugin: plugin
5854
- });
5855
- /* All plugins registered initialize, is last loop */
5856
-
5857
- if (parsedOptions.pluginsArray.length === i + 1) {
5858
- store.dispatch({
5859
- type: EVENTS$1.initializeStart,
5860
- plugins: enabledPlugins,
5861
- disabled: disabledPlugins
5862
- });
5863
- }
5864
- });
5865
-
5866
- {
5867
- /* Watch for network events */
5868
- watch(function (offline) {
5869
- store.dispatch({
5870
- type: offline ? EVENTS$1.offline : EVENTS$1.online
5871
- });
5872
- });
5873
- /* Tick heartbeat for queued events */
5874
-
5875
- heartBeat(store, getPlugins, instance);
5876
- }
5877
-
5878
- function appendArguments(fn) {
5879
- return function () {
5880
- /* Get original args */
5881
- var args = Array.prototype.slice.call(arguments);
5882
- /* Create clone of args */
5883
-
5884
- var newArgs = new Array(fn.length);
5885
-
5886
- for (var i = 0; i < args.length; i++) {
5887
- newArgs[i] = args[i];
5888
- }
5889
- /* Append new arg to end */
1261
+ var a="sessionStorage",i=b$3.bind(null,"sessionStorage");u$1("sessionStorage","getItem",a$2);u$1("sessionStorage","setItem",f);u$1("sessionStorage","removeItem",i$2);
5890
1262
 
1263
+ var b$1="any",m="*",F$1="undefined"!=typeof process?process:{};F$1.env&&F$1.env.NODE_ENV||"";var $="undefined"!=typeof document;null!=F$1.versions&&null!=F$1.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M(n,t){return t.charAt(0)[n]()+t.slice(1)}var U=M.bind(null,"toUpperCase"),H=M.bind(null,"toLowerCase");function J$1(n){return Y(n)?U("null"):"object"==typeof n?yn(n):Object.prototype.toString.call(n).slice(8,-1)}function R(n,t){void 0===t&&(t=!0);var e=J$1(n);return t?H(e):e}function V(n,t){return typeof t===n}var W=V.bind(null,"function"),q=V.bind(null,"string"),I$1=V.bind(null,"undefined");V.bind(null,"boolean");V.bind(null,"symbol");function Y(n){return null===n}function nn(n){return "number"===R(n)&&!isNaN(n)}function on(n){if(!un(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un(n){return n&&("object"==typeof n||null!==n)}function yn(n){return W(n.constructor)?n.constructor.name:null}function hn(n){return n instanceof Error||q(n.message)&&n.constructor&&nn(n.constructor.stackTraceLimit)}function On(n,t){if("object"!=typeof t||Y(t))return !1;if(t instanceof n)return !0;var e=R(new n(""));if(hn(t))for(;t;){if(R(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}On.bind(null,TypeError);On.bind(null,SyntaxError);function $n(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn(n,t):e}function Tn(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n($n,"form");_n($n,"button");_n($n,"input");_n($n,"select");
5891
1264
 
5892
- newArgs[newArgs.length] = instance; // Set instance on extended methods
5893
-
5894
- return fn.apply({
5895
- instance: instance
5896
- }, newArgs);
5897
- };
5898
- }
5899
- /* Return analytics instance */
5900
-
5901
-
5902
- return instance;
5903
- } // Duplicated strings
5904
-
5905
-
5906
- var before = 'before';
5907
- var after = 'after';
5908
-
5909
- var t="cookie",i$1=a$1(),r$1=d$1,c=d$1;function u(o){return i$1?d$1(o,"",-1):i$2(o)}function a$1(){if(void 0!==i$1)return i$1;var e="cookiecookie";try{d$1(e,e),i$1=-1!==document.cookie.indexOf(e),u(e);}catch(e){i$1=!1;}return i$1}function d$1(e,t,r,c,u,a){if("undefined"!=typeof window){var d=arguments.length>1;return !1===i$1&&(d?f$1(e,t):a$2(e)),d?document.cookie=e+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(c?"; path="+c:"")+(u?"; domain="+u:"")+(a?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}
5910
-
5911
- var r="localStorage",g=b$1.bind(null,"localStorage");u$1("localStorage","getItem",a$2);u$1("localStorage","setItem",f$1);u$1("localStorage","removeItem",i$2);
5912
-
5913
- var a="sessionStorage",i=b$1.bind(null,"sessionStorage");u$1("sessionStorage","getItem",a$2);u$1("sessionStorage","setItem",f$1);u$1("sessionStorage","removeItem",i$2);
5914
-
5915
- var n,f="any",l="*",h$1="undefined"!=typeof process?process:{};(null==(n=h$1.env)?void 0:n.NODE_ENV)||"";var z="undefined"!=typeof window;null!=h$1.versions&&null!=h$1.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;z&&"nodejs"===window.name||"undefined"!=typeof navigator&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function C$1(n,e){return typeof e===n}C$1.bind(null,"function");var L$1=C$1.bind(null,"string"),$=C$1.bind(null,"undefined");C$1.bind(null,"boolean");function H(n){return n&&("object"==typeof n||null!==n)}function M(n){if(!H(n))return !1;for(var e=n;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e}
5916
-
5917
- function I(t){var o=t;try{if("true"===(o=JSON.parse(t)))return !0;if("false"===o)return !1;if(M(o))return o;parseFloat(o)===o&&(o=parseFloat(o));}catch(t){}if(null!==o&&""!==o)return o}var k=g(),x=i(),C=a$1();function L(o,e){if(o){var r=A(e),a=!E(r),i=d(r)?I(localStorage.getItem(o)):void 0;if(a&&!$(i))return i;var s=h(r)?I(r$1(o)):void 0;if(a&&s)return s;var l=N(r)?I(sessionStorage.getItem(o)):void 0;if(a&&l)return l;var u=a$2(o);return a?u:{localStorage:i,sessionStorage:l,cookie:s,global:u}}}function O(r$2,a$1,l){if(r$2&&!$(a$1)){var u={},g=A(l),m=JSON.stringify(a$1),S=!E(g);return d(g)&&(u[r]=G(r,a$1,I(localStorage.getItem(r$2))),localStorage.setItem(r$2,m),S)?u[r]:h(g)&&(u[t]=G(t,a$1,I(r$1(r$2))),c(r$2,m),S)?u[t]:N(g)&&(u[a]=G(a,a$1,I(sessionStorage.getItem(r$2))),sessionStorage.setItem(r$2,m),S)?u[a]:(u[l$1]=G(l$1,a$1,a$2(r$2)),f$1(r$2,a$1),S?u[l$1]:u)}}function b(t$1,e){if(t$1){var a$1=A(e),n=L(t$1,l),s={};return !$(n.localStorage)&&d(a$1)&&(localStorage.removeItem(t$1),s[r]=n.localStorage),!$(n.cookie)&&h(a$1)&&(u(t$1),s[t]=n.cookie),!$(n.sessionStorage)&&N(a$1)&&(sessionStorage.removeItem(t$1),s[a]=n.sessionStorage),!$(n.global)&&F(a$1,l$1)&&(i$2(t$1),s[l$1]=n.global),s}}function A(t){return t?L$1(t)?t:t.storage:f}function d(t){return k&&F(t,r)}function h(t$1){return C&&F(t$1,t)}function N(t){return x&&F(t,a)}function E(t){return t===l||"all"===t}function F(t,o){return t===f||t===o||E(t)}function G(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:O,getItem:L,removeItem:b};var storage = J;
1265
+ function I(t){var o=t;try{if("true"===(o=JSON.parse(t)))return !0;if("false"===o)return !1;if(on(o))return o;parseFloat(o)===o&&(o=parseFloat(o));}catch(t){}if(null!==o&&""!==o)return o}var k=g(),O=i(),x=a$1();function C(o,e){if(o){var r=A(e),a=!N(r),i=d(r)?I(localStorage.getItem(o)):void 0;if(a&&!I$1(i))return i;var n=h(r)?I(r$1(o)):void 0;if(a&&n)return n;var l=E(r)?I(sessionStorage.getItem(o)):void 0;if(a&&l)return l;var u=a$2(o);return a?u:{localStorage:i,sessionStorage:l,cookie:n,global:u}}}function L(r$2,a$1,l$1){if(r$2&&!I$1(a$1)){var u={},g=A(l$1),m=JSON.stringify(a$1),S=!N(g);return d(g)&&(u[r]=F(r,a$1,I(localStorage.getItem(r$2))),localStorage.setItem(r$2,m),S)?u[r]:h(g)&&(u[t]=F(t,a$1,I(r$1(r$2))),c(r$2,m),S)?u[t]:E(g)&&(u[a]=F(a,a$1,I(sessionStorage.getItem(r$2))),sessionStorage.setItem(r$2,m),S)?u[a]:(u[l]=F(l,a$1,a$2(r$2)),f(r$2,a$1),S?u[l]:u)}}function b(t$1,e){if(t$1){var a$1=A(e),s=C(t$1,m),n={};return !I$1(s.localStorage)&&d(a$1)&&(localStorage.removeItem(t$1),n[r]=s.localStorage),!I$1(s.cookie)&&h(a$1)&&(u(t$1),n[t]=s.cookie),!I$1(s.sessionStorage)&&E(a$1)&&(sessionStorage.removeItem(t$1),n[a]=s.sessionStorage),!I$1(s.global)&&G(a$1,l)&&(i$2(t$1),n[l]=s.global),n}}function A(t){return t?q(t)?t:t.storage:b$1}function d(t){return k&&G(t,r)}function h(t$1){return x&&G(t$1,t)}function E(t){return O&&G(t,a)}function N(t){return t===m||"all"===t}function G(t,o){return t===b$1||t===o||N(t)}function F(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:L,getItem:C,removeItem:b};
5918
1266
 
5919
1267
  function _defineProperty(obj, key, value) {
5920
1268
  if (key in obj) {
@@ -5960,37 +1308,42 @@
5960
1308
  function analyticsLib() {
5961
1309
  var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5962
1310
  var defaultSettings = {
5963
- storage: storage
1311
+ storage: J
5964
1312
  };
5965
- return analytics(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
1313
+ return Ve(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
1314
+ }
1315
+
1316
+ /******************************************************************************
1317
+ Copyright (c) Microsoft Corporation.
1318
+
1319
+ Permission to use, copy, modify, and/or distribute this software for any
1320
+ purpose with or without fee is hereby granted.
1321
+
1322
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1323
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1324
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1325
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1326
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1327
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1328
+ PERFORMANCE OF THIS SOFTWARE.
1329
+ ***************************************************************************** */
1330
+
1331
+ function __rest(s, e) {
1332
+ var t = {};
1333
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1334
+ t[p] = s[p];
1335
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
1336
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1337
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1338
+ t[p[i]] = s[p[i]];
1339
+ }
1340
+ return t;
5966
1341
  }
5967
1342
 
5968
- /******************************************************************************
5969
- Copyright (c) Microsoft Corporation.
5970
-
5971
- Permission to use, copy, modify, and/or distribute this software for any
5972
- purpose with or without fee is hereby granted.
5973
-
5974
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5975
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5976
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5977
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5978
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5979
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5980
- PERFORMANCE OF THIS SOFTWARE.
5981
- ***************************************************************************** */
5982
-
5983
- function __rest(s, e) {
5984
- var t = {};
5985
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5986
- t[p] = s[p];
5987
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
5988
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5989
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
5990
- t[p[i]] = s[p[i]];
5991
- }
5992
- return t;
5993
- }
1343
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1344
+ var e = new Error(message);
1345
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1346
+ };
5994
1347
 
5995
1348
  /*! *****************************************************************************
5996
1349
  Copyright (c) Microsoft Corporation.
@@ -6780,6 +2133,10 @@
6780
2133
  return { access };
6781
2134
  }
6782
2135
 
2136
+ /**
2137
+ * Amazon Telemetry
2138
+ * Supports Amazon Pinpoint
2139
+ */
6783
2140
  class Amazon {
6784
2141
  constructor(options) {
6785
2142
  this.name = 'amazon';