stream-engine-player 0.0.11 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -5657,7 +5657,7 @@
5657
5657
  }
5658
5658
  return _this;
5659
5659
  }
5660
- TimelineController2.prototype.addCues = function(trackName, startTime2, endTime, screen) {
5660
+ TimelineController2.prototype.addCues = function(trackName, startTime2, endTime, screen2) {
5661
5661
  var ranges = this.cueRanges;
5662
5662
  var merged = false;
5663
5663
  for (var i2 = ranges.length; i2--; ) {
@@ -5675,7 +5675,7 @@
5675
5675
  if (!merged) {
5676
5676
  ranges.push([startTime2, endTime]);
5677
5677
  }
5678
- this.Cues.newCue(this.captionsTracks[trackName], startTime2, endTime, screen);
5678
+ this.Cues.newCue(this.captionsTracks[trackName], startTime2, endTime, screen2);
5679
5679
  };
5680
5680
  TimelineController2.prototype.onInitPtsFound = function(data) {
5681
5681
  var _this = this;
@@ -6318,7 +6318,7 @@
6318
6318
  var errors_1 = __webpack_require__("./src/errors.js");
6319
6319
  var events_1 = __webpack_require__("./src/events.js");
6320
6320
  function getAudioConfig(observer, data, offset, audioCodec) {
6321
- var adtsObjectType, adtsSampleingIndex, adtsExtensionSampleingIndex, adtsChanelConfig, config, userAgent = navigator.userAgent.toLowerCase(), manifestCodec = audioCodec, adtsSampleingRates = [
6321
+ var adtsObjectType, adtsSampleingIndex, adtsExtensionSampleingIndex, adtsChanelConfig, config, userAgent2 = navigator.userAgent.toLowerCase(), manifestCodec = audioCodec, adtsSampleingRates = [
6322
6322
  96e3,
6323
6323
  88200,
6324
6324
  64e3,
@@ -6342,7 +6342,7 @@
6342
6342
  adtsChanelConfig = (data[offset + 2] & 1) << 2;
6343
6343
  adtsChanelConfig |= (data[offset + 3] & 192) >>> 6;
6344
6344
  logger_1.logger.log("manifest codec:" + audioCodec + ",ADTS data:type:" + adtsObjectType + ",sampleingIndex:" + adtsSampleingIndex + "[" + adtsSampleingRates[adtsSampleingIndex] + "Hz],channelConfig:" + adtsChanelConfig);
6345
- if (/firefox/i.test(userAgent)) {
6345
+ if (/firefox/i.test(userAgent2)) {
6346
6346
  if (adtsSampleingIndex >= 6) {
6347
6347
  adtsObjectType = 5;
6348
6348
  config = new Array(4);
@@ -6352,7 +6352,7 @@
6352
6352
  config = new Array(2);
6353
6353
  adtsExtensionSampleingIndex = adtsSampleingIndex;
6354
6354
  }
6355
- } else if (userAgent.indexOf("android") !== -1) {
6355
+ } else if (userAgent2.indexOf("android") !== -1) {
6356
6356
  adtsObjectType = 2;
6357
6357
  config = new Array(2);
6358
6358
  adtsExtensionSampleingIndex = adtsSampleingIndex;
@@ -6362,7 +6362,7 @@
6362
6362
  if (audioCodec && (audioCodec.indexOf("mp4a.40.29") !== -1 || audioCodec.indexOf("mp4a.40.5") !== -1) || !audioCodec && adtsSampleingIndex >= 6) {
6363
6363
  adtsExtensionSampleingIndex = adtsSampleingIndex - 3;
6364
6364
  } else {
6365
- if (audioCodec && audioCodec.indexOf("mp4a.40.2") !== -1 && (adtsSampleingIndex >= 6 && adtsChanelConfig === 1 || /vivaldi/i.test(userAgent)) || !audioCodec && adtsChanelConfig === 1) {
6365
+ if (audioCodec && audioCodec.indexOf("mp4a.40.2") !== -1 && (adtsSampleingIndex >= 6 && adtsChanelConfig === 1 || /vivaldi/i.test(userAgent2)) || !audioCodec && adtsChanelConfig === 1) {
6366
6366
  adtsObjectType = 2;
6367
6367
  config = new Array(2);
6368
6368
  }
@@ -11265,8 +11265,8 @@
11265
11265
  this.observer = observer;
11266
11266
  this.config = config;
11267
11267
  this.typeSupported = typeSupported;
11268
- var userAgent = navigator.userAgent;
11269
- this.isSafari = vendor && vendor.indexOf("Apple") > -1 && userAgent && !userAgent.match("CriOS");
11268
+ var userAgent2 = navigator.userAgent;
11269
+ this.isSafari = vendor && vendor.indexOf("Apple") > -1 && userAgent2 && !userAgent2.match("CriOS");
11270
11270
  this.ISGenerated = false;
11271
11271
  }
11272
11272
  MP4Remuxer2.prototype.destroy = function() {
@@ -12617,8 +12617,8 @@
12617
12617
  for (var i2 = 0; i2 < chars.length; i2++) {
12618
12618
  this.writeScreen.insertChar(chars[i2]);
12619
12619
  }
12620
- var screen = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP";
12621
- logger2.log("INFO", screen + ": " + this.writeScreen.getDisplayText(true));
12620
+ var screen2 = this.writeScreen === this.displayedMemory ? "DISP" : "NON_DISP";
12621
+ logger2.log("INFO", screen2 + ": " + this.writeScreen.getDisplayText(true));
12622
12622
  if (this.mode === "MODE_PAINT-ON" || this.mode === "MODE_ROLL-UP") {
12623
12623
  logger2.log("TEXT", "DISPLAYED: " + this.displayedMemory.getDisplayText(true));
12624
12624
  this.outputDataUpdate();
@@ -13415,12 +13415,12 @@
13415
13415
  this.timelineController.addCues(this.trackName, this.startTime, this.endTime, this.screen);
13416
13416
  this.startTime = null;
13417
13417
  };
13418
- OutputFilter2.prototype.newCue = function(startTime2, endTime, screen) {
13418
+ OutputFilter2.prototype.newCue = function(startTime2, endTime, screen2) {
13419
13419
  if (this.startTime === null || this.startTime > startTime2) {
13420
13420
  this.startTime = startTime2;
13421
13421
  }
13422
13422
  this.endTime = endTime;
13423
- this.screen = screen;
13423
+ this.screen = screen2;
13424
13424
  this.timelineController.createCaptionsTrack(this.trackName);
13425
13425
  };
13426
13426
  return OutputFilter2;
@@ -14282,17 +14282,17 @@
14282
14282
  });
14283
14283
  })(hls);
14284
14284
  const Hls$2 = /* @__PURE__ */ getDefaultExportFromCjs(hls.exports);
14285
- var win$2;
14285
+ var win$3;
14286
14286
  if (typeof window !== "undefined") {
14287
- win$2 = window;
14287
+ win$3 = window;
14288
14288
  } else if (typeof commonjsGlobal !== "undefined") {
14289
- win$2 = commonjsGlobal;
14289
+ win$3 = commonjsGlobal;
14290
14290
  } else if (typeof self !== "undefined") {
14291
- win$2 = self;
14291
+ win$3 = self;
14292
14292
  } else {
14293
- win$2 = {};
14293
+ win$3 = {};
14294
14294
  }
14295
- var window_1$1 = win$2;
14295
+ var window_1$1 = win$3;
14296
14296
  const __viteBrowserExternal = {};
14297
14297
  const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14298
14298
  __proto__: null,
@@ -14452,12 +14452,12 @@
14452
14452
  })(keycode$1, keycode$1.exports);
14453
14453
  const keycode = keycode$1.exports;
14454
14454
  var isFunction_1 = isFunction$1;
14455
- var toString$1 = Object.prototype.toString;
14455
+ var toString$2 = Object.prototype.toString;
14456
14456
  function isFunction$1(fn) {
14457
14457
  if (!fn) {
14458
14458
  return false;
14459
14459
  }
14460
- var string = toString$1.call(fn);
14460
+ var string = toString$2.call(fn);
14461
14461
  return string === "[object Function]" || typeof fn === "function" && string !== "[object RegExp]" || typeof window !== "undefined" && (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt);
14462
14462
  }
14463
14463
  var trim = function(string) {
@@ -14484,13 +14484,13 @@
14484
14484
  return result;
14485
14485
  };
14486
14486
  var immutable = extend$1;
14487
- var hasOwnProperty = Object.prototype.hasOwnProperty;
14487
+ var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
14488
14488
  function extend$1() {
14489
14489
  var target = {};
14490
14490
  for (var i2 = 0; i2 < arguments.length; i2++) {
14491
14491
  var source = arguments[i2];
14492
14492
  for (var key in source) {
14493
- if (hasOwnProperty.call(source, key)) {
14493
+ if (hasOwnProperty$1.call(source, key)) {
14494
14494
  target[key] = source[key];
14495
14495
  }
14496
14496
  }
@@ -16246,17 +16246,17 @@
16246
16246
  };
16247
16247
  return _extends.apply(this, arguments);
16248
16248
  }
16249
- var win$1;
16249
+ var win$2;
16250
16250
  if (typeof window !== "undefined") {
16251
- win$1 = window;
16251
+ win$2 = window;
16252
16252
  } else if (typeof commonjsGlobal !== "undefined") {
16253
- win$1 = commonjsGlobal;
16253
+ win$2 = commonjsGlobal;
16254
16254
  } else if (typeof self !== "undefined") {
16255
- win$1 = self;
16255
+ win$2 = self;
16256
16256
  } else {
16257
- win$1 = {};
16257
+ win$2 = {};
16258
16258
  }
16259
- var window_1 = win$1;
16259
+ var window_1 = win$2;
16260
16260
  var atob$1 = function atob2(s) {
16261
16261
  return window_1.atob ? window_1.atob(s) : Buffer.from(s, "base64").toString("binary");
16262
16262
  };
@@ -21391,7 +21391,7 @@
21391
21391
  }
21392
21392
  var log = createLogger("VIDEOJS");
21393
21393
  var createLogger$1 = log.createLogger;
21394
- var toString = Object.prototype.toString;
21394
+ var toString$1 = Object.prototype.toString;
21395
21395
  var keys = function keys2(object) {
21396
21396
  return isObject(object) ? Object.keys(object) : [];
21397
21397
  };
@@ -21429,7 +21429,7 @@
21429
21429
  return !!value && typeof value === "object";
21430
21430
  }
21431
21431
  function isPlain(value) {
21432
- return isObject(value) && toString.call(value) === "[object Object]" && value.constructor === Object;
21432
+ return isObject(value) && toString$1.call(value) === "[object Object]" && value.constructor === Object;
21433
21433
  }
21434
21434
  function computedStyle(el, prop) {
21435
21435
  if (!el || !prop) {
@@ -29309,8 +29309,8 @@
29309
29309
  };
29310
29310
  _proto.supportsFullScreen = function supportsFullScreen() {
29311
29311
  if (typeof this.el_.webkitEnterFullScreen === "function") {
29312
- var userAgent = window_1$1.navigator && window_1$1.navigator.userAgent || "";
29313
- if (/Android/.test(userAgent) || !/Chrome|Mac OS X 10.5/.test(userAgent)) {
29312
+ var userAgent2 = window_1$1.navigator && window_1$1.navigator.userAgent || "";
29313
+ if (/Android/.test(userAgent2) || !/Chrome|Mac OS X 10.5/.test(userAgent2)) {
29314
29314
  return true;
29315
29315
  }
29316
29316
  }
@@ -31592,7 +31592,7 @@
31592
31592
  };
31593
31593
  });
31594
31594
  Player.players = {};
31595
- var navigator$1 = window_1$1.navigator;
31595
+ var navigator$2 = window_1$1.navigator;
31596
31596
  Player.prototype.options_ = {
31597
31597
  techOrder: Tech.defaultTechOrder_,
31598
31598
  html5: {},
@@ -31601,7 +31601,7 @@
31601
31601
  playbackRates: [],
31602
31602
  liveui: false,
31603
31603
  children: ["mediaLoader", "posterImage", "textTrackDisplay", "loadingSpinner", "bigPlayButton", "liveTracker", "controlBar", "errorDisplay", "textTrackSettings", "resizeManager"],
31604
- language: navigator$1 && (navigator$1.languages && navigator$1.languages[0] || navigator$1.userLanguage || navigator$1.language) || "en",
31604
+ language: navigator$2 && (navigator$2.languages && navigator$2.languages[0] || navigator$2.userLanguage || navigator$2.language) || "en",
31605
31605
  languages: {},
31606
31606
  notSupportedMessage: "No compatible source was found for this media.",
31607
31607
  fullscreen: {
@@ -33313,7 +33313,7 @@
33313
33313
  }
33314
33314
  }
33315
33315
  };
33316
- var win = typeof window !== "undefined" ? window : {}, TARGET = typeof Symbol === "undefined" ? "__target" : Symbol(), SCRIPT_TYPE = "application/javascript", BlobBuilder$1 = win.BlobBuilder || win.WebKitBlobBuilder || win.MozBlobBuilder || win.MSBlobBuilder, URL = win.URL || win.webkitURL || URL && URL.msURL, Worker$1 = win.Worker;
33316
+ var win$1 = typeof window !== "undefined" ? window : {}, TARGET = typeof Symbol === "undefined" ? "__target" : Symbol(), SCRIPT_TYPE = "application/javascript", BlobBuilder$1 = win$1.BlobBuilder || win$1.WebKitBlobBuilder || win$1.MozBlobBuilder || win$1.MSBlobBuilder, URL$1 = win$1.URL || win$1.webkitURL || URL$1 && URL$1.msURL, Worker$1 = win$1.Worker;
33317
33317
  function shimWorker(filename, fn) {
33318
33318
  return function ShimWorker(forceFallback) {
33319
33319
  var o = this;
@@ -33358,7 +33358,7 @@
33358
33358
  } catch (e) {
33359
33359
  Worker$1 = null;
33360
33360
  } finally {
33361
- URL.revokeObjectURL(objURL);
33361
+ URL$1.revokeObjectURL(objURL);
33362
33362
  if (testWorker) {
33363
33363
  testWorker.terminate();
33364
33364
  }
@@ -33366,13 +33366,13 @@
33366
33366
  }
33367
33367
  function createSourceObject(str) {
33368
33368
  try {
33369
- return URL.createObjectURL(new Blob([str], {
33369
+ return URL$1.createObjectURL(new Blob([str], {
33370
33370
  type: SCRIPT_TYPE
33371
33371
  }));
33372
33372
  } catch (e) {
33373
33373
  var blob = new BlobBuilder$1();
33374
33374
  blob.append(str);
33375
- return URL.createObjectURL(blob.getBlob(type));
33375
+ return URL$1.createObjectURL(blob.getBlob(type));
33376
33376
  }
33377
33377
  }
33378
33378
  function wrapTerminate(worker, objURL2) {
@@ -33382,7 +33382,7 @@
33382
33382
  worker.objURL = objURL2;
33383
33383
  worker.terminate = function() {
33384
33384
  if (worker.objURL)
33385
- URL.revokeObjectURL(worker.objURL);
33385
+ URL$1.revokeObjectURL(worker.objURL);
33386
33386
  term.call(worker);
33387
33387
  };
33388
33388
  }
@@ -38162,7 +38162,7 @@
38162
38162
  };
38163
38163
  MediaSource.open = open;
38164
38164
  MediaSource.supportsNativeMediaSources = supportsNativeMediaSources;
38165
- var URL$1 = {
38165
+ var URL$1$1 = {
38166
38166
  createObjectURL: function createObjectURL(object) {
38167
38167
  var objectUrlPrefix = "blob:vjs-media-source/";
38168
38168
  var url = void 0;
@@ -38183,7 +38183,7 @@
38183
38183
  }
38184
38184
  };
38185
38185
  videojs$1.MediaSource = MediaSource;
38186
- videojs$1.URL = URL$1;
38186
+ videojs$1.URL = URL$1$1;
38187
38187
  var EventTarget$1$1 = videojs$1.EventTarget, mergeOptions$2 = videojs$1.mergeOptions;
38188
38188
  var updateMaster$1 = function updateMaster$$1(oldMaster, newMaster) {
38189
38189
  var noChanges = void 0;
@@ -38690,7 +38690,7 @@
38690
38690
  }]);
38691
38691
  return DashPlaylistLoader2;
38692
38692
  }(EventTarget$1$1);
38693
- var logger = function logger2(source) {
38693
+ var logger$3 = function logger2(source) {
38694
38694
  if (videojs$1.log.debug) {
38695
38695
  return videojs$1.log.debug.bind(videojs$1, "VHS:", source + " >");
38696
38696
  }
@@ -38709,7 +38709,7 @@
38709
38709
  this.processedAppend_ = false;
38710
38710
  this.type_ = type2;
38711
38711
  this.mimeType_ = mimeType;
38712
- this.logger_ = logger("SourceUpdater[" + type2 + "][" + mimeType + "]");
38712
+ this.logger_ = logger$3("SourceUpdater[" + type2 + "][" + mimeType + "]");
38713
38713
  if (mediaSource.readyState === "closed") {
38714
38714
  mediaSource.addEventListener("sourceopen", this.createSourceBuffer_.bind(this, mimeType, sourceBufferEmitter));
38715
38715
  } else {
@@ -38853,7 +38853,7 @@
38853
38853
  }]);
38854
38854
  return SourceUpdater2;
38855
38855
  }();
38856
- var Config = {
38856
+ var Config$1 = {
38857
38857
  GOAL_BUFFER_LENGTH: 30,
38858
38858
  MAX_GOAL_BUFFER_LENGTH: 60,
38859
38859
  GOAL_BUFFER_LENGTH_RATE: 1,
@@ -39168,7 +39168,7 @@
39168
39168
  });
39169
39169
  }
39170
39170
  var bandwidthPlaylistReps = enabledPlaylistReps.filter(function(rep) {
39171
- return rep.bandwidth * Config.BANDWIDTH_VARIANCE < playerBandwidth;
39171
+ return rep.bandwidth * Config$1.BANDWIDTH_VARIANCE < playerBandwidth;
39172
39172
  });
39173
39173
  var highestRemainingBandwidthRep = bandwidthPlaylistReps[bandwidthPlaylistReps.length - 1];
39174
39174
  var bandwidthBestRep = bandwidthPlaylistReps.filter(function(rep) {
@@ -39401,7 +39401,7 @@
39401
39401
  return _this.ended_ = false;
39402
39402
  });
39403
39403
  _this.fetchAtBuffer_ = false;
39404
- _this.logger_ = logger("SegmentLoader[" + _this.loaderType_ + "]");
39404
+ _this.logger_ = logger$3("SegmentLoader[" + _this.loaderType_ + "]");
39405
39405
  Object.defineProperty(_this, "state", {
39406
39406
  get: function get$$1() {
39407
39407
  return this.state_;
@@ -39843,7 +39843,7 @@
39843
39843
  if (!switchCandidate.playlist || switchCandidate.playlist.uri === this.playlist_.uri || timeSavedBySwitching < minimumTimeSaving) {
39844
39844
  return false;
39845
39845
  }
39846
- this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config.BANDWIDTH_VARIANCE + 1;
39846
+ this.bandwidth = switchCandidate.playlist.attributes.BANDWIDTH * Config$1.BANDWIDTH_VARIANCE + 1;
39847
39847
  this.abort();
39848
39848
  this.trigger("earlyabort");
39849
39849
  return true;
@@ -40550,7 +40550,7 @@
40550
40550
  _this.timelines = [];
40551
40551
  _this.discontinuities = [];
40552
40552
  _this.datetimeToDisplayTime = null;
40553
- _this.logger_ = logger("SyncController");
40553
+ _this.logger_ = logger$3("SyncController");
40554
40554
  return _this;
40555
40555
  }
40556
40556
  createClass(SyncController2, [{
@@ -41581,7 +41581,7 @@
41581
41581
  loaderStats.forEach(function(stat) {
41582
41582
  _this[stat + "_"] = sumLoaderStat.bind(_this, stat);
41583
41583
  });
41584
- _this.logger_ = logger("MPC");
41584
+ _this.logger_ = logger$3("MPC");
41585
41585
  _this.masterPlaylistLoader_.load();
41586
41586
  return _this;
41587
41587
  }
@@ -41785,7 +41785,7 @@
41785
41785
  var buffered2 = _this3.tech_.buffered();
41786
41786
  var forwardBuffer = buffered2.length ? buffered2.end(buffered2.length - 1) - _this3.tech_.currentTime() : 0;
41787
41787
  var bufferLowWaterLine = _this3.bufferLowWaterLine();
41788
- if (!currentPlaylist.endList || _this3.duration() < Config.MAX_BUFFER_LOW_WATER_LINE || nextPlaylist.attributes.BANDWIDTH < currentPlaylist.attributes.BANDWIDTH || forwardBuffer >= bufferLowWaterLine) {
41788
+ if (!currentPlaylist.endList || _this3.duration() < Config$1.MAX_BUFFER_LOW_WATER_LINE || nextPlaylist.attributes.BANDWIDTH < currentPlaylist.attributes.BANDWIDTH || forwardBuffer >= bufferLowWaterLine) {
41789
41789
  _this3.masterPlaylistLoader_.media(nextPlaylist);
41790
41790
  }
41791
41791
  _this3.tech_.trigger("bandwidthupdate");
@@ -42261,18 +42261,18 @@
42261
42261
  key: "goalBufferLength",
42262
42262
  value: function goalBufferLength() {
42263
42263
  var currentTime = this.tech_.currentTime();
42264
- var initial = Config.GOAL_BUFFER_LENGTH;
42265
- var rate = Config.GOAL_BUFFER_LENGTH_RATE;
42266
- var max = Math.max(initial, Config.MAX_GOAL_BUFFER_LENGTH);
42264
+ var initial = Config$1.GOAL_BUFFER_LENGTH;
42265
+ var rate = Config$1.GOAL_BUFFER_LENGTH_RATE;
42266
+ var max = Math.max(initial, Config$1.MAX_GOAL_BUFFER_LENGTH);
42267
42267
  return Math.min(initial + currentTime * rate, max);
42268
42268
  }
42269
42269
  }, {
42270
42270
  key: "bufferLowWaterLine",
42271
42271
  value: function bufferLowWaterLine() {
42272
42272
  var currentTime = this.tech_.currentTime();
42273
- var initial = Config.BUFFER_LOW_WATER_LINE;
42274
- var rate = Config.BUFFER_LOW_WATER_LINE_RATE;
42275
- var max = Math.max(initial, Config.MAX_BUFFER_LOW_WATER_LINE);
42273
+ var initial = Config$1.BUFFER_LOW_WATER_LINE;
42274
+ var rate = Config$1.BUFFER_LOW_WATER_LINE_RATE;
42275
+ var max = Math.max(initial, Config$1.MAX_BUFFER_LOW_WATER_LINE);
42276
42276
  return Math.min(initial + currentTime * rate, max);
42277
42277
  }
42278
42278
  }]);
@@ -42340,7 +42340,7 @@
42340
42340
  this.lastRecordedTime = null;
42341
42341
  this.timer_ = null;
42342
42342
  this.checkCurrentTimeTimeout_ = null;
42343
- this.logger_ = logger("PlaybackWatcher");
42343
+ this.logger_ = logger$3("PlaybackWatcher");
42344
42344
  this.logger_("initialize");
42345
42345
  var canPlayHandler = function canPlayHandler2() {
42346
42346
  return _this.monitorCurrentTime_();
@@ -42680,7 +42680,7 @@
42680
42680
  Object.defineProperty(Hls$1, prop, {
42681
42681
  get: function get$$1() {
42682
42682
  videojs$1.log.warn("using Hls." + prop + " is UNSAFE be sure you know what you are doing");
42683
- return Config[prop];
42683
+ return Config$1[prop];
42684
42684
  },
42685
42685
  set: function set$$1(value) {
42686
42686
  videojs$1.log.warn("using Hls." + prop + " is UNSAFE be sure you know what you are doing");
@@ -42688,7 +42688,7 @@
42688
42688
  videojs$1.log.warn("value of Hls." + prop + " must be greater than or equal to 0");
42689
42689
  return;
42690
42690
  }
42691
- Config[prop] = value;
42691
+ Config$1[prop] = value;
42692
42692
  }
42693
42693
  });
42694
42694
  });
@@ -42914,9 +42914,9 @@
42914
42914
  }
42915
42915
  }
42916
42916
  if (typeof this.options_.bandwidth !== "number") {
42917
- this.options_.bandwidth = Config.INITIAL_BANDWIDTH;
42917
+ this.options_.bandwidth = Config$1.INITIAL_BANDWIDTH;
42918
42918
  }
42919
- this.options_.enableLowInitialPlaylist = this.options_.enableLowInitialPlaylist && this.options_.bandwidth === Config.INITIAL_BANDWIDTH;
42919
+ this.options_.enableLowInitialPlaylist = this.options_.enableLowInitialPlaylist && this.options_.bandwidth === Config$1.INITIAL_BANDWIDTH;
42920
42920
  ["withCredentials", "limitRenditionByPlayerDimensions", "bandwidth", "smoothQualityChange", "customTagParsers", "customTagMappers", "handleManifestRedirects", "cacheEncryptionKeys"].forEach(function(option) {
42921
42921
  if (typeof _this2.source_[option] !== "undefined") {
42922
42922
  _this2.options_[option] = _this2.source_[option];
@@ -43254,7 +43254,7 @@
43254
43254
  };
43255
43255
  if (typeof videojs$1.MediaSource === "undefined" || typeof videojs$1.URL === "undefined") {
43256
43256
  videojs$1.MediaSource = MediaSource;
43257
- videojs$1.URL = URL$1;
43257
+ videojs$1.URL = URL$1$1;
43258
43258
  }
43259
43259
  if (MediaSource.supportsNativeMediaSources()) {
43260
43260
  videojs$1.getTech("Html5").registerSourceHandler(HlsSourceHandler, 0);
@@ -43276,7 +43276,7 @@
43276
43276
  default: videojs$1
43277
43277
  }, Symbol.toStringTag, { value: "Module" }));
43278
43278
  const name$1 = "stream-engine-player";
43279
- const version$2 = "0.0.11";
43279
+ const version$2 = "0.0.13";
43280
43280
  const description = "Stream engine player";
43281
43281
  const type$1 = "module";
43282
43282
  const files$1 = [
@@ -43303,6 +43303,7 @@
43303
43303
  "include-media": "^2.0.0",
43304
43304
  localforage: "^1.10.0",
43305
43305
  "m3u8-parser": "^7.1.0",
43306
+ "mixpanel-browser": "2.52.0",
43306
43307
  "video.js": "7.6.6",
43307
43308
  "videojs-youtube": "^2.6.1",
43308
43309
  "videojs-ima": "1.7.5",
@@ -52434,13 +52435,11 @@
52434
52435
  }
