UNPKG

@cataract6545/tmui

Version:

tm-vuetify是一个新势力由主题驱动的UI组件库,相比其它优势大,组件全,设计趋势紧跟未来。具有主题生成,主题实时切换,暗黑实时切换,lottie动画,图表等新颖功能,tmui TMUI

1,358 lines (1,355 loc) 83.1 kB
const e = "android" === wx.getSystemInfoSync().platform, t = `${wx.env.USER_DATA_PATH}/pag/`, i = wx.getFileSystemManager(); let r; try { r = performance.now.bind(performance) } catch (e) { r = Date.now } class s { constructor() { this.startTime = r(), this.markers = {} } reset() { this.startTime = r(), this.markers = {} } mark(e) { e ? Object.keys(this.markers).find((t => t === e)) ? console.log( `Clock.mark(): The specified marker name '${e}' already exists!`) : this.markers[e] = r() : console .log("Clock.mark(): An empty marker name was specified!") } measure(e, t) { let i, s; if (e) { if (!Object.keys(this.markers).find((t => t === e))) return console.log( `Clock.measure(): The specified makerFrom '${e}' does not exist!`), 0; i = this.markers[e] } else i = this.startTime; if (t) { if (!Object.keys(this.markers).find((e => e === t))) return console.log( `Clock.measure(): The specified makerTo '${t}' does not exist!`), 0; s = this.markers[t] } else s = r(); return s - i } } function a(e) { let t = Object.getOwnPropertyNames(e.prototype).filter((t => "constructor" !== t && "function" == typeof e .prototype[t])); const i = (e, t) => { const i = e[t]; e[t] = function (...e) { if (!this.destroyed) return i.call(this, ...e); console.error(`Don't call ${t} of the PAGView that is destroyed.`) } }; t.forEach((t => i(e.prototype, t))) } const n = { alpha: !0, depth: !1, stencil: !1, antialias: !1 }; var o = (e => (e[e.Normal = 0] = "Normal", e[e.Multiply = 1] = "Multiply", e[e.Screen = 2] = "Screen", e[e.Overlay = 3] = "Overlay", e[e.Darken = 4] = "Darken", e[e.Lighten = 5] = "Lighten", e[e.ColorDodge = 6] = "ColorDodge", e[e.ColorBurn = 7] = "ColorBurn", e[e.HardLight = 8] = "HardLight", e[e.SoftLight = 9] = "SoftLight", e[e.Difference = 10] = "Difference", e[e.Exclusion = 11] = "Exclusion", e[e.Hue = 12] = "Hue", e[e.Saturation = 13] = "Saturation", e[e.Color = 14] = "Color", e[e.Luminosity = 15] = "Luminosity", e[e .DestinationIn = 21] = "DestinationIn", e[e.DestinationOut = 22] = "DestinationOut", e[e .DestinationATop = 23] = "DestinationATop", e[e.SourceIn = 24] = "SourceIn", e[e.SourceOut = 25] = "SourceOut", e[e.Xor = 26] = "Xor", e))(o || {}), h = (e => (e[e.None = 0] = "None", e[e.Linear = 1] = "Linear", e[e.Bezier = 2] = "Bezier", e[e.Hold = 3] = "Hold", e))(h || {}); const l = navigator && /(ios|ipad|iphone)/.test(navigator.userAgent.toLowerCase()), d = e => { const t = []; for (let i = 0; i < e.length; i++) t.push(e.charCodeAt(i)); return t }, c = e => [e >> 24, e >> 16 & 255, e >> 8 & 255, 255 & e], u = (e, ...t) => { let i = 8, r = t.length; const s = r; for (; r;) r -= 1, i += t[r].byteLength; const a = new Uint8Array(i); for (a[0] = i >> 24 & 255, a[1] = i >> 16 & 255, a[2] = i >> 8 & 255, a[3] = 255 & i, a.set(e, 4), r = 0, i = 8; r < s; ++r) a.set(t[r], i), i += t[r].byteLength; return a }; class m { constructor(e) { this.param = e } ftyp() { return u(d("ftyp"), new Uint8Array(d("isom")), new Uint8Array([0, 0, 0, 1]), new Uint8Array(d("isom")), new Uint8Array(d("iso2")), new Uint8Array(d("avc1")), new Uint8Array(d("mp41"))) } moov() { const e = this.param.tracks.map((e => this.trak(e))).reverse(); return u(d("moov"), this.mvhd(), ...e, this.mvex()) } moof() { return u(d("moof"), this.mfhd(), this.traf()) } mdat() { const e = new Uint8Array(this.param.track.len); let t = 0; return this.param.videoSequence.headers.forEach((i => { e.set(new Uint8Array(i.data.data()), t), t += i.length })), this.param.videoSequence.frames.forEach(((i, r) => { e.set(new Uint8Array(i.fileBytes.data.data()), t), t += i.fileBytes.length })), u(d("mdat"), e) } mvhd() { return u(d("mvhd"), new Uint8Array([0, 0, 0, 0, ...c(2082873600), ...c(2082873600), ...c(this.param .timescale), ...c(this.param.duration), 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 ])) } trak(e) { return u(d("trak"), this.tkhd(e), this.edts(e), this.mdia(e)) } tkhd(e) { return u(d("tkhd"), new Uint8Array([0, 0, 0, 1, ...c(2082873600), ...c(2082873600), ...c(e.id), 0, 0, 0, 0, ...c(e.duration), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, e.width >> 8 & 255, 255 & e.width, 0, 0, e.height >> 8 & 255, 255 & e.height, 0, 0 ])) } edts(e) { return u(d("edts"), this.elst(e)) } elst(e) { return u(d("elst"), new Uint8Array([0, 0, 0, 0, ...c(1), ...c(e.duration), ...c(e.implicitOffset * Math .floor(e.duration / e.samples.length)), 0, 1, 0, 0])) } mdia(e) { return u(d("mdia"), this.mdhd(), this.hdlr(), this.minf(e)) } mdhd() { return u(d("mdhd"), new Uint8Array([0, 0, 0, 0, ...c(2082873600), ...c(2082873600), ...c(this.param .timescale), ...c(0), 85, 196, 0, 0])) } hdlr() { return u(d("hdlr"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110, 100, 108, 101, 114, 0 ])) } minf(e) { return u(d("minf"), this.vmhd(), this.dinf(), this.stbl(e)) } vmhd() { return u(d("vmhd"), new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0])) } dinf() { return u(d("dinf"), this.dref()) } dref() { return u(d("dref"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0, 0, 0, 1])) } stbl(e) { return u(d("stbl"), this.stsd(e), this.stts(e), this.ctts(e), this.stss(e), this.stsc(), this.stsz(), this .stco()) } stsd(e) { return u(d("stsd"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]), this.avc1(e)) } avc1(e) { const t = [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, e.width >> 8 & 255, 255 & e.width, e.height >> 8 & 255, 255 & e.height, 0, 72, 0, 0, 0, 72, 0, 0, 0, 0, 0, 0, 0, 1, 18, 98, 105, 110, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 255, 255 ]; return u(d("avc1"), new Uint8Array(t), this.avcc(e)) } avcc(e) { let t = [], i = []; e.sps.forEach((e => { const i = e.length - 4; t.push(i >>> 8 & 255), t.push(255 & i), t = t.concat(Array.prototype.slice.call( new Uint8Array(e.data.data(), 4))) })), e.pps.forEach((e => { const t = e.length - 4; i.push(t >>> 8 & 255), i.push(255 & t), i = i.concat(Array.prototype.slice.call( new Uint8Array(e.data.data(), 4))) })); const r = [1, t[3], t[4], t[5], 255, 224 | e.sps.length].concat(t).concat([e.pps.length]).concat(i); return u(d("avcC"), new Uint8Array(r)) } stts(e) { return u(d("stts"), new Uint8Array([0, 0, 0, 0, ...c(1), ...c(e.samples.length), ...c(Math.floor(e .duration / e.samples.length))])) } ctts(e) { const t = e.pts.length, i = Math.floor(e.duration / t), r = [0, 0, 0, 0, ...c(t)]; for (let s = 0; s < t; s++) { r.push(...c(1)); const t = s * i, a = (e.pts[s] + e.implicitOffset) * i; r.push(...c(a - t)) } return u(d("ctts"), new Uint8Array(r)) } stss(e) { const t = e.samples.filter((e => e.flags.isKeyFrame)).map((e => e.index + 1)), i = [0, 0, 0, 0, ...c(t.length)]; return t.forEach((e => { i.push(...c(e)) })), u(d("stss"), new Uint8Array(i)) } stsc() { return u(d("stsc"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])) } stsz() { return u(d("stsz"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) } stco() { return u(d("stco"), new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])) } mvex() { const e = this.param.tracks.map((e => this.trex(e))).reverse(); return u(d("mvex"), ...e) } trex(e) { return u(d("trex"), new Uint8Array([0, 0, 0, 0, e.id >> 24, e.id >> 16 & 255, e.id >> 8 & 255, 255 & e.id, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1 ])) } mfhd() { return u(d("mfhd"), new Uint8Array([0, 0, 0, 0, this.param.sequenceNumber >> 24, this.param .sequenceNumber >> 16 & 255, this.param.sequenceNumber >> 8 & 255, 255 & this.param .sequenceNumber ])) } traf() { const e = this.sdtp(); return this.param.offset = e.length + 72, u(d("traf"), this.tfhd(), this.tfdt(), this.trun(), e) } tfhd() { return u(d("tfhd"), new Uint8Array([0, 0, 0, 0, ...c(this.param.track.id)])) } tfdt() { return u(d("tfdt"), new Uint8Array([0, 0, 0, 0, ...c(this.param.baseMediaDecodeTime)])) } trun() { const e = (this.param.track.samples || []).length, t = 12 + 16 * e; this.param.offset += 8 + t; const i = [0, 0, 15, 1, ...c(e), ...c(this.param.offset)]; return this.param.track.samples.forEach((e => { const { duration: t, size: r, flags: s, cts: a } = e; i.push(...c(t)), i.push(...c(r)), i.push(s.isLeading << 2 | s.dependsOn), i.push(s .isDependedOn << 6 | s.hasRedundancy << 4 | 0 | s.isNonSync), i.push(61440 & s .degradPrio), i.push(15 & s.degradPrio), i.push(...c(a)) })), u(d("trun"), new Uint8Array(i)) } sdtp() { const e = new Uint8Array(4 + this.param.track.samples.length); return this.param.track.samples.forEach(((t, i) => { e[i + 4] = t.flags.dependsOn << 4 | t.flags.isDependedOn << 2 | t.flags.hasRedundancy })), u(d("sdtp"), e) } } var f = Object.defineProperty, p = Object.getOwnPropertySymbols, g = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable, w = (e, t, i) => t in e ? f(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, v = (e, t) => { for (var i in t || (t = {})) g.call(t, i) && w(e, i, t[i]); if (p) for (var i of p(t)) y.call(t, i) && w(e, i, t[i]); return e }; const b = e => { const t = l ? T(e) : e, i = S(t); if (!i || 0 === i.len) throw new Error("mp4Track is empty"); const r = { offset: 0, tracks: [i], track: i, duration: i.duration, timescale: i.timescale, sequenceNumber: 1, baseMediaDecodeTime: 0, nalusBytesLen: i.len, videoSequence: t }, s = new m(r); return (e => { let t = 0; for (const i of e) t += i.byteLength; const i = new Uint8Array(t); let r = 0; for (const t of e) i.set(t, r), r += t.byteLength; return i })([s.ftyp(), s.moov(), s.moof(), s.mdat()]) }, S = e => { if (e.headers.length < 2) throw new Error("Bad header data in video sequence!"); if (0 === e.frames.length) throw new Error("There is no frame data in the video sequence!"); const t = { id: 1, type: "video", timescale: 6e3, duration: Math.floor(6e3 * e.frames.length / e.frameRate), width: e.getVideoWidth(), height: e.getVideoHeight(), sps: [e.headers[0]], pps: [e.headers[1]], implicitOffset: E(e.frames), len: 0, pts: [], samples: [] }, i = e.headers.reduce(((e, t) => e + t.length), 0), r = t.duration / e.frames.length; return e.frames.forEach(((e, s) => { var a; let n = null != (a = e.fileBytes.length) ? a : 0; 0 === s && (n += i), t.len += n, t.pts.push(e.frame), t.samples.push({ index: s, size: n, duration: r, cts: (e.frame + t.implicitOffset - s) * r, flags: { isKeyFrame: e.isKeyframe, isNonSync: e.isKeyframe ? 0 : 1, dependsOn: e.isKeyframe ? 2 : 1, isLeading: 0, isDependedOn: 0, hasRedundancy: 0, degradPrio: 0 } }) })), t }, E = e => Math.max(...e.map(((e, t) => t - e.frame))), T = e => { const t = e.frames.length; for (let i = 0; i < e.frames.length; i++) { const r = v({}, e.frames[i]); if (r.isKeyframe && i > 0) break; r.frame += t, e.frames.push(r) } return e }, x = (e, t, i) => { const r = e.createProgram(); if (!r) throw new Error("Failed to create program."); const s = R(e, t, e.VERTEX_SHADER); if (!s) throw new Error("Failed to create vertex shader."); e.attachShader(r, s); const a = R(e, i, e.FRAGMENT_SHADER); if (!a) throw new Error("Failed to create fragment shader."); e.attachShader(r, a), e.linkProgram(r); const n = e.getProgramInfoLog(r); n && console.log(n); const o = e.getShaderInfoLog(s); o && console.log(o); const h = e.getShaderInfoLog(a); return h && console.log(h), r }, R = (e, t, i) => { const r = e.createShader(i); if (!r) throw new Error("Failed to create shader."); return e.shaderSource(r, t), e.compileShader(r), r }, P = e => e.replace(/^\s+|\s+$/g, ""), A = e => { const t = e.createTexture(); if (!t) throw new Error("Failed to create texture."); return e.bindTexture(e.TEXTURE_2D, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e .texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e .TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), t }; let D = {}; const k = (e, t, i, r = !1) => { var s; t in D || (D[t] = []), null == (s = D[t]) || s.push({ node: e, handler: i, capture: r }), e.addEventListener(t, i, r) }; var F = Object.defineProperty, V = Object.getOwnPropertyDescriptor; const C = navigator && /MicroMessenger/i.test(navigator.userAgent), L = async e => { C && window.WeixinJSBridge && await new Promise((e => { window.WeixinJSBridge.invoke("getNetworkType", {}, (() => { e() }), (() => { e() })) })); try { await e.play() } catch (e) { throw new Error(e.message) } }; let B = class { constructor(e) { this.destroyed = !1, this.frameRate = 0, this._duration = e.frameCount / e.frameRate, this.frameRate = e .frameRate } static create(e) { const t = new B(e), i = t.load(e); return { videoReader: t, debugData: i } } getVideoElement() { return this.videoElement } progress() { return Math.round(this.videoElement.currentTime / this._duration * 100) / 100 } duration() { return this._duration } currentTime() { return this.videoElement.currentTime || 0 } start() { return L(this.videoElement) } pause() { var e; null == (e = this.videoElement) || e.pause() } seek(e) { return new Promise((t => { const i = () => { var e, r, s, a, n, o, h; e = this.videoElement, s = i, (r = "seeked") in D && (s ? (null == (a = D[r]) || a.filter((({ node: t, handler: i }) => t === e && i === s)).forEach((({ node: e, handler: t, capture: i }) => e.removeEventListener(r, t, i))), D[r] = null == (n = D[r]) ? void 0 : n.filter((({ node: t, handler: i }) => !(t === e && i === s)))) : (null == (o = D[r]) || o.filter((({ node: t }) => t === e)).forEach((({ node: e, handler: t, capture: i }) => e.removeEventListener(r, t, i))), D[r] = null == (h = D[r]) ? void 0 : h.filter((({ node: t }) => t !== e)))), t() }; k(this.videoElement, "seeked", i), this.videoElement.currentTime = e })) } addListener(e, t) { k(this.videoElement, e, t) } removeAllListeners() { var e; e = this.videoElement, Object.keys(D).forEach((t => { var i, r; const s = t; null == (i = D[s]) || i.filter((({ node: t }) => t === e)).forEach((({ node: e, handler: t, capture: i }) => e.removeEventListener(s, t, i))), D[s] = null == (r = D[s]) ? void 0 : r .filter((({ node: t }) => t !== e)) })) } getFrameData(e) { } clearCallback() { } destroy() { this.removeAllListeners(), this.videoElement = void 0, this.destroyed = !0 } load(e) { this.videoElement = document.createElement("video"), this.videoElement.style.display = "none", this .videoElement.muted = !0, this.videoElement.playsInline = !0; const t = new s, i = b(e); return t.mark("coverMP4"), this.videoElement.src = URL.createObjectURL(new Blob([i], { type: "video/mp4" })), this.videoElement.load(), { coverMP4: t.measure("", "coverMP4") } } }; B = ((e, t, i, r) => { for (var s, a = r > 1 ? void 0 : r ? V(t, i) : t, n = e.length - 1; n >= 0; n--)(s = e[n]) && (a = (r ? s(t, i, a) : s(a)) || a); return r && a && F(t, i, a), a })([a], B); var _ = Object.defineProperty, U = Object.getOwnPropertyDescriptor; const M = (e, t) => { const i = new ArrayBuffer(t.data.byteLength); return new Uint8Array(i).set(new Uint8Array(t.data)), { id: e, data: i, width: t.width, height: t.height } }; let I = class extends B { constructor() { super(...arguments), this.started = !1, this.frameDataBuffers = [], this.getFrameDataLooping = !1, this .getFrameDataCallback = null, this.getFrameDataLoopTimer = null, this.currentFrame = 0, this .seeking = !1 } static create(e) { const t = new I(e), i = t.load(e); return { videoReader: t, debugData: i } } getVideoElement() { throw new Error("WeChat mini program does not support video element as decoder!") } progress() { return 0 } duration() { return 0 } currentTime() { return 0 } async start() { this.started || (this.started = !0, await this.loadedPromise, this.startGetFrameDataLoop()) } pause() { } async seek(e) { var t; const i = Math.floor(e * this.frameRate); if (this.frameDataBuffers.length > 0) { const e = this.frameDataBuffers.findIndex((e => e.id === i)); if (-1 !== e) return void (this.frameDataBuffers = this.frameDataBuffers.slice(e)); this.frameDataBuffers = [] } i !== this.currentFrame && (this.seeking = !0, await (null == (t = this.videoDecoder) ? void 0 : t.seek( e)), this.seeking = !1, this.currentFrame = i) } getFrameData(e) { if (this.frameDataBuffers.length <= 2 && !this.getFrameDataLooping && this.startGetFrameDataLoop(), 0 === this.frameDataBuffers.length) return void (this.getFrameDataCallback = e); const t = this.frameDataBuffers.shift(); t ? e(t) : this.getFrameDataCallback = e } addListener(e, t) { var i; const r = e; null == (i = this.videoDecoder) || i.on(r, t) } removeAllListeners() { } destroy() { var e; this.clearFrameDataLoop(), this.clearCallback(), null == (e = this.videoDecoder) || e.remove(), this .videoDecoder = void 0, this.mp4Path && (e => { try { i.accessSync(e), i.unlinkSync(e) } catch (e) { console.error(e) } })(this.mp4Path), this.destroyed = !0 } clearCallback() { this.getFrameDataCallback = null } load(e) { const r = new s; this.mp4Path = `${t}${Date.now()}.mp4`, (e => { try { i.accessSync(e) } catch (t) { try { i.mkdirSync(e) } catch (e) { console.error(t) } } })(t), r.mark("createDir"); const a = b(e); return r.mark("coverMP4"), ((e, t) => { try { i.writeFileSync(e, t, "utf8") } catch (e) { throw new Error(e) } })(this.mp4Path, a.buffer), r.mark("writeFile"), this.videoDecoder = wx.createVideoDecoder(), r .mark("createDecoder"), this.loadedPromise = this.videoDecoder.start({ source: this.mp4Path, mode: 1 }), this.videoDecoder.on("ended", (() => { var e; null == (e = this.videoDecoder) || e.seek(0).then((() => { this.currentFrame = 0 })) })), { createDir: r.measure("", "createDir"), coverMP4: r.measure("createDir", "coverMP4"), writeFile: r.measure("coverMP4", "writeFile"), createDecoder: r.measure("writeFile", "createDecoder") } } startGetFrameDataLoop() { this.getFrameDataLooping = !0, this.getFrameDataLoopTimer = setInterval((() => { this.getFrameDataLoop() }), 2) } getFrameDataLoop() { if (this.seeking) return; if (!this.videoDecoder) throw this.clearFrameDataLoop(), new Error("VideoDecoder is not ready!"); if (this.frameDataBuffers.length >= 6) return this.getFrameDataLooping = !1, void this .clearFrameDataLoop(); const e = this.videoDecoder.getFrameData(); null !== e && (this.getFrameDataCallback ? (this.getFrameDataCallback(M(this.currentFrame, e)), this .getFrameDataCallback = null) : this.frameDataBuffers.push(M(this.currentFrame, e)), this .currentFrame += 1) } clearFrameDataLoop() { this.getFrameDataLoopTimer && (clearInterval(this.getFrameDataLoopTimer), this.getFrameDataLoopTimer = null), this.getFrameDataLooping = !1 } }; I = ((e, t, i, r) => { for (var s, a = r > 1 ? void 0 : r ? U(t, i) : t, n = e.length - 1; n >= 0; n--)(s = e[n]) && (a = (r ? s(t, i, a) : s(a)) || a); return r && a && _(t, i, a), a })([a], I); var O = (e => (e.Canvas2D = "2d", e.WebGL = "WebGL", e))(O || {}), q = (e => (e.onAnimationStart = "onAnimationStart", e.onAnimationEnd = "onAnimationEnd", e.onAnimationCancel = "onAnimationCancel", e.onAnimationRepeat = "onAnimationRepeat", e.onAnimationUpdate = "onAnimationUpdate", e .onAnimationPlay = "onAnimationPlay", e.onAnimationPause = "onAnimationPause", e))(q || {}), G = (e => (e.None = "None", e.Stretch = "Stretch", e.LetterBox = "LetterBox", e.Zoom = "Zoom", e))(G || {}), N = Object.freeze({ __proto__: null, RenderingMode: O, EventName: q, ScaleMode: G }); const z = "\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform vec2 u_resolution;\n uniform vec2 u_scale;\n \n varying vec2 v_texCoord;\n \n \n void main() {\n // convert the rectangle from pixels to 0.0 to 1.0\n vec2 zeroToOne = a_position / u_resolution;\n \n // convert from 0->1 to 0->2\n vec2 zeroToTwo = zeroToOne * 2.0;\n \n // convert from 0->2 to -1->+1 (clipspace)\n vec2 clipSpace = zeroToTwo - 1.0;\n \n gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);\n \n // pass the texCoord to the fragment shader\n // The GPU will interpolate this value between points.\n v_texCoord = a_texCoord / u_scale;\n }\n "; class W { constructor() { this.listenersMap = {} } on(e, t) { void 0 === this.listenersMap[e] && (this.listenersMap[e] = []), this.listenersMap[e].push(t) } off(e, t) { const i = this.listenersMap[e]; if (void 0 === i) return; if (void 0 === t) return void delete this.listenersMap[e]; const r = i.findIndex((e => e === t)); i.splice(r, 1) } emit(e, ...t) { const i = this.listenersMap[e]; if (void 0 === i || i.length < 1) return !1; for (const e of i) e(...t); return !0 } } var X = Object.defineProperty, H = Object.getOwnPropertyDescriptor, j = Object.getOwnPropertySymbols, K = Object.prototype.hasOwnProperty, Y = Object.prototype.propertyIsEnumerable, $ = (e, t, i) => t in e ? X(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i, Z = (e, t) => { for (var i in t || (t = {})) K.call(t, i) && $(e, i, t[i]); if (j) for (var i of j(t)) Y.call(t, i) && $(e, i, t[i]); return e }; let J = class { constructor(e, t, i) { this.canvasSize = { width: 0, height: 0 }, this.playing = !1, this.viewportSize = { x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 }, this.destroyed = !1, this.renderTimer = null, this.repeatCount = 0, this.viewScaleMode = G .LetterBox, this.debugData = { FPS: 0, decodePAGFile: 0, createDir: 0, coverMP4: 0, writeFile: 0, createDecoder: 0, getFrame: 0, draw: 0 }; const r = e.getVideoSequence(); if (!r) throw new Error("PAGFile has no BMP video sequence!"); delete r.composition, this.videoSequence = r, this.canvas = t, this.videoParam = ((e, t) => ({ width: e.mainComposition.width, height: e.mainComposition.height, hasAlpha: t.alphaStartX > 0 || t.alphaStartY > 0, alphaStartX: t.alphaStartX, alphaStartY: t.alphaStartY, sequenceWidth: t.width, sequenceHeight: t.height, MP4Width: (t.width + t.alphaStartX) % 2 == 0 ? t.width + t.alphaStartX : t.width + t .alphaStartX + 1, MP4Height: (t.height + t.alphaStartY) % 2 == 0 ? t.height + t.alphaStartY : t.height + t .alphaStartY + 1 }))(e, r), this.eventManager = new W, this.renderingMode = i.renderingMode || O.WebGL, this .updateSize(i.useScale), this.setScaleMode() } isPlaying() { return this.playing } isDestroyed() { return this.destroyed } duration() { return this.videoSequence.frameCount / this.videoSequence.frameRate } frameRate() { return this.videoSequence.frameRate } setRepeatCount(e = 1) { this.repeatCount = e < 0 ? -1 : e - 1 } addListener(e, t) { return this.eventManager.on(e, t) } removeListener(e, t) { return this.eventManager.off(e, t) } scaleMode() { return this.viewScaleMode } setScaleMode(e = G.LetterBox) { switch (this.viewScaleMode = e, e) { case G.None: this.viewportSize = { x: 0, y: this.renderingMode === O.WebGL ? this.canvas.height - this.videoParam.height : 0, width: this.videoParam.width, height: this.videoParam.height, scaleX: 1, scaleY: 1 }; break; case G.Stretch: this.viewportSize = { x: 0, y: 0, width: this.canvas.width, height: this.canvas.height, scaleX: this.canvas.width / this.videoParam.sequenceWidth, scaleY: this.canvas.height / this.videoParam.sequenceHeight }; break; case G.LetterBox: { const e = this.canvas.width / this.videoParam.sequenceWidth, t = this.canvas.height / this.videoParam.sequenceHeight, i = Math.min(e, t); this.viewportSize = { x: (this.canvas.width - this.videoParam.sequenceWidth * i) / 2, y: (this.canvas.height - this.videoParam.sequenceHeight * i) / 2, width: this.videoParam.sequenceWidth * i, height: this.videoParam.sequenceHeight * i, scaleX: i, scaleY: i } } break; case G.Zoom: { const e = this.canvas.width / this.videoParam.sequenceWidth, t = this.canvas.height / this.videoParam.sequenceHeight, i = Math.max(e, t); this.viewportSize = { x: (this.canvas.width - this.videoParam.sequenceWidth * i) / 2, y: (this.canvas.height - this.videoParam.sequenceHeight * i) / 2, width: this.videoParam.sequenceWidth * i, height: this.videoParam.sequenceHeight * i, scaleX: i, scaleY: i } } } } updateSize(e = !0) { if (!this.canvas) throw new Error("Canvas element is not found!"); let t; const i = getComputedStyle(this.canvas), r = { width: Number(i.width.replace("px", "")), height: Number(i.height.replace("px", "")) }; if (r.width > 0 && r.height > 0) t = r; else { const e = { width: Number(this.canvas.style.width.replace("px", "")), height: Number(this.canvas.style.height.replace("px", "")) }; t = e.width > 0 && e.height > 0 ? e : { width: this.canvas.width, height: this.canvas.height } } if (!e) return this.canvas.width = this.canvas.width || t.width, void (this.canvas.height = this.canvas .height || t.height); this.canvas.style.width = `${t.width}px`, this.canvas.style.height = `${t.height}px`, this.canvas .width = t.width * window.devicePixelRatio, this.canvas.height = t.height * window.devicePixelRatio } getDebugData() { return this.debugData } setDebugData(e) { this.debugData = Z(Z({}, this.debugData), e) } loadContext() { } clearRender() { } }; J = ((e, t, i, r) => { for (var s, a = r > 1 ? void 0 : r ? H(t, i) : t, n = e.length - 1; n >= 0; n--)(s = e[n]) && (a = (r ? s(t, i, a) : s(a)) || a); return r && a && X(t, i, a), a })([a], J); var Q = Object.defineProperty, ee = Object.getOwnPropertyDescriptor; navigator && /MicroMessenger/i.test(navigator.userAgent); let te = class extends J { constructor(e, t, i) { super(e, t, i), this.fpsBuffer = [], this.currentFrame = -1, this.needSeek = !1, this.videoReader = this .createVideoReader(this.videoSequence) } async play() { this.playing || (this.playing = !0, await this.videoReader.start(), await this.flushLoop(), 0 === this .getProgress() && this.eventManager.emit(q.onAnimationStart), this.eventManager.emit(q .onAnimationPlay)) } pause() { this.playing && (this.videoReader.pause(), this.clearTimer(), this.playing = !1, this.eventManager.emit( q.onAnimationPause)) } stop() { this.videoReader.pause(), this.videoReader.seek(0), this.clearRender(), this.playing = !1, this .eventManager.emit(q.onAnimationCancel) } destroy() { this.clearTimer(), this.clearRender(), this.canvas = null, this.videoReader.destroy(), this .destroyed = !0 } getProgress() { return this.currentFrame / this.videoSequence.frameCount } setProgress(e) { if (e < 0 || e > 1) throw new Error("progress must be between 0.0 and 1.0!"); const t = Math.round(e * this.videoSequence.frameCount); this.currentFrame !== t && (this.needSeek = !0, this.currentFrame = t) } flush() { return this.flushInternal(!0) } draw() { } createVideoReader(e) { const { videoReader: t, debugData: i } = B.create(e); return this.setDebugData(i), l || t.addListener("ended", (() => { this.repeat() })), t } async repeat() { return 0 === this.repeatCount ? (this.setProgress(1), await this.flushInternal(!0), this.videoReader .pause(), this.clearTimer(), this.playing = !1, this.eventManager.emit("onAnimationEnd"), !1) : (this.repeatCount -= 1, l ? await this.videoReader.seek(0) : this.videoReader.start(), this .eventManager.emit("onAnimationRepeat"), !0) } flushLoop() { return this.renderTimer = window.requestAnimationFrame((() => { this.flushLoop() })), l && this.duration() - this.videoReader.currentTime() <= 1 / this.frameRate() && this.repeat(), this.flushInternal(!1) } clearTimer() { this.renderTimer && (window.cancelAnimationFrame(this.renderTimer), this.renderTimer = null) } updateFPS() { let e; try { e = performance.now() } catch (t) { e = Date.now() } this.fpsBuffer = this.fpsBuffer.filter((t => e - t <= 1e3)), this.fpsBuffer.push(e), this.setDebugData({ FPS: this.fpsBuffer.length }) } async flushInternal(e) { const t = new s; this.needSeek ? (e ? await this.videoReader.seek(this.currentFrame / this.frameRate()) : this .videoReader.seek(this.currentFrame / this.frameRate()), this.needSeek = !1) : this .currentFrame = Math.floor(this.videoReader.currentTime() * this.frameRate()), this.draw(), t.mark( "draw"), this.setDebugData({ draw: t.measure("", "draw") }), this.updateFPS(), this.eventManager.emit(q.onAnimationUpdate) } }; te = ((e, t, i, r) => { for (var s, a = r > 1 ? void 0 : r ? ee(t, i) : t, n = e.length - 1; n >= 0; n--)(s = e[n]) && (a = (r ? s( t, i, a) : s(a)) || a); return r && a && Q(t, i, a), a })([a], te); var ie = Object.defineProperty, re = Object.getOwnPropertyDescriptor, se = Object.getOwnPropertySymbols, ae = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable, oe = (e, t, i) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i; let he = class extends te { constructor(e, t, i) { var r; super(e, t, i), this.scale = { x: 1, y: 1 }, this.positionLocation = 0, this.texcoordLocation = 0, this.alphaStartLocation = null, this .scaleLocation = null, this.resolutionLocation = null, this.positionBuffer = null, this .texcoordBuffer = null, this.originalVideoTexture = null, this.renderingTexture = null, this .renderingFbo = null; const s = null == (r = this.canvas) ? void 0 : r.getContext("webgl", ((e, t) => { for (var i in t || (t = {})) ae.call(t, i) && oe(e, i, t[i]); if (se) for (var i of se(t)) ne.call(t, i) && oe(e, i, t[i]); return e })({}, n)); if (!s) throw new Error("Can't get WebGL context!"); this.gl = s, this.videoParam.hasAlpha ? this.program = x(this.gl, P(z), P( "\n precision mediump float;\n // our texture\n uniform sampler2D u_image;\n \n // the texCoords passed in from the vertex shader.\n varying vec2 v_texCoord;\n uniform vec2 v_alphaStart;\n \n void main() {\n vec4 color = texture2D(u_image, v_texCoord);\n vec4 alpha = texture2D(u_image, vec2(v_texCoord.x + v_alphaStart.x, v_texCoord.y + v_alphaStart.y));\n gl_FragColor = vec4(color.rgb * alpha.r, alpha.r);\n } \n " )) : this.program = x(this.gl, P(z), P( "\n precision mediump float;\n // our texture\n uniform sampler2D u_image;\n \n // the texCoords passed in from the vertex shader.\n varying vec2 v_texCoord;\n \n void main() {\n gl_FragColor = texture2D(u_image, v_texCoord);\n }\n " )), this.loadContext() } loadContext() { if (!this.program) throw new Error("program is not initialized"); if (this.positionLocation = this.gl.getAttribLocation(this.program, "a_position"), -1 === this .positionLocation) throw new Error("unable to get attribute location for a_position"); if (this.scaleLocation = this.gl.getUniformLocation(this.program, "u_scale"), -1 === this.scaleLocation) throw new Error("unable to get attribute location for u_scale"); if (this.texcoordLocation = this.gl.getAttribLocation(this.program, "a_texCoord"), -1 === this .texcoordLocation) throw new Error("unable to get attribute location for a_texCoord"); if (this.videoParam.hasAlpha && (this.alphaStartLocation = this.gl.getUniformLocation(this.program, "v_alphaStart"), !this.alphaStartLocation)) throw new Error( "unable to get attribute location for v_alphaStart"); if (this.resolutionLocation = this.gl.getUniformLocation(this.program, "u_resolution"), -1 === this .positionLocation) throw new Error("unable to get attribute location for u_resolution"); if (this.positionBuffer = this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this .positionBuffer), this.setRectangle(this.gl, 0, 0, this.videoParam.MP4Width, this.videoParam .MP4Height), this.texcoordBuffer = this.gl.createBuffer(), this.gl.bindBuffer(this.gl .ARRAY_BUFFER, this.texcoordBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([ 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ]), this.gl.STATIC_DRAW), this.renderingTexture = A(this.gl), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.videoParam.sequenceWidth, this.videoParam.sequenceHeight, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, null), this.renderingFbo = this.gl.createFramebuffer(), !this .renderingFbo) throw new Error("unable to create framebuffer"); this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.renderingFbo), this.gl.framebufferTexture2D(this.gl .FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.TEXTURE_2D, this.renderingTexture, 0), this .originalVideoTexture = A(this.gl) } draw() { this.gl.bindTexture(this.gl.TEXTURE_2D, this.originalVideoTexture), this.texImage2D(), this.gl .clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT), this.gl.useProgram(this.program), this.gl.enableVertexAttribArray(this.positionLocation), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer); const e = this.gl.FLOAT; this.gl.vertexAttribPointer(this.positionLocation, 2, e, false, 0, 0), this.gl.enableVertexAttribArray( this.texcoordLocation), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.texcoordBuffer), this.gl .vertexAttribPointer(this.texcoordLocation, 2, e, false, 0, 0), this.videoParam.hasAlpha && this.gl .uniform2f(this.alphaStartLocation, this.videoParam.alphaStartX / this.videoParam.MP4Width / this .scale.x, this.videoParam.alphaStartY / this.videoParam.MP4Height / this.scale.y), this.gl .bindTexture(this.gl.TEXTURE_2D, this.originalVideoTexture), this.gl.bindFramebuffer(this.gl .FRAMEBUFFER, this.renderingFbo), this.gl.uniform2f(this.resolutionLocation, this.videoParam .sequenceWidth, this.videoParam.sequenceHeight), this.gl.uniform2f(this.scaleLocation, this .scale.x, this.scale.y), this.gl.viewport(0, 0, this.videoParam.sequenceWidth, this.videoParam .sequenceHeight); const t = this.gl.TRIANGLES; this.gl.drawArrays(t, 0, 6), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null), this.gl.uniform2f(this .resolutionLocation, this.videoParam.sequenceWidth, this.videoParam.sequenceHeight), this.gl .viewport(this.viewportSize.x, this.viewportSize.y, this.viewportSize.width, this.viewportSize .height), this.gl.drawArrays(t, 0, 6) } clearRender() { this.gl.clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT) } detectWebGLContext() { return (() => { const e = document.createElement("canvas"); return !(!e.getContext("webgl") && !e.getContext("experimental-webgl")) })() } texImage2D() { this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, this .videoReader.getVideoElement()) } setRectangle(e, t, i, r, s) { const a = t, n = t + r, o = i, h = i + s; e.bufferData(e.ARRAY_BUFFER, new Float32Array([a, o, n, o, a, h, a, h, n, o, n, h]), e.STATIC_DRAW) } }; he = ((e, t, i, r) => { for (var s, a = r > 1 ? void 0 : r ? re(t, i) : t, n = e.length - 1; n >= 0; n--)(s = e[n]) && (a = (r ? s( t, i, a) : s(a)) || a); return r && a && ie(t, i, a), a })([a], he); var le = (e => (e[e.Unknown = 0] = "Unknown", e[e.Vector = 1] = "Vector", e[e.Bitmap = 2] = "Bitmap", e[e.Video = 3] = "Video", e))(le || {}), de = (e => (e[e.End = 0] = "End", e[e.FontTables = 1] = "FontTables", e[e.VectorCompositionBlock = 2] = "VectorCompositionBlock", e[e.CompositionAttributes = 3] = "CompositionAttributes", e[e.ImageTables = 4] = "ImageTables", e[e.LayerBlock = 5] = "LayerBlock", e[e.LayerAttributes = 6] = "LayerAttributes", e[e .SolidColor = 7] = "SolidColor", e[e.TextSource = 8] = "TextSource", e[e.TextPathOption = 9] = "TextPathOption", e[e.TextMoreOption = 10] = "TextMoreOption", e[e.ImageReference = 11] = "ImageReference", e[e.CompositionReference = 12] = "CompositionReference", e[e.Transform2D = 13] = "Transform2D", e[e .MaskBlock = 14] = "MaskBlock", e[e.ShapeGroup = 15] = "ShapeGroup", e[e.Rectangle = 16] = "Rectangle", e[e.Ellipse = 17] = "Ellipse", e[e.PolyStar = 18] = "PolyStar", e[e.ShapePath = 19] = "ShapePath", e[e .Fill = 20] = "Fill", e[e.Stroke = 21] = "Stroke", e[e.GradientFill = 22] = "GradientFill", e[e .GradientStroke = 23] = "GradientStroke", e[e.MergePaths = 24] = "MergePaths", e[e.TrimPaths = 25] = "TrimPaths", e[e.Repeater = 26] = "Repeater", e[e.RoundCorners = 27] = "RoundCorners", e[e.Performance = 28] = "Performance", e[e.DropShadowStyle = 29] = "DropShadowStyle", e[e.InnerShadowStyle = 30] = "InnerShadowStyle", e[e.OuterGlowStyle = 31] = "OuterGlowStyle", e[e.InnerGlowStyle = 32] = "InnerGlowStyle", e[e.BevelAndEmbossStyle = 33] = "BevelAndEmbossStyle", e[e.SatinStyle = 34] = "SatinStyle", e[e.ColorOverlayStyle = 35] = "ColorOverlayStyle", e[e.GradientOverlayStyle = 36] = "GradientOverlayStyle", e[e.StrokeStyle = 37] = "StrokeStyle", e[e.TintEffect = 38] = "TintEffect", e[e .FillEffect = 39] = "FillEffect", e[e.StrokeEffect = 40] = "StrokeEffect", e[e.TritoneEffect = 41] = "TritoneEffect", e[e.DropShadowEffect = 42] = "DropShadowEffect", e[e.RadialWipeEffect = 43] = "RadialWipeEffect", e[e.DisplacementMapEffect = 44] = "DisplacementMapEffect", e[e.BitmapCompositionBlock = 45] = "BitmapCompositionBlock", e[e.BitmapSequence = 46] = "BitmapSequence", e[e.ImageBytes = 47] = "ImageBytes", e[e.ImageBytes2 = 48] = "ImageBytes2", e[e.ImageBytes3 = 49] = "ImageBytes3", e[e .VideoCompositionBlock = 50] = "VideoCompositionBlock", e[e.VideoSequence = 51] = "VideoSequence", e[e .LayerAttributesV2 = 52] = "LayerAttributesV2", e[e.Count = 53] = "Count", e))(de || {}); const ce = e => { const t = e.readUint16(); let i = (63 & t) >>> 0; const r = t >> 6; return 63 === i && (i = e.readUint32()), e.context.tagLevel < r && (e.context.tagLevel = r), { code: r, length: i } }; function ue(e, t, i) { let r = ce(e); for (; r.code !== de.End;) { const s = e.readBytes(r.length); i(s, r.code, t), e.context.tagLevel < s.context.tagLevel && (e.context.tagLevel = s.context.tagLevel), r = ce(e) } } const me = { red: 0, green: 0, blue: 0 }, fe = { red: 255, green: 255, blue: 255 }, pe = () => { console.error("PAG Verify Failed!") }, ge = e => !!e || (console.error("PAG Verify Failed!"), !1), ye = class { constructor() { this.id = 0, this.width = 0, this.height = 0, this.duration = 0, this.frameRate = 30, this .backgroundColor = fe, this.cacheID = 0, this.cacheID = ye.cacheIDCount, ye.cacheIDCount += 1 } type() { return le.Unknown } getStaticTimeRanges() { return [] } verify() { return ge(this.width > 0 && this.height > 0 && this.duration > 0 && this.frameRate > 0) } }; let we = ye; we.cacheIDCount = 1; class ve extends we { constructor() { super(...arguments), this.hasAlpha = !1, this.sequences = [], this.staticTimeRanges = [], this .staticTimeRangeUpdated = !1 } type() { return le.Video } getStaticTimeRanges() { return this.staticTimeRangeUpdated || (this.staticTimeRangeUpdated = !0, this.updateStaticTimeRanges()), this.staticTimeRanges } updateStaticTimeRanges() { if (!(this.duration <= 1)) if (this.sequences.length > 0) { let e = this.sequences[0]; for (let t = 1; t < this.sequences.length; t++) { const i = this.sequences[t]; i.frameRate > e.frameRate && (e = i) } const t = this.frameRate / e.frameRate; for (const i of e.staticTimeRanges) i.start = Math.round(i.start * t), i.end = Math.round(i.end * t), this.staticTimeRanges.push(i) } else { const e = { start: 0, end: this.duration - 1 }; this.staticTimeRanges.push(e) } } hasImageContent() { return !0 } verify() { if (!super.verify() || this.sequences.length <= 0) return pe(), !1; for (const e of this.sequences) if (!e || !e.verify()) return pe(), !1; return !0 } } class be { constructor(e, t) { this.numerator = 1, this.denominator = 1, this.numerator = e, this.denominator = t } value() { return this.numerator / this.denominator } } const Se = new be(1, 1); class Ee { constructor(e, t) { this.x = e, this.y = t } } const Te = new Ee(0, 0); var xe = (e => (e[e.None = 0] = "None", e[e.Alpha = 1] = "Alpha", e[e.AlphaInverted = 2] = "AlphaInverted", e[e.Luma = 3] = "Luma", e[e.LumaInverted = 4] = "LumaInverted", e))(xe || {}), Re = (e => (e[e.Unknown = 0] = "Unknown", e[e[void 0] = 1] = "undefined", e[e.Solid = 2] = "Solid", e[e.Text = 3] = "Text", e[e.Shape = 4] = "Shape", e[e.Image = 5] = "Image", e[e.PreCompose = 6] = "PreCompose", e))(Re || {}); class Pe { constructor() { this.id = 0, this.parent = void 0, this.containingComposition = void 0, this.stretch = Se, this.startTime = 0, this.duration = 0, this.autoOrientation = !1, this.transform = void 0, this.isActive = !0, this .blendMode = o.Normal, this.trackMatteType = 0, this.trackMatteLayer = void 0, this.timeRemap = void 0, this.masks = void 0, this.effects = void 0, this.layerStyles = void 0, this.layerCache = void 0, this .maxScale = void 0 } type() { return 0 } excludeVaryingRanges(e) { var t; if (null == (t = this.transform) || t.excludeVaryingRanges(e), void 0 !== this.timeRemap && this.timeRemap .excludeVaryingRanges(e), void 0 !== this.masks) for (const t of this.masks) t.excludeVaryingRanges(e); if (void 0 !== this.effects && this.effects.length > 0) for (const t of this.effects) t.excludeVaryingRanges(e); if (void 0 !== this.layerStyles && this.layerStyles.length > 0) for (const t of this.layerStyles) t.excludeVaryingRanges(e) } gotoFrame(e) { var t; if (null == (t = this.transform) || t.gotoFrame(e), void 0 !== this.timeRemap && this.timeRemap.gotoFrame( e), void 0 !== this.masks && this.masks.length > 0) for (const t of this.masks) t.gotoFrame(e); if (void 0 !== this.effects && this.effects.length > 0) for (const t of this.effects) t.gotoFrame(e); if (void 0 !== this.layerStyles && this.layerStyles.length > 0) for (const t of this.layerStyles) t.gotoFrame(e) } verify() { if (!this.containingComposition || this.duration <= 0 || !this.transform) return pe(), !1; if (!this.transform.verify()) return pe(), !1; if (this.masks && this.masks.length > 0) for (const e of this.masks) if (!e || !e.verify()) return pe(), !1; if (this.layerStyles && this.layerStyles.length > 0) for (const e of this.layerStyles) if (!e || !e.verify()) return pe(), !1; if (this.effects && this.effects.length > 0) for (const e of this.effects) if (!e || !e.verify()) return pe(), !1; return !0 } getMaxScaleFactor() { if (void 0 !== this.maxScale) return this.maxScale; this.maxScale = new Ee(1, 1); const e = this.transform.scale; if (e.animatable()) { const { keyframes: t } = e; let i = Math.abs(t[0].startValue.x), r = Math.abs(t[0].startValue.y); if (void 0 !== t && t.length > 0) for (const e of t) { const t = Math.abs(e.endValue.x), s = Math.abs(e.endValue.y); i < t && (i = t), r < s && (r = s) } this.maxScale.x = i, this.maxScale.y = r } else this.maxScale.x = Math.abs(e.value.x), this.maxScale.y = Math.abs(e.value.y); if (void 0 !== this.parent) { const e = this.parent.getMaxScaleFactor(); this.maxScale.x *= e.x, this.maxScale.y *= e.y } return this.maxScale } } const Ae = e => ({ red: e.readUint8(), green: e.readUint8(), blue: e.readUint8() }), De = e => e.readEncodedUint64(), ke = e => { const t = e.readFloat32(), i = e.readFloat32(); return new Ee(t, i) }, Fe = (e, t) => { t.width = e.readEncodeInt32(), t.height = e.readEncodeInt32(), t.duration = De(e), t.frameRate = e .readFloat32(), t.backgroundColor = Ae(e) }; class Ve { constructor() { this.tagLevel = 0, this.compositions = [], this.errorMessages = [] } throwException(e) { this.errorMessages.push(e) } releaseCompositions() { const e = this.compositions.slice(); return this.compositions = [], e } } const Ce = "PAG file decode error!"; class Le { constructor(e, t) { this._position = 0, this.bitPosition = 0, this.dataView = new DataView(e), this.littleEndian = !!t, this .context = new Ve } get length() { return this.dataView.byteLength } get bytesAvailable() { return this.dataView.byteLength - this._position } data() { return this.dataView.buffer } get position() { return this._position } alignWithBytes() { this.bitPosition = 8 * this._position } readBoolean() { const e = this.dataView.getInt8(this._position); return this._position += 1, this.positonChanged(), Boolean(e) } readChar() { if (this._position >= this.length) throw new Error(Ce); const e = this.dataView.getInt8(this._position); return this._position += 1, this.positonChanged(), String.fromCharCode(e) } readUint8() { if (this._position >= this.length) throw new Error(Ce); const e = this.dataView.getUint8(this._position); return this._position += 1, this.positonChanged(), e } readInt8() { if (this._position >= this.length) throw new Error(Ce); const e = this.dataView.getInt8(this._position); return this._position += 1, this.positonChanged(), e } readInt16() { if (this._position >= this.length - 1) throw new Error(Ce); const e = this.dataView.getInt16(this._position, this.littleEndian); return this._position += 2, this.positonChanged(), e } readUint16() { if (this._position >= this.length - 1) throw new Error(Ce); const e = this.dataView.getUint16(this._position, this.littleEndian); return this._position += 2, this.positonChanged(), e } readInt24() { if (this._position >= this.length - 2) throw new Error(Ce); const e = this.dataView.getInt16(this._position, this.littleEndian), t = this.dataView.getInt8(this._position + 2); return this._position += 3, this.positonChanged(), this.littleEndian ? e + 65536 * t : 65536 * e + t } readUint24() { if (this._position >= this.length - 2) throw new Error(Ce); const e = this.dataView.getUint16(this._position, this.littleEndian), t = this.dataView.getUint8(this._position + 2); return this._position += 3, this.positonChanged(), this.littleEndian ? e + 65536 * t : 65536 * e + t } readInt32() { if (this._position >= this.length - 3) throw new Error(Ce); const e = this.dataView.getInt32(this._position, this.littleEndian); return this._position += 4, this.positonChanged(), e } readUint32() { if (this._position >= this.length - 3) throw new Error(Ce); const e = this.dataView.getUint32(this._position, this.littleEndian); return this._position += 4, this.positonChanged(), e } readInt64() { if (this._position >= this.length -