UNPKG

@mediatrack/open-asset

Version:

文档见 [分秒帧开放平台](https://open.mediatrack.cn/#/docs/api/jssdk/upload)

1,094 lines 447 kB
function filenameParser(r) { const m = r.split("."); if (m.length === 1) return [r, ""]; const o = m.pop(); return /([a-z]|\d[a-z]+)/i.test(o) ? [m.join("."), o] : [r, ""]; } var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function getDefaultExportFromCjs(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } var cosJsSdkV5 = { exports: {} }; (function(module, exports) { (function(m, o) { module.exports = o(); })(commonjsGlobal, function() { return ( /******/ function(r) { var m = {}; function o(p) { if (m[p]) return m[p].exports; var b = m[p] = { /******/ i: p, /******/ l: !1, /******/ exports: {} /******/ }; return r[p].call(b.exports, b, b.exports, o), b.l = !0, b.exports; } return o.m = r, o.c = m, o.d = function(p, b, u) { o.o(p, b) || Object.defineProperty(p, b, { enumerable: !0, get: u }); }, o.r = function(p) { typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(p, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(p, "__esModule", { value: !0 }); }, o.t = function(p, b) { if (b & 1 && (p = o(p)), b & 8 || b & 4 && typeof p == "object" && p && p.__esModule) return p; var u = /* @__PURE__ */ Object.create(null); if (o.r(u), Object.defineProperty(u, "default", { enumerable: !0, value: p }), b & 2 && typeof p != "string") for (var T in p) o.d(u, T, function(I) { return p[I]; }.bind(null, T)); return u; }, o.n = function(p) { var b = p && p.__esModule ? ( /******/ function() { return p.default; } ) : ( /******/ function() { return p; } ); return o.d(b, "a", b), b; }, o.o = function(p, b) { return Object.prototype.hasOwnProperty.call(p, b); }, o.p = "/dist/", o(o.s = "./index.js"); }({ /***/ "./index.js": ( /*!******************!*\ !*** ./index.js ***! \******************/ /*! no static exports found */ /***/ function(r, m, o) { var p = o( /*! ./src/cos */ "./src/cos.js" ); r.exports = p; } ), /***/ "./lib/beacon.min.js": ( /*!***************************!*\ !*** ./lib/beacon.min.js ***! \***************************/ /*! no static exports found */ /***/ function(r, m, o) { var p, b, u = o( /*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js" ); (function(T, I) { u(m) == "object" && typeof r < "u" ? r.exports = I() : (p = I, b = typeof p == "function" ? p.call(m, o, m, r) : p, b !== void 0 && (r.exports = b)); })(this, function() { var T = function(s, l) { return T = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(c, S) { c.__proto__ = S; } || function(c, S) { for (var A in S) Object.prototype.hasOwnProperty.call(S, A) && (c[A] = S[A]); }, T(s, l); }, I = function() { return I = Object.assign || function(s) { for (var l, c = 1, S = arguments.length; c < S; c++) for (var A in l = arguments[c]) Object.prototype.hasOwnProperty.call(l, A) && (s[A] = l[A]); return s; }, I.apply(this, arguments); }; function q(g, s, l, c) { return new (l || (l = Promise))(function(S, A) { function M(xe) { try { ve(c.next(xe)); } catch (Y) { A(Y); } } function ee(xe) { try { ve(c.throw(xe)); } catch (Y) { A(Y); } } function ve(xe) { var Y; xe.done ? S(xe.value) : (Y = xe.value, Y instanceof l ? Y : new l(function(Pe) { Pe(Y); })).then(M, ee); } ve((c = c.apply(g, s || [])).next()); }); } function j(g, s) { var l, c, S, A, M = { label: 0, sent: function() { if (1 & S[0]) throw S[1]; return S[1]; }, trys: [], ops: [] }; return A = { next: ee(0), throw: ee(1), return: ee(2) }, typeof Symbol == "function" && (A[Symbol.iterator] = function() { return this; }), A; function ee(ve) { return function(xe) { return function(Y) { if (l) throw new TypeError("Generator is already executing."); for (; M; ) try { if (l = 1, c && (S = 2 & Y[0] ? c.return : Y[0] ? c.throw || ((S = c.return) && S.call(c), 0) : c.next) && !(S = S.call(c, Y[1])).done) return S; switch (c = 0, S && (Y = [2 & Y[0], S.value]), Y[0]) { case 0: case 1: S = Y; break; case 4: return M.label++, { value: Y[1], done: !1 }; case 5: M.label++, c = Y[1], Y = [0]; continue; case 7: Y = M.ops.pop(), M.trys.pop(); continue; default: if (S = M.trys, !((S = S.length > 0 && S[S.length - 1]) || Y[0] !== 6 && Y[0] !== 2)) { M = 0; continue; } if (Y[0] === 3 && (!S || Y[1] > S[0] && Y[1] < S[3])) { M.label = Y[1]; break; } if (Y[0] === 6 && M.label < S[1]) { M.label = S[1], S = Y; break; } if (S && M.label < S[2]) { M.label = S[2], M.ops.push(Y); break; } S[2] && M.ops.pop(), M.trys.pop(); continue; } Y = s.call(g, M); } catch (Pe) { Y = [6, Pe], c = 0; } finally { l = S = 0; } if (5 & Y[0]) throw Y[1]; return { value: Y[0] ? Y[1] : void 0, done: !0 }; }([ve, xe]); }; } } var _ = "__BEACON_", z = "__BEACON_deviceId", X = "last_report_time", W = "sending_event_ids", F = "beacon_config", N = "beacon_config_request_time", K = function() { function g() { var s = this; this.emit = function(l, c) { if (s) { var S, A = s.__EventsList[l]; if (A != null && A.length) { A = A.slice(); for (var M = 0; M < A.length; M++) { S = A[M]; try { var ee = S.callback.apply(s, [c]); if (S.type === 1 && s.remove(l, S.callback), ee === !1) break; } catch (ve) { throw ve; } } } return s; } }, this.__EventsList = {}; } return g.prototype.indexOf = function(s, l) { for (var c = 0; c < s.length; c++) if (s[c].callback === l) return c; return -1; }, g.prototype.on = function(s, l, c) { if (c === void 0 && (c = 0), this) { var S = this.__EventsList[s]; if (S || (S = this.__EventsList[s] = []), this.indexOf(S, l) === -1) { var A = { name: s, type: c || 0, callback: l }; return S.push(A), this; } return this; } }, g.prototype.one = function(s, l) { this.on(s, l, 1); }, g.prototype.remove = function(s, l) { if (this) { var c = this.__EventsList[s]; if (!c) return null; if (!l) { try { delete this.__EventsList[s]; } catch { } return null; } if (c.length) { var S = this.indexOf(c, l); c.splice(S, 1); } return this; } }, g; }(); function w(g, s) { for (var l = {}, c = 0, S = Object.keys(g); c < S.length; c++) { var A = S[c], M = g[A]; if (typeof M == "string") l[E(A)] = E(M); else { if (s) throw new Error("value mast be string !!!!"); l[E(String(A))] = E(String(M)); } } return l; } function E(g) { if (typeof g != "string") return g; try { return g.replace(new RegExp("\\|", "g"), "%7C").replace(new RegExp("\\&", "g"), "%26").replace(new RegExp("\\=", "g"), "%3D").replace(new RegExp("\\+", "g"), "%2B"); } catch { return ""; } } function a(g) { return String(g.A99) + String(g.A100); } var t = function() { }, n = function() { function g(s) { var l = this; this.lifeCycle = new K(), this.uploadJobQueue = [], this.additionalParams = {}, this.delayTime = 0, this._normalLogPipeline = function(c) { if (!c || !c.reduce || !c.length) throw new TypeError("createPipeline 方法需要传入至少有一个 pipe 的数组"); return c.length === 1 ? function(S, A) { c[0](S, A || t); } : c.reduce(function(S, A) { return function(M, ee) { return ee === void 0 && (ee = t), S(M, function(ve) { return A == null ? void 0 : A(ve, ee); }); }; }); }([function(c) { l.send({ url: l.strategy.getUploadUrl(), data: c, method: "post", contentType: "application/json;charset=UTF-8" }, function() { var S = l.config.onReportSuccess; typeof S == "function" && S(JSON.stringify(c.events)); }, function() { var S = l.config.onReportFail; typeof S == "function" && S(JSON.stringify(c.events)); }); }]), function(c, S) { if (!c) throw S instanceof Error ? S : new Error(S); }(!!s.appkey, "appkey must be initial"), this.config = I({}, s); } return g.prototype.onUserAction = function(s, l) { this.preReport(s, l, !1); }, g.prototype.onDirectUserAction = function(s, l) { this.preReport(s, l, !0); }, g.prototype.preReport = function(s, l, c) { s ? this.strategy.isEventUpOnOff() && (this.strategy.isBlackEvent(s) || this.strategy.isSampleEvent(s) || this.onReport(s, l, c)) : this.errorReport.reportError("602", " no eventCode"); }, g.prototype.addAdditionalParams = function(s) { for (var l = 0, c = Object.keys(s); l < c.length; l++) { var S = c[l]; this.additionalParams[S] = s[S]; } }, g.prototype.setChannelId = function(s) { this.commonInfo.channelID = String(s); }, g.prototype.setOpenId = function(s) { this.commonInfo.openid = String(s); }, g.prototype.setUnionid = function(s) { this.commonInfo.unid = String(s); }, g.prototype.getDeviceId = function() { return this.commonInfo.deviceId; }, g.prototype.getCommonInfo = function() { return this.commonInfo; }, g.prototype.removeSendingId = function(s) { try { var l = JSON.parse(this.storage.getItem(W)), c = l.indexOf(s); c != -1 && (l.splice(c, 1), this.storage.setItem(W, JSON.stringify(l))); } catch { } }, g; }(), v = function() { function g(s, l, c, S) { this.requestParams = {}, this.network = S, this.requestParams.attaid = "00400014144", this.requestParams.token = "6478159937", this.requestParams.product_id = s.appkey, this.requestParams.platform = c, this.requestParams.uin = l.deviceId, this.requestParams.model = "", this.requestParams.os = c, this.requestParams.app_version = s.appVersion, this.requestParams.sdk_version = l.sdkVersion, this.requestParams.error_stack = "", this.uploadUrl = s.isOversea ? "https://htrace.wetvinfo.com/kv" : "https://h.trace.qq.com/kv"; } return g.prototype.reportError = function(s, l) { this.requestParams._dc = Math.random(), this.requestParams.error_msg = l, this.requestParams.error_code = s, this.network.get(this.uploadUrl, { params: this.requestParams }).catch(function(c) { }); }, g; }(), d = function() { function g(s, l, c, S, A) { this.strategy = { isEventUpOnOff: !0, httpsUploadUrl: "https://otheve.beacon.qq.com/analytics/v2_upload", requestInterval: 30, blacklist: [], samplelist: [] }, this.realSample = {}, this.appkey = "", this.needQueryConfig = !0, this.appkey = l.appkey, this.storage = S, this.needQueryConfig = s; try { var M = JSON.parse(this.storage.getItem(F)); M && this.processData(M); } catch { } l.isOversea && (this.strategy.httpsUploadUrl = "https://svibeacon.onezapp.com/analytics/v2_upload"), !l.isOversea && this.needRequestConfig() && this.requestConfig(l.appVersion, c, A); } return g.prototype.requestConfig = function(s, l, c) { var S = this; this.storage.setItem(N, Date.now().toString()), c.post("https://oth.str.beacon.qq.com/trpc.beacon.configserver.BeaconConfigService/QueryConfig", { platformId: typeof wx > "u" ? "3" : "4", mainAppKey: this.appkey, appVersion: s, sdkVersion: l.sdkVersion, osVersion: l.userAgent, model: "", packageName: "", params: { A3: l.deviceId } }).then(function(A) { if (A.data.ret == 0) try { var M = JSON.parse(A.data.beaconConfig); M && (S.processData(M), S.storage.setItem(F, A.data.beaconConfig)); } catch { } else S.processData(null), S.storage.setItem(F, ""); }).catch(function(A) { }); }, g.prototype.processData = function(s) { var l, c, S, A, M; this.strategy.isEventUpOnOff = (l = s == null ? void 0 : s.isEventUpOnOff) !== null && l !== void 0 ? l : this.strategy.isEventUpOnOff, this.strategy.httpsUploadUrl = (c = s == null ? void 0 : s.httpsUploadUrl) !== null && c !== void 0 ? c : this.strategy.httpsUploadUrl, this.strategy.requestInterval = (S = s == null ? void 0 : s.requestInterval) !== null && S !== void 0 ? S : this.strategy.requestInterval, this.strategy.blacklist = (A = s == null ? void 0 : s.blacklist) !== null && A !== void 0 ? A : this.strategy.blacklist, this.strategy.samplelist = (M = s == null ? void 0 : s.samplelist) !== null && M !== void 0 ? M : this.strategy.samplelist; for (var ee = 0, ve = this.strategy.samplelist; ee < ve.length; ee++) { var xe = ve[ee].split(","); xe.length == 2 && (this.realSample[xe[0]] = xe[1]); } }, g.prototype.needRequestConfig = function() { if (!this.needQueryConfig) return !1; var s = Number(this.storage.getItem(N)); return Date.now() - s > 60 * this.strategy.requestInterval * 1e3; }, g.prototype.getUploadUrl = function() { return this.strategy.httpsUploadUrl + "?appkey=" + this.appkey; }, g.prototype.isBlackEvent = function(s) { return this.strategy.blacklist.indexOf(s) != -1; }, g.prototype.isEventUpOnOff = function() { return this.strategy.isEventUpOnOff; }, g.prototype.isSampleEvent = function(s) { return !!Object.prototype.hasOwnProperty.call(this.realSample, s) && this.realSample[s] < Math.floor(Math.random() * Math.floor(1e4)); }, g; }(), L = "session_storage_key", U = function() { function g(s, l, c) { this.getSessionStackDepth = 0, this.beacon = c, this.storage = s, this.duration = l, this.appkey = c.config.appkey; } return g.prototype.getSession = function() { this.getSessionStackDepth += 1; var s = this.storage.getItem(L); if (!s) return this.createSession(); var l = "", c = 0; try { var S = JSON.parse(s) || { sessionId: void 0, sessionStart: void 0 }; if (!S.sessionId || !S.sessionStart) return this.createSession(); var A = Number(this.storage.getItem(X)); if (Date.now() - A > this.duration) return this.createSession(); l = S.sessionId, c = S.sessionStart, this.getSessionStackDepth = 0; } catch { } return { sessionId: l, sessionStart: c }; }, g.prototype.createSession = function() { var s = Date.now(), l = { sessionId: this.appkey + "_" + s.toString(), sessionStart: s }; this.storage.setItem(L, JSON.stringify(l)), this.storage.setItem(X, s.toString()); var c = "is_new_user", S = this.storage.getItem(c); return this.getSessionStackDepth <= 1 && this.beacon.onDirectUserAction("rqd_applaunched", { A21: S ? "N" : "Y" }), this.storage.setItem(c, JSON.stringify(!1)), l; }, g; }(); function G() { var g = navigator.userAgent, s = g.indexOf("compatible") > -1 && g.indexOf("MSIE") > -1, l = g.indexOf("Edge") > -1 && !s, c = g.indexOf("Trident") > -1 && g.indexOf("rv:11.0") > -1; if (s) { new RegExp("MSIE (\\d+\\.\\d+);").test(g); var S = parseFloat(RegExp.$1); return S == 7 ? 7 : S == 8 ? 8 : S == 9 ? 9 : S == 10 ? 10 : 6; } return l ? -2 : c ? 11 : -1; } function he(g, s) { var l, c; return (l = "https://tun-cos-1258344701.file.myqcloud.com/fp.js", c === void 0 && (c = Date.now() + "-" + Math.random()), new Promise(function(S, A) { if (document.getElementById(c)) S(void 0); else { var M = document.getElementsByTagName("head")[0], ee = document.createElement("script"); ee.onload = function() { return function() { ee.onload = null, S(void 0); }; }, ee.onerror = function(ve) { ee.onerror = null, M.removeChild(ee), A(ve); }, ee.src = l, ee.id = c, M.appendChild(ee); } })).then(function() { new Fingerprint().getQimei36(g, s); }).catch(function(S) { }), ""; } var P = function() { return (P = Object.assign || function(s) { for (var l, c = 1, S = arguments.length; c < S; c++) for (var A in l = arguments[c]) Object.prototype.hasOwnProperty.call(l, A) && (s[A] = l[A]); return s; }).apply(this, arguments); }, Q, $ = function() { function g(s, l) { l === void 0 && (l = {}), this.reportOptions = {}, this.config = s, this.reportOptions = l; } return g.canUseDB = function() { return !!(window != null && window.indexedDB); }, g.prototype.openDB = function() { var s = this; return new Promise(function(l, c) { if (!g.canUseDB()) return c({ message: "当前不支持 indexeddb" }); var S = s.config, A = S.name, M = S.version, ee = S.stores, ve = indexedDB.open(A, M); ve.onsuccess = function() { s.db = ve.result, l(), P({ result: 1, func: "open", params: JSON.stringify(s.config) }, s.reportOptions); }, ve.onerror = function(xe) { var Y, Pe; c(xe), P({ result: 0, func: "open", params: JSON.stringify(s.config), error_msg: (Pe = (Y = xe.target) === null || Y === void 0 ? void 0 : Y.error) === null || Pe === void 0 ? void 0 : Pe.message }, s.reportOptions); }, ve.onupgradeneeded = function() { s.db = ve.result; try { ee == null || ee.forEach(function(xe) { s.createStore(xe); }); } catch (xe) { P({ result: 0, func: "open", params: JSON.stringify(s.config), error_msg: xe.message }, s.reportOptions), c(xe); } }; }); }, g.prototype.useStore = function(s) { return this.storeName = s, this; }, g.prototype.deleteDB = function() { var s = this; return this.closeDB(), new Promise(function(l, c) { var S = indexedDB.deleteDatabase(s.config.name); S.onsuccess = function() { return l(); }, S.onerror = c; }); }, g.prototype.closeDB = function() { var s; (s = this.db) === null || s === void 0 || s.close(), this.db = null; }, g.prototype.getStoreCount = function() { var s = this; return new Promise(function(l, c) { var S = s.getStore("readonly").count(); S.onsuccess = function() { return l(S.result); }, S.onerror = c; }); }, g.prototype.clearStore = function() { var s = this; return new Promise(function(l, c) { var S = s.getStore("readwrite").clear(); S.onsuccess = function() { return l(); }, S.onerror = c; }); }, g.prototype.add = function(s, l) { var c = this; return new Promise(function(S, A) { var M = c.getStore("readwrite").add(s, l); M.onsuccess = function() { S(M.result); }, M.onerror = A; }); }, g.prototype.put = function(s, l) { var c = this; return new Promise(function(S, A) { var M = c.getStore("readwrite").put(s, l); M.onsuccess = function() { S(M.result); }, M.onerror = A; }); }, g.prototype.getStoreAllData = function() { var s = this; return new Promise(function(l, c) { var S = s.getStore("readonly").openCursor(), A = []; S.onsuccess = function() { var M; if (!((M = S.result) === null || M === void 0) && M.value) { var ee = S.result.value; A.push(ee), S.result.continue(); } else l(A); }, S.onerror = c; }); }, g.prototype.getDataRangeByIndex = function(s, l, c, S, A) { var M = this; return new Promise(function(ee, ve) { var xe = M.getStore().index(s), Y = IDBKeyRange.bound(l, c, S, A), Pe = [], ke = xe.openCursor(Y); ke.onsuccess = function() { var Ue; !((Ue = ke == null ? void 0 : ke.result) === null || Ue === void 0) && Ue.value ? (Pe.push(ke == null ? void 0 : ke.result.value), ke == null || ke.result.continue()) : ee(Pe); }, ke.onerror = ve; }); }, g.prototype.removeDataByIndex = function(s, l, c, S, A) { var M = this; return new Promise(function(ee, ve) { var xe = M.getStore("readwrite").index(s), Y = IDBKeyRange.bound(l, c, S, A), Pe = xe.openCursor(Y), ke = 0; Pe.onsuccess = function(Ue) { var f = Ue.target.result; f ? (ke += 1, f.delete(), f.continue()) : ee(ke); }, Pe.onerror = ve; }); }, g.prototype.createStore = function(s) { var l = s.name, c = s.indexes, S = c === void 0 ? [] : c, A = s.options; if (this.db) { this.db.objectStoreNames.contains(l) && this.db.deleteObjectStore(l); var M = this.db.createObjectStore(l, A); S.forEach(function(ee) { M.createIndex(ee.indexName, ee.keyPath, ee.options); }); } }, g.prototype.getStore = function(s) { var l; return s === void 0 && (s = "readonly"), (l = this.db) === null || l === void 0 ? void 0 : l.transaction(this.storeName, s).objectStore(this.storeName); }, g; }(), J = "event_table_v3", te = "eventId", re = function() { function g(s) { this.isReady = !1, this.taskQueue = Promise.resolve(), this.db = new $({ name: "Beacon_" + s + "_V3", version: 1, stores: [{ name: J, options: { keyPath: te }, indexes: [{ indexName: te, keyPath: te, options: { unique: !0 } }] }] }), this.open(); } return g.prototype.getCount = function() { var s = this; return this.readyExec(function() { return s.db.getStoreCount(); }); }, g.prototype.setItem = function(s, l) { var c = this; return this.readyExec(function() { return c.db.add({ eventId: s, value: l }); }); }, g.prototype.getItem = function(s) { return q(this, void 0, void 0, function() { var l = this; return j(this, function(c) { return [2, this.readyExec(function() { return l.db.getDataRangeByIndex(te, s, s); })]; }); }); }, g.prototype.removeItem = function(s) { var l = this; return this.readyExec(function() { return l.db.removeDataByIndex(te, s, s); }); }, g.prototype.updateItem = function(s, l) { var c = this; return this.readyExec(function() { return c.db.put({ eventId: s, value: l }); }); }, g.prototype.iterate = function(s) { var l = this; return this.readyExec(function() { return l.db.getStoreAllData().then(function(c) { c.forEach(function(S) { s(S.value); }); }); }); }, g.prototype.open = function() { return q(this, void 0, void 0, function() { var s = this; return j(this, function(l) { switch (l.label) { case 0: return this.taskQueue = this.taskQueue.then(function() { return s.db.openDB(); }), [4, this.taskQueue]; case 1: return l.sent(), this.isReady = !0, this.db.useStore(J), [2]; } }); }); }, g.prototype.readyExec = function(s) { return this.isReady ? s() : (this.taskQueue = this.taskQueue.then(function() { return s(); }), this.taskQueue); }, g; }(), le = function() { function g(s) { this.keyObject = {}, this.storage = s; } return g.prototype.getCount = function() { return this.storage.getStoreCount(); }, g.prototype.removeItem = function(s) { this.storage.removeItem(s), delete this.keyObject[s]; }, g.prototype.setItem = function(s, l) { var c = JSON.stringify(l); this.storage.setItem(s, c), this.keyObject[s] = l; }, g.prototype.iterate = function(s) { for (var l = Object.keys(this.keyObject), c = 0; c < l.length; c++) { var S = this.storage.getItem(l[c]); s(JSON.parse(S)); } }, g; }(), ue = function() { function g(s, l) { var c = this; this.dbEventCount = 0, G() > 0 || !window.indexedDB || /X5Lite/.test(navigator.userAgent) ? (this.store = new le(l), this.dbEventCount = this.store.getCount()) : (this.store = new re(s), this.getCount().then(function(S) { c.dbEventCount = S; }).catch(function(S) { })); } return g.prototype.getCount = function() { return q(this, void 0, void 0, function() { return j(this, function(s) { switch (s.label) { case 0: return s.trys.push([0, 2, , 3]), [4, this.store.getCount()]; case 1: return [2, s.sent()]; case 2: return s.sent(), [2, Promise.reject()]; case 3: return [2]; } }); }); }, g.prototype.insertEvent = function(s, l) { return q(this, void 0, void 0, function() { var c, S; return j(this, function(A) { switch (A.label) { case 0: if (this.dbEventCount >= 1e4) return [2, Promise.reject()]; c = a(s.mapValue), A.label = 1; case 1: return A.trys.push([1, 3, , 4]), this.dbEventCount++, [4, this.store.setItem(c, s)]; case 2: return [2, A.sent()]; case 3: return S = A.sent(), l && l(S, s), this.dbEventCount--, [2, Promise.reject()]; case 4: return [2]; } }); }); }, g.prototype.getEvents = function() { return q(this, void 0, void 0, function() { var s; return j(this, function(l) { switch (l.label) { case 0: s = [], l.label = 1; case 1: return l.trys.push([1, 3, , 4]), [4, this.store.iterate(function(c) { s.push(c); })]; case 2: return l.sent(), [2, Promise.all(s)]; case 3: return l.sent(), [2, Promise.all(s)]; case 4: return [2]; } }); }); }, g.prototype.removeEvent = function(s) { return q(this, void 0, void 0, function() { var l; return j(this, function(c) { switch (c.label) { case 0: l = a(s.mapValue), c.label = 1; case 1: return c.trys.push([1, 3, , 4]), this.dbEventCount--, [4, this.store.removeItem(l)]; case 2: return [2, c.sent()]; case 3: return c.sent(), this.dbEventCount++, [2, Promise.reject()]; case 4: return [2]; } }); }); }, g; }(), ne = function() { return (ne = Object.assign || function(s) { for (var l, c = 1, S = arguments.length; c < S; c++) for (var A in l = arguments[c]) Object.prototype.hasOwnProperty.call(l, A) && (s[A] = l[A]); return s; }).apply(this, arguments); }; function pe(g) { try { return decodeURIComponent(g.replace(/\+/g, " ")); } catch { return null; } } function se(g, s) { var l = [null, void 0, "", NaN].includes(g); if (s.isSkipEmpty && l) return null; var c = !s.isSkipEmpty && l ? "" : g; try { return s.encode ? encodeURIComponent(c) : c; } catch { return null; } } function de(g, s) { s === void 0 && (s = { encode: !0, isSkipEmpty: !1 }); var l = g.url, c = g.query, S = c === void 0 ? {} : c, A = g.hash, M = l.split("#"), ee = M[0], ve = M[1], xe = ve === void 0 ? "" : ve, Y = ee.split("?")[0], Pe = [], ke = se(A || xe, s), Ue = ne(ne({}, function(f) { var x = f.split("#"), B = x[0], V = x[1], ce = V === void 0 ? "" : V, Be = B.split("?"), Me = Be[0], Ke = Be[1], Je = Ke === void 0 ? "" : Ke, We = pe(ce), qe = /* @__PURE__ */ Object.create(null); return Je.split("&").forEach(function(Ve) { var He = Ve.split("="), $e = He[0], Ge = He[1], Xe = Ge === void 0 ? "" : Ge, fe = pe($e), Fe = pe(Xe); fe === null || Fe === null || fe === "" && Fe === "" || qe[fe] || (qe[fe] = Fe); }), { url: Me, query: qe, hash: We }; }(l).query), S); return Object.keys(Ue).forEach(function(f) { var x = se(f, s), B = se(Ue[f], s); x !== null && B !== null && Pe.push(x + "=" + B); }), Y + (Pe.length ? "?" + Pe.join("&") : "") + (ke ? "#" + ke : ""); } function ae(g, s) { return new Promise(function(l, c) { if (s && document.querySelectorAll("script[data-tag=" + s + "]").length) return l(); var S = document.createElement("script"), A = ne({ type: "text/javascript", charset: "utf-8" }, g); Object.keys(A).forEach(function(M) { return function(ee, ve, xe) { if (ee) return xe === void 0 ? ee.getAttribute(ve) : ee.setAttribute(ve, xe); }(S, M, A[M]); }), s && (S.dataset.tag = s), S.onload = function() { return l(); }, S.onreadystatechange = function() { var M = S.readyState; ["complete", "loaded"].includes(M) && (S.onreadystatechange = null, l()); }, S.onerror = c, document.body.appendChild(S); }); } (function(g) { g[g.equal = 0] = "equal", g[g.low = -1] = "low", g[g.high = 1] = "high"; })(Q || (Q = {})); var Z = function() { return (Z = Object.assign || function(s) { for (var l, c = 1, S = arguments.length; c < S; c++) for (var A in l = arguments[c]) Object.prototype.hasOwnProperty.call(l, A) && (s[A] = l[A]); return s; }).apply(this, arguments); }; function ge(g, s, l, c) { return new (l || (l = Promise))(function(S, A) { function M(xe) { try { ve(c.next(xe)); } catch (Y) { A(Y); } } function ee(xe) { try { ve(c.throw(xe)); } catch (Y) { A(Y); } } function ve(xe) { var Y; xe.done ? S(xe.value) : (Y = xe.value, Y instanceof l ? Y : new l(function(Pe) { Pe(Y); })).then(M, ee); } ve((c = c.apply(g, s || [])).next()); }); } function Ce(g, s) { var l, c, S, A, M = { label: 0, sent: function() { if (1 & S[0]) throw S[1]; return S[1]; }, trys: [], ops: [] }; return A = { next: ee(0), throw: ee(1), return: ee(2) }, typeof Symbol == "function" && (A[Symbol.iterator] = function() { return this; }), A; function ee(ve) { return function(xe) { return function(Y) { if (l) throw new TypeError("Generator is already executing."); for (; M; ) try { if (l = 1, c && (S = 2 & Y[0] ? c.return : Y[0] ? c.throw || ((S = c.return) && S.call(c), 0) : c.next) && !(S = S.call(c, Y[1])).done) return S; switch (c = 0, S && (Y = [2 & Y[0], S.value]), Y[0]) { case 0: case 1: S = Y; break; case 4: return M.label++, { value: Y[1], done: !1 }; case 5: M.label++, c = Y[1], Y = [0]; continue; case 7: Y = M.ops.pop(), M.trys.pop(); continue; default: if (!((S = (S = M.trys).length > 0 && S[S.length - 1]) || Y[0] !== 6 && Y[0] !== 2)) { M = 0; continue; } if (Y[0] === 3 && (!S || Y[1] > S[0] && Y[1] < S[3])) { M.label = Y[1]; break; } if (Y[0] === 6 && M.label < S[1]) { M.label = S[1], S = Y; break; } if (S && M.label < S[2]) { M.label = S[2], M.ops.push(Y); break; } S[2] && M.ops.pop(), M.trys.pop(); continue; } Y = s.call(g, M); } catch (Pe) { Y = [6, Pe], c = 0; } finally { l = S = 0; } if (5 & Y[0]) throw Y[1]; return { value: Y[0] ? Y[1] : void 0, done: !0 }; }([ve, xe]); }; } } var me = function() { function g() { this.interceptors = []; } return g.prototype.use = function(s, l) { return this.interceptors.push({ resolved: s, rejected: l }), this.interceptors.length - 1; }, g.prototype.traverse = function(s, l) { l === void 0 && (l = !1); var c = Promise.resolve(s); return (l ? Array.prototype.reduceRight : Array.prototype.reduce).call(this.interceptors, function(S, A) { if (A) { var M = A.resolved, ee = A.rejected; c = c.then(M, ee); } return S; }, ""), c; }, g.prototype.eject = function(s) { this.interceptors[s] && (this.interceptors[s] = null); }, g; }(), ye = { defaults: { timeout: 0, method: "GET", mode: "cors", redirect: "follow", credentials: "same-origin" }, headers: { common: { Accept: "application/json, text/plain, */*" }, POST: { "Content-Type": "application/x-www-form-urlencoded" }, PUT: { "Content-Type": "application/x-www-form-urlencoded" }, PATCH: { "Content-Type": "application/x-www-form-urlencoded" } }, baseURL: "", polyfillUrl: "https://vm.gtimg.cn/comps/script/fetch.min.js", interceptors: { request: new me(), response: new me() } }, Se = /^([a-z][a-z\d+\-.]*:)?\/\//i, Te = Object.prototype.toString; function Re(g) { return ge(this, void 0, void 0, function() { var s; return Ce(this, function(l) { switch (l.label) { case 0: if (window.fetch) return [2]; l.label = 1; case 1: return l.trys.push([1, 3, , 4]), [4, ae({ src: g })]; case 2: return l.sent(), [3, 4]; case 3: throw s = l.sent(), new Error("加载 polyfill " + g + " 失败: " + s.message); case 4: return [2]; } }); }); } function we(g) { return ["Accept", "Content-Type"].forEach(function(s) { return l = s, void ((c = g.headers) && Object.keys(c).forEach(function(S) { S !== l && S.toUpperCase() === l.toUpperCase() && (c[l] = c[S], delete c[S]); })); var l, c; }), function(s) { if (Te.call(s) !== "[object Object]") return !1; var l