rrweb
Version:
record and replay the web
29 lines (25 loc) • 58.8 kB
JavaScript
var rrweb=function(e){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function r(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function i(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(o(arguments[t]));return e}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(t||(t={}));var a=1,s=RegExp("[^a-z1-6-]");function c(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).reduce((function(e,t){return e+(function(e){return"styleSheet"in e}(n=t)?c(n.styleSheet)||"":n.cssText);var n}),""):null}catch(e){return null}}var u=/url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm,l=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/,d=/^(data:)([\w\/\+\-]+);(charset=[\w-]+|base64).*,(.*)/i;function p(e,t){return(e||"").replace(u,(function(e,n,r,o){var i,a=n||r||o;if(!a)return e;if(!l.test(a))return"url('"+a+"')";if(d.test(a))return"url("+a+")";if("/"===a[0])return"url('"+(((i=t).indexOf("//")>-1?i.split("/").slice(0,3).join("/"):i.split("/")[0]).split("?")[0]+a+"')");var s=t.split("/"),c=a.split("/");s.pop();for(var u=0,p=c;u<p.length;u++){var f=p[u];"."!==f&&(".."===f?s.pop():s.push(f))}return"url('"+s.join("/")+"')"}))}function f(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function h(e,t,n){return"src"===t||"href"===t&&n?f(e,n):"srcset"===t&&n?function(e,t){return""===t.trim()?t:t.split(",").map((function(t){var n=t.trimLeft().trimRight().split(" ");return 2===n.length?f(e,n[0])+" "+n[1]:1===n.length?""+f(e,n[0]):""})).join(",")}(e,n):"style"===t&&n?p(n,location.href):n}function m(e,n,r,o,i){switch(void 0===i&&(i={}),e.nodeType){case e.DOCUMENT_NODE:return{type:t.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:t.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId};case e.ELEMENT_NODE:var a=!1;"string"==typeof r?a=e.classList.contains(r):e.classList.forEach((function(e){r.test(e)&&(a=!0)}));for(var u=function(e){var t=e.toLowerCase().trim();return s.test(t)?"div":t}(e.tagName),l={},d=0,f=Array.from(e.attributes);d<f.length;d++){var m=f[d],v=m.name,y=m.value;l[v]=h(n,v,y)}if("link"===u&&o){var g,b=Array.from(n.styleSheets).find((function(t){return t.href===e.href}));(g=c(b))&&(delete l.rel,delete l.href,l._cssText=p(g,b.href))}if("style"===u&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(g=c(e.sheet))&&(l._cssText=p(g,location.href));if("input"===u||"textarea"===u||"select"===u){y=e.value;"radio"!==l.type&&"checkbox"!==l.type&&"submit"!==l.type&&"button"!==l.type&&y?l.value=i[l.type]||i[u]?"*".repeat(y.length):y:e.checked&&(l.checked=e.checked)}if("option"===u){var S=e.parentElement;l.value===S.value&&(l.selected=e.selected)}if("canvas"===u&&(l.rr_dataURL=e.toDataURL()),"audio"!==u&&"video"!==u||(l.rr_mediaState=e.paused?"paused":"played"),a){var E=e.getBoundingClientRect(),w=E.width,I=E.height;l.rr_width=w+"px",l.rr_height=I+"px"}return{type:t.Element,tagName:u,attributes:l,childNodes:[],isSVG:(M=e,"svg"===M.tagName||M instanceof SVGElement||void 0),needBlock:a};case e.TEXT_NODE:var x=e.parentNode&&e.parentNode.tagName,T=e.textContent,C="STYLE"===x||void 0;return C&&T&&(T=p(T,location.href)),"SCRIPT"===x&&(T="SCRIPT_PLACEHOLDER"),{type:t.Text,textContent:T||"",isStyle:C};case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:""};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||""};default:return!1}var M}function v(e,n,r,o,i,s,c){void 0===i&&(i=!1),void 0===s&&(s=!0);var u,l=m(e,n,o,s,c);if(!l)return console.warn(e,"not serialized"),null;u="__sn"in e?e.__sn.id:a++;var d=Object.assign(l,{id:u});e.__sn=d,r[u]=e;var p=!i;if(d.type===t.Element&&(p=p&&!d.needBlock,delete d.needBlock),(d.type===t.Document||d.type===t.Element)&&p)for(var f=0,h=Array.from(e.childNodes);f<h.length;f++){var y=v(h[f],n,r,o,i,s,c);y&&d.childNodes.push(y)}return d}var y=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function g(e,t){void 0===t&&(t={});var n=1,r=1;function o(e){var t=e.match(/\n/g);t&&(n+=t.length);var o=e.lastIndexOf("\n");r=-1===o?r+e.length:e.length-o}function i(){var e={line:n,column:r};return function(t){return t.position=new a(e),f(),t}}var a=function(e){this.start=e,this.end={line:n,column:r},this.source=t.source};a.prototype.content=e;var s=[];function c(o){var i=new Error(t.source+":"+n+":"+r+": "+o);if(i.reason=o,i.filename=t.source,i.line=n,i.column=r,i.source=e,!t.silent)throw i;s.push(i)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function d(){var t,n=[];for(f(),h(n);e.length&&"}"!==e.charAt(0)&&(t=M()||N());)!1!==t&&(n.push(t),h(n));return n}function p(t){var n=t.exec(e);if(n){var r=n[0];return o(r),e=e.slice(r.length),n}}function f(){p(/^\s*/)}function h(e){var t;for(void 0===e&&(e=[]);t=m();)!1!==t&&e.push(t),t=m();return e}function m(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var n=2;""!==e.charAt(n)&&("*"!==e.charAt(n)||"/"!==e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return c("End of comment missing");var a=e.slice(2,n-2);return r+=2,o(a),e=e.slice(n),r+=2,t({type:"comment",comment:a})}}function v(){var e=p(/^([^{]+)/);if(e)return b(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,(function(e){return e.replace(/,/g,"")})).split(/\s*(?![^(]*\)),\s*/).map((function(e){return e.replace(/\u200C/g,",")}))}function g(){var e=i(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var n=b(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var r=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),o=e({type:"declaration",property:n.replace(y,""),value:r?b(r[0]).replace(y,""):""});return p(/^[;\s]*/),o}}function S(){var e,t=[];if(!u())return c("missing '{'");for(h(t);e=g();)!1!==e&&(t.push(e),h(t)),e=g();return l()?t:c("missing '}'")}function E(){for(var e,t=[],n=i();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return n({type:"keyframe",values:t,declarations:S()})}var w,I=C("import"),x=C("charset"),T=C("namespace");function C(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var n=i(),r=p(t);if(r){var o={type:e};return o[e]=r[1].trim(),n(o)}}}function M(){if("@"===e[0])return function(){var e=i(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var n=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var r,o=t[1];if(!u())return c("@keyframes missing '{'");for(var a=h();r=E();)a.push(r),a=a.concat(h());return l()?e({type:"keyframes",name:o,vendor:n,keyframes:a}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=p(/^@media *([^{]+)/);if(t){var n=b(t[1]);if(!u())return c("@media missing '{'");var r=h().concat(d());return l()?e({type:"media",media:n,rules:r}):c("@media missing '}'")}}()||function(){var e=i(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:b(t[1]),media:b(t[2])})}()||function(){var e=i(),t=p(/^@supports *([^{]+)/);if(t){var n=b(t[1]);if(!u())return c("@supports missing '{'");var r=h().concat(d());return l()?e({type:"supports",supports:n,rules:r}):c("@supports missing '}'")}}()||I()||x()||T()||function(){var e=i(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var n=b(t[1]),r=b(t[2]);if(!u())return c("@document missing '{'");var o=h().concat(d());return l()?e({type:"document",document:r,vendor:n,rules:o}):c("@document missing '}'")}}()||function(){var e=i();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var n,r=h();n=g();)r.push(n),r=r.concat(h());return l()?e({type:"page",selectors:t,declarations:r}):c("@page missing '}'")}}()||function(){var e=i();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=h().concat(d());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,n=h();t=g();)n.push(t),n=n.concat(h());return l()?e({type:"font-face",declarations:n}):c("@font-face missing '}'")}}()}function N(){var e=i(),t=v();return t?(h(),e({type:"rule",selectors:t,declarations:S()})):c("selector missing")}return function e(t,n){for(var r=t&&"string"==typeof t.type,o=r?t:n,i=0,a=Object.keys(t);i<a.length;i++){var s=a[i],c=t[s];Array.isArray(c)?c.forEach((function(t){e(t,o)})):c&&"object"==typeof c&&e(c,o)}r&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:n||null});return t}((w=d(),{type:"stylesheet",stylesheet:{source:t.source,rules:w,parsingErrors:s}}))}function b(e){return e?e.replace(/^\s+|\s+$/g,""):""}var S={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var E,w,I,x,T,C=/([^\\]):hover/g;function M(e){var t=g(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach((function(t){"selectors"in t&&(t.selectors||[]).forEach((function(t){if(C.test(t)){var n=t.replace(C,"$1.\\:hover");e=e.replace(t,t+", "+n)}}))})),e):e}function N(e,n,r){switch(e.type){case t.Document:return n.implementation.createDocument(null,"",null);case t.DocumentType:return n.implementation.createDocumentType(e.name,e.publicId,e.systemId);case t.Element:var o,i=function(e){var t=S[e.tagName]?S[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(e);o=e.isSVG?n.createElementNS("http://www.w3.org/2000/svg",i):n.createElement(i);var a=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var a=e.attributes[t];if(a="boolean"==typeof a?"":a,t.startsWith("rr_")){if("canvas"===i&&"rr_dataURL"===t){var s=document.createElement("img");s.src=a,s.onload=function(){var e=o.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===t&&(o.style.width=a),"rr_height"===t&&(o.style.height=a),"rr_mediaState"===t)switch(a){case"played":o.play();case"paused":o.pause()}}else{var c="textarea"===i&&"value"===t,u="style"===i&&"_cssText"===t;if(u&&r&&(a=M(a)),c||u){for(var l=n.createTextNode(a),d=0,p=Array.from(o.childNodes);d<p.length;d++){var f=p[d];f.nodeType===o.TEXT_NODE&&o.removeChild(f)}return o.appendChild(l),"continue"}if("iframe"===i&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?o.setAttributeNS("http://www.w3.org/1999/xlink",t,a):"onload"==t||"onclick"==t||"onmouse"==t.substring(0,7)?o.setAttribute("_"+t,a):o.setAttribute(t,a)}catch(e){}}};for(var s in e.attributes)a(s);return o;case t.Text:return n.createTextNode(e.isStyle&&r?M(e.textContent):e.textContent);case t.CDATA:return n.createCDATASection(e.textContent);case t.Comment:return n.createComment(e.textContent);default:return null}}function k(e,n,r,o,i){void 0===o&&(o=!1),void 0===i&&(i=!0);var a=N(e,n,i);if(!a)return null;if(e.type===t.Document&&(n.close(),n.open(),a=n),a.__sn=e,r[e.id]=a,(e.type===t.Document||e.type===t.Element)&&!o)for(var s=0,c=e.childNodes;s<c.length;s++){var u=c[s],l=k(u,n,r,!1,i);l?a.appendChild(l):console.warn("Failed to rebuild",u)}return a}function _(e,t,n){void 0===n&&(n=document);var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}(E=e.EventType||(e.EventType={}))[E.DomContentLoaded=0]="DomContentLoaded",E[E.Load=1]="Load",E[E.FullSnapshot=2]="FullSnapshot",E[E.IncrementalSnapshot=3]="IncrementalSnapshot",E[E.Meta=4]="Meta",E[E.Custom=5]="Custom",(w=e.IncrementalSource||(e.IncrementalSource={}))[w.Mutation=0]="Mutation",w[w.MouseMove=1]="MouseMove",w[w.MouseInteraction=2]="MouseInteraction",w[w.Scroll=3]="Scroll",w[w.ViewportResize=4]="ViewportResize",w[w.Input=5]="Input",w[w.TouchMove=6]="TouchMove",w[w.MediaInteraction=7]="MediaInteraction",w[w.StyleSheetRule=8]="StyleSheetRule",(I=e.MouseInteractions||(e.MouseInteractions={}))[I.MouseUp=0]="MouseUp",I[I.MouseDown=1]="MouseDown",I[I.Click=2]="Click",I[I.ContextMenu=3]="ContextMenu",I[I.DblClick=4]="DblClick",I[I.Focus=5]="Focus",I[I.Blur=6]="Blur",I[I.TouchStart=7]="TouchStart",I[I.TouchMove_Departed=8]="TouchMove_Departed",I[I.TouchEnd=9]="TouchEnd",function(e){e[e.Play=0]="Play",e[e.Pause=1]="Pause"}(x||(x={})),(T=e.ReplayerEvents||(e.ReplayerEvents={})).Start="start",T.Pause="pause",T.Resume="resume",T.Resize="resize",T.Finish="finish",T.FullsnapshotRebuilded="fullsnapshot-rebuilded",T.LoadStylesheetStart="load-stylesheet-start",T.LoadStylesheetEnd="load-stylesheet-end",T.SkipStart="skip-start",T.SkipEnd="skip-end",T.MouseInteraction="mouse-interaction",T.EventCast="event-cast",T.CustomEvent="custom-event",T.Flush="flush",T.StateChange="state-change";var R={map:{},getId:function(e){return e.__sn?e.__sn.id:-1},getNode:function(e){return R.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete R.map[t],e.childNodes&&e.childNodes.forEach((function(e){return R.removeNodeFromMap(e)}))},has:function(e){return R.map.hasOwnProperty(e)}};function O(e,t,n){void 0===n&&(n={});var r=null,o=0;return function(i){var a=Date.now();o||!1!==n.leading||(o=a);var s=t-(a-o),c=this,u=arguments;s<=0||s>t?(r&&(window.clearTimeout(r),r=null),o=a,e.apply(c,u)):r||!1===n.trailing||(r=window.setTimeout((function(){o=!1===n.leading?0:Date.now(),r=null,e.apply(c,u)}),s))}}function A(e,t,n,r,o){void 0===o&&(o=window);var i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set:function(e){var t=this;setTimeout((function(){n.set.call(t,e)}),0),i&&i.set&&i.set.call(this,e)}}),function(){return A(e,t,i||{},!0)}}function D(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function L(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function F(e,t){if(!e)return!1;if(e.nodeType===e.ELEMENT_NODE){var n=!1;return"string"==typeof t?n=e.classList.contains(t):e.classList.forEach((function(e){t.test(e)&&(n=!0)})),n||F(e.parentNode,t)}return e.nodeType,e.TEXT_NODE,F(e.parentNode,t)}function P(e){var t=R.getId(e);return!R.has(t)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||P(e.parentNode))}function j(e){return Boolean(e.changedTouches)}function B(){"NodeList"in window&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach)}function z(t){switch(t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:case e.EventType.Custom:return!1;case e.EventType.FullSnapshot:case e.EventType.Meta:return!0}switch(t.data.source){case e.IncrementalSource.MouseMove:case e.IncrementalSource.MouseInteraction:case e.IncrementalSource.TouchMove:case e.IncrementalSource.MediaInteraction:return!1;case e.IncrementalSource.ViewportResize:case e.IncrementalSource.StyleSheetRule:case e.IncrementalSource.Scroll:case e.IncrementalSource.Input:return!0}return!0}var V=function(){function t(){this.reset()}return t.prototype.add=function(e){var t=this.indexes.get(e.parentId),n={id:e.node.id,mutation:e,children:[],texts:[],attributes:[]};t?(n.parent=t,t.children[n.id]=n):this.tree[n.id]=n,this.indexes.set(n.id,n)},t.prototype.remove=function(e){var t=this,n=this.indexes.get(e.parentId),r=this.indexes.get(e.id),o=function(e){t.removeIdSet.add(e);var n=R.getNode(e);null==n||n.childNodes.forEach((function(e){return o(e.__sn.id)}))},i=function(n){t.removeIdSet.add(n.id),Object.values(n.children).forEach((function(e){return i(e)}));var r=t.indexes.get(n.id);if(r){var o=r.parent;o&&(delete r.parent,delete o.children[r.id],t.indexes.delete(e.id))}};r?n?(delete r.parent,delete n.children[r.id],this.indexes.delete(e.id),i(r)):(delete this.tree[r.id],this.indexes.delete(r.id),i(r)):(this.removeNodeMutations.push(e),o(e.id))},t.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},t.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},t.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},t.prototype.input=function(e){this.inputMap.set(e.id,e)},t.prototype.flush=function(){var t,n,o,i,a=this,s=this.tree,c=this.removeNodeMutations,u=this.textMutations,l=this.attributeMutations,d={source:e.IncrementalSource.Mutation,removes:c,texts:u,attributes:l,adds:[]},p=function(e,t){t&&a.removeIdSet.add(e.id),d.texts=d.texts.concat(t?[]:e.texts).filter((function(e){return!a.removeIdSet.has(e.id)})),d.attributes=d.attributes.concat(t?[]:e.attributes).filter((function(e){return!a.removeIdSet.has(e.id)})),a.removeIdSet.has(e.id)||a.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return p(e,!0)})):(d.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return p(e,!1)})))};Object.values(s).forEach((function(e){return p(e,!1)}));try{for(var f=r(this.scrollMap.keys()),h=f.next();!h.done;h=f.next()){var m=h.value;this.removeIdSet.has(m)&&this.scrollMap.delete(m)}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}try{for(var v=r(this.inputMap.keys()),y=v.next();!y.done;y=v.next()){m=y.value;this.removeIdSet.has(m)&&this.inputMap.delete(m)}}catch(e){o={error:e}}finally{try{y&&!y.done&&(i=v.return)&&i.call(v)}finally{if(o)throw o.error}}var g=new Map(this.scrollMap),b=new Map(this.inputMap);return this.reset(),{mutationData:d,scrollMap:g,inputMap:b}},t.prototype.reset=function(){this.tree=[],this.indexes=new Map,this.removeNodeMutations=[],this.textMutations=[],this.attributeMutations=[],this.removeIdSet=new Set,this.scrollMap=new Map,this.inputMap=new Map},t}(),U=Object.freeze({__proto__:null,on:_,mirror:R,throttle:O,hookSetter:A,patch:function(e,t,n){if(!(t in e))return function(){};var r=e[t],o=n(r);if("function"==typeof o)try{o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})}catch(e){}return e[t]=o,function(){e[t]=r}},getWindowHeight:D,getWindowWidth:L,isBlocked:F,isAncestorRemoved:P,isTouchEvent:j,polyfill:B,needCastInSyncMode:z,TreeIndex:V}),X=function(e,t){return e+"@"+t};function Y(e){return"__sn"in e}var H=function(e,t,n,o){var i=this;this.texts=[],this.attributes=[],this.removes=[],this.adds=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=function(e){var t,n,o,a;e.forEach(i.processMutation);var s=[],c=function(e){if(e.parentNode){var t=R.getId(e.parentNode),n=e.nextSibling&&R.getId(e.nextSibling);if(-1===t||-1===n)return s.push(e);i.adds.push({parentId:t,nextId:n,node:v(e,document,R.map,i.blockClass,!0,i.inlineStylesheet,i.maskInputOptions)})}};try{for(var u=r(i.movedSet),l=u.next();!l.done;l=u.next())c(f=l.value)}catch(e){t={error:e}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}try{for(var d=r(i.addedSet),p=d.next();!p.done;p=d.next()){var f=p.value;q(i.droppedSet,f)||G(i.removes,f)?q(i.movedSet,f)?c(f):i.droppedSet.add(f):c(f)}}catch(e){o={error:e}}finally{try{p&&!p.done&&(a=d.return)&&a.call(d)}finally{if(o)throw o.error}}for(;s.length&&!s.every((function(e){return-1===R.getId(e.parentNode)}));)c(s.shift());i.emit()},this.emit=function(){var e={texts:i.texts.map((function(e){return{id:R.getId(e.node),value:e.value}})).filter((function(e){return R.has(e.id)})),attributes:i.attributes.map((function(e){return{id:R.getId(e.node),attributes:e.attributes}})).filter((function(e){return R.has(e.id)})),removes:i.removes,adds:i.adds};(e.texts.length||e.attributes.length||e.removes.length||e.adds.length)&&(i.emissionCallback(e),i.texts=[],i.attributes=[],i.removes=[],i.adds=[],i.addedSet=new Set,i.movedSet=new Set,i.droppedSet=new Set,i.movedMap={})},this.processMutation=function(e){switch(e.type){case"characterData":var t=e.target.textContent;F(e.target,i.blockClass)||t===e.oldValue||i.texts.push({value:t,node:e.target});break;case"attributes":if(t=e.target.getAttribute(e.attributeName),F(e.target,i.blockClass)||t===e.oldValue)return;var n=i.attributes.find((function(t){return t.node===e.target}));n||(n={node:e.target,attributes:{}},i.attributes.push(n)),n.attributes[e.attributeName]=h(document,e.attributeName,t);break;case"childList":e.addedNodes.forEach((function(t){return i.genAdds(t,e.target)})),e.removedNodes.forEach((function(t){var n=R.getId(t),r=R.getId(e.target);F(t,i.blockClass)||F(e.target,i.blockClass)||(i.addedSet.has(t)?(W(i.addedSet,t),i.droppedSet.add(t)):i.addedSet.has(e.target)&&-1===n||P(e.target)||(i.movedSet.has(t)&&i.movedMap[X(n,r)]?W(i.movedSet,t):i.removes.push({parentId:r,id:n})),R.removeNodeFromMap(t))}))}},this.genAdds=function(e,t){if(!F(e,i.blockClass)){if(Y(e)){i.movedSet.add(e);var n=null;t&&Y(t)&&(n=t.__sn.id),n&&(i.movedMap[X(e.__sn.id,n)]=!0)}else i.addedSet.add(e),i.droppedSet.delete(e);e.childNodes.forEach((function(e){return i.genAdds(e)}))}},this.blockClass=t,this.inlineStylesheet=n,this.maskInputOptions=o,this.emissionCallback=e};function W(e,t){e.delete(t),t.childNodes.forEach((function(t){return W(e,t)}))}function G(e,t){var n=t.parentNode;if(!n)return!1;var r=R.getId(n);return!!e.some((function(e){return e.id===r}))||G(e,n)}function q(e,t){var n=t.parentNode;return!!n&&(!!e.has(n)||q(e,n))}function K(t,n,r){if(!1===r.mouseInteraction)return function(){};var o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,i=[];return Object.keys(e.MouseInteractions).filter((function(e){return Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==o[e]})).forEach((function(r){var o=r.toLowerCase(),a=function(r){return function(o){if(!F(o.target,n)){var i=R.getId(o.target),a=j(o)?o.changedTouches[0]:o,s=a.clientX,c=a.clientY;t({type:e.MouseInteractions[r],id:i,x:s,y:c})}}}(r);i.push(_(o,a))})),function(){i.forEach((function(e){return e()}))}}var $,Z=["INPUT","TEXTAREA","SELECT"],J=new WeakMap;function Q(t,r){void 0===r&&(r={}),function(e,t){var n=e.mutationCb,r=e.mousemoveCb,o=e.mouseInteractionCb,a=e.scrollCb,s=e.viewportResizeCb,c=e.inputCb,u=e.mediaInteractionCb,l=e.styleSheetRuleCb;e.mutationCb=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];t.mutation&&t.mutation.apply(t,i(e)),n.apply(void 0,i(e))},e.mousemoveCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.mousemove&&t.mousemove.apply(t,i(e)),r.apply(void 0,i(e))},e.mouseInteractionCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.mouseInteraction&&t.mouseInteraction.apply(t,i(e)),o.apply(void 0,i(e))},e.scrollCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.scroll&&t.scroll.apply(t,i(e)),a.apply(void 0,i(e))},e.viewportResizeCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.viewportResize&&t.viewportResize.apply(t,i(e)),s.apply(void 0,i(e))},e.inputCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.input&&t.input.apply(t,i(e)),c.apply(void 0,i(e))},e.mediaInteractionCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.mediaInteaction&&t.mediaInteaction.apply(t,i(e)),u.apply(void 0,i(e))},e.styleSheetRuleCb=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];t.styleSheetRule&&t.styleSheetRule.apply(t,i(e)),l.apply(void 0,i(e))}}(t,r);var o,a,s,c,u,l,d=(o=t.mutationCb,a=t.blockClass,s=t.inlineStylesheet,c=t.maskInputOptions,u=new H(o,a,s,c),(l=new MutationObserver(u.processMutations)).observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l),p=function(t,n){if(!1===n.mousemove)return function(){};var r,o="number"==typeof n.mousemove?n.mousemove:50,i=[],a=O((function(n){var o=Date.now()-r;t(i.map((function(e){return e.timeOffset-=o,e})),n?e.IncrementalSource.TouchMove:e.IncrementalSource.MouseMove),i=[],r=null}),500),s=O((function(e){var t=e.target,n=j(e)?e.changedTouches[0]:e,o=n.clientX,s=n.clientY;r||(r=Date.now()),i.push({x:o,y:s,id:R.getId(t),timeOffset:Date.now()-r}),a(j(e))}),o,{trailing:!1}),c=[_("mousemove",s),_("touchmove",s)];return function(){c.forEach((function(e){return e()}))}}(t.mousemoveCb,t.sampling),f=K(t.mouseInteractionCb,t.blockClass,t.sampling),h=function(e,t,n){return _("scroll",O((function(n){if(n.target&&!F(n.target,t)){var r=R.getId(n.target);if(n.target===document){var o=document.scrollingElement||document.documentElement;e({id:r,x:o.scrollLeft,y:o.scrollTop})}else e({id:r,x:n.target.scrollLeft,y:n.target.scrollTop})}}),n.scroll||100))}(t.scrollCb,t.blockClass,t.sampling),m=function(e){return _("resize",O((function(){var t=D(),n=L();e({width:Number(n),height:Number(t)})}),200),window)}(t.viewportResizeCb),v=function(e,t,r,o,a){function s(e){var n=e.target;if(n&&n.tagName&&!(Z.indexOf(n.tagName)<0)&&!F(n,t)){var i=n.type;if("password"!==i&&!n.classList.contains(r)){var a=n.value,s=!1;"radio"===i||"checkbox"===i?s=n.checked:(o[n.tagName.toLowerCase()]||o[i])&&(a="*".repeat(a.length)),c(n,{text:a,isChecked:s});var u=n.name;"radio"===i&&u&&s&&document.querySelectorAll('input[type="radio"][name="'+u+'"]').forEach((function(e){e!==n&&c(e,{text:e.value,isChecked:!s})}))}}}function c(t,r){var o=J.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){J.set(t,r);var i=R.getId(t);e(n(n({},r),{id:i}))}}var u=("last"===a.input?["change"]:["input","change"]).map((function(e){return _(e,s)})),l=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value"),d=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"]];return l&&l.set&&u.push.apply(u,i(d.map((function(e){return A(e[0],e[1],{set:function(){s({target:this})}})})))),function(){u.forEach((function(e){return e()}))}}(t.inputCb,t.blockClass,t.ignoreClass,t.maskInputOptions,t.sampling),y=function(e,t){var n=function(n){return function(r){var o=r.target;o&&!F(o,t)&&e({type:"play"===n?x.Play:x.Pause,id:R.getId(o)})}},r=[_("play",n("play")),_("pause",n("pause"))];return function(){r.forEach((function(e){return e()}))}}(t.mediaInteractionCb,t.blockClass),g=function(e){var t=CSSStyleSheet.prototype.insertRule;CSSStyleSheet.prototype.insertRule=function(n,r){var o=R.getId(this.ownerNode);return-1!==o&&e({id:o,adds:[{rule:n,index:r}]}),t.apply(this,arguments)};var n=CSSStyleSheet.prototype.deleteRule;return CSSStyleSheet.prototype.deleteRule=function(t){var r=R.getId(this.ownerNode);return-1!==r&&e({id:r,removes:[{index:t}]}),n.apply(this,arguments)},function(){CSSStyleSheet.prototype.insertRule=t,CSSStyleSheet.prototype.deleteRule=n}}(t.styleSheetRuleCb);return function(){d.disconnect(),p(),f(),h(),m(),v(),y(),g()}}function ee(e){return n(n({},e),{timestamp:Date.now()})}function te(t){void 0===t&&(t={});var r=t.emit,i=t.checkoutEveryNms,a=t.checkoutEveryNth,s=t.blockClass,c=void 0===s?"rr-block":s,u=t.ignoreClass,l=void 0===u?"rr-ignore":u,d=t.inlineStylesheet,p=void 0===d||d,f=t.maskAllInputs,h=t.maskInputOptions,m=t.hooks,y=t.packFn,g=t.sampling,b=void 0===g?{}:g,S=t.mousemoveWait;if(!r)throw new Error("emit function is required");void 0!==S&&void 0===b.mousemove&&(b.mousemove=S);var E,w=!0===f?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:void 0!==h?h:{};B();var I=0;function x(t){var n,r,i,a;void 0===t&&(t=!1),$(ee({type:e.EventType.Meta,data:{href:window.location.href,width:L(),height:D()}}),t);var s=o(function(e,t,n,r){void 0===t&&(t="rr-block"),void 0===n&&(n=!0);var o={};return[v(e,e,o,t,!1,n,!0===r?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0}:!1===r?{}:r),o]}(document,c,p,w),2),u=s[0],l=s[1];if(!u)return console.warn("Failed to snapshot the document");R.map=l,$(ee({type:e.EventType.FullSnapshot,data:{node:u,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(r=null===(n=null===document||void 0===document?void 0:document.body)||void 0===n?void 0:n.parentElement)||void 0===r?void 0:r.scrollLeft)||(null===document||void 0===document?void 0:document.body.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(a=null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.parentElement)||void 0===a?void 0:a.scrollTop)||(null===document||void 0===document?void 0:document.body.scrollTop)||0}}}))}$=function(t,n){if(r(y?y(t):t,n),t.type===e.EventType.FullSnapshot)E=t,I=0;else if(t.type===e.EventType.IncrementalSnapshot){I++;var o=a&&I>=a,s=i&&t.timestamp-E.timestamp>i;(o||s)&&x(!0)}};try{var T=[];T.push(_("DOMContentLoaded",(function(){$(ee({type:e.EventType.DomContentLoaded,data:{}}))})));var C=function(){x(),T.push(Q({mutationCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Mutation},t)}))},mousemoveCb:function(t,n){return $(ee({type:e.EventType.IncrementalSnapshot,data:{source:n,positions:t}}))},mouseInteractionCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MouseInteraction},t)}))},scrollCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Scroll},t)}))},viewportResizeCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.ViewportResize},t)}))},inputCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.Input},t)}))},mediaInteractionCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.MediaInteraction},t)}))},styleSheetRuleCb:function(t){return $(ee({type:e.EventType.IncrementalSnapshot,data:n({source:e.IncrementalSource.StyleSheetRule},t)}))},blockClass:c,ignoreClass:l,maskInputOptions:w,inlineStylesheet:p,sampling:b},m))};return"interactive"===document.readyState||"complete"===document.readyState?C():T.push(_("load",(function(){$(ee({type:e.EventType.Load,data:{}})),C()}),window)),function(){T.forEach((function(e){return e()}))}}catch(e){console.warn(e)}}function ne(e){return e=e||Object.create(null),{on:function(t,n){(e[t]||(e[t]=[])).push(n)},off:function(t,n){e[t]&&e[t].splice(e[t].indexOf(n)>>>0,1)},emit:function(t,n){(e[t]||[]).slice().map((function(e){e(n)})),(e["*"]||[]).slice().map((function(e){e(t,n)}))}}}te.addCustomEvent=function(t,n){if(!$)throw new Error("please add custom event after start recording");$(ee({type:e.EventType.Custom,data:{tag:t,payload:n}}))};var re=Object.freeze({__proto__:null,default:ne});var oe,ie=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){e.exports={polyfill:function(){var e=window,t=document;if(!("scrollBehavior"in t.documentElement.style)||!0===e.__forceSmoothScrollPolyfill__){var n,r=e.HTMLElement||e.Element,o={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||s,scrollIntoView:r.prototype.scrollIntoView},i=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,a=(n=e.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(n)?1:0);e.scroll=e.scrollTo=function(){void 0!==arguments[0]&&(!0!==c(arguments[0])?h.call(e,t.body,void 0!==arguments[0].left?~~arguments[0].left:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:e.scrollY||e.pageYOffset):o.scroll.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:e.scrollX||e.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:e.scrollY||e.pageYOffset))},e.scrollBy=function(){void 0!==arguments[0]&&(c(arguments[0])?o.scrollBy.call(e,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset)))},r.prototype.scroll=r.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==c(arguments[0])){var e=arguments[0].left,t=arguments[0].top;h.call(this,this,void 0===e?this.scrollLeft:~~e,void 0===t?this.scrollTop:~~t)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},r.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==c(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):o.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},r.prototype.scrollIntoView=function(){if(!0!==c(arguments[0])){var n=p(this),r=n.getBoundingClientRect(),i=this.getBoundingClientRect();n!==t.body?(h.call(this,n,n.scrollLeft+i.left-r.left,n.scrollTop+i.top-r.top),"fixed"!==e.getComputedStyle(n).position&&e.scrollBy({left:r.left,top:r.top,behavior:"smooth"})):e.scrollBy({left:i.left,top:i.top,behavior:"smooth"})}else o.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function c(e){if(null===e||"object"!=typeof e||void 0===e.behavior||"auto"===e.behavior||"instant"===e.behavior)return!0;if("object"==typeof e&&"smooth"===e.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+e.behavior+" is not a valid value for enumeration ScrollBehavior.")}function u(e,t){return"Y"===t?e.clientHeight+a<e.scrollHeight:"X"===t?e.clientWidth+a<e.scrollWidth:void 0}function l(t,n){var r=e.getComputedStyle(t,null)["overflow"+n];return"auto"===r||"scroll"===r}function d(e){var t=u(e,"Y")&&l(e,"Y"),n=u(e,"X")&&l(e,"X");return t||n}function p(e){for(;e!==t.body&&!1===d(e);)e=e.parentNode||e.host;return e}function f(t){var n,r,o,a,s=(i()-t.startTime)/468;a=s=s>1?1:s,n=.5*(1-Math.cos(Math.PI*a)),r=t.startX+(t.x-t.startX)*n,o=t.startY+(t.y-t.startY)*n,t.method.call(t.scrollable,r,o),r===t.x&&o===t.y||e.requestAnimationFrame(f.bind(e,t))}function h(n,r,a){var c,u,l,d,p=i();n===t.body?(c=e,u=e.scrollX||e.pageXOffset,l=e.scrollY||e.pageYOffset,d=o.scroll):(c=n,u=n.scrollLeft,l=n.scrollTop,d=s),f({scrollable:c,method:d,startTime:p,startX:u,startY:l,x:r,y:a})}}}})).polyfill,ae=function(){function e(e,t){void 0===e&&(e=[]),this.timeOffset=0,this.actions=e,this.speed=t}return e.prototype.addAction=function(e){var t=this.findActionIndex(e);this.actions.splice(t,0,e)},e.prototype.addActions=function(e){var t;(t=this.actions).push.apply(t,i(e))},e.prototype.start=function(){this.actions.sort((function(e,t){return e.delay-t.delay})),this.timeOffset=0;var e=performance.now(),t=this.actions,n=this;this.raf=requestAnimationFrame((function r(o){for(n.timeOffset+=(o-e)*n.speed,e=o;t.length;){var i=t[0];if(!(n.timeOffset>=i.delay))break;t.shift(),i.doAction()}(t.length>0||n.liveMode)&&(n.raf=requestAnimationFrame(r))}))},e.prototype.clear=function(){this.raf&&cancelAnimationFrame(this.raf),this.actions.length=0},e.prototype.setSpeed=function(e){this.speed=e},e.prototype.toggleLiveMode=function(e){this.liveMode=e},e.prototype.findActionIndex=function(e){for(var t=0,n=this.actions.length-1;t<=n;){var r=Math.floor((t+n)/2);if(this.actions[r].delay<e.delay)t=r+1;else{if(!(this.actions[r].delay>e.delay))return r;n=r-1}}return t},e}();function se(t,n){if(t.type===e.EventType.IncrementalSnapshot&&t.data.source===e.IncrementalSource.MouseMove){var r=t.data.positions[0].timeOffset,o=t.timestamp+r;return t.delay=o-n,o-n}return t.delay=t.timestamp-n,t.delay}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(oe||(oe={}));var ce={type:"xstate.init"};function ue(e){return void 0===e?[]:[].concat(e)}function le(e){return{type:"xstate.assign",assignment:e}}function de(e,t){return"string"==typeof(e="string"==typeof e&&t&&t[e]?t[e]:e)?{type:e}:"function"==typeof e?{type:e.name,exec:e}:e}function pe(e){return function(t){return e===t}}function fe(e){return"string"==typeof e?{type:e}:e}function he(e,t){return{value:e,context:t,actions:[],changed:!1,matches:pe(e)}}function me(e,t){void 0===t&&(t={});var n={config:e,_options:t,initialState:{value:e.initial,actions:ue(e.states[e.initial].entry).map((function(e){return de(e,t.actions)})),context:e.context,matches:pe(e.initial)},transition:function(t,r){var o,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,c=a.context,u=fe(r),l=e.states[s];if(l.on){var d=ue(l.on[u.type]),p=function(t){if(void 0===t)return{value:he(s,c)};var r="string"==typeof t?{target:t}:t,o=r.target,i=void 0===o?s:o,a=r.actions,d=void 0===a?[]:a,p=r.cond,f=c;if((void 0===p?function(){return!0}:p)(c,u)){var h=e.states[i],m=!1,v=[].concat(l.exit,d,h.entry).filter((function(e){return e})).map((function(e){return de(e,n._options.actions)})).filter((function(e){if("xstate.assign"===e.type){m=!0;var t=Object.assign({},f);return"function"==typeof e.assignment?t=e.assignment(f,u):Object.keys(e.assignment).forEach((function(n){t[n]="function"==typeof e.assignment[n]?e.assignment[n](f,u):e.assignment[n]})),f=t,!1}return!0}));return{value:{value:i,context:f,actions:v,changed:i!==s||v.length>0||m,matches:pe(i)}}}};try{for(var f=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(d),h=f.next();!h.done;h=f.next()){var m=p(h.value);if("object"==typeof m)return m.value}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}}return he(s,c)}};return n}var ve=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};function ye(e){var t=e.initialState,n=oe.NotStarted,r=new Set,o={_machine:e,send:function(o){n===oe.Running&&(t=e.transition(t,o),ve(t,fe(o)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(){return n=oe.Running,ve(t,ce),o},stop:function(){return n=oe.Stopped,r.clear(),o},get state(){return t},get status(){return n}};return o}function ge(t,o){var i=o.getCastFn,a=o.emitter;return ye(me({id:"player",context:t,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]}}}}},{actions:{castEvent:le({lastPlayedEvent:function(e,t){return"CAST_EVENT"===t.type?t.payload.event:e.lastPlayedEvent}}),recordTimeOffset:le((function(e,t){var r=e.timeOffset;return"payload"in t&&"timeOffset"in t.payload&&(r=t.payload.timeOffset),n(n({},e),{timeOffset:r,baselineTime:e.events[0].timestamp+r})})),play:function(t){var n,o,s,c,u=t.timer,l=t.events,d=t.baselineTime,p=t.lastPlayedEvent;u.clear();try{for(var f=r(l),h=f.next();!h.done;h=f.next()){se(h.value,d)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(o=f.return)&&o.call(f)}finally{if(n)throw n.error}}var m=function(t,n){for(var r=t.length-1;r>=0;r--){var o=t[r];if(o.type===e.EventType.Meta&&o.timestamp<=n)return t.slice(r)}return t}(l,d),v=new Array,y=function(t){if(p&&p.timestamp<d&&(t.timestamp<=p.timestamp||t===p))return"continue";var n=t.timestamp<d;if(n&&!z(t))return"continue";var r=i(t,n);n?r():v.push({doAction:function(){r(),a.emit(e.ReplayerEvents.EventCast,t)},delay:t.delay})};try{for(var g=r(m),b=g.next();!b.done;b=g.next()){y(b.value)}}catch(e){s={error:e}}finally{try{b&&!b.done&&(c=g.return)&&c.call(g)}finally{if(s)throw s.error}}a.emit(e.ReplayerEvents.Flush),u.addActions(v),u.start()},pause:function(e){e.timer.clear()},resetLastPlayedEvent:le((function(e){return n(n({},e),{lastPlayedEvent:null})})),startLive:le({baselineTime:function(e,t){return e.timer.toggleLiveMode(!0),e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:le((function(t,r){var o=t.baselineTime,s=t.timer,c=t.events;if("ADD_EVENT"===r.type){var u=r.payload.event;se(u,o),c.push(u);var l=u.timestamp<o,d=i(u,l);l?d():s.addAction({doAction:function(){d(),a.emit(e.ReplayerEvents.EventCast,u)},delay:u.delay})}return n(n({},t),{events:c})}))}}))}var be=ne||re,Se={speed:1,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0},Ee=function(){function i(n,i){var a=this;if(this.emitter=be(),this.legacy_missingNodeRetryMap={},!(null==i?void 0:i.liveMode)&&n.length<2)throw new Error("Replayer need at least 2 events.");this.config=Object.assign({},Se,i),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(e.ReplayerEvents.Resize,this.handleResize),ie(),B(),this.setupDom(),this.treeIndex=new V,this.fragmentParentMap=new Map,this.emitter.on(e.ReplayerEvents.Flush,(function(){var e,n,i,s,c,u,l=a.treeIndex.flush(),d=l.scrollMap,p=l.inputMap;try{for(var f=r(d.values()),h=f.next();!h.done;h=f.next()){var m=h.value;a.applyScroll(m)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(n=f.return)&&n.call(f)}finally{if(e)throw e.error}}try{for(var v=r(p.values()),y=v.next();!y.done;y=v.next()){m=y.value;a.applyInput(m)}}catch(e){i={error:e}}finally{try{y&&!y.done&&(s=v.return)&&s.call(v)}finally{if(i)throw i.error}}try{for(var g=r(a.fragmentParentMap.entries()),b=g.next();!b.done;b=g.next()){var S=o(b.value,2),E=S[0],w=S[1];R.map[w.__sn.id]=w,w.__sn.type===t.Element&&"textarea"===w.__sn.tagName&&E.textContent&&(w.value=E.textContent),w.appendChild(E)}}catch(e){c={error:e}}finally{try{b&&!b.done&&(u=g.return)&&u.call(g)}finally{if(c)throw c.error}}a.fragmentParentMap.clear()}));var s=new ae([],(null==i?void 0:i.speed)||Se.speed);this.service=ge({events:n.map((function(e){return i&&i.unpackFn?i.unpackFn(e):e})),timer:s,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(t){a.emitter.emit(e.ReplayerEvents.StateChange,{player:t})})),this.speedService=ye(me({id:"speed",context:{normalSpeed:-1,timer:s},initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:function(e,t){"payload"in t&&e.timer.setSpeed(t.payload.speed)},recordSpeed:le({normalSpeed:function(e){return e.timer.speed}}),restoreSpeed:function(e){e.timer.setSpeed(e.normalSpeed)}}})),this.speedService.start(),this.speedService.subscribe((function(t){a.emitter.emit(e.ReplayerEvents.StateChange,{speed:t})}));var c=this.service.state.context.events.find((function(t){return t.type===e.EventType.Meta})),u=this.service.state.context.events.find((function(t){return t.type===e.EventType.FullSnapshot}));if(c){var l=c.data,d=l.width,p=l.height;setTimeout((function(){a.emitter.emit(e.ReplayerEvents.Resize,{width:d,height:p})}),0)}u&&this.rebuildFullSnapshot(u)}return Object.defineProperty(i.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),i.prototype.on=function(e,t){this.emitter.on(e,t)},i.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),this.config.skipInactive||this.backToNormal()},i.prototype.getMetaData=function(){var e=this.service.state.context.events[0],t=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:t.timestamp,totalTime:t.timestamp-e.timestamp}},i.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},i.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},i.prototype.play=function(t){void 0===t&&(t=0),this.service.state.matches("paused")||this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}}),this.emitter.emit(e.ReplayerEvents.Start)},i.prototype.pause=function(t){void 0===t&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),"number"==typeof t&&(this.play(t),this.service.send({type:"PAUSE"})),this.emitter.emit(e.ReplayerEvents.Pause)},i.prototype.resume=function(t){void 0===t&&(t=0),console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(e.ReplayerEvents.Resume)},i.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},i.prototype.addEvent=function(e){var t=this,n=this.config.unpackFn?this.config.unpackFn(e):e;Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENT",payload:{event:n}})}))},i.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},i.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},i.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin"),this.disableInteract(),this.wrapper.appendChild(this.iframe)},i.prototype.handleResize=function(e){this.iframe.setAttribute("width",String(e.width)),this.iframe.setAttribute("height",String(e.height))},i.prototype.getCastFn=function(t,n){var o,i=this;switch(void 0===n&&(n=!1),t.type){case e.EventType.DomContentLoaded:case e.EventType.Load:break;case e.EventType.Custom:o=function(){i.emitter.emit(e.ReplayerEvents.CustomEvent,t)};break;case e.EventType.Meta:o=function(){return i.emitter.emit(e.ReplayerEvents.Resize,{width:t.data.width,height:t.data.height})};break;case e.EventType.FullSnapshot:o=function(){i.rebuildFullSnapshot(t),i.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case e.EventType.IncrementalSnapshot:o=function(){var o,a;if(i.applyIncremental(t,n),!n&&(t===i.nextUserInteractionEvent&&(i.nextUserInteractionEvent=null,i.backToNormal()),i.config.skipInactive&&!i.nextUserInteractionEvent)){try{for(var s=r(i.service.state.context.events),c=s.next();!c.done;c=s.next()){var u=c.value;if(!(u.timestamp<=t.timestamp)&&i.isUserInteraction(u)){u.delay-t.delay