52435
52436
  let wrapper = document.createElement("div");
52436
52437
  wrapper.className = wrapperClass;
52437
- console.log(this.player.tech(true).el_);
52438
52438
  this.player.videoWrapper = wrapAll(this.player.tech(true).el_, [
52439
52439
  ".video-js .vjs-mask",
52440
52440
  ".video-js .vjs-loading-spinner",
52441
52441
  ".video-js .vjs-text-track-display"
52442
52442
  ], [wrapper]);
52443
- console.log(this.player.videoWrapper);
52444
52443
  }
52445
52444
  },
52446
52445
  wrapControls: function(wrapperClass) {
@@ -54930,11 +54929,4311 @@
54930
54929
  });
54931
54930
  }();
54932
54931
  })(videojsMux);
54933
- module$2.service("VJSAnalyticsPlugin", [function() {
54934
- const Plugin2 = videojs$1.getPlugin("plugin");
54935
- const plugin = videojs$1.extend(Plugin2, {
54936
- constructor: function(player, options) {
54937
- Plugin2.call(this, player, options);
54932
+ var Config = {
54933
+ DEBUG: false,
54934
+ LIB_VERSION: "2.52.0"
54935
+ };
54936
+ var win;
54937
+ if (typeof window === "undefined") {
54938
+ var loc = {
54939
+ hostname: ""
54940
+ };
54941
+ win = {
54942
+ navigator: { userAgent: "" },
54943
+ document: {
54944
+ location: loc,
54945
+ referrer: ""
54946
+ },
54947
+ screen: { width: 0, height: 0 },
54948
+ location: loc
54949
+ };
54950
+ } else {
54951
+ win = window;
54952
+ }
54953
+ var MAX_RECORDING_MS = 24 * 60 * 60 * 1e3;
54954
+ var ArrayProto = Array.prototype, FuncProto = Function.prototype, ObjProto = Object.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, windowConsole = win.console, navigator$1 = win.navigator, document$1 = win.document, windowOpera = win.opera, screen = win.screen, userAgent = navigator$1.userAgent;
54955
+ var nativeBind = FuncProto.bind, nativeForEach = ArrayProto.forEach, nativeIndexOf = ArrayProto.indexOf, nativeMap = ArrayProto.map, nativeIsArray = Array.isArray, breaker = {};
54956
+ var _$1 = {
54957
+ trim: function(str) {
54958
+ return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
54959
+ }
54960
+ };
54961
+ var console$1 = {
54962
+ log: function() {
54963
+ if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
54964
+ try {
54965
+ windowConsole.log.apply(windowConsole, arguments);
54966
+ } catch (err) {
54967
+ _$1.each(arguments, function(arg) {
54968
+ windowConsole.log(arg);
54969
+ });
54970
+ }
54971
+ }
54972
+ },
54973
+ warn: function() {
54974
+ if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
54975
+ var args = ["Mixpanel warning:"].concat(_$1.toArray(arguments));
54976
+ try {
54977
+ windowConsole.warn.apply(windowConsole, args);
54978
+ } catch (err) {
54979
+ _$1.each(args, function(arg) {
54980
+ windowConsole.warn(arg);
54981
+ });
54982
+ }
54983
+ }
54984
+ },
54985
+ error: function() {
54986
+ if (Config.DEBUG && !_$1.isUndefined(windowConsole) && windowConsole) {
54987
+ var args = ["Mixpanel error:"].concat(_$1.toArray(arguments));
54988
+ try {
54989
+ windowConsole.error.apply(windowConsole, args);
54990
+ } catch (err) {
54991
+ _$1.each(args, function(arg) {
54992
+ windowConsole.error(arg);
54993
+ });
54994
+ }
54995
+ }
54996
+ },
54997
+ critical: function() {
54998
+ if (!_$1.isUndefined(windowConsole) && windowConsole) {
54999
+ var args = ["Mixpanel error:"].concat(_$1.toArray(arguments));
55000
+ try {
55001
+ windowConsole.error.apply(windowConsole, args);
55002
+ } catch (err) {
55003
+ _$1.each(args, function(arg) {
55004
+ windowConsole.error(arg);
55005
+ });
55006
+ }
55007
+ }
55008
+ }
55009
+ };
55010
+ var log_func_with_prefix = function(func, prefix) {
55011
+ return function() {
55012
+ arguments[0] = "[" + prefix + "] " + arguments[0];
55013
+ return func.apply(console$1, arguments);
55014
+ };
55015
+ };
55016
+ var console_with_prefix = function(prefix) {
55017
+ return {
55018
+ log: log_func_with_prefix(console$1.log, prefix),
55019
+ error: log_func_with_prefix(console$1.error, prefix),
55020
+ critical: log_func_with_prefix(console$1.critical, prefix)
55021
+ };
55022
+ };
55023
+ _$1.bind = function(func, context) {
55024
+ var args, bound;
55025
+ if (nativeBind && func.bind === nativeBind) {
55026
+ return nativeBind.apply(func, slice.call(arguments, 1));
55027
+ }
55028
+ if (!_$1.isFunction(func)) {
55029
+ throw new TypeError();
55030
+ }
55031
+ args = slice.call(arguments, 2);
55032
+ bound = function() {
55033
+ if (!(this instanceof bound)) {
55034
+ return func.apply(context, args.concat(slice.call(arguments)));
55035
+ }
55036
+ var ctor = {};
55037
+ ctor.prototype = func.prototype;
55038
+ var self2 = new ctor();
55039
+ ctor.prototype = null;
55040
+ var result = func.apply(self2, args.concat(slice.call(arguments)));
55041
+ if (Object(result) === result) {
55042
+ return result;
55043
+ }
55044
+ return self2;
55045
+ };
55046
+ return bound;
55047
+ };
55048
+ _$1.each = function(obj2, iterator, context) {
55049
+ if (obj2 === null || obj2 === void 0) {
55050
+ return;
55051
+ }
55052
+ if (nativeForEach && obj2.forEach === nativeForEach) {
55053
+ obj2.forEach(iterator, context);
55054
+ } else if (obj2.length === +obj2.length) {
55055
+ for (var i2 = 0, l = obj2.length; i2 < l; i2++) {
55056
+ if (i2 in obj2 && iterator.call(context, obj2[i2], i2, obj2) === breaker) {
55057
+ return;
55058
+ }
55059
+ }
55060
+ } else {
55061
+ for (var key in obj2) {
55062
+ if (hasOwnProperty.call(obj2, key)) {
55063
+ if (iterator.call(context, obj2[key], key, obj2) === breaker) {
55064
+ return;
55065
+ }
55066
+ }
55067
+ }
55068
+ }
55069
+ };
55070
+ _$1.extend = function(obj2) {
55071
+ _$1.each(slice.call(arguments, 1), function(source) {
55072
+ for (var prop in source) {
55073
+ if (source[prop] !== void 0) {
55074
+ obj2[prop] = source[prop];
55075
+ }
55076
+ }
55077
+ });
55078
+ return obj2;
55079
+ };
55080
+ _$1.isArray = nativeIsArray || function(obj2) {
55081
+ return toString.call(obj2) === "[object Array]";
55082
+ };
55083
+ _$1.isFunction = function(f) {
55084
+ try {
55085
+ return /^\s*\bfunction\b/.test(f);
55086
+ } catch (x) {
55087
+ return false;
55088
+ }
55089
+ };
55090
+ _$1.isArguments = function(obj2) {
55091
+ return !!(obj2 && hasOwnProperty.call(obj2, "callee"));
55092
+ };
55093
+ _$1.toArray = function(iterable) {
55094
+ if (!iterable) {
55095
+ return [];
55096
+ }
55097
+ if (iterable.toArray) {
55098
+ return iterable.toArray();
55099
+ }
55100
+ if (_$1.isArray(iterable)) {
55101
+ return slice.call(iterable);
55102
+ }
55103
+ if (_$1.isArguments(iterable)) {
55104
+ return slice.call(iterable);
55105
+ }
55106
+ return _$1.values(iterable);
55107
+ };
55108
+ _$1.map = function(arr, callback, context) {
55109
+ if (nativeMap && arr.map === nativeMap) {
55110
+ return arr.map(callback, context);
55111
+ } else {
55112
+ var results = [];
55113
+ _$1.each(arr, function(item) {
55114
+ results.push(callback.call(context, item));
55115
+ });
55116
+ return results;
55117
+ }
55118
+ };
55119
+ _$1.keys = function(obj2) {
55120
+ var results = [];
55121
+ if (obj2 === null) {
55122
+ return results;
55123
+ }
55124
+ _$1.each(obj2, function(value, key) {
55125
+ results[results.length] = key;
55126
+ });
55127
+ return results;
55128
+ };
55129
+ _$1.values = function(obj2) {
55130
+ var results = [];
55131
+ if (obj2 === null) {
55132
+ return results;
55133
+ }
55134
+ _$1.each(obj2, function(value) {
55135
+ results[results.length] = value;
55136
+ });
55137
+ return results;
55138
+ };
55139
+ _$1.include = function(obj2, target) {
55140
+ var found = false;
55141
+ if (obj2 === null) {
55142
+ return found;
55143
+ }
55144
+ if (nativeIndexOf && obj2.indexOf === nativeIndexOf) {
55145
+ return obj2.indexOf(target) != -1;
55146
+ }
55147
+ _$1.each(obj2, function(value) {
55148
+ if (found || (found = value === target)) {
55149
+ return breaker;
55150
+ }
55151
+ });
55152
+ return found;
55153
+ };
55154
+ _$1.includes = function(str, needle) {
55155
+ return str.indexOf(needle) !== -1;
55156
+ };
55157
+ _$1.inherit = function(subclass, superclass) {
55158
+ subclass.prototype = new superclass();
55159
+ subclass.prototype.constructor = subclass;
55160
+ subclass.superclass = superclass.prototype;
55161
+ return subclass;
55162
+ };
55163
+ _$1.isObject = function(obj2) {
55164
+ return obj2 === Object(obj2) && !_$1.isArray(obj2);
55165
+ };
55166
+ _$1.isEmptyObject = function(obj2) {
55167
+ if (_$1.isObject(obj2)) {
55168
+ for (var key in obj2) {
55169
+ if (hasOwnProperty.call(obj2, key)) {
55170
+ return false;
55171
+ }
55172
+ }
55173
+ return true;
55174
+ }
55175
+ return false;
55176
+ };
55177
+ _$1.isUndefined = function(obj2) {
55178
+ return obj2 === void 0;
55179
+ };
55180
+ _$1.isString = function(obj2) {
55181
+ return toString.call(obj2) == "[object String]";
55182
+ };
55183
+ _$1.isDate = function(obj2) {
55184
+ return toString.call(obj2) == "[object Date]";
55185
+ };
55186
+ _$1.isNumber = function(obj2) {
55187
+ return toString.call(obj2) == "[object Number]";
55188
+ };
55189
+ _$1.isElement = function(obj2) {
55190
+ return !!(obj2 && obj2.nodeType === 1);
55191
+ };
55192
+ _$1.encodeDates = function(obj2) {
55193
+ _$1.each(obj2, function(v, k) {
55194
+ if (_$1.isDate(v)) {
55195
+ obj2[k] = _$1.formatDate(v);
55196
+ } else if (_$1.isObject(v)) {
55197
+ obj2[k] = _$1.encodeDates(v);
55198
+ }
55199
+ });
55200
+ return obj2;
55201
+ };
55202
+ _$1.timestamp = function() {
55203
+ Date.now = Date.now || function() {
55204
+ return +new Date();
55205
+ };
55206
+ return Date.now();
55207
+ };
55208
+ _$1.formatDate = function(d) {
55209
+ function pad(n) {
55210
+ return n < 10 ? "0" + n : n;
55211
+ }
55212
+ return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds());
55213
+ };
55214
+ _$1.strip_empty_properties = function(p) {
55215
+ var ret = {};
55216
+ _$1.each(p, function(v, k) {
55217
+ if (_$1.isString(v) && v.length > 0) {
55218
+ ret[k] = v;
55219
+ }
55220
+ });
55221
+ return ret;
55222
+ };
55223
+ _$1.truncate = function(obj2, length) {
55224
+ var ret;
55225
+ if (typeof obj2 === "string") {
55226
+ ret = obj2.slice(0, length);
55227
+ } else if (_$1.isArray(obj2)) {
55228
+ ret = [];
55229
+ _$1.each(obj2, function(val) {
55230
+ ret.push(_$1.truncate(val, length));
55231
+ });
55232
+ } else if (_$1.isObject(obj2)) {
55233
+ ret = {};
55234
+ _$1.each(obj2, function(val, key) {
55235
+ ret[key] = _$1.truncate(val, length);
55236
+ });
55237
+ } else {
55238
+ ret = obj2;
55239
+ }
55240
+ return ret;
55241
+ };
55242
+ _$1.JSONEncode = function() {
55243
+ return function(mixed_val) {
55244
+ var value = mixed_val;
55245
+ var quote = function(string) {
55246
+ var escapable = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
55247
+ var meta = {
55248
+ "\b": "\\b",
55249
+ " ": "\\t",
55250
+ "\n": "\\n",
55251
+ "\f": "\\f",
55252
+ "\r": "\\r",
55253
+ '"': '\\"',
55254
+ "\\": "\\\\"
55255
+ };
55256
+ escapable.lastIndex = 0;
55257
+ return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
55258
+ var c = meta[a];
55259
+ return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
55260
+ }) + '"' : '"' + string + '"';
55261
+ };
55262
+ var str = function(key, holder) {
55263
+ var gap = "";
55264
+ var indent = " ";
55265
+ var i2 = 0;
55266
+ var k = "";
55267
+ var v = "";
55268
+ var length = 0;
55269
+ var mind = gap;
55270
+ var partial = [];
55271
+ var value2 = holder[key];
55272
+ if (value2 && typeof value2 === "object" && typeof value2.toJSON === "function") {
55273
+ value2 = value2.toJSON(key);
55274
+ }
55275
+ switch (typeof value2) {
55276
+ case "string":
55277
+ return quote(value2);
55278
+ case "number":
55279
+ return isFinite(value2) ? String(value2) : "null";
55280
+ case "boolean":
55281
+ case "null":
55282
+ return String(value2);
55283
+ case "object":
55284
+ if (!value2) {
55285
+ return "null";
55286
+ }
55287
+ gap += indent;
55288
+ partial = [];
55289
+ if (toString.apply(value2) === "[object Array]") {
55290
+ length = value2.length;
55291
+ for (i2 = 0; i2 < length; i2 += 1) {
55292
+ partial[i2] = str(i2, value2) || "null";
55293
+ }
55294
+ v = partial.length === 0 ? "[]" : gap ? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]" : "[" + partial.join(",") + "]";
55295
+ gap = mind;
55296
+ return v;
55297
+ }
55298
+ for (k in value2) {
55299
+ if (hasOwnProperty.call(value2, k)) {
55300
+ v = str(k, value2);
55301
+ if (v) {
55302
+ partial.push(quote(k) + (gap ? ": " : ":") + v);
55303
+ }
55304
+ }
55305
+ }
55306
+ v = partial.length === 0 ? "{}" : gap ? "{" + partial.join(",") + mind + "}" : "{" + partial.join(",") + "}";
55307
+ gap = mind;
55308
+ return v;
55309
+ }
55310
+ };
55311
+ return str("", {
55312
+ "": value
55313
+ });
55314
+ };
55315
+ }();
55316
+ _$1.JSONDecode = function() {
55317
+ var at, ch, escapee = {
55318
+ '"': '"',
55319
+ "\\": "\\",
55320
+ "/": "/",
55321
+ "b": "\b",
55322
+ "f": "\f",
55323
+ "n": "\n",
55324
+ "r": "\r",
55325
+ "t": " "
55326
+ }, text, error = function(m) {
55327
+ var e = new SyntaxError(m);
55328
+ e.at = at;
55329
+ e.text = text;
55330
+ throw e;
55331
+ }, next = function(c) {
55332
+ if (c && c !== ch) {
55333
+ error("Expected '" + c + "' instead of '" + ch + "'");
55334
+ }
55335
+ ch = text.charAt(at);
55336
+ at += 1;
55337
+ return ch;
55338
+ }, number = function() {
55339
+ var number2, string2 = "";
55340
+ if (ch === "-") {
55341
+ string2 = "-";
55342
+ next("-");
55343
+ }
55344
+ while (ch >= "0" && ch <= "9") {
55345
+ string2 += ch;
55346
+ next();
55347
+ }
55348
+ if (ch === ".") {
55349
+ string2 += ".";
55350
+ while (next() && ch >= "0" && ch <= "9") {
55351
+ string2 += ch;
55352
+ }
55353
+ }
55354
+ if (ch === "e" || ch === "E") {
55355
+ string2 += ch;
55356
+ next();
55357
+ if (ch === "-" || ch === "+") {
55358
+ string2 += ch;
55359
+ next();
55360
+ }
55361
+ while (ch >= "0" && ch <= "9") {
55362
+ string2 += ch;
55363
+ next();
55364
+ }
55365
+ }
55366
+ number2 = +string2;
55367
+ if (!isFinite(number2)) {
55368
+ error("Bad number");
55369
+ } else {
55370
+ return number2;
55371
+ }
55372
+ }, string = function() {
55373
+ var hex, i2, string2 = "", uffff;
55374
+ if (ch === '"') {
55375
+ while (next()) {
55376
+ if (ch === '"') {
55377
+ next();
55378
+ return string2;
55379
+ }
55380
+ if (ch === "\\") {
55381
+ next();
55382
+ if (ch === "u") {
55383
+ uffff = 0;
55384
+ for (i2 = 0; i2 < 4; i2 += 1) {
55385
+ hex = parseInt(next(), 16);
55386
+ if (!isFinite(hex)) {
55387
+ break;
55388
+ }
55389
+ uffff = uffff * 16 + hex;
55390
+ }
55391
+ string2 += String.fromCharCode(uffff);
55392
+ } else if (typeof escapee[ch] === "string") {
55393
+ string2 += escapee[ch];
55394
+ } else {
55395
+ break;
55396
+ }
55397
+ } else {
55398
+ string2 += ch;
55399
+ }
55400
+ }
55401
+ }
55402
+ error("Bad string");
55403
+ }, white = function() {
55404
+ while (ch && ch <= " ") {
55405
+ next();
55406
+ }
55407
+ }, word = function() {
55408
+ switch (ch) {
55409
+ case "t":
55410
+ next("t");
55411
+ next("r");
55412
+ next("u");
55413
+ next("e");
55414
+ return true;
55415
+ case "f":
55416
+ next("f");
55417
+ next("a");
55418
+ next("l");
55419
+ next("s");
55420
+ next("e");
55421
+ return false;
55422
+ case "n":
55423
+ next("n");
55424
+ next("u");
55425
+ next("l");
55426
+ next("l");
55427
+ return null;
55428
+ }
55429
+ error('Unexpected "' + ch + '"');
55430
+ }, value, array = function() {
55431
+ var array2 = [];
55432
+ if (ch === "[") {
55433
+ next("[");
55434
+ white();
55435
+ if (ch === "]") {
55436
+ next("]");
55437
+ return array2;
55438
+ }
55439
+ while (ch) {
55440
+ array2.push(value());
55441
+ white();
55442
+ if (ch === "]") {
55443
+ next("]");
55444
+ return array2;
55445
+ }
55446
+ next(",");
55447
+ white();
55448
+ }
55449
+ }
55450
+ error("Bad array");
55451
+ }, object = function() {
55452
+ var key, object2 = {};
55453
+ if (ch === "{") {
55454
+ next("{");
55455
+ white();
55456
+ if (ch === "}") {
55457
+ next("}");
55458
+ return object2;
55459
+ }
55460
+ while (ch) {
55461
+ key = string();
55462
+ white();
55463
+ next(":");
55464
+ if (Object.hasOwnProperty.call(object2, key)) {
55465
+ error('Duplicate key "' + key + '"');
55466
+ }
55467
+ object2[key] = value();
55468
+ white();
55469
+ if (ch === "}") {
55470
+ next("}");
55471
+ return object2;
55472
+ }
55473
+ next(",");
55474
+ white();
55475
+ }
55476
+ }
55477
+ error("Bad object");
55478
+ };
55479
+ value = function() {
55480
+ white();
55481
+ switch (ch) {
55482
+ case "{":
55483
+ return object();
55484
+ case "[":
55485
+ return array();
55486
+ case '"':
55487
+ return string();
55488
+ case "-":
55489
+ return number();
55490
+ default:
55491
+ return ch >= "0" && ch <= "9" ? number() : word();
55492
+ }
55493
+ };
55494
+ return function(source) {
55495
+ var result;
55496
+ text = source;
55497
+ at = 0;
55498
+ ch = " ";
55499
+ result = value();
55500
+ white();
55501
+ if (ch) {
55502
+ error("Syntax error");
55503
+ }
55504
+ return result;
55505
+ };
55506
+ }();
55507
+ _$1.base64Encode = function(data) {
55508
+ var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
55509
+ var o1, o2, o3, h1, h2, h3, h4, bits, i2 = 0, ac = 0, enc = "", tmp_arr = [];
55510
+ if (!data) {
55511
+ return data;
55512
+ }
55513
+ data = _$1.utf8Encode(data);
55514
+ do {
55515
+ o1 = data.charCodeAt(i2++);
55516
+ o2 = data.charCodeAt(i2++);
55517
+ o3 = data.charCodeAt(i2++);
55518
+ bits = o1 << 16 | o2 << 8 | o3;
55519
+ h1 = bits >> 18 & 63;
55520
+ h2 = bits >> 12 & 63;
55521
+ h3 = bits >> 6 & 63;
55522
+ h4 = bits & 63;
55523
+ tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
55524
+ } while (i2 < data.length);
55525
+ enc = tmp_arr.join("");
55526
+ switch (data.length % 3) {
55527
+ case 1:
55528
+ enc = enc.slice(0, -2) + "==";
55529
+ break;
55530
+ case 2:
55531
+ enc = enc.slice(0, -1) + "=";
55532
+ break;
55533
+ }
55534
+ return enc;
55535
+ };
55536
+ _$1.utf8Encode = function(string) {
55537
+ string = (string + "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
55538
+ var utftext = "", start2, end2;
55539
+ var stringl = 0, n;
55540
+ start2 = end2 = 0;
55541
+ stringl = string.length;
55542
+ for (n = 0; n < stringl; n++) {
55543
+ var c1 = string.charCodeAt(n);
55544
+ var enc = null;
55545
+ if (c1 < 128) {
55546
+ end2++;
55547
+ } else if (c1 > 127 && c1 < 2048) {
55548
+ enc = String.fromCharCode(c1 >> 6 | 192, c1 & 63 | 128);
55549
+ } else {
55550
+ enc = String.fromCharCode(c1 >> 12 | 224, c1 >> 6 & 63 | 128, c1 & 63 | 128);
55551
+ }
55552
+ if (enc !== null) {
55553
+ if (end2 > start2) {
55554
+ utftext += string.substring(start2, end2);
55555
+ }
55556
+ utftext += enc;
55557
+ start2 = end2 = n + 1;
55558
+ }
55559
+ }
55560
+ if (end2 > start2) {
55561
+ utftext += string.substring(start2, string.length);
55562
+ }
55563
+ return utftext;
55564
+ };
55565
+ _$1.UUID = function() {
55566
+ var T = function() {
55567
+ var time = 1 * new Date();
55568
+ var ticks;
55569
+ if (win.performance && win.performance.now) {
55570
+ ticks = win.performance.now();
55571
+ } else {
55572
+ ticks = 0;
55573
+ while (time == 1 * new Date()) {
55574
+ ticks++;
55575
+ }
55576
+ }
55577
+ return time.toString(16) + Math.floor(ticks).toString(16);
55578
+ };
55579
+ var R = function() {
55580
+ return Math.random().toString(16).replace(".", "");
55581
+ };
55582
+ var UA = function() {
55583
+ var ua = userAgent, i2, ch, buffer = [], ret = 0;
55584
+ function xor(result, byte_array) {
55585
+ var j, tmp = 0;
55586
+ for (j = 0; j < byte_array.length; j++) {
55587
+ tmp |= buffer[j] << j * 8;
55588
+ }
55589
+ return result ^ tmp;
55590
+ }
55591
+ for (i2 = 0; i2 < ua.length; i2++) {
55592
+ ch = ua.charCodeAt(i2);
55593
+ buffer.unshift(ch & 255);
55594
+ if (buffer.length >= 4) {
55595
+ ret = xor(ret, buffer);
55596
+ buffer = [];
55597
+ }
55598
+ }
55599
+ if (buffer.length > 0) {
55600
+ ret = xor(ret, buffer);
55601
+ }
55602
+ return ret.toString(16);
55603
+ };
55604
+ return function() {
55605
+ var se = (screen.height * screen.width).toString(16);
55606
+ return T() + "-" + R() + "-" + UA() + "-" + se + "-" + T();
55607
+ };
55608
+ }();
55609
+ var BLOCKED_UA_STRS = [
55610
+ "ahrefsbot",
55611
+ "ahrefssiteaudit",
55612
+ "baiduspider",
55613
+ "bingbot",
55614
+ "bingpreview",
55615
+ "chrome-lighthouse",
55616
+ "facebookexternal",
55617
+ "petalbot",
55618
+ "pinterest",
55619
+ "screaming frog",
55620
+ "yahoo! slurp",
55621
+ "yandexbot",
55622
+ "adsbot-google",
55623
+ "apis-google",
55624
+ "duplexweb-google",
55625
+ "feedfetcher-google",
55626
+ "google favicon",
55627
+ "google web preview",
55628
+ "google-read-aloud",
55629
+ "googlebot",
55630
+ "googleweblight",
55631
+ "mediapartners-google",
55632
+ "storebot-google"
55633
+ ];
55634
+ _$1.isBlockedUA = function(ua) {
55635
+ var i2;
55636
+ ua = ua.toLowerCase();
55637
+ for (i2 = 0; i2 < BLOCKED_UA_STRS.length; i2++) {
55638
+ if (ua.indexOf(BLOCKED_UA_STRS[i2]) !== -1) {
55639
+ return true;
55640
+ }
55641
+ }
55642
+ return false;
55643
+ };
55644
+ _$1.HTTPBuildQuery = function(formdata, arg_separator) {
55645
+ var use_val, use_key, tmp_arr = [];
55646
+ if (_$1.isUndefined(arg_separator)) {
55647
+ arg_separator = "&";
55648
+ }
55649
+ _$1.each(formdata, function(val, key) {
55650
+ use_val = encodeURIComponent(val.toString());
55651
+ use_key = encodeURIComponent(key);
55652
+ tmp_arr[tmp_arr.length] = use_key + "=" + use_val;
55653
+ });
55654
+ return tmp_arr.join(arg_separator);
55655
+ };
55656
+ _$1.getQueryParam = function(url, param) {
55657
+ param = param.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
55658
+ var regexS = "[\\?&]" + param + "=([^&#]*)", regex = new RegExp(regexS), results = regex.exec(url);
55659
+ if (results === null || results && typeof results[1] !== "string" && results[1].length) {
55660
+ return "";
55661
+ } else {
55662
+ var result = results[1];
55663
+ try {
55664
+ result = decodeURIComponent(result);
55665
+ } catch (err) {
55666
+ console$1.error("Skipping decoding for malformed query param: " + result);
55667
+ }
55668
+ return result.replace(/\+/g, " ");
55669
+ }
55670
+ };
55671
+ _$1.cookie = {
55672
+ get: function(name2) {
55673
+ var nameEQ = name2 + "=";
55674
+ var ca = document$1.cookie.split(";");
55675
+ for (var i2 = 0; i2 < ca.length; i2++) {
55676
+ var c = ca[i2];
55677
+ while (c.charAt(0) == " ") {
55678
+ c = c.substring(1, c.length);
55679
+ }
55680
+ if (c.indexOf(nameEQ) === 0) {
55681
+ return decodeURIComponent(c.substring(nameEQ.length, c.length));
55682
+ }
55683
+ }
55684
+ return null;
55685
+ },
55686
+ parse: function(name2) {
55687
+ var cookie;
55688
+ try {
55689
+ cookie = _$1.JSONDecode(_$1.cookie.get(name2)) || {};
55690
+ } catch (err) {
55691
+ }
55692
+ return cookie;
55693
+ },
55694
+ set_seconds: function(name2, value, seconds, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
55695
+ var cdomain = "", expires = "", secure = "";
55696
+ if (domain_override) {
55697
+ cdomain = "; domain=" + domain_override;
55698
+ } else if (is_cross_subdomain) {
55699
+ var domain = extract_domain(document$1.location.hostname);
55700
+ cdomain = domain ? "; domain=." + domain : "";
55701
+ }
55702
+ if (seconds) {
55703
+ var date = new Date();
55704
+ date.setTime(date.getTime() + seconds * 1e3);
55705
+ expires = "; expires=" + date.toGMTString();
55706
+ }
55707
+ if (is_cross_site) {
55708
+ is_secure = true;
55709
+ secure = "; SameSite=None";
55710
+ }
55711
+ if (is_secure) {
55712
+ secure += "; secure";
55713
+ }
55714
+ document$1.cookie = name2 + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
55715
+ },
55716
+ set: function(name2, value, days, is_cross_subdomain, is_secure, is_cross_site, domain_override) {
55717
+ var cdomain = "", expires = "", secure = "";
55718
+ if (domain_override) {
55719
+ cdomain = "; domain=" + domain_override;
55720
+ } else if (is_cross_subdomain) {
55721
+ var domain = extract_domain(document$1.location.hostname);
55722
+ cdomain = domain ? "; domain=." + domain : "";
55723
+ }
55724
+ if (days) {
55725
+ var date = new Date();
55726
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
55727
+ expires = "; expires=" + date.toGMTString();
55728
+ }
55729
+ if (is_cross_site) {
55730
+ is_secure = true;
55731
+ secure = "; SameSite=None";
55732
+ }
55733
+ if (is_secure) {
55734
+ secure += "; secure";
55735
+ }
55736
+ var new_cookie_val = name2 + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
55737
+ document$1.cookie = new_cookie_val;
55738
+ return new_cookie_val;
55739
+ },
55740
+ remove: function(name2, is_cross_subdomain, domain_override) {
55741
+ _$1.cookie.set(name2, "", -1, is_cross_subdomain, false, false, domain_override);
55742
+ }
55743
+ };
55744
+ var _localStorageSupported = null;
55745
+ var localStorageSupported = function(storage, forceCheck) {
55746
+ if (_localStorageSupported !== null && !forceCheck) {
55747
+ return _localStorageSupported;
55748
+ }
55749
+ var supported = true;
55750
+ try {
55751
+ storage = storage || window.localStorage;
55752
+ var key = "__mplss_" + cheap_guid(8), val = "xyz";
55753
+ storage.setItem(key, val);
55754
+ if (storage.getItem(key) !== val) {
55755
+ supported = false;
55756
+ }
55757
+ storage.removeItem(key);
55758
+ } catch (err) {
55759
+ supported = false;
55760
+ }
55761
+ _localStorageSupported = supported;
55762
+ return supported;
55763
+ };
55764
+ _$1.localStorage = {
55765
+ is_supported: function(force_check) {
55766
+ var supported = localStorageSupported(null, force_check);
55767
+ if (!supported) {
55768
+ console$1.error("localStorage unsupported; falling back to cookie store");
55769
+ }
55770
+ return supported;
55771
+ },
55772
+ error: function(msg) {
55773
+ console$1.error("localStorage error: " + msg);
55774
+ },
55775
+ get: function(name2) {
55776
+ try {
55777
+ return window.localStorage.getItem(name2);
55778
+ } catch (err) {
55779
+ _$1.localStorage.error(err);
55780
+ }
55781
+ return null;
55782
+ },
55783
+ parse: function(name2) {
55784
+ try {
55785
+ return _$1.JSONDecode(_$1.localStorage.get(name2)) || {};
55786
+ } catch (err) {
55787
+ }
55788
+ return null;
55789
+ },
55790
+ set: function(name2, value) {
55791
+ try {
55792
+ window.localStorage.setItem(name2, value);
55793
+ } catch (err) {
55794
+ _$1.localStorage.error(err);
55795
+ }
55796
+ },
55797
+ remove: function(name2) {
55798
+ try {
55799
+ window.localStorage.removeItem(name2);
55800
+ } catch (err) {
55801
+ _$1.localStorage.error(err);
55802
+ }
55803
+ }
55804
+ };
55805
+ _$1.register_event = function() {
55806
+ var register_event = function(element, type2, handler, oldSchool, useCapture) {
55807
+ if (!element) {
55808
+ console$1.error("No valid element provided to register_event");
55809
+ return;
55810
+ }
55811
+ if (element.addEventListener && !oldSchool) {
55812
+ element.addEventListener(type2, handler, !!useCapture);
55813
+ } else {
55814
+ var ontype = "on" + type2;
55815
+ var old_handler = element[ontype];
55816
+ element[ontype] = makeHandler(element, handler, old_handler);
55817
+ }
55818
+ };
55819
+ function makeHandler(element, new_handler, old_handlers) {
55820
+ var handler = function(event2) {
55821
+ event2 = event2 || fixEvent2(window.event);
55822
+ if (!event2) {
55823
+ return void 0;
55824
+ }
55825
+ var ret = true;
55826
+ var old_result, new_result;
55827
+ if (_$1.isFunction(old_handlers)) {
55828
+ old_result = old_handlers(event2);
55829
+ }
55830
+ new_result = new_handler.call(element, event2);
55831
+ if (false === old_result || false === new_result) {
55832
+ ret = false;
55833
+ }
55834
+ return ret;
55835
+ };
55836
+ return handler;
55837
+ }
55838
+ function fixEvent2(event2) {
55839
+ if (event2) {
55840
+ event2.preventDefault = fixEvent2.preventDefault;
55841
+ event2.stopPropagation = fixEvent2.stopPropagation;
55842
+ }
55843
+ return event2;
55844
+ }
55845
+ fixEvent2.preventDefault = function() {
55846
+ this.returnValue = false;
55847
+ };
55848
+ fixEvent2.stopPropagation = function() {
55849
+ this.cancelBubble = true;
55850
+ };
55851
+ return register_event;
55852
+ }();
55853
+ var TOKEN_MATCH_REGEX = new RegExp('^(\\w*)\\[(\\w+)([=~\\|\\^\\$\\*]?)=?"?([^\\]"]*)"?\\]$');
55854
+ _$1.dom_query = function() {
55855
+ function getAllChildren(e) {
55856
+ return e.all ? e.all : e.getElementsByTagName("*");
55857
+ }
55858
+ var bad_whitespace = /[\t\r\n]/g;
55859
+ function hasClass2(elem, selector) {
55860
+ var className = " " + selector + " ";
55861
+ return (" " + elem.className + " ").replace(bad_whitespace, " ").indexOf(className) >= 0;
55862
+ }
55863
+ function getElementsBySelector(selector) {
55864
+ if (!document$1.getElementsByTagName) {
55865
+ return [];
55866
+ }
55867
+ var tokens = selector.split(" ");
55868
+ var token, bits, tagName, found, foundCount, i2, j, k, elements, currentContextIndex;
55869
+ var currentContext = [document$1];
55870
+ for (i2 = 0; i2 < tokens.length; i2++) {
55871
+ token = tokens[i2].replace(/^\s+/, "").replace(/\s+$/, "");
55872
+ if (token.indexOf("#") > -1) {
55873
+ bits = token.split("#");
55874
+ tagName = bits[0];
55875
+ var id = bits[1];
55876
+ var element = document$1.getElementById(id);
55877
+ if (!element || tagName && element.nodeName.toLowerCase() != tagName) {
55878
+ return [];
55879
+ }
55880
+ currentContext = [element];
55881
+ continue;
55882
+ }
55883
+ if (token.indexOf(".") > -1) {
55884
+ bits = token.split(".");
55885
+ tagName = bits[0];
55886
+ var className = bits[1];
55887
+ if (!tagName) {
55888
+ tagName = "*";
55889
+ }
55890
+ found = [];
55891
+ foundCount = 0;
55892
+ for (j = 0; j < currentContext.length; j++) {
55893
+ if (tagName == "*") {
55894
+ elements = getAllChildren(currentContext[j]);
55895
+ } else {
55896
+ elements = currentContext[j].getElementsByTagName(tagName);
55897
+ }
55898
+ for (k = 0; k < elements.length; k++) {
55899
+ found[foundCount++] = elements[k];
55900
+ }
55901
+ }
55902
+ currentContext = [];
55903
+ currentContextIndex = 0;
55904
+ for (j = 0; j < found.length; j++) {
55905
+ if (found[j].className && _$1.isString(found[j].className) && hasClass2(found[j], className)) {
55906
+ currentContext[currentContextIndex++] = found[j];
55907
+ }
55908
+ }
55909
+ continue;
55910
+ }
55911
+ var token_match = token.match(TOKEN_MATCH_REGEX);
55912
+ if (token_match) {
55913
+ tagName = token_match[1];
55914
+ var attrName = token_match[2];
55915
+ var attrOperator = token_match[3];
55916
+ var attrValue = token_match[4];
55917
+ if (!tagName) {
55918
+ tagName = "*";
55919
+ }
55920
+ found = [];
55921
+ foundCount = 0;
55922
+ for (j = 0; j < currentContext.length; j++) {
55923
+ if (tagName == "*") {
55924
+ elements = getAllChildren(currentContext[j]);
55925
+ } else {
55926
+ elements = currentContext[j].getElementsByTagName(tagName);
55927
+ }
55928
+ for (k = 0; k < elements.length; k++) {
55929
+ found[foundCount++] = elements[k];
55930
+ }
55931
+ }
55932
+ currentContext = [];
55933
+ currentContextIndex = 0;
55934
+ var checkFunction;
55935
+ switch (attrOperator) {
55936
+ case "=":
55937
+ checkFunction = function(e) {
55938
+ return e.getAttribute(attrName) == attrValue;
55939
+ };
55940
+ break;
55941
+ case "~":
55942
+ checkFunction = function(e) {
55943
+ return e.getAttribute(attrName).match(new RegExp("\\b" + attrValue + "\\b"));
55944
+ };
55945
+ break;
55946
+ case "|":
55947
+ checkFunction = function(e) {
55948
+ return e.getAttribute(attrName).match(new RegExp("^" + attrValue + "-?"));
55949
+ };
55950
+ break;
55951
+ case "^":
55952
+ checkFunction = function(e) {
55953
+ return e.getAttribute(attrName).indexOf(attrValue) === 0;
55954
+ };
55955
+ break;
55956
+ case "$":
55957
+ checkFunction = function(e) {
55958
+ return e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length;
55959
+ };
55960
+ break;
55961
+ case "*":
55962
+ checkFunction = function(e) {
55963
+ return e.getAttribute(attrName).indexOf(attrValue) > -1;
55964
+ };
55965
+ break;
55966
+ default:
55967
+ checkFunction = function(e) {
55968
+ return e.getAttribute(attrName);
55969
+ };
55970
+ }
55971
+ currentContext = [];
55972
+ currentContextIndex = 0;
55973
+ for (j = 0; j < found.length; j++) {
55974
+ if (checkFunction(found[j])) {
55975
+ currentContext[currentContextIndex++] = found[j];
55976
+ }
55977
+ }
55978
+ continue;
55979
+ }
55980
+ tagName = token;
55981
+ found = [];
55982
+ foundCount = 0;
55983
+ for (j = 0; j < currentContext.length; j++) {
55984
+ elements = currentContext[j].getElementsByTagName(tagName);
55985
+ for (k = 0; k < elements.length; k++) {
55986
+ found[foundCount++] = elements[k];
55987
+ }
55988
+ }
55989
+ currentContext = found;
55990
+ }
55991
+ return currentContext;
55992
+ }
55993
+ return function(query) {
55994
+ if (_$1.isElement(query)) {
55995
+ return [query];
55996
+ } else if (_$1.isObject(query) && !_$1.isUndefined(query.length)) {
55997
+ return query;
55998
+ } else {
55999
+ return getElementsBySelector.call(this, query);
56000
+ }
56001
+ };
56002
+ }();
56003
+ var CAMPAIGN_KEYWORDS = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"];
56004
+ var CLICK_IDS = ["dclid", "fbclid", "gclid", "ko_click_id", "li_fat_id", "msclkid", "ttclid", "twclid", "wbraid"];
56005
+ _$1.info = {
56006
+ campaignParams: function(default_value) {
56007
+ var kw = "", params = {};
56008
+ _$1.each(CAMPAIGN_KEYWORDS, function(kwkey) {
56009
+ kw = _$1.getQueryParam(document$1.URL, kwkey);
56010
+ if (kw.length) {
56011
+ params[kwkey] = kw;
56012
+ } else if (default_value !== void 0) {
56013
+ params[kwkey] = default_value;
56014
+ }
56015
+ });
56016
+ return params;
56017
+ },
56018
+ clickParams: function() {
56019
+ var id = "", params = {};
56020
+ _$1.each(CLICK_IDS, function(idkey) {
56021
+ id = _$1.getQueryParam(document$1.URL, idkey);
56022
+ if (id.length) {
56023
+ params[idkey] = id;
56024
+ }
56025
+ });
56026
+ return params;
56027
+ },
56028
+ marketingParams: function() {
56029
+ return _$1.extend(_$1.info.campaignParams(), _$1.info.clickParams());
56030
+ },
56031
+ searchEngine: function(referrer) {
56032
+ if (referrer.search("https?://(.*)google.([^/?]*)") === 0) {
56033
+ return "google";
56034
+ } else if (referrer.search("https?://(.*)bing.com") === 0) {
56035
+ return "bing";
56036
+ } else if (referrer.search("https?://(.*)yahoo.com") === 0) {
56037
+ return "yahoo";
56038
+ } else if (referrer.search("https?://(.*)duckduckgo.com") === 0) {
56039
+ return "duckduckgo";
56040
+ } else {
56041
+ return null;
56042
+ }
56043
+ },
56044
+ searchInfo: function(referrer) {
56045
+ var search = _$1.info.searchEngine(referrer), param = search != "yahoo" ? "q" : "p", ret = {};
56046
+ if (search !== null) {
56047
+ ret["$search_engine"] = search;
56048
+ var keyword = _$1.getQueryParam(referrer, param);
56049
+ if (keyword.length) {
56050
+ ret["mp_keyword"] = keyword;
56051
+ }
56052
+ }
56053
+ return ret;
56054
+ },
56055
+ browser: function(user_agent, vendor, opera) {
56056
+ vendor = vendor || "";
56057
+ if (opera || _$1.includes(user_agent, " OPR/")) {
56058
+ if (_$1.includes(user_agent, "Mini")) {
56059
+ return "Opera Mini";
56060
+ }
56061
+ return "Opera";
56062
+ } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
56063
+ return "BlackBerry";
56064
+ } else if (_$1.includes(user_agent, "IEMobile") || _$1.includes(user_agent, "WPDesktop")) {
56065
+ return "Internet Explorer Mobile";
56066
+ } else if (_$1.includes(user_agent, "SamsungBrowser/")) {
56067
+ return "Samsung Internet";
56068
+ } else if (_$1.includes(user_agent, "Edge") || _$1.includes(user_agent, "Edg/")) {
56069
+ return "Microsoft Edge";
56070
+ } else if (_$1.includes(user_agent, "FBIOS")) {
56071
+ return "Facebook Mobile";
56072
+ } else if (_$1.includes(user_agent, "Chrome")) {
56073
+ return "Chrome";
56074
+ } else if (_$1.includes(user_agent, "CriOS")) {
56075
+ return "Chrome iOS";
56076
+ } else if (_$1.includes(user_agent, "UCWEB") || _$1.includes(user_agent, "UCBrowser")) {
56077
+ return "UC Browser";
56078
+ } else if (_$1.includes(user_agent, "FxiOS")) {
56079
+ return "Firefox iOS";
56080
+ } else if (_$1.includes(vendor, "Apple")) {
56081
+ if (_$1.includes(user_agent, "Mobile")) {
56082
+ return "Mobile Safari";
56083
+ }
56084
+ return "Safari";
56085
+ } else if (_$1.includes(user_agent, "Android")) {
56086
+ return "Android Mobile";
56087
+ } else if (_$1.includes(user_agent, "Konqueror")) {
56088
+ return "Konqueror";
56089
+ } else if (_$1.includes(user_agent, "Firefox")) {
56090
+ return "Firefox";
56091
+ } else if (_$1.includes(user_agent, "MSIE") || _$1.includes(user_agent, "Trident/")) {
56092
+ return "Internet Explorer";
56093
+ } else if (_$1.includes(user_agent, "Gecko")) {
56094
+ return "Mozilla";
56095
+ } else {
56096
+ return "";
56097
+ }
56098
+ },
56099
+ browserVersion: function(userAgent2, vendor, opera) {
56100
+ var browser2 = _$1.info.browser(userAgent2, vendor, opera);
56101
+ var versionRegexs = {
56102
+ "Internet Explorer Mobile": /rv:(\d+(\.\d+)?)/,
56103
+ "Microsoft Edge": /Edge?\/(\d+(\.\d+)?)/,
56104
+ "Chrome": /Chrome\/(\d+(\.\d+)?)/,
56105
+ "Chrome iOS": /CriOS\/(\d+(\.\d+)?)/,
56106
+ "UC Browser": /(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/,
56107
+ "Safari": /Version\/(\d+(\.\d+)?)/,
56108
+ "Mobile Safari": /Version\/(\d+(\.\d+)?)/,
56109
+ "Opera": /(Opera|OPR)\/(\d+(\.\d+)?)/,
56110
+ "Firefox": /Firefox\/(\d+(\.\d+)?)/,
56111
+ "Firefox iOS": /FxiOS\/(\d+(\.\d+)?)/,
56112
+ "Konqueror": /Konqueror:(\d+(\.\d+)?)/,
56113
+ "BlackBerry": /BlackBerry (\d+(\.\d+)?)/,
56114
+ "Android Mobile": /android\s(\d+(\.\d+)?)/,
56115
+ "Samsung Internet": /SamsungBrowser\/(\d+(\.\d+)?)/,
56116
+ "Internet Explorer": /(rv:|MSIE )(\d+(\.\d+)?)/,
56117
+ "Mozilla": /rv:(\d+(\.\d+)?)/
56118
+ };
56119
+ var regex = versionRegexs[browser2];
56120
+ if (regex === void 0) {
56121
+ return null;
56122
+ }
56123
+ var matches = userAgent2.match(regex);
56124
+ if (!matches) {
56125
+ return null;
56126
+ }
56127
+ return parseFloat(matches[matches.length - 2]);
56128
+ },
56129
+ os: function() {
56130
+ var a = userAgent;
56131
+ if (/Windows/i.test(a)) {
56132
+ if (/Phone/.test(a) || /WPDesktop/.test(a)) {
56133
+ return "Windows Phone";
56134
+ }
56135
+ return "Windows";
56136
+ } else if (/(iPhone|iPad|iPod)/.test(a)) {
56137
+ return "iOS";
56138
+ } else if (/Android/.test(a)) {
56139
+ return "Android";
56140
+ } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {
56141
+ return "BlackBerry";
56142
+ } else if (/Mac/i.test(a)) {
56143
+ return "Mac OS X";
56144
+ } else if (/Linux/.test(a)) {
56145
+ return "Linux";
56146
+ } else if (/CrOS/.test(a)) {
56147
+ return "Chrome OS";
56148
+ } else {
56149
+ return "";
56150
+ }
56151
+ },
56152
+ device: function(user_agent) {
56153
+ if (/Windows Phone/i.test(user_agent) || /WPDesktop/.test(user_agent)) {
56154
+ return "Windows Phone";
56155
+ } else if (/iPad/.test(user_agent)) {
56156
+ return "iPad";
56157
+ } else if (/iPod/.test(user_agent)) {
56158
+ return "iPod Touch";
56159
+ } else if (/iPhone/.test(user_agent)) {
56160
+ return "iPhone";
56161
+ } else if (/(BlackBerry|PlayBook|BB10)/i.test(user_agent)) {
56162
+ return "BlackBerry";
56163
+ } else if (/Android/.test(user_agent)) {
56164
+ return "Android";
56165
+ } else {
56166
+ return "";
56167
+ }
56168
+ },
56169
+ referringDomain: function(referrer) {
56170
+ var split = referrer.split("/");
56171
+ if (split.length >= 3) {
56172
+ return split[2];
56173
+ }
56174
+ return "";
56175
+ },
56176
+ currentUrl: function() {
56177
+ return win.location.href;
56178
+ },
56179
+ properties: function(extra_props) {
56180
+ if (typeof extra_props !== "object") {
56181
+ extra_props = {};
56182
+ }
56183
+ return _$1.extend(_$1.strip_empty_properties({
56184
+ "$os": _$1.info.os(),
56185
+ "$browser": _$1.info.browser(userAgent, navigator$1.vendor, windowOpera),
56186
+ "$referrer": document$1.referrer,
56187
+ "$referring_domain": _$1.info.referringDomain(document$1.referrer),
56188
+ "$device": _$1.info.device(userAgent)
56189
+ }), {
56190
+ "$current_url": _$1.info.currentUrl(),
56191
+ "$browser_version": _$1.info.browserVersion(userAgent, navigator$1.vendor, windowOpera),
56192
+ "$screen_height": screen.height,
56193
+ "$screen_width": screen.width,
56194
+ "mp_lib": "web",
56195
+ "$lib_version": Config.LIB_VERSION,
56196
+ "$insert_id": cheap_guid(),
56197
+ "time": _$1.timestamp() / 1e3
56198
+ }, _$1.strip_empty_properties(extra_props));
56199
+ },
56200
+ people_properties: function() {
56201
+ return _$1.extend(_$1.strip_empty_properties({
56202
+ "$os": _$1.info.os(),
56203
+ "$browser": _$1.info.browser(userAgent, navigator$1.vendor, windowOpera)
56204
+ }), {
56205
+ "$browser_version": _$1.info.browserVersion(userAgent, navigator$1.vendor, windowOpera)
56206
+ });
56207
+ },
56208
+ mpPageViewProperties: function() {
56209
+ return _$1.strip_empty_properties({
56210
+ "current_page_title": document$1.title,
56211
+ "current_domain": win.location.hostname,
56212
+ "current_url_path": win.location.pathname,
56213
+ "current_url_protocol": win.location.protocol,
56214
+ "current_url_search": win.location.search
56215
+ });
56216
+ }
56217
+ };
56218
+ var cheap_guid = function(maxlen) {
56219
+ var guid = Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10);
56220
+ return maxlen ? guid.substring(0, maxlen) : guid;
56221
+ };
56222
+ var SIMPLE_DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]*\.[a-z]+$/i;
56223
+ var DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i;
56224
+ var extract_domain = function(hostname) {
56225
+ var domain_regex = DOMAIN_MATCH_REGEX;
56226
+ var parts = hostname.split(".");
56227
+ var tld = parts[parts.length - 1];
56228
+ if (tld.length > 4 || tld === "com" || tld === "org") {
56229
+ domain_regex = SIMPLE_DOMAIN_MATCH_REGEX;
56230
+ }
56231
+ var matches = hostname.match(domain_regex);
56232
+ return matches ? matches[0] : "";
56233
+ };
56234
+ var JSONStringify = null, JSONParse = null;
56235
+ if (typeof JSON !== "undefined") {
56236
+ JSONStringify = JSON.stringify;
56237
+ JSONParse = JSON.parse;
56238
+ }
56239
+ JSONStringify = JSONStringify || _$1.JSONEncode;
56240
+ JSONParse = JSONParse || _$1.JSONDecode;
56241
+ _$1["toArray"] = _$1.toArray;
56242
+ _$1["isObject"] = _$1.isObject;
56243
+ _$1["JSONEncode"] = _$1.JSONEncode;
56244
+ _$1["JSONDecode"] = _$1.JSONDecode;
56245
+ _$1["isBlockedUA"] = _$1.isBlockedUA;
56246
+ _$1["isEmptyObject"] = _$1.isEmptyObject;
56247
+ _$1["info"] = _$1.info;
56248
+ _$1["info"]["device"] = _$1.info.device;
56249
+ _$1["info"]["browser"] = _$1.info.browser;
56250
+ _$1["info"]["browserVersion"] = _$1.info.browserVersion;
56251
+ _$1["info"]["properties"] = _$1.info.properties;
56252
+ var DomTracker = function() {
56253
+ };
56254
+ DomTracker.prototype.create_properties = function() {
56255
+ };
56256
+ DomTracker.prototype.event_handler = function() {
56257
+ };
56258
+ DomTracker.prototype.after_track_handler = function() {
56259
+ };
56260
+ DomTracker.prototype.init = function(mixpanel_instance) {
56261
+ this.mp = mixpanel_instance;
56262
+ return this;
56263
+ };
56264
+ DomTracker.prototype.track = function(query, event_name, properties, user_callback) {
56265
+ var that = this;
56266
+ var elements = _$1.dom_query(query);
56267
+ if (elements.length === 0) {
56268
+ console$1.error("The DOM query (" + query + ") returned 0 elements");
56269
+ return;
56270
+ }
56271
+ _$1.each(elements, function(element) {
56272
+ _$1.register_event(element, this.override_event, function(e) {
56273
+ var options = {};
56274
+ var props = that.create_properties(properties, this);
56275
+ var timeout = that.mp.get_config("track_links_timeout");
56276
+ that.event_handler(e, this, options);
56277
+ window.setTimeout(that.track_callback(user_callback, props, options, true), timeout);
56278
+ that.mp.track(event_name, props, that.track_callback(user_callback, props, options));
56279
+ });
56280
+ }, this);
56281
+ return true;
56282
+ };
56283
+ DomTracker.prototype.track_callback = function(user_callback, props, options, timeout_occured) {
56284
+ timeout_occured = timeout_occured || false;
56285
+ var that = this;
56286
+ return function() {
56287
+ if (options.callback_fired) {
56288
+ return;
56289
+ }
56290
+ options.callback_fired = true;
56291
+ if (user_callback && user_callback(timeout_occured, props) === false) {
56292
+ return;
56293
+ }
56294
+ that.after_track_handler(props, options, timeout_occured);
56295
+ };
56296
+ };
56297
+ DomTracker.prototype.create_properties = function(properties, element) {
56298
+ var props;
56299
+ if (typeof properties === "function") {
56300
+ props = properties(element);
56301
+ } else {
56302
+ props = _$1.extend({}, properties);
56303
+ }
56304
+ return props;
56305
+ };
56306
+ var LinkTracker = function() {
56307
+ this.override_event = "click";
56308
+ };
56309
+ _$1.inherit(LinkTracker, DomTracker);
56310
+ LinkTracker.prototype.create_properties = function(properties, element) {
56311
+ var props = LinkTracker.superclass.create_properties.apply(this, arguments);
56312
+ if (element.href) {
56313
+ props["url"] = element.href;
56314
+ }
56315
+ return props;
56316
+ };
56317
+ LinkTracker.prototype.event_handler = function(evt, element, options) {
56318
+ options.new_tab = evt.which === 2 || evt.metaKey || evt.ctrlKey || element.target === "_blank";
56319
+ options.href = element.href;
56320
+ if (!options.new_tab) {
56321
+ evt.preventDefault();
56322
+ }
56323
+ };
56324
+ LinkTracker.prototype.after_track_handler = function(props, options) {
56325
+ if (options.new_tab) {
56326
+ return;
56327
+ }
56328
+ setTimeout(function() {
56329
+ window.location = options.href;
56330
+ }, 0);
56331
+ };
56332
+ var FormTracker = function() {
56333
+ this.override_event = "submit";
56334
+ };
56335
+ _$1.inherit(FormTracker, DomTracker);
56336
+ FormTracker.prototype.event_handler = function(evt, element, options) {
56337
+ options.element = element;
56338
+ evt.preventDefault();
56339
+ };
56340
+ FormTracker.prototype.after_track_handler = function(props, options) {
56341
+ setTimeout(function() {
56342
+ options.element.submit();
56343
+ }, 0);
56344
+ };
56345
+ var logger$2 = console_with_prefix("lock");
56346
+ var SharedLock = function(key, options) {
56347
+ options = options || {};
56348
+ this.storageKey = key;
56349
+ this.storage = options.storage || window.localStorage;
56350
+ this.pollIntervalMS = options.pollIntervalMS || 100;
56351
+ this.timeoutMS = options.timeoutMS || 2e3;
56352
+ };
56353
+ SharedLock.prototype.withLock = function(lockedCB, errorCB, pid) {
56354
+ if (!pid && typeof errorCB !== "function") {
56355
+ pid = errorCB;
56356
+ errorCB = null;
56357
+ }
56358
+ var i2 = pid || new Date().getTime() + "|" + Math.random();
56359
+ var startTime2 = new Date().getTime();
56360
+ var key = this.storageKey;
56361
+ var pollIntervalMS = this.pollIntervalMS;
56362
+ var timeoutMS = this.timeoutMS;
56363
+ var storage = this.storage;
56364
+ var keyX = key + ":X";
56365
+ var keyY = key + ":Y";
56366
+ var keyZ = key + ":Z";
56367
+ var reportError = function(err) {
56368
+ errorCB && errorCB(err);
56369
+ };
56370
+ var delay = function(cb) {
56371
+ if (new Date().getTime() - startTime2 > timeoutMS) {
56372
+ logger$2.error("Timeout waiting for mutex on " + key + "; clearing lock. [" + i2 + "]");
56373
+ storage.removeItem(keyZ);
56374
+ storage.removeItem(keyY);
56375
+ loop();
56376
+ return;
56377
+ }
56378
+ setTimeout(function() {
56379
+ try {
56380
+ cb();
56381
+ } catch (err) {
56382
+ reportError(err);
56383
+ }
56384
+ }, pollIntervalMS * (Math.random() + 0.1));
56385
+ };
56386
+ var waitFor = function(predicate, cb) {
56387
+ if (predicate()) {
56388
+ cb();
56389
+ } else {
56390
+ delay(function() {
56391
+ waitFor(predicate, cb);
56392
+ });
56393
+ }
56394
+ };
56395
+ var getSetY = function() {
56396
+ var valY = storage.getItem(keyY);
56397
+ if (valY && valY !== i2) {
56398
+ return false;
56399
+ } else {
56400
+ storage.setItem(keyY, i2);
56401
+ if (storage.getItem(keyY) === i2) {
56402
+ return true;
56403
+ } else {
56404
+ if (!localStorageSupported(storage, true)) {
56405
+ throw new Error("localStorage support dropped while acquiring lock");
56406
+ }
56407
+ return false;
56408
+ }
56409
+ }
56410
+ };
56411
+ var loop = function() {
56412
+ storage.setItem(keyX, i2);
56413
+ waitFor(getSetY, function() {
56414
+ if (storage.getItem(keyX) === i2) {
56415
+ criticalSection();
56416
+ return;
56417
+ }
56418
+ delay(function() {
56419
+ if (storage.getItem(keyY) !== i2) {
56420
+ loop();
56421
+ return;
56422
+ }
56423
+ waitFor(function() {
56424
+ return !storage.getItem(keyZ);
56425
+ }, criticalSection);
56426
+ });
56427
+ });
56428
+ };
56429
+ var criticalSection = function() {
56430
+ storage.setItem(keyZ, "1");
56431
+ try {
56432
+ lockedCB();
56433
+ } finally {
56434
+ storage.removeItem(keyZ);
56435
+ if (storage.getItem(keyY) === i2) {
56436
+ storage.removeItem(keyY);
56437
+ }
56438
+ if (storage.getItem(keyX) === i2) {
56439
+ storage.removeItem(keyX);
56440
+ }
56441
+ }
56442
+ };
56443
+ try {
56444
+ if (localStorageSupported(storage, true)) {
56445
+ loop();
56446
+ } else {
56447
+ throw new Error("localStorage support check failed");
56448
+ }
56449
+ } catch (err) {
56450
+ reportError(err);
56451
+ }
56452
+ };
56453
+ var logger$1 = console_with_prefix("batch");
56454
+ var RequestQueue = function(storageKey, options) {
56455
+ options = options || {};
56456
+ this.storageKey = storageKey;
56457
+ this.storage = options.storage || window.localStorage;
56458
+ this.reportError = options.errorReporter || _$1.bind(logger$1.error, logger$1);
56459
+ this.lock = new SharedLock(storageKey, { storage: this.storage });
56460
+ this.pid = options.pid || null;
56461
+ this.memQueue = [];
56462
+ };
56463
+ RequestQueue.prototype.enqueue = function(item, flushInterval, cb) {
56464
+ var queueEntry = {
56465
+ "id": cheap_guid(),
56466
+ "flushAfter": new Date().getTime() + flushInterval * 2,
56467
+ "payload": item
56468
+ };
56469
+ this.lock.withLock(_$1.bind(function lockAcquired() {
56470
+ var succeeded;
56471
+ try {
56472
+ var storedQueue = this.readFromStorage();
56473
+ storedQueue.push(queueEntry);
56474
+ succeeded = this.saveToStorage(storedQueue);
56475
+ if (succeeded) {
56476
+ this.memQueue.push(queueEntry);
56477
+ }
56478
+ } catch (err) {
56479
+ this.reportError("Error enqueueing item", item);
56480
+ succeeded = false;
56481
+ }
56482
+ if (cb) {
56483
+ cb(succeeded);
56484
+ }
56485
+ }, this), _$1.bind(function lockFailure(err) {
56486
+ this.reportError("Error acquiring storage lock", err);
56487
+ if (cb) {
56488
+ cb(false);
56489
+ }
56490
+ }, this), this.pid);
56491
+ };
56492
+ RequestQueue.prototype.fillBatch = function(batchSize) {
56493
+ var batch = this.memQueue.slice(0, batchSize);
56494
+ if (batch.length < batchSize) {
56495
+ var storedQueue = this.readFromStorage();
56496
+ if (storedQueue.length) {
56497
+ var idsInBatch = {};
56498
+ _$1.each(batch, function(item2) {
56499
+ idsInBatch[item2["id"]] = true;
56500
+ });
56501
+ for (var i2 = 0; i2 < storedQueue.length; i2++) {
56502
+ var item = storedQueue[i2];
56503
+ if (new Date().getTime() > item["flushAfter"] && !idsInBatch[item["id"]]) {
56504
+ item.orphaned = true;
56505
+ batch.push(item);
56506
+ if (batch.length >= batchSize) {
56507
+ break;
56508
+ }
56509
+ }
56510
+ }
56511
+ }
56512
+ }
56513
+ return batch;
56514
+ };
56515
+ var filterOutIDsAndInvalid = function(items, idSet) {
56516
+ var filteredItems = [];
56517
+ _$1.each(items, function(item) {
56518
+ if (item["id"] && !idSet[item["id"]]) {
56519
+ filteredItems.push(item);
56520
+ }
56521
+ });
56522
+ return filteredItems;
56523
+ };
56524
+ RequestQueue.prototype.removeItemsByID = function(ids, cb) {
56525
+ var idSet = {};
56526
+ _$1.each(ids, function(id) {
56527
+ idSet[id] = true;
56528
+ });
56529
+ this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
56530
+ var removeFromStorage = _$1.bind(function() {
56531
+ var succeeded;
56532
+ try {
56533
+ var storedQueue = this.readFromStorage();
56534
+ storedQueue = filterOutIDsAndInvalid(storedQueue, idSet);
56535
+ succeeded = this.saveToStorage(storedQueue);
56536
+ if (succeeded) {
56537
+ storedQueue = this.readFromStorage();
56538
+ for (var i2 = 0; i2 < storedQueue.length; i2++) {
56539
+ var item = storedQueue[i2];
56540
+ if (item["id"] && !!idSet[item["id"]]) {
56541
+ this.reportError("Item not removed from storage");
56542
+ return false;
56543
+ }
56544
+ }
56545
+ }
56546
+ } catch (err) {
56547
+ this.reportError("Error removing items", ids);
56548
+ succeeded = false;
56549
+ }
56550
+ return succeeded;
56551
+ }, this);
56552
+ this.lock.withLock(function lockAcquired() {
56553
+ var succeeded = removeFromStorage();
56554
+ if (cb) {
56555
+ cb(succeeded);
56556
+ }
56557
+ }, _$1.bind(function lockFailure(err) {
56558
+ var succeeded = false;
56559
+ this.reportError("Error acquiring storage lock", err);
56560
+ if (!localStorageSupported(this.storage, true)) {
56561
+ succeeded = removeFromStorage();
56562
+ if (!succeeded) {
56563
+ try {
56564
+ this.storage.removeItem(this.storageKey);
56565
+ } catch (err2) {
56566
+ this.reportError("Error clearing queue", err2);
56567
+ }
56568
+ }
56569
+ }
56570
+ if (cb) {
56571
+ cb(succeeded);
56572
+ }
56573
+ }, this), this.pid);
56574
+ };
56575
+ var updatePayloads = function(existingItems, itemsToUpdate) {
56576
+ var newItems = [];
56577
+ _$1.each(existingItems, function(item) {
56578
+ var id = item["id"];
56579
+ if (id in itemsToUpdate) {
56580
+ var newPayload = itemsToUpdate[id];
56581
+ if (newPayload !== null) {
56582
+ item["payload"] = newPayload;
56583
+ newItems.push(item);
56584
+ }
56585
+ } else {
56586
+ newItems.push(item);
56587
+ }
56588
+ });
56589
+ return newItems;
56590
+ };
56591
+ RequestQueue.prototype.updatePayloads = function(itemsToUpdate, cb) {
56592
+ this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
56593
+ this.lock.withLock(_$1.bind(function lockAcquired() {
56594
+ var succeeded;
56595
+ try {
56596
+ var storedQueue = this.readFromStorage();
56597
+ storedQueue = updatePayloads(storedQueue, itemsToUpdate);
56598
+ succeeded = this.saveToStorage(storedQueue);
56599
+ } catch (err) {
56600
+ this.reportError("Error updating items", itemsToUpdate);
56601
+ succeeded = false;
56602
+ }
56603
+ if (cb) {
56604
+ cb(succeeded);
56605
+ }
56606
+ }, this), _$1.bind(function lockFailure(err) {
56607
+ this.reportError("Error acquiring storage lock", err);
56608
+ if (cb) {
56609
+ cb(false);
56610
+ }
56611
+ }, this), this.pid);
56612
+ };
56613
+ RequestQueue.prototype.readFromStorage = function() {
56614
+ var storageEntry;
56615
+ try {
56616
+ storageEntry = this.storage.getItem(this.storageKey);
56617
+ if (storageEntry) {
56618
+ storageEntry = JSONParse(storageEntry);
56619
+ if (!_$1.isArray(storageEntry)) {
56620
+ this.reportError("Invalid storage entry:", storageEntry);
56621
+ storageEntry = null;
56622
+ }
56623
+ }
56624
+ } catch (err) {
56625
+ this.reportError("Error retrieving queue", err);
56626
+ storageEntry = null;
56627
+ }
56628
+ return storageEntry || [];
56629
+ };
56630
+ RequestQueue.prototype.saveToStorage = function(queue) {
56631
+ try {
56632
+ this.storage.setItem(this.storageKey, JSONStringify(queue));
56633
+ return true;
56634
+ } catch (err) {
56635
+ this.reportError("Error saving queue", err);
56636
+ return false;
56637
+ }
56638
+ };
56639
+ RequestQueue.prototype.clear = function() {
56640
+ this.memQueue = [];
56641
+ this.storage.removeItem(this.storageKey);
56642
+ };
56643
+ var MAX_RETRY_INTERVAL_MS = 10 * 60 * 1e3;
56644
+ var logger = console_with_prefix("batch");
56645
+ var RequestBatcher = function(storageKey, options) {
56646
+ this.errorReporter = options.errorReporter;
56647
+ this.queue = new RequestQueue(storageKey, {
56648
+ errorReporter: _$1.bind(this.reportError, this),
56649
+ storage: options.storage
56650
+ });
56651
+ this.libConfig = options.libConfig;
56652
+ this.sendRequest = options.sendRequestFunc;
56653
+ this.beforeSendHook = options.beforeSendHook;
56654
+ this.stopAllBatching = options.stopAllBatchingFunc;
56655
+ this.batchSize = this.libConfig["batch_size"];
56656
+ this.flushInterval = this.libConfig["batch_flush_interval_ms"];
56657
+ this.stopped = !this.libConfig["batch_autostart"];
56658
+ this.consecutiveRemovalFailures = 0;
56659
+ this.itemIdsSentSuccessfully = {};
56660
+ };
56661
+ RequestBatcher.prototype.enqueue = function(item, cb) {
56662
+ this.queue.enqueue(item, this.flushInterval, cb);
56663
+ };
56664
+ RequestBatcher.prototype.start = function() {
56665
+ this.stopped = false;
56666
+ this.consecutiveRemovalFailures = 0;
56667
+ this.flush();
56668
+ };
56669
+ RequestBatcher.prototype.stop = function() {
56670
+ this.stopped = true;
56671
+ if (this.timeoutID) {
56672
+ clearTimeout(this.timeoutID);
56673
+ this.timeoutID = null;
56674
+ }
56675
+ };
56676
+ RequestBatcher.prototype.clear = function() {
56677
+ this.queue.clear();
56678
+ };
56679
+ RequestBatcher.prototype.resetBatchSize = function() {
56680
+ this.batchSize = this.libConfig["batch_size"];
56681
+ };
56682
+ RequestBatcher.prototype.resetFlush = function() {
56683
+ this.scheduleFlush(this.libConfig["batch_flush_interval_ms"]);
56684
+ };
56685
+ RequestBatcher.prototype.scheduleFlush = function(flushMS) {
56686
+ this.flushInterval = flushMS;
56687
+ if (!this.stopped) {
56688
+ this.timeoutID = setTimeout(_$1.bind(this.flush, this), this.flushInterval);
56689
+ }
56690
+ };
56691
+ RequestBatcher.prototype.flush = function(options) {
56692
+ try {
56693
+ if (this.requestInProgress) {
56694
+ logger.log("Flush: Request already in progress");
56695
+ return;
56696
+ }
56697
+ options = options || {};
56698
+ var timeoutMS = this.libConfig["batch_request_timeout_ms"];
56699
+ var startTime2 = new Date().getTime();
56700
+ var currentBatchSize = this.batchSize;
56701
+ var batch = this.queue.fillBatch(currentBatchSize);
56702
+ var dataForRequest = [];
56703
+ var transformedItems = {};
56704
+ _$1.each(batch, function(item) {
56705
+ var payload = item["payload"];
56706
+ if (this.beforeSendHook && !item.orphaned) {
56707
+ payload = this.beforeSendHook(payload);
56708
+ }
56709
+ if (payload) {
56710
+ if (payload["event"] && payload["properties"]) {
56711
+ payload["properties"] = _$1.extend(
56712
+ {},
56713
+ payload["properties"],
56714
+ { "mp_sent_by_lib_version": Config.LIB_VERSION }
56715
+ );
56716
+ }
56717
+ var addPayload = true;
56718
+ var itemId = item["id"];
56719
+ if (itemId) {
56720
+ if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
56721
+ this.reportError("[dupe] item ID sent too many times, not sending", {
56722
+ item,
56723
+ batchSize: batch.length,
56724
+ timesSent: this.itemIdsSentSuccessfully[itemId]
56725
+ });
56726
+ addPayload = false;
56727
+ }
56728
+ } else {
56729
+ this.reportError("[dupe] found item with no ID", { item });
56730
+ }
56731
+ if (addPayload) {
56732
+ dataForRequest.push(payload);
56733
+ }
56734
+ }
56735
+ transformedItems[item["id"]] = payload;
56736
+ }, this);
56737
+ if (dataForRequest.length < 1) {
56738
+ this.resetFlush();
56739
+ return;
56740
+ }
56741
+ this.requestInProgress = true;
56742
+ var batchSendCallback = _$1.bind(function(res) {
56743
+ this.requestInProgress = false;
56744
+ try {
56745
+ var removeItemsFromQueue = false;
56746
+ if (options.unloading) {
56747
+ this.queue.updatePayloads(transformedItems);
56748
+ } else if (_$1.isObject(res) && res.error === "timeout" && new Date().getTime() - startTime2 >= timeoutMS) {
56749
+ this.reportError("Network timeout; retrying");
56750
+ this.flush();
56751
+ } else if (_$1.isObject(res) && res.xhr_req && (res.xhr_req["status"] >= 500 || res.xhr_req["status"] === 429 || res.error === "timeout")) {
56752
+ var retryMS = this.flushInterval * 2;
56753
+ var headers = res.xhr_req["responseHeaders"];
56754
+ if (headers) {
56755
+ var retryAfter = headers["Retry-After"];
56756
+ if (retryAfter) {
56757
+ retryMS = parseInt(retryAfter, 10) * 1e3 || retryMS;
56758
+ }
56759
+ }
56760
+ retryMS = Math.min(MAX_RETRY_INTERVAL_MS, retryMS);
56761
+ this.reportError("Error; retry in " + retryMS + " ms");
56762
+ this.scheduleFlush(retryMS);
56763
+ } else if (_$1.isObject(res) && res.xhr_req && res.xhr_req["status"] === 413) {
56764
+ if (batch.length > 1) {
56765
+ var halvedBatchSize = Math.max(1, Math.floor(currentBatchSize / 2));
56766
+ this.batchSize = Math.min(this.batchSize, halvedBatchSize, batch.length - 1);
56767
+ this.reportError("413 response; reducing batch size to " + this.batchSize);
56768
+ this.resetFlush();
56769
+ } else {
56770
+ this.reportError("Single-event request too large; dropping", batch);
56771
+ this.resetBatchSize();
56772
+ removeItemsFromQueue = true;
56773
+ }
56774
+ } else {
56775
+ removeItemsFromQueue = true;
56776
+ }
56777
+ if (removeItemsFromQueue) {
56778
+ this.queue.removeItemsByID(
56779
+ _$1.map(batch, function(item) {
56780
+ return item["id"];
56781
+ }),
56782
+ _$1.bind(function(succeeded) {
56783
+ if (succeeded) {
56784
+ this.consecutiveRemovalFailures = 0;
56785
+ this.flush();
56786
+ } else {
56787
+ this.reportError("Failed to remove items from queue");
56788
+ if (++this.consecutiveRemovalFailures > 5) {
56789
+ this.reportError("Too many queue failures; disabling batching system.");
56790
+ this.stopAllBatching();
56791
+ } else {
56792
+ this.resetFlush();
56793
+ }
56794
+ }
56795
+ }, this)
56796
+ );
56797
+ _$1.each(batch, _$1.bind(function(item) {
56798
+ var itemId = item["id"];
56799
+ if (itemId) {
56800
+ this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
56801
+ this.itemIdsSentSuccessfully[itemId]++;
56802
+ if (this.itemIdsSentSuccessfully[itemId] > 5) {
56803
+ this.reportError("[dupe] item ID sent too many times", {
56804
+ item,
56805
+ batchSize: batch.length,
56806
+ timesSent: this.itemIdsSentSuccessfully[itemId]
56807
+ });
56808
+ }
56809
+ } else {
56810
+ this.reportError("[dupe] found item with no ID while removing", { item });
56811
+ }
56812
+ }, this));
56813
+ }
56814
+ } catch (err) {
56815
+ this.reportError("Error handling API response", err);
56816
+ this.resetFlush();
56817
+ }
56818
+ }, this);
56819
+ var requestOptions = {
56820
+ method: "POST",
56821
+ verbose: true,
56822
+ ignore_json_errors: true,
56823
+ timeout_ms: timeoutMS
56824
+ };
56825
+ if (options.unloading) {
56826
+ requestOptions.transport = "sendBeacon";
56827
+ }
56828
+ logger.log("MIXPANEL REQUEST:", dataForRequest);
56829
+ this.sendRequest(dataForRequest, requestOptions, batchSendCallback);
56830
+ } catch (err) {
56831
+ this.reportError("Error flushing request queue", err);
56832
+ this.resetFlush();
56833
+ }
56834
+ };
56835
+ RequestBatcher.prototype.reportError = function(msg, err) {
56836
+ logger.error.apply(logger.error, arguments);
56837
+ if (this.errorReporter) {
56838
+ try {
56839
+ if (!(err instanceof Error)) {
56840
+ err = new Error(msg);
56841
+ }
56842
+ this.errorReporter(msg, err);
56843
+ } catch (err2) {
56844
+ logger.error(err2);
56845
+ }
56846
+ }
56847
+ };
56848
+ var GDPR_DEFAULT_PERSISTENCE_PREFIX = "__mp_opt_in_out_";
56849
+ function optIn(token, options) {
56850
+ _optInOut(true, token, options);
56851
+ }
56852
+ function optOut(token, options) {
56853
+ _optInOut(false, token, options);
56854
+ }
56855
+ function hasOptedIn(token, options) {
56856
+ return _getStorageValue(token, options) === "1";
56857
+ }
56858
+ function hasOptedOut(token, options) {
56859
+ if (_hasDoNotTrackFlagOn(options)) {
56860
+ console$1.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"');
56861
+ return true;
56862
+ }
56863
+ var optedOut = _getStorageValue(token, options) === "0";
56864
+ if (optedOut) {
56865
+ console$1.warn("You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.");
56866
+ }
56867
+ return optedOut;
56868
+ }
56869
+ function addOptOutCheckMixpanelLib(method) {
56870
+ return _addOptOutCheck(method, function(name2) {
56871
+ return this.get_config(name2);
56872
+ });
56873
+ }
56874
+ function addOptOutCheckMixpanelPeople(method) {
56875
+ return _addOptOutCheck(method, function(name2) {
56876
+ return this._get_config(name2);
56877
+ });
56878
+ }
56879
+ function addOptOutCheckMixpanelGroup(method) {
56880
+ return _addOptOutCheck(method, function(name2) {
56881
+ return this._get_config(name2);
56882
+ });
56883
+ }
56884
+ function clearOptInOut(token, options) {
56885
+ options = options || {};
56886
+ _getStorage(options).remove(
56887
+ _getStorageKey(token, options),
56888
+ !!options.crossSubdomainCookie,
56889
+ options.cookieDomain
56890
+ );
56891
+ }
56892
+ function _getStorage(options) {
56893
+ options = options || {};
56894
+ return options.persistenceType === "localStorage" ? _$1.localStorage : _$1.cookie;
56895
+ }
56896
+ function _getStorageKey(token, options) {
56897
+ options = options || {};
56898
+ return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
56899
+ }
56900
+ function _getStorageValue(token, options) {
56901
+ return _getStorage(options).get(_getStorageKey(token, options));
56902
+ }
56903
+ function _hasDoNotTrackFlagOn(options) {
56904
+ if (options && options.ignoreDnt) {
56905
+ return false;
56906
+ }
56907
+ var win$12 = options && options.window || win;
56908
+ var nav = win$12["navigator"] || {};
56909
+ var hasDntOn = false;
56910
+ _$1.each([
56911
+ nav["doNotTrack"],
56912
+ nav["msDoNotTrack"],
56913
+ win$12["doNotTrack"]
56914
+ ], function(dntValue) {
56915
+ if (_$1.includes([true, 1, "1", "yes"], dntValue)) {
56916
+ hasDntOn = true;
56917
+ }
56918
+ });
56919
+ return hasDntOn;
56920
+ }
56921
+ function _optInOut(optValue, token, options) {
56922
+ if (!_$1.isString(token) || !token.length) {
56923
+ console$1.error("gdpr." + (optValue ? "optIn" : "optOut") + " called with an invalid token");
56924
+ return;
56925
+ }
56926
+ options = options || {};
56927
+ _getStorage(options).set(
56928
+ _getStorageKey(token, options),
56929
+ optValue ? 1 : 0,
56930
+ _$1.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
56931
+ !!options.crossSubdomainCookie,
56932
+ !!options.secureCookie,
56933
+ !!options.crossSiteCookie,
56934
+ options.cookieDomain
56935
+ );
56936
+ if (options.track && optValue) {
56937
+ options.track(options.trackEventName || "$opt_in", options.trackProperties, {
56938
+ "send_immediately": true
56939
+ });
56940
+ }
56941
+ }
56942
+ function _addOptOutCheck(method, getConfigValue) {
56943
+ return function() {
56944
+ var optedOut = false;
56945
+ try {
56946
+ var token = getConfigValue.call(this, "token");
56947
+ var ignoreDnt = getConfigValue.call(this, "ignore_dnt");
56948
+ var persistenceType = getConfigValue.call(this, "opt_out_tracking_persistence_type");
56949
+ var persistencePrefix = getConfigValue.call(this, "opt_out_tracking_cookie_prefix");
56950
+ var win2 = getConfigValue.call(this, "window");
56951
+ if (token) {
56952
+ optedOut = hasOptedOut(token, {
56953
+ ignoreDnt,
56954
+ persistenceType,
56955
+ persistencePrefix,
56956
+ window: win2
56957
+ });
56958
+ }
56959
+ } catch (err) {
56960
+ console$1.error("Unexpected error when checking tracking opt-out status: " + err);
56961
+ }
56962
+ if (!optedOut) {
56963
+ return method.apply(this, arguments);
56964
+ }
56965
+ var callback = arguments[arguments.length - 1];
56966
+ if (typeof callback === "function") {
56967
+ callback(0);
56968
+ }
56969
+ return;
56970
+ };
56971
+ }
56972
+ var SET_ACTION = "$set";
56973
+ var SET_ONCE_ACTION = "$set_once";
56974
+ var UNSET_ACTION = "$unset";
56975
+ var ADD_ACTION = "$add";
56976
+ var APPEND_ACTION = "$append";
56977
+ var UNION_ACTION = "$union";
56978
+ var REMOVE_ACTION = "$remove";
56979
+ var DELETE_ACTION = "$delete";
56980
+ var apiActions = {
56981
+ set_action: function(prop, to) {
56982
+ var data = {};
56983
+ var $set = {};
56984
+ if (_$1.isObject(prop)) {
56985
+ _$1.each(prop, function(v, k) {
56986
+ if (!this._is_reserved_property(k)) {
56987
+ $set[k] = v;
56988
+ }
56989
+ }, this);
56990
+ } else {
56991
+ $set[prop] = to;
56992
+ }
56993
+ data[SET_ACTION] = $set;
56994
+ return data;
56995
+ },
56996
+ unset_action: function(prop) {
56997
+ var data = {};
56998
+ var $unset = [];
56999
+ if (!_$1.isArray(prop)) {
57000
+ prop = [prop];
57001
+ }
57002
+ _$1.each(prop, function(k) {
57003
+ if (!this._is_reserved_property(k)) {
57004
+ $unset.push(k);
57005
+ }
57006
+ }, this);
57007
+ data[UNSET_ACTION] = $unset;
57008
+ return data;
57009
+ },
57010
+ set_once_action: function(prop, to) {
57011
+ var data = {};
57012
+ var $set_once = {};
57013
+ if (_$1.isObject(prop)) {
57014
+ _$1.each(prop, function(v, k) {
57015
+ if (!this._is_reserved_property(k)) {
57016
+ $set_once[k] = v;
57017
+ }
57018
+ }, this);
57019
+ } else {
57020
+ $set_once[prop] = to;
57021
+ }
57022
+ data[SET_ONCE_ACTION] = $set_once;
57023
+ return data;
57024
+ },
57025
+ union_action: function(list_name, values2) {
57026
+ var data = {};
57027
+ var $union = {};
57028
+ if (_$1.isObject(list_name)) {
57029
+ _$1.each(list_name, function(v, k) {
57030
+ if (!this._is_reserved_property(k)) {
57031
+ $union[k] = _$1.isArray(v) ? v : [v];
57032
+ }
57033
+ }, this);
57034
+ } else {
57035
+ $union[list_name] = _$1.isArray(values2) ? values2 : [values2];
57036
+ }
57037
+ data[UNION_ACTION] = $union;
57038
+ return data;
57039
+ },
57040
+ append_action: function(list_name, value) {
57041
+ var data = {};
57042
+ var $append = {};
57043
+ if (_$1.isObject(list_name)) {
57044
+ _$1.each(list_name, function(v, k) {
57045
+ if (!this._is_reserved_property(k)) {
57046
+ $append[k] = v;
57047
+ }
57048
+ }, this);
57049
+ } else {
57050
+ $append[list_name] = value;
57051
+ }
57052
+ data[APPEND_ACTION] = $append;
57053
+ return data;
57054
+ },
57055
+ remove_action: function(list_name, value) {
57056
+ var data = {};
57057
+ var $remove = {};
57058
+ if (_$1.isObject(list_name)) {
57059
+ _$1.each(list_name, function(v, k) {
57060
+ if (!this._is_reserved_property(k)) {
57061
+ $remove[k] = v;
57062
+ }
57063
+ }, this);
57064
+ } else {
57065
+ $remove[list_name] = value;
57066
+ }
57067
+ data[REMOVE_ACTION] = $remove;
57068
+ return data;
57069
+ },
57070
+ delete_action: function() {
57071
+ var data = {};
57072
+ data[DELETE_ACTION] = "";
57073
+ return data;
57074
+ }
57075
+ };
57076
+ var MixpanelGroup = function() {
57077
+ };
57078
+ _$1.extend(MixpanelGroup.prototype, apiActions);
57079
+ MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id) {
57080
+ this._mixpanel = mixpanel_instance;
57081
+ this._group_key = group_key;
57082
+ this._group_id = group_id;
57083
+ };
57084
+ MixpanelGroup.prototype.set = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
57085
+ var data = this.set_action(prop, to);
57086
+ if (_$1.isObject(prop)) {
57087
+ callback = to;
57088
+ }
57089
+ return this._send_request(data, callback);
57090
+ });
57091
+ MixpanelGroup.prototype.set_once = addOptOutCheckMixpanelGroup(function(prop, to, callback) {
57092
+ var data = this.set_once_action(prop, to);
57093
+ if (_$1.isObject(prop)) {
57094
+ callback = to;
57095
+ }
57096
+ return this._send_request(data, callback);
57097
+ });
57098
+ MixpanelGroup.prototype.unset = addOptOutCheckMixpanelGroup(function(prop, callback) {
57099
+ var data = this.unset_action(prop);
57100
+ return this._send_request(data, callback);
57101
+ });
57102
+ MixpanelGroup.prototype.union = addOptOutCheckMixpanelGroup(function(list_name, values2, callback) {
57103
+ if (_$1.isObject(list_name)) {
57104
+ callback = values2;
57105
+ }
57106
+ var data = this.union_action(list_name, values2);
57107
+ return this._send_request(data, callback);
57108
+ });
57109
+ MixpanelGroup.prototype["delete"] = addOptOutCheckMixpanelGroup(function(callback) {
57110
+ var data = this.delete_action();
57111
+ return this._send_request(data, callback);
57112
+ });
57113
+ MixpanelGroup.prototype.remove = addOptOutCheckMixpanelGroup(function(list_name, value, callback) {
57114
+ var data = this.remove_action(list_name, value);
57115
+ return this._send_request(data, callback);
57116
+ });
57117
+ MixpanelGroup.prototype._send_request = function(data, callback) {
57118
+ data["$group_key"] = this._group_key;
57119
+ data["$group_id"] = this._group_id;
57120
+ data["$token"] = this._get_config("token");
57121
+ var date_encoded_data = _$1.encodeDates(data);
57122
+ return this._mixpanel._track_or_batch({
57123
+ type: "groups",
57124
+ data: date_encoded_data,
57125
+ endpoint: this._get_config("api_host") + "/" + this._get_config("api_routes")["groups"],
57126
+ batcher: this._mixpanel.request_batchers.groups
57127
+ }, callback);
57128
+ };
57129
+ MixpanelGroup.prototype._is_reserved_property = function(prop) {
57130
+ return prop === "$group_key" || prop === "$group_id";
57131
+ };
57132
+ MixpanelGroup.prototype._get_config = function(conf) {
57133
+ return this._mixpanel.get_config(conf);
57134
+ };
57135
+ MixpanelGroup.prototype.toString = function() {
57136
+ return this._mixpanel.toString() + ".group." + this._group_key + "." + this._group_id;
57137
+ };
57138
+ MixpanelGroup.prototype["remove"] = MixpanelGroup.prototype.remove;
57139
+ MixpanelGroup.prototype["set"] = MixpanelGroup.prototype.set;
57140
+ MixpanelGroup.prototype["set_once"] = MixpanelGroup.prototype.set_once;
57141
+ MixpanelGroup.prototype["union"] = MixpanelGroup.prototype.union;
57142
+ MixpanelGroup.prototype["unset"] = MixpanelGroup.prototype.unset;
57143
+ MixpanelGroup.prototype["toString"] = MixpanelGroup.prototype.toString;
57144
+ var MixpanelPeople = function() {
57145
+ };
57146
+ _$1.extend(MixpanelPeople.prototype, apiActions);
57147
+ MixpanelPeople.prototype._init = function(mixpanel_instance) {
57148
+ this._mixpanel = mixpanel_instance;
57149
+ };
57150
+ MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
57151
+ var data = this.set_action(prop, to);
57152
+ if (_$1.isObject(prop)) {
57153
+ callback = to;
57154
+ }
57155
+ if (this._get_config("save_referrer")) {
57156
+ this._mixpanel["persistence"].update_referrer_info(document.referrer);
57157
+ }
57158
+ data[SET_ACTION] = _$1.extend(
57159
+ {},
57160
+ _$1.info.people_properties(),
57161
+ data[SET_ACTION]
57162
+ );
57163
+ return this._send_request(data, callback);
57164
+ });
57165
+ MixpanelPeople.prototype.set_once = addOptOutCheckMixpanelPeople(function(prop, to, callback) {
57166
+ var data = this.set_once_action(prop, to);
57167
+ if (_$1.isObject(prop)) {
57168
+ callback = to;
57169
+ }
57170
+ return this._send_request(data, callback);
57171
+ });
57172
+ MixpanelPeople.prototype.unset = addOptOutCheckMixpanelPeople(function(prop, callback) {
57173
+ var data = this.unset_action(prop);
57174
+ return this._send_request(data, callback);
57175
+ });
57176
+ MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop, by, callback) {
57177
+ var data = {};
57178
+ var $add = {};
57179
+ if (_$1.isObject(prop)) {
57180
+ _$1.each(prop, function(v, k) {
57181
+ if (!this._is_reserved_property(k)) {
57182
+ if (isNaN(parseFloat(v))) {
57183
+ console$1.error("Invalid increment value passed to mixpanel.people.increment - must be a number");
57184
+ return;
57185
+ } else {
57186
+ $add[k] = v;
57187
+ }
57188
+ }
57189
+ }, this);
57190
+ callback = by;
57191
+ } else {
57192
+ if (_$1.isUndefined(by)) {
57193
+ by = 1;
57194
+ }
57195
+ $add[prop] = by;
57196
+ }
57197
+ data[ADD_ACTION] = $add;
57198
+ return this._send_request(data, callback);
57199
+ });
57200
+ MixpanelPeople.prototype.append = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
57201
+ if (_$1.isObject(list_name)) {
57202
+ callback = value;
57203
+ }
57204
+ var data = this.append_action(list_name, value);
57205
+ return this._send_request(data, callback);
57206
+ });
57207
+ MixpanelPeople.prototype.remove = addOptOutCheckMixpanelPeople(function(list_name, value, callback) {
57208
+ if (_$1.isObject(list_name)) {
57209
+ callback = value;
57210
+ }
57211
+ var data = this.remove_action(list_name, value);
57212
+ return this._send_request(data, callback);
57213
+ });
57214
+ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name, values2, callback) {
57215
+ if (_$1.isObject(list_name)) {
57216
+ callback = values2;
57217
+ }
57218
+ var data = this.union_action(list_name, values2);
57219
+ return this._send_request(data, callback);
57220
+ });
57221
+ MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
57222
+ if (!_$1.isNumber(amount)) {
57223
+ amount = parseFloat(amount);
57224
+ if (isNaN(amount)) {
57225
+ console$1.error("Invalid value passed to mixpanel.people.track_charge - must be a number");
57226
+ return;
57227
+ }
57228
+ }
57229
+ return this.append("$transactions", _$1.extend({
57230
+ "$amount": amount
57231
+ }, properties), callback);
57232
+ });
57233
+ MixpanelPeople.prototype.clear_charges = function(callback) {
57234
+ return this.set("$transactions", [], callback);
57235
+ };
57236
+ MixpanelPeople.prototype.delete_user = function() {
57237
+ if (!this._identify_called()) {
57238
+ console$1.error("mixpanel.people.delete_user() requires you to call identify() first");
57239
+ return;
57240
+ }
57241
+ var data = { "$delete": this._mixpanel.get_distinct_id() };
57242
+ return this._send_request(data);
57243
+ };
57244
+ MixpanelPeople.prototype.toString = function() {
57245
+ return this._mixpanel.toString() + ".people";
57246
+ };
57247
+ MixpanelPeople.prototype._send_request = function(data, callback) {
57248
+ data["$token"] = this._get_config("token");
57249
+ data["$distinct_id"] = this._mixpanel.get_distinct_id();
57250
+ var device_id = this._mixpanel.get_property("$device_id");
57251
+ var user_id = this._mixpanel.get_property("$user_id");
57252
+ var had_persisted_distinct_id = this._mixpanel.get_property("$had_persisted_distinct_id");
57253
+ if (device_id) {
57254
+ data["$device_id"] = device_id;
57255
+ }
57256
+ if (user_id) {
57257
+ data["$user_id"] = user_id;
57258
+ }
57259
+ if (had_persisted_distinct_id) {
57260
+ data["$had_persisted_distinct_id"] = had_persisted_distinct_id;
57261
+ }
57262
+ var date_encoded_data = _$1.encodeDates(data);
57263
+ if (!this._identify_called()) {
57264
+ this._enqueue(data);
57265
+ if (!_$1.isUndefined(callback)) {
57266
+ if (this._get_config("verbose")) {
57267
+ callback({ status: -1, error: null });
57268
+ } else {
57269
+ callback(-1);
57270
+ }
57271
+ }
57272
+ return _$1.truncate(date_encoded_data, 255);
57273
+ }
57274
+ return this._mixpanel._track_or_batch({
57275
+ type: "people",
57276
+ data: date_encoded_data,
57277
+ endpoint: this._get_config("api_host") + "/" + this._get_config("api_routes")["engage"],
57278
+ batcher: this._mixpanel.request_batchers.people
57279
+ }, callback);
57280
+ };
57281
+ MixpanelPeople.prototype._get_config = function(conf_var) {
57282
+ return this._mixpanel.get_config(conf_var);
57283
+ };
57284
+ MixpanelPeople.prototype._identify_called = function() {
57285
+ return this._mixpanel._flags.identify_called === true;
57286
+ };
57287
+ MixpanelPeople.prototype._enqueue = function(data) {
57288
+ if (SET_ACTION in data) {
57289
+ this._mixpanel["persistence"]._add_to_people_queue(SET_ACTION, data);
57290
+ } else if (SET_ONCE_ACTION in data) {
57291
+ this._mixpanel["persistence"]._add_to_people_queue(SET_ONCE_ACTION, data);
57292
+ } else if (UNSET_ACTION in data) {
57293
+ this._mixpanel["persistence"]._add_to_people_queue(UNSET_ACTION, data);
57294
+ } else if (ADD_ACTION in data) {
57295
+ this._mixpanel["persistence"]._add_to_people_queue(ADD_ACTION, data);
57296
+ } else if (APPEND_ACTION in data) {
57297
+ this._mixpanel["persistence"]._add_to_people_queue(APPEND_ACTION, data);
57298
+ } else if (REMOVE_ACTION in data) {
57299
+ this._mixpanel["persistence"]._add_to_people_queue(REMOVE_ACTION, data);
57300
+ } else if (UNION_ACTION in data) {
57301
+ this._mixpanel["persistence"]._add_to_people_queue(UNION_ACTION, data);
57302
+ } else {
57303
+ console$1.error("Invalid call to _enqueue():", data);
57304
+ }
57305
+ };
57306
+ MixpanelPeople.prototype._flush_one_queue = function(action, action_method, callback, queue_to_params_fn) {
57307
+ var _this = this;
57308
+ var queued_data = _$1.extend({}, this._mixpanel["persistence"].load_queue(action));
57309
+ var action_params = queued_data;
57310
+ if (!_$1.isUndefined(queued_data) && _$1.isObject(queued_data) && !_$1.isEmptyObject(queued_data)) {
57311
+ _this._mixpanel["persistence"]._pop_from_people_queue(action, queued_data);
57312
+ _this._mixpanel["persistence"].save();
57313
+ if (queue_to_params_fn) {
57314
+ action_params = queue_to_params_fn(queued_data);
57315
+ }
57316
+ action_method.call(_this, action_params, function(response, data) {
57317
+ if (response === 0) {
57318
+ _this._mixpanel["persistence"]._add_to_people_queue(action, queued_data);
57319
+ }
57320
+ if (!_$1.isUndefined(callback)) {
57321
+ callback(response, data);
57322
+ }
57323
+ });
57324
+ }
57325
+ };
57326
+ MixpanelPeople.prototype._flush = function(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback) {
57327
+ var _this = this;
57328
+ this._flush_one_queue(SET_ACTION, this.set, _set_callback);
57329
+ this._flush_one_queue(SET_ONCE_ACTION, this.set_once, _set_once_callback);
57330
+ this._flush_one_queue(UNSET_ACTION, this.unset, _unset_callback, function(queue) {
57331
+ return _$1.keys(queue);
57332
+ });
57333
+ this._flush_one_queue(ADD_ACTION, this.increment, _add_callback);
57334
+ this._flush_one_queue(UNION_ACTION, this.union, _union_callback);
57335
+ var $append_queue = this._mixpanel["persistence"].load_queue(APPEND_ACTION);
57336
+ if (!_$1.isUndefined($append_queue) && _$1.isArray($append_queue) && $append_queue.length) {
57337
+ var $append_item;
57338
+ var append_callback = function(response, data) {
57339
+ if (response === 0) {
57340
+ _this._mixpanel["persistence"]._add_to_people_queue(APPEND_ACTION, $append_item);
57341
+ }
57342
+ if (!_$1.isUndefined(_append_callback)) {
57343
+ _append_callback(response, data);
57344
+ }
57345
+ };
57346
+ for (var i2 = $append_queue.length - 1; i2 >= 0; i2--) {
57347
+ $append_queue = this._mixpanel["persistence"].load_queue(APPEND_ACTION);
57348
+ $append_item = $append_queue.pop();
57349
+ _this._mixpanel["persistence"].save();
57350
+ if (!_$1.isEmptyObject($append_item)) {
57351
+ _this.append($append_item, append_callback);
57352
+ }
57353
+ }
57354
+ }
57355
+ var $remove_queue = this._mixpanel["persistence"].load_queue(REMOVE_ACTION);
57356
+ if (!_$1.isUndefined($remove_queue) && _$1.isArray($remove_queue) && $remove_queue.length) {
57357
+ var $remove_item;
57358
+ var remove_callback = function(response, data) {
57359
+ if (response === 0) {
57360
+ _this._mixpanel["persistence"]._add_to_people_queue(REMOVE_ACTION, $remove_item);
57361
+ }
57362
+ if (!_$1.isUndefined(_remove_callback)) {
57363
+ _remove_callback(response, data);
57364
+ }
57365
+ };
57366
+ for (var j = $remove_queue.length - 1; j >= 0; j--) {
57367
+ $remove_queue = this._mixpanel["persistence"].load_queue(REMOVE_ACTION);
57368
+ $remove_item = $remove_queue.pop();
57369
+ _this._mixpanel["persistence"].save();
57370
+ if (!_$1.isEmptyObject($remove_item)) {
57371
+ _this.remove($remove_item, remove_callback);
57372
+ }
57373
+ }
57374
+ }
57375
+ };
57376
+ MixpanelPeople.prototype._is_reserved_property = function(prop) {
57377
+ return prop === "$distinct_id" || prop === "$token" || prop === "$device_id" || prop === "$user_id" || prop === "$had_persisted_distinct_id";
57378
+ };
57379
+ MixpanelPeople.prototype["set"] = MixpanelPeople.prototype.set;
57380
+ MixpanelPeople.prototype["set_once"] = MixpanelPeople.prototype.set_once;
57381
+ MixpanelPeople.prototype["unset"] = MixpanelPeople.prototype.unset;
57382
+ MixpanelPeople.prototype["increment"] = MixpanelPeople.prototype.increment;
57383
+ MixpanelPeople.prototype["append"] = MixpanelPeople.prototype.append;
57384
+ MixpanelPeople.prototype["remove"] = MixpanelPeople.prototype.remove;
57385
+ MixpanelPeople.prototype["union"] = MixpanelPeople.prototype.union;
57386
+ MixpanelPeople.prototype["track_charge"] = MixpanelPeople.prototype.track_charge;
57387
+ MixpanelPeople.prototype["clear_charges"] = MixpanelPeople.prototype.clear_charges;
57388
+ MixpanelPeople.prototype["delete_user"] = MixpanelPeople.prototype.delete_user;
57389
+ MixpanelPeople.prototype["toString"] = MixpanelPeople.prototype.toString;
57390
+ var SET_QUEUE_KEY = "__mps";
57391
+ var SET_ONCE_QUEUE_KEY = "__mpso";
57392
+ var UNSET_QUEUE_KEY = "__mpus";
57393
+ var ADD_QUEUE_KEY = "__mpa";
57394
+ var APPEND_QUEUE_KEY = "__mpap";
57395
+ var REMOVE_QUEUE_KEY = "__mpr";
57396
+ var UNION_QUEUE_KEY = "__mpu";
57397
+ var PEOPLE_DISTINCT_ID_KEY = "$people_distinct_id";
57398
+ var ALIAS_ID_KEY = "__alias";
57399
+ var EVENT_TIMERS_KEY = "__timers";
57400
+ var RESERVED_PROPERTIES = [
57401
+ SET_QUEUE_KEY,
57402
+ SET_ONCE_QUEUE_KEY,
57403
+ UNSET_QUEUE_KEY,
57404
+ ADD_QUEUE_KEY,
57405
+ APPEND_QUEUE_KEY,
57406
+ REMOVE_QUEUE_KEY,
57407
+ UNION_QUEUE_KEY,
57408
+ PEOPLE_DISTINCT_ID_KEY,
57409
+ ALIAS_ID_KEY,
57410
+ EVENT_TIMERS_KEY
57411
+ ];
57412
+ var MixpanelPersistence = function(config) {
57413
+ this["props"] = {};
57414
+ this.campaign_params_saved = false;
57415
+ if (config["persistence_name"]) {
57416
+ this.name = "mp_" + config["persistence_name"];
57417
+ } else {
57418
+ this.name = "mp_" + config["token"] + "_mixpanel";
57419
+ }
57420
+ var storage_type = config["persistence"];
57421
+ if (storage_type !== "cookie" && storage_type !== "localStorage") {
57422
+ console$1.critical("Unknown persistence type " + storage_type + "; falling back to cookie");
57423
+ storage_type = config["persistence"] = "cookie";
57424
+ }
57425
+ if (storage_type === "localStorage" && _$1.localStorage.is_supported()) {
57426
+ this.storage = _$1.localStorage;
57427
+ } else {
57428
+ this.storage = _$1.cookie;
57429
+ }
57430
+ this.load();
57431
+ this.update_config(config);
57432
+ this.upgrade();
57433
+ this.save();
57434
+ };
57435
+ MixpanelPersistence.prototype.properties = function() {
57436
+ var p = {};
57437
+ this.load();
57438
+ _$1.each(this["props"], function(v, k) {
57439
+ if (!_$1.include(RESERVED_PROPERTIES, k)) {
57440
+ p[k] = v;
57441
+ }
57442
+ });
57443
+ return p;
57444
+ };
57445
+ MixpanelPersistence.prototype.load = function() {
57446
+ if (this.disabled) {
57447
+ return;
57448
+ }
57449
+ var entry = this.storage.parse(this.name);
57450
+ if (entry) {
57451
+ this["props"] = _$1.extend({}, entry);
57452
+ }
57453
+ };
57454
+ MixpanelPersistence.prototype.upgrade = function() {
57455
+ var old_cookie, old_localstorage;
57456
+ if (this.storage === _$1.localStorage) {
57457
+ old_cookie = _$1.cookie.parse(this.name);
57458
+ _$1.cookie.remove(this.name);
57459
+ _$1.cookie.remove(this.name, true);
57460
+ if (old_cookie) {
57461
+ this.register_once(old_cookie);
57462
+ }
57463
+ } else if (this.storage === _$1.cookie) {
57464
+ old_localstorage = _$1.localStorage.parse(this.name);
57465
+ _$1.localStorage.remove(this.name);
57466
+ if (old_localstorage) {
57467
+ this.register_once(old_localstorage);
57468
+ }
57469
+ }
57470
+ };
57471
+ MixpanelPersistence.prototype.save = function() {
57472
+ if (this.disabled) {
57473
+ return;
57474
+ }
57475
+ this.storage.set(
57476
+ this.name,
57477
+ _$1.JSONEncode(this["props"]),
57478
+ this.expire_days,
57479
+ this.cross_subdomain,
57480
+ this.secure,
57481
+ this.cross_site,
57482
+ this.cookie_domain
57483
+ );
57484
+ };
57485
+ MixpanelPersistence.prototype.load_prop = function(key) {
57486
+ this.load();
57487
+ return this["props"][key];
57488
+ };
57489
+ MixpanelPersistence.prototype.remove = function() {
57490
+ this.storage.remove(this.name, false, this.cookie_domain);
57491
+ this.storage.remove(this.name, true, this.cookie_domain);
57492
+ };
57493
+ MixpanelPersistence.prototype.clear = function() {
57494
+ this.remove();
57495
+ this["props"] = {};
57496
+ };
57497
+ MixpanelPersistence.prototype.register_once = function(props, default_value, days) {
57498
+ if (_$1.isObject(props)) {
57499
+ if (typeof default_value === "undefined") {
57500
+ default_value = "None";
57501
+ }
57502
+ this.expire_days = typeof days === "undefined" ? this.default_expiry : days;
57503
+ this.load();
57504
+ _$1.each(props, function(val, prop) {
57505
+ if (!this["props"].hasOwnProperty(prop) || this["props"][prop] === default_value) {
57506
+ this["props"][prop] = val;
57507
+ }
57508
+ }, this);
57509
+ this.save();
57510
+ return true;
57511
+ }
57512
+ return false;
57513
+ };
57514
+ MixpanelPersistence.prototype.register = function(props, days) {
57515
+ if (_$1.isObject(props)) {
57516
+ this.expire_days = typeof days === "undefined" ? this.default_expiry : days;
57517
+ this.load();
57518
+ _$1.extend(this["props"], props);
57519
+ this.save();
57520
+ return true;
57521
+ }
57522
+ return false;
57523
+ };
57524
+ MixpanelPersistence.prototype.unregister = function(prop) {
57525
+ this.load();
57526
+ if (prop in this["props"]) {
57527
+ delete this["props"][prop];
57528
+ this.save();
57529
+ }
57530
+ };
57531
+ MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
57532
+ this.register(_$1.info.searchInfo(referrer));
57533
+ };
57534
+ MixpanelPersistence.prototype.update_referrer_info = function(referrer) {
57535
+ this.register_once({
57536
+ "$initial_referrer": referrer || "$direct",
57537
+ "$initial_referring_domain": _$1.info.referringDomain(referrer) || "$direct"
57538
+ }, "");
57539
+ };
57540
+ MixpanelPersistence.prototype.get_referrer_info = function() {
57541
+ return _$1.strip_empty_properties({
57542
+ "$initial_referrer": this["props"]["$initial_referrer"],
57543
+ "$initial_referring_domain": this["props"]["$initial_referring_domain"]
57544
+ });
57545
+ };
57546
+ MixpanelPersistence.prototype.update_config = function(config) {
57547
+ this.default_expiry = this.expire_days = config["cookie_expiration"];
57548
+ this.set_disabled(config["disable_persistence"]);
57549
+ this.set_cookie_domain(config["cookie_domain"]);
57550
+ this.set_cross_site(config["cross_site_cookie"]);
57551
+ this.set_cross_subdomain(config["cross_subdomain_cookie"]);
57552
+ this.set_secure(config["secure_cookie"]);
57553
+ };
57554
+ MixpanelPersistence.prototype.set_disabled = function(disabled) {
57555
+ this.disabled = disabled;
57556
+ if (this.disabled) {
57557
+ this.remove();
57558
+ } else {
57559
+ this.save();
57560
+ }
57561
+ };
57562
+ MixpanelPersistence.prototype.set_cookie_domain = function(cookie_domain) {
57563
+ if (cookie_domain !== this.cookie_domain) {
57564
+ this.remove();
57565
+ this.cookie_domain = cookie_domain;
57566
+ this.save();
57567
+ }
57568
+ };
57569
+ MixpanelPersistence.prototype.set_cross_site = function(cross_site) {
57570
+ if (cross_site !== this.cross_site) {
57571
+ this.cross_site = cross_site;
57572
+ this.remove();
57573
+ this.save();
57574
+ }
57575
+ };
57576
+ MixpanelPersistence.prototype.set_cross_subdomain = function(cross_subdomain) {
57577
+ if (cross_subdomain !== this.cross_subdomain) {
57578
+ this.cross_subdomain = cross_subdomain;
57579
+ this.remove();
57580
+ this.save();
57581
+ }
57582
+ };
57583
+ MixpanelPersistence.prototype.get_cross_subdomain = function() {
57584
+ return this.cross_subdomain;
57585
+ };
57586
+ MixpanelPersistence.prototype.set_secure = function(secure) {
57587
+ if (secure !== this.secure) {
57588
+ this.secure = secure ? true : false;
57589
+ this.remove();
57590
+ this.save();
57591
+ }
57592
+ };
57593
+ MixpanelPersistence.prototype._add_to_people_queue = function(queue, data) {
57594
+ var q_key = this._get_queue_key(queue), q_data = data[queue], set_q = this._get_or_create_queue(SET_ACTION), set_once_q = this._get_or_create_queue(SET_ONCE_ACTION), unset_q = this._get_or_create_queue(UNSET_ACTION), add_q = this._get_or_create_queue(ADD_ACTION), union_q = this._get_or_create_queue(UNION_ACTION), remove_q = this._get_or_create_queue(REMOVE_ACTION, []), append_q = this._get_or_create_queue(APPEND_ACTION, []);
57595
+ if (q_key === SET_QUEUE_KEY) {
57596
+ _$1.extend(set_q, q_data);
57597
+ this._pop_from_people_queue(ADD_ACTION, q_data);
57598
+ this._pop_from_people_queue(UNION_ACTION, q_data);
57599
+ this._pop_from_people_queue(UNSET_ACTION, q_data);
57600
+ } else if (q_key === SET_ONCE_QUEUE_KEY) {
57601
+ _$1.each(q_data, function(v, k) {
57602
+ if (!(k in set_once_q)) {
57603
+ set_once_q[k] = v;
57604
+ }
57605
+ });
57606
+ this._pop_from_people_queue(UNSET_ACTION, q_data);
57607
+ } else if (q_key === UNSET_QUEUE_KEY) {
57608
+ _$1.each(q_data, function(prop) {
57609
+ _$1.each([set_q, set_once_q, add_q, union_q], function(enqueued_obj) {
57610
+ if (prop in enqueued_obj) {
57611
+ delete enqueued_obj[prop];
57612
+ }
57613
+ });
57614
+ _$1.each(append_q, function(append_obj) {
57615
+ if (prop in append_obj) {
57616
+ delete append_obj[prop];
57617
+ }
57618
+ });
57619
+ unset_q[prop] = true;
57620
+ });
57621
+ } else if (q_key === ADD_QUEUE_KEY) {
57622
+ _$1.each(q_data, function(v, k) {
57623
+ if (k in set_q) {
57624
+ set_q[k] += v;
57625
+ } else {
57626
+ if (!(k in add_q)) {
57627
+ add_q[k] = 0;
57628
+ }
57629
+ add_q[k] += v;
57630
+ }
57631
+ }, this);
57632
+ this._pop_from_people_queue(UNSET_ACTION, q_data);
57633
+ } else if (q_key === UNION_QUEUE_KEY) {
57634
+ _$1.each(q_data, function(v, k) {
57635
+ if (_$1.isArray(v)) {
57636
+ if (!(k in union_q)) {
57637
+ union_q[k] = [];
57638
+ }
57639
+ union_q[k] = union_q[k].concat(v);
57640
+ }
57641
+ });
57642
+ this._pop_from_people_queue(UNSET_ACTION, q_data);
57643
+ } else if (q_key === REMOVE_QUEUE_KEY) {
57644
+ remove_q.push(q_data);
57645
+ this._pop_from_people_queue(APPEND_ACTION, q_data);
57646
+ } else if (q_key === APPEND_QUEUE_KEY) {
57647
+ append_q.push(q_data);
57648
+ this._pop_from_people_queue(UNSET_ACTION, q_data);
57649
+ }
57650
+ console$1.log("MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY):");
57651
+ console$1.log(data);
57652
+ this.save();
57653
+ };
57654
+ MixpanelPersistence.prototype._pop_from_people_queue = function(queue, data) {
57655
+ var q = this["props"][this._get_queue_key(queue)];
57656
+ if (!_$1.isUndefined(q)) {
57657
+ _$1.each(data, function(v, k) {
57658
+ if (queue === APPEND_ACTION || queue === REMOVE_ACTION) {
57659
+ _$1.each(q, function(queued_action) {
57660
+ if (queued_action[k] === v) {
57661
+ delete queued_action[k];
57662
+ }
57663
+ });
57664
+ } else {
57665
+ delete q[k];
57666
+ }
57667
+ }, this);
57668
+ }
57669
+ };
57670
+ MixpanelPersistence.prototype.load_queue = function(queue) {
57671
+ return this.load_prop(this._get_queue_key(queue));
57672
+ };
57673
+ MixpanelPersistence.prototype._get_queue_key = function(queue) {
57674
+ if (queue === SET_ACTION) {
57675
+ return SET_QUEUE_KEY;
57676
+ } else if (queue === SET_ONCE_ACTION) {
57677
+ return SET_ONCE_QUEUE_KEY;
57678
+ } else if (queue === UNSET_ACTION) {
57679
+ return UNSET_QUEUE_KEY;
57680
+ } else if (queue === ADD_ACTION) {
57681
+ return ADD_QUEUE_KEY;
57682
+ } else if (queue === APPEND_ACTION) {
57683
+ return APPEND_QUEUE_KEY;
57684
+ } else if (queue === REMOVE_ACTION) {
57685
+ return REMOVE_QUEUE_KEY;
57686
+ } else if (queue === UNION_ACTION) {
57687
+ return UNION_QUEUE_KEY;
57688
+ } else {
57689
+ console$1.error("Invalid queue:", queue);
57690
+ }
57691
+ };
57692
+ MixpanelPersistence.prototype._get_or_create_queue = function(queue, default_val) {
57693
+ var key = this._get_queue_key(queue);
57694
+ default_val = _$1.isUndefined(default_val) ? {} : default_val;
57695
+ return this["props"][key] || (this["props"][key] = default_val);
57696
+ };
57697
+ MixpanelPersistence.prototype.set_event_timer = function(event_name, timestamp) {
57698
+ var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
57699
+ timers[event_name] = timestamp;
57700
+ this["props"][EVENT_TIMERS_KEY] = timers;
57701
+ this.save();
57702
+ };
57703
+ MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
57704
+ var timers = this.load_prop(EVENT_TIMERS_KEY) || {};
57705
+ var timestamp = timers[event_name];
57706
+ if (!_$1.isUndefined(timestamp)) {
57707
+ delete this["props"][EVENT_TIMERS_KEY][event_name];
57708
+ this.save();
57709
+ }
57710
+ return timestamp;
57711
+ };
57712
+ var init_type;
57713
+ var mixpanel_master;
57714
+ var INIT_MODULE = 0;
57715
+ var INIT_SNIPPET = 1;
57716
+ var IDENTITY_FUNC = function(x) {
57717
+ return x;
57718
+ };
57719
+ var NOOP_FUNC = function() {
57720
+ };
57721
+ var PRIMARY_INSTANCE_NAME = "mixpanel";
57722
+ var PAYLOAD_TYPE_BASE64 = "base64";
57723
+ var PAYLOAD_TYPE_JSON = "json";
57724
+ var DEVICE_ID_PREFIX = "$device:";
57725
+ var USE_XHR = win.XMLHttpRequest && "withCredentials" in new XMLHttpRequest();
57726
+ var ENQUEUE_REQUESTS = !USE_XHR && userAgent.indexOf("MSIE") === -1 && userAgent.indexOf("Mozilla") === -1;
57727
+ var sendBeacon = null;
57728
+ if (navigator$1["sendBeacon"]) {
57729
+ sendBeacon = function() {
57730
+ return navigator$1["sendBeacon"].apply(navigator$1, arguments);
57731
+ };
57732
+ }
57733
+ var DEFAULT_API_ROUTES = {
57734
+ "track": "track/",
57735
+ "engage": "engage/",
57736
+ "groups": "groups/",
57737
+ "record": "record/"
57738
+ };
57739
+ var DEFAULT_CONFIG = {
57740
+ "api_host": "https://api-js.mixpanel.com",
57741
+ "api_routes": DEFAULT_API_ROUTES,
57742
+ "api_method": "POST",
57743
+ "api_transport": "XHR",
57744
+ "api_payload_format": PAYLOAD_TYPE_BASE64,
57745
+ "app_host": "https://mixpanel.com",
57746
+ "cdn": "https://cdn.mxpnl.com",
57747
+ "cross_site_cookie": false,
57748
+ "cross_subdomain_cookie": true,
57749
+ "error_reporter": NOOP_FUNC,
57750
+ "persistence": "cookie",
57751
+ "persistence_name": "",
57752
+ "cookie_domain": "",
57753
+ "cookie_name": "",
57754
+ "loaded": NOOP_FUNC,
57755
+ "mp_loader": null,
57756
+ "track_marketing": true,
57757
+ "track_pageview": false,
57758
+ "skip_first_touch_marketing": false,
57759
+ "store_google": true,
57760
+ "stop_utm_persistence": false,
57761
+ "save_referrer": true,
57762
+ "test": false,
57763
+ "verbose": false,
57764
+ "img": false,
57765
+ "debug": false,
57766
+ "track_links_timeout": 300,
57767
+ "cookie_expiration": 365,
57768
+ "upgrade": false,
57769
+ "disable_persistence": false,
57770
+ "disable_cookie": false,
57771
+ "secure_cookie": false,
57772
+ "ip": true,
57773
+ "opt_out_tracking_by_default": false,
57774
+ "opt_out_persistence_by_default": false,
57775
+ "opt_out_tracking_persistence_type": "localStorage",
57776
+ "opt_out_tracking_cookie_prefix": null,
57777
+ "property_blacklist": [],
57778
+ "xhr_headers": {},
57779
+ "ignore_dnt": false,
57780
+ "batch_requests": true,
57781
+ "batch_size": 50,
57782
+ "batch_flush_interval_ms": 5e3,
57783
+ "batch_request_timeout_ms": 9e4,
57784
+ "batch_autostart": true,
57785
+ "hooks": {},
57786
+ "record_block_class": new RegExp("^(mp-block|fs-exclude|amp-block|rr-block|ph-no-capture)$"),
57787
+ "record_block_selector": "img, video",
57788
+ "record_idle_timeout_ms": 30 * 60 * 1e3,
57789
+ "record_mask_text_class": new RegExp("^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$"),
57790
+ "record_mask_text_selector": "*",
57791
+ "record_max_ms": MAX_RECORDING_MS,
57792
+ "record_sessions_percent": 0,
57793
+ "recorder_src": "https://cdn.mxpnl.com/libs/mixpanel-recorder.min.js"
57794
+ };
57795
+ var DOM_LOADED = false;
57796
+ var MixpanelLib = function() {
57797
+ };
57798
+ var create_mplib = function(token, config, name2) {
57799
+ var instance, target = name2 === PRIMARY_INSTANCE_NAME ? mixpanel_master : mixpanel_master[name2];
57800
+ if (target && init_type === INIT_MODULE) {
57801
+ instance = target;
57802
+ } else {
57803
+ if (target && !_$1.isArray(target)) {
57804
+ console$1.error("You have already initialized " + name2);
57805
+ return;
57806
+ }
57807
+ instance = new MixpanelLib();
57808
+ }
57809
+ instance._cached_groups = {};
57810
+ instance._init(token, config, name2);
57811
+ instance["people"] = new MixpanelPeople();
57812
+ instance["people"]._init(instance);
57813
+ if (!instance.get_config("skip_first_touch_marketing")) {
57814
+ var utm_params = _$1.info.campaignParams(null);
57815
+ var initial_utm_params = {};
57816
+ var has_utm = false;
57817
+ _$1.each(utm_params, function(utm_value, utm_key) {
57818
+ initial_utm_params["initial_" + utm_key] = utm_value;
57819
+ if (utm_value) {
57820
+ has_utm = true;
57821
+ }
57822
+ });
57823
+ if (has_utm) {
57824
+ instance["people"].set_once(initial_utm_params);
57825
+ }
57826
+ }
57827
+ Config.DEBUG = Config.DEBUG || instance.get_config("debug");
57828
+ if (!_$1.isUndefined(target) && _$1.isArray(target)) {
57829
+ instance._execute_array.call(instance["people"], target["people"]);
57830
+ instance._execute_array(target);
57831
+ }
57832
+ return instance;
57833
+ };
57834
+ MixpanelLib.prototype.init = function(token, config, name2) {
57835
+ if (_$1.isUndefined(name2)) {
57836
+ this.report_error("You must name your new library: init(token, config, name)");
57837
+ return;
57838
+ }
57839
+ if (name2 === PRIMARY_INSTANCE_NAME) {
57840
+ this.report_error("You must initialize the main mixpanel object right after you include the Mixpanel js snippet");
57841
+ return;
57842
+ }
57843
+ var instance = create_mplib(token, config, name2);
57844
+ mixpanel_master[name2] = instance;
57845
+ instance._loaded();
57846
+ return instance;
57847
+ };
57848
+ MixpanelLib.prototype._init = function(token, config, name2) {
57849
+ config = config || {};
57850
+ this["__loaded"] = true;
57851
+ this["config"] = {};
57852
+ var variable_features = {};
57853
+ if (!("api_payload_format" in config)) {
57854
+ var api_host = config["api_host"] || DEFAULT_CONFIG["api_host"];
57855
+ if (api_host.match(/\.mixpanel\.com/)) {
57856
+ variable_features["api_payload_format"] = PAYLOAD_TYPE_JSON;
57857
+ }
57858
+ }
57859
+ this.set_config(_$1.extend({}, DEFAULT_CONFIG, variable_features, config, {
57860
+ "name": name2,
57861
+ "token": token,
57862
+ "callback_fn": (name2 === PRIMARY_INSTANCE_NAME ? name2 : PRIMARY_INSTANCE_NAME + "." + name2) + "._jsc"
57863
+ }));
57864
+ this["_jsc"] = NOOP_FUNC;
57865
+ this.__dom_loaded_queue = [];
57866
+ this.__request_queue = [];
57867
+ this.__disabled_events = [];
57868
+ this._flags = {
57869
+ "disable_all_events": false,
57870
+ "identify_called": false
57871
+ };
57872
+ this.request_batchers = {};
57873
+ this._batch_requests = this.get_config("batch_requests");
57874
+ if (this._batch_requests) {
57875
+ if (!_$1.localStorage.is_supported(true) || !USE_XHR) {
57876
+ this._batch_requests = false;
57877
+ console$1.log("Turning off Mixpanel request-queueing; needs XHR and localStorage support");
57878
+ _$1.each(this.get_batcher_configs(), function(batcher_config) {
57879
+ console$1.log("Clearing batch queue " + batcher_config.queue_key);
57880
+ _$1.localStorage.remove(batcher_config.queue_key);
57881
+ });
57882
+ } else {
57883
+ this.init_batchers();
57884
+ if (sendBeacon && win.addEventListener) {
57885
+ var flush_on_unload = _$1.bind(function() {
57886
+ if (!this.request_batchers.events.stopped) {
57887
+ this.request_batchers.events.flush({ unloading: true });
57888
+ }
57889
+ }, this);
57890
+ win.addEventListener("pagehide", function(ev) {
57891
+ if (ev["persisted"]) {
57892
+ flush_on_unload();
57893
+ }
57894
+ });
57895
+ win.addEventListener("visibilitychange", function() {
57896
+ if (document$1["visibilityState"] === "hidden") {
57897
+ flush_on_unload();
57898
+ }
57899
+ });
57900
+ }
57901
+ }
57902
+ }
57903
+ this["persistence"] = this["cookie"] = new MixpanelPersistence(this["config"]);
57904
+ this.unpersisted_superprops = {};
57905
+ this._gdpr_init();
57906
+ var uuid2 = _$1.UUID();
57907
+ if (!this.get_distinct_id()) {
57908
+ this.register_once({
57909
+ "distinct_id": DEVICE_ID_PREFIX + uuid2,
57910
+ "$device_id": uuid2
57911
+ }, "");
57912
+ }
57913
+ var track_pageview_option = this.get_config("track_pageview");
57914
+ if (track_pageview_option) {
57915
+ this._init_url_change_tracking(track_pageview_option);
57916
+ }
57917
+ if (this.get_config("record_sessions_percent") > 0 && Math.random() * 100 <= this.get_config("record_sessions_percent")) {
57918
+ this.start_session_recording();
57919
+ }
57920
+ };
57921
+ MixpanelLib.prototype.start_session_recording = addOptOutCheckMixpanelLib(function() {
57922
+ if (!win["MutationObserver"]) {
57923
+ console$1.critical("Browser does not support MutationObserver; skipping session recording");
57924
+ return;
57925
+ }
57926
+ var handleLoadedRecorder = _$1.bind(function() {
57927
+ this._recorder = this._recorder || new win["__mp_recorder"](this);
57928
+ this._recorder["startRecording"]();
57929
+ }, this);
57930
+ if (_$1.isUndefined(win["__mp_recorder"])) {
57931
+ var scriptEl = document$1.createElement("script");
57932
+ scriptEl.type = "text/javascript";
57933
+ scriptEl.async = true;
57934
+ scriptEl.onload = handleLoadedRecorder;
57935
+ scriptEl.src = this.get_config("recorder_src");
57936
+ document$1.head.appendChild(scriptEl);
57937
+ } else {
57938
+ handleLoadedRecorder();
57939
+ }
57940
+ });
57941
+ MixpanelLib.prototype.stop_session_recording = function() {
57942
+ if (this._recorder) {
57943
+ this._recorder["stopRecording"]();
57944
+ } else {
57945
+ console$1.critical("Session recorder module not loaded");
57946
+ }
57947
+ };
57948
+ MixpanelLib.prototype.get_session_recording_properties = function() {
57949
+ var props = {};
57950
+ if (this._recorder) {
57951
+ var replay_id = this._recorder["replayId"];
57952
+ if (replay_id) {
57953
+ props["$mp_replay_id"] = replay_id;
57954
+ }
57955
+ }
57956
+ return props;
57957
+ };
57958
+ MixpanelLib.prototype._loaded = function() {
57959
+ this.get_config("loaded")(this);
57960
+ this._set_default_superprops();
57961
+ this["people"].set_once(this["persistence"].get_referrer_info());
57962
+ if (this.get_config("store_google") && this.get_config("stop_utm_persistence")) {
57963
+ var utm_params = _$1.info.campaignParams(null);
57964
+ _$1.each(utm_params, function(_utm_value, utm_key) {
57965
+ this.unregister(utm_key);
57966
+ }.bind(this));
57967
+ }
57968
+ };
57969
+ MixpanelLib.prototype._set_default_superprops = function() {
57970
+ this["persistence"].update_search_keyword(document$1.referrer);
57971
+ if (this.get_config("store_google") && !this.get_config("stop_utm_persistence")) {
57972
+ this.register(_$1.info.campaignParams());
57973
+ }
57974
+ if (this.get_config("save_referrer")) {
57975
+ this["persistence"].update_referrer_info(document$1.referrer);
57976
+ }
57977
+ };
57978
+ MixpanelLib.prototype._dom_loaded = function() {
57979
+ _$1.each(this.__dom_loaded_queue, function(item) {
57980
+ this._track_dom.apply(this, item);
57981
+ }, this);
57982
+ if (!this.has_opted_out_tracking()) {
57983
+ _$1.each(this.__request_queue, function(item) {
57984
+ this._send_request.apply(this, item);
57985
+ }, this);
57986
+ }
57987
+ delete this.__dom_loaded_queue;
57988
+ delete this.__request_queue;
57989
+ };
57990
+ MixpanelLib.prototype._track_dom = function(DomClass, args) {
57991
+ if (this.get_config("img")) {
57992
+ this.report_error("You can't use DOM tracking functions with img = true.");
57993
+ return false;
57994
+ }
57995
+ if (!DOM_LOADED) {
57996
+ this.__dom_loaded_queue.push([DomClass, args]);
57997
+ return false;
57998
+ }
57999
+ var dt = new DomClass().init(this);
58000
+ return dt.track.apply(dt, args);
58001
+ };
58002
+ MixpanelLib.prototype._init_url_change_tracking = function(track_pageview_option) {
58003
+ var previous_tracked_url = "";
58004
+ var tracked = this.track_pageview();
58005
+ if (tracked) {
58006
+ previous_tracked_url = _$1.info.currentUrl();
58007
+ }
58008
+ if (_$1.include(["full-url", "url-with-path-and-query-string", "url-with-path"], track_pageview_option)) {
58009
+ win.addEventListener("popstate", function() {
58010
+ win.dispatchEvent(new Event("mp_locationchange"));
58011
+ });
58012
+ win.addEventListener("hashchange", function() {
58013
+ win.dispatchEvent(new Event("mp_locationchange"));
58014
+ });
58015
+ var nativePushState = win.history.pushState;
58016
+ if (typeof nativePushState === "function") {
58017
+ win.history.pushState = function(state, unused, url) {
58018
+ nativePushState.call(win.history, state, unused, url);
58019
+ win.dispatchEvent(new Event("mp_locationchange"));
58020
+ };
58021
+ }
58022
+ var nativeReplaceState = win.history.replaceState;
58023
+ if (typeof nativeReplaceState === "function") {
58024
+ win.history.replaceState = function(state, unused, url) {
58025
+ nativeReplaceState.call(win.history, state, unused, url);
58026
+ win.dispatchEvent(new Event("mp_locationchange"));
58027
+ };
58028
+ }
58029
+ win.addEventListener("mp_locationchange", function() {
58030
+ var current_url = _$1.info.currentUrl();
58031
+ var should_track = false;
58032
+ if (track_pageview_option === "full-url") {
58033
+ should_track = current_url !== previous_tracked_url;
58034
+ } else if (track_pageview_option === "url-with-path-and-query-string") {
58035
+ should_track = current_url.split("#")[0] !== previous_tracked_url.split("#")[0];
58036
+ } else if (track_pageview_option === "url-with-path") {
58037
+ should_track = current_url.split("#")[0].split("?")[0] !== previous_tracked_url.split("#")[0].split("?")[0];
58038
+ }
58039
+ if (should_track) {
58040
+ var tracked2 = this.track_pageview();
58041
+ if (tracked2) {
58042
+ previous_tracked_url = current_url;
58043
+ }
58044
+ }
58045
+ }.bind(this));
58046
+ }
58047
+ };
58048
+ MixpanelLib.prototype._prepare_callback = function(callback, data) {
58049
+ if (_$1.isUndefined(callback)) {
58050
+ return null;
58051
+ }
58052
+ if (USE_XHR) {
58053
+ var callback_function = function(response) {
58054
+ callback(response, data);
58055
+ };
58056
+ return callback_function;
58057
+ } else {
58058
+ var jsc = this["_jsc"];
58059
+ var randomized_cb = "" + Math.floor(Math.random() * 1e8);
58060
+ var callback_string = this.get_config("callback_fn") + "[" + randomized_cb + "]";
58061
+ jsc[randomized_cb] = function(response) {
58062
+ delete jsc[randomized_cb];
58063
+ callback(response, data);
58064
+ };
58065
+ return callback_string;
58066
+ }
58067
+ };
58068
+ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
58069
+ var succeeded = true;
58070
+ if (ENQUEUE_REQUESTS) {
58071
+ this.__request_queue.push(arguments);
58072
+ return succeeded;
58073
+ }
58074
+ var DEFAULT_OPTIONS = {
58075
+ method: this.get_config("api_method"),
58076
+ transport: this.get_config("api_transport"),
58077
+ verbose: this.get_config("verbose")
58078
+ };
58079
+ var body_data = null;
58080
+ if (!callback && (_$1.isFunction(options) || typeof options === "string")) {
58081
+ callback = options;
58082
+ options = null;
58083
+ }
58084
+ options = _$1.extend(DEFAULT_OPTIONS, options || {});
58085
+ if (!USE_XHR) {
58086
+ options.method = "GET";
58087
+ }
58088
+ var use_post = options.method === "POST";
58089
+ var use_sendBeacon = sendBeacon && use_post && options.transport.toLowerCase() === "sendbeacon";
58090
+ var verbose_mode = options.verbose;
58091
+ if (data["verbose"]) {
58092
+ verbose_mode = true;
58093
+ }
58094
+ if (this.get_config("test")) {
58095
+ data["test"] = 1;
58096
+ }
58097
+ if (verbose_mode) {
58098
+ data["verbose"] = 1;
58099
+ }
58100
+ if (this.get_config("img")) {
58101
+ data["img"] = 1;
58102
+ }
58103
+ if (!USE_XHR) {
58104
+ if (callback) {
58105
+ data["callback"] = callback;
58106
+ } else if (verbose_mode || this.get_config("test")) {
58107
+ data["callback"] = "(function(){})";
58108
+ }
58109
+ }
58110
+ data["ip"] = this.get_config("ip") ? 1 : 0;
58111
+ data["_"] = new Date().getTime().toString();
58112
+ if (use_post) {
58113
+ body_data = "data=" + encodeURIComponent(data["data"]);
58114
+ delete data["data"];
58115
+ }
58116
+ url += "?" + _$1.HTTPBuildQuery(data);
58117
+ var lib = this;
58118
+ if ("img" in data) {
58119
+ var img = document$1.createElement("img");
58120
+ img.src = url;
58121
+ document$1.body.appendChild(img);
58122
+ } else if (use_sendBeacon) {
58123
+ try {
58124
+ succeeded = sendBeacon(url, body_data);
58125
+ } catch (e) {
58126
+ lib.report_error(e);
58127
+ succeeded = false;
58128
+ }
58129
+ try {
58130
+ if (callback) {
58131
+ callback(succeeded ? 1 : 0);
58132
+ }
58133
+ } catch (e) {
58134
+ lib.report_error(e);
58135
+ }
58136
+ } else if (USE_XHR) {
58137
+ try {
58138
+ var req = new XMLHttpRequest();
58139
+ req.open(options.method, url, true);
58140
+ var headers = this.get_config("xhr_headers");
58141
+ if (use_post) {
58142
+ headers["Content-Type"] = "application/x-www-form-urlencoded";
58143
+ }
58144
+ _$1.each(headers, function(headerValue, headerName) {
58145
+ req.setRequestHeader(headerName, headerValue);
58146
+ });
58147
+ if (options.timeout_ms && typeof req.timeout !== "undefined") {
58148
+ req.timeout = options.timeout_ms;
58149
+ var start_time = new Date().getTime();
58150
+ }
58151
+ req.withCredentials = true;
58152
+ req.onreadystatechange = function() {
58153
+ if (req.readyState === 4) {
58154
+ if (req.status === 200) {
58155
+ if (callback) {
58156
+ if (verbose_mode) {
58157
+ var response;
58158
+ try {
58159
+ response = _$1.JSONDecode(req.responseText);
58160
+ } catch (e) {
58161
+ lib.report_error(e);
58162
+ if (options.ignore_json_errors) {
58163
+ response = req.responseText;
58164
+ } else {
58165
+ return;
58166
+ }
58167
+ }
58168
+ callback(response);
58169
+ } else {
58170
+ callback(Number(req.responseText));
58171
+ }
58172
+ }
58173
+ } else {
58174
+ var error;
58175
+ if (req.timeout && !req.status && new Date().getTime() - start_time >= req.timeout) {
58176
+ error = "timeout";
58177
+ } else {
58178
+ error = "Bad HTTP status: " + req.status + " " + req.statusText;
58179
+ }
58180
+ lib.report_error(error);
58181
+ if (callback) {
58182
+ if (verbose_mode) {
58183
+ callback({ status: 0, error, xhr_req: req });
58184
+ } else {
58185
+ callback(0);
58186
+ }
58187
+ }
58188
+ }
58189
+ }
58190
+ };
58191
+ req.send(body_data);
58192
+ } catch (e) {
58193
+ lib.report_error(e);
58194
+ succeeded = false;
58195
+ }
58196
+ } else {
58197
+ var script = document$1.createElement("script");
58198
+ script.type = "text/javascript";
58199
+ script.async = true;
58200
+ script.defer = true;
58201
+ script.src = url;
58202
+ var s = document$1.getElementsByTagName("script")[0];
58203
+ s.parentNode.insertBefore(script, s);
58204
+ }
58205
+ return succeeded;
58206
+ };
58207
+ MixpanelLib.prototype._execute_array = function(array) {
58208
+ var fn_name, alias_calls = [], other_calls = [], tracking_calls = [];
58209
+ _$1.each(array, function(item) {
58210
+ if (item) {
58211
+ fn_name = item[0];
58212
+ if (_$1.isArray(fn_name)) {
58213
+ tracking_calls.push(item);
58214
+ } else if (typeof item === "function") {
58215
+ item.call(this);
58216
+ } else if (_$1.isArray(item) && fn_name === "alias") {
58217
+ alias_calls.push(item);
58218
+ } else if (_$1.isArray(item) && fn_name.indexOf("track") !== -1 && typeof this[fn_name] === "function") {
58219
+ tracking_calls.push(item);
58220
+ } else {
58221
+ other_calls.push(item);
58222
+ }
58223
+ }
58224
+ }, this);
58225
+ var execute = function(calls, context) {
58226
+ _$1.each(calls, function(item) {
58227
+ if (_$1.isArray(item[0])) {
58228
+ var caller = context;
58229
+ _$1.each(item, function(call) {
58230
+ caller = caller[call[0]].apply(caller, call.slice(1));
58231
+ });
58232
+ } else {
58233
+ this[item[0]].apply(this, item.slice(1));
58234
+ }
58235
+ }, context);
58236
+ };
58237
+ execute(alias_calls, this);
58238
+ execute(other_calls, this);
58239
+ execute(tracking_calls, this);
58240
+ };
58241
+ MixpanelLib.prototype.are_batchers_initialized = function() {
58242
+ return !!this.request_batchers.events;
58243
+ };
58244
+ MixpanelLib.prototype.get_batcher_configs = function() {
58245
+ var queue_prefix = "__mpq_" + this.get_config("token");
58246
+ var api_routes = this.get_config("api_routes");
58247
+ this._batcher_configs = this._batcher_configs || {
58248
+ events: { type: "events", endpoint: "/" + api_routes["track"], queue_key: queue_prefix + "_ev" },
58249
+ people: { type: "people", endpoint: "/" + api_routes["engage"], queue_key: queue_prefix + "_pp" },
58250
+ groups: { type: "groups", endpoint: "/" + api_routes["groups"], queue_key: queue_prefix + "_gr" }
58251
+ };
58252
+ return this._batcher_configs;
58253
+ };
58254
+ MixpanelLib.prototype.init_batchers = function() {
58255
+ if (!this.are_batchers_initialized()) {
58256
+ var batcher_for = _$1.bind(function(attrs) {
58257
+ return new RequestBatcher(
58258
+ attrs.queue_key,
58259
+ {
58260
+ libConfig: this["config"],
58261
+ sendRequestFunc: _$1.bind(function(data, options, cb) {
58262
+ this._send_request(
58263
+ this.get_config("api_host") + attrs.endpoint,
58264
+ this._encode_data_for_request(data),
58265
+ options,
58266
+ this._prepare_callback(cb, data)
58267
+ );
58268
+ }, this),
58269
+ beforeSendHook: _$1.bind(function(item) {
58270
+ return this._run_hook("before_send_" + attrs.type, item);
58271
+ }, this),
58272
+ errorReporter: this.get_config("error_reporter"),
58273
+ stopAllBatchingFunc: _$1.bind(this.stop_batch_senders, this)
58274
+ }
58275
+ );
58276
+ }, this);
58277
+ var batcher_configs = this.get_batcher_configs();
58278
+ this.request_batchers = {
58279
+ events: batcher_for(batcher_configs.events),
58280
+ people: batcher_for(batcher_configs.people),
58281
+ groups: batcher_for(batcher_configs.groups)
58282
+ };
58283
+ }
58284
+ if (this.get_config("batch_autostart")) {
58285
+ this.start_batch_senders();
58286
+ }
58287
+ };
58288
+ MixpanelLib.prototype.start_batch_senders = function() {
58289
+ this._batchers_were_started = true;
58290
+ if (this.are_batchers_initialized()) {
58291
+ this._batch_requests = true;
58292
+ _$1.each(this.request_batchers, function(batcher) {
58293
+ batcher.start();
58294
+ });
58295
+ }
58296
+ };
58297
+ MixpanelLib.prototype.stop_batch_senders = function() {
58298
+ this._batch_requests = false;
58299
+ _$1.each(this.request_batchers, function(batcher) {
58300
+ batcher.stop();
58301
+ batcher.clear();
58302
+ });
58303
+ };
58304
+ MixpanelLib.prototype.push = function(item) {
58305
+ this._execute_array([item]);
58306
+ };
58307
+ MixpanelLib.prototype.disable = function(events) {
58308
+ if (typeof events === "undefined") {
58309
+ this._flags.disable_all_events = true;
58310
+ } else {
58311
+ this.__disabled_events = this.__disabled_events.concat(events);
58312
+ }
58313
+ };
58314
+ MixpanelLib.prototype._encode_data_for_request = function(data) {
58315
+ var encoded_data = _$1.JSONEncode(data);
58316
+ if (this.get_config("api_payload_format") === PAYLOAD_TYPE_BASE64) {
58317
+ encoded_data = _$1.base64Encode(encoded_data);
58318
+ }
58319
+ return { "data": encoded_data };
58320
+ };
58321
+ MixpanelLib.prototype._track_or_batch = function(options, callback) {
58322
+ var truncated_data = _$1.truncate(options.data, 255);
58323
+ var endpoint = options.endpoint;
58324
+ var batcher = options.batcher;
58325
+ var should_send_immediately = options.should_send_immediately;
58326
+ var send_request_options = options.send_request_options || {};
58327
+ callback = callback || NOOP_FUNC;
58328
+ var request_enqueued_or_initiated = true;
58329
+ var send_request_immediately = _$1.bind(function() {
58330
+ if (!send_request_options.skip_hooks) {
58331
+ truncated_data = this._run_hook("before_send_" + options.type, truncated_data);
58332
+ }
58333
+ if (truncated_data) {
58334
+ console$1.log("MIXPANEL REQUEST:");
58335
+ console$1.log(truncated_data);
58336
+ return this._send_request(
58337
+ endpoint,
58338
+ this._encode_data_for_request(truncated_data),
58339
+ send_request_options,
58340
+ this._prepare_callback(callback, truncated_data)
58341
+ );
58342
+ } else {
58343
+ return null;
58344
+ }
58345
+ }, this);
58346
+ if (this._batch_requests && !should_send_immediately) {
58347
+ batcher.enqueue(truncated_data, function(succeeded) {
58348
+ if (succeeded) {
58349
+ callback(1, truncated_data);
58350
+ } else {
58351
+ send_request_immediately();
58352
+ }
58353
+ });
58354
+ } else {
58355
+ request_enqueued_or_initiated = send_request_immediately();
58356
+ }
58357
+ return request_enqueued_or_initiated && truncated_data;
58358
+ };
58359
+ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
58360
+ if (!callback && typeof options === "function") {
58361
+ callback = options;
58362
+ options = null;
58363
+ }
58364
+ options = options || {};
58365
+ var transport = options["transport"];
58366
+ if (transport) {
58367
+ options.transport = transport;
58368
+ }
58369
+ var should_send_immediately = options["send_immediately"];
58370
+ if (typeof callback !== "function") {
58371
+ callback = NOOP_FUNC;
58372
+ }
58373
+ if (_$1.isUndefined(event_name)) {
58374
+ this.report_error("No event name provided to mixpanel.track");
58375
+ return;
58376
+ }
58377
+ if (this._event_is_disabled(event_name)) {
58378
+ callback(0);
58379
+ return;
58380
+ }
58381
+ properties = _$1.extend({}, properties);
58382
+ properties["token"] = this.get_config("token");
58383
+ var start_timestamp = this["persistence"].remove_event_timer(event_name);
58384
+ if (!_$1.isUndefined(start_timestamp)) {
58385
+ var duration_in_ms = new Date().getTime() - start_timestamp;
58386
+ properties["$duration"] = parseFloat((duration_in_ms / 1e3).toFixed(3));
58387
+ }
58388
+ this._set_default_superprops();
58389
+ var marketing_properties = this.get_config("track_marketing") ? _$1.info.marketingParams() : {};
58390
+ properties = _$1.extend(
58391
+ {},
58392
+ _$1.info.properties({ "mp_loader": this.get_config("mp_loader") }),
58393
+ marketing_properties,
58394
+ this["persistence"].properties(),
58395
+ this.unpersisted_superprops,
58396
+ this.get_session_recording_properties(),
58397
+ properties
58398
+ );
58399
+ var property_blacklist = this.get_config("property_blacklist");
58400
+ if (_$1.isArray(property_blacklist)) {
58401
+ _$1.each(property_blacklist, function(blacklisted_prop) {
58402
+ delete properties[blacklisted_prop];
58403
+ });
58404
+ } else {
58405
+ this.report_error("Invalid value for property_blacklist config: " + property_blacklist);
58406
+ }
58407
+ var data = {
58408
+ "event": event_name,
58409
+ "properties": properties
58410
+ };
58411
+ var ret = this._track_or_batch({
58412
+ type: "events",
58413
+ data,
58414
+ endpoint: this.get_config("api_host") + "/" + this.get_config("api_routes")["track"],
58415
+ batcher: this.request_batchers.events,
58416
+ should_send_immediately,
58417
+ send_request_options: options
58418
+ }, callback);
58419
+ return ret;
58420
+ });
58421
+ MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key, group_ids, callback) {
58422
+ if (!_$1.isArray(group_ids)) {
58423
+ group_ids = [group_ids];
58424
+ }
58425
+ var prop = {};
58426
+ prop[group_key] = group_ids;
58427
+ this.register(prop);
58428
+ return this["people"].set(group_key, group_ids, callback);
58429
+ });
58430
+ MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
58431
+ var old_values = this.get_property(group_key);
58432
+ var prop = {};
58433
+ if (old_values === void 0) {
58434
+ prop[group_key] = [group_id];
58435
+ this.register(prop);
58436
+ } else {
58437
+ if (old_values.indexOf(group_id) === -1) {
58438
+ old_values.push(group_id);
58439
+ prop[group_key] = old_values;
58440
+ this.register(prop);
58441
+ }
58442
+ }
58443
+ return this["people"].union(group_key, group_id, callback);
58444
+ });
58445
+ MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_key, group_id, callback) {
58446
+ var old_value = this.get_property(group_key);
58447
+ if (old_value !== void 0) {
58448
+ var idx = old_value.indexOf(group_id);
58449
+ if (idx > -1) {
58450
+ old_value.splice(idx, 1);
58451
+ this.register({ group_key: old_value });
58452
+ }
58453
+ if (old_value.length === 0) {
58454
+ this.unregister(group_key);
58455
+ }
58456
+ }
58457
+ return this["people"].remove(group_key, group_id, callback);
58458
+ });
58459
+ MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(event_name, properties, groups, callback) {
58460
+ var tracking_props = _$1.extend({}, properties || {});
58461
+ _$1.each(groups, function(v, k) {
58462
+ if (v !== null && v !== void 0) {
58463
+ tracking_props[k] = v;
58464
+ }
58465
+ });
58466
+ return this.track(event_name, tracking_props, callback);
58467
+ });
58468
+ MixpanelLib.prototype._create_map_key = function(group_key, group_id) {
58469
+ return group_key + "_" + JSON.stringify(group_id);
58470
+ };
58471
+ MixpanelLib.prototype._remove_group_from_cache = function(group_key, group_id) {
58472
+ delete this._cached_groups[this._create_map_key(group_key, group_id)];
58473
+ };
58474
+ MixpanelLib.prototype.get_group = function(group_key, group_id) {
58475
+ var map_key = this._create_map_key(group_key, group_id);
58476
+ var group = this._cached_groups[map_key];
58477
+ if (group === void 0 || group._group_key !== group_key || group._group_id !== group_id) {
58478
+ group = new MixpanelGroup();
58479
+ group._init(this, group_key, group_id);
58480
+ this._cached_groups[map_key] = group;
58481
+ }
58482
+ return group;
58483
+ };
58484
+ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
58485
+ if (typeof properties !== "object") {
58486
+ properties = {};
58487
+ }
58488
+ options = options || {};
58489
+ var event_name = options["event_name"] || "$mp_web_page_view";
58490
+ var default_page_properties = _$1.extend(
58491
+ _$1.info.mpPageViewProperties(),
58492
+ _$1.info.campaignParams(),
58493
+ _$1.info.clickParams()
58494
+ );
58495
+ var event_properties = _$1.extend(
58496
+ {},
58497
+ default_page_properties,
58498
+ properties
58499
+ );
58500
+ return this.track(event_name, event_properties);
58501
+ });
58502
+ MixpanelLib.prototype.track_links = function() {
58503
+ return this._track_dom.call(this, LinkTracker, arguments);
58504
+ };
58505
+ MixpanelLib.prototype.track_forms = function() {
58506
+ return this._track_dom.call(this, FormTracker, arguments);
58507
+ };
58508
+ MixpanelLib.prototype.time_event = function(event_name) {
58509
+ if (_$1.isUndefined(event_name)) {
58510
+ this.report_error("No event name provided to mixpanel.time_event");
58511
+ return;
58512
+ }
58513
+ if (this._event_is_disabled(event_name)) {
58514
+ return;
58515
+ }
58516
+ this["persistence"].set_event_timer(event_name, new Date().getTime());
58517
+ };
58518
+ var REGISTER_DEFAULTS = {
58519
+ "persistent": true
58520
+ };
58521
+ var options_for_register = function(days_or_options) {
58522
+ var options;
58523
+ if (_$1.isObject(days_or_options)) {
58524
+ options = days_or_options;
58525
+ } else if (!_$1.isUndefined(days_or_options)) {
58526
+ options = { "days": days_or_options };
58527
+ } else {
58528
+ options = {};
58529
+ }
58530
+ return _$1.extend({}, REGISTER_DEFAULTS, options);
58531
+ };
58532
+ MixpanelLib.prototype.register = function(props, days_or_options) {
58533
+ var options = options_for_register(days_or_options);
58534
+ if (options["persistent"]) {
58535
+ this["persistence"].register(props, options["days"]);
58536
+ } else {
58537
+ _$1.extend(this.unpersisted_superprops, props);
58538
+ }
58539
+ };
58540
+ MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
58541
+ var options = options_for_register(days_or_options);
58542
+ if (options["persistent"]) {
58543
+ this["persistence"].register_once(props, default_value, options["days"]);
58544
+ } else {
58545
+ if (typeof default_value === "undefined") {
58546
+ default_value = "None";
58547
+ }
58548
+ _$1.each(props, function(val, prop) {
58549
+ if (!this.unpersisted_superprops.hasOwnProperty(prop) || this.unpersisted_superprops[prop] === default_value) {
58550
+ this.unpersisted_superprops[prop] = val;
58551
+ }
58552
+ }, this);
58553
+ }
58554
+ };
58555
+ MixpanelLib.prototype.unregister = function(property, options) {
58556
+ options = options_for_register(options);
58557
+ if (options["persistent"]) {
58558
+ this["persistence"].unregister(property);
58559
+ } else {
58560
+ delete this.unpersisted_superprops[property];
58561
+ }
58562
+ };
58563
+ MixpanelLib.prototype._register_single = function(prop, value) {
58564
+ var props = {};
58565
+ props[prop] = value;
58566
+ this.register(props);
58567
+ };
58568
+ MixpanelLib.prototype.identify = function(new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback) {
58569
+ var previous_distinct_id = this.get_distinct_id();
58570
+ if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
58571
+ if (typeof new_distinct_id === "string" && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
58572
+ this.report_error("distinct_id cannot have $device: prefix");
58573
+ return -1;
58574
+ }
58575
+ this.register({ "$user_id": new_distinct_id });
58576
+ }
58577
+ if (!this.get_property("$device_id")) {
58578
+ var device_id = previous_distinct_id;
58579
+ this.register_once({
58580
+ "$had_persisted_distinct_id": true,
58581
+ "$device_id": device_id
58582
+ }, "");
58583
+ }
58584
+ if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
58585
+ this.unregister(ALIAS_ID_KEY);
58586
+ this.register({ "distinct_id": new_distinct_id });
58587
+ }
58588
+ this._flags.identify_called = true;
58589
+ this["people"]._flush(_set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback);
58590
+ if (new_distinct_id !== previous_distinct_id) {
58591
+ this.track("$identify", {
58592
+ "distinct_id": new_distinct_id,
58593
+ "$anon_distinct_id": previous_distinct_id
58594
+ }, { skip_hooks: true });
58595
+ }
58596
+ };
58597
+ MixpanelLib.prototype.reset = function() {
58598
+ this["persistence"].clear();
58599
+ this._flags.identify_called = false;
58600
+ var uuid2 = _$1.UUID();
58601
+ this.register_once({
58602
+ "distinct_id": DEVICE_ID_PREFIX + uuid2,
58603
+ "$device_id": uuid2
58604
+ }, "");
58605
+ };
58606
+ MixpanelLib.prototype.get_distinct_id = function() {
58607
+ return this.get_property("distinct_id");
58608
+ };
58609
+ MixpanelLib.prototype.alias = function(alias, original) {
58610
+ if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
58611
+ this.report_error("Attempting to create alias for existing People user - aborting.");
58612
+ return -2;
58613
+ }
58614
+ var _this = this;
58615
+ if (_$1.isUndefined(original)) {
58616
+ original = this.get_distinct_id();
58617
+ }
58618
+ if (alias !== original) {
58619
+ this._register_single(ALIAS_ID_KEY, alias);
58620
+ return this.track("$create_alias", {
58621
+ "alias": alias,
58622
+ "distinct_id": original
58623
+ }, {
58624
+ skip_hooks: true
58625
+ }, function() {
58626
+ _this.identify(alias);
58627
+ });
58628
+ } else {
58629
+ this.report_error("alias matches current distinct_id - skipping api call.");
58630
+ this.identify(alias);
58631
+ return -1;
58632
+ }
58633
+ };
58634
+ MixpanelLib.prototype.name_tag = function(name_tag) {
58635
+ this._register_single("mp_name_tag", name_tag);
58636
+ };
58637
+ MixpanelLib.prototype.set_config = function(config) {
58638
+ if (_$1.isObject(config)) {
58639
+ _$1.extend(this["config"], config);
58640
+ var new_batch_size = config["batch_size"];
58641
+ if (new_batch_size) {
58642
+ _$1.each(this.request_batchers, function(batcher) {
58643
+ batcher.resetBatchSize();
58644
+ });
58645
+ }
58646
+ if (!this.get_config("persistence_name")) {
58647
+ this["config"]["persistence_name"] = this["config"]["cookie_name"];
58648
+ }
58649
+ if (!this.get_config("disable_persistence")) {
58650
+ this["config"]["disable_persistence"] = this["config"]["disable_cookie"];
58651
+ }
58652
+ if (this["persistence"]) {
58653
+ this["persistence"].update_config(this["config"]);
58654
+ }
58655
+ Config.DEBUG = Config.DEBUG || this.get_config("debug");
58656
+ }
58657
+ };
58658
+ MixpanelLib.prototype.get_config = function(prop_name) {
58659
+ return this["config"][prop_name];
58660
+ };
58661
+ MixpanelLib.prototype._run_hook = function(hook_name) {
58662
+ var ret = (this["config"]["hooks"][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
58663
+ if (typeof ret === "undefined") {
58664
+ this.report_error(hook_name + " hook did not return a value");
58665
+ ret = null;
58666
+ }
58667
+ return ret;
58668
+ };
58669
+ MixpanelLib.prototype.get_property = function(property_name) {
58670
+ return this["persistence"].load_prop([property_name]);
58671
+ };
58672
+ MixpanelLib.prototype.toString = function() {
58673
+ var name2 = this.get_config("name");
58674
+ if (name2 !== PRIMARY_INSTANCE_NAME) {
58675
+ name2 = PRIMARY_INSTANCE_NAME + "." + name2;
58676
+ }
58677
+ return name2;
58678
+ };
58679
+ MixpanelLib.prototype._event_is_disabled = function(event_name) {
58680
+ return _$1.isBlockedUA(userAgent) || this._flags.disable_all_events || _$1.include(this.__disabled_events, event_name);
58681
+ };
58682
+ MixpanelLib.prototype._gdpr_init = function() {
58683
+ var is_localStorage_requested = this.get_config("opt_out_tracking_persistence_type") === "localStorage";
58684
+ if (is_localStorage_requested && _$1.localStorage.is_supported()) {
58685
+ if (!this.has_opted_in_tracking() && this.has_opted_in_tracking({ "persistence_type": "cookie" })) {
58686
+ this.opt_in_tracking({ "enable_persistence": false });
58687
+ }
58688
+ if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({ "persistence_type": "cookie" })) {
58689
+ this.opt_out_tracking({ "clear_persistence": false });
58690
+ }
58691
+ this.clear_opt_in_out_tracking({
58692
+ "persistence_type": "cookie",
58693
+ "enable_persistence": false
58694
+ });
58695
+ }
58696
+ if (this.has_opted_out_tracking()) {
58697
+ this._gdpr_update_persistence({ "clear_persistence": true });
58698
+ } else if (!this.has_opted_in_tracking() && (this.get_config("opt_out_tracking_by_default") || _$1.cookie.get("mp_optout"))) {
58699
+ _$1.cookie.remove("mp_optout");
58700
+ this.opt_out_tracking({
58701
+ "clear_persistence": this.get_config("opt_out_persistence_by_default")
58702
+ });
58703
+ }
58704
+ };
58705
+ MixpanelLib.prototype._gdpr_update_persistence = function(options) {
58706
+ var disabled;
58707
+ if (options && options["clear_persistence"]) {
58708
+ disabled = true;
58709
+ } else if (options && options["enable_persistence"]) {
58710
+ disabled = false;
58711
+ } else {
58712
+ return;
58713
+ }
58714
+ if (!this.get_config("disable_persistence") && this["persistence"].disabled !== disabled) {
58715
+ this["persistence"].set_disabled(disabled);
58716
+ }
58717
+ if (disabled) {
58718
+ this.stop_batch_senders();
58719
+ } else {
58720
+ if (this._batchers_were_started) {
58721
+ this.start_batch_senders();
58722
+ }
58723
+ }
58724
+ };
58725
+ MixpanelLib.prototype._gdpr_call_func = function(func, options) {
58726
+ options = _$1.extend({
58727
+ "track": _$1.bind(this.track, this),
58728
+ "persistence_type": this.get_config("opt_out_tracking_persistence_type"),
58729
+ "cookie_prefix": this.get_config("opt_out_tracking_cookie_prefix"),
58730
+ "cookie_expiration": this.get_config("cookie_expiration"),
58731
+ "cross_site_cookie": this.get_config("cross_site_cookie"),
58732
+ "cross_subdomain_cookie": this.get_config("cross_subdomain_cookie"),
58733
+ "cookie_domain": this.get_config("cookie_domain"),
58734
+ "secure_cookie": this.get_config("secure_cookie"),
58735
+ "ignore_dnt": this.get_config("ignore_dnt")
58736
+ }, options);
58737
+ if (!_$1.localStorage.is_supported()) {
58738
+ options["persistence_type"] = "cookie";
58739
+ }
58740
+ return func(this.get_config("token"), {
58741
+ track: options["track"],
58742
+ trackEventName: options["track_event_name"],
58743
+ trackProperties: options["track_properties"],
58744
+ persistenceType: options["persistence_type"],
58745
+ persistencePrefix: options["cookie_prefix"],
58746
+ cookieDomain: options["cookie_domain"],
58747
+ cookieExpiration: options["cookie_expiration"],
58748
+ crossSiteCookie: options["cross_site_cookie"],
58749
+ crossSubdomainCookie: options["cross_subdomain_cookie"],
58750
+ secureCookie: options["secure_cookie"],
58751
+ ignoreDnt: options["ignore_dnt"]
58752
+ });
58753
+ };
58754
+ MixpanelLib.prototype.opt_in_tracking = function(options) {
58755
+ options = _$1.extend({
58756
+ "enable_persistence": true
58757
+ }, options);
58758
+ this._gdpr_call_func(optIn, options);
58759
+ this._gdpr_update_persistence(options);
58760
+ };
58761
+ MixpanelLib.prototype.opt_out_tracking = function(options) {
58762
+ options = _$1.extend({
58763
+ "clear_persistence": true,
58764
+ "delete_user": true
58765
+ }, options);
58766
+ if (options["delete_user"] && this["people"] && this["people"]._identify_called()) {
58767
+ this["people"].delete_user();
58768
+ this["people"].clear_charges();
58769
+ }
58770
+ this._gdpr_call_func(optOut, options);
58771
+ this._gdpr_update_persistence(options);
58772
+ };
58773
+ MixpanelLib.prototype.has_opted_in_tracking = function(options) {
58774
+ return this._gdpr_call_func(hasOptedIn, options);
58775
+ };
58776
+ MixpanelLib.prototype.has_opted_out_tracking = function(options) {
58777
+ return this._gdpr_call_func(hasOptedOut, options);
58778
+ };
58779
+ MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
58780
+ options = _$1.extend({
58781
+ "enable_persistence": true
58782
+ }, options);
58783
+ this._gdpr_call_func(clearOptInOut, options);
58784
+ this._gdpr_update_persistence(options);
58785
+ };
58786
+ MixpanelLib.prototype.report_error = function(msg, err) {
58787
+ console$1.error.apply(console$1.error, arguments);
58788
+ try {
58789
+ if (!err && !(msg instanceof Error)) {
58790
+ msg = new Error(msg);
58791
+ }
58792
+ this.get_config("error_reporter")(msg, err);
58793
+ } catch (err2) {
58794
+ console$1.error(err2);
58795
+ }
58796
+ };
58797
+ MixpanelLib.prototype["init"] = MixpanelLib.prototype.init;
58798
+ MixpanelLib.prototype["reset"] = MixpanelLib.prototype.reset;
58799
+ MixpanelLib.prototype["disable"] = MixpanelLib.prototype.disable;
58800
+ MixpanelLib.prototype["time_event"] = MixpanelLib.prototype.time_event;
58801
+ MixpanelLib.prototype["track"] = MixpanelLib.prototype.track;
58802
+ MixpanelLib.prototype["track_links"] = MixpanelLib.prototype.track_links;
58803
+ MixpanelLib.prototype["track_forms"] = MixpanelLib.prototype.track_forms;
58804
+ MixpanelLib.prototype["track_pageview"] = MixpanelLib.prototype.track_pageview;
58805
+ MixpanelLib.prototype["register"] = MixpanelLib.prototype.register;
58806
+ MixpanelLib.prototype["register_once"] = MixpanelLib.prototype.register_once;
58807
+ MixpanelLib.prototype["unregister"] = MixpanelLib.prototype.unregister;
58808
+ MixpanelLib.prototype["identify"] = MixpanelLib.prototype.identify;
58809
+ MixpanelLib.prototype["alias"] = MixpanelLib.prototype.alias;
58810
+ MixpanelLib.prototype["name_tag"] = MixpanelLib.prototype.name_tag;
58811
+ MixpanelLib.prototype["set_config"] = MixpanelLib.prototype.set_config;
58812
+ MixpanelLib.prototype["get_config"] = MixpanelLib.prototype.get_config;
58813
+ MixpanelLib.prototype["get_property"] = MixpanelLib.prototype.get_property;
58814
+ MixpanelLib.prototype["get_distinct_id"] = MixpanelLib.prototype.get_distinct_id;
58815
+ MixpanelLib.prototype["toString"] = MixpanelLib.prototype.toString;
58816
+ MixpanelLib.prototype["opt_out_tracking"] = MixpanelLib.prototype.opt_out_tracking;
58817
+ MixpanelLib.prototype["opt_in_tracking"] = MixpanelLib.prototype.opt_in_tracking;
58818
+ MixpanelLib.prototype["has_opted_out_tracking"] = MixpanelLib.prototype.has_opted_out_tracking;
58819
+ MixpanelLib.prototype["has_opted_in_tracking"] = MixpanelLib.prototype.has_opted_in_tracking;
58820
+ MixpanelLib.prototype["clear_opt_in_out_tracking"] = MixpanelLib.prototype.clear_opt_in_out_tracking;
58821
+ MixpanelLib.prototype["get_group"] = MixpanelLib.prototype.get_group;
58822
+ MixpanelLib.prototype["set_group"] = MixpanelLib.prototype.set_group;
58823
+ MixpanelLib.prototype["add_group"] = MixpanelLib.prototype.add_group;
58824
+ MixpanelLib.prototype["remove_group"] = MixpanelLib.prototype.remove_group;
58825
+ MixpanelLib.prototype["track_with_groups"] = MixpanelLib.prototype.track_with_groups;
58826
+ MixpanelLib.prototype["start_batch_senders"] = MixpanelLib.prototype.start_batch_senders;
58827
+ MixpanelLib.prototype["stop_batch_senders"] = MixpanelLib.prototype.stop_batch_senders;
58828
+ MixpanelLib.prototype["start_session_recording"] = MixpanelLib.prototype.start_session_recording;
58829
+ MixpanelLib.prototype["stop_session_recording"] = MixpanelLib.prototype.stop_session_recording;
58830
+ MixpanelLib.prototype["get_session_recording_properties"] = MixpanelLib.prototype.get_session_recording_properties;
58831
+ MixpanelLib.prototype["DEFAULT_API_ROUTES"] = DEFAULT_API_ROUTES;
58832
+ MixpanelPersistence.prototype["properties"] = MixpanelPersistence.prototype.properties;
58833
+ MixpanelPersistence.prototype["update_search_keyword"] = MixpanelPersistence.prototype.update_search_keyword;
58834
+ MixpanelPersistence.prototype["update_referrer_info"] = MixpanelPersistence.prototype.update_referrer_info;
58835
+ MixpanelPersistence.prototype["get_cross_subdomain"] = MixpanelPersistence.prototype.get_cross_subdomain;
58836
+ MixpanelPersistence.prototype["clear"] = MixpanelPersistence.prototype.clear;
58837
+ var instances = {};
58838
+ var extend_mp = function() {
58839
+ _$1.each(instances, function(instance, name2) {
58840
+ if (name2 !== PRIMARY_INSTANCE_NAME) {
58841
+ mixpanel_master[name2] = instance;
58842
+ }
58843
+ });
58844
+ mixpanel_master["_"] = _$1;
58845
+ };
58846
+ var override_mp_init_func = function() {
58847
+ mixpanel_master["init"] = function(token, config, name2) {
58848
+ if (name2) {
58849
+ if (!mixpanel_master[name2]) {
58850
+ mixpanel_master[name2] = instances[name2] = create_mplib(token, config, name2);
58851
+ mixpanel_master[name2]._loaded();
58852
+ }
58853
+ return mixpanel_master[name2];
58854
+ } else {
58855
+ var instance = mixpanel_master;
58856
+ if (instances[PRIMARY_INSTANCE_NAME]) {
58857
+ instance = instances[PRIMARY_INSTANCE_NAME];
58858
+ } else if (token) {
58859
+ instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
58860
+ instance._loaded();
58861
+ instances[PRIMARY_INSTANCE_NAME] = instance;
58862
+ }
58863
+ mixpanel_master = instance;
58864
+ if (init_type === INIT_SNIPPET) {
58865
+ win[PRIMARY_INSTANCE_NAME] = mixpanel_master;
58866
+ }
58867
+ extend_mp();
58868
+ }
58869
+ };
58870
+ };
58871
+ var add_dom_loaded_handler = function() {
58872
+ function dom_loaded_handler() {
58873
+ if (dom_loaded_handler.done) {
58874
+ return;
58875
+ }
58876
+ dom_loaded_handler.done = true;
58877
+ DOM_LOADED = true;
58878
+ ENQUEUE_REQUESTS = false;
58879
+ _$1.each(instances, function(inst) {
58880
+ inst._dom_loaded();
58881
+ });
58882
+ }
58883
+ function do_scroll_check() {
58884
+ try {
58885
+ document$1.documentElement.doScroll("left");
58886
+ } catch (e) {
58887
+ setTimeout(do_scroll_check, 1);
58888
+ return;
58889
+ }
58890
+ dom_loaded_handler();
58891
+ }
58892
+ if (document$1.addEventListener) {
58893
+ if (document$1.readyState === "complete") {
58894
+ dom_loaded_handler();
58895
+ } else {
58896
+ document$1.addEventListener("DOMContentLoaded", dom_loaded_handler, false);
58897
+ }
58898
+ } else if (document$1.attachEvent) {
58899
+ document$1.attachEvent("onreadystatechange", dom_loaded_handler);
58900
+ var toplevel = false;
58901
+ try {
58902
+ toplevel = win.frameElement === null;
58903
+ } catch (e) {
58904
+ }
58905
+ if (document$1.documentElement.doScroll && toplevel) {
58906
+ do_scroll_check();
58907
+ }
58908
+ }
58909
+ _$1.register_event(win, "load", dom_loaded_handler, true);
58910
+ };
58911
+ function init_as_module() {
58912
+ init_type = INIT_MODULE;
58913
+ mixpanel_master = new MixpanelLib();
58914
+ override_mp_init_func();
58915
+ mixpanel_master["init"]();
58916
+ add_dom_loaded_handler();
58917
+ return mixpanel_master;
58918
+ }
58919
+ var mixpanel = init_as_module();
58920
+ var mixpanel_cjs = mixpanel;
58921
+ module$2.factory("MixpanelService", [function() {
58922
+ const service = {};
58923
+ const mixpanelTimescaleProxyDEV = "https://d3ige8rf4hrn8x.cloudfront.net/dev";
58924
+ mixpanel_cjs.init("some_token");
58925
+ mixpanel_cjs.init("", { api_host: mixpanelTimescaleProxyDEV }, "proxy");
58926
+ service.sendProxyEvent = (event2, properties) => {
58927
+ try {
58928
+ event2 = event2.toLowerCase();
58929
+ properties = properties || {};
58930
+ if (properties.user_id) {
58931
+ mixpanel_cjs.proxy.identify(properties.user_id);
58932
+ }
58933
+ mixpanel_cjs.proxy.track(event2, properties);
58934
+ } catch (err) {
58935
+ console.log("Failed to send MX event");
58936
+ }
58937
+ };
58938
+ return service;
58939
+ }]);
58940
+ module$2.service("PlayerTrackerService", ["MixpanelService", function(MixpanelService) {
58941
+ this.track = function(event2, properties) {
58942
+ properties.__table = "video_events";
58943
+ MixpanelService.sendProxyEvent(event2, properties);
58944
+ };
58945
+ try {
58946
+ const broadCastChannel = new BroadcastChannel("chunk_loaded");
58947
+ const origOpen = XMLHttpRequest.prototype.open;
58948
+ XMLHttpRequest.prototype.open = function() {
58949
+ this.addEventListener("load", function() {
58950
+ let url;
58951
+ try {
58952
+ url = new URL(this.responseURL);
58953
+ if (this.status === 200 && url && ["stream.videoflow.io", "dflsjqznkm1lx.cloudfront.net", "a6f45de6e044.us-west-2.playback.live-video.net", "live.videoflow.io"].includes(url.hostname) && url.pathname.match(/.(ts|cmfv|cmfa)$/)) {
58954
+ broadCastChannel.postMessage(JSON.stringify({ size: parseInt(this.getResponseHeader("content-length")) }));
58955
+ }
58956
+ } catch (err) {
58957
+ }
58958
+ });
58959
+ origOpen.apply(this, arguments);
58960
+ };
58961
+ } catch (err) {
58962
+ }
58963
+ return this;
58964
+ }]).factory("PlayerTracker", ["PlayerTrackerService", function(PlayerTrackerService) {
58965
+ const watchTimeEvent = "video_watched_time";
58966
+ const TrackedEvents = {
58967
+ impression: true,
58968
+ play: false,
58969
+ pause: false,
58970
+ ended: false,
58971
+ "section watched": true,
58972
+ "ad started": true,
58973
+ "ad impression": false,
58974
+ "ad skipped": true,
58975
+ "ad completed": true,
58976
+ "chunk": true
58977
+ };
58978
+ const tracker2 = function Tracker(player, metadata) {
58979
+ this.player = player;
58980
+ this.metadata = metadata;
58981
+ this.player.one("play", () => {
58982
+ try {
58983
+ const props = this._getProps();
58984
+ props.event = "impression";
58985
+ if (TrackedEvents[props.event])
58986
+ PlayerTrackerService.track("video", props);
58987
+ this.sendSectionWatchedEvent();
58988
+ } catch (err) {
58989
+ }
58990
+ });
58991
+ this.on("play");
58992
+ this.on("pause");
58993
+ this.on("ended");
58994
+ const prop = {};
58995
+ prop[watchTimeEvent] = 0;
58996
+ mixpanel_cjs.register_once(prop);
58997
+ this.lastTimeUpdate = 0;
58998
+ this.watchTime = 0;
58999
+ let sectionWatchSent = 0;
59000
+ const sectionDuration = 30;
59001
+ let self2 = this;
59002
+ this.chunkListener = function(event2) {
59003
+ try {
59004
+ let data = JSON.parse(event2.data);
59005
+ const props = self2._getProps();
59006
+ props.event = "chunk";
59007
+ Object.assign(props, self2._getHLSProps());
59008
+ props.stream_bitrate = data.size;
59009
+ if (TrackedEvents[props.event])
59010
+ PlayerTrackerService.track("video", props);
59011
+ } catch (err) {
59012
+ }
59013
+ };
59014
+ this.sendSectionWatchedEvent = function() {
59015
+ const props = this._getProps();
59016
+ props.event = "section watched";
59017
+ props.section_duration = sectionDuration;
59018
+ props.measure = sectionDuration;
59019
+ Object.assign(props, this._getHLSProps());
59020
+ if (TrackedEvents[props.event])
59021
+ PlayerTrackerService.track("video", props);
59022
+ };
59023
+ try {
59024
+ this.broadcastChannel = new BroadcastChannel("chunk_loaded");
59025
+ this.broadcastChannel.addEventListener("message", this.chunkListener);
59026
+ } catch (err) {
59027
+ }
59028
+ this.player.on("frag_loaded", (event2, data) => {
59029
+ try {
59030
+ const props = this._getProps();
59031
+ props.event = "chunk";
59032
+ props.stream_bitrate = data.frag.loaded;
59033
+ Object.assign(props, this._getHLSProps());
59034
+ props.stream_segment_duration = data.frag.duration;
59035
+ if (TrackedEvents[props.event])
59036
+ PlayerTrackerService.track("video", props);
59037
+ } catch (err) {
59038
+ }
59039
+ });
59040
+ this.player.on("timeupdate", (event2) => {
59041
+ if (this.lastTimeUpdate && Math.abs(this.player.currentTime() - this.lastTimeUpdate) < 1) {
59042
+ this._increment(watchTimeEvent, this.player.currentTime() - this.lastTimeUpdate);
59043
+ this.watchTime += this.player.currentTime() - this.lastTimeUpdate;
59044
+ }
59045
+ this.lastTimeUpdate = this.player.currentTime();
59046
+ if (this.watchTime - sectionWatchSent > sectionDuration) {
59047
+ try {
59048
+ this.sendSectionWatchedEvent();
59049
+ sectionWatchSent = this.watchTime;
59050
+ } catch (err) {
59051
+ }
59052
+ }
59053
+ });
59054
+ };
59055
+ tracker2.prototype = {
59056
+ _getInputType: function(input) {
59057
+ if (input.type === "live")
59058
+ return input.live_type;
59059
+ if (input.type === "normal") {
59060
+ return "custom";
59061
+ }
59062
+ return input.type;
59063
+ },
59064
+ _getProps: function() {
59065
+ let props = {
59066
+ input_src: this.player.src(),
59067
+ input_name: this.metadata.videoTitle,
59068
+ input_token: this.metadata.videoId,
59069
+ input_tags: this.metadata.videoTags,
59070
+ input_parent_id: this.metadata.videoParentId,
59071
+ input_parent_token: this.metadata.videoParentId,
59072
+ organization_owner: this.metadata.workspaceOwner,
59073
+ organization_name: this.metadata.workspaceName,
59074
+ organization_token: this.metadata.workspaceToken,
59075
+ organization_id: this.metadata.workspaceId,
59076
+ channel_name: this.metadata.channelTitle,
59077
+ channel_token: this.metadata.channelId,
59078
+ video_current_watch_time: parseFloat(this.watchTime.toFixed(2)),
59079
+ video_duration: parseFloat(this.player.duration().toFixed(2)),
59080
+ video_current_time: parseFloat(this.player.currentTime().toFixed(2)),
59081
+ is_recording: !!this.metadata.isRecording,
59082
+ is_external: !!this.metadata.isExternal,
59083
+ input_stream_state: this.metadata.videoState,
59084
+ input_type: this.metadata.videoType,
59085
+ user_id: this.metadata.viewerId
59086
+ };
59087
+ return props;
59088
+ },
59089
+ _aproxEq: function(val1, val2, delta) {
59090
+ return val1 >= val2 - delta && val1 <= val2 + delta;
59091
+ },
59092
+ _getHLSProps: function() {
59093
+ try {
59094
+ if (this.player.vfhls.currentLevel) {
59095
+ return {
59096
+ stream_width: this.player.vfhls.currentLevel.width,
59097
+ stream_height: this.player.vfhls.currentLevel.height,
59098
+ stream_bitrate: this.player.vfhls.currentLevel.bitrate,
59099
+ stream_video_codec: this.player.vfhls.currentLevel.videoCodec,
59100
+ stream_audio_codec: this.player.vfhls.currentLevel.audioCodec,
59101
+ stream_level: `${this.player.vfhls.currentLevel.level + 1}/${this.player.vfhls.currentLevel.totalLevels}`,
59102
+ stream_level_index: this.player.vfhls.currentLevel.level,
59103
+ stream_total_levels: this.player.vfhls.currentLevel.totalLevels,
59104
+ stream_resolutions: this.player.vfhls.currentLevel.availableResolutions,
59105
+ stream_is_live: !!this.player.vfhls.isLive,
59106
+ stream_segment_duration: this.player.vfhls.manifest ? this.player.vfhls.manifest._segmentDuration : void 0
59107
+ };
59108
+ } else if (this.player.vfhls.manifest && this.player.vfhls.manifest.playlists) {
59109
+ const width = this.player.videoWidth();
59110
+ const height = this.player.videoHeight();
59111
+ let playlists = this.player.vfhls.manifest.playlists;
59112
+ const subManifestIndex = playlists.findIndex((playlist) => {
59113
+ return playlist.attributes && playlist.attributes.RESOLUTION && this._aproxEq(playlist.attributes.RESOLUTION.width, width, 10) && this._aproxEq(playlist.attributes.RESOLUTION.height, height, 10);
59114
+ });
59115
+ if (subManifestIndex < 0)
59116
+ return {};
59117
+ const subManifest = playlists[subManifestIndex];
59118
+ if (!subManifest || !subManifest.attributes)
59119
+ return {};
59120
+ const codecs = subManifest.attributes.CODECS ? subManifest.attributes.CODECS.split(",") : [];
59121
+ return {
59122
+ stream_total_levels: playlists.length,
59123
+ stream_level: `${subManifestIndex + 1}/${playlists.length}`,
59124
+ stream_level_index: subManifestIndex,
59125
+ stream_is_live: this.player.vfhls.manifest._live,
59126
+ stream_segment_duration: this.player.vfhls.manifest._segmentDuration,
59127
+ stream_bitrate: subManifest.attributes.BANDWIDTH,
59128
+ stream_width: subManifest.attributes.RESOLUTION ? subManifest.attributes.RESOLUTION.width : void 0,
59129
+ stream_height: subManifest.attributes.RESOLUTION ? subManifest.attributes.RESOLUTION.height : void 0,
59130
+ stream_video_codec: codecs.length > 1 ? codecs[0].trim() : "unknown",
59131
+ stream_audio_codec: codecs.length > 2 ? codecs[1].trim() : "unknown"
59132
+ };
59133
+ } else {
59134
+ return {};
59135
+ }
59136
+ } catch (err) {
59137
+ return {};
59138
+ }
59139
+ },
59140
+ one: function(playerEvent, mxEvent) {
59141
+ this.player.one(playerEvent, () => {
59142
+ const props = this._getProps();
59143
+ props.event = playerEvent;
59144
+ PlayerTrackerService.track(mxEvent, props);
59145
+ });
59146
+ },
59147
+ on: function(playerEvent, alternateName) {
59148
+ this.player.on(playerEvent, () => {
59149
+ try {
59150
+ const props = this._getProps();
59151
+ props.event = alternateName || playerEvent;
59152
+ if (TrackedEvents[props.event])
59153
+ PlayerTrackerService.track("video", props);
59154
+ } catch (err) {
59155
+ }
59156
+ });
59157
+ },
59158
+ onAd: function(adEvent, alternateName) {
59159
+ try {
59160
+ this.player.ima.addEventListener(adEvent, (e) => {
59161
+ try {
59162
+ const props = this._getProps();
59163
+ props.event = alternateName || adEvent;
59164
+ if (TrackedEvents[props.event])
59165
+ PlayerTrackerService.track("video", props);
59166
+ } catch (err) {
59167
+ }
59168
+ });
59169
+ } catch (err) {
59170
+ }
59171
+ },
59172
+ debug: function(playerEvent) {
59173
+ this.player.on(playerEvent, () => {
59174
+ console.log(playerEvent);
59175
+ });
59176
+ },
59177
+ off: function(event2) {
59178
+ this.player.off(event2);
59179
+ },
59180
+ trackAds: function() {
59181
+ this.onAd("start", "ad started");
59182
+ this.onAd("impression", "ad impression");
59183
+ this.onAd("skip", "ad skipped");
59184
+ this.onAd("allAdsCompleted", "ad completed");
59185
+ },
59186
+ destroy: function(event2) {
59187
+ this.off("play");
59188
+ this.off("pause");
59189
+ this.off("ended");
59190
+ this.off("timeupdate");
59191
+ try {
59192
+ this.broadcastChannel.removeEventListener("message", this.chunkListener);
59193
+ } catch (err) {
59194
+ }
59195
+ },
59196
+ _increment: function(property, value) {
59197
+ const prop = {};
59198
+ prop[property] = parseFloat((mixpanel_cjs.get_property(property) + value).toFixed(2));
59199
+ mixpanel_cjs.register(prop);
59200
+ }
59201
+ };
59202
+ return tracker2;
59203
+ }]);
59204
+ function initMux(player, options) {
59205
+ var _a;
59206
+ const muxSettings = {
59207
+ debug: false,
59208
+ data: {
59209
+ env_key: options.muxKey,
59210
+ player_name: options.playerName || "Stream Engine Player",
59211
+ viewer_user_id: options.viewerId || "",
59212
+ player_version: "1.0.0",
59213
+ video_id: options.videoId,
59214
+ video_title: options.videoTitle,
59215
+ video_series: "",
59216
+ video_duration: (parseFloat(player.duration().toFixed(2)) || 0) * 1e3,
59217
+ video_stream_type: (_a = options.videoState) == null ? void 0 : _a.toUpperCase(),
59218
+ video_cdn: "CloudFront",
59219
+ custom_1: options.channelTitle,
59220
+ custom_2: window.location.host
59221
+ }
59222
+ };
59223
+ player.mux(muxSettings);
59224
+ }
59225
+ module$2.service("VJSAnalyticsPlugin", ["PlayerTracker", function(PlayerTracker) {
59226
+ const Plugin2 = videojs$1.getPlugin("plugin");
59227
+ const plugin = videojs$1.extend(Plugin2, {
59228
+ constructor: function(player, options) {
59229
+ Plugin2.call(this, player, options);
59230
+ if (options.muxKey && player.mux) {
59231
+ initMux(player, options);
59232
+ }
59233
+ this.tracker = new PlayerTracker(player, options);
59234
+ },
59235
+ trackAds: function() {
59236
+ this.tracker.trackAds();
54938
59237
  }
54939
59238
  });
54940
59239
  plugin.pluginName = "analytics";
@@ -61820,6 +66119,7 @@
61820
66119
  player.info = {};
61821
66120
  player.vfhls = {};
61822
66121
  player.transparent = !!scope.options.transparent;
66122
+ let analyticsPlugin = player.analytics(scope.options.analytics);
61823
66123
  let imaOptions = {
61824
66124
  adTagUrl: scope.options.adTagUrl,
61825
66125
  adsManagerLoadedCallback
@@ -62212,6 +66512,7 @@
62212
66512
  player.removeClass("vjs-ad-paused");
62213
66513
  }
62214
66514
  );
66515
+ analyticsPlugin.trackAds();
62215
66516
  let isLoop = false;
62216
66517
  player.on("adstart", () => {
62217
66518
  try {
@@ -62278,7 +66579,8 @@
62278
66579
  logger: "=",
62279
66580
  title: "@",
62280
66581
  dvr: "=",
62281
- captions: "="
66582
+ captions: "=",
66583
+ analytics: "="
62282
66584
  },
62283
66585
  controller: ["$scope", ($scope) => {
62284
66586
  $scope.api = new Player2();
@@ -62330,6 +66632,7 @@
62330
66632
  style: $scope.style || {},
62331
66633
  metadata: {},
62332
66634
  captions: $scope.captions,
66635
+ analytics: $scope.analytics,
62333
66636
  title: "",
62334
66637
  description: ""
62335
66638
  };