@esri/telemetry-amazon 5.1.1 → 5.1.3
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.
|
@@ -219,29 +219,29 @@
|
|
|
219
219
|
|
|
220
220
|
}(dlv_umd));
|
|
221
221
|
|
|
222
|
-
var i$
|
|
222
|
+
var i$6 = dlv_umd.exports;
|
|
223
223
|
|
|
224
|
-
var
|
|
224
|
+
var n$5="function",t$4="string",e$3="undefined",r$5="boolean",o$5="object",c$5="number",i$5="symbol",a$7="null",S$4="form",j$4="input",A$5="button",E$5="select",P$4=typeof process!==e$3?process:{};P$4.env&&P$4.env.NODE_ENV||"";var $$4=typeof document!==e$3;null!=P$4.versions&&null!=P$4.versions.node;typeof Deno!==e$3&&typeof Deno.core!==e$3;$$4&&"nodejs"===window.name||typeof navigator!==e$3&&typeof navigator.userAgent!==e$3&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$4(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$4=M$4.bind(null,"toUpperCase"),H$4=M$4.bind(null,"toLowerCase");function J$5(n){return Y$4(n)?U$4(a$7):typeof n===o$5?yn$3(n):Object.prototype.toString.call(n).slice(8,-1)}function R$4(n,t){void 0===t&&(t=!0);var e=J$5(n);return t?H$4(e):e}function V$4(n,t){return typeof t===n}var W$4=V$4.bind(null,n$5),q$4=V$4.bind(null,t$4);V$4.bind(null,e$3);V$4.bind(null,r$5);V$4.bind(null,i$5);function Y$4(n){return null===n}function nn$3(n){return R$4(n)===c$5&&!isNaN(n)}function yn$3(n){return W$4(n.constructor)?n.constructor.name:null}function hn$3(n){return n instanceof Error||q$4(n.message)&&n.constructor&&nn$3(n.constructor.stackTraceLimit)}function Sn$3(n,t){if("object"!=typeof t||Y$4(t))return !1;if(t instanceof n)return !0;var e=R$4(new n(""));if(hn$3(t))for(;t;){if(R$4(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$3.bind(null,TypeError);Sn$3.bind(null,SyntaxError);function $n$3(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$3(n,t):e}function Tn$3(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$3(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$3($n$3,S$4);_n$3($n$3,A$5);_n$3($n$3,j$4);_n$3($n$3,E$5);
|
|
225
225
|
|
|
226
|
-
function n$
|
|
226
|
+
function n$4(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o$4(){if($$4){var r=navigator,t=r.languages;return r.userLanguage||(t&&t.length?t[0]:r.language)}}function a$6(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}}function s$1(r){return function(e){for(var r,t=Object.create(null),o=/([^&=]+)=?([^&]*)/g;r=o.exec(e);){var a=n$4(r[1]),i=n$4(r[2]);if(a)if("[]"===a.substring(a.length-2)){var u=t[a=a.substring(0,a.length-2)]||(t[a]=[]);t[a]=Array.isArray(u)?u:[],t[a].push(i);}else t[a]=""===i||i;}for(var c in t){var l=c.split("[");l.length>1&&(m$2(t,l.map(function(e){return e.replace(/[?[\]\\ ]/g,"")}),t[c]),delete t[c]);}return t}(function(r){if(r){var t=r.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return $$4&&window.location.search.substring(1)}(r))}function m$2(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 b$2(){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}
|
|
227
227
|
|
|
228
|
-
var e="undefined",o$
|
|
228
|
+
var n$3="function",t$3="string",e$2="undefined",r$4="boolean",o$3="object",c$4="number",i$4="symbol",a$5="null",O$3="__",S$3="form",j$3="input",A$4="button",E$4="select",P$3=typeof process!==e$2?process:{};P$3.env&&P$3.env.NODE_ENV||"";var $$3=typeof document!==e$2;null!=P$3.versions&&null!=P$3.versions.node;typeof Deno!==e$2&&typeof Deno.core!==e$2;$$3&&"nodejs"===window.name||typeof navigator!==e$2&&typeof navigator.userAgent!==e$2&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$3(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$3=M$3.bind(null,"toUpperCase"),H$3=M$3.bind(null,"toLowerCase");function J$4(n){return Y$3(n)?U$3(a$5):typeof n===o$3?yn$2(n):Object.prototype.toString.call(n).slice(8,-1)}function R$3(n,t){void 0===t&&(t=!0);var e=J$4(n);return t?H$3(e):e}function V$3(n,t){return typeof t===n}var W$3=V$3.bind(null,n$3),q$3=V$3.bind(null,t$3);V$3.bind(null,e$2);V$3.bind(null,r$4);V$3.bind(null,i$4);function Y$3(n){return null===n}function nn$2(n){return R$3(n)===c$4&&!isNaN(n)}function yn$2(n){return W$3(n.constructor)?n.constructor.name:null}function hn$2(n){return n instanceof Error||q$3(n.message)&&n.constructor&&nn$2(n.constructor.stackTraceLimit)}function Sn$2(n,t){if("object"!=typeof t||Y$3(t))return !1;if(t instanceof n)return !0;var e=R$3(new n(""));if(hn$2(t))for(;t;){if(R$3(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$2.bind(null,TypeError);Sn$2.bind(null,SyntaxError);function $n$2(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$2(n,t):e}function Tn$2(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$2(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$2($n$2,S$3);_n$2($n$2,A$4);_n$2($n$2,j$3);_n$2($n$2,E$4);
|
|
229
229
|
|
|
230
|
-
var
|
|
230
|
+
var n$2="global",o$2=O$3+n$2+O$3,l$1=typeof self===o$3&&self.self===self&&self||typeof global===o$3&&global[n$2]===global&&global||void 0;function f(t){return l$1[o$2][t]}function a$4(t,e){return l$1[o$2][t]=e}function i$3(t){delete l$1[o$2][t];}function u$2(t,e,r){var n;try{if(s(t)){var o=window[t];n=o[e].bind(o);}}catch(t){}return n||r}l$1[o$2]||(l$1[o$2]={});var c$3={};function s(t){if(typeof c$3[t]!==e$2)return c$3[t];try{var e=window[t];e.setItem(e$2,e$2),e.removeItem(e$2);}catch(e){return c$3[t]=!1}return c$3[t]=!0}
|
|
231
231
|
|
|
232
|
-
var
|
|
232
|
+
var n$1="function",t$2="string",e$1="undefined",r$3="boolean",o$1="object",u$1="array",c$2="number",i$2="symbol",a$3="null",O$2="__",S$2="form",j$2="input",A$3="button",E$3="select",P$2=typeof process!==e$1?process:{};P$2.env&&P$2.env.NODE_ENV||"";var $$2=typeof document!==e$1;null!=P$2.versions&&null!=P$2.versions.node;typeof Deno!==e$1&&typeof Deno.core!==e$1;$$2&&"nodejs"===window.name||typeof navigator!==e$1&&typeof navigator.userAgent!==e$1&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$2(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$2=M$2.bind(null,"toUpperCase"),H$2=M$2.bind(null,"toLowerCase");function J$3(n){return Y$2(n)?U$2(a$3):typeof n===o$1?yn$1(n):Object.prototype.toString.call(n).slice(8,-1)}function R$2(n,t){void 0===t&&(t=!0);var e=J$3(n);return t?H$2(e):e}function V$2(n,t){return typeof t===n}var W$2=V$2.bind(null,n$1),q$2=V$2.bind(null,t$2);V$2.bind(null,e$1);var Q$1=V$2.bind(null,r$3);V$2.bind(null,i$2);function Y$2(n){return null===n}function nn$1(n){return R$2(n)===c$2&&!isNaN(n)}function rn(n){return R$2(n)===u$1}function on$1(n){if(!un$1(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un$1(n){return n&&(typeof n===o$1||null!==n)}function yn$1(n){return W$2(n.constructor)?n.constructor.name:null}function hn$1(n){return n instanceof Error||q$2(n.message)&&n.constructor&&nn$1(n.constructor.stackTraceLimit)}function Sn$1(n,t){if("object"!=typeof t||Y$2(t))return !1;if(t instanceof n)return !0;var e=R$2(new n(""));if(hn$1(t))for(;t;){if(R$2(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$1.bind(null,TypeError);Sn$1.bind(null,SyntaxError);function $n$1(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$1(n,t):e}function Tn$1(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$1(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$1($n$1,S$2);_n$1($n$1,A$3);_n$1($n$1,j$2);_n$1($n$1,E$3);
|
|
233
233
|
|
|
234
|
-
function v(){return v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);}return e},v.apply(this,arguments)}var y="function",b$2="undefined",I$2="@@redux/"+Math.random().toString(36),w=/* #__PURE__ */function(){return typeof Symbol===y&&Symbol.observable||"@@observable"}(),E$1=" != "+y;function P(e,n,t){var r;if(typeof n===y&&typeof t===b$2&&(t=n,n=void 0),typeof t!==b$2){if(typeof t!==y)throw new Error("enhancer"+E$1);return t(P)(e,n)}if(typeof e!==y)throw new Error("reducer"+E$1);var i=e,a=n,o=[],u=o,c=!1;function s(){u===o&&(u=o.slice());}function f(){return a}function d(e){if(typeof e!==y)throw new Error("Listener"+E$1);var n=!0;return s(),u.push(e),function(){if(n){n=!1,s();var t=u.indexOf(e);u.splice(t,1);}}}function p(e){if(!on$1(e))throw new Error("Act != obj");if(typeof e.type===b$2)throw new Error("ActType "+b$2);if(c)throw new Error("Dispatch in reducer");try{c=!0,a=i(a,e);}finally{c=!1;}for(var n=o=u,t=0;t<n.length;t++)(0, n[t])();return e}return p({type:"@@redux/INIT"}),(r={dispatch:p,subscribe:d,getState:f,replaceReducer:function(e){if(typeof e!==y)throw new Error("next reducer"+E$1);i=e,p({type:"@@redux/INIT"});}})[w]=function(){var e,n=d;return (e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function t(){e.next&&e.next(f());}return t(),{unsubscribe:n(t)}}})[w]=function(){return this},e},r}function S(e,n){var t=n&&n.type;return "action "+(t&&t.toString()||"?")+"reducer "+e+" returns "+b$2}function N$1(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function O$1(){var e=arguments;return function(n){return function(t,r,i){var a,o=n(t,r,i),u=o.dispatch,c={getState:o.getState,dispatch:function(e){return u(e)}};return a=[].slice.call(e).map(function(e){return e(c)}),v({},o,{dispatch:u=N$1.apply(void 0,a)(o.dispatch)})}}}var A$1=j+"anon_id",_=j+"user_id",x$1=j+"user_traits",k$1="userId",T="anonymousId",z=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],M$1=["name","EVENTS","config","loaded"],q$1=z.reduce(function(e,n){return e[n]=n,e},{registerPluginType:function(e){return "registerPlugin:"+e},pluginReadyType:function(e){return "ready:"+e}}),U$1=/^utm_/,V$1=/^an_prop_/,L$1=/^an_trait_/;function C$1(e){var n=e.storage.setItem;return function(t){return function(r){return function(i){if(i.type===q$1.bootstrap){var a=i.params,o=i.user,u=i.persistedUser,c=i.initialUser,s=u.userId===o.userId;u.anonymousId!==o.anonymousId&&n(A$1,o.anonymousId),s||n(_,o.userId),c.traits&&n(x$1,v({},s&&u.traits?u.traits:{},c.traits));var l=Object.keys(i.params);if(l.length){var f=a.an_uid,d=a.an_event,p=l.reduce(function(e,n){if(n.match(U$1)||n.match(/^(d|g)clid/)){var t=n.replace(U$1,"");e.campaign["campaign"===t?"name":t]=a[n];}return n.match(V$1)&&(e.props[n.replace(V$1,"")]=a[n]),n.match(L$1)&&(e.traits[n.replace(L$1,"")]=a[n]),e},{campaign:{},props:{},traits:{}});t.dispatch(v({type:q$1.params,raw:a},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&t.dispatch({type:q$1.campaign,campaign:p.campaign});}}return r(i)}}}}function R$1(e){return function(n,t){if(void 0===n&&(n={}),void 0===t&&(t={}),t.type===q$1.setItemEnd){if(t.key===A$1)return v({},n,{anonymousId:t.value});if(t.key===_)return v({},n,{userId:t.value})}switch(t.type){case q$1.identify:return Object.assign({},n,{userId:t.userId,traits:v({},n.traits,t.traits)});case q$1.reset:return [_,A$1,x$1].forEach(function(n){e.removeItem(n);}),Object.assign({},n,{userId:null,anonymousId:null,traits:{}});default:return n}}}function $$1(e){return {userId:e.getItem(_),anonymousId:e.getItem(A$1),traits:e.getItem(x$1)}}var D=function(e){return j+"TEMP"+j+e};function B(n){var t=n.storage,r=t.setItem,i=t.removeItem,a=t.getItem;return function(n){return function(t){return function(u){var c=u.userId,s=u.traits,l=u.options;if(u.type===q$1.reset&&([_,x$1,A$1].forEach(function(e){i(e);}),[k$1,T,"traits"].forEach(function(e){i$2(D(e));})),u.type===q$1.identify){a(A$1)||r(A$1,y$1());var f=a(_),d=a(x$1)||{};f&&f!==c&&n.dispatch({type:q$1.userIdChanged,old:{userId:f,traits:d},new:{userId:c,traits:s},options:l}),c&&r(_,c),s&&r(x$1,v({},d,s));}return t(u)}}}}var X={};function J$2(e,n){X[e]&&W$2(X[e])&&(X[e](n),delete X[e]);}function W$1(e,n,t){return new Promise(function(r,i){return n()?r(e):t<1?i(v({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(a){return W$1(e,n,t-10).then(r,i)})})}function H$1(e){return {abort:e}}function F$2(e,n,t){var r={},i=n(),a=e.getState(),o=a.plugins,u=a.queue,c=a.user;if(!a.context.offline&&u&&u.actions&&u.actions.length){var s=u.actions.reduce(function(e,n,t){return o[n.plugin].loaded?(e.process.push(n),e.processIndex.push(t)):(e.requeue.push(n),e.requeueIndex.push(t)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(s.processIndex&&s.processIndex.length){s.processIndex.forEach(function(n){var a=u.actions[n],s=a.plugin,f=a.payload.type,p=i[s][f];if(p&&W$2(p)){var m,g=function(e,n){return void 0===e&&(e={}),void 0===n&&(n={}),[k$1,T].reduce(function(t,r){return e.hasOwnProperty(r)&&n[r]&&n[r]!==e[r]&&(t[r]=n[r]),t},e)}(a.payload,c),h=r[g.meta.rid];if(!h&&(m=p({payload:g,config:o[s].config,instance:t,abort:H$1}))&&on$1(m)&&m.abort)return void(r[g.meta.rid]=!0);if(!h){var y=f+":"+s;e.dispatch(v({},g,{type:y,_:{called:y,from:"queueDrain"}}));}}});var f=u.actions.filter(function(e,n){return !~s.processIndex.indexOf(n)});u.actions=f;}}}var G$1=function(e){var n=e.data,t=e.action,r=e.instance,i=e.state,a=e.allPlugins,o=e.allMatches,u=e.store,c=e.EVENTS;try{var s=i.plugins,f=i.context,p=t.type,m=p.match(K),g=n.exact.map(function(e){return e.pluginName});m&&(g=o.during.map(function(e){return e.pluginName}));var h=function(e,n){return function(t,r,i){var a=r.config,o=r.name,u=o+"."+t.type;i&&(u=i.event);var c=t.type.match(K)?function(e,n,t,r,i){return function(a,o){var u=r?r.name:e,c=o&&ae(o)?o:t;if(r&&(!(c=o&&ae(o)?o:[e]).includes(e)||1!==c.length))throw new Error("Method "+n+" can only abort "+e+" plugin. "+JSON.stringify(c)+" input valid");return v({},i,{abort:{reason:a,plugins:c,caller:n,_:u}})}}(o,u,n,i,t):function(e,n){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+n)}}(t,u);return {payload:ce(t),instance:e,config:a||{},abort:c}}}(r,g),y=n.exact.reduce(function(e,n){var t=n.pluginName,r=n.methodName,i=!1;return r.match(/^initialize/)||r.match(/^reset/)||(i=!s[t].loaded),f.offline&&r.match(/^(page|track|identify)/)&&(i=!0),e[""+t]=i,e},{});return Promise.resolve(n.exact.reduce(function(e,i,o){try{var u=i.pluginName;return Promise.resolve(e).then(function(e){function i(){return Promise.resolve(e)}var o=function(){if(n.namespaced&&n.namespaced[u])return Promise.resolve(n.namespaced[u].reduce(function(e,n,t){try{return Promise.resolve(e).then(function(e){return n.method&&W$2(n.method)?(function(e,n){var t=ue(e);if(t&&t.name===n){var r=ue(t.method);throw new Error([n+" plugin is calling method "+e,"Plugins cant call self","Use "+t.method+" "+(r?"or "+r.method:"")+" in "+n+" plugin insteadof "+e].join("\n"))}}(n.methodName,n.pluginName),Promise.resolve(n.method({payload:e,instance:r,abort:(t=e,i=u,o=n.pluginName,function(e,n){return v({},t,{abort:{reason:e,plugins:n||[i],caller:p,from:o||i}})}),config:ee(n.pluginName,s,a),plugins:s})).then(function(n){var t=on$1(n)?n:{};return Promise.resolve(v({},e,t))})):e;var t,i,o;})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(n){e[u]=n;});e[u]=t;}();return o&&o.then?o.then(i):i()})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(e){return Promise.resolve(n.exact.reduce(function(t,i,o){try{var c=n.exact.length===o+1,f=i.pluginName,d=a[f];return Promise.resolve(t).then(function(n){var t=e[f]?e[f]:{};if(m&&(t=n),re(t,f))return Z({data:t,method:p,instance:r,pluginName:f,store:u}),Promise.resolve(n);if(re(n,f))return c&&Z({data:n,method:p,instance:r,store:u}),Promise.resolve(n);if(y.hasOwnProperty(f)&&!0===y[f])return u.dispatch({type:"queue",plugin:f,payload:t,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(n);var i=h(e[f],a[f]);return Promise.resolve(d[p]({abort:i.abort,payload:t,instance:r,config:ee(f,s,a),plugins:s})).then(function(i){var a=on$1(i)?i:{},o=v({},n,a),c=e[f];if(re(c,f))Z({data:c,method:p,instance:r,pluginName:f,store:u});else {var s=p+":"+f;(s.match(/:/g)||[]).length<2&&!p.match(Q)&&!p.match(Y$1)&&r.dispatch(v({},m?o:t,{type:s,_:{called:s,from:"submethod"}}));}return Promise.resolve(o)})})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(e){if(!(p.match(K)||p.match(/^registerPlugin/)||p.match(Y$1)||p.match(Q)||p.match(/^params/)||p.match(/^userIdChanged/))){if(c.plugins.includes(p),e._&&e._.originalAction===p)return e;var t=v({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});ie(e,n.exact.length)&&!p.match(/End$/)&&(t=v({},t,{type:e.type+"Aborted"})),u.dispatch(t);}return e})})}catch(e){return Promise.reject(e)}},K=/Start$/,Q=/^bootstrap/,Y$1=/^ready/;function Z(e){var n=e.pluginName,t=e.method+"Aborted"+(n?":"+n:"");e.store.dispatch(v({},e.data,{type:t,_:{called:t,from:"abort"}}));}function ee(e,n,t){var r=n[e]||t[e];return r&&r.config?r.config:{}}function ne(e,n){return n.reduce(function(n,t){return t[e]?n.concat({methodName:e,pluginName:t.name,method:t[e]}):n},[])}function te(e,n){var t=e.replace(K,""),r=n?":"+n:"";return [""+e+r,""+t+r,t+"End"+r]}function re(e,n){var t=e.abort;return !!t&&(!0===t||oe(t,n)||t&&oe(t.plugins,n))}function ie(e,n){var t=e.abort;if(!t)return !1;if(!0===t||q$2(t))return !0;var r=t.plugins;return ae(t)&&t.length===n||ae(r)&&r.length===n}function ae(e){return Array.isArray(e)}function oe(e,n){return !(!e||!ae(e))&&e.includes(n)}function ue(e){var n=e.match(/(.*):(.*)/);return !!n&&{method:n[1],name:n[2]}}function ce(e){return Object.keys(e).reduce(function(n,t){return "type"===t||(n[t]=on$1(e[t])?Object.assign({},e[t]):e[t]),n},{})}function se(e,n,t){var r={};return function(i){return function(a){return function(o){try{var u,c=function(e){return u?e:a(f)},s=o.type,l=o.plugins,f=o;if(o.abort)return Promise.resolve(a(o));if(s===q$1.enablePlugin&&i.dispatch({type:q$1.initializeStart,plugins:l,disabled:[],fromEnable:!0,meta:o.meta}),s===q$1.disablePlugin&&setTimeout(function(){return J$2(o.meta.rid,{payload:o})},0),s===q$1.initializeEnd){var m=n(),g=Object.keys(m),h=g.filter(function(e){return l.includes(e)}).map(function(e){return m[e]}),y=[],b=[],I=o.disabled,w=h.map(function(e){var n=e.loaded,t=e.name,a=e.config;return W$1(e,function(){return n({config:a})},1e4).then(function(n){return r[t]||(i.dispatch({type:q$1.pluginReadyType(t),name:t,events:Object.keys(e).filter(function(e){return !M$1.includes(e)})}),r[t]=!0),y=y.concat(t),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return b=b.concat(e.name),e})});Promise.all(w).then(function(e){var n={plugins:y,failed:b,disabled:I};setTimeout(function(){g.length===w.length+I.length&&i.dispatch(v({},{type:q$1.ready},n));},0);});}var E=function(){if(s!==q$1.bootstrap)return /^ready:([^:]*)$/.test(s)&&setTimeout(function(){return F$2(i,n,e)},0),Promise.resolve(function(e,n,t,r,i){try{var a=W$2(n)?n():n,o=e.type,u=o.replace(K,"");if(e._&&e._.called)return Promise.resolve(e);var c=t.getState(),s=(m=a,void 0===(g=c.plugins)&&(g={}),void 0===(h=e.options)&&(h={}),Object.keys(m).filter(function(e){var n=h.plugins||{};return Q$1(n[e])?n[e]:!1!==n.all&&(!g[e]||!1!==g[e].enabled)}).map(function(e){return m[e]}));o===q$1.initializeStart&&e.fromEnable&&(s=Object.keys(c.plugins).filter(function(n){var t=c.plugins[n];return e.plugins.includes(n)&&!t.initialized}).map(function(e){return a[e]}));var l=s.map(function(e){return e.name}),f=function(e,n,t){var r=te(e).map(function(e){return ne(e,n)});return n.reduce(function(t,r){var i=r.name,a=te(e,i).map(function(e){return ne(e,n)}),o=a[0],u=a[1],c=a[2];return o.length&&(t.beforeNS[i]=o),u.length&&(t.duringNS[i]=u),c.length&&(t.afterNS[i]=c),t},{before:r[0],beforeNS:{},during:r[1],duringNS:{},after:r[2],afterNS:{}})}(o,s);return Promise.resolve(G$1({action:e,data:{exact:f.before,namespaced:f.beforeNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){function n(){var n=function(){if(o.match(K))return Promise.resolve(G$1({action:v({},s,{type:u+"End"}),data:{exact:f.after,namespaced:f.afterNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&J$2(e.meta.rid,{payload:e});})}();return n&&n.then?n.then(function(){return e}):e}if(ie(e,l.length))return e;var s,d=function(){if(o!==u)return Promise.resolve(G$1({action:v({},e,{type:u}),data:{exact:f.during,namespaced:f.duringNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){s=e;});s=e;}();return d&&d.then?d.then(n):n()})}catch(e){return Promise.reject(e)}var m,g,h;}(o,n,e,i,t)).then(function(e){return u=1,a(e)})}();return Promise.resolve(E&&E.then?E.then(c):c(E))}catch(e){return Promise.reject(e)}}}}}function le(e){return function(n){return function(n){return function(t){var r=t.type,i=t.key,a=t.value,o=t.options;if(r===q$1.setItem||r===q$1.removeItem){if(t.abort)return n(t);r===q$1.setItem?e.setItem(i,a,o):e.removeItem(i,o);}return n(t)}}}}var fe=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(n,t){e[t]=e[t].concat(n);},this.removeMiddleware=function(n,t){var r=e[t].findIndex(function(e){return e===n});-1!==r&&(e[t]=[].concat(e[t].slice(0,r),e[t].slice(r+1)));},this.dynamicMiddlewares=function(n){return function(t){return function(r){return function(i){var a={getState:t.getState,dispatch:function(e){return t.dispatch(e)}},o=e[n].map(function(e){return e(a)});return N$1.apply(void 0,o)(r)(i)}}}};};function de(e){return function(n,t){void 0===n&&(n={});var r={};if("initialize:aborted"===t.type)return n;if(/^registerPlugin:([^:]*)$/.test(t.type)){var i=pe(t.type,"registerPlugin"),a=e()[i];if(!a||!i)return n;var o=t.enabled,u=a.config;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded({config:u})),config:u},v({},n,r)}if(/^initialize:([^:]*)$/.test(t.type)){var c=pe(t.type,q$1.initialize),s=e()[c];return s&&c?(r[c]=v({},n[c],{initialized:!0,loaded:Boolean(s.loaded({config:s.config}))}),v({},n,r)):n}if(/^ready:([^:]*)$/.test(t.type))return r[t.name]=v({},n[t.name],{loaded:!0}),v({},n,r);switch(t.type){case q$1.disablePlugin:return v({},n,me(t.plugins,!1,n));case q$1.enablePlugin:return v({},n,me(t.plugins,!0,n));default:return n}}}function pe(e,n){return e.substring(n.length+1,e.length)}function me(e,n,t){return e.reduce(function(e,r){return e[r]=v({},t[r],{enabled:n}),e},t)}function ge(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var he={last:{},history:[]};function ve(e,n){void 0===e&&(e=he);var t=n.options,r=n.meta;if(n.type===q$1.track){var i=ge(v({event:n.event,properties:n.properties},Object.keys(t).length&&{options:t},{meta:r}));return v({},e,{last:i,history:e.history.concat(i)})}return e}var ye={actions:[]};function be(e,n){void 0===e&&(e=ye);var t=n.payload;switch(n.type){case"queue":var r;return r=t&&t.type&&t.type===q$1.identify?[n].concat(e.actions):e.actions.concat(n),v({},e,{actions:r});case"dequeue":return [];default:return e}}var Ie=/#.*$/;function we(e){var n=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(n&&n[3]?n[3].split("?")[0].replace(Ie,""):"")}var Ee,Pe,Se,Ne,Oe=function(e){if(void 0===e&&(e={}),!$$2)return e;var n=document,t=n.title,r=n.referrer,i=window,a=i.location,o=i.innerWidth,u=i.innerHeight,c=a.hash,s=a.search,l=function(e){var n=function(){if($$2)for(var e,n=document.getElementsByTagName("link"),t=0;e=n[t];t++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return n?n.match(/\?/)?n:n+e:window.location.href.replace(Ie,"")}(s),f={title:t,url:l,path:we(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),v({},f,e)},Ae={last:{},history:[]};function _e(e,n){void 0===e&&(e=Ae);var t=n.options;if(n.type===q$1.page){var r=ge(v({properties:n.properties,meta:n.meta},Object.keys(t).length&&{options:t}));return v({},e,{last:r,history:e.history.concat(r)})}return e}Ee=function(){if(!$$2)return !1;var e=navigator.appVersion;return ~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Pe=$$2?document.referrer:null,Se=o$2(),Ne=a$3();var xe={initialized:!1,sessionId:y$1(),app:null,version:null,debug:!1,offline:!!$$2&&!navigator.onLine,os:{name:Ee},userAgent:$$2?navigator.userAgent:"node",library:{name:"analytics",version:"0.12.16"},timezone:Ne,locale:Se,campaign:{},referrer:Pe};function je(e,n){void 0===e&&(e=xe);var t=e.initialized,r=n.campaign;switch(n.type){case q$1.campaign:return v({},e,{campaign:r});case q$1.offline:return v({},e,{offline:!0});case q$1.online:return v({},e,{offline:!1});default:return t?e:v({},xe,e,{initialized:!0})}}var ke=["plugins","reducers","storage"];function Te(e,n,t){if($$2){var r=window[(t?"add":"remove")+"EventListener"];e.split(" ").forEach(function(e){r(e,n);});}}function ze(e){var n=Te.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return n(!0),function(e){return n(!1)}}function Me(){return f("analytics",[]),function(e){return function(n$1,t,r){var i=e(n$1,t,r),a=i.dispatch;return Object.assign(i,{dispatch:function(e){return n[o].analytics.push(e.action||e),a(e)}})}}}function qe(e){return function(){return N$1(N$1.apply(null,arguments),Me())}}function Ue(e){return e?rn(e)?e:[e]:[]}function Ve(n,t,r){void 0===n&&(n={});var i,a,o=y$1();return t&&(X[o]=(i=t,a=function(e){for(var n,t=e||Array.prototype.slice.call(arguments),r=0;r<t.length;r++)if(W$2(t[r])){n=t[r];break}return n}(r),function(e){a&&a(e),i(e);})),v({},n,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function Le(n){void 0===n&&(n={});var t=n.reducers||{},c=n.initialUser||{},s$1=(n.plugins||[]).reduce(function(e,n){if(W$2(n))return e.middlewares=e.middlewares.concat(n),e;if(n.NAMESPACE&&(n.name=n.NAMESPACE),!n.name)throw new Error("https://lytics.dev/errors/1");n.config||(n.config={});var t=n.EVENTS?Object.keys(n.EVENTS).map(function(e){return n.EVENTS[e]}):[];e.pluginEnabled[n.name]=!(!1===n.enabled||!1===n.config.enabled),delete n.enabled,n.methods&&(e.methods[n.name]=Object.keys(n.methods).reduce(function(e,t){var r;return e[t]=(r=n.methods[t],function(){for(var e=Array.prototype.slice.call(arguments),n=new Array(r.length),t=0;t<e.length;t++)n[t]=e[t];return n[n.length]=Q,r.apply({instance:Q},n)}),e},{}),delete n.methods);var r=Object.keys(n).concat(t),i=new Set(e.events.concat(r));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(n),e.plugins[n.name])throw new Error(n.name+"AlreadyLoaded");return e.plugins[n.name]=n,e.plugins[n.name].loaded||(e.plugins[n.name].loaded=function(){return !0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),f$1=n.storage?n.storage:{getItem:a$2,setItem:f,removeItem:i$2},p=function(e){return function(n,t,r){return t.getState("user")[n]||(r&&on$1(r)&&r[n]?r[n]:$$1(e)[n]||a$2(D(n))||null)}}(f$1),h=s$1.plugins,w=s$1.events.filter(function(e){return !M$1.includes(e)}).sort(),E=new Set(w.concat(z).filter(function(e){return !M$1.includes(e)})),_=Array.from(E).sort(),x=function(){return h},j=new fe,U=j.addMiddleware,V=j.removeMiddleware,L=j.dynamicMiddlewares,X=function(){throw new Error("Abort disabled inListener")},J=s(),W=$$1(f$1),H=v({},W,c,J.an_uid?{userId:J.an_uid}:{},J.an_aid?{anonymousId:J.an_aid}:{});H.anonymousId||(H.anonymousId=y$1());var G=v({enable:function(e,n){return new Promise(function(t){ue.dispatch({type:q$1.enablePlugin,plugins:Ue(e),_:{originalAction:q$1.enablePlugin}},t,[n]);})},disable:function(e,n){return new Promise(function(t){ue.dispatch({type:q$1.disablePlugin,plugins:Ue(e),_:{originalAction:q$1.disablePlugin}},t,[n]);})}},s$1.methods),K=!1,Q={identify:function(e,n,t,r){try{var i=q$2(e)?e:null,a=on$1(e)?e:n,o=t||{},c=Q.user();f(D(k$1),i);var s=i||a.userId||p(k$1,Q,a);return Promise.resolve(new Promise(function(e){ue.dispatch(v({type:q$1.identifyStart,userId:s,traits:a||{},options:o,anonymousId:c.anonymousId},c.id&&c.id!==i&&{previousId:c.id}),e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},track:function(e,n,t,r){try{var i=on$1(e)?e.event:e;if(!i||!q$2(i))throw new Error("EventMissing");var a=on$1(e)?e:n||{},o=on$1(t)?t:{};return Promise.resolve(new Promise(function(e){ue.dispatch({type:q$1.trackStart,event:i,properties:a,options:o,userId:p(k$1,Q,n),anonymousId:p(T,Q,n)},e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},page:function(e,n,t){try{var r=on$1(e)?e:{},i=on$1(n)?n:{};return Promise.resolve(new Promise(function(a){ue.dispatch({type:q$1.pageStart,properties:Oe(r),options:i,userId:p(k$1,Q,r),anonymousId:p(T,Q,r)},a,[e,n,t]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===k$1||"id"===e)return p(k$1,Q);if(e===T||"anonId"===e)return p(T,Q);var n=Q.getState("user");return e?i$3(n,e):n},reset:function(e){return new Promise(function(n){ue.dispatch({type:q$1.resetStart},n,e);})},ready:function(e){return K&&e({plugins:G,instance:Q}),Q.on(q$1.ready,function(n){e(n),K=!0;})},on:function(e,n){if(!e||!W$2(n))return !1;if(e===q$1.bootstrap)throw new Error(".on disabled for "+e);var t=/Start$|Start:/;if("*"===e){var r=function(e){return function(e){return function(r){return r.type.match(t)&&n({payload:r,instance:Q,plugins:h}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(t)||n({payload:r,instance:Q,plugins:h}),e(r)}}};return U(r,Ce),U(i,Re),function(){V(r,Ce),V(i,Re);}}var a=e.match(t)?Ce:Re,o=function(t){return function(t){return function(r){return r.type===e&&n({payload:r,instance:Q,plugins:h,abort:X}),t(r)}}};return U(o,a),function(){return V(o,a)}},once:function(e,n){if(!e||!W$2(n))return !1;if(e===q$1.bootstrap)throw new Error(".once disabled for "+e);var t=Q.on(e,function(e){n({payload:e.payload,instance:Q,plugins:h,abort:X}),t();});return t},getState:function(e){var n=ue.getState();return e?i$3(n,e):Object.assign({},n)},dispatch:function(e){var n=q$2(e)?{type:e}:e;if(z.includes(n.type))throw new Error("reserved action "+n.type);var t=v({},n,{_:v({originalAction:n.type},e._||{})});ue.dispatch(t);},enablePlugin:G.enable,disablePlugin:G.disable,plugins:G,storage:{getItem:f$1.getItem,setItem:function(e,n,t){ue.dispatch({type:q$1.setItemStart,key:e,value:n,options:t});},removeItem:function(e,n){ue.dispatch({type:q$1.removeItemStart,key:e,options:n});}},setAnonymousId:function(e,n){Q.storage.setItem(A$1,e,n);},events:{core:z,plugins:w}},Y=s$1.middlewares.concat([function(e){return function(e){return function(n){return n.meta||(n.meta=Ve()),e(n)}}},L(Ce),se(Q,x,{all:_,plugins:w}),le(f$1),C$1(Q),B(Q),L(Re)]),Z={context:je,user:R$1(f$1),page:_e,track:ve,plugins:de(x),queue:be},ee=N$1,ne=N$1;if($$2&&n.debug){var te=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;te&&(ee=te({trace:!0,traceLimit:25})),ne=function(){return 0===arguments.length?Me():on$1(typeof arguments[0])?qe():qe().apply(null,arguments)};}var re,ie=function(e){return Object.keys(e).reduce(function(n,t){return ke.includes(t)||(n[t]=e[t]),n},{})}(n),ae=s$1.pluginsArray.reduce(function(e,n){var t=n.name,r=n.config,i=n.loaded,a=s$1.pluginEnabled[t];return e[t]={enabled:a,initialized:!!a&&Boolean(!n.initialize),loaded:Boolean(i({config:r})),config:r},e},{}),oe={context:ie,user:H,plugins:ae},ue=P(function(e){for(var n=Object.keys(e),t={},r=0;r<n.length;r++){var i=n[r];typeof e[i]===y&&(t[i]=e[i]);}var a,o=Object.keys(t);try{!function(e){Object.keys(e).forEach(function(n){var t=e[n];if(typeof t(void 0,{type:"@@redux/INIT"})===b$2||typeof t(void 0,{type:I$2})===b$2)throw new Error("reducer "+n+" "+b$2)});}(t);}catch(e){a=e;}return function(e,n){if(void 0===e&&(e={}),a)throw a;for(var r=!1,i={},u=0;u<o.length;u++){var c=o[u],s=e[c],l=(0, t[c])(s,n);if(typeof l===b$2){var f=S(c,n);throw new Error(f)}i[c]=l,r=r||l!==s;}return r?i:e}}(v({},Z,t)),oe,ne(ee(O$1.apply(void 0,Y))));ue.dispatch=(re=ue.dispatch,function(e,n,t){var r=v({},e,{meta:Ve(e.meta,n,Ue(t))});return re.apply(null,[r])});var ce=Object.keys(h);ue.dispatch({type:q$1.bootstrap,plugins:ce,config:ie,params:J,user:H,initialUser:c,persistedUser:W});var pe=ce.filter(function(e){return s$1.pluginEnabled[e]}),me=ce.filter(function(e){return !s$1.pluginEnabled[e]});return ue.dispatch({type:q$1.registerPlugins,plugins:ce,enabled:s$1.pluginEnabled}),s$1.pluginsArray.map(function(e,n){var t=e.bootstrap,r=e.config,i=e.name;t&&W$2(t)&&t({instance:Q,config:r,payload:e}),ue.dispatch({type:q$1.registerPluginType(i),name:i,enabled:s$1.pluginEnabled[i],plugin:e}),s$1.pluginsArray.length===n+1&&ue.dispatch({type:q$1.initializeStart,plugins:pe,disabled:me});}),ze(function(e){ue.dispatch({type:e?q$1.offline:q$1.online});}),function(e,n,t){setInterval(function(){return F$2(e,n,t)},3e3);}(ue,x,Q),Q}var Ce="before",Re="after";
|
|
234
|
+
function h$1(){return h$1=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);}return e},h$1.apply(null,arguments)}var y="function",b$1="undefined",I$2="reducer",w="@@redux/",E$2=w+"INIT",P$1=w+Math.random().toString(36),S$1=/* #__PURE__ */function(){return typeof Symbol===y&&Symbol.observable||"@@observable"}(),N$1=" != "+y;function O$1(e,n,t){var r;if(typeof n===y&&typeof t===b$1&&(t=n,n=void 0),typeof t!==b$1){if(typeof t!==y)throw new Error("enhancer"+N$1);return t(O$1)(e,n)}if(typeof e!==y)throw new Error(I$2+N$1);var i=e,a=n,o=[],u=o,c=!1;function s(){u===o&&(u=o.slice());}function f(){return a}function d(e){if(typeof e!==y)throw new Error("Listener"+N$1);var n=!0;return s(),u.push(e),function(){if(n){n=!1,s();var t=u.indexOf(e);u.splice(t,1);}}}function p(e){if(!on$1(e))throw new Error("Act != obj");if(typeof e.type===b$1)throw new Error("ActType "+b$1);if(c)throw new Error("Dispatch in "+I$2);try{c=!0,a=i(a,e);}finally{c=!1;}for(var n=o=u,t=0;t<n.length;t++)(0, n[t])();return e}return p({type:E$2}),(r={dispatch:p,subscribe:d,getState:f,replaceReducer:function(e){if(typeof e!==y)throw new Error("next "+I$2+N$1);i=e,p({type:E$2});}})[S$1]=function(){var e,n=d;return (e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function t(){e.next&&e.next(f());}return t(),{unsubscribe:n(t)}}})[S$1]=function(){return this},e},r}function A$2(e,n){var t=n&&n.type;return "action "+(t&&t.toString()||"?")+I$2+" "+e+" returns "+b$1}function _(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function k$1(){var e=arguments;return function(n){return function(t,r,i){var a,o=n(t,r,i),u=o.dispatch,c={getState:o.getState,dispatch:function(e){return u(e)}};return a=[].slice.call(e).map(function(e){return e(c)}),h$1({},o,{dispatch:u=_.apply(void 0,a)(o.dispatch)})}}}var x$1=O$2+"anon_id",j$1=O$2+"user_id",T=O$2+"user_traits",M$1="analytics",q$1="userId",U$1="anonymousId",V$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"],L$1=["name","EVENTS","config","loaded"],C$1=V$1.reduce(function(e,n){return e[n]=n,e},{registerPluginType:function(e){return "registerPlugin:"+e},pluginReadyType:function(e){return "ready:"+e}}),R$1=/^utm_/,$$1=/^an_prop_/,D=/^an_trait_/;function B(e){var n=e.storage.setItem;return function(t){return function(r){return function(i){if(i.type===C$1.bootstrap){var a=i.params,o=i.user,u=i.persistedUser,c=i.initialUser,s=u.userId===o.userId;u.anonymousId!==o.anonymousId&&n(x$1,o.anonymousId),s||n(j$1,o.userId),c.traits&&n(T,h$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,n){if(n.match(R$1)||n.match(/^(d|g)clid/)){var t=n.replace(R$1,"");e.campaign["campaign"===t?"name":t]=a[n];}return n.match($$1)&&(e.props[n.replace($$1,"")]=a[n]),n.match(D)&&(e.traits[n.replace(D,"")]=a[n]),e},{campaign:{},props:{},traits:{}});t.dispatch(h$1({type:C$1.params,raw:a},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&t.dispatch({type:C$1.campaign,campaign:p.campaign});}}return r(i)}}}}function X(e){return function(n,t){if(void 0===n&&(n={}),void 0===t&&(t={}),t.type===C$1.setItemEnd){if(t.key===x$1)return h$1({},n,{anonymousId:t.value});if(t.key===j$1)return h$1({},n,{userId:t.value})}switch(t.type){case C$1.identify:return Object.assign({},n,{userId:t.userId,traits:h$1({},n.traits,t.traits)});case C$1.reset:return [j$1,x$1,T].forEach(function(n){e.removeItem(n);}),Object.assign({},n,{userId:null,anonymousId:null,traits:{}});default:return n}}}function J$2(e){return {userId:e.getItem(j$1),anonymousId:e.getItem(x$1),traits:e.getItem(T)}}var W$1=function(e){return O$2+"TEMP"+O$2+e};function H$1(n){var t=n.storage,r=t.setItem,i=t.removeItem,a=t.getItem;return function(n){return function(t){return function(u){var c=u.userId,s=u.traits,l=u.options;if(u.type===C$1.reset&&([j$1,T,x$1].forEach(function(e){i(e);}),[q$1,U$1,"traits"].forEach(function(e){i$3(W$1(e));})),u.type===C$1.identify){a(x$1)||r(x$1,b$2());var f=a(j$1),d=a(T)||{};f&&f!==c&&n.dispatch({type:C$1.userIdChanged,old:{userId:f,traits:d},new:{userId:c,traits:s},options:l}),c&&r(j$1,c),s&&r(T,h$1({},d,s));}return t(u)}}}}var F$1={};function G$1(e,n){F$1[e]&&W$2(F$1[e])&&(F$1[e](n),delete F$1[e]);}function K(e,n,t){return new Promise(function(r,i){return n()?r(e):t<1?i(h$1({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(a){return K(e,n,t-10).then(r,i)})})}function Q(e){return {abort:e}}function Y$1(e,n,t){var r={},i=n(),a=e.getState(),o=a.plugins,u=a.queue,c=a.user;if(!a.context.offline&&u&&u.actions&&u.actions.length){var s=u.actions.reduce(function(e,n,t){return o[n.plugin].loaded?(e.process.push(n),e.processIndex.push(t)):(e.requeue.push(n),e.requeueIndex.push(t)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(s.processIndex&&s.processIndex.length){s.processIndex.forEach(function(n){var a=u.actions[n],s=a.plugin,f=a.payload.type,p=i[s][f];if(p&&W$2(p)){var m,g=function(e,n){return void 0===e&&(e={}),void 0===n&&(n={}),[q$1,U$1].reduce(function(t,r){return e.hasOwnProperty(r)&&n[r]&&n[r]!==e[r]&&(t[r]=n[r]),t},e)}(a.payload,c),v=r[g.meta.rid];if(!v&&(m=p({payload:g,config:o[s].config,instance:t,abort:Q}))&&on$1(m)&&m.abort)return void(r[g.meta.rid]=!0);if(!v){var y=f+":"+s;e.dispatch(h$1({},g,{type:y,_:{called:y,from:"queueDrain"}}));}}});var f=u.actions.filter(function(e,n){return !~s.processIndex.indexOf(n)});u.actions=f;}}}var Z=function(e){var n=e.data,t=e.action,r=e.instance,i=e.state,a=e.allPlugins,o=e.allMatches,u=e.store,c=e.EVENTS;try{var s=i.plugins,f=i.context,p=t.type,m=p.match(ee),g=n.exact.map(function(e){return e.pluginName});m&&(g=o.during.map(function(e){return e.pluginName}));var v=function(e,n){return function(t,r,i){var a=r.config,o=r.name,u=o+"."+t.type;i&&(u=i.event);var c=t.type.match(ee)?function(e,n,t,r,i){return function(a,o){var u=r?r.name:e,c=o&&se(o)?o:t;if(r&&(!(c=o&&se(o)?o:[e]).includes(e)||1!==c.length))throw new Error("Method "+n+" can only abort "+e+" plugin. "+JSON.stringify(c)+" input valid");return h$1({},i,{abort:{reason:a,plugins:c,caller:n,_:u}})}}(o,u,n,i,t):function(e,n){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+n)}}(t,u);return {payload:de(t),instance:e,config:a||{},abort:c}}}(r,g),y=n.exact.reduce(function(e,n){var t=n.pluginName,r=n.methodName,i=!1;return r.match(/^initialize/)||r.match(/^reset/)||(i=!s[t].loaded),f.offline&&r.match(/^(page|track|identify)/)&&(i=!0),e[""+t]=i,e},{});return Promise.resolve(n.exact.reduce(function(e,i,o){var u=i.pluginName;return Promise.resolve(e).then(function(e){function i(){return Promise.resolve(e)}var o=function(){if(n.namespaced&&n.namespaced[u])return Promise.resolve(n.namespaced[u].reduce(function(e,n,t){return Promise.resolve(e).then(function(e){return n.method&&W$2(n.method)?(function(e,n){var t=fe(e);if(t&&t.name===n){var r=fe(t.method);throw new Error([n+" plugin is calling method "+e,"Plugins cant call self","Use "+t.method+" "+(r?"or "+r.method:"")+" in "+n+" plugin insteadof "+e].join("\n"))}}(n.methodName,n.pluginName),Promise.resolve(n.method({payload:e,instance:r,abort:(t=e,i=u,o=n.pluginName,function(e,n){return h$1({},t,{abort:{reason:e,plugins:n||[i],caller:p,from:o||i}})}),config:ie(n.pluginName,s,a),plugins:s})).then(function(n){var t=on$1(n)?n:{};return Promise.resolve(h$1({},e,t))})):e;var t,i,o;})},Promise.resolve(t))).then(function(n){e[u]=n;});e[u]=t;}();return o&&o.then?o.then(i):i()})},Promise.resolve({}))).then(function(e){return Promise.resolve(n.exact.reduce(function(t,i,o){try{var c=n.exact.length===o+1,f=i.pluginName,d=a[f];return Promise.resolve(t).then(function(n){var t=e[f]?e[f]:{};if(m&&(t=n),ue(t,f))return re({data:t,method:p,instance:r,pluginName:f,store:u}),Promise.resolve(n);if(ue(n,f))return c&&re({data:n,method:p,instance:r,store:u}),Promise.resolve(n);if(y.hasOwnProperty(f)&&!0===y[f])return u.dispatch({type:"queue",plugin:f,payload:t,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(n);var i=v(e[f],a[f]);return Promise.resolve(d[p]({abort:i.abort,payload:t,instance:r,config:ie(f,s,a),plugins:s})).then(function(i){var a=on$1(i)?i:{},o=h$1({},n,a),c=e[f];if(ue(c,f))re({data:c,method:p,instance:r,pluginName:f,store:u});else {var s=p+":"+f;(s.match(/:/g)||[]).length<2&&!p.match(ne)&&!p.match(te)&&r.dispatch(h$1({},m?o:t,{type:s,_:{called:s,from:"submethod"}}));}return Promise.resolve(o)})})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(e){if(!(p.match(ee)||p.match(/^registerPlugin/)||p.match(te)||p.match(ne)||p.match(/^params/)||p.match(/^userIdChanged/))){if(c.plugins.includes(p),e._&&e._.originalAction===p)return e;var t=h$1({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});ce(e,n.exact.length)&&!p.match(/End$/)&&(t=h$1({},t,{type:e.type+"Aborted"})),u.dispatch(t);}return e})})}catch(e){return Promise.reject(e)}},ee=/Start$/,ne=/^bootstrap/,te=/^ready/;function re(e){var n=e.pluginName,t=e.method+"Aborted"+(n?":"+n:"");e.store.dispatch(h$1({},e.data,{type:t,_:{called:t,from:"abort"}}));}function ie(e,n,t){var r=n[e]||t[e];return r&&r.config?r.config:{}}function ae(e,n){return n.reduce(function(n,t){return t[e]?n.concat({methodName:e,pluginName:t.name,method:t[e]}):n},[])}function oe(e,n){var t=e.replace(ee,""),r=n?":"+n:"";return [""+e+r,""+t+r,t+"End"+r]}function ue(e,n){var t=e.abort;return !!t&&(!0===t||le(t,n)||t&&le(t.plugins,n))}function ce(e,n){var t=e.abort;if(!t)return !1;if(!0===t||q$2(t))return !0;var r=t.plugins;return se(t)&&t.length===n||se(r)&&r.length===n}function se(e){return Array.isArray(e)}function le(e,n){return !(!e||!se(e))&&e.includes(n)}function fe(e){var n=e.match(/(.*):(.*)/);return !!n&&{method:n[1],name:n[2]}}function de(e){return Object.keys(e).reduce(function(n,t){return "type"===t||(n[t]=on$1(e[t])?Object.assign({},e[t]):e[t]),n},{})}function pe(e,n,t){var r={};return function(i){return function(a){return function(o){try{var u,c=function(e){return u?e:a(f)},s=o.type,l=o.plugins,f=o;if(o.abort)return Promise.resolve(a(o));if(s===C$1.enablePlugin&&i.dispatch({type:C$1.initializeStart,plugins:l,disabled:[],fromEnable:!0,meta:o.meta}),s===C$1.disablePlugin&&setTimeout(function(){return G$1(o.meta.rid,{payload:o})},0),s===C$1.initializeEnd){var m=n(),g=Object.keys(m),v=g.filter(function(e){return l.includes(e)}).map(function(e){return m[e]}),y=[],b=[],I=o.disabled,w=v.map(function(e){var n=e.loaded,t=e.name,a=e.config;return K(e,function(){return n({config:a})},1e4).then(function(n){return r[t]||(i.dispatch({type:C$1.pluginReadyType(t),name:t,events:Object.keys(e).filter(function(e){return !L$1.includes(e)})}),r[t]=!0),y=y.concat(t),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return b=b.concat(e.name),e})});Promise.all(w).then(function(e){var n={plugins:y,failed:b,disabled:I};setTimeout(function(){g.length===w.length+I.length&&i.dispatch(h$1({},{type:C$1.ready},n));},0);});}var E=function(){if(s!==C$1.bootstrap)return /^ready:([^:]*)$/.test(s)&&setTimeout(function(){return Y$1(i,n,e)},0),Promise.resolve(function(e,n,t,r,i){try{var a=W$2(n)?n():n,o=e.type,u=o.replace(ee,"");if(e._&&e._.called)return Promise.resolve(e);var c=t.getState(),s=(m=a,void 0===(g=c.plugins)&&(g={}),void 0===(v=e.options)&&(v={}),Object.keys(m).filter(function(e){var n=v.plugins||{};return Q$1(n[e])?n[e]:!1!==n.all&&(!g[e]||!1!==g[e].enabled)}).map(function(e){return m[e]}));o===C$1.initializeStart&&e.fromEnable&&(s=Object.keys(c.plugins).filter(function(n){var t=c.plugins[n];return e.plugins.includes(n)&&!t.initialized}).map(function(e){return a[e]}));var l=s.map(function(e){return e.name}),f=function(e,n){var t=oe(e).map(function(e){return ae(e,n)});return n.reduce(function(t,r){var i=r.name,a=oe(e,i).map(function(e){return ae(e,n)}),o=a[0],u=a[1],c=a[2];return o.length&&(t.beforeNS[i]=o),u.length&&(t.duringNS[i]=u),c.length&&(t.afterNS[i]=c),t},{before:t[0],beforeNS:{},during:t[1],duringNS:{},after:t[2],afterNS:{}})}(o,s);return Promise.resolve(Z({action:e,data:{exact:f.before,namespaced:f.beforeNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){function n(){var n=function(){if(o.match(ee))return Promise.resolve(Z({action:h$1({},s,{type:u+"End"}),data:{exact:f.after,namespaced:f.afterNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&G$1(e.meta.rid,{payload:e});})}();return n&&n.then?n.then(function(){return e}):e}if(ce(e,l.length))return e;var s,d=function(){if(o!==u)return Promise.resolve(Z({action:h$1({},e,{type:u}),data:{exact:f.during,namespaced:f.duringNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){s=e;});s=e;}();return d&&d.then?d.then(n):n()})}catch(e){return Promise.reject(e)}var m,g,v;}(o,n,e,i,t)).then(function(e){var n=a(e);return u=1,n})}();return Promise.resolve(E&&E.then?E.then(c):c(E))}catch(e){return Promise.reject(e)}}}}}function me(e){return function(n){return function(n){return function(t){var r=t.type,i=t.key,a=t.value,o=t.options;if(r===C$1.setItem||r===C$1.removeItem){if(t.abort)return n(t);r===C$1.setItem?e.setItem(i,a,o):e.removeItem(i,o);}return n(t)}}}}var ge=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(n,t){e[t]=e[t].concat(n);},this.removeMiddleware=function(n,t){var r=e[t].findIndex(function(e){return e===n});-1!==r&&(e[t]=[].concat(e[t].slice(0,r),e[t].slice(r+1)));},this.dynamicMiddlewares=function(n){return function(t){return function(r){return function(i){var a={getState:t.getState,dispatch:function(e){return t.dispatch(e)}},o=e[n].map(function(e){return e(a)});return _.apply(void 0,o)(r)(i)}}}};};function ve(e){return function(n,t){void 0===n&&(n={});var r={};if("initialize:aborted"===t.type)return n;if(/^registerPlugin:([^:]*)$/.test(t.type)){var i=he(t.type,"registerPlugin"),a=e()[i];if(!a||!i)return n;var o=t.enabled,u=a.config;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded({config:u})),config:u},h$1({},n,r)}if(/^initialize:([^:]*)$/.test(t.type)){var c=he(t.type,C$1.initialize),s=e()[c];return s&&c?(r[c]=h$1({},n[c],{initialized:!0,loaded:Boolean(s.loaded({config:s.config}))}),h$1({},n,r)):n}if(/^ready:([^:]*)$/.test(t.type))return r[t.name]=h$1({},n[t.name],{loaded:!0}),h$1({},n,r);switch(t.type){case C$1.disablePlugin:return h$1({},n,ye(t.plugins,!1,n));case C$1.enablePlugin:return h$1({},n,ye(t.plugins,!0,n));default:return n}}}function he(e,n){return e.substring(n.length+1,e.length)}function ye(e,n,t){return e.reduce(function(e,r){return e[r]=h$1({},t[r],{enabled:n}),e},t)}function be(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var Ie={last:{},history:[]};function we(e,n){void 0===e&&(e=Ie);var t=n.options,r=n.meta;if(n.type===C$1.track){var i=be(h$1({event:n.event,properties:n.properties},Object.keys(t).length&&{options:t},{meta:r}));return h$1({},e,{last:i,history:e.history.concat(i)})}return e}var Ee={actions:[]};function Pe(e,n){void 0===e&&(e=Ee);var t=n.payload;switch(n.type){case"queue":var r;return r=t&&t.type&&t.type===C$1.identify?[n].concat(e.actions):e.actions.concat(n),h$1({},e,{actions:r});case"dequeue":return [];default:return e}}var Se=/#.*$/;function Ne(e){var n=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(n&&n[3]?n[3].split("?")[0].replace(Se,""):"")}var Oe,Ae,_e,ke,xe=function(e){if(void 0===e&&(e={}),!$$2)return e;var n=document,t=n.title,r=n.referrer,i=window,a=i.location,o=i.innerWidth,u=i.innerHeight,c=a.hash,s=a.search,l=function(e){var n=function(){if($$2)for(var e,n=document.getElementsByTagName("link"),t=0;e=n[t];t++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return n?n.match(/\?/)?n:n+e:window.location.href.replace(Se,"")}(s),f={title:t,url:l,path:Ne(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),h$1({},f,e)},je={last:{},history:[]};function Te(e,n){void 0===e&&(e=je);var t=n.options;if(n.type===C$1.page){var r=be(h$1({properties:n.properties,meta:n.meta},Object.keys(t).length&&{options:t}));return h$1({},e,{last:r,history:e.history.concat(r)})}return e}Oe=function(){if(!$$2)return !1;var e=navigator.appVersion;return ~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Ae=$$2?document.referrer:null,_e=o$4(),ke=a$6();var ze={initialized:!1,sessionId:b$2(),app:null,version:null,debug:!1,offline:!!$$2&&!navigator.onLine,os:{name:Oe},userAgent:$$2?navigator.userAgent:"node",library:{name:M$1,version:"0.13.1"},timezone:ke,locale:_e,campaign:{},referrer:Ae};function Me(e,n){void 0===e&&(e=ze);var t=e.initialized,r=n.campaign;switch(n.type){case C$1.campaign:return h$1({},e,{campaign:r});case C$1.offline:return h$1({},e,{offline:!0});case C$1.online:return h$1({},e,{offline:!1});default:return t?e:h$1({},ze,e,{initialized:!0})}}var qe=["plugins","reducers","storage"];function Ue(e,n,t){if($$2){var r=window[(t?"add":"remove")+"EventListener"];e.split(" ").forEach(function(e){r(e,n);});}}function Ve(e){var n=Ue.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return n(!0),function(e){return n(!1)}}function Le(){return a$4(M$1,[]),function(e){return function(n,t,r){var i=e(n,t,r),a=i.dispatch;return Object.assign(i,{dispatch:function(e){return l$1[o$2][M$1].push(e.action||e),a(e)}})}}}function Ce(e){return function(){return _(_.apply(null,arguments),Le())}}function Re(e){return e?rn(e)?e:[e]:[]}function $e(n,t,r){void 0===n&&(n={});var i,a,o=b$2();return t&&(F$1[o]=(i=t,a=function(e){for(var n,t=e||Array.prototype.slice.call(arguments),r=0;r<t.length;r++)if(W$2(t[r])){n=t[r];break}return n}(r),function(e){a&&a(e),i(e);})),h$1({},n,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function De(n){void 0===n&&(n={});var t=n.reducers||{},c=n.initialUser||{},s=(n.plugins||[]).reduce(function(e,n){if(W$2(n))return e.middlewares=e.middlewares.concat(n),e;if(n.NAMESPACE&&(n.name=n.NAMESPACE),!n.name)throw new Error("https://lytics.dev/errors/1");n.config||(n.config={});var t=n.EVENTS?Object.keys(n.EVENTS).map(function(e){return n.EVENTS[e]}):[];e.pluginEnabled[n.name]=!(!1===n.enabled||!1===n.config.enabled),delete n.enabled,n.methods&&(e.methods[n.name]=Object.keys(n.methods).reduce(function(e,t){var r;return e[t]=(r=n.methods[t],function(){for(var e=Array.prototype.slice.call(arguments),n=new Array(r.length),t=0;t<e.length;t++)n[t]=e[t];return n[n.length]=Z,r.apply({instance:Z},n)}),e},{}),delete n.methods);var r=Object.keys(n).concat(t),i=new Set(e.events.concat(r));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(n),e.plugins[n.name])throw new Error(n.name+"AlreadyLoaded");return e.plugins[n.name]=n,e.plugins[n.name].loaded||(e.plugins[n.name].loaded=function(){return !0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),f$1=n.storage?n.storage:{getItem:f,setItem:a$4,removeItem:i$3},p=function(e){return function(n,t,r){return t.getState("user")[n]||(r&&on$1(r)&&r[n]?r[n]:J$2(e)[n]||f(W$1(n))||null)}}(f$1),v=s.plugins,w=s.events.filter(function(e){return !L$1.includes(e)}).sort(),S=new Set(w.concat(V$1).filter(function(e){return !L$1.includes(e)})),N=Array.from(S).sort(),j=function(){return v},T=new ge,z=T.addMiddleware,M=T.removeMiddleware,R=T.dynamicMiddlewares,$=function(){throw new Error("Abort disabled inListener")},D=s$1(),F=J$2(f$1),G=h$1({},F,c,D.an_uid?{userId:D.an_uid}:{},D.an_aid?{anonymousId:D.an_aid}:{});G.anonymousId||(G.anonymousId=b$2());var K=h$1({enable:function(e,n){return new Promise(function(t){se.dispatch({type:C$1.enablePlugin,plugins:Re(e),_:{originalAction:C$1.enablePlugin}},t,[n]);})},disable:function(e,n){return new Promise(function(t){se.dispatch({type:C$1.disablePlugin,plugins:Re(e),_:{originalAction:C$1.disablePlugin}},t,[n]);})}},s.methods),Q=!1,Z={identify:function(e,n,t,r){try{var i=q$2(e)?e:null,a=on$1(e)?e:n,o=t||{},c=Z.user();a$4(W$1(q$1),i);var s=i||a.userId||p(q$1,Z,a);return Promise.resolve(new Promise(function(e){se.dispatch(h$1({type:C$1.identifyStart,userId:s,traits:a||{},options:o,anonymousId:c.anonymousId},c.id&&c.id!==i&&{previousId:c.id}),e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},track:function(e,n,t,r){try{var i=on$1(e)?e.event:e;if(!i||!q$2(i))throw new Error("EventMissing");var a=on$1(e)?e:n||{},o=on$1(t)?t:{};return Promise.resolve(new Promise(function(e){se.dispatch({type:C$1.trackStart,event:i,properties:a,options:o,userId:p(q$1,Z,n),anonymousId:p(U$1,Z,n)},e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},page:function(e,n,t){try{var r=on$1(e)?e:{},i=on$1(n)?n:{};return Promise.resolve(new Promise(function(a){se.dispatch({type:C$1.pageStart,properties:xe(r),options:i,userId:p(q$1,Z,r),anonymousId:p(U$1,Z,r)},a,[e,n,t]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===q$1||"id"===e)return p(q$1,Z);if(e===U$1||"anonId"===e)return p(U$1,Z);var n=Z.getState("user");return e?i$6(n,e):n},reset:function(e){return new Promise(function(n){se.dispatch({type:C$1.resetStart},n,e);})},ready:function(e){return Q&&e({plugins:K,instance:Z}),Z.on(C$1.ready,function(n){e&&e(n),Q=!0;})},on:function(e,n){if(!e||!W$2(n))return !1;if(e===C$1.bootstrap)throw new Error(".on disabled for "+e);var t=/Start$|Start:/;if("*"===e){var r=function(e){return function(e){return function(r){return r.type.match(t)&&n({payload:r,instance:Z,plugins:v}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(t)||n({payload:r,instance:Z,plugins:v}),e(r)}}};return z(r,Be),z(i,Xe),function(){M(r,Be),M(i,Xe);}}var a=e.match(t)?Be:Xe,o=function(t){return function(t){return function(r){return r.type===e&&n({payload:r,instance:Z,plugins:v,abort:$}),t(r)}}};return z(o,a),function(){return M(o,a)}},once:function(e,n){if(!e||!W$2(n))return !1;if(e===C$1.bootstrap)throw new Error(".once disabled for "+e);var t=Z.on(e,function(e){n({payload:e.payload,instance:Z,plugins:v,abort:$}),t();});return t},getState:function(e){var n=se.getState();return e?i$6(n,e):Object.assign({},n)},dispatch:function(e){var n=q$2(e)?{type:e}:e;if(V$1.includes(n.type))throw new Error("reserved action "+n.type);var t=h$1({},n,{_:h$1({originalAction:n.type},e._||{})});se.dispatch(t);},enablePlugin:K.enable,disablePlugin:K.disable,plugins:K,storage:{getItem:f$1.getItem,setItem:function(e,n,t){se.dispatch({type:C$1.setItemStart,key:e,value:n,options:t});},removeItem:function(e,n){se.dispatch({type:C$1.removeItemStart,key:e,options:n});}},setAnonymousId:function(e,n){Z.storage.setItem(x$1,e,n);},events:{core:V$1,plugins:w}},ee=s.middlewares.concat([function(e){return function(e){return function(n){return n.meta||(n.meta=$e()),e(n)}}},R(Be),pe(Z,j,{all:N,plugins:w}),me(f$1),B(Z),H$1(Z),R(Xe)]),ne={context:Me,user:X(f$1),page:Te,track:we,plugins:ve(j),queue:Pe},te=_,re=_;if($$2&&n.debug){var ie=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;ie&&(te=ie({trace:!0,traceLimit:25})),re=function(){return 0===arguments.length?Le():on$1(typeof arguments[0])?Ce():Ce().apply(null,arguments)};}var ae,oe=function(e){return Object.keys(e).reduce(function(n,t){return qe.includes(t)||(n[t]=e[t]),n},{})}(n),ue=s.pluginsArray.reduce(function(e,n){var t=n.name,r=n.config,i=n.loaded,a=s.pluginEnabled[t];return e[t]={enabled:a,initialized:!!a&&Boolean(!n.initialize),loaded:Boolean(i({config:r})),config:r},e},{}),ce={context:oe,user:G,plugins:ue},se=O$1(function(e){for(var n=Object.keys(e),t={},r=0;r<n.length;r++){var i=n[r];typeof e[i]===y&&(t[i]=e[i]);}var a,o=Object.keys(t);try{!function(e){Object.keys(e).forEach(function(n){var t=e[n];if(typeof t(void 0,{type:E$2})===b$1||typeof t(void 0,{type:P$1})===b$1)throw new Error(I$2+" "+n+" "+b$1)});}(t);}catch(e){a=e;}return function(e,n){if(void 0===e&&(e={}),a)throw a;for(var r=!1,i={},u=0;u<o.length;u++){var c=o[u],s=e[c],l=(0, t[c])(s,n);if(typeof l===b$1){var f=A$2(c,n);throw new Error(f)}i[c]=l,r=r||l!==s;}return r?i:e}}(h$1({},ne,t)),ce,re(te(k$1.apply(void 0,ee))));se.dispatch=(ae=se.dispatch,function(e,n,t){var r=h$1({},e,{meta:$e(e.meta,n,Re(t))});return ae.apply(null,[r])});var le=Object.keys(v);se.dispatch({type:C$1.bootstrap,plugins:le,config:oe,params:D,user:G,initialUser:c,persistedUser:F});var fe=le.filter(function(e){return s.pluginEnabled[e]}),de=le.filter(function(e){return !s.pluginEnabled[e]});return se.dispatch({type:C$1.registerPlugins,plugins:le,enabled:s.pluginEnabled}),s.pluginsArray.map(function(e,n){var t=e.bootstrap,r=e.config,i=e.name;t&&W$2(t)&&t({instance:Z,config:r,payload:e}),se.dispatch({type:C$1.registerPluginType(i),name:i,enabled:s.pluginEnabled[i],plugin:e}),s.pluginsArray.length===n+1&&se.dispatch({type:C$1.initializeStart,plugins:fe,disabled:de});}),Ve(function(e){se.dispatch({type:e?C$1.offline:C$1.online});}),function(e,n,t){setInterval(function(){return Y$1(e,n,t)},3e3);}(se,j,Z),Z}var Be="before",Xe="after";
|
|
235
235
|
|
|
236
|
-
var t="cookie",i$1=a$
|
|
236
|
+
var t$1="cookie",i$1=a$2(),r$2=d$1,c$1=d$1;function u(e){return i$1?d$1(e,"",-1):i$3(e)}function a$2(){if(void 0!==i$1)return i$1;var e=t$1+t$1;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(n,t,r,c,u,a){if("undefined"!=typeof window){var d=arguments.length>1;return !1===i$1&&(d?a$4(n,t):f(n)),d?document.cookie=n+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(c?"; path="+c:"")+(u?"; domain="+u:"")+(a?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+n+"=")[1]||"").split(";")[0])}}
|
|
237
237
|
|
|
238
|
-
var r="localStorage",
|
|
238
|
+
var r$1="localStorage",m$1=s.bind(null,r$1);u$2(r$1,"getItem",f);u$2(r$1,"setItem",a$4);u$2(r$1,"removeItem",i$3);
|
|
239
239
|
|
|
240
|
-
var a="sessionStorage",
|
|
240
|
+
var a$1="sessionStorage",l=s.bind(null,a$1);u$2(a$1,"getItem",f);u$2(a$1,"setItem",a$4);u$2(a$1,"removeItem",i$3);
|
|
241
241
|
|
|
242
|
-
var
|
|
242
|
+
var n="function",t="string",e="undefined",r="boolean",o="object",c="number",i="symbol",a="null",m="any",v="*",S="form",j="input",A$1="button",E$1="select",P=typeof process!==e?process:{};P.env&&P.env.NODE_ENV||"";var $=typeof document!==e;null!=P.versions&&null!=P.versions.node;typeof Deno!==e&&typeof Deno.core!==e;$&&"nodejs"===window.name||typeof navigator!==e&&typeof navigator.userAgent!==e&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M(n,t){return t.charAt(0)[n]()+t.slice(1)}var U=M.bind(null,"toUpperCase"),H=M.bind(null,"toLowerCase");function J$1(n){return Y(n)?U(a):typeof n===o?yn(n):Object.prototype.toString.call(n).slice(8,-1)}function R(n,t){void 0===t&&(t=!0);var e=J$1(n);return t?H(e):e}function V(n,t){return typeof t===n}var W=V.bind(null,n),q=V.bind(null,t),I$1=V.bind(null,e);V.bind(null,r);V.bind(null,i);function Y(n){return null===n}function nn(n){return R(n)===c&&!isNaN(n)}function on(n){if(!un(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un(n){return n&&(typeof n===o||null!==n)}function yn(n){return W(n.constructor)?n.constructor.name:null}function hn(n){return n instanceof Error||q(n.message)&&n.constructor&&nn(n.constructor.stackTraceLimit)}function Sn(n,t){if("object"!=typeof t||Y(t))return !1;if(t instanceof n)return !0;var e=R(new n(""));if(hn(t))for(;t;){if(R(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn.bind(null,TypeError);Sn.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,S);_n($n,A$1);_n($n,j);_n($n,E$1);
|
|
243
243
|
|
|
244
|
-
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=
|
|
244
|
+
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=m$1(),O=l(),x=a$2();function C(o,e){if(o){var r=A(e),a=!N(r),s=d(r)?I(localStorage.getItem(o)):void 0;if(a&&!I$1(s))return s;var n=h(r)?I(r$2(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=f(o);return a?u:{localStorage:s,sessionStorage:l,cookie:n,global:u}}}function L(r,a,l){if(r&&!I$1(a)){var u={},g=A(l),m=JSON.stringify(a),p=!N(g);return d(g)&&(u[r$1]=F(r$1,a,I(localStorage.getItem(r))),localStorage.setItem(r,m),p)?u[r$1]:h(g)&&(u[t$1]=F(t$1,a,I(r$2(r))),c$1(r,m),p)?u[t$1]:E(g)&&(u[a$1]=F(a$1,a,I(sessionStorage.getItem(r))),sessionStorage.setItem(r,m),p)?u[a$1]:(u[n$2]=F(n$2,a,f(r)),a$4(r,a),p?u[n$2]:u)}}function b(t,e){if(t){var a=A(e),i=C(t,v),n={};return !I$1(i.localStorage)&&d(a)&&(localStorage.removeItem(t),n[r$1]=i.localStorage),!I$1(i.cookie)&&h(a)&&(u(t),n[t$1]=i.cookie),!I$1(i.sessionStorage)&&E(a)&&(sessionStorage.removeItem(t),n[a$1]=i.sessionStorage),!I$1(i.global)&&G(a,n$2)&&(i$3(t),n[n$2]=i.global),n}}function A(t){return t?q(t)?t:t.storage:m}function d(t){return k&&G(t,r$1)}function h(t){return x&&G(t,t$1)}function E(t){return O&&G(t,a$1)}function N(t){return t===v||"all"===t}function G(t,o){return t===m||t===o||N(t)}function F(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:L,getItem:C,removeItem:b};
|
|
245
245
|
|
|
246
246
|
function _defineProperty(obj, key, value) {
|
|
247
247
|
if (key in obj) {
|
|
@@ -254,23 +254,19 @@
|
|
|
254
254
|
} else {
|
|
255
255
|
obj[key] = value;
|
|
256
256
|
}
|
|
257
|
-
|
|
258
257
|
return obj;
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
function ownKeys(object, enumerableOnly) {
|
|
262
261
|
var keys = Object.keys(object);
|
|
263
|
-
|
|
264
262
|
if (Object.getOwnPropertySymbols) {
|
|
265
263
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
266
264
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
267
265
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
268
266
|
})), keys.push.apply(keys, symbols);
|
|
269
267
|
}
|
|
270
|
-
|
|
271
268
|
return keys;
|
|
272
269
|
}
|
|
273
|
-
|
|
274
270
|
function _objectSpread2(target) {
|
|
275
271
|
for (var i = 1; i < arguments.length; i++) {
|
|
276
272
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -280,16 +276,16 @@
|
|
|
280
276
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
281
277
|
});
|
|
282
278
|
}
|
|
283
|
-
|
|
284
279
|
return target;
|
|
285
280
|
}
|
|
286
281
|
|
|
282
|
+
// See ../packages/analytics-core for source code
|
|
287
283
|
function analyticsLib() {
|
|
288
284
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
289
285
|
var defaultSettings = {
|
|
290
286
|
storage: J
|
|
291
287
|
};
|
|
292
|
-
return
|
|
288
|
+
return De(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
|
|
293
289
|
}
|
|
294
290
|
|
|
295
291
|
/******************************************************************************
|
|
@@ -542,6 +538,168 @@
|
|
|
542
538
|
}
|
|
543
539
|
}
|
|
544
540
|
|
|
541
|
+
/* istanbul ignore file */
|
|
542
|
+
// Note: currently this is all internal to the package, and we are not exposing
|
|
543
|
+
// anything that a user can set... but we need all this to be able to ensure
|
|
544
|
+
// that multiple instances of the package can share the same config.
|
|
545
|
+
/**
|
|
546
|
+
* The default config for the request module. This is used to store
|
|
547
|
+
* the no-cors domains and pending requests.
|
|
548
|
+
*/
|
|
549
|
+
const DEFAULT_ARCGIS_REQUEST_CONFIG = {
|
|
550
|
+
noCorsDomains: [],
|
|
551
|
+
crossOriginNoCorsDomains: {},
|
|
552
|
+
pendingNoCorsRequests: {}
|
|
553
|
+
};
|
|
554
|
+
const GLOBAL_VARIABLE_NAME = "ARCGIS_REST_JS_NO_CORS";
|
|
555
|
+
// Set the global variable to the default config if it is not aleady defined
|
|
556
|
+
// This is done to ensure that all instances of rest-request work with a single
|
|
557
|
+
// instance of the config
|
|
558
|
+
if (!globalThis[GLOBAL_VARIABLE_NAME]) {
|
|
559
|
+
globalThis[GLOBAL_VARIABLE_NAME] = Object.assign({}, DEFAULT_ARCGIS_REQUEST_CONFIG);
|
|
560
|
+
}
|
|
561
|
+
// export the settings as immutable consts that read from the global config
|
|
562
|
+
const requestConfig = globalThis[GLOBAL_VARIABLE_NAME];
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Send a no-cors request to the passed uri. This is used to pick up
|
|
566
|
+
* a cookie from a 3rd party server to meet a requirement of some authentication
|
|
567
|
+
* flows.
|
|
568
|
+
* @param url
|
|
569
|
+
* @returns
|
|
570
|
+
*/
|
|
571
|
+
function sendNoCorsRequest(url) {
|
|
572
|
+
// drop any query params, other than f=json
|
|
573
|
+
const urlObj = new URL(url);
|
|
574
|
+
url = urlObj.origin + urlObj.pathname;
|
|
575
|
+
if (urlObj.search.includes("f=json")) {
|
|
576
|
+
url += "?f=json";
|
|
577
|
+
}
|
|
578
|
+
const origin = urlObj.origin;
|
|
579
|
+
// If we have already sent a no-cors request to this url, return the promise
|
|
580
|
+
// so we don't send multiple requests
|
|
581
|
+
if (requestConfig.pendingNoCorsRequests[origin]) {
|
|
582
|
+
return requestConfig.pendingNoCorsRequests[origin];
|
|
583
|
+
}
|
|
584
|
+
// Make the request and add to the cache
|
|
585
|
+
requestConfig.pendingNoCorsRequests[origin] = fetch(url, {
|
|
586
|
+
mode: "no-cors",
|
|
587
|
+
credentials: "include",
|
|
588
|
+
cache: "no-store"
|
|
589
|
+
})
|
|
590
|
+
.then((response) => {
|
|
591
|
+
// Add to the list of cross-origin no-cors domains
|
|
592
|
+
// if the domain is not already in the list
|
|
593
|
+
if (requestConfig.noCorsDomains.indexOf(origin) === -1) {
|
|
594
|
+
requestConfig.noCorsDomains.push(origin);
|
|
595
|
+
}
|
|
596
|
+
// Hold the timestamp of this request so we can decide when to
|
|
597
|
+
// send another request to this domain
|
|
598
|
+
requestConfig.crossOriginNoCorsDomains[origin.toLowerCase()] = Date.now();
|
|
599
|
+
// Remove the pending request from the cache
|
|
600
|
+
delete requestConfig.pendingNoCorsRequests[origin];
|
|
601
|
+
// Due to limitations of fetchMock at the version of the tooling
|
|
602
|
+
// in this project, we can't mock the response type of a no-cors request
|
|
603
|
+
// and thus we can't test this. So we are going to comment this out
|
|
604
|
+
// and leave it in place for now. If we need to test this, we can
|
|
605
|
+
// update the tooling to a version that supports this. Also
|
|
606
|
+
// JS SDK does not do this check, so we are going to leave it out for now.
|
|
607
|
+
// ================================================================
|
|
608
|
+
// no-cors requests are opaque to javascript
|
|
609
|
+
// and thus will always return a response with a type of "opaque"
|
|
610
|
+
// if (response.type === "opaque") {
|
|
611
|
+
// return Promise.resolve();
|
|
612
|
+
// } else {
|
|
613
|
+
// // Not sure if this is possible, but since we have a check above
|
|
614
|
+
// // lets handle the else case
|
|
615
|
+
// return Promise.reject(
|
|
616
|
+
// new Error(`no-cors request to ${origin} not opaque`)
|
|
617
|
+
// );
|
|
618
|
+
// }
|
|
619
|
+
// ================================================================
|
|
620
|
+
})
|
|
621
|
+
.catch((e) => {
|
|
622
|
+
// Not sure this is necessary, but if the request fails
|
|
623
|
+
// we should remove it from the pending requests
|
|
624
|
+
// and return a rejected promise with some information
|
|
625
|
+
delete requestConfig.pendingNoCorsRequests[origin];
|
|
626
|
+
return Promise.reject(new Error(`no-cors request to ${origin} failed`));
|
|
627
|
+
});
|
|
628
|
+
// return the promise
|
|
629
|
+
return requestConfig.pendingNoCorsRequests[origin];
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Register the domains that are allowed to be used in no-cors requests
|
|
633
|
+
* This is called by `request` when the portal/self response is intercepted
|
|
634
|
+
* and the `.authorizedCrossOriginNoCorsDomains` property is set.
|
|
635
|
+
* @param authorizedCrossOriginNoCorsDomains
|
|
636
|
+
*/
|
|
637
|
+
function registerNoCorsDomains(authorizedCrossOriginNoCorsDomains) {
|
|
638
|
+
// register the domains
|
|
639
|
+
authorizedCrossOriginNoCorsDomains.forEach((domain) => {
|
|
640
|
+
// ensure domain is lower case and ensure protocol is included
|
|
641
|
+
domain = domain.toLowerCase();
|
|
642
|
+
if (/^https?:\/\//.test(domain)) {
|
|
643
|
+
addNoCorsDomain(domain);
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
// no protocol present, so add http and https
|
|
647
|
+
addNoCorsDomain("http://" + domain);
|
|
648
|
+
addNoCorsDomain("https://" + domain);
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Ensure we don't get duplicate domains in the no-cors domains list
|
|
654
|
+
* @param domain
|
|
655
|
+
*/
|
|
656
|
+
function addNoCorsDomain(url) {
|
|
657
|
+
// Since the caller of this always ensures a protocol is present
|
|
658
|
+
// we can safely use the URL constructor to get the origin
|
|
659
|
+
// and add it to the no-cors domains list
|
|
660
|
+
const uri = new URL(url);
|
|
661
|
+
const domain = uri.origin;
|
|
662
|
+
if (requestConfig.noCorsDomains.indexOf(domain) === -1) {
|
|
663
|
+
requestConfig.noCorsDomains.push(domain);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Is the origin of the passed url in the no-cors domains list?
|
|
668
|
+
* @param url
|
|
669
|
+
* @returns
|
|
670
|
+
*/
|
|
671
|
+
function isNoCorsDomain(url) {
|
|
672
|
+
let result = false;
|
|
673
|
+
if (requestConfig.noCorsDomains.length) {
|
|
674
|
+
// is the current url in the no-cors domains?
|
|
675
|
+
const origin = new URL(url).origin.toLowerCase();
|
|
676
|
+
result = requestConfig.noCorsDomains.some((domain) => {
|
|
677
|
+
return origin.includes(domain);
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
return result;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Is the origin of the passed url in the no-cors domains list
|
|
684
|
+
* and do we need to send a no-cors request?
|
|
685
|
+
*
|
|
686
|
+
* @param url
|
|
687
|
+
* @returns
|
|
688
|
+
*/
|
|
689
|
+
function isNoCorsRequestRequired(url) {
|
|
690
|
+
let result = false;
|
|
691
|
+
// is the current origin in the no-cors domains?
|
|
692
|
+
if (isNoCorsDomain(url)) {
|
|
693
|
+
const origin = new URL(url).origin.toLowerCase();
|
|
694
|
+
// check if we have sent a no-cors request to this domain in the last hour
|
|
695
|
+
const lastRequest = requestConfig.crossOriginNoCorsDomains[origin] || 0;
|
|
696
|
+
if (Date.now() - 60 * 60000 > lastRequest) {
|
|
697
|
+
result = true;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return result;
|
|
701
|
+
}
|
|
702
|
+
|
|
545
703
|
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
|
546
704
|
* Apache-2.0 */
|
|
547
705
|
/**
|
|
@@ -562,6 +720,28 @@
|
|
|
562
720
|
});
|
|
563
721
|
}
|
|
564
722
|
|
|
723
|
+
/**
|
|
724
|
+
* Is the given URL the same origin as the current window?
|
|
725
|
+
* Used to determine if we need to do any additional cross-origin
|
|
726
|
+
* handling for the request.
|
|
727
|
+
* @param url
|
|
728
|
+
* @param win - optional window object to use for origin comparison
|
|
729
|
+
* (useful for testing)
|
|
730
|
+
* @returns
|
|
731
|
+
*/
|
|
732
|
+
function isSameOrigin(url, win) {
|
|
733
|
+
var _a;
|
|
734
|
+
/* istanbul ignore next */
|
|
735
|
+
if ((!win && !window) || !url) {
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
win = win || window;
|
|
740
|
+
const origin = (_a = win.location) === null || _a === void 0 ? void 0 : _a.origin;
|
|
741
|
+
return url.startsWith(origin);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
565
745
|
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
|
566
746
|
* Apache-2.0 */
|
|
567
747
|
const NODEJS_DEFAULT_REFERER_HEADER = `@esri/arcgis-rest-js`;
|
|
@@ -717,6 +897,10 @@
|
|
|
717
897
|
needed to support sending IWA cookies */
|
|
718
898
|
credentials: options.credentials || "same-origin"
|
|
719
899
|
};
|
|
900
|
+
// Is this a no-cors domain? if so we need to set credentials to include
|
|
901
|
+
if (isNoCorsDomain(url)) {
|
|
902
|
+
fetchOptions.credentials = "include";
|
|
903
|
+
}
|
|
720
904
|
// the /oauth2/platformSelf route will add X-Esri-Auth-Client-Id header
|
|
721
905
|
// and that request needs to send cookies cross domain
|
|
722
906
|
// so we need to set the credentials to "include"
|
|
@@ -752,7 +936,31 @@
|
|
|
752
936
|
// for errors in GET requests we want the URL passed to the error to be the URL before
|
|
753
937
|
// query params are applied.
|
|
754
938
|
const originalUrl = url;
|
|
755
|
-
|
|
939
|
+
// default to false, for nodejs
|
|
940
|
+
let sameOrigin = false;
|
|
941
|
+
// if we are in a browser, check if the url is same origin
|
|
942
|
+
/* istanbul ignore else */
|
|
943
|
+
if (typeof window !== "undefined") {
|
|
944
|
+
sameOrigin = isSameOrigin(url);
|
|
945
|
+
}
|
|
946
|
+
const requiresNoCors = !sameOrigin && isNoCorsRequestRequired(url);
|
|
947
|
+
// the /oauth2/platformSelf route will add X-Esri-Auth-Client-Id header
|
|
948
|
+
// and that request needs to send cookies cross domain
|
|
949
|
+
// so we need to set the credentials to "include"
|
|
950
|
+
if (options.headers &&
|
|
951
|
+
options.headers["X-Esri-Auth-Client-Id"] &&
|
|
952
|
+
url.indexOf("/oauth2/platformSelf") > -1) {
|
|
953
|
+
fetchOptions.credentials = "include";
|
|
954
|
+
}
|
|
955
|
+
// Simple first promise that we may turn into the no-cors request
|
|
956
|
+
let firstPromise = Promise.resolve();
|
|
957
|
+
if (requiresNoCors) {
|
|
958
|
+
// ensure we send cookies on the request after
|
|
959
|
+
fetchOptions.credentials = "include";
|
|
960
|
+
firstPromise = sendNoCorsRequest(url);
|
|
961
|
+
}
|
|
962
|
+
return firstPromise
|
|
963
|
+
.then(() => authentication
|
|
756
964
|
? authentication.getToken(url).catch((err) => {
|
|
757
965
|
/**
|
|
758
966
|
* append original request url and requestOptions
|
|
@@ -795,7 +1003,8 @@
|
|
|
795
1003
|
const urlWithQueryString = queryParams === "" ? url : url + "?" + encodeQueryString(params);
|
|
796
1004
|
if (
|
|
797
1005
|
// This would exceed the maximum length for URLs by 2000 as default or as specified by the consumer and requires POST
|
|
798
|
-
(options.maxUrlLength &&
|
|
1006
|
+
(options.maxUrlLength &&
|
|
1007
|
+
urlWithQueryString.length > options.maxUrlLength) ||
|
|
799
1008
|
(!options.maxUrlLength && urlWithQueryString.length > 2000) ||
|
|
800
1009
|
// Or if the customer requires the token to be hidden and it has not already been hidden in the header (for browsers)
|
|
801
1010
|
(params.token && options.hideToken)) {
|
|
@@ -893,6 +1102,14 @@
|
|
|
893
1102
|
// Most ArcGIS Server services will return a successful status code but include an error in the response body.
|
|
894
1103
|
if ((params.f === "json" || params.f === "geojson") && !rawResponse) {
|
|
895
1104
|
const response = checkForErrors(data, originalUrl, params, options, originalAuthError);
|
|
1105
|
+
// If this was a portal/self call, and we got authorizedNoCorsDomains back
|
|
1106
|
+
// register them
|
|
1107
|
+
if (data && /\/sharing\/rest\/(accounts|portals)\/self/i.test(url)) {
|
|
1108
|
+
// if we have a list of no-cors domains, register them
|
|
1109
|
+
if (Array.isArray(data.authorizedCrossOriginNoCorsDomains)) {
|
|
1110
|
+
registerNoCorsDomains(data.authorizedCrossOriginNoCorsDomains);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
896
1113
|
if (originalAuthError) {
|
|
897
1114
|
/* If the request was made to an unfederated service that
|
|
898
1115
|
didn't require authentication, add the base url and a dummy token
|