@jitsu/js 0.0.0-alpha.108

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.
@@ -0,0 +1,1475 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ function n$2(t,e,l,n,r){for(e=e.split?e.split("."):e,n=0;n<e.length;n++)t=t?t[e[n]]:r;return t===r?l:t}
5
+
6
+ var e="undefined",o$1="object",g$2="any",m$1="*",j$1="__",F$2="undefined"!=typeof process?process:{};F$2.env&&F$2.env.NODE_ENV||"";var $$1="undefined"!=typeof window;null!=F$2.versions&&null!=F$2.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$1(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$1=M$1.bind(null,"toUpperCase"),H$1=M$1.bind(null,"toLowerCase");function J$2(n){return Y$1(n)?U$1("null"):"object"==typeof n?yn(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$1(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"),I$2=V$1.bind(null,"undefined");var Q$1=V$1.bind(null,"boolean");V$1.bind(null,"symbol");function Y$1(n){return null===n}function nn(n){return "number"===R$1(n)&&!isNaN(n)}function rn(n){return "array"===R$1(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$1(n.constructor)?n.constructor.name:null}function hn(n){return n instanceof Error||q$1(n.message)&&n.constructor&&nn(n.constructor.stackTraceLimit)}function On(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(t))for(;t;){if(R$1(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");
7
+
8
+ function n$1(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}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(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 $$1&&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$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}
9
+
10
+ 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$2(t)){var o=window[t];l=o[e].bind(o);}}catch(t){}return l||r}n[o]||(n[o]={});var c$1={};function b$2(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}
11
+
12
+ function g$1(){return g$1=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e},g$1.apply(this,arguments)}var h$1="function",v="undefined",y="@@redux/"+Math.random().toString(36),b$1=/* #__PURE__ */function(){return typeof Symbol===h$1&&Symbol.observable||"@@observable"}(),I$1=" != "+h$1;function w(e,t,n){var r;if(typeof t===h$1&&typeof n===v&&(n=t,t=void 0),typeof n!==v){if(typeof n!==h$1)throw new Error("enhancer"+I$1);return n(w)(e,t)}if(typeof e!==h$1)throw new Error("reducer"+I$1);var i=e,a=t,o=[],u=o,s=!1;function l(){u===o&&(u=o.slice());}function f(){return a}function d(e){if(typeof e!==h$1)throw new Error("Listener"+I$1);var t=!0;return l(),u.push(e),function(){if(t){t=!1,l();var n=u.indexOf(e);u.splice(n,1);}}}function p(e){if(!on(e))throw new Error("Act != obj");if(typeof e.type===v)throw new Error("ActType "+v);if(s)throw new Error("Dispatch in reducer");try{s=!0,a=i(a,e);}finally{s=!1;}for(var t=o=u,n=0;n<t.length;n++)(0, t[n])();return e}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:d,getState:f,replaceReducer:function(e){if(typeof e!==h$1)throw new Error("next reducer"+I$1);i=e,p({type:"@@redux/INIT"});}})[b$1]=function(){var e,t=d;return (e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function n(){e.next&&e.next(f());}return n(),{unsubscribe:t(n)}}})[b$1]=function(){return this},e},r}function E$1(e,t){var n=t&&t.type;return "action "+(n&&n.toString()||"?")+"reducer "+e+" returns "+v}function P(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,t){return function(){return e(t.apply(void 0,[].slice.call(arguments)))}})}function S(){var e=arguments;return function(t){return function(n,r,i){var a,o=t(n,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)}),g$1({},o,{dispatch:u=P.apply(void 0,a)(o.dispatch)})}}}var N$1=j$1+"anon_id",A$1=j$1+"user_id",_=j$1+"user_traits",k$1="userId",j="anonymousId",x$1=["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"],T=["name","EVENTS","config","loaded"],z=x$1.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return "registerPlugin:"+e},pluginReadyType:function(e){return "ready:"+e}}),M=/^utm_/,q=/^an_prop_/,V=/^an_trait_/;function C$1(e){var t=e.storage.setItem;return function(n){return function(r){return function(i){if(i.type===z.bootstrap){var a=i.params,o=i.user,u=i.persistedUser,c=i.initialUser,s=u.userId===o.userId;u.anonymousId!==o.anonymousId&&t(N$1,o.anonymousId),s||t(A$1,o.userId),c.traits&&t(_,g$1({},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,t){if(t.match(M)||t.match(/^(d|g)clid/)){var n=t.replace(M,"");e.campaign["campaign"===n?"name":n]=a[t];}return t.match(q)&&(e.props[t.replace(q,"")]=a[t]),t.match(V)&&(e.traits[t.replace(V,"")]=a[t]),e},{campaign:{},props:{},traits:{}});n.dispatch(g$1({type:z.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&&n.dispatch({type:z.campaign,campaign:p.campaign});}}return r(i)}}}}function U(e){return function(t,n){if(void 0===t&&(t={}),void 0===n&&(n={}),n.type===z.setItemEnd){if(n.key===N$1)return g$1({},t,{anonymousId:n.value});if(n.key===A$1)return g$1({},t,{userId:n.value})}switch(n.type){case z.identify:return Object.assign({},t,{userId:n.userId,traits:g$1({},t.traits,n.traits)});case z.reset:return [A$1,N$1,_].forEach(function(t){e.removeItem(t);}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function R(e){return {userId:e.getItem(A$1),anonymousId:e.getItem(N$1),traits:e.getItem(_)}}var $=function(e){return j$1+"TEMP"+j$1+e};function D(t){var n=t.storage,r=n.setItem,a=n.removeItem,o=n.getItem;return function(t){return function(n){return function(u){var c=u.userId,s=u.traits,l=u.options;if(u.type===z.reset&&([A$1,_,N$1].forEach(function(e){a(e);}),[k$1,j,"traits"].forEach(function(e){i$2($(e));})),u.type===z.identify){o(N$1)||r(N$1,y$1());var f=o(A$1),d=o(_)||{};f&&f!==c&&t.dispatch({type:z.userIdChanged,old:{userId:f,traits:d},new:{userId:c,traits:s},options:l}),c&&r(A$1,c),s&&r(_,g$1({},d,s));}return n(u)}}}}var B={};function L$1(e,t){B[e]&&W$1(B[e])&&(B[e](t),delete B[e]);}function J$1(e,t,n){return new Promise(function(r,i){return t()?r(e):n<1?i(g$1({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(a){return J$1(e,t,n-10).then(r,i)})})}var X=function(e){var t=e.data,n=e.action,r=e.instance,i=e.state,a=e.allPlugins,o=e.allMatches,u=e.store,s=e.EVENTS;try{var f=i.plugins,d=i.context,p=n.type,m=p.match(H),h=t.exact.map(function(e){return e.pluginName});m&&(h=o.during.map(function(e){return e.pluginName}));var v=function(e,t){return function(n,r,i){var a=r.config,o=r.name,u=o+"."+n.type;i&&(u=i.event);var c=n.type.match(H)?function(e,t,n,r,i){return function(a,o){var u=r?r.name:e,c=o&&te(o)?o:n;if(r&&(!(c=o&&te(o)?o:[e]).includes(e)||1!==c.length))throw new Error("Method "+t+" can only abort "+e+" plugin. "+JSON.stringify(c)+" input valid");return g$1({},i,{abort:{reason:a,plugins:c,caller:t,_:u}})}}(o,u,t,i,n):function(e,t){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+t)}}(n,u);return {payload:ie(n),instance:e,config:a||{},abort:c}}}(r,h),y=t.exact.reduce(function(e,t){var n=t.pluginName,r=t.methodName,i=!1;return r.match(/^initialize/)||r.match(/^reset/)||(i=!f[n].loaded),d.offline&&r.match(/^(page|track|identify)/)&&(i=!0),e[""+n]=i,e},{});return Promise.resolve(t.exact.reduce(function(e,i,o){var u=i.pluginName;return Promise.resolve(e).then(function(e){function i(){return Promise.resolve(e)}var o=function(){if(t.namespaced&&t.namespaced[u])return Promise.resolve(t.namespaced[u].reduce(function(e,t,n){return Promise.resolve(e).then(function(e){return t.method&&W$1(t.method)?(function(e,t){var n=re(e);if(n&&n.name===t){var r=re(n.method);throw new Error([t+" plugin is calling method "+e,"Plugins cant call self","Use "+n.method+" "+(r?"or "+r.method:"")+" in "+t+" plugin insteadof "+e].join("\n"))}}(t.methodName,t.pluginName),Promise.resolve(t.method({payload:e,instance:r,abort:(n=e,i=u,o=t.pluginName,function(e,t){return g$1({},n,{abort:{reason:e,plugins:t||[i],caller:p,from:o||i}})}),config:K(t.pluginName,f,a),plugins:f})).then(function(t){var n=on(t)?t:{};return Promise.resolve(g$1({},e,n))})):e;var n,i,o;})},Promise.resolve(n))).then(function(t){e[u]=t;});e[u]=n;}();return o&&o.then?o.then(i):i()})},Promise.resolve({}))).then(function(e){return Promise.resolve(t.exact.reduce(function(n,i,o){try{var s=t.exact.length===o+1,l=i.pluginName,d=a[l];return Promise.resolve(n).then(function(t){var n=e[l]?e[l]:{};if(m&&(n=t),Z(n,l))return G$1({data:n,method:p,instance:r,pluginName:l,store:u}),Promise.resolve(t);if(Z(t,l))return s&&G$1({data:t,method:p,instance:r,store:u}),Promise.resolve(t);if(y.hasOwnProperty(l)&&!0===y[l])return u.dispatch({type:"queue",plugin:l,payload:n,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(t);var i=v(e[l],a[l]);return Promise.resolve(d[p]({abort:i.abort,payload:n,instance:r,config:K(l,f,a),plugins:f})).then(function(i){var a=on(i)?i:{},o=g$1({},t,a),s=e[l];if(Z(s,l))G$1({data:s,method:p,instance:r,pluginName:l,store:u});else {var f=p+":"+l;(f.match(/:/g)||[]).length<2&&!p.match(W)&&!p.match(F$1)&&r.dispatch(g$1({},m?o:n,{type:f,_:{called:f,from:"submethod"}}));}return Promise.resolve(o)})})}catch(e){return Promise.reject(e)}},Promise.resolve(n))).then(function(e){if(!(p.match(H)||p.match(/^registerPlugin/)||p.match(F$1)||p.match(W)||p.match(/^params/)||p.match(/^userIdChanged/))){if(s.plugins.includes(p),e._&&e._.originalAction===p)return e;var n=g$1({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});ee(e,t.exact.length)&&!p.match(/End$/)&&(n=g$1({},n,{type:e.type+"Aborted"})),u.dispatch(n);}return e})})}catch(e){return Promise.reject(e)}},H=/Start$/,W=/^bootstrap/,F$1=/^ready/;function G$1(e){var t=e.pluginName,n=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(g$1({},e.data,{type:n,_:{called:n,from:"abort"}}));}function K(e,t,n){var r=t[e]||n[e];return r&&r.config?r.config:{}}function Q(e,t){return t.reduce(function(t,n){return n[e]?t.concat({methodName:e,pluginName:n.name,method:n[e]}):t},[])}function Y(e,t){var n=e.replace(H,""),r=t?":"+t:"";return [""+e+r,""+n+r,n+"End"+r]}function Z(e,t){var n=e.abort;return !!n&&(!0===n||ne(n,t)||n&&ne(n.plugins,t))}function ee(e,t){var n=e.abort;if(!n)return !1;if(!0===n||q$1(n))return !0;var r=n.plugins;return te(n)&&n.length===t||te(r)&&r.length===t}function te(e){return Array.isArray(e)}function ne(e,t){return !(!e||!te(e))&&e.includes(t)}function re(e){var t=e.match(/(.*):(.*)/);return !!t&&{method:t[1],name:t[2]}}function ie(e){return Object.keys(e).reduce(function(t,n){return "type"===n||(t[n]=on(e[n])?Object.assign({},e[n]):e[n]),t},{})}function ae(e,t,n){var r={};return function(i){return function(a){return function(o){try{var u,c=function(e){return u?e:a(p)},s=o.type,d=o.plugins,p=o;if(o.abort)return Promise.resolve(a(o));if(s===z.enablePlugin&&i.dispatch({type:z.initializeStart,plugins:d,disabled:[],fromEnable:!0,meta:o.meta}),s===z.disablePlugin&&setTimeout(function(){return L$1(o.meta.rid,{payload:o})},0),s===z.initializeEnd){var m=t(),h=Object.keys(m),v=h.filter(function(e){return d.includes(e)}).map(function(e){return m[e]}),y=[],b=[],I=o.disabled,w=v.map(function(e){var t=e.name;return J$1(e,e.loaded,1e4).then(function(n){return r[t]||(i.dispatch({type:z.pluginReadyType(t),name:t,events:Object.keys(e).filter(function(e){return !T.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 t={plugins:y,failed:b,disabled:I};setTimeout(function(){h.length===w.length+I.length&&i.dispatch(g$1({},{type:z.ready},t));},0);});}var E=function(){if(s!==z.bootstrap)return /^ready:([^:]*)$/.test(s)&&setTimeout(function(){return function(e,t,n){var r=t(),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,t,n){return a[t.plugin].loaded?(e.process.push(t),e.processIndex.push(n)):(e.requeue.push(t),e.requeueIndex.push(n)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(c.processIndex&&c.processIndex.length){c.processIndex.forEach(function(t){var i=o.actions[t],c=i.plugin,s=i.payload.type,f=r[c][s];if(f&&W$1(f)){var d=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),[k$1,j].reduce(function(n,r){return e.hasOwnProperty(r)&&t[r]&&t[r]!==e[r]&&(n[r]=t[r]),n},e)}(i.payload,u);f({payload:d,config:a[c].config,instance:n});var p=s+":"+c;e.dispatch(g$1({},d,{type:p,_:{called:p,from:"queueDrain"}}));}});var s=o.actions.filter(function(e,t){return !~c.processIndex.indexOf(t)});o.actions=s;}}}(i,t,e)},0),Promise.resolve(function(e,t,n,r,i){try{var a=W$1(t)?t():t,o=e.type,u=o.replace(H,"");if(e._&&e._.called)return Promise.resolve(e);var c=n.getState(),s=(m=a,void 0===(h=c.plugins)&&(h={}),void 0===(v=e.options)&&(v={}),Object.keys(m).filter(function(e){var t=v.plugins||{};return Q$1(t[e])?t[e]:!1!==t.all&&(!h[e]||!1!==h[e].enabled)}).map(function(e){return m[e]}));o===z.initializeStart&&e.fromEnable&&(s=Object.keys(c.plugins).filter(function(t){var n=c.plugins[t];return e.plugins.includes(t)&&!n.initialized}).map(function(e){return a[e]}));var d=s.map(function(e){return e.name}),p=function(e,t,n){var r=Y(e).map(function(e){return Q(e,t)});return t.reduce(function(n,r){var i=r.name,a=Y(e,i).map(function(e){return Q(e,t)}),o=a[0],u=a[1],c=a[2];return o.length&&(n.beforeNS[i]=o),u.length&&(n.duringNS[i]=u),c.length&&(n.afterNS[i]=c),n},{before:r[0],beforeNS:{},during:r[1],duringNS:{},after:r[2],afterNS:{}})}(o,s);return Promise.resolve(X({action:e,data:{exact:p.before,namespaced:p.beforeNS},state:c,allPlugins:a,allMatches:p,instance:n,store:r,EVENTS:i})).then(function(e){function t(){var t=function(){if(o.match(H))return Promise.resolve(X({action:g$1({},s,{type:u+"End"}),data:{exact:p.after,namespaced:p.afterNS},state:c,allPlugins:a,allMatches:p,instance:n,store:r,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&L$1(e.meta.rid,{payload:e});})}();return t&&t.then?t.then(function(){return e}):e}if(ee(e,d.length))return e;var s,l=function(){if(o!==u)return Promise.resolve(X({action:g$1({},e,{type:u}),data:{exact:p.during,namespaced:p.duringNS},state:c,allPlugins:a,allMatches:p,instance:n,store:r,EVENTS:i})).then(function(e){s=e;});s=e;}();return l&&l.then?l.then(t):t()})}catch(e){return Promise.reject(e)}var m,h,v;}(o,t,e,i,n)).then(function(e){var t=a(e);return u=1,t})}();return Promise.resolve(E&&E.then?E.then(c):c(E))}catch(e){return Promise.reject(e)}}}}}function oe(e){return function(t){return function(t){return function(n){var r=n.type,i=n.key,a=n.value,o=n.options;if(r===z.setItem||r===z.removeItem){if(n.abort)return t(n);r===z.setItem?e.setItem(i,a,o):e.removeItem(i,o);}return t(n)}}}}var ue=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,n){e[n]=e[n].concat(t);},this.removeMiddleware=function(t,n){var r=e[n].findIndex(function(e){return e===t});-1!==r&&(e[n]=[].concat(e[n].slice(0,r),e[n].slice(r+1)));},this.dynamicMiddlewares=function(t){return function(n){return function(r){return function(i){var a={getState:n.getState,dispatch:function(e){return n.dispatch(e)}},o=e[t].map(function(e){return e(a)});return P.apply(void 0,o)(r)(i)}}}};};function ce(e){return function(t,n){void 0===t&&(t={});var r={};if("initialize:aborted"===n.type)return t;if(/^registerPlugin:([^:]*)$/.test(n.type)){var i=se(n.type,"registerPlugin"),a=e()[i];if(!a||!i)return t;var o=n.enabled;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded()),config:a.config||{}},g$1({},t,r)}if(/^initialize:([^:]*)$/.test(n.type)){var u=se(n.type,z.initialize),c=e()[u];return c&&u?(r[u]=g$1({},t[u],{initialized:!0,loaded:Boolean(c.loaded())}),g$1({},t,r)):t}if(/^ready:([^:]*)$/.test(n.type))return r[n.name]=g$1({},t[n.name],{loaded:!0}),g$1({},t,r);switch(n.type){case z.disablePlugin:return g$1({},t,le(n.plugins,!1,t));case z.enablePlugin:return g$1({},t,le(n.plugins,!0,t));default:return t}}}function se(e,t){return e.substring(t.length+1,e.length)}function le(e,t,n){return e.reduce(function(e,r){return e[r]=g$1({},n[r],{enabled:t}),e},n)}function fe(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var de={last:{},history:[]};function pe(e,t){void 0===e&&(e=de);var n=t.options,r=t.meta;if(t.type===z.track){var i=fe(g$1({event:t.event,properties:t.properties},Object.keys(n).length&&{options:n},{meta:r}));return g$1({},e,{last:i,history:e.history.concat(i)})}return e}var me={actions:[]};function ge(e,t){void 0===e&&(e=me);var n=t.payload;switch(t.type){case"queue":var r;return r=n&&n.type&&n.type===z.identify?[t].concat(e.actions):e.actions.concat(t),g$1({},e,{actions:r});case"dequeue":return [];default:return e}}var he=/#.*$/;function ve(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(t&&t[3]?t[3].split("?")[0].replace(he,""):"")}var ye,be=function(e){if(void 0===e&&(e={}),!$$1)return e;var t=document,n=t.title,r=t.referrer,i=window,a=i.location,o=i.innerWidth,u=i.innerHeight,c=a.hash,s=a.search,l=function(e){var t=function(){if($$1)for(var e,t=document.getElementsByTagName("link"),n=0;e=t[n];n++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return t?t.match(/\?/)?t:t+e:window.location.href.replace(he,"")}(s),f={title:n,url:l,path:ve(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),g$1({},f,e)},Ie={last:{},history:[]};function we(e,t){void 0===e&&(e=Ie);var n=t.options;if(t.type===z.page){var r=fe(g$1({properties:t.properties,meta:t.meta},Object.keys(n).length&&{options:n}));return g$1({},e,{last:r,history:e.history.concat(r)})}return e}ye={};var Ee={initialized:!1,sessionId:y$1(),app:null,version:null,debug:!1,offline:!!$$1&&!navigator.onLine,os:{name:"na"},userAgent:$$1?navigator.userAgent:"node",library:{name:"analytics",version:"0.11.0"},timezone:void 0,locale:void 0,campaign:{},referrer:ye};function Pe(e,t){void 0===e&&(e=Ee);var n=e.initialized,r=t.campaign;switch(t.type){case z.campaign:return g$1({},e,{campaign:r});case z.offline:return g$1({},e,{offline:!0});case z.online:return g$1({},e,{offline:!1});default:return n?e:g$1({},Ee,e,{initialized:!0})}}var Se=["plugins","reducers","storage"];function Ne(){return f("analytics",[]),function(e){return function(t,n$1,r){var i=e(t,n$1,r),a=i.dispatch;return Object.assign(i,{dispatch:function(e){return n[o].analytics.push(e.action||e),a(e)}})}}}function Ae(e){return function(){return P(P.apply(null,arguments),Ne())}}function _e(e){return e?rn(e)?e:[e]:[]}function Oe(t,n,r){void 0===t&&(t={});var i,a,o=y$1();return n&&(B[o]=(i=n,a=function(e){for(var t,n=e||Array.prototype.slice.call(arguments),r=0;r<n.length;r++)if(W$1(n[r])){t=n[r];break}return t}(r),function(e){a&&a(e),i(e);})),g$1({},t,{rid:o,ts:(new Date).getTime()},n?{hasCallback:!0}:{})}function ke(o){void 0===o&&(o={});var u=o.reducers||{},s$1=o.initialUser||{},f$1=(o.plugins||[]).reduce(function(e,t){if(W$1(t))return e.middlewares=e.middlewares.concat(t),e;if(t.NAMESPACE&&(t.name=t.NAMESPACE),!t.name)throw new Error("https://lytics.dev/errors/1");var n=t.EVENTS?Object.keys(t.EVENTS).map(function(e){return t.EVENTS[e]}):[];e.pluginEnabled[t.name]=!(!1===t.enabled||t.config&&!1===t.config.enabled),delete t.enabled,t.methods&&(e.methods[t.name]=Object.keys(t.methods).reduce(function(e,n){var r;return e[n]=(r=t.methods[n],function(){for(var e=Array.prototype.slice.call(arguments),t=new Array(r.length),n=0;n<e.length;n++)t[n]=e[n];return t[t.length]=G,r.apply({instance:G},t)}),e},{}),delete t.methods);var r=Object.keys(t).concat(n),i=new Set(e.events.concat(r));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(t),e.plugins[t.name])throw new Error(t.name+"AlreadyLoaded");return e.plugins[t.name]=t,e.plugins[t.name].loaded||(e.plugins[t.name].loaded=function(){return !0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),m=o.storage?o.storage:{getItem:a$2,setItem:f,removeItem:i$2},b=function(e){return function(t,n,i){return n.getState("user")[t]||(i&&on(i)&&i[t]?i[t]:R(e)[t]||a$2($(t))||null)}}(m),I=f$1.plugins,A=f$1.events.filter(function(e){return !T.includes(e)}).sort(),_=new Set(A.concat(x$1).filter(function(e){return !T.includes(e)})),O=Array.from(_).sort(),M=function(){return I},q=new ue,V=q.addMiddleware,B=q.removeMiddleware,L=q.dynamicMiddlewares,J=function(){throw new Error("Abort disabled inListener")},X=s(),H=R(m),W=g$1({},H,s$1,X.an_uid?{userId:X.an_uid}:{},X.an_aid?{anonymousId:X.an_aid}:{});W.anonymousId||(W.anonymousId=y$1());var F=g$1({enable:function(e,t){return new Promise(function(n){se.dispatch({type:z.enablePlugin,plugins:_e(e),_:{originalAction:z.enablePlugin}},n,[t]);})},disable:function(e,t){return new Promise(function(n){se.dispatch({type:z.disablePlugin,plugins:_e(e),_:{originalAction:z.disablePlugin}},n,[t]);})}},f$1.methods),G={identify:function(e,t,n,r){try{var i=q$1(e)?e:null,o=on(e)?e:t,u=n||{},s=G.user();f($(k$1),i);var l=i||o.userId||b(k$1,G,o);return Promise.resolve(new Promise(function(e){se.dispatch(g$1({type:z.identifyStart,userId:l,traits:o||{},options:u,anonymousId:s.anonymousId},s.id&&s.id!==i&&{previousId:s.id}),e,[t,n,r]);}))}catch(e){return Promise.reject(e)}},track:function(e,t,n,r){try{var i=on(e)?e.event:e;if(!i||!q$1(i))throw new Error("EventMissing");var a=on(e)?e:t||{},o=on(n)?n:{};return Promise.resolve(new Promise(function(e){se.dispatch({type:z.trackStart,event:i,properties:a,options:o,userId:b(k$1,G,t),anonymousId:b(j,G,t)},e,[t,n,r]);}))}catch(e){return Promise.reject(e)}},page:function(e,t,n){try{var r=on(e)?e:{},i=on(t)?t:{};return Promise.resolve(new Promise(function(a){se.dispatch({type:z.pageStart,properties:be(r),options:i,userId:b(k$1,G,r),anonymousId:b(j,G,r)},a,[e,t,n]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===k$1||"id"===e)return b(k$1,G);if(e===j||"anonId"===e)return b(j,G);var t=G.getState("user");return e?n$2(t,e):t},reset:function(e){return new Promise(function(t){se.dispatch({type:z.resetStart},t,e);})},ready:function(e){return G.on(z.ready,e)},on:function(e,t){if(!e||!W$1(t))return !1;if(e===z.bootstrap)throw new Error(".on disabled for "+e);var n=/Start$|Start:/;if("*"===e){var r=function(e){return function(e){return function(r){return r.type.match(n)&&t({payload:r,instance:G,plugins:I}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(n)||t({payload:r,instance:G,plugins:I}),e(r)}}};return V(r,je),V(i,xe),function(){B(r,je),B(i,xe);}}var a=e.match(n)?je:xe,o=function(n){return function(n){return function(r){return r.type===e&&t({payload:r,instance:G,plugins:I,abort:J}),n(r)}}};return V(o,a),function(){return B(o,a)}},once:function(e,t){if(!e||!W$1(t))return !1;if(e===z.bootstrap)throw new Error(".once disabled for "+e);var n=G.on(e,function(e){t({payload:e.payload,instance:G,plugins:I,abort:J}),n();});return n},getState:function(e){var t=se.getState();return e?n$2(t,e):Object.assign({},t)},dispatch:function(e){var t=q$1(e)?{type:e}:e;if(x$1.includes(t.type))throw new Error("reserved action "+t.type);var n=g$1({},t,{_:g$1({originalAction:t.type},e._||{})});se.dispatch(n);},enablePlugin:F.enable,disablePlugin:F.disable,plugins:F,storage:{getItem:m.getItem,setItem:function(e,t,n){se.dispatch({type:z.setItemStart,key:e,value:t,options:n});},removeItem:function(e,t){se.dispatch({type:z.removeItemStart,key:e,options:t});}},setAnonymousId:function(e,t){G.storage.setItem(N$1,e,t);},events:{core:x$1,plugins:A}},K=f$1.middlewares.concat([function(e){return function(e){return function(t){return t.meta||(t.meta=Oe()),e(t)}}},L(je),ae(G,M,{all:O,plugins:A}),oe(m),C$1(G),D(G),L(xe)]),Q={context:Pe,user:U(m),page:we,track:pe,plugins:ce(M),queue:ge},Y=P,Z=P;if($$1&&o.debug){var ee=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;ee&&(Y=ee({trace:!0,traceLimit:25})),Z=function(){return 0===arguments.length?Ne():on(typeof arguments[0])?Ae():Ae().apply(null,arguments)};}var te,ne=function(e){return Object.keys(e).reduce(function(t,n){return Se.includes(n)||(t[n]=e[n]),t},{})}(o),re=f$1.pluginsArray.reduce(function(e,t){var n=t.name,r=t.config,i=t.loaded,a=f$1.pluginEnabled[n];return e[n]={enabled:a,initialized:!!a&&Boolean(!t.initialize),loaded:Boolean(i()),config:r||{}},e},{}),ie={context:ne,user:W,plugins:re},se=w(function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var i=t[r];typeof e[i]===h$1&&(n[i]=e[i]);}var a,o=Object.keys(n);try{!function(e){Object.keys(e).forEach(function(t){var n=e[t];if(typeof n(void 0,{type:"@@redux/INIT"})===v||typeof n(void 0,{type:y})===v)throw new Error("reducer "+t+" "+v)});}(n);}catch(e){a=e;}return function(e,t){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, n[c])(s,t);if(typeof l===v){var f=E$1(c,t);throw new Error(f)}i[c]=l,r=r||l!==s;}return r?i:e}}(g$1({},Q,u)),ie,Z(Y(S.apply(void 0,K))));se.dispatch=(te=se.dispatch,function(e,t,n){var r=g$1({},e,{meta:Oe(e.meta,t,_e(n))});return te.apply(null,[r])});var le=Object.keys(I);se.dispatch({type:z.bootstrap,plugins:le,config:ne,params:X,user:W,initialUser:s$1,persistedUser:H});var fe=le.filter(function(e){return f$1.pluginEnabled[e]}),de=le.filter(function(e){return !f$1.pluginEnabled[e]});return se.dispatch({type:z.registerPlugins,plugins:le,enabled:f$1.pluginEnabled}),f$1.pluginsArray.map(function(e,t){var n=e.bootstrap,r=e.config,i=e.name;n&&W$1(n)&&n({instance:G,config:r,payload:e}),se.dispatch({type:z.registerPluginType(i),name:i,enabled:f$1.pluginEnabled[i],plugin:e}),f$1.pluginsArray.length===t+1&&se.dispatch({type:z.initializeStart,plugins:fe,disabled:de});}),G}var je="before",xe="after";
13
+
14
+ 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])}}
15
+
16
+ var r="localStorage",g=b$2.bind(null,"localStorage");u$1("localStorage","getItem",a$2);u$1("localStorage","setItem",f);u$1("localStorage","removeItem",i$2);
17
+
18
+ var a="sessionStorage",i=b$2.bind(null,"sessionStorage");u$1("sessionStorage","getItem",a$2);u$1("sessionStorage","setItem",f);u$1("sessionStorage","removeItem",i$2);
19
+
20
+ 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$2(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$2(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$1),n={};return !I$2(s.localStorage)&&d(a$1)&&(localStorage.removeItem(t$1),n[r]=s.localStorage),!I$2(s.cookie)&&h(a$1)&&(u(t$1),n[t]=s.cookie),!I$2(s.sessionStorage)&&E(a$1)&&(sessionStorage.removeItem(t$1),n[a]=s.sessionStorage),!I$2(s.global)&&G(a$1,l)&&(i$2(t$1),n[l]=s.global),n}}function A(t){return t?q$1(t)?t:t.storage:g$2}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$1||"all"===t}function G(t,o){return t===g$2||t===o||N(t)}function F(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:L,getItem:C,removeItem:b};
21
+
22
+ function _defineProperty(obj, key, value) {
23
+ if (key in obj) {
24
+ Object.defineProperty(obj, key, {
25
+ value: value,
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true
29
+ });
30
+ } else {
31
+ obj[key] = value;
32
+ }
33
+
34
+ return obj;
35
+ }
36
+
37
+ function ownKeys(object, enumerableOnly) {
38
+ var keys = Object.keys(object);
39
+
40
+ if (Object.getOwnPropertySymbols) {
41
+ var symbols = Object.getOwnPropertySymbols(object);
42
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
43
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
44
+ })), keys.push.apply(keys, symbols);
45
+ }
46
+
47
+ return keys;
48
+ }
49
+
50
+ function _objectSpread2(target) {
51
+ for (var i = 1; i < arguments.length; i++) {
52
+ var source = null != arguments[i] ? arguments[i] : {};
53
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
54
+ _defineProperty(target, key, source[key]);
55
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
56
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
57
+ });
58
+ }
59
+
60
+ return target;
61
+ }
62
+
63
+ function analyticsLib() {
64
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
+ var defaultSettings = {
66
+ storage: J
67
+ };
68
+ return ke(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
69
+ }
70
+
71
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
72
+
73
+ var alea$1 = {exports: {}};
74
+
75
+ (function (module) {
76
+ // A port of an algorithm by Johannes Baagøe <baagoe@baagoe.com>, 2010
77
+ // http://baagoe.com/en/RandomMusings/javascript/
78
+ // https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
79
+ // Original work is under MIT license -
80
+
81
+ // Copyright (C) 2010 by Johannes Baagøe <baagoe@baagoe.org>
82
+ //
83
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
84
+ // of this software and associated documentation files (the "Software"), to deal
85
+ // in the Software without restriction, including without limitation the rights
86
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
87
+ // copies of the Software, and to permit persons to whom the Software is
88
+ // furnished to do so, subject to the following conditions:
89
+ //
90
+ // The above copyright notice and this permission notice shall be included in
91
+ // all copies or substantial portions of the Software.
92
+ //
93
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
95
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
96
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
97
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
98
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
99
+ // THE SOFTWARE.
100
+
101
+
102
+
103
+ (function(global, module, define) {
104
+
105
+ function Alea(seed) {
106
+ var me = this, mash = Mash();
107
+
108
+ me.next = function() {
109
+ var t = 2091639 * me.s0 + me.c * 2.3283064365386963e-10; // 2^-32
110
+ me.s0 = me.s1;
111
+ me.s1 = me.s2;
112
+ return me.s2 = t - (me.c = t | 0);
113
+ };
114
+
115
+ // Apply the seeding algorithm from Baagoe.
116
+ me.c = 1;
117
+ me.s0 = mash(' ');
118
+ me.s1 = mash(' ');
119
+ me.s2 = mash(' ');
120
+ me.s0 -= mash(seed);
121
+ if (me.s0 < 0) { me.s0 += 1; }
122
+ me.s1 -= mash(seed);
123
+ if (me.s1 < 0) { me.s1 += 1; }
124
+ me.s2 -= mash(seed);
125
+ if (me.s2 < 0) { me.s2 += 1; }
126
+ mash = null;
127
+ }
128
+
129
+ function copy(f, t) {
130
+ t.c = f.c;
131
+ t.s0 = f.s0;
132
+ t.s1 = f.s1;
133
+ t.s2 = f.s2;
134
+ return t;
135
+ }
136
+
137
+ function impl(seed, opts) {
138
+ var xg = new Alea(seed),
139
+ state = opts && opts.state,
140
+ prng = xg.next;
141
+ prng.int32 = function() { return (xg.next() * 0x100000000) | 0; };
142
+ prng.double = function() {
143
+ return prng() + (prng() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53
144
+ };
145
+ prng.quick = prng;
146
+ if (state) {
147
+ if (typeof(state) == 'object') copy(state, xg);
148
+ prng.state = function() { return copy(xg, {}); };
149
+ }
150
+ return prng;
151
+ }
152
+
153
+ function Mash() {
154
+ var n = 0xefc8249d;
155
+
156
+ var mash = function(data) {
157
+ data = String(data);
158
+ for (var i = 0; i < data.length; i++) {
159
+ n += data.charCodeAt(i);
160
+ var h = 0.02519603282416938 * n;
161
+ n = h >>> 0;
162
+ h -= n;
163
+ h *= n;
164
+ n = h >>> 0;
165
+ h -= n;
166
+ n += h * 0x100000000; // 2^32
167
+ }
168
+ return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
169
+ };
170
+
171
+ return mash;
172
+ }
173
+
174
+
175
+ if (module && module.exports) {
176
+ module.exports = impl;
177
+ } else if (define && define.amd) {
178
+ define(function() { return impl; });
179
+ } else {
180
+ this.alea = impl;
181
+ }
182
+
183
+ })(
184
+ commonjsGlobal,
185
+ module, // present in node.js
186
+ (typeof undefined) == 'function' // present with an AMD loader
187
+ );
188
+ } (alea$1));
189
+
190
+ var xor128$1 = {exports: {}};
191
+
192
+ (function (module) {
193
+ // A Javascript implementaion of the "xor128" prng algorithm by
194
+ // George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
195
+
196
+ (function(global, module, define) {
197
+
198
+ function XorGen(seed) {
199
+ var me = this, strseed = '';
200
+
201
+ me.x = 0;
202
+ me.y = 0;
203
+ me.z = 0;
204
+ me.w = 0;
205
+
206
+ // Set up generator function.
207
+ me.next = function() {
208
+ var t = me.x ^ (me.x << 11);
209
+ me.x = me.y;
210
+ me.y = me.z;
211
+ me.z = me.w;
212
+ return me.w ^= (me.w >>> 19) ^ t ^ (t >>> 8);
213
+ };
214
+
215
+ if (seed === (seed | 0)) {
216
+ // Integer seed.
217
+ me.x = seed;
218
+ } else {
219
+ // String seed.
220
+ strseed += seed;
221
+ }
222
+
223
+ // Mix in string seed, then discard an initial batch of 64 values.
224
+ for (var k = 0; k < strseed.length + 64; k++) {
225
+ me.x ^= strseed.charCodeAt(k) | 0;
226
+ me.next();
227
+ }
228
+ }
229
+
230
+ function copy(f, t) {
231
+ t.x = f.x;
232
+ t.y = f.y;
233
+ t.z = f.z;
234
+ t.w = f.w;
235
+ return t;
236
+ }
237
+
238
+ function impl(seed, opts) {
239
+ var xg = new XorGen(seed),
240
+ state = opts && opts.state,
241
+ prng = function() { return (xg.next() >>> 0) / 0x100000000; };
242
+ prng.double = function() {
243
+ do {
244
+ var top = xg.next() >>> 11,
245
+ bot = (xg.next() >>> 0) / 0x100000000,
246
+ result = (top + bot) / (1 << 21);
247
+ } while (result === 0);
248
+ return result;
249
+ };
250
+ prng.int32 = xg.next;
251
+ prng.quick = prng;
252
+ if (state) {
253
+ if (typeof(state) == 'object') copy(state, xg);
254
+ prng.state = function() { return copy(xg, {}); };
255
+ }
256
+ return prng;
257
+ }
258
+
259
+ if (module && module.exports) {
260
+ module.exports = impl;
261
+ } else if (define && define.amd) {
262
+ define(function() { return impl; });
263
+ } else {
264
+ this.xor128 = impl;
265
+ }
266
+
267
+ })(
268
+ commonjsGlobal,
269
+ module, // present in node.js
270
+ (typeof undefined) == 'function' // present with an AMD loader
271
+ );
272
+ } (xor128$1));
273
+
274
+ var xorwow$1 = {exports: {}};
275
+
276
+ (function (module) {
277
+ // A Javascript implementaion of the "xorwow" prng algorithm by
278
+ // George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
279
+
280
+ (function(global, module, define) {
281
+
282
+ function XorGen(seed) {
283
+ var me = this, strseed = '';
284
+
285
+ // Set up generator function.
286
+ me.next = function() {
287
+ var t = (me.x ^ (me.x >>> 2));
288
+ me.x = me.y; me.y = me.z; me.z = me.w; me.w = me.v;
289
+ return (me.d = (me.d + 362437 | 0)) +
290
+ (me.v = (me.v ^ (me.v << 4)) ^ (t ^ (t << 1))) | 0;
291
+ };
292
+
293
+ me.x = 0;
294
+ me.y = 0;
295
+ me.z = 0;
296
+ me.w = 0;
297
+ me.v = 0;
298
+
299
+ if (seed === (seed | 0)) {
300
+ // Integer seed.
301
+ me.x = seed;
302
+ } else {
303
+ // String seed.
304
+ strseed += seed;
305
+ }
306
+
307
+ // Mix in string seed, then discard an initial batch of 64 values.
308
+ for (var k = 0; k < strseed.length + 64; k++) {
309
+ me.x ^= strseed.charCodeAt(k) | 0;
310
+ if (k == strseed.length) {
311
+ me.d = me.x << 10 ^ me.x >>> 4;
312
+ }
313
+ me.next();
314
+ }
315
+ }
316
+
317
+ function copy(f, t) {
318
+ t.x = f.x;
319
+ t.y = f.y;
320
+ t.z = f.z;
321
+ t.w = f.w;
322
+ t.v = f.v;
323
+ t.d = f.d;
324
+ return t;
325
+ }
326
+
327
+ function impl(seed, opts) {
328
+ var xg = new XorGen(seed),
329
+ state = opts && opts.state,
330
+ prng = function() { return (xg.next() >>> 0) / 0x100000000; };
331
+ prng.double = function() {
332
+ do {
333
+ var top = xg.next() >>> 11,
334
+ bot = (xg.next() >>> 0) / 0x100000000,
335
+ result = (top + bot) / (1 << 21);
336
+ } while (result === 0);
337
+ return result;
338
+ };
339
+ prng.int32 = xg.next;
340
+ prng.quick = prng;
341
+ if (state) {
342
+ if (typeof(state) == 'object') copy(state, xg);
343
+ prng.state = function() { return copy(xg, {}); };
344
+ }
345
+ return prng;
346
+ }
347
+
348
+ if (module && module.exports) {
349
+ module.exports = impl;
350
+ } else if (define && define.amd) {
351
+ define(function() { return impl; });
352
+ } else {
353
+ this.xorwow = impl;
354
+ }
355
+
356
+ })(
357
+ commonjsGlobal,
358
+ module, // present in node.js
359
+ (typeof undefined) == 'function' // present with an AMD loader
360
+ );
361
+ } (xorwow$1));
362
+
363
+ var xorshift7$1 = {exports: {}};
364
+
365
+ (function (module) {
366
+ // A Javascript implementaion of the "xorshift7" algorithm by
367
+ // François Panneton and Pierre L'ecuyer:
368
+ // "On the Xorgshift Random Number Generators"
369
+ // http://saluc.engr.uconn.edu/refs/crypto/rng/panneton05onthexorshift.pdf
370
+
371
+ (function(global, module, define) {
372
+
373
+ function XorGen(seed) {
374
+ var me = this;
375
+
376
+ // Set up generator function.
377
+ me.next = function() {
378
+ // Update xor generator.
379
+ var X = me.x, i = me.i, t, v;
380
+ t = X[i]; t ^= (t >>> 7); v = t ^ (t << 24);
381
+ t = X[(i + 1) & 7]; v ^= t ^ (t >>> 10);
382
+ t = X[(i + 3) & 7]; v ^= t ^ (t >>> 3);
383
+ t = X[(i + 4) & 7]; v ^= t ^ (t << 7);
384
+ t = X[(i + 7) & 7]; t = t ^ (t << 13); v ^= t ^ (t << 9);
385
+ X[i] = v;
386
+ me.i = (i + 1) & 7;
387
+ return v;
388
+ };
389
+
390
+ function init(me, seed) {
391
+ var j, X = [];
392
+
393
+ if (seed === (seed | 0)) {
394
+ // Seed state array using a 32-bit integer.
395
+ X[0] = seed;
396
+ } else {
397
+ // Seed state using a string.
398
+ seed = '' + seed;
399
+ for (j = 0; j < seed.length; ++j) {
400
+ X[j & 7] = (X[j & 7] << 15) ^
401
+ (seed.charCodeAt(j) + X[(j + 1) & 7] << 13);
402
+ }
403
+ }
404
+ // Enforce an array length of 8, not all zeroes.
405
+ while (X.length < 8) X.push(0);
406
+ for (j = 0; j < 8 && X[j] === 0; ++j);
407
+ if (j == 8) X[7] = -1; else X[j];
408
+
409
+ me.x = X;
410
+ me.i = 0;
411
+
412
+ // Discard an initial 256 values.
413
+ for (j = 256; j > 0; --j) {
414
+ me.next();
415
+ }
416
+ }
417
+
418
+ init(me, seed);
419
+ }
420
+
421
+ function copy(f, t) {
422
+ t.x = f.x.slice();
423
+ t.i = f.i;
424
+ return t;
425
+ }
426
+
427
+ function impl(seed, opts) {
428
+ if (seed == null) seed = +(new Date);
429
+ var xg = new XorGen(seed),
430
+ state = opts && opts.state,
431
+ prng = function() { return (xg.next() >>> 0) / 0x100000000; };
432
+ prng.double = function() {
433
+ do {
434
+ var top = xg.next() >>> 11,
435
+ bot = (xg.next() >>> 0) / 0x100000000,
436
+ result = (top + bot) / (1 << 21);
437
+ } while (result === 0);
438
+ return result;
439
+ };
440
+ prng.int32 = xg.next;
441
+ prng.quick = prng;
442
+ if (state) {
443
+ if (state.x) copy(state, xg);
444
+ prng.state = function() { return copy(xg, {}); };
445
+ }
446
+ return prng;
447
+ }
448
+
449
+ if (module && module.exports) {
450
+ module.exports = impl;
451
+ } else if (define && define.amd) {
452
+ define(function() { return impl; });
453
+ } else {
454
+ this.xorshift7 = impl;
455
+ }
456
+
457
+ })(
458
+ commonjsGlobal,
459
+ module, // present in node.js
460
+ (typeof undefined) == 'function' // present with an AMD loader
461
+ );
462
+ } (xorshift7$1));
463
+
464
+ var xor4096$1 = {exports: {}};
465
+
466
+ (function (module) {
467
+ // A Javascript implementaion of Richard Brent's Xorgens xor4096 algorithm.
468
+ //
469
+ // This fast non-cryptographic random number generator is designed for
470
+ // use in Monte-Carlo algorithms. It combines a long-period xorshift
471
+ // generator with a Weyl generator, and it passes all common batteries
472
+ // of stasticial tests for randomness while consuming only a few nanoseconds
473
+ // for each prng generated. For background on the generator, see Brent's
474
+ // paper: "Some long-period random number generators using shifts and xors."
475
+ // http://arxiv.org/pdf/1004.3115v1.pdf
476
+ //
477
+ // Usage:
478
+ //
479
+ // var xor4096 = require('xor4096');
480
+ // random = xor4096(1); // Seed with int32 or string.
481
+ // assert.equal(random(), 0.1520436450538547); // (0, 1) range, 53 bits.
482
+ // assert.equal(random.int32(), 1806534897); // signed int32, 32 bits.
483
+ //
484
+ // For nonzero numeric keys, this impelementation provides a sequence
485
+ // identical to that by Brent's xorgens 3 implementaion in C. This
486
+ // implementation also provides for initalizing the generator with
487
+ // string seeds, or for saving and restoring the state of the generator.
488
+ //
489
+ // On Chrome, this prng benchmarks about 2.1 times slower than
490
+ // Javascript's built-in Math.random().
491
+
492
+ (function(global, module, define) {
493
+
494
+ function XorGen(seed) {
495
+ var me = this;
496
+
497
+ // Set up generator function.
498
+ me.next = function() {
499
+ var w = me.w,
500
+ X = me.X, i = me.i, t, v;
501
+ // Update Weyl generator.
502
+ me.w = w = (w + 0x61c88647) | 0;
503
+ // Update xor generator.
504
+ v = X[(i + 34) & 127];
505
+ t = X[i = ((i + 1) & 127)];
506
+ v ^= v << 13;
507
+ t ^= t << 17;
508
+ v ^= v >>> 15;
509
+ t ^= t >>> 12;
510
+ // Update Xor generator array state.
511
+ v = X[i] = v ^ t;
512
+ me.i = i;
513
+ // Result is the combination.
514
+ return (v + (w ^ (w >>> 16))) | 0;
515
+ };
516
+
517
+ function init(me, seed) {
518
+ var t, v, i, j, w, X = [], limit = 128;
519
+ if (seed === (seed | 0)) {
520
+ // Numeric seeds initialize v, which is used to generates X.
521
+ v = seed;
522
+ seed = null;
523
+ } else {
524
+ // String seeds are mixed into v and X one character at a time.
525
+ seed = seed + '\0';
526
+ v = 0;
527
+ limit = Math.max(limit, seed.length);
528
+ }
529
+ // Initialize circular array and weyl value.
530
+ for (i = 0, j = -32; j < limit; ++j) {
531
+ // Put the unicode characters into the array, and shuffle them.
532
+ if (seed) v ^= seed.charCodeAt((j + 32) % seed.length);
533
+ // After 32 shuffles, take v as the starting w value.
534
+ if (j === 0) w = v;
535
+ v ^= v << 10;
536
+ v ^= v >>> 15;
537
+ v ^= v << 4;
538
+ v ^= v >>> 13;
539
+ if (j >= 0) {
540
+ w = (w + 0x61c88647) | 0; // Weyl.
541
+ t = (X[j & 127] ^= (v + w)); // Combine xor and weyl to init array.
542
+ i = (0 == t) ? i + 1 : 0; // Count zeroes.
543
+ }
544
+ }
545
+ // We have detected all zeroes; make the key nonzero.
546
+ if (i >= 128) {
547
+ X[(seed && seed.length || 0) & 127] = -1;
548
+ }
549
+ // Run the generator 512 times to further mix the state before using it.
550
+ // Factoring this as a function slows the main generator, so it is just
551
+ // unrolled here. The weyl generator is not advanced while warming up.
552
+ i = 127;
553
+ for (j = 4 * 128; j > 0; --j) {
554
+ v = X[(i + 34) & 127];
555
+ t = X[i = ((i + 1) & 127)];
556
+ v ^= v << 13;
557
+ t ^= t << 17;
558
+ v ^= v >>> 15;
559
+ t ^= t >>> 12;
560
+ X[i] = v ^ t;
561
+ }
562
+ // Storing state as object members is faster than using closure variables.
563
+ me.w = w;
564
+ me.X = X;
565
+ me.i = i;
566
+ }
567
+
568
+ init(me, seed);
569
+ }
570
+
571
+ function copy(f, t) {
572
+ t.i = f.i;
573
+ t.w = f.w;
574
+ t.X = f.X.slice();
575
+ return t;
576
+ }
577
+ function impl(seed, opts) {
578
+ if (seed == null) seed = +(new Date);
579
+ var xg = new XorGen(seed),
580
+ state = opts && opts.state,
581
+ prng = function() { return (xg.next() >>> 0) / 0x100000000; };
582
+ prng.double = function() {
583
+ do {
584
+ var top = xg.next() >>> 11,
585
+ bot = (xg.next() >>> 0) / 0x100000000,
586
+ result = (top + bot) / (1 << 21);
587
+ } while (result === 0);
588
+ return result;
589
+ };
590
+ prng.int32 = xg.next;
591
+ prng.quick = prng;
592
+ if (state) {
593
+ if (state.X) copy(state, xg);
594
+ prng.state = function() { return copy(xg, {}); };
595
+ }
596
+ return prng;
597
+ }
598
+
599
+ if (module && module.exports) {
600
+ module.exports = impl;
601
+ } else if (define && define.amd) {
602
+ define(function() { return impl; });
603
+ } else {
604
+ this.xor4096 = impl;
605
+ }
606
+
607
+ })(
608
+ commonjsGlobal, // window object or global
609
+ module, // present in node.js
610
+ (typeof undefined) == 'function' // present with an AMD loader
611
+ );
612
+ } (xor4096$1));
613
+
614
+ var tychei$1 = {exports: {}};
615
+
616
+ (function (module) {
617
+ // A Javascript implementaion of the "Tyche-i" prng algorithm by
618
+ // Samuel Neves and Filipe Araujo.
619
+ // See https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
620
+
621
+ (function(global, module, define) {
622
+
623
+ function XorGen(seed) {
624
+ var me = this, strseed = '';
625
+
626
+ // Set up generator function.
627
+ me.next = function() {
628
+ var b = me.b, c = me.c, d = me.d, a = me.a;
629
+ b = (b << 25) ^ (b >>> 7) ^ c;
630
+ c = (c - d) | 0;
631
+ d = (d << 24) ^ (d >>> 8) ^ a;
632
+ a = (a - b) | 0;
633
+ me.b = b = (b << 20) ^ (b >>> 12) ^ c;
634
+ me.c = c = (c - d) | 0;
635
+ me.d = (d << 16) ^ (c >>> 16) ^ a;
636
+ return me.a = (a - b) | 0;
637
+ };
638
+
639
+ /* The following is non-inverted tyche, which has better internal
640
+ * bit diffusion, but which is about 25% slower than tyche-i in JS.
641
+ me.next = function() {
642
+ var a = me.a, b = me.b, c = me.c, d = me.d;
643
+ a = (me.a + me.b | 0) >>> 0;
644
+ d = me.d ^ a; d = d << 16 ^ d >>> 16;
645
+ c = me.c + d | 0;
646
+ b = me.b ^ c; b = b << 12 ^ d >>> 20;
647
+ me.a = a = a + b | 0;
648
+ d = d ^ a; me.d = d = d << 8 ^ d >>> 24;
649
+ me.c = c = c + d | 0;
650
+ b = b ^ c;
651
+ return me.b = (b << 7 ^ b >>> 25);
652
+ }
653
+ */
654
+
655
+ me.a = 0;
656
+ me.b = 0;
657
+ me.c = 2654435769 | 0;
658
+ me.d = 1367130551;
659
+
660
+ if (seed === Math.floor(seed)) {
661
+ // Integer seed.
662
+ me.a = (seed / 0x100000000) | 0;
663
+ me.b = seed | 0;
664
+ } else {
665
+ // String seed.
666
+ strseed += seed;
667
+ }
668
+
669
+ // Mix in string seed, then discard an initial batch of 64 values.
670
+ for (var k = 0; k < strseed.length + 20; k++) {
671
+ me.b ^= strseed.charCodeAt(k) | 0;
672
+ me.next();
673
+ }
674
+ }
675
+
676
+ function copy(f, t) {
677
+ t.a = f.a;
678
+ t.b = f.b;
679
+ t.c = f.c;
680
+ t.d = f.d;
681
+ return t;
682
+ }
683
+ function impl(seed, opts) {
684
+ var xg = new XorGen(seed),
685
+ state = opts && opts.state,
686
+ prng = function() { return (xg.next() >>> 0) / 0x100000000; };
687
+ prng.double = function() {
688
+ do {
689
+ var top = xg.next() >>> 11,
690
+ bot = (xg.next() >>> 0) / 0x100000000,
691
+ result = (top + bot) / (1 << 21);
692
+ } while (result === 0);
693
+ return result;
694
+ };
695
+ prng.int32 = xg.next;
696
+ prng.quick = prng;
697
+ if (state) {
698
+ if (typeof(state) == 'object') copy(state, xg);
699
+ prng.state = function() { return copy(xg, {}); };
700
+ }
701
+ return prng;
702
+ }
703
+
704
+ if (module && module.exports) {
705
+ module.exports = impl;
706
+ } else if (define && define.amd) {
707
+ define(function() { return impl; });
708
+ } else {
709
+ this.tychei = impl;
710
+ }
711
+
712
+ })(
713
+ commonjsGlobal,
714
+ module, // present in node.js
715
+ (typeof undefined) == 'function' // present with an AMD loader
716
+ );
717
+ } (tychei$1));
718
+
719
+ var seedrandom$1 = {exports: {}};
720
+
721
+ /*
722
+ Copyright 2019 David Bau.
723
+
724
+ Permission is hereby granted, free of charge, to any person obtaining
725
+ a copy of this software and associated documentation files (the
726
+ "Software"), to deal in the Software without restriction, including
727
+ without limitation the rights to use, copy, modify, merge, publish,
728
+ distribute, sublicense, and/or sell copies of the Software, and to
729
+ permit persons to whom the Software is furnished to do so, subject to
730
+ the following conditions:
731
+
732
+ The above copyright notice and this permission notice shall be
733
+ included in all copies or substantial portions of the Software.
734
+
735
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
736
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
737
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
738
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
739
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
740
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
741
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
742
+
743
+ */
744
+
745
+ (function (module) {
746
+ (function (global, pool, math) {
747
+ //
748
+ // The following constants are related to IEEE 754 limits.
749
+ //
750
+
751
+ var width = 256, // each RC4 output is 0 <= x < 256
752
+ chunks = 6, // at least six RC4 outputs for each double
753
+ digits = 52, // there are 52 significant digits in a double
754
+ rngname = 'random', // rngname: name for Math.random and Math.seedrandom
755
+ startdenom = math.pow(width, chunks),
756
+ significance = math.pow(2, digits),
757
+ overflow = significance * 2,
758
+ mask = width - 1,
759
+ nodecrypto; // node.js crypto module, initialized at the bottom.
760
+
761
+ //
762
+ // seedrandom()
763
+ // This is the seedrandom function described above.
764
+ //
765
+ function seedrandom(seed, options, callback) {
766
+ var key = [];
767
+ options = (options == true) ? { entropy: true } : (options || {});
768
+
769
+ // Flatten the seed string or build one from local entropy if needed.
770
+ var shortseed = mixkey(flatten(
771
+ options.entropy ? [seed, tostring(pool)] :
772
+ (seed == null) ? autoseed() : seed, 3), key);
773
+
774
+ // Use the seed to initialize an ARC4 generator.
775
+ var arc4 = new ARC4(key);
776
+
777
+ // This function returns a random double in [0, 1) that contains
778
+ // randomness in every bit of the mantissa of the IEEE 754 value.
779
+ var prng = function() {
780
+ var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
781
+ d = startdenom, // and denominator d = 2 ^ 48.
782
+ x = 0; // and no 'extra last byte'.
783
+ while (n < significance) { // Fill up all significant digits by
784
+ n = (n + x) * width; // shifting numerator and
785
+ d *= width; // denominator and generating a
786
+ x = arc4.g(1); // new least-significant-byte.
787
+ }
788
+ while (n >= overflow) { // To avoid rounding up, before adding
789
+ n /= 2; // last byte, shift everything
790
+ d /= 2; // right using integer math until
791
+ x >>>= 1; // we have exactly the desired bits.
792
+ }
793
+ return (n + x) / d; // Form the number within [0, 1).
794
+ };
795
+
796
+ prng.int32 = function() { return arc4.g(4) | 0; };
797
+ prng.quick = function() { return arc4.g(4) / 0x100000000; };
798
+ prng.double = prng;
799
+
800
+ // Mix the randomness into accumulated entropy.
801
+ mixkey(tostring(arc4.S), pool);
802
+
803
+ // Calling convention: what to return as a function of prng, seed, is_math.
804
+ return (options.pass || callback ||
805
+ function(prng, seed, is_math_call, state) {
806
+ if (state) {
807
+ // Load the arc4 state from the given state if it has an S array.
808
+ if (state.S) { copy(state, arc4); }
809
+ // Only provide the .state method if requested via options.state.
810
+ prng.state = function() { return copy(arc4, {}); };
811
+ }
812
+
813
+ // If called as a method of Math (Math.seedrandom()), mutate
814
+ // Math.random because that is how seedrandom.js has worked since v1.0.
815
+ if (is_math_call) { math[rngname] = prng; return seed; }
816
+
817
+ // Otherwise, it is a newer calling convention, so return the
818
+ // prng directly.
819
+ else return prng;
820
+ })(
821
+ prng,
822
+ shortseed,
823
+ 'global' in options ? options.global : (this == math),
824
+ options.state);
825
+ }
826
+
827
+ //
828
+ // ARC4
829
+ //
830
+ // An ARC4 implementation. The constructor takes a key in the form of
831
+ // an array of at most (width) integers that should be 0 <= x < (width).
832
+ //
833
+ // The g(count) method returns a pseudorandom integer that concatenates
834
+ // the next (count) outputs from ARC4. Its return value is a number x
835
+ // that is in the range 0 <= x < (width ^ count).
836
+ //
837
+ function ARC4(key) {
838
+ var t, keylen = key.length,
839
+ me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
840
+
841
+ // The empty key [] is treated as [0].
842
+ if (!keylen) { key = [keylen++]; }
843
+
844
+ // Set up S using the standard key scheduling algorithm.
845
+ while (i < width) {
846
+ s[i] = i++;
847
+ }
848
+ for (i = 0; i < width; i++) {
849
+ s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
850
+ s[j] = t;
851
+ }
852
+
853
+ // The "g" method returns the next (count) outputs as one number.
854
+ (me.g = function(count) {
855
+ // Using instance members instead of closure state nearly doubles speed.
856
+ var t, r = 0,
857
+ i = me.i, j = me.j, s = me.S;
858
+ while (count--) {
859
+ t = s[i = mask & (i + 1)];
860
+ r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
861
+ }
862
+ me.i = i; me.j = j;
863
+ return r;
864
+ // For robust unpredictability, the function call below automatically
865
+ // discards an initial batch of values. This is called RC4-drop[256].
866
+ // See http://google.com/search?q=rsa+fluhrer+response&btnI
867
+ })(width);
868
+ }
869
+
870
+ //
871
+ // copy()
872
+ // Copies internal state of ARC4 to or from a plain object.
873
+ //
874
+ function copy(f, t) {
875
+ t.i = f.i;
876
+ t.j = f.j;
877
+ t.S = f.S.slice();
878
+ return t;
879
+ }
880
+ //
881
+ // flatten()
882
+ // Converts an object tree to nested arrays of strings.
883
+ //
884
+ function flatten(obj, depth) {
885
+ var result = [], typ = (typeof obj), prop;
886
+ if (depth && typ == 'object') {
887
+ for (prop in obj) {
888
+ try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
889
+ }
890
+ }
891
+ return (result.length ? result : typ == 'string' ? obj : obj + '\0');
892
+ }
893
+
894
+ //
895
+ // mixkey()
896
+ // Mixes a string seed into a key that is an array of integers, and
897
+ // returns a shortened string seed that is equivalent to the result key.
898
+ //
899
+ function mixkey(seed, key) {
900
+ var stringseed = seed + '', smear, j = 0;
901
+ while (j < stringseed.length) {
902
+ key[mask & j] =
903
+ mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
904
+ }
905
+ return tostring(key);
906
+ }
907
+
908
+ //
909
+ // autoseed()
910
+ // Returns an object for autoseeding, using window.crypto and Node crypto
911
+ // module if available.
912
+ //
913
+ function autoseed() {
914
+ try {
915
+ var out;
916
+ if (nodecrypto && (out = nodecrypto.randomBytes)) {
917
+ // The use of 'out' to remember randomBytes makes tight minified code.
918
+ out = out(width);
919
+ } else {
920
+ out = new Uint8Array(width);
921
+ (global.crypto || global.msCrypto).getRandomValues(out);
922
+ }
923
+ return tostring(out);
924
+ } catch (e) {
925
+ var browser = global.navigator,
926
+ plugins = browser && browser.plugins;
927
+ return [+new Date, global, plugins, global.screen, tostring(pool)];
928
+ }
929
+ }
930
+
931
+ //
932
+ // tostring()
933
+ // Converts an array of charcodes to a string
934
+ //
935
+ function tostring(a) {
936
+ return String.fromCharCode.apply(0, a);
937
+ }
938
+
939
+ //
940
+ // When seedrandom.js is loaded, we immediately mix a few bits
941
+ // from the built-in RNG into the entropy pool. Because we do
942
+ // not want to interfere with deterministic PRNG state later,
943
+ // seedrandom will not call math.random on its own again after
944
+ // initialization.
945
+ //
946
+ mixkey(math.random(), pool);
947
+
948
+ //
949
+ // Nodejs and AMD support: export the implementation as a module using
950
+ // either convention.
951
+ //
952
+ if (module.exports) {
953
+ module.exports = seedrandom;
954
+ // When in node.js, try using crypto package for autoseeding.
955
+ try {
956
+ nodecrypto = require('crypto');
957
+ } catch (ex) {}
958
+ } else {
959
+ // When included as a plain script, set up Math.seedrandom global.
960
+ math['seed' + rngname] = seedrandom;
961
+ }
962
+
963
+
964
+ // End anonymous scope, and pass initial values.
965
+ })(
966
+ // global: `self` in browsers (including strict mode and web workers),
967
+ // otherwise `this` in Node and other environments
968
+ (typeof self !== 'undefined') ? self : commonjsGlobal,
969
+ [], // pool: entropy pool starts empty
970
+ Math // math: package containing random, pow, and seedrandom
971
+ );
972
+ } (seedrandom$1));
973
+
974
+ // A library of seedable RNGs implemented in Javascript.
975
+ //
976
+ // Usage:
977
+ //
978
+ // var seedrandom = require('seedrandom');
979
+ // var random = seedrandom(1); // or any seed.
980
+ // var x = random(); // 0 <= x < 1. Every bit is random.
981
+ // var x = random.quick(); // 0 <= x < 1. 32 bits of randomness.
982
+
983
+ // alea, a 53-bit multiply-with-carry generator by Johannes Baagøe.
984
+ // Period: ~2^116
985
+ // Reported to pass all BigCrush tests.
986
+ var alea = alea$1.exports;
987
+
988
+ // xor128, a pure xor-shift generator by George Marsaglia.
989
+ // Period: 2^128-1.
990
+ // Reported to fail: MatrixRank and LinearComp.
991
+ var xor128 = xor128$1.exports;
992
+
993
+ // xorwow, George Marsaglia's 160-bit xor-shift combined plus weyl.
994
+ // Period: 2^192-2^32
995
+ // Reported to fail: CollisionOver, SimpPoker, and LinearComp.
996
+ var xorwow = xorwow$1.exports;
997
+
998
+ // xorshift7, by François Panneton and Pierre L'ecuyer, takes
999
+ // a different approach: it adds robustness by allowing more shifts
1000
+ // than Marsaglia's original three. It is a 7-shift generator
1001
+ // with 256 bits, that passes BigCrush with no systmatic failures.
1002
+ // Period 2^256-1.
1003
+ // No systematic BigCrush failures reported.
1004
+ var xorshift7 = xorshift7$1.exports;
1005
+
1006
+ // xor4096, by Richard Brent, is a 4096-bit xor-shift with a
1007
+ // very long period that also adds a Weyl generator. It also passes
1008
+ // BigCrush with no systematic failures. Its long period may
1009
+ // be useful if you have many generators and need to avoid
1010
+ // collisions.
1011
+ // Period: 2^4128-2^32.
1012
+ // No systematic BigCrush failures reported.
1013
+ var xor4096 = xor4096$1.exports;
1014
+
1015
+ // Tyche-i, by Samuel Neves and Filipe Araujo, is a bit-shifting random
1016
+ // number generator derived from ChaCha, a modern stream cipher.
1017
+ // https://eden.dei.uc.pt/~sneves/pubs/2011-snfa2.pdf
1018
+ // Period: ~2^127
1019
+ // No systematic BigCrush failures reported.
1020
+ var tychei = tychei$1.exports;
1021
+
1022
+ // The original ARC4-based prng included in this library.
1023
+ // Period: ~2^1600
1024
+ var sr = seedrandom$1.exports;
1025
+
1026
+ sr.alea = alea;
1027
+ sr.xor128 = xor128;
1028
+ sr.xorwow = xorwow;
1029
+ sr.xorshift7 = xorshift7;
1030
+ sr.xor4096 = xor4096;
1031
+ sr.tychei = tychei;
1032
+
1033
+ var seedrandom = sr;
1034
+
1035
+ /* global analytics */
1036
+ const config = {
1037
+ /* Your segment writeKey */
1038
+ writeKey: null,
1039
+ /* Disable anonymous MTU */
1040
+ host: null,
1041
+ debug: false,
1042
+ fetch: null,
1043
+ };
1044
+ const autoSeedRandom = seedrandom();
1045
+ const parseQuery = (qs) => {
1046
+ if (!qs) {
1047
+ return {};
1048
+ }
1049
+ let queryString = qs.length > 0 && qs.charAt(0) === "?" ? qs.substring(1) : qs;
1050
+ let query = {};
1051
+ let pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
1052
+ for (let i = 0; i < pairs.length; i++) {
1053
+ let pair = pairs[i].split("=");
1054
+ query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
1055
+ }
1056
+ return query;
1057
+ };
1058
+ function utmToKey(key) {
1059
+ const name = key.substring("utm_".length);
1060
+ return name === "campaign" ? "name" : name;
1061
+ }
1062
+ function parseUtms(query) {
1063
+ return Object.entries(query)
1064
+ .filter(([key]) => key.indexOf("utm_") === 0)
1065
+ .reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [utmToKey(key)]: value })), {});
1066
+ }
1067
+ function safeCall(f, defaultVal) {
1068
+ try {
1069
+ return f();
1070
+ }
1071
+ catch (e) {
1072
+ return defaultVal;
1073
+ }
1074
+ }
1075
+ function restoreTraits(storage) {
1076
+ const val = storage.getItem("__user_traits");
1077
+ if (typeof val === "string") {
1078
+ return safeCall(() => JSON.parse(val), {});
1079
+ }
1080
+ return val;
1081
+ }
1082
+ function getTopLevelDomain(opts = {}) {
1083
+ if (opts.cookieDomain) {
1084
+ return opts.cookieDomain;
1085
+ }
1086
+ const [domain] = window.location.hostname.split(":");
1087
+ const parts = domain.split(".");
1088
+ if (parts[parts.length - 1] === "localhost" || parts.length < 2) {
1089
+ return parts[parts.length - 1];
1090
+ }
1091
+ else {
1092
+ return parts[parts.length - 2] + "." + parts[parts.length - 1];
1093
+ }
1094
+ }
1095
+ function getCookie(name) {
1096
+ const value = `; ${document.cookie}`;
1097
+ const parts = value.split(`; ${name}=`);
1098
+ return parts.length === 2 ? parts.pop().split(";").shift() : undefined;
1099
+ }
1100
+ function removeCookie(name) {
1101
+ document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;";
1102
+ }
1103
+ function setCookie(name, val, { domain, secure }) {
1104
+ document.cookie =
1105
+ name +
1106
+ "=" +
1107
+ val +
1108
+ ";domain=" +
1109
+ domain +
1110
+ ";path=/" +
1111
+ ";expires=" +
1112
+ new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365 * 5).toUTCString() +
1113
+ ";SameSite=" +
1114
+ (secure ? "None" : "Lax") +
1115
+ (secure ? ";secure" : "");
1116
+ }
1117
+ const defaultCookie2Key = {
1118
+ __anon_id: "__eventn_id",
1119
+ __user_traits: "__eventn_id_usr",
1120
+ __user_id: "__eventn_uid",
1121
+ };
1122
+ const cookieStorage = (cookieDomain, key2cookie) => {
1123
+ return {
1124
+ setItem(key, val) {
1125
+ const strVal = typeof val === "object" && val !== null ? JSON.stringify(val) : val;
1126
+ const cookieName = key2cookie[key] || key;
1127
+ setCookie(cookieName, strVal, {
1128
+ domain: cookieDomain,
1129
+ secure: window.location.protocol === "https:",
1130
+ });
1131
+ },
1132
+ getItem(key) {
1133
+ const cookieName = key2cookie[key] || key;
1134
+ const result = getCookie(cookieName);
1135
+ if (typeof result === "undefined" && key === "__user_id") {
1136
+ //backward compatibility with old jitsu code. get user id if from traits
1137
+ const traits = parse(getCookie(key2cookie[key])) || {};
1138
+ return traits.internal_id || traits.user_id || traits.id || traits.userId;
1139
+ }
1140
+ return parse(result);
1141
+ },
1142
+ removeItem(key) {
1143
+ removeCookie(key2cookie[key] || key);
1144
+ },
1145
+ };
1146
+ };
1147
+ function windowRuntime(opts) {
1148
+ return {
1149
+ documentEncoding() {
1150
+ return window.document.characterSet;
1151
+ },
1152
+ timezoneOffset() {
1153
+ return new Date().getTimezoneOffset();
1154
+ },
1155
+ store() {
1156
+ return cookieStorage(opts.cookieDomain || getTopLevelDomain(), defaultCookie2Key);
1157
+ },
1158
+ language() {
1159
+ return window.navigator.language;
1160
+ },
1161
+ pageTitle() {
1162
+ return window.document.title;
1163
+ },
1164
+ pageUrl() {
1165
+ return window.location.href;
1166
+ },
1167
+ referrer() {
1168
+ return window.document.referrer;
1169
+ },
1170
+ screen() {
1171
+ return {
1172
+ width: window.screen.width,
1173
+ height: window.screen.height,
1174
+ innerWidth: window.innerWidth,
1175
+ innerHeight: window.innerHeight,
1176
+ density: Math.floor(window.devicePixelRatio),
1177
+ };
1178
+ },
1179
+ userAgent() {
1180
+ return window.navigator.userAgent;
1181
+ },
1182
+ };
1183
+ }
1184
+ const emptyRuntime = (config) => ({
1185
+ documentEncoding() {
1186
+ return undefined;
1187
+ },
1188
+ timezoneOffset() {
1189
+ return undefined;
1190
+ },
1191
+ store() {
1192
+ const storage = {};
1193
+ return {
1194
+ setItem(key, val) {
1195
+ if (config.debug) {
1196
+ console.log(`[JITSU EMPTY RUNTIME] Set storage item ${key}=${JSON.stringify(val)}`);
1197
+ }
1198
+ storage[key] = val;
1199
+ },
1200
+ getItem(key) {
1201
+ const val = storage[key];
1202
+ if (config.debug) {
1203
+ console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${JSON.stringify(val)}`);
1204
+ }
1205
+ return val;
1206
+ },
1207
+ removeItem(key) {
1208
+ if (config.debug) {
1209
+ console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${storage[key]}`);
1210
+ }
1211
+ delete storage[key];
1212
+ },
1213
+ };
1214
+ },
1215
+ language() {
1216
+ return undefined;
1217
+ },
1218
+ pageTitle() {
1219
+ return undefined;
1220
+ },
1221
+ pageUrl() {
1222
+ return undefined;
1223
+ },
1224
+ referrer() {
1225
+ return undefined;
1226
+ },
1227
+ screen() {
1228
+ return undefined;
1229
+ },
1230
+ userAgent() {
1231
+ return undefined;
1232
+ },
1233
+ });
1234
+ function deepMerge(target, source) {
1235
+ if (typeof source !== "object" || source === null) {
1236
+ return source;
1237
+ }
1238
+ if (typeof target !== "object" || target === null) {
1239
+ return source;
1240
+ }
1241
+ return Object.entries(source).reduce((acc, [key, value]) => {
1242
+ acc[key] = deepMerge(target[key], value);
1243
+ return acc;
1244
+ }, target);
1245
+ }
1246
+ function adjustPayload(payload, config, storage) {
1247
+ var _a, _b;
1248
+ const runtime = config.runtime || (typeof window === "undefined" ? emptyRuntime(config) : windowRuntime(config));
1249
+ const url = runtime.pageUrl();
1250
+ const parsedUrl = safeCall(() => new URL(url), undefined);
1251
+ const query = parsedUrl ? parseQuery(parsedUrl.search) : {};
1252
+ const properties = payload.properties || {};
1253
+ const customContext = ((_a = payload.properties) === null || _a === void 0 ? void 0 : _a.context) || {};
1254
+ (_b = payload.properties) === null || _b === void 0 ? true : delete _b.context;
1255
+ const referrer = runtime.referrer();
1256
+ const context = {
1257
+ library: {
1258
+ name: "jitsu-js",
1259
+ version: "1.0.0",
1260
+ },
1261
+ userAgent: runtime.userAgent(),
1262
+ locale: runtime.language(),
1263
+ screen: runtime.screen(),
1264
+ traits: payload.type != "identify" ? Object.assign({}, (restoreTraits(storage) || {})) : undefined,
1265
+ page: {
1266
+ path: properties.path || (parsedUrl && parsedUrl.pathname),
1267
+ referrer: referrer,
1268
+ referring_domain: safeCall(() => referrer && new URL(referrer).hostname),
1269
+ host: parsedUrl && parsedUrl.host,
1270
+ search: properties.search || (parsedUrl && parsedUrl.search),
1271
+ title: properties.title || runtime.pageTitle(),
1272
+ url: properties.url || url,
1273
+ enconding: properties.enconding || runtime.documentEncoding(),
1274
+ },
1275
+ campaign: parseUtms(query),
1276
+ };
1277
+ const withContext = Object.assign(Object.assign({}, payload), { timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(), context: deepMerge(context, customContext) });
1278
+ delete withContext.meta;
1279
+ delete withContext.options;
1280
+ return withContext;
1281
+ }
1282
+ function send(method, payload, jitsuConfig, store) {
1283
+ const url = `${jitsuConfig.host}/api/s/${method}`;
1284
+ const fetch = jitsuConfig.fetch || globalThis.fetch;
1285
+ if (!fetch) {
1286
+ throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");
1287
+ }
1288
+ const authHeader = jitsuConfig.writeKey ? { Authorization: `Bearer ${jitsuConfig.writeKey}` } : {};
1289
+ const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
1290
+ if (jitsuConfig.debug) {
1291
+ console.log(`Sending jitsu event to ${url}: `, JSON.stringify(payload, null, 2));
1292
+ }
1293
+ const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
1294
+ return fetch(url, {
1295
+ method: "POST",
1296
+ headers: Object.assign(Object.assign({ "Content-Type": "application/json" }, authHeader), debugHeader),
1297
+ body: JSON.stringify(adjustedPayload),
1298
+ })
1299
+ .then(res => {
1300
+ if (jitsuConfig.debug) {
1301
+ console.debug(`Jitsu ${url} replied ${res.status}. Original payload: `, JSON.stringify(adjustedPayload, null, 2));
1302
+ }
1303
+ })
1304
+ .catch(err => {
1305
+ if (jitsuConfig.debug) {
1306
+ console.error(`Jitsu ${url} failed: `, err);
1307
+ }
1308
+ });
1309
+ }
1310
+ const jitsuAnalyticsPlugin = (pluginConfig = {}) => {
1311
+ const storageCache = {};
1312
+ // AnalyticsInstance's storage is async somewhere inside. So if we make 'page' call right after 'identify' call
1313
+ // 'page' call will load traits from storage before 'identify' call had a change to save them.
1314
+ // to avoid that we use in-memory cache for storage
1315
+ const cachingStorageWrapper = (persistentStorage) => ({
1316
+ setItem(key, val) {
1317
+ storageCache[key] = val;
1318
+ persistentStorage.setItem(key, val);
1319
+ },
1320
+ getItem(key) {
1321
+ return storageCache[key] || persistentStorage.getItem(key);
1322
+ },
1323
+ removeItem(key) {
1324
+ delete storageCache[key];
1325
+ persistentStorage.removeItem(key);
1326
+ },
1327
+ });
1328
+ return {
1329
+ name: "jitsu",
1330
+ config: Object.assign(Object.assign({}, config), pluginConfig),
1331
+ initialize: args => {
1332
+ const { config, instance } = args;
1333
+ if (config.debug) {
1334
+ console.debug("Initializing Jitsu plugin with config: ", JSON.stringify(config));
1335
+ }
1336
+ if (!config.host) {
1337
+ throw new Error("Please specify host variable in jitsu plugin initialization");
1338
+ }
1339
+ },
1340
+ page: args => {
1341
+ const { payload, config, instance } = args;
1342
+ return send("page", payload, config, cachingStorageWrapper(instance.storage));
1343
+ },
1344
+ track: args => {
1345
+ const { payload, config, instance } = args;
1346
+ return send("track", payload, config, cachingStorageWrapper(instance.storage));
1347
+ },
1348
+ identify: args => {
1349
+ const { payload, config, instance } = args;
1350
+ // Store traits in cache to be able to use them in page and track events that run asynchronously with current identify.
1351
+ storageCache["__user_traits"] = payload.traits;
1352
+ return send("identify", payload, config, cachingStorageWrapper(instance.storage));
1353
+ },
1354
+ reset: args => {
1355
+ //clear storage cache
1356
+ Object.keys(storageCache).forEach(key => delete storageCache[key]);
1357
+ },
1358
+ };
1359
+ };
1360
+ function randomId(digits = 24) {
1361
+ let id = "";
1362
+ for (let i = 0; i < digits; i++) {
1363
+ id += randomChar(i === 0, autoSeedRandom);
1364
+ }
1365
+ return id;
1366
+ }
1367
+ function randomChar(noDigits, rng = Math.random) {
1368
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1369
+ while (true) {
1370
+ const index = Math.floor(rng() * chars.length);
1371
+ if (!noDigits || index > 9) {
1372
+ return chars[index];
1373
+ }
1374
+ }
1375
+ }
1376
+
1377
+ function parse(input) {
1378
+ let value = input;
1379
+ if ((input === null || input === void 0 ? void 0 : input.indexOf("%7B%22")) === 0) {
1380
+ value = decodeURIComponent(input);
1381
+ }
1382
+ try {
1383
+ value = JSON.parse(input);
1384
+ if (value === "true")
1385
+ return true;
1386
+ if (value === "false")
1387
+ return false;
1388
+ if (typeof value === "object")
1389
+ return value;
1390
+ if (parseFloat(value) === value) {
1391
+ value = parseFloat(value);
1392
+ }
1393
+ }
1394
+ catch (e) { }
1395
+ if (value === null || value === "") {
1396
+ return;
1397
+ }
1398
+ return value;
1399
+ }
1400
+ function jitsuAnalytics(opts) {
1401
+ const rt = opts.runtime || (typeof window === "undefined" ? emptyRuntime(opts) : windowRuntime(opts));
1402
+ const analytics = analyticsLib({
1403
+ app: "test",
1404
+ debug: !!opts.debug,
1405
+ storage: rt.store(),
1406
+ plugins: [jitsuAnalyticsPlugin(opts)],
1407
+ });
1408
+ const originalPage = analytics.page;
1409
+ analytics.page = (...args) => {
1410
+ if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "object") {
1411
+ return originalPage(Object.assign({ name: args[0] }, args[1]));
1412
+ }
1413
+ else {
1414
+ return originalPage(...args);
1415
+ }
1416
+ };
1417
+ return analytics;
1418
+ }
1419
+
1420
+ function snakeToCamel(s) {
1421
+ return s.replace(/([-_][a-z])/gi, $1 => {
1422
+ return $1.toUpperCase().replace("-", "").replace("_", "");
1423
+ });
1424
+ }
1425
+ const booleanParser = (arg) => arg === "true" || arg === "1" || arg === "yes";
1426
+ const parsers = {
1427
+ debug: booleanParser,
1428
+ initOnly: booleanParser,
1429
+ };
1430
+ function getParser(name) {
1431
+ return parsers[name] || (x => x);
1432
+ }
1433
+ function getScriptAttributes(scriptElement) {
1434
+ return scriptElement
1435
+ .getAttributeNames()
1436
+ .filter(name => name.indexOf("data-") === 0)
1437
+ .map(name => name.substring("data-".length))
1438
+ .reduce((res, name) => (Object.assign(Object.assign({}, res), { [snakeToCamel(name)]: getParser(snakeToCamel(name))(scriptElement.getAttribute(`data-${name}`)) })), {});
1439
+ }
1440
+ (function () {
1441
+ if (window["jitsu"]) {
1442
+ console.log("Jitsu is already initialized");
1443
+ }
1444
+ function readJitsuOptions() {
1445
+ const scriptElement = window.document.currentScript;
1446
+ if (!scriptElement) {
1447
+ throw new Error(`Can't find script element`);
1448
+ }
1449
+ const host = new URL(scriptElement.src).origin;
1450
+ return Object.assign(Object.assign(Object.assign({}, ((window === null || window === void 0 ? void 0 : window.jitsuConfig) || {})), getScriptAttributes(scriptElement)), { host });
1451
+ }
1452
+ const options = readJitsuOptions();
1453
+ if (options.debug) {
1454
+ console.log(`Jitsu options: `, JSON.stringify(options));
1455
+ }
1456
+ const jitsu = jitsuAnalytics(options);
1457
+ if (options.onload) {
1458
+ const onloadFunction = window[options.onload];
1459
+ if (!onloadFunction) {
1460
+ console.warn(`onload function ${options.onload} is not found in window`);
1461
+ }
1462
+ if (typeof onloadFunction === "function") {
1463
+ onloadFunction(jitsu);
1464
+ }
1465
+ else {
1466
+ console.warn(`onload function ${options.onload} is not callable: ${typeof onloadFunction}`);
1467
+ }
1468
+ }
1469
+ window["jitsu"] = jitsu;
1470
+ if (!options.initOnly) {
1471
+ jitsu.page();
1472
+ }
1473
+ })();
1474
+
1475
+ })();