import { $ as t, A as e, B as n, C as o, D as s, E as i, F as r, G as a, H as c, I as d, K as u, L as l, M as f, O as p, P as h, Q as g, R as m, S as v, T as S, U as y, W as I, X as w, Z as N, _ as E, at as b, c as T, ct as x, d as C, et as D, f as R, g as O, h as _, i as M, k as A, l as L, lt as P, m as k, n as z, o as V, ot as H, p as G, q as U, r as $, s as B, st as F, t as X, u as Y, ut as q, v as W, w as j, x as J, y as K, z as Z } from "./ingest.worker-B1ibo6Wb.js";
const Q = 2, tt = 3, et = 4, nt = 6, ot = 7, st = 8, it = 9, rt = 12, at = 0, ct = 1, dt = 2, ut = 3, lt = 4, ft = 11, pt = {
	AddString: 0,
	AddNode: 1,
	RemoveNode: 2,
	Attribute: 3,
	Text: 4,
	Size: 5,
	ScrollPosition: 6,
	AddStyleSheet: 7,
	AttachedStyleSheets: 8,
	MediaPlaybackState: 9,
	VisualViewport: 10
}, ht = 0, gt = 1, mt = 2, vt = 3, St = 4, yt = 5, It = 6, wt = 7, Nt = 8, Et = 5, bt = 6, Tt = 0, xt = 1;
function Ct() {
	return Rt(() => /* @__PURE__ */ new Map(), 0);
}
function Dt(t) {
	return Rt(() => /* @__PURE__ */ new WeakMap(), t);
}
function Rt(t, e) {
	let n = t(), o = e;
	const s = (t) => n.get(t);
	return {
		clear() {
			o !== e && (n = t(), o = e);
		},
		delete(t) {
			n.delete(t);
		},
		get: s,
		getOrInsert(t) {
			let e = s(t);
			return void 0 === e && (e = o++, n.set(t, e)), e;
		},
		get nextId() {
			return o;
		},
		get size() {
			return o - e;
		}
	};
}
function Ot() {
	return U(u.USE_CHANGE_RECORDS) || U(u.USE_INCREMENTAL_CHANGE_RECORDS);
}
function _t() {
	return U(u.USE_INCREMENTAL_CHANGE_RECORDS);
}
function Mt(t, e, n) {
	return At(t, e, n);
}
function At(t, e, n) {
	let o = {
		container: void 0,
		parentId: t,
		previousSiblingId: void 0,
		nextSiblingId: e
	};
	return {
		advance(t) {
			const e = n.getOrInsert(t), s = ((t) => o.previousSiblingId === t - 1 ? 0 : void 0 !== o.nextSiblingId ? o.nextSiblingId - t : void 0 !== o.parentId ? t - o.parentId : null)(e);
			return o.previousSiblingId = e, {
				nodeId: e,
				insertionPoint: s
			};
		},
		ascend() {
			o.container && (o = o.container);
		},
		descend() {
			void 0 !== o.previousSiblingId && (o = {
				container: o,
				parentId: o.previousSiblingId,
				previousSiblingId: void 0,
				nextSiblingId: void 0
			});
		}
	};
}
function Lt(t, e) {
	const n = t.tagName, o = t.value;
	if (_(t, e)) {
		const e = t.type;
		if ("INPUT" === n && ("button" === e || "submit" === e || "reset" === e)) return o;
		if (!o || "OPTION" === n) return;
		return "***";
	}
	return "OPTION" === n || "SELECT" === n ? t.value : "INPUT" === n || "TEXTAREA" === n ? o : void 0;
}
const Pt = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm, kt = /^[A-Za-z]+:|^\/\//, zt = /^["']?data:.*,/i;
function Vt(t, e) {
	return t.replace(Pt, (t, n, o, s, i, r) => {
		const a = o || i || r;
		if (!e || !a || kt.test(a) || zt.test(a)) return t;
		const c = n || s || "";
		return `url(${c}${function(t, e) {
			try {
				return w(t, e).href;
			} catch (n) {
				return t;
			}
		}(a, e)}${c})`;
	});
}
const Ht = /[^a-z1-6-_]/;
function Gt(t) {
	return t.tagName.toLowerCase();
}
function Ut(t, e) {
	return `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='${t}' height='${e}' style='background-color:silver'%3E%3C/svg%3E`;
}
function $t(t, e) {
	if (void 0 === t || 0 === t.length) return;
	const n = (t) => {
		const n = t.cssRules || t.rules, o = Array.from(n, (t) => t.cssText);
		return e.addMetric("cssText", o.reduce((t, e) => t + e.length, 0)), {
			cssRules: o,
			disabled: t.disabled || void 0,
			media: t.media.length > 0 ? Array.from(t.media) : void 0
		};
	}, o = [];
	for (let s = 0; s < t.length; s++) o.push(n(t[s]));
	return o;
}
function Bt(t, e, n, o) {
	if (e === E.HIDDEN) return null;
	const i = t.getAttribute(n), r = t.tagName;
	if (k(r, n, i, e, o)) {
		if ("IMG" === r) {
			const e = t;
			if (e.naturalWidth > 0) return Ut(e.naturalWidth, e.naturalHeight);
			const { width: n, height: o } = t.getBoundingClientRect();
			return n > 0 || o > 0 ? Ut(n, o) : O;
		}
		return "SOURCE" === r ? O : "***";
	}
	return i ? s(i, 1e6) : i;
}
function Ft(t, e, n) {
	if (e === E.HIDDEN) return {};
	const o = {}, s = Gt(t);
	for (let r = 0; r < t.attributes.length; r += 1) {
		const s = t.attributes.item(r).name, i = Bt(t, e, s, n.scope.configuration);
		null !== i && (o[s] = i);
	}
	if (t.value && ("textarea" === s || "select" === s || "option" === s || "input" === s)) {
		const n = Lt(t, e);
		void 0 !== n && (o.value = n);
	}
	if ("option" === s) {
		const n = t;
		n.selected && !_(n, e) ? o.selected = "" : delete o.selected;
	}
	const i = t;
	return "input" !== s || "radio" !== i.type && "checkbox" !== i.type || (i.checked && !_(i, e) ? o.checked = "" : delete o.checked), o;
}
function Xt(t, e, n) {
	if (e === E.HIDDEN) return {};
	const o = {}, s = t.ownerDocument, i = Gt(t);
	if ("link" === i) {
		const e = Array.from(s.styleSheets).find((e) => e.href === t.href), i = Yt(e);
		i && e && (n.addMetric("cssText", i.length), o._cssText = i);
	}
	if ("style" === i && t.sheet) {
		const e = Yt(t.sheet);
		e && (n.addMetric("cssText", e.length), o._cssText = e);
	}
	let r, a;
	switch ("audio" !== i && "video" !== i || (o.rr_mediaState = t.paused ? "paused" : "played"), n.kind) {
		case 0:
			r = Math.round(t.scrollTop), a = Math.round(t.scrollLeft), (r || a) && n.scope.elementsScrollPositions.set(t, {
				scrollTop: r,
				scrollLeft: a
			});
			break;
		case 1: n.scope.elementsScrollPositions.has(t) && ({scrollTop: r, scrollLeft: a} = n.scope.elementsScrollPositions.get(t));
	}
	return a && (o.rr_scrollLeft = a), r && (o.rr_scrollTop = r), o;
}
function Yt(t) {
	if (!t) return null;
	let e;
	try {
		e = t.rules || t.cssRules;
	} catch (n) {}
	return e ? Vt(Array.from(e, N() ? qt : Wt).join(""), t.href) : null;
}
function qt(t) {
	return function(t) {
		return "selectorText" in t;
	}(t) && t.selectorText.includes(":") ? t.cssText.replace(/(\[[\w-]+[^\\])(:[^\]]+\])/g, "$1\\$2") : Wt(t);
}
function Wt(t) {
	return function(t) {
		return "styleSheet" in t;
	}(t) && Yt(t.styleSheet) || t.cssText;
}
function jt(t, e, n) {
	switch (t.nodeType) {
		case t.DOCUMENT_NODE: return function(t, e, n) {
			return {
				type: at,
				id: n.assignId(t),
				childNodes: Jt(t, e, n),
				adoptedStyleSheets: $t(t.adoptedStyleSheets, n)
			};
		}(t, e, n);
		case t.DOCUMENT_FRAGMENT_NODE: return function(t, e, n) {
			const o = i(t);
			o && n.scope.shadowRootsController.addShadowRoot(t, n.scope);
			return {
				type: ft,
				id: n.assignId(t),
				childNodes: Jt(t, e, n),
				isShadowRoot: o,
				adoptedStyleSheets: o ? $t(t.adoptedStyleSheets, n) : void 0
			};
		}(t, e, n);
		case t.DOCUMENT_TYPE_NODE: return function(t, e) {
			return {
				type: ct,
				id: e.assignId(t),
				name: t.name,
				publicId: t.publicId,
				systemId: t.systemId
			};
		}(t, n);
		case t.ELEMENT_NODE: return function(t, e, n) {
			const s = function(t) {
				const e = t.toLowerCase().trim();
				return Ht.test(e) ? "div" : e;
			}(t.tagName), i = (a = t, "svg" === a.tagName || a instanceof SVGElement || void 0), r = G(C(t), e);
			var a;
			if (r === E.HIDDEN) {
				const { width: e, height: o } = t.getBoundingClientRect();
				return {
					type: dt,
					id: n.assignId(t),
					tagName: s,
					attributes: {
						rr_width: `${e}px`,
						rr_height: `${o}px`,
						[W]: K
					},
					childNodes: [],
					isSVG: i
				};
			}
			if (r === E.IGNORE) return null;
			const c = n.assignId(t), d = function(t, e, n) {
				return {
					...Ft(t, e, n),
					...Xt(t, e, n)
				};
			}(t, r, n);
			let u = [];
			o(t) && "style" !== s && (u = Jt(t, r, n));
			return {
				type: dt,
				id: c,
				tagName: s,
				attributes: d,
				childNodes: u,
				isSVG: i
			};
		}(t, e, n);
		case t.TEXT_NODE: return function(t, e, n) {
			const o = R(t, e);
			return void 0 === o ? null : {
				type: ut,
				id: n.assignId(t),
				textContent: o
			};
		}(t, e, n);
		case t.CDATA_SECTION_NODE: return function(t, e) {
			return {
				type: lt,
				id: e.assignId(t),
				textContent: ""
			};
		}(t, n);
		default: return null;
	}
}
function Jt(t, e, n) {
	const o = [];
	return J(t, (t) => {
		const s = jt(t, e, n);
		s && o.push(s);
	}), o;
}
function Kt(t, e, n) {
	t[e].count += 1, t[e].max = Math.max(t[e].max, n), t[e].sum += n;
}
function Zt(t, e, n, o, s) {
	const i = [], r = {
		cssText: {
			count: 0,
			max: 0,
			sum: 0
		},
		serializationDuration: {
			count: 0,
			max: 0,
			sum: 0
		}
	}, a = {
		add(t) {
			i.push(t);
		},
		addMetric(t, e) {
			Kt(r, t, e);
		},
		assignId(t) {
			const e = o.nodeIds.getOrInsert(t);
			return a.serializedNodeIds && a.serializedNodeIds.add(e), e;
		},
		kind: t,
		scope: o
	}, c = H();
	s(a), Kt(r, "serializationDuration", b(c, H()));
	for (const d of i) e(d);
	n(r);
}
function Qt(t, e, n, o, s, i) {
	const r = function(t) {
		let e = {};
		const n = (e) => {
			for (let s = 0, i = e.length; s < i; s++) {
				const i = e[s];
				if ("string" == typeof i) {
					const n = t.size;
					e[s] = t.getOrInsert(i), t.size > n && o(pt.AddString, i);
				} else Array.isArray(i) && n(i);
			}
		}, o = (t, o) => {
			t in e || (e[t] = [t]), t !== pt.AddString && Array.isArray(o) && n(o), e[t].push(o);
		};
		return {
			add: o,
			flush: () => {
				const t = [];
				return [
					pt.AddString,
					pt.AddNode,
					pt.RemoveNode,
					pt.Attribute,
					pt.Text,
					pt.Size,
					pt.ScrollPosition,
					pt.AddStyleSheet,
					pt.AttachedStyleSheets,
					pt.MediaPlaybackState,
					pt.VisualViewport
				].forEach((n) => {
					const o = e[n];
					o && t.push(o);
				}), e = {}, t;
			}
		};
	}(o.stringIds), a = {
		cssText: {
			count: 0,
			max: 0,
			sum: 0
		},
		serializationDuration: {
			count: 0,
			max: 0,
			sum: 0
		}
	}, c = {
		addMetric(t, e) {
			Kt(a, t, e);
		},
		addNode(...t) {
			r.add(pt.AddNode, t);
		},
		addStyleSheet(t, e, n) {
			n ? r.add(pt.AddStyleSheet, [
				t,
				e || [],
				n
			]) : e ? r.add(pt.AddStyleSheet, [t, e]) : r.add(pt.AddStyleSheet, [t]);
		},
		attachStyleSheets(t, e) {
			const n = [t];
			for (const o of e) n.push(o);
			r.add(pt.AttachedStyleSheets, n);
		},
		removeNode(t) {
			r.add(pt.RemoveNode, t);
		},
		setAttributes(t) {
			r.add(pt.Attribute, t);
		},
		setMediaPlaybackState(t, e) {
			r.add(pt.MediaPlaybackState, [t, e]);
		},
		setScrollPosition(t, e, n) {
			r.add(pt.ScrollPosition, [
				t,
				e,
				n
			]);
		},
		setSize(t, e, n) {
			r.add(pt.Size, [
				t,
				e,
				n
			]);
		},
		setText(t, e) {
			r.add(pt.Text, [t, e]);
		},
		kind: t,
		scope: o
	}, d = H();
	i(c), Kt(a, "serializationDuration", b(d, H()));
	const u = r.flush();
	u.length > 0 && e({
		data: u,
		type: rt,
		timestamp: s
	}), n(a);
}
function te(t, e, n, o, s, i) {
	Zt(e, o, s, i, (o) => {
		const s = o.scope.configuration.defaultPrivacyLevel, r = {
			data: {
				node: jt(n, s, o),
				initialOffset: {
					left: T(),
					top: L()
				}
			},
			type: Q,
			timestamp: t
		};
		o.add(r), i.serializeObservable.notify({
			type: "full",
			kind: e,
			target: n,
			timestamp: t,
			v1: r
		});
	});
}
function ee(t, e, n, o) {
	var s;
	if ("STYLE" === (null === (s = e.parentNode) || void 0 === s ? void 0 : s.nodeName)) return;
	let r;
	const a = C(e);
	if (r = a ? G(a, n) : n, r !== E.HIDDEN) {
		if (r !== E.IGNORE) {
			switch (e.nodeType) {
				case e.CDATA_SECTION_NODE:
					(function(t, e, n) {
						const { insertionPoint: o } = t.advance(e);
						n.addNode(o, "#cdata-section");
					})(t, e, o);
					break;
				case e.DOCUMENT_NODE:
					(function(t, e, n) {
						const { nodeId: o, insertionPoint: s } = t.advance(e);
						n.addNode(s, "#document"), n.setScrollPosition(o, T(), L()), ne(e.adoptedStyleSheets, o, n);
					})(t, e, o);
					break;
				case e.DOCUMENT_FRAGMENT_NODE:
					(function(t, e, n) {
						const { nodeId: o, insertionPoint: s } = t.advance(e);
						if (!i(e)) return void n.addNode(s, "#document-fragment");
						n.addNode(s, "#shadow-root"), n.scope.shadowRootsController.addShadowRoot(e, n.scope), ne(e.adoptedStyleSheets, o, n);
					})(t, e, o);
					break;
				case e.DOCUMENT_TYPE_NODE:
					(function(t, e, n) {
						const { insertionPoint: o } = t.advance(e);
						n.addNode(o, "#doctype", e.name, e.publicId, e.systemId);
					})(t, e, o);
					break;
				case e.ELEMENT_NODE:
					(function(t, e, n, o) {
						const { nodeId: s, insertionPoint: i } = t.advance(e), r = Object.entries(Ft(e, n, o));
						o.addNode(i, oe(e), ...r);
						const { _cssText: a, rr_mediaState: c, rr_scrollLeft: d, rr_scrollTop: u } = Xt(e, n, o), l = e;
						if (void 0 !== a && l.sheet) {
							const t = o.scope.styleSheetIds.getOrInsert(l.sheet);
							o.addStyleSheet(a), o.attachStyleSheets(s, [t]);
						}
						"played" === c ? o.setMediaPlaybackState(s, Tt) : "paused" === c && o.setMediaPlaybackState(s, xt);
						void 0 === d && void 0 === u || o.setScrollPosition(s, d || 0, u || 0);
					})(t, e, r, o);
					break;
				case e.TEXT_NODE:
					(function(t, e, n, o) {
						const s = R(e, n);
						if (void 0 === s) return;
						const { insertionPoint: i } = t.advance(e);
						o.addNode(i, "#text", s);
					})(t, e, r, o);
					break;
				default: return;
			}
			switch (e.nodeType) {
				case e.CDATA_SECTION_NODE:
				case e.DOCUMENT_TYPE_NODE:
				case e.TEXT_NODE: return;
			}
			t.descend(), J(e, (e) => {
				ee(t, e, r, o);
			}), t.ascend();
		}
	} else (function(t, e, n) {
		if (!j(e)) return;
		const { nodeId: o, insertionPoint: s } = t.advance(e);
		n.addNode(s, oe(e), [W, K]);
		const { width: i, height: r } = e.getBoundingClientRect();
		n.setSize(o, i, r);
	})(t, e, o);
}
function ne(t, e, n) {
	t && 0 !== t.length && n.attachStyleSheets(e, t.map((t) => function(t, e) {
		const n = Array.from(t.cssRules || t.rules, (t) => t.cssText), o = t.media.length > 0 ? Array.from(t.media) : void 0;
		return e.addMetric("cssText", n.reduce((t, e) => t + e.length, 0)), e.addStyleSheet(n, o, t.disabled), e.scope.styleSheetIds.getOrInsert(t);
	}(t, n)));
}
function oe(t) {
	const e = t.nodeName;
	return function(t) {
		return "http://www.w3.org/2000/svg" === t.namespaceURI;
	}(t) ? `svg>${e}` : e;
}
function se(t, e, n, o, s, i) {
	i.resetIds(), Qt(e, o, s, i, t, (t) => {
		ee(At(void 0, void 0, i.nodeIds), n, i.configuration.defaultPrivacyLevel, t);
	});
}
function ie(t, e, n = H()) {
	return {
		data: {
			source: t,
			...e
		},
		type: tt,
		timestamp: n
	};
}
function re(t, e, n, o, s) {
	Zt(2, n, o, s, (n) => function(t, e, n) {
		const o = /* @__PURE__ */ new Map();
		e.filter((t) => "childList" === t.type).forEach((t) => {
			t.removedNodes.forEach((t) => {
				ae(t, n.scope.shadowRootsController.removeShadowRoot);
			});
		});
		const s = e.filter((t) => t.target.isConnected && function(t, e) {
			let n = t;
			for (; n;) {
				if (void 0 === e.get(n) && !i(n)) return !1;
				n = v(n);
			}
			return !0;
		}(t.target, n.scope.nodeIds) && Y(t.target, n.scope.configuration.defaultPrivacyLevel, o) !== E.HIDDEN), { adds: r, removes: a, hasBeenSerialized: c } = function(t, e, n) {
			const o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
			for (const l of t) l.addedNodes.forEach((t) => {
				o.add(t);
			}), l.removedNodes.forEach((t) => {
				o.has(t) || s.set(t, l.target), o.delete(t);
			});
			const i = Array.from(o);
			r = i, r.sort((t, e) => {
				const n = t.compareDocumentPosition(e);
				return n & Node.DOCUMENT_POSITION_CONTAINED_BY ? -1 : n & Node.DOCUMENT_POSITION_CONTAINS || n & Node.DOCUMENT_POSITION_FOLLOWING ? 1 : n & Node.DOCUMENT_POSITION_PRECEDING ? -1 : 0;
			}), n.serializedNodeIds = /* @__PURE__ */ new Set();
			var r;
			const a = [];
			for (const l of i) {
				if (d(l)) continue;
				const t = Y(l.parentNode, n.scope.configuration.defaultPrivacyLevel, e);
				if (t === E.HIDDEN || t === E.IGNORE) continue;
				const o = jt(l, t, n);
				if (!o) continue;
				const s = v(l);
				a.push({
					nextId: u(l),
					parentId: n.scope.nodeIds.get(s),
					node: o
				});
			}
			const c = [];
			return s.forEach((t, e) => {
				const o = n.scope.nodeIds.get(t), s = n.scope.nodeIds.get(e);
				void 0 !== o && void 0 !== s && c.push({
					parentId: o,
					id: s
				});
			}), {
				adds: a,
				removes: c,
				hasBeenSerialized: d
			};
			function d(t) {
				var e;
				const o = n.scope.nodeIds.get(t);
				return void 0 !== o && (null === (e = n.serializedNodeIds) || void 0 === e ? void 0 : e.has(o));
			}
			function u(t) {
				let e = t.nextSibling;
				for (; e;) {
					const t = n.scope.nodeIds.get(e);
					if (void 0 !== t) return t;
					e = e.nextSibling;
				}
				return null;
			}
		}(s.filter((t) => "childList" === t.type), o, n), d = function(t, e, n) {
			var o;
			const s = [], i = /* @__PURE__ */ new Set(), r = t.filter((t) => !i.has(t.target) && (i.add(t.target), !0));
			for (const a of r) {
				if (a.target.textContent === a.oldValue) continue;
				const t = n.scope.nodeIds.get(a.target);
				if (void 0 === t) continue;
				const i = Y(v(a.target), n.scope.configuration.defaultPrivacyLevel, e);
				i !== E.HIDDEN && i !== E.IGNORE && s.push({
					id: t,
					value: null !== (o = R(a.target, i)) && void 0 !== o ? o : null
				});
			}
			return s;
		}(s.filter((t) => "characterData" === t.type && !c(t.target)), o, n), u = function(t, e, n) {
			const o = [], s = /* @__PURE__ */ new Map(), i = t.filter((t) => {
				const e = s.get(t.target);
				return (!e || !e.has(t.attributeName)) && (e ? e.add(t.attributeName) : s.set(t.target, /* @__PURE__ */ new Set([t.attributeName])), !0);
			}), r = /* @__PURE__ */ new Map();
			for (const a of i) {
				if (a.target.getAttribute(a.attributeName) === a.oldValue) continue;
				const t = n.scope.nodeIds.get(a.target);
				if (void 0 === t) continue;
				const s = Y(a.target, n.scope.configuration.defaultPrivacyLevel, e), i = Bt(a.target, s, a.attributeName, n.scope.configuration);
				let c;
				if ("value" === a.attributeName) {
					const t = Lt(a.target, s);
					if (void 0 === t) continue;
					c = t;
				} else c = "string" == typeof i ? i : null;
				let d = r.get(a.target);
				d || (d = {
					id: t,
					attributes: {}
				}, o.push(d), r.set(a.target, d)), d.attributes[a.attributeName] = c;
			}
			return o;
		}(s.filter((t) => "attributes" === t.type && !c(t.target)), o, n);
		if (!(d.length || u.length || a.length || r.length)) return;
		const l = ie(ht, {
			adds: r,
			removes: a,
			texts: d,
			attributes: u
		}, t);
		n.add(l), n.scope.serializeObservable.notify({
			type: "incremental",
			target: e,
			timestamp: t,
			v1: l
		});
	}(t, e, n));
}
function ae(t, e) {
	S(t) && e(t.shadowRoot), J(t, (t) => ae(t, e));
}
function ce(t, e, n, o, s) {
	Qt(2, n, o, s, t, (t) => function(t, e) {
		const n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
		for (const c of t) switch (c.type) {
			case "attributes": {
				const t = c.target;
				let e = o.get(t);
				e || (e = /* @__PURE__ */ new Map(), o.set(t, e));
				const n = c.attributeName;
				e.has(n) || e.set(n, c.oldValue);
				break;
			}
			case "characterData":
				s.has(c.target) || s.set(c.target, c.oldValue);
				break;
			case "childList":
				for (let t = 0; t < c.addedNodes.length; t++) n.add(c.addedNodes[t]);
				for (let t = 0; t < c.removedNodes.length; t++) i.add(c.removedNodes[t]);
		}
		const r = e.scope.nodeIds.nextId, a = /* @__PURE__ */ new Map();
		(function(t, e) {
			const n = e.scope.nodeIds;
			for (const o of t) {
				const t = n.get(o);
				void 0 !== t && (ue(o, (t) => {
					S(t) && e.scope.shadowRootsController.removeShadowRoot(t.shadowRoot), n.delete(t);
				}), e.removeNode(t));
			}
		})(i, e), function(t, e, n) {
			const o = n.scope.nodeIds;
			for (const s of t) {
				if (!s.isConnected) continue;
				if (void 0 !== o.get(s)) continue;
				const t = v(s);
				if (!t) continue;
				const i = o.get(t);
				if (void 0 === i) continue;
				const r = Y(t, n.scope.configuration.defaultPrivacyLevel, e);
				ee(Mt(i, de(s, o), o), s, r, n);
			}
		}(n, a, e), function(t, e, n, o) {
			var s;
			const i = o.scope.nodeIds;
			for (const [r, a] of t) {
				if (r.textContent === a) continue;
				if (!r.isConnected) continue;
				const t = i.get(r);
				if (void 0 === t) continue;
				if (t >= e) continue;
				const c = v(r);
				if (!c) continue;
				const d = Y(c, o.scope.configuration.defaultPrivacyLevel, n);
				if (d === E.HIDDEN || d === E.IGNORE) continue;
				const u = null !== (s = R(r, d)) && void 0 !== s ? s : "";
				o.setText(t, u);
			}
		}(s, r, a, e), function(t, e, n, o) {
			const s = o.scope.nodeIds;
			for (const [i, r] of t) {
				if (!i.isConnected) continue;
				const t = s.get(i);
				if (void 0 === t) continue;
				if (t >= e) continue;
				const a = Y(i, o.scope.configuration.defaultPrivacyLevel, n);
				if (a === E.HIDDEN || a === E.IGNORE) continue;
				const c = [t];
				for (const [e, n] of r) {
					if (i.getAttribute(e) === n) continue;
					if ("value" === e) {
						const t = Lt(i, a);
						void 0 !== t && c.push([e, t]);
						continue;
					}
					const t = Bt(i, a, e, o.scope.configuration);
					null === t ? c.push([e]) : c.push([e, t]);
				}
				c.length > 1 && o.setAttributes(c);
			}
		}(o, r, a, e);
	}(e, t));
}
function de(t, e) {
	let n = t.nextSibling;
	for (; n;) {
		const t = e.get(n);
		if (void 0 !== t) return t;
		n = n.nextSibling;
	}
}
function ue(t, e) {
	e(t), J(t, (t) => ue(t, e));
}
const le = (t, e) => {
	const n = window.visualViewport, o = {
		layoutViewportX: t,
		layoutViewportY: e,
		visualViewportX: t,
		visualViewportY: e
	};
	return n ? (!function(t) {
		return Math.abs(t.pageTop - t.offsetTop - window.scrollY) > 25 || Math.abs(t.pageLeft - t.offsetLeft - window.scrollX) > 25;
	}(n) ? (o.visualViewportX = Math.round(t - n.offsetLeft), o.visualViewportY = Math.round(e - n.offsetTop)) : (o.layoutViewportX = Math.round(t + n.offsetLeft), o.layoutViewportY = Math.round(e + n.offsetTop)), o) : o;
}, fe = (t) => ({
	scale: t.scale,
	offsetLeft: t.offsetLeft,
	offsetTop: t.offsetTop,
	pageLeft: t.pageLeft,
	pageTop: t.pageTop,
	height: t.height,
	width: t.width
});
function pe(t, e, n, o, s, i = he()) {
	const { width: r, height: a } = V();
	n({
		data: {
			height: a,
			href: window.location.href,
			width: r
		},
		type: et,
		timestamp: t
	}), n({
		data: { has_focus: document.hasFocus() },
		type: nt,
		timestamp: t
	}), i(t, e, document, n, o, s), window.visualViewport && n({
		data: fe(window.visualViewport),
		type: st,
		timestamp: t
	});
}
function he() {
	return Ot() ? se : te;
}
function ge(t, e, n) {
	const o = Dt(1), s = Dt(0), i = Ct(), r = Dt(0), a = {
		resetIds() {
			a.eventIds.clear(), a.nodeIds.clear(), a.stringIds.clear(), a.styleSheetIds.clear();
		},
		configuration: t,
		elementsScrollPositions: e,
		eventIds: o,
		nodeIds: s,
		serializeObservable: new F(),
		shadowRootsController: n,
		stringIds: i,
		styleSheetIds: r
	};
	return a;
}
function me(t) {
	return Boolean(t.changedTouches);
}
function ve(t) {
	return !0 === t.composed && S(t.target) ? t.composedPath()[0] : t.target;
}
function Se(e, n) {
	const { throttled: o, cancel: s } = t((t) => {
		const o = ve(t), s = n.nodeIds.get(o);
		if (void 0 === s) return;
		const i = ye(t);
		if (!i) return;
		const r = {
			id: s,
			timeOffset: 0,
			x: i.x,
			y: i.y
		};
		e(ie(me(t) ? It : gt, { positions: [r] }));
	}, 50, { trailing: !1 }), { stop: i } = y(n.configuration, document, ["mousemove", "touchmove"], o, {
		capture: !0,
		passive: !0
	});
	return { stop: () => {
		i(), s();
	} };
}
function ye(t) {
	let { clientX: e, clientY: n } = me(t) ? t.changedTouches[0] : t;
	if (window.visualViewport) {
		const { visualViewportX: t, visualViewportY: o } = le(e, n);
		e = t, n = o;
	}
	if (Number.isFinite(e) && Number.isFinite(n)) return {
		x: e,
		y: n
	};
}
const Ie = {
	pointerup: 0,
	mousedown: 1,
	click: 2,
	contextmenu: 3,
	dblclick: 4,
	focus: Et,
	blur: bt,
	touchstart: 7,
	touchend: 9
};
function we(t, e) {
	return y(e.configuration, document, Object.keys(Ie), (n) => {
		const o = ve(n), s = e.nodeIds.get(o);
		if (void 0 === s || Y(o, e.configuration.defaultPrivacyLevel) === E.HIDDEN) return;
		const i = Ie[n.type];
		let r;
		if (i !== bt && i !== Et) {
			const t = ye(n);
			if (!t) return;
			r = {
				id: s,
				type: i,
				x: t.x,
				y: t.y
			};
		} else r = {
			id: s,
			type: i
		};
		t({
			id: e.eventIds.getOrInsert(n),
			...ie(mt, r)
		});
	}, {
		capture: !0,
		passive: !0
	});
}
function Ne(e, n, o) {
	const { throttled: s, cancel: i } = t((t) => {
		const e = ve(t);
		if (!e) return;
		const s = o.nodeIds.get(e);
		if (void 0 === s || Y(e, o.configuration.defaultPrivacyLevel) === E.HIDDEN) return;
		const i = e === document ? {
			scrollTop: L(),
			scrollLeft: T()
		} : {
			scrollTop: Math.round(e.scrollTop),
			scrollLeft: Math.round(e.scrollLeft)
		};
		o.elementsScrollPositions.set(e, i), n(ie(vt, {
			id: s,
			x: i.scrollLeft,
			y: i.scrollTop
		}));
	}, 100), { stop: r } = c(o.configuration, e, "scroll", s, {
		capture: !0,
		passive: !0
	});
	return { stop: () => {
		r(), i();
	} };
}
function Ee(t, e) {
	const n = B(e.configuration).subscribe((e) => {
		t(ie(St, e));
	});
	return { stop: () => {
		n.unsubscribe();
	} };
}
function be(e, n) {
	const o = window.visualViewport;
	if (!o) return { stop: g };
	const { throttled: s, cancel: i } = t(() => {
		e({
			data: fe(o),
			type: st,
			timestamp: H()
		});
	}, 200, { trailing: !1 }), { stop: r } = y(n.configuration, o, ["resize", "scroll"], s, {
		capture: !0,
		passive: !0
	});
	return { stop: () => {
		r(), i();
	} };
}
function Te(t, e) {
	return y(e.configuration, document, ["play", "pause"], (n) => {
		const o = ve(n);
		if (!o) return;
		const s = e.nodeIds.get(o);
		void 0 !== s && Y(o, e.configuration.defaultPrivacyLevel) !== E.HIDDEN && t(ie(wt, {
			id: s,
			type: "play" === n.type ? Tt : xt
		}));
	}, {
		capture: !0,
		passive: !0
	});
}
function xe(t, e) {
	function n(t, n) {
		if (!t || !t.ownerNode) return;
		const o = e.nodeIds.get(t.ownerNode);
		void 0 !== o && n(o);
	}
	const o = [I(CSSStyleSheet.prototype, "insertRule", ({ target: e, parameters: [o, s] }) => {
		n(e, (e) => t(ie(Nt, {
			id: e,
			adds: [{
				rule: o,
				index: s
			}]
		})));
	}), I(CSSStyleSheet.prototype, "deleteRule", ({ target: e, parameters: [o] }) => {
		n(e, (e) => t(ie(Nt, {
			id: e,
			removes: [{ index: o }]
		})));
	})];
	function s(e) {
		o.push(I(e.prototype, "insertRule", ({ target: e, parameters: [o, s] }) => {
			n(e.parentStyleSheet, (n) => {
				const i = Ce(e);
				i && (i.push(s || 0), t(ie(Nt, {
					id: n,
					adds: [{
						rule: o,
						index: i
					}]
				})));
			});
		}), I(e.prototype, "deleteRule", ({ target: e, parameters: [o] }) => {
			n(e.parentStyleSheet, (n) => {
				const s = Ce(e);
				s && (s.push(o), t(ie(Nt, {
					id: n,
					removes: [{ index: s }]
				})));
			});
		}));
	}
	return "undefined" != typeof CSSGroupingRule ? s(CSSGroupingRule) : (s(CSSMediaRule), s(CSSSupportsRule)), { stop: () => {
		o.forEach((t) => t.stop());
	} };
}
function Ce(t) {
	const e = [];
	let n = t;
	for (; n.parentRule;) {
		const t = Array.from(n.parentRule.cssRules).indexOf(n);
		e.unshift(t), n = n.parentRule;
	}
	if (!n.parentStyleSheet) return;
	const o = Array.from(n.parentStyleSheet.cssRules).indexOf(n);
	return e.unshift(o), e;
}
function De(t, e) {
	return y(e.configuration, window, ["focus", "blur"], () => {
		t({
			data: { has_focus: document.hasFocus() },
			type: nt,
			timestamp: H()
		});
	});
}
function Re(t, n, o) {
	const s = t.subscribe(12, (t) => {
		var s, i;
		t.rawRumEvent.type === e.ACTION && t.rawRumEvent.action.type === A.CLICK && !(null === (i = null === (s = t.rawRumEvent.action.frustration) || void 0 === s ? void 0 : s.type) || void 0 === i) && i.length && "events" in t.domainContext && t.domainContext.events && t.domainContext.events.length && n({
			timestamp: t.rawRumEvent.date,
			type: it,
			data: {
				frustrationTypes: t.rawRumEvent.action.frustration.type,
				recordIds: t.domainContext.events.map((t) => o.eventIds.getOrInsert(t))
			}
		});
	});
	return { stop: () => {
		s.unsubscribe();
	} };
}
function Oe(t, e, n) {
	const o = t.subscribe(5, () => {
		n(), e({
			timestamp: H(),
			type: ot
		});
	});
	return { stop: () => {
		o.unsubscribe();
	} };
}
function _e(t, e, n) {
	const o = n.configuration.defaultPrivacyLevel, s = /* @__PURE__ */ new WeakMap(), i = t !== document, { stop: r } = y(n.configuration, t, i ? ["change"] : ["input", "change"], (t) => {
		const e = ve(t);
		(e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement) && d(e);
	}, {
		capture: !0,
		passive: !0
	});
	let c;
	if (i) c = g;
	else {
		const t = [
			a(HTMLInputElement.prototype, "value", d),
			a(HTMLInputElement.prototype, "checked", d),
			a(HTMLSelectElement.prototype, "value", d),
			a(HTMLTextAreaElement.prototype, "value", d),
			a(HTMLSelectElement.prototype, "selectedIndex", d)
		];
		c = () => {
			t.forEach((t) => t.stop());
		};
	}
	return { stop: () => {
		c(), r();
	} };
	function d(t) {
		const e = Y(t, o);
		if (e === E.HIDDEN) return;
		const n = t.type;
		let s;
		if ("radio" === n || "checkbox" === n) {
			if (_(t, e)) return;
			s = { isChecked: t.checked };
		} else {
			const n = Lt(t, e);
			if (void 0 === n) return;
			s = { text: n };
		}
		u(t, s);
		const i = t.name;
		"radio" === n && i && t.checked && document.querySelectorAll(`input[type="radio"][name="${CSS.escape(i)}"]`).forEach((e) => {
			e !== t && u(e, { isChecked: !1 });
		});
	}
	function u(t, o) {
		const i = n.nodeIds.get(t);
		if (void 0 === i) return;
		const r = s.get(t);
		r && r.text === o.text && r.isChecked === o.isChecked || (s.set(t, o), e(ie(yt, {
			id: i,
			...o
		})));
	}
}
function Me(e, n, o, s, i = function() {
	return _t() ? ce : re;
}()) {
	const r = p();
	if (!r) return {
		stop: g,
		flush: g
	};
	const a = function(e) {
		let n = g, o = [];
		function s() {
			n(), e(o), o = [];
		}
		const { throttled: i, cancel: r } = t(s, 16, { leading: !1 });
		return {
			addMutations: (t) => {
				0 === o.length && (n = f(i, { timeout: 100 })), o.push(...t);
			},
			flush: s,
			stop: () => {
				n(), r();
			}
		};
	}((t) => {
		i(H(), t.concat(c.takeRecords()), n, o, s);
	}), c = new r(q(a.addMutations));
	return c.observe(e, {
		attributeOldValue: !0,
		attributes: !0,
		characterData: !0,
		characterDataOldValue: !0,
		childList: !0,
		subtree: !0
	}), {
		stop: () => {
			c.disconnect(), a.stop();
		},
		flush: () => {
			a.flush();
		}
	};
}
function Ae(t) {
	const { emitRecord: e, emitStats: o, configuration: s, lifeCycle: i } = t;
	if (!e || !o) throw new Error("emit functions are required");
	const r = (o) => {
		e(o), n("record", { record: o });
		X(t.viewHistory.findView().id);
	}, a = ((t, e) => {
		const n = /* @__PURE__ */ new Map();
		return {
			addShadowRoot: (o, s) => {
				if (n.has(o)) return;
				const i = Me(o, t, e, s), r = _e(o, t, s), a = Ne(o, t, s);
				n.set(o, {
					flush: () => i.flush(),
					stop: () => {
						i.stop(), r.stop(), a.stop();
					}
				});
			},
			removeShadowRoot: (t) => {
				const e = n.get(t);
				e && (e.stop(), n.delete(t));
			},
			stop: () => {
				n.forEach(({ stop: t }) => t());
			},
			flush: () => {
				n.forEach(({ flush: t }) => t());
			}
		};
	})(r, o), c = ge(s, function() {
		const t = /* @__PURE__ */ new WeakMap();
		return {
			set(e, n) {
				(e !== document || document.scrollingElement) && t.set(e === document ? document.scrollingElement : e, n);
			},
			get: (e) => t.get(e),
			has: (e) => t.has(e)
		};
	}(), a), { stop: d } = function(t, e, n, o, s, i = he()) {
		pe(H(), 0, e, n, s, i);
		const { unsubscribe: r } = t.subscribe(2, (t) => {
			o(), pe(t.startClocks.timeStamp, 1, e, n, s, i);
		});
		return { stop: r };
	}(i, r, o, u, c);
	function u() {
		a.flush(), l.flush();
	}
	const l = Me(document, r, o, c), f = [
		l,
		Se(r, c),
		we(r, c),
		Ne(document, r, c),
		Ee(r, c),
		_e(document, r, c),
		Te(r, c),
		xe(r, c),
		De(r, c),
		be(r, c),
		Re(i, r, c),
		Oe(i, r, u)
	];
	return {
		stop: () => {
			a.stop(), f.forEach((t) => t.stop()), d();
		},
		flushMutations: u,
		shadowRootsController: a
	};
}
function Le({ context: t, creationReason: e, encoder: n }) {
	let o = 0;
	const s = t.view.id, i = {
		start: Infinity,
		end: -Infinity,
		creation_reason: e,
		records_count: 0,
		has_full_snapshot: !1,
		index_in_view: M(s),
		source: "browser",
		...t
	}, r = {
		cssText: {
			count: 0,
			max: 0,
			sum: 0
		},
		serializationDuration: {
			count: 0,
			max: 0,
			sum: 0
		}
	};
	return z(s), {
		addRecord: function(t, e) {
			i.start = Math.min(i.start, t.timestamp), i.end = Math.max(i.end, t.timestamp), i.records_count += 1, i.has_full_snapshot || (i.has_full_snapshot = t.type === Q || t.type === rt && 0 === i.index_in_view);
			const s = n.isEmpty ? "{\"records\":[" : ",";
			n.write(s + JSON.stringify(t), (t) => {
				o += t, e(o);
			});
		},
		addStats: function(t) {
			(function(t, e) {
				for (const n of ["cssText", "serializationDuration"]) t[n].count += e[n].count, t[n].max = Math.max(t[n].max, e[n].max), t[n].sum += e[n].sum;
			})(r, t);
		},
		flush: function(t) {
			if (n.isEmpty) throw new Error("Empty segment flushed");
			n.write(`],${JSON.stringify(i).slice(1)}\n`), n.finish((e) => {
				$(i.view.id, e.rawBytesCount), t(i, r, e);
			});
		}
	};
}
const Pe = 5 * D;
let ke = 6e4;
function ze(t, e, n, o, s, i) {
	return function(t, e, n, o) {
		let s = {
			status: 0,
			nextSegmentCreationReason: "init"
		};
		const { unsubscribe: i } = t.subscribe(2, () => {
			a("view_change");
		}), { unsubscribe: r } = t.subscribe(11, (t) => {
			a(t.reason);
		});
		function a(t) {
			1 === s.status && (s.segment.flush((e, o, s) => {
				const i = function(t, e, n, o) {
					const s = new FormData();
					s.append("segment", new Blob([t], { type: "application/octet-stream" }), `${e.session.id}-${e.start}`);
					const i = {
						raw_segment_size: o,
						compressed_segment_size: t.byteLength,
						...e
					}, r = JSON.stringify(i);
					return s.append("event", new Blob([r], { type: "application/json" })), {
						data: s,
						bytesCount: t.byteLength,
						cssText: n.cssText,
						isFullSnapshot: 0 === e.index_in_view,
						rawSize: o,
						recordCount: e.records_count,
						serializationDuration: n.serializationDuration
					};
				}(s.output, e, o, s.rawBytesCount);
				d(t) ? n.sendOnExit(i) : n.send(i);
			}), x(s.expirationTimeoutId)), s = "stop" !== t ? {
				status: 0,
				nextSegmentCreationReason: t
			} : { status: 2 };
		}
		return {
			addRecord: (t) => {
				if (2 !== s.status) {
					if (0 === s.status) {
						const t = e();
						if (!t) return;
						s = {
							status: 1,
							segment: Le({
								encoder: o,
								context: t,
								creationReason: s.nextSegmentCreationReason
							}),
							expirationTimeoutId: P(() => {
								a("segment_duration_limit");
							}, Pe)
						};
					}
					s.segment.addRecord(t, (t) => {
						t > ke && a("segment_bytes_limit");
					});
				}
			},
			addStats: (t) => {
				1 === s.status && s.segment.addStats(t);
			},
			stop: () => {
				a("stop"), i(), r();
			}
		};
	}(t, () => function(t, e, n) {
		const o = e.findTrackedSession(), s = n.findView();
		if (!o || !s) return;
		return {
			application: { id: t },
			session: { id: o.id },
			view: { id: s.id }
		};
	}(e.applicationId, n, o), s, i);
}
function Ve(t, e, n, o, s, i, a) {
	const c = [], d = a || Z([e.sessionReplayEndpointBuilder], (e) => {
		t.notify(14, { error: e }), h("Error reported to customer", { "error.message": e.message });
	}, ke);
	let u, f;
	if (l()) ({addRecord: u} = function(t) {
		const e = m();
		return { addRecord: (n) => {
			const o = t.findView();
			e.send("record", n, o.id);
		} };
	}(o)), f = g;
	else {
		const a = ze(t, e, n, o, d, s);
		u = a.addRecord, f = a.addStats, c.push(a.stop);
		const l = function(t, e) {
			if (!t.metricsEnabled) return { stop: g };
			const { unsubscribe: n } = e.subscribe((t) => {
				var e, n, o;
				("failure" === t.type || "queue-full" === t.type || "success" === t.type && t.payload.isFullSnapshot) && r("Segment network request metrics", { metrics: (e = t.type, n = t.bandwidth, o = t.payload, {
					cssText: {
						count: o.cssText.count,
						max: o.cssText.max,
						sum: o.cssText.sum
					},
					encoding: {
						fullSnapshot: Ot() ? "change" : "v1",
						incrementalSnapshot: _t() ? "change" : "v1"
					},
					isFullSnapshot: o.isFullSnapshot,
					ongoingRequests: {
						count: n.ongoingRequestCount,
						totalSize: n.ongoingByteCount
					},
					recordCount: o.recordCount,
					result: e,
					serializationDuration: {
						count: o.serializationDuration.count,
						max: o.serializationDuration.max,
						sum: o.serializationDuration.sum
					},
					size: {
						compressed: o.bytesCount,
						raw: o.rawSize
					}
				}) });
			});
			return { stop: n };
		}(i, d.observable);
		c.push(l.stop);
	}
	const { stop: p } = Ae({
		emitRecord: u,
		emitStats: f,
		configuration: e,
		lifeCycle: t,
		viewHistory: o
	});
	return c.push(p), { stop: () => {
		c.forEach((t) => t());
	} };
}
export { Ve as startRecording };
