UNPKG

@xysfe/memento-core

Version:

record and replay the web

29 lines (25 loc) 53.8 kB
var mementoCoreReplay=function(e){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var t,n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(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 l=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function c(e,t){void 0===t&&(t={});var n=1,r=1;function i(e){var t=e.match(/\n/g);t&&(n+=t.length);var i=e.lastIndexOf("\n");r=-1===i?r+e.length:e.length-i}function o(){var e={line:n,column:r};return function(t){return t.position=new a(e),m(),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(i){var o=new Error(t.source+":"+n+":"+r+": "+i);if(o.reason=i,o.filename=t.source,o.line=n,o.column=r,o.source=e,!t.silent)throw o;s.push(o)}function f(){return h(/^{\s*/)}function d(){return h(/^}/)}function p(){var t,n=[];for(m(),v(n);e.length&&"}"!==e.charAt(0)&&(t=I()||N());)!1!==t&&(n.push(t),v(n));return n}function h(t){var n=t.exec(e);if(n){var r=n[0];return i(r),e=e.slice(r.length),n}}function m(){h(/^\s*/)}function v(e){var t;for(void 0===e&&(e=[]);t=y();)!1!==t&&e.push(t),t=y();return e}function y(){var t=o();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,i(a),e=e.slice(n),r+=2,t({type:"comment",comment:a})}}function g(){var e=h(/^([^{]+)/);if(e)return u(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 b(){var e=o(),t=h(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var n=u(t[0]);if(!h(/^:\s*/))return c("property missing ':'");var r=h(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:n.replace(l,""),value:r?u(r[0]).replace(l,""):""});return h(/^[;\s]*/),i}}function w(){var e,t=[];if(!f())return c("missing '{'");for(v(t);e=b();)!1!==e&&(t.push(e),v(t)),e=b();return d()?t:c("missing '}'")}function x(){for(var e,t=[],n=o();e=h(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),h(/^,\s*/);if(t.length)return n({type:"keyframe",values:t,declarations:w()})}var E,S=C("import"),M=C("charset"),T=C("namespace");function C(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var n=o(),r=h(t);if(r){var i={type:e};return i[e]=r[1].trim(),n(i)}}}function I(){if("@"===e[0])return function(){var e=o(),t=h(/^@([-\w]+)?keyframes\s*/);if(t){var n=t[1];if(!(t=h(/^([-\w]+)\s*/)))return c("@keyframes missing name");var r,i=t[1];if(!f())return c("@keyframes missing '{'");for(var a=v();r=x();)a.push(r),a=a.concat(v());return d()?e({type:"keyframes",name:i,vendor:n,keyframes:a}):c("@keyframes missing '}'")}}()||function(){var e=o(),t=h(/^@media *([^{]+)/);if(t){var n=u(t[1]);if(!f())return c("@media missing '{'");var r=v().concat(p());return d()?e({type:"media",media:n,rules:r}):c("@media missing '}'")}}()||function(){var e=o(),t=h(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:u(t[1]),media:u(t[2])})}()||function(){var e=o(),t=h(/^@supports *([^{]+)/);if(t){var n=u(t[1]);if(!f())return c("@supports missing '{'");var r=v().concat(p());return d()?e({type:"supports",supports:n,rules:r}):c("@supports missing '}'")}}()||S()||M()||T()||function(){var e=o(),t=h(/^@([-\w]+)?document *([^{]+)/);if(t){var n=u(t[1]),r=u(t[2]);if(!f())return c("@document missing '{'");var i=v().concat(p());return d()?e({type:"document",document:r,vendor:n,rules:i}):c("@document missing '}'")}}()||function(){var e=o();if(h(/^@page */)){var t=g()||[];if(!f())return c("@page missing '{'");for(var n,r=v();n=b();)r.push(n),r=r.concat(v());return d()?e({type:"page",selectors:t,declarations:r}):c("@page missing '}'")}}()||function(){var e=o();if(h(/^@host\s*/)){if(!f())return c("@host missing '{'");var t=v().concat(p());return d()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=o();if(h(/^@font-face\s*/)){if(!f())return c("@font-face missing '{'");for(var t,n=v();t=b();)n.push(t),n=n.concat(v());return d()?e({type:"font-face",declarations:n}):c("@font-face missing '}'")}}()}function N(){var e=o(),t=g();return t?(v(),e({type:"rule",selectors:t,declarations:w()})):c("selector missing")}return function e(t,n){for(var r=t&&"string"==typeof t.type,i=r?t:n,o=0,a=Object.keys(t);o<a.length;o++){var s=a[o],l=t[s];Array.isArray(l)?l.forEach((function(t){e(t,i)})):l&&"object"==typeof l&&e(l,i)}r&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:n||null});return t}((E=p(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function u(e){return e?e.replace(/^\s+|\s+$/g,""):""}var f={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 d=/([^\\]):hover/g,p=/(\s|;|\{)inset\s*:([^;}]+)/gi;function h(e){var t=c(e,{silent:!0});return t.stylesheet&&t.stylesheet.rules?(t.stylesheet.rules.forEach((function(t){"selectors"in t&&(t.selectors||[]).forEach((function(t){if(d.test(t)){var n=t.replace(d,"$1.\\:hover");e=e.replace(t,t+", "+n)}}))})),e.replace(p,"$1top: $2; right: $2; bottom: $2; left: $2;")):e}var m=/url\((data:image\/svg\+xml;charset=[\w-].*?)\)\s*(;|\}|$)/gi;function v(e){return e?e.replace(m,(function(e,t,n){return'url("'+t+'")'+n})):e}function y(e,n,r,i){switch(void 0===i&&(i=!0),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,a=function(e){var t=f[e.tagName]?f[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",a):n.createElement(a);var s=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";if(e.attributes.hasOwnProperty("_memimage_"+t))return"continue";var s=e.attributes[t];s="boolean"==typeof s||"number"==typeof s?"":s;var l=t;if((t=t.replace("_memimage_","")).startsWith("mem_")){if("canvas"===a&&"mem_dataURL"===t){var c=document.createElement("img");c.src=s,c.onload=function(){var e=o.getContext("2d");e&&e.drawImage(c,0,0,c.width,c.height)}}"mem_imgwidth"===t||"mem_width"===t?o.style.width=s:"mem_imgheight"===t||"mem_height"===t?o.style.height=s:"video"===a&&"mem_placeholder"===l&&(o.style.background="center / cover no-repeat url("+s+") !important")}else{var u="textarea"===a&&"value"===t,f="style"===a&&"_cssText"===t;if(f&&r&&(s=v(s=h(s))),u||f){for(var d=n.createTextNode(s),p=0,m=Array.from(o.childNodes);p<m.length;p++){var y=m[p];y.nodeType===o.TEXT_NODE&&o.removeChild(y)}return o.appendChild(d),"continue"}if("iframe"===a&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?o.setAttributeNS("http://www.w3.org/1999/xlink",t,s):"onload"===t||"onclick"===t||"onmouse"===t.substring(0,7)?o.setAttribute("_"+t,s):(i&&"link"===a&&"_memimage_href"===l&&s&&s.match(/memento\.oss/)&&(s=s.replace(/^http\:\/\//,"https://")),o.setAttribute(t,s))}catch(e){}}};for(var l in e.attributes)s(l);return o;case t.Text:var c=e.isStyle?v(e.textContent):e.textContent;return n.createTextNode(e.isStyle&&r?h(c):c);case t.CDATA:return n.createCDATASection(e.textContent);case t.Comment:return n.createComment(e.textContent);default:return null}}function g(e,n,r,i,o,a){void 0===i&&(i=!1),void 0===o&&(o=!0),void 0===a&&(a=!0);var s=y(e,n,o,a);if(!s)return null;if(e.type===t.Document&&(n.close(),n.open(),s=n),s.__sn=e,r[e.id]=s,(e.type===t.Document||e.type===t.Element)&&!i)for(var l=0,c=e.childNodes;l<c.length;l++){var u=c[l],f=g(u,n,r,!1,o,a);f?s.appendChild(f):console.warn("Failed to rebuild",u)}return s}function b(e,n,r,i){void 0===r&&(r=!0),void 0===i&&(i=!0);var o={},a=g(e,n,o,!1,r,i);return function(e){for(var n in e){var r=e[n],i=r.__sn;if(i.type===t.Element){var o=r;for(var a in i.attributes)if(i.attributes.hasOwnProperty(a)&&a.startsWith("mem_")){var s=i.attributes[a];"mem_scrollLeft"===a&&(o.scrollLeft=s),"mem_scrollTop"===a&&(o.scrollTop=s)}}}}(o),[a,o]}function w(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)}))}}}var x=Object.freeze({__proto__:null,default:w});var E,S,M,T,C,I,N,A,_=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,i={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||s,scrollIntoView:r.prototype.scrollIntoView},o=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!==l(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):i.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]&&(l(arguments[0])?i.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!==l(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");i.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!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):i.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!==l(arguments[0])){var n=d(this),r=n.getBoundingClientRect(),o=this.getBoundingClientRect();n!==t.body?(h.call(this,n,n.scrollLeft+o.left-r.left,n.scrollTop+o.top-r.top),"fixed"!==e.getComputedStyle(n).position&&e.scrollBy({left:r.left,top:r.top,behavior:"smooth"})):e.scrollBy({left:o.left,top:o.top,behavior:"smooth"})}else i.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(e,t){this.scrollLeft=e,this.scrollTop=t}function l(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 c(e,t){return"Y"===t?e.clientHeight+a<e.scrollHeight:"X"===t?e.clientWidth+a<e.scrollWidth:void 0}function u(t,n){var r=e.getComputedStyle(t,null)["overflow"+n];return"auto"===r||"scroll"===r}function f(e){var t=c(e,"Y")&&u(e,"Y"),n=c(e,"X")&&u(e,"X");return t||n}function d(e){for(;e!==t.body&&!1===f(e);)e=e.parentNode||e.host;return e}function p(t){var n,r,i,a,s=(o()-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,i=t.startY+(t.y-t.startY)*n,t.method.call(t.scrollable,r,i),r===t.x&&i===t.y||e.requestAnimationFrame(p.bind(e,t))}function h(n,r,a){var l,c,u,f,d=o();n===t.body?(l=e,c=e.scrollX||e.pageXOffset,u=e.scrollY||e.pageYOffset,f=i.scroll):(l=n,c=n.scrollLeft,u=n.scrollTop,f=s),p({scrollable:l,method:f,startTime:d,startX:c,startY:u,x:r,y:a})}}}})).polyfill;!function(e){e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.PageChange=5]="PageChange",e[e.Custom=9]="Custom",e[e.Other=99]="Other"}(E||(E={})),function(e){e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Drag=10]="Drag",e[e.UserDefinedEvent=11]="UserDefinedEvent"}(S||(S={})),function(e){e[e.LivePlay=0]="LivePlay"}(M||(M={})),function(e){e[e.Console=1]="Console",e[e.Network=2]="Network"}(T||(T={})),function(e){e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd"}(C||(C={})),function(e){e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2"}(I||(I={})),function(e){e[e.Play=0]="Play",e[e.Pause=1]="Pause"}(N||(N={})),function(e){e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.AddEvents="add-events"}(A||(A={}));var k,D=function(){function e(e,t){void 0===t&&(t=[]),this.timeOffset=0,this.actions=t,this.config=e}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,s(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.config,r=this;this.raf=requestAnimationFrame((function i(o){for(r.timeOffset+=(o-e)*n.speed,e=o;t.length;){var a=t[0];if(!(r.timeOffset>=a.delay))break;t.shift(),a.doAction()}(t.length>0||r.config.liveMode)&&(r.raf&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(i))}))},e.prototype.clear=function(){this.raf&&cancelAnimationFrame(this.raf),this.actions.length=0},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 L(e,t){if(e.type===E.IncrementalSnapshot&&e.data.source===S.MouseMove){var n=e.data.positions[0].timeOffset,r=e.timestamp+n;return e.delay=r-t,r-t}return e.delay=e.timestamp-t,e.timestamp-t} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function P(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}!function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"}(k||(k={}));var O={type:"xstate.init"};function F(e){return void 0===e?[]:[].concat(e)}function R(e){return{type:"xstate.assign",assignment:e}}function j(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 B(e){return function(t){return e===t}}function U(e){return"string"==typeof e?{type:e}:e}function W(e,t){return{value:e,context:t,actions:[],changed:!1,matches:B(e)}}function V(e,t,n){var r=t,i=!1;return[e.filter((function(e){if("xstate.assign"===e.type){i=!0;var t=Object.assign({},r);return"function"==typeof e.assignment?t=e.assignment(r,n):Object.keys(e.assignment).forEach((function(i){t[i]="function"==typeof e.assignment[i]?e.assignment[i](r,n):e.assignment[i]})),r=t,!1}return!0})),r,i]}var G=function(e,t){return e.actions.forEach((function(n){var r=n.exec;return r&&r(e.context,t)}))};var z={map:{},getId:function(e){return e&&e.__sn?e.__sn.id:-1},getNode:function(e){return z.map[e]||null},removeNodeFromMap:function(e){var t=e.__sn&&e.__sn.id;delete z.map[t],e.childNodes&&e.childNodes.forEach((function(e){return z.removeNodeFromMap(e)}))},has:function(e){return z.map.hasOwnProperty(e)}};function Y(e){switch(e.type){case E.DomContentLoaded:case E.Load:case E.PageChange:case E.Custom:return!1;case E.FullSnapshot:case E.Meta:return!0}switch(e.data.source){case S.MouseMove:case S.MouseInteraction:case S.TouchMove:case S.MediaInteraction:return!1;case S.ViewportResize:case S.StyleSheetRule:case S.Scroll:case S.Input:return!0}return!0}var H=function(){function e(){this.reset()}return e.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)},e.prototype.remove=function(e){var t=this,n=this.indexes.get(e.parentId),r=this.indexes.get(e.id),i=function(e){t.removeIdSet.add(e);var n=z.getNode(e);null==n||n.childNodes.forEach((function(e){return i(e.__sn.id)}))},o=function(n){t.removeIdSet.add(n.id),Object.values(n.children).forEach((function(e){return o(e)}));var r=t.indexes.get(n.id);if(r){var i=r.parent;i&&(delete r.parent,delete i.children[r.id],t.indexes.delete(e.id))}};r?n?(delete r.parent,delete n.children[r.id],this.indexes.delete(e.id),o(r)):(delete this.tree[r.id],this.indexes.delete(r.id),o(r)):(this.removeNodeMutations.push(e),i(e.id))},e.prototype.text=function(e){var t=this.indexes.get(e.id);t?t.texts.push(e):this.textMutations.push(e)},e.prototype.attribute=function(e){var t=this.indexes.get(e.id);t?t.attributes.push(e):this.attributeMutations.push(e)},e.prototype.scroll=function(e){this.scrollMap.set(e.id,e)},e.prototype.input=function(e){this.inputMap.set(e.id,e)},e.prototype.flush=function(){var e,t,n,r,i=this,a=this.tree,s=this.removeNodeMutations,l=this.textMutations,c=this.attributeMutations,u={source:S.Mutation,removes:s,texts:l,attributes:c,adds:[]},f=function(e,t){t&&i.removeIdSet.add(e.id),u.texts=u.texts.concat(t?[]:e.texts).filter((function(e){return!i.removeIdSet.has(e.id)})),u.attributes=u.attributes.concat(t?[]:e.attributes).filter((function(e){return!i.removeIdSet.has(e.id)})),i.removeIdSet.has(e.id)||i.removeIdSet.has(e.mutation.parentId)||t?Object.values(e.children).forEach((function(e){return f(e,!0)})):(u.adds.push(e.mutation),e.children&&Object.values(e.children).forEach((function(e){return f(e,!1)})))};Object.values(a).forEach((function(e){return f(e,!1)}));try{for(var d=o(this.scrollMap.keys()),p=d.next();!p.done;p=d.next()){var h=p.value;this.removeIdSet.has(h)&&this.scrollMap.delete(h)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(t=d.return)&&t.call(d)}finally{if(e)throw e.error}}try{for(var m=o(this.inputMap.keys()),v=m.next();!v.done;v=m.next()){h=v.value;this.removeIdSet.has(h)&&this.inputMap.delete(h)}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}var y=new Map(this.scrollMap),g=new Map(this.inputMap);return this.reset(),{mutationData:u,scrollMap:y,inputMap:g}},e.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},e}();function X(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.type===E.Meta&&r.timestamp<=t)return e.slice(n)}return e}function $(e,t){var r=t.getCastFn,i=t.emitter;return function(e){var t=e.initialState,n=k.NotStarted,r=new Set,i={_machine:e,send:function(i){n===k.Running&&(t=e.transition(t,i),G(t,U(i)),r.forEach((function(e){return e(t)})))},subscribe:function(e){return r.add(e),e(t),{unsubscribe:function(){return r.delete(e)}}},start:function(r){if(r){var o="object"==typeof r?r:{context:e.config.context,value:r};t={value:o.value,actions:[],context:o.context,matches:B(o.value)}}return n=k.Running,G(t,O),i},stop:function(){return n=k.Stopped,r.clear(),i},get state(){return t},get status(){return n}};return i}(function(e,t){void 0===t&&(t={});var n=P(V(F(e.states[e.initial].entry).map((function(e){return j(e,t.actions)})),e.context,O),2),r=n[0],i=n[1],o={config:e,_options:t,initialState:{value:e.initial,actions:r,context:i,matches:B(e.initial)},transition:function(t,n){var r,i,a="string"==typeof t?{value:t,context:e.context}:t,s=a.value,l=a.context,c=U(n),u=e.states[s];if(u.on){var f=F(u.on[c.type]);try{for(var d=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(f),p=d.next();!p.done;p=d.next()){var h=p.value;if(void 0===h)return W(s,l);var m="string"==typeof h?{target:h}:h,v=m.target,y=m.actions,g=void 0===y?[]:y,b=m.cond,w=void 0===b?function(){return!0}:b,x=void 0===v,E=null!=v?v:s,S=e.states[E];if(w(l,c)){var M=P(V((x?F(g):[].concat(u.exit,g,S.entry).filter((function(e){return e}))).map((function(e){return j(e,o._options.actions)})),l,c),3),T=M[0],C=M[1],I=M[2],N=null!=v?v:s;return{value:N,context:C,actions:T,changed:v!==s||T.length>0||I,matches:B(N)}}}}catch(e){r={error:e}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}}return W(s,l)}};return o}({id:"player",context:e,initial:"inited",states:{inited:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},TO_LIVE:{target:"live",actions:["startLive"]}}},playing:{on:{PAUSE:{target:"paused",actions:["pause"]},PLAY:{target:"playing",actions:["recordTimeOffset","play"]},FAST_FORWARD:"skipping",CAST_EVENT:{target:"playing",actions:"castEvent"},ADD_EVENTS:{target:"playing",actions:["addEvents","recordTimeOffset"]}}},paused:{on:{RESUME:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},ADD_EVENTS:{target:"paused",actions:["addEvents"]}}},skipping:{on:{BACK_TO_NORMAL:"playing"}},ended:{on:{REPLAY:{target:"playing",actions:["recordTimeOffset","play"]},ADD_EVENTS:{target:"playing",actions:["addEvents","recordTimeOffset","play"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]}}}}},{actions:{castEvent:R({lastPlayedEvent:function(t,n){return"CAST_EVENT"===n.type?n.payload.event:e.lastPlayedEvent}}),recordTimeOffset:R((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(e){var t,n,a=e.timer,s=e.events,l=e.baselineTime;e.lastPlayedEvent,a.clear();var c=X(s,l),u=new Array,f=function(e){var t=e.timestamp<l;if(t&&!Y(e))return"continue";var n=r(e,t);t?n():u.push({doAction:function(){n(),i.emit(A.EventCast,e)},delay:L(e,l)})};try{for(var d=o(c),p=d.next();!p.done;p=d.next()){f(p.value)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}i.emit(A.Flush),a.addActions(u),a.start()},pause:function(e){e.timer.clear()},startLive:R({baselineTime:function(e,t){return e.timer.start(),"TO_LIVE"===t.type&&t.payload.baselineTime?t.payload.baselineTime:Date.now()}}),addEvent:R((function(e,t){var o=e.baselineTime,a=e.timer,s=e.events;if("ADD_EVENT"===t.type){var l=t.payload.event;s.push(l);var c=l.timestamp<o,u=r(l,c);c?u():a.addAction({doAction:function(){u(),i.emit(A.EventCast,l)},delay:L(l,o)})}return n(n({},e),{events:s})})),addEvents:R((function(e,t){var a,s,l=e.timer,c=e.events,u=e.baselineTime,f=e.lastPlayedEvent;if("ADD_EVENTS"===t.type){var d=t.payload.events;if(Array.isArray(d)&&d.length){c=c.concat(d);var p=X(d,u),h=new Array,m=function(e){if(f&&f.timestamp>u&&(e.timestamp<=f.timestamp||e===f))return"continue";var t=e.timestamp<u;if(t&&!Y(e))return"continue";var n=r(e,t);t?n():h.push({doAction:function(){n(),i.emit(A.EventCast,e)},delay:L(e,u)})};try{for(var v=o(p),y=v.next();!y.done;y=v.next()){m(y.value)}}catch(e){a={error:e}}finally{try{y&&!y.done&&(s=v.return)&&s.call(v)}finally{if(a)throw a.error}}i.emit(A.AddEvents),l.addActions(h)}}return n(n({},e),{events:c})}))}}))}for(var q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J="undefined"==typeof Uint8Array?[]:new Uint8Array(256),K=0;K<q.length;K++)J[q.charCodeAt(K)]=K;var Q=function(e){var t,n,r,i,o,a=.75*e.length,s=e.length,l=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var c=new ArrayBuffer(a),u=new Uint8Array(c);for(t=0;t<s;t+=4)n=J[e.charCodeAt(t)],r=J[e.charCodeAt(t+1)],i=J[e.charCodeAt(t+2)],o=J[e.charCodeAt(t+3)],u[l++]=n<<2|r>>4,u[l++]=(15&r)<<4|i>>2,u[l++]=(3&i)<<6|63&o;return c},Z=new Map;function ee(e,t){var n=Z.get(e);return n||(n=new Map,Z.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function te(e,t,n){var o=this;return function(a){return r(o,void 0,Promise,(function(){var r,o,l,c,u,f,d,p,h,m,v;return i(this,(function(i){switch(i.label){case 0:return a&&"object"==typeof a&&"rr_type"in a?(n&&(n.isUnchanged=!1),"ImageBitmap"===a.rr_type&&"args"in a?[4,te(e,t,n)(a.args)]:[3,3]):[3,11];case 1:return l=i.sent(),[4,createImageBitmap.apply(null,l)];case 2:return[2,i.sent()];case 3:return"index"in a?n||null===t?[2,a]:(o=a.rr_type,r=a.index,[2,ee(t,o)[r]]):[3,4];case 4:return"args"in a?(o=a.rr_type,l=a.args,c=window[o],f=(u=c.bind).apply,d=[c],p=[[void 0]],[4,Promise.all(l.map(te(e,t,n)))]):[3,6];case 5:return[2,new(f.apply(u,d.concat([s.apply(void 0,p.concat([i.sent()]))])))];case 6:return"base64"in a?[2,Q(a.base64)]:[3,7];case 7:return"src"in a?(h=e.get(a.src))?[2,h]:((m=new Image).src=a.src,e.set(a.src,m),[2,m]):[3,8];case 8:return"data"in a&&"Blob"===a.rr_type?[4,Promise.all(a.data.map(te(e,t,n)))]:[3,10];case 9:return v=i.sent(),[2,new Blob(v,{type:a.type})];case 10:return[3,13];case 11:return Array.isArray(a)?[4,Promise.all(a.map(te(e,t,n)))]:[3,13];case 12:return[2,i.sent()];case 13:return[2,a]}}))}))}}var ne=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function re(e){var t=e.mutation,n=e.target,o=e.type,a=e.imageMap,s=e.errorHandler;return r(this,void 0,Promise,(function(){var e,r,l,c,u;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),(e=function(e,t){try{return t===I.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(e){return null}}(n,o))?t.setter?(e[t.property]=t.args[0],[2]):(r=e[t.property],[4,Promise.all(t.args.map(te(a,e)))]):[2];case 1:return l=i.sent(),c=r.apply(e,l),function(e,t){if(null==t?void 0:t.constructor){var n=t.constructor.name;if(ne.includes(n)){var r=ee(e,n);r.includes(t)||r.push(t)}}}(e,c),!1,[3,3];case 2:return u=i.sent(),s(t,u),[3,3];case 3:return[2]}}))}))}function ie(e){var t=e.event,n=e.mutation,o=e.target,a=e.imageMap,s=e.errorHandler;return r(this,void 0,Promise,(function(){var e,r,l,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),e=o.getContext("2d"),n.setter?(e[n.property]=n.args[0],[2]):(r=e[n.property],"drawImage"!==n.property||"string"!=typeof n.args[0]?[3,1]:(a.get(t),r.apply(e,n.args),[3,3]));case 1:return[4,Promise.all(n.args.map(te(a,e)))];case 2:l=i.sent(),r.apply(e,l),i.label=3;case 3:return[3,5];case 4:return c=i.sent(),s(n,c),[3,5];case 5:return[2]}}))}))}var oe=w||x,ae={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"},se={normalSpeed:1,speed:1,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"mem-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,mouseTail:ae,forceSkipInactive:!1,mode:"player"},le=function(){function e(e,n){var r=this;if(this.mouseTail=null,this.tailPositions=[],this.emitter=oe(),this.normalSpeed=-1,this.legacy_missingNodeRetryMap={},this.unloadStylesheetMap={},this.imageMap=new Map,this.canvasEventMap=new Map,!(null==n?void 0:n.liveMode)&&e.length<2)throw new Error("Replayer need at least 2 events.");this.config=Object.assign({},se,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.emitter.on(A.Resize,this.handleResize),_(),"NodeList"in window&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),this.setupDom(),this.treeIndex=new H,this.fragmentParentMap=new Map,this.emitter.on(A.Flush,(function(){var e,n,i,s,l,c,u=r.treeIndex.flush(),f=u.scrollMap,d=u.inputMap;try{for(var p=o(f.values()),h=p.next();!h.done;h=p.next()){var m=h.value;r.applyScroll(m)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(n=p.return)&&n.call(p)}finally{if(e)throw e.error}}try{for(var v=o(d.values()),y=v.next();!y.done;y=v.next()){m=y.value;r.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=o(r.fragmentParentMap.entries()),b=g.next();!b.done;b=g.next()){var w=a(b.value,2),x=w[0],E=w[1];z.map[E.__sn.id]=E,E.__sn.type===t.Element&&"textarea"===E.__sn.tagName&&x.textContent&&(E.value=x.textContent),E.appendChild(x)}}catch(e){l={error:e}}finally{try{b&&!b.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}r.fragmentParentMap.clear()})),this.emitter.on(A.EventCast,(function(e){r.timeDisplayer&&(r.timeDisplayer.innerText=function(e,t){var n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var r in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+r+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?n[r]:("00"+n[r]).substr((""+n[r]).length)));return t}(new Date(e.timestamp),"yyyy/M/d hh:mm:ss"))})),this.service=$({events:e.map((function(e){return n&&n.unpackFn?n.unpackFn(e):e})),timer:new D(this.config),speed:(null==n?void 0:n.speed)||se.speed,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,emitter:this.emitter}),this.service.start(),this.service.subscribe((function(e){e.changed}));var i=this.service.state.context.events,s=i.find((function(e){return e.type===E.Meta})),l=i.find((function(e){return e.type===E.FullSnapshot}));if(s){var c=s.data,u=c.width,f=c.height;this.emitter.emit(A.Resize,{width:u,height:f})}l&&this.rebuildFullSnapshot(l)}return Object.defineProperty(e.prototype,"timer",{get:function(){return this.service.state.context.timer},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){this.emitter.on(e,t)},e.prototype.setConfig=function(e){var t=this;Object.keys(e).forEach((function(n){t.config[n]=e[n]})),this.config.skipInactive||(this.normalSpeed=-1),!("normalSpeed"in e)&&"speed"in e&&(this.config.normalSpeed=e.speed),void 0!==e.mouseTail&&(!1===e.mouseTail?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))},e.prototype.getMetaData=function(){var e=this.service.state.context.events,t=e[0],n=e[e.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}},e.prototype.getCurrentTime=function(){return this.timer.timeOffset+this.getTimeOffset()},e.prototype.getTimeOffset=function(){var e=this.service.state.context;return e.baselineTime-e.events[0].timestamp},e.prototype.play=function(e){void 0===e&&(e=0),this.nextUserInteractionEvent=null,this.restoreSpeed(),"ended"===this.service.state.value&&(this.service.state.context.lastPlayedEvent=null,this.service.send({type:"REPLAY",payload:{timeOffset:e}})),"paused"===this.service.state.value?this.service.send({type:"RESUME",payload:{timeOffset:e}}):this.service.send({type:"PLAY",payload:{timeOffset:e}}),this.emitter.emit(A.Start)},e.prototype.pause=function(){this.service.send({type:"PAUSE"}),this.emitter.emit(A.Pause)},e.prototype.resume=function(e){void 0===e&&(e=0),this.service.send({type:"RESUME",payload:{timeOffset:e}}),this.emitter.emit(A.Resume)},e.prototype.startLive=function(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})},e.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}})}))},e.prototype.addEvents=function(e){var t=this,n=e.map((function(e){return t.config.unpackFn?t.config.unpackFn(e):e}));Promise.resolve().then((function(){return t.service.send({type:"ADD_EVENTS",payload:{events:n}})}))},e.prototype.enableInteract=function(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"},e.prototype.disableInteract=function(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"},e.prototype.setupDom=function(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.timeDisplayer=document.createElement("span");var e=document.createElement("div");e.classList.add("replayer-time"),e.appendChild(this.timeDisplayer),this.wrapper.appendChild(e),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),!1!==this.config.mouseTail&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");var t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe)},e.prototype.handleResize=function(e){var t,n;this.iframe.style.display="inherit";try{for(var r=o([this.mouseTail,this.iframe]),i=r.next();!i.done;i=r.next()){var a=i.value;a&&(a.setAttribute("width",String(e.width)),a.setAttribute("height",String(e.height)))}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},e.prototype.getCastFn=function(e,t){var n,r=this;void 0===t&&(t=!1);var i=function(){if(!t){for(var n=r.service.state.context.events,i=0,o=0,a=n.length;o<a;o++)if(n[o]===e){i=o;break}if(r.config.forceSkipInactive)if(n[i+1]&&n[i+1].timestamp-e.timestamp>3e5)return void r.play(n[i+1].timestamp-n[0].timestamp);if(e===r.nextUserInteractionEvent&&(r.nextUserInteractionEvent=null,r.restoreSpeed()),r.config.skipInactive&&!r.nextUserInteractionEvent){var s=r.service.state.context.events;for(o=i+1,a=s.length;o<a;o++){var l=s[o];if(r.isUserInteraction(l)||l.type===E.FullSnapshot){l.delay-e.delay>1e4*r.config.speed&&(r.nextUserInteractionEvent=l);break}}if(r.nextUserInteractionEvent){r.normalSpeed=r.config.normalSpeed;var c=r.nextUserInteractionEvent.delay-e.delay,u={speed:Math.min(Math.round(c/5e3),3600),normalSpeed:r.normalSpeed};r.setConfig(u),r.emitter.emit(A.SkipStart,u)}}}};switch(e.type){case E.DomContentLoaded:case E.Load:case E.PageChange:break;case E.Custom:n=function(){r.emitter.emit(A.CustomEvent,e)};break;case E.Meta:n=function(){return r.emitter.emit(A.Resize,{width:e.data.width,height:e.data.height})};break;case E.FullSnapshot:n=function(){r.rebuildFullSnapshot(e),r.iframe.contentWindow.scrollTo(e.data.initialOffset),i()};break;case E.IncrementalSnapshot:n=function(){try{r.applyIncremental(e,t)}catch(e){console.error(e)}i()}}return function(){var t=r.service.state.context.events;n&&n(),r.service.send({type:"CAST_EVENT",payload:{event:e}}),e===t[t.length-1]&&(r.restoreSpeed(),r.service.send("END"),r.emitter.emit(A.Finish))}},e.prototype.rebuildFullSnapshot=function(e){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={},z.map=b(e.data.node,this.iframe.contentDocument,!0,this.config.cdnHttps)[1];var t=document.createElement("style"),n=this.iframe.contentDocument,r=n.documentElement,i=n.head;r.insertBefore(t,i);for(var o=function(e){var t=["iframe, ."+e.blockClass+" { background: #ccc }","noscript { display: none !important; }"];return"page"===e.mode&&(t.push(".mem-replayer-show { display: block !important; }"),t.push(".mem-replayer-hide { display: none !important; }"),t.push("::-webkit-scrollbar { display: none; }")),t}({blockClass:this.config.blockClass,mode:this.config.mode}).concat(this.config.insertStyleRules),a=0;a<o.length;a++)t.sheet.insertRule(o[a],a);this.emitter.emit(A.FullsnapshotRebuilded,e),"page"!==this.config.mode&&this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()},e.prototype.waitForStylesheetLoad=function(){var e,t=this,n=null===(e=this.iframe.contentDocument)||void 0===e?void 0:e.head;if(n){var r,i=new Set,o=this.service.state,a=n.querySelectorAll('link[rel="stylesheet"]');(a=Array.prototype.filter.call(a,(function(e){return!!t.unloadStylesheetMap[e.href]}))).forEach((function(e){e.sheet||(i.add(e),t.unloadStylesheetMap[e.href]=1,e.addEventListener("load",(function(){i.delete(e),0===i.size&&-1!==r&&(o.matches("playing")&&t.resume(t.getCurrentTime()),t.emitter.emit(A.LoadStylesheetEnd),r&&window.clearTimeout(r))})))})),i.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(A.LoadStylesheetStart),r=window.setTimeout((function(){o.matches("playing")&&t.resume(t.getCurrentTime()),r=-1}),this.config.loadTimeout))}},e.prototype.preloadAllImages=function(){return r(this,void 0,Promise,(function(){var e,t,n,r,a,s,l,c,u,f=this;return i(this,(function(i){this.service.state,e=function(){f.service.state},this.emitter.on(A.Start,e),this.emitter.on(A.Pause,e),t=[],n=function(e){e.type===E.IncrementalSnapshot&&e.data.source===S.CanvasMutation&&(t.push(r.deserializeAndPreloadCanvasEvents(e.data,e)),("commands"in e.data?e.data.commands:[e.data]).forEach((function(t){f.preloadImages(t,e)})))},r=this;try{for(a=o(this.service.state.context.events),s=a.next();!s.done;s=a.next())l=s.value,n(l)}catch(e){c={error:e}}finally{try{s&&!s.done&&(u=a.return)&&u.call(a)}finally{if(c)throw c.error}}return[2,Promise.all(t)]}))}))},e.prototype.preloadImages=function(e,t){if("drawImage"===e.property&&"string"==typeof e.args[0]&&!this.imageMap.has(t)){var n=document.createElement("canvas"),r=n.getContext("2d"),i=null==r?void 0:r.createImageData(n.width,n.height);null==i||i.data,JSON.parse(e.args[0]),null==r||r.putImageData(i,0,0)}},e.prototype.deserializeAndPreloadCanvasEvents=function(e,t){return r(this,void 0,void 0,(function(){var o,a,s,l=this;return i(this,(function(c){switch(c.label){case 0:return this.canvasEventMap.has(t)?[3,4]:(o={isUnchanged:!0},"commands"in e?[4,Promise.all(e.commands.map((function(e){return r(l,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.args.map(te(this.imageMap,null,o)))];case 1:return t=r.sent(),[2,n(n({},e),{args:t})]}}))}))})))]:[3,2]);case 1:return a=c.sent(),!1===o.isUnchanged&&this.canvasEventMap.set(t,n(n({},e),{commands:a})),[3,4];case 2:return[4,Promise.all(e.args.map(te(this.imageMap,null,o)))];case 3:s=c.sent(),!1===o.isUnchanged&&this.canvasEventMap.set(t,n(n({},e),{args:s})),c.label=4;case 4:return[2]}}))}))},e.prototype.applyIncremental=function(e,t){var n=this,o=this.service.state.context.baselineTime,a=e.data;switch(a.source){case S.Mutation:t&&(a.adds.forEach((function(e){return n.treeIndex.add(e)})),a.texts.forEach((function(e){return n.treeIndex.text(e)})),a.attributes.forEach((function(e){return n.treeIndex.attribute(e)})),a.removes.forEach((function(e){return n.treeIndex.remove(e)}))),this.applyMutation(a,t);break;case S.Drag:case S.TouchMove:case S.MouseMove:if(t){var s=a.positions[a.positions.length-1];this.moveAndHover(a,s.x,s.y,s.id,t)}else a.positions.forEach((function(r){var i={doAction:function(){n.moveAndHover(a,r.x,r.y,r.id,t)},delay:r.timeOffset+e.timestamp-o};n.timer.addAction(i)}));break;case S.MouseInteraction:if(-1===a.id)break;var l=new Event(C[a.type].toLowerCase());if(!(f=z.getNode(a.id)))return this.debugNodeNotFound(a,a.id);this.emitter.emit(A.MouseInteraction,{type:a.type,target:f});var c=this.config.triggerFocus;switch(a.type){case C.Blur:"blur"in f&&f.blur();break;case C.Focus:c&&f.focus&&f.focus({preventScroll:!0});break;case C.Click:case C.TouchStart:case C.TouchEnd:t||(this.moveAndHover(a,a.x,a.y,a.id,t),this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active"));break;default:f.dispatchEvent(l)}break;case S.Scroll:if(-1===a.id)break;if(t){this.treeIndex.scroll(a);break}this.applyScroll(a);break;case S.ViewportResize:a.rotate&&this.emitter.emit(A.Resize,{width:a.width,height:a.height});break;case S.Input:if(-1===a.id)break;if(t){this.treeIndex.input(a);break}this.applyInput(a);break;case S.StyleSheetRule:if(!(f=z.getNode(a.id)))return this.debugNodeNotFound(a,a.id);var u=f.sheet;a.adds&&a.adds.forEach((function(e){var t=e.rule,n=e.index,r=void 0===n?void 0:Math.min(n,u.rules.length);try{u.insertRule(t,r)}catch(e){}})),a.removes&&a.removes.forEach((function(e){var t=e.index;u.deleteRule(t)}));break;case S.CanvasMutation:if(!this.config.UNSAFE_replayCanvas)return;var f;if(!(f=z.getNode(a.id)))return this.debugNodeNotFound(a,a.id);!function(e){var t=e.event,n=e.mutation,o=e.target,a=e.imageMap,s=e.canvasEventMap,l=e.errorHandler;r(this,void 0,Promise,(function(){var e,r,c,u,f;return i(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,10,,11]),e=s.get(t)||n,r="commands"in e?e.commands:[e],![I.WebGL,I.WebGL2].includes(n.type))return[3,5];c=0,i.label=1;case 1:return c<r.length?[4,re({mutation:u=r[c],type:n.type,target:o,imageMap:a,errorHandler:l})]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return[2];case 5:c=0,i.label=6;case 6:return c<r.length?(u=r[c],[4,ie({event:t,mutation:u,target:o,imageMap:a,errorHandler:l})]):[3,9];case 7:i.sent(),i.label=8;case 8:return c++,[3,6];case 9:return[3,11];case 10:return f=i.sent(),l(n,f),[3,11];case 11:return[2]}}))}))}({event:e,mutation:a,target:f,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)});break;case S.UserDefinedEvent:if(a.evt===M.LivePlay){var d=this.iframe.contentDocument;if(!d||!a.selector||!a.url)return;var p=d.querySelector(a.selector);p&&p.tagName&&"video"===p.tagName.toLowerCase()&&(p.setAttribute("src",a.url),p.play())}}},e.prototype.applyMutation=function(e,t){var r=this;e.removes.forEach((function(t){var n=z.getNode(t.id);if(!n)return r.warnNodeNotFound(e,t.id);var i=z.getNode(t.parentId);if(!i)return r.warnNodeNotFound(e,t.parentId);if(z.removeNodeFromMap(n),i){var o=r.fragmentParentMap.get(i);o&&o.contains(n)?o.removeChild(n):i.removeChild(n)}}));var i=n({},this.legacy_missingNodeRetryMap),o=[],a=function(e){if(!r.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");var n=z.getNode(e.parentId);if(!n)return o.push(e);var a=r.iframe.contentDocument.contains(n);if(t&&a){var s=document.createDocumentFragment();for(z.map[e.parentId]=s,r.fragmentParentMap.set(s,n);n.firstChild;)s.appendChild(n.firstChild);n=s}var l=null,c=null;if(e.previousId&&(l=z.getNode(e.previousId)),e.nextId&&(c=z.getNode(e.nextId)),null!==e.nextId&&-1!==e.nextId&&!c)return o.push(e);if(!z.has(e.node.id)){var u=g(e.node,r.iframe.contentDocument,z.map,!0,!0,r.config.cdnHttps);-1!==e.previousId&&-1!==e.nextId?(l&&l.nextSibling&&l.nextSibling.parentNode?n.insertBefore(u,l.nextSibling):c&&c.parentNode?n.contains(c)?n.insertBefore(u,c):n.insertBefore(u,null):n.appendChild(u),(e.previousId||e.nextId)&&r.legacy_resolveMissingNode(i,n,u,e)):i[e.node.id]={node:u,mutation:e}}};for(e.adds.forEach((function(e){a(e)}));o.length;){if(o.every((function(e){return!Boolean(z.getNode(e.parentId))})))return o.forEach((function(t){return r.warnNodeNotFound(e,t.node.id)}));var s=o.shift();a(s)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),e.texts.forEach((function(t){var n=z.getNode(t.id);if(!n)return r.warnNodeNotFound(e,t.id);r.fragmentParentMap.has(n)&&(n=r.fragmentParentMap.get(n)),n.textContent=t.value})),e.attributes.forEach((function(t){var n=z.getNode(t.id);if(!n)return r.warnNode