UNPKG

@kt-web-tracing/vue3

Version:

基于 JS 跨平台插件,为前端项目提供【 埋点、行为、性能、异常、请求、资源、路由、曝光、录屏 】监控手段 - vue3版本

1,761 lines (1,744 loc) 547 kB
function isType(type) { return function(value) { return Object.prototype.toString.call(value) === `[object ${type}]`; }; } const isRegExp$1 = isType("RegExp"); const isNumber = isType("Number"); const isString = isType("String"); const isBoolean = isType("Boolean"); const isFunction = isType("Function"); const isArray = isType("Array"); const isWindow = isType("Window"); const isFlase = (val) => { return isBoolean(val) && String(val) === "false"; }; function isEmpty(wat) { return isString(wat) && wat.trim() === "" || wat === void 0 || wat === null; } const isBrowserEnv = isWindow(typeof window !== "undefined" ? window : 0); const isElectronEnv = !!window?.process?.versions?.electron; const isTestEnv = typeof navigator !== "undefined" && navigator.userAgent.includes("jsdom") || // @ts-expect-error: jsdom typeof window !== "undefined" && window.jsdom; function getGlobal() { if (isBrowserEnv || isElectronEnv || isTestEnv) return window; return {}; } function getGlobalSupport() { _global.__webTracing__ = _global.__webTracing__ || {}; return _global.__webTracing__; } function isInit() { return !!_global.__webTracingInit__; } const _global = getGlobal(); const _support = getGlobalSupport(); class Dep { // set结构可以自动去重,因为不可避免有些依赖会被重复添加 // 例如有两个计算属性是依赖于dataA,第一遍计算出那两个计算属性时,dataA的dep是收集了他俩的watcher // 但是当其中一个计算属性重新计算时(比如另外一个依赖项改动了会影响此计算属性重新计算),会再次调取dataA // 的get拦截,也就是会再次触发 dep.addSub(),如果不加重复过滤这样的场景会一直递增下去,然后当dataA发生 // 更改时遍历其subs,届时有太多不需要遍历的watcher,很大概率卡死 subs = /* @__PURE__ */ new Set(); static target; // 全局唯一收集容器 addSub() { if (Dep.target) this.subs.add(Dep.target); } notify(...params) { this.subs.forEach(function(watcher) { watcher.proxy.dirty = true; watcher.update(...params); }); } } const OBSERVERSIGNBOARD = "__webtracingobserver__"; function isRegExp(value) { return Object.prototype.toString.call(value) === `[object RegExp]`; } class Observer { target; constructor(target) { this.target = target; } defineReactive() { const dep = new Dep(); const handlers = getHandlers( () => { dep.addSub(); }, (oldValue) => { dep.notify(oldValue); } ); return new Proxy(this.target, handlers); } } function getHandlers(getCallBack, setCallBack) { const proxyCache = /* @__PURE__ */ new WeakMap(); const handlers = { get(target, key, receiver) { const value = Reflect.get(target, key, receiver); getCallBack && getCallBack(); if (typeof value === "object" && value !== null && !isRegExp(value)) { let proxy = proxyCache.get(value); if (!proxy) { proxy = new Proxy(value, handlers); proxyCache.set(value, proxy); } return proxy; } return value; }, set(target, key, value, receiver) { const oldValue = Reflect.get(target, key, receiver); if (oldValue === value) return oldValue; const beforeTarget = JSON.parse(JSON.stringify(target)); const result = Reflect.set(target, key, value, receiver); setCallBack && setCallBack(beforeTarget); return result; } }; return handlers; } const refMap = /* @__PURE__ */ new WeakMap(); function ref$1(target) { const newObj = { value: target }; newObj[OBSERVERSIGNBOARD] = true; const ob = new Observer(newObj); const proxy = ob.defineReactive(); refMap.set(ob, proxy); return proxy; } function isRef(ref2) { return !!ref2[OBSERVERSIGNBOARD]; } const targetStack = []; function pushTarget(_target) { if (Dep.target) targetStack.push(Dep.target); Dep.target = _target; } function popTarget() { Dep.target = targetStack.pop(); } class Watcher { vm; computed; watch; proxy; dep; getter; callback; constructor(vm, options, getter) { const { computed, watch, callback } = options; this.getter = getter; this.computed = computed || false; this.watch = watch || false; this.callback = callback; this.proxy = { value: "", // 存储这个属性的值,在不需要更新的时候会直接取这个值 dirty: true // 表示这个属性是否脏了(脏了代表需要重新运算更新这个值) }; this.vm = vm; if (computed) { this.dep = new Dep(); } else if (watch) { this.watchGet(); } else { this.get(); } } update(oldValue) { if (this.computed) { this.dep.notify(); } else if (this.watch) { if (oldValue !== this.proxy.value) { this.callback && this.callback(this.proxy.value, oldValue); } } else { this.get(); } } get() { pushTarget(this); const value = this.computed ? computedMap.get(this.vm).call(this.vm) : ""; if (value !== this.proxy.value) { this.proxy.dirty = false; this.proxy.value = value; } popTarget(); return value; } /** * 监听属性专用 - 拿到最新值并添加依赖 */ watchGet() { pushTarget(this); this.proxy.dirty = false; if (this.getter) { this.proxy.value = this.getter(); } popTarget(); } /** * 计算属性专用 - 添加依赖 * 其他值用到了这个计算属性就会被记录添加到依赖中 */ depend() { this.dep.addSub(); } } class Computed { target; constructor(target) { this.target = target; } defineReactive() { const computedWatcher = new Watcher(this, { computed: true }); const handlers = { get() { if (computedWatcher.proxy.dirty) { computedWatcher.depend(); return computedWatcher.get(); } else { computedWatcher.depend(); return computedWatcher.proxy.value; } } }; return new Proxy(this.target, handlers); } } const computedMap = /* @__PURE__ */ new WeakMap(); function computed$1(fun) { const target = { value: 0 }; target[OBSERVERSIGNBOARD] = true; const ob = new Computed(target); const proxy = ob.defineReactive(); computedMap.set(ob, fun); return proxy; } function watchInit(callback, getter) { new Watcher("", { watch: true, callback }, getter); } function watch$1(target, fun) { if (!isRef(target)) return; watchInit( (newValue, oldValue) => { fun(newValue, oldValue); }, function() { return target.value; } ); } function hasProxy() { return !!window.Proxy; } function ref(target) { return hasProxy() ? ref$1(target) : { value: target }; } function computed(fun) { return hasProxy() ? computed$1(fun) : { value: fun() }; } function watch(target, fun) { return hasProxy() ? watch$1(target, fun) : () => ({}); } class Options { dsn = ""; // 上报地址 appName = ""; // 应用名称 appCode = ""; // 应用code appVersion = ""; // 应用版本 userUuid = ""; // 用户id(外部填充进来的id) username = ""; // 用户名 sysId = ""; // 系统id sysName = ""; // 系统名称 sdkUserUuid = ""; // 用户id(sdk内部生成的id) debug = false; // 是否开启调试模式(控制台会输出sdk动作) pv = { core: false // 页面跳转-是否自动发送页面跳转相关数据 }; performance = { core: false, // 性能数据-是否采集静态资源、接口的相关数据 firstResource: false, // 性能数据-是否采集首次进入页面的数据(ps: tcp连接耗时,HTML加载完成时间,首次可交互时间) server: false // 接口请求-是否采集接口请求(成功的才会采集) }; error = { core: false, // 是否采集异常数据(ps: 资源引入错误,promise错误,控制台输出错误) server: false // 接口请求-是否采集报错接口数据 }; event = { core: false, // 页面点击-是否采集点击事件 input: false // 页面输入-是否采集输入事件 }; recordScreen = true; // 是否启动录屏 ext = {}; // 自定义全局附加参数(放在baseInfo中) tracesSampleRate = 1; // 抽样发送 cacheMaxLength = 5; // 上报数据最大缓存数 cacheWatingTime = 5e3; // 上报数据最大等待时间 ignoreInput = []; // 输入框类型过滤 ignoreErrors = []; // 错误类型事件过滤 ignoreRequest = []; // 请求类型事件过滤 scopeError = false; // 当某个时间段报错时,会将此类错误转为特殊错误类型,会新增错误持续时间范围 localization = false; // 是否本地化:sdk不再主动发送事件,事件都存储在本地,由用户手动调用方法发送 sendTypeByXmlBody = false; // 是否强制指定发送形式为xml,body请求方式 // whiteScreen = false // 开启白屏检测 // 添加到行为列表前的 hook (在这里面可以给出错误类型,然后就能达到用户想拿到是何种事件类型的触发) beforePushEventList = []; // 数据上报前的 hook beforeSendData = []; // 数据上报后的 hook afterSendData = []; // 本地化存储溢出后的回调 localizationOverFlow = () => { }; constructor(initOptions2) { const _options = this.transitionOptions(initOptions2); _options.ignoreRequest.push(new RegExp(_options.dsn)); deepAssign(this, _options); } /** * 对入参配置项进行转换 */ transitionOptions(options2) { const _options = deepAssign({}, this, options2); const { beforePushEventList, beforeSendData, afterSendData } = options2; if (beforePushEventList) { _options.beforePushEventList = [beforePushEventList]; } if (beforeSendData) { _options.beforeSendData = [beforeSendData]; } if (afterSendData) { _options.afterSendData = [afterSendData]; } return _options; } } function _validateInitOption(options2) { const { dsn, appName, appCode, appVersion, userUuid, username, sysId, sysName, debug, recordScreen, pv, performance, error, event, ext, tracesSampleRate, cacheMaxLength, cacheWatingTime, ignoreErrors, ignoreRequest, ignoreInput, scopeError, localization, sendTypeByXmlBody, // whiteScreen, beforePushEventList, beforeSendData } = options2; const validateFunList = []; if (pv && typeof pv === "object") { validateFunList.push(validateOption(pv.core, "pv.core", "boolean")); } else { validateFunList.push(validateOption(pv, "pv", "boolean")); } if (performance && typeof performance === "object") { validateFunList.push( validateOption(performance.core, "performance.core", "boolean"), validateOption( performance.firstResource, "performance.firstResource", "boolean" ), validateOption(performance.server, "performance.server", "boolean") ); } else { validateFunList.push(validateOption(performance, "performance", "boolean")); } if (error && typeof error === "object") { validateFunList.push( validateOption(error.core, "error.core", "boolean"), validateOption(error.server, "error.server", "boolean") ); } else { validateFunList.push(validateOption(error, "error", "boolean")); } if (event && typeof event === "object") { validateFunList.push(validateOption(event.core, "event.core", "boolean")); } else { validateFunList.push(validateOption(event, "event", "boolean")); } const validateList = [ validateOption(dsn, "dsn", "string"), validateOption(appName, "appName", "string"), validateOption(appCode, "appCode", "string"), validateOption(appVersion, "appVersion", "string"), validateOption(userUuid, "userUuid", "string"), validateOption(username, "username", "string"), validateOption(sysId, "sysId", "string"), validateOption(sysName, "sysName", "string"), validateOption(debug, "debug", "boolean"), validateOption(recordScreen, "recordScreen", "boolean"), validateOption(ext, "ext", "object"), validateOption(tracesSampleRate, "tracesSampleRate", "number"), validateOption(cacheMaxLength, "cacheMaxLength", "number"), validateOption(cacheWatingTime, "cacheWatingTime", "number"), validateOption(ignoreInput, "ignoreInput", "array"), validateOption(ignoreErrors, "ignoreErrors", "array"), validateOptionArray(ignoreErrors, "ignoreErrors", ["string", "regexp"]), validateOption(ignoreRequest, "ignoreRequest", "array"), validateOptionArray(ignoreRequest, "ignoreRequest", ["string", "regexp"]), validateOption(scopeError, "scopeError", "boolean"), validateOption(localization, "localization", "boolean"), validateOption(sendTypeByXmlBody, "sendTypeByXmlBody", "boolean"), // validateOption(whiteScreen, 'whiteScreen', 'boolean'), validateOption(beforePushEventList, "beforePushEventList", "function"), validateOption(beforeSendData, "beforeSendData", "function") ]; return validateList.every((res) => !!res); } function _validateMustFill(options2) { const validateList = [ validateOptionMustFill(options2.appName, "appName"), validateOptionMustFill(options2.dsn, "dsn") ]; return validateList.every((res) => !!res); } function validateOptionMustFill(target, targetName) { if (isEmpty(target)) { logError(`\u3010${targetName}\u3011\u53C2\u6570\u5FC5\u586B`); return false; } return true; } function validateOption(target, targetName, expectType) { if (!target || typeofAny(target) === expectType) return true; logError( `TypeError:\u3010${targetName}\u3011\u671F\u671B\u4F20\u5165${expectType}\u7C7B\u578B\uFF0C\u76EE\u524D\u662F${typeofAny( target )}\u7C7B\u578B` ); return false; } function validateOptionArray(target, targetName, expectTypes) { if (!target) return true; let pass = true; target.forEach((item) => { if (!expectTypes.includes(typeofAny(item))) { logError( `TypeError:\u3010${targetName}\u3011\u6570\u7EC4\u5185\u7684\u503C\u671F\u671B\u4F20\u5165${expectTypes.join( "|" )}\u7C7B\u578B\uFF0C\u76EE\u524D\u503C${item}\u662F${typeofAny(item)}\u7C7B\u578B` ); pass = false; } }); return pass; } let options; function initOptions(initOptions2) { if (!_validateMustFill(initOptions2) || !_validateInitOption(initOptions2)) return false; options = ref(new Options(initOptions2)); _support.options = options; return true; } function debug(...args) { if (options.value.debug) console.log("@web-tracing: ", ...args); } function logError(...args) { console.error("@web-tracing: ", ...args); } function on$1(target, eventName, handler, opitons = false) { target.addEventListener(eventName, handler, opitons); } function replaceAop(source, name, replacement, isForced = false) { if (source === void 0) return; if (name in source || isForced) { const original = source[name]; const wrapped = replacement(original); if (isFunction(wrapped)) { source[name] = wrapped; } } } function normalizeObj(source) { Object.keys(source).forEach((p) => { const v = source[p]; if (isNumber(v)) { source[p] = v === 0 ? void 0 : parseFloat(v.toFixed(2)); } }); return source; } function getLocationHref() { if (typeof document === "undefined" || document.location == null) return ""; return document.location.href; } function getTimestamp() { return Date.now(); } function throttle$1(func, wait, runFirst = false) { let timer = null; let lastArgs; return function(...args) { lastArgs = args; if (timer === null) { if (runFirst) { func.apply(this, lastArgs); } timer = setTimeout(() => { timer = null; func.apply(this, lastArgs); }, wait); } }; } function debounce(func, wait, runFirst = false) { let timer = null; return function(...arg) { if (runFirst) { func.call(this, ...arg); runFirst = false; } if (timer) clearTimeout(timer); timer = setTimeout(() => { func.call(this, ...arg); }, wait); }; } function groupArray(arr, ...keys) { const groups = /* @__PURE__ */ new Map(); for (const obj of arr) { const key = keys.filter((k) => obj[k]).map((k) => obj[k]).join(":"); if (!groups.has(key)) { groups.set(key, []); } groups.get(key).push(obj); } return Array.from(groups.values()); } function deepAssign(target, ...sources) { sources.forEach((source) => { for (const key in source) { if (source[key] !== null && isRegExp$1(source[key])) { target[key] = source[key]; } else if (source[key] !== null && typeof source[key] === "object") { target[key] = deepAssign( target[key] || (isArray(source[key]) ? [] : {}), source[key] ); } else { target[key] = source[key]; } } }); return target; } function validateMethods(methodsName) { if (!isInit()) { logError(`${methodsName} \u9700\u8981\u5728SDK\u521D\u59CB\u5316\u4E4B\u540E\u4F7F\u7528`); return false; } return true; } function typeofAny(target) { return Object.prototype.toString.call(target).slice(8, -1).toLowerCase(); } function isValidKey(key, object) { return key in object; } function randomBoolean(randow) { return Math.random() <= randow; } function pad(num, len, placeholder = "0") { const str = String(num); if (str.length < len) { let result = str; for (let i = 0; i < len - str.length; i += 1) { result = placeholder + result; } return result; } return str; } function uuid() { const date = /* @__PURE__ */ new Date(); const hexDate = parseInt( `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad( date.getDate(), 2 )}`, 10 ).toString(16); const hexTime = parseInt( `${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad( date.getSeconds(), 2 )}${pad(date.getMilliseconds(), 3)}`, 10 ).toString(16); let guid = hexDate + hexTime.length + hexTime; while (guid.length < 32) { guid += Math.floor(Math.random() * 16).toString(16); } return `${guid.slice(0, 8)}-${guid.slice(8, 16)}-${guid.slice(16)}`; } function getCookieByName(name) { const result = document.cookie.match(new RegExp(`${name}=([^;]+)(;|$)`)); return result ? result[1] : void 0; } function sendByBeacon(url, data) { return navigator.sendBeacon(url, JSON.stringify(data)); } const sendReaconImageList = []; function sendByImage(url, data) { return new Promise((resolve) => { const beacon = new Image(); beacon.src = `${url}?v=${encodeURIComponent(JSON.stringify(data))}`; sendReaconImageList.push(beacon); beacon.onload = () => { resolve(); }; beacon.onerror = function() { resolve(); }; }); } function sendByXML(url, data) { return new Promise((resolve) => { const xhr = new XMLHttpRequest(); xhr.open("post", url); xhr.setRequestHeader("content-type", "application/json"); xhr.send(JSON.stringify(data)); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { resolve(); } }; }); } function executeFunctions(funList, through, args) { if (funList.length === 0) return args; let result = void 0; for (let i = 0; i < funList.length; i++) { const func = funList[i]; if (i === 0 || through) { result = func(args); } else { result = func(result); } } return result; } function unKnowToArray(target) { return isArray(target) ? target : [target]; } const arrayMap = Array.prototype.map || function polyfillMap(fn) { const result = []; for (let i = 0; i < this.length; i += 1) { result.push(fn(this[i], i, this)); } return result; }; function map(arr, fn) { return arrayMap.call(arr, fn); } const arrayFilter = Array.prototype.filter || function filterPolyfill(fn) { const result = []; for (let i = 0; i < this.length; i += 1) { if (fn(this[i], i, this)) { result.push(this[i]); } } return result; }; function filter(arr, fn) { return arrayFilter.call(arr, fn); } const nextTime = window.requestIdleCallback || window.requestAnimationFrame || ((callback) => setTimeout(callback, 17)); function isObjectOverSizeLimit(object, limitInKB) { const serializedObject = JSON.stringify(object); const sizeInBytes = new TextEncoder().encode(serializedObject).length; const sizeInKB = sizeInBytes / 1024; return sizeInKB > limitInKB; } function parseGetParams(url) { const params = {}; const query = url.split("?")[1]; if (query) { const pairs = query.split("&"); for (const pair of pairs) { const [key, value] = pair.split("="); params[decodeURIComponent(key)] = decodeURIComponent(value); } } return params; } function deepCopy(target, map2 = /* @__PURE__ */ new Map()) { if (target !== null && typeof target === "object") { let res = map2.get(target); if (res) return res; if (target instanceof Array) { res = []; map2.set(target, res); target.forEach((item, index) => { res[index] = deepCopy(item, map2); }); } else { res = {}; map2.set(target, res); Object.keys(target).forEach((key) => { if (isValidKey(key, target)) { res[key] = deepCopy(target[key], map2); } }); } return res; } return target; } var version$1 = "1.0.22"; const DEVICE_KEY = "_webtracing_device_id"; const SESSION_KEY = "_webtracing_session_id"; const SURVIVIE_MILLI_SECONDS = 18e5; const SDK_LOCAL_KEY = "_webtracing_localization_key"; const SDK_VERSION = version$1; var EVENTTYPES = /* @__PURE__ */ ((EVENTTYPES2) => { EVENTTYPES2["ERROR"] = "error"; EVENTTYPES2["CONSOLEERROR"] = "consoleError"; EVENTTYPES2["UNHANDLEDREJECTION"] = "unhandledrejection"; EVENTTYPES2["CLICK"] = "click"; EVENTTYPES2["INPUT"] = "input"; EVENTTYPES2["LOAD"] = "load"; EVENTTYPES2["BEFOREUNLOAD"] = "beforeunload"; EVENTTYPES2["FETCH"] = "fetch"; EVENTTYPES2["XHROPEN"] = "xhr-open"; EVENTTYPES2["XHRSEND"] = "xhr-send"; EVENTTYPES2["HASHCHANGE"] = "hashchange"; EVENTTYPES2["HISTORYPUSHSTATE"] = "history-pushState"; EVENTTYPES2["HISTORYREPLACESTATE"] = "history-replaceState"; EVENTTYPES2["POPSTATE"] = "popstate"; EVENTTYPES2["READYSTATECHANGE"] = "readystatechange"; EVENTTYPES2["ONLINE"] = "online"; EVENTTYPES2["OFFLINE"] = "offline"; return EVENTTYPES2; })(EVENTTYPES || {}); var SEDNEVENTTYPES = /* @__PURE__ */ ((SEDNEVENTTYPES2) => { SEDNEVENTTYPES2["PV"] = "pv"; SEDNEVENTTYPES2["PVDURATION"] = "pv-duration"; SEDNEVENTTYPES2["ERROR"] = "error"; SEDNEVENTTYPES2["PERFORMANCE"] = "performance"; SEDNEVENTTYPES2["CLICK"] = "click"; SEDNEVENTTYPES2["INPUT"] = "input"; SEDNEVENTTYPES2["DWELL"] = "dwell"; SEDNEVENTTYPES2["CUSTOM"] = "custom"; SEDNEVENTTYPES2["INTERSECTION"] = "intersection"; return SEDNEVENTTYPES2; })(SEDNEVENTTYPES || {}); var SENDID = /* @__PURE__ */ ((SENDID2) => { SENDID2["PAGE"] = "page"; SENDID2["RESOURCE"] = "resource"; SENDID2["SERVER"] = "server"; SENDID2["CODE"] = "code"; SENDID2["REJECT"] = "reject"; SENDID2["CONSOLEERROR"] = "console.error"; return SENDID2; })(SENDID || {}); const WEBPAGELOAD = { 0: "navigate", // 网页通过点击链接,地址栏输入,表单提交,脚本操作等方式加载 1: "reload", // 网页通过“重新加载”按钮或者location.reload()方法加载 2: "back_forward", // 网页通过“前进”或“后退”按钮加载 255: "reserved" // 任何其他来源的加载 }; class EventBus { handlers; constructor() { this.handlers = {}; } /** * 为目标类型事件添加回调 * @param handler 需要被添加的类型以及回调函数 */ addEvent(handler) { !this.handlers[handler.type] && (this.handlers[handler.type] = []); const funIndex = this._getCallbackIndex(handler); if (funIndex === -1) { this.handlers[handler.type]?.push(handler.callback); } } /** * 为目标类型事件删除回调 * @param handler 需要被删除的类型以及回调函数 */ delEvent(handler) { const funIndex = this._getCallbackIndex(handler); if (funIndex !== -1) { this.handlers[handler.type]?.splice(funIndex, 1); } } /** * 为目标类型事件更改回调 * @param handler 需要被更改的类型以及回调函数 * @param newCallback 新的回调函数 */ changeEvent(handler, newCallback) { const funIndex = this._getCallbackIndex(handler); if (funIndex !== -1) { this.handlers[handler.type]?.splice(funIndex, 1, newCallback); } } /** * 获取目标类型事件所有的回调 * @param type 事件类型 */ getEvent(type) { return this.handlers[type] || []; } /** * 执行目标类型事件所有的回调 * @param type 事件类型 * @param args 额外参数 */ runEvent(type, ...args) { const allEvent = this.getEvent(type); allEvent.forEach((fun) => { fun(...args); }); } /** * 获取函数在 callback 列表中的位置 */ _getCallbackIndex(handler) { if (this.handlers[handler.type]) { const callbackList = this.handlers[handler.type]; if (callbackList) { return callbackList.findIndex((fun) => fun === handler.callback); } else { return -1; } } else { return -1; } } } const eventBus = _support.eventBus || (_support.eventBus = new EventBus()); function initReplace() { for (const key in EVENTTYPES) { if (isValidKey(key, EVENTTYPES)) { replace(key); } } } function replace(type) { if (!isValidKey(type, EVENTTYPES)) return; const value = EVENTTYPES[type]; switch (value) { case EVENTTYPES.ERROR: listenError(EVENTTYPES.ERROR); break; case EVENTTYPES.UNHANDLEDREJECTION: listenUnhandledrejection(EVENTTYPES.UNHANDLEDREJECTION); break; case EVENTTYPES.CONSOLEERROR: replaceConsoleError(EVENTTYPES.CONSOLEERROR); break; case EVENTTYPES.CLICK: listenClick(EVENTTYPES.CLICK); break; case EVENTTYPES.INPUT: listenInput(EVENTTYPES.INPUT); break; case EVENTTYPES.LOAD: listenLoad(EVENTTYPES.LOAD); break; case EVENTTYPES.BEFOREUNLOAD: listenBeforeunload(EVENTTYPES.BEFOREUNLOAD); break; case EVENTTYPES.XHROPEN: replaceXHROpen(EVENTTYPES.XHROPEN); break; case EVENTTYPES.XHRSEND: replaceXHRSend(EVENTTYPES.XHRSEND); break; case EVENTTYPES.FETCH: replaceFetch(EVENTTYPES.FETCH); break; case EVENTTYPES.HASHCHANGE: listenHashchange(EVENTTYPES.HASHCHANGE); break; case EVENTTYPES.HISTORYPUSHSTATE: replaceHistoryPushState(EVENTTYPES.HISTORYPUSHSTATE); break; case EVENTTYPES.HISTORYREPLACESTATE: replaceHistoryReplaceState(EVENTTYPES.HISTORYREPLACESTATE); break; case EVENTTYPES.POPSTATE: listenPopState(EVENTTYPES.POPSTATE); break; case EVENTTYPES.OFFLINE: listenOffline(EVENTTYPES.OFFLINE); break; case EVENTTYPES.ONLINE: listenOnline(EVENTTYPES.ONLINE); break; } } function listenError(type) { on$1( _global, "error", function(e) { eventBus.runEvent(type, e); }, true ); } function listenUnhandledrejection(type) { on$1(_global, "unhandledrejection", function(ev) { eventBus.runEvent(type, ev); }); } function replaceConsoleError(type) { replaceAop(console, "error", (originalError) => { return function(...args) { if (!(args[0] && args[0].slice && args[0].slice(0, 12) === "@web-tracing")) { eventBus.runEvent(type, args); } originalError.apply(this, args); }; }); } function listenClick(type) { if (!("document" in _global)) return; const clickThrottle = throttle$1(eventBus.runEvent, 100, true); on$1( _global.document, "click", function(e) { clickThrottle.call(eventBus, type, e); }, true ); } function listenInput(type) { if (!("document" in _global)) return; const inputThrottle = debounce(eventBus.runEvent, 500, false); on$1( _global.document, "input", function(e) { inputThrottle.call(eventBus, type, e); }, true ); } function listenLoad(type) { on$1( _global, "load", function(e) { eventBus.runEvent(type, e); }, true ); } function listenBeforeunload(type) { on$1( _global, "beforeunload", function(e) { eventBus.runEvent(type, e); }, false ); } function replaceXHROpen(type) { if (!("XMLHttpRequest" in _global)) return; replaceAop(XMLHttpRequest.prototype, "open", (originalOpen) => { return function(...args) { eventBus.runEvent(type, ...args); originalOpen.apply(this, args); }; }); } function replaceXHRSend(type) { if (!("XMLHttpRequest" in _global)) return; replaceAop(XMLHttpRequest.prototype, "send", (originalSend) => { return function(...args) { eventBus.runEvent(type, this, ...args); originalSend.apply(this, args); }; }); } function replaceFetch(type) { if (!("fetch" in _global)) return; replaceAop(_global, "fetch", (originalFetch) => { return function(...args) { const fetchStart = getTimestamp(); let requestInfo; let requestInit; if (args[0] instanceof Request) { requestInfo = args[0].clone(); } else { requestInfo = args[0]; requestInit = { ...args[1] }; } const requestData = { url: requestInfo instanceof Request ? requestInfo.url : requestInfo, method: requestInfo instanceof Request ? requestInfo.method : requestInit?.method || "GET", headers: extractHeaders(requestInfo, requestInit) }; if (!requestInit && typeof requestInfo === "string") { requestInit = { method: "GET" }; } return originalFetch.apply(_global, [requestInfo, requestInit]).then((res) => { eventBus.runEvent(type, requestData.url, requestData, res, fetchStart); return res; }).catch((error) => { throw error; }); }; }); } function extractHeaders(info, init) { if (info instanceof Request) { return Object.fromEntries(info.headers.entries()); } const headers = init?.headers || {}; if (headers instanceof Headers) { return Object.fromEntries(headers.entries()); } if (Array.isArray(headers)) { return Object.fromEntries(headers); } return { ...headers }; } function listenHashchange(type) { on$1(_global, "hashchange", function(e) { eventBus.runEvent(type, e); }); } function replaceHistoryReplaceState(type) { if (!("history" in _global)) return; if (!("pushState" in _global.history)) return; replaceAop(_global.history, "replaceState", (originalSend) => { return function(...args) { eventBus.runEvent(type, ...args); originalSend.apply(this, args); }; }); } function replaceHistoryPushState(type) { if (!("history" in _global)) return; if (!("pushState" in _global.history)) return; replaceAop(_global.history, "pushState", (originalSend) => { return function(...args) { eventBus.runEvent(type, ...args); originalSend.apply(this, args); }; }); } function listenPopState(type) { on$1(_global, "popstate", function(e) { eventBus.runEvent(type, e); }); } function listenOffline(type) { on$1( _global, "offline", function(e) { eventBus.runEvent(type, e); }, true ); } function listenOnline(type) { on$1( _global, "online", function(e) { eventBus.runEvent(type, e); }, true ); } let e = function() { return e = Object.assign || function(e2) { for (var n2, t2 = 1, r2 = arguments.length; t2 < r2; t2++) for (const o2 in n2 = arguments[t2]) Object.prototype.hasOwnProperty.call(n2, o2) && (e2[o2] = n2[o2]); return e2; }, e.apply(this, arguments); }; function n(e2, n2, t2, r2) { return new (t2 || (t2 = Promise))(function(o2, a2) { function i2(e3) { try { u2(r2.next(e3)); } catch (n3) { a2(n3); } } function c2(e3) { try { u2(r2.throw(e3)); } catch (n3) { a2(n3); } } function u2(e3) { let n3; e3.done ? o2(e3.value) : (n3 = e3.value, n3 instanceof t2 ? n3 : new t2(function(e4) { e4(n3); })).then(i2, c2); } u2((r2 = r2.apply(e2, n2 || [])).next()); }); } function t(e2, n2) { let t2, r2, o2, a2, i2 = { label: 0, sent: function() { if (1 & o2[0]) throw o2[1]; return o2[1]; }, trys: [], ops: [] }; return a2 = { next: c2(0), throw: c2(1), return: c2(2) }, "function" == typeof Symbol && (a2[Symbol.iterator] = function() { return this; }), a2; function c2(c3) { return function(u2) { return function(c4) { if (t2) throw new TypeError("Generator is already executing."); for (; a2 && (a2 = 0, c4[0] && (i2 = 0)), i2; ) try { if (t2 = 1, r2 && (o2 = 2 & c4[0] ? r2.return : c4[0] ? r2.throw || ((o2 = r2.return) && o2.call(r2), 0) : r2.next) && !(o2 = o2.call(r2, c4[1])).done) return o2; switch (r2 = 0, o2 && (c4 = [2 & c4[0], o2.value]), c4[0]) { case 0: case 1: o2 = c4; break; case 4: return i2.label++, { value: c4[1], done: false }; case 5: i2.label++, r2 = c4[1], c4 = [0]; continue; case 7: ; c4 = i2.ops.pop(), i2.trys.pop(); continue; default: if (!(o2 = i2.trys, (o2 = o2.length > 0 && o2[o2.length - 1]) || 6 !== c4[0] && 2 !== c4[0])) { i2 = 0; continue; } if (3 === c4[0] && (!o2 || c4[1] > o2[0] && c4[1] < o2[3])) { i2.label = c4[1]; break; } if (6 === c4[0] && i2.label < o2[1]) { ; i2.label = o2[1], o2 = c4; break; } if (o2 && i2.label < o2[2]) { ; i2.label = o2[2], i2.ops.push(c4); break; } o2[2] && i2.ops.pop(), i2.trys.pop(); continue; } c4 = n2.call(e2, i2); } catch (u3) { c4 = [6, u3], r2 = 0; } finally { t2 = o2 = 0; } if (5 & c4[0]) throw c4[1]; return { value: c4[0] ? c4[1] : void 0, done: true }; }([c3, u2]); }; } } function r(e2, n2, t2) { if (t2 || 2 === arguments.length) for (var r2, o2 = 0, a2 = n2.length; o2 < a2; o2++) !r2 && o2 in n2 || (r2 || (r2 = Array.prototype.slice.call(n2, 0, o2)), r2[o2] = n2[o2]); return e2.concat(r2 || Array.prototype.slice.call(n2)); } function o(e2, n2) { return new Promise(function(t2) { return setTimeout(t2, e2, n2); }); } function a(e2) { return !!e2 && "function" == typeof e2.then; } function i$1(e2, n2) { try { const t2 = e2(); a(t2) ? t2.then( function(e3) { return n2(true, e3); }, function(e3) { return n2(false, e3); } ) : n2(true, t2); } catch (r2) { n2(false, r2); } } function c(e2, r2, a2) { return void 0 === a2 && (a2 = 16), n(this, void 0, void 0, function() { let n2, i2, c2; return t(this, function(t2) { switch (t2.label) { case 0: n2 = Date.now(), i2 = 0, t2.label = 1; case 1: return i2 < e2.length ? (r2(e2[i2], i2), (c2 = Date.now()) >= n2 + a2 ? (n2 = c2, [4, o(0)]) : [3, 3]) : [3, 4]; case 2: t2.sent(), t2.label = 3; case 3: return ++i2, [3, 1]; case 4: return [2]; } }); }); } function u(e2) { e2.then(void 0, function() { }); } function l(e2, n2) { e2 = [e2[0] >>> 16, 65535 & e2[0], e2[1] >>> 16, 65535 & e2[1]], n2 = [n2[0] >>> 16, 65535 & n2[0], n2[1] >>> 16, 65535 & n2[1]]; const t2 = [0, 0, 0, 0]; return t2[3] += e2[3] + n2[3], t2[2] += t2[3] >>> 16, t2[3] &= 65535, t2[2] += e2[2] + n2[2], t2[1] += t2[2] >>> 16, t2[2] &= 65535, t2[1] += e2[1] + n2[1], t2[0] += t2[1] >>> 16, t2[1] &= 65535, t2[0] += e2[0] + n2[0], t2[0] &= 65535, [t2[0] << 16 | t2[1], t2[2] << 16 | t2[3]]; } function s(e2, n2) { e2 = [e2[0] >>> 16, 65535 & e2[0], e2[1] >>> 16, 65535 & e2[1]], n2 = [n2[0] >>> 16, 65535 & n2[0], n2[1] >>> 16, 65535 & n2[1]]; const t2 = [0, 0, 0, 0]; return t2[3] += e2[3] * n2[3], t2[2] += t2[3] >>> 16, t2[3] &= 65535, t2[2] += e2[2] * n2[3], t2[1] += t2[2] >>> 16, t2[2] &= 65535, t2[2] += e2[3] * n2[2], t2[1] += t2[2] >>> 16, t2[2] &= 65535, t2[1] += e2[1] * n2[3], t2[0] += t2[1] >>> 16, t2[1] &= 65535, t2[1] += e2[2] * n2[2], t2[0] += t2[1] >>> 16, t2[1] &= 65535, t2[1] += e2[3] * n2[1], t2[0] += t2[1] >>> 16, t2[1] &= 65535, t2[0] += e2[0] * n2[3] + e2[1] * n2[2] + e2[2] * n2[1] + e2[3] * n2[0], t2[0] &= 65535, [t2[0] << 16 | t2[1], t2[2] << 16 | t2[3]]; } function d(e2, n2) { return 32 === (n2 %= 64) ? [e2[1], e2[0]] : n2 < 32 ? [e2[0] << n2 | e2[1] >>> 32 - n2, e2[1] << n2 | e2[0] >>> 32 - n2] : (n2 -= 32, [e2[1] << n2 | e2[0] >>> 32 - n2, e2[0] << n2 | e2[1] >>> 32 - n2]); } function m(e2, n2) { return 0 === (n2 %= 64) ? e2 : n2 < 32 ? [e2[0] << n2 | e2[1] >>> 32 - n2, e2[1] << n2] : [e2[1] << n2 - 32, 0]; } function f(e2, n2) { return [e2[0] ^ n2[0], e2[1] ^ n2[1]]; } function v(e2) { return e2 = f(e2, [0, e2[0] >>> 1]), e2 = f(e2 = s(e2, [4283543511, 3981806797]), [0, e2[0] >>> 1]), e2 = f(e2 = s(e2, [3301882366, 444984403]), [0, e2[0] >>> 1]); } function h(e2, n2) { n2 = n2 || 0; let t2, r2 = (e2 = e2 || "").length % 16, o2 = e2.length - r2, a2 = [0, n2], i2 = [0, n2], c2 = [0, 0], u2 = [0, 0], h2 = [2277735313, 289559509], b2 = [1291169091, 658871167]; for (t2 = 0; t2 < o2; t2 += 16) c2 = [ 255 & e2.charCodeAt(t2 + 4) | (255 & e2.charCodeAt(t2 + 5)) << 8 | (255 & e2.charCodeAt(t2 + 6)) << 16 | (255 & e2.charCodeAt(t2 + 7)) << 24, 255 & e2.charCodeAt(t2) | (255 & e2.charCodeAt(t2 + 1)) << 8 | (255 & e2.charCodeAt(t2 + 2)) << 16 | (255 & e2.charCodeAt(t2 + 3)) << 24 ], u2 = [ 255 & e2.charCodeAt(t2 + 12) | (255 & e2.charCodeAt(t2 + 13)) << 8 | (255 & e2.charCodeAt(t2 + 14)) << 16 | (255 & e2.charCodeAt(t2 + 15)) << 24, 255 & e2.charCodeAt(t2 + 8) | (255 & e2.charCodeAt(t2 + 9)) << 8 | (255 & e2.charCodeAt(t2 + 10)) << 16 | (255 & e2.charCodeAt(t2 + 11)) << 24 ], c2 = d(c2 = s(c2, h2), 31), a2 = l(a2 = d(a2 = f(a2, c2 = s(c2, b2)), 27), i2), a2 = l(s(a2, [0, 5]), [0, 1390208809]), u2 = d(u2 = s(u2, b2), 33), i2 = l(i2 = d(i2 = f(i2, u2 = s(u2, h2)), 31), a2), i2 = l(s(i2, [0, 5]), [0, 944331445]); switch (c2 = [0, 0], u2 = [0, 0], r2) { case 15: u2 = f(u2, m([0, e2.charCodeAt(t2 + 14)], 48)); case 14: u2 = f(u2, m([0, e2.charCodeAt(t2 + 13)], 40)); case 13: u2 = f(u2, m([0, e2.charCodeAt(t2 + 12)], 32)); case 12: u2 = f(u2, m([0, e2.charCodeAt(t2 + 11)], 24)); case 11: u2 = f(u2, m([0, e2.charCodeAt(t2 + 10)], 16)); case 10: u2 = f(u2, m([0, e2.charCodeAt(t2 + 9)], 8)); case 9: u2 = s(u2 = f(u2, [0, e2.charCodeAt(t2 + 8)]), b2), i2 = f(i2, u2 = s(u2 = d(u2, 33), h2)); case 8: c2 = f(c2, m([0, e2.charCodeAt(t2 + 7)], 56)); case 7: c2 = f(c2, m([0, e2.charCodeAt(t2 + 6)], 48)); case 6: c2 = f(c2, m([0, e2.charCodeAt(t2 + 5)], 40)); case 5: c2 = f(c2, m([0, e2.charCodeAt(t2 + 4)], 32)); case 4: c2 = f(c2, m([0, e2.charCodeAt(t2 + 3)], 24)); case 3: c2 = f(c2, m([0, e2.charCodeAt(t2 + 2)], 16)); case 2: c2 = f(c2, m([0, e2.charCodeAt(t2 + 1)], 8)); case 1: c2 = s(c2 = f(c2, [0, e2.charCodeAt(t2)]), h2), a2 = f(a2, c2 = s(c2 = d(c2, 31), b2)); } return a2 = l(a2 = f(a2, [0, e2.length]), i2 = f(i2, [0, e2.length])), i2 = l(i2, a2), a2 = l(a2 = v(a2), i2 = v(i2)), i2 = l(i2, a2), ("00000000" + (a2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (a2[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (i2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (i2[1] >>> 0).toString(16)).slice(-8); } function b(e2) { return parseInt(e2); } function p(e2) { return parseFloat(e2); } function y(e2, n2) { return "number" == typeof e2 && isNaN(e2) ? n2 : e2; } function g(e2) { return e2.reduce(function(e3, n2) { return e3 + (n2 ? 1 : 0); }, 0); } function w(e2, n2) { if (void 0 === n2 && (n2 = 1), Math.abs(n2) >= 1) return Math.round(e2 / n2) * n2; const t2 = 1 / n2; return Math.round(e2 * t2) / t2; } function L(e2) { return e2 && "object" == typeof e2 && "message" in e2 ? e2 : { message: e2 }; } function k(e2) { return "function" != typeof e2; } function V(e2, r2, a2) { const l2 = Object.keys(e2).filter(function(e3) { return !function(e4, n2) { for (let t2 = 0, r3 = e4.length; t2 < r3; ++t2) if (e4[t2] === n2) return true; return false; }(a2, e3); }), s2 = Array(l2.length); return c(l2, function(n2, t2) { s2[t2] = function(e3, n3) { const t3 = new Promise(function(t4) { const r3 = Date.now(); i$1(e3.bind(null, n3), function() { for (var e4 = [], n4 = 0; n4 < arguments.length; n4++) e4[n4] = arguments[n4]; const o2 = Date.now() - r3; if (!e4[0]) return t4(function() { return { error: L(e4[1]), duration: o2 }; }); const a3 = e4[1]; if (k(a3)) return t4(function() { return { value: a3, duration: o2 }; }); t4(function() { return new Promise(function(e5) { const n5 = Date.now(); i$1(a3, function() { for (var t5 = [], r4 = 0; r4 < arguments.length; r4++) t5[r4] = arguments[r4]; const a4 = o2 + Date.now() - n5; if (!t5[0]) return e5({ error: L(t5[1]), duration: a4 }); e5({ value: t5[1], duration: a4 }); }); }); }); }); }); return u(t3), function() { return t3.then(function(e4) { return e4(); }); }; }(e2[n2], r2); }), function() { return n(this, void 0, void 0, function() { let e3, n2, r3, a3, i2, d2; return t(this, function(m2) { switch (m2.label) { case 0: for (e3 = {}, n2 = 0, r3 = l2; n2 < r3.length; n2++) a3 = r3[n2], e3[a3] = void 0; i2 = Array(l2.length), d2 = function() { let n3; return t(this, function(t2) { switch (t2.label) { case 0: return n3 = true, [ 4, c(l2, function(t3, r4) { if (!i2[r4]) if (s2[r4]) { const o2 = s2[r4]().then(function(n4) { return e3[t3] = n4; }); u(o2), i2[r4] = o2; } else n3 = false; }) ]; case 1: return t2.sent(), n3 ? [2, "break"] : [4, o(1)]; case 2: return t2.sent(), [2]; } }); }, m2.label = 1; case 1: return [5, d2()]; case 2: if ("break" === m2.sent()) return [3, 4]; m2.label = 3; case 3: return [3, 1]; case 4: return [4, Promise.all(i2)]; case 5: return m2.sent(), [2, e3]; } }); }); }; } function Z() { const e2 = window, n2 = navigator; return g([ "MSCSSMatrix" in e2, "msSetImmediate" in e2, "msIndexedDB" in e2, "msMaxTouchPoints" in n2, "msPointerEnabled" in n2 ]) >= 4; } function S() { const e2 = window, n2 = navigator; return g([ "msWriteProfilerMark" in e2, "MSStream" in e2, "msLaunchUri" in n2, "msSaveBlob" in n2 ]) >= 3 && !Z(); } function X() { const e2 = window, n2 = navigator; return g([ "webkitPersistentStorage" in n2, "webkitTemporaryStorage" in n2, 0 === n2.vendor.indexOf("Google"), "webkitResolveLocalFileSystemURL" in e2, "BatteryManager" in e2, "webkitMediaStream" in e2, "webkitSpeechGrammar" in e2 ]) >= 5; } function x() { const e2 = window, n2 = navigator; return g([ "ApplePayError" in e2, "CSSPrimitiveValue" in e2, "Counter" in e2, 0 === n2.vendor.indexOf("Apple"), "getStorageUpdates" in n2, "WebKitMediaKeys" in e2 ]) >= 4; } function F() { const e2 = window; return g([ "safari" in e2, !("DeviceMotionEvent" in e2), !("ongestureend" in e2), !("standalone" in navigator) ]) >= 3; } function Y() { let e2, n2, t2 = window; return g([ "buildID" in navigator, "MozAppearance" in (null !== (n2 = null === (e2 = document.documentElement) || void 0 === e2 ? void 0 : e2.style) && void 0 !== n2 ? n2 : {}), "onmozfullscreenchange" in t2, "mozInnerScreenX" in t2, "CSSMozDocumentRule" in t2, "CanvasCaptureMediaStream" in t2 ]) >= 4; } function C() { const e2 = document; return e2.fullscreenElement || e2.msFullscreenElement || e2.mozFullScreenElement || e2.webkitFullscreenElement || null; } function R() { const e2 = X(), n2 = Y(); if (!e2 && !n2) return false; const t2 = window; return g([ "onorientationchange" in t2, "orientation" in t2, e2 && !("SharedWorker" in t2), n2 && /android/i.test(navigator.appVersion) ]) >= 2; } function G(e2) { const n2 = new Error(e2); return n2.name = e2, n2; } function M(e2, r2, a2) { let i2, c2, u2; return void 0 === a2 && (a2 = 50), n(this, void 0, void 0, function() { let n2, l2; return t(this, function(t2) { switch (t2.label) { case 0: n2 = document, t2.label = 1; case 1: return n2.body ? [3, 3] : [4, o(a2)]; case 2: return t2.sent(), [3, 1]; case 3: l2 = n2.createElement("iframe"), t2.label = 4; case 4: return t2.trys.push([4, , 10, 11]), [ 4, new Promise(function(e3, t3) { let o2 = false, a3 = function() { o2 = true, e3(); }; l2.onload = a3, l2.onerror = function(e4) { o2 = true, t3(e4); }; const i3 = l2.style; i3.setProperty("display", "block", "important"), i3.position = "absolute", i3.top = "0", i3.left = "0", i3.visibility = "hidden", r2 && "srcdoc" in l2 ? l2.srcdoc = r2 : l2.src = "about:blank", n2.body.appendChild(l2); const c3 = function() { let e4, n3; o2 || ("complete" === (null === (n3 = null === (e4 = l2.contentWindow) || void 0 === e4 ? void 0 : e4.document) || void 0 === n3 ? void 0 : n3.readyState) ? a3() : setTimeout(c3, 10)); }; c3(); }) ]; case 5: t2.sent(), t2.label = 6; case 6: return (null === (c2 = null === (i2 = l2.contentWindow) || void 0 === i2 ? void 0 : i2.document) || void 0 === c2 ? void 0 : c2.body) ? [3, 8] : [4, o(a2)]; case 7: return t2.sent(), [3, 6]; case 8: return [4, e2(l2, l2.contentWindow)]; case 9: return [2, t2.sent()]; case 10: return null === (u2 = l2.parentNode) || void 0 === u2 || u2.removeChild(l2), [7]; case 11: return [2]; } }); }); } function I(e2) { for (var n2 = function(e3) { for (var n3, t3, r3 = "Unexpected syntax '".concat(e3, "'"), o3 = /^\s*([a-z-]*)(.*)$/i.exec(e3), a3 = o3[1] || void 0, i3 = {}, c2 = /([.:#][\w-]+|\[.+?\])/gi, u2 = function(e4, n4) { i3[e4] = i3[e4] || [], i3[e4].push(n4); }; ; ) { const l2 = c2.exec(o3[2]); if (!l2) break; const s2 = l2[0]; switch (s2[0]) { case ".": u2("class", s2.slice(1)); break; case "#": u2("id", s2.slice(1)); break; case "[": var d2 = /^\[([\w-]+)([~|^$*]?=("(.*?)"|([\w-]+)))?(\s+[is])?\]$/.exec(s2); if (!d2) throw new Error(r3); u2( d2[1], null !== (t3 = null !== (n3 = d2[4]) && void 0 !== n3 ? n3 : d2[5]) && void 0 !== t3 ? t3 : "" ); break; default: throw new Error(r3); } } return [a3, i3]; }(e2), t2 = n2[0], r2 = n2[1], o2 = document.createElement(null != t2 ? t2 : "div"), a2 = 0, i2 = Object.keys(r2); a2 < i2.length; a2++) { const c2 = i2[a2], u2 = r2[c2].join(" "); "style" === c2 ? j(o2.style, u2) : o2.setAttribute(c2, u2); } return o2; } function j(e2, n2) { for (let t2 = 0, r2 = n2.split(";"); t2 < r2.length; t2++) { const o2 = r2[t2], a2 = /^\s*([\w-]+)\s*:\s*(.+?)(\s*!([\w-]+))?\s*$/.exec(o2); if (a2) { const i2 = a2[1], c2 = a2[2], u2 = a2[4]; e2.setProperty(i2, c2, u2 || ""); } } } const A = ["monospace", "sans-serif", "serif"], J = [ "sans-serif-thin", "ARNO PRO", "Agency FB", "Arabic Typesetting", "Arial Unicode MS", "AvantGarde Bk BT", "BankGothic Md BT", "Batang", "Bitstream Vera Sans Mono", "Calibri", "Century", "Century Gothic", "Clarendon", "EUROSTILE", "Franklin Gothic", "Futura Bk BT", "Futura Md BT", "GOTHAM", "Gill Sans", "HELV", "Haettenschweiler", "Helvetica Neue", "Humanst521 BT", "Leelawadee", "Letter Gothic", "Levenim MT", "Lucida Bright", "Lucida Sans", "Menlo", "MS Mincho", "MS Outlook", "MS Reference Specialty", "MS UI Gothic", "MT Extra", "MYRIAD PRO", "Marlett", "Meiryo UI", "Microsoft Uighur", "Minion Pro", "Monotype Corsiva", "PMingLiU", "Pristina", "SCRIPTINA", "Segoe UI Light", "Serifa", "SimHei", "Small Fonts", "Staccato222 BT", "TRAJAN PRO", "Univers CE 55 Medium", "Vrinda", "ZWAdobeF" ]; function H(e2) { return e2.toDataURL(); } let N, P; function z() { const e2 = this; return function() { if (void 0 === P) { const e3 = function() { const n2 = D(); E(n2) ? P = setTimeout(e3, 2500) : (N = n2, P = void 0); }; e3(); } }(), function() { return n(e2, void 0, void 0, function() { let e3; return t(this, function(n2) { switch (n2.label) { case 0: return E(e3 = D()) ? N ? [2, r([], N, true)] : C() ? [ 4, (t2 = document, (t2.exitFullscreen || t2.msExitFullscreen || t2.mozCancelFullScreen || t2.webkitExitFullscreen).call(t2)) ] : [3, 2] : [3, 2]; case 1: n2.sent(), e3 = D(), n2.label = 2; case 2: return E(e3) || (N = e3), [2, e3]; } let t2; }); }