@amplitude/segment-session-replay-plugin 0.0.0-prereleasenetworkcapture.0 → 0.0.0-zen-plus-zoning.0

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 (47) hide show
  1. package/lib/cjs/constants.d.ts +6 -0
  2. package/lib/cjs/constants.d.ts.map +1 -0
  3. package/lib/cjs/constants.js +9 -0
  4. package/lib/cjs/constants.js.map +1 -0
  5. package/lib/cjs/helpers.d.ts +5 -0
  6. package/lib/cjs/helpers.d.ts.map +1 -0
  7. package/lib/cjs/helpers.js +53 -0
  8. package/lib/cjs/helpers.js.map +1 -0
  9. package/lib/cjs/index.d.ts +3 -0
  10. package/lib/cjs/index.d.ts.map +1 -0
  11. package/lib/cjs/index.js +98 -0
  12. package/lib/cjs/index.js.map +1 -0
  13. package/lib/cjs/typings/wrapper.d.ts +12 -0
  14. package/lib/cjs/typings/wrapper.d.ts.map +1 -0
  15. package/lib/cjs/typings/wrapper.js +3 -0
  16. package/lib/cjs/typings/wrapper.js.map +1 -0
  17. package/lib/cjs/version.d.ts +2 -0
  18. package/lib/cjs/version.d.ts.map +1 -0
  19. package/lib/cjs/version.js +6 -0
  20. package/lib/cjs/version.js.map +1 -0
  21. package/lib/esm/helpers.d.ts.map +1 -1
  22. package/lib/esm/version.d.ts +1 -1
  23. package/lib/esm/version.d.ts.map +1 -1
  24. package/lib/esm/version.js +1 -1
  25. package/lib/esm/version.js.map +1 -1
  26. package/lib/scripts/index-min.js +2 -0
  27. package/lib/scripts/index-min.js.gz +0 -0
  28. package/lib/scripts/index-min.js.map +1 -0
  29. package/lib/scripts/index-min2.js +2 -0
  30. package/lib/scripts/index-min2.js.gz +0 -0
  31. package/lib/scripts/index-min2.js.map +1 -0
  32. package/lib/scripts/index-min3.js +2 -0
  33. package/lib/scripts/index-min3.js.gz +0 -0
  34. package/lib/scripts/index-min3.js.map +1 -0
  35. package/lib/scripts/observers-min.js +2 -0
  36. package/lib/scripts/observers-min.js.gz +0 -0
  37. package/lib/scripts/observers-min.js.map +1 -0
  38. package/lib/scripts/rrweb-plugin-console-record-min.js +2 -0
  39. package/lib/scripts/rrweb-plugin-console-record-min.js.gz +0 -0
  40. package/lib/scripts/rrweb-plugin-console-record-min.js.map +1 -0
  41. package/lib/scripts/rrweb-record-min.js +2 -0
  42. package/lib/scripts/rrweb-record-min.js.gz +0 -0
  43. package/lib/scripts/rrweb-record-min.js.map +1 -0
  44. package/lib/scripts/segment-session-replay-wrapper-esm.js +2 -0
  45. package/lib/scripts/segment-session-replay-wrapper-esm.js.gz +0 -0
  46. package/lib/scripts/segment-session-replay-wrapper-esm.js.map +1 -0
  47. package/package.json +3 -3
