diff --git a/dist/dd-manager.js b/dist/dd-manager.js index 6baa046..5a28e53 100644 --- a/dist/dd-manager.js +++ b/dist/dd-manager.js @@ -1262,7 +1262,7 @@ }()); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":49}],2:[function(require,module,exports){ +},{"_process":50}],2:[function(require,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -4278,7 +4278,7 @@ function coerce(val) { return val; } -},{"ms":48}],46:[function(require,module,exports){ +},{"ms":49}],46:[function(require,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -4400,6 +4400,153 @@ module.exports = isArray || function (val) { }; },{}],48:[function(require,module,exports){ +/*! + * JavaScript Cookie v2.1.0 + * https://github.com/js-cookie/js-cookie + * + * Copyright 2006, 2015 Klaus Hartl & Fagner Brack + * Released under the MIT license + */ +(function (factory) { + if (typeof define === 'function' && define.amd) { + define(factory); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + var _OldCookies = window.Cookies; + var api = window.Cookies = factory(); + api.noConflict = function () { + window.Cookies = _OldCookies; + return api; + }; + } +}(function () { + function extend () { + var i = 0; + var result = {}; + for (; i < arguments.length; i++) { + var attributes = arguments[ i ]; + for (var key in attributes) { + result[key] = attributes[key]; + } + } + return result; + } + + function init (converter) { + function api (key, value, attributes) { + var result; + + // Write + + if (arguments.length > 1) { + attributes = extend({ + path: '/' + }, api.defaults, attributes); + + if (typeof attributes.expires === 'number') { + var expires = new Date(); + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); + attributes.expires = expires; + } + + try { + result = JSON.stringify(value); + if (/^[\{\[]/.test(result)) { + value = result; + } + } catch (e) {} + + if (!converter.write) { + value = encodeURIComponent(String(value)) + .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); + } else { + value = converter.write(value, key); + } + + key = encodeURIComponent(String(key)); + key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); + key = key.replace(/[\(\)]/g, escape); + + return (document.cookie = [ + key, '=', value, + attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE + attributes.path && '; path=' + attributes.path, + attributes.domain && '; domain=' + attributes.domain, + attributes.secure ? '; secure' : '' + ].join('')); + } + + // Read + + if (!key) { + result = {}; + } + + // To prevent the for loop in the first place assign an empty array + // in case there are no cookies at all. Also prevents odd result when + // calling "get()" + var cookies = document.cookie ? document.cookie.split('; ') : []; + var rdecode = /(%[0-9A-Z]{2})+/g; + var i = 0; + + for (; i < cookies.length; i++) { + var parts = cookies[i].split('='); + var name = parts[0].replace(rdecode, decodeURIComponent); + var cookie = parts.slice(1).join('='); + + if (cookie.charAt(0) === '"') { + cookie = cookie.slice(1, -1); + } + + try { + cookie = converter.read ? + converter.read(cookie, name) : converter(cookie, name) || + cookie.replace(rdecode, decodeURIComponent); + + if (this.json) { + try { + cookie = JSON.parse(cookie); + } catch (e) {} + } + + if (key === name) { + result = cookie; + break; + } + + if (!key) { + result[name] = cookie; + } + } catch (e) {} + } + + return result; + } + + api.get = api.set = api; + api.getJSON = function () { + return api.apply({ + json: true + }, [].slice.call(arguments)); + }; + api.defaults = {}; + + api.remove = function (key, attributes) { + api(key, '', extend(attributes, { + expires: -1 + })); + }; + + api.withConverter = init; + + return api; + } + + return init(function () {}); +})); + +},{}],49:[function(require,module,exports){ /** * Helpers. */ @@ -4526,7 +4673,7 @@ function plural(ms, n, name) { return Math.ceil(ms / n) + ' ' + name + 's'; } -},{}],49:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -4619,7 +4766,422 @@ process.chdir = function (dir) { }; process.umask = function() { return 0; }; -},{}],50:[function(require,module,exports){ +},{}],51:[function(require,module,exports){ +(function (global){ +"use strict" +// Module export pattern from +// https://github.com/umdjs/umd/blob/master/returnExports.js +;(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof exports === 'object') { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + root.store = factory(); + } +}(this, function () { + + // Store.js + var store = {}, + win = (typeof window != 'undefined' ? window : global), + doc = win.document, + localStorageName = 'localStorage', + scriptTag = 'script', + storage + + store.disabled = false + store.version = '1.3.20' + store.set = function(key, value) {} + store.get = function(key, defaultVal) {} + store.has = function(key) { return store.get(key) !== undefined } + store.remove = function(key) {} + store.clear = function() {} + store.transact = function(key, defaultVal, transactionFn) { + if (transactionFn == null) { + transactionFn = defaultVal + defaultVal = null + } + if (defaultVal == null) { + defaultVal = {} + } + var val = store.get(key, defaultVal) + transactionFn(val) + store.set(key, val) + } + store.getAll = function() {} + store.forEach = function() {} + + store.serialize = function(value) { + return JSON.stringify(value) + } + store.deserialize = function(value) { + if (typeof value != 'string') { return undefined } + try { return JSON.parse(value) } + catch(e) { return value || undefined } + } + + // Functions to encapsulate questionable FireFox 3.6.13 behavior + // when about.config::dom.storage.enabled === false + // See https://github.com/marcuswestin/store.js/issues#issue/13 + function isLocalStorageNameSupported() { + try { return (localStorageName in win && win[localStorageName]) } + catch(err) { return false } + } + + if (isLocalStorageNameSupported()) { + storage = win[localStorageName] + store.set = function(key, val) { + if (val === undefined) { return store.remove(key) } + storage.setItem(key, store.serialize(val)) + return val + } + store.get = function(key, defaultVal) { + var val = store.deserialize(storage.getItem(key)) + return (val === undefined ? defaultVal : val) + } + store.remove = function(key) { storage.removeItem(key) } + store.clear = function() { storage.clear() } + store.getAll = function() { + var ret = {} + store.forEach(function(key, val) { + ret[key] = val + }) + return ret + } + store.forEach = function(callback) { + for (var i=0; idocument.w=window') + storageContainer.close() + storageOwner = storageContainer.w.frames[0].document + storage = storageOwner.createElement('div') + } catch(e) { + // somehow ActiveXObject instantiation failed (perhaps some special + // security settings or otherwse), fall back to per-path storage + storage = doc.createElement('div') + storageOwner = doc.body + } + var withIEStorage = function(storeFunction) { + return function() { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift(storage) + // See http://msdn.microsoft.com/en-us/library/ms531081(v=VS.85).aspx + // and http://msdn.microsoft.com/en-us/library/ms531424(v=VS.85).aspx + storageOwner.appendChild(storage) + storage.addBehavior('#default#userData') + storage.load(localStorageName) + var result = storeFunction.apply(store, args) + storageOwner.removeChild(storage) + return result + } + } + + // In IE7, keys cannot start with a digit or contain certain chars. + // See https://github.com/marcuswestin/store.js/issues/40 + // See https://github.com/marcuswestin/store.js/issues/83 + var forbiddenCharsRegex = new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]", "g") + var ieKeyFix = function(key) { + return key.replace(/^d/, '___$&').replace(forbiddenCharsRegex, '___') + } + store.set = withIEStorage(function(storage, key, val) { + key = ieKeyFix(key) + if (val === undefined) { return store.remove(key) } + storage.setAttribute(key, store.serialize(val)) + storage.save(localStorageName) + return val + }) + store.get = withIEStorage(function(storage, key, defaultVal) { + key = ieKeyFix(key) + var val = store.deserialize(storage.getAttribute(key)) + return (val === undefined ? defaultVal : val) + }) + store.remove = withIEStorage(function(storage, key) { + key = ieKeyFix(key) + storage.removeAttribute(key) + storage.save(localStorageName) + }) + store.clear = withIEStorage(function(storage) { + var attributes = storage.XMLDocument.documentElement.attributes + storage.load(localStorageName) + for (var i=attributes.length-1; i>=0; i--) { + storage.removeAttribute(attributes[i].name) + } + storage.save(localStorageName) + }) + store.getAll = function(storage) { + var ret = {} + store.forEach(function(key, val) { + ret[key] = val + }) + return ret + } + store.forEach = withIEStorage(function(storage, callback) { + var attributes = storage.XMLDocument.documentElement.attributes + for (var i=0, attr; attr=attributes[i]; ++i) { + callback(attr.name, store.deserialize(storage.getAttribute(attr.name))) + } + }) + } + + try { + var testKey = '__storejs__' + store.set(testKey, testKey) + if (store.get(testKey) != testKey) { store.disabled = true } + store.remove(testKey) + } catch(e) { + store.disabled = true + } + store.enabled = !store.disabled + + return store +})); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],52:[function(require,module,exports){ +(function (global){ + +var rng; + +if (global.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; +} + +if (!rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; +} + +module.exports = rng; + + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],53:[function(require,module,exports){ +// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php + +// Unique ID creation requires a high quality random # generator. We feature +// detect to determine the best RNG source, normalizing to a function that +// returns 128-bits of randomness, since that's what's usually required +var _rng = require('./rng'); + +// Maps for number <-> hex string conversion +var _byteToHex = []; +var _hexToByte = {}; +for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; +} + +// **`parse()` - Parse a UUID into it's component bytes** +function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; +} + +// **`unparse()` - Convert UUID byte array (ala parse()) into a string** +function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; +} + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html + +// random #'s we need to init node and clockseq +var _seedBytes = _rng(); + +// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) +var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] +]; + +// Per 4.2.2, randomize (14 bit) clockseq +var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + +// Previous uuid creation time +var _lastMSecs = 0, _lastNSecs = 0; + +// See https://github.com/broofa/node-uuid for API details +function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); +} + +// **`v4()` - Generate random UUID** + +// See https://github.com/broofa/node-uuid for API details +function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new Array(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || _rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); +} + +// Export public API +var uuid = v4; +uuid.v1 = v1; +uuid.v4 = v4; +uuid.parse = parse; +uuid.unparse = unparse; + +module.exports = uuid; + +},{"./rng":52}],54:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -4650,7 +5212,6 @@ var AutoEvents = (function () { this.fireViewedPage(); this.fireViewedProductCategory(); this.fireViewedProductDetail(); - this.fireViewedCheckoutStep(); this.fireCompletedTransaction(); if (this.ddListener) { @@ -4665,8 +5226,6 @@ var AutoEvents = (function () { this.ddListener.push(['on', 'change:transaction.orderId', function (newOrderId, oldOrderId) { _this.onTransactionChange(newOrderId, oldOrderId); }]); - - // TODO: checkout step change } } }; @@ -4693,7 +5252,6 @@ var AutoEvents = (function () { AutoEvents.prototype.fireViewedPage = function fireViewedPage(page) { page = page || this.digitalData.page; this.digitalData.events.push({ - updateDigitalData: false, enrichEventData: false, name: 'Viewed Page', category: 'Content', @@ -4707,7 +5265,6 @@ var AutoEvents = (function () { return; } this.digitalData.events.push({ - updateDigitalData: false, enrichEventData: false, name: 'Viewed Product Category', category: 'Ecommerce', @@ -4721,7 +5278,6 @@ var AutoEvents = (function () { return; } this.digitalData.events.push({ - updateDigitalData: false, enrichEventData: false, name: 'Viewed Product Detail', category: 'Ecommerce', @@ -4729,27 +5285,12 @@ var AutoEvents = (function () { }); }; - AutoEvents.prototype.fireViewedCheckoutStep = function fireViewedCheckoutStep(page) { - page = page || this.digitalData.page || {}; - if (page.type !== 'cart' && page.type !== 'checkout') { - return; - } - this.digitalData.events.push({ - updateDigitalData: false, - enrichEventData: false, - name: 'Viewed Checkout Step', - category: 'Ecommerce', - page: page - }); - }; - AutoEvents.prototype.fireCompletedTransaction = function fireCompletedTransaction(transaction) { transaction = transaction || this.digitalData.transaction; if (!transaction || transaction.isReturning === true) { return; } this.digitalData.events.push({ - updateDigitalData: false, enrichEventData: false, name: 'Completed Transaction', category: 'Ecommerce', @@ -4762,11 +5303,15 @@ var AutoEvents = (function () { exports['default'] = AutoEvents; -},{}],51:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ 'use strict'; exports.__esModule = true; +var _getProperty = require('./functions/getProperty.js'); + +var _getProperty2 = _interopRequireDefault(_getProperty); + var _componentClone = require('component-clone'); var _componentClone2 = _interopRequireDefault(_componentClone); @@ -4781,33 +5326,14 @@ function _classCallCheck(instance, Constructor) { } } -function _keyToArray(key) { - key = key.trim(); - if (key === '') { - return []; - } - key = key.replace(/\[(\w+)\]/g, '.$1'); - key = key.replace(/^\./, ''); - return key.split('.'); -} - var DDHelper = (function () { function DDHelper() { _classCallCheck(this, DDHelper); } DDHelper.get = function get(key, digitalData) { - var keyParts = _keyToArray(key); - var nestedVar = (0, _componentClone2['default'])(digitalData); - while (keyParts.length > 0) { - var childKey = keyParts.shift(); - if (nestedVar.hasOwnProperty(childKey)) { - nestedVar = nestedVar[childKey]; - } else { - return undefined; - } - } - return nestedVar; + var value = (0, _getProperty2['default'])(digitalData, key); + return (0, _componentClone2['default'])(value); }; DDHelper.getProduct = function getProduct(id, digitalData) { @@ -4838,22 +5364,12 @@ var DDHelper = (function () { var listing = _ref2; if (listing.items && listing.items.length) { - for (var _iterator3 = listing.items, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { - var _ref3; - - if (_isArray3) { - if (_i4 >= _iterator3.length) break; - _ref3 = _iterator3[_i4++]; - } else { - _i4 = _iterator3.next(); - if (_i4.done) break; - _ref3 = _i4.value; - } - - var product = _ref3; - - if (product.id && String(product.id) === String(id)) { - return (0, _componentClone2['default'])(product); + for (var i = 0, length = listing.items.length; i < length; i++) { + if (listing.items[i].id && String(listing.items[i].id) === String(id)) { + var product = (0, _componentClone2['default'])(listing.items[i]); + product.position = product.position || i + 1; + if (listing.listName) product.listName = product.listName || listing.listName; + return product; } } } @@ -4885,19 +5401,19 @@ var DDHelper = (function () { DDHelper.getCampaign = function getCampaign(id, digitalData) { if (digitalData.campaigns && digitalData.campaigns.length) { - for (var _iterator4 = digitalData.campaigns, _isArray4 = Array.isArray(_iterator4), _i5 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { - var _ref4; + for (var _iterator3 = digitalData.campaigns, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { + var _ref3; - if (_isArray4) { - if (_i5 >= _iterator4.length) break; - _ref4 = _iterator4[_i5++]; + if (_isArray3) { + if (_i4 >= _iterator3.length) break; + _ref3 = _iterator3[_i4++]; } else { - _i5 = _iterator4.next(); - if (_i5.done) break; - _ref4 = _i5.value; + _i4 = _iterator3.next(); + if (_i4.done) break; + _ref3 = _i4.value; } - var campaign = _ref4; + var campaign = _ref3; if (campaign.id && String(campaign.id) === String(id)) { return (0, _componentClone2['default'])(campaign); @@ -4911,7 +5427,107 @@ var DDHelper = (function () { exports['default'] = DDHelper; -},{"component-clone":4}],52:[function(require,module,exports){ +},{"./functions/getProperty.js":67,"component-clone":4}],56:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _htmlGlobals = require('./functions/htmlGlobals.js'); + +var _htmlGlobals2 = _interopRequireDefault(_htmlGlobals); + +var _uuid = require('uuid'); + +var _uuid2 = _interopRequireDefault(_uuid); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { 'default': obj }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +var DigitalDataEnricher = (function () { + function DigitalDataEnricher(digitalData, storage, options) { + _classCallCheck(this, DigitalDataEnricher); + + this.digitalData = digitalData; + this.storage = storage; + this.options = Object.assign({ + sessionLength: 3600 + }, options); + } + + DigitalDataEnricher.prototype.setDigitalData = function setDigitalData(digitalData) { + this.digitalData = digitalData; + }; + + DigitalDataEnricher.prototype.setStorage = function setStorage(storage) { + this.storage = storage; + }; + + DigitalDataEnricher.prototype.getStorage = function getStorage() { + return this.storage; + }; + + DigitalDataEnricher.prototype.enrichDigitalData = function enrichDigitalData() { + this.enrichPageData(); + this.enrichUserData(); + this.enrichContextData(); + }; + + DigitalDataEnricher.prototype.enrichPageData = function enrichPageData() { + var page = this.digitalData.page; + + page.path = page.path || this.getHtmlGlobals().getLocation().pathname; + page.referrer = page.referrer || this.getHtmlGlobals().getDocument().referrer; + page.queryString = page.queryString || this.getHtmlGlobals().getLocation().search; + page.title = page.title || this.getHtmlGlobals().getDocument().title; + page.url = page.url || this.getHtmlGlobals().getLocation().href; + page.hash = page.hash || this.getHtmlGlobals().getLocation().hash; + }; + + DigitalDataEnricher.prototype.enrichUserData = function enrichUserData() { + var user = this.digitalData.user; + user.anonymousId = this.getUserAnonymousId(); + }; + + DigitalDataEnricher.prototype.enrichContextData = function enrichContextData() { + var context = this.digitalData.context; + context.userAgent = this.getHtmlGlobals().getNavigator().userAgent; + }; + + /** + * Can be overriden for test purposes + * @returns {{getDocument, getLocation, getNavigator}} + */ + + DigitalDataEnricher.prototype.getHtmlGlobals = function getHtmlGlobals() { + return _htmlGlobals2['default']; + }; + + DigitalDataEnricher.prototype.getUserAnonymousId = function getUserAnonymousId() { + var anonymousId = this.storage.get('user.anonymousId'); + if (!anonymousId) { + anonymousId = (0, _uuid2['default'])(); + this.storage.set('user.anonymousId', anonymousId); + } + return anonymousId; + }; + + DigitalDataEnricher.prototype.getOption = function getOption(name) { + return this.options[name]; + }; + + return DigitalDataEnricher; +})(); + +exports['default'] = DigitalDataEnricher; + +},{"./functions/htmlGlobals.js":69,"uuid":53}],57:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -5018,7 +5634,7 @@ var EventDataEnricher = (function () { exports['default'] = EventDataEnricher; -},{"./DDHelper.js":51,"component-type":6}],53:[function(require,module,exports){ +},{"./DDHelper.js":55,"component-type":6}],58:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -5335,7 +5951,7 @@ var EventManager = (function () { exports['default'] = EventManager; -},{"./DDHelper.js":51,"./EventDataEnricher.js":52,"./functions/after.js":57,"./functions/deleteProperty.js":58,"./functions/jsonIsEqual.js":62,"./functions/size.js":68,"async":1,"component-clone":4,"debug":44}],54:[function(require,module,exports){ +},{"./DDHelper.js":55,"./EventDataEnricher.js":57,"./functions/after.js":63,"./functions/deleteProperty.js":64,"./functions/jsonIsEqual.js":70,"./functions/size.js":76,"async":1,"component-clone":4,"debug":44}],59:[function(require,module,exports){ 'use strict'; function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -5530,13 +6146,137 @@ var Integration = (function (_EventEmitter) { exports['default'] = Integration; -},{"./DDHelper.js":51,"./functions/deleteProperty.js":58,"./functions/each.js":59,"./functions/format.js":60,"./functions/loadIframe.js":63,"./functions/loadPixel.js":64,"./functions/loadScript.js":65,"./functions/noop.js":66,"async":1,"component-emitter":5,"debug":44}],55:[function(require,module,exports){ +},{"./DDHelper.js":55,"./functions/deleteProperty.js":64,"./functions/each.js":65,"./functions/format.js":66,"./functions/loadIframe.js":71,"./functions/loadPixel.js":72,"./functions/loadScript.js":73,"./functions/noop.js":74,"async":1,"component-emitter":5,"debug":44}],60:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +var _store = require('store'); + +var _store2 = _interopRequireDefault(_store); + +var _jsCookie = require('js-cookie'); + +var _jsCookie2 = _interopRequireDefault(_jsCookie); + +var _debug = require('debug'); + +var _debug2 = _interopRequireDefault(_debug); + +var _topDomain = require('./functions/topDomain.js'); + +var _topDomain2 = _interopRequireDefault(_topDomain); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { 'default': obj }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +var Storage = (function () { + function Storage(options) { + _classCallCheck(this, Storage); + + this.options = Object.assign({ + cookieDomain: (0, _topDomain2['default'])(location.href), + cookieMaxAge: 31536000000, // default to a year + prefix: 'ddl:' + }, options); + + // http://curl.haxx.se/rfc/cookie_spec.html + // https://publicsuffix.org/list/effective_tld_names.dat + // + // try setting a dummy cookie with the options + // if the cookie isn't set, it probably means + // that the domain is on the public suffix list + // like myapp.herokuapp.com or localhost / ip. + if (this.getOption('cookieDomain')) { + _jsCookie2['default'].set('__tld__', true, { + domain: this.getOption('cookieDomain') + }); + if (!this.get('__tld__')) { + (0, _debug2['default'])('fallback to domain=null'); + this.setOption('cookieDomain', null); + } + _jsCookie2['default'].remove('__tld__'); + } + } + + Storage.prototype.set = function set(key, val, exp) { + key = this.prefix + key; + if (_store2['default'].enabled) { + _store2['default'].set(key, { + val: val, + exp: exp, + time: new Date().getTime() + }); + } else { + exp = exp || this.getOption('cookieMaxAge'); + var expDays = exp / 86400; + _jsCookie2['default'].set(key, val, { + expires: expDays, + domain: this.getOption('cookieDomain') + }); + } + }; + + Storage.prototype.get = function get(key) { + key = this.prefix + key; + if (_store2['default'].enabled) { + var info = _store2['default'].get(key); + if (!info) { + return null; + } + if (new Date().getTime() - info.time > info.exp) { + return null; + } + return info.val; + } + return _jsCookie2['default'].get(key); + }; + + Storage.prototype.remove = function remove(key) { + key = this.prefix + key; + if (_store2['default'].enabled) { + return _store2['default'].remove(key); + } + _jsCookie2['default'].remove(key); + }; + + Storage.prototype.clear = function clear() { + if (_store2['default'].enabled) { + return _store2['default'].clear(); + } + }; + + Storage.prototype.isEnabled = function isEnabled() { + return _store2['default'].enabled; + }; + + Storage.prototype.getOption = function getOption(name) { + return this.options[name]; + }; + + return Storage; +})(); + +exports['default'] = Storage; + +},{"./functions/topDomain.js":78,"debug":44,"js-cookie":48,"store":51}],61:[function(require,module,exports){ 'use strict'; var _integrations; exports.__esModule = true; +var _GoogleAnalytics = require('./integrations/GoogleAnalytics.js'); + +var _GoogleAnalytics2 = _interopRequireDefault(_GoogleAnalytics); + var _GoogleTagManager = require('./integrations/GoogleTagManager.js'); var _GoogleTagManager2 = _interopRequireDefault(_GoogleTagManager); @@ -5557,11 +6297,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -var integrations = (_integrations = {}, _integrations[_GoogleTagManager2['default'].getName()] = _GoogleTagManager2['default'], _integrations[_FacebookPixel2['default'].getName()] = _FacebookPixel2['default'], _integrations[_Driveback2['default'].getName()] = _Driveback2['default'], _integrations[_RetailRocket2['default'].getName()] = _RetailRocket2['default'], _integrations); +var integrations = (_integrations = {}, _integrations[_GoogleAnalytics2['default'].getName()] = _GoogleAnalytics2['default'], _integrations[_GoogleTagManager2['default'].getName()] = _GoogleTagManager2['default'], _integrations[_FacebookPixel2['default'].getName()] = _FacebookPixel2['default'], _integrations[_Driveback2['default'].getName()] = _Driveback2['default'], _integrations[_RetailRocket2['default'].getName()] = _RetailRocket2['default'], _integrations); exports['default'] = integrations; -},{"./integrations/Driveback.js":71,"./integrations/FacebookPixel.js":72,"./integrations/GoogleTagManager.js":73,"./integrations/RetailRocket.js":74}],56:[function(require,module,exports){ +},{"./integrations/Driveback.js":81,"./integrations/FacebookPixel.js":82,"./integrations/GoogleAnalytics.js":83,"./integrations/GoogleTagManager.js":84,"./integrations/RetailRocket.js":85}],62:[function(require,module,exports){ 'use strict'; function _typeof2(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -5608,9 +6348,17 @@ var _DDHelper = require('./DDHelper.js'); var _DDHelper2 = _interopRequireDefault(_DDHelper); -function _interopRequireDefault(obj) { - return obj && obj.__esModule ? obj : { 'default': obj }; -} +var _DigitalDataEnricher = require('./DigitalDataEnricher.js'); + +var _DigitalDataEnricher2 = _interopRequireDefault(_DigitalDataEnricher); + +var _Storage = require('./Storage.js'); + +var _Storage2 = _interopRequireDefault(_Storage); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { 'default': obj }; +} function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); @@ -5646,6 +6394,12 @@ var _digitalData = {}; */ var _ddListener = []; +/** + * @type {Storage} + * @private + */ +var _storage = undefined; + /** * @type {Object} * @private @@ -5685,6 +6439,7 @@ function _prepareGlobals() { _digitalData.page = _digitalData.page || {}; _digitalData.user = _digitalData.user || {}; + _digitalData.context = _digitalData.context || {}; if (!_digitalData.page.type || _digitalData.page.type !== 'confirmation') { _digitalData.cart = _digitalData.cart || {}; } @@ -5732,6 +6487,7 @@ var ddManager = { * * { * autoEvents: true, + * sessionLength: 3600, * integrations: { * 'Google Tag Manager': { * containerId: 'XXX' @@ -5744,7 +6500,9 @@ var ddManager = { */ initialize: function initialize(settings) { settings = Object.assign({ - autoEvents: true + domain: null, + autoEvents: true, + sessionLength: 3600 }, settings); if (_isInitialized) { @@ -5753,6 +6511,18 @@ var ddManager = { _prepareGlobals(); + // initialize storage + _storage = new _Storage2['default']({ + cookieDomain: settings.domain + }); + + // initialize digital data enricher + var digitalDataEnricher = new _DigitalDataEnricher2['default'](_digitalData, _storage, { + sessionLength: settings.sessionLength + }); + digitalDataEnricher.enrichDigitalData(); + + // initialize event manager _eventManager = new _EventManager2['default'](_digitalData, _ddListener); if (settings.autoEvents) { _eventManager.setAutoEvents(new _AutoEvents2['default']()); @@ -5873,7 +6643,7 @@ ddManager.on = ddManager.addEventListener = function (event, handler) { exports['default'] = ddManager; -},{"./AutoEvents.js":50,"./DDHelper.js":51,"./EventManager.js":53,"./Integration.js":54,"./functions/after.js":57,"./functions/each.js":59,"./functions/size.js":68,"async":1,"component-clone":4,"component-emitter":5}],57:[function(require,module,exports){ +},{"./AutoEvents.js":54,"./DDHelper.js":55,"./DigitalDataEnricher.js":56,"./EventManager.js":58,"./Integration.js":59,"./Storage.js":60,"./functions/after.js":63,"./functions/each.js":65,"./functions/size.js":76,"async":1,"component-clone":4,"component-emitter":5}],63:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -5887,7 +6657,7 @@ exports["default"] = function (times, fn) { }; }; -},{}],58:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -5900,7 +6670,7 @@ exports["default"] = function (obj, prop) { } }; -},{}],59:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -5913,7 +6683,7 @@ exports["default"] = function (obj, fn) { } }; -},{}],60:[function(require,module,exports){ +},{}],66:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -5952,7 +6722,36 @@ function format(str) { }); } -},{}],61:[function(require,module,exports){ +},{}],67:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; + +exports['default'] = function (obj, prop) { + var keyParts = _keyToArray(prop); + var nestedVar = obj; + while (keyParts.length > 0) { + var childKey = keyParts.shift(); + if (nestedVar.hasOwnProperty(childKey)) { + nestedVar = nestedVar[childKey]; + } else { + return undefined; + } + } + return nestedVar; +}; + +function _keyToArray(key) { + key = key.trim(); + if (key === '') { + return []; + } + key = key.replace(/\[(\w+)\]/g, '.$1'); + key = key.replace(/^\./, ''); + return key.split('.'); +} + +},{}],68:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -5967,7 +6766,25 @@ function getQueryParam(name, queryString) { return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); } -},{}],62:[function(require,module,exports){ +},{}],69:[function(require,module,exports){ +"use strict"; + +exports.__esModule = true; +exports["default"] = { + getDocument: function getDocument() { + return window.document; + }, + + getLocation: function getLocation() { + return window.location; + }, + + getNavigator: function getNavigator() { + return window.navigator; + } +}; + +},{}],70:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -5982,7 +6799,7 @@ function jsonIsEqual(json1, json2) { return json1 === json2; } -},{}],63:[function(require,module,exports){ +},{}],71:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -6042,7 +6859,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -},{"./scriptOnLoad.js":67,"async":1}],64:[function(require,module,exports){ +},{"./scriptOnLoad.js":75,"async":1}],72:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -6078,7 +6895,7 @@ function error(fn, message, img) { }; } -},{}],65:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -6137,14 +6954,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -},{"./scriptOnLoad.js":67,"async":1}],66:[function(require,module,exports){ +},{"./scriptOnLoad.js":75,"async":1}],74:[function(require,module,exports){ "use strict"; exports.__esModule = true; exports["default"] = function () {}; -},{}],67:[function(require,module,exports){ +},{}],75:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -6199,7 +7016,7 @@ function attachEvent(el, fn) { }); } -},{}],68:[function(require,module,exports){ +},{}],76:[function(require,module,exports){ "use strict"; exports.__esModule = true; @@ -6212,7 +7029,7 @@ exports["default"] = function (obj) { return size; }; -},{}],69:[function(require,module,exports){ +},{}],77:[function(require,module,exports){ 'use strict'; exports.__esModule = true; @@ -6239,7 +7056,144 @@ function throwError(code, message) { throw error; } -},{"debug":44}],70:[function(require,module,exports){ +},{"debug":44}],78:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports['default'] = topDomain; + +var _url = require('./url.js'); + +var _jsCookie = require('js-cookie'); + +var _jsCookie2 = _interopRequireDefault(_jsCookie); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { 'default': obj }; +} + +/** + * Levels returns all levels of the given url. + * + * @param {String} url + * @return {Array} + * @api public + */ +function getLevels(url) { + var host = (0, _url.parse)(url).hostname; + var parts = host.split('.'); + var last = parts[parts.length - 1]; + var levels = []; + + // Ip address. + if (parts.length === 4 && parseInt(last, 10) === last) { + return levels; + } + + // Localhost. + if (parts.length <= 1) { + return levels; + } + + // Create levels. + for (var i = parts.length - 2; i >= 0; --i) { + levels.push(parts.slice(i).join('.')); + } + + return levels; +} + +/** + * Get the top domain. + * + * The function constructs the levels of domain + * and attempts to set a global cookie on each one + * when it succeeds it returns the top level domain. + * + * The method returns an empty string when the hostname + * is an ip or `localhost`. + * + * Example levels: + * + * domain.levels('http://www.google.co.uk'); + * // => ["co.uk", "google.co.uk", "www.google.co.uk"] + * + * Example: + * + * domain('http://localhost:3000/baz'); + * // => '' + * domain('http://dev:3000/baz'); + * // => '' + * domain('http://127.0.0.1:3000/baz'); + * // => '' + * domain('http://example.com/baz'); + * // => 'example.com' + * + * @param {String} url + * @return {String} + * @api public + */ + +function topDomain(url) { + var levels = getLevels(url); + + // Lookup the real top level one. + for (var i = 0; i < levels.length; ++i) { + var cname = '__tld__'; + var domain = levels[i]; + var opts = { + domain: '.' + domain + }; + _jsCookie2['default'].set(cname, 1, opts); + if (_jsCookie2['default'].get(cname)) { + _jsCookie2['default'].set(cname, null, opts); + return domain; + } + } + + return ''; +} + +},{"./url.js":79,"js-cookie":48}],79:[function(require,module,exports){ +'use strict'; + +exports.__esModule = true; +exports.parse = parse; +/** + * Return default port for `protocol`. + * + * @param {String} protocol + * @return {String} + * @api private + */ +function port(protocol) { + switch (protocol) { + case 'http:': + return 80; + case 'https:': + return 443; + default: + return location.port; + } +} + +function parse(url) { + var a = document.createElement('a'); + a.href = url; + return { + href: a.href, + host: a.host || location.host, + port: a.port === '0' || a.port === '' ? port(a.protocol) : a.port, + hash: a.hash, + hostname: a.hostname || location.hostname, + pathname: a.pathname.charAt(0) !== '/' ? '/' + a.pathname : a.pathname, + protocol: !a.protocol || a.protocol === ':' ? location.protocol : a.protocol, + search: a.search, + query: a.search.slice(1) + }; +} + +},{}],80:[function(require,module,exports){ 'use strict'; require('./polyfill.js'); @@ -6261,7 +7215,7 @@ _ddManager2['default'].processEarlyStubCalls(); window.ddManager = _ddManager2['default']; -},{"./availableIntegrations.js":55,"./ddManager.js":56,"./polyfill.js":75}],71:[function(require,module,exports){ +},{"./availableIntegrations.js":61,"./ddManager.js":62,"./polyfill.js":86}],81:[function(require,module,exports){ 'use strict'; function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -6358,7 +7312,7 @@ var Driveback = (function (_Integration) { exports['default'] = Driveback; -},{"./../Integration.js":54,"./../functions/deleteProperty.js":58}],72:[function(require,module,exports){ +},{"./../Integration.js":59,"./../functions/deleteProperty.js":64}],82:[function(require,module,exports){ 'use strict'; function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -6426,7 +7380,7 @@ var FacebookPixel = (function (_Integration) { FacebookPixel.prototype.initialize = function initialize() { if (this.getOption('pixelId') && !window.fbq) { - window.fbq = window._fbq = function () { + window.fbq = window._fbq = function fbq() { if (window.fbq.callMethod) { window.fbq.callMethod.apply(window.fbq, arguments); } else { @@ -6549,7 +7503,607 @@ var FacebookPixel = (function (_Integration) { exports['default'] = FacebookPixel; -},{"./../Integration.js":54,"./../functions/deleteProperty.js":58,"component-type":6}],73:[function(require,module,exports){ +},{"./../Integration.js":59,"./../functions/deleteProperty.js":64,"component-type":6}],83:[function(require,module,exports){ +'use strict'; + +function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } + +exports.__esModule = true; + +var _Integration2 = require('./../Integration.js'); + +var _Integration3 = _interopRequireDefault(_Integration2); + +var _deleteProperty = require('./../functions/deleteProperty.js'); + +var _deleteProperty2 = _interopRequireDefault(_deleteProperty); + +var _getProperty = require('./../functions/getProperty.js'); + +var _getProperty2 = _interopRequireDefault(_getProperty); + +var _each = require('./../functions/each.js'); + +var _each2 = _interopRequireDefault(_each); + +var _size = require('./../functions/size.js'); + +var _size2 = _interopRequireDefault(_size); + +var _componentType = require('component-type'); + +var _componentType2 = _interopRequireDefault(_componentType); + +var _componentClone = require('component-clone'); + +var _componentClone2 = _interopRequireDefault(_componentClone); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { 'default': obj }; +} + +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} + +function _possibleConstructorReturn(self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + }return call && ((typeof call === 'undefined' ? 'undefined' : _typeof(call)) === "object" || typeof call === "function") ? call : self; +} + +function _inherits(subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === 'undefined' ? 'undefined' : _typeof(superClass))); + }subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +} + +function enhancedEcommerceTrackProduct(product, quantity) { + var gaProduct = { + id: product.id || product.skuCode, + name: product.name, + category: product.category, + quantity: quantity, + price: product.unitSalePrice || product.unitPrice, + brand: product.brand || product.manufacturer, + variant: product.variant, + currency: product.currency + }; + // append coupon if it set + // https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-transactions + if (product.voucher) gaProduct.coupon = product.voucher; + window.ga('ec:addProduct', gaProduct); +} + +function enhancedEcommerceProductAction(event, action, data) { + enhancedEcommerceTrackProduct(event.product, event.quantity); + window.ga('ec:setAction', action, data || {}); +} + +function getTransactionVoucher(transaction) { + var voucher = undefined; + if (Array.isArray(transaction.vouchers)) { + voucher = transaction.vouchers[0]; + } else { + voucher = transaction.voucher; + } + if (!voucher) { + if (Array.isArray(transaction.promotions)) { + voucher = transaction.promotions[0]; + } else { + voucher = transaction.promotion; + } + } + return voucher; +} + +function getCheckoutOptions(event) { + var optionNames = ['paymentMethod', 'shippingMethod']; + var options = []; + for (var _iterator = optionNames, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var optionName = _ref; + + if (event[optionName]) { + options.push(event[optionName]); + } + } + return options.join(', '); +} + +var GoogleAnalytics = (function (_Integration) { + _inherits(GoogleAnalytics, _Integration); + + function GoogleAnalytics(digitalData, options) { + _classCallCheck(this, GoogleAnalytics); + + var optionsWithDefaults = Object.assign({ + trackingId: '', + doubleClick: false, + enhancedLinkAttribution: false, + enhancedEcommerce: false, + sendUserId: false, + anonymizeIp: false, + domain: 'auto', + includeSearch: false, + siteSpeedSampleRate: 1, + defaultCurrency: 'USD', + metrics: {}, + dimensions: {}, + contentGroupings: {} + }, options); + + var _this = _possibleConstructorReturn(this, _Integration.call(this, digitalData, optionsWithDefaults)); + + _this.addTag({ + type: 'script', + attr: { + src: '//www.google-analytics.com/analytics.js' + } + }); + return _this; + } + + GoogleAnalytics.getName = function getName() { + return 'Google Analytics'; + }; + + GoogleAnalytics.prototype.initialize = function initialize() { + if (this.getOption('trackingId')) { + this.pageCalled = false; + + // setup the tracker globals + window.GoogleAnalyticsObject = 'ga'; + window.ga = window.ga || function ga() { + window.ga.q = window.ga.q || []; + window.ga.q.push(arguments); + }; + window.ga.l = new Date().getTime(); + + if (window.location.hostname === 'localhost') { + this.setOption('domain', 'none'); + } + + window.ga('create', this.getOption('trackingId'), { + // Fall back on default to protect against empty string + cookieDomain: this.getOption('domain'), + siteSpeedSampleRate: this.getOption('siteSpeedSampleRate'), + allowLinker: true + }); + + // display advertising + if (this.getOption('doubleClick')) { + window.ga('require', 'displayfeatures'); + } + // https://support.google.com/analytics/answer/2558867?hl=en + if (this.getOption('enhancedLinkAttribution')) { + window.ga('require', 'linkid', 'linkid.js'); + } + + // send global id + var userId = this.get('user.id'); + if (this.getOption('sendUserId') && userId) { + window.ga('set', 'userId', userId); + } + + // anonymize after initializing, otherwise a warning is shown + // in google analytics debugger + if (this.getOption('anonymizeIp')) window.ga('set', 'anonymizeIp', true); + + // custom dimensions & metrics + var custom = this.getCustomDimensions(); + if ((0, _size2['default'])(custom)) window.ga('set', custom); + + this.load(this.ready); + } else { + this.ready(); + } + }; + + GoogleAnalytics.prototype.isLoaded = function isLoaded() { + return !!window.gaplugins; + }; + + GoogleAnalytics.prototype.reset = function reset() { + (0, _deleteProperty2['default'])(window, 'GoogleAnalyticsObject'); + (0, _deleteProperty2['default'])(window, 'ga'); + (0, _deleteProperty2['default'])(window, 'gaplugins'); + this.pageCalled = false; + }; + + GoogleAnalytics.prototype.getCustomDimensions = function getCustomDimensions(source) { + source = source || this._digitalData; + var settings = Object.assign(Object.assign(this.getOption('metrics'), this.getOption('dimensions')), this.getOption('contentGroupings')); + var custom = {}; + (0, _each2['default'])(settings, function (key, value) { + var dimensionVal = (0, _getProperty2['default'])(source, value); + if (dimensionVal !== undefined) { + if ((0, _componentType2['default'])(dimensionVal) === 'boolean') dimensionVal = dimensionVal.toString(); + custom[key] = dimensionVal; + } + }); + return custom; + }; + + GoogleAnalytics.prototype.loadEnhancedEcommerce = function loadEnhancedEcommerce(currency) { + if (!this.enhancedEcommerceLoaded) { + window.ga('require', 'ec'); + this.enhancedEcommerceLoaded = true; + } + + // Ensure we set currency for every hit + window.ga('set', '&cu', currency || this.getOption('defaultCurrency')); + }; + + GoogleAnalytics.prototype.pushEnhancedEcommerce = function pushEnhancedEcommerce(event) { + // Send a custom non-interaction event to ensure all EE data is pushed. + // Without doing this we'd need to require page display after setting EE data. + var cleanedArgs = []; + var args = ['send', 'event', event.category || 'Ecommerce', event.name || 'not defined', event.label, { + nonInteraction: 1 + }]; + + for (var _iterator2 = args, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var arg = _ref2; + + if (arg !== undefined) { + cleanedArgs.push(arg); + } + } + + window.ga.apply(window, cleanedArgs); + }; + + GoogleAnalytics.prototype.trackEvent = function trackEvent(event) { + if (event.name === 'Viewed Page') { + this.onViewedPage(event); + } else if (this.getOption('enhancedEcommerce')) { + if (event.name === 'Viewed Product') { + this.onViewedProduct(event); + } else if (event.name === 'Clicked Product') { + this.onClickedProduct(event); + } else if (event.name === 'Viewed Product Detail') { + this.onViewedProductDetail(event); + } else if (event.name === 'Added Product') { + this.onAddedProduct(event); + } else if (event.name === 'Removed Product') { + this.onRemovedProduct(event); + } else if (event.name === 'Completed Transaction') { + this.onCompletedTransactionEnhanced(event); + } else if (event.name === 'Refunded Transaction') { + this.onRefundedTransaction(event); + } else if (event.name === 'Viewed Product Category') { + this.onViewedProductCategory(event); + } else if (event.name === 'Viewed Campaign') { + this.onViewedCampaign(event); + } else if (event.name === 'Clicked Campaign') { + this.onClickedCampaign(event); + } else if (event.name === 'Viewed Checkout Step') { + this.onViewedCheckoutStep(event); + } else if (event.name === 'Completed Checkout Step') { + this.onCompletedCheckoutStep(event); + } else { + this.onCustomEvent(event); + } + } else { + if (event.name === 'Completed Transaction') { + this.onCompletedTransaction(event); + } else { + this.onCustomEvent(event); + } + } + }; + + GoogleAnalytics.prototype.onViewedPage = function onViewedPage(event) { + var page = event.page; + var campaign = this.get('context.campaign') || {}; + var pageview = {}; + var pageUrl = page.url; + var pagePath = page.path; + if (this.getOption('includeSearch') && page.queryString) { + pagePath = pagePath + page.queryString; + } + var pageTitle = page.name || page.title; + + pageview.page = pagePath; + pageview.title = pageTitle; + pageview.location = pageUrl; + + if (campaign.name) pageview.campaignName = campaign.name; + if (campaign.source) pageview.campaignSource = campaign.source; + if (campaign.medium) pageview.campaignMedium = campaign.medium; + if (campaign.content) pageview.campaignContent = campaign.content; + if (campaign.term) pageview.campaignKeyword = campaign.term; + + // set + window.ga('set', { + page: pagePath, + title: pageTitle + }); + + if (this.pageCalled) { + (0, _deleteProperty2['default'])(pageview, 'location'); + } + + // send + window.ga('send', 'pageview', pageview); + + this.pageCalled = true; + }; + + GoogleAnalytics.prototype.onViewedProduct = function onViewedProduct(event) { + var product = event.product; + if (!product.id && !product.skuCode && !product.name) { + return; + } + this.loadEnhancedEcommerce(product.currency); + window.ga('ec:addImpression', { + id: product.id || product.skuCode, + name: product.name, + list: product.listName, + category: product.category, + brand: product.brand || product.manufacturer, + price: product.unitSalePrice || product.unitPrice, + currency: product.currency || this.getOption('defaultCurrency'), + variant: product.variant, + position: product.position + }); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onClickedProduct = function onClickedProduct(event) { + var product = event.product; + this.loadEnhancedEcommerce(product.currency); + enhancedEcommerceProductAction(event, 'click', { + list: product.listName + }); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onViewedProductDetail = function onViewedProductDetail(event) { + var product = event.product; + this.loadEnhancedEcommerce(product.currency); + enhancedEcommerceProductAction(event, 'detail'); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onAddedProduct = function onAddedProduct(event) { + var product = event.product; + this.loadEnhancedEcommerce(product.currency); + enhancedEcommerceProductAction(event, 'add'); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onRemovedProduct = function onRemovedProduct(event) { + var product = event.product; + this.loadEnhancedEcommerce(product.currency); + enhancedEcommerceProductAction(event, 'remove'); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onCompletedTransaction = function onCompletedTransaction(event) { + var transaction = event.transaction; + // orderId is required. + if (!transaction || !transaction.orderId) return; + + // require ecommerce + if (!this.ecommerce) { + window.ga('require', 'ecommerce'); + this.ecommerce = true; + } + + // add transaction + window.ga('ecommerce:addTransaction', { + id: transaction.orderId, + affiliation: transaction.affiliation, + shipping: transaction.shippingCost, + tax: transaction.tax, + revenue: transaction.total || transaction.subtotal || 0, + currency: transaction.currency + }); + + // add products + (0, _each2['default'])(transaction.lineItems, function addProduct(key, lineItem) { + var product = lineItem.product; + if (product) { + window.ga('ecommerce:addItem', { + id: transaction.orderId, + category: product.category, + quantity: lineItem.quantity, + price: product.unitSalePrice || product.unitPrice, + name: product.name, + sku: product.skuCode, + currency: product.currency || transaction.currency + }); + } + }); + + // send + window.ga('ecommerce:send'); + }; + + GoogleAnalytics.prototype.onCompletedTransactionEnhanced = function onCompletedTransactionEnhanced(event) { + var transaction = event.transaction; + + // orderId is required. + if (!transaction || !transaction.orderId) return; + + this.loadEnhancedEcommerce(transaction.currency); + + (0, _each2['default'])(transaction.lineItems, function addProduct(key, lineItem) { + var product = lineItem.product; + if (product) { + product.currency = product.currency || transaction.currency || this.getOption('defaultCurrency'); + enhancedEcommerceTrackProduct(lineItem.product, lineItem.quantity); + } + }); + + var voucher = getTransactionVoucher(transaction); + window.ga('ec:setAction', 'purchase', { + id: transaction.orderId, + affiliation: transaction.affiliation, + revenue: transaction.total || transaction.subtotal || 0, + tax: transaction.tax, + shipping: transaction.shippingCost, + coupon: voucher + }); + + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onRefundedTransaction = function onRefundedTransaction(event) { + var transaction = event.transaction; + + // orderId is required. + if (!transaction || !transaction.orderId) return; + + this.loadEnhancedEcommerce(transaction.currency); + + (0, _each2['default'])(transaction.lineItems, function addProduct(key, lineItem) { + var product = lineItem.product; + if (product) { + product.currency = product.currency || transaction.currency || this.getOption('defaultCurrency'); + enhancedEcommerceTrackProduct(lineItem.product, lineItem.quantity); + } + }); + + window.ga('ec:setAction', 'refund', { + id: transaction.orderId + }); + + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onViewedCampaign = function onViewedCampaign(event) { + var campaign = event.campaign; + + if (!campaign || !campaign.id) { + return; + } + + this.loadEnhancedEcommerce(); + window.ga('ec:addPromo', { + id: campaign.id, + name: campaign.name, + creative: campaign.design || campaign.creative, + position: campaign.position + }); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onClickedCampaign = function onClickedCampaign(event) { + var campaign = event.campaign; + + if (!campaign || !campaign.id) { + return; + } + + this.loadEnhancedEcommerce(); + window.ga('ec:addPromo', { + id: campaign.id, + name: campaign.name, + creative: campaign.design || campaign.creative, + position: campaign.position + }); + window.ga('ec:setAction', 'promo_click', {}); + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onViewedCheckoutStep = function onViewedCheckoutStep(event) { + var cartOrTransaction = this.get('cart') || this.get('transaction'); + + this.loadEnhancedEcommerce(cartOrTransaction.currency); + + (0, _each2['default'])(cartOrTransaction.lineItems, function addProduct(key, lineItem) { + var product = lineItem.product; + if (product) { + product.currency = product.currency || cartOrTransaction.currency || this.getOption('defaultCurrency'); + enhancedEcommerceTrackProduct(lineItem.product, lineItem.quantity); + } + }); + + window.ga('ec:setAction', 'checkout', { + step: event.step || 1, + option: getCheckoutOptions(event) || undefined + }); + + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onCompletedCheckoutStep = function onCompletedCheckoutStep(event) { + var cartOrTransaction = this.get('cart') || this.get('transaction'); + var options = getCheckoutOptions(event); + + if (!event.step || !options) { + return; + } + + this.loadEnhancedEcommerce(cartOrTransaction.currency); + + window.ga('ec:setAction', 'checkout_option', { + step: event.step, + option: options + }); + + this.pushEnhancedEcommerce(event); + }; + + GoogleAnalytics.prototype.onCustomEvent = function onCustomEvent(event) { + var campaign = this.get('context.campaign') || {}; + + // custom dimensions & metrics + var source = (0, _componentClone2['default'])(event); + (0, _deleteProperty2['default'])(source, 'name'); + (0, _deleteProperty2['default'])(source, 'category'); + var custom = this.getCustomDimensions(source); + if ((0, _size2['default'])(custom)) window.ga('set', custom); + + var payload = { + eventAction: event.name || 'event', + eventCategory: event.category || 'All', + eventLabel: event.label, + eventValue: Math.round(event.value) || 0, + nonInteraction: !!event.nonInteraction + }; + + if (campaign.name) payload.campaignName = campaign.name; + if (campaign.source) payload.campaignSource = campaign.source; + if (campaign.medium) payload.campaignMedium = campaign.medium; + if (campaign.content) payload.campaignContent = campaign.content; + if (campaign.term) payload.campaignKeyword = campaign.term; + + window.ga('send', 'event', payload); + }; + + return GoogleAnalytics; +})(_Integration3['default']); + +exports['default'] = GoogleAnalytics; + +},{"./../Integration.js":59,"./../functions/deleteProperty.js":64,"./../functions/each.js":65,"./../functions/getProperty.js":67,"./../functions/size.js":76,"component-clone":4,"component-type":6}],84:[function(require,module,exports){ 'use strict'; function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -6645,7 +8199,7 @@ var GoogleTagManager = (function (_Integration) { exports['default'] = GoogleTagManager; -},{"./../Integration.js":54,"./../functions/deleteProperty.js":58}],74:[function(require,module,exports){ +},{"./../Integration.js":59,"./../functions/deleteProperty.js":64}],85:[function(require,module,exports){ 'use strict'; function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } @@ -6976,7 +8530,7 @@ var RetailRocket = (function (_Integration) { exports['default'] = RetailRocket; -},{"./../Integration.js":54,"./../functions/deleteProperty.js":58,"./../functions/format.js":60,"./../functions/getQueryParam.js":61,"./../functions/throwError.js":69,"component-type":6}],75:[function(require,module,exports){ +},{"./../Integration.js":59,"./../functions/deleteProperty.js":64,"./../functions/format.js":66,"./../functions/getQueryParam.js":68,"./../functions/throwError.js":77,"component-type":6}],86:[function(require,module,exports){ 'use strict'; require('core-js/modules/es5'); @@ -6985,4 +8539,4 @@ require('core-js/modules/es6.object.assign'); require('core-js/modules/es6.string.trim'); -},{"core-js/modules/es5":41,"core-js/modules/es6.object.assign":42,"core-js/modules/es6.string.trim":43}]},{},[70]); +},{"core-js/modules/es5":41,"core-js/modules/es6.object.assign":42,"core-js/modules/es6.string.trim":43}]},{},[80]); diff --git a/dist/dd-manager.min.js b/dist/dd-manager.min.js index e3f3cb5..48db74d 100644 --- a/dist/dd-manager.min.js +++ b/dist/dd-manager.min.js @@ -1,3 +1,4 @@ -!function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var c="function"==typeof require&&require;if(!u&&c)return c(a,!0);if(i)return i(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[a]={exports:{}};e[a][0].call(f.exports,function(t){var n=e[a][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a=0&&t.length%1===0}function f(t,e){for(var n=-1,r=t.length;++nr?r:null}):(n=Y(t),e=n.length,function(){return r++,e>r?n[r]:null})}function v(t,e){return e=null==e?t.length-1:+e,function(){for(var n=Math.max(arguments.length-e,0),r=Array(n),o=0;n>o;o++)r[o]=arguments[o+e];switch(e){case 0:return t.call(this,r);case 1:return t.call(this,arguments[0],r)}}}function w(t){return function(e,n,r){return t(e,r)}}function m(t){return function(e,n,o){o=c(o||r),e=e||[];var i=g(e);if(0>=t)return o(null);var a=!1,s=0,f=!1;!function l(){if(a&&0>=s)return o(null);for(;t>s&&!f;){var r=i();if(null===r)return a=!0,void(0>=s&&o(null));s+=1,n(e[r],r,u(function(t){s-=1,t?(o(t),f=!0):l()}))}}()}}function b(t){return function(e,n,r){return t(C.eachOf,e,n,r)}}function E(t){return function(e,n,r,o){return t(m(n),e,r,o)}}function _(t){return function(e,n,r){return t(C.eachOfSeries,e,n,r)}}function j(t,e,n,o){o=c(o||r),e=e||[];var i=s(e)?[]:{};t(e,function(t,e,r){n(t,function(t,n){i[e]=n,r(t)})},function(t){o(t,i)})}function A(t,e,n,r){var o=[];t(e,function(t,e,r){n(t,function(n){n&&o.push({index:e,value:t}),r()})},function(){r(l(o.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})}function k(t,e,n,r){A(t,e,function(t,e){n(t,function(t){e(!t)})},r)}function I(t,e,n){return function(r,o,i,a){function u(){a&&a(n(!1,void 0))}function c(t,r,o){return a?void i(t,function(r){a&&e(r)&&(a(n(!0,t)),a=i=!1),o()}):o()}arguments.length>3?t(r,o,c,u):(a=i,i=o,t(r,c,u))}}function P(t,e){return e}function S(t,e,n){n=n||r;var o=s(e)?[]:{};t(e,function(t,e,n){t(v(function(t,r){r.length<=1&&(r=r[0]),o[e]=r,n(t)}))},function(t){n(t,o)})}function O(t,e,n,r){var o=[];t(e,function(t,e,r){n(t,function(t,e){o=o.concat(e||[]),r(t)})},function(t){r(t,o)})}function D(t,e,n){function o(t,e,n,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");return t.started=!0,U(e)||(e=[e]),0===e.length&&t.idle()?C.setImmediate(function(){t.drain()}):(f(e,function(e){var i={data:e,callback:o||r};n?t.tasks.unshift(i):t.tasks.push(i),t.tasks.length===t.concurrency&&t.saturated()}),void C.setImmediate(t.process))}function i(t,e){return function(){a-=1;var n=!1,r=arguments;f(e,function(t){f(c,function(e,r){e!==t||n||(c.splice(r,1),n=!0)}),t.callback.apply(t,r)}),t.tasks.length+a===0&&t.drain(),t.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var a=0,c=[],s={tasks:[],concurrency:e,payload:n,saturated:r,empty:r,drain:r,started:!1,paused:!1,push:function(t,e){o(s,t,!1,e)},kill:function(){s.drain=r,s.tasks=[]},unshift:function(t,e){o(s,t,!0,e)},process:function(){if(!s.paused&&a=e;e++)C.setImmediate(s.process)}}};return s}function $(t){return v(function(e,n){e.apply(null,n.concat([v(function(e,n){"object"==typeof console&&(e?console.error&&console.error(e):console[t]&&f(n,function(e){console[t](e)}))})]))})}function x(t){return function(e,n,r){t(d(e),n,r)}}function T(t){return v(function(e,n){var r=v(function(n){var r=this,o=n.pop();return t(e,function(t,e,o){t.apply(r,n.concat([o]))},o)});return n.length?r.apply(this,n):r})}function L(t){return v(function(e){var n=e.pop();e.push(function(){var t=arguments;r?C.setImmediate(function(){n.apply(null,t)}):n.apply(null,t)});var r=!0;t.apply(this,e),r=!1})}var R,C={},M="object"==typeof self&&self.self===self&&self||"object"==typeof n&&n.global===n&&n||this;null!=M&&(R=M.async),C.noConflict=function(){return M.async=R,C};var B=Object.prototype.toString,U=Array.isArray||function(t){return"[object Array]"===B.call(t)},N=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},Y=Object.keys||function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e},V="function"==typeof setImmediate&&setImmediate,F=V?function(t){V(t)}:function(t){setTimeout(t,0)};"object"==typeof t&&"function"==typeof t.nextTick?C.nextTick=t.nextTick:C.nextTick=F,C.setImmediate=V?F:C.nextTick,C.forEach=C.each=function(t,e,n){return C.eachOf(t,w(e),n)},C.forEachSeries=C.eachSeries=function(t,e,n){return C.eachOfSeries(t,w(e),n)},C.forEachLimit=C.eachLimit=function(t,e,n,r){return m(e)(t,w(n),r)},C.forEachOf=C.eachOf=function(t,e,n){function o(t){s--,t?n(t):null===i&&0>=s&&n(null)}n=c(n||r),t=t||[];for(var i,a=g(t),s=0;null!=(i=a());)s+=1,e(t[i],i,u(o));0===s&&n(null)},C.forEachOfSeries=C.eachOfSeries=function(t,e,n){function o(){var r=!0;return null===a?n(null):(e(t[a],a,u(function(t){if(t)n(t);else{if(a=i(),null===a)return n(null);r?C.setImmediate(o):o()}})),void(r=!1))}n=c(n||r),t=t||[];var i=g(t),a=i();o()},C.forEachOfLimit=C.eachOfLimit=function(t,e,n,r){m(e)(t,n,r)},C.map=b(j),C.mapSeries=_(j),C.mapLimit=E(j),C.inject=C.foldl=C.reduce=function(t,e,n,r){C.eachOfSeries(t,function(t,r,o){n(e,t,function(t,n){e=n,o(t)})},function(t){r(t,e)})},C.foldr=C.reduceRight=function(t,e,n,r){var i=l(t,o).reverse();C.reduce(i,e,n,r)},C.transform=function(t,e,n,r){3===arguments.length&&(r=n,n=e,e=U(t)?[]:{}),C.eachOf(t,function(t,r,o){n(e,t,r,o)},function(t){r(t,e)})},C.select=C.filter=b(A),C.selectLimit=C.filterLimit=E(A),C.selectSeries=C.filterSeries=_(A),C.reject=b(k),C.rejectLimit=E(k),C.rejectSeries=_(k),C.any=C.some=I(C.eachOf,i,o),C.someLimit=I(C.eachOfLimit,i,o),C.all=C.every=I(C.eachOf,a,a),C.everyLimit=I(C.eachOfLimit,a,a),C.detect=I(C.eachOf,o,P),C.detectSeries=I(C.eachOfSeries,o,P),C.detectLimit=I(C.eachOfLimit,o,P),C.sortBy=function(t,e,n){function r(t,e){var n=t.criteria,r=e.criteria;return r>n?-1:n>r?1:0}C.map(t,function(t,n){e(t,function(e,r){e?n(e):n(null,{value:t,criteria:r})})},function(t,e){return t?n(t):void n(null,l(e.sort(r),function(t){return t.value}))})},C.auto=function(t,e,n){function o(t){g.unshift(t)}function i(t){var e=y(g,t);e>=0&&g.splice(e,1)}function a(){s--,f(g.slice(0),function(t){t()})}n||(n=e,e=null),n=c(n||r);var u=Y(t),s=u.length;if(!s)return n(null);e||(e=s);var l={},d=0,g=[];o(function(){s||n(null,l)}),f(u,function(r){function u(){return e>d&&p(w,function(t,e){return t&&l.hasOwnProperty(e)},!0)&&!l.hasOwnProperty(r)}function c(){u()&&(d++,i(c),f[f.length-1](g,l))}for(var s,f=U(t[r])?t[r]:[t[r]],g=v(function(t,e){if(d--,e.length<=1&&(e=e[0]),t){var o={};h(l,function(t,e){o[e]=t}),o[r]=e,n(t,o)}else l[r]=e,C.setImmediate(a)}),w=f.slice(0,f.length-1),m=w.length;m--;){if(!(s=t[w[m]]))throw new Error("Has inexistant dependency");if(U(s)&&y(s,r)>=0)throw new Error("Has cyclic dependencies")}u()?(d++,f[f.length-1](g,l)):o(c)})},C.retry=function(t,e,n){function r(t,e){if("number"==typeof e)t.times=parseInt(e,10)||i;else{if("object"!=typeof e)throw new Error("Unsupported argument type for 'times': "+typeof e);t.times=parseInt(e.times,10)||i,t.interval=parseInt(e.interval,10)||a}}function o(t,e){function n(t,n){return function(r){t(function(t,e){r(!t||n,{err:t,result:e})},e)}}function r(t){return function(e){setTimeout(function(){e(null)},t)}}for(;c.times;){var o=!(c.times-=1);u.push(n(c.task,o)),!o&&c.interval>0&&u.push(r(c.interval))}C.series(u,function(e,n){n=n[n.length-1],(t||c.callback)(n.err,n.result)})}var i=5,a=0,u=[],c={times:i,interval:a},s=arguments.length;if(1>s||s>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=s&&"function"==typeof t&&(n=e,e=t),"function"!=typeof t&&r(c,t),c.callback=n,c.task=e,c.callback?o():o},C.waterfall=function(t,e){function n(t){return v(function(r,o){if(r)e.apply(null,[r].concat(o));else{var i=t.next();i?o.push(n(i)):o.push(e),L(t).apply(null,o)}})}if(e=c(e||r),!U(t)){var o=new Error("First argument to waterfall must be an array of functions");return e(o)}return t.length?void n(C.iterator(t))():e()},C.parallel=function(t,e){S(C.eachOf,t,e)},C.parallelLimit=function(t,e,n){S(m(e),t,n)},C.series=function(t,e){S(C.eachOfSeries,t,e)},C.iterator=function(t){function e(n){function r(){return t.length&&t[n].apply(null,arguments),r.next()}return r.next=function(){return nr;){var i=r+(o-r+1>>>1);n(e,t[i])>=0?r=i:o=i-1}return r}function i(t,e,i,a){if(null!=a&&"function"!=typeof a)throw new Error("task callback must be a function");return t.started=!0,U(e)||(e=[e]),0===e.length?C.setImmediate(function(){t.drain()}):void f(e,function(e){var u={data:e,priority:i,callback:"function"==typeof a?a:r};t.tasks.splice(o(t.tasks,u,n)+1,0,u),t.tasks.length===t.concurrency&&t.saturated(),C.setImmediate(t.process)})}var a=C.queue(t,e);return a.push=function(t,e,n){i(a,t,e,n)},delete a.unshift,a},C.cargo=function(t,e){return D(t,1,e)},C.log=$("log"),C.dir=$("dir"),C.memoize=function(t,e){var n={},r={};e=e||o;var i=v(function(o){var i=o.pop(),a=e.apply(null,o);a in n?C.setImmediate(function(){i.apply(null,n[a])}):a in r?r[a].push(i):(r[a]=[i],t.apply(null,o.concat([v(function(t){n[a]=t;var e=r[a];delete r[a];for(var o=0,i=e.length;i>o;o++)e[o].apply(null,t)})])))});return i.memo=n,i.unmemoized=t,i},C.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},C.times=x(C.map),C.timesSeries=x(C.mapSeries),C.timesLimit=function(t,e,n,r){return C.mapLimit(d(t),e,n,r)},C.seq=function(){var t=arguments;return v(function(e){var n=this,o=e[e.length-1];"function"==typeof o?e.pop():o=r,C.reduce(t,e,function(t,e,r){e.apply(n,t.concat([v(function(t,e){r(t,e)})]))},function(t,e){o.apply(n,[t].concat(e))})})},C.compose=function(){return C.seq.apply(null,Array.prototype.reverse.call(arguments))},C.applyEach=T(C.eachOf),C.applyEachSeries=T(C.eachOfSeries),C.forever=function(t,e){function n(t){return t?o(t):void i(n)}var o=u(e||r),i=L(t);n()},C.ensureAsync=L,C.constant=v(function(t){var e=[null].concat(t);return function(t){return t.apply(this,e)}}),C.wrapSync=C.asyncify=function(t){return v(function(e){var n,r=e.pop();try{n=t.apply(this,e)}catch(o){return r(o)}N(n)&&"function"==typeof n.then?n.then(function(t){r(null,t)})["catch"](function(t){r(t.message?t:new Error(t))}):r(null,n)})},"object"==typeof e&&e.exports?e.exports=C:"function"==typeof define&&define.amd?define([],function(){return C}):M.async=C}()}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:49}],2:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a||e===l?62:e===u||e===d?63:c>e?-1:c+10>e?e-c+26+26:f+26>e?e-f:s+26>e?e-s+26:void 0}function n(t){function n(t){s[l++]=t}var r,o,a,u,c,s;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;c="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,s=new i(3*t.length/4-c),a=c>0?t.length-4:t.length;var l=0;for(r=0,o=0;a>r;r+=4,o+=3)u=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&u)>>16),n((65280&u)>>8),n(255&u);return 2===c?(u=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&u)):1===c&&(u=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(u>>8&255),n(255&u)),s}function o(t){function e(t){return r.charAt(t)}function n(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var o,i,a,u=t.length%3,c="";for(o=0,a=t.length-u;a>o;o+=3)i=(t[o]<<16)+(t[o+1]<<8)+t[o+2],c+=n(i);switch(u){case 1:i=t[t.length-1],c+=e(i>>2),c+=e(i<<4&63),c+="==";break;case 2:i=(t[t.length-2]<<8)+t[t.length-1],c+=e(i>>10),c+=e(i>>4&63),c+=e(i<<2&63),c+="="}return c}var i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),c="0".charCodeAt(0),s="a".charCodeAt(0),f="A".charCodeAt(0),l="-".charCodeAt(0),d="_".charCodeAt(0);t.toByteArray=n,t.fromByteArray=o}("undefined"==typeof n?this.base64js={}:n)},{}],3:[function(t,e,n){(function(e){function r(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(n){return!1}}function o(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(t){return this instanceof i?(this.length=0,this.parent=void 0,"number"==typeof t?a(this,t):"string"==typeof t?u(this,t,arguments.length>1?arguments[1]:"utf8"):c(this,t)):arguments.length>1?new i(t,arguments[1]):new i(t)}function a(t,e){if(t=y(t,0>e?0:0|g(e)),!i.TYPED_ARRAY_SUPPORT)for(var n=0;e>n;n++)t[n]=0;return t}function u(t,e,n){("string"!=typeof n||""===n)&&(n="utf8");var r=0|w(e,n);return t=y(t,r),t.write(e,n),t}function c(t,e){if(i.isBuffer(e))return s(t,e);if(K(e))return f(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return l(t,e);if(e instanceof ArrayBuffer)return d(t,e)}return e.length?p(t,e):h(t,e)}function s(t,e){var n=0|g(e.length);return t=y(t,n),e.copy(t,0,0,n),t}function f(t,e){var n=0|g(e.length);t=y(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function l(t,e){var n=0|g(e.length);t=y(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function d(t,e){return i.TYPED_ARRAY_SUPPORT?(e.byteLength,t=i._augment(new Uint8Array(e))):t=l(t,new Uint8Array(e)),t}function p(t,e){var n=0|g(e.length);t=y(t,n);for(var r=0;n>r;r+=1)t[r]=255&e[r];return t}function h(t,e){var n,r=0;"Buffer"===e.type&&K(e.data)&&(n=e.data,r=0|g(n.length)),t=y(t,r);for(var o=0;r>o;o+=1)t[o]=255&n[o];return t}function y(t,e){i.TYPED_ARRAY_SUPPORT?(t=i._augment(new Uint8Array(e)),t.__proto__=i.prototype):(t.length=e,t._isBuffer=!0);var n=0!==e&&e<=i.poolSize>>>1;return n&&(t.parent=Q),t}function g(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function v(t,e){if(!(this instanceof v))return new v(t,e);var n=new i(t,e);return delete n.parent,n}function w(t,e){"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":return F(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return H(t).length;default:if(r)return F(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=!1;if(e=0|e,n=void 0===n||n===1/0?this.length:0|n,t||(t="utf8"),0>e&&(e=0),n>this.length&&(n=this.length),e>=n)return"";for(;;)switch(t){case"hex":return $(this,e,n);case"utf8":case"utf-8":return P(this,e,n);case"ascii":return O(this,e,n);case"binary":return D(this,e,n);case"base64":return I(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;var i=e.length;if(i%2!==0)throw new Error("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;r>a;a++){var u=parseInt(e.substr(2*a,2),16);if(isNaN(u))throw new Error("Invalid hex string");t[n+a]=u}return a}function E(t,e,n,r){return J(F(e,t.length-n),t,n,r)}function _(t,e,n,r){return J(q(e),t,n,r)}function j(t,e,n,r){return _(t,e,n,r)}function A(t,e,n,r){return J(H(e),t,n,r)}function k(t,e,n,r){return J(z(e,t.length-n),t,n,r)}function I(t,e,n){return 0===e&&n===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,n))}function P(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;n>o;){var i=t[o],a=null,u=i>239?4:i>223?3:i>191?2:1;if(n>=o+u){var c,s,f,l;switch(u){case 1:128>i&&(a=i);break;case 2:c=t[o+1],128===(192&c)&&(l=(31&i)<<6|63&c,l>127&&(a=l));break;case 3:c=t[o+1],s=t[o+2],128===(192&c)&&128===(192&s)&&(l=(15&i)<<12|(63&c)<<6|63&s,l>2047&&(55296>l||l>57343)&&(a=l));break;case 4:c=t[o+1],s=t[o+2],f=t[o+3],128===(192&c)&&128===(192&s)&&128===(192&f)&&(l=(15&i)<<18|(63&c)<<12|(63&s)<<6|63&f,l>65535&&1114112>l&&(a=l))}}null===a?(a=65533,u=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),o+=u}return S(r)}function S(t){var e=t.length;if(Z>=e)return String.fromCharCode.apply(String,t);for(var n="",r=0;e>r;)n+=String.fromCharCode.apply(String,t.slice(r,r+=Z));return n}function O(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;o++)r+=String.fromCharCode(127&t[o]);return r}function D(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;n>o;o++)r+=String.fromCharCode(t[o]);return r}function $(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var o="",i=e;n>i;i++)o+=V(t[i]);return o}function x(t,e,n){for(var r=t.slice(e,n),o="",i=0;it)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,r,o,a){if(!i.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||a>e)throw new RangeError("value is out of bounds");if(n+r>t.length)throw new RangeError("index out of range")}function R(t,e,n,r){0>e&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-n,2);i>o;o++)t[n+o]=(e&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function C(t,e,n,r){0>e&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-n,4);i>o;o++)t[n+o]=e>>>8*(r?o:3-o)&255}function M(t,e,n,r,o,i){if(e>o||i>e)throw new RangeError("value is out of bounds");if(n+r>t.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function B(t,e,n,r,o){return o||M(t,e,n,4,3.4028234663852886e38,-3.4028234663852886e38),G.write(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return o||M(t,e,n,8,1.7976931348623157e308,-1.7976931348623157e308),G.write(t,e,n,r,52,8),n+8}function N(t){if(t=Y(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function Y(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function V(t){return 16>t?"0"+t.toString(16):t.toString(16)}function F(t,e){e=e||1/0;for(var n,r=t.length,o=null,i=[],a=0;r>a;a++){if(n=t.charCodeAt(a),n>55295&&57344>n){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(56320>n){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,128>n){if((e-=1)<0)break;i.push(n)}else if(2048>n){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(65536>n){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function q(t){for(var e=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function H(t){return W.toByteArray(N(t))}function J(t,e,n,r){for(var o=0;r>o&&!(o+n>=e.length||o>=t.length);o++)e[o+n]=t[o];return o}var W=t("base64-js"),G=t("ieee754"),K=t("is-array");n.Buffer=i,n.SlowBuffer=v,n.INSPECT_MAX_BYTES=50,i.poolSize=8192;var Q={};i.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:r(),i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array),i.isBuffer=function(t){return!(null==t||!t._isBuffer)},i.compare=function(t,e){if(!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,o=0,a=Math.min(n,r);a>o&&t[o]===e[o];)++o;return o!==a&&(n=t[o],r=e[o]),r>n?-1:n>r?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!K(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new i(0);var n;if(void 0===e)for(e=0,n=0;n0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),""},i.prototype.compare=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:i.compare(this,t)},i.prototype.indexOf=function(t,e){function n(t,e,n){for(var r=-1,o=0;n+o2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(i.isBuffer(t))return n(this,t,e);if("number"==typeof t)return i.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):n(this,[t],e);throw new TypeError("val must be string, number or Buffer")},i.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},i.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0);else{var o=r;r=e,e=0|n,n=o}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(0>n||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return b(this,t,e,n);case"utf8":case"utf-8":return E(this,t,e,n);case"ascii":return _(this,t,e,n);case"binary":return j(this,t,e,n);case"base64":return A(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;i.prototype.slice=function(t,e){var n=this.length;t=~~t,e=void 0===e?n:~~e,0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),t>e&&(e=t);var r;if(i.TYPED_ARRAY_SUPPORT)r=i._augment(this.subarray(t,e));else{var o=e-t;r=new i(o,void 0);for(var a=0;o>a;a++)r[a]=this[a+t]}return r.length&&(r.parent=this.parent||this),r},i.prototype.readUIntLE=function(t,e,n){t=0|t,e=0|e,n||T(t,e,this.length);for(var r=this[t],o=1,i=0;++i0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t=0|t,e=0|e,n||T(t,e,this.length);for(var r=this[t],o=1,i=0;++i=o&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t=0|t,e=0|e,n||T(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),G.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),G.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),G.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),G.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e=0|e,n=0|n,r||L(this,t,e,n,Math.pow(2,8*n),0);var o=1,i=0;for(this[e]=255&t;++i=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUInt8=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,1,255,0),i.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):C(this,t,e,!0),e+4},i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):C(this,t,e,!1),e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);L(this,t,e,n,o-1,-o)}var i=0,a=1,u=0>t?1:0;for(this[e]=255&t;++i>0)-u&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e=0|e,!r){var o=Math.pow(2,8*n-1);L(this,t,e,n,o-1,-o)}var i=n-1,a=1,u=0>t?1:0;for(this[e+i]=255&t;--i>=0&&(a*=256);)this[e+i]=(t/a>>0)-u&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,1,127,-128),i.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):R(this,t,e,!0),e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):R(this,t,e,!1),e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):C(this,t,e,!0),e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e=0|e,n||L(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):C(this,t,e,!1),e+4},i.prototype.writeFloatLE=function(t,e,n){return B(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return B(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-en&&r>e)for(o=a-1;o>=0;o--)t[o+e]=this[o+n];else if(1e3>a||!i.TYPED_ARRAY_SUPPORT)for(o=0;a>o;o++)t[o+e]=this[o+n];else t._set(this.subarray(n,n+a),e);return a},i.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),e>n)throw new RangeError("end < start");if(n!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var o=F(t.toString()),i=o.length;for(r=e;n>r;r++)this[r]=o[r%i]}return this}},i.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(i.TYPED_ARRAY_SUPPORT)return new i(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var X=i.prototype;i._augment=function(t){return t.constructor=i,t._isBuffer=!0,t._set=t.set,t.get=X.get,t.set=X.set,t.write=X.write,t.toString=X.toString,t.toLocaleString=X.toString,t.toJSON=X.toJSON,t.equals=X.equals,t.compare=X.compare,t.indexOf=X.indexOf,t.copy=X.copy,t.slice=X.slice,t.readUIntLE=X.readUIntLE,t.readUIntBE=X.readUIntBE,t.readUInt8=X.readUInt8,t.readUInt16LE=X.readUInt16LE,t.readUInt16BE=X.readUInt16BE,t.readUInt32LE=X.readUInt32LE,t.readUInt32BE=X.readUInt32BE,t.readIntLE=X.readIntLE,t.readIntBE=X.readIntBE, -t.readInt8=X.readInt8,t.readInt16LE=X.readInt16LE,t.readInt16BE=X.readInt16BE,t.readInt32LE=X.readInt32LE,t.readInt32BE=X.readInt32BE,t.readFloatLE=X.readFloatLE,t.readFloatBE=X.readFloatBE,t.readDoubleLE=X.readDoubleLE,t.readDoubleBE=X.readDoubleBE,t.writeUInt8=X.writeUInt8,t.writeUIntLE=X.writeUIntLE,t.writeUIntBE=X.writeUIntBE,t.writeUInt16LE=X.writeUInt16LE,t.writeUInt16BE=X.writeUInt16BE,t.writeUInt32LE=X.writeUInt32LE,t.writeUInt32BE=X.writeUInt32BE,t.writeIntLE=X.writeIntLE,t.writeIntBE=X.writeIntBE,t.writeInt8=X.writeInt8,t.writeInt16LE=X.writeInt16LE,t.writeInt16BE=X.writeInt16BE,t.writeInt32LE=X.writeInt32LE,t.writeInt32BE=X.writeInt32BE,t.writeFloatLE=X.writeFloatLE,t.writeFloatBE=X.writeFloatBE,t.writeDoubleLE=X.writeDoubleLE,t.writeDoubleBE=X.writeDoubleBE,t.fill=X.fill,t.inspect=X.inspect,t.toArrayBuffer=X.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":2,ieee754:46,"is-array":47}],4:[function(t,e,n){function r(t){switch(o(t)){case"object":var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=r(t[n]));return e;case"array":for(var e=new Array(t.length),i=0,a=t.length;a>i;i++)e[i]=r(t[i]);return e;case"regexp":var u="";return u+=t.multiline?"m":"",u+=t.global?"g":"",u+=t.ignoreCase?"i":"",new RegExp(t.source,u);case"date":return new Date(t.getTime());default:return t}}var o;try{o=t("component-type")}catch(i){o=t("type")}e.exports=r},{"component-type":6,type:6}],5:[function(t,e,n){function r(t){return t?o(t):void 0}function o(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}e.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){r.off(t,n),e.apply(this,arguments)}var r=this;return this._callbacks=this._callbacks||{},n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var r,o=0;or;++r)n[r].apply(this,e)}return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},{}],6:[function(t,e,n){(function(t){var n=Object.prototype.toString;e.exports=function(e){switch(n.call(e)){case"[object Date]":return"date";case"[object RegExp]":return"regexp";case"[object Arguments]":return"arguments";case"[object Array]":return"array";case"[object Error]":return"error"}return null===e?"null":void 0===e?"undefined":e!==e?"nan":e&&1===e.nodeType?"element":"undefined"!=typeof t&&t.isBuffer(e)?"buffer":(e=e.valueOf?e.valueOf():Object.prototype.valueOf.apply(e),typeof e)}}).call(this,t("buffer").Buffer)},{buffer:3}],7:[function(t,e,n){e.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},{}],8:[function(t,e,n){var r=t("./$.is-object");e.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},{"./$.is-object":27}],9:[function(t,e,n){var r=t("./$.to-iobject"),o=t("./$.to-length"),i=t("./$.to-index");e.exports=function(t){return function(e,n,a){var u,c=r(e),s=o(c.length),f=i(a,s);if(t&&n!=n){for(;s>f;)if(u=c[f++],u!=u)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===n)return t||f;return!t&&-1}}},{"./$.to-index":34,"./$.to-iobject":36,"./$.to-length":37}],10:[function(t,e,n){var r=t("./$.ctx"),o=t("./$.iobject"),i=t("./$.to-object"),a=t("./$.to-length"),u=t("./$.array-species-create");e.exports=function(t){var e=1==t,n=2==t,c=3==t,s=4==t,f=6==t,l=5==t||f;return function(d,p,h){for(var y,g,v=i(d),w=o(v),m=r(p,h,3),b=a(w.length),E=0,_=e?u(d,b):n?u(d,0):void 0;b>E;E++)if((l||E in w)&&(y=w[E],g=m(y,E,v),t))if(e)_[E]=g;else if(g)switch(t){case 3:return!0;case 5:return y;case 6:return E;case 2:_.push(y)}else if(s)return!1;return f?-1:c||s?s:_}}},{"./$.array-species-create":11,"./$.ctx":14,"./$.iobject":25,"./$.to-length":37,"./$.to-object":38}],11:[function(t,e,n){var r=t("./$.is-object"),o=t("./$.is-array"),i=t("./$.wks")("species");e.exports=function(t,e){var n;return o(t)&&(n=t.constructor,"function"!=typeof n||n!==Array&&!o(n.prototype)||(n=void 0),r(n)&&(n=n[i],null===n&&(n=void 0))),new(void 0===n?Array:n)(e)}},{"./$.is-array":26,"./$.is-object":27,"./$.wks":40}],12:[function(t,e,n){var r={}.toString;e.exports=function(t){return r.call(t).slice(8,-1)}},{}],13:[function(t,e,n){var r=e.exports={version:"1.2.6"};"number"==typeof __e&&(__e=r)},{}],14:[function(t,e,n){var r=t("./$.a-function");e.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}}},{"./$.a-function":7}],15:[function(t,e,n){e.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},{}],16:[function(t,e,n){e.exports=!t("./$.fails")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{"./$.fails":19}],17:[function(t,e,n){var r=t("./$.is-object"),o=t("./$.global").document,i=r(o)&&r(o.createElement);e.exports=function(t){return i?o.createElement(t):{}}},{"./$.global":20,"./$.is-object":27}],18:[function(t,e,n){var r=t("./$.global"),o=t("./$.core"),i=t("./$.hide"),a=t("./$.redefine"),u=t("./$.ctx"),c="prototype",s=function(t,e,n){var f,l,d,p,h=t&s.F,y=t&s.G,g=t&s.S,v=t&s.P,w=t&s.B,m=y?r:g?r[e]||(r[e]={}):(r[e]||{})[c],b=y?o:o[e]||(o[e]={}),E=b[c]||(b[c]={});y&&(n=e);for(f in n)l=!h&&m&&f in m,d=(l?m:n)[f],p=w&&l?u(d,r):v&&"function"==typeof d?u(Function.call,d):d,m&&!l&&a(m,f,d),b[f]!=d&&i(b,f,p),v&&E[f]!=d&&(E[f]=d)};r.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,e.exports=s},{"./$.core":13,"./$.ctx":14,"./$.global":20,"./$.hide":22,"./$.redefine":31}],19:[function(t,e,n){e.exports=function(t){try{return!!t()}catch(e){return!0}}},{}],20:[function(t,e,n){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},{}],21:[function(t,e,n){var r={}.hasOwnProperty;e.exports=function(t,e){return r.call(t,e)}},{}],22:[function(t,e,n){var r=t("./$"),o=t("./$.property-desc");e.exports=t("./$.descriptors")?function(t,e,n){return r.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},{"./$":28,"./$.descriptors":16,"./$.property-desc":30}],23:[function(t,e,n){e.exports=t("./$.global").document&&document.documentElement},{"./$.global":20}],24:[function(t,e,n){e.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},{}],25:[function(t,e,n){var r=t("./$.cof");e.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},{"./$.cof":12}],26:[function(t,e,n){var r=t("./$.cof");e.exports=Array.isArray||function(t){return"Array"==r(t)}},{"./$.cof":12}],27:[function(t,e,n){e.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},{}],28:[function(t,e,n){var r=Object;e.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},{}],29:[function(t,e,n){var r=t("./$"),o=t("./$.to-object"),i=t("./$.iobject");e.exports=t("./$.fails")(function(){var t=Object.assign,e={},n={},r=Symbol(),o="abcdefghijklmnopqrst";return e[r]=7,o.split("").forEach(function(t){n[t]=t}),7!=t({},e)[r]||Object.keys(t({},n)).join("")!=o})?function(t,e){for(var n=o(t),a=arguments,u=a.length,c=1,s=r.getKeys,f=r.getSymbols,l=r.isEnum;u>c;)for(var d,p=i(a[c++]),h=f?s(p).concat(f(p)):s(p),y=h.length,g=0;y>g;)l.call(p,d=h[g++])&&(n[d]=p[d]);return n}:Object.assign},{"./$":28,"./$.fails":19,"./$.iobject":25,"./$.to-object":38}],30:[function(t,e,n){e.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},{}],31:[function(t,e,n){var r=t("./$.global"),o=t("./$.hide"),i=t("./$.uid")("src"),a="toString",u=Function[a],c=(""+u).split(a);t("./$.core").inspectSource=function(t){return u.call(t)},(e.exports=function(t,e,n,a){"function"==typeof n&&(n.hasOwnProperty(i)||o(n,i,t[e]?""+t[e]:c.join(String(e))),n.hasOwnProperty("name")||o(n,"name",e)),t===r?t[e]=n:(a||delete t[e],o(t,e,n))})(Function.prototype,a,function(){return"function"==typeof this&&this[i]||u.call(this)})},{"./$.core":13,"./$.global":20,"./$.hide":22,"./$.uid":39}],32:[function(t,e,n){var r=t("./$.global"),o="__core-js_shared__",i=r[o]||(r[o]={});e.exports=function(t){return i[t]||(i[t]={})}},{"./$.global":20}],33:[function(t,e,n){var r=t("./$.export"),o=t("./$.defined"),i=t("./$.fails"),a=" \n\x0B\f\r   ᠎              \u2028\u2029\ufeff",u="["+a+"]",c="​…",s=RegExp("^"+u+u+"*"),f=RegExp(u+u+"*$"),l=function(t,e){var n={};n[t]=e(d),r(r.P+r.F*i(function(){return!!a[t]()||c[t]()!=c}),"String",n)},d=l.trim=function(t,e){return t=String(o(t)),1&e&&(t=t.replace(s,"")),2&e&&(t=t.replace(f,"")),t};e.exports=l},{"./$.defined":15,"./$.export":18,"./$.fails":19}],34:[function(t,e,n){var r=t("./$.to-integer"),o=Math.max,i=Math.min;e.exports=function(t,e){return t=r(t),0>t?o(t+e,0):i(t,e)}},{"./$.to-integer":35}],35:[function(t,e,n){var r=Math.ceil,o=Math.floor;e.exports=function(t){return isNaN(t=+t)?0:(t>0?o:r)(t)}},{}],36:[function(t,e,n){var r=t("./$.iobject"),o=t("./$.defined");e.exports=function(t){return r(o(t))}},{"./$.defined":15,"./$.iobject":25}],37:[function(t,e,n){var r=t("./$.to-integer"),o=Math.min;e.exports=function(t){return t>0?o(r(t),9007199254740991):0}},{"./$.to-integer":35}],38:[function(t,e,n){var r=t("./$.defined");e.exports=function(t){return Object(r(t))}},{"./$.defined":15}],39:[function(t,e,n){var r=0,o=Math.random();e.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+o).toString(36))}},{}],40:[function(t,e,n){var r=t("./$.shared")("wks"),o=t("./$.uid"),i=t("./$.global").Symbol;e.exports=function(t){return r[t]||(r[t]=i&&i[t]||(i||o)("Symbol."+t))}},{"./$.global":20,"./$.shared":32,"./$.uid":39}],41:[function(t,e,n){"use strict";var r,o=t("./$"),i=t("./$.export"),a=t("./$.descriptors"),u=t("./$.property-desc"),c=t("./$.html"),s=t("./$.dom-create"),f=t("./$.has"),l=t("./$.cof"),d=t("./$.invoke"),p=t("./$.fails"),h=t("./$.an-object"),y=t("./$.a-function"),g=t("./$.is-object"),v=t("./$.to-object"),w=t("./$.to-iobject"),m=t("./$.to-integer"),b=t("./$.to-index"),E=t("./$.to-length"),_=t("./$.iobject"),j=t("./$.uid")("__proto__"),A=t("./$.array-methods"),k=t("./$.array-includes")(!1),I=Object.prototype,P=Array.prototype,S=P.slice,O=P.join,D=o.setDesc,$=o.getDesc,x=o.setDescs,T={};a||(r=!p(function(){return 7!=D(s("div"),"a",{get:function(){return 7}}).a}),o.setDesc=function(t,e,n){if(r)try{return D(t,e,n)}catch(o){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(h(t)[e]=n.value),t},o.getDesc=function(t,e){if(r)try{return $(t,e)}catch(n){}return f(t,e)?u(!I.propertyIsEnumerable.call(t,e),t[e]):void 0},o.setDescs=x=function(t,e){h(t);for(var n,r=o.getKeys(e),i=r.length,a=0;i>a;)o.setDesc(t,n=r[a++],e[n]);return t}),i(i.S+i.F*!a,"Object",{getOwnPropertyDescriptor:o.getDesc,defineProperty:o.setDesc,defineProperties:x});var L="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),R=L.concat("length","prototype"),C=L.length,M=function(){var t,e=s("iframe"),n=C,r=">";for(e.style.display="none",c.appendChild(e),e.src="javascript:",t=e.contentWindow.document,t.open(),t.write("