UNPKG

@kwai-video-team/kwai-player-web

Version:

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

1,274 lines (1,273 loc) 499 kB
var yl = Object.defineProperty; var Xn = Object.getOwnPropertySymbols; var El = Object.prototype.hasOwnProperty, bl = Object.prototype.propertyIsEnumerable; var eo = (i, e, o) => e in i ? yl(i, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : i[e] = o, to = (i, e) => { for (var o in e || (e = {})) El.call(e, o) && eo(i, o, e[o]); if (Xn) for (var o of Xn(e)) bl.call(e, o) && eo(i, o, e[o]); return i; }; Number.isFinite || (Number.isFinite = (i) => typeof i == "number" && isFinite(i)); Array.prototype.find || (Array.prototype.find = function(i, e) { if (this === null || this === void 0) throw new TypeError("Array.prototype.find called on null or undefined"); if (typeof i != "function") throw new TypeError("callback must be a function"); const o = Object(this), l = o.length >>> 0; for (let c = 0; c < l; c++) if (i.call(e, o[c], c, o)) return o[c]; }); Array.prototype.findIndex || (Array.prototype.findIndex = function(i, e) { if (this === null || this === void 0) throw new TypeError("Array.prototype.findIndex called on null or undefined"); if (typeof i != "function") throw new TypeError("callback must be a function"); const o = Object(this), l = o.length >>> 0; for (let c = 0; c < l; c++) if (c in o && i.call(e, o[c], c, o)) return c; return -1; }); Array.prototype.fill || (Array.prototype.fill = function(i, e = 0, o = this.length) { if (this === null || this === void 0) throw new TypeError("Array.prototype.fill called on null or undefined"); const l = Object(this), c = l.length >>> 0, h = e >> 0, A = o >> 0, p = h < 0 ? Math.max(c + h, 0) : Math.min(h, c), T = A < 0 ? Math.max(c + A, 0) : Math.min(A, c); for (let S = p; S < T; S++) l[S] = i; return l; }); var Tl = Object.defineProperty, Rl = (i, e, o) => e in i ? Tl(i, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : i[e] = o, Mo = (i, e, o) => (Rl(i, typeof e != "symbol" ? e + "" : e, o), o), jt = function(i) { var e = {}; function o(l) { if (e[l]) return e[l].exports; var c = e[l] = { i: l, l: !1, exports: {} }; return i[l].call(c.exports, c, c.exports, o), c.l = !0, c.exports; } return o.m = i, o.c = e, o.d = function(l, c, h) { o.o(l, c) || Object.defineProperty(l, c, { enumerable: !0, get: h }); }, o.r = function(l) { typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(l, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(l, "__esModule", { value: !0 }); }, o.t = function(l, c) { if (1 & c && (l = o(l)), 8 & c || 4 & c && typeof l == "object" && l && l.__esModule) return l; var h = /* @__PURE__ */ Object.create(null); if (o.r(h), Object.defineProperty(h, "default", { enumerable: !0, value: l }), 2 & c && typeof l != "string") for (var A in l) o.d(h, A, function(p) { return l[p]; }.bind(null, A)); return h; }, o.n = function(l) { var c = l && l.__esModule ? function() { return l.default; } : function() { return l; }; return o.d(c, "a", c), c; }, o.o = function(l, c) { return Object.prototype.hasOwnProperty.call(l, c); }, o.p = "", o(o.s = 8); }([function(i, e, o) { var l = o(5); function c(h, A) { for (var p = 0; p < A.length; p++) { var T = A[p]; T.enumerable = T.enumerable || !1, T.configurable = !0, "value" in T && (T.writable = !0), Object.defineProperty(h, l(T.key), T); } } i.exports = function(h, A, p) { return A && c(h.prototype, A), p && c(h, p), Object.defineProperty(h, "prototype", { writable: !1 }), h; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e) { function o(l) { return i.exports = o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(c) { return typeof c; } : function(c) { return c && typeof Symbol == "function" && c.constructor === Symbol && c !== Symbol.prototype ? "symbol" : typeof c; }, i.exports.__esModule = !0, i.exports.default = i.exports, o(l); } i.exports = o, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e, o) { var l = o(7)(); i.exports = l; try { regeneratorRuntime = l; } catch (c) { typeof globalThis == "object" ? globalThis.regeneratorRuntime = l : Function("r", "regeneratorRuntime = r")(l); } }, function(i, e) { function o() { return i.exports = o = Object.assign ? Object.assign.bind() : function(l) { for (var c = 1; c < arguments.length; c++) { var h = arguments[c]; for (var A in h) Object.prototype.hasOwnProperty.call(h, A) && (l[A] = h[A]); } return l; }, i.exports.__esModule = !0, i.exports.default = i.exports, o.apply(this, arguments); } i.exports = o, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e) { function o(l, c, h, A, p, T, S) { try { var f = l[T](S), L = f.value; } catch (b) { return void h(b); } f.done ? c(L) : Promise.resolve(L).then(A, p); } i.exports = function(l) { return function() { var c = this, h = arguments; return new Promise(function(A, p) { var T = l.apply(c, h); function S(L) { o(T, A, p, S, f, "next", L); } function f(L) { o(T, A, p, S, f, "throw", L); } S(void 0); }); }; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e, o) { var l = o(1).default, c = o(6); i.exports = function(h) { var A = c(h, "string"); return l(A) == "symbol" ? A : A + ""; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e, o) { var l = o(1).default; i.exports = function(c, h) { if (l(c) != "object" || !c) return c; var A = c[Symbol.toPrimitive]; if (A !== void 0) { var p = A.call(c, h || "default"); if (l(p) != "object") return p; throw new TypeError("@@toPrimitive must return a primitive value."); } return (h === "string" ? String : Number)(c); }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e, o) { var l = o(1).default; function c() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ i.exports = c = function() { return A; }, i.exports.__esModule = !0, i.exports.default = i.exports; var h, A = {}, p = Object.prototype, T = p.hasOwnProperty, S = Object.defineProperty || function(U, H, J) { U[H] = J.value; }, f = typeof Symbol == "function" ? Symbol : {}, L = f.iterator || "@@iterator", b = f.asyncIterator || "@@asyncIterator", C = f.toStringTag || "@@toStringTag"; function w(U, H, J) { return Object.defineProperty(U, H, { value: J, enumerable: !0, configurable: !0, writable: !0 }), U[H]; } try { w({}, ""); } catch (U) { w = function(H, J, oe) { return H[J] = oe; }; } function I(U, H, J, oe) { var ee = H && H.prototype instanceof R ? H : R, pe = Object.create(ee.prototype), Ce = new te(oe || []); return S(pe, "_invoke", { value: O(U, J, Ce) }), pe; } function D(U, H, J) { try { return { type: "normal", arg: U.call(H, J) }; } catch (oe) { return { type: "throw", arg: oe }; } } A.wrap = I; var g = "suspendedStart", y = "executing", m = "completed", E = {}; function R() { } function k() { } function P() { } var M = {}; w(M, L, function() { return this; }); var Y = Object.getPrototypeOf, re = Y && Y(Y(ie([]))); re && re !== p && T.call(re, L) && (M = re); var he = P.prototype = R.prototype = Object.create(M); function q(U) { ["next", "throw", "return"].forEach(function(H) { w(U, H, function(J) { return this._invoke(H, J); }); }); } function F(U, H) { function J(ee, pe, Ce, Te) { var Oe = D(U[ee], U, pe); if (Oe.type !== "throw") { var Z = Oe.arg, rt = Z.value; return rt && l(rt) == "object" && T.call(rt, "__await") ? H.resolve(rt.__await).then(function(xe) { J("next", xe, Ce, Te); }, function(xe) { J("throw", xe, Ce, Te); }) : H.resolve(rt).then(function(xe) { Z.value = xe, Ce(Z); }, function(xe) { return J("throw", xe, Ce, Te); }); } Te(Oe.arg); } var oe; S(this, "_invoke", { value: function(ee, pe) { function Ce() { return new H(function(Te, Oe) { J(ee, pe, Te, Oe); }); } return oe = oe ? oe.then(Ce, Ce) : Ce(); } }); } function O(U, H, J) { var oe = g; return function(ee, pe) { if (oe === y) throw Error("Generator is already running"); if (oe === m) { if (ee === "throw") throw pe; return { value: h, done: !0 }; } for (J.method = ee, J.arg = pe; ; ) { var Ce = J.delegate; if (Ce) { var Te = B(Ce, J); if (Te) { if (Te === E) continue; return Te; } } if (J.method === "next") J.sent = J._sent = J.arg; else if (J.method === "throw") { if (oe === g) throw oe = m, J.arg; J.dispatchException(J.arg); } else J.method === "return" && J.abrupt("return", J.arg); oe = y; var Oe = D(U, H, J); if (Oe.type === "normal") { if (oe = J.done ? m : "suspendedYield", Oe.arg === E) continue; return { value: Oe.arg, done: J.done }; } Oe.type === "throw" && (oe = m, J.method = "throw", J.arg = Oe.arg); } }; } function B(U, H) { var J = H.method, oe = U.iterator[J]; if (oe === h) return H.delegate = null, J === "throw" && U.iterator.return && (H.method = "return", H.arg = h, B(U, H), H.method === "throw") || J !== "return" && (H.method = "throw", H.arg = new TypeError("The iterator does not provide a '" + J + "' method")), E; var ee = D(oe, U.iterator, H.arg); if (ee.type === "throw") return H.method = "throw", H.arg = ee.arg, H.delegate = null, E; var pe = ee.arg; return pe ? pe.done ? (H[U.resultName] = pe.value, H.next = U.nextLoc, H.method !== "return" && (H.method = "next", H.arg = h), H.delegate = null, E) : pe : (H.method = "throw", H.arg = new TypeError("iterator result is not an object"), H.delegate = null, E); } function K(U) { var H = { tryLoc: U[0] }; 1 in U && (H.catchLoc = U[1]), 2 in U && (H.finallyLoc = U[2], H.afterLoc = U[3]), this.tryEntries.push(H); } function W(U) { var H = U.completion || {}; H.type = "normal", delete H.arg, U.completion = H; } function te(U) { this.tryEntries = [{ tryLoc: "root" }], U.forEach(K, this), this.reset(!0); } function ie(U) { if (U || U === "") { var H = U[L]; if (H) return H.call(U); if (typeof U.next == "function") return U; if (!isNaN(U.length)) { var J = -1, oe = function ee() { for (; ++J < U.length; ) if (T.call(U, J)) return ee.value = U[J], ee.done = !1, ee; return ee.value = h, ee.done = !0, ee; }; return oe.next = oe; } } throw new TypeError(l(U) + " is not iterable"); } return k.prototype = P, S(he, "constructor", { value: P, configurable: !0 }), S(P, "constructor", { value: k, configurable: !0 }), k.displayName = w(P, C, "GeneratorFunction"), A.isGeneratorFunction = function(U) { var H = typeof U == "function" && U.constructor; return !!H && (H === k || (H.displayName || H.name) === "GeneratorFunction"); }, A.mark = function(U) { return Object.setPrototypeOf ? Object.setPrototypeOf(U, P) : (U.__proto__ = P, w(U, C, "GeneratorFunction")), U.prototype = Object.create(he), U; }, A.awrap = function(U) { return { __await: U }; }, q(F.prototype), w(F.prototype, b, function() { return this; }), A.AsyncIterator = F, A.async = function(U, H, J, oe, ee) { ee === void 0 && (ee = Promise); var pe = new F(I(U, H, J, oe), ee); return A.isGeneratorFunction(H) ? pe : pe.next().then(function(Ce) { return Ce.done ? Ce.value : pe.next(); }); }, q(he), w(he, C, "Generator"), w(he, L, function() { return this; }), w(he, "toString", function() { return "[object Generator]"; }), A.keys = function(U) { var H = Object(U), J = []; for (var oe in H) J.push(oe); return J.reverse(), function ee() { for (; J.length; ) { var pe = J.pop(); if (pe in H) return ee.value = pe, ee.done = !1, ee; } return ee.done = !0, ee; }; }, A.values = ie, te.prototype = { constructor: te, reset: function(U) { if (this.prev = 0, this.next = 0, this.sent = this._sent = h, this.done = !1, this.delegate = null, this.method = "next", this.arg = h, this.tryEntries.forEach(W), !U) for (var H in this) H.charAt(0) === "t" && T.call(this, H) && !isNaN(+H.slice(1)) && (this[H] = h); }, stop: function() { this.done = !0; var U = this.tryEntries[0].completion; if (U.type === "throw") throw U.arg; return this.rval; }, dispatchException: function(U) { if (this.done) throw U; var H = this; function J(Oe, Z) { return pe.type = "throw", pe.arg = U, H.next = Oe, Z && (H.method = "next", H.arg = h), !!Z; } for (var oe = this.tryEntries.length - 1; oe >= 0; --oe) { var ee = this.tryEntries[oe], pe = ee.completion; if (ee.tryLoc === "root") return J("end"); if (ee.tryLoc <= this.prev) { var Ce = T.call(ee, "catchLoc"), Te = T.call(ee, "finallyLoc"); if (Ce && Te) { if (this.prev < ee.catchLoc) return J(ee.catchLoc, !0); if (this.prev < ee.finallyLoc) return J(ee.finallyLoc); } else if (Ce) { if (this.prev < ee.catchLoc) return J(ee.catchLoc, !0); } else { if (!Te) throw Error("try statement without catch or finally"); if (this.prev < ee.finallyLoc) return J(ee.finallyLoc); } } } }, abrupt: function(U, H) { for (var J = this.tryEntries.length - 1; J >= 0; --J) { var oe = this.tryEntries[J]; if (oe.tryLoc <= this.prev && T.call(oe, "finallyLoc") && this.prev < oe.finallyLoc) { var ee = oe; break; } } ee && (U === "break" || U === "continue") && ee.tryLoc <= H && H <= ee.finallyLoc && (ee = null); var pe = ee ? ee.completion : {}; return pe.type = U, pe.arg = H, ee ? (this.method = "next", this.next = ee.finallyLoc, E) : this.complete(pe); }, complete: function(U, H) { if (U.type === "throw") throw U.arg; return U.type === "break" || U.type === "continue" ? this.next = U.arg : U.type === "return" ? (this.rval = this.arg = U.arg, this.method = "return", this.next = "end") : U.type === "normal" && H && (this.next = H), E; }, finish: function(U) { for (var H = this.tryEntries.length - 1; H >= 0; --H) { var J = this.tryEntries[H]; if (J.finallyLoc === U) return this.complete(J.completion, J.afterLoc), W(J), E; } }, catch: function(U) { for (var H = this.tryEntries.length - 1; H >= 0; --H) { var J = this.tryEntries[H]; if (J.tryLoc === U) { var oe = J.completion; if (oe.type === "throw") { var ee = oe.arg; W(J); } return ee; } } throw Error("illegal catch attempt"); }, delegateYield: function(U, H, J) { return this.delegate = { iterator: ie(U), resultName: H, nextLoc: J }, this.method === "next" && (this.arg = h), E; } }, A; } i.exports = c, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, e, o) { o.r(e), o.d(e, "KwaiVideoLocalLog", function() { return he; }), o.d(e, "LogLevel", function() { return b; }), o.d(e, "DefaultLogger", function() { return D; }), o.d(e, "Logger", function() { return I; }), o.d(e, "printVersion", function() { return T; }), o.d(e, "DEFAULT_LOG_LEVEL", function() { return C; }); var l = o(0), c = o.n(l), h = o(3), A = o.n(h), p = { idbName: "kwai-video-local-log", idbMaxDataCount: 25e3, idbMaxFoldLog: 20, maxLogLen: 4096 }; function T(q, F) { console.log("%c " + q + " %c " + F + " %c", "background:#35495e ; padding: 1px; border-radius: 4px 0 0 4px; color: #fff", "background:#ffa483 ; padding: 1px; border-radius: 0 4px 4px 0; color: #fff", "background:transparent"); } var S = function() { function q() { this.timeout = 6048e5; } var F = q.prototype; return F.write = function(O, B) { if (q.available) try { localStorage.setItem(O, JSON.stringify({ value: B, time: Date.now() })); } catch (K) { } }, F.read = function(O, B) { if (B === void 0 && (B = !0), q.available) try { var K = localStorage.getItem(O); if (K) { var W = JSON.parse(K), te = W.value, ie = W.time, U = ie === void 0 ? 0 : ie; if (!B || Date.now() - U < (typeof B == "number" ? B : this.timeout)) return te; } } catch (H) { } }, c()(q, null, [{ key: "available", get: function() { if (q._available === void 0) try { localStorage.setItem("alg", "test"), q._available = !0; } catch (O) { q._available = !1; } return q._available; } }]); }(); S._available = void 0; var f, L = S, b = function(q) { return q.NONE = "none", q.ERROR = "e", q.WARN = "w", q.INFO = "i", q.DEBUG = "d", q.VERBOSE = "v", q; }({}), C = b.ERROR, w = ((f = {})[b.NONE] = { value: 1, str: "N" }, f[b.ERROR] = { value: 100, str: "E" }, f[b.WARN] = { value: 200, str: "W" }, f[b.INFO] = { value: 300, str: "I" }, f[b.DEBUG] = { value: 400, str: "D" }, f[b.VERBOSE] = { value: 500, str: "V" }, f), I = function() { function q(O) { if (this._name = "kwai-v", this._level = C, this._id = -1, this._output = void 0, this._workerTag = "main", typeof location < "u" && location.protocol === "blob:") { var B, K = location.href.split("/"), W = (B = K[K.length - 1]) == null ? void 0 : B.match(/(\w+)-/); W && (this._workerTag = O ? O + "-" + W[1] : W[1]); } else O && (this._workerTag = O); } q.loadLogLevel = function(O, B) { if (B === void 0 && (B = !0), location.href) { var K = new RegExp(O + "=([a-z]{1})"), W = location.href.match(K); if (W && W.length > 1) { var te = W[1]; if (this._isValueInLevel(te)) return te; } } var ie = new L().read(O, B); if (this._isValueInLevel(ie)) return ie; }, q.saveLogLevel = function(O, B) { this._isValueInLevel(B) && new L().write(O, B); }, q._isValueInLevel = function(O) { return Object.values(b).indexOf(O) !== -1; }; var F = q.prototype; return F.setOutput = function(O) { return this._output = O, this; }, F.setLevel = function(O) { return this._level = O, this; }, F.setId = function(O) { return this._id = O, this; }, F.setName = function(O) { return this._name = O, this; }, F.getLevel = function() { return this._level; }, F.getOutput = function() { return this._output; }, F.hasOutput = function() { return !!this._output; }, F.e = function(O) { if (this._isLevelEnabled(this._level, b.ERROR)) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; var te = this._printLog(b.ERROR, O, K); try { var ie; (ie = this._output) == null || ie.e.apply(ie, [te].concat(K)); } catch (U) { } } }, F.w = function(O) { if (this._isLevelEnabled(this._level, b.WARN)) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; var te = this._printLog(b.WARN, O, K); try { var ie; (ie = this._output) == null || ie.w.apply(ie, [te].concat(K)); } catch (U) { } } }, F.i = function(O) { if (this._isLevelEnabled(this._level, b.INFO)) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; var te = this._printLog(b.INFO, O, K); try { var ie; (ie = this._output) == null || ie.i.apply(ie, [te].concat(K)); } catch (U) { } } }, F.d = function(O) { if (this._isLevelEnabled(this._level, b.DEBUG)) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; var te = this._printLog(b.DEBUG, O, K); try { var ie; (ie = this._output) == null || ie.d.apply(ie, [te].concat(K)); } catch (U) { } } }, F.v = function(O) { if (this._isLevelEnabled(this._level, b.VERBOSE)) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; var te = this._printLog(b.VERBOSE, O, K); try { var ie; (ie = this._output) == null || ie.v.apply(ie, [te].concat(K)); } catch (U) { } } }, F._isLevelEnabled = function(O, B) { return w[O].value >= w[B].value; }, F._printLog = function(O, B, K) { var W, te, ie = typeof B; if (ie === "object") B = ((te = B) == null ? void 0 : te.constructor.name) || "unknown"; else if (ie === "function") { var U; B = ((U = Object.getOwnPropertyDescriptor(B, "name")) == null ? void 0 : U.value) || "unknown"; } var H, J, oe = (((W = w[O]) == null ? void 0 : W.str) || "") + "|" + this._name + "[" + (typeof this._id == "function" ? this._id() : this._id) + "][" + this._workerTag + "]::" + B; return O === b.ERROR ? (H = console).error.apply(H, [oe].concat(K.slice(0))) : (J = console).log.apply(J, [oe].concat(K.slice(0))), oe; }, q; }(), D = new I(), g = function() { return c()(function q(F) { this._logger = void 0, this._id = 0, this._config = p, this._id = q._id, q._id++, this._logger = new I().setId(this._id).setLevel(b.INFO), this._config = A()({}, p, F); }, [{ key: "config", get: function() { return this._config; } }, { key: "logger", get: function() { return this._logger; } }, { key: "id", get: function() { return this._id; } }], [{ key: "packName", get: function() { return "ll_es"; } }, { key: "version", get: function() { return "1.0.13"; } }, { key: "buildTime", get: function() { return "Tue Oct 08 2024 17:18:49 GMT+0800 (中国标准时间)"; } }]); }(); g._id = 0; var y = o(4), m = o.n(y), E = o(2), R = o.n(E), k = function() { function q(O, B, K, W, te) { var ie = this; te === void 0 && (te = 1), this._logger = void 0, this._name = void 0, this._storeName = void 0, this._dbIndex = void 0, this._version = void 0, this._taskQueue = [], this._openReq = void 0, this._isTransactionActive = !1, this._runTaskQueue = function() { for (; ie._taskQueue.length; ) { var U = ie._taskQueue.shift(); U && ie.run(U.task, U.mode); } }, this._logger = O, this._name = B, this._storeName = K, this._dbIndex = W, this._version = te; } var F = q.prototype; return F.init = function() { var O = this; if (!this._openReq && indexedDB) { var B = this._openReq = indexedDB.open(this._name, this._version); this._logger.i("idb-wrapper", "open", B), B.onerror = function() { O._logger.i("idb-wrapper", "open error."); }, B.onsuccess = function() { O._logger.i("idb-wrapper", "open success."), O._runTaskQueue(); }, B.onupgradeneeded = function() { O._logger.i("idb-wrapper", "open upgradeneeded."), B.result.objectStoreNames.contains(O._storeName) && B.result.deleteObjectStore(O._storeName); var K = B.result.createObjectStore(O._storeName, { keyPath: "id", autoIncrement: !0 }); O._dbIndex && O._dbIndex.forEach(function(W) { K.createIndex(W.name, W.keyPath, W.option); }); }; } }, F.run = function(O, B) { if (B === void 0 && (B = "readwrite"), this.init(), this._openReq && this._openReq.readyState === "done" && !this._openReq.error) return this._doTask(O, B); this.state !== "error" && (this._taskQueue.push({ task: O, mode: B }), this._taskQueue.length > 1e3 && this._taskQueue.shift()); }, F.close = function() { var O = this; this._logger.i("idb-wrapper", "close"), this._openReq && (this._openReq.readyState === "done" ? (this._openReq.result.close(), this._openReq = void 0) : this._openReq.onsuccess = function() { O.close(); }); }, F.destroy = function() { this._logger.i("idb-wrapper", "destroy"), this.close(), this._taskQueue = []; }, F._doTask = function(O, B) { var K = this; if (B === void 0 && (B = "readwrite"), this._openReq && !this._openReq.error) try { this._isTransactionActive = !0; var W = this._openReq.result.transaction(this._storeName, B), te = void 0; W.oncomplete = function() { K._isTransactionActive = !1, O.callback && O.callback(te), K._runTaskQueue(); }, W.onabort = W.onerror = function() { K._isTransactionActive = !1, O.callback && O.callback(te), K._runTaskQueue(); }, te = O.exec(W.objectStore(this._storeName)); } catch (ie) { } else O.callback && O.callback(); }, c()(q, [{ key: "isTransactionActive", get: function() { return this._isTransactionActive; } }, { key: "state", get: function() { return this._openReq && this._openReq.readyState === "done" ? this._openReq.error ? "error" : "ready" : "idle"; } }]); }(), P = [{ name: "id", keyPath: "id", option: { unique: !0 } }], M = [function() { function q(O) { this._ctx = void 0, this._idb = void 0, this._logCount = 0, this._saveCount = 0, this._reCountOnSaveCount = 100, this._reduceData = !1, this._ctx = O, this._idb = new k(O.logger, O.config.idbName, O.config.idbName, P), this._reCountOnSaveCount = Math.min(200, Math.max(50, Math.round(this._ctx.config.idbMaxDataCount / 10))), this._count(); } q.isSupported = function() { return typeof indexedDB < "u"; }; var F = q.prototype; return F.saveLog = function(O) { var B = this, K = { exec: function(W) { return W.add({ value: O }); }, callback: function(W) { B._saveCount++, B._saveCount % B._reCountOnSaveCount == 0 && B._count(), W != null && W.error && B._ctx.logger.i("idb-backend", "save log err", W.error); } }; this._idb.run(K); }, F.exportLog = function() { var O = m()(R.a.mark(function B() { var K = this; return R.a.wrap(function(W) { for (; ; ) switch (W.prev = W.next) { case 0: return W.abrupt("return", new Promise(function(te, ie) { K._ctx.logger.i("idb-backend", "export start"); var U = { exec: function(H) { return H.getAll(); }, callback: function(H) { te(H === void 0 ? "" : K._mergeGetAll(H.result)); } }; K._idb.run(U, "readonly"); })); case 1: case "end": return W.stop(); } }, B); })); return function() { return O.apply(this, arguments); }; }(), F.destroy = function() { this._idb.destroy(); }, F.clean = function() { this._idb.run({ exec: function(O) { return O.clear(); } }); }, F._count = function() { var O = this, B = { exec: function(K) { return K.count(); }, callback: function(K) { K != null && K.error || K == null || !K.result || (O._ctx.logger.i("idb-backend", "count: " + K.result + " max: " + O._ctx.config.idbMaxDataCount), O._logCount = K.result, O._logCount >= O._ctx.config.idbMaxDataCount && !O._reduceData && O._deleteFromHead(O._logCount - Math.round(O._ctx.config.idbMaxDataCount / 2))); } }; this._idb.run(B); }, F._deleteFromHead = function(O) { var B = this; this._ctx.logger.i("idb-backend", "delete from head"), this._reduceData = !0; var K = { exec: function(W) { return W.openCursor(); }, callback: function(W) { if (B._reduceData = !1, W != null && W.result) { var te = IDBKeyRange.bound(W.result.key, W.result.key + O, !1, !1), ie = { exec: function(U) { return B._ctx.logger.i("idb-backend", "del: " + te.lower + "~" + te.upper), U.delete(te); }, callback: function(U) { B._ctx.logger.i("idb-backend", "del result: " + !(U == null || !U.error)); } }; B._idb.run(ie); } } }; this._idb.run(K); }, F._mergeGetAll = function(O) { return O.length ? O.reduce(function(B, K) { return "" + B + K.value + ` `; }, "") : ""; }, c()(q, [{ key: "isActive", get: function() { return this._idb.state !== "error"; } }]); }()]; function Y(q, F, O) { var B = /* @__PURE__ */ new Date(); typeof q != "string" && (q = q.toString()); var K = B.toLocaleString() + "." + B.getMilliseconds().toString().padStart(3, "0") + "|" + q + "|"; return F.forEach(function(W) { K += typeof W == "object" ? JSON.stringify(W) + " " : W + " "; }), K.length > O ? K.substring(0, O) : K; } function re(q) { return q.join(` `); } var he = function() { function q(O) { var B = this; this._ctx = void 0, this._backend = void 0, this._delayTimer = void 0, this._logCache = [], this._loggerForAdd = void 0, this._downloadHref = void 0, this._startDelay = function() { B._delayTimer = setInterval(function() { B._saveLog(!0); }, 1e3); }, this._stopDelay = function() { B._delayTimer && (clearTimeout(B._delayTimer), B._delayTimer = void 0); }, T("kwai-video-local-log", "1.0.13"), this._ctx = new g(O); var K = function(W) { for (var te = arguments.length, ie = new Array(te > 1 ? te - 1 : 0), U = 1; U < te; U++) ie[U - 1] = arguments[U]; B.addLog.apply(B, [W].concat(ie)); }; this._loggerForAdd = { e: K, w: K, i: K, d: K, v: K }, this._ctx.logger.setOutput(this._loggerForAdd), this._ctx.logger.i("kwai-video-local-log", "constructor", O, this._ctx.config), this._backend = function(W) { for (var te = 0; te < M.length; te++) { var ie = M[te]; if (ie != null && ie.isSupported()) return new ie(W); } }(this._ctx), this._backend && this._startDelay(); } q.isSupported = function() { return function() { for (var O = 0; O < M.length; O++) { var B = M[O]; if (B != null && B.isSupported()) return !0; } return !1; }(); }; var F = q.prototype; return F.addLog = function(O) { for (var B = arguments.length, K = new Array(B > 1 ? B - 1 : 0), W = 1; W < B; W++) K[W - 1] = arguments[W]; this._logCache.push(Y(O, K, this._ctx.config.maxLogLen)), this._saveLog(); }, F.cleanLog = function() { var O; this._ctx.logger.i("kwai-video-local-log", "clean"), (O = this._backend) == null || O.clean(); }, F.exportLog = function() { var O = this; return this._ctx.logger.i("kwai-video-local-log", "export log"), new Promise(function(B, K) { O._backend ? O._backend.exportLog().then(function(W) { B(re([W].concat(O._logCache))); }) : B(""); }); }, F.downloadLog = function(O) { var B = this; this._ctx.logger.i("kwai-video-local-log", "download log: " + O), this._destroyDownloadHref(), this.exportLog().then(function(K) { var W = new Blob([K], { type: "text/plain" }); if (document) { var te = document.createElement("a"); B._downloadHref = te.href = URL.createObjectURL(W), te.download = O || "Log_web_" + (/* @__PURE__ */ new Date()).toLocaleString() + ".log", document.body.appendChild(te), te.click(), te.remove(); } else console.log("无document,当前是否在worker中"); }); }, F.destroy = function() { var O; this._destroyDownloadHref(), (O = this._backend) == null || O.destroy(), this._stopDelay(); }, F.getLoggerForAdd = function() { return this._loggerForAdd; }, F._destroyDownloadHref = function() { try { this._downloadHref && (URL.revokeObjectURL(this._downloadHref), this._downloadHref = void 0); } catch (O) { } }, F._saveLog = function(O) { if (O === void 0 && (O = !1), this._backend && this._backend.isActive && (this._logCache.length >= this._ctx.config.idbMaxFoldLog || this._logCache.length > 0 && O)) { var B = re(this._logCache); this._logCache.splice(0, this._logCache.length), B && this._backend.saveLog(B); } }, c()(q, null, [{ key: "version", get: function() { return "1.0.13"; } }]); }(); e.default = he; }]); jt === void 0 && console.error("esm-webpack-plugin: nothing exported!"); const io = jt.KwaiVideoLocalLog, No = jt.LogLevel, Je = jt.DefaultLogger, Po = jt.Logger, wl = jt.printVersion; jt.DEFAULT_LOG_LEVEL; jt.default; var Lr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Uo(i) { return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i; } var Kr = { exports: {} }, ri = typeof Reflect == "object" ? Reflect : null, ro = ri && typeof ri.apply == "function" ? ri.apply : function(i, e, o) { return Function.prototype.apply.call(i, e, o); }, Di; ri && typeof ri.ownKeys == "function" ? Di = ri.ownKeys : Object.getOwnPropertySymbols ? Di = function(i) { return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i)); } : Di = function(i) { return Object.getOwnPropertyNames(i); }; function Sl(i) { console && console.warn && console.warn(i); } var Bo = Number.isNaN || function(i) { return i !== i; }; function De() { De.init.call(this); } Kr.exports = De; Kr.exports.once = Dl; De.EventEmitter = De; De.prototype._events = void 0; De.prototype._eventsCount = 0; De.prototype._maxListeners = void 0; var no = 10; function ji(i) { if (typeof i != "function") throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof i); } Object.defineProperty(De, "defaultMaxListeners", { enumerable: !0, get: function() { return no; }, set: function(i) { if (typeof i != "number" || i < 0 || Bo(i)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + i + "."); no = i; } }); De.init = function() { (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; }; De.prototype.setMaxListeners = function(i) { if (typeof i != "number" || i < 0 || Bo(i)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + i + "."); return this._maxListeners = i, this; }; function Fo(i) { return i._maxListeners === void 0 ? De.defaultMaxListeners : i._maxListeners; } De.prototype.getMaxListeners = function() { return Fo(this); }; De.prototype.emit = function(i) { for (var e = [], o = 1; o < arguments.length; o++) e.push(arguments[o]); var l = i === "error", c = this._events; if (c !== void 0) l = l && c.error === void 0; else if (!l) return !1; if (l) { var h; if (e.length > 0 && (h = e[0]), h instanceof Error) throw h; var A = new Error("Unhandled error." + (h ? " (" + h.message + ")" : "")); throw A.context = h, A; } var p = c[i]; if (p === void 0) return !1; if (typeof p == "function") ro(p, this, e); else for (var T = p.length, S = Ko(p, T), o = 0; o < T; ++o) ro(S[o], this, e); return !0; }; function Ho(i, e, o, l) { var c, h, A; if (ji(o), h = i._events, h === void 0 ? (h = i._events = /* @__PURE__ */ Object.create(null), i._eventsCount = 0) : (h.newListener !== void 0 && (i.emit( "newListener", e, o.listener ? o.listener : o ), h = i._events), A = h[e]), A === void 0) A = h[e] = o, ++i._eventsCount; else if (typeof A == "function" ? A = h[e] = l ? [o, A] : [A, o] : l ? A.unshift(o) : A.push(o), c = Fo(i), c > 0 && A.length > c && !A.warned) { A.warned = !0; var p = new Error("Possible EventEmitter memory leak detected. " + A.length + " " + String(e) + " listeners added. Use emitter.setMaxListeners() to increase limit"); p.name = "MaxListenersExceededWarning", p.emitter = i, p.type = e, p.count = A.length, Sl(p); } return i; } De.prototype.addListener = function(i, e) { return Ho(this, i, e, !1); }; De.prototype.on = De.prototype.addListener; De.prototype.prependListener = function(i, e) { return Ho(this, i, e, !0); }; function Ll() { if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); } function Vo(i, e, o) { var l = { fired: !1, wrapFn: void 0, target: i, type: e, listener: o }, c = Ll.bind(l); return c.listener = o, l.wrapFn = c, c; } De.prototype.once = function(i, e) { return ji(e), this.on(i, Vo(this, i, e)), this; }; De.prototype.prependOnceListener = function(i, e) { return ji(e), this.prependListener(i, Vo(this, i, e)), this; }; De.prototype.removeListener = function(i, e) { var o, l, c, h, A; if (ji(e), l = this._events, l === void 0) return this; if (o = l[i], o === void 0) return this; if (o === e || o.listener === e) --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete l[i], l.removeListener && this.emit("removeListener", i, o.listener || e)); else if (typeof o != "function") { for (c = -1, h = o.length - 1; h >= 0; h--) if (o[h] === e || o[h].listener === e) { A = o[h].listener, c = h; break; } if (c < 0) return this; c === 0 ? o.shift() : Il(o, c), o.length === 1 && (l[i] = o[0]), l.removeListener !== void 0 && this.emit("removeListener", i, A || e); } return this; }; De.prototype.off = De.prototype.removeListener; De.prototype.removeAllListeners = function(i) { var e, o, l; if (o = this._events, o === void 0) return this; if (o.removeListener === void 0) return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : o[i] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete o[i]), this; if (arguments.length === 0) { var c = Object.keys(o), h; for (l = 0; l < c.length; ++l) h = c[l], h !== "removeListener" && this.removeAllListeners(h); return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; } if (e = o[i], typeof e == "function") this.removeListener(i, e); else if (e !== void 0) for (l = e.length - 1; l >= 0; l--) this.removeListener(i, e[l]); return this; }; function Go(i, e, o) { var l = i._events; if (l === void 0) return []; var c = l[e]; return c === void 0 ? [] : typeof c == "function" ? o ? [c.listener || c] : [c] : o ? Cl(c) : Ko(c, c.length); } De.prototype.listeners = function(i) { return Go(this, i, !0); }; De.prototype.rawListeners = function(i) { return Go(this, i, !1); }; De.listenerCount = function(i, e) { return typeof i.listenerCount == "function" ? i.listenerCount(e) : Wo.call(i, e); }; De.prototype.listenerCount = Wo; function Wo(i) { var e = this._events; if (e !== void 0) { var o = e[i]; if (typeof o == "function") return 1; if (o !== void 0) return o.length; } return 0; } De.prototype.eventNames = function() { return this._eventsCount > 0 ? Di(this._events) : []; }; function Ko(i, e) { for (var o = new Array(e), l = 0; l < e; ++l) o[l] = i[l]; return o; } function Il(i, e) { for (; e + 1 < i.length; e++) i[e] = i[e + 1]; i.pop(); } function Cl(i) { for (var e = new Array(i.length), o = 0; o < e.length; ++o) e[o] = i[o].listener || i[o]; return e; } function Dl(i, e) { return new Promise(function(o, l) { function c(A) { i.removeListener(e, h), l(A); } function h() { typeof i.removeListener == "function" && i.removeListener("error", c), o([].slice.call(arguments)); } jo(i, e, h, { once: !0 }), e !== "error" && kl(i, c, { once: !0 }); }); } function kl(i, e, o) { typeof i.on == "function" && jo(i, "error", e, o); } function jo(i, e, o, l) { if (typeof i.on == "function") l.once ? i.once(e, o) : i.on(e, o); else if (typeof i.addEventListener == "function") i.addEventListener(e, function c(h) { l.once && i.removeEventListener(e, c), o(h); }); else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof i); } var Ol = Kr.exports, zo = function() { if (typeof Map < "u") return Map; function i(e, o) { var l = -1; return e.some(function(c, h) { return c[0] === o ? (l = h, !0) : !1; }), l; } return ( /** @class */ function() { function e() { this.__entries__ = []; } return Object.defineProperty(e.prototype, "size", { /** * @returns {boolean} */ get: function() { return this.__entries__.length; }, enumerable: !0, configurable: !0 }), e.prototype.get = function(o) { var l = i(this.__entries__, o), c = this.__entries__[l]; return c && c[1]; }, e.prototype.set = function(o, l) { var c = i(this.__entries__, o); ~c ? this.__entries__[c][1] = l : this.__entries__.push([o, l]); }, e.prototype.delete = function(o) { var l = this.__entries__, c = i(l, o); ~c && l.splice(c, 1); }, e.prototype.has = function(o) { return !!~i(this.__entries__, o); }, e.prototype.clear = function() { this.__entries__.splice(0); }, e.prototype.forEach = function(o, l) { l === void 0 && (l = null); for (var c = 0, h = this.__entries__; c < h.length; c++) { var A = h[c]; o.call(l, A[1], A[0]); } }, e; }() ); }(), Ir = typeof window < "u" && typeof document < "u" && window.document === document, Bi = function() { return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")(); }(), xl = function() { return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(Bi) : function(i) { return setTimeout(function() { return i(Date.now()); }, 1e3 / 60); }; }(), Ml = 2; function Nl(i, e) { var o = !1, l = !1, c = 0; function h() { o && (o = !1, i()), l && p(); } function A() { xl(h); } function p() { var T = Date.now(); if (o) { if (T - c < Ml) return; l = !0; } else o = !0, l = !1, setTimeout(A, e); c = T; } return p; } var Pl = 20, Ul = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], Bl = typeof MutationObserver < "u", Fl = ( /** @class */ function() { function i() { this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = Nl(this.refresh.bind(this), Pl); } return i.prototype.addObserver = function(e) { ~this.observers_.indexOf(e) || this.observers_.push(e), this.connected_ || this.connect_(); }, i.prototype.removeObserver = function(e) { var o = this.observers_, l = o.indexOf(e); ~l && o.splice(l, 1), !o.length && this.connected_ && this.disconnect_(); }, i.prototype.refresh = function() { var e = this.updateObservers_(); e && this.refresh(); }, i.prototype.updateObservers_ = function() { var e = this.observers_.filter(function(o) { return o.gatherActive(), o.hasActive(); }); return e.forEach(function(o) { return o.broadcastActive(); }), e.length > 0; }, i.prototype.connect_ = function() { !Ir || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), Bl ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, { attributes: !0, childList: !0, characterData: !0, subtree: !0 })) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0); }, i.prototype.disconnect_ = function() { !Ir || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1); }, i.prototype.onTransitionEnd_ = function(e) { var o = e.propertyName, l = o === void 0 ? "" : o, c = Ul.some(function(h) { return !!~l.indexOf(h); }); c && this.refresh(); }, i.getInstance = function() { return this.instance_ || (this.instance_ = new i()), this.instance_; }, i.instance_ = null, i; }() ), Jo = function(i, e) { for (var o = 0, l = Object.keys(e); o < l.length; o++) { var c = l[o]; Object.defineProperty(i, c, { value: e[c], enumerable: !1, writable: !1, configurable: !0 }); } return i; }, oi = function(i) { var e = i && i.ownerDocument && i.ownerDocument.defaultView; return e || Bi; }, Yo = zi(0, 0, 0, 0); function Fi(i) { return parseFloat(i) || 0; } function oo(i) { for (var e = [], o = 1; o < arguments.length; o++) e[o - 1] = arguments[o]; return e.reduce(function(l, c) { var h = i["border-" + c + "-width"]; return l + Fi(h); }, 0); } function Hl(i) { for (var e = ["top", "right", "bottom", "left"], o = {}, l = 0, c = e; l < c.length; l++) { var h = c[l], A = i["padding-" + h]; o[h] = Fi(A); } return o; } function Vl(i) { var e = i.getBBox(); return zi(0, 0, e.width, e.height); } function Gl(i) { var e = i.clientWidth, o = i.clientHeight; if (!e && !o) return Yo; var l = oi(i).getComputedStyle(i), c = Hl(l), h = c.left + c.right, A = c.top + c.bottom, p = Fi(l.width), T = Fi(l.height); if (l.boxSizing === "border-box" && (Math.round(p + h) !== e && (p -= oo(l, "left", "right") + h), Math.round(T + A) !== o && (T -= oo(l, "top", "bottom") + A)), !Kl(i)) { var S = Math.round(p + h) - e, f = Math.round(T + A) - o; Math.abs(S) !== 1 && (p -= S), Math.abs(f) !== 1 && (T -= f); } return zi(c.left, c.top, p, T); } var Wl = function() { return typeof SVGGraphicsElement < "u" ? function(i) { return i instanceof oi(i).SVGGraphicsElement; } : function(i) { return i instanceof oi(i).SVGElement && typeof i.getBBox == "function"; }; }(); function Kl(i) { return i === oi(i).document.documentElement; } function jl(i) { return Ir ? Wl(i) ? Vl(i) : Gl(i) : Yo; } function zl(i) { var e = i.x, o = i.y, l = i.width, c = i.height, h = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, A = Object.create(h.prototype); return Jo(A, { x: e, y: o, width: l, height: c, top: o, right: e + l, bottom: c + o, left: e }), A; } function zi(i, e, o, l) { return { x: i, y: e, width: o, height: l }; } var Jl = ( /** @class */ function() { function i(e) { this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = zi(0, 0, 0, 0), this.target = e; } return i.prototype.isActive = function() { var e = jl(this.target); return this.contentRect_ = e, e.width !== this.broadcastWidth || e.height !== this.broadcastHeight; }, i.prototype.broadcastRect = function() { var e = this.contentRect_; return this.broadcastWidth = e.width, this.broadcastHeight = e.height, e; }, i; }() ), Yl = ( /** @class */ function() { function i(e, o) { var l = zl(o);