@reservamos/browser-analytics 1.0.7 → 1.0.10-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/browser-analytics.cjs +3 -3
  2. package/dist/browser-analytics.cjs.map +1 -1
  3. package/dist/browser-analytics.d.ts +137 -6
  4. package/dist/browser-analytics.esm.js +871 -2850
  5. package/dist/browser-analytics.esm.js.map +1 -1
  6. package/dist/browser-analytics.iife.js +3 -3
  7. package/dist/browser-analytics.iife.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/events/customEvent/trackCustomEvent.ts +1 -1
  10. package/src/events/identify/identify.ts +14 -14
  11. package/src/index.ts +17 -2
  12. package/src/init.ts +4 -22
  13. package/src/profiles/createAnonymousProfile/createAnonymousProfile.ts +10 -33
  14. package/src/recommendations/createRecommendedSeats/createRecommendedSeats.ts +40 -0
  15. package/src/recommendations/createRecommendedSeats/createRecommendedSeatsSchema.ts +25 -0
  16. package/src/recommendations/createRecommendedSeats/index.ts +5 -0
  17. package/src/recommendations/getRecommendedPlaces/getRecommendedPlaces.ts +63 -0
  18. package/src/recommendations/getRecommendedPlaces/index.ts +3 -0
  19. package/src/recommendations/getRecommendedSeats/getRecommendedSeats.ts +37 -0
  20. package/src/recommendations/getRecommendedSeats/getRecommendedSeatsSchema.ts +24 -0
  21. package/src/recommendations/getRecommendedSeats/index.ts +5 -0
  22. package/src/recommendations/getRecommendedTrips/getRecommendedTrips.ts +36 -0
  23. package/src/recommendations/getRecommendedTrips/getRecommendedTripsSchema.ts +10 -0
  24. package/src/recommendations/getRecommendedTrips/index.ts +5 -0
  25. package/src/services/config.ts +33 -10
  26. package/src/services/mixpanel.ts +2 -2
  27. package/src/track.ts +16 -31
  28. package/src/js-api-client.d.ts +0 -15
@@ -89,8 +89,8 @@ const ZodParsedType = util.arrayToEnum([
89
89
  "set"
90
90
  ]);
