var TimeCat=function(t){"use strict";function e(t,e,n,i){var s,r=arguments.length,o=r=0;a--)(s=t[a])&&(o=(r3?s(e,n,o):s(e,n))||o);return r>3&&o&&Object.defineProperty(e,n,o),o}function n(t,e,n,i){return new(n||(n=Promise))((function(s,r){function o(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}l((i=i.apply(t,e||[])).next())}))}var i,s,r,o;function a(){}function l(t,e,n,i,s){for(var r=0,o=e.length,a=0,l=0;rt.length?n:t})),c.value=t.join(h)}else c.value=t.join(n.slice(a,a+c.count));a+=c.count,c.added||(l+=c.count)}}var u=e[o-1];return o>1&&"string"==typeof u.value&&(u.added||u.removed)&&t.equals("",u.value)&&(e[o-2].value+=u.value,e.pop()),e}function c(t){return{newPos:t.newPos,components:t.components.slice(0)}}t.RecordType=void 0,(i=t.RecordType||(t.RecordType={}))[i.HEAD=0]="HEAD",i[i.SNAPSHOT=1]="SNAPSHOT",i[i.WINDOW=2]="WINDOW",i[i.SCROLL=3]="SCROLL",i[i.MOUSE=4]="MOUSE",i[i.DOM=5]="DOM",i[i.FORM_EL=6]="FORM_EL",i[i.LOCATION=7]="LOCATION",i[i.AUDIO=8]="AUDIO",i[i.CANVAS=9]="CANVAS",i[i.TERMINATE=10]="TERMINATE",i[i.FONT=11]="FONT",i[i.PATCH=12]="PATCH",i[i.CUSTOM=13]="CUSTOM",i[i.WEBGL=14]="WEBGL",i[i.CANVAS_SNAPSHOT=15]="CANVAS_SNAPSHOT",i[i.VIDEO=16]="VIDEO",function(t){t[t.PROP=0]="PROP",t[t.INPUT=1]="INPUT",t[t.CHANGE=2]="CHANGE",t[t.FOCUS=3]="FOCUS",t[t.BLUR=4]="BLUR"}(s||(s={})),function(t){t[t.MOVE=0]="MOVE",t[t.CLICK=1]="CLICK"}(r||(r={})),function(t){t.READONLY="readonly",t.READWRITE="readwrite",t.VERSIONCHANGE="versionchange"}(o||(o={})),a.prototype={diff:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=n.callback;"function"==typeof n&&(i=n,n={}),this.options=n;var s=this;function r(t){return i?(setTimeout((function(){i(void 0,t)}),0),!0):t}t=this.castInput(t),e=this.castInput(e),t=this.removeEmpty(this.tokenize(t));var o=(e=this.removeEmpty(this.tokenize(e))).length,a=t.length,d=1,h=o+a,u=[{newPos:-1,components:[]}],p=this.extractCommon(u[0],e,t,0);if(u[0].newPos+1>=o&&p+1>=a)return r([{value:this.join(e),count:e.length}]);function f(){for(var n=-1*d;n=o&&f+1>=a)return r(l(s,i.components,e,t,s.useLongestToken));u[n]=i}else u[n]=void 0}d++}if(i)!function t(){setTimeout((function(){if(d>h)return i();f()||t()}),0)}();else for(;d{setTimeout((()=>e()),t)}))}))}function S(t){return!!t.tag}function I(t,e){return function(t){let e=0;return t.map((t=>{const{added:n,removed:i,value:s,count:r}=t,o=r||0;if(n){const t={index:e,type:"add",value:s};return e+=o,t}if(i){return{index:e,type:"rm",len:o}}e+=o})).filter(Boolean)}(function(t,e,n){return d.diff(t,e,n)}(t,e))}function O(t,e,n={}){let i,s,r,o=null,a=0;const l=function(){a=!1===n.leading?0:Date.now(),o=null,r=t.apply(i,s),o||(i=s=null)};return function(){const c=Date.now();a||!1!==n.leading||(a=c);const d=e-(c-a);return i=this,s=arguments,de?(o&&(clearTimeout(o),o=null),a=c,r=t.apply(i,s),o||(i=s=null)):o||!1===n.trailing||(o=setTimeout(l,d)),r}}function N(t,e,n={isImmediate:!1,isTrailing:!1}){let i;return function(...s){const r=this,o=n.isImmediate&&void 0===i;void 0!==i&&clearTimeout(i),i=setTimeout((function(){i=void 0,n.isImmediate&&!n.isTrailing||t.apply(r,s)}),e),o&&t.apply(r,s)}}function k(t,e){try{return new URL(t,e)}catch(t){E(t)}return{href:t,pathname:t}}function C(t){const{title:e,content:n,titleColor:i,backgroundColor:s}=t,r=i||"#606060",o=s||"#1475b2",a=["%c ".concat(e," %c ").concat(n," "),"padding: 1px; border-radius: 3px 0 0 3px; color: #fff; background: ".concat(r,";"),"padding: 1px; border-radius: 0 3px 3px 0; color: #fff; background: ".concat(o,";")];console.log.apply(void 0,a)}function L(){console.log("%c\n______ _ _____ _ \n|_ _(_) / __ \\ | | \n | | _ _ __ ___ ___| / \\/ __ _| |_ \n | | | | '_ ` _ \\ / _ \\ | / _` | __|\n | | | | | | | | | __/ \\__/\\ (_| | |_ \n \\_/ |_|_| |_| |_|\\___|\\____/\\__,_|\\__|\n ","color: #1475b2;"),C({title:"version",content:v}),C({title:"more info",content:"github.com/oct16/timecat"})}const D=()=>{},P=()=>Promise.resolve(),M=["direction","fillStyle","filter","font","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","imageSmoothingQuality","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","shadowBlur","shadowColor","shadowOffsetX","shadowOffsetY","strokeStyle","textAlign","textBaseline"],U=[...M,"arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createImageData","createLinearGradient","createPattern","createRadialGradient","drawFocusIfNeeded","drawImage","ellipse","fill","fillRect","fillText","getImageData","getLineDash","getTransform","isPointInPath","isPointInStroke","lineTo","measureText","moveTo","putImageData","quadraticCurveTo","rect","resetTransform","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeRect","strokeText","transform","translate"],F=["drawingBufferWidth","drawingBufferHeight","ACTIVE_ATTRIBUTES","ACTIVE_TEXTURE","ACTIVE_UNIFORMS","ALIASED_LINE_WIDTH_RANGE","ALIASED_POINT_SIZE_RANGE","ALPHA","ALPHA_BITS","ALWAYS","ARRAY_BUFFER","ARRAY_BUFFER_BINDING","ATTACHED_SHADERS","BACK","BLEND","BLEND_COLOR","BLEND_DST_ALPHA","BLEND_DST_RGB","BLEND_EQUATION","BLEND_EQUATION_ALPHA","BLEND_EQUATION_RGB","BLEND_SRC_ALPHA","BLEND_SRC_RGB","BLUE_BITS","BOOL","BOOL_VEC2","BOOL_VEC3","BOOL_VEC4","BROWSER_DEFAULT_WEBGL","BUFFER_SIZE","BUFFER_USAGE","BYTE","CCW","CLAMP_TO_EDGE","COLOR_ATTACHMENT0","COLOR_BUFFER_BIT","COLOR_CLEAR_VALUE","COLOR_WRITEMASK","COMPILE_STATUS","COMPRESSED_TEXTURE_FORMATS","CONSTANT_ALPHA","CONSTANT_COLOR","CONTEXT_LOST_WEBGL","CULL_FACE","CULL_FACE_MODE","CURRENT_PROGRAM","CURRENT_VERTEX_ATTRIB","CW","DECR","DECR_WRAP","DELETE_STATUS","DEPTH_ATTACHMENT","DEPTH_BITS","DEPTH_BUFFER_BIT","DEPTH_CLEAR_VALUE","DEPTH_COMPONENT","DEPTH_COMPONENT16","DEPTH_FUNC","DEPTH_RANGE","DEPTH_STENCIL","DEPTH_STENCIL_ATTACHMENT","DEPTH_TEST","DEPTH_WRITEMASK","DITHER","DONT_CARE","DST_ALPHA","DST_COLOR","DYNAMIC_DRAW","ELEMENT_ARRAY_BUFFER","ELEMENT_ARRAY_BUFFER_BINDING","EQUAL","FASTEST","FLOAT","FLOAT_MAT2","FLOAT_MAT3","FLOAT_MAT4","FLOAT_VEC2","FLOAT_VEC3","FLOAT_VEC4","FRAGMENT_SHADER","FRAMEBUFFER","FRAMEBUFFER_ATTACHMENT_OBJECT_NAME","FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE","FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE","FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL","FRAMEBUFFER_BINDING","FRAMEBUFFER_COMPLETE","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_UNSUPPORTED","FRONT","FRONT_AND_BACK","FRONT_FACE","FUNC_ADD","FUNC_REVERSE_SUBTRACT","FUNC_SUBTRACT","GENERATE_MIPMAP_HINT","GEQUAL","GREATER","GREEN_BITS","HIGH_FLOAT","HIGH_INT","IMPLEMENTATION_COLOR_READ_FORMAT","IMPLEMENTATION_COLOR_READ_TYPE","INCR","INCR_WRAP","INT","INT_VEC2","INT_VEC3","INT_VEC4","INVALID_ENUM","INVALID_FRAMEBUFFER_OPERATION","INVALID_OPERATION","INVALID_VALUE","INVERT","KEEP","LEQUAL","LESS","LINEAR","LINEAR_MIPMAP_LINEAR","LINEAR_MIPMAP_NEAREST","LINES","LINE_LOOP","LINE_STRIP","LINE_WIDTH","LINK_STATUS","LOW_FLOAT","LOW_INT","LUMINANCE","LUMINANCE_ALPHA","MAX_COMBINED_TEXTURE_IMAGE_UNITS","MAX_CUBE_MAP_TEXTURE_SIZE","MAX_FRAGMENT_UNIFORM_VECTORS","MAX_RENDERBUFFER_SIZE","MAX_TEXTURE_IMAGE_UNITS","MAX_TEXTURE_SIZE","MAX_VARYING_VECTORS","MAX_VERTEX_ATTRIBS","MAX_VERTEX_TEXTURE_IMAGE_UNITS","MAX_VERTEX_UNIFORM_VECTORS","MAX_VIEWPORT_DIMS","MEDIUM_FLOAT","MEDIUM_INT","MIRRORED_REPEAT","NEAREST","NEAREST_MIPMAP_LINEAR","NEAREST_MIPMAP_NEAREST","NEVER","NICEST","NONE","NOTEQUAL","NO_ERROR","ONE","ONE_MINUS_CONSTANT_ALPHA","ONE_MINUS_CONSTANT_COLOR","ONE_MINUS_DST_ALPHA","ONE_MINUS_DST_COLOR","ONE_MINUS_SRC_ALPHA","ONE_MINUS_SRC_COLOR","OUT_OF_MEMORY","PACK_ALIGNMENT","POINTS","POLYGON_OFFSET_FACTOR","POLYGON_OFFSET_FILL","POLYGON_OFFSET_UNITS","RED_BITS","RENDERBUFFER","RENDERBUFFER_ALPHA_SIZE","RENDERBUFFER_BINDING","RENDERBUFFER_BLUE_SIZE","RENDERBUFFER_DEPTH_SIZE","RENDERBUFFER_GREEN_SIZE","RENDERBUFFER_HEIGHT","RENDERBUFFER_INTERNAL_FORMAT","RENDERBUFFER_RED_SIZE","RENDERBUFFER_STENCIL_SIZE","RENDERBUFFER_WIDTH","RENDERER","REPEAT","REPLACE","RGB","RGB565","RGB5_A1","RGBA","RGBA4","SAMPLER_2D","SAMPLER_CUBE","SAMPLES","SAMPLE_ALPHA_TO_COVERAGE","SAMPLE_BUFFERS","SAMPLE_COVERAGE","SAMPLE_COVERAGE_INVERT","SAMPLE_COVERAGE_VALUE","SCISSOR_BOX","SCISSOR_TEST","SHADER_TYPE","SHADING_LANGUAGE_VERSION","SHORT","SRC_ALPHA","SRC_ALPHA_SATURATE","SRC_COLOR","STATIC_DRAW","STENCIL_ATTACHMENT","STENCIL_BACK_FAIL","STENCIL_BACK_FUNC","STENCIL_BACK_PASS_DEPTH_FAIL","STENCIL_BACK_PASS_DEPTH_PASS","STENCIL_BACK_REF","STENCIL_BACK_VALUE_MASK","STENCIL_BACK_WRITEMASK","STENCIL_BITS","STENCIL_BUFFER_BIT","STENCIL_CLEAR_VALUE","STENCIL_FAIL","STENCIL_FUNC","STENCIL_INDEX8","STENCIL_PASS_DEPTH_FAIL","STENCIL_PASS_DEPTH_PASS","STENCIL_REF","STENCIL_TEST","STENCIL_VALUE_MASK","STENCIL_WRITEMASK","STREAM_DRAW","SUBPIXEL_BITS","TEXTURE","TEXTURE0","TEXTURE1","TEXTURE10","TEXTURE11","TEXTURE12","TEXTURE13","TEXTURE14","TEXTURE15","TEXTURE16","TEXTURE17","TEXTURE18","TEXTURE19","TEXTURE2","TEXTURE20","TEXTURE21","TEXTURE22","TEXTURE23","TEXTURE24","TEXTURE25","TEXTURE26","TEXTURE27","TEXTURE28","TEXTURE29","TEXTURE3","TEXTURE30","TEXTURE31","TEXTURE4","TEXTURE5","TEXTURE6","TEXTURE7","TEXTURE8","TEXTURE9","TEXTURE_2D","TEXTURE_BINDING_2D","TEXTURE_BINDING_CUBE_MAP","TEXTURE_CUBE_MAP","TEXTURE_CUBE_MAP_NEGATIVE_X","TEXTURE_CUBE_MAP_NEGATIVE_Y","TEXTURE_CUBE_MAP_NEGATIVE_Z","TEXTURE_CUBE_MAP_POSITIVE_X","TEXTURE_CUBE_MAP_POSITIVE_Y","TEXTURE_CUBE_MAP_POSITIVE_Z","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","TRIANGLES","TRIANGLE_FAN","TRIANGLE_STRIP","UNPACK_ALIGNMENT","UNPACK_COLORSPACE_CONVERSION_WEBGL","UNPACK_FLIP_Y_WEBGL","UNPACK_PREMULTIPLY_ALPHA_WEBGL","UNSIGNED_BYTE","UNSIGNED_INT","UNSIGNED_SHORT","UNSIGNED_SHORT_4_4_4_4","UNSIGNED_SHORT_5_5_5_1","UNSIGNED_SHORT_5_6_5","VALIDATE_STATUS","VENDOR","VERSION","VERTEX_ATTRIB_ARRAY_BUFFER_BINDING","VERTEX_ATTRIB_ARRAY_ENABLED","VERTEX_ATTRIB_ARRAY_NORMALIZED","VERTEX_ATTRIB_ARRAY_POINTER","VERTEX_ATTRIB_ARRAY_SIZE","VERTEX_ATTRIB_ARRAY_STRIDE","VERTEX_ATTRIB_ARRAY_TYPE","VERTEX_SHADER","VIEWPORT","ZERO","activeTexture","attachShader","bindAttribLocation","bindBuffer","bindFramebuffer","bindRenderbuffer","bindTexture","blendColor","blendEquation","blendEquationSeparate","blendFunc","blendFuncSeparate","bufferData","bufferSubData","checkFramebufferStatus","clear","clearColor","clearDepth","clearStencil","colorMask","compileShader","compressedTexImage2D","compressedTexSubImage2D","copyTexImage2D","copyTexSubImage2D","createBuffer","createFramebuffer","createProgram","createRenderbuffer","createShader","createTexture","cullFace","deleteBuffer","deleteFramebuffer","deleteProgram","deleteRenderbuffer","deleteShader","deleteTexture","depthFunc","depthMask","depthRange","detachShader","disable","disableVertexAttribArray","drawArrays","drawElements","enable","enableVertexAttribArray","finish","flush","framebufferRenderbuffer","framebufferTexture2D","frontFace","generateMipmap","getActiveAttrib","getActiveUniform","getAttachedShaders","getAttribLocation","getBufferParameter","getContextAttributes","getError","getExtension","getFramebufferAttachmentParameter","getParameter","getProgramInfoLog","getProgramParameter","getRenderbufferParameter","getShaderInfoLog","getShaderParameter","getShaderPrecisionFormat","getShaderSource","getSupportedExtensions","getTexParameter","getUniform","getUniformLocation","getVertexAttrib","getVertexAttribOffset","hint","isBuffer","isContextLost","isEnabled","isFramebuffer","isProgram","isRenderbuffer","isShader","isTexture","lineWidth","linkProgram","makeXRCompatible","pixelStorei","polygonOffset","readPixels","renderbufferStorage","sampleCoverage","scissor","shaderSource","stencilFunc","stencilFuncSeparate","stencilMask","stencilMaskSeparate","stencilOp","stencilOpSeparate","texImage2D","texParameterf","texParameteri","texSubImage2D","uniform1f","uniform1fv","uniform1i","uniform1iv","uniform2f","uniform2fv","uniform2i","uniform2iv","uniform3f","uniform3fv","uniform3i","uniform3iv","uniform4f","uniform4fv","uniform4i","uniform4iv","uniformMatrix2fv","uniformMatrix3fv","uniformMatrix4fv","useProgram","validateProgram","vertexAttrib1f","vertexAttrib1fv","vertexAttrib2f","vertexAttrib2fv","vertexAttrib3f","vertexAttrib3fv","vertexAttrib4f","vertexAttrib4fv","vertexAttribPointer","viewport"],B=()=>{var t;return(null===(t=window.G_REPLAY_DATA&&window.G_REPLAY_DATA.snapshot.data)||void 0===t?void 0:t.href)||location.href};function j(t){return t.nodeType===Node.ELEMENT_NODE}function H(t,e,n){return t.replace(/(url\(['"]?((\/{1,2}|\.\.?\/)?.*?)(^\?.*?)?['"]?(?=\)))/g,((t,i,s)=>{const r=k(s,e||B());return s.startsWith("data:")?t:t.replace(s,n?n(r.href):r.href)}))}function z(t,e){return t.startsWith("data")?t:(e&&setTimeout((()=>{const n=e.getRootNode().defaultView,{href:i,path:s}=(null==n?void 0:n.G_REPLAY_LOCATION)||{};if(s&&i){const n=k(s,i).href;e.getAttributeNames().filter((t=>~["src","href"].indexOf(t))).forEach((i=>{const s=k(t,n).href;e.getAttribute(i)!==s&&e.setAttribute(i,s)}))}})),k(t,B()).href)}function V(t){return t.ownerDocument&&!!t.ownerDocument.contains(t)}function G(t){return n(this,void 0,void 0,(function*(){if(!t)return!1;if(t.length>500)return!1;const e=z(t);if(function(t){try{new URL(t)}catch(t){return!1}return!0}(e))try{return yield W(e)}catch(t){return!1}return!1}))}function W(t){return n(this,void 0,void 0,(function*(){return yield fetch(t).then((t=>n(this,void 0,void 0,(function*(){return(yield t.text()).replace(//g,"")}))),(e=>(E(e),t)))}))}function X(t,e){return function(t,{channelCount:e,sampleBits:n,sampleRate:i}){const s=new ArrayBuffer(44+t.byteLength),r=!0,o=new DataView(s);Z(o,0,"RIFF"),o.setUint32(4,36+2*t.byteLength,r),Z(o,8,"WAVE"),Z(o,12,"fmt "),o.setUint32(16,16,r),o.setUint16(20,1,r),o.setUint16(22,e,r),o.setUint32(24,i,r),o.setUint32(28,i*e*(n/8),r),o.setUint16(32,e*(n/8),r),o.setUint16(34,n,r),Z(o,36,"data"),o.setUint32(40,t.byteLength,r);const a=t.byteLength;let l=44;for(let e=0;e{this.requestID=requestAnimationFrame(n);const s=i-t;s>=e-.1&&(t=i-s%e,this.animate(s,this.index++))};this.requestID=requestAnimationFrame(n)}stop(){cancelAnimationFrame(this.requestID)}}const Q=[["type","type",{unique:!1}],["data","data",{unique:!1}],["relatedId","relatedId",{unique:!1}],["time","time",{unique:!1}]];var tt;!function(t){t[t.ADD=0]="ADD",t[t.DELETE=1]="DELETE",t[t.CLEAR=2]="CLEAR"}(tt||(tt={}));const et=new class extends class{constructor(t,e,n){this.DBName=t,this.version=e,this.storeName=n,this.init()}init(){return n(this,void 0,void 0,(function*(){this.dbResolve=this.initDB(),this.db=yield this.dbResolve}))}initDB(){const t=window.indexedDB.open(this.DBName,this.version);return t.onupgradeneeded=t=>{const e=t.target.result;if(!e.objectStoreNames.contains(this.storeName)){const t=e.createObjectStore(this.storeName,{autoIncrement:!0,keyPath:"id"});Q.forEach((e=>t.createIndex(...e)))}},new Promise(((e,n)=>{t.onsuccess=()=>{e(t.result)},t.onerror=()=>{const t="open indexedDB on error";E(t)&&n(t)}}))}getIDBObjectStore(t){const e=this.db.transaction(this.storeName,t);return e.onabort=e.onerror=()=>{E(e.error)},e.objectStore(this.storeName)}}{constructor(t,e,n){super(t,e,n),this.tasks=[],this.triggerTask=(()=>{let t=0;return()=>{if(this.db){let t=Promise.resolve();for(;this.tasks.length;){const e=this.tasks.shift();t=t.then((()=>this.execTask(e)))}}else clearInterval(t),t=window.setTimeout((()=>this.triggerTask()),0)}})()}add(t){this.addTask(tt.ADD,t)}delete(t){this.addTask(tt.DELETE,t)}clear(){this.addTask(tt.CLEAR)}count(){return n(this,void 0,void 0,(function*(){const t=this.getIDBObjectStore(o.READONLY);return new Promise((e=>{t.count().onsuccess=t=>{e(t.target.result)}}))}))}last(){return n(this,void 0,void 0,(function*(){const t=this.getIDBObjectStore(o.READONLY);return new Promise(((e,n)=>{const i=t.openKeyCursor(null,"prev");i.onsuccess=()=>{const s=i.result;if(!s)return n("DB is empty");const r=t.get(s.key);r.onsuccess=()=>{e(r.result)}}}))}))}readAll(t){return n(this,void 0,void 0,(function*(){const{limit:e}=t||{};yield this.dbResolve;const n=this.getIDBObjectStore(o.READONLY),i=[];return new Promise((t=>{n.openCursor().onsuccess=n=>{const s=n.target.result;return e&&i.length>=e?t(i):s?(i.push(s.value),void s.continue()):void t(i)}})).then((t=>t.length?t:null))}))}execTask(t){switch(t.type){case tt.ADD:return this.execAddTask(t.data);case tt.DELETE:return this.execDeleteTask(t.data);case tt.CLEAR:return this.execClearTask();default:return Promise.resolve()}}addTask(t,e){this.tasks.push({type:t,data:e}),this.triggerTask()}execAddTask(t){return n(this,void 0,void 0,(function*(){this.getIDBObjectStore(o.READWRITE).add(t)}))}execDeleteTask(t){return n(this,void 0,void 0,(function*(){const{lowerBound:e,upperBound:n}=t||{};if(e&&n){const t=IDBKeyRange.bound(e,n);this.getIDBObjectStore(o.READWRITE).delete(t)}else E("Options lowerBound and upperBound is required")}))}execClearTask(){return n(this,void 0,void 0,(function*(){this.getIDBObjectStore(o.READWRITE).clear()}))}}("cat_db",1,"cat_data");class nt{constructor(){this.createNodeId=()=>nt.nodeId++,this.init()}init(){this.nodeMap=new Map,this.idMap=new WeakMap}reset(){this.nodeMap.clear()}getNode(t){return this.nodeMap.get(t)||null}addNode(t,e=this.createNodeId()){return this.idMap.set(t,e),this.nodeMap.set(e,t),e}removeNode(t){this.nodeMap.delete(t),this.idMap.delete(this.getNode(t))}getNodeId(t){return this.idMap.get(t)}updateNode(t,e){this.idMap.set(e,t),this.nodeMap.set(t,e)}}nt.nodeId=1;const it=new nt,st=(t,e={})=>j(t)?{id:e.id||it.createNodeId(),type:t.nodeType,attrs:rt(t),tag:t.tagName.toLocaleLowerCase(),children:[],extra:ot(t,e.isSVG)}:{id:e.id||it.createNodeId(),type:t.nodeType,value:t.textContent},rt=t=>{const e={},{attributes:n}=t;return n&&n.length?Object.values(n).reduce(((t,e)=>{const[n,i]=at(e);return n&&(t[n]=i),t}),e):e};function ot(t,e){var n,i;const{tagName:s}=t,r={},o={};if(e||"svg"===s.toLowerCase())r.isSVG=!0;else if("INPUT"===s){const{checked:e,value:n}=t;void 0!==n&&(o.value=n),void 0!==e&&(o.checked=e)}else if("OPTION"===s){const{selected:e}=t;!0===e&&(o.selected=!0)}else if("STYLE"===s){const e=null===(i=null===(n=t)||void 0===n?void 0:n.sheet)||void 0===i?void 0:i.rules;if(e&&e.length){const t=Array.from(e).map((t=>t.cssText)).join(" ");o.textContent=H(t)}}else"VIDEO"===s&&(o.autoplay=!1,o.controls=!1,o.loop=!1,o.muted=!0);const a=t.scrollLeft,l=t.scrollTop;return(l||a)&&(o.scroll={left:a,top:l}),Object.keys(o).length&&(r.props=o),r}const at=t=>{const{name:e,value:n}=t;return("href"===e||"src"===e)&&n.startsWith("#/")?[]:[e,n]},lt=(t,e)=>{var n,i,s;const r=st(t,{isSVG:e}),{id:o}=r;if(it.addNode(t,o),null===(s=null===(i=null===(n=r)||void 0===n?void 0:n.extra)||void 0===i?void 0:i.props)||void 0===s?void 0:s.textContent)return r;if(r.type===Node.ELEMENT_NODE){const n=r;e=e||n.extra.isSVG,t.childNodes.forEach((t=>{const i=lt(t,e);i&&n.children.push(i)}))}return r},ct=["VIDEO","IFRAME"];function dt(t,e,n){if(t.nodeType===Node.ELEMENT_NODE)if("style"!==e){if(!("src"===e&&~ct.indexOf(t.tagName)||n&&"string"==typeof n&&/\.js$/.test(n)||/^\d+/.test(e)||/^on\w+$/.test(e))){if(null===n)return t.removeAttribute(e);if(n=String(n),"href"===e&&(n=z(String(n),t)),"background"!==e&&"src"!==e||n.startsWith("data:")||(n=z(String(n),t)),"srcset"===e){const e=n.split(",");n=e.map((e=>{const[n,i]=e.trim().split(" ");return n&&i?`${z(n,t)} ${i}`:n?z(n,t):""})).join(", "),n=decodeURIComponent(n)}n.startsWith("/")&&(n=z(n,t));try{t.setAttribute(e,n)}catch(t){E(t)}}}else if("string"==typeof n)t.style.cssText=H(n);else if(null!==n&&"object"==typeof n)for(const[e,i]of Object.entries(n))"-"===e[0]?t.style.setProperty(e,i):t.style[e]=i}function ht(t,e){if(null==t)return null;const n=t;if(t.type===Node.COMMENT_NODE)return function(t){const{value:e,id:n}=t,i=document.createComment(e);return it.updateNode(n,i),i}(n);if(t.type===Node.TEXT_NODE){if(e&&"style"===e.tag){n.value=H(n.value,null==e?void 0:e.attrs["css-url"])}return function(t){const{value:e,id:n}=t,i=document.createTextNode(e);return it.updateNode(n,i),i}(n)}const i=t,s=function(t){const{id:e,extra:n}=t,{isSVG:i}=n;let s;const r=(o=t.tag,{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",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",lineargradient:"linearGradient",radialgradient:"radialGradient",textpath:"textPath"}[o]||o);var o;s=i?document.createElementNS("http://www.w3.org/2000/svg",r):document.createElement(r);return function(t,e){const n=function(t){return Object.assign({},t.attrs)}(t);for(const[t,i]of Object.entries(n))dt(e,t,i);"a"===t.tag&&e.setAttribute("target","_blank")}(t,s),function(t,e){const{props:n}=t.extra;if(n)for(const[t,i]of Object.entries(n))if("scroll"===t){const{left:t,top:n}=i;setTimeout((()=>{e.scrollTop=n,e.scrollLeft=t}),1e3)}else e[t]=i}(t,s),it.updateNode(e,s),s}(i);return(i.children&&i.children.length||s.childNodes&&s.childNodes.length)&&function(t,e){const n=[];t.children.slice().forEach((i=>{let s=n.pop();s=ht(i,t),s&&(function(t){return!!t&&t.nodeType===Node.COMMENT_NODE&&"hidden"===t.textContent}(e.lastChild)&&dt(s,"style","visibility: hidden"),e.appendChild(s))}))}(i,s),s}class ut{constructor(t){this.getNode=t=>it.getNode.call(it,t),this.getNodeId=t=>it.getNodeId.call(it,t);const{emit:e,context:n,relatedId:i,recorder:s}=t;this.options=t,this.recorder=s,this.relatedId=i,this.context=n,this.recordOptions=n.G_RECORD_OPTIONS||window.G_RECORD_OPTIONS||{},this.emit=e,this.init(t)}init(t){}uninstall(t){this.options.listenStore.add(t)}emitData(t,e,n=w(),i){const s={type:t,data:e,relatedId:this.relatedId,time:n};if(i)return this.emit(i(s));this.emit(s)}registerEvent(t){const{context:e,eventTypes:n,handleFn:i,listenerOptions:s,type:r,optimizeOptions:o,waitTime:a}=t;let l;l="throttle"===r?O(i,a,o):N(i,a,o),n.map((t=>n=>{e.addEventListener(t,n,s)})).forEach((t=>t(l))),this.uninstall((()=>{n.forEach((t=>{e.removeEventListener(t,l,s)}))}))}}const pt="https://timecatjs.com/all-origins?url=";function ft(t,e,i){if(!e)return;const{rewriteConfigs:s,preFetchConfigs:r}=e.reduce(((t,e)=>("preFetch"===e.type?t.preFetchConfigs.push(e):t.rewriteConfigs.push(e),t)),{rewriteConfigs:[],preFetchConfigs:[]});if(s.some((t=>{const{matches:e,rewrite:n}=t,{replaceOrigin:i}=n;return!i||!e})))return E("The params replaceOrigin and matches is required for using rewriteResource");function o(t,e){return n=>{const{href:i,src:s}=t.attrs;Object.entries({href:i,src:s}).filter((([,t])=>{if(t)return e.some((e=>"string"==typeof e?t.endsWith("."+e):e.test(t)))})).forEach((e=>n(t,...e)))}}s.forEach((e=>{const{rewrite:n,matches:i}=e,{replaceOrigin:s,folderPath:r,fn:a}=n,[l]=document.getElementsByTagName("base"),c=window.location.href,d=(t,e,n)=>{const i=t.attrs,o=k(n,(null==l?void 0:l.href)||c),d=o.href,h=mt(s,r||"",o.pathname),u=a&&a(d,h)||h;i[e]=u};t.forEach((t=>o(t,i)(d)))})),r.forEach((e=>{const{rewrite:s,matches:r}=e;if(!r.filter((t=>"string"==typeof t)).every((t=>t.endsWith("css"))))return E("PreFetch Resource only support [css] currently");const{replaceOrigin:a,folderPath:l,crossUrl:c,fn:d,matches:h}=s,[u]=document.getElementsByTagName("base"),p=window.location.href,f=(t,e,s)=>n(this,void 0,void 0,(function*(){const n=k(s,(null==u?void 0:u.href)||p),r=yield fetch(n.href).then((t=>t.text()),(()=>"")).catch((t=>function(t){const e=t.message||t;return console.warn(`TimeCat Warning: ${e}`),e}(t)));if(!r)return;const o=H(r,n.href,(t=>{if(!h)return t;let e;const n=k(t,(null==u?void 0:u.href)||p);return h.some((e=>"string"==typeof e?n.pathname.endsWith("."+e):e.test(t)))?(e=a&&l?mt(a,l||"",n.pathname):function(t,e){const n=encodeURIComponent(t);let i;i=e&&"string"==typeof e?~e.indexOf("")?e.replace("",n):e+n:pt+n;return i}(t,c),d&&d(t,e)||e):t})),f={id:t.id,tag:t.tag,key:e,time:w(),url:n.href,text:o};i(f)}));t.forEach((t=>o(t,r)(f)))}))}function mt(...t){if(!t.length)return"";if(1===t.length)return t[0];function e(t){return t.endsWith("/")?t.substring(0,t.length-1):t}return t.reduce(((t,n)=>{if(!t){if(!n.startsWith("http"))throw new Error("path error");return e(n)}return t+(n?"/"+function(t){return t.startsWith("/")?t.substring(1):t}(e(n)):"")}),"")}var gt,_t;!function(t){t.add="add",t.rm="rm"}(gt||(gt={})),function(t){t.replaceState="replaceState",t.pushState="pushState",t.popstate="popstate",t.hashchange="hashchange"}(_t||(_t={}));class yt extends ut{constructor(){super(...arguments),this.locationHandle=e=>{var n,i;const s=this.getContextNodeId(e),[,,r]=e.arguments||[,,null===(i=null===(n=this.context)||void 0===n?void 0:n.location)||void 0===i?void 0:i.pathname],[o]=this.context.document.body.getElementsByTagName("base"),{href:a,hash:l}=this.context.location,c=document.title;this.emitData(t.RecordType.LOCATION,{contextNodeId:s,href:(null==o?void 0:o.href)||a,hash:l,path:r,title:c})},this.emitOne=()=>this.locationHandle({target:window})}init(){this.context.history.pushState=this.kidnapLocation(_t.pushState),this.context.history.replaceState=this.kidnapLocation(_t.replaceState);const t=Object.values(_t);t.forEach((t=>this.toggleListener(gt.add,t,this.locationHandle))),this.uninstall((()=>{t.forEach((t=>this.toggleListener(gt.rm,t,this.locationHandle)))}))}toggleListener(t,e,n){this.context[t===gt.add?"addEventListener":"removeEventListener"](e,n)}kidnapLocation(t){const e=this.context,n=e.history[t];return function(){const i=n.apply(this,arguments),s=new Event(t);return s.arguments=arguments,e.dispatchEvent(s),i}}getContextNodeId(t){return this.getNodeId(t.target.document.documentElement)}}function bt(t){const e=Object.create(null),n=Object.create(null);return function(i,s,r){if(e[i]||(e[i]=[]),t.blockInstances.some((t=>r instanceof t))||e[i].push({name:s,args:r}),!n[i]){const s=window.setTimeout((()=>{!function(i){clearTimeout(n[i]),n[i]=0;const s=e[i].slice();e[i].length=0,t.fn.call(this,i,s)}(i)}),t.wait);n[i]=s}}}function vt(t,e){const n=t;if(!n.typeWatchers){n.typeWatchers=[];const t=n.getContext;n.getContext=function(e,i){return n.getContext=t,n.typeWatchers.forEach((t=>t.call(this,e,i))),n.typeWatchers.length=0,delete n.typeWatchers,t.apply(this,arguments)}}n.typeWatchers.push(e)}function Et(t){const e=document.createElement("canvas");return e.width=t.width,e.height=t.height,t.toDataURL()===e.toDataURL()}const wt=[];function Tt(t){wt.push(t);const e=document.createElement;e.toString().indexOf("[native code]")>-1&&(this.uninstall((()=>{document.createElement=e})),document.createElement=function(t,n){const i=e.call(this,t,n);return!1!==n&&wt.forEach((t=>t(i))),i})}function xt(t){Tt.call(this,(e=>{"CANVAS"===e.tagName&&t(e)}))}function At(){wt.length=0}const Rt=new WeakMap;const St=[WebGLActiveInfo,WebGLBuffer,WebGLFramebuffer,WebGLProgram,WebGLRenderbuffer,WebGLShader,WebGLShaderPrecisionFormat,WebGLTexture,WebGLUniformLocation],It=new WeakMap;const Ot={DOMWatcher:class extends ut{init(){const t=new MutationObserver((t=>this.mutationCallback(t)));t.observe(this.context.document.documentElement,{attributeOldValue:!0,attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),this.uninstall((()=>t.disconnect()))}mutationCallback(e){const n=new Set,i=new Map,s=new Set,r=new Set,o=[],a=new Set,l=this;function c(t,e){const o=l.getNodeId(t);if(o){if(e){s.add(t),i.delete(t);const n=l.getNodeId(e);n&&r.add(n+"@"+o)}}else n.add(t);t.childNodes.forEach((t=>c(t)))}function d(t,e){t.delete(e),e.childNodes.forEach((e=>{d(t,e)}))}e.forEach((t=>{const{target:e,addedNodes:h,removedNodes:u,type:p,attributeName:f,oldValue:m}=t;switch(p){case"attributes":o.push({key:f,node:e,oldValue:m});break;case"characterData":a.add(e);break;case"childList":h.forEach((t=>c(t,e))),u.forEach((t=>function(t,e){if(!t)return;const o=l.getNodeId(t),a=l.getNodeId(t.parentNode);n.has(t)?(d(n,t),i.set(t,e)):s.has(t)&&r.has(a+"@"+o)?(d(s,t),r.delete(a+"@"+o)):i.set(t,e)}(t,e)))}}));const h=[],u=new Map;n.forEach((t=>{const e=this.getNodeId(t.parentNode),n=it.getNodeId(t),i=n?st(t,{id:n}):((t,e=!1)=>{const n=st(t,{isSVG:e}),{id:i}=n;return it.addNode(t,i),n})(t);if(S(i)){t.constructor.name.startsWith("SVG")&&(i.extra.isSVG=!0)}h.push({parentId:e,nextId:this.getNodeId(t.nextSibling)||null,node:i}),S(i)&&u.set(i.id,i)}));const p=[];s.forEach((t=>{const e=this.getNodeId(t);p.push({parentId:this.getNodeId(t.parentNode),nextId:this.getNodeId(t.nextSibling)||null,id:e})}));const f=[];i.forEach(((t,e)=>{const n=this.getNodeId(e),i=this.getNodeId(t);n&&i&&f.push({parentId:i,id:n})}));const m=o.map((t=>{const{node:e,key:n,oldValue:i}=t;if(V(e)){const t=e.getAttribute(n);if(i===t)return null;const s=this.getNodeId(e);return"IFRAME"===e.tagName&&"src"===n&&this.waitAndRecordIFrame(e),{id:s,key:n,value:t}}})).filter(Boolean),g=[...a].map((t=>{if(V(t)&&t.parentNode)return{id:this.getNodeId(t),parentId:this.getNodeId(t.parentNode),value:t.textContent}})).filter(Boolean),_={addedNodes:h,movedNodes:p,removedNodes:f,attrs:m,texts:g};Object.keys(_).forEach((t=>{_[t].length||delete _[t]}));const y=w();_.addedNodes&&(this.watchIFrames(h),this.rewriteAddedSource(h,y)),Object.values(_).some((t=>t.length))&&this.emitData(t.RecordType.DOM,_,y)}waitAndRecordIFrame(t){var e,n;const i=t.contentWindow;null===(n=null===(e=t)||void 0===e?void 0:e.frameRecorder)||void 0===n||n.destroy();const s=()=>{this.recorder.recordIFrame(i),t.removeEventListener("load",s)};t.addEventListener("load",s)}findElementsByTag(t,e){return e.filter((e=>e.node.tag===t))}watchIFrames(t){const e=this.findElementsByTag("iframe",t);e.length&&e.map((t=>it.getNode(t.node.id))).filter(Boolean).map((t=>t.contentWindow)).forEach((t=>this.recorder.recordIFrame(t)))}rewriteAddedSource(e,n){const{G_RECORD_OPTIONS:i}=window,s=(null==i?void 0:i.rewriteResource)||[];if(!(null==s?void 0:s.length))return;ft(e.map((t=>t.node)).filter((t=>S(t)&&t)),s,(e=>this.emitData(t.RecordType.PATCH,e,n+1)))}},FormElementWatcher:class extends ut{init(){this.listenInputs(this.options),this.hijackInputs(this.options)}listenInputs(e){const{context:n}=e;let i;!function(t){t.input="input",t.change="change",t.focus="focus",t.blur="blur"}(i||(i={}));const r={once:!1,passive:!0,capture:!0};function o(e){const n=e.type;let r;switch(n){case i.input:case i.change:const t=e.target,o=t.getAttribute("type")||"text";let a="value";const l=t.value||"";let c="";const d=[];if("checkbox"===o||"radio"===o){if("input"===n)return;a="checked",c=t.checked}else{if(l===t.oldValue)return;l.lengthe=>{n.addEventListener(t,e,r),this.uninstall((()=>n.removeEventListener(t,e,r)))})).forEach((t=>t(o.bind(this))))}hijackInputs(e){const{context:n}=e,i=this;function r(e,n){const r={type:s.PROP,id:i.getNodeId(this),key:e,value:n};i.emitData(t.RecordType.FORM_EL,r)}const o=(t,e)=>{const i=n.Object.getOwnPropertyDescriptor(e,t);n.Object.defineProperty(e,t,{set:function(e){setTimeout((()=>{r.call(this,t,e)})),i&&i.set&&i.set.call(this,e)}}),this.uninstall((()=>{i&&n.Object.defineProperty(e,t,i)}))};new Map([[n.HTMLSelectElement.prototype,"value"],[n.HTMLTextAreaElement.prototype,"value"],[n.HTMLOptionElement.prototype,"selected"]]).forEach(o.bind(this)),new Map([["value",n.HTMLInputElement.prototype],["checked",n.HTMLInputElement.prototype]]).forEach(((t,e)=>o(e,t)))}},MouseWatcher:class extends ut{init(){this.mouseMove(),this.mouseClick(),this.detectScrolling()}detectScrolling(){let t;const e=()=>{this.scrolling=!0,clearTimeout(t),t=this.context.setTimeout((()=>{this.scrolling=!1,this.latestMove&&(this.sendMoveData(this.latestMove),this.latestMove=null)}),500)};["mousewheel","scroll"].forEach((t=>{this.context.addEventListener(t,e,!0),this.uninstall((()=>{this.context.removeEventListener(t,e,!0)}))}))}sendMoveData(e){const{x:n,y:i,id:s}=e;this.emitData(t.RecordType.MOUSE,{type:r.MOVE,id:s,x:n,y:i})}mouseMove(){const t="mousemove",e=O((t=>{const e=this.getOffsetPosition(t,this.context);this.scrolling?this.latestMove=e:e&&this.sendMoveData(e)}),300,{trailing:!0,leading:!0});this.context.addEventListener(t,e),this.uninstall((()=>{this.context.removeEventListener(t,e)}))}mouseClick(){const e="click",n=O((e=>{const n=this.getOffsetPosition(e,this.context);n&&this.emitData(t.RecordType.MOUSE,Object.assign({type:r.CLICK},n))}),250);this.uninstall((()=>{this.context.removeEventListener(e,n)})),this.context.addEventListener(e,n)}getOffsetPosition(t,e){var n;const{mode:i}=e.G_RECORD_OPTIONS,{view:s,target:r,offsetX:o,offsetY:a}=t;if(s===e){const t=r.ownerDocument;function l(t){return"inline"===e.getComputedStyle(t).display}let s,c=r;if(V(c)){for(;l(c);)c=c.parentElement;s=this.getNodeId(c)}let d;if(function(t){if(!V(t))return 0;const n=e.getComputedStyle(t).transform;let i;if("none"!==n){const t=n.split("(")[1].split(")")[0].split(","),e=Number(t[0]),s=Number(t[1]);i=Math.round(Math.atan2(s,e)*(180/Math.PI))}else i=0;return i{this.snapshotCanvas(t)}))}snapshotCanvas(e){if(Et(e))return;const n=e.toDataURL();this.emitData(t.RecordType.CANVAS_SNAPSHOT,{id:this.getNodeId(e),src:n})}},Canvas2DWatcher:class extends ut{constructor(){super(...arguments),this.aggregateDataEmitter=this.strokesManager(((e,n)=>{this.emitData(t.RecordType.CANVAS,{id:e,strokes:n})}))}getCanvasInitState(t){return Object.values(M).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:t[n]})),{})}init(){this.watchCreatedCanvas(),this.watchCreatingCanvas()}watchCreatedCanvas(){const t=document.getElementsByTagName("canvas");Array.from(t).forEach((t=>{Et(t)?vt(t,(e=>{"2d"===e&&this.watchCanvas(t)})):this.watchCanvas(t)}))}watchCreatingCanvas(){xt.call(this,(t=>{vt(t,(e=>{"2d"===e&&this.watchCanvas(t)}))})),this.uninstall((()=>At()))}watchCanvas(e){const n=this,i=CanvasRenderingContext2D.prototype,s=U,r=e.getContext("2d");if(!r)return;if(Rt.get(e))return;this.emitData(t.RecordType.CANVAS,{id:this.getNodeId(r.canvas),status:this.getCanvasInitState(r)});const o={};s.forEach((t=>{const e=Object.getOwnPropertyDescriptor(i,t),s=e.value;o[t]=r[t];const a=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(r,t,{get(){const e=this,i=n.getNodeId(this.canvas);return"function"==typeof s?function(){var r;const o=[...arguments];if("createPattern"===t)o[0]=i;else if("drawImage"===t){const t=null===(r=o[0])||void 0===r?void 0:r.constructor.name;if("HTMLCanvasElement"===t){const t=o[0].toDataURL();o[0]=t}else if("HTMLImageElement"===t){const t=o[0];t.setAttribute("crossorigin","anonymous");const e=document.createElement("canvas",!1);e.width=t.width,e.height=t.height;e.getContext("2d").drawImage(t,0,0,t.width,t.height),o[0]=e.toDataURL()}}return n.aggregateDataEmitter(i,t,o),s.apply(e,arguments)}:o[t]},set:function(i){var s;const r=n.getNodeId(this.canvas);return"function"!=typeof i&&n.aggregateDataEmitter(r,t,i),o[t]=i,null===(s=e.set)||void 0===s?void 0:s.apply(this,arguments)},configurable:!0}),this.uninstall((()=>{Object.defineProperty(r,t,a||e)}))})),Rt.set(e,!0),this.uninstall((()=>{Rt.set(e,!1)}))}strokesManager(t,e=30){const n=Object.create(null),i=Object.create(null),s=[CanvasGradient,CanvasPattern];return function(r,o,a){if(!r)return;const l=it.getNode(r);if(!l)return;const c=this,d=U.indexOf("clearRect");if(n[r]||(n[r]=[]),!s.some((t=>a instanceof t))){const t=U.indexOf(o);n[r].push({name:t,args:a})}if(!i[r]){const s=window.setTimeout((()=>{(e=>{clearTimeout(i[e]),i[e]=0;const s=n[e].slice(),{width:r,height:o}=l.getBoundingClientRect(),a=s.reverse().findIndex((t=>{if(t.name===d){const e=t.args;if(0===e[0]&&0===e[1]&&e[2]===r&&e[3]===o)return!0}})),h=~a?s.slice(0,a+1).reverse():s.reverse();t.call(c,e,h),n[e].length=0})(r)}),e);i[r]=s}}}},CanvasWebGLWatcher:class extends ut{constructor(){super(...arguments),this.GLVars=Object.create(null),this.emitStroke=bt({keys:F,wait:20,blockInstances:[],fn:(e,n)=>{n=this.parseArgs(n),this.emitData(t.RecordType.WEBGL,{id:e,args:n})}})}init(){this.patchWebGLProto(WebGLRenderingContext.prototype),void 0!==window.WebGL2RenderingContext&&this.patchWebGLProto(WebGL2RenderingContext.prototype)}patchWebGLProto(t){Object.getOwnPropertyNames(t).forEach((e=>{"canvas"!==e&&"constructor"!==e&&void 0===t.__lookupGetter__(e)&&"function"==typeof t[e]&&this.patchProtoFunc(t,e)}))}patchProtoFunc(t,e){const n=t[e],i=this;if("isPatch"in n)return;const s=function(){const t=n.apply(this,arguments),s=[...arguments];return setTimeout((()=>{const t=this.canvas,n=i.getNodeId(t)||it.addNode(t);i.emitStroke(n,e,s)})),t};s.isPatch=!0,t[e]=s,this.uninstall((()=>{delete s.isPatch,t[e]=n}))}watchCreatedCanvas(){const t=document.getElementsByTagName("canvas");Array.from(t).forEach((t=>{Et(t)&&vt(t,(e=>{"webgl"!==e&&"experimental-webgl"!==e||this.watchCanvas(t)}))}))}watchCreatingCanvas(){xt.call(this,(t=>{vt(t,(e=>{"webgl"!==e&&"experimental-webgl"!==e||this.watchCanvas(t)}))})),this.uninstall((()=>At()))}watchCanvas(t){const e=this,n=WebGLRenderingContext.prototype,i=t.getContext("webgl")||t.getContext("experimental-webgl");if(!i)return;if(It.get(t))return;const s={};for(const r in i){const o=r;if("canvas"===o)continue;if("drawingBufferHeight"===r||"drawingBufferWidth"===r)continue;const a=Object.getOwnPropertyDescriptor(n,o),l=a.value;s[o]=l;const c=Object.getOwnPropertyDescriptor(i,o);Object.defineProperty(i,o,{get(){const n=this;return"function"==typeof l?function(){const i=[...arguments];return setTimeout((()=>{const s=e.getNodeId(n.canvas)||it.addNode(t);e.emitStroke(s,o,i)})),l.apply(n,arguments)}:s[o]},set:function(n){var i;return setTimeout((()=>{const i=e.getNodeId(this.canvas)||it.addNode(t);"function"!=typeof n&&this.emitStroke(i,o,n)})),s[o]=n,null===(i=a.set)||void 0===i?void 0:i.apply(this,arguments)},configurable:!0}),this.uninstall((()=>{Object.defineProperty(i,o,c||a)}))}It.set(t,!0),this.uninstall((()=>{It.set(t,!1)}))}parseArgs(t){return t.map((({name:t,args:e})=>({name:t,args:e.map((t=>this.getWebGLVariable(t)))})))}getWebGLVariable(t){if(ArrayBuffer.isView(t))return"$f32arr"+Array.prototype.slice.call(t);if(t instanceof Array)return"$arr"+Array.prototype.slice.call(t);if(t instanceof HTMLImageElement)return"$src@"+t.src;if(St.some((e=>t instanceof e))||"object"==typeof t&&null!==t||t&&"WebGLVertexArrayObjectOES"===t.constructor.name){const e=t.constructor.name,n=this.GLVars[e]||(this.GLVars[e]=[]);let i=n.indexOf(t);return~i||(i=n.length,n.push(t)),"$"+e+"@"+i}return t}},FontWatcher:class extends ut{init(){this.recordOptions.font&&this.interceptAddFont()}interceptAddFont(){const e=window.FontFace,n=this;window.FontFace=function(i,s){const r=new e(i,s);n.emitData(t.RecordType.FONT,{family:i,source:"string"==typeof s?s:function(t){const e=new Uint16Array(t),n=e.byteLength;let i=Math.pow(2,16)-1,s="";for(let t=0;tn&&(i=n-t),s+=String.fromCharCode.apply(null,e.subarray(t,t+i));return s}(s)}),document.fonts.add(r)},this.uninstall((()=>{window.FontFace=e}))}},TerminateWatcher:class extends ut{init(){this.context.addEventListener("beforeunload",this.handleFn),this.uninstall((()=>{this.context.removeEventListener("beforeunload",this.handleFn)}))}handleFn(){}wrapData(){return[t.RecordType.TERMINATE,null]}}});class kt{constructor(t=kt.defaultRecordOptions){this.setOptions(t)}getOptions(){return this.opts}setOptions(t=kt.defaultRecordOptions){this.opts=Object.assign(Object.assign({},this.opts),t)}beginRecord(){this.audioContext=new(window.AudioContext||window.webkitAudioContext)({sampleRate:this.opts.sampleRate}),this.mediaNode=this.audioContext.createMediaStreamSource(this.mediaStream);this.processNode=this.audioContext.createScriptProcessor.call(this.audioContext,4096,this.opts.channelCount,this.opts.channelCount),this.processNode.connect(this.audioContext.destination),this.processNode.onaudioprocess=function(t){const e=t.inputBuffer.getChannelData(0).slice();if(this.onProgress){const t=[Y(e)];this.onProgress(t)}}.bind(this),this.mediaNode.connect(this.processNode)}initRecorder(){return n(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{window.navigator.mediaDevices.getUserMedia({audio:{sampleRate:this.opts.sampleRate,channelCount:this.opts.channelCount,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!1,latency:0}}).then((e=>t(e))).catch((t=>e(t)))}))}))}start(t=kt.defaultRecordOptions){return n(this,void 0,void 0,(function*(){this.setOptions(t),this.mediaStream=yield this.initRecorder(),this.mediaStream&&this.beginRecord()}))}stop(){this.mediaStream&&this.mediaStream.getAudioTracks()[0].stop(),this.processNode&&this.processNode.disconnect(),this.mediaNode&&this.mediaNode.disconnect()}pause(){}resume(){}}kt.defaultRecordOptions={sampleBits:8,sampleRate:48e3,channelCount:1};class Ct extends ut{constructor(t){super(t)}init(){const e=new kt({sampleBits:8,sampleRate:8e3,channelCount:1});e.start(),this.uninstall((()=>{e.stop()})),this.emitData(t.RecordType.AUDIO,{type:"opts",data:e.getOptions()}),e.onProgress=e=>{this.emitData(t.RecordType.AUDIO,{encode:"base64",type:"pcm",data:e})}}}class Lt extends ut{init(){const e=this.DOMSnapshotData(this.options.context||window),n=w();this.checkNodesData(e,n),this.emitData(t.RecordType.SNAPSHOT,e,n)}DOMSnapshotData(t){return Object.assign({vNode:lt(t.document.documentElement)},this.getInitInfo(t))}getInitInfo(t){const{name:e,publicId:n,systemId:i}=t.document.doctype||{},[s]=document.getElementsByTagName("base"),r=it.getNodeId(t.frameElement)||null;return{doctype:{name:e,publicId:n,systemId:i},href:(null==s?void 0:s.href)||t.location.href,scrollTop:t.pageYOffset,scrollLeft:t.pageXOffset,width:t.innerWidth,height:t.innerHeight,frameId:r}}checkNodesData({vNode:e},n){const{G_RECORD_OPTIONS:i}=window,s=(null==i?void 0:i.rewriteResource)||[];if(!(null==s?void 0:s.length))return;const r=t=>{const e=[];return t.forEach((t=>{const n=t;S(n)&&e.push(n,...r(n.children))})),e};ft(r(e.children),s,(e=>{this.emitData(t.RecordType.PATCH,e,n+1)}))}}var Dt="1.2.0-alpha.27";class Pt{constructor(t){Array.isArray(t)||(t=[]),this._args=t,this.taps=[],this.interceptors=[],this.call=this._call,this.promise=this._promise,this.callAsync=this._callAsync,this._x=void 0}compile(t){throw new Error("Abstract: should be overriden")}_createCall(t){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:t})}tap(t,e){if("string"==typeof t&&(t={name:t}),"object"!=typeof t||null===t)throw new Error("Invalid arguments to tap(options: Object, fn: function)");if("string"!=typeof(t=Object.assign({type:"sync",fn:e},t)).name||""===t.name)throw new Error("Missing name for tap");t=this._runRegisterInterceptors(t),this._insert(t)}tapAsync(t,e){if("string"==typeof t&&(t={name:t}),"object"!=typeof t||null===t)throw new Error("Invalid arguments to tapAsync(options: Object, fn: function)");if("string"!=typeof(t=Object.assign({type:"async",fn:e},t)).name||""===t.name)throw new Error("Missing name for tapAsync");t=this._runRegisterInterceptors(t),this._insert(t)}tapPromise(t,e){if("string"==typeof t&&(t={name:t}),"object"!=typeof t||null===t)throw new Error("Invalid arguments to tapPromise(options: Object, fn: function)");if("string"!=typeof(t=Object.assign({type:"promise",fn:e},t)).name||""===t.name)throw new Error("Missing name for tapPromise");t=this._runRegisterInterceptors(t),this._insert(t)}_runRegisterInterceptors(t){for(const e of this.interceptors)if(e.register){const n=e.register(t);void 0!==n&&(t=n)}return t}withOptions(t){const e=e=>Object.assign({},t,"string"==typeof e?{name:e}:e);t=Object.assign({},t,this._withOptions);const n=this._withOptionsBase||this,i=Object.create(n);return i.tapAsync=(t,i)=>n.tapAsync(e(t),i),i.tap=(t,i)=>n.tap(e(t),i),i.tapPromise=(t,i)=>n.tapPromise(e(t),i),i._withOptions=t,i._withOptionsBase=n,i}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(t){if(this._resetCompilation(),this.interceptors.push(Object.assign({},t)),t.register)for(let e=0;e0;){i--;const t=this.taps[i];this.taps[i+1]=t;const s=t.stage||0;if(e){if(e.has(t.name)){e.delete(t.name);continue}if(e.size>0)continue}if(!(s>n)){i++;break}}this.taps[i]=t}}function Mt(t,e){return function(...n){return this[t]=this._createCall(e),this[t](...n)}}Object.defineProperties(Pt.prototype,{_call:{value:Mt("call","sync"),configurable:!0,writable:!0},_promise:{value:Mt("promise","promise"),configurable:!0,writable:!0},_callAsync:{value:Mt("callAsync","async"),configurable:!0,writable:!0}});var Ut=Pt;var Ft=class{constructor(t){this.config=t,this.options=void 0,this._args=void 0}create(t){let e;switch(this.init(t),this.options.type){case"sync":e=new Function(this.args(),'"use strict";\n'+this.header()+this.content({onError:t=>`throw ${t};\n`,onResult:t=>`return ${t};\n`,resultReturns:!0,onDone:()=>"",rethrowIfPossible:!0}));break;case"async":e=new Function(this.args({after:"_callback"}),'"use strict";\n'+this.header()+this.content({onError:t=>`_callback(${t});\n`,onResult:t=>`_callback(null, ${t});\n`,onDone:()=>"_callback();\n"}));break;case"promise":let t=!1;const n=this.content({onError:e=>(t=!0,`_error(${e});\n`),onResult:t=>`_resolve(${t});\n`,onDone:()=>"_resolve();\n"});let i="";i+='"use strict";\n',i+="return new Promise((_resolve, _reject) => {\n",t&&(i+="var _sync = true;\n",i+="function _error(_err) {\n",i+="if(_sync)\n",i+="_resolve(Promise.resolve().then(() => { throw _err; }));\n",i+="else\n",i+="_reject(_err);\n",i+="};\n"),i+=this.header(),i+=n,t&&(i+="_sync = false;\n"),i+="});\n",e=new Function(this.args(),i)}return this.deinit(),e}setup(t,e){t._x=e.taps.map((t=>t.fn))}init(t){this.options=t,this._args=t.args.slice()}deinit(){this.options=void 0,this._args=void 0}header(){let t="";this.needContext()?t+="var _context = {};\n":t+="var _context;\n",t+="var _x = this._x;\n",this.options.interceptors.length>0&&(t+="var _taps = this.taps;\n",t+="var _interceptors = this.interceptors;\n");for(let e=0;e {\n`:`_err${t} => {\n`,o+=`if(_err${t}) {\n`,o+=e(`_err${t}`),o+="} else {\n",n&&(o+=n(`_result${t}`)),i&&(o+=i()),o+="}\n",o+="}",r+=`_fn${t}(${this.args({before:a.context?"_context":void 0,after:o})});\n`;break;case"promise":r+=`var _hasResult${t} = false;\n`,r+=`var _promise${t} = _fn${t}(${this.args({before:a.context?"_context":void 0})});\n`,r+=`if (!_promise${t} || !_promise${t}.then)\n`,r+=` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${t} + ')');\n`,r+=`_promise${t}.then(_result${t} => {\n`,r+=`_hasResult${t} = true;\n`,n&&(r+=n(`_result${t}`)),i&&(r+=i()),r+=`}, _err${t} => {\n`,r+=`if(_hasResult${t}) throw _err${t};\n`,r+=e(`_err${t}`),r+="});\n"}return r}callTapsSeries({onError:t,onResult:e,resultReturns:n,onDone:i,doneReturns:s,rethrowIfPossible:r}){if(0===this.options.taps.length)return i();const o=this.options.taps.findIndex((t=>"sync"!==t.type)),a=n||s||!1;let l="",c=i;for(let n=this.options.taps.length-1;n>=0;n--){const s=n;c!==i&&"sync"!==this.options.taps[s].type&&(l+=`function _next${s}() {\n`,l+=c(),l+="}\n",c=()=>`${a?"return ":""}_next${s}();\n`);const d=c,h=t=>t?"":i(),u=this.callTap(s,{onError:e=>t(s,e,d,h),onResult:e&&(t=>e(s,t,d,h)),onDone:!e&&d,rethrowIfPossible:r&&(ou}return l+=c(),l}callTapsLooping({onError:t,onDone:e,rethrowIfPossible:n}){if(0===this.options.taps.length)return e();const i=this.options.taps.every((t=>"sync"===t.type));let s="";i||(s+="var _looper = () => {\n",s+="var _loopAsync = false;\n"),s+="var _loop;\n",s+="do {\n",s+="_loop = false;\n";for(let t=0;t{let r="";return r+=`if(${e} !== undefined) {\n`,r+="_loop = true;\n",i||(r+="if(_loopAsync) _looper();\n"),r+=s(!0),r+="} else {\n",r+=n(),r+="}\n",r},onDone:e&&(()=>{let t="";return t+="if(!_loop) {\n",t+=e(),t+="}\n",t}),rethrowIfPossible:n&&i}),s+="} while(_loop);\n",i||(s+="_loopAsync = true;\n",s+="};\n",s+="_looper();\n"),s}callTapsParallel({onError:t,onResult:e,onDone:n,rethrowIfPossible:i,onTap:s=((t,e)=>e())}){if(this.options.taps.length {\n",r+=n(),r+="};\n");for(let o=0;on?"if(--_counter === 0) _done();\n":"--_counter;",l=t=>t||!n?"_counter = 0;\n":"_counter = 0;\n_done();\n";r+="if(_counter this.callTap(o,{onError:e=>{let n="";return n+="if(_counter > 0) {\n",n+=t(o,e,a,l),n+="}\n",n},onResult:e&&(t=>{let n="";return n+="if(_counter > 0) {\n",n+=e(o,t,a,l),n+="}\n",n}),onDone:!e&&(()=>a()),rethrowIfPossible:i})),a,l)}return r+="} while(false);\n",r}args({before:t,after:e}={}){let n=this._args;return t&&(n=[t].concat(n)),e&&(n=n.concat(e)),0===n.length?"":n.join(", ")}getTapFn(t){return`_x[${t}]`}getTap(t){return`_taps[${t}]`}getInterceptor(t){return`_interceptors[${t}]`}};const Bt=new class extends Ft{content({onError:t,onDone:e,rethrowIfPossible:n}){return this.callTapsSeries({onError:(e,n)=>t(n),onDone:e,rethrowIfPossible:n})}};var jt,Ht,zt=class extends Ut{tapAsync(){throw new Error("tapAsync is not supported on a SyncHook")}tapPromise(){throw new Error("tapPromise is not supported on a SyncHook")}compile(t){return Bt.setup(this,t),Bt.create(t)}};!function(t){t.beforeRun="beforeRun",t.run="run",t.emit="emit",t.end="end"}(jt||(jt={}));class Vt extends ut{init(){const t=this.recordOptions,{video:e}=t;this.fps=e.fps,this.watchVideos()}watchVideos(){const t=document.getElementsByTagName("video");Array.from(t).forEach((t=>{this.recordVideo(t)}))}recordVideo(e){const i=this.createMirrorCanvas(e),s=i.getContext("2d");if(!s)return;const r=()=>{this.resizeCanvasSize(i,e)};function o(t,e){const n=e.canvas;e.drawImage(t,0,0,n.width,n.height)}e.addEventListener("resize",r),o(e,s);const a=new MediaRecorder(i.captureStream(60),{mimeType:"video/webm;codecs=vp9",bitsPerSecond:1e6});a.ondataavailable=i=>n(this,void 0,void 0,(function*(){const n=i.data,s=q(yield n.arrayBuffer()),r={id:it.getNodeId(e),dataStr:s};this.emitData(t.RecordType.VIDEO,r)}));const l=()=>{"recording"===a.state&&a.stop()};let c=!1;const d=new J((()=>o(e,s)),this.fps),h=N((()=>{c=!c,c?(d.start(),a.start(1e3/this.fps)):(d.stop(),l())}),300,{isTrailing:!0,isImmediate:!0});e.addEventListener("timeupdate",h),this.uninstall((()=>{l(),e.removeEventListener("timeupdate",h),e.removeEventListener("resize",r)}))}createMirrorCanvas(t){const e=document.createElement("canvas",!1);return this.resizeCanvasSize(e,t),e}resizeCanvasSize(t,e){const{width:n,height:i}=e.getBoundingClientRect();t.width=n,t.height=i}}t.RecorderStatus=void 0,(Ht=t.RecorderStatus||(t.RecorderStatus={})).RUNNING="running",Ht.PAUSE="pause",Ht.HALT="halt";class Gt extends class{constructor(t){this.defaultPlugins=[],this.pluginWatchers=[],this.checkHookAvailable=()=>{try{return(new zt).call(),!0}catch(t){E(`Plugin hooks is not available in the current env, because ${t}`)}},this.plugin=(t,e)=>{const n=/Async/.test(this.hooks[t].constructor.name)?"tapAsync":"tap";this.hooks[t][n](t,e)},this.plugins=[],this.initPlugin(t);const e={beforeRun:new zt,run:new zt,emit:new zt(["data"]),end:new zt},n=this.checkHookAvailable()?e:Object.keys(e).reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:()=>{}})),{});this.hooks=n}use(t){this.plugins.push(t)}initPlugin(t){const{plugins:e}=t||{};this.plugins.push(...this.defaultPlugins,...e||[])}loadPlugins(){this.plugins.forEach((t=>{t.apply.call(t,this)}))}addWatcher(t){this.pluginWatchers.push(t)}}{constructor(e){super(e),this.defaultMiddleware=[],this.destroyStore=new Set,this.listenStore=new Set,this.middleware=[...this.defaultMiddleware],this.watchersInstance=new Map,this.watchesReadyPromise=new Promise((t=>this.watcherResolve=t)),this.status=t.RecorderStatus.PAUSE;const n=this.initOptions(e);n.rootContext=n.rootContext||n.context,this.options=n,this.watchers=this.getWatchers(),this.init()}initOptions(t){const e=Object.assign(Object.assign({},Gt.defaultRecordOpts),t);return!0===e.video?e.video={fps:24}:e.video&&"fps"in e.video&&e.video.fps>24&&(e.video.fps=24),e}init(){this.startTime=w();const t=this.options;this.db=et,this.loadPlugins(),this.hooks.beforeRun.call(this),this.record(t),this.hooks.run.call(this)}onData(t){this.middleware.unshift(t)}destroy(){return n(this,void 0,void 0,(function*(){if(this.status===t.RecorderStatus.HALT)return;const e=yield this.pause();e&&(this.status=t.RecorderStatus.HALT,this.destroyTime=e.lastTime||w())}))}pause(){return n(this,void 0,void 0,(function*(){if(this.status===t.RecorderStatus.RUNNING){this.status=t.RecorderStatus.PAUSE;const e=yield this.db.last().catch((()=>{}));yield this.cancelListener(),this.destroyStore.forEach((t=>t())),this.destroyStore.clear();let n=null;if(e){n=e.time+1;const i={type:t.RecordType.TERMINATE,data:null,relatedId:window.G_RECORD_RELATED_ID,time:n};i.relatedId&&(this.options.write&&this.db.add(i),this.connectCompose(this.middleware)(i))}return{lastTime:n}}}))}clearDB(){this.db.clear()}cancelListener(){return n(this,void 0,void 0,(function*(){yield this.watchesReadyPromise,this.listenStore.forEach((t=>t())),this.listenStore.clear(),it.reset()}))}getWatchers(){const{video:t,audio:e,disableWatchers:n}=this.options,i=[Lt,...Object.values(Nt)];return e&&i.push(Ct),t&&i.push(Vt),i.filter((t=>!~n.indexOf(t.name)))}record(e){if(this.status!==t.RecorderStatus.PAUSE);else{const t=Object.assign(Object.assign({},Gt.defaultRecordOpts),e);this.startRecord(t.context.G_RECORD_OPTIONS=t)}}startRecord(e){return n(this,void 0,void 0,(function*(){this.status=t.RecorderStatus.RUNNING;let i=[...this.watchers,...this.pluginWatchers];e.context===this.options.rootContext?e.keep||this.db.clear():i=[Lt,...Object.values(Ot)];const s=e.context===this.options.rootContext,r=(e=>{const{write:i}=e,s=[],{middleware:r}=this.options.rootRecorder||{middleware:[]},o=(()=>{let e=0;return()=>n(this,void 0,void 0,(function*(){if(!(e>=1)){for(e++;s.length;){const e=s.shift();if(yield R(0),this.status===t.RecorderStatus.RUNNING){i&&this.db.add(e);const t=[...r,...this.middleware];yield this.connectCompose(t)(e),this.hooks.emit.call(e)}}e--}}))})();return t=>{t&&(s.push(t),o())}})(e),o={href:location.href,title:document.title,relatedId:T(),userAgent:navigator.userAgent,platform:navigator.platform,beginTime:w(),version:Dt},a=s?o.relatedId:e.rootContext.G_RECORD_RELATED_ID;if(e.context.G_RECORD_RELATED_ID=a,s&&r({type:t.RecordType.HEAD,data:o,relatedId:a,time:w()}),i.forEach((t=>{try{const n=new t({recorder:this,context:e&&e.context,listenStore:this.listenStore,relatedId:a,emit:r,watchers:this.watchersInstance});this.watchersInstance.set(t.name,n)}catch(t){E(t)}})),s&&e.emitLocationImmediate){const t=this.watchersInstance.get(yt.name);null==t||t.emitOne()}this.watcherResolve(),yield this.recordSubIFrames(e.context)}))}waitingSubIFramesLoaded(t){return n(this,void 0,void 0,(function*(){const e=Array.from(t.frames).filter((t=>{try{return t.frameElement&&t.frameElement.getAttribute("src")}catch(t){return E(t),!1}})).map((t=>n(this,void 0,void 0,(function*(){return yield R(0),yield new Promise((e=>{"complete"===t.document.readyState?e(t):t.addEventListener("load",(()=>{e(t)}))}))}))));return e.length?Promise.all(e):Promise.resolve([])}))}waitingIFrameLoaded(t){return n(this,void 0,void 0,(function*(){try{t.document&&t.frameElement&&t.frameElement.getAttribute("src")}catch(t){return void E(t)}return new Promise((e=>{const n=window.setInterval((()=>{try{t.document&&(clearInterval(n),e(t))}catch(t){E(t),clearInterval(n),e(void 0)}}),200)}))}))}recordSubIFrames(t){return n(this,void 0,void 0,(function*(){(yield this.waitingSubIFramesLoaded(t)).forEach((t=>{this.createIFrameRecorder(t)}))}))}recordIFrame(t){return n(this,void 0,void 0,(function*(){const e=yield this.waitingIFrameLoaded(t);e&&this.createIFrameRecorder(e)}))}createIFrameRecorder(t){const e=new Gt(Object.assign(Object.assign({},this.options),{context:t,keep:!0,rootRecorder:this.options.rootRecorder||this,rootContext:this.options.rootContext}));t.frameElement.frameRecorder=e,this.destroyStore.add((()=>e.destroy()))}connectCompose(t){return e=>n(this,void 0,void 0,(function*(){return yield t.reduce(((t,n)=>this.createNext(n,e,t)),(()=>Promise.resolve()))()}))}createNext(t,e,i){return()=>n(this,void 0,void 0,(function*(){return yield t(e,i)}))}}Gt.defaultRecordOpts={mode:"default",write:!0,keep:!1,audio:!1,video:!1,emitLocationImmediate:!0,context:window,rewriteResource:[],disableWatchers:[]};var Wt,Xt=(function(t,e){t.exports={polyfill:function(){var t=window,e=document;if(!("scrollBehavior"in e.documentElement.style)||!0===t.__forceSmoothScrollPolyfill__){var n,i=t.HTMLElement||t.Element,s={scroll:t.scroll||t.scrollTo,scrollBy:t.scrollBy,elementScroll:i.prototype.scroll||a,scrollIntoView:i.prototype.scrollIntoView},r=t.performance&&t.performance.now?t.performance.now.bind(t.performance):Date.now,o=(n=t.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(n)?1:0);t.scroll=t.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?f.call(t,e.body,void 0!==arguments[0].left?~~arguments[0].left:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:t.scrollY||t.pageYOffset):s.scroll.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:t.scrollY||t.pageYOffset))},t.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?s.scrollBy.call(t,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):f.call(t,e.body,~~arguments[0].left+(t.scrollX||t.pageXOffset),~~arguments[0].top+(t.scrollY||t.pageYOffset)))},i.prototype.scroll=i.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var t=arguments[0].left,e=arguments[0].top;f.call(this,this,void 0===t?this.scrollLeft:~~t,void 0===e?this.scrollTop:~~e)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");s.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)}},i.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}):s.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))},i.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var n=u(this),i=n.getBoundingClientRect(),r=this.getBoundingClientRect();n!==e.body?(f.call(this,n,n.scrollLeft+r.left-i.left,n.scrollTop+r.top-i.top),"fixed"!==t.getComputedStyle(n).position&&t.scrollBy({left:i.left,top:i.top,behavior:"smooth"})):t.scrollBy({left:r.left,top:r.top,behavior:"smooth"})}else s.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function a(t,e){this.scrollLeft=t,this.scrollTop=e}function l(t){if(null===t||"object"!=typeof t||void 0===t.behavior||"auto"===t.behavior||"instant"===t.behavior)return!0;if("object"==typeof t&&"smooth"===t.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+t.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(t,e){return"Y"===e?t.clientHeight+o1?1:o),e.method.call(e.scrollable,i=e.startX+(e.x-e.startX)*n,s=e.startY+(e.y-e.startY)*n),i===e.x&&s===e.y||t.requestAnimationFrame(p.bind(t,e))}function f(n,i,o){var l,c,d,h,u=r();n===e.body?(l=t,c=t.scrollX||t.pageXOffset,d=t.scrollY||t.pageYOffset,h=s.scroll):(l=n,c=n.scrollLeft,d=n.scrollTop,h=a),p({scrollable:l,method:h,startTime:u,startX:c,startY:d,x:i,y:o})}}}}(Wt={exports:{}},Wt.exports),Wt.exports);class Zt{constructor(){this.interval=1e3,this.len=0,this.resolved=!1,this.listener=[],this.timer=null,this.observe()}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}destroy(){this.listener.length=0}observe(){this.timer=window.setTimeout((()=>{const t=performance.getEntriesByType("resource").filter((t=>this.isMatchType(t))).length;if(tt())));this.len=t,this.observe()}),this.interval)}isMatchType(t){switch(t.initiatorType){case"link":case"img":case"css":case"iframe":return!0}}ready(t){if(this.resolved)return t();this.listener.push(t)}}const Yt=new class{constructor(){this.id=1,this.listenersMap=new Map}on(t,e){return this.getListenersByKey(t).set(++this.id,e),this.id}emit(t,...e){this.getListenersByKey(t).forEach((t=>{t(...e)}))}once(t,e){const n=this.on(t,((...i)=>{e(...i),this.off(t,n)}));return n}flush(t){this.getListenersByKey(t).clear()}destroy(){this.listenersMap.clear()}off(t,e){this.getListenersByKey(t).delete(e)}getListenersByKey(t){const e=this.listenersMap.get(t)||new Map;return this.listenersMap.set(t,e),e}};function Kt(t){let e=t.length;for(;--e>=0;)t[e]=0}const qt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),$t=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Jt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Qt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),te=new Array(576);Kt(te);const ee=new Array(60);Kt(ee);const ne=new Array(512);Kt(ne);const ie=new Array(256);Kt(ie);const se=new Array(29);Kt(se);const re=new Array(30);function oe(t,e,n,i,s){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=s,this.has_stree=t&&t.length}let ae,le,ce;function de(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Kt(re);const he=t=>t>>7)],ue=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},pe=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e{pe(t,n[2*e],n[2*e+1])},me=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n0);return n>>>1},ge=(t,e,n)=>{const i=new Array(16);let s,r,o=0;for(s=1;s{let e;for(e=0;e{t.bi_valid>8?ue(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},be=(t,e,n,i)=>{const s=2*e,r=2*n;return t[s]{const i=t.heap[n];let s=n{let i,s,r,o,a=0;if(0!==t.last_lit)do{i=t.pending_buf[t.d_buf+2*a]{const n=e.dyn_tree,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.elems;let o,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o>1;o>=1;o--)ve(t,n,o);l=r;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],ve(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[2*l]=n[2*o]+n[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[2*o+1]=n[2*a+1]=l,t.heap[1]=l++,ve(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,s=e.stat_desc.static_tree,r=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,p,f,m=0;for(u=0;ul&&(u=l,m++),n[2*d+1]=u,d>i||(t.bl_count[u]++,p=0,d>=a&&(p=o[d-a]),f=n[2*d],t.opt_len+=f*(u+p),r&&(t.static_len+=f*(s[2*d+1]+p)));if(0!==m){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),d--)}})(t,e),ge(n,c,t.bl_count)},Te=(t,e,n)=>{let i,s,r=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),e[2*(n+1)+1]=65535,i=0;i{let i,s,r=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),i=0;i{pe(t,0+(i?1:0),3),((t,e,n,i)=>{ye(t),ue(t,n),ue(t,~n),t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n})(t,e,n)};var Se={_tr_init:t=>{Ae||((()=>{let t,e,n,i,s;const r=new Array(16);for(n=0,i=0;i>=7;i{let s,r,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e{let e;for(Te(t,t.dyn_ltree,t.l_desc.max_code),Te(t,t.dyn_dtree,t.d_desc.max_code),we(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Qt[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),s=t.opt_len+3+7>>>3,r=t.static_len+3+7>>>3,r{let s;for(pe(t,e-257,5),pe(t,n-1,5),pe(t,i-4,4),s=0;s(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&n,t.last_lit++,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(ie[n]+256+1)]++,t.dyn_dtree[2*he(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{pe(t,2,3),fe(t,256,te),(t=>{16===t.bi_valid?(ue(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},Ie=(t,e,n,i)=>{let s=65535&t|0,r=t>>>16&65535|0,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{s=s+e[i++]|0,r=r+s|0}while(--o);s%=65521,r%=65521}return s|r{let t,e=[];for(var n=0;n>>1:t>>>1;e[n]=t}return e})());var Ne=(t,e,n,i)=>{const s=Oe,r=i+n;t^=-1;for(let n=i;n>>8^s[255&(t^e[n])];return-1^t},ke={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ce={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Le,_tr_stored_block:De,_tr_flush_block:Pe,_tr_tally:Me,_tr_align:Ue}=Se,{Z_NO_FLUSH:Fe,Z_PARTIAL_FLUSH:Be,Z_FULL_FLUSH:je,Z_FINISH:He,Z_BLOCK:ze,Z_OK:Ve,Z_STREAM_END:Ge,Z_STREAM_ERROR:We,Z_DATA_ERROR:Xe,Z_BUF_ERROR:Ze,Z_DEFAULT_COMPRESSION:Ye,Z_FILTERED:Ke,Z_HUFFMAN_ONLY:qe,Z_RLE:$e,Z_FIXED:Je,Z_DEFAULT_STRATEGY:Qe,Z_UNKNOWN:tn,Z_DEFLATED:en}=Ce,nn=(t,e)=>(t.msg=ke[e],e),sn=t=>(t4?9:0),rn=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let on=(t,e,n)=>(e{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},ln=(t,e)=>{Pe(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,an(t.strm)},cn=(t,e)=>{t.pending_buf[t.pending++]=e},dn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},hn=(t,e,n,i)=>{let s=t.avail_in;return s>i&&(s=i),0===s?0:(t.avail_in-=s,e.set(t.input.subarray(t.next_in,t.next_in+s),n),1===t.state.wrap?t.adler=Ie(t.adler,e,s,n):2===t.state.wrap&&(t.adler=Ne(t.adler,e,s,n)),t.next_in+=s,t.total_in+=s,s)},un=(t,e)=>{let n,i,s=t.max_chain_length,r=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+258;let p=c[r+o-1],f=c[r+o];t.prev_length>=t.good_match&&(s>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,c[n+o]===f&&c[n+o-1]===p&&c[n]===c[r]&&c[++n]===c[r+1]){r+=2,n++;do{}while(c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&ro){if(t.match_start=e,o=i,i>=a)break;p=c[r+o-1],f=c[r+o]}}}while((e=h[e&d])>l&&0!=--s);return o{const e=t.w_size;let n,i,s,r,o;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-262)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,i=t.hash_size,n=i;do{s=t.head[--n],t.head[n]=s>=e?s-e:0}while(--i);i=e,n=i;do{s=t.prev[--n],t.prev[n]=s>=e?s-e:0}while(--i);r+=e}if(0===t.strm.avail_in)break;if(i=hn(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=i,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=on(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=on(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert{let n,i;for(;;){if(t.lookahead=3&&(t.ins_h=on(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n=3)if(i=Me(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length=3){t.match_length--;do{t.strstart++,t.ins_h=on(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=on(t,t.ins_h,t.window[t.strstart+1]);else i=Me(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ln(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart{let n,i,s;for(;;){if(t.lookahead=3&&(t.ins_h=on(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length{let n=65535;for(n>t.pending_buf_size-5&&(n=t.pending_buf_size-5);;){if(t.lookahead=i)&&(t.lookahead=t.strstart-i,t.strstart=i,ln(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-262&&(ln(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===He?(ln(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&ln(t,!1),1)})),new gn(4,4,8,4,fn),new gn(4,5,16,8,fn),new gn(4,6,32,32,fn),new gn(4,4,16,16,mn),new gn(8,16,32,32,mn),new gn(8,16,128,128,mn),new gn(8,32,128,256,mn),new gn(32,128,258,1024,mn),new gn(32,258,258,4096,mn)];function yn(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=en,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),rn(this.dyn_ltree),rn(this.dyn_dtree),rn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),rn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),rn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const bn=t=>{if(!t||!t.state)return nn(t,We);t.total_in=t.total_out=0,t.data_type=tn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap{const e=bn(t);var n;return e===Ve&&((n=t.state).window_size=2*n.w_size,rn(n.head),n.max_lazy_match=_n[n.level].max_lazy,n.good_match=_n[n.level].good_length,n.nice_match=_n[n.level].nice_length,n.max_chain_length=_n[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},En=(t,e,n,i,s,r)=>{if(!t)return We;let o=1;if(e===Ye&&(e=6),i15&&(o=2,i-=16),s9||n!==en||i15||e9||rJe)return nn(t,We);8===i&&(i=9);const a=new yn;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1t&&t.state?2!==t.state.wrap?We:(t.state.gzhead=e,Ve):We,xn=(t,e)=>{let n,i;if(!t||!t.state||e>ze||e>8&255),cn(s,s.gzhead.time>>16&255),cn(s,s.gzhead.time>>24&255),cn(s,9===s.level?2:s.strategy>=qe||s.level>8&255)),s.gzhead.hcrc&&(t.adler=Ne(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69):(cn(s,0),cn(s,0),cn(s,0),cn(s,0),cn(s,0),cn(s,9===s.level?2:s.strategy>=qe||s.level=qe||s.level>>16),dn(s,65535&t.adler)),t.adler=1}if(69===s.status)if(s.gzhead.extra){for(n=s.pending;s.gzindexn&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),an(t),n=s.pending,s.pending!==s.pending_buf_size));)cn(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>n&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=73)}else s.status=73;if(73===s.status)if(s.gzhead.name){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),an(t),n=s.pending,s.pending===s.pending_buf_size)){i=1;break}i=s.gzindexn&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),0===i&&(s.gzindex=0,s.status=91)}else s.status=91;if(91===s.status)if(s.gzhead.comment){n=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>n&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),an(t),n=s.pending,s.pending===s.pending_buf_size)){i=1;break}i=s.gzindexn&&(t.adler=Ne(t.adler,s.pending_buf,s.pending-n,n)),0===i&&(s.status=103)}else s.status=103;if(103===s.status&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&an(t),s.pending+2>8&255),t.adler=0,s.status=113)):s.status=113),0!==s.pending){if(an(t),0===t.avail_out)return s.last_flush=-1,Ve}else if(0===t.avail_in&&sn(e){let n;for(;;){if(0===t.lookahead&&(pn(t),0===t.lookahead)){if(e===Fe)return 1;break}if(t.match_length=0,n=Me(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(ln(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===He?(ln(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ln(t,!1),0===t.strm.avail_out)?1:2})(s,e):s.strategy===$e?((t,e)=>{let n,i,s,r;const o=t.window;for(;;){if(t.lookahead=3&&t.strstart>0&&(s=t.strstart-1,i=o[s],i===o[++s]&&i===o[++s]&&i===o[++s])){r=t.strstart+258;do{}while(i===o[++s]&&i===o[++s]&&i===o[++s]&&i===o[++s]&&i===o[++s]&&i===o[++s]&&i===o[++s]&&i===o[++s]&&st.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=Me(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=Me(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(ln(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===He?(ln(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(ln(t,!1),0===t.strm.avail_out)?1:2})(s,e):_n[s.level].func(s,e);if(3!==n&&4!==n||(s.status=666),1===n||3===n)return 0===t.avail_out&&(s.last_flush=-1),Ve;if(2===n&&(e===Be?Ue(s):e!==ze&&(De(s,0,0,!1),e===je&&(rn(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),an(t),0===t.avail_out))return s.last_flush=-1,Ve}return e!==He?Ve:s.wrap>8&255),cn(s,t.adler>>16&255),cn(s,t.adler>>24&255),cn(s,255&t.total_in),cn(s,t.total_in>>8&255),cn(s,t.total_in>>16&255),cn(s,t.total_in>>24&255)):(dn(s,t.adler>>>16),dn(s,65535&t.adler)),an(t),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?Ve:Ge)},An=t=>{if(!t||!t.state)return We;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&103!==e&&113!==e&&666!==e?nn(t,We):(t.state=null,113===e?nn(t,Xe):Ve)},Rn=(t,e)=>{let n=e.length;if(!t||!t.state)return We;const i=t.state,s=i.wrap;if(2===s||1===s&&42!==i.status||i.lookahead)return We;if(1===s&&(t.adler=Ie(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===s&&(rn(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const r=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,pn(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=on(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,pn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=r,i.wrap=s,Ve};const Sn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var In=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)Sn(n,e)&&(t[e]=n[e])}}return t},On=t=>{let e=0;for(let n=0,i=t.length;n=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;kn[254]=kn[254]=1;var Cn=t=>{let e,n,i,s,r,o=t.length,a=0;for(s=0;s>>6,e[r++]=128|63&n):n>>12,e[r++]=128|n>>>6&63,e[r++]=128|63&n):(e[r++]=240|n>>>18,e[r++]=128|n>>>12&63,e[r++]=128|n>>>6&63,e[r++]=128|63&n);return e},Ln=(t,e)=>{let n,i;const s=e||t.length,r=new Array(2*s);for(i=0,n=0;n4)r[i++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n1?r[i++]=65533:e>10&1023,r[i++]=56320|1023&e)}}return((t,e)=>{if(e{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return ne?n:e},Pn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Mn=Object.prototype.toString,{Z_NO_FLUSH:Un,Z_SYNC_FLUSH:Fn,Z_FULL_FLUSH:Bn,Z_FINISH:jn,Z_OK:Hn,Z_STREAM_END:zn,Z_DEFAULT_COMPRESSION:Vn,Z_DEFAULT_STRATEGY:Gn,Z_DEFLATED:Wn}=Ce;function Xn(t){this.options=In({level:Vn,method:Wn,chunkSize:16384,windowBits:15,memLevel:8,strategy:Gn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits0&&this.onData(n.output.subarray(0,n.next_out)),s=An(this.strm),this.onEnd(s),this.ended=!0,s===Hn;if(0!==n.avail_out){if(r>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Xn.prototype.onData=function(t){this.chunks.push(t)},Xn.prototype.onEnd=function(t){t===Hn&&(this.result=On(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Yn={Deflate:Xn,deflate:Zn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Zn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Zn(t,e)},constants:Ce},Kn=function(t,e){let n,i,s,r,o,a,l,c,d,h,u,p,f,m,g,_,y,b,v,E,w,T,x,A;const R=t.state;n=t.next_in,x=t.input,i=n+(t.avail_in-5),s=t.next_out,A=t.output,r=s-(e-t.avail_out),o=s+(t.avail_out-257),a=R.dmax,l=R.wsize,c=R.whave,d=R.wnext,h=R.window,u=R.hold,p=R.bits,f=R.lencode,m=R.distcode,g=(1>>24,u>>>=b,p-=b,b=y>>>16&255,0===b)A[s++]=65535&y;else{if(!(16&b)){if(0==(64&b)){y=f[(65535&y)+(u&(1>>=b,p-=b),p>>24,u>>>=b,p-=b,b=y>>>16&255,!(16&b)){if(0==(64&b)){y=m[(65535&y)+(u&(1a){t.msg="invalid distance too far back",R.mode=30;break t}if(u>>>=b,p-=b,b=s-r,E>b){if(b=E-b,b>c&&R.sane){t.msg="invalid distance too far back",R.mode=30;break t}if(w=0,T=h,0===d){if(w+=l-b,b2;)A[s++]=T[w++],A[s++]=T[w++],A[s++]=T[w++],v-=3;v&&(A[s++]=T[w++],v>1&&(A[s++]=T[w++]))}else{w=s-E;do{A[s++]=A[w++],A[s++]=A[w++],A[s++]=A[w++],v-=3}while(v>2);v&&(A[s++]=A[w++],v>1&&(A[s++]=A[w++]))}break}}break}}while(n>3,n-=v,p-=v{const l=a.bits;let c,d,h,u,p,f,m=0,g=0,_=0,y=0,b=0,v=0,E=0,w=0,T=0,x=0,A=null,R=0;const S=new Uint16Array(16),I=new Uint16Array(16);let O,N,k,C=null,L=0;for(m=0;m=1&&0===S[y];y--);if(b>y&&(b=y),0===y)return s[r++]=20971520,s[r++]=20971520,a.bits=1,0;for(_=1;_0&&(0===t||1!==y))return-1;for(I[1]=0,m=1;m852||2===t&&T>592)return 1;for(;;){O=m-E,o[g]f?(N=C[L+o[g]],k=A[R+o[g]]):(N=96,k=0),c=1>E)+d]=O>=1;if(0!==c?(x&=c-1,x+=c):x=0,g++,0==--S[m]){if(m===y)break;m=e[n+o[g]]}if(m>b&&(x&u)!==h){for(0===E&&(E=b),p+=_,v=m-E,w=1852||2===t&&T>592)return 1;h=x&u,s[h]=b(t>>>24&255)+(t>>>8&65280)+((65280&t){if(!t||!t.state)return ai;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,si},mi=t=>{if(!t||!t.state)return ai;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,fi(t)},gi=(t,e)=>{let n;if(!t||!t.state)return ai;const i=t.state;return e>4),e15)?ai:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,mi(t))},_i=(t,e)=>{if(!t)return ai;const n=new pi;t.state=n,n.window=null;const i=gi(t,e);return i!==si&&(t.state=null),i};let yi,bi,vi=!0;const Ei=t=>{if(vi){yi=new Int32Array(512),bi=new Int32Array(32);let e=0;for(;e{let s;const r=t.state;return null===r.window&&(r.wsize=1=r.wsize?(r.window.set(e.subarray(n-r.wsize,n),0),r.wnext=0,r.whave=r.wsize):(s=r.wsize-r.wnext,s>i&&(s=i),r.window.set(e.subarray(n-i,n-i+s),r.wnext),(i-=s)?(r.window.set(e.subarray(n-i,n),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=s,r.wnext===r.wsize&&(r.wnext=0),r.whave{let n,i,s,r,o,a,l,c,d,h,u,p,f,m,g,_,y,b,v,E,w,T,x=0;const A=new Uint8Array(4);let R,S;const I=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return ai;n=t.state,12===n.mode&&(n.mode=13),o=t.next_out,s=t.output,l=t.avail_out,r=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,h=a,u=l,T=si;t:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;d>>8&255,n.check=Ne(n.check,A,2,0),c=0,d=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)>8))%31){t.msg="incorrect header check",n.mode=30;break}if((15&c)!==hi){t.msg="unknown compression method",n.mode=30;break}if(c>>>=4,d-=4,w=8+(15&c),0===n.wbits)n.wbits=w;else if(w>n.wbits){t.msg="invalid window size",n.mode=30;break}n.dmax=1>8&1),512&n.flags&&(A[0]=255&c,A[1]=c>>>8&255,n.check=Ne(n.check,A,2,0)),c=0,d=0,n.mode=3;case 3:for(;d>>8&255,A[2]=c>>>16&255,A[3]=c>>>24&255,n.check=Ne(n.check,A,4,0)),c=0,d=0,n.mode=4;case 4:for(;d>8),512&n.flags&&(A[0]=255&c,A[1]=c>>>8&255,n.check=Ne(n.check,A,2,0)),c=0,d=0,n.mode=5;case 5:if(1024&n.flags){for(;d>>8&255,n.check=Ne(n.check,A,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p=n.length,p>a&&(p=a),p&&(n.head&&(w=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(r,r+p),w)),512&n.flags&&(n.check=Ne(n.check,i,p,r)),a-=p,r+=p,n.length-=p),n.length))break t;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===a)break t;p=0;do{w=i[r+p++],n.head&&w&&n.length>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=12;break;case 10:for(;d>>=7&d,d-=7&d,n.mode=27;break}for(;d>>=1,d-=1,3&c){case 0:n.mode=14;break;case 1:if(Ei(n),n.mode=20,e===ii){c>>>=2,d-=2;break t}break;case 2:n.mode=17;break;case 3:t.msg="invalid block type",n.mode=30}c>>>=2,d-=2;break;case 14:for(c>>>=7&d,d-=7&d;d>>16^65535)){t.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&c,c=0,d=0,n.mode=15,e===ii)break t;case 15:n.mode=16;case 16:if(p=n.length,p){if(p>a&&(p=a),p>l&&(p=l),0===p)break t;s.set(i.subarray(r,r+p),o),a-=p,r+=p,l-=p,o+=p,n.length-=p;break}n.mode=12;break;case 17:for(;d>>=5,d-=5,n.ndist=1+(31&c),c>>>=5,d-=5,n.ncode=4+(15&c),c>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have>>=3,d-=3}for(;n.have>>24,_=x>>>16&255,y=65535&x,!(g>>=g,d-=g,n.lens[n.have++]=y;else{if(16===y){for(S=g+2;d>>=g,d-=g,0===n.have){t.msg="invalid bit length repeat",n.mode=30;break}w=n.lens[n.have-1],p=3+(3&c),c>>>=2,d-=2}else if(17===y){for(S=g+3;d>>=g,d-=g,w=0,p=3+(7&c),c>>>=3,d-=3}else{for(S=g+7;d>>=g,d-=g,w=0,p=11+(127&c),c>>>=7,d-=7}if(n.have+p>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=30;break}for(;p--;)n.lens[n.have++]=w}}if(30===n.mode)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,R={bits:n.lenbits},T=ti(1,n.lens,0,n.nlen,n.lencode,0,n.work,R),n.lenbits=R.bits,T){t.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,R={bits:n.distbits},T=ti(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,R),n.distbits=R.bits,T){t.msg="invalid distances set",n.mode=30;break}if(n.mode=20,e===ii)break t;case 20:n.mode=21;case 21:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=r,t.avail_in=a,n.hold=c,n.bits=d,Kn(t,u),o=t.next_out,s=t.output,l=t.avail_out,r=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;x=n.lencode[c&(1>>24,_=x>>>16&255,y=65535&x,!(g>b)],g=x>>>24,_=x>>>16&255,y=65535&x,!(b+g>>=b,d-=b,n.back+=b}if(c>>>=g,d-=g,n.back+=g,n.length=y,0===_){n.mode=26;break}if(32&_){n.back=-1,n.mode=12;break}if(64&_){t.msg="invalid literal/length code",n.mode=30;break}n.extra=15&_,n.mode=22;case 22:if(n.extra){for(S=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;x=n.distcode[c&(1>>24,_=x>>>16&255,y=65535&x,!(g>b)],g=x>>>24,_=x>>>16&255,y=65535&x,!(b+g>>=b,d-=b,n.back+=b}if(c>>>=g,d-=g,n.back+=g,64&_){t.msg="invalid distance code",n.mode=30;break}n.offset=y,n.extra=15&_,n.mode=24;case 24:if(n.extra){for(S=n.extra;d>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===l)break t;if(p=u-l,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=30;break}p>n.wnext?(p-=n.wnext,f=n.wsize-p):f=n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=s,f=o-n.offset,p=n.length;p>l&&(p=l),l-=p,n.length-=p;do{s[o++]=m[f++]}while(--p);0===n.length&&(n.mode=21);break;case 26:if(0===l)break t;s[o++]=n.length,l--,n.mode=21;break;case 27:if(n.wrap){for(;d{if(!t||!t.state)return ai;let e=t.state;return e.window&&(e.window=null),t.state=null,si},Si=(t,e)=>{if(!t||!t.state)return ai;const n=t.state;return 0==(2&n.wrap)?ai:(n.head=e,e.done=!1,si)},Ii=(t,e)=>{const n=e.length;let i,s,r;return t&&t.state?(i=t.state,0!==i.wrap&&11!==i.mode?ai:11===i.mode&&(s=1,s=Ie(s,e,n,0),s!==i.check)?li:(r=wi(t,e,n,n),r?(i.mode=31,ci):(i.havedict=1,si))):ai},Oi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Ni=Object.prototype.toString,{Z_NO_FLUSH:ki,Z_FINISH:Ci,Z_OK:Li,Z_STREAM_END:Di,Z_NEED_DICT:Pi,Z_STREAM_ERROR:Mi,Z_DATA_ERROR:Ui,Z_MEM_ERROR:Fi}=Ce;function Bi(t){this.options=In({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits=0&&e.windowBits15&&e.windowBits0&&r===Di&&n.state.wrap>0&&0!==t[n.next_in];)Ti(n),r=Ai(n,o);switch(r){case Mi:case Ui:case Pi:case Fi:return this.onEnd(r),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||r===Di))if("string"===this.options.to){let t=Dn(n.output,n.next_out),e=n.next_out-t,s=Ln(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(s)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(r!==Li||0!==a){if(r===Di)return r=Ri(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Bi.prototype.onData=function(t){this.chunks.push(t)},Bi.prototype.onEnd=function(t){t===Li&&(this.result="string"===this.options.to?this.chunks.join(""):On(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Hi={Inflate:Bi,inflate:ji,inflateRaw:function(t,e){return(e=e||{}).raw=!0,ji(t,e)},ungzip:ji,constants:Ce};const{Deflate:zi,deflate:Vi,deflateRaw:Gi,gzip:Wi}=Yn,{Inflate:Xi,inflate:Zi,inflateRaw:Yi,ungzip:Ki}=Hi;var qi={Deflate:zi,deflate:Vi,deflateRaw:Gi,gzip:Wi,Inflate:Xi,inflate:Zi,inflateRaw:Yi,ungzip:Ki,constants:Ce};class $i{constructor(t){this.defaultOptions={ai:"$",si:","},this.keysMap=new Map,this.indexMap=new Map;let e=0,n=1;this.options=this.defaultOptions,"Object"===Object.prototype.toString.call(t[0]).slice(8,14)&&(this.options={...this.defaultOptions,...t[0]},e++,n++),this.result=this.convert2Json(t[e],t[n])}convert2Json(t,e){if(!(t&&Array.isArray(t)&&e&&Array.isArray(e)))throw new Error("Params is not valid");const n=t.slice();for(t.forEach(((t,e)=>{n[e].i=e;const i=t.join(this.options.si);this.keysMap.set(i,e),this.indexMap.set(e,i)}));n.length;){const t=n.shift(),e=t.i,i=t.join(this.options.si);for(const[e,n]of t.entries())if("number"==typeof n){const i=this.indexMap.get(n);t[e]=i.split(this.options.si)}const s=t.flat().join(this.options.si);i!==s&&(this.keysMap.delete(i),this.keysMap.set(s,e),this.indexMap.set(e,s))}return this.convertObj(e)}convertObj(t){if(Array.isArray(t)){if(t[0]===this.options.ai){const e=t.slice(1);return this.convertArray(e)}if(!t.length)return{};const e=this.indexMap.get(t[0]),n={},i=e.split(this.options.si),s=t.slice(1);return i.forEach(((t,e)=>{const i=s[e];n[t]=Array.isArray(i)?this.convertObj(i):i})),n}return t}convertArray(t){const e=[];return t.forEach((t=>{e.push(this.convertObj(t))})),e}}class Ji{constructor(t,e){if(this.defaultOptions={arrayIdentifier:"$",separatorIdentifier:","},this.keys=[],this.values=[],this.keyMap=new Map,this.indexMap=new Map,this.getLastKeyInMap=()=>{const t=this.keyMap;return Array.from(t)[t.size-1][0]},"object"!=typeof t||null===t)throw new Error("The params json is not a object");const{arrayIdentifier:n,separatorIdentifier:i}=e||{};this.json=t,this.arrayIdentifier=n||this.defaultOptions.arrayIdentifier,this.separatorIdentifier=i||this.defaultOptions.separatorIdentifier,this.result=this.getResult()}getResult(){const t=this.json;this.values=Array.isArray(t)?[...this.deepConvertArray(t)]:this.deepConvertObj(t);const e={ai:this.arrayIdentifier===this.defaultOptions.arrayIdentifier?void 0:this.arrayIdentifier,si:this.separatorIdentifier===this.defaultOptions.separatorIdentifier?void 0:this.separatorIdentifier};return Object.keys(e).forEach((t=>{e[t]||delete e[t]})),Object.keys(e).length?[e,this.keys,this.values]:[this.keys,this.values]}deepConvertArray(t,e=!0){const n=[e?this.arrayIdentifier:""].filter(Boolean);return t.forEach((t=>{const e=typeof t;Array.isArray(t)?n.push(this.deepConvertArray(t)):n.push(null!==t&&"object"===e?this.deepConvertObj(t):t)})),n}deepConvertObj(t){const e=this.separatorIdentifier,n=[],i=Object.getOwnPropertyNames(t).sort(),s=i.join(e),r="";if(""===s&&!i.length)return n;let o=i.map((e=>t[e]));if(this.keys.length){const a=this.getIndexByKey(s);if(void 0!==a)return o=s.split(e).map((e=>t[e])),n.push(a,...this.deepConvertArray(o,!1)),n;const l=this.getLastKeyInMap();for(const[t,o]of this.keyMap){const a=s.split(e).lengtht.split(e).map((t=>"")).join(e),p=u(c),f=u(d);if(~p.indexOf(f)){const t=p.replace(f,r),i=n=>t.split(e).map((t=>t===r?n:t.substring(2,t.length-1)));if(a){const t=this.saveKey(d),s=i(t),r=this.getIndexByKey(c);this.keys.push(d.split(e)),this.keys[r]=s,n.unshift(t)}else{const t=i(o);this.saveKey(c),this.keys.push(t),n.unshift(h)}break}if(l===t){this.saveKey(s),this.keys.push([...i]),n.unshift(h);break}}}else n.unshift(this.saveKey(s)),this.keys.push(i);return n.push(...this.deepConvertArray(o,!1)),n}saveKey(t,e=this.keys.length){return this.keyMap.set(t,e),this.indexMap.set(e,t),e}getIndexByKey(t){return this.keyMap.get(t)}}const Qi={startTime:0,endTime:0,duration:0,packsInfo:[]};var ts;!function(t){t.RESET="RESET",t.PROGRESS="PROGRESS"}(ts||(ts={}));const es={speed:0,options:{}};var ns;function is(e){const n=[],i=[];return e.forEach(((s,r)=>{r&&s.type===t.RecordType.HEAD&&(n.push(i.slice()),i.length=0),i.push(s),e.length-1===r&&n.push(i)})),n}!function(t){t.RESET="RESET",t.SPEED="SPEED",t.OPTIONS="OPTIONS"}(ns||(ns={}));const ss={records:[],packs:[],currentData:{}};var rs;!function(t){t.RESET="RESET",t.UPDATE_DATA="UPDATE_DATA",t.APPEND_RECORDS="APPEND_RECORDS"}(rs||(rs={}));const os=function(t){let e=t({});const n=[];function i(i){e=t(e,i),n.forEach((t=>{t(e)}))}return{unsubscribe:function(){n.length=0,i({type:"RESET",data:{}})},subscribe:function(t){n.push(t)},dispatch:i,getState:function(){return e}}}(function(t){const e=Object.keys(t);return function(n,i){const s={};for(let r=0;r1&&-1!==e.indexOf("Macintosh")&&-1!==e.indexOf("Safari")&&(n=!0),n}as.isMobile=hs,as.default=ls;function us(e){const n={head:{},snapshot:{},records:[],audio:{src:"",pcmStrList:[],wavStrList:[],subtitles:[],opts:{}},videos:[]},i=new Map;if(e.forEach(((s,r)=>{const o=e[r+1];if(s.type===t.RecordType.HEAD)o&&!o.data.frameId&&(n.head=s);else if(s.type===t.RecordType.SNAPSHOT)s.data.frameId?n.records.push(s):n&&(n.snapshot=s);else{switch(s.type){case t.RecordType.AUDIO:const{data:e}=s;if(e.src){const t=e;n.audio.src=t.src,n.audio.subtitles=t.subtitles}else!function(t){return"pcm"===t.type&&"base64"===t.encode}(e)?!function(t){return"wav"===t.type&&"base64"===t.encode}(e)?n.audio.opts=e.data:n.audio.wavStrList.push(...e.data):n.audio.pcmStrList.push(...e.data);n.records.push(s);break;case t.RecordType.VIDEO:const{data:r,time:o}=s,{id:a,dataStr:l}=r;if(!l)break;const c=i.get(a);if(c)c.bufferStrList.push(l),c.endTime=o;else{i.set(a,{id:a,startTime:o,endTime:o,bufferStrList:[l]})}n.records.push(s)}n&&n.records.push(s)}})),i.size){const t=Array.from(i.entries()).map((([,t])=>{const{bufferStrList:e,startTime:n,endTime:i,id:s}=t,r=e.map((t=>{const e=$(t);return new Blob([e],{type:"video/webm;codecs=vp9"})})),o=new Blob(r,{type:"video/webm"});return{id:s,src:window.URL.createObjectURL(o),startTime:n,endTime:i}}));n.videos.push(...t)}return n}function ps(){const t=window.G_REPLAY_STR_RECORDS;if(!t)return null;return function(t){return function(t){const{result:e}=new $i(t);return e}(JSON.parse(qi.ungzip(t,{to:"string"})))}(function(t){const e=t.split(""),n=new Uint8Array(e.length);for(let t=0;t=256?i-256:i}return n}(t))}function fs(){return n(this,void 0,void 0,(function*(){const t=yield et.readAll();return t&&t.length?t:null}))}function ms(t){return[...(new DOMParser).parseFromString(t,"text/html").body.children]}function gs(t,e){t.open();const n=e.doctype;t.write(``)}function _s(t,e){const n=ht(e.vNode);if(n){const i=n.querySelector("head");if(i){const t=ms("

\n \n
")[0].firstElementChild;i.appendChild(t)}const s=t.documentElement;n.scrollLeft=e.scrollLeft,n.scrollTop=e.scrollTop,t.replaceChild(n,s)}}const ys=(bs=os,t=>{let e;return n=>{bs.subscribe((()=>{const i=t(bs.getState());((t,e)=>{if(t===e)return!0;if("object"!=typeof t||null==t||"object"!=typeof e||null==e)return!1;const n=Object.keys(t),i=Object.keys(e);if(n.length!==i.length)return!1;for(let i=0;ifunction(e,n,i){const s=i.value;i.value=function(e){ys(t)((t=>{s.call(this,t),e&&e(t)}))}};class Es{constructor(t,e=[]){this.ratio=2,this.target=t,this.points=e;const n=this.target.offsetHeight*this.ratio;this.targetWidth=t.width=this.target.offsetWidth*this.ratio,this.targetHeight=t.height=n,this.context=t.getContext("2d")}radiusRect(t,e,n,i,s,r="#fff"){const o=Math.min(n,i);s>o/2&&(s=o/2),this.context.fillStyle=r,this.context.strokeStyle=r,this.context.beginPath(),this.context.moveTo(t+s,e),this.context.arcTo(t+n,e,t+n,e+i,s),this.context.arcTo(t+n,e+i,t,e+i,s),this.context.arcTo(t,e+i,t,e,s),this.context.arcTo(t,e,t+n,e,s),this.context.closePath(),this.context.stroke(),this.context.fill()}}class ws extends Es{constructor(t,e){super(t,e),this.draw()}draw(){const t=this.points,e=t.length,n=this.targetWidth/(2*e),i=this.targetHeight,s=Math.max.apply(null,t.map((t=>t.step)));for(let r=0;r0){const t=o.parentElement;[...this.children].forEach((e=>null==t?void 0:t.insertBefore(e,null))),null==t||t.removeChild(o)}(null==n?void 0:n.isShadow)?this.attachShadow({mode:"open"}).append(r):null===(s=this.parentElement)||void 0===s||s.replaceChild(r,this),i.prototype.parent=r.parentElement}})}}const As=function(t,...e){let n="";return t.forEach(((t,i)=>{n+=t+(e[i]||"")})),n};const Rs="const loadingNode = document.createElement('div')\nloadingNode.className = 'pacman-box';\nloadingNode.innerHTML = '
'\nloadingNode.setAttribute('style', 'text-align: center;vertical-align: middle;line-height: 100vh;')\ndocument.body.insertBefore(loadingNode, document.body.firstChild);window.addEventListener('DOMContentLoaded', () => loadingNode.parentNode.removeChild(loadingNode))";const Ss=new class{constructor(){const t=document.createElement("iframe");t.style.display="none",t.style.visibility="hidden",document.body.appendChild(t),this.safeWindow=t.contentWindow}getObjByPath(t,e){if(!t)return e;const n=this.getMethodAtPath(t);let i=e;return n.forEach((t=>{i=i[t]})),i}getMethodAtPath(t){return t.split(".")}recoverMethod(t){const e=this.getObjByPath(t,window);if(!this.isNative(e)){const e=this.getObjByPath(t,this.safeWindow);this.recover(t,e)}}recover(t,e){const n=this.getMethodAtPath(t),[i,...s]=n.reverse();this.getObjByPath(s.reverse().join("."),window)[i]=e}isNative(t){const e=Object.prototype.toString,n=Function.prototype.toString,i=RegExp("^"+String(e).replace(/[.*+?^${}()|[\]\/\\]/g,"\\$&").replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),s=typeof t;return"function"==s?i.test(n.call(t)):t&&"object"==s&&/^\[object .+?Constructor\]$/.test(e.call(t))||!1}};["MutationObserver","console.warn","console.error","console.log"].forEach(Ss.recoverMethod.bind(Ss));function Is(t){return n(this,void 0,void 0,(function*(){["HTMLElement.prototype.appendChild"].forEach(Ss.recoverMethod.bind(Ss));const e=(yield Os(t)).documentElement.outerHTML;!function(t,e){!function(t,e){const n=document.createElement("a");n.download=e,"string"==typeof t?(n.href=t,n.click()):(n.href=URL.createObjectURL(t),n.click(),URL.revokeObjectURL(n.href))}(new Blob([e],{type:"text/html"}),`${t}.html`)}(`${t.exportName||"TimeCat"}-${T()}`,e)}))}function Os(t){return n(this,void 0,void 0,(function*(){const e=(new DOMParser).parseFromString('\n\n\n \n \n \n TimeCat\n\n\n\n\n',"text/html");return yield function(t){return n(this,void 0,void 0,(function*(){Ns(t,[{src:Rs}])}))}(e),yield function(t,e){return n(this,void 0,void 0,(function*(){const n=e.records||ps()||function(){const t=os.getState().replayData.records;return t.length?t:null}()||(yield fs());if(!n)return E("Records not found");const i=function(t){let e="";for(let n=0;n"timecat-init"===t.name))||r.push({name:"timecat-init",src:`new TimeCat.Player(${JSON.stringify(s)})`}),yield Ns(t,r)}))}(e,t),e}))}function Ns(t,e){return n(this,void 0,void 0,(function*(){if(e)for(const n of e){const{src:e,name:i}=n;let s=e;const r=document.createElement("script");i&&(r.id=i);/^((chrome-extension|https?):)?\/\/.+/.test(e)&&(s=yield W(e)),r.text=s,t.body.appendChild(r)}}))}function ks(e){const n=[],i=[];if(e.forEach((e=>{if(e.type===t.RecordType.AUDIO){if("pcm"===e.data.type)return void n.push(e)}i.push(e)})),n.length){const e=q(function(t){const e=[];t.forEach((t=>{const{data:n}=t.data;e.push(...n)}));const n=[];for(let t=0;t{if(t.target&&"button"===t.target.type){const e=Number(t.target.getAttribute("speed"));this.dispatchPlay(e)}};this.controller.addEventListener("click",t,!1),this.options.destroyStore.add((()=>{this.controller.removeEventListener("click",t,!1)})),this.watchPlayerSpeed(),this.detectWindowIsActive()}createFastForwards(t){if(t=Array.from(new Set([1].concat(t)))){const e=t.reduce(((t,e)=>t+As``),"");this.controller.append(...ms(e))}}dispatchPlay(t=0){os.dispatch({type:ns.SPEED,data:{speed:t}})}detectWindowIsActive(){const t=()=>{"hidden"===document.visibilityState&&this.dispatchPlay(0)};document.addEventListener("visibilitychange",t,!1),this.options.destroyStore.add((()=>{document.removeEventListener("visibilitychange",t,!1)}))}paly(t){0!==t?(this.playOrPauseBtn.innerText="〓",this.playOrPauseBtn.setAttribute("style","letter-spacing: 1px;font-weight: bold;"),this.playOrPauseBtn.removeAttribute("speed")):(this.playOrPauseBtn.innerText="▲",this.playOrPauseBtn.removeAttribute("style"),this.playOrPauseBtn.setAttribute("speed","1"))}setSpeed(t){const e=this.c.container.querySelectorAll(".speed");[...e].forEach((t=>{t.removeAttribute("disabled")}));const n=function(t){return[...e].findIndex((e=>e.getAttribute("speed")===t.toString()))}(t);n>-1&&e[n].setAttribute("disabled","")}};e([vs((t=>({speed:t.player.speed})))],Ls.prototype,"watchPlayerSpeed",null),Ls=e([xs("player-keyboard",As`
`)],Ls);const Ds=[WebGLActiveInfo,WebGLBuffer,WebGLFramebuffer,WebGLProgram,WebGLRenderbuffer,WebGLShader,WebGLShaderPrecisionFormat,WebGLTexture,WebGLUniformLocation],Ps=Object.create(null),Ms=t=>Ps[t]||(Ps[t]=[]);function Us(t){return n(this,void 0,void 0,(function*(){yield R();const{id:e,args:n}=t,i=it.getNode(e);if(!i)return;if(i.contextType){if("2d"===i.contextType)return}else i.contextType="webgl";const s=i.getContext("webgl",{preserveDrawingBuffer:!0});s&&n.forEach((({name:t,args:e})=>{const n=s[t];if("function"==typeof n){e=e.map((t=>{if("string"==typeof t){if(t.startsWith("$f32arr")){const e=t.slice(7).split(",");return new Float32Array(e)}if(t.startsWith("$arr")){return new Array(...t.slice(4).split(",")).map((t=>function(t){return!isNaN(parseFloat(t))&&isFinite(parseFloat(t))}(t)?+t:t))}if(t.startsWith("$")){const[e,n]=t.slice(1).split("@");if("src"===e){const t=document.createElement("img");return t.setAttribute(e,n),t}return Ms(e)[+n]}}return t}));const i=n.apply(s,e);if(null==i?void 0:i.constructor){const e=i.constructor.name;if(Ds.some((t=>t.name===e))||"getExtension"===t){const t=Ms(e);i&&Array.isArray(t)&&(~t.indexOf(i)||t.push(i))}}}}))}))}function Fs(t){const{family:e,source:n}=t,i=new Uint8Array(n.length);for(let t=0;t3*a?"auto":"smooth"};try{o.scroll(l)}catch(t){"HTML"===o.nodeName?null===(e=o.ownerDocument.defaultView)||void 0===e||e.scroll(l):(o.scrollLeft=i,o.scrollTop=n)}}function js(t){const{width:e,height:n,id:i}=t;let s;i?(s=it.getNode(i),s.style.width=e+"px",s.style.height=n+"px"):(s=this.c.sandBoxDoc.body,this.c.resize({setWidth:e,setHeight:n}))}function Hs(t){const{x:e,y:n,id:i,type:s}=t;let o=0,a=0;if(i){const t=it.getNode(i);let e={};t&&t.getBoundingClientRect&&(e=t.getBoundingClientRect());const{left:n,top:s}=e;o=n,a=s}s===r.MOVE?this.pointer.move(e+o,n+a):s===r.CLICK&&this.pointer.click(e+o,n+a)}function zs(t,e){const{parentId:n,nextId:i,node:s}=t,r=it.getNode(n);if(!r||!j(r))return!0;{let t=null;if(i){if(e.has(i))return!0;if(t=(t=>t?it.getNode(t):null)(i),!t)return!0;if(!r.contains(t))return!0}const n=s;let o;"number"==typeof s?(o=it.getNode(s),e.has(s)&&e.delete(s)):o=S(n)?ht(n):function(t){const{type:e,value:n,id:i}=t;let s;switch(e){case Node.TEXT_NODE:s=document.createTextNode(n);break;case Node.COMMENT_NODE:s=document.createComment(n)}return it.updateNode(i,s),s}(n),o&&r.insertBefore(o,t)}}function Vs(e,i){return n(this,void 0,void 0,(function*(){const{isJumping:r,speed:o}=i||{},a=r?0:200,{type:l,data:c}=e,d=()=>a?R(a):Promise.resolve();switch(l){case t.RecordType.SNAPSHOT:!function(t){n(this,void 0,void 0,(function*(){const e=t,{frameId:n}=e;if(n){const t=it.getNode(n);if(t){const n=t.getAttribute("src");n&&(dt(t,"disabled-src",n),dt(t,"src",null));const i=t.contentDocument;gs(i,e),_s(i,e)}}}))}(c);break;case t.RecordType.SCROLL:Bs.call(this,c);break;case t.RecordType.WINDOW:js.call(this,c);break;case t.RecordType.MOUSE:Hs.call(this,c);break;case t.RecordType.DOM:r||1!==o||(yield d()),function(t){const{addedNodes:e,movedNodes:n,removedNodes:i,attrs:s,texts:r}=t;i&&i.forEach((t=>{const{parentId:e,id:n}=t,i=it.getNode(e),s=it.getNode(n);s&&i&&i.contains(s)&&i.removeChild(s)}));const o=new Set,a=n&&n.slice()||[];a.forEach((t=>{t.nextId&&a.some((e=>e.id===t.nextId))&&o.add(t.nextId)}));const l=a.map((t=>{const{id:e,parentId:n,nextId:i}=t;return{node:e,parentId:n,nextId:i}})).concat(e&&e.slice()||[]);if(l){const t=l.length,e=t>0?(t*t+t)/2:0;let n=0;for(;l.length;){const t=l.shift();t&&zs(t,o)&&n++{const{id:e,key:n,value:i}=t,s=it.getNode(e);s&&dt(s,n,i)})),r&&r.forEach((t=>{const{id:e,value:n,parentId:i}=t,s=it.getNode(i),r=it.getNode(e);if(s&&r){if(V(r))return void(r.textContent=n);s.innerText=n}}))}(c);break;case t.RecordType.FORM_EL:r||1!==o||(yield d()),function(t,e){const{isJumping:n}=e||{},{id:i,key:r,type:o,value:a,patches:l}=t,c=it.getNode(i),{mode:d}=os.getState().player.options;if(c)if(o===s.INPUT||o===s.CHANGE)if(l&&l.length){const t=(h=c.value,l.forEach((t=>{const{type:e,value:n,len:i}=t;switch(e){case"add":h=h.substring(0,t.index)+n+h.substring(t.index);break;case"rm":h=h.substring(0,t.index)+h.substring(t.index+i)}})),h);c.value=t}else r&&(c[r]=a);else o===s.FOCUS?"live"!==d&&!n&&c.focus&&c.focus({preventScroll:!0}):o===s.BLUR?"live"!==d&&!n&&c.blur&&c.blur():o===s.PROP&&r&&(c[r]=a);var h}(c,{isJumping:r});break;case t.RecordType.LOCATION:!function(t){n(this,void 0,void 0,(function*(){const{path:e,hash:n,href:i,contextNodeId:s}=t,r=it.getNode(s);if(r){const t=r.ownerDocument.defaultView;t.G_REPLAY_LOCATION=Object.assign(Object.assign({},t.G_REPLAY_LOCATION),{path:e,hash:n,href:i})}}))}(c);break;case t.RecordType.CANVAS_SNAPSHOT:!function(t){const{src:e,id:n}=t,i=it.getNode(n);if(!i||"HTMLCanvasElement"!==i.constructor.name)return;if(i.contextType){if("webgl"===i.contextType||"experimental-webgl"===i.contextType)return}else i.contextType="2d";const s=i.getContext("2d");if(s&&e){const t=new Image;t.src=e,t.onload=function(){s.drawImage(this,0,0)}}}(c);break;case t.RecordType.CANVAS:r||1!==o||(yield d()),function(t){const e=t,{src:n,status:i,id:s,strokes:r}=e,o=it.getNode(s);if(!o||"HTMLCanvasElement"!==o.constructor.name)return;if(o.contextType){if("webgl"===o.contextType||"experimental-webgl"===o.contextType)return}else o.contextType="2d";const a=o.getContext("2d");if(a)if(n){const t=new Image;t.src=n,t.onload=function(){a.drawImage(this,0,0)}}else if(i)Object.keys(i).forEach((t=>{a[t]=i[t]}));else for(const t of r){const{name:e,args:n}=t,i="number"==typeof e?U[e]:e;if(Array.isArray(n)){const t=n.slice();if("createPattern"===i)t[0]=it.getNode(t[0]);else if("drawImage"===i){const e=new Image,n=t[0];if(n.length0?(this.play(),0===n&&Yt.emit(Cs.PLAY)):this.pause()}}watchProgress(){this.recalculateProgress(),this.viewsLength=os.getState().replayData.packs.length}watcherProgressJump(){Yt.on(Cs.JUMP,(t=>n(this,void 0,void 0,(function*(){return this.jump(t,!0)}))))}init(){return n(this,void 0,void 0,(function*(){this.audioNode=new Audio,this.calcFrames(),this.viewsLength=os.getState().replayData.packs.length,this.initViewState(),this.setViewState(),this.records.lengthwindow.removeEventListener("record-data",this.streamHandle.bind(this))))):(this.watchProgress(),this.watchPlayerSpeed(),this.watcherProgressJump()),Yt.on(Cs.RESIZE,(()=>n(this,void 0,void 0,(function*(){yield R(500),this.recalculateProgress()})))),Yt.on(Cs.PROGRESS,(t=>{this.progress.setProgressPosition(t/(this.frames.length-1))}))}))}initAudio(){if(this.audioData)if(this.audioData.src)this.audioBlobUrl=location.href.split("/").slice(0,-1).join("/")+"/"+this.audioData.src;else{const{wavStrList:t,pcmStrList:e}=this.audioData;let n;const i=[];if(t.length?(n="wav",i.push(...t)):e.length&&(n="pcm",i.push(...e)),!n)return;const s=[];for(let t=0;t{const{src:e,id:n}=t,i=it.getNode(n);if(i){const t=i;t.muted=!0,t.autoplay=t.loop=t.controls=!1,t.src=e}}))}streamHandle(t){const e=t.detail;if(A(e))return os.getState().replayData.currentData.snapshot=e,void this.setViewState();this.execFrame(e)}initViewState(){const{currentData:t}=os.getState().replayData,{records:e,audio:n,videos:i,head:s}=t;this.records=this.processing(e),this.audioData=n,this.videos=i;const{userAgent:r}=(null==s?void 0:s.data)||{};var o;(o=r)&&as({ua:o})&&this.pointer.hidePointer(),this.records.length&&(this.subtitlesIndex=0,this.broadcaster.cleanText(),this.curViewStartTime=s&&s.time||e[0].time,this.curViewEndTime=e.slice(-1)[0].time,this.preViewsDurationTime=0,this.curViewDiffTime=0,this.viewIndex=0)}setViewState(){this.c.setViewState(),this.initAudio(),this.mountVideos()}jump(t,e=!1){return n(this,void 0,void 0,(function*(){let n;this.isJumping=!0,this.shouldWaitForSync=!0;const{speed:i}=os.getState().player,{index:s,time:r,percent:o}=t;e&&(this.pause(!1),n=ms('
')[0],this.c.container.appendChild(n),yield R(100));const a=this.getNextReplayData(s);if(!a)return;if(this.initViewState(),this.viewIndex!==s||this.startTime>=r){const[{packsInfo:t},{packs:e}]=[os.getState().progress,os.getState().replayData],n=t[s].diffTime;this.curViewEndTime=e[s].slice(-1)[0].time,this.curViewDiffTime=n,this.preViewsDurationTime=t.slice(0,s).reduce(((t,e)=>t+e.duration),0),this.viewIndex=s,this.records=e[s]}const l=1+this.frames.findIndex(((t,e)=>{if(r>=t&&rthis.shouldWaitForSync=!1),100)}))}getNextReplayData(t){const{packs:e}=os.getState().replayData,n=e[t];if(n){const t=us(n);return os.dispatch({type:rs.UPDATE_DATA,data:{currentData:t}}),t}return null}loopFramesByTime(t,e=!1){let n=this.frames[this.frameIndex];for(;n&&t>=n;)e||Yt.emit(Cs.PROGRESS,this.frameIndex,this.frames.length-1),this.frameIndex++,this.renderEachFrame(),n=this.frames[this.frameIndex];return n}play(){0===this.frameIndex&&(this.progress.moveThumb(),this.isFirstTimePlay?this.progress.drawHeatPoints():(this.getNextReplayData(0),this.initViewState(),this.setViewState())),this.playAudio(),this.isFirstTimePlay=!1,this.RAF&&this.RAF.requestID&&this.RAF.stop(),this.RAF=new J(function(t,e){return n(this,void 0,void 0,(function*(){const t=w()-this.initTime;if(this.frameIndex>0&&this.frameIndex>=this.frames.length)return void this.stop();const e=this.startTime+t*this.speed;if(this.loopFramesByTime(e)>this.curViewEndTime-this.curViewDiffTime&&this.viewIndexthis.RAF.stop())),this.RAF.start(),this.initTime=w(),this.startTime=this.frames[this.frameIndex]}playAudio(){this.audioData&&(this.audioBlobUrl?this.audioNode&&(this.audioNode.src&&this.audioNode.src===this.audioBlobUrl||(this.audioNode.src=this.audioBlobUrl),this.syncAudioTargetNode(),this.speed>0&&this.audioNode.play()):this.pauseAudio())}syncAudio(){if(!this.audioNode)return;Math.abs(this.elapsedTime-this.preViewsDurationTime/1e3-this.audioNode.currentTime)>(100+this.audioOffset)/1e3&&this.syncAudioTargetNode()}syncAudioTargetNode(){this.audioNode.currentTime=this.elapsedTime-this.preViewsDurationTime/1e3+this.audioOffset/1e3}syncVideos(){const t=this.curViewStartTime,e=t+(1e3*this.elapsedTime-this.preViewsDurationTime);this.videos.forEach((n=>{const{startTime:i,endTime:s,id:r}=n,o=it.getNode(r);if(o)if(e>=i&&e0&&o.play();const e=this.elapsedTime-this.preViewsDurationTime/1e3-(i-t)/1e3;Math.abs(e-o.currentTime)>.1&&(o.currentTime=e)}else o.paused||o.pause()}))}pauseAudio(){this.audioNode&&this.audioNode.pause()}pauseVideos(){this.videos&&this.videos.length&&this.videos.forEach((t=>{const e=it.getNode(t.id);e&&e.pause()}))}renderEachFrame(){let t;for(this.progress.updateTimer(this.frameIndex,this.frameInterval,this.curViewDiffTime);this.recordIndexi/1e3&&(this.broadcaster.cleanText(),this.subtitlesIndexthis.elapsedTime)break;this.subtitlesIndex++}e=t[this.subtitlesIndex].text}this.broadcaster.updateText(e)}}))}pause(t=!0){this.RAF&&this.RAF.stop(),os.dispatch({type:ns.SPEED,data:{speed:0}}),this.pauseAudio(),this.pauseVideos(),t&&Yt.emit(Cs.PAUSE)}stop(){this.speed=0,this.recordIndex=0,this.frameIndex=0,this.elapsedTime=0,this.pause(),this.audioNode.currentTime=0,Yt.emit(Cs.STOP)}execFrame(t){const{isJumping:e,speed:n}=this;Vs.call(this,t,{isJumping:e,speed:n})}calcFrames(t=this.maxFrameInterval){if("live"===this.options.mode)return[];const e=this.frames&&this.frames[this.frameIndex],{duration:n,startTime:i,endTime:s}=os.getState().progress;this.frameInterval=Math.max(20,Math.min(t,n/60/1e3*60-40));const r=this.frameInterval,o=[];let a;for(let t=i;t=e&&(a=o.length-1);o.push(s),a&&(this.frameIndex=a),this.frames=o}calcHeatPointsData(){const t=this.frames;if(!(null==t?void 0:t.length)||!this.options.heatPoints)return[];const e=os.getState(),{packs:n}=e.replayData,{duration:i}=e.progress,s=i/Math.floor(this.progress.slider.offsetWidth/7);return n.reduce(((t,e)=>{let n=0,i=0,r=!1;const o=e.slice(-1)[0].time;let a=e[0].time;for(;at.time-e.time)),t):[]}recalculateProgress(){this.calcFrames(),this.progress.drawHeatPoints(this.calcHeatPointsData())}processing(t){return this.orderRecords(t)}};e([vs((t=>({speed:t.player.speed})))],Gs.prototype,"watchPlayerSpeed",null),e([vs((t=>({endTime:t.progress.endTime})))],Gs.prototype,"watchProgress",null),Gs=e([xs("timecat-player",As`
`)],Gs);let Ws=class{constructor(t){this.x=0,this.y=0,this.c=t,this.initPointer(),this.togglePointer(!0)}initPointer(){this.pointer=this.c.container.querySelector(".player-pointer")}togglePointer(t=!this.show){this.show=t,this.pointer.firstElementChild.style.display=this.show?"inherit":"none"}hidePointer(){this.togglePointer(this.show=!1)}move(t,e){this.x=t,this.y=e,this.pointer.style.left=this.x+"px",this.pointer.style.top=this.y+"px"}click(t,e){return n(this,void 0,void 0,(function*(){this.move(t,e),this.pointer.hasAttribute("active")||(yield R(200),dt(this.pointer,"active",""),yield R(400),dt(this.pointer,"active",null))}))}};Ws=e([xs("player-pointer",As`
pointer
`)],Ws);let Xs=class{constructor(t,e){this.heatPoints=[],this.findProgressByPosition=(()=>{const t=new Map;return function(e){const n=t.get(e);if(n)return n;const{startTime:i,duration:s,packsInfo:r}=os.getState().progress,{packs:o}=os.getState().replayData,a=i+s*e,l=r.findIndex((t=>{const{startTime:e,endTime:n,diffTime:i}=t;if(e-i=a)return!0}));if(void 0!==l){const n=o[l],i=r[l],{startTime:s,diffTime:c}=i,d=r.reduce(((t,e)=>t+e.duration),0),h=r.slice(0,l).reduce(((t,e)=>t+e.duration),0);for(let i=0;i=r.time-c&&afunction(t,e,n){let i=n,s=0;return n=>{t((function(t){s&&clearTimeout(s),s=window.setTimeout((()=>{i!==t&&(n(t),i=t,clearTimeout(s),s=0)}),"number"==typeof e?e:e(t))}))}}((e=>{const n=()=>e("in"),i=()=>e("out");t.addEventListener("mouseover",n,!1),t.addEventListener("mouseout",i,!1),this.options.destroyStore.add((()=>{t.removeEventListener("mouseover",n,!1),t.removeEventListener("mouseout",i,!1)}))}),(t=>"in"===t?200:1e3),"out"),this.options=t,this.c=e,this.progress=e.container.querySelector(".player-progress"),this.progress=e.container.querySelector(".player-progress"),this.timer=e.container.querySelector(".player-timer"),this.currentProgress=this.progress.querySelector(".player-current-progress"),this.slider=this.progress.querySelector(".player-slider-bar"),this.heatBar=this.progress.querySelector(".player-heat-bar"),this.thumb=this.progress.querySelector(".player-thumb"),this.listenElementOnHover(this.parent)((t=>{"in"!==t?this.thumb.removeAttribute("active"):this.thumb.setAttribute("active","")}));const n=t=>{const{left:e,width:n}=this.slider.getBoundingClientRect(),i=+(Math.max(0,Math.min(t.x-e,n))/n).toFixed(3),s=this.findProgressByPosition(i);Yt.emit(Cs.JUMP,s)};this.progress.addEventListener("click",n,!1),this.options.destroyStore.add((()=>{this.progress.removeEventListener("click",n,!1)}))}updateTimer(t,e,n){const i=this.c.options,{timeMode:s}=i,r=(t+1)*e;let o;if("durationTime"===s)o=function(t){tt
00:00
`)],Xs);let Zs=class{constructor(t){this.c=t,this.init()}init(){this.broadcaster=this.c.container.querySelector(".player-broadcaster"),this.floatLayer=this.broadcaster.firstElementChild,this.subtitle=this.floatLayer.firstElementChild}updateText(t){t=t.trim(),this.subtitle.innerText.trim()!==t&&(this.subtitle.innerText=t,this.floatLayer.toggleAttribute("hidden",!t))}cleanText(){this.updateText("")}};Zs=e([xs("player-broadcaster",As`
`)],Zs);let Ys=class{constructor(t,e){this.options=t,this.c=e,this.exportBtn=this.target.querySelector(".player-export"),this.exportBtn.addEventListener("click",this.export),this.fullscreenBtn=this.target.querySelector(".player-fullscreen"),this.fullscreenTarget=this.c.container.parentNode.host.parentElement,this.fullscreenTarget.addEventListener("fullscreenchange",(()=>this.cancelFullScreen())),this.fullscreenBtn.addEventListener("click",(()=>this.setFullScreen())),this.options.destroyStore.add((()=>{this.exportBtn.removeEventListener("click",this.export),this.fullscreenTarget.removeEventListener("fullscreenchange",(()=>this.cancelFullScreen())),this.fullscreenBtn.removeEventListener("click",(()=>this.setFullScreen()))}))}export(){return n(this,void 0,void 0,(function*(){const t=document.querySelector("#timecat"),e=document.querySelector("#timecat-init"),i=[],s=document.querySelectorAll("script");function r(t){return n(this,void 0,void 0,(function*(){if(t)return t.textContent||(yield G(t.src.trim()))||t.src}))}const o=(yield r(t))||Array.from(s).map((t=>t.src)).find((t=>/(timecat)(\.prod)?\.global\.js/.test(t)))||Array.from(s).map((t=>t.textContent)).find((t=>null==t?void 0:t.trim().startsWith("var TimeCat")))||"//cdn.jsdelivr.net/npm/timecatjs/dist/timecat.global.prod.js";i.push({name:"timecat",src:o});const a=(yield r(e))||Array.from(s).map((t=>t.textContent)).find((t=>{if(t)return/new\s(TimeCat\.)?Player/.test(t)}))||"new window.TimeCat.Player({autoplay: true})";i.push({name:"timecat-init",src:a});const l=os.getState().player.options;Is(Object.assign(Object.assign({},l),{scripts:i}))}))}setFullScreen(){this.c.resize({maxScale:100}),this.fullscreenTarget.requestFullscreen().catch((t=>{E(t),function(t){console.log(`%c TimeCat Advice: ${t}`,"color:#0f0;")}("If the Player within the iframe, you should be set the attribute: allowfullscreen")}))}cancelFullScreen(){document.fullscreen||this.c.resize({maxScale:0})}};Ys=e([xs("player-toolbox",As`
`)],Ys);let Ks=class{constructor(t){this.c=t,this.options=t.options,this.options.hidePanel&&(this.target.style.display="none"),this.initComponent()}initComponent(){new Ys(this.options,this.c),this.keyboard=new Ls(this.options,this.c),this.progress=new Xs(this.options,this.c),this.pointer=new Ws(this.c),this.broadcaster=new Zs(this.c),this.player=new Gs(this.options,this.c,this.pointer,this.progress,this.broadcaster)}};Ks=e([xs("player-panel",As`
`)],Ks);let qs=class{constructor(){setTimeout((()=>{}))}};qs=e([xs("player-start-page",As``)],qs);class $s{constructor(t){this.options=t,this.init()}init(){const t=this.options.target,e="string"==typeof t?document.querySelector(t):t;this.target=e,this.initTemplate(),this.initSandbox();const{resize:n}=this.makeItResponsive();this.resize=n,this.initPanel(),setTimeout((()=>Yt.emit(Cs.INIT)))}initPanel(){this.panel=new Ks(this),new qs}initSandbox(){this.sandBox=this.container.querySelector(".player-sandbox"),this.sandBoxDoc=this.sandBox.contentDocument,this.setSmoothScroll(this.sandBox.contentWindow),gs(this.sandBoxDoc,this.getSnapshotRecord()),this.options.disableScrolling&&function(t){const e={37:1,38:1,39:1,40:1};function n(t){t.preventDefault()}function i(t){if(e[t.keyCode])return n(t),!1}let s=!1;try{t.addEventListener("test",(()=>{}),Object.defineProperty({},"passive",{get:function(){s=!0}}))}catch(t){}const r=!!s&&{passive:!1},o="onwheel"in document.createElement("div")?"wheel":"mousewheel";t.addEventListener("DOMMouseScroll",n,!1),t.addEventListener(o,n,r),t.addEventListener("touchmove",n,r),t.addEventListener("keydown",i,!1)}(this.sandBox.contentWindow.document),this.setViewState()}getSnapshotRecord(){return os.getState().replayData.currentData.snapshot.data}setSmoothScroll(t){Xt.polyfill(),t.HTMLElement.prototype.scroll=window.scroll,t.HTMLElement.prototype.scrollTo=window.scrollTo}setViewState(){it.reset();const t=this.getSnapshotRecord(),{pathname:e,hash:n,href:i}=k(t.href),s=this.sandBoxDoc.defaultView;s.G_REPLAY_LOCATION=Object.assign(Object.assign({},s.G_REPLAY_LOCATION||{}),{path:e,hash:n,href:i}),_s(this.sandBoxDoc,t)}initTemplate(){const t=this.target instanceof Window?this.target.document.body:this.target,e=ms(As`
`)[0];t.appendChild(e);const n=e.attachShadow({mode:"open"});n.appendChild(this.createStyle("player-css","/**\n * Copyright (c) oct16.\n * https://github.com/oct16\n * \n * This source code is licensed under the GPL-3.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\nbody {\n margin: 0;\n background-color: #e2e2e2;\n overflow: hidden;\n}\n.player-main {\n box-shadow: 0px 0px 5px rgba(26, 26, 26, 0.05);\n transition: all 0.5s;\n -webkit-transition: all 0.5s;\n opacity: 0;\n position: relative;\n overflow: visible;\n}\n.player-sandbox {\n background: white;\n vertical-align: top;\n border: 0;\n width: 100%;\n height: 100%;\n}\n.timecat-player {\n position: relative;\n width: inherit;\n height: inherit;\n}\n.player-pointer {\n width: 10px;\n height: 10px;\n position: absolute;\n transition: all 0.2s;\n}\n.player-pointer img {\n width: 15px;\n position: absolute;\n z-index: 100;\n top: -5px;\n left: -3px;\n}\n.player-pointer[active] .spinner {\n width: 32px;\n height: 32px;\n left: -17px;\n top: -18px;\n position: absolute;\n background-color: #333;\n border-radius: 100%;\n -webkit-animation: spinner-scale 0.4s 1 ease-in-out;\n animation: spinner-scale 0.4s 1 ease-in-out;\n}\n@-webkit-keyframes spinner-scale {\n 0% {\n -webkit-transform: scale(0);\n }\n 100% {\n -webkit-transform: scale(1);\n opacity: 0.2;\n }\n}\n@keyframes spinner-scale {\n 0% {\n -webkit-transform: scale(0);\n transform: scale(0);\n }\n 100% {\n -webkit-transform: scale(1);\n transform: scale(1);\n opacity: 0.2;\n }\n}\n.player-container {\n background: grey;\n}\n.player-panel {\n width: 100%;\n box-sizing: border-box;\n padding: 5px 10px;\n height: 40px;\n position: absolute;\n left: 0;\n bottom: -41px;\n background: black;\n opacity: 0.8;\n display: flex;\n user-select: none;\n}\n.player-broadcaster {\n position: absolute;\n width: 100%;\n left: 0;\n bottom: 50px;\n display: flex;\n justify-content: center;\n}\n.player-broadcaster .float-layer {\n margin: 0 10px;\n line-height: 20px;\n color: #fff;\n background-color: rgba(0, 0, 0, 0.6);\n border-radius: 2px;\n padding: 5px;\n box-shadow: 0px 0px 2px rgba(26, 26, 26, 0.5);\n text-align: center;\n}\n.player-broadcaster .float-layer[hidden] {\n display: none;\n}\n.player-keyboard {\n white-space: nowrap;\n}\n.player-keyboard button[disabled] {\n cursor: default;\n color: #999;\n}\n.player-export button,\n.player-keyboard button {\n border: none;\n background: none;\n color: white;\n outline: none;\n cursor: pointer;\n font-size: 14px;\n padding: 0 5px;\n}\n.player-export button.play-or-pause,\n.player-keyboard button.play-or-pause {\n padding: 0;\n text-indent: 1px;\n transform: rotate(90deg);\n width: 18px;\n}\n.player-progress,\n.player-keyboard,\n.player-toolbox,\n.player-timer {\n display: flex;\n align-items: center;\n}\n.player-export {\n display: flex;\n}\n.player-export button {\n padding: 2px 0 0 0;\n padding-left: 2px;\n}\n.player-fullscreen {\n margin-left: 8px;\n cursor: pointer;\n display: flex;\n}\n.player-progress {\n width: 100%;\n cursor: pointer;\n}\n.player-progress .player-timer {\n margin-left: 2px;\n padding: 0 4px;\n color: white;\n font-size: 14px;\n font-family: Helvetica;\n}\n.player-slider-bar {\n position: relative;\n width: calc(100% - 20px);\n height: 23px;\n margin: 7.5px 8px;\n border-radius: 2.5px;\n}\n.player-heat-bar-container {\n height: 100%;\n width: 100%;\n position: absolute;\n overflow: hidden;\n background: black;\n}\n.player-heat-bar {\n height: 16px;\n width: 100%;\n position: absolute;\n left: 0;\n top: 0;\n margin: 2px 0px 0 0px;\n background: black;\n transform: rotateZ(180deg) rotateY(180deg);\n}\n.player-thumb {\n width: 2px;\n border: 1px solid white;\n border-radius: 1px;\n height: 95%;\n background: #fff;\n cursor: pointer;\n position: absolute;\n right: 0px;\n top: 0;\n z-index: 10;\n transition: all 0.3s;\n box-shadow: 0px 0px 5px black;\n}\n.player-thumb[active] {\n background: red;\n border-color: red;\n}\n.player-current-progress {\n position: absolute;\n left: 0;\n top: 0;\n width: 0;\n height: 100%;\n}\n.player-start-page {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: calc(100% + 42px);\n -webkit-backdrop-filter: blur(1.5px);\n backdrop-filter: blur(1.5px);\n transition: 0.5s all;\n cursor: pointer;\n}\n.player-start-page .play-btn {\n position: absolute;\n margin: auto;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n width: 100px;\n height: 100px;\n transition: all 0.5s;\n transform: scale(0);\n opacity: 0;\n}\n.player-start-page .play-btn.show {\n transform: scale(1);\n opacity: 1;\n}\n")),n.appendChild(this.createContainer("player-main",'
\n \n \n \n \n \n \n \n \n \n
\n')),this.shadowHost=e}createContainer(t,e){const n=(new DOMParser).parseFromString(e,"text/html").body.firstChild;return n.className=t,n.style.width=this.getSnapshotRecord().width+"px",n.style.height=this.getSnapshotRecord().height+"px",n.style.display="none",this.container=n}makeItResponsive(){const t=this,e=N(o,500),i=()=>e({target:t.target});window.addEventListener("resize",i,!0),this.options.destroyStore.add((()=>window.removeEventListener("resize",i,!0))),setTimeout((()=>this.container.style.opacity="1")),this.container.style.display="block";let s=0;function r(e){const{setHeight:n,setWidth:i,maxScale:s}=e||{};o({target:t.target},i,n,s)}function o(e,i,r,o=1){return n(this,void 0,void 0,(function*(){if(!e)return;const{width:n,height:l}=(c=t.container,{width:parseInt(c.style.width,10),height:parseInt(c.style.height,10)});var c;switch(i=i||n,r=r||l,o){case 0:s=0;break;case 100:s=100}const d=s||o;if(e.target instanceof Window){const{innerWidth:n,innerHeight:s}=e.target;a(t.container,n,s,i,r,d)}else{const{offsetWidth:n,offsetHeight:s}=e.target;a(t.container,n,s,i,r,d)}}))}function a(t,e,n,i,s,r){const{mode:o}=os.getState().player.options||{},a="live"===o?0:38,l=e/i,c=n/(s+a),d=Math.min(l>c?c:l,r||1),h=(i*d-i)/2+(e-i*d)/2,u=(n-s-a*d)/2;t.style.transform=`scale(${d})`,t.style.left=h+"px",t.style.top=u+"px";const p=parseInt(t.style.width),f=parseInt(t.style.height);i===p&&s===f||(t.style.width=i+"px",t.style.height=s+"px",Yt.emit(Cs.RESIZE))}return r(),{resize:r}}createStyle(t,e){const n=document.createElement("style");return n.id=t,n.innerHTML=e,n}}class Js{constructor(t){this.commands=[],this.commandsGetHandle=(t,e,n)=>("push"===e&&this.player&&setTimeout((()=>this.execLastCommand())),Reflect.get(t,e,n)),this.proxyCommands=new Proxy(this.commands,{get:this.commandsGetHandle}),this.getPlayer(),Yt.on(Cs.INIT,(()=>{var e;const{player:n}=(null===(e=null==t?void 0:t.c)||void 0===e?void 0:e.panel)||{};this.player=n,this.initResolve(this.player),this.execLastCommand()}))}command(t){this.proxyCommands.push(t)}execLastCommand(){let t;for(;t=this.commands.shift();){const{cmd:e,value:n}=t;this.getPlayer().then((t=>{switch(e){case"jump":const{startTime:e}=os.getState().progress;this.player.jump({index:0,time:e+n});case"speed":os.dispatch({type:ns.SPEED,data:{speed:n}});break;case"pause":t.pause()}}))}}get duration(){const{duration:t}=os.getState().progress;return t}get paused(){return 0===this.player.speed}get frames(){return{index:this.player.frameIndex,total:this.player.frames.length}}get currentTime(){const{duration:t}=os.getState().progress,{index:e,total:n}=this.frames;return+(e/n*t).toFixed(0)}set currentTime(t){this.setCurrentTime(t)}setCurrentTime(t){return n(this,void 0,void 0,(function*(){this.command({cmd:"jump",value:t})}))}getPlayer(){return n(this,void 0,void 0,(function*(){return yield new Promise((t=>{this.initResolve?t(this.player):this.initResolve=t}))}))}play(){return n(this,void 0,void 0,(function*(){this.command({cmd:"speed",value:1})}))}pause(){return n(this,void 0,void 0,(function*(){this.command({cmd:"pause"})}))}}const Qs={autoplay:!0,mode:"default",target:window,heatPoints:!0,timeMode:"durationTime",fastForward:[2,8],disableScrolling:!0};class tr{constructor(t){this.destroyStore=new Set,this.initialized=!1,this.triggerCalcProgress=N((()=>this.calcProgress()),500),this.getCtrl=()=>this.ctrl,it.reset(),this.init(t),this.watchData(),this.ctrl=new Js(this)}watchData(t){if(t&&!this.initialized){this.initialized=!0;const e=this.options,{records:i,packs:s,currentData:r}=t,{audio:o}=r,a=o&&(o.src||o.wavStrList.length||o.pcmStrList.length);if(this.c=new $s(e),function(t){t.container.querySelector(".player-start-page").setAttribute("style","")}(this.c),(this.fmp=new Zt).ready((()=>n(this,void 0,void 0,(function*(){a&&(yield function(t){return n(this,void 0,void 0,(function*(){const e=function(t){const e=t.querySelector(".player-start-page").querySelector(".play-btn");return e.classList.add("show"),e}(t);return new Promise((t=>{e.addEventListener("click",(()=>n(this,void 0,void 0,(function*(){e.classList.remove("show"),yield R(500),t()}))))}))}))}(this.c.container)),function(t){var e;const n=t.querySelector(".player-start-page");null===(e=null==n?void 0:n.parentElement)||void 0===e||e.removeChild(n)}(this.c.container),i.length&&(e.autoplay||a)&&e.autoplay&&os.dispatch({type:ns.SPEED,data:{speed:1}})})))),s.length&&this.calcProgress(),i.lengthos.unsubscribe()))}))}initData(){return n(this,void 0,void 0,(function*(){const t=this.options,e=yield this.getRecords(t);window.G_REPLAY_RECORDS=e;const n=is(e),i=us(n[0]);os.dispatch({type:rs.UPDATE_DATA,data:{records:e,packs:n,currentData:i}})}))}getRecords(t){return n(this,void 0,void 0,(function*(){const{receiver:e,records:n}=t,i=n||e&&(yield this.dataReceiver(e))||ps()||(yield fs());if(!i)throw E("Replay data not found");return i}))}calcProgress(){const{packs:t}=os.getState().replayData,e=t[0][0].time;let n=0;const i=[];let s=0;t.forEach(((e,r)=>{const o=e[0].time,a=e.slice(-1)[0].time;r&&(s+=o-t[r-1].slice(-1)[0].time);const l={startTime:o,endTime:a,duration:a-o,diffTime:s};i.push(l),n+=l.duration}));os.dispatch({type:ts.PROGRESS,data:{duration:n,packsInfo:i,startTime:e,endTime:e+n}})}dispatchEvent(t,e){const n=new CustomEvent(t,{detail:e});window.dispatchEvent(n)}dataReceiver(e){return n(this,void 0,void 0,(function*(){let n,i,s;return yield new Promise((r=>{e((e=>{n?this.dispatchEvent("record-data",e):(e.type===t.RecordType.HEAD?i=e:e.type===t.RecordType.SNAPSHOT&&(s=e),i&&s&&(n=!0,r([i,s]),this.dispatchEvent("record-data",e)))}))}))}))}destroy(t={removeDOM:!0}){var e;return n(this,void 0,void 0,(function*(){if(this.destroyStore.forEach((t=>t())),Yt.destroy(),os.unsubscribe(),yield R(0),Object.keys(window).filter((t=>{if(t&&(t.startsWith("G_RECORD")||t.startsWith("G_REPLAY")))return!0})).forEach((t=>{delete window[t]})),t.removeDOM){const t=this.c.shadowHost;null===(e=this.c.shadowHost.parentElement)||void 0===e||e.removeChild(t)}}))}on(t,e){Yt.on(t,e)}append(t){return n(this,void 0,void 0,(function*(){yield R(0),os.dispatch({type:rs.APPEND_RECORDS,data:{records:t}}),this.triggerCalcProgress()}))}}return e([vs((t=>({currentData:t.replayData.currentData,records:t.replayData.records,packs:t.replayData.packs})))],tr.prototype,"watchData",null),t.Player=class{constructor(t){this.on=D,this.destroy=D,this.append=D,this.getCtrl=D;const e=new tr(t);Object.keys(this).forEach((t=>{this[t]=e[t].bind(e)}))}},t.PlayerModule=tr,t.Recorder=class{constructor(e){this.status=t.RecorderStatus.PAUSE,this.onData=D,this.destroy=P,this.pause=P,this.record=P,this.use=D,this.clearDB=P;const n=new Gt(e);Object.keys(this).forEach((t=>{Object.defineProperty(this,t,{get:()=>"function"==typeof n[t]?n[t].bind(n):n[t]})}))}},t.RecorderModule=Gt,t.Watcher=ut,t.createReplayDocument=Os,t.debounce=N,t.delay=R,t.exportReplay=Is,t.throttle=O,t.version=v,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); //# sourceMappingURL=timecat.global.prod.js.map