UNPKG

keen-analysis

Version:

A JavaScript client for Keen.IO

2 lines 47.2 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=24)}([function(e,t){e.exports=function(e){for(var t=1;t<arguments.length;t++)for(var r in arguments[t])e[r]=arguments[t][r];return e}},function(e,t){e.exports=function(e,t,r){var n;if(!e)return 0;if(r=r||e,e instanceof Array){for(n=0;n<e.length;n++)if(!1===t.call(r,e[n],n,e))return 0}else for(n in e)if(e.hasOwnProperty(n)&&!1===t.call(r,e[n],n,e))return 0;return 1}},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";r.r(t),function(e){var t=r(9),n=r(4),o=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();o.Promise?o.Promise.prototype.finally||(o.Promise.prototype.finally=n.a):o.Promise=t.a}.call(this,r(2))},function(e,t,r){"use strict";t.a=function(e){var t=this.constructor;return this.then(function(r){return t.resolve(e()).then(function(){return r})},function(r){return t.resolve(e()).then(function(){return t.reject(r)})})}},function(e,t){!function(e){"use strict";if(!e.fetch){var t={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=function(e){return e&&DataView.prototype.isPrototypeOf(e)},o=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};l.prototype.append=function(e,t){e=s(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=u(t)},l.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},l.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),c(e)},l.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),c(e)},l.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),c(e)},t.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},y.call(v.prototype),y.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},b.error=function(){var e=new b(null,{status:0,statusText:""});return e.type="error",e};var a=[301,302,303,307,308];b.redirect=function(e,t){if(-1===a.indexOf(t))throw new RangeError("Invalid status code");return new b(null,{status:t,headers:{location:e}})},e.Headers=l,e.Request=v,e.Response=b,e.fetch=function(e,r){return new Promise(function(n,o){var i=new v(e,r),a=new XMLHttpRequest;a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new b(o,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.open(i.method,i.url,!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&t.blob&&(a.responseType="blob"),i.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),a.send(void 0===i._bodyInit?null:i._bodyInit)})},e.fetch.polyfill=!0}function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function l(e){this.map={},e instanceof l?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function d(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function p(e){var t=new FileReader,r=d(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&n(e))this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!o(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=h(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=d(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},t.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}function v(e,t){var r,n,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(r=t.method||this.method||"GET",n=r.toUpperCase(),i.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}}),t}function b(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}}("undefined"!=typeof self?self:this)},function(e){e.exports={name:"keen-analysis",version:"3.7.0",description:"A JavaScript client for Keen.IO",main:"dist/node/keen-analysis.js",browser:"dist/keen-analysis.js",scripts:{start:"NODE_ENV=development webpack-dev-server",test:"NODE_ENV=test jest && npm run test:node","test:node":"NODE_ENV=test TEST_ENV=node jest","test:watch":"NODE_ENV=test jest --watch","test:node:watch":"NODE_ENV=test TEST_ENV=node jest --watch",build:"NODE_ENV=production webpack -p && NODE_ENV=production OPTIMIZE_MINIMIZE=1 webpack -p && npm run build:node && npm run build:modules && npm run build:modules:node","build:node":"TARGET=node NODE_ENV=production webpack -p","build:modules":"NODE_ENV=production webpack -p --config webpack.modules.config.js","build:modules:node":"NODE_ENV=production TARGET=node webpack -p --config webpack.modules.config.js",profile:"webpack --profile --json > stats.json",analyze:"webpack-bundle-analyzer stats.json /dist",preversion:"npm run build && npm run test",version:"npm run build && git add .",postversion:"git push && git push --tags && npm publish",demo:"npm run build:node && node ./test/demo/index.node.js"},repository:{type:"git",url:"git+https://github.com/keen/keen-analysis.js.git"},author:"Keen IO <team@keen.io>",homepage:"https://keen.io",contributors:["Dustin Larimer <dustin@keen.io> (https://github.com/dustinlarimer)","Adam Kasprowicz <adam.kasprowicz@keen.io> (https://github.com/adamkasprowicz)","Dariusz Łacheta <dariusz.lacheta@keen.io> (https://github.com/dariuszlacheta)"],keywords:["Analytics","Analysis","Conversion","Query","Stats","Client","Min","Max","Count","Percentile","Average","Median","Keen","Keen Query"],license:"MIT",bugs:{url:"https://github.com/keen/keen-analysis.js/issues"},dependencies:{crossfilter2:"^1.4.6",csvtojson:"^2.0.8","keen-core":"^0.2.0",moment:"^2.22.2","promise-polyfill":"^8.0.0","whatwg-fetch":"^2.0.4"},devDependencies:{"abortcontroller-polyfill":"^1.1.9","babel-loader":"^7.1.4","babel-plugin-transform-es2015-modules-commonjs":"^6.26.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.7.0",del:"^2.1.0",eslint:"^4.19.1","eslint-config-airbnb":"^16.1.0","eslint-loader":"^2.0.0","eslint-plugin-import":"^2.11.0","eslint-plugin-jsx-a11y":"^6.0.3","fake-indexeddb":"^2.0.4","html-loader":"^0.5.5","html-webpack-plugin":"^3.2.0",jest:"^22.4.3","jest-fetch-mock":"^1.6.5",merge:"^1.2.1",nock:"^9.2.6","regenerator-runtime":"^0.11.1",requirejs:"^2.1.22",through2:"^2.0.0","url-parse":"^1.4.3",webpack:"^4.5.0","webpack-bundle-analyzer":"^3.3.2","webpack-cli":"^2.0.13","webpack-dev-server":"^3.1.14","xhr-mock":"^2.3.2"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.mapKeysToUnderscore=function e(t){var r=["cache"];if(!t||"object"!==(void 0===t?"undefined":n(t)))return t;var o=Object.keys(t)||[];var i={};o.forEach(function(o){var a=t[o];return r.includes(o)?i[o]=a:(o.match(new RegExp("[A-Z]"))&&(o=o.replace(/[A-Z]/g,function(e){return"_"+e.toLowerCase()})),Array.isArray(a)?i[o]=a.map(function(t){return e(t)}):"object"===(void 0===a?"undefined":n(a))?i[o]=e(a):void(i[o]=a))});return i}},function(e,t,r){var n=r(1);r(0);e.exports=function(e){var t=[];return n(e,function(e,r){"string"!=typeof e&&(e=JSON.stringify(e)),t.push(r+"="+encodeURIComponent(e))}),t.join("&")}},function(e,t,r){"use strict";(function(e){var n=r(4),o=setTimeout;function i(){}function a(e){if(!(this instanceof a))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],f(e,this)}function s(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,a._immediateFn(function(){var r=1===e._state?t.onFulfilled:t.onRejected;if(null!==r){var n;try{n=r(e._value)}catch(e){return void c(t.promise,e)}u(t.promise,n)}else(1===e._state?u:c)(t.promise,e._value)})):e._deferreds.push(t)}function u(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var r=t.then;if(t instanceof a)return e._state=3,e._value=t,void l(e);if("function"==typeof r)return void f((n=r,o=t,function(){n.apply(o,arguments)}),e)}e._state=1,e._value=t,l(e)}catch(t){c(e,t)}var n,o}function c(e,t){e._state=2,e._value=t,l(e)}function l(e){2===e._state&&0===e._deferreds.length&&a._immediateFn(function(){e._handled||a._unhandledRejectionFn(e._value)});for(var t=0,r=e._deferreds.length;t<r;t++)s(e,e._deferreds[t]);e._deferreds=null}function f(e,t){var r=!1;try{e(function(e){r||(r=!0,u(t,e))},function(e){r||(r=!0,c(t,e))})}catch(e){if(r)return;r=!0,c(t,e)}}a.prototype.catch=function(e){return this.then(null,e)},a.prototype.then=function(e,t){var r=new this.constructor(i);return s(this,new function(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}(e,t,r)),r},a.prototype.finally=n.a,a.all=function(e){return new a(function(t,r){if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var n=Array.prototype.slice.call(e);if(0===n.length)return t([]);var o=n.length;function i(e,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(t){i(e,t)},r)}n[e]=a,0==--o&&t(n)}catch(e){r(e)}}for(var a=0;a<n.length;a++)i(a,n[a])})},a.resolve=function(e){return e&&"object"==typeof e&&e.constructor===a?e:new a(function(t){t(e)})},a.reject=function(e){return new a(function(t,r){r(e)})},a.race=function(e){return new a(function(t,r){for(var n=0,o=e.length;n<o;n++)e[n].then(t,r)})},a._immediateFn="function"==typeof e&&function(t){e(t)}||function(e){o(e,0)},a._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},t.a=a}).call(this,r(21).setImmediate)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=t.MD5=function(e){return function(e){for(var t,r="0123456789ABCDEF",n="",o=0;o<e.length;o++)t=e.charCodeAt(o),n+=r.charAt(t>>>4&15)+r.charAt(15&t);return n}(function(e){for(var t="",r=0;r<32*e.length;r+=8)t+=String.fromCharCode(e[r>>5]>>>r%32&255);return t}(function(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var r=1732584193,n=-271733879,o=-1732584194,l=271733878,f=0;f<e.length;f+=16){var d=r,p=n,h=o,y=l;n=u(n=u(n=u(n=u(n=s(n=s(n=s(n=s(n=a(n=a(n=a(n=a(n=i(n=i(n=i(n=i(n,o=i(o,l=i(l,r=i(r,n,o,l,e[f+0],7,-680876936),n,o,e[f+1],12,-389564586),r,n,e[f+2],17,606105819),l,r,e[f+3],22,-1044525330),o=i(o,l=i(l,r=i(r,n,o,l,e[f+4],7,-176418897),n,o,e[f+5],12,1200080426),r,n,e[f+6],17,-1473231341),l,r,e[f+7],22,-45705983),o=i(o,l=i(l,r=i(r,n,o,l,e[f+8],7,1770035416),n,o,e[f+9],12,-1958414417),r,n,e[f+10],17,-42063),l,r,e[f+11],22,-1990404162),o=i(o,l=i(l,r=i(r,n,o,l,e[f+12],7,1804603682),n,o,e[f+13],12,-40341101),r,n,e[f+14],17,-1502002290),l,r,e[f+15],22,1236535329),o=a(o,l=a(l,r=a(r,n,o,l,e[f+1],5,-165796510),n,o,e[f+6],9,-1069501632),r,n,e[f+11],14,643717713),l,r,e[f+0],20,-373897302),o=a(o,l=a(l,r=a(r,n,o,l,e[f+5],5,-701558691),n,o,e[f+10],9,38016083),r,n,e[f+15],14,-660478335),l,r,e[f+4],20,-405537848),o=a(o,l=a(l,r=a(r,n,o,l,e[f+9],5,568446438),n,o,e[f+14],9,-1019803690),r,n,e[f+3],14,-187363961),l,r,e[f+8],20,1163531501),o=a(o,l=a(l,r=a(r,n,o,l,e[f+13],5,-1444681467),n,o,e[f+2],9,-51403784),r,n,e[f+7],14,1735328473),l,r,e[f+12],20,-1926607734),o=s(o,l=s(l,r=s(r,n,o,l,e[f+5],4,-378558),n,o,e[f+8],11,-2022574463),r,n,e[f+11],16,1839030562),l,r,e[f+14],23,-35309556),o=s(o,l=s(l,r=s(r,n,o,l,e[f+1],4,-1530992060),n,o,e[f+4],11,1272893353),r,n,e[f+7],16,-155497632),l,r,e[f+10],23,-1094730640),o=s(o,l=s(l,r=s(r,n,o,l,e[f+13],4,681279174),n,o,e[f+0],11,-358537222),r,n,e[f+3],16,-722521979),l,r,e[f+6],23,76029189),o=s(o,l=s(l,r=s(r,n,o,l,e[f+9],4,-640364487),n,o,e[f+12],11,-421815835),r,n,e[f+15],16,530742520),l,r,e[f+2],23,-995338651),o=u(o,l=u(l,r=u(r,n,o,l,e[f+0],6,-198630844),n,o,e[f+7],10,1126891415),r,n,e[f+14],15,-1416354905),l,r,e[f+5],21,-57434055),o=u(o,l=u(l,r=u(r,n,o,l,e[f+12],6,1700485571),n,o,e[f+3],10,-1894986606),r,n,e[f+10],15,-1051523),l,r,e[f+1],21,-2054922799),o=u(o,l=u(l,r=u(r,n,o,l,e[f+8],6,1873313359),n,o,e[f+15],10,-30611744),r,n,e[f+6],15,-1560198380),l,r,e[f+13],21,1309151649),o=u(o,l=u(l,r=u(r,n,o,l,e[f+4],6,-145523070),n,o,e[f+11],10,-1120210379),r,n,e[f+2],15,718787259),l,r,e[f+9],21,-343485551),r=c(r,d),n=c(n,p),o=c(o,h),l=c(l,y)}return Array(r,n,o,l)}(function(e){for(var t=Array(e.length>>2),r=0;r<t.length;r++)t[r]=0;for(r=0;r<8*e.length;r+=8)t[r>>5]|=(255&e.charCodeAt(r/8))<<r%32;return t}(e),8*e.length))).toLowerCase()};function o(e,t,r,n,o,i){return c(function(e,t){return e<<t|e>>>32-t}(c(c(t,e),c(n,i)),o),r)}function i(e,t,r,n,i,a,s){return o(t&r|~t&n,e,t,i,a,s)}function a(e,t,r,n,i,a,s){return o(t&n|r&~n,e,t,i,a,s)}function s(e,t,r,n,i,a,s){return o(t^r^n,e,t,i,a,s)}function u(e,t,r,n,i,a,s){return o(r^(t|~n),e,t,i,a,s)}function c(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getFromCache=t.saveToCache=void 0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};r(3),r(5);var o,i=r(10),a=(o=i)&&o.__esModule?o:{default:o};var s=!0;"indexedDB"in self||(s=!1);var u=void 0,c={dbName:"keenAnalysisIndexedDB",dbCollectionName:"requests",dbCollectionKey:"url",maxAge:6e4};function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return u?Promise.resolve():s?(c=n({},c,e),new Promise(function(e,t){var r=self.indexedDB.open(c.dbName);r.onerror=function(t){s=!1,e()},r.onupgradeneeded=function(e){var t=e.target.result.createObjectStore(c.dbCollectionName,{keyPath:c.dbCollectionKey});t.createIndex(c.dbCollectionKey,c.dbCollectionKey,{unique:!0}),t.createIndex("expiryTime","expiryTime",{unique:!1})},r.onsuccess=function(t){(u=t.target.result).onerror=function(e){s=!1},e(u)}})):Promise.resolve()}var f=function(e,t){return(0,a.default)(e+"&body="+JSON.stringify(t.body))};t.saveToCache=function(e,t,r){return l().then(function(){var n=u.transaction(c.dbCollectionName,"readwrite").objectStore(c.dbCollectionName).add({url:f(e,t),expiryTime:Date.now()+c.maxAge,responseJson:r});n.onsuccess=function(e){},n.onerror=function(e){s=!1}})},t.getFromCache=function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return l(n.cache).then(function(){return new Promise(function(o,i){if(!s)return o(null);var a=u.transaction(c.dbCollectionName,"readwrite").objectStore(c.dbCollectionName).index("expiryTime"),l=IDBKeyRange.upperBound(Date.now(),!0);a.openCursor(l).onsuccess=function(e){var t=e.target.result;if(t){u.transaction(c.dbCollectionName,"readwrite").objectStore(c.dbCollectionName).delete(e.target.result.value[c.dbCollectionKey]);t.continue()}};var d=u.transaction(c.dbCollectionName,"readwrite").objectStore(c.dbCollectionName).index(c.dbCollectionKey).get(f(t,r));d.onsuccess=function(i){if(!i.target.result||i.target.result.expiryTime<Date.now()){if(i.target.result&&i.target.result.expiryTime<Date.now()){var a=u.transaction(c.dbCollectionName,"readwrite").objectStore(c.dbCollectionName).delete(i.target.result[c.dbCollectionKey]);return a.onsuccess=function(i){o(e(t,r,n))},a.onerror=function(i){s=!1,o(e(t,r,n))},o(null)}return o(null)}return o(i.target.result.responseJson)},d.onerror=function(i){s=!1,o(e(t,r,n))}})})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEL=t.PUT=t.POST=t.GET=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};r(3),r(5);var i=c(r(1)),a=c(r(0)),s=c(r(8)),u=r(11);function c(e){return e&&e.__esModule?e:{default:e}}var l=function e(t,r){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l={},f=r.url;"GET"!==t&&"DELETE"!==t||(-1===f.indexOf("?")?f+="?":f+="&",r.api_key&&(f+="api_key="+r.api_key+"&"),r.params&&(f+=(0,s.default)(r.params))),(0,i.default)(r.headers,function(e,t){"string"==typeof e&&(l[t]=e)});var d={method:t,body:"GET"!==t&&r.params?JSON.stringify(r.params):void 0,mode:"cors",headers:l};if(r.cache&&"DELETE"!==t&&"PUT"!==t&&!c.notFoundInCache)return(0,u.getFromCache)(f,d,r).then(function(n){if(n)return c.resolve(n);e(t,r,o({},c,{notFoundInCache:!0}))});var p=void 0;fetch(f,o({},d,{signal:c.signal})).catch(function(e){c.reject(e)}).then(function(e){if(e)return p=e,e.ok&&"DELETE"===t?{}:e.json()}).then(function(e){if(e){if(e.error_code||!p.ok)return c.reject({ok:!1,error_code:e.error_code,body:e.message,status:p.status,statusText:p.statusText});r.cache&&"DELETE"!==t&&"PUT"!==t&&(0,u.saveToCache)(f,d,e);var o=(0,a.default)({},r);if(Array.isArray(e.result)?r.params.interval?r.params.group_by?"extraction"===r.params.analysis_type?c.resolve(e):e.result&&Array.isArray(e.result)&&e.result.forEach(function(e){if(e)return e.value?Array.isArray(e.value)?void e.value.forEach(function(e){isNaN(Number(e.result))||(e.result=Number(e.result))}):e.value:e}):e.result.forEach(function(e){e&&(isNaN(Number(e.value))||(e.value=Number(e.value)))}):e.result.forEach(function(e){e&&(isNaN(Number(e.result))||(e.result=Number(e.result)))}):isNaN(Number(e.result))||(e.result=Number(e.result)),r.resultParsers)if(Array.isArray(e.result))r.params.interval?r.params.group_by?e.result.forEach(function(e){e.value.forEach(function(e){var t=void 0;r.resultParsers.forEach(function(r){t=r(t||e.result)}),e.result=t})}):e.result.forEach(function(e){var t=void 0;r.resultParsers.forEach(function(r){t=r(t||e.value)}),e.value=t}):e.result.forEach(function(e){var t=void 0;r.resultParsers.forEach(function(r){t=r(t||e.result)}),e.result=t});else if("object"===n(e.result))Object.keys(e.result).forEach(function(t){var n=void 0;r.resultParsers.forEach(function(r){n=r(n||e.result[t])}),e.result[t]=n});else{var i=void 0;r.resultParsers.forEach(function(t){i=t(i||e.result)}),e.result=i}if(o.params&&void 0!==o.params.event_collection&&void 0===e.query){var s=(0,a.default)({query:o.params},e);c.resolve(s)}c.resolve(e)}})},f=function(){var e=window||void 0;if(e.XMLHttpRequest&&(!e.ActiveXObject||e.location&&e.location.protocol&&"file:"!==e.location.protocol))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}return!1},d=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=f(),o=r.callback,a=t.url;return n.onreadystatechange=function(){var e=void 0;if(4==n.readyState)if(n.status>=200&&n.status<300)if(204===n.status)o&&o(null,n);else try{e=JSON.parse(n.responseText),o&&e&&o(null,e)}catch(e){o&&o(n,null)}else try{e=JSON.parse(n.responseText),o&&e&&o(e,null)}catch(e){o&&o(n,null)}},"GET"!==e?(n.open(e,a,!0),(0,i.default)(t.headers,function(e,t){"string"==typeof e&&n.setRequestHeader(t,e)}),t.params?n.send(JSON.stringify(t.params)):n.send()):(a+="?",t.api_key&&(a+="api_key="+t.api_key+"&"),t.params&&(a+=(0,s.default)(t.params)),n.open(e,a,!0),(0,i.default)(t.headers,function(e,t){"string"==typeof e&&n.setRequestHeader(t,e)}),n.send()),n};t.GET=function(e,t){return"undefined"!=typeof fetch?l("GET",e,t):f()?d("GET",e,t):function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.url,n=t.callback,o=(new Date).getTime(),i=document.createElement("script"),a=document.getElementsByTagName("head")[0],u="keenJSONPCallback",c=!1;for(u+=o;u in window;)u+="a";window[u]=function(e){!0!==c&&l(null,e)},e.params&&(r+=(0,s.default)(e.params)),i.onreadystatechange=function(){!1===c&&"loaded"===this.readyState&&l("An error occurred",null)},i.onerror=function(){!1===c&&l("An error occurred",null)},i.src=r+"&jsonp="+u,a.appendChild(i);var l=function(e,t){c=!0,n&&"function"==typeof n&&(n(e,t),n=void 0),window[u]=void 0;try{delete window[u]}catch(e){}a.removeChild(i)}}(e,t)},t.POST=function(e,t){return"undefined"!=typeof fetch?l("POST",e,t):f()?d("POST",e,t):void t.reject("XHR POST not supported")},t.PUT=function(e,t){return"undefined"!=typeof fetch?l("PUT",e,t):f()?d("PUT",e,t):void t.reject("XHR PUT not supported")},t.DEL=function(e,t){return"undefined"!=typeof fetch?l("DELETE",e,t):f()?d("DELETE",e,t):void t.reject("XHR DELETE not supported")}},function(e,t,r){(function(e){(function(){"use strict";var t=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},o=function(){function e(){t(this,e),this.listeners={}}return r(e,[{key:"addEventListener",value:function(e,t){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push(t)}},{key:"removeEventListener",value:function(e,t){if(e in this.listeners)for(var r=this.listeners[e],n=0,o=r.length;n<o;n++)if(r[n]===t)return void r.splice(n,1)}},{key:"dispatchEvent",value:function(e){var t=this;if(e.type in this.listeners){for(var r=function(r){setTimeout(function(){return r.call(t,e)})},n=this.listeners[e.type],o=0,i=n.length;o<i;o++)r(n[o]);return!e.defaultPrevented}}}]),e}(),i=function(e){function i(){t(this,i);var e=n(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return e.aborted=!1,e.onabort=null,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(i,o),r(i,[{key:"toString",value:function(){return"[object AbortSignal]"}},{key:"dispatchEvent",value:function(e){"abort"===e.type&&(this.aborted=!0,"function"==typeof this.onabort&&this.onabort.call(this,e)),function e(t,r,n){null===t&&(t=Function.prototype);var o=Object.getOwnPropertyDescriptor(t,r);if(void 0===o){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,r,n)}if("value"in o)return o.value;var a=o.get;return void 0!==a?a.call(n):void 0}(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"dispatchEvent",this).call(this,e)}}]),i}(),a=function(){function e(){t(this,e),this.signal=new i}return r(e,[{key:"abort",value:function(){var e=void 0;try{e=new Event("abort")}catch(t){"undefined"!=typeof document?(e=document.createEvent("Event")).initEvent("abort",!1,!1):e={type:"abort",bubbles:!1,cancelable:!1}}this.signal.dispatchEvent(e)}},{key:"toString",value:function(){return"[object AbortController]"}}]),e}();"undefined"!=typeof Symbol&&Symbol.toStringTag&&(a.prototype[Symbol.toStringTag]="AbortController",i.prototype[Symbol.toStringTag]="AbortSignal"),function(e){if(!e.AbortController)if(e.AbortController=a,e.AbortSignal=i,e.fetch){var t=function(e){"function"==typeof e&&(e={fetch:e});var t=e,r=t.fetch,n=t.Request,o=void 0===n?r.Request:n,i=t.AbortController,s=o;if(s){var u=(new(void 0===i?a:i)).signal;if(new s("/",{signal:u}).signal)return{fetch:r,Request:s};(s=function(e,t){var r=new o(e,t);return t&&t.signal&&(r.signal=t.signal),r}).prototype=o.prototype}var c=r;return{fetch:function(e,t){var r=s&&s.prototype.isPrototypeOf(e)?e.signal:t?t.signal:void 0;if(r){var n=void 0;try{n=new DOMException("Aborted","AbortError")}catch(e){(n=new Error("Aborted")).name="AbortError"}if(r.aborted)return Promise.reject(n);var o=new Promise(function(e,t){r.addEventListener("abort",function(){return t(n)},{once:!0})});return Promise.race([o,c(e,t)])}return c(e,t)},Request:s}}(e),r=t.fetch,n=t.Request;e.fetch=r,e.Request=n}else console.warn("fetch() is not available, cannot install abortcontroller-polyfill")}("undefined"!=typeof self?self:e)})()}).call(this,r(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e};t.default=l;var i=c(r(1)),a=c(r(0));r(13),r(3);var s=r(7),u=r(6);function c(e){return e&&e.__esModule?e:{default:e}}function l(e,t){return this.httpHandlers=t,function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t)return this.config=o({api_key:void 0,method:e,params:{},url:t,headers:{Authorization:"","Content-type":"application/json","keen-sdk":"javascript-"+u.version}},r),this;if(t&&t.params&&(t.params=(0,s.mapKeysToUnderscore)(t.params)),"DELETE"===e){var n=t.url,i="";return["filters","timeframe","timezone"].forEach(function(e){if(t[e]){var r=t[e];try{r=JSON.parse(decodeURIComponent(t[e]))}catch(n){r=t[e]}Array.isArray(r)?r=(0,s.mapKeysToUnderscore)({vals:r}).vals:"string"!=typeof r&&(r=(0,s.mapKeysToUnderscore)(r)),i+=e+"="+encodeURIComponent(JSON.stringify(r))+"&"}}),-1===n.indexOf("?")&&(n+="?"),n+=i,this.config=o({api_key:void 0,params:{},method:e,headers:{Authorization:t.api_key||t.apiKey,"Content-type":"application/json","keen-sdk":"javascript-"+u.version}},t,r,{url:n}),this.send()}return this.config=o({api_key:void 0,params:{},method:e,headers:{Authorization:t.api_key||t.apiKey,"Content-type":"application/json","keen-sdk":"javascript-"+u.version}},t,r),this.send()}.bind(this)}l.prototype.auth=function(e){return"string"==typeof e&&(this.config.api_key="string"==typeof e?e:void 0,this.headers({Authorization:e})),this},l.prototype.headers=function(e){return"object"===(void 0===e?"undefined":n(e))&&(0,i.default)(e,function(e,t){this.config.headers[t]=e}.bind(this)),this},l.prototype.timeout=function(e){return this.config.timeout="number"==typeof e?e:3e5,this},l.prototype.send=function(e){if(this.config&&!this.config.api_key&&!this.config.apiKey)throw new Error("Please provide a valid API key");e&&(this.config.params=e&&"object"===(void 0===e?"undefined":n(e))?(0,s.mapKeysToUnderscore)(e):{});var t=this.config.method;"DELETE"===t&&(t="DEL");var r=this.httpHandlers[t],o=(0,a.default)({},this.config);"DELETE"!==this.config.method&&void 0===o.params.analysis_type&&o.url.indexOf("/queries/")>-1&&o.url.indexOf("/saved/")<0&&(o.params.analysis_type=o.url.split("/queries/").pop());var i=void 0;"undefined"!=typeof AbortController&&(i=new AbortController);var u=void 0,c=new Promise(function(e,t){var n={};return i&&(n.signal=i.signal),n.resolve=e,n.reject=t,u=r(o,n)}).then(function(e){return e});return c.abort=function(){if(i)return i.abort();u.emit("abort")},c}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.validateAuthCredentials=function(e){if("object"!==(void 0===e?"undefined":n(e)))return;if(!e.projectId)throw new Error("Please provide valid project ID");if(!e.masterKey&&!e.readKey)throw new Error("Please provide valid API key");return!0}},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<n.length;o++)if((r=n[o])===t||r.fn===t){n.splice(o,1);break}return this},n.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),r=this._callbacks["$"+e];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,t);return this},n.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},n.prototype.hasListeners=function(e){return!!this.listeners(e).length}},function(e,t){e.exports=function(e){var t,r={},n=/\+/g,o=/([^&=]+)=?([^&]*)/g,i=function(e){return decodeURIComponent(e.replace(n," "))},a=e.split("?")[1];for(;t=o.exec(a);)r[i(t[1])]=i(t[2]);return r}},function(e,t,r){(function(t){(function(t){var n=t.Keen||void 0,o=r(1),i=r(0),a=r(17),s=r(8),u=r(16);function c(e){if(this instanceof c==!1)return new c(e);this.configure(e),c.debug&&this.on("error",c.log),this.emit("ready"),c.emit("client",this)}function l(e){return void 0!==e}n&&void 0===n.resources&&(c.legacyVersion=n),u(c),u(c.prototype),i(c,{debug:!1,enabled:!0,loaded:!1,version:"__VERSION__"}),c.helpers=c.helpers||{},c.resources=c.resources||{},i(c.resources,{base:"{protocol}://{host}",version:"{protocol}://{host}/3.0",projects:"{protocol}://{host}/3.0/projects",projectId:"{protocol}://{host}/3.0/projects/{projectId}",events:"{protocol}://{host}/3.0/projects/{projectId}/events",queries:"{protocol}://{host}/3.0/projects/{projectId}/queries",datasets:"{protocol}://{host}/3.0/projects/{projectId}/datasets"}),c.utils=c.utils||{},i(c.utils,{each:o,extend:i,parseParams:a,serialize:s}),c.extendLibrary=function(e,t){var r=n||t;return l(r)&&l(r.resources)&&(o(r,function(t,r){"object"==typeof t?(e[r]=e[r]||{},i(e[r],t)):e[r]=e[r]||t}),i(e.prototype,r.prototype)),e},c.log=function(e){c.debug&&"object"==typeof console&&console.log("[Keen]",e)},c.noConflict=function(){return void 0!==t.Keen&&(t.Keen=c.legacyVersion||n),c},c.ready=function(e){c.loaded?e():c.once("ready",e)},c.prototype.configure=function(e){var t=e||{};return this.config=this.config||{projectId:void 0,writeKey:void 0,host:"api.keen.io",protocol:"https",requestType:"jsonp",resources:i({},c.resources)},"undefined"!=typeof window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1&&(t.protocol=document.location.protocol.replace(":","")),t.host&&t.host.replace(/.*?:\/\//g,""),i(this.config,t),this},c.prototype.masterKey=function(e){return arguments.length?(this.config.masterKey=e?String(e):null,this):this.config.masterKey},c.prototype.projectId=function(e){return arguments.length?(this.config.projectId=e?String(e):null,this):this.config.projectId},c.prototype.resources=function(e){if(!arguments.length)return this.config.resources;var t=this;return"object"==typeof e&&o(e,function(e,r){t.config.resources[r]=e||null}),t},c.prototype.url=function(e){var t,r=Array.prototype.slice.call(arguments,1),n=this.config.resources.base||"{protocol}://{host}";return t=e&&"string"==typeof e?this.config.resources[e]?this.config.resources[e]:n+e:n,o(this.config,function(e,r){"object"!=typeof e&&(t=t.replace("{"+r+"}",e))}),o(r,function(e,r){"string"==typeof e?t+="/"+e:"object"==typeof e&&(t+="?",o(e,function(e,r){t+=r+"="+e+"&"}),t=t.slice(0,-1))}),t},function(e){if(c.loaded||"undefined"==typeof document)return void e();null==document.readyState&&document.addEventListener&&(document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),document.readyState="complete"},!1),document.readyState="loading");!function e(t){/in/.test(document.readyState)?setTimeout(function(){e(t)},9):t()}(e)}(function(){c.loaded=!0,c.emit("ready")}),e.exports=c}).call(this,"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{})}).call(this,r(2))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,c=[],l=!1,f=-1;function d(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&p())}function p(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(u=c,c=[];++f<t;)u&&u[f].run();f=-1,t=c.length}u=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];c.push(new h(e,t)),1!==c.length||l||s(p)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,o,i,a,s,u=1,c={},l=!1,f=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){h(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},n=function(e){i.port2.postMessage(e)}):f&&"onreadystatechange"in f.createElement("script")?(o=f.documentElement,n=function(e){var t=f.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,o.removeChild(t),t=null},o.appendChild(t)}):n=function(e){setTimeout(h,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&h(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var o={callback:e,args:t};return c[u]=o,n(u),u++},d.clearImmediate=p}function p(e){delete c[e]}function h(e){if(l)setTimeout(h,0,e);else{var t=c[e];if(t){l=!0;try{!function(e){var t=e.callback,n=e.args;switch(n.length){case 0:t();break;case 1:t(n[0]);break;case 2:t(n[0],n[1]);break;case 3:t(n[0],n[1],n[2]);break;default:t.apply(r,n)}}(t)}finally{p(e),l=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(2),r(19))},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,o=Function.prototype.apply;function i(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new i(o.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new i(o.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(20),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeenAnalysis=void 0;var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r(3);var i=f(r(18)),a=f(r(1)),s=f(r(0)),u=r(15),c=r(7),l=f(r(6));function f(e){return e&&e.__esModule?e:{default:e}}function d(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.analysis=e,this.params={},this.set(t),this.options=n({},r)}i.default.prototype.readKey=function(e){return arguments.length?(this.config.readKey=e?String(e):null,this):this.config.readKey},i.default.prototype.query=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};(0,u.validateAuthCredentials)(this.config);var i={a:(0,c.mapKeysToUnderscore)(e),b:(0,c.mapKeysToUnderscore)(t)},a=i.a,l=i.b;if("object"===(void 0===e?"undefined":o(e))&&!t){var f=i.a,d=f.analysis_type,p=f.cache;a=d,l=function(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}(f,["analysis_type","cache"]);var h=this.config.cache;void 0!==p&&(h=p),r.cache=h}if(r.resultParsers=this.config.resultParsers,void 0===r.cache&&this.config.cache&&(r.cache=n({},this.config.cache)),"object"===(void 0===l?"undefined":o(l))&&(this.config.includeMetadata||this.config.include_metadata)&&(l.includeMetadata=!0),a&&l&&"string"==typeof l)return l.indexOf("/result")<0&&(l+="/result"),this.get({url:this.url("queries",a,l),api_key:this.config.readKey||this.config.masterKey},r);if(l&&l.saved_query_name){var y=l.saved_query_name.indexOf("/result")>-1?l.saved_query_name:l.saved_query_name+"/result";return this.get({url:this.url("queries","saved",y),api_key:this.config.readKey||this.config.masterKey},r)}if("dataset"===a&&"object"===(void 0===l?"undefined":o(l)))return this.get({url:this.url("datasets",l.name,"results"),api_key:this.config.readKey||this.config.masterKey,params:l},r);if(l&&l.dataset_name)return this.get({url:this.url("datasets",l.dataset_name,"results"),api_key:this.config.readKey||this.config.masterKey,params:l},r);if(a&&l&&"object"===(void 0===l?"undefined":o(l))){var v=(0,s.default)({analysis_type:a},l);return v.timezone||(v.timezone=-60*(new Date).getTimezoneOffset()),this.post({url:this.url("queries",a),api_key:this.config.readKey||this.config.masterKey,params:v},r)}return a&&"string"==typeof a&&!l?Promise.reject({error_code:"SDKError",message:".query() called with incorrect arguments"}):void 0},i.default.Query=d,i.default.prototype.run=function(e,t){var r=this,n=t,o=void 0,u=e instanceof Array?e:[e],c=[];return(0,a.default)(u,function(e,t){var n=void 0;n="string"==typeof e?r.query("saved",e+"/result"):e instanceof i.default.Query?r.query(e.analysis,(0,s.default)({analysis_type:e.analysis},e.params),e.options):e,c.push(n)}),o=c.length>1?Promise.all(c):c[0],n&&(o.then(function(e){n(null,e)}),o.catch(function(e){n(e,null)})),o},d.prototype.set=function(e){var t=this;return(0,a.default)(e,function(e,r){var n=r,i=e;r.match(new RegExp("[A-Z]"))&&(n=r.replace(/([A-Z])/g,function(e){return"_"+e.toLowerCase()})),t.params[n]=i,i instanceof Array&&(0,a.default)(i,function(e,r){e instanceof Array==0&&"object"===(void 0===e?"undefined":o(e))&&(0,a.default)(e,function(e,o){if(o.match(new RegExp("[A-Z]"))){var i=o.replace(/([A-Z])/g,function(e){return"_"+e.toLowerCase()});delete t.params[n][r][o],t.params[n][r][i]=e}})})}),t},d.prototype.get=function(e){var t=e;if(t.match(new RegExp("[A-Z]"))&&(t=t.replace(/([A-Z])/g,function(e){return"_"+e.toLowerCase()})),this.params)return this.params[t]||null},d.prototype.addFilter=function(e,t,r){return this.params.filters=this.params.filters||[],this.params.filters.push({property_name:e,operator:t,property_value:r}),this},i.default.version=l.default.version;var p=t.KeenAnalysis=i.default;t.default=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.KeenAnalysis=t.Keen=t.keenGlobals=void 0;a(r(0));var n=a(r(22)),o=a(r(14)),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(12));function a(e){return e&&e.__esModule?e:{default:e}}n.default.prototype.get=new o.default("GET",i),n.default.prototype.post=new o.default("POST",i),n.default.prototype.put=new o.default("PUT",i),n.default.prototype.del=new o.default("DELETE",i);t.keenGlobals=void 0;"undefined"!=typeof webpackKeenGlobals&&(t.keenGlobals=webpackKeenGlobals);var s=t.Keen=n.default.extendLibrary(n.default);t.KeenAnalysis=s;t.default=s},function(e,t,r){e.exports=r(23)}])}); //# sourceMappingURL=keen-analysis.min.js.map