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,262 lines 1.46 MB
var cf = Object.defineProperty; var vc = Object.getOwnPropertySymbols; var uf = Object.prototype.hasOwnProperty, lf = Object.prototype.propertyIsEnumerable; var gc = (i, n, a) => n in i ? cf(i, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[n] = a, mc = (i, n) => { for (var a in n || (n = {})) uf.call(n, a) && gc(i, a, n[a]); if (vc) for (var a of vc(n)) lf.call(n, a) && gc(i, a, n[a]); return i; }; Number.isFinite || (Number.isFinite = (i) => typeof i == "number" && isFinite(i)); Array.prototype.find || (Array.prototype.find = function(i, n) { 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 a = Object(this), u = a.length >>> 0; for (let c = 0; c < u; c++) if (i.call(n, a[c], c, a)) return a[c]; }); Array.prototype.findIndex || (Array.prototype.findIndex = function(i, n) { 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 a = Object(this), u = a.length >>> 0; for (let c = 0; c < u; c++) if (c in a && i.call(n, a[c], c, a)) return c; return -1; }); Array.prototype.fill || (Array.prototype.fill = function(i, n = 0, a = this.length) { if (this === null || this === void 0) throw new TypeError("Array.prototype.fill called on null or undefined"); const u = Object(this), c = u.length >>> 0, A = n >> 0, y = a >> 0, T = A < 0 ? Math.max(c + A, 0) : Math.min(A, c), I = y < 0 ? Math.max(c + y, 0) : Math.min(y, c); for (let U = T; U < I; U++) u[U] = i; return u; }); var hf = Object.defineProperty, df = (i, n, a) => n in i ? hf(i, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : i[n] = a, uu = (i, n, a) => (df(i, typeof n != "symbol" ? n + "" : n, a), a), on = function(i) { var n = {}; function a(u) { if (n[u]) return n[u].exports; var c = n[u] = { i: u, l: !1, exports: {} }; return i[u].call(c.exports, c, c.exports, a), c.l = !0, c.exports; } return a.m = i, a.c = n, a.d = function(u, c, A) { a.o(u, c) || Object.defineProperty(u, c, { enumerable: !0, get: A }); }, a.r = function(u) { typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(u, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(u, "__esModule", { value: !0 }); }, a.t = function(u, c) { if (1 & c && (u = a(u)), 8 & c || 4 & c && typeof u == "object" && u && u.__esModule) return u; var A = /* @__PURE__ */ Object.create(null); if (a.r(A), Object.defineProperty(A, "default", { enumerable: !0, value: u }), 2 & c && typeof u != "string") for (var y in u) a.d(A, y, function(T) { return u[T]; }.bind(null, y)); return A; }, a.n = function(u) { var c = u && u.__esModule ? function() { return u.default; } : function() { return u; }; return a.d(c, "a", c), c; }, a.o = function(u, c) { return Object.prototype.hasOwnProperty.call(u, c); }, a.p = "", a(a.s = 8); }([function(i, n, a) { var u = a(5); function c(A, y) { for (var T = 0; T < y.length; T++) { var I = y[T]; I.enumerable = I.enumerable || !1, I.configurable = !0, "value" in I && (I.writable = !0), Object.defineProperty(A, u(I.key), I); } } i.exports = function(A, y, T) { return y && c(A.prototype, y), T && c(A, T), Object.defineProperty(A, "prototype", { writable: !1 }), A; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n) { function a(u) { return i.exports = a = 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, a(u); } i.exports = a, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n, a) { var u = a(7)(); i.exports = u; try { regeneratorRuntime = u; } catch (c) { typeof globalThis == "object" ? globalThis.regeneratorRuntime = u : Function("r", "regeneratorRuntime = r")(u); } }, function(i, n) { function a() { return i.exports = a = Object.assign ? Object.assign.bind() : function(u) { for (var c = 1; c < arguments.length; c++) { var A = arguments[c]; for (var y in A) Object.prototype.hasOwnProperty.call(A, y) && (u[y] = A[y]); } return u; }, i.exports.__esModule = !0, i.exports.default = i.exports, a.apply(this, arguments); } i.exports = a, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n) { function a(u, c, A, y, T, I, U) { try { var h = u[I](U), F = h.value; } catch (w) { return void A(w); } h.done ? c(F) : Promise.resolve(F).then(y, T); } i.exports = function(u) { return function() { var c = this, A = arguments; return new Promise(function(y, T) { var I = u.apply(c, A); function U(F) { a(I, y, T, U, h, "next", F); } function h(F) { a(I, y, T, U, h, "throw", F); } U(void 0); }); }; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n, a) { var u = a(1).default, c = a(6); i.exports = function(A) { var y = c(A, "string"); return u(y) == "symbol" ? y : y + ""; }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n, a) { var u = a(1).default; i.exports = function(c, A) { if (u(c) != "object" || !c) return c; var y = c[Symbol.toPrimitive]; if (y !== void 0) { var T = y.call(c, A || "default"); if (u(T) != "object") return T; throw new TypeError("@@toPrimitive must return a primitive value."); } return (A === "string" ? String : Number)(c); }, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n, a) { var u = a(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 y; }, i.exports.__esModule = !0, i.exports.default = i.exports; var A, y = {}, T = Object.prototype, I = T.hasOwnProperty, U = Object.defineProperty || function(he, X, ge) { he[X] = ge.value; }, h = typeof Symbol == "function" ? Symbol : {}, F = h.iterator || "@@iterator", w = h.asyncIterator || "@@asyncIterator", E = h.toStringTag || "@@toStringTag"; function O(he, X, ge) { return Object.defineProperty(he, X, { value: ge, enumerable: !0, configurable: !0, writable: !0 }), he[X]; } try { O({}, ""); } catch (he) { O = function(X, ge, Pe) { return X[ge] = Pe; }; } function Q(he, X, ge, Pe) { var ae = X && X.prototype instanceof te ? X : te, J = Object.create(ae.prototype), g = new Te(Pe || []); return U(J, "_invoke", { value: D(he, ge, g) }), J; } function j(he, X, ge) { try { return { type: "normal", arg: he.call(X, ge) }; } catch (Pe) { return { type: "throw", arg: Pe }; } } y.wrap = Q; var N = "suspendedStart", K = "executing", G = "completed", B = {}; function te() { } function ye() { } function Z() { } var Ce = {}; O(Ce, F, function() { return this; }); var Be = Object.getPrototypeOf, je = Be && Be(Be(Oe([]))); je && je !== T && I.call(je, F) && (Ce = je); var He = Z.prototype = te.prototype = Object.create(Ce); function De(he) { ["next", "throw", "return"].forEach(function(X) { O(he, X, function(ge) { return this._invoke(X, ge); }); }); } function ue(he, X) { function ge(ae, J, g, ve) { var P = j(he[ae], he, J); if (P.type !== "throw") { var k = P.arg, ne = k.value; return ne && u(ne) == "object" && I.call(ne, "__await") ? X.resolve(ne.__await).then(function(we) { ge("next", we, g, ve); }, function(we) { ge("throw", we, g, ve); }) : X.resolve(ne).then(function(we) { k.value = we, g(k); }, function(we) { return ge("throw", we, g, ve); }); } ve(P.arg); } var Pe; U(this, "_invoke", { value: function(ae, J) { function g() { return new X(function(ve, P) { ge(ae, J, ve, P); }); } return Pe = Pe ? Pe.then(g, g) : g(); } }); } function D(he, X, ge) { var Pe = N; return function(ae, J) { if (Pe === K) throw Error("Generator is already running"); if (Pe === G) { if (ae === "throw") throw J; return { value: A, done: !0 }; } for (ge.method = ae, ge.arg = J; ; ) { var g = ge.delegate; if (g) { var ve = R(g, ge); if (ve) { if (ve === B) continue; return ve; } } if (ge.method === "next") ge.sent = ge._sent = ge.arg; else if (ge.method === "throw") { if (Pe === N) throw Pe = G, ge.arg; ge.dispatchException(ge.arg); } else ge.method === "return" && ge.abrupt("return", ge.arg); Pe = K; var P = j(he, X, ge); if (P.type === "normal") { if (Pe = ge.done ? G : "suspendedYield", P.arg === B) continue; return { value: P.arg, done: ge.done }; } P.type === "throw" && (Pe = G, ge.method = "throw", ge.arg = P.arg); } }; } function R(he, X) { var ge = X.method, Pe = he.iterator[ge]; if (Pe === A) return X.delegate = null, ge === "throw" && he.iterator.return && (X.method = "return", X.arg = A, R(he, X), X.method === "throw") || ge !== "return" && (X.method = "throw", X.arg = new TypeError("The iterator does not provide a '" + ge + "' method")), B; var ae = j(Pe, he.iterator, X.arg); if (ae.type === "throw") return X.method = "throw", X.arg = ae.arg, X.delegate = null, B; var J = ae.arg; return J ? J.done ? (X[he.resultName] = J.value, X.next = he.nextLoc, X.method !== "return" && (X.method = "next", X.arg = A), X.delegate = null, B) : J : (X.method = "throw", X.arg = new TypeError("iterator result is not an object"), X.delegate = null, B); } function le(he) { var X = { tryLoc: he[0] }; 1 in he && (X.catchLoc = he[1]), 2 in he && (X.finallyLoc = he[2], X.afterLoc = he[3]), this.tryEntries.push(X); } function oe(he) { var X = he.completion || {}; X.type = "normal", delete X.arg, he.completion = X; } function Te(he) { this.tryEntries = [{ tryLoc: "root" }], he.forEach(le, this), this.reset(!0); } function Oe(he) { if (he || he === "") { var X = he[F]; if (X) return X.call(he); if (typeof he.next == "function") return he; if (!isNaN(he.length)) { var ge = -1, Pe = function ae() { for (; ++ge < he.length; ) if (I.call(he, ge)) return ae.value = he[ge], ae.done = !1, ae; return ae.value = A, ae.done = !0, ae; }; return Pe.next = Pe; } } throw new TypeError(u(he) + " is not iterable"); } return ye.prototype = Z, U(He, "constructor", { value: Z, configurable: !0 }), U(Z, "constructor", { value: ye, configurable: !0 }), ye.displayName = O(Z, E, "GeneratorFunction"), y.isGeneratorFunction = function(he) { var X = typeof he == "function" && he.constructor; return !!X && (X === ye || (X.displayName || X.name) === "GeneratorFunction"); }, y.mark = function(he) { return Object.setPrototypeOf ? Object.setPrototypeOf(he, Z) : (he.__proto__ = Z, O(he, E, "GeneratorFunction")), he.prototype = Object.create(He), he; }, y.awrap = function(he) { return { __await: he }; }, De(ue.prototype), O(ue.prototype, w, function() { return this; }), y.AsyncIterator = ue, y.async = function(he, X, ge, Pe, ae) { ae === void 0 && (ae = Promise); var J = new ue(Q(he, X, ge, Pe), ae); return y.isGeneratorFunction(X) ? J : J.next().then(function(g) { return g.done ? g.value : J.next(); }); }, De(He), O(He, E, "Generator"), O(He, F, function() { return this; }), O(He, "toString", function() { return "[object Generator]"; }), y.keys = function(he) { var X = Object(he), ge = []; for (var Pe in X) ge.push(Pe); return ge.reverse(), function ae() { for (; ge.length; ) { var J = ge.pop(); if (J in X) return ae.value = J, ae.done = !1, ae; } return ae.done = !0, ae; }; }, y.values = Oe, Te.prototype = { constructor: Te, reset: function(he) { if (this.prev = 0, this.next = 0, this.sent = this._sent = A, this.done = !1, this.delegate = null, this.method = "next", this.arg = A, this.tryEntries.forEach(oe), !he) for (var X in this) X.charAt(0) === "t" && I.call(this, X) && !isNaN(+X.slice(1)) && (this[X] = A); }, stop: function() { this.done = !0; var he = this.tryEntries[0].completion; if (he.type === "throw") throw he.arg; return this.rval; }, dispatchException: function(he) { if (this.done) throw he; var X = this; function ge(P, k) { return J.type = "throw", J.arg = he, X.next = P, k && (X.method = "next", X.arg = A), !!k; } for (var Pe = this.tryEntries.length - 1; Pe >= 0; --Pe) { var ae = this.tryEntries[Pe], J = ae.completion; if (ae.tryLoc === "root") return ge("end"); if (ae.tryLoc <= this.prev) { var g = I.call(ae, "catchLoc"), ve = I.call(ae, "finallyLoc"); if (g && ve) { if (this.prev < ae.catchLoc) return ge(ae.catchLoc, !0); if (this.prev < ae.finallyLoc) return ge(ae.finallyLoc); } else if (g) { if (this.prev < ae.catchLoc) return ge(ae.catchLoc, !0); } else { if (!ve) throw Error("try statement without catch or finally"); if (this.prev < ae.finallyLoc) return ge(ae.finallyLoc); } } } }, abrupt: function(he, X) { for (var ge = this.tryEntries.length - 1; ge >= 0; --ge) { var Pe = this.tryEntries[ge]; if (Pe.tryLoc <= this.prev && I.call(Pe, "finallyLoc") && this.prev < Pe.finallyLoc) { var ae = Pe; break; } } ae && (he === "break" || he === "continue") && ae.tryLoc <= X && X <= ae.finallyLoc && (ae = null); var J = ae ? ae.completion : {}; return J.type = he, J.arg = X, ae ? (this.method = "next", this.next = ae.finallyLoc, B) : this.complete(J); }, complete: function(he, X) { if (he.type === "throw") throw he.arg; return he.type === "break" || he.type === "continue" ? this.next = he.arg : he.type === "return" ? (this.rval = this.arg = he.arg, this.method = "return", this.next = "end") : he.type === "normal" && X && (this.next = X), B; }, finish: function(he) { for (var X = this.tryEntries.length - 1; X >= 0; --X) { var ge = this.tryEntries[X]; if (ge.finallyLoc === he) return this.complete(ge.completion, ge.afterLoc), oe(ge), B; } }, catch: function(he) { for (var X = this.tryEntries.length - 1; X >= 0; --X) { var ge = this.tryEntries[X]; if (ge.tryLoc === he) { var Pe = ge.completion; if (Pe.type === "throw") { var ae = Pe.arg; oe(ge); } return ae; } } throw Error("illegal catch attempt"); }, delegateYield: function(he, X, ge) { return this.delegate = { iterator: Oe(he), resultName: X, nextLoc: ge }, this.method === "next" && (this.arg = A), B; } }, y; } i.exports = c, i.exports.__esModule = !0, i.exports.default = i.exports; }, function(i, n, a) { a.r(n), a.d(n, "KwaiVideoLocalLog", function() { return He; }), a.d(n, "LogLevel", function() { return w; }), a.d(n, "DefaultLogger", function() { return j; }), a.d(n, "Logger", function() { return Q; }), a.d(n, "printVersion", function() { return I; }), a.d(n, "DEFAULT_LOG_LEVEL", function() { return E; }); var u = a(0), c = a.n(u), A = a(3), y = a.n(A), T = { idbName: "kwai-video-local-log", idbMaxDataCount: 25e3, idbMaxFoldLog: 20, maxLogLen: 4096 }; function I(De, ue) { console.log("%c " + De + " %c " + ue + " %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 U = function() { function De() { this.timeout = 6048e5; } var ue = De.prototype; return ue.write = function(D, R) { if (De.available) try { localStorage.setItem(D, JSON.stringify({ value: R, time: Date.now() })); } catch (le) { } }, ue.read = function(D, R) { if (R === void 0 && (R = !0), De.available) try { var le = localStorage.getItem(D); if (le) { var oe = JSON.parse(le), Te = oe.value, Oe = oe.time, he = Oe === void 0 ? 0 : Oe; if (!R || Date.now() - he < (typeof R == "number" ? R : this.timeout)) return Te; } } catch (X) { } }, c()(De, null, [{ key: "available", get: function() { if (De._available === void 0) try { localStorage.setItem("alg", "test"), De._available = !0; } catch (D) { De._available = !1; } return De._available; } }]); }(); U._available = void 0; var h, F = U, w = function(De) { return De.NONE = "none", De.ERROR = "e", De.WARN = "w", De.INFO = "i", De.DEBUG = "d", De.VERBOSE = "v", De; }({}), E = w.ERROR, O = ((h = {})[w.NONE] = { value: 1, str: "N" }, h[w.ERROR] = { value: 100, str: "E" }, h[w.WARN] = { value: 200, str: "W" }, h[w.INFO] = { value: 300, str: "I" }, h[w.DEBUG] = { value: 400, str: "D" }, h[w.VERBOSE] = { value: 500, str: "V" }, h), Q = function() { function De(D) { if (this._name = "kwai-v", this._level = E, this._id = -1, this._output = void 0, this._workerTag = "main", typeof location < "u" && location.protocol === "blob:") { var R, le = location.href.split("/"), oe = (R = le[le.length - 1]) == null ? void 0 : R.match(/(\w+)-/); oe && (this._workerTag = D ? D + "-" + oe[1] : oe[1]); } else D && (this._workerTag = D); } De.loadLogLevel = function(D, R) { if (R === void 0 && (R = !0), location.href) { var le = new RegExp(D + "=([a-z]{1})"), oe = location.href.match(le); if (oe && oe.length > 1) { var Te = oe[1]; if (this._isValueInLevel(Te)) return Te; } } var Oe = new F().read(D, R); if (this._isValueInLevel(Oe)) return Oe; }, De.saveLogLevel = function(D, R) { this._isValueInLevel(R) && new F().write(D, R); }, De._isValueInLevel = function(D) { return Object.values(w).indexOf(D) !== -1; }; var ue = De.prototype; return ue.setOutput = function(D) { return this._output = D, this; }, ue.setLevel = function(D) { return this._level = D, this; }, ue.setId = function(D) { return this._id = D, this; }, ue.setName = function(D) { return this._name = D, this; }, ue.getLevel = function() { return this._level; }, ue.getOutput = function() { return this._output; }, ue.hasOutput = function() { return !!this._output; }, ue.e = function(D) { if (this._isLevelEnabled(this._level, w.ERROR)) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; var Te = this._printLog(w.ERROR, D, le); try { var Oe; (Oe = this._output) == null || Oe.e.apply(Oe, [Te].concat(le)); } catch (he) { } } }, ue.w = function(D) { if (this._isLevelEnabled(this._level, w.WARN)) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; var Te = this._printLog(w.WARN, D, le); try { var Oe; (Oe = this._output) == null || Oe.w.apply(Oe, [Te].concat(le)); } catch (he) { } } }, ue.i = function(D) { if (this._isLevelEnabled(this._level, w.INFO)) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; var Te = this._printLog(w.INFO, D, le); try { var Oe; (Oe = this._output) == null || Oe.i.apply(Oe, [Te].concat(le)); } catch (he) { } } }, ue.d = function(D) { if (this._isLevelEnabled(this._level, w.DEBUG)) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; var Te = this._printLog(w.DEBUG, D, le); try { var Oe; (Oe = this._output) == null || Oe.d.apply(Oe, [Te].concat(le)); } catch (he) { } } }, ue.v = function(D) { if (this._isLevelEnabled(this._level, w.VERBOSE)) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; var Te = this._printLog(w.VERBOSE, D, le); try { var Oe; (Oe = this._output) == null || Oe.v.apply(Oe, [Te].concat(le)); } catch (he) { } } }, ue._isLevelEnabled = function(D, R) { return O[D].value >= O[R].value; }, ue._printLog = function(D, R, le) { var oe, Te, Oe = typeof R; if (Oe === "object") R = ((Te = R) == null ? void 0 : Te.constructor.name) || "unknown"; else if (Oe === "function") { var he; R = ((he = Object.getOwnPropertyDescriptor(R, "name")) == null ? void 0 : he.value) || "unknown"; } var X, ge, Pe = (((oe = O[D]) == null ? void 0 : oe.str) || "") + "|" + this._name + "[" + (typeof this._id == "function" ? this._id() : this._id) + "][" + this._workerTag + "]::" + R; return D === w.ERROR ? (X = console).error.apply(X, [Pe].concat(le.slice(0))) : (ge = console).log.apply(ge, [Pe].concat(le.slice(0))), Pe; }, De; }(), j = new Q(), N = function() { return c()(function De(ue) { this._logger = void 0, this._id = 0, this._config = T, this._id = De._id, De._id++, this._logger = new Q().setId(this._id).setLevel(w.INFO), this._config = y()({}, T, ue); }, [{ 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 (中国标准时间)"; } }]); }(); N._id = 0; var K = a(4), G = a.n(K), B = a(2), te = a.n(B), ye = function() { function De(D, R, le, oe, Te) { var Oe = 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 (; Oe._taskQueue.length; ) { var he = Oe._taskQueue.shift(); he && Oe.run(he.task, he.mode); } }, this._logger = D, this._name = R, this._storeName = le, this._dbIndex = oe, this._version = Te; } var ue = De.prototype; return ue.init = function() { var D = this; if (!this._openReq && indexedDB) { var R = this._openReq = indexedDB.open(this._name, this._version); this._logger.i("idb-wrapper", "open", R), R.onerror = function() { D._logger.i("idb-wrapper", "open error."); }, R.onsuccess = function() { D._logger.i("idb-wrapper", "open success."), D._runTaskQueue(); }, R.onupgradeneeded = function() { D._logger.i("idb-wrapper", "open upgradeneeded."), R.result.objectStoreNames.contains(D._storeName) && R.result.deleteObjectStore(D._storeName); var le = R.result.createObjectStore(D._storeName, { keyPath: "id", autoIncrement: !0 }); D._dbIndex && D._dbIndex.forEach(function(oe) { le.createIndex(oe.name, oe.keyPath, oe.option); }); }; } }, ue.run = function(D, R) { if (R === void 0 && (R = "readwrite"), this.init(), this._openReq && this._openReq.readyState === "done" && !this._openReq.error) return this._doTask(D, R); this.state !== "error" && (this._taskQueue.push({ task: D, mode: R }), this._taskQueue.length > 1e3 && this._taskQueue.shift()); }, ue.close = function() { var D = 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() { D.close(); }); }, ue.destroy = function() { this._logger.i("idb-wrapper", "destroy"), this.close(), this._taskQueue = []; }, ue._doTask = function(D, R) { var le = this; if (R === void 0 && (R = "readwrite"), this._openReq && !this._openReq.error) try { this._isTransactionActive = !0; var oe = this._openReq.result.transaction(this._storeName, R), Te = void 0; oe.oncomplete = function() { le._isTransactionActive = !1, D.callback && D.callback(Te), le._runTaskQueue(); }, oe.onabort = oe.onerror = function() { le._isTransactionActive = !1, D.callback && D.callback(Te), le._runTaskQueue(); }, Te = D.exec(oe.objectStore(this._storeName)); } catch (Oe) { } else D.callback && D.callback(); }, c()(De, [{ key: "isTransactionActive", get: function() { return this._isTransactionActive; } }, { key: "state", get: function() { return this._openReq && this._openReq.readyState === "done" ? this._openReq.error ? "error" : "ready" : "idle"; } }]); }(), Z = [{ name: "id", keyPath: "id", option: { unique: !0 } }], Ce = [function() { function De(D) { this._ctx = void 0, this._idb = void 0, this._logCount = 0, this._saveCount = 0, this._reCountOnSaveCount = 100, this._reduceData = !1, this._ctx = D, this._idb = new ye(D.logger, D.config.idbName, D.config.idbName, Z), this._reCountOnSaveCount = Math.min(200, Math.max(50, Math.round(this._ctx.config.idbMaxDataCount / 10))), this._count(); } De.isSupported = function() { return typeof indexedDB < "u"; }; var ue = De.prototype; return ue.saveLog = function(D) { var R = this, le = { exec: function(oe) { return oe.add({ value: D }); }, callback: function(oe) { R._saveCount++, R._saveCount % R._reCountOnSaveCount == 0 && R._count(), oe != null && oe.error && R._ctx.logger.i("idb-backend", "save log err", oe.error); } }; this._idb.run(le); }, ue.exportLog = function() { var D = G()(te.a.mark(function R() { var le = this; return te.a.wrap(function(oe) { for (; ; ) switch (oe.prev = oe.next) { case 0: return oe.abrupt("return", new Promise(function(Te, Oe) { le._ctx.logger.i("idb-backend", "export start"); var he = { exec: function(X) { return X.getAll(); }, callback: function(X) { Te(X === void 0 ? "" : le._mergeGetAll(X.result)); } }; le._idb.run(he, "readonly"); })); case 1: case "end": return oe.stop(); } }, R); })); return function() { return D.apply(this, arguments); }; }(), ue.destroy = function() { this._idb.destroy(); }, ue.clean = function() { this._idb.run({ exec: function(D) { return D.clear(); } }); }, ue._count = function() { var D = this, R = { exec: function(le) { return le.count(); }, callback: function(le) { le != null && le.error || le == null || !le.result || (D._ctx.logger.i("idb-backend", "count: " + le.result + " max: " + D._ctx.config.idbMaxDataCount), D._logCount = le.result, D._logCount >= D._ctx.config.idbMaxDataCount && !D._reduceData && D._deleteFromHead(D._logCount - Math.round(D._ctx.config.idbMaxDataCount / 2))); } }; this._idb.run(R); }, ue._deleteFromHead = function(D) { var R = this; this._ctx.logger.i("idb-backend", "delete from head"), this._reduceData = !0; var le = { exec: function(oe) { return oe.openCursor(); }, callback: function(oe) { if (R._reduceData = !1, oe != null && oe.result) { var Te = IDBKeyRange.bound(oe.result.key, oe.result.key + D, !1, !1), Oe = { exec: function(he) { return R._ctx.logger.i("idb-backend", "del: " + Te.lower + "~" + Te.upper), he.delete(Te); }, callback: function(he) { R._ctx.logger.i("idb-backend", "del result: " + !(he == null || !he.error)); } }; R._idb.run(Oe); } } }; this._idb.run(le); }, ue._mergeGetAll = function(D) { return D.length ? D.reduce(function(R, le) { return "" + R + le.value + ` `; }, "") : ""; }, c()(De, [{ key: "isActive", get: function() { return this._idb.state !== "error"; } }]); }()]; function Be(De, ue, D) { var R = /* @__PURE__ */ new Date(); typeof De != "string" && (De = De.toString()); var le = R.toLocaleString() + "." + R.getMilliseconds().toString().padStart(3, "0") + "|" + De + "|"; return ue.forEach(function(oe) { le += typeof oe == "object" ? JSON.stringify(oe) + " " : oe + " "; }), le.length > D ? le.substring(0, D) : le; } function je(De) { return De.join(` `); } var He = function() { function De(D) { var R = 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() { R._delayTimer = setInterval(function() { R._saveLog(!0); }, 1e3); }, this._stopDelay = function() { R._delayTimer && (clearTimeout(R._delayTimer), R._delayTimer = void 0); }, I("kwai-video-local-log", "1.0.13"), this._ctx = new N(D); var le = function(oe) { for (var Te = arguments.length, Oe = new Array(Te > 1 ? Te - 1 : 0), he = 1; he < Te; he++) Oe[he - 1] = arguments[he]; R.addLog.apply(R, [oe].concat(Oe)); }; this._loggerForAdd = { e: le, w: le, i: le, d: le, v: le }, this._ctx.logger.setOutput(this._loggerForAdd), this._ctx.logger.i("kwai-video-local-log", "constructor", D, this._ctx.config), this._backend = function(oe) { for (var Te = 0; Te < Ce.length; Te++) { var Oe = Ce[Te]; if (Oe != null && Oe.isSupported()) return new Oe(oe); } }(this._ctx), this._backend && this._startDelay(); } De.isSupported = function() { return function() { for (var D = 0; D < Ce.length; D++) { var R = Ce[D]; if (R != null && R.isSupported()) return !0; } return !1; }(); }; var ue = De.prototype; return ue.addLog = function(D) { for (var R = arguments.length, le = new Array(R > 1 ? R - 1 : 0), oe = 1; oe < R; oe++) le[oe - 1] = arguments[oe]; this._logCache.push(Be(D, le, this._ctx.config.maxLogLen)), this._saveLog(); }, ue.cleanLog = function() { var D; this._ctx.logger.i("kwai-video-local-log", "clean"), (D = this._backend) == null || D.clean(); }, ue.exportLog = function() { var D = this; return this._ctx.logger.i("kwai-video-local-log", "export log"), new Promise(function(R, le) { D._backend ? D._backend.exportLog().then(function(oe) { R(je([oe].concat(D._logCache))); }) : R(""); }); }, ue.downloadLog = function(D) { var R = this; this._ctx.logger.i("kwai-video-local-log", "download log: " + D), this._destroyDownloadHref(), this.exportLog().then(function(le) { var oe = new Blob([le], { type: "text/plain" }); if (document) { var Te = document.createElement("a"); R._downloadHref = Te.href = URL.createObjectURL(oe), Te.download = D || "Log_web_" + (/* @__PURE__ */ new Date()).toLocaleString() + ".log", document.body.appendChild(Te), Te.click(), Te.remove(); } else console.log("无document,当前是否在worker中"); }); }, ue.destroy = function() { var D; this._destroyDownloadHref(), (D = this._backend) == null || D.destroy(), this._stopDelay(); }, ue.getLoggerForAdd = function() { return this._loggerForAdd; }, ue._destroyDownloadHref = function() { try { this._downloadHref && (URL.revokeObjectURL(this._downloadHref), this._downloadHref = void 0); } catch (D) { } }, ue._saveLog = function(D) { if (D === void 0 && (D = !1), this._backend && this._backend.isActive && (this._logCache.length >= this._ctx.config.idbMaxFoldLog || this._logCache.length > 0 && D)) { var R = je(this._logCache); this._logCache.splice(0, this._logCache.length), R && this._backend.saveLog(R); } }, c()(De, null, [{ key: "version", get: function() { return "1.0.13"; } }]); }(); n.default = He; }]); on === void 0 && console.error("esm-webpack-plugin: nothing exported!"); on.KwaiVideoLocalLog; const lu = on.LogLevel, Ii = on.DefaultLogger, hu = on.Logger, ff = on.printVersion; on.DEFAULT_LOG_LEVEL; on.default; var pf = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function _f(i) { return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i; } var ho = { exports: {} }, Sn = typeof Reflect == "object" ? Reflect : null, bc = Sn && typeof Sn.apply == "function" ? Sn.apply : function(i, n, a) { return Function.prototype.apply.call(i, n, a); }, Da; Sn && typeof Sn.ownKeys == "function" ? Da = Sn.ownKeys : Object.getOwnPropertySymbols ? Da = function(i) { return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i)); } : Da = function(i) { return Object.getOwnPropertyNames(i); }; function Af(i) { console && console.warn && console.warn(i); } var du = Number.isNaN || function(i) { return i !== i; }; function Zt() { Zt.init.call(this); } ho.exports = Zt; ho.exports.once = bf; Zt.EventEmitter = Zt; Zt.prototype._events = void 0; Zt.prototype._eventsCount = 0; Zt.prototype._maxListeners = void 0; var yc = 10; function Ya(i) { if (typeof i != "function") throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof i); } Object.defineProperty(Zt, "defaultMaxListeners", { enumerable: !0, get: function() { return yc; }, set: function(i) { if (typeof i != "number" || i < 0 || du(i)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + i + "."); yc = i; } }); Zt.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; }; Zt.prototype.setMaxListeners = function(i) { if (typeof i != "number" || i < 0 || du(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 fu(i) { return i._maxListeners === void 0 ? Zt.defaultMaxListeners : i._maxListeners; } Zt.prototype.getMaxListeners = function() { return fu(this); }; Zt.prototype.emit = function(i) { for (var n = [], a = 1; a < arguments.length; a++) n.push(arguments[a]); var u = i === "error", c = this._events; if (c !== void 0) u = u && c.error === void 0; else if (!u) return !1; if (u) { var A; if (n.length > 0 && (A = n[0]), A instanceof Error) throw A; var y = new Error("Unhandled error." + (A ? " (" + A.message + ")" : "")); throw y.context = A, y; } var T = c[i]; if (T === void 0) return !1; if (typeof T == "function") bc(T, this, n); else for (var I = T.length, U = gu(T, I), a = 0; a < I; ++a) bc(U[a], this, n); return !0; }; function pu(i, n, a, u) { var c, A, y; if (Ya(a), A = i._events, A === void 0 ? (A = i._events = /* @__PURE__ */ Object.create(null), i._eventsCount = 0) : (A.newListener !== void 0 && (i.emit( "newListener", n, a.listener ? a.listener : a ), A = i._events), y = A[n]), y === void 0) y = A[n] = a, ++i._eventsCount; else if (typeof y == "function" ? y = A[n] = u ? [a, y] : [y, a] : u ? y.unshift(a) : y.push(a), c = fu(i), c > 0 && y.length > c && !y.warned) { y.warned = !0; var T = new Error("Possible EventEmitter memory leak detected. " + y.length + " " + String(n) + " listeners added. Use emitter.setMaxListeners() to increase limit"); T.name = "MaxListenersExceededWarning", T.emitter = i, T.type = n, T.count = y.length, Af(T); } return i; } Zt.prototype.addListener = function(i, n) { return pu(this, i, n, !1); }; Zt.prototype.on = Zt.prototype.addListener; Zt.prototype.prependListener = function(i, n) { return pu(this, i, n, !0); }; function vf() { 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 _u(i, n, a) { var u = { fired: !1, wrapFn: void 0, target: i, type: n, listener: a }, c = vf.bind(u); return c.listener = a, u.wrapFn = c, c; } Zt.prototype.once = function(i, n) { return Ya(n), this.on(i, _u(this, i, n)), this; }; Zt.prototype.prependOnceListener = function(i, n) { return Ya(n), this.prependListener(i, _u(this, i, n)), this; }; Zt.prototype.removeListener = function(i, n) { var a, u, c, A, y; if (Ya(n), u = this._events, u === void 0) return this; if (a = u[i], a === void 0) return this; if (a === n || a.listener === n) --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete u[i], u.removeListener && this.emit("removeListener", i, a.listener || n)); else if (typeof a != "function") { for (c = -1, A = a.length - 1; A >= 0; A--) if (a[A] === n || a[A].listener === n) { y = a[A].listener, c = A; break; } if (c < 0) return this; c === 0 ? a.shift() : gf(a, c), a.length === 1 && (u[i] = a[0]), u.removeListener !== void 0 && this.emit("removeListener", i, y || n); } return this; }; Zt.prototype.off = Zt.prototype.removeListener; Zt.prototype.removeAllListeners = function(i) { var n, a, u; if (a = this._events, a === void 0) return this; if (a.removeListener === void 0) return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : a[i] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete a[i]), this; if (arguments.length === 0) { var c = Object.keys(a), A; for (u = 0; u < c.length; ++u) A = c[u], A !== "removeListener" && this.removeAllListeners(A); return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; } if (n = a[i], typeof n == "function") this.removeListener(i, n); else if (n !== void 0) for (u = n.length - 1; u >= 0; u--) this.removeListener(i, n[u]); return this; }; function Au(i, n, a) { var u = i._events; if (u === void 0) return []; var c = u[n]; return c === void 0 ? [] : typeof c == "function" ? a ? [c.listener || c] : [c] : a ? mf(c) : gu(c, c.length); } Zt.prototype.listeners = function(i) { return Au(this, i, !0); }; Zt.prototype.rawListeners = function(i) { return Au(this, i, !1); }; Zt.listenerCount = function(i, n) { return typeof i.listenerCount == "function" ? i.listenerCount(n) : vu.call(i, n); }; Zt.prototype.listenerCount = vu; function vu(i) { var n = this._events; if (n !== void 0) { var a = n[i]; if (typeof a == "function") return 1; if (a !== void 0) return a.length; } return 0; } Zt.prototype.eventNames = function() { return this._eventsCount > 0 ? Da(this._events) : []; }; function gu(i, n) { for (var a = new Array(n), u = 0; u < n; ++u) a[u] = i[u]; return a; } function gf(i, n) { for (; n + 1 < i.length; n++) i[n] = i[n + 1]; i.pop(); } function mf(i) { for (var n = new Array(i.length), a = 0; a < n.length; ++a) n[a] = i[a].listener || i[a]; return n; } function bf(i, n) { return new Promise(function(a, u) { function c(y) { i.removeListener(n, A), u(y); } function A() { typeof i.removeListener == "function" && i.removeListener("error", c), a([].slice.call(arguments)); } mu(i, n, A, { once: !0 }), n !== "error" && yf(i, c, { once: !0 }); }); } function yf(i, n, a) { typeof i.on == "function" && mu(i, "error", n, a); } function mu(i, n, a, u) { if (typeof i.on == "function") u.once ? i.once(n, a) : i.on(n, a); else if (typeof i.addEventListener == "function") i.addEventListener(n, function c(A) { u.once && i.removeEventListener(n, c), a(A); }); else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof i); } var Ef = ho.exports, bu = function() { if (typeof Map < "u") return Map; function i(n, a) { var u = -1; return n.some(function(c, A) { return c[0] === a ? (u = A, !0) : !1; }), u; } return ( /** @class */ function() { function n() { this.__entries__ = []; } return Object.defineProperty(n.prototype, "size", { /** * @returns {boolean} */ get: function() { return this.__entries__.length; }, enumerable: !0, configurable: !0 }), n.prototype.get = function(a) { var u = i(this.__entries__, a), c = this.__entries__[u]; return c && c[1]; }, n.prototype.set = function(a, u) { var c = i(this.__entries__, a); ~c ? this.__entries__[c][1] = u : this.__entries__.push([a, u]); }, n.prototype.delete = function(a) { var u = this.__entries__, c = i(u, a); ~c && u.splice(c, 1); }, n.prototype.has = function(a) { return !!~i(this.__entries__, a); }, n.prototype.clear = function() { this.__entries__.splice(0); }, n.prototype.forEach = function(a, u) { u === void 0 && (u = null); for (var c = 0, A = this.__entries__; c < A.length; c++) { var y = A[c]; a.call(u, y[1], y[0]); } }, n; }() ); }(), Gs = typeof window < "u" && typeof document < "u" && window.document === document, Pa = 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")(); }(), Cf = function() { return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(Pa) : function(i) { return setTimeout(function() { return i(Date.now()); }, 1e3 / 60); }; }(), If = 2; function Tf(i, n) { var a = !1, u = !1, c = 0; function A() { a && (a = !1, i()), u && T(); } function y() { Cf(A); } function T() { var I = Date.now(); if (a) { if (I - c < If) return; u = !0; } else a = !0, u = !1, setTimeout(y, n); c = I; } return T; } var Rf = 20, wf = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], Df = typeof MutationObserver < "u", Sf = ( /** @class */ function() { function i() { this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = Tf(this.refresh.bind(this), Rf); } return i.prototype.addObserver = function(n) { ~this.observers_.indexOf(n) || this.observers_.push(n), this.connected_ || this.connect_(); }, i.prototype.removeObserver = function(n) { var a = this.observers_, u = a.indexOf(n); ~u && a.splice(u, 1), !a.length && this.connected_ && this.disconnect_(); }, i.prototype.refresh = function() { var n = this.updateObservers_(); n && this.refresh(); }, i.prototype.updateObservers_ = function() { var n = this.observers_.filter(function(a) { return a.gatherActive(), a.hasActive(); }); return n.forEach(function(a) { return a.broadcastActive(); }), n.length > 0; }, i.prototype.connect_ = function() { !Gs || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), Df ? (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() { !Gs || !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(n) { var a = n.propertyName, u = a === void 0 ? "" : a, c = wf.some(function(A) { return !!~u.indexOf(A); }); c && this.refresh(); }, i.getInstance = function() { return this.instance_ || (this.instance_ = new i()), this.instance_; }, i.instance_ = null, i; }() ), yu = function(i, n) { for (var a = 0, u = Object.keys(n); a < u.length; a++) { var c = u[a]; Object.defineProperty(i, c, { value: n[c], enumerable: !1, writable: !1, configurable: !0 }); } return i; }, Nn = function(i) { var n = i && i.ownerDocument && i.ownerDocument.defaultView; return n || Pa; }, Eu = Qa(0, 0, 0, 0); function Ua(i) { return parseFloat(i) || 0; } function Ec(i) { for (var n = [], a = 1; a < arguments.length; a++) n[a - 1] = arguments[a]; return n.reduce(function(u, c) { var A = i["border-" + c + "-width"]; return u + Ua(A); }, 0); } function Lf(i) { for (var n = ["top", "right", "bottom", "left"], a = {}, u = 0, c = n; u < c.length; u++) { var A = c[u], y = i["padding-" + A]; a[A] = Ua(y); } return a; } function Of(i) { var n = i.getBBox(); return Qa(0, 0, n.width, n.height); } function Nf(i) { var n = i.clientWidth, a = i.clientHeight; if (!n && !a) return Eu; var u = Nn(i).getComputedStyle(i), c = Lf(u), A = c.left + c.right, y = c.top + c.bottom, T = Ua(u.width), I = Ua(u.height); if (u.boxSizing === "border-box" && (Math.round(T + A) !== n && (T -= Ec(u, "left", "right") + A), Math.round(I + y) !== a && (I -= Ec(u, "top", "bottom") + y)), !Mf(i)) { var U = Math.round(T + A) - n, h = Math.round(I + y) - a; Math.abs(U) !== 1 && (T -= U), Math.abs(h) !== 1 && (I -= h); } return Qa(c.left, c.top, T, I); } var kf = function() { return typeof SVGGraphicsElement < "u" ? function(i) { return i instanceof Nn(i).SVGGraphicsElement; } : function(i) { return i instanceof Nn(i).SVGElement && typeof i.getBBox == "function"; }; }(); function Mf(i) { return i === Nn(i).document.documentElement; } function xf(i) { return Gs ? kf(i) ? Of(i) : Nf(i) : Eu; } function Pf(i) { var n = i.x, a = i.y, u = i.width, c = i.height, A = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, y = Object.create(A.prototype); return yu(y, { x: n, y: a, width: u, height: c, top: a, right: n + u, bottom: c + a, left: n }), y; } function Qa(i, n, a, u) { return { x: i, y: n, width: a, height: u }; } var Uf = ( /** @class */ function() { function i(n) { this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = Qa(0, 0, 0, 0), this.target = n; } return i.prototype.isA