const maxLenNum = (t, e) => (t > e ? t : e).toString().length + 1, num2PadNumArr = (t, e) => { const r = (t, e) => t.length < e ? r("0" + t, e) : t; return (t => t.split("").map(Number))(r(t.toString(), e)).reverse() }, isstr = t => "[object String]" === Object.prototype.toString.call(t); var remainder = 0; class FlipJackpotNumbers { constructor({ node: t, from: e = 0, to: r, duration: s = 30, delay: i, easeFn: n = (t => t), systemArr: a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], direct: o = !0, separator: h = ".", seperateOnly: l = 0, separateEvery: d = 0 }) { this.beforeArr = [], this.afterArr = [], this.ctnrArr = [], this.duration = 1e3 * s, this.systemArr = a, this.easeFn = n, this.from = e, this.to = r || 0, this.node = t, this.direct = o, this.separator = h, this.seperateOnly = l, this.separateEvery = l ? 0 : d, this._initHTML(maxLenNum(this.from, this.to)), void 0 !== r && (i ? setTimeout(() => this.flipTo({ to: this.to }), 1e3 * i) : this.flipTo({ to: this.to })) } _initHTML(t) { this.node.classList.add("component_jackpot_slider"), this.node.style.position = "relative", this.node.style.overflow = "hidden"; for (let r = 0; r < t; r += 1) { let s = document.createElement("div"); s.className = 0 == r ? "component_jackpot_slider_number_wrapper component_jackpot_slider_number_wrapper0 hide" : "component_jackpot_slider_number_wrapper component_jackpot_slider_number_wrapper" + r; var e = t - this.seperateOnly; r < t - this.seperateOnly && (r != e % 3 && (r - remainder) % 3 != 0 || (remainder = r, s.classList.add("comp_jack_padding"))); for (let t = 0; t < this.systemArr.length; t++) { let e = document.createElement("div"); e.className = "component_jackpot_slider_number", e.innerHTML = t, s.appendChild(e) } let i = document.createElement("div"); if (i.className = "digit", i.innerHTML = this.systemArr[0], s.appendChild(i), s.style.position = "relative", s.style.display = "inline-block", s.style.verticalAlign = "top", this.ctnrArr.unshift(s), this.node.appendChild(s), this.beforeArr.push(0), !this.separator || !this.separateEvery && !this.seperateOnly || r === t - 1 || (t - r) % this.separateEvery != 1 && t - r - this.seperateOnly != 1) continue; const n = isstr(this.separator) ? this.separator : this.separator.shift(), a = document.createElement("div"); a.className = "sprtr", a.innerHTML = n, a.style.display = "inline-block", this.node.appendChild(a) } const r = () => { if (this.height = this.ctnrArr[0].clientHeight / (this.systemArr.length + 1), this.node.style.height = this.height + "px", this.afterArr.length) this.frame(1); else for (let t = 0, e = this.ctnrArr.length; t < e; t += 1)this._draw({ digit: t, per: 1, alter: ~~(this.from / Math.pow(10, t)) }) }; r(), window.addEventListener("resize", r) } _draw({ per: t, alter: e, digit: r }) { const s = this.ctnrArr[0].clientHeight / (this.systemArr.length + 1); s && this.height !== s && (this.height = s); const i = `translateY(${-(((t * e + this.beforeArr[r]) % 10 + 10) % 10) * this.height}px)`; this.ctnrArr[r].style.webkitTransform = i, this.ctnrArr[r].style.transform = i } frame(t) { let e = 0; for (let r = this.ctnrArr.length - 1; r >= 0; r -= 1) { let s = this.afterArr[r] - this.beforeArr[r]; e += s, this._draw({ digit: r, per: this.easeFn(t), alter: this.direct ? s : e }), e *= 10 } } flipTo({ to: t, duration: e, easeFn: r, direct: s }) { r && (this.easeFn = r), void 0 !== s && (this.direct = s); const i = this.ctnrArr.length; this.beforeArr = num2PadNumArr(this.from, i), this.afterArr = num2PadNumArr(t, i); const n = Date.now(), a = 1e3 * e || this.duration, o = () => { let e = Date.now() - n; this.frame(e / a), e < a ? requestAnimationFrame(o) : (this.from = t, this.frame(1)) }; requestAnimationFrame(o) } destroy() { this.node.innerHTML = "", this.node.classList.remove("blink") } }