@@ -0,0 +1,6 @@
1
+ export declare const COOKIE_NAME = "amp_session_id";
2
+ export declare const DEBUG_LOG_PREFIX = "Amplitude Session Replay Segment Plugin [Debug]:";
3
+ export declare const INITIAL_EVENT_NAME = "Immediate Event";
4
+ export declare const PLUGIN_NAME = "Session Replay Events";
5
+ export declare const PLUGIN_TYPE = "enrichment";
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,gBAAgB,qDAAqD,CAAC;AACnF,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,WAAW,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_TYPE = exports.PLUGIN_NAME = exports.INITIAL_EVENT_NAME = exports.DEBUG_LOG_PREFIX = exports.COOKIE_NAME = void 0;
4
+ exports.COOKIE_NAME = 'amp_session_id';
5
+ exports.DEBUG_LOG_PREFIX = 'Amplitude Session Replay Segment Plugin [Debug]:';
6
+ exports.INITIAL_EVENT_NAME = 'Immediate Event';
7
+ exports.PLUGIN_NAME = 'Session Replay Events';
8
+ exports.PLUGIN_TYPE = 'enrichment'; // https://github.com/segmentio/analytics-next/blob/c45d445/packages/core/src/plugins/index.ts#L11
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,gBAAgB,GAAG,kDAAkD,CAAC;AACtE,QAAA,kBAAkB,GAAG,iBAAiB,CAAC;AACvC,QAAA,WAAW,GAAG,uBAAuB,CAAC;AACtC,QAAA,WAAW,GAAG,YAAY,CAAC,CAAC,kGAAkG","sourcesContent":["export const COOKIE_NAME = 'amp_session_id';\nexport const DEBUG_LOG_PREFIX = 'Amplitude Session Replay Segment Plugin [Debug]:';\nexport const INITIAL_EVENT_NAME = 'Immediate Event';\nexport const PLUGIN_NAME = 'Session Replay Events';\nexport const PLUGIN_TYPE = 'enrichment'; // https://github.com/segmentio/analytics-next/blob/c45d445/packages/core/src/plugins/index.ts#L11\n"]}
@@ -0,0 +1,5 @@
1
+ import { Context } from '@segment/analytics-next';
2
+ export declare const getSessionId: () => number | undefined;
3
+ export declare const setSessionId: (sessionId: number, deviceId: string | undefined) => Promise<void>;
4
+ export declare const updateSessionIdAndAddProperties: (ctx: Context, deviceId: string | undefined) => Promise<Context>;
5
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,eAAO,MAAM,YAAY,QAAO,MAAM,GAAG,SAcxC,CAAC;AAEF,eAAO,MAAM,YAAY,cAAe,MAAM,YAAY,MAAM,GAAG,SAAS,KAAG,QAAQ,IAAI,CAM1F,CAAC;AAEF,eAAO,MAAM,+BAA+B,QAAe,OAAO,YAAY,MAAM,GAAG,SAAS,KAAG,QAAQ,OAAO,CA0BjH,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateSessionIdAndAddProperties = exports.setSessionId = exports.getSessionId = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser"));
6
+ var js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
7
+ var constants_1 = require("./constants");
8
+ var getSessionId = function () {
9
+ // First try to get the sessionId from the Session Replay SDK
10
+ // If that fails, try to get the sessionId from the persistent storage
11
+ var sessionId = sessionReplay.getSessionId() || js_cookie_1.default.get(constants_1.COOKIE_NAME);
12
+ if (sessionId) {
13
+ var result = parseInt(sessionId.toString(), 10);
14
+ if (isNaN(result)) {
15
+ return undefined;
16
+ }
17
+ return result;
18
+ }
19
+ // If sessionId is not found in either the Session Replay SDK nor persistent storage, return undefined
20
+ return undefined;
21
+ };
22
+ exports.getSessionId = getSessionId;
23
+ var setSessionId = function (sessionId, deviceId) {
24
+ // Set the sessionId in the persistent storage
25
+ js_cookie_1.default.set(constants_1.COOKIE_NAME, sessionId.toString());
26
+ // Set the sessionId in the Session Replay SDK
27
+ return sessionReplay.setSessionId(sessionId, deviceId).promise;
28
+ };
29
+ exports.setSessionId = setSessionId;
30
+ var updateSessionIdAndAddProperties = function (ctx, deviceId) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
31
+ var sessionId, nextSessionId, sessionReplayProperties, properties;
32
+ return tslib_1.__generator(this, function (_a) {
33
+ switch (_a.label) {
34
+ case 0:
35
+ sessionId = (0, exports.getSessionId)() || 0;
36
+ if (ctx.event.integrations && ctx.event.integrations['Actions Amplitude']) {
37
+ nextSessionId = ctx.event.integrations['Actions Amplitude'].session_id;
38
+ }
39
+ if (!(nextSessionId && sessionId < nextSessionId)) return [3 /*break*/, 2];
40
+ return [4 /*yield*/, (0, exports.setSessionId)(nextSessionId, deviceId)];
41
+ case 1:
42
+ _a.sent();
43
+ _a.label = 2;
44
+ case 2:
45
+ sessionReplayProperties = sessionReplay.getSessionReplayProperties();
46
+ properties = tslib_1.__assign(tslib_1.__assign({}, sessionReplayProperties), ctx.event.properties);
47
+ ctx.updateEvent('properties', properties);
48
+ return [2 /*return*/, ctx];
49
+ }
50
+ });
51
+ }); };
52
+ exports.updateSessionIdAndAddProperties = updateSessionIdAndAddProperties;
53
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;;AAAA,uFAAmE;AAEnE,gEAA+B;AAC/B,yCAA0C;AAGnC,IAAM,YAAY,GAAG;IAC1B,6DAA6D;IAC7D,sEAAsE;IACtE,IAAM,SAAS,GAAgC,aAAa,CAAC,YAAY,EAAE,IAAI,mBAAM,CAAC,GAAG,CAAC,uBAAW,CAAC,CAAC;IACvG,IAAI,SAAS,EAAE;QACb,IAAM,MAAM,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;YACjB,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,MAAM,CAAC;KACf;IAED,sGAAsG;IACtG,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB;AAEK,IAAM,YAAY,GAAG,UAAC,SAAiB,EAAE,QAA4B;IAC1E,8CAA8C;IAC9C,mBAAM,CAAC,GAAG,CAAC,uBAAW,EAAE,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE9C,8CAA8C;IAC9C,OAAO,aAAa,CAAC,YAAY,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,OAAO,CAAC;AACjE,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AAEK,IAAM,+BAA+B,GAAG,UAAO,GAAY,EAAE,QAA4B;;;;;gBAExF,SAAS,GAAW,IAAA,oBAAY,GAAE,IAAI,CAAC,CAAC;gBAI9C,IAAI,GAAG,CAAC,KAAK,CAAC,YAAY,IAAK,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAA8B,EAAE;oBACvG,aAAa,GAAI,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAA8B,CAAC,UAAU,CAAC;iBACtG;qBAGG,CAAA,aAAa,IAAI,SAAS,GAAG,aAAa,CAAA,EAA1C,wBAA0C;gBAC5C,qBAAM,IAAA,oBAAY,EAAC,aAAa,EAAE,QAAQ,CAAC,EAAA;;gBAA3C,SAA2C,CAAC;;;gBAKxC,uBAAuB,GAAG,aAAa,CAAC,0BAA0B,EAAE,CAAC;gBACrE,UAAU,yCACX,uBAAuB,GACvB,GAAG,CAAC,KAAK,CAAC,UAAU,CACxB,CAAC;gBAEF,GAAG,CAAC,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;gBAE1C,sBAAO,GAAG,EAAC;;;KACZ,CAAC;AA1BW,QAAA,+BAA+B,mCA0B1C","sourcesContent":["import * as sessionReplay from '@amplitude/session-replay-browser';\nimport { Context } from '@segment/analytics-next';\nimport Cookie from 'js-cookie';\nimport { COOKIE_NAME } from './constants';\nimport { AmplitudeIntegrationData } from './typings/wrapper';\n\nexport const getSessionId = (): number | undefined => {\n // First try to get the sessionId from the Session Replay SDK\n // If that fails, try to get the sessionId from the persistent storage\n const sessionId: string | number | undefined = sessionReplay.getSessionId() || Cookie.get(COOKIE_NAME);\n if (sessionId) {\n const result = parseInt(sessionId.toString(), 10);\n if (isNaN(result)) {\n return undefined;\n }\n return result;\n }\n\n // If sessionId is not found in either the Session Replay SDK nor persistent storage, return undefined\n return undefined;\n};\n\nexport const setSessionId = (sessionId: number, deviceId: string | undefined): Promise<void> => {\n // Set the sessionId in the persistent storage\n Cookie.set(COOKIE_NAME, sessionId.toString());\n\n // Set the sessionId in the Session Replay SDK\n return sessionReplay.setSessionId(sessionId, deviceId).promise;\n};\n\nexport const updateSessionIdAndAddProperties = async (ctx: Context, deviceId: string | undefined): Promise<Context> => {\n // Get the current session id or default to 0 if it does not exist\n const sessionId: number = getSessionId() || 0;\n\n // Get the next session id from the event, if it exists\n let nextSessionId: number | undefined;\n if (ctx.event.integrations && (ctx.event.integrations['Actions Amplitude'] as AmplitudeIntegrationData)) {\n nextSessionId = (ctx.event.integrations['Actions Amplitude'] as AmplitudeIntegrationData).session_id;\n }\n\n // Update the session id if it is new\n if (nextSessionId && sessionId < nextSessionId) {\n await setSessionId(nextSessionId, deviceId);\n }\n\n // Enrich the event with the session replay properties\n // NOTE: This is what will add the `[Amplitude] Session Replay ID` attribute to the event\n const sessionReplayProperties = sessionReplay.getSessionReplayProperties();\n const properties = {\n ...sessionReplayProperties,\n ...ctx.event.properties,\n };\n\n ctx.updateEvent('properties', properties);\n\n return ctx;\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { PluginOptions } from './typings/wrapper';
2
+ export declare const createSegmentActionsPlugin: ({ amplitudeApiKey, sessionReplayOptions, segmentInstance, enableWrapperDebug, }: PluginOptions) => Promise<void>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,eAAO,MAAM,0BAA0B,oFAKpC,aAAa,KAAG,QAAQ,IAAI,CAuE9B,CAAC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSegmentActionsPlugin = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var sessionReplay = tslib_1.__importStar(require("@amplitude/session-replay-browser"));
6
+ var constants_1 = require("./constants");
7
+ var helpers_1 = require("./helpers");
8
+ var version_1 = require("./version");
9
+ var createSegmentActionsPlugin = function (_a) {
10
+ var amplitudeApiKey = _a.amplitudeApiKey, sessionReplayOptions = _a.sessionReplayOptions, segmentInstance = _a.segmentInstance, _b = _a.enableWrapperDebug, enableWrapperDebug = _b === void 0 ? false : _b;
11
+ return tslib_1.__awaiter(void 0, void 0, void 0, function () {
12
+ var initPromise, isInitialized, deviceId, _plugin;
13
+ return tslib_1.__generator(this, function (_c) {
14
+ switch (_c.label) {
15
+ case 0:
16
+ isInitialized = false;
17
+ deviceId = sessionReplayOptions === null || sessionReplayOptions === void 0 ? void 0 : sessionReplayOptions.deviceId;
18
+ _plugin = {
19
+ name: constants_1.PLUGIN_NAME,
20
+ type: constants_1.PLUGIN_TYPE,
21
+ version: version_1.VERSION,
22
+ isLoaded: function () { return isInitialized; },
23
+ load: function (_ctx, ajs) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
24
+ var user, sessionId;
25
+ return tslib_1.__generator(this, function (_a) {
26
+ switch (_a.label) {
27
+ case 0:
28
+ // If the deviceId is not provided via the plugin parameters,
29
+ // default to use the anonymousId from the user
30
+ if (!deviceId) {
31
+ user = ajs.user();
32
+ deviceId = user.anonymousId() || undefined;
33
+ }
34
+ sessionId = (0, helpers_1.getSessionId)();
35
+ // Initialize the session replay plugin
36
+ enableWrapperDebug &&
37
+ console.log("".concat(constants_1.DEBUG_LOG_PREFIX, " initializing session replay with sessionId=").concat(sessionId !== null && sessionId !== void 0 ? sessionId : 'undefined', " and deviceId=").concat(deviceId !== null && deviceId !== void 0 ? deviceId : 'undefined'));
38
+ initPromise = sessionReplay.init(amplitudeApiKey, tslib_1.__assign(tslib_1.__assign({}, sessionReplayOptions), { sessionId: sessionId, deviceId: deviceId || undefined, version: { type: 'segment', version: version_1.VERSION } })).promise;
39
+ return [4 /*yield*/, initPromise];
40
+ case 1:
41
+ _a.sent();
42
+ isInitialized = true;
43
+ return [2 /*return*/];
44
+ }
45
+ });
46
+ }); },
47
+ track: function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
48
+ return tslib_1.__generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, initPromise];
51
+ case 1:
52
+ _a.sent();
53
+ return [4 /*yield*/, (0, helpers_1.updateSessionIdAndAddProperties)(ctx, deviceId)];
54
+ case 2: return [2 /*return*/, _a.sent()];
55
+ }
56
+ });
57
+ }); },
58
+ page: function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
59
+ return tslib_1.__generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, initPromise];
62
+ case 1:
63
+ _a.sent();
64
+ return [4 /*yield*/, (0, helpers_1.updateSessionIdAndAddProperties)(ctx, deviceId)];
65
+ case 2: return [2 /*return*/, _a.sent()];
66
+ }
67
+ });
68
+ }); },
69
+ identify: function (ctx) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
70
+ var sessionId;
71
+ return tslib_1.__generator(this, function (_a) {
72
+ switch (_a.label) {
73
+ case 0: return [4 /*yield*/, initPromise];
74
+ case 1:
75
+ _a.sent();
76
+ sessionId = (0, helpers_1.getSessionId)();
77
+ if (!sessionId) return [3 /*break*/, 3];
78
+ enableWrapperDebug &&
79
+ console.log("".concat(constants_1.DEBUG_LOG_PREFIX, " calling setSessionId() with sessionId=").concat(sessionId, " and deviceId=").concat(deviceId !== null && deviceId !== void 0 ? deviceId : 'undefined'));
80
+ return [4 /*yield*/, (0, helpers_1.setSessionId)(sessionId, deviceId)];
81
+ case 2:
82
+ _a.sent();
83
+ _a.label = 3;
84
+ case 3: return [2 /*return*/, ctx];
85
+ }
86
+ });
87
+ }); },
88
+ };
89
+ return [4 /*yield*/, segmentInstance.register(_plugin)];
90
+ case 1:
91
+ _c.sent();
92
+ return [2 /*return*/];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ exports.createSegmentActionsPlugin = createSegmentActionsPlugin;
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,uFAAmE;AAGnE,yCAAyE;AACzE,qCAAwF;AAExF,qCAAoC;AAE7B,IAAM,0BAA0B,GAAG,UAAO,EAKjC;QAJd,eAAe,qBAAA,EACf,oBAAoB,0BAAA,EACpB,eAAe,qBAAA,EACf,0BAA0B,EAA1B,kBAAkB,mBAAG,KAAK,KAAA;;;;;;oBAGtB,aAAa,GAAG,KAAK,CAAC;oBACtB,QAAQ,GAAuB,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,QAAQ,CAAC;oBAE5D,OAAO,GAAW;wBACtB,IAAI,EAAE,uBAAW;wBACjB,IAAI,EAAE,uBAAW;wBACjB,OAAO,EAAE,iBAAO;wBAEhB,QAAQ,EAAE,cAAe,OAAA,aAAa,EAAb,CAAa;wBAEtC,IAAI,EAAE,UAAO,IAAa,EAAE,GAAc;;;;;wCACxC,6DAA6D;wCAC7D,+CAA+C;wCAC/C,IAAI,CAAC,QAAQ,EAAE;4CACP,IAAI,GAAS,GAAG,CAAC,IAAI,EAAE,CAAC;4CAC9B,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,SAAS,CAAC;yCAC5C;wCAEK,SAAS,GAAuB,IAAA,sBAAY,GAAE,CAAC;wCAErD,uCAAuC;wCACvC,kBAAkB;4CAChB,OAAO,CAAC,GAAG,CACT,UAAG,4BAAgB,yDAA+C,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,WAAW,2BACxF,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,WAAW,CACvB,CACH,CAAC;wCAEJ,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,eAAe,wCAC3C,oBAAoB,KACvB,SAAS,WAAA,EACT,QAAQ,EAAE,QAAQ,IAAI,SAAS,EAC/B,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAO,EAAE,IAC9C,CAAC,OAAO,CAAC;wCAEX,qBAAM,WAAW,EAAA;;wCAAjB,SAAiB,CAAC;wCAClB,aAAa,GAAG,IAAI,CAAC;;;;6BACtB;wBAED,KAAK,EAAE,UAAO,GAAY;;;4CACxB,qBAAM,WAAW,EAAA;;wCAAjB,SAAiB,CAAC;wCACX,qBAAM,IAAA,yCAA+B,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAA;4CAA3D,sBAAO,SAAoD,EAAC;;;6BAC7D;wBAED,IAAI,EAAE,UAAO,GAAY;;;4CACvB,qBAAM,WAAW,EAAA;;wCAAjB,SAAiB,CAAC;wCACX,qBAAM,IAAA,yCAA+B,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAA;4CAA3D,sBAAO,SAAoD,EAAC;;;6BAC7D;wBAED,QAAQ,EAAE,UAAO,GAAY;;;;4CAC3B,qBAAM,WAAW,EAAA;;wCAAjB,SAAiB,CAAC;wCAEZ,SAAS,GAAuB,IAAA,sBAAY,GAAE,CAAC;6CAEjD,SAAS,EAAT,wBAAS;wCACX,kBAAkB;4CAChB,OAAO,CAAC,GAAG,CACT,UAAG,4BAAgB,oDAA0C,SAAS,2BACpE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,WAAW,CACvB,CACH,CAAC;wCACJ,qBAAM,IAAA,sBAAY,EAAC,SAAS,EAAE,QAAQ,CAAC,EAAA;;wCAAvC,SAAuC,CAAC;;4CAG1C,sBAAO,GAAG,EAAC;;;6BACZ;qBACF,CAAC;oBAEF,qBAAM,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAA;;oBAAvC,SAAuC,CAAC;;;;;CACzC,CAAC;AA5EW,QAAA,0BAA0B,8BA4ErC","sourcesContent":["import * as sessionReplay from '@amplitude/session-replay-browser';\nimport { Analytics, Context, Plugin, User } from '@segment/analytics-next';\n\nimport { DEBUG_LOG_PREFIX, PLUGIN_NAME, PLUGIN_TYPE } from './constants';\nimport { getSessionId, setSessionId, updateSessionIdAndAddProperties } from './helpers';\nimport { PluginOptions } from './typings/wrapper';\nimport { VERSION } from './version';\n\nexport const createSegmentActionsPlugin = async ({\n amplitudeApiKey,\n sessionReplayOptions,\n segmentInstance,\n enableWrapperDebug = false,\n}: PluginOptions): Promise<void> => {\n let initPromise: Promise<void>;\n let isInitialized = false;\n let deviceId: string | undefined = sessionReplayOptions?.deviceId;\n\n const _plugin: Plugin = {\n name: PLUGIN_NAME,\n type: PLUGIN_TYPE,\n version: VERSION,\n\n isLoaded: (): boolean => isInitialized,\n\n load: async (_ctx: Context, ajs: Analytics): Promise<void> => {\n // If the deviceId is not provided via the plugin parameters,\n // default to use the anonymousId from the user\n if (!deviceId) {\n const user: User = ajs.user();\n deviceId = user.anonymousId() || undefined;\n }\n\n const sessionId: number | undefined = getSessionId();\n\n // Initialize the session replay plugin\n enableWrapperDebug &&\n console.log(\n `${DEBUG_LOG_PREFIX} initializing session replay with sessionId=${sessionId ?? 'undefined'} and deviceId=${\n deviceId ?? 'undefined'\n }`,\n );\n\n initPromise = sessionReplay.init(amplitudeApiKey, {\n ...sessionReplayOptions,\n sessionId,\n deviceId: deviceId || undefined,\n version: { type: 'segment', version: VERSION },\n }).promise;\n\n await initPromise;\n isInitialized = true;\n },\n\n track: async (ctx: Context): Promise<Context> => {\n await initPromise;\n return await updateSessionIdAndAddProperties(ctx, deviceId);\n },\n\n page: async (ctx: Context): Promise<Context> => {\n await initPromise;\n return await updateSessionIdAndAddProperties(ctx, deviceId);\n },\n\n identify: async (ctx: Context): Promise<Context> => {\n await initPromise;\n\n const sessionId: number | undefined = getSessionId();\n\n if (sessionId) {\n enableWrapperDebug &&\n console.log(\n `${DEBUG_LOG_PREFIX} calling setSessionId() with sessionId=${sessionId} and deviceId=${\n deviceId ?? 'undefined'\n }`,\n );\n await setSessionId(sessionId, deviceId);\n }\n\n return ctx;\n },\n };\n\n await segmentInstance.register(_plugin);\n};\n"]}
@@ -0,0 +1,12 @@
1
+ import { SessionReplayOptions } from '@amplitude/session-replay-browser';
2
+ import { AnalyticsBrowser } from '@segment/analytics-next';
3
+ export interface PluginOptions {
4
+ segmentInstance: AnalyticsBrowser;
5
+ amplitudeApiKey: string;
6
+ sessionReplayOptions?: SessionReplayOptions;
7
+ enableWrapperDebug?: boolean;
8
+ }
9
+ export type AmplitudeIntegrationData = {
10
+ session_id: number;
11
+ };
12
+ //# sourceMappingURL=wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../../src/typings/wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,gBAAgB,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,MAAM,wBAAwB,GAAG;IAErC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../../src/typings/wrapper.ts"],"names":[],"mappings":"","sourcesContent":["import { SessionReplayOptions } from '@amplitude/session-replay-browser';\nimport { AnalyticsBrowser } from '@segment/analytics-next';\n\nexport interface PluginOptions {\n segmentInstance: AnalyticsBrowser;\n amplitudeApiKey: string;\n sessionReplayOptions?: SessionReplayOptions;\n enableWrapperDebug?: boolean;\n}\n\nexport type AmplitudeIntegrationData = {\n // https://github.com/segmentio/analytics-next/blob/3f15dfae034d101fb1847bc7228c0354b414d68a/packages/browser-integration-tests/src/index.test.ts#L64-L66\n session_id: number;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.0.0-zen-plus-zoning.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,4BAA4B,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ // Autogenerated by `yarn version-file`. DO NOT EDIT
5
+ exports.VERSION = '0.0.0-zen-plus-zoning.0';
6
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AACvC,QAAA,OAAO,GAAG,yBAAyB,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '0.0.0-zen-plus-zoning.0';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,eAAO,MAAM,YAAY,QAAO,MAAM,GAAG,SAcxC,CAAC;AAEF,eAAO,MAAM,YAAY,cAAe,MAAM,YAAY,MAAM,GAAG,SAAS,KAAG,QAAQ,IAAI,CAM1F,CAAC;AAEF,eAAO,MAAM,+BAA+B,2BAAkC,MAAM,GAAG,SAAS,KAAG,QAAQ,OAAO,CA0BjH,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAKlD,eAAO,MAAM,YAAY,QAAO,MAAM,GAAG,SAcxC,CAAC;AAEF,eAAO,MAAM,YAAY,cAAe,MAAM,YAAY,MAAM,GAAG,SAAS,KAAG,QAAQ,IAAI,CAM1F,CAAC;AAEF,eAAO,MAAM,+BAA+B,QAAe,OAAO,YAAY,MAAM,GAAG,SAAS,KAAG,QAAQ,OAAO,CA0BjH,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.0.0-beta.0";
1
+ export declare const VERSION = "0.0.0-zen-plus-zoning.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,iBAAiB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,4BAA4B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Autogenerated by `yarn version-file`. DO NOT EDIT
2
- export var VERSION = '0.0.0-beta.0';
2
+ export var VERSION = '0.0.0-zen-plus-zoning.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,cAAc,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '0.0.0-beta.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,IAAM,OAAO,GAAG,yBAAyB,CAAC","sourcesContent":["// Autogenerated by `yarn version-file`. DO NOT EDIT\nexport const VERSION = '0.0.0-zen-plus-zoning.0';\n"]}
@@ -0,0 +1,2 @@
1
+ var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};function t(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n,r,i=function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((r=r.apply(e,t||[])).next())})}function s(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function a(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function u(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(n||(n={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(r||(r={}));var l,d="".concat("AMP","_unsent"),f="$default_instance",v="https://api2.amplitude.com/2/httpapi";!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(l||(l={}));var h,g=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},p=u([],c(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),m=function(e){var t,n=g();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,m)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,u([],c(r.entries()),!1).map(function(e){var t=c(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(p[r]):p[r]}).join("")},y=function(e){return{promise:e||Promise.resolve()}};!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(h||(h={}));var b="Amplitude Logger ",S=function(){function e(){this.logLevel=h.None}return e.prototype.disable=function(){this.logLevel=h.None},e.prototype.enable=function(e){void 0===e&&(e=h.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<h.Verbose||console.log("".concat(b,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<h.Warn||console.warn("".concat(b,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<h.Error||console.error("".concat(b,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<h.Debug||console.log("".concat(b,"[Debug]: ").concat(e.join(" ")))},e}(),w=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:f,logLevel:h.Warn,loggerProvider:new S,offline:!1,optOut:!1,serverUrl:v,serverZone:"US",useBatch:!1}},I=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=w();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=E(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),C=function(e,t){return"EU"===e?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":v},E=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=w().serverZone),void 0===n&&(n=w().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:w().serverZone;return{serverZone:r,serverUrl:C(r,n)}};var P=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n(),c=a.logger,u=a.logLevel;if(u&&u<h.Debug||!u||!c)return e.apply(i,o);var l,d={type:"invoke public method",name:t,args:o,stacktrace:(l=1,void 0===l&&(l=0),((new Error).stack||"").split("\n").slice(2+l).map(function(e){return e.trim()})),time:{start:(new Date).toISOString()},states:{}};r&&d.states&&(d.states.before=r());var f=e.apply(i,o);return f&&f.promise?f.promise.then(function(){r&&d.states&&(d.states.after=r()),d.time&&(d.time.end=(new Date).toISOString()),c.debug(JSON.stringify(d,null,2))}):(r&&d.states&&(d.states.after=r()),d.time&&(d.time.end=(new Date).toISOString()),c.debug(JSON.stringify(d,null,2))),f}},k=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:x(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),x=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},_=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(t){e(t)}),this.queue=[])},e}(),R=function(){return R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},R.apply(this,arguments)};function T(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function O(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var M=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=T(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next()){if(s.value===i)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),c=Array.isArray(t);if(a!==c)return!1;if(!a||!c){var u=Object.keys(e).sort(),l=Object.keys(t).sort();if(!M(u,l))return!1;var d=!0;return Object.keys(e).forEach(function(n){M(e[n],t[n])||(d=!1)}),d}for(var f=0;f<e.length;f++)if(!M(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var D,L=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=R({},this.identity.userProperties),n=R(R({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,s,a,c=n.userProperties||{};try{for(var u=T(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=O(l.value,2),f=d[0],v=d[1];switch(f){case"$set":try{for(var h=(i=void 0,T(Object.entries(v))),g=h.next();!g.done;g=h.next()){var p=O(g.value,2),m=p[0],y=p[1];c[m]=y}}catch(e){i={error:e}}finally{try{g&&!g.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(s=void 0,T(Object.keys(v))),S=b.next();!S.done;S=b.next()){delete c[m=S.value]}}catch(e){s={error:e}}finally{try{S&&!S.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":c={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return R({},this.identity)},e.prototype.setIdentity=function(e){var t=R({},this.identity);this.identity=R({},e),M(t,this.identity)||this.listeners.forEach(function(t){t(e)})},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),q="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,N=function(){function e(){this.identityStore=new L,this.eventBridge=new _,this.applicationContextProvider=new k}return e.getInstance=function(t){return q.analyticsConnectorInstances||(q.analyticsConnectorInstances={}),q.analyticsConnectorInstances[t]||(q.analyticsConnectorInstances[t]=new e),q.analyticsConnectorInstances[t]},e}(),j=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},U=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,s,a,c,u,d,f,v,h,g,p,m,y,b,S,w,I,C;if("object"!=typeof e)return null;var E=e.code||0,P=this.buildStatus(E);switch(P){case l.Success:return{status:P,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case l.Invalid:return{status:P,statusCode:E,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(d=e.exceeded_daily_quota_devices)&&void 0!==d?d:{},silencedDevices:null!==(f=e.silenced_devices)&&void 0!==f?f:[],silencedEvents:null!==(v=e.silenced_events)&&void 0!==v?v:[],throttledDevices:null!==(h=e.throttled_devices)&&void 0!==h?h:{},throttledEvents:null!==(g=e.throttled_events)&&void 0!==g?g:[]}};case l.PayloadTooLarge:return{status:P,statusCode:E,body:{error:null!==(p=e.error)&&void 0!==p?p:""}};case l.RateLimit:return{status:P,statusCode:E,body:{error:null!==(m=e.error)&&void 0!==m?m:"",epsThreshold:null!==(y=e.eps_threshold)&&void 0!==y?y:0,throttledDevices:null!==(b=e.throttled_devices)&&void 0!==b?b:{},throttledUsers:null!==(S=e.throttled_users)&&void 0!==S?S:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(I=e.exceeded_daily_quota_users)&&void 0!==I?I:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case l.Timeout:default:return{status:P,statusCode:E}}},e.prototype.buildStatus=function(e){return function(e){return e>=200&&e<300}(e)?l.Success:429===e?l.RateLimit:413===e?l.PayloadTooLarge:408===e?l.Timeout:e>=400&&e<500?l.Invalid:e>=500?l.Failed:l.Unknown},e}(),A=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t(n,e),n.prototype.send=function(e,t){return o(this,void 0,void 0,function(){var n,r,i;return s(this,function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:i=o.sent();try{return[2,this.buildResponse(JSON.parse(i))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}})})},n}(U),F=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),B=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new F(e,t)}return e.prototype.subscribe=function(e,t,n){var r=m(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return o(this,void 0,void 0,function(){var e,t=this;return s(this,function(n){switch(n.label){case 0:return[4,this.fetch()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.subscribeAll=function(e){return o(this,void 0,void 0,function(){var t,n,r,i=this;return s(this,function(o){switch(o.label){case 0:return t=this.fetch().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),this.sendCallback(e,r,"cache")),[4,t];case 2:return o.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return o(this,void 0,void 0,function(){var n,r;return s(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.fetch(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),o(this,void 0,void 0,function(){var n,r,i,o,a,c,u=this;return s(this,function(l){switch(l.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,c,l,d;return s(this,function(s){switch(s.label){case 0:i=new AbortController,a=setTimeout(function(){return i.abort()},t),s.label=1;case 1:return s.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:i.signal})];case 2:return(c=s.sent()).ok?[3,4]:[4,c.text()];case 3:return l=s.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(c.status,": ").concat(l)),[3,6];case 4:return[4,c.json()];case 5:return[2,{value:{remoteConfig:s.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=s.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(a),[7];case 9:return r<e-1?[4,new Promise(function(e){return setTimeout(e,u.getJitterDelay(n))})]:[3,11];case 10:s.sent(),s.label=11;case 11:return[2]}})},o=this,a=0,l.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(c=l.sent()))return[2,c.value];l.label=3;case 3:return a++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}();!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(D||(D={}));var W,K="[Amplitude]",z="".concat(K," Session Replay ID"),J=D.US,G={enabled:!0},H="".concat(K," Session Replay Debug"),$="amp-mask";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata",e.TARGETING_DECISION="targeting-decision"}(W||(W={}));var Q=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){var t;if(!this.logger)return function(){};var n=this.logger[e];return"function"==typeof n?(null!==(t=n.__rrweb_original__)&&void 0!==t?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),V="medium";var X=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return X(e,V,n)}},Z=function(e,t){return function(n,r){return function(e,t,n){var r,i,o;if(void 0===t&&(t={defaultMaskLevel:V}),n){if(n.closest("."+$))return!0;var s=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some(function(e){return n.closest(e)});if(s)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(i=t.unmaskSelector)&&void 0!==i?i:[]).some(function(e){return n.closest(e)});if(a)return!1}return X(e,null!==(o=t.defaultMaskLevel)&&void 0!==o?o:V,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Y=function(e,t){return t||(e===D.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===D.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track")},ee=function(e){var t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp("^".concat(t,"$"))},te=function(e,t){var n,r;try{for(var i=a(t),o=i.next();!o.done;o=i.next()){var s=o.value,c=ee(s.selector);if(c.test(e))return e.replace(c,s.replacement)}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},ne=function(){return o(void 0,void 0,void 0,function(){var e,t,n,r,i,o,a;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),(e=g())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=s.sent(),n=t.usage,r=t.quota,i=t.usageDetails,o=n?Math.round(n/1024):0,a=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:o,percentOfQuota:a,usageDetails:JSON.stringify(i)}];case 2:return[3,4];case 3:return s.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},re=function(e){var t=i({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},ie=function(){return{flushMaxRetries:2,logLevel:h.Warn,loggerProvider:new S,transportProvider:new A}},oe=function(e){function n(t,n){var r,o,s,a,c,u=this,l=ie();return(u=e.call(this,i(i({transportProvider:l.transportProvider,loggerProvider:new Q(n.loggerProvider||l.loggerProvider)},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=l.flushMaxRetries?n.flushMaxRetries:l.flushMaxRetries,u.apiKey=t,u.sampleRate=n.sampleRate||0,u.serverZone=n.serverZone||J,u.configServerUrl=n.configServerUrl,u.trackServerUrl=n.trackServerUrl,u.shouldInlineStylesheet=n.shouldInlineStylesheet,u.version=n.version,u.performanceConfig=n.performanceConfig||G,u.storeType=null!==(r=n.storeType)&&void 0!==r?r:"idb",u.applyBackgroundColorToBlockedElements=null!==(o=n.applyBackgroundColorToBlockedElements)&&void 0!==o&&o,u.enableUrlChangePolling=null!==(s=n.enableUrlChangePolling)&&void 0!==s&&s,u.urlChangePollingInterval=null!==(a=n.urlChangePollingInterval)&&void 0!==a?a:1e3,u.captureDocumentTitle=null!==(c=n.captureDocumentTitle)&&void 0!==c&&c,n.privacyConfig&&(u.privacyConfig=n.privacyConfig),n.interactionConfig&&(u.interactionConfig=n.interactionConfig,u.interactionConfig.ugcFilterRules&&function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t);var t}))throw new Error("ugcFilterRules must be an array of objects with valid globs")}(u.interactionConfig.ugcFilterRules)),n.debugMode&&(u.debugMode=n.debugMode),n.experimental&&(u.experimental=n.experimental),n.omitElementTags&&(u.omitElementTags=n.omitElementTags),u}return t(n,e),n}(I),se=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(se||{}),ae=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ae||{}),ce=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,n;return o(this,void 0,void 0,function(){var r,o,u,l,d,f,v,h,g,p,m,y,b,S,w,I,C=this;return s(this,function(s){switch(s.label){case 0:return(r=i({},this.localConfig)).optOut=this.localConfig.optOut,r.captureEnabled=!0,[4,new Promise(function(e){C.remoteConfigClient.subscribe("configs.sessionReplay","all",function(t,n){var i;if(C.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(n,":"),JSON.stringify(t,null,2)),t){var s=t,a=s.sr_sampling_config,c=s.sr_privacy_config,u=s.sr_targeting_config,l=null===(i=r.interactionConfig)||void 0===i?void 0:i.ugcFilterRules;r.interactionConfig=s.sr_interaction_config,r.interactionConfig&&l&&(r.interactionConfig.ugcFilterRules=l),r.loggingConfig=s.sr_logging_config,(a||c||u)&&(o={},a&&(o.sr_sampling_config=a),c&&(o.sr_privacy_config=c),u&&(o.sr_targeting_config=u))}e()})})];case 1:if(s.sent(),!o)return[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:o}];if(u=o.sr_sampling_config,l=o.sr_privacy_config,d=o.sr_targeting_config,u&&Object.keys(u).length>0?(Object.prototype.hasOwnProperty.call(u,"capture_enabled")?r.captureEnabled=u.capture_enabled:r.captureEnabled=!1,Object.prototype.hasOwnProperty.call(u,"sample_rate")&&(r.sampleRate=u.sample_rate)):(r.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),l){f=null!==(e=r.privacyConfig)&&void 0!==e?e:{},v={defaultMaskLevel:null!==(n=null!==(t=l.defaultMaskLevel)&&void 0!==t?t:f.defaultMaskLevel)&&void 0!==n?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},h=function(e){var t,n,r,i,o,s,c,u,l,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var f=a(null!==(c=e.blockSelector)&&void 0!==c?c:[]),v=f.next();!v.done;v=f.next()){d[v.value]="block"}}catch(e){t={error:e}}finally{try{v&&!v.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}try{for(var h=a(null!==(u=e.maskSelector)&&void 0!==u?u:[]),g=h.next();!g.done;g=h.next()){d[g.value]="mask"}}catch(e){r={error:e}}finally{try{g&&!g.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}try{for(var p=a(null!==(l=e.unmaskSelector)&&void 0!==l?l:[]),m=p.next();!m.done;m=p.next()){d[m.value]="unmask"}}catch(e){o={error:e}}finally{try{m&&!m.done&&(s=p.return)&&s.call(p)}finally{if(o)throw o.error}}return d},g=i(i({},h(f)),h(l));try{for(p=a(Object.entries(g)),m=p.next();!m.done;m=p.next())y=c(m.value,2),b=y[0],"mask"===(S=y[1])?v.maskSelector.push(b):"block"===S?v.blockSelector.push(b):"unmask"===S&&v.unmaskSelector.push(b)}catch(e){w={error:e}}finally{try{m&&!m.done&&(I=p.return)&&I.call(p)}finally{if(w)throw w.error}}r.privacyConfig=(E=v,P=this.localConfig.loggerProvider,k=document.createDocumentFragment(),x=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter(function(e){try{k.querySelector(e)}catch(t){return P.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0}),0!==e.length)return e},E.blockSelector=x(E.blockSelector),E.maskSelector=x(E.maskSelector),E.unmaskSelector=x(E.unmaskSelector),E)}return d&&Object.keys(d).length>0&&(r.targetingConfig=d),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:re(r)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:r,remoteConfig:o}]}var E,P,k,x})})},e}(),ue=function(e,t){return o(void 0,void 0,void 0,function(){var n,r;return s(this,function(i){return n=new oe(e,t),r=new B(e,n.loggerProvider,n.serverZone,t.configServerUrl),[2,new ce(r,n)]})})},le=Uint8Array,de=Uint16Array,fe=Uint32Array,ve=new le([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),he=new le([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ge=new le([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pe=function(e,t){for(var n=new de(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new fe(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return[n,i]},me=pe(ve,2),ye=me[0],be=me[1];ye[28]=258,be[258]=28;for(var Se=pe(he,0)[1],we=new de(32768),Ie=0;Ie<32768;++Ie){var Ce=(43690&Ie)>>>1|(21845&Ie)<<1;Ce=(61680&(Ce=(52428&Ce)>>>2|(13107&Ce)<<2))>>>4|(3855&Ce)<<4,we[Ie]=((65280&Ce)>>>8|(255&Ce)<<8)>>>1}var Ee=function(e,t,n){for(var r=e.length,i=0,o=new de(t);i<r;++i)++o[e[i]-1];var s,a=new de(t);for(i=0;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;if(n){s=new de(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],l=t-e[i],d=a[e[i]-1]++<<l,f=d|(1<<l)-1;d<=f;++d)s[we[d]>>>c]=u}else for(s=new de(r),i=0;i<r;++i)s[i]=we[a[e[i]-1]++]>>>15-e[i];return s},Pe=new le(288);for(Ie=0;Ie<144;++Ie)Pe[Ie]=8;for(Ie=144;Ie<256;++Ie)Pe[Ie]=9;for(Ie=256;Ie<280;++Ie)Pe[Ie]=7;for(Ie=280;Ie<288;++Ie)Pe[Ie]=8;var ke=new le(32);for(Ie=0;Ie<32;++Ie)ke[Ie]=5;var xe=Ee(Pe,9,0),_e=Ee(ke,5,0),Re=function(e){return(e/8|0)+(7&e&&1)},Te=function(e,t,n){(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof de?de:e instanceof fe?fe:le)(n-t);return r.set(e.subarray(t,n)),r},Oe=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},Me=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},De=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,o=n.slice();if(!i)return[new le(0),0];if(1==i){var s=new le(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],u=0,l=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=i-1;)a=n[n[u].f<n[d].f?u++:d++],c=n[u!=l&&n[u].f<n[d].f?u++:d++],n[l++]={s:-1,f:a.f+c.f,l:a,r:c};var f=o[0].s;for(r=1;r<i;++r)o[r].s>f&&(f=o[r].s);var v=new de(f+1),h=Le(n[l-1],v,0);if(h>t){r=0;var g=0,p=h-t,m=1<<p;for(o.sort(function(e,t){return v[t.s]-v[e.s]||e.f-t.f});r<i;++r){var y=o[r].s;if(!(v[y]>t))break;g+=m-(1<<h-v[y]),v[y]=t}for(g>>>=p;g>0;){var b=o[r].s;v[b]<t?g-=1<<t-v[b]++-1:++r}for(;r>=0&&g;--r){var S=o[r].s;v[S]==t&&(--v[S],++g)}h=t}return[new le(v),h]},Le=function(e,t,n){return-1==e.s?Math.max(Le(e.l,t,n+1),Le(e.r,t,n+1)):t[e.s]=n},qe=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new de(++t),r=0,i=e[0],o=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==i&&a!=t)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=e[a]}return[n.subarray(0,r),t]},Ne=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},je=function(e,t,n){var r=n.length,i=Re(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var o=0;o<r;++o)e[i+o+4]=n[o];return 8*(i+4+r)},Ue=function(e,t,n,r,i,o,s,a,c,u,l){Oe(t,l++,n),++i[256];for(var d=De(i,15),f=d[0],v=d[1],h=De(o,15),g=h[0],p=h[1],m=qe(f),y=m[0],b=m[1],S=qe(g),w=S[0],I=S[1],C=new de(19),E=0;E<y.length;++E)C[31&y[E]]++;for(E=0;E<w.length;++E)C[31&w[E]]++;for(var P=De(C,7),k=P[0],x=P[1],_=19;_>4&&!k[ge[_-1]];--_);var R,T,O,M,D=u+5<<3,L=Ne(i,Pe)+Ne(o,ke)+s,q=Ne(i,f)+Ne(o,g)+s+14+3*_+Ne(C,k)+(2*C[16]+3*C[17]+7*C[18]);if(D<=L&&D<=q)return je(t,l,e.subarray(c,c+u));if(Oe(t,l,1+(q<L)),l+=2,q<L){R=Ee(f,v,0),T=f,O=Ee(g,p,0),M=g;var N=Ee(k,x,0);Oe(t,l,b-257),Oe(t,l+5,I-1),Oe(t,l+10,_-4),l+=14;for(E=0;E<_;++E)Oe(t,l+3*E,k[ge[E]]);l+=3*_;for(var j=[y,w],U=0;U<2;++U){var A=j[U];for(E=0;E<A.length;++E){var F=31&A[E];Oe(t,l,N[F]),l+=k[F],F>15&&(Oe(t,l,A[E]>>>5&127),l+=A[E]>>>12)}}}else R=xe,T=Pe,O=_e,M=ke;for(E=0;E<a;++E)if(r[E]>255){F=r[E]>>>18&31;Me(t,l,R[F+257]),l+=T[F+257],F>7&&(Oe(t,l,r[E]>>>23&31),l+=ve[F]);var B=31&r[E];Me(t,l,O[B]),l+=M[B],B>3&&(Me(t,l,r[E]>>>5&8191),l+=he[B])}else Me(t,l,R[r[E]]),l+=T[r[E]];return Me(t,l,R[256]),l+T[256]},Ae=new fe([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fe=function(e,t,n,r,i){return function(e,t,n,r,i,o){var s=e.length,a=new le(r+s+5*(1+Math.floor(s/7e3))+i),c=a.subarray(r,a.length-i),u=0;if(!t||s<8)for(var l=0;l<=s;l+=65535){var d=l+65535;d<s?u=je(c,u,e.subarray(l,d)):(c[l]=o,u=je(c,u,e.subarray(l,s)))}else{for(var f=Ae[t-1],v=f>>>13,h=8191&f,g=(1<<n)-1,p=new de(32768),m=new de(g+1),y=Math.ceil(n/3),b=2*y,S=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<b)&g},w=new fe(25e3),I=new de(288),C=new de(32),E=0,P=0,k=(l=0,0),x=0,_=0;l<s;++l){var R=S(l),T=32767&l,O=m[R];if(p[T]=O,m[R]=T,x<=l){var M=s-l;if((E>7e3||k>24576)&&M>423){u=Ue(e,c,0,w,I,C,P,k,_,l-_,u),k=E=P=0,_=l;for(var D=0;D<286;++D)I[D]=0;for(D=0;D<30;++D)C[D]=0}var L=2,q=0,N=h,j=T-O&32767;if(M>2&&R==S(l-j))for(var U=Math.min(v,M)-1,A=Math.min(32767,l),F=Math.min(258,M);j<=A&&--N&&T!=O;){if(e[l+L]==e[l+L-j]){for(var B=0;B<F&&e[l+B]==e[l+B-j];++B);if(B>L){if(L=B,q=j,B>U)break;var W=Math.min(j,B-2),K=0;for(D=0;D<W;++D){var z=l-j+D+32768&32767,J=z-p[z]+32768&32767;J>K&&(K=J,O=z)}}}j+=(T=O)-(O=p[T])+32768&32767}if(q){w[k++]=268435456|be[L]<<18|Se[q];var G=31&be[L],H=31&Se[q];P+=ve[G]+he[H],++I[257+G],++C[H],x=l+L,++E}else w[k++]=e[l],++I[e[l]]}}u=Ue(e,c,o,w,I,C,P,k,_,l-_,u)}return Te(a,0,r+Re(u)+i)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!i)};function Be(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,o=n.length,s=0;s!=o;){for(var a=Math.min(s+5552,o);s<a;++s)i+=r+=n[s];r%=65521,i%=65521}e=r,t=i},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r,i,o,s=Fe(e,t,2,4);return r=s,i=t.level,o=0==i?0:i<6?1:9==i?3:2,r[0]=120,r[1]=o<<6|(o?32-2*o:1),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(s,s.length-4,n.d()),s}const We=e=>{const t={...e,v:"v1"};return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var i=e[r++];i<128||t?n+=String.fromCharCode(i):i<224?n+=String.fromCharCode((31&i)<<6|63&e[r++]):i<240?n+=String.fromCharCode((15&i)<<12|(63&e[r++])<<6|63&e[r++]):(i=((15&i)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}return n}(Be(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new le(e.length+(e.length>>>1)),i=0,o=function(e){r[i++]=e},s=0;s<n;++s){if(i+5>r.length){var a=new le(i+8+(n-s<<1));a.set(r),r=a}var c=e.charCodeAt(s);c<128||t?o(c):c<2048?(o(192|c>>>6),o(128|63&c)):c>55295&&c<57344?(o(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++s))>>>18),o(128|c>>>12&63),o(128|c>>>6&63),o(128|63&c)):(o(224|c>>>12),o(128|c>>>6&63),o(128|63&c))}return Te(r,0,i)}(JSON.stringify(t))),!0)};var Ke=function(){function e(e,t,n,r){var i,o=this;this.taskQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=We(e);return JSON.stringify(t)},this.addCompressedEventToManager=function(e,t){o.eventsManager&&o.deviceId&&o.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:o.deviceId})},this.addCompressedEvent=function(e,t){if(o.worker)try{o.worker.postMessage({event:e,sessionId:t})}catch(n){"DataCloneError"===n.name?o.worker.postMessage(JSON.stringify({event:e,sessionId:t})):o.config.loggerProvider.warn("Unexpected error while posting message to worker:",n)}else{var n=o.compressEvent(e);o.addCompressedEventToManager(n,t)}},this.terminate=function(){var e;null===(e=o.worker)||void 0===e||e.terminate()};var s=g();if(this.canUseIdleCallback=s&&"requestIdleCallback"in s,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null===(i=t.performanceConfig)||void 0===i?void 0:i.timeout)||2e3,r){t.loggerProvider.log("[Experimental] Enabling web worker for compression");var a=new Worker(URL.createObjectURL(new Blob([r],{type:"application/javascript"})));a.onerror=function(e){t.loggerProvider.error(e)},a.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;o.addCompressedEventToManager(n,r)},this.worker=a}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n;this.canUseIdleCallback&&(null===(n=this.config.performanceConfig)||void 0===n?void 0:n.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.taskQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){for(var t=this;this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var n=this.taskQueue.shift();if(n){var r=n.event,i=n.sessionId;this.addCompressedEvent(r,i)}}this.taskQueue.length>0?requestIdleCallback(function(e){t.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e}(),ze="Failed to store session replay events in IndexedDB",Je="1.29.5-zen-plus-zoning.0",Ge=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t}return e.prototype.sendEventsList=function(e){this.addToQueue(i(i({},e),{attempts:0,timeout:0}))},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter(function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"Session replay event batch rejected due to exceeded retry count"}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout(function(){t.timeout=0,e.schedule(0)},t.timeout):e.schedule(0)})},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,function(){var t,n,r=this;return s(this,function(i){switch(i.label){case 0:return t=[],n=[],this.queue.forEach(function(e){return 0===e.timeout?t.push(e):n.push(e)}),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map(function(t){return r.send(t,e)}))];case 1:return i.sent(),[2]}})})},e.prototype.send=function(e,t){var n,r;return void 0===t&&(t=!0),o(this,void 0,void 0,function(){var i,o,a,c,u,l,d,f,v,h,p,m,y;return s(this,function(s){switch(s.label){case 0:if(!(i=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(o=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(b=g(),a=(null==b?void 0:b.location)?b.location.href:"",c=Je,u=e.sampleRate,l=new URLSearchParams({device_id:o,session_id:"".concat(e.sessionId),type:"".concat(e.type)}),d="".concat((null===(n=e.version)||void 0===n?void 0:n.type)||"standalone","/").concat((null===(r=e.version)||void 0===r?void 0:r.version)||c),0===(f=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];s.label=1;case 1:return s.trys.push([1,3,,4]),v={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(i),"X-Client-Version":c,"X-Client-Library":d,"X-Client-Url":a.substring(0,1e3),"X-Client-Sample-Rate":"".concat(u)},body:JSON.stringify(f),method:"POST"},h="".concat(Y(e.serverZone,this.trackServerUrl),"?").concat(l.toString()),[4,fetch(h,v)];case 2:if(null===(p=s.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(p.status,e);else{m="";try{m=JSON.stringify(p.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(p.status,": ").concat(m)})}return[3,4];case 3:return y=s.sent(),this.completeRequest({context:e,err:y}),[3,4];case 4:return[2]}var b})})},e.prototype.handleReponse=function(e,t){switch((new U).buildStatus(e)){case l.Success:this.handleSuccessResponse(t);break;case l.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){this.addToQueue(i(i({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}();const He=(e,t)=>t.some(t=>e instanceof t);let $e,Qe;const Ve=new WeakMap,Xe=new WeakMap,Ze=new WeakMap;let Ye={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Ve.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return rt(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function et(e){Ye=e(Ye)}function tt(e){return(Qe||(Qe=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(it(this),t),rt(this.request)}:function(...t){return rt(e.apply(it(this),t))}}function nt(e){return"function"==typeof e?tt(e):(e instanceof IDBTransaction&&function(e){if(Ve.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",o),e.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",o),e.addEventListener("abort",o)});Ve.set(e,t)}(e),He(e,$e||($e=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Ye):e)}function rt(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",o)},i=()=>{t(rt(e.result)),r()},o=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",o)});return Ze.set(t,e),t}(e);if(Xe.has(e))return Xe.get(e);const t=nt(e);return t!==e&&(Xe.set(e,t),Ze.set(t,e)),t}const it=e=>Ze.get(e);function ot(e,t,{blocked:n,upgrade:r,blocking:i,terminated:o}={}){const s=indexedDB.open(e,t),a=rt(s);return r&&s.addEventListener("upgradeneeded",e=>{r(rt(s.result),e.oldVersion,e.newVersion,rt(s.transaction),e)}),n&&s.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{o&&e.addEventListener("close",()=>o()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}const st=["get","getKey","getAll","getAllKeys","count"],at=["put","add","delete","clear"],ct=new Map;function ut(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(ct.get(t))return ct.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=at.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!st.includes(n))return;const o=async function(e,...t){const o=this.transaction(e,i?"readwrite":"readonly");let s=o.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),i&&o.done]))[0]};return ct.set(t,o),o}et(e=>({...e,get:(t,n,r)=>ut(t,n)||e.get(t,n,r),has:(t,n)=>!!ut(t,n)||e.has(t,n)}));const lt=["continue","continuePrimaryKey","advance"],dt={},ft=new WeakMap,vt=new WeakMap,ht={get(e,t){if(!lt.includes(t))return e[t];let n=dt[t];return n||(n=dt[t]=function(...e){ft.set(this,vt.get(this)[t](...e))}),n}};async function*gt(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,ht);for(vt.set(n,t),Ze.set(n,it(t));t;)yield n,t=await(ft.get(n)||t.continue()),ft.delete(n)}function pt(e,t){return t===Symbol.asyncIterator&&He(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&He(e,[IDBIndex,IDBObjectStore])}et(e=>({...e,get:(t,n,r)=>pt(t,n)?gt:e.get(t,n,r),has:(t,n)=>pt(t,n)||e.has(t,n)}));var mt,yt=function(){function e(e){var t,n,r,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=1e6,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>=i.maxPersistedEventsSize||!!(Date.now()-i.timeAtLastSplit>i.interval&&e.length)&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!==(t=e.minInterval)&&void 0!==t?t:this.minInterval,this.maxInterval=null!==(n=e.maxInterval)&&void 0!==n?n:this.maxInterval,this.maxPersistedEventsSize=null!==(r=e.maxPersistedEventsSize)&&void 0!==r?r:this.maxPersistedEventsSize}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){return e.length},e.prototype.getEventsArraySize=function(e){var t,n,r=0;try{for(var i=a(e),o=i.next();!o.done;o=i.next()){var s=o.value;r+=this.getStringSize(s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}();!function(e){e.RECORDING="recording",e.SENT="sent"}(mt||(mt={}));var bt,St,wt,It="sessionCurrentSequence",Ct="sequencesToSend",Et=function(){var e=g();return new Promise(function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)},r.onerror=function(){n(r.error)}}catch(e){n(e)}})},Pt=function(e){return o(void 0,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return e.length>0?(t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}})})},kt=function(e){var t,n;return e.objectStoreNames.contains(It)||(n=e.createObjectStore(It,{keyPath:"sessionId"})),e.objectStoreNames.contains(Ct)||(t=e.createObjectStore(Ct,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},xt=function(e){return o(void 0,void 0,void 0,function(){return s(this,function(t){switch(t.label){case 0:return[4,ot(e,1,{upgrade:kt})];case 1:return[2,t.sent()]}})})},_t=function(e){function n(t){var n=e.call(this,t)||this;return n.getSequencesToSend=function(){return o(n,void 0,void 0,function(){var e,t,n,r,i,o;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,5,,6]),e=[],[4,this.db.transaction("sequencesToSend").store.openCursor()];case 1:t=s.sent(),s.label=2;case 2:return t?(n=t.value,r=n.sessionId,i=n.events,e.push({events:i,sequenceId:t.key,sessionId:r}),[4,t.continue()]):[3,4];case 3:return t=s.sent(),[3,2];case 4:return[2,e];case 5:return o=s.sent(),this.loggerProvider.warn("".concat(ze,": ").concat(o)),[3,6];case 6:return[2,void 0]}})})},n.storeCurrentSequence=function(e){return o(n,void 0,void 0,function(){var t,n,r;return s(this,function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),[4,this.db.get(It,e)];case 1:return(t=o.sent())?[4,this.db.put(Ct,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=o.sent(),[4,this.db.put(It,{sessionId:e,events:[]})];case 3:return o.sent(),[2,i(i({},t),{sessionId:e,sequenceId:n})];case 4:return r=o.sent(),this.loggerProvider.warn("".concat(ze,": ").concat(r)),[3,5];case 5:return[2,void 0]}})})},n.addEventToCurrentSequence=function(e,t){return o(n,void 0,void 0,function(){var n,r,i,o,a,c;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,10,,11]),[4,(n=this.db.transaction(It,"readwrite")).store.get(e)];case 1:return(r=s.sent())?[3,3]:[4,n.store.put({sessionId:e,events:[t]})];case 2:return s.sent(),[2];case 3:return i=void 0,this.shouldSplitEventsList(r.events,t)?(i=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,5];case 4:return s.sent(),[3,7];case 5:return o=r.events.concat(t),[4,n.store.put({sessionId:e,events:o})];case 6:s.sent(),s.label=7;case 7:return[4,n.done];case 8:return s.sent(),i?[4,this.storeSendingEvents(e,i)]:[2,void 0];case 9:return(a=s.sent())?[2,{events:i,sessionId:e,sequenceId:a}]:[2,void 0];case 10:return c=s.sent(),this.loggerProvider.warn("".concat(ze,": ").concat(c)),[3,11];case 11:return[2,void 0]}})})},n.storeSendingEvents=function(e,t){return o(n,void 0,void 0,function(){var n;return s(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.db.put(Ct,{sessionId:e,events:t})];case 1:return[2,r.sent()];case 2:return n=r.sent(),this.loggerProvider.warn("".concat(ze,": ").concat(n)),[3,3];case 3:return[2,void 0]}})})},n.cleanUpSessionEventsStore=function(e,t){return o(n,void 0,void 0,function(){var e;return s(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Ct,t)];case 2:return n.sent(),[3,4];case 3:return e=n.sent(),this.loggerProvider.warn("".concat(ze,": ").concat(e)),[3,4];case 4:return[2]}})})},n.transitionFromKeyValStore=function(e){return o(n,void 0,void 0,function(){var t,n,r,i,a,l,f,v,h=this;return s(this,function(p){switch(p.label){case 0:return p.trys.push([0,6,,7]),[4,Et()];case 1:if(!(t=p.sent()))return[2];n=function(e,t){return o(h,void 0,void 0,function(){var n,r,i=this;return s(this,function(a){switch(a.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach(function(a){var l=parseInt(a,10),d=n[l];if(l===t.currentSequenceId){var f=d.events.map(function(t){return o(i,void 0,void 0,function(){return s(this,function(n){return[2,this.addEventToCurrentSequence(e,t)]})})});r.push.apply(r,u([],c(f),!1))}else d.status!==mt.SENT&&r.push(i.storeSendingEvents(e,d.events))}),[4,Pt(r)];case 1:return a.sent(),[2]}})})},r="".concat(d,"_").concat(this.apiKey.substring(0,10)),p.label=2;case 2:return p.trys.push([2,4,,5]),i=t.transaction("keyval").objectStore("keyval").getAll(r),a=new Promise(function(t){i.onsuccess=function(r){return o(h,void 0,void 0,function(){var i,o,a,c=this;return s(this,function(s){switch(s.label){case 0:return i=r&&r.target.result,(o=i&&i[0])?(a=[],Object.keys(o).forEach(function(t){var r=parseInt(t,10),i=o[r];if(e===r)a.push(n(r,i));else{var s=i.sessionSequences;Object.keys(s).forEach(function(e){var t=parseInt(e,10);s[t].status!==mt.SENT&&a.push(c.storeSendingEvents(r,s[t].events))})}}),[4,Pt(a)]):[3,2];case 1:s.sent(),s.label=2;case 2:return t(),[2]}})})}}),[4,a];case 3:return p.sent(),(l=g())&&l.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return f=p.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(f)),[3,5];case 5:return[3,7];case 6:return v=p.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(v,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}})})},n.apiKey=t.apiKey,n.db=t.db,n}return t(n,e),n.new=function(e,t,r){return o(this,void 0,void 0,function(){var o,a,c,u,l;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),o="replay"===e?"":"_".concat(e),a="".concat(t.apiKey.substring(0,10),"_amp_session_replay_events").concat(o),[4,xt(a)];case 1:return c=s.sent(),[4,(u=new n(i(i({},t),{db:c}))).transitionFromKeyValStore(r)];case 2:return s.sent(),[2,u];case 3:return l=s.sent(),t.loggerProvider.warn("".concat(ze,": ").concat(l)),[3,4];case 4:return[2]}})})},n.prototype.getCurrentSequenceEvents=function(e){return o(this,void 0,void 0,function(){var t,n,r,i,o,c,u;return s(this,function(s){switch(s.label){case 0:return e?[4,this.db.get("sessionCurrentSequence",e)]:[3,2];case 1:return(i=s.sent())?[2,[i]]:[2,void 0];case 2:t=[],s.label=3;case 3:return s.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:n=a.apply(void 0,[s.sent()]),r=n.next(),s.label=5;case 5:if(r.done)return[3,7];i=r.value,t.push(i),s.label=6;case 6:return r=n.next(),[3,5];case 7:return[3,10];case 8:return o=s.sent(),c={error:o},[3,10];case 9:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}return[7];case 10:return[2,t]}})})},n}(yt),Rt=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return t(n,e),n.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},n.prototype.addSequence=function(e){var t=this.sequenceId++,n=u([],c(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},n.prototype.getSequencesToSend=function(){return o(this,void 0,void 0,function(){return s(this,function(e){return[2,Object.entries(this.finalizedSequences).map(function(e){var t=c(e,2),n=t[0],r=t[1],i=r.sessionId,o=r.events;return{sequenceId:Number(n),sessionId:i,events:o}})]})})},n.prototype.storeCurrentSequence=function(e){return o(this,void 0,void 0,function(){return s(this,function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]})})},n.prototype.addEventToCurrentSequence=function(e,t){return o(this,void 0,void 0,function(){var n;return s(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},n.prototype.storeSendingEvents=function(e,t){return o(this,void 0,void 0,function(){return s(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},n.prototype.cleanUpSessionEventsStore=function(e,t){return o(this,void 0,void 0,function(){return s(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},n}(yt),Tt=function(e){var t=e.config,n=e.sessionId,r=e.minInterval,a=e.maxInterval,c=e.type,u=e.payloadBatcher,l=e.storeType;return o(void 0,void 0,void 0,function(){function e(e){return void 0===e&&(e=!1),o(this,void 0,void 0,function(){return s(this,function(t){return[2,d.flush(e)]})})}var d,f,v,h,g,p,m,y,b;return s(this,function(S){switch(S.label){case 0:return d=new Ge(i(i({},t),{loggerProvider:t.loggerProvider,payloadBatcher:u})),f=function(){return new Rt({loggerProvider:t.loggerProvider,maxInterval:a,minInterval:r})},v=function(){return o(void 0,void 0,void 0,function(){var e;return s(this,function(i){switch(i.label){case 0:return[4,_t.new(c,{loggerProvider:t.loggerProvider,minInterval:r,maxInterval:a,apiKey:t.apiKey},n)];case 1:return e=i.sent(),t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,null!=e?e:f()]}})})},"idb"!==l?[3,2]:[4,v()];case 1:return g=S.sent(),[3,3];case 2:g=f(),S.label=3;case 3:return h=g,p=function(e){var n=e.events,r=e.sessionId,i=e.deviceId,a=e.sequenceId;t.debugMode&&ne().then(function(e){var n=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(i))}).catch(function(){}),d.sendEventsList({events:n,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:i,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:c,onComplete:function(){return o(void 0,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,h.cleanUpSessionEventsStore(r,a)];case 1:return e.sent(),[2]}})})}})},m=function(e){var n=e.sessionId,r=e.deviceId;h.storeCurrentSequence(n).then(function(e){e&&p({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})},y=function(e){var t=e.deviceId;return o(void 0,void 0,void 0,function(){var e;return s(this,function(n){switch(n.label){case 0:return[4,h.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach(function(e){p({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})}),[2]}})})},b=function(e){var n=e.event,r=e.sessionId,i=e.deviceId;h.addEventToCurrentSequence(r,n.data).then(function(e){return e&&p({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})}).catch(function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)})},[2,{sendCurrentSequenceEvents:m,addEvent:b,sendStoredEvents:y,flush:e}]}})})},Ot=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach(function(e){n.set(e.name,e.manager)}),this.managers=n}return e.prototype.sendStoredEvents=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,i=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},e.prototype.flush=function(e){return o(this,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e}();function Mt(e,t){if(wt=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};bt=i(i({},n),t),St=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(bt.root,n);var r=Dt(e,"all",function(){return Dt(e,"two",function(){return Dt(e,"one",function(){return Dt(e,"none")})})});if(r){var o=Kt(zt(r,e));return o.length>0&&(r=o[0]),qt(r)}throw new Error("Selector was not found.")}function Dt(e,t,n){for(var r=null,i=[],o=e,s=0,l=function(){var e,l,d=(new Date).getTime()-wt.getTime();if(void 0!==bt.timeoutMs&&d>bt.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var f=Ft(function(e){var t=e.getAttribute("id");if(t&&bt.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(o))||Ft.apply(void 0,u([],c(function(e){var t=Array.from(e.attributes).filter(function(e){return bt.attr(e.name,e.value)});return t.map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})}(o)),!1))||Ft.apply(void 0,u([],c(function(e){var t=Array.from(e.classList).filter(bt.className);return t.map(function(e){return{name:"."+CSS.escape(e),penalty:1}})}(o)),!1))||Ft(function(e){var t=e.tagName.toLowerCase();if(bt.tagName(t))return{name:t,penalty:2};return null}(o))||[{name:"*",penalty:3}],v=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(o);if("all"==t)v&&(f=f.concat(f.filter(At).map(function(e){return Ut(e,v)})));else if("two"==t)f=f.slice(0,1),v&&(f=f.concat(f.filter(At).map(function(e){return Ut(e,v)})));else if("one"==t){var h=c(f=f.slice(0,1),1)[0];v&&At(h)&&(f=[Ut(h,v)])}else"none"==t&&(f=[{name:"*",penalty:3}],v&&(f=[Ut(f[0],v)]));try{for(var g=(e=void 0,a(f)),p=g.next();!p.done;p=g.next()){(h=p.value).level=s}}catch(t){e={error:t}}finally{try{p&&!p.done&&(l=g.return)&&l.call(g)}finally{if(e)throw e.error}}if(i.push(f),i.length>=bt.seedMinLength&&(r=Lt(i,n)))return"break";o=o.parentElement,s++};o;){if("break"===l())break}return r||(r=Lt(i,n)),!r&&n?n():r}function Lt(e,t){var n,r,i=Kt(Wt(e));if(i.length>bt.threshold)return t?t():null;try{for(var o=a(i),s=o.next();!s.done;s=o.next()){var c=s.value;if(jt(c))return c}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null}function qt(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var i=e[r].level||0;n=t.level===i-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function Nt(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function jt(e){var t=qt(e);switch(St.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function Ut(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function At(e){return"html"!==e.name&&!e.name.startsWith("#")}function Ft(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Bt);return n.length>0?n:null}function Bt(e){return null!=e}function Wt(e,t){var n,r,i,o,c,u;return void 0===t&&(t=[]),s(this,function(s){switch(s.label){case 0:if(!(e.length>0))return[3,9];s.label=1;case 1:s.trys.push([1,6,7,8]),n=a(e[0]),r=n.next(),s.label=2;case 2:return r.done?[3,5]:(i=r.value,[5,a(Wt(e.slice(1,e.length),t.concat(i)))]);case 3:s.sent(),s.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o=s.sent(),c={error:o},[3,8];case 7:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(c)throw c.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:s.sent(),s.label=11;case 11:return[2]}})}function Kt(e){return u([],c(e),!1).sort(function(e,t){return Nt(e)-Nt(t)})}function zt(e,t,n){var r,i,o;return void 0===n&&(n={counter:0,visited:new Map}),s(this,function(s){switch(s.label){case 0:if(!(e.length>2&&e.length>bt.optimizedMinLength))return[3,5];r=1,s.label=1;case 1:return r<e.length-1?n.counter>bt.maxNumberOfTries?[2]:(n.counter+=1,(i=u([],c(e),!1)).splice(r,1),o=qt(i),n.visited.has(o)?[2]:jt(i)&&function(e,t){return St.querySelector(qt(e))===t}(i,t)?[4,i]:[3,4]):[3,5];case 2:return s.sent(),n.visited.set(o,!0),[5,a(zt(i,t,n))];case 3:s.sent(),s.label=4;case 4:return r++,[3,1];case 5:return[2]}})}var Jt=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)}),{version:t,events:r}},Gt=function(e){var t=e.version,n=e.events,r=[];n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)});var o=r.reduce(function(e,t){var n=t.x,r=t.y,o=t.selector,s=t.timestamp,a=s-s%36e5,c="".concat(n,":").concat(r,":").concat(null!=o?o:"",":").concat(a);return e[c]?e[c].count+=1:e[c]=i(i({},t),{timestamp:a,count:1}),e},{});return{version:t,events:Object.values(o)}},Ht=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,o=e.mirror,s=e.ugcFilterRules;return function(e){if(e.type===ae.Click){var a=g();if(a){var c=a.location,u=a.innerHeight,l=a.innerWidth;if(c){var d=e.x,f=e.y;if(void 0!==d&&void 0!==f){var v,h=o.getNode(e.id);if(h)try{v=Mt(h)}catch(e){n.logger.debug("error resolving selector from finder")}var p=te(c.href,s),m={x:d+n.scrollWatcher.currentScrollX,y:f+n.scrollWatcher.currentScrollY,selector:v,viewportHeight:u,viewportWidth:l,pageUrl:p,timestamp:Date.now(),type:"click"},y=i();y&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(m)},deviceId:y})}}}}}},this.logger=e,this.scrollWatcher=t};function $t(){var e=g();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight||0}function Qt(){var e=g();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth||0}var Vt=function(){function e(e,t){var n=g();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(e){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=Y(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,i=n.type,o=new URLSearchParams({device_id:e,session_id:String(r),type:String(i),api_key:this.apiKey}),s="".concat(this.basePageUrl,"?").concat(o.toString());this.sendBeacon(s,t)||this.sendXhr(s,t)},e}(),Xt=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,i,o=e(),s=g();s&&o&&n.transport.send(o,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:$t(),viewportWidth:Qt(),pageUrl:te(s.location.href,null!==(i=null===(r=n.config.interactionConfig)||void 0===r?void 0:r.ugcFilterRules)&&void 0!==i?i:[]),timestamp:n.timestamp,type:"scroll"}]})}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=Qt(),this._maxScrollHeight=$t(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new Vt(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=Qt();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=$t();this._maxScrollY=e.y;var o=e.y+i;o>this._maxScrollHeight&&(this._maxScrollHeight=o),this.timestamp=t}},e}(),Zt=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},Yt=function(){var e=this;this.dbs={},this.createStore=function(t){return o(e,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return[4,ot(t,1,{upgrade:function(e){e.objectStoreNames.contains("sessionTargetingMatch")||e.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return o(e,void 0,void 0,function(){var e,n;return s(this,function(r){switch(r.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId;return o(e,void 0,void 0,function(){var e,t,o,a;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=s.sent(),t=String(i),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(o=s.sent())?void 0:o.targetingMatch];case 3:return a=s.sent(),n.warn("Failed to get targeting match for session id ".concat(i,": ").concat(a)),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,a=t.targetingMatch;return o(e,void 0,void 0,function(){var e,t,o;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=s.sent(),t=String(i),[4,e.put("sessionTargetingMatch",{targetingMatch:a,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,s.sent()];case 3:return o=s.sent(),n.warn("Failed to store targeting match for session id ".concat(i,": ").concat(o)),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return o(e,void 0,void 0,function(){var e,t,o,a,c,u,l,d;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=s.sent(),t=String(i),[4,(o=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:a=s.sent(),c=0,s.label=3;case 3:return c<a.length?(u=a[c],l=Date.now()-u.lastUpdated,u.sessionId!==t&&l>1728e5?[4,o.store.delete(u.sessionId)]:[3,5]):[3,6];case 4:s.sent(),s.label=5;case 5:return c++,[3,3];case 6:return[4,o.done];case 7:return s.sent(),[3,9];case 8:return d=s.sent(),n.warn("Failed to clear old targeting matches for sessions: ".concat(d)),[3,9];case 9:return[2]}})})}},en=new Yt,tn=function(e){var t=e.sessionId,n=e.targetingConfig,r=e.loggerProvider,a=e.apiKey,c=e.targetingParams;return o(void 0,void 0,void 0,function(){var e,o,u,l;return s(this,function(s){switch(s.label){case 0:return[4,en.clearStoreOfOldSessions({loggerProvider:r,apiKey:a,currentSessionId:t})];case 1:return s.sent(),[4,en.getTargetingMatchForSession({loggerProvider:r,apiKey:a,sessionId:t})];case 2:if(!0===s.sent())return[2,!0];e=!0,s.label=3;case 3:return s.trys.push([3,6,,7]),[4,import("./index-min3.js")];case 4:return[4,(0,s.sent().evaluateTargeting)(i(i({},c),{flag:n,sessionId:t,apiKey:a,loggerProvider:r}))];case 5:return(o=s.sent())&&o.sr_targeting_config&&(e="on"===o.sr_targeting_config.key),en.storeTargetingMatchForSession({loggerProvider:r,apiKey:a,sessionId:t,targetingMatch:e}),[3,7];case 6:return u=s.sent(),l=u,r.warn(l.message),[3,7];case 7:return[2,e]}})})};function nn(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,n,r){var o,s,a,c=i(i({},e),r),u=c.ugcFilterRules||[],l=null!==(o=c.enablePolling)&&void 0!==o&&o,d=null!==(s=c.pollingInterval)&&void 0!==s?s:1e3,f=null!==(a=c.captureDocumentTitle)&&void 0!==a&&a;if(!n)return function(){};var v=void 0,h="__amplitude_url_tracking_patched__",g="__amplitude_url_tracking_reset__",p=function(){return n.location&&n.location.href||""},m=function(){var e=p();if(void 0===v||e!==v){v=e;var r=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=p(),o="";return f&&(o=(null==r?void 0:r.title)||""),{href:u.length>0?te(i,u):i,title:o,viewportHeight:e,viewportWidth:t,type:"url-change-event"}}();t(r)}},y=function(e){var t=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=e.apply(this,t);return n[g]||m(),i};return t[h]=!0,t},b=function(){m()};if(l){var S=n.setInterval(function(){m()},d);return m(),function(){S&&n.clearInterval(S)}}if(n.history){var w=n.history.pushState.bind(n.history),I=n.history.replaceState.bind(n.history);return n.history.pushState[h]||(n.history.pushState=y(w),n.history.replaceState=y(I)),n.addEventListener("popstate",m),n.addEventListener("hashchange",b),m(),function(){n[g]=!0,n.removeEventListener("popstate",m),n.removeEventListener("hashchange",b)}}return n.addEventListener("hashchange",b),m(),function(){n.removeEventListener("hashchange",b)}},options:e}}nn();var rn=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.recordFunction=null,this.teardownEventListeners=function(t){var n=g();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){e.recordEvents(!1)},this.pageLeaveListener=function(t){e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,i){return void 0===n&&(n=!1),void 0===i&&(i=!1),o(e,void 0,void 0,function(){var e,o;return s(this,function(s){switch(s.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig){if(!n)return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.")}return this.lastTargetingParams=t,!this.config.targetingConfig||this.sessionTargetingMatch?[3,2]:((e=t.event)&&Object.values(r).includes(e.event_type)&&(e=void 0),o=this,[4,tn({sessionId:this.identifiers.sessionId,targetingConfig:this.config.targetingConfig,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:e}})]);case 1:o.sessionTargetingMatch=s.sent(),this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:e,targetingParams:t},null,2)),s.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return!i&&this.recordCancelCallback?[3,5]:(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]);case 4:s.sent(),s.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,r){return void 0===n&&(n={}),void 0===r&&(r=!0),o(e,void 0,void 0,function(){var e,o,a,c;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),e=void 0,(o=this.config)&&t!==W.METADATA?(e={config:re(o),version:Je},r?[4,ne()]:[3,2]):[3,2];case 1:a=s.sent(),e=i(i({},a),e),s.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,i(i({},n),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return c=s.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",c),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null===(t=e.networkObservers)||void 0===t||t.stop()}catch(t){var n=t;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(n.toString()))}},this.loggerProvider=new Q(new S)}return e.prototype.init=function(e,t){return y(this._init(e,t))},e.prototype._init=function(e,t){var n,r,i,a,l,d,f;return o(this,void 0,void 0,function(){var o,v,h,p,m,y,b,w,I,C,E,P,k,x,_,R,T;return s(this,function(s){switch(s.label){case 0:return this.loggerProvider=new Q(t.loggerProvider||new S),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.identifiers=new Zt({sessionId:t.sessionId,deviceId:t.deviceId}),o=this,[4,ue(e,t)];case 1:return o.joinedConfigGenerator=s.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:v=s.sent(),h=v.joinedConfig,p=v.localConfig,m=v.remoteConfig,this.config=h,this.setMetadata(t.sessionId,h,p,m,null===(n=t.version)||void 0===n?void 0:n.version,Je,null===(r=t.version)||void 0===r?void 0:r.type),t.sessionId&&(null===(i=this.config.interactionConfig)||void 0===i?void 0:i.enabled)&&(y=Xt.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[y.send(this.getDeviceId.bind(this)).bind(y)],this.scrollHook=y.hook.bind(y),this.clickHandler=new Ht(this.loggerProvider,y)),b=[],"idb"!==(w=this.config.storeType)||(null===(a=g())||void 0===a?void 0:a.indexedDB)||(w="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(w," for event storage.")),s.label=3;case 3:return s.trys.push([3,5,,6]),[4,Tt({config:this.config,sessionId:this.identifiers.sessionId,type:"replay",storeType:w})];case 4:return I=s.sent(),b.push({name:"replay",manager:I}),[3,6];case 5:return C=s.sent(),x=C,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(x.toString())),[3,6];case 6:if(!(null===(l=this.config.interactionConfig)||void 0===l?void 0:l.enabled))return[3,10];E=this.config.interactionConfig.batch?Gt:Jt,s.label=7;case 7:return s.trys.push([7,9,,10]),[4,Tt({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(d=this.config.interactionConfig.trackEveryNms)&&void 0!==d?d:3e4,maxInterval:6e4,payloadBatcher:E,storeType:w})];case 8:return P=s.sent(),b.push({name:"interaction",manager:P}),[3,10];case 9:return k=s.sent(),x=k,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(x.toString())),[3,10];case 10:return this.eventsManager=new(Ot.bind.apply(Ot,u([void 0],c(b),!1))),this.eventCompressor&&this.eventCompressor.terminate(),_=void 0,R=g(),(null===(f=this.config.experimental)||void 0===f?void 0:f.useWebWorker)&&R&&R.Worker?[4,import("./index-min2.js")]:[3,12];case 11:T=s.sent().compressionScript,_=T,s.label=12;case 12:return this.eventCompressor=new Ke(this.eventsManager,this.config,this.getDeviceId(),_),[4,this.initializeNetworkObservers()];case 13:return s.sent(),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties},!0)];case 14:return s.sent(),[2]}})})},e.prototype.setSessionId=function(e,t){return y(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t,n){var r;return o(this,void 0,void 0,function(){var i,o,a;return s(this,function(s){switch(s.label){case 0:return this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,(i=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(i),o=t||this.getDeviceId(),this.identifiers=new Zt({sessionId:e,deviceId:o}),this.joinedConfigGenerator&&i?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2];case 1:a=s.sent().joinedConfig,this.config=a,s.label=2;case 2:return(null===(r=this.config)||void 0===r?void 0:r.targetingConfig)?[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties},!1,!0)]:[3,4];case 3:return s.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:s.sent(),s.label=6;case 6:return[2]}})})},e.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var r=this.getShouldRecord(),i={};return r&&((e={})[z]=n.sessionReplayId?n.sessionReplayId:null,i=e,t.debugMode&&(i[H]=JSON.stringify({appHash:j(t.apiKey).toString()}))),this.addCustomRRWebEvent(W.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},e.prototype.sendEvents=function(e){var t,n=e||(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),o(this,void 0,void 0,function(){var n;return s(this,function(r){return(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},e.prototype.shouldOptOut=function(){var e,t,n,r;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=(r=this.config.instanceName,void 0===r&&(r=f),N.getInstance(r)).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n,r=!1,i="",o=!1;this.config.targetingConfig?this.sessionTargetingMatch?(i="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(i),r=!0,o=!0):(i="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(i),r=!1,o=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,n=j(e.toString()),31*Math.abs(n)%1e6/1e6<t)?(r=!0,o=!0):(i="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(i),r=!1,o=!1);return this.lastShouldRecordDecision!==r&&this.config.targetingConfig&&(this.addCustomRRWebEvent(W.TARGETING_DECISION,{message:i,sessionId:this.identifiers.sessionId,matched:o,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=r),r},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var i=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return i||void 0},e.prototype.getRecordingPlugins=function(e){var t,n,r,i,a,c;return o(this,void 0,void 0,function(){var o,u,l,d;return s(this,function(s){switch(s.label){case 0:o=[];try{u=nn({ugcFilterRules:(null===(n=null===(t=this.config)||void 0===t?void 0:t.interactionConfig)||void 0===n?void 0:n.ugcFilterRules)||[],enablePolling:(null===(r=this.config)||void 0===r?void 0:r.enableUrlChangePolling)||!1,pollingInterval:null===(i=this.config)||void 0===i?void 0:i.urlChangePollingInterval,captureDocumentTitle:null===(a=this.config)||void 0===a?void 0:a.captureDocumentTitle}),o.push(u)}catch(e){this.loggerProvider.warn("Failed to create URL tracking plugin:",e)}if(!(null===(c=null==e?void 0:e.console)||void 0===c?void 0:c.enabled))return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,import("./rrweb-plugin-console-record-min.js")];case 2:return l=s.sent().getRecordConsolePlugin,o.push(l({level:e.console.levels})),[3,4];case 3:return d=s.sent(),this.loggerProvider.warn("Failed to load console plugin:",d),[3,4];case 4:return[2,o.length>0?o:void 0]}})})},e.prototype.getRecordFunction=function(){return o(this,void 0,void 0,function(){var e,t;return s(this,function(n){switch(n.label){case 0:if(this.recordFunction)return[2,this.recordFunction];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,import("./rrweb-record-min.js")];case 2:return e=n.sent().record,this.recordFunction=e,[2,e];case 3:return t=n.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}})})},e.prototype.recordEvents=function(e){var t,n,r,i,a,c;return void 0===e&&(e=!0),o(this,void 0,void 0,function(){var o,u,l,d,f,v,h,g,p,m,y,b,S,w=this;return s(this,function(s){switch(s.label){case 0:return o=this.config,u=this.getShouldRecord(),l=null===(t=this.identifiers)||void 0===t?void 0:t.sessionId,u&&l&&o?(this.stopRecordingEvents(),[4,this.getRecordFunction()]):[2];case 1:return(d=s.sent())?[4,this.initializeNetworkObservers()]:[2];case 2:s.sent(),null===(n=this.networkObservers)||void 0===n||n.start(function(e){w.addCustomRRWebEvent(W.FETCH_REQUEST,e)}),f=o.privacyConfig,v=o.interactionConfig,h=o.loggingConfig,g=(null==v?void 0:v.enabled)?{mouseInteraction:this.eventsManager&&(null===(r=this.clickHandler)||void 0===r?void 0:r.createHook({eventsManager:this.eventsManager,sessionId:l,deviceIdFn:this.getDeviceId.bind(this),mirror:d.mirror,ugcFilterRules:null!==(i=v.ugcFilterRules)&&void 0!==i?i:[]})),scroll:this.scrollHook}:{},p=(null==v?void 0:v.enabled)&&v.ugcFilterRules?v.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(l,".")),s.label=3;case 3:return s.trys.push([3,5,,6]),m=this,y=d,S={emit:function(e){if(w.shouldOptOut())return w.loggerProvider.log("Opting session ".concat(l," out of recording due to optOut config.")),w.stopRecordingEvents(),void w.sendEvents();e.type===se.Meta&&(e.data.href=te(e.data.href,p)),w.eventCompressor&&w.eventCompressor.enqueueEvent(e,l)},inlineStylesheet:o.shouldInlineStylesheet,hooks:g,maskAllInputs:!0,maskTextClass:$,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:o.applyBackgroundColorToBlockedElements,maskInputFn:Z("input",f),maskTextFn:Z("text",f),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,slimDOMOptions:{script:null===(a=o.omitElementTags)||void 0===a?void 0:a.script,comment:null===(c=o.omitElementTags)||void 0===c?void 0:c.comment},errorHandler:function(e){var t=e;if(t.message.includes("insertRule")&&t.message.includes("CSSStyleSheet"))throw t;if(t._external_)throw t;return w.loggerProvider.warn("Error while capturing replay: ",t.toString()),!0}},[4,this.getRecordingPlugins(h)];case 4:return m.recordCancelCallback=y.apply(void 0,[(S.plugins=s.sent(),S)]),this.addCustomRRWebEvent(W.DEBUG_INFO),e&&this.addCustomRRWebEvent(W.METADATA,this.metadata),[3,6];case 5:return b=s.sent(),this.loggerProvider.warn("Failed to initialize session replay:",b),[3,6];case 6:return[2]}})})},e.prototype.getDeviceId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),o(this,void 0,void 0,function(){return s(this,function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]})})},e.prototype.shutdown=function(){this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},e.prototype.setMetadata=function(e,t,n,r,i,o,s){var a=(null==e?void 0:e.toString())?j(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(s),replaySDKVersion:i,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:o}},e.prototype.initializeNetworkObservers=function(){var e,t,n;return o(this,void 0,void 0,function(){var r,i;return s(this,function(o){switch(o.label){case 0:if(!(null===(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.loggingConfig)||void 0===t?void 0:t.network)||void 0===n?void 0:n.enabled)||this.networkObservers)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,import("./observers-min.js")];case 2:return r=o.sent().NetworkObservers,this.networkObservers=new r,[3,4];case 3:return i=o.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",i),[3,4];case 4:return[2]}})})},e}(),on=function(e){return function(){var t=e.config||ie();return{logger:t.loggerProvider,logLevel:t.logLevel}}},sn=function(){var e=new rn;return{init:P(e.init.bind(e),"init",on(e)),evaluateTargetingAndCapture:P(e.evaluateTargetingAndCapture.bind(e),"evaluateTargetingAndRecord",on(e)),setSessionId:P(e.setSessionId.bind(e),"setSessionId",on(e)),getSessionId:P(e.getSessionId.bind(e),"getSessionId",on(e)),getSessionReplayProperties:P(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",on(e)),flush:P(e.flush.bind(e),"flush",on(e)),shutdown:P(e.shutdown.bind(e),"shutdown",on(e))}}(),an=sn.init,cn=sn.setSessionId,un=sn.getSessionId,ln=sn.getSessionReplayProperties;sn.flush,sn.shutdown,sn.evaluateTargetingAndCapture;const dn="amp_session_id",fn="Amplitude Session Replay Segment Plugin [Debug]:";function vn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)e[r]=n[r]}return e}var hn=function e(t,n){function r(e,r,i){if("undefined"!=typeof document){"number"==typeof(i=vn({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var o="";for(var s in i)i[s]&&(o+="; "+s,!0!==i[s]&&(o+="="+i[s].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+o}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var n=document.cookie?document.cookie.split("; "):[],r={},i=0;i<n.length;i++){var o=n[i].split("="),s=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=t.read(s,a),e===a)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",vn({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,vn({},this.attributes,t))},withConverter:function(t){return e(vn({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const gn=()=>{const e=un()||hn.get(dn);if(e){const t=parseInt(e.toString(),10);if(isNaN(t))return;return t}},pn=(e,t)=>(hn.set(dn,e.toString()),cn(e,t).promise),mn=(e,t)=>o(void 0,void 0,void 0,function*(){const n=gn()||0;let r;e.event.integrations&&e.event.integrations["Actions Amplitude"]&&(r=e.event.integrations["Actions Amplitude"].session_id),r&&n<r&&(yield pn(r,t));const i=ln(),o=Object.assign(Object.assign({},i),e.event.properties);return e.updateEvent("properties",o),e}),yn="0.0.0-zen-plus-zoning.0",bn=({amplitudeApiKey:e,sessionReplayOptions:t,segmentInstance:n,enableWrapperDebug:r=!1})=>o(void 0,void 0,void 0,function*(){let i,s=!1,a=null==t?void 0:t.deviceId;const c={name:"Session Replay Events",type:"enrichment",version:yn,isLoaded:()=>s,load:(n,c)=>o(void 0,void 0,void 0,function*(){if(!a){const e=c.user();a=e.anonymousId()||void 0}const n=gn();r&&console.log(`${fn} initializing session replay with sessionId=${null!=n?n:"undefined"} and deviceId=${null!=a?a:"undefined"}`),i=an(e,Object.assign(Object.assign({},t),{sessionId:n,deviceId:a||void 0,version:{type:"segment",version:yn}})).promise,yield i,s=!0}),track:e=>o(void 0,void 0,void 0,function*(){return yield i,yield mn(e,a)}),page:e=>o(void 0,void 0,void 0,function*(){return yield i,yield mn(e,a)}),identify:e=>o(void 0,void 0,void 0,function*(){yield i;const t=gn();return t&&(r&&console.log(`${fn} calling setSessionId() with sessionId=${t} and deviceId=${null!=a?a:"undefined"}`),yield pn(t,a)),e})};yield n.register(c)});export{o as _,s as a,i as b,bn as c,g,ot as o};
2
+ //# sourceMappingURL=index-min.js.map
Binary file