UNPKG

aard-recorder

Version:

A JavaScript tracking library for the Aard Platform at InYourArea.co.uk. Record and track activity across the different services of the platform.

1 lines 29 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("aard-recorder",[],e):"object"==typeof exports?exports["aard-recorder"]=e():t["aard-recorder"]=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=31)}([function(t,e,r){t.exports=r(14)},function(t,e){function r(t,e,r,n,o,i,a){try{var s=t[i](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,u,"next",t)}function u(t){r(a,o,i,s,u,"throw",t)}s(void 0)})}}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}},function(t,e){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,r){t.exports=!r(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){var r=function(t){function e(){this.fetch=!1}return e.prototype=t,new e}("undefined"!=typeof self?self:this);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function i(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function s(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function c(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function f(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function h(t){var e=new FileReader,r=f(e);return e.readAsArrayBuffer(t),r}function l(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=l(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||o(t))?this._bodyArrayBuffer=l(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=c(this);if(t)return t;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?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(h)}),this.text=function(){var t,e,r,n=c(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=f(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(v)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=i(t),e=a(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},u.prototype.delete=function(t){delete this.map[i(t)]},u.prototype.get=function(t){return t=i(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(i(t))},u.prototype.set=function(t,e){this.map[i(t)]=a(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),s(t)},u.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),s(t)},u.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),s(t)},r.iterable&&(u.prototype[Symbol.iterator]=u.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function d(t,e){var r,n,o=(e=e||{}).body;if(t instanceof d){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),y.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,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 v(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}}),e}function m(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})},p.call(d.prototype),p.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var b=[301,302,303,307,308];m.redirect=function(t,e){if(-1===b.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function g(t,n){return new Promise(function(o,i){var a=new d(t,n);if(a.signal&&a.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var t,e,r={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}}),e)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;o(new m(n,r))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}g.polyfill=!0,t.fetch||(t.fetch=g,t.Headers=u,t.Request=d,t.Response=m),e.Headers=u,e.Request=d,e.Response=m,e.fetch=g}({})}(r),delete r.fetch.polyfill,t.exports=e=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,e.default=r.fetch},function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(e){return"function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?t.exports=n=function(t){return r(t)}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)},n(e)}t.exports=n},function(t,e,r){var n=r(16);t.exports=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),o.forEach(function(e){n(t,e,r[e])})}return t}},function(t,e){var r=t.exports={version:"2.6.3"};"number"==typeof __e&&(__e=r)},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e,r){var n=r(17);t.exports=function(t,e){if(null==t)return{};var r,o,i=n(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(o=0;o<a.length;o++)r=a[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}},function(t,e,r){r(18),t.exports=r(10).setTimeout},function(t,e,r){var n=function(){return this||"object"==typeof self&&self}()||Function("return this")(),o=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,i=o&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=r(15),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e){!function(e){"use strict";var r,n=Object.prototype,o=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag",c="object"==typeof t,f=e.regeneratorRuntime;if(f)c&&(t.exports=f);else{(f=e.regeneratorRuntime=c?t.exports:{}).wrap=w;var h="suspendedStart",l="suspendedYield",p="executing",y="completed",d={},v={};v[a]=function(){return this};var m=Object.getPrototypeOf,b=m&&m(m(B([])));b&&b!==n&&o.call(b,a)&&(v=b);var g=j.prototype=E.prototype=Object.create(v);O.prototype=g.constructor=j,j.constructor=O,j[u]=O.displayName="GeneratorFunction",f.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===O||"GeneratorFunction"===(e.displayName||e.name))},f.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,j):(t.__proto__=j,u in t||(t[u]="GeneratorFunction")),t.prototype=Object.create(g),t},f.awrap=function(t){return{__await:t}},P(_.prototype),_.prototype[s]=function(){return this},f.AsyncIterator=_,f.async=function(t,e,r,n){var o=new _(w(t,e,r,n));return f.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},P(g),g[u]="Generator",g[a]=function(){return this},g.toString=function(){return"[object Generator]"},f.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},f.values=B,A.prototype={constructor:A,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return s.type="throw",s.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:B(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}}}function w(t,e,r,n){var o=e&&e.prototype instanceof E?e:E,i=Object.create(o.prototype),a=new A(n||[]);return i._invoke=function(t,e,r){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return R()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=T(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=x(t,e,r);if("normal"===u.type){if(n=r.done?y:l,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=y,r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function x(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function E(){}function O(){}function j(){}function P(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function _(t){var e;this._invoke=function(r,n){function i(){return new Promise(function(e,i){!function e(r,n,i,a){var s=x(t[r],t,n);if("throw"!==s.type){var u=s.arg,c=u.value;return c&&"object"==typeof c&&o.call(c,"__await")?Promise.resolve(c.__await).then(function(t){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(c).then(function(t){u.value=t,i(u)},function(t){return e("throw",t,i,a)})}a(s.arg)}(r,n,e,i)})}return e=e?e.then(i,i):i()}}function T(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,T(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=x(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function B(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(o.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}return{next:R}}function R(){return{value:r,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){t.exports=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}},function(t,e,r){var n=r(4),o=r(19),i=r(30),a=[].slice,s=/MSIE .\./.test(i),u=function(t){return function(e,r){var n=arguments.length>2,o=!!n&&a.call(arguments,2);return t(n?function(){("function"==typeof e?e:Function(e)).apply(this,o)}:e,r)}};o(o.G+o.B+o.F*s,{setTimeout:u(n.setTimeout),setInterval:u(n.setInterval)})},function(t,e,r){var n=r(4),o=r(10),i=r(20),a=r(22),s=r(29),u=function(t,e,r){var c,f,h,l=t&u.F,p=t&u.G,y=t&u.S,d=t&u.P,v=t&u.B,m=t&u.W,b=p?o:o[e]||(o[e]={}),g=b.prototype,w=p?n:y?n[e]:(n[e]||{}).prototype;for(c in p&&(r=e),r)(f=!l&&w&&void 0!==w[c])&&s(b,c)||(h=f?w[c]:r[c],b[c]=p&&"function"!=typeof w[c]?r[c]:v&&f?i(h,n):m&&w[c]==h?function(t){var e=function(e,r,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,r)}return new t(e,r,n)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(h):d&&"function"==typeof h?i(Function.call,h):h,d&&((b.virtual||(b.virtual={}))[c]=h,t&u.R&&g&&!g[c]&&a(g,c,h)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u},function(t,e,r){var n=r(21);t.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,r){var n=r(23),o=r(28);t.exports=r(6)?function(t,e,r){return n.f(t,e,o(1,r))}:function(t,e,r){return t[e]=r,t}},function(t,e,r){var n=r(24),o=r(25),i=r(27),a=Object.defineProperty;e.f=r(6)?Object.defineProperty:function(t,e,r){if(n(t),e=i(e,!0),n(r),o)try{return a(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t}},function(t,e,r){var n=r(5);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e,r){t.exports=!r(6)&&!r(11)(function(){return 7!=Object.defineProperty(r(26)("div"),"a",{get:function(){return 7}}).a})},function(t,e,r){var n=r(5),o=r(4).document,i=n(o)&&n(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e,r){var n=r(5);t.exports=function(t,e){if(!n(t))return t;var r,o;if(e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!n(o=r.call(t)))return o;if(!e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e){var r={}.hasOwnProperty;t.exports=function(t,e){return r.call(t,e)}},function(t,e,r){var n=r(4).navigator;t.exports=n&&n.userAgent||""},function(t,e,r){"use strict";r.r(e);var n={};r.r(n),r.d(n,"createMetric",function(){return m}),r.d(n,"Percents",function(){return b}),r.d(n,"Units",function(){return g}),r.d(n,"Milliseconds",function(){return w}),r.d(n,"Microseconds",function(){return x}),r.d(n,"Minutes",function(){return E}),r.d(n,"Hours",function(){return O}),r.d(n,"Bytes",function(){return j}),r.d(n,"Kilobytes",function(){return P}),r.d(n,"Megabytes",function(){return _}),r.d(n,"Gigabytes",function(){return T}),r.d(n,"Terabytes",function(){return S});var o={};r.r(o),r.d(o,"Event",function(){return I});var i=r(8),a=r.n(i),s=r(0),u=r.n(s),c=r(2),f=r.n(c),h=r(3),l=r.n(h),p=r(1),y=r.n(p),d=r(9),v=r.n(d);function m(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){return!0};return function(r){if(!e(r))throw"invalid value (".concat(r,") for the metric ").concat(t);return{unit:t,value:r}}}var b=m("Percent"),g=m("Unit"),w=m("Milliseconds"),x=m("Microseconds"),E=m("Minutes"),O=m("Hours"),j=m("Bytes"),P=m("Kilobytes"),_=m("Megabytes"),T=m("Gigabytes"),S=m("Terabytes");function k(t,e){var r={};for(var n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(var o in t)t.hasOwnProperty(o)&&(t[o]instanceof Object&&!Array.isArray(t[o])?r[o]=k(t[o],r[o]):null!==t[o]&&(r[o]=t[o]));return r}var A=r(12),B=r.n(A),R=r(7),L=r.n(R),N=r(13),F=r.n(N);function M(t){return new Promise(function(e){return F()(e,t)})}function D(t){return U.apply(this,arguments)}function U(){return(U=y()(u.a.mark(function t(e){var r,n,o,i,a,s,c,f=arguments;return u.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=f.length>1&&void 0!==f[1]?f[1]:{},n=r.fetchFn,o=void 0===n?L.a:n,i=B()(r,["fetchFn"]),a=f.length>2&&void 0!==f[2]?f[2]:0,s=f.length>3&&void 0!==f[3]?f[3]:3,t.prev=3,t.next=6,o(e,i);case 6:return t.abrupt("return",t.sent);case 9:if(t.prev=9,t.t0=t.catch(3),!(a>s)){t.next=13;break}throw t.t0;case 13:return c=1e3*Math.pow(a,2),t.next=16,M(c);case 16:return t.abrupt("return",D(e,i,a+1));case 17:case"end":return t.stop()}},t,this,[[3,9]])}))).apply(this,arguments)}var I=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timestamp,o=r.dimensions,i=void 0===o?{}:o,a=r.metric,s=void 0===a?g(1):a,u=r.session,c=void 0!==u&&u,h=r.plugins,l=void 0===h?[]:h;f()(this,t),this.metricName=e,this.dimensions=i,this.metric=s,this.timestamp=n||Date.now(),this.session=c,this.plugins=l}return l()(t,[{key:"extendLeft",value:function(e){var r=this.timestamp,n=this.metricName,o=this.session,i=this.dimensions,a=this.metric,s=this.plugins;return new t(n,{timestamp:r,metric:a,session:o,dimensions:k(i,e),plugins:s})}},{key:"extendRight",value:function(e){var r=this.timestamp,n=this.metricName,o=this.session,i=this.dimensions,a=this.metric,s=this.plugins;return new t(n,{timestamp:r,metric:a,session:o,dimensions:k(e,i),plugins:s})}},{key:"addPlugin",value:function(t,e,r){var n={name:t,input:e};return void 0!==r&&(n=v()({output:r},n)),this.plugins.push(n),this}},{key:"toRecord",value:function(t){return r=(e=this).timestamp,n=e.metricName,o=e.dimensions,i=e.metric,a=e.session,s=e.plugins,v()({projectName:t,timestamp:r,metricName:n,dimensions:o,session:a,plugins:s},i);var e,r,n,o,i,a,s}}]),t}(),G="https://aard-gateway-{{env}}.inyourarea.co.uk",H={TEST:"test",STAG:"stag",PROD:"prod"},C=function(){function t(e){var r=e.apiKey,n=e.projectName,o=e.environment,i=e.url,a=e.enabled,s=void 0===a||a,u=e.debug,c=void 0!==u&&u,h=e.fetch,l=void 0===h?l:h,p=e.serializer,y=void 0===p?function(t){return t}:p,d=e.blacklist,v=void 0===d?{}:d,m=e.ignoredEvents,b=void 0===m?[]:m;f()(this,t),this.apiKey=r,this.projectName=n,this.environment=o||H.PROD,this.url=i||function(t,e){var r=t;for(var n in e)e.hasOwnProperty(n)&&(r=r.replace("{{".concat(n,"}}"),e[n]));return r}(G,{env:this.environment}),this.enabled=s,this.debug=c,this.blacklist=v,this.fetch=l,this.serializer=y,this.ignoredEvents=b,this.validate()}return l()(t,[{key:"validate",value:function(){if(!this.apiKey)throw"Missing API Key, please provide one.";if(!this.projectName)throw"No Project Name, please provide one"}},{key:"serialize",value:function(t){return this.serializer(t)}}]),t}();function q(t,e){return K.apply(this,arguments)}function K(){return(K=y()(u.a.mark(function t(e,r){var n;return u.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if("function"!=typeof r){t.next=12;break}return t.prev=1,t.next=4,r();case 4:n=t.sent,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),n={};case 10:t.next=13;break;case 12:n=r;case 13:return t.abrupt("return",e.extendLeft(n));case 14:case"end":return t.stop()}},t,this,[[1,7]])}))).apply(this,arguments)}function z(t,e){return null!=t&&t.some(function(t){return Object.keys(t).some(function(r){return!(!t.hasOwnProperty(r)||!t.hasOwnProperty(r)||e[r]!==t[r])})})}var J=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};f()(this,t),this.config=e instanceof C?e:new C(e),this.globalExtension=r,this.metricExtensions=new Map}return l()(t,[{key:"getUrl",value:function(){return"".concat(this.config.url,"/records")}},{key:"patchHeaders",value:function(){return{"Content-Type":"application/json; charset=utf-8",Authorization:this.config.apiKey}}},{key:"extendEvent",value:function(t,e){this.metricExtensions.set(t,e)}},{key:"isIgnoredEvent",value:function(t){return this.config.ignoredEvents.includes(t.metricName)}},{key:"isBlacklistedEvent",value:function(t){var e=this.config.blacklist["*"],r=this.config.blacklist[t.metricName];return z(e,t.dimensions)||z(r,t.dimensions)}},{key:"prepareRecord",value:function(){var t=y()(u.a.mark(function t(e){var r,n=this;return u.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,q(e,this.globalExtension).then(function(){var t=y()(u.a.mark(function t(e){var r;return u.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!n.metricExtensions.has(e.metricName)){t.next=5;break}return r=n.metricExtensions.get(e.metricName),t.abrupt("return",q(e,r));case 5:return t.abrupt("return",e);case 6:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}());case 2:return r=t.sent,t.abrupt("return",r.toRecord(this.config.projectName));case 4:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()},{key:"record",value:function(){var t=y()(u.a.mark(function t(e){var r,n,o;return u.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.config.enabled){t.next=17;break}if(!this.isIgnoredEvent(e)&&!this.isBlacklistedEvent(e)){t.next=3;break}return t.abrupt("return","".concat(e.metricName," event rejected."));case 3:return t.prev=3,t.next=6,this.prepareRecord(e);case 6:return r=t.sent,t.next=9,D(this.getUrl(),{fetchFn:this.config.fetch,method:"POST",headers:this.patchHeaders(),body:this.config.serialize(r),credentials:"include"});case 9:return n=t.sent,o=n.json?"function"==typeof n.json?n.json():n.json:n,t.abrupt("return",o);case 14:return t.prev=14,t.t0=t.catch(3),t.abrupt("return",t.t0);case 17:case"end":return t.stop()}},t,this,[[3,14]])}));return function(e){return t.apply(this,arguments)}}()},{key:"log",value:function(t){this.config.debug&&(a()(t),console.log("".concat(this.config.projectName," ").concat("object"===a()(t)?JSON.stringify(t):t)))}}]),t}();r.d(e,"Recorder",function(){return J}),r.d(e,"Config",function(){return C}),r.d(e,"metrics",function(){return n}),r.d(e,"events",function(){return o})}])});