// Metro module 1089 (f1090). import * as _objectWithoutProperties from "./_objectWithoutProperties"; import * as _classCallCheck from "./_classCallCheck"; import * as _createClass from "./_createClass"; import { defineIntegration } from "./Module817"; import { HermesBuiltin, $withEnv } from "../_hermes/prelude"; function $mk67994($env) { return (a0) => { let r16; if (a0 === null) { return false; } L8: { L9: { L4: { try { const r6 = $env; const r5 = r6[0]; if (r5) { if (typeof r5 === "string") { if (a0.matches(`.${r5}`)) { break L9; } } else if ((function elementClassMatchesRegex(a0, a1) { let r12; const r7 = +a0.classList.length; let r2 = r7 - 1; if (r7) { do { const r10 = a1.test(a0.classList[r2]); const r11 = r2; if (r10) { return true; } r12 = +r11; r2 = r12 - 1; } while (r12); } return false; })(a0, r5)) { break L4; } } const r15 = r6[1]; r16 = !r15; if (!r15) { break L8; } r16 = !a0.matches(r15); break L8; } catch ($e) { return false; } } return true; } return true; } return !r16; }; } function $mk67996($env) { return () => { const r1 = $env; const r6 = r1[0]; const r5 = r1[1]; const r4 = r1[3] || {}; let env24164; const r9 = env24164 = { $parent: $env.$parent }; env24164[0] = r6; env24164[1] = r5; env24164[2] = r4; const r10 = window; env24164[3] = void 0; env24164[3] = r10.Object.getOwnPropertyDescriptor(r6, r5); r10.Object.defineProperty(r6, r5, r4); return $mk67996(r9); }; } function $mk68016($env) { return function(...args) { let r13; try { r13 = $env[0].apply(void 0, [...args]); } catch (r14) { const r16 = $env.$parent[18]; if (r16 && r16(r14) === true) { return () => {}; } throw r14; } return r13; }; } function $mk68017($env) { return (a0) => { const r1 = $env; return (0, $env.$parent[24])(a0, r1[0], r1[1]); }; } function $mk68018($env) { return (a0) => typeof $env[1][a0] === "function"; } function $mk68019($env) { return (a0) => { const r1 = $env; return r1[0] instanceof r1[1][a0]; }; } let hookSetter, patch, isBlocked, getImplementation, onRequestAnimationFrame, setTimeout$1, serializeArg, initCanvasContextObserver, patchGLPrototype, _excluded, defineProperty, __publicField$1, c899_8, c899_10, c899_14, c899_19, callbackWrapper, c899_21; let env899 = {}; const distanceToMatch = function distanceToMatch(a0, a1, r10 = Infinity, r6 = 0) { return a0 ? a0.nodeType === a0.ELEMENT_NODE ? r6 > r10 ? -1 : a1(a0) ? r6 : distanceToMatch(a0.parentNode, a1, r10, r6 + 1) : -1 : -1; }; hookSetter = function hookSetter(a0, a1, a2, a3) { let env12774; const r1 = env12774 = { $parent: env899 }; env12774[0] = a0; env12774[1] = a1; let r4 = a2; env12774[2] = a2; let r2 = arguments[4]; if (r2 === void 0) { r2 = window; } env12774[3] = void 0; env12774[3] = r2.Object.getOwnPropertyDescriptor(a0, a1); const Object2 = r2.Object; if (!a3) { r4 = { set: function set(a0) { setTimeout$1(() => { env12774[2].set.call(this, a0); }, 0); const r10 = env12774[3]; if (r10 && r10.set) { r10.set.call(this, a0); } } }; } Object2.defineProperty(a0, a1, r4); return $mk67996(r1); }; patch = function patch(a0, a1, a2) { let c12775_2; L8: { try { if (a1 in a0) { const value2 = a0[a1]; c12775_2 = value2; const r14 = a2(value2); if (typeof r14 === "function") { r14.prototype = r14.prototype || {}; Object.defineProperties(r14, { __rrweb_original__: { enumerable: false, value: value2 } }); } a0[a1] = r14; break L8; } } catch ($e) { return () => {}; } return () => {}; } return () => { a0[a1] = c12775_2; }; }; isBlocked = function isBlocked(a0, a1, a2, a3, a4) { if (a0) { const r12 = (function closestElementOfNode(a0) { let r4; if (a0) { try { r4 = a0.nodeType !== a0.ELEMENT_NODE ? a0.parentElement : a0; } catch ($e) { return null; } return r4; } return null; })(a0); if (r12) { let env12776; const r26 = env12776 = {}; env12776[0] = a1; env12776[1] = a2; const r18 = $mk67994(r26); if (a4) { let r30 = -1; if (r12) { const { nodeType, ELEMENT_NODE } = r12; let r33 = -1; if (nodeType === ELEMENT_NODE) { const r34 = r18(r12); let r35 = 0; if (!r34) { const parentNode = r12.parentNode; r35 = parentNode ? parentNode.nodeType === parentNode.ELEMENT_NODE ? Infinity < 1 ? -1 : r18(parentNode) ? 1 : distanceToMatch(parentNode.parentNode, r18, Infinity, 1 + 1) : -1 : -1; } r33 = r35; } r30 = r33; } let r42 = !(r30 < 0); if (r42) { let r43 = -1; if (a3) { let env12777; const r44 = env12777 = {}; env12777[0] = null; env12777[1] = a3; let r45 = -1; if (r12) { const { nodeType: nodeType2, ELEMENT_NODE: ELEMENT_NODE2 } = r12; let r48 = -1; if (nodeType2 === ELEMENT_NODE2) { const r49 = $mk67994(r44); const r50 = r49(r12); let r51 = 0; if (!r50) { const parentNode2 = r12.parentNode; r51 = parentNode2 ? parentNode2.nodeType === parentNode2.ELEMENT_NODE ? Infinity < 1 ? -1 : r49(parentNode2) ? 1 : distanceToMatch(parentNode2.parentNode, r49, Infinity, 1 + 1) : -1 : -1; } r48 = r51; } r45 = r48; } r43 = r45; } r42 = r30 > -1 && r43 < 0 || r30 < r43; } return r42; } const r27 = a3 ? r12.matches(a3) : a3; return r18(r12) && !r27; } return false; } return false; }; getImplementation = function getImplementation(a0) { const r11 = c899_14[a0]; if (r11) { return r11; } const document2 = window.document; let r13 = window[a0]; if (document2 && typeof document2.createElement === "function") { try { const element = document2.createElement("iframe"); element.hidden = true; document2.head.appendChild(element); let contentWindow = element.contentWindow; const r22 = contentWindow; if (contentWindow) { contentWindow = r22[a0]; } if (contentWindow) { r13 = r22[a0]; } document2.head.removeChild(element); } catch ($e) {} } const r31 = r13.bind(window); c899_14[a0] = r31; return r31; }; onRequestAnimationFrame = function onRequestAnimationFrame(...args) { return getImplementation("requestAnimationFrame").apply(void 0, [...args]); }; setTimeout$1 = function setTimeout$1(...args) { return getImplementation("setTimeout").apply(void 0, [...args]); }; serializeArg = function serializeArg(a0, a1, a2) { let r68; if (a0 instanceof Array) { return a0.map((item) => serializeArg(item, a1, a2)); } if (a0 === null) { return a0; } if (!(a0 instanceof Float32Array) && !(a0 instanceof Float64Array) && !(a0 instanceof Int32Array) && !(a0 instanceof Uint32Array) && !(a0 instanceof Uint8Array) && !(a0 instanceof Uint16Array) && !(a0 instanceof Int16Array) && !(a0 instanceof Int8Array) && !(a0 instanceof Uint8ClampedArray)) { if (a0 instanceof ArrayBuffer) { const uint8Array = new Uint8Array(a0); const length = uint8Array.length; const r110 = 0 < length; let r111 = ""; let r2 = 0; let r112 = ""; if (r110) { do { const r24 = r111 + c899_21[uint8Array[r2] >> 2]; const r0 = 3 & uint8Array[r2]; const r116 = r2 + 1; const r121 = r24 + c899_21[r0 << 4 | uint8Array[r116] >> 4]; const r123 = 15 & uint8Array[r116]; const r124 = r2 + 2; r111 = r121 + c899_21[r123 << 2 | uint8Array[r124] >> 6] + c899_21[63 & uint8Array[r124]]; r2 = r2 + 3; r112 = r111; } while (r2 < length); } return { rr_type: a0.constructor.name, base64: length % 3 === 2 ? r112.substring(0, r112.length - 1) + "=" : length % 3 === 1 ? r112.substring(0, r112.length - 2) + "==" : r112 }; } if (a0 instanceof DataView) { return { rr_type: a0.constructor.name, args: [serializeArg(a0.buffer, a1, a2), a0.byteOffset, a0.byteLength] }; } if (a0 instanceof HTMLImageElement) { return { rr_type: a0.constructor.name, src: a0.src }; } if (a0 instanceof HTMLCanvasElement) { return { rr_type: "HTMLImageElement", src: a0.toDataURL() }; } L23: { if (a0 instanceof ImageData) { r68 = { rr_type: a0.constructor.name, args: [serializeArg(a0.data, a1, a2), a0.width, a0.height] }; } else { let env12779; const r60 = env12779 = {}; env12779[0] = a0; env12779[1] = a1; if (!Boolean(["WebGLActiveInfo", "WebGLBuffer", "WebGLFramebuffer", "WebGLProgram", "WebGLRenderbuffer", "WebGLShader", "WebGLShaderPrecisionFormat", "WebGLTexture", "WebGLUniformLocation", "WebGLVertexArrayObject", "WebGLVertexArrayObjectOES"].filter($mk68018(r60)).find($mk68019(r60)))) { r68 = a0; if (typeof a0 !== "object") { break L23; } } r68 = { rr_type: a0.constructor.name, index: (0, env899[23])(a0, a1, a2) }; } } return r68; } return { rr_type: a0.constructor.name, args: [Object.values(a0)] }; }; initCanvasContextObserver = function initCanvasContextObserver(a0, c12780_0, c12780_1, c12780_2, c12780_3) { const r3 = []; let c12780_4 = r3; try { r3.push(patch(a0.HTMLCanvasElement.prototype, "getContext", function(c24165_0) { return function(a0) { let r8; L12: { r8 = Array.prototype.slice.call(arguments, 1); if (!isBlocked(this, c12780_0, c12780_1, c12780_2, true)) { const __context = a0 !== "experimental-webgl" ? a0 : "webgl"; if (!("__context" in this)) { this.__context = __context; } if (c12780_3 && ["webgl", "webgl2"].includes(__context)) { if (r8[0] && typeof r8[0] === "object") { const r31 = r8[0]; if (r31.preserveDrawingBuffer) { break L12; } r31.preserveDrawingBuffer = true; break L12; } r8.splice(0, 1, { preserveDrawingBuffer: true }); } } } return c24165_0.apply(this, [a0, ...r8]); }; })); } catch ($e) { console.error("failed to patch HTMLCanvasElement.prototype.getContext"); } return () => { c12780_4.forEach((item) => item()); }; }; patchGLPrototype = function patchGLPrototype(a0, type, c12781_2, c12781_3, c12781_4, c12781_5, a6, c12781_6) { let c12781_0 = a0; const r23 = []; let c12781_7 = r23; const ownPropertyNames = Object.getOwnPropertyNames(a0); const _loop2 = function _loop2(a0) { const property = a0; if (["isContextLost", "canvas", "drawingBufferWidth", "drawingBufferHeight"].includes(a0)) { return 0; } L4: { try { if (typeof c12781_0[a0] !== "function") { break L4; } c12781_7.push(patch(c12781_0, a0, function(c28804_0) { return function(...args) { const r21 = c28804_0.apply(this, args); const r6 = env899; const r9 = env899[23]; r9(r21, c12781_6, this); if ("tagName" in this.canvas && !isBlocked(this.canvas, c12781_3, c12781_4, c12781_5, true)) { let env31207; const r30 = env31207 = { $parent: r6 }; env31207[0] = c12781_6; env31207[1] = this; c12781_2(this.canvas, { type, property, args: args.map($mk68017(r30)) }); } return r21; }; })); } catch ($e) { c12781_7.push(hookSetter(c12781_0, a0, { set: function set(a0) { c12781_2(this.canvas, { type, property, args: [a0], setter: true }); } })); } return void 0; } return 0; }; for (const item of ownPropertyNames) { _loop2(item); } return r23; }; _excluded = ["type"]; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); defineProperty = Object.defineProperty; __publicField$1 = (a0, a1, a2) => {}; c899_8 = (function() { "use strict"; const Mirror2 = function Mirror() { _classCallCheck(this, Mirror2); const map = new Map(); if ("idNodeMap" in this) { defineProperty(this, "idNodeMap", { enumerable: true, configurable: true, writable: true, value: map }); } else { this.idNodeMap = map; } const weakMap = new WeakMap(); if ("nodeMetaMap" in this) { defineProperty(this, "nodeMetaMap", { enumerable: true, configurable: true, writable: true, value: weakMap }); } else { this.nodeMetaMap = weakMap; } }; return _createClass(Mirror2, [{ key: "getId", value: function getId(a0) { if (a0) { let r7 = this.getMeta(a0)?.id; if (r7 == null) { r7 = -1; } return r7; } return -1; } }, { key: "getNode", value: function getNode(a0) { return this.idNodeMap.get(a0) || null; } }, { key: "getIds", value: function getIds() { return Array.from(this.idNodeMap.keys()); } }, { key: "getMeta", value: function getMeta(a0) { return this.nodeMetaMap.get(a0) || null; } }, { key: "removeNodeFromMap", value: function removeNodeFromMap(a0) { this.idNodeMap.delete(this.getId(a0)); if (a0.childNodes) { a0.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode)); } } }, { key: "has", value: function has(a0) { return this.idNodeMap.has(a0); } }, { key: "hasNode", value: function hasNode(a0) { return this.nodeMetaMap.has(a0); } }, { key: "add", value: function add(a0, a1) { this.idNodeMap.set(a1.id, a0); this.nodeMetaMap.set(a0, a1); } }, { key: "replace", value: function replace(a0, a1) { const node = this.getNode(a0); if (node) { const r8 = this.nodeMetaMap.get(node); if (r8) { this.nodeMetaMap.set(a1, r8); } } this.idNodeMap.set(a0, a1); } }, { key: "reset", value: function reset() { this.idNodeMap = new Map(); this.nodeMetaMap = new WeakMap(); } }]); })(); c899_10 = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording."; const r11 = { map: {}, getId: () => { console.error(c899_10); return -1; }, getNode: () => { console.error(c899_10); return null; }, removeNodeFromMap: () => { console.error(c899_10); }, has: () => { console.error(c899_10); return false; }, reset: () => { console.error(c899_10); } }; const window2 = globalThis.window; if ((typeof window2 !== "undefined" ? window.Proxy : typeof window2 !== "undefined") && window.Reflect) { new Proxy(r11, { get: (a0, a1, a2) => { if (a1 === "map") { console.error(c899_10); } return Reflect.get(a0, a1, a2); } }); } Date.now().toString(); c899_14 = {}; const r68 = {}; ((a0) => { a0["2D"] = 0; a0[0] = "2D"; a0.WebGL = 1; a0[1] = "WebGL"; a0.WebGL2 = 2; a0[2] = "WebGL2"; return a0; })(r68); c899_19 = r68; callbackWrapper = (a0) => {}; c899_21 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; const r78 = typeof globalThis.Uint8Array === "undefined" ? [] : new Uint8Array(256); let r81 = 0; while (true) { r78[c899_21.charCodeAt(r81)] = r81; r81 = r81 + 1; if (!(r81 < 64)) { env899[22] = new Map(); env899[23] = (a0, a1, a2) => { L5: { if (a0) { let env12783; const r4 = env12783 = {}; env12783[0] = a0; env12783[1] = a1; if (!Boolean(["WebGLActiveInfo", "WebGLBuffer", "WebGLFramebuffer", "WebGLProgram", "WebGLRenderbuffer", "WebGLShader", "WebGLShaderPrecisionFormat", "WebGLTexture", "WebGLUniformLocation", "WebGLVertexArrayObject", "WebGLVertexArrayObjectOES"].filter($mk68018(r4)).find($mk68019(r4))) && typeof a0 !== "object") { break L5; } const name = a0.constructor.name; const r25 = env899[22]; let r27 = r25.get(a2); if (!r27) { const map = new Map(); r25.set(a2, map); r27 = map; } if (!r27.has(name)) { r27.set(name, []); } const r40 = r27.get(name); let r42 = r40.indexOf(a0); if (r42 === -1) { r42 = r40.length; r40.push(a0); } return r42; } } }; env899[25] = (a0, a1, a2) => {}; env899[26] = (a0, a1) => {}; env899[29] = (function() { "use strict"; const CanvasManager2 = function CanvasManager(a0) { let recordCanvas, sampling; const _this = this; const r5 = env899; _classCallCheck(this, CanvasManager2); this.pendingCanvasMutations = new Map(); this.rafStamps = { latestId: 0, invokeId: null }; this.shadowDoms = new Set(); this.windowsSet = new WeakSet(); this.windows = []; this.restoreHandlers = []; this.frozen = false; this.locked = false; this.snapshotInProgressMap = new Map(); this.worker = null; this.lastSnapshotTime = 0; this.processMutation = (a0, a1) => { const r3 = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId; if (!(r3 ? !r3 : _this.rafStamps.invokeId)) { _this.rafStamps.invokeId = _this.rafStamps.latestId; } if (!_this.pendingCanvasMutations.has(a0)) { _this.pendingCanvasMutations.set(a0, []); } _this.pendingCanvasMutations.get(a0).push(a1); }; const { enableManualSnapshot: enableManualSnapshot2, sampling: sampling3 } = a0; sampling = sampling3 !== void 0 ? sampling3 : "all"; const win = a0.win; let recordCanvas3 = a0.recordCanvas; recordCanvas = recordCanvas3; const errorHandler2 = a0.errorHandler; a0.sampling = sampling; this.mutationCb = a0.mutationCb; this.mirror = a0.mirror; this.options = a0; if (errorHandler2) { env899[18] = errorHandler2; } if (recordCanvas) { recordCanvas3 = typeof sampling === "number"; } if (!recordCanvas3) { recordCanvas3 = enableManualSnapshot2; } if (recordCanvas3) { this.worker = this.initFPSWorker(); } this.addWindow(win); if (!enableManualSnapshot2) { let env24169; let r53 = () => { let r2 = recordCanvas; if (recordCanvas ? sampling === "all" : recordCanvas) { _this.startRAFTimestamping(); _this.startPendingCanvasMutationFlusher(); } if (recordCanvas) { r2 = typeof sampling === "number"; } if (r2) { _this.initCanvasFPSObserver(); } }; const r54 = env24169 = { $parent: r5 }; env24169[0] = r53; if (env899[18]) { r53 = $mk68016(r54); } r53(); } }; return _createClass(CanvasManager2, [{ key: "reset", value: function reset() { this.pendingCanvasMutations.clear(); this.restoreHandlers.forEach((restoreHandler) => { try { restoreHandler(); } catch ($e) {} }); this.restoreHandlers = []; this.windowsSet = new WeakSet(); this.windows = []; this.shadowDoms = new Set(); const worker = this.worker; if (worker != null) { worker.terminate(); } this.worker = null; this.snapshotInProgressMap = new Map(); } }, { key: "freeze", value: function freeze() { this.frozen = true; } }, { key: "unfreeze", value: function unfreeze() { this.frozen = false; } }, { key: "lock", value: function lock() { this.locked = true; } }, { key: "unlock", value: function unlock() { this.locked = false; } }, { key: "addWindow", value: function addWindow(a0) { const options = this.options; const { sampling: sampling2 = "all", blockClass, blockSelector, unblockSelector, recordCanvas: recordCanvas2, enableManualSnapshot: enableManualSnapshot2 } = options; if (!this.windowsSet.has(a0)) { if (enableManualSnapshot2) { this.windowsSet.add(a0); this.windows.push(new WeakRef(a0)); return void 0; } let env24171; let r21 = () => { if (recordCanvas2 ? sampling2 === "all" : recordCanvas2) { this.initCanvasMutationObserver(a0, blockClass, blockSelector, unblockSelector); } if (recordCanvas2 && typeof sampling2 === "number") { let c28805_0 = initCanvasContextObserver(a0, blockClass, blockSelector, unblockSelector, true); this.restoreHandlers.push(() => { c28805_0(); }); } }; const r22 = env24171 = { $parent: env899 }; env24171[0] = r21; if (env899[18]) { r21 = $mk68016(r22); } r21(); this.windowsSet.add(a0); this.windows.push(new WeakRef(a0)); } } }, { key: "addShadowRoot", value: function addShadowRoot(a0) { this.shadowDoms.add(new WeakRef(a0)); } }, { key: "resetShadowRoots", value: function resetShadowRoots() { this.shadowDoms = new Set(); } }, { key: "snapshot", value: function snapshot(a0, a1) { let c24172_0 = a0; if (a1?.skipRequestAnimationFrame) { this.takeSnapshot(performance.now(), true, a0); } else { onRequestAnimationFrame((a0) => this.takeSnapshot(a0, true, c24172_0)); } } }, { key: "initFPSWorker", value: function initFPSWorker() { const worker = new Worker(URL.createObjectURL(new Blob(["for(var e=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",t=\"undefined\"==typeof Uint8Array?[]:new Uint8Array(256),a=0;a<64;a++)t[e.charCodeAt(a)]=a;var n=function(t){var a,n=new Uint8Array(t),r=n.length,s=\"\";for(a=0;a>2],s+=e[(3&n[a])<<4|n[a+1]>>4],s+=e[(15&n[a+1])<<2|n[a+2]>>6],s+=e[63&n[a+2]];return r%3==2?s=s.substring(0,s.length-1)+\"=\":r%3==1&&(s=s.substring(0,s.length-2)+\"==\"),s};const r=new Map,s=new Map;const i=self;i.onmessage=async function(e){if(!(\"OffscreenCanvas\"in globalThis))return i.postMessage({id:e.data.id});{const{id:t,bitmap:a,width:o,height:f,maxCanvasSize:c,dataURLOptions:g}=e.data,u=async function(e,t,a){const r=e+\"-\"+t;if(\"OffscreenCanvas\"in globalThis){if(s.has(r))return s.get(r);const i=new OffscreenCanvas(e,t);i.getContext(\"2d\");const o=await i.convertToBlob(a),f=await o.arrayBuffer(),c=n(f);return s.set(r,c),c}return\"\"}(o,f,g),[h,d]=function(e,t,a){if(!a)return[e,t];const[n,r]=a;if(e<=n&&t<=r)return[e,t];let s=e,i=t;return s>n&&(i=Math.floor(n*t/e),s=n),i>r&&(s=Math.floor(r*e/t),i=r),[s,i]}(o,f,c),l=new OffscreenCanvas(h,d),w=l.getContext(\"bitmaprenderer\"),p=h===o&&d===f?a:await createImageBitmap(a,{resizeWidth:h,resizeHeight:d,resizeQuality:\"low\"});w?.transferFromImageBitmap(p),a.close();const y=await l.convertToBlob(g),v=y.type,b=await y.arrayBuffer(),m=n(b);if(p.close(),!r.has(t)&&await u===m)return r.set(t,m),i.postMessage({id:t});if(r.get(t)===m)return i.postMessage({id:t});i.postMessage({id:t,type:v,base64:m,width:o,height:f}),r.set(t,m)}};"]))); worker.onmessage = ({ data }) => { const id2 = data.id; this.snapshotInProgressMap.set(id2, false); if ("base64" in data) { const { base64, type: type2, width, height } = data; this.mutationCb({ id: id2, type: c899_19["2D"], commands: [{ property: "clearRect", args: [0, 0, width, height] }, { property: "drawImage", args: [{ rr_type: "ImageBitmap", args: [{ rr_type: "Blob", data: [{ rr_type: "ArrayBuffer", base64 }], type: type2 }] }, 0, 0, width, height] }] }); } }; return worker; } }, { key: "initCanvasFPSObserver", value: function initCanvasFPSObserver() { let rafCallback2, c24174_1; if (!(!this.windows.length && !this.shadowDoms.size)) { rafCallback2 = (a0) => { this.takeSnapshot(a0, false); c24174_1 = onRequestAnimationFrame(rafCallback2); }; c24174_1 = onRequestAnimationFrame(rafCallback2); this.restoreHandlers.push(() => { if (c24174_1) { cancelAnimationFrame(c24174_1); } }); } } }, { key: "initCanvasMutationObserver", value: function initCanvasMutationObserver(a0, a1, a2, a3) { let c24175_2; let env24176; let c24175_0 = initCanvasContextObserver(a0, a1, a2, a3, false); let c24175_1 = (function initCanvas2DMutationObserver(c28806_0, a1, c28806_2, c28806_3, c28806_4) { let c28806_5 = []; const ownPropertyNames = Object.getOwnPropertyNames(a1.CanvasRenderingContext2D.prototype); const _loop = function _loop(a0) { const property2 = a0; L3: { try { if (typeof a1.CanvasRenderingContext2D.prototype[a0] !== "function") { break L3; } c28806_5.push(patch(a1.CanvasRenderingContext2D.prototype, a0, function(c31876_0) { return function(...args) { let c32093_0 = args; if (!isBlocked(this.canvas, c28806_2, c28806_3, c28806_4, true)) { setTimeout$1(() => { const r5 = env899; const r3 = env899[25]; let env32159; const r11 = env32159 = { $parent: r5 }; env32159[0] = a1; env32159[1] = this; c28806_0(this.canvas, { type: c899_19["2D"], property: property2, args: c32093_0.map($mk68017(r11)) }); }, 0); } return c31876_0.apply(this, args); }; })); } catch ($e) { c28806_5.push(hookSetter(a1.CanvasRenderingContext2D.prototype, a0, { set: function set(a0) { c28806_0(this.canvas, { type: c899_19["2D"], property: property2, args: [a0], setter: true }); } })); } return void 0; } return 1; }; for (const item of ownPropertyNames) { _loop(item); } return () => { c28806_5.forEach((item) => item()); }; })(this.processMutation.bind(this), a0, a1, a2, a3); const r12 = this.processMutation.bind(this); this.mirror; const r40 = env24176 = {}; const r9 = []; env24176[0] = r9; const push = r9.push; const prototype = a0.WebGLRenderingContext.prototype; push.apply(r9, [...patchGLPrototype(prototype, c899_19.WebGL, r12, a1, a2, a3, 0, a0)]); if (a0.WebGL2RenderingContext !== void 0) { r9.push.apply(r9, [...patchGLPrototype(a0.WebGL2RenderingContext.prototype, c899_19.WebGL2, r12, a1, a2, a3, 0, a0)]); } c24175_2 = $withEnv(() => {}, r40); this.restoreHandlers.push(() => { c24175_0(); c24175_1(); c24175_2.$env[0].forEach((item) => item()); }); } }, { key: "getCanvasElements", value: function getCanvasElements(c24177_0, c24177_1, c24177_2) { const r26 = []; let c24177_3 = r26; const searchCanvas = (a0) => { a0.querySelectorAll("canvas").forEach((item) => { if (!isBlocked(item, c24177_0, c24177_1, c24177_2, true)) { c24177_3.push(item); } }); }; for (const window2 of this.windows) { const r32 = window2.deref(); let r33 = void 0; try { r33 = r32 && r32.document; } catch ($e) {} if (r33) { searchCanvas(r33); } } for (const shadowDom of this.shadowDoms) { const r49 = shadowDom.deref(); if (r49) { searchCanvas(r49); } } return r26; } }, { key: "takeSnapshot", value: function takeSnapshot(a0, c24178_1, a2) { const options = this.options; let sampling3 = options.sampling; const { blockClass: blockClass2, blockSelector: blockSelector2, unblockSelector: unblockSelector2, dataURLOptions, maxCanvasSize } = options; let r14 = 2; if (sampling3 !== "all") { if (!sampling3) { sampling3 = 2; } r14 = sampling3; } const r17 = 1000 / r14; const r18 = this.lastSnapshotTime && a0 - this.lastSnapshotTime < r17; let r1 = !r18; if (!r18) { this.lastSnapshotTime = a0; (a2 ? [a2] : this.getCanvasElements(blockClass2, blockSelector2, unblockSelector2)).forEach((item) => { const id = this.mirror.getId(item); if (this.mirror.hasNode(item) && item.width && item.height && !this.snapshotInProgressMap.get(id)) { this.snapshotInProgressMap.set(id, true); if (!c24178_1 && ["webgl", "webgl2"].includes(item.__context)) { const context = item.getContext(item.__context); if ((context == null ? void 0 : context.getContextAttributes()?.preserveDrawingBuffer) === false) { context.clear(context.COLOR_BUFFER_BIT); } } createImageBitmap(item).then((result) => { const worker = this.worker; if (worker != null) { worker.postMessage({ id, bitmap: result, width: item.width, height: item.height, dataURLOptions, maxCanvasSize }, [result]); } }).catch((c31209_0) => { const r3 = env899; let env31210; let r7 = () => { this.snapshotInProgressMap.delete(id); throw c31209_0; }; const r8 = env31210 = { $parent: r3 }; env31210[0] = r7; if (env899[18]) { r7 = $mk68016(r8); } r7(); }); } }); r1 = true; } return r1; } }, { key: "startPendingCanvasMutationFlusher", value: function startPendingCanvasMutationFlusher() { onRequestAnimationFrame(() => this.flushPendingCanvasMutations()); } }, { key: "startRAFTimestamping", value: function startRAFTimestamping() { const setLatestRAFTimestamp2 = (a0) => { this.rafStamps.latestId = a0; onRequestAnimationFrame(setLatestRAFTimestamp2); }; onRequestAnimationFrame(setLatestRAFTimestamp2); } }, { key: "flushPendingCanvasMutations", value: function flushPendingCanvasMutations() { this.pendingCanvasMutations.forEach((pendingCanvasMutation, index) => { this.flushPendingCanvasMutationFor(index, this.mirror.getId(index)); }); onRequestAnimationFrame(() => this.flushPendingCanvasMutations()); } }, { key: "flushPendingCanvasMutationFor", value: function flushPendingCanvasMutationFor(a0, a1) { if (!this.frozen && !this.locked) { const r11 = this.pendingCanvasMutations.get(a0); if (r11 && a1 !== -1) { this.mutationCb({ id: a1, type: r11[0].type, commands: r11.map((item) => { item.type; return _objectWithoutProperties(item, _excluded); }) }); this.pendingCanvasMutations.delete(a0); } } } }]); })(); try { if (Array.from([1], (a0) => 2 * a0)[0] !== 2) { const element = document.createElement("iframe"); document.body.appendChild(element); const r109 = Array; const contentWindow = element.contentWindow; r109.from = (contentWindow == null ? void 0 : contentWindow.Array.from) || Array.from; document.body.removeChild(element); } } catch ($e) { console.debug("Unable to override Array.from", $e); } (function createMirror$2() { return new c899_8(); })(); const r128 = { NotStarted: 0, 0: "NotStarted", Running: 1, 1: "Running", Stopped: 2, 2: "Stopped" }; env899[30] = { low: { sampling: { canvas: 1 }, dataURLOptions: { type: "image/webp", quality: 0.25 } }, medium: { sampling: { canvas: 2 }, dataURLOptions: { type: "image/webp", quality: 0.4 } }, high: { sampling: { canvas: 4 }, dataURLOptions: { type: "image/webp", quality: 0.5 } } }; env899[31] = 1280; exports.replayCanvasIntegration = defineIntegration(function(r5 = {}) { let r18, r19; let c12785_0, c12785_1; c12785_0 = void 0; c12785_1 = void 0; const [r8, r9] = r5.maxCanvasSize || []; const quality = r5.quality || "medium"; if (r8) { const r7 = Math; const r2 = env899[31]; r19 = r7.min(r8, r2); r18 = r2; } else { r18 = env899[31]; r19 = r18; } let c12785_2 = { quality, enableManualSnapshot: r5.enableManualSnapshot, maxCanvasSize: [r19, r9 ? Math.min(r9, r18) : r18] }; const value = new Promise((resolve) => { c12785_1 = resolve; return resolve; }); return { name: "ReplayCanvas", getOptions: () => { const { enableManualSnapshot, maxCanvasSize: maxCanvasSize2 } = c12785_2; const r8 = { enableManualSnapshot, recordCanvas: true, getCanvasManager: (a0) => { const r15 = new env899[29]({ ...a0, enableManualSnapshot, maxCanvasSize: maxCanvasSize2, errorHandler: (a0) => { try { if (typeof a0 === "object") { a0.__rrweb__ = true; } } catch ($e) {} } }); c12785_0 = r15; c12785_1(r15); return r15; } }; const r10 = env899[30]; HermesBuiltin.copyDataProperties(r8, r10[c12785_2.quality] || r10.medium); return r8; }, snapshot: async (c24183_0, c24183_1) => { let c28808_0; L12: { c28808_0 = void 0; if (c12785_0) { c12785_0.snapshot(c24183_0, c24183_1); break L12; } (await value).snapshot(c24183_0, c24183_1); return void 0; } } }; }); return void 0; } }