const __vite__mapDeps = (i, m=__vite__mapDeps, d=(m.f || (m.f = ["js/browserAll-_HSkMkNs.js", "js/webworkerAll-Bal_rQBj.js", "js/canvasUtils-BvmpO7YZ.js", "js/Filter-BRoym6Oj.js", "js/index-xnhGKCfe.js", "css/index-BarkczBl.css", "js/WebGPURenderer-DJ3OxtML.js", "js/localUniformBit-BOGrcT1E.js", "js/BufferResource-QPKhnBC5.js", "js/RenderTargetSystem-D-vK_uIb.js", "js/colorToUniform-DUza8Qlq.js", "js/WebGLRenderer-B7bE1YuE.js", "js/CanvasRenderer-D0z9UDRV.js", "js/Graphics-BZzfoMkk.js", "js/BitmapFont-Dw0jX6D9.js"]))) => i.map(i => d[i]);
import {aW as oe, d4 as Zr} from "./index-xnhGKCfe.js";
var I = (s => (s.Application = "application",
s.WebGLPipes = "webgl-pipes",
s.WebGLPipesAdaptor = "webgl-pipes-adaptor",
s.WebGLSystem = "webgl-system",
s.WebGPUPipes = "webgpu-pipes",
s.WebGPUPipesAdaptor = "webgpu-pipes-adaptor",
s.WebGPUSystem = "webgpu-system",
s.CanvasSystem = "canvas-system",
s.CanvasPipesAdaptor = "canvas-pipes-adaptor",
s.CanvasPipes = "canvas-pipes",
s.Asset = "asset",
s.LoadParser = "load-parser",
s.ResolveParser = "resolve-parser",
s.CacheParser = "cache-parser",
s.DetectionParser = "detection-parser",
s.MaskEffect = "mask-effect",
s.BlendMode = "blend-mode",
s.TextureSource = "texture-source",
s.Environment = "environment",
s.ShapeBuilder = "shape-builder",
s.Batcher = "batcher",
s))(I || {});
const js = s => {
    if (typeof s == "function" || typeof s == "object" && s.extension) {
        if (!s.extension)
            throw new Error("Extension class must have an extension object");
        s = {
            ...typeof s.extension != "object" ? {
                type: s.extension
            } : s.extension,
            ref: s
        }
    }
    if (typeof s == "object")
        s = {
            ...s
        };
    else
        throw new Error("Invalid extension type");
    return typeof s.type == "string" && (s.type = [s.type]),
    s
}
  , He = (s, t) => js(s).priority ?? t
  , Y = {
    _addHandlers: {},
    _removeHandlers: {},
    _queue: {},
    remove(...s) {
        return s.map(js).forEach(t => {
            t.type.forEach(e => {
                var i, r;
                return (r = (i = this._removeHandlers)[e]) == null ? void 0 : r.call(i, t)
            }
            )
        }
        ),
        this
    },
    add(...s) {
        return s.map(js).forEach(t => {
            t.type.forEach(e => {
                var n, a;
                const i = this._addHandlers
                  , r = this._queue;
                i[e] ? (a = i[e]) == null || a.call(i, t) : (r[e] = r[e] || [],
                (n = r[e]) == null || n.push(t))
            }
            )
        }
        ),
        this
    },
    handle(s, t, e) {
        var a;
        const i = this._addHandlers
          , r = this._removeHandlers;
        if (i[s] || r[s])
            throw new Error(`Extension type ${s} already has a handler`);
        i[s] = t,
        r[s] = e;
        const n = this._queue;
        return n[s] && ((a = n[s]) == null || a.forEach(o => t(o)),
        delete n[s]),
        this
    },
    handleByMap(s, t) {
        return this.handle(s, e => {
            e.name && (t[e.name] = e.ref)
        }
        , e => {
            e.name && delete t[e.name]
        }
        )
    },
    handleByNamedList(s, t, e=-1) {
        return this.handle(s, i => {
            t.findIndex(n => n.name === i.name) >= 0 || (t.push({
                name: i.name,
                value: i.ref
            }),
            t.sort( (n, a) => He(a.value, e) - He(n.value, e)))
        }
        , i => {
            const r = t.findIndex(n => n.name === i.name);
            r !== -1 && t.splice(r, 1)
        }
        )
    },
    handleByList(s, t, e=-1) {
        return this.handle(s, i => {
            t.includes(i.ref) || (t.push(i.ref),
            t.sort( (r, n) => He(n, e) - He(r, e)))
        }
        , i => {
            const r = t.indexOf(i.ref);
            r !== -1 && t.splice(r, 1)
        }
        )
    },
    mixin(s, ...t) {
        for (const e of t)
            Object.defineProperties(s.prototype, Object.getOwnPropertyDescriptors(e))
    }
}
  , La = {
    extension: {
        type: I.Environment,
        name: "browser",
        priority: -1
    },
    test: () => !0,
    load: async () => {
        await oe( () => import("./browserAll-_HSkMkNs.js"), __vite__mapDeps([0, 1, 2, 3, 4, 5]))
    }
}
  , Ga = {
    extension: {
        type: I.Environment,
        name: "webworker",
        priority: 0
    },
    test: () => typeof self < "u" && self.WorkerGlobalScope !== void 0,
    load: async () => {
        await oe( () => import("./webworkerAll-Bal_rQBj.js"), __vite__mapDeps([1, 2, 3, 4, 5]))
    }
};
class it {
    constructor(t, e, i) {
        this._x = e || 0,
        this._y = i || 0,
        this._observer = t
    }
    clone(t) {
        return new it(t ?? this._observer,this._x,this._y)
    }
    set(t=0, e=t) {
        return (this._x !== t || this._y !== e) && (this._x = t,
        this._y = e,
        this._observer._onUpdate(this)),
        this
    }
    copyFrom(t) {
        return (this._x !== t.x || this._y !== t.y) && (this._x = t.x,
        this._y = t.y,
        this._observer._onUpdate(this)),
        this
    }
    copyTo(t) {
        return t.set(this._x, this._y),
        t
    }
    equals(t) {
        return t.x === this._x && t.y === this._y
    }
    toString() {
        return `[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`
    }
    get x() {
        return this._x
    }
    set x(t) {
        this._x !== t && (this._x = t,
        this._observer._onUpdate(this))
    }
    get y() {
        return this._y
    }
    set y(t) {
        this._y !== t && (this._y = t,
        this._observer._onUpdate(this))
    }
}
var bs = {
    exports: {}
}, Mi;
function Da() {
    return Mi || (Mi = 1,
    (function(s) {
        var t = Object.prototype.hasOwnProperty
          , e = "~";
        function i() {}
        Object.create && (i.prototype = Object.create(null),
        new i().__proto__ || (e = !1));
        function r(h, l, c) {
            this.fn = h,
            this.context = l,
            this.once = c || !1
        }
        function n(h, l, c, u, d) {
            if (typeof c != "function")
                throw new TypeError("The listener must be a function");
            var f = new r(c,u || h,d)
              , p = e ? e + l : l;
            return h._events[p] ? h._events[p].fn ? h._events[p] = [h._events[p], f] : h._events[p].push(f) : (h._events[p] = f,
            h._eventsCount++),
            h
        }
        function a(h, l) {
            --h._eventsCount === 0 ? h._events = new i : delete h._events[l]
        }
        function o() {
            this._events = new i,
            this._eventsCount = 0
        }
        o.prototype.eventNames = function() {
            var l = [], c, u;
            if (this._eventsCount === 0)
                return l;
            for (u in c = this._events)
                t.call(c, u) && l.push(e ? u.slice(1) : u);
            return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(c)) : l
        }
        ,
        o.prototype.listeners = function(l) {
            var c = e ? e + l : l
              , u = this._events[c];
            if (!u)
                return [];
            if (u.fn)
                return [u.fn];
            for (var d = 0, f = u.length, p = new Array(f); d < f; d++)
                p[d] = u[d].fn;
            return p
        }
        ,
        o.prototype.listenerCount = function(l) {
            var c = e ? e + l : l
              , u = this._events[c];
            return u ? u.fn ? 1 : u.length : 0
        }
        ,
        o.prototype.emit = function(l, c, u, d, f, p) {
            var m = e ? e + l : l;
            if (!this._events[m])
                return !1;
            var g = this._events[m], x = arguments.length, y, _;
            if (g.fn) {
                switch (g.once && this.removeListener(l, g.fn, void 0, !0),
                x) {
                case 1:
                    return g.fn.call(g.context),
                    !0;
                case 2:
                    return g.fn.call(g.context, c),
                    !0;
                case 3:
                    return g.fn.call(g.context, c, u),
                    !0;
                case 4:
                    return g.fn.call(g.context, c, u, d),
                    !0;
                case 5:
                    return g.fn.call(g.context, c, u, d, f),
                    !0;
                case 6:
                    return g.fn.call(g.context, c, u, d, f, p),
                    !0
                }
                for (_ = 1,
                y = new Array(x - 1); _ < x; _++)
                    y[_ - 1] = arguments[_];
                g.fn.apply(g.context, y)
            } else {
                var b = g.length, A;
                for (_ = 0; _ < b; _++)
                    switch (g[_].once && this.removeListener(l, g[_].fn, void 0, !0),
                    x) {
                    case 1:
                        g[_].fn.call(g[_].context);
                        break;
                    case 2:
                        g[_].fn.call(g[_].context, c);
                        break;
                    case 3:
                        g[_].fn.call(g[_].context, c, u);
                        break;
                    case 4:
                        g[_].fn.call(g[_].context, c, u, d);
                        break;
                    default:
                        if (!y)
                            for (A = 1,
                            y = new Array(x - 1); A < x; A++)
                                y[A - 1] = arguments[A];
                        g[_].fn.apply(g[_].context, y)
                    }
            }
            return !0
        }
        ,
        o.prototype.on = function(l, c, u) {
            return n(this, l, c, u, !1)
        }
        ,
        o.prototype.once = function(l, c, u) {
            return n(this, l, c, u, !0)
        }
        ,
        o.prototype.removeListener = function(l, c, u, d) {
            var f = e ? e + l : l;
            if (!this._events[f])
                return this;
            if (!c)
                return a(this, f),
                this;
            var p = this._events[f];
            if (p.fn)
                p.fn === c && (!d || p.once) && (!u || p.context === u) && a(this, f);
            else {
                for (var m = 0, g = [], x = p.length; m < x; m++)
                    (p[m].fn !== c || d && !p[m].once || u && p[m].context !== u) && g.push(p[m]);
                g.length ? this._events[f] = g.length === 1 ? g[0] : g : a(this, f)
            }
            return this
        }
        ,
        o.prototype.removeAllListeners = function(l) {
            var c;
            return l ? (c = e ? e + l : l,
            this._events[c] && a(this, c)) : (this._events = new i,
            this._eventsCount = 0),
            this
        }
        ,
        o.prototype.off = o.prototype.removeListener,
        o.prototype.addListener = o.prototype.on,
        o.prefixed = e,
        o.EventEmitter = o,
        s.exports = o
    }
    )(bs)),
    bs.exports
}
var za = Da();
const vt = Zr(za)
  , Wa = Math.PI * 2
  , Oa = 180 / Math.PI
  , Ua = Math.PI / 180;
class nt {
    constructor(t=0, e=0) {
        this.x = 0,
        this.y = 0,
        this.x = t,
        this.y = e
    }
    clone() {
        return new nt(this.x,this.y)
    }
    copyFrom(t) {
        return this.set(t.x, t.y),
        this
    }
    copyTo(t) {
        return t.set(this.x, this.y),
        t
    }
    equals(t) {
        return t.x === this.x && t.y === this.y
    }
    set(t=0, e=t) {
        return this.x = t,
        this.y = e,
        this
    }
    toString() {
        return `[pixi.js/math:Point x=${this.x} y=${this.y}]`
    }
    static get shared() {
        return ws.x = 0,
        ws.y = 0,
        ws
    }
}
const ws = new nt;
class D {
    constructor(t=1, e=0, i=0, r=1, n=0, a=0) {
        this.array = null,
        this.a = t,
        this.b = e,
        this.c = i,
        this.d = r,
        this.tx = n,
        this.ty = a
    }
    fromArray(t) {
        this.a = t[0],
        this.b = t[1],
        this.c = t[3],
        this.d = t[4],
        this.tx = t[2],
        this.ty = t[5]
    }
    set(t, e, i, r, n, a) {
        return this.a = t,
        this.b = e,
        this.c = i,
        this.d = r,
        this.tx = n,
        this.ty = a,
        this
    }
    toArray(t, e) {
        this.array || (this.array = new Float32Array(9));
        const i = e || this.array;
        return t ? (i[0] = this.a,
        i[1] = this.b,
        i[2] = 0,
        i[3] = this.c,
        i[4] = this.d,
        i[5] = 0,
        i[6] = this.tx,
        i[7] = this.ty,
        i[8] = 1) : (i[0] = this.a,
        i[1] = this.c,
        i[2] = this.tx,
        i[3] = this.b,
        i[4] = this.d,
        i[5] = this.ty,
        i[6] = 0,
        i[7] = 0,
        i[8] = 1),
        i
    }
    apply(t, e) {
        e = e || new nt;
        const i = t.x
          , r = t.y;
        return e.x = this.a * i + this.c * r + this.tx,
        e.y = this.b * i + this.d * r + this.ty,
        e
    }
    applyInverse(t, e) {
        e = e || new nt;
        const i = this.a
          , r = this.b
          , n = this.c
          , a = this.d
          , o = this.tx
          , h = this.ty
          , l = 1 / (i * a + n * -r)
          , c = t.x
          , u = t.y;
        return e.x = a * l * c + -n * l * u + (h * n - o * a) * l,
        e.y = i * l * u + -r * l * c + (-h * i + o * r) * l,
        e
    }
    translate(t, e) {
        return this.tx += t,
        this.ty += e,
        this
    }
    scale(t, e) {
        return this.a *= t,
        this.d *= e,
        this.c *= t,
        this.b *= e,
        this.tx *= t,
        this.ty *= e,
        this
    }
    rotate(t) {
        const e = Math.cos(t)
          , i = Math.sin(t)
          , r = this.a
          , n = this.c
          , a = this.tx;
        return this.a = r * e - this.b * i,
        this.b = r * i + this.b * e,
        this.c = n * e - this.d * i,
        this.d = n * i + this.d * e,
        this.tx = a * e - this.ty * i,
        this.ty = a * i + this.ty * e,
        this
    }
    append(t) {
        const e = this.a
          , i = this.b
          , r = this.c
          , n = this.d;
        return this.a = t.a * e + t.b * r,
        this.b = t.a * i + t.b * n,
        this.c = t.c * e + t.d * r,
        this.d = t.c * i + t.d * n,
        this.tx = t.tx * e + t.ty * r + this.tx,
        this.ty = t.tx * i + t.ty * n + this.ty,
        this
    }
    appendFrom(t, e) {
        const i = t.a
          , r = t.b
          , n = t.c
          , a = t.d
          , o = t.tx
          , h = t.ty
          , l = e.a
          , c = e.b
          , u = e.c
          , d = e.d;
        return this.a = i * l + r * u,
        this.b = i * c + r * d,
        this.c = n * l + a * u,
        this.d = n * c + a * d,
        this.tx = o * l + h * u + e.tx,
        this.ty = o * c + h * d + e.ty,
        this
    }
    setTransform(t, e, i, r, n, a, o, h, l) {
        return this.a = Math.cos(o + l) * n,
        this.b = Math.sin(o + l) * n,
        this.c = -Math.sin(o - h) * a,
        this.d = Math.cos(o - h) * a,
        this.tx = t - (i * this.a + r * this.c),
        this.ty = e - (i * this.b + r * this.d),
        this
    }
    prepend(t) {
        const e = this.tx;
        if (t.a !== 1 || t.b !== 0 || t.c !== 0 || t.d !== 1) {
            const i = this.a
              , r = this.c;
            this.a = i * t.a + this.b * t.c,
            this.b = i * t.b + this.b * t.d,
            this.c = r * t.a + this.d * t.c,
            this.d = r * t.b + this.d * t.d
        }
        return this.tx = e * t.a + this.ty * t.c + t.tx,
        this.ty = e * t.b + this.ty * t.d + t.ty,
        this
    }
    decompose(t) {
        const e = this.a
          , i = this.b
          , r = this.c
          , n = this.d
          , a = t.pivot
          , o = -Math.atan2(-r, n)
          , h = Math.atan2(i, e)
          , l = Math.abs(o + h);
        return l < 1e-5 || Math.abs(Wa - l) < 1e-5 ? (t.rotation = h,
        t.skew.x = t.skew.y = 0) : (t.rotation = 0,
        t.skew.x = o,
        t.skew.y = h),
        t.scale.x = Math.sqrt(e * e + i * i),
        t.scale.y = Math.sqrt(r * r + n * n),
        t.position.x = this.tx + (a.x * e + a.y * r),
        t.position.y = this.ty + (a.x * i + a.y * n),
        t
    }
    invert() {
        const t = this.a
          , e = this.b
          , i = this.c
          , r = this.d
          , n = this.tx
          , a = t * r - e * i;
        return this.a = r / a,
        this.b = -e / a,
        this.c = -i / a,
        this.d = t / a,
        this.tx = (i * this.ty - r * n) / a,
        this.ty = -(t * this.ty - e * n) / a,
        this
    }
    isIdentity() {
        return this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1 && this.tx === 0 && this.ty === 0
    }
    identity() {
        return this.a = 1,
        this.b = 0,
        this.c = 0,
        this.d = 1,
        this.tx = 0,
        this.ty = 0,
        this
    }
    clone() {
        const t = new D;
        return t.a = this.a,
        t.b = this.b,
        t.c = this.c,
        t.d = this.d,
        t.tx = this.tx,
        t.ty = this.ty,
        t
    }
    copyTo(t) {
        return t.a = this.a,
        t.b = this.b,
        t.c = this.c,
        t.d = this.d,
        t.tx = this.tx,
        t.ty = this.ty,
        t
    }
    copyFrom(t) {
        return this.a = t.a,
        this.b = t.b,
        this.c = t.c,
        this.d = t.d,
        this.tx = t.tx,
        this.ty = t.ty,
        this
    }
    equals(t) {
        return t.a === this.a && t.b === this.b && t.c === this.c && t.d === this.d && t.tx === this.tx && t.ty === this.ty
    }
    toString() {
        return `[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`
    }
    static get IDENTITY() {
        return Ha.identity()
    }
    static get shared() {
        return Na.identity()
    }
}
const Na = new D
  , Ha = new D
  , Vt = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]
  , jt = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1]
  , Yt = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1]
  , Xt = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1]
  , Ys = []
  , Qr = []
  , $e = Math.sign;
function $a() {
    for (let s = 0; s < 16; s++) {
        const t = [];
        Ys.push(t);
        for (let e = 0; e < 16; e++) {
            const i = $e(Vt[s] * Vt[e] + Yt[s] * jt[e])
              , r = $e(jt[s] * Vt[e] + Xt[s] * jt[e])
              , n = $e(Vt[s] * Yt[e] + Yt[s] * Xt[e])
              , a = $e(jt[s] * Yt[e] + Xt[s] * Xt[e]);
            for (let o = 0; o < 16; o++)
                if (Vt[o] === i && jt[o] === r && Yt[o] === n && Xt[o] === a) {
                    t.push(o);
                    break
                }
        }
    }
    for (let s = 0; s < 16; s++) {
        const t = new D;
        t.set(Vt[s], jt[s], Yt[s], Xt[s], 0, 0),
        Qr.push(t)
    }
}
$a();
const U = {
    E: 0,
    SE: 1,
    S: 2,
    SW: 3,
    W: 4,
    NW: 5,
    N: 6,
    NE: 7,
    MIRROR_VERTICAL: 8,
    MAIN_DIAGONAL: 10,
    MIRROR_HORIZONTAL: 12,
    REVERSE_DIAGONAL: 14,
    uX: s => Vt[s],
    uY: s => jt[s],
    vX: s => Yt[s],
    vY: s => Xt[s],
    inv: s => s & 8 ? s & 15 : -s & 7,
    add: (s, t) => Ys[s][t],
    sub: (s, t) => Ys[s][U.inv(t)],
    rotate180: s => s ^ 4,
    isVertical: s => (s & 3) === 2,
    byDirection: (s, t) => Math.abs(s) * 2 <= Math.abs(t) ? t >= 0 ? U.S : U.N : Math.abs(t) * 2 <= Math.abs(s) ? s > 0 ? U.E : U.W : t > 0 ? s > 0 ? U.SE : U.SW : s > 0 ? U.NE : U.NW,
    matrixAppendRotationInv: (s, t, e=0, i=0, r=0, n=0) => {
        const a = Qr[U.inv(t)]
          , o = a.a
          , h = a.b
          , l = a.c
          , c = a.d
          , u = e - Math.min(0, o * r, l * n, o * r + l * n)
          , d = i - Math.min(0, h * r, c * n, h * r + c * n)
          , f = s.a
          , p = s.b
          , m = s.c
          , g = s.d;
        s.a = o * f + h * m,
        s.b = o * p + h * g,
        s.c = l * f + c * m,
        s.d = l * p + c * g,
        s.tx = u * f + d * m + s.tx,
        s.ty = u * p + d * g + s.ty
    }
    ,
    transformRectCoords: (s, t, e, i) => {
        const {x: r, y: n, width: a, height: o} = s
          , {x: h, y: l, width: c, height: u} = t;
        return e === U.E ? (i.set(r + h, n + l, a, o),
        i) : e === U.S ? i.set(c - n - o + h, r + l, o, a) : e === U.W ? i.set(c - r - a + h, u - n - o + l, a, o) : e === U.N ? i.set(n + h, u - r - a + l, o, a) : i.set(r + h, n + l, a, o)
    }
}
  , Ve = [new nt, new nt, new nt, new nt];
class Z {
    constructor(t=0, e=0, i=0, r=0) {
        this.type = "rectangle",
        this.x = Number(t),
        this.y = Number(e),
        this.width = Number(i),
        this.height = Number(r)
    }
    get left() {
        return this.x
    }
    get right() {
        return this.x + this.width
    }
    get top() {
        return this.y
    }
    get bottom() {
        return this.y + this.height
    }
    isEmpty() {
        return this.left === this.right || this.top === this.bottom
    }
    static get EMPTY() {
        return new Z(0,0,0,0)
    }
    clone() {
        return new Z(this.x,this.y,this.width,this.height)
    }
    copyFromBounds(t) {
        return this.x = t.minX,
        this.y = t.minY,
        this.width = t.maxX - t.minX,
        this.height = t.maxY - t.minY,
        this
    }
    copyFrom(t) {
        return this.x = t.x,
        this.y = t.y,
        this.width = t.width,
        this.height = t.height,
        this
    }
    copyTo(t) {
        return t.copyFrom(this),
        t
    }
    contains(t, e) {
        return this.width <= 0 || this.height <= 0 ? !1 : t >= this.x && t < this.x + this.width && e >= this.y && e < this.y + this.height
    }
    strokeContains(t, e, i, r=.5) {
        const {width: n, height: a} = this;
        if (n <= 0 || a <= 0)
            return !1;
        const o = this.x
          , h = this.y
          , l = i * (1 - r)
          , c = i - l
          , u = o - l
          , d = o + n + l
          , f = h - l
          , p = h + a + l
          , m = o + c
          , g = o + n - c
          , x = h + c
          , y = h + a - c;
        return t >= u && t <= d && e >= f && e <= p && !(t > m && t < g && e > x && e < y)
    }
    intersects(t, e) {
        if (!e) {
            const M = this.x < t.x ? t.x : this.x;
            if ((this.right > t.right ? t.right : this.right) <= M)
                return !1;
            const S = this.y < t.y ? t.y : this.y;
            return (this.bottom > t.bottom ? t.bottom : this.bottom) > S
        }
        const i = this.left
          , r = this.right
          , n = this.top
          , a = this.bottom;
        if (r <= i || a <= n)
            return !1;
        const o = Ve[0].set(t.left, t.top)
          , h = Ve[1].set(t.left, t.bottom)
          , l = Ve[2].set(t.right, t.top)
          , c = Ve[3].set(t.right, t.bottom);
        if (l.x <= o.x || h.y <= o.y)
            return !1;
        const u = Math.sign(e.a * e.d - e.b * e.c);
        if (u === 0 || (e.apply(o, o),
        e.apply(h, h),
        e.apply(l, l),
        e.apply(c, c),
        Math.max(o.x, h.x, l.x, c.x) <= i || Math.min(o.x, h.x, l.x, c.x) >= r || Math.max(o.y, h.y, l.y, c.y) <= n || Math.min(o.y, h.y, l.y, c.y) >= a))
            return !1;
        const d = u * (h.y - o.y)
          , f = u * (o.x - h.x)
          , p = d * i + f * n
          , m = d * r + f * n
          , g = d * i + f * a
          , x = d * r + f * a;
        if (Math.max(p, m, g, x) <= d * o.x + f * o.y || Math.min(p, m, g, x) >= d * c.x + f * c.y)
            return !1;
        const y = u * (o.y - l.y)
          , _ = u * (l.x - o.x)
          , b = y * i + _ * n
          , A = y * r + _ * n
          , w = y * i + _ * a
          , v = y * r + _ * a;
        return !(Math.max(b, A, w, v) <= y * o.x + _ * o.y || Math.min(b, A, w, v) >= y * c.x + _ * c.y)
    }
    pad(t=0, e=t) {
        return this.x -= t,
        this.y -= e,
        this.width += t * 2,
        this.height += e * 2,
        this
    }
    fit(t) {
        const e = Math.max(this.x, t.x)
          , i = Math.min(this.x + this.width, t.x + t.width)
          , r = Math.max(this.y, t.y)
          , n = Math.min(this.y + this.height, t.y + t.height);
        return this.x = e,
        this.width = Math.max(i - e, 0),
        this.y = r,
        this.height = Math.max(n - r, 0),
        this
    }
    ceil(t=1, e=.001) {
        const i = Math.ceil((this.x + this.width - e) * t) / t
          , r = Math.ceil((this.y + this.height - e) * t) / t;
        return this.x = Math.floor((this.x + e) * t) / t,
        this.y = Math.floor((this.y + e) * t) / t,
        this.width = i - this.x,
        this.height = r - this.y,
        this
    }
    scale(t, e=t) {
        return this.x *= t,
        this.y *= e,
        this.width *= t,
        this.height *= e,
        this
    }
    enlarge(t) {
        const e = Math.min(this.x, t.x)
          , i = Math.max(this.x + this.width, t.x + t.width)
          , r = Math.min(this.y, t.y)
          , n = Math.max(this.y + this.height, t.y + t.height);
        return this.x = e,
        this.width = i - e,
        this.y = r,
        this.height = n - r,
        this
    }
    getBounds(t) {
        return t || (t = new Z),
        t.copyFrom(this),
        t
    }
    containsRect(t) {
        if (this.width <= 0 || this.height <= 0)
            return !1;
        const e = t.x
          , i = t.y
          , r = t.x + t.width
          , n = t.y + t.height;
        return e >= this.x && e < this.x + this.width && i >= this.y && i < this.y + this.height && r >= this.x && r < this.x + this.width && n >= this.y && n < this.y + this.height
    }
    set(t, e, i, r) {
        return this.x = t,
        this.y = e,
        this.width = i,
        this.height = r,
        this
    }
    toString() {
        return `[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`
    }
}
const As = {
    default: -1
};
function q(s="default") {
    return As[s] === void 0 && (As[s] = -1),
    ++As[s]
}
const ki = new Set
  , dt = "8.0.0"
  , Va = "8.3.4"
  , ne = {
    quiet: !1,
    noColor: !1
}
  , V = ( (s, t, e=3) => {
    if (ne.quiet || ki.has(t))
        return;
    let i = new Error().stack;
    const r = `${t}
Deprecated since v${s}`
      , n = typeof console.groupCollapsed == "function" && !ne.noColor;
    typeof i > "u" || (i = i.split(`
`).splice(e).join(`
`)),
    ki.add(t)
}
);
Object.defineProperties(V, {
    quiet: {
        get: () => ne.quiet,
        set: s => {
            ne.quiet = s
        }
        ,
        enumerable: !0,
        configurable: !1
    },
    noColor: {
        get: () => ne.noColor,
        set: s => {
            ne.noColor = s
        }
        ,
        enumerable: !0,
        configurable: !1
    }
});
const Jr = () => {}
;
function ce(s) {
    return s += s === 0 ? 1 : 0,
    --s,
    s |= s >>> 1,
    s |= s >>> 2,
    s |= s >>> 4,
    s |= s >>> 8,
    s |= s >>> 16,
    s + 1
}
function Ei(s) {
    return !(s & s - 1) && !!s
}
function tn(s) {
    const t = {};
    for (const e in s)
        s[e] !== void 0 && (t[e] = s[e]);
    return t
}
const Ii = Object.create(null);
function ja(s) {
    const t = Ii[s];
    return t === void 0 && (Ii[s] = q("resource")),
    t
}
const en = class sn extends vt {
    constructor(t={}) {
        super(),
        this._resourceType = "textureSampler",
        this._touched = 0,
        this._maxAnisotropy = 1,
        this.destroyed = !1,
        t = {
            ...sn.defaultOptions,
            ...t
        },
        this.addressMode = t.addressMode,
        this.addressModeU = t.addressModeU ?? this.addressModeU,
        this.addressModeV = t.addressModeV ?? this.addressModeV,
        this.addressModeW = t.addressModeW ?? this.addressModeW,
        this.scaleMode = t.scaleMode,
        this.magFilter = t.magFilter ?? this.magFilter,
        this.minFilter = t.minFilter ?? this.minFilter,
        this.mipmapFilter = t.mipmapFilter ?? this.mipmapFilter,
        this.lodMinClamp = t.lodMinClamp,
        this.lodMaxClamp = t.lodMaxClamp,
        this.compare = t.compare,
        this.maxAnisotropy = t.maxAnisotropy ?? 1
    }
    set addressMode(t) {
        this.addressModeU = t,
        this.addressModeV = t,
        this.addressModeW = t
    }
    get addressMode() {
        return this.addressModeU
    }
    set wrapMode(t) {
        V(dt, "TextureStyle.wrapMode is now TextureStyle.addressMode"),
        this.addressMode = t
    }
    get wrapMode() {
        return this.addressMode
    }
    set scaleMode(t) {
        this.magFilter = t,
        this.minFilter = t,
        this.mipmapFilter = t
    }
    get scaleMode() {
        return this.magFilter
    }
    set maxAnisotropy(t) {
        this._maxAnisotropy = Math.min(t, 16),
        this._maxAnisotropy > 1 && (this.scaleMode = "linear")
    }
    get maxAnisotropy() {
        return this._maxAnisotropy
    }
    get _resourceId() {
        return this._sharedResourceId || this._generateResourceId()
    }
    update() {
        this._sharedResourceId = null,
        this.emit("change", this)
    }
    _generateResourceId() {
        const t = `${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;
        return this._sharedResourceId = ja(t),
        this._resourceId
    }
    destroy() {
        this.destroyed = !0,
        this.emit("destroy", this),
        this.emit("change", this),
        this.removeAllListeners()
    }
}
;
en.defaultOptions = {
    addressMode: "clamp-to-edge",
    scaleMode: "linear"
};
let ue = en;
const rn = class nn extends vt {
    constructor(t={}) {
        super(),
        this.options = t,
        this._gpuData = Object.create(null),
        this._gcLastUsed = -1,
        this.uid = q("textureSource"),
        this._resourceType = "textureSource",
        this._resourceId = q("resource"),
        this.uploadMethodId = "unknown",
        this._resolution = 1,
        this.pixelWidth = 1,
        this.pixelHeight = 1,
        this.width = 1,
        this.height = 1,
        this.sampleCount = 1,
        this.mipLevelCount = 1,
        this.autoGenerateMipmaps = !1,
        this.format = "rgba8unorm",
        this.dimension = "2d",
        this.viewDimension = "2d",
        this.arrayLayerCount = 1,
        this.antialias = !1,
        this._touched = 0,
        this._batchTick = -1,
        this._textureBindLocation = -1,
        t = {
            ...nn.defaultOptions,
            ...t
        },
        this.label = t.label ?? "",
        this.resource = t.resource,
        this.autoGarbageCollect = t.autoGarbageCollect,
        this._resolution = t.resolution,
        t.width ? this.pixelWidth = t.width * this._resolution : this.pixelWidth = this.resource ? this.resourceWidth ?? 1 : 1,
        t.height ? this.pixelHeight = t.height * this._resolution : this.pixelHeight = this.resource ? this.resourceHeight ?? 1 : 1,
        this.width = this.pixelWidth / this._resolution,
        this.height = this.pixelHeight / this._resolution,
        this.format = t.format,
        this.dimension = t.dimensions,
        this.viewDimension = t.viewDimension ?? t.dimensions,
        this.arrayLayerCount = t.arrayLayerCount,
        this.mipLevelCount = t.mipLevelCount,
        this.autoGenerateMipmaps = t.autoGenerateMipmaps,
        this.sampleCount = t.sampleCount,
        this.antialias = t.antialias,
        this.alphaMode = t.alphaMode,
        this.style = new ue(tn(t)),
        this.destroyed = !1,
        this._refreshPOT()
    }
    get source() {
        return this
    }
    get style() {
        return this._style
    }
    set style(t) {
        var e, i;
        this.style !== t && ((e = this._style) == null || e.off("change", this._onStyleChange, this),
        this._style = t,
        (i = this._style) == null || i.on("change", this._onStyleChange, this),
        this._onStyleChange())
    }
    set maxAnisotropy(t) {
        this._style.maxAnisotropy = t
    }
    get maxAnisotropy() {
        return this._style.maxAnisotropy
    }
    get addressMode() {
        return this._style.addressMode
    }
    set addressMode(t) {
        this._style.addressMode = t
    }
    get repeatMode() {
        return this._style.addressMode
    }
    set repeatMode(t) {
        this._style.addressMode = t
    }
    get magFilter() {
        return this._style.magFilter
    }
    set magFilter(t) {
        this._style.magFilter = t
    }
    get minFilter() {
        return this._style.minFilter
    }
    set minFilter(t) {
        this._style.minFilter = t
    }
    get mipmapFilter() {
        return this._style.mipmapFilter
    }
    set mipmapFilter(t) {
        this._style.mipmapFilter = t
    }
    get lodMinClamp() {
        return this._style.lodMinClamp
    }
    set lodMinClamp(t) {
        this._style.lodMinClamp = t
    }
    get lodMaxClamp() {
        return this._style.lodMaxClamp
    }
    set lodMaxClamp(t) {
        this._style.lodMaxClamp = t
    }
    _onStyleChange() {
        this.emit("styleChange", this)
    }
    update() {
        if (this.resource) {
            const t = this._resolution;
            if (this.resize(this.resourceWidth / t, this.resourceHeight / t))
                return
        }
        this.emit("update", this)
    }
    destroy() {
        this.destroyed = !0,
        this.unload(),
        this.emit("destroy", this),
        this._style && (this._style.destroy(),
        this._style = null),
        this.uploadMethodId = null,
        this.resource = null,
        this.removeAllListeners()
    }
    unload() {
        var t, e;
        this._resourceId = q("resource"),
        this.emit("change", this),
        this.emit("unload", this);
        for (const i in this._gpuData)
            (e = (t = this._gpuData[i]) == null ? void 0 : t.destroy) == null || e.call(t);
        this._gpuData = Object.create(null)
    }
    get resourceWidth() {
        const {resource: t} = this;
        return t.naturalWidth || t.videoWidth || t.displayWidth || t.width
    }
    get resourceHeight() {
        const {resource: t} = this;
        return t.naturalHeight || t.videoHeight || t.displayHeight || t.height
    }
    get resolution() {
        return this._resolution
    }
    set resolution(t) {
        this._resolution !== t && (this._resolution = t,
        this.width = this.pixelWidth / t,
        this.height = this.pixelHeight / t)
    }
    resize(t, e, i) {
        i || (i = this._resolution),
        t || (t = this.width),
        e || (e = this.height);
        const r = Math.round(t * i)
          , n = Math.round(e * i);
        return this.width = r / i,
        this.height = n / i,
        this._resolution = i,
        this.pixelWidth === r && this.pixelHeight === n ? !1 : (this._refreshPOT(),
        this.pixelWidth = r,
        this.pixelHeight = n,
        this.emit("resize", this),
        this._resourceId = q("resource"),
        this.emit("change", this),
        !0)
    }
    updateMipmaps() {
        this.autoGenerateMipmaps && this.mipLevelCount > 1 && this.emit("updateMipmaps", this)
    }
    set wrapMode(t) {
        this._style.wrapMode = t
    }
    get wrapMode() {
        return this._style.wrapMode
    }
    set scaleMode(t) {
        this._style.scaleMode = t
    }
    get scaleMode() {
        return this._style.scaleMode
    }
    _refreshPOT() {
        this.isPowerOfTwo = Ei(this.pixelWidth) && Ei(this.pixelHeight)
    }
    static test(t) {
        throw new Error("Unimplemented")
    }
}
;
rn.defaultOptions = {
    resolution: 1,
    format: "bgra8unorm",
    alphaMode: "premultiply-alpha-on-upload",
    dimensions: "2d",
    viewDimension: "2d",
    arrayLayerCount: 1,
    mipLevelCount: 1,
    autoGenerateMipmaps: !1,
    sampleCount: 1,
    antialias: !1,
    autoGarbageCollect: !1
};
let xt = rn;
class fi extends xt {
    constructor(t) {
        const e = t.resource || new Float32Array(t.width * t.height * 4);
        let i = t.format;
        i || (e instanceof Float32Array ? i = "rgba32float" : e instanceof Int32Array || e instanceof Uint32Array ? i = "rgba32uint" : e instanceof Int16Array || e instanceof Uint16Array ? i = "rgba16uint" : (e instanceof Int8Array,
        i = "bgra8unorm")),
        super({
            ...t,
            resource: e,
            format: i
        }),
        this.uploadMethodId = "buffer"
    }
    static test(t) {
        return t instanceof Int8Array || t instanceof Uint8Array || t instanceof Uint8ClampedArray || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array
    }
}
fi.extension = I.TextureSource;
const Ri = new D;
class Ya {
    constructor(t, e) {
        this.mapCoord = new D,
        this.uClampFrame = new Float32Array(4),
        this.uClampOffset = new Float32Array(2),
        this._updateID = 0,
        this.clampOffset = 0,
        typeof e > "u" ? this.clampMargin = t.width < 10 ? 0 : .5 : this.clampMargin = e,
        this.isSimple = !1,
        this.texture = t
    }
    get texture() {
        return this._texture
    }
    set texture(t) {
        var e;
        this._texture !== t && ((e = this._texture) == null || e.removeListener("update", this.update, this),
        this._texture = t,
        this._texture.addListener("update", this.update, this)),
        this.update()
    }
    multiplyUvs(t, e) {
        e === void 0 && (e = t);
        const i = this.mapCoord;
        for (let r = 0; r < t.length; r += 2) {
            const n = t[r]
              , a = t[r + 1];
            e[r] = n * i.a + a * i.c + i.tx,
            e[r + 1] = n * i.b + a * i.d + i.ty
        }
        return e
    }
    update() {
        const t = this._texture;
        this._updateID++;
        const e = t.uvs;
        this.mapCoord.set(e.x1 - e.x0, e.y1 - e.y0, e.x3 - e.x0, e.y3 - e.y0, e.x0, e.y0);
        const i = t.orig
          , r = t.trim;
        r && (Ri.set(i.width / r.width, 0, 0, i.height / r.height, -r.x / r.width, -r.y / r.height),
        this.mapCoord.append(Ri));
        const n = t.source
          , a = this.uClampFrame
          , o = this.clampMargin / n._resolution
          , h = this.clampOffset / n._resolution;
        return a[0] = (t.frame.x + o + h) / n.width,
        a[1] = (t.frame.y + o + h) / n.height,
        a[2] = (t.frame.x + t.frame.width - o + h) / n.width,
        a[3] = (t.frame.y + t.frame.height - o + h) / n.height,
        this.uClampOffset[0] = this.clampOffset / n.pixelWidth,
        this.uClampOffset[1] = this.clampOffset / n.pixelHeight,
        this.isSimple = t.frame.width === n.width && t.frame.height === n.height && t.rotate === 0,
        !0
    }
}
class W extends vt {
    constructor({source: t, label: e, frame: i, orig: r, trim: n, defaultAnchor: a, defaultBorders: o, rotate: h, dynamic: l}={}) {
        if (super(),
        this.uid = q("texture"),
        this.uvs = {
            x0: 0,
            y0: 0,
            x1: 0,
            y1: 0,
            x2: 0,
            y2: 0,
            x3: 0,
            y3: 0
        },
        this.frame = new Z,
        this.noFrame = !1,
        this.dynamic = !1,
        this.isTexture = !0,
        this.label = e,
        this.source = (t == null ? void 0 : t.source) ?? new xt,
        this.noFrame = !i,
        i)
            this.frame.copyFrom(i);
        else {
            const {width: c, height: u} = this._source;
            this.frame.width = c,
            this.frame.height = u
        }
        this.orig = r || this.frame,
        this.trim = n,
        this.rotate = h ?? 0,
        this.defaultAnchor = a,
        this.defaultBorders = o,
        this.destroyed = !1,
        this.dynamic = l || !1,
        this.updateUvs()
    }
    set source(t) {
        this._source && this._source.off("resize", this.update, this),
        this._source = t,
        t.on("resize", this.update, this),
        this.emit("update", this)
    }
    get source() {
        return this._source
    }
    get textureMatrix() {
        return this._textureMatrix || (this._textureMatrix = new Ya(this)),
        this._textureMatrix
    }
    get width() {
        return this.orig.width
    }
    get height() {
        return this.orig.height
    }
    updateUvs() {
        const {uvs: t, frame: e} = this
          , {width: i, height: r} = this._source
          , n = e.x / i
          , a = e.y / r
          , o = e.width / i
          , h = e.height / r;
        let l = this.rotate;
        if (l) {
            const c = o / 2
              , u = h / 2
              , d = n + c
              , f = a + u;
            l = U.add(l, U.NW),
            t.x0 = d + c * U.uX(l),
            t.y0 = f + u * U.uY(l),
            l = U.add(l, 2),
            t.x1 = d + c * U.uX(l),
            t.y1 = f + u * U.uY(l),
            l = U.add(l, 2),
            t.x2 = d + c * U.uX(l),
            t.y2 = f + u * U.uY(l),
            l = U.add(l, 2),
            t.x3 = d + c * U.uX(l),
            t.y3 = f + u * U.uY(l)
        } else
            t.x0 = n,
            t.y0 = a,
            t.x1 = n + o,
            t.y1 = a,
            t.x2 = n + o,
            t.y2 = a + h,
            t.x3 = n,
            t.y3 = a + h
    }
    destroy(t=!1) {
        this._source && (this._source.off("resize", this.update, this),
        t && (this._source.destroy(),
        this._source = null)),
        this._textureMatrix = null,
        this.destroyed = !0,
        this.emit("destroy", this),
        this.removeAllListeners()
    }
    update() {
        this.noFrame && (this.frame.width = this._source.width,
        this.frame.height = this._source.height),
        this.updateUvs(),
        this.emit("update", this)
    }
    get baseTexture() {
        return V(dt, "Texture.baseTexture is now Texture.source"),
        this._source
    }
}
W.EMPTY = new W({
    label: "EMPTY",
    source: new xt({
        label: "EMPTY"
    })
});
W.EMPTY.destroy = Jr;
W.WHITE = new W({
    source: new fi({
        resource: new Uint8Array([255, 255, 255, 255]),
        width: 1,
        height: 1,
        alphaMode: "premultiply-alpha-on-upload",
        label: "WHITE"
    }),
    label: "WHITE"
});
W.WHITE.destroy = Jr;
function an(s, t, e) {
    const {width: i, height: r} = e.orig
      , n = e.trim;
    if (n) {
        const a = n.width
          , o = n.height;
        s.minX = n.x - t._x * i,
        s.maxX = s.minX + a,
        s.minY = n.y - t._y * r,
        s.maxY = s.minY + o
    } else
        s.minX = -t._x * i,
        s.maxX = s.minX + i,
        s.minY = -t._y * r,
        s.maxY = s.minY + r
}
const Bi = new D;
class gt {
    constructor(t=1 / 0, e=1 / 0, i=-1 / 0, r=-1 / 0) {
        this.minX = 1 / 0,
        this.minY = 1 / 0,
        this.maxX = -1 / 0,
        this.maxY = -1 / 0,
        this.matrix = Bi,
        this.minX = t,
        this.minY = e,
        this.maxX = i,
        this.maxY = r
    }
    isEmpty() {
        return this.minX > this.maxX || this.minY > this.maxY
    }
    get rectangle() {
        this._rectangle || (this._rectangle = new Z);
        const t = this._rectangle;
        return this.minX > this.maxX || this.minY > this.maxY ? (t.x = 0,
        t.y = 0,
        t.width = 0,
        t.height = 0) : t.copyFromBounds(this),
        t
    }
    clear() {
        return this.minX = 1 / 0,
        this.minY = 1 / 0,
        this.maxX = -1 / 0,
        this.maxY = -1 / 0,
        this.matrix = Bi,
        this
    }
    set(t, e, i, r) {
        this.minX = t,
        this.minY = e,
        this.maxX = i,
        this.maxY = r
    }
    addFrame(t, e, i, r, n) {
        n || (n = this.matrix);
        const a = n.a
          , o = n.b
          , h = n.c
          , l = n.d
          , c = n.tx
          , u = n.ty;
        let d = this.minX
          , f = this.minY
          , p = this.maxX
          , m = this.maxY
          , g = a * t + h * e + c
          , x = o * t + l * e + u;
        g < d && (d = g),
        x < f && (f = x),
        g > p && (p = g),
        x > m && (m = x),
        g = a * i + h * e + c,
        x = o * i + l * e + u,
        g < d && (d = g),
        x < f && (f = x),
        g > p && (p = g),
        x > m && (m = x),
        g = a * t + h * r + c,
        x = o * t + l * r + u,
        g < d && (d = g),
        x < f && (f = x),
        g > p && (p = g),
        x > m && (m = x),
        g = a * i + h * r + c,
        x = o * i + l * r + u,
        g < d && (d = g),
        x < f && (f = x),
        g > p && (p = g),
        x > m && (m = x),
        this.minX = d,
        this.minY = f,
        this.maxX = p,
        this.maxY = m
    }
    addRect(t, e) {
        this.addFrame(t.x, t.y, t.x + t.width, t.y + t.height, e)
    }
    addBounds(t, e) {
        this.addFrame(t.minX, t.minY, t.maxX, t.maxY, e)
    }
    addBoundsMask(t) {
        this.minX = this.minX > t.minX ? this.minX : t.minX,
        this.minY = this.minY > t.minY ? this.minY : t.minY,
        this.maxX = this.maxX < t.maxX ? this.maxX : t.maxX,
        this.maxY = this.maxY < t.maxY ? this.maxY : t.maxY
    }
    applyMatrix(t) {
        const e = this.minX
          , i = this.minY
          , r = this.maxX
          , n = this.maxY
          , {a, b: o, c: h, d: l, tx: c, ty: u} = t;
        let d = a * e + h * i + c
          , f = o * e + l * i + u;
        this.minX = d,
        this.minY = f,
        this.maxX = d,
        this.maxY = f,
        d = a * r + h * i + c,
        f = o * r + l * i + u,
        this.minX = d < this.minX ? d : this.minX,
        this.minY = f < this.minY ? f : this.minY,
        this.maxX = d > this.maxX ? d : this.maxX,
        this.maxY = f > this.maxY ? f : this.maxY,
        d = a * e + h * n + c,
        f = o * e + l * n + u,
        this.minX = d < this.minX ? d : this.minX,
        this.minY = f < this.minY ? f : this.minY,
        this.maxX = d > this.maxX ? d : this.maxX,
        this.maxY = f > this.maxY ? f : this.maxY,
        d = a * r + h * n + c,
        f = o * r + l * n + u,
        this.minX = d < this.minX ? d : this.minX,
        this.minY = f < this.minY ? f : this.minY,
        this.maxX = d > this.maxX ? d : this.maxX,
        this.maxY = f > this.maxY ? f : this.maxY
    }
    fit(t) {
        return this.minX < t.left && (this.minX = t.left),
        this.maxX > t.right && (this.maxX = t.right),
        this.minY < t.top && (this.minY = t.top),
        this.maxY > t.bottom && (this.maxY = t.bottom),
        this
    }
    fitBounds(t, e, i, r) {
        return this.minX < t && (this.minX = t),
        this.maxX > e && (this.maxX = e),
        this.minY < i && (this.minY = i),
        this.maxY > r && (this.maxY = r),
        this
    }
    pad(t, e=t) {
        return this.minX -= t,
        this.maxX += t,
        this.minY -= e,
        this.maxY += e,
        this
    }
    ceil() {
        return this.minX = Math.floor(this.minX),
        this.minY = Math.floor(this.minY),
        this.maxX = Math.ceil(this.maxX),
        this.maxY = Math.ceil(this.maxY),
        this
    }
    clone() {
        return new gt(this.minX,this.minY,this.maxX,this.maxY)
    }
    scale(t, e=t) {
        return this.minX *= t,
        this.minY *= e,
        this.maxX *= t,
        this.maxY *= e,
        this
    }
    get x() {
        return this.minX
    }
    set x(t) {
        const e = this.maxX - this.minX;
        this.minX = t,
        this.maxX = t + e
    }
    get y() {
        return this.minY
    }
    set y(t) {
        const e = this.maxY - this.minY;
        this.minY = t,
        this.maxY = t + e
    }
    get width() {
        return this.maxX - this.minX
    }
    set width(t) {
        this.maxX = this.minX + t
    }
    get height() {
        return this.maxY - this.minY
    }
    set height(t) {
        this.maxY = this.minY + t
    }
    get left() {
        return this.minX
    }
    get right() {
        return this.maxX
    }
    get top() {
        return this.minY
    }
    get bottom() {
        return this.maxY
    }
    get isPositive() {
        return this.maxX - this.minX > 0 && this.maxY - this.minY > 0
    }
    get isValid() {
        return this.minX + this.minY !== 1 / 0
    }
    addVertexData(t, e, i, r) {
        let n = this.minX
          , a = this.minY
          , o = this.maxX
          , h = this.maxY;
        r || (r = this.matrix);
        const l = r.a
          , c = r.b
          , u = r.c
          , d = r.d
          , f = r.tx
          , p = r.ty;
        for (let m = e; m < i; m += 2) {
            const g = t[m]
              , x = t[m + 1]
              , y = l * g + u * x + f
              , _ = c * g + d * x + p;
            n = y < n ? y : n,
            a = _ < a ? _ : a,
            o = y > o ? y : o,
            h = _ > h ? _ : h
        }
        this.minX = n,
        this.minY = a,
        this.maxX = o,
        this.maxY = h
    }
    containsPoint(t, e) {
        return this.minX <= t && this.minY <= e && this.maxX >= t && this.maxY >= e
    }
    toString() {
        return `[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`
    }
    copyFrom(t) {
        return this.minX = t.minX,
        this.minY = t.minY,
        this.maxX = t.maxX,
        this.maxY = t.maxY,
        this
    }
}
var Xa = {
    grad: .9,
    turn: 360,
    rad: 360 / (2 * Math.PI)
}
  , Tt = function(s) {
    return typeof s == "string" ? s.length > 0 : typeof s == "number"
}
  , et = function(s, t, e) {
    return t === void 0 && (t = 0),
    e === void 0 && (e = Math.pow(10, t)),
    Math.round(e * s) / e + 0
}
  , ft = function(s, t, e) {
    return t === void 0 && (t = 0),
    e === void 0 && (e = 1),
    s > e ? e : s > t ? s : t
}
  , on = function(s) {
    return (s = isFinite(s) ? s % 360 : 0) > 0 ? s : s + 360
}
  , Fi = function(s) {
    return {
        r: ft(s.r, 0, 255),
        g: ft(s.g, 0, 255),
        b: ft(s.b, 0, 255),
        a: ft(s.a)
    }
}
  , vs = function(s) {
    return {
        r: et(s.r),
        g: et(s.g),
        b: et(s.b),
        a: et(s.a, 3)
    }
}
  , qa = /^#([0-9a-f]{3,8})$/i
  , je = function(s) {
    var t = s.toString(16);
    return t.length < 2 ? "0" + t : t
}
  , hn = function(s) {
    var t = s.r
      , e = s.g
      , i = s.b
      , r = s.a
      , n = Math.max(t, e, i)
      , a = n - Math.min(t, e, i)
      , o = a ? n === t ? (e - i) / a : n === e ? 2 + (i - t) / a : 4 + (t - e) / a : 0;
    return {
        h: 60 * (o < 0 ? o + 6 : o),
        s: n ? a / n * 100 : 0,
        v: n / 255 * 100,
        a: r
    }
}
  , ln = function(s) {
    var t = s.h
      , e = s.s
      , i = s.v
      , r = s.a;
    t = t / 360 * 6,
    e /= 100,
    i /= 100;
    var n = Math.floor(t)
      , a = i * (1 - e)
      , o = i * (1 - (t - n) * e)
      , h = i * (1 - (1 - t + n) * e)
      , l = n % 6;
    return {
        r: 255 * [i, o, a, a, h, i][l],
        g: 255 * [h, i, i, o, a, a][l],
        b: 255 * [a, a, h, i, i, o][l],
        a: r
    }
}
  , Li = function(s) {
    return {
        h: on(s.h),
        s: ft(s.s, 0, 100),
        l: ft(s.l, 0, 100),
        a: ft(s.a)
    }
}
  , Gi = function(s) {
    return {
        h: et(s.h),
        s: et(s.s),
        l: et(s.l),
        a: et(s.a, 3)
    }
}
  , Di = function(s) {
    return ln((e = (t = s).s,
    {
        h: t.h,
        s: (e *= ((i = t.l) < 50 ? i : 100 - i) / 100) > 0 ? 2 * e / (i + e) * 100 : 0,
        v: i + e,
        a: t.a
    }));
    var t, e, i
}
  , Ee = function(s) {
    return {
        h: (t = hn(s)).h,
        s: (r = (200 - (e = t.s)) * (i = t.v) / 100) > 0 && r < 200 ? e * i / 100 / (r <= 100 ? r : 200 - r) * 100 : 0,
        l: r / 2,
        a: t.a
    };
    var t, e, i, r
}
  , Ka = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i
  , Za = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i
  , Qa = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i
  , Ja = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i
  , Xs = {
    string: [[function(s) {
        var t = qa.exec(s);
        return t ? (s = t[1]).length <= 4 ? {
            r: parseInt(s[0] + s[0], 16),
            g: parseInt(s[1] + s[1], 16),
            b: parseInt(s[2] + s[2], 16),
            a: s.length === 4 ? et(parseInt(s[3] + s[3], 16) / 255, 2) : 1
        } : s.length === 6 || s.length === 8 ? {
            r: parseInt(s.substr(0, 2), 16),
            g: parseInt(s.substr(2, 2), 16),
            b: parseInt(s.substr(4, 2), 16),
            a: s.length === 8 ? et(parseInt(s.substr(6, 2), 16) / 255, 2) : 1
        } : null : null
    }
    , "hex"], [function(s) {
        var t = Qa.exec(s) || Ja.exec(s);
        return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Fi({
            r: Number(t[1]) / (t[2] ? 100 / 255 : 1),
            g: Number(t[3]) / (t[4] ? 100 / 255 : 1),
            b: Number(t[5]) / (t[6] ? 100 / 255 : 1),
            a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1)
        }) : null
    }
    , "rgb"], [function(s) {
        var t = Ka.exec(s) || Za.exec(s);
        if (!t)
            return null;
        var e, i, r = Li({
            h: (e = t[1],
            i = t[2],
            i === void 0 && (i = "deg"),
            Number(e) * (Xa[i] || 1)),
            s: Number(t[3]),
            l: Number(t[4]),
            a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1)
        });
        return Di(r)
    }
    , "hsl"]],
    object: [[function(s) {
        var t = s.r
          , e = s.g
          , i = s.b
          , r = s.a
          , n = r === void 0 ? 1 : r;
        return Tt(t) && Tt(e) && Tt(i) ? Fi({
            r: Number(t),
            g: Number(e),
            b: Number(i),
            a: Number(n)
        }) : null
    }
    , "rgb"], [function(s) {
        var t = s.h
          , e = s.s
          , i = s.l
          , r = s.a
          , n = r === void 0 ? 1 : r;
        if (!Tt(t) || !Tt(e) || !Tt(i))
            return null;
        var a = Li({
            h: Number(t),
            s: Number(e),
            l: Number(i),
            a: Number(n)
        });
        return Di(a)
    }
    , "hsl"], [function(s) {
        var t = s.h
          , e = s.s
          , i = s.v
          , r = s.a
          , n = r === void 0 ? 1 : r;
        if (!Tt(t) || !Tt(e) || !Tt(i))
            return null;
        var a = (function(o) {
            return {
                h: on(o.h),
                s: ft(o.s, 0, 100),
                v: ft(o.v, 0, 100),
                a: ft(o.a)
            }
        }
        )({
            h: Number(t),
            s: Number(e),
            v: Number(i),
            a: Number(n)
        });
        return ln(a)
    }
    , "hsv"]]
}
  , zi = function(s, t) {
    for (var e = 0; e < t.length; e++) {
        var i = t[e][0](s);
        if (i)
            return [i, t[e][1]]
    }
    return [null, void 0]
}
  , to = function(s) {
    return typeof s == "string" ? zi(s.trim(), Xs.string) : typeof s == "object" && s !== null ? zi(s, Xs.object) : [null, void 0]
}
  , Ss = function(s, t) {
    var e = Ee(s);
    return {
        h: e.h,
        s: ft(e.s + 100 * t, 0, 100),
        l: e.l,
        a: e.a
    }
}
  , Ts = function(s) {
    return (299 * s.r + 587 * s.g + 114 * s.b) / 1e3 / 255
}
  , Wi = function(s, t) {
    var e = Ee(s);
    return {
        h: e.h,
        s: e.s,
        l: ft(e.l + 100 * t, 0, 100),
        a: e.a
    }
}
  , qs = (function() {
    function s(t) {
        this.parsed = to(t)[0],
        this.rgba = this.parsed || {
            r: 0,
            g: 0,
            b: 0,
            a: 1
        }
    }
    return s.prototype.isValid = function() {
        return this.parsed !== null
    }
    ,
    s.prototype.brightness = function() {
        return et(Ts(this.rgba), 2)
    }
    ,
    s.prototype.isDark = function() {
        return Ts(this.rgba) < .5
    }
    ,
    s.prototype.isLight = function() {
        return Ts(this.rgba) >= .5
    }
    ,
    s.prototype.toHex = function() {
        return t = vs(this.rgba),
        e = t.r,
        i = t.g,
        r = t.b,
        a = (n = t.a) < 1 ? je(et(255 * n)) : "",
        "#" + je(e) + je(i) + je(r) + a;
        var t, e, i, r, n, a
    }
    ,
    s.prototype.toRgb = function() {
        return vs(this.rgba)
    }
    ,
    s.prototype.toRgbString = function() {
        return t = vs(this.rgba),
        e = t.r,
        i = t.g,
        r = t.b,
        (n = t.a) < 1 ? "rgba(" + e + ", " + i + ", " + r + ", " + n + ")" : "rgb(" + e + ", " + i + ", " + r + ")";
        var t, e, i, r, n
    }
    ,
    s.prototype.toHsl = function() {
        return Gi(Ee(this.rgba))
    }
    ,
    s.prototype.toHslString = function() {
        return t = Gi(Ee(this.rgba)),
        e = t.h,
        i = t.s,
        r = t.l,
        (n = t.a) < 1 ? "hsla(" + e + ", " + i + "%, " + r + "%, " + n + ")" : "hsl(" + e + ", " + i + "%, " + r + "%)";
        var t, e, i, r, n
    }
    ,
    s.prototype.toHsv = function() {
        return t = hn(this.rgba),
        {
            h: et(t.h),
            s: et(t.s),
            v: et(t.v),
            a: et(t.a, 3)
        };
        var t
    }
    ,
    s.prototype.invert = function() {
        return wt({
            r: 255 - (t = this.rgba).r,
            g: 255 - t.g,
            b: 255 - t.b,
            a: t.a
        });
        var t
    }
    ,
    s.prototype.saturate = function(t) {
        return t === void 0 && (t = .1),
        wt(Ss(this.rgba, t))
    }
    ,
    s.prototype.desaturate = function(t) {
        return t === void 0 && (t = .1),
        wt(Ss(this.rgba, -t))
    }
    ,
    s.prototype.grayscale = function() {
        return wt(Ss(this.rgba, -1))
    }
    ,
    s.prototype.lighten = function(t) {
        return t === void 0 && (t = .1),
        wt(Wi(this.rgba, t))
    }
    ,
    s.prototype.darken = function(t) {
        return t === void 0 && (t = .1),
        wt(Wi(this.rgba, -t))
    }
    ,
    s.prototype.rotate = function(t) {
        return t === void 0 && (t = 15),
        this.hue(this.hue() + t)
    }
    ,
    s.prototype.alpha = function(t) {
        return typeof t == "number" ? wt({
            r: (e = this.rgba).r,
            g: e.g,
            b: e.b,
            a: t
        }) : et(this.rgba.a, 3);
        var e
    }
    ,
    s.prototype.hue = function(t) {
        var e = Ee(this.rgba);
        return typeof t == "number" ? wt({
            h: t,
            s: e.s,
            l: e.l,
            a: e.a
        }) : et(e.h)
    }
    ,
    s.prototype.isEqual = function(t) {
        return this.toHex() === wt(t).toHex()
    }
    ,
    s
}
)()
  , wt = function(s) {
    return s instanceof qs ? s : new qs(s)
}
  , Oi = []
  , eo = function(s) {
    s.forEach(function(t) {
        Oi.indexOf(t) < 0 && (t(qs, Xs),
        Oi.push(t))
    })
};
function so(s, t) {
    var e = {
        white: "#ffffff",
        bisque: "#ffe4c4",
        blue: "#0000ff",
        cadetblue: "#5f9ea0",
        chartreuse: "#7fff00",
        chocolate: "#d2691e",
        coral: "#ff7f50",
        antiquewhite: "#faebd7",
        aqua: "#00ffff",
        azure: "#f0ffff",
        whitesmoke: "#f5f5f5",
        papayawhip: "#ffefd5",
        plum: "#dda0dd",
        blanchedalmond: "#ffebcd",
        black: "#000000",
        gold: "#ffd700",
        goldenrod: "#daa520",
        gainsboro: "#dcdcdc",
        cornsilk: "#fff8dc",
        cornflowerblue: "#6495ed",
        burlywood: "#deb887",
        aquamarine: "#7fffd4",
        beige: "#f5f5dc",
        crimson: "#dc143c",
        cyan: "#00ffff",
        darkblue: "#00008b",
        darkcyan: "#008b8b",
        darkgoldenrod: "#b8860b",
        darkkhaki: "#bdb76b",
        darkgray: "#a9a9a9",
        darkgreen: "#006400",
        darkgrey: "#a9a9a9",
        peachpuff: "#ffdab9",
        darkmagenta: "#8b008b",
        darkred: "#8b0000",
        darkorchid: "#9932cc",
        darkorange: "#ff8c00",
        darkslateblue: "#483d8b",
        gray: "#808080",
        darkslategray: "#2f4f4f",
        darkslategrey: "#2f4f4f",
        deeppink: "#ff1493",
        deepskyblue: "#00bfff",
        wheat: "#f5deb3",
        firebrick: "#b22222",
        floralwhite: "#fffaf0",
        ghostwhite: "#f8f8ff",
        darkviolet: "#9400d3",
        magenta: "#ff00ff",
        green: "#008000",
        dodgerblue: "#1e90ff",
        grey: "#808080",
        honeydew: "#f0fff0",
        hotpink: "#ff69b4",
        blueviolet: "#8a2be2",
        forestgreen: "#228b22",
        lawngreen: "#7cfc00",
        indianred: "#cd5c5c",
        indigo: "#4b0082",
        fuchsia: "#ff00ff",
        brown: "#a52a2a",
        maroon: "#800000",
        mediumblue: "#0000cd",
        lightcoral: "#f08080",
        darkturquoise: "#00ced1",
        lightcyan: "#e0ffff",
        ivory: "#fffff0",
        lightyellow: "#ffffe0",
        lightsalmon: "#ffa07a",
        lightseagreen: "#20b2aa",
        linen: "#faf0e6",
        mediumaquamarine: "#66cdaa",
        lemonchiffon: "#fffacd",
        lime: "#00ff00",
        khaki: "#f0e68c",
        mediumseagreen: "#3cb371",
        limegreen: "#32cd32",
        mediumspringgreen: "#00fa9a",
        lightskyblue: "#87cefa",
        lightblue: "#add8e6",
        midnightblue: "#191970",
        lightpink: "#ffb6c1",
        mistyrose: "#ffe4e1",
        moccasin: "#ffe4b5",
        mintcream: "#f5fffa",
        lightslategray: "#778899",
        lightslategrey: "#778899",
        navajowhite: "#ffdead",
        navy: "#000080",
        mediumvioletred: "#c71585",
        powderblue: "#b0e0e6",
        palegoldenrod: "#eee8aa",
        oldlace: "#fdf5e6",
        paleturquoise: "#afeeee",
        mediumturquoise: "#48d1cc",
        mediumorchid: "#ba55d3",
        rebeccapurple: "#663399",
        lightsteelblue: "#b0c4de",
        mediumslateblue: "#7b68ee",
        thistle: "#d8bfd8",
        tan: "#d2b48c",
        orchid: "#da70d6",
        mediumpurple: "#9370db",
        purple: "#800080",
        pink: "#ffc0cb",
        skyblue: "#87ceeb",
        springgreen: "#00ff7f",
        palegreen: "#98fb98",
        red: "#ff0000",
        yellow: "#ffff00",
        slateblue: "#6a5acd",
        lavenderblush: "#fff0f5",
        peru: "#cd853f",
        palevioletred: "#db7093",
        violet: "#ee82ee",
        teal: "#008080",
        slategray: "#708090",
        slategrey: "#708090",
        aliceblue: "#f0f8ff",
        darkseagreen: "#8fbc8f",
        darkolivegreen: "#556b2f",
        greenyellow: "#adff2f",
        seagreen: "#2e8b57",
        seashell: "#fff5ee",
        tomato: "#ff6347",
        silver: "#c0c0c0",
        sienna: "#a0522d",
        lavender: "#e6e6fa",
        lightgreen: "#90ee90",
        orange: "#ffa500",
        orangered: "#ff4500",
        steelblue: "#4682b4",
        royalblue: "#4169e1",
        turquoise: "#40e0d0",
        yellowgreen: "#9acd32",
        salmon: "#fa8072",
        saddlebrown: "#8b4513",
        sandybrown: "#f4a460",
        rosybrown: "#bc8f8f",
        darksalmon: "#e9967a",
        lightgoldenrodyellow: "#fafad2",
        snow: "#fffafa",
        lightgrey: "#d3d3d3",
        lightgray: "#d3d3d3",
        dimgray: "#696969",
        dimgrey: "#696969",
        olivedrab: "#6b8e23",
        olive: "#808000"
    }
      , i = {};
    for (var r in e)
        i[e[r]] = r;
    var n = {};
    s.prototype.toName = function(a) {
        if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b))
            return "transparent";
        var o, h, l = i[this.toHex()];
        if (l)
            return l;
        if (a != null && a.closest) {
            var c = this.toRgb()
              , u = 1 / 0
              , d = "black";
            if (!n.length)
                for (var f in e)
                    n[f] = new s(e[f]).toRgb();
            for (var p in e) {
                var m = (o = c,
                h = n[p],
                Math.pow(o.r - h.r, 2) + Math.pow(o.g - h.g, 2) + Math.pow(o.b - h.b, 2));
                m < u && (u = m,
                d = p)
            }
            return d
        }
    }
    ,
    t.string.push([function(a) {
        var o = a.toLowerCase()
          , h = o === "transparent" ? "#0000" : e[o];
        return h ? new s(h).toRgb() : null
    }
    , "name"])
}
eo([so]);
const de = class Pe {
    constructor(t=16777215) {
        this._value = null,
        this._components = new Float32Array(4),
        this._components.fill(1),
        this._int = 16777215,
        this.value = t
    }
    get red() {
        return this._components[0]
    }
    get green() {
        return this._components[1]
    }
    get blue() {
        return this._components[2]
    }
    get alpha() {
        return this._components[3]
    }
    setValue(t) {
        return this.value = t,
        this
    }
    set value(t) {
        if (t instanceof Pe)
            this._value = this._cloneSource(t._value),
            this._int = t._int,
            this._components.set(t._components);
        else {
            if (t === null)
                throw new Error("Cannot set Color#value to null");
            (this._value === null || !this._isSourceEqual(this._value, t)) && (this._value = this._cloneSource(t),
            this._normalize(this._value))
        }
    }
    get value() {
        return this._value
    }
    _cloneSource(t) {
        return typeof t == "string" || typeof t == "number" || t instanceof Number || t === null ? t : Array.isArray(t) || ArrayBuffer.isView(t) ? t.slice(0) : typeof t == "object" && t !== null ? {
            ...t
        } : t
    }
    _isSourceEqual(t, e) {
        const i = typeof t;
        if (i !== typeof e)
            return !1;
        if (i === "number" || i === "string" || t instanceof Number)
            return t === e;
        if (Array.isArray(t) && Array.isArray(e) || ArrayBuffer.isView(t) && ArrayBuffer.isView(e))
            return t.length !== e.length ? !1 : t.every( (n, a) => n === e[a]);
        if (t !== null && e !== null) {
            const n = Object.keys(t)
              , a = Object.keys(e);
            return n.length !== a.length ? !1 : n.every(o => t[o] === e[o])
        }
        return t === e
    }
    toRgba() {
        const [t,e,i,r] = this._components;
        return {
            r: t,
            g: e,
            b: i,
            a: r
        }
    }
    toRgb() {
        const [t,e,i] = this._components;
        return {
            r: t,
            g: e,
            b: i
        }
    }
    toRgbaString() {
        const [t,e,i] = this.toUint8RgbArray();
        return `rgba(${t},${e},${i},${this.alpha})`
    }
    toUint8RgbArray(t) {
        const [e,i,r] = this._components;
        return this._arrayRgb || (this._arrayRgb = []),
        t || (t = this._arrayRgb),
        t[0] = Math.round(e * 255),
        t[1] = Math.round(i * 255),
        t[2] = Math.round(r * 255),
        t
    }
    toArray(t) {
        this._arrayRgba || (this._arrayRgba = []),
        t || (t = this._arrayRgba);
        const [e,i,r,n] = this._components;
        return t[0] = e,
        t[1] = i,
        t[2] = r,
        t[3] = n,
        t
    }
    toRgbArray(t) {
        this._arrayRgb || (this._arrayRgb = []),
        t || (t = this._arrayRgb);
        const [e,i,r] = this._components;
        return t[0] = e,
        t[1] = i,
        t[2] = r,
        t
    }
    toNumber() {
        return this._int
    }
    toBgrNumber() {
        const [t,e,i] = this.toUint8RgbArray();
        return (i << 16) + (e << 8) + t
    }
    toLittleEndianNumber() {
        const t = this._int;
        return (t >> 16) + (t & 65280) + ((t & 255) << 16)
    }
    multiply(t) {
        const [e,i,r,n] = Pe._temp.setValue(t)._components;
        return this._components[0] *= e,
        this._components[1] *= i,
        this._components[2] *= r,
        this._components[3] *= n,
        this._refreshInt(),
        this._value = null,
        this
    }
    premultiply(t, e=!0) {
        return e && (this._components[0] *= t,
        this._components[1] *= t,
        this._components[2] *= t),
        this._components[3] = t,
        this._refreshInt(),
        this._value = null,
        this
    }
    toPremultiplied(t, e=!0) {
        if (t === 1)
            return (255 << 24) + this._int;
        if (t === 0)
            return e ? 0 : this._int;
        let i = this._int >> 16 & 255
          , r = this._int >> 8 & 255
          , n = this._int & 255;
        return e && (i = i * t + .5 | 0,
        r = r * t + .5 | 0,
        n = n * t + .5 | 0),
        (t * 255 << 24) + (i << 16) + (r << 8) + n
    }
    toHex() {
        const t = this._int.toString(16);
        return `#${"000000".substring(0, 6 - t.length) + t}`
    }
    toHexa() {
        const e = Math.round(this._components[3] * 255).toString(16);
        return this.toHex() + "00".substring(0, 2 - e.length) + e
    }
    setAlpha(t) {
        return this._components[3] = this._clamp(t),
        this._value = null,
        this
    }
    _normalize(t) {
        let e, i, r, n;
        if ((typeof t == "number" || t instanceof Number) && t >= 0 && t <= 16777215) {
            const a = t;
            e = (a >> 16 & 255) / 255,
            i = (a >> 8 & 255) / 255,
            r = (a & 255) / 255,
            n = 1
        } else if ((Array.isArray(t) || t instanceof Float32Array) && t.length >= 3 && t.length <= 4)
            t = this._clamp(t),
            [e,i,r,n=1] = t;
        else if ((t instanceof Uint8Array || t instanceof Uint8ClampedArray) && t.length >= 3 && t.length <= 4)
            t = this._clamp(t, 0, 255),
            [e,i,r,n=255] = t,
            e /= 255,
            i /= 255,
            r /= 255,
            n /= 255;
        else if (typeof t == "string" || typeof t == "object") {
            if (typeof t == "string") {
                const o = Pe.HEX_PATTERN.exec(t);
                o && (t = `#${o[2]}`)
            }
            const a = wt(t);
            a.isValid() && ({r: e, g: i, b: r, a: n} = a.rgba,
            e /= 255,
            i /= 255,
            r /= 255)
        }
        if (e !== void 0)
            this._components[0] = e,
            this._components[1] = i,
            this._components[2] = r,
            this._components[3] = n,
            this._refreshInt();
        else
            throw new Error(`Unable to convert color ${t}`)
    }
    _refreshInt() {
        this._clamp(this._components);
        const [t,e,i] = this._components;
        this._int = (t * 255 << 16) + (e * 255 << 8) + (i * 255 | 0)
    }
    _clamp(t, e=0, i=1) {
        return typeof t == "number" ? Math.min(Math.max(t, e), i) : (t.forEach( (r, n) => {
            t[n] = Math.min(Math.max(r, e), i)
        }
        ),
        t)
    }
    static isColorLike(t) {
        return typeof t == "number" || typeof t == "string" || t instanceof Number || t instanceof Pe || Array.isArray(t) || t instanceof Uint8Array || t instanceof Uint8ClampedArray || t instanceof Float32Array || t.r !== void 0 && t.g !== void 0 && t.b !== void 0 || t.r !== void 0 && t.g !== void 0 && t.b !== void 0 && t.a !== void 0 || t.h !== void 0 && t.s !== void 0 && t.l !== void 0 || t.h !== void 0 && t.s !== void 0 && t.l !== void 0 && t.a !== void 0 || t.h !== void 0 && t.s !== void 0 && t.v !== void 0 || t.h !== void 0 && t.s !== void 0 && t.v !== void 0 && t.a !== void 0
    }
}
;
de.shared = new de;
de._temp = new de;
de.HEX_PATTERN = /^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;
let J = de;
const io = {
    cullArea: null,
    cullable: !1,
    cullableChildren: !0
};
let Cs = 0;
const Ui = 500;
function $(...s) {
    Cs !== Ui && Cs++
}
const Ue = {
    _registeredResources: new Set,
    register(s) {
        this._registeredResources.add(s)
    },
    unregister(s) {
        this._registeredResources.delete(s)
    },
    release() {
        this._registeredResources.forEach(s => s.clear())
    },
    get registeredCount() {
        return this._registeredResources.size
    },
    isRegistered(s) {
        return this._registeredResources.has(s)
    },
    reset() {
        this._registeredResources.clear()
    }
};
class ro {
    constructor(t, e) {
        this._pool = [],
        this._count = 0,
        this._index = 0,
        this._classType = t,
        e && this.prepopulate(e)
    }
    prepopulate(t) {
        for (let e = 0; e < t; e++)
            this._pool[this._index++] = new this._classType;
        this._count += t
    }
    get(t) {
        var i;
        let e;
        return this._index > 0 ? e = this._pool[--this._index] : (e = new this._classType,
        this._count++),
        (i = e.init) == null || i.call(e, t),
        e
    }
    return(t) {
        var e;
        (e = t.reset) == null || e.call(t),
        this._pool[this._index++] = t
    }
    get totalSize() {
        return this._count
    }
    get totalFree() {
        return this._index
    }
    get totalUsed() {
        return this._count - this._index
    }
    clear() {
        if (this._pool.length > 0 && this._pool[0].destroy)
            for (let t = 0; t < this._index; t++)
                this._pool[t].destroy();
        this._pool.length = 0,
        this._count = 0,
        this._index = 0
    }
}
class no {
    constructor() {
        this._poolsByClass = new Map
    }
    prepopulate(t, e) {
        this.getPool(t).prepopulate(e)
    }
    get(t, e) {
        return this.getPool(t).get(e)
    }
    return(t) {
        this.getPool(t.constructor).return(t)
    }
    getPool(t) {
        return this._poolsByClass.has(t) || this._poolsByClass.set(t, new ro(t)),
        this._poolsByClass.get(t)
    }
    stats() {
        const t = {};
        return this._poolsByClass.forEach(e => {
            const i = t[e._classType.name] ? e._classType.name + e._classType.ID : e._classType.name;
            t[i] = {
                free: e.totalFree,
                used: e.totalUsed,
                size: e.totalSize
            }
        }
        ),
        t
    }
    clear() {
        this._poolsByClass.forEach(t => t.clear()),
        this._poolsByClass.clear()
    }
}
const mt = new no;
Ue.register(mt);
const ao = {
    get isCachedAsTexture() {
        var s;
        return !!((s = this.renderGroup) != null && s.isCachedAsTexture)
    },
    cacheAsTexture(s) {
        typeof s == "boolean" && s === !1 ? this.disableRenderGroup() : (this.enableRenderGroup(),
        this.renderGroup.enableCacheAsTexture(s === !0 ? {} : s))
    },
    updateCacheTexture() {
        var s;
        (s = this.renderGroup) == null || s.updateCacheTexture()
    },
    get cacheAsBitmap() {
        return this.isCachedAsTexture
    },
    set cacheAsBitmap(s) {
        V("v8.6.0", "cacheAsBitmap is deprecated, use cacheAsTexture instead."),
        this.cacheAsTexture(s)
    }
};
function oo(s, t, e) {
    const i = s.length;
    let r;
    if (t >= i || e === 0)
        return;
    e = t + e > i ? i - t : e;
    const n = i - e;
    for (r = t; r < n; ++r)
        s[r] = s[r + e];
    s.length = n
}
const ho = {
    allowChildren: !0,
    removeChildren(s=0, t) {
        var n;
        const e = t ?? this.children.length
          , i = e - s
          , r = [];
        if (i > 0 && i <= e) {
            for (let o = e - 1; o >= s; o--) {
                const h = this.children[o];
                h && (r.push(h),
                h.parent = null)
            }
            oo(this.children, s, e);
            const a = this.renderGroup || this.parentRenderGroup;
            a && a.removeChildren(r);
            for (let o = 0; o < r.length; ++o) {
                const h = r[o];
                (n = h.parentRenderLayer) == null || n.detach(h),
                this.emit("childRemoved", h, this, o),
                r[o].emit("removed", this)
            }
            return r.length > 0 && this._didViewChangeTick++,
            r
        } else if (i === 0 && this.children.length === 0)
            return r;
        throw new RangeError("removeChildren: numeric values are outside the acceptable range.")
    },
    removeChildAt(s) {
        const t = this.getChildAt(s);
        return this.removeChild(t)
    },
    getChildAt(s) {
        if (s < 0 || s >= this.children.length)
            throw new Error(`getChildAt: Index (${s}) does not exist.`);
        return this.children[s]
    },
    setChildIndex(s, t) {
        if (t < 0 || t >= this.children.length)
            throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);
        this.getChildIndex(s),
        this.addChildAt(s, t)
    },
    getChildIndex(s) {
        const t = this.children.indexOf(s);
        if (t === -1)
            throw new Error("The supplied Container must be a child of the caller");
        return t
    },
    addChildAt(s, t) {
        this.allowChildren || V(dt, "addChildAt: Only Containers will be allowed to add children in v8.0.0");
        const {children: e} = this;
        if (t < 0 || t > e.length)
            throw new Error(`${s}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);
        const i = s.parent === this;
        if (s.parent) {
            const n = s.parent.children.indexOf(s);
            if (i) {
                if (n === t)
                    return s;
                s.parent.children.splice(n, 1)
            } else
                s.removeFromParent()
        }
        t === e.length ? e.push(s) : e.splice(t, 0, s),
        s.parent = this,
        s.didChange = !0,
        s._updateFlags = 15;
        const r = this.renderGroup || this.parentRenderGroup;
        return r && r.addChild(s),
        this.sortableChildren && (this.sortDirty = !0),
        i || (this.emit("childAdded", s, this, t),
        s.emit("added", this)),
        s
    },
    swapChildren(s, t) {
        if (s === t)
            return;
        const e = this.getChildIndex(s)
          , i = this.getChildIndex(t);
        this.children[e] = t,
        this.children[i] = s;
        const r = this.renderGroup || this.parentRenderGroup;
        r && (r.structureDidChange = !0),
        this._didContainerChangeTick++
    },
    removeFromParent() {
        var s;
        (s = this.parent) == null || s.removeChild(this)
    },
    reparentChild(...s) {
        return s.length === 1 ? this.reparentChildAt(s[0], this.children.length) : (s.forEach(t => this.reparentChildAt(t, this.children.length)),
        s[0])
    },
    reparentChildAt(s, t) {
        if (s.parent === this)
            return this.setChildIndex(s, t),
            s;
        const e = s.worldTransform.clone();
        s.removeFromParent(),
        this.addChildAt(s, t);
        const i = this.worldTransform.clone();
        return i.invert(),
        e.prepend(i),
        s.setFromMatrix(e),
        s
    },
    replaceChild(s, t) {
        s.updateLocalTransform(),
        this.addChildAt(t, this.getChildIndex(s)),
        t.setFromMatrix(s.localTransform),
        t.updateLocalTransform(),
        this.removeChild(s)
    }
}
  , lo = {
    collectRenderables(s, t, e) {
        this.parentRenderLayer && this.parentRenderLayer !== e || this.globalDisplayStatus < 7 || !this.includeInBuild || (this.sortableChildren && this.sortChildren(),
        this.isSimple ? this.collectRenderablesSimple(s, t, e) : this.renderGroup ? t.renderPipes.renderGroup.addRenderGroup(this.renderGroup, s) : this.collectRenderablesWithEffects(s, t, e))
    },
    collectRenderablesSimple(s, t, e) {
        const i = this.children
          , r = i.length;
        for (let n = 0; n < r; n++)
            i[n].collectRenderables(s, t, e)
    },
    collectRenderablesWithEffects(s, t, e) {
        const {renderPipes: i} = t;
        for (let r = 0; r < this.effects.length; r++) {
            const n = this.effects[r];
            i[n.pipe].push(n, this, s)
        }
        this.collectRenderablesSimple(s, t, e);
        for (let r = this.effects.length - 1; r >= 0; r--) {
            const n = this.effects[r];
            i[n.pipe].pop(n, this, s)
        }
    }
};
class Ni {
    constructor() {
        this.pipe = "filter",
        this.priority = 1
    }
    destroy() {
        for (let t = 0; t < this.filters.length; t++)
            this.filters[t].destroy();
        this.filters = null,
        this.filterArea = null
    }
}
class co {
    constructor() {
        this._effectClasses = [],
        this._tests = [],
        this._initialized = !1
    }
    init() {
        this._initialized || (this._initialized = !0,
        this._effectClasses.forEach(t => {
            this.add({
                test: t.test,
                maskClass: t
            })
        }
        ))
    }
    add(t) {
        this._tests.push(t)
    }
    getMaskEffect(t) {
        this._initialized || this.init();
        for (let e = 0; e < this._tests.length; e++) {
            const i = this._tests[e];
            if (i.test(t))
                return mt.get(i.maskClass, t)
        }
        return t
    }
    returnMaskEffect(t) {
        mt.return(t)
    }
}
const Ks = new co;
Y.handleByList(I.MaskEffect, Ks._effectClasses);
const uo = {
    _maskEffect: null,
    _maskOptions: {
        inverse: !1,
        channel: "red"
    },
    _filterEffect: null,
    effects: [],
    _markStructureAsChanged() {
        const s = this.renderGroup || this.parentRenderGroup;
        s && (s.structureDidChange = !0)
    },
    addEffect(s) {
        this.effects.indexOf(s) === -1 && (this.effects.push(s),
        this.effects.sort( (e, i) => e.priority - i.priority),
        this._markStructureAsChanged(),
        this._updateIsSimple())
    },
    removeEffect(s) {
        const t = this.effects.indexOf(s);
        t !== -1 && (this.effects.splice(t, 1),
        this._markStructureAsChanged(),
        this._updateIsSimple())
    },
    set mask(s) {
        const t = this._maskEffect;
        (t == null ? void 0 : t.mask) !== s && (t && (this.removeEffect(t),
        Ks.returnMaskEffect(t),
        this._maskEffect = null),
        s != null && (this._maskEffect = Ks.getMaskEffect(s),
        this.addEffect(this._maskEffect)))
    },
    get mask() {
        var s;
        return (s = this._maskEffect) == null ? void 0 : s.mask
    },
    setMask(s) {
        this._maskOptions = {
            ...this._maskOptions,
            ...s
        },
        s.mask && (this.mask = s.mask),
        this._markStructureAsChanged()
    },
    set filters(s) {
        var n;
        !Array.isArray(s) && s && (s = [s]);
        const t = this._filterEffect || (this._filterEffect = new Ni);
        s = s;
        const e = (s == null ? void 0 : s.length) > 0
          , i = ((n = t.filters) == null ? void 0 : n.length) > 0
          , r = e !== i;
        s = Array.isArray(s) ? s.slice(0) : s,
        t.filters = Object.freeze(s),
        r && (e ? this.addEffect(t) : (this.removeEffect(t),
        t.filters = s ?? null))
    },
    get filters() {
        var s;
        return (s = this._filterEffect) == null ? void 0 : s.filters
    },
    set filterArea(s) {
        this._filterEffect || (this._filterEffect = new Ni),
        this._filterEffect.filterArea = s
    },
    get filterArea() {
        var s;
        return (s = this._filterEffect) == null ? void 0 : s.filterArea
    }
}
  , fo = {
    label: null,
    get name() {
        return V(dt, "Container.name property has been removed, use Container.label instead"),
        this.label
    },
    set name(s) {
        V(dt, "Container.name property has been removed, use Container.label instead"),
        this.label = s
    },
    getChildByName(s, t=!1) {
        return this.getChildByLabel(s, t)
    },
    getChildByLabel(s, t=!1) {
        const e = this.children;
        for (let i = 0; i < e.length; i++) {
            const r = e[i];
            if (r.label === s || s instanceof RegExp && s.test(r.label))
                return r
        }
        if (t)
            for (let i = 0; i < e.length; i++) {
                const n = e[i].getChildByLabel(s, !0);
                if (n)
                    return n
            }
        return null
    },
    getChildrenByLabel(s, t=!1, e=[]) {
        const i = this.children;
        for (let r = 0; r < i.length; r++) {
            const n = i[r];
            (n.label === s || s instanceof RegExp && s.test(n.label)) && e.push(n)
        }
        if (t)
            for (let r = 0; r < i.length; r++)
                i[r].getChildrenByLabel(s, !0, e);
        return e
    }
}
  , ot = mt.getPool(D)
  , Et = mt.getPool(gt)
  , po = new D
  , go = {
    getFastGlobalBounds(s, t) {
        t || (t = new gt),
        t.clear(),
        this._getGlobalBoundsRecursive(!!s, t, this.parentRenderLayer),
        t.isValid || t.set(0, 0, 0, 0);
        const e = this.renderGroup || this.parentRenderGroup;
        return t.applyMatrix(e.worldTransform),
        t
    },
    _getGlobalBoundsRecursive(s, t, e) {
        let i = t;
        if (s && this.parentRenderLayer && this.parentRenderLayer !== e || this.localDisplayStatus !== 7 || !this.measurable)
            return;
        const r = !!this.effects.length;
        if ((this.renderGroup || r) && (i = Et.get().clear()),
        this.boundsArea)
            t.addRect(this.boundsArea, this.worldTransform);
        else {
            if (this.renderPipeId) {
                const a = this.bounds;
                i.addFrame(a.minX, a.minY, a.maxX, a.maxY, this.groupTransform)
            }
            const n = this.children;
            for (let a = 0; a < n.length; a++)
                n[a]._getGlobalBoundsRecursive(s, i, e)
        }
        if (r) {
            let n = !1;
            const a = this.renderGroup || this.parentRenderGroup;
            for (let o = 0; o < this.effects.length; o++)
                this.effects[o].addBounds && (n || (n = !0,
                i.applyMatrix(a.worldTransform)),
                this.effects[o].addBounds(i, !0));
            n && i.applyMatrix(a.worldTransform.copyTo(po).invert()),
            t.addBounds(i),
            Et.return(i)
        } else
            this.renderGroup && (t.addBounds(i, this.relativeGroupTransform),
            Et.return(i))
    }
};
function cn(s, t, e) {
    e.clear();
    let i, r;
    return s.parent ? t ? i = s.parent.worldTransform : (r = ot.get().identity(),
    i = pi(s, r)) : i = D.IDENTITY,
    un(s, e, i, t),
    r && ot.return(r),
    e.isValid || e.set(0, 0, 0, 0),
    e
}
function un(s, t, e, i) {
    var o, h;
    if (!s.visible || !s.measurable)
        return;
    let r;
    i ? r = s.worldTransform : (s.updateLocalTransform(),
    r = ot.get(),
    r.appendFrom(s.localTransform, e));
    const n = t
      , a = !!s.effects.length;
    if (a && (t = Et.get().clear()),
    s.boundsArea)
        t.addRect(s.boundsArea, r);
    else {
        const l = s.bounds;
        l && !l.isEmpty() && (t.matrix = r,
        t.addBounds(l));
        for (let c = 0; c < s.children.length; c++)
            un(s.children[c], t, r, i)
    }
    if (a) {
        for (let l = 0; l < s.effects.length; l++)
            (h = (o = s.effects[l]).addBounds) == null || h.call(o, t);
        n.addBounds(t, D.IDENTITY),
        Et.return(t)
    }
    i || ot.return(r)
}
function pi(s, t) {
    const e = s.parent;
    return e && (pi(e, t),
    e.updateLocalTransform(),
    t.append(e.localTransform)),
    t
}
function dn(s, t) {
    if (s === 16777215 || !t)
        return t;
    if (t === 16777215 || !s)
        return s;
    const e = s >> 16 & 255
      , i = s >> 8 & 255
      , r = s & 255
      , n = t >> 16 & 255
      , a = t >> 8 & 255
      , o = t & 255
      , h = e * n / 255 | 0
      , l = i * a / 255 | 0
      , c = r * o / 255 | 0;
    return (h << 16) + (l << 8) + c
}
const Hi = 16777215;
function $i(s, t) {
    return s === Hi ? t : t === Hi ? s : dn(s, t)
}
function rs(s) {
    return ((s & 255) << 16) + (s & 65280) + (s >> 16 & 255)
}
const mo = {
    getGlobalAlpha(s) {
        if (s)
            return this.renderGroup ? this.renderGroup.worldAlpha : this.parentRenderGroup ? this.parentRenderGroup.worldAlpha * this.alpha : this.alpha;
        let t = this.alpha
          , e = this.parent;
        for (; e; )
            t *= e.alpha,
            e = e.parent;
        return t
    },
    getGlobalTransform(s=new D, t) {
        if (t)
            return s.copyFrom(this.worldTransform);
        this.updateLocalTransform();
        const e = pi(this, ot.get().identity());
        return s.appendFrom(this.localTransform, e),
        ot.return(e),
        s
    },
    getGlobalTint(s) {
        if (s)
            return this.renderGroup ? rs(this.renderGroup.worldColor) : this.parentRenderGroup ? rs($i(this.localColor, this.parentRenderGroup.worldColor)) : this.tint;
        let t = this.localColor
          , e = this.parent;
        for (; e; )
            t = $i(t, e.localColor),
            e = e.parent;
        return rs(t)
    }
};
function fn(s, t, e) {
    return t.clear(),
    e || (e = D.IDENTITY),
    pn(s, t, e, s, !0),
    t.isValid || t.set(0, 0, 0, 0),
    t
}
function pn(s, t, e, i, r) {
    var h, l;
    let n;
    if (r)
        n = ot.get(),
        n = e.copyTo(n);
    else {
        if (!s.visible || !s.measurable)
            return;
        s.updateLocalTransform();
        const c = s.localTransform;
        n = ot.get(),
        n.appendFrom(c, e)
    }
    const a = t
      , o = !!s.effects.length;
    if (o && (t = Et.get().clear()),
    s.boundsArea)
        t.addRect(s.boundsArea, n);
    else {
        s.renderPipeId && (t.matrix = n,
        t.addBounds(s.bounds));
        const c = s.children;
        for (let u = 0; u < c.length; u++)
            pn(c[u], t, n, i, !1)
    }
    if (o) {
        for (let c = 0; c < s.effects.length; c++)
            (l = (h = s.effects[c]).addLocalBounds) == null || l.call(h, t, i);
        a.addBounds(t, D.IDENTITY),
        Et.return(t)
    }
    ot.return(n)
}
function gn(s, t) {
    const e = s.children;
    for (let i = 0; i < e.length; i++) {
        const r = e[i]
          , n = r.uid
          , a = (r._didViewChangeTick & 65535) << 16 | r._didContainerChangeTick & 65535
          , o = t.index;
        (t.data[o] !== n || t.data[o + 1] !== a) && (t.data[t.index] = n,
        t.data[t.index + 1] = a,
        t.didChange = !0),
        t.index = o + 2,
        r.children.length && gn(r, t)
    }
    return t.didChange
}
const xo = new D
  , yo = {
    _localBoundsCacheId: -1,
    _localBoundsCacheData: null,
    _setWidth(s, t) {
        const e = Math.sign(this.scale.x) || 1;
        t !== 0 ? this.scale.x = s / t * e : this.scale.x = e
    },
    _setHeight(s, t) {
        const e = Math.sign(this.scale.y) || 1;
        t !== 0 ? this.scale.y = s / t * e : this.scale.y = e
    },
    getLocalBounds() {
        this._localBoundsCacheData || (this._localBoundsCacheData = {
            data: [],
            index: 1,
            didChange: !1,
            localBounds: new gt
        });
        const s = this._localBoundsCacheData;
        return s.index = 1,
        s.didChange = !1,
        s.data[0] !== this._didViewChangeTick && (s.didChange = !0,
        s.data[0] = this._didViewChangeTick),
        gn(this, s),
        s.didChange && fn(this, s.localBounds, xo),
        s.localBounds
    },
    getBounds(s, t) {
        return cn(this, s, t || new gt)
    }
}
  , _o = {
    _onRender: null,
    set onRender(s) {
        const t = this.renderGroup || this.parentRenderGroup;
        if (!s) {
            this._onRender && (t == null || t.removeOnRender(this)),
            this._onRender = null;
            return
        }
        this._onRender || t == null || t.addOnRender(this),
        this._onRender = s
    },
    get onRender() {
        return this._onRender
    }
}
  , bo = {
    _zIndex: 0,
    sortDirty: !1,
    sortableChildren: !1,
    get zIndex() {
        return this._zIndex
    },
    set zIndex(s) {
        this._zIndex !== s && (this._zIndex = s,
        this.depthOfChildModified())
    },
    depthOfChildModified() {
        this.parent && (this.parent.sortableChildren = !0,
        this.parent.sortDirty = !0),
        this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0)
    },
    sortChildren() {
        this.sortDirty && (this.sortDirty = !1,
        this.children.sort(wo))
    }
};
function wo(s, t) {
    return s._zIndex - t._zIndex
}
const Ao = {
    getGlobalPosition(s=new nt, t=!1) {
        return this.parent ? this.parent.toGlobal(this._position, s, t) : (s.x = this._position.x,
        s.y = this._position.y),
        s
    },
    toGlobal(s, t, e=!1) {
        const i = this.getGlobalTransform(ot.get(), e);
        return t = i.apply(s, t),
        ot.return(i),
        t
    },
    toLocal(s, t, e, i) {
        t && (s = t.toGlobal(s, e, i));
        const r = this.getGlobalTransform(ot.get(), i);
        return e = r.applyInverse(s, e),
        ot.return(r),
        e
    }
};
class mn {
    constructor() {
        this.uid = q("instructionSet"),
        this.instructions = [],
        this.instructionSize = 0,
        this.renderables = [],
        this.gcTick = 0
    }
    reset() {
        this.instructionSize = 0
    }
    destroy() {
        this.instructions.length = 0,
        this.renderables.length = 0,
        this.renderPipes = null,
        this.gcTick = 0
    }
    add(t) {
        this.instructions[this.instructionSize++] = t
    }
    log() {
        this.instructions.length = this.instructionSize
    }
}
let vo = 0;
class So {
    constructor(t) {
        this._poolKeyHash = Object.create(null),
        this._texturePool = {},
        this.textureOptions = t || {},
        this.enableFullScreen = !1,
        this.textureStyle = new ue(this.textureOptions)
    }
    createTexture(t, e, i, r) {
        const n = new xt({
            ...this.textureOptions,
            width: t,
            height: e,
            resolution: 1,
            antialias: i,
            autoGarbageCollect: !1,
            autoGenerateMipmaps: r
        });
        return new W({
            source: n,
            label: `texturePool_${vo++}`
        })
    }
    getOptimalTexture(t, e, i=1, r, n=!1) {
        let a = Math.ceil(t * i - 1e-6)
          , o = Math.ceil(e * i - 1e-6);
        a = ce(a),
        o = ce(o);
        const h = r ? 1 : 0
          , l = n ? 1 : 0
          , c = (a << 17) + (o << 2) + (l << 1) + h;
        this._texturePool[c] || (this._texturePool[c] = []);
        let u = this._texturePool[c].pop();
        return u || (u = this.createTexture(a, o, r, n)),
        u.source._resolution = i,
        u.source.width = a / i,
        u.source.height = o / i,
        u.source.pixelWidth = a,
        u.source.pixelHeight = o,
        u.frame.x = 0,
        u.frame.y = 0,
        u.frame.width = t,
        u.frame.height = e,
        u.updateUvs(),
        this._poolKeyHash[u.uid] = c,
        u
    }
    getSameSizeTexture(t, e=!1) {
        const i = t.source;
        return this.getOptimalTexture(t.width, t.height, i._resolution, e)
    }
    returnTexture(t, e=!1) {
        const i = this._poolKeyHash[t.uid];
        e && (t.source.style = this.textureStyle),
        this._texturePool[i].push(t)
    }
    clear(t) {
        if (t = t !== !1,
        t)
            for (const e in this._texturePool) {
                const i = this._texturePool[e];
                if (i)
                    for (let r = 0; r < i.length; r++)
                        i[r].destroy(!0)
            }
        this._texturePool = {}
    }
}
const ds = new So;
Ue.register(ds);
class To {
    constructor() {
        this.renderPipeId = "renderGroup",
        this.root = null,
        this.canBundle = !1,
        this.renderGroupParent = null,
        this.renderGroupChildren = [],
        this.worldTransform = new D,
        this.worldColorAlpha = 4294967295,
        this.worldColor = 16777215,
        this.worldAlpha = 1,
        this.childrenToUpdate = Object.create(null),
        this.updateTick = 0,
        this.gcTick = 0,
        this.childrenRenderablesToUpdate = {
            list: [],
            index: 0
        },
        this.structureDidChange = !0,
        this.instructionSet = new mn,
        this._onRenderContainers = [],
        this.textureNeedsUpdate = !0,
        this.isCachedAsTexture = !1,
        this._matrixDirty = 7
    }
    init(t) {
        this.root = t,
        t._onRender && this.addOnRender(t),
        t.didChange = !0;
        const e = t.children;
        for (let i = 0; i < e.length; i++) {
            const r = e[i];
            r._updateFlags = 15,
            this.addChild(r)
        }
    }
    enableCacheAsTexture(t={}) {
        this.textureOptions = t,
        this.isCachedAsTexture = !0,
        this.textureNeedsUpdate = !0
    }
    disableCacheAsTexture() {
        this.isCachedAsTexture = !1,
        this.texture && (ds.returnTexture(this.texture, !0),
        this.texture = null)
    }
    updateCacheTexture() {
        this.textureNeedsUpdate = !0;
        const t = this._parentCacheAsTextureRenderGroup;
        t && !t.textureNeedsUpdate && t.updateCacheTexture()
    }
    reset() {
        this.renderGroupChildren.length = 0;
        for (const t in this.childrenToUpdate) {
            const e = this.childrenToUpdate[t];
            e.list.fill(null),
            e.index = 0
        }
        this.childrenRenderablesToUpdate.index = 0,
        this.childrenRenderablesToUpdate.list.fill(null),
        this.root = null,
        this.updateTick = 0,
        this.structureDidChange = !0,
        this._onRenderContainers.length = 0,
        this.renderGroupParent = null,
        this.disableCacheAsTexture()
    }
    get localTransform() {
        return this.root.localTransform
    }
    addRenderGroupChild(t) {
        t.renderGroupParent && t.renderGroupParent._removeRenderGroupChild(t),
        t.renderGroupParent = this,
        this.renderGroupChildren.push(t)
    }
    _removeRenderGroupChild(t) {
        const e = this.renderGroupChildren.indexOf(t);
        e > -1 && this.renderGroupChildren.splice(e, 1),
        t.renderGroupParent = null
    }
    addChild(t) {
        if (this.structureDidChange = !0,
        t.parentRenderGroup = this,
        t.updateTick = -1,
        t.parent === this.root ? t.relativeRenderGroupDepth = 1 : t.relativeRenderGroupDepth = t.parent.relativeRenderGroupDepth + 1,
        t.didChange = !0,
        this.onChildUpdate(t),
        t.renderGroup) {
            this.addRenderGroupChild(t.renderGroup);
            return
        }
        t._onRender && this.addOnRender(t);
        const e = t.children;
        for (let i = 0; i < e.length; i++)
            this.addChild(e[i])
    }
    removeChild(t) {
        if (this.structureDidChange = !0,
        t._onRender && (t.renderGroup || this.removeOnRender(t)),
        t.parentRenderGroup = null,
        t.renderGroup) {
            this._removeRenderGroupChild(t.renderGroup);
            return
        }
        const e = t.children;
        for (let i = 0; i < e.length; i++)
            this.removeChild(e[i])
    }
    removeChildren(t) {
        for (let e = 0; e < t.length; e++)
            this.removeChild(t[e])
    }
    onChildUpdate(t) {
        let e = this.childrenToUpdate[t.relativeRenderGroupDepth];
        e || (e = this.childrenToUpdate[t.relativeRenderGroupDepth] = {
            index: 0,
            list: []
        }),
        e.list[e.index++] = t
    }
    updateRenderable(t) {
        t.globalDisplayStatus < 7 || (this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),
        t.didViewUpdate = !1)
    }
    onChildViewUpdate(t) {
        this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++] = t
    }
    get isRenderable() {
        return this.root.localDisplayStatus === 7 && this.worldAlpha > 0
    }
    addOnRender(t) {
        this._onRenderContainers.push(t)
    }
    removeOnRender(t) {
        this._onRenderContainers.splice(this._onRenderContainers.indexOf(t), 1)
    }
    runOnRender(t) {
        for (let e = 0; e < this._onRenderContainers.length; e++)
            this._onRenderContainers[e]._onRender(t)
    }
    destroy() {
        this.disableCacheAsTexture(),
        this.renderGroupParent = null,
        this.root = null,
        this.childrenRenderablesToUpdate = null,
        this.childrenToUpdate = null,
        this.renderGroupChildren = null,
        this._onRenderContainers = null,
        this.instructionSet = null
    }
    getChildren(t=[]) {
        const e = this.root.children;
        for (let i = 0; i < e.length; i++)
            this._getChildren(e[i], t);
        return t
    }
    _getChildren(t, e=[]) {
        if (e.push(t),
        t.renderGroup)
            return e;
        const i = t.children;
        for (let r = 0; r < i.length; r++)
            this._getChildren(i[r], e);
        return e
    }
    invalidateMatrices() {
        this._matrixDirty = 7
    }
    get inverseWorldTransform() {
        return (this._matrixDirty & 1) === 0 ? this._inverseWorldTransform : (this._matrixDirty &= -2,
        this._inverseWorldTransform || (this._inverseWorldTransform = new D),
        this._inverseWorldTransform.copyFrom(this.worldTransform).invert())
    }
    get textureOffsetInverseTransform() {
        return (this._matrixDirty & 2) === 0 ? this._textureOffsetInverseTransform : (this._matrixDirty &= -3,
        this._textureOffsetInverseTransform || (this._textureOffsetInverseTransform = new D),
        this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x, -this._textureBounds.y))
    }
    get inverseParentTextureTransform() {
        if ((this._matrixDirty & 4) === 0)
            return this._inverseParentTextureTransform;
        this._matrixDirty &= -5;
        const t = this._parentCacheAsTextureRenderGroup;
        return t ? (this._inverseParentTextureTransform || (this._inverseParentTextureTransform = new D),
        this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x, -t._textureBounds.y)) : this.worldTransform
    }
    get cacheToLocalTransform() {
        return this.isCachedAsTexture ? this.textureOffsetInverseTransform : this._parentCacheAsTextureRenderGroup ? this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform : null
    }
}
function Co(s, t, e={}) {
    for (const i in t)
        !e[i] && t[i] !== void 0 && (s[i] = t[i])
}
const Ps = new it(null)
  , Ye = new it(null)
  , Ms = new it(null,1,1)
  , Xe = new it(null)
  , Vi = 1
  , Po = 2
  , ks = 4;
class Gt extends vt {
    constructor(t={}) {
        var e, i;
        super(),
        this.uid = q("renderable"),
        this._updateFlags = 15,
        this.renderGroup = null,
        this.parentRenderGroup = null,
        this.parentRenderGroupIndex = 0,
        this.didChange = !1,
        this.didViewUpdate = !1,
        this.relativeRenderGroupDepth = 0,
        this.children = [],
        this.parent = null,
        this.includeInBuild = !0,
        this.measurable = !0,
        this.isSimple = !0,
        this.parentRenderLayer = null,
        this.updateTick = -1,
        this.localTransform = new D,
        this.relativeGroupTransform = new D,
        this.groupTransform = this.relativeGroupTransform,
        this.destroyed = !1,
        this._position = new it(this,0,0),
        this._scale = Ms,
        this._pivot = Ye,
        this._origin = Xe,
        this._skew = Ps,
        this._cx = 1,
        this._sx = 0,
        this._cy = 0,
        this._sy = 1,
        this._rotation = 0,
        this.localColor = 16777215,
        this.localAlpha = 1,
        this.groupAlpha = 1,
        this.groupColor = 16777215,
        this.groupColorAlpha = 4294967295,
        this.localBlendMode = "inherit",
        this.groupBlendMode = "normal",
        this.localDisplayStatus = 7,
        this.globalDisplayStatus = 7,
        this._didContainerChangeTick = 0,
        this._didViewChangeTick = 0,
        this._didLocalTransformChangeId = -1,
        this.effects = [],
        Co(this, t, {
            children: !0,
            parent: !0,
            effects: !0
        }),
        (e = t.children) == null || e.forEach(r => this.addChild(r)),
        (i = t.parent) == null || i.addChild(this)
    }
    static mixin(t) {
        V("8.8.0", "Container.mixin is deprecated, please use extensions.mixin instead."),
        Y.mixin(Gt, t)
    }
    set _didChangeId(t) {
        this._didViewChangeTick = t >> 12 & 4095,
        this._didContainerChangeTick = t & 4095
    }
    get _didChangeId() {
        return this._didContainerChangeTick & 4095 | (this._didViewChangeTick & 4095) << 12
    }
    addChild(...t) {
        if (this.allowChildren || V(dt, "addChild: Only Containers will be allowed to add children in v8.0.0"),
        t.length > 1) {
            for (let r = 0; r < t.length; r++)
                this.addChild(t[r]);
            return t[0]
        }
        const e = t[0]
          , i = this.renderGroup || this.parentRenderGroup;
        return e.parent === this ? (this.children.splice(this.children.indexOf(e), 1),
        this.children.push(e),
        i && (i.structureDidChange = !0),
        e) : (e.parent && e.parent.removeChild(e),
        this.children.push(e),
        this.sortableChildren && (this.sortDirty = !0),
        e.parent = this,
        e.didChange = !0,
        e._updateFlags = 15,
        i && i.addChild(e),
        this.emit("childAdded", e, this, this.children.length - 1),
        e.emit("added", this),
        this._didViewChangeTick++,
        e._zIndex !== 0 && e.depthOfChildModified(),
        e)
    }
    removeChild(...t) {
        if (t.length > 1) {
            for (let r = 0; r < t.length; r++)
                this.removeChild(t[r]);
            return t[0]
        }
        const e = t[0]
          , i = this.children.indexOf(e);
        return i > -1 && (this._didViewChangeTick++,
        this.children.splice(i, 1),
        this.renderGroup ? this.renderGroup.removeChild(e) : this.parentRenderGroup && this.parentRenderGroup.removeChild(e),
        e.parentRenderLayer && e.parentRenderLayer.detach(e),
        e.parent = null,
        this.emit("childRemoved", e, this, i),
        e.emit("removed", this)),
        e
    }
    _onUpdate(t) {
        t && t === this._skew && this._updateSkew(),
        this._didContainerChangeTick++,
        !this.didChange && (this.didChange = !0,
        this.parentRenderGroup && this.parentRenderGroup.onChildUpdate(this))
    }
    set isRenderGroup(t) {
        !!this.renderGroup !== t && (t ? this.enableRenderGroup() : this.disableRenderGroup())
    }
    get isRenderGroup() {
        return !!this.renderGroup
    }
    enableRenderGroup() {
        if (this.renderGroup)
            return;
        const t = this.parentRenderGroup;
        t == null || t.removeChild(this),
        this.renderGroup = mt.get(To, this),
        this.groupTransform = D.IDENTITY,
        t == null || t.addChild(this),
        this._updateIsSimple()
    }
    disableRenderGroup() {
        if (!this.renderGroup)
            return;
        const t = this.parentRenderGroup;
        t == null || t.removeChild(this),
        mt.return(this.renderGroup),
        this.renderGroup = null,
        this.groupTransform = this.relativeGroupTransform,
        t == null || t.addChild(this),
        this._updateIsSimple()
    }
    _updateIsSimple() {
        this.isSimple = !this.renderGroup && this.effects.length === 0
    }
    get worldTransform() {
        return this._worldTransform || (this._worldTransform = new D),
        this.renderGroup ? this._worldTransform.copyFrom(this.renderGroup.worldTransform) : this.parentRenderGroup && this._worldTransform.appendFrom(this.relativeGroupTransform, this.parentRenderGroup.worldTransform),
        this._worldTransform
    }
    get x() {
        return this._position.x
    }
    set x(t) {
        this._position.x = t
    }
    get y() {
        return this._position.y
    }
    set y(t) {
        this._position.y = t
    }
    get position() {
        return this._position
    }
    set position(t) {
        this._position.copyFrom(t)
    }
    get rotation() {
        return this._rotation
    }
    set rotation(t) {
        this._rotation !== t && (this._rotation = t,
        this._onUpdate(this._skew))
    }
    get angle() {
        return this.rotation * Oa
    }
    set angle(t) {
        this.rotation = t * Ua
    }
    get pivot() {
        return this._pivot === Ye && (this._pivot = new it(this,0,0)),
        this._pivot
    }
    set pivot(t) {
        this._pivot === Ye && (this._pivot = new it(this,0,0),
        this._origin !== Xe && $("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),
        typeof t == "number" ? this._pivot.set(t) : this._pivot.copyFrom(t)
    }
    get skew() {
        return this._skew === Ps && (this._skew = new it(this,0,0)),
        this._skew
    }
    set skew(t) {
        this._skew === Ps && (this._skew = new it(this,0,0)),
        this._skew.copyFrom(t)
    }
    get scale() {
        return this._scale === Ms && (this._scale = new it(this,1,1)),
        this._scale
    }
    set scale(t) {
        this._scale === Ms && (this._scale = new it(this,0,0)),
        typeof t == "string" && (t = parseFloat(t)),
        typeof t == "number" ? this._scale.set(t) : this._scale.copyFrom(t)
    }
    get origin() {
        return this._origin === Xe && (this._origin = new it(this,0,0)),
        this._origin
    }
    set origin(t) {
        this._origin === Xe && (this._origin = new it(this,0,0),
        this._pivot !== Ye && $("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),
        typeof t == "number" ? this._origin.set(t) : this._origin.copyFrom(t)
    }
    get width() {
        return Math.abs(this.scale.x * this.getLocalBounds().width)
    }
    set width(t) {
        const e = this.getLocalBounds().width;
        this._setWidth(t, e)
    }
    get height() {
        return Math.abs(this.scale.y * this.getLocalBounds().height)
    }
    set height(t) {
        const e = this.getLocalBounds().height;
        this._setHeight(t, e)
    }
    getSize(t) {
        t || (t = {});
        const e = this.getLocalBounds();
        return t.width = Math.abs(this.scale.x * e.width),
        t.height = Math.abs(this.scale.y * e.height),
        t
    }
    setSize(t, e) {
        const i = this.getLocalBounds();
        typeof t == "object" ? (e = t.height ?? t.width,
        t = t.width) : e ?? (e = t),
        t !== void 0 && this._setWidth(t, i.width),
        e !== void 0 && this._setHeight(e, i.height)
    }
    _updateSkew() {
        const t = this._rotation
          , e = this._skew;
        this._cx = Math.cos(t + e._y),
        this._sx = Math.sin(t + e._y),
        this._cy = -Math.sin(t - e._x),
        this._sy = Math.cos(t - e._x)
    }
    updateTransform(t) {
        return this.position.set(typeof t.x == "number" ? t.x : this.position.x, typeof t.y == "number" ? t.y : this.position.y),
        this.scale.set(typeof t.scaleX == "number" ? t.scaleX || 1 : this.scale.x, typeof t.scaleY == "number" ? t.scaleY || 1 : this.scale.y),
        this.rotation = typeof t.rotation == "number" ? t.rotation : this.rotation,
        this.skew.set(typeof t.skewX == "number" ? t.skewX : this.skew.x, typeof t.skewY == "number" ? t.skewY : this.skew.y),
        this.pivot.set(typeof t.pivotX == "number" ? t.pivotX : this.pivot.x, typeof t.pivotY == "number" ? t.pivotY : this.pivot.y),
        this.origin.set(typeof t.originX == "number" ? t.originX : this.origin.x, typeof t.originY == "number" ? t.originY : this.origin.y),
        this
    }
    setFromMatrix(t) {
        t.decompose(this)
    }
    updateLocalTransform() {
        const t = this._didContainerChangeTick;
        if (this._didLocalTransformChangeId === t)
            return;
        this._didLocalTransformChangeId = t;
        const e = this.localTransform
          , i = this._scale
          , r = this._pivot
          , n = this._origin
          , a = this._position
          , o = i._x
          , h = i._y
          , l = r._x
          , c = r._y
          , u = -n._x
          , d = -n._y;
        e.a = this._cx * o,
        e.b = this._sx * o,
        e.c = this._cy * h,
        e.d = this._sy * h,
        e.tx = a._x - (l * e.a + c * e.c) + (u * e.a + d * e.c) - u,
        e.ty = a._y - (l * e.b + c * e.d) + (u * e.b + d * e.d) - d
    }
    set alpha(t) {
        t !== this.localAlpha && (this.localAlpha = t,
        this._updateFlags |= Vi,
        this._onUpdate())
    }
    get alpha() {
        return this.localAlpha
    }
    set tint(t) {
        const i = J.shared.setValue(t ?? 16777215).toBgrNumber();
        i !== this.localColor && (this.localColor = i,
        this._updateFlags |= Vi,
        this._onUpdate())
    }
    get tint() {
        return rs(this.localColor)
    }
    set blendMode(t) {
        this.localBlendMode !== t && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0),
        this._updateFlags |= Po,
        this.localBlendMode = t,
        this._onUpdate())
    }
    get blendMode() {
        return this.localBlendMode
    }
    get visible() {
        return !!(this.localDisplayStatus & 2)
    }
    set visible(t) {
        const e = t ? 2 : 0;
        (this.localDisplayStatus & 2) !== e && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0),
        this._updateFlags |= ks,
        this.localDisplayStatus ^= 2,
        this._onUpdate(),
        this.emit("visibleChanged", t))
    }
    get culled() {
        return !(this.localDisplayStatus & 4)
    }
    set culled(t) {
        const e = t ? 0 : 4;
        (this.localDisplayStatus & 4) !== e && (this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0),
        this._updateFlags |= ks,
        this.localDisplayStatus ^= 4,
        this._onUpdate())
    }
    get renderable() {
        return !!(this.localDisplayStatus & 1)
    }
    set renderable(t) {
        const e = t ? 1 : 0;
        (this.localDisplayStatus & 1) !== e && (this._updateFlags |= ks,
        this.localDisplayStatus ^= 1,
        this.parentRenderGroup && (this.parentRenderGroup.structureDidChange = !0),
        this._onUpdate())
    }
    get isRenderable() {
        return this.localDisplayStatus === 7 && this.groupAlpha > 0
    }
    destroy(t=!1) {
        var r;
        if (this.destroyed)
            return;
        this.destroyed = !0;
        let e;
        if (this.children.length && (e = this.removeChildren(0, this.children.length)),
        this.removeFromParent(),
        this.parent = null,
        this._maskEffect = null,
        this._filterEffect = null,
        this.effects = null,
        this._position = null,
        this._scale = null,
        this._pivot = null,
        this._origin = null,
        this._skew = null,
        this.emit("destroyed", this),
        this.removeAllListeners(),
        (typeof t == "boolean" ? t : t == null ? void 0 : t.children) && e)
            for (let n = 0; n < e.length; ++n)
                e[n].destroy(t);
        (r = this.renderGroup) == null || r.destroy(),
        this.renderGroup = null
    }
}
Y.mixin(Gt, ho, go, Ao, _o, yo, uo, fo, bo, io, ao, mo, lo);
class xn extends Gt {
    constructor(t) {
        super(t),
        this.canBundle = !0,
        this.allowChildren = !1,
        this._roundPixels = 0,
        this._lastUsed = -1,
        this._gpuData = Object.create(null),
        this.autoGarbageCollect = !0,
        this._gcLastUsed = -1,
        this._bounds = new gt(0,1,0,0),
        this._boundsDirty = !0,
        this.autoGarbageCollect = t.autoGarbageCollect ?? !0
    }
    get bounds() {
        return this._boundsDirty ? (this.updateBounds(),
        this._boundsDirty = !1,
        this._bounds) : this._bounds
    }
    get roundPixels() {
        return !!this._roundPixels
    }
    set roundPixels(t) {
        this._roundPixels = t ? 1 : 0
    }
    containsPoint(t) {
        const e = this.bounds
          , {x: i, y: r} = t;
        return i >= e.minX && i <= e.maxX && r >= e.minY && r <= e.maxY
    }
    onViewUpdate() {
        if (this._didViewChangeTick++,
        this._boundsDirty = !0,
        this.didViewUpdate)
            return;
        this.didViewUpdate = !0;
        const t = this.renderGroup || this.parentRenderGroup;
        t && t.onChildViewUpdate(this)
    }
    unload() {
        var t;
        this.emit("unload", this);
        for (const e in this._gpuData)
            (t = this._gpuData[e]) == null || t.destroy();
        this._gpuData = Object.create(null),
        this.onViewUpdate()
    }
    destroy(t) {
        this.unload(),
        super.destroy(t),
        this._bounds = null
    }
    collectRenderablesSimple(t, e, i) {
        const {renderPipes: r} = e;
        r.blendMode.pushBlendMode(this, this.groupBlendMode, t);
        const a = r[this.renderPipeId];
        a != null && a.addRenderable && a.addRenderable(this, t),
        this.didViewUpdate = !1;
        const o = this.children
          , h = o.length;
        for (let l = 0; l < h; l++)
            o[l].collectRenderables(t, e, i);
        r.blendMode.popBlendMode(t)
    }
}
class fe extends xn {
    constructor(t=W.EMPTY) {
        t instanceof W && (t = {
            texture: t
        });
        const {texture: e=W.EMPTY, anchor: i, roundPixels: r, width: n, height: a, ...o} = t;
        super({
            label: "Sprite",
            ...o
        }),
        this.renderPipeId = "sprite",
        this.batched = !0,
        this._visualBounds = {
            minX: 0,
            maxX: 1,
            minY: 0,
            maxY: 0
        },
        this._anchor = new it({
            _onUpdate: () => {
                this.onViewUpdate()
            }
        }),
        i ? this.anchor = i : e.defaultAnchor && (this.anchor = e.defaultAnchor),
        this.texture = e,
        this.allowChildren = !1,
        this.roundPixels = r ?? !1,
        n !== void 0 && (this.width = n),
        a !== void 0 && (this.height = a)
    }
    static from(t, e=!1) {
        return t instanceof W ? new fe(t) : new fe(W.from(t, e))
    }
    set texture(t) {
        t || (t = W.EMPTY);
        const e = this._texture;
        e !== t && (e && e.dynamic && e.off("update", this.onViewUpdate, this),
        t.dynamic && t.on("update", this.onViewUpdate, this),
        this._texture = t,
        this._width && this._setWidth(this._width, this._texture.orig.width),
        this._height && this._setHeight(this._height, this._texture.orig.height),
        this.onViewUpdate())
    }
    get texture() {
        return this._texture
    }
    get visualBounds() {
        return an(this._visualBounds, this._anchor, this._texture),
        this._visualBounds
    }
    get sourceBounds() {
        return V("8.6.1", "Sprite.sourceBounds is deprecated, use visualBounds instead."),
        this.visualBounds
    }
    updateBounds() {
        const t = this._anchor
          , e = this._texture
          , i = this._bounds
          , {width: r, height: n} = e.orig;
        i.minX = -t._x * r,
        i.maxX = i.minX + r,
        i.minY = -t._y * n,
        i.maxY = i.minY + n
    }
    destroy(t=!1) {
        if (super.destroy(t),
        typeof t == "boolean" ? t : t == null ? void 0 : t.texture) {
            const i = typeof t == "boolean" ? t : t == null ? void 0 : t.textureSource;
            this._texture.destroy(i)
        }
        this._texture = null,
        this._visualBounds = null,
        this._bounds = null,
        this._anchor = null
    }
    get anchor() {
        return this._anchor
    }
    set anchor(t) {
        typeof t == "number" ? this._anchor.set(t) : this._anchor.copyFrom(t)
    }
    get width() {
        return Math.abs(this.scale.x) * this._texture.orig.width
    }
    set width(t) {
        this._setWidth(t, this._texture.orig.width),
        this._width = t
    }
    get height() {
        return Math.abs(this.scale.y) * this._texture.orig.height
    }
    set height(t) {
        this._setHeight(t, this._texture.orig.height),
        this._height = t
    }
    getSize(t) {
        return t || (t = {}),
        t.width = Math.abs(this.scale.x) * this._texture.orig.width,
        t.height = Math.abs(this.scale.y) * this._texture.orig.height,
        t
    }
    setSize(t, e) {
        typeof t == "object" ? (e = t.height ?? t.width,
        t = t.width) : e ?? (e = t),
        t !== void 0 && this._setWidth(t, this._texture.orig.width),
        e !== void 0 && this._setHeight(e, this._texture.orig.height)
    }
}
const Mo = new gt;
function yn(s, t, e) {
    const i = Mo;
    s.measurable = !0,
    cn(s, e, i),
    t.addBoundsMask(i),
    s.measurable = !1
}
function _n(s, t, e) {
    const i = Et.get();
    s.measurable = !0;
    const r = ot.get().identity()
      , n = bn(s, e, r);
    fn(s, i, n),
    s.measurable = !1,
    t.addBoundsMask(i),
    ot.return(r),
    Et.return(i)
}
function bn(s, t, e) {
    return s ? (s !== t && (bn(s.parent, t, e),
    s.updateLocalTransform(),
    e.append(s.localTransform)),
    e) : ($("Mask bounds, renderable is not inside the root container"),
    e)
}
class wn {
    constructor(t) {
        this.priority = 0,
        this.inverse = !1,
        this.channel = "red",
        this.pipe = "alphaMask",
        t != null && t.mask && this.init(t.mask)
    }
    init(t) {
        this.mask = t,
        this.renderMaskToTexture = !(t instanceof fe),
        this.mask.renderable = this.renderMaskToTexture,
        this.mask.includeInBuild = !this.renderMaskToTexture,
        this.mask.measurable = !1
    }
    reset() {
        this.mask !== null && (this.mask.measurable = !0,
        this.mask = null)
    }
    addBounds(t, e) {
        this.inverse || yn(this.mask, t, e)
    }
    addLocalBounds(t, e) {
        _n(this.mask, t, e)
    }
    containsPoint(t, e) {
        const i = this.mask;
        return e(i, t)
    }
    destroy() {
        this.reset()
    }
    static test(t) {
        return t instanceof fe
    }
}
wn.extension = I.MaskEffect;
class An {
    constructor(t) {
        this.priority = 0,
        this.pipe = "colorMask",
        t != null && t.mask && this.init(t.mask)
    }
    init(t) {
        this.mask = t
    }
    destroy() {}
    static test(t) {
        return typeof t == "number"
    }
}
An.extension = I.MaskEffect;
class vn {
    constructor(t) {
        this.priority = 0,
        this.pipe = "stencilMask",
        t != null && t.mask && this.init(t.mask)
    }
    init(t) {
        this.mask = t,
        this.mask.includeInBuild = !1,
        this.mask.measurable = !1
    }
    reset() {
        this.mask !== null && (this.mask.measurable = !0,
        this.mask.includeInBuild = !0,
        this.mask = null)
    }
    addBounds(t, e) {
        yn(this.mask, t, e)
    }
    addLocalBounds(t, e) {
        _n(this.mask, t, e)
    }
    containsPoint(t, e) {
        const i = this.mask;
        return e(i, t)
    }
    destroy() {
        this.reset()
    }
    static test(t) {
        return t instanceof Gt
    }
}
vn.extension = I.MaskEffect;
const ko = {
    createCanvas: (s, t) => {
        const e = document.createElement("canvas");
        return e.width = s,
        e.height = t,
        e
    }
    ,
    createImage: () => new Image,
    getCanvasRenderingContext2D: () => CanvasRenderingContext2D,
    getWebGLRenderingContext: () => WebGLRenderingContext,
    getNavigator: () => navigator,
    getBaseUrl: () => document.baseURI ?? window.location.href,
    getFontFaceSet: () => document.fonts,
    fetch: (s, t) => fetch(s, t),
    parseXML: s => new DOMParser().parseFromString(s, "text/xml")
};
let ji = ko;
const O = {
    get() {
        return ji
    },
    set(s) {
        ji = s
    }
};
class gi extends xt {
    constructor(t) {
        t.resource || (t.resource = O.get().createCanvas()),
        t.width || (t.width = t.resource.width,
        t.autoDensity || (t.width /= t.resolution)),
        t.height || (t.height = t.resource.height,
        t.autoDensity || (t.height /= t.resolution)),
        super(t),
        this.uploadMethodId = "image",
        this.autoDensity = t.autoDensity,
        this.resizeCanvas(),
        this.transparent = !!t.transparent
    }
    resizeCanvas() {
        this.autoDensity && "style"in this.resource && (this.resource.style.width = `${this.width}px`,
        this.resource.style.height = `${this.height}px`),
        (this.resource.width !== this.pixelWidth || this.resource.height !== this.pixelHeight) && (this.resource.width = this.pixelWidth,
        this.resource.height = this.pixelHeight)
    }
    resize(t=this.width, e=this.height, i=this._resolution) {
        const r = super.resize(t, e, i);
        return r && this.resizeCanvas(),
        r
    }
    static test(t) {
        return globalThis.HTMLCanvasElement && t instanceof HTMLCanvasElement || globalThis.OffscreenCanvas && t instanceof OffscreenCanvas
    }
    get context2D() {
        return this._context2D || (this._context2D = this.resource.getContext("2d"))
    }
}
gi.extension = I.TextureSource;
class pe extends xt {
    constructor(t) {
        super(t),
        this.uploadMethodId = "image",
        this.autoGarbageCollect = !0
    }
    static test(t) {
        return globalThis.HTMLImageElement && t instanceof HTMLImageElement || typeof ImageBitmap < "u" && t instanceof ImageBitmap || globalThis.VideoFrame && t instanceof VideoFrame
    }
}
pe.extension = I.TextureSource;
var Le = (s => (s[s.INTERACTION = 50] = "INTERACTION",
s[s.HIGH = 25] = "HIGH",
s[s.NORMAL = 0] = "NORMAL",
s[s.LOW = -25] = "LOW",
s[s.UTILITY = -50] = "UTILITY",
s))(Le || {});
class Es {
    constructor(t, e=null, i=0, r=!1) {
        this.next = null,
        this.previous = null,
        this._destroyed = !1,
        this._fn = t,
        this._context = e,
        this.priority = i,
        this._once = r
    }
    match(t, e=null) {
        return this._fn === t && this._context === e
    }
    emit(t) {
        this._fn && (this._context ? this._fn.call(this._context, t) : this._fn(t));
        const e = this.next;
        return this._once && this.destroy(!0),
        this._destroyed && (this.next = null),
        e
    }
    connect(t) {
        this.previous = t,
        t.next && (t.next.previous = this),
        this.next = t.next,
        t.next = this
    }
    destroy(t=!1) {
        this._destroyed = !0,
        this._fn = null,
        this._context = null,
        this.previous && (this.previous.next = this.next),
        this.next && (this.next.previous = this.previous);
        const e = this.next;
        return this.next = t ? null : e,
        this.previous = null,
        e
    }
}
const Sn = class ut {
    constructor() {
        this.autoStart = !1,
        this.deltaTime = 1,
        this.lastTime = -1,
        this.speed = 1,
        this.started = !1,
        this._requestId = null,
        this._maxElapsedMS = 100,
        this._minElapsedMS = 0,
        this._protected = !1,
        this._lastFrame = -1,
        this._head = new Es(null,null,1 / 0),
        this.deltaMS = 1 / ut.targetFPMS,
        this.elapsedMS = 1 / ut.targetFPMS,
        this._tick = t => {
            this._requestId = null,
            this.started && (this.update(t),
            this.started && this._requestId === null && this._head.next && (this._requestId = requestAnimationFrame(this._tick)))
        }
    }
    _requestIfNeeded() {
        this._requestId === null && this._head.next && (this.lastTime = performance.now(),
        this._lastFrame = this.lastTime,
        this._requestId = requestAnimationFrame(this._tick))
    }
    _cancelIfNeeded() {
        this._requestId !== null && (cancelAnimationFrame(this._requestId),
        this._requestId = null)
    }
    _startIfPossible() {
        this.started ? this._requestIfNeeded() : this.autoStart && this.start()
    }
    add(t, e, i=Le.NORMAL) {
        return this._addListener(new Es(t,e,i))
    }
    addOnce(t, e, i=Le.NORMAL) {
        return this._addListener(new Es(t,e,i,!0))
    }
    _addListener(t) {
        let e = this._head.next
          , i = this._head;
        if (!e)
            t.connect(i);
        else {
            for (; e; ) {
                if (t.priority > e.priority) {
                    t.connect(i);
                    break
                }
                i = e,
                e = e.next
            }
            t.previous || t.connect(i)
        }
        return this._startIfPossible(),
        this
    }
    remove(t, e) {
        let i = this._head.next;
        for (; i; )
            i.match(t, e) ? i = i.destroy() : i = i.next;
        return this._head.next || this._cancelIfNeeded(),
        this
    }
    get count() {
        if (!this._head)
            return 0;
        let t = 0
          , e = this._head;
        for (; e = e.next; )
            t++;
        return t
    }
    start() {
        this.started || (this.started = !0,
        this._requestIfNeeded())
    }
    stop() {
        this.started && (this.started = !1,
        this._cancelIfNeeded())
    }
    destroy() {
        if (!this._protected) {
            this.stop();
            let t = this._head.next;
            for (; t; )
                t = t.destroy(!0);
            this._head.destroy(),
            this._head = null
        }
    }
    update(t=performance.now()) {
        let e;
        if (t > this.lastTime) {
            if (e = this.elapsedMS = t - this.lastTime,
            e > this._maxElapsedMS && (e = this._maxElapsedMS),
            e *= this.speed,
            this._minElapsedMS) {
                const n = t - this._lastFrame | 0;
                if (n < this._minElapsedMS)
                    return;
                this._lastFrame = t - n % this._minElapsedMS
            }
            this.deltaMS = e,
            this.deltaTime = this.deltaMS * ut.targetFPMS;
            const i = this._head;
            let r = i.next;
            for (; r; )
                r = r.emit(this);
            i.next || this._cancelIfNeeded()
        } else
            this.deltaTime = this.deltaMS = this.elapsedMS = 0;
        this.lastTime = t
    }
    get FPS() {
        return 1e3 / this.elapsedMS
    }
    get minFPS() {
        return 1e3 / this._maxElapsedMS
    }
    set minFPS(t) {
        const e = Math.min(Math.max(0, t) / 1e3, ut.targetFPMS);
        this._maxElapsedMS = 1 / e,
        this._minElapsedMS && t > this.maxFPS && (this.maxFPS = t)
    }
    get maxFPS() {
        return this._minElapsedMS ? Math.round(1e3 / this._minElapsedMS) : 0
    }
    set maxFPS(t) {
        t === 0 ? this._minElapsedMS = 0 : (t < this.minFPS && (this.minFPS = t),
        this._minElapsedMS = 1 / (t / 1e3))
    }
    static get shared() {
        if (!ut._shared) {
            const t = ut._shared = new ut;
            t.autoStart = !0,
            t._protected = !0
        }
        return ut._shared
    }
    static get system() {
        if (!ut._system) {
            const t = ut._system = new ut;
            t.autoStart = !0,
            t._protected = !0
        }
        return ut._system
    }
}
;
Sn.targetFPMS = .06;
let _t = Sn, Is;
async function Tn() {
    return Is ?? (Is = (async () => {
        var a;
        const t = O.get().createCanvas(1, 1).getContext("webgl");
        if (!t)
            return "premultiply-alpha-on-upload";
        const e = await new Promise(o => {
            const h = document.createElement("video");
            h.onloadeddata = () => o(h),
            h.onerror = () => o(null),
            h.autoplay = !1,
            h.crossOrigin = "anonymous",
            h.preload = "auto",
            h.src = "data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",
            h.load()
        }
        );
        if (!e)
            return "premultiply-alpha-on-upload";
        const i = t.createTexture();
        t.bindTexture(t.TEXTURE_2D, i);
        const r = t.createFramebuffer();
        t.bindFramebuffer(t.FRAMEBUFFER, r),
        t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, i, 0),
        t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1),
        t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL, t.NONE),
        t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, e);
        const n = new Uint8Array(4);
        return t.readPixels(0, 0, 1, 1, t.RGBA, t.UNSIGNED_BYTE, n),
        t.deleteFramebuffer(r),
        t.deleteTexture(i),
        (a = t.getExtension("WEBGL_lose_context")) == null || a.loseContext(),
        n[0] <= n[3] ? "premultiplied-alpha" : "premultiply-alpha-on-upload"
    }
    )()),
    Is
}
const fs = class Cn extends xt {
    constructor(t) {
        super(t),
        this.isReady = !1,
        this.uploadMethodId = "video",
        t = {
            ...Cn.defaultOptions,
            ...t
        },
        this._autoUpdate = !0,
        this._isConnectedToTicker = !1,
        this._updateFPS = t.updateFPS || 0,
        this._msToNextUpdate = 0,
        this.autoPlay = t.autoPlay !== !1,
        this.alphaMode = t.alphaMode ?? "premultiply-alpha-on-upload",
        this._videoFrameRequestCallback = this._videoFrameRequestCallback.bind(this),
        this._videoFrameRequestCallbackHandle = null,
        this._load = null,
        this._resolve = null,
        this._reject = null,
        this._onCanPlay = this._onCanPlay.bind(this),
        this._onCanPlayThrough = this._onCanPlayThrough.bind(this),
        this._onError = this._onError.bind(this),
        this._onPlayStart = this._onPlayStart.bind(this),
        this._onPlayStop = this._onPlayStop.bind(this),
        this._onSeeked = this._onSeeked.bind(this),
        this._onLoadedMetadata = this._onLoadedMetadata.bind(this),
        t.autoLoad !== !1 && this.load()
    }
    updateFrame() {
        if (!this.destroyed) {
            if (this._updateFPS) {
                const t = _t.shared.elapsedMS * this.resource.playbackRate;
                this._msToNextUpdate = Math.floor(this._msToNextUpdate - t)
            }
            (!this._updateFPS || this._msToNextUpdate <= 0) && (this._msToNextUpdate = this._updateFPS ? Math.floor(1e3 / this._updateFPS) : 0),
            this.isValid && this.update()
        }
    }
    _videoFrameRequestCallback() {
        this.updateFrame(),
        this.destroyed ? this._videoFrameRequestCallbackHandle = null : this._videoFrameRequestCallbackHandle = this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)
    }
    get isValid() {
        return !!this.resource.videoWidth && !!this.resource.videoHeight
    }
    async load() {
        if (this._load)
            return this._load;
        const t = this.resource
          , e = this.options;
        return (t.readyState === t.HAVE_ENOUGH_DATA || t.readyState === t.HAVE_FUTURE_DATA) && t.width && t.height && (t.complete = !0),
        t.addEventListener("play", this._onPlayStart),
        t.addEventListener("pause", this._onPlayStop),
        t.addEventListener("seeked", this._onSeeked),
        this._isSourceReady() ? this._mediaReady() : (e.preload || t.addEventListener("canplay", this._onCanPlay),
        t.addEventListener("canplaythrough", this._onCanPlayThrough),
        t.addEventListener("error", this._onError, !0)),
        this.isValid || t.addEventListener("loadedmetadata", this._onLoadedMetadata),
        this.alphaMode = await Tn(),
        this._load = new Promise( (i, r) => {
            this.isValid ? i(this) : (this._resolve = i,
            this._reject = r,
            e.preloadTimeoutMs !== void 0 && (this._preloadTimeout = setTimeout( () => {
                this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))
            }
            )),
            t.load())
        }
        ),
        this._load
    }
    _onError(t) {
        this.resource.removeEventListener("error", this._onError, !0),
        this.emit("error", t),
        this._reject && (this._reject(t),
        this._reject = null,
        this._resolve = null)
    }
    _isSourcePlaying() {
        const t = this.resource;
        return !t.paused && !t.ended
    }
    _isSourceReady() {
        return this.resource.readyState > 2
    }
    _onPlayStart() {
        this._configureAutoUpdate()
    }
    _onPlayStop() {
        this._configureAutoUpdate()
    }
    _onSeeked() {
        this._autoUpdate && !this._isSourcePlaying() && (this._msToNextUpdate = 0,
        this.updateFrame(),
        this._msToNextUpdate = 0)
    }
    _onLoadedMetadata() {
        this.isValid && this._mediaReady()
    }
    _onCanPlay() {
        this.resource.removeEventListener("canplay", this._onCanPlay),
        this._mediaReady()
    }
    _onCanPlayThrough() {
        this.resource.removeEventListener("canplaythrough", this._onCanPlayThrough),
        this._preloadTimeout && (clearTimeout(this._preloadTimeout),
        this._preloadTimeout = void 0),
        this._mediaReady()
    }
    _mediaReady() {
        const t = this.resource;
        this.isValid && (this.isReady = !0,
        this.resize(t.videoWidth, t.videoHeight)),
        this._msToNextUpdate = 0,
        this.updateFrame(),
        this._msToNextUpdate = 0,
        this._resolve && this.isValid && (this._resolve(this),
        this._resolve = null,
        this._reject = null),
        this._isSourcePlaying() ? this._onPlayStart() : this.autoPlay && this.resource.play()
    }
    destroy() {
        this._configureAutoUpdate();
        const t = this.resource;
        t && (t.removeEventListener("play", this._onPlayStart),
        t.removeEventListener("pause", this._onPlayStop),
        t.removeEventListener("seeked", this._onSeeked),
        t.removeEventListener("canplay", this._onCanPlay),
        t.removeEventListener("canplaythrough", this._onCanPlayThrough),
        t.removeEventListener("loadedmetadata", this._onLoadedMetadata),
        t.removeEventListener("error", this._onError, !0),
        t.pause(),
        t.src = "",
        t.load()),
        super.destroy()
    }
    get autoUpdate() {
        return this._autoUpdate
    }
    set autoUpdate(t) {
        t !== this._autoUpdate && (this._autoUpdate = t,
        this._configureAutoUpdate())
    }
    get updateFPS() {
        return this._updateFPS
    }
    set updateFPS(t) {
        t !== this._updateFPS && (this._updateFPS = t,
        this._configureAutoUpdate())
    }
    _configureAutoUpdate() {
        this._autoUpdate && this._isSourcePlaying() ? !this._updateFPS && this.resource.requestVideoFrameCallback ? (this._isConnectedToTicker && (_t.shared.remove(this.updateFrame, this),
        this._isConnectedToTicker = !1,
        this._msToNextUpdate = 0),
        this._videoFrameRequestCallbackHandle === null && (this._videoFrameRequestCallbackHandle = this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))) : (this._videoFrameRequestCallbackHandle !== null && (this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),
        this._videoFrameRequestCallbackHandle = null),
        this._isConnectedToTicker || (_t.shared.add(this.updateFrame, this),
        this._isConnectedToTicker = !0,
        this._msToNextUpdate = 0)) : (this._videoFrameRequestCallbackHandle !== null && (this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),
        this._videoFrameRequestCallbackHandle = null),
        this._isConnectedToTicker && (_t.shared.remove(this.updateFrame, this),
        this._isConnectedToTicker = !1,
        this._msToNextUpdate = 0))
    }
    static test(t) {
        return globalThis.HTMLVideoElement && t instanceof HTMLVideoElement
    }
}
;
fs.extension = I.TextureSource;
fs.defaultOptions = {
    ...xt.defaultOptions,
    autoLoad: !0,
    autoPlay: !0,
    updateFPS: 0,
    crossorigin: !0,
    loop: !1,
    muted: !0,
    playsinline: !0,
    preload: !1
};
fs.MIME_TYPES = {
    ogv: "video/ogg",
    mov: "video/quicktime",
    m4v: "video/mp4"
};
let Ie = fs;
const bt = (s, t, e=!1) => (Array.isArray(s) || (s = [s]),
t ? s.map(i => typeof i == "string" || e ? t(i) : i) : s);
class Eo {
    constructor() {
        this._parsers = [],
        this._cache = new Map,
        this._cacheMap = new Map
    }
    reset() {
        this._cacheMap.clear(),
        this._cache.clear()
    }
    has(t) {
        return this._cache.has(t)
    }
    get(t) {
        const e = this._cache.get(t);
        return e || $(`[Assets] Asset id ${t} was not found in the Cache`),
        e
    }
    set(t, e) {
        const i = bt(t);
        let r;
        for (let h = 0; h < this.parsers.length; h++) {
            const l = this.parsers[h];
            if (l.test(e)) {
                r = l.getCacheableAssets(i, e);
                break
            }
        }
        const n = new Map(Object.entries(r || {}));
        r || i.forEach(h => {
            n.set(h, e)
        }
        );
        const a = [...n.keys()]
          , o = {
            cacheKeys: a,
            keys: i
        };
        i.forEach(h => {
            this._cacheMap.set(h, o)
        }
        ),
        a.forEach(h => {
            const l = r ? r[h] : e;
            this._cache.has(h) && this._cache.get(h) !== l && $("[Cache] already has key:", h),
            this._cache.set(h, n.get(h))
        }
        )
    }
    remove(t) {
        if (!this._cacheMap.has(t)) {
            $(`[Assets] Asset id ${t} was not found in the Cache`);
            return
        }
        const e = this._cacheMap.get(t);
        e.cacheKeys.forEach(r => {
            this._cache.delete(r)
        }
        ),
        e.keys.forEach(r => {
            this._cacheMap.delete(r)
        }
        )
    }
    get parsers() {
        return this._parsers
    }
}
const st = new Eo
  , Zs = [];
Y.handleByList(I.TextureSource, Zs);
function Pn(s={}) {
    const t = s && s.resource
      , e = t ? s.resource : s
      , i = t ? s : {
        resource: s
    };
    for (let r = 0; r < Zs.length; r++) {
        const n = Zs[r];
        if (n.test(e))
            return new n(i)
    }
    throw new Error(`Could not find a source type for resource: ${i.resource}`)
}
function Io(s={}, t=!1) {
    const e = s && s.resource
      , i = e ? s.resource : s
      , r = e ? s : {
        resource: s
    };
    if (!t && st.has(i))
        return st.get(i);
    const n = new W({
        source: Pn(r)
    });
    return n.on("destroy", () => {
        st.has(i) && st.remove(i)
    }
    ),
    t || st.set(i, n),
    n
}
function Ro(s, t=!1) {
    return typeof s == "string" ? st.get(s) : s instanceof xt ? new W({
        source: s
    }) : Io(s, t)
}
W.from = Ro;
xt.from = Pn;
Y.add(wn, An, vn, Ie, pe, gi, fi);
var Dt = (s => (s[s.Low = 0] = "Low",
s[s.Normal = 1] = "Normal",
s[s.High = 2] = "High",
s))(Dt || {});
function yt(s) {
    if (typeof s != "string")
        throw new TypeError(`Path must be a string. Received ${JSON.stringify(s)}`)
}
function _e(s) {
    return s.split("?")[0].split("#")[0]
}
function Bo(s) {
    return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
}
function Fo(s, t, e) {
    return s.replace(new RegExp(Bo(t),"g"), e)
}
function Lo(s, t) {
    let e = ""
      , i = 0
      , r = -1
      , n = 0
      , a = -1;
    for (let o = 0; o <= s.length; ++o) {
        if (o < s.length)
            a = s.charCodeAt(o);
        else {
            if (a === 47)
                break;
            a = 47
        }
        if (a === 47) {
            if (!(r === o - 1 || n === 1))
                if (r !== o - 1 && n === 2) {
                    if (e.length < 2 || i !== 2 || e.charCodeAt(e.length - 1) !== 46 || e.charCodeAt(e.length - 2) !== 46) {
                        if (e.length > 2) {
                            const h = e.lastIndexOf("/");
                            if (h !== e.length - 1) {
                                h === -1 ? (e = "",
                                i = 0) : (e = e.slice(0, h),
                                i = e.length - 1 - e.lastIndexOf("/")),
                                r = o,
                                n = 0;
                                continue
                            }
                        } else if (e.length === 2 || e.length === 1) {
                            e = "",
                            i = 0,
                            r = o,
                            n = 0;
                            continue
                        }
                    }
                } else
                    e.length > 0 ? e += `/${s.slice(r + 1, o)}` : e = s.slice(r + 1, o),
                    i = o - r - 1;
            r = o,
            n = 0
        } else
            a === 46 && n !== -1 ? ++n : n = -1
    }
    return e
}
const lt = {
    toPosix(s) {
        return Fo(s, "\\", "/")
    },
    isUrl(s) {
        return /^https?:/.test(this.toPosix(s))
    },
    isDataUrl(s) {
        return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(s)
    },
    isBlobUrl(s) {
        return s.startsWith("blob:")
    },
    hasProtocol(s) {
        return /^[^/:]+:/.test(this.toPosix(s))
    },
    getProtocol(s) {
        yt(s),
        s = this.toPosix(s);
        const t = /^file:\/\/\//.exec(s);
        if (t)
            return t[0];
        const e = /^[^/:]+:\/{0,2}/.exec(s);
        return e ? e[0] : ""
    },
    toAbsolute(s, t, e) {
        if (yt(s),
        this.isDataUrl(s) || this.isBlobUrl(s))
            return s;
        const i = _e(this.toPosix(t ?? O.get().getBaseUrl()))
          , r = _e(this.toPosix(e ?? this.rootname(i)));
        return s = this.toPosix(s),
        s.startsWith("/") ? lt.join(r, s.slice(1)) : this.isAbsolute(s) ? s : this.join(i, s)
    },
    normalize(s) {
        if (yt(s),
        s.length === 0)
            return ".";
        if (this.isDataUrl(s) || this.isBlobUrl(s))
            return s;
        s = this.toPosix(s);
        let t = "";
        const e = s.startsWith("/");
        this.hasProtocol(s) && (t = this.rootname(s),
        s = s.slice(t.length));
        const i = s.endsWith("/");
        return s = Lo(s),
        s.length > 0 && i && (s += "/"),
        e ? `/${s}` : t + s
    },
    isAbsolute(s) {
        return yt(s),
        s = this.toPosix(s),
        this.hasProtocol(s) ? !0 : s.startsWith("/")
    },
    join(...s) {
        if (s.length === 0)
            return ".";
        let t;
        for (let e = 0; e < s.length; ++e) {
            const i = s[e];
            if (yt(i),
            i.length > 0)
                if (t === void 0)
                    t = i;
                else {
                    const r = s[e - 1] ?? "";
                    this.joinExtensions.includes(this.extname(r).toLowerCase()) ? t += `/../${i}` : t += `/${i}`
                }
        }
        return t === void 0 ? "." : this.normalize(t)
    },
    dirname(s) {
        if (yt(s),
        s.length === 0)
            return ".";
        s = this.toPosix(s);
        let t = s.charCodeAt(0);
        const e = t === 47;
        let i = -1
          , r = !0;
        const n = this.getProtocol(s)
          , a = s;
        s = s.slice(n.length);
        for (let o = s.length - 1; o >= 1; --o)
            if (t = s.charCodeAt(o),
            t === 47) {
                if (!r) {
                    i = o;
                    break
                }
            } else
                r = !1;
        return i === -1 ? e ? "/" : this.isUrl(a) ? n + s : n : e && i === 1 ? "//" : n + s.slice(0, i)
    },
    rootname(s) {
        yt(s),
        s = this.toPosix(s);
        let t = "";
        if (s.startsWith("/") ? t = "/" : t = this.getProtocol(s),
        this.isUrl(s)) {
            const e = s.indexOf("/", t.length);
            e !== -1 ? t = s.slice(0, e) : t = s,
            t.endsWith("/") || (t += "/")
        }
        return t
    },
    basename(s, t) {
        yt(s),
        t && yt(t),
        s = _e(this.toPosix(s));
        let e = 0, i = -1, r = !0, n;
        if (t !== void 0 && t.length > 0 && t.length <= s.length) {
            if (t.length === s.length && t === s)
                return "";
            let a = t.length - 1
              , o = -1;
            for (n = s.length - 1; n >= 0; --n) {
                const h = s.charCodeAt(n);
                if (h === 47) {
                    if (!r) {
                        e = n + 1;
                        break
                    }
                } else
                    o === -1 && (r = !1,
                    o = n + 1),
                    a >= 0 && (h === t.charCodeAt(a) ? --a === -1 && (i = n) : (a = -1,
                    i = o))
            }
            return e === i ? i = o : i === -1 && (i = s.length),
            s.slice(e, i)
        }
        for (n = s.length - 1; n >= 0; --n)
            if (s.charCodeAt(n) === 47) {
                if (!r) {
                    e = n + 1;
                    break
                }
            } else
                i === -1 && (r = !1,
                i = n + 1);
        return i === -1 ? "" : s.slice(e, i)
    },
    extname(s) {
        yt(s),
        s = _e(this.toPosix(s));
        let t = -1
          , e = 0
          , i = -1
          , r = !0
          , n = 0;
        for (let a = s.length - 1; a >= 0; --a) {
            const o = s.charCodeAt(a);
            if (o === 47) {
                if (!r) {
                    e = a + 1;
                    break
                }
                continue
            }
            i === -1 && (r = !1,
            i = a + 1),
            o === 46 ? t === -1 ? t = a : n !== 1 && (n = 1) : t !== -1 && (n = -1)
        }
        return t === -1 || i === -1 || n === 0 || n === 1 && t === i - 1 && t === e + 1 ? "" : s.slice(t, i)
    },
    parse(s) {
        yt(s);
        const t = {
            root: "",
            dir: "",
            base: "",
            ext: "",
            name: ""
        };
        if (s.length === 0)
            return t;
        s = _e(this.toPosix(s));
        let e = s.charCodeAt(0);
        const i = this.isAbsolute(s);
        let r;
        t.root = this.rootname(s),
        i || this.hasProtocol(s) ? r = 1 : r = 0;
        let n = -1
          , a = 0
          , o = -1
          , h = !0
          , l = s.length - 1
          , c = 0;
        for (; l >= r; --l) {
            if (e = s.charCodeAt(l),
            e === 47) {
                if (!h) {
                    a = l + 1;
                    break
                }
                continue
            }
            o === -1 && (h = !1,
            o = l + 1),
            e === 46 ? n === -1 ? n = l : c !== 1 && (c = 1) : n !== -1 && (c = -1)
        }
        return n === -1 || o === -1 || c === 0 || c === 1 && n === o - 1 && n === a + 1 ? o !== -1 && (a === 0 && i ? t.base = t.name = s.slice(1, o) : t.base = t.name = s.slice(a, o)) : (a === 0 && i ? (t.name = s.slice(1, n),
        t.base = s.slice(1, o)) : (t.name = s.slice(a, n),
        t.base = s.slice(a, o)),
        t.ext = s.slice(n, o)),
        t.dir = this.dirname(s),
        t
    },
    sep: "/",
    delimiter: ":",
    joinExtensions: [".html"]
};
function Mn(s, t, e, i, r) {
    const n = t[e];
    for (let a = 0; a < n.length; a++) {
        const o = n[a];
        e < t.length - 1 ? Mn(s.replace(i[e], o), t, e + 1, i, r) : r.push(s.replace(i[e], o))
    }
}
function Go(s) {
    const t = /\{(.*?)\}/g
      , e = s.match(t)
      , i = [];
    if (e) {
        const r = [];
        e.forEach(n => {
            const a = n.substring(1, n.length - 1).split(",");
            r.push(a)
        }
        ),
        Mn(s, r, 0, e, i)
    } else
        i.push(s);
    return i
}
const os = s => !Array.isArray(s);
class me {
    constructor() {
        this._defaultBundleIdentifierOptions = {
            connector: "-",
            createBundleAssetId: (t, e) => `${t}${this._bundleIdConnector}${e}`,
            extractAssetIdFromBundle: (t, e) => e.replace(`${t}${this._bundleIdConnector}`, "")
        },
        this._bundleIdConnector = this._defaultBundleIdentifierOptions.connector,
        this._createBundleAssetId = this._defaultBundleIdentifierOptions.createBundleAssetId,
        this._extractAssetIdFromBundle = this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,
        this._assetMap = {},
        this._preferredOrder = [],
        this._parsers = [],
        this._resolverHash = {},
        this._bundles = {}
    }
    setBundleIdentifier(t) {
        if (this._bundleIdConnector = t.connector ?? this._bundleIdConnector,
        this._createBundleAssetId = t.createBundleAssetId ?? this._createBundleAssetId,
        this._extractAssetIdFromBundle = t.extractAssetIdFromBundle ?? this._extractAssetIdFromBundle,
        this._extractAssetIdFromBundle("foo", this._createBundleAssetId("foo", "bar")) !== "bar")
            throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")
    }
    prefer(...t) {
        t.forEach(e => {
            this._preferredOrder.push(e),
            e.priority || (e.priority = Object.keys(e.params))
        }
        ),
        this._resolverHash = {}
    }
    set basePath(t) {
        this._basePath = t
    }
    get basePath() {
        return this._basePath
    }
    set rootPath(t) {
        this._rootPath = t
    }
    get rootPath() {
        return this._rootPath
    }
    get parsers() {
        return this._parsers
    }
    reset() {
        this.setBundleIdentifier(this._defaultBundleIdentifierOptions),
        this._assetMap = {},
        this._preferredOrder = [],
        this._resolverHash = {},
        this._rootPath = null,
        this._basePath = null,
        this._manifest = null,
        this._bundles = {},
        this._defaultSearchParams = null
    }
    setDefaultSearchParams(t) {
        if (typeof t == "string")
            this._defaultSearchParams = t;
        else {
            const e = t;
            this._defaultSearchParams = Object.keys(e).map(i => `${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")
        }
    }
    getAlias(t) {
        const {alias: e, src: i} = t;
        return bt(e || i, n => typeof n == "string" ? n : Array.isArray(n) ? n.map(a => (a == null ? void 0 : a.src) ?? a) : n != null && n.src ? n.src : n, !0)
    }
    removeAlias(t, e) {
        this._assetMap[t] && (e && e !== this._resolverHash[t] || (delete this._resolverHash[t],
        delete this._assetMap[t]))
    }
    addManifest(t) {
        this._manifest && $("[Resolver] Manifest already exists, this will be overwritten"),
        this._manifest = t,
        t.bundles.forEach(e => {
            this.addBundle(e.name, e.assets)
        }
        )
    }
    addBundle(t, e) {
        const i = [];
        let r = e;
        Array.isArray(e) || (r = Object.entries(e).map( ([n,a]) => typeof a == "string" || Array.isArray(a) ? {
            alias: n,
            src: a
        } : {
            alias: n,
            ...a
        })),
        r.forEach(n => {
            const a = n.src
              , o = n.alias;
            let h;
            if (typeof o == "string") {
                const l = this._createBundleAssetId(t, o);
                i.push(l),
                h = [o, l]
            } else {
                const l = o.map(c => this._createBundleAssetId(t, c));
                i.push(...l),
                h = [...o, ...l]
            }
            this.add({
                ...n,
                alias: h,
                src: a
            })
        }
        ),
        this._bundles[t] = i
    }
    add(t) {
        const e = [];
        Array.isArray(t) ? e.push(...t) : e.push(t);
        let i;
        i = n => {
            this.hasKey(n) && $(`[Resolver] already has key: ${n} overwriting`)
        }
        ,
        bt(e).forEach(n => {
            const {src: a} = n;
            let {data: o, format: h, loadParser: l, parser: c} = n;
            const u = bt(a).map(m => typeof m == "string" ? Go(m) : Array.isArray(m) ? m : [m])
              , d = this.getAlias(n);
            Array.isArray(d) ? d.forEach(i) : i(d);
            const f = []
              , p = m => {
                const g = this._parsers.find(x => x.test(m));
                return {
                    src: m,
                    ...g == null ? void 0 : g.parse(m)
                }
            }
            ;
            u.forEach(m => {
                m.forEach(g => {
                    let x = {};
                    if (typeof g != "object" ? x = p(g) : (o = g.data ?? o,
                    h = g.format ?? h,
                    (g.loadParser || g.parser) && (l = g.loadParser ?? l,
                    c = g.parser ?? c),
                    x = {
                        ...p(g.src),
                        ...g
                    }),
                    !d)
                        throw new Error(`[Resolver] alias is undefined for this asset: ${x.src}`);
                    x = this._buildResolvedAsset(x, {
                        aliases: d,
                        data: o,
                        format: h,
                        loadParser: l,
                        parser: c,
                        progressSize: n.progressSize
                    }),
                    f.push(x)
                }
                )
            }
            ),
            d.forEach(m => {
                this._assetMap[m] = f
            }
            )
        }
        )
    }
    resolveBundle(t) {
        const e = os(t);
        t = bt(t);
        const i = {};
        return t.forEach(r => {
            const n = this._bundles[r];
            if (n) {
                const a = this.resolve(n)
                  , o = {};
                for (const h in a) {
                    const l = a[h];
                    o[this._extractAssetIdFromBundle(r, h)] = l
                }
                i[r] = o
            }
        }
        ),
        e ? i[t[0]] : i
    }
    resolveUrl(t) {
        const e = this.resolve(t);
        if (typeof t != "string") {
            const i = {};
            for (const r in e)
                i[r] = e[r].src;
            return i
        }
        return e.src
    }
    resolve(t) {
        const e = os(t);
        t = bt(t);
        const i = {};
        return t.forEach(r => {
            if (!this._resolverHash[r])
                if (this._assetMap[r]) {
                    let n = this._assetMap[r];
                    const a = this._getPreferredOrder(n);
                    a == null || a.priority.forEach(o => {
                        a.params[o].forEach(h => {
                            const l = n.filter(c => c[o] ? c[o] === h : !1);
                            l.length && (n = l)
                        }
                        )
                    }
                    ),
                    this._resolverHash[r] = n[0]
                } else
                    this._resolverHash[r] = this._buildResolvedAsset({
                        alias: [r],
                        src: r
                    }, {});
            i[r] = this._resolverHash[r]
        }
        ),
        e ? i[t[0]] : i
    }
    hasKey(t) {
        return !!this._assetMap[t]
    }
    hasBundle(t) {
        return !!this._bundles[t]
    }
    _getPreferredOrder(t) {
        for (let e = 0; e < t.length; e++) {
            const i = t[e]
              , r = this._preferredOrder.find(n => n.params.format.includes(i.format));
            if (r)
                return r
        }
        return this._preferredOrder[0]
    }
    _appendDefaultSearchParams(t) {
        if (!this._defaultSearchParams)
            return t;
        const e = /\?/.test(t) ? "&" : "?";
        return `${t}${e}${this._defaultSearchParams}`
    }
    _buildResolvedAsset(t, e) {
        const {aliases: i, data: r, loadParser: n, parser: a, format: o, progressSize: h} = e;
        return (this._basePath || this._rootPath) && (t.src = lt.toAbsolute(t.src, this._basePath, this._rootPath)),
        t.alias = i ?? t.alias ?? [t.src],
        t.src = this._appendDefaultSearchParams(t.src),
        t.data = {
            ...r || {},
            ...t.data
        },
        t.loadParser = n ?? t.loadParser,
        t.parser = a ?? t.parser,
        t.format = o ?? t.format ?? Do(t.src),
        h !== void 0 && (t.progressSize = h),
        t
    }
}
me.RETINA_PREFIX = /@([0-9\.]+)x/;
function Do(s) {
    return s.split(".").pop().split("?").shift().split("#").shift()
}
const Qs = (s, t) => {
    const e = t.split("?")[1];
    return e && (s += `?${e}`),
    s
}
  , kn = class Me {
    constructor(t, e) {
        this.linkedSheets = [];
        let i = t;
        (t == null ? void 0 : t.source)instanceof xt && (i = {
            texture: t,
            data: e
        });
        const {texture: r, data: n, cachePrefix: a=""} = i;
        this.cachePrefix = a,
        this._texture = r instanceof W ? r : null,
        this.textureSource = r.source,
        this.textures = {},
        this.animations = {},
        this.data = n;
        const o = parseFloat(n.meta.scale);
        o ? (this.resolution = o,
        r.source.resolution = this.resolution) : this.resolution = r.source._resolution,
        this._frames = this.data.frames,
        this._frameKeys = Object.keys(this._frames),
        this._batchIndex = 0,
        this._callback = null
    }
    parse() {
        return new Promise(t => {
            this._callback = t,
            this._batchIndex = 0,
            this._frameKeys.length <= Me.BATCH_SIZE ? (this._processFrames(0),
            this._processAnimations(),
            this._parseComplete()) : this._nextBatch()
        }
        )
    }
    parseSync() {
        return this._processFrames(0, !0),
        this._processAnimations(),
        this.textures
    }
    _processFrames(t, e=!1) {
        let i = t;
        const r = e ? 1 / 0 : Me.BATCH_SIZE;
        for (; i - t < r && i < this._frameKeys.length; ) {
            const n = this._frameKeys[i]
              , a = this._frames[n]
              , o = a.frame;
            if (o) {
                let h = null
                  , l = null;
                const c = a.trimmed !== !1 && a.sourceSize ? a.sourceSize : a.frame
                  , u = new Z(0,0,Math.floor(c.w) / this.resolution,Math.floor(c.h) / this.resolution);
                a.rotated ? h = new Z(Math.floor(o.x) / this.resolution,Math.floor(o.y) / this.resolution,Math.floor(o.h) / this.resolution,Math.floor(o.w) / this.resolution) : h = new Z(Math.floor(o.x) / this.resolution,Math.floor(o.y) / this.resolution,Math.floor(o.w) / this.resolution,Math.floor(o.h) / this.resolution),
                a.trimmed !== !1 && a.spriteSourceSize && (l = new Z(Math.floor(a.spriteSourceSize.x) / this.resolution,Math.floor(a.spriteSourceSize.y) / this.resolution,Math.floor(o.w) / this.resolution,Math.floor(o.h) / this.resolution)),
                this.textures[n] = new W({
                    source: this.textureSource,
                    frame: h,
                    orig: u,
                    trim: l,
                    rotate: a.rotated ? 2 : 0,
                    defaultAnchor: a.anchor,
                    defaultBorders: a.borders,
                    label: n.toString()
                })
            }
            i++
        }
    }
    _processAnimations() {
        const t = this.data.animations || {};
        for (const e in t) {
            this.animations[e] = [];
            for (let i = 0; i < t[e].length; i++) {
                const r = t[e][i];
                this.animations[e].push(this.textures[r])
            }
        }
    }
    _parseComplete() {
        const t = this._callback;
        this._callback = null,
        this._batchIndex = 0,
        t.call(this, this.textures)
    }
    _nextBatch() {
        this._processFrames(this._batchIndex * Me.BATCH_SIZE),
        this._batchIndex++,
        setTimeout( () => {
            this._batchIndex * Me.BATCH_SIZE < this._frameKeys.length ? this._nextBatch() : (this._processAnimations(),
            this._parseComplete())
        }
        , 0)
    }
    destroy(t=!1) {
        var e;
        for (const i in this.textures)
            this.textures[i].destroy();
        this._frames = null,
        this._frameKeys = null,
        this.data = null,
        this.textures = null,
        t && ((e = this._texture) == null || e.destroy(),
        this.textureSource.destroy()),
        this._texture = null,
        this.textureSource = null,
        this.linkedSheets = []
    }
}
;
kn.BATCH_SIZE = 1e3;
let Yi = kn;
const zo = ["jpg", "png", "jpeg", "avif", "webp", "basis", "etc2", "bc7", "bc6h", "bc5", "bc4", "bc3", "bc2", "bc1", "eac", "astc"];
function En(s, t, e) {
    const i = {};
    if (s.forEach(r => {
        i[r] = t
    }
    ),
    Object.keys(t.textures).forEach(r => {
        i[`${t.cachePrefix}${r}`] = t.textures[r]
    }
    ),
    !e) {
        const r = lt.dirname(s[0]);
        t.linkedSheets.forEach( (n, a) => {
            const o = En([`${r}/${t.data.meta.related_multi_packs[a]}`], n, !0);
            Object.assign(i, o)
        }
        )
    }
    return i
}
const Wo = {
    extension: I.Asset,
    cache: {
        test: s => s instanceof Yi,
        getCacheableAssets: (s, t) => En(s, t, !1)
    },
    resolver: {
        extension: {
            type: I.ResolveParser,
            name: "resolveSpritesheet"
        },
        test: s => {
            const e = s.split("?")[0].split(".")
              , i = e.pop()
              , r = e.pop();
            return i === "json" && zo.includes(r)
        }
        ,
        parse: s => {
            var e;
            const t = s.split(".");
            return {
                resolution: parseFloat(((e = me.RETINA_PREFIX.exec(s)) == null ? void 0 : e[1]) ?? "1"),
                format: t[t.length - 2],
                src: s
            }
        }
    },
    loader: {
        name: "spritesheetLoader",
        id: "spritesheet",
        extension: {
            type: I.LoadParser,
            priority: Dt.Normal,
            name: "spritesheetLoader"
        },
        async testParse(s, t) {
            return lt.extname(t.src).toLowerCase() === ".json" && !!s.frames
        },
        async parse(s, t, e) {
            var u, d;
            const {texture: i, imageFilename: r, textureOptions: n, cachePrefix: a} = (t == null ? void 0 : t.data) ?? {};
            let o = lt.dirname(t.src);
            o && o.lastIndexOf("/") !== o.length - 1 && (o += "/");
            let h;
            if (i instanceof W)
                h = i;
            else {
                const f = Qs(o + (r ?? s.meta.image), t.src);
                h = (await e.load([{
                    src: f,
                    data: n
                }]))[f]
            }
            const l = new Yi({
                texture: h.source,
                data: s,
                cachePrefix: a
            });
            await l.parse();
            const c = (u = s == null ? void 0 : s.meta) == null ? void 0 : u.related_multi_packs;
            if (Array.isArray(c)) {
                const f = [];
                for (const m of c) {
                    if (typeof m != "string")
                        continue;
                    let g = o + m;
                    (d = t.data) != null && d.ignoreMultiPack || (g = Qs(g, t.src),
                    f.push(e.load({
                        src: g,
                        data: {
                            textureOptions: n,
                            ignoreMultiPack: !0
                        }
                    })))
                }
                const p = await Promise.all(f);
                l.linkedSheets = p,
                p.forEach(m => {
                    m.linkedSheets = [l].concat(l.linkedSheets.filter(g => g !== m))
                }
                )
            }
            return l
        },
        async unload(s, t, e) {
            await e.unload(s.textureSource._sourceOrigin),
            s.destroy(!1)
        }
    }
};
Y.add(Wo);
const Rs = Object.create(null)
  , Xi = Object.create(null);
function mi(s, t) {
    let e = Xi[s];
    return e === void 0 && (Rs[t] === void 0 && (Rs[t] = 1),
    Xi[s] = e = Rs[t]++),
    e
}
let ee;
function In() {
    return (!ee || ee != null && ee.isContextLost()) && (ee = O.get().createCanvas().getContext("webgl", {})),
    ee
}
let qe;
function Oo() {
    if (!qe) {
        qe = "mediump";
        const s = In();
        s && s.getShaderPrecisionFormat && (qe = s.getShaderPrecisionFormat(s.FRAGMENT_SHADER, s.HIGH_FLOAT).precision ? "highp" : "mediump")
    }
    return qe
}
function Uo(s, t, e) {
    return t ? s : e ? (s = s.replace("out vec4 finalColor;", ""),
    `

        #ifdef GL_ES // This checks if it is WebGL1
        #define in varying
        #define finalColor gl_FragColor
        #define texture texture2D
        #endif
        ${s}
        `) : `

        #ifdef GL_ES // This checks if it is WebGL1
        #define in attribute
        #define out varying
        #endif
        ${s}
        `
}
function No(s, t, e) {
    const i = e ? t.maxSupportedFragmentPrecision : t.maxSupportedVertexPrecision;
    if (s.substring(0, 9) !== "precision") {
        let r = e ? t.requestedFragmentPrecision : t.requestedVertexPrecision;
        return r === "highp" && i !== "highp" && (r = "mediump"),
        `precision ${r} float;
${s}`
    } else if (i !== "highp" && s.substring(0, 15) === "precision highp")
        return s.replace("precision highp", "precision mediump");
    return s
}
function Ho(s, t) {
    return t ? `#version 300 es
${s}` : s
}
const $o = {}
  , Vo = {};
function jo(s, {name: t="pixi-program"}, e=!0) {
    t = t.replace(/\s+/g, "-"),
    t += e ? "-fragment" : "-vertex";
    const i = e ? $o : Vo;
    return i[t] ? (i[t]++,
    t += `-${i[t]}`) : i[t] = 1,
    s.indexOf("#define SHADER_NAME") !== -1 ? s : `${`#define SHADER_NAME ${t}`}
${s}`
}
function Yo(s, t) {
    return t ? s.replace("#version 300 es", "") : s
}
const Bs = {
    stripVersion: Yo,
    ensurePrecision: No,
    addProgramDefines: Uo,
    setProgramName: jo,
    insertVersion: Ho
}
  , be = Object.create(null)
  , Rn = class Js {
    constructor(t) {
        t = {
            ...Js.defaultOptions,
            ...t
        };
        const e = t.fragment.indexOf("#version 300 es") !== -1
          , i = {
            stripVersion: e,
            ensurePrecision: {
                requestedFragmentPrecision: t.preferredFragmentPrecision,
                requestedVertexPrecision: t.preferredVertexPrecision,
                maxSupportedVertexPrecision: "highp",
                maxSupportedFragmentPrecision: Oo()
            },
            setProgramName: {
                name: t.name
            },
            addProgramDefines: e,
            insertVersion: e
        };
        let r = t.fragment
          , n = t.vertex;
        Object.keys(Bs).forEach(a => {
            const o = i[a];
            r = Bs[a](r, o, !0),
            n = Bs[a](n, o, !1)
        }
        ),
        this.fragment = r,
        this.vertex = n,
        this.transformFeedbackVaryings = t.transformFeedbackVaryings,
        this._key = mi(`${this.vertex}:${this.fragment}`, "gl-program")
    }
    destroy() {
        this.fragment = null,
        this.vertex = null,
        this._attributeData = null,
        this._uniformData = null,
        this._uniformBlockData = null,
        this.transformFeedbackVaryings = null,
        be[this._cacheKey] = null
    }
    static from(t) {
        const e = `${t.vertex}:${t.fragment}`;
        return be[e] || (be[e] = new Js(t),
        be[e]._cacheKey = e),
        be[e]
    }
}
;
Rn.defaultOptions = {
    preferredVertexPrecision: "highp",
    preferredFragmentPrecision: "mediump"
};
let Bn = Rn;
const qi = {
    uint8x2: {
        size: 2,
        stride: 2,
        normalised: !1
    },
    uint8x4: {
        size: 4,
        stride: 4,
        normalised: !1
    },
    sint8x2: {
        size: 2,
        stride: 2,
        normalised: !1
    },
    sint8x4: {
        size: 4,
        stride: 4,
        normalised: !1
    },
    unorm8x2: {
        size: 2,
        stride: 2,
        normalised: !0
    },
    unorm8x4: {
        size: 4,
        stride: 4,
        normalised: !0
    },
    snorm8x2: {
        size: 2,
        stride: 2,
        normalised: !0
    },
    snorm8x4: {
        size: 4,
        stride: 4,
        normalised: !0
    },
    uint16x2: {
        size: 2,
        stride: 4,
        normalised: !1
    },
    uint16x4: {
        size: 4,
        stride: 8,
        normalised: !1
    },
    sint16x2: {
        size: 2,
        stride: 4,
        normalised: !1
    },
    sint16x4: {
        size: 4,
        stride: 8,
        normalised: !1
    },
    unorm16x2: {
        size: 2,
        stride: 4,
        normalised: !0
    },
    unorm16x4: {
        size: 4,
        stride: 8,
        normalised: !0
    },
    snorm16x2: {
        size: 2,
        stride: 4,
        normalised: !0
    },
    snorm16x4: {
        size: 4,
        stride: 8,
        normalised: !0
    },
    float16x2: {
        size: 2,
        stride: 4,
        normalised: !1
    },
    float16x4: {
        size: 4,
        stride: 8,
        normalised: !1
    },
    float32: {
        size: 1,
        stride: 4,
        normalised: !1
    },
    float32x2: {
        size: 2,
        stride: 8,
        normalised: !1
    },
    float32x3: {
        size: 3,
        stride: 12,
        normalised: !1
    },
    float32x4: {
        size: 4,
        stride: 16,
        normalised: !1
    },
    uint32: {
        size: 1,
        stride: 4,
        normalised: !1
    },
    uint32x2: {
        size: 2,
        stride: 8,
        normalised: !1
    },
    uint32x3: {
        size: 3,
        stride: 12,
        normalised: !1
    },
    uint32x4: {
        size: 4,
        stride: 16,
        normalised: !1
    },
    sint32: {
        size: 1,
        stride: 4,
        normalised: !1
    },
    sint32x2: {
        size: 2,
        stride: 8,
        normalised: !1
    },
    sint32x3: {
        size: 3,
        stride: 12,
        normalised: !1
    },
    sint32x4: {
        size: 4,
        stride: 16,
        normalised: !1
    }
};
function Xo(s) {
    return qi[s] ?? qi.float32
}
const qo = {
    f32: "float32",
    "vec2<f32>": "float32x2",
    "vec3<f32>": "float32x3",
    "vec4<f32>": "float32x4",
    vec2f: "float32x2",
    vec3f: "float32x3",
    vec4f: "float32x4",
    i32: "sint32",
    "vec2<i32>": "sint32x2",
    "vec3<i32>": "sint32x3",
    "vec4<i32>": "sint32x4",
    vec2i: "sint32x2",
    vec3i: "sint32x3",
    vec4i: "sint32x4",
    u32: "uint32",
    "vec2<u32>": "uint32x2",
    "vec3<u32>": "uint32x3",
    "vec4<u32>": "uint32x4",
    vec2u: "uint32x2",
    vec3u: "uint32x3",
    vec4u: "uint32x4",
    bool: "uint32",
    "vec2<bool>": "uint32x2",
    "vec3<bool>": "uint32x3",
    "vec4<bool>": "uint32x4"
}
  , Ki = /@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;
function Zi(s, t) {
    let e;
    for (; (e = Ki.exec(s)) !== null; ) {
        const i = qo[e[3]] ?? "float32";
        t[e[2]] = {
            location: parseInt(e[1], 10),
            format: i,
            stride: Xo(i).stride,
            offset: 0,
            instance: !1,
            start: 0
        }
    }
    Ki.lastIndex = 0
}
function Ko(s) {
    return s.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "")
}
function Zo({source: s, entryPoint: t}) {
    const e = {}
      , i = Ko(s)
      , r = i.indexOf(`fn ${t}(`);
    if (r === -1)
        return e;
    const n = i.indexOf("->", r);
    if (n === -1)
        return e;
    const a = i.substring(r, n);
    if (Zi(a, e),
    Object.keys(e).length === 0) {
        const o = a.match(/\(\s*\w+\s*:\s*(\w+)/);
        if (o) {
            const h = o[1]
              , l = new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s")
              , c = i.match(l);
            c && Zi(c[1], e)
        }
    }
    return e
}
function Fs(s) {
    var u, d;
    const t = /(^|[^/])@(group|binding)\(\d+\)[^;]+;/g
      , e = /@group\((\d+)\)/
      , i = /@binding\((\d+)\)/
      , r = /var(<[^>]+>)? (\w+)/
      , n = /:\s*([\w<>]+)/
      , a = /struct\s+(\w+)\s*{([^}]+)}/g
      , o = /(\w+)\s*:\s*([\w\<\>]+)/g
      , h = /struct\s+(\w+)/
      , l = (u = s.match(t)) == null ? void 0 : u.map(f => ({
        group: parseInt(f.match(e)[1], 10),
        binding: parseInt(f.match(i)[1], 10),
        name: f.match(r)[2],
        isUniform: f.match(r)[1] === "<uniform>",
        type: f.match(n)[1]
    }));
    if (!l)
        return {
            groups: [],
            structs: []
        };
    const c = ((d = s.match(a)) == null ? void 0 : d.map(f => {
        const p = f.match(h)[1]
          , m = f.match(o).reduce( (g, x) => {
            const [y,_] = x.split(":");
            return g[y.trim()] = _.trim(),
            g
        }
        , {});
        return m ? {
            name: p,
            members: m
        } : null
    }
    ).filter( ({name: f}) => l.some(p => p.type === f || p.type.includes(`<${f}>`)))) ?? [];
    return {
        groups: l,
        structs: c
    }
}
var qt = (s => (s[s.VERTEX = 1] = "VERTEX",
s[s.FRAGMENT = 2] = "FRAGMENT",
s[s.COMPUTE = 4] = "COMPUTE",
s))(qt || {});
function Qo({groups: s}) {
    const t = [];
    for (let e = 0; e < s.length; e++) {
        const i = s[e];
        t[i.group] || (t[i.group] = []),
        i.isUniform ? t[i.group].push({
            binding: i.binding,
            visibility: qt.VERTEX | qt.FRAGMENT,
            buffer: {
                type: "uniform"
            }
        }) : i.type === "sampler" ? t[i.group].push({
            binding: i.binding,
            visibility: qt.FRAGMENT,
            sampler: {
                type: "filtering"
            }
        }) : i.type === "texture_2d" || i.type.startsWith("texture_2d<") ? t[i.group].push({
            binding: i.binding,
            visibility: qt.FRAGMENT,
            texture: {
                sampleType: "float",
                viewDimension: "2d",
                multisampled: !1
            }
        }) : i.type === "texture_2d_array" || i.type.startsWith("texture_2d_array<") ? t[i.group].push({
            binding: i.binding,
            visibility: qt.FRAGMENT,
            texture: {
                sampleType: "float",
                viewDimension: "2d-array",
                multisampled: !1
            }
        }) : (i.type === "texture_cube" || i.type.startsWith("texture_cube<")) && t[i.group].push({
            binding: i.binding,
            visibility: qt.FRAGMENT,
            texture: {
                sampleType: "float",
                viewDimension: "cube",
                multisampled: !1
            }
        })
    }
    for (let e = 0; e < t.length; e++)
        t[e] || (t[e] = []);
    return t
}
function Jo({groups: s}) {
    const t = [];
    for (let e = 0; e < s.length; e++) {
        const i = s[e];
        t[i.group] || (t[i.group] = {}),
        t[i.group][i.name] = i.binding
    }
    return t
}
function th(s, t) {
    const e = new Set
      , i = new Set
      , r = [...s.structs, ...t.structs].filter(a => e.has(a.name) ? !1 : (e.add(a.name),
    !0))
      , n = [...s.groups, ...t.groups].filter(a => {
        const o = `${a.name}-${a.binding}`;
        return i.has(o) ? !1 : (i.add(o),
        !0)
    }
    );
    return {
        structs: r,
        groups: n
    }
}
const we = Object.create(null);
class ps {
    constructor(t) {
        var o, h;
        this._layoutKey = 0,
        this._attributeLocationsKey = 0;
        const {fragment: e, vertex: i, layout: r, gpuLayout: n, name: a} = t;
        if (this.name = a,
        this.fragment = e,
        this.vertex = i,
        e.source === i.source) {
            const l = Fs(e.source);
            this.structsAndGroups = l
        } else {
            const l = Fs(i.source)
              , c = Fs(e.source);
            this.structsAndGroups = th(l, c)
        }
        this.layout = r ?? Jo(this.structsAndGroups),
        this.gpuLayout = n ?? Qo(this.structsAndGroups),
        this.autoAssignGlobalUniforms = ((o = this.layout[0]) == null ? void 0 : o.globalUniforms) !== void 0,
        this.autoAssignLocalUniforms = ((h = this.layout[1]) == null ? void 0 : h.localUniforms) !== void 0,
        this._generateProgramKey()
    }
    _generateProgramKey() {
        const {vertex: t, fragment: e} = this
          , i = t.source + e.source + t.entryPoint + e.entryPoint;
        this._layoutKey = mi(i, "program")
    }
    get attributeData() {
        return this._attributeData ?? (this._attributeData = Zo(this.vertex)),
        this._attributeData
    }
    destroy() {
        this.gpuLayout = null,
        this.layout = null,
        this.structsAndGroups = null,
        this.fragment = null,
        this.vertex = null,
        we[this._cacheKey] = null
    }
    static from(t) {
        const e = `${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;
        return we[e] || (we[e] = new ps(t),
        we[e]._cacheKey = e),
        we[e]
    }
}
const Fn = ["f32", "i32", "vec2<f32>", "vec3<f32>", "vec4<f32>", "mat2x2<f32>", "mat3x3<f32>", "mat4x4<f32>", "mat3x2<f32>", "mat4x2<f32>", "mat2x3<f32>", "mat4x3<f32>", "mat2x4<f32>", "mat3x4<f32>", "vec2<i32>", "vec3<i32>", "vec4<i32>"]
  , eh = Fn.reduce( (s, t) => (s[t] = !0,
s), {});
function sh(s, t) {
    switch (s) {
    case "f32":
        return 0;
    case "vec2<f32>":
        return new Float32Array(2 * t);
    case "vec3<f32>":
        return new Float32Array(3 * t);
    case "vec4<f32>":
        return new Float32Array(4 * t);
    case "mat2x2<f32>":
        return new Float32Array([1, 0, 0, 1]);
    case "mat3x3<f32>":
        return new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
    case "mat4x4<f32>":
        return new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
    }
    return null
}
const Ln = class Gn {
    constructor(t, e) {
        this._touched = 0,
        this.uid = q("uniform"),
        this._resourceType = "uniformGroup",
        this._resourceId = q("resource"),
        this.isUniformGroup = !0,
        this._dirtyId = 0,
        this.destroyed = !1,
        e = {
            ...Gn.defaultOptions,
            ...e
        },
        this.uniformStructures = t;
        const i = {};
        for (const r in t) {
            const n = t[r];
            if (n.name = r,
            n.size = n.size ?? 1,
            !eh[n.type]) {
                const a = n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);
                if (a) {
                    const [,o,h] = a;
                    throw new Error(`Uniform type ${n.type} is not supported. Use type: '${o}', size: ${h} instead.`)
                }
                throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${Fn.join(", ")}`)
            }
            n.value ?? (n.value = sh(n.type, n.size)),
            i[r] = n.value
        }
        this.uniforms = i,
        this._dirtyId = 1,
        this.ubo = e.ubo,
        this.isStatic = e.isStatic,
        this._signature = mi(Object.keys(i).map(r => `${r}-${t[r].type}`).join("-"), "uniform-group")
    }
    update() {
        this._dirtyId++
    }
}
;
Ln.defaultOptions = {
    ubo: !1,
    isStatic: !1
};
let Dn = Ln;
class ns {
    constructor(t) {
        this.resources = Object.create(null),
        this._dirty = !0;
        let e = 0;
        for (const i in t) {
            const r = t[i];
            this.setResource(r, e++)
        }
        this._updateKey()
    }
    _updateKey() {
        if (!this._dirty)
            return;
        this._dirty = !1;
        const t = [];
        let e = 0;
        for (const i in this.resources)
            t[e++] = this.resources[i]._resourceId;
        this._key = t.join("|")
    }
    setResource(t, e) {
        var r, n;
        const i = this.resources[e];
        t !== i && ((r = i == null ? void 0 : i.off) == null || r.call(i, "change", this.onResourceChange, this),
        (n = t.on) == null || n.call(t, "change", this.onResourceChange, this),
        this.resources[e] = t,
        this._dirty = !0)
    }
    getResource(t) {
        return this.resources[t]
    }
    _touch(t, e) {
        const i = this.resources;
        for (const r in i)
            i[r]._gcLastUsed = t,
            i[r]._touched = e
    }
    destroy() {
        var e;
        const t = this.resources;
        for (const i in t) {
            const r = t[i];
            (e = r == null ? void 0 : r.off) == null || e.call(r, "change", this.onResourceChange, this)
        }
        this.resources = null
    }
    onResourceChange(t) {
        this._dirty = !0,
        t.destroyed ? this.destroy() : this._updateKey()
    }
}
var ti = (s => (s[s.WEBGL = 1] = "WEBGL",
s[s.WEBGPU = 2] = "WEBGPU",
s[s.CANVAS = 4] = "CANVAS",
s[s.BOTH = 3] = "BOTH",
s))(ti || {});
class xi extends vt {
    constructor(t) {
        super(),
        this.uid = q("shader"),
        this._uniformBindMap = Object.create(null),
        this._ownedBindGroups = [],
        this._destroyed = !1;
        let {gpuProgram: e, glProgram: i, groups: r, resources: n, compatibleRenderers: a, groupMap: o} = t;
        this.gpuProgram = e,
        this.glProgram = i,
        a === void 0 && (a = 0,
        e && (a |= ti.WEBGPU),
        i && (a |= ti.WEBGL)),
        this.compatibleRenderers = a;
        const h = {};
        if (!n && !r && (n = {}),
        n && r)
            throw new Error("[Shader] Cannot have both resources and groups");
        if (!e && r && !o)
            throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");
        if (!e && r && o)
            for (const l in o)
                for (const c in o[l]) {
                    const u = o[l][c];
                    h[u] = {
                        group: l,
                        binding: c,
                        name: u
                    }
                }
        else if (e && r && !o) {
            const l = e.structsAndGroups.groups;
            o = {},
            l.forEach(c => {
                o[c.group] = o[c.group] || {},
                o[c.group][c.binding] = c.name,
                h[c.name] = c
            }
            )
        } else if (n) {
            r = {},
            o = {},
            e && e.structsAndGroups.groups.forEach(u => {
                o[u.group] = o[u.group] || {},
                o[u.group][u.binding] = u.name,
                h[u.name] = u
            }
            );
            let l = 0;
            for (const c in n)
                h[c] || (r[99] || (r[99] = new ns,
                this._ownedBindGroups.push(r[99])),
                h[c] = {
                    group: 99,
                    binding: l,
                    name: c
                },
                o[99] = o[99] || {},
                o[99][l] = c,
                l++);
            for (const c in n) {
                const u = c;
                let d = n[c];
                !d.source && !d._resourceType && (d = new Dn(d));
                const f = h[u];
                f && (r[f.group] || (r[f.group] = new ns,
                this._ownedBindGroups.push(r[f.group])),
                r[f.group].setResource(d, f.binding))
            }
        }
        this.groups = r,
        this._uniformBindMap = o,
        this.resources = this._buildResourceAccessor(r, h)
    }
    addResource(t, e, i) {
        var r, n;
        (r = this._uniformBindMap)[e] || (r[e] = {}),
        (n = this._uniformBindMap[e])[i] || (n[i] = t),
        this.groups[e] || (this.groups[e] = new ns,
        this._ownedBindGroups.push(this.groups[e]))
    }
    _buildResourceAccessor(t, e) {
        const i = {};
        for (const r in e) {
            const n = e[r];
            Object.defineProperty(i, n.name, {
                get() {
                    return t[n.group].getResource(n.binding)
                },
                set(a) {
                    t[n.group].setResource(a, n.binding)
                }
            })
        }
        return i
    }
    destroy(t=!1) {
        var e, i;
        this._destroyed || (this._destroyed = !0,
        this.emit("destroy", this),
        t && ((e = this.gpuProgram) == null || e.destroy(),
        (i = this.glProgram) == null || i.destroy()),
        this.gpuProgram = null,
        this.glProgram = null,
        this.removeAllListeners(),
        this._uniformBindMap = null,
        this._ownedBindGroups.forEach(r => {
            r.destroy()
        }
        ),
        this._ownedBindGroups = null,
        this.resources = null,
        this.groups = null)
    }
    static from(t) {
        const {gpu: e, gl: i, ...r} = t;
        let n, a;
        return e && (n = ps.from(e)),
        i && (a = Bn.from(i)),
        new xi({
            gpuProgram: n,
            glProgram: a,
            ...r
        })
    }
}
const ei = [];
Y.handleByNamedList(I.Environment, ei);
async function ih(s) {
    if (!s)
        for (let t = 0; t < ei.length; t++) {
            const e = ei[t];
            if (e.value.test()) {
                await e.value.load();
                return
            }
        }
}
let Ae;
function rh() {
    if (typeof Ae == "boolean")
        return Ae;
    try {
        Ae = new Function("param1","param2","param3","return param1[param2] === param3;")({
            a: "b"
        }, "a", "b") === !0
    } catch {
        Ae = !1
    }
    return Ae
}
function Qi(s, t, e=2) {
    const i = t && t.length
      , r = i ? t[0] * e : s.length;
    let n = zn(s, 0, r, e, !0);
    const a = [];
    if (!n || n.next === n.prev)
        return a;
    let o, h, l;
    if (i && (n = lh(s, t, n, e)),
    s.length > 80 * e) {
        o = s[0],
        h = s[1];
        let c = o
          , u = h;
        for (let d = e; d < r; d += e) {
            const f = s[d]
              , p = s[d + 1];
            f < o && (o = f),
            p < h && (h = p),
            f > c && (c = f),
            p > u && (u = p)
        }
        l = Math.max(c - o, u - h),
        l = l !== 0 ? 32767 / l : 0
    }
    return Ge(n, a, e, o, h, l, 0),
    a
}
function zn(s, t, e, i, r) {
    let n;
    if (r === bh(s, t, e, i) > 0)
        for (let a = t; a < e; a += i)
            n = Ji(a / i | 0, s[a], s[a + 1], n);
    else
        for (let a = e - i; a >= t; a -= i)
            n = Ji(a / i | 0, s[a], s[a + 1], n);
    return n && ge(n, n.next) && (ze(n),
    n = n.next),
    n
}
function Jt(s, t) {
    if (!s)
        return s;
    t || (t = s);
    let e = s, i;
    do
        if (i = !1,
        !e.steiner && (ge(e, e.next) || j(e.prev, e, e.next) === 0)) {
            if (ze(e),
            e = t = e.prev,
            e === e.next)
                break;
            i = !0
        } else
            e = e.next;
    while (i || e !== t);
    return t
}
function Ge(s, t, e, i, r, n, a) {
    if (!s)
        return;
    !a && n && ph(s, i, r, n);
    let o = s;
    for (; s.prev !== s.next; ) {
        const h = s.prev
          , l = s.next;
        if (n ? ah(s, i, r, n) : nh(s)) {
            t.push(h.i, s.i, l.i),
            ze(s),
            s = l.next,
            o = l.next;
            continue
        }
        if (s = l,
        s === o) {
            a ? a === 1 ? (s = oh(Jt(s), t),
            Ge(s, t, e, i, r, n, 2)) : a === 2 && hh(s, t, e, i, r, n) : Ge(Jt(s), t, e, i, r, n, 1);
            break
        }
    }
}
function nh(s) {
    const t = s.prev
      , e = s
      , i = s.next;
    if (j(t, e, i) >= 0)
        return !1;
    const r = t.x
      , n = e.x
      , a = i.x
      , o = t.y
      , h = e.y
      , l = i.y
      , c = Math.min(r, n, a)
      , u = Math.min(o, h, l)
      , d = Math.max(r, n, a)
      , f = Math.max(o, h, l);
    let p = i.next;
    for (; p !== t; ) {
        if (p.x >= c && p.x <= d && p.y >= u && p.y <= f && ke(r, o, n, h, a, l, p.x, p.y) && j(p.prev, p, p.next) >= 0)
            return !1;
        p = p.next
    }
    return !0
}
function ah(s, t, e, i) {
    const r = s.prev
      , n = s
      , a = s.next;
    if (j(r, n, a) >= 0)
        return !1;
    const o = r.x
      , h = n.x
      , l = a.x
      , c = r.y
      , u = n.y
      , d = a.y
      , f = Math.min(o, h, l)
      , p = Math.min(c, u, d)
      , m = Math.max(o, h, l)
      , g = Math.max(c, u, d)
      , x = si(f, p, t, e, i)
      , y = si(m, g, t, e, i);
    let _ = s.prevZ
      , b = s.nextZ;
    for (; _ && _.z >= x && b && b.z <= y; ) {
        if (_.x >= f && _.x <= m && _.y >= p && _.y <= g && _ !== r && _ !== a && ke(o, c, h, u, l, d, _.x, _.y) && j(_.prev, _, _.next) >= 0 || (_ = _.prevZ,
        b.x >= f && b.x <= m && b.y >= p && b.y <= g && b !== r && b !== a && ke(o, c, h, u, l, d, b.x, b.y) && j(b.prev, b, b.next) >= 0))
            return !1;
        b = b.nextZ
    }
    for (; _ && _.z >= x; ) {
        if (_.x >= f && _.x <= m && _.y >= p && _.y <= g && _ !== r && _ !== a && ke(o, c, h, u, l, d, _.x, _.y) && j(_.prev, _, _.next) >= 0)
            return !1;
        _ = _.prevZ
    }
    for (; b && b.z <= y; ) {
        if (b.x >= f && b.x <= m && b.y >= p && b.y <= g && b !== r && b !== a && ke(o, c, h, u, l, d, b.x, b.y) && j(b.prev, b, b.next) >= 0)
            return !1;
        b = b.nextZ
    }
    return !0
}
function oh(s, t) {
    let e = s;
    do {
        const i = e.prev
          , r = e.next.next;
        !ge(i, r) && On(i, e, e.next, r) && De(i, r) && De(r, i) && (t.push(i.i, e.i, r.i),
        ze(e),
        ze(e.next),
        e = s = r),
        e = e.next
    } while (e !== s);
    return Jt(e)
}
function hh(s, t, e, i, r, n) {
    let a = s;
    do {
        let o = a.next.next;
        for (; o !== a.prev; ) {
            if (a.i !== o.i && xh(a, o)) {
                let h = Un(a, o);
                a = Jt(a, a.next),
                h = Jt(h, h.next),
                Ge(a, t, e, i, r, n, 0),
                Ge(h, t, e, i, r, n, 0);
                return
            }
            o = o.next
        }
        a = a.next
    } while (a !== s)
}
function lh(s, t, e, i) {
    const r = [];
    for (let n = 0, a = t.length; n < a; n++) {
        const o = t[n] * i
          , h = n < a - 1 ? t[n + 1] * i : s.length
          , l = zn(s, o, h, i, !1);
        l === l.next && (l.steiner = !0),
        r.push(mh(l))
    }
    r.sort(ch);
    for (let n = 0; n < r.length; n++)
        e = uh(r[n], e);
    return e
}
function ch(s, t) {
    let e = s.x - t.x;
    if (e === 0 && (e = s.y - t.y,
    e === 0)) {
        const i = (s.next.y - s.y) / (s.next.x - s.x)
          , r = (t.next.y - t.y) / (t.next.x - t.x);
        e = i - r
    }
    return e
}
function uh(s, t) {
    const e = dh(s, t);
    if (!e)
        return t;
    const i = Un(e, s);
    return Jt(i, i.next),
    Jt(e, e.next)
}
function dh(s, t) {
    let e = t;
    const i = s.x
      , r = s.y;
    let n = -1 / 0, a;
    if (ge(s, e))
        return e;
    do {
        if (ge(s, e.next))
            return e.next;
        if (r <= e.y && r >= e.next.y && e.next.y !== e.y) {
            const u = e.x + (r - e.y) * (e.next.x - e.x) / (e.next.y - e.y);
            if (u <= i && u > n && (n = u,
            a = e.x < e.next.x ? e : e.next,
            u === i))
                return a
        }
        e = e.next
    } while (e !== t);
    if (!a)
        return null;
    const o = a
      , h = a.x
      , l = a.y;
    let c = 1 / 0;
    e = a;
    do {
        if (i >= e.x && e.x >= h && i !== e.x && Wn(r < l ? i : n, r, h, l, r < l ? n : i, r, e.x, e.y)) {
            const u = Math.abs(r - e.y) / (i - e.x);
            De(e, s) && (u < c || u === c && (e.x > a.x || e.x === a.x && fh(a, e))) && (a = e,
            c = u)
        }
        e = e.next
    } while (e !== o);
    return a
}
function fh(s, t) {
    return j(s.prev, s, t.prev) < 0 && j(t.next, s, s.next) < 0
}
function ph(s, t, e, i) {
    let r = s;
    do
        r.z === 0 && (r.z = si(r.x, r.y, t, e, i)),
        r.prevZ = r.prev,
        r.nextZ = r.next,
        r = r.next;
    while (r !== s);
    r.prevZ.nextZ = null,
    r.prevZ = null,
    gh(r)
}
function gh(s) {
    let t, e = 1;
    do {
        let i = s, r;
        s = null;
        let n = null;
        for (t = 0; i; ) {
            t++;
            let a = i
              , o = 0;
            for (let l = 0; l < e && (o++,
            a = a.nextZ,
            !!a); l++)
                ;
            let h = e;
            for (; o > 0 || h > 0 && a; )
                o !== 0 && (h === 0 || !a || i.z <= a.z) ? (r = i,
                i = i.nextZ,
                o--) : (r = a,
                a = a.nextZ,
                h--),
                n ? n.nextZ = r : s = r,
                r.prevZ = n,
                n = r;
            i = a
        }
        n.nextZ = null,
        e *= 2
    } while (t > 1);
    return s
}
function si(s, t, e, i, r) {
    return s = (s - e) * r | 0,
    t = (t - i) * r | 0,
    s = (s | s << 8) & 16711935,
    s = (s | s << 4) & 252645135,
    s = (s | s << 2) & 858993459,
    s = (s | s << 1) & 1431655765,
    t = (t | t << 8) & 16711935,
    t = (t | t << 4) & 252645135,
    t = (t | t << 2) & 858993459,
    t = (t | t << 1) & 1431655765,
    s | t << 1
}
function mh(s) {
    let t = s
      , e = s;
    do
        (t.x < e.x || t.x === e.x && t.y < e.y) && (e = t),
        t = t.next;
    while (t !== s);
    return e
}
function Wn(s, t, e, i, r, n, a, o) {
    return (r - a) * (t - o) >= (s - a) * (n - o) && (s - a) * (i - o) >= (e - a) * (t - o) && (e - a) * (n - o) >= (r - a) * (i - o)
}
function ke(s, t, e, i, r, n, a, o) {
    return !(s === a && t === o) && Wn(s, t, e, i, r, n, a, o)
}
function xh(s, t) {
    return s.next.i !== t.i && s.prev.i !== t.i && !yh(s, t) && (De(s, t) && De(t, s) && _h(s, t) && (j(s.prev, s, t.prev) || j(s, t.prev, t)) || ge(s, t) && j(s.prev, s, s.next) > 0 && j(t.prev, t, t.next) > 0)
}
function j(s, t, e) {
    return (t.y - s.y) * (e.x - t.x) - (t.x - s.x) * (e.y - t.y)
}
function ge(s, t) {
    return s.x === t.x && s.y === t.y
}
function On(s, t, e, i) {
    const r = Ze(j(s, t, e))
      , n = Ze(j(s, t, i))
      , a = Ze(j(e, i, s))
      , o = Ze(j(e, i, t));
    return !!(r !== n && a !== o || r === 0 && Ke(s, e, t) || n === 0 && Ke(s, i, t) || a === 0 && Ke(e, s, i) || o === 0 && Ke(e, t, i))
}
function Ke(s, t, e) {
    return t.x <= Math.max(s.x, e.x) && t.x >= Math.min(s.x, e.x) && t.y <= Math.max(s.y, e.y) && t.y >= Math.min(s.y, e.y)
}
function Ze(s) {
    return s > 0 ? 1 : s < 0 ? -1 : 0
}
function yh(s, t) {
    let e = s;
    do {
        if (e.i !== s.i && e.next.i !== s.i && e.i !== t.i && e.next.i !== t.i && On(e, e.next, s, t))
            return !0;
        e = e.next
    } while (e !== s);
    return !1
}
function De(s, t) {
    return j(s.prev, s, s.next) < 0 ? j(s, t, s.next) >= 0 && j(s, s.prev, t) >= 0 : j(s, t, s.prev) < 0 || j(s, s.next, t) < 0
}
function _h(s, t) {
    let e = s
      , i = !1;
    const r = (s.x + t.x) / 2
      , n = (s.y + t.y) / 2;
    do
        e.y > n != e.next.y > n && e.next.y !== e.y && r < (e.next.x - e.x) * (n - e.y) / (e.next.y - e.y) + e.x && (i = !i),
        e = e.next;
    while (e !== s);
    return i
}
function Un(s, t) {
    const e = ii(s.i, s.x, s.y)
      , i = ii(t.i, t.x, t.y)
      , r = s.next
      , n = t.prev;
    return s.next = t,
    t.prev = s,
    e.next = r,
    r.prev = e,
    i.next = e,
    e.prev = i,
    n.next = i,
    i.prev = n,
    i
}
function Ji(s, t, e, i) {
    const r = ii(s, t, e);
    return i ? (r.next = i.next,
    r.prev = i,
    i.next.prev = r,
    i.next = r) : (r.prev = r,
    r.next = r),
    r
}
function ze(s) {
    s.next.prev = s.prev,
    s.prev.next = s.next,
    s.prevZ && (s.prevZ.nextZ = s.nextZ),
    s.nextZ && (s.nextZ.prevZ = s.prevZ)
}
function ii(s, t, e) {
    return {
        i: s,
        x: t,
        y: e,
        prev: null,
        next: null,
        z: 0,
        prevZ: null,
        nextZ: null,
        steiner: !1
    }
}
function bh(s, t, e, i) {
    let r = 0;
    for (let n = t, a = e - i; n < e; n += i)
        r += (s[a] - s[n]) * (s[n + 1] + s[a + 1]),
        a = n;
    return r
}
const wh = Qi.default || Qi;
var Nn = (s => (s[s.NONE = 0] = "NONE",
s[s.COLOR = 16384] = "COLOR",
s[s.STENCIL = 1024] = "STENCIL",
s[s.DEPTH = 256] = "DEPTH",
s[s.COLOR_DEPTH = 16640] = "COLOR_DEPTH",
s[s.COLOR_STENCIL = 17408] = "COLOR_STENCIL",
s[s.DEPTH_STENCIL = 1280] = "DEPTH_STENCIL",
s[s.ALL = 17664] = "ALL",
s))(Nn || {});
class Ah {
    constructor(t) {
        this.items = [],
        this._name = t
    }
    emit(t, e, i, r, n, a, o, h) {
        const {name: l, items: c} = this;
        for (let u = 0, d = c.length; u < d; u++)
            c[u][l](t, e, i, r, n, a, o, h);
        return this
    }
    add(t) {
        return t[this._name] && (this.remove(t),
        this.items.push(t)),
        this
    }
    remove(t) {
        const e = this.items.indexOf(t);
        return e !== -1 && this.items.splice(e, 1),
        this
    }
    contains(t) {
        return this.items.indexOf(t) !== -1
    }
    removeAll() {
        return this.items.length = 0,
        this
    }
    destroy() {
        this.removeAll(),
        this.items = null,
        this._name = null
    }
    get empty() {
        return this.items.length === 0
    }
    get name() {
        return this._name
    }
}
const vh = ["init", "destroy", "contextChange", "resolutionChange", "resetState", "renderEnd", "renderStart", "render", "update", "postrender", "prerender"]
  , Hn = class $n extends vt {
    constructor(t) {
        super(),
        this.tick = 0,
        this.uid = q("renderer"),
        this.runners = Object.create(null),
        this.renderPipes = Object.create(null),
        this._initOptions = {},
        this._systemsHash = Object.create(null),
        this.type = t.type,
        this.name = t.name,
        this.config = t;
        const e = [...vh, ...this.config.runners ?? []];
        this._addRunners(...e),
        this._unsafeEvalCheck()
    }
    async init(t={}) {
        const e = t.skipExtensionImports === !0 ? !0 : t.manageImports === !1;
        await ih(e),
        this._addSystems(this.config.systems),
        this._addPipes(this.config.renderPipes, this.config.renderPipeAdaptors);
        for (const i in this._systemsHash)
            t = {
                ...this._systemsHash[i].constructor.defaultOptions,
                ...t
            };
        t = {
            ...$n.defaultOptions,
            ...t
        },
        this._roundPixels = t.roundPixels ? 1 : 0;
        for (let i = 0; i < this.runners.init.items.length; i++)
            await this.runners.init.items[i].init(t);
        this._initOptions = t
    }
    render(t, e) {
        this.tick++;
        let i = t;
        if (i instanceof Gt && (i = {
            container: i
        },
        e && (V(dt, "passing a second argument is deprecated, please use render options instead"),
        i.target = e.renderTexture)),
        i.target || (i.target = this.view.renderTarget),
        i.target === this.view.renderTarget && (this._lastObjectRendered = i.container,
        i.clearColor ?? (i.clearColor = this.background.colorRgba),
        i.clear ?? (i.clear = this.background.clearBeforeRender)),
        i.clearColor) {
            const r = Array.isArray(i.clearColor) && i.clearColor.length === 4;
            i.clearColor = r ? i.clearColor : J.shared.setValue(i.clearColor).toArray()
        }
        i.transform || (i.container.updateLocalTransform(),
        i.transform = i.container.localTransform),
        i.container.visible && (i.container.enableRenderGroup(),
        this.runners.prerender.emit(i),
        this.runners.renderStart.emit(i),
        this.runners.render.emit(i),
        this.runners.renderEnd.emit(i),
        this.runners.postrender.emit(i))
    }
    resize(t, e, i) {
        const r = this.view.resolution;
        this.view.resize(t, e, i),
        this.emit("resize", this.view.screen.width, this.view.screen.height, this.view.resolution),
        i !== void 0 && i !== r && this.runners.resolutionChange.emit(i)
    }
    clear(t={}) {
        const e = this;
        t.target || (t.target = e.renderTarget.renderTarget),
        t.clearColor || (t.clearColor = this.background.colorRgba),
        t.clear ?? (t.clear = Nn.ALL);
        const {clear: i, clearColor: r, target: n, mipLevel: a, layer: o} = t;
        J.shared.setValue(r ?? this.background.colorRgba),
        e.renderTarget.clear(n, i, J.shared.toArray(), a ?? 0, o ?? 0)
    }
    get resolution() {
        return this.view.resolution
    }
    set resolution(t) {
        this.view.resolution = t,
        this.runners.resolutionChange.emit(t)
    }
    get width() {
        return this.view.texture.frame.width
    }
    get height() {
        return this.view.texture.frame.height
    }
    get canvas() {
        return this.view.canvas
    }
    get lastObjectRendered() {
        return this._lastObjectRendered
    }
    get renderingToScreen() {
        return this.renderTarget.renderingToScreen
    }
    get screen() {
        return this.view.screen
    }
    _addRunners(...t) {
        t.forEach(e => {
            this.runners[e] = new Ah(e)
        }
        )
    }
    _addSystems(t) {
        let e;
        for (e in t) {
            const i = t[e];
            this._addSystem(i.value, i.name)
        }
    }
    _addSystem(t, e) {
        const i = new t(this);
        if (this[e])
            throw new Error(`Whoops! The name "${e}" is already in use`);
        this[e] = i,
        this._systemsHash[e] = i;
        for (const r in this.runners)
            this.runners[r].add(i);
        return this
    }
    _addPipes(t, e) {
        const i = e.reduce( (r, n) => (r[n.name] = n.value,
        r), {});
        t.forEach(r => {
            const n = r.value
              , a = r.name
              , o = i[a];
            this.renderPipes[a] = new n(this,o ? new o : null),
            this.runners.destroy.add(this.renderPipes[a])
        }
        )
    }
    destroy(t=!1) {
        this.runners.destroy.items.reverse(),
        this.runners.destroy.emit(t),
        (t === !0 || typeof t == "object" && t.releaseGlobalResources) && Ue.release(),
        Object.values(this.runners).forEach(e => {
            e.destroy()
        }
        ),
        this._systemsHash = null,
        this.renderPipes = null,
        this.removeAllListeners()
    }
    generateTexture(t) {
        return this.textureGenerator.generateTexture(t)
    }
    get roundPixels() {
        return !!this._roundPixels
    }
    _unsafeEvalCheck() {
        if (!rh())
            throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")
    }
    resetState() {
        this.runners.resetState.emit()
    }
}
;
Hn.defaultOptions = {
    resolution: 1,
    failIfMajorPerformanceCaveat: !1,
    roundPixels: !1
};
let Vn = Hn, Qe;
function Sh(s) {
    return Qe !== void 0 || (Qe = ( () => {
        var e;
        const t = {
            stencil: !0,
            failIfMajorPerformanceCaveat: s ?? Vn.defaultOptions.failIfMajorPerformanceCaveat
        };
        try {
            if (!O.get().getWebGLRenderingContext())
                return !1;
            let r = O.get().createCanvas().getContext("webgl", t);
            const n = !!((e = r == null ? void 0 : r.getContextAttributes()) != null && e.stencil);
            if (r) {
                const a = r.getExtension("WEBGL_lose_context");
                a && a.loseContext()
            }
            return r = null,
            n
        } catch {
            return !1
        }
    }
    )()),
    Qe
}
let Je;
async function Th(s={}) {
    return Je !== void 0 || (Je = await (async () => {
        const t = O.get().getNavigator().gpu;
        if (!t)
            return !1;
        try {
            return await (await t.requestAdapter(s)).requestDevice(),
            !0
        } catch {
            return !1
        }
    }
    )()),
    Je
}
const tr = ["webgl", "webgpu", "canvas"];
async function Ch(s) {
    let t = [];
    s.preference ? Array.isArray(s.preference) ? t = s.preference.slice() : (t.push(s.preference),
    tr.forEach(n => {
        n !== s.preference && t.push(n)
    }
    )) : t = tr.slice();
    let e, i = {};
    for (let n = 0; n < t.length; n++) {
        const a = t[n];
        if (a === "webgpu" && await Th()) {
            const {WebGPURenderer: o} = await oe(async () => {
                const {WebGPURenderer: h} = await import("./WebGPURenderer-DJ3OxtML.js");
                return {
                    WebGPURenderer: h
                }
            }
            , __vite__mapDeps([6, 7, 8, 3, 9, 10, 4, 5]));
            e = o,
            i = {
                ...s,
                ...s.webgpu
            };
            break
        } else if (a === "webgl" && Sh(s.failIfMajorPerformanceCaveat ?? Vn.defaultOptions.failIfMajorPerformanceCaveat)) {
            const {WebGLRenderer: o} = await oe(async () => {
                const {WebGLRenderer: h} = await import("./WebGLRenderer-B7bE1YuE.js");
                return {
                    WebGLRenderer: h
                }
            }
            , __vite__mapDeps([11, 7, 8, 3, 9, 10, 4, 5]));
            e = o,
            i = {
                ...s,
                ...s.webgl
            };
            break
        } else if (a === "canvas") {
            const {CanvasRenderer: o} = await oe(async () => {
                const {CanvasRenderer: h} = await import("./CanvasRenderer-D0z9UDRV.js");
                return {
                    CanvasRenderer: h
                }
            }
            , __vite__mapDeps([12, 9, 3, 10, 2, 13, 4, 5]));
            e = o,
            i = {
                ...s,
                ...s.canvasOptions
            };
            break
        }
    }
    if (delete i.webgpu,
    delete i.webgl,
    delete i.canvasOptions,
    !e)
        throw new Error("No available renderer for the current environment");
    const r = new e;
    return await r.init(i),
    r
}
const jn = "8.18.1";
class Yn {
    static init() {
        var t;
        (t = globalThis.__PIXI_APP_INIT__) == null || t.call(globalThis, this, jn)
    }
    static destroy() {}
}
Yn.extension = I.Application;
class Ph {
    constructor(t) {
        this._renderer = t
    }
    init() {
        var t;
        (t = globalThis.__PIXI_RENDERER_INIT__) == null || t.call(globalThis, this._renderer, jn)
    }
    destroy() {
        this._renderer = null
    }
}
Ph.extension = {
    type: [I.WebGLSystem, I.WebGPUSystem],
    name: "initHook",
    priority: -10
};
class Xn {
    static init(t) {
        Object.defineProperty(this, "resizeTo", {
            configurable: !0,
            set(e) {
                globalThis.removeEventListener("resize", this.queueResize),
                this._resizeTo = e,
                e && (globalThis.addEventListener("resize", this.queueResize),
                this.resize())
            },
            get() {
                return this._resizeTo
            }
        }),
        this.queueResize = () => {
            this._resizeTo && (this._cancelResize(),
            this._resizeId = requestAnimationFrame( () => this.resize()))
        }
        ,
        this._cancelResize = () => {
            this._resizeId && (cancelAnimationFrame(this._resizeId),
            this._resizeId = null)
        }
        ,
        this.resize = () => {
            if (!this._resizeTo)
                return;
            this._cancelResize();
            let e, i;
            if (this._resizeTo === globalThis.window)
                e = globalThis.innerWidth,
                i = globalThis.innerHeight;
            else {
                const {clientWidth: r, clientHeight: n} = this._resizeTo;
                e = r,
                i = n
            }
            this.renderer.resize(e, i),
            this.render()
        }
        ,
        this._resizeId = null,
        this._resizeTo = null,
        this.resizeTo = t.resizeTo || null
    }
    static destroy() {
        globalThis.removeEventListener("resize", this.queueResize),
        this._cancelResize(),
        this._cancelResize = null,
        this.queueResize = null,
        this.resizeTo = null,
        this.resize = null
    }
}
Xn.extension = I.Application;
class qn {
    static init(t) {
        t = Object.assign({
            autoStart: !0,
            sharedTicker: !1
        }, t),
        Object.defineProperty(this, "ticker", {
            configurable: !0,
            set(e) {
                this._ticker && this._ticker.remove(this.render, this),
                this._ticker = e,
                e && e.add(this.render, this, Le.LOW)
            },
            get() {
                return this._ticker
            }
        }),
        this.stop = () => {
            this._ticker.stop()
        }
        ,
        this.start = () => {
            this._ticker.start()
        }
        ,
        this._ticker = null,
        this.ticker = t.sharedTicker ? _t.shared : new _t,
        t.autoStart && this.start()
    }
    static destroy() {
        if (this._ticker) {
            const t = this._ticker;
            this.ticker = null,
            t.destroy()
        }
    }
}
qn.extension = I.Application;
Y.add(Xn);
Y.add(qn);
const Kn = class ri {
    constructor(...t) {
        this.stage = new Gt,
        t[0] !== void 0 && V(dt, "Application constructor options are deprecated, please use Application.init() instead.")
    }
    async init(t) {
        t = {
            ...t
        },
        this.stage || (this.stage = new Gt),
        this.renderer = await Ch(t),
        ri._plugins.forEach(e => {
            e.init.call(this, t)
        }
        )
    }
    render() {
        this.renderer.render({
            container: this.stage
        })
    }
    get canvas() {
        return this.renderer.canvas
    }
    get view() {
        return V(dt, "Application.view is deprecated, please use Application.canvas instead."),
        this.renderer.canvas
    }
    get screen() {
        return this.renderer.screen
    }
    get domContainerRoot() {
        var t;
        return (t = this.renderer.renderPipes.dom) == null ? void 0 : t._domElement
    }
    destroy(t=!1, e=!1) {
        const i = ri._plugins.slice(0);
        i.reverse(),
        i.forEach(r => {
            r.destroy.call(this)
        }
        ),
        this.stage.destroy(e),
        this.stage = null,
        this.renderer.destroy(t),
        this.renderer = null
    }
}
;
Kn._plugins = [];
let Mh = Kn;
Y.handleByList(I.Application, Mh._plugins);
Y.add(Yn);
const Ls = {
    test(s) {
        return typeof s == "string" && s.startsWith("info face=")
    },
    parse(s) {
        const t = s.match(/^[a-z]+\s+.+$/gm)
          , e = {
            info: [],
            common: [],
            page: [],
            char: [],
            chars: [],
            kerning: [],
            kernings: [],
            distanceField: []
        };
        for (const u in t) {
            const d = t[u].match(/^[a-z]+/gm)[0]
              , f = t[u].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm)
              , p = {};
            for (const m in f) {
                const g = f[m].split("=")
                  , x = g[0]
                  , y = g[1].replace(/"/gm, "")
                  , _ = parseFloat(y)
                  , b = isNaN(_) ? y : _;
                p[x] = b
            }
            e[d].push(p)
        }
        const i = {
            chars: {},
            pages: [],
            lineHeight: 0,
            fontSize: 0,
            fontFamily: "",
            distanceField: null,
            baseLineOffset: 0
        }
          , [r] = e.info
          , [n] = e.common
          , [a] = e.distanceField ?? [];
        a && (i.distanceField = {
            range: parseInt(a.distanceRange, 10),
            type: a.fieldType
        }),
        i.fontSize = parseInt(r.size, 10),
        i.fontFamily = r.face,
        i.lineHeight = parseInt(n.lineHeight, 10);
        const o = e.page;
        for (let u = 0; u < o.length; u++)
            i.pages.push({
                id: parseInt(o[u].id, 10) || 0,
                file: o[u].file
            });
        const h = {};
        i.baseLineOffset = i.lineHeight - parseInt(n.base, 10);
        const l = e.char;
        for (let u = 0; u < l.length; u++) {
            const d = l[u]
              , f = parseInt(d.id, 10);
            let p = d.letter ?? d.char ?? String.fromCharCode(f);
            p === "space" && (p = " "),
            h[f] = p,
            i.chars[p] = {
                id: f,
                page: parseInt(d.page, 10) || 0,
                x: parseInt(d.x, 10),
                y: parseInt(d.y, 10),
                width: parseInt(d.width, 10),
                height: parseInt(d.height, 10),
                xOffset: parseInt(d.xoffset, 10),
                yOffset: parseInt(d.yoffset, 10),
                xAdvance: parseInt(d.xadvance, 10),
                kerning: {}
            }
        }
        const c = e.kerning || [];
        for (let u = 0; u < c.length; u++) {
            const d = parseInt(c[u].first, 10)
              , f = parseInt(c[u].second, 10)
              , p = parseInt(c[u].amount, 10);
            i.chars[h[f]] && (i.chars[h[f]].kerning[h[d]] = p)
        }
        return i
    }
}
  , er = {
    test(s) {
        const t = s;
        return typeof t != "string" && "getElementsByTagName"in t && t.getElementsByTagName("page").length && t.getElementsByTagName("info")[0].getAttribute("face") !== null
    },
    parse(s) {
        const t = {
            chars: {},
            pages: [],
            lineHeight: 0,
            fontSize: 0,
            fontFamily: "",
            distanceField: null,
            baseLineOffset: 0
        }
          , e = s.getElementsByTagName("info")[0]
          , i = s.getElementsByTagName("common")[0]
          , r = s.getElementsByTagName("distanceField")[0];
        r && (t.distanceField = {
            type: r.getAttribute("fieldType"),
            range: parseInt(r.getAttribute("distanceRange"), 10)
        });
        const n = s.getElementsByTagName("page")
          , a = s.getElementsByTagName("char")
          , o = s.getElementsByTagName("kerning");
        t.fontSize = parseInt(e.getAttribute("size"), 10),
        t.fontFamily = e.getAttribute("face"),
        t.lineHeight = parseInt(i.getAttribute("lineHeight"), 10);
        for (let l = 0; l < n.length; l++)
            t.pages.push({
                id: parseInt(n[l].getAttribute("id"), 10) || 0,
                file: n[l].getAttribute("file")
            });
        const h = {};
        t.baseLineOffset = t.lineHeight - parseInt(i.getAttribute("base"), 10);
        for (let l = 0; l < a.length; l++) {
            const c = a[l]
              , u = parseInt(c.getAttribute("id"), 10);
            let d = c.getAttribute("letter") ?? c.getAttribute("char") ?? String.fromCharCode(u);
            d === "space" && (d = " "),
            h[u] = d,
            t.chars[d] = {
                id: u,
                page: parseInt(c.getAttribute("page"), 10) || 0,
                x: parseInt(c.getAttribute("x"), 10),
                y: parseInt(c.getAttribute("y"), 10),
                width: parseInt(c.getAttribute("width"), 10),
                height: parseInt(c.getAttribute("height"), 10),
                xOffset: parseInt(c.getAttribute("xoffset"), 10),
                yOffset: parseInt(c.getAttribute("yoffset"), 10),
                xAdvance: parseInt(c.getAttribute("xadvance"), 10),
                kerning: {}
            }
        }
        for (let l = 0; l < o.length; l++) {
            const c = parseInt(o[l].getAttribute("first"), 10)
              , u = parseInt(o[l].getAttribute("second"), 10)
              , d = parseInt(o[l].getAttribute("amount"), 10);
            t.chars[h[u]] && (t.chars[h[u]].kerning[h[c]] = d)
        }
        return t
    }
}
  , sr = {
    test(s) {
        return typeof s == "string" && s.match(/<font(\s|>)/) ? er.test(O.get().parseXML(s)) : !1
    },
    parse(s) {
        return er.parse(O.get().parseXML(s))
    }
}
  , kh = [".xml", ".fnt"]
  , Eh = {
    extension: {
        type: I.CacheParser,
        name: "cacheBitmapFont"
    },
    test: s => !!(s != null && s.pages) && !!(s != null && s.chars) && typeof (s == null ? void 0 : s.fontFamily) == "string" && s.fontFamily !== "",
    getCacheableAssets(s, t) {
        const e = {};
        return s.forEach(i => {
            e[i] = t,
            e[`${i}-bitmap`] = t
        }
        ),
        e[`${t.fontFamily}-bitmap`] = t,
        e
    }
}
  , Ih = {
    extension: {
        type: I.LoadParser,
        priority: Dt.Normal
    },
    name: "loadBitmapFont",
    id: "bitmap-font",
    test(s) {
        return kh.includes(lt.extname(s).toLowerCase())
    },
    async testParse(s) {
        return Ls.test(s) || sr.test(s)
    },
    async parse(s, t, e) {
        const i = Ls.test(s) ? Ls.parse(s) : sr.parse(s)
          , {src: r} = t
          , {pages: n} = i
          , a = []
          , o = i.distanceField ? {
            scaleMode: "linear",
            alphaMode: "premultiply-alpha-on-upload",
            autoGenerateMipmaps: !1,
            resolution: 1
        } : {};
        for (let d = 0; d < n.length; ++d) {
            const f = n[d].file;
            let p = lt.join(lt.dirname(r), f);
            p = Qs(p, r),
            a.push({
                src: p,
                data: o
            })
        }
        const [h,{BitmapFont: l}] = await Promise.all([e.load(a), oe( () => import("./BitmapFont-Dw0jX6D9.js"), __vite__mapDeps([14, 4, 5]))])
          , c = a.map(d => h[d.src]);
        return new l({
            data: i,
            textures: c
        },r)
    },
    async load(s, t) {
        return await (await O.get().fetch(s)).text()
    },
    async unload(s, t, e) {
        await Promise.all(s.pages.map(i => e.unload(i.texture.source._sourceOrigin))),
        s.destroy()
    }
};
class Rh {
    constructor(t, e=!1) {
        this._loader = t,
        this._assetList = [],
        this._isLoading = !1,
        this._maxConcurrent = 1,
        this.verbose = e
    }
    add(t) {
        t.forEach(e => {
            this._assetList.push(e)
        }
        ),
        this.verbose,
        this._isActive && !this._isLoading && this._next()
    }
    async _next() {
        if (this._assetList.length && this._isActive) {
            this._isLoading = !0;
            const t = []
              , e = Math.min(this._assetList.length, this._maxConcurrent);
            for (let i = 0; i < e; i++)
                t.push(this._assetList.pop());
            await this._loader.load(t),
            this._isLoading = !1,
            this._next()
        }
    }
    get active() {
        return this._isActive
    }
    set active(t) {
        this._isActive !== t && (this._isActive = t,
        t && !this._isLoading && this._next())
    }
}
const Bh = {
    extension: {
        type: I.CacheParser,
        name: "cacheTextureArray"
    },
    test: s => Array.isArray(s) && s.every(t => t instanceof W),
    getCacheableAssets: (s, t) => {
        const e = {};
        return s.forEach(i => {
            t.forEach( (r, n) => {
                e[i + (n === 0 ? "" : n + 1)] = r
            }
            )
        }
        ),
        e
    }
};
async function Zn(s) {
    if ("Image"in globalThis)
        return new Promise(t => {
            const e = new Image;
            e.onload = () => {
                t(!0)
            }
            ,
            e.onerror = () => {
                t(!1)
            }
            ,
            e.src = s
        }
        );
    if ("createImageBitmap"in globalThis && "fetch"in globalThis) {
        try {
            const t = await (await fetch(s)).blob();
            await createImageBitmap(t)
        } catch {
            return !1
        }
        return !0
    }
    return !1
}
const Fh = {
    extension: {
        type: I.DetectionParser,
        priority: 1
    },
    test: async () => Zn("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),
    add: async s => [...s, "avif"],
    remove: async s => s.filter(t => t !== "avif")
}
  , ir = ["png", "jpg", "jpeg"]
  , Lh = {
    extension: {
        type: I.DetectionParser,
        priority: -1
    },
    test: () => Promise.resolve(!0),
    add: async s => [...s, ...ir],
    remove: async s => s.filter(t => !ir.includes(t))
}
  , Gh = "WorkerGlobalScope"in globalThis && globalThis instanceof globalThis.WorkerGlobalScope;
function gs(s) {
    return Gh ? !1 : document.createElement("video").canPlayType(s) !== ""
}
const Dh = {
    extension: {
        type: I.DetectionParser,
        priority: 0
    },
    test: async () => gs("video/mp4"),
    add: async s => [...s, "mp4", "m4v"],
    remove: async s => s.filter(t => t !== "mp4" && t !== "m4v")
}
  , zh = {
    extension: {
        type: I.DetectionParser,
        priority: 0
    },
    test: async () => gs("video/ogg"),
    add: async s => [...s, "ogv"],
    remove: async s => s.filter(t => t !== "ogv")
}
  , Wh = {
    extension: {
        type: I.DetectionParser,
        priority: 0
    },
    test: async () => gs("video/webm"),
    add: async s => [...s, "webm"],
    remove: async s => s.filter(t => t !== "webm")
}
  , Oh = {
    extension: {
        type: I.DetectionParser,
        priority: 0
    },
    test: async () => Zn("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),
    add: async s => [...s, "webp"],
    remove: async s => s.filter(t => t !== "webp")
}
  , Qn = class as {
    constructor() {
        this.loadOptions = {
            ...as.defaultOptions
        },
        this._parsers = [],
        this._parsersValidated = !1,
        this.parsers = new Proxy(this._parsers,{
            set: (t, e, i) => (this._parsersValidated = !1,
            t[e] = i,
            !0)
        }),
        this.promiseCache = {}
    }
    reset() {
        this._parsersValidated = !1,
        this.promiseCache = {}
    }
    _getLoadPromiseAndParser(t, e) {
        const i = {
            promise: null,
            parser: null
        };
        return i.promise = (async () => {
            var a, o;
            let r = null
              , n = null;
            if ((e.parser || e.loadParser) && (n = this._parserHash[e.parser || e.loadParser],
            e.loadParser && $(`[Assets] "loadParser" is deprecated, use "parser" instead for ${t}`),
            n || $(`[Assets] specified load parser "${e.parser || e.loadParser}" not found while loading ${t}`)),
            !n) {
                for (let h = 0; h < this.parsers.length; h++) {
                    const l = this.parsers[h];
                    if (l.load && ((a = l.test) != null && a.call(l, t, e, this))) {
                        n = l;
                        break
                    }
                }
                if (!n)
                    return $(`[Assets] ${t} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`),
                    null
            }
            r = await n.load(t, e, this),
            i.parser = n;
            for (let h = 0; h < this.parsers.length; h++) {
                const l = this.parsers[h];
                l.parse && l.parse && await ((o = l.testParse) == null ? void 0 : o.call(l, r, e, this)) && (r = await l.parse(r, e, this) || r,
                i.parser = l)
            }
            return r
        }
        )(),
        i
    }
    async load(t, e) {
        this._parsersValidated || this._validateParsers();
        const i = typeof e == "function" ? {
            ...as.defaultOptions,
            ...this.loadOptions,
            onProgress: e
        } : {
            ...as.defaultOptions,
            ...this.loadOptions,
            ...e || {}
        }
          , {onProgress: r, onError: n, strategy: a, retryCount: o, retryDelay: h} = i;
        let l = 0;
        const c = {}
          , u = os(t)
          , d = bt(t, m => ({
            alias: [m],
            src: m,
            data: {}
        }))
          , f = d.reduce( (m, g) => m + (g.progressSize || 1), 0)
          , p = d.map(async m => {
            const g = lt.toAbsolute(m.src);
            c[m.src] || (await this._loadAssetWithRetry(g, m, {
                onProgress: r,
                onError: n,
                strategy: a,
                retryCount: o,
                retryDelay: h
            }, c),
            l += m.progressSize || 1,
            r && r(l / f))
        }
        );
        return await Promise.all(p),
        u ? c[d[0].src] : c
    }
    async unload(t) {
        const i = bt(t, r => ({
            alias: [r],
            src: r
        })).map(async r => {
            var o, h;
            const n = lt.toAbsolute(r.src)
              , a = this.promiseCache[n];
            if (a) {
                const l = await a.promise;
                delete this.promiseCache[n],
                await ((h = (o = a.parser) == null ? void 0 : o.unload) == null ? void 0 : h.call(o, l, r, this))
            }
        }
        );
        await Promise.all(i)
    }
    _validateParsers() {
        this._parsersValidated = !0,
        this._parserHash = this._parsers.filter(t => t.name || t.id).reduce( (t, e) => (!e.name && !e.id ? $("[Assets] parser should have an id") : (t[e.name] || t[e.id]) && $(`[Assets] parser id conflict "${e.id}"`),
        t[e.name] = e,
        e.id && (t[e.id] = e),
        t), {})
    }
    async _loadAssetWithRetry(t, e, i, r) {
        let n = 0;
        const {onError: a, strategy: o, retryCount: h, retryDelay: l} = i
          , c = u => new Promise(d => setTimeout(d, u));
        for (; ; )
            try {
                this.promiseCache[t] || (this.promiseCache[t] = this._getLoadPromiseAndParser(t, e)),
                r[e.src] = await this.promiseCache[t].promise;
                return
            } catch (u) {
                delete this.promiseCache[t],
                delete r[e.src],
                n++;
                const d = o !== "retry" || n > h;
                if (o === "retry" && !d) {
                    a && a(u, e),
                    await c(l);
                    continue
                }
                if (o === "skip") {
                    a && a(u, e);
                    return
                }
                a && a(u, e);
                const f = new Error(`[Loader.load] Failed to load ${t}.
${u}`);
                throw u instanceof Error && u.stack && (f.stack = u.stack),
                f
            }
    }
}
;
Qn.defaultOptions = {
    onProgress: void 0,
    onError: void 0,
    strategy: "throw",
    retryCount: 3,
    retryDelay: 250
};
let Uh = Qn;
function xe(s, t) {
    if (Array.isArray(t)) {
        for (const e of t)
            if (s.startsWith(`data:${e}`))
                return !0;
        return !1
    }
    return s.startsWith(`data:${t}`)
}
function ye(s, t) {
    const e = s.split("?")[0]
      , i = lt.extname(e).toLowerCase();
    return Array.isArray(t) ? t.includes(i) : i === t
}
const Nh = ".json"
  , Hh = "application/json"
  , $h = {
    extension: {
        type: I.LoadParser,
        priority: Dt.Low
    },
    name: "loadJson",
    id: "json",
    test(s) {
        return xe(s, Hh) || ye(s, Nh)
    },
    async load(s) {
        return await (await O.get().fetch(s)).json()
    }
}
  , Vh = ".txt"
  , jh = "text/plain"
  , Yh = {
    name: "loadTxt",
    id: "text",
    extension: {
        type: I.LoadParser,
        priority: Dt.Low,
        name: "loadTxt"
    },
    test(s) {
        return xe(s, jh) || ye(s, Vh)
    },
    async load(s) {
        return await (await O.get().fetch(s)).text()
    }
}
  , Xh = ["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"]
  , qh = [".ttf", ".otf", ".woff", ".woff2"]
  , Kh = ["font/ttf", "font/otf", "font/woff", "font/woff2"]
  , Zh = /^(--|-?[A-Z_])[0-9A-Z_-]*$/i;
function Qh(s) {
    const t = lt.extname(s)
      , r = lt.basename(s, t).replace(/(-|_)/g, " ").toLowerCase().split(" ").map(o => o.charAt(0).toUpperCase() + o.slice(1));
    let n = r.length > 0;
    for (const o of r)
        if (!o.match(Zh)) {
            n = !1;
            break
        }
    let a = r.join(" ");
    return n || (a = `"${a.replace(/[\\"]/g, "\\$&")}"`),
    a
}
const Jh = /^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;
function tl(s) {
    return Jh.test(s) ? s : encodeURI(s)
}
const el = {
    extension: {
        type: I.LoadParser,
        priority: Dt.Low
    },
    name: "loadWebFont",
    id: "web-font",
    test(s) {
        return xe(s, Kh) || ye(s, qh)
    },
    async load(s, t) {
        var i, r, n;
        const e = O.get().getFontFaceSet();
        if (e) {
            const a = []
              , o = ((i = t.data) == null ? void 0 : i.family) ?? Qh(s)
              , h = ((n = (r = t.data) == null ? void 0 : r.weights) == null ? void 0 : n.filter(c => Xh.includes(c))) ?? ["normal"]
              , l = t.data ?? {};
            for (let c = 0; c < h.length; c++) {
                const u = h[c]
                  , d = new FontFace(o,`url('${tl(s)}')`,{
                    ...l,
                    weight: u
                });
                await d.load(),
                e.add(d),
                a.push(d)
            }
            return st.has(`${o}-and-url`) ? st.get(`${o}-and-url`).entries.push({
                url: s,
                faces: a
            }) : st.set(`${o}-and-url`, {
                entries: [{
                    url: s,
                    faces: a
                }]
            }),
            a.length === 1 ? a[0] : a
        }
        return $("[loadWebFont] FontFace API is not supported. Skipping loading font"),
        null
    },
    unload(s) {
        const t = Array.isArray(s) ? s : [s]
          , e = t[0].family
          , i = st.get(`${e}-and-url`)
          , r = i.entries.find(n => n.faces.some(a => t.indexOf(a) !== -1));
        r.faces = r.faces.filter(n => t.indexOf(n) === -1),
        r.faces.length === 0 && (i.entries = i.entries.filter(n => n !== r)),
        t.forEach(n => {
            O.get().getFontFaceSet().delete(n)
        }
        ),
        i.entries.length === 0 && st.remove(`${e}-and-url`)
    }
};
var Gs, rr;
function sl() {
    if (rr)
        return Gs;
    rr = 1,
    Gs = e;
    var s = {
        a: 7,
        c: 6,
        h: 1,
        l: 2,
        m: 2,
        q: 4,
        s: 4,
        t: 2,
        v: 1,
        z: 0
    }
      , t = /([astvzqmhlc])([^astvzqmhlc]*)/ig;
    function e(n) {
        var a = [];
        return n.replace(t, function(o, h, l) {
            var c = h.toLowerCase();
            for (l = r(l),
            c == "m" && l.length > 2 && (a.push([h].concat(l.splice(0, 2))),
            c = "l",
            h = h == "m" ? "l" : "L"); ; ) {
                if (l.length == s[c])
                    return l.unshift(h),
                    a.push(l);
                if (l.length < s[c])
                    throw new Error("malformed path data");
                a.push([h].concat(l.splice(0, s[c])))
            }
        }),
        a
    }
    var i = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;
    function r(n) {
        var a = n.match(i);
        return a ? a.map(Number) : []
    }
    return Gs
}
var il = sl();
const rl = Zr(il);
function nl(s, t) {
    const e = rl(s)
      , i = [];
    let r = null
      , n = 0
      , a = 0;
    for (let o = 0; o < e.length; o++) {
        const h = e[o]
          , l = h[0]
          , c = h;
        switch (l) {
        case "M":
            n = c[1],
            a = c[2],
            t.moveTo(n, a);
            break;
        case "m":
            n += c[1],
            a += c[2],
            t.moveTo(n, a);
            break;
        case "H":
            n = c[1],
            t.lineTo(n, a);
            break;
        case "h":
            n += c[1],
            t.lineTo(n, a);
            break;
        case "V":
            a = c[1],
            t.lineTo(n, a);
            break;
        case "v":
            a += c[1],
            t.lineTo(n, a);
            break;
        case "L":
            n = c[1],
            a = c[2],
            t.lineTo(n, a);
            break;
        case "l":
            n += c[1],
            a += c[2],
            t.lineTo(n, a);
            break;
        case "C":
            n = c[5],
            a = c[6],
            t.bezierCurveTo(c[1], c[2], c[3], c[4], n, a);
            break;
        case "c":
            t.bezierCurveTo(n + c[1], a + c[2], n + c[3], a + c[4], n + c[5], a + c[6]),
            n += c[5],
            a += c[6];
            break;
        case "S":
            n = c[3],
            a = c[4],
            t.bezierCurveToShort(c[1], c[2], n, a);
            break;
        case "s":
            t.bezierCurveToShort(n + c[1], a + c[2], n + c[3], a + c[4]),
            n += c[3],
            a += c[4];
            break;
        case "Q":
            n = c[3],
            a = c[4],
            t.quadraticCurveTo(c[1], c[2], n, a);
            break;
        case "q":
            t.quadraticCurveTo(n + c[1], a + c[2], n + c[3], a + c[4]),
            n += c[3],
            a += c[4];
            break;
        case "T":
            n = c[1],
            a = c[2],
            t.quadraticCurveToShort(n, a);
            break;
        case "t":
            n += c[1],
            a += c[2],
            t.quadraticCurveToShort(n, a);
            break;
        case "A":
            n = c[6],
            a = c[7],
            t.arcToSvg(c[1], c[2], c[3], c[4], c[5], n, a);
            break;
        case "a":
            n += c[6],
            a += c[7],
            t.arcToSvg(c[1], c[2], c[3], c[4], c[5], n, a);
            break;
        case "Z":
        case "z":
            t.closePath(),
            i.length > 0 && (r = i.pop(),
            r ? (n = r.startX,
            a = r.startY) : (n = 0,
            a = 0)),
            r = null;
            break;
        default:
            $(`Unknown SVG path command: ${l}`)
        }
        l !== "Z" && l !== "z" && r === null && (r = {
            startX: n,
            startY: a
        },
        i.push(r))
    }
    return t
}
class yi {
    constructor(t=0, e=0, i=0) {
        this.type = "circle",
        this.x = t,
        this.y = e,
        this.radius = i
    }
    clone() {
        return new yi(this.x,this.y,this.radius)
    }
    contains(t, e) {
        if (this.radius <= 0)
            return !1;
        const i = this.radius * this.radius;
        let r = this.x - t
          , n = this.y - e;
        return r *= r,
        n *= n,
        r + n <= i
    }
    strokeContains(t, e, i, r=.5) {
        if (this.radius === 0)
            return !1;
        const n = this.x - t
          , a = this.y - e
          , o = this.radius
          , h = (1 - r) * i
          , l = Math.sqrt(n * n + a * a);
        return l <= o + h && l > o - (i - h)
    }
    getBounds(t) {
        return t || (t = new Z),
        t.x = this.x - this.radius,
        t.y = this.y - this.radius,
        t.width = this.radius * 2,
        t.height = this.radius * 2,
        t
    }
    copyFrom(t) {
        return this.x = t.x,
        this.y = t.y,
        this.radius = t.radius,
        this
    }
    copyTo(t) {
        return t.copyFrom(this),
        t
    }
    toString() {
        return `[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`
    }
}
class _i {
    constructor(t=0, e=0, i=0, r=0) {
        this.type = "ellipse",
        this.x = t,
        this.y = e,
        this.halfWidth = i,
        this.halfHeight = r
    }
    clone() {
        return new _i(this.x,this.y,this.halfWidth,this.halfHeight)
    }
    contains(t, e) {
        if (this.halfWidth <= 0 || this.halfHeight <= 0)
            return !1;
        let i = (t - this.x) / this.halfWidth
          , r = (e - this.y) / this.halfHeight;
        return i *= i,
        r *= r,
        i + r <= 1
    }
    strokeContains(t, e, i, r=.5) {
        const {halfWidth: n, halfHeight: a} = this;
        if (n <= 0 || a <= 0)
            return !1;
        const o = i * (1 - r)
          , h = i - o
          , l = n - h
          , c = a - h
          , u = n + o
          , d = a + o
          , f = t - this.x
          , p = e - this.y
          , m = f * f / (l * l) + p * p / (c * c)
          , g = f * f / (u * u) + p * p / (d * d);
        return m > 1 && g <= 1
    }
    getBounds(t) {
        return t || (t = new Z),
        t.x = this.x - this.halfWidth,
        t.y = this.y - this.halfHeight,
        t.width = this.halfWidth * 2,
        t.height = this.halfHeight * 2,
        t
    }
    copyFrom(t) {
        return this.x = t.x,
        this.y = t.y,
        this.halfWidth = t.halfWidth,
        this.halfHeight = t.halfHeight,
        this
    }
    copyTo(t) {
        return t.copyFrom(this),
        t
    }
    toString() {
        return `[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`
    }
}
function al(s, t, e, i, r, n) {
    const a = s - e
      , o = t - i
      , h = r - e
      , l = n - i
      , c = a * h + o * l
      , u = h * h + l * l;
    let d = -1;
    u !== 0 && (d = c / u);
    let f, p;
    d < 0 ? (f = e,
    p = i) : d > 1 ? (f = r,
    p = n) : (f = e + d * h,
    p = i + d * l);
    const m = s - f
      , g = t - p;
    return m * m + g * g
}
let ol, hl;
class Re {
    constructor(...t) {
        this.type = "polygon";
        let e = Array.isArray(t[0]) ? t[0] : t;
        if (typeof e[0] != "number") {
            const i = [];
            for (let r = 0, n = e.length; r < n; r++)
                i.push(e[r].x, e[r].y);
            e = i
        }
        this.points = e,
        this.closePath = !0
    }
    isClockwise() {
        let t = 0;
        const e = this.points
          , i = e.length;
        for (let r = 0; r < i; r += 2) {
            const n = e[r]
              , a = e[r + 1]
              , o = e[(r + 2) % i]
              , h = e[(r + 3) % i];
            t += (o - n) * (h + a)
        }
        return t < 0
    }
    containsPolygon(t) {
        const e = this.getBounds(ol)
          , i = t.getBounds(hl);
        if (!e.containsRect(i))
            return !1;
        const r = t.points;
        for (let n = 0; n < r.length; n += 2) {
            const a = r[n]
              , o = r[n + 1];
            if (!this.contains(a, o))
                return !1
        }
        return !0
    }
    clone() {
        const t = this.points.slice()
          , e = new Re(t);
        return e.closePath = this.closePath,
        e
    }
    contains(t, e) {
        let i = !1;
        const r = this.points.length / 2;
        for (let n = 0, a = r - 1; n < r; a = n++) {
            const o = this.points[n * 2]
              , h = this.points[n * 2 + 1]
              , l = this.points[a * 2]
              , c = this.points[a * 2 + 1];
            h > e != c > e && t < (l - o) * ((e - h) / (c - h)) + o && (i = !i)
        }
        return i
    }
    strokeContains(t, e, i, r=.5) {
        const n = i * i
          , a = n * (1 - r)
          , o = n - a
          , {points: h} = this
          , l = h.length - (this.closePath ? 0 : 2);
        for (let c = 0; c < l; c += 2) {
            const u = h[c]
              , d = h[c + 1]
              , f = h[(c + 2) % h.length]
              , p = h[(c + 3) % h.length]
              , m = al(t, e, u, d, f, p)
              , g = Math.sign((f - u) * (e - d) - (p - d) * (t - u));
            if (m <= (g < 0 ? o : a))
                return !0
        }
        return !1
    }
    getBounds(t) {
        t || (t = new Z);
        const e = this.points;
        let i = 1 / 0
          , r = -1 / 0
          , n = 1 / 0
          , a = -1 / 0;
        for (let o = 0, h = e.length; o < h; o += 2) {
            const l = e[o]
              , c = e[o + 1];
            i = l < i ? l : i,
            r = l > r ? l : r,
            n = c < n ? c : n,
            a = c > a ? c : a
        }
        return t.x = i,
        t.width = r - i,
        t.y = n,
        t.height = a - n,
        t
    }
    copyFrom(t) {
        return this.points = t.points.slice(),
        this.closePath = t.closePath,
        this
    }
    copyTo(t) {
        return t.copyFrom(this),
        t
    }
    toString() {
        return `[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce( (t, e) => `${t}, ${e}`, "")}]`
    }
    get lastX() {
        return this.points[this.points.length - 2]
    }
    get lastY() {
        return this.points[this.points.length - 1]
    }
    get x() {
        return V("8.11.0", "Polygon.lastX is deprecated, please use Polygon.lastX instead."),
        this.points[this.points.length - 2]
    }
    get y() {
        return V("8.11.0", "Polygon.y is deprecated, please use Polygon.lastY instead."),
        this.points[this.points.length - 1]
    }
    get startX() {
        return this.points[0]
    }
    get startY() {
        return this.points[1]
    }
}
const ts = (s, t, e, i, r, n, a) => {
    const o = s - e
      , h = t - i
      , l = Math.sqrt(o * o + h * h);
    return l >= r - n && l <= r + a
}
;
class bi {
    constructor(t=0, e=0, i=0, r=0, n=20) {
        this.type = "roundedRectangle",
        this.x = t,
        this.y = e,
        this.width = i,
        this.height = r,
        this.radius = n
    }
    getBounds(t) {
        return t || (t = new Z),
        t.x = this.x,
        t.y = this.y,
        t.width = this.width,
        t.height = this.height,
        t
    }
    clone() {
        return new bi(this.x,this.y,this.width,this.height,this.radius)
    }
    copyFrom(t) {
        return this.x = t.x,
        this.y = t.y,
        this.width = t.width,
        this.height = t.height,
        this
    }
    copyTo(t) {
        return t.copyFrom(this),
        t
    }
    contains(t, e) {
        if (this.width <= 0 || this.height <= 0)
            return !1;
        if (t >= this.x && t <= this.x + this.width && e >= this.y && e <= this.y + this.height) {
            const i = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));
            if (e >= this.y + i && e <= this.y + this.height - i || t >= this.x + i && t <= this.x + this.width - i)
                return !0;
            let r = t - (this.x + i)
              , n = e - (this.y + i);
            const a = i * i;
            if (r * r + n * n <= a || (r = t - (this.x + this.width - i),
            r * r + n * n <= a) || (n = e - (this.y + this.height - i),
            r * r + n * n <= a) || (r = t - (this.x + i),
            r * r + n * n <= a))
                return !0
        }
        return !1
    }
    strokeContains(t, e, i, r=.5) {
        const {x: n, y: a, width: o, height: h, radius: l} = this
          , c = i * (1 - r)
          , u = i - c
          , d = n + l
          , f = a + l
          , p = o - l * 2
          , m = h - l * 2
          , g = n + o
          , x = a + h;
        return (t >= n - c && t <= n + u || t >= g - u && t <= g + c) && e >= f && e <= f + m || (e >= a - c && e <= a + u || e >= x - u && e <= x + c) && t >= d && t <= d + p ? !0 : t < d && e < f && ts(t, e, d, f, l, u, c) || t > g - l && e < f && ts(t, e, g - l, f, l, u, c) || t > g - l && e > x - l && ts(t, e, g - l, x - l, l, u, c) || t < d && e > x - l && ts(t, e, d, x - l, l, u, c)
    }
    toString() {
        return `[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`
    }
}
const Jn = {};
function ll(s, t, e) {
    let i = 2166136261;
    for (let r = 0; r < t; r++)
        i ^= s[r].uid,
        i = Math.imul(i, 16777619),
        i >>>= 0;
    return Jn[i] || cl(s, t, i, e)
}
function cl(s, t, e, i) {
    const r = {};
    let n = 0;
    for (let o = 0; o < i; o++) {
        const h = o < t ? s[o] : W.EMPTY.source;
        r[n++] = h.source,
        r[n++] = h.style
    }
    const a = new ns(r);
    return Jn[e] = a,
    a
}
class nr {
    constructor(t) {
        typeof t == "number" ? this.rawBinaryData = new ArrayBuffer(t) : t instanceof Uint8Array ? this.rawBinaryData = t.buffer : this.rawBinaryData = t,
        this.uint32View = new Uint32Array(this.rawBinaryData),
        this.float32View = new Float32Array(this.rawBinaryData),
        this.size = this.rawBinaryData.byteLength
    }
    get int8View() {
        return this._int8View || (this._int8View = new Int8Array(this.rawBinaryData)),
        this._int8View
    }
    get uint8View() {
        return this._uint8View || (this._uint8View = new Uint8Array(this.rawBinaryData)),
        this._uint8View
    }
    get int16View() {
        return this._int16View || (this._int16View = new Int16Array(this.rawBinaryData)),
        this._int16View
    }
    get int32View() {
        return this._int32View || (this._int32View = new Int32Array(this.rawBinaryData)),
        this._int32View
    }
    get float64View() {
        return this._float64Array || (this._float64Array = new Float64Array(this.rawBinaryData)),
        this._float64Array
    }
    get bigUint64View() {
        return this._bigUint64Array || (this._bigUint64Array = new BigUint64Array(this.rawBinaryData)),
        this._bigUint64Array
    }
    view(t) {
        return this[`${t}View`]
    }
    destroy() {
        this.rawBinaryData = null,
        this.uint32View = null,
        this.float32View = null,
        this.uint16View = null,
        this._int8View = null,
        this._uint8View = null,
        this._int16View = null,
        this._int32View = null,
        this._float64Array = null,
        this._bigUint64Array = null
    }
    static sizeOf(t) {
        switch (t) {
        case "int8":
        case "uint8":
            return 1;
        case "int16":
        case "uint16":
            return 2;
        case "int32":
        case "uint32":
        case "float32":
            return 4;
        default:
            throw new Error(`${t} isn't a valid view type`)
        }
    }
}
function ar(s, t, e, i) {
    if (e ?? (e = 0),
    i ?? (i = Math.min(s.byteLength - e, t.byteLength)),
    !(e & 7) && !(i & 7)) {
        const r = i / 8;
        new Float64Array(t,0,r).set(new Float64Array(s,e,r))
    } else if (!(e & 3) && !(i & 3)) {
        const r = i / 4;
        new Float32Array(t,0,r).set(new Float32Array(s,e,r))
    } else
        new Uint8Array(t).set(new Uint8Array(s,e,i))
}
const ul = {
    normal: "normal-npm",
    add: "add-npm",
    screen: "screen-npm"
};
var dl = (s => (s[s.DISABLED = 0] = "DISABLED",
s[s.RENDERING_MASK_ADD = 1] = "RENDERING_MASK_ADD",
s[s.MASK_ACTIVE = 2] = "MASK_ACTIVE",
s[s.INVERSE_MASK_ACTIVE = 3] = "INVERSE_MASK_ACTIVE",
s[s.RENDERING_MASK_REMOVE = 4] = "RENDERING_MASK_REMOVE",
s[s.NONE = 5] = "NONE",
s))(dl || {});
function or(s, t) {
    return t.alphaMode === "no-premultiply-alpha" && ul[s] || s
}
const fl = ["precision mediump float;", "void main(void){", "float test = 0.1;", "%forloop%", "gl_FragColor = vec4(0.0);", "}"].join(`
`);
function pl(s) {
    let t = "";
    for (let e = 0; e < s; ++e)
        e > 0 && (t += `
else `),
        e < s - 1 && (t += `if(test == ${e}.0){}`);
    return t
}
function gl(s, t) {
    if (s === 0)
        throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");
    const e = t.createShader(t.FRAGMENT_SHADER);
    try {
        for (; ; ) {
            const i = fl.replace(/%forloop%/gi, pl(s));
            if (t.shaderSource(e, i),
            t.compileShader(e),
            !t.getShaderParameter(e, t.COMPILE_STATUS))
                s = s / 2 | 0;
            else
                break
        }
    } finally {
        t.deleteShader(e)
    }
    return s
}
let se = null;
function ml() {
    var t;
    if (se)
        return se;
    const s = In();
    return se = s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),
    se = gl(se, s),
    (t = s.getExtension("WEBGL_lose_context")) == null || t.loseContext(),
    se
}
class xl {
    constructor() {
        this.ids = Object.create(null),
        this.textures = [],
        this.count = 0
    }
    clear() {
        for (let t = 0; t < this.count; t++) {
            const e = this.textures[t];
            this.textures[t] = null,
            this.ids[e.uid] = null
        }
        this.count = 0
    }
}
class yl {
    constructor() {
        this.renderPipeId = "batch",
        this.action = "startBatch",
        this.start = 0,
        this.size = 0,
        this.textures = new xl,
        this.blendMode = "normal",
        this.topology = "triangle-strip",
        this.canBundle = !0
    }
    destroy() {
        this.textures = null,
        this.gpuBindGroup = null,
        this.bindGroup = null,
        this.batcher = null,
        this.elements = null
    }
}
const Be = [];
let hs = 0;
Ue.register({
    clear: () => {
        if (Be.length > 0)
            for (const s of Be)
                s && s.destroy();
        Be.length = 0,
        hs = 0
    }
});
function hr() {
    return hs > 0 ? Be[--hs] : new yl
}
function lr(s) {
    s.elements = null,
    Be[hs++] = s
}
let ve = 0;
const ta = class ea {
    constructor(t) {
        this.uid = q("batcher"),
        this.dirty = !0,
        this.batchIndex = 0,
        this.batches = [],
        this._elements = [],
        t = {
            ...ea.defaultOptions,
            ...t
        },
        t.maxTextures || (V("v8.8.0", "maxTextures is a required option for Batcher now, please pass it in the options"),
        t.maxTextures = ml());
        const {maxTextures: e, attributesInitialSize: i, indicesInitialSize: r} = t;
        this.attributeBuffer = new nr(i * 4),
        this.indexBuffer = new Uint16Array(r),
        this.maxTextures = e
    }
    begin() {
        this.elementSize = 0,
        this.elementStart = 0,
        this.indexSize = 0,
        this.attributeSize = 0;
        for (let t = 0; t < this.batchIndex; t++)
            lr(this.batches[t]);
        this.batchIndex = 0,
        this._batchIndexStart = 0,
        this._batchIndexSize = 0,
        this.dirty = !0
    }
    add(t) {
        this._elements[this.elementSize++] = t,
        t._indexStart = this.indexSize,
        t._attributeStart = this.attributeSize,
        t._batcher = this,
        this.indexSize += t.indexSize,
        this.attributeSize += t.attributeSize * this.vertexSize
    }
    checkAndUpdateTexture(t, e) {
        const i = t._batch.textures.ids[e._source.uid];
        return !i && i !== 0 ? !1 : (t._textureId = i,
        t.texture = e,
        !0)
    }
    updateElement(t) {
        this.dirty = !0;
        const e = this.attributeBuffer;
        t.packAsQuad ? this.packQuadAttributes(t, e.float32View, e.uint32View, t._attributeStart, t._textureId) : this.packAttributes(t, e.float32View, e.uint32View, t._attributeStart, t._textureId)
    }
    break(t) {
        const e = this._elements;
        if (!e[this.elementStart])
            return;
        let i = hr()
          , r = i.textures;
        r.clear();
        const n = e[this.elementStart];
        let a = or(n.blendMode, n.texture._source)
          , o = n.topology;
        this.attributeSize * 4 > this.attributeBuffer.size && this._resizeAttributeBuffer(this.attributeSize * 4),
        this.indexSize > this.indexBuffer.length && this._resizeIndexBuffer(this.indexSize);
        const h = this.attributeBuffer.float32View
          , l = this.attributeBuffer.uint32View
          , c = this.indexBuffer;
        let u = this._batchIndexSize
          , d = this._batchIndexStart
          , f = "startBatch"
          , p = [];
        const m = this.maxTextures;
        for (let g = this.elementStart; g < this.elementSize; ++g) {
            const x = e[g];
            e[g] = null;
            const _ = x.texture._source
              , b = or(x.blendMode, _)
              , A = a !== b || o !== x.topology;
            if (_._batchTick === ve && !A) {
                x._textureId = _._textureBindLocation,
                u += x.indexSize,
                x.packAsQuad ? (this.packQuadAttributes(x, h, l, x._attributeStart, x._textureId),
                this.packQuadIndex(c, x._indexStart, x._attributeStart / this.vertexSize)) : (this.packAttributes(x, h, l, x._attributeStart, x._textureId),
                this.packIndex(x, c, x._indexStart, x._attributeStart / this.vertexSize)),
                x._batch = i,
                p.push(x);
                continue
            }
            _._batchTick = ve,
            (r.count >= m || A) && (this._finishBatch(i, d, u - d, r, a, o, t, f, p),
            f = "renderBatch",
            d = u,
            a = b,
            o = x.topology,
            i = hr(),
            r = i.textures,
            r.clear(),
            p = [],
            ++ve),
            x._textureId = _._textureBindLocation = r.count,
            r.ids[_.uid] = r.count,
            r.textures[r.count++] = _,
            x._batch = i,
            p.push(x),
            u += x.indexSize,
            x.packAsQuad ? (this.packQuadAttributes(x, h, l, x._attributeStart, x._textureId),
            this.packQuadIndex(c, x._indexStart, x._attributeStart / this.vertexSize)) : (this.packAttributes(x, h, l, x._attributeStart, x._textureId),
            this.packIndex(x, c, x._indexStart, x._attributeStart / this.vertexSize))
        }
        r.count > 0 && (this._finishBatch(i, d, u - d, r, a, o, t, f, p),
        d = u,
        ++ve),
        this.elementStart = this.elementSize,
        this._batchIndexStart = d,
        this._batchIndexSize = u
    }
    _finishBatch(t, e, i, r, n, a, o, h, l) {
        t.gpuBindGroup = null,
        t.bindGroup = null,
        t.action = h,
        t.batcher = this,
        t.textures = r,
        t.blendMode = n,
        t.topology = a,
        t.start = e,
        t.size = i,
        t.elements = l,
        ++ve,
        this.batches[this.batchIndex++] = t,
        o.add(t)
    }
    finish(t) {
        this.break(t)
    }
    ensureAttributeBuffer(t) {
        t * 4 <= this.attributeBuffer.size || this._resizeAttributeBuffer(t * 4)
    }
    ensureIndexBuffer(t) {
        t <= this.indexBuffer.length || this._resizeIndexBuffer(t)
    }
    _resizeAttributeBuffer(t) {
        const e = Math.max(t, this.attributeBuffer.size * 2)
          , i = new nr(e);
        ar(this.attributeBuffer.rawBinaryData, i.rawBinaryData),
        this.attributeBuffer = i
    }
    _resizeIndexBuffer(t) {
        const e = this.indexBuffer;
        let i = Math.max(t, e.length * 1.5);
        i += i % 2;
        const r = i > 65535 ? new Uint32Array(i) : new Uint16Array(i);
        if (r.BYTES_PER_ELEMENT !== e.BYTES_PER_ELEMENT)
            for (let n = 0; n < e.length; n++)
                r[n] = e[n];
        else
            ar(e.buffer, r.buffer);
        this.indexBuffer = r
    }
    packQuadIndex(t, e, i) {
        t[e] = i + 0,
        t[e + 1] = i + 1,
        t[e + 2] = i + 2,
        t[e + 3] = i + 0,
        t[e + 4] = i + 2,
        t[e + 5] = i + 3
    }
    packIndex(t, e, i, r) {
        const n = t.indices
          , a = t.indexSize
          , o = t.indexOffset
          , h = t.attributeOffset;
        for (let l = 0; l < a; l++)
            e[i++] = r + n[l + o] - h
    }
    destroy(t={}) {
        var e;
        if (this.batches !== null) {
            for (let i = 0; i < this.batchIndex; i++)
                lr(this.batches[i]);
            this.batches = null,
            this.geometry.destroy(!0),
            this.geometry = null,
            t.shader && ((e = this.shader) == null || e.destroy(),
            this.shader = null);
            for (let i = 0; i < this._elements.length; i++)
                this._elements[i] && (this._elements[i]._batch = null);
            this._elements = null,
            this.indexBuffer = null,
            this.attributeBuffer.destroy(),
            this.attributeBuffer = null
        }
    }
}
;
ta.defaultOptions = {
    maxTextures: null,
    attributesInitialSize: 4,
    indicesInitialSize: 6
};
let _l = ta;
var ht = (s => (s[s.MAP_READ = 1] = "MAP_READ",
s[s.MAP_WRITE = 2] = "MAP_WRITE",
s[s.COPY_SRC = 4] = "COPY_SRC",
s[s.COPY_DST = 8] = "COPY_DST",
s[s.INDEX = 16] = "INDEX",
s[s.VERTEX = 32] = "VERTEX",
s[s.UNIFORM = 64] = "UNIFORM",
s[s.STORAGE = 128] = "STORAGE",
s[s.INDIRECT = 256] = "INDIRECT",
s[s.QUERY_RESOLVE = 512] = "QUERY_RESOLVE",
s[s.STATIC = 1024] = "STATIC",
s))(ht || {});
class We extends vt {
    constructor(t) {
        let {data: e, size: i} = t;
        const {usage: r, label: n, shrinkToFit: a} = t;
        super(),
        this._gpuData = Object.create(null),
        this._gcLastUsed = -1,
        this.autoGarbageCollect = !0,
        this.uid = q("buffer"),
        this._resourceType = "buffer",
        this._resourceId = q("resource"),
        this._touched = 0,
        this._updateID = 1,
        this._dataInt32 = null,
        this.shrinkToFit = !0,
        this.destroyed = !1,
        e instanceof Array && (e = new Float32Array(e)),
        this._data = e,
        i ?? (i = e == null ? void 0 : e.byteLength);
        const o = !!e;
        this.descriptor = {
            size: i,
            usage: r,
            mappedAtCreation: o,
            label: n
        },
        this.shrinkToFit = a ?? !0
    }
    get data() {
        return this._data
    }
    set data(t) {
        this.setDataWithSize(t, t.length, !0)
    }
    get dataInt32() {
        return this._dataInt32 || (this._dataInt32 = new Int32Array(this.data.buffer)),
        this._dataInt32
    }
    get static() {
        return !!(this.descriptor.usage & ht.STATIC)
    }
    set static(t) {
        t ? this.descriptor.usage |= ht.STATIC : this.descriptor.usage &= ~ht.STATIC
    }
    setDataWithSize(t, e, i) {
        if (this._updateID++,
        this._updateSize = e * t.BYTES_PER_ELEMENT,
        this._data === t) {
            i && this.emit("update", this);
            return
        }
        const r = this._data;
        if (this._data = t,
        this._dataInt32 = null,
        !r || r.length !== t.length) {
            !this.shrinkToFit && r && t.byteLength < r.byteLength ? i && this.emit("update", this) : (this.descriptor.size = t.byteLength,
            this._resourceId = q("resource"),
            this.emit("change", this));
            return
        }
        i && this.emit("update", this)
    }
    update(t) {
        this._updateSize = t ?? this._updateSize,
        this._updateID++,
        this.emit("update", this)
    }
    unload() {
        var t;
        this.emit("unload", this);
        for (const e in this._gpuData)
            (t = this._gpuData[e]) == null || t.destroy();
        this._gpuData = Object.create(null)
    }
    destroy() {
        this.destroyed = !0,
        this.unload(),
        this.emit("destroy", this),
        this.emit("change", this),
        this._data = null,
        this.descriptor = null,
        this.removeAllListeners()
    }
}
function sa(s, t) {
    if (!(s instanceof We)) {
        let e = t ? ht.INDEX : ht.VERTEX;
        s instanceof Array && (t ? (s = new Uint32Array(s),
        e = ht.INDEX | ht.COPY_DST) : (s = new Float32Array(s),
        e = ht.VERTEX | ht.COPY_DST)),
        s = new We({
            data: s,
            label: t ? "index-mesh-buffer" : "vertex-mesh-buffer",
            usage: e
        })
    }
    return s
}
function bl(s, t, e) {
    const i = s.getAttribute(t);
    if (!i)
        return e.minX = 0,
        e.minY = 0,
        e.maxX = 0,
        e.maxY = 0,
        e;
    const r = i.buffer.data;
    let n = 1 / 0
      , a = 1 / 0
      , o = -1 / 0
      , h = -1 / 0;
    const l = r.BYTES_PER_ELEMENT
      , c = (i.offset || 0) / l
      , u = (i.stride || 8) / l;
    for (let d = c; d < r.length; d += u) {
        const f = r[d]
          , p = r[d + 1];
        f > o && (o = f),
        p > h && (h = p),
        f < n && (n = f),
        p < a && (a = p)
    }
    return e.minX = n,
    e.minY = a,
    e.maxX = o,
    e.maxY = h,
    e
}
function wl(s) {
    return (s instanceof We || Array.isArray(s) || s.BYTES_PER_ELEMENT) && (s = {
        buffer: s
    }),
    s.buffer = sa(s.buffer, !1),
    s
}
class Al extends vt {
    constructor(t={}) {
        super(),
        this._gpuData = Object.create(null),
        this.autoGarbageCollect = !0,
        this._gcLastUsed = -1,
        this.uid = q("geometry"),
        this._layoutKey = 0,
        this.instanceCount = 1,
        this._bounds = new gt,
        this._boundsDirty = !0;
        const {attributes: e, indexBuffer: i, topology: r} = t;
        if (this.buffers = [],
        this.attributes = {},
        e)
            for (const n in e)
                this.addAttribute(n, e[n]);
        this.instanceCount = t.instanceCount ?? 1,
        i && this.addIndex(i),
        this.topology = r || "triangle-list"
    }
    onBufferUpdate() {
        this._boundsDirty = !0,
        this.emit("update", this)
    }
    getAttribute(t) {
        return this.attributes[t]
    }
    getIndex() {
        return this.indexBuffer
    }
    getBuffer(t) {
        return this.getAttribute(t).buffer
    }
    getSize() {
        for (const t in this.attributes) {
            const e = this.attributes[t];
            return e.buffer.data.length / (e.stride / 4 || e.size)
        }
        return 0
    }
    addAttribute(t, e) {
        const i = wl(e);
        this.buffers.indexOf(i.buffer) === -1 && (this.buffers.push(i.buffer),
        i.buffer.on("update", this.onBufferUpdate, this),
        i.buffer.on("change", this.onBufferUpdate, this)),
        this.attributes[t] = i
    }
    addIndex(t) {
        this.indexBuffer = sa(t, !0),
        this.buffers.push(this.indexBuffer)
    }
    get bounds() {
        return this._boundsDirty ? (this._boundsDirty = !1,
        bl(this, "aPosition", this._bounds)) : this._bounds
    }
    unload() {
        var t;
        this.emit("unload", this);
        for (const e in this._gpuData)
            (t = this._gpuData[e]) == null || t.destroy();
        this._gpuData = Object.create(null)
    }
    destroy(t=!1) {
        var e;
        this.emit("destroy", this),
        this.removeAllListeners(),
        t && this.buffers.forEach(i => i.destroy()),
        this.unload(),
        (e = this.indexBuffer) == null || e.destroy(),
        this.attributes = null,
        this.buffers = null,
        this.indexBuffer = null,
        this._bounds = null
    }
}
const vl = new Float32Array(1)
  , Sl = new Uint32Array(1);
class Tl extends Al {
    constructor() {
        const e = new We({
            data: vl,
            label: "attribute-batch-buffer",
            usage: ht.VERTEX | ht.COPY_DST,
            shrinkToFit: !1
        })
          , i = new We({
            data: Sl,
            label: "index-batch-buffer",
            usage: ht.INDEX | ht.COPY_DST,
            shrinkToFit: !1
        })
          , r = 24;
        super({
            attributes: {
                aPosition: {
                    buffer: e,
                    format: "float32x2",
                    stride: r,
                    offset: 0
                },
                aUV: {
                    buffer: e,
                    format: "float32x2",
                    stride: r,
                    offset: 8
                },
                aColor: {
                    buffer: e,
                    format: "unorm8x4",
                    stride: r,
                    offset: 16
                },
                aTextureIdAndRound: {
                    buffer: e,
                    format: "uint16x2",
                    stride: r,
                    offset: 20
                }
            },
            indexBuffer: i
        })
    }
}
function cr(s, t, e) {
    if (s)
        for (const i in s) {
            const r = i.toLocaleLowerCase()
              , n = t[r];
            if (n) {
                let a = s[i];
                i === "header" && (a = a.replace(/@in\s+[^;]+;\s*/g, "").replace(/@out\s+[^;]+;\s*/g, "")),
                e && n.push(`//----${e}----//`),
                n.push(a)
            } else
                $(`${i} placement hook does not exist in shader`)
        }
}
const Cl = /\{\{(.*?)\}\}/g;
function ur(s) {
    var i;
    const t = {};
    return (((i = s.match(Cl)) == null ? void 0 : i.map(r => r.replace(/[{()}]/g, ""))) ?? []).forEach(r => {
        t[r] = []
    }
    ),
    t
}
function dr(s, t) {
    let e;
    const i = /@in\s+([^;]+);/g;
    for (; (e = i.exec(s)) !== null; )
        t.push(e[1])
}
function fr(s, t, e=!1) {
    const i = [];
    dr(t, i),
    s.forEach(o => {
        o.header && dr(o.header, i)
    }
    );
    const r = i;
    e && r.sort();
    const n = r.map( (o, h) => `       @location(${h}) ${o},`).join(`
`);
    let a = t.replace(/@in\s+[^;]+;\s*/g, "");
    return a = a.replace("{{in}}", `
${n}
`),
    a
}
function pr(s, t) {
    let e;
    const i = /@out\s+([^;]+);/g;
    for (; (e = i.exec(s)) !== null; )
        t.push(e[1])
}
function Pl(s) {
    const e = /\b(\w+)\s*:/g.exec(s);
    return e ? e[1] : ""
}
function Ml(s) {
    const t = /@.*?\s+/g;
    return s.replace(t, "")
}
function kl(s, t) {
    const e = [];
    pr(t, e),
    s.forEach(h => {
        h.header && pr(h.header, e)
    }
    );
    let i = 0;
    const r = e.sort().map(h => h.indexOf("builtin") > -1 ? h : `@location(${i++}) ${h}`).join(`,
`)
      , n = e.sort().map(h => `       var ${Ml(h)};`).join(`
`)
      , a = `return VSOutput(
            ${e.sort().map(h => ` ${Pl(h)}`).join(`,
`)});`;
    let o = t.replace(/@out\s+[^;]+;\s*/g, "");
    return o = o.replace("{{struct}}", `
${r}
`),
    o = o.replace("{{start}}", `
${n}
`),
    o = o.replace("{{return}}", `
${a}
`),
    o
}
function gr(s, t) {
    let e = s;
    for (const i in t) {
        const r = t[i];
        r.join(`
`).length ? e = e.replace(`{{${i}}}`, `//-----${i} START-----//
${r.join(`
`)}
//----${i} FINISH----//`) : e = e.replace(`{{${i}}}`, "")
    }
    return e
}
const Lt = Object.create(null)
  , Ds = new Map;
let El = 0;
function Il({template: s, bits: t}) {
    const e = ia(s, t);
    if (Lt[e])
        return Lt[e];
    const {vertex: i, fragment: r} = Bl(s, t);
    return Lt[e] = ra(i, r, t),
    Lt[e]
}
function Rl({template: s, bits: t}) {
    const e = ia(s, t);
    return Lt[e] || (Lt[e] = ra(s.vertex, s.fragment, t)),
    Lt[e]
}
function Bl(s, t) {
    const e = t.map(a => a.vertex).filter(a => !!a)
      , i = t.map(a => a.fragment).filter(a => !!a);
    let r = fr(e, s.vertex, !0);
    r = kl(e, r);
    const n = fr(i, s.fragment, !0);
    return {
        vertex: r,
        fragment: n
    }
}
function ia(s, t) {
    return t.map(e => (Ds.has(e) || Ds.set(e, El++),
    Ds.get(e))).sort( (e, i) => e - i).join("-") + s.vertex + s.fragment
}
function ra(s, t, e) {
    const i = ur(s)
      , r = ur(t);
    return e.forEach(n => {
        cr(n.vertex, i, n.name),
        cr(n.fragment, r, n.name)
    }
    ),
    {
        vertex: gr(s, i),
        fragment: gr(t, r)
    }
}
const Fl = `
    @in aPosition: vec2<f32>;
    @in aUV: vec2<f32>;

    @out @builtin(position) vPosition: vec4<f32>;
    @out vUV : vec2<f32>;
    @out vColor : vec4<f32>;

    {{header}}

    struct VSOutput {
        {{struct}}
    };

    @vertex
    fn main( {{in}} ) -> VSOutput {

        var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
        var modelMatrix = mat3x3<f32>(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        var position = aPosition;
        var uv = aUV;

        {{start}}

        vColor = vec4<f32>(1., 1., 1., 1.);

        {{main}}

        vUV = uv;

        var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;

        vPosition =  vec4<f32>((modelViewProjectionMatrix *  vec3<f32>(position, 1.0)).xy, 0.0, 1.0);

        vColor *= globalUniforms.uWorldColorAlpha;

        {{end}}

        {{return}}
    };
`
  , Ll = `
    @in vUV : vec2<f32>;
    @in vColor : vec4<f32>;

    {{header}}

    @fragment
    fn main(
        {{in}}
      ) -> @location(0) vec4<f32> {

        {{start}}

        var outColor:vec4<f32>;

        {{main}}

        var finalColor:vec4<f32> = outColor * vColor;

        {{end}}

        return finalColor;
      };
`
  , Gl = `
    in vec2 aPosition;
    in vec2 aUV;

    out vec4 vColor;
    out vec2 vUV;

    {{header}}

    void main(void){

        mat3 worldTransformMatrix = uWorldTransformMatrix;
        mat3 modelMatrix = mat3(
            1.0, 0.0, 0.0,
            0.0, 1.0, 0.0,
            0.0, 0.0, 1.0
          );
        vec2 position = aPosition;
        vec2 uv = aUV;

        {{start}}

        vColor = vec4(1.);

        {{main}}

        vUV = uv;

        mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;

        gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);

        vColor *= uWorldColorAlpha;

        {{end}}
    }
`
  , Dl = `

    in vec4 vColor;
    in vec2 vUV;

    out vec4 finalColor;

    {{header}}

    void main(void) {

        {{start}}

        vec4 outColor;

        {{main}}

        finalColor = outColor * vColor;

        {{end}}
    }
`
  , zl = {
    name: "global-uniforms-bit",
    vertex: {
        header: `
        struct GlobalUniforms {
            uProjectionMatrix:mat3x3<f32>,
            uWorldTransformMatrix:mat3x3<f32>,
            uWorldColorAlpha: vec4<f32>,
            uResolution: vec2<f32>,
        }

        @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
        `
    }
}
  , Wl = {
    name: "global-uniforms-bit",
    vertex: {
        header: `
          uniform mat3 uProjectionMatrix;
          uniform mat3 uWorldTransformMatrix;
          uniform vec4 uWorldColorAlpha;
          uniform vec2 uResolution;
        `
    }
};
function Ol({bits: s, name: t}) {
    const e = Il({
        template: {
            fragment: Ll,
            vertex: Fl
        },
        bits: [zl, ...s]
    });
    return ps.from({
        name: t,
        vertex: {
            source: e.vertex,
            entryPoint: "main"
        },
        fragment: {
            source: e.fragment,
            entryPoint: "main"
        }
    })
}
function Ul({bits: s, name: t}) {
    return new Bn({
        name: t,
        ...Rl({
            template: {
                vertex: Gl,
                fragment: Dl
            },
            bits: [Wl, ...s]
        })
    })
}
const Nl = {
    name: "color-bit",
    vertex: {
        header: `
            @in aColor: vec4<f32>;
        `,
        main: `
            vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
        `
    }
}
  , Hl = {
    name: "color-bit",
    vertex: {
        header: `
            in vec4 aColor;
        `,
        main: `
            vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
        `
    }
}
  , zs = {};
function $l(s) {
    const t = [];
    if (s === 1)
        t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),
        t.push("@group(1) @binding(1) var textureSampler1: sampler;");
    else {
        let e = 0;
        for (let i = 0; i < s; i++)
            t.push(`@group(1) @binding(${e++}) var textureSource${i + 1}: texture_2d<f32>;`),
            t.push(`@group(1) @binding(${e++}) var textureSampler${i + 1}: sampler;`)
    }
    return t.join(`
`)
}
function Vl(s) {
    const t = [];
    if (s === 1)
        t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");
    else {
        t.push("switch vTextureId {");
        for (let e = 0; e < s; e++)
            e === s - 1 ? t.push("  default:{") : t.push(`  case ${e}:{`),
            t.push(`      outColor = textureSampleGrad(textureSource${e + 1}, textureSampler${e + 1}, vUV, uvDx, uvDy);`),
            t.push("      break;}");
        t.push("}")
    }
    return t.join(`
`)
}
function jl(s) {
    return zs[s] || (zs[s] = {
        name: "texture-batch-bit",
        vertex: {
            header: `
                @in aTextureIdAndRound: vec2<u32>;
                @out @interpolate(flat) vTextureId : u32;
            `,
            main: `
                vTextureId = aTextureIdAndRound.y;
            `,
            end: `
                if(aTextureIdAndRound.x == 1)
                {
                    vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
                }
            `
        },
        fragment: {
            header: `
                @in @interpolate(flat) vTextureId: u32;

                ${$l(s)}
            `,
            main: `
                var uvDx = dpdx(vUV);
                var uvDy = dpdy(vUV);

                ${Vl(s)}
            `
        }
    }),
    zs[s]
}
const Ws = {};
function Yl(s) {
    const t = [];
    for (let e = 0; e < s; e++)
        e > 0 && t.push("else"),
        e < s - 1 && t.push(`if(vTextureId < ${e}.5)`),
        t.push("{"),
        t.push(`	outColor = texture(uTextures[${e}], vUV);`),
        t.push("}");
    return t.join(`
`)
}
function Xl(s) {
    return Ws[s] || (Ws[s] = {
        name: "texture-batch-bit",
        vertex: {
            header: `
                in vec2 aTextureIdAndRound;
                out float vTextureId;

            `,
            main: `
                vTextureId = aTextureIdAndRound.y;
            `,
            end: `
                if(aTextureIdAndRound.x == 1.)
                {
                    gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
                }
            `
        },
        fragment: {
            header: `
                in float vTextureId;

                uniform sampler2D uTextures[${s}];

            `,
            main: `

                ${Yl(s)}
            `
        }
    }),
    Ws[s]
}
const ql = {
    name: "round-pixels-bit",
    vertex: {
        header: `
            fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `
    }
}
  , Kl = {
    name: "round-pixels-bit",
    vertex: {
        header: `
            vec2 roundPixels(vec2 position, vec2 targetSize)
            {
                return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
            }
        `
    }
}
  , mr = {};
function Zl(s) {
    let t = mr[s];
    if (t)
        return t;
    const e = new Int32Array(s);
    for (let i = 0; i < s; i++)
        e[i] = i;
    return t = mr[s] = new Dn({
        uTextures: {
            value: e,
            type: "i32",
            size: s
        }
    },{
        isStatic: !0
    }),
    t
}
class xr extends xi {
    constructor(t) {
        const e = Ul({
            name: "batch",
            bits: [Hl, Xl(t), Kl]
        })
          , i = Ol({
            name: "batch",
            bits: [Nl, jl(t), ql]
        });
        super({
            glProgram: e,
            gpuProgram: i,
            resources: {
                batchSamplers: Zl(t)
            }
        }),
        this.maxTextures = t
    }
}
let Se = null;
const na = class aa extends _l {
    constructor(t) {
        super(t),
        this.geometry = new Tl,
        this.name = aa.extension.name,
        this.vertexSize = 6,
        Se ?? (Se = new xr(t.maxTextures)),
        this.shader = Se
    }
    packAttributes(t, e, i, r, n) {
        const a = n << 16 | t.roundPixels & 65535
          , o = t.transform
          , h = o.a
          , l = o.b
          , c = o.c
          , u = o.d
          , d = o.tx
          , f = o.ty
          , {positions: p, uvs: m} = t
          , g = t.color
          , x = t.attributeOffset
          , y = x + t.attributeSize;
        for (let _ = x; _ < y; _++) {
            const b = _ * 2
              , A = p[b]
              , w = p[b + 1];
            e[r++] = h * A + c * w + d,
            e[r++] = u * w + l * A + f,
            e[r++] = m[b],
            e[r++] = m[b + 1],
            i[r++] = g,
            i[r++] = a
        }
    }
    packQuadAttributes(t, e, i, r, n) {
        const a = t.texture
          , o = t.transform
          , h = o.a
          , l = o.b
          , c = o.c
          , u = o.d
          , d = o.tx
          , f = o.ty
          , p = t.bounds
          , m = p.maxX
          , g = p.minX
          , x = p.maxY
          , y = p.minY
          , _ = a.uvs
          , b = t.color
          , A = n << 16 | t.roundPixels & 65535;
        e[r + 0] = h * g + c * y + d,
        e[r + 1] = u * y + l * g + f,
        e[r + 2] = _.x0,
        e[r + 3] = _.y0,
        i[r + 4] = b,
        i[r + 5] = A,
        e[r + 6] = h * m + c * y + d,
        e[r + 7] = u * y + l * m + f,
        e[r + 8] = _.x1,
        e[r + 9] = _.y1,
        i[r + 10] = b,
        i[r + 11] = A,
        e[r + 12] = h * m + c * x + d,
        e[r + 13] = u * x + l * m + f,
        e[r + 14] = _.x2,
        e[r + 15] = _.y2,
        i[r + 16] = b,
        i[r + 17] = A,
        e[r + 18] = h * g + c * x + d,
        e[r + 19] = u * x + l * g + f,
        e[r + 20] = _.x3,
        e[r + 21] = _.y3,
        i[r + 22] = b,
        i[r + 23] = A
    }
    _updateMaxTextures(t) {
        this.shader.maxTextures !== t && (Se = new xr(t),
        this.shader = Se)
    }
    destroy() {
        this.shader = null,
        super.destroy()
    }
}
;
na.extension = {
    type: [I.Batcher],
    name: "default"
};
let Ql = na;
class oa {
    constructor(t) {
        this.items = Object.create(null);
        const {renderer: e, type: i, onUnload: r, priority: n, name: a} = t;
        this._renderer = e,
        e.gc.addResourceHash(this, "items", i, n ?? 0),
        this._onUnload = r,
        this.name = a
    }
    add(t) {
        return this.items[t.uid] ? !1 : (this.items[t.uid] = t,
        t.once("unload", this.remove, this),
        t._gcLastUsed = this._renderer.gc.now,
        !0)
    }
    remove(t, ...e) {
        var r;
        if (!this.items[t.uid])
            return;
        const i = t._gpuData[this._renderer.uid];
        i && ((r = this._onUnload) == null || r.call(this, t, ...e),
        i.destroy(),
        t._gpuData[this._renderer.uid] = null,
        this.items[t.uid] = null)
    }
    removeAll(...t) {
        Object.values(this.items).forEach(e => e && this.remove(e, ...t))
    }
    destroy(...t) {
        this.removeAll(...t),
        this.items = Object.create(null),
        this._renderer = null,
        this._onUnload = null
    }
}
function Jl(s, t, e, i, r, n, a, o=null) {
    let h = 0;
    e *= t,
    r *= n;
    const l = o.a
      , c = o.b
      , u = o.c
      , d = o.d
      , f = o.tx
      , p = o.ty;
    for (; h < a; ) {
        const m = s[e]
          , g = s[e + 1];
        i[r] = l * m + u * g + f,
        i[r + 1] = c * m + d * g + p,
        r += n,
        e += t,
        h++
    }
}
function tc(s, t, e, i) {
    let r = 0;
    for (t *= e; r < i; )
        s[t] = 0,
        s[t + 1] = 0,
        t += e,
        r++
}
function ha(s, t, e, i, r) {
    const n = t.a
      , a = t.b
      , o = t.c
      , h = t.d
      , l = t.tx
      , c = t.ty;
    e || (e = 0),
    i || (i = 2),
    r || (r = s.length / i - e);
    let u = e * i;
    for (let d = 0; d < r; d++) {
        const f = s[u]
          , p = s[u + 1];
        s[u] = n * f + o * p + l,
        s[u + 1] = a * f + h * p + c,
        u += i
    }
}
const ec = new D;
class la {
    constructor() {
        this.packAsQuad = !1,
        this.batcherName = "default",
        this.topology = "triangle-list",
        this.applyTransform = !0,
        this.roundPixels = 0,
        this._batcher = null,
        this._batch = null
    }
    get uvs() {
        return this.geometryData.uvs
    }
    get positions() {
        return this.geometryData.vertices
    }
    get indices() {
        return this.geometryData.indices
    }
    get blendMode() {
        return this.renderable && this.applyTransform ? this.renderable.groupBlendMode : "normal"
    }
    get color() {
        const t = this.baseColor
          , e = t >> 16 | t & 65280 | (t & 255) << 16
          , i = this.renderable;
        return i ? dn(e, i.groupColor) + (this.alpha * i.groupAlpha * 255 << 24) : e + (this.alpha * 255 << 24)
    }
    get transform() {
        var t;
        return ((t = this.renderable) == null ? void 0 : t.groupTransform) || ec
    }
    copyTo(t) {
        t.indexOffset = this.indexOffset,
        t.indexSize = this.indexSize,
        t.attributeOffset = this.attributeOffset,
        t.attributeSize = this.attributeSize,
        t.baseColor = this.baseColor,
        t.alpha = this.alpha,
        t.texture = this.texture,
        t.geometryData = this.geometryData,
        t.topology = this.topology
    }
    reset() {
        this.applyTransform = !0,
        this.renderable = null,
        this.topology = "triangle-list"
    }
    destroy() {
        this.renderable = null,
        this.texture = null,
        this.geometryData = null,
        this._batcher = null,
        this._batch = null
    }
}
const Oe = {
    extension: {
        type: I.ShapeBuilder,
        name: "circle"
    },
    build(s, t) {
        let e, i, r, n, a, o;
        if (s.type === "circle") {
            const b = s;
            if (a = o = b.radius,
            a <= 0)
                return !1;
            e = b.x,
            i = b.y,
            r = n = 0
        } else if (s.type === "ellipse") {
            const b = s;
            if (a = b.halfWidth,
            o = b.halfHeight,
            a <= 0 || o <= 0)
                return !1;
            e = b.x,
            i = b.y,
            r = n = 0
        } else {
            const b = s
              , A = b.width / 2
              , w = b.height / 2;
            e = b.x + A,
            i = b.y + w,
            a = o = Math.max(0, Math.min(b.radius, Math.min(A, w))),
            r = A - a,
            n = w - o
        }
        if (r < 0 || n < 0)
            return !1;
        const h = Math.ceil(2.3 * Math.sqrt(a + o))
          , l = h * 8 + (r ? 4 : 0) + (n ? 4 : 0);
        if (l === 0)
            return !1;
        if (h === 0)
            return t[0] = t[6] = e + r,
            t[1] = t[3] = i + n,
            t[2] = t[4] = e - r,
            t[5] = t[7] = i - n,
            !0;
        let c = 0
          , u = h * 4 + (r ? 2 : 0) + 2
          , d = u
          , f = l
          , p = r + a
          , m = n
          , g = e + p
          , x = e - p
          , y = i + m;
        if (t[c++] = g,
        t[c++] = y,
        t[--u] = y,
        t[--u] = x,
        n) {
            const b = i - m;
            t[d++] = x,
            t[d++] = b,
            t[--f] = b,
            t[--f] = g
        }
        for (let b = 1; b < h; b++) {
            const A = Math.PI / 2 * (b / h)
              , w = r + Math.cos(A) * a
              , v = n + Math.sin(A) * o
              , M = e + w
              , T = e - w
              , S = i + v
              , C = i - v;
            t[c++] = M,
            t[c++] = S,
            t[--u] = S,
            t[--u] = T,
            t[d++] = T,
            t[d++] = C,
            t[--f] = C,
            t[--f] = M
        }
        p = r,
        m = n + o,
        g = e + p,
        x = e - p,
        y = i + m;
        const _ = i - m;
        return t[c++] = g,
        t[c++] = y,
        t[--f] = _,
        t[--f] = g,
        r && (t[c++] = x,
        t[c++] = y,
        t[--f] = _,
        t[--f] = x),
        !0
    },
    triangulate(s, t, e, i, r, n) {
        if (s.length === 0)
            return;
        let a = 0
          , o = 0;
        for (let c = 0; c < s.length; c += 2)
            a += s[c],
            o += s[c + 1];
        a /= s.length / 2,
        o /= s.length / 2;
        let h = i;
        t[h * e] = a,
        t[h * e + 1] = o;
        const l = h++;
        for (let c = 0; c < s.length; c += 2)
            t[h * e] = s[c],
            t[h * e + 1] = s[c + 1],
            c > 0 && (r[n++] = h,
            r[n++] = l,
            r[n++] = h - 1),
            h++;
        r[n++] = l + 1,
        r[n++] = l,
        r[n++] = h - 1
    }
}
  , sc = {
    ...Oe,
    extension: {
        ...Oe.extension,
        name: "ellipse"
    }
}
  , ic = {
    ...Oe,
    extension: {
        ...Oe.extension,
        name: "roundedRectangle"
    }
}
  , ca = 1e-4
  , yr = 1e-4;
function rc(s) {
    const t = s.length;
    if (t < 6)
        return 1;
    let e = 0;
    for (let i = 0, r = s[t - 2], n = s[t - 1]; i < t; i += 2) {
        const a = s[i]
          , o = s[i + 1];
        e += (a - r) * (o + n),
        r = a,
        n = o
    }
    return e < 0 ? -1 : 1
}
function _r(s, t, e, i, r, n, a, o) {
    const h = s - e * r
      , l = t - i * r
      , c = s + e * n
      , u = t + i * n;
    let d, f;
    a ? (d = i,
    f = -e) : (d = -i,
    f = e);
    const p = h + d
      , m = l + f
      , g = c + d
      , x = u + f;
    return o.push(p, m),
    o.push(g, x),
    2
}
function Ht(s, t, e, i, r, n, a, o) {
    const h = e - s
      , l = i - t;
    let c = Math.atan2(h, l)
      , u = Math.atan2(r - s, n - t);
    o && c < u ? c += Math.PI * 2 : !o && c > u && (u += Math.PI * 2);
    let d = c;
    const f = u - c
      , p = Math.abs(f)
      , m = Math.sqrt(h * h + l * l)
      , g = (15 * p * Math.sqrt(m) / Math.PI >> 0) + 1
      , x = f / g;
    if (d += x,
    o) {
        a.push(s, t),
        a.push(e, i);
        for (let y = 1, _ = d; y < g; y++,
        _ += x)
            a.push(s, t),
            a.push(s + Math.sin(_) * m, t + Math.cos(_) * m);
        a.push(s, t),
        a.push(r, n)
    } else {
        a.push(e, i),
        a.push(s, t);
        for (let y = 1, _ = d; y < g; y++,
        _ += x)
            a.push(s + Math.sin(_) * m, t + Math.cos(_) * m),
            a.push(s, t);
        a.push(r, n),
        a.push(s, t)
    }
    return g * 2
}
function nc(s, t, e, i, r, n) {
    const a = ca;
    if (s.length === 0)
        return;
    const o = t;
    let h = o.alignment;
    if (t.alignment !== .5) {
        let B = rc(s);
        h = (h - .5) * B + .5
    }
    const l = new nt(s[0],s[1])
      , c = new nt(s[s.length - 2],s[s.length - 1])
      , u = i
      , d = Math.abs(l.x - c.x) < a && Math.abs(l.y - c.y) < a;
    if (u) {
        s = s.slice(),
        d && (s.pop(),
        s.pop(),
        c.set(s[s.length - 2], s[s.length - 1]));
        const B = (l.x + c.x) * .5
          , z = (c.y + l.y) * .5;
        s.unshift(B, z),
        s.push(B, z)
    }
    const f = r
      , p = s.length / 2;
    let m = s.length;
    const g = f.length / 2
      , x = o.width / 2
      , y = x * x
      , _ = o.miterLimit * o.miterLimit;
    let b = s[0]
      , A = s[1]
      , w = s[2]
      , v = s[3]
      , M = 0
      , T = 0
      , S = -(A - v)
      , C = b - w
      , k = 0
      , R = 0
      , F = Math.sqrt(S * S + C * C);
    S /= F,
    C /= F,
    S *= x,
    C *= x;
    const rt = h
      , P = (1 - rt) * 2
      , E = rt * 2;
    u || (o.cap === "round" ? m += Ht(b - S * (P - E) * .5, A - C * (P - E) * .5, b - S * P, A - C * P, b + S * E, A + C * E, f, !0) + 2 : o.cap === "square" && (m += _r(b, A, S, C, P, E, !0, f))),
    f.push(b - S * P, A - C * P),
    f.push(b + S * E, A + C * E);
    for (let B = 1; B < p - 1; ++B) {
        b = s[(B - 1) * 2],
        A = s[(B - 1) * 2 + 1],
        w = s[B * 2],
        v = s[B * 2 + 1],
        M = s[(B + 1) * 2],
        T = s[(B + 1) * 2 + 1],
        S = -(A - v),
        C = b - w,
        F = Math.sqrt(S * S + C * C),
        S /= F,
        C /= F,
        S *= x,
        C *= x,
        k = -(v - T),
        R = w - M,
        F = Math.sqrt(k * k + R * R),
        k /= F,
        R /= F,
        k *= x,
        R *= x;
        const z = w - b
          , H = A - v
          , G = w - M
          , Q = T - v
          , at = z * G + H * Q
          , ct = H * G - Q * z
          , tt = ct < 0;
        if (Math.abs(ct) < .001 * Math.abs(at)) {
            f.push(w - S * P, v - C * P),
            f.push(w + S * E, v + C * E),
            at >= 0 && (o.join === "round" ? m += Ht(w, v, w - S * P, v - C * P, w - k * P, v - R * P, f, !1) + 4 : m += 2,
            f.push(w - k * E, v - R * E),
            f.push(w + k * P, v + R * P));
            continue
        }
        const St = (-S + b) * (-C + v) - (-S + w) * (-C + A)
          , zt = (-k + M) * (-R + v) - (-k + w) * (-R + T)
          , te = (z * zt - G * St) / ct
          , Ne = (Q * St - H * zt) / ct
          , _s = (te - w) * (te - w) + (Ne - v) * (Ne - v)
          , Wt = w + (te - w) * P
          , Ot = v + (Ne - v) * P
          , Ut = w - (te - w) * E
          , Nt = v - (Ne - v) * E
          , Ba = Math.min(z * z + H * H, G * G + Q * Q)
          , Pi = tt ? P : E
          , Fa = Ba + Pi * Pi * y;
        _s <= Fa ? o.join === "bevel" || _s / y > _ ? (tt ? (f.push(Wt, Ot),
        f.push(w + S * E, v + C * E),
        f.push(Wt, Ot),
        f.push(w + k * E, v + R * E)) : (f.push(w - S * P, v - C * P),
        f.push(Ut, Nt),
        f.push(w - k * P, v - R * P),
        f.push(Ut, Nt)),
        m += 2) : o.join === "round" ? tt ? (f.push(Wt, Ot),
        f.push(w + S * E, v + C * E),
        m += Ht(w, v, w + S * E, v + C * E, w + k * E, v + R * E, f, !0) + 4,
        f.push(Wt, Ot),
        f.push(w + k * E, v + R * E)) : (f.push(w - S * P, v - C * P),
        f.push(Ut, Nt),
        m += Ht(w, v, w - S * P, v - C * P, w - k * P, v - R * P, f, !1) + 4,
        f.push(w - k * P, v - R * P),
        f.push(Ut, Nt)) : (f.push(Wt, Ot),
        f.push(Ut, Nt)) : (f.push(w - S * P, v - C * P),
        f.push(w + S * E, v + C * E),
        o.join === "round" ? tt ? m += Ht(w, v, w + S * E, v + C * E, w + k * E, v + R * E, f, !0) + 2 : m += Ht(w, v, w - S * P, v - C * P, w - k * P, v - R * P, f, !1) + 2 : o.join === "miter" && _s / y <= _ && (tt ? (f.push(Ut, Nt),
        f.push(Ut, Nt)) : (f.push(Wt, Ot),
        f.push(Wt, Ot)),
        m += 2),
        f.push(w - k * P, v - R * P),
        f.push(w + k * E, v + R * E),
        m += 2)
    }
    b = s[(p - 2) * 2],
    A = s[(p - 2) * 2 + 1],
    w = s[(p - 1) * 2],
    v = s[(p - 1) * 2 + 1],
    S = -(A - v),
    C = b - w,
    F = Math.sqrt(S * S + C * C),
    S /= F,
    C /= F,
    S *= x,
    C *= x,
    f.push(w - S * P, v - C * P),
    f.push(w + S * E, v + C * E),
    u || (o.cap === "round" ? m += Ht(w - S * (P - E) * .5, v - C * (P - E) * .5, w - S * P, v - C * P, w + S * E, v + C * E, f, !1) + 2 : o.cap === "square" && (m += _r(w, v, S, C, P, E, !1, f)));
    const N = yr * yr;
    for (let B = g; B < m + g - 2; ++B)
        b = f[B * 2],
        A = f[B * 2 + 1],
        w = f[(B + 1) * 2],
        v = f[(B + 1) * 2 + 1],
        M = f[(B + 2) * 2],
        T = f[(B + 2) * 2 + 1],
        !(Math.abs(b * (v - T) + w * (T - A) + M * (A - v)) < N) && n.push(B, B + 1, B + 2)
}
function ac(s, t, e, i) {
    const r = ca;
    if (s.length === 0)
        return;
    const n = s[0]
      , a = s[1]
      , o = s[s.length - 2]
      , h = s[s.length - 1]
      , l = t || Math.abs(n - o) < r && Math.abs(a - h) < r
      , c = e
      , u = s.length / 2
      , d = c.length / 2;
    for (let f = 0; f < u; f++)
        c.push(s[f * 2]),
        c.push(s[f * 2 + 1]);
    for (let f = 0; f < u - 1; f++)
        i.push(d + f, d + f + 1);
    l && i.push(d + u - 1, d)
}
function ua(s, t, e, i, r, n, a) {
    const o = wh(s, t, 2);
    if (!o)
        return;
    for (let l = 0; l < o.length; l += 3)
        n[a++] = o[l] + r,
        n[a++] = o[l + 1] + r,
        n[a++] = o[l + 2] + r;
    let h = r * i;
    for (let l = 0; l < s.length; l += 2)
        e[h] = s[l],
        e[h + 1] = s[l + 1],
        h += i
}
const oc = []
  , hc = {
    extension: {
        type: I.ShapeBuilder,
        name: "polygon"
    },
    build(s, t) {
        for (let e = 0; e < s.points.length; e++)
            t[e] = s.points[e];
        return !0
    },
    triangulate(s, t, e, i, r, n) {
        ua(s, oc, t, e, i, r, n)
    }
}
  , lc = {
    extension: {
        type: I.ShapeBuilder,
        name: "rectangle"
    },
    build(s, t) {
        const e = s
          , i = e.x
          , r = e.y
          , n = e.width
          , a = e.height;
        return n > 0 && a > 0 ? (t[0] = i,
        t[1] = r,
        t[2] = i + n,
        t[3] = r,
        t[4] = i + n,
        t[5] = r + a,
        t[6] = i,
        t[7] = r + a,
        !0) : !1
    },
    triangulate(s, t, e, i, r, n) {
        let a = 0;
        i *= e,
        t[i + a] = s[0],
        t[i + a + 1] = s[1],
        a += e,
        t[i + a] = s[2],
        t[i + a + 1] = s[3],
        a += e,
        t[i + a] = s[6],
        t[i + a + 1] = s[7],
        a += e,
        t[i + a] = s[4],
        t[i + a + 1] = s[5],
        a += e;
        const o = i / e;
        r[n++] = o,
        r[n++] = o + 1,
        r[n++] = o + 2,
        r[n++] = o + 1,
        r[n++] = o + 3,
        r[n++] = o + 2
    }
}
  , cc = {
    extension: {
        type: I.ShapeBuilder,
        name: "triangle"
    },
    build(s, t) {
        return t[0] = s.x,
        t[1] = s.y,
        t[2] = s.x2,
        t[3] = s.y2,
        t[4] = s.x3,
        t[5] = s.y3,
        !0
    },
    triangulate(s, t, e, i, r, n) {
        let a = 0;
        i *= e,
        t[i + a] = s[0],
        t[i + a + 1] = s[1],
        a += e,
        t[i + a] = s[2],
        t[i + a + 1] = s[3],
        a += e,
        t[i + a] = s[4],
        t[i + a + 1] = s[5];
        const o = i / e;
        r[n++] = o,
        r[n++] = o + 1,
        r[n++] = o + 2
    }
}
  , br = [{
    offset: 0,
    color: "white"
}, {
    offset: 1,
    color: "black"
}]
  , wi = class ni {
    constructor(...t) {
        this.uid = q("fillGradient"),
        this._tick = 0,
        this.type = "linear",
        this.colorStops = [];
        let e = uc(t);
        e = {
            ...e.type === "radial" ? ni.defaultRadialOptions : ni.defaultLinearOptions,
            ...tn(e)
        },
        this._textureSize = e.textureSize,
        this._wrapMode = e.wrapMode,
        e.type === "radial" ? (this.center = e.center,
        this.outerCenter = e.outerCenter ?? this.center,
        this.innerRadius = e.innerRadius,
        this.outerRadius = e.outerRadius,
        this.scale = e.scale,
        this.rotation = e.rotation) : (this.start = e.start,
        this.end = e.end),
        this.textureSpace = e.textureSpace,
        this.type = e.type,
        e.colorStops.forEach(r => {
            this.addColorStop(r.offset, r.color)
        }
        )
    }
    addColorStop(t, e) {
        return this.colorStops.push({
            offset: t,
            color: J.shared.setValue(e).toHexa()
        }),
        this
    }
    buildLinearGradient() {
        if (this.texture)
            return;
        let {x: t, y: e} = this.start
          , {x: i, y: r} = this.end
          , n = i - t
          , a = r - e;
        const o = n < 0 || a < 0;
        if (this._wrapMode === "clamp-to-edge") {
            if (n < 0) {
                const g = t;
                t = i,
                i = g,
                n *= -1
            }
            if (a < 0) {
                const g = e;
                e = r,
                r = g,
                a *= -1
            }
        }
        const h = this.colorStops.length ? this.colorStops : br
          , l = this._textureSize
          , {canvas: c, context: u} = Ar(l, 1)
          , d = o ? u.createLinearGradient(this._textureSize, 0, 0, 0) : u.createLinearGradient(0, 0, this._textureSize, 0);
        wr(d, h),
        u.fillStyle = d,
        u.fillRect(0, 0, l, 1),
        this.texture = new W({
            source: new pe({
                resource: c,
                addressMode: this._wrapMode
            })
        });
        const f = Math.sqrt(n * n + a * a)
          , p = Math.atan2(a, n)
          , m = new D;
        m.scale(f / l, 1),
        m.rotate(p),
        m.translate(t, e),
        this.textureSpace === "local" && m.scale(l, l),
        this.transform = m
    }
    buildGradient() {
        this.texture || this._tick++,
        this.type === "linear" ? this.buildLinearGradient() : this.buildRadialGradient()
    }
    buildRadialGradient() {
        if (this.texture)
            return;
        const t = this.colorStops.length ? this.colorStops : br
          , e = this._textureSize
          , {canvas: i, context: r} = Ar(e, e)
          , {x: n, y: a} = this.center
          , {x: o, y: h} = this.outerCenter
          , l = this.innerRadius
          , c = this.outerRadius
          , u = o - c
          , d = h - c
          , f = e / (c * 2)
          , p = (n - u) * f
          , m = (a - d) * f
          , g = r.createRadialGradient(p, m, l * f, (o - u) * f, (h - d) * f, c * f);
        wr(g, t),
        r.fillStyle = t[t.length - 1].color,
        r.fillRect(0, 0, e, e),
        r.fillStyle = g,
        r.translate(p, m),
        r.rotate(this.rotation),
        r.scale(1, this.scale),
        r.translate(-p, -m),
        r.fillRect(0, 0, e, e),
        this.texture = new W({
            source: new pe({
                resource: i,
                addressMode: this._wrapMode
            })
        });
        const x = new D;
        x.scale(1 / f, 1 / f),
        x.translate(u, d),
        this.textureSpace === "local" && x.scale(e, e),
        this.transform = x
    }
    destroy() {
        var t;
        (t = this.texture) == null || t.destroy(!0),
        this.texture = null,
        this.transform = null,
        this.colorStops = [],
        this.start = null,
        this.end = null,
        this.center = null,
        this.outerCenter = null
    }
    get styleKey() {
        return `fill-gradient-${this.uid}-${this._tick}`
    }
}
;
wi.defaultLinearOptions = {
    start: {
        x: 0,
        y: 0
    },
    end: {
        x: 0,
        y: 1
    },
    colorStops: [],
    textureSpace: "local",
    type: "linear",
    textureSize: 256,
    wrapMode: "clamp-to-edge"
};
wi.defaultRadialOptions = {
    center: {
        x: .5,
        y: .5
    },
    innerRadius: 0,
    outerRadius: .5,
    colorStops: [],
    scale: 1,
    textureSpace: "local",
    type: "radial",
    textureSize: 256,
    wrapMode: "clamp-to-edge"
};
let Rt = wi;
function wr(s, t) {
    for (let e = 0; e < t.length; e++) {
        const i = t[e];
        s.addColorStop(i.offset, i.color)
    }
}
function Ar(s, t) {
    const e = O.get().createCanvas(s, t)
      , i = e.getContext("2d");
    return {
        canvas: e,
        context: i
    }
}
function uc(s) {
    let t = s[0] ?? {};
    return (typeof t == "number" || s[1]) && (V("8.5.2", "use options object instead"),
    t = {
        type: "linear",
        start: {
            x: s[0],
            y: s[1]
        },
        end: {
            x: s[2],
            y: s[3]
        },
        textureSpace: s[4],
        textureSize: s[5] ?? Rt.defaultLinearOptions.textureSize
    }),
    t
}
const dc = new D
  , fc = new Z;
function pc(s, t, e, i) {
    const r = t.matrix ? s.copyFrom(t.matrix).invert() : s.identity();
    if (t.textureSpace === "local") {
        const a = e.getBounds(fc);
        t.width && a.pad(t.width);
        const {x: o, y: h} = a
          , l = 1 / a.width
          , c = 1 / a.height
          , u = -o * l
          , d = -h * c
          , f = r.a
          , p = r.b
          , m = r.c
          , g = r.d;
        r.a *= l,
        r.b *= l,
        r.c *= c,
        r.d *= c,
        r.tx = u * f + d * m + r.tx,
        r.ty = u * p + d * g + r.ty
    } else
        r.translate(t.texture.frame.x, t.texture.frame.y),
        r.scale(1 / t.texture.source.width, 1 / t.texture.source.height);
    const n = t.texture.source.style;
    return !(t.fill instanceof Rt) && n.addressMode === "clamp-to-edge" && (n.addressMode = "repeat",
    n.update()),
    i && r.append(dc.copyFrom(i).invert()),
    r
}
const ms = {};
Y.handleByMap(I.ShapeBuilder, ms);
Y.add(lc, hc, cc, Oe, sc, ic);
const gc = new Z
  , mc = new D;
function xc(s, t) {
    const {geometryData: e, batches: i} = t;
    i.length = 0,
    e.indices.length = 0,
    e.vertices.length = 0,
    e.uvs.length = 0;
    for (let r = 0; r < s.instructions.length; r++) {
        const n = s.instructions[r];
        if (n.action === "texture")
            yc(n.data, i, e);
        else if (n.action === "fill" || n.action === "stroke") {
            const a = n.action === "stroke"
              , o = n.data.path.shapePath
              , h = n.data.style
              , l = n.data.hole;
            a && l && vr(l.shapePath, h, !0, i, e),
            l && (o.shapePrimitives[o.shapePrimitives.length - 1].holes = l.shapePath.shapePrimitives),
            vr(o, h, a, i, e)
        }
    }
}
function yc(s, t, e) {
    const i = []
      , r = ms.rectangle
      , n = gc;
    n.x = s.dx,
    n.y = s.dy,
    n.width = s.dw,
    n.height = s.dh;
    const a = s.transform;
    if (!r.build(n, i))
        return;
    const {vertices: o, uvs: h, indices: l} = e
      , c = l.length
      , u = o.length / 2;
    a && ha(i, a),
    r.triangulate(i, o, 2, u, l, c);
    const d = s.image
      , f = d.uvs;
    h.push(f.x0, f.y0, f.x1, f.y1, f.x3, f.y3, f.x2, f.y2);
    const p = mt.get(la);
    p.indexOffset = c,
    p.indexSize = l.length - c,
    p.attributeOffset = u,
    p.attributeSize = o.length / 2 - u,
    p.baseColor = s.style,
    p.alpha = s.alpha,
    p.texture = d,
    p.geometryData = e,
    t.push(p)
}
function vr(s, t, e, i, r) {
    const {vertices: n, uvs: a, indices: o} = r;
    s.shapePrimitives.forEach( ({shape: h, transform: l, holes: c}) => {
        const u = []
          , d = ms[h.type];
        if (!d.build(h, u))
            return;
        const f = o.length
          , p = n.length / 2;
        let m = "triangle-list";
        if (l && ha(u, l),
        e) {
            const _ = h.closePath ?? !0
              , b = t;
            b.pixelLine ? (ac(u, _, n, o),
            m = "line-list") : nc(u, b, !1, _, n, o)
        } else if (c) {
            const _ = []
              , b = u.slice();
            _c(c).forEach(w => {
                _.push(b.length / 2),
                b.push(...w)
            }
            ),
            ua(b, _, n, 2, p, o, f)
        } else
            d.triangulate(u, n, 2, p, o, f);
        const g = a.length / 2
          , x = t.texture;
        if (x !== W.WHITE) {
            const _ = pc(mc, t, h, l);
            Jl(n, 2, p, a, g, 2, n.length / 2 - p, _)
        } else
            tc(a, g, 2, n.length / 2 - p);
        const y = mt.get(la);
        y.indexOffset = f,
        y.indexSize = o.length - f,
        y.attributeOffset = p,
        y.attributeSize = n.length / 2 - p,
        y.baseColor = t.color,
        y.alpha = t.alpha,
        y.texture = x,
        y.geometryData = r,
        y.topology = m,
        i.push(y)
    }
    )
}
function _c(s) {
    const t = [];
    for (let e = 0; e < s.length; e++) {
        const i = s[e].shape
          , r = [];
        ms[i.type].build(i, r) && t.push(r)
    }
    return t
}
class bc {
    constructor() {
        this.batches = [],
        this.geometryData = {
            vertices: [],
            uvs: [],
            indices: []
        }
    }
    reset() {
        this.batches && this.batches.forEach(t => {
            mt.return(t)
        }
        ),
        this.graphicsData && mt.return(this.graphicsData),
        this.isBatchable = !1,
        this.context = null,
        this.batches.length = 0,
        this.geometryData.indices.length = 0,
        this.geometryData.vertices.length = 0,
        this.geometryData.uvs.length = 0,
        this.graphicsData = null
    }
    destroy() {
        this.reset(),
        this.batches = null,
        this.geometryData = null
    }
}
class wc {
    constructor() {
        this.instructions = new mn
    }
    init(t) {
        const e = t.maxTextures;
        this.batcher ? this.batcher._updateMaxTextures(e) : this.batcher = new Ql({
            maxTextures: e
        }),
        this.instructions.reset()
    }
    get geometry() {
        return V(Va, "GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),
        this.batcher.geometry
    }
    destroy() {
        this.batcher.destroy(),
        this.instructions.destroy(),
        this.batcher = null,
        this.instructions = null
    }
}
const Ai = class ai {
    constructor(t) {
        this._renderer = t,
        this._managedContexts = new oa({
            renderer: t,
            type: "resource",
            name: "graphicsContext"
        })
    }
    init(t) {
        ai.defaultOptions.bezierSmoothness = (t == null ? void 0 : t.bezierSmoothness) ?? ai.defaultOptions.bezierSmoothness
    }
    getContextRenderData(t) {
        return t._gpuData[this._renderer.uid].graphicsData || this._initContextRenderData(t)
    }
    updateGpuContext(t) {
        const e = !!t._gpuData[this._renderer.uid]
          , i = t._gpuData[this._renderer.uid] || this._initContext(t);
        if (t.dirty || !e) {
            e && i.reset(),
            xc(t, i);
            const r = t.batchMode;
            t.customShader || r === "no-batch" ? i.isBatchable = !1 : r === "auto" ? i.isBatchable = i.geometryData.vertices.length < 400 : i.isBatchable = !0,
            t.dirty = !1
        }
        return i
    }
    getGpuContext(t) {
        return t._gpuData[this._renderer.uid] || this._initContext(t)
    }
    _initContextRenderData(t) {
        const e = mt.get(wc, {
            maxTextures: this._renderer.limits.maxBatchableTextures
        })
          , i = t._gpuData[this._renderer.uid]
          , {batches: r, geometryData: n} = i;
        i.graphicsData = e;
        const a = n.vertices.length
          , o = n.indices.length;
        for (let u = 0; u < r.length; u++)
            r[u].applyTransform = !1;
        const h = e.batcher;
        h.ensureAttributeBuffer(a),
        h.ensureIndexBuffer(o),
        h.begin();
        for (let u = 0; u < r.length; u++) {
            const d = r[u];
            h.add(d)
        }
        h.finish(e.instructions);
        const l = h.geometry;
        l.indexBuffer.setDataWithSize(h.indexBuffer, h.indexSize, !0),
        l.buffers[0].setDataWithSize(h.attributeBuffer.float32View, h.attributeSize, !0);
        const c = h.batches;
        for (let u = 0; u < c.length; u++) {
            const d = c[u];
            d.bindGroup = ll(d.textures.textures, d.textures.count, this._renderer.limits.maxBatchableTextures)
        }
        return e
    }
    _initContext(t) {
        const e = new bc;
        return e.context = t,
        t._gpuData[this._renderer.uid] = e,
        this._managedContexts.add(t),
        e
    }
    destroy() {
        this._managedContexts.destroy(),
        this._renderer = null
    }
}
;
Ai.extension = {
    type: [I.WebGLSystem, I.WebGPUSystem],
    name: "graphicsContext"
};
Ai.defaultOptions = {
    bezierSmoothness: .5
};
let da = Ai;
const Ac = 8
  , es = 11920929e-14
  , vc = 1;
function fa(s, t, e, i, r, n, a, o, h, l) {
    const u = Math.min(.99, Math.max(0, l ?? da.defaultOptions.bezierSmoothness));
    let d = (vc - u) / 1;
    return d *= d,
    Sc(t, e, i, r, n, a, o, h, s, d),
    s
}
function Sc(s, t, e, i, r, n, a, o, h, l) {
    oi(s, t, e, i, r, n, a, o, h, l, 0),
    h.push(a, o)
}
function oi(s, t, e, i, r, n, a, o, h, l, c) {
    if (c > Ac)
        return;
    const u = (s + e) / 2
      , d = (t + i) / 2
      , f = (e + r) / 2
      , p = (i + n) / 2
      , m = (r + a) / 2
      , g = (n + o) / 2
      , x = (u + f) / 2
      , y = (d + p) / 2
      , _ = (f + m) / 2
      , b = (p + g) / 2
      , A = (x + _) / 2
      , w = (y + b) / 2;
    if (c > 0) {
        let v = a - s
          , M = o - t;
        const T = Math.abs((e - a) * M - (i - o) * v)
          , S = Math.abs((r - a) * M - (n - o) * v);
        if (T > es && S > es) {
            if ((T + S) * (T + S) <= l * (v * v + M * M)) {
                h.push(A, w);
                return
            }
        } else if (T > es) {
            if (T * T <= l * (v * v + M * M)) {
                h.push(A, w);
                return
            }
        } else if (S > es) {
            if (S * S <= l * (v * v + M * M)) {
                h.push(A, w);
                return
            }
        } else if (v = A - (s + a) / 2,
        M = w - (t + o) / 2,
        v * v + M * M <= l) {
            h.push(A, w);
            return
        }
    }
    oi(s, t, u, d, x, y, A, w, h, l, c + 1),
    oi(A, w, _, b, m, g, a, o, h, l, c + 1)
}
const Tc = 8
  , Cc = 11920929e-14
  , Pc = 1;
function Mc(s, t, e, i, r, n, a, o) {
    const l = Math.min(.99, Math.max(0, o ?? da.defaultOptions.bezierSmoothness));
    let c = (Pc - l) / 1;
    return c *= c,
    kc(t, e, i, r, n, a, s, c),
    s
}
function kc(s, t, e, i, r, n, a, o) {
    hi(a, s, t, e, i, r, n, o, 0),
    a.push(r, n)
}
function hi(s, t, e, i, r, n, a, o, h) {
    if (h > Tc)
        return;
    const l = (t + i) / 2
      , c = (e + r) / 2
      , u = (i + n) / 2
      , d = (r + a) / 2
      , f = (l + u) / 2
      , p = (c + d) / 2;
    let m = n - t
      , g = a - e;
    const x = Math.abs((i - n) * g - (r - a) * m);
    if (x > Cc) {
        if (x * x <= o * (m * m + g * g)) {
            s.push(f, p);
            return
        }
    } else if (m = f - (t + n) / 2,
    g = p - (e + a) / 2,
    m * m + g * g <= o) {
        s.push(f, p);
        return
    }
    hi(s, t, e, l, c, f, p, o, h + 1),
    hi(s, f, p, u, d, n, a, o, h + 1)
}
function pa(s, t, e, i, r, n, a, o) {
    let h = Math.abs(r - n);
    (!a && r > n || a && n > r) && (h = 2 * Math.PI - h),
    o || (o = Math.max(6, Math.floor(6 * Math.pow(i, 1 / 3) * (h / Math.PI)))),
    o = Math.max(o, 3);
    let l = h / o
      , c = r;
    l *= a ? -1 : 1;
    for (let u = 0; u < o + 1; u++) {
        const d = Math.cos(c)
          , f = Math.sin(c)
          , p = t + d * i
          , m = e + f * i;
        s.push(p, m),
        c += l
    }
}
function Ec(s, t, e, i, r, n) {
    const a = s[s.length - 2]
      , h = s[s.length - 1] - e
      , l = a - t
      , c = r - e
      , u = i - t
      , d = Math.abs(h * u - l * c);
    if (d < 1e-8 || n === 0) {
        (s[s.length - 2] !== t || s[s.length - 1] !== e) && s.push(t, e);
        return
    }
    const f = h * h + l * l
      , p = c * c + u * u
      , m = h * c + l * u
      , g = n * Math.sqrt(f) / d
      , x = n * Math.sqrt(p) / d
      , y = g * m / f
      , _ = x * m / p
      , b = g * u + x * l
      , A = g * c + x * h
      , w = l * (x + y)
      , v = h * (x + y)
      , M = u * (g + _)
      , T = c * (g + _)
      , S = Math.atan2(v - A, w - b)
      , C = Math.atan2(T - A, M - b);
    pa(s, b + t, A + e, n, S, C, l * c > u * h)
}
const Fe = Math.PI * 2
  , Os = {
    centerX: 0,
    centerY: 0,
    ang1: 0,
    ang2: 0
}
  , Us = ({x: s, y: t}, e, i, r, n, a, o, h) => {
    s *= e,
    t *= i;
    const l = r * s - n * t
      , c = n * s + r * t;
    return h.x = l + a,
    h.y = c + o,
    h
}
;
function Ic(s, t) {
    const e = t === -1.5707963267948966 ? -.551915024494 : 1.3333333333333333 * Math.tan(t / 4)
      , i = t === 1.5707963267948966 ? .551915024494 : e
      , r = Math.cos(s)
      , n = Math.sin(s)
      , a = Math.cos(s + t)
      , o = Math.sin(s + t);
    return [{
        x: r - n * i,
        y: n + r * i
    }, {
        x: a + o * i,
        y: o - a * i
    }, {
        x: a,
        y: o
    }]
}
const Sr = (s, t, e, i) => {
    const r = s * i - t * e < 0 ? -1 : 1;
    let n = s * e + t * i;
    return n > 1 && (n = 1),
    n < -1 && (n = -1),
    r * Math.acos(n)
}
  , Rc = (s, t, e, i, r, n, a, o, h, l, c, u, d) => {
    const f = Math.pow(r, 2)
      , p = Math.pow(n, 2)
      , m = Math.pow(c, 2)
      , g = Math.pow(u, 2);
    let x = f * p - f * g - p * m;
    x < 0 && (x = 0),
    x /= f * g + p * m,
    x = Math.sqrt(x) * (a === o ? -1 : 1);
    const y = x * r / n * u
      , _ = x * -n / r * c
      , b = l * y - h * _ + (s + e) / 2
      , A = h * y + l * _ + (t + i) / 2
      , w = (c - y) / r
      , v = (u - _) / n
      , M = (-c - y) / r
      , T = (-u - _) / n
      , S = Sr(1, 0, w, v);
    let C = Sr(w, v, M, T);
    o === 0 && C > 0 && (C -= Fe),
    o === 1 && C < 0 && (C += Fe),
    d.centerX = b,
    d.centerY = A,
    d.ang1 = S,
    d.ang2 = C
}
;
function Bc(s, t, e, i, r, n, a, o=0, h=0, l=0) {
    if (n === 0 || a === 0)
        return;
    const c = Math.sin(o * Fe / 360)
      , u = Math.cos(o * Fe / 360)
      , d = u * (t - i) / 2 + c * (e - r) / 2
      , f = -c * (t - i) / 2 + u * (e - r) / 2;
    if (d === 0 && f === 0)
        return;
    n = Math.abs(n),
    a = Math.abs(a);
    const p = Math.pow(d, 2) / Math.pow(n, 2) + Math.pow(f, 2) / Math.pow(a, 2);
    p > 1 && (n *= Math.sqrt(p),
    a *= Math.sqrt(p)),
    Rc(t, e, i, r, n, a, h, l, c, u, d, f, Os);
    let {ang1: m, ang2: g} = Os;
    const {centerX: x, centerY: y} = Os;
    let _ = Math.abs(g) / (Fe / 4);
    Math.abs(1 - _) < 1e-7 && (_ = 1);
    const b = Math.max(Math.ceil(_), 1);
    g /= b;
    let A = s[s.length - 2]
      , w = s[s.length - 1];
    const v = {
        x: 0,
        y: 0
    };
    for (let M = 0; M < b; M++) {
        const T = Ic(m, g)
          , {x: S, y: C} = Us(T[0], n, a, u, c, x, y, v)
          , {x: k, y: R} = Us(T[1], n, a, u, c, x, y, v)
          , {x: F, y: rt} = Us(T[2], n, a, u, c, x, y, v);
        fa(s, A, w, S, C, k, R, F, rt),
        A = F,
        w = rt,
        m += g
    }
}
function Fc(s, t, e) {
    const i = (a, o) => {
        const h = o.x - a.x
          , l = o.y - a.y
          , c = Math.sqrt(h * h + l * l)
          , u = h / c
          , d = l / c;
        return {
            len: c,
            nx: u,
            ny: d
        }
    }
      , r = (a, o) => {
        a === 0 ? s.moveTo(o.x, o.y) : s.lineTo(o.x, o.y)
    }
    ;
    let n = t[t.length - 1];
    for (let a = 0; a < t.length; a++) {
        const o = t[a % t.length]
          , h = o.radius ?? e;
        if (h <= 0) {
            r(a, o),
            n = o;
            continue
        }
        const l = t[(a + 1) % t.length]
          , c = i(o, n)
          , u = i(o, l);
        if (c.len < 1e-4 || u.len < 1e-4) {
            r(a, o),
            n = o;
            continue
        }
        let d = Math.asin(c.nx * u.ny - c.ny * u.nx)
          , f = 1
          , p = !1;
        c.nx * u.nx - c.ny * -u.ny < 0 ? d < 0 ? d = Math.PI + d : (d = Math.PI - d,
        f = -1,
        p = !0) : d > 0 && (f = -1,
        p = !0);
        const m = d / 2;
        let g, x = Math.abs(Math.cos(m) * h / Math.sin(m));
        x > Math.min(c.len / 2, u.len / 2) ? (x = Math.min(c.len / 2, u.len / 2),
        g = Math.abs(x * Math.sin(m) / Math.cos(m))) : g = h;
        const y = o.x + u.nx * x + -u.ny * g * f
          , _ = o.y + u.ny * x + u.nx * g * f
          , b = Math.atan2(c.ny, c.nx) + Math.PI / 2 * f
          , A = Math.atan2(u.ny, u.nx) - Math.PI / 2 * f;
        a === 0 && s.moveTo(y + Math.cos(b) * g, _ + Math.sin(b) * g),
        s.arc(y, _, g, b, A, p),
        n = o
    }
}
function Lc(s, t, e, i) {
    const r = (o, h) => Math.sqrt((o.x - h.x) ** 2 + (o.y - h.y) ** 2)
      , n = (o, h, l) => ({
        x: o.x + (h.x - o.x) * l,
        y: o.y + (h.y - o.y) * l
    })
      , a = t.length;
    for (let o = 0; o < a; o++) {
        const h = t[(o + 1) % a]
          , l = h.radius ?? e;
        if (l <= 0) {
            o === 0 ? s.moveTo(h.x, h.y) : s.lineTo(h.x, h.y);
            continue
        }
        const c = t[o]
          , u = t[(o + 2) % a]
          , d = r(c, h);
        let f;
        if (d < 1e-4)
            f = h;
        else {
            const g = Math.min(d / 2, l);
            f = n(h, c, g / d)
        }
        const p = r(u, h);
        let m;
        if (p < 1e-4)
            m = h;
        else {
            const g = Math.min(p / 2, l);
            m = n(h, u, g / p)
        }
        o === 0 ? s.moveTo(f.x, f.y) : s.lineTo(f.x, f.y),
        s.quadraticCurveTo(h.x, h.y, m.x, m.y, i)
    }
}
const Gc = new Z;
class Dc {
    constructor(t) {
        this.shapePrimitives = [],
        this._currentPoly = null,
        this._bounds = new gt,
        this._graphicsPath2D = t,
        this.signed = t.checkForHoles
    }
    moveTo(t, e) {
        return this.startPoly(t, e),
        this
    }
    lineTo(t, e) {
        this._ensurePoly();
        const i = this._currentPoly.points
          , r = i[i.length - 2]
          , n = i[i.length - 1];
        return (r !== t || n !== e) && i.push(t, e),
        this
    }
    arc(t, e, i, r, n, a) {
        this._ensurePoly(!1);
        const o = this._currentPoly.points;
        return pa(o, t, e, i, r, n, a),
        this
    }
    arcTo(t, e, i, r, n) {
        this._ensurePoly();
        const a = this._currentPoly.points;
        return Ec(a, t, e, i, r, n),
        this
    }
    arcToSvg(t, e, i, r, n, a, o) {
        const h = this._currentPoly.points;
        return Bc(h, this._currentPoly.lastX, this._currentPoly.lastY, a, o, t, e, i, r, n),
        this
    }
    bezierCurveTo(t, e, i, r, n, a, o) {
        this._ensurePoly();
        const h = this._currentPoly;
        return fa(this._currentPoly.points, h.lastX, h.lastY, t, e, i, r, n, a, o),
        this
    }
    quadraticCurveTo(t, e, i, r, n) {
        this._ensurePoly();
        const a = this._currentPoly;
        return Mc(this._currentPoly.points, a.lastX, a.lastY, t, e, i, r, n),
        this
    }
    closePath() {
        return this.endPoly(!0),
        this
    }
    addPath(t, e) {
        this.endPoly(),
        e && !e.isIdentity() && (t = t.clone(!0),
        t.transform(e));
        const i = this.shapePrimitives
          , r = i.length;
        for (let n = 0; n < t.instructions.length; n++) {
            const a = t.instructions[n];
            this[a.action](...a.data)
        }
        if (t.checkForHoles && i.length - r > 1) {
            let n = null;
            for (let a = r; a < i.length; a++) {
                const o = i[a];
                if (o.shape.type === "polygon") {
                    const h = o.shape
                      , l = n == null ? void 0 : n.shape;
                    l && l.containsPolygon(h) ? (n.holes || (n.holes = []),
                    n.holes.push(o),
                    i.copyWithin(a, a + 1),
                    i.length--,
                    a--) : n = o
                }
            }
        }
        return this
    }
    finish(t=!1) {
        this.endPoly(t)
    }
    rect(t, e, i, r, n) {
        return this.drawShape(new Z(t,e,i,r), n),
        this
    }
    circle(t, e, i, r) {
        return this.drawShape(new yi(t,e,i), r),
        this
    }
    poly(t, e, i) {
        const r = new Re(t);
        return r.closePath = e,
        this.drawShape(r, i),
        this
    }
    regularPoly(t, e, i, r, n=0, a) {
        r = Math.max(r | 0, 3);
        const o = -1 * Math.PI / 2 + n
          , h = Math.PI * 2 / r
          , l = [];
        for (let c = 0; c < r; c++) {
            const u = o - c * h;
            l.push(t + i * Math.cos(u), e + i * Math.sin(u))
        }
        return this.poly(l, !0, a),
        this
    }
    roundPoly(t, e, i, r, n, a=0, o) {
        if (r = Math.max(r | 0, 3),
        n <= 0)
            return this.regularPoly(t, e, i, r, a);
        const h = i * Math.sin(Math.PI / r) - .001;
        n = Math.min(n, h);
        const l = -1 * Math.PI / 2 + a
          , c = Math.PI * 2 / r
          , u = (r - 2) * Math.PI / r / 2;
        for (let d = 0; d < r; d++) {
            const f = d * c + l
              , p = t + i * Math.cos(f)
              , m = e + i * Math.sin(f)
              , g = f + Math.PI + u
              , x = f - Math.PI - u
              , y = p + n * Math.cos(g)
              , _ = m + n * Math.sin(g)
              , b = p + n * Math.cos(x)
              , A = m + n * Math.sin(x);
            d === 0 ? this.moveTo(y, _) : this.lineTo(y, _),
            this.quadraticCurveTo(p, m, b, A, o)
        }
        return this.closePath()
    }
    roundShape(t, e, i=!1, r) {
        return t.length < 3 ? this : (i ? Lc(this, t, e, r) : Fc(this, t, e),
        this.closePath())
    }
    filletRect(t, e, i, r, n) {
        if (n === 0)
            return this.rect(t, e, i, r);
        const a = Math.min(i, r) / 2
          , o = Math.min(a, Math.max(-a, n))
          , h = t + i
          , l = e + r
          , c = o < 0 ? -o : 0
          , u = Math.abs(o);
        return this.moveTo(t, e + u).arcTo(t + c, e + c, t + u, e, u).lineTo(h - u, e).arcTo(h - c, e + c, h, e + u, u).lineTo(h, l - u).arcTo(h - c, l - c, t + i - u, l, u).lineTo(t + u, l).arcTo(t + c, l - c, t, l - u, u).closePath()
    }
    chamferRect(t, e, i, r, n, a) {
        if (n <= 0)
            return this.rect(t, e, i, r);
        const o = Math.min(n, Math.min(i, r) / 2)
          , h = t + i
          , l = e + r
          , c = [t + o, e, h - o, e, h, e + o, h, l - o, h - o, l, t + o, l, t, l - o, t, e + o];
        for (let u = c.length - 1; u >= 2; u -= 2)
            c[u] === c[u - 2] && c[u - 1] === c[u - 3] && c.splice(u - 1, 2);
        return this.poly(c, !0, a)
    }
    ellipse(t, e, i, r, n) {
        return this.drawShape(new _i(t,e,i,r), n),
        this
    }
    roundRect(t, e, i, r, n, a) {
        return this.drawShape(new bi(t,e,i,r,n), a),
        this
    }
    drawShape(t, e) {
        return this.endPoly(),
        this.shapePrimitives.push({
            shape: t,
            transform: e
        }),
        this
    }
    startPoly(t, e) {
        let i = this._currentPoly;
        return i && this.endPoly(),
        i = new Re,
        i.points.push(t, e),
        this._currentPoly = i,
        this
    }
    endPoly(t=!1) {
        const e = this._currentPoly;
        return e && e.points.length > 2 && (e.closePath = t,
        this.shapePrimitives.push({
            shape: e
        })),
        this._currentPoly = null,
        this
    }
    _ensurePoly(t=!0) {
        if (!this._currentPoly && (this._currentPoly = new Re,
        t)) {
            const e = this.shapePrimitives[this.shapePrimitives.length - 1];
            if (e) {
                let i = e.shape.x
                  , r = e.shape.y;
                if (e.transform && !e.transform.isIdentity()) {
                    const n = e.transform
                      , a = i;
                    i = n.a * i + n.c * r + n.tx,
                    r = n.b * a + n.d * r + n.ty
                }
                this._currentPoly.points.push(i, r)
            } else
                this._currentPoly.points.push(0, 0)
        }
    }
    buildPath() {
        const t = this._graphicsPath2D;
        this.shapePrimitives.length = 0,
        this._currentPoly = null;
        for (let e = 0; e < t.instructions.length; e++) {
            const i = t.instructions[e];
            this[i.action](...i.data)
        }
        this.finish()
    }
    get bounds() {
        const t = this._bounds;
        t.clear();
        const e = this.shapePrimitives;
        for (let i = 0; i < e.length; i++) {
            const r = e[i]
              , n = r.shape.getBounds(Gc);
            r.transform ? t.addRect(n, r.transform) : t.addRect(n)
        }
        return t
    }
}
class It {
    constructor(t, e=!1) {
        this.instructions = [],
        this.uid = q("graphicsPath"),
        this._dirty = !0,
        this.checkForHoles = e,
        typeof t == "string" ? nl(t, this) : this.instructions = (t == null ? void 0 : t.slice()) ?? []
    }
    get shapePath() {
        return this._shapePath || (this._shapePath = new Dc(this)),
        this._dirty && (this._dirty = !1,
        this._shapePath.buildPath()),
        this._shapePath
    }
    addPath(t, e) {
        return t = t.clone(),
        this.instructions.push({
            action: "addPath",
            data: [t, e]
        }),
        this._dirty = !0,
        this
    }
    arc(...t) {
        return this.instructions.push({
            action: "arc",
            data: t
        }),
        this._dirty = !0,
        this
    }
    arcTo(...t) {
        return this.instructions.push({
            action: "arcTo",
            data: t
        }),
        this._dirty = !0,
        this
    }
    arcToSvg(...t) {
        return this.instructions.push({
            action: "arcToSvg",
            data: t
        }),
        this._dirty = !0,
        this
    }
    bezierCurveTo(...t) {
        return this.instructions.push({
            action: "bezierCurveTo",
            data: t
        }),
        this._dirty = !0,
        this
    }
    bezierCurveToShort(t, e, i, r, n) {
        const a = this.instructions[this.instructions.length - 1]
          , o = this.getLastPoint(nt.shared);
        let h = 0
          , l = 0;
        if (!a || a.action !== "bezierCurveTo")
            h = o.x,
            l = o.y;
        else {
            h = a.data[2],
            l = a.data[3];
            const c = o.x
              , u = o.y;
            h = c + (c - h),
            l = u + (u - l)
        }
        return this.instructions.push({
            action: "bezierCurveTo",
            data: [h, l, t, e, i, r, n]
        }),
        this._dirty = !0,
        this
    }
    closePath() {
        return this.instructions.push({
            action: "closePath",
            data: []
        }),
        this._dirty = !0,
        this
    }
    ellipse(...t) {
        return this.instructions.push({
            action: "ellipse",
            data: t
        }),
        this._dirty = !0,
        this
    }
    lineTo(...t) {
        return this.instructions.push({
            action: "lineTo",
            data: t
        }),
        this._dirty = !0,
        this
    }
    moveTo(...t) {
        return this.instructions.push({
            action: "moveTo",
            data: t
        }),
        this
    }
    quadraticCurveTo(...t) {
        return this.instructions.push({
            action: "quadraticCurveTo",
            data: t
        }),
        this._dirty = !0,
        this
    }
    quadraticCurveToShort(t, e, i) {
        const r = this.instructions[this.instructions.length - 1]
          , n = this.getLastPoint(nt.shared);
        let a = 0
          , o = 0;
        if (!r || r.action !== "quadraticCurveTo")
            a = n.x,
            o = n.y;
        else {
            a = r.data[0],
            o = r.data[1];
            const h = n.x
              , l = n.y;
            a = h + (h - a),
            o = l + (l - o)
        }
        return this.instructions.push({
            action: "quadraticCurveTo",
            data: [a, o, t, e, i]
        }),
        this._dirty = !0,
        this
    }
    rect(t, e, i, r, n) {
        return this.instructions.push({
            action: "rect",
            data: [t, e, i, r, n]
        }),
        this._dirty = !0,
        this
    }
    circle(t, e, i, r) {
        return this.instructions.push({
            action: "circle",
            data: [t, e, i, r]
        }),
        this._dirty = !0,
        this
    }
    roundRect(...t) {
        return this.instructions.push({
            action: "roundRect",
            data: t
        }),
        this._dirty = !0,
        this
    }
    poly(...t) {
        return this.instructions.push({
            action: "poly",
            data: t
        }),
        this._dirty = !0,
        this
    }
    regularPoly(...t) {
        return this.instructions.push({
            action: "regularPoly",
            data: t
        }),
        this._dirty = !0,
        this
    }
    roundPoly(...t) {
        return this.instructions.push({
            action: "roundPoly",
            data: t
        }),
        this._dirty = !0,
        this
    }
    roundShape(...t) {
        return this.instructions.push({
            action: "roundShape",
            data: t
        }),
        this._dirty = !0,
        this
    }
    filletRect(...t) {
        return this.instructions.push({
            action: "filletRect",
            data: t
        }),
        this._dirty = !0,
        this
    }
    chamferRect(...t) {
        return this.instructions.push({
            action: "chamferRect",
            data: t
        }),
        this._dirty = !0,
        this
    }
    star(t, e, i, r, n, a, o) {
        n || (n = r / 2);
        const h = -1 * Math.PI / 2 + a
          , l = i * 2
          , c = Math.PI * 2 / l
          , u = [];
        for (let d = 0; d < l; d++) {
            const f = d % 2 ? n : r
              , p = d * c + h;
            u.push(t + f * Math.cos(p), e + f * Math.sin(p))
        }
        return this.poly(u, !0, o),
        this
    }
    clone(t=!1) {
        const e = new It;
        if (e.checkForHoles = this.checkForHoles,
        !t)
            e.instructions = this.instructions.slice();
        else
            for (let i = 0; i < this.instructions.length; i++) {
                const r = this.instructions[i];
                e.instructions.push({
                    action: r.action,
                    data: r.data.slice()
                })
            }
        return e
    }
    clear() {
        return this.instructions.length = 0,
        this._dirty = !0,
        this
    }
    transform(t) {
        if (t.isIdentity())
            return this;
        const e = t.a
          , i = t.b
          , r = t.c
          , n = t.d
          , a = t.tx
          , o = t.ty;
        let h = 0
          , l = 0
          , c = 0
          , u = 0
          , d = 0
          , f = 0
          , p = 0
          , m = 0;
        for (let g = 0; g < this.instructions.length; g++) {
            const x = this.instructions[g]
              , y = x.data;
            switch (x.action) {
            case "moveTo":
            case "lineTo":
                h = y[0],
                l = y[1],
                y[0] = e * h + r * l + a,
                y[1] = i * h + n * l + o;
                break;
            case "bezierCurveTo":
                c = y[0],
                u = y[1],
                d = y[2],
                f = y[3],
                h = y[4],
                l = y[5],
                y[0] = e * c + r * u + a,
                y[1] = i * c + n * u + o,
                y[2] = e * d + r * f + a,
                y[3] = i * d + n * f + o,
                y[4] = e * h + r * l + a,
                y[5] = i * h + n * l + o;
                break;
            case "quadraticCurveTo":
                c = y[0],
                u = y[1],
                h = y[2],
                l = y[3],
                y[0] = e * c + r * u + a,
                y[1] = i * c + n * u + o,
                y[2] = e * h + r * l + a,
                y[3] = i * h + n * l + o;
                break;
            case "arcToSvg":
                h = y[5],
                l = y[6],
                p = y[0],
                m = y[1],
                y[0] = e * p + r * m,
                y[1] = i * p + n * m,
                y[5] = e * h + r * l + a,
                y[6] = i * h + n * l + o;
                break;
            case "circle":
                y[4] = ie(y[3], t);
                break;
            case "rect":
                y[4] = ie(y[4], t);
                break;
            case "ellipse":
                y[8] = ie(y[8], t);
                break;
            case "roundRect":
                y[5] = ie(y[5], t);
                break;
            case "addPath":
                y[0].transform(t);
                break;
            case "poly":
                y[2] = ie(y[2], t);
                break;
            case "regularPoly":
            case "chamferRect":
                y[5] = ie(y[5], t);
                break;
            case "closePath":
                break;
            default:
                $("unknown transform action", x.action);
                break
            }
        }
        return this._dirty = !0,
        this
    }
    get bounds() {
        return this.shapePath.bounds
    }
    getLastPoint(t) {
        let e = this.instructions.length - 1
          , i = this.instructions[e];
        if (!i)
            return t.x = 0,
            t.y = 0,
            t;
        for (; i.action === "closePath"; ) {
            if (e--,
            e < 0)
                return t.x = 0,
                t.y = 0,
                t;
            i = this.instructions[e]
        }
        switch (i.action) {
        case "moveTo":
        case "lineTo":
            t.x = i.data[0],
            t.y = i.data[1];
            break;
        case "quadraticCurveTo":
            t.x = i.data[2],
            t.y = i.data[3];
            break;
        case "bezierCurveTo":
            t.x = i.data[4],
            t.y = i.data[5];
            break;
        case "arc":
        case "arcToSvg":
            t.x = i.data[5],
            t.y = i.data[6];
            break;
        case "addPath":
            i.data[0].getLastPoint(t);
            break
        }
        return t
    }
}
function ie(s, t) {
    return s ? s.prepend(t) : t.clone()
}
function X(s, t, e) {
    const i = s.getAttribute(t);
    return i ? Number(i) : e
}
function zc(s, t) {
    const e = s.querySelectorAll("defs");
    for (let i = 0; i < e.length; i++) {
        const r = e[i];
        for (let n = 0; n < r.children.length; n++) {
            const a = r.children[n];
            switch (a.nodeName.toLowerCase()) {
            case "lineargradient":
                t.defs[a.id] = Wc(a);
                break;
            case "radialgradient":
                t.defs[a.id] = Oc();
                break
            }
        }
    }
}
function Wc(s) {
    const t = X(s, "x1", 0)
      , e = X(s, "y1", 0)
      , i = X(s, "x2", 1)
      , r = X(s, "y2", 0)
      , n = s.getAttribute("gradientUnits") || "objectBoundingBox"
      , a = new Rt(t,e,i,r,n === "objectBoundingBox" ? "local" : "global");
    for (let o = 0; o < s.children.length; o++) {
        const h = s.children[o]
          , l = X(h, "offset", 0)
          , c = J.shared.setValue(h.getAttribute("stop-color")).toNumber();
        a.addColorStop(l, c)
    }
    return a
}
function Oc(s) {
    return $("[SVG Parser] Radial gradients are not yet supported"),
    new Rt(0,0,1,0)
}
function Tr(s) {
    const t = s.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);
    return t ? t[1] : ""
}
const Cr = {
    fill: {
        type: "paint",
        default: 0
    },
    "fill-opacity": {
        type: "number",
        default: 1
    },
    stroke: {
        type: "paint",
        default: 0
    },
    "stroke-width": {
        type: "number",
        default: 1
    },
    "stroke-opacity": {
        type: "number",
        default: 1
    },
    "stroke-linecap": {
        type: "string",
        default: "butt"
    },
    "stroke-linejoin": {
        type: "string",
        default: "miter"
    },
    "stroke-miterlimit": {
        type: "number",
        default: 10
    },
    "stroke-dasharray": {
        type: "string",
        default: "none"
    },
    "stroke-dashoffset": {
        type: "number",
        default: 0
    },
    opacity: {
        type: "number",
        default: 1
    }
};
function ga(s, t) {
    const e = s.getAttribute("style")
      , i = {}
      , r = {}
      , n = {
        strokeStyle: i,
        fillStyle: r,
        useFill: !1,
        useStroke: !1
    };
    for (const a in Cr) {
        const o = s.getAttribute(a);
        o && Pr(t, n, a, o.trim())
    }
    if (e) {
        const a = e.split(";");
        for (let o = 0; o < a.length; o++) {
            const h = a[o].trim()
              , [l,c] = h.split(":");
            Cr[l] && Pr(t, n, l, c.trim())
        }
    }
    return {
        strokeStyle: n.useStroke ? i : null,
        fillStyle: n.useFill ? r : null,
        useFill: n.useFill,
        useStroke: n.useStroke
    }
}
function Pr(s, t, e, i) {
    switch (e) {
    case "stroke":
        if (i !== "none") {
            if (i.startsWith("url(")) {
                const r = Tr(i);
                t.strokeStyle.fill = s.defs[r]
            } else
                t.strokeStyle.color = J.shared.setValue(i).toNumber();
            t.useStroke = !0
        }
        break;
    case "stroke-width":
        t.strokeStyle.width = Number(i);
        break;
    case "fill":
        if (i !== "none") {
            if (i.startsWith("url(")) {
                const r = Tr(i);
                t.fillStyle.fill = s.defs[r]
            } else
                t.fillStyle.color = J.shared.setValue(i).toNumber();
            t.useFill = !0
        }
        break;
    case "fill-opacity":
        t.fillStyle.alpha = Number(i);
        break;
    case "stroke-opacity":
        t.strokeStyle.alpha = Number(i);
        break;
    case "opacity":
        t.fillStyle.alpha = Number(i),
        t.strokeStyle.alpha = Number(i);
        break
    }
}
function Uc(s) {
    if (s.length <= 2)
        return !0;
    const t = s.map(o => o.area).sort( (o, h) => h - o)
      , [e,i] = t
      , r = t[t.length - 1]
      , n = e / i
      , a = i / r;
    return !(n > 3 && a < 2)
}
function Nc(s) {
    return s.split(/(?=[Mm])/).filter(i => i.trim().length > 0)
}
function Hc(s) {
    const t = s.match(/[-+]?[0-9]*\.?[0-9]+/g);
    if (!t || t.length < 4)
        return 0;
    const e = t.map(Number)
      , i = []
      , r = [];
    for (let c = 0; c < e.length; c += 2)
        c + 1 < e.length && (i.push(e[c]),
        r.push(e[c + 1]));
    if (i.length === 0 || r.length === 0)
        return 0;
    const n = Math.min(...i)
      , a = Math.max(...i)
      , o = Math.min(...r)
      , h = Math.max(...r);
    return (a - n) * (h - o)
}
function Mr(s, t) {
    const e = new It(s,!1);
    for (const i of e.instructions)
        t.instructions.push(i)
}
function $c(s, t) {
    if (typeof s == "string") {
        const a = document.createElement("div");
        a.innerHTML = s.trim(),
        s = a.querySelector("svg")
    }
    const e = {
        context: t,
        defs: {},
        path: new It
    };
    zc(s, e);
    const i = s.children
      , {fillStyle: r, strokeStyle: n} = ga(s, e);
    for (let a = 0; a < i.length; a++) {
        const o = i[a];
        o.nodeName.toLowerCase() !== "defs" && ma(o, e, r, n)
    }
    return t
}
function ma(s, t, e, i) {
    const r = s.children
      , {fillStyle: n, strokeStyle: a} = ga(s, t);
    n && e ? e = {
        ...e,
        ...n
    } : n && (e = n),
    a && i ? i = {
        ...i,
        ...a
    } : a && (i = a);
    const o = !e && !i;
    o && (e = {
        color: 0
    });
    let h, l, c, u, d, f, p, m, g, x, y, _, b, A, w, v, M;
    switch (s.nodeName.toLowerCase()) {
    case "path":
        {
            A = s.getAttribute("d");
            const T = s.getAttribute("fill-rule")
              , S = Nc(A)
              , C = T === "evenodd"
              , k = S.length > 1;
            if (C && k) {
                const F = S.map(P => ({
                    path: P,
                    area: Hc(P)
                }));
                if (F.sort( (P, E) => E.area - P.area),
                S.length > 3 || !Uc(F))
                    for (let P = 0; P < F.length; P++) {
                        const E = F[P]
                          , N = P === 0;
                        t.context.beginPath();
                        const B = new It(void 0,!0);
                        Mr(E.path, B),
                        t.context.path(B),
                        N ? (e && t.context.fill(e),
                        i && t.context.stroke(i)) : t.context.cut()
                    }
                else
                    for (let P = 0; P < F.length; P++) {
                        const E = F[P]
                          , N = P % 2 === 1;
                        t.context.beginPath();
                        const B = new It(void 0,!0);
                        Mr(E.path, B),
                        t.context.path(B),
                        N ? t.context.cut() : (e && t.context.fill(e),
                        i && t.context.stroke(i))
                    }
            } else {
                const F = T ? T === "evenodd" : !0;
                w = new It(A,F),
                t.context.path(w),
                e && t.context.fill(e),
                i && t.context.stroke(i)
            }
            break
        }
    case "circle":
        p = X(s, "cx", 0),
        m = X(s, "cy", 0),
        g = X(s, "r", 0),
        t.context.ellipse(p, m, g, g),
        e && t.context.fill(e),
        i && t.context.stroke(i);
        break;
    case "rect":
        h = X(s, "x", 0),
        l = X(s, "y", 0),
        v = X(s, "width", 0),
        M = X(s, "height", 0),
        x = X(s, "rx", 0),
        y = X(s, "ry", 0),
        x || y ? t.context.roundRect(h, l, v, M, x || y) : t.context.rect(h, l, v, M),
        e && t.context.fill(e),
        i && t.context.stroke(i);
        break;
    case "ellipse":
        p = X(s, "cx", 0),
        m = X(s, "cy", 0),
        x = X(s, "rx", 0),
        y = X(s, "ry", 0),
        t.context.beginPath(),
        t.context.ellipse(p, m, x, y),
        e && t.context.fill(e),
        i && t.context.stroke(i);
        break;
    case "line":
        c = X(s, "x1", 0),
        u = X(s, "y1", 0),
        d = X(s, "x2", 0),
        f = X(s, "y2", 0),
        t.context.beginPath(),
        t.context.moveTo(c, u),
        t.context.lineTo(d, f),
        i && t.context.stroke(i);
        break;
    case "polygon":
        b = s.getAttribute("points"),
        _ = b.match(/-?\d+/g).map(T => parseInt(T, 10)),
        t.context.poly(_, !0),
        e && t.context.fill(e),
        i && t.context.stroke(i);
        break;
    case "polyline":
        b = s.getAttribute("points"),
        _ = b.match(/-?\d+/g).map(T => parseInt(T, 10)),
        t.context.poly(_, !1),
        i && t.context.stroke(i);
        break;
    case "g":
    case "svg":
        break;
    default:
        {
            $(`[SVG parser] <${s.nodeName}> elements unsupported`);
            break
        }
    }
    o && (e = null);
    for (let T = 0; T < r.length; T++)
        ma(r[T], t, e, i)
}
const kr = {
    repeat: {
        addressModeU: "repeat",
        addressModeV: "repeat"
    },
    "repeat-x": {
        addressModeU: "repeat",
        addressModeV: "clamp-to-edge"
    },
    "repeat-y": {
        addressModeU: "clamp-to-edge",
        addressModeV: "repeat"
    },
    "no-repeat": {
        addressModeU: "clamp-to-edge",
        addressModeV: "clamp-to-edge"
    }
};
class xs {
    constructor(t, e) {
        this.uid = q("fillPattern"),
        this._tick = 0,
        this.transform = new D,
        this.texture = t,
        this.transform.scale(1 / t.frame.width, 1 / t.frame.height),
        e && (t.source.style.addressModeU = kr[e].addressModeU,
        t.source.style.addressModeV = kr[e].addressModeV)
    }
    setTransform(t) {
        const e = this.texture;
        this.transform.copyFrom(t),
        this.transform.invert(),
        this.transform.scale(1 / e.frame.width, 1 / e.frame.height),
        this._tick++
    }
    get texture() {
        return this._texture
    }
    set texture(t) {
        this._texture !== t && (this._texture = t,
        this._tick++)
    }
    get styleKey() {
        return `fill-pattern-${this.uid}-${this._tick}`
    }
    destroy() {
        this.texture.destroy(!0),
        this.texture = null
    }
}
function Vc(s) {
    return J.isColorLike(s)
}
function Er(s) {
    return s instanceof xs
}
function Ir(s) {
    return s instanceof Rt
}
function jc(s) {
    return s instanceof W
}
function Yc(s, t, e) {
    const i = J.shared.setValue(t ?? 0);
    return s.color = i.toNumber(),
    s.alpha = i.alpha === 1 ? e.alpha : i.alpha,
    s.texture = W.WHITE,
    {
        ...e,
        ...s
    }
}
function Xc(s, t, e) {
    return s.texture = t,
    {
        ...e,
        ...s
    }
}
function Rr(s, t, e) {
    return s.fill = t,
    s.color = 16777215,
    s.texture = t.texture,
    s.matrix = t.transform,
    {
        ...e,
        ...s
    }
}
function Br(s, t, e) {
    return t.buildGradient(),
    s.fill = t,
    s.color = 16777215,
    s.texture = t.texture,
    s.matrix = t.transform,
    s.textureSpace = t.textureSpace,
    {
        ...e,
        ...s
    }
}
function qc(s, t) {
    const e = {
        ...t,
        ...s
    }
      , i = J.shared.setValue(e.color);
    return e.alpha *= i.alpha,
    e.color = i.toNumber(),
    e
}
function Qt(s, t) {
    if (s == null)
        return null;
    const e = {}
      , i = s;
    return Vc(s) ? Yc(e, s, t) : jc(s) ? Xc(e, s, t) : Er(s) ? Rr(e, s, t) : Ir(s) ? Br(e, s, t) : i.fill && Er(i.fill) ? Rr(i, i.fill, t) : i.fill && Ir(i.fill) ? Br(i, i.fill, t) : qc(i, t)
}
function ls(s, t) {
    const {width: e, alignment: i, miterLimit: r, cap: n, join: a, pixelLine: o, ...h} = t
      , l = Qt(s, h);
    return l ? {
        width: e,
        alignment: i,
        miterLimit: r,
        cap: n,
        join: a,
        pixelLine: o,
        ...l
    } : null
}
function Kc(s, t) {
    let e = 1;
    const i = s.shapePath.shapePrimitives;
    for (let r = 0; r < i.length; r++) {
        const n = i[r].shape;
        if (n.type !== "polygon")
            continue;
        const a = n.points
          , o = a.length;
        if (o < 6)
            continue;
        const h = n.closePath;
        for (let l = 0; l < o; l += 2) {
            if (!h && (l === 0 || l === o - 2))
                continue;
            const c = (l - 2 + o) % o
              , u = (l + 2) % o
              , d = a[c]
              , f = a[c + 1]
              , p = a[l]
              , m = a[l + 1]
              , g = a[u]
              , x = a[u + 1]
              , y = d - p
              , _ = f - m
              , b = g - p
              , A = x - m
              , w = y * y + _ * _
              , v = b * b + A * A;
            if (w < 1e-12 || v < 1e-12)
                continue;
            let S = (y * b + _ * A) / Math.sqrt(w * v);
            S < -1 ? S = -1 : S > 1 && (S = 1);
            const C = Math.sqrt((1 - S) * .5);
            if (C < 1e-6)
                continue;
            const k = Math.min(1 / C, t);
            k > e && (e = k)
        }
    }
    return e
}
const Zc = new nt
  , Fr = new D
  , vi = class At extends vt {
    constructor() {
        super(...arguments),
        this._gpuData = Object.create(null),
        this.autoGarbageCollect = !0,
        this._gcLastUsed = -1,
        this.uid = q("graphicsContext"),
        this.dirty = !0,
        this.batchMode = "auto",
        this.instructions = [],
        this.destroyed = !1,
        this._activePath = new It,
        this._transform = new D,
        this._fillStyle = {
            ...At.defaultFillStyle
        },
        this._strokeStyle = {
            ...At.defaultStrokeStyle
        },
        this._stateStack = [],
        this._tick = 0,
        this._bounds = new gt,
        this._boundsDirty = !0
    }
    clone() {
        const t = new At;
        return t.batchMode = this.batchMode,
        t.instructions = this.instructions.slice(),
        t._activePath = this._activePath.clone(),
        t._transform = this._transform.clone(),
        t._fillStyle = {
            ...this._fillStyle
        },
        t._strokeStyle = {
            ...this._strokeStyle
        },
        t._stateStack = this._stateStack.slice(),
        t._bounds = this._bounds.clone(),
        t._boundsDirty = !0,
        t
    }
    get fillStyle() {
        return this._fillStyle
    }
    set fillStyle(t) {
        this._fillStyle = Qt(t, At.defaultFillStyle)
    }
    get strokeStyle() {
        return this._strokeStyle
    }
    set strokeStyle(t) {
        this._strokeStyle = ls(t, At.defaultStrokeStyle)
    }
    setFillStyle(t) {
        return this._fillStyle = Qt(t, At.defaultFillStyle),
        this
    }
    setStrokeStyle(t) {
        return this._strokeStyle = Qt(t, At.defaultStrokeStyle),
        this
    }
    texture(t, e, i, r, n, a) {
        return this.instructions.push({
            action: "texture",
            data: {
                image: t,
                dx: i || 0,
                dy: r || 0,
                dw: n || t.frame.width,
                dh: a || t.frame.height,
                transform: this._transform.clone(),
                alpha: this._fillStyle.alpha,
                style: e || e === 0 ? J.shared.setValue(e).toNumber() : 16777215
            }
        }),
        this.onUpdate(),
        this
    }
    beginPath() {
        return this._activePath = new It,
        this
    }
    fill(t, e) {
        let i;
        const r = this.instructions[this.instructions.length - 1];
        return this._tick === 0 && (r == null ? void 0 : r.action) === "stroke" ? i = r.data.path : i = this._activePath.clone(),
        i ? (t != null && (e !== void 0 && typeof t == "number" && (V(dt, "GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),
        t = {
            color: t,
            alpha: e
        }),
        this._fillStyle = Qt(t, At.defaultFillStyle)),
        this.instructions.push({
            action: "fill",
            data: {
                style: this.fillStyle,
                path: i
            }
        }),
        this.onUpdate(),
        this._initNextPathLocation(),
        this._tick = 0,
        this) : this
    }
    _initNextPathLocation() {
        const {x: t, y: e} = this._activePath.getLastPoint(nt.shared);
        this._activePath.clear(),
        this._activePath.moveTo(t, e)
    }
    stroke(t) {
        let e;
        const i = this.instructions[this.instructions.length - 1];
        return this._tick === 0 && (i == null ? void 0 : i.action) === "fill" ? e = i.data.path : e = this._activePath.clone(),
        e ? (t != null && (this._strokeStyle = ls(t, At.defaultStrokeStyle)),
        this.instructions.push({
            action: "stroke",
            data: {
                style: this.strokeStyle,
                path: e
            }
        }),
        this.onUpdate(),
        this._initNextPathLocation(),
        this._tick = 0,
        this) : this
    }
    cut() {
        for (let t = 0; t < 2; t++) {
            const e = this.instructions[this.instructions.length - 1 - t]
              , i = this._activePath.clone();
            if (e && (e.action === "stroke" || e.action === "fill"))
                if (e.data.hole)
                    e.data.hole.addPath(i);
                else {
                    e.data.hole = i;
                    break
                }
        }
        return this._initNextPathLocation(),
        this
    }
    arc(t, e, i, r, n, a) {
        this._tick++;
        const o = this._transform;
        return this._activePath.arc(o.a * t + o.c * e + o.tx, o.b * t + o.d * e + o.ty, i, r, n, a),
        this
    }
    arcTo(t, e, i, r, n) {
        this._tick++;
        const a = this._transform;
        return this._activePath.arcTo(a.a * t + a.c * e + a.tx, a.b * t + a.d * e + a.ty, a.a * i + a.c * r + a.tx, a.b * i + a.d * r + a.ty, n),
        this
    }
    arcToSvg(t, e, i, r, n, a, o) {
        this._tick++;
        const h = this._transform;
        return this._activePath.arcToSvg(t, e, i, r, n, h.a * a + h.c * o + h.tx, h.b * a + h.d * o + h.ty),
        this
    }
    bezierCurveTo(t, e, i, r, n, a, o) {
        this._tick++;
        const h = this._transform;
        return this._activePath.bezierCurveTo(h.a * t + h.c * e + h.tx, h.b * t + h.d * e + h.ty, h.a * i + h.c * r + h.tx, h.b * i + h.d * r + h.ty, h.a * n + h.c * a + h.tx, h.b * n + h.d * a + h.ty, o),
        this
    }
    closePath() {
        var t;
        return this._tick++,
        (t = this._activePath) == null || t.closePath(),
        this
    }
    ellipse(t, e, i, r) {
        return this._tick++,
        this._activePath.ellipse(t, e, i, r, this._transform.clone()),
        this
    }
    circle(t, e, i) {
        return this._tick++,
        this._activePath.circle(t, e, i, this._transform.clone()),
        this
    }
    path(t) {
        return this._tick++,
        this._activePath.addPath(t, this._transform.clone()),
        this
    }
    lineTo(t, e) {
        this._tick++;
        const i = this._transform;
        return this._activePath.lineTo(i.a * t + i.c * e + i.tx, i.b * t + i.d * e + i.ty),
        this
    }
    moveTo(t, e) {
        this._tick++;
        const i = this._transform
          , r = this._activePath.instructions
          , n = i.a * t + i.c * e + i.tx
          , a = i.b * t + i.d * e + i.ty;
        return r.length === 1 && r[0].action === "moveTo" ? (r[0].data[0] = n,
        r[0].data[1] = a,
        this) : (this._activePath.moveTo(n, a),
        this)
    }
    quadraticCurveTo(t, e, i, r, n) {
        this._tick++;
        const a = this._transform;
        return this._activePath.quadraticCurveTo(a.a * t + a.c * e + a.tx, a.b * t + a.d * e + a.ty, a.a * i + a.c * r + a.tx, a.b * i + a.d * r + a.ty, n),
        this
    }
    rect(t, e, i, r) {
        return this._tick++,
        this._activePath.rect(t, e, i, r, this._transform.clone()),
        this
    }
    roundRect(t, e, i, r, n) {
        return this._tick++,
        this._activePath.roundRect(t, e, i, r, n, this._transform.clone()),
        this
    }
    poly(t, e) {
        return this._tick++,
        this._activePath.poly(t, e, this._transform.clone()),
        this
    }
    regularPoly(t, e, i, r, n=0, a) {
        return this._tick++,
        this._activePath.regularPoly(t, e, i, r, n, a),
        this
    }
    roundPoly(t, e, i, r, n, a) {
        return this._tick++,
        this._activePath.roundPoly(t, e, i, r, n, a),
        this
    }
    roundShape(t, e, i, r) {
        return this._tick++,
        this._activePath.roundShape(t, e, i, r),
        this
    }
    filletRect(t, e, i, r, n) {
        return this._tick++,
        this._activePath.filletRect(t, e, i, r, n),
        this
    }
    chamferRect(t, e, i, r, n, a) {
        return this._tick++,
        this._activePath.chamferRect(t, e, i, r, n, a),
        this
    }
    star(t, e, i, r, n=0, a=0) {
        return this._tick++,
        this._activePath.star(t, e, i, r, n, a, this._transform.clone()),
        this
    }
    svg(t) {
        return this._tick++,
        $c(t, this),
        this
    }
    restore() {
        const t = this._stateStack.pop();
        return t && (this._transform = t.transform,
        this._fillStyle = t.fillStyle,
        this._strokeStyle = t.strokeStyle),
        this
    }
    save() {
        return this._stateStack.push({
            transform: this._transform.clone(),
            fillStyle: {
                ...this._fillStyle
            },
            strokeStyle: {
                ...this._strokeStyle
            }
        }),
        this
    }
    getTransform() {
        return this._transform
    }
    resetTransform() {
        return this._transform.identity(),
        this
    }
    rotate(t) {
        return this._transform.rotate(t),
        this
    }
    scale(t, e=t) {
        return this._transform.scale(t, e),
        this
    }
    setTransform(t, e, i, r, n, a) {
        return t instanceof D ? (this._transform.set(t.a, t.b, t.c, t.d, t.tx, t.ty),
        this) : (this._transform.set(t, e, i, r, n, a),
        this)
    }
    transform(t, e, i, r, n, a) {
        return t instanceof D ? (this._transform.append(t),
        this) : (Fr.set(t, e, i, r, n, a),
        this._transform.append(Fr),
        this)
    }
    translate(t, e=t) {
        return this._transform.translate(t, e),
        this
    }
    clear() {
        return this._activePath.clear(),
        this.instructions.length = 0,
        this.resetTransform(),
        this.onUpdate(),
        this
    }
    onUpdate() {
        this._boundsDirty = !0,
        this.dirty = !0,
        this.emit("update", this, 16)
    }
    get bounds() {
        if (!this._boundsDirty)
            return this._bounds;
        this._boundsDirty = !1;
        const t = this._bounds;
        t.clear();
        for (let e = 0; e < this.instructions.length; e++) {
            const i = this.instructions[e]
              , r = i.action;
            if (r === "fill") {
                const n = i.data;
                t.addBounds(n.path.bounds)
            } else if (r === "texture") {
                const n = i.data;
                t.addFrame(n.dx, n.dy, n.dx + n.dw, n.dy + n.dh, n.transform)
            }
            if (r === "stroke") {
                const n = i.data
                  , a = n.style.alignment;
                let o = n.style.width * (1 - a);
                n.style.join === "miter" && (o *= Kc(n.path, n.style.miterLimit));
                const h = n.path.bounds;
                t.addFrame(h.minX - o, h.minY - o, h.maxX + o, h.maxY + o)
            }
        }
        return t.isValid || t.set(0, 0, 0, 0),
        t
    }
    containsPoint(t) {
        var r;
        if (!this.bounds.containsPoint(t.x, t.y))
            return !1;
        const e = this.instructions;
        let i = !1;
        for (let n = 0; n < e.length; n++) {
            const a = e[n]
              , o = a.data
              , h = o.path;
            if (!a.action || !h)
                continue;
            const l = o.style
              , c = h.shapePath.shapePrimitives;
            for (let u = 0; u < c.length; u++) {
                const d = c[u].shape;
                if (!l || !d)
                    continue;
                const f = c[u].transform
                  , p = f ? f.applyInverse(t, Zc) : t;
                if (a.action === "fill")
                    i = d.contains(p.x, p.y);
                else {
                    const g = l;
                    i = d.strokeContains(p.x, p.y, g.width, g.alignment)
                }
                const m = o.hole;
                if (m) {
                    const g = (r = m.shapePath) == null ? void 0 : r.shapePrimitives;
                    if (g)
                        for (let x = 0; x < g.length; x++)
                            g[x].shape.contains(p.x, p.y) && (i = !1)
                }
                if (i)
                    return !0
            }
        }
        return i
    }
    unload() {
        var t;
        this.emit("unload", this);
        for (const e in this._gpuData)
            (t = this._gpuData[e]) == null || t.destroy();
        this._gpuData = Object.create(null)
    }
    destroy(t=!1) {
        if (this.destroyed)
            return;
        if (this.destroyed = !0,
        this._stateStack.length = 0,
        this._transform = null,
        this.unload(),
        this.emit("destroy", this),
        this.removeAllListeners(),
        typeof t == "boolean" ? t : t == null ? void 0 : t.texture) {
            const i = typeof t == "boolean" ? t : t == null ? void 0 : t.textureSource;
            this._fillStyle.texture && (this._fillStyle.fill && "uid"in this._fillStyle.fill ? this._fillStyle.fill.destroy() : this._fillStyle.texture.destroy(i)),
            this._strokeStyle.texture && (this._strokeStyle.fill && "uid"in this._strokeStyle.fill ? this._strokeStyle.fill.destroy() : this._strokeStyle.texture.destroy(i))
        }
        this._fillStyle = null,
        this._strokeStyle = null,
        this.instructions = null,
        this._activePath = null,
        this._bounds = null,
        this._stateStack = null,
        this.customShader = null,
        this._transform = null
    }
}
;
vi.defaultFillStyle = {
    color: 16777215,
    alpha: 1,
    texture: W.WHITE,
    matrix: null,
    fill: null,
    textureSpace: "local"
};
vi.defaultStrokeStyle = {
    width: 1,
    color: 16777215,
    alpha: 1,
    alignment: .5,
    miterLimit: 10,
    cap: "butt",
    join: "miter",
    texture: W.WHITE,
    matrix: null,
    fill: null,
    textureSpace: "local",
    pixelLine: !1
};
let Kt = vi;
function Si(s, t=1) {
    var i;
    const e = (i = me.RETINA_PREFIX) == null ? void 0 : i.exec(s);
    return e ? parseFloat(e[1]) : t
}
function Ti(s, t, e) {
    s.label = e,
    s._sourceOrigin = e;
    const i = new W({
        source: s,
        label: e
    })
      , r = () => {
        delete t.promiseCache[e],
        st.has(e) && st.remove(e)
    }
    ;
    return i.source.once("destroy", () => {
        t.promiseCache[e] && ($("[Assets] A TextureSource managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the TextureSource."),
        r())
    }
    ),
    i.once("destroy", () => {
        s.destroyed || ($("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."),
        r())
    }
    ),
    i
}
const Qc = ".svg"
  , Jc = "image/svg+xml"
  , tu = {
    extension: {
        type: I.LoadParser,
        priority: Dt.Low,
        name: "loadSVG"
    },
    name: "loadSVG",
    id: "svg",
    config: {
        crossOrigin: "anonymous",
        parseAsGraphicsContext: !1
    },
    test(s) {
        return xe(s, Jc) || ye(s, Qc)
    },
    async load(s, t, e) {
        var i;
        return ((i = t.data) == null ? void 0 : i.parseAsGraphicsContext) ?? this.config.parseAsGraphicsContext ? su(s) : eu(s, t, e, this.config.crossOrigin)
    },
    unload(s) {
        s.destroy(!0)
    }
};
async function eu(s, t, e, i) {
    var g, x, y;
    const r = await O.get().fetch(s)
      , n = O.get().createImage();
    n.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,
    n.crossOrigin = i,
    await n.decode();
    const a = ((g = t.data) == null ? void 0 : g.width) ?? n.width
      , o = ((x = t.data) == null ? void 0 : x.height) ?? n.height
      , h = ((y = t.data) == null ? void 0 : y.resolution) || Si(s)
      , l = Math.ceil(a * h)
      , c = Math.ceil(o * h)
      , u = O.get().createCanvas(l, c)
      , d = u.getContext("2d");
    d.imageSmoothingEnabled = !0,
    d.imageSmoothingQuality = "high",
    d.drawImage(n, 0, 0, a * h, o * h);
    const {parseAsGraphicsContext: f, ...p} = t.data ?? {}
      , m = new pe({
        resource: u,
        alphaMode: "premultiply-alpha-on-upload",
        resolution: h,
        ...p
    });
    return Ti(m, e, s)
}
async function su(s) {
    const e = await (await O.get().fetch(s)).text()
      , i = new Kt;
    return i.svg(e),
    i
}
const iu = `(function () {
    'use strict';

    const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
    async function checkImageBitmap() {
      try {
        if (typeof createImageBitmap !== "function") return false;
        const response = await fetch(WHITE_PNG);
        const imageBlob = await response.blob();
        const imageBitmap = await createImageBitmap(imageBlob);
        return imageBitmap.width === 1 && imageBitmap.height === 1;
      } catch (_e) {
        return false;
      }
    }
    void checkImageBitmap().then((result) => {
      self.postMessage(result);
    });

})();
`;
let he = null
  , li = class {
    constructor() {
        he || (he = URL.createObjectURL(new Blob([iu],{
            type: "application/javascript"
        }))),
        this.worker = new Worker(he)
    }
}
;
li.revokeObjectURL = function() {
    he && (URL.revokeObjectURL(he),
    he = null)
}
;
const ru = `(function () {
    'use strict';

    async function loadImageBitmap(url, alphaMode) {
      const response = await fetch(url);
      if (!response.ok) {
        throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \${response.status} \${response.statusText}\`);
      }
      const imageBlob = await response.blob();
      return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);
    }
    self.onmessage = async (event) => {
      try {
        const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);
        self.postMessage({
          data: imageBitmap,
          uuid: event.data.uuid,
          id: event.data.id
        }, [imageBitmap]);
      } catch (e) {
        self.postMessage({
          error: e,
          uuid: event.data.uuid,
          id: event.data.id
        });
      }
    };

})();
`;
let le = null;
class xa {
    constructor() {
        le || (le = URL.createObjectURL(new Blob([ru],{
            type: "application/javascript"
        }))),
        this.worker = new Worker(le)
    }
}
xa.revokeObjectURL = function() {
    le && (URL.revokeObjectURL(le),
    le = null)
}
;
let Lr = 0, Ns;
class nu {
    constructor() {
        this._initialized = !1,
        this._createdWorkers = 0,
        this._workerPool = [],
        this._queue = [],
        this._resolveHash = {}
    }
    isImageBitmapSupported() {
        return this._isImageBitmapSupported !== void 0 ? this._isImageBitmapSupported : (this._isImageBitmapSupported = new Promise(t => {
            const {worker: e} = new li;
            e.addEventListener("message", i => {
                e.terminate(),
                li.revokeObjectURL(),
                t(i.data)
            }
            )
        }
        ),
        this._isImageBitmapSupported)
    }
    loadImageBitmap(t, e) {
        var i;
        return this._run("loadImageBitmap", [t, (i = e == null ? void 0 : e.data) == null ? void 0 : i.alphaMode])
    }
    async _initWorkers() {
        this._initialized || (this._initialized = !0)
    }
    _getWorker() {
        Ns === void 0 && (Ns = navigator.hardwareConcurrency || 4);
        let t = this._workerPool.pop();
        return !t && this._createdWorkers < Ns && (this._createdWorkers++,
        t = new xa().worker,
        t.addEventListener("message", e => {
            this._complete(e.data),
            this._returnWorker(e.target),
            this._next()
        }
        )),
        t
    }
    _returnWorker(t) {
        this._workerPool.push(t)
    }
    _complete(t) {
        this._resolveHash[t.uuid] && (t.error !== void 0 ? this._resolveHash[t.uuid].reject(t.error) : this._resolveHash[t.uuid].resolve(t.data),
        delete this._resolveHash[t.uuid])
    }
    async _run(t, e) {
        await this._initWorkers();
        const i = new Promise( (r, n) => {
            this._queue.push({
                id: t,
                arguments: e,
                resolve: r,
                reject: n
            })
        }
        );
        return this._next(),
        i
    }
    _next() {
        if (!this._queue.length)
            return;
        const t = this._getWorker();
        if (!t)
            return;
        const e = this._queue.pop()
          , i = e.id;
        this._resolveHash[Lr] = {
            resolve: e.resolve,
            reject: e.reject
        },
        t.postMessage({
            data: e.arguments,
            uuid: Lr++,
            id: i
        })
    }
    reset() {
        this._workerPool.forEach(t => t.terminate()),
        this._workerPool.length = 0,
        Object.values(this._resolveHash).forEach( ({reject: t}) => {
            t == null || t(new Error("WorkerManager has been reset before completion"))
        }
        ),
        this._resolveHash = {},
        this._queue.length = 0,
        this._initialized = !1,
        this._createdWorkers = 0
    }
}
const Gr = new nu
  , au = [".jpeg", ".jpg", ".png", ".webp", ".avif"]
  , ou = ["image/jpeg", "image/png", "image/webp", "image/avif"];
async function hu(s, t) {
    var r;
    const e = await O.get().fetch(s);
    if (!e.ok)
        throw new Error(`[loadImageBitmap] Failed to fetch ${s}: ${e.status} ${e.statusText}`);
    const i = await e.blob();
    return ((r = t == null ? void 0 : t.data) == null ? void 0 : r.alphaMode) === "premultiplied-alpha" ? createImageBitmap(i, {
        premultiplyAlpha: "none"
    }) : createImageBitmap(i)
}
const ya = {
    name: "loadTextures",
    id: "texture",
    extension: {
        type: I.LoadParser,
        priority: Dt.High,
        name: "loadTextures"
    },
    config: {
        preferWorkers: !0,
        preferCreateImageBitmap: !0,
        crossOrigin: "anonymous"
    },
    test(s) {
        return xe(s, ou) || ye(s, au)
    },
    async load(s, t, e) {
        var n;
        let i = null;
        globalThis.createImageBitmap && this.config.preferCreateImageBitmap ? this.config.preferWorkers && await Gr.isImageBitmapSupported() ? i = await Gr.loadImageBitmap(s, t) : i = await hu(s, t) : i = await new Promise( (a, o) => {
            i = O.get().createImage(),
            i.crossOrigin = this.config.crossOrigin,
            i.src = s,
            i.complete ? a(i) : (i.onload = () => {
                a(i)
            }
            ,
            i.onerror = o)
        }
        );
        const r = new pe({
            resource: i,
            alphaMode: "premultiply-alpha-on-upload",
            resolution: ((n = t.data) == null ? void 0 : n.resolution) || Si(s),
            ...t.data
        });
        return Ti(r, e, s)
    },
    unload(s) {
        s.destroy(!0)
    }
}
  , lu = [".mp4", ".m4v", ".webm", ".ogg", ".ogv", ".h264", ".avi", ".mov"];
let Hs, $s;
function cu(s, t, e) {
    e === void 0 && !t.startsWith("data:") ? s.crossOrigin = du(t) : e !== !1 && (s.crossOrigin = typeof e == "string" ? e : "anonymous")
}
function uu(s) {
    return new Promise( (t, e) => {
        s.addEventListener("canplaythrough", i),
        s.addEventListener("error", r),
        s.load();
        function i() {
            n(),
            t()
        }
        function r(a) {
            n(),
            e(a)
        }
        function n() {
            s.removeEventListener("canplaythrough", i),
            s.removeEventListener("error", r)
        }
    }
    )
}
function du(s, t=globalThis.location) {
    if (s.startsWith("data:"))
        return "";
    t || (t = globalThis.location);
    const e = new URL(s,document.baseURI);
    return e.hostname !== t.hostname || e.port !== t.port || e.protocol !== t.protocol ? "anonymous" : ""
}
function fu() {
    const s = []
      , t = [];
    for (const e of lu) {
        const i = Ie.MIME_TYPES[e.substring(1)] || `video/${e.substring(1)}`;
        gs(i) && (s.push(e),
        t.includes(i) || t.push(i))
    }
    return {
        validVideoExtensions: s,
        validVideoMime: t
    }
}
const pu = {
    name: "loadVideo",
    id: "video",
    extension: {
        type: I.LoadParser,
        name: "loadVideo"
    },
    test(s) {
        if (!Hs || !$s) {
            const {validVideoExtensions: i, validVideoMime: r} = fu();
            Hs = i,
            $s = r
        }
        const t = xe(s, $s)
          , e = ye(s, Hs);
        return t || e
    },
    async load(s, t, e) {
        var h, l;
        const i = {
            ...Ie.defaultOptions,
            resolution: ((h = t.data) == null ? void 0 : h.resolution) || Si(s),
            alphaMode: ((l = t.data) == null ? void 0 : l.alphaMode) || await Tn(),
            ...t.data
        }
          , r = document.createElement("video")
          , n = {
            preload: i.autoLoad !== !1 ? "auto" : void 0,
            "webkit-playsinline": i.playsinline !== !1 ? "" : void 0,
            playsinline: i.playsinline !== !1 ? "" : void 0,
            muted: i.muted === !0 ? "" : void 0,
            loop: i.loop === !0 ? "" : void 0,
            autoplay: i.autoPlay !== !1 ? "" : void 0
        };
        Object.keys(n).forEach(c => {
            const u = n[c];
            u !== void 0 && r.setAttribute(c, u)
        }
        ),
        i.muted === !0 && (r.muted = !0),
        cu(r, s, i.crossorigin);
        const a = document.createElement("source");
        let o;
        if (i.mime)
            o = i.mime;
        else if (s.startsWith("data:"))
            o = s.slice(5, s.indexOf(";"));
        else if (!s.startsWith("blob:")) {
            const c = s.split("?")[0].slice(s.lastIndexOf(".") + 1).toLowerCase();
            o = Ie.MIME_TYPES[c] || `video/${c}`
        }
        return a.src = s,
        o && (a.type = o),
        new Promise( (c, u) => {
            i.preload && !i.autoPlay && r.load(),
            r.addEventListener("canplay", d),
            r.addEventListener("error", f),
            a.addEventListener("error", f),
            r.appendChild(a);
            async function d() {
                const m = new Ie({
                    ...i,
                    resource: r
                });
                p(),
                t.data.preload && await uu(r),
                c(Ti(m, e, s))
            }
            function f(m) {
                p(),
                u(m)
            }
            function p() {
                r.removeEventListener("canplay", d),
                r.removeEventListener("error", f),
                a.removeEventListener("error", f)
            }
        }
        )
    },
    unload(s) {
        s.destroy(!0)
    }
}
  , _a = {
    extension: {
        type: I.ResolveParser,
        name: "resolveTexture"
    },
    test: ya.test,
    parse: s => {
        var t;
        return {
            resolution: parseFloat(((t = me.RETINA_PREFIX.exec(s)) == null ? void 0 : t[1]) ?? "1"),
            format: s.split(".").pop(),
            src: s
        }
    }
}
  , gu = {
    extension: {
        type: I.ResolveParser,
        priority: -2,
        name: "resolveJson"
    },
    test: s => me.RETINA_PREFIX.test(s) && s.endsWith(".json"),
    parse: _a.parse
};
class mu {
    constructor() {
        this._detections = [],
        this._initialized = !1,
        this.resolver = new me,
        this.loader = new Uh,
        this.cache = st,
        this._backgroundLoader = new Rh(this.loader),
        this._backgroundLoader.active = !0,
        this.reset()
    }
    async init(t={}) {
        var n, a;
        if (this._initialized) {
            $("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");
            return
        }
        if (this._initialized = !0,
        t.defaultSearchParams && this.resolver.setDefaultSearchParams(t.defaultSearchParams),
        t.basePath && (this.resolver.basePath = t.basePath),
        t.bundleIdentifier && this.resolver.setBundleIdentifier(t.bundleIdentifier),
        t.manifest) {
            let o = t.manifest;
            typeof o == "string" && (o = await this.load(o)),
            this.resolver.addManifest(o)
        }
        const e = ((n = t.texturePreference) == null ? void 0 : n.resolution) ?? 1
          , i = typeof e == "number" ? [e] : e
          , r = await this._detectFormats({
            preferredFormats: (a = t.texturePreference) == null ? void 0 : a.format,
            skipDetections: t.skipDetections,
            detections: this._detections
        });
        this.resolver.prefer({
            params: {
                format: r,
                resolution: i
            }
        }),
        t.preferences && this.setPreferences(t.preferences),
        t.loadOptions && (this.loader.loadOptions = {
            ...this.loader.loadOptions,
            ...t.loadOptions
        })
    }
    add(t) {
        this.resolver.add(t)
    }
    async load(t, e) {
        this._initialized || await this.init();
        const i = os(t)
          , r = bt(t).map(o => {
            if (typeof o != "string") {
                const h = this.resolver.getAlias(o);
                return h.some(l => !this.resolver.hasKey(l)) && this.add(o),
                Array.isArray(h) ? h[0] : h
            }
            return this.resolver.hasKey(o) || this.add({
                alias: o,
                src: o
            }),
            o
        }
        )
          , n = this.resolver.resolve(r)
          , a = await this._mapLoadToResolve(n, e);
        return i ? a[r[0]] : a
    }
    addBundle(t, e) {
        this.resolver.addBundle(t, e)
    }
    async loadBundle(t, e) {
        this._initialized || await this.init();
        let i = !1;
        typeof t == "string" && (i = !0,
        t = [t]);
        const r = this.resolver.resolveBundle(t)
          , n = {}
          , a = Object.keys(r);
        let o = 0;
        const h = []
          , l = () => {
            e == null || e(h.reduce( (u, d) => u + d, 0) / o)
        }
          , c = a.map( (u, d) => {
            const f = r[u]
              , p = Object.values(f)
              , g = [...new Set(p.flat())].reduce( (x, y) => x + (y.progressSize || 1), 0);
            return h.push(0),
            o += g,
            this._mapLoadToResolve(f, x => {
                h[d] = x * g,
                l()
            }
            ).then(x => {
                n[u] = x
            }
            )
        }
        );
        return await Promise.all(c),
        i ? n[t[0]] : n
    }
    async backgroundLoad(t) {
        this._initialized || await this.init(),
        typeof t == "string" && (t = [t]);
        const e = this.resolver.resolve(t);
        this._backgroundLoader.add(Object.values(e))
    }
    async backgroundLoadBundle(t) {
        this._initialized || await this.init(),
        typeof t == "string" && (t = [t]);
        const e = this.resolver.resolveBundle(t);
        Object.values(e).forEach(i => {
            this._backgroundLoader.add(Object.values(i))
        }
        )
    }
    reset() {
        this.resolver.reset(),
        this.loader.reset(),
        this.cache.reset(),
        this._initialized = !1
    }
    get(t) {
        if (typeof t == "string")
            return st.get(t);
        const e = {};
        for (let i = 0; i < t.length; i++)
            e[i] = st.get(t[i]);
        return e
    }
    async _mapLoadToResolve(t, e) {
        const i = [...new Set(Object.values(t))];
        this._backgroundLoader.active = !1;
        const r = await this.loader.load(i, e);
        this._backgroundLoader.active = !0;
        const n = {};
        return i.forEach(a => {
            const o = r[a.src]
              , h = [a.src];
            a.alias && h.push(...a.alias),
            h.forEach(l => {
                n[l] = o
            }
            ),
            st.set(h, o)
        }
        ),
        n
    }
    async unload(t) {
        this._initialized || await this.init();
        const e = bt(t).map(r => typeof r != "string" ? r.src : r)
          , i = this.resolver.resolve(e);
        await this._unloadFromResolved(i)
    }
    async unloadBundle(t) {
        this._initialized || await this.init(),
        t = bt(t);
        const e = this.resolver.resolveBundle(t)
          , i = Object.keys(e).map(r => this._unloadFromResolved(e[r]));
        await Promise.all(i)
    }
    async _unloadFromResolved(t) {
        const e = Object.values(t);
        e.forEach(i => {
            st.remove(i.src)
        }
        ),
        await this.loader.unload(e)
    }
    async _detectFormats(t) {
        let e = [];
        t.preferredFormats && (e = Array.isArray(t.preferredFormats) ? t.preferredFormats : [t.preferredFormats]);
        for (const i of t.detections)
            t.skipDetections || await i.test() ? e = await i.add(e) : t.skipDetections || (e = await i.remove(e));
        return e = e.filter( (i, r) => e.indexOf(i) === r),
        e
    }
    get detections() {
        return this._detections
    }
    setPreferences(t) {
        this.loader.parsers.forEach(e => {
            e.config && Object.keys(e.config).filter(i => i in t).forEach(i => {
                e.config[i] = t[i]
            }
            )
        }
        )
    }
}
const ss = new mu;
Y.handleByList(I.LoadParser, ss.loader.parsers).handleByList(I.ResolveParser, ss.resolver.parsers).handleByList(I.CacheParser, ss.cache.parsers).handleByList(I.DetectionParser, ss.detections);
Y.add(Bh, Lh, Fh, Oh, Dh, zh, Wh, $h, Yh, el, tu, ya, pu, Ih, Eh, _a, gu);
const Dr = {
    loader: I.LoadParser,
    resolver: I.ResolveParser,
    cache: I.CacheParser,
    detection: I.DetectionParser
};
Y.handle(I.Asset, s => {
    const t = s.ref;
    Object.entries(Dr).filter( ([e]) => !!t[e]).forEach( ([e,i]) => Y.add(Object.assign(t[e], {
        extension: t[e].extension ?? i
    })))
}
, s => {
    const t = s.ref;
    Object.keys(Dr).filter(e => !!t[e]).forEach(e => Y.remove(t[e]))
}
);
class xu {
    constructor(t) {
        this._canvasPool = Object.create(null),
        this.canvasOptions = t || {},
        this.enableFullScreen = !1
    }
    _createCanvasAndContext(t, e) {
        const i = O.get().createCanvas();
        i.width = t,
        i.height = e;
        const r = i.getContext("2d");
        return {
            canvas: i,
            context: r
        }
    }
    getOptimalCanvasAndContext(t, e, i=1) {
        t = Math.ceil(t * i - 1e-6),
        e = Math.ceil(e * i - 1e-6),
        t = ce(t),
        e = ce(e);
        const r = (t << 17) + (e << 1);
        this._canvasPool[r] || (this._canvasPool[r] = []);
        let n = this._canvasPool[r].pop();
        return n || (n = this._createCanvasAndContext(t, e)),
        n
    }
    returnCanvasAndContext(t) {
        const e = t.canvas
          , {width: i, height: r} = e
          , n = (i << 17) + (r << 1);
        t.context.resetTransform(),
        t.context.clearRect(0, 0, i, r),
        this._canvasPool[n].push(t)
    }
    clear() {
        this._canvasPool = {}
    }
}
const ci = new xu;
Ue.register(ci);
const yu = new gt;
function _u(s, t, e, i, r=!1) {
    const n = yu;
    n.minX = 0,
    n.minY = 0,
    n.maxX = s.width / i | 0,
    n.maxY = s.height / i | 0;
    const a = ds.getOptimalTexture(n.width, n.height, i, !1, r);
    return a.source.uploadMethodId = "image",
    a.source.resource = s,
    a.source.alphaMode = "premultiply-alpha-on-upload",
    a.frame.width = t / i,
    a.frame.height = e / i,
    a.source.emit("update", a.source),
    a.updateUvs(),
    a
}
class bu extends xn {
    constructor(t, e) {
        const {text: i, resolution: r, style: n, anchor: a, width: o, height: h, roundPixels: l, ...c} = t;
        super({
            ...c
        }),
        this.batched = !0,
        this._resolution = null,
        this._autoResolution = !0,
        this._didTextUpdate = !0,
        this._styleClass = e,
        this.text = i ?? "",
        this.style = n,
        this.resolution = r ?? null,
        this.allowChildren = !1,
        this._anchor = new it({
            _onUpdate: () => {
                this.onViewUpdate()
            }
        }),
        a && (this.anchor = a),
        this.roundPixels = l ?? !1,
        o !== void 0 && (this.width = o),
        h !== void 0 && (this.height = h)
    }
    get anchor() {
        return this._anchor
    }
    set anchor(t) {
        typeof t == "number" ? this._anchor.set(t) : this._anchor.copyFrom(t)
    }
    set text(t) {
        t = t.toString(),
        this._text !== t && (this._text = t,
        this.onViewUpdate())
    }
    get text() {
        return this._text
    }
    set resolution(t) {
        this._autoResolution = t === null,
        this._resolution = t,
        this.onViewUpdate()
    }
    get resolution() {
        return this._resolution
    }
    get style() {
        return this._style
    }
    set style(t) {
        var e;
        t || (t = {}),
        (e = this._style) == null || e.off("update", this.onViewUpdate, this),
        t instanceof this._styleClass ? this._style = t : this._style = new this._styleClass(t),
        this._style.on("update", this.onViewUpdate, this),
        this.onViewUpdate()
    }
    get width() {
        return Math.abs(this.scale.x) * this.bounds.width
    }
    set width(t) {
        this._setWidth(t, this.bounds.width)
    }
    get height() {
        return Math.abs(this.scale.y) * this.bounds.height
    }
    set height(t) {
        this._setHeight(t, this.bounds.height)
    }
    getSize(t) {
        return t || (t = {}),
        t.width = Math.abs(this.scale.x) * this.bounds.width,
        t.height = Math.abs(this.scale.y) * this.bounds.height,
        t
    }
    setSize(t, e) {
        typeof t == "object" ? (e = t.height ?? t.width,
        t = t.width) : e ?? (e = t),
        t !== void 0 && this._setWidth(t, this.bounds.width),
        e !== void 0 && this._setHeight(e, this.bounds.height)
    }
    containsPoint(t) {
        const e = this.bounds.width
          , i = this.bounds.height
          , r = -e * this.anchor.x;
        let n = 0;
        return t.x >= r && t.x <= r + e && (n = -i * this.anchor.y,
        t.y >= n && t.y <= n + i)
    }
    onViewUpdate() {
        this.didViewUpdate || (this._didTextUpdate = !0),
        super.onViewUpdate()
    }
    destroy(t=!1) {
        super.destroy(t),
        this.owner = null,
        this._bounds = null,
        this._anchor = null,
        (typeof t == "boolean" ? t : t != null && t.style) && this._style.destroy(t),
        this._style = null,
        this._text = null
    }
    get styleKey() {
        return `${this._text}:${this._style.styleKey}:${this._resolution}`
    }
}
function wu(s, t) {
    let e = s[0] ?? {};
    return (typeof e == "string" || s[1]) && (V(dt, `use new ${t}({ text: "hi!", style }) instead`),
    e = {
        text: e,
        style: s[1]
    }),
    e
}
let $t = null
  , kt = null;
function Au(s, t) {
    $t || ($t = O.get().createCanvas(256, 128),
    kt = $t.getContext("2d", {
        willReadFrequently: !0
    }),
    kt.globalCompositeOperation = "copy",
    kt.globalAlpha = 1),
    ($t.width < s || $t.height < t) && ($t.width = ce(s),
    $t.height = ce(t))
}
function zr(s, t, e) {
    for (let i = 0, r = 4 * e * t; i < t; ++i,
    r += 4)
        if (s[r + 3] !== 0)
            return !1;
    return !0
}
function Wr(s, t, e, i, r) {
    const n = 4 * t;
    for (let a = i, o = i * n + 4 * e; a <= r; ++a,
    o += n)
        if (s[o + 3] !== 0)
            return !1;
    return !0
}
function vu(...s) {
    let t = s[0];
    t.canvas || (t = {
        canvas: s[0],
        resolution: s[1]
    });
    const {canvas: e} = t
      , i = Math.min(t.resolution ?? 1, 1)
      , r = t.width ?? e.width
      , n = t.height ?? e.height;
    let a = t.output;
    if (Au(r, n),
    !kt)
        throw new TypeError("Failed to get canvas 2D context");
    kt.drawImage(e, 0, 0, r, n, 0, 0, r * i, n * i);
    const h = kt.getImageData(0, 0, r, n).data;
    let l = 0
      , c = 0
      , u = r - 1
      , d = n - 1;
    for (; c < n && zr(h, r, c); )
        ++c;
    if (c === n)
        return Z.EMPTY;
    for (; zr(h, r, d); )
        --d;
    for (; Wr(h, r, l, c, d); )
        ++l;
    for (; Wr(h, r, u, c, d); )
        --u;
    return ++u,
    ++d,
    kt.globalCompositeOperation = "source-over",
    kt.strokeRect(l, c, u - l, d - c),
    kt.globalCompositeOperation = "copy",
    a ?? (a = new Z),
    a.set(l / i, c / i, (u - l) / i, (d - c) / i),
    a
}
/**
 * tiny-lru
 *
 * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
 * @license BSD-3-Clause
 * @version 11.4.7
 */
class Su {
    constructor(t=0, e=0, i=!1) {
        this.first = null,
        this.items = Object.create(null),
        this.last = null,
        this.max = t,
        this.resetTtl = i,
        this.size = 0,
        this.ttl = e
    }
    clear() {
        return this.first = null,
        this.items = Object.create(null),
        this.last = null,
        this.size = 0,
        this
    }
    delete(t) {
        if (this.has(t)) {
            const e = this.items[t];
            delete this.items[t],
            this.size--,
            e.prev !== null && (e.prev.next = e.next),
            e.next !== null && (e.next.prev = e.prev),
            this.first === e && (this.first = e.next),
            this.last === e && (this.last = e.prev)
        }
        return this
    }
    entries(t=this.keys()) {
        const e = new Array(t.length);
        for (let i = 0; i < t.length; i++) {
            const r = t[i];
            e[i] = [r, this.get(r)]
        }
        return e
    }
    evict(t=!1) {
        if (t || this.size > 0) {
            const e = this.first;
            delete this.items[e.key],
            --this.size === 0 ? (this.first = null,
            this.last = null) : (this.first = e.next,
            this.first.prev = null)
        }
        return this
    }
    expiresAt(t) {
        let e;
        return this.has(t) && (e = this.items[t].expiry),
        e
    }
    get(t) {
        const e = this.items[t];
        if (e !== void 0) {
            if (this.ttl > 0 && e.expiry <= Date.now()) {
                this.delete(t);
                return
            }
            return this.moveToEnd(e),
            e.value
        }
    }
    has(t) {
        return t in this.items
    }
    moveToEnd(t) {
        this.last !== t && (t.prev !== null && (t.prev.next = t.next),
        t.next !== null && (t.next.prev = t.prev),
        this.first === t && (this.first = t.next),
        t.prev = this.last,
        t.next = null,
        this.last !== null && (this.last.next = t),
        this.last = t,
        this.first === null && (this.first = t))
    }
    keys() {
        const t = new Array(this.size);
        let e = this.first
          , i = 0;
        for (; e !== null; )
            t[i++] = e.key,
            e = e.next;
        return t
    }
    setWithEvicted(t, e, i=this.resetTtl) {
        let r = null;
        if (this.has(t))
            this.set(t, e, !0, i);
        else {
            this.max > 0 && this.size === this.max && (r = {
                ...this.first
            },
            this.evict(!0));
            let n = this.items[t] = {
                expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
                key: t,
                prev: this.last,
                next: null,
                value: e
            };
            ++this.size === 1 ? this.first = n : this.last.next = n,
            this.last = n
        }
        return r
    }
    set(t, e, i=!1, r=this.resetTtl) {
        let n = this.items[t];
        return i || n !== void 0 ? (n.value = e,
        i === !1 && r && (n.expiry = this.ttl > 0 ? Date.now() + this.ttl : this.ttl),
        this.moveToEnd(n)) : (this.max > 0 && this.size === this.max && this.evict(!0),
        n = this.items[t] = {
            expiry: this.ttl > 0 ? Date.now() + this.ttl : this.ttl,
            key: t,
            prev: this.last,
            next: null,
            value: e
        },
        ++this.size === 1 ? this.first = n : this.last.next = n,
        this.last = n),
        this
    }
    values(t=this.keys()) {
        const e = new Array(t.length);
        for (let i = 0; i < t.length; i++)
            e[i] = this.get(t[i]);
        return e
    }
}
function Tu(s=1e3, t=0, e=!1) {
    if (isNaN(s) || s < 0)
        throw new TypeError("Invalid max value");
    if (isNaN(t) || t < 0)
        throw new TypeError("Invalid ttl value");
    if (typeof e != "boolean")
        throw new TypeError("Invalid resetTtl value");
    return new Su(s,t,e)
}
function ba(s) {
    return !!s.tagStyles && Object.keys(s.tagStyles).length > 0
}
function wa(s) {
    return s.includes("<")
}
function Cu(s, t) {
    return s.clone().assign(t)
}
function Pu(s, t) {
    const e = []
      , i = t.tagStyles;
    if (!ba(t) || !wa(s))
        return e.push({
            text: s,
            style: t
        }),
        e;
    const r = [t]
      , n = [];
    let a = ""
      , o = 0;
    for (; o < s.length; ) {
        const h = s[o];
        if (h === "<") {
            const l = s.indexOf(">", o);
            if (l === -1) {
                a += h,
                o++;
                continue
            }
            const c = s.indexOf("<", o + 1);
            if (c !== -1 && c < l) {
                a += h,
                o++;
                continue
            }
            const u = s.slice(o + 1, l);
            if (u.startsWith("/")) {
                const d = u.slice(1).trim();
                if (n.length > 0 && n[n.length - 1] === d) {
                    a.length > 0 && (e.push({
                        text: a,
                        style: r[r.length - 1]
                    }),
                    a = ""),
                    r.pop(),
                    n.pop(),
                    o = l + 1;
                    continue
                } else {
                    a += s.slice(o, l + 1),
                    o = l + 1;
                    continue
                }
            } else {
                const d = u.trim();
                if (i[d]) {
                    a.length > 0 && (e.push({
                        text: a,
                        style: r[r.length - 1]
                    }),
                    a = "");
                    const f = r[r.length - 1]
                      , p = Cu(f, i[d]);
                    r.push(p),
                    n.push(d),
                    o = l + 1;
                    continue
                } else {
                    a += s.slice(o, l + 1),
                    o = l + 1;
                    continue
                }
            }
        } else
            a += h,
            o++
    }
    return a.length > 0 && e.push({
        text: a,
        style: r[r.length - 1]
    }),
    e
}
const Mu = [10, 13]
  , ku = new Set(Mu)
  , Eu = [9, 32, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8200, 8201, 8202, 8287, 12288]
  , Iu = new Set(Eu)
  , Ru = [9, 32]
  , Bu = new Set(Ru)
  , Fu = [45, 8208, 8211, 8212, 173]
  , Lu = new Set(Fu)
  , Gu = /(\r\n|\r|\n)/
  , Du = /(?:\r\n|\r|\n)/;
function cs(s) {
    return typeof s != "string" ? !1 : ku.has(s.charCodeAt(0))
}
function pt(s, t) {
    return typeof s != "string" ? !1 : Iu.has(s.charCodeAt(0))
}
function nd(s) {
    return typeof s != "string" ? !1 : Bu.has(s.charCodeAt(0))
}
function zu(s) {
    return typeof s != "string" ? !1 : Lu.has(s.charCodeAt(0))
}
function Aa(s) {
    return s === "normal" || s === "pre-line"
}
function va(s) {
    return s === "normal"
}
function Mt(s) {
    if (typeof s != "string")
        return "";
    let t = s.length - 1;
    for (; t >= 0 && pt(s[t]); )
        t--;
    return t < s.length - 1 ? s.slice(0, t + 1) : s
}
function Sa(s) {
    const t = []
      , e = [];
    if (typeof s != "string")
        return t;
    for (let i = 0; i < s.length; i++) {
        const r = s[i]
          , n = s[i + 1];
        if (pt(r) || cs(r)) {
            e.length > 0 && (t.push(e.join("")),
            e.length = 0),
            r === "\r" && n === `
` ? (t.push(`\r
`),
            i++) : t.push(r);
            continue
        }
        e.push(r),
        zu(r) && n && !pt(n) && !cs(n) && (t.push(e.join("")),
        e.length = 0)
    }
    return e.length > 0 && t.push(e.join("")),
    t
}
function Ta(s, t, e, i) {
    const r = e(s)
      , n = [];
    for (let a = 0; a < r.length; a++) {
        let o = r[a]
          , h = o
          , l = 1;
        for (; r[a + l]; ) {
            const c = r[a + l];
            if (!i(h, c, s, a, t))
                o += c,
                h = c,
                l++;
            else
                break
        }
        a += l - 1,
        n.push(o)
    }
    return n
}
const Wu = /\r\n|\r|\n/g;
function Ou(s, t, e, i, r, n, a, o, h) {
    var F, rt;
    const l = Pu(s, t);
    if (va(t.whiteSpace))
        for (let P = 0; P < l.length; P++) {
            const E = l[P];
            l[P] = {
                text: E.text.replace(Wu, " "),
                style: E.style
            }
        }
    const u = [];
    let d = [];
    for (const P of l) {
        const E = P.text.split(Gu);
        for (let N = 0; N < E.length; N++) {
            const B = E[N];
            B === `\r
` || B === "\r" || B === `
` ? (u.push(d),
            d = []) : B.length > 0 && d.push({
                text: B,
                style: P.style
            })
        }
    }
    (d.length > 0 || u.length === 0) && u.push(d);
    const f = e ? Uu(u, t, i, n, o, h) : u
      , p = []
      , m = []
      , g = []
      , x = []
      , y = [];
    let _ = 0;
    const b = t._fontString
      , A = a(b);
    A.fontSize === 0 && (A.fontSize = t.fontSize,
    A.ascent = t.fontSize);
    let w = ""
      , v = !!t.dropShadow
      , M = ((F = t._stroke) == null ? void 0 : F.width) || 0;
    for (const P of f) {
        let E = 0
          , N = A.ascent
          , B = A.descent
          , z = "";
        for (const G of P) {
            const Q = G.style._fontString
              , at = a(Q);
            Q !== w && (i.font = Q,
            w = Q);
            const ct = r(G.text, G.style.letterSpacing, i);
            E += ct,
            N = Math.max(N, at.ascent),
            B = Math.max(B, at.descent),
            z += G.text;
            const tt = ((rt = G.style._stroke) == null ? void 0 : rt.width) || 0;
            tt > M && (M = tt),
            !v && G.style.dropShadow && (v = !0)
        }
        P.length === 0 && (N = A.ascent,
        B = A.descent),
        p.push(E),
        m.push(N),
        g.push(B),
        y.push(z);
        const H = t.lineHeight || N + B;
        x.push(H + t.leading),
        _ = Math.max(_, E)
    }
    const T = M
      , S = _ + T + (t.dropShadow ? t.dropShadow.distance : 0);
    let C = 0;
    for (let P = 0; P < x.length; P++)
        C += x[P];
    C = Math.max(C, x[0] + T);
    const k = C + (t.dropShadow ? t.dropShadow.distance : 0)
      , R = t.lineHeight || A.fontSize;
    return {
        width: S,
        height: k,
        lines: y,
        lineWidths: p,
        lineHeight: R + t.leading,
        maxLineWidth: _,
        fontProperties: A,
        runsByLine: f,
        lineAscents: m,
        lineDescents: g,
        lineHeights: x,
        hasDropShadow: v
    }
}
function Uu(s, t, e, i, r, n) {
    var g;
    const {letterSpacing: a, whiteSpace: o, wordWrapWidth: h, breakWords: l} = t
      , c = Aa(o)
      , u = h + a
      , d = {};
    let f = "";
    const p = (x, y) => {
        const _ = `${x}|${y.styleKey}`;
        let b = d[_];
        if (b === void 0) {
            const A = y._fontString;
            A !== f && (e.font = A,
            f = A),
            b = i(x, y.letterSpacing, e) + y.letterSpacing,
            d[_] = b
        }
        return b
    }
      , m = [];
    for (const x of s) {
        const y = Nu(x)
          , _ = m.length
          , b = k => {
            let R = 0
              , F = k;
            do {
                const {token: rt, style: P} = y[F];
                R += p(rt, P),
                F++
            } while (F < y.length && y[F].continuesFromPrevious);
            return R
        }
          , A = k => {
            const R = [];
            let F = k;
            do
                R.push({
                    token: y[F].token,
                    style: y[F].style
                }),
                F++;
            while (F < y.length && y[F].continuesFromPrevious);
            return R
        }
        ;
        let w = []
          , v = 0
          , M = !c
          , T = null;
        const S = () => {
            T && T.text.length > 0 && w.push(T),
            T = null
        }
          , C = () => {
            if (S(),
            w.length > 0) {
                const k = w[w.length - 1];
                k.text = Mt(k.text),
                k.text.length === 0 && w.pop()
            }
            m.push(w),
            w = [],
            v = 0,
            M = !1
        }
        ;
        for (let k = 0; k < y.length; k++) {
            const {token: R, style: F, continuesFromPrevious: rt} = y[k]
              , P = p(R, F);
            if (c) {
                const B = pt(R)
                  , z = (T == null ? void 0 : T.text[T.text.length - 1]) ?? ((g = w[w.length - 1]) == null ? void 0 : g.text.slice(-1)) ?? ""
                  , H = z ? pt(z) : !1;
                if (B && H)
                    continue
            }
            const E = !rt
              , N = E ? b(k) : P;
            if (N > u && E)
                if (v > 0 && C(),
                l) {
                    const B = A(k);
                    for (let z = 0; z < B.length; z++) {
                        const H = B[z].token
                          , G = B[z].style
                          , Q = Ta(H, l, n, r);
                        for (const at of Q) {
                            const ct = p(at, G);
                            ct + v > u && C(),
                            !T || T.style !== G ? (S(),
                            T = {
                                text: at,
                                style: G
                            }) : T.text += at,
                            v += ct
                        }
                    }
                    k += B.length - 1
                } else {
                    const B = A(k);
                    S(),
                    m.push(B.map(z => ({
                        text: z.token,
                        style: z.style
                    }))),
                    M = !1,
                    k += B.length - 1
                }
            else if (N + v > u && E) {
                if (pt(R)) {
                    M = !1;
                    continue
                }
                C(),
                T = {
                    text: R,
                    style: F
                },
                v = P
            } else if (rt && !l)
                !T || T.style !== F ? (S(),
                T = {
                    text: R,
                    style: F
                }) : T.text += R,
                v += P;
            else {
                const B = pt(R);
                if (v === 0 && B && !M)
                    continue;
                !T || T.style !== F ? (S(),
                T = {
                    text: R,
                    style: F
                }) : T.text += R,
                v += P
            }
        }
        if (S(),
        w.length > 0) {
            const k = w[w.length - 1];
            k.text = Mt(k.text),
            k.text.length === 0 && w.pop()
        }
        (w.length > 0 || m.length === _) && m.push(w)
    }
    return m
}
function Nu(s) {
    const t = [];
    let e = !1;
    for (const i of s) {
        const r = Sa(i.text);
        let n = !0;
        for (const a of r) {
            const o = pt(a) || cs(a)
              , h = n && e && !o;
            t.push({
                token: a,
                style: i.style,
                continuesFromPrevious: h
            }),
            e = !o,
            n = !1
        }
    }
    return t
}
const Hu = {
    willReadFrequently: !0
};
function Or(s, t, e, i, r) {
    let n = e[s];
    return typeof n != "number" && (n = r(s, t, i) + t,
    e[s] = n),
    n
}
function $u(s, t, e, i, r, n, a) {
    const o = e.getContext("2d", Hu);
    o.font = t._fontString;
    let h = 0
      , l = "";
    const c = []
      , u = Object.create(null)
      , {letterSpacing: d, whiteSpace: f} = t
      , p = Aa(f)
      , m = va(f);
    let g = !p;
    const x = t.wordWrapWidth + d
      , y = Sa(s);
    for (let b = 0; b < y.length; b++) {
        let A = y[b];
        if (cs(A)) {
            if (!m) {
                c.push(Mt(l)),
                g = !p,
                l = "",
                h = 0;
                continue
            }
            A = " "
        }
        if (p) {
            const v = pt(A)
              , M = pt(l[l.length - 1]);
            if (v && M)
                continue
        }
        const w = Or(A, d, u, o, i);
        if (w > x)
            if (l !== "" && (c.push(Mt(l)),
            l = "",
            h = 0),
            r(A, t.breakWords)) {
                const v = Ta(A, t.breakWords, a, n);
                for (const M of v) {
                    const T = Or(M, d, u, o, i);
                    T + h > x && (c.push(Mt(l)),
                    g = !1,
                    l = "",
                    h = 0),
                    l += M,
                    h += T
                }
            } else
                l.length > 0 && (c.push(Mt(l)),
                l = "",
                h = 0),
                c.push(Mt(A)),
                g = !1,
                l = "",
                h = 0;
        else
            w + h > x && (g = !1,
            c.push(Mt(l)),
            l = "",
            h = 0),
            (l.length > 0 || !pt(A) || g) && (l += A,
            h += w)
    }
    const _ = Mt(l);
    return _.length > 0 && c.push(_),
    c.join(`
`)
}
const Ur = {
    willReadFrequently: !0
}
  , Bt = class L {
    static get experimentalLetterSpacingSupported() {
        let t = L._experimentalLetterSpacingSupported;
        if (t === void 0) {
            const e = O.get().getCanvasRenderingContext2D().prototype;
            t = L._experimentalLetterSpacingSupported = "letterSpacing"in e || "textLetterSpacing"in e
        }
        return t
    }
    constructor(t, e, i, r, n, a, o, h, l, c) {
        this.text = t,
        this.style = e,
        this.width = i,
        this.height = r,
        this.lines = n,
        this.lineWidths = a,
        this.lineHeight = o,
        this.maxLineWidth = h,
        this.fontProperties = l,
        c && (this.runsByLine = c.runsByLine,
        this.lineAscents = c.lineAscents,
        this.lineDescents = c.lineDescents,
        this.lineHeights = c.lineHeights,
        this.hasDropShadow = c.hasDropShadow)
    }
    static measureText(t=" ", e, i=L._canvas, r=e.wordWrap) {
        var b;
        const n = `${t}-${e.styleKey}-wordWrap-${r}`;
        if (L._measurementCache.has(n))
            return L._measurementCache.get(n);
        if (ba(e) && wa(t)) {
            const A = Ou(t, e, r, L._context, L._measureText, L._measureTextAdvance, L.measureFont, L.canBreakChars, L.wordWrapSplit)
              , w = new L(t,e,A.width,A.height,A.lines,A.lineWidths,A.lineHeight,A.maxLineWidth,A.fontProperties,{
                runsByLine: A.runsByLine,
                lineAscents: A.lineAscents,
                lineDescents: A.lineDescents,
                lineHeights: A.lineHeights,
                hasDropShadow: A.hasDropShadow
            });
            return L._measurementCache.set(n, w),
            w
        }
        const o = e._fontString
          , h = L.measureFont(o);
        h.fontSize === 0 && (h.fontSize = e.fontSize,
        h.ascent = e.fontSize,
        h.descent = 0);
        const l = L._context;
        l.font = o;
        const u = (r ? L._wordWrap(t, e, i) : t).split(Du)
          , d = new Array(u.length);
        let f = 0;
        for (let A = 0; A < u.length; A++) {
            const w = L._measureText(u[A], e.letterSpacing, l);
            d[A] = w,
            f = Math.max(f, w)
        }
        const p = ((b = e._stroke) == null ? void 0 : b.width) ?? 0
          , m = e.lineHeight || h.fontSize
          , g = L._adjustWidthForStyle(f, e)
          , x = Math.max(m, h.fontSize + p) + (u.length - 1) * (m + e.leading)
          , y = L._adjustHeightForStyle(x, e)
          , _ = new L(t,e,g,y,u,d,m + e.leading,f,h);
        return L._measurementCache.set(n, _),
        _
    }
    static _adjustWidthForStyle(t, e) {
        var n;
        const i = ((n = e._stroke) == null ? void 0 : n.width) || 0;
        let r = t + i;
        return e.dropShadow && (r += e.dropShadow.distance),
        r
    }
    static _adjustHeightForStyle(t, e) {
        let i = t;
        return e.dropShadow && (i += e.dropShadow.distance),
        i
    }
    static _measureText(t, e, i) {
        const {metricWidth: r, metrics: n, letterSpacingVal: a} = L._measureTextCore(t, e, i)
          , o = -(n.actualBoundingBoxLeft ?? 0);
        let l = (n.actualBoundingBoxRight ?? 0) - o;
        return n.width > 0 && (l += a),
        Math.max(r, l)
    }
    static _measureTextAdvance(t, e, i) {
        return L._measureTextCore(t, e, i).metricWidth
    }
    static _measureTextCore(t, e, i) {
        let r = !1;
        L.experimentalLetterSpacingSupported && (L.experimentalLetterSpacing ? (i.letterSpacing = `${e}px`,
        i.textLetterSpacing = `${e}px`,
        r = !0) : (i.letterSpacing = "0px",
        i.textLetterSpacing = "0px"));
        const n = i.measureText(t);
        let a = n.width
          , o = 0;
        return a > 0 && (r ? o = -e : o = (L.graphemeSegmenter(t).length - 1) * e,
        a += o),
        {
            metricWidth: a,
            metrics: n,
            letterSpacingVal: o
        }
    }
    static _wordWrap(t, e, i=L._canvas) {
        return $u(t, e, i, L._measureTextAdvance, L.canBreakWords, L.canBreakChars, L.wordWrapSplit)
    }
    static isBreakingSpace(t, e) {
        return pt(t)
    }
    static canBreakWords(t, e) {
        return e
    }
    static canBreakChars(t, e, i, r, n) {
        return !0
    }
    static wordWrapSplit(t) {
        return L.graphemeSegmenter(t)
    }
    static measureFont(t) {
        if (L._fonts[t])
            return L._fonts[t];
        const e = L._context;
        e.font = t;
        const i = e.measureText(L.METRICS_STRING + L.BASELINE_SYMBOL)
          , r = i.actualBoundingBoxAscent ?? 0
          , n = i.actualBoundingBoxDescent ?? 0
          , a = {
            ascent: r,
            descent: n,
            fontSize: r + n
        };
        return L._fonts[t] = a,
        a
    }
    static clearMetrics(t="") {
        t ? delete L._fonts[t] : L._fonts = {}
    }
    static get _canvas() {
        if (!L.__canvas) {
            let t;
            try {
                const e = new OffscreenCanvas(0,0)
                  , i = e.getContext("2d", Ur);
                if (i != null && i.measureText)
                    return L.__canvas = e,
                    e;
                t = O.get().createCanvas()
            } catch {
                t = O.get().createCanvas()
            }
            t.width = t.height = 10,
            L.__canvas = t
        }
        return L.__canvas
    }
    static get _context() {
        return L.__context || (L.__context = L._canvas.getContext("2d", Ur)),
        L.__context
    }
}
;
Bt.METRICS_STRING = "|ÉqÅ";
Bt.BASELINE_SYMBOL = "M";
Bt.BASELINE_MULTIPLIER = 1.4;
Bt.HEIGHT_MULTIPLIER = 2;
Bt.graphemeSegmenter = ( () => {
    if (typeof (Intl == null ? void 0 : Intl.Segmenter) == "function") {
        const s = new Intl.Segmenter;
        return t => {
            const e = s.segment(t)
              , i = [];
            let r = 0;
            for (const n of e)
                i[r++] = n.segment;
            return i
        }
    }
    return s => [...s]
}
)();
Bt.experimentalLetterSpacing = !1;
Bt._fonts = {};
Bt._measurementCache = Tu(1e3);
let Ft = Bt;
const Vu = ["serif", "sans-serif", "monospace", "cursive", "fantasy", "system-ui"];
function ui(s) {
    const t = typeof s.fontSize == "number" ? `${s.fontSize}px` : s.fontSize;
    let e = s.fontFamily;
    Array.isArray(s.fontFamily) || (e = s.fontFamily.split(","));
    for (let i = e.length - 1; i >= 0; i--) {
        let r = e[i].trim();
        !/([\"\'])[^\'\"]+\1/.test(r) && !Vu.includes(r) && (r = `"${r}"`),
        e[i] = r
    }
    return `${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${t} ${e.join(",")}`
}
const Nr = 1e5;
function is(s, t, e, i=0, r=0, n=0) {
    if (s.texture === W.WHITE && !s.fill)
        return J.shared.setValue(s.color).setAlpha(s.alpha ?? 1).toHexa();
    if (s.fill) {
        if (s.fill instanceof xs) {
            const a = s.fill
              , o = t.createPattern(a.texture.source.resource, "repeat")
              , h = a.transform.copyTo(D.shared);
            return h.scale(a.texture.source.pixelWidth, a.texture.source.pixelHeight),
            o.setTransform(h),
            o
        } else if (s.fill instanceof Rt) {
            const a = s.fill
              , o = a.type === "linear"
              , h = a.textureSpace === "local";
            let l = 1
              , c = 1;
            h && e && (l = e.width + i,
            c = e.height + i);
            let u, d = !1;
            if (o) {
                const {start: f, end: p} = a;
                u = t.createLinearGradient(f.x * l + r, f.y * c + n, p.x * l + r, p.y * c + n),
                d = Math.abs(p.x - f.x) < Math.abs((p.y - f.y) * .1)
            } else {
                const {center: f, innerRadius: p, outerCenter: m, outerRadius: g} = a;
                u = t.createRadialGradient(f.x * l + r, f.y * c + n, p * l, m.x * l + r, m.y * c + n, g * l)
            }
            if (d && h && e) {
                const f = e.lineHeight / c;
                for (let p = 0; p < e.lines.length; p++) {
                    const m = (p * e.lineHeight + i / 2) / c;
                    a.colorStops.forEach(g => {
                        let x = m + g.offset * f;
                        x = Math.max(0, Math.min(1, x)),
                        u.addColorStop(Math.floor(x * Nr) / Nr, J.shared.setValue(g.color).toHex())
                    }
                    )
                }
            } else
                a.colorStops.forEach(f => {
                    u.addColorStop(f.offset, J.shared.setValue(f.color).toHex())
                }
                );
            return u
        }
    } else {
        const a = t.createPattern(s.texture.source.resource, "repeat")
          , o = s.matrix.copyTo(D.shared);
        return o.scale(s.texture.source.pixelWidth, s.texture.source.pixelHeight),
        a.setTransform(o),
        a
    }
    return $("FillStyle not recognised", s),
    "red"
}
const Hr = new Z;
function re(s) {
    let t = 0;
    for (let e = 0; e < s.length; e++)
        s.charCodeAt(e) === 32 && t++;
    return t
}
class ju {
    getCanvasAndContext(t) {
        const {text: e, style: i, resolution: r=1} = t
          , n = i._getFinalPadding()
          , a = Ft.measureText(e || " ", i)
          , o = Math.ceil(Math.ceil(Math.max(1, a.width) + n * 2) * r)
          , h = Math.ceil(Math.ceil(Math.max(1, a.height) + n * 2) * r)
          , l = ci.getOptimalCanvasAndContext(o, h);
        this._renderTextToCanvas(i, n, r, l, a);
        const c = i.trim ? vu({
            canvas: l.canvas,
            width: o,
            height: h,
            resolution: 1,
            output: Hr
        }) : Hr.set(0, 0, o, h);
        return {
            canvasAndContext: l,
            frame: c
        }
    }
    returnCanvasAndContext(t) {
        ci.returnCanvasAndContext(t)
    }
    _renderTextToCanvas(t, e, i, r, n) {
        var A, w, v;
        if (n.runsByLine && n.runsByLine.length > 0) {
            this._renderTaggedTextToCanvas(n, t, e, i, r);
            return
        }
        const {canvas: a, context: o} = r
          , h = ui(t)
          , l = n.lines
          , c = n.lineHeight
          , u = n.lineWidths
          , d = n.maxLineWidth
          , f = n.fontProperties
          , p = a.height;
        if (o.resetTransform(),
        o.scale(i, i),
        o.textBaseline = t.textBaseline,
        (A = t._stroke) != null && A.width) {
            const M = t._stroke;
            o.lineWidth = M.width,
            o.miterLimit = M.miterLimit,
            o.lineJoin = M.join,
            o.lineCap = M.cap
        }
        o.font = h;
        let m, g;
        const x = t.dropShadow ? 2 : 1
          , _ = (((w = t._stroke) == null ? void 0 : w.width) ?? 0) / 2;
        let b = (c - f.fontSize) / 2;
        c - f.fontSize < 0 && (b = 0);
        for (let M = 0; M < x; ++M) {
            const T = t.dropShadow && M === 0
              , S = T ? Math.ceil(Math.max(1, p) + e * 2) : 0
              , C = S * i;
            if (T)
                this._setupDropShadow(o, t, i, C);
            else {
                const k = t._gradientBounds
                  , R = t._gradientOffset;
                if (k) {
                    const F = {
                        width: k.width,
                        height: k.height,
                        lineHeight: k.height,
                        lines: n.lines
                    };
                    this._setFillAndStrokeStyles(o, t, F, e, _, (R == null ? void 0 : R.x) ?? 0, (R == null ? void 0 : R.y) ?? 0)
                } else
                    R ? this._setFillAndStrokeStyles(o, t, n, e, _, R.x, R.y) : this._setFillAndStrokeStyles(o, t, n, e, _);
                o.shadowColor = "rgba(0,0,0,0)"
            }
            for (let k = 0; k < l.length; k++) {
                m = _,
                g = _ + k * c + f.ascent + b,
                m += this._getAlignmentOffset(u[k], d, t.align);
                let R = 0;
                if (t.align === "justify" && t.wordWrap && k < l.length - 1) {
                    const F = re(l[k]);
                    F > 0 && (R = (d - u[k]) / F)
                }
                (v = t._stroke) != null && v.width && this._drawLetterSpacing(l[k], t, r, m + e, g + e - S, !0, R),
                t._fill !== void 0 && this._drawLetterSpacing(l[k], t, r, m + e, g + e - S, !1, R)
            }
        }
    }
    _renderTaggedTextToCanvas(t, e, i, r, n) {
        var _, b, A;
        const {canvas: a, context: o} = n
          , {runsByLine: h, lineWidths: l, maxLineWidth: c, lineAscents: u, lineHeights: d, hasDropShadow: f} = t
          , p = a.height;
        o.resetTransform(),
        o.scale(r, r),
        o.textBaseline = e.textBaseline;
        const m = f ? 2 : 1;
        let g = ((_ = e._stroke) == null ? void 0 : _.width) ?? 0;
        for (const w of h)
            for (const v of w) {
                const M = ((b = v.style._stroke) == null ? void 0 : b.width) ?? 0;
                M > g && (g = M)
            }
        const x = g / 2
          , y = [];
        for (let w = 0; w < h.length; w++) {
            const v = h[w]
              , M = [];
            for (const T of v) {
                const S = ui(T.style);
                o.font = S,
                M.push({
                    width: Ft._measureText(T.text, T.style.letterSpacing, o),
                    font: S
                })
            }
            y.push(M)
        }
        for (let w = 0; w < m; ++w) {
            const v = f && w === 0
              , M = v ? Math.ceil(Math.max(1, p) + i * 2) : 0
              , T = M * r;
            v || (o.shadowColor = "rgba(0,0,0,0)");
            let S = x;
            for (let C = 0; C < h.length; C++) {
                const k = h[C]
                  , R = l[C]
                  , F = u[C]
                  , rt = d[C]
                  , P = y[C];
                let E = x;
                E += this._getAlignmentOffset(R, c, e.align);
                let N = 0;
                if (e.align === "justify" && e.wordWrap && C < h.length - 1) {
                    let H = 0;
                    for (const G of k)
                        H += re(G.text);
                    H > 0 && (N = (c - R) / H)
                }
                const B = S + F;
                let z = E + i;
                for (let H = 0; H < k.length; H++) {
                    const G = k[H]
                      , {width: Q, font: at} = P[H];
                    if (o.font = at,
                    o.textBaseline = G.style.textBaseline,
                    (A = G.style._stroke) != null && A.width) {
                        const tt = G.style._stroke;
                        if (o.lineWidth = tt.width,
                        o.miterLimit = tt.miterLimit,
                        o.lineJoin = tt.join,
                        o.lineCap = tt.cap,
                        v)
                            if (G.style.dropShadow)
                                this._setupDropShadow(o, G.style, r, T);
                            else {
                                const St = re(G.text);
                                z += Q + St * N;
                                continue
                            }
                        else {
                            const St = Ft.measureFont(at)
                              , zt = G.style.lineHeight || St.fontSize
                              , te = {
                                width: Q,
                                height: zt,
                                lineHeight: zt,
                                lines: [G.text]
                            };
                            o.strokeStyle = is(tt, o, te, i * 2, z - i, S)
                        }
                        this._drawLetterSpacing(G.text, G.style, n, z, B + i - M, !0, N)
                    }
                    const ct = re(G.text);
                    z += Q + ct * N
                }
                z = E + i;
                for (let H = 0; H < k.length; H++) {
                    const G = k[H]
                      , {width: Q, font: at} = P[H];
                    if (o.font = at,
                    o.textBaseline = G.style.textBaseline,
                    G.style._fill !== void 0) {
                        if (v)
                            if (G.style.dropShadow)
                                this._setupDropShadow(o, G.style, r, T);
                            else {
                                const tt = re(G.text);
                                z += Q + tt * N;
                                continue
                            }
                        else {
                            const tt = Ft.measureFont(at)
                              , St = G.style.lineHeight || tt.fontSize
                              , zt = {
                                width: Q,
                                height: St,
                                lineHeight: St,
                                lines: [G.text]
                            };
                            o.fillStyle = is(G.style._fill, o, zt, i * 2, z - i, S)
                        }
                        this._drawLetterSpacing(G.text, G.style, n, z, B + i - M, !1, N)
                    }
                    const ct = re(G.text);
                    z += Q + ct * N
                }
                S += rt
            }
        }
    }
    _setFillAndStrokeStyles(t, e, i, r, n, a=0, o=0) {
        var h;
        if (t.fillStyle = e._fill ? is(e._fill, t, i, r * 2, a, o) : null,
        (h = e._stroke) != null && h.width) {
            const l = n + r * 2;
            t.strokeStyle = is(e._stroke, t, i, l, a, o)
        }
    }
    _setupDropShadow(t, e, i, r) {
        t.fillStyle = "black",
        t.strokeStyle = "black";
        const n = e.dropShadow
          , a = n.color
          , o = n.alpha;
        t.shadowColor = J.shared.setValue(a).setAlpha(o).toRgbaString();
        const h = n.blur * i
          , l = n.distance * i;
        t.shadowBlur = h,
        t.shadowOffsetX = Math.cos(n.angle) * l,
        t.shadowOffsetY = Math.sin(n.angle) * l + r
    }
    _getAlignmentOffset(t, e, i) {
        return i === "right" ? e - t : i === "center" ? (e - t) / 2 : 0
    }
    _drawLetterSpacing(t, e, i, r, n, a=!1, o=0) {
        const {context: h} = i
          , l = e.letterSpacing;
        let c = !1;
        if (Ft.experimentalLetterSpacingSupported && (Ft.experimentalLetterSpacing ? (h.letterSpacing = `${l}px`,
        h.textLetterSpacing = `${l}px`,
        c = !0) : (h.letterSpacing = "0px",
        h.textLetterSpacing = "0px")),
        (l === 0 || c) && o === 0) {
            a ? h.strokeText(t, r, n) : h.fillText(t, r, n);
            return
        }
        if (o !== 0 && (l === 0 || c)) {
            const m = t.split(" ");
            let g = r;
            const x = h.measureText(" ").width;
            for (let y = 0; y < m.length; y++)
                a ? h.strokeText(m[y], g, n) : h.fillText(m[y], g, n),
                g += h.measureText(m[y]).width + x + o;
            return
        }
        let u = r;
        const d = Ft.graphemeSegmenter(t);
        let f = h.measureText(t).width
          , p = 0;
        for (let m = 0; m < d.length; ++m) {
            const g = d[m];
            a ? h.strokeText(g, u, n) : h.fillText(g, u, n);
            let x = "";
            for (let y = m + 1; y < d.length; ++y)
                x += d[y];
            p = h.measureText(x).width,
            u += f - p + l,
            g === " " && (u += o),
            f = p
        }
    }
}
const ae = new ju
  , Ci = class Zt extends vt {
    constructor(t={}) {
        super(),
        this.uid = q("textStyle"),
        this._tick = 0,
        this._cachedFontString = null,
        Yu(t),
        t instanceof Zt && (t = t._toObject());
        const r = {
            ...Zt.defaultTextStyle,
            ...t
        };
        for (const n in r) {
            const a = n;
            this[a] = r[n]
        }
        this._tagStyles = t.tagStyles ?? void 0,
        this.update(),
        this._tick = 0
    }
    get align() {
        return this._align
    }
    set align(t) {
        this._align !== t && (this._align = t,
        this.update())
    }
    get breakWords() {
        return this._breakWords
    }
    set breakWords(t) {
        this._breakWords !== t && (this._breakWords = t,
        this.update())
    }
    get dropShadow() {
        return this._dropShadow
    }
    set dropShadow(t) {
        this._dropShadow !== t && (t !== null && typeof t == "object" ? this._dropShadow = this._createProxy({
            ...Zt.defaultDropShadow,
            ...t
        }) : this._dropShadow = t ? this._createProxy({
            ...Zt.defaultDropShadow
        }) : null,
        this.update())
    }
    get fontFamily() {
        return this._fontFamily
    }
    set fontFamily(t) {
        this._fontFamily !== t && (this._fontFamily = t,
        this.update())
    }
    get fontSize() {
        return this._fontSize
    }
    set fontSize(t) {
        this._fontSize !== t && (typeof t == "string" ? this._fontSize = parseInt(t, 10) : this._fontSize = t,
        this.update())
    }
    get fontStyle() {
        return this._fontStyle
    }
    set fontStyle(t) {
        this._fontStyle !== t && (this._fontStyle = t.toLowerCase(),
        this.update())
    }
    get fontVariant() {
        return this._fontVariant
    }
    set fontVariant(t) {
        this._fontVariant !== t && (this._fontVariant = t,
        this.update())
    }
    get fontWeight() {
        return this._fontWeight
    }
    set fontWeight(t) {
        this._fontWeight !== t && (this._fontWeight = t,
        this.update())
    }
    get leading() {
        return this._leading
    }
    set leading(t) {
        this._leading !== t && (this._leading = t,
        this.update())
    }
    get letterSpacing() {
        return this._letterSpacing
    }
    set letterSpacing(t) {
        this._letterSpacing !== t && (this._letterSpacing = t,
        this.update())
    }
    get lineHeight() {
        return this._lineHeight
    }
    set lineHeight(t) {
        this._lineHeight !== t && (this._lineHeight = t,
        this.update())
    }
    get padding() {
        return this._padding
    }
    set padding(t) {
        this._padding !== t && (this._padding = t,
        this.update())
    }
    get filters() {
        return this._filters
    }
    set filters(t) {
        this._filters !== t && (this._filters = Object.freeze(t),
        this.update())
    }
    get trim() {
        return this._trim
    }
    set trim(t) {
        this._trim !== t && (this._trim = t,
        this.update())
    }
    get textBaseline() {
        return this._textBaseline
    }
    set textBaseline(t) {
        this._textBaseline !== t && (this._textBaseline = t,
        this.update())
    }
    get whiteSpace() {
        return this._whiteSpace
    }
    set whiteSpace(t) {
        this._whiteSpace !== t && (this._whiteSpace = t,
        this.update())
    }
    get wordWrap() {
        return this._wordWrap
    }
    set wordWrap(t) {
        this._wordWrap !== t && (this._wordWrap = t,
        this.update())
    }
    get wordWrapWidth() {
        return this._wordWrapWidth
    }
    set wordWrapWidth(t) {
        this._wordWrapWidth !== t && (this._wordWrapWidth = t,
        this.update())
    }
    get fill() {
        return this._originalFill
    }
    set fill(t) {
        t !== this._originalFill && (this._originalFill = t,
        this._isFillStyle(t) && (this._originalFill = this._createProxy({
            ...Kt.defaultFillStyle,
            ...t
        }, () => {
            this._fill = Qt({
                ...this._originalFill
            }, Kt.defaultFillStyle)
        }
        )),
        this._fill = Qt(t === 0 ? "black" : t, Kt.defaultFillStyle),
        this.update())
    }
    get stroke() {
        return this._originalStroke
    }
    set stroke(t) {
        t !== this._originalStroke && (this._originalStroke = t,
        this._isFillStyle(t) && (this._originalStroke = this._createProxy({
            ...Kt.defaultStrokeStyle,
            ...t
        }, () => {
            this._stroke = ls({
                ...this._originalStroke
            }, Kt.defaultStrokeStyle)
        }
        )),
        this._stroke = ls(t, Kt.defaultStrokeStyle),
        this.update())
    }
    get tagStyles() {
        return this._tagStyles
    }
    set tagStyles(t) {
        this._tagStyles !== t && (this._tagStyles = t ?? void 0,
        this.update())
    }
    update() {
        this._tick++,
        this._cachedFontString = null,
        this.emit("update", this)
    }
    reset() {
        const t = Zt.defaultTextStyle;
        for (const e in t)
            this[e] = t[e]
    }
    assign(t) {
        for (const e in t) {
            const i = e;
            this[i] = t[e]
        }
        return this
    }
    get styleKey() {
        return `${this.uid}-${this._tick}`
    }
    get _fontString() {
        return this._cachedFontString === null && (this._cachedFontString = ui(this)),
        this._cachedFontString
    }
    _toObject() {
        return {
            align: this.align,
            breakWords: this.breakWords,
            dropShadow: this._dropShadow ? {
                ...this._dropShadow
            } : null,
            fill: this._fill ? {
                ...this._fill
            } : void 0,
            fontFamily: this.fontFamily,
            fontSize: this.fontSize,
            fontStyle: this.fontStyle,
            fontVariant: this.fontVariant,
            fontWeight: this.fontWeight,
            leading: this.leading,
            letterSpacing: this.letterSpacing,
            lineHeight: this.lineHeight,
            padding: this.padding,
            stroke: this._stroke ? {
                ...this._stroke
            } : void 0,
            textBaseline: this.textBaseline,
            trim: this.trim,
            whiteSpace: this.whiteSpace,
            wordWrap: this.wordWrap,
            wordWrapWidth: this.wordWrapWidth,
            filters: this._filters ? [...this._filters] : void 0,
            tagStyles: this._tagStyles ? {
                ...this._tagStyles
            } : void 0
        }
    }
    clone() {
        return new Zt(this._toObject())
    }
    _getFinalPadding() {
        let t = 0;
        if (this._filters)
            for (let e = 0; e < this._filters.length; e++)
                t += this._filters[e].padding;
        return Math.max(this._padding, t)
    }
    destroy(t=!1) {
        var i, r, n, a;
        if (this.removeAllListeners(),
        typeof t == "boolean" ? t : t == null ? void 0 : t.texture) {
            const o = typeof t == "boolean" ? t : t == null ? void 0 : t.textureSource;
            (i = this._fill) != null && i.texture && this._fill.texture.destroy(o),
            (r = this._originalFill) != null && r.texture && this._originalFill.texture.destroy(o),
            (n = this._stroke) != null && n.texture && this._stroke.texture.destroy(o),
            (a = this._originalStroke) != null && a.texture && this._originalStroke.texture.destroy(o)
        }
        this._fill = null,
        this._stroke = null,
        this.dropShadow = null,
        this._originalStroke = null,
        this._originalFill = null
    }
    _createProxy(t, e) {
        return new Proxy(t,{
            set: (i, r, n) => (i[r] === n || (i[r] = n,
            e == null || e(r, n),
            this.update()),
            !0)
        })
    }
    _isFillStyle(t) {
        return (t ?? null) !== null && !(J.isColorLike(t) || t instanceof Rt || t instanceof xs)
    }
}
;
Ci.defaultDropShadow = {
    alpha: 1,
    angle: Math.PI / 6,
    blur: 0,
    color: "black",
    distance: 5
};
Ci.defaultTextStyle = {
    align: "left",
    breakWords: !1,
    dropShadow: null,
    fill: "black",
    fontFamily: "Arial",
    fontSize: 26,
    fontStyle: "normal",
    fontVariant: "normal",
    fontWeight: "normal",
    leading: 0,
    letterSpacing: 0,
    lineHeight: 0,
    padding: 0,
    stroke: null,
    textBaseline: "alphabetic",
    trim: !1,
    whiteSpace: "pre",
    wordWrap: !1,
    wordWrapWidth: 100
};
let us = Ci;
function Yu(s) {
    const t = s;
    if (typeof t.dropShadow == "boolean" && t.dropShadow) {
        const e = us.defaultDropShadow;
        s.dropShadow = {
            alpha: t.dropShadowAlpha ?? e.alpha,
            angle: t.dropShadowAngle ?? e.angle,
            blur: t.dropShadowBlur ?? e.blur,
            color: t.dropShadowColor ?? e.color,
            distance: t.dropShadowDistance ?? e.distance
        }
    }
    if (t.strokeThickness !== void 0) {
        V(dt, "strokeThickness is now a part of stroke");
        const e = t.stroke;
        let i = {};
        if (J.isColorLike(e))
            i.color = e;
        else if (e instanceof Rt || e instanceof xs)
            i.fill = e;
        else if (Object.hasOwnProperty.call(e, "color") || Object.hasOwnProperty.call(e, "fill"))
            i = e;
        else
            throw new Error("Invalid stroke value.");
        s.stroke = {
            ...i,
            width: t.strokeThickness
        }
    }
    if (Array.isArray(t.fillGradientStops)) {
        if (V(dt, "gradient fill is now a fill pattern: `new FillGradient(...)`"),
        !Array.isArray(t.fill) || t.fill.length === 0)
            throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");
        t.fill.length !== t.fillGradientStops.length && $("The number of fill colors must match the number of fill gradient stops.");
        const e = new Rt({
            start: {
                x: 0,
                y: 0
            },
            end: {
                x: 0,
                y: 1
            },
            textureSpace: "local"
        })
          , i = t.fillGradientStops.slice()
          , r = t.fill.map(n => J.shared.setValue(n).toNumber());
        i.forEach( (n, a) => {
            e.addColorStop(n, r[a])
        }
        ),
        s.fill = {
            fill: e
        }
    }
}
function Xu(s, t) {
    const {texture: e, bounds: i} = s
      , r = t._style._getFinalPadding();
    an(i, t._anchor, e);
    const n = t._anchor._x * r * 2
      , a = t._anchor._y * r * 2;
    i.minX -= r - n,
    i.minY -= r - a,
    i.maxX -= r - n,
    i.maxY -= r - a
}
class qu {
    constructor() {
        this.batcherName = "default",
        this.topology = "triangle-list",
        this.attributeSize = 4,
        this.indexSize = 6,
        this.packAsQuad = !0,
        this.roundPixels = 0,
        this._attributeStart = 0,
        this._batcher = null,
        this._batch = null
    }
    get blendMode() {
        return this.renderable.groupBlendMode
    }
    get color() {
        return this.renderable.groupColorAlpha
    }
    reset() {
        this.renderable = null,
        this.texture = null,
        this._batcher = null,
        this._batch = null,
        this.bounds = null
    }
    destroy() {
        this.reset()
    }
}
class Ku extends qu {
}
class Ca {
    constructor(t) {
        this._renderer = t,
        t.runners.resolutionChange.add(this),
        this._managedTexts = new oa({
            renderer: t,
            type: "renderable",
            onUnload: this.onTextUnload.bind(this),
            name: "canvasText"
        })
    }
    resolutionChange() {
        for (const t in this._managedTexts.items) {
            const e = this._managedTexts.items[t];
            e != null && e._autoResolution && e.onViewUpdate()
        }
    }
    validateRenderable(t) {
        const e = this._getGpuText(t)
          , i = t.styleKey;
        return e.currentKey !== i ? !0 : t._didTextUpdate
    }
    addRenderable(t, e) {
        const i = this._getGpuText(t);
        if (t._didTextUpdate) {
            const r = t._autoResolution ? this._renderer.resolution : t.resolution;
            (i.currentKey !== t.styleKey || t._resolution !== r) && this._updateGpuText(t),
            t._didTextUpdate = !1,
            Xu(i, t)
        }
        this._renderer.renderPipes.batch.addToBatch(i, e)
    }
    updateRenderable(t) {
        const e = this._getGpuText(t);
        e._batcher.updateElement(e)
    }
    _updateGpuText(t) {
        const e = this._getGpuText(t);
        e.texture && this._renderer.canvasText.decreaseReferenceCount(e.currentKey),
        t._resolution = t._autoResolution ? this._renderer.resolution : t.resolution,
        e.texture = this._renderer.canvasText.getManagedTexture(t),
        e.currentKey = t.styleKey
    }
    _getGpuText(t) {
        return t._gpuData[this._renderer.uid] || this.initGpuText(t)
    }
    initGpuText(t) {
        const e = new Ku;
        return e.currentKey = "--",
        e.renderable = t,
        e.transform = t.groupTransform,
        e.bounds = {
            minX: 0,
            maxX: 1,
            minY: 0,
            maxY: 0
        },
        e.roundPixels = this._renderer._roundPixels | t._roundPixels,
        t._gpuData[this._renderer.uid] = e,
        this._managedTexts.add(t),
        e
    }
    onTextUnload(t) {
        const e = t._gpuData[this._renderer.uid];
        if (!e)
            return;
        const {canvasText: i} = this._renderer;
        i.getReferenceCount(e.currentKey) > 0 ? i.decreaseReferenceCount(e.currentKey) : e.texture && i.returnTexture(e.texture)
    }
    destroy() {
        this._managedTexts.destroy(),
        this._renderer = null
    }
}
Ca.extension = {
    type: [I.WebGLPipes, I.WebGPUPipes, I.CanvasPipes],
    name: "text"
};
class Pa {
    constructor(t, e) {
        this._activeTextures = {},
        this._renderer = t,
        this._retainCanvasContext = e
    }
    getTexture(t, e, i, r) {
        typeof t == "string" && (V("8.0.0", "CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),
        t = {
            text: t,
            style: i,
            resolution: e
        }),
        t.style instanceof us || (t.style = new us(t.style)),
        t.textureStyle instanceof ue || (t.textureStyle = new ue(t.textureStyle)),
        typeof t.text != "string" && (t.text = t.text.toString());
        const {text: n, style: a, textureStyle: o, autoGenerateMipmaps: h} = t
          , l = t.resolution ?? this._renderer.resolution
          , {frame: c, canvasAndContext: u} = ae.getCanvasAndContext({
            text: n,
            style: a,
            resolution: l
        })
          , d = _u(u.canvas, c.width, c.height, l, h);
        if (o && (d.source.style = o),
        a.trim && (c.pad(a.padding),
        d.frame.copyFrom(c),
        d.frame.scale(1 / l),
        d.updateUvs()),
        a.filters) {
            const f = this._applyFilters(d, a.filters);
            return this.returnTexture(d),
            ae.returnCanvasAndContext(u),
            f
        }
        return this._renderer.texture.initSource(d._source),
        this._retainCanvasContext || ae.returnCanvasAndContext(u),
        d
    }
    returnTexture(t) {
        const e = t.source
          , i = e.resource;
        if (this._retainCanvasContext && (i != null && i.getContext)) {
            const r = i.getContext("2d");
            r && ae.returnCanvasAndContext({
                canvas: i,
                context: r
            })
        }
        e.resource = null,
        e.uploadMethodId = "unknown",
        e.alphaMode = "no-premultiply-alpha",
        ds.returnTexture(t, !0)
    }
    renderTextToCanvas() {
        V("8.10.0", "CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")
    }
    getManagedTexture(t) {
        t._resolution = t._autoResolution ? this._renderer.resolution : t.resolution;
        const e = t.styleKey;
        if (this._activeTextures[e])
            return this._increaseReferenceCount(e),
            this._activeTextures[e].texture;
        const i = this.getTexture({
            text: t.text,
            style: t.style,
            resolution: t._resolution,
            textureStyle: t.textureStyle,
            autoGenerateMipmaps: t.autoGenerateMipmaps
        });
        return this._activeTextures[e] = {
            texture: i,
            usageCount: 1
        },
        i
    }
    decreaseReferenceCount(t) {
        const e = this._activeTextures[t];
        e && (e.usageCount--,
        e.usageCount === 0 && (this.returnTexture(e.texture),
        this._activeTextures[t] = null))
    }
    getReferenceCount(t) {
        var e;
        return ((e = this._activeTextures[t]) == null ? void 0 : e.usageCount) ?? 0
    }
    _increaseReferenceCount(t) {
        this._activeTextures[t].usageCount++
    }
    _applyFilters(t, e) {
        const i = this._renderer.renderTarget.renderTarget
          , r = this._renderer.filter.generateFilteredTexture({
            texture: t,
            filters: e
        });
        return this._renderer.renderTarget.bind(i, !1),
        r
    }
    destroy() {
        this._renderer = null;
        for (const t in this._activeTextures)
            this._activeTextures[t] && this.returnTexture(this._activeTextures[t].texture);
        this._activeTextures = null
    }
}
class Ma extends Pa {
    constructor(t) {
        super(t, !0)
    }
}
Ma.extension = {
    type: [I.CanvasSystem],
    name: "canvasText"
};
class ka extends Pa {
    constructor(t) {
        super(t, !1)
    }
}
ka.extension = {
    type: [I.WebGLSystem, I.WebGPUSystem],
    name: "canvasText"
};
Y.add(Ma);
Y.add(ka);
Y.add(Ca);
class ad extends bu {
    constructor(...t) {
        const e = wu(t, "Text");
        super(e, us),
        this.renderPipeId = "text",
        e.textureStyle && (this.textureStyle = e.textureStyle instanceof ue ? e.textureStyle : new ue(e.textureStyle)),
        this.autoGenerateMipmaps = e.autoGenerateMipmaps ?? xt.defaultOptions.autoGenerateMipmaps
    }
    updateBounds() {
        const t = this._bounds
          , e = this._anchor;
        let i = 0
          , r = 0;
        if (this._style.trim) {
            const {frame: n, canvasAndContext: a} = ae.getCanvasAndContext({
                text: this.text,
                style: this._style,
                resolution: 1
            });
            ae.returnCanvasAndContext(a),
            i = n.width,
            r = n.height
        } else {
            const n = Ft.measureText(this._text, this._style);
            i = n.width,
            r = n.height
        }
        t.minX = -e._x * i,
        t.maxX = t.minX + i,
        t.minY = -e._y * r,
        t.maxY = t.minY + r
    }
}
Y.add(La, Ga);
var Ct = {}, Vs = {}, Pt = {}, $r;
function Ea() {
    if ($r)
        return Pt;
    $r = 1,
    Object.defineProperty(Pt, "__esModule", {
        value: !0
    }),
    Pt.loop = Pt.conditional = Pt.parse = void 0;
    var s = function i(r, n) {
        var a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}
          , o = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : a;
        if (Array.isArray(n))
            n.forEach(function(l) {
                return i(r, l, a, o)
            });
        else if (typeof n == "function")
            n(r, a, o, i);
        else {
            var h = Object.keys(n)[0];
            Array.isArray(n[h]) ? (o[h] = {},
            i(r, n[h], a, o[h])) : o[h] = n[h](r, a, o, i)
        }
        return a
    };
    Pt.parse = s;
    var t = function(r, n) {
        return function(a, o, h, l) {
            n(a, o, h) && l(a, r, o, h)
        }
    };
    Pt.conditional = t;
    var e = function(r, n) {
        return function(a, o, h, l) {
            for (var c = [], u = a.pos; n(a, o, h); ) {
                var d = {};
                if (l(a, r, o, d),
                a.pos === u)
                    break;
                u = a.pos,
                c.push(d)
            }
            return c
        }
    };
    return Pt.loop = e,
    Pt
}
var K = {}, Vr;
function Ia() {
    if (Vr)
        return K;
    Vr = 1,
    Object.defineProperty(K, "__esModule", {
        value: !0
    }),
    K.readBits = K.readArray = K.readUnsigned = K.readString = K.peekBytes = K.readBytes = K.peekByte = K.readByte = K.buildStream = void 0;
    var s = function(u) {
        return {
            data: u,
            pos: 0
        }
    };
    K.buildStream = s;
    var t = function() {
        return function(u) {
            return u.data[u.pos++]
        }
    };
    K.readByte = t;
    var e = function() {
        var u = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
        return function(d) {
            return d.data[d.pos + u]
        }
    };
    K.peekByte = e;
    var i = function(u) {
        return function(d) {
            return d.data.subarray(d.pos, d.pos += u)
        }
    };
    K.readBytes = i;
    var r = function(u) {
        return function(d) {
            return d.data.subarray(d.pos, d.pos + u)
        }
    };
    K.peekBytes = r;
    var n = function(u) {
        return function(d) {
            return Array.from(i(u)(d)).map(function(f) {
                return String.fromCharCode(f)
            }).join("")
        }
    };
    K.readString = n;
    var a = function(u) {
        return function(d) {
            var f = i(2)(d);
            return u ? (f[1] << 8) + f[0] : (f[0] << 8) + f[1]
        }
    };
    K.readUnsigned = a;
    var o = function(u, d) {
        return function(f, p, m) {
            for (var g = typeof d == "function" ? d(f, p, m) : d, x = i(u), y = new Array(g), _ = 0; _ < g; _++)
                y[_] = x(f);
            return y
        }
    };
    K.readArray = o;
    var h = function(u, d, f) {
        for (var p = 0, m = 0; m < f; m++)
            p += u[d + m] && Math.pow(2, f - m - 1);
        return p
    }
      , l = function(u) {
        return function(d) {
            for (var f = t()(d), p = new Array(8), m = 0; m < 8; m++)
                p[7 - m] = !!(f & 1 << m);
            return Object.keys(u).reduce(function(g, x) {
                var y = u[x];
                return y.length ? g[x] = h(p, y.index, y.length) : g[x] = p[y.index],
                g
            }, {})
        }
    };
    return K.readBits = l,
    K
}
var jr;
function Zu() {
    return jr || (jr = 1,
    (function(s) {
        Object.defineProperty(s, "__esModule", {
            value: !0
        }),
        s.default = void 0;
        var t = Ea()
          , e = Ia()
          , i = {
            blocks: function(d) {
                for (var f = 0, p = [], m = d.data.length, g = 0, x = (0,
                e.readByte)()(d); x !== f && x; x = (0,
                e.readByte)()(d)) {
                    if (d.pos + x >= m) {
                        var y = m - d.pos;
                        p.push((0,
                        e.readBytes)(y)(d)),
                        g += y;
                        break
                    }
                    p.push((0,
                    e.readBytes)(x)(d)),
                    g += x
                }
                for (var _ = new Uint8Array(g), b = 0, A = 0; A < p.length; A++)
                    _.set(p[A], b),
                    b += p[A].length;
                return _
            }
        }
          , r = (0,
        t.conditional)({
            gce: [{
                codes: (0,
                e.readBytes)(2)
            }, {
                byteSize: (0,
                e.readByte)()
            }, {
                extras: (0,
                e.readBits)({
                    future: {
                        index: 0,
                        length: 3
                    },
                    disposal: {
                        index: 3,
                        length: 3
                    },
                    userInput: {
                        index: 6
                    },
                    transparentColorGiven: {
                        index: 7
                    }
                })
            }, {
                delay: (0,
                e.readUnsigned)(!0)
            }, {
                transparentColorIndex: (0,
                e.readByte)()
            }, {
                terminator: (0,
                e.readByte)()
            }]
        }, function(u) {
            var d = (0,
            e.peekBytes)(2)(u);
            return d[0] === 33 && d[1] === 249
        })
          , n = (0,
        t.conditional)({
            image: [{
                code: (0,
                e.readByte)()
            }, {
                descriptor: [{
                    left: (0,
                    e.readUnsigned)(!0)
                }, {
                    top: (0,
                    e.readUnsigned)(!0)
                }, {
                    width: (0,
                    e.readUnsigned)(!0)
                }, {
                    height: (0,
                    e.readUnsigned)(!0)
                }, {
                    lct: (0,
                    e.readBits)({
                        exists: {
                            index: 0
                        },
                        interlaced: {
                            index: 1
                        },
                        sort: {
                            index: 2
                        },
                        future: {
                            index: 3,
                            length: 2
                        },
                        size: {
                            index: 5,
                            length: 3
                        }
                    })
                }]
            }, (0,
            t.conditional)({
                lct: (0,
                e.readArray)(3, function(u, d, f) {
                    return Math.pow(2, f.descriptor.lct.size + 1)
                })
            }, function(u, d, f) {
                return f.descriptor.lct.exists
            }), {
                data: [{
                    minCodeSize: (0,
                    e.readByte)()
                }, i]
            }]
        }, function(u) {
            return (0,
            e.peekByte)()(u) === 44
        })
          , a = (0,
        t.conditional)({
            text: [{
                codes: (0,
                e.readBytes)(2)
            }, {
                blockSize: (0,
                e.readByte)()
            }, {
                preData: function(d, f, p) {
                    return (0,
                    e.readBytes)(p.text.blockSize)(d)
                }
            }, i]
        }, function(u) {
            var d = (0,
            e.peekBytes)(2)(u);
            return d[0] === 33 && d[1] === 1
        })
          , o = (0,
        t.conditional)({
            application: [{
                codes: (0,
                e.readBytes)(2)
            }, {
                blockSize: (0,
                e.readByte)()
            }, {
                id: function(d, f, p) {
                    return (0,
                    e.readString)(p.blockSize)(d)
                }
            }, i]
        }, function(u) {
            var d = (0,
            e.peekBytes)(2)(u);
            return d[0] === 33 && d[1] === 255
        })
          , h = (0,
        t.conditional)({
            comment: [{
                codes: (0,
                e.readBytes)(2)
            }, i]
        }, function(u) {
            var d = (0,
            e.peekBytes)(2)(u);
            return d[0] === 33 && d[1] === 254
        })
          , l = [{
            header: [{
                signature: (0,
                e.readString)(3)
            }, {
                version: (0,
                e.readString)(3)
            }]
        }, {
            lsd: [{
                width: (0,
                e.readUnsigned)(!0)
            }, {
                height: (0,
                e.readUnsigned)(!0)
            }, {
                gct: (0,
                e.readBits)({
                    exists: {
                        index: 0
                    },
                    resolution: {
                        index: 1,
                        length: 3
                    },
                    sort: {
                        index: 4
                    },
                    size: {
                        index: 5,
                        length: 3
                    }
                })
            }, {
                backgroundColorIndex: (0,
                e.readByte)()
            }, {
                pixelAspectRatio: (0,
                e.readByte)()
            }]
        }, (0,
        t.conditional)({
            gct: (0,
            e.readArray)(3, function(u, d) {
                return Math.pow(2, d.lsd.gct.size + 1)
            })
        }, function(u, d) {
            return d.lsd.gct.exists
        }), {
            frames: (0,
            t.loop)([r, o, h, n, a], function(u) {
                var d = (0,
                e.peekByte)()(u);
                return d === 33 || d === 44
            })
        }]
          , c = l;
        s.default = c
    }
    )(Vs)),
    Vs
}
var Te = {}, Yr;
function Qu() {
    if (Yr)
        return Te;
    Yr = 1,
    Object.defineProperty(Te, "__esModule", {
        value: !0
    }),
    Te.deinterlace = void 0;
    var s = function(e, i) {
        for (var r = new Array(e.length), n = e.length / i, a = function(f, p) {
            var m = e.slice(p * i, (p + 1) * i);
            r.splice.apply(r, [f * i, i].concat(m))
        }, o = [0, 4, 2, 1], h = [8, 8, 4, 2], l = 0, c = 0; c < 4; c++)
            for (var u = o[c]; u < n; u += h[c])
                a(u, l),
                l++;
        return r
    };
    return Te.deinterlace = s,
    Te
}
var Ce = {}, Xr;
function Ju() {
    if (Xr)
        return Ce;
    Xr = 1,
    Object.defineProperty(Ce, "__esModule", {
        value: !0
    }),
    Ce.lzw = void 0;
    var s = function(e, i, r) {
        var n = 4096, a = -1, o = r, h, l, c, u, d, f, p, v, m, g, w, x, M, T, C, S, y = new Array(r), _ = new Array(n), b = new Array(n), A = new Array(n + 1);
        for (x = e,
        l = 1 << x,
        d = l + 1,
        h = l + 2,
        p = a,
        u = x + 1,
        c = (1 << u) - 1,
        m = 0; m < l; m++)
            _[m] = 0,
            b[m] = m;
        var w, v, M, T, S, C;
        for (w = v = M = T = S = C = 0,
        g = 0; g < o; ) {
            if (T === 0) {
                if (v < u) {
                    w += i[C] << v,
                    v += 8,
                    C++;
                    continue
                }
                if (m = w & c,
                w >>= u,
                v -= u,
                m > h || m == d)
                    break;
                if (m == l) {
                    u = x + 1,
                    c = (1 << u) - 1,
                    h = l + 2,
                    p = a;
                    continue
                }
                if (p == a) {
                    A[T++] = b[m],
                    p = m,
                    M = m;
                    continue
                }
                for (f = m,
                m == h && (A[T++] = M,
                m = p); m > l; )
                    A[T++] = b[m],
                    m = _[m];
                M = b[m] & 255,
                A[T++] = M,
                h < n && (_[h] = p,
                b[h] = M,
                h++,
                (h & c) === 0 && h < n && (u++,
                c += h)),
                p = f
            }
            T--,
            y[S++] = A[T],
            g++
        }
        for (g = S; g < o; g++)
            y[g] = 0;
        return y
    };
    return Ce.lzw = s,
    Ce
}
var qr;
function td() {
    if (qr)
        return Ct;
    qr = 1,
    Object.defineProperty(Ct, "__esModule", {
        value: !0
    }),
    Ct.decompressFrames = Ct.decompressFrame = Ct.parseGIF = void 0;
    var s = n(Zu())
      , t = Ea()
      , e = Ia()
      , i = Qu()
      , r = Ju();
    function n(c) {
        return c && c.__esModule ? c : {
            default: c
        }
    }
    var a = function(u) {
        var d = new Uint8Array(u);
        return (0,
        t.parse)((0,
        e.buildStream)(d), s.default)
    };
    Ct.parseGIF = a;
    var o = function(u) {
        for (var d = u.pixels.length, f = new Uint8ClampedArray(d * 4), p = 0; p < d; p++) {
            var m = p * 4
              , g = u.pixels[p]
              , x = u.colorTable[g] || [0, 0, 0];
            f[m] = x[0],
            f[m + 1] = x[1],
            f[m + 2] = x[2],
            f[m + 3] = g !== u.transparentIndex ? 255 : 0
        }
        return f
    }
      , h = function(u, d, f) {
        if (u.image) {
            var p = u.image
              , m = p.descriptor.width * p.descriptor.height
              , g = (0,
            r.lzw)(p.data.minCodeSize, p.data.blocks, m);
            p.descriptor.lct.interlaced && (g = (0,
            i.deinterlace)(g, p.descriptor.width));
            var x = {
                pixels: g,
                dims: {
                    top: u.image.descriptor.top,
                    left: u.image.descriptor.left,
                    width: u.image.descriptor.width,
                    height: u.image.descriptor.height
                }
            };
            return p.descriptor.lct && p.descriptor.lct.exists ? x.colorTable = p.lct : x.colorTable = d,
            u.gce && (x.delay = (u.gce.delay || 10) * 10,
            x.disposalType = u.gce.extras.disposal,
            u.gce.extras.transparentColorGiven && (x.transparentIndex = u.gce.transparentColorIndex)),
            f && (x.patch = o(x)),
            x
        }
    };
    Ct.decompressFrame = h;
    var l = function(u, d) {
        return u.frames.filter(function(f) {
            return f.image
        }).map(function(f) {
            return h(f, u.gct, d)
        })
    };
    return Ct.decompressFrames = l,
    Ct
}
var Kr = td();
class ys {
    constructor(t) {
        if (!t || !t.length)
            throw new Error("Invalid frames");
        const [{texture: {width: e, height: i}}] = t;
        this.width = e,
        this.height = i,
        this.frames = t,
        this.textures = this.frames.map(r => r.texture),
        this.totalFrames = this.frames.length,
        this.duration = this.frames[this.totalFrames - 1].end
    }
    destroy() {
        for (const t of this.textures)
            t.destroy(!0);
        for (const t of this.frames)
            t.texture = null;
        this.frames.length = 0,
        this.textures.length = 0,
        Object.assign(this, {
            frames: null,
            textures: null,
            width: 0,
            height: 0,
            duration: 0,
            totalFrames: 0
        })
    }
    static from(t, e) {
        if (!t || t.byteLength === 0)
            throw new Error("Invalid buffer");
        const i = y => {
            let _ = null;
            for (const b of y.frames)
                _ = b.gce ?? _,
                "image"in b && !("gce"in b) && (b.gce = _)
        }
          , r = Kr.parseGIF(t);
        i(r);
        const n = Kr.decompressFrames(r, !0)
          , a = []
          , o = r.lsd.width
          , h = r.lsd.height
          , l = O.get().createCanvas(o, h)
          , c = l.getContext("2d", {
            willReadFrequently: !0
        })
          , u = O.get().createCanvas()
          , d = u.getContext("2d");
        let f = 0
          , p = null;
        const {fps: m=30, ...g} = e ?? {}
          , x = 1e3 / m;
        for (let y = 0; y < n.length; y++) {
            const {disposalType: _=2, delay: b=x, patch: A, dims: {width: w, height: v, left: M, top: T}} = n[y];
            u.width = w,
            u.height = v,
            d.clearRect(0, 0, w, v);
            const S = d.createImageData(w, v);
            S.data.set(A),
            d.putImageData(S, 0, 0),
            _ === 3 && (p = c.getImageData(0, 0, o, h)),
            c.drawImage(u, M, T);
            const C = c.getImageData(0, 0, o, h);
            _ === 2 ? c.clearRect(0, 0, o, h) : _ === 3 && c.putImageData(p, 0, 0);
            const k = O.get().createCanvas(C.width, C.height);
            k.getContext("2d").putImageData(C, 0, 0),
            a.push({
                start: f,
                end: f + b,
                texture: new W({
                    source: new gi({
                        resource: k,
                        ...g
                    })
                })
            }),
            f += b
        }
        return l.width = l.height = 0,
        u.width = u.height = 0,
        new ys(a)
    }
}
const ed = {
    extension: I.Asset,
    detection: {
        test: async () => !0,
        add: async s => [...s, "gif"],
        remove: async s => s.filter(t => t !== "gif")
    },
    loader: {
        name: "gifLoader",
        id: "gif",
        test: s => lt.extname(s) === ".gif" || s.startsWith("data:image/gif"),
        load: async (s, t) => {
            const i = await (await O.get().fetch(s)).arrayBuffer();
            return ys.from(i, t == null ? void 0 : t.data)
        }
        ,
        unload: async s => {
            s.destroy()
        }
    }
}
  , Ra = class di extends fe {
    constructor(...t) {
        const e = t[0]instanceof ys ? {
            source: t[0]
        } : t[0]
          , {source: i, fps: r, loop: n, animationSpeed: a, autoPlay: o, autoUpdate: h, onComplete: l, onFrameChange: c, onLoop: u, ...d} = Object.assign({}, di.defaultOptions, e);
        super({
            texture: W.EMPTY,
            ...d
        }),
        this.animationSpeed = 1,
        this.loop = !0,
        this.duration = 0,
        this.autoPlay = !0,
        this.dirty = !1,
        this._currentFrame = 0,
        this._autoUpdate = !1,
        this._isConnectedToTicker = !1,
        this._playing = !1,
        this._currentTime = 0,
        this.onRender = () => this._updateFrame(),
        this.texture = i.textures[0],
        this.duration = i.frames[i.frames.length - 1].end,
        this._source = i,
        this._playing = !1,
        this._currentTime = 0,
        this._isConnectedToTicker = !1,
        Object.assign(this, {
            fps: r,
            loop: n,
            animationSpeed: a,
            autoPlay: o,
            autoUpdate: h,
            onComplete: l,
            onFrameChange: c,
            onLoop: u
        }),
        this.currentFrame = 0,
        o && this.play()
    }
    stop() {
        this._playing && (this._playing = !1,
        this._autoUpdate && this._isConnectedToTicker && (_t.shared.remove(this.update, this),
        this._isConnectedToTicker = !1))
    }
    play() {
        this._playing || (this._playing = !0,
        this._autoUpdate && !this._isConnectedToTicker && (_t.shared.add(this.update, this, Le.HIGH),
        this._isConnectedToTicker = !0),
        !this.loop && this.currentFrame === this._source.frames.length - 1 && (this._currentTime = 0))
    }
    get progress() {
        return this._currentTime / this.duration
    }
    get playing() {
        return this._playing
    }
    update(t) {
        var a, o;
        if (!this._playing)
            return;
        const e = this.animationSpeed * t.deltaTime / _t.targetFPMS
          , i = this._currentTime + e
          , r = i % this.duration
          , n = this._source.frames.findIndex(h => h.start <= r && h.end > r);
        i >= this.duration ? this.loop ? (this._currentTime = r,
        this._updateFrameIndex(n),
        (a = this.onLoop) == null || a.call(this)) : (this._currentTime = this.duration,
        this._updateFrameIndex(this.totalFrames - 1),
        (o = this.onComplete) == null || o.call(this),
        this.stop()) : (this._currentTime = r,
        this._updateFrameIndex(n))
    }
    _updateFrame() {
        this.dirty && (this.texture = this._source.frames[this._currentFrame].texture,
        this.dirty = !1)
    }
    get autoUpdate() {
        return this._autoUpdate
    }
    set autoUpdate(t) {
        t !== this._autoUpdate && (this._autoUpdate = t,
        !this._autoUpdate && this._isConnectedToTicker ? (_t.shared.remove(this.update, this),
        this._isConnectedToTicker = !1) : this._autoUpdate && !this._isConnectedToTicker && this._playing && (_t.shared.add(this.update, this),
        this._isConnectedToTicker = !0))
    }
    get currentFrame() {
        return this._currentFrame
    }
    set currentFrame(t) {
        this._updateFrameIndex(t),
        this._currentTime = this._source.frames[t].start
    }
    get source() {
        return this._source
    }
    _updateFrameIndex(t) {
        var e;
        if (t < 0 || t >= this.totalFrames)
            throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);
        this._currentFrame !== t && (this._currentFrame = t,
        this.dirty = !0,
        (e = this.onFrameChange) == null || e.call(this, t))
    }
    get totalFrames() {
        return this._source.totalFrames
    }
    destroy(t=!1) {
        this.stop(),
        super.destroy(),
        t && this._source.destroy();
        const e = null;
        this._source = e,
        this.onComplete = e,
        this.onFrameChange = e,
        this.onLoop = e
    }
    clone() {
        const t = new di({
            source: this._source,
            autoUpdate: this._autoUpdate,
            loop: this.loop,
            autoPlay: this.autoPlay,
            animationSpeed: this.animationSpeed,
            onComplete: this.onComplete,
            onFrameChange: this.onFrameChange,
            onLoop: this.onLoop
        });
        return t.dirty = !0,
        t
    }
}
;
Ra.defaultOptions = {
    fps: 30,
    loop: !0,
    animationSpeed: 1,
    autoPlay: !0,
    autoUpdate: !0,
    onComplete: null,
    onFrameChange: null,
    onLoop: null
};
let od = Ra;
Y.add(ed);
export {Le as $, dl as A, mt as B, J as C, O as D, I as E, rh as F, ps as G, We as H, mn as I, ht as J, q as K, rs as L, dn as M, D as N, ms as O, nc as P, pc as Q, Z as R, xi as S, W as T, Rt as U, xn as V, xs as W, gi as X, Vn as Y, ti as Z, _t as _, Bn as a, nt as a0, oo as a1, Gt as a2, ss as a3, Mh as a4, fe as a5, ad as a6, od as a7, ll as a8, ar as a9, Al as aA, gl as aB, Ul as aC, Hl as aD, Xl as aE, Kl as aF, Zl as aG, it as aH, or as aI, nr as aJ, Co as aK, _u as aL, ns as aa, mi as ab, Nn as ac, xt as ad, Dn as ae, Ol as af, Nl as ag, jl as ah, ql as ai, Ya as aj, Ql as ak, cn as al, gt as am, ds as an, Ni as ao, qu as ap, To as aq, $i as ar, ks as as, Vi as at, Po as au, fn as av, jn as aw, Ue as ax, Ph as ay, Ah as az, oa as b, la as c, da as d, Y as e, Kt as f, U as g, V as h, vt as i, ui as j, ue as k, Ft as l, ci as m, pe as n, is as o, us as p, Aa as q, va as r, pt as s, nd as t, zu as u, dt as v, Tu as w, st as x, $ as y, Xo as z};
