{"version":3,"file":"rrweb.cjs","sources":["../../rrdom/dist/rrdom.js","../src/record/style-declaration-parser.ts","../src/record/mutation.ts","../src/record/observer.ts","../src/record/cross-origin-iframe-mirror.ts","../src/record/iframe-manager.ts","../src/record/shadow-dom-manager.ts","../src/record/stylesheet-manager.ts","../src/record/processed-node-manager.ts","../src/record/index.ts","../../../node_modules/mitt/dist/mitt.mjs","../src/replay/smoothscroll.ts","../src/replay/timer.ts","../../../node_modules/@xstate/fsm/es/index.js","../src/replay/machine.ts","../src/replay/styles/inject-style.ts","../src/replay/canvas/deserialize-args.ts","../src/replay/canvas/webgl.ts","../src/replay/canvas/2d.ts","../src/replay/canvas/index.ts","../src/replay/index.ts"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar __defProp2 = Object.defineProperty;\nvar __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField2 = (obj, key, value) => __defNormalProp2(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar NodeType$1 = /* @__PURE__ */ ((NodeType2) => {\n  NodeType2[NodeType2[\"Document\"] = 0] = \"Document\";\n  NodeType2[NodeType2[\"DocumentType\"] = 1] = \"DocumentType\";\n  NodeType2[NodeType2[\"Element\"] = 2] = \"Element\";\n  NodeType2[NodeType2[\"Text\"] = 3] = \"Text\";\n  NodeType2[NodeType2[\"CDATA\"] = 4] = \"CDATA\";\n  NodeType2[NodeType2[\"Comment\"] = 5] = \"Comment\";\n  return NodeType2;\n})(NodeType$1 || {});\nlet Mirror$1 = class Mirror {\n  constructor() {\n    __publicField2(this, \"idNodeMap\", /* @__PURE__ */ new Map());\n    __publicField2(this, \"nodeMetaMap\", /* @__PURE__ */ new WeakMap());\n  }\n  getId(n) {\n    if (!n) return -1;\n    const id = this.getMeta(n)?.id;\n    return id ?? -1;\n  }\n  getNode(id) {\n    return this.idNodeMap.get(id) || null;\n  }\n  getIds() {\n    return Array.from(this.idNodeMap.keys());\n  }\n  getMeta(n) {\n    return this.nodeMetaMap.get(n) || null;\n  }\n  // removes the node from idNodeMap\n  // doesn't remove the node from nodeMetaMap\n  removeNodeFromMap(n) {\n    const id = this.getId(n);\n    this.idNodeMap.delete(id);\n    if (n.childNodes) {\n      n.childNodes.forEach(\n        (childNode) => this.removeNodeFromMap(childNode)\n      );\n    }\n  }\n  has(id) {\n    return this.idNodeMap.has(id);\n  }\n  hasNode(node) {\n    return this.nodeMetaMap.has(node);\n  }\n  add(n, meta) {\n    const id = meta.id;\n    this.idNodeMap.set(id, n);\n    this.nodeMetaMap.set(n, meta);\n  }\n  replace(id, n) {\n    const oldNode = this.getNode(id);\n    if (oldNode) {\n      const meta = this.nodeMetaMap.get(oldNode);\n      if (meta) this.nodeMetaMap.set(n, meta);\n    }\n    this.idNodeMap.set(id, n);\n  }\n  reset() {\n    this.idNodeMap = /* @__PURE__ */ new Map();\n    this.nodeMetaMap = /* @__PURE__ */ new WeakMap();\n  }\n};\nfunction createMirror$1() {\n  return new Mirror$1();\n}\nfunction parseCSSText(cssText) {\n  const res = {};\n  const listDelimiter = /;(?![^(]*\\))/g;\n  const propertyDelimiter = /:(.+)/;\n  const comment = /\\/\\*.*?\\*\\//g;\n  cssText.replace(comment, \"\").split(listDelimiter).forEach(function(item) {\n    if (item) {\n      const tmp = item.split(propertyDelimiter);\n      tmp.length > 1 && (res[camelize(tmp[0].trim())] = tmp[1].trim());\n    }\n  });\n  return res;\n}\nfunction toCSSText(style) {\n  const properties = [];\n  for (const name in style) {\n    const value = style[name];\n    if (typeof value !== \"string\") continue;\n    const normalizedName = hyphenate(name);\n    properties.push(`${normalizedName}: ${value};`);\n  }\n  return properties.join(\" \");\n}\nconst camelizeRE = /-([a-z])/g;\nconst CUSTOM_PROPERTY_REGEX = /^--[a-zA-Z0-9-]+$/;\nconst camelize = (str) => {\n  if (CUSTOM_PROPERTY_REGEX.test(str)) return str;\n  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : \"\");\n};\nconst hyphenateRE = /\\B([A-Z])/g;\nconst hyphenate = (str) => {\n  return str.replace(hyphenateRE, \"-$1\").toLowerCase();\n};\nclass BaseRRNode {\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n  constructor(..._args) {\n    __publicField(this, \"parentElement\", null);\n    __publicField(this, \"parentNode\", null);\n    __publicField(this, \"ownerDocument\");\n    __publicField(this, \"firstChild\", null);\n    __publicField(this, \"lastChild\", null);\n    __publicField(this, \"previousSibling\", null);\n    __publicField(this, \"nextSibling\", null);\n    __publicField(this, \"ELEMENT_NODE\", 1);\n    __publicField(this, \"TEXT_NODE\", 3);\n    // corresponding nodeType value of standard HTML Node\n    __publicField(this, \"nodeType\");\n    __publicField(this, \"nodeName\");\n    __publicField(this, \"RRNodeType\");\n  }\n  get childNodes() {\n    const childNodes = [];\n    let childIterator = this.firstChild;\n    while (childIterator) {\n      childNodes.push(childIterator);\n      childIterator = childIterator.nextSibling;\n    }\n    return childNodes;\n  }\n  contains(node) {\n    if (!(node instanceof BaseRRNode)) return false;\n    else if (node.ownerDocument !== this.ownerDocument) return false;\n    else if (node === this) return true;\n    while (node.parentNode) {\n      if (node.parentNode === this) return true;\n      node = node.parentNode;\n    }\n    return false;\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  appendChild(_newChild) {\n    throw new Error(\n      `RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.`\n    );\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  insertBefore(_newChild, _refChild) {\n    throw new Error(\n      `RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.`\n    );\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  removeChild(_node) {\n    throw new Error(\n      `RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.`\n    );\n  }\n  toString() {\n    return \"RRNode\";\n  }\n}\nclass BaseRRDocument extends BaseRRNode {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  constructor(...args) {\n    super(args);\n    __publicField(this, \"nodeType\", 9);\n    __publicField(this, \"nodeName\", \"#document\");\n    __publicField(this, \"compatMode\", \"CSS1Compat\");\n    __publicField(this, \"RRNodeType\", NodeType$1.Document);\n    __publicField(this, \"textContent\", null);\n    this.ownerDocument = this;\n  }\n  get documentElement() {\n    return this.childNodes.find(\n      (node) => node.RRNodeType === NodeType$1.Element && node.tagName === \"HTML\"\n    ) || null;\n  }\n  get body() {\n    return this.documentElement?.childNodes.find(\n      (node) => node.RRNodeType === NodeType$1.Element && node.tagName === \"BODY\"\n    ) || null;\n  }\n  get head() {\n    return this.documentElement?.childNodes.find(\n      (node) => node.RRNodeType === NodeType$1.Element && node.tagName === \"HEAD\"\n    ) || null;\n  }\n  get implementation() {\n    return this;\n  }\n  get firstElementChild() {\n    return this.documentElement;\n  }\n  appendChild(newChild) {\n    const nodeType = newChild.RRNodeType;\n    if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) {\n      if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {\n        throw new Error(\n          `RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? \"RRElement\" : \"RRDoctype\"} on RRDocument allowed.`\n        );\n      }\n    }\n    const child = appendChild(this, newChild);\n    child.parentElement = null;\n    return child;\n  }\n  insertBefore(newChild, refChild) {\n    const nodeType = newChild.RRNodeType;\n    if (nodeType === NodeType$1.Element || nodeType === NodeType$1.DocumentType) {\n      if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {\n        throw new Error(\n          `RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? \"RRElement\" : \"RRDoctype\"} on RRDocument allowed.`\n        );\n      }\n    }\n    const child = insertBefore(this, newChild, refChild);\n    child.parentElement = null;\n    return child;\n  }\n  removeChild(node) {\n    return removeChild(this, node);\n  }\n  open() {\n    this.firstChild = null;\n    this.lastChild = null;\n  }\n  close() {\n  }\n  /**\n   * Adhoc implementation for setting xhtml namespace in rebuilt.ts (rrweb-snapshot).\n   * There are two lines used this function:\n   * 1. doc.write('\\<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"\"\\>')\n   * 2. doc.write('\\<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\"\\>')\n   */\n  write(content) {\n    let publicId;\n    if (content === '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"\">')\n      publicId = \"-//W3C//DTD XHTML 1.0 Transitional//EN\";\n    else if (content === '<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"\">')\n      publicId = \"-//W3C//DTD HTML 4.0 Transitional//EN\";\n    if (publicId) {\n      const doctype = this.createDocumentType(\"html\", publicId, \"\");\n      this.open();\n      this.appendChild(doctype);\n    }\n  }\n  createDocument(_namespace, _qualifiedName, _doctype) {\n    return new BaseRRDocument();\n  }\n  createDocumentType(qualifiedName, publicId, systemId) {\n    const doctype = new BaseRRDocumentType(qualifiedName, publicId, systemId);\n    doctype.ownerDocument = this;\n    return doctype;\n  }\n  createElement(tagName) {\n    const element = new BaseRRElement(tagName);\n    element.ownerDocument = this;\n    return element;\n  }\n  createElementNS(_namespaceURI, qualifiedName) {\n    return this.createElement(qualifiedName);\n  }\n  createTextNode(data) {\n    const text = new BaseRRText(data);\n    text.ownerDocument = this;\n    return text;\n  }\n  createComment(data) {\n    const comment = new BaseRRComment(data);\n    comment.ownerDocument = this;\n    return comment;\n  }\n  createCDATASection(data) {\n    const CDATASection = new BaseRRCDATASection(data);\n    CDATASection.ownerDocument = this;\n    return CDATASection;\n  }\n  toString() {\n    return \"RRDocument\";\n  }\n}\nclass BaseRRDocumentType extends BaseRRNode {\n  constructor(qualifiedName, publicId, systemId) {\n    super();\n    __publicField(this, \"nodeType\", 10);\n    __publicField(this, \"RRNodeType\", NodeType$1.DocumentType);\n    __publicField(this, \"name\");\n    __publicField(this, \"publicId\");\n    __publicField(this, \"systemId\");\n    __publicField(this, \"textContent\", null);\n    this.name = qualifiedName;\n    this.publicId = publicId;\n    this.systemId = systemId;\n    this.nodeName = qualifiedName;\n  }\n  toString() {\n    return \"RRDocumentType\";\n  }\n}\nclass BaseRRElement extends BaseRRNode {\n  constructor(tagName) {\n    super();\n    __publicField(this, \"nodeType\", 1);\n    __publicField(this, \"RRNodeType\", NodeType$1.Element);\n    __publicField(this, \"tagName\");\n    __publicField(this, \"attributes\", {});\n    __publicField(this, \"shadowRoot\", null);\n    __publicField(this, \"scrollLeft\");\n    __publicField(this, \"scrollTop\");\n    this.tagName = tagName.toUpperCase();\n    this.nodeName = tagName.toUpperCase();\n  }\n  get textContent() {\n    let result = \"\";\n    this.childNodes.forEach((node) => result += node.textContent);\n    return result;\n  }\n  set textContent(textContent) {\n    this.firstChild = null;\n    this.lastChild = null;\n    this.appendChild(this.ownerDocument.createTextNode(textContent));\n  }\n  get classList() {\n    return new ClassList(\n      this.attributes.class,\n      (newClassName) => {\n        this.attributes.class = newClassName;\n      }\n    );\n  }\n  get id() {\n    return this.attributes.id || \"\";\n  }\n  get className() {\n    return this.attributes.class || \"\";\n  }\n  get style() {\n    const style = this.attributes.style ? parseCSSText(this.attributes.style) : {};\n    const hyphenateRE2 = /\\B([A-Z])/g;\n    style.setProperty = (name, value, priority) => {\n      if (hyphenateRE2.test(name)) return;\n      const normalizedName = camelize(name);\n      if (!value) delete style[normalizedName];\n      else style[normalizedName] = value;\n      if (priority === \"important\") style[normalizedName] += \" !important\";\n      this.attributes.style = toCSSText(style);\n    };\n    style.removeProperty = (name) => {\n      if (hyphenateRE2.test(name)) return \"\";\n      const normalizedName = camelize(name);\n      const value = style[normalizedName] || \"\";\n      delete style[normalizedName];\n      this.attributes.style = toCSSText(style);\n      return value;\n    };\n    return style;\n  }\n  getAttribute(name) {\n    return this.attributes[name] || null;\n  }\n  setAttribute(name, attribute) {\n    this.attributes[name] = attribute;\n  }\n  setAttributeNS(_namespace, qualifiedName, value) {\n    this.setAttribute(qualifiedName, value);\n  }\n  removeAttribute(name) {\n    delete this.attributes[name];\n  }\n  appendChild(newChild) {\n    return appendChild(this, newChild);\n  }\n  insertBefore(newChild, refChild) {\n    return insertBefore(this, newChild, refChild);\n  }\n  removeChild(node) {\n    return removeChild(this, node);\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  attachShadow(_init) {\n    const shadowRoot = this.ownerDocument.createElement(\"SHADOWROOT\");\n    this.shadowRoot = shadowRoot;\n    return shadowRoot;\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  dispatchEvent(_event) {\n    return true;\n  }\n  toString() {\n    let attributeString = \"\";\n    for (const attribute in this.attributes) {\n      attributeString += `${attribute}=\"${this.attributes[attribute]}\" `;\n    }\n    return `${this.tagName} ${attributeString}`;\n  }\n}\nclass BaseRRMediaElement extends BaseRRElement {\n  constructor() {\n    super(...arguments);\n    __publicField(this, \"currentTime\");\n    __publicField(this, \"volume\");\n    __publicField(this, \"paused\");\n    __publicField(this, \"muted\");\n    __publicField(this, \"playbackRate\");\n    __publicField(this, \"loop\");\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  attachShadow(_init) {\n    throw new Error(\n      `RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow`\n    );\n  }\n  play() {\n    this.paused = false;\n  }\n  pause() {\n    this.paused = true;\n  }\n}\nclass BaseRRText extends BaseRRNode {\n  constructor(data) {\n    super();\n    __publicField(this, \"nodeType\", 3);\n    __publicField(this, \"nodeName\", \"#text\");\n    __publicField(this, \"RRNodeType\", NodeType$1.Text);\n    __publicField(this, \"data\");\n    this.data = data;\n  }\n  get textContent() {\n    return this.data;\n  }\n  set textContent(textContent) {\n    this.data = textContent;\n  }\n  toString() {\n    return `RRText text=${JSON.stringify(this.data)}`;\n  }\n}\nclass BaseRRComment extends BaseRRNode {\n  constructor(data) {\n    super();\n    __publicField(this, \"nodeType\", 8);\n    __publicField(this, \"nodeName\", \"#comment\");\n    __publicField(this, \"RRNodeType\", NodeType$1.Comment);\n    __publicField(this, \"data\");\n    this.data = data;\n  }\n  get textContent() {\n    return this.data;\n  }\n  set textContent(textContent) {\n    this.data = textContent;\n  }\n  toString() {\n    return `RRComment text=${JSON.stringify(this.data)}`;\n  }\n}\nclass BaseRRCDATASection extends BaseRRNode {\n  constructor(data) {\n    super();\n    __publicField(this, \"nodeName\", \"#cdata-section\");\n    __publicField(this, \"nodeType\", 4);\n    __publicField(this, \"RRNodeType\", NodeType$1.CDATA);\n    __publicField(this, \"data\");\n    this.data = data;\n  }\n  get textContent() {\n    return this.data;\n  }\n  set textContent(textContent) {\n    this.data = textContent;\n  }\n  toString() {\n    return `RRCDATASection data=${JSON.stringify(this.data)}`;\n  }\n}\nclass ClassList {\n  constructor(classText, onChange) {\n    __publicField(this, \"onChange\");\n    __publicField(this, \"classes\", []);\n    __publicField(this, \"add\", (...classNames) => {\n      for (const item of classNames) {\n        const className = String(item);\n        if (this.classes.indexOf(className) >= 0) continue;\n        this.classes.push(className);\n      }\n      this.onChange && this.onChange(this.classes.join(\" \"));\n    });\n    __publicField(this, \"remove\", (...classNames) => {\n      this.classes = this.classes.filter(\n        (item) => classNames.indexOf(item) === -1\n      );\n      this.onChange && this.onChange(this.classes.join(\" \"));\n    });\n    if (classText) {\n      const classes = classText.trim().split(/\\s+/);\n      this.classes.push(...classes);\n    }\n    this.onChange = onChange;\n  }\n}\nfunction appendChild(parent, newChild) {\n  if (newChild.parentNode) newChild.parentNode.removeChild(newChild);\n  if (parent.lastChild) {\n    parent.lastChild.nextSibling = newChild;\n    newChild.previousSibling = parent.lastChild;\n  } else {\n    parent.firstChild = newChild;\n    newChild.previousSibling = null;\n  }\n  parent.lastChild = newChild;\n  newChild.nextSibling = null;\n  newChild.parentNode = parent;\n  newChild.parentElement = parent;\n  newChild.ownerDocument = parent.ownerDocument;\n  return newChild;\n}\nfunction insertBefore(parent, newChild, refChild) {\n  if (!refChild) return appendChild(parent, newChild);\n  if (refChild.parentNode !== parent)\n    throw new Error(\n      \"Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.\"\n    );\n  if (newChild === refChild) return newChild;\n  if (newChild.parentNode) newChild.parentNode.removeChild(newChild);\n  newChild.previousSibling = refChild.previousSibling;\n  refChild.previousSibling = newChild;\n  newChild.nextSibling = refChild;\n  if (newChild.previousSibling) newChild.previousSibling.nextSibling = newChild;\n  else parent.firstChild = newChild;\n  newChild.parentElement = parent;\n  newChild.parentNode = parent;\n  newChild.ownerDocument = parent.ownerDocument;\n  return newChild;\n}\nfunction removeChild(parent, child) {\n  if (child.parentNode !== parent)\n    throw new Error(\n      \"Failed to execute 'removeChild' on 'RRNode': The RRNode to be removed is not a child of this RRNode.\"\n    );\n  if (child.previousSibling)\n    child.previousSibling.nextSibling = child.nextSibling;\n  else parent.firstChild = child.nextSibling;\n  if (child.nextSibling)\n    child.nextSibling.previousSibling = child.previousSibling;\n  else parent.lastChild = child.previousSibling;\n  child.previousSibling = null;\n  child.nextSibling = null;\n  child.parentElement = null;\n  child.parentNode = null;\n  return child;\n}\nvar NodeType = /* @__PURE__ */ ((NodeType2) => {\n  NodeType2[NodeType2[\"PLACEHOLDER\"] = 0] = \"PLACEHOLDER\";\n  NodeType2[NodeType2[\"ELEMENT_NODE\"] = 1] = \"ELEMENT_NODE\";\n  NodeType2[NodeType2[\"ATTRIBUTE_NODE\"] = 2] = \"ATTRIBUTE_NODE\";\n  NodeType2[NodeType2[\"TEXT_NODE\"] = 3] = \"TEXT_NODE\";\n  NodeType2[NodeType2[\"CDATA_SECTION_NODE\"] = 4] = \"CDATA_SECTION_NODE\";\n  NodeType2[NodeType2[\"ENTITY_REFERENCE_NODE\"] = 5] = \"ENTITY_REFERENCE_NODE\";\n  NodeType2[NodeType2[\"ENTITY_NODE\"] = 6] = \"ENTITY_NODE\";\n  NodeType2[NodeType2[\"PROCESSING_INSTRUCTION_NODE\"] = 7] = \"PROCESSING_INSTRUCTION_NODE\";\n  NodeType2[NodeType2[\"COMMENT_NODE\"] = 8] = \"COMMENT_NODE\";\n  NodeType2[NodeType2[\"DOCUMENT_NODE\"] = 9] = \"DOCUMENT_NODE\";\n  NodeType2[NodeType2[\"DOCUMENT_TYPE_NODE\"] = 10] = \"DOCUMENT_TYPE_NODE\";\n  NodeType2[NodeType2[\"DOCUMENT_FRAGMENT_NODE\"] = 11] = \"DOCUMENT_FRAGMENT_NODE\";\n  return NodeType2;\n})(NodeType || {});\nfunction getIFrameContentDocument(iframe) {\n  try {\n    return iframe.contentDocument;\n  } catch (e) {\n  }\n}\nfunction getIFrameContentWindow(iframe) {\n  try {\n    return iframe.contentWindow;\n  } catch (e) {\n  }\n}\nconst NAMESPACES = {\n  svg: \"http://www.w3.org/2000/svg\",\n  \"xlink:href\": \"http://www.w3.org/1999/xlink\",\n  xmlns: \"http://www.w3.org/2000/xmlns/\"\n};\nconst SVGTagMap = {\n  altglyph: \"altGlyph\",\n  altglyphdef: \"altGlyphDef\",\n  altglyphitem: \"altGlyphItem\",\n  animatecolor: \"animateColor\",\n  animatemotion: \"animateMotion\",\n  animatetransform: \"animateTransform\",\n  clippath: \"clipPath\",\n  feblend: \"feBlend\",\n  fecolormatrix: \"feColorMatrix\",\n  fecomponenttransfer: \"feComponentTransfer\",\n  fecomposite: \"feComposite\",\n  feconvolvematrix: \"feConvolveMatrix\",\n  fediffuselighting: \"feDiffuseLighting\",\n  fedisplacementmap: \"feDisplacementMap\",\n  fedistantlight: \"feDistantLight\",\n  fedropshadow: \"feDropShadow\",\n  feflood: \"feFlood\",\n  fefunca: \"feFuncA\",\n  fefuncb: \"feFuncB\",\n  fefuncg: \"feFuncG\",\n  fefuncr: \"feFuncR\",\n  fegaussianblur: \"feGaussianBlur\",\n  feimage: \"feImage\",\n  femerge: \"feMerge\",\n  femergenode: \"feMergeNode\",\n  femorphology: \"feMorphology\",\n  feoffset: \"feOffset\",\n  fepointlight: \"fePointLight\",\n  fespecularlighting: \"feSpecularLighting\",\n  fespotlight: \"feSpotLight\",\n  fetile: \"feTile\",\n  feturbulence: \"feTurbulence\",\n  foreignobject: \"foreignObject\",\n  glyphref: \"glyphRef\",\n  lineargradient: \"linearGradient\",\n  radialgradient: \"radialGradient\"\n};\nlet createdNodeSet = null;\nfunction diff(oldTree, newTree, replayer, rrnodeMirror = newTree.mirror || newTree.ownerDocument.mirror) {\n  oldTree = diffBeforeUpdatingChildren(\n    oldTree,\n    newTree,\n    replayer,\n    rrnodeMirror\n  );\n  diffChildren(oldTree, newTree, replayer, rrnodeMirror);\n  diffAfterUpdatingChildren(oldTree, newTree, replayer);\n}\nfunction diffBeforeUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror) {\n  if (replayer.afterAppend && !createdNodeSet) {\n    createdNodeSet = /* @__PURE__ */ new WeakSet();\n    setTimeout(() => {\n      createdNodeSet = null;\n    }, 0);\n  }\n  if (!sameNodeType(oldTree, newTree)) {\n    const calibratedOldTree = createOrGetNode(\n      newTree,\n      replayer.mirror,\n      rrnodeMirror\n    );\n    oldTree.parentNode?.replaceChild(calibratedOldTree, oldTree);\n    oldTree = calibratedOldTree;\n  }\n  switch (newTree.RRNodeType) {\n    case NodeType$1.Document: {\n      if (!nodeMatching(oldTree, newTree, replayer.mirror, rrnodeMirror)) {\n        const newMeta = rrnodeMirror.getMeta(newTree);\n        if (newMeta) {\n          replayer.mirror.removeNodeFromMap(oldTree);\n          oldTree.close();\n          oldTree.open();\n          replayer.mirror.add(oldTree, newMeta);\n          createdNodeSet?.add(oldTree);\n        }\n      }\n      break;\n    }\n    case NodeType$1.Element: {\n      const oldElement = oldTree;\n      const newRRElement = newTree;\n      switch (newRRElement.tagName) {\n        case \"IFRAME\": {\n          const oldContentDocument = getIFrameContentDocument(\n            oldTree\n          );\n          if (!oldContentDocument) break;\n          diff(\n            oldContentDocument,\n            newTree.contentDocument,\n            replayer,\n            rrnodeMirror\n          );\n          break;\n        }\n      }\n      if (newRRElement.shadowRoot) {\n        if (!oldElement.shadowRoot) oldElement.attachShadow({ mode: \"open\" });\n        diffChildren(\n          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n          oldElement.shadowRoot,\n          newRRElement.shadowRoot,\n          replayer,\n          rrnodeMirror\n        );\n      }\n      diffProps(oldElement, newRRElement, rrnodeMirror);\n      break;\n    }\n  }\n  return oldTree;\n}\nfunction diffAfterUpdatingChildren(oldTree, newTree, replayer) {\n  switch (newTree.RRNodeType) {\n    case NodeType$1.Document: {\n      const scrollData = newTree.scrollData;\n      scrollData && replayer.applyScroll(scrollData, true);\n      break;\n    }\n    case NodeType$1.Element: {\n      const oldElement = oldTree;\n      const newRRElement = newTree;\n      newRRElement.scrollData && replayer.applyScroll(newRRElement.scrollData, true);\n      newRRElement.inputData && replayer.applyInput(newRRElement.inputData);\n      switch (newRRElement.tagName) {\n        case \"AUDIO\":\n        case \"VIDEO\": {\n          const oldMediaElement = oldTree;\n          const newMediaRRElement = newRRElement;\n          if (newMediaRRElement.paused !== void 0) {\n            const maybePromise = newMediaRRElement.paused ? oldMediaElement.pause() : oldMediaElement.play();\n            if (typeof maybePromise?.catch === \"function\") {\n              maybePromise.catch((e) => {\n                console.warn(e);\n              });\n            }\n          }\n          if (newMediaRRElement.muted !== void 0)\n            oldMediaElement.muted = newMediaRRElement.muted;\n          if (newMediaRRElement.volume !== void 0)\n            oldMediaElement.volume = newMediaRRElement.volume;\n          if (newMediaRRElement.currentTime !== void 0)\n            oldMediaElement.currentTime = newMediaRRElement.currentTime;\n          if (newMediaRRElement.playbackRate !== void 0)\n            oldMediaElement.playbackRate = newMediaRRElement.playbackRate;\n          break;\n        }\n        case \"CANVAS\": {\n          const rrCanvasElement = newTree;\n          if (rrCanvasElement.rr_dataURL !== null) {\n            const image = document.createElement(\"img\");\n            image.onload = () => {\n              const ctx = oldElement.getContext(\"2d\");\n              if (ctx) {\n                ctx.drawImage(image, 0, 0, image.width, image.height);\n              }\n            };\n            image.src = rrCanvasElement.rr_dataURL;\n          }\n          rrCanvasElement.canvasMutations.forEach(\n            (canvasMutation) => replayer.applyCanvas(\n              canvasMutation.event,\n              canvasMutation.mutation,\n              oldTree\n            )\n          );\n          break;\n        }\n        // Props of style elements have to be updated after all children are updated. Otherwise the props can be overwritten by textContent.\n        case \"STYLE\": {\n          const styleSheet = oldElement.sheet;\n          styleSheet && newTree.rules.forEach(\n            (data) => replayer.applyStyleSheetMutation(data, styleSheet)\n          );\n          break;\n        }\n      }\n      break;\n    }\n    case NodeType$1.Text:\n    case NodeType$1.Comment:\n    case NodeType$1.CDATA: {\n      if (oldTree.textContent !== newTree.data)\n        oldTree.textContent = newTree.data;\n      break;\n    }\n  }\n  if (createdNodeSet?.has(oldTree)) {\n    createdNodeSet.delete(oldTree);\n    replayer.afterAppend?.(oldTree, replayer.mirror.getId(oldTree));\n  }\n}\nfunction diffProps(oldTree, newTree, rrnodeMirror) {\n  const oldAttributes = oldTree.attributes;\n  const newAttributes = newTree.attributes;\n  for (const name in newAttributes) {\n    const newValue = newAttributes[name];\n    const sn = rrnodeMirror.getMeta(newTree);\n    if (sn?.isSVG && NAMESPACES[name])\n      oldTree.setAttributeNS(NAMESPACES[name], name, newValue);\n    else if (newTree.tagName === \"CANVAS\" && name === \"rr_dataURL\") {\n      const image = document.createElement(\"img\");\n      image.src = newValue;\n      image.onload = () => {\n        const ctx = oldTree.getContext(\"2d\");\n        if (ctx) {\n          ctx.drawImage(image, 0, 0, image.width, image.height);\n        }\n      };\n    } else if (newTree.tagName === \"IFRAME\" && name === \"srcdoc\") continue;\n    else {\n      try {\n        oldTree.setAttribute(name, newValue);\n      } catch (err) {\n        console.warn(err);\n      }\n    }\n  }\n  for (const { name } of Array.from(oldAttributes))\n    if (!(name in newAttributes)) oldTree.removeAttribute(name);\n  newTree.scrollLeft && (oldTree.scrollLeft = newTree.scrollLeft);\n  newTree.scrollTop && (oldTree.scrollTop = newTree.scrollTop);\n}\nfunction diffChildren(oldTree, newTree, replayer, rrnodeMirror) {\n  const oldChildren = Array.from(oldTree.childNodes);\n  const newChildren = newTree.childNodes;\n  if (oldChildren.length === 0 && newChildren.length === 0) return;\n  let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1;\n  let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex];\n  let oldIdToIndex = void 0, indexInOld = void 0;\n  while (oldStartIndex <= oldEndIndex && newStartIndex <= newEndIndex) {\n    if (oldStartNode === void 0) {\n      oldStartNode = oldChildren[++oldStartIndex];\n    } else if (oldEndNode === void 0) {\n      oldEndNode = oldChildren[--oldEndIndex];\n    } else if (\n      // same first node?\n      nodeMatching(oldStartNode, newStartNode, replayer.mirror, rrnodeMirror)\n    ) {\n      oldStartNode = oldChildren[++oldStartIndex];\n      newStartNode = newChildren[++newStartIndex];\n    } else if (\n      // same last node?\n      nodeMatching(oldEndNode, newEndNode, replayer.mirror, rrnodeMirror)\n    ) {\n      oldEndNode = oldChildren[--oldEndIndex];\n      newEndNode = newChildren[--newEndIndex];\n    } else if (\n      // is the first old node the same as the last new node?\n      nodeMatching(oldStartNode, newEndNode, replayer.mirror, rrnodeMirror)\n    ) {\n      try {\n        handleInsertBefore(oldTree, oldStartNode, oldEndNode.nextSibling);\n      } catch (e) {\n        console.warn(e);\n      }\n      oldStartNode = oldChildren[++oldStartIndex];\n      newEndNode = newChildren[--newEndIndex];\n    } else if (\n      // is the last old node the same as the first new node?\n      nodeMatching(oldEndNode, newStartNode, replayer.mirror, rrnodeMirror)\n    ) {\n      try {\n        handleInsertBefore(oldTree, oldEndNode, oldStartNode);\n      } catch (e) {\n        console.warn(e);\n      }\n      oldEndNode = oldChildren[--oldEndIndex];\n      newStartNode = newChildren[++newStartIndex];\n    } else {\n      if (!oldIdToIndex) {\n        oldIdToIndex = {};\n        for (let i = oldStartIndex; i <= oldEndIndex; i++) {\n          const oldChild2 = oldChildren[i];\n          if (oldChild2 && replayer.mirror.hasNode(oldChild2))\n            oldIdToIndex[replayer.mirror.getId(oldChild2)] = i;\n        }\n      }\n      indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];\n      const nodeToMove = oldChildren[indexInOld];\n      if (indexInOld !== void 0 && nodeToMove && nodeMatching(nodeToMove, newStartNode, replayer.mirror, rrnodeMirror)) {\n        try {\n          handleInsertBefore(oldTree, nodeToMove, oldStartNode);\n        } catch (e) {\n          console.warn(e);\n        }\n        oldChildren[indexInOld] = void 0;\n      } else {\n        const newNode = createOrGetNode(\n          newStartNode,\n          replayer.mirror,\n          rrnodeMirror\n        );\n        if (oldTree.nodeName === \"#document\" && oldStartNode && /**\n        * Special case 1: one document isn't allowed to have two doctype nodes at the same time, so we need to remove the old one first before inserting the new one.\n        * How this case happens: A parent document in the old tree already has a doctype node with an id e.g. #1. A new full snapshot rebuilds the replayer with a new doctype node with another id #2. According to the algorithm, the new doctype node will be inserted before the old one, which is not allowed by the Document standard.\n        */\n        (newNode.nodeType === newNode.DOCUMENT_TYPE_NODE && oldStartNode.nodeType === oldStartNode.DOCUMENT_TYPE_NODE || /**\n        * Special case 2: one document isn't allowed to have two HTMLElements at the same time, so we need to remove the old one first before inserting the new one.\n        * How this case happens: A mounted iframe element has an automatically created HTML element. We should delete it before inserting a serialized one. Otherwise, an error 'Only one element on document allowed' will be thrown.\n        */\n        newNode.nodeType === newNode.ELEMENT_NODE && oldStartNode.nodeType === oldStartNode.ELEMENT_NODE)) {\n          oldTree.removeChild(oldStartNode);\n          replayer.mirror.removeNodeFromMap(oldStartNode);\n          oldStartNode = oldChildren[++oldStartIndex];\n        }\n        try {\n          handleInsertBefore(oldTree, newNode, oldStartNode || null);\n        } catch (e) {\n          console.warn(e);\n        }\n      }\n      newStartNode = newChildren[++newStartIndex];\n    }\n  }\n  if (oldStartIndex > oldEndIndex) {\n    const referenceRRNode = newChildren[newEndIndex + 1];\n    let referenceNode = null;\n    if (referenceRRNode)\n      referenceNode = replayer.mirror.getNode(\n        rrnodeMirror.getId(referenceRRNode)\n      );\n    for (; newStartIndex <= newEndIndex; ++newStartIndex) {\n      const newNode = createOrGetNode(\n        newChildren[newStartIndex],\n        replayer.mirror,\n        rrnodeMirror\n      );\n      try {\n        handleInsertBefore(oldTree, newNode, referenceNode);\n      } catch (e) {\n        console.warn(e);\n      }\n    }\n  } else if (newStartIndex > newEndIndex) {\n    for (; oldStartIndex <= oldEndIndex; oldStartIndex++) {\n      const node = oldChildren[oldStartIndex];\n      if (!node || node.parentNode !== oldTree) continue;\n      try {\n        oldTree.removeChild(node);\n        replayer.mirror.removeNodeFromMap(node);\n      } catch (e) {\n        console.warn(e);\n      }\n    }\n  }\n  let oldChild = oldTree.firstChild;\n  let newChild = newTree.firstChild;\n  while (oldChild !== null && newChild !== null) {\n    diff(oldChild, newChild, replayer, rrnodeMirror);\n    oldChild = oldChild.nextSibling;\n    newChild = newChild.nextSibling;\n  }\n}\nfunction createOrGetNode(rrNode, domMirror, rrnodeMirror) {\n  const nodeId = rrnodeMirror.getId(rrNode);\n  const sn = rrnodeMirror.getMeta(rrNode);\n  let node = null;\n  if (nodeId > -1) node = domMirror.getNode(nodeId);\n  if (node !== null && sameNodeType(node, rrNode)) return node;\n  switch (rrNode.RRNodeType) {\n    case NodeType$1.Document:\n      node = new Document();\n      break;\n    case NodeType$1.DocumentType:\n      node = document.implementation.createDocumentType(\n        rrNode.name,\n        rrNode.publicId,\n        rrNode.systemId\n      );\n      break;\n    case NodeType$1.Element: {\n      let tagName = rrNode.tagName.toLowerCase();\n      tagName = SVGTagMap[tagName] || tagName;\n      if (sn && \"isSVG\" in sn && sn?.isSVG) {\n        node = document.createElementNS(NAMESPACES[\"svg\"], tagName);\n      } else node = document.createElement(rrNode.tagName);\n      break;\n    }\n    case NodeType$1.Text:\n      node = document.createTextNode(rrNode.data);\n      break;\n    case NodeType$1.Comment:\n      node = document.createComment(rrNode.data);\n      break;\n    case NodeType$1.CDATA:\n      node = document.createCDATASection(rrNode.data);\n      break;\n  }\n  if (sn) domMirror.add(node, { ...sn });\n  try {\n    createdNodeSet?.add(node);\n  } catch (e) {\n  }\n  return node;\n}\nfunction sameNodeType(node1, node2) {\n  if (node1.nodeType !== node2.nodeType) return false;\n  return node1.nodeType !== node1.ELEMENT_NODE || node1.tagName.toUpperCase() === node2.tagName;\n}\nfunction nodeMatching(node1, node2, domMirror, rrdomMirror) {\n  const node1Id = domMirror.getId(node1);\n  const node2Id = rrdomMirror.getId(node2);\n  if (node1Id === -1 || node1Id !== node2Id) return false;\n  return sameNodeType(node1, node2);\n}\nfunction getInsertedStylesFromElement(styleElement) {\n  const elementCssRules = styleElement.sheet?.cssRules;\n  if (!elementCssRules || !elementCssRules.length) return;\n  const tempStyleSheet = new CSSStyleSheet();\n  tempStyleSheet.replaceSync(styleElement.innerText);\n  const innerTextStylesMap = {};\n  for (let i = 0; i < tempStyleSheet.cssRules.length; i++) {\n    innerTextStylesMap[tempStyleSheet.cssRules[i].cssText] = tempStyleSheet.cssRules[i];\n  }\n  const insertedStylesStyleSheet = [];\n  for (let i = 0; i < elementCssRules?.length; i++) {\n    const cssRuleText = elementCssRules[i].cssText;\n    if (!innerTextStylesMap[cssRuleText]) {\n      insertedStylesStyleSheet.push({\n        index: i,\n        cssRuleText\n      });\n    }\n  }\n  return insertedStylesStyleSheet;\n}\nfunction handleInsertBefore(oldTree, nodeToMove, insertBeforeNode) {\n  let insertedStyles;\n  if (nodeToMove.nodeName === \"STYLE\") {\n    insertedStyles = getInsertedStylesFromElement(\n      nodeToMove\n    );\n  }\n  oldTree.insertBefore(nodeToMove, insertBeforeNode);\n  if (insertedStyles && insertedStyles.length) {\n    insertedStyles.forEach(({ cssRuleText, index }) => {\n      nodeToMove.sheet?.insertRule(cssRuleText, index);\n    });\n  }\n}\nclass RRDocument extends BaseRRDocument {\n  constructor(mirror) {\n    super();\n    __publicField(this, \"UNSERIALIZED_STARTING_ID\", -2);\n    // In the rrweb replayer, there are some unserialized nodes like the element that stores the injected style rules.\n    // These unserialized nodes may interfere the execution of the diff algorithm.\n    // The id of serialized node is larger than 0. So this value less than 0 is used as id for these unserialized nodes.\n    __publicField(this, \"_unserializedId\", this.UNSERIALIZED_STARTING_ID);\n    __publicField(this, \"mirror\", createMirror());\n    __publicField(this, \"scrollData\", null);\n    if (mirror) {\n      this.mirror = mirror;\n    }\n  }\n  /**\n   * Every time the id is used, it will minus 1 automatically to avoid collisions.\n   */\n  get unserializedId() {\n    return this._unserializedId--;\n  }\n  createDocument(_namespace, _qualifiedName, _doctype) {\n    return new RRDocument();\n  }\n  createDocumentType(qualifiedName, publicId, systemId) {\n    const documentTypeNode = new RRDocumentType(\n      qualifiedName,\n      publicId,\n      systemId\n    );\n    documentTypeNode.ownerDocument = this;\n    return documentTypeNode;\n  }\n  createElement(tagName) {\n    const upperTagName = tagName.toUpperCase();\n    let element;\n    switch (upperTagName) {\n      case \"AUDIO\":\n      case \"VIDEO\":\n        element = new RRMediaElement(upperTagName);\n        break;\n      case \"IFRAME\":\n        element = new RRIFrameElement(upperTagName, this.mirror);\n        break;\n      case \"CANVAS\":\n        element = new RRCanvasElement(upperTagName);\n        break;\n      case \"STYLE\":\n        element = new RRStyleElement(upperTagName);\n        break;\n      default:\n        element = new RRElement(upperTagName);\n        break;\n    }\n    element.ownerDocument = this;\n    return element;\n  }\n  createComment(data) {\n    const commentNode = new RRComment(data);\n    commentNode.ownerDocument = this;\n    return commentNode;\n  }\n  createCDATASection(data) {\n    const sectionNode = new RRCDATASection(data);\n    sectionNode.ownerDocument = this;\n    return sectionNode;\n  }\n  createTextNode(data) {\n    const textNode = new RRText(data);\n    textNode.ownerDocument = this;\n    return textNode;\n  }\n  destroyTree() {\n    this.firstChild = null;\n    this.lastChild = null;\n    this.mirror.reset();\n  }\n  open() {\n    super.open();\n    this._unserializedId = this.UNSERIALIZED_STARTING_ID;\n  }\n}\nconst RRDocumentType = BaseRRDocumentType;\nclass RRElement extends BaseRRElement {\n  constructor() {\n    super(...arguments);\n    __publicField(this, \"inputData\", null);\n    __publicField(this, \"scrollData\", null);\n  }\n}\nclass RRMediaElement extends BaseRRMediaElement {\n}\nclass RRCanvasElement extends RRElement {\n  constructor() {\n    super(...arguments);\n    __publicField(this, \"rr_dataURL\", null);\n    __publicField(this, \"canvasMutations\", []);\n  }\n  /**\n   * This is a dummy implementation to distinguish RRCanvasElement from real HTMLCanvasElement.\n   */\n  getContext() {\n    return null;\n  }\n}\nclass RRStyleElement extends RRElement {\n  constructor() {\n    super(...arguments);\n    __publicField(this, \"rules\", []);\n  }\n}\nclass RRIFrameElement extends RRElement {\n  constructor(upperTagName, mirror) {\n    super(upperTagName);\n    __publicField(this, \"contentDocument\", new RRDocument());\n    this.contentDocument.mirror = mirror;\n  }\n}\nconst RRText = BaseRRText;\nconst RRComment = BaseRRComment;\nconst RRCDATASection = BaseRRCDATASection;\nfunction getValidTagName(element) {\n  if (element instanceof HTMLFormElement) {\n    return \"FORM\";\n  }\n  return element.tagName.toUpperCase();\n}\nfunction buildFromNode(node, rrdom, domMirror, parentRRNode) {\n  let rrNode;\n  switch (node.nodeType) {\n    case NodeType.DOCUMENT_NODE:\n      if (parentRRNode && parentRRNode.nodeName === \"IFRAME\")\n        rrNode = parentRRNode.contentDocument;\n      else {\n        rrNode = rrdom;\n        rrNode.compatMode = node.compatMode;\n      }\n      break;\n    case NodeType.DOCUMENT_TYPE_NODE: {\n      const documentType = node;\n      rrNode = rrdom.createDocumentType(\n        documentType.name,\n        documentType.publicId,\n        documentType.systemId\n      );\n      break;\n    }\n    case NodeType.ELEMENT_NODE: {\n      const elementNode = node;\n      const tagName = getValidTagName(elementNode);\n      rrNode = rrdom.createElement(tagName);\n      const rrElement = rrNode;\n      for (const { name, value } of Array.from(elementNode.attributes)) {\n        rrElement.attributes[name] = value;\n      }\n      elementNode.scrollLeft && (rrElement.scrollLeft = elementNode.scrollLeft);\n      elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop);\n      break;\n    }\n    case NodeType.TEXT_NODE:\n      rrNode = rrdom.createTextNode(node.textContent || \"\");\n      break;\n    case NodeType.CDATA_SECTION_NODE:\n      rrNode = rrdom.createCDATASection(node.data);\n      break;\n    case NodeType.COMMENT_NODE:\n      rrNode = rrdom.createComment(node.textContent || \"\");\n      break;\n    // if node is a shadow root\n    case NodeType.DOCUMENT_FRAGMENT_NODE:\n      rrNode = parentRRNode.attachShadow({ mode: \"open\" });\n      break;\n    default:\n      return null;\n  }\n  let sn = domMirror.getMeta(node);\n  if (rrdom instanceof RRDocument) {\n    if (!sn) {\n      sn = getDefaultSN(rrNode, rrdom.unserializedId);\n      domMirror.add(node, sn);\n    }\n    rrdom.mirror.add(rrNode, { ...sn });\n  }\n  return rrNode;\n}\nfunction buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) {\n  function walk2(node, parentRRNode) {\n    const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode);\n    if (rrNode === null) return;\n    if (\n      // if the parentRRNode isn't a RRIFrameElement\n      parentRRNode?.nodeName !== \"IFRAME\" && // if node isn't a shadow root\n      node.nodeType !== NodeType.DOCUMENT_FRAGMENT_NODE\n    ) {\n      parentRRNode?.appendChild(rrNode);\n      rrNode.parentNode = parentRRNode;\n      rrNode.parentElement = parentRRNode;\n    }\n    if (node.nodeName === \"IFRAME\") {\n      const iframeDoc = getIFrameContentDocument(node);\n      iframeDoc && walk2(iframeDoc, rrNode);\n    } else if (node.nodeType === NodeType.DOCUMENT_NODE || node.nodeType === NodeType.ELEMENT_NODE || node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) {\n      if (node.nodeType === NodeType.ELEMENT_NODE && node.shadowRoot)\n        walk2(node.shadowRoot, rrNode);\n      node.childNodes.forEach((childNode) => walk2(childNode, rrNode));\n    }\n  }\n  walk2(dom, null);\n  return rrdom;\n}\nfunction createMirror() {\n  return new Mirror2();\n}\nclass Mirror2 {\n  constructor() {\n    __publicField(this, \"idNodeMap\", /* @__PURE__ */ new Map());\n    __publicField(this, \"nodeMetaMap\", /* @__PURE__ */ new WeakMap());\n  }\n  getId(n) {\n    if (!n) return -1;\n    const id = this.getMeta(n)?.id;\n    return id ?? -1;\n  }\n  getNode(id) {\n    return this.idNodeMap.get(id) || null;\n  }\n  getIds() {\n    return Array.from(this.idNodeMap.keys());\n  }\n  getMeta(n) {\n    return this.nodeMetaMap.get(n) || null;\n  }\n  // removes the node from idNodeMap\n  // doesn't remove the node from nodeMetaMap\n  removeNodeFromMap(n) {\n    const id = this.getId(n);\n    this.idNodeMap.delete(id);\n    if (n.childNodes) {\n      n.childNodes.forEach((childNode) => this.removeNodeFromMap(childNode));\n    }\n  }\n  has(id) {\n    return this.idNodeMap.has(id);\n  }\n  hasNode(node) {\n    return this.nodeMetaMap.has(node);\n  }\n  add(n, meta) {\n    const id = meta.id;\n    this.idNodeMap.set(id, n);\n    this.nodeMetaMap.set(n, meta);\n  }\n  replace(id, n) {\n    const oldNode = this.getNode(id);\n    if (oldNode) {\n      const meta = this.nodeMetaMap.get(oldNode);\n      if (meta) this.nodeMetaMap.set(n, meta);\n    }\n    this.idNodeMap.set(id, n);\n  }\n  reset() {\n    this.idNodeMap = /* @__PURE__ */ new Map();\n    this.nodeMetaMap = /* @__PURE__ */ new WeakMap();\n  }\n}\nfunction getDefaultSN(node, id) {\n  switch (node.RRNodeType) {\n    case NodeType$1.Document:\n      return {\n        id,\n        type: node.RRNodeType,\n        childNodes: []\n      };\n    case NodeType$1.DocumentType: {\n      const doctype = node;\n      return {\n        id,\n        type: node.RRNodeType,\n        name: doctype.name,\n        publicId: doctype.publicId,\n        systemId: doctype.systemId\n      };\n    }\n    case NodeType$1.Element:\n      return {\n        id,\n        type: node.RRNodeType,\n        tagName: node.tagName.toLowerCase(),\n        // In rrweb data, all tagNames are lowercase.\n        attributes: {},\n        childNodes: []\n      };\n    case NodeType$1.Text:\n      return {\n        id,\n        type: node.RRNodeType,\n        textContent: node.textContent || \"\"\n      };\n    case NodeType$1.Comment:\n      return {\n        id,\n        type: node.RRNodeType,\n        textContent: node.textContent || \"\"\n      };\n    case NodeType$1.CDATA:\n      return {\n        id,\n        type: node.RRNodeType,\n        textContent: \"\"\n      };\n  }\n}\nfunction printRRDom(rootNode, mirror) {\n  return walk(rootNode, mirror, \"\");\n}\nfunction walk(node, mirror, blankSpace) {\n  let printText = `${blankSpace}${mirror.getId(node)} ${node.toString()}\n`;\n  if (node.RRNodeType === NodeType$1.Element) {\n    const element = node;\n    if (element.shadowRoot)\n      printText += walk(element.shadowRoot, mirror, blankSpace + \"  \");\n  }\n  for (const child of node.childNodes)\n    printText += walk(child, mirror, blankSpace + \"  \");\n  if (node.nodeName === \"IFRAME\")\n    printText += walk(\n      node.contentDocument,\n      mirror,\n      blankSpace + \"  \"\n    );\n  return printText;\n}\nexport {\n  BaseRRCDATASection,\n  BaseRRComment,\n  BaseRRDocument,\n  BaseRRDocumentType,\n  BaseRRElement,\n  BaseRRMediaElement,\n  BaseRRNode,\n  BaseRRText,\n  ClassList,\n  Mirror2 as Mirror,\n  NodeType,\n  RRCDATASection,\n  RRCanvasElement,\n  RRComment,\n  RRDocument,\n  RRDocumentType,\n  RRElement,\n  RRIFrameElement,\n  RRMediaElement,\n  BaseRRNode as RRNode,\n  RRStyleElement,\n  RRText,\n  buildFromDom,\n  buildFromNode,\n  createMirror,\n  createOrGetNode,\n  diff,\n  getDefaultSN,\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n  printRRDom\n};\n//# sourceMappingURL=rrdom.js.map\n","/**\n * This class is used to parse a style declaration into a CSSStyleDeclaration object.\n * It uses an unattached doc unless `CSSStyleSheet.prototype.replaceSync` is available which can be used to bypass CSP violations.\n * https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/replaceSync\n *\n * This builds on https://github.com/getsentry/rrweb/pull/211#issuecomment-2284551183 which exhausted the other available options.\n *\n * Note: This means some browsers (older than 23 March 2023) will use the unattached doc and may experience CSP violations,\n * but newer browsers will use the replaceSync method and will not experience CSP violations.\n */\nexport class StyleDeclarationParser {\n  private unattachedDoc: Document | null = null;\n\n  public constructor(private readonly doc: Document) {}\n\n  public parse(styleText: string): CSSStyleDeclaration | null {\n    return (\n      this.parseWithConstructableStylesheet(styleText) ||\n      this.parseWithDetachedElement(styleText)\n    );\n  }\n\n  private parseWithConstructableStylesheet(\n    styleText: string,\n  ): CSSStyleDeclaration | null {\n    if (\n      typeof CSSStyleSheet === 'undefined' ||\n      typeof CSSStyleSheet.prototype.replaceSync !== 'function'\n    ) {\n      return null;\n    }\n\n    try {\n      const sheet = new CSSStyleSheet();\n      sheet.replaceSync(`x { ${styleText} }`);\n\n      const rule = sheet.cssRules[0];\n      if (!rule || rule.type !== CSSRule.STYLE_RULE) {\n        return null;\n      }\n\n      return (rule as CSSStyleRule).style;\n    } catch {\n      return null;\n    }\n  }\n\n  private parseWithDetachedElement(styleText: string): CSSStyleDeclaration {\n    const old = this.getUnattachedDoc().createElement('span');\n    old.setAttribute('style', styleText);\n    return old.style;\n  }\n\n  private getUnattachedDoc(): Document {\n    if (!this.unattachedDoc) {\n      try {\n        // avoid upsetting the observed document from a CSP point of view\n        this.unattachedDoc = document.implementation.createHTMLDocument();\n      } catch {\n        this.unattachedDoc = this.doc;\n      }\n    }\n\n    return this.unattachedDoc;\n  }\n}\n","import {\n  serializeNodeWithId,\n  transformAttribute,\n  IGNORED_NODE,\n  ignoreAttribute,\n  isShadowRoot,\n  needMaskingText,\n  maskInputValue,\n  Mirror,\n  isNativeShadowDom,\n  getInputType,\n  toLowerCase,\n  getInputValue,\n  shouldMaskInput,\n} from '@sentry-internal/rrweb-snapshot';\nimport type { observerParam, MutationBufferParam } from '../types';\nimport type {\n  mutationRecord,\n  textCursor,\n  attributeCursor,\n  removedNodeMutation,\n  addedNodeMutation,\n  Optional,\n  IWindow,\n} from '@sentry-internal/rrweb-types';\nimport {\n  isBlocked,\n  isAncestorRemoved,\n  isIgnored,\n  isSerialized,\n  hasShadowRoot,\n  isSerializedIframe,\n  isSerializedStylesheet,\n  inDom,\n  getShadowHost,\n  closestElementOfNode,\n} from '../utils';\nimport { StyleDeclarationParser } from './style-declaration-parser';\n\nimport {\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n} from '@sentry-internal/rrdom';\n\ntype DoubleLinkedListNode = {\n  previous: DoubleLinkedListNode | null;\n  next: DoubleLinkedListNode | null;\n  value: NodeInLinkedList;\n};\ntype NodeInLinkedList = Node & {\n  __ln: DoubleLinkedListNode;\n};\n\nfunction isNodeInLinkedList(n: Node | NodeInLinkedList): n is NodeInLinkedList {\n  return '__ln' in n;\n}\n\nclass DoubleLinkedList {\n  public length = 0;\n  public head: DoubleLinkedListNode | null = null;\n  public tail: DoubleLinkedListNode | null = null;\n\n  public get(position: number) {\n    if (position >= this.length) {\n      throw new Error('Position outside of list range');\n    }\n\n    let current = this.head;\n    for (let index = 0; index < position; index++) {\n      current = current?.next || null;\n    }\n    return current;\n  }\n\n  public addNode(n: Node) {\n    const node: DoubleLinkedListNode = {\n      value: n as NodeInLinkedList,\n      previous: null,\n      next: null,\n    };\n    (n as NodeInLinkedList).__ln = node;\n    if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {\n      const current = n.previousSibling.__ln.next;\n      node.next = current;\n      node.previous = n.previousSibling.__ln;\n      n.previousSibling.__ln.next = node;\n      if (current) {\n        current.previous = node;\n      }\n    } else if (\n      n.nextSibling &&\n      isNodeInLinkedList(n.nextSibling) &&\n      n.nextSibling.__ln.previous\n    ) {\n      const current = n.nextSibling.__ln.previous;\n      node.previous = current;\n      node.next = n.nextSibling.__ln;\n      n.nextSibling.__ln.previous = node;\n      if (current) {\n        current.next = node;\n      }\n    } else {\n      if (this.head) {\n        this.head.previous = node;\n      }\n      node.next = this.head;\n      this.head = node;\n    }\n    if (node.next === null) {\n      this.tail = node;\n    }\n    this.length++;\n  }\n\n  public removeNode(n: NodeInLinkedList) {\n    const current = n.__ln;\n    if (!this.head) {\n      return;\n    }\n\n    if (!current.previous) {\n      this.head = current.next;\n      if (this.head) {\n        this.head.previous = null;\n      } else {\n        this.tail = null;\n      }\n    } else {\n      current.previous.next = current.next;\n      if (current.next) {\n        current.next.previous = current.previous;\n      } else {\n        this.tail = current.previous;\n      }\n    }\n    if (n.__ln) {\n      delete (n as Optional<NodeInLinkedList, '__ln'>).__ln;\n    }\n    this.length--;\n  }\n}\n\nconst moveKey = (id: number, parentId: number) => `${id}@${parentId}`;\n\n/**\n * controls behaviour of a MutationObserver\n */\nexport default class MutationBuffer {\n  private frozen = false;\n  private locked = false;\n\n  private texts: textCursor[] = [];\n  private attributes: attributeCursor[] = [];\n  private attributeMap = new WeakMap<Node, attributeCursor>();\n  private removes: removedNodeMutation[] = [];\n  private mapRemoves: Node[] = [];\n\n  private movedMap: Record<string, true> = {};\n\n  /**\n   * the browser MutationObserver emits multiple mutations after\n   * a delay for performance reasons, making tracing added nodes hard\n   * in our `processMutations` callback function.\n   * For example, if we append an element el_1 into body, and then append\n   * another element el_2 into el_1, these two mutations may be passed to the\n   * callback function together when the two operations were done.\n   * Generally we need to trace child nodes of newly added nodes, but in this\n   * case if we count el_2 as el_1's child node in the first mutation record,\n   * then we will count el_2 again in the second mutation record which was\n   * duplicated.\n   * To avoid of duplicate counting added nodes, we use a Set to store\n   * added nodes and its child nodes during iterate mutation records. Then\n   * collect added nodes from the Set which have no duplicate copy. But\n   * this also causes newly added nodes will not be serialized with id ASAP,\n   * which means all the id related calculation should be lazy too.\n   */\n  private addedSet = new Set<Node>();\n  private movedSet = new Set<Node>();\n  private droppedSet = new Set<Node>();\n\n  private mutationCb: observerParam['mutationCb'];\n  private blockClass: observerParam['blockClass'];\n  private blockSelector: observerParam['blockSelector'];\n  private unblockSelector: observerParam['unblockSelector'];\n  private maskAllText: observerParam['maskAllText'];\n  private maskTextClass: observerParam['maskTextClass'];\n  private unmaskTextClass: observerParam['unmaskTextClass'];\n  private maskTextSelector: observerParam['maskTextSelector'];\n  private unmaskTextSelector: observerParam['unmaskTextSelector'];\n  private inlineStylesheet: observerParam['inlineStylesheet'];\n  private maskInputOptions: observerParam['maskInputOptions'];\n  private maskAttributeFn: observerParam['maskAttributeFn'];\n  private maskTextFn: observerParam['maskTextFn'];\n  private maskInputFn: observerParam['maskInputFn'];\n  private keepIframeSrcFn: observerParam['keepIframeSrcFn'];\n  private recordCanvas: observerParam['recordCanvas'];\n  private inlineImages: observerParam['inlineImages'];\n  private slimDOMOptions: observerParam['slimDOMOptions'];\n  private dataURLOptions: observerParam['dataURLOptions'];\n  private doc: observerParam['doc'];\n  private mirror: observerParam['mirror'];\n  private iframeManager: observerParam['iframeManager'];\n  private stylesheetManager: observerParam['stylesheetManager'];\n  private shadowDomManager: observerParam['shadowDomManager'];\n  private canvasManager: observerParam['canvasManager'];\n  private processedNodeManager: observerParam['processedNodeManager'];\n  private ignoreCSSAttributes: observerParam['ignoreCSSAttributes'];\n  private styleDeclarationParser!: StyleDeclarationParser;\n\n  public init(options: MutationBufferParam) {\n    (\n      [\n        'mutationCb',\n        'blockClass',\n        'blockSelector',\n        'unblockSelector',\n        'maskAllText',\n        'maskTextClass',\n        'unmaskTextClass',\n        'maskTextSelector',\n        'unmaskTextSelector',\n        'inlineStylesheet',\n        'maskInputOptions',\n        'maskAttributeFn',\n        'maskTextFn',\n        'maskInputFn',\n        'keepIframeSrcFn',\n        'recordCanvas',\n        'inlineImages',\n        'slimDOMOptions',\n        'dataURLOptions',\n        'doc',\n        'mirror',\n        'iframeManager',\n        'stylesheetManager',\n        'shadowDomManager',\n        'canvasManager',\n        'processedNodeManager',\n        'ignoreCSSAttributes',\n      ] as const\n    ).forEach((key) => {\n      // just a type trick, the runtime result is correct\n      this[key] = options[key] as never;\n    });\n\n    this.styleDeclarationParser = new StyleDeclarationParser(this.doc);\n  }\n\n  public freeze() {\n    this.frozen = true;\n    this.canvasManager.freeze();\n  }\n\n  public unfreeze() {\n    this.frozen = false;\n    this.canvasManager.unfreeze();\n    this.emit();\n  }\n\n  public isFrozen() {\n    return this.frozen;\n  }\n\n  public lock() {\n    this.locked = true;\n    this.canvasManager.lock();\n  }\n\n  public unlock() {\n    this.locked = false;\n    this.canvasManager.unlock();\n    this.emit();\n  }\n\n  public reset() {\n    this.shadowDomManager.reset();\n    this.canvasManager.reset();\n  }\n\n  public processMutations = (mutations: mutationRecord[]) => {\n    mutations.forEach(this.processMutation); // adds mutations to the buffer\n    this.emit(); // clears buffer if not locked/frozen\n  };\n\n  public emit = () => {\n    if (this.frozen || this.locked) {\n      return;\n    }\n\n    // delay any modification of the mirror until this function\n    // so that the mirror for takeFullSnapshot doesn't get mutated while it's event is being processed\n\n    const adds: addedNodeMutation[] = [];\n    const addedIds = new Set<number>();\n\n    /**\n     * Sometimes child node may be pushed before its newly added\n     * parent, so we init a queue to store these nodes.\n     */\n    const addList = new DoubleLinkedList();\n    const getNextId = (n: Node): number | null => {\n      let ns: Node | null = n;\n      let nextId: number | null = IGNORED_NODE; // slimDOM: ignored\n      while (nextId === IGNORED_NODE) {\n        ns = ns && ns.nextSibling;\n        nextId = ns && this.mirror.getId(ns);\n      }\n      return nextId;\n    };\n    const pushAdd = (n: Node) => {\n      if (!n.parentNode || !inDom(n)) {\n        return;\n      }\n      const parentId = isShadowRoot(n.parentNode)\n        ? this.mirror.getId(getShadowHost(n))\n        : this.mirror.getId(n.parentNode);\n      const nextId = getNextId(n);\n      if (parentId === -1 || nextId === -1) {\n        return addList.addNode(n);\n      }\n      const sn = serializeNodeWithId(n, {\n        doc: this.doc,\n        mirror: this.mirror,\n        blockClass: this.blockClass,\n        blockSelector: this.blockSelector,\n        maskAllText: this.maskAllText,\n        unblockSelector: this.unblockSelector,\n        maskTextClass: this.maskTextClass,\n        unmaskTextClass: this.unmaskTextClass,\n        maskTextSelector: this.maskTextSelector,\n        unmaskTextSelector: this.unmaskTextSelector,\n        skipChild: true,\n        newlyAddedElement: true,\n        inlineStylesheet: this.inlineStylesheet,\n        maskInputOptions: this.maskInputOptions,\n        maskAttributeFn: this.maskAttributeFn,\n        maskTextFn: this.maskTextFn,\n        maskInputFn: this.maskInputFn,\n        slimDOMOptions: this.slimDOMOptions,\n        dataURLOptions: this.dataURLOptions,\n        recordCanvas: this.recordCanvas,\n        inlineImages: this.inlineImages,\n        onSerialize: (currentN) => {\n          if (\n            isSerializedIframe(currentN, this.mirror) &&\n            !isBlocked(\n              currentN,\n              this.blockClass,\n              this.blockSelector,\n              this.unblockSelector,\n              false,\n            )\n          ) {\n            this.iframeManager.addIframe(currentN as HTMLIFrameElement);\n          }\n          if (isSerializedStylesheet(currentN, this.mirror)) {\n            this.stylesheetManager.trackLinkElement(\n              currentN as HTMLLinkElement,\n            );\n          }\n          if (hasShadowRoot(n)) {\n            this.shadowDomManager.addShadowRoot(n.shadowRoot, this.doc);\n          }\n        },\n        onIframeLoad: (iframe, childSn) => {\n          if (\n            isBlocked(\n              iframe,\n              this.blockClass,\n              this.blockSelector,\n              this.unblockSelector,\n              false,\n            )\n          ) {\n            return;\n          }\n\n          this.iframeManager.attachIframe(iframe, childSn);\n          const contentWindow = getIFrameContentWindow(iframe);\n          if (contentWindow) {\n            this.canvasManager.addWindow(contentWindow as IWindow);\n          }\n          this.shadowDomManager.observeAttachShadow(iframe);\n        },\n        onStylesheetLoad: (link, childSn) => {\n          this.stylesheetManager.attachLinkElement(link, childSn);\n        },\n        onBlockedImageLoad: (_imageEl, serializedNode, { width, height }) => {\n          this.mutationCb({\n            adds: [],\n            removes: [],\n            texts: [],\n            attributes: [\n              {\n                id: serializedNode.id,\n                attributes: {\n                  style: {\n                    width: `${width}px`,\n                    height: `${height}px`,\n                  },\n                },\n              },\n            ],\n          });\n        },\n        ignoreCSSAttributes: this.ignoreCSSAttributes,\n      });\n      if (sn) {\n        adds.push({\n          parentId,\n          nextId,\n          node: sn,\n        });\n        addedIds.add(sn.id);\n      }\n    };\n\n    while (this.mapRemoves.length) {\n      this.mirror.removeNodeFromMap(this.mapRemoves.shift()!);\n    }\n\n    for (const n of this.movedSet) {\n      if (\n        isParentRemoved(this.removes, n, this.mirror) &&\n        !this.movedSet.has(n.parentNode!)\n      ) {\n        continue;\n      }\n      pushAdd(n);\n    }\n\n    for (const n of this.addedSet) {\n      if (\n        !isAncestorInSet(this.droppedSet, n) &&\n        !isParentRemoved(this.removes, n, this.mirror)\n      ) {\n        pushAdd(n);\n      } else if (isAncestorInSet(this.movedSet, n)) {\n        pushAdd(n);\n      } else {\n        this.droppedSet.add(n);\n      }\n    }\n\n    let candidate: DoubleLinkedListNode | null = null;\n    while (addList.length) {\n      let node: DoubleLinkedListNode | null = null;\n      if (candidate) {\n        const parentId = this.mirror.getId(candidate.value.parentNode);\n        const nextId = getNextId(candidate.value);\n        if (parentId !== -1 && nextId !== -1) {\n          node = candidate;\n        }\n      }\n      if (!node) {\n        let tailNode = addList.tail;\n        while (tailNode) {\n          const _node = tailNode;\n          tailNode = tailNode.previous;\n          // ensure _node is defined before attempting to find value\n          if (_node) {\n            const parentId = this.mirror.getId(_node.value.parentNode);\n            const nextId = getNextId(_node.value);\n\n            if (nextId === -1) continue;\n            // nextId !== -1 && parentId !== -1\n            else if (parentId !== -1) {\n              node = _node;\n              break;\n            }\n            // nextId !== -1 && parentId === -1 This branch can happen if the node is the child of shadow root\n            else {\n              const unhandledNode = _node.value;\n              // If the node is the direct child of a shadow root, we treat the shadow host as its parent node.\n              if (\n                unhandledNode.parentNode &&\n                unhandledNode.parentNode.nodeType ===\n                  Node.DOCUMENT_FRAGMENT_NODE\n              ) {\n                const shadowHost = (unhandledNode.parentNode as ShadowRoot)\n                  .host;\n                const parentId = this.mirror.getId(shadowHost);\n                if (parentId !== -1) {\n                  node = _node;\n                  break;\n                }\n              }\n            }\n          }\n        }\n      }\n      if (!node) {\n        /**\n         * If all nodes in queue could not find a serialized parent,\n         * it may be a bug or corner case. We need to escape the\n         * dead while loop at once.\n         */\n        while (addList.head) {\n          addList.removeNode(addList.head.value);\n        }\n        break;\n      }\n      candidate = node.previous;\n      addList.removeNode(node.value);\n      pushAdd(node.value);\n    }\n\n    const payload = {\n      texts: this.texts\n        .map((text) => ({\n          id: this.mirror.getId(text.node),\n          value: text.value,\n        }))\n        // no need to include them on added elements, as they have just been serialized with up to date attribubtes\n        .filter((text) => !addedIds.has(text.id))\n        // text mutation's id was not in the mirror map means the target node has been removed\n        .filter((text) => this.mirror.has(text.id)),\n      attributes: this.attributes\n        .map((attribute) => {\n          const { attributes } = attribute;\n          if (typeof attributes.style === 'string') {\n            const diffAsStr = JSON.stringify(attribute.styleDiff);\n            const unchangedAsStr = JSON.stringify(attribute._unchangedStyles);\n            // check if the style diff is actually shorter than the regular string based mutation\n            // (which was the whole point of #464 'compact style mutation').\n            if (diffAsStr.length < attributes.style.length) {\n              // also: CSSOM fails badly when var() is present on shorthand properties, so only proceed with\n              // the compact style mutation if these have all been accounted for\n              if (\n                (diffAsStr + unchangedAsStr).split('var(').length ===\n                attributes.style.split('var(').length\n              ) {\n                attributes.style = attribute.styleDiff;\n              }\n            }\n          }\n          return {\n            id: this.mirror.getId(attribute.node),\n            attributes: attributes,\n          };\n        })\n        // no need to include them on added elements, as they have just been serialized with up to date attribubtes\n        .filter((attribute) => !addedIds.has(attribute.id))\n        // attribute mutation's id was not in the mirror map means the target node has been removed\n        .filter((attribute) => this.mirror.has(attribute.id)),\n      removes: this.removes,\n      adds,\n    };\n    // payload may be empty if the mutations happened in some blocked elements\n    if (\n      !payload.texts.length &&\n      !payload.attributes.length &&\n      !payload.removes.length &&\n      !payload.adds.length\n    ) {\n      return;\n    }\n\n    // reset\n    this.texts = [];\n    this.attributes = [];\n    this.attributeMap = new WeakMap<Node, attributeCursor>();\n    this.removes = [];\n    this.addedSet = new Set<Node>();\n    this.movedSet = new Set<Node>();\n    this.droppedSet = new Set<Node>();\n    this.movedMap = {};\n\n    this.mutationCb(payload);\n  };\n\n  private processMutation = (m: mutationRecord) => {\n    if (isIgnored(m.target, this.mirror)) {\n      return;\n    }\n    switch (m.type) {\n      case 'characterData': {\n        const value = m.target.textContent;\n\n        if (\n          !isBlocked(\n            m.target,\n            this.blockClass,\n            this.blockSelector,\n            this.unblockSelector,\n            false,\n          ) &&\n          value !== m.oldValue\n        ) {\n          this.texts.push({\n            value:\n              needMaskingText(\n                m.target,\n                this.maskTextClass,\n                this.maskTextSelector,\n                this.unmaskTextClass,\n                this.unmaskTextSelector,\n                this.maskAllText,\n              ) && value\n                ? this.maskTextFn\n                  ? this.maskTextFn(value, closestElementOfNode(m.target))\n                  : value.replace(/[\\S]/g, '*')\n                : value,\n            node: m.target,\n          });\n        }\n        break;\n      }\n\n      case 'attributes': {\n        const target = m.target as HTMLElement;\n        let attributeName = m.attributeName as string;\n        let value = (m.target as HTMLElement).getAttribute(attributeName);\n\n        if (attributeName === 'value') {\n          const type = getInputType(target);\n          const tagName = target.tagName as unknown as Uppercase<string>;\n          value = getInputValue(target as HTMLInputElement, tagName, type);\n\n          const isInputMasked = shouldMaskInput({\n            maskInputOptions: this.maskInputOptions,\n            tagName,\n            type,\n          });\n\n          const forceMask = needMaskingText(\n            m.target,\n            this.maskTextClass,\n            this.maskTextSelector,\n            this.unmaskTextClass,\n            this.unmaskTextSelector,\n            isInputMasked,\n          );\n\n          value = maskInputValue({\n            isMasked: forceMask,\n            element: target,\n            value,\n            maskInputFn: this.maskInputFn,\n          });\n        }\n        if (\n          isBlocked(\n            m.target,\n            this.blockClass,\n            this.blockSelector,\n            this.unblockSelector,\n            false,\n          ) ||\n          value === m.oldValue\n        ) {\n          return;\n        }\n\n        let item = this.attributeMap.get(m.target);\n        if (\n          target.tagName === 'IFRAME' &&\n          attributeName === 'src' &&\n          !this.keepIframeSrcFn(value as string)\n        ) {\n          const iframeDoc = getIFrameContentDocument(\n            target as HTMLIFrameElement,\n          );\n          if (!iframeDoc) {\n            // we can't record it directly as we can't see into it\n            // preserve the src attribute so a decision can be taken at replay time\n            attributeName = 'rr_src';\n          } else {\n            return;\n          }\n        }\n        if (!item) {\n          item = {\n            node: m.target,\n            attributes: {},\n            styleDiff: {},\n            _unchangedStyles: {},\n          };\n          this.attributes.push(item);\n          this.attributeMap.set(m.target, item);\n        }\n\n        // Keep this property on inputs that used to be password inputs\n        // This is used to ensure we do not unmask value when using e.g. a \"Show password\" type button\n        if (\n          attributeName === 'type' &&\n          target.tagName === 'INPUT' &&\n          (m.oldValue || '').toLowerCase() === 'password'\n        ) {\n          target.setAttribute('data-rr-is-password', 'true');\n        }\n\n        if (!ignoreAttribute(target.tagName, attributeName, value)) {\n          // overwrite attribute if the mutations was triggered in same time\n          item.attributes[attributeName] = transformAttribute(\n            this.doc,\n            toLowerCase(target.tagName),\n            toLowerCase(attributeName),\n            value,\n            target,\n            this.maskAttributeFn,\n          );\n          if (attributeName === 'style') {\n            const oldStyle = m.oldValue\n              ? this.styleDeclarationParser.parse(m.oldValue)\n              : null;\n            for (const pname of Array.from(target.style)) {\n              const newValue = target.style.getPropertyValue(pname);\n              const newPriority = target.style.getPropertyPriority(pname);\n              if (\n                newValue !== (oldStyle?.getPropertyValue(pname) || '') ||\n                newPriority !== (oldStyle?.getPropertyPriority(pname) || '')\n              ) {\n                if (newPriority === '') {\n                  item.styleDiff[pname] = newValue;\n                } else {\n                  item.styleDiff[pname] = [newValue, newPriority];\n                }\n              } else {\n                // for checking\n                item._unchangedStyles[pname] = [newValue, newPriority];\n              }\n            }\n            if (oldStyle) {\n              for (const pname of Array.from(oldStyle)) {\n                if (target.style.getPropertyValue(pname) === '') {\n                  // \"if not set, returns the empty string\"\n                  item.styleDiff[pname] = false; // delete\n                }\n              }\n            }\n          }\n        }\n        break;\n      }\n      case 'childList': {\n        /**\n         * Parent is blocked, ignore all child mutations\n         */\n        if (\n          isBlocked(\n            m.target,\n            this.blockClass,\n            this.blockSelector,\n            this.unblockSelector,\n            true,\n          )\n        ) {\n          return;\n        }\n\n        m.addedNodes.forEach((n) => this.genAdds(n, m.target));\n        m.removedNodes.forEach((n) => {\n          const nodeId = this.mirror.getId(n);\n          const parentId = isShadowRoot(m.target)\n            ? this.mirror.getId(m.target.host)\n            : this.mirror.getId(m.target);\n          if (\n            isBlocked(\n              m.target,\n              this.blockClass,\n              this.blockSelector,\n              this.unblockSelector,\n              false,\n            ) ||\n            isIgnored(n, this.mirror) ||\n            !isSerialized(n, this.mirror)\n          ) {\n            return;\n          }\n          // removed node has not been serialized yet, just remove it from the Set\n          if (this.addedSet.has(n)) {\n            deepDelete(this.addedSet, n);\n            this.droppedSet.add(n);\n          } else if (this.addedSet.has(m.target) && nodeId === -1) {\n            /**\n             * If target was newly added and removed child node was\n             * not serialized, it means the child node has been removed\n             * before callback fired, so we can ignore it because\n             * newly added node will be serialized without child nodes.\n             * TODO: verify this\n             */\n          } else if (isAncestorRemoved(m.target, this.mirror)) {\n            /**\n             * If parent id was not in the mirror map any more, it\n             * means the parent node has already been removed. So\n             * the node is also removed which we do not need to track\n             * and replay.\n             */\n          } else if (\n            this.movedSet.has(n) &&\n            this.movedMap[moveKey(nodeId, parentId)]\n          ) {\n            deepDelete(this.movedSet, n);\n          } else {\n            this.removes.push({\n              parentId,\n              id: nodeId,\n              isShadow:\n                isShadowRoot(m.target) && isNativeShadowDom(m.target)\n                  ? true\n                  : undefined,\n            });\n          }\n          this.mapRemoves.push(n);\n        });\n        break;\n      }\n      default:\n        break;\n    }\n  };\n\n  /**\n   * Make sure you check if `n`'s parent is blocked before calling this function\n   * */\n  private genAdds = (n: Node, target?: Node) => {\n    // this node was already recorded in other buffer, ignore it\n    if (this.processedNodeManager.inOtherBuffer(n, this)) return;\n\n    // if n is added to set, there is no need to travel it and its' children again\n    if (this.addedSet.has(n) || this.movedSet.has(n)) return;\n\n    if (this.mirror.hasNode(n)) {\n      if (isIgnored(n, this.mirror)) {\n        return;\n      }\n      this.movedSet.add(n);\n      let targetId: number | null = null;\n      if (target && this.mirror.hasNode(target)) {\n        targetId = this.mirror.getId(target);\n      }\n      if (targetId && targetId !== -1) {\n        this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;\n      }\n    } else {\n      this.addedSet.add(n);\n      this.droppedSet.delete(n);\n    }\n\n    // if this node is blocked `serializeNode` will turn it into a placeholder element\n    // but we have to remove it's children otherwise they will be added as placeholders too\n    if (\n      !isBlocked(\n        n,\n        this.blockClass,\n        this.blockSelector,\n        this.unblockSelector,\n        false,\n      )\n    ) {\n      if (n.childNodes) {\n        n.childNodes.forEach((childN) => this.genAdds(childN));\n      }\n      if (hasShadowRoot(n)) {\n        n.shadowRoot.childNodes.forEach((childN) => {\n          this.processedNodeManager.add(childN, this);\n          this.genAdds(childN, n);\n        });\n      }\n    }\n  };\n}\n\n/**\n * Some utils to handle the mutation observer DOM records.\n * It should be more clear to extend the native data structure\n * like Set and Map, but currently Typescript does not support\n * that.\n */\nfunction deepDelete(addsSet: Set<Node>, n: Node) {\n  addsSet.delete(n);\n  n.childNodes?.forEach((childN) => deepDelete(addsSet, childN));\n}\n\nfunction isParentRemoved(\n  removes: removedNodeMutation[],\n  n: Node,\n  mirror: Mirror,\n): boolean {\n  if (removes.length === 0) return false;\n  return _isParentRemoved(removes, n, mirror);\n}\n\nfunction _isParentRemoved(\n  removes: removedNodeMutation[],\n  n: Node,\n  mirror: Mirror,\n): boolean {\n  let node: ParentNode | null = n.parentNode;\n  while (node) {\n    const parentId = mirror.getId(node);\n    if (removes.some((r) => r.id === parentId)) {\n      return true;\n    }\n    node = node.parentNode;\n  }\n  return false;\n}\n\nfunction isAncestorInSet(set: Set<Node>, n: Node): boolean {\n  if (set.size === 0) return false;\n  return _isAncestorInSet(set, n);\n}\n\nfunction _isAncestorInSet(set: Set<Node>, n: Node): boolean {\n  const { parentNode } = n;\n  if (!parentNode) {\n    return false;\n  }\n  if (set.has(parentNode)) {\n    return true;\n  }\n  return _isAncestorInSet(set, parentNode);\n}\n","import {\n  maskInputValue,\n  Mirror,\n  getInputType,\n  getInputValue,\n  shouldMaskInput,\n  toLowerCase,\n  needMaskingText,\n  toUpperCase,\n} from '@sentry-internal/rrweb-snapshot';\nimport type { FontFaceSet } from 'css-font-loading-module';\nimport {\n  throttle,\n  on,\n  hookSetter,\n  getWindowScroll,\n  getWindowHeight,\n  getWindowWidth,\n  isBlocked,\n  legacy_isTouchEvent,\n  patch,\n  StyleSheetMirror,\n  nowTimestamp,\n  setTimeout,\n} from '../utils';\nimport type { observerParam, MutationBufferParam } from '../types';\nimport {\n  mousePosition,\n  MouseInteractions,\n  PointerTypes,\n  listenerHandler,\n  inputValue,\n  hookResetter,\n  IncrementalSource,\n  MediaInteractions,\n  fontParam,\n  IWindow,\n  SelectionRange,\n  hooksParam,\n} from '@sentry-internal/rrweb-types';\nimport MutationBuffer from './mutation';\nimport { callbackWrapper } from './error-handler';\n\ntype WindowWithStoredMutationObserver = IWindow & {\n  __rrMutationObserver?: MutationObserver;\n};\ntype WindowWithAngularZone = IWindow & {\n  Zone?: {\n    __symbol__?: (key: string) => string;\n  };\n};\n\nexport const mutationBuffers: MutationBuffer[] = [];\n\n// Event.path is non-standard and used in some older browsers\ntype NonStandardEvent = Omit<Event, 'composedPath'> & {\n  path: EventTarget[];\n};\n\nfunction getEventTarget(event: Event | NonStandardEvent): EventTarget | null {\n  try {\n    if ('composedPath' in event) {\n      const path = event.composedPath();\n      if (path.length) {\n        return path[0];\n      }\n    } else if ('path' in event && event.path.length) {\n      return event.path[0];\n    }\n  } catch {\n    // fallback to `event.target` below\n  }\n\n  return event && event.target;\n}\n\nexport function initMutationObserver(\n  options: MutationBufferParam,\n  rootEl: Node,\n): MutationObserver {\n  const mutationBuffer = new MutationBuffer();\n  mutationBuffers.push(mutationBuffer);\n  // see mutation.ts for details\n  mutationBuffer.init(options);\n  let mutationObserverCtor =\n    window.MutationObserver ||\n    /**\n     * Some websites may disable MutationObserver by removing it from the window object.\n     * If someone is using rrweb to build a browser extention or things like it, they\n     * could not change the website's code but can have an opportunity to inject some\n     * code before the website executing its JS logic.\n     * Then they can do this to store the native MutationObserver:\n     * window.__rrMutationObserver = MutationObserver\n     */\n    (window as WindowWithStoredMutationObserver).__rrMutationObserver;\n  const angularZoneSymbol = (\n    window as WindowWithAngularZone\n  )?.Zone?.__symbol__?.('MutationObserver');\n  if (\n    angularZoneSymbol &&\n    (window as unknown as Record<string, typeof MutationObserver>)[\n      angularZoneSymbol\n    ]\n  ) {\n    mutationObserverCtor = (\n      window as unknown as Record<string, typeof MutationObserver>\n    )[angularZoneSymbol];\n  }\n  const observer = new (mutationObserverCtor as new (\n    callback: MutationCallback,\n  ) => MutationObserver)(\n    callbackWrapper((mutations) => {\n      // If this callback returns `false`, we do not want to process the mutations\n      // This can be used to e.g. do a manual full snapshot when mutations become too large, or similar.\n      if (options.onMutation && options.onMutation(mutations) === false) {\n        return;\n      }\n      mutationBuffer.processMutations.bind(mutationBuffer)(mutations);\n    }),\n  );\n  observer.observe(rootEl, {\n    attributes: true,\n    attributeOldValue: true,\n    characterData: true,\n    characterDataOldValue: true,\n    childList: true,\n    subtree: true,\n  });\n  return observer;\n}\n\nfunction initMoveObserver({\n  mousemoveCb,\n  sampling,\n  doc,\n  mirror,\n}: observerParam): listenerHandler {\n  if (sampling.mousemove === false) {\n    return () => {\n      //\n    };\n  }\n\n  const threshold =\n    typeof sampling.mousemove === 'number' ? sampling.mousemove : 50;\n  const callbackThreshold =\n    typeof sampling.mousemoveCallback === 'number'\n      ? sampling.mousemoveCallback\n      : 500;\n\n  let positions: mousePosition[] = [];\n  let timeBaseline: number | null;\n  const wrappedCb = throttle(\n    callbackWrapper(\n      (\n        source:\n          | IncrementalSource.MouseMove\n          | IncrementalSource.TouchMove\n          | IncrementalSource.Drag,\n      ) => {\n        const totalOffset = Date.now() - timeBaseline!;\n        mousemoveCb(\n          positions.map((p) => {\n            p.timeOffset -= totalOffset;\n            return p;\n          }),\n          source,\n        );\n        positions = [];\n        timeBaseline = null;\n      },\n    ),\n    callbackThreshold,\n  );\n  const updatePosition = callbackWrapper(\n    throttle<MouseEvent | TouchEvent | DragEvent>(\n      callbackWrapper((evt) => {\n        const target = getEventTarget(evt);\n        // 'legacy' here as we could switch to https://developer.mozilla.org/en-US/docs/Web/API/Element/pointermove_event\n        const { clientX, clientY } = legacy_isTouchEvent(evt)\n          ? evt.changedTouches[0]\n          : evt;\n        if (!timeBaseline) {\n          timeBaseline = nowTimestamp();\n        }\n        positions.push({\n          x: clientX,\n          y: clientY,\n          id: mirror.getId(target as Node),\n          timeOffset: nowTimestamp() - timeBaseline,\n        });\n        // it is possible DragEvent is undefined even on devices\n        // that support event 'drag'\n        wrappedCb(\n          typeof DragEvent !== 'undefined' && evt instanceof DragEvent\n            ? IncrementalSource.Drag\n            : evt instanceof MouseEvent\n            ? IncrementalSource.MouseMove\n            : IncrementalSource.TouchMove,\n        );\n      }),\n      threshold,\n      {\n        trailing: false,\n      },\n    ),\n  );\n  const handlers = [\n    on('mousemove', updatePosition, doc),\n    on('touchmove', updatePosition, doc),\n    on('drag', updatePosition, doc),\n  ];\n  return callbackWrapper(() => {\n    handlers.forEach((h) => h());\n  });\n}\n\nfunction initMouseInteractionObserver({\n  mouseInteractionCb,\n  doc,\n  mirror,\n  blockClass,\n  blockSelector,\n  unblockSelector,\n  sampling,\n}: observerParam): listenerHandler {\n  if (sampling.mouseInteraction === false) {\n    return () => {\n      //\n    };\n  }\n  const disableMap: Record<string, boolean | undefined> =\n    sampling.mouseInteraction === true ||\n    sampling.mouseInteraction === undefined\n      ? {}\n      : sampling.mouseInteraction;\n\n  const handlers: listenerHandler[] = [];\n  let currentPointerType: PointerTypes | null = null;\n  const getHandler = (eventKey: keyof typeof MouseInteractions) => {\n    return (event: MouseEvent | TouchEvent | PointerEvent) => {\n      const target = getEventTarget(event) as Node;\n      if (isBlocked(target, blockClass, blockSelector, unblockSelector, true)) {\n        return;\n      }\n      let pointerType: PointerTypes | null = null;\n      let thisEventKey = eventKey;\n      if ('pointerType' in event) {\n        switch (event.pointerType) {\n          case 'mouse':\n            pointerType = PointerTypes.Mouse;\n            break;\n          case 'touch':\n            pointerType = PointerTypes.Touch;\n            break;\n          case 'pen':\n            pointerType = PointerTypes.Pen;\n            break;\n        }\n        if (pointerType === PointerTypes.Touch) {\n          if (MouseInteractions[eventKey] === MouseInteractions.MouseDown) {\n            // we are actually listening on 'pointerdown'\n            thisEventKey = 'TouchStart';\n          } else if (\n            MouseInteractions[eventKey] === MouseInteractions.MouseUp\n          ) {\n            // we are actually listening on 'pointerup'\n            thisEventKey = 'TouchEnd';\n          }\n        } else if (pointerType === PointerTypes.Pen) {\n          // TODO: these will get incorrectly emitted as MouseDown/MouseUp\n        }\n      } else if (legacy_isTouchEvent(event)) {\n        pointerType = PointerTypes.Touch;\n      }\n      if (pointerType !== null) {\n        currentPointerType = pointerType;\n        if (\n          (thisEventKey.startsWith('Touch') &&\n            pointerType === PointerTypes.Touch) ||\n          (thisEventKey.startsWith('Mouse') &&\n            pointerType === PointerTypes.Mouse)\n        ) {\n          // don't output redundant info\n          pointerType = null;\n        }\n      } else if (MouseInteractions[eventKey] === MouseInteractions.Click) {\n        pointerType = currentPointerType;\n        currentPointerType = null; // cleanup as we've used it\n      }\n      const e = legacy_isTouchEvent(event) ? event.changedTouches[0] : event;\n      if (!e) {\n        return;\n      }\n      const id = mirror.getId(target);\n      const { clientX, clientY } = e;\n      callbackWrapper(mouseInteractionCb)({\n        type: MouseInteractions[thisEventKey],\n        id,\n        x: clientX,\n        y: clientY,\n        ...(pointerType !== null && { pointerType }),\n      });\n    };\n  };\n  Object.keys(MouseInteractions)\n    .filter(\n      (key) =>\n        Number.isNaN(Number(key)) &&\n        !key.endsWith('_Departed') &&\n        disableMap[key] !== false,\n    )\n    .forEach((eventKey: keyof typeof MouseInteractions) => {\n      let eventName = toLowerCase(eventKey);\n      const handler = getHandler(eventKey);\n      if (window.PointerEvent) {\n        switch (MouseInteractions[eventKey]) {\n          case MouseInteractions.MouseDown:\n          case MouseInteractions.MouseUp:\n            eventName = eventName.replace(\n              'mouse',\n              'pointer',\n            ) as unknown as typeof eventName;\n            break;\n          case MouseInteractions.TouchStart:\n          case MouseInteractions.TouchEnd:\n            // these are handled by pointerdown/pointerup\n            return;\n        }\n      }\n      handlers.push(on(eventName, handler, doc));\n    });\n  return callbackWrapper(() => {\n    handlers.forEach((h) => h());\n  });\n}\n\nexport function initScrollObserver({\n  scrollCb,\n  doc,\n  mirror,\n  blockClass,\n  blockSelector,\n  unblockSelector,\n  sampling,\n}: Pick<\n  observerParam,\n  | 'scrollCb'\n  | 'doc'\n  | 'mirror'\n  | 'blockClass'\n  | 'blockSelector'\n  | 'unblockSelector'\n  | 'sampling'\n>): listenerHandler {\n  const updatePosition = callbackWrapper(\n    throttle<UIEvent>(\n      callbackWrapper((evt) => {\n        const target = getEventTarget(evt);\n        if (\n          !target ||\n          isBlocked(\n            target as Node,\n            blockClass,\n            blockSelector,\n            unblockSelector,\n            true,\n          )\n        ) {\n          return;\n        }\n        const id = mirror.getId(target as Node);\n        if (target === doc && doc.defaultView) {\n          const scrollLeftTop = getWindowScroll(doc.defaultView);\n          scrollCb({\n            id,\n            x: scrollLeftTop.left,\n            y: scrollLeftTop.top,\n          });\n        } else {\n          scrollCb({\n            id,\n            x: (target as HTMLElement).scrollLeft,\n            y: (target as HTMLElement).scrollTop,\n          });\n        }\n      }),\n      sampling.scroll || 100,\n    ),\n  );\n  return on('scroll', updatePosition, doc);\n}\n\nfunction initViewportResizeObserver(\n  { viewportResizeCb }: observerParam,\n  { win }: { win: IWindow },\n): listenerHandler {\n  let lastH = -1;\n  let lastW = -1;\n  const updateDimension = callbackWrapper(\n    throttle(\n      callbackWrapper(() => {\n        const height = getWindowHeight();\n        const width = getWindowWidth();\n        if (lastH !== height || lastW !== width) {\n          viewportResizeCb({\n            width: Number(width),\n            height: Number(height),\n          });\n          lastH = height;\n          lastW = width;\n        }\n      }),\n      200,\n    ),\n  );\n  return on('resize', updateDimension, win);\n}\n\nexport const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];\nconst lastInputValueMap: WeakMap<EventTarget, inputValue> = new WeakMap();\nfunction initInputObserver({\n  inputCb,\n  doc,\n  mirror,\n  blockClass,\n  blockSelector,\n  unblockSelector,\n  ignoreClass,\n  ignoreSelector,\n  maskInputOptions,\n  maskInputFn,\n  sampling,\n  userTriggeredOnInput,\n  maskTextClass,\n  unmaskTextClass,\n  maskTextSelector,\n  unmaskTextSelector,\n}: observerParam): listenerHandler {\n  function eventHandler(event: Event) {\n    let target = getEventTarget(event) as HTMLElement | null;\n    const userTriggered = event.isTrusted;\n    const tagName = target && toUpperCase((target as Element).tagName);\n    /**\n     * If a site changes the value 'selected' of an option element, the value of its parent element, usually a select element, will be changed as well.\n     * We can treat this change as a value change of the select element the current target belongs to.\n     */\n    if (tagName === 'OPTION') target = (target as Element).parentElement;\n    if (\n      !target ||\n      !tagName ||\n      INPUT_TAGS.indexOf(tagName) < 0 ||\n      isBlocked(\n        target as Node,\n        blockClass,\n        blockSelector,\n        unblockSelector,\n        true,\n      )\n    ) {\n      return;\n    }\n\n    const el = target as\n      | HTMLInputElement\n      | HTMLTextAreaElement\n      | HTMLSelectElement;\n\n    if (\n      el.classList.contains(ignoreClass) ||\n      (ignoreSelector && el.matches(ignoreSelector))\n    ) {\n      return;\n    }\n\n    const type = getInputType(target);\n    let text = getInputValue(el, tagName, type);\n    let isChecked = false;\n\n    const isInputMasked = shouldMaskInput({\n      maskInputOptions,\n      tagName,\n      type,\n    });\n\n    const forceMask = needMaskingText(\n      target as Node,\n      maskTextClass,\n      maskTextSelector,\n      unmaskTextClass,\n      unmaskTextSelector,\n      isInputMasked,\n    );\n\n    if (type === 'radio' || type === 'checkbox') {\n      isChecked = (target as HTMLInputElement).checked;\n    }\n\n    text = maskInputValue({\n      isMasked: forceMask,\n      element: target,\n      value: text,\n      maskInputFn,\n    });\n\n    cbWithDedup(\n      target,\n      userTriggeredOnInput\n        ? { text, isChecked, userTriggered }\n        : { text, isChecked },\n    );\n    // if a radio was checked\n    // the other radios with the same name attribute will be unchecked.\n    const name: string | undefined = (target as HTMLInputElement).name;\n    if (type === 'radio' && name && isChecked) {\n      doc\n        .querySelectorAll(`input[type=\"radio\"][name=\"${name}\"]`)\n        .forEach((el) => {\n          if (el !== target) {\n            const text = maskInputValue({\n              // share mask behavior of `target`\n              isMasked: forceMask,\n              element: el as HTMLInputElement,\n              value: getInputValue(el as HTMLInputElement, tagName, type),\n              maskInputFn,\n            });\n            cbWithDedup(\n              el,\n              userTriggeredOnInput\n                ? { text, isChecked: !isChecked, userTriggered: false }\n                : { text, isChecked: !isChecked },\n            );\n          }\n        });\n    }\n  }\n  function cbWithDedup(target: EventTarget, v: inputValue) {\n    const lastInputValue = lastInputValueMap.get(target);\n    if (\n      !lastInputValue ||\n      lastInputValue.text !== v.text ||\n      lastInputValue.isChecked !== v.isChecked\n    ) {\n      lastInputValueMap.set(target, v);\n      const id = mirror.getId(target as Node);\n      callbackWrapper(inputCb)({\n        ...v,\n        id,\n      });\n    }\n  }\n  const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];\n  const handlers: Array<listenerHandler | hookResetter> = events.map(\n    (eventName) => on(eventName, callbackWrapper(eventHandler), doc),\n  );\n  const currentWindow = doc.defaultView;\n  if (!currentWindow) {\n    return () => {\n      handlers.forEach((h) => h());\n    };\n  }\n  const propertyDescriptor = currentWindow.Object.getOwnPropertyDescriptor(\n    currentWindow.HTMLInputElement.prototype,\n    'value',\n  );\n  const hookProperties: Array<[HTMLElement, string]> = [\n    [currentWindow.HTMLInputElement.prototype, 'value'],\n    [currentWindow.HTMLInputElement.prototype, 'checked'],\n    [currentWindow.HTMLSelectElement.prototype, 'value'],\n    [currentWindow.HTMLTextAreaElement.prototype, 'value'],\n    // Some UI library use selectedIndex to set select value\n    [currentWindow.HTMLSelectElement.prototype, 'selectedIndex'],\n    [currentWindow.HTMLOptionElement.prototype, 'selected'],\n  ];\n  if (propertyDescriptor && propertyDescriptor.set) {\n    handlers.push(\n      ...hookProperties.map((p) =>\n        hookSetter<HTMLElement>(\n          p[0],\n          p[1],\n          {\n            set() {\n              // mock to a normal event\n              callbackWrapper(eventHandler)({\n                target: this as EventTarget,\n                isTrusted: false, // userTriggered to false as this could well be programmatic\n              } as Event);\n            },\n          },\n          false,\n          currentWindow,\n        ),\n      ),\n    );\n  }\n  return callbackWrapper(() => {\n    handlers.forEach((h) => h());\n  });\n}\n\ntype GroupingCSSRule =\n  | CSSGroupingRule\n  | CSSMediaRule\n  | CSSSupportsRule\n  | CSSConditionRule;\ntype GroupingCSSRuleTypes =\n  | typeof CSSGroupingRule\n  | typeof CSSMediaRule\n  | typeof CSSSupportsRule\n  | typeof CSSConditionRule;\n\nfunction getNestedCSSRulePositions(rule: CSSRule): number[] {\n  const positions: number[] = [];\n  function recurse(childRule: CSSRule, pos: number[]) {\n    if (\n      (hasNestedCSSRule('CSSGroupingRule') &&\n        childRule.parentRule instanceof CSSGroupingRule) ||\n      (hasNestedCSSRule('CSSMediaRule') &&\n        childRule.parentRule instanceof CSSMediaRule) ||\n      (hasNestedCSSRule('CSSSupportsRule') &&\n        childRule.parentRule instanceof CSSSupportsRule) ||\n      (hasNestedCSSRule('CSSConditionRule') &&\n        childRule.parentRule instanceof CSSConditionRule)\n    ) {\n      const rules = Array.from(\n        (childRule.parentRule as GroupingCSSRule).cssRules,\n      );\n      const index = rules.indexOf(childRule);\n      pos.unshift(index);\n    } else if (childRule.parentStyleSheet) {\n      const rules = Array.from(childRule.parentStyleSheet.cssRules);\n      const index = rules.indexOf(childRule);\n      pos.unshift(index);\n    }\n    return pos;\n  }\n  return recurse(rule, positions);\n}\n\n/**\n * For StyleSheets in Element, this function retrieves id of its host element.\n * For adopted StyleSheets, this function retrieves its styleId from a styleMirror.\n */\nfunction getIdAndStyleId(\n  sheet: CSSStyleSheet | undefined | null,\n  mirror: Mirror,\n  styleMirror: StyleSheetMirror,\n): {\n  styleId?: number;\n  id?: number;\n} {\n  let id, styleId;\n  if (!sheet) return {};\n  if (sheet.ownerNode) id = mirror.getId(sheet.ownerNode as Node);\n  else styleId = styleMirror.getId(sheet);\n  return {\n    styleId,\n    id,\n  };\n}\n\nfunction initStyleSheetObserver(\n  { styleSheetRuleCb, mirror, stylesheetManager }: observerParam,\n  { win }: { win: IWindow },\n): listenerHandler {\n  if (!win.CSSStyleSheet || !win.CSSStyleSheet.prototype) {\n    // If, for whatever reason, CSSStyleSheet is not available, we skip the observation of stylesheets.\n    return () => {\n      // Do nothing\n    };\n  }\n\n  // eslint-disable-next-line @typescript-eslint/unbound-method\n  const insertRule = win.CSSStyleSheet.prototype.insertRule;\n  win.CSSStyleSheet.prototype.insertRule = new Proxy(insertRule, {\n    apply: callbackWrapper(\n      (\n        target: typeof insertRule,\n        thisArg: CSSStyleSheet,\n        argumentsList: [string, number | undefined],\n      ) => {\n        const [rule, index] = argumentsList;\n\n        const { id, styleId } = getIdAndStyleId(\n          thisArg,\n          mirror,\n          stylesheetManager.styleMirror,\n        );\n\n        if ((id && id !== -1) || (styleId && styleId !== -1)) {\n          styleSheetRuleCb({\n            id,\n            styleId,\n            adds: [{ rule, index }],\n          });\n        }\n        return target.apply(thisArg, argumentsList);\n      },\n    ),\n  });\n\n  // eslint-disable-next-line @typescript-eslint/unbound-method\n  const deleteRule = win.CSSStyleSheet.prototype.deleteRule;\n  win.CSSStyleSheet.prototype.deleteRule = new Proxy(deleteRule, {\n    apply: callbackWrapper(\n      (\n        target: typeof deleteRule,\n        thisArg: CSSStyleSheet,\n        argumentsList: [number],\n      ) => {\n        const [index] = argumentsList;\n\n        const { id, styleId } = getIdAndStyleId(\n          thisArg,\n          mirror,\n          stylesheetManager.styleMirror,\n        );\n\n        if ((id && id !== -1) || (styleId && styleId !== -1)) {\n          styleSheetRuleCb({\n            id,\n            styleId,\n            removes: [{ index }],\n          });\n        }\n        return target.apply(thisArg, argumentsList);\n      },\n    ),\n  });\n\n  let replace: (text: string) => Promise<CSSStyleSheet>;\n\n  if (win.CSSStyleSheet.prototype.replace) {\n    // eslint-disable-next-line @typescript-eslint/unbound-method\n    replace = win.CSSStyleSheet.prototype.replace;\n    win.CSSStyleSheet.prototype.replace = new Proxy(replace, {\n      apply: callbackWrapper(\n        (\n          target: typeof replace,\n          thisArg: CSSStyleSheet,\n          argumentsList: [string],\n        ) => {\n          const [text] = argumentsList;\n\n          const { id, styleId } = getIdAndStyleId(\n            thisArg,\n            mirror,\n            stylesheetManager.styleMirror,\n          );\n\n          if ((id && id !== -1) || (styleId && styleId !== -1)) {\n            styleSheetRuleCb({\n              id,\n              styleId,\n              replace: text,\n            });\n          }\n          return target.apply(thisArg, argumentsList);\n        },\n      ),\n    });\n  }\n\n  let replaceSync: (text: string) => void;\n  if (win.CSSStyleSheet.prototype.replaceSync) {\n    // eslint-disable-next-line @typescript-eslint/unbound-method\n    replaceSync = win.CSSStyleSheet.prototype.replaceSync;\n    win.CSSStyleSheet.prototype.replaceSync = new Proxy(replaceSync, {\n      apply: callbackWrapper(\n        (\n          target: typeof replaceSync,\n          thisArg: CSSStyleSheet,\n          argumentsList: [string],\n        ) => {\n          const [text] = argumentsList;\n\n          const { id, styleId } = getIdAndStyleId(\n            thisArg,\n            mirror,\n            stylesheetManager.styleMirror,\n          );\n\n          if ((id && id !== -1) || (styleId && styleId !== -1)) {\n            styleSheetRuleCb({\n              id,\n              styleId,\n              replaceSync: text,\n            });\n          }\n          return target.apply(thisArg, argumentsList);\n        },\n      ),\n    });\n  }\n\n  const supportedNestedCSSRuleTypes: {\n    [key: string]: GroupingCSSRuleTypes;\n  } = {};\n  if (canMonkeyPatchNestedCSSRule('CSSGroupingRule')) {\n    supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;\n  } else {\n    // Some browsers (Safari) don't support CSSGroupingRule\n    // https://caniuse.com/?search=cssgroupingrule\n    // fall back to monkey patching classes that would have inherited from CSSGroupingRule\n\n    if (canMonkeyPatchNestedCSSRule('CSSMediaRule')) {\n      supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;\n    }\n    if (canMonkeyPatchNestedCSSRule('CSSConditionRule')) {\n      supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;\n    }\n    if (canMonkeyPatchNestedCSSRule('CSSSupportsRule')) {\n      supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;\n    }\n  }\n\n  const unmodifiedFunctions: {\n    [key: string]: {\n      insertRule: (rule: string, index?: number) => number;\n      deleteRule: (index: number) => void;\n    };\n  } = {};\n\n  Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n    unmodifiedFunctions[typeKey] = {\n      // eslint-disable-next-line @typescript-eslint/unbound-method\n      insertRule: type.prototype.insertRule,\n      // eslint-disable-next-line @typescript-eslint/unbound-method\n      deleteRule: type.prototype.deleteRule,\n    };\n\n    type.prototype.insertRule = new Proxy(\n      unmodifiedFunctions[typeKey].insertRule,\n      {\n        apply: callbackWrapper(\n          (\n            target: typeof insertRule,\n            thisArg: CSSRule,\n            argumentsList: [string, number | undefined],\n          ) => {\n            const [rule, index] = argumentsList;\n\n            const { id, styleId } = getIdAndStyleId(\n              thisArg.parentStyleSheet,\n              mirror,\n              stylesheetManager.styleMirror,\n            );\n\n            if ((id && id !== -1) || (styleId && styleId !== -1)) {\n              styleSheetRuleCb({\n                id,\n                styleId,\n                adds: [\n                  {\n                    rule,\n                    index: [\n                      ...getNestedCSSRulePositions(thisArg),\n                      index || 0, // defaults to 0\n                    ],\n                  },\n                ],\n              });\n            }\n            return target.apply(thisArg, argumentsList);\n          },\n        ),\n      },\n    );\n\n    type.prototype.deleteRule = new Proxy(\n      unmodifiedFunctions[typeKey].deleteRule,\n      {\n        apply: callbackWrapper(\n          (\n            target: typeof deleteRule,\n            thisArg: CSSRule,\n            argumentsList: [number],\n          ) => {\n            const [index] = argumentsList;\n\n            const { id, styleId } = getIdAndStyleId(\n              thisArg.parentStyleSheet,\n              mirror,\n              stylesheetManager.styleMirror,\n            );\n\n            if ((id && id !== -1) || (styleId && styleId !== -1)) {\n              styleSheetRuleCb({\n                id,\n                styleId,\n                removes: [\n                  { index: [...getNestedCSSRulePositions(thisArg), index] },\n                ],\n              });\n            }\n            return target.apply(thisArg, argumentsList);\n          },\n        ),\n      },\n    );\n  });\n\n  return callbackWrapper(() => {\n    win.CSSStyleSheet.prototype.insertRule = insertRule;\n    win.CSSStyleSheet.prototype.deleteRule = deleteRule;\n    replace && (win.CSSStyleSheet.prototype.replace = replace);\n    replaceSync && (win.CSSStyleSheet.prototype.replaceSync = replaceSync);\n    Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {\n      type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;\n      type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;\n    });\n  });\n}\n\nexport function initAdoptedStyleSheetObserver(\n  {\n    mirror,\n    stylesheetManager,\n  }: Pick<observerParam, 'mirror' | 'stylesheetManager'>,\n  host: Document | ShadowRoot,\n): listenerHandler {\n  let hostId: number | null = null;\n  // host of adoptedStyleSheets is outermost document or IFrame's document\n  if (host.nodeName === '#document') hostId = mirror.getId(host);\n  // The host is a ShadowRoot.\n  else hostId = mirror.getId((host as ShadowRoot).host);\n\n  const patchTarget =\n    host.nodeName === '#document'\n      ? (host as Document).defaultView?.Document\n      : host.ownerDocument?.defaultView?.ShadowRoot;\n  const originalPropertyDescriptor = patchTarget?.prototype\n    ? Object.getOwnPropertyDescriptor(\n        patchTarget?.prototype,\n        'adoptedStyleSheets',\n      )\n    : undefined;\n  if (\n    hostId === null ||\n    hostId === -1 ||\n    !patchTarget ||\n    !originalPropertyDescriptor\n  )\n    return () => {\n      //\n    };\n\n  // Patch adoptedStyleSheets by overriding the original one.\n  Object.defineProperty(host, 'adoptedStyleSheets', {\n    configurable: originalPropertyDescriptor.configurable,\n    enumerable: originalPropertyDescriptor.enumerable,\n    get(): CSSStyleSheet[] {\n      return originalPropertyDescriptor.get?.call(this) as CSSStyleSheet[];\n    },\n    set(sheets: CSSStyleSheet[]) {\n      const result = originalPropertyDescriptor.set?.call(this, sheets);\n      if (hostId !== null && hostId !== -1) {\n        try {\n          stylesheetManager.adoptStyleSheets(sheets, hostId);\n        } catch (e) {\n          // for safety\n        }\n      }\n      return result;\n    },\n  });\n\n  return callbackWrapper(() => {\n    Object.defineProperty(host, 'adoptedStyleSheets', {\n      configurable: originalPropertyDescriptor.configurable,\n      enumerable: originalPropertyDescriptor.enumerable,\n      // eslint-disable-next-line @typescript-eslint/unbound-method\n      get: originalPropertyDescriptor.get,\n      // eslint-disable-next-line @typescript-eslint/unbound-method\n      set: originalPropertyDescriptor.set,\n    });\n  });\n}\n\nfunction initStyleDeclarationObserver(\n  {\n    styleDeclarationCb,\n    mirror,\n    ignoreCSSAttributes,\n    stylesheetManager,\n  }: observerParam,\n  { win }: { win: IWindow },\n): listenerHandler {\n  // eslint-disable-next-line @typescript-eslint/unbound-method\n  const setProperty = win.CSSStyleDeclaration.prototype.setProperty;\n  win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {\n    apply: callbackWrapper(\n      (\n        target: typeof setProperty,\n        thisArg: CSSStyleDeclaration,\n        argumentsList: [string, string, string],\n      ) => {\n        const [property, value, priority] = argumentsList;\n\n        // ignore this mutation if we do not care about this css attribute\n        if (ignoreCSSAttributes.has(property)) {\n          return setProperty.apply(thisArg, [property, value, priority]);\n        }\n        const { id, styleId } = getIdAndStyleId(\n          thisArg.parentRule?.parentStyleSheet,\n          mirror,\n          stylesheetManager.styleMirror,\n        );\n        if ((id && id !== -1) || (styleId && styleId !== -1)) {\n          styleDeclarationCb({\n            id,\n            styleId,\n            set: {\n              property,\n              value,\n              priority,\n            },\n            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n            index: getNestedCSSRulePositions(thisArg.parentRule!),\n          });\n        }\n        return target.apply(thisArg, argumentsList);\n      },\n    ),\n  });\n\n  // eslint-disable-next-line @typescript-eslint/unbound-method\n  const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;\n  win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {\n    apply: callbackWrapper(\n      (\n        target: typeof removeProperty,\n        thisArg: CSSStyleDeclaration,\n        argumentsList: [string],\n      ) => {\n        const [property] = argumentsList;\n\n        // ignore this mutation if we do not care about this css attribute\n        if (ignoreCSSAttributes.has(property)) {\n          return removeProperty.apply(thisArg, [property]);\n        }\n        const { id, styleId } = getIdAndStyleId(\n          thisArg.parentRule?.parentStyleSheet,\n          mirror,\n          stylesheetManager.styleMirror,\n        );\n        if ((id && id !== -1) || (styleId && styleId !== -1)) {\n          styleDeclarationCb({\n            id,\n            styleId,\n            remove: {\n              property,\n            },\n            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n            index: getNestedCSSRulePositions(thisArg.parentRule!),\n          });\n        }\n        return target.apply(thisArg, argumentsList);\n      },\n    ),\n  });\n\n  return callbackWrapper(() => {\n    win.CSSStyleDeclaration.prototype.setProperty = setProperty;\n    win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;\n  });\n}\n\nfunction initMediaInteractionObserver({\n  mediaInteractionCb,\n  blockClass,\n  blockSelector,\n  unblockSelector,\n  mirror,\n  sampling,\n  doc,\n}: observerParam): listenerHandler {\n  const handler = callbackWrapper((type: MediaInteractions) =>\n    throttle(\n      callbackWrapper((event: Event) => {\n        const target = getEventTarget(event);\n        if (\n          !target ||\n          isBlocked(\n            target as Node,\n            blockClass,\n            blockSelector,\n            unblockSelector,\n            true,\n          )\n        ) {\n          return;\n        }\n        const { currentTime, volume, muted, playbackRate } =\n          target as HTMLMediaElement;\n        mediaInteractionCb({\n          type,\n          id: mirror.getId(target as Node),\n          currentTime,\n          volume,\n          muted,\n          playbackRate,\n        });\n      }),\n      sampling.media || 500,\n    ),\n  );\n  const handlers = [\n    on('play', handler(MediaInteractions.Play), doc),\n    on('pause', handler(MediaInteractions.Pause), doc),\n    on('seeked', handler(MediaInteractions.Seeked), doc),\n    on('volumechange', handler(MediaInteractions.VolumeChange), doc),\n    on('ratechange', handler(MediaInteractions.RateChange), doc),\n  ];\n  return callbackWrapper(() => {\n    handlers.forEach((h) => h());\n  });\n}\n\nfunction initFontObserver({ fontCb, doc }: observerParam): listenerHandler {\n  const win = doc.defaultView as IWindow;\n  if (!win) {\n    return () => {\n      //\n    };\n  }\n\n  const handlers: listenerHandler[] = [];\n\n  const fontMap = new WeakMap<FontFace, fontParam>();\n\n  const originalFontFace = win.FontFace;\n  win.FontFace = function FontFace(\n    family: string,\n    source: string | ArrayBufferLike,\n    descriptors?: FontFaceDescriptors,\n  ) {\n    const fontFace = new originalFontFace(family, source, descriptors);\n    fontMap.set(fontFace, {\n      family,\n      buffer: typeof source !== 'string',\n      descriptors,\n      fontSource:\n        typeof source === 'string'\n          ? source\n          : JSON.stringify(Array.from(new Uint8Array(source))),\n    });\n    return fontFace;\n  } as unknown as typeof FontFace;\n\n  const restoreHandler = patch(\n    doc.fonts,\n    'add',\n    function (original: (font: FontFace) => void) {\n      return function (this: FontFaceSet, fontFace: FontFace) {\n        setTimeout(\n          callbackWrapper(() => {\n            const p = fontMap.get(fontFace);\n            if (p) {\n              fontCb(p);\n              fontMap.delete(fontFace);\n            }\n          }),\n          0,\n        );\n        return original.apply(this, [fontFace]);\n      };\n    },\n  );\n\n  handlers.push(() => {\n    win.FontFace = originalFontFace;\n  });\n  handlers.push(restoreHandler);\n\n  return callbackWrapper(() => {\n    handlers.forEach((h) => h());\n  });\n}\n\nfunction initSelectionObserver(param: observerParam): listenerHandler {\n  const {\n    doc,\n    mirror,\n    blockClass,\n    blockSelector,\n    unblockSelector,\n    selectionCb,\n  } = param;\n  let collapsed = true;\n\n  const updateSelection = callbackWrapper(() => {\n    const selection = doc.getSelection();\n\n    if (!selection || (collapsed && selection?.isCollapsed)) return;\n\n    collapsed = selection.isCollapsed || false;\n\n    const ranges: SelectionRange[] = [];\n    const count = selection.rangeCount || 0;\n\n    for (let i = 0; i < count; i++) {\n      const range = selection.getRangeAt(i);\n\n      const { startContainer, startOffset, endContainer, endOffset } = range;\n\n      const blocked =\n        isBlocked(\n          startContainer,\n          blockClass,\n          blockSelector,\n          unblockSelector,\n          true,\n        ) ||\n        isBlocked(\n          endContainer,\n          blockClass,\n          blockSelector,\n          unblockSelector,\n          true,\n        );\n\n      if (blocked) continue;\n\n      ranges.push({\n        start: mirror.getId(startContainer),\n        startOffset,\n        end: mirror.getId(endContainer),\n        endOffset,\n      });\n    }\n\n    selectionCb({ ranges });\n  });\n\n  updateSelection();\n\n  return on('selectionchange', updateSelection);\n}\n\nfunction initCustomElementObserver({\n  doc,\n  customElementCb,\n}: observerParam): listenerHandler {\n  const win = doc.defaultView as IWindow;\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  if (!win || !win.customElements) return () => {};\n  const restoreHandler = patch(\n    win.customElements,\n    'define',\n    function (\n      original: (\n        name: string,\n        constructor: CustomElementConstructor,\n        options?: ElementDefinitionOptions,\n      ) => void,\n    ) {\n      return function (\n        name: string,\n        constructor: CustomElementConstructor,\n        options?: ElementDefinitionOptions,\n      ) {\n        try {\n          customElementCb({\n            define: {\n              name,\n            },\n          });\n        } catch (e) {\n          // do nothing\n        }\n        return original.apply(this, [name, constructor, options]);\n      };\n    },\n  );\n  return restoreHandler;\n}\n\nexport function initObservers(\n  o: observerParam,\n  _hooks: hooksParam = {},\n): listenerHandler {\n  const currentWindow = o.doc.defaultView; // basically document.window\n  if (!currentWindow) {\n    return () => {\n      //\n    };\n  }\n\n  // Sentry: We do not use hooks, so we skip this\n  // mergeHooks(o, hooks);\n  let mutationObserver: MutationObserver | undefined;\n  if (o.recordDOM) {\n    mutationObserver = initMutationObserver(o, o.doc);\n  }\n  const mousemoveHandler = initMoveObserver(o);\n  const mouseInteractionHandler = initMouseInteractionObserver(o);\n  const scrollHandler = initScrollObserver(o);\n  const viewportResizeHandler = initViewportResizeObserver(o, {\n    win: currentWindow,\n  });\n  const inputHandler = initInputObserver(o);\n  const mediaInteractionHandler = initMediaInteractionObserver(o);\n\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  let styleSheetObserver = () => {};\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  let adoptedStyleSheetObserver = () => {};\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  let styleDeclarationObserver = () => {};\n  // eslint-disable-next-line @typescript-eslint/no-empty-function\n  let fontObserver = () => {};\n  if (o.recordDOM) {\n    styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });\n    adoptedStyleSheetObserver = initAdoptedStyleSheetObserver(o, o.doc);\n    styleDeclarationObserver = initStyleDeclarationObserver(o, {\n      win: currentWindow,\n    });\n    if (o.collectFonts) {\n      fontObserver = initFontObserver(o);\n    }\n  }\n  const selectionObserver = initSelectionObserver(o);\n  const customElementObserver = initCustomElementObserver(o);\n\n  // plugins\n  const pluginHandlers: listenerHandler[] = [];\n  for (const plugin of o.plugins) {\n    pluginHandlers.push(\n      plugin.observer(plugin.callback, currentWindow, plugin.options),\n    );\n  }\n\n  return callbackWrapper(() => {\n    mutationBuffers.forEach((b) => b.reset());\n    mutationObserver?.disconnect();\n    mousemoveHandler();\n    mouseInteractionHandler();\n    scrollHandler();\n    viewportResizeHandler();\n    inputHandler();\n    mediaInteractionHandler();\n    styleSheetObserver();\n    adoptedStyleSheetObserver();\n    styleDeclarationObserver();\n    fontObserver();\n    selectionObserver();\n    customElementObserver();\n    pluginHandlers.forEach((h) => h());\n  });\n}\n\ntype CSSGroupingProp =\n  | 'CSSGroupingRule'\n  | 'CSSMediaRule'\n  | 'CSSSupportsRule'\n  | 'CSSConditionRule';\n\nfunction hasNestedCSSRule(prop: CSSGroupingProp): boolean {\n  return typeof window[prop] !== 'undefined';\n}\n\nfunction canMonkeyPatchNestedCSSRule(prop: CSSGroupingProp): boolean {\n  return Boolean(\n    typeof window[prop] !== 'undefined' &&\n      // Note: Generally, this check _shouldn't_ be necessary\n      // However, in some scenarios (e.g. jsdom) this can sometimes fail, so we check for it here\n      window[prop].prototype &&\n      'insertRule' in window[prop].prototype &&\n      'deleteRule' in window[prop].prototype,\n  );\n}\n","import type { ICrossOriginIframeMirror } from '@sentry-internal/rrweb-types';\nexport default class CrossOriginIframeMirror\n  implements ICrossOriginIframeMirror\n{\n  private iframeIdToRemoteIdMap: WeakMap<\n    HTMLIFrameElement,\n    Map<number, number>\n  > = new WeakMap();\n  private iframeRemoteIdToIdMap: WeakMap<\n    HTMLIFrameElement,\n    Map<number, number>\n  > = new WeakMap();\n\n  constructor(private generateIdFn: () => number) {}\n\n  getId(\n    iframe: HTMLIFrameElement,\n    remoteId: number,\n    idToRemoteMap?: Map<number, number>,\n    remoteToIdMap?: Map<number, number>,\n  ): number {\n    const idToRemoteIdMap = idToRemoteMap || this.getIdToRemoteIdMap(iframe);\n    const remoteIdToIdMap = remoteToIdMap || this.getRemoteIdToIdMap(iframe);\n\n    let id = idToRemoteIdMap.get(remoteId);\n    if (!id) {\n      id = this.generateIdFn();\n      idToRemoteIdMap.set(remoteId, id);\n      remoteIdToIdMap.set(id, remoteId);\n    }\n    return id;\n  }\n\n  getIds(iframe: HTMLIFrameElement, remoteId: number[]): number[] {\n    const idToRemoteIdMap = this.getIdToRemoteIdMap(iframe);\n    const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);\n    return remoteId.map((id) =>\n      this.getId(iframe, id, idToRemoteIdMap, remoteIdToIdMap),\n    );\n  }\n\n  getRemoteId(\n    iframe: HTMLIFrameElement,\n    id: number,\n    map?: Map<number, number>,\n  ): number {\n    const remoteIdToIdMap = map || this.getRemoteIdToIdMap(iframe);\n\n    if (typeof id !== 'number') return id;\n\n    const remoteId = remoteIdToIdMap.get(id);\n    if (!remoteId) return -1;\n    return remoteId;\n  }\n\n  getRemoteIds(iframe: HTMLIFrameElement, ids: number[]): number[] {\n    const remoteIdToIdMap = this.getRemoteIdToIdMap(iframe);\n\n    return ids.map((id) => this.getRemoteId(iframe, id, remoteIdToIdMap));\n  }\n\n  reset(iframe?: HTMLIFrameElement) {\n    if (!iframe) {\n      this.iframeIdToRemoteIdMap = new WeakMap();\n      this.iframeRemoteIdToIdMap = new WeakMap();\n      return;\n    }\n    this.iframeIdToRemoteIdMap.delete(iframe);\n    this.iframeRemoteIdToIdMap.delete(iframe);\n  }\n\n  private getIdToRemoteIdMap(iframe: HTMLIFrameElement) {\n    let idToRemoteIdMap = this.iframeIdToRemoteIdMap.get(iframe);\n    if (!idToRemoteIdMap) {\n      idToRemoteIdMap = new Map();\n      this.iframeIdToRemoteIdMap.set(iframe, idToRemoteIdMap);\n    }\n    return idToRemoteIdMap;\n  }\n\n  private getRemoteIdToIdMap(iframe: HTMLIFrameElement) {\n    let remoteIdToIdMap = this.iframeRemoteIdToIdMap.get(iframe);\n    if (!remoteIdToIdMap) {\n      remoteIdToIdMap = new Map();\n      this.iframeRemoteIdToIdMap.set(iframe, remoteIdToIdMap);\n    }\n    return remoteIdToIdMap;\n  }\n}\n","import type {\n  Mirror,\n  serializedNodeWithId,\n} from '@sentry-internal/rrweb-snapshot';\nimport { genId, NodeType } from '@sentry-internal/rrweb-snapshot';\nimport type { CrossOriginIframeMessageEvent } from '../types';\nimport CrossOriginIframeMirror from './cross-origin-iframe-mirror';\nimport { EventType, IncrementalSource } from '@sentry-internal/rrweb-types';\nimport type {\n  eventWithTime,\n  eventWithoutTime,\n  mutationCallBack,\n} from '@sentry-internal/rrweb-types';\nimport type { StylesheetManager } from './stylesheet-manager';\nimport {\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n} from '@sentry-internal/rrdom';\n\nexport interface IframeManagerInterface {\n  crossOriginIframeMirror: CrossOriginIframeMirror;\n  crossOriginIframeStyleMirror: CrossOriginIframeMirror;\n  crossOriginIframeRootIdMap: WeakMap<HTMLIFrameElement, number>;\n\n  addIframe(iframeEl: HTMLIFrameElement): void;\n  addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown): void;\n  attachIframe(\n    iframeEl: HTMLIFrameElement,\n    childSn: serializedNodeWithId,\n  ): void;\n}\n\nexport class IframeManagerNoop implements IframeManagerInterface {\n  public crossOriginIframeMirror = new CrossOriginIframeMirror(genId);\n  public crossOriginIframeStyleMirror: CrossOriginIframeMirror;\n  public crossOriginIframeRootIdMap: WeakMap<HTMLIFrameElement, number> =\n    new WeakMap();\n\n  public addIframe() {\n    // noop\n  }\n  public addLoadListener() {\n    // noop\n  }\n  public attachIframe() {\n    // noop\n  }\n}\n\nexport class IframeManager implements IframeManagerInterface {\n  private iframes: WeakMap<HTMLIFrameElement, true> = new WeakMap();\n  private crossOriginIframeMap: WeakMap<MessageEventSource, HTMLIFrameElement> =\n    new WeakMap();\n  public crossOriginIframeMirror = new CrossOriginIframeMirror(genId);\n  public crossOriginIframeStyleMirror: CrossOriginIframeMirror;\n  public crossOriginIframeRootIdMap: WeakMap<HTMLIFrameElement, number> =\n    new WeakMap();\n  private mirror: Mirror;\n  private mutationCb: mutationCallBack;\n  private wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;\n  private loadListener?: (iframeEl: HTMLIFrameElement) => unknown;\n  private stylesheetManager: StylesheetManager;\n  private recordCrossOriginIframes: boolean;\n\n  constructor(options: {\n    mirror: Mirror;\n    mutationCb: mutationCallBack;\n    stylesheetManager: StylesheetManager;\n    recordCrossOriginIframes: boolean;\n    wrappedEmit: (e: eventWithoutTime, isCheckout?: boolean) => void;\n  }) {\n    this.mutationCb = options.mutationCb;\n    this.wrappedEmit = options.wrappedEmit;\n    this.stylesheetManager = options.stylesheetManager;\n    this.recordCrossOriginIframes = options.recordCrossOriginIframes;\n    this.crossOriginIframeStyleMirror = new CrossOriginIframeMirror(\n      this.stylesheetManager.styleMirror.generateId.bind(\n        this.stylesheetManager.styleMirror,\n      ),\n    );\n    this.mirror = options.mirror;\n    if (this.recordCrossOriginIframes) {\n      window.addEventListener('message', this.handleMessage.bind(this));\n    }\n  }\n\n  public addIframe(iframeEl: HTMLIFrameElement) {\n    this.iframes.set(iframeEl, true);\n    const contentWindow = getIFrameContentWindow(iframeEl);\n    if (contentWindow) this.crossOriginIframeMap.set(contentWindow, iframeEl);\n  }\n\n  public addLoadListener(cb: (iframeEl: HTMLIFrameElement) => unknown) {\n    this.loadListener = cb;\n  }\n\n  public attachIframe(\n    iframeEl: HTMLIFrameElement,\n    childSn: serializedNodeWithId,\n  ) {\n    this.mutationCb({\n      adds: [\n        {\n          parentId: this.mirror.getId(iframeEl),\n          nextId: null,\n          node: childSn,\n        },\n      ],\n      removes: [],\n      texts: [],\n      attributes: [],\n      isAttachIframe: true,\n    });\n\n    // Receive messages (events) coming from cross-origin iframes that are nested in this same-origin iframe.\n    if (this.recordCrossOriginIframes) {\n      getIFrameContentWindow(iframeEl)?.addEventListener(\n        'message',\n        this.handleMessage.bind(this),\n      );\n    }\n\n    this.loadListener?.(iframeEl);\n\n    const iframeDoc = getIFrameContentDocument(iframeEl);\n\n    if (\n      iframeDoc &&\n      iframeDoc.adoptedStyleSheets &&\n      iframeDoc.adoptedStyleSheets.length > 0\n    )\n      this.stylesheetManager.adoptStyleSheets(\n        iframeDoc.adoptedStyleSheets,\n        this.mirror.getId(iframeDoc),\n      );\n  }\n  private handleMessage(message: MessageEvent | CrossOriginIframeMessageEvent) {\n    const crossOriginMessageEvent = message as CrossOriginIframeMessageEvent;\n    if (\n      crossOriginMessageEvent.data.type !== 'rrweb' ||\n      // To filter out the rrweb messages which are forwarded by some sites.\n      crossOriginMessageEvent.origin !== crossOriginMessageEvent.data.origin\n    )\n      return;\n\n    const iframeSourceWindow = message.source;\n    if (!iframeSourceWindow) return;\n\n    const iframeEl = this.crossOriginIframeMap.get(message.source);\n    if (!iframeEl) return;\n\n    const transformedEvent = this.transformCrossOriginEvent(\n      iframeEl,\n      crossOriginMessageEvent.data.event,\n    );\n\n    if (transformedEvent)\n      this.wrappedEmit(\n        transformedEvent,\n        crossOriginMessageEvent.data.isCheckout,\n      );\n  }\n\n  private transformCrossOriginEvent(\n    iframeEl: HTMLIFrameElement,\n    e: eventWithTime,\n  ): eventWithTime | false {\n    switch (e.type) {\n      case EventType.FullSnapshot: {\n        this.crossOriginIframeMirror.reset(iframeEl);\n        this.crossOriginIframeStyleMirror.reset(iframeEl);\n        /**\n         * Replaces the original id of the iframe with a new set of unique ids\n         */\n        this.replaceIdOnNode(e.data.node, iframeEl);\n        const rootId = e.data.node.id;\n        this.crossOriginIframeRootIdMap.set(iframeEl, rootId);\n        this.patchRootIdOnNode(e.data.node, rootId);\n        return {\n          timestamp: e.timestamp,\n          type: EventType.IncrementalSnapshot,\n          data: {\n            source: IncrementalSource.Mutation,\n            adds: [\n              {\n                parentId: this.mirror.getId(iframeEl),\n                nextId: null,\n                node: e.data.node,\n              },\n            ],\n            removes: [],\n            texts: [],\n            attributes: [],\n            isAttachIframe: true,\n          },\n        };\n      }\n      case EventType.Meta:\n      case EventType.Load:\n      case EventType.DomContentLoaded: {\n        return false;\n      }\n      case EventType.Plugin: {\n        return e;\n      }\n      case EventType.Custom: {\n        this.replaceIds(\n          e.data.payload as {\n            id?: unknown;\n            parentId?: unknown;\n            previousId?: unknown;\n            nextId?: unknown;\n          },\n          iframeEl,\n          ['id', 'parentId', 'previousId', 'nextId'],\n        );\n        return e;\n      }\n      case EventType.IncrementalSnapshot: {\n        switch (e.data.source) {\n          case IncrementalSource.Mutation: {\n            e.data.adds.forEach((n) => {\n              this.replaceIds(n, iframeEl, [\n                'parentId',\n                'nextId',\n                'previousId',\n              ]);\n              this.replaceIdOnNode(n.node, iframeEl);\n              const rootId = this.crossOriginIframeRootIdMap.get(iframeEl);\n              rootId && this.patchRootIdOnNode(n.node, rootId);\n            });\n            e.data.removes.forEach((n) => {\n              this.replaceIds(n, iframeEl, ['parentId', 'id']);\n            });\n            e.data.attributes.forEach((n) => {\n              this.replaceIds(n, iframeEl, ['id']);\n            });\n            e.data.texts.forEach((n) => {\n              this.replaceIds(n, iframeEl, ['id']);\n            });\n            return e;\n          }\n          case IncrementalSource.Drag:\n          case IncrementalSource.TouchMove:\n          case IncrementalSource.MouseMove: {\n            e.data.positions.forEach((p) => {\n              this.replaceIds(p, iframeEl, ['id']);\n            });\n            return e;\n          }\n          case IncrementalSource.ViewportResize: {\n            // can safely ignore these events\n            return false;\n          }\n          case IncrementalSource.MediaInteraction:\n          case IncrementalSource.MouseInteraction:\n          case IncrementalSource.Scroll:\n          case IncrementalSource.CanvasMutation:\n          case IncrementalSource.Input: {\n            this.replaceIds(e.data, iframeEl, ['id']);\n            return e;\n          }\n          case IncrementalSource.StyleSheetRule:\n          case IncrementalSource.StyleDeclaration: {\n            this.replaceIds(e.data, iframeEl, ['id']);\n            this.replaceStyleIds(e.data, iframeEl, ['styleId']);\n            return e;\n          }\n          case IncrementalSource.Font: {\n            // fine as-is no modification needed\n            return e;\n          }\n          case IncrementalSource.Selection: {\n            e.data.ranges.forEach((range) => {\n              this.replaceIds(range, iframeEl, ['start', 'end']);\n            });\n            return e;\n          }\n          case IncrementalSource.AdoptedStyleSheet: {\n            this.replaceIds(e.data, iframeEl, ['id']);\n            this.replaceStyleIds(e.data, iframeEl, ['styleIds']);\n            e.data.styles?.forEach((style) => {\n              this.replaceStyleIds(style, iframeEl, ['styleId']);\n            });\n            return e;\n          }\n        }\n      }\n    }\n    return false;\n  }\n\n  private replace<T extends Record<string, unknown>>(\n    iframeMirror: CrossOriginIframeMirror,\n    obj: T,\n    iframeEl: HTMLIFrameElement,\n    keys: Array<keyof T>,\n  ): T {\n    for (const key of keys) {\n      if (!Array.isArray(obj[key]) && typeof obj[key] !== 'number') continue;\n      if (Array.isArray(obj[key])) {\n        obj[key] = iframeMirror.getIds(\n          iframeEl,\n          obj[key] as number[],\n        ) as T[keyof T];\n      } else {\n        (obj[key] as number) = iframeMirror.getId(iframeEl, obj[key] as number);\n      }\n    }\n\n    return obj;\n  }\n\n  private replaceIds<T extends Record<string, unknown>>(\n    obj: T,\n    iframeEl: HTMLIFrameElement,\n    keys: Array<keyof T>,\n  ): T {\n    return this.replace(this.crossOriginIframeMirror, obj, iframeEl, keys);\n  }\n\n  private replaceStyleIds<T extends Record<string, unknown>>(\n    obj: T,\n    iframeEl: HTMLIFrameElement,\n    keys: Array<keyof T>,\n  ): T {\n    return this.replace(this.crossOriginIframeStyleMirror, obj, iframeEl, keys);\n  }\n\n  private replaceIdOnNode(\n    node: serializedNodeWithId,\n    iframeEl: HTMLIFrameElement,\n  ) {\n    this.replaceIds(node, iframeEl, ['id', 'rootId']);\n    if ('childNodes' in node) {\n      node.childNodes.forEach((child) => {\n        this.replaceIdOnNode(child, iframeEl);\n      });\n    }\n  }\n\n  private patchRootIdOnNode(node: serializedNodeWithId, rootId: number) {\n    if (node.type !== NodeType.Document && !node.rootId) node.rootId = rootId;\n    if ('childNodes' in node) {\n      node.childNodes.forEach((child) => {\n        this.patchRootIdOnNode(child, rootId);\n      });\n    }\n  }\n}\n","import type { MutationBufferParam } from '../types';\nimport type {\n  mutationCallBack,\n  scrollCallback,\n  SamplingStrategy,\n} from '@sentry-internal/rrweb-types';\nimport {\n  initMutationObserver,\n  initScrollObserver,\n  initAdoptedStyleSheetObserver,\n} from './observer';\nimport { patch, inDom, setTimeout } from '../utils';\nimport type { Mirror } from '@sentry-internal/rrweb-snapshot';\nimport { isNativeShadowDom } from '@sentry-internal/rrweb-snapshot';\nimport {\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n} from '@sentry-internal/rrdom';\n\ntype BypassOptions = Omit<\n  MutationBufferParam,\n  'doc' | 'mutationCb' | 'mirror' | 'shadowDomManager'\n> & {\n  sampling: SamplingStrategy;\n};\n\nexport interface ShadowDomManagerInterface {\n  init(): void;\n  addShadowRoot(shadowRoot: ShadowRoot, doc: Document): void;\n  observeAttachShadow(iframeElement: HTMLIFrameElement): void;\n  reset(): void;\n}\n\nexport class ShadowDomManagerNoop implements ShadowDomManagerInterface {\n  public init() {\n    // noop\n  }\n  public addShadowRoot() {\n    // noop\n  }\n  public observeAttachShadow() {\n    // noop\n  }\n  public reset() {\n    // noop\n  }\n}\n\nexport class ShadowDomManager implements ShadowDomManagerInterface {\n  private shadowDoms = new WeakSet<ShadowRoot>();\n  private mutationCb: mutationCallBack;\n  private scrollCb: scrollCallback;\n  private bypassOptions: BypassOptions;\n  private mirror: Mirror;\n  private restoreHandlers: (() => void)[] = [];\n\n  constructor(options: {\n    mutationCb: mutationCallBack;\n    scrollCb: scrollCallback;\n    bypassOptions: BypassOptions;\n    mirror: Mirror;\n  }) {\n    this.mutationCb = options.mutationCb;\n    this.scrollCb = options.scrollCb;\n    this.bypassOptions = options.bypassOptions;\n    this.mirror = options.mirror;\n\n    this.init();\n  }\n\n  public init() {\n    this.reset();\n    // Patch 'attachShadow' to observe newly added shadow doms.\n    this.patchAttachShadow(Element, document);\n  }\n\n  public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {\n    if (!isNativeShadowDom(shadowRoot)) return;\n    if (this.shadowDoms.has(shadowRoot)) return;\n    this.shadowDoms.add(shadowRoot);\n    this.bypassOptions.canvasManager.addShadowRoot(shadowRoot);\n    const observer = initMutationObserver(\n      {\n        ...this.bypassOptions,\n        doc,\n        mutationCb: this.mutationCb,\n        mirror: this.mirror,\n        shadowDomManager: this,\n      },\n      shadowRoot,\n    );\n    this.restoreHandlers.push(() => observer.disconnect());\n    this.restoreHandlers.push(\n      initScrollObserver({\n        ...this.bypassOptions,\n        scrollCb: this.scrollCb,\n        // https://gist.github.com/praveenpuglia/0832da687ed5a5d7a0907046c9ef1813\n        // scroll is not allowed to pass the boundary, so we need to listen the shadow document\n        doc: shadowRoot as unknown as Document,\n        mirror: this.mirror,\n      }),\n    );\n    // Defer this to avoid adoptedStyleSheet events being created before the full snapshot is created or attachShadow action is recorded.\n    setTimeout(() => {\n      if (\n        shadowRoot.adoptedStyleSheets &&\n        shadowRoot.adoptedStyleSheets.length > 0\n      )\n        this.bypassOptions.stylesheetManager.adoptStyleSheets(\n          shadowRoot.adoptedStyleSheets,\n          this.mirror.getId(shadowRoot.host),\n        );\n      this.restoreHandlers.push(\n        initAdoptedStyleSheetObserver(\n          {\n            mirror: this.mirror,\n            stylesheetManager: this.bypassOptions.stylesheetManager,\n          },\n          shadowRoot,\n        ),\n      );\n    }, 0);\n  }\n\n  /**\n   * Monkey patch 'attachShadow' of an IFrameElement to observe newly added shadow doms.\n   */\n  public observeAttachShadow(iframeElement: HTMLIFrameElement) {\n    const iframeDoc = getIFrameContentDocument(iframeElement);\n    const iframeWindow = getIFrameContentWindow(iframeElement);\n    if (!iframeDoc || !iframeWindow) return;\n    this.patchAttachShadow(\n      (\n        iframeWindow as Window & {\n          Element: { prototype: Element };\n        }\n      ).Element,\n      iframeDoc,\n    );\n  }\n\n  /**\n   * Patch 'attachShadow' to observe newly added shadow doms.\n   */\n  private patchAttachShadow(\n    element: {\n      prototype: Element;\n    },\n    doc: Document,\n  ) {\n    // eslint-disable-next-line @typescript-eslint/no-this-alias\n    const manager = this;\n    this.restoreHandlers.push(\n      patch(\n        element.prototype,\n        'attachShadow',\n        function (original: (init: ShadowRootInit) => ShadowRoot) {\n          return function (this: Element, option: ShadowRootInit) {\n            const shadowRoot = original.call(this, option);\n            // For the shadow dom elements in the document, monitor their dom mutations.\n            // For shadow dom elements that aren't in the document yet,\n            // we start monitoring them once their shadow dom host is appended to the document.\n            if (this.shadowRoot && inDom(this))\n              manager.addShadowRoot(this.shadowRoot, doc);\n            return shadowRoot;\n          };\n        },\n      ),\n    );\n  }\n\n  public reset() {\n    this.restoreHandlers.forEach((handler) => {\n      try {\n        handler();\n      } catch (e) {\n        //\n      }\n    });\n    this.restoreHandlers = [];\n    this.shadowDoms = new WeakSet();\n    this.bypassOptions.canvasManager.resetShadowRoots();\n  }\n}\n","import type {\n  elementNode,\n  serializedNodeWithId,\n} from '@sentry-internal/rrweb-snapshot';\nimport { stringifyRule } from '@sentry-internal/rrweb-snapshot';\nimport type {\n  adoptedStyleSheetCallback,\n  adoptedStyleSheetParam,\n  attributeMutation,\n  mutationCallBack,\n} from '@sentry-internal/rrweb-types';\nimport { StyleSheetMirror } from '../utils';\n\nexport class StylesheetManager {\n  private trackedLinkElements: WeakSet<HTMLLinkElement> = new WeakSet();\n  private mutationCb: mutationCallBack;\n  private adoptedStyleSheetCb: adoptedStyleSheetCallback;\n  public styleMirror = new StyleSheetMirror();\n\n  constructor(options: {\n    mutationCb: mutationCallBack;\n    adoptedStyleSheetCb: adoptedStyleSheetCallback;\n  }) {\n    this.mutationCb = options.mutationCb;\n    this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;\n  }\n\n  public attachLinkElement(\n    linkEl: HTMLLinkElement,\n    childSn: serializedNodeWithId,\n  ) {\n    if ('_cssText' in (childSn as elementNode).attributes)\n      this.mutationCb({\n        adds: [],\n        removes: [],\n        texts: [],\n        attributes: [\n          {\n            id: childSn.id,\n            attributes: (childSn as elementNode)\n              .attributes as attributeMutation['attributes'],\n          },\n        ],\n      });\n\n    this.trackLinkElement(linkEl);\n  }\n\n  public trackLinkElement(linkEl: HTMLLinkElement) {\n    if (this.trackedLinkElements.has(linkEl)) return;\n\n    this.trackedLinkElements.add(linkEl);\n    this.trackStylesheetInLinkElement(linkEl);\n  }\n\n  public adoptStyleSheets(\n    sheets: CSSStyleSheet[] | readonly CSSStyleSheet[],\n    hostId: number,\n  ) {\n    if (sheets.length === 0) return;\n    const adoptedStyleSheetData: adoptedStyleSheetParam = {\n      id: hostId,\n      styleIds: [] as number[],\n    };\n    const styles: NonNullable<adoptedStyleSheetParam['styles']> = [];\n    for (const sheet of sheets) {\n      let styleId;\n      if (!this.styleMirror.has(sheet)) {\n        styleId = this.styleMirror.add(sheet);\n        styles.push({\n          styleId,\n          rules: Array.from(sheet.rules || CSSRule, (r, index) => ({\n            rule: stringifyRule(r),\n            index,\n          })),\n        });\n      } else styleId = this.styleMirror.getId(sheet);\n      adoptedStyleSheetData.styleIds.push(styleId);\n    }\n    if (styles.length > 0) adoptedStyleSheetData.styles = styles;\n    this.adoptedStyleSheetCb(adoptedStyleSheetData);\n  }\n\n  public reset() {\n    this.styleMirror.reset();\n    this.trackedLinkElements = new WeakSet();\n  }\n\n  // TODO: take snapshot on stylesheet reload by applying event listener\n  private trackStylesheetInLinkElement(_linkEl: HTMLLinkElement) {\n    // linkEl.addEventListener('load', () => {\n    //   // re-loaded, maybe take another snapshot?\n    // });\n  }\n}\n","import { onRequestAnimationFrame } from '../utils';\nimport type MutationBuffer from './mutation';\n\n/**\n * Keeps a log of nodes that could show up in multiple mutation buffer but shouldn't be handled twice.\n */\nexport default class ProcessedNodeManager {\n  private nodeMap: WeakMap<Node, Set<MutationBuffer>> = new WeakMap();\n\n  private active = false;\n\n  public inOtherBuffer(node: Node, thisBuffer: MutationBuffer) {\n    const buffers = this.nodeMap.get(node);\n    return (\n      buffers && Array.from(buffers).some((buffer) => buffer !== thisBuffer)\n    );\n  }\n\n  public add(node: Node, buffer: MutationBuffer) {\n    if (!this.active) {\n      this.active = true;\n      onRequestAnimationFrame(() => {\n        this.nodeMap = new WeakMap();\n        this.active = false;\n      });\n    }\n    this.nodeMap.set(node, (this.nodeMap.get(node) || new Set()).add(buffer));\n  }\n\n  public destroy() {\n    // cleanup no longer needed\n  }\n}\n","import {\n  snapshot,\n  MaskInputOptions,\n  SlimDOMOptions,\n  createMirror,\n} from '@sentry-internal/rrweb-snapshot';\nimport { getIFrameContentWindow } from '@sentry-internal/rrdom';\nimport { initObservers, mutationBuffers } from './observer';\nimport {\n  on,\n  getWindowWidth,\n  getWindowHeight,\n  getWindowScroll,\n  polyfill,\n  hasShadowRoot,\n  isSerializedIframe,\n  isSerializedStylesheet,\n  nowTimestamp,\n} from '../utils';\nimport type { recordOptions } from '../types';\nimport {\n  EventType,\n  eventWithoutTime,\n  eventWithTime,\n  IncrementalSource,\n  listenerHandler,\n  mutationCallbackParam,\n  scrollCallback,\n  canvasMutationParam,\n  adoptedStyleSheetParam,\n  IWindow,\n} from '@sentry-internal/rrweb-types';\nimport type { CrossOriginIframeMessageEventContent } from '../types';\nimport {\n  IframeManager,\n  IframeManagerInterface,\n  IframeManagerNoop,\n} from './iframe-manager';\nimport {\n  ShadowDomManager,\n  ShadowDomManagerInterface,\n  ShadowDomManagerNoop,\n} from './shadow-dom-manager';\nimport {\n  CanvasManagerConstructorOptions,\n  CanvasManagerInterface,\n  CanvasManagerNoop,\n} from './observers/canvas/canvas-manager';\nimport { StylesheetManager } from './stylesheet-manager';\nimport ProcessedNodeManager from './processed-node-manager';\nimport {\n  callbackWrapper,\n  registerErrorHandler,\n  unregisterErrorHandler,\n} from './error-handler';\nexport type { CanvasManagerConstructorOptions } from './observers/canvas/canvas-manager';\n\ndeclare global {\n  const __RRWEB_EXCLUDE_SHADOW_DOM__: boolean;\n  const __RRWEB_EXCLUDE_IFRAME__: boolean;\n}\n\nlet wrappedEmit!: (e: eventWithoutTime, isCheckout?: boolean) => void;\n\n// These are stored in module scope because we access them in other exported methods\nlet _wrappedEmit:\n  | undefined\n  | ((e: eventWithTime, isCheckout?: boolean) => void);\nlet _takeFullSnapshot: undefined | ((isCheckout?: boolean) => void);\n\n// Multiple tools (i.e. MooTools, Prototype.js) override Array.from and drop support for the 2nd parameter\n// Try to pull a clean implementation from a newly created iframe\ntry {\n  if (Array.from([1], (x) => x * 2)[0] !== 2) {\n    const cleanFrame = document.createElement('iframe');\n    document.body.appendChild(cleanFrame);\n    // eslint-disable-next-line @typescript-eslint/unbound-method -- Array.from is static and doesn't rely on binding\n    Array.from = cleanFrame.contentWindow?.Array.from || Array.from;\n    document.body.removeChild(cleanFrame);\n  }\n} catch (err) {\n  console.debug('Unable to override Array.from', err);\n}\n\nconst mirror = createMirror();\nfunction record<T = eventWithTime>(\n  options: recordOptions<T> = {},\n): listenerHandler | undefined {\n  const {\n    emit,\n    checkoutEveryNms,\n    checkoutEveryNth,\n    blockClass = 'rr-block',\n    blockSelector = null,\n    unblockSelector = null,\n    ignoreClass = 'rr-ignore',\n    ignoreSelector = null,\n    maskAllText = false,\n    maskTextClass = 'rr-mask',\n    unmaskTextClass = null,\n    maskTextSelector = null,\n    unmaskTextSelector = null,\n    inlineStylesheet = true,\n    maskAllInputs,\n    maskInputOptions: _maskInputOptions,\n    slimDOMOptions: _slimDOMOptions,\n    maskAttributeFn,\n    maskInputFn,\n    maskTextFn,\n    maxCanvasSize = null,\n    packFn,\n    sampling = {},\n    dataURLOptions = {},\n    mousemoveWait,\n    recordDOM = true,\n    recordCanvas = false,\n    recordCrossOriginIframes = false,\n    recordAfter = options.recordAfter === 'DOMContentLoaded'\n      ? options.recordAfter\n      : 'load',\n    userTriggeredOnInput = false,\n    collectFonts = false,\n    inlineImages = false,\n    plugins,\n    keepIframeSrcFn = () => false,\n    ignoreCSSAttributes = new Set([]),\n    errorHandler,\n    onMutation,\n    getCanvasManager,\n  } = options;\n\n  registerErrorHandler(errorHandler);\n\n  const inEmittingFrame = recordCrossOriginIframes\n    ? window.parent === window\n    : true;\n\n  let passEmitsToParent = false;\n  if (!inEmittingFrame) {\n    try {\n      // throws if parent is cross-origin\n      if (window.parent.document) {\n        passEmitsToParent = false; // if parent is same origin we collect iframe events from the parent\n      }\n    } catch (e) {\n      passEmitsToParent = true;\n    }\n  }\n\n  // runtime checks for user options\n  if (inEmittingFrame && !emit) {\n    throw new Error('emit function is required');\n  }\n  if (!inEmittingFrame && !passEmitsToParent) {\n    return () => {\n      /* no-op since in this case we don't need to record anything from this frame in particular */\n    };\n  }\n  // move departed options to new options\n  if (mousemoveWait !== undefined && sampling.mousemove === undefined) {\n    sampling.mousemove = mousemoveWait;\n  }\n\n  // reset mirror in case `record` this was called earlier\n  mirror.reset();\n\n  const maskInputOptions: MaskInputOptions =\n    maskAllInputs === true\n      ? {\n          color: true,\n          date: true,\n          'datetime-local': true,\n          email: true,\n          month: true,\n          number: true,\n          range: true,\n          search: true,\n          tel: true,\n          text: true,\n          time: true,\n          url: true,\n          week: true,\n          textarea: true,\n          select: true,\n          radio: true,\n          checkbox: true,\n        }\n      : _maskInputOptions !== undefined\n      ? _maskInputOptions\n      : {};\n\n  const slimDOMOptions: SlimDOMOptions =\n    _slimDOMOptions === true || _slimDOMOptions === 'all'\n      ? {\n          script: true,\n          comment: true,\n          headFavicon: true,\n          headWhitespace: true,\n          headMetaSocial: true,\n          headMetaRobots: true,\n          headMetaHttpEquiv: true,\n          headMetaVerification: true,\n          // the following are off for slimDOMOptions === true,\n          // as they destroy some (hidden) info:\n          headMetaAuthorship: _slimDOMOptions === 'all',\n          headMetaDescKeywords: _slimDOMOptions === 'all',\n        }\n      : _slimDOMOptions\n      ? _slimDOMOptions\n      : {};\n\n  polyfill();\n\n  let lastFullSnapshotEvent: eventWithTime;\n  let incrementalSnapshotCount = 0;\n\n  const eventProcessor = (e: eventWithTime): T => {\n    for (const plugin of plugins || []) {\n      if (plugin.eventProcessor) {\n        e = plugin.eventProcessor(e);\n      }\n    }\n    if (\n      packFn &&\n      // Disable packing events which will be emitted to parent frames.\n      !passEmitsToParent\n    ) {\n      e = packFn(e) as unknown as eventWithTime;\n    }\n    return e as unknown as T;\n  };\n  wrappedEmit = (r: eventWithoutTime, isCheckout?: boolean) => {\n    const e = r as eventWithTime;\n    e.timestamp = nowTimestamp();\n    if (\n      mutationBuffers[0]?.isFrozen() &&\n      e.type !== EventType.FullSnapshot &&\n      !(\n        e.type === EventType.IncrementalSnapshot &&\n        e.data.source === IncrementalSource.Mutation\n      )\n    ) {\n      // we've got a user initiated event so first we need to apply\n      // all DOM changes that have been buffering during paused state\n      mutationBuffers.forEach((buf) => buf.unfreeze());\n    }\n\n    if (inEmittingFrame) {\n      emit?.(eventProcessor(e), isCheckout);\n    } else if (passEmitsToParent) {\n      const message: CrossOriginIframeMessageEventContent<T> = {\n        type: 'rrweb',\n        event: eventProcessor(e),\n        origin: window.location.origin,\n        isCheckout,\n      };\n      window.parent.postMessage(message, '*');\n    }\n\n    if (e.type === EventType.FullSnapshot) {\n      lastFullSnapshotEvent = e;\n      incrementalSnapshotCount = 0;\n    } else if (e.type === EventType.IncrementalSnapshot) {\n      // attach iframe should be considered as full snapshot\n      if (\n        e.data.source === IncrementalSource.Mutation &&\n        e.data.isAttachIframe\n      ) {\n        return;\n      }\n\n      incrementalSnapshotCount++;\n      const exceedCount =\n        checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;\n      const exceedTime =\n        checkoutEveryNms &&\n        lastFullSnapshotEvent &&\n        e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;\n      if (exceedCount || exceedTime) {\n        takeFullSnapshot(true);\n      }\n    }\n  };\n  _wrappedEmit = wrappedEmit;\n\n  const wrappedMutationEmit = (m: mutationCallbackParam) => {\n    wrappedEmit({\n      type: EventType.IncrementalSnapshot,\n      data: {\n        source: IncrementalSource.Mutation,\n        ...m,\n      },\n    });\n  };\n  const wrappedScrollEmit: scrollCallback = (p) =>\n    wrappedEmit({\n      type: EventType.IncrementalSnapshot,\n      data: {\n        source: IncrementalSource.Scroll,\n        ...p,\n      },\n    });\n  const wrappedCanvasMutationEmit = (p: canvasMutationParam) =>\n    wrappedEmit({\n      type: EventType.IncrementalSnapshot,\n      data: {\n        source: IncrementalSource.CanvasMutation,\n        ...p,\n      },\n    });\n\n  const wrappedAdoptedStyleSheetEmit = (a: adoptedStyleSheetParam) =>\n    wrappedEmit({\n      type: EventType.IncrementalSnapshot,\n      data: {\n        source: IncrementalSource.AdoptedStyleSheet,\n        ...a,\n      },\n    });\n\n  const stylesheetManager = new StylesheetManager({\n    mutationCb: wrappedMutationEmit,\n    adoptedStyleSheetCb: wrappedAdoptedStyleSheetEmit,\n  });\n\n  const iframeManager: IframeManagerInterface =\n    typeof __RRWEB_EXCLUDE_IFRAME__ === 'boolean' && __RRWEB_EXCLUDE_IFRAME__\n      ? new IframeManagerNoop()\n      : new IframeManager({\n          mirror,\n          mutationCb: wrappedMutationEmit,\n          stylesheetManager: stylesheetManager,\n          recordCrossOriginIframes,\n          wrappedEmit,\n        });\n\n  /**\n   * Exposes mirror to the plugins\n   */\n  for (const plugin of plugins || []) {\n    if (plugin.getMirror)\n      plugin.getMirror({\n        nodeMirror: mirror,\n        crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,\n        crossOriginIframeStyleMirror:\n          iframeManager.crossOriginIframeStyleMirror,\n      });\n  }\n\n  const processedNodeManager = new ProcessedNodeManager();\n\n  const canvasManager: CanvasManagerInterface = _getCanvasManager(\n    getCanvasManager,\n    {\n      mirror,\n      win: window,\n      mutationCb: (p: canvasMutationParam) =>\n        wrappedEmit({\n          type: EventType.IncrementalSnapshot,\n          data: {\n            source: IncrementalSource.CanvasMutation,\n            ...p,\n          },\n        }),\n      recordCanvas,\n      blockClass,\n      blockSelector,\n      unblockSelector,\n      maxCanvasSize,\n      sampling: sampling['canvas'],\n      dataURLOptions,\n      errorHandler,\n    },\n  );\n\n  const shadowDomManager: ShadowDomManagerInterface =\n    typeof __RRWEB_EXCLUDE_SHADOW_DOM__ === 'boolean' &&\n    __RRWEB_EXCLUDE_SHADOW_DOM__\n      ? new ShadowDomManagerNoop()\n      : new ShadowDomManager({\n          mutationCb: wrappedMutationEmit,\n          scrollCb: wrappedScrollEmit,\n          bypassOptions: {\n            onMutation,\n            blockClass,\n            blockSelector,\n            unblockSelector,\n            maskAllText,\n            maskTextClass,\n            unmaskTextClass,\n            maskTextSelector,\n            unmaskTextSelector,\n            inlineStylesheet,\n            maskInputOptions,\n            dataURLOptions,\n            maskAttributeFn,\n            maskTextFn,\n            maskInputFn,\n            recordCanvas,\n            inlineImages,\n            sampling,\n            slimDOMOptions,\n            iframeManager,\n            stylesheetManager,\n            canvasManager,\n            keepIframeSrcFn,\n            processedNodeManager,\n            ignoreCSSAttributes,\n          },\n          mirror,\n        });\n\n  const takeFullSnapshot = (isCheckout = false) => {\n    if (!recordDOM) {\n      return;\n    }\n    wrappedEmit(\n      {\n        type: EventType.Meta,\n        data: {\n          href: window.location.href,\n          width: getWindowWidth(),\n          height: getWindowHeight(),\n        },\n      },\n      isCheckout,\n    );\n\n    // When we take a full snapshot, old tracked StyleSheets need to be removed.\n    stylesheetManager.reset();\n\n    shadowDomManager.init();\n\n    mutationBuffers.forEach((buf) => buf.lock()); // don't allow any mirror modifications during snapshotting\n    const node = snapshot(document, {\n      mirror,\n      blockClass,\n      blockSelector,\n      unblockSelector,\n      maskAllText,\n      maskTextClass,\n      unmaskTextClass,\n      maskTextSelector,\n      unmaskTextSelector,\n      inlineStylesheet,\n      maskAllInputs: maskInputOptions,\n      maskAttributeFn,\n      maskInputFn,\n      maskTextFn,\n      slimDOM: slimDOMOptions,\n      dataURLOptions,\n      recordCanvas,\n      inlineImages,\n      onSerialize: (n) => {\n        if (isSerializedIframe(n, mirror)) {\n          iframeManager.addIframe(n as HTMLIFrameElement);\n        }\n        if (isSerializedStylesheet(n, mirror)) {\n          stylesheetManager.trackLinkElement(n as HTMLLinkElement);\n        }\n        if (hasShadowRoot(n)) {\n          shadowDomManager.addShadowRoot(n.shadowRoot, document);\n        }\n      },\n      onIframeLoad: (iframe, childSn) => {\n        iframeManager.attachIframe(iframe, childSn);\n        const contentWindow = getIFrameContentWindow(iframe);\n        if (contentWindow) {\n          canvasManager.addWindow(contentWindow as IWindow);\n        }\n        shadowDomManager.observeAttachShadow(iframe);\n      },\n      onStylesheetLoad: (linkEl, childSn) => {\n        stylesheetManager.attachLinkElement(linkEl, childSn);\n      },\n      onBlockedImageLoad: (_imageEl, serializedNode, { width, height }) => {\n        wrappedMutationEmit({\n          adds: [],\n          removes: [],\n          texts: [],\n          attributes: [\n            {\n              id: serializedNode.id,\n              attributes: {\n                style: {\n                  width: `${width}px`,\n                  height: `${height}px`,\n                },\n              },\n            },\n          ],\n        });\n      },\n      keepIframeSrcFn,\n      ignoreCSSAttributes,\n    });\n\n    if (!node) {\n      return console.warn('Failed to snapshot the document');\n    }\n\n    wrappedEmit({\n      type: EventType.FullSnapshot,\n      data: {\n        node,\n        initialOffset: getWindowScroll(window),\n      },\n    });\n    mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror\n\n    // Some old browsers don't support adoptedStyleSheets.\n    if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)\n      stylesheetManager.adoptStyleSheets(\n        document.adoptedStyleSheets,\n        mirror.getId(document),\n      );\n  };\n  _takeFullSnapshot = takeFullSnapshot;\n\n  try {\n    const handlers: listenerHandler[] = [];\n\n    const observe = (doc: Document) => {\n      return callbackWrapper(initObservers)(\n        {\n          onMutation,\n          mutationCb: wrappedMutationEmit,\n          mousemoveCb: (positions, source) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source,\n                positions,\n              },\n            }),\n          mouseInteractionCb: (d) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.MouseInteraction,\n                ...d,\n              },\n            }),\n          scrollCb: wrappedScrollEmit,\n          viewportResizeCb: (d) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.ViewportResize,\n                ...d,\n              },\n            }),\n          inputCb: (v) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.Input,\n                ...v,\n              },\n            }),\n          mediaInteractionCb: (p) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.MediaInteraction,\n                ...p,\n              },\n            }),\n          styleSheetRuleCb: (r) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.StyleSheetRule,\n                ...r,\n              },\n            }),\n          styleDeclarationCb: (r) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.StyleDeclaration,\n                ...r,\n              },\n            }),\n          canvasMutationCb: wrappedCanvasMutationEmit,\n          fontCb: (p) =>\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.Font,\n                ...p,\n              },\n            }),\n          selectionCb: (p) => {\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.Selection,\n                ...p,\n              },\n            });\n          },\n          customElementCb: (c) => {\n            wrappedEmit({\n              type: EventType.IncrementalSnapshot,\n              data: {\n                source: IncrementalSource.CustomElement,\n                ...c,\n              },\n            });\n          },\n          blockClass,\n          ignoreClass,\n          ignoreSelector,\n          maskAllText,\n          maskTextClass,\n          unmaskTextClass,\n          maskTextSelector,\n          unmaskTextSelector,\n          maskInputOptions,\n          inlineStylesheet,\n          sampling,\n          recordDOM,\n          recordCanvas,\n          inlineImages,\n          userTriggeredOnInput,\n          collectFonts,\n          doc,\n          maskAttributeFn,\n          maskInputFn,\n          maskTextFn,\n          keepIframeSrcFn,\n          blockSelector,\n          unblockSelector,\n          slimDOMOptions,\n          dataURLOptions,\n          mirror,\n          iframeManager,\n          stylesheetManager,\n          shadowDomManager,\n          processedNodeManager,\n          canvasManager,\n          ignoreCSSAttributes,\n          plugins:\n            plugins\n              ?.filter((p) => p.observer)\n              ?.map((p) => ({\n                observer: p.observer!,\n                options: p.options,\n                callback: (payload: object) =>\n                  wrappedEmit({\n                    type: EventType.Plugin,\n                    data: {\n                      plugin: p.name,\n                      payload,\n                    },\n                  }),\n              })) || [],\n        },\n        {},\n      );\n    };\n\n    iframeManager.addLoadListener((iframeEl) => {\n      try {\n        handlers.push(observe(iframeEl.contentDocument!));\n      } catch (error) {\n        // TODO: handle internal error\n        console.warn(error);\n      }\n    });\n\n    const init = () => {\n      takeFullSnapshot();\n      handlers.push(observe(document));\n    };\n    if (\n      document.readyState === 'interactive' ||\n      document.readyState === 'complete'\n    ) {\n      init();\n    } else {\n      handlers.push(\n        on('DOMContentLoaded', () => {\n          wrappedEmit({\n            type: EventType.DomContentLoaded,\n            data: {},\n          });\n          if (recordAfter === 'DOMContentLoaded') init();\n        }),\n      );\n      handlers.push(\n        on(\n          'load',\n          () => {\n            wrappedEmit({\n              type: EventType.Load,\n              data: {},\n            });\n            if (recordAfter === 'load') init();\n          },\n          window,\n        ),\n      );\n    }\n    return () => {\n      handlers.forEach((h) => h());\n      processedNodeManager.destroy();\n      _takeFullSnapshot = undefined;\n      unregisterErrorHandler();\n    };\n  } catch (error) {\n    // TODO: handle internal error\n    console.warn(error);\n  }\n}\n\nexport function addCustomEvent<T>(tag: string, payload: T) {\n  if (!_wrappedEmit) {\n    throw new Error('please add custom event after start recording');\n  }\n  wrappedEmit({\n    type: EventType.Custom,\n    data: {\n      tag,\n      payload,\n    },\n  });\n}\n\nexport function freezePage() {\n  mutationBuffers.forEach((buf) => buf.freeze());\n}\n\nexport function takeFullSnapshot(isCheckout?: boolean) {\n  if (!_takeFullSnapshot) {\n    throw new Error('please take full snapshot after start recording');\n  }\n  _takeFullSnapshot(isCheckout);\n}\n\n// record.addCustomEvent is removed because Sentry Session Replay does not use it\n// record.freezePage is removed because Sentry Session Replay does not use it\n\n// For backwards compatibility - we can eventually remove this when we migrated to using the exported `mirror` & `takeFullSnapshot`\nrecord.mirror = mirror;\nrecord.takeFullSnapshot = takeFullSnapshot;\n\nexport default record;\n\nfunction _getCanvasManager(\n  getCanvasManagerFn:\n    | undefined\n    | ((\n        options: Partial<CanvasManagerConstructorOptions>,\n      ) => CanvasManagerInterface),\n  options: CanvasManagerConstructorOptions,\n) {\n  try {\n    return getCanvasManagerFn\n      ? getCanvasManagerFn(options)\n      : new CanvasManagerNoop();\n  } catch {\n    console.warn('Unable to initialize CanvasManager');\n    return new CanvasManagerNoop();\n  }\n}\n","export default function(n){return{all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e])},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]))},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e)}),(i=n.get(\"*\"))&&i.slice().map(function(n){n(t,e)})}}}\n//# sourceMappingURL=mitt.mjs.map\n","/**\n * A fork version of https://github.com/iamdustan/smoothscroll\n * Add support of customize target window and document\n */\n\n/* eslint-disable */\n// @ts-nocheck\nexport function polyfill(w: Window = window, d = document) {\n  // return if scroll behavior is supported and polyfill is not forced\n  if (\n    'scrollBehavior' in d.documentElement.style &&\n    w.__forceSmoothScrollPolyfill__ !== true\n  ) {\n    return;\n  }\n\n  // globals\n  const Element = w.HTMLElement || w.Element;\n  const SCROLL_TIME = 468;\n\n  // object gathering original scroll methods\n  const original = {\n    scroll: w.scroll || w.scrollTo,\n    scrollBy: w.scrollBy,\n    elementScroll: Element.prototype.scroll || scrollElement,\n    scrollIntoView: Element.prototype.scrollIntoView,\n  };\n\n  // define timing method\n  const now =\n    w.performance && w.performance.now\n      ? w.performance.now.bind(w.performance)\n      : Date.now;\n\n  /**\n   * indicates if a the current browser is made by Microsoft\n   * @method isMicrosoftBrowser\n   * @param {String} userAgent\n   * @returns {Boolean}\n   */\n  function isMicrosoftBrowser(userAgent) {\n    const userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];\n\n    return new RegExp(userAgentPatterns.join('|')).test(userAgent);\n  }\n\n  /*\n   * IE has rounding bug rounding down clientHeight and clientWidth and\n   * rounding up scrollHeight and scrollWidth causing false positives\n   * on hasScrollableSpace\n   */\n  const ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;\n\n  /**\n   * changes scroll position inside an element\n   * @method scrollElement\n   * @param {Number} x\n   * @param {Number} y\n   * @returns {undefined}\n   */\n  function scrollElement(x, y) {\n    this.scrollLeft = x;\n    this.scrollTop = y;\n  }\n\n  /**\n   * returns result of applying ease math function to a number\n   * @method ease\n   * @param {Number} k\n   * @returns {Number}\n   */\n  function ease(k) {\n    return 0.5 * (1 - Math.cos(Math.PI * k));\n  }\n\n  /**\n   * indicates if a smooth behavior should be applied\n   * @method shouldBailOut\n   * @param {Number|Object} firstArg\n   * @returns {Boolean}\n   */\n  function shouldBailOut(firstArg) {\n    if (\n      firstArg === null ||\n      typeof firstArg !== 'object' ||\n      firstArg.behavior === undefined ||\n      firstArg.behavior === 'auto' ||\n      firstArg.behavior === 'instant'\n    ) {\n      // first argument is not an object/null\n      // or behavior is auto, instant or undefined\n      return true;\n    }\n\n    if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {\n      // first argument is an object and behavior is smooth\n      return false;\n    }\n\n    // throw error when behavior is not supported\n    throw new TypeError(\n      'behavior member of ScrollOptions ' +\n        firstArg.behavior +\n        ' is not a valid value for enumeration ScrollBehavior.',\n    );\n  }\n\n  /**\n   * indicates if an element has scrollable space in the provided axis\n   * @method hasScrollableSpace\n   * @param {Node} el\n   * @param {String} axis\n   * @returns {Boolean}\n   */\n  function hasScrollableSpace(el, axis) {\n    if (axis === 'Y') {\n      return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;\n    }\n\n    if (axis === 'X') {\n      return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;\n    }\n  }\n\n  /**\n   * indicates if an element has a scrollable overflow property in the axis\n   * @method canOverflow\n   * @param {Node} el\n   * @param {String} axis\n   * @returns {Boolean}\n   */\n  function canOverflow(el, axis) {\n    const overflowValue = w.getComputedStyle(el, null)['overflow' + axis];\n\n    return overflowValue === 'auto' || overflowValue === 'scroll';\n  }\n\n  /**\n   * indicates if an element can be scrolled in either axis\n   * @method isScrollable\n   * @param {Node} el\n   * @param {String} axis\n   * @returns {Boolean}\n   */\n  function isScrollable(el) {\n    const isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');\n    const isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');\n\n    return isScrollableY || isScrollableX;\n  }\n\n  /**\n   * finds scrollable parent of an element\n   * @method findScrollableParent\n   * @param {Node} el\n   * @returns {Node} el\n   */\n  function findScrollableParent(el) {\n    while (el !== d.body && isScrollable(el) === false) {\n      el = el.parentNode || el.host;\n    }\n\n    return el;\n  }\n\n  /**\n   * self invoked function that, given a context, steps through scrolling\n   * @method step\n   * @param {Object} context\n   * @returns {undefined}\n   */\n  function step(context) {\n    const time = now();\n    let value;\n    let currentX;\n    let currentY;\n    let elapsed = (time - context.startTime) / SCROLL_TIME;\n\n    // avoid elapsed times higher than one\n    elapsed = elapsed > 1 ? 1 : elapsed;\n\n    // apply easing to elapsed time\n    value = ease(elapsed);\n\n    currentX = context.startX + (context.x - context.startX) * value;\n    currentY = context.startY + (context.y - context.startY) * value;\n\n    context.method.call(context.scrollable, currentX, currentY);\n\n    // scroll more if we have not reached our destination\n    if (currentX !== context.x || currentY !== context.y) {\n      w.requestAnimationFrame(step.bind(w, context));\n    }\n  }\n\n  /**\n   * scrolls window or element with a smooth behavior\n   * @method smoothScroll\n   * @param {Object|Node} el\n   * @param {Number} x\n   * @param {Number} y\n   * @returns {undefined}\n   */\n  function smoothScroll(el, x, y) {\n    let scrollable;\n    let startX;\n    let startY;\n    let method;\n    const startTime = now();\n\n    // define scroll context\n    if (el === d.body) {\n      scrollable = w;\n      startX = w.scrollX || w.pageXOffset;\n      startY = w.scrollY || w.pageYOffset;\n      method = original.scroll;\n    } else {\n      scrollable = el;\n      startX = el.scrollLeft;\n      startY = el.scrollTop;\n      method = scrollElement;\n    }\n\n    // scroll looping over a frame\n    step({\n      scrollable: scrollable,\n      method: method,\n      startTime: startTime,\n      startX: startX,\n      startY: startY,\n      x: x,\n      y: y,\n    });\n  }\n\n  // ORIGINAL METHODS OVERRIDES\n  // w.scroll and w.scrollTo\n  w.scroll = w.scrollTo = function () {\n    // avoid action when no arguments are passed\n    if (arguments[0] === undefined) {\n      return;\n    }\n\n    // avoid smooth behavior if not required\n    if (shouldBailOut(arguments[0]) === true) {\n      original.scroll.call(\n        w,\n        arguments[0].left !== undefined\n          ? arguments[0].left\n          : typeof arguments[0] !== 'object'\n          ? arguments[0]\n          : w.scrollX || w.pageXOffset,\n        // use top prop, second argument if present or fallback to scrollY\n        arguments[0].top !== undefined\n          ? arguments[0].top\n          : arguments[1] !== undefined\n          ? arguments[1]\n          : w.scrollY || w.pageYOffset,\n      );\n\n      return;\n    }\n\n    // LET THE SMOOTHNESS BEGIN!\n    smoothScroll.call(\n      w,\n      d.body,\n      arguments[0].left !== undefined\n        ? ~~arguments[0].left\n        : w.scrollX || w.pageXOffset,\n      arguments[0].top !== undefined\n        ? ~~arguments[0].top\n        : w.scrollY || w.pageYOffset,\n    );\n  };\n\n  // w.scrollBy\n  w.scrollBy = function () {\n    // avoid action when no arguments are passed\n    if (arguments[0] === undefined) {\n      return;\n    }\n\n    // avoid smooth behavior if not required\n    if (shouldBailOut(arguments[0])) {\n      original.scrollBy.call(\n        w,\n        arguments[0].left !== undefined\n          ? arguments[0].left\n          : typeof arguments[0] !== 'object'\n          ? arguments[0]\n          : 0,\n        arguments[0].top !== undefined\n          ? arguments[0].top\n          : arguments[1] !== undefined\n          ? arguments[1]\n          : 0,\n      );\n\n      return;\n    }\n\n    // LET THE SMOOTHNESS BEGIN!\n    smoothScroll.call(\n      w,\n      d.body,\n      ~~arguments[0].left + (w.scrollX || w.pageXOffset),\n      ~~arguments[0].top + (w.scrollY || w.pageYOffset),\n    );\n  };\n\n  // Element.prototype.scroll and Element.prototype.scrollTo\n  Element.prototype.scroll = Element.prototype.scrollTo = function () {\n    // avoid action when no arguments are passed\n    if (arguments[0] === undefined) {\n      return;\n    }\n\n    // avoid smooth behavior if not required\n    if (shouldBailOut(arguments[0]) === true) {\n      // if one number is passed, throw error to match Firefox implementation\n      if (typeof arguments[0] === 'number' && arguments[1] === undefined) {\n        throw new SyntaxError('Value could not be converted');\n      }\n\n      original.elementScroll.call(\n        this,\n        // use left prop, first number argument or fallback to scrollLeft\n        arguments[0].left !== undefined\n          ? ~~arguments[0].left\n          : typeof arguments[0] !== 'object'\n          ? ~~arguments[0]\n          : this.scrollLeft,\n        // use top prop, second argument or fallback to scrollTop\n        arguments[0].top !== undefined\n          ? ~~arguments[0].top\n          : arguments[1] !== undefined\n          ? ~~arguments[1]\n          : this.scrollTop,\n      );\n\n      return;\n    }\n\n    const left = arguments[0].left;\n    const top = arguments[0].top;\n\n    // LET THE SMOOTHNESS BEGIN!\n    smoothScroll.call(\n      this,\n      this,\n      typeof left === 'undefined' ? this.scrollLeft : ~~left,\n      typeof top === 'undefined' ? this.scrollTop : ~~top,\n    );\n  };\n\n  // Element.prototype.scrollBy\n  Element.prototype.scrollBy = function () {\n    // avoid action when no arguments are passed\n    if (arguments[0] === undefined) {\n      return;\n    }\n\n    // avoid smooth behavior if not required\n    if (shouldBailOut(arguments[0]) === true) {\n      original.elementScroll.call(\n        this,\n        arguments[0].left !== undefined\n          ? ~~arguments[0].left + this.scrollLeft\n          : ~~arguments[0] + this.scrollLeft,\n        arguments[0].top !== undefined\n          ? ~~arguments[0].top + this.scrollTop\n          : ~~arguments[1] + this.scrollTop,\n      );\n\n      return;\n    }\n\n    this.scroll({\n      left: ~~arguments[0].left + this.scrollLeft,\n      top: ~~arguments[0].top + this.scrollTop,\n      behavior: arguments[0].behavior,\n    });\n  };\n\n  // Element.prototype.scrollIntoView\n  Element.prototype.scrollIntoView = function () {\n    // avoid smooth behavior if not required\n    if (shouldBailOut(arguments[0]) === true) {\n      original.scrollIntoView.call(\n        this,\n        arguments[0] === undefined ? true : arguments[0],\n      );\n\n      return;\n    }\n\n    // LET THE SMOOTHNESS BEGIN!\n    const scrollableParent = findScrollableParent(this);\n    const parentRects = scrollableParent.getBoundingClientRect();\n    const clientRects = this.getBoundingClientRect();\n\n    if (scrollableParent !== d.body) {\n      // reveal element inside parent\n      smoothScroll.call(\n        this,\n        scrollableParent,\n        scrollableParent.scrollLeft + clientRects.left - parentRects.left,\n        scrollableParent.scrollTop + clientRects.top - parentRects.top,\n      );\n\n      // reveal parent in viewport unless is fixed\n      if (w.getComputedStyle(scrollableParent).position !== 'fixed') {\n        w.scrollBy({\n          left: parentRects.left,\n          top: parentRects.top,\n          behavior: 'smooth',\n        });\n      }\n    } else {\n      // reveal element in viewport\n      w.scrollBy({\n        left: clientRects.left,\n        top: clientRects.top,\n        behavior: 'smooth',\n      });\n    }\n  };\n}\n","import {\n  actionWithDelay,\n  eventWithTime,\n  EventType,\n  IncrementalSource,\n} from '@sentry-internal/rrweb-types';\nimport { onRequestAnimationFrame } from '../utils';\n\nexport class Timer {\n  public timeOffset = 0;\n  public speed: number;\n\n  private actions: actionWithDelay[];\n  private raf: number | true | null = null;\n  private lastTimestamp: number;\n\n  constructor(\n    actions: actionWithDelay[] = [],\n    config: {\n      speed: number;\n    },\n  ) {\n    this.actions = actions;\n    this.speed = config.speed;\n  }\n  /**\n   * Add an action, possibly after the timer starts.\n   */\n  public addAction(action: actionWithDelay) {\n    const rafWasActive = this.raf === true;\n    if (\n      !this.actions.length ||\n      this.actions[this.actions.length - 1].delay <= action.delay\n    ) {\n      // 'fast track'\n      this.actions.push(action);\n    } else {\n      // binary search - events can arrive out of order in a realtime context\n      const index = this.findActionIndex(action);\n      this.actions.splice(index, 0, action);\n    }\n    if (rafWasActive) {\n      this.raf = onRequestAnimationFrame(this.rafCheck.bind(this));\n    }\n  }\n\n  public start() {\n    this.timeOffset = 0;\n    this.lastTimestamp = performance.now();\n    this.raf = onRequestAnimationFrame(this.rafCheck.bind(this));\n  }\n\n  private rafCheck() {\n    const time = performance.now();\n    this.timeOffset += (time - this.lastTimestamp) * this.speed;\n    this.lastTimestamp = time;\n    while (this.actions.length) {\n      const action = this.actions[0];\n\n      if (this.timeOffset >= action.delay) {\n        this.actions.shift();\n        action.doAction();\n      } else {\n        break;\n      }\n    }\n    if (this.actions.length > 0) {\n      this.raf = onRequestAnimationFrame(this.rafCheck.bind(this));\n    } else {\n      this.raf = true; // was active\n    }\n  }\n\n  public clear() {\n    if (this.raf) {\n      if (this.raf !== true) {\n        cancelAnimationFrame(this.raf);\n      }\n      this.raf = null;\n    }\n    this.actions.length = 0;\n  }\n\n  public setSpeed(speed: number) {\n    this.speed = speed;\n  }\n\n  public isActive() {\n    return this.raf !== null;\n  }\n\n  private findActionIndex(action: actionWithDelay): number {\n    let start = 0;\n    let end = this.actions.length - 1;\n    while (start <= end) {\n      const mid = Math.floor((start + end) / 2);\n      if (this.actions[mid].delay < action.delay) {\n        start = mid + 1;\n      } else if (this.actions[mid].delay > action.delay) {\n        end = mid - 1;\n      } else {\n        // already an action with same delay (timestamp)\n        // the plus one will splice the new one after the existing one\n        return mid + 1;\n      }\n    }\n    return start;\n  }\n}\n\n// TODO: add speed to mouse move timestamp calculation\nexport function addDelay(event: eventWithTime, baselineTime: number): number {\n  // Mouse move events was recorded in a throttle function,\n  // so we need to find the real timestamp by traverse the time offsets.\n  if (\n    event.type === EventType.IncrementalSnapshot &&\n    event.data.source === IncrementalSource.MouseMove &&\n    event.data.positions &&\n    event.data.positions.length\n  ) {\n    const firstOffset = event.data.positions[0].timeOffset;\n    // timeOffset is a negative offset to event.timestamp\n    const firstTimestamp = event.timestamp + firstOffset;\n    event.delay = firstTimestamp - baselineTime;\n    return firstTimestamp - baselineTime;\n  }\n\n  event.delay = event.timestamp - baselineTime;\n  return event.delay;\n}\n","/*! *****************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\nfunction t(t,n){var e=\"function\"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]=\"NotStarted\",t[t.Running=1]=\"Running\",t[t.Stopped=2]=\"Stopped\"}(n||(n={}));var e={type:\"xstate.init\"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return{type:\"xstate.assign\",assignment:t}}function i(t,n){return\"string\"==typeof(t=\"string\"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:\"function\"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return\"string\"==typeof t?{type:t}:t}function c(t,n){return{value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return[t.filter((function(t){if(\"xstate.assign\"===t.type){o=!0;var n=Object.assign({},r);return\"function\"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]=\"function\"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o]})),r=n,!1}return!0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v=\"string\"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n=\"function\"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&\"number\"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w=\"string\"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return!0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return{value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t}}finally{try{b&&!b.done&&(l=h.return)&&l.call(h)}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})))},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u=\"object\"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)}}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}export{n as InterpreterStatus,o as assign,s as createMachine,v as interpret};\n","import { createMachine, interpret, assign, StateMachine } from '@xstate/fsm';\nimport type { playerConfig } from '../types';\nimport {\n  eventWithTime,\n  ReplayerEvents,\n  EventType,\n  Emitter,\n  IncrementalSource,\n} from '@sentry-internal/rrweb-types';\nimport { Timer, addDelay } from './timer';\n\nexport type PlayerContext = {\n  events: eventWithTime[];\n  timer: Timer;\n  timeOffset: number;\n  baselineTime: number;\n  lastPlayedEvent: eventWithTime | null;\n};\nexport type PlayerEvent =\n  | {\n      type: 'PLAY';\n      payload: {\n        timeOffset: number;\n      };\n    }\n  | {\n      type: 'CAST_EVENT';\n      payload: {\n        event: eventWithTime;\n      };\n    }\n  | { type: 'PAUSE' }\n  | { type: 'TO_LIVE'; payload: { baselineTime?: number } }\n  | {\n      type: 'ADD_EVENT';\n      payload: {\n        event: eventWithTime;\n      };\n    }\n  | {\n      type: 'END';\n    };\nexport type PlayerState =\n  | {\n      value: 'playing';\n      context: PlayerContext;\n    }\n  | {\n      value: 'paused';\n      context: PlayerContext;\n    }\n  | {\n      value: 'live';\n      context: PlayerContext;\n    };\n\n/**\n * If the array have multiple meta and fullsnapshot events,\n * return the events from last meta to the end.\n */\nexport function discardPriorSnapshots(\n  events: eventWithTime[],\n  baselineTime: number,\n): eventWithTime[] {\n  for (let idx = events.length - 1; idx >= 0; idx--) {\n    const event = events[idx];\n    if (event.type === EventType.Meta) {\n      if (event.timestamp <= baselineTime) {\n        return events.slice(idx);\n      }\n    }\n  }\n  return events;\n}\n\ntype PlayerAssets = {\n  emitter: Emitter;\n  applyEventsSynchronously(events: Array<eventWithTime>): void;\n  getCastFn(event: eventWithTime, isSync: boolean): () => void;\n};\nexport function createPlayerService(\n  context: PlayerContext,\n  { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets,\n) {\n  const playerMachine = createMachine<PlayerContext, PlayerEvent, PlayerState>(\n    {\n      id: 'player',\n      context,\n      initial: 'paused',\n      states: {\n        playing: {\n          on: {\n            PAUSE: {\n              target: 'paused',\n              actions: ['pause'],\n            },\n            CAST_EVENT: {\n              target: 'playing',\n              actions: 'castEvent',\n            },\n            END: {\n              target: 'paused',\n              actions: ['resetLastPlayedEvent', 'pause'],\n            },\n            ADD_EVENT: {\n              target: 'playing',\n              actions: ['addEvent'],\n            },\n          },\n        },\n        paused: {\n          on: {\n            PLAY: {\n              target: 'playing',\n              actions: ['recordTimeOffset', 'play'],\n            },\n            CAST_EVENT: {\n              target: 'paused',\n              actions: 'castEvent',\n            },\n            TO_LIVE: {\n              target: 'live',\n              actions: ['startLive'],\n            },\n            ADD_EVENT: {\n              target: 'paused',\n              actions: ['addEvent'],\n            },\n          },\n        },\n        live: {\n          on: {\n            ADD_EVENT: {\n              target: 'live',\n              actions: ['addEvent'],\n            },\n            CAST_EVENT: {\n              target: 'live',\n              actions: ['castEvent'],\n            },\n          },\n        },\n      },\n    },\n    {\n      actions: {\n        castEvent: assign({\n          lastPlayedEvent: (ctx, event) => {\n            if (event.type === 'CAST_EVENT') {\n              return event.payload.event;\n            }\n            return ctx.lastPlayedEvent;\n          },\n        }),\n        recordTimeOffset: assign((ctx, event) => {\n          let timeOffset = ctx.timeOffset;\n          if ('payload' in event && 'timeOffset' in event.payload) {\n            timeOffset = event.payload.timeOffset;\n          }\n          return {\n            ...ctx,\n            timeOffset,\n            baselineTime: ctx.events[0].timestamp + timeOffset,\n          };\n        }),\n        play(ctx) {\n          const { timer, events, baselineTime, lastPlayedEvent } = ctx;\n          timer.clear();\n\n          for (const event of events) {\n            // TODO: improve this API\n            addDelay(event, baselineTime);\n          }\n          const neededEvents = discardPriorSnapshots(events, baselineTime);\n\n          let lastPlayedTimestamp = lastPlayedEvent?.timestamp;\n          if (\n            lastPlayedEvent?.type === EventType.IncrementalSnapshot &&\n            lastPlayedEvent.data.source === IncrementalSource.MouseMove\n          ) {\n            lastPlayedTimestamp =\n              lastPlayedEvent.timestamp +\n              lastPlayedEvent.data.positions[0]?.timeOffset;\n          }\n          if (baselineTime < (lastPlayedTimestamp || 0)) {\n            emitter.emit(ReplayerEvents.PlayBack);\n          }\n\n          const syncEvents = new Array<eventWithTime>();\n          for (const event of neededEvents) {\n            if (\n              lastPlayedTimestamp &&\n              lastPlayedTimestamp < baselineTime &&\n              (event.timestamp <= lastPlayedTimestamp ||\n                event === lastPlayedEvent)\n            ) {\n              continue;\n            }\n            if (event.timestamp < baselineTime) {\n              syncEvents.push(event);\n            } else {\n              const castFn = getCastFn(event, false);\n              timer.addAction({\n                doAction: () => {\n                  castFn();\n                },\n                delay: event.delay!,\n              });\n            }\n          }\n          applyEventsSynchronously(syncEvents);\n          emitter.emit(ReplayerEvents.Flush);\n          timer.start();\n        },\n        pause(ctx) {\n          ctx.timer.clear();\n        },\n        resetLastPlayedEvent: assign((ctx) => {\n          return {\n            ...ctx,\n            lastPlayedEvent: null,\n          };\n        }),\n        startLive: assign({\n          baselineTime: (ctx, event) => {\n            ctx.timer.start();\n            if (event.type === 'TO_LIVE' && event.payload.baselineTime) {\n              return event.payload.baselineTime;\n            }\n            return Date.now();\n          },\n        }),\n        addEvent: assign((ctx, machineEvent) => {\n          const { baselineTime, timer, events } = ctx;\n          if (machineEvent.type === 'ADD_EVENT') {\n            const { event } = machineEvent.payload;\n            addDelay(event, baselineTime);\n\n            let end = events.length - 1;\n            if (!events[end] || events[end].timestamp <= event.timestamp) {\n              // fast track\n              events.push(event);\n            } else {\n              let insertionIndex = -1;\n              let start = 0;\n              while (start <= end) {\n                const mid = Math.floor((start + end) / 2);\n                if (events[mid].timestamp <= event.timestamp) {\n                  start = mid + 1;\n                } else {\n                  end = mid - 1;\n                }\n              }\n              if (insertionIndex === -1) {\n                insertionIndex = start;\n              }\n              events.splice(insertionIndex, 0, event);\n            }\n\n            const isSync = event.timestamp < baselineTime;\n            const castFn = getCastFn(event, isSync);\n            if (isSync) {\n              castFn();\n            } else if (timer.isActive()) {\n              timer.addAction({\n                doAction: () => {\n                  castFn();\n                },\n                delay: event.delay!,\n              });\n            }\n          }\n          return { ...ctx, events };\n        }),\n      },\n    },\n  );\n  return interpret(playerMachine);\n}\n\nexport type SpeedContext = {\n  normalSpeed: playerConfig['speed'];\n  timer: Timer;\n};\n\nexport type SpeedEvent =\n  | {\n      type: 'FAST_FORWARD';\n      payload: { speed: playerConfig['speed'] };\n    }\n  | {\n      type: 'BACK_TO_NORMAL';\n    }\n  | {\n      type: 'SET_SPEED';\n      payload: { speed: playerConfig['speed'] };\n    };\n\nexport type SpeedState =\n  | {\n      value: 'normal';\n      context: SpeedContext;\n    }\n  | {\n      value: 'skipping';\n      context: SpeedContext;\n    };\n\nexport function createSpeedService(context: SpeedContext) {\n  const speedMachine = createMachine<SpeedContext, SpeedEvent, SpeedState>(\n    {\n      id: 'speed',\n      context,\n      initial: 'normal',\n      states: {\n        normal: {\n          on: {\n            FAST_FORWARD: {\n              target: 'skipping',\n              actions: ['recordSpeed', 'setSpeed'],\n            },\n            SET_SPEED: {\n              target: 'normal',\n              actions: ['setSpeed'],\n            },\n          },\n        },\n        skipping: {\n          on: {\n            BACK_TO_NORMAL: {\n              target: 'normal',\n              actions: ['restoreSpeed'],\n            },\n            SET_SPEED: {\n              target: 'normal',\n              actions: ['setSpeed'],\n            },\n          },\n        },\n      },\n    },\n    {\n      actions: {\n        setSpeed: (ctx, event) => {\n          if ('payload' in event) {\n            ctx.timer.setSpeed(event.payload.speed);\n          }\n        },\n        recordSpeed: assign({\n          normalSpeed: (ctx) => ctx.timer.speed,\n        }),\n        restoreSpeed: (ctx) => {\n          ctx.timer.setSpeed(ctx.normalSpeed);\n        },\n      },\n    },\n  );\n\n  return interpret(speedMachine);\n}\n\nexport type PlayerMachineState = StateMachine.State<\n  PlayerContext,\n  PlayerEvent,\n  PlayerState\n>;\n\nexport type SpeedMachineState = StateMachine.State<\n  SpeedContext,\n  SpeedEvent,\n  SpeedState\n>;\n","const rules: (blockClass: string) => string[] = (blockClass: string) => [\n  `.${blockClass} { background: currentColor }`,\n  'noscript { display: none !important; }',\n];\n\nexport default rules;\n","import { decode } from 'base64-arraybuffer';\nimport type { Replayer } from '../';\nimport type {\n  CanvasArg,\n  SerializedCanvasArg,\n} from '@sentry-internal/rrweb-types';\n\n// TODO: add ability to wipe this list\ntype GLVarMap = Map<string, any[]>;\nconst webGLVarMap: Map<\n  CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext,\n  GLVarMap\n> = new Map();\nexport function variableListFor(\n  ctx:\n    | CanvasRenderingContext2D\n    | WebGLRenderingContext\n    | WebGL2RenderingContext,\n  ctor: string,\n) {\n  let contextMap = webGLVarMap.get(ctx);\n  if (!contextMap) {\n    contextMap = new Map();\n    webGLVarMap.set(ctx, contextMap);\n  }\n  if (!contextMap.has(ctor)) {\n    contextMap.set(ctor, []);\n  }\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n  return contextMap.get(ctor) as any[];\n}\n\nexport function isSerializedArg(arg: unknown): arg is SerializedCanvasArg {\n  return Boolean(arg && typeof arg === 'object' && 'rr_type' in arg);\n}\n\nexport function deserializeArg(\n  imageMap: Replayer['imageMap'],\n  ctx:\n    | CanvasRenderingContext2D\n    | WebGLRenderingContext\n    | WebGL2RenderingContext\n    | null,\n  preload?: {\n    isUnchanged: boolean;\n  },\n): (arg: CanvasArg) => Promise<any> {\n  return async (arg: CanvasArg): Promise<any> => {\n    if (arg && typeof arg === 'object' && 'rr_type' in arg) {\n      if (preload) preload.isUnchanged = false;\n      if (arg.rr_type === 'ImageBitmap' && 'args' in arg) {\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n        const args = await deserializeArg(imageMap, ctx, preload)(arg.args);\n        // eslint-disable-next-line prefer-spread\n        return await createImageBitmap.apply(null, args);\n      } else if ('index' in arg) {\n        if (preload || ctx === null) return arg; // we are preloading, ctx is unknown\n        const { rr_type: name, index } = arg;\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n        return variableListFor(ctx, name)[index];\n      } else if ('args' in arg) {\n        const { rr_type: name, args } = arg;\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n        const ctor = window[name as keyof Window];\n\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n        return new ctor(\n          ...(await Promise.all(\n            args.map(deserializeArg(imageMap, ctx, preload)),\n          )),\n        );\n      } else if ('base64' in arg) {\n        return decode(arg.base64);\n      } else if ('src' in arg) {\n        const image = imageMap.get(arg.src);\n        if (image) {\n          return image;\n        } else {\n          const image = new Image();\n          image.src = arg.src;\n          imageMap.set(arg.src, image);\n          return image;\n        }\n      } else if ('data' in arg && arg.rr_type === 'Blob') {\n        const blobContents = await Promise.all(\n          arg.data.map(deserializeArg(imageMap, ctx, preload)),\n        );\n        const blob = new Blob(blobContents, {\n          type: arg.type,\n        });\n        return blob;\n      }\n    } else if (Array.isArray(arg)) {\n      const result = await Promise.all(\n        arg.map(deserializeArg(imageMap, ctx, preload)),\n      );\n      // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n      return result;\n    }\n    return arg;\n  };\n}\n","import type { Replayer } from '../';\nimport {\n  CanvasContext,\n  canvasMutationCommand,\n} from '@sentry-internal/rrweb-types';\nimport { deserializeArg, variableListFor } from './deserialize-args';\n\nfunction getContext(\n  target: HTMLCanvasElement,\n  type: CanvasContext,\n): WebGLRenderingContext | WebGL2RenderingContext | null {\n  // Note to whomever is going to implement support for `contextAttributes`:\n  // if `preserveDrawingBuffer` is set to true,\n  // you might have to do `ctx.flush()` before every webgl canvas event\n  try {\n    if (type === CanvasContext.WebGL) {\n      return (\n        target.getContext('webgl')! || target.getContext('experimental-webgl')\n      );\n    }\n    return target.getContext('webgl2')!;\n  } catch (e) {\n    return null;\n  }\n}\n\nconst WebGLVariableConstructorsNames = [\n  'WebGLActiveInfo',\n  'WebGLBuffer',\n  'WebGLFramebuffer',\n  'WebGLProgram',\n  'WebGLRenderbuffer',\n  'WebGLShader',\n  'WebGLShaderPrecisionFormat',\n  'WebGLTexture',\n  'WebGLUniformLocation',\n  'WebGLVertexArrayObject',\n];\n\nfunction saveToWebGLVarMap(\n  ctx: WebGLRenderingContext | WebGL2RenderingContext,\n  result: any,\n) {\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n  if (!result?.constructor) return; // probably null or undefined\n\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n  const { name } = result.constructor;\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n  if (!WebGLVariableConstructorsNames.includes(name)) return; // not a WebGL variable\n\n  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n  const variables = variableListFor(ctx, name);\n  if (!variables.includes(result)) variables.push(result);\n}\n\nexport default async function webglMutation({\n  mutation,\n  target,\n  type,\n  imageMap,\n  errorHandler,\n}: {\n  mutation: canvasMutationCommand;\n  target: HTMLCanvasElement;\n  type: CanvasContext;\n  imageMap: Replayer['imageMap'];\n  errorHandler: Replayer['warnCanvasMutationFailed'];\n}): Promise<void> {\n  try {\n    const ctx = getContext(target, type);\n    if (!ctx) return;\n\n    // NOTE: if `preserveDrawingBuffer` is set to true,\n    // we must flush the buffers on every new canvas event\n    // if (mutation.newFrame) ctx.flush();\n\n    if (mutation.setter) {\n      // skip some read-only type checks\n      // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n      (ctx as any)[mutation.property] = mutation.args[0];\n      return;\n    }\n    const original = ctx[\n      mutation.property as Exclude<keyof typeof ctx, 'canvas'>\n    ] as (\n      ctx: WebGLRenderingContext | WebGL2RenderingContext,\n      args: unknown[],\n    ) => void;\n\n    const args = await Promise.all(\n      mutation.args.map(deserializeArg(imageMap, ctx)),\n    );\n    const result = original.apply(ctx, args);\n    saveToWebGLVarMap(ctx, result);\n\n    // Slows down replay considerably, only use for debugging\n    const debugMode = false;\n    if (debugMode) {\n      if (mutation.property === 'compileShader') {\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n        if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))\n          console.warn(\n            'something went wrong in replay',\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n            ctx.getShaderInfoLog(args[0]),\n          );\n      } else if (mutation.property === 'linkProgram') {\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n        ctx.validateProgram(args[0]);\n        // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n        if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))\n          console.warn(\n            'something went wrong in replay',\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n            ctx.getProgramInfoLog(args[0]),\n          );\n      }\n      const webglError = ctx.getError();\n      if (webglError !== ctx.NO_ERROR) {\n        console.warn(\n          'WEBGL ERROR',\n          webglError,\n          'on command:',\n          mutation.property,\n          // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n          ...args,\n        );\n      }\n    }\n  } catch (error) {\n    errorHandler(mutation, error);\n  }\n}\n","import type { Replayer } from '../';\nimport type { canvasMutationCommand } from '@sentry-internal/rrweb-types';\nimport { deserializeArg } from './deserialize-args';\n\nexport default async function canvasMutation({\n  event,\n  mutations,\n  target,\n  imageMap,\n  errorHandler,\n}: {\n  event: Parameters<Replayer['applyIncremental']>[0];\n  mutations: canvasMutationCommand[];\n  target: HTMLCanvasElement;\n  imageMap: Replayer['imageMap'];\n  errorHandler: Replayer['warnCanvasMutationFailed'];\n}): Promise<void> {\n  const ctx = target.getContext('2d');\n\n  if (!ctx) {\n    errorHandler(mutations[0], new Error('Canvas context is null'));\n    return;\n  }\n\n  // step 1, deserialize args, they may be async\n  const mutationArgsPromises = mutations.map(\n    async (mutation: canvasMutationCommand): Promise<unknown[]> => {\n      return Promise.all(mutation.args.map(deserializeArg(imageMap, ctx)));\n    },\n  );\n  const args = await Promise.all(mutationArgsPromises);\n  // step 2 apply all mutations\n  args.forEach((args, index) => {\n    const mutation = mutations[index];\n    try {\n      if (mutation.setter) {\n        // skip some read-only type checks\n        (ctx as unknown as Record<string, unknown>)[mutation.property] =\n          mutation.args[0];\n        return;\n      }\n      const original = ctx[\n        mutation.property as Exclude<keyof typeof ctx, 'canvas'>\n      ] as (ctx: CanvasRenderingContext2D, args: unknown[]) => void;\n\n      /**\n       * We have serialized the image source into base64 string during recording,\n       * which has been preloaded before replay.\n       * So we can get call drawImage SYNCHRONOUSLY which avoid some fragile cast.\n       */\n      if (\n        mutation.property === 'drawImage' &&\n        typeof mutation.args[0] === 'string'\n      ) {\n        imageMap.get(event);\n        original.apply(ctx, mutation.args);\n      } else {\n        original.apply(ctx, args);\n      }\n    } catch (error) {\n      errorHandler(mutation, error);\n    }\n\n    return;\n  });\n}\n","import type { Replayer } from '..';\nimport {\n  CanvasContext,\n  canvasMutationCommand,\n  canvasMutationData,\n  canvasMutationParam,\n} from '@sentry-internal/rrweb-types';\nimport webglMutation from './webgl';\nimport canvas2DMutation from './2d';\n\nexport default async function canvasMutation({\n  event,\n  mutation,\n  target,\n  imageMap,\n  canvasEventMap,\n  errorHandler,\n}: {\n  event: Parameters<Replayer['applyIncremental']>[0];\n  mutation: canvasMutationData;\n  target: HTMLCanvasElement;\n  imageMap: Replayer['imageMap'];\n  canvasEventMap: Replayer['canvasEventMap'];\n  errorHandler: Replayer['warnCanvasMutationFailed'];\n}): Promise<void> {\n  try {\n    const precomputedMutation: canvasMutationParam =\n      canvasEventMap.get(event) || mutation;\n\n    const commands: canvasMutationCommand[] =\n      'commands' in precomputedMutation\n        ? precomputedMutation.commands\n        : [precomputedMutation];\n\n    if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {\n      for (let i = 0; i < commands.length; i++) {\n        const command = commands[i];\n        await webglMutation({\n          mutation: command,\n          type: mutation.type,\n          target,\n          imageMap,\n          errorHandler,\n        });\n      }\n      return;\n    }\n    // default is '2d' for backwards compatibility (rrweb below 1.1.x)\n    await canvas2DMutation({\n      event,\n      mutations: commands,\n      target,\n      imageMap,\n      errorHandler,\n    });\n  } catch (error) {\n    errorHandler(mutation, error);\n  }\n}\n","import {\n  rebuild,\n  buildNodeWithSN,\n  NodeType,\n  BuildCache,\n  createCache,\n  Mirror,\n  createMirror,\n  attributes,\n  serializedElementNodeWithId,\n  toLowerCase,\n} from '@sentry-internal/rrweb-snapshot';\nimport {\n  RRDocument,\n  createOrGetNode,\n  buildFromNode,\n  buildFromDom,\n  diff,\n  getDefaultSN,\n  getIFrameContentDocument,\n  getIFrameContentWindow,\n} from '@sentry-internal/rrdom';\nimport type {\n  RRNode,\n  RRElement,\n  RRStyleElement,\n  RRIFrameElement,\n  RRMediaElement,\n  RRCanvasElement,\n  ReplayerHandler,\n  Mirror as RRDOMMirror,\n} from '@sentry-internal/rrdom';\nimport * as mittProxy from 'mitt';\nimport { polyfill as smoothscrollPolyfill } from './smoothscroll';\nimport { Timer } from './timer';\nimport {\n  createPlayerService,\n  createSpeedService,\n  type PlayerState,\n  type SpeedState,\n  type PlayerMachineState,\n  type SpeedMachineState,\n} from './machine';\nimport type { playerConfig, missingNodeMap } from '../types';\nimport {\n  EventType,\n  IncrementalSource,\n  fullSnapshotEvent,\n  eventWithTime,\n  MouseInteractions,\n  playerMetaData,\n  viewportResizeDimension,\n  addedNodeMutation,\n  incrementalSnapshotEvent,\n  incrementalData,\n  ReplayerEvents,\n  Handler,\n  Emitter,\n  MediaInteractions,\n  metaEvent,\n  mutationData,\n  scrollData,\n  inputData,\n  canvasMutationData,\n  styleValueWithPriority,\n  mouseMovePos,\n  IWindow,\n  canvasMutationCommand,\n  canvasMutationParam,\n  canvasEventWithTime,\n  selectionData,\n  styleSheetRuleData,\n  styleDeclarationData,\n  adoptedStyleSheetData,\n  mouseInteractionData,\n  mousemoveData,\n} from '@sentry-internal/rrweb-types';\nimport {\n  polyfill,\n  queueToResolveTrees,\n  iterateResolveTree,\n  AppendedIframe,\n  getBaseDimension,\n  hasShadowRoot,\n  isSerializedIframe,\n  getNestedRule,\n  getPositionsAndIndex,\n  uniqueTextMutations,\n  StyleSheetMirror,\n  clearTimeout,\n  setTimeout,\n} from '../utils';\nimport getInjectStyleRules from './styles/inject-style';\nimport './styles/style.css';\nimport canvasMutation from './canvas';\nimport { deserializeArg } from './canvas/deserialize-args';\n\nconst SKIP_TIME_INTERVAL = 5 * 1000;\n\n// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734\nconst mitt = mittProxy.default || mittProxy;\n\nconst REPLAY_CONSOLE_PREFIX = '[replayer]';\n\nexport function getEventIndex(\n  events: eventWithTime[],\n  eventTime: number,\n): number {\n  // Use binary search (O(log n)) to find the index of the event at or before the given time\n  let result = -1;\n  if (events.length === 0) {\n    return result;\n  }\n  let left = 0,\n    right = events.length - 1;\n  while (left <= right) {\n    const mid = Math.floor((left + right) / 2);\n    if (events[mid].timestamp <= eventTime) {\n      result = mid;\n      left = mid + 1;\n    } else {\n      right = mid - 1;\n    }\n  }\n  return result;\n}\n\nconst defaultMouseTailConfig = {\n  duration: 500,\n  lineCap: 'round',\n  lineWidth: 3,\n  strokeStyle: 'red',\n} as const;\n\ntype incrementalSnapshotEventWithTime = incrementalSnapshotEvent & {\n  timestamp: number;\n  delay?: number;\n};\n\nfunction indicatesTouchDevice(\n  e: eventWithTime,\n): e is incrementalSnapshotEventWithTime {\n  return (\n    e.type == EventType.IncrementalSnapshot &&\n    (e.data.source == IncrementalSource.TouchMove ||\n      (e.data.source == IncrementalSource.MouseInteraction &&\n        e.data.type == MouseInteractions.TouchStart))\n  );\n}\n\nfunction getPointerId(\n  d: incrementalData | mousemoveData | mouseInteractionData,\n): number {\n  const pointerId =\n    'pointerId' in d && typeof d.pointerId === 'number' ? d.pointerId : -1;\n  return pointerId;\n}\n\nexport class Replayer {\n  public wrapper: HTMLDivElement;\n  public iframe: HTMLIFrameElement;\n\n  public service: ReturnType<typeof createPlayerService>;\n  public speedService: ReturnType<typeof createSpeedService>;\n  public get timer() {\n    return this.service.state.context.timer;\n  }\n\n  public config: playerConfig;\n\n  // In the fast-forward process, if the virtual-dom optimization is used, this flag value is true.\n  public usingVirtualDom = false;\n  public virtualDom: RRDocument = new RRDocument();\n\n  private emitter: Emitter = mitt();\n\n  private nextUserInteractionEvent: eventWithTime | null;\n\n  private legacy_missingNodeRetryMap: missingNodeMap = {};\n\n  // The replayer uses the cache to speed up replay and scrubbing.\n  private cache: BuildCache = createCache();\n\n  private imageMap: Map<eventWithTime | string, HTMLImageElement> = new Map();\n  private canvasEventMap: Map<eventWithTime, canvasMutationParam> = new Map();\n\n  private mirror: Mirror = createMirror();\n\n  // Used to track StyleSheetObjects adopted on multiple document hosts.\n  private styleMirror: StyleSheetMirror = new StyleSheetMirror();\n\n  private firstFullSnapshot: eventWithTime | true | null = null;\n\n  private newDocumentQueue: addedNodeMutation[] = [];\n\n  // Map of pointer ID to the unique vars used to show pointers and their movements\n  private pointers: Record<\n    number,\n    {\n      touchActive: boolean | null;\n      pointerEl: HTMLDivElement;\n      tailPositions: Array<{ x: number; y: number }>;\n      pointerPosition: mouseMovePos | null;\n      mouseTail: HTMLCanvasElement | null;\n    }\n  > = {};\n  private lastMouseDownEvent: [Node, Event] | null = null;\n\n  // Keep the rootNode of the last hovered element. So  when hovering a new element, we can remove the last hovered element's :hover style.\n  private lastHoveredRootNode: Document | ShadowRoot;\n\n  // In the fast-forward mode, only the last selection data needs to be applied.\n  private lastSelectionData: selectionData | null = null;\n\n  // In the fast-forward mode using VirtualDom optimization, all stylesheetRule, and styleDeclaration events on constructed StyleSheets will be delayed to get applied until the flush stage.\n  private constructedStyleMutations: (\n    | styleSheetRuleData\n    | styleDeclarationData\n  )[] = [];\n\n  // Similar to the reason for constructedStyleMutations.\n  private adoptedStyleSheets: adoptedStyleSheetData[] = [];\n\n  constructor(\n    events: Array<eventWithTime | string>,\n    config?: Partial<playerConfig>,\n  ) {\n    if (!config?.liveMode && events.length < 2) {\n      throw new Error('Replayer need at least 2 events.');\n    }\n    const defaultConfig: playerConfig = {\n      speed: 1,\n      maxSpeed: 360,\n      root: document.body,\n      loadTimeout: 0,\n      skipInactive: false,\n      inactivePeriodThreshold: 10 * 1000,\n      showWarning: true,\n      showDebug: false,\n      blockClass: 'rr-block',\n      liveMode: false,\n      insertStyleRules: [],\n      triggerFocus: true,\n      UNSAFE_replayCanvas: false,\n      pauseAnimation: true,\n      mouseTail: defaultMouseTailConfig,\n      useVirtualDom: true, // Virtual-dom optimization is enabled by default.\n      logger: console,\n    };\n    this.config = Object.assign({}, defaultConfig, config);\n\n    this.handleResize = this.handleResize.bind(this);\n    this.getCastFn = this.getCastFn.bind(this);\n    this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);\n    this.emitter.on(ReplayerEvents.Resize, this.handleResize as Handler);\n\n    this.setupDom();\n\n    /**\n     * Exposes mirror to the plugins\n     */\n    for (const plugin of this.config.plugins || []) {\n      if (plugin.getMirror) plugin.getMirror({ nodeMirror: this.mirror });\n    }\n\n    this.emitter.on(ReplayerEvents.Flush, () => {\n      if (this.usingVirtualDom) {\n        const replayerHandler: ReplayerHandler = {\n          mirror: this.mirror,\n          applyCanvas: (\n            canvasEvent: canvasEventWithTime,\n            canvasMutationData: canvasMutationData,\n            target: HTMLCanvasElement,\n          ) => {\n            void canvasMutation({\n              event: canvasEvent,\n              mutation: canvasMutationData,\n              target,\n              imageMap: this.imageMap,\n              canvasEventMap: this.canvasEventMap,\n              errorHandler: this.warnCanvasMutationFailed.bind(this),\n            });\n          },\n          applyInput: this.applyInput.bind(this),\n          applyScroll: this.applyScroll.bind(this),\n          applyStyleSheetMutation: (\n            data: styleDeclarationData | styleSheetRuleData,\n            styleSheet: CSSStyleSheet,\n          ) => {\n            if (data.source === IncrementalSource.StyleSheetRule)\n              this.applyStyleSheetRule(data, styleSheet);\n            else if (data.source === IncrementalSource.StyleDeclaration)\n              this.applyStyleDeclaration(data, styleSheet);\n          },\n          afterAppend: (node: Node, id: number) => {\n            for (const plugin of this.config.plugins || []) {\n              if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });\n            }\n          },\n        };\n        const iframeDoc = getIFrameContentDocument(this.iframe);\n        if (iframeDoc)\n          try {\n            diff(\n              iframeDoc,\n              this.virtualDom,\n              replayerHandler,\n              this.virtualDom.mirror,\n            );\n          } catch (e) {\n            console.warn(e);\n          }\n\n        this.virtualDom.destroyTree();\n        this.usingVirtualDom = false;\n\n        // If these legacy missing nodes haven't been resolved, they should be converted to real Nodes.\n        if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n          for (const key in this.legacy_missingNodeRetryMap) {\n            try {\n              const value = this.legacy_missingNodeRetryMap[key];\n              const realNode = createOrGetNode(\n                value.node as RRNode,\n                this.mirror,\n                this.virtualDom.mirror,\n              );\n              diff(\n                realNode,\n                value.node as RRNode,\n                replayerHandler,\n                this.virtualDom.mirror,\n              );\n              value.node = realNode;\n            } catch (error) {\n              this.warn(error);\n            }\n          }\n        }\n\n        this.constructedStyleMutations.forEach((data) => {\n          this.applyStyleSheetMutation(data);\n        });\n        this.constructedStyleMutations = [];\n\n        this.adoptedStyleSheets.forEach((data) => {\n          this.applyAdoptedStyleSheet(data);\n        });\n        this.adoptedStyleSheets = [];\n      }\n\n      for (const [\n        pointerId,\n        { pointerPosition, touchActive },\n      ] of Object.entries(this.pointers)) {\n        const id = parseInt(pointerId);\n        const pointer = this.pointers[id];\n\n        if (pointerPosition) {\n          this.moveAndHover(\n            pointerPosition.x,\n            pointerPosition.y,\n            pointerPosition.id,\n            true,\n            pointerPosition.debugData,\n            id,\n          );\n          pointer.pointerPosition = null;\n        }\n\n        if (touchActive === true) {\n          pointer.pointerEl.classList.add('touch-active');\n        } else if (touchActive === false) {\n          pointer.pointerEl.classList.remove('touch-active');\n        }\n        pointer.touchActive = null;\n      }\n\n      if (this.lastMouseDownEvent) {\n        const [target, event] = this.lastMouseDownEvent;\n        target.dispatchEvent(event);\n      }\n      this.lastMouseDownEvent = null;\n\n      if (this.lastSelectionData) {\n        this.applySelection(this.lastSelectionData);\n        this.lastSelectionData = null;\n      }\n    });\n    this.emitter.on(ReplayerEvents.PlayBack, () => {\n      this.firstFullSnapshot = null;\n      this.mirror.reset();\n      this.styleMirror.reset();\n    });\n\n    const timer = new Timer([], {\n      speed: this.config.speed,\n    });\n    this.service = createPlayerService(\n      {\n        events: events\n          .map((e) => {\n            if (config && config.unpackFn) {\n              return config.unpackFn(e as string);\n            }\n            return e as eventWithTime;\n          })\n          .sort((a1, a2) => a1.timestamp - a2.timestamp),\n        timer,\n        timeOffset: 0,\n        baselineTime: 0,\n        lastPlayedEvent: null,\n      },\n      {\n        getCastFn: this.getCastFn,\n        applyEventsSynchronously: this.applyEventsSynchronously,\n        emitter: this.emitter,\n      },\n    );\n    this.service.start();\n    this.service.subscribe((state) => {\n      this.emitter.emit(ReplayerEvents.StateChange, {\n        player: state,\n      });\n    });\n    this.speedService = createSpeedService({\n      normalSpeed: -1,\n      timer,\n    });\n    this.speedService.start();\n    this.speedService.subscribe((state) => {\n      this.emitter.emit(ReplayerEvents.StateChange, {\n        speed: state,\n      });\n    });\n\n    // rebuild first full snapshot as the poster of the player\n    // maybe we can cache it for performance optimization\n    const firstMeta = this.service.state.context.events.find(\n      (e) => e.type === EventType.Meta,\n    );\n    const firstFullsnapshot = this.service.state.context.events.find(\n      (e) => e.type === EventType.FullSnapshot,\n    );\n    if (firstMeta) {\n      const { width, height } = firstMeta.data as metaEvent['data'];\n      setTimeout(() => {\n        this.emitter.emit(ReplayerEvents.Resize, {\n          width,\n          height,\n        });\n      }, 0);\n    }\n    if (firstFullsnapshot) {\n      setTimeout(() => {\n        // when something has been played, there is no need to rebuild poster\n        if (this.firstFullSnapshot) {\n          // true if any other fullSnapshot has been executed by Timer already\n          return;\n        }\n        this.firstFullSnapshot = firstFullsnapshot;\n        this.rebuildFullSnapshot(\n          firstFullsnapshot as fullSnapshotEvent & { timestamp: number },\n        );\n        this.iframe.contentWindow?.scrollTo(\n          (firstFullsnapshot as fullSnapshotEvent).data.initialOffset,\n        );\n      }, 1);\n    }\n  }\n\n  private createPointer(pointerId: number, event: eventWithTime) {\n    const mouseTail = document.createElement('canvas');\n    mouseTail.classList.add('replayer-mouse-tail');\n    mouseTail.width = Number.parseFloat(this.iframe.width);\n    mouseTail.height = Number.parseFloat(this.iframe.height);\n    this.wrapper.insertBefore(mouseTail, this.iframe);\n\n    mouseTail.style.display =\n      this.config.mouseTail === false ? 'none' : 'inherit';\n\n    const newMouse = document.createElement('div');\n    newMouse.classList.add('replayer-mouse');\n    this.pointers[pointerId] = {\n      touchActive: null,\n      pointerEl: newMouse,\n      tailPositions: [],\n      pointerPosition: null,\n      mouseTail,\n    };\n\n    if (indicatesTouchDevice(event)) {\n      newMouse.classList.add('touch-device');\n    }\n    this.wrapper.appendChild(newMouse);\n  }\n\n  public on(event: string, handler: Handler) {\n    this.emitter.on(event, handler);\n    return this;\n  }\n\n  public off(event: string, handler: Handler) {\n    this.emitter.off(event, handler);\n    return this;\n  }\n\n  public setConfig(config: Partial<playerConfig>) {\n    const previousSkipInactive = this.config.skipInactive;\n    Object.keys(config).forEach((key) => {\n      const newConfigValue = config[key as keyof playerConfig];\n      (this.config as Record<keyof playerConfig, typeof newConfigValue>)[\n        key as keyof playerConfig\n      ] = config[key as keyof playerConfig];\n    });\n    if (!this.config.skipInactive) {\n      this.backToNormal();\n    } else if (\n      previousSkipInactive === false &&\n      this.config.skipInactive === true\n    ) {\n      this.reevaluateFastForward();\n    }\n    if (typeof config.speed !== 'undefined') {\n      this.speedService.send({\n        type: 'SET_SPEED',\n        payload: {\n          speed: config.speed,\n        },\n      });\n    }\n    if (typeof config.mouseTail !== 'undefined') {\n      if (config.mouseTail === false) {\n        for (const { mouseTail } of Object.values(this.pointers)) {\n          if (mouseTail) {\n            mouseTail.style.display = 'none';\n          }\n        }\n      } else {\n        for (let { mouseTail } of Object.values(this.pointers)) {\n          if (!mouseTail) {\n            mouseTail = document.createElement('canvas');\n            mouseTail.width = Number.parseFloat(this.iframe.width);\n            mouseTail.height = Number.parseFloat(this.iframe.height);\n            mouseTail.classList.add('replayer-mouse-tail');\n            this.wrapper.insertBefore(mouseTail, this.iframe);\n          }\n          mouseTail.style.display = 'inherit';\n        }\n      }\n    }\n  }\n\n  public getMetaData(): playerMetaData {\n    const firstEvent = this.service.state.context.events[0];\n    const lastEvent =\n      this.service.state.context.events[\n        this.service.state.context.events.length - 1\n      ];\n    return {\n      startTime: firstEvent.timestamp,\n      endTime: lastEvent.timestamp,\n      totalTime: lastEvent.timestamp - firstEvent.timestamp,\n    };\n  }\n\n  public getCurrentTime(): number {\n    return this.timer.timeOffset + this.getTimeOffset();\n  }\n\n  public getTimeOffset(): number {\n    const { baselineTime, events } = this.service.state.context;\n    return baselineTime - events[0].timestamp;\n  }\n\n  public getMirror(): Mirror {\n    return this.mirror;\n  }\n\n  /**\n   * This API was designed to be used as play at any time offset.\n   * Since we minimized the data collected from recorder, we do not\n   * have the ability of undo an event.\n   * So the implementation of play at any time offset will always iterate\n   * all of the events, cast event before the offset synchronously\n   * and cast event after the offset asynchronously with timer.\n   * @param timeOffset - number\n   */\n  public play(timeOffset = 0) {\n    if (\n      this.config.skipInactive &&\n      this.speedService.state.matches('skipping')\n    ) {\n      this.backToNormal();\n    }\n    if (this.service.state.matches('paused')) {\n      this.service.send({ type: 'PLAY', payload: { timeOffset } });\n    } else {\n      this.service.send({ type: 'PAUSE' });\n      this.service.send({ type: 'PLAY', payload: { timeOffset } });\n    }\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    iframeDoc\n      ?.getElementsByTagName('html')[0]\n      ?.classList.remove('rrweb-paused');\n    this.emitter.emit(ReplayerEvents.Start);\n    if (this.config.skipInactive) {\n      this.reevaluateFastForward();\n    }\n  }\n\n  public pause(timeOffset?: number) {\n    if (timeOffset === undefined && this.service.state.matches('playing')) {\n      this.service.send({ type: 'PAUSE' });\n    }\n    if (typeof timeOffset === 'number') {\n      this.play(timeOffset);\n      this.service.send({ type: 'PAUSE' });\n    }\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    iframeDoc?.getElementsByTagName('html')[0]?.classList.add('rrweb-paused');\n    this.emitter.emit(ReplayerEvents.Pause);\n  }\n\n  public resume(timeOffset = 0) {\n    this.warn(\n      `The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface.`,\n    );\n    this.play(timeOffset);\n    this.emitter.emit(ReplayerEvents.Resume);\n  }\n\n  /**\n   * Totally destroy this replayer and please be careful that this operation is irreversible.\n   * Memory occupation can be released by removing all references to this replayer.\n   */\n  public destroy() {\n    this.pause();\n    this.config.root.removeChild(this.wrapper);\n    this.emitter.emit(ReplayerEvents.Destroy);\n  }\n\n  public startLive(baselineTime?: number) {\n    this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });\n  }\n\n  public addEvent(rawEvent: eventWithTime | string) {\n    const event = this.config.unpackFn\n      ? this.config.unpackFn(rawEvent as string)\n      : (rawEvent as eventWithTime);\n\n    void Promise.resolve().then(() =>\n      this.service.send({ type: 'ADD_EVENT', payload: { event } }),\n    );\n  }\n\n  public enableInteract() {\n    this.iframe.setAttribute('scrolling', 'auto');\n    this.iframe.style.pointerEvents = 'auto';\n  }\n\n  public disableInteract() {\n    this.iframe.setAttribute('scrolling', 'no');\n    this.iframe.style.pointerEvents = 'none';\n  }\n\n  /**\n   * Empties the replayer's cache and reclaims memory.\n   * The replayer will use this cache to speed up the playback.\n   */\n  public resetCache() {\n    this.cache = createCache();\n  }\n\n  private reevaluateFastForward(): void {\n    if (!this.config.skipInactive) {\n      return;\n    }\n\n    // Clear stale state\n    this.nextUserInteractionEvent = null;\n\n    // Get current time and convert to event-relative time\n    const events = this.service.state.context.events;\n    const firstEvent = events[0];\n    if (!firstEvent) {\n      return;\n    }\n    const currentEventTime = firstEvent.timestamp + this.getCurrentTime();\n\n    // Find current event index\n    const currentEventIndex = getEventIndex(events, currentEventTime);\n    if (currentEventIndex === -1) {\n      return;\n    }\n\n    // Find next user interaction event starting from the current event index\n    const currentEvent = events[currentEventIndex];\n    const threshold =\n      this.config.inactivePeriodThreshold *\n      this.speedService.state.context.timer.speed;\n    for (let i = currentEventIndex + 1; i < events.length; i++) {\n      const event = events[i];\n      if (this.isUserInteraction(event)) {\n        const gapTime = event.timestamp - currentEvent.timestamp;\n        // Fast forward if the gap time is greater than the threshold\n        if (gapTime > threshold) {\n          this.nextUserInteractionEvent = event;\n          const payload = {\n            speed: Math.min(\n              Math.round(gapTime / SKIP_TIME_INTERVAL),\n              this.config.maxSpeed,\n            ),\n          };\n          this.speedService.send({ type: 'FAST_FORWARD', payload });\n          this.emitter.emit(ReplayerEvents.SkipStart, payload);\n        }\n        break;\n      }\n    }\n  }\n\n  private setupDom() {\n    this.wrapper = document.createElement('div');\n    this.wrapper.classList.add('replayer-wrapper');\n    this.config.root.appendChild(this.wrapper);\n\n    this.iframe = document.createElement('iframe');\n    const attributes = ['allow-same-origin'];\n    if (this.config.UNSAFE_replayCanvas) {\n      attributes.push('allow-scripts');\n    }\n    // hide iframe before first meta event\n    this.iframe.style.display = 'none';\n    this.iframe.setAttribute('sandbox', attributes.join(' '));\n    this.disableInteract();\n    this.wrapper.appendChild(this.iframe);\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    const iframeWindow = getIFrameContentWindow(this.iframe);\n    if (iframeWindow && iframeDoc) {\n      smoothscrollPolyfill(iframeWindow, iframeDoc);\n      polyfill(iframeWindow as IWindow);\n    }\n  }\n\n  private handleResize = (dimension: viewportResizeDimension) => {\n    this.iframe.style.display = 'inherit';\n\n    for (const el of [\n      ...Object.values(this.pointers).flatMap((a) => a.mouseTail),\n      this.iframe,\n    ]) {\n      if (!el) {\n        continue;\n      }\n      el.setAttribute('width', String(dimension.width));\n      el.setAttribute('height', String(dimension.height));\n    }\n  };\n\n  private applyEventsSynchronously = (events: Array<eventWithTime>) => {\n    for (const event of events) {\n      switch (event.type) {\n        case EventType.DomContentLoaded:\n        case EventType.Load:\n        case EventType.Custom:\n          continue;\n        case EventType.FullSnapshot:\n        case EventType.Meta:\n        case EventType.Plugin:\n        case EventType.IncrementalSnapshot:\n          break;\n        default:\n          break;\n      }\n      const castFn = this.getCastFn(event, true);\n      castFn();\n    }\n  };\n\n  private getCastFn = (event: eventWithTime, isSync = false) => {\n    let castFn: undefined | (() => void);\n    switch (event.type) {\n      case EventType.DomContentLoaded:\n      case EventType.Load:\n        break;\n      case EventType.Custom:\n        castFn = () => {\n          /**\n           * emit custom-event and pass the event object.\n           *\n           * This will add more value to the custom event and allows the client to react for custom-event.\n           */\n          this.emitter.emit(ReplayerEvents.CustomEvent, event);\n        };\n        break;\n      case EventType.Meta:\n        castFn = () =>\n          this.emitter.emit(ReplayerEvents.Resize, {\n            width: event.data.width,\n            height: event.data.height,\n          });\n        break;\n      case EventType.FullSnapshot:\n        castFn = () => {\n          if (this.firstFullSnapshot) {\n            if (this.firstFullSnapshot === event) {\n              // we've already built this exact FullSnapshot when the player was mounted, and haven't built any other FullSnapshot since\n              this.firstFullSnapshot = true; // forget as we might need to re-execute this FullSnapshot later e.g. to rebuild after scrubbing\n              return;\n            }\n          } else {\n            // Timer (requestAnimationFrame) can be faster than setTimeout(..., 1)\n            this.firstFullSnapshot = true;\n          }\n          this.rebuildFullSnapshot(event, isSync);\n          this.iframe.contentWindow?.scrollTo(event.data.initialOffset);\n          this.styleMirror.reset();\n        };\n        break;\n      case EventType.IncrementalSnapshot:\n        castFn = () => {\n          this.applyIncremental(event, isSync);\n          if (isSync) {\n            // do not check skip in sync\n            return;\n          }\n          if (event === this.nextUserInteractionEvent) {\n            this.nextUserInteractionEvent = null;\n            this.backToNormal();\n          }\n          if (this.config.skipInactive && !this.nextUserInteractionEvent) {\n            for (const _event of this.service.state.context.events) {\n              if (_event.timestamp <= event.timestamp) {\n                continue;\n              }\n              if (this.isUserInteraction(_event)) {\n                if (\n                  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n                  _event.delay! - event.delay! >\n                  this.config.inactivePeriodThreshold *\n                    this.speedService.state.context.timer.speed\n                ) {\n                  this.nextUserInteractionEvent = _event;\n                }\n                break;\n              }\n            }\n            if (this.nextUserInteractionEvent) {\n              const skipTime =\n                // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n                this.nextUserInteractionEvent.delay! - event.delay!;\n              const payload = {\n                speed: Math.min(\n                  Math.round(skipTime / SKIP_TIME_INTERVAL),\n                  this.config.maxSpeed,\n                ),\n              };\n              this.speedService.send({ type: 'FAST_FORWARD', payload });\n              this.emitter.emit(ReplayerEvents.SkipStart, payload);\n            }\n          }\n        };\n        break;\n      default:\n    }\n    const wrappedCastFn = () => {\n      if (castFn) {\n        castFn();\n      }\n\n      for (const plugin of this.config.plugins || []) {\n        if (plugin.handler) plugin.handler(event, isSync, { replayer: this });\n      }\n\n      this.service.send({ type: 'CAST_EVENT', payload: { event } });\n\n      // events are kept sorted by timestamp, check if this is the last event\n      const last_index = this.service.state.context.events.length - 1;\n      if (\n        !this.config.liveMode &&\n        event === this.service.state.context.events[last_index]\n      ) {\n        const finish = () => {\n          if (last_index < this.service.state.context.events.length - 1) {\n            // more events have been added since the setTimeout\n            return;\n          }\n          this.backToNormal();\n          this.service.send('END');\n          this.emitter.emit(ReplayerEvents.Finish);\n        };\n        let finish_buffer = 50; // allow for checking whether new events aren't just about to be loaded in\n        if (\n          event.type === EventType.IncrementalSnapshot &&\n          event.data.source === IncrementalSource.MouseMove &&\n          event.data.positions.length\n        ) {\n          // extend finish event if the last event is a mouse move so that the timer isn't stopped by the service before checking the last event\n          finish_buffer += Math.max(0, -event.data.positions[0].timeOffset);\n        }\n        setTimeout(finish, finish_buffer);\n      }\n\n      this.emitter.emit(ReplayerEvents.EventCast, event);\n    };\n    return wrappedCastFn;\n  };\n\n  private rebuildFullSnapshot(\n    event: fullSnapshotEvent & { timestamp: number },\n    isSync = false,\n  ) {\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    if (!iframeDoc) {\n      return this.warn('Looks like your replayer has been destroyed.');\n    }\n    if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n      this.warn(\n        'Found unresolved missing node map',\n        this.legacy_missingNodeRetryMap,\n      );\n    }\n    this.legacy_missingNodeRetryMap = {};\n    const collected: AppendedIframe[] = [];\n    const afterAppend = (builtNode: Node, id: number) => {\n      this.collectIframeAndAttachDocument(collected, builtNode);\n      for (const plugin of this.config.plugins || []) {\n        if (plugin.onBuild)\n          plugin.onBuild(builtNode, {\n            id,\n            replayer: this,\n          });\n      }\n    };\n\n    /**\n     * Normally rebuilding full snapshot should not be under virtual dom environment.\n     * But if the order of data events has some issues, it might be possible.\n     * Adding this check to avoid any potential issues.\n     */\n    if (this.usingVirtualDom) {\n      this.virtualDom.destroyTree();\n      this.usingVirtualDom = false;\n    }\n\n    this.mirror.reset();\n    rebuild(event.data.node, {\n      doc: iframeDoc,\n      afterAppend,\n      cache: this.cache,\n      mirror: this.mirror,\n    });\n    afterAppend(iframeDoc, event.data.node.id);\n\n    for (const { mutationInQueue, builtNode } of collected) {\n      this.attachDocumentToIframe(mutationInQueue, builtNode);\n      this.newDocumentQueue = this.newDocumentQueue.filter(\n        (m) => m !== mutationInQueue,\n      );\n    }\n    const { documentElement, head } = iframeDoc;\n    this.insertStyleRules(documentElement, head);\n    if (!this.service.state.matches('playing')) {\n      const iframeHtmlElement = iframeDoc.getElementsByTagName('html')[0];\n\n      iframeHtmlElement && iframeHtmlElement.classList.add('rrweb-paused');\n    }\n    this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);\n    if (!isSync) {\n      this.waitForStylesheetLoad();\n    }\n    if (this.config.UNSAFE_replayCanvas) {\n      void this.preloadAllImages();\n    }\n  }\n\n  private insertStyleRules(\n    documentElement: HTMLElement | RRElement,\n    head: HTMLHeadElement | RRElement,\n  ) {\n    const injectStylesRules = getInjectStyleRules(\n      this.config.blockClass,\n    ).concat(this.config.insertStyleRules);\n    if (this.config.pauseAnimation) {\n      injectStylesRules.push(\n        'html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }',\n      );\n    }\n    if (this.usingVirtualDom) {\n      const styleEl = this.virtualDom.createElement('style');\n      this.virtualDom.mirror.add(\n        styleEl,\n        getDefaultSN(styleEl, this.virtualDom.unserializedId),\n      );\n      (documentElement as RRElement).insertBefore(styleEl, head as RRElement);\n      styleEl.rules.push({\n        source: IncrementalSource.StyleSheetRule,\n        adds: injectStylesRules.map((cssText, index) => ({\n          rule: cssText,\n          index,\n        })),\n      });\n    } else {\n      const styleEl = document.createElement('style');\n      (documentElement as HTMLElement).insertBefore(\n        styleEl,\n        head as HTMLHeadElement,\n      );\n      for (let idx = 0; idx < injectStylesRules.length; idx++) {\n        styleEl.sheet?.insertRule(injectStylesRules[idx], idx);\n      }\n    }\n  }\n\n  private attachDocumentToIframe(\n    mutation: addedNodeMutation,\n    iframeEl: HTMLIFrameElement | RRIFrameElement,\n  ) {\n    const mirror: RRDOMMirror | Mirror = this.usingVirtualDom\n      ? this.virtualDom.mirror\n      : this.mirror;\n    type TNode = typeof mirror extends Mirror ? Node : RRNode;\n    type TMirror = typeof mirror extends Mirror ? Mirror : RRDOMMirror;\n    const iframeContentDoc = getIFrameContentDocument(\n      iframeEl as HTMLIFrameElement,\n    );\n\n    const collected: AppendedIframe[] = [];\n    const afterAppend = (builtNode: Node, id: number) => {\n      this.collectIframeAndAttachDocument(collected, builtNode);\n      const sn = (mirror as TMirror).getMeta(builtNode as unknown as TNode);\n      if (\n        sn?.type === NodeType.Element &&\n        sn?.tagName.toUpperCase() === 'HTML' &&\n        iframeContentDoc\n      ) {\n        const { documentElement, head } = iframeContentDoc;\n        this.insertStyleRules(\n          documentElement as HTMLElement | RRElement,\n          head as HTMLElement | RRElement,\n        );\n      }\n\n      // Skip the plugin onBuild callback in the virtual dom mode\n      if (this.usingVirtualDom) return;\n      for (const plugin of this.config.plugins || []) {\n        if (plugin.onBuild)\n          plugin.onBuild(builtNode, {\n            id,\n            replayer: this,\n          });\n      }\n    };\n\n    buildNodeWithSN(mutation.node, {\n      doc: iframeContentDoc as Document,\n      mirror: mirror as Mirror,\n      hackCss: true,\n      skipChild: false,\n      afterAppend,\n      cache: this.cache,\n    });\n    afterAppend(iframeContentDoc as Document, mutation.node.id);\n\n    for (const { mutationInQueue, builtNode } of collected) {\n      this.attachDocumentToIframe(mutationInQueue, builtNode);\n      this.newDocumentQueue = this.newDocumentQueue.filter(\n        (m) => m !== mutationInQueue,\n      );\n    }\n  }\n\n  private collectIframeAndAttachDocument(\n    collected: AppendedIframe[],\n    builtNode: Node,\n  ) {\n    if (isSerializedIframe(builtNode, this.mirror)) {\n      const mutationInQueue = this.newDocumentQueue.find(\n        (m) => m.parentId === this.mirror.getId(builtNode),\n      );\n      if (mutationInQueue) {\n        collected.push({\n          mutationInQueue,\n          builtNode: builtNode as HTMLIFrameElement,\n        });\n      }\n    }\n  }\n\n  /**\n   * pause when loading style sheet, resume when loaded all timeout exceed\n   */\n  private waitForStylesheetLoad() {\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    const head = iframeDoc?.head;\n    if (head) {\n      const unloadSheets: Set<HTMLLinkElement> = new Set();\n      let timer: ReturnType<typeof setTimeout> | -1;\n      let beforeLoadState = this.service.state;\n      const stateHandler = () => {\n        beforeLoadState = this.service.state;\n      };\n      this.emitter.on(ReplayerEvents.Start, stateHandler);\n      this.emitter.on(ReplayerEvents.Pause, stateHandler);\n      const unsubscribe = () => {\n        this.emitter.off(ReplayerEvents.Start, stateHandler);\n        this.emitter.off(ReplayerEvents.Pause, stateHandler);\n      };\n      head\n        .querySelectorAll('link[rel=\"stylesheet\"]')\n        .forEach((css: HTMLLinkElement) => {\n          if (!css.sheet) {\n            unloadSheets.add(css);\n            css.addEventListener('load', () => {\n              unloadSheets.delete(css);\n              // all loaded and timer not released yet\n              if (unloadSheets.size === 0 && timer !== -1) {\n                if (beforeLoadState.matches('playing')) {\n                  this.play(this.getCurrentTime());\n                }\n                this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);\n                if (timer) {\n                  clearTimeout(timer);\n                }\n                unsubscribe();\n              }\n            });\n          }\n        });\n\n      if (unloadSheets.size > 0) {\n        // find some unload sheets after iterate\n        this.service.send({ type: 'PAUSE' });\n        this.emitter.emit(ReplayerEvents.LoadStylesheetStart);\n        timer = setTimeout(() => {\n          if (beforeLoadState.matches('playing')) {\n            this.play(this.getCurrentTime());\n          }\n          // mark timer was called\n          timer = -1;\n          unsubscribe();\n        }, this.config.loadTimeout);\n      }\n    }\n  }\n\n  /**\n   * pause when there are some canvas drawImage args need to be loaded\n   */\n  private async preloadAllImages(): Promise<void[]> {\n    const promises: Promise<void>[] = [];\n    for (const event of this.service.state.context.events) {\n      if (\n        event.type === EventType.IncrementalSnapshot &&\n        event.data.source === IncrementalSource.CanvasMutation\n      ) {\n        promises.push(\n          this.deserializeAndPreloadCanvasEvents(event.data, event),\n        );\n        const commands =\n          'commands' in event.data ? event.data.commands : [event.data];\n        commands.forEach((c) => {\n          this.preloadImages(c, event);\n        });\n      }\n    }\n    return Promise.all(promises);\n  }\n\n  private preloadImages(data: canvasMutationCommand, event: eventWithTime) {\n    if (\n      data.property === 'drawImage' &&\n      typeof data.args[0] === 'string' &&\n      !this.imageMap.has(event)\n    ) {\n      const canvas = document.createElement('canvas');\n      const ctx = canvas.getContext('2d');\n      const imgd = ctx?.createImageData(canvas.width, canvas.height);\n      ctx?.putImageData(imgd!, 0, 0);\n    }\n  }\n  private async deserializeAndPreloadCanvasEvents(\n    data: canvasMutationData,\n    event: eventWithTime,\n  ) {\n    if (!this.canvasEventMap.has(event)) {\n      const status = {\n        isUnchanged: true,\n      };\n      if ('commands' in data) {\n        const commands = await Promise.all(\n          data.commands.map(async (c) => {\n            const args = await Promise.all(\n              c.args.map(deserializeArg(this.imageMap, null, status)),\n            );\n            return { ...c, args };\n          }),\n        );\n        if (status.isUnchanged === false)\n          this.canvasEventMap.set(event, { ...data, commands });\n      } else {\n        const args = await Promise.all(\n          data.args.map(deserializeArg(this.imageMap, null, status)),\n        );\n        if (status.isUnchanged === false)\n          this.canvasEventMap.set(event, { ...data, args });\n      }\n    }\n  }\n\n  private applyIncremental(\n    e: incrementalSnapshotEvent & { timestamp: number; delay?: number },\n    isSync: boolean,\n  ) {\n    const { data: d } = e;\n    switch (d.source) {\n      case IncrementalSource.Mutation: {\n        try {\n          this.applyMutation(d, isSync);\n        } catch (error) {\n          // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions\n          this.warn(`Exception in mutation ${error.message || error}`, d);\n        }\n        break;\n      }\n      case IncrementalSource.Drag:\n      case IncrementalSource.TouchMove:\n      case IncrementalSource.MouseMove: {\n        const pointerId = getPointerId(d);\n        if (!this.pointers[pointerId]) {\n          this.createPointer(pointerId, e);\n        }\n\n        const pointer = this.pointers[pointerId];\n\n        if (isSync) {\n          const lastPosition = d.positions[d.positions.length - 1];\n          pointer.pointerPosition = {\n            x: lastPosition.x,\n            y: lastPosition.y,\n            id: lastPosition.id,\n            debugData: d,\n          };\n        } else {\n          d.positions.forEach((p) => {\n            const action = {\n              doAction: () => {\n                this.moveAndHover(p.x, p.y, p.id, isSync, d, pointerId);\n              },\n              delay:\n                p.timeOffset +\n                e.timestamp -\n                this.service.state.context.baselineTime,\n            };\n            this.timer.addAction(action);\n          });\n          // add a dummy action to keep timer alive\n          this.timer.addAction({\n            doAction() {\n              //\n            },\n            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n            delay: e.delay! - d.positions[0]?.timeOffset,\n          });\n        }\n        break;\n      }\n      case IncrementalSource.MouseInteraction: {\n        const pointerId = getPointerId(d);\n        if (!this.pointers[pointerId]) {\n          this.createPointer(pointerId, e);\n        }\n\n        const pointer = this.pointers[pointerId];\n\n        /**\n         * Same as the situation of missing input target.\n         */\n        if (d.id === -1) {\n          break;\n        }\n        const event = new Event(toLowerCase(MouseInteractions[d.type]));\n        const target = this.mirror.getNode(d.id);\n        if (!target) {\n          return this.debugNodeNotFound(d, d.id);\n        }\n        this.emitter.emit(ReplayerEvents.MouseInteraction, {\n          type: d.type,\n          target,\n        });\n        const { triggerFocus } = this.config;\n        switch (d.type) {\n          case MouseInteractions.Blur:\n            if ('blur' in (target as HTMLElement)) {\n              (target as HTMLElement).blur();\n            }\n            break;\n          case MouseInteractions.Focus:\n            if (triggerFocus && (target as HTMLElement).focus) {\n              (target as HTMLElement).focus({\n                preventScroll: true,\n              });\n            }\n            break;\n          case MouseInteractions.Click:\n          case MouseInteractions.TouchStart:\n          case MouseInteractions.TouchEnd:\n          case MouseInteractions.MouseDown:\n          case MouseInteractions.MouseUp:\n            if (isSync) {\n              if (d.type === MouseInteractions.TouchStart) {\n                pointer.touchActive = true;\n\n                // prevents multiple touch circles from staying on the screen\n                // when the user seeks by breadcrumbs\n                Object.values(this.pointers).forEach((p) => {\n                  // don't set p.touchActive to false if p.touchActive is already true\n                  // so that multitouch still works.\n                  // p.touchActive can be null (in which case\n                  // we still want to set it as false) - it's set as null\n                  // in the ReplayerEvents.Flush handler after\n                  // the 'touch-active' class is added or removed.\n                  if (p !== pointer && !p.touchActive) {\n                    p.touchActive = false;\n                  }\n                });\n              } else if (d.type === MouseInteractions.TouchEnd) {\n                pointer.touchActive = false;\n                pointer.pointerEl.remove();\n                if (pointer.mouseTail) {\n                  pointer.mouseTail.remove();\n                }\n                delete this.pointers[pointerId];\n              }\n              if (d.type === MouseInteractions.MouseDown) {\n                this.lastMouseDownEvent = [target, event];\n              } else if (d.type === MouseInteractions.MouseUp) {\n                this.lastMouseDownEvent = null;\n              }\n              pointer.pointerPosition = {\n                x: d.x || 0,\n                y: d.y || 0,\n                id: d.id,\n                debugData: d,\n              };\n            } else {\n              if (d.type === MouseInteractions.TouchStart) {\n                // don't draw a trail as user has lifted finger and is placing at a new point\n                pointer.tailPositions.length = 0;\n              }\n              this.moveAndHover(d.x || 0, d.y || 0, d.id, isSync, d, pointerId);\n              if (d.type === MouseInteractions.Click) {\n                /*\n                 * don't want target.click() here as could trigger an iframe navigation\n                 * instead any effects of the click should already be covered by mutations\n                 */\n                /*\n                 * removal and addition of .active class (along with void line to trigger repaint)\n                 * triggers the 'click' css animation in styles/style.css\n                 */\n                pointer.pointerEl.classList.remove('active');\n                void pointer.pointerEl.offsetWidth;\n                pointer.pointerEl.classList.add('active');\n              } else if (d.type === MouseInteractions.TouchStart) {\n                void pointer.pointerEl.offsetWidth; // needed for the position update of moveAndHover to apply without the .touch-active transition\n                pointer.pointerEl.classList.add('touch-active');\n              } else if (d.type === MouseInteractions.TouchEnd) {\n                pointer.pointerEl.remove();\n                if (pointer.mouseTail) {\n                  pointer.mouseTail.remove();\n                }\n                delete this.pointers[pointerId];\n              } else {\n                // for MouseDown & MouseUp also invoke default behavior\n                target.dispatchEvent(event);\n              }\n            }\n            break;\n          case MouseInteractions.TouchCancel:\n            if (isSync) {\n              pointer.touchActive = false;\n            } else {\n              pointer.pointerEl.classList.remove('touch-active');\n            }\n            break;\n          default:\n            target.dispatchEvent(event);\n        }\n        break;\n      }\n      case IncrementalSource.Scroll: {\n        /**\n         * Same as the situation of missing input target.\n         */\n        if (d.id === -1) {\n          break;\n        }\n        if (this.usingVirtualDom) {\n          const target = this.virtualDom.mirror.getNode(d.id) as RRElement;\n          if (!target) {\n            return this.debugNodeNotFound(d, d.id);\n          }\n          target.scrollData = d;\n          break;\n        }\n        // Use isSync rather than this.usingVirtualDom because not every fast-forward process uses virtual dom optimization.\n        this.applyScroll(d, isSync);\n        break;\n      }\n      case IncrementalSource.ViewportResize:\n        this.emitter.emit(ReplayerEvents.Resize, {\n          width: d.width,\n          height: d.height,\n        });\n        break;\n      case IncrementalSource.Input: {\n        /**\n         * Input event on an unserialized node usually means the event\n         * was synchrony triggered programmatically after the node was\n         * created. This means there was not an user observable interaction\n         * and we do not need to replay it.\n         */\n        if (d.id === -1) {\n          break;\n        }\n        if (this.usingVirtualDom) {\n          const target = this.virtualDom.mirror.getNode(d.id) as RRElement;\n          if (!target) {\n            return this.debugNodeNotFound(d, d.id);\n          }\n          target.inputData = d;\n          break;\n        }\n        this.applyInput(d);\n        break;\n      }\n      case IncrementalSource.MediaInteraction: {\n        const target = this.usingVirtualDom\n          ? this.virtualDom.mirror.getNode(d.id)\n          : this.mirror.getNode(d.id);\n        if (!target) {\n          return this.debugNodeNotFound(d, d.id);\n        }\n        const mediaEl = target as HTMLMediaElement | RRMediaElement;\n        try {\n          if (d.currentTime !== undefined) {\n            mediaEl.currentTime = d.currentTime;\n          }\n          if (d.volume !== undefined) {\n            mediaEl.volume = d.volume;\n          }\n          if (d.muted !== undefined) {\n            mediaEl.muted = d.muted;\n          }\n          if (d.type === MediaInteractions.Pause) {\n            mediaEl.pause();\n          }\n          if (d.type === MediaInteractions.Play) {\n            // remove listener for 'canplay' event because play() is async and returns a promise\n            // i.e. media will evntualy start to play when data is loaded\n            // 'canplay' event fires even when currentTime attribute changes which may lead to\n            // unexpeted behavior\n            const maybePlayPromise = mediaEl.play();\n\n            if (typeof maybePlayPromise?.catch === 'function') {\n              maybePlayPromise.catch((err) => {\n                // ignore rejections from play() as they are not useful and\n                // quite noisy. some examples:\n                // AbortError: The play() request was interrupted by a call to pause(). https://goo.gl/LdLk22\n                // AbortError: The play() request was interrupted by a new load request. https://goo.gl/LdLk22\n                // AbortError: The play() request was interrupted by a call to pause().\n                // NotAllowedError: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD\n                // AbortError: The play() request was interrupted because the media was removed from the document.\n                // AbortError: The play() request was interrupted because video-only background media was paused to save power. https://goo.gl/LdLk22\n                // NotAllowedError: play() failed because the user didn't interact with the document first.\n                // NotAllowedError: play() can only be initiated by a user gesture.\n                // AbortError: The play() request was interrupted by end of playback. https://goo.gl/LdLk22\n                console.warn(err);\n              });\n            }\n          }\n          if (d.type === MediaInteractions.RateChange) {\n            mediaEl.playbackRate = d.playbackRate;\n          }\n        } catch (error) {\n          this.warn(\n            // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions\n            `Failed to replay media interactions: ${error.message || error}`,\n          );\n        }\n        break;\n      }\n      case IncrementalSource.StyleSheetRule:\n      case IncrementalSource.StyleDeclaration: {\n        if (this.usingVirtualDom) {\n          if (d.styleId) this.constructedStyleMutations.push(d);\n          else if (d.id)\n            (\n              this.virtualDom.mirror.getNode(d.id) as RRStyleElement | null\n            )?.rules?.push(d);\n        } else this.applyStyleSheetMutation(d);\n        break;\n      }\n      case IncrementalSource.CanvasMutation: {\n        if (!this.config.UNSAFE_replayCanvas) {\n          return;\n        }\n        if (this.usingVirtualDom) {\n          const target = this.virtualDom.mirror.getNode(\n            d.id,\n          ) as RRCanvasElement;\n          if (!target) {\n            return this.debugNodeNotFound(d, d.id);\n          }\n          target.canvasMutations.push({\n            event: e as canvasEventWithTime,\n            mutation: d,\n          });\n        } else {\n          const target = this.mirror.getNode(d.id);\n          if (!target) {\n            return this.debugNodeNotFound(d, d.id);\n          }\n          void canvasMutation({\n            event: e,\n            mutation: d,\n            target: target as HTMLCanvasElement,\n            imageMap: this.imageMap,\n            canvasEventMap: this.canvasEventMap,\n            errorHandler: this.warnCanvasMutationFailed.bind(this),\n          });\n        }\n        break;\n      }\n      case IncrementalSource.Font: {\n        try {\n          const fontFace = new FontFace(\n            d.family,\n            d.buffer\n              ? new Uint8Array(JSON.parse(d.fontSource) as Iterable<number>)\n              : d.fontSource,\n            d.descriptors,\n          );\n          getIFrameContentDocument(this.iframe)?.fonts.add(fontFace);\n        } catch (error) {\n          this.warn(error);\n        }\n        break;\n      }\n      case IncrementalSource.Selection: {\n        if (isSync) {\n          this.lastSelectionData = d;\n          break;\n        }\n        this.applySelection(d);\n        break;\n      }\n      case IncrementalSource.AdoptedStyleSheet: {\n        if (this.usingVirtualDom) this.adoptedStyleSheets.push(d);\n        else this.applyAdoptedStyleSheet(d);\n        break;\n      }\n      default:\n    }\n  }\n\n  private applyMutation(d: mutationData, isSync: boolean) {\n    // Only apply virtual dom optimization if the fast-forward process has node mutation. Because the cost of creating a virtual dom tree and executing the diff algorithm is usually higher than directly applying other kind of events.\n    if (this.config.useVirtualDom && !this.usingVirtualDom && isSync) {\n      this.usingVirtualDom = true;\n      const iframeDoc = getIFrameContentDocument(this.iframe);\n      if (iframeDoc) {\n        buildFromDom(iframeDoc, this.mirror, this.virtualDom);\n      }\n      // If these legacy missing nodes haven't been resolved, they should be converted to virtual nodes.\n      if (Object.keys(this.legacy_missingNodeRetryMap).length) {\n        for (const key in this.legacy_missingNodeRetryMap) {\n          try {\n            const value = this.legacy_missingNodeRetryMap[key];\n            const virtualNode = buildFromNode(\n              value.node as Node,\n              this.virtualDom,\n              this.mirror,\n            );\n            if (virtualNode) value.node = virtualNode;\n          } catch (error) {\n            this.warn(error);\n          }\n        }\n      }\n    }\n    const mirror = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;\n    type TNode = typeof mirror extends Mirror ? Node : RRNode;\n\n    d.removes = d.removes.filter((mutation) => {\n      // warn of absence from mirror before we start applying each removal\n      // as earlier removals could remove a tree that includes a later removal\n      if (!mirror.getNode(mutation.id)) {\n        this.warnNodeNotFound(d, mutation.id);\n        return false;\n      }\n      return true;\n    });\n    d.removes.forEach((mutation) => {\n      const target = mirror.getNode(mutation.id);\n      if (!target) {\n        // no need to warn here, an ancestor may have already been removed\n        return;\n      }\n      let parent: Node | null | ShadowRoot | RRNode = mirror.getNode(\n        mutation.parentId,\n      );\n      if (!parent) {\n        return this.warnNodeNotFound(d, mutation.parentId);\n      }\n      if (mutation.isShadow && hasShadowRoot(parent as Node)) {\n        parent = (parent as Element | RRElement).shadowRoot;\n      }\n      // target may be removed with its parents before\n      mirror.removeNodeFromMap(target as Node & RRNode);\n      if (parent)\n        try {\n          parent.removeChild(target as Node & RRNode);\n          /**\n           * https://github.com/rrweb-io/rrweb/pull/887\n           * Remove any virtual style rules for stylesheets if a child text node is removed.\n           */\n          if (\n            this.usingVirtualDom &&\n            target.nodeName === '#text' &&\n            parent.nodeName === 'STYLE' &&\n            (parent as RRStyleElement).rules?.length > 0\n          )\n            (parent as RRStyleElement).rules = [];\n        } catch (error) {\n          if (error instanceof DOMException) {\n            this.warn(\n              'parent could not remove child in mutation',\n              parent,\n              target,\n              d,\n            );\n          } else {\n            throw error;\n          }\n        }\n    });\n\n    const legacy_missingNodeMap: missingNodeMap = {\n      ...this.legacy_missingNodeRetryMap,\n    };\n    const queue: addedNodeMutation[] = [];\n\n    // next not present at this moment\n    const nextNotInDOM = (mutation: addedNodeMutation) => {\n      let next: TNode | null = null;\n      if (mutation.nextId) {\n        next = mirror.getNode(mutation.nextId) as TNode | null;\n      }\n      // next not present at this moment\n      if (\n        mutation.nextId !== null &&\n        mutation.nextId !== undefined &&\n        mutation.nextId !== -1 &&\n        !next\n      ) {\n        return true;\n      }\n      return false;\n    };\n\n    const appendNode = (mutation: addedNodeMutation) => {\n      const iframeDoc = getIFrameContentDocument(this.iframe);\n      if (!iframeDoc) {\n        return this.warn('Looks like your replayer has been destroyed.');\n      }\n      let parent: Node | null | ShadowRoot | RRNode = mirror.getNode(\n        mutation.parentId,\n      );\n      if (!parent) {\n        if (mutation.node.type === NodeType.Document) {\n          // is newly added document, maybe the document node of an iframe\n          return this.newDocumentQueue.push(mutation);\n        }\n        return queue.push(mutation);\n      }\n\n      if (mutation.node.isShadow) {\n        // If the parent is attached a shadow dom after it's created, it won't have a shadow root.\n        if (!hasShadowRoot(parent)) {\n          (parent as Element | RRElement).attachShadow({ mode: 'open' });\n          parent = (parent as Element | RRElement).shadowRoot! as Node | RRNode;\n        } else parent = parent.shadowRoot as Node | RRNode;\n      }\n\n      let previous: Node | RRNode | null = null;\n      let next: Node | RRNode | null = null;\n      if (mutation.previousId) {\n        previous = mirror.getNode(mutation.previousId);\n      }\n      if (mutation.nextId) {\n        next = mirror.getNode(mutation.nextId);\n      }\n      if (nextNotInDOM(mutation)) {\n        return queue.push(mutation);\n      }\n\n      if (mutation.node.rootId && !mirror.getNode(mutation.node.rootId)) {\n        return;\n      }\n\n      const targetDoc = mutation.node.rootId\n        ? mirror.getNode(mutation.node.rootId)\n        : this.usingVirtualDom\n        ? this.virtualDom\n        : iframeDoc;\n      if (isSerializedIframe<typeof parent>(parent, mirror)) {\n        this.attachDocumentToIframe(\n          mutation,\n          parent as HTMLIFrameElement | RRIFrameElement,\n        );\n        return;\n      }\n      const afterAppend = (node: Node | RRNode, id: number) => {\n        // Skip the plugin onBuild callback for virtual dom\n        if (this.usingVirtualDom) return;\n        for (const plugin of this.config.plugins || []) {\n          if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });\n        }\n      };\n\n      const target = buildNodeWithSN(mutation.node, {\n        doc: targetDoc as Document, // can be Document or RRDocument\n        mirror: mirror as Mirror, // can be this.mirror or virtualDom.mirror\n        skipChild: true,\n        hackCss: true,\n        cache: this.cache,\n        /**\n         * caveat: `afterAppend` only gets called on child nodes of target\n         * we have to call it again below when this target was added to the DOM\n         */\n        afterAppend,\n      }) as Node | RRNode;\n\n      // legacy data, we should not have -1 siblings any more\n      if (mutation.previousId === -1 || mutation.nextId === -1) {\n        legacy_missingNodeMap[mutation.node.id] = {\n          node: target,\n          mutation,\n        };\n        return;\n      }\n\n      // Typescripts type system is not smart enough\n      // to understand what is going on with the types below\n      type TNode = typeof mirror extends Mirror ? Node : RRNode;\n      type TMirror = typeof mirror extends Mirror ? Mirror : RRDOMMirror;\n\n      const parentSn = (mirror as TMirror).getMeta(parent as TNode);\n      if (\n        parentSn &&\n        parentSn.type === NodeType.Element &&\n        parentSn.tagName === 'textarea' &&\n        mutation.node.type === NodeType.Text\n      ) {\n        const childNodeArray = Array.isArray(parent.childNodes)\n          ? parent.childNodes\n          : Array.from(parent.childNodes);\n\n        // https://github.com/rrweb-io/rrweb/issues/745\n        // parent is textarea, will only keep one child node as the value\n        for (const c of childNodeArray) {\n          if (c.nodeType === parent.TEXT_NODE) {\n            parent.removeChild(c as Node & RRNode);\n          }\n        }\n      } else if (parentSn?.type === NodeType.Document) {\n        /**\n         * Sometimes the document object is changed or reopened and the MutationObserver is disconnected, so the removal of child elements can't be detected and recorded.\n         * After the change of document, we may get another mutation which adds a new doctype or a HTML element, while the old one still exists in the dom.\n         * So, we need to remove the old one first to avoid collision.\n         */\n        const parentDoc = parent as Document | RRDocument;\n        /**\n         * To detect the exist of the old doctype before adding a new doctype.\n         * We need to remove the old doctype before adding the new one. Otherwise, code will throw \"mutation Failed to execute 'insertBefore' on 'Node': Only one doctype on document allowed\".\n         */\n        if (\n          mutation.node.type === NodeType.DocumentType &&\n          parentDoc.childNodes[0]?.nodeType === Node.DOCUMENT_TYPE_NODE\n        )\n          parentDoc.removeChild(parentDoc.childNodes[0] as Node & RRNode);\n        /**\n         * To detect the exist of the old HTML element before adding a new HTML element.\n         * The reason is similar to the above. One document only allows exactly one DocType and one HTML Element.\n         */\n        if (target.nodeName === 'HTML' && parentDoc.documentElement)\n          parentDoc.removeChild(\n            parentDoc.documentElement as HTMLElement & RRNode,\n          );\n      }\n\n      if (previous && previous.nextSibling && previous.nextSibling.parentNode) {\n        (parent as TNode).insertBefore(\n          target as TNode,\n          previous.nextSibling as TNode,\n        );\n      } else if (next && next.parentNode) {\n        // making sure the parent contains the reference nodes\n        // before we insert target before next.\n        (parent as TNode).contains(next as TNode)\n          ? (parent as TNode).insertBefore(target as TNode, next as TNode)\n          : (parent as TNode).insertBefore(target as TNode, null);\n      } else {\n        (parent as TNode).appendChild(target as TNode);\n      }\n      /**\n       * target was added, execute plugin hooks\n       */\n      afterAppend(target, mutation.node.id);\n\n      /**\n       * https://github.com/rrweb-io/rrweb/pull/887\n       * Remove any virtual style rules for stylesheets if a new text node is appended.\n       */\n      if (\n        this.usingVirtualDom &&\n        target.nodeName === '#text' &&\n        parent.nodeName === 'STYLE' &&\n        (parent as RRStyleElement).rules?.length > 0\n      )\n        (parent as RRStyleElement).rules = [];\n\n      if (isSerializedIframe(target, this.mirror)) {\n        const targetId = this.mirror.getId(target as HTMLIFrameElement);\n        const mutationInQueue = this.newDocumentQueue.find(\n          (m) => m.parentId === targetId,\n        );\n        if (mutationInQueue) {\n          this.attachDocumentToIframe(\n            mutationInQueue,\n            target as HTMLIFrameElement,\n          );\n          this.newDocumentQueue = this.newDocumentQueue.filter(\n            (m) => m !== mutationInQueue,\n          );\n        }\n      }\n\n      if (mutation.previousId || mutation.nextId) {\n        this.legacy_resolveMissingNode(\n          legacy_missingNodeMap,\n          parent,\n          target,\n          mutation,\n        );\n      }\n    };\n\n    d.adds.forEach((mutation) => {\n      appendNode(mutation);\n    });\n\n    const startTime = Date.now();\n    while (queue.length) {\n      // transform queue to resolve tree\n      const resolveTrees = queueToResolveTrees(queue);\n      queue.length = 0;\n      if (Date.now() - startTime > 500) {\n        this.warn(\n          'Timeout in the loop, please check the resolve tree data:',\n          resolveTrees,\n        );\n        break;\n      }\n      for (const tree of resolveTrees) {\n        const parent = mirror.getNode(tree.value.parentId);\n        if (!parent) {\n          this.debug(\n            'Drop resolve tree since there is no parent for the root node.',\n            tree,\n          );\n        } else {\n          iterateResolveTree(tree, (mutation) => {\n            appendNode(mutation);\n          });\n        }\n      }\n    }\n\n    if (Object.keys(legacy_missingNodeMap).length) {\n      Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);\n    }\n\n    uniqueTextMutations(d.texts).forEach((mutation) => {\n      const target = mirror.getNode(mutation.id);\n      if (!target) {\n        if (d.removes.find((r) => r.id === mutation.id)) {\n          // no need to warn, element was already removed\n          return;\n        }\n        return this.warnNodeNotFound(d, mutation.id);\n      }\n      target.textContent = mutation.value;\n\n      /**\n       * https://github.com/rrweb-io/rrweb/pull/865\n       * Remove any virtual style rules for stylesheets whose contents are replaced.\n       */\n      if (this.usingVirtualDom) {\n        const parent = target.parentNode as RRStyleElement;\n        if (parent?.rules?.length > 0) parent.rules = [];\n      }\n    });\n    d.attributes.forEach((mutation) => {\n      const target = mirror.getNode(mutation.id);\n      if (!target) {\n        if (d.removes.find((r) => r.id === mutation.id)) {\n          // no need to warn, element was already removed\n          return;\n        }\n        return this.warnNodeNotFound(d, mutation.id);\n      }\n      for (const attributeName in mutation.attributes) {\n        if (typeof attributeName === 'string') {\n          const value = mutation.attributes[attributeName];\n          if (value === null) {\n            (target as Element | RRElement).removeAttribute(attributeName);\n          } else if (typeof value === 'string') {\n            try {\n              // When building snapshot, some link styles haven't loaded. Then they are loaded, they will be inlined as incremental mutation change of attribute. We need to replace the old elements whose styles aren't inlined.\n              if (\n                attributeName === '_cssText' &&\n                (target.nodeName === 'LINK' || target.nodeName === 'STYLE')\n              ) {\n                try {\n                  const newSn = mirror.getMeta(\n                    target as Node & RRNode,\n                  ) as serializedElementNodeWithId;\n                  const newNode = buildNodeWithSN(\n                    {\n                      ...newSn,\n                      attributes: {\n                        ...newSn.attributes,\n                        ...(mutation.attributes as attributes),\n                      },\n                    },\n                    {\n                      doc: target.ownerDocument as Document, // can be Document or RRDocument\n                      mirror: mirror as Mirror,\n                      skipChild: true,\n                      hackCss: true,\n                      cache: this.cache,\n                    },\n                  );\n                  const siblingNode = target.nextSibling;\n                  const parentNode = target.parentNode;\n                  if (newNode && parentNode) {\n                    parentNode.removeChild(target as Node & RRNode);\n                    parentNode.insertBefore(\n                      newNode as Node & RRNode,\n                      siblingNode as (Node & RRNode) | null,\n                    );\n                    mirror.replace(mutation.id, newNode as Node & RRNode);\n                    break;\n                  }\n                } catch (e) {\n                  // for safe\n                }\n              }\n              // Not sure yet how this is happening during recording, but this\n              // prevents calling `setAttribute` on Text nodes (which does not\n              // have `setAttribute` method).\n              if (target.nodeType !== 3) {\n                (target as Element | RRElement).setAttribute(\n                  attributeName,\n                  value,\n                );\n              }\n            } catch (error) {\n              this.warn(\n                'An error occurred may due to the checkout feature.',\n                error,\n              );\n            }\n          } else if (attributeName === 'style') {\n            const styleValues = value;\n            const targetEl = target as HTMLElement | RRElement;\n            for (const s in styleValues) {\n              if (styleValues[s] === false) {\n                targetEl.style.removeProperty(s);\n              } else if (styleValues[s] instanceof Array) {\n                const svp = styleValues[s] as styleValueWithPriority;\n                targetEl.style.setProperty(s, svp[0], svp[1]);\n              } else {\n                const svs = styleValues[s] as string;\n                targetEl.style.setProperty(s, svs);\n              }\n            }\n          }\n        }\n      }\n    });\n  }\n\n  /**\n   * Apply the scroll data on real elements.\n   * If the replayer is in sync mode, smooth scroll behavior should be disabled.\n   * @param d - the scroll data\n   * @param isSync - whether the replayer is in sync mode(fast-forward)\n   */\n  private applyScroll(d: scrollData, isSync: boolean) {\n    const target = this.mirror.getNode(d.id);\n    if (!target) {\n      return this.debugNodeNotFound(d, d.id);\n    }\n    const sn = this.mirror.getMeta(target);\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    if (target === iframeDoc) {\n      this.iframe.contentWindow?.scrollTo({\n        top: d.y,\n        left: d.x,\n        behavior: isSync ? 'auto' : 'smooth',\n      });\n    } else if (sn?.type === NodeType.Document) {\n      // nest iframe content document\n      (target as Document).defaultView?.scrollTo({\n        top: d.y,\n        left: d.x,\n        behavior: isSync ? 'auto' : 'smooth',\n      });\n    } else {\n      try {\n        (target as Element).scrollTo({\n          top: d.y,\n          left: d.x,\n          behavior: isSync ? 'auto' : 'smooth',\n        });\n      } catch (error) {\n        /**\n         * Seldomly we may found scroll target was removed before\n         * its last scroll event.\n         */\n      }\n    }\n  }\n\n  private applyInput(d: inputData) {\n    const target = this.mirror.getNode(d.id);\n    if (!target) {\n      return this.debugNodeNotFound(d, d.id);\n    }\n    try {\n      (target as HTMLInputElement).checked = d.isChecked;\n      (target as HTMLInputElement).value = d.text;\n    } catch (error) {\n      // for safe\n    }\n  }\n\n  private applySelection(d: selectionData) {\n    try {\n      const selectionSet = new Set<Selection>();\n      const ranges = d.ranges.map(({ start, startOffset, end, endOffset }) => {\n        const startContainer = this.mirror.getNode(start);\n        const endContainer = this.mirror.getNode(end);\n\n        if (!startContainer || !endContainer) return;\n\n        const result = new Range();\n\n        result.setStart(startContainer, startOffset);\n        result.setEnd(endContainer, endOffset);\n        const doc = startContainer.ownerDocument;\n        const selection = doc?.getSelection();\n        selection && selectionSet.add(selection);\n\n        return {\n          range: result,\n          selection,\n        };\n      });\n\n      selectionSet.forEach((s) => s.removeAllRanges());\n\n      ranges.forEach((r) => r && r.selection?.addRange(r.range));\n    } catch (error) {\n      // for safe\n    }\n  }\n\n  private applyStyleSheetMutation(\n    data: styleDeclarationData | styleSheetRuleData,\n  ) {\n    let styleSheet: CSSStyleSheet | null = null;\n    if (data.styleId) styleSheet = this.styleMirror.getStyle(data.styleId);\n    else if (data.id)\n      styleSheet =\n        (this.mirror.getNode(data.id) as HTMLStyleElement)?.sheet || null;\n    if (!styleSheet) return;\n    if (data.source === IncrementalSource.StyleSheetRule)\n      this.applyStyleSheetRule(data, styleSheet);\n    else if (data.source === IncrementalSource.StyleDeclaration)\n      this.applyStyleDeclaration(data, styleSheet);\n  }\n\n  private applyStyleSheetRule(\n    data: styleSheetRuleData,\n    styleSheet: CSSStyleSheet,\n  ) {\n    data.adds?.forEach(({ rule, index: nestedIndex }) => {\n      try {\n        if (Array.isArray(nestedIndex)) {\n          const { positions, index } = getPositionsAndIndex(nestedIndex);\n          const nestedRule = getNestedRule(styleSheet.cssRules, positions);\n          nestedRule.insertRule(rule, index);\n        } else {\n          const index =\n            nestedIndex === undefined\n              ? undefined\n              : Math.min(nestedIndex, styleSheet.cssRules.length);\n          styleSheet?.insertRule(rule, index);\n        }\n      } catch (e) {\n        /**\n         * sometimes we may capture rules with browser prefix\n         * insert rule with prefixs in other browsers may cause Error\n         */\n        /**\n         * accessing styleSheet rules may cause SecurityError\n         * for specific access control settings\n         */\n      }\n    });\n\n    data.removes?.forEach(({ index: nestedIndex }) => {\n      try {\n        if (Array.isArray(nestedIndex)) {\n          const { positions, index } = getPositionsAndIndex(nestedIndex);\n          const nestedRule = getNestedRule(styleSheet.cssRules, positions);\n          nestedRule.deleteRule(index || 0);\n        } else {\n          styleSheet?.deleteRule(nestedIndex);\n        }\n      } catch (e) {\n        /**\n         * same as insertRule\n         */\n      }\n    });\n\n    if (data.replace)\n      try {\n        void styleSheet.replace?.(data.replace);\n      } catch (e) {\n        // for safety\n      }\n\n    if (data.replaceSync)\n      try {\n        styleSheet.replaceSync?.(data.replaceSync);\n      } catch (e) {\n        // for safety\n      }\n  }\n\n  private applyStyleDeclaration(\n    data: styleDeclarationData,\n    styleSheet: CSSStyleSheet,\n  ) {\n    if (data.set) {\n      const rule = getNestedRule(\n        styleSheet.rules,\n        data.index,\n      ) as unknown as CSSStyleRule;\n      rule &&\n        rule.style &&\n        rule.style.setProperty(\n          data.set.property,\n          data.set.value,\n          data.set.priority,\n        );\n    }\n\n    if (data.remove) {\n      const rule = getNestedRule(\n        styleSheet.rules,\n        data.index,\n      ) as unknown as CSSStyleRule;\n      rule && rule.style && rule.style.removeProperty(data.remove.property);\n    }\n  }\n\n  private applyAdoptedStyleSheet(data: adoptedStyleSheetData) {\n    const targetHost = this.mirror.getNode(data.id);\n    if (!targetHost) return;\n    // Create StyleSheet objects which will be adopted after.\n    data.styles?.forEach((style) => {\n      let newStyleSheet: CSSStyleSheet | null = null;\n      /**\n       * Constructed StyleSheet can't share across multiple documents.\n       * The replayer has to get the correct host window to recreate a StyleSheetObject.\n       */\n      let hostWindow: IWindow | null = null;\n      if (hasShadowRoot(targetHost))\n        hostWindow = targetHost.ownerDocument?.defaultView || null;\n      else if (targetHost.nodeName === '#document')\n        hostWindow = (targetHost as Document).defaultView;\n\n      if (!hostWindow) return;\n      try {\n        newStyleSheet = new hostWindow.CSSStyleSheet();\n        this.styleMirror.add(newStyleSheet, style.styleId);\n        // To reuse the code of applying stylesheet rules\n        this.applyStyleSheetRule(\n          {\n            source: IncrementalSource.StyleSheetRule,\n            adds: style.rules,\n          },\n          newStyleSheet,\n        );\n      } catch (e) {\n        // In case some browsers don't support constructing StyleSheet.\n      }\n    });\n\n    const MAX_RETRY_TIME = 10;\n    let count = 0;\n    const adoptStyleSheets = (targetHost: Node, styleIds: number[]) => {\n      const stylesToAdopt = styleIds\n        .map((styleId) => this.styleMirror.getStyle(styleId))\n        .filter((style) => style !== null) as CSSStyleSheet[];\n      if (hasShadowRoot(targetHost))\n        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n        (targetHost as HTMLElement).shadowRoot!.adoptedStyleSheets =\n          stylesToAdopt;\n      else if (targetHost.nodeName === '#document')\n        (targetHost as Document).adoptedStyleSheets = stylesToAdopt;\n\n      /**\n       * In the live mode where events are transferred over network without strict order guarantee, some newer events are applied before some old events and adopted stylesheets may haven't been created.\n       * This retry mechanism can help resolve this situation.\n       */\n      if (stylesToAdopt.length !== styleIds.length && count < MAX_RETRY_TIME) {\n        setTimeout(\n          () => adoptStyleSheets(targetHost, styleIds),\n          0 + 100 * count,\n        );\n        count++;\n      }\n    };\n    adoptStyleSheets(targetHost, data.styleIds);\n  }\n\n  private legacy_resolveMissingNode(\n    map: missingNodeMap,\n    parent: Node | RRNode,\n    target: Node | RRNode,\n    targetMutation: addedNodeMutation,\n  ) {\n    const { previousId, nextId } = targetMutation;\n    const previousInMap = previousId && map[previousId];\n    const nextInMap = nextId && map[nextId];\n    if (previousInMap) {\n      const { node, mutation } = previousInMap;\n      parent.insertBefore(node as Node & RRNode, target as Node & RRNode);\n      delete map[mutation.node.id];\n      delete this.legacy_missingNodeRetryMap[mutation.node.id];\n      if (mutation.previousId || mutation.nextId) {\n        this.legacy_resolveMissingNode(map, parent, node, mutation);\n      }\n    }\n    if (nextInMap) {\n      const { node, mutation } = nextInMap;\n      parent.insertBefore(\n        node as Node & RRNode,\n        target.nextSibling as Node & RRNode,\n      );\n      delete map[mutation.node.id];\n      delete this.legacy_missingNodeRetryMap[mutation.node.id];\n      if (mutation.previousId || mutation.nextId) {\n        this.legacy_resolveMissingNode(map, parent, node, mutation);\n      }\n    }\n  }\n\n  private moveAndHover(\n    x: number,\n    y: number,\n    id: number,\n    isSync: boolean,\n    debugData: incrementalData,\n    pointerId: number,\n  ) {\n    const target = this.mirror.getNode(id);\n    if (!target) {\n      return this.debugNodeNotFound(debugData, id);\n    }\n\n    const base = getBaseDimension(target, this.iframe);\n    const _x = x * base.absoluteScale + base.x;\n    const _y = y * base.absoluteScale + base.y;\n\n    const pointer = this.pointers[pointerId];\n    if (pointer && pointer.pointerEl) {\n      pointer.pointerEl.style.left = `${_x}px`;\n      pointer.pointerEl.style.top = `${_y}px`;\n    }\n\n    if (!isSync) {\n      this.drawMouseTail({ x: _x, y: _y }, pointerId);\n    }\n    this.hoverElements(target as Element);\n  }\n\n  private drawMouseTail(position: { x: number; y: number }, pointerId: number) {\n    const pointer = this.pointers[pointerId];\n\n    if (!pointer || !pointer.mouseTail) {\n      return;\n    }\n\n    const { lineCap, lineWidth, strokeStyle, duration } =\n      this.config.mouseTail === true\n        ? defaultMouseTailConfig\n        : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);\n\n    const draw = () => {\n      if (!pointer || !pointer.mouseTail) {\n        return;\n      }\n      const mouseTail = pointer.mouseTail;\n\n      const ctx = mouseTail.getContext('2d');\n      if (!ctx || !pointer.tailPositions.length) {\n        return;\n      }\n      ctx.clearRect(0, 0, mouseTail.width, mouseTail.height);\n      ctx.beginPath();\n      ctx.lineWidth = lineWidth;\n      ctx.lineCap = lineCap;\n      ctx.strokeStyle = strokeStyle;\n      ctx.moveTo(pointer.tailPositions[0].x, pointer.tailPositions[0].y);\n      pointer.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));\n      ctx.stroke();\n    };\n\n    pointer.tailPositions.push(position);\n    draw();\n    setTimeout(() => {\n      if (pointerId in this.pointers) {\n        pointer.tailPositions = pointer.tailPositions.filter(\n          (p) => p !== position,\n        );\n        draw();\n      }\n    }, duration / this.speedService.state.context.timer.speed);\n  }\n\n  private hoverElements(el: Element) {\n    const iframeDoc = getIFrameContentDocument(this.iframe);\n    const rootElement = this.lastHoveredRootNode || iframeDoc;\n\n    // Sometimes this throws because `querySelectorAll` is not a function,\n    // unsure of value of rootElement when this occurs\n    if (rootElement && typeof rootElement.querySelectorAll === 'function') {\n      rootElement.querySelectorAll('.\\\\:hover').forEach((hoveredEl) => {\n        hoveredEl.classList.remove(':hover');\n      });\n    }\n\n    this.lastHoveredRootNode = el.getRootNode() as Document | ShadowRoot;\n    let currentEl: Element | null = el;\n    while (currentEl) {\n      if (currentEl.classList) {\n        currentEl.classList.add(':hover');\n      }\n      currentEl = currentEl.parentElement;\n    }\n  }\n\n  private isUserInteraction(event: eventWithTime): boolean {\n    if (event.type !== EventType.IncrementalSnapshot) {\n      return false;\n    }\n    return (\n      event.data.source > IncrementalSource.Mutation &&\n      event.data.source <= IncrementalSource.Input\n    );\n  }\n\n  private backToNormal() {\n    this.nextUserInteractionEvent = null;\n    if (this.speedService.state.matches('normal')) {\n      return;\n    }\n    this.speedService.send({ type: 'BACK_TO_NORMAL' });\n    this.emitter.emit(ReplayerEvents.SkipEnd, {\n      speed: this.speedService.state.context.normalSpeed,\n    });\n  }\n\n  private warnNodeNotFound(d: incrementalData, id: number) {\n    this.warn(`Node with id '${id}' not found. `, d);\n  }\n\n  private warnCanvasMutationFailed(\n    d: canvasMutationData | canvasMutationCommand,\n    error: unknown,\n  ) {\n    this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);\n  }\n\n  private debugNodeNotFound(d: incrementalData, id: number) {\n    /**\n     * There maybe some valid scenes of node not being found.\n     * Because DOM events are macrotask and MutationObserver callback\n     * is microtask, so events fired on a removed DOM may emit\n     * snapshots in the reverse order.\n     */\n    this.debug(`Node with id '${id}' not found. `, d);\n  }\n\n  private warn(...args: Parameters<typeof console.warn>) {\n    if (!this.config.showWarning) {\n      return;\n    }\n    this.config.logger.warn(REPLAY_CONSOLE_PREFIX, ...args);\n  }\n\n  private debug(...args: Parameters<typeof console.log>) {\n    if (!this.config.showDebug) {\n      return;\n    }\n    this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);\n  }\n}\n\nexport {\n  type PlayerState,\n  type SpeedState,\n  type PlayerMachineState,\n  type SpeedMachineState,\n  playerConfig,\n};\n"],"names":["n","c","s","e","canvasMutation","i","mirror","IGNORED_NODE","inDom","isShadowRoot","getShadowHost","serializeNodeWithId","isSerializedIframe","isBlocked","isSerializedStylesheet","hasShadowRoot","parentId","isIgnored","needMaskingText","closestElementOfNode","getInputType","getInputValue","shouldMaskInput","maskInputValue","ignoreAttribute","transformAttribute","toLowerCase","isSerialized","isAncestorRemoved","isNativeShadowDom","r","callbackWrapper","throttle","legacy_isTouchEvent","nowTimestamp","IncrementalSource","on","PointerTypes","MouseInteractions","getWindowScroll","getWindowHeight","getWindowWidth","toUpperCase","el","text","v","hookSetter","rules","MediaInteractions","FontFace","patch","setTimeout","o","genId","EventType","NodeType","StyleSheetMirror","stringifyRule","onRequestAnimationFrame","createMirror","registerErrorHandler","polyfill","takeFullSnapshot","a","canvasManager","snapshot","unregisterErrorHandler","CanvasManagerNoop","t","Element","l","u","createMachine","assign","ReplayerEvents","interpret","decode","image","CanvasContext","args","canvas2DMutation","mittProxy.default","createCache","events","canvasMutationData","attributes","smoothscrollPolyfill","rebuild","getInjectStyleRules","buildNodeWithSN","clearTimeout","queueToResolveTrees","iterateResolveTree","uniqueTextMutations","getPositionsAndIndex","getNestedRule","targetHost","getBaseDimension"],"mappings":";;;AAAA,IAAI,YAAY,OAAO;AACvB,IAAI,kBAAkB,CAAC,KAAK,KAAK,UAAU,OAAO,MAAM,UAAU,KAAK,KAAK,EAAE,YAAY,MAAM,cAAc,MAA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