91
91
  const getParsedType = (data) => {
92
- const t = typeof data;
93
- switch (t) {
92
+ const t3 = typeof data;
93
+ switch (t3) {
94
94
  case "undefined":
95
95
  return ZodParsedType.undefined;
96
96
  case "string":
@@ -3922,25 +3922,25 @@ const customEventSchema = z.record(
3922
3922
  );
3923
3923
  const eventNameSchema = z.string().min(1, "Event name is required");
3924
3924
  var __assign = function() {
3925
- __assign = Object.assign || function __assign2(t) {
3926
- for (var s2, i = 1, n = arguments.length; i < n; i++) {
3925
+ __assign = Object.assign || function __assign2(t3) {
3926
+ for (var s2, i = 1, n2 = arguments.length; i < n2; i++) {
3927
3927
  s2 = arguments[i];
3928
- for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t[p2] = s2[p2];
3928
+ for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t3[p2] = s2[p2];
3929
3929
  }
3930
- return t;
3930
+ return t3;
3931
3931
  };
3932
3932
  return __assign.apply(this, arguments);
3933
3933
  };
3934
3934
  function __rest$1(s2, e) {
3935
- var t = {};
3935
+ var t3 = {};
3936
3936
  for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e.indexOf(p2) < 0)
3937
- t[p2] = s2[p2];
3937
+ t3[p2] = s2[p2];
3938
3938
  if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
3939
3939
  for (var i = 0, p2 = Object.getOwnPropertySymbols(s2); i < p2.length; i++) {
3940
3940
  if (e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i]))
3941
- t[p2[i]] = s2[p2[i]];
3941
+ t3[p2[i]] = s2[p2[i]];
3942
3942
  }
3943
- return t;
3943
+ return t3;
3944
3944
  }
3945
3945
  function __awaiter$1(thisArg, _arguments, P2, generator) {
3946
3946
  function adopt(value) {
@@ -3982,79 +3982,79 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
3982
3982
  var e = new Error(message);
3983
3983
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3984
3984
  };
3985
- function r(e, t) {
3986
- return function(e2, t2) {
3987
- return Object.prototype.hasOwnProperty.call(e2, t2);
3988
- }(e, t) ? e[t] : void 0;
3985
+ function r$3(e, t3) {
3986
+ return function(e2, t4) {
3987
+ return Object.prototype.hasOwnProperty.call(e2, t4);
3988
+ }(e, t3) ? e[t3] : void 0;
3989
3989
  }
3990
- function o(e, t, n, r2) {
3991
- var o2, i = document, a2 = "securitypolicyviolation", u2 = function(t2) {
3992
- var n2 = new URL(e, location.href), r3 = t2.blockedURI;
3993
- r3 !== n2.href && r3 !== n2.protocol.slice(0, -1) && r3 !== n2.origin || (o2 = t2, R2());
3990
+ function o$1(e, t3, n2, r2) {
3991
+ var o2, i = document, a2 = "securitypolicyviolation", u2 = function(t4) {
3992
+ var n3 = new URL(e, location.href), r3 = t4.blockedURI;
3993
+ r3 !== n3.href && r3 !== n3.protocol.slice(0, -1) && r3 !== n3.origin || (o2 = t4, R2());
3994
3994
  };
3995
3995
  i.addEventListener(a2, u2);
3996
3996
  var R2 = function() {
3997
3997
  return i.removeEventListener(a2, u2);
3998
3998
  };
3999
- return Promise.resolve().then(t).then(function(e2) {
3999
+ return Promise.resolve().then(t3).then(function(e2) {
4000
4000
  return R2(), e2;
4001
4001
  }, function(e2) {
4002
4002
  return new Promise(function(e3) {
4003
- var t2 = new MessageChannel();
4004
- t2.port1.onmessage = function() {
4003
+ var t4 = new MessageChannel();
4004
+ t4.port1.onmessage = function() {
4005
4005
  return e3();
4006
- }, t2.port2.postMessage(null);
4006
+ }, t4.port2.postMessage(null);
4007
4007
  }).then(function() {
4008
- if (R2(), o2) return n(o2);
4008
+ if (R2(), o2) return n2(o2);
4009
4009
  throw e2;
4010
4010
  });
4011
4011
  });
4012
4012
  }
4013
- var i$1 = { default: "endpoint" }, a = { default: "tlsEndpoint" }, u = "Client timeout", R = "Network connection error", c = "Network request aborted", s = "Response cannot be parsed", f = "Blocked by CSP", l = "The endpoint parameter is not a valid URL";
4014
- function E(e) {
4015
- for (var t = "", n = 0; n < e.length; ++n) if (n > 0) {
4016
- var r2 = e[n].toLowerCase();
4017
- r2 !== e[n] ? t += " ".concat(r2) : t += e[n];
4018
- } else t += e[n].toUpperCase();
4019
- return t;
4020
- }
4021
- var d = /* @__PURE__ */ E("WrongRegion"), p = /* @__PURE__ */ E("SubscriptionNotActive"), v = /* @__PURE__ */ E("UnsupportedVersion"), _$1 = /* @__PURE__ */ E("InstallationMethodRestricted"), O = /* @__PURE__ */ E("HostnameRestricted"), h = /* @__PURE__ */ E("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m = "Request cannot be parsed", w = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y = "Not available for this origin", D = "Not available with restricted header", S = I, g = N, L = T, U = "3.11.1", b = "Failed to load the JS script of the agent", C = "9319";
4022
- function M(t, n) {
4023
- var r2, o2, i, a2, u2, R2, c2 = [], s2 = (r2 = function(t2) {
4024
- var n2 = __spreadArray([], t2, true);
4013
+ var i$3 = { default: "endpoint" }, a$3 = { default: "tlsEndpoint" }, u$1 = "Client timeout", R = "Network connection error", c$3 = "Network request aborted", s$4 = "Response cannot be parsed", f$1 = "Blocked by CSP", l$2 = "The endpoint parameter is not a valid URL";
4014
+ function E$1(e) {
4015
+ for (var t3 = "", n2 = 0; n2 < e.length; ++n2) if (n2 > 0) {
4016
+ var r2 = e[n2].toLowerCase();
4017
+ r2 !== e[n2] ? t3 += " ".concat(r2) : t3 += e[n2];
4018
+ } else t3 += e[n2].toUpperCase();
4019
+ return t3;
4020
+ }
4021
+ var d$2 = /* @__PURE__ */ E$1("WrongRegion"), p$1 = /* @__PURE__ */ E$1("SubscriptionNotActive"), v = /* @__PURE__ */ E$1("UnsupportedVersion"), _$1 = /* @__PURE__ */ E$1("InstallationMethodRestricted"), O = /* @__PURE__ */ E$1("HostnameRestricted"), h = /* @__PURE__ */ E$1("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m$1 = "Request cannot be parsed", w$1 = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y$1 = "Not available for this origin", D = "Not available with restricted header", S = I, g = N, L = T, U = "3.11.1", b = "Failed to load the JS script of the agent", C$1 = "9319";
4022
+ function M(t3, n2) {
4023
+ var r2, o2, i, a2, u2, R2, c2 = [], s2 = (r2 = function(t4) {
4024
+ var n3 = __spreadArray([], t4, true);
4025
4025
  return { current: function() {
4026
- return n2[0];
4026
+ return n3[0];
4027
4027
  }, postpone: function() {
4028
- var e = n2.shift();
4029
- void 0 !== e && n2.push(e);
4028
+ var e = n3.shift();
4029
+ void 0 !== e && n3.push(e);
4030
4030
  }, exclude: function() {
4031
- n2.shift();
4031
+ n3.shift();
4032
4032
  } };
4033
- }(t), a2 = 100, u2 = 3e3, R2 = 0, o2 = function() {
4033
+ }(t3), a2 = 100, u2 = 3e3, R2 = 0, o2 = function() {
4034
4034
  return Math.random() * Math.min(u2, a2 * Math.pow(2, R2++));
4035
- }, i = /* @__PURE__ */ new Set(), [r2.current(), function(e, t2) {
4036
- var n2, a3 = t2 instanceof Error ? t2.message : "";
4037
- if (a3 === f || a3 === l) r2.exclude(), n2 = 0;
4038
- else if (a3 === C) r2.exclude();
4035
+ }, i = /* @__PURE__ */ new Set(), [r2.current(), function(e, t4) {
4036
+ var n3, a3 = t4 instanceof Error ? t4.message : "";
4037
+ if (a3 === f$1 || a3 === l$2) r2.exclude(), n3 = 0;
4038
+ else if (a3 === C$1) r2.exclude();
4039
4039
  else if (a3 === b) {
4040
4040
  var u3 = Date.now() - e.getTime() < 50, R3 = r2.current();
4041
- R3 && u3 && !i.has(R3) && (i.add(R3), n2 = 0), r2.postpone();
4041
+ R3 && u3 && !i.has(R3) && (i.add(R3), n3 = 0), r2.postpone();
4042
4042
  } else r2.postpone();
4043
4043
  var c3 = r2.current();
4044
- return void 0 === c3 ? void 0 : [c3, null != n2 ? n2 : e.getTime() + o2() - Date.now()];
4044
+ return void 0 === c3 ? void 0 : [c3, null != n3 ? n3 : e.getTime() + o2() - Date.now()];
4045
4045
  }]), E2 = s2[0], d2 = s2[1];
4046
4046
  if (void 0 === E2) return Promise.reject(new TypeError("The list of script URL patterns is empty"));
4047
4047
  var p2 = function(e) {
4048
- var t2 = /* @__PURE__ */ new Date(), r3 = function(n2) {
4049
- return c2.push({ url: e, startedAt: t2, finishedAt: /* @__PURE__ */ new Date(), error: n2 });
4050
- }, o3 = n(e);
4048
+ var t4 = /* @__PURE__ */ new Date(), r3 = function(n3) {
4049
+ return c2.push({ url: e, startedAt: t4, finishedAt: /* @__PURE__ */ new Date(), error: n3 });
4050
+ }, o3 = n2(e);
4051
4051
  return o3.then(function() {
4052
4052
  return r3();
4053
4053
  }, r3), o3.catch(function(e2) {
4054
4054
  if (c2.length >= 5) throw e2;
4055
- var n2 = d2(t2, e2);
4056
- if (!n2) throw e2;
4057
- var r4, o4 = n2[0], i2 = n2[1];
4055
+ var n3 = d2(t4, e2);
4056
+ if (!n3) throw e2;
4057
+ var r4, o4 = n3[0], i2 = n3[1];
4058
4058
  return (r4 = i2, new Promise(function(e3) {
4059
4059
  return setTimeout(e3, r4);
4060
4060
  })).then(function() {
@@ -4070,106 +4070,106 @@ var K = "https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js", B
4070
4070
  function F(e) {
4071
4071
  var o2;
4072
4072
  e.scriptUrlPattern;
4073
- var i = e.token, a2 = e.apiKey, u2 = void 0 === a2 ? i : a2, R2 = __rest$1(e, ["scriptUrlPattern", "token", "apiKey"]), c2 = null !== (o2 = r(e, "scriptUrlPattern")) && void 0 !== o2 ? o2 : K, s2 = function() {
4074
- var e2 = [], t = function() {
4073
+ var i = e.token, a2 = e.apiKey, u2 = void 0 === a2 ? i : a2, R2 = __rest$1(e, ["scriptUrlPattern", "token", "apiKey"]), c2 = null !== (o2 = r$3(e, "scriptUrlPattern")) && void 0 !== o2 ? o2 : K, s2 = function() {
4074
+ var e2 = [], t3 = function() {
4075
4075
  e2.push({ time: /* @__PURE__ */ new Date(), state: document.visibilityState });
4076
- }, n = function(e3, t2, n2, r2) {
4077
- return e3.addEventListener(t2, n2, r2), function() {
4078
- return e3.removeEventListener(t2, n2, r2);
4076
+ }, n2 = function(e3, t4, n3, r2) {
4077
+ return e3.addEventListener(t4, n3, r2), function() {
4078
+ return e3.removeEventListener(t4, n3, r2);
4079
4079
  };
4080
- }(document, "visibilitychange", t);
4081
- return t(), [e2, n];
4080
+ }(document, "visibilitychange", t3);
4081
+ return t3(), [e2, n2];
4082
4082
  }(), f2 = s2[0], l2 = s2[1];
4083
4083
  return Promise.resolve().then(function() {
4084
4084
  if (!u2 || "string" != typeof u2) throw new Error(I);
4085
- var e2 = function(e3, t) {
4085
+ var e2 = function(e3, t3) {
4086
4086
  return (Array.isArray(e3) ? e3 : [e3]).map(function(e4) {
4087
- return function(e5, t2) {
4088
- var n = encodeURIComponent;
4087
+ return function(e5, t4) {
4088
+ var n2 = encodeURIComponent;
4089
4089
  return e5.replace(/<[^<>]+>/g, function(e6) {
4090
- return "<version>" === e6 ? "3" : "<apiKey>" === e6 ? n(t2) : "<loaderVersion>" === e6 ? n(U) : e6;
4090
+ return "<version>" === e6 ? "3" : "<apiKey>" === e6 ? n2(t4) : "<loaderVersion>" === e6 ? n2(U) : e6;
4091
4091
  });
4092
- }(String(e4), t);
4092
+ }(String(e4), t3);
4093
4093
  });
4094
4094
  }(c2, u2);
4095
4095
  return M(e2, V);
4096
4096
  }).catch(function(e2) {
4097
4097
  throw l2(), function(e3) {
4098
- if (e3 instanceof Error && e3.message === C) return new Error(b);
4098
+ if (e3 instanceof Error && e3.message === C$1) return new Error(b);
4099
4099
  return e3;
4100
4100
  }(e2);
4101
4101
  }).then(function(e2) {
4102
- var t = e2[0], r2 = e2[1];
4103
- return l2(), t.load(__assign(__assign({}, R2), { ldi: { attempts: r2, visibilityStates: f2 } }));
4102
+ var t3 = e2[0], r2 = e2[1];
4103
+ return l2(), t3.load(__assign(__assign({}, R2), { ldi: { attempts: r2, visibilityStates: f2 } }));
4104
4104
  });
4105
4105
  }
4106
4106
  function V(e) {
4107
- return o(e, function() {
4107
+ return o$1(e, function() {
4108
4108
  return function(e2) {
4109
- return new Promise(function(t, n) {
4109
+ return new Promise(function(t3, n2) {
4110
4110
  if (function(e3) {
4111
4111
  if (URL.prototype) try {
4112
4112
  return new URL(e3, location.href), false;
4113
- } catch (t2) {
4114
- if (t2 instanceof Error && "TypeError" === t2.name) return true;
4115
- throw t2;
4113
+ } catch (t4) {
4114
+ if (t4 instanceof Error && "TypeError" === t4.name) return true;
4115
+ throw t4;
4116
4116
  }
4117
- }(e2)) throw new Error(l);
4117
+ }(e2)) throw new Error(l$2);
4118
4118
  var r2 = document.createElement("script"), o2 = function() {
4119
4119
  var e3;
4120
4120
  return null === (e3 = r2.parentNode) || void 0 === e3 ? void 0 : e3.removeChild(r2);
4121
4121
  }, i = document.head || document.getElementsByTagName("head")[0];
4122
4122
  r2.onload = function() {
4123
- o2(), t();
4123
+ o2(), t3();
4124
4124
  }, r2.onerror = function() {
4125
- o2(), n(new Error(b));
4125
+ o2(), n2(new Error(b));
4126
4126
  }, r2.async = true, r2.src = e2, i.appendChild(r2);
4127
4127
  });
4128
4128
  }(e);
4129
4129
  }, function() {
4130
- throw new Error(f);
4130
+ throw new Error(f$1);
4131
4131
  }).then(k);
4132
4132
  }
4133
4133
  function k() {
4134
- var e = window, t = "__fpjs_p_l_b", n = e[t];
4135
- if (function(e2, t2) {
4136
- var n2, r2 = null === (n2 = Object.getOwnPropertyDescriptor) || void 0 === n2 ? void 0 : n2.call(Object, e2, t2);
4137
- (null == r2 ? void 0 : r2.configurable) ? delete e2[t2] : r2 && !r2.writable || (e2[t2] = void 0);
4138
- }(e, t), "function" != typeof (null == n ? void 0 : n.load)) throw new Error(C);
4139
- return n;
4140
- }
4141
- var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m, ERROR_BAD_RESPONSE_FORMAT: s, ERROR_CLIENT_TIMEOUT: u, ERROR_CSP_BLOCK: f, ERROR_FORBIDDEN_ENDPOINT: O, ERROR_FORBIDDEN_HEADER: D, ERROR_FORBIDDEN_ORIGIN: y, ERROR_GENERAL_SERVER_FAILURE: w, ERROR_INSTALLATION_METHOD_RESTRICTED: _$1, ERROR_INTEGRATION_FAILURE: h, ERROR_INVALID_ENDPOINT: l, ERROR_NETWORK_ABORT: c, ERROR_NETWORK_CONNECTION: R, ERROR_RATE_LIMIT: P, ERROR_SERVER_TIMEOUT: A, ERROR_SUBSCRIPTION_NOT_ACTIVE: p, ERROR_TOKEN_EXPIRED: L, ERROR_TOKEN_INVALID: g, ERROR_TOKEN_MISSING: S, ERROR_UNSUPPORTED_VERSION: v, ERROR_WRONG_REGION: d, defaultEndpoint: i$1, defaultTlsEndpoint: a };
4134
+ var e = window, t3 = "__fpjs_p_l_b", n2 = e[t3];
4135
+ if (function(e2, t4) {
4136
+ var n3, r2 = null === (n3 = Object.getOwnPropertyDescriptor) || void 0 === n3 ? void 0 : n3.call(Object, e2, t4);
4137
+ (null == r2 ? void 0 : r2.configurable) ? delete e2[t4] : r2 && !r2.writable || (e2[t4] = void 0);
4138
+ }(e, t3), "function" != typeof (null == n2 ? void 0 : n2.load)) throw new Error(C$1);
4139
+ return n2;
4140
+ }
4141
+ var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m$1, ERROR_BAD_RESPONSE_FORMAT: s$4, ERROR_CLIENT_TIMEOUT: u$1, ERROR_CSP_BLOCK: f$1, ERROR_FORBIDDEN_ENDPOINT: O, ERROR_FORBIDDEN_HEADER: D, ERROR_FORBIDDEN_ORIGIN: y$1, ERROR_GENERAL_SERVER_FAILURE: w$1, ERROR_INSTALLATION_METHOD_RESTRICTED: _$1, ERROR_INTEGRATION_FAILURE: h, ERROR_INVALID_ENDPOINT: l$2, ERROR_NETWORK_ABORT: c$3, ERROR_NETWORK_CONNECTION: R, ERROR_RATE_LIMIT: P, ERROR_SERVER_TIMEOUT: A, ERROR_SUBSCRIPTION_NOT_ACTIVE: p$1, ERROR_TOKEN_EXPIRED: L, ERROR_TOKEN_INVALID: g, ERROR_TOKEN_MISSING: S, ERROR_UNSUPPORTED_VERSION: v, ERROR_WRONG_REGION: d$2, defaultEndpoint: i$3, defaultTlsEndpoint: a$3 };
4142
4142
  const FingerprintJSPro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4143
4143
  __proto__: null,
4144
4144
  ERROR_API_KEY_EXPIRED: T,
4145
4145
  ERROR_API_KEY_INVALID: N,
4146
4146
  ERROR_API_KEY_MISSING: I,
4147
- ERROR_BAD_REQUEST_FORMAT: m,
4148
- ERROR_BAD_RESPONSE_FORMAT: s,
4149
- ERROR_CLIENT_TIMEOUT: u,
4150
- ERROR_CSP_BLOCK: f,
4147
+ ERROR_BAD_REQUEST_FORMAT: m$1,
4148
+ ERROR_BAD_RESPONSE_FORMAT: s$4,
4149
+ ERROR_CLIENT_TIMEOUT: u$1,
4150
+ ERROR_CSP_BLOCK: f$1,
4151
4151
  ERROR_FORBIDDEN_ENDPOINT: O,
4152
4152
  ERROR_FORBIDDEN_HEADER: D,
4153
- ERROR_FORBIDDEN_ORIGIN: y,
4154
- ERROR_GENERAL_SERVER_FAILURE: w,
4153
+ ERROR_FORBIDDEN_ORIGIN: y$1,
4154
+ ERROR_GENERAL_SERVER_FAILURE: w$1,
4155
4155
  ERROR_INSTALLATION_METHOD_RESTRICTED: _$1,
4156
4156
  ERROR_INTEGRATION_FAILURE: h,
4157
- ERROR_INVALID_ENDPOINT: l,
4158
- ERROR_NETWORK_ABORT: c,
4157
+ ERROR_INVALID_ENDPOINT: l$2,
4158
+ ERROR_NETWORK_ABORT: c$3,
4159
4159
  ERROR_NETWORK_CONNECTION: R,
4160
4160
  ERROR_RATE_LIMIT: P,
4161
4161
  ERROR_SCRIPT_LOAD_FAIL: b,
4162
4162
  ERROR_SERVER_TIMEOUT: A,
4163
- ERROR_SUBSCRIPTION_NOT_ACTIVE: p,
4163
+ ERROR_SUBSCRIPTION_NOT_ACTIVE: p$1,
4164
4164
  ERROR_TOKEN_EXPIRED: L,
4165
4165
  ERROR_TOKEN_INVALID: g,
4166
4166
  ERROR_TOKEN_MISSING: S,
4167
4167
  ERROR_UNSUPPORTED_VERSION: v,
4168
- ERROR_WRONG_REGION: d,
4168
+ ERROR_WRONG_REGION: d$2,
4169
4169
  default: G,
4170
- defaultEndpoint: i$1,
4170
+ defaultEndpoint: i$3,
4171
4171
  defaultScriptUrlPattern: B,
4172
- defaultTlsEndpoint: a,
4172
+ defaultTlsEndpoint: a$3,
4173
4173
  load: F
4174
4174
  }, Symbol.toStringTag, { value: "Module" }));
4175
4175
  const CACHE_KEY_PREFIX = "@fpjs@client@";
@@ -4366,7 +4366,7 @@ var CacheLocation;
4366
4366
  CacheLocation2["SessionStorage"] = "sessionstorage";
4367
4367
  CacheLocation2["NoCache"] = "nocache";
4368
4368
  })(CacheLocation || (CacheLocation = {}));
4369
- var version = "1.3.2";
4369
+ var version$1 = "1.3.2";
4370
4370
  const cacheLocationBuilders = {
4371
4371
  [CacheLocation.Memory]: () => new InMemoryCache().enclosedCache,
4372
4372
  [CacheLocation.LocalStorage]: (prefix) => new LocalStorageCache(prefix),
@@ -4445,7 +4445,7 @@ class FpjsClient {
4445
4445
  const loadOptions = Object.assign(Object.assign(Object.assign({}, this.loadOptions), passedLoadOptions), { integrationInfo: [
4446
4446
  ...((_a = this.loadOptions) === null || _a === void 0 ? void 0 : _a.integrationInfo) || [],
4447
4447
  ...(passedLoadOptions === null || passedLoadOptions === void 0 ? void 0 : passedLoadOptions.integrationInfo) || [],
4448
- `fingerprintjs-pro-spa/${version}`
4448
+ `fingerprintjs-pro-spa/${version$1}`
4449
4449
  ] });
4450
4450
  if (!this.agentPromise) {
4451
4451
  const agentLoader = (_b = this.customAgent) !== null && _b !== void 0 ? _b : FingerprintJSPro;
@@ -4565,7 +4565,7 @@ function buildProxyUrl(url) {
4565
4565
  return `${url}?${PROXY_QUERY_PARAM}`;
4566
4566
  }
4567
4567
  async function initFingerprint(apiKey, proxyUrl) {
4568
- const customEndpointArray = [i$1];
4568
+ const customEndpointArray = [i$3];
4569
4569
  const customScriptEndpointArray = [B];
4570
4570
  if (proxyUrl) {
4571
4571
  customEndpointArray.unshift(proxyUrl);
@@ -4619,2493 +4619,395 @@ const fingerprintService = {
4619
4619
  isFingerprintReady,
4620
4620
  getCachedFingerprint
4621
4621
  };
4622
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4623
- var jsApiClient = { exports: {} };
4624
- (function(module, exports) {
4625
- (function webpackUniversalModuleDefinition(root, factory) {
4626
- module.exports = factory();
4627
- })(typeof self !== "undefined" ? self : commonjsGlobal, function() {
4628
- return (
4629
- /******/
4630
- function(modules) {
4631
- var installedModules = {};
4632
- function __webpack_require__(moduleId) {
4633
- if (installedModules[moduleId]) {
4634
- return installedModules[moduleId].exports;
4635
- }
4636
- var module2 = installedModules[moduleId] = {
4637
- /******/
4638
- i: moduleId,
4639
- /******/
4640
- l: false,
4641
- /******/
4642
- exports: {}
4643
- /******/
4644
- };
4645
- modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
4646
- module2.l = true;
4647
- return module2.exports;
4648
- }
4649
- __webpack_require__.m = modules;
4650
- __webpack_require__.c = installedModules;
4651
- __webpack_require__.d = function(exports2, name, getter) {
4652
- if (!__webpack_require__.o(exports2, name)) {
4653
- Object.defineProperty(exports2, name, {
4654
- /******/
4655
- configurable: false,
4656
- /******/
4657
- enumerable: true,
4658
- /******/
4659
- get: getter
4660
- /******/
4661
- });
4662
- }
4663
- };
4664
- __webpack_require__.n = function(module2) {
4665
- var getter = module2 && module2.__esModule ? (
4666
- /******/
4667
- function getDefault() {
4668
- return module2["default"];
4669
- }
4670
- ) : (
4671
- /******/
4672
- function getModuleExports() {
4673
- return module2;
4674
- }
4675
- );
4676
- __webpack_require__.d(getter, "a", getter);
4677
- return getter;
4678
- };
4679
- __webpack_require__.o = function(object, property) {
4680
- return Object.prototype.hasOwnProperty.call(object, property);
4681
- };
4682
- __webpack_require__.p = "";
4683
- return __webpack_require__(__webpack_require__.s = 3);
4684
- }([
4685
- /* 0 */
4686
- /***/
4687
- function(module2, exports2, __webpack_require__) {
4688
- Object.defineProperty(exports2, "__esModule", {
4689
- value: true
4690
- });
4691
- var _extends = Object.assign || function(target) {
4692
- for (var i = 1; i < arguments.length; i++) {
4693
- var source = arguments[i];
4694
- for (var key in source) {
4695
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4696
- target[key] = source[key];
4697
- }
4698
- }
4699
- }
4700
- return target;
4701
- };
4702
- exports2.post = post;
4703
- exports2.get = get;
4704
- exports2.put = put;
4705
- exports2.deleteMethod = deleteMethod;
4706
- exports2.poll = poll;
4707
- var _config = __webpack_require__(1);
4708
- var _config2 = _interopRequireDefault(_config);
4709
- var _request = __webpack_require__(2);
4710
- var request = _interopRequireWildcard(_request);
4711
- var _Poll = __webpack_require__(9);
4712
- var _Poll2 = _interopRequireDefault(_Poll);
4713
- function _interopRequireWildcard(obj) {
4714
- if (obj && obj.__esModule) {
4715
- return obj;
4716
- } else {
4717
- var newObj = {};
4718
- if (obj != null) {
4719
- for (var key in obj) {
4720
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
4721
- }
4722
- }
4723
- newObj.default = obj;
4724
- return newObj;
4725
- }
4726
- }
4727
- function _interopRequireDefault(obj) {
4728
- return obj && obj.__esModule ? obj : { default: obj };
4729
- }
4730
- function _toConsumableArray(arr) {
4731
- if (Array.isArray(arr)) {
4732
- for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
4733
- arr2[i] = arr[i];
4734
- }
4735
- return arr2;
4736
- } else {
4737
- return Array.from(arr);
4738
- }
4739
- }
4740
- var headerOptions = { apiKey: _config2.default.apiKey };
4741
- function serializeQueryParams(options) {
4742
- var ignore = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
4743
- if (!options) {
4744
- return "";
4745
- }
4746
- var ignoreList = [null, void 0, ""].concat(_toConsumableArray(ignore));
4747
- var optionList = [];
4748
- Object.keys(options).forEach(function(key) {
4749
- var value = options[key];
4750
- if (!ignoreList.includes(value)) {
4751
- optionList.push(key + "=" + value);
4752
- }
4753
- });
4754
- return optionList.length ? "?" + optionList.join("&") : "";
4755
- }
4756
- function buildUrl(_ref) {
4757
- var endpoint = _ref.endpoint, _ref$apiVersion = _ref.apiVersion, apiVersion = _ref$apiVersion === void 0 ? _config2.default.version : _ref$apiVersion, queryParams = _ref.queryParams, apiType = _ref.apiType;
4758
- if (apiType === "core") {
4759
- return _config2.default.coreUrl + "/" + _config2.default.coreVersion + "/" + endpoint + serializeQueryParams(queryParams);
4760
- }
4761
- var apiUrl = /search|redirect|places/.test(endpoint) ? _config2.default.searchUrl : _config2.default.purchaseUrl;
4762
- return apiUrl + "/" + apiVersion + "/" + endpoint + serializeQueryParams(queryParams);
4763
- }
4764
- function post(endpoint, payload) {
4765
- var _ref2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref2.apiVersion, apiType = _ref2.apiType;
4766
- var url = buildUrl({ endpoint, apiVersion, apiType });
4767
- return request.post(url, payload, headerOptions);
4768
- }
4769
- function get(endpoint) {
4770
- var _ref3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref3.apiVersion, queryParams = _ref3.queryParams, apiType = _ref3.apiType;
4771
- var url = buildUrl({ endpoint, apiVersion, queryParams, apiType });
4772
- return request.get(url, headerOptions);
4773
- }
4774
- function put(endpoint, payload) {
4775
- var _ref4 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, apiVersion = _ref4.apiVersion, apiType = _ref4.apiType;
4776
- var url = buildUrl({ endpoint, apiVersion, apiType });
4777
- return request.put(url, payload, headerOptions);
4778
- }
4779
- function deleteMethod(endpoint) {
4780
- var _ref5 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, apiVersion = _ref5.apiVersion;
4781
- _ref5.queryParams;
4782
- var apiType = _ref5.apiType;
4783
- var url = buildUrl({ endpoint, apiVersion, apiType });
4784
- return request.deleteMethod(url, headerOptions);
4785
- }
4786
- function poll(endpoint, eachCall) {
4787
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4788
- var apiVersion = arguments[3];
4789
- var apiType = arguments[4];
4790
- var url = buildUrl({ endpoint, apiVersion, apiType });
4791
- var pollOptions = _extends({ url, eachCall }, options);
4792
- return new _Poll2.default(pollOptions);
4793
- }
4794
- },
4795
- /* 1 */
4796
- /***/
4797
- function(module2, exports2, __webpack_require__) {
4798
- Object.defineProperty(exports2, "__esModule", {
4799
- value: true
4800
- });
4801
- exports2.setConfig = setConfig;
4802
- exports2.setUserAuthToken = setUserAuthToken;
4803
- var configRoots = {
4804
- sandbox: {
4805
- search: "https://search.resertravel.com/api",
4806
- purchase: "https://purchases.resertravel.com/api",
4807
- core: ""
4808
- },
4809
- production: {
4810
- search: "https://search.reservamos.mx/api",
4811
- purchase: "https://compras.reservamos.mx/api",
4812
- core: ""
4813
- }
4814
- };
4815
- var defaultEnv = "sandbox";
4816
- var defaultVersion = "v2";
4817
- var defaultCoreVersion = "v1";
4818
- var defaultConfig = {
4819
- env: defaultEnv,
4820
- headers: {},
4821
- searchUrl: configRoots[defaultEnv].search,
4822
- purchaseUrl: configRoots[defaultEnv].purchase,
4823
- coreUrl: configRoots[defaultEnv].core,
4824
- version: defaultVersion,
4825
- coreVersion: defaultCoreVersion,
4826
- apiKey: void 0,
4827
- userAuthToken: void 0,
4828
- withCredentials: false
4829
- };
4830
- var config = exports2.config = Object.assign({}, defaultConfig);
4831
- function setConfig() {
4832
- var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
4833
- if (userConfig.env !== void 0) {
4834
- userConfig.searchUrl = configRoots[userConfig.env].search;
4835
- userConfig.purchaseUrl = configRoots[userConfig.env].purchase;
4836
- userConfig.coreUrl = configRoots[userConfig.env].core;
4837
- userConfig.coreVersion = configRoots[userConfig.env].coreVersion;
4838
- }
4839
- return Object.assign(config, userConfig);
4840
- }
4841
- function setUserAuthToken(userAuthToken) {
4842
- return Object.assign(config, { userAuthToken });
4843
- }
4844
- exports2.default = config;
4845
- },
4846
- /* 2 */
4847
- /***/
4848
- function(module2, exports2, __webpack_require__) {
4849
- Object.defineProperty(exports2, "__esModule", {
4850
- value: true
4851
- });
4852
- var _extends = Object.assign || function(target) {
4853
- for (var i = 1; i < arguments.length; i++) {
4854
- var source = arguments[i];
4855
- for (var key in source) {
4856
- if (Object.prototype.hasOwnProperty.call(source, key)) {
4857
- target[key] = source[key];
4858
- }
4859
- }
4860
- }
4861
- return target;
4862
- };
4863
- exports2.post = post;
4864
- exports2.get = get;
4865
- exports2.put = put;
4866
- exports2.deleteMethod = deleteMethod;
4867
- var _config = __webpack_require__(1);
4868
- var _config2 = _interopRequireDefault(_config);
4869
- var _NetworkError = __webpack_require__(7);
4870
- var _NetworkError2 = _interopRequireDefault(_NetworkError);
4871
- var _errorTypes = __webpack_require__(8);
4872
- var _errorTypes2 = _interopRequireDefault(_errorTypes);
4873
- function _interopRequireDefault(obj) {
4874
- return obj && obj.__esModule ? obj : { default: obj };
4875
- }
4876
- function _defineProperty(obj, key, value) {
4877
- if (key in obj) {
4878
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
4879
- } else {
4880
- obj[key] = value;
4881
- }
4882
- return obj;
4883
- }
4884
- function checkStatus(response) {
4885
- var handledErrors = [404, 422, 500];
4886
- var body = response.json();
4887
- if (response.ok) {
4888
- return body;
4889
- } else if (handledErrors.includes(response.status)) {
4890
- switch (response.status) {
4891
- case 404:
4892
- throw new _NetworkError2.default(100, "Not found");
4893
- case 422:
4894
- return body;
4895
- case 500:
4896
- throw new _NetworkError2.default(101, "Server error");
4897
- default:
4898
- throw new _NetworkError2.default();
4899
- }
4900
- } else {
4901
- throw new _NetworkError2.default(response.status, response.statusText);
4902
- }
4903
- }
4904
- function handleErrors(response) {
4905
- if (response.errors instanceof Array) {
4906
- var _ref = response.errors[0] || {}, _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
4907
- var knownError = (0, _errorTypes2.default)(message)[code];
4908
- if (knownError) {
4909
- throw new _NetworkError2.default(knownError.code, knownError.message);
4910
- } else {
4911
- throw new _NetworkError2.default(code, message);
4912
- }
4913
- } else {
4914
- return response;
4915
- }
4916
- }
4917
- function buildHeaders() {
4918
- for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
4919
- sources[_key] = arguments[_key];
4920
- }
4921
- var keys = Object.keys(Object.assign.apply(Object, [{}].concat(sources)));
4922
- var headers = keys.reduce(function(result, key) {
4923
- return _extends({}, result, _defineProperty({}, key, sources.map(function(source) {
4924
- return key in source && source[key];
4925
- }).filter(Boolean)));
4926
- }, {});
4927
- return new Headers(headers);
4928
- }
4929
- function fetchJson(url) {
4930
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4931
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4932
- var onRequestError = arguments[3];
4933
- var apiKey = _config2.default.apiKey, withCredentials = _config2.default.withCredentials, userAuthToken = _config2.default.userAuthToken, defaultHeaders = _config2.default.headers;
4934
- var headers = {
4935
- "Accept": "application/json",
4936
- "Authorization": "Token token=" + (headerOptions.apiKey || apiKey),
4937
- "Content-Type": "application/json"
4938
- };
4939
- if (userAuthToken) {
4940
- headers.Authorization = "Token " + (headerOptions.apiKey || apiKey) + ", Bearer " + userAuthToken;
4941
- }
4942
- options.headers = buildHeaders(defaultHeaders, headers);
4943
- options.credentials = withCredentials ? "include" : "omit";
4944
- if (typeof options.body !== "string") {
4945
- options.body = JSON.stringify(options.body);
4946
- }
4947
- return fetch(url, options).then(checkStatus).then(handleErrors).catch(onRequestError);
4948
- }
4949
- function post(url, payload) {
4950
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4951
- return fetchJson(url, {
4952
- method: "POST",
4953
- body: JSON.stringify(payload)
4954
- }, headerOptions);
4955
- }
4956
- function get(url) {
4957
- var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4958
- var onRequestError = arguments[2];
4959
- return fetchJson(url, headerOptions, {}, onRequestError);
4960
- }
4961
- function put(url, payload) {
4962
- var headerOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
4963
- return fetchJson(url, {
4964
- method: "PUT",
4965
- body: JSON.stringify(payload)
4966
- }, headerOptions);
4967
- }
4968
- function deleteMethod(url) {
4969
- var headerOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
4970
- return fetchJson(url, {
4971
- method: "DELETE"
4972
- }, headerOptions);
4973
- }
4974
- },
4975
- /* 3 */
4976
- /***/
4977
- function(module2, exports2, __webpack_require__) {
4978
- __webpack_require__(4);
4979
- __webpack_require__(5);
4980
- module2.exports = __webpack_require__(6);
4981
- },
4982
- /* 4 */
4983
- /***/
4984
- function(module2, exports2) {
4985
- if (typeof Object.assign !== "function") {
4986
- Object.assign = function(target, varArgs) {
4987
- if (target == null) {
4988
- throw new TypeError("Cannot convert undefined or null to object");
4989
- }
4990
- var to = Object(target);
4991
- for (var index = 1; index < arguments.length; index++) {
4992
- var nextSource = arguments[index];
4993
- if (nextSource != null) {
4994
- for (var nextKey in nextSource) {
4995
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
4996
- to[nextKey] = nextSource[nextKey];
4997
- }
4998
- }
4999
- }
5000
- }
5001
- return to;
5002
- };
5003
- }
5004
- },
5005
- /* 5 */
5006
- /***/
5007
- function(module2, exports2) {
5008
- (function(self2) {
5009
- if (self2.fetch) {
5010
- return;
5011
- }
5012
- var support = {
5013
- searchParams: "URLSearchParams" in self2,
5014
- iterable: "Symbol" in self2 && "iterator" in Symbol,
5015
- blob: "FileReader" in self2 && "Blob" in self2 && function() {
5016
- try {
5017
- new Blob();
5018
- return true;
5019
- } catch (e) {
5020
- return false;
5021
- }
5022
- }(),
5023
- formData: "FormData" in self2,
5024
- arrayBuffer: "ArrayBuffer" in self2
5025
- };
5026
- if (support.arrayBuffer) {
5027
- var viewClasses = [
5028
- "[object Int8Array]",
5029
- "[object Uint8Array]",
5030
- "[object Uint8ClampedArray]",
5031
- "[object Int16Array]",
5032
- "[object Uint16Array]",
5033
- "[object Int32Array]",
5034
- "[object Uint32Array]",
5035
- "[object Float32Array]",
5036
- "[object Float64Array]"
5037
- ];
5038
- var isDataView = function(obj) {
5039
- return obj && DataView.prototype.isPrototypeOf(obj);
5040
- };
5041
- var isArrayBufferView = ArrayBuffer.isView || function(obj) {
5042
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
5043
- };
5044
- }
5045
- function normalizeName(name) {
5046
- if (typeof name !== "string") {
5047
- name = String(name);
5048
- }
5049
- if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
5050
- throw new TypeError("Invalid character in header field name");
5051
- }
5052
- return name.toLowerCase();
5053
- }
5054
- function normalizeValue(value) {
5055
- if (typeof value !== "string") {
5056
- value = String(value);
5057
- }
5058
- return value;
5059
- }
5060
- function iteratorFor(items) {
5061
- var iterator = {
5062
- next: function() {
5063
- var value = items.shift();
5064
- return { done: value === void 0, value };
5065
- }
5066
- };
5067
- if (support.iterable) {
5068
- iterator[Symbol.iterator] = function() {
5069
- return iterator;
5070
- };
5071
- }
5072
- return iterator;
5073
- }
5074
- function Headers2(headers) {
5075
- this.map = {};
5076
- if (headers instanceof Headers2) {
5077
- headers.forEach(function(value, name) {
5078
- this.append(name, value);
5079
- }, this);
5080
- } else if (Array.isArray(headers)) {
5081
- headers.forEach(function(header) {
5082
- this.append(header[0], header[1]);
5083
- }, this);
5084
- } else if (headers) {
5085
- Object.getOwnPropertyNames(headers).forEach(function(name) {
5086
- this.append(name, headers[name]);
5087
- }, this);
5088
- }
5089
- }
5090
- Headers2.prototype.append = function(name, value) {
5091
- name = normalizeName(name);
5092
- value = normalizeValue(value);
5093
- var oldValue = this.map[name];
5094
- this.map[name] = oldValue ? oldValue + "," + value : value;
5095
- };
5096
- Headers2.prototype["delete"] = function(name) {
5097
- delete this.map[normalizeName(name)];
5098
- };
5099
- Headers2.prototype.get = function(name) {
5100
- name = normalizeName(name);
5101
- return this.has(name) ? this.map[name] : null;
5102
- };
5103
- Headers2.prototype.has = function(name) {
5104
- return this.map.hasOwnProperty(normalizeName(name));
5105
- };
5106
- Headers2.prototype.set = function(name, value) {
5107
- this.map[normalizeName(name)] = normalizeValue(value);
5108
- };
5109
- Headers2.prototype.forEach = function(callback, thisArg) {
5110
- for (var name in this.map) {
5111
- if (this.map.hasOwnProperty(name)) {
5112
- callback.call(thisArg, this.map[name], name, this);
5113
- }
5114
- }
5115
- };
5116
- Headers2.prototype.keys = function() {
5117
- var items = [];
5118
- this.forEach(function(value, name) {
5119
- items.push(name);
5120
- });
5121
- return iteratorFor(items);
5122
- };
5123
- Headers2.prototype.values = function() {
5124
- var items = [];
5125
- this.forEach(function(value) {
5126
- items.push(value);
5127
- });
5128
- return iteratorFor(items);
5129
- };
5130
- Headers2.prototype.entries = function() {
5131
- var items = [];
5132
- this.forEach(function(value, name) {
5133
- items.push([name, value]);
5134
- });
5135
- return iteratorFor(items);
5136
- };
5137
- if (support.iterable) {
5138
- Headers2.prototype[Symbol.iterator] = Headers2.prototype.entries;
5139
- }
5140
- function consumed(body) {
5141
- if (body.bodyUsed) {
5142
- return Promise.reject(new TypeError("Already read"));
5143
- }
5144
- body.bodyUsed = true;
5145
- }
5146
- function fileReaderReady(reader) {
5147
- return new Promise(function(resolve, reject) {
5148
- reader.onload = function() {
5149
- resolve(reader.result);
5150
- };
5151
- reader.onerror = function() {
5152
- reject(reader.error);
5153
- };
5154
- });
5155
- }
5156
- function readBlobAsArrayBuffer(blob) {
5157
- var reader = new FileReader();
5158
- var promise = fileReaderReady(reader);
5159
- reader.readAsArrayBuffer(blob);
5160
- return promise;
5161
- }
5162
- function readBlobAsText(blob) {
5163
- var reader = new FileReader();
5164
- var promise = fileReaderReady(reader);
5165
- reader.readAsText(blob);
5166
- return promise;
5167
- }
5168
- function readArrayBufferAsText(buf) {
5169
- var view = new Uint8Array(buf);
5170
- var chars2 = new Array(view.length);
5171
- for (var i = 0; i < view.length; i++) {
5172
- chars2[i] = String.fromCharCode(view[i]);
5173
- }
5174
- return chars2.join("");
5175
- }
5176
- function bufferClone(buf) {
5177
- if (buf.slice) {
5178
- return buf.slice(0);
5179
- } else {
5180
- var view = new Uint8Array(buf.byteLength);
5181
- view.set(new Uint8Array(buf));
5182
- return view.buffer;
5183
- }
5184
- }
5185
- function Body() {
5186
- this.bodyUsed = false;
5187
- this._initBody = function(body) {
5188
- this._bodyInit = body;
5189
- if (!body) {
5190
- this._bodyText = "";
5191
- } else if (typeof body === "string") {
5192
- this._bodyText = body;
5193
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
5194
- this._bodyBlob = body;
5195
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
5196
- this._bodyFormData = body;
5197
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
5198
- this._bodyText = body.toString();
5199
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
5200
- this._bodyArrayBuffer = bufferClone(body.buffer);
5201
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
5202
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
5203
- this._bodyArrayBuffer = bufferClone(body);
5204
- } else {
5205
- throw new Error("unsupported BodyInit type");
5206
- }
5207
- if (!this.headers.get("content-type")) {
5208
- if (typeof body === "string") {
5209
- this.headers.set("content-type", "text/plain;charset=UTF-8");
5210
- } else if (this._bodyBlob && this._bodyBlob.type) {
5211
- this.headers.set("content-type", this._bodyBlob.type);
5212
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
5213
- this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
5214
- }
5215
- }
5216
- };
5217
- if (support.blob) {
5218
- this.blob = function() {
5219
- var rejected = consumed(this);
5220
- if (rejected) {
5221
- return rejected;
5222
- }
5223
- if (this._bodyBlob) {
5224
- return Promise.resolve(this._bodyBlob);
5225
- } else if (this._bodyArrayBuffer) {
5226
- return Promise.resolve(new Blob([this._bodyArrayBuffer]));
5227
- } else if (this._bodyFormData) {
5228
- throw new Error("could not read FormData body as blob");
5229
- } else {
5230
- return Promise.resolve(new Blob([this._bodyText]));
5231
- }
5232
- };
5233
- this.arrayBuffer = function() {
5234
- if (this._bodyArrayBuffer) {
5235
- return consumed(this) || Promise.resolve(this._bodyArrayBuffer);
5236
- } else {
5237
- return this.blob().then(readBlobAsArrayBuffer);
5238
- }
5239
- };
5240
- }
5241
- this.text = function() {
5242
- var rejected = consumed(this);
5243
- if (rejected) {
5244
- return rejected;
5245
- }
5246
- if (this._bodyBlob) {
5247
- return readBlobAsText(this._bodyBlob);
5248
- } else if (this._bodyArrayBuffer) {
5249
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
5250
- } else if (this._bodyFormData) {
5251
- throw new Error("could not read FormData body as text");
5252
- } else {
5253
- return Promise.resolve(this._bodyText);
5254
- }
5255
- };
5256
- if (support.formData) {
5257
- this.formData = function() {
5258
- return this.text().then(decode);
5259
- };
5260
- }
5261
- this.json = function() {
5262
- return this.text().then(JSON.parse);
5263
- };
5264
- return this;
5265
- }
5266
- var methods = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
5267
- function normalizeMethod(method) {
5268
- var upcased = method.toUpperCase();
5269
- return methods.indexOf(upcased) > -1 ? upcased : method;
5270
- }
5271
- function Request(input, options) {
5272
- options = options || {};
5273
- var body = options.body;
5274
- if (input instanceof Request) {
5275
- if (input.bodyUsed) {
5276
- throw new TypeError("Already read");
5277
- }
5278
- this.url = input.url;
5279
- this.credentials = input.credentials;
5280
- if (!options.headers) {
5281
- this.headers = new Headers2(input.headers);
5282
- }
5283
- this.method = input.method;
5284
- this.mode = input.mode;
5285
- if (!body && input._bodyInit != null) {
5286
- body = input._bodyInit;
5287
- input.bodyUsed = true;
5288
- }
5289
- } else {
5290
- this.url = String(input);
5291
- }
5292
- this.credentials = options.credentials || this.credentials || "omit";
5293
- if (options.headers || !this.headers) {
5294
- this.headers = new Headers2(options.headers);
5295
- }
5296
- this.method = normalizeMethod(options.method || this.method || "GET");
5297
- this.mode = options.mode || this.mode || null;
5298
- this.referrer = null;
5299
- if ((this.method === "GET" || this.method === "HEAD") && body) {
5300
- throw new TypeError("Body not allowed for GET or HEAD requests");
5301
- }
5302
- this._initBody(body);
5303
- }
5304
- Request.prototype.clone = function() {
5305
- return new Request(this, { body: this._bodyInit });
5306
- };
5307
- function decode(body) {
5308
- var form = new FormData();
5309
- body.trim().split("&").forEach(function(bytes) {
5310
- if (bytes) {
5311
- var split = bytes.split("=");
5312
- var name = split.shift().replace(/\+/g, " ");
5313
- var value = split.join("=").replace(/\+/g, " ");
5314
- form.append(decodeURIComponent(name), decodeURIComponent(value));
5315
- }
5316
- });
5317
- return form;
5318
- }
5319
- function parseHeaders(rawHeaders) {
5320
- var headers = new Headers2();
5321
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
5322
- preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
5323
- var parts = line.split(":");
5324
- var key = parts.shift().trim();
5325
- if (key) {
5326
- var value = parts.join(":").trim();
5327
- headers.append(key, value);
5328
- }
5329
- });
5330
- return headers;
5331
- }
5332
- Body.call(Request.prototype);
5333
- function Response2(bodyInit, options) {
5334
- if (!options) {
5335
- options = {};
5336
- }
5337
- this.type = "default";
5338
- this.status = options.status === void 0 ? 200 : options.status;
5339
- this.ok = this.status >= 200 && this.status < 300;
5340
- this.statusText = "statusText" in options ? options.statusText : "OK";
5341
- this.headers = new Headers2(options.headers);
5342
- this.url = options.url || "";
5343
- this._initBody(bodyInit);
5344
- }
5345
- Body.call(Response2.prototype);
5346
- Response2.prototype.clone = function() {
5347
- return new Response2(this._bodyInit, {
5348
- status: this.status,
5349
- statusText: this.statusText,
5350
- headers: new Headers2(this.headers),
5351
- url: this.url
5352
- });
5353
- };
5354
- Response2.error = function() {
5355
- var response = new Response2(null, { status: 0, statusText: "" });
5356
- response.type = "error";
5357
- return response;
5358
- };
5359
- var redirectStatuses = [301, 302, 303, 307, 308];
5360
- Response2.redirect = function(url, status) {
5361
- if (redirectStatuses.indexOf(status) === -1) {
5362
- throw new RangeError("Invalid status code");
5363
- }
5364
- return new Response2(null, { status, headers: { location: url } });
5365
- };
5366
- self2.Headers = Headers2;
5367
- self2.Request = Request;
5368
- self2.Response = Response2;
5369
- self2.fetch = function(input, init2) {
5370
- return new Promise(function(resolve, reject) {
5371
- var request = new Request(input, init2);
5372
- var xhr = new XMLHttpRequest();
5373
- xhr.onload = function() {
5374
- var options = {
5375
- status: xhr.status,
5376
- statusText: xhr.statusText,
5377
- headers: parseHeaders(xhr.getAllResponseHeaders() || "")
5378
- };
5379
- options.url = "responseURL" in xhr ? xhr.responseURL : options.headers.get("X-Request-URL");
5380
- var body = "response" in xhr ? xhr.response : xhr.responseText;
5381
- resolve(new Response2(body, options));
5382
- };
5383
- xhr.onerror = function() {
5384
- reject(new TypeError("Network request failed"));
5385
- };
5386
- xhr.ontimeout = function() {
5387
- reject(new TypeError("Network request failed"));
5388
- };
5389
- xhr.open(request.method, request.url, true);
5390
- if (request.credentials === "include") {
5391
- xhr.withCredentials = true;
5392
- } else if (request.credentials === "omit") {
5393
- xhr.withCredentials = false;
5394
- }
5395
- if ("responseType" in xhr && support.blob) {
5396
- xhr.responseType = "blob";
5397
- }
5398
- request.headers.forEach(function(value, name) {
5399
- xhr.setRequestHeader(name, value);
5400
- });
5401
- xhr.send(typeof request._bodyInit === "undefined" ? null : request._bodyInit);
5402
- });
5403
- };
5404
- self2.fetch.polyfill = true;
5405
- })(typeof self !== "undefined" ? self : this);
5406
- },
5407
- /* 6 */
5408
- /***/
5409
- function(module2, exports2, __webpack_require__) {
5410
- Object.defineProperty(exports2, "__esModule", {
5411
- value: true
5412
- });
5413
- exports2.core = exports2.adyen = exports2.exchange = exports2.priceAlert = exports2.users = exports2.quotes = exports2.redirect = exports2.utils = exports2.purchase = exports2.trip = exports2.search = exports2.collections = exports2.session = exports2.apiRequest = exports2.setUserAuthToken = exports2.setConfig = void 0;
5414
- var _config = __webpack_require__(1);
5415
- var _apiRequest = __webpack_require__(0);
5416
- var apiRequest = _interopRequireWildcard(_apiRequest);
5417
- var _session = __webpack_require__(10);
5418
- var session = _interopRequireWildcard(_session);
5419
- var _collections = __webpack_require__(11);
5420
- var collections = _interopRequireWildcard(_collections);
5421
- var _search = __webpack_require__(12);
5422
- var search = _interopRequireWildcard(_search);
5423
- var _trip = __webpack_require__(13);
5424
- var trip = _interopRequireWildcard(_trip);
5425
- var _purchase = __webpack_require__(14);
5426
- var purchase = _interopRequireWildcard(_purchase);
5427
- var _utils = __webpack_require__(17);
5428
- var utils = _interopRequireWildcard(_utils);
5429
- var _redirect = __webpack_require__(19);
5430
- var redirect = _interopRequireWildcard(_redirect);
5431
- var _quotes = __webpack_require__(20);
5432
- var quotes = _interopRequireWildcard(_quotes);
5433
- var _users = __webpack_require__(21);
5434
- var users = _interopRequireWildcard(_users);
5435
- var _priceAlert = __webpack_require__(22);
5436
- var priceAlert = _interopRequireWildcard(_priceAlert);
5437
- var _exchange = __webpack_require__(23);
5438
- var exchange = _interopRequireWildcard(_exchange);
5439
- var _adyen = __webpack_require__(24);
5440
- var adyen = _interopRequireWildcard(_adyen);
5441
- var _core = __webpack_require__(25);
5442
- var core = _interopRequireWildcard(_core);
5443
- function _interopRequireWildcard(obj) {
5444
- if (obj && obj.__esModule) {
5445
- return obj;
5446
- } else {
5447
- var newObj = {};
5448
- if (obj != null) {
5449
- for (var key in obj) {
5450
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5451
- }
5452
- }
5453
- newObj.default = obj;
5454
- return newObj;
5455
- }
5456
- }
5457
- exports2.setConfig = _config.setConfig;
5458
- exports2.setUserAuthToken = _config.setUserAuthToken;
5459
- exports2.apiRequest = apiRequest;
5460
- exports2.session = session;
5461
- exports2.collections = collections;
5462
- exports2.search = search;
5463
- exports2.trip = trip;
5464
- exports2.purchase = purchase;
5465
- exports2.utils = utils;
5466
- exports2.redirect = redirect;
5467
- exports2.quotes = quotes;
5468
- exports2.users = users;
5469
- exports2.priceAlert = priceAlert;
5470
- exports2.exchange = exchange;
5471
- exports2.adyen = adyen;
5472
- exports2.core = core;
5473
- },
5474
- /* 7 */
5475
- /***/
5476
- function(module2, exports2, __webpack_require__) {
5477
- Object.defineProperty(exports2, "__esModule", {
5478
- value: true
5479
- });
5480
- function _classCallCheck(instance, Constructor) {
5481
- if (!(instance instanceof Constructor)) {
5482
- throw new TypeError("Cannot call a class as a function");
5483
- }
5484
- }
5485
- function _possibleConstructorReturn(self2, call) {
5486
- if (!self2) {
5487
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5488
- }
5489
- return call && (typeof call === "object" || typeof call === "function") ? call : self2;
5490
- }
5491
- function _inherits(subClass, superClass) {
5492
- if (typeof superClass !== "function" && superClass !== null) {
5493
- throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
5494
- }
5495
- subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
5496
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
5497
- }
5498
- var NetworkError = function(_Error) {
5499
- _inherits(NetworkError2, _Error);
5500
- function NetworkError2() {
5501
- var code = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : -100;
5502
- var message = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Unknown error";
5503
- _classCallCheck(this, NetworkError2);
5504
- var _this = _possibleConstructorReturn(this, (NetworkError2.__proto__ || Object.getPrototypeOf(NetworkError2)).call(this, message));
5505
- _this.code = code;
5506
- _this.stack = new Error().stack;
5507
- return _this;
5508
- }
5509
- return NetworkError2;
5510
- }(Error);
5511
- exports2.default = NetworkError;
5512
- },
5513
- /* 8 */
5514
- /***/
5515
- function(module2, exports2, __webpack_require__) {
5516
- Object.defineProperty(exports2, "__esModule", {
5517
- value: true
5518
- });
5519
- var _extends = Object.assign || function(target) {
5520
- for (var i = 1; i < arguments.length; i++) {
5521
- var source = arguments[i];
5522
- for (var key in source) {
5523
- if (Object.prototype.hasOwnProperty.call(source, key)) {
5524
- target[key] = source[key];
5525
- }
5526
- }
5527
- }
5528
- return target;
5529
- };
5530
- var authorizationErrors = {
5531
- // UNAUTHORIZED
5532
- 1: {
5533
- code: 200,
5534
- message: "Operación no autorizada"
5535
- }
5536
- };
5537
- var generalErrors = {
5538
- // INCORRECT_PARAMS
5539
- 3: {
5540
- code: 300,
5541
- message: "Parámetros incorrectos"
5542
- },
5543
- // INCORRECT_DATE
5544
- 7: {
5545
- code: 301,
5546
- message: "Fecha inválida"
5547
- }
5548
- };
5549
- var tripErrors = {
5550
- // NONEXISTENT_TRIP
5551
- 10: {
5552
- code: 400,
5553
- message: "No existe el viaje"
5554
- },
5555
- // journey_key_not_found
5556
- 20: {
5557
- code: 60,
5558
- message: "No se encontró el viaje"
5559
- },
5560
- // sold_out_fare_code
5561
- 21: {
5562
- code: 60,
5563
- message: "Tarifa no disponible"
5564
- },
5565
- // unavailable_fare_code
5566
- 22: {
5567
- code: 60,
5568
- message: "Tarifa no disponible"
5569
- }
5570
- };
5571
- var discountCodeErrors = function discountCodeErrors2(message) {
5572
- return {
5573
- // INVALID_DISCOUNT
5574
- 11: {
5575
- code: 500,
5576
- message
5577
- },
5578
- //EXPIRED_DISCOUNT
5579
- 12: {
5580
- code: 501,
5581
- message
5582
- }
5583
- };
5584
- };
5585
- var ticketErrors = {
5586
- // unavailable_student
5587
- 23: {
5588
- code: 60,
5589
- message: "Estudiante no disponible"
5590
- },
5591
- // unavailable_teacher
5592
- 24: {
5593
- code: 60,
5594
- message: "Profesor no disponible"
5595
- },
5596
- // unavailable_minor
5597
- 25: {
5598
- code: 60,
5599
- message: "Menor no disponible"
5600
- },
5601
- // unavailable_special
5602
- 26: {
5603
- code: 60,
5604
- message: "Capacidades diferentes no disponible"
5605
- },
5606
- // unavailable_older
5607
- 27: {
5608
- code: 60,
5609
- message: "INSEN no disponible"
5610
- },
5611
- // unavailable_general
5612
- 28: {
5613
- code: 60,
5614
- message: "General no disponible"
5615
- },
5616
- // unavailable_unknown
5617
- 29: {
5618
- code: 60,
5619
- message: "Error desconocido"
5620
- }
5621
- };
5622
- var exchange = function exchange2(message) {
5623
- return {
5624
- 30: {
5625
- code: 30,
5626
- message
5627
- }
5628
- };
5629
- };
5630
- var paymentErrors = {
5631
- 50: {
5632
- code: 50,
5633
- message: "Unknow Error"
5634
- }
5635
- };
5636
- var apiErrors = exports2.apiErrors = function apiErrors2(message) {
5637
- return _extends({}, authorizationErrors, generalErrors, tripErrors, discountCodeErrors(message), ticketErrors, paymentErrors, exchange(message));
5638
- };
5639
- exports2.default = apiErrors;
5640
- },
5641
- /* 9 */
5642
- /***/
5643
- function(module2, exports2, __webpack_require__) {
5644
- Object.defineProperty(exports2, "__esModule", {
5645
- value: true
5646
- });
5647
- var _createClass = /* @__PURE__ */ function() {
5648
- function defineProperties(target, props) {
5649
- for (var i = 0; i < props.length; i++) {
5650
- var descriptor = props[i];
5651
- descriptor.enumerable = descriptor.enumerable || false;
5652
- descriptor.configurable = true;
5653
- if ("value" in descriptor) descriptor.writable = true;
5654
- Object.defineProperty(target, descriptor.key, descriptor);
5655
- }
5656
- }
5657
- return function(Constructor, protoProps, staticProps) {
5658
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
5659
- if (staticProps) defineProperties(Constructor, staticProps);
5660
- return Constructor;
5661
- };
5662
- }();
5663
- var _request = __webpack_require__(2);
5664
- var request = _interopRequireWildcard(_request);
5665
- function _interopRequireWildcard(obj) {
5666
- if (obj && obj.__esModule) {
5667
- return obj;
5668
- } else {
5669
- var newObj = {};
5670
- if (obj != null) {
5671
- for (var key in obj) {
5672
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5673
- }
5674
- }
5675
- newObj.default = obj;
5676
- return newObj;
5677
- }
5678
- }
5679
- function _classCallCheck(instance, Constructor) {
5680
- if (!(instance instanceof Constructor)) {
5681
- throw new TypeError("Cannot call a class as a function");
5682
- }
5683
- }
5684
- var Poll = function() {
5685
- function Poll2(_ref) {
5686
- var url = _ref.url, watch = _ref.watch, expect = _ref.expect, _ref$maxRetries = _ref.maxRetries, maxRetries = _ref$maxRetries === void 0 ? 30 : _ref$maxRetries, _ref$interval = _ref.interval, interval = _ref$interval === void 0 ? 2e3 : _ref$interval, _ref$eachCall = _ref.eachCall, eachCall = _ref$eachCall === void 0 ? null : _ref$eachCall;
5687
- _classCallCheck(this, Poll2);
5688
- this.url = url;
5689
- this.watch = watch;
5690
- this.expect = expect instanceof Array ? expect : [expect];
5691
- this.interval = interval;
5692
- this.maxRetries = maxRetries;
5693
- this.eachCall = eachCall && eachCall.bind(this);
5694
- this.aborted = false;
5695
- this.timers = [];
5696
- this.execute = this.execute.bind(this);
5697
- this.executeEachCall = this.executeEachCall.bind(this);
5698
- }
5699
- _createClass(Poll2, [{
5700
- key: "start",
5701
- value: function start() {
5702
- return this.execute(this.maxRetries);
5703
- }
5704
- }, {
5705
- key: "abort",
5706
- value: function abort() {
5707
- this.aborted = true;
5708
- }
5709
- }, {
5710
- key: "execute",
5711
- value: function execute(retries) {
5712
- var _this = this;
5713
- var onRequestSuccess = function onRequestSuccess2(payload) {
5714
- if (_this.expect.includes(payload[_this.watch]) || retries === 1 || _this.aborted) {
5715
- var status = payload[_this.watch];
5716
- if (retries === 1) {
5717
- status = "retries_exceeded";
5718
- } else if (_this.aborted) {
5719
- status = "aborted";
5720
- }
5721
- _this.timers.forEach(clearInterval);
5722
- _this.executeEachCall(status, payload);
5723
- } else if (payload[_this.watch] === "failed") {
5724
- _this.timers.forEach(clearInterval);
5725
- _this.executeEachCall("failed", payload);
5726
- } else {
5727
- _this.executeEachCall("pending", payload);
5728
- var timer = window.setTimeout(_this.execute, _this.interval, retries - 1);
5729
- _this.timers.push(timer);
5730
- }
5731
- };
5732
- var onRequestError = function onRequestError2(err) {
5733
- return _this.executeEachCall("error", err);
5734
- };
5735
- return request.get(this.url, {}, onRequestError).then(onRequestSuccess);
5736
- }
5737
- }, {
5738
- key: "executeEachCall",
5739
- value: function executeEachCall(status, payload) {
5740
- if (this.eachCall instanceof Function) {
5741
- if (this.eachCall({ status, payload })) {
5742
- this.abort();
5743
- }
5744
- }
5745
- }
5746
- }]);
5747
- return Poll2;
5748
- }();
5749
- exports2.default = Poll;
5750
- },
5751
- /* 10 */
5752
- /***/
5753
- function(module2, exports2, __webpack_require__) {
5754
- Object.defineProperty(exports2, "__esModule", {
5755
- value: true
5756
- });
5757
- exports2.get = get;
5758
- exports2.agency = agency;
5759
- var _apiRequest = __webpack_require__(0);
5760
- var apiRequest = _interopRequireWildcard(_apiRequest);
5761
- function _interopRequireWildcard(obj) {
5762
- if (obj && obj.__esModule) {
5763
- return obj;
5764
- } else {
5765
- var newObj = {};
5766
- if (obj != null) {
5767
- for (var key in obj) {
5768
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5769
- }
5770
- }
5771
- newObj.default = obj;
5772
- return newObj;
5773
- }
5774
- }
5775
- function get() {
5776
- return new Promise(function(resolve, reject) {
5777
- apiRequest.get("session", { apiVersion: "v1" }).then(function(session) {
5778
- return resolve(session);
5779
- }).catch(function(_ref) {
5780
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
5781
- return reject({ code, message });
5782
- });
5783
- });
5784
- }
5785
- function agency() {
5786
- return new Promise(function(resolve, reject) {
5787
- apiRequest.get("get_agency").then(function(agency2) {
5788
- return resolve(agency2);
5789
- }).catch(function(_ref2) {
5790
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
5791
- return reject({ code, message });
5792
- });
5793
- });
5794
- }
5795
- },
5796
- /* 11 */
5797
- /***/
5798
- function(module2, exports2, __webpack_require__) {
5799
- Object.defineProperty(exports2, "__esModule", {
5800
- value: true
5801
- });
5802
- exports2.getCountries = getCountries;
5803
- exports2.getPlaces = getPlaces;
5804
- var _apiRequest = __webpack_require__(0);
5805
- var apiRequest = _interopRequireWildcard(_apiRequest);
5806
- function _interopRequireWildcard(obj) {
5807
- if (obj && obj.__esModule) {
5808
- return obj;
5809
- } else {
5810
- var newObj = {};
5811
- if (obj != null) {
5812
- for (var key in obj) {
5813
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5814
- }
5815
- }
5816
- newObj.default = obj;
5817
- return newObj;
5818
- }
5819
- }
5820
- function getCountries() {
5821
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5822
- var _options$prefetch = options.prefetch, prefetch = _options$prefetch === void 0 ? true : _options$prefetch, _options$q = options.q, q = _options$q === void 0 ? "" : _options$q;
5823
- var queryParams = { prefetch, q };
5824
- return new Promise(function(resolve, reject) {
5825
- apiRequest.get("countries", { queryParams }).then(function(countries) {
5826
- return resolve(countries);
5827
- }).catch(function(_ref) {
5828
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
5829
- return reject({ code, message });
5830
- });
5831
- });
5832
- }
5833
- function getPlaces(q, from) {
5834
- var queryParams = !q ? { prefetch: true } : { q, from };
5835
- return new Promise(function(resolve, reject) {
5836
- apiRequest.get("places", { queryParams }).then(function(places) {
5837
- return resolve(places);
5838
- }).catch(function(_ref2) {
5839
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
5840
- return reject({ code, message });
5841
- });
5842
- });
5843
- }
5844
- },
5845
- /* 12 */
5846
- /***/
5847
- function(module2, exports2, __webpack_require__) {
5848
- Object.defineProperty(exports2, "__esModule", {
5849
- value: true
5850
- });
5851
- var _slicedToArray = /* @__PURE__ */ function() {
5852
- function sliceIterator(arr, i) {
5853
- var _arr = [];
5854
- var _n = true;
5855
- var _d = false;
5856
- var _e = void 0;
5857
- try {
5858
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
5859
- _arr.push(_s.value);
5860
- if (i && _arr.length === i) break;
5861
- }
5862
- } catch (err) {
5863
- _d = true;
5864
- _e = err;
5865
- } finally {
5866
- try {
5867
- if (!_n && _i["return"]) _i["return"]();
5868
- } finally {
5869
- if (_d) throw _e;
5870
- }
5871
- }
5872
- return _arr;
5873
- }
5874
- return function(arr, i) {
5875
- if (Array.isArray(arr)) {
5876
- return arr;
5877
- } else if (Symbol.iterator in Object(arr)) {
5878
- return sliceIterator(arr, i);
5879
- } else {
5880
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
5881
- }
5882
- };
5883
- }();
5884
- var _extends = Object.assign || function(target) {
5885
- for (var i = 1; i < arguments.length; i++) {
5886
- var source = arguments[i];
5887
- for (var key in source) {
5888
- if (Object.prototype.hasOwnProperty.call(source, key)) {
5889
- target[key] = source[key];
5890
- }
5891
- }
5892
- }
5893
- return target;
5894
- };
5895
- exports2.create = create;
5896
- exports2.stopSearch = stopSearch;
5897
- exports2.stopAllSearches = stopAllSearches;
5898
- exports2.get = get;
5899
- exports2.validateExternalCoupon = validateExternalCoupon;
5900
- exports2.walletSearchDiscount = walletSearchDiscount;
5901
- var _apiRequest = __webpack_require__(0);
5902
- var apiRequest = _interopRequireWildcard(_apiRequest);
5903
- function _interopRequireWildcard(obj) {
5904
- if (obj && obj.__esModule) {
5905
- return obj;
5906
- } else {
5907
- var newObj = {};
5908
- if (obj != null) {
5909
- for (var key in obj) {
5910
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
5911
- }
5912
- }
5913
- newObj.default = obj;
5914
- return newObj;
5915
- }
5916
- }
5917
- var currentPolls = {};
5918
- function startPolls(payload, polling) {
5919
- var _payload$search = payload.search, id = _payload$search.id, typeOfTransport = _payload$search.type_of_transport;
5920
- var bus = typeOfTransport.bus, flights = typeOfTransport.flights, mix = typeOfTransport.mix;
5921
- var _polling$initBuses = polling.initBuses, initBuses = _polling$initBuses === void 0 ? true : _polling$initBuses, _polling$initFlights = polling.initFlights, initFlights = _polling$initFlights === void 0 ? true : _polling$initFlights, _polling$initRides = polling.initRides, initRides = _polling$initRides === void 0 ? false : _polling$initRides, _polling$initMix = polling.initMix, initMix = _polling$initMix === void 0 ? true : _polling$initMix, onReceiveBuses = polling.onReceiveBuses, onReceiveFlights = polling.onReceiveFlights, onReceiveRides = polling.onReceiveRides, onReceiveMixed = polling.onReceiveMixed;
5922
- var pollOptions = _extends({
5923
- watch: "state",
5924
- expect: "finished"
5925
- }, polling.options || {});
5926
- var polls = [];
5927
- if (bus && bus.active && initBuses) {
5928
- var poll = apiRequest.poll("search/" + id + "?type=bus", onReceiveBuses, pollOptions);
5929
- poll.start();
5930
- polls.push(poll);
5931
- } else if (onReceiveBuses) {
5932
- onReceiveBuses({ status: "deactivated" });
5933
- }
5934
- if (flights && flights.active && initFlights) {
5935
- var _poll = apiRequest.poll("search/" + id + "?type=plane", onReceiveFlights, pollOptions);
5936
- _poll.start();
5937
- polls.push(_poll);
5938
- } else if (onReceiveFlights) {
5939
- onReceiveFlights({ status: "deactivated" });
5940
- }
5941
- if (mix && mix.active && initMix) {
5942
- var _poll2 = apiRequest.poll("search/" + id + "?type=mix", onReceiveMixed, pollOptions);
5943
- _poll2.start();
5944
- polls.push(_poll2);
5945
- } else if (onReceiveMixed) {
5946
- onReceiveMixed({ status: "deactivated" });
5947
- }
5948
- if (initRides) {
5949
- var _poll3 = apiRequest.poll("search/" + id + "?type=car", onReceiveRides, pollOptions);
5950
- _poll3.start();
5951
- polls.push(_poll3);
5952
- }
5953
- currentPolls[id] = polls;
5954
- return payload;
5955
- }
5956
- function create(params, polling) {
5957
- var onCreateSuccess = function onCreateSuccess2(search) {
5958
- return startPolls(search, polling);
5959
- };
5960
- return apiRequest.post("search", params).then(onCreateSuccess);
5961
- }
5962
- function stopSearch(searchId) {
5963
- if (!currentPolls || !searchId || !currentPolls[searchId]) {
5964
- return false;
5965
- }
5966
- currentPolls[searchId].forEach(function(p2) {
5967
- return p2.abort();
5968
- });
5969
- Reflect.deleteProperty(currentPolls, searchId);
5970
- return true;
5971
- }
5972
- function stopAllSearches() {
5973
- if (!currentPolls) {
5974
- return false;
5975
- }
5976
- Object.entries(currentPolls).forEach(function(_ref) {
5977
- var _ref2 = _slicedToArray(_ref, 2);
5978
- _ref2[0];
5979
- var polls = _ref2[1];
5980
- return polls.forEach(function(p2) {
5981
- return p2.abort();
5982
- });
5983
- });
5984
- currentPolls = {};
5985
- return true;
5986
- }
5987
- function get(id, polling) {
5988
- return new Promise(function(resolve, reject) {
5989
- apiRequest.get("search/" + id + "/info").then(function(search) {
5990
- return resolve(startPolls(search, polling));
5991
- }).catch(function(_ref3) {
5992
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
5993
- return reject({ code, message });
5994
- });
5995
- });
5996
- }
5997
- function validateExternalCoupon(couponCode) {
5998
- var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
5999
- var query = new URLSearchParams(params).toString();
6000
- var queryParams = query ? "?" + query : "";
6001
- return new Promise(function(resolve, reject) {
6002
- apiRequest.get("search/discounts/validate_external_coupon/" + couponCode + queryParams).then(function(response) {
6003
- return resolve(response);
6004
- }).catch(function(_ref4) {
6005
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
6006
- return reject({ code, message });
6007
- });
6008
- });
6009
- }
6010
- function walletSearchDiscount(wallet) {
6011
- var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6012
- var query = new URLSearchParams(params).toString();
6013
- var queryParams = query ? "?" + query : "";
6014
- return new Promise(function(resolve, reject) {
6015
- apiRequest.get(wallet + "/discounts" + queryParams).then(function(response) {
6016
- return resolve(response);
6017
- }).catch(function(_ref5) {
6018
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
6019
- return reject({ code, message });
6020
- });
6021
- });
6022
- }
6023
- },
6024
- /* 13 */
6025
- /***/
6026
- function(module2, exports2, __webpack_require__) {
6027
- Object.defineProperty(exports2, "__esModule", {
6028
- value: true
6029
- });
6030
- var _extends = Object.assign || function(target) {
6031
- for (var i = 1; i < arguments.length; i++) {
6032
- var source = arguments[i];
6033
- for (var key in source) {
6034
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6035
- target[key] = source[key];
6036
- }
6037
- }
6038
- }
6039
- return target;
6040
- };
6041
- exports2.get = get;
6042
- exports2.getWithBus = getWithBus;
6043
- var _apiRequest = __webpack_require__(0);
6044
- var apiRequest = _interopRequireWildcard(_apiRequest);
6045
- function _interopRequireWildcard(obj) {
6046
- if (obj && obj.__esModule) {
6047
- return obj;
6048
- } else {
6049
- var newObj = {};
6050
- if (obj != null) {
6051
- for (var key in obj) {
6052
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6053
- }
6054
- }
6055
- newObj.default = obj;
6056
- return newObj;
6057
- }
6058
- }
6059
- function startPoll(slug, payload, polling) {
6060
- var id = payload.id;
6061
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, _polling$options = polling.options, options = _polling$options === void 0 ? {} : _polling$options, onReceiveTrip = polling.onReceiveTrip;
6062
- var pollOptions = _extends({
6063
- watch: "state",
6064
- expect: "finished"
6065
- }, options);
6066
- var poll = void 0;
6067
- var startedPoll = void 0;
6068
- if (init2) {
6069
- poll = apiRequest.poll("trips/" + slug + "/details_requests/" + id, onReceiveTrip, pollOptions);
6070
- startedPoll = poll.start();
6071
- }
6072
- return {
6073
- payload,
6074
- polls: {
6075
- trip: startedPoll,
6076
- abort: function abort() {
6077
- return poll.abort();
6078
- }
6079
- }
6080
- };
6081
- }
6082
- function encodePassengers(passengers) {
6083
- var encoded = [];
6084
- Object.keys(passengers).forEach(function(key) {
6085
- var quantity = passengers[key];
6086
- if (quantity) {
6087
- encoded.push(key + "=" + quantity);
6088
- }
6089
- });
6090
- return encoded.join("&");
6091
- }
6092
- function get(id) {
6093
- var passengers = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6094
- return new Promise(function(resolve, reject) {
6095
- apiRequest.get("trips/" + id + "?" + encodePassengers(passengers)).then(function(trip) {
6096
- return resolve(trip);
6097
- }).catch(function(_ref) {
6098
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6099
- return reject({ code, message });
6100
- });
6101
- });
6102
- }
6103
- function getWithBus(id) {
6104
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
6105
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6106
- var postPayload = _extends({
6107
- with_pricing: true
6108
- }, options);
6109
- return new Promise(function(resolve, reject) {
6110
- apiRequest.post("trips/" + id + "/details_requests", postPayload).then(function(trip) {
6111
- return resolve(startPoll(id, trip, polling));
6112
- }).catch(function(_ref2) {
6113
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6114
- return reject({ code, message });
6115
- });
6116
- });
6117
- }
6118
- },
6119
- /* 14 */
6120
- /***/
6121
- function(module2, exports2, __webpack_require__) {
6122
- Object.defineProperty(exports2, "__esModule", {
6123
- value: true
6124
- });
6125
- exports2.startTicketsPoll = void 0;
6126
- var _extends = Object.assign || function(target) {
6127
- for (var i = 1; i < arguments.length; i++) {
6128
- var source = arguments[i];
6129
- for (var key in source) {
6130
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6131
- target[key] = source[key];
6132
- }
6133
- }
6134
- }
6135
- return target;
6136
- };
6137
- exports2.startPurchasePoll = startPurchasePoll;
6138
- exports2.create = create;
6139
- exports2.get = get;
6140
- exports2.update = update;
6141
- exports2.createPassengers = createPassengers;
6142
- exports2.updatePassengers = updatePassengers;
6143
- exports2.deletePassenger = deletePassenger;
6144
- exports2.createTickets = createTickets;
6145
- exports2.applyDiscountCode = applyDiscountCode;
6146
- exports2.removeDiscountCode = removeDiscountCode;
6147
- exports2.createPayment = createPayment;
6148
- exports2.getPayment = getPayment;
6149
- exports2.sendEmail = sendEmail;
6150
- exports2.confirmPaypalPayment = confirmPaypalPayment;
6151
- exports2.updateWallet = updateWallet;
6152
- exports2.verifyPhoneNumber = verifyPhoneNumber;
6153
- exports2.verifySmsCode = verifySmsCode;
6154
- exports2.unlockSeats = unlockSeats;
6155
- exports2.generateOTP = generateOTP;
6156
- exports2.validateOTP = validateOTP;
6157
- exports2.membershipDiscountPayment = membershipDiscountPayment;
6158
- exports2.membershipDiscountPaymentDelete = membershipDiscountPaymentDelete;
6159
- exports2.downloadTickets = downloadTickets;
6160
- exports2.downloadPurchasesHistory = downloadPurchasesHistory;
6161
- exports2.increaseExpiration = increaseExpiration;
6162
- var _apiRequest = __webpack_require__(0);
6163
- var apiRequest = _interopRequireWildcard(_apiRequest);
6164
- var _payment = __webpack_require__(15);
6165
- var _tickets = __webpack_require__(16);
6166
- function _interopRequireWildcard(obj) {
6167
- if (obj && obj.__esModule) {
6168
- return obj;
6169
- } else {
6170
- var newObj = {};
6171
- if (obj != null) {
6172
- for (var key in obj) {
6173
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6174
- }
6175
- }
6176
- newObj.default = obj;
6177
- return newObj;
6178
- }
6179
- }
6180
- var PURCHASE = "purchases";
6181
- var WALLET = "wallet_movements";
6182
- var WALLET_CANCEL = "cancel";
6183
- var PASSENGER_REQUESTS = "passenger_requests";
6184
- var PASSENGER_REQUESTS_UPDATE = PASSENGER_REQUESTS + "/update";
6185
- var TICKET_REQUESTS = "ticket_requests";
6186
- var TICKET_RESEND = "tickets/resend";
6187
- var DISCOUNTS = "discounts";
6188
- var CANCEL = "cancel";
6189
- var PAYMENT_DISCOUNT = "payment_discounts";
6190
- var PAYMENTS = "payments";
6191
- var PURCHASES_HISTORY = "purchase_history/search";
6192
- var EXTEND_EXPIRE_AT = "session-extension";
6193
- function startPurchasePoll(token, polling) {
6194
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePurchase = polling.onReceivePurchase;
6195
- var endpoint = "purchases/" + token;
6196
- var pollOptions = _extends({
6197
- watch: "state",
6198
- expect: ["completed"]
6199
- }, polling.options || {});
6200
- var poll = void 0;
6201
- var startedPoll = void 0;
6202
- if (init2) {
6203
- poll = apiRequest.poll(endpoint, onReceivePurchase, pollOptions);
6204
- startedPoll = poll.start();
6205
- }
6206
- return {
6207
- polls: {
6208
- payment: startedPoll,
6209
- abort: function abort() {
6210
- return poll.abort();
6211
- }
6212
- }
6213
- };
6214
- }
6215
- function create(params) {
6216
- return new Promise(function(resolve, reject) {
6217
- apiRequest.post(PURCHASE, params).then(function(purchase) {
6218
- return resolve(purchase);
6219
- }).catch(function(_ref) {
6220
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6221
- return reject({ code, message });
6222
- });
6223
- });
6224
- }
6225
- function get(id, queryParams, polling) {
6226
- if (polling) {
6227
- return startPurchasePoll(id, polling);
6228
- }
6229
- return new Promise(function(resolve, reject) {
6230
- apiRequest.get(PURCHASE + "/" + id, { queryParams }).then(function(purchase) {
6231
- return resolve(purchase);
6232
- }).catch(function(_ref2) {
6233
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6234
- return reject({ code, message });
6235
- });
6236
- });
6237
- }
6238
- function update(id, params) {
6239
- return new Promise(function(resolve, reject) {
6240
- apiRequest.put(PURCHASE + "/" + id, params).then(function(purchase) {
6241
- return resolve(purchase);
6242
- }).catch(function(_ref3) {
6243
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknown error" : _ref3$message;
6244
- return reject({ code, message });
6245
- });
6246
- });
6247
- }
6248
- function createPassengers(id, passengers) {
6249
- return new Promise(function(resolve, reject) {
6250
- apiRequest.post(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS, { passengers }).then(function(passengers2) {
6251
- return resolve(passengers2);
6252
- }).catch(function(_ref4) {
6253
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknown error" : _ref4$message;
6254
- return reject({ code, message });
6255
- });
6256
- });
6257
- }
6258
- function updatePassengers(id, passengers) {
6259
- return new Promise(function(resolve, reject) {
6260
- apiRequest.put(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS_UPDATE, { passengers }).then(function(passengers2) {
6261
- return resolve(passengers2);
6262
- }).catch(function(_ref5) {
6263
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknown error" : _ref5$message;
6264
- return reject({ code, message });
6265
- });
6266
- });
6267
- }
6268
- function deletePassenger(id, passengerId) {
6269
- return new Promise(function(resolve, reject) {
6270
- apiRequest.deleteMethod(PURCHASE + "/" + id + "/" + PASSENGER_REQUESTS + "/" + passengerId).then(function(response) {
6271
- return resolve(response);
6272
- }).catch(function(_ref6) {
6273
- var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknown error" : _ref6$message;
6274
- return reject({ code, message });
6275
- });
6276
- });
6277
- }
6278
- function createTickets(id, params) {
6279
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6280
- return new Promise(function(resolve, reject) {
6281
- apiRequest.post(PURCHASE + "/" + id + "/" + TICKET_REQUESTS, params).then(function(tickets) {
6282
- return resolve((0, _tickets.startTicketsPoll)(id, tickets, polling));
6283
- }).catch(function(_ref7) {
6284
- var _ref7$code = _ref7.code, code = _ref7$code === void 0 ? -100 : _ref7$code, _ref7$message = _ref7.message, message = _ref7$message === void 0 ? "Unknown error" : _ref7$message;
6285
- return reject({ code, message });
6286
- });
6287
- });
6288
- }
6289
- function applyDiscountCode(id, code) {
6290
- return new Promise(function(resolve, reject) {
6291
- apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS, { code }, { apiVersion: "v2" }).then(function() {
6292
- return get(id);
6293
- }).then(function(purchase) {
6294
- return resolve(purchase);
6295
- }).catch(function(_ref8) {
6296
- var _ref8$code = _ref8.code, code2 = _ref8$code === void 0 ? -100 : _ref8$code, _ref8$message = _ref8.message, message = _ref8$message === void 0 ? "Unknown error" : _ref8$message;
6297
- return reject({ code: code2, message });
6298
- });
6299
- });
6300
- }
6301
- function removeDiscountCode(id) {
6302
- return new Promise(function(resolve, reject) {
6303
- apiRequest.post(PURCHASE + "/" + id + "/" + DISCOUNTS + "/" + CANCEL, { apiVersion: "v2" }).then(function() {
6304
- return get(id);
6305
- }).then(function(purchase) {
6306
- return resolve(purchase);
6307
- }).catch(function(_ref9) {
6308
- var _ref9$code = _ref9.code, code = _ref9$code === void 0 ? -100 : _ref9$code, _ref9$message = _ref9.message, message = _ref9$message === void 0 ? "Unknown error" : _ref9$message;
6309
- return reject({ code, message });
6310
- });
6311
- });
6312
- }
6313
- function createPayment(id, params) {
6314
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6315
- return new Promise(function(resolve, reject) {
6316
- apiRequest.post(PURCHASE + "/" + id + "/" + PAYMENTS, params).then(function(payment) {
6317
- return resolve((0, _payment.startPaymentPoll)(id, payment, polling));
6318
- }).catch(function(_ref10) {
6319
- var _ref10$code = _ref10.code, code = _ref10$code === void 0 ? -100 : _ref10$code, _ref10$message = _ref10.message, message = _ref10$message === void 0 ? "Unknown error" : _ref10$message;
6320
- return reject({ code, message });
6321
- });
6322
- });
6323
- }
6324
- function getPayment(purchaseToken, paymentId, polling) {
6325
- if (polling) {
6326
- return (0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling);
6327
- }
6328
- return new Promise(function(resolve, reject) {
6329
- apiRequest.get(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId).then(function(payment) {
6330
- return resolve(payment);
6331
- }).catch(function(_ref11) {
6332
- var _ref11$code = _ref11.code, code = _ref11$code === void 0 ? -100 : _ref11$code, _ref11$message = _ref11.message, message = _ref11$message === void 0 ? "Unknown error" : _ref11$message;
6333
- return reject({ code, message });
6334
- });
6335
- });
6336
- }
6337
- function sendEmail(token, email) {
6338
- var queryParams = { email };
6339
- return new Promise(function(resolve, reject) {
6340
- apiRequest.get(PURCHASE + "/" + token + "/" + TICKET_RESEND, { queryParams }).then(function() {
6341
- return resolve();
6342
- }).catch(function(_ref12) {
6343
- var _ref12$code = _ref12.code, code = _ref12$code === void 0 ? -100 : _ref12$code, _ref12$message = _ref12.message, message = _ref12$message === void 0 ? "Unknown error" : _ref12$message;
6344
- reject({ code, message });
6345
- });
6346
- });
6347
- }
6348
- function confirmPaypalPayment(purchaseToken, paymentId) {
6349
- var polling = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6350
- return new Promise(function(resolve, reject) {
6351
- apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/confirm.json").then(function(payload) {
6352
- resolve((0, _payment.startPaymentPoll)(purchaseToken, { id: paymentId }, polling));
6353
- }).catch(function(_ref13) {
6354
- var _ref13$code = _ref13.code, code = _ref13$code === void 0 ? -100 : _ref13$code, _ref13$message = _ref13.message, message = _ref13$message === void 0 ? "Unknown error" : _ref13$message;
6355
- reject({ code, message });
6356
- });
6357
- });
6358
- }
6359
- function updateWallet(purchaseToken, using) {
6360
- var params = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
6361
- var baseUrl = PURCHASE + "/" + purchaseToken + "/" + WALLET;
6362
- var url = using ? baseUrl : baseUrl + "/" + WALLET_CANCEL;
6363
- return apiRequest.post(url, params).then(function() {
6364
- return get(purchaseToken);
6365
- });
6366
- }
6367
- function verifyPhoneNumber(purchaseToken, paymentId, params) {
6368
- return apiRequest.put(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/send_verification", params);
6369
- }
6370
- function verifySmsCode(purchaseToken, paymentId, code) {
6371
- return apiRequest.post(PURCHASE + "/" + purchaseToken + "/" + PAYMENTS + "/" + paymentId + "/verify_code", {
6372
- code
6373
- });
6374
- }
6375
- function unlockSeats(purchaseToken) {
6376
- return new Promise(function(resolve, reject) {
6377
- apiRequest.post(PURCHASE + "/" + purchaseToken + "/unlock_seats").then(function(response) {
6378
- return resolve(response);
6379
- }).catch(function(_ref14) {
6380
- var _ref14$code = _ref14.code, code = _ref14$code === void 0 ? -100 : _ref14$code, _ref14$message = _ref14.message, message = _ref14$message === void 0 ? "Unknown error" : _ref14$message;
6381
- return reject({ code, message });
6382
- });
6383
- });
6384
- }
6385
- function generateOTP(path, payload) {
6386
- return new Promise(function(resolve, reject) {
6387
- apiRequest.post(path + "/otp-generate", payload).then(function() {
6388
- return resolve();
6389
- }).catch(function(_ref15) {
6390
- var _ref15$code = _ref15.code, code = _ref15$code === void 0 ? -100 : _ref15$code, _ref15$message = _ref15.message, message = _ref15$message === void 0 ? "Unknown error" : _ref15$message;
6391
- return reject({ code, message });
6392
- });
6393
- });
6394
- }
6395
- function validateOTP(path, otp) {
6396
- return new Promise(function(resolve, reject) {
6397
- var payload = { otp };
6398
- apiRequest.post(path + "/otp-validate", payload).then(function() {
6399
- return resolve();
6400
- }).catch(function(_ref16) {
6401
- var _ref16$code = _ref16.code, code = _ref16$code === void 0 ? -100 : _ref16$code, _ref16$message = _ref16.message, message = _ref16$message === void 0 ? "Unknown error" : _ref16$message;
6402
- return reject({ code, message });
6403
- });
6404
- });
6405
- }
6406
- function membershipDiscountPayment(token, payload) {
6407
- return new Promise(function(resolve, reject) {
6408
- apiRequest.post(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT, payload).then(function() {
6409
- return resolve();
6410
- }).catch(function(_ref17) {
6411
- var _ref17$code = _ref17.code, code = _ref17$code === void 0 ? -100 : _ref17$code, _ref17$message = _ref17.message, message = _ref17$message === void 0 ? "Unknown error" : _ref17$message;
6412
- return reject({ code, message });
6413
- });
6414
- });
6415
- }
6416
- function membershipDiscountPaymentDelete(token) {
6417
- return new Promise(function(resolve, reject) {
6418
- apiRequest.deleteMethod(PURCHASE + "/" + token + "/" + PAYMENT_DISCOUNT).then(function() {
6419
- return resolve();
6420
- }).catch(function(_ref18) {
6421
- var _ref18$code = _ref18.code, code = _ref18$code === void 0 ? -100 : _ref18$code, _ref18$message = _ref18.message, message = _ref18$message === void 0 ? "Unknown error" : _ref18$message;
6422
- return reject({ code, message });
6423
- });
6424
- });
6425
- }
6426
- function downloadTickets(payload) {
6427
- return new Promise(function(resolve, reject) {
6428
- apiRequest.post("tickets/pdf", payload).then(function(ticketResponse) {
6429
- return resolve(ticketResponse);
6430
- }).catch(function(_ref19) {
6431
- var _ref19$code = _ref19.code, code = _ref19$code === void 0 ? -100 : _ref19$code, _ref19$message = _ref19.message, message = _ref19$message === void 0 ? "Unknown error" : _ref19$message;
6432
- return reject({ code, message });
6433
- });
6434
- });
6435
- }
6436
- function downloadPurchasesHistory(payload) {
6437
- return new Promise(function(resolve, reject) {
6438
- apiRequest.post(PURCHASES_HISTORY, payload).then(function(history) {
6439
- return resolve(history);
6440
- }).catch(function(_ref20) {
6441
- var _ref20$code = _ref20.code, code = _ref20$code === void 0 ? -100 : _ref20$code, _ref20$message = _ref20.message, message = _ref20$message === void 0 ? "Unknown error" : _ref20$message;
6442
- return reject({ code, message });
6443
- });
6444
- });
6445
- }
6446
- function increaseExpiration(token) {
6447
- return new Promise(function(resolve, reject) {
6448
- apiRequest.post(PURCHASE + "/" + token + "/" + EXTEND_EXPIRE_AT).then(function(response) {
6449
- return resolve(response);
6450
- }).catch(function(_ref21) {
6451
- var _ref21$code = _ref21.code, code = _ref21$code === void 0 ? -100 : _ref21$code, _ref21$message = _ref21.message, message = _ref21$message === void 0 ? "Unknown error" : _ref21$message;
6452
- return reject({ code, message });
6453
- });
6454
- });
6455
- }
6456
- exports2.startTicketsPoll = _tickets.startTicketsPoll;
6457
- },
6458
- /* 15 */
6459
- /***/
6460
- function(module2, exports2, __webpack_require__) {
6461
- Object.defineProperty(exports2, "__esModule", {
6462
- value: true
6463
- });
6464
- var _extends = Object.assign || function(target) {
6465
- for (var i = 1; i < arguments.length; i++) {
6466
- var source = arguments[i];
6467
- for (var key in source) {
6468
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6469
- target[key] = source[key];
6470
- }
6471
- }
6472
- }
6473
- return target;
6474
- };
6475
- exports2.startPaymentPoll = startPaymentPoll;
6476
- var _apiRequest = __webpack_require__(0);
6477
- var apiRequest = _interopRequireWildcard(_apiRequest);
6478
- function _interopRequireWildcard(obj) {
6479
- if (obj && obj.__esModule) {
6480
- return obj;
6481
- } else {
6482
- var newObj = {};
6483
- if (obj != null) {
6484
- for (var key in obj) {
6485
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6486
- }
6487
- }
6488
- newObj.default = obj;
6489
- return newObj;
6490
- }
6491
- }
6492
- var paymentFailed = function paymentFailed2(_ref) {
6493
- var payload = _ref.payload;
6494
- return ["suspicious", "failed", "rejected"].includes(payload.status);
6495
- };
6496
- function checkPaymentPayload(onReceivePayment) {
6497
- return function(pollResponse) {
6498
- var _pollResponse$payload = pollResponse.payload, using3dsecure = _pollResponse$payload.using_3d_secure, needsVerification = _pollResponse$payload.needs_verification;
6499
- if (onReceivePayment) {
6500
- onReceivePayment(pollResponse);
6501
- }
6502
- return paymentFailed(pollResponse) || using3dsecure || needsVerification;
6503
- };
6504
- }
6505
- function startPaymentPoll(token, payload, polling) {
6506
- var id = payload.id;
6507
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceivePayment = polling.onReceivePayment;
6508
- var endpoint = "purchases/" + token + "/payments/" + id;
6509
- var pollOptions = _extends({
6510
- watch: "purchase_state",
6511
- expect: ["completed", "pending"]
6512
- }, polling.options || {});
6513
- var poll = void 0;
6514
- var startedPoll = void 0;
6515
- if (init2) {
6516
- poll = apiRequest.poll(endpoint, checkPaymentPayload(onReceivePayment), pollOptions);
6517
- startedPoll = poll.start();
6518
- }
6519
- return {
6520
- payload,
6521
- polls: {
6522
- payment: startedPoll,
6523
- abort: function abort() {
6524
- return poll.abort();
6525
- }
6526
- }
6527
- };
6528
- }
6529
- },
6530
- /* 16 */
6531
- /***/
6532
- function(module2, exports2, __webpack_require__) {
6533
- Object.defineProperty(exports2, "__esModule", {
6534
- value: true
6535
- });
6536
- var _extends = Object.assign || function(target) {
6537
- for (var i = 1; i < arguments.length; i++) {
6538
- var source = arguments[i];
6539
- for (var key in source) {
6540
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6541
- target[key] = source[key];
6542
- }
6543
- }
6544
- }
6545
- return target;
6546
- };
6547
- exports2.startTicketsPoll = startTicketsPoll;
6548
- var _apiRequest = __webpack_require__(0);
6549
- var apiRequest = _interopRequireWildcard(_apiRequest);
6550
- function _interopRequireWildcard(obj) {
6551
- if (obj && obj.__esModule) {
6552
- return obj;
6553
- } else {
6554
- var newObj = {};
6555
- if (obj != null) {
6556
- for (var key in obj) {
6557
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6558
- }
6559
- }
6560
- newObj.default = obj;
6561
- return newObj;
6562
- }
6563
- }
6564
- function startTicketsPoll(token, payload, polling) {
6565
- var id = payload.id;
6566
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onReceiveTickets = polling.onReceiveTickets;
6567
- var endpoint = "purchases/" + token + "/ticket_requests/" + id;
6568
- var pollOptions = _extends({
6569
- watch: "state",
6570
- expect: "finished"
6571
- }, polling.options || {});
6572
- var poll = void 0;
6573
- var startedPoll = void 0;
6574
- if (init2) {
6575
- poll = apiRequest.poll(endpoint, onReceiveTickets, pollOptions);
6576
- startedPoll = poll.start();
6577
- }
6578
- return {
6579
- payload,
6580
- polls: {
6581
- tickets: startedPoll,
6582
- abort: function abort() {
6583
- return poll.abort();
6584
- }
6585
- }
6586
- };
6587
- }
6588
- },
6589
- /* 17 */
6590
- /***/
6591
- function(module2, exports2, __webpack_require__) {
6592
- Object.defineProperty(exports2, "__esModule", {
6593
- value: true
6594
- });
6595
- var _seatFinder = __webpack_require__(18);
6596
- Object.defineProperty(exports2, "findSeats", {
6597
- enumerable: true,
6598
- get: function get() {
6599
- return _seatFinder.findSeats;
6600
- }
6601
- });
6602
- },
6603
- /* 18 */
6604
- /***/
6605
- function(module2, exports2, __webpack_require__) {
6606
- Object.defineProperty(exports2, "__esModule", {
6607
- value: true
6608
- });
6609
- var _slicedToArray = /* @__PURE__ */ function() {
6610
- function sliceIterator(arr, i) {
6611
- var _arr = [];
6612
- var _n = true;
6613
- var _d = false;
6614
- var _e = void 0;
6615
- try {
6616
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
6617
- _arr.push(_s.value);
6618
- if (i && _arr.length === i) break;
6619
- }
6620
- } catch (err) {
6621
- _d = true;
6622
- _e = err;
6623
- } finally {
6624
- try {
6625
- if (!_n && _i["return"]) _i["return"]();
6626
- } finally {
6627
- if (_d) throw _e;
6628
- }
6629
- }
6630
- return _arr;
6631
- }
6632
- return function(arr, i) {
6633
- if (Array.isArray(arr)) {
6634
- return arr;
6635
- } else if (Symbol.iterator in Object(arr)) {
6636
- return sliceIterator(arr, i);
6637
- } else {
6638
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
6639
- }
6640
- };
6641
- }();
6642
- exports2.findSeats = findSeats;
6643
- function hasAvailableSeats(rowSeats) {
6644
- var count = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
6645
- var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6646
- var availableSeats = rowSeats.filter(function(seat) {
6647
- return !(seat.occupied || except.includes(seat.number));
6648
- });
6649
- return availableSeats.length >= count;
6650
- }
6651
- function findAvailableSeats(n, deck) {
6652
- var selectedSeats = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6653
- var pending = arguments[3];
6654
- var rowCount = deck.length;
6655
- var selectedCount = selectedSeats.length;
6656
- var newDeck = deck;
6657
- var newSeats = void 0;
6658
- if (typeof pending === "undefined") {
6659
- pending = n - selectedCount;
6660
- }
6661
- if (!pending) {
6662
- return selectedSeats;
6663
- }
6664
- for (var i = 0; i < rowCount; i++) {
6665
- var rowSeats = deck[i].filter(function(busSpace) {
6666
- return ["seat", "seat_tv"].includes(busSpace.category);
6667
- });
6668
- newSeats = findAvailableAdjecentSeats(pending, rowSeats, selectedSeats);
6669
- if (newSeats.length === pending) {
6670
- newDeck = deck.slice(i);
6671
- newDeck = newDeck.concat(deck.slice(0, i));
6672
- selectedSeats = selectedSeats.concat(newSeats);
6673
- selectedCount = selectedSeats.length;
6674
- break;
6675
- }
6676
- }
6677
- if (!newSeats.length) {
6678
- pending -= 1;
6679
- } else {
6680
- pending = n - selectedCount;
6681
- }
6682
- return findAvailableSeats(n, newDeck, selectedSeats, pending);
6683
- }
6684
- function findAvailableAdjecentSeats(n, rowSeats) {
6685
- var except = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
6686
- var adjecent = [];
6687
- var hasEnoughSeats = false;
6688
- if (!hasAvailableSeats(rowSeats, n, except)) {
6689
- return adjecent;
6690
- }
6691
- for (var i = rowSeats.length - 1; i >= 0; i--) {
6692
- var seat = rowSeats[i];
6693
- if (seat.occupied) {
6694
- adjecent = [];
6695
- } else {
6696
- adjecent.push(seat.number);
6697
- }
6698
- if (adjecent.length === n) {
6699
- hasEnoughSeats = true;
6700
- break;
6701
- }
6702
- }
6703
- if (hasEnoughSeats) {
6704
- return adjecent;
6705
- } else {
6706
- return [];
6707
- }
6708
- }
6709
- function findSeats(n, layout) {
6710
- var _layout = _slicedToArray(layout, 2), firstDeck = _layout[0], secondDeck = _layout[1];
6711
- var firstDeckSeats = findAvailableSeats(n, firstDeck);
6712
- var selectedSeats = [];
6713
- if (firstDeckSeats.length < n && secondDeck) {
6714
- var secondDeckSeats = findAvailableSeats(n, secondDeck);
6715
- if (secondDeckSeats.length < n) {
6716
- selectedSeats = firstDeckSeats.concat(secondDeckSeats).slice(0, n);
6717
- } else {
6718
- selectedSeats = secondDeckSeats;
6719
- }
6720
- } else {
6721
- selectedSeats = firstDeckSeats;
6722
- }
6723
- return selectedSeats.length ? selectedSeats : null;
6724
- }
6725
- },
6726
- /* 19 */
6727
- /***/
6728
- function(module2, exports2, __webpack_require__) {
6729
- Object.defineProperty(exports2, "__esModule", {
6730
- value: true
6731
- });
6732
- exports2.get = get;
6733
- var _apiRequest = __webpack_require__(0);
6734
- var apiRequest = _interopRequireWildcard(_apiRequest);
6735
- function _interopRequireWildcard(obj) {
6736
- if (obj && obj.__esModule) {
6737
- return obj;
6738
- } else {
6739
- var newObj = {};
6740
- if (obj != null) {
6741
- for (var key in obj) {
6742
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6743
- }
6744
- }
6745
- newObj.default = obj;
6746
- return newObj;
6747
- }
6748
- }
6749
- function get(queryParams) {
6750
- return new Promise(function(resolve, reject) {
6751
- apiRequest.get("redirect", { apiVersion: "v2", queryParams }).then(function(response) {
6752
- return resolve(response);
6753
- }).catch(function(_ref) {
6754
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6755
- return reject({ code, message });
6756
- });
6757
- });
6758
- }
6759
- },
6760
- /* 20 */
6761
- /***/
6762
- function(module2, exports2, __webpack_require__) {
6763
- Object.defineProperty(exports2, "__esModule", {
6764
- value: true
6765
- });
6766
- exports2.get = get;
6767
- var _apiRequest = __webpack_require__(0);
6768
- var apiRequest = _interopRequireWildcard(_apiRequest);
6769
- function _interopRequireWildcard(obj) {
6770
- if (obj && obj.__esModule) {
6771
- return obj;
6772
- } else {
6773
- var newObj = {};
6774
- if (obj != null) {
6775
- for (var key in obj) {
6776
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6777
- }
6778
- }
6779
- newObj.default = obj;
6780
- return newObj;
6781
- }
6782
- }
6783
- function get(queryParams) {
6784
- return new Promise(function(resolve, reject) {
6785
- apiRequest.get("quotes", { queryParams }).then(function(quotes) {
6786
- return resolve(quotes);
6787
- }).catch(function(_ref) {
6788
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6789
- return reject({ code, message });
6790
- });
6791
- });
6792
- }
6793
- },
6794
- /* 21 */
6795
- /***/
6796
- function(module2, exports2, __webpack_require__) {
6797
- Object.defineProperty(exports2, "__esModule", {
6798
- value: true
6799
- });
6800
- exports2.getUser = getUser;
6801
- exports2.getCreditCards = getCreditCards;
6802
- var _apiRequest = __webpack_require__(0);
6803
- var apiRequest = _interopRequireWildcard(_apiRequest);
6804
- var _config = __webpack_require__(1);
6805
- var _config2 = _interopRequireDefault(_config);
6806
- function _interopRequireDefault(obj) {
6807
- return obj && obj.__esModule ? obj : { default: obj };
6808
- }
6809
- function _interopRequireWildcard(obj) {
6810
- if (obj && obj.__esModule) {
6811
- return obj;
6812
- } else {
6813
- var newObj = {};
6814
- if (obj != null) {
6815
- for (var key in obj) {
6816
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6817
- }
6818
- }
6819
- newObj.default = obj;
6820
- return newObj;
6821
- }
6822
- }
6823
- var USERS = "users";
6824
- var USERS_PROFILE = USERS + "/profile.json";
6825
- var USERS_CREDIT_CARDS = USERS + "/list_cards.json";
6826
- function getUser() {
6827
- if (!_config2.default.userAuthToken) return null;
6828
- return apiRequest.get(USERS_PROFILE);
6829
- }
6830
- function getCreditCards() {
6831
- if (!_config2.default.userAuthToken) return null;
6832
- return apiRequest.get(USERS_CREDIT_CARDS);
6833
- }
6834
- },
6835
- /* 22 */
6836
- /***/
6837
- function(module2, exports2, __webpack_require__) {
6838
- Object.defineProperty(exports2, "__esModule", {
6839
- value: true
6840
- });
6841
- exports2.createPriceAlert = createPriceAlert;
6842
- exports2.deletePriceAlert = deletePriceAlert;
6843
- var _apiRequest = __webpack_require__(0);
6844
- var apiRequest = _interopRequireWildcard(_apiRequest);
6845
- function _interopRequireWildcard(obj) {
6846
- if (obj && obj.__esModule) {
6847
- return obj;
6848
- } else {
6849
- var newObj = {};
6850
- if (obj != null) {
6851
- for (var key in obj) {
6852
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6853
- }
6854
- }
6855
- newObj.default = obj;
6856
- return newObj;
6857
- }
6858
- }
6859
- var PRICE_ALERTS = "price_alerts";
6860
- var CANCEL = "cancel.json";
6861
- function createPriceAlert(alertData) {
6862
- return apiRequest.post(PRICE_ALERTS + ".json", alertData);
6863
- }
6864
- function deletePriceAlert(id) {
6865
- return apiRequest.get(PRICE_ALERTS + "/" + id + "/" + CANCEL);
6866
- }
6867
- },
6868
- /* 23 */
6869
- /***/
6870
- function(module2, exports2, __webpack_require__) {
6871
- Object.defineProperty(exports2, "__esModule", {
6872
- value: true
6873
- });
6874
- var _extends = Object.assign || function(target) {
6875
- for (var i = 1; i < arguments.length; i++) {
6876
- var source = arguments[i];
6877
- for (var key in source) {
6878
- if (Object.prototype.hasOwnProperty.call(source, key)) {
6879
- target[key] = source[key];
6880
- }
6881
- }
6882
- }
6883
- return target;
6884
- };
6885
- exports2.validate = validate;
6886
- exports2.cancelTicket = cancelTicket;
6887
- exports2.getCancelledTicketStatusPoll = getCancelledTicketStatusPoll;
6888
- var _apiRequest = __webpack_require__(0);
6889
- var apiRequest = _interopRequireWildcard(_apiRequest);
6890
- function _interopRequireWildcard(obj) {
6891
- if (obj && obj.__esModule) {
6892
- return obj;
6893
- } else {
6894
- var newObj = {};
6895
- if (obj != null) {
6896
- for (var key in obj) {
6897
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6898
- }
6899
- }
6900
- newObj.default = obj;
6901
- return newObj;
6902
- }
6903
- }
6904
- var EXCHANGE = "exchanges";
6905
- function validate(operationNumber, nit, origin2, destination, recaptchaToken, email, document2) {
6906
- var payload = _extends({}, email && { email }, document2 && { document: document2 }, {
6907
- operation_number: operationNumber
6908
- }, nit && { nit }, origin2 && { origin: origin2 }, destination && { destination }, recaptchaToken && { recaptcha_token: recaptchaToken });
6909
- return new Promise(function(resolve, reject) {
6910
- apiRequest.post(EXCHANGE + "/validate", payload).then(function(validation) {
6911
- return resolve(validation);
6912
- }).catch(function(_ref) {
6913
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6914
- return reject({ code, message });
6915
- });
6916
- });
6917
- }
6918
- function cancelTicket(token, operationNumberArray) {
6919
- var payload = {
6920
- operation_number: operationNumberArray
6921
- };
6922
- return new Promise(function(resolve, reject) {
6923
- apiRequest.post("purchases/" + token + "/cancellations", payload).then(function(response) {
6924
- return resolve(response);
6925
- }).catch(function(_ref2) {
6926
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6927
- return reject({ code, message });
6928
- });
6929
- });
6930
- }
6931
- function getCancelledTicketStatusPoll(token, idCancellation, polling) {
6932
- var id = idCancellation;
6933
- var _polling$init = polling.init, init2 = _polling$init === void 0 ? true : _polling$init, onGetCancelStatus = polling.onGetCancelStatus;
6934
- var endpoint = "purchases/" + token + "/cancellations/" + id;
6935
- var pollOptions = _extends({
6936
- watch: "status",
6937
- expect: "success"
6938
- }, polling.options || {});
6939
- var poll = void 0;
6940
- var startedPoll = void 0;
6941
- if (init2) {
6942
- poll = apiRequest.poll(endpoint, onGetCancelStatus, pollOptions);
6943
- startedPoll = poll.start();
6944
- }
6945
- return {
6946
- payload: idCancellation,
6947
- polls: {
6948
- data: startedPoll,
6949
- abort: function abort() {
6950
- return poll.abort();
6951
- }
6952
- }
6953
- };
6954
- }
6955
- },
6956
- /* 24 */
6957
- /***/
6958
- function(module2, exports2, __webpack_require__) {
6959
- Object.defineProperty(exports2, "__esModule", {
6960
- value: true
6961
- });
6962
- exports2.paymentCards = paymentCards;
6963
- exports2.deleteCard = deleteCard;
6964
- var _apiRequest = __webpack_require__(0);
6965
- var apiRequest = _interopRequireWildcard(_apiRequest);
6966
- function _interopRequireWildcard(obj) {
6967
- if (obj && obj.__esModule) {
6968
- return obj;
6969
- } else {
6970
- var newObj = {};
6971
- if (obj != null) {
6972
- for (var key in obj) {
6973
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
6974
- }
6975
- }
6976
- newObj.default = obj;
6977
- return newObj;
6978
- }
6979
- }
6980
- function paymentCards(params) {
6981
- return new Promise(function(resolve, reject) {
6982
- apiRequest.post("adyen/payment_cards", params).then(function(creditCards) {
6983
- return resolve(creditCards);
6984
- }).catch(function(_ref) {
6985
- var _ref$code = _ref.code, code = _ref$code === void 0 ? -100 : _ref$code, _ref$message = _ref.message, message = _ref$message === void 0 ? "Unknown error" : _ref$message;
6986
- return reject({ code, message });
6987
- });
6988
- });
6989
- }
6990
- function deleteCard(params) {
6991
- return new Promise(function(resolve, reject) {
6992
- apiRequest.post("adyen/delete_payment_card", params).then(function(response) {
6993
- return resolve(response);
6994
- }).catch(function(_ref2) {
6995
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
6996
- return reject({ code, message });
6997
- });
6998
- });
6999
- }
7000
- },
7001
- /* 25 */
7002
- /***/
7003
- function(module2, exports2, __webpack_require__) {
7004
- Object.defineProperty(exports2, "__esModule", {
7005
- value: true
7006
- });
7007
- exports2.getRecommendedTrips = getRecommendedTrips;
7008
- exports2.createTripPriceAlerts = createTripPriceAlerts;
7009
- exports2.updateTripPriceAlerts = updateTripPriceAlerts;
7010
- exports2.deleteTripPriceAlerts = deleteTripPriceAlerts;
7011
- exports2.createAnonymousProfile = createAnonymousProfile2;
7012
- var _apiRequest = __webpack_require__(0);
7013
- var apiRequest = _interopRequireWildcard(_apiRequest);
7014
- function _interopRequireWildcard(obj) {
7015
- if (obj && obj.__esModule) {
7016
- return obj;
7017
- } else {
7018
- var newObj = {};
7019
- if (obj != null) {
7020
- for (var key in obj) {
7021
- if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
7022
- }
7023
- }
7024
- newObj.default = obj;
7025
- return newObj;
7026
- }
7027
- }
7028
- var TRIP_PRICE_ALERTS = "trip_price_alerts";
7029
- var ANONYMOUS_PROFILE = "anonymous_profiles/identify";
7030
- function getRecommendedTrips(_ref) {
7031
- var searchId = _ref.searchId, userIdentifier = _ref.userIdentifier;
7032
- return new Promise(function(resolve, reject) {
7033
- apiRequest.get("trip_recommendations/" + searchId + "/" + userIdentifier, { apiType: "core" }).then(function(response) {
7034
- return resolve(response);
7035
- }).catch(function(_ref2) {
7036
- var _ref2$code = _ref2.code, code = _ref2$code === void 0 ? -100 : _ref2$code, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? "Unknown error" : _ref2$message;
7037
- return reject({ code, message });
7038
- });
7039
- });
7040
- }
7041
- function createTripPriceAlerts(payload) {
7042
- return new Promise(function(resolve, reject) {
7043
- apiRequest.post("" + TRIP_PRICE_ALERTS, payload).then(function(response) {
7044
- return resolve(response);
7045
- }).catch(function(_ref3) {
7046
- var _ref3$code = _ref3.code, code = _ref3$code === void 0 ? -100 : _ref3$code, _ref3$message = _ref3.message, message = _ref3$message === void 0 ? "Unknow error" : _ref3$message;
7047
- return reject({ code, message });
7048
- });
7049
- });
7050
- }
7051
- function updateTripPriceAlerts(priceAlertId, payload) {
7052
- return new Promise(function(resolve, reject) {
7053
- apiRequest.put(TRIP_PRICE_ALERTS + "/" + priceAlertId, payload).then(function(response) {
7054
- return resolve(response);
7055
- }).catch(function(_ref4) {
7056
- var _ref4$code = _ref4.code, code = _ref4$code === void 0 ? -100 : _ref4$code, _ref4$message = _ref4.message, message = _ref4$message === void 0 ? "Unknow error" : _ref4$message;
7057
- return reject({ code, message });
7058
- });
7059
- });
7060
- }
7061
- function deleteTripPriceAlerts(priceAlertId) {
7062
- return new Promise(function(resolve, reject) {
7063
- apiRequest.deleteMethod(TRIP_PRICE_ALERTS + "/" + priceAlertId).then(function() {
7064
- return resolve({ code: 200, message: "Trip Price Alert deleted" });
7065
- }).catch(function(_ref5) {
7066
- var _ref5$code = _ref5.code, code = _ref5$code === void 0 ? -100 : _ref5$code, _ref5$message = _ref5.message, message = _ref5$message === void 0 ? "Unknow error" : _ref5$message;
7067
- return reject({ code, message });
7068
- });
7069
- });
7070
- }
7071
- function createAnonymousProfile2(payload) {
7072
- return new Promise(function(resolve, reject) {
7073
- apiRequest.post(ANONYMOUS_PROFILE, payload, { apiType: "core" }).then(function(response) {
7074
- return resolve(response);
7075
- }).catch(function(_ref6) {
7076
- var _ref6$code = _ref6.code, code = _ref6$code === void 0 ? -100 : _ref6$code, _ref6$message = _ref6.message, message = _ref6$message === void 0 ? "Unknow error" : _ref6$message;
7077
- return reject({ code, message });
7078
- });
7079
- });
7080
- }
7081
- }
7082
- /******/
7083
- ])
7084
- );
4622
+ const r$2 = {
4623
+ sandbox: {
4624
+ search: "https://search.resertravel.com/api",
4625
+ purchase: "https://purchases.resertravel.com/api",
4626
+ core: ""
4627
+ },
4628
+ production: {
4629
+ search: "https://search.reservamos.mx/api",
4630
+ purchase: "https://compras.reservamos.mx/api",
4631
+ core: ""
4632
+ }
4633
+ }, s$3 = "sandbox", a$2 = "v2", t$3 = "v1", n$2 = {
4634
+ env: s$3,
4635
+ headers: {},
4636
+ searchUrl: r$2[s$3].search,
4637
+ purchaseUrl: r$2[s$3].purchase,
4638
+ coreUrl: r$2[s$3].core,
4639
+ version: a$2,
4640
+ coreVersion: t$3,
4641
+ apiKey: void 0,
4642
+ userAuthToken: void 0,
4643
+ withCredentials: false
4644
+ };
4645
+ let c$2 = Object.assign({}, n$2);
4646
+ const o = {
4647
+ // UNAUTHORIZED
4648
+ 1: {
4649
+ code: 200,
4650
+ message: "Operación no autorizada"
4651
+ }
4652
+ }, s$2 = {
4653
+ // INCORRECT_PARAMS
4654
+ 3: {
4655
+ code: 300,
4656
+ message: "Parámetros incorrectos"
4657
+ },
4658
+ // INCORRECT_DATE
4659
+ 7: {
4660
+ code: 301,
4661
+ message: "Fecha inválida"
4662
+ }
4663
+ }, r$1 = {
4664
+ // NONEXISTENT_TRIP
4665
+ 10: {
4666
+ code: 400,
4667
+ message: "No existe el viaje"
4668
+ },
4669
+ // journey_key_not_found
4670
+ 20: {
4671
+ code: 60,
4672
+ message: "No se encontró el viaje"
4673
+ },
4674
+ // sold_out_fare_code
4675
+ 21: {
4676
+ code: 60,
4677
+ message: "Tarifa no disponible"
4678
+ },
4679
+ // unavailable_fare_code
4680
+ 22: {
4681
+ code: 60,
4682
+ message: "Tarifa no disponible"
4683
+ }
4684
+ }, n$1 = (e) => ({
4685
+ // INVALID_DISCOUNT
4686
+ 11: {
4687
+ code: 500,
4688
+ message: e
4689
+ },
4690
+ //EXPIRED_DISCOUNT
4691
+ 12: {
4692
+ code: 501,
4693
+ message: e
4694
+ }
4695
+ }), a$1 = {
4696
+ // unavailable_student
4697
+ 23: {
4698
+ code: 60,
4699
+ message: "Estudiante no disponible"
4700
+ },
4701
+ // unavailable_teacher
4702
+ 24: {
4703
+ code: 60,
4704
+ message: "Profesor no disponible"
4705
+ },
4706
+ // unavailable_minor
4707
+ 25: {
4708
+ code: 60,
4709
+ message: "Menor no disponible"
4710
+ },
4711
+ // unavailable_special
4712
+ 26: {
4713
+ code: 60,
4714
+ message: "Capacidades diferentes no disponible"
4715
+ },
4716
+ // unavailable_older
4717
+ 27: {
4718
+ code: 60,
4719
+ message: "INSEN no disponible"
4720
+ },
4721
+ // unavailable_general
4722
+ 28: {
4723
+ code: 60,
4724
+ message: "General no disponible"
4725
+ },
4726
+ // unavailable_unknown
4727
+ 29: {
4728
+ code: 60,
4729
+ message: "Error desconocido"
4730
+ }
4731
+ }, c$1 = (e) => ({
4732
+ 30: {
4733
+ code: 30,
4734
+ message: e
4735
+ }
4736
+ }), d$1 = {
4737
+ 50: {
4738
+ code: 50,
4739
+ message: "Unknow Error"
4740
+ }
4741
+ }, i$2 = (e) => ({
4742
+ ...o,
4743
+ ...s$2,
4744
+ ...r$1,
4745
+ ...n$1(e),
4746
+ ...a$1,
4747
+ ...d$1,
4748
+ ...c$1(e)
4749
+ });
4750
+ let t$2 = class t extends Error {
4751
+ constructor(r2 = -100, o2 = "Unknown error") {
4752
+ super(o2), this.code = r2, this.stack = new Error().stack;
4753
+ }
4754
+ };
4755
+ function l$1(e) {
4756
+ const t3 = [404, 422, 500], r2 = e.json();
4757
+ if (e.ok)
4758
+ return r2;
4759
+ if (t3.includes(e.status))
4760
+ switch (e.status) {
4761
+ case 404:
4762
+ throw new t$2(100, "Not found");
4763
+ case 422:
4764
+ return r2;
4765
+ case 500:
4766
+ throw new t$2(101, "Server error");
4767
+ default:
4768
+ throw new t$2();
4769
+ }
4770
+ else
4771
+ throw new t$2(e.status, e.statusText);
4772
+ }
4773
+ function w(e) {
4774
+ if (e.errors instanceof Array) {
4775
+ const { code: t3 = -100, message: r2 = "Unknown error" } = e.errors[0] || {}, n2 = i$2(r2)[t3];
4776
+ throw n2 ? new t$2(n2.code, n2.message) : new t$2(t3, r2);
4777
+ } else
4778
+ return e;
4779
+ }
4780
+ function y(...e) {
4781
+ const r2 = Object.keys(Object.assign({}, ...e)).reduce(
4782
+ (n2, o2) => ({
4783
+ ...n2,
4784
+ [o2]: e.map((a2) => o2 in a2 && a2[o2]).filter(Boolean)
4785
+ }),
4786
+ {}
4787
+ );
4788
+ return new Headers(r2);
4789
+ }
4790
+ function c(e, t3 = {}, r2 = {}, n2) {
4791
+ const {
4792
+ apiKey: o2,
4793
+ withCredentials: a2,
4794
+ userAuthToken: s2,
4795
+ headers: d2
4796
+ } = c$2, u2 = {
4797
+ Accept: "application/json",
4798
+ Authorization: `Token token=${r2.apiKey || o2}`,
4799
+ "Content-Type": "application/json"
4800
+ };
4801
+ return s2 && (u2.Authorization = `Token ${r2.apiKey || o2}, Bearer ${s2}`), t3.headers = y(d2, u2), t3.credentials = a2 ? "include" : "omit", typeof t3.body != "string" && (t3.body = JSON.stringify(t3.body)), fetch(e, t3).then(l$1).then(w).catch(n2);
4802
+ }
4803
+ function E(e, t3 = {}, r2) {
4804
+ return c(e, t3, {}, r2);
4805
+ }
4806
+ class u {
4807
+ constructor({
4808
+ url: e,
4809
+ watch: i,
4810
+ expect: h2,
4811
+ maxRetries: t3 = 30,
4812
+ interval: s2 = 2e3,
4813
+ eachCall: c2 = null
4814
+ }) {
4815
+ this.url = e, this.watch = i, this.expect = h2 instanceof Array ? h2 : [h2], this.interval = s2, this.maxRetries = t3, this.eachCall = c2 && c2.bind(this), this.aborted = false, this.timers = [], this.execute = this.execute.bind(this), this.executeEachCall = this.executeEachCall.bind(this);
4816
+ }
4817
+ start() {
4818
+ return this.execute(this.maxRetries);
4819
+ }
4820
+ abort() {
4821
+ this.aborted = true;
4822
+ }
4823
+ execute(e) {
4824
+ const i = (t3) => {
4825
+ if (this.expect.includes(t3[this.watch]) || e === 1 || this.aborted) {
4826
+ let s2 = t3[this.watch];
4827
+ e === 1 ? s2 = "retries_exceeded" : this.aborted && (s2 = "aborted"), this.timers.forEach(clearInterval), this.executeEachCall(s2, t3);
4828
+ } else if (t3[this.watch] === "failed")
4829
+ this.timers.forEach(clearInterval), this.executeEachCall("failed", t3);
4830
+ else {
4831
+ this.executeEachCall("pending", t3);
4832
+ const s2 = window.setTimeout(
4833
+ this.execute,
4834
+ this.interval,
4835
+ e - 1
4836
+ );
4837
+ this.timers.push(s2);
4838
+ }
4839
+ }, h2 = (t3) => this.executeEachCall("error", t3);
4840
+ return E(this.url, {}, h2).then(i);
4841
+ }
4842
+ executeEachCall(e, i) {
4843
+ this.eachCall instanceof Function && this.eachCall({ status: e, payload: i }) && this.abort();
4844
+ }
4845
+ }
4846
+ function C({
4847
+ apiName: d2,
4848
+ defaultApiVersion: r2
4849
+ }) {
4850
+ let o2, a2 = {
4851
+ "Content-Type": "application/json"
4852
+ }, c2;
4853
+ function f2(e) {
4854
+ o2 = e.baseUrl, a2 = {
4855
+ ...a2,
4856
+ ...e.defaultHeaders || {}
4857
+ };
4858
+ }
4859
+ function p2(e) {
4860
+ c2 = e;
4861
+ }
4862
+ function u$12() {
4863
+ if (!o2)
4864
+ throw new Error(`Base URL is not set for ${d2} API.`);
4865
+ }
4866
+ const h2 = { body: {} };
4867
+ async function $(e, t3 = h2) {
4868
+ u$12();
4869
+ const { body: s2, headers: n2 = {}, apiVersion: i = r2 } = t3, l2 = `${o2}/${i}/${e}`, b2 = {
4870
+ ...a2,
4871
+ ...n2,
4872
+ ...c2 ? { Authorization: c2 } : {}
4873
+ };
4874
+ return (await fetch(l2, {
4875
+ method: "POST",
4876
+ body: JSON.stringify(s2),
4877
+ headers: b2
4878
+ })).json();
4879
+ }
4880
+ async function y2(e, t3 = {}) {
4881
+ u$12();
4882
+ const { headers: s2 = {}, apiVersion: n2 = r2 } = t3, i = `${o2}/${n2}/${e}`;
4883
+ return (await fetch(i, { headers: s2 })).json();
4884
+ }
4885
+ function w2(e, t3) {
4886
+ const n2 = {
4887
+ url: `${o2}/${r2}/${e}`,
4888
+ watch: t3.watch,
4889
+ expect: t3.expect,
4890
+ eachCall: t3.onEachResponse
4891
+ };
4892
+ return new u(n2);
4893
+ }
4894
+ return {
4895
+ get: y2,
4896
+ post: $,
4897
+ setAuthorizationHeader: p2,
4898
+ setConfig: f2,
4899
+ poll: w2
4900
+ };
4901
+ }
4902
+ const t$1 = C({
4903
+ apiName: "Core",
4904
+ defaultApiVersion: "v1"
4905
+ });
4906
+ async function r(e) {
4907
+ return t$1.get(
4908
+ `passengers/${e}`
4909
+ );
4910
+ }
4911
+ async function n(e) {
4912
+ return t$1.post("passengers", {
4913
+ body: e
4914
+ });
4915
+ }
4916
+ const a = {
4917
+ getFrequentPassengers: r,
4918
+ createFrequentPassengers: n
4919
+ };
4920
+ async function t2(o2) {
4921
+ const { data: e } = await t$1.post(
4922
+ "anonymous_profiles/identify",
4923
+ {
4924
+ body: o2
4925
+ }
4926
+ );
4927
+ return e;
4928
+ }
4929
+ const s$1 = {
4930
+ createAnonymousProfile: t2
4931
+ };
4932
+ function d({
4933
+ searchId: e,
4934
+ userIdentifier: t3
4935
+ }) {
4936
+ return t$1.get(
4937
+ `trip_recommendations/${e}/${t3}`
4938
+ );
4939
+ }
4940
+ function i$1(e) {
4941
+ return t$1.post("seat_recommendations", {
4942
+ body: e
4943
+ });
4944
+ }
4945
+ function m({
4946
+ distinct_id: e,
4947
+ ...t3
4948
+ }) {
4949
+ return t$1.post(`seat_recommendations/${e}`, {
4950
+ body: t3
4951
+ });
4952
+ }
4953
+ function p(e, t3) {
4954
+ const { start: s2, onEachResponse: c2 } = t3, r2 = `profiles/${e}`, a2 = {
4955
+ watch: "state",
4956
+ expect: "finished",
4957
+ onEachResponse: c2
4958
+ }, n2 = t$1.poll(r2, a2);
4959
+ return s2 && n2.start(), n2;
4960
+ }
4961
+ async function l(e) {
4962
+ return t$1.post("profiles", {
4963
+ body: e
7085
4964
  });
7086
- })(jsApiClient);
7087
- var jsApiClientExports = jsApiClient.exports;
4965
+ }
4966
+ const f = {
4967
+ getRecommendedTrips: d,
4968
+ createRecommendedPlaces: l,
4969
+ pollRecommendedPlaces: p,
4970
+ createRecommendedSeats: i$1,
4971
+ getRecommendedSeats: m
4972
+ };
4973
+ const s = {
4974
+ setConfig: t$1.setConfig,
4975
+ recommendations: f,
4976
+ profiles: s$1,
4977
+ preferences: a
4978
+ };
4979
+ let environment;
7088
4980
  const origin = window.location.origin;
7089
4981
  const coreAPIConfig = {
7090
4982
  sandbox: {
7091
- coreUrl: "https://datalake-api-dev.reservamossaas.com/api",
7092
- coreVersion: "v1",
7093
- headers: {
7094
- Origin: origin
7095
- },
7096
- coreApiKey: "Bearer 753bf0710dc920a84236d42241d4f487"
4983
+ baseUrl: "https://datalake-api-dev.reservamossaas.com/api",
4984
+ defaultHeaders: {
4985
+ Origin: origin,
4986
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4987
+ }
7097
4988
  },
7098
4989
  prod: {
7099
- coreUrl: "https://data-lake.reservamossaas.com/api",
7100
- coreVersion: "v1",
7101
- headers: {
7102
- Origin: origin
7103
- },
7104
- coreApiKey: "Bearer 753bf0710dc920a84236d42241d4f487"
4990
+ baseUrl: "https://data-lake.reservamossaas.com/api",
4991
+ defaultHeaders: {
4992
+ Origin: origin,
4993
+ Authorization: "Bearer 753bf0710dc920a84236d42241d4f487"
4994
+ }
7105
4995
  }
7106
4996
  };
4997
+ function setEnvironment(env) {
4998
+ environment = env;
4999
+ }
5000
+ function getCoreAPIConfig() {
5001
+ if (!environment) {
5002
+ throw new Error(
5003
+ "Unable to get core API config, environment not set. Use configService.setEnvironment(environment) to set the environment."
5004
+ );
5005
+ }
5006
+ return coreAPIConfig[environment];
5007
+ }
7107
5008
  const configService = {
7108
- coreAPIConfig
5009
+ setEnvironment,
5010
+ getCoreAPIConfig
7109
5011
  };
7110
5012
  var NodeType;
7111
5013
  (function(NodeType2) {
@@ -7116,12 +5018,12 @@ var NodeType;
7116
5018
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
7117
5019
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
7118
5020
  })(NodeType || (NodeType = {}));
7119
- function isElement(n) {
7120
- return n.nodeType === n.ELEMENT_NODE;
5021
+ function isElement(n2) {
5022
+ return n2.nodeType === n2.ELEMENT_NODE;
7121
5023
  }
7122
- function isShadowRoot(n) {
7123
- const host = n === null || n === void 0 ? void 0 : n.host;
7124
- return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
5024
+ function isShadowRoot(n2) {
5025
+ const host = n2 === null || n2 === void 0 ? void 0 : n2.host;
5026
+ return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n2);
7125
5027
  }
7126
5028
  function isNativeShadowDom(shadowRoot) {
7127
5029
  return Object.prototype.toString.call(shadowRoot) === "[object ShadowRoot]";
@@ -7185,11 +5087,11 @@ class Mirror {
7185
5087
  this.idNodeMap = /* @__PURE__ */ new Map();
7186
5088
  this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
7187
5089
  }
7188
- getId(n) {
5090
+ getId(n2) {
7189
5091
  var _a;
7190
- if (!n)
5092
+ if (!n2)
7191
5093
  return -1;
7192
- const id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
5094
+ const id = (_a = this.getMeta(n2)) === null || _a === void 0 ? void 0 : _a.id;
7193
5095
  return id !== null && id !== void 0 ? id : -1;
7194
5096
  }
7195
5097
  getNode(id) {
@@ -7198,14 +5100,14 @@ class Mirror {
7198
5100
  getIds() {
7199
5101
  return Array.from(this.idNodeMap.keys());
7200
5102
  }
7201
- getMeta(n) {
7202
- return this.nodeMetaMap.get(n) || null;
5103
+ getMeta(n2) {
5104
+ return this.nodeMetaMap.get(n2) || null;
7203
5105
  }
7204
- removeNodeFromMap(n) {
7205
- const id = this.getId(n);
5106
+ removeNodeFromMap(n2) {
5107
+ const id = this.getId(n2);
7206
5108
  this.idNodeMap.delete(id);
7207
- if (n.childNodes) {
7208
- n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
5109
+ if (n2.childNodes) {
5110
+ n2.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));
7209
5111
  }
7210
5112
  }
7211
5113
  has(id) {
@@ -7214,19 +5116,19 @@ class Mirror {
7214
5116
  hasNode(node) {
7215
5117
  return this.nodeMetaMap.has(node);
7216
5118
  }
7217
- add(n, meta) {
5119
+ add(n2, meta) {
7218
5120
  const id = meta.id;
7219
- this.idNodeMap.set(id, n);
7220
- this.nodeMetaMap.set(n, meta);
5121
+ this.idNodeMap.set(id, n2);
5122
+ this.nodeMetaMap.set(n2, meta);
7221
5123
  }
7222
- replace(id, n) {
5124
+ replace(id, n2) {
7223
5125
  const oldNode = this.getNode(id);
7224
5126
  if (oldNode) {
7225
5127
  const meta = this.nodeMetaMap.get(oldNode);
7226
5128
  if (meta)
7227
- this.nodeMetaMap.set(n, meta);
5129
+ this.nodeMetaMap.set(n2, meta);
7228
5130
  }
7229
- this.idNodeMap.set(id, n);
5131
+ this.idNodeMap.set(id, n2);
7230
5132
  }
7231
5133
  reset() {
7232
5134
  this.idNodeMap = /* @__PURE__ */ new Map();
@@ -7565,16 +5467,16 @@ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
7565
5467
  listener();
7566
5468
  });
7567
5469
  }
7568
- function serializeNode(n, options) {
5470
+ function serializeNode(n2, options) {
7569
5471
  const { doc, mirror: mirror2, blockClass, blockSelector, needsMask, inlineStylesheet, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false } = options;
7570
5472
  const rootId = getRootId(doc, mirror2);
7571
- switch (n.nodeType) {
7572
- case n.DOCUMENT_NODE:
7573
- if (n.compatMode !== "CSS1Compat") {
5473
+ switch (n2.nodeType) {
5474
+ case n2.DOCUMENT_NODE:
5475
+ if (n2.compatMode !== "CSS1Compat") {
7574
5476
  return {
7575
5477
  type: NodeType.Document,
7576
5478
  childNodes: [],
7577
- compatMode: n.compatMode
5479
+ compatMode: n2.compatMode
7578
5480
  };
7579
5481
  } else {
7580
5482
  return {
@@ -7582,16 +5484,16 @@ function serializeNode(n, options) {
7582
5484
  childNodes: []
7583
5485
  };
7584
5486
  }
7585
- case n.DOCUMENT_TYPE_NODE:
5487
+ case n2.DOCUMENT_TYPE_NODE:
7586
5488
  return {
7587
5489
  type: NodeType.DocumentType,
7588
- name: n.name,
7589
- publicId: n.publicId,
7590
- systemId: n.systemId,
5490
+ name: n2.name,
5491
+ publicId: n2.publicId,
5492
+ systemId: n2.systemId,
7591
5493
  rootId
7592
5494
  };
7593
- case n.ELEMENT_NODE:
7594
- return serializeElementNode(n, {
5495
+ case n2.ELEMENT_NODE:
5496
+ return serializeElementNode(n2, {
7595
5497
  doc,
7596
5498
  blockClass,
7597
5499
  blockSelector,
@@ -7605,22 +5507,22 @@ function serializeNode(n, options) {
7605
5507
  newlyAddedElement,
7606
5508
  rootId
7607
5509
  });
7608
- case n.TEXT_NODE:
7609
- return serializeTextNode(n, {
5510
+ case n2.TEXT_NODE:
5511
+ return serializeTextNode(n2, {
7610
5512
  needsMask,
7611
5513
  maskTextFn,
7612
5514
  rootId
7613
5515
  });
7614
- case n.CDATA_SECTION_NODE:
5516
+ case n2.CDATA_SECTION_NODE:
7615
5517
  return {
7616
5518
  type: NodeType.CDATA,
7617
5519
  textContent: "",
7618
5520
  rootId
7619
5521
  };
7620
- case n.COMMENT_NODE:
5522
+ case n2.COMMENT_NODE:
7621
5523
  return {
7622
5524
  type: NodeType.Comment,
7623
- textContent: n.textContent || "",
5525
+ textContent: n2.textContent || "",
7624
5526
  rootId
7625
5527
  };
7626
5528
  default:
@@ -7633,21 +5535,21 @@ function getRootId(doc, mirror2) {
7633
5535
  const docId = mirror2.getId(doc);
7634
5536
  return docId === 1 ? void 0 : docId;
7635
5537
  }
7636
- function serializeTextNode(n, options) {
5538
+ function serializeTextNode(n2, options) {
7637
5539
  var _a;
7638
5540
  const { needsMask, maskTextFn, rootId } = options;
7639
- const parentTagName = n.parentNode && n.parentNode.tagName;
7640
- let textContent = n.textContent;
5541
+ const parentTagName = n2.parentNode && n2.parentNode.tagName;
5542
+ let textContent = n2.textContent;
7641
5543
  const isStyle = parentTagName === "STYLE" ? true : void 0;
7642
5544
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
7643
5545
  if (isStyle && textContent) {
7644
5546
  try {
7645
- if (n.nextSibling || n.previousSibling) {
7646
- } else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
7647
- textContent = stringifyStylesheet(n.parentNode.sheet);
5547
+ if (n2.nextSibling || n2.previousSibling) {
5548
+ } else if ((_a = n2.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
5549
+ textContent = stringifyStylesheet(n2.parentNode.sheet);
7648
5550
  }
7649
5551
  } catch (err) {
7650
- console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n);
5552
+ console.warn(`Cannot get CSS styles from text's parentNode. Error: ${err}`, n2);
7651
5553
  }
7652
5554
  textContent = absoluteToStylesheet(textContent, getHref());
7653
5555
  }
@@ -7655,7 +5557,7 @@ function serializeTextNode(n, options) {
7655
5557
  textContent = "SCRIPT_PLACEHOLDER";
7656
5558
  }
7657
5559
  if (!isStyle && !isScript && textContent && needsMask) {
7658
- textContent = maskTextFn ? maskTextFn(textContent, n.parentElement) : textContent.replace(/[\S]/g, "*");
5560
+ textContent = maskTextFn ? maskTextFn(textContent, n2.parentElement) : textContent.replace(/[\S]/g, "*");
7659
5561
  }
7660
5562
  return {
7661
5563
  type: NodeType.Text,
@@ -7664,21 +5566,21 @@ function serializeTextNode(n, options) {
7664
5566
  rootId
7665
5567
  };
7666
5568
  }
7667
- function serializeElementNode(n, options) {
5569
+ function serializeElementNode(n2, options) {
7668
5570
  const { doc, blockClass, blockSelector, inlineStylesheet, maskInputOptions = {}, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, newlyAddedElement = false, rootId } = options;
7669
- const needBlock = _isBlockedElement(n, blockClass, blockSelector);
7670
- const tagName = getValidTagName(n);
5571
+ const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
5572
+ const tagName = getValidTagName(n2);
7671
5573
  let attributes = {};
7672
- const len = n.attributes.length;
5574
+ const len = n2.attributes.length;
7673
5575
  for (let i = 0; i < len; i++) {
7674
- const attr = n.attributes[i];
5576
+ const attr = n2.attributes[i];
7675
5577
  if (!ignoreAttribute(tagName, attr.name, attr.value)) {
7676
5578
  attributes[attr.name] = transformAttribute(doc, tagName, toLowerCase(attr.name), attr.value);
7677
5579
  }
7678
5580
  }
7679
5581
  if (tagName === "link" && inlineStylesheet) {
7680
5582
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
7681
- return s2.href === n.href;
5583
+ return s2.href === n2.href;
7682
5584
  });
7683
5585
  let cssText = null;
7684
5586
  if (stylesheet) {
@@ -7690,19 +5592,19 @@ function serializeElementNode(n, options) {
7690
5592
  attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
7691
5593
  }
7692
5594
  }
7693
- if (tagName === "style" && n.sheet && !(n.innerText || n.textContent || "").trim().length) {
7694
- const cssText = stringifyStylesheet(n.sheet);
5595
+ if (tagName === "style" && n2.sheet && !(n2.innerText || n2.textContent || "").trim().length) {
5596
+ const cssText = stringifyStylesheet(n2.sheet);
7695
5597
  if (cssText) {
7696
5598
  attributes._cssText = absoluteToStylesheet(cssText, getHref());
7697
5599
  }
7698
5600
  }
7699
5601
  if (tagName === "input" || tagName === "textarea" || tagName === "select") {
7700
- const value = n.value;
7701
- const checked = n.checked;
5602
+ const value = n2.value;
5603
+ const checked = n2.checked;
7702
5604
  if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
7703
5605
  attributes.value = maskInputValue({
7704
- element: n,
7705
- type: getInputType(n),
5606
+ element: n2,
5607
+ type: getInputType(n2),
7706
5608
  tagName,
7707
5609
  value,
7708
5610
  maskInputOptions,
@@ -7713,22 +5615,22 @@ function serializeElementNode(n, options) {
7713
5615
  }
7714
5616
  }
7715
5617
  if (tagName === "option") {
7716
- if (n.selected && !maskInputOptions["select"]) {
5618
+ if (n2.selected && !maskInputOptions["select"]) {
7717
5619
  attributes.selected = true;
7718
5620
  } else {
7719
5621
  delete attributes.selected;
7720
5622
  }
7721
5623
  }
7722
5624
  if (tagName === "canvas" && recordCanvas) {
7723
- if (n.__context === "2d") {
7724
- if (!is2DCanvasBlank(n)) {
7725
- attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5625
+ if (n2.__context === "2d") {
5626
+ if (!is2DCanvasBlank(n2)) {
5627
+ attributes.rr_dataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
7726
5628
  }
7727
- } else if (!("__context" in n)) {
7728
- const canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
5629
+ } else if (!("__context" in n2)) {
5630
+ const canvasDataURL = n2.toDataURL(dataURLOptions.type, dataURLOptions.quality);
7729
5631
  const blankCanvas = document.createElement("canvas");
7730
- blankCanvas.width = n.width;
7731
- blankCanvas.height = n.height;
5632
+ blankCanvas.width = n2.width;
5633
+ blankCanvas.height = n2.height;
7732
5634
  const blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
7733
5635
  if (canvasDataURL !== blankCanvasDataURL) {
7734
5636
  attributes.rr_dataURL = canvasDataURL;
@@ -7740,7 +5642,7 @@ function serializeElementNode(n, options) {
7740
5642
  canvasService = doc.createElement("canvas");
7741
5643
  canvasCtx = canvasService.getContext("2d");
7742
5644
  }
7743
- const image = n;
5645
+ const image = n2;
7744
5646
  const oldValue = image.crossOrigin;
7745
5647
  image.crossOrigin = "anonymous";
7746
5648
  const recordInlineImage = () => {
@@ -7762,23 +5664,23 @@ function serializeElementNode(n, options) {
7762
5664
  }
7763
5665
  if (tagName === "audio" || tagName === "video") {
7764
5666
  const mediaAttributes = attributes;
7765
- mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
7766
- mediaAttributes.rr_mediaCurrentTime = n.currentTime;
7767
- mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
7768
- mediaAttributes.rr_mediaMuted = n.muted;
7769
- mediaAttributes.rr_mediaLoop = n.loop;
7770
- mediaAttributes.rr_mediaVolume = n.volume;
5667
+ mediaAttributes.rr_mediaState = n2.paused ? "paused" : "played";
5668
+ mediaAttributes.rr_mediaCurrentTime = n2.currentTime;
5669
+ mediaAttributes.rr_mediaPlaybackRate = n2.playbackRate;
5670
+ mediaAttributes.rr_mediaMuted = n2.muted;
5671
+ mediaAttributes.rr_mediaLoop = n2.loop;
5672
+ mediaAttributes.rr_mediaVolume = n2.volume;
7771
5673
  }
7772
5674
  if (!newlyAddedElement) {
7773
- if (n.scrollLeft) {
7774
- attributes.rr_scrollLeft = n.scrollLeft;
5675
+ if (n2.scrollLeft) {
5676
+ attributes.rr_scrollLeft = n2.scrollLeft;
7775
5677
  }
7776
- if (n.scrollTop) {
7777
- attributes.rr_scrollTop = n.scrollTop;
5678
+ if (n2.scrollTop) {
5679
+ attributes.rr_scrollTop = n2.scrollTop;
7778
5680
  }
7779
5681
  }
7780
5682
  if (needBlock) {
7781
- const { width, height } = n.getBoundingClientRect();
5683
+ const { width, height } = n2.getBoundingClientRect();
7782
5684
  attributes = {
7783
5685
  class: attributes.class,
7784
5686
  rr_width: `${width}px`,
@@ -7786,7 +5688,7 @@ function serializeElementNode(n, options) {
7786
5688
  };
7787
5689
  }
7788
5690
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
7789
- if (!n.contentDocument) {
5691
+ if (!n2.contentDocument) {
7790
5692
  attributes.rr_src = attributes.src;
7791
5693
  }
7792
5694
  delete attributes.src;
@@ -7802,7 +5704,7 @@ function serializeElementNode(n, options) {
7802
5704
  tagName,
7803
5705
  attributes,
7804
5706
  childNodes: [],
7805
- isSVG: isSVGElement(n) || void 0,
5707
+ isSVG: isSVGElement(n2) || void 0,
7806
5708
  needBlock,
7807
5709
  rootId,
7808
5710
  isCustom: isCustomElement
@@ -7841,15 +5743,15 @@ function slimDOMExcluded(sn, slimDOMOptions) {
7841
5743
  }
7842
5744
  return false;
7843
5745
  }
7844
- function serializeNodeWithId(n, options) {
5746
+ function serializeNodeWithId(n2, options) {
7845
5747
  const { doc, mirror: mirror2, blockClass, blockSelector, maskTextClass, maskTextSelector, skipChild = false, inlineStylesheet = true, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5e3, onStylesheetLoad, stylesheetLoadTimeout = 5e3, keepIframeSrcFn = () => false, newlyAddedElement = false } = options;
7846
5748
  let { needsMask } = options;
7847
5749
  let { preserveWhiteSpace = true } = options;
7848
- if (!needsMask && n.childNodes) {
5750
+ if (!needsMask && n2.childNodes) {
7849
5751
  const checkAncestors = needsMask === void 0;
7850
- needsMask = needMaskingText(n, maskTextClass, maskTextSelector, checkAncestors);
5752
+ needsMask = needMaskingText(n2, maskTextClass, maskTextSelector, checkAncestors);
7851
5753
  }
7852
- const _serializedNode = serializeNode(n, {
5754
+ const _serializedNode = serializeNode(n2, {
7853
5755
  doc,
7854
5756
  mirror: mirror2,
7855
5757
  blockClass,
@@ -7866,30 +5768,30 @@ function serializeNodeWithId(n, options) {
7866
5768
  newlyAddedElement
7867
5769
  });
7868
5770
  if (!_serializedNode) {
7869
- console.warn(n, "not serialized");
5771
+ console.warn(n2, "not serialized");
7870
5772
  return null;
7871
5773
  }
7872
5774
  let id;
7873
- if (mirror2.hasNode(n)) {
7874
- id = mirror2.getId(n);
5775
+ if (mirror2.hasNode(n2)) {
5776
+ id = mirror2.getId(n2);
7875
5777
  } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
7876
5778
  id = IGNORED_NODE;
7877
5779
  } else {
7878
5780
  id = genId();
7879
5781
  }
7880
5782
  const serializedNode = Object.assign(_serializedNode, { id });
7881
- mirror2.add(n, serializedNode);
5783
+ mirror2.add(n2, serializedNode);
7882
5784
  if (id === IGNORED_NODE) {
7883
5785
  return null;
7884
5786
  }
7885
5787
  if (onSerialize) {
7886
- onSerialize(n);
5788
+ onSerialize(n2);
7887
5789
  }
7888
5790
  let recordChild = !skipChild;
7889
5791
  if (serializedNode.type === NodeType.Element) {
7890
5792
  recordChild = recordChild && !serializedNode.needBlock;
7891
5793
  delete serializedNode.needBlock;
7892
- const shadowRoot = n.shadowRoot;
5794
+ const shadowRoot = n2.shadowRoot;
7893
5795
  if (shadowRoot && isNativeShadowDom(shadowRoot))
7894
5796
  serializedNode.isShadowHost = true;
7895
5797
  }
@@ -7924,29 +5826,29 @@ function serializeNodeWithId(n, options) {
7924
5826
  };
7925
5827
  if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
7926
5828
  else {
7927
- for (const childN of Array.from(n.childNodes)) {
5829
+ for (const childN of Array.from(n2.childNodes)) {
7928
5830
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
7929
5831
  if (serializedChildNode) {
7930
5832
  serializedNode.childNodes.push(serializedChildNode);
7931
5833
  }
7932
5834
  }
7933
5835
  }
7934
- if (isElement(n) && n.shadowRoot) {
7935
- for (const childN of Array.from(n.shadowRoot.childNodes)) {
5836
+ if (isElement(n2) && n2.shadowRoot) {
5837
+ for (const childN of Array.from(n2.shadowRoot.childNodes)) {
7936
5838
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
7937
5839
  if (serializedChildNode) {
7938
- isNativeShadowDom(n.shadowRoot) && (serializedChildNode.isShadow = true);
5840
+ isNativeShadowDom(n2.shadowRoot) && (serializedChildNode.isShadow = true);
7939
5841
  serializedNode.childNodes.push(serializedChildNode);
7940
5842
  }
7941
5843
  }
7942
5844
  }
7943
5845
  }
7944
- if (n.parentNode && isShadowRoot(n.parentNode) && isNativeShadowDom(n.parentNode)) {
5846
+ if (n2.parentNode && isShadowRoot(n2.parentNode) && isNativeShadowDom(n2.parentNode)) {
7945
5847
  serializedNode.isShadow = true;
7946
5848
  }
7947
5849
  if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
7948
- onceIframeLoaded(n, () => {
7949
- const iframeDoc = n.contentDocument;
5850
+ onceIframeLoaded(n2, () => {
5851
+ const iframeDoc = n2.contentDocument;
7950
5852
  if (iframeDoc && onIframeLoad) {
7951
5853
  const serializedIframeNode = serializeNodeWithId(iframeDoc, {
7952
5854
  doc: iframeDoc,
@@ -7974,15 +5876,15 @@ function serializeNodeWithId(n, options) {
7974
5876
  keepIframeSrcFn
7975
5877
  });
7976
5878
  if (serializedIframeNode) {
7977
- onIframeLoad(n, serializedIframeNode);
5879
+ onIframeLoad(n2, serializedIframeNode);
7978
5880
  }
7979
5881
  }
7980
5882
  }, iframeLoadTimeout);
7981
5883
  }
7982
5884
  if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
7983
- onceStylesheetLoaded(n, () => {
5885
+ onceStylesheetLoaded(n2, () => {
7984
5886
  if (onStylesheetLoad) {
7985
- const serializedLinkNode = serializeNodeWithId(n, {
5887
+ const serializedLinkNode = serializeNodeWithId(n2, {
7986
5888
  doc,
7987
5889
  mirror: mirror2,
7988
5890
  blockClass,
@@ -8008,14 +5910,14 @@ function serializeNodeWithId(n, options) {
8008
5910
  keepIframeSrcFn
8009
5911
  });
8010
5912
  if (serializedLinkNode) {
8011
- onStylesheetLoad(n, serializedLinkNode);
5913
+ onStylesheetLoad(n2, serializedLinkNode);
8012
5914
  }
8013
5915
  }
8014
5916
  }, stylesheetLoadTimeout);
8015
5917
  }
8016
5918
  return serializedNode;
8017
5919
  }
8018
- function snapshot(n, options) {
5920
+ function snapshot(n2, options) {
8019
5921
  const { mirror: mirror2 = new Mirror(), blockClass = "rr-block", blockSelector = null, maskTextClass = "rr-mask", maskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, onStylesheetLoad, stylesheetLoadTimeout, keepIframeSrcFn = () => false } = options || {};
8020
5922
  const maskInputOptions = maskAllInputs === true ? {
8021
5923
  color: true,
@@ -8049,8 +5951,8 @@ function snapshot(n, options) {
8049
5951
  headMetaAuthorship: true,
8050
5952
  headMetaVerification: true
8051
5953
  } : slimDOM === false ? {} : slimDOM;
8052
- return serializeNodeWithId(n, {
8053
- doc: n,
5954
+ return serializeNodeWithId(n2, {
5955
+ doc: n2,
8054
5956
  mirror: mirror2,
8055
5957
  blockClass,
8056
5958
  blockSelector,
@@ -8231,11 +6133,11 @@ function isBlocked(node, blockClass, blockSelector, checkAncestors) {
8231
6133
  }
8232
6134
  return false;
8233
6135
  }
8234
- function isSerialized(n, mirror2) {
8235
- return mirror2.getId(n) !== -1;
6136
+ function isSerialized(n2, mirror2) {
6137
+ return mirror2.getId(n2) !== -1;
8236
6138
  }
8237
- function isIgnored(n, mirror2) {
8238
- return mirror2.getId(n) === IGNORED_NODE;
6139
+ function isIgnored(n2, mirror2) {
6140
+ return mirror2.getId(n2) === IGNORED_NODE;
8239
6141
  }
8240
6142
  function isAncestorRemoved(target, mirror2) {
8241
6143
  if (isShadowRoot(target)) {
@@ -8278,14 +6180,14 @@ function polyfill(win2 = window) {
8278
6180
  };
8279
6181
  }
8280
6182
  }
8281
- function isSerializedIframe(n, mirror2) {
8282
- return Boolean(n.nodeName === "IFRAME" && mirror2.getMeta(n));
6183
+ function isSerializedIframe(n2, mirror2) {
6184
+ return Boolean(n2.nodeName === "IFRAME" && mirror2.getMeta(n2));
8283
6185
  }
8284
- function isSerializedStylesheet(n, mirror2) {
8285
- return Boolean(n.nodeName === "LINK" && n.nodeType === n.ELEMENT_NODE && n.getAttribute && n.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n));
6186
+ function isSerializedStylesheet(n2, mirror2) {
6187
+ return Boolean(n2.nodeName === "LINK" && n2.nodeType === n2.ELEMENT_NODE && n2.getAttribute && n2.getAttribute("rel") === "stylesheet" && mirror2.getMeta(n2));
8286
6188
  }
8287
- function hasShadowRoot(n) {
8288
- return Boolean(n === null || n === void 0 ? void 0 : n.shadowRoot);
6189
+ function hasShadowRoot(n2) {
6190
+ return Boolean(n2 === null || n2 === void 0 ? void 0 : n2.shadowRoot);
8289
6191
  }
8290
6192
  class StyleSheetMirror {
8291
6193
  constructor() {
@@ -8324,32 +6226,32 @@ class StyleSheetMirror {
8324
6226
  return this.id++;
8325
6227
  }
8326
6228
  }
8327
- function getShadowHost(n) {
6229
+ function getShadowHost(n2) {
8328
6230
  var _a, _b;
8329
6231
  let shadowHost = null;
8330
- if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && n.getRootNode().host)
8331
- shadowHost = n.getRootNode().host;
6232
+ if (((_b = (_a = n2.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n2)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE && n2.getRootNode().host)
6233
+ shadowHost = n2.getRootNode().host;
8332
6234
  return shadowHost;
8333
6235
  }
8334
- function getRootShadowHost(n) {
8335
- let rootShadowHost = n;
6236
+ function getRootShadowHost(n2) {
6237
+ let rootShadowHost = n2;
8336
6238
  let shadowHost;
8337
6239
  while (shadowHost = getShadowHost(rootShadowHost))
8338
6240
  rootShadowHost = shadowHost;
8339
6241
  return rootShadowHost;
8340
6242
  }
8341
- function shadowHostInDom(n) {
8342
- const doc = n.ownerDocument;
6243
+ function shadowHostInDom(n2) {
6244
+ const doc = n2.ownerDocument;
8343
6245
  if (!doc)
8344
6246
  return false;
8345
- const shadowHost = getRootShadowHost(n);
6247
+ const shadowHost = getRootShadowHost(n2);
8346
6248
  return doc.contains(shadowHost);
8347
6249
  }
8348
- function inDom(n) {
8349
- const doc = n.ownerDocument;
6250
+ function inDom(n2) {
6251
+ const doc = n2.ownerDocument;
8350
6252
  if (!doc)
8351
6253
  return false;
8352
- return doc.contains(n) || shadowHostInDom(n);
6254
+ return doc.contains(n2) || shadowHostInDom(n2);
8353
6255
  }
8354
6256
  var EventType$1 = /* @__PURE__ */ ((EventType2) => {
8355
6257
  EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
@@ -8407,8 +6309,8 @@ var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
8407
6309
  CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
8408
6310
  return CanvasContext2;
8409
6311
  })(CanvasContext || {});
8410
- function isNodeInLinkedList(n) {
8411
- return "__ln" in n;
6312
+ function isNodeInLinkedList(n2) {
6313
+ return "__ln" in n2;
8412
6314
  }
8413
6315
  class DoubleLinkedList {
8414
6316
  constructor() {
@@ -8426,26 +6328,26 @@ class DoubleLinkedList {
8426
6328
  }
8427
6329
  return current;
8428
6330
  }
8429
- addNode(n) {
6331
+ addNode(n2) {
8430
6332
  const node = {
8431
- value: n,
6333
+ value: n2,
8432
6334
  previous: null,
8433
6335
  next: null
8434
6336
  };
8435
- n.__ln = node;
8436
- if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
8437
- const current = n.previousSibling.__ln.next;
6337
+ n2.__ln = node;
6338
+ if (n2.previousSibling && isNodeInLinkedList(n2.previousSibling)) {
6339
+ const current = n2.previousSibling.__ln.next;
8438
6340
  node.next = current;
8439
- node.previous = n.previousSibling.__ln;
8440
- n.previousSibling.__ln.next = node;
6341
+ node.previous = n2.previousSibling.__ln;
6342
+ n2.previousSibling.__ln.next = node;
8441
6343
  if (current) {
8442
6344
  current.previous = node;
8443
6345
  }
8444
- } else if (n.nextSibling && isNodeInLinkedList(n.nextSibling) && n.nextSibling.__ln.previous) {
8445
- const current = n.nextSibling.__ln.previous;
6346
+ } else if (n2.nextSibling && isNodeInLinkedList(n2.nextSibling) && n2.nextSibling.__ln.previous) {
6347
+ const current = n2.nextSibling.__ln.previous;
8446
6348
  node.previous = current;
8447
- node.next = n.nextSibling.__ln;
8448
- n.nextSibling.__ln.previous = node;
6349
+ node.next = n2.nextSibling.__ln;
6350
+ n2.nextSibling.__ln.previous = node;
8449
6351
  if (current) {
8450
6352
  current.next = node;
8451
6353
  }
@@ -8461,8 +6363,8 @@ class DoubleLinkedList {
8461
6363
  }
8462
6364
  this.length++;
8463
6365
  }
8464
- removeNode(n) {
8465
- const current = n.__ln;
6366
+ removeNode(n2) {
6367
+ const current = n2.__ln;
8466
6368
  if (!this.head) {
8467
6369
  return;
8468
6370
  }
@@ -8481,8 +6383,8 @@ class DoubleLinkedList {
8481
6383
  this.tail = current.previous;
8482
6384
  }
8483
6385
  }
8484
- if (n.__ln) {
8485
- delete n.__ln;
6386
+ if (n2.__ln) {
6387
+ delete n2.__ln;
8486
6388
  }
8487
6389
  this.length--;
8488
6390
  }
@@ -8512,8 +6414,8 @@ class MutationBuffer {
8512
6414
  const adds = [];
8513
6415
  const addedIds = /* @__PURE__ */ new Set();
8514
6416
  const addList = new DoubleLinkedList();
8515
- const getNextId = (n) => {
8516
- let ns = n;
6417
+ const getNextId = (n2) => {
6418
+ let ns = n2;
8517
6419
  let nextId = IGNORED_NODE;
8518
6420
  while (nextId === IGNORED_NODE) {
8519
6421
  ns = ns && ns.nextSibling;
@@ -8521,16 +6423,16 @@ class MutationBuffer {
8521
6423
  }
8522
6424
  return nextId;
8523
6425
  };
8524
- const pushAdd = (n) => {
8525
- if (!n.parentNode || !inDom(n) || n.parentNode.tagName === "TEXTAREA") {
6426
+ const pushAdd = (n2) => {
6427
+ if (!n2.parentNode || !inDom(n2) || n2.parentNode.tagName === "TEXTAREA") {
8526
6428
  return;
8527
6429
  }
8528
- const parentId = isShadowRoot(n.parentNode) ? this.mirror.getId(getShadowHost(n)) : this.mirror.getId(n.parentNode);
8529
- const nextId = getNextId(n);
6430
+ const parentId = isShadowRoot(n2.parentNode) ? this.mirror.getId(getShadowHost(n2)) : this.mirror.getId(n2.parentNode);
6431
+ const nextId = getNextId(n2);
8530
6432
  if (parentId === -1 || nextId === -1) {
8531
- return addList.addNode(n);
6433
+ return addList.addNode(n2);
8532
6434
  }
8533
- const sn = serializeNodeWithId(n, {
6435
+ const sn = serializeNodeWithId(n2, {
8534
6436
  doc: this.doc,
8535
6437
  mirror: this.mirror,
8536
6438
  blockClass: this.blockClass,
@@ -8554,8 +6456,8 @@ class MutationBuffer {
8554
6456
  if (isSerializedStylesheet(currentN, this.mirror)) {
8555
6457
  this.stylesheetManager.trackLinkElement(currentN);
8556
6458
  }
8557
- if (hasShadowRoot(n)) {
8558
- this.shadowDomManager.addShadowRoot(n.shadowRoot, this.doc);
6459
+ if (hasShadowRoot(n2)) {
6460
+ this.shadowDomManager.addShadowRoot(n2.shadowRoot, this.doc);
8559
6461
  }
8560
6462
  },
8561
6463
  onIframeLoad: (iframe, childSn) => {
@@ -8578,19 +6480,19 @@ class MutationBuffer {
8578
6480
  while (this.mapRemoves.length) {
8579
6481
  this.mirror.removeNodeFromMap(this.mapRemoves.shift());
8580
6482
  }
8581
- for (const n of this.movedSet) {
8582
- if (isParentRemoved(this.removes, n, this.mirror) && !this.movedSet.has(n.parentNode)) {
6483
+ for (const n2 of this.movedSet) {
6484
+ if (isParentRemoved(this.removes, n2, this.mirror) && !this.movedSet.has(n2.parentNode)) {
8583
6485
  continue;
8584
6486
  }
8585
- pushAdd(n);
6487
+ pushAdd(n2);
8586
6488
  }
8587
- for (const n of this.addedSet) {
8588
- if (!isAncestorInSet(this.droppedSet, n) && !isParentRemoved(this.removes, n, this.mirror)) {
8589
- pushAdd(n);
8590
- } else if (isAncestorInSet(this.movedSet, n)) {
8591
- pushAdd(n);
6489
+ for (const n2 of this.addedSet) {
6490
+ if (!isAncestorInSet(this.droppedSet, n2) && !isParentRemoved(this.removes, n2, this.mirror)) {
6491
+ pushAdd(n2);
6492
+ } else if (isAncestorInSet(this.movedSet, n2)) {
6493
+ pushAdd(n2);
8592
6494
  } else {
8593
- this.droppedSet.add(n);
6495
+ this.droppedSet.add(n2);
8594
6496
  }
8595
6497
  }
8596
6498
  let candidate = null;
@@ -8642,12 +6544,12 @@ class MutationBuffer {
8642
6544
  }
8643
6545
  const payload = {
8644
6546
  texts: this.texts.map((text) => {
8645
- const n = text.node;
8646
- if (n.parentNode && n.parentNode.tagName === "TEXTAREA") {
8647
- this.genTextAreaValueMutation(n.parentNode);
6547
+ const n2 = text.node;
6548
+ if (n2.parentNode && n2.parentNode.tagName === "TEXTAREA") {
6549
+ this.genTextAreaValueMutation(n2.parentNode);
8648
6550
  }
8649
6551
  return {
8650
- id: this.mirror.getId(n),
6552
+ id: this.mirror.getId(n2),
8651
6553
  value: text.value
8652
6554
  };
8653
6555
  }).filter((text) => !addedIds.has(text.id)).filter((text) => this.mirror.has(text.id)),
@@ -8794,20 +6696,20 @@ class MutationBuffer {
8794
6696
  this.genTextAreaValueMutation(m2.target);
8795
6697
  return;
8796
6698
  }
8797
- m2.addedNodes.forEach((n) => this.genAdds(n, m2.target));
8798
- m2.removedNodes.forEach((n) => {
8799
- const nodeId = this.mirror.getId(n);
6699
+ m2.addedNodes.forEach((n2) => this.genAdds(n2, m2.target));
6700
+ m2.removedNodes.forEach((n2) => {
6701
+ const nodeId = this.mirror.getId(n2);
8800
6702
  const parentId = isShadowRoot(m2.target) ? this.mirror.getId(m2.target.host) : this.mirror.getId(m2.target);
8801
- if (isBlocked(m2.target, this.blockClass, this.blockSelector, false) || isIgnored(n, this.mirror) || !isSerialized(n, this.mirror)) {
6703
+ if (isBlocked(m2.target, this.blockClass, this.blockSelector, false) || isIgnored(n2, this.mirror) || !isSerialized(n2, this.mirror)) {
8802
6704
  return;
8803
6705
  }
8804
- if (this.addedSet.has(n)) {
8805
- deepDelete(this.addedSet, n);
8806
- this.droppedSet.add(n);
6706
+ if (this.addedSet.has(n2)) {
6707
+ deepDelete(this.addedSet, n2);
6708
+ this.droppedSet.add(n2);
8807
6709
  } else if (this.addedSet.has(m2.target) && nodeId === -1) ;
8808
6710
  else if (isAncestorRemoved(m2.target, this.mirror)) ;
8809
- else if (this.movedSet.has(n) && this.movedMap[moveKey(nodeId, parentId)]) {
8810
- deepDelete(this.movedSet, n);
6711
+ else if (this.movedSet.has(n2) && this.movedMap[moveKey(nodeId, parentId)]) {
6712
+ deepDelete(this.movedSet, n2);
8811
6713
  } else {
8812
6714
  this.removes.push({
8813
6715
  parentId,
@@ -8815,39 +6717,39 @@ class MutationBuffer {
8815
6717
  isShadow: isShadowRoot(m2.target) && isNativeShadowDom(m2.target) ? true : void 0
8816
6718
  });
8817
6719
  }
8818
- this.mapRemoves.push(n);
6720
+ this.mapRemoves.push(n2);
8819
6721
  });
8820
6722
  break;
8821
6723
  }
8822
6724
  }
8823
6725
  };
8824
- this.genAdds = (n, target) => {
8825
- if (this.processedNodeManager.inOtherBuffer(n, this))
6726
+ this.genAdds = (n2, target) => {
6727
+ if (this.processedNodeManager.inOtherBuffer(n2, this))
8826
6728
  return;
8827
- if (this.addedSet.has(n) || this.movedSet.has(n))
6729
+ if (this.addedSet.has(n2) || this.movedSet.has(n2))
8828
6730
  return;
8829
- if (this.mirror.hasNode(n)) {
8830
- if (isIgnored(n, this.mirror)) {
6731
+ if (this.mirror.hasNode(n2)) {
6732
+ if (isIgnored(n2, this.mirror)) {
8831
6733
  return;
8832
6734
  }
8833
- this.movedSet.add(n);
6735
+ this.movedSet.add(n2);
8834
6736
  let targetId = null;
8835
6737
  if (target && this.mirror.hasNode(target)) {
8836
6738
  targetId = this.mirror.getId(target);
8837
6739
  }
8838
6740
  if (targetId && targetId !== -1) {
8839
- this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;
6741
+ this.movedMap[moveKey(this.mirror.getId(n2), targetId)] = true;
8840
6742
  }
8841
6743
  } else {
8842
- this.addedSet.add(n);
8843
- this.droppedSet.delete(n);
6744
+ this.addedSet.add(n2);
6745
+ this.droppedSet.delete(n2);
8844
6746
  }
8845
- if (!isBlocked(n, this.blockClass, this.blockSelector, false)) {
8846
- n.childNodes.forEach((childN) => this.genAdds(childN));
8847
- if (hasShadowRoot(n)) {
8848
- n.shadowRoot.childNodes.forEach((childN) => {
6747
+ if (!isBlocked(n2, this.blockClass, this.blockSelector, false)) {
6748
+ n2.childNodes.forEach((childN) => this.genAdds(childN));
6749
+ if (hasShadowRoot(n2)) {
6750
+ n2.shadowRoot.childNodes.forEach((childN) => {
8849
6751
  this.processedNodeManager.add(childN, this);
8850
- this.genAdds(childN, n);
6752
+ this.genAdds(childN, n2);
8851
6753
  });
8852
6754
  }
8853
6755
  }
@@ -8906,17 +6808,17 @@ class MutationBuffer {
8906
6808
  this.canvasManager.reset();
8907
6809
  }
8908
6810
  }
8909
- function deepDelete(addsSet, n) {
8910
- addsSet.delete(n);
8911
- n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
6811
+ function deepDelete(addsSet, n2) {
6812
+ addsSet.delete(n2);
6813
+ n2.childNodes.forEach((childN) => deepDelete(addsSet, childN));
8912
6814
  }
8913
- function isParentRemoved(removes, n, mirror2) {
6815
+ function isParentRemoved(removes, n2, mirror2) {
8914
6816
  if (removes.length === 0)
8915
6817
  return false;
8916
- return _isParentRemoved(removes, n, mirror2);
6818
+ return _isParentRemoved(removes, n2, mirror2);
8917
6819
  }
8918
- function _isParentRemoved(removes, n, mirror2) {
8919
- const { parentNode } = n;
6820
+ function _isParentRemoved(removes, n2, mirror2) {
6821
+ const { parentNode } = n2;
8920
6822
  if (!parentNode) {
8921
6823
  return false;
8922
6824
  }
@@ -8926,13 +6828,13 @@ function _isParentRemoved(removes, n, mirror2) {
8926
6828
  }
8927
6829
  return _isParentRemoved(removes, parentNode, mirror2);
8928
6830
  }
8929
- function isAncestorInSet(set, n) {
6831
+ function isAncestorInSet(set, n2) {
8930
6832
  if (set.size === 0)
8931
6833
  return false;
8932
- return _isAncestorInSet(set, n);
6834
+ return _isAncestorInSet(set, n2);
8933
6835
  }
8934
- function _isAncestorInSet(set, n) {
8935
- const { parentNode } = n;
6836
+ function _isAncestorInSet(set, n2) {
6837
+ const { parentNode } = n2;
8936
6838
  if (!parentNode) {
8937
6839
  return false;
8938
6840
  }
@@ -9929,24 +7831,24 @@ class IframeManager {
9929
7831
  case EventType$1.IncrementalSnapshot: {
9930
7832
  switch (e.data.source) {
9931
7833
  case IncrementalSource$1.Mutation: {
9932
- e.data.adds.forEach((n) => {
9933
- this.replaceIds(n, iframeEl, [
7834
+ e.data.adds.forEach((n2) => {
7835
+ this.replaceIds(n2, iframeEl, [
9934
7836
  "parentId",
9935
7837
  "nextId",
9936
7838
  "previousId"
9937
7839
  ]);
9938
- this.replaceIdOnNode(n.node, iframeEl);
7840
+ this.replaceIdOnNode(n2.node, iframeEl);
9939
7841
  const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);
9940
- rootId && this.patchRootIdOnNode(n.node, rootId);
7842
+ rootId && this.patchRootIdOnNode(n2.node, rootId);
9941
7843
  });
9942
- e.data.removes.forEach((n) => {
9943
- this.replaceIds(n, iframeEl, ["parentId", "id"]);
7844
+ e.data.removes.forEach((n2) => {
7845
+ this.replaceIds(n2, iframeEl, ["parentId", "id"]);
9944
7846
  });
9945
- e.data.attributes.forEach((n) => {
9946
- this.replaceIds(n, iframeEl, ["id"]);
7847
+ e.data.attributes.forEach((n2) => {
7848
+ this.replaceIds(n2, iframeEl, ["id"]);
9947
7849
  });
9948
- e.data.texts.forEach((n) => {
9949
- this.replaceIds(n, iframeEl, ["id"]);
7850
+ e.data.texts.forEach((n2) => {
7851
+ this.replaceIds(n2, iframeEl, ["id"]);
9950
7852
  });
9951
7853
  return e;
9952
7854
  }
@@ -10107,15 +8009,15 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10107
8009
  PERFORMANCE OF THIS SOFTWARE.
10108
8010
  ***************************************************************************** */
10109
8011
  function __rest(s2, e) {
10110
- var t = {};
8012
+ var t3 = {};
10111
8013
  for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e.indexOf(p2) < 0)
10112
- t[p2] = s2[p2];
8014
+ t3[p2] = s2[p2];
10113
8015
  if (s2 != null && typeof Object.getOwnPropertySymbols === "function")
10114
8016
  for (var i = 0, p2 = Object.getOwnPropertySymbols(s2); i < p2.length; i++) {
10115
8017
  if (e.indexOf(p2[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s2, p2[i]))
10116
- t[p2[i]] = s2[p2[i]];
8018
+ t3[p2[i]] = s2[p2[i]];
10117
8019
  }
10118
- return t;
8020
+ return t3;
10119
8021
  }
10120
8022
  function __awaiter(thisArg, _arguments, P2, generator) {
10121
8023
  function adopt(value) {
@@ -10410,7 +8312,7 @@ function funcToSource(fn, sourcemapArg) {
10410
8312
  lines.shift();
10411
8313
  var blankPrefixLength = lines[0].search(/\S/);
10412
8314
  var regex = /(['"])__worker_loader_strict__(['"])/g;
10413
- for (var i = 0, n = lines.length; i < n; ++i) {
8315
+ for (var i = 0, n2 = lines.length; i < n2; ++i) {
10414
8316
  lines[i] = lines[i].substring(blankPrefixLength).replace(regex, "$1use strict$2") + "\n";
10415
8317
  }
10416
8318
  return lines;
@@ -11016,15 +8918,15 @@ function record(options = {}) {
11016
8918
  dataURLOptions,
11017
8919
  recordCanvas,
11018
8920
  inlineImages,
11019
- onSerialize: (n) => {
11020
- if (isSerializedIframe(n, mirror)) {
11021
- iframeManager.addIframe(n);
8921
+ onSerialize: (n2) => {
8922
+ if (isSerializedIframe(n2, mirror)) {
8923
+ iframeManager.addIframe(n2);
11022
8924
  }
11023
- if (isSerializedStylesheet(n, mirror)) {
11024
- stylesheetManager.trackLinkElement(n);
8925
+ if (isSerializedStylesheet(n2, mirror)) {
8926
+ stylesheetManager.trackLinkElement(n2);
11025
8927
  }
11026
- if (hasShadowRoot(n)) {
11027
- shadowDomManager.addShadowRoot(n.shadowRoot, document);
8928
+ if (hasShadowRoot(n2)) {
8929
+ shadowDomManager.addShadowRoot(n2.shadowRoot, document);
11028
8930
  }
11029
8931
  },
11030
8932
  onIframeLoad: (iframe, childSn) => {
@@ -11521,8 +9423,8 @@ _.timestamp = function() {
11521
9423
  return Date.now();
11522
9424
  };
11523
9425
  _.formatDate = function(d2) {
11524
- function pad(n) {
11525
- return n < 10 ? "0" + n : n;
9426
+ function pad(n2) {
9427
+ return n2 < 10 ? "0" + n2 : n2;
11526
9428
  }
11527
9429
  return d2.getUTCFullYear() + "-" + pad(d2.getUTCMonth() + 1) + "-" + pad(d2.getUTCDate()) + "T" + pad(d2.getUTCHours()) + ":" + pad(d2.getUTCMinutes()) + ":" + pad(d2.getUTCSeconds());
11528
9430
  };
@@ -11852,11 +9754,11 @@ _.base64Encode = function(data) {
11852
9754
  _.utf8Encode = function(string) {
11853
9755
  string = (string + "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
11854
9756
  var utftext = "", start, end;
11855
- var stringl = 0, n;
9757
+ var stringl = 0, n2;
11856
9758
  start = end = 0;
11857
9759
  stringl = string.length;
11858
- for (n = 0; n < stringl; n++) {
11859
- var c1 = string.charCodeAt(n);
9760
+ for (n2 = 0; n2 < stringl; n2++) {
9761
+ var c1 = string.charCodeAt(n2);
11860
9762
  var enc = null;
11861
9763
  if (c1 < 128) {
11862
9764
  end++;
@@ -11870,7 +9772,7 @@ _.utf8Encode = function(string) {
11870
9772
  utftext += string.substring(start, end);
11871
9773
  }
11872
9774
  utftext += enc;
11873
- start = end = n + 1;
9775
+ start = end = n2 + 1;
11874
9776
  }
11875
9777
  }
11876
9778
  if (end > start) {
@@ -15507,6 +13409,7 @@ function loadNoop(_src, onload) {
15507
13409
  onload();
15508
13410
  }
15509
13411
  var mixpanel = init_as_module(loadNoop);
13412
+ const version = "1.0.10-alpha.1";
15510
13413
  const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
15511
13414
  function init$2(mixpanelToken, debug = false, proxyUrl) {
15512
13415
  return new Promise((resolve) => {
@@ -15538,7 +13441,7 @@ function track(eventName, properties) {
15538
13441
  if (!isReady()) {
15539
13442
  return;
15540
13443
  }
15541
- mixpanel.track(eventName, properties);
13444
+ mixpanel.track(eventName, { ...properties, "Reservamos Version": version });
15542
13445
  }
15543
13446
  const getMixpanelDistinctId = () => {
15544
13447
  const cachedId = localStorage.getItem(MIXPANEL_DISTINCT_ID_CACHE_KEY);
@@ -15911,7 +13814,6 @@ const validatorService = {
15911
13814
  function onLoaded() {
15912
13815
  window.dispatchEvent(new CustomEvent("Tracker Ready"));
15913
13816
  }
15914
- let apiConfig = null;
15915
13817
  async function init$1(config) {
15916
13818
  validatorService.parseInitProps(config);
15917
13819
  const {
@@ -15932,17 +13834,13 @@ async function init$1(config) {
15932
13834
  } catch (error) {
15933
13835
  console.error("Error initializing identification service:", error);
15934
13836
  }
15935
- const environment = isSandbox ? "sandbox" : "prod";
15936
- apiConfig = configService.coreAPIConfig[environment];
15937
- jsApiClientExports.setConfig(apiConfig);
13837
+ configService.setEnvironment(isSandbox ? "sandbox" : "prod");
13838
+ s.setConfig(configService.getCoreAPIConfig());
15938
13839
  onLoaded();
15939
13840
  }
15940
13841
  function isTrackerReady() {
15941
13842
  return mixpanelService.isReady();
15942
13843
  }
15943
- function getApiConfig() {
15944
- return apiConfig;
15945
- }
15946
13844
  let currentCoordinates = null;
15947
13845
  function init() {
15948
13846
  return new Promise((resolve) => {
@@ -16015,37 +13913,26 @@ function flattenEventData(data) {
16015
13913
  return flattenedData;
16016
13914
  }, {});
16017
13915
  }
16018
- function trackEventTracked(eventName, from) {
16019
- mixpanelService.track("Event Tracked", {
16020
- "Event Name": eventName,
16021
- "From": from
16022
- });
16023
- }
16024
- function trackEventError(eventName, error) {
16025
- try {
16026
- tryTrackEvent("Track Event Error", async () => {
13916
+ function trackEventError(eventName, error, payload) {
13917
+ tryTrackEvent(async () => {
13918
+ try {
16027
13919
  mixpanelService.track("Track Event Error", {
16028
13920
  "Failed Event Name": eventName,
16029
13921
  "Error Message": (error == null ? void 0 : error.message) ?? "Failed to track event",
16030
- "Validation Errors": (error == null ? void 0 : error.errors) || []
13922
+ "Validation Errors": (error == null ? void 0 : error.errors) || [],
13923
+ "Event Payload": payload
16031
13924
  });
16032
- });
16033
- } catch (trackingError) {
16034
- console.error("Failed to track error event:", trackingError);
16035
- }
13925
+ } catch (trackingError) {
13926
+ console.error("Failed to track error event:", trackingError);
13927
+ }
13928
+ });
16036
13929
  }
16037
- async function tryTrackEvent(eventName, trackEventCallback) {
13930
+ async function tryTrackEvent(trackEventCallback) {
16038
13931
  if (mixpanelService.isReady()) {
16039
13932
  await trackEventCallback();
16040
- trackEventTracked(eventName, "Mixpanel Ready");
16041
13933
  } else {
16042
13934
  window.addEventListener("Tracker Ready", async () => {
16043
- try {
16044
- await trackEventCallback();
16045
- trackEventTracked(eventName, "Mixpanel Ready Listener");
16046
- } catch (error) {
16047
- trackEventError(eventName, error);
16048
- }
13935
+ await trackEventCallback();
16049
13936
  });
16050
13937
  }
16051
13938
  }
@@ -16078,7 +13965,7 @@ async function trackEvent(eventName, eventProperties, meta = {}) {
16078
13965
  mixpanelService.track(eventName, properties);
16079
13966
  } catch (error) {
16080
13967
  console.error(`Error tracking event '${eventName}':`, error);
16081
- trackEventError(eventName, error);
13968
+ trackEventError(eventName, error, eventProperties);
16082
13969
  }
16083
13970
  }
16084
13971
  function extractTrackingParams() {
@@ -16103,7 +13990,7 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
16103
13990
  trackEvent(eventName, eventData, meta);
16104
13991
  } catch (error) {
16105
13992
  console.error("Error trackCustomEvent:", error);
16106
- trackEventError(eventName, error);
13993
+ trackEventError(eventName, error, eventData);
16107
13994
  }
16108
13995
  }
16109
13996
  const CreateAnonymousProfileSchema = z.object({
@@ -16158,8 +14045,7 @@ async function createAnonymousProfile(payload) {
16158
14045
  identifiers.push({ key: "fingerprint", value: userFingerprintId });
16159
14046
  if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
16160
14047
  const dataPayload = getAnonymousProfilePayload(payload, identifiers);
16161
- const result = await jsApiClientExports.core.createAnonymousProfile(dataPayload);
16162
- return result.data;
14048
+ return await s.profiles.createAnonymousProfile(dataPayload);
16163
14049
  } catch (error) {
16164
14050
  console.error("Could not create anonymous profile:", error);
16165
14051
  return void 0;
@@ -16186,8 +14072,8 @@ function mapProperties(properties) {
16186
14072
  return { ...parsedProperties, ...additionalProperties };
16187
14073
  }
16188
14074
  const identifyWithLocation = async (userId, properties) => {
14075
+ var _a, _b;
16189
14076
  try {
16190
- const apiConfig2 = getApiConfig();
16191
14077
  const coordinates = geolocationService.getCoordinates();
16192
14078
  if (!coordinates) {
16193
14079
  return;
@@ -16200,12 +14086,13 @@ const identifyWithLocation = async (userId, properties) => {
16200
14086
  properties.name = `${properties.firstName} ${properties.lastName}`;
16201
14087
  delete properties.firstName;
16202
14088
  delete properties.lastName;
16203
- fetch(`${apiConfig2 == null ? void 0 : apiConfig2.coreUrl}/${apiConfig2 == null ? void 0 : apiConfig2.coreVersion}/datalake/identify`, {
14089
+ const coreApiConfig = configService.getCoreAPIConfig();
14090
+ fetch(`${coreApiConfig.baseUrl}/v1/datalake/identify`, {
16204
14091
  method: "POST",
16205
14092
  headers: {
16206
14093
  "Content-Type": "application/json",
16207
- "Authorization": (apiConfig2 == null ? void 0 : apiConfig2.coreApiKey) || "",
16208
- ...(apiConfig2 == null ? void 0 : apiConfig2.headers) || {}
14094
+ "Authorization": ((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a.Authorization) || "",
14095
+ "Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || ""
16209
14096
  },
16210
14097
  body: JSON.stringify({
16211
14098
  profile_params: {
@@ -16219,8 +14106,8 @@ const identifyWithLocation = async (userId, properties) => {
16219
14106
  }
16220
14107
  };
16221
14108
  async function identify(userId, properties = {}) {
16222
- try {
16223
- tryTrackEvent("Identify", async () => {
14109
+ tryTrackEvent(async () => {
14110
+ try {
16224
14111
  validatorService.parseIdentifyProps(properties);
16225
14112
  if (!userId) {
16226
14113
  console.error("User ID is required for identification.");
@@ -16236,18 +14123,146 @@ async function identify(userId, properties = {}) {
16236
14123
  if (fingerprint) {
16237
14124
  mixpanelService.attachProperty(FINGERPRINT_PROPERTY, fingerprint);
16238
14125
  }
16239
- });
16240
- } catch (error) {
16241
- console.error("Error identifying user", error);
16242
- trackEventError("Identify", error);
16243
- } finally {
16244
- identifyWithLocation(userId, properties);
16245
- }
14126
+ } catch (error) {
14127
+ console.error("Error identifying user", error);
14128
+ trackEventError("Identify", error, { userId, properties });
14129
+ } finally {
14130
+ identifyWithLocation(userId, properties);
14131
+ }
14132
+ });
16246
14133
  }
14134
+ z.object({
14135
+ "Operation Id": stringField("Operation Id"),
14136
+ "Trips": arrayField(tripSchema, "Trips", 1).optional(),
14137
+ "Passenger Count": numberField("Passenger Count").optional(),
14138
+ "Total": numberField("Total").optional(),
14139
+ "Trip Count": numberField("Trip Count").optional(),
14140
+ "product": productValidation,
14141
+ "Passengers": arrayField(passengerSchema, "Passengers", 1).optional()
14142
+ });
16247
14143
  const EVENT_NAME = "Purchase Canceled";
16248
14144
  function trackPurchaseCanceled(eventData, meta = {}) {
16249
14145
  trackEvent(EVENT_NAME, eventData, meta);
16250
14146
  }
14147
+ const SeatSchema$1 = z.object({
14148
+ category: z.string(),
14149
+ number: z.string().optional(),
14150
+ occupied: z.boolean().optional(),
14151
+ adjacent_seats: z.null().optional()
14152
+ });
14153
+ const BusSchemeSchema$1 = z.object({
14154
+ bus: z.array(z.array(z.array(SeatSchema$1)))
14155
+ });
14156
+ const CreateRecommendedSeatsSchema = z.object({
14157
+ bus_type: z.string(),
14158
+ selected_seats: z.string(),
14159
+ bus_scheme: BusSchemeSchema$1
14160
+ });
14161
+ async function createRecommendedSeats$1(payload) {
14162
+ try {
14163
+ validatorService.validateProps(payload, CreateRecommendedSeatsSchema);
14164
+ const distinctId = mixpanelService.getMixpanelDistinctId();
14165
+ const userFingerprintId = fingerprintService.getCachedFingerprint();
14166
+ if (!distinctId) {
14167
+ throw new Error("No distinct ID found");
14168
+ }
14169
+ return await s.recommendations.createRecommendedSeats({
14170
+ ...payload,
14171
+ distinct_id: distinctId,
14172
+ device_fingerprint: userFingerprintId || ""
14173
+ });
14174
+ } catch (error) {
14175
+ console.error("Could not create recommended seats:", error);
14176
+ throw new Error(error instanceof Error ? error.message : String(error));
14177
+ }
14178
+ }
14179
+ const pollingRecommendedPlaces = async (response) => {
14180
+ return new Promise((resolve, reject) => {
14181
+ const { state, polling_id } = response;
14182
+ if (state === "finished") {
14183
+ resolve(response);
14184
+ return;
14185
+ }
14186
+ s.recommendations.pollRecommendedPlaces(polling_id, {
14187
+ start: true,
14188
+ watch: "state",
14189
+ expect: "finished",
14190
+ onEachResponse: (profile) => {
14191
+ if (profile.status === "finished") {
14192
+ resolve(profile);
14193
+ return;
14194
+ }
14195
+ if (profile.status === "failed") {
14196
+ reject(profile);
14197
+ return;
14198
+ }
14199
+ }
14200
+ });
14201
+ });
14202
+ };
14203
+ async function getRecommendedPlaces() {
14204
+ const distinctId = mixpanelService.getMixpanelDistinctId();
14205
+ if (!distinctId) {
14206
+ throw new Error("No distinct ID found");
14207
+ }
14208
+ const response = await s.recommendations.createRecommendedPlaces({
14209
+ distinct_id: distinctId
14210
+ });
14211
+ if (!response) {
14212
+ throw new Error("No response received");
14213
+ }
14214
+ const profile = await pollingRecommendedPlaces(response);
14215
+ return profile;
14216
+ }
14217
+ const SeatSchema = z.object({
14218
+ category: z.string(),
14219
+ number: z.string().optional(),
14220
+ occupied: z.boolean().optional(),
14221
+ adjacent_seats: z.null().optional()
14222
+ });
14223
+ const BusSchemeSchema = z.object({
14224
+ bus: z.array(z.array(z.array(SeatSchema)))
14225
+ });
14226
+ const GetRecommendedSeatsSchema = z.object({
14227
+ bus_scheme: BusSchemeSchema,
14228
+ total_seats: z.number()
14229
+ });
14230
+ async function createRecommendedSeats(payload) {
14231
+ try {
14232
+ validatorService.validateProps(payload, GetRecommendedSeatsSchema);
14233
+ const distinctId = mixpanelService.getMixpanelDistinctId();
14234
+ if (!distinctId) {
14235
+ throw new Error("No distinct ID found");
14236
+ }
14237
+ return await s.recommendations.getRecommendedSeats({
14238
+ ...payload,
14239
+ distinct_id: distinctId
14240
+ });
14241
+ } catch (error) {
14242
+ console.error("Could not create recommended seats:", error);
14243
+ throw new Error(error instanceof Error ? error.message : String(error));
14244
+ }
14245
+ }
14246
+ const GetRecommendedTripsSchema = z.object({
14247
+ searchId: z.number().min(1, "SearchId is required")
14248
+ });
14249
+ async function getRecommendedTrips({
14250
+ searchId
14251
+ }) {
14252
+ try {
14253
+ validatorService.validateProps({ searchId }, GetRecommendedTripsSchema);
14254
+ const identifier = fingerprintService.getCachedFingerprint() || mixpanelService.getMixpanelDistinctId();
14255
+ if (!identifier) throw new Error("No identifier id");
14256
+ const response = await s.recommendations.getRecommendedTrips({
14257
+ searchId,
14258
+ userIdentifier: String(identifier)
14259
+ });
14260
+ return response;
14261
+ } catch (error) {
14262
+ console.error("Could not get recommended trips:", error);
14263
+ throw new Error(error instanceof Error ? error.message : String(error));
14264
+ }
14265
+ }
16251
14266
  const analytics = {
16252
14267
  init: init$1,
16253
14268
  isReady: isTrackerReady,
@@ -16259,6 +14274,12 @@ const analytics = {
16259
14274
  profiles: {
16260
14275
  createAnonymousProfile
16261
14276
  },
14277
+ recommendations: {
14278
+ getRecommendedPlaces,
14279
+ createRecommendedSeats: createRecommendedSeats$1,
14280
+ getRecommendedSeats: createRecommendedSeats,
14281
+ getRecommendedTrips
14282
+ },
16262
14283
  track: {
16263
14284
  search: trackSearch,
16264
14285
  seatChange: trackSeatChange,