UNPKG

avada-wheel-canvas-react

Version:
1,399 lines (1,397 loc) 82 kB
import K from "react"; var Ot = { exports: {} }, gt = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Zt; function $e() { if (Zt) return gt; Zt = 1; var l = K, t = Symbol.for("react.element"), e = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, s = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, n = { key: !0, ref: !0, __self: !0, __source: !0 }; function h(o, a, u) { var f, c = {}, p = null, w = null; u !== void 0 && (p = "" + u), a.key !== void 0 && (p = "" + a.key), a.ref !== void 0 && (w = a.ref); for (f in a) i.call(a, f) && !n.hasOwnProperty(f) && (c[f] = a[f]); if (o && o.defaultProps) for (f in a = o.defaultProps, a) c[f] === void 0 && (c[f] = a[f]); return { $$typeof: t, type: o, key: p, ref: w, props: c, _owner: s.current }; } return gt.Fragment = e, gt.jsx = h, gt.jsxs = h, gt; } var pt = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Qt; function Ae() { return Qt || (Qt = 1, process.env.NODE_ENV !== "production" && function() { var l = K, t = Symbol.for("react.element"), e = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), n = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), o = Symbol.for("react.context"), a = Symbol.for("react.forward_ref"), u = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), c = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), w = Symbol.for("react.offscreen"), y = Symbol.iterator, E = "@@iterator"; function g(r) { if (r === null || typeof r != "object") return null; var d = y && r[y] || r[E]; return typeof d == "function" ? d : null; } var k = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function b(r) { { for (var d = arguments.length, m = new Array(d > 1 ? d - 1 : 0), v = 1; v < d; v++) m[v - 1] = arguments[v]; x("error", r, m); } } function x(r, d, m) { { var v = k.ReactDebugCurrentFrame, _ = v.getStackAddendum(); _ !== "" && (d += "%s", m = m.concat([_])); var R = m.map(function(z) { return String(z); }); R.unshift("Warning: " + d), Function.prototype.apply.call(console[r], console, R); } } var S = !1, A = !1, T = !1, I = !1, W = !1, D; D = Symbol.for("react.module.reference"); function O(r) { return !!(typeof r == "string" || typeof r == "function" || r === i || r === n || W || r === s || r === u || r === f || I || r === w || S || A || T || typeof r == "object" && r !== null && (r.$$typeof === p || r.$$typeof === c || r.$$typeof === h || r.$$typeof === o || r.$$typeof === a || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. r.$$typeof === D || r.getModuleId !== void 0)); } function H(r, d, m) { var v = r.displayName; if (v) return v; var _ = d.displayName || d.name || ""; return _ !== "" ? m + "(" + _ + ")" : m; } function Y(r) { return r.displayName || "Context"; } function F(r) { if (r == null) return null; if (typeof r.tag == "number" && b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof r == "function") return r.displayName || r.name || null; if (typeof r == "string") return r; switch (r) { case i: return "Fragment"; case e: return "Portal"; case n: return "Profiler"; case s: return "StrictMode"; case u: return "Suspense"; case f: return "SuspenseList"; } if (typeof r == "object") switch (r.$$typeof) { case o: var d = r; return Y(d) + ".Consumer"; case h: var m = r; return Y(m._context) + ".Provider"; case a: return H(r, r.render, "ForwardRef"); case c: var v = r.displayName || null; return v !== null ? v : F(r.type) || "Memo"; case p: { var _ = r, R = _._payload, z = _._init; try { return F(z(R)); } catch { return null; } } } return null; } var j = Object.assign, U = 0, it, lt, $, ct, V, Z, st; function rt() { } rt.__reactDisabledLog = !0; function ut() { { if (U === 0) { it = console.log, lt = console.info, $ = console.warn, ct = console.error, V = console.group, Z = console.groupCollapsed, st = console.groupEnd; var r = { configurable: !0, enumerable: !0, value: rt, writable: !0 }; Object.defineProperties(console, { info: r, log: r, warn: r, error: r, group: r, groupCollapsed: r, groupEnd: r }); } U++; } } function Ct() { { if (U--, U === 0) { var r = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: j({}, r, { value: it }), info: j({}, r, { value: lt }), warn: j({}, r, { value: $ }), error: j({}, r, { value: ct }), group: j({}, r, { value: V }), groupCollapsed: j({}, r, { value: Z }), groupEnd: j({}, r, { value: st }) }); } U < 0 && b("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var Q = k.ReactCurrentDispatcher, nt; function X(r, d, m) { { if (nt === void 0) try { throw Error(); } catch (_) { var v = _.stack.trim().match(/\n( *(at )?)/); nt = v && v[1] || ""; } return ` ` + nt + r; } } var ft = !1, wt; { var oe = typeof WeakMap == "function" ? WeakMap : Map; wt = new oe(); } function Ft(r, d) { if (!r || ft) return ""; { var m = wt.get(r); if (m !== void 0) return m; } var v; ft = !0; var _ = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var R; R = Q.current, Q.current = null, ut(); try { if (d) { var z = function() { throw Error(); }; if (Object.defineProperty(z.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(z, []); } catch (B) { v = B; } Reflect.construct(r, [], z); } else { try { z.call(); } catch (B) { v = B; } r.call(z.prototype); } } else { try { throw Error(); } catch (B) { v = B; } r(); } } catch (B) { if (B && v && typeof B.stack == "string") { for (var C = B.stack.split(` `), M = v.stack.split(` `), L = C.length - 1, P = M.length - 1; L >= 1 && P >= 0 && C[L] !== M[P]; ) P--; for (; L >= 1 && P >= 0; L--, P--) if (C[L] !== M[P]) { if (L !== 1 || P !== 1) do if (L--, P--, P < 0 || C[L] !== M[P]) { var N = ` ` + C[L].replace(" at new ", " at "); return r.displayName && N.includes("<anonymous>") && (N = N.replace("<anonymous>", r.displayName)), typeof r == "function" && wt.set(r, N), N; } while (L >= 1 && P >= 0); break; } } } finally { ft = !1, Q.current = R, Ct(), Error.prepareStackTrace = _; } var at = r ? r.displayName || r.name : "", tt = at ? X(at) : ""; return typeof r == "function" && wt.set(r, tt), tt; } function ae(r, d, m) { return Ft(r, !1); } function he(r) { var d = r.prototype; return !!(d && d.isReactComponent); } function bt(r, d, m) { if (r == null) return ""; if (typeof r == "function") return Ft(r, he(r)); if (typeof r == "string") return X(r); switch (r) { case u: return X("Suspense"); case f: return X("SuspenseList"); } if (typeof r == "object") switch (r.$$typeof) { case a: return ae(r.render); case c: return bt(r.type, d, m); case p: { var v = r, _ = v._payload, R = v._init; try { return bt(R(_), d, m); } catch { } } } return ""; } var dt = Object.prototype.hasOwnProperty, Dt = {}, jt = k.ReactDebugCurrentFrame; function vt(r) { if (r) { var d = r._owner, m = bt(r.type, r._source, d ? d.type : null); jt.setExtraStackFrame(m); } else jt.setExtraStackFrame(null); } function le(r, d, m, v, _) { { var R = Function.call.bind(dt); for (var z in r) if (R(r, z)) { var C = void 0; try { if (typeof r[z] != "function") { var M = Error((v || "React class") + ": " + m + " type `" + z + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof r[z] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw M.name = "Invariant Violation", M; } C = r[z](d, z, v, m, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (L) { C = L; } C && !(C instanceof Error) && (vt(_), b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", v || "React class", m, z, typeof C), vt(null)), C instanceof Error && !(C.message in Dt) && (Dt[C.message] = !0, vt(_), b("Failed %s type: %s", m, C.message), vt(null)); } } } var ce = Array.isArray; function Et(r) { return ce(r); } function ue(r) { { var d = typeof Symbol == "function" && Symbol.toStringTag, m = d && r[Symbol.toStringTag] || r.constructor.name || "Object"; return m; } } function fe(r) { try { return Mt(r), !1; } catch { return !0; } } function Mt(r) { return "" + r; } function Ht(r) { if (fe(r)) return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ue(r)), Mt(r); } var Bt = k.ReactCurrentOwner, de = { key: !0, ref: !0, __self: !0, __source: !0 }, Nt, Ut; function ge(r) { if (dt.call(r, "ref")) { var d = Object.getOwnPropertyDescriptor(r, "ref").get; if (d && d.isReactWarning) return !1; } return r.ref !== void 0; } function pe(r) { if (dt.call(r, "key")) { var d = Object.getOwnPropertyDescriptor(r, "key").get; if (d && d.isReactWarning) return !1; } return r.key !== void 0; } function me(r, d) { typeof r.ref == "string" && Bt.current; } function ye(r, d) { { var m = function() { Nt || (Nt = !0, b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d)); }; m.isReactWarning = !0, Object.defineProperty(r, "key", { get: m, configurable: !0 }); } } function we(r, d) { { var m = function() { Ut || (Ut = !0, b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d)); }; m.isReactWarning = !0, Object.defineProperty(r, "ref", { get: m, configurable: !0 }); } } var be = function(r, d, m, v, _, R, z) { var C = { // This tag allows us to uniquely identify this as a React Element $$typeof: t, // Built-in properties that belong on the element type: r, key: d, ref: m, props: z, // Record the component responsible for creating this element. _owner: R }; return C._store = {}, Object.defineProperty(C._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(C, "_self", { configurable: !1, enumerable: !1, writable: !1, value: v }), Object.defineProperty(C, "_source", { configurable: !1, enumerable: !1, writable: !1, value: _ }), Object.freeze && (Object.freeze(C.props), Object.freeze(C)), C; }; function ve(r, d, m, v, _) { { var R, z = {}, C = null, M = null; m !== void 0 && (Ht(m), C = "" + m), pe(d) && (Ht(d.key), C = "" + d.key), ge(d) && (M = d.ref, me(d, _)); for (R in d) dt.call(d, R) && !de.hasOwnProperty(R) && (z[R] = d[R]); if (r && r.defaultProps) { var L = r.defaultProps; for (R in L) z[R] === void 0 && (z[R] = L[R]); } if (C || M) { var P = typeof r == "function" ? r.displayName || r.name || "Unknown" : r; C && ye(z, P), M && we(z, P); } return be(r, C, M, _, v, Bt.current, z); } } var xt = k.ReactCurrentOwner, Yt = k.ReactDebugCurrentFrame; function ot(r) { if (r) { var d = r._owner, m = bt(r.type, r._source, d ? d.type : null); Yt.setExtraStackFrame(m); } else Yt.setExtraStackFrame(null); } var zt; zt = !1; function _t(r) { return typeof r == "object" && r !== null && r.$$typeof === t; } function Xt() { { if (xt.current) { var r = F(xt.current.type); if (r) return ` Check the render method of \`` + r + "`."; } return ""; } } function Se(r) { return ""; } var Gt = {}; function ke(r) { { var d = Xt(); if (!d) { var m = typeof r == "string" ? r : r.displayName || r.name; m && (d = ` Check the top-level render call using <` + m + ">."); } return d; } } function Vt(r, d) { { if (!r._store || r._store.validated || r.key != null) return; r._store.validated = !0; var m = ke(d); if (Gt[m]) return; Gt[m] = !0; var v = ""; r && r._owner && r._owner !== xt.current && (v = " It was passed a child from " + F(r._owner.type) + "."), ot(r), b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', m, v), ot(null); } } function qt(r, d) { { if (typeof r != "object") return; if (Et(r)) for (var m = 0; m < r.length; m++) { var v = r[m]; _t(v) && Vt(v, d); } else if (_t(r)) r._store && (r._store.validated = !0); else if (r) { var _ = g(r); if (typeof _ == "function" && _ !== r.entries) for (var R = _.call(r), z; !(z = R.next()).done; ) _t(z.value) && Vt(z.value, d); } } } function Ce(r) { { var d = r.type; if (d == null || typeof d == "string") return; var m; if (typeof d == "function") m = d.propTypes; else if (typeof d == "object" && (d.$$typeof === a || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. d.$$typeof === c)) m = d.propTypes; else return; if (m) { var v = F(d); le(m, r.props, "prop", v, r); } else if (d.PropTypes !== void 0 && !zt) { zt = !0; var _ = F(d); b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _ || "Unknown"); } typeof d.getDefaultProps == "function" && !d.getDefaultProps.isReactClassApproved && b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Ee(r) { { for (var d = Object.keys(r.props), m = 0; m < d.length; m++) { var v = d[m]; if (v !== "children" && v !== "key") { ot(r), b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", v), ot(null); break; } } r.ref !== null && (ot(r), b("Invalid attribute `ref` supplied to `React.Fragment`."), ot(null)); } } var Jt = {}; function Kt(r, d, m, v, _, R) { { var z = O(r); if (!z) { var C = ""; (r === void 0 || typeof r == "object" && r !== null && Object.keys(r).length === 0) && (C += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var M = Se(); M ? C += M : C += Xt(); var L; r === null ? L = "null" : Et(r) ? L = "array" : r !== void 0 && r.$$typeof === t ? (L = "<" + (F(r.type) || "Unknown") + " />", C = " Did you accidentally export a JSX literal instead of a component?") : L = typeof r, b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", L, C); } var P = ve(r, d, m, _, R); if (P == null) return P; if (z) { var N = d.children; if (N !== void 0) if (v) if (Et(N)) { for (var at = 0; at < N.length; at++) qt(N[at], r); Object.freeze && Object.freeze(N); } else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else qt(N, r); } if (dt.call(d, "key")) { var tt = F(r), B = Object.keys(d).filter(function(Oe) { return Oe !== "key"; }), Rt = B.length > 0 ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Jt[tt + Rt]) { var Te = B.length > 0 ? "{" + B.join(": ..., ") + ": ...}" : "{}"; b(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, Rt, tt, Te, tt), Jt[tt + Rt] = !0; } } return r === i ? Ee(P) : Ce(P), P; } } function xe(r, d, m) { return Kt(r, d, m, !0); } function ze(r, d, m) { return Kt(r, d, m, !1); } var _e = ze, Re = xe; pt.Fragment = i, pt.jsx = _e, pt.jsxs = Re; }()), pt; } process.env.NODE_ENV === "production" ? Ot.exports = $e() : Ot.exports = Ae(); var $t = Ot.exports; Array.prototype.includes || Object.defineProperty(Array.prototype, "includes", { value: function(l, t) { if (this == null) throw new TypeError('"this" is null or not defined'); var e = Object(this), i = e.length >>> 0; if (i === 0) return !1; var s = t | 0, n = Math.max(s >= 0 ? s : i - Math.abs(s), 0); function h(o, a) { return o === a || typeof o == "number" && typeof a == "number" && isNaN(o) && isNaN(a); } for (; n < i; ) { if (h(e[n], l)) return !0; n++; } return !1; } }); String.prototype.includes || (String.prototype.includes = function(l, t) { return typeof t != "number" && (t = 0), t + l.length > this.length ? !1 : this.indexOf(l, t) !== -1; }); Array.prototype.find || Object.defineProperty(Array.prototype, "find", { value: function(l) { if (this == null) throw new TypeError('"this" is null or not defined'); var t = Object(this), e = t.length >>> 0; if (typeof l != "function") throw new TypeError("predicate must be a function"); for (var i = arguments[1], s = 0; s < e; ) { var n = t[s]; if (l.call(i, n, s, t)) return n; s++; } } }); const mt = (l, ...t) => t.some((e) => Object.prototype.toString.call(l).slice(8, -1).toLowerCase() === e), ht = (l, t) => Object.prototype.hasOwnProperty.call(l, t), At = (l) => [].filter.call(l, (t) => t !== ` `).join(""), Ie = (l) => l === null ? 0 : typeof l == "object" ? NaN : typeof l == "number" ? l : typeof l == "string" ? l[l.length - 1] === "%" ? Number(l.slice(0, -1)) / 100 : Number(l) : NaN, J = (l) => { if (typeof l != "string" || (l = l.toLocaleLowerCase().trim(), l === "transparent")) return !1; if (/^rgba/.test(l)) { const t = /([^\s,]+)\)$/.exec(l); if (Ie(t) === 0) return !1; } return !0; }, ie = (l, t) => { var a; let e = ((a = l.padding) == null ? void 0 : a.split(" ").map((u) => t(u))) || [0], i = 0, s = 0, n = 0, h = 0; switch (e.length) { case 1: i = s = n = h = e[0]; break; case 2: i = s = e[0], n = h = e[1]; break; case 3: i = e[0], n = h = e[1], s = e[2]; break; default: i = e[0], s = e[1], n = e[2], h = e[3]; } const o = { paddingTop: i, paddingBottom: s, paddingLeft: n, paddingRight: h }; for (let u in o) o[u] = ht(l, u) && mt(l[u], "string", "number") ? t(l[u]) : o[u]; return [i, s, n, h]; }, Le = (l, t = 300) => { let e = null; return function(...i) { e || (e = setTimeout(() => { l.apply(this, i), clearTimeout(e), e = null; }, t)); }; }, se = (l) => { const t = [], e = l.map((s) => Number(s)).reduce((s, n) => { if (n > 0) { const h = s + n; return t.push(h), h; } else return t.push(NaN), s; }, 0), i = Math.random() * e; return t.findIndex((s) => i <= s); }, It = (l, t, e, i = 1 / 0) => { i <= 0 && (i = 1 / 0); let s = ""; const n = [], h = l.measureText("...").width; for (let o = 0; o < t.length; o++) { s += t[o]; let a = l.measureText(s).width; const u = e(n); if (i === n.length + 1 && (a += h), u < 0) return n; if (a > u && (n.push(s.slice(0, -1)), s = t[o]), i === n.length) return n[n.length - 1] += "...", n; } return s && n.push(s), n.length || n.push(t), n; }, Pe = (l, t) => { const e = {}, i = []; for (let s = 0; s < l.length; s++) e[s] = l[s]; for (let s = 0; s < t.length; s++) { const n = e[t[s]]; n && (i[s] = n); } return i; }, We = "avada-wheel-canvas", Tt = "1.0.0"; class et { /** * Subscription center constructor */ constructor() { this.subs = []; } /** * Collect dependencies * @param {*} sub */ addSub(t) { this.subs.includes(t) || this.subs.push(t); } /** * Dispatch updates */ notify() { this.subs.forEach((t) => { t.update(); }); } } const Fe = "__proto__" in {}; function te(l, t, e, i) { Object.defineProperty(l, t, { value: e, enumerable: !1, writable: !0, configurable: !0 }); } function De(l) { l += "."; let t = [], e = ""; for (let i = 0; i < l.length; i++) { let s = l[i]; if (/\[|\./.test(s)) t.push(e), e = ""; else { if (/\W/.test(s)) continue; e += s; } } return function(i) { return t.reduce((s, n) => s[n], i); }; } function je(l) { const t = (e) => { mt(e, "array", "object") && Object.keys(e).forEach((i) => { const s = e[i]; t(s); }); }; t(l); } const re = Array.prototype, St = Object.create(re), Me = ["push", "pop", "shift", "unshift", "sort", "splice", "reverse"]; Me.forEach((l) => { St[l] = function(...t) { const e = re[l].apply(this, t), i = this.__luckyOb__; return ["push", "unshift", "splice"].includes(l) && i.walk(this), i.dep.notify(), e; }; }); class He { /** * Observer constructor * @param value */ constructor(t) { this.dep = new et(), te(t, "__luckyOb__", this), Array.isArray(t) && (Fe ? t.__proto__ = St : Object.getOwnPropertyNames(St).forEach((e) => { te(t, e, St[e]); })), this.walk(t); } walk(t) { Object.keys(t).forEach((e) => { ne(t, e, t[e]); }); } } function ee(l) { if (!l || typeof l != "object") return; let t; return "__luckyOb__" in l ? t = l.__luckyOb__ : t = new He(l), t; } function ne(l, t, e) { const i = new et(), s = Object.getOwnPropertyDescriptor(l, t); if (s && s.configurable === !1) return; const n = s && s.get, h = s && s.set; (!n || h) && arguments.length === 2 && (e = l[t]); let o = ee(e); Object.defineProperty(l, t, { get: () => { const a = n ? n.call(l) : e; return et.target && (i.addSub(et.target), o && o.dep.addSub(et.target)), a; }, set: (a) => { a !== e && (e = a, !(n && !h) && (h ? h.call(l, a) : e = a, o = ee(a), i.notify())); } }); } let Be = 0; class Ne { /** * Observer constructor * @param {*} $lucky * @param {*} expr * @param {*} cb */ constructor(t, e, i, s = {}) { this.id = Be++, this.$lucky = t, this.expr = e, this.deep = !!s.deep, typeof e == "function" ? this.getter = e : this.getter = De(e), this.cb = i, this.value = this.get(); } /** * Get new value based on expression */ get() { et.target = this; const t = this.getter.call(this.$lucky, this.$lucky); return this.deep && je(t), et.target = null, t; } /** * Trigger watcher update */ update() { const t = this.get(), e = this.value; this.value = t, this.cb.call(this.$lucky, t, e); } } const Wt = class Wt { /** * Common constructor * @param config */ constructor(t, e) { this.version = Tt, this.htmlFontSize = 16, this.rAF = function() { }, this.boxWidth = 0, this.boxHeight = 0, typeof t == "string" ? t = { el: t } : t.nodeType === 1 && (t = { el: "", divElement: t }), t = t, this.config = t, this.data = e, t.flag || (t.flag = "WEB"), t.el && (t.divElement = document.querySelector(t.el)), t.divElement && (t.canvasElement = document.createElement("canvas"), t.divElement.appendChild(t.canvasElement)), t.canvasElement && (t.ctx = t.canvasElement.getContext("2d"), t.canvasElement.setAttribute("package", `${We}@${Tt}`), t.canvasElement.addEventListener("click", (i) => this.handleClick(i))), this.ctx = t.ctx, this.initWindowFunction(), this.config.ctx || console.error("Unable to get CanvasContext2D"), window && typeof window.addEventListener == "function" && window.addEventListener("resize", Le(() => this.resize(), 300)), window && typeof window.MutationObserver == "function" && new window.MutationObserver(() => { this.resize(); }).observe(document.documentElement, { attributes: !0 }); } /** * Initialize component size/units */ resize() { var t, e; (e = (t = this.config).beforeResize) == null || e.call(t), this.setHTMLFontSize(), this.setDpr(), this.resetWidthAndHeight(), this.zoomCanvas(); } /** * Initialize method */ initLucky() { if (this.resize(), !this.boxWidth || !this.boxHeight) return console.error("Unable to get width or height"); } /** * Mouse click event * @param e Event parameters */ handleClick(t) { } /** * Root tag font size */ setHTMLFontSize() { window && (this.htmlFontSize = +window.getComputedStyle(document.documentElement).fontSize.slice(0, -2)); } // Clear canvas clearCanvas() { const [t, e] = [this.boxWidth, this.boxHeight]; this.ctx.clearRect(-t, -e, t * 2, e * 2); } /** * Device pixel ratio * Automatically obtained in window environment, manually passed in other environments */ setDpr() { const { config: t } = this; t.dpr || (window ? window.dpr = t.dpr = window.devicePixelRatio || 1 : t.dpr || console.error(t, "No dpr provided may cause rendering issues")); } /** * Reset box and canvas width/height */ resetWidthAndHeight() { const { config: t, data: e } = this; let i = 0, s = 0; t.divElement && (i = t.divElement.offsetWidth, s = t.divElement.offsetHeight), this.boxWidth = this.getLength(e.width || t.width) || i, this.boxHeight = this.getLength(e.height || t.height) || s, t.divElement && (t.divElement.style.overflow = "hidden", t.divElement.style.width = this.boxWidth + "px", t.divElement.style.height = this.boxHeight + "px"); } /** * Scale canvas according to dpr and handle displacement */ zoomCanvas() { const { config: t, ctx: e } = this, { canvasElement: i, dpr: s } = t, [n, h] = [this.boxWidth * s, this.boxHeight * s]; i && (i.width = n, i.height = h, i.style.width = `${n}px`, i.style.height = `${h}px`, i.style["transform-origin"] = "left top", i.style.transform = `scale(${1 / s})`, e.scale(s, s)); } /** * Get some methods from window object */ initWindowFunction() { const { config: t } = this; if (window) { this.rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(e) { window.setTimeout(e, 1e3 / 60); }, t.setTimeout = window.setTimeout, t.setInterval = window.setInterval, t.clearTimeout = window.clearTimeout, t.clearInterval = window.clearInterval; return; } if (t.rAF) this.rAF = t.rAF; else if (t.setTimeout) { const e = t.setTimeout; this.rAF = (i) => e(i, 16.7); } else this.rAF = (e) => setTimeout(e, 16.7); } isWeb() { return ["WEB", "UNI-H5", "TARO-H5"].includes(this.config.flag); } /** * Asynchronously load image and return image geometric information * @param src Image path * @param info Image information */ loadImg(t, e, i = "$resolve") { return new Promise((s, n) => { if (t || n(`=> '${e.src}' cannot be empty or invalid`), this.config.flag === "WEB") { let h = new Image(); h.crossorigin = "anonymous", h.onload = () => s(h), h.onerror = () => n(`=> '${e.src}' image load failed`), h.src = t; } else { e[i] = s, e.$reject = n; return; } }); } /** * Common method for drawing images * @param imgObj Image object * @param rectInfo: [x-axis position, y-axis position, render width, render height] */ drawImage(t, e, ...i) { var a, u; let s; const { flag: n, dpr: h } = this.config; if (["WEB", "MP-WX"].includes(n)) s = e; else if (["UNI-H5", "UNI-MP", "TARO-H5", "TARO-MP"].includes(n)) s = e.path; else return console.error("Unexpected flag, platform not yet compatible!"); const o = (u = (a = s.canvas || s).getContext) == null ? void 0 : u.call(a, "2d"); if (o && !this.isWeb()) { i = i.map((c) => c * h); const f = o.getImageData(...i.slice(0, 4)); t.putImageData(f, ...i.slice(4, 6)); } else { i.length === 8 && (i = i.map((f, c) => c < 4 ? f * h : f)); try { t.drawImage(s, ...i); } catch { } } } /** * Calculate image render width and height * @param imgObj Image tag element * @param imgInfo Image information * @param maxWidth Maximum width * @param maxHeight Maximum height * @return [render width, render height] */ computedWidthAndHeight(t, e, i, s) { if (!e.width && !e.height) return [t.width, t.height]; if (e.width && !e.height) { let n = this.getLength(e.width, i); return [n, t.height * (n / t.width)]; } else if (!e.width && e.height) { let n = this.getLength(e.height, s); return [t.width * (n / t.height), n]; } return [ this.getLength(e.width, i), this.getLength(e.height, s) ]; } /** * Convert units * @param { string } value Value to convert * @param { number } denominator Denominator * @return { number } Return new string */ changeUnits(t, e = 1) { const { config: i } = this; return Number(t.replace(/^([-]*[0-9.]*)([a-z%]*)$/, (s, n, h) => { const o = { "%": (u) => u * (e / 100), px: (u) => u * 1, rem: (u) => u * this.htmlFontSize, vw: (u) => u / 100 * window.innerWidth }[h]; if (o) return o(n); const a = i.handleCssUnit || i.unitFunc; return a ? a(n, h) : n; })); } /** * Get length * @param length Length to convert * @param maxLength Maximum length * @return Length */ getLength(t, e) { return mt(t, "number") ? t : mt(t, "string") ? this.changeUnits(t, e) : 0; } /** * Get relative (centered) X coordinate * @param width * @param col */ getOffsetX(t, e = 0) { return (e - t) / 2; } getOffscreenCanvas(t, e) { if (!ht(this, "_offscreenCanvas") && (window && window.document && this.config.flag === "WEB" ? this._offscreenCanvas = document.createElement("canvas") : this._offscreenCanvas = this.config.offscreenCanvas, !this._offscreenCanvas)) return console.error("Offscreen Canvas cannot render!"); const i = this.config.dpr, s = this._offscreenCanvas; s.width = (t || 300) * i, s.height = (e || 150) * i; const n = s.getContext("2d"); return n.clearRect(0, 0, t, e), n.scale(i, i), n.dpr = i, { _offscreenCanvas: s, _ctx: n }; } /** * Add a new reactive data (temporary) * @param data Data * @param key Property * @param value New value */ $set(t, e, i) { !t || typeof t != "object" || ne(t, e, i); } /** * Add a computed property (temporary) * @param data Source data * @param key Property name * @param callback Callback function */ $computed(t, e, i) { Object.defineProperty(t, e, { get: () => i.call(this) }); } /** * Add an observer create user watcher * @param expr Expression * @param handler Callback function * @param watchOpt Configuration parameters * @return Function to uninstall current observer (not yet returned) */ $watch(t, e, i = {}) { typeof e == "object" && (i = e, e = i.handler); const s = new Ne(this, t, e, i); return i.immediate && e.call(this, s.value), function() { }; } }; Wt.version = Tt; let yt = Wt; const q = (l) => Math.PI / 180 * l, Ue = (l, t) => [+(Math.cos(l) * t).toFixed(8), +(Math.sin(l) * t).toFixed(8)], Ye = (l, t, e, i, s, n) => { l.beginPath(); let h = q(90 / Math.PI / e * n), o = i + h, a = s - h; l.arc(0, 0, e, o, a, !1), l.lineTo( ...Ue( (i + s) / 2, n / 2 / Math.abs(Math.sin((i - s) / 2)) ) ), l.closePath(); }, kt = (l, ...[t, e, i, s, n]) => { const h = Math.min(i, s), o = Math.PI; n > h / 2 && (n = h / 2), l.beginPath(), l.moveTo(t + n, e), l.lineTo(t + n, e), l.lineTo(t + i - n, e), l.arc(t + i - n, e + n, n, -o / 2, 0), l.lineTo(t + i, e + s - n), l.arc(t + i - n, e + s - n, n, 0, o / 2), l.lineTo(t + n, e + s), l.arc(t + n, e + s - n, n, o / 2, o), l.lineTo(t, e + n), l.arc(t + n, e + n, n, o, -o / 2), l.closePath(); }, Xe = (l, t, e, i, s, n) => { const h = /linear-gradient\((.+)\)/.exec(n)[1].split(",").map((f) => f.trim()); let o = h.shift(), a = [0, 0, 0, 0]; if (o.includes("deg")) { o = o.slice(0, -3) % 360; const f = (c) => Math.tan(c / 180 * Math.PI); o >= 0 && o < 45 ? a = [t, e + s, t + i, e + s - i * f(o - 0)] : o >= 45 && o < 90 ? a = [t, e + s, t + i - s * f(o - 45), e] : o >= 90 && o < 135 ? a = [t + i, e + s, t + i - s * f(o - 90), e] : o >= 135 && o < 180 ? a = [t + i, e + s, t, e + i * f(o - 135)] : o >= 180 && o < 225 ? a = [t + i, e, t, e + i * f(o - 180)] : o >= 225 && o < 270 ? a = [t + i, e, t + s * f(o - 225), e + s] : o >= 270 && o < 315 ? a = [t, e, t + s * f(o - 270), e + s] : o >= 315 && o < 360 && (a = [t, e, t + i, e + s - i * f(o - 315)]); } else o.includes("top") ? a = [t, e + s, t, e] : o.includes("bottom") ? a = [t, e, t, e + s] : o.includes("left") ? a = [t + i, e, t, e] : o.includes("right") && (a = [t, e, t + i, e]); const u = l.createLinearGradient(...a.map((f) => f >> 0)); return h.reduce((f, c, p) => { const w = c.split(" "); return w.length === 1 ? f.addColorStop(p, w[0]) : w.length === 2 && f.addColorStop(...w), f; }, u); }, G = { easeIn: function(l, t, e, i) { return l >= i && (l = i), e * (l /= i) * l + t; }, easeOut: function(l, t, e, i) { return l >= i && (l = i), -e * (l /= i) * (l - 2) + t; } }; class Ge extends yt { /** * Lucky wheel constructor * @param config Configuration * @param data Lottery data */ constructor(t, e) { var i; super(t, { width: e.width, height: e.height }), this.blocks = [], this.prizes = [], this.buttons = [], this.defaultConfig = {}, this.defaultStyle = {}, this._defaultConfig = {}, this._defaultStyle = {}, this.Radius = 0, this.prizeRadius = 0, this.prizeDeg = 0, this.prizeAng = 0, this.rotateDeg = 0, this.maxBtnRadius = 0, this.startTime = 0, this.endTime = 0, this.stopDeg = 0, this.endDeg = 0, this.FPS = 16.6, this.step = 0, this.ImageCache = /* @__PURE__ */ new Map(), this.initData(e), this.initWatch(), this.initComputed(), (i = t.beforeCreate) == null || i.call(this), this.init(); } resize() { var t, e; super.resize(), this.Radius = Math.min(this.boxWidth, this.boxHeight) / 2, this.ctx.translate(this.Radius, this.Radius), this.draw(), (e = (t = this.config).afterResize) == null || e.call(t); } initLucky() { this.Radius = 0, this.prizeRadius = 0, this.prizeDeg = 0, this.prizeAng = 0, this.rotateDeg = 0, this.maxBtnRadius = 0, this.startTime = 0, this.endTime = 0, this.stopDeg = 0, this.endDeg = 0, this.FPS = 16.6, this.prizeFlag = -1, this.step = 0, super.initLucky(); } /** * Initialize data * @param data */ initData(t) { this.$set(this, "width", t.width), this.$set(this, "height", t.height), this.$set(this, "blocks", t.blocks || []), this.$set(this, "prizes", t.prizes || []), this.$set(this, "buttons", t.buttons || []), this.$set(this, "defaultConfig", t.defaultConfig || {}), this.$set(this, "defaultStyle", t.defaultStyle || {}), this.$set(this, "startCallback", t.start), this.$set(this, "endCallback", t.end); } /** * Initialize computed properties */ initComputed() { this.$computed(this, "_defaultConfig", () => ({ gutter: "0px", offsetDegree: 0, speed: 20, speedFunction: "quad", accelerationTime: 2500, decelerationTime: 2500, stopRange: 0, ...this.defaultConfig })), this.$computed(this, "_defaultStyle", () => ({ fontSize: "18px", fontColor: "#000", fontStyle: "sans-serif", fontWeight: "400", background: "rgba(0,0,0,0)", wordWrap: !0, lengthLimit: "90%", ...this.defaultStyle })); } /** * Initialize observers */ initWatch() { this.$watch("width", (t) => { this.data.width = t, this.resize(); }), this.$watch("height", (t) => { this.data.height = t, this.resize(); }), this.$watch("blocks", (t) => { this.initImageCache(); }, { deep: !0 }), this.$watch("prizes", (t) => { this.initImageCache(); }, { deep: !0 }), this.$watch("buttons", (t) => { this.initImageCache(); }, { deep: !0 }), this.$watch("defaultConfig", () => this.draw(), { deep: !0 }), this.$watch("defaultStyle", () => this.draw(), { deep: !0 }), this.$watch("startCallback", () => this.init()), this.$watch("endCallback", () => this.init()); } /** * Initialize canvas lottery */ async init() { var e, i; this.initLucky(); const { config: t } = this; (e = t.beforeInit) == null || e.call(this), this.draw(), this.draw(), await this.initImageCache(), (i = t.afterInit) == null || i.call(this); } initImageCache() { return new Promise((t) => { const e = { blocks: this.blocks.map((i) => i.imgs), prizes: this.prizes.map((i) => i.imgs), buttons: this.buttons.map((i) => i.imgs) }; Object.keys(e).forEach((i) => { const s = e[i], n = []; s && s.forEach((h, o) => { h && h.forEach((a, u) => { n.push(this.loadAndCacheImg(i, o, u)); }); }), Promise.all(n).then(() => { this.draw(), t(); }); }); }); } /** * Canvas click event * @param e Event parameters */ handleClick(t) { var i; const { ctx: e } = this; e.beginPath(), e.arc(0, 0, this.maxBtnRadius, 0, Math.PI * 2, !1), e.isPointInPath(t.offsetX, t.offsetY) && this.step === 0 && ((i = this.startCallback) == null || i.call(this, t)); } /** * Load and cache specified image by index * @param cellName Module name * @param cellIndex Module index * @param imgName Module image cache * @param imgIndex Image index */ async loadAndCacheImg(t, e, i) { return new Promise((s, n) => { const h = this[t][e]; if (!h || !h.imgs) return; const o = h.imgs[i]; o && this.loadImg(o.src, o).then(async (a) => { typeof o.formatter == "function" && (a = await Promise.resolve(o.formatter.call(this, a))), this.ImageCache.set(o.src, a), s(); }).catch((a) => { console.error(`${t}[${e}].imgs[${i}] ${a}`), n(); }); }); } drawBlock(t, e, i) { const { ctx: s } = this; J(e.background) && (s.beginPath(), s.fillStyle = e.background, s.arc(0, 0, t, 0, Math.PI * 2, !1), s.fill()), e.imgs && e.imgs.forEach((n, h) => { const o = this.ImageCache.get(n.src); if (!o) return; const [a, u] = this.computedWidthAndHeight(o, n, t * 2, t * 2), [f, c] = [this.getOffsetX(a) + this.getLength(n.left, t * 2), this.getLength(n.top, t * 2) - t]; s.save(), n.rotate && s.rotate(q(this.rotateDeg)), this.drawImage(s, o, f, c, a, u), s.restore(); }); } /** * Start drawing */ draw() { var u, f; const { config: t, ctx: e, _defaultConfig: i, _defaultStyle: s } = this; (u = t.beforeDraw) == null || u.call(this, e), e.clearRect(-this.Radius, -this.Radius, this.Radius * 2, this.Radius * 2), this.prizeRadius = this.blocks.reduce((c, p, w) => (this.drawBlock(c, p, w), c - this.getLength(p.padding && p.padding.split(" ")[0])), this.Radius), this.prizeDeg = 360 / this.prizes.length, this.prizeAng = q(this.prizeDeg); const n = this.prizeRadius * Math.sin(this.prizeAng / 2) * 2; let h = q(this.rotateDeg - 90 + this.prizeDeg / 2 + i.offsetDegree); const o = (c, p) => this.getOffsetX(e.measureText(p).width) + this.getLength(c.left, n), a = (c, p, w) => { const y = c.lineHeight || s.lineHeight || c.fontSize || s.fontSize; return this.getLength(c.top, p) + (w + 1) * this.getLength(y); }; e.save(), this.prizes.forEach((c, p) => { let w = h + p * this.prizeAng, y = this.prizeRadius - this.maxBtnRadius; const E = c.background || s.background; J(E) && (e.fillStyle = E, Ye( e, this.maxBtnRadius, this.prizeRadius, w - this.prizeAng / 2, w + this.prizeAng / 2, this.getLength(i.gutter) ), e.fill()); let g = Math.cos(w) * this.prizeRadius, k = Math.sin(w) * this.prizeRadius; e.translate(g, k), e.rotate(w + q(90)), c.imgs && c.imgs.forEach((b, x) => { const S = this.ImageCache.get(b.src); if (!S) return; const [A, T] = this.computedWidthAndHeight( S, b, this.prizeAng * this.prizeRadius, y ), [I, W] = [ this.getOffsetX(A) + this.getLength(b.left, n), this.getLength(b.top, y) ]; this.drawImage(e, S, I, W, A, T); }), c.fonts && c.fonts.forEach((b) => { const x = b.fontColor || s.fontColor, S = b.fontWeight || s.fontWeight, A = this.getLength(b.fontSize || s.fontSize), T = b.fontStyle || s.fontStyle, I = ht(b, "wordWrap") ? b.wordWrap : s.wordWrap, W = b.lengthLimit || s.lengthLimit, D = b.lineClamp || s.lineClamp, O = b.rotate || 0; e.fillStyle = x, e.font = `${S} ${A >> 0}px ${T}`; let H = [], Y = String(b.text); I ? H = It(e, At(Y), (F) => { let j = (this.prizeRadius - a(b, y, F.length)) * Math.tan(this.prizeAng / 2) * 2 - this.getLength(i.gutter); return this.getLength(W, j); }, D) : H = Y.split(` `), H.filter((F) => !!F).forEach((F, j) => { const U = o(b, F), it = a(b, y, j); e.save(), e.translate(U, it), e.rotate(q(O)), e.fillText(F, 0, 0), e.restore(); }); }), e.rotate(q(360) - w - q(90)), e.translate(-g, -k); }), e.restore(), this.buttons.forEach((c, p) => { let w = this.getLength(c.radius, this.prizeRadius); this.maxBtnRadius = Math.max(this.maxBtnRadius, w), J(c.background) && (e.beginPath(), e.fillStyle = c.background, e.arc(0, 0, w, 0, Math.PI * 2, !1), e.fill()), c.pointer && J(c.background) && (e.beginPath(), e.fillStyle = c.background, e.moveTo(-w, 0), e.lineTo(w, 0), e.lineTo(0, -w * 2), e.closePath(), e.fill()), c.imgs && c.imgs.forEach((y, E) => { const g = this.ImageCache.get(y.src); if (!g) return; const [k, b] = this.computedWidthAndHeight(g, y, w * 2, w * 2), [x, S] = [this.getOffsetX(k) + this.getLength(y.left, w), this.getLength(y.top, w)]; this.drawImage(e, g, x, S, k, b); }), c.fonts && c.fonts.forEach((y) => { let E = y.fontColor || s.fontColor, g = y.fontWeight || s.fontWeight, k = this.getLength(y.fontSize || s.fontSize), b = y.fontStyle || s.fontStyle; e.fillStyle = E, e.font = `${g} ${k >> 0}px ${b}`, String(y.text).split(` `).forEach((x, S) => { e.fillText(x, o(y, x), a(y, w, S)); }); }); }), (f = t.afterDraw) == null || f.call(this, e); } /** * Carve on gunwale of moving boat */ carveOnGunwaleOfAMovingBoat() { const { _defaultConfig: t, prizeFlag: e, prizeDeg: i, rotateDeg: s } = this; this.endTime = Date.now(); const n = this.stopDeg = s, h = t.speed, o = (Math.random() * i - i / 2) * this.getLength(t.stopRange); let a = 0, u = 0, f = 0; for (; ++a; ) { const c = 360 * a - e * i - s - t.offsetDegree + o - i / 2; let p = G.easeOut(this.FPS, n, c, t.decelerationTime) - n; if (p > h) { this.endDeg = h - u > p - h ? c : f; break; } f = c, u = p; } } /** * Exposed: Start lottery method */ play() { var t, e; this.step === 0 && (this.startTime = Date.now(), this.prizeFlag = void 0, this.step = 1, (e = (t = this.config).afterStart) == null || e.call(t), this.run()); } /** * Exposed: Slow stop method * @param index Prize index */ stop(t) { if (!(this.step === 0 || this.step === 3)) { if (!t && t !== 0) { const e = this.prizes.map((i) => i.range); t = se(e); } t < 0 ? (this.step = 0, this.prizeFlag = -1) : (this.step = 2, this.prizeFlag = t % this.prizes.length); } } /** * Actually start execution method * @param num Record how many times frame animation executed */ run(t = 0) { var p; const { rAF: e, step: i, prizeFlag: s, _defaultConfig: n } = this, { accelerationTime: h, decelerationTime: o, speed: a } = n; if (i === 0) { (p = this.endCallback) == null || p.call(this, this.prizes.find((w, y) => y === s) || {}); return; } if (s === -1) return; i === 3 && !this.endDeg && this.carveOnGunwaleOfAMovingBoat(); const u = Date.now() - this.startTime, f = Date.now() - this.endTime; let c = this.rotateDeg; if (i === 1 || u < h) { this.FPS = u / t; const w = G.easeIn(u, 0, a, h); w === a && (this.step = 2), c = c + w % 360; } else i === 2 ? (c = c + a % 360, s !== void 0 && s >= 0 && (this.step = 3, this.stopDeg = 0, this.endDeg = 0)) : i === 3 ? (c = G.easeOut(f, this.stopDeg, this.endDeg, o), f >= o && (this.step = 0)) : this.stop(-1); this.rotateDeg = c, this.draw(), e(this.run.bind(this, t + 1)); } /** * Convert render coordinates * @param x * @param y */ conversionAxis(t, e) { const { config: i } = this; return [t / i.dpr - this.Radius, e / i.dpr - this.Radius]; } } class Ve exten