@jitsu/js 1.11.0-beta.1 → 1.11.0-beta.11

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.
@@ -1,25 +1,1198 @@
1
- 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}
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a4, b5) => {
9
+ for (var prop in b5 || (b5 = {}))
10
+ if (__hasOwnProp.call(b5, prop))
11
+ __defNormalProp(a4, prop, b5[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b5)) {
14
+ if (__propIsEnum.call(b5, prop))
15
+ __defNormalProp(a4, prop, b5[prop]);
16
+ }
17
+ return a4;
18
+ };
19
+ var __spreadProps = (a4, b5) => __defProps(a4, __getOwnPropDescs(b5));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e2) {
26
+ reject(e2);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e2) {
33
+ reject(e2);
34
+ }
35
+ };
36
+ var step = (x3) => x3.done ? resolve(x3.value) : Promise.resolve(x3.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
2
40
 
3
- var e="undefined",o$1="object",b$3="any",m$1="*",j$1="__",F$2="undefined"!=typeof process?process:{};F$2.env&&F$2.env.NODE_ENV||"";var $$1="undefined"!=typeof document;null!=F$2.versions&&null!=F$2.versions.node;"undefined"!=typeof Deno&&void 0!==Deno.core;$$1&&"nodejs"===window.name||"undefined"!=typeof navigator&&void 0!==navigator.userAgent&&(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");
41
+ // ../../node_modules/.pnpm/dlv@1.1.3/node_modules/dlv/dist/dlv.es.js
42
+ function dlv_es_default(t2, e2, l3, n4, r3) {
43
+ for (e2 = e2.split ? e2.split(".") : e2, n4 = 0; n4 < e2.length; n4++) t2 = t2 ? t2[e2[n4]] : r3;
44
+ return t2 === r3 ? l3 : t2;
45
+ }
4
46
 
5
- 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}
47
+ // ../../node_modules/.pnpm/@analytics+type-utils@0.6.2/node_modules/@analytics/type-utils/dist/analytics-util-types.module.js
48
+ var e = "undefined";
49
+ var o = "object";
50
+ var b = "any";
51
+ var m = "*";
52
+ var j = "__";
53
+ var F = "undefined" != typeof process ? process : {};
54
+ var P = F.env && F.env.NODE_ENV || "";
55
+ var $ = "undefined" != typeof document;
56
+ var T = $ && "localhost" === window.location.hostname;
57
+ var _ = null != F.versions && null != F.versions.node;
58
+ var k = "undefined" != typeof Deno && void 0 !== Deno.core;
59
+ var B = "object" == typeof self && self.constructor && "DedicatedWorkerGlobalScope" === self.constructor.name;
60
+ var G = $ && "nodejs" === window.name || "undefined" != typeof navigator && void 0 !== navigator.userAgent && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
61
+ function M(n4, t2) {
62
+ return t2.charAt(0)[n4]() + t2.slice(1);
63
+ }
64
+ var U = M.bind(null, "toUpperCase");
65
+ var H = M.bind(null, "toLowerCase");
66
+ function J(n4) {
67
+ return Y(n4) ? U("null") : "object" == typeof n4 ? yn(n4) : Object.prototype.toString.call(n4).slice(8, -1);
68
+ }
69
+ function R(n4, t2) {
70
+ void 0 === t2 && (t2 = true);
71
+ var e2 = J(n4);
72
+ return t2 ? H(e2) : e2;
73
+ }
74
+ function V(n4, t2) {
75
+ return typeof t2 === n4;
76
+ }
77
+ var W = V.bind(null, "function");
78
+ var q = V.bind(null, "string");
79
+ var I = V.bind(null, "undefined");
80
+ var Q = V.bind(null, "boolean");
81
+ var X = V.bind(null, "symbol");
82
+ function Y(n4) {
83
+ return null === n4;
84
+ }
85
+ function nn(n4) {
86
+ return "number" === R(n4) && !isNaN(n4);
87
+ }
88
+ function rn(n4) {
89
+ return "array" === R(n4);
90
+ }
91
+ function on(n4) {
92
+ if (!un(n4)) return false;
93
+ for (var t2 = n4; null !== Object.getPrototypeOf(t2); ) t2 = Object.getPrototypeOf(t2);
94
+ return Object.getPrototypeOf(n4) === t2;
95
+ }
96
+ function un(n4) {
97
+ return n4 && ("object" == typeof n4 || null !== n4);
98
+ }
99
+ function yn(n4) {
100
+ return W(n4.constructor) ? n4.constructor.name : null;
101
+ }
102
+ function hn(n4) {
103
+ return n4 instanceof Error || q(n4.message) && n4.constructor && nn(n4.constructor.stackTraceLimit);
104
+ }
105
+ function On(n4, t2) {
106
+ if ("object" != typeof t2 || Y(t2)) return false;
107
+ if (t2 instanceof n4) return true;
108
+ var e2 = R(new n4(""));
109
+ if (hn(t2)) for (; t2; ) {
110
+ if (R(t2) === e2) return true;
111
+ t2 = Object.getPrototypeOf(t2);
112
+ }
113
+ return false;
114
+ }
115
+ var Sn = On.bind(null, TypeError);
116
+ var An = On.bind(null, SyntaxError);
117
+ function $n(n4, t2) {
118
+ var e2 = n4 instanceof Element || n4 instanceof HTMLDocument;
119
+ return e2 && t2 ? Tn(n4, t2) : e2;
120
+ }
121
+ function Tn(n4, t2) {
122
+ return void 0 === t2 && (t2 = ""), n4 && n4.nodeName === t2.toUpperCase();
123
+ }
124
+ function _n(n4) {
125
+ var t2 = [].slice.call(arguments, 1);
126
+ return function() {
127
+ return n4.apply(void 0, [].slice.call(arguments).concat(t2));
128
+ };
129
+ }
130
+ var kn = _n($n, "form");
131
+ var Bn = _n($n, "button");
132
+ var Gn = _n($n, "input");
133
+ var Mn = _n($n, "select");
6
134
 
7
- 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}
135
+ // ../../node_modules/.pnpm/analytics-utils@1.0.12_@types+dlv@1.1.4/node_modules/analytics-utils/dist/analytics-utils.module.js
136
+ function n(e2) {
137
+ try {
138
+ return decodeURIComponent(e2.replace(/\+/g, " "));
139
+ } catch (e3) {
140
+ return null;
141
+ }
142
+ }
143
+ function s(r3) {
144
+ return (function(e2) {
145
+ for (var r4, t2 = /* @__PURE__ */ Object.create(null), o3 = /([^&=]+)=?([^&]*)/g; r4 = o3.exec(e2); ) {
146
+ var a4 = n(r4[1]), i4 = n(r4[2]);
147
+ "[]" === a4.substring(a4.length - 2) ? (t2[a4 = a4.substring(0, a4.length - 2)] || (t2[a4] = [])).push(i4) : t2[a4] = "" === i4 || i4;
148
+ }
149
+ for (var u3 in t2) {
150
+ var c4 = u3.split("[");
151
+ c4.length > 1 && (m2(t2, c4.map(function(e3) {
152
+ return e3.replace(/[?[\]\\ ]/g, "");
153
+ }), t2[u3]), delete t2[u3]);
154
+ }
155
+ return t2;
156
+ })((function(r4) {
157
+ if (r4) {
158
+ var t2 = r4.match(/\?(.*)/);
159
+ return t2 && t2[1] ? t2[1].split("#")[0] : "";
160
+ }
161
+ return $ && window.location.search.substring(1);
162
+ })(r3));
163
+ }
164
+ function m2(e2, r3, t2) {
165
+ for (var n4 = r3.length - 1, o3 = 0; o3 < n4; ++o3) {
166
+ var a4 = r3[o3];
167
+ if ("__proto__" === a4 || "constructor" === a4) break;
168
+ a4 in e2 || (e2[a4] = {}), e2 = e2[a4];
169
+ }
170
+ e2[r3[n4]] = t2;
171
+ }
172
+ function y() {
173
+ for (var e2 = "", r3 = 0, t2 = 4294967295 * Math.random() | 0; r3++ < 36; ) {
174
+ var n4 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r3 - 1], o3 = 15 & t2;
175
+ e2 += "-" == n4 || "4" == n4 ? n4 : ("x" == n4 ? o3 : 3 & o3 | 8).toString(16), t2 = r3 % 8 == 0 ? 4294967295 * Math.random() | 0 : t2 >> 4;
176
+ }
177
+ return e2;
178
+ }
8
179
 
9
- 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",j="userId",k$1="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);}),[j,k$1,"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)})})}function X(e){return {abort:e}}var H=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(W),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(W)?function(e,t,n,r,i){return function(a,o){var u=r?r.name:e,c=o&&ne(o)?o:n;if(r&&(!(c=o&&ne(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:ae(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){try{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){try{return Promise.resolve(e).then(function(e){return t.method&&W$1(t.method)?(function(e,t){var n=ie(e);if(n&&n.name===t){var r=ie(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:Q(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;})}catch(e){return Promise.reject(e)}},Promise.resolve(n))).then(function(t){e[u]=t;});e[u]=n;}();return o&&o.then?o.then(i):i()})}catch(e){return Promise.reject(e)}},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),ee(n,l))return K({data:n,method:p,instance:r,pluginName:l,store:u}),Promise.resolve(t);if(ee(t,l))return s&&K({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:Q(l,f,a),plugins:f})).then(function(i){var a=on(i)?i:{},o=g$1({},t,a),s=e[l];if(ee(s,l))K({data:s,method:p,instance:r,pluginName:l,store:u});else {var f=p+":"+l;(f.match(/:/g)||[]).length<2&&!p.match(F$1)&&!p.match(G$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(W)||p.match(/^registerPlugin/)||p.match(G$1)||p.match(F$1)||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"}});te(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)}},W=/Start$/,F$1=/^bootstrap/,G$1=/^ready/;function K(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 Q(e,t,n){var r=t[e]||n[e];return r&&r.config?r.config:{}}function Y(e,t){return t.reduce(function(t,n){return n[e]?t.concat({methodName:e,pluginName:n.name,method:n[e]}):t},[])}function Z(e,t){var n=e.replace(W,""),r=t?":"+t:"";return [""+e+r,""+n+r,n+"End"+r]}function ee(e,t){var n=e.abort;return !!n&&(!0===n||re(n,t)||n&&re(n.plugins,t))}function te(e,t){var n=e.abort;if(!n)return !1;if(!0===n||q$1(n))return !0;var r=n.plugins;return ne(n)&&n.length===t||ne(r)&&r.length===t}function ne(e){return Array.isArray(e)}function re(e,t){return !(!e||!ne(e))&&e.includes(t)}function ie(e){var t=e.match(/(.*):(.*)/);return !!t&&{method:t[1],name:t[2]}}function ae(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 oe(e,t,n){var r={};return function(i){return function(a){return function(o){try{var u,s=function(e){return u?e:a(m)},d=o.type,p=o.plugins,m=o;if(o.abort)return Promise.resolve(a(o));if(d===z.enablePlugin&&i.dispatch({type:z.initializeStart,plugins:p,disabled:[],fromEnable:!0,meta:o.meta}),d===z.disablePlugin&&setTimeout(function(){return L$1(o.meta.rid,{payload:o})},0),d===z.initializeEnd){var h=t(),v=Object.keys(h),y=v.filter(function(e){return p.includes(e)}).map(function(e){return h[e]}),b=[],I=[],w=o.disabled,E=y.map(function(e){var t=e.loaded,n=e.name,a=e.config;return J$1(e,function(){return t({config:a})},1e4).then(function(t){return r[n]||(i.dispatch({type:z.pluginReadyType(n),name:n,events:Object.keys(e).filter(function(e){return !T.includes(e)})}),r[n]=!0),b=b.concat(n),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return I=I.concat(e.name),e})});Promise.all(E).then(function(e){var t={plugins:b,failed:I,disabled:w};setTimeout(function(){v.length===E.length+w.length&&i.dispatch(g$1({},{type:z.ready},t));},0);});}var P=function(){if(d!==z.bootstrap)return /^ready:([^:]*)$/.test(d)&&setTimeout(function(){return function(e,t,n){var r={},i=t(),a=e.getState(),o=a.plugins,u=a.queue,s=a.user;if(!a.context.offline&&u&&u.actions&&u.actions.length){var f=u.actions.reduce(function(e,t,n){return o[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(f.processIndex&&f.processIndex.length){f.processIndex.forEach(function(t){var a=u.actions[t],f=a.plugin,d=a.payload.type,p=i[f][d];if(p&&W$1(p)){var m,h=function(e,t){return void 0===e&&(e={}),void 0===t&&(t={}),[j,k$1].reduce(function(n,r){return e.hasOwnProperty(r)&&t[r]&&t[r]!==e[r]&&(n[r]=t[r]),n},e)}(a.payload,s),v=r[h.meta.rid];if(!v&&(m=p({payload:h,config:o[f].config,instance:n,abort:X}))&&on(m)&&m.abort)return void(r[h.meta.rid]=!0);if(!v){var y=d+":"+f;e.dispatch(g$1({},h,{type:y,_:{called:y,from:"queueDrain"}}));}}});var d=u.actions.filter(function(e,t){return !~f.processIndex.indexOf(t)});u.actions=d;}}}(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(W,"");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=Z(e).map(function(e){return Y(e,t)});return t.reduce(function(n,r){var i=r.name,a=Z(e,i).map(function(e){return Y(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(H({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(W))return Promise.resolve(H({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(te(e,d.length))return e;var s,l=function(){if(o!==u)return Promise.resolve(H({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){return u=1,a(e)})}();return Promise.resolve(P&&P.then?P.then(s):s(P))}catch(e){return Promise.reject(e)}}}}}function ue(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 ce=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 se(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=le(n.type,"registerPlugin"),a=e()[i];if(!a||!i)return t;var o=n.enabled,u=a.config;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded({config:u})),config:u},g$1({},t,r)}if(/^initialize:([^:]*)$/.test(n.type)){var c=le(n.type,z.initialize),s=e()[c];return s&&c?(r[c]=g$1({},t[c],{initialized:!0,loaded:Boolean(s.loaded({config:s.config}))}),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,fe(n.plugins,!1,t));case z.enablePlugin:return g$1({},t,fe(n.plugins,!0,t));default:return t}}}function le(e,t){return e.substring(t.length+1,e.length)}function fe(e,t,n){return e.reduce(function(e,r){return e[r]=g$1({},n[r],{enabled:t}),e},n)}function de(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var pe={last:{},history:[]};function me(e,t){void 0===e&&(e=pe);var n=t.options,r=t.meta;if(t.type===z.track){var i=de(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 ge={actions:[]};function he(e,t){void 0===e&&(e=ge);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 ve=/#.*$/;function ye(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(t&&t[3]?t[3].split("?")[0].replace(ve,""):"")}var be,Ie=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(ve,"")}(s),f={title:n,url:l,path:ye(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),g$1({},f,e)},we={last:{},history:[]};function Ee(e,t){void 0===e&&(e=we);var n=t.options;if(t.type===z.page){var r=de(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}be={};var Pe={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.12.14"},timezone:void 0,locale:void 0,campaign:{},referrer:be};function Se(e,t){void 0===e&&(e=Pe);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({},Pe,e,{initialized:!0})}}var Ne=["plugins","reducers","storage"];function Ae(){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 _e(e){return function(){return P(P.apply(null,arguments),Ae())}}function Oe(e){return e?rn(e)?e:[e]:[]}function je(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");t.config||(t.config={});var n=t.EVENTS?Object.keys(t.EVENTS).map(function(e){return t.EVENTS[e]}):[];e.pluginEnabled[t.name]=!(!1===t.enabled||!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]=K,r.apply({instance:K},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 ce,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){le.dispatch({type:z.enablePlugin,plugins:Oe(e),_:{originalAction:z.enablePlugin}},n,[t]);})},disable:function(e,t){return new Promise(function(n){le.dispatch({type:z.disablePlugin,plugins:Oe(e),_:{originalAction:z.disablePlugin}},n,[t]);})}},f$1.methods),G=!1,K={identify:function(e,t,n,r){try{var i=q$1(e)?e:null,o=on(e)?e:t,u=n||{},s=K.user();f($(j),i);var l=i||o.userId||b(j,K,o);return Promise.resolve(new Promise(function(e){le.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){le.dispatch({type:z.trackStart,event:i,properties:a,options:o,userId:b(j,K,t),anonymousId:b(k$1,K,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){le.dispatch({type:z.pageStart,properties:Ie(r),options:i,userId:b(j,K,r),anonymousId:b(k$1,K,r)},a,[e,t,n]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===j||"id"===e)return b(j,K);if(e===k$1||"anonId"===e)return b(k$1,K);var t=K.getState("user");return e?n$2(t,e):t},reset:function(e){return new Promise(function(t){le.dispatch({type:z.resetStart},t,e);})},ready:function(e){return G&&e({plugins:F,instance:K}),K.on(z.ready,function(t){e(t),G=!0;})},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:K,plugins:I}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(n)||t({payload:r,instance:K,plugins:I}),e(r)}}};return V(r,xe),V(i,Te),function(){B(r,xe),B(i,Te);}}var a=e.match(n)?xe:Te,o=function(n){return function(n){return function(r){return r.type===e&&t({payload:r,instance:K,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=K.on(e,function(e){t({payload:e.payload,instance:K,plugins:I,abort:J}),n();});return n},getState:function(e){var t=le.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._||{})});le.dispatch(n);},enablePlugin:F.enable,disablePlugin:F.disable,plugins:F,storage:{getItem:m.getItem,setItem:function(e,t,n){le.dispatch({type:z.setItemStart,key:e,value:t,options:n});},removeItem:function(e,t){le.dispatch({type:z.removeItemStart,key:e,options:t});}},setAnonymousId:function(e,t){K.storage.setItem(N$1,e,t);},events:{core:x$1,plugins:A}},Q=f$1.middlewares.concat([function(e){return function(e){return function(t){return t.meta||(t.meta=je()),e(t)}}},L(xe),oe(K,M,{all:O,plugins:A}),ue(m),C$1(K),D(K),L(Te)]),Y={context:Se,user:U(m),page:Ee,track:me,plugins:se(M),queue:he},Z=P,ee=P;if($$1&&o.debug){var te=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;te&&(Z=te({trace:!0,traceLimit:25})),ee=function(){return 0===arguments.length?Ae():on(typeof arguments[0])?_e():_e().apply(null,arguments)};}var ne,re=function(e){return Object.keys(e).reduce(function(t,n){return Ne.includes(n)||(t[n]=e[n]),t},{})}(o),ie=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})),config:r},e},{}),ae={context:re,user:W,plugins:ie},le=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({},Y,u)),ae,ee(Z(S.apply(void 0,Q))));le.dispatch=(ne=le.dispatch,function(e,t,n){var r=g$1({},e,{meta:je(e.meta,t,Oe(n))});return ne.apply(null,[r])});var fe=Object.keys(I);le.dispatch({type:z.bootstrap,plugins:fe,config:re,params:X,user:W,initialUser:s$1,persistedUser:H});var de=fe.filter(function(e){return f$1.pluginEnabled[e]}),pe=fe.filter(function(e){return !f$1.pluginEnabled[e]});return le.dispatch({type:z.registerPlugins,plugins:fe,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:K,config:r,payload:e}),le.dispatch({type:z.registerPluginType(i),name:i,enabled:f$1.pluginEnabled[i],plugin:e}),f$1.pluginsArray.length===t+1&&le.dispatch({type:z.initializeStart,plugins:de,disabled:pe});}),K}var xe="before",Te="after";
180
+ // ../../node_modules/.pnpm/@analytics+global-storage-utils@0.1.7/node_modules/@analytics/global-storage-utils/dist/analytics-util-global-storage.module.js
181
+ var l = "global";
182
+ var o2 = j + "global" + j;
183
+ var n2 = typeof self === o && self.self === self && self || typeof global === o && global.global === global && global || void 0;
184
+ function a(t2) {
185
+ return n2[o2][t2];
186
+ }
187
+ function f(t2, e2) {
188
+ return n2[o2][t2] = e2;
189
+ }
190
+ function i(t2) {
191
+ delete n2[o2][t2];
192
+ }
193
+ function u(t2, e2, r3) {
194
+ var l3;
195
+ try {
196
+ if (b2(t2)) {
197
+ var o3 = window[t2];
198
+ l3 = o3[e2].bind(o3);
199
+ }
200
+ } catch (t3) {
201
+ }
202
+ return l3 || r3;
203
+ }
204
+ n2[o2] || (n2[o2] = {});
205
+ var c = {};
206
+ function b2(t2) {
207
+ if (typeof c[t2] !== e) return c[t2];
208
+ try {
209
+ var e2 = window[t2];
210
+ e2.setItem(e, e), e2.removeItem(e);
211
+ } catch (e3) {
212
+ return c[t2] = false;
213
+ }
214
+ return c[t2] = true;
215
+ }
10
216
 
11
- 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])}}
217
+ // ../../node_modules/.pnpm/@analytics+core@0.12.15_@types+dlv@1.1.4/node_modules/@analytics/core/dist/server/analytics-core.module.js
218
+ function g() {
219
+ return g = Object.assign || function(e2) {
220
+ for (var t2 = 1; t2 < arguments.length; t2++) {
221
+ var n4 = arguments[t2];
222
+ for (var r3 in n4) Object.prototype.hasOwnProperty.call(n4, r3) && (e2[r3] = n4[r3]);
223
+ }
224
+ return e2;
225
+ }, g.apply(this, arguments);
226
+ }
227
+ var h = "function";
228
+ var v = "undefined";
229
+ var y2 = "@@redux/" + Math.random().toString(36);
230
+ var b3 = /* @__PURE__ */ (function() {
231
+ return typeof Symbol === h && Symbol.observable || "@@observable";
232
+ })();
233
+ var I2 = " != " + h;
234
+ function w(e2, t2, n4) {
235
+ var r3;
236
+ if (typeof t2 === h && typeof n4 === v && (n4 = t2, t2 = void 0), typeof n4 !== v) {
237
+ if (typeof n4 !== h) throw new Error("enhancer" + I2);
238
+ return n4(w)(e2, t2);
239
+ }
240
+ if (typeof e2 !== h) throw new Error("reducer" + I2);
241
+ var i4 = e2, a4 = t2, o3 = [], u3 = o3, s2 = false;
242
+ function l3() {
243
+ u3 === o3 && (u3 = o3.slice());
244
+ }
245
+ function f2() {
246
+ return a4;
247
+ }
248
+ function d3(e3) {
249
+ if (typeof e3 !== h) throw new Error("Listener" + I2);
250
+ var t3 = true;
251
+ return l3(), u3.push(e3), function() {
252
+ if (t3) {
253
+ t3 = false, l3();
254
+ var n5 = u3.indexOf(e3);
255
+ u3.splice(n5, 1);
256
+ }
257
+ };
258
+ }
259
+ function p(e3) {
260
+ if (!on(e3)) throw new Error("Act != obj");
261
+ if (typeof e3.type === v) throw new Error("ActType " + v);
262
+ if (s2) throw new Error("Dispatch in reducer");
263
+ try {
264
+ s2 = true, a4 = i4(a4, e3);
265
+ } finally {
266
+ s2 = false;
267
+ }
268
+ for (var t3 = o3 = u3, n5 = 0; n5 < t3.length; n5++) (0, t3[n5])();
269
+ return e3;
270
+ }
271
+ return p({ type: "@@redux/INIT" }), (r3 = { dispatch: p, subscribe: d3, getState: f2, replaceReducer: function(e3) {
272
+ if (typeof e3 !== h) throw new Error("next reducer" + I2);
273
+ i4 = e3, p({ type: "@@redux/INIT" });
274
+ } })[b3] = function() {
275
+ var e3, t3 = d3;
276
+ return (e3 = { subscribe: function(e4) {
277
+ if ("object" != typeof e4) throw new TypeError("Observer != obj");
278
+ function n5() {
279
+ e4.next && e4.next(f2());
280
+ }
281
+ return n5(), { unsubscribe: t3(n5) };
282
+ } })[b3] = function() {
283
+ return this;
284
+ }, e3;
285
+ }, r3;
286
+ }
287
+ function E(e2, t2) {
288
+ var n4 = t2 && t2.type;
289
+ return "action " + (n4 && n4.toString() || "?") + "reducer " + e2 + " returns " + v;
290
+ }
291
+ function P2() {
292
+ var e2 = [].slice.call(arguments);
293
+ return 0 === e2.length ? function(e3) {
294
+ return e3;
295
+ } : 1 === e2.length ? e2[0] : e2.reduce(function(e3, t2) {
296
+ return function() {
297
+ return e3(t2.apply(void 0, [].slice.call(arguments)));
298
+ };
299
+ });
300
+ }
301
+ function S() {
302
+ var e2 = arguments;
303
+ return function(t2) {
304
+ return function(n4, r3, i4) {
305
+ var a4, o3 = t2(n4, r3, i4), u3 = o3.dispatch, c4 = { getState: o3.getState, dispatch: function(e3) {
306
+ return u3(e3);
307
+ } };
308
+ return a4 = [].slice.call(e2).map(function(e3) {
309
+ return e3(c4);
310
+ }), g({}, o3, { dispatch: u3 = P2.apply(void 0, a4)(o3.dispatch) });
311
+ };
312
+ };
313
+ }
314
+ var N = j + "anon_id";
315
+ var A = j + "user_id";
316
+ var _2 = j + "user_traits";
317
+ var j2 = "userId";
318
+ var k2 = "anonymousId";
319
+ var x = ["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"];
320
+ var T2 = ["name", "EVENTS", "config", "loaded"];
321
+ var z = x.reduce(function(e2, t2) {
322
+ return e2[t2] = t2, e2;
323
+ }, { registerPluginType: function(e2) {
324
+ return "registerPlugin:" + e2;
325
+ }, pluginReadyType: function(e2) {
326
+ return "ready:" + e2;
327
+ } });
328
+ var M2 = /^utm_/;
329
+ var q2 = /^an_prop_/;
330
+ var V2 = /^an_trait_/;
331
+ function C(e2) {
332
+ var t2 = e2.storage.setItem;
333
+ return function(n4) {
334
+ return function(r3) {
335
+ return function(i4) {
336
+ if (i4.type === z.bootstrap) {
337
+ var a4 = i4.params, o3 = i4.user, u3 = i4.persistedUser, c4 = i4.initialUser, s2 = u3.userId === o3.userId;
338
+ u3.anonymousId !== o3.anonymousId && t2(N, o3.anonymousId), s2 || t2(A, o3.userId), c4.traits && t2(_2, g({}, s2 && u3.traits ? u3.traits : {}, c4.traits));
339
+ var l3 = Object.keys(i4.params);
340
+ if (l3.length) {
341
+ var f2 = a4.an_uid, d3 = a4.an_event, p = l3.reduce(function(e3, t3) {
342
+ if (t3.match(M2) || t3.match(/^(d|g)clid/)) {
343
+ var n5 = t3.replace(M2, "");
344
+ e3.campaign["campaign" === n5 ? "name" : n5] = a4[t3];
345
+ }
346
+ return t3.match(q2) && (e3.props[t3.replace(q2, "")] = a4[t3]), t3.match(V2) && (e3.traits[t3.replace(V2, "")] = a4[t3]), e3;
347
+ }, { campaign: {}, props: {}, traits: {} });
348
+ n4.dispatch(g({ type: z.params, raw: a4 }, p, f2 ? { userId: f2 } : {})), f2 && setTimeout(function() {
349
+ return e2.identify(f2, p.traits);
350
+ }, 0), d3 && setTimeout(function() {
351
+ return e2.track(d3, p.props);
352
+ }, 0), Object.keys(p.campaign).length && n4.dispatch({ type: z.campaign, campaign: p.campaign });
353
+ }
354
+ }
355
+ return r3(i4);
356
+ };
357
+ };
358
+ };
359
+ }
360
+ function U2(e2) {
361
+ return function(t2, n4) {
362
+ if (void 0 === t2 && (t2 = {}), void 0 === n4 && (n4 = {}), n4.type === z.setItemEnd) {
363
+ if (n4.key === N) return g({}, t2, { anonymousId: n4.value });
364
+ if (n4.key === A) return g({}, t2, { userId: n4.value });
365
+ }
366
+ switch (n4.type) {
367
+ case z.identify:
368
+ return Object.assign({}, t2, { userId: n4.userId, traits: g({}, t2.traits, n4.traits) });
369
+ case z.reset:
370
+ return [A, N, _2].forEach(function(t3) {
371
+ e2.removeItem(t3);
372
+ }), Object.assign({}, t2, { userId: null, anonymousId: null, traits: {} });
373
+ default:
374
+ return t2;
375
+ }
376
+ };
377
+ }
378
+ function R2(e2) {
379
+ return { userId: e2.getItem(A), anonymousId: e2.getItem(N), traits: e2.getItem(_2) };
380
+ }
381
+ var $2 = function(e2) {
382
+ return j + "TEMP" + j + e2;
383
+ };
384
+ function D(t2) {
385
+ var n4 = t2.storage, r3 = n4.setItem, a4 = n4.removeItem, o3 = n4.getItem;
386
+ return function(t3) {
387
+ return function(n5) {
388
+ return function(u3) {
389
+ var c4 = u3.userId, s2 = u3.traits, l3 = u3.options;
390
+ if (u3.type === z.reset && ([A, _2, N].forEach(function(e2) {
391
+ a4(e2);
392
+ }), [j2, k2, "traits"].forEach(function(e2) {
393
+ i($2(e2));
394
+ })), u3.type === z.identify) {
395
+ o3(N) || r3(N, y());
396
+ var f2 = o3(A), d3 = o3(_2) || {};
397
+ f2 && f2 !== c4 && t3.dispatch({ type: z.userIdChanged, old: { userId: f2, traits: d3 }, new: { userId: c4, traits: s2 }, options: l3 }), c4 && r3(A, c4), s2 && r3(_2, g({}, d3, s2));
398
+ }
399
+ return n5(u3);
400
+ };
401
+ };
402
+ };
403
+ }
404
+ var B2 = {};
405
+ function L(e2, t2) {
406
+ B2[e2] && W(B2[e2]) && (B2[e2](t2), delete B2[e2]);
407
+ }
408
+ function J2(e2, t2, n4) {
409
+ return new Promise(function(r3, i4) {
410
+ return t2() ? r3(e2) : n4 < 1 ? i4(g({}, e2, { queue: true })) : new Promise(function(e3) {
411
+ return setTimeout(e3, 10);
412
+ }).then(function(a4) {
413
+ return J2(e2, t2, n4 - 10).then(r3, i4);
414
+ });
415
+ });
416
+ }
417
+ function X2(e2) {
418
+ return { abort: e2 };
419
+ }
420
+ var H2 = function(e2) {
421
+ var t2 = e2.data, n4 = e2.action, r3 = e2.instance, i4 = e2.state, a4 = e2.allPlugins, o3 = e2.allMatches, u3 = e2.store, s2 = e2.EVENTS;
422
+ try {
423
+ var f2 = i4.plugins, d3 = i4.context, p = n4.type, m4 = p.match(W2), h3 = t2.exact.map(function(e3) {
424
+ return e3.pluginName;
425
+ });
426
+ m4 && (h3 = o3.during.map(function(e3) {
427
+ return e3.pluginName;
428
+ }));
429
+ var v2 = /* @__PURE__ */ (function(e3, t3) {
430
+ return function(n5, r4, i5) {
431
+ var a5 = r4.config, o4 = r4.name, u4 = o4 + "." + n5.type;
432
+ i5 && (u4 = i5.event);
433
+ var c4 = n5.type.match(W2) ? /* @__PURE__ */ (function(e4, t4, n6, r5, i6) {
434
+ return function(a6, o5) {
435
+ var u5 = r5 ? r5.name : e4, c5 = o5 && ne(o5) ? o5 : n6;
436
+ if (r5 && (!(c5 = o5 && ne(o5) ? o5 : [e4]).includes(e4) || 1 !== c5.length)) throw new Error("Method " + t4 + " can only abort " + e4 + " plugin. " + JSON.stringify(c5) + " input valid");
437
+ return g({}, i6, { abort: { reason: a6, plugins: c5, caller: t4, _: u5 } });
438
+ };
439
+ })(o4, u4, t3, i5, n5) : /* @__PURE__ */ (function(e4, t4) {
440
+ return function() {
441
+ throw new Error(e4.type + " action not cancellable. Remove abort in " + t4);
442
+ };
443
+ })(n5, u4);
444
+ return { payload: ae(n5), instance: e3, config: a5 || {}, abort: c4 };
445
+ };
446
+ })(r3, h3), y3 = t2.exact.reduce(function(e3, t3) {
447
+ var n5 = t3.pluginName, r4 = t3.methodName, i5 = false;
448
+ return r4.match(/^initialize/) || r4.match(/^reset/) || (i5 = !f2[n5].loaded), d3.offline && r4.match(/^(page|track|identify)/) && (i5 = true), e3["" + n5] = i5, e3;
449
+ }, {});
450
+ return Promise.resolve(t2.exact.reduce(function(e3, i5, o4) {
451
+ try {
452
+ var u4 = i5.pluginName;
453
+ return Promise.resolve(e3).then(function(e4) {
454
+ function i6() {
455
+ return Promise.resolve(e4);
456
+ }
457
+ var o5 = (function() {
458
+ if (t2.namespaced && t2.namespaced[u4]) return Promise.resolve(t2.namespaced[u4].reduce(function(e5, t3, n5) {
459
+ try {
460
+ return Promise.resolve(e5).then(function(e6) {
461
+ return t3.method && W(t3.method) ? ((function(e7, t4) {
462
+ var n7 = ie(e7);
463
+ if (n7 && n7.name === t4) {
464
+ var r4 = ie(n7.method);
465
+ throw new Error([t4 + " plugin is calling method " + e7, "Plugins cant call self", "Use " + n7.method + " " + (r4 ? "or " + r4.method : "") + " in " + t4 + " plugin insteadof " + e7].join("\n"));
466
+ }
467
+ })(t3.methodName, t3.pluginName), Promise.resolve(t3.method({ payload: e6, instance: r3, abort: (n6 = e6, i7 = u4, o6 = t3.pluginName, function(e7, t4) {
468
+ return g({}, n6, { abort: { reason: e7, plugins: t4 || [i7], caller: p, from: o6 || i7 } });
469
+ }), config: Q2(t3.pluginName, f2, a4), plugins: f2 })).then(function(t4) {
470
+ var n7 = on(t4) ? t4 : {};
471
+ return Promise.resolve(g({}, e6, n7));
472
+ })) : e6;
473
+ var n6, i7, o6;
474
+ });
475
+ } catch (e6) {
476
+ return Promise.reject(e6);
477
+ }
478
+ }, Promise.resolve(n4))).then(function(t3) {
479
+ e4[u4] = t3;
480
+ });
481
+ e4[u4] = n4;
482
+ })();
483
+ return o5 && o5.then ? o5.then(i6) : i6();
484
+ });
485
+ } catch (e4) {
486
+ return Promise.reject(e4);
487
+ }
488
+ }, Promise.resolve({}))).then(function(e3) {
489
+ return Promise.resolve(t2.exact.reduce(function(n5, i5, o4) {
490
+ try {
491
+ var s3 = t2.exact.length === o4 + 1, l3 = i5.pluginName, d4 = a4[l3];
492
+ return Promise.resolve(n5).then(function(t3) {
493
+ var n6 = e3[l3] ? e3[l3] : {};
494
+ if (m4 && (n6 = t3), ee(n6, l3)) return K({ data: n6, method: p, instance: r3, pluginName: l3, store: u3 }), Promise.resolve(t3);
495
+ if (ee(t3, l3)) return s3 && K({ data: t3, method: p, instance: r3, store: u3 }), Promise.resolve(t3);
496
+ if (y3.hasOwnProperty(l3) && true === y3[l3]) return u3.dispatch({ type: "queue", plugin: l3, payload: n6, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(t3);
497
+ var i6 = v2(e3[l3], a4[l3]);
498
+ return Promise.resolve(d4[p]({ abort: i6.abort, payload: n6, instance: r3, config: Q2(l3, f2, a4), plugins: f2 })).then(function(i7) {
499
+ var a5 = on(i7) ? i7 : {}, o5 = g({}, t3, a5), s4 = e3[l3];
500
+ if (ee(s4, l3)) K({ data: s4, method: p, instance: r3, pluginName: l3, store: u3 });
501
+ else {
502
+ var f3 = p + ":" + l3;
503
+ (f3.match(/:/g) || []).length < 2 && !p.match(F2) && !p.match(G2) && r3.dispatch(g({}, m4 ? o5 : n6, { type: f3, _: { called: f3, from: "submethod" } }));
504
+ }
505
+ return Promise.resolve(o5);
506
+ });
507
+ });
508
+ } catch (e4) {
509
+ return Promise.reject(e4);
510
+ }
511
+ }, Promise.resolve(n4))).then(function(e4) {
512
+ if (!(p.match(W2) || p.match(/^registerPlugin/) || p.match(G2) || p.match(F2) || p.match(/^params/) || p.match(/^userIdChanged/))) {
513
+ if (s2.plugins.includes(p), e4._ && e4._.originalAction === p) return e4;
514
+ var n5 = g({}, e4, { _: { originalAction: e4.type, called: e4.type, from: "engineEnd" } });
515
+ te(e4, t2.exact.length) && !p.match(/End$/) && (n5 = g({}, n5, { type: e4.type + "Aborted" })), u3.dispatch(n5);
516
+ }
517
+ return e4;
518
+ });
519
+ });
520
+ } catch (e3) {
521
+ return Promise.reject(e3);
522
+ }
523
+ };
524
+ var W2 = /Start$/;
525
+ var F2 = /^bootstrap/;
526
+ var G2 = /^ready/;
527
+ function K(e2) {
528
+ var t2 = e2.pluginName, n4 = e2.method + "Aborted" + (t2 ? ":" + t2 : "");
529
+ e2.store.dispatch(g({}, e2.data, { type: n4, _: { called: n4, from: "abort" } }));
530
+ }
531
+ function Q2(e2, t2, n4) {
532
+ var r3 = t2[e2] || n4[e2];
533
+ return r3 && r3.config ? r3.config : {};
534
+ }
535
+ function Y2(e2, t2) {
536
+ return t2.reduce(function(t3, n4) {
537
+ return n4[e2] ? t3.concat({ methodName: e2, pluginName: n4.name, method: n4[e2] }) : t3;
538
+ }, []);
539
+ }
540
+ function Z(e2, t2) {
541
+ var n4 = e2.replace(W2, ""), r3 = t2 ? ":" + t2 : "";
542
+ return ["" + e2 + r3, "" + n4 + r3, n4 + "End" + r3];
543
+ }
544
+ function ee(e2, t2) {
545
+ var n4 = e2.abort;
546
+ return !!n4 && (true === n4 || re(n4, t2) || n4 && re(n4.plugins, t2));
547
+ }
548
+ function te(e2, t2) {
549
+ var n4 = e2.abort;
550
+ if (!n4) return false;
551
+ if (true === n4 || q(n4)) return true;
552
+ var r3 = n4.plugins;
553
+ return ne(n4) && n4.length === t2 || ne(r3) && r3.length === t2;
554
+ }
555
+ function ne(e2) {
556
+ return Array.isArray(e2);
557
+ }
558
+ function re(e2, t2) {
559
+ return !(!e2 || !ne(e2)) && e2.includes(t2);
560
+ }
561
+ function ie(e2) {
562
+ var t2 = e2.match(/(.*):(.*)/);
563
+ return !!t2 && { method: t2[1], name: t2[2] };
564
+ }
565
+ function ae(e2) {
566
+ return Object.keys(e2).reduce(function(t2, n4) {
567
+ return "type" === n4 || (t2[n4] = on(e2[n4]) ? Object.assign({}, e2[n4]) : e2[n4]), t2;
568
+ }, {});
569
+ }
570
+ function oe(e2, t2, n4) {
571
+ var r3 = {};
572
+ return function(i4) {
573
+ return function(a4) {
574
+ return function(o3) {
575
+ try {
576
+ var u3, s2 = function(e3) {
577
+ return u3 ? e3 : a4(m4);
578
+ }, d3 = o3.type, p = o3.plugins, m4 = o3;
579
+ if (o3.abort) return Promise.resolve(a4(o3));
580
+ if (d3 === z.enablePlugin && i4.dispatch({ type: z.initializeStart, plugins: p, disabled: [], fromEnable: true, meta: o3.meta }), d3 === z.disablePlugin && setTimeout(function() {
581
+ return L(o3.meta.rid, { payload: o3 });
582
+ }, 0), d3 === z.initializeEnd) {
583
+ var h3 = t2(), v2 = Object.keys(h3), y3 = v2.filter(function(e3) {
584
+ return p.includes(e3);
585
+ }).map(function(e3) {
586
+ return h3[e3];
587
+ }), b5 = [], I4 = [], w2 = o3.disabled, E3 = y3.map(function(e3) {
588
+ var t3 = e3.loaded, n5 = e3.name, a5 = e3.config;
589
+ return J2(e3, function() {
590
+ return t3({ config: a5 });
591
+ }, 1e4).then(function(t4) {
592
+ return r3[n5] || (i4.dispatch({ type: z.pluginReadyType(n5), name: n5, events: Object.keys(e3).filter(function(e4) {
593
+ return !T2.includes(e4);
594
+ }) }), r3[n5] = true), b5 = b5.concat(n5), e3;
595
+ }).catch(function(e4) {
596
+ if (e4 instanceof Error) throw new Error(e4);
597
+ return I4 = I4.concat(e4.name), e4;
598
+ });
599
+ });
600
+ Promise.all(E3).then(function(e3) {
601
+ var t3 = { plugins: b5, failed: I4, disabled: w2 };
602
+ setTimeout(function() {
603
+ v2.length === E3.length + w2.length && i4.dispatch(g({}, { type: z.ready }, t3));
604
+ }, 0);
605
+ });
606
+ }
607
+ var P3 = (function() {
608
+ if (d3 !== z.bootstrap) return /^ready:([^:]*)$/.test(d3) && setTimeout(function() {
609
+ return (function(e3, t3, n5) {
610
+ var r4 = {}, i5 = t3(), a5 = e3.getState(), o4 = a5.plugins, u4 = a5.queue, s3 = a5.user;
611
+ if (!a5.context.offline && u4 && u4.actions && u4.actions.length) {
612
+ var f2 = u4.actions.reduce(function(e4, t4, n6) {
613
+ return o4[t4.plugin].loaded ? (e4.process.push(t4), e4.processIndex.push(n6)) : (e4.requeue.push(t4), e4.requeueIndex.push(n6)), e4;
614
+ }, { processIndex: [], process: [], requeue: [], requeueIndex: [] });
615
+ if (f2.processIndex && f2.processIndex.length) {
616
+ f2.processIndex.forEach(function(t4) {
617
+ var a6 = u4.actions[t4], f3 = a6.plugin, d5 = a6.payload.type, p2 = i5[f3][d5];
618
+ if (p2 && W(p2)) {
619
+ var m5, h4 = (function(e4, t5) {
620
+ return void 0 === e4 && (e4 = {}), void 0 === t5 && (t5 = {}), [j2, k2].reduce(function(n6, r5) {
621
+ return e4.hasOwnProperty(r5) && t5[r5] && t5[r5] !== e4[r5] && (n6[r5] = t5[r5]), n6;
622
+ }, e4);
623
+ })(a6.payload, s3), v3 = r4[h4.meta.rid];
624
+ if (!v3 && (m5 = p2({ payload: h4, config: o4[f3].config, instance: n5, abort: X2 })) && on(m5) && m5.abort) return void (r4[h4.meta.rid] = true);
625
+ if (!v3) {
626
+ var y4 = d5 + ":" + f3;
627
+ e3.dispatch(g({}, h4, { type: y4, _: { called: y4, from: "queueDrain" } }));
628
+ }
629
+ }
630
+ });
631
+ var d4 = u4.actions.filter(function(e4, t4) {
632
+ return !~f2.processIndex.indexOf(t4);
633
+ });
634
+ u4.actions = d4;
635
+ }
636
+ }
637
+ })(i4, t2, e2);
638
+ }, 0), Promise.resolve((function(e3, t3, n5, r4, i5) {
639
+ try {
640
+ var a5 = W(t3) ? t3() : t3, o4 = e3.type, u4 = o4.replace(W2, "");
641
+ if (e3._ && e3._.called) return Promise.resolve(e3);
642
+ var c4 = n5.getState(), s3 = (m5 = a5, void 0 === (h4 = c4.plugins) && (h4 = {}), void 0 === (v3 = e3.options) && (v3 = {}), Object.keys(m5).filter(function(e4) {
643
+ var t4 = v3.plugins || {};
644
+ return Q(t4[e4]) ? t4[e4] : false !== t4.all && (!h4[e4] || false !== h4[e4].enabled);
645
+ }).map(function(e4) {
646
+ return m5[e4];
647
+ }));
648
+ o4 === z.initializeStart && e3.fromEnable && (s3 = Object.keys(c4.plugins).filter(function(t4) {
649
+ var n6 = c4.plugins[t4];
650
+ return e3.plugins.includes(t4) && !n6.initialized;
651
+ }).map(function(e4) {
652
+ return a5[e4];
653
+ }));
654
+ var d4 = s3.map(function(e4) {
655
+ return e4.name;
656
+ }), p2 = (function(e4, t4, n6) {
657
+ var r5 = Z(e4).map(function(e5) {
658
+ return Y2(e5, t4);
659
+ });
660
+ return t4.reduce(function(n7, r6) {
661
+ var i6 = r6.name, a6 = Z(e4, i6).map(function(e5) {
662
+ return Y2(e5, t4);
663
+ }), o5 = a6[0], u5 = a6[1], c5 = a6[2];
664
+ return o5.length && (n7.beforeNS[i6] = o5), u5.length && (n7.duringNS[i6] = u5), c5.length && (n7.afterNS[i6] = c5), n7;
665
+ }, { before: r5[0], beforeNS: {}, during: r5[1], duringNS: {}, after: r5[2], afterNS: {} });
666
+ })(o4, s3);
667
+ return Promise.resolve(H2({ action: e3, data: { exact: p2.before, namespaced: p2.beforeNS }, state: c4, allPlugins: a5, allMatches: p2, instance: n5, store: r4, EVENTS: i5 })).then(function(e4) {
668
+ function t4() {
669
+ var t5 = (function() {
670
+ if (o4.match(W2)) return Promise.resolve(H2({ action: g({}, s4, { type: u4 + "End" }), data: { exact: p2.after, namespaced: p2.afterNS }, state: c4, allPlugins: a5, allMatches: p2, instance: n5, store: r4, EVENTS: i5 })).then(function(e5) {
671
+ e5.meta && e5.meta.hasCallback && L(e5.meta.rid, { payload: e5 });
672
+ });
673
+ })();
674
+ return t5 && t5.then ? t5.then(function() {
675
+ return e4;
676
+ }) : e4;
677
+ }
678
+ if (te(e4, d4.length)) return e4;
679
+ var s4, l3 = (function() {
680
+ if (o4 !== u4) return Promise.resolve(H2({ action: g({}, e4, { type: u4 }), data: { exact: p2.during, namespaced: p2.duringNS }, state: c4, allPlugins: a5, allMatches: p2, instance: n5, store: r4, EVENTS: i5 })).then(function(e5) {
681
+ s4 = e5;
682
+ });
683
+ s4 = e4;
684
+ })();
685
+ return l3 && l3.then ? l3.then(t4) : t4();
686
+ });
687
+ } catch (e4) {
688
+ return Promise.reject(e4);
689
+ }
690
+ var m5, h4, v3;
691
+ })(o3, t2, e2, i4, n4)).then(function(e3) {
692
+ return u3 = 1, a4(e3);
693
+ });
694
+ })();
695
+ return Promise.resolve(P3 && P3.then ? P3.then(s2) : s2(P3));
696
+ } catch (e3) {
697
+ return Promise.reject(e3);
698
+ }
699
+ };
700
+ };
701
+ };
702
+ }
703
+ function ue(e2) {
704
+ return function(t2) {
705
+ return function(t3) {
706
+ return function(n4) {
707
+ var r3 = n4.type, i4 = n4.key, a4 = n4.value, o3 = n4.options;
708
+ if (r3 === z.setItem || r3 === z.removeItem) {
709
+ if (n4.abort) return t3(n4);
710
+ r3 === z.setItem ? e2.setItem(i4, a4, o3) : e2.removeItem(i4, o3);
711
+ }
712
+ return t3(n4);
713
+ };
714
+ };
715
+ };
716
+ }
717
+ var ce = function() {
718
+ var e2 = this;
719
+ this.before = [], this.after = [], this.addMiddleware = function(t2, n4) {
720
+ e2[n4] = e2[n4].concat(t2);
721
+ }, this.removeMiddleware = function(t2, n4) {
722
+ var r3 = e2[n4].findIndex(function(e3) {
723
+ return e3 === t2;
724
+ });
725
+ -1 !== r3 && (e2[n4] = [].concat(e2[n4].slice(0, r3), e2[n4].slice(r3 + 1)));
726
+ }, this.dynamicMiddlewares = function(t2) {
727
+ return function(n4) {
728
+ return function(r3) {
729
+ return function(i4) {
730
+ var a4 = { getState: n4.getState, dispatch: function(e3) {
731
+ return n4.dispatch(e3);
732
+ } }, o3 = e2[t2].map(function(e3) {
733
+ return e3(a4);
734
+ });
735
+ return P2.apply(void 0, o3)(r3)(i4);
736
+ };
737
+ };
738
+ };
739
+ };
740
+ };
741
+ function se(e2) {
742
+ return function(t2, n4) {
743
+ void 0 === t2 && (t2 = {});
744
+ var r3 = {};
745
+ if ("initialize:aborted" === n4.type) return t2;
746
+ if (/^registerPlugin:([^:]*)$/.test(n4.type)) {
747
+ var i4 = le(n4.type, "registerPlugin"), a4 = e2()[i4];
748
+ if (!a4 || !i4) return t2;
749
+ var o3 = n4.enabled, u3 = a4.config;
750
+ return r3[i4] = { enabled: o3, initialized: !!o3 && Boolean(!a4.initialize), loaded: !!o3 && Boolean(a4.loaded({ config: u3 })), config: u3 }, g({}, t2, r3);
751
+ }
752
+ if (/^initialize:([^:]*)$/.test(n4.type)) {
753
+ var c4 = le(n4.type, z.initialize), s2 = e2()[c4];
754
+ return s2 && c4 ? (r3[c4] = g({}, t2[c4], { initialized: true, loaded: Boolean(s2.loaded({ config: s2.config })) }), g({}, t2, r3)) : t2;
755
+ }
756
+ if (/^ready:([^:]*)$/.test(n4.type)) return r3[n4.name] = g({}, t2[n4.name], { loaded: true }), g({}, t2, r3);
757
+ switch (n4.type) {
758
+ case z.disablePlugin:
759
+ return g({}, t2, fe(n4.plugins, false, t2));
760
+ case z.enablePlugin:
761
+ return g({}, t2, fe(n4.plugins, true, t2));
762
+ default:
763
+ return t2;
764
+ }
765
+ };
766
+ }
767
+ function le(e2, t2) {
768
+ return e2.substring(t2.length + 1, e2.length);
769
+ }
770
+ function fe(e2, t2, n4) {
771
+ return e2.reduce(function(e3, r3) {
772
+ return e3[r3] = g({}, n4[r3], { enabled: t2 }), e3;
773
+ }, n4);
774
+ }
775
+ function de(e2) {
776
+ try {
777
+ return JSON.parse(JSON.stringify(e2));
778
+ } catch (e3) {
779
+ }
780
+ return e2;
781
+ }
782
+ var pe = { last: {}, history: [] };
783
+ function me(e2, t2) {
784
+ void 0 === e2 && (e2 = pe);
785
+ var n4 = t2.options, r3 = t2.meta;
786
+ if (t2.type === z.track) {
787
+ var i4 = de(g({ event: t2.event, properties: t2.properties }, Object.keys(n4).length && { options: n4 }, { meta: r3 }));
788
+ return g({}, e2, { last: i4, history: e2.history.concat(i4) });
789
+ }
790
+ return e2;
791
+ }
792
+ var ge = { actions: [] };
793
+ function he(e2, t2) {
794
+ void 0 === e2 && (e2 = ge);
795
+ var n4 = t2.payload;
796
+ switch (t2.type) {
797
+ case "queue":
798
+ var r3;
799
+ return r3 = n4 && n4.type && n4.type === z.identify ? [t2].concat(e2.actions) : e2.actions.concat(t2), g({}, e2, { actions: r3 });
800
+ case "dequeue":
801
+ return [];
802
+ default:
803
+ return e2;
804
+ }
805
+ }
806
+ var ve = /#.*$/;
807
+ function ye(e2) {
808
+ var t2 = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e2);
809
+ return "/" + (t2 && t2[3] ? t2[3].split("?")[0].replace(ve, "") : "");
810
+ }
811
+ var be;
812
+ var Ie = function(e2) {
813
+ if (void 0 === e2 && (e2 = {}), !$) return e2;
814
+ var t2 = document, n4 = t2.title, r3 = t2.referrer, i4 = window, a4 = i4.location, o3 = i4.innerWidth, u3 = i4.innerHeight, c4 = a4.hash, s2 = a4.search, l3 = (function(e3) {
815
+ var t3 = (function() {
816
+ if ($) {
817
+ for (var e4, t4 = document.getElementsByTagName("link"), n5 = 0; e4 = t4[n5]; n5++) if ("canonical" === e4.getAttribute("rel")) return e4.getAttribute("href");
818
+ }
819
+ })();
820
+ return t3 ? t3.match(/\?/) ? t3 : t3 + e3 : window.location.href.replace(ve, "");
821
+ })(s2), f2 = { title: n4, url: l3, path: ye(l3), hash: c4, search: s2, width: o3, height: u3 };
822
+ return r3 && "" !== r3 && (f2.referrer = r3), g({}, f2, e2);
823
+ };
824
+ var we = { last: {}, history: [] };
825
+ function Ee(e2, t2) {
826
+ void 0 === e2 && (e2 = we);
827
+ var n4 = t2.options;
828
+ if (t2.type === z.page) {
829
+ var r3 = de(g({ properties: t2.properties, meta: t2.meta }, Object.keys(n4).length && { options: n4 }));
830
+ return g({}, e2, { last: r3, history: e2.history.concat(r3) });
831
+ }
832
+ return e2;
833
+ }
834
+ be = {};
835
+ var Pe = { initialized: false, sessionId: y(), app: null, version: null, debug: false, offline: !!$ && !navigator.onLine, os: { name: "na" }, userAgent: $ ? navigator.userAgent : "node", library: { name: "analytics", version: "0.12.14" }, timezone: void 0, locale: void 0, campaign: {}, referrer: be };
836
+ function Se(e2, t2) {
837
+ void 0 === e2 && (e2 = Pe);
838
+ var n4 = e2.initialized, r3 = t2.campaign;
839
+ switch (t2.type) {
840
+ case z.campaign:
841
+ return g({}, e2, { campaign: r3 });
842
+ case z.offline:
843
+ return g({}, e2, { offline: true });
844
+ case z.online:
845
+ return g({}, e2, { offline: false });
846
+ default:
847
+ return n4 ? e2 : g({}, Pe, e2, { initialized: true });
848
+ }
849
+ }
850
+ var Ne = ["plugins", "reducers", "storage"];
851
+ function Ae() {
852
+ return f("analytics", []), function(e2) {
853
+ return function(t2, n4, r3) {
854
+ var i4 = e2(t2, n4, r3), a4 = i4.dispatch;
855
+ return Object.assign(i4, { dispatch: function(e3) {
856
+ return n2[o2].analytics.push(e3.action || e3), a4(e3);
857
+ } });
858
+ };
859
+ };
860
+ }
861
+ function _e(e2) {
862
+ return function() {
863
+ return P2(P2.apply(null, arguments), Ae());
864
+ };
865
+ }
866
+ function Oe(e2) {
867
+ return e2 ? rn(e2) ? e2 : [e2] : [];
868
+ }
869
+ function je(t2, n4, r3) {
870
+ void 0 === t2 && (t2 = {});
871
+ var i4, a4, o3 = y();
872
+ return n4 && (B2[o3] = (i4 = n4, a4 = (function(e2) {
873
+ for (var t3, n5 = e2 || Array.prototype.slice.call(arguments), r4 = 0; r4 < n5.length; r4++) if (W(n5[r4])) {
874
+ t3 = n5[r4];
875
+ break;
876
+ }
877
+ return t3;
878
+ })(r3), function(e2) {
879
+ a4 && a4(e2), i4(e2);
880
+ })), g({}, t2, { rid: o3, ts: (/* @__PURE__ */ new Date()).getTime() }, n4 ? { hasCallback: true } : {});
881
+ }
882
+ function ke(o3) {
883
+ void 0 === o3 && (o3 = {});
884
+ var u3 = o3.reducers || {}, s2 = o3.initialUser || {}, f2 = (o3.plugins || []).reduce(function(e2, t2) {
885
+ if (W(t2)) return e2.middlewares = e2.middlewares.concat(t2), e2;
886
+ if (t2.NAMESPACE && (t2.name = t2.NAMESPACE), !t2.name) throw new Error("https://lytics.dev/errors/1");
887
+ t2.config || (t2.config = {});
888
+ var n4 = t2.EVENTS ? Object.keys(t2.EVENTS).map(function(e3) {
889
+ return t2.EVENTS[e3];
890
+ }) : [];
891
+ e2.pluginEnabled[t2.name] = !(false === t2.enabled || false === t2.config.enabled), delete t2.enabled, t2.methods && (e2.methods[t2.name] = Object.keys(t2.methods).reduce(function(e3, n5) {
892
+ var r4;
893
+ return e3[n5] = (r4 = t2.methods[n5], function() {
894
+ for (var e4 = Array.prototype.slice.call(arguments), t3 = new Array(r4.length), n6 = 0; n6 < e4.length; n6++) t3[n6] = e4[n6];
895
+ return t3[t3.length] = K2, r4.apply({ instance: K2 }, t3);
896
+ }), e3;
897
+ }, {}), delete t2.methods);
898
+ var r3 = Object.keys(t2).concat(n4), i4 = new Set(e2.events.concat(r3));
899
+ if (e2.events = Array.from(i4), e2.pluginsArray = e2.pluginsArray.concat(t2), e2.plugins[t2.name]) throw new Error(t2.name + "AlreadyLoaded");
900
+ return e2.plugins[t2.name] = t2, e2.plugins[t2.name].loaded || (e2.plugins[t2.name].loaded = function() {
901
+ return true;
902
+ }), e2;
903
+ }, { plugins: {}, pluginEnabled: {}, methods: {}, pluginsArray: [], middlewares: [], events: [] }), m4 = o3.storage ? o3.storage : { getItem: a, setItem: f, removeItem: i }, b5 = /* @__PURE__ */ (function(e2) {
904
+ return function(t2, n4, i4) {
905
+ return n4.getState("user")[t2] || (i4 && on(i4) && i4[t2] ? i4[t2] : R2(e2)[t2] || a($2(t2)) || null);
906
+ };
907
+ })(m4), I4 = f2.plugins, A3 = f2.events.filter(function(e2) {
908
+ return !T2.includes(e2);
909
+ }).sort(), _3 = new Set(A3.concat(x).filter(function(e2) {
910
+ return !T2.includes(e2);
911
+ })), O2 = Array.from(_3).sort(), M3 = function() {
912
+ return I4;
913
+ }, q3 = new ce(), V3 = q3.addMiddleware, B3 = q3.removeMiddleware, L3 = q3.dynamicMiddlewares, J4 = function() {
914
+ throw new Error("Abort disabled inListener");
915
+ }, X3 = s(), H3 = R2(m4), W3 = g({}, H3, s2, X3.an_uid ? { userId: X3.an_uid } : {}, X3.an_aid ? { anonymousId: X3.an_aid } : {});
916
+ W3.anonymousId || (W3.anonymousId = y());
917
+ var F4 = g({ enable: function(e2, t2) {
918
+ return new Promise(function(n4) {
919
+ le2.dispatch({ type: z.enablePlugin, plugins: Oe(e2), _: { originalAction: z.enablePlugin } }, n4, [t2]);
920
+ });
921
+ }, disable: function(e2, t2) {
922
+ return new Promise(function(n4) {
923
+ le2.dispatch({ type: z.disablePlugin, plugins: Oe(e2), _: { originalAction: z.disablePlugin } }, n4, [t2]);
924
+ });
925
+ } }, f2.methods), G4 = false, K2 = { identify: function(e2, t2, n4, r3) {
926
+ try {
927
+ var i4 = q(e2) ? e2 : null, o4 = on(e2) ? e2 : t2, u4 = n4 || {}, s3 = K2.user();
928
+ f($2(j2), i4);
929
+ var l3 = i4 || o4.userId || b5(j2, K2, o4);
930
+ return Promise.resolve(new Promise(function(e3) {
931
+ le2.dispatch(g({ type: z.identifyStart, userId: l3, traits: o4 || {}, options: u4, anonymousId: s3.anonymousId }, s3.id && s3.id !== i4 && { previousId: s3.id }), e3, [t2, n4, r3]);
932
+ }));
933
+ } catch (e3) {
934
+ return Promise.reject(e3);
935
+ }
936
+ }, track: function(e2, t2, n4, r3) {
937
+ try {
938
+ var i4 = on(e2) ? e2.event : e2;
939
+ if (!i4 || !q(i4)) throw new Error("EventMissing");
940
+ var a4 = on(e2) ? e2 : t2 || {}, o4 = on(n4) ? n4 : {};
941
+ return Promise.resolve(new Promise(function(e3) {
942
+ le2.dispatch({ type: z.trackStart, event: i4, properties: a4, options: o4, userId: b5(j2, K2, t2), anonymousId: b5(k2, K2, t2) }, e3, [t2, n4, r3]);
943
+ }));
944
+ } catch (e3) {
945
+ return Promise.reject(e3);
946
+ }
947
+ }, page: function(e2, t2, n4) {
948
+ try {
949
+ var r3 = on(e2) ? e2 : {}, i4 = on(t2) ? t2 : {};
950
+ return Promise.resolve(new Promise(function(a4) {
951
+ le2.dispatch({ type: z.pageStart, properties: Ie(r3), options: i4, userId: b5(j2, K2, r3), anonymousId: b5(k2, K2, r3) }, a4, [e2, t2, n4]);
952
+ }));
953
+ } catch (e3) {
954
+ return Promise.reject(e3);
955
+ }
956
+ }, user: function(e2) {
957
+ if (e2 === j2 || "id" === e2) return b5(j2, K2);
958
+ if (e2 === k2 || "anonId" === e2) return b5(k2, K2);
959
+ var t2 = K2.getState("user");
960
+ return e2 ? dlv_es_default(t2, e2) : t2;
961
+ }, reset: function(e2) {
962
+ return new Promise(function(t2) {
963
+ le2.dispatch({ type: z.resetStart }, t2, e2);
964
+ });
965
+ }, ready: function(e2) {
966
+ return G4 && e2({ plugins: F4, instance: K2 }), K2.on(z.ready, function(t2) {
967
+ e2(t2), G4 = true;
968
+ });
969
+ }, on: function(e2, t2) {
970
+ if (!e2 || !W(t2)) return false;
971
+ if (e2 === z.bootstrap) throw new Error(".on disabled for " + e2);
972
+ var n4 = /Start$|Start:/;
973
+ if ("*" === e2) {
974
+ var r3 = function(e3) {
975
+ return function(e4) {
976
+ return function(r4) {
977
+ return r4.type.match(n4) && t2({ payload: r4, instance: K2, plugins: I4 }), e4(r4);
978
+ };
979
+ };
980
+ }, i4 = function(e3) {
981
+ return function(e4) {
982
+ return function(r4) {
983
+ return r4.type.match(n4) || t2({ payload: r4, instance: K2, plugins: I4 }), e4(r4);
984
+ };
985
+ };
986
+ };
987
+ return V3(r3, xe), V3(i4, Te), function() {
988
+ B3(r3, xe), B3(i4, Te);
989
+ };
990
+ }
991
+ var a4 = e2.match(n4) ? xe : Te, o4 = function(n5) {
992
+ return function(n6) {
993
+ return function(r4) {
994
+ return r4.type === e2 && t2({ payload: r4, instance: K2, plugins: I4, abort: J4 }), n6(r4);
995
+ };
996
+ };
997
+ };
998
+ return V3(o4, a4), function() {
999
+ return B3(o4, a4);
1000
+ };
1001
+ }, once: function(e2, t2) {
1002
+ if (!e2 || !W(t2)) return false;
1003
+ if (e2 === z.bootstrap) throw new Error(".once disabled for " + e2);
1004
+ var n4 = K2.on(e2, function(e3) {
1005
+ t2({ payload: e3.payload, instance: K2, plugins: I4, abort: J4 }), n4();
1006
+ });
1007
+ return n4;
1008
+ }, getState: function(e2) {
1009
+ var t2 = le2.getState();
1010
+ return e2 ? dlv_es_default(t2, e2) : Object.assign({}, t2);
1011
+ }, dispatch: function(e2) {
1012
+ var t2 = q(e2) ? { type: e2 } : e2;
1013
+ if (x.includes(t2.type)) throw new Error("reserved action " + t2.type);
1014
+ var n4 = g({}, t2, { _: g({ originalAction: t2.type }, e2._ || {}) });
1015
+ le2.dispatch(n4);
1016
+ }, enablePlugin: F4.enable, disablePlugin: F4.disable, plugins: F4, storage: { getItem: m4.getItem, setItem: function(e2, t2, n4) {
1017
+ le2.dispatch({ type: z.setItemStart, key: e2, value: t2, options: n4 });
1018
+ }, removeItem: function(e2, t2) {
1019
+ le2.dispatch({ type: z.removeItemStart, key: e2, options: t2 });
1020
+ } }, setAnonymousId: function(e2, t2) {
1021
+ K2.storage.setItem(N, e2, t2);
1022
+ }, events: { core: x, plugins: A3 } }, Q3 = f2.middlewares.concat([function(e2) {
1023
+ return function(e3) {
1024
+ return function(t2) {
1025
+ return t2.meta || (t2.meta = je()), e3(t2);
1026
+ };
1027
+ };
1028
+ }, L3(xe), oe(K2, M3, { all: O2, plugins: A3 }), ue(m4), C(K2), D(K2), L3(Te)]), Y3 = { context: Se, user: U2(m4), page: Ee, track: me, plugins: se(M3), queue: he }, Z2 = P2, ee2 = P2;
1029
+ if ($ && o3.debug) {
1030
+ var te2 = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
1031
+ te2 && (Z2 = te2({ trace: true, traceLimit: 25 })), ee2 = function() {
1032
+ return 0 === arguments.length ? Ae() : on(typeof arguments[0]) ? _e() : _e().apply(null, arguments);
1033
+ };
1034
+ }
1035
+ var ne2, re2 = (function(e2) {
1036
+ return Object.keys(e2).reduce(function(t2, n4) {
1037
+ return Ne.includes(n4) || (t2[n4] = e2[n4]), t2;
1038
+ }, {});
1039
+ })(o3), ie2 = f2.pluginsArray.reduce(function(e2, t2) {
1040
+ var n4 = t2.name, r3 = t2.config, i4 = t2.loaded, a4 = f2.pluginEnabled[n4];
1041
+ return e2[n4] = { enabled: a4, initialized: !!a4 && Boolean(!t2.initialize), loaded: Boolean(i4({ config: r3 })), config: r3 }, e2;
1042
+ }, {}), ae2 = { context: re2, user: W3, plugins: ie2 }, le2 = w((function(e2) {
1043
+ for (var t2 = Object.keys(e2), n4 = {}, r3 = 0; r3 < t2.length; r3++) {
1044
+ var i4 = t2[r3];
1045
+ typeof e2[i4] === h && (n4[i4] = e2[i4]);
1046
+ }
1047
+ var a4, o4 = Object.keys(n4);
1048
+ try {
1049
+ !(function(e3) {
1050
+ Object.keys(e3).forEach(function(t3) {
1051
+ var n5 = e3[t3];
1052
+ if (typeof n5(void 0, { type: "@@redux/INIT" }) === v || typeof n5(void 0, { type: y2 }) === v) throw new Error("reducer " + t3 + " " + v);
1053
+ });
1054
+ })(n4);
1055
+ } catch (e3) {
1056
+ a4 = e3;
1057
+ }
1058
+ return function(e3, t3) {
1059
+ if (void 0 === e3 && (e3 = {}), a4) throw a4;
1060
+ for (var r4 = false, i5 = {}, u4 = 0; u4 < o4.length; u4++) {
1061
+ var c4 = o4[u4], s3 = e3[c4], l3 = (0, n4[c4])(s3, t3);
1062
+ if (typeof l3 === v) {
1063
+ var f3 = E(c4, t3);
1064
+ throw new Error(f3);
1065
+ }
1066
+ i5[c4] = l3, r4 = r4 || l3 !== s3;
1067
+ }
1068
+ return r4 ? i5 : e3;
1069
+ };
1070
+ })(g({}, Y3, u3)), ae2, ee2(Z2(S.apply(void 0, Q3))));
1071
+ le2.dispatch = (ne2 = le2.dispatch, function(e2, t2, n4) {
1072
+ var r3 = g({}, e2, { meta: je(e2.meta, t2, Oe(n4)) });
1073
+ return ne2.apply(null, [r3]);
1074
+ });
1075
+ var fe2 = Object.keys(I4);
1076
+ le2.dispatch({ type: z.bootstrap, plugins: fe2, config: re2, params: X3, user: W3, initialUser: s2, persistedUser: H3 });
1077
+ var de2 = fe2.filter(function(e2) {
1078
+ return f2.pluginEnabled[e2];
1079
+ }), pe2 = fe2.filter(function(e2) {
1080
+ return !f2.pluginEnabled[e2];
1081
+ });
1082
+ return le2.dispatch({ type: z.registerPlugins, plugins: fe2, enabled: f2.pluginEnabled }), f2.pluginsArray.map(function(e2, t2) {
1083
+ var n4 = e2.bootstrap, r3 = e2.config, i4 = e2.name;
1084
+ n4 && W(n4) && n4({ instance: K2, config: r3, payload: e2 }), le2.dispatch({ type: z.registerPluginType(i4), name: i4, enabled: f2.pluginEnabled[i4], plugin: e2 }), f2.pluginsArray.length === t2 + 1 && le2.dispatch({ type: z.initializeStart, plugins: de2, disabled: pe2 });
1085
+ }), K2;
1086
+ }
1087
+ var xe = "before";
1088
+ var Te = "after";
12
1089
 
13
- 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);
1090
+ // ../../node_modules/.pnpm/@analytics+cookie-utils@0.2.12/node_modules/@analytics/cookie-utils/dist/analytics-util-cookie.module.js
1091
+ var t = "cookie";
1092
+ var i2 = a2();
1093
+ var r = d;
1094
+ var c2 = d;
1095
+ function u2(o3) {
1096
+ return i2 ? d(o3, "", -1) : i(o3);
1097
+ }
1098
+ function a2() {
1099
+ if (void 0 !== i2) return i2;
1100
+ var e2 = "cookiecookie";
1101
+ try {
1102
+ d(e2, e2), i2 = -1 !== document.cookie.indexOf(e2), u2(e2);
1103
+ } catch (e3) {
1104
+ i2 = false;
1105
+ }
1106
+ return i2;
1107
+ }
1108
+ function d(e2, t2, r3, c4, u3, a4) {
1109
+ if ("undefined" != typeof window) {
1110
+ var d3 = arguments.length > 1;
1111
+ return false === i2 && (d3 ? f(e2, t2) : a(e2)), d3 ? document.cookie = e2 + "=" + encodeURIComponent(t2) + (r3 ? "; expires=" + new Date(+/* @__PURE__ */ new Date() + 1e3 * r3).toUTCString() + (c4 ? "; path=" + c4 : "") + (u3 ? "; domain=" + u3 : "") + (a4 ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + e2 + "=")[1] || "").split(";")[0]);
1112
+ }
1113
+ }
14
1114
 
15
- 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);
1115
+ // ../../node_modules/.pnpm/@analytics+localstorage-utils@0.1.10/node_modules/@analytics/localstorage-utils/dist/analytics-util-localstorage.module.js
1116
+ var r2 = "localStorage";
1117
+ var g2 = b2.bind(null, "localStorage");
1118
+ var c3 = u("localStorage", "getItem", a);
1119
+ var m3 = u("localStorage", "setItem", f);
1120
+ var S2 = u("localStorage", "removeItem", i);
16
1121
 
17
- 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:b$3}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===b$3||t===o||N(t)}function F(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:L,getItem:C,removeItem:b};
1122
+ // ../../node_modules/.pnpm/@analytics+session-storage-utils@0.0.7/node_modules/@analytics/session-storage-utils/dist/analytics-util-session-storage.module.js
1123
+ var a3 = "sessionStorage";
1124
+ var i3 = b2.bind(null, "sessionStorage");
1125
+ var g3 = u("sessionStorage", "getItem", a);
1126
+ var n3 = u("sessionStorage", "setItem", f);
1127
+ var l2 = u("sessionStorage", "removeItem", i);
18
1128
 
1129
+ // ../../node_modules/.pnpm/@analytics+storage-utils@0.4.2/node_modules/@analytics/storage-utils/dist/analytics-util-storage.module.js
1130
+ function I3(t2) {
1131
+ var o3 = t2;
1132
+ try {
1133
+ if ("true" === (o3 = JSON.parse(t2))) return true;
1134
+ if ("false" === o3) return false;
1135
+ if (on(o3)) return o3;
1136
+ parseFloat(o3) === o3 && (o3 = parseFloat(o3));
1137
+ } catch (t3) {
1138
+ }
1139
+ if (null !== o3 && "" !== o3) return o3;
1140
+ }
1141
+ var k3 = g2();
1142
+ var O = i3();
1143
+ var x2 = a2();
1144
+ function C2(o3, e2) {
1145
+ if (o3) {
1146
+ var r3 = A2(e2), a4 = !N2(r3), i4 = d2(r3) ? I3(localStorage.getItem(o3)) : void 0;
1147
+ if (a4 && !I(i4)) return i4;
1148
+ var n4 = h2(r3) ? I3(r(o3)) : void 0;
1149
+ if (a4 && n4) return n4;
1150
+ var l3 = E2(r3) ? I3(sessionStorage.getItem(o3)) : void 0;
1151
+ if (a4 && l3) return l3;
1152
+ var u3 = a(o3);
1153
+ return a4 ? u3 : { localStorage: i4, sessionStorage: l3, cookie: n4, global: u3 };
1154
+ }
1155
+ }
1156
+ function L2(r3, a4, l3) {
1157
+ if (r3 && !I(a4)) {
1158
+ var u3 = {}, g4 = A2(l3), m4 = JSON.stringify(a4), S3 = !N2(g4);
1159
+ return d2(g4) && (u3[r2] = F3(r2, a4, I3(localStorage.getItem(r3))), localStorage.setItem(r3, m4), S3) ? u3[r2] : h2(g4) && (u3[t] = F3(t, a4, I3(r(r3))), c2(r3, m4), S3) ? u3[t] : E2(g4) && (u3[a3] = F3(a3, a4, I3(sessionStorage.getItem(r3))), sessionStorage.setItem(r3, m4), S3) ? u3[a3] : (u3[l] = F3(l, a4, a(r3)), f(r3, a4), S3 ? u3[l] : u3);
1160
+ }
1161
+ }
1162
+ function b4(t2, e2) {
1163
+ if (t2) {
1164
+ var a4 = A2(e2), s2 = C2(t2, m), n4 = {};
1165
+ return !I(s2.localStorage) && d2(a4) && (localStorage.removeItem(t2), n4[r2] = s2.localStorage), !I(s2.cookie) && h2(a4) && (u2(t2), n4[t] = s2.cookie), !I(s2.sessionStorage) && E2(a4) && (sessionStorage.removeItem(t2), n4[a3] = s2.sessionStorage), !I(s2.global) && G3(a4, l) && (i(t2), n4[l] = s2.global), n4;
1166
+ }
1167
+ }
1168
+ function A2(t2) {
1169
+ return t2 ? q(t2) ? t2 : t2.storage : b;
1170
+ }
1171
+ function d2(t2) {
1172
+ return k3 && G3(t2, r2);
1173
+ }
1174
+ function h2(t2) {
1175
+ return x2 && G3(t2, t);
1176
+ }
1177
+ function E2(t2) {
1178
+ return O && G3(t2, a3);
1179
+ }
1180
+ function N2(t2) {
1181
+ return t2 === m || "all" === t2;
1182
+ }
1183
+ function G3(t2, o3) {
1184
+ return t2 === b || t2 === o3 || N2(t2);
1185
+ }
1186
+ function F3(t2, o3, e2) {
1187
+ return { location: t2, current: o3, previous: e2 };
1188
+ }
1189
+ var J3 = { setItem: L2, getItem: C2, removeItem: b4 };
1190
+
1191
+ // ../../node_modules/.pnpm/analytics@0.8.9_@types+dlv@1.1.4/node_modules/analytics/lib/analytics.es.js
19
1192
  function _defineProperty(obj, key, value) {
20
1193
  if (key in obj) {
21
1194
  Object.defineProperty(obj, key, {
22
- value: value,
1195
+ value,
23
1196
  enumerable: true,
24
1197
  configurable: true,
25
1198
  writable: true
@@ -27,1719 +1200,2108 @@ function _defineProperty(obj, key, value) {
27
1200
  } else {
28
1201
  obj[key] = value;
29
1202
  }
30
-
31
1203
  return obj;
32
1204
  }
33
-
34
1205
  function ownKeys(object, enumerableOnly) {
35
1206
  var keys = Object.keys(object);
36
-
37
1207
  if (Object.getOwnPropertySymbols) {
38
1208
  var symbols = Object.getOwnPropertySymbols(object);
39
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1209
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
40
1210
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
41
1211
  })), keys.push.apply(keys, symbols);
42
1212
  }
43
-
44
1213
  return keys;
45
1214
  }
46
-
47
1215
  function _objectSpread2(target) {
48
- for (var i = 1; i < arguments.length; i++) {
49
- var source = null != arguments[i] ? arguments[i] : {};
50
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
1216
+ for (var i4 = 1; i4 < arguments.length; i4++) {
1217
+ var source = null != arguments[i4] ? arguments[i4] : {};
1218
+ i4 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
51
1219
  _defineProperty(target, key, source[key]);
52
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
1220
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
53
1221
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
54
1222
  });
55
1223
  }
56
-
57
1224
  return target;
58
1225
  }
59
-
60
1226
  function analyticsLib() {
61
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1227
+ var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
62
1228
  var defaultSettings = {
63
- storage: J
1229
+ storage: J3
64
1230
  };
65
1231
  return ke(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
66
1232
  }
67
1233
 
1234
+ // src/script-loader.ts
68
1235
  function findScript(src) {
69
- const scripts = Array.prototype.slice.call(window.document.querySelectorAll("script"));
70
- return scripts.find(s => s.src === src);
1236
+ const scripts = Array.prototype.slice.call(window.document.querySelectorAll("script"));
1237
+ return scripts.find((s2) => s2.src === src);
71
1238
  }
72
1239
  function buildScriptSrc(src, options) {
73
- let result = src;
74
- if (!result.startsWith("http")) {
75
- result = `https://${(options === null || options === void 0 ? void 0 : options.www) ? "www." : ""}${result}`;
76
- }
77
- if (options === null || options === void 0 ? void 0 : options.min) {
78
- result = result + ".min.js";
1240
+ let result = src;
1241
+ if (!result.startsWith("http")) {
1242
+ result = `https://${(options == null ? void 0 : options.www) ? "www." : ""}${result}`;
1243
+ }
1244
+ if (options == null ? void 0 : options.min) {
1245
+ result = result + ".min.js";
1246
+ } else if (options == null ? void 0 : options.js) {
1247
+ result = result + ".js";
1248
+ }
1249
+ if (options == null ? void 0 : options.query) {
1250
+ result += "?" + options.query;
1251
+ }
1252
+ return result;
1253
+ }
1254
+ function loadScript(src, options) {
1255
+ const found = findScript(src);
1256
+ if (found !== void 0) {
1257
+ const status = found == null ? void 0 : found.getAttribute("status");
1258
+ if (status === "loaded") {
1259
+ return Promise.resolve(found);
1260
+ }
1261
+ if (status === "loading") {
1262
+ return new Promise((resolve, reject) => {
1263
+ found.addEventListener("load", () => resolve(found));
1264
+ found.addEventListener("error", (err) => reject(err));
1265
+ });
79
1266
  }
80
- else if (options === null || options === void 0 ? void 0 : options.js) {
81
- result = result + ".js";
1267
+ }
1268
+ return new Promise((resolve, reject) => {
1269
+ var _a, _b;
1270
+ const script = window.document.createElement("script");
1271
+ script.type = "text/javascript";
1272
+ script.src = buildScriptSrc(src, options);
1273
+ script.async = true;
1274
+ script.setAttribute("status", "loading");
1275
+ for (const [k4, v2] of Object.entries((_a = options == null ? void 0 : options.attributes) != null ? _a : {})) {
1276
+ script.setAttribute(k4, v2);
1277
+ }
1278
+ script.onload = () => {
1279
+ script.onerror = script.onload = null;
1280
+ script.setAttribute("status", "loaded");
1281
+ resolve(script);
1282
+ };
1283
+ script.onerror = () => {
1284
+ script.onerror = script.onload = null;
1285
+ script.setAttribute("status", "error");
1286
+ reject(new Error(`Failed to load ${src}`));
1287
+ };
1288
+ const tag = window.document.getElementsByTagName("script")[0];
1289
+ (_b = tag.parentElement) == null ? void 0 : _b.insertBefore(script, tag);
1290
+ });
1291
+ }
1292
+
1293
+ // src/destination-plugins/tag.ts
1294
+ var tagPlugin = {
1295
+ id: "tag",
1296
+ handle(config, payload) {
1297
+ return __async(this, null, function* () {
1298
+ if (!applyFilters(payload, config)) {
1299
+ return;
1300
+ }
1301
+ insertTags(config.code, payload);
1302
+ });
1303
+ }
1304
+ };
1305
+ function insertTags(code, event, opts = {}) {
1306
+ let tag;
1307
+ try {
1308
+ tag = JSON.parse(code);
1309
+ } catch (e2) {
1310
+ tag = { code, lang: "javascript" };
1311
+ }
1312
+ const debug = opts.debug || false;
1313
+ if (isInBrowser()) {
1314
+ if (tag.lang === "javascript") {
1315
+ execJs(tag.code, event);
1316
+ } else {
1317
+ const codeHolder = document.createElement("span");
1318
+ codeHolder.innerHTML = replaceMacro(tag.code, event);
1319
+ document.body.insertAdjacentElement("beforeend", codeHolder);
1320
+ const scripts = codeHolder.querySelectorAll("script");
1321
+ scripts.forEach((script) => {
1322
+ const scriptClone = document.createElement("script");
1323
+ scriptClone.type = scriptClone.type || "text/javascript";
1324
+ if (script.hasAttribute("src")) {
1325
+ scriptClone.src = script.src;
1326
+ }
1327
+ scriptClone.text = script.text;
1328
+ if (debug) {
1329
+ console.log(
1330
+ `[JITSU] Executing script${script.hasAttribute("src") ? ` ${script.src}` : ""}`,
1331
+ scriptClone.text
1332
+ );
1333
+ }
1334
+ document.head.appendChild(scriptClone);
1335
+ document.head.removeChild(scriptClone);
1336
+ });
82
1337
  }
83
- if (options === null || options === void 0 ? void 0 : options.query) {
84
- result += "?" + options.query;
1338
+ } else {
1339
+ if (debug) {
1340
+ console.log(`[JITSU] insertTags(): cannot insert tags in non-browser environment`);
85
1341
  }
86
- return result;
1342
+ }
87
1343
  }
88
- function loadScript(src, options) {
89
- const found = findScript(src);
90
- if (found !== undefined) {
91
- const status = found === null || found === void 0 ? void 0 : found.getAttribute("status");
92
- if (status === "loaded") {
93
- return Promise.resolve(found);
1344
+ var al = "al";
1345
+ var ev = "ve".split("").reverse().join("");
1346
+ var execF = globalThis[ev + al];
1347
+ function execJs(code, event) {
1348
+ const varName = `jitsu_event_${randomId()}`;
1349
+ window[varName] = event;
1350
+ const iif = `(function(){
1351
+ const event = ${varName};
1352
+ ${code}
1353
+ })()`;
1354
+ try {
1355
+ execF(iif);
1356
+ } catch (e2) {
1357
+ console.error(`[JITSU] Error executing JS code: ${e2.message}. Code: `, iif);
1358
+ } finally {
1359
+ delete window[varName];
1360
+ }
1361
+ return iif;
1362
+ }
1363
+ function replaceMacro(code, event) {
1364
+ return code.replace(/{{\s*event\s*}}/g, JSON.stringify(event));
1365
+ }
1366
+
1367
+ // src/destination-plugins/logrocket.ts
1368
+ var cdn = "cdn.lr-ingest.io/";
1369
+ var logrocketPlugin = {
1370
+ id: "logrocket",
1371
+ handle(config, payload) {
1372
+ return __async(this, null, function* () {
1373
+ if (!applyFilters(payload, config)) {
1374
+ return;
1375
+ }
1376
+ initLogrocketIfNeeded(config.appId);
1377
+ const action = (logRocket) => {
1378
+ if (payload.type === "identify" && payload.userId) {
1379
+ logRocket.identify(payload.userId, payload.traits || {});
94
1380
  }
95
- if (status === "loading") {
96
- return new Promise((resolve, reject) => {
97
- found.addEventListener("load", () => resolve(found));
98
- found.addEventListener("error", err => reject(err));
99
- });
1381
+ };
1382
+ getLogRocketQueue().push(action);
1383
+ if (getLogRocketState() === "loaded") {
1384
+ flushLogRocketQueue(window["LogRocket"]);
1385
+ }
1386
+ });
1387
+ }
1388
+ };
1389
+ function getLogRocketState() {
1390
+ return window["__jitsuLrState"] || "fresh";
1391
+ }
1392
+ function setLogRocketState(s2) {
1393
+ window["__jitsuLrState"] = s2;
1394
+ }
1395
+ function getLogRocketQueue() {
1396
+ return window["__jitsuLrQueue"] || (window["__jitsuLrQueue"] = []);
1397
+ }
1398
+ function flushLogRocketQueue(lr) {
1399
+ const queue = getLogRocketQueue();
1400
+ while (queue.length > 0) {
1401
+ const method = queue.shift();
1402
+ if (method) {
1403
+ try {
1404
+ const res = method(lr);
1405
+ if (res) {
1406
+ res.catch((e2) => console.warn(`Async LogRocket method failed: ${e2.message}`, e2));
100
1407
  }
1408
+ } catch (e2) {
1409
+ console.warn(`LogRocket method failed: ${e2.message}`, e2);
1410
+ }
101
1411
  }
102
- return new Promise((resolve, reject) => {
103
- var _a, _b;
104
- const script = window.document.createElement("script");
105
- script.type = "text/javascript";
106
- script.src = buildScriptSrc(src, options);
107
- script.async = true;
108
- script.setAttribute("status", "loading");
109
- for (const [k, v] of Object.entries((_a = options === null || options === void 0 ? void 0 : options.attributes) !== null && _a !== void 0 ? _a : {})) {
110
- script.setAttribute(k, v);
1412
+ }
1413
+ }
1414
+ function initLogrocketIfNeeded(appId) {
1415
+ return __async(this, null, function* () {
1416
+ if (getLogRocketState() !== "fresh") {
1417
+ return;
1418
+ }
1419
+ setLogRocketState("loading");
1420
+ loadScript(`${cdn}LogRocket`, { min: true, attributes: { crossOrigin: "anonymous" } }).then(() => {
1421
+ if (window["LogRocket"]) {
1422
+ try {
1423
+ window["LogRocket"].init(appId);
1424
+ } catch (e2) {
1425
+ console.warn(`LogRocket (id=${appId}) init failed: ${e2.message}`, e2);
1426
+ setLogRocketState("failed");
111
1427
  }
112
- script.onload = () => {
113
- script.onerror = script.onload = null;
114
- script.setAttribute("status", "loaded");
115
- resolve(script);
116
- };
117
- script.onerror = () => {
118
- script.onerror = script.onload = null;
119
- script.setAttribute("status", "error");
120
- reject(new Error(`Failed to load ${src}`));
121
- };
122
- const tag = window.document.getElementsByTagName("script")[0];
123
- (_b = tag.parentElement) === null || _b === void 0 ? void 0 : _b.insertBefore(script, tag);
1428
+ setLogRocketState("loaded");
1429
+ flushLogRocketQueue(window["LogRocket"]);
1430
+ }
1431
+ }).catch((e2) => {
1432
+ console.warn(`LogRocket (id=${appId}) init failed: ${e2.message}`, e2);
1433
+ setLogRocketState("failed");
124
1434
  });
1435
+ });
125
1436
  }
126
1437
 
127
- const internalDestinationPlugins = {};
1438
+ // src/destination-plugins/gtm.ts
1439
+ function omit(obj, ...keys) {
1440
+ return Object.fromEntries(Object.entries(obj).filter(([k4]) => !keys.includes(k4)));
1441
+ }
1442
+ var gtmPlugin = {
1443
+ id: "gtm",
1444
+ handle(config, payload) {
1445
+ return __async(this, null, function* () {
1446
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2;
1447
+ const debug = !!config.debug;
1448
+ if (!applyFilters(payload, config)) {
1449
+ return;
1450
+ }
1451
+ yield initGtmIfNeeded(config, payload);
1452
+ const dataLayer = window[config.dataLayerName || "dataLayer"];
1453
+ const traits = __spreadValues(__spreadValues({}, (payload == null ? void 0 : payload.traits) || {}), ((_a = payload == null ? void 0 : payload.context) == null ? void 0 : _a.traits) || {});
1454
+ const idsFromTraits = omit(traits, "id", "userId", "user_id", "anonymousId", "userId");
1455
+ if (debug) {
1456
+ console.debug("GTM plugin will be applied to following payload", payload);
1457
+ }
1458
+ const userData = {
1459
+ email_address: traits.email
1460
+ };
1461
+ const ids = __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, payload.userId ? { user_id: payload.userId, userId: payload.userId } : {}), payload.anonymousId ? { anonymousId: payload.anonymousId } : {}), idsFromTraits), {
1462
+ user_data: Object.keys(userData).length > 0 ? userData : void 0
1463
+ });
1464
+ if (debug) {
1465
+ console.debug("GTM plugin will set following user-related data layer vars", ids);
1466
+ }
1467
+ const pageProperties = payload.properties || {};
1468
+ const pageVariables = {
1469
+ page_location: pageProperties.url || ((_c = (_b = payload.context) == null ? void 0 : _b.page) == null ? void 0 : _c.url),
1470
+ page_title: pageProperties.title || ((_e2 = (_d = payload.context) == null ? void 0 : _d.page) == null ? void 0 : _e2.title),
1471
+ page_path: pageProperties.path || ((_g = (_f = payload.context) == null ? void 0 : _f.page) == null ? void 0 : _g.path),
1472
+ page_hash: pageProperties.hash || ((_i = (_h = payload.context) == null ? void 0 : _h.page) == null ? void 0 : _i.hash),
1473
+ page_search: pageProperties.search || ((_k = (_j = payload.context) == null ? void 0 : _j.page) == null ? void 0 : _k.search),
1474
+ page_referrer: (_n2 = (_m = (_l = payload == null ? void 0 : payload.context) == null ? void 0 : _l.page) == null ? void 0 : _m.referrer) != null ? _n2 : ""
1475
+ };
1476
+ if (debug) {
1477
+ console.debug("GTM plugin will set following context (page) related data layer vars", ids);
1478
+ }
1479
+ const pushToDataLayer = (data) => {
1480
+ dataLayer.push(data);
1481
+ if (debug) {
1482
+ console.debug("GTM plugin will push following data to dataLayer", data);
1483
+ }
1484
+ };
1485
+ switch (payload.type) {
1486
+ case "page":
1487
+ const { properties: pageProperties2, context } = payload;
1488
+ const pageEvent = __spreadValues(__spreadValues({
1489
+ event: "page_view"
1490
+ }, pageVariables), ids);
1491
+ pushToDataLayer(pageEvent);
1492
+ break;
1493
+ case "track":
1494
+ const { properties: trackProperties } = payload;
1495
+ const trackEvent = __spreadValues(__spreadValues(__spreadValues({
1496
+ event: payload.event
1497
+ }, pageVariables), trackProperties), ids);
1498
+ pushToDataLayer(trackEvent);
1499
+ break;
1500
+ case "identify":
1501
+ const { traits: traits2 } = payload;
1502
+ const identifyEvent = __spreadValues(__spreadValues(__spreadValues({
1503
+ event: "identify"
1504
+ }, pageVariables), traits2), ids);
1505
+ pushToDataLayer(identifyEvent);
1506
+ break;
1507
+ }
1508
+ dataLayer.push(function() {
1509
+ this.reset();
1510
+ });
1511
+ });
1512
+ }
1513
+ };
1514
+ function getGtmState() {
1515
+ return window["__jitsuGtmState"] || "fresh";
1516
+ }
1517
+ function setGtmState(s2) {
1518
+ window["__jitsuGtmState"] = s2;
1519
+ }
1520
+ function initGtmIfNeeded(config, payload) {
1521
+ return __async(this, null, function* () {
1522
+ if (getGtmState() !== "fresh") {
1523
+ return;
1524
+ }
1525
+ setGtmState("loading");
1526
+ const dlName = config.dataLayerName || "dataLayer";
1527
+ const tagId = config.containerId;
1528
+ (function(w2, l3, i4) {
1529
+ w2[l3] = w2[l3] || [];
1530
+ w2[l3].push({
1531
+ user_id: payload.userId
1532
+ });
1533
+ w2[l3].push({
1534
+ "gtm.start": (/* @__PURE__ */ new Date()).getTime(),
1535
+ event: "gtm.js"
1536
+ });
1537
+ const dl = l3 != "dataLayer" ? "&l=" + l3 : "";
1538
+ const scriptSrc = "googletagmanager.com/gtm";
1539
+ loadScript(scriptSrc, { www: true, js: true, query: "id=" + i4 + dl }).then(() => {
1540
+ setGtmState("loaded");
1541
+ }).catch((e2) => {
1542
+ console.warn(`GTM (containerId=${tagId}) init failed: ${e2.message}`, e2);
1543
+ setGtmState("failed");
1544
+ });
1545
+ })(window, dlName, tagId);
1546
+ });
1547
+ }
128
1548
 
129
- var name = "@jitsu/js";
130
- var version = "1.11.0-beta.1";
131
- var description = "";
132
- var author = "Jitsu Dev Team <dev@jitsu.com>";
133
- var main = "dist/jitsu.cjs.js";
134
- var files = [
135
- "dist"
1549
+ // src/destination-plugins/ga4.ts
1550
+ var urlData = [
1551
+ new Uint8Array([109, 111, 99, 46, 114, 101, 103, 97, 110, 97, 109, 103, 97, 116, 101, 108, 103, 111, 111, 103]),
1552
+ new Uint8Array([103, 97, 116, 103]),
1553
+ new Uint8Array([115, 106])
136
1554
  ];
137
- var module = "dist/jitsu.es.js";
138
- var types = "dist/jitsu.d.ts";
139
- var publishConfig = {
140
- access: "public"
141
- };
142
- var license = "MIT";
143
- var scripts = {
144
- clean: "rm -rf ./dist ./compiled",
145
- "test:node": "vitest run",
146
- "test:playwright": "playwright test ./__tests__/playwright",
147
- test: "pnpm run test:node",
148
- "//typecheck": "Build is required because types are generated during build",
149
- typecheck: "pnpm run build",
150
- build: "pnpm run clean && tsc -p . && rollup -c",
151
- "//build-deps": "Required by turbo ^build-deps - builds dist/ for workspace packages that import this",
152
- "build-deps": "pnpm run build"
153
- };
154
- var devDependencies = {
155
- "@jitsu/common-config": "workspace:*",
156
- tslib: "catalog:",
157
- "@playwright/test": "1.39.0",
158
- "@rollup/plugin-commonjs": "^28.0.2",
159
- "rollup-plugin-dts": "^6.2.1",
160
- "@rollup/plugin-json": "^5.0.1",
161
- "@rollup/plugin-multi-entry": "^6.0.0",
162
- "@rollup/plugin-node-resolve": "^16.0.0",
163
- "@rollup/plugin-replace": "^5.0.1",
164
- "@rollup/plugin-terser": "^0.1.0",
165
- "@segment/analytics-next": "^1.75.0",
166
- "@types/chalk": "^2.2.0",
167
- "@types/node": "catalog:",
168
- "@vitest/ui": "catalog:",
169
- chalk: "^4.1.2",
170
- "cookie-parser": "^1.4.7",
171
- ejs: "^3.1.8",
172
- express: "^4.21.2",
173
- "node-fetch-commonjs": "^3.3.2",
174
- "node-forge": "^1.3.1",
175
- "raw-loader": "^4.0.2",
176
- rollup: "^3.29.5",
177
- typescript: "catalog:",
178
- vitest: "catalog:",
179
- jsondiffpatch: "workspace:*"
180
- };
181
- var peerDependencies = {
182
- "@jitsu/protocols": "workspace:*"
1555
+ function byteArrayToString(byteArray) {
1556
+ const decoder = new TextDecoder();
1557
+ return decoder.decode(byteArray);
1558
+ }
1559
+ function buildTagUrl() {
1560
+ return urlData.map((d3) => d3.reverse()).map(byteArrayToString).join("/");
1561
+ }
1562
+ var ga4Plugin = {
1563
+ id: "ga4-tag",
1564
+ handle(config, payload) {
1565
+ return __async(this, null, function* () {
1566
+ var _a, _b;
1567
+ if (!applyFilters(payload, config)) {
1568
+ return;
1569
+ }
1570
+ yield initGa4IfNeeded(config, payload);
1571
+ const dataLayer = window[config.dataLayerName || "dataLayer"];
1572
+ const gtag = function() {
1573
+ dataLayer.push(arguments);
1574
+ };
1575
+ const ids = __spreadValues(__spreadValues({}, payload.userId ? { user_id: payload.userId, userId: payload.userId } : {}), payload.anonymousId ? { anonymousId: payload.anonymousId } : {});
1576
+ if (payload.userId) {
1577
+ gtag("set", { user_id: payload.userId });
1578
+ }
1579
+ switch (payload.type) {
1580
+ case "page":
1581
+ if (config.autoPageView) {
1582
+ console.log("autoPageView");
1583
+ break;
1584
+ }
1585
+ const { properties: pageProperties, context } = payload;
1586
+ if (pageProperties) {
1587
+ const pageEvent = __spreadValues({
1588
+ page_location: pageProperties.url,
1589
+ page_title: pageProperties.title,
1590
+ page_path: pageProperties.path,
1591
+ page_hash: pageProperties.hash,
1592
+ page_search: pageProperties.search,
1593
+ page_referrer: (_b = (_a = context == null ? void 0 : context.page) == null ? void 0 : _a.referrer) != null ? _b : ""
1594
+ }, ids);
1595
+ gtag("event", "page_view", pageEvent);
1596
+ }
1597
+ break;
1598
+ case "track":
1599
+ const { properties: trackProperties } = payload;
1600
+ const trackEvent = __spreadValues(__spreadValues({}, trackProperties), ids);
1601
+ gtag("event", payload.event, trackEvent);
1602
+ break;
1603
+ case "identify":
1604
+ const { traits } = payload;
1605
+ const identifyEvent = __spreadValues(__spreadValues({}, traits), ids);
1606
+ gtag("event", "identify", identifyEvent);
1607
+ break;
1608
+ }
1609
+ });
1610
+ }
183
1611
  };
184
- var dependencies = {
185
- analytics: "0.8.9"
1612
+ function getGa4State() {
1613
+ return window["__jitsuGa4State"] || "fresh";
1614
+ }
1615
+ function setGa4State(s2) {
1616
+ window["__jitsuGa4State"] = s2;
1617
+ }
1618
+ function initGa4IfNeeded(config, payload) {
1619
+ return __async(this, null, function* () {
1620
+ if (getGa4State() !== "fresh") {
1621
+ return;
1622
+ }
1623
+ setGa4State("loading");
1624
+ const dlName = config.dataLayerName || "dataLayer";
1625
+ const dlParam = dlName !== "dataLayer" ? "&l=" + dlName : "";
1626
+ const tagId = config.measurementIds;
1627
+ window[dlName] = window[dlName] || [];
1628
+ const gtag = function() {
1629
+ window[dlName].push(arguments);
1630
+ };
1631
+ gtag("js", /* @__PURE__ */ new Date());
1632
+ gtag(
1633
+ // @ts-ignore
1634
+ "config",
1635
+ tagId,
1636
+ __spreadValues(__spreadValues({}, payload.userId ? { user_id: payload.userId } : {}), !config.autoPageView ? { send_page_view: false } : {})
1637
+ );
1638
+ loadScript(buildTagUrl(), { query: `id=${tagId}${dlParam}`, www: true }).then(() => {
1639
+ setGa4State("loaded");
1640
+ }).catch((e2) => {
1641
+ console.warn(`GA4 (containerId=${config.measurementIds}) init failed: ${e2.message}`, e2);
1642
+ setGa4State("failed");
1643
+ });
1644
+ });
1645
+ }
1646
+
1647
+ // src/destination-plugins/index.ts
1648
+ function satisfyFilter(filter, subject) {
1649
+ return filter === "*" || filter.toLowerCase().trim() === (subject || "").trim().toLowerCase();
1650
+ }
1651
+ function satisfyDomainFilter(filter, subject) {
1652
+ if (filter === "*") {
1653
+ return true;
1654
+ }
1655
+ subject = subject || "";
1656
+ if (filter.startsWith("*.")) {
1657
+ return subject.endsWith(filter.substring(1));
1658
+ } else {
1659
+ return filter === subject;
1660
+ }
1661
+ }
1662
+ function applyFilters(event, creds) {
1663
+ const { hosts = "*", events = "*" } = creds;
1664
+ try {
1665
+ const eventsArray = Array.isArray(events) ? events : events.split("\n");
1666
+ const hostsArray = Array.isArray(hosts) ? hosts : hosts.split("\n");
1667
+ return !!hostsArray.find((hostFilter) => {
1668
+ var _a, _b;
1669
+ return satisfyDomainFilter(hostFilter, (_b = (_a = event.context) == null ? void 0 : _a.page) == null ? void 0 : _b.host);
1670
+ }) && (!!eventsArray.find((eventFilter) => satisfyFilter(eventFilter, event.type)) || !!eventsArray.find((eventFilter) => satisfyFilter(eventFilter, event.event)));
1671
+ } catch (e2) {
1672
+ console.warn(
1673
+ `Failed to apply filters: ${e2.message}. Typeof events: ${typeof events}, typeof hosts: ${typeof hosts}. Values`,
1674
+ events,
1675
+ hosts
1676
+ );
1677
+ throw new Error(
1678
+ `Failed to apply filters: ${e2.message}. Typeof events: ${typeof events}, typeof hosts: ${typeof hosts}`
1679
+ );
1680
+ }
1681
+ }
1682
+ var internalDestinationPlugins = {
1683
+ [tagPlugin.id]: tagPlugin,
1684
+ [gtmPlugin.id]: gtmPlugin,
1685
+ [ga4Plugin.id]: ga4Plugin,
1686
+ [logrocketPlugin.id]: logrocketPlugin
186
1687
  };
187
- var pkg = {
188
- name: name,
189
- version: version,
190
- description: description,
191
- author: author,
192
- main: main,
193
- files: files,
194
- module: module,
195
- types: types,
196
- publishConfig: publishConfig,
197
- license: license,
198
- "private": false,
199
- scripts: scripts,
200
- devDependencies: devDependencies,
201
- peerDependencies: peerDependencies,
202
- dependencies: dependencies
1688
+
1689
+ // package.json
1690
+ var package_default = {
1691
+ name: "@jitsu/js",
1692
+ version: "1.11.0-beta.11",
1693
+ description: "",
1694
+ author: "Jitsu Dev Team <dev@jitsu.com>",
1695
+ main: "src/index.ts",
1696
+ types: "src/index.ts",
1697
+ files: [
1698
+ "dist",
1699
+ "compiled"
1700
+ ],
1701
+ publishConfig: {
1702
+ main: "dist/jitsu.cjs.js",
1703
+ module: "dist/jitsu.es.js",
1704
+ types: "dist/index.d.ts",
1705
+ access: "public"
1706
+ },
1707
+ license: "MIT",
1708
+ private: false,
1709
+ scripts: {
1710
+ clean: "rm -rf ./dist ./compiled",
1711
+ "test:node": "vitest run",
1712
+ "test:playwright": "playwright test ./__tests__/playwright",
1713
+ test: "pnpm run test:node",
1714
+ typecheck: "tsc --noEmit",
1715
+ build: "tsc && tsx bundle.mts",
1716
+ prepublishOnly: "pnpm run build",
1717
+ "//build-deps": "Required by turbo ^build-deps - builds dist/ for workspace packages that import this",
1718
+ "build-deps": "pnpm run build"
1719
+ },
1720
+ devDependencies: {
1721
+ "@jitsu/common-config": "workspace:*",
1722
+ tslib: "catalog:",
1723
+ "@playwright/test": "^1.57.0",
1724
+ esbuild: "catalog:",
1725
+ tsx: "catalog:",
1726
+ "@segment/analytics-next": "^1.75.0",
1727
+ "@types/chalk": "^2.2.0",
1728
+ "@types/node": "catalog:",
1729
+ "@vitest/ui": "catalog:",
1730
+ chalk: "^4.1.2",
1731
+ "cookie-parser": "^1.4.7",
1732
+ ejs: "^3.1.8",
1733
+ express: "^4.21.2",
1734
+ "node-forge": "^1.3.2",
1735
+ "raw-loader": "^4.0.2",
1736
+ typescript: "catalog:",
1737
+ vitest: "catalog:",
1738
+ jsondiffpatch: "workspace:*"
1739
+ },
1740
+ peerDependencies: {
1741
+ "@jitsu/protocols": "workspace:*"
1742
+ },
1743
+ dependencies: {
1744
+ analytics: "0.8.9"
1745
+ }
203
1746
  };
204
1747
 
205
- const jitsuVersion = pkg.version ;
206
- const jitsuLibraryName = "@jitsu/js";
1748
+ // src/version.ts
1749
+ var jitsuVersion = package_default.version !== "0.0.0" ? package_default.version : "2.0.0";
1750
+ var jitsuLibraryName = "@jitsu/js";
207
1751
 
208
- const publicSuffixes = "webflow.io,vercel.app,myshopify.com,ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,aéroport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,māori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(",");
209
- const _publicSuffixesMap = {};
210
- publicSuffixes.forEach(tld => {
211
- _publicSuffixesMap[tld] = true;
1752
+ // src/tlds.ts
1753
+ var publicSuffixes = "webflow.io,vercel.app,myshopify.com,ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,a\xE9roport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,m\u0101ori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(
1754
+ ","
1755
+ );
1756
+ var _publicSuffixesMap = {};
1757
+ publicSuffixes.forEach((tld) => {
1758
+ _publicSuffixesMap[tld] = true;
212
1759
  });
213
- const publicSuffixesMap = _publicSuffixesMap;
1760
+ var publicSuffixesMap = _publicSuffixesMap;
214
1761
  function getTopLevelDomain(hostname) {
215
- const [domain] = hostname.split(":");
216
- const parts = domain.split(".");
217
- if (parts[parts.length - 1] === "localhost" || parts.length < 2) {
218
- return parts[parts.length - 1];
219
- }
220
- else {
221
- const d = parts[parts.length - 2] + "." + parts[parts.length - 1];
222
- if (parts.length > 2 && publicSuffixesMap[d]) {
223
- return parts[parts.length - 3] + "." + d;
224
- }
225
- else {
226
- return d;
227
- }
1762
+ const [domain] = hostname.split(":");
1763
+ const parts = domain.split(".");
1764
+ if (parts[parts.length - 1] === "localhost" || parts.length < 2) {
1765
+ return parts[parts.length - 1];
1766
+ } else {
1767
+ const d3 = parts[parts.length - 2] + "." + parts[parts.length - 1];
1768
+ if (parts.length > 2 && publicSuffixesMap[d3]) {
1769
+ return parts[parts.length - 3] + "." + d3;
1770
+ } else {
1771
+ return d3;
228
1772
  }
1773
+ }
229
1774
  }
230
1775
 
231
- class Processor {
232
- constructor(options) {
233
- this.selfOptions = options || {};
234
- this.pipes = {};
235
- }
236
- options(options) {
237
- if (options) {
238
- this.selfOptions = options;
239
- }
240
- return this.selfOptions;
241
- }
242
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
243
- pipe(name, pipeArg) {
244
- let pipe = pipeArg;
245
- if (typeof name === "string") {
246
- if (typeof pipe === "undefined") {
247
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
248
- return this.pipes[name];
249
- }
250
- else {
251
- this.pipes[name] = pipe;
252
- }
253
- }
254
- if (name && name.name) {
255
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
256
- pipe = name;
257
- if (pipe.processor === this) {
258
- return pipe;
259
- }
260
- this.pipes[pipe.name] = pipe;
261
- }
262
- pipe.processor = this;
1776
+ // ../jsondiffpatch/dist/processor.js
1777
+ var Processor = class {
1778
+ constructor(options) {
1779
+ this.selfOptions = options || {};
1780
+ this.pipes = {};
1781
+ }
1782
+ options(options) {
1783
+ if (options) {
1784
+ this.selfOptions = options;
1785
+ }
1786
+ return this.selfOptions;
1787
+ }
1788
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1789
+ pipe(name, pipeArg) {
1790
+ let pipe = pipeArg;
1791
+ if (typeof name === "string") {
1792
+ if (typeof pipe === "undefined") {
1793
+ return this.pipes[name];
1794
+ } else {
1795
+ this.pipes[name] = pipe;
1796
+ }
1797
+ }
1798
+ if (name && name.name) {
1799
+ pipe = name;
1800
+ if (pipe.processor === this) {
263
1801
  return pipe;
1802
+ }
1803
+ this.pipes[pipe.name] = pipe;
264
1804
  }
265
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
266
- process(input, pipe) {
267
- let context = input;
268
- context.options = this.options();
269
- let nextPipe = pipe || input.pipe || "default";
270
- let lastPipe;
271
- while (nextPipe) {
272
- if (typeof context.nextAfterChildren !== "undefined") {
273
- // children processed and coming back to parent
274
- context.next = context.nextAfterChildren;
275
- context.nextAfterChildren = null;
276
- }
277
- if (typeof nextPipe === "string") {
278
- nextPipe = this.pipe(nextPipe);
279
- }
280
- nextPipe.process(context);
281
- lastPipe = nextPipe;
282
- nextPipe = null;
283
- if (context) {
284
- if (context.next) {
285
- context = context.next;
286
- nextPipe = context.pipe || lastPipe;
287
- }
288
- }
1805
+ pipe.processor = this;
1806
+ return pipe;
1807
+ }
1808
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1809
+ process(input, pipe) {
1810
+ let context = input;
1811
+ context.options = this.options();
1812
+ let nextPipe = pipe || input.pipe || "default";
1813
+ let lastPipe;
1814
+ while (nextPipe) {
1815
+ if (typeof context.nextAfterChildren !== "undefined") {
1816
+ context.next = context.nextAfterChildren;
1817
+ context.nextAfterChildren = null;
1818
+ }
1819
+ if (typeof nextPipe === "string") {
1820
+ nextPipe = this.pipe(nextPipe);
1821
+ }
1822
+ nextPipe.process(context);
1823
+ lastPipe = nextPipe;
1824
+ nextPipe = null;
1825
+ if (context) {
1826
+ if (context.next) {
1827
+ context = context.next;
1828
+ nextPipe = context.pipe || lastPipe;
289
1829
  }
290
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
291
- return context.hasResult ? context.result : undefined;
1830
+ }
292
1831
  }
293
- }
1832
+ return context.hasResult ? context.result : void 0;
1833
+ }
1834
+ };
1835
+ var processor_default = Processor;
294
1836
 
295
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
296
- class Pipe {
297
- constructor(name) {
298
- this.name = name;
299
- this.filters = [];
300
- }
301
- process(input) {
302
- if (!this.processor) {
303
- throw new Error("add this pipe to a processor before using it");
304
- }
305
- const debug = this.debug;
306
- const length = this.filters.length;
307
- const context = input;
308
- for (let index = 0; index < length; index++) {
309
- const filter = this.filters[index];
310
- if (debug) {
311
- this.log(`filter: ${filter.filterName}`);
312
- }
313
- filter(context);
314
- if (typeof context === "object" && context.exiting) {
315
- context.exiting = false;
316
- break;
317
- }
318
- }
319
- if (!context.next && this.resultCheck) {
320
- this.resultCheck(context);
321
- }
1837
+ // ../jsondiffpatch/dist/pipe.js
1838
+ var Pipe = class {
1839
+ constructor(name) {
1840
+ this.name = name;
1841
+ this.filters = [];
1842
+ }
1843
+ process(input) {
1844
+ if (!this.processor) {
1845
+ throw new Error("add this pipe to a processor before using it");
322
1846
  }
323
- log(msg) {
324
- console.log(`[jsondiffpatch] ${this.name} pipe, ${msg}`);
1847
+ const debug = this.debug;
1848
+ const length = this.filters.length;
1849
+ const context = input;
1850
+ for (let index = 0; index < length; index++) {
1851
+ const filter = this.filters[index];
1852
+ if (debug) {
1853
+ this.log(`filter: ${filter.filterName}`);
1854
+ }
1855
+ filter(context);
1856
+ if (typeof context === "object" && context.exiting) {
1857
+ context.exiting = false;
1858
+ break;
1859
+ }
1860
+ }
1861
+ if (!context.next && this.resultCheck) {
1862
+ this.resultCheck(context);
325
1863
  }
326
- append(...args) {
327
- this.filters.push(...args);
328
- return this;
1864
+ }
1865
+ log(msg) {
1866
+ console.log(`[jsondiffpatch] ${this.name} pipe, ${msg}`);
1867
+ }
1868
+ append(...args) {
1869
+ this.filters.push(...args);
1870
+ return this;
1871
+ }
1872
+ prepend(...args) {
1873
+ this.filters.unshift(...args);
1874
+ return this;
1875
+ }
1876
+ indexOf(filterName) {
1877
+ if (!filterName) {
1878
+ throw new Error("a filter name is required");
329
1879
  }
330
- prepend(...args) {
331
- this.filters.unshift(...args);
332
- return this;
1880
+ for (let index = 0; index < this.filters.length; index++) {
1881
+ const filter = this.filters[index];
1882
+ if (filter.filterName === filterName) {
1883
+ return index;
1884
+ }
333
1885
  }
334
- indexOf(filterName) {
335
- if (!filterName) {
336
- throw new Error("a filter name is required");
337
- }
338
- for (let index = 0; index < this.filters.length; index++) {
339
- const filter = this.filters[index];
340
- if (filter.filterName === filterName) {
341
- return index;
342
- }
343
- }
344
- throw new Error(`filter not found: ${filterName}`);
345
- }
346
- list() {
347
- return this.filters.map(f => f.filterName);
348
- }
349
- after(filterName, ...params) {
350
- const index = this.indexOf(filterName);
351
- this.filters.splice(index + 1, 0, ...params);
352
- return this;
353
- }
354
- before(filterName, ...params) {
355
- const index = this.indexOf(filterName);
356
- this.filters.splice(index, 0, ...params);
357
- return this;
358
- }
359
- replace(filterName, ...params) {
360
- const index = this.indexOf(filterName);
361
- this.filters.splice(index, 1, ...params);
362
- return this;
363
- }
364
- remove(filterName) {
365
- const index = this.indexOf(filterName);
366
- this.filters.splice(index, 1);
367
- return this;
368
- }
369
- clear() {
370
- this.filters.length = 0;
371
- return this;
372
- }
373
- shouldHaveResult(should) {
374
- if (should === false) {
375
- this.resultCheck = null;
376
- return;
377
- }
378
- if (this.resultCheck) {
379
- return;
380
- }
381
- this.resultCheck = context => {
382
- if (!context.hasResult) {
383
- console.log(context);
384
- const error = new Error(`${this.name} failed`);
385
- error.noResult = true;
386
- throw error;
387
- }
388
- };
389
- return this;
390
- }
391
- }
1886
+ throw new Error(`filter not found: ${filterName}`);
1887
+ }
1888
+ list() {
1889
+ return this.filters.map((f2) => f2.filterName);
1890
+ }
1891
+ after(filterName, ...params) {
1892
+ const index = this.indexOf(filterName);
1893
+ this.filters.splice(index + 1, 0, ...params);
1894
+ return this;
1895
+ }
1896
+ before(filterName, ...params) {
1897
+ const index = this.indexOf(filterName);
1898
+ this.filters.splice(index, 0, ...params);
1899
+ return this;
1900
+ }
1901
+ replace(filterName, ...params) {
1902
+ const index = this.indexOf(filterName);
1903
+ this.filters.splice(index, 1, ...params);
1904
+ return this;
1905
+ }
1906
+ remove(filterName) {
1907
+ const index = this.indexOf(filterName);
1908
+ this.filters.splice(index, 1);
1909
+ return this;
1910
+ }
1911
+ clear() {
1912
+ this.filters.length = 0;
1913
+ return this;
1914
+ }
1915
+ shouldHaveResult(should) {
1916
+ if (should === false) {
1917
+ this.resultCheck = null;
1918
+ return;
1919
+ }
1920
+ if (this.resultCheck) {
1921
+ return;
1922
+ }
1923
+ this.resultCheck = (context) => {
1924
+ if (!context.hasResult) {
1925
+ console.log(context);
1926
+ const error = new Error(`${this.name} failed`);
1927
+ error.noResult = true;
1928
+ throw error;
1929
+ }
1930
+ };
1931
+ return this;
1932
+ }
1933
+ };
1934
+ var pipe_default = Pipe;
392
1935
 
393
- class Context {
394
- setResult(result) {
395
- this.result = result;
396
- this.hasResult = true;
397
- return this;
398
- }
399
- exit() {
400
- this.exiting = true;
401
- return this;
402
- }
403
- push(child, name) {
404
- child.parent = this;
405
- if (typeof name !== "undefined") {
406
- child.childName = name;
407
- }
408
- child.root = this.root || this;
409
- child.options = child.options || this.options;
410
- if (!this.children) {
411
- this.children = [child];
412
- this.nextAfterChildren = this.next || null;
413
- this.next = child;
414
- }
415
- else {
416
- this.children[this.children.length - 1].next = child;
417
- this.children.push(child);
418
- }
419
- child.next = this;
420
- return this;
421
- }
422
- }
1936
+ // ../jsondiffpatch/dist/contexts/context.js
1937
+ var Context = class {
1938
+ setResult(result) {
1939
+ this.result = result;
1940
+ this.hasResult = true;
1941
+ return this;
1942
+ }
1943
+ exit() {
1944
+ this.exiting = true;
1945
+ return this;
1946
+ }
1947
+ push(child, name) {
1948
+ child.parent = this;
1949
+ if (typeof name !== "undefined") {
1950
+ child.childName = name;
1951
+ }
1952
+ child.root = this.root || this;
1953
+ child.options = child.options || this.options;
1954
+ if (!this.children) {
1955
+ this.children = [child];
1956
+ this.nextAfterChildren = this.next || null;
1957
+ this.next = child;
1958
+ } else {
1959
+ this.children[this.children.length - 1].next = child;
1960
+ this.children.push(child);
1961
+ }
1962
+ child.next = this;
1963
+ return this;
1964
+ }
1965
+ };
423
1966
 
424
- class DiffContext extends Context {
425
- constructor(left, right) {
426
- super();
427
- this.left = left;
428
- this.right = right;
429
- this.pipe = "diff";
430
- }
431
- setResult(result) {
432
- return super.setResult(result);
433
- }
434
- }
1967
+ // ../jsondiffpatch/dist/contexts/diff.js
1968
+ var DiffContext = class extends Context {
1969
+ constructor(left, right) {
1970
+ super();
1971
+ this.left = left;
1972
+ this.right = right;
1973
+ this.pipe = "diff";
1974
+ }
1975
+ setResult(result) {
1976
+ return super.setResult(result);
1977
+ }
1978
+ };
1979
+ var diff_default = DiffContext;
435
1980
 
436
- class PatchContext extends Context {
437
- constructor(left, delta) {
438
- super();
439
- this.left = left;
440
- this.delta = delta;
441
- this.pipe = "patch";
442
- }
443
- }
1981
+ // ../jsondiffpatch/dist/contexts/patch.js
1982
+ var PatchContext = class extends Context {
1983
+ constructor(left, delta) {
1984
+ super();
1985
+ this.left = left;
1986
+ this.delta = delta;
1987
+ this.pipe = "patch";
1988
+ }
1989
+ };
1990
+ var patch_default = PatchContext;
444
1991
 
445
- function arrayEquals(a, b) {
446
- if (a.length !== b.length) {
447
- return false;
448
- }
449
- for (let i = 0; i < a.length; i++) {
450
- if (a[i] !== b[i]) {
451
- return false;
452
- }
1992
+ // ../jsondiffpatch/dist/filters/trivial.js
1993
+ function arrayEquals(a4, b5) {
1994
+ if (a4.length !== b5.length) {
1995
+ return false;
1996
+ }
1997
+ for (let i4 = 0; i4 < a4.length; i4++) {
1998
+ if (a4[i4] !== b5[i4]) {
1999
+ return false;
453
2000
  }
454
- return true;
2001
+ }
2002
+ return true;
455
2003
  }
456
- const diffFilter$1 = function trivialMatchesDiffFilter(context) {
457
- if (context.left === context.right) {
458
- context.setResult(undefined).exit();
459
- return;
460
- }
461
- if (typeof context.left === "undefined") {
462
- if (typeof context.right === "function") {
463
- throw new Error("functions are not supported");
464
- }
465
- context.setResult([context.right]).exit();
466
- return;
467
- }
468
- if (typeof context.right === "undefined") {
469
- context.setResult([context.left, 0, 0]).exit();
470
- return;
471
- }
472
- if (typeof context.left === "function" || typeof context.right === "function") {
473
- throw new Error("functions are not supported");
474
- }
475
- context.leftType = context.left === null ? "null" : typeof context.left;
476
- context.rightType = context.right === null ? "null" : typeof context.right;
477
- if (context.leftType !== context.rightType) {
478
- context.setResult([context.left, context.right]).exit();
479
- return;
480
- }
481
- if (context.leftType === "boolean" || context.leftType === "number" || context.leftType === "string") {
482
- context.setResult([context.left, context.right]).exit();
483
- return;
484
- }
485
- if (context.leftType === "object") {
486
- context.leftIsArray = Array.isArray(context.left);
487
- }
488
- if (context.rightType === "object") {
489
- context.rightIsArray = Array.isArray(context.right);
490
- }
491
- if (context.leftIsArray !== context.rightIsArray) {
492
- context.setResult([context.left, context.right]).exit();
493
- return;
2004
+ var diffFilter = function trivialMatchesDiffFilter(context) {
2005
+ if (context.left === context.right) {
2006
+ context.setResult(void 0).exit();
2007
+ return;
2008
+ }
2009
+ if (typeof context.left === "undefined") {
2010
+ if (typeof context.right === "function") {
2011
+ throw new Error("functions are not supported");
494
2012
  }
495
- if (context.leftIsArray && context.rightIsArray) {
496
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
497
- if (arrayEquals(context.left, context.right)) {
498
- context.setResult(undefined).exit();
499
- return;
500
- }
501
- else {
502
- context.setResult([context.left, context.right]).exit();
503
- return;
504
- }
2013
+ context.setResult([context.right]).exit();
2014
+ return;
2015
+ }
2016
+ if (typeof context.right === "undefined") {
2017
+ context.setResult([context.left, 0, 0]).exit();
2018
+ return;
2019
+ }
2020
+ if (typeof context.left === "function" || typeof context.right === "function") {
2021
+ throw new Error("functions are not supported");
2022
+ }
2023
+ context.leftType = context.left === null ? "null" : typeof context.left;
2024
+ context.rightType = context.right === null ? "null" : typeof context.right;
2025
+ if (context.leftType !== context.rightType) {
2026
+ context.setResult([context.left, context.right]).exit();
2027
+ return;
2028
+ }
2029
+ if (context.leftType === "boolean" || context.leftType === "number" || context.leftType === "string") {
2030
+ context.setResult([context.left, context.right]).exit();
2031
+ return;
2032
+ }
2033
+ if (context.leftType === "object") {
2034
+ context.leftIsArray = Array.isArray(context.left);
2035
+ }
2036
+ if (context.rightType === "object") {
2037
+ context.rightIsArray = Array.isArray(context.right);
2038
+ }
2039
+ if (context.leftIsArray !== context.rightIsArray) {
2040
+ context.setResult([context.left, context.right]).exit();
2041
+ return;
2042
+ }
2043
+ if (context.leftIsArray && context.rightIsArray) {
2044
+ if (arrayEquals(context.left, context.right)) {
2045
+ context.setResult(void 0).exit();
2046
+ return;
2047
+ } else {
2048
+ context.setResult([context.left, context.right]).exit();
2049
+ return;
505
2050
  }
506
- if (context.left instanceof RegExp) {
507
- if (context.right instanceof RegExp) {
508
- context.setResult([context.left.toString(), context.right.toString()]).exit();
509
- }
510
- else {
511
- context.setResult([context.left, context.right]).exit();
512
- }
2051
+ }
2052
+ if (context.left instanceof RegExp) {
2053
+ if (context.right instanceof RegExp) {
2054
+ context.setResult([context.left.toString(), context.right.toString()]).exit();
2055
+ } else {
2056
+ context.setResult([context.left, context.right]).exit();
513
2057
  }
2058
+ }
514
2059
  };
515
- diffFilter$1.filterName = "trivial";
516
- const patchFilter$1 = function trivialMatchesPatchFilter(context) {
517
- if (typeof context.delta === "undefined") {
518
- context.setResult(context.left).exit();
519
- return;
520
- }
521
- context.nested = !Array.isArray(context.delta);
522
- if (context.nested) {
523
- return;
524
- }
525
- const nonNestedDelta = context.delta;
526
- if (nonNestedDelta.length === 1) {
527
- context.setResult(nonNestedDelta[0]).exit();
528
- return;
529
- }
530
- if (nonNestedDelta.length === 2) {
531
- if (context.left instanceof RegExp) {
532
- const regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
533
- if (regexArgs) {
534
- context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
535
- return;
536
- }
537
- }
538
- context.setResult(nonNestedDelta[1]).exit();
2060
+ diffFilter.filterName = "trivial";
2061
+ var patchFilter = function trivialMatchesPatchFilter(context) {
2062
+ if (typeof context.delta === "undefined") {
2063
+ context.setResult(context.left).exit();
2064
+ return;
2065
+ }
2066
+ context.nested = !Array.isArray(context.delta);
2067
+ if (context.nested) {
2068
+ return;
2069
+ }
2070
+ const nonNestedDelta = context.delta;
2071
+ if (nonNestedDelta.length === 1) {
2072
+ context.setResult(nonNestedDelta[0]).exit();
2073
+ return;
2074
+ }
2075
+ if (nonNestedDelta.length === 2) {
2076
+ if (context.left instanceof RegExp) {
2077
+ const regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
2078
+ if (regexArgs) {
2079
+ context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
539
2080
  return;
2081
+ }
540
2082
  }
541
- if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
542
- context.setResult(undefined).exit();
543
- }
2083
+ context.setResult(nonNestedDelta[1]).exit();
2084
+ return;
2085
+ }
2086
+ if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
2087
+ context.setResult(void 0).exit();
2088
+ }
544
2089
  };
545
- patchFilter$1.filterName = "trivial";
2090
+ patchFilter.filterName = "trivial";
546
2091
 
547
- const collectChildrenDiffFilter = context => {
548
- if (!context || !context.children) {
549
- return;
550
- }
551
- const length = context.children.length;
552
- let child;
553
- let result = context.result;
554
- for (let index = 0; index < length; index++) {
555
- child = context.children[index];
556
- if (typeof child.result === "undefined") {
557
- continue;
558
- }
559
- result = result || {};
560
- result[child.childName] = child.result;
561
- }
562
- if (result && context.leftIsArray) {
563
- result._t = "a";
564
- }
565
- context.setResult(result).exit();
2092
+ // ../jsondiffpatch/dist/filters/nested.js
2093
+ var collectChildrenDiffFilter = (context) => {
2094
+ if (!context || !context.children) {
2095
+ return;
2096
+ }
2097
+ const length = context.children.length;
2098
+ let child;
2099
+ let result = context.result;
2100
+ for (let index = 0; index < length; index++) {
2101
+ child = context.children[index];
2102
+ if (typeof child.result === "undefined") {
2103
+ continue;
2104
+ }
2105
+ result = result || {};
2106
+ result[child.childName] = child.result;
2107
+ }
2108
+ if (result && context.leftIsArray) {
2109
+ result._t = "a";
2110
+ }
2111
+ context.setResult(result).exit();
566
2112
  };
567
2113
  collectChildrenDiffFilter.filterName = "collectChildren";
568
- const objectsDiffFilter = context => {
569
- if (context.leftIsArray || context.leftType !== "object") {
570
- return;
571
- }
572
- const left = context.left;
573
- const right = context.right;
574
- let name;
575
- let child;
576
- const propertyFilter = context.options.propertyFilter;
577
- for (name in left) {
578
- if (!Object.prototype.hasOwnProperty.call(left, name)) {
579
- continue;
580
- }
581
- if (propertyFilter && !propertyFilter(name, context)) {
582
- continue;
583
- }
584
- child = new DiffContext(left[name], right[name]);
585
- context.push(child, name);
2114
+ var objectsDiffFilter = (context) => {
2115
+ if (context.leftIsArray || context.leftType !== "object") {
2116
+ return;
2117
+ }
2118
+ const left = context.left;
2119
+ const right = context.right;
2120
+ let name;
2121
+ let child;
2122
+ const propertyFilter = context.options.propertyFilter;
2123
+ for (name in left) {
2124
+ if (!Object.prototype.hasOwnProperty.call(left, name)) {
2125
+ continue;
2126
+ }
2127
+ if (propertyFilter && !propertyFilter(name, context)) {
2128
+ continue;
2129
+ }
2130
+ child = new diff_default(left[name], right[name]);
2131
+ context.push(child, name);
2132
+ }
2133
+ for (name in right) {
2134
+ if (!Object.prototype.hasOwnProperty.call(right, name)) {
2135
+ continue;
586
2136
  }
587
- for (name in right) {
588
- if (!Object.prototype.hasOwnProperty.call(right, name)) {
589
- continue;
590
- }
591
- if (propertyFilter && !propertyFilter(name, context)) {
592
- continue;
593
- }
594
- if (typeof left[name] === "undefined") {
595
- child = new DiffContext(undefined, right[name]);
596
- context.push(child, name);
597
- }
2137
+ if (propertyFilter && !propertyFilter(name, context)) {
2138
+ continue;
598
2139
  }
599
- if (!context.children || context.children.length === 0) {
600
- context.setResult(undefined).exit();
601
- return;
2140
+ if (typeof left[name] === "undefined") {
2141
+ child = new diff_default(void 0, right[name]);
2142
+ context.push(child, name);
602
2143
  }
603
- context.exit();
2144
+ }
2145
+ if (!context.children || context.children.length === 0) {
2146
+ context.setResult(void 0).exit();
2147
+ return;
2148
+ }
2149
+ context.exit();
604
2150
  };
605
2151
  objectsDiffFilter.filterName = "objects";
606
- const patchFilter = function nestedPatchFilter(context) {
607
- if (!context.nested) {
608
- return;
609
- }
610
- const nestedDelta = context.delta;
611
- if (nestedDelta._t) {
612
- return;
613
- }
614
- const objectDelta = nestedDelta;
615
- let name;
616
- let child;
617
- for (name in objectDelta) {
618
- child = new PatchContext(context.left[name], objectDelta[name]);
619
- context.push(child, name);
620
- }
621
- context.exit();
2152
+ var patchFilter2 = function nestedPatchFilter(context) {
2153
+ if (!context.nested) {
2154
+ return;
2155
+ }
2156
+ const nestedDelta = context.delta;
2157
+ if (nestedDelta._t) {
2158
+ return;
2159
+ }
2160
+ const objectDelta = nestedDelta;
2161
+ let name;
2162
+ let child;
2163
+ for (name in objectDelta) {
2164
+ child = new patch_default(context.left[name], objectDelta[name]);
2165
+ context.push(child, name);
2166
+ }
2167
+ context.exit();
622
2168
  };
623
- patchFilter.filterName = "objects";
624
- const collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
625
- if (!context || !context.children) {
626
- return;
627
- }
628
- const deltaWithChildren = context.delta;
629
- if (deltaWithChildren._t) {
630
- return;
631
- }
632
- const object = context.left;
633
- const length = context.children.length;
634
- let child;
635
- for (let index = 0; index < length; index++) {
636
- child = context.children[index];
637
- const property = child.childName;
638
- if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
639
- delete object[property];
640
- }
641
- else if (object[property] !== child.result) {
642
- object[property] = child.result;
643
- }
2169
+ patchFilter2.filterName = "objects";
2170
+ var collectChildrenPatchFilter = function collectChildrenPatchFilter2(context) {
2171
+ if (!context || !context.children) {
2172
+ return;
2173
+ }
2174
+ const deltaWithChildren = context.delta;
2175
+ if (deltaWithChildren._t) {
2176
+ return;
2177
+ }
2178
+ const object = context.left;
2179
+ const length = context.children.length;
2180
+ let child;
2181
+ for (let index = 0; index < length; index++) {
2182
+ child = context.children[index];
2183
+ const property = child.childName;
2184
+ if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === void 0) {
2185
+ delete object[property];
2186
+ } else if (object[property] !== child.result) {
2187
+ object[property] = child.result;
644
2188
  }
645
- context.setResult(object).exit();
2189
+ }
2190
+ context.setResult(object).exit();
646
2191
  };
647
2192
  collectChildrenPatchFilter.filterName = "collectChildren";
648
2193
 
649
- const diffFilter = function datesDiffFilter(context) {
650
- if (context.left instanceof Date) {
651
- if (context.right instanceof Date) {
652
- if (context.left.getTime() !== context.right.getTime()) {
653
- context.setResult([context.left, context.right]);
654
- }
655
- else {
656
- context.setResult(undefined);
657
- }
658
- }
659
- else {
660
- context.setResult([context.left, context.right]);
661
- }
662
- context.exit();
663
- }
664
- else if (context.right instanceof Date) {
665
- context.setResult([context.left, context.right]).exit();
2194
+ // ../jsondiffpatch/dist/filters/dates.js
2195
+ var diffFilter2 = function datesDiffFilter(context) {
2196
+ if (context.left instanceof Date) {
2197
+ if (context.right instanceof Date) {
2198
+ if (context.left.getTime() !== context.right.getTime()) {
2199
+ context.setResult([context.left, context.right]);
2200
+ } else {
2201
+ context.setResult(void 0);
2202
+ }
2203
+ } else {
2204
+ context.setResult([context.left, context.right]);
666
2205
  }
2206
+ context.exit();
2207
+ } else if (context.right instanceof Date) {
2208
+ context.setResult([context.left, context.right]).exit();
2209
+ }
667
2210
  };
668
- diffFilter.filterName = "dates";
2211
+ diffFilter2.filterName = "dates";
669
2212
 
670
- class DiffPatcher {
671
- constructor(options) {
672
- this.processor = new Processor(options);
673
- this.processor.pipe(new Pipe("diff")
674
- .append(collectChildrenDiffFilter, diffFilter$1, diffFilter, objectsDiffFilter)
675
- .shouldHaveResult());
676
- this.processor.pipe(new Pipe("patch")
677
- .append(collectChildrenPatchFilter, patchFilter$1, patchFilter)
678
- .shouldHaveResult());
679
- }
680
- options(options) {
681
- return this.processor.options(options);
682
- }
683
- diff(left, right) {
684
- return this.processor.process(new DiffContext(left, right));
685
- }
686
- patch(left, delta) {
687
- return this.processor.process(new PatchContext(left, delta));
688
- }
689
- }
2213
+ // ../jsondiffpatch/dist/diffpatcher.js
2214
+ var DiffPatcher = class {
2215
+ constructor(options) {
2216
+ this.processor = new processor_default(options);
2217
+ this.processor.pipe(new pipe_default("diff").append(collectChildrenDiffFilter, diffFilter, diffFilter2, objectsDiffFilter).shouldHaveResult());
2218
+ this.processor.pipe(new pipe_default("patch").append(collectChildrenPatchFilter, patchFilter, patchFilter2).shouldHaveResult());
2219
+ }
2220
+ options(options) {
2221
+ return this.processor.options(options);
2222
+ }
2223
+ diff(left, right) {
2224
+ return this.processor.process(new diff_default(left, right));
2225
+ }
2226
+ patch(left, delta) {
2227
+ return this.processor.process(new patch_default(left, delta));
2228
+ }
2229
+ };
2230
+ var diffpatcher_default = DiffPatcher;
690
2231
 
2232
+ // ../jsondiffpatch/dist/index.js
691
2233
  function create(options) {
692
- return new DiffPatcher(options);
2234
+ return new diffpatcher_default(options);
693
2235
  }
694
2236
 
695
- var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
696
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
697
- return new (P || (P = Promise))(function (resolve, reject) {
698
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
699
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
700
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
701
- step((generator = generator.apply(thisArg, _arguments || [])).next());
702
- });
703
- };
704
- const diff = create();
705
- const defaultConfig = {
706
- writeKey: null,
707
- host: null,
708
- debug: false,
709
- fetch: null,
710
- echoEvents: false,
711
- cookieDomain: undefined,
712
- cookieNames: {},
713
- cookieCapture: {},
714
- runtime: undefined,
715
- fetchTimeoutMs: undefined,
716
- s2s: undefined,
717
- idEndpoint: undefined,
718
- errorPolicy: "log",
719
- defaultPayloadContext: {},
720
- privacy: {
721
- dontSend: false,
722
- disableUserIds: false,
723
- ipPolicy: "keep",
724
- consentCategories: {},
725
- },
2237
+ // src/analytics-plugin.ts
2238
+ var diff = create();
2239
+ var defaultConfig = {
2240
+ /* Your segment writeKey */
2241
+ writeKey: void 0,
2242
+ /* Disable anonymous MTU */
2243
+ host: void 0,
2244
+ debug: false,
2245
+ fetch: void 0,
2246
+ echoEvents: false,
2247
+ cookieDomain: void 0,
2248
+ cookieNames: {},
2249
+ cookieCapture: {},
2250
+ runtime: void 0,
2251
+ fetchTimeoutMs: void 0,
2252
+ s2s: void 0,
2253
+ idEndpoint: void 0,
2254
+ errorPolicy: "log",
2255
+ defaultPayloadContext: {},
2256
+ privacy: {
2257
+ dontSend: false,
2258
+ disableUserIds: false,
2259
+ ipPolicy: "keep",
2260
+ consentCategories: {}
2261
+ }
726
2262
  };
727
- const mergeConfig = (current, newConfig) => {
728
- for (const key of Object.keys(defaultConfig)) {
729
- const value = newConfig[key];
730
- if (key === "privacy") {
731
- if (typeof value === "object") {
732
- current.privacy = Object.assign(Object.assign(Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) }), current.privacy), value);
733
- }
734
- else if (typeof value === "undefined") {
735
- if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
736
- current.privacy = Object.assign(Object.assign({}, defaultConfig.privacy), { consentCategories: Object.assign({}, defaultConfig.privacy.consentCategories) });
737
- }
738
- }
739
- }
740
- else if (typeof value === "undefined") {
741
- if (newConfig.hasOwnProperty(key) || !current.hasOwnProperty(key)) {
742
- current[key] = defaultConfig[key];
743
- }
744
- }
745
- else {
746
- current[key] = value;
2263
+ var mergeConfig = (current, newConfig) => {
2264
+ for (const key of Object.keys(defaultConfig)) {
2265
+ const value = newConfig[key];
2266
+ if (key === "privacy") {
2267
+ if (typeof value === "object") {
2268
+ current.privacy = __spreadValues(__spreadValues(__spreadProps(__spreadValues({}, defaultConfig.privacy), {
2269
+ consentCategories: __spreadValues({}, defaultConfig.privacy.consentCategories)
2270
+ }), current.privacy), value);
2271
+ } else if (typeof value === "undefined") {
2272
+ if (newConfig.hasOwnProperty("privacy") || !current.hasOwnProperty("privacy")) {
2273
+ current.privacy = __spreadProps(__spreadValues({}, defaultConfig.privacy), {
2274
+ consentCategories: __spreadValues({}, defaultConfig.privacy.consentCategories)
2275
+ });
747
2276
  }
2277
+ }
2278
+ } else if (typeof value === "undefined") {
2279
+ if (newConfig.hasOwnProperty(key) || !current.hasOwnProperty(key)) {
2280
+ current[key] = defaultConfig[key];
2281
+ }
2282
+ } else {
2283
+ current[key] = value;
748
2284
  }
2285
+ }
749
2286
  };
750
- const parseQuery = (qs) => {
751
- if (!qs) {
752
- return {};
753
- }
754
- let queryString = qs.length > 0 && qs.charAt(0) === "?" ? qs.substring(1) : qs;
755
- let query = {};
756
- let pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
757
- for (let i = 0; i < pairs.length; i++) {
758
- let pair = pairs[i].split("=");
759
- query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
760
- }
761
- return query;
2287
+ var parseQuery = (qs) => {
2288
+ if (!qs) {
2289
+ return {};
2290
+ }
2291
+ let queryString = qs.length > 0 && qs.charAt(0) === "?" ? qs.substring(1) : qs;
2292
+ let query = {};
2293
+ let pairs = (queryString[0] === "?" ? queryString.substr(1) : queryString).split("&");
2294
+ for (let i4 = 0; i4 < pairs.length; i4++) {
2295
+ let pair = pairs[i4].split("=");
2296
+ query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
2297
+ }
2298
+ return query;
762
2299
  };
763
2300
  function utmToKey(key) {
764
- const name = key.substring("utm_".length);
765
- return name === "campaign" ? "name" : name;
2301
+ const name = key.substring("utm_".length);
2302
+ return name === "campaign" ? "name" : name;
766
2303
  }
767
2304
  function parseUtms(query) {
768
- return Object.entries(query)
769
- .filter(([key]) => key.indexOf("utm_") === 0)
770
- .reduce((acc, [key, value]) => (Object.assign(Object.assign({}, acc), { [utmToKey(key)]: value })), {});
2305
+ return Object.entries(query).filter(([key]) => key.indexOf("utm_") === 0).reduce(
2306
+ (acc, [key, value]) => __spreadProps(__spreadValues({}, acc), {
2307
+ [utmToKey(key)]: value
2308
+ }),
2309
+ {}
2310
+ );
771
2311
  }
772
- function safeCall(f, defaultVal) {
773
- try {
774
- return f();
775
- }
776
- catch (e) {
777
- return defaultVal;
778
- }
2312
+ function safeCall(f2, defaultVal) {
2313
+ try {
2314
+ return f2();
2315
+ } catch (e2) {
2316
+ return defaultVal;
2317
+ }
779
2318
  }
780
2319
  function restoreTraits(storage) {
781
- let val = storage.getItem("__user_traits");
782
- if (typeof val === "string") {
783
- val = safeCall(() => JSON.parse(val), {});
784
- }
785
- if (typeof val !== "object" || val === null || Array.isArray(val)) {
786
- val = {};
787
- }
788
- let groupVal = storage.getItem("__group_traits");
789
- if (typeof groupVal === "string") {
790
- groupVal = safeCall(() => JSON.parse(groupVal), {});
791
- }
792
- if (typeof groupVal !== "object" || groupVal === null || Array.isArray(groupVal)) {
793
- groupVal = {};
794
- }
795
- return Object.assign(Object.assign({}, (groupVal || {})), (val || {}));
2320
+ let val = storage.getItem("__user_traits");
2321
+ if (typeof val === "string") {
2322
+ val = safeCall(() => JSON.parse(val), {});
2323
+ }
2324
+ if (typeof val !== "object" || val === null || Array.isArray(val)) {
2325
+ val = {};
2326
+ }
2327
+ let groupVal = storage.getItem("__group_traits");
2328
+ if (typeof groupVal === "string") {
2329
+ groupVal = safeCall(() => JSON.parse(groupVal), {});
2330
+ }
2331
+ if (typeof groupVal !== "object" || groupVal === null || Array.isArray(groupVal)) {
2332
+ groupVal = {};
2333
+ }
2334
+ return __spreadValues(__spreadValues({}, groupVal || {}), val || {});
796
2335
  }
797
2336
  function getCookie(name) {
798
- const value = `; ${document.cookie}`;
799
- const parts = value.split(`; ${name}=`);
800
- return parts.length === 2 ? parts.pop().split(";").shift() : undefined;
2337
+ var _a;
2338
+ const value = `; ${document.cookie}`;
2339
+ const parts = value.split(`; ${name}=`);
2340
+ return parts.length === 2 ? (_a = parts.pop()) == null ? void 0 : _a.split(";").shift() : void 0;
801
2341
  }
802
2342
  function getClientIds(runtime, customCookieCapture) {
803
- const cookieCapture = Object.assign({ fbc: "_fbc", fbp: "_fbp" }, customCookieCapture);
804
- const clientIds = Object.entries(cookieCapture).reduce((acc, [key, cookieName]) => {
805
- acc[key] = runtime.getCookie(cookieName);
806
- return acc;
807
- }, {});
808
- return Object.assign(Object.assign({}, clientIds), getGa4Ids(runtime));
809
- }
810
- function parseGa4SessionId(cookieValue) {
811
- if (typeof cookieValue !== "string") {
812
- return undefined;
813
- }
814
- if (cookieValue.startsWith("GA1") || cookieValue.startsWith("GS1")) {
815
- return cookieValue.split(".")[2];
816
- }
817
- else {
818
- const match = cookieValue.match(/^GS\d+\.\d+\.(?:[\w_-]+[$])*s(\d+)(?:$|[$])/);
819
- return match ? match[1] : undefined;
820
- }
2343
+ const cookieCapture = __spreadValues({
2344
+ fbc: "_fbc",
2345
+ fbp: "_fbp"
2346
+ }, customCookieCapture);
2347
+ const clientIds = Object.entries(cookieCapture).reduce((acc, [key, cookieName]) => {
2348
+ acc[key] = runtime.getCookie(cookieName);
2349
+ return acc;
2350
+ }, {});
2351
+ return __spreadValues(__spreadValues({}, clientIds), getGa4Ids(runtime));
2352
+ }
2353
+ function parseGa4SessionId(cookieValue) {
2354
+ if (typeof cookieValue !== "string") {
2355
+ return void 0;
2356
+ }
2357
+ if (cookieValue.startsWith("GA1") || cookieValue.startsWith("GS1")) {
2358
+ return cookieValue.split(".")[2];
2359
+ } else {
2360
+ const match = cookieValue.match(/^GS\d+\.\d+\.(?:[\w_-]+[$])*s(\d+)(?:$|[$])/);
2361
+ return match ? match[1] : void 0;
2362
+ }
821
2363
  }
822
2364
  function getGa4Ids(runtime) {
823
- var _a;
824
- const allCookies = runtime.getCookies();
825
- const clientId = (_a = allCookies["_ga"]) === null || _a === void 0 ? void 0 : _a.split(".").slice(-2).join(".");
826
- const gaSessionCookies = Object.entries(allCookies).filter(([key]) => key.startsWith("_ga_"));
827
- const sessionIds = gaSessionCookies.length > 0
828
- ? Object.fromEntries(gaSessionCookies
829
- .map(([key, value]) => {
830
- const sessionId = parseGa4SessionId(value);
831
- if (!sessionId) {
832
- return null;
833
- }
834
- return [key.substring("_ga_".length), sessionId];
835
- })
836
- .filter(v => v !== null))
837
- : undefined;
838
- if (clientId || sessionIds) {
839
- return { ga4: { clientId, sessionIds } };
840
- }
841
- else {
842
- return undefined;
843
- }
2365
+ var _a;
2366
+ const allCookies = runtime.getCookies();
2367
+ const clientId = (_a = allCookies["_ga"]) == null ? void 0 : _a.split(".").slice(-2).join(".");
2368
+ const gaSessionCookies = Object.entries(allCookies).filter(([key]) => key.startsWith("_ga_"));
2369
+ const sessionIds = gaSessionCookies.length > 0 ? Object.fromEntries(
2370
+ gaSessionCookies.map(([key, value]) => {
2371
+ const sessionId = parseGa4SessionId(value);
2372
+ if (!sessionId) {
2373
+ return null;
2374
+ }
2375
+ return [key.substring("_ga_".length), sessionId];
2376
+ }).filter((v2) => v2 !== null)
2377
+ ) : void 0;
2378
+ if (clientId || sessionIds) {
2379
+ return { ga4: { clientId, sessionIds } };
2380
+ } else {
2381
+ return void 0;
2382
+ }
844
2383
  }
845
2384
  function removeCookie(name, { domain, secure }) {
846
- document.cookie =
847
- name +
848
- "=;domain=" +
849
- domain +
850
- ";path=/" +
851
- ";expires=Thu, 01 Jan 1970 00:00:01 GMT;SameSite=" +
852
- (secure ? "None" : "Lax") +
853
- (secure ? ";secure" : "");
2385
+ document.cookie = name + "=;domain=" + domain + ";path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;SameSite=" + (secure ? "None" : "Lax") + (secure ? ";secure" : "");
854
2386
  }
855
2387
  function setCookie(name, val, { domain, secure }) {
856
- document.cookie =
857
- name +
858
- "=" +
859
- val +
860
- ";domain=" +
861
- domain +
862
- ";path=/" +
863
- ";expires=" +
864
- new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 365 * 5).toUTCString() +
865
- ";SameSite=" +
866
- (secure ? "None" : "Lax") +
867
- (secure ? ";secure" : "");
868
- }
869
- const defaultCookie2Key = {
870
- __anon_id: "__eventn_id",
871
- __user_id: "__eventn_uid",
872
- __user_traits: "__eventn_id_usr",
873
- __group_id: "__group_id",
874
- __group_traits: "__group_traits",
875
- };
876
- const cookieStorage = (cookieDomain, key2cookie) => {
877
- return {
878
- setItem(key, val) {
879
- const cookieName = key2cookie(key) || key;
880
- if (typeof val === "undefined") {
881
- removeCookie(cookieName, {
882
- domain: cookieDomain,
883
- secure: window.location.protocol === "https:",
884
- });
885
- return;
886
- }
887
- const strVal = typeof val === "object" && val !== null ? encodeURIComponent(JSON.stringify(val)) : val;
888
- setCookie(cookieName, strVal, {
889
- domain: cookieDomain,
890
- secure: window.location.protocol === "https:",
891
- });
892
- },
893
- getItem(key) {
894
- const cookieName = key2cookie(key) || key;
895
- const result = getCookie(cookieName);
896
- if (key === "__anon_id") {
897
- return result;
898
- }
899
- if (typeof result === "undefined" && key === "__user_id") {
900
- const traits = parse(getCookie(key2cookie("__user_traits") || "__eventn_id_usr")) || {};
901
- return traits.internal_id || traits.user_id || traits.id || traits.userId;
902
- }
903
- return parse(result);
904
- },
905
- removeItem(key) {
906
- removeCookie(key2cookie(key) || key, {
907
- domain: cookieDomain,
908
- secure: window.location.protocol === "https:",
909
- });
910
- },
911
- reset() {
912
- for (const key of Object.keys(defaultCookie2Key)) {
913
- removeCookie(key2cookie(key) || key, {
914
- domain: cookieDomain,
915
- secure: window.location.protocol === "https:",
916
- });
917
- }
918
- },
919
- };
920
- };
921
- function windowRuntime(opts) {
922
- const key2Cookie = (key) => {
923
- var _a, _b, _c, _d, _e;
924
- switch (key) {
925
- case "__anon_id":
926
- return ((_a = opts.cookieNames) === null || _a === void 0 ? void 0 : _a.anonymousId) || defaultCookie2Key.__anon_id;
927
- case "__user_id":
928
- return ((_b = opts.cookieNames) === null || _b === void 0 ? void 0 : _b.userId) || defaultCookie2Key.__user_id;
929
- case "__user_traits":
930
- return ((_c = opts.cookieNames) === null || _c === void 0 ? void 0 : _c.userTraits) || defaultCookie2Key.__user_traits;
931
- case "__group_id":
932
- return ((_d = opts.cookieNames) === null || _d === void 0 ? void 0 : _d.groupId) || defaultCookie2Key.__group_id;
933
- case "__group_traits":
934
- return ((_e = opts.cookieNames) === null || _e === void 0 ? void 0 : _e.groupTraits) || defaultCookie2Key.__group_traits;
935
- default:
936
- return key;
937
- }
938
- };
939
- return {
940
- getCookie(name) {
941
- const value = `; ${document.cookie}`;
942
- const parts = value.split(`; ${name}=`);
943
- return parts.length === 2 ? parts.pop().split(";").shift() : undefined;
944
- },
945
- getCookies() {
946
- const value = `; ${document.cookie}`;
947
- const cookies = {};
948
- const matches = value.matchAll(/(\w+)=([^;]+)/g);
949
- for (const match of matches) {
950
- cookies[match[1]] = match[2];
951
- }
952
- return cookies;
953
- },
954
- documentEncoding() {
955
- return window.document.characterSet;
956
- },
957
- timezoneOffset() {
958
- return new Date().getTimezoneOffset();
959
- },
960
- store() {
961
- return cookieStorage(opts.cookieDomain || getTopLevelDomain(window.location.hostname), key2Cookie);
962
- },
963
- language() {
964
- return window.navigator.language;
965
- },
966
- pageTitle() {
967
- return window.document.title;
968
- },
969
- pageUrl() {
970
- return window.location.href;
971
- },
972
- referrer() {
973
- return window.document.referrer;
974
- },
975
- screen() {
976
- return {
977
- width: window.screen.width,
978
- height: window.screen.height,
979
- innerWidth: window.innerWidth,
980
- innerHeight: window.innerHeight,
981
- density: Math.floor(window.devicePixelRatio),
982
- };
983
- },
984
- userAgent() {
985
- return window.navigator.userAgent;
986
- },
987
- };
988
- }
989
- function createInMemoryStorage(debug) {
990
- const storage = {};
991
- return {
992
- reset() {
993
- Object.keys(storage).forEach(key => delete storage[key]);
994
- },
995
- setItem(key, val) {
996
- if (debug) {
997
- console.log(`[JITSU EMPTY RUNTIME] Set storage item ${key}=${JSON.stringify(val)}`);
998
- }
999
- if (typeof val === "undefined") {
1000
- delete storage[key];
1001
- }
1002
- else {
1003
- storage[key] = val;
1004
- }
1005
- },
1006
- getItem(key) {
1007
- const val = storage[key];
1008
- if (debug) {
1009
- console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${JSON.stringify(val)}`);
1010
- }
1011
- return val;
1012
- },
1013
- removeItem(key) {
1014
- if (debug) {
1015
- console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${storage[key]}`);
1016
- }
1017
- delete storage[key];
1018
- },
1019
- };
2388
+ document.cookie = name + "=" + val + ";domain=" + domain + ";path=/;expires=" + new Date((/* @__PURE__ */ new Date()).getTime() + 1e3 * 60 * 60 * 24 * 365 * 5).toUTCString() + ";SameSite=" + (secure ? "None" : "Lax") + (secure ? ";secure" : "");
1020
2389
  }
1021
- const emptyRuntime = (config) => ({
1022
- documentEncoding() {
1023
- return undefined;
2390
+ var defaultCookie2Key = {
2391
+ __anon_id: "__eventn_id",
2392
+ __user_id: "__eventn_uid",
2393
+ __user_traits: "__eventn_id_usr",
2394
+ __group_id: "__group_id",
2395
+ __group_traits: "__group_traits"
2396
+ };
2397
+ var cookieStorage = (cookieDomain, key2cookie) => {
2398
+ return {
2399
+ setItem(key, val) {
2400
+ const cookieName = key2cookie(key) || key;
2401
+ if (typeof val === "undefined") {
2402
+ removeCookie(cookieName, {
2403
+ domain: cookieDomain,
2404
+ secure: window.location.protocol === "https:"
2405
+ });
2406
+ return;
2407
+ }
2408
+ const strVal = typeof val === "object" && val !== null ? encodeURIComponent(JSON.stringify(val)) : val;
2409
+ setCookie(cookieName, strVal, {
2410
+ domain: cookieDomain,
2411
+ secure: window.location.protocol === "https:"
2412
+ });
1024
2413
  },
1025
- timezoneOffset() {
1026
- return undefined;
2414
+ getItem(key) {
2415
+ const cookieName = key2cookie(key) || key;
2416
+ const result = getCookie(cookieName);
2417
+ if (key === "__anon_id") {
2418
+ return result;
2419
+ }
2420
+ if (typeof result === "undefined" && key === "__user_id") {
2421
+ const traits = parse(getCookie(key2cookie("__user_traits") || "__eventn_id_usr")) || {};
2422
+ return traits.internal_id || traits.user_id || traits.id || traits.userId;
2423
+ }
2424
+ return parse(result);
2425
+ },
2426
+ removeItem(key) {
2427
+ removeCookie(key2cookie(key) || key, {
2428
+ domain: cookieDomain,
2429
+ secure: window.location.protocol === "https:"
2430
+ });
1027
2431
  },
2432
+ reset() {
2433
+ for (const key of Object.keys(defaultCookie2Key)) {
2434
+ removeCookie(key2cookie(key) || key, {
2435
+ domain: cookieDomain,
2436
+ secure: window.location.protocol === "https:"
2437
+ });
2438
+ }
2439
+ }
2440
+ };
2441
+ };
2442
+ function windowRuntime(opts) {
2443
+ const key2Cookie = (key) => {
2444
+ var _a, _b, _c, _d, _e2;
2445
+ switch (key) {
2446
+ case "__anon_id":
2447
+ return ((_a = opts.cookieNames) == null ? void 0 : _a.anonymousId) || defaultCookie2Key.__anon_id;
2448
+ case "__user_id":
2449
+ return ((_b = opts.cookieNames) == null ? void 0 : _b.userId) || defaultCookie2Key.__user_id;
2450
+ case "__user_traits":
2451
+ return ((_c = opts.cookieNames) == null ? void 0 : _c.userTraits) || defaultCookie2Key.__user_traits;
2452
+ case "__group_id":
2453
+ return ((_d = opts.cookieNames) == null ? void 0 : _d.groupId) || defaultCookie2Key.__group_id;
2454
+ case "__group_traits":
2455
+ return ((_e2 = opts.cookieNames) == null ? void 0 : _e2.groupTraits) || defaultCookie2Key.__group_traits;
2456
+ default:
2457
+ return key;
2458
+ }
2459
+ };
2460
+ return {
1028
2461
  getCookie(name) {
1029
- return undefined;
2462
+ var _a;
2463
+ const value = `; ${document.cookie}`;
2464
+ const parts = value.split(`; ${name}=`);
2465
+ return parts.length === 2 ? (_a = parts.pop()) == null ? void 0 : _a.split(";").shift() : void 0;
1030
2466
  },
1031
2467
  getCookies() {
1032
- return {};
2468
+ const value = `; ${document.cookie}`;
2469
+ const cookies = {};
2470
+ const matches = value.matchAll(/(\w+)=([^;]+)/g);
2471
+ for (const match of matches) {
2472
+ cookies[match[1]] = match[2];
2473
+ }
2474
+ return cookies;
2475
+ },
2476
+ documentEncoding() {
2477
+ return window.document.characterSet;
2478
+ },
2479
+ timezoneOffset() {
2480
+ return (/* @__PURE__ */ new Date()).getTimezoneOffset();
1033
2481
  },
1034
2482
  store() {
1035
- return createInMemoryStorage(config.debug);
2483
+ return cookieStorage(opts.cookieDomain || getTopLevelDomain(window.location.hostname), key2Cookie);
1036
2484
  },
1037
2485
  language() {
1038
- return undefined;
2486
+ return window.navigator.language;
1039
2487
  },
1040
2488
  pageTitle() {
1041
- return undefined;
2489
+ return window.document.title;
1042
2490
  },
1043
2491
  pageUrl() {
1044
- return undefined;
2492
+ return window.location.href;
1045
2493
  },
1046
2494
  referrer() {
1047
- return undefined;
2495
+ return window.document.referrer;
1048
2496
  },
1049
2497
  screen() {
1050
- return undefined;
2498
+ return {
2499
+ width: window.screen.width,
2500
+ height: window.screen.height,
2501
+ innerWidth: window.innerWidth,
2502
+ innerHeight: window.innerHeight,
2503
+ density: Math.floor(window.devicePixelRatio)
2504
+ };
1051
2505
  },
1052
2506
  userAgent() {
1053
- return undefined;
1054
- },
1055
- });
1056
- function deepCopy(o) {
1057
- if (typeof o !== "object") {
1058
- return o;
2507
+ return window.navigator.userAgent;
1059
2508
  }
1060
- if (!o) {
1061
- return o;
2509
+ };
2510
+ }
2511
+ function createInMemoryStorage(debug) {
2512
+ const storage = {};
2513
+ return {
2514
+ reset() {
2515
+ Object.keys(storage).forEach((key) => delete storage[key]);
2516
+ },
2517
+ setItem(key, val) {
2518
+ if (debug) {
2519
+ console.log(`[JITSU EMPTY RUNTIME] Set storage item ${key}=${JSON.stringify(val)}`);
2520
+ }
2521
+ if (typeof val === "undefined") {
2522
+ delete storage[key];
2523
+ } else {
2524
+ storage[key] = val;
2525
+ }
2526
+ },
2527
+ getItem(key) {
2528
+ const val = storage[key];
2529
+ if (debug) {
2530
+ console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${JSON.stringify(val)}`);
2531
+ }
2532
+ return val;
2533
+ },
2534
+ removeItem(key) {
2535
+ if (debug) {
2536
+ console.log(`[JITSU EMPTY RUNTIME] Get storage item ${key}=${storage[key]}`);
2537
+ }
2538
+ delete storage[key];
1062
2539
  }
1063
- return JSON.parse(JSON.stringify(o));
2540
+ };
2541
+ }
2542
+ var emptyRuntime = (config) => ({
2543
+ documentEncoding() {
2544
+ return void 0;
2545
+ },
2546
+ timezoneOffset() {
2547
+ return void 0;
2548
+ },
2549
+ getCookie(name) {
2550
+ return void 0;
2551
+ },
2552
+ getCookies() {
2553
+ return {};
2554
+ },
2555
+ store() {
2556
+ return createInMemoryStorage(config.debug);
2557
+ },
2558
+ language() {
2559
+ return void 0;
2560
+ },
2561
+ pageTitle() {
2562
+ return void 0;
2563
+ },
2564
+ pageUrl() {
2565
+ return void 0;
2566
+ },
2567
+ referrer() {
2568
+ return void 0;
2569
+ },
2570
+ screen() {
2571
+ return void 0;
2572
+ },
2573
+ userAgent() {
2574
+ return void 0;
2575
+ }
2576
+ });
2577
+ function deepCopy(o3) {
2578
+ if (typeof o3 !== "object") {
2579
+ return o3;
2580
+ }
2581
+ if (!o3) {
2582
+ return o3;
2583
+ }
2584
+ return JSON.parse(JSON.stringify(o3));
1064
2585
  }
1065
2586
  function deepMerge(target, source) {
1066
- if (typeof source !== "object" || source === null) {
1067
- return source;
1068
- }
1069
- if (typeof target !== "object" || target === null) {
1070
- return source;
1071
- }
1072
- return Object.entries(source).reduce((acc, [key, value]) => {
1073
- acc[key] = deepMerge(target[key], value);
1074
- return acc;
1075
- }, target);
2587
+ if (typeof source !== "object" || source === null || Array.isArray(source) || source instanceof Date) {
2588
+ return source;
2589
+ }
2590
+ if (typeof target !== "object" || target === null || Array.isArray(target) || target instanceof Date) {
2591
+ return source;
2592
+ }
2593
+ return Object.entries(source).reduce((acc, [key, value]) => {
2594
+ acc[key] = deepMerge(target[key], value);
2595
+ return acc;
2596
+ }, target);
1076
2597
  }
1077
2598
  function isInBrowser() {
1078
- return typeof document !== "undefined" && typeof window !== "undefined";
2599
+ return typeof document !== "undefined" && typeof window !== "undefined";
1079
2600
  }
1080
2601
  function fixPath(path) {
1081
- if (path.indexOf("//") === 0 && path.lastIndexOf("/") === 1) {
1082
- return "/";
1083
- }
1084
- return path;
2602
+ if (path.indexOf("//") === 0 && path.lastIndexOf("/") === 1) {
2603
+ return "/";
2604
+ }
2605
+ return path;
1085
2606
  }
1086
- const hashRegex = /#.*$/;
2607
+ var hashRegex = /#.*$/;
1087
2608
  function urlPath(url) {
1088
- const regex = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g;
1089
- const matches = regex.exec(url);
1090
- const pathMatch = matches && matches[3] ? matches[3].split("?")[0].replace(hashRegex, "") : "";
1091
- return "/" + pathMatch;
2609
+ const regex = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g;
2610
+ const matches = regex.exec(url);
2611
+ const pathMatch = matches && matches[3] ? matches[3].split("?")[0].replace(hashRegex, "") : "";
2612
+ return "/" + pathMatch;
1092
2613
  }
1093
2614
  function canonicalUrl() {
1094
- if (!isInBrowser())
1095
- return;
1096
- const tags = document.getElementsByTagName("link");
1097
- for (var i = 0, tag; (tag = tags[i]); i++) {
1098
- if (tag.getAttribute("rel") === "canonical") {
1099
- return tag.getAttribute("href");
1100
- }
2615
+ if (!isInBrowser()) return;
2616
+ const tags = document.getElementsByTagName("link");
2617
+ for (var i4 = 0, tag; tag = tags[i4]; i4++) {
2618
+ if (tag.getAttribute("rel") === "canonical") {
2619
+ return tag.getAttribute("href");
1101
2620
  }
2621
+ }
1102
2622
  }
1103
2623
  function analyticsJsUrl() {
1104
- if (!isInBrowser())
1105
- return;
1106
- const canonical = canonicalUrl();
1107
- if (!canonical)
1108
- return window.location.href.replace(hashRegex, "");
1109
- return canonical.match(/\?/) ? canonical : canonical + window.location.search;
2624
+ if (!isInBrowser()) return;
2625
+ const canonical = canonicalUrl();
2626
+ if (!canonical) return window.location.href.replace(hashRegex, "");
2627
+ return canonical.match(/\?/) ? canonical : canonical + window.location.search;
1110
2628
  }
1111
2629
  function adjustPayload(payload, config, storage, s2s) {
1112
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1113
- const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
1114
- const url = runtime.pageUrl();
1115
- const parsedUrl = safeCall(() => new URL(url), undefined);
1116
- const query = parsedUrl ? parseQuery(parsedUrl.search) : {};
1117
- const properties = payload.properties || {};
1118
- if (payload.type === "page" && (properties.url || url)) {
1119
- let targetUrl = url || properties.url;
1120
- if (properties.url && properties.url !== analyticsJsUrl()) {
1121
- targetUrl = properties.url;
1122
- }
1123
- properties.url = targetUrl.replace(hashRegex, "");
1124
- properties.path = fixPath(urlPath(targetUrl));
1125
- }
1126
- const customContext = deepMerge(config.defaultPayloadContext, ((_a = payload.properties) === null || _a === void 0 ? void 0 : _a.context) || ((_b = payload.options) === null || _b === void 0 ? void 0 : _b.context) || {});
1127
- (_c = payload.properties) === null || _c === void 0 ? true : delete _c.context;
1128
- const referrer = runtime.referrer();
1129
- const context = {
1130
- library: {
1131
- name: jitsuLibraryName,
1132
- version: jitsuVersion,
1133
- env: isInBrowser() ? "browser" : "node",
1134
- },
1135
- consent: typeof ((_d = config.privacy) === null || _d === void 0 ? void 0 : _d.consentCategories) === "object" && Object.keys((_e = config.privacy) === null || _e === void 0 ? void 0 : _e.consentCategories).length
1136
- ? {
1137
- categoryPreferences: config.privacy.consentCategories,
1138
- }
1139
- : undefined,
1140
- userAgent: (_f = runtime.userAgent) === null || _f === void 0 ? void 0 : _f.call(runtime),
1141
- locale: (_g = runtime.language) === null || _g === void 0 ? void 0 : _g.call(runtime),
1142
- screen: (_h = runtime.screen) === null || _h === void 0 ? void 0 : _h.call(runtime),
1143
- ip: (_j = runtime === null || runtime === void 0 ? void 0 : runtime.ip) === null || _j === void 0 ? void 0 : _j.call(runtime),
1144
- traits: payload.type != "identify" && payload.type != "group"
1145
- ? Object.assign(Object.assign({}, (restoreTraits(storage) || {})), (((_k = payload === null || payload === void 0 ? void 0 : payload.options) === null || _k === void 0 ? void 0 : _k.traits) || {})) : undefined,
1146
- page: {
1147
- path: properties.path || (parsedUrl && parsedUrl.pathname),
1148
- referrer: referrer,
1149
- referring_domain: safeCall(() => referrer && new URL(referrer).hostname),
1150
- host: parsedUrl && parsedUrl.host,
1151
- search: properties.search || (parsedUrl && parsedUrl.search),
1152
- title: properties.title || runtime.pageTitle(),
1153
- url: properties.url || url,
1154
- encoding: properties.encoding || runtime.documentEncoding(),
1155
- },
1156
- clientIds: !((_l = config.privacy) === null || _l === void 0 ? void 0 : _l.disableUserIds) ? getClientIds(runtime, config.cookieCapture) : undefined,
1157
- campaign: parseUtms(query),
1158
- };
1159
- const withContext = Object.assign(Object.assign({}, payload), { userId: ((_m = payload === null || payload === void 0 ? void 0 : payload.options) === null || _m === void 0 ? void 0 : _m.userId) || (payload === null || payload === void 0 ? void 0 : payload.userId), anonymousId: ((_o = payload === null || payload === void 0 ? void 0 : payload.options) === null || _o === void 0 ? void 0 : _o.anonymousId) || (payload === null || payload === void 0 ? void 0 : payload.anonymousId), groupId: ((_p = payload === null || payload === void 0 ? void 0 : payload.options) === null || _p === void 0 ? void 0 : _p.groupId) || storage.getItem("__group_id"), timestamp: new Date().toISOString(), sentAt: new Date().toISOString(), messageId: randomId(properties.path || (parsedUrl && parsedUrl.pathname)), writeKey: maskWriteKey(config.writeKey), context: deepMerge(context, customContext) });
1160
- delete withContext.meta;
1161
- delete withContext.options;
1162
- if ((_q = config.privacy) === null || _q === void 0 ? void 0 : _q.disableUserIds) {
1163
- delete withContext.userId;
1164
- delete withContext.anonymousId;
1165
- delete withContext.context.traits;
1166
- delete withContext.groupId;
1167
- }
1168
- return withContext;
2630
+ var _a, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o;
2631
+ const runtime = config.runtime || (isInBrowser() ? windowRuntime(config) : emptyRuntime(config));
2632
+ const url = runtime.pageUrl();
2633
+ const parsedUrl = url ? safeCall(() => new URL(url), void 0) : void 0;
2634
+ const query = parsedUrl ? parseQuery(parsedUrl.search) : {};
2635
+ const properties = payload.properties || {};
2636
+ if (payload.type === "page" && (properties.url || url)) {
2637
+ let targetUrl = url || properties.url;
2638
+ if (properties.url && properties.url !== analyticsJsUrl()) {
2639
+ targetUrl = properties.url;
2640
+ }
2641
+ properties.url = targetUrl.replace(hashRegex, "");
2642
+ properties.path = fixPath(urlPath(targetUrl));
2643
+ }
2644
+ const customContext = deepMerge(
2645
+ config.defaultPayloadContext,
2646
+ ((_a = payload.properties) == null ? void 0 : _a.context) || ((_b = payload.options) == null ? void 0 : _b.context) || {}
2647
+ );
2648
+ (_c = payload.properties) == null ? true : delete _c.context;
2649
+ const referrer = runtime.referrer();
2650
+ const context = {
2651
+ library: {
2652
+ name: jitsuLibraryName,
2653
+ version: jitsuVersion,
2654
+ env: isInBrowser() ? "browser" : "node"
2655
+ },
2656
+ consent: typeof ((_d = config.privacy) == null ? void 0 : _d.consentCategories) === "object" && Object.keys((_e2 = config.privacy) == null ? void 0 : _e2.consentCategories).length ? {
2657
+ categoryPreferences: config.privacy.consentCategories
2658
+ } : void 0,
2659
+ userAgent: (_f = runtime.userAgent) == null ? void 0 : _f.call(runtime),
2660
+ locale: (_g = runtime.language) == null ? void 0 : _g.call(runtime),
2661
+ screen: (_h = runtime.screen) == null ? void 0 : _h.call(runtime),
2662
+ ip: (_i = runtime == null ? void 0 : runtime.ip) == null ? void 0 : _i.call(runtime),
2663
+ traits: payload.type != "identify" && payload.type != "group" ? __spreadValues(__spreadValues({}, restoreTraits(storage) || {}), ((_j = payload == null ? void 0 : payload.options) == null ? void 0 : _j.traits) || {}) : void 0,
2664
+ page: {
2665
+ path: properties.path || parsedUrl && parsedUrl.pathname,
2666
+ referrer,
2667
+ referring_domain: safeCall(() => referrer && new URL(referrer).hostname),
2668
+ host: parsedUrl && parsedUrl.host,
2669
+ search: properties.search || parsedUrl && parsedUrl.search,
2670
+ title: properties.title || runtime.pageTitle(),
2671
+ url: properties.url || url,
2672
+ encoding: properties.encoding || runtime.documentEncoding()
2673
+ },
2674
+ clientIds: !((_k = config.privacy) == null ? void 0 : _k.disableUserIds) ? getClientIds(runtime, config.cookieCapture || {}) : void 0,
2675
+ campaign: parseUtms(query)
2676
+ };
2677
+ const withContext = __spreadProps(__spreadValues({}, payload), {
2678
+ userId: ((_l = payload == null ? void 0 : payload.options) == null ? void 0 : _l.userId) || (payload == null ? void 0 : payload.userId),
2679
+ anonymousId: ((_m = payload == null ? void 0 : payload.options) == null ? void 0 : _m.anonymousId) || (payload == null ? void 0 : payload.anonymousId),
2680
+ groupId: ((_n2 = payload == null ? void 0 : payload.options) == null ? void 0 : _n2.groupId) || storage.getItem("__group_id"),
2681
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2682
+ sentAt: (/* @__PURE__ */ new Date()).toISOString(),
2683
+ messageId: randomId(properties.path || parsedUrl && parsedUrl.pathname),
2684
+ writeKey: maskWriteKey(config.writeKey),
2685
+ context: deepMerge(context, customContext)
2686
+ });
2687
+ delete withContext.meta;
2688
+ delete withContext.options;
2689
+ if ((_o = config.privacy) == null ? void 0 : _o.disableUserIds) {
2690
+ delete withContext.userId;
2691
+ delete withContext.anonymousId;
2692
+ delete withContext.context.traits;
2693
+ delete withContext.groupId;
2694
+ }
2695
+ return withContext;
1169
2696
  }
1170
2697
  function isDiff(obj) {
1171
- const keys = Object.keys(obj);
1172
- return keys.length === 1 && keys[0] === "__diff";
2698
+ const keys = Object.keys(obj);
2699
+ return keys.length === 1 && keys[0] === "__diff";
1173
2700
  }
1174
2701
  function processDestinations(destinations, method, originalEvent, debug, analyticsInstance) {
1175
- return __awaiter$1(this, void 0, void 0, function* () {
1176
- const promises = [];
1177
- for (const destination of destinations) {
1178
- let newEvents = [];
1179
- if (destination.newEvents) {
1180
- try {
1181
- newEvents = destination.newEvents.map(e => e === "same" ? deepCopy(originalEvent) : isDiff(e) ? diff.patch(deepCopy(originalEvent), e.__diff) : e);
1182
- }
1183
- catch (e) {
1184
- console.error(`[JITSU] Error applying '${destination.id}' changes to event: ${e === null || e === void 0 ? void 0 : e.message}`, e);
1185
- }
1186
- }
1187
- else {
1188
- newEvents = [deepCopy(originalEvent)];
2702
+ return __async(this, null, function* () {
2703
+ const promises = [];
2704
+ for (const destination of destinations) {
2705
+ let newEvents = [];
2706
+ if (destination.newEvents) {
2707
+ try {
2708
+ newEvents = destination.newEvents.map(
2709
+ (e2) => e2 === "same" ? deepCopy(originalEvent) : isDiff(e2) ? diff.patch(deepCopy(originalEvent), e2.__diff) : e2
2710
+ );
2711
+ } catch (e2) {
2712
+ console.error(`[JITSU] Error applying '${destination.id}' changes to event: ${e2 == null ? void 0 : e2.message}`, e2);
2713
+ }
2714
+ } else {
2715
+ newEvents = [deepCopy(originalEvent)];
2716
+ }
2717
+ const credentials = __spreadValues(__spreadValues({}, destination.credentials), destination.options);
2718
+ if (destination.deviceOptions.type === "internal-plugin") {
2719
+ const plugin = internalDestinationPlugins[destination.deviceOptions.name];
2720
+ if (plugin) {
2721
+ for (const event of newEvents) {
2722
+ try {
2723
+ promises.push(plugin.handle(__spreadProps(__spreadValues({}, credentials), { debug }), event));
2724
+ } catch (e2) {
2725
+ console.warn(
2726
+ `[JITSU] Error processing event with internal plugin '${destination.deviceOptions.name}': ${e2 == null ? void 0 : e2.message}`,
2727
+ e2
2728
+ );
1189
2729
  }
1190
- const credentials = Object.assign(Object.assign({}, destination.credentials), destination.options);
1191
- if (destination.deviceOptions.type === "internal-plugin") {
1192
- const plugin = internalDestinationPlugins[destination.deviceOptions.name];
1193
- if (plugin) {
1194
- for (const event of newEvents) {
1195
- try {
1196
- promises.push(plugin.handle(Object.assign(Object.assign({}, credentials), { debug }), event));
1197
- }
1198
- catch (e) {
1199
- console.warn(`[JITSU] Error processing event with internal plugin '${destination.deviceOptions.name}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
1200
- }
1201
- }
1202
- }
1203
- else {
1204
- console.warn(`[JITSU] Unknown internal plugin '${destination.deviceOptions.name}' for destination '${destination.id}'`);
1205
- }
2730
+ }
2731
+ } else {
2732
+ console.warn(
2733
+ `[JITSU] Unknown internal plugin '${destination.deviceOptions.name}' for destination '${destination.id}'`
2734
+ );
2735
+ }
2736
+ } else if (destination.deviceOptions.type === "analytics-plugin") {
2737
+ yield loadScript(destination.deviceOptions.packageCdn);
2738
+ const plugin = window[destination.deviceOptions.moduleVarName];
2739
+ if (!plugin) {
2740
+ console.warn(
2741
+ `[JITSU] Broken plugin '${destination.deviceOptions.packageCdn}' for destination '${destination.id}' - it doesn't export '${destination.deviceOptions.moduleVarName}' variable`
2742
+ );
2743
+ } else {
2744
+ let pluginInstance;
2745
+ try {
2746
+ pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
2747
+ } catch (e2) {
2748
+ console.warn(
2749
+ `[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e2 == null ? void 0 : e2.message}`,
2750
+ e2
2751
+ );
2752
+ }
2753
+ try {
2754
+ if (debug) {
2755
+ console.log(
2756
+ `[JITSU] Plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}' initialized with config:`,
2757
+ pluginInstance.config
2758
+ );
1206
2759
  }
1207
- else if (destination.deviceOptions.type === "analytics-plugin") {
1208
- yield loadScript(destination.deviceOptions.packageCdn);
1209
- const plugin = window[destination.deviceOptions.moduleVarName];
1210
- if (!plugin) {
1211
- console.warn(`[JITSU] Broken plugin '${destination.deviceOptions.packageCdn}' for destination '${destination.id}' - it doesn't export '${destination.deviceOptions.moduleVarName}' variable`);
1212
- }
1213
- else {
1214
- let pluginInstance;
1215
- try {
1216
- pluginInstance = (typeof plugin === "function" ? plugin : plugin.init)(credentials);
1217
- }
1218
- catch (e) {
1219
- console.warn(`[JITSU] Error creating plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
1220
- }
1221
- try {
1222
- if (debug) {
1223
- console.log(`[JITSU] Plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}' initialized with config:`, pluginInstance.config);
1224
- }
1225
- pluginInstance.initialize({ config: pluginInstance.config, instance: analyticsInstance });
1226
- }
1227
- catch (e) {
1228
- console.warn(`[JITSU] Error initializing plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}. Config: ${JSON.stringify(pluginInstance.config)}`, e);
1229
- continue;
1230
- }
1231
- if (pluginInstance[method]) {
1232
- for (const event of newEvents) {
1233
- try {
1234
- pluginInstance[method]({
1235
- payload: event,
1236
- config: pluginInstance.config,
1237
- instance: analyticsInstance,
1238
- });
1239
- }
1240
- catch (e) {
1241
- console.warn(`[JITSU] Error processing ${method}() with plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e === null || e === void 0 ? void 0 : e.message}`, e);
1242
- }
1243
- }
1244
- }
1245
- }
2760
+ pluginInstance.initialize({ config: pluginInstance.config, instance: analyticsInstance });
2761
+ } catch (e2) {
2762
+ console.warn(
2763
+ `[JITSU] Error initializing plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e2 == null ? void 0 : e2.message}. Config: ${JSON.stringify(pluginInstance.config)}`,
2764
+ e2
2765
+ );
2766
+ continue;
2767
+ }
2768
+ if (pluginInstance[method]) {
2769
+ for (const event of newEvents) {
2770
+ try {
2771
+ pluginInstance[method]({
2772
+ payload: event,
2773
+ config: pluginInstance.config,
2774
+ instance: analyticsInstance
2775
+ });
2776
+ } catch (e2) {
2777
+ console.warn(
2778
+ `[JITSU] Error processing ${method}() with plugin '${destination.deviceOptions.moduleVarName}@${destination.deviceOptions.packageCdn}' for destination '${destination.id}': ${e2 == null ? void 0 : e2.message}`,
2779
+ e2
2780
+ );
2781
+ }
1246
2782
  }
2783
+ }
1247
2784
  }
1248
- });
2785
+ }
2786
+ }
2787
+ });
1249
2788
  }
1250
2789
  function looksLikeCuid(id) {
1251
- return id.length === 25 && id.charAt(0) === "c";
2790
+ return id.length === 25 && id.charAt(0) === "c";
1252
2791
  }
1253
2792
  function validateWriteKey(writeKey) {
1254
- if (writeKey) {
1255
- const [, secret] = writeKey.split(":", 2);
1256
- if (!secret && !looksLikeCuid(writeKey)) {
1257
- throw new Error(`Legacy write key detected - ${writeKey}! This format doesn't work anymore, it should be 'key:secret'. Please download a new key from Jitsu UI`);
1258
- }
2793
+ if (writeKey) {
2794
+ const [, secret] = writeKey.split(":", 2);
2795
+ if (!secret && !looksLikeCuid(writeKey)) {
2796
+ throw new Error(
2797
+ `Legacy write key detected - ${writeKey}! This format doesn't work anymore, it should be 'key:secret'. Please download a new key from Jitsu UI`
2798
+ );
1259
2799
  }
1260
- return writeKey;
2800
+ }
2801
+ return writeKey;
1261
2802
  }
1262
2803
  function maskWriteKey(writeKey) {
1263
- if (writeKey) {
1264
- const [id, secret] = writeKey.split(":", 2);
1265
- if (secret) {
1266
- return `${id}:***`;
1267
- }
1268
- else {
1269
- return "***";
1270
- }
2804
+ if (writeKey) {
2805
+ const [id, secret] = writeKey.split(":", 2);
2806
+ if (secret) {
2807
+ return `${id}:***`;
2808
+ } else {
2809
+ return "***";
1271
2810
  }
1272
- return writeKey;
2811
+ }
2812
+ return writeKey;
1273
2813
  }
1274
2814
  function getErrorHandler(opts) {
1275
- const configuredHandler = opts.errorPolicy || "log";
1276
- if (typeof configuredHandler === "function") {
1277
- return configuredHandler;
1278
- }
1279
- else if (configuredHandler === "rethrow") {
1280
- return (msg, ...args) => {
1281
- throw new Error(msg);
1282
- };
1283
- }
1284
- else {
1285
- return (msg, ...args) => {
1286
- console.error(msg, ...args);
1287
- };
1288
- }
2815
+ const configuredHandler = opts.errorPolicy || "log";
2816
+ if (typeof configuredHandler === "function") {
2817
+ return configuredHandler;
2818
+ } else if (configuredHandler === "rethrow") {
2819
+ return (msg, ...args) => {
2820
+ throw new Error(msg);
2821
+ };
2822
+ } else {
2823
+ return (msg, ...args) => {
2824
+ console.error(msg, ...args);
2825
+ };
2826
+ }
1289
2827
  }
1290
2828
  function send(method, payload, jitsuConfig, instance, store) {
1291
- return __awaiter$1(this, void 0, void 0, function* () {
1292
- var _a, _b;
1293
- const s2s = !!jitsuConfig.s2s;
1294
- const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
1295
- const adjustedPayload = adjustPayload(payload, jitsuConfig, store);
1296
- if (jitsuConfig.echoEvents) {
1297
- console.log(`[JITSU DEBUG] sending '${method}' event:`, adjustedPayload);
1298
- return;
1299
- }
1300
- const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
1301
- const fetch = jitsuConfig.fetch || globalThis.fetch;
1302
- if (!fetch) {
1303
- throw new Error("Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope");
1304
- }
1305
- const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
1306
- const abortTimeout = jitsuConfig.fetchTimeoutMs
1307
- ? setTimeout(() => {
1308
- abortController.abort();
1309
- }, jitsuConfig.fetchTimeoutMs)
1310
- : undefined;
1311
- const authHeader = jitsuConfig.writeKey ? { "X-Write-Key": jitsuConfig.writeKey } : {};
1312
- const ipHeader = typeof ((_a = jitsuConfig.privacy) === null || _a === void 0 ? void 0 : _a.ipPolicy) === "undefined" || ((_b = jitsuConfig.privacy) === null || _b === void 0 ? void 0 : _b.ipPolicy) === "keep"
1313
- ? {}
1314
- : { "X-IP-Policy": jitsuConfig.privacy.ipPolicy };
1315
- let fetchResult;
1316
- try {
1317
- fetchResult = yield fetch(url, {
1318
- method: "POST",
1319
- headers: Object.assign(Object.assign(Object.assign({ "Content-Type": "application/json" }, authHeader), debugHeader), ipHeader),
1320
- body: JSON.stringify(adjustedPayload),
1321
- signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
1322
- });
1323
- if (abortTimeout) {
1324
- clearTimeout(abortTimeout);
1325
- }
2829
+ return __async(this, null, function* () {
2830
+ var _a, _b;
2831
+ const s2s = !!jitsuConfig.s2s;
2832
+ const debugHeader = jitsuConfig.debug ? { "X-Enable-Debug": "true" } : {};
2833
+ const adjustedPayload = adjustPayload(payload, jitsuConfig, store, s2s);
2834
+ if (jitsuConfig.echoEvents) {
2835
+ console.log(`[JITSU DEBUG] sending '${method}' event:`, adjustedPayload);
2836
+ return;
2837
+ }
2838
+ const url = s2s ? `${jitsuConfig.host}/api/s/s2s/${method}` : `${jitsuConfig.host}/api/s/${method}`;
2839
+ const fetch = jitsuConfig.fetch || globalThis.fetch;
2840
+ if (!fetch) {
2841
+ throw new Error(
2842
+ "Please specify fetch function in jitsu plugin initialization, fetch isn't available in global scope"
2843
+ );
2844
+ }
2845
+ const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : void 0;
2846
+ const abortTimeout = jitsuConfig.fetchTimeoutMs ? setTimeout(() => {
2847
+ abortController == null ? void 0 : abortController.abort();
2848
+ }, jitsuConfig.fetchTimeoutMs) : void 0;
2849
+ const authHeader = jitsuConfig.writeKey ? { "X-Write-Key": jitsuConfig.writeKey } : {};
2850
+ const ipHeader = typeof ((_a = jitsuConfig.privacy) == null ? void 0 : _a.ipPolicy) === "undefined" || ((_b = jitsuConfig.privacy) == null ? void 0 : _b.ipPolicy) === "keep" ? {} : { "X-IP-Policy": jitsuConfig.privacy.ipPolicy };
2851
+ let fetchResult;
2852
+ try {
2853
+ fetchResult = yield fetch(url, {
2854
+ method: "POST",
2855
+ headers: __spreadValues(__spreadValues(__spreadValues({
2856
+ "Content-Type": "application/json"
2857
+ }, authHeader), debugHeader), ipHeader),
2858
+ body: JSON.stringify(adjustedPayload),
2859
+ signal: abortController == null ? void 0 : abortController.signal
2860
+ });
2861
+ if (abortTimeout) {
2862
+ clearTimeout(abortTimeout);
2863
+ }
2864
+ } catch (e2) {
2865
+ getErrorHandler(jitsuConfig)(`Call to ${url} failed with error ${e2.message}`);
2866
+ return Promise.resolve();
2867
+ }
2868
+ let responseText;
2869
+ try {
2870
+ responseText = yield fetchResult.text();
2871
+ } catch (e2) {
2872
+ console.warn(
2873
+ `Can't read response text from ${url} (status - ${fetchResult.status} ${fetchResult.statusText}): ${e2 == null ? void 0 : e2.message}`
2874
+ );
2875
+ }
2876
+ if (jitsuConfig.debug) {
2877
+ console.log(
2878
+ `[JITSU DEBUG] ${url} replied ${fetchResult.status}: ${responseText}. Original payload:
2879
+ ${JSON.stringify(
2880
+ adjustedPayload,
2881
+ null,
2882
+ 2
2883
+ )}`
2884
+ );
2885
+ }
2886
+ if (!fetchResult.ok) {
2887
+ getErrorHandler(jitsuConfig)(
2888
+ `Call to ${url} failed with error: ${fetchResult.status} - ${fetchResult.statusText}: ${responseText}`
2889
+ );
2890
+ return Promise.resolve();
2891
+ }
2892
+ let responseJson;
2893
+ try {
2894
+ responseJson = JSON.parse(responseText);
2895
+ } catch (e2) {
2896
+ getErrorHandler(jitsuConfig)(`Can't parse JSON: ${responseText}: ${e2 == null ? void 0 : e2.message}`);
2897
+ return Promise.resolve();
2898
+ }
2899
+ if (responseJson.destinations && responseJson.destinations.length > 0) {
2900
+ if (jitsuConfig.s2s) {
2901
+ console.warn(
2902
+ `[JITSU] ${payload.type} responded with list of ${responseJson.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`,
2903
+ jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : void 0
2904
+ );
2905
+ } else {
2906
+ if (isInBrowser()) {
2907
+ if (jitsuConfig.debug) {
2908
+ console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
2909
+ }
2910
+ return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1326
2911
  }
1327
- catch (e) {
1328
- getErrorHandler(jitsuConfig)(`Call to ${url} failed with error ${e.message}`);
1329
- return Promise.resolve();
2912
+ }
2913
+ }
2914
+ return adjustedPayload;
2915
+ });
2916
+ }
2917
+ var controllingTraits = ["$doNotSend"];
2918
+ function stripControllingTraits(traits) {
2919
+ const res = __spreadValues({}, traits);
2920
+ for (const key of controllingTraits) {
2921
+ delete res[key];
2922
+ }
2923
+ return res;
2924
+ }
2925
+ var jitsuAnalyticsPlugin = (jitsuOptions = {}, storage) => {
2926
+ mergeConfig(jitsuOptions, jitsuOptions);
2927
+ return {
2928
+ name: "jitsu",
2929
+ config: jitsuOptions,
2930
+ initialize: (args) => __async(null, null, function* () {
2931
+ const { config } = args;
2932
+ if (config.debug) {
2933
+ console.debug("[JITSU DEBUG] Initializing Jitsu plugin with config: ", JSON.stringify(config, null, 2));
2934
+ }
2935
+ if (!config.host && !config.echoEvents) {
2936
+ throw new Error("Please specify host variable in jitsu plugin initialization, or set echoEvents to true");
2937
+ }
2938
+ validateWriteKey(config.writeKey);
2939
+ if (config.idEndpoint) {
2940
+ if (!isInBrowser()) {
2941
+ console.error(`[JITSU] 'idEndpoint' option can be used only in browser environment`);
2942
+ return;
1330
2943
  }
1331
- let responseText;
1332
2944
  try {
1333
- responseText = yield fetchResult.text();
1334
- }
1335
- catch (e) {
1336
- console.warn(`Can't read response text from ${url} (status - ${fetchResult.status} ${fetchResult.statusText}): ${e === null || e === void 0 ? void 0 : e.message}`);
2945
+ const fetch = config.fetch || globalThis.fetch;
2946
+ const controller = new AbortController();
2947
+ setTimeout(() => controller.abort(), 1e3);
2948
+ const domain = config.cookieDomain || getTopLevelDomain(window.location.hostname);
2949
+ const res = yield fetch(config.idEndpoint + "?domain=" + encodeURIComponent(domain), {
2950
+ credentials: "include",
2951
+ signal: controller.signal
2952
+ });
2953
+ if (!res.ok) {
2954
+ console.error(`[JITSU] Can't fetch idEndpoint: ${res.status} - ${res.statusText}`);
2955
+ } else if (config.debug) {
2956
+ console.log(`[JITSU DEBUG] Fetch idEndpoint: ${res.status}`);
2957
+ }
2958
+ } catch (e2) {
2959
+ console.error(`[JITSU] Can't fetch idEndpoint: ${e2.message}`);
1337
2960
  }
1338
- if (jitsuConfig.debug) {
1339
- console.log(`[JITSU DEBUG] ${url} replied ${fetchResult.status}: ${responseText}. Original payload:\n${JSON.stringify(adjustedPayload, null, 2)}`);
2961
+ }
2962
+ }),
2963
+ page: (args) => {
2964
+ var _a;
2965
+ const { payload, config, instance } = args;
2966
+ if ((_a = config.privacy) == null ? void 0 : _a.dontSend) {
2967
+ return;
2968
+ }
2969
+ return send("page", payload, config, instance, storage);
2970
+ },
2971
+ track: (args) => {
2972
+ var _a;
2973
+ const { payload, config, instance } = args;
2974
+ if ((_a = config.privacy) == null ? void 0 : _a.dontSend) {
2975
+ return;
2976
+ }
2977
+ return send("track", payload, config, instance, storage);
2978
+ },
2979
+ identify: (args) => {
2980
+ var _a, _b, _c;
2981
+ const { payload, config, instance } = args;
2982
+ if (((_a = config.privacy) == null ? void 0 : _a.dontSend) || ((_b = config.privacy) == null ? void 0 : _b.disableUserIds)) {
2983
+ return;
2984
+ }
2985
+ storage.setItem("__user_id", payload.userId);
2986
+ const doNotSend = (_c = payload.traits) == null ? void 0 : _c.$doNotSend;
2987
+ if (payload.traits && typeof payload.traits === "object") {
2988
+ payload.traits = stripControllingTraits(payload.traits);
2989
+ storage.setItem("__user_traits", payload.traits);
2990
+ }
2991
+ if (doNotSend) {
2992
+ return Promise.resolve();
2993
+ }
2994
+ return send("identify", payload, config, instance, storage);
2995
+ },
2996
+ reset: (args) => {
2997
+ const { config, instance } = args;
2998
+ storage.reset();
2999
+ if (config.debug) {
3000
+ console.log("[JITSU DEBUG] Resetting Jitsu plugin storage");
3001
+ }
3002
+ },
3003
+ methods: {
3004
+ //analytics doesn't support group as a base method, so we need to add it manually
3005
+ configure(newOptions) {
3006
+ var _a, _b, _c, _d;
3007
+ const idsWasDisabled = ((_a = jitsuOptions.privacy) == null ? void 0 : _a.disableUserIds) || ((_b = jitsuOptions.privacy) == null ? void 0 : _b.dontSend);
3008
+ mergeConfig(jitsuOptions, newOptions);
3009
+ const idsDisabledNow = ((_c = jitsuOptions.privacy) == null ? void 0 : _c.disableUserIds) || ((_d = jitsuOptions.privacy) == null ? void 0 : _d.dontSend);
3010
+ if (!idsDisabledNow && idsWasDisabled) {
3011
+ if (jitsuOptions.debug) {
3012
+ console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");
3013
+ }
3014
+ const instance = this.instance;
3015
+ const newAnonymousId = uuid();
3016
+ const userState = instance.user();
3017
+ if (userState) {
3018
+ userState.anonymousId = newAnonymousId;
3019
+ }
3020
+ storage.setItem("__anon_id", newAnonymousId);
3021
+ instance.setAnonymousId(newAnonymousId);
1340
3022
  }
1341
- if (!fetchResult.ok) {
1342
- getErrorHandler(jitsuConfig)(`Call to ${url} failed with error: ${fetchResult.status} - ${fetchResult.statusText}: ${responseText}`);
1343
- return Promise.resolve();
3023
+ },
3024
+ group(groupId, traits, options, callback) {
3025
+ var _a, _b;
3026
+ if (((_a = jitsuOptions.privacy) == null ? void 0 : _a.dontSend) || ((_b = jitsuOptions.privacy) == null ? void 0 : _b.disableUserIds)) {
3027
+ return;
1344
3028
  }
1345
- let responseJson;
1346
- try {
1347
- responseJson = JSON.parse(responseText);
3029
+ if (typeof groupId === "number") {
3030
+ groupId = groupId + "";
1348
3031
  }
1349
- catch (e) {
1350
- getErrorHandler(jitsuConfig)(`Can't parse JSON: ${responseText}: ${e === null || e === void 0 ? void 0 : e.message}`);
1351
- return Promise.resolve();
3032
+ const instance = this.instance;
3033
+ const user = instance.user();
3034
+ const userId = (options == null ? void 0 : options.userId) || (user == null ? void 0 : user.userId);
3035
+ const anonymousId = (options == null ? void 0 : options.anonymousId) || (user == null ? void 0 : user.anonymousId) || storage.getItem("__anon_id");
3036
+ storage.setItem("__group_id", groupId);
3037
+ const doNotSend = traits == null ? void 0 : traits.$doNotSend;
3038
+ if (traits && typeof traits === "object") {
3039
+ traits = stripControllingTraits(traits);
3040
+ storage.setItem("__group_traits", traits);
1352
3041
  }
1353
- if (responseJson.destinations && responseJson.destinations.length > 0) {
1354
- if (jitsuConfig.s2s) {
1355
- console.warn(`[JITSU] ${payload.type} responded with list of ${responseJson.destinations.length} destinations. However, this code is running in server-to-server mode, so destinations will be ignored`, jitsuConfig.debug ? JSON.stringify(responseJson.destinations, null, 2) : undefined);
1356
- }
1357
- else {
1358
- if (isInBrowser()) {
1359
- if (jitsuConfig.debug) {
1360
- console.log(`[JITSU] Processing device destinations: `, JSON.stringify(responseJson.destinations, null, 2));
1361
- }
1362
- return processDestinations(responseJson.destinations, method, adjustedPayload, !!jitsuConfig.debug, instance);
1363
- }
1364
- }
3042
+ if (doNotSend) {
3043
+ return Promise.resolve();
1365
3044
  }
1366
- return adjustedPayload;
1367
- });
1368
- }
1369
- const controllingTraits = ["$doNotSend"];
1370
- function stripControllingTraits(traits) {
1371
- const res = Object.assign({}, traits);
1372
- for (const key of controllingTraits) {
1373
- delete res[key];
1374
- }
1375
- return res;
1376
- }
1377
- const jitsuAnalyticsPlugin = (jitsuOptions = {}, storage) => {
1378
- mergeConfig(jitsuOptions, jitsuOptions);
1379
- return {
1380
- name: "jitsu",
1381
- config: jitsuOptions,
1382
- initialize: (args) => __awaiter$1(void 0, void 0, void 0, function* () {
1383
- const { config } = args;
1384
- if (config.debug) {
1385
- console.debug("[JITSU DEBUG] Initializing Jitsu plugin with config: ", JSON.stringify(config, null, 2));
1386
- }
1387
- if (!config.host && !config.echoEvents) {
1388
- throw new Error("Please specify host variable in jitsu plugin initialization, or set echoEvents to true");
1389
- }
1390
- validateWriteKey(config.writeKey);
1391
- if (config.idEndpoint) {
1392
- if (!isInBrowser()) {
1393
- console.error(`[JITSU] 'idEndpoint' option can be used only in browser environment`);
1394
- return;
1395
- }
1396
- try {
1397
- const fetch = config.fetch || globalThis.fetch;
1398
- const controller = new AbortController();
1399
- setTimeout(() => controller.abort(), 1000);
1400
- const domain = config.cookieDomain || getTopLevelDomain(window.location.hostname);
1401
- const res = yield fetch(config.idEndpoint + "?domain=" + encodeURIComponent(domain), {
1402
- credentials: "include",
1403
- signal: controller.signal,
1404
- });
1405
- if (!res.ok) {
1406
- console.error(`[JITSU] Can't fetch idEndpoint: ${res.status} - ${res.statusText}`);
1407
- }
1408
- else if (config.debug) {
1409
- console.log(`[JITSU DEBUG] Fetch idEndpoint: ${res.status}`);
1410
- }
1411
- }
1412
- catch (e) {
1413
- console.error(`[JITSU] Can't fetch idEndpoint: ${e.message}`);
1414
- }
1415
- }
1416
- }),
1417
- page: args => {
1418
- var _a;
1419
- const { payload, config, instance } = args;
1420
- if ((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) {
1421
- return;
1422
- }
1423
- return send("page", payload, config, instance, storage);
1424
- },
1425
- track: args => {
1426
- var _a;
1427
- const { payload, config, instance } = args;
1428
- if ((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) {
1429
- return;
1430
- }
1431
- return send("track", payload, config, instance, storage);
1432
- },
1433
- identify: args => {
1434
- var _a, _b, _c;
1435
- const { payload, config, instance } = args;
1436
- if (((_a = config.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = config.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1437
- return;
1438
- }
1439
- storage.setItem("__user_id", payload.userId);
1440
- const doNotSend = (_c = payload.traits) === null || _c === void 0 ? void 0 : _c.$doNotSend;
1441
- if (payload.traits && typeof payload.traits === "object") {
1442
- payload.traits = stripControllingTraits(payload.traits);
1443
- storage.setItem("__user_traits", payload.traits);
1444
- }
1445
- if (doNotSend) {
1446
- return Promise.resolve();
1447
- }
1448
- return send("identify", payload, config, instance, storage);
1449
- },
1450
- reset: args => {
1451
- const { config, instance } = args;
1452
- storage.reset();
1453
- if (config.debug) {
1454
- console.log("[JITSU DEBUG] Resetting Jitsu plugin storage");
1455
- }
1456
- },
1457
- methods: {
1458
- configure(newOptions) {
1459
- var _a, _b, _c, _d;
1460
- const idsWasDisabled = ((_a = jitsuOptions.privacy) === null || _a === void 0 ? void 0 : _a.disableUserIds) || ((_b = jitsuOptions.privacy) === null || _b === void 0 ? void 0 : _b.dontSend);
1461
- mergeConfig(jitsuOptions, newOptions);
1462
- const idsDisabledNow = ((_c = jitsuOptions.privacy) === null || _c === void 0 ? void 0 : _c.disableUserIds) || ((_d = jitsuOptions.privacy) === null || _d === void 0 ? void 0 : _d.dontSend);
1463
- if (!idsDisabledNow && idsWasDisabled) {
1464
- if (jitsuOptions.debug) {
1465
- console.log("[JITSU] Enabling Anonymous ID. Generating new Id.");
1466
- }
1467
- const instance = this.instance;
1468
- const newAnonymousId = uuid();
1469
- const userState = instance.user();
1470
- if (userState) {
1471
- userState.anonymousId = newAnonymousId;
1472
- }
1473
- storage.setItem("__anon_id", newAnonymousId);
1474
- instance.setAnonymousId(newAnonymousId);
1475
- }
1476
- },
1477
- group(groupId, traits, options, callback) {
1478
- var _a, _b;
1479
- if (((_a = jitsuOptions.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = jitsuOptions.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1480
- return;
1481
- }
1482
- if (typeof groupId === "number") {
1483
- groupId = groupId + "";
1484
- }
1485
- const instance = this.instance;
1486
- const user = instance.user();
1487
- const userId = (options === null || options === void 0 ? void 0 : options.userId) || (user === null || user === void 0 ? void 0 : user.userId);
1488
- const anonymousId = (options === null || options === void 0 ? void 0 : options.anonymousId) || (user === null || user === void 0 ? void 0 : user.anonymousId) || storage.getItem("__anon_id");
1489
- storage.setItem("__group_id", groupId);
1490
- const doNotSend = traits === null || traits === void 0 ? void 0 : traits.$doNotSend;
1491
- if (traits && typeof traits === "object") {
1492
- traits = stripControllingTraits(traits);
1493
- storage.setItem("__group_traits", traits);
1494
- }
1495
- if (doNotSend) {
1496
- return Promise.resolve();
1497
- }
1498
- return send("group", Object.assign(Object.assign({ type: "group", groupId, traits }, (anonymousId ? { anonymousId } : {})), (userId ? { userId } : {})), jitsuOptions, instance, storage);
1499
- },
1500
- },
1501
- };
3045
+ return send(
3046
+ "group",
3047
+ __spreadValues(__spreadValues({ type: "group", groupId, traits }, anonymousId ? { anonymousId } : {}), userId ? { userId } : {}),
3048
+ jitsuOptions,
3049
+ instance,
3050
+ storage
3051
+ );
3052
+ }
3053
+ }
3054
+ };
1502
3055
  };
1503
- let seedCounter = 0;
3056
+ var seedCounter = 0;
1504
3057
  function getSeed() {
1505
- var _a;
1506
- seedCounter = (seedCounter + 1) % Number.MAX_SAFE_INTEGER;
1507
- const defaultSeed = Date.now() % 2147483647;
1508
- const seed = isInBrowser() ? ((_a = window === null || window === void 0 ? void 0 : window.performance) === null || _a === void 0 ? void 0 : _a.now()) || defaultSeed : defaultSeed;
1509
- return seed + seedCounter;
3058
+ var _a;
3059
+ seedCounter = (seedCounter + 1) % Number.MAX_SAFE_INTEGER;
3060
+ const defaultSeed = Date.now() % 2147483647;
3061
+ const seed = isInBrowser() ? ((_a = window == null ? void 0 : window.performance) == null ? void 0 : _a.now()) || defaultSeed : defaultSeed;
3062
+ return seed + seedCounter;
1510
3063
  }
1511
3064
  function randomId(hashString = "") {
1512
- const d = Date.now();
1513
- return (((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", getSeed())) % Number.MAX_SAFE_INTEGER).toString(36) +
1514
- ((Math.random() * d * hash(hashString !== null && hashString !== void 0 ? hashString : "", getSeed())) % Number.MAX_SAFE_INTEGER).toString(36));
3065
+ const d3 = Date.now();
3066
+ return (Math.random() * d3 * hash(hashString != null ? hashString : "", getSeed()) % Number.MAX_SAFE_INTEGER).toString(36) + (Math.random() * d3 * hash(hashString != null ? hashString : "", getSeed()) % Number.MAX_SAFE_INTEGER).toString(36);
1515
3067
  }
1516
3068
  function uuid() {
1517
- var u = "", m = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", i = 0, rb = (Math.random() * 0xffffffff) | 0;
1518
- while (i++ < 36) {
1519
- var c = m[i - 1], r = rb & 0xf, v = c == "x" ? r : (r & 0x3) | 0x8;
1520
- u += c == "-" || c == "4" ? c : v.toString(16);
1521
- rb = i % 8 == 0 ? (Math.random() * 0xffffffff) | 0 : rb >> 4;
1522
- }
1523
- return u;
3069
+ var u3 = "", m4 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", i4 = 0, rb = Math.random() * 4294967295 | 0;
3070
+ while (i4++ < 36) {
3071
+ var c4 = m4[i4 - 1], r3 = rb & 15, v2 = c4 == "x" ? r3 : r3 & 3 | 8;
3072
+ u3 += c4 == "-" || c4 == "4" ? c4 : v2.toString(16);
3073
+ rb = i4 % 8 == 0 ? Math.random() * 4294967295 | 0 : rb >> 4;
3074
+ }
3075
+ return u3;
1524
3076
  }
1525
3077
  function hash(str, seed = 0) {
1526
- let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
1527
- for (let i = 0, ch; i < str.length; i++) {
1528
- ch = str.charCodeAt(i);
1529
- h1 = Math.imul(h1 ^ ch, 2654435761);
1530
- h2 = Math.imul(h2 ^ ch, 1597334677);
1531
- }
1532
- h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
1533
- h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
1534
- return 4294967296 * (2097151 & h2) + (h1 >>> 0);
3078
+ let h1 = 3735928559 ^ seed, h22 = 1103547991 ^ seed;
3079
+ for (let i4 = 0, ch; i4 < str.length; i4++) {
3080
+ ch = str.charCodeAt(i4);
3081
+ h1 = Math.imul(h1 ^ ch, 2654435761);
3082
+ h22 = Math.imul(h22 ^ ch, 1597334677);
3083
+ }
3084
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h22 ^ h22 >>> 13, 3266489909);
3085
+ h22 = Math.imul(h22 ^ h22 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
3086
+ return 4294967296 * (2097151 & h22) + (h1 >>> 0);
1535
3087
  }
1536
3088
 
1537
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
1538
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1539
- return new (P || (P = Promise))(function (resolve, reject) {
1540
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1541
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1542
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1543
- step((generator = generator.apply(thisArg, _arguments || [])).next());
1544
- });
1545
- };
3089
+ // src/index.ts
1546
3090
  function parse(input) {
1547
- let value = input;
1548
- if ((input === null || input === void 0 ? void 0 : input.indexOf("%7B%22")) === 0) {
1549
- value = decodeURIComponent(input);
1550
- }
1551
- try {
1552
- value = JSON.parse(value);
1553
- if (value === "true")
1554
- return true;
1555
- if (value === "false")
1556
- return false;
1557
- if (typeof value === "object")
1558
- return value;
1559
- if (parseFloat(value) === value) {
1560
- value = parseFloat(value);
1561
- }
1562
- }
1563
- catch (e) { }
1564
- if (value === null || value === "") {
1565
- return;
1566
- }
1567
- return value;
3091
+ let value = input;
3092
+ if ((input == null ? void 0 : input.indexOf("%7B%22")) === 0) {
3093
+ value = decodeURIComponent(input);
3094
+ }
3095
+ try {
3096
+ value = JSON.parse(value);
3097
+ if (value === "true") return true;
3098
+ if (value === "false") return false;
3099
+ if (typeof value === "object") return value;
3100
+ if (parseFloat(value) === value) {
3101
+ value = parseFloat(value);
3102
+ }
3103
+ } catch (e2) {
3104
+ }
3105
+ if (value === null || value === "") {
3106
+ return;
3107
+ }
3108
+ return value;
1568
3109
  }
1569
- const emptyAnalytics = {
1570
- setAnonymousId: () => { },
1571
- setContextProperty(name, value) { },
3110
+ var emptyAnalytics = {
3111
+ setAnonymousId: () => {
3112
+ },
3113
+ setContextProperty(name, value) {
3114
+ },
3115
+ getContextProperty(name) {
3116
+ return void 0;
3117
+ },
3118
+ track: () => Promise.resolve(),
3119
+ page: () => Promise.resolve(),
3120
+ user: () => ({}),
3121
+ identify: () => Promise.resolve({}),
3122
+ group: () => Promise.resolve({}),
3123
+ reset: () => Promise.resolve({}),
3124
+ configure: () => {
3125
+ },
3126
+ getConfiguration() {
3127
+ return {};
3128
+ }
3129
+ };
3130
+ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
3131
+ var _a, _c, _d;
3132
+ const storageCache = {};
3133
+ const cachingStorageWrapper = (persistentStorage) => ({
3134
+ setItem(key, val) {
3135
+ var _a2, _b2;
3136
+ if (((_a2 = opts.privacy) == null ? void 0 : _a2.dontSend) || ((_b2 = opts.privacy) == null ? void 0 : _b2.disableUserIds)) {
3137
+ return;
3138
+ }
3139
+ if (opts.debug) {
3140
+ console.log(`[JITSU DEBUG] Caching storage setItem: ${key}=${val}`);
3141
+ }
3142
+ storageCache[key] = val;
3143
+ persistentStorage.setItem(key, val);
3144
+ },
3145
+ getItem(key) {
3146
+ var _a2, _b2;
3147
+ if (((_a2 = opts.privacy) == null ? void 0 : _a2.dontSend) || ((_b2 = opts.privacy) == null ? void 0 : _b2.disableUserIds)) {
3148
+ return;
3149
+ }
3150
+ const value = storageCache[key] || persistentStorage.getItem(key);
3151
+ if (opts.debug) {
3152
+ console.log(
3153
+ `[JITSU DEBUG] Caching storage getItem: ${key}=${value}. Evicted from cache: ${!storageCache[key]}`
3154
+ );
3155
+ }
3156
+ return value;
3157
+ },
3158
+ reset() {
3159
+ for (const key of [...Object.keys(storageCache)]) {
3160
+ delete storageCache[key];
3161
+ }
3162
+ persistentStorage.reset();
3163
+ },
3164
+ removeItem(key) {
3165
+ if (opts.debug) {
3166
+ console.log(`[JITSU DEBUG] Caching storage removeItem: ${key}`);
3167
+ }
3168
+ delete storageCache[key];
3169
+ persistentStorage.removeItem(key);
3170
+ }
3171
+ });
3172
+ const storage = cachingStorageWrapper(((_a = rt.store) == null ? void 0 : _a.call(rt)) || createInMemoryStorage(opts.debug));
3173
+ const analytics = analyticsLib({
3174
+ debug: !!opts.debug,
3175
+ storage,
3176
+ plugins: [jitsuAnalyticsPlugin(opts, storage), ...plugins]
3177
+ });
3178
+ const a4 = __spreadProps(__spreadValues({}, analytics), {
3179
+ page: (...args) => {
3180
+ if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "object") {
3181
+ return analytics.page(__spreadValues({
3182
+ name: args[0]
3183
+ }, args[1]));
3184
+ } else {
3185
+ return analytics.page(...args);
3186
+ }
3187
+ },
3188
+ identify: (...args) => {
3189
+ if (args[0] && typeof args[0] !== "object" && typeof args[0] !== "string") {
3190
+ args[0] = args[0] + "";
3191
+ }
3192
+ const storage2 = analytics.storage;
3193
+ const storageWrapper = cachingStorageWrapper(storage2);
3194
+ if (typeof args[0] === "string") {
3195
+ storageWrapper.setItem("__user_id", args[0]);
3196
+ } else if (typeof args[0] === "object") {
3197
+ storageWrapper.setItem("__user_traits", args[0]);
3198
+ }
3199
+ if (args.length === 2 && typeof args[1] === "object") {
3200
+ storageWrapper.setItem("__user_traits", args[1]);
3201
+ }
3202
+ return analytics.identify(...args);
3203
+ },
3204
+ setContextProperty(name, value) {
3205
+ if (opts.debug) {
3206
+ console.log(`[JITSU DEBUG] Setting context property '${name}':${JSON.stringify(value)}`);
3207
+ }
3208
+ if (!opts.defaultPayloadContext) {
3209
+ opts.defaultPayloadContext = {
3210
+ [name]: value
3211
+ };
3212
+ } else {
3213
+ opts.defaultPayloadContext[name] = value;
3214
+ }
3215
+ },
1572
3216
  getContextProperty(name) {
1573
- return undefined;
3217
+ var _a2;
3218
+ if (opts.debug) {
3219
+ console.log(`[JITSU DEBUG] Getting context property '${name}'`);
3220
+ }
3221
+ return (_a2 = opts.defaultPayloadContext) == null ? void 0 : _a2[name];
1574
3222
  },
1575
- track: () => Promise.resolve(),
1576
- page: () => Promise.resolve(),
1577
- user: () => ({}),
1578
- identify: () => Promise.resolve({}),
1579
- group: () => Promise.resolve({}),
1580
- reset: () => Promise.resolve({}),
1581
- configure: () => { },
1582
- getConfiguration() {
1583
- return {};
3223
+ setAnonymousId: (id) => {
3224
+ if (opts.debug) {
3225
+ console.log("[JITSU DEBUG] Setting anonymous id to " + id);
3226
+ }
3227
+ storage.setItem("__anon_id", id);
3228
+ const userState = analytics.user();
3229
+ if (userState) {
3230
+ userState.anonymousId = id;
3231
+ }
3232
+ analytics.setAnonymousId(id);
1584
3233
  },
1585
- };
1586
- function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
1587
- var _a, _b, _c;
1588
- const storageCache = {};
1589
- const cachingStorageWrapper = (persistentStorage) => ({
1590
- setItem(key, val) {
1591
- var _a, _b;
1592
- if (((_a = opts.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1593
- return;
1594
- }
1595
- if (opts.debug) {
1596
- console.log(`[JITSU DEBUG] Caching storage setItem: ${key}=${val}`);
1597
- }
1598
- storageCache[key] = val;
1599
- persistentStorage.setItem(key, val);
1600
- },
1601
- getItem(key) {
1602
- var _a, _b;
1603
- if (((_a = opts.privacy) === null || _a === void 0 ? void 0 : _a.dontSend) || ((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds)) {
1604
- return;
1605
- }
1606
- const value = storageCache[key] || persistentStorage.getItem(key);
1607
- if (opts.debug) {
1608
- console.log(`[JITSU DEBUG] Caching storage getItem: ${key}=${value}. Evicted from cache: ${!storageCache[key]}`);
1609
- }
1610
- return value;
1611
- },
1612
- reset() {
1613
- for (const key of [...Object.keys(storageCache)]) {
1614
- delete storageCache[key];
1615
- }
1616
- persistentStorage.reset();
1617
- },
1618
- removeItem(key) {
1619
- if (opts.debug) {
1620
- console.log(`[JITSU DEBUG] Caching storage removeItem: ${key}`);
1621
- }
1622
- delete storageCache[key];
1623
- persistentStorage.removeItem(key);
1624
- },
1625
- });
1626
- const storage = cachingStorageWrapper(((_a = rt.store) === null || _a === void 0 ? void 0 : _a.call(rt)) || createInMemoryStorage(opts.debug));
1627
- const analytics = analyticsLib({
1628
- debug: !!opts.debug,
1629
- storage,
1630
- plugins: [jitsuAnalyticsPlugin(opts, storage), ...plugins],
1631
- });
1632
- const a = Object.assign(Object.assign({}, analytics), { page: (...args) => {
1633
- if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "object") {
1634
- return analytics.page(Object.assign({ name: args[0] }, args[1]));
1635
- }
1636
- else {
1637
- return analytics.page(...args);
1638
- }
1639
- }, identify: (...args) => {
1640
- if (args[0] && typeof args[0] !== "object" && typeof args[0] !== "string") {
1641
- args[0] = args[0] + "";
1642
- }
1643
- const storage = analytics.storage;
1644
- const storageWrapper = cachingStorageWrapper(storage);
1645
- if (typeof args[0] === "string") {
1646
- storageWrapper.setItem("__user_id", args[0]);
1647
- }
1648
- else if (typeof args[0] === "object") {
1649
- storageWrapper.setItem("__user_traits", args[0]);
1650
- }
1651
- if (args.length === 2 && typeof args[1] === "object") {
1652
- storageWrapper.setItem("__user_traits", args[1]);
1653
- }
1654
- return analytics.identify(...args);
1655
- }, setContextProperty(name, value) {
1656
- if (opts.debug) {
1657
- console.log(`[JITSU DEBUG] Setting context property '${name}':${JSON.stringify(value)}`);
1658
- }
1659
- if (!opts.defaultPayloadContext) {
1660
- opts.defaultPayloadContext = {
1661
- [name]: value,
1662
- };
1663
- }
1664
- else {
1665
- opts.defaultPayloadContext[name] = value;
1666
- }
1667
- },
1668
- getContextProperty(name) {
1669
- var _a;
1670
- if (opts.debug) {
1671
- console.log(`[JITSU DEBUG] Getting context property '${name}'`);
1672
- }
1673
- return (_a = opts.defaultPayloadContext) === null || _a === void 0 ? void 0 : _a[name];
1674
- }, setAnonymousId: (id) => {
1675
- if (opts.debug) {
1676
- console.log("[JITSU DEBUG] Setting anonymous id to " + id);
1677
- }
1678
- storage.setItem("__anon_id", id);
1679
- const userState = analytics.user();
1680
- if (userState) {
1681
- userState.anonymousId = id;
1682
- }
1683
- analytics.setAnonymousId(id);
1684
- }, reset() {
1685
- return __awaiter(this, void 0, void 0, function* () {
1686
- if (opts.debug) {
1687
- console.log("[JITSU DEBUG] Called reset(). Storage state", JSON.stringify(analytics.user()));
1688
- }
1689
- storage.reset();
1690
- yield analytics.reset();
1691
- this.setAnonymousId(uuid());
1692
- if (opts.debug) {
1693
- console.log("[JITSU DEBUG] User state after reset", JSON.stringify(analytics.user()));
1694
- }
1695
- });
1696
- },
1697
- configure(options) {
1698
- return __awaiter(this, void 0, void 0, function* () {
1699
- var _a, _b;
1700
- if (opts.debug) {
1701
- console.log("[JITSU DEBUG] Update Jitsu config with", JSON.stringify(options));
1702
- }
1703
- if (((_a = options.privacy) === null || _a === void 0 ? void 0 : _a.disableUserIds) || ((_b = options.privacy) === null || _b === void 0 ? void 0 : _b.dontSend)) {
1704
- storage.reset();
1705
- }
1706
- for (const plugin of Object.values(analytics.plugins)) {
1707
- if (typeof plugin["configure"] === "function") {
1708
- plugin["configure"](options);
1709
- }
1710
- }
1711
- });
1712
- },
1713
- group(groupId, traits, options, callback) {
1714
- return __awaiter(this, void 0, void 0, function* () {
1715
- const results = [];
1716
- for (const plugin of Object.values(analytics.plugins)) {
1717
- if (plugin["group"]) {
1718
- results.push(yield plugin["group"](groupId, traits, options, callback));
1719
- }
1720
- }
1721
- return results[0];
1722
- });
1723
- },
1724
- getConfiguration() {
1725
- return opts;
1726
- } });
1727
- if (((_b = opts.privacy) === null || _b === void 0 ? void 0 : _b.disableUserIds) || ((_c = opts.privacy) === null || _c === void 0 ? void 0 : _c.dontSend)) {
3234
+ reset() {
3235
+ return __async(this, null, function* () {
3236
+ if (opts.debug) {
3237
+ console.log("[JITSU DEBUG] Called reset(). Storage state", JSON.stringify(analytics.user()));
3238
+ }
1728
3239
  storage.reset();
3240
+ yield analytics.reset();
3241
+ this.setAnonymousId(uuid());
3242
+ if (opts.debug) {
3243
+ console.log("[JITSU DEBUG] User state after reset", JSON.stringify(analytics.user()));
3244
+ }
3245
+ });
3246
+ },
3247
+ configure(options) {
3248
+ return __async(this, null, function* () {
3249
+ var _a2, _b2;
3250
+ if (opts.debug) {
3251
+ console.log("[JITSU DEBUG] Update Jitsu config with", JSON.stringify(options));
3252
+ }
3253
+ if (((_a2 = options.privacy) == null ? void 0 : _a2.disableUserIds) || ((_b2 = options.privacy) == null ? void 0 : _b2.dontSend)) {
3254
+ storage.reset();
3255
+ }
3256
+ for (const plugin of Object.values(analytics.plugins)) {
3257
+ if (typeof plugin["configure"] === "function") {
3258
+ plugin["configure"](options);
3259
+ }
3260
+ }
3261
+ });
3262
+ },
3263
+ group(groupId, traits, options, callback) {
3264
+ return __async(this, null, function* () {
3265
+ const results = [];
3266
+ for (const plugin of Object.values(analytics.plugins)) {
3267
+ if (plugin["group"]) {
3268
+ results.push(yield plugin["group"](groupId, traits, options, callback));
3269
+ }
3270
+ }
3271
+ return results[0];
3272
+ });
3273
+ },
3274
+ getConfiguration() {
3275
+ return opts;
1729
3276
  }
1730
- return a;
3277
+ });
3278
+ if (((_c = opts.privacy) == null ? void 0 : _c.disableUserIds) || ((_d = opts.privacy) == null ? void 0 : _d.dontSend)) {
3279
+ storage.reset();
3280
+ }
3281
+ return a4;
1731
3282
  }
1732
3283
  function fixOptions(opts) {
1733
- var _a, _b;
1734
- return Object.assign(Object.assign({}, opts), { host: ((_a = opts.host) !== null && _a !== void 0 ? _a : "").indexOf("https://") !== 0 && ((_b = opts.host) !== null && _b !== void 0 ? _b : "").indexOf("http://") !== 0
1735
- ? `https://${opts.host}`
1736
- : opts.host });
3284
+ var _a, _b;
3285
+ return __spreadProps(__spreadValues({}, opts), {
3286
+ host: ((_a = opts.host) != null ? _a : "").indexOf("https://") !== 0 && ((_b = opts.host) != null ? _b : "").indexOf("http://") !== 0 ? `https://${opts.host}` : opts.host
3287
+ });
1737
3288
  }
1738
3289
  function jitsuAnalytics(_opts) {
1739
- const opts = fixOptions(_opts);
1740
- const inBrowser = isInBrowser();
1741
- const rt = opts.runtime || (inBrowser ? windowRuntime(opts) : emptyRuntime(opts));
1742
- return createUnderlyingAnalyticsInstance(opts, rt);
3290
+ const opts = fixOptions(_opts);
3291
+ const inBrowser = isInBrowser();
3292
+ const rt = opts.runtime || (inBrowser ? windowRuntime(opts) : emptyRuntime(opts));
3293
+ return createUnderlyingAnalyticsInstance(opts, rt);
1743
3294
  }
1744
-
1745
- export { createInMemoryStorage, emptyAnalytics, emptyRuntime, isInBrowser, jitsuAnalytics, jitsuAnalyticsPlugin, parseQuery, randomId, uuid, windowRuntime };
3295
+ export {
3296
+ createInMemoryStorage,
3297
+ parse as default,
3298
+ emptyAnalytics,
3299
+ emptyRuntime,
3300
+ isInBrowser,
3301
+ jitsuAnalytics,
3302
+ jitsuAnalyticsPlugin,
3303
+ parseQuery,
3304
+ randomId,
3305
+ uuid,
3306
+ windowRuntime
3307
+ };