const og = [
  { color: "red", primary: 600, secondary: 100 },
  { color: "green", primary: 600, secondary: 100 },
  { color: "blue", primary: 600, secondary: 100 },
  { color: "yellow", primary: 500, secondary: 100 },
  { color: "purple", primary: 600, secondary: 100 },
  { color: "teal", primary: 600, secondary: 100 },
  { color: "orange", primary: 600, secondary: 100 },
  { color: "cyan", primary: 600, secondary: 100 },
  { color: "lime", primary: 500, secondary: 100 },
  { color: "pink", primary: 600, secondary: 100 }
], gu = {
  inherit: "inherit",
  current: "currentColor",
  transparent: "transparent",
  black: "#000",
  white: "#fff",
  slate: {
    50: "#f8fafc",
    100: "#f1f5f9",
    200: "#e2e8f0",
    300: "#cbd5e1",
    400: "#94a3b8",
    500: "#64748b",
    600: "#475569",
    700: "#334155",
    800: "#1e293b",
    900: "#0f172a",
    950: "#020617"
  },
  gray: {
    50: "#f9fafb",
    100: "#f3f4f6",
    200: "#e5e7eb",
    300: "#d1d5db",
    400: "#9ca3af",
    500: "#6b7280",
    600: "#4b5563",
    700: "#374151",
    800: "#1f2937",
    900: "#111827",
    950: "#030712"
  },
  zinc: {
    50: "#fafafa",
    100: "#f4f4f5",
    200: "#e4e4e7",
    300: "#d4d4d8",
    400: "#a1a1aa",
    500: "#71717a",
    600: "#52525b",
    700: "#3f3f46",
    800: "#27272a",
    900: "#18181b",
    950: "#09090b"
  },
  neutral: {
    50: "#fafafa",
    100: "#f5f5f5",
    200: "#e5e5e5",
    300: "#d4d4d4",
    400: "#a3a3a3",
    500: "#737373",
    600: "#525252",
    700: "#404040",
    800: "#262626",
    900: "#171717",
    950: "#0a0a0a"
  },
  stone: {
    50: "#fafaf9",
    100: "#f5f5f4",
    200: "#e7e5e4",
    300: "#d6d3d1",
    400: "#a8a29e",
    500: "#78716c",
    600: "#57534e",
    700: "#44403c",
    800: "#292524",
    900: "#1c1917",
    950: "#0c0a09"
  },
  red: {
    50: "#fef2f2",
    100: "#fee2e2",
    200: "#fecaca",
    300: "#fca5a5",
    400: "#f87171",
    500: "#ef4444",
    600: "#dc2626",
    700: "#b91c1c",
    800: "#991b1b",
    900: "#7f1d1d",
    950: "#450a0a"
  },
  orange: {
    50: "#fff7ed",
    100: "#ffedd5",
    200: "#fed7aa",
    300: "#fdba74",
    400: "#fb923c",
    500: "#f97316",
    600: "#ea580c",
    700: "#c2410c",
    800: "#9a3412",
    900: "#7c2d12",
    950: "#431407"
  },
  amber: {
    50: "#fffbeb",
    100: "#fef3c7",
    200: "#fde68a",
    300: "#fcd34d",
    400: "#fbbf24",
    500: "#f59e0b",
    600: "#d97706",
    700: "#b45309",
    800: "#92400e",
    900: "#78350f",
    950: "#451a03"
  },
  yellow: {
    50: "#fefce8",
    100: "#fef9c3",
    200: "#fef08a",
    300: "#fde047",
    400: "#facc15",
    500: "#eab308",
    600: "#ca8a04",
    700: "#a16207",
    800: "#854d0e",
    900: "#713f12",
    950: "#422006"
  },
  lime: {
    50: "#f7fee7",
    100: "#ecfccb",
    200: "#d9f99d",
    300: "#bef264",
    400: "#a3e635",
    500: "#84cc16",
    600: "#65a30d",
    700: "#4d7c0f",
    800: "#3f6212",
    900: "#365314",
    950: "#1a2e05"
  },
  green: {
    50: "#f0fdf4",
    100: "#dcfce7",
    200: "#bbf7d0",
    300: "#86efac",
    400: "#4ade80",
    500: "#22c55e",
    600: "#16a34a",
    700: "#15803d",
    800: "#166534",
    900: "#14532d",
    950: "#052e16"
  },
  emerald: {
    50: "#ecfdf5",
    100: "#d1fae5",
    200: "#a7f3d0",
    300: "#6ee7b7",
    400: "#34d399",
    500: "#10b981",
    600: "#059669",
    700: "#047857",
    800: "#065f46",
    900: "#064e3b",
    950: "#022c22"
  },
  teal: {
    50: "#f0fdfa",
    100: "#ccfbf1",
    200: "#99f6e4",
    300: "#5eead4",
    400: "#2dd4bf",
    500: "#14b8a6",
    600: "#0d9488",
    700: "#0f766e",
    800: "#115e59",
    900: "#134e4a",
    950: "#042f2e"
  },
  cyan: {
    50: "#ecfeff",
    100: "#cffafe",
    200: "#a5f3fc",
    300: "#67e8f9",
    400: "#22d3ee",
    500: "#06b6d4",
    600: "#0891b2",
    700: "#0e7490",
    800: "#155e75",
    900: "#164e63",
    950: "#083344"
  },
  sky: {
    50: "#f0f9ff",
    100: "#e0f2fe",
    200: "#bae6fd",
    300: "#7dd3fc",
    400: "#38bdf8",
    500: "#0ea5e9",
    600: "#0284c7",
    700: "#0369a1",
    800: "#075985",
    900: "#0c4a6e",
    950: "#082f49"
  },
  blue: {
    50: "#eff6ff",
    100: "#dbeafe",
    200: "#bfdbfe",
    300: "#93c5fd",
    400: "#60a5fa",
    500: "#3b82f6",
    600: "#2563eb",
    700: "#1d4ed8",
    800: "#1e40af",
    900: "#1e3a8a",
    950: "#172554"
  },
  indigo: {
    50: "#eef2ff",
    100: "#e0e7ff",
    200: "#c7d2fe",
    300: "#a5b4fc",
    400: "#818cf8",
    500: "#6366f1",
    600: "#4f46e5",
    700: "#4338ca",
    800: "#3730a3",
    900: "#312e81",
    950: "#1e1b4b"
  },
  violet: {
    50: "#f5f3ff",
    100: "#ede9fe",
    200: "#ddd6fe",
    300: "#c4b5fd",
    400: "#a78bfa",
    500: "#8b5cf6",
    600: "#7c3aed",
    700: "#6d28d9",
    800: "#5b21b6",
    900: "#4c1d95",
    950: "#2e1065"
  },
  purple: {
    50: "#faf5ff",
    100: "#f3e8ff",
    200: "#e9d5ff",
    300: "#d8b4fe",
    400: "#c084fc",
    500: "#a855f7",
    600: "#9333ea",
    700: "#7e22ce",
    800: "#6b21a8",
    900: "#581c87",
    950: "#3b0764"
  },
  fuchsia: {
    50: "#fdf4ff",
    100: "#fae8ff",
    200: "#f5d0fe",
    300: "#f0abfc",
    400: "#e879f9",
    500: "#d946ef",
    600: "#c026d3",
    700: "#a21caf",
    800: "#86198f",
    900: "#701a75",
    950: "#4a044e"
  },
  pink: {
    50: "#fdf2f8",
    100: "#fce7f3",
    200: "#fbcfe8",
    300: "#f9a8d4",
    400: "#f472b6",
    500: "#ec4899",
    600: "#db2777",
    700: "#be185d",
    800: "#9d174d",
    900: "#831843",
    950: "#500724"
  },
  rose: {
    50: "#fff1f2",
    100: "#ffe4e6",
    200: "#fecdd3",
    300: "#fda4af",
    400: "#fb7185",
    500: "#f43f5e",
    600: "#e11d48",
    700: "#be123c",
    800: "#9f1239",
    900: "#881337",
    950: "#4c0519"
  }
};
og.reduce(
  (r, { color: e, primary: t, secondary: i }) => ({
    ...r,
    [e]: {
      primary: gu[e][t],
      secondary: gu[e][i]
    }
  }),
  {}
);
class Ao extends Error {
  constructor(e) {
    super(e), this.name = "ShareError";
  }
}
async function ag(r, e) {
  var l;
  if (window.__gradio_space__ == null)
    throw new Ao("Must be on Spaces to share.");
  let t, i, n;
  t = lg(r), i = r.split(";")[0].split(":")[1], n = "file" + i.split("/")[1];
  const s = new File([t], n, { type: i }), o = await fetch("https://huggingface.co/uploads", {
    method: "POST",
    body: s,
    headers: {
      "Content-Type": s.type,
      "X-Requested-With": "XMLHttpRequest"
    }
  });
  if (!o.ok) {
    if ((l = o.headers.get("content-type")) != null && l.includes("application/json")) {
      const h = await o.json();
      throw new Ao(`Upload failed: ${h.error}`);
    }
    throw new Ao("Upload failed.");
  }
  return await o.text();
}
function lg(r) {
  for (var e = r.split(","), t = e[0].match(/:(.*?);/)[1], i = atob(e[1]), n = i.length, s = new Uint8Array(n); n--; )
    s[n] = i.charCodeAt(n);
  return new Blob([s], { type: t });
}
const {
  SvelteComponent: hg,
  assign: cg,
  create_slot: ug,
  detach: dg,
  element: fg,
  get_all_dirty_from_scope: pg,
  get_slot_changes: _g,
  get_spread_update: mg,
  init: gg,
  insert: yg,
  safe_not_equal: vg,
  set_dynamic_element_data: yu,
  set_style: pt,
  toggle_class: ei,
  transition_in: s_,
  transition_out: o_,
  update_slot_base: bg
} = window.__gradio__svelte__internal;
function wg(r) {
  let e, t, i;
  const n = (
    /*#slots*/
    r[18].default
  ), s = ug(
    n,
    r,
    /*$$scope*/
    r[17],
    null
  );
  let o = [
    { "data-testid": (
      /*test_id*/
      r[7]
    ) },
    { id: (
      /*elem_id*/
      r[2]
    ) },
    {
      class: t = "block " + /*elem_classes*/
      r[3].join(" ") + " svelte-nl1om8"
    }
  ], a = {};
  for (let l = 0; l < o.length; l += 1)
    a = cg(a, o[l]);
  return {
    c() {
      e = fg(
        /*tag*/
        r[14]
      ), s && s.c(), yu(
        /*tag*/
        r[14]
      )(e, a), ei(
        e,
        "hidden",
        /*visible*/
        r[10] === !1
      ), ei(
        e,
        "padded",
        /*padding*/
        r[6]
      ), ei(
        e,
        "border_focus",
        /*border_mode*/
        r[5] === "focus"
      ), ei(
        e,
        "border_contrast",
        /*border_mode*/
        r[5] === "contrast"
      ), ei(e, "hide-container", !/*explicit_call*/
      r[8] && !/*container*/
      r[9]), pt(
        e,
        "height",
        /*get_dimension*/
        r[15](
          /*height*/
          r[0]
        )
      ), pt(e, "width", typeof /*width*/
      r[1] == "number" ? `calc(min(${/*width*/
      r[1]}px, 100%))` : (
        /*get_dimension*/
        r[15](
          /*width*/
          r[1]
        )
      )), pt(
        e,
        "border-style",
        /*variant*/
        r[4]
      ), pt(
        e,
        "overflow",
        /*allow_overflow*/
        r[11] ? "visible" : "hidden"
      ), pt(
        e,
        "flex-grow",
        /*scale*/
        r[12]
      ), pt(e, "min-width", `calc(min(${/*min_width*/
      r[13]}px, 100%))`), pt(e, "border-width", "var(--block-border-width)");
    },
    m(l, h) {
      yg(l, e, h), s && s.m(e, null), i = !0;
    },
    p(l, h) {
      s && s.p && (!i || h & /*$$scope*/
      131072) && bg(
        s,
        n,
        l,
        /*$$scope*/
        l[17],
        i ? _g(
          n,
          /*$$scope*/
          l[17],
          h,
          null
        ) : pg(
          /*$$scope*/
          l[17]
        ),
        null
      ), yu(
        /*tag*/
        l[14]
      )(e, a = mg(o, [
        (!i || h & /*test_id*/
        128) && { "data-testid": (
          /*test_id*/
          l[7]
        ) },
        (!i || h & /*elem_id*/
        4) && { id: (
          /*elem_id*/
          l[2]
        ) },
        (!i || h & /*elem_classes*/
        8 && t !== (t = "block " + /*elem_classes*/
        l[3].join(" ") + " svelte-nl1om8")) && { class: t }
      ])), ei(
        e,
        "hidden",
        /*visible*/
        l[10] === !1
      ), ei(
        e,
        "padded",
        /*padding*/
        l[6]
      ), ei(
        e,
        "border_focus",
        /*border_mode*/
        l[5] === "focus"
      ), ei(
        e,
        "border_contrast",
        /*border_mode*/
        l[5] === "contrast"
      ), ei(e, "hide-container", !/*explicit_call*/
      l[8] && !/*container*/
      l[9]), h & /*height*/
      1 && pt(
        e,
        "height",
        /*get_dimension*/
        l[15](
          /*height*/
          l[0]
        )
      ), h & /*width*/
      2 && pt(e, "width", typeof /*width*/
      l[1] == "number" ? `calc(min(${/*width*/
      l[1]}px, 100%))` : (
        /*get_dimension*/
        l[15](
          /*width*/
          l[1]
        )
      )), h & /*variant*/
      16 && pt(
        e,
        "border-style",
        /*variant*/
        l[4]
      ), h & /*allow_overflow*/
      2048 && pt(
        e,
        "overflow",
        /*allow_overflow*/
        l[11] ? "visible" : "hidden"
      ), h & /*scale*/
      4096 && pt(
        e,
        "flex-grow",
        /*scale*/
        l[12]
      ), h & /*min_width*/
      8192 && pt(e, "min-width", `calc(min(${/*min_width*/
      l[13]}px, 100%))`);
    },
    i(l) {
      i || (s_(s, l), i = !0);
    },
    o(l) {
      o_(s, l), i = !1;
    },
    d(l) {
      l && dg(e), s && s.d(l);
    }
  };
}
function xg(r) {
  let e, t = (
    /*tag*/
    r[14] && wg(r)
  );
  return {
    c() {
      t && t.c();
    },
    m(i, n) {
      t && t.m(i, n), e = !0;
    },
    p(i, [n]) {
      /*tag*/
      i[14] && t.p(i, n);
    },
    i(i) {
      e || (s_(t, i), e = !0);
    },
    o(i) {
      o_(t, i), e = !1;
    },
    d(i) {
      t && t.d(i);
    }
  };
}
function Eg(r, e, t) {
  let { $$slots: i = {}, $$scope: n } = e, { height: s = void 0 } = e, { width: o = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: l = [] } = e, { variant: h = "solid" } = e, { border_mode: c = "base" } = e, { padding: u = !0 } = e, { type: d = "normal" } = e, { test_id: f = void 0 } = e, { explicit_call: p = !1 } = e, { container: _ = !0 } = e, { visible: m = !0 } = e, { allow_overflow: y = !0 } = e, { scale: v = null } = e, { min_width: g = 0 } = e, b = d === "fieldset" ? "fieldset" : "div";
  const w = (T) => {
    if (T !== void 0) {
      if (typeof T == "number")
        return T + "px";
      if (typeof T == "string")
        return T;
    }
  };
  return r.$$set = (T) => {
    "height" in T && t(0, s = T.height), "width" in T && t(1, o = T.width), "elem_id" in T && t(2, a = T.elem_id), "elem_classes" in T && t(3, l = T.elem_classes), "variant" in T && t(4, h = T.variant), "border_mode" in T && t(5, c = T.border_mode), "padding" in T && t(6, u = T.padding), "type" in T && t(16, d = T.type), "test_id" in T && t(7, f = T.test_id), "explicit_call" in T && t(8, p = T.explicit_call), "container" in T && t(9, _ = T.container), "visible" in T && t(10, m = T.visible), "allow_overflow" in T && t(11, y = T.allow_overflow), "scale" in T && t(12, v = T.scale), "min_width" in T && t(13, g = T.min_width), "$$scope" in T && t(17, n = T.$$scope);
  }, [
    s,
    o,
    a,
    l,
    h,
    c,
    u,
    f,
    p,
    _,
    m,
    y,
    v,
    g,
    b,
    w,
    d,
    n,
    i
  ];
}
class a_ extends hg {
  constructor(e) {
    super(), gg(this, e, Eg, xg, vg, {
      height: 0,
      width: 1,
      elem_id: 2,
      elem_classes: 3,
      variant: 4,
      border_mode: 5,
      padding: 6,
      type: 16,
      test_id: 7,
      explicit_call: 8,
      container: 9,
      visible: 10,
      allow_overflow: 11,
      scale: 12,
      min_width: 13
    });
  }
}
const {
  SvelteComponent: Tg,
  append: Va,
  attr: Gs,
  create_component: Ag,
  destroy_component: Sg,
  detach: Cg,
  element: vu,
  init: Ig,
  insert: Rg,
  mount_component: Pg,
  safe_not_equal: Mg,
  set_data: kg,
  space: Dg,
  text: Bg,
  toggle_class: Fi,
  transition_in: Fg,
  transition_out: Og
} = window.__gradio__svelte__internal;
function Lg(r) {
  let e, t, i, n, s, o;
  return i = new /*Icon*/
  r[1]({}), {
    c() {
      e = vu("label"), t = vu("span"), Ag(i.$$.fragment), n = Dg(), s = Bg(
        /*label*/
        r[0]
      ), Gs(t, "class", "svelte-9gxdi0"), Gs(e, "for", ""), Gs(e, "data-testid", "block-label"), Gs(e, "class", "svelte-9gxdi0"), Fi(e, "hide", !/*show_label*/
      r[2]), Fi(e, "sr-only", !/*show_label*/
      r[2]), Fi(
        e,
        "float",
        /*float*/
        r[4]
      ), Fi(
        e,
        "hide-label",
        /*disable*/
        r[3]
      );
    },
    m(a, l) {
      Rg(a, e, l), Va(e, t), Pg(i, t, null), Va(e, n), Va(e, s), o = !0;
    },
    p(a, [l]) {
      (!o || l & /*label*/
      1) && kg(
        s,
        /*label*/
        a[0]
      ), (!o || l & /*show_label*/
      4) && Fi(e, "hide", !/*show_label*/
      a[2]), (!o || l & /*show_label*/
      4) && Fi(e, "sr-only", !/*show_label*/
      a[2]), (!o || l & /*float*/
      16) && Fi(
        e,
        "float",
        /*float*/
        a[4]
      ), (!o || l & /*disable*/
      8) && Fi(
        e,
        "hide-label",
        /*disable*/
        a[3]
      );
    },
    i(a) {
      o || (Fg(i.$$.fragment, a), o = !0);
    },
    o(a) {
      Og(i.$$.fragment, a), o = !1;
    },
    d(a) {
      a && Cg(e), Sg(i);
    }
  };
}
function Ng(r, e, t) {
  let { label: i = null } = e, { Icon: n } = e, { show_label: s = !0 } = e, { disable: o = !1 } = e, { float: a = !0 } = e;
  return r.$$set = (l) => {
    "label" in l && t(0, i = l.label), "Icon" in l && t(1, n = l.Icon), "show_label" in l && t(2, s = l.show_label), "disable" in l && t(3, o = l.disable), "float" in l && t(4, a = l.float);
  }, [i, n, s, o, a];
}
class l_ extends Tg {
  constructor(e) {
    super(), Ig(this, e, Ng, Lg, Mg, {
      label: 0,
      Icon: 1,
      show_label: 2,
      disable: 3,
      float: 4
    });
  }
}
const {
  SvelteComponent: Ug,
  append: Ah,
  attr: Ti,
  bubble: Gg,
  create_component: Hg,
  destroy_component: zg,
  detach: h_,
  element: Sh,
  init: Xg,
  insert: c_,
  listen: Vg,
  mount_component: Wg,
  safe_not_equal: jg,
  set_data: qg,
  set_style: Zr,
  space: Yg,
  text: Kg,
  toggle_class: ot,
  transition_in: Zg,
  transition_out: $g
} = window.__gradio__svelte__internal;
function bu(r) {
  let e, t;
  return {
    c() {
      e = Sh("span"), t = Kg(
        /*label*/
        r[1]
      ), Ti(e, "class", "svelte-1lrphxw");
    },
    m(i, n) {
      c_(i, e, n), Ah(e, t);
    },
    p(i, n) {
      n & /*label*/
      2 && qg(
        t,
        /*label*/
        i[1]
      );
    },
    d(i) {
      i && h_(e);
    }
  };
}
function Jg(r) {
  let e, t, i, n, s, o, a, l = (
    /*show_label*/
    r[2] && bu(r)
  );
  return n = new /*Icon*/
  r[0]({}), {
    c() {
      e = Sh("button"), l && l.c(), t = Yg(), i = Sh("div"), Hg(n.$$.fragment), Ti(i, "class", "svelte-1lrphxw"), ot(
        i,
        "small",
        /*size*/
        r[4] === "small"
      ), ot(
        i,
        "large",
        /*size*/
        r[4] === "large"
      ), ot(
        i,
        "medium",
        /*size*/
        r[4] === "medium"
      ), e.disabled = /*disabled*/
      r[7], Ti(
        e,
        "aria-label",
        /*label*/
        r[1]
      ), Ti(
        e,
        "aria-haspopup",
        /*hasPopup*/
        r[8]
      ), Ti(
        e,
        "title",
        /*label*/
        r[1]
      ), Ti(e, "class", "svelte-1lrphxw"), ot(
        e,
        "pending",
        /*pending*/
        r[3]
      ), ot(
        e,
        "padded",
        /*padded*/
        r[5]
      ), ot(
        e,
        "highlight",
        /*highlight*/
        r[6]
      ), ot(
        e,
        "transparent",
        /*transparent*/
        r[9]
      ), Zr(e, "color", !/*disabled*/
      r[7] && /*_color*/
      r[12] ? (
        /*_color*/
        r[12]
      ) : "var(--block-label-text-color)"), Zr(e, "--bg-color", /*disabled*/
      r[7] ? "auto" : (
        /*background*/
        r[10]
      )), Zr(
        e,
        "margin-left",
        /*offset*/
        r[11] + "px"
      );
    },
    m(h, c) {
      c_(h, e, c), l && l.m(e, null), Ah(e, t), Ah(e, i), Wg(n, i, null), s = !0, o || (a = Vg(
        e,
        "click",
        /*click_handler*/
        r[14]
      ), o = !0);
    },
    p(h, [c]) {
      /*show_label*/
      h[2] ? l ? l.p(h, c) : (l = bu(h), l.c(), l.m(e, t)) : l && (l.d(1), l = null), (!s || c & /*size*/
      16) && ot(
        i,
        "small",
        /*size*/
        h[4] === "small"
      ), (!s || c & /*size*/
      16) && ot(
        i,
        "large",
        /*size*/
        h[4] === "large"
      ), (!s || c & /*size*/
      16) && ot(
        i,
        "medium",
        /*size*/
        h[4] === "medium"
      ), (!s || c & /*disabled*/
      128) && (e.disabled = /*disabled*/
      h[7]), (!s || c & /*label*/
      2) && Ti(
        e,
        "aria-label",
        /*label*/
        h[1]
      ), (!s || c & /*hasPopup*/
      256) && Ti(
        e,
        "aria-haspopup",
        /*hasPopup*/
        h[8]
      ), (!s || c & /*label*/
      2) && Ti(
        e,
        "title",
        /*label*/
        h[1]
      ), (!s || c & /*pending*/
      8) && ot(
        e,
        "pending",
        /*pending*/
        h[3]
      ), (!s || c & /*padded*/
      32) && ot(
        e,
        "padded",
        /*padded*/
        h[5]
      ), (!s || c & /*highlight*/
      64) && ot(
        e,
        "highlight",
        /*highlight*/
        h[6]
      ), (!s || c & /*transparent*/
      512) && ot(
        e,
        "transparent",
        /*transparent*/
        h[9]
      ), c & /*disabled, _color*/
      4224 && Zr(e, "color", !/*disabled*/
      h[7] && /*_color*/
      h[12] ? (
        /*_color*/
        h[12]
      ) : "var(--block-label-text-color)"), c & /*disabled, background*/
      1152 && Zr(e, "--bg-color", /*disabled*/
      h[7] ? "auto" : (
        /*background*/
        h[10]
      )), c & /*offset*/
      2048 && Zr(
        e,
        "margin-left",
        /*offset*/
        h[11] + "px"
      );
    },
    i(h) {
      s || (Zg(n.$$.fragment, h), s = !0);
    },
    o(h) {
      $g(n.$$.fragment, h), s = !1;
    },
    d(h) {
      h && h_(e), l && l.d(), zg(n), o = !1, a();
    }
  };
}
function Qg(r, e, t) {
  let i, { Icon: n } = e, { label: s = "" } = e, { show_label: o = !1 } = e, { pending: a = !1 } = e, { size: l = "small" } = e, { padded: h = !0 } = e, { highlight: c = !1 } = e, { disabled: u = !1 } = e, { hasPopup: d = !1 } = e, { color: f = "var(--block-label-text-color)" } = e, { transparent: p = !1 } = e, { background: _ = "var(--background-fill-primary)" } = e, { offset: m = 0 } = e;
  function y(v) {
    Gg.call(this, r, v);
  }
  return r.$$set = (v) => {
    "Icon" in v && t(0, n = v.Icon), "label" in v && t(1, s = v.label), "show_label" in v && t(2, o = v.show_label), "pending" in v && t(3, a = v.pending), "size" in v && t(4, l = v.size), "padded" in v && t(5, h = v.padded), "highlight" in v && t(6, c = v.highlight), "disabled" in v && t(7, u = v.disabled), "hasPopup" in v && t(8, d = v.hasPopup), "color" in v && t(13, f = v.color), "transparent" in v && t(9, p = v.transparent), "background" in v && t(10, _ = v.background), "offset" in v && t(11, m = v.offset);
  }, r.$$.update = () => {
    r.$$.dirty & /*highlight, color*/
    8256 && t(12, i = c ? "var(--color-accent)" : f);
  }, [
    n,
    s,
    o,
    a,
    l,
    h,
    c,
    u,
    d,
    p,
    _,
    m,
    i,
    f,
    y
  ];
}
class Pi extends Ug {
  constructor(e) {
    super(), Xg(this, e, Qg, Jg, jg, {
      Icon: 0,
      label: 1,
      show_label: 2,
      pending: 3,
      size: 4,
      padded: 5,
      highlight: 6,
      disabled: 7,
      hasPopup: 8,
      color: 13,
      transparent: 9,
      background: 10,
      offset: 11
    });
  }
}
const {
  SvelteComponent: e1,
  append: t1,
  attr: Wa,
  binding_callbacks: i1,
  create_slot: r1,
  detach: n1,
  element: wu,
  get_all_dirty_from_scope: s1,
  get_slot_changes: o1,
  init: a1,
  insert: l1,
  safe_not_equal: h1,
  toggle_class: Oi,
  transition_in: c1,
  transition_out: u1,
  update_slot_base: d1
} = window.__gradio__svelte__internal;
function f1(r) {
  let e, t, i;
  const n = (
    /*#slots*/
    r[5].default
  ), s = r1(
    n,
    r,
    /*$$scope*/
    r[4],
    null
  );
  return {
    c() {
      e = wu("div"), t = wu("div"), s && s.c(), Wa(t, "class", "icon svelte-3w3rth"), Wa(e, "class", "empty svelte-3w3rth"), Wa(e, "aria-label", "Empty value"), Oi(
        e,
        "small",
        /*size*/
        r[0] === "small"
      ), Oi(
        e,
        "large",
        /*size*/
        r[0] === "large"
      ), Oi(
        e,
        "unpadded_box",
        /*unpadded_box*/
        r[1]
      ), Oi(
        e,
        "small_parent",
        /*parent_height*/
        r[3]
      );
    },
    m(o, a) {
      l1(o, e, a), t1(e, t), s && s.m(t, null), r[6](e), i = !0;
    },
    p(o, [a]) {
      s && s.p && (!i || a & /*$$scope*/
      16) && d1(
        s,
        n,
        o,
        /*$$scope*/
        o[4],
        i ? o1(
          n,
          /*$$scope*/
          o[4],
          a,
          null
        ) : s1(
          /*$$scope*/
          o[4]
        ),
        null
      ), (!i || a & /*size*/
      1) && Oi(
        e,
        "small",
        /*size*/
        o[0] === "small"
      ), (!i || a & /*size*/
      1) && Oi(
        e,
        "large",
        /*size*/
        o[0] === "large"
      ), (!i || a & /*unpadded_box*/
      2) && Oi(
        e,
        "unpadded_box",
        /*unpadded_box*/
        o[1]
      ), (!i || a & /*parent_height*/
      8) && Oi(
        e,
        "small_parent",
        /*parent_height*/
        o[3]
      );
    },
    i(o) {
      i || (c1(s, o), i = !0);
    },
    o(o) {
      u1(s, o), i = !1;
    },
    d(o) {
      o && n1(e), s && s.d(o), r[6](null);
    }
  };
}
function p1(r, e, t) {
  let i, { $$slots: n = {}, $$scope: s } = e, { size: o = "small" } = e, { unpadded_box: a = !1 } = e, l;
  function h(u) {
    var d;
    if (!u)
      return !1;
    const { height: f } = u.getBoundingClientRect(), { height: p } = ((d = u.parentElement) === null || d === void 0 ? void 0 : d.getBoundingClientRect()) || { height: f };
    return f > p + 2;
  }
  function c(u) {
    i1[u ? "unshift" : "push"](() => {
      l = u, t(2, l);
    });
  }
  return r.$$set = (u) => {
    "size" in u && t(0, o = u.size), "unpadded_box" in u && t(1, a = u.unpadded_box), "$$scope" in u && t(4, s = u.$$scope);
  }, r.$$.update = () => {
    r.$$.dirty & /*el*/
    4 && t(3, i = h(l));
  }, [o, a, l, i, s, n, c];
}
class _1 extends e1 {
  constructor(e) {
    super(), a1(this, e, p1, f1, h1, { size: 0, unpadded_box: 1 });
  }
}
const {
  SvelteComponent: m1,
  append: xu,
  attr: dr,
  detach: g1,
  init: y1,
  insert: v1,
  noop: ja,
  safe_not_equal: b1,
  svg_element: qa
} = window.__gradio__svelte__internal;
function w1(r) {
  let e, t, i;
  return {
    c() {
      e = qa("svg"), t = qa("path"), i = qa("path"), dr(t, "d", "M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"), dr(t, "fill", "currentColor"), dr(i, "d", "M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"), dr(i, "fill", "currentColor"), dr(e, "width", "100%"), dr(e, "height", "100%"), dr(e, "viewBox", "0 0 32 32");
    },
    m(n, s) {
      v1(n, e, s), xu(e, t), xu(e, i);
    },
    p: ja,
    i: ja,
    o: ja,
    d(n) {
      n && g1(e);
    }
  };
}
let x1 = class extends m1 {
  constructor(e) {
    super(), y1(this, e, null, w1, b1, {});
  }
};
const {
  SvelteComponent: E1,
  append: Eu,
  attr: at,
  detach: T1,
  init: A1,
  insert: S1,
  noop: Ya,
  safe_not_equal: C1,
  svg_element: Ka
} = window.__gradio__svelte__internal;
function I1(r) {
  let e, t, i;
  return {
    c() {
      e = Ka("svg"), t = Ka("path"), i = Ka("circle"), at(t, "d", "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"), at(i, "cx", "12"), at(i, "cy", "13"), at(i, "r", "4"), at(e, "xmlns", "http://www.w3.org/2000/svg"), at(e, "width", "100%"), at(e, "height", "100%"), at(e, "viewBox", "0 0 24 24"), at(e, "fill", "none"), at(e, "stroke", "currentColor"), at(e, "stroke-width", "1.5"), at(e, "stroke-linecap", "round"), at(e, "stroke-linejoin", "round"), at(e, "class", "feather feather-camera");
    },
    m(n, s) {
      S1(n, e, s), Eu(e, t), Eu(e, i);
    },
    p: Ya,
    i: Ya,
    o: Ya,
    d(n) {
      n && T1(e);
    }
  };
}
class R1 extends E1 {
  constructor(e) {
    super(), A1(this, e, null, I1, C1, {});
  }
}
const {
  SvelteComponent: P1,
  append: M1,
  attr: Li,
  detach: k1,
  init: D1,
  insert: B1,
  noop: Za,
  safe_not_equal: F1,
  svg_element: Tu
} = window.__gradio__svelte__internal;
function O1(r) {
  let e, t;
  return {
    c() {
      e = Tu("svg"), t = Tu("polyline"), Li(t, "points", "20 6 9 17 4 12"), Li(e, "xmlns", "http://www.w3.org/2000/svg"), Li(e, "viewBox", "2 0 20 20"), Li(e, "fill", "none"), Li(e, "stroke", "currentColor"), Li(e, "stroke-width", "3"), Li(e, "stroke-linecap", "round"), Li(e, "stroke-linejoin", "round");
    },
    m(i, n) {
      B1(i, e, n), M1(e, t);
    },
    p: Za,
    i: Za,
    o: Za,
    d(i) {
      i && k1(e);
    }
  };
}
class L1 extends P1 {
  constructor(e) {
    super(), D1(this, e, null, O1, F1, {});
  }
}
const {
  SvelteComponent: N1,
  append: U1,
  attr: Ft,
  detach: G1,
  init: H1,
  insert: z1,
  noop: $a,
  safe_not_equal: X1,
  svg_element: Au
} = window.__gradio__svelte__internal;
function V1(r) {
  let e, t;
  return {
    c() {
      e = Au("svg"), t = Au("circle"), Ft(t, "cx", "12"), Ft(t, "cy", "12"), Ft(t, "r", "10"), Ft(e, "xmlns", "http://www.w3.org/2000/svg"), Ft(e, "width", "100%"), Ft(e, "height", "100%"), Ft(e, "viewBox", "0 0 24 24"), Ft(e, "stroke-width", "1.5"), Ft(e, "stroke-linecap", "round"), Ft(e, "stroke-linejoin", "round"), Ft(e, "class", "feather feather-circle");
    },
    m(i, n) {
      z1(i, e, n), U1(e, t);
    },
    p: $a,
    i: $a,
    o: $a,
    d(i) {
      i && G1(e);
    }
  };
}
let W1 = class extends N1 {
  constructor(e) {
    super(), H1(this, e, null, V1, X1, {});
  }
};
const {
  SvelteComponent: j1,
  append: Ja,
  attr: Ot,
  detach: q1,
  init: Y1,
  insert: K1,
  noop: Qa,
  safe_not_equal: Z1,
  set_style: ti,
  svg_element: Hs
} = window.__gradio__svelte__internal;
function $1(r) {
  let e, t, i, n;
  return {
    c() {
      e = Hs("svg"), t = Hs("g"), i = Hs("path"), n = Hs("path"), Ot(i, "d", "M18,6L6.087,17.913"), ti(i, "fill", "none"), ti(i, "fill-rule", "nonzero"), ti(i, "stroke-width", "2px"), Ot(t, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"), Ot(n, "d", "M4.364,4.364L19.636,19.636"), ti(n, "fill", "none"), ti(n, "fill-rule", "nonzero"), ti(n, "stroke-width", "2px"), Ot(e, "width", "100%"), Ot(e, "height", "100%"), Ot(e, "viewBox", "0 0 24 24"), Ot(e, "version", "1.1"), Ot(e, "xmlns", "http://www.w3.org/2000/svg"), Ot(e, "xmlns:xlink", "http://www.w3.org/1999/xlink"), Ot(e, "xml:space", "preserve"), Ot(e, "stroke", "currentColor"), ti(e, "fill-rule", "evenodd"), ti(e, "clip-rule", "evenodd"), ti(e, "stroke-linecap", "round"), ti(e, "stroke-linejoin", "round");
    },
    m(s, o) {
      K1(s, e, o), Ja(e, t), Ja(t, i), Ja(e, n);
    },
    p: Qa,
    i: Qa,
    o: Qa,
    d(s) {
      s && q1(e);
    }
  };
}
class J1 extends j1 {
  constructor(e) {
    super(), Y1(this, e, null, $1, Z1, {});
  }
}
const {
  SvelteComponent: Q1,
  append: ey,
  attr: Qn,
  detach: ty,
  init: iy,
  insert: ry,
  noop: el,
  safe_not_equal: ny,
  svg_element: Su
} = window.__gradio__svelte__internal;
function sy(r) {
  let e, t;
  return {
    c() {
      e = Su("svg"), t = Su("path"), Qn(t, "d", "M23,20a5,5,0,0,0-3.89,1.89L11.8,17.32a4.46,4.46,0,0,0,0-2.64l7.31-4.57A5,5,0,1,0,18,7a4.79,4.79,0,0,0,.2,1.32l-7.31,4.57a5,5,0,1,0,0,6.22l7.31,4.57A4.79,4.79,0,0,0,18,25a5,5,0,1,0,5-5ZM23,4a3,3,0,1,1-3,3A3,3,0,0,1,23,4ZM7,19a3,3,0,1,1,3-3A3,3,0,0,1,7,19Zm16,9a3,3,0,1,1,3-3A3,3,0,0,1,23,28Z"), Qn(t, "fill", "currentColor"), Qn(e, "id", "icon"), Qn(e, "xmlns", "http://www.w3.org/2000/svg"), Qn(e, "viewBox", "0 0 32 32");
    },
    m(i, n) {
      ry(i, e, n), ey(e, t);
    },
    p: el,
    i: el,
    o: el,
    d(i) {
      i && ty(e);
    }
  };
}
class oy extends Q1 {
  constructor(e) {
    super(), iy(this, e, null, sy, ny, {});
  }
}
const {
  SvelteComponent: ay,
  append: ly,
  attr: $r,
  detach: hy,
  init: cy,
  insert: uy,
  noop: tl,
  safe_not_equal: dy,
  svg_element: Cu
} = window.__gradio__svelte__internal;
function fy(r) {
  let e, t;
  return {
    c() {
      e = Cu("svg"), t = Cu("path"), $r(t, "fill", "currentColor"), $r(t, "d", "M17 23v-4H7q-.825 0-1.413-.588T5 17V7H1V5h4V1h2v16h16v2h-4v4h-2Zm0-8V7H9V5h8q.825 0 1.413.588T19 7v8h-2Z"), $r(e, "xmlns", "http://www.w3.org/2000/svg"), $r(e, "width", "100%"), $r(e, "height", "100%"), $r(e, "viewBox", "0 0 24 24");
    },
    m(i, n) {
      uy(i, e, n), ly(e, t);
    },
    p: tl,
    i: tl,
    o: tl,
    d(i) {
      i && hy(e);
    }
  };
}
let py = class extends ay {
  constructor(e) {
    super(), cy(this, e, null, fy, dy, {});
  }
};
const {
  SvelteComponent: _y,
  append: my,
  attr: Jr,
  detach: gy,
  init: yy,
  insert: vy,
  noop: il,
  safe_not_equal: by,
  svg_element: Iu
} = window.__gradio__svelte__internal;
function wy(r) {
  let e, t;
  return {
    c() {
      e = Iu("svg"), t = Iu("path"), Jr(t, "fill", "currentColor"), Jr(t, "d", "M26 24v4H6v-4H4v4a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2v-4zm0-10l-1.41-1.41L17 20.17V2h-2v18.17l-7.59-7.58L6 14l10 10l10-10z"), Jr(e, "xmlns", "http://www.w3.org/2000/svg"), Jr(e, "width", "100%"), Jr(e, "height", "100%"), Jr(e, "viewBox", "0 0 32 32");
    },
    m(i, n) {
      vy(i, e, n), my(e, t);
    },
    p: il,
    i: il,
    o: il,
    d(i) {
      i && gy(e);
    }
  };
}
class xy extends _y {
  constructor(e) {
    super(), yy(this, e, null, wy, by, {});
  }
}
const {
  SvelteComponent: Ey,
  append: Ty,
  attr: Qr,
  detach: Ay,
  init: Sy,
  insert: Cy,
  noop: rl,
  safe_not_equal: Iy,
  svg_element: Ru
} = window.__gradio__svelte__internal;
function Ry(r) {
  let e, t;
  return {
    c() {
      e = Ru("svg"), t = Ru("path"), Qr(t, "d", "M5 8l4 4 4-4z"), Qr(e, "class", "dropdown-arrow svelte-145leq6"), Qr(e, "xmlns", "http://www.w3.org/2000/svg"), Qr(e, "width", "100%"), Qr(e, "height", "100%"), Qr(e, "viewBox", "0 0 18 18");
    },
    m(i, n) {
      Cy(i, e, n), Ty(e, t);
    },
    p: rl,
    i: rl,
    o: rl,
    d(i) {
      i && Ay(e);
    }
  };
}
class u_ extends Ey {
  constructor(e) {
    super(), Sy(this, e, null, Ry, Iy, {});
  }
}
const {
  SvelteComponent: Py,
  append: nl,
  attr: Lt,
  detach: My,
  init: ky,
  insert: Dy,
  noop: sl,
  safe_not_equal: By,
  svg_element: zs
} = window.__gradio__svelte__internal;
function Fy(r) {
  let e, t, i, n;
  return {
    c() {
      e = zs("svg"), t = zs("g"), i = zs("path"), n = zs("path"), Lt(i, "fill", "currentColor"), Lt(i, "d", "m5.505 11.41l.53.53l-.53-.53ZM3 14.952h-.75H3ZM9.048 21v.75V21ZM11.41 5.505l-.53-.53l.53.53Zm1.831 12.34a.75.75 0 0 0 1.06-1.061l-1.06 1.06ZM7.216 9.697a.75.75 0 1 0-1.06 1.061l1.06-1.06Zm10.749 2.362l-5.905 5.905l1.06 1.06l5.905-5.904l-1.06-1.06Zm-11.93-.12l5.905-5.905l-1.06-1.06l-5.905 5.904l1.06 1.06Zm0 6.025c-.85-.85-1.433-1.436-1.812-1.933c-.367-.481-.473-.79-.473-1.08h-1.5c0 .749.312 1.375.78 1.99c.455.596 1.125 1.263 1.945 2.083l1.06-1.06Zm-1.06-7.086c-.82.82-1.49 1.488-1.945 2.084c-.468.614-.78 1.24-.78 1.99h1.5c0-.29.106-.6.473-1.08c.38-.498.962-1.083 1.812-1.933l-1.06-1.06Zm7.085 7.086c-.85.85-1.435 1.433-1.933 1.813c-.48.366-.79.472-1.08.472v1.5c.75 0 1.376-.312 1.99-.78c.596-.455 1.264-1.125 2.084-1.945l-1.06-1.06Zm-7.085 1.06c.82.82 1.487 1.49 2.084 1.945c.614.468 1.24.78 1.989.78v-1.5c-.29 0-.599-.106-1.08-.473c-.497-.38-1.083-.962-1.933-1.812l-1.06 1.06Zm12.99-12.99c.85.85 1.433 1.436 1.813 1.933c.366.481.472.79.472 1.08h1.5c0-.749-.312-1.375-.78-1.99c-.455-.596-1.125-1.263-1.945-2.083l-1.06 1.06Zm1.06 7.086c.82-.82 1.49-1.488 1.945-2.084c.468-.614.78-1.24.78-1.99h-1.5c0 .29-.106.6-.473 1.08c-.38.498-.962 1.083-1.812 1.933l1.06 1.06Zm0-8.146c-.82-.82-1.487-1.49-2.084-1.945c-.614-.468-1.24-.78-1.989-.78v1.5c.29 0 .599.106 1.08.473c.497.38 1.083.962 1.933 1.812l1.06-1.06Zm-7.085 1.06c.85-.85 1.435-1.433 1.933-1.812c.48-.367.79-.473 1.08-.473v-1.5c-.75 0-1.376.312-1.99.78c-.596.455-1.264 1.125-2.084 1.945l1.06 1.06Zm2.362 10.749L7.216 9.698l-1.06 1.061l7.085 7.085l1.06-1.06Z"), Lt(n, "stroke", "currentColor"), Lt(n, "stroke-linecap", "round"), Lt(n, "stroke-width", "1.5"), Lt(n, "d", "M9 21h12"), Lt(t, "fill", "none"), Lt(e, "xmlns", "http://www.w3.org/2000/svg"), Lt(e, "width", "100%"), Lt(e, "height", "100%"), Lt(e, "viewBox", "0 0 24 24");
    },
    m(s, o) {
      Dy(s, e, o), nl(e, t), nl(t, i), nl(t, n);
    },
    p: sl,
    i: sl,
    o: sl,
    d(s) {
      s && My(e);
    }
  };
}
class Oy extends Py {
  constructor(e) {
    super(), ky(this, e, null, Fy, By, {});
  }
}
const {
  SvelteComponent: Ly,
  append: ol,
  attr: Oe,
  detach: Ny,
  init: Uy,
  insert: Gy,
  noop: al,
  safe_not_equal: Hy,
  svg_element: Xs
} = window.__gradio__svelte__internal;
function zy(r) {
  let e, t, i, n;
  return {
    c() {
      e = Xs("svg"), t = Xs("rect"), i = Xs("circle"), n = Xs("polyline"), Oe(t, "x", "3"), Oe(t, "y", "3"), Oe(t, "width", "18"), Oe(t, "height", "18"), Oe(t, "rx", "2"), Oe(t, "ry", "2"), Oe(i, "cx", "8.5"), Oe(i, "cy", "8.5"), Oe(i, "r", "1.5"), Oe(n, "points", "21 15 16 10 5 21"), Oe(e, "xmlns", "http://www.w3.org/2000/svg"), Oe(e, "width", "100%"), Oe(e, "height", "100%"), Oe(e, "viewBox", "0 0 24 24"), Oe(e, "fill", "none"), Oe(e, "stroke", "currentColor"), Oe(e, "stroke-width", "1.5"), Oe(e, "stroke-linecap", "round"), Oe(e, "stroke-linejoin", "round"), Oe(e, "class", "feather feather-image");
    },
    m(s, o) {
      Gy(s, e, o), ol(e, t), ol(e, i), ol(e, n);
    },
    p: al,
    i: al,
    o: al,
    d(s) {
      s && Ny(e);
    }
  };
}
let Bs = class extends Ly {
  constructor(e) {
    super(), Uy(this, e, null, zy, Hy, {});
  }
};
const {
  SvelteComponent: Xy,
  append: Vy,
  attr: Vs,
  detach: Wy,
  init: jy,
  insert: qy,
  noop: ll,
  safe_not_equal: Yy,
  svg_element: Pu
} = window.__gradio__svelte__internal;
function Ky(r) {
  let e, t;
  return {
    c() {
      e = Pu("svg"), t = Pu("path"), Vs(t, "fill", "currentColor"), Vs(t, "d", "M13.75 2a2.25 2.25 0 0 1 2.236 2.002V4h1.764A2.25 2.25 0 0 1 20 6.25V11h-1.5V6.25a.75.75 0 0 0-.75-.75h-2.129c-.404.603-1.091 1-1.871 1h-3.5c-.78 0-1.467-.397-1.871-1H6.25a.75.75 0 0 0-.75.75v13.5c0 .414.336.75.75.75h4.78a4 4 0 0 0 .505 1.5H6.25A2.25 2.25 0 0 1 4 19.75V6.25A2.25 2.25 0 0 1 6.25 4h1.764a2.25 2.25 0 0 1 2.236-2zm2.245 2.096L16 4.25q0-.078-.005-.154M13.75 3.5h-3.5a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5M15 12a3 3 0 0 0-3 3v5c0 .556.151 1.077.415 1.524l3.494-3.494a2.25 2.25 0 0 1 3.182 0l3.494 3.494c.264-.447.415-.968.415-1.524v-5a3 3 0 0 0-3-3zm0 11a3 3 0 0 1-1.524-.415l3.494-3.494a.75.75 0 0 1 1.06 0l3.494 3.494A3 3 0 0 1 20 23zm5-7a1 1 0 1 1 0-2 1 1 0 0 1 0 2"), Vs(e, "xmlns", "http://www.w3.org/2000/svg"), Vs(e, "viewBox", "0 0 24 24");
    },
    m(i, n) {
      qy(i, e, n), Vy(e, t);
    },
    p: ll,
    i: ll,
    o: ll,
    d(i) {
      i && Wy(e);
    }
  };
}
class Zy extends Xy {
  constructor(e) {
    super(), jy(this, e, null, Ky, Yy, {});
  }
}
const {
  SvelteComponent: $y,
  append: Mu,
  attr: xt,
  detach: Jy,
  init: Qy,
  insert: ev,
  noop: hl,
  safe_not_equal: tv,
  svg_element: cl
} = window.__gradio__svelte__internal;
function iv(r) {
  let e, t, i;
  return {
    c() {
      e = cl("svg"), t = cl("path"), i = cl("path"), xt(t, "d", "M1.35327 10.9495L6.77663 15.158C7.12221 15.4229 7.50051 15.5553 7.91154 15.5553C8.32258 15.5553 8.70126 15.4229 9.0476 15.158L14.471 10.9495"), xt(t, "stroke", "currentColor"), xt(t, "stroke-width", "1.5"), xt(t, "stroke-linecap", "round"), xt(i, "d", "M7.23461 11.4324C7.23406 11.432 7.2335 11.4316 7.23295 11.4312L1.81496 7.2268C1.81471 7.22661 1.81446 7.22641 1.8142 7.22621C1.52269 6.99826 1.39429 6.73321 1.39429 6.37014C1.39429 6.00782 1.52236 5.74301 1.81325 5.51507C1.8136 5.5148 1.81394 5.51453 1.81428 5.51426L7.2331 1.30812C7.45645 1.13785 7.67632 1.06653 7.91159 1.06653C8.14692 1.06653 8.36622 1.13787 8.58861 1.30787C8.58915 1.30828 8.58969 1.30869 8.59023 1.30911L14.0082 5.51462C14.0085 5.51485 14.0088 5.51507 14.0091 5.51529C14.3008 5.74345 14.4289 6.00823 14.4289 6.37014C14.4289 6.73356 14.3006 6.99862 14.01 7.22634C14.0096 7.22662 14.0093 7.22689 14.0089 7.22717L8.59007 11.4322C8.36672 11.6024 8.14686 11.6738 7.91159 11.6738C7.67628 11.6738 7.45699 11.6024 7.23461 11.4324Z"), xt(i, "stroke", "currentColor"), xt(i, "stroke-width", "1.5"), xt(e, "width", "100%"), xt(e, "height", "100%"), xt(e, "viewBox", "0 0 17 17"), xt(e, "fill", "none"), xt(e, "xmlns", "http://www.w3.org/2000/svg");
    },
    m(n, s) {
      ev(n, e, s), Mu(e, t), Mu(e, i);
    },
    p: hl,
    i: hl,
    o: hl,
    d(n) {
      n && Jy(e);
    }
  };
}
class rv extends $y {
  constructor(e) {
    super(), Qy(this, e, null, iv, tv, {});
  }
}
const {
  SvelteComponent: nv,
  append: ku,
  attr: Et,
  detach: sv,
  init: ov,
  insert: av,
  noop: ul,
  safe_not_equal: lv,
  set_style: hv,
  svg_element: dl
} = window.__gradio__svelte__internal;
function cv(r) {
  let e, t, i;
  return {
    c() {
      e = dl("svg"), t = dl("polyline"), i = dl("path"), Et(t, "points", "1 4 1 10 7 10"), Et(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), Et(e, "xmlns", "http://www.w3.org/2000/svg"), Et(e, "width", "100%"), Et(e, "height", "100%"), Et(e, "viewBox", "0 0 24 24"), Et(e, "fill", "none"), Et(e, "stroke", "currentColor"), Et(e, "stroke-width", "2"), Et(e, "stroke-linecap", "round"), Et(e, "stroke-linejoin", "round"), Et(e, "class", "feather feather-rotate-ccw"), hv(e, "transform", "rotateY(180deg)");
    },
    m(n, s) {
      av(n, e, s), ku(e, t), ku(e, i);
    },
    p: ul,
    i: ul,
    o: ul,
    d(n) {
      n && sv(e);
    }
  };
}
class uv extends nv {
  constructor(e) {
    super(), ov(this, e, null, cv, lv, {});
  }
}
const {
  SvelteComponent: dv,
  append: fv,
  attr: lt,
  detach: pv,
  init: _v,
  insert: mv,
  noop: fl,
  safe_not_equal: gv,
  svg_element: Du
} = window.__gradio__svelte__internal;
function yv(r) {
  let e, t;
  return {
    c() {
      e = Du("svg"), t = Du("rect"), lt(t, "x", "3"), lt(t, "y", "3"), lt(t, "width", "18"), lt(t, "height", "18"), lt(t, "rx", "2"), lt(t, "ry", "2"), lt(e, "xmlns", "http://www.w3.org/2000/svg"), lt(e, "width", "100%"), lt(e, "height", "100%"), lt(e, "viewBox", "0 0 24 24"), lt(e, "stroke-width", "1.5"), lt(e, "stroke-linecap", "round"), lt(e, "stroke-linejoin", "round"), lt(e, "class", "feather feather-square");
    },
    m(i, n) {
      mv(i, e, n), fv(e, t);
    },
    p: fl,
    i: fl,
    o: fl,
    d(i) {
      i && pv(e);
    }
  };
}
class vv extends dv {
  constructor(e) {
    super(), _v(this, e, null, yv, gv, {});
  }
}
const {
  SvelteComponent: bv,
  append: Ni,
  attr: ke,
  detach: wv,
  init: xv,
  insert: Ev,
  noop: pl,
  safe_not_equal: Tv,
  svg_element: Ui,
  text: Av
} = window.__gradio__svelte__internal;
function Sv(r) {
  let e, t, i, n, s, o, a, l, h;
  return {
    c() {
      e = Ui("svg"), t = Ui("defs"), i = Ui("style"), n = Av(`.cls-1 {
				fill: none;
			}
		`), s = Ui("rect"), o = Ui("rect"), a = Ui("path"), l = Ui("rect"), h = Ui("rect"), ke(s, "x", "12"), ke(s, "y", "12"), ke(s, "width", "2"), ke(s, "height", "12"), ke(o, "x", "18"), ke(o, "y", "12"), ke(o, "width", "2"), ke(o, "height", "12"), ke(a, "d", "M4,6V8H6V28a2,2,0,0,0,2,2H24a2,2,0,0,0,2-2V8h2V6ZM8,28V8H24V28Z"), ke(l, "x", "12"), ke(l, "y", "2"), ke(l, "width", "8"), ke(l, "height", "2"), ke(h, "id", "_Transparent_Rectangle_"), ke(h, "data-name", "<Transparent Rectangle>"), ke(h, "class", "cls-1"), ke(h, "width", "32"), ke(h, "height", "32"), ke(e, "id", "icon"), ke(e, "xmlns", "http://www.w3.org/2000/svg"), ke(e, "viewBox", "0 0 32 32"), ke(e, "fill", "currentColor");
    },
    m(c, u) {
      Ev(c, e, u), Ni(e, t), Ni(t, i), Ni(i, n), Ni(e, s), Ni(e, o), Ni(e, a), Ni(e, l), Ni(e, h);
    },
    p: pl,
    i: pl,
    o: pl,
    d(c) {
      c && wv(e);
    }
  };
}
class Cv extends bv {
  constructor(e) {
    super(), xv(this, e, null, Sv, Tv, {});
  }
}
const {
  SvelteComponent: Iv,
  append: Bu,
  attr: Tt,
  detach: Rv,
  init: Pv,
  insert: Mv,
  noop: _l,
  safe_not_equal: kv,
  svg_element: ml
} = window.__gradio__svelte__internal;
function Dv(r) {
  let e, t, i;
  return {
    c() {
      e = ml("svg"), t = ml("polyline"), i = ml("path"), Tt(t, "points", "1 4 1 10 7 10"), Tt(i, "d", "M3.51 15a9 9 0 1 0 2.13-9.36L1 10"), Tt(e, "xmlns", "http://www.w3.org/2000/svg"), Tt(e, "width", "100%"), Tt(e, "height", "100%"), Tt(e, "viewBox", "0 0 24 24"), Tt(e, "fill", "none"), Tt(e, "stroke", "currentColor"), Tt(e, "stroke-width", "2"), Tt(e, "stroke-linecap", "round"), Tt(e, "stroke-linejoin", "round"), Tt(e, "class", "feather feather-rotate-ccw");
    },
    m(n, s) {
      Mv(n, e, s), Bu(e, t), Bu(e, i);
    },
    p: _l,
    i: _l,
    o: _l,
    d(n) {
      n && Rv(e);
    }
  };
}
class Bv extends Iv {
  constructor(e) {
    super(), Pv(this, e, null, Dv, kv, {});
  }
}
const {
  SvelteComponent: Fv,
  append: Fu,
  attr: Gi,
  detach: Ov,
  init: Lv,
  insert: Nv,
  noop: gl,
  safe_not_equal: Uv,
  svg_element: yl
} = window.__gradio__svelte__internal;
function Gv(r) {
  let e, t, i;
  return {
    c() {
      e = yl("svg"), t = yl("path"), i = yl("path"), Gi(t, "fill", "currentColor"), Gi(t, "d", "M12 2c-4.963 0-9 4.038-9 9c0 3.328 1.82 6.232 4.513 7.79l-2.067 1.378A1 1 0 0 0 6 22h12a1 1 0 0 0 .555-1.832l-2.067-1.378C19.18 17.232 21 14.328 21 11c0-4.962-4.037-9-9-9zm0 16c-3.859 0-7-3.141-7-7c0-3.86 3.141-7 7-7s7 3.14 7 7c0 3.859-3.141 7-7 7z"), Gi(i, "fill", "currentColor"), Gi(i, "d", "M12 6c-2.757 0-5 2.243-5 5s2.243 5 5 5s5-2.243 5-5s-2.243-5-5-5zm0 8c-1.654 0-3-1.346-3-3s1.346-3 3-3s3 1.346 3 3s-1.346 3-3 3z"), Gi(e, "xmlns", "http://www.w3.org/2000/svg"), Gi(e, "width", "100%"), Gi(e, "height", "100%"), Gi(e, "viewBox", "0 0 24 24");
    },
    m(n, s) {
      Nv(n, e, s), Fu(e, t), Fu(e, i);
    },
    p: gl,
    i: gl,
    o: gl,
    d(n) {
      n && Ov(e);
    }
  };
}
let d_ = class extends Fv {
  constructor(e) {
    super(), Lv(this, e, null, Gv, Uv, {});
  }
};
const {
  SvelteComponent: Hv,
  create_component: zv,
  destroy_component: Xv,
  init: Vv,
  mount_component: Wv,
  safe_not_equal: jv,
  transition_in: qv,
  transition_out: Yv
} = window.__gradio__svelte__internal, { createEventDispatcher: Kv } = window.__gradio__svelte__internal;
function Zv(r) {
  let e, t;
  return e = new Pi({
    props: {
      Icon: oy,
      label: (
        /*i18n*/
        r[2]("common.share")
      ),
      pending: (
        /*pending*/
        r[3]
      )
    }
  }), e.$on(
    "click",
    /*click_handler*/
    r[5]
  ), {
    c() {
      zv(e.$$.fragment);
    },
    m(i, n) {
      Wv(e, i, n), t = !0;
    },
    p(i, [n]) {
      const s = {};
      n & /*i18n*/
      4 && (s.label = /*i18n*/
      i[2]("common.share")), n & /*pending*/
      8 && (s.pending = /*pending*/
      i[3]), e.$set(s);
    },
    i(i) {
      t || (qv(e.$$.fragment, i), t = !0);
    },
    o(i) {
      Yv(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Xv(e, i);
    }
  };
}
function $v(r, e, t) {
  const i = Kv();
  let { formatter: n } = e, { value: s } = e, { i18n: o } = e, a = !1;
  const l = async () => {
    try {
      t(3, a = !0);
      const h = await n(s);
      i("share", { description: h });
    } catch (h) {
      console.error(h);
      let c = h instanceof Ao ? h.message : "Share failed.";
      i("error", c);
    } finally {
      t(3, a = !1);
    }
  };
  return r.$$set = (h) => {
    "formatter" in h && t(0, n = h.formatter), "value" in h && t(1, s = h.value), "i18n" in h && t(2, o = h.i18n);
  }, [n, s, o, a, i, l];
}
class Jv extends Hv {
  constructor(e) {
    super(), Vv(this, e, $v, Zv, jv, { formatter: 0, value: 1, i18n: 2 });
  }
}
const {
  SvelteComponent: Qv,
  attr: eb,
  create_slot: tb,
  detach: ib,
  element: rb,
  get_all_dirty_from_scope: nb,
  get_slot_changes: sb,
  init: ob,
  insert: ab,
  safe_not_equal: lb,
  toggle_class: Ou,
  transition_in: hb,
  transition_out: cb,
  update_slot_base: ub
} = window.__gradio__svelte__internal;
function db(r) {
  let e, t;
  const i = (
    /*#slots*/
    r[2].default
  ), n = tb(
    i,
    r,
    /*$$scope*/
    r[1],
    null
  );
  return {
    c() {
      e = rb("div"), n && n.c(), eb(e, "class", "svelte-q32hvf"), Ou(
        e,
        "show_border",
        /*show_border*/
        r[0]
      );
    },
    m(s, o) {
      ab(s, e, o), n && n.m(e, null), t = !0;
    },
    p(s, [o]) {
      n && n.p && (!t || o & /*$$scope*/
      2) && ub(
        n,
        i,
        s,
        /*$$scope*/
        s[1],
        t ? sb(
          i,
          /*$$scope*/
          s[1],
          o,
          null
        ) : nb(
          /*$$scope*/
          s[1]
        ),
        null
      ), (!t || o & /*show_border*/
      1) && Ou(
        e,
        "show_border",
        /*show_border*/
        s[0]
      );
    },
    i(s) {
      t || (hb(n, s), t = !0);
    },
    o(s) {
      cb(n, s), t = !1;
    },
    d(s) {
      s && ib(e), n && n.d(s);
    }
  };
}
function fb(r, e, t) {
  let { $$slots: i = {}, $$scope: n } = e, { show_border: s = !1 } = e;
  return r.$$set = (o) => {
    "show_border" in o && t(0, s = o.show_border), "$$scope" in o && t(1, n = o.$$scope);
  }, [s, n, i];
}
class pb extends Qv {
  constructor(e) {
    super(), ob(this, e, fb, db, lb, { show_border: 0 });
  }
}
const _b = (r) => {
  let e;
  if (r.currentTarget instanceof Element)
    e = r.currentTarget.querySelector("img");
  else
    return [NaN, NaN];
  const t = e.getBoundingClientRect(), i = e.naturalWidth / t.width, n = e.naturalHeight / t.height;
  if (i > n) {
    const a = e.naturalHeight / i, l = (t.height - a) / 2;
    var s = Math.round((r.clientX - t.left) * i), o = Math.round((r.clientY - t.top - l) * i);
  } else {
    const a = e.naturalWidth / n, l = (t.width - a) / 2;
    var s = Math.round((r.clientX - t.left - l) * n), o = Math.round((r.clientY - t.top) * n);
  }
  return s < 0 || s >= e.naturalWidth || o < 0 || o >= e.naturalHeight ? null : [s, o];
}, { setContext: P4, getContext: mb } = window.__gradio__svelte__internal, gb = "WORKER_PROXY_CONTEXT_KEY";
function f_() {
  return mb(gb);
}
function yb(r) {
  return r.host === window.location.host || r.host === "localhost:7860" || r.host === "127.0.0.1:7860" || // Ref: https://github.com/gradio-app/gradio/blob/v3.32.0/js/app/src/Index.svelte#L194
  r.host === "lite.local";
}
function p_(r, e) {
  const t = e.toLowerCase();
  for (const [i, n] of Object.entries(r))
    if (i.toLowerCase() === t)
      return n;
}
function __(r) {
  if (r == null)
    return !1;
  const e = new URL(r, window.location.href);
  return !(!yb(e) || e.protocol !== "http:" && e.protocol !== "https:");
}
async function vb(r) {
  if (r == null || !__(r))
    return r;
  const e = f_();
  if (e == null)
    return r;
  const i = new URL(r, window.location.href).pathname;
  return e.httpRequest({
    method: "GET",
    path: i,
    headers: {},
    query_string: ""
  }).then((n) => {
    if (n.status !== 200)
      throw new Error(`Failed to get file ${i} from the Wasm worker.`);
    const s = new Blob([n.body], {
      type: p_(n.headers, "content-type")
    });
    return URL.createObjectURL(s);
  });
}
const {
  SvelteComponent: bb,
  assign: qo,
  check_outros: m_,
  compute_rest_props: Lu,
  create_slot: zc,
  detach: Aa,
  element: g_,
  empty: y_,
  exclude_internal_props: wb,
  get_all_dirty_from_scope: Xc,
  get_slot_changes: Vc,
  get_spread_update: v_,
  group_outros: b_,
  init: xb,
  insert: Sa,
  listen: w_,
  prevent_default: Eb,
  safe_not_equal: Tb,
  set_attributes: Yo,
  transition_in: Fr,
  transition_out: Or,
  update_slot_base: Wc
} = window.__gradio__svelte__internal, { createEventDispatcher: Ab } = window.__gradio__svelte__internal;
function Sb(r) {
  let e, t, i, n, s;
  const o = (
    /*#slots*/
    r[8].default
  ), a = zc(
    o,
    r,
    /*$$scope*/
    r[7],
    null
  );
  let l = [
    { href: (
      /*href*/
      r[0]
    ) },
    {
      target: t = typeof window < "u" && window.__is_colab__ ? "_blank" : null
    },
    { rel: "noopener noreferrer" },
    { download: (
      /*download*/
      r[1]
    ) },
    /*$$restProps*/
    r[6]
  ], h = {};
  for (let c = 0; c < l.length; c += 1)
    h = qo(h, l[c]);
  return {
    c() {
      e = g_("a"), a && a.c(), Yo(e, h);
    },
    m(c, u) {
      Sa(c, e, u), a && a.m(e, null), i = !0, n || (s = w_(
        e,
        "click",
        /*dispatch*/
        r[3].bind(null, "click")
      ), n = !0);
    },
    p(c, u) {
      a && a.p && (!i || u & /*$$scope*/
      128) && Wc(
        a,
        o,
        c,
        /*$$scope*/
        c[7],
        i ? Vc(
          o,
          /*$$scope*/
          c[7],
          u,
          null
        ) : Xc(
          /*$$scope*/
          c[7]
        ),
        null
      ), Yo(e, h = v_(l, [
        (!i || u & /*href*/
        1) && { href: (
          /*href*/
          c[0]
        ) },
        { target: t },
        { rel: "noopener noreferrer" },
        (!i || u & /*download*/
        2) && { download: (
          /*download*/
          c[1]
        ) },
        u & /*$$restProps*/
        64 && /*$$restProps*/
        c[6]
      ]));
    },
    i(c) {
      i || (Fr(a, c), i = !0);
    },
    o(c) {
      Or(a, c), i = !1;
    },
    d(c) {
      c && Aa(e), a && a.d(c), n = !1, s();
    }
  };
}
function Cb(r) {
  let e, t, i, n;
  const s = [Rb, Ib], o = [];
  function a(l, h) {
    return (
      /*is_downloading*/
      l[2] ? 0 : 1
    );
  }
  return e = a(r), t = o[e] = s[e](r), {
    c() {
      t.c(), i = y_();
    },
    m(l, h) {
      o[e].m(l, h), Sa(l, i, h), n = !0;
    },
    p(l, h) {
      let c = e;
      e = a(l), e === c ? o[e].p(l, h) : (b_(), Or(o[c], 1, 1, () => {
        o[c] = null;
      }), m_(), t = o[e], t ? t.p(l, h) : (t = o[e] = s[e](l), t.c()), Fr(t, 1), t.m(i.parentNode, i));
    },
    i(l) {
      n || (Fr(t), n = !0);
    },
    o(l) {
      Or(t), n = !1;
    },
    d(l) {
      l && Aa(i), o[e].d(l);
    }
  };
}
function Ib(r) {
  let e, t, i, n;
  const s = (
    /*#slots*/
    r[8].default
  ), o = zc(
    s,
    r,
    /*$$scope*/
    r[7],
    null
  );
  let a = [
    /*$$restProps*/
    r[6],
    { href: (
      /*href*/
      r[0]
    ) }
  ], l = {};
  for (let h = 0; h < a.length; h += 1)
    l = qo(l, a[h]);
  return {
    c() {
      e = g_("a"), o && o.c(), Yo(e, l);
    },
    m(h, c) {
      Sa(h, e, c), o && o.m(e, null), t = !0, i || (n = w_(e, "click", Eb(
        /*wasm_click_handler*/
        r[5]
      )), i = !0);
    },
    p(h, c) {
      o && o.p && (!t || c & /*$$scope*/
      128) && Wc(
        o,
        s,
        h,
        /*$$scope*/
        h[7],
        t ? Vc(
          s,
          /*$$scope*/
          h[7],
          c,
          null
        ) : Xc(
          /*$$scope*/
          h[7]
        ),
        null
      ), Yo(e, l = v_(a, [
        c & /*$$restProps*/
        64 && /*$$restProps*/
        h[6],
        (!t || c & /*href*/
        1) && { href: (
          /*href*/
          h[0]
        ) }
      ]));
    },
    i(h) {
      t || (Fr(o, h), t = !0);
    },
    o(h) {
      Or(o, h), t = !1;
    },
    d(h) {
      h && Aa(e), o && o.d(h), i = !1, n();
    }
  };
}
function Rb(r) {
  let e;
  const t = (
    /*#slots*/
    r[8].default
  ), i = zc(
    t,
    r,
    /*$$scope*/
    r[7],
    null
  );
  return {
    c() {
      i && i.c();
    },
    m(n, s) {
      i && i.m(n, s), e = !0;
    },
    p(n, s) {
      i && i.p && (!e || s & /*$$scope*/
      128) && Wc(
        i,
        t,
        n,
        /*$$scope*/
        n[7],
        e ? Vc(
          t,
          /*$$scope*/
          n[7],
          s,
          null
        ) : Xc(
          /*$$scope*/
          n[7]
        ),
        null
      );
    },
    i(n) {
      e || (Fr(i, n), e = !0);
    },
    o(n) {
      Or(i, n), e = !1;
    },
    d(n) {
      i && i.d(n);
    }
  };
}
function Pb(r) {
  let e, t, i, n, s;
  const o = [Cb, Sb], a = [];
  function l(h, c) {
    return c & /*href*/
    1 && (e = null), e == null && (e = !!/*worker_proxy*/
    (h[4] && __(
      /*href*/
      h[0]
    ))), e ? 0 : 1;
  }
  return t = l(r, -1), i = a[t] = o[t](r), {
    c() {
      i.c(), n = y_();
    },
    m(h, c) {
      a[t].m(h, c), Sa(h, n, c), s = !0;
    },
    p(h, [c]) {
      let u = t;
      t = l(h, c), t === u ? a[t].p(h, c) : (b_(), Or(a[u], 1, 1, () => {
        a[u] = null;
      }), m_(), i = a[t], i ? i.p(h, c) : (i = a[t] = o[t](h), i.c()), Fr(i, 1), i.m(n.parentNode, n));
    },
    i(h) {
      s || (Fr(i), s = !0);
    },
    o(h) {
      Or(i), s = !1;
    },
    d(h) {
      h && Aa(n), a[t].d(h);
    }
  };
}
function Mb(r, e, t) {
  const i = ["href", "download"];
  let n = Lu(e, i), { $$slots: s = {}, $$scope: o } = e;
  var a = this && this.__awaiter || function(p, _, m, y) {
    function v(g) {
      return g instanceof m ? g : new m(function(b) {
        b(g);
      });
    }
    return new (m || (m = Promise))(function(g, b) {
      function w(E) {
        try {
          x(y.next(E));
        } catch (R) {
          b(R);
        }
      }
      function T(E) {
        try {
          x(y.throw(E));
        } catch (R) {
          b(R);
        }
      }
      function x(E) {
        E.done ? g(E.value) : v(E.value).then(w, T);
      }
      x((y = y.apply(p, _ || [])).next());
    });
  };
  let { href: l = void 0 } = e, { download: h } = e;
  const c = Ab();
  let u = !1;
  const d = f_();
  function f() {
    return a(this, void 0, void 0, function* () {
      if (u)
        return;
      if (c("click"), l == null)
        throw new Error("href is not defined.");
      if (d == null)
        throw new Error("Wasm worker proxy is not available.");
      const _ = new URL(l, window.location.href).pathname;
      t(2, u = !0), d.httpRequest({
        method: "GET",
        path: _,
        headers: {},
        query_string: ""
      }).then((m) => {
        if (m.status !== 200)
          throw new Error(`Failed to get file ${_} from the Wasm worker.`);
        const y = new Blob(
          [m.body],
          {
            type: p_(m.headers, "content-type")
          }
        ), v = URL.createObjectURL(y), g = document.createElement("a");
        g.href = v, g.download = h, g.click(), URL.revokeObjectURL(v);
      }).finally(() => {
        t(2, u = !1);
      });
    });
  }
  return r.$$set = (p) => {
    e = qo(qo({}, e), wb(p)), t(6, n = Lu(e, i)), "href" in p && t(0, l = p.href), "download" in p && t(1, h = p.download), "$$scope" in p && t(7, o = p.$$scope);
  }, [
    l,
    h,
    u,
    c,
    d,
    f,
    n,
    o,
    s
  ];
}
class kb extends bb {
  constructor(e) {
    super(), xb(this, e, Mb, Pb, Tb, { href: 0, download: 1 });
  }
}
const {
  SvelteComponent: Db,
  assign: Ch,
  compute_rest_props: Nu,
  detach: Bb,
  element: Fb,
  exclude_internal_props: Ob,
  get_spread_update: Lb,
  init: Nb,
  insert: Ub,
  noop: Uu,
  safe_not_equal: Gb,
  set_attributes: Gu,
  src_url_equal: Hb,
  toggle_class: Hu
} = window.__gradio__svelte__internal;
function zb(r) {
  let e, t, i = [
    {
      src: t = /*resolved_src*/
      r[0]
    },
    /*$$restProps*/
    r[1]
  ], n = {};
  for (let s = 0; s < i.length; s += 1)
    n = Ch(n, i[s]);
  return {
    c() {
      e = Fb("img"), Gu(e, n), Hu(e, "svelte-kxeri3", !0);
    },
    m(s, o) {
      Ub(s, e, o);
    },
    p(s, [o]) {
      Gu(e, n = Lb(i, [
        o & /*resolved_src*/
        1 && !Hb(e.src, t = /*resolved_src*/
        s[0]) && { src: t },
        o & /*$$restProps*/
        2 && /*$$restProps*/
        s[1]
      ])), Hu(e, "svelte-kxeri3", !0);
    },
    i: Uu,
    o: Uu,
    d(s) {
      s && Bb(e);
    }
  };
}
function Xb(r, e, t) {
  const i = ["src"];
  let n = Nu(e, i), { src: s = void 0 } = e, o, a;
  return r.$$set = (l) => {
    e = Ch(Ch({}, e), Ob(l)), t(1, n = Nu(e, i)), "src" in l && t(2, s = l.src);
  }, r.$$.update = () => {
    if (r.$$.dirty & /*src, latest_src*/
    12) {
      t(0, o = s), t(3, a = s);
      const l = s;
      vb(l).then((h) => {
        a === l && t(0, o = h);
      });
    }
  }, [o, n, s, a];
}
let Vb = class extends Db {
  constructor(e) {
    super(), Nb(this, e, Xb, zb, Gb, { src: 2 });
  }
};
const {
  SvelteComponent: Wb,
  append: zu,
  attr: vl,
  bubble: Xu,
  check_outros: Ih,
  create_component: Vr,
  destroy_component: Wr,
  detach: ms,
  element: bl,
  empty: jb,
  group_outros: Rh,
  init: qb,
  insert: gs,
  listen: Yb,
  mount_component: jr,
  safe_not_equal: Kb,
  space: Ph,
  toggle_class: Vu,
  transition_in: nt,
  transition_out: vt
} = window.__gradio__svelte__internal, { createEventDispatcher: Zb } = window.__gradio__svelte__internal;
function $b(r) {
  let e, t, i, n, s, o, a, l, h, c = (
    /*show_download_button*/
    r[3] && Wu(r)
  ), u = (
    /*show_share_button*/
    r[5] && ju(r)
  );
  return o = new Vb({
    props: {
      src: (
        /*value*/
        r[0].url
      ),
      alt: "",
      loading: "lazy"
    }
  }), {
    c() {
      e = bl("div"), c && c.c(), t = Ph(), u && u.c(), i = Ph(), n = bl("button"), s = bl("div"), Vr(o.$$.fragment), vl(e, "class", "icon-buttons svelte-n22rtv"), vl(s, "class", "image-container svelte-n22rtv"), Vu(
        s,
        "selectable",
        /*selectable*/
        r[4]
      ), vl(n, "class", "svelte-n22rtv");
    },
    m(d, f) {
      gs(d, e, f), c && c.m(e, null), zu(e, t), u && u.m(e, null), gs(d, i, f), gs(d, n, f), zu(n, s), jr(o, s, null), a = !0, l || (h = Yb(
        n,
        "click",
        /*handle_click*/
        r[7]
      ), l = !0);
    },
    p(d, f) {
      /*show_download_button*/
      d[3] ? c ? (c.p(d, f), f & /*show_download_button*/
      8 && nt(c, 1)) : (c = Wu(d), c.c(), nt(c, 1), c.m(e, t)) : c && (Rh(), vt(c, 1, 1, () => {
        c = null;
      }), Ih()), /*show_share_button*/
      d[5] ? u ? (u.p(d, f), f & /*show_share_button*/
      32 && nt(u, 1)) : (u = ju(d), u.c(), nt(u, 1), u.m(e, null)) : u && (Rh(), vt(u, 1, 1, () => {
        u = null;
      }), Ih());
      const p = {};
      f & /*value*/
      1 && (p.src = /*value*/
      d[0].url), o.$set(p), (!a || f & /*selectable*/
      16) && Vu(
        s,
        "selectable",
        /*selectable*/
        d[4]
      );
    },
    i(d) {
      a || (nt(c), nt(u), nt(o.$$.fragment, d), a = !0);
    },
    o(d) {
      vt(c), vt(u), vt(o.$$.fragment, d), a = !1;
    },
    d(d) {
      d && (ms(e), ms(i), ms(n)), c && c.d(), u && u.d(), Wr(o), l = !1, h();
    }
  };
}
function Jb(r) {
  let e, t;
  return e = new _1({
    props: {
      unpadded_box: !0,
      size: "large",
      $$slots: { default: [ew] },
      $$scope: { ctx: r }
    }
  }), {
    c() {
      Vr(e.$$.fragment);
    },
    m(i, n) {
      jr(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n & /*$$scope*/
      4096 && (s.$$scope = { dirty: n, ctx: i }), e.$set(s);
    },
    i(i) {
      t || (nt(e.$$.fragment, i), t = !0);
    },
    o(i) {
      vt(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Wr(e, i);
    }
  };
}
function Wu(r) {
  let e, t;
  return e = new kb({
    props: {
      href: (
        /*value*/
        r[0].url
      ),
      download: (
        /*value*/
        r[0].orig_name || "image"
      ),
      $$slots: { default: [Qb] },
      $$scope: { ctx: r }
    }
  }), {
    c() {
      Vr(e.$$.fragment);
    },
    m(i, n) {
      jr(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n & /*value*/
      1 && (s.href = /*value*/
      i[0].url), n & /*value*/
      1 && (s.download = /*value*/
      i[0].orig_name || "image"), n & /*$$scope, i18n*/
      4160 && (s.$$scope = { dirty: n, ctx: i }), e.$set(s);
    },
    i(i) {
      t || (nt(e.$$.fragment, i), t = !0);
    },
    o(i) {
      vt(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Wr(e, i);
    }
  };
}
function Qb(r) {
  let e, t;
  return e = new Pi({
    props: {
      Icon: xy,
      label: (
        /*i18n*/
        r[6]("common.download")
      )
    }
  }), {
    c() {
      Vr(e.$$.fragment);
    },
    m(i, n) {
      jr(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n & /*i18n*/
      64 && (s.label = /*i18n*/
      i[6]("common.download")), e.$set(s);
    },
    i(i) {
      t || (nt(e.$$.fragment, i), t = !0);
    },
    o(i) {
      vt(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Wr(e, i);
    }
  };
}
function ju(r) {
  let e, t;
  return e = new Jv({
    props: {
      i18n: (
        /*i18n*/
        r[6]
      ),
      formatter: (
        /*func*/
        r[8]
      ),
      value: (
        /*value*/
        r[0]
      )
    }
  }), e.$on(
    "share",
    /*share_handler*/
    r[9]
  ), e.$on(
    "error",
    /*error_handler*/
    r[10]
  ), {
    c() {
      Vr(e.$$.fragment);
    },
    m(i, n) {
      jr(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n & /*i18n*/
      64 && (s.i18n = /*i18n*/
      i[6]), n & /*value*/
      1 && (s.value = /*value*/
      i[0]), e.$set(s);
    },
    i(i) {
      t || (nt(e.$$.fragment, i), t = !0);
    },
    o(i) {
      vt(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Wr(e, i);
    }
  };
}
function ew(r) {
  let e, t;
  return e = new Bs({}), {
    c() {
      Vr(e.$$.fragment);
    },
    m(i, n) {
      jr(e, i, n), t = !0;
    },
    i(i) {
      t || (nt(e.$$.fragment, i), t = !0);
    },
    o(i) {
      vt(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Wr(e, i);
    }
  };
}
function tw(r) {
  let e, t, i, n, s, o;
  e = new l_({
    props: {
      show_label: (
        /*show_label*/
        r[2]
      ),
      Icon: Bs,
      label: (
        /*label*/
        r[1] || /*i18n*/
        r[6]("image.image")
      )
    }
  });
  const a = [Jb, $b], l = [];
  function h(c, u) {
    return (
      /*value*/
      c[0] === null || !/*value*/
      c[0].url ? 0 : 1
    );
  }
  return i = h(r), n = l[i] = a[i](r), {
    c() {
      Vr(e.$$.fragment), t = Ph(), n.c(), s = jb();
    },
    m(c, u) {
      jr(e, c, u), gs(c, t, u), l[i].m(c, u), gs(c, s, u), o = !0;
    },
    p(c, [u]) {
      const d = {};
      u & /*show_label*/
      4 && (d.show_label = /*show_label*/
      c[2]), u & /*label, i18n*/
      66 && (d.label = /*label*/
      c[1] || /*i18n*/
      c[6]("image.image")), e.$set(d);
      let f = i;
      i = h(c), i === f ? l[i].p(c, u) : (Rh(), vt(l[f], 1, 1, () => {
        l[f] = null;
      }), Ih(), n = l[i], n ? n.p(c, u) : (n = l[i] = a[i](c), n.c()), nt(n, 1), n.m(s.parentNode, s));
    },
    i(c) {
      o || (nt(e.$$.fragment, c), nt(n), o = !0);
    },
    o(c) {
      vt(e.$$.fragment, c), vt(n), o = !1;
    },
    d(c) {
      c && (ms(t), ms(s)), Wr(e, c), l[i].d(c);
    }
  };
}
function iw(r, e, t) {
  let { value: i } = e, { label: n = void 0 } = e, { show_label: s } = e, { show_download_button: o = !0 } = e, { selectable: a = !1 } = e, { show_share_button: l = !1 } = e, { i18n: h } = e;
  const c = Zb(), u = (_) => {
    let m = _b(_);
    m && c("select", { index: m, value: null });
  }, d = async (_) => _ ? `<img src="${await ag(_)}" />` : "";
  function f(_) {
    Xu.call(this, r, _);
  }
  function p(_) {
    Xu.call(this, r, _);
  }
  return r.$$set = (_) => {
    "value" in _ && t(0, i = _.value), "label" in _ && t(1, n = _.label), "show_label" in _ && t(2, s = _.show_label), "show_download_button" in _ && t(3, o = _.show_download_button), "selectable" in _ && t(4, a = _.selectable), "show_share_button" in _ && t(5, l = _.show_share_button), "i18n" in _ && t(6, h = _.i18n);
  }, [
    i,
    n,
    s,
    o,
    a,
    l,
    h,
    u,
    d,
    f,
    p
  ];
}
class rw extends Wb {
  constructor(e) {
    super(), qb(this, e, iw, tw, Kb, {
      value: 0,
      label: 1,
      show_label: 2,
      show_download_button: 3,
      selectable: 4,
      show_share_button: 5,
      i18n: 6
    });
  }
}
var nw = Object.defineProperty, sw = (r, e, t) => e in r ? nw(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, bi = (r, e, t) => (sw(r, typeof e != "symbol" ? e + "" : e, t), t);
new Intl.Collator(0, { numeric: 1 }).compare;
async function ys(r, e) {
  return r.map(
    (t) => new ow({
      path: t.name,
      orig_name: t.name,
      blob: t,
      size: t.size,
      mime_type: t.type,
      is_stream: e
    })
  );
}
class ow {
  constructor({
    path: e,
    url: t,
    orig_name: i,
    size: n,
    blob: s,
    is_stream: o,
    mime_type: a,
    alt_text: l
  }) {
    bi(this, "path"), bi(this, "url"), bi(this, "orig_name"), bi(this, "size"), bi(this, "blob"), bi(this, "is_stream"), bi(this, "mime_type"), bi(this, "alt_text"), bi(this, "meta", { _type: "gradio.FileData" }), this.path = e, this.url = t, this.orig_name = i, this.size = n, this.blob = t ? void 0 : s, this.is_stream = o, this.mime_type = a, this.alt_text = l;
  }
}
const {
  SvelteComponent: aw,
  append: Ws,
  attr: wl,
  create_component: lw,
  destroy_component: hw,
  detach: cw,
  element: xl,
  init: uw,
  insert: dw,
  listen: fw,
  mount_component: pw,
  noop: _w,
  safe_not_equal: mw,
  set_style: gw,
  space: yw,
  text: vw,
  transition_in: bw,
  transition_out: ww
} = window.__gradio__svelte__internal, { createEventDispatcher: xw } = window.__gradio__svelte__internal;
function Ew(r) {
  let e, t, i, n, s, o = "Click to Access Webcam", a, l, h, c;
  return n = new d_({}), {
    c() {
      e = xl("button"), t = xl("div"), i = xl("span"), lw(n.$$.fragment), s = yw(), a = vw(o), wl(i, "class", "icon-wrap svelte-fjcd9c"), wl(t, "class", "wrap svelte-fjcd9c"), wl(e, "class", "svelte-fjcd9c"), gw(e, "height", "100%");
    },
    m(u, d) {
      dw(u, e, d), Ws(e, t), Ws(t, i), pw(n, i, null), Ws(t, s), Ws(t, a), l = !0, h || (c = fw(
        e,
        "click",
        /*click_handler*/
        r[1]
      ), h = !0);
    },
    p: _w,
    i(u) {
      l || (bw(n.$$.fragment, u), l = !0);
    },
    o(u) {
      ww(n.$$.fragment, u), l = !1;
    },
    d(u) {
      u && cw(e), hw(n), h = !1, c();
    }
  };
}
function Tw(r) {
  const e = xw();
  return [e, () => e("click")];
}
class Aw extends aw {
  constructor(e) {
    super(), uw(this, e, Tw, Ew, mw, {});
  }
}
function So() {
}
const Sw = (r) => r;
function Cw(r, e) {
  return r != r ? e == e : r !== e || r && typeof r == "object" || typeof r == "function";
}
const x_ = typeof window < "u";
let qu = x_ ? () => window.performance.now() : () => Date.now(), E_ = x_ ? (r) => requestAnimationFrame(r) : So;
const En = /* @__PURE__ */ new Set();
function T_(r) {
  En.forEach((e) => {
    e.c(r) || (En.delete(e), e.f());
  }), En.size !== 0 && E_(T_);
}
function Iw(r) {
  let e;
  return En.size === 0 && E_(T_), {
    promise: new Promise((t) => {
      En.add(e = { c: r, f: t });
    }),
    abort() {
      En.delete(e);
    }
  };
}
function Rw(r, { delay: e = 0, duration: t = 400, easing: i = Sw } = {}) {
  const n = +getComputedStyle(r).opacity;
  return {
    delay: e,
    duration: t,
    easing: i,
    css: (s) => `opacity: ${s * n}`
  };
}
const en = [];
function rt(r, e = So) {
  let t;
  const i = /* @__PURE__ */ new Set();
  function n(a) {
    if (Cw(r, a) && (r = a, t)) {
      const l = !en.length;
      for (const h of i)
        h[1](), en.push(h, r);
      if (l) {
        for (let h = 0; h < en.length; h += 2)
          en[h][0](en[h + 1]);
        en.length = 0;
      }
    }
  }
  function s(a) {
    n(a(r));
  }
  function o(a, l = So) {
    const h = [a, l];
    return i.add(h), i.size === 1 && (t = e(n, s) || So), a(r), () => {
      i.delete(h), i.size === 0 && t && (t(), t = null);
    };
  }
  return { set: n, update: s, subscribe: o };
}
function Yu(r) {
  return Object.prototype.toString.call(r) === "[object Date]";
}
function Mh(r, e, t, i) {
  if (typeof t == "number" || Yu(t)) {
    const n = i - t, s = (t - e) / (r.dt || 1 / 60), o = r.opts.stiffness * n, a = r.opts.damping * s, l = (o - a) * r.inv_mass, h = (s + l) * r.dt;
    return Math.abs(h) < r.opts.precision && Math.abs(n) < r.opts.precision ? i : (r.settled = !1, Yu(t) ? new Date(t.getTime() + h) : t + h);
  } else {
    if (Array.isArray(t))
      return t.map(
        (n, s) => Mh(r, e[s], t[s], i[s])
      );
    if (typeof t == "object") {
      const n = {};
      for (const s in t)
        n[s] = Mh(r, e[s], t[s], i[s]);
      return n;
    } else
      throw new Error(`Cannot spring ${typeof t} values`);
  }
}
function Ko(r, e = {}) {
  const t = rt(r), { stiffness: i = 0.15, damping: n = 0.8, precision: s = 0.01 } = e;
  let o, a, l, h = r, c = r, u = 1, d = 0, f = !1;
  function p(m, y = {}) {
    c = m;
    const v = l = {};
    return r == null || y.hard || _.stiffness >= 1 && _.damping >= 1 ? (f = !0, o = qu(), h = m, t.set(r = c), Promise.resolve()) : (y.soft && (d = 1 / ((y.soft === !0 ? 0.5 : +y.soft) * 60), u = 0), a || (o = qu(), f = !1, a = Iw((g) => {
      if (f)
        return f = !1, a = null, !1;
      u = Math.min(u + d, 1);
      const b = {
        inv_mass: u,
        opts: _,
        settled: !0,
        dt: (g - o) * 60 / 1e3
      }, w = Mh(b, h, r, c);
      return o = g, h = r, t.set(r = w), b.settled && (a = null), !b.settled;
    })), new Promise((g) => {
      a.promise.then(() => {
        v === l && g();
      });
    }));
  }
  const _ = {
    set: p,
    update: (m, y) => p(m(c, r), y),
    subscribe: t.subscribe,
    stiffness: i,
    damping: n,
    precision: s
  };
  return _;
}
function Pw() {
  return navigator.mediaDevices.enumerateDevices();
}
function Mw(r, e) {
  e.srcObject = r, e.muted = !0, e.play();
}
async function Ku(r, e, t) {
  const i = {
    width: { ideal: 1920 },
    height: { ideal: 1440 }
  }, n = {
    video: t ? { deviceId: { exact: t }, ...i } : i,
    audio: r
  };
  return navigator.mediaDevices.getUserMedia(n).then((s) => (Mw(s, e), s));
}
function kw(r) {
  return r.filter(
    (t) => t.kind === "videoinput"
  );
}
const {
  SvelteComponent: Dw,
  action_destroyer: Bw,
  add_render_callback: Fw,
  append: ki,
  attr: Ne,
  binding_callbacks: Ow,
  check_outros: vs,
  create_component: zn,
  create_in_transition: Lw,
  destroy_component: Xn,
  destroy_each: Nw,
  detach: dt,
  element: wt,
  empty: jc,
  ensure_array_like: Zu,
  group_outros: bs,
  init: Uw,
  insert: ft,
  listen: Zo,
  mount_component: Vn,
  noop: qc,
  run_all: Gw,
  safe_not_equal: Hw,
  set_data: A_,
  set_input_value: kh,
  space: Rs,
  stop_propagation: zw,
  text: S_,
  toggle_class: js,
  transition_in: Xe,
  transition_out: $e
} = window.__gradio__svelte__internal, { createEventDispatcher: Xw, onMount: Vw } = window.__gradio__svelte__internal;
function $u(r, e, t) {
  const i = r.slice();
  return i[32] = e[t], i;
}
function Ww(r) {
  let e, t, i, n, s, o, a, l, h, c, u;
  const d = [Yw, qw], f = [];
  function p(y, v) {
    return (
      /*mode*/
      y[1] === "video" || /*streaming*/
      y[0] ? 0 : 1
    );
  }
  i = p(r), n = f[i] = d[i](r);
  let _ = !/*recording*/
  r[8] && Ju(r), m = (
    /*options_open*/
    r[10] && /*selected_device*/
    r[7] && Qu(r)
  );
  return {
    c() {
      e = wt("div"), t = wt("button"), n.c(), o = Rs(), _ && _.c(), a = Rs(), m && m.c(), l = jc(), Ne(t, "aria-label", s = /*mode*/
      r[1] === "image" ? "capture photo" : "start recording"), Ne(t, "class", "svelte-8hqvb6"), Ne(e, "class", "button-wrap svelte-8hqvb6");
    },
    m(y, v) {
      ft(y, e, v), ki(e, t), f[i].m(t, null), ki(e, o), _ && _.m(e, null), ft(y, a, v), m && m.m(y, v), ft(y, l, v), h = !0, c || (u = Zo(
        t,
        "click",
        /*record_video_or_photo*/
        r[13]
      ), c = !0);
    },
    p(y, v) {
      let g = i;
      i = p(y), i === g ? f[i].p(y, v) : (bs(), $e(f[g], 1, 1, () => {
        f[g] = null;
      }), vs(), n = f[i], n ? n.p(y, v) : (n = f[i] = d[i](y), n.c()), Xe(n, 1), n.m(t, null)), (!h || v[0] & /*mode*/
      2 && s !== (s = /*mode*/
      y[1] === "image" ? "capture photo" : "start recording")) && Ne(t, "aria-label", s), /*recording*/
      y[8] ? _ && (bs(), $e(_, 1, 1, () => {
        _ = null;
      }), vs()) : _ ? (_.p(y, v), v[0] & /*recording*/
      256 && Xe(_, 1)) : (_ = Ju(y), _.c(), Xe(_, 1), _.m(e, null)), /*options_open*/
      y[10] && /*selected_device*/
      y[7] ? m ? (m.p(y, v), v[0] & /*options_open, selected_device*/
      1152 && Xe(m, 1)) : (m = Qu(y), m.c(), Xe(m, 1), m.m(l.parentNode, l)) : m && (bs(), $e(m, 1, 1, () => {
        m = null;
      }), vs());
    },
    i(y) {
      h || (Xe(n), Xe(_), Xe(m), h = !0);
    },
    o(y) {
      $e(n), $e(_), $e(m), h = !1;
    },
    d(y) {
      y && (dt(e), dt(a), dt(l)), f[i].d(), _ && _.d(), m && m.d(y), c = !1, u();
    }
  };
}
function jw(r) {
  let e, t, i, n;
  return t = new Aw({}), t.$on(
    "click",
    /*click_handler*/
    r[20]
  ), {
    c() {
      e = wt("div"), zn(t.$$.fragment), Ne(e, "title", "grant webcam access");
    },
    m(s, o) {
      ft(s, e, o), Vn(t, e, null), n = !0;
    },
    p: qc,
    i(s) {
      n || (Xe(t.$$.fragment, s), s && (i || Fw(() => {
        i = Lw(e, Rw, { delay: 100, duration: 200 }), i.start();
      })), n = !0);
    },
    o(s) {
      $e(t.$$.fragment, s), n = !1;
    },
    d(s) {
      s && dt(e), Xn(t);
    }
  };
}
function qw(r) {
  let e, t, i;
  return t = new R1({}), {
    c() {
      e = wt("div"), zn(t.$$.fragment), Ne(e, "class", "icon svelte-8hqvb6"), Ne(e, "title", "capture photo");
    },
    m(n, s) {
      ft(n, e, s), Vn(t, e, null), i = !0;
    },
    p: qc,
    i(n) {
      i || (Xe(t.$$.fragment, n), i = !0);
    },
    o(n) {
      $e(t.$$.fragment, n), i = !1;
    },
    d(n) {
      n && dt(e), Xn(t);
    }
  };
}
function Yw(r) {
  let e, t, i, n;
  const s = [Zw, Kw], o = [];
  function a(l, h) {
    return (
      /*recording*/
      l[8] ? 0 : 1
    );
  }
  return e = a(r), t = o[e] = s[e](r), {
    c() {
      t.c(), i = jc();
    },
    m(l, h) {
      o[e].m(l, h), ft(l, i, h), n = !0;
    },
    p(l, h) {
      let c = e;
      e = a(l), e !== c && (bs(), $e(o[c], 1, 1, () => {
        o[c] = null;
      }), vs(), t = o[e], t || (t = o[e] = s[e](l), t.c()), Xe(t, 1), t.m(i.parentNode, i));
    },
    i(l) {
      n || (Xe(t), n = !0);
    },
    o(l) {
      $e(t), n = !1;
    },
    d(l) {
      l && dt(i), o[e].d(l);
    }
  };
}
function Kw(r) {
  let e, t, i;
  return t = new W1({}), {
    c() {
      e = wt("div"), zn(t.$$.fragment), Ne(e, "class", "icon red svelte-8hqvb6"), Ne(e, "title", "start recording");
    },
    m(n, s) {
      ft(n, e, s), Vn(t, e, null), i = !0;
    },
    i(n) {
      i || (Xe(t.$$.fragment, n), i = !0);
    },
    o(n) {
      $e(t.$$.fragment, n), i = !1;
    },
    d(n) {
      n && dt(e), Xn(t);
    }
  };
}
function Zw(r) {
  let e, t, i;
  return t = new vv({}), {
    c() {
      e = wt("div"), zn(t.$$.fragment), Ne(e, "class", "icon red svelte-8hqvb6"), Ne(e, "title", "stop recording");
    },
    m(n, s) {
      ft(n, e, s), Vn(t, e, null), i = !0;
    },
    i(n) {
      i || (Xe(t.$$.fragment, n), i = !0);
    },
    o(n) {
      $e(t.$$.fragment, n), i = !1;
    },
    d(n) {
      n && dt(e), Xn(t);
    }
  };
}
function Ju(r) {
  let e, t, i, n, s;
  return t = new u_({}), {
    c() {
      e = wt("button"), zn(t.$$.fragment), Ne(e, "class", "icon svelte-8hqvb6"), Ne(e, "aria-label", "select input source");
    },
    m(o, a) {
      ft(o, e, a), Vn(t, e, null), i = !0, n || (s = Zo(
        e,
        "click",
        /*click_handler_1*/
        r[21]
      ), n = !0);
    },
    p: qc,
    i(o) {
      i || (Xe(t.$$.fragment, o), i = !0);
    },
    o(o) {
      $e(t.$$.fragment, o), i = !1;
    },
    d(o) {
      o && dt(e), Xn(t), n = !1, s();
    }
  };
}
function Qu(r) {
  let e, t, i, n, s, o, a;
  i = new u_({});
  function l(u, d) {
    return (
      /*available_video_devices*/
      u[6].length === 0 ? Jw : $w
    );
  }
  let h = l(r), c = h(r);
  return {
    c() {
      e = wt("select"), t = wt("button"), zn(i.$$.fragment), n = Rs(), c.c(), Ne(t, "class", "inset-icon svelte-8hqvb6"), Ne(e, "class", "select-wrap svelte-8hqvb6"), Ne(e, "aria-label", "select source");
    },
    m(u, d) {
      ft(u, e, d), ki(e, t), Vn(i, t, null), ki(t, n), c.m(e, null), s = !0, o || (a = [
        Zo(t, "click", zw(
          /*click_handler_2*/
          r[22]
        )),
        Bw(Yc.call(
          null,
          e,
          /*handle_click_outside*/
          r[14]
        )),
        Zo(
          e,
          "change",
          /*handle_device_change*/
          r[11]
        )
      ], o = !0);
    },
    p(u, d) {
      h === (h = l(u)) && c ? c.p(u, d) : (c.d(1), c = h(u), c && (c.c(), c.m(e, null)));
    },
    i(u) {
      s || (Xe(i.$$.fragment, u), s = !0);
    },
    o(u) {
      $e(i.$$.fragment, u), s = !1;
    },
    d(u) {
      u && dt(e), Xn(i), c.d(), o = !1, Gw(a);
    }
  };
}
function $w(r) {
  let e, t = Zu(
    /*available_video_devices*/
    r[6]
  ), i = [];
  for (let n = 0; n < t.length; n += 1)
    i[n] = ed($u(r, t, n));
  return {
    c() {
      for (let n = 0; n < i.length; n += 1)
        i[n].c();
      e = jc();
    },
    m(n, s) {
      for (let o = 0; o < i.length; o += 1)
        i[o] && i[o].m(n, s);
      ft(n, e, s);
    },
    p(n, s) {
      if (s[0] & /*available_video_devices, selected_device*/
      192) {
        t = Zu(
          /*available_video_devices*/
          n[6]
        );
        let o;
        for (o = 0; o < t.length; o += 1) {
          const a = $u(n, t, o);
          i[o] ? i[o].p(a, s) : (i[o] = ed(a), i[o].c(), i[o].m(e.parentNode, e));
        }
        for (; o < i.length; o += 1)
          i[o].d(1);
        i.length = t.length;
      }
    },
    d(n) {
      n && dt(e), Nw(i, n);
    }
  };
}
function Jw(r) {
  let e, t = (
    /*i18n*/
    r[3]("common.no_devices") + ""
  ), i;
  return {
    c() {
      e = wt("option"), i = S_(t), e.__value = "", kh(e, e.__value), Ne(e, "class", "svelte-8hqvb6");
    },
    m(n, s) {
      ft(n, e, s), ki(e, i);
    },
    p(n, s) {
      s[0] & /*i18n*/
      8 && t !== (t = /*i18n*/
      n[3]("common.no_devices") + "") && A_(i, t);
    },
    d(n) {
      n && dt(e);
    }
  };
}
function ed(r) {
  let e, t = (
    /*device*/
    r[32].label + ""
  ), i, n, s, o;
  return {
    c() {
      e = wt("option"), i = S_(t), n = Rs(), e.__value = s = /*device*/
      r[32].deviceId, kh(e, e.__value), e.selected = o = /*selected_device*/
      r[7].deviceId === /*device*/
      r[32].deviceId, Ne(e, "class", "svelte-8hqvb6");
    },
    m(a, l) {
      ft(a, e, l), ki(e, i), ki(e, n);
    },
    p(a, l) {
      l[0] & /*available_video_devices*/
      64 && t !== (t = /*device*/
      a[32].label + "") && A_(i, t), l[0] & /*available_video_devices*/
      64 && s !== (s = /*device*/
      a[32].deviceId) && (e.__value = s, kh(e, e.__value)), l[0] & /*selected_device, available_video_devices*/
      192 && o !== (o = /*selected_device*/
      a[7].deviceId === /*device*/
      a[32].deviceId) && (e.selected = o);
    },
    d(a) {
      a && dt(e);
    }
  };
}
function Qw(r) {
  let e, t, i, n, s, o;
  const a = [jw, Ww], l = [];
  function h(c, u) {
    return (
      /*webcam_accessed*/
      c[9] ? 1 : 0
    );
  }
  return n = h(r), s = l[n] = a[n](r), {
    c() {
      e = wt("div"), t = wt("video"), i = Rs(), s.c(), Ne(t, "class", "svelte-8hqvb6"), js(
        t,
        "flip",
        /*mirror_webcam*/
        r[2]
      ), js(t, "hide", !/*webcam_accessed*/
      r[9]), Ne(e, "class", "wrap svelte-8hqvb6");
    },
    m(c, u) {
      ft(c, e, u), ki(e, t), r[19](t), ki(e, i), l[n].m(e, null), o = !0;
    },
    p(c, u) {
      (!o || u[0] & /*mirror_webcam*/
      4) && js(
        t,
        "flip",
        /*mirror_webcam*/
        c[2]
      ), (!o || u[0] & /*webcam_accessed*/
      512) && js(t, "hide", !/*webcam_accessed*/
      c[9]);
      let d = n;
      n = h(c), n === d ? l[n].p(c, u) : (bs(), $e(l[d], 1, 1, () => {
        l[d] = null;
      }), vs(), s = l[n], s ? s.p(c, u) : (s = l[n] = a[n](c), s.c()), Xe(s, 1), s.m(e, null));
    },
    i(c) {
      o || (Xe(s), o = !0);
    },
    o(c) {
      $e(s), o = !1;
    },
    d(c) {
      c && dt(e), r[19](null), l[n].d();
    }
  };
}
function Yc(r, e) {
  const t = (i) => {
    r && !r.contains(i.target) && !i.defaultPrevented && e(i);
  };
  return document.addEventListener("click", t, !0), {
    destroy() {
      document.removeEventListener("click", t, !0);
    }
  };
}
function ex(r, e, t) {
  var i = this && this.__awaiter || function(D, N, I, S) {
    function z(V) {
      return V instanceof I ? V : new I(function($) {
        $(V);
      });
    }
    return new (I || (I = Promise))(function(V, $) {
      function P(X) {
        try {
          A(S.next(X));
        } catch (te) {
          $(te);
        }
      }
      function ie(X) {
        try {
          A(S.throw(X));
        } catch (te) {
          $(te);
        }
      }
      function A(X) {
        X.done ? V(X.value) : z(X.value).then(P, ie);
      }
      A((S = S.apply(D, N || [])).next());
    });
  };
  let n, s = [], o = null, a, { streaming: l = !1 } = e, { pending: h = !1 } = e, { root: c = "" } = e, { mode: u = "image" } = e, { mirror_webcam: d } = e, { include_audio: f } = e, { i18n: p } = e, { upload: _ } = e;
  const m = Xw();
  Vw(() => a = document.createElement("canvas"));
  const y = (D) => i(void 0, void 0, void 0, function* () {
    const I = D.target.value;
    yield Ku(f, n, I).then((S) => i(void 0, void 0, void 0, function* () {
      T = S, t(7, o = s.find((z) => z.deviceId === I) || null), t(10, B = !1);
    }));
  });
  function v() {
    return i(this, void 0, void 0, function* () {
      try {
        Ku(f, n).then((D) => i(this, void 0, void 0, function* () {
          t(9, k = !0), t(6, s = yield Pw()), T = D;
        })).then(() => kw(s)).then((D) => {
          t(6, s = D);
          const N = T.getTracks().map((I) => {
            var S;
            return (S = I.getSettings()) === null || S === void 0 ? void 0 : S.deviceId;
          })[0];
          t(7, o = N && D.find((I) => I.deviceId === N) || s[0]);
        }), (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) && m("error", p("image.no_webcam_support"));
      } catch (D) {
        if (D instanceof DOMException && D.name == "NotAllowedError")
          m("error", p("image.allow_webcam_access"));
        else
          throw D;
      }
    });
  }
  function g() {
    var D = a.getContext("2d");
    (!l || l && b) && n.videoWidth && n.videoHeight && (a.width = n.videoWidth, a.height = n.videoHeight, D.drawImage(n, 0, 0, n.videoWidth, n.videoHeight), d && (D.scale(-1, 1), D.drawImage(n, -n.videoWidth, 0)), a.toBlob(
      (N) => {
        m(l ? "stream" : "capture", N);
      },
      "image/png",
      0.8
    ));
  }
  let b = !1, w = [], T, x, E;
  function R() {
    if (b) {
      E.stop();
      let D = new Blob(w, { type: x }), N = new FileReader();
      N.onload = function(I) {
        return i(this, void 0, void 0, function* () {
          var S;
          if (I.target) {
            let z = new File([D], "sample." + x.substring(6));
            const V = yield ys([z]);
            let $ = ((S = yield _(V, c)) === null || S === void 0 ? void 0 : S.filter(Boolean))[0];
            m("capture", $), m("stop_recording");
          }
        });
      }, N.readAsDataURL(D);
    } else {
      m("start_recording"), w = [];
      let D = ["video/webm", "video/mp4"];
      for (let N of D)
        if (MediaRecorder.isTypeSupported(N)) {
          x = N;
          break;
        }
      if (x === null) {
        console.error("No supported MediaRecorder mimeType");
        return;
      }
      E = new MediaRecorder(T, { mimeType: x }), E.addEventListener("dataavailable", function(N) {
        w.push(N.data);
      }), E.start(200);
    }
    t(8, b = !b);
  }
  let k = !1;
  function O() {
    u === "image" && l && t(8, b = !b), u === "image" ? g() : R(), !b && T && (T.getTracks().forEach((D) => D.stop()), t(5, n.srcObject = null, n), t(9, k = !1));
  }
  l && u === "image" && window.setInterval(
    () => {
      n && !h && g();
    },
    500
  );
  let B = !1;
  function C(D) {
    D.preventDefault(), D.stopPropagation(), t(10, B = !1);
  }
  function M(D) {
    Ow[D ? "unshift" : "push"](() => {
      n = D, t(5, n);
    });
  }
  const F = async () => v(), U = () => t(10, B = !0), L = () => t(10, B = !1);
  return r.$$set = (D) => {
    "streaming" in D && t(0, l = D.streaming), "pending" in D && t(15, h = D.pending), "root" in D && t(16, c = D.root), "mode" in D && t(1, u = D.mode), "mirror_webcam" in D && t(2, d = D.mirror_webcam), "include_audio" in D && t(17, f = D.include_audio), "i18n" in D && t(3, p = D.i18n), "upload" in D && t(18, _ = D.upload);
  }, [
    l,
    u,
    d,
    p,
    Yc,
    n,
    s,
    o,
    b,
    k,
    B,
    y,
    v,
    O,
    C,
    h,
    c,
    f,
    _,
    M,
    F,
    U,
    L
  ];
}
class tx extends Dw {
  constructor(e) {
    super(), Uw(
      this,
      e,
      ex,
      Qw,
      Hw,
      {
        streaming: 0,
        pending: 15,
        root: 16,
        mode: 1,
        mirror_webcam: 2,
        include_audio: 17,
        i18n: 3,
        upload: 18,
        click_outside: 4
      },
      null,
      [-1, -1]
    );
  }
  get click_outside() {
    return Yc;
  }
}
const {
  SvelteComponent: ix,
  append: ct,
  attr: Sr,
  detach: C_,
  element: Cr,
  init: rx,
  insert: I_,
  noop: td,
  safe_not_equal: nx,
  set_data: $o,
  set_style: El,
  space: Dh,
  text: vn,
  toggle_class: id
} = window.__gradio__svelte__internal, { onMount: sx, createEventDispatcher: ox, onDestroy: ax } = window.__gradio__svelte__internal;
function rd(r) {
  let e, t, i, n, s = as(
    /*file_to_display*/
    r[2]
  ) + "", o, a, l, h, c = (
    /*file_to_display*/
    r[2].orig_name + ""
  ), u;
  return {
    c() {
      e = Cr("div"), t = Cr("span"), i = Cr("div"), n = Cr("progress"), o = vn(s), l = Dh(), h = Cr("span"), u = vn(c), El(n, "visibility", "hidden"), El(n, "height", "0"), El(n, "width", "0"), n.value = a = as(
        /*file_to_display*/
        r[2]
      ), Sr(n, "max", "100"), Sr(n, "class", "svelte-cr2edf"), Sr(i, "class", "progress-bar svelte-cr2edf"), Sr(h, "class", "file-name svelte-cr2edf"), Sr(e, "class", "file svelte-cr2edf");
    },
    m(d, f) {
      I_(d, e, f), ct(e, t), ct(t, i), ct(i, n), ct(n, o), ct(e, l), ct(e, h), ct(h, u);
    },
    p(d, f) {
      f & /*file_to_display*/
      4 && s !== (s = as(
        /*file_to_display*/
        d[2]
      ) + "") && $o(o, s), f & /*file_to_display*/
      4 && a !== (a = as(
        /*file_to_display*/
        d[2]
      )) && (n.value = a), f & /*file_to_display*/
      4 && c !== (c = /*file_to_display*/
      d[2].orig_name + "") && $o(u, c);
    },
    d(d) {
      d && C_(e);
    }
  };
}
function lx(r) {
  let e, t, i, n = (
    /*files_with_progress*/
    r[0].length + ""
  ), s, o, a = (
    /*files_with_progress*/
    r[0].length > 1 ? "files" : "file"
  ), l, h, c, u = (
    /*file_to_display*/
    r[2] && rd(r)
  );
  return {
    c() {
      e = Cr("div"), t = Cr("span"), i = vn("Uploading "), s = vn(n), o = Dh(), l = vn(a), h = vn("..."), c = Dh(), u && u.c(), Sr(t, "class", "uploading svelte-cr2edf"), Sr(e, "class", "wrap svelte-cr2edf"), id(
        e,
        "progress",
        /*progress*/
        r[1]
      );
    },
    m(d, f) {
      I_(d, e, f), ct(e, t), ct(t, i), ct(t, s), ct(t, o), ct(t, l), ct(t, h), ct(e, c), u && u.m(e, null);
    },
    p(d, [f]) {
      f & /*files_with_progress*/
      1 && n !== (n = /*files_with_progress*/
      d[0].length + "") && $o(s, n), f & /*files_with_progress*/
      1 && a !== (a = /*files_with_progress*/
      d[0].length > 1 ? "files" : "file") && $o(l, a), /*file_to_display*/
      d[2] ? u ? u.p(d, f) : (u = rd(d), u.c(), u.m(e, null)) : u && (u.d(1), u = null), f & /*progress*/
      2 && id(
        e,
        "progress",
        /*progress*/
        d[1]
      );
    },
    i: td,
    o: td,
    d(d) {
      d && C_(e), u && u.d();
    }
  };
}
function as(r) {
  return r.progress * 100 / (r.size || 0) || 0;
}
function hx(r) {
  let e = 0;
  return r.forEach((t) => {
    e += as(t);
  }), document.documentElement.style.setProperty("--upload-progress-width", (e / r.length).toFixed(2) + "%"), e / r.length;
}
function cx(r, e, t) {
  var i = this && this.__awaiter || function(_, m, y, v) {
    function g(b) {
      return b instanceof y ? b : new y(function(w) {
        w(b);
      });
    }
    return new (y || (y = Promise))(function(b, w) {
      function T(R) {
        try {
          E(v.next(R));
        } catch (k) {
          w(k);
        }
      }
      function x(R) {
        try {
          E(v.throw(R));
        } catch (k) {
          w(k);
        }
      }
      function E(R) {
        R.done ? b(R.value) : g(R.value).then(T, x);
      }
      E((v = v.apply(_, m || [])).next());
    });
  };
  let { upload_id: n } = e, { root: s } = e, { files: o } = e, { stream_handler: a } = e, l, h = !1, c, u, d = o.map((_) => Object.assign(Object.assign({}, _), { progress: 0 }));
  const f = ox();
  function p(_, m) {
    t(0, d = d.map((y) => (y.orig_name === _ && (y.progress += m), y)));
  }
  return sx(() => i(void 0, void 0, void 0, function* () {
    if (l = yield a(new URL(`${s}/upload_progress?upload_id=${n}`)), l == null)
      throw new Error("Event source is not defined");
    l.onmessage = function(_) {
      return i(this, void 0, void 0, function* () {
        const m = JSON.parse(_.data);
        h || t(1, h = !0), m.msg === "done" ? (l == null || l.close(), f("done")) : (t(7, c = m), p(m.orig_name, m.chunk_size));
      });
    };
  })), ax(() => {
    (l != null || l != null) && l.close();
  }), r.$$set = (_) => {
    "upload_id" in _ && t(3, n = _.upload_id), "root" in _ && t(4, s = _.root), "files" in _ && t(5, o = _.files), "stream_handler" in _ && t(6, a = _.stream_handler);
  }, r.$$.update = () => {
    r.$$.dirty & /*files_with_progress*/
    1 && hx(d), r.$$.dirty & /*current_file_upload, files_with_progress*/
    129 && t(2, u = c || d[0]);
  }, [
    d,
    h,
    u,
    n,
    s,
    o,
    a,
    c
  ];
}
class ux extends ix {
  constructor(e) {
    super(), rx(this, e, cx, lx, nx, {
      upload_id: 3,
      root: 4,
      files: 5,
      stream_handler: 6
    });
  }
}
const {
  SvelteComponent: dx,
  append: nd,
  attr: Ze,
  binding_callbacks: fx,
  bubble: fr,
  check_outros: R_,
  create_component: px,
  create_slot: P_,
  destroy_component: _x,
  detach: Ca,
  element: Bh,
  empty: M_,
  get_all_dirty_from_scope: k_,
  get_slot_changes: D_,
  group_outros: B_,
  init: mx,
  insert: Ia,
  listen: _t,
  mount_component: gx,
  prevent_default: pr,
  run_all: yx,
  safe_not_equal: vx,
  set_style: F_,
  space: bx,
  stop_propagation: _r,
  toggle_class: ze,
  transition_in: er,
  transition_out: Lr,
  update_slot_base: O_
} = window.__gradio__svelte__internal, { createEventDispatcher: wx, tick: xx } = window.__gradio__svelte__internal;
function Ex(r) {
  let e, t, i, n, s, o, a, l, h, c, u;
  const d = (
    /*#slots*/
    r[26].default
  ), f = P_(
    d,
    r,
    /*$$scope*/
    r[25],
    null
  );
  return {
    c() {
      e = Bh("button"), f && f.c(), t = bx(), i = Bh("input"), Ze(i, "aria-label", "file upload"), Ze(i, "data-testid", "file-upload"), Ze(i, "type", "file"), Ze(i, "accept", n = /*accept_file_types*/
      r[16] || void 0), i.multiple = s = /*file_count*/
      r[6] === "multiple" || void 0, Ze(i, "webkitdirectory", o = /*file_count*/
      r[6] === "directory" || void 0), Ze(i, "mozdirectory", a = /*file_count*/
      r[6] === "directory" || void 0), Ze(i, "class", "svelte-1s26xmt"), Ze(e, "tabindex", l = /*hidden*/
      r[9] ? -1 : 0), Ze(e, "class", "svelte-1s26xmt"), ze(
        e,
        "hidden",
        /*hidden*/
        r[9]
      ), ze(
        e,
        "center",
        /*center*/
        r[4]
      ), ze(
        e,
        "boundedheight",
        /*boundedheight*/
        r[3]
      ), ze(
        e,
        "flex",
        /*flex*/
        r[5]
      ), ze(
        e,
        "disable_click",
        /*disable_click*/
        r[7]
      ), F_(e, "height", "100%");
    },
    m(p, _) {
      Ia(p, e, _), f && f.m(e, null), nd(e, t), nd(e, i), r[34](i), h = !0, c || (u = [
        _t(
          i,
          "change",
          /*load_files_from_upload*/
          r[18]
        ),
        _t(e, "drag", _r(pr(
          /*drag_handler*/
          r[27]
        ))),
        _t(e, "dragstart", _r(pr(
          /*dragstart_handler*/
          r[28]
        ))),
        _t(e, "dragend", _r(pr(
          /*dragend_handler*/
          r[29]
        ))),
        _t(e, "dragover", _r(pr(
          /*dragover_handler*/
          r[30]
        ))),
        _t(e, "dragenter", _r(pr(
          /*dragenter_handler*/
          r[31]
        ))),
        _t(e, "dragleave", _r(pr(
          /*dragleave_handler*/
          r[32]
        ))),
        _t(e, "drop", _r(pr(
          /*drop_handler*/
          r[33]
        ))),
        _t(
          e,
          "click",
          /*open_file_upload*/
          r[13]
        ),
        _t(
          e,
          "drop",
          /*loadFilesFromDrop*/
          r[19]
        ),
        _t(
          e,
          "dragenter",
          /*updateDragging*/
          r[17]
        ),
        _t(
          e,
          "dragleave",
          /*updateDragging*/
          r[17]
        )
      ], c = !0);
    },
    p(p, _) {
      f && f.p && (!h || _[0] & /*$$scope*/
      33554432) && O_(
        f,
        d,
        p,
        /*$$scope*/
        p[25],
        h ? D_(
          d,
          /*$$scope*/
          p[25],
          _,
          null
        ) : k_(
          /*$$scope*/
          p[25]
        ),
        null
      ), (!h || _[0] & /*accept_file_types*/
      65536 && n !== (n = /*accept_file_types*/
      p[16] || void 0)) && Ze(i, "accept", n), (!h || _[0] & /*file_count*/
      64 && s !== (s = /*file_count*/
      p[6] === "multiple" || void 0)) && (i.multiple = s), (!h || _[0] & /*file_count*/
      64 && o !== (o = /*file_count*/
      p[6] === "directory" || void 0)) && Ze(i, "webkitdirectory", o), (!h || _[0] & /*file_count*/
      64 && a !== (a = /*file_count*/
      p[6] === "directory" || void 0)) && Ze(i, "mozdirectory", a), (!h || _[0] & /*hidden*/
      512 && l !== (l = /*hidden*/
      p[9] ? -1 : 0)) && Ze(e, "tabindex", l), (!h || _[0] & /*hidden*/
      512) && ze(
        e,
        "hidden",
        /*hidden*/
        p[9]
      ), (!h || _[0] & /*center*/
      16) && ze(
        e,
        "center",
        /*center*/
        p[4]
      ), (!h || _[0] & /*boundedheight*/
      8) && ze(
        e,
        "boundedheight",
        /*boundedheight*/
        p[3]
      ), (!h || _[0] & /*flex*/
      32) && ze(
        e,
        "flex",
        /*flex*/
        p[5]
      ), (!h || _[0] & /*disable_click*/
      128) && ze(
        e,
        "disable_click",
        /*disable_click*/
        p[7]
      );
    },
    i(p) {
      h || (er(f, p), h = !0);
    },
    o(p) {
      Lr(f, p), h = !1;
    },
    d(p) {
      p && Ca(e), f && f.d(p), r[34](null), c = !1, yx(u);
    }
  };
}
function Tx(r) {
  let e, t, i = !/*hidden*/
  r[9] && sd(r);
  return {
    c() {
      i && i.c(), e = M_();
    },
    m(n, s) {
      i && i.m(n, s), Ia(n, e, s), t = !0;
    },
    p(n, s) {
      /*hidden*/
      n[9] ? i && (B_(), Lr(i, 1, 1, () => {
        i = null;
      }), R_()) : i ? (i.p(n, s), s[0] & /*hidden*/
      512 && er(i, 1)) : (i = sd(n), i.c(), er(i, 1), i.m(e.parentNode, e));
    },
    i(n) {
      t || (er(i), t = !0);
    },
    o(n) {
      Lr(i), t = !1;
    },
    d(n) {
      n && Ca(e), i && i.d(n);
    }
  };
}
function Ax(r) {
  let e, t, i, n, s;
  const o = (
    /*#slots*/
    r[26].default
  ), a = P_(
    o,
    r,
    /*$$scope*/
    r[25],
    null
  );
  return {
    c() {
      e = Bh("button"), a && a.c(), Ze(e, "tabindex", t = /*hidden*/
      r[9] ? -1 : 0), Ze(e, "class", "svelte-1s26xmt"), ze(
        e,
        "hidden",
        /*hidden*/
        r[9]
      ), ze(
        e,
        "center",
        /*center*/
        r[4]
      ), ze(
        e,
        "boundedheight",
        /*boundedheight*/
        r[3]
      ), ze(
        e,
        "flex",
        /*flex*/
        r[5]
      ), F_(e, "height", "100%");
    },
    m(l, h) {
      Ia(l, e, h), a && a.m(e, null), i = !0, n || (s = _t(
        e,
        "click",
        /*paste_clipboard*/
        r[12]
      ), n = !0);
    },
    p(l, h) {
      a && a.p && (!i || h[0] & /*$$scope*/
      33554432) && O_(
        a,
        o,
        l,
        /*$$scope*/
        l[25],
        i ? D_(
          o,
          /*$$scope*/
          l[25],
          h,
          null
        ) : k_(
          /*$$scope*/
          l[25]
        ),
        null
      ), (!i || h[0] & /*hidden*/
      512 && t !== (t = /*hidden*/
      l[9] ? -1 : 0)) && Ze(e, "tabindex", t), (!i || h[0] & /*hidden*/
      512) && ze(
        e,
        "hidden",
        /*hidden*/
        l[9]
      ), (!i || h[0] & /*center*/
      16) && ze(
        e,
        "center",
        /*center*/
        l[4]
      ), (!i || h[0] & /*boundedheight*/
      8) && ze(
        e,
        "boundedheight",
        /*boundedheight*/
        l[3]
      ), (!i || h[0] & /*flex*/
      32) && ze(
        e,
        "flex",
        /*flex*/
        l[5]
      );
    },
    i(l) {
      i || (er(a, l), i = !0);
    },
    o(l) {
      Lr(a, l), i = !1;
    },
    d(l) {
      l && Ca(e), a && a.d(l), n = !1, s();
    }
  };
}
function sd(r) {
  let e, t;
  return e = new ux({
    props: {
      root: (
        /*root*/
        r[8]
      ),
      upload_id: (
        /*upload_id*/
        r[14]
      ),
      files: (
        /*file_data*/
        r[15]
      ),
      stream_handler: (
        /*stream_handler*/
        r[11]
      )
    }
  }), {
    c() {
      px(e.$$.fragment);
    },
    m(i, n) {
      gx(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*root*/
      256 && (s.root = /*root*/
      i[8]), n[0] & /*upload_id*/
      16384 && (s.upload_id = /*upload_id*/
      i[14]), n[0] & /*file_data*/
      32768 && (s.files = /*file_data*/
      i[15]), n[0] & /*stream_handler*/
      2048 && (s.stream_handler = /*stream_handler*/
      i[11]), e.$set(s);
    },
    i(i) {
      t || (er(e.$$.fragment, i), t = !0);
    },
    o(i) {
      Lr(e.$$.fragment, i), t = !1;
    },
    d(i) {
      _x(e, i);
    }
  };
}
function Sx(r) {
  let e, t, i, n;
  const s = [Ax, Tx, Ex], o = [];
  function a(l, h) {
    return (
      /*filetype*/
      l[0] === "clipboard" ? 0 : (
        /*uploading*/
        l[1] && /*show_progress*/
        l[10] ? 1 : 2
      )
    );
  }
  return e = a(r), t = o[e] = s[e](r), {
    c() {
      t.c(), i = M_();
    },
    m(l, h) {
      o[e].m(l, h), Ia(l, i, h), n = !0;
    },
    p(l, h) {
      let c = e;
      e = a(l), e === c ? o[e].p(l, h) : (B_(), Lr(o[c], 1, 1, () => {
        o[c] = null;
      }), R_(), t = o[e], t ? t.p(l, h) : (t = o[e] = s[e](l), t.c()), er(t, 1), t.m(i.parentNode, i));
    },
    i(l) {
      n || (er(t), n = !0);
    },
    o(l) {
      Lr(t), n = !1;
    },
    d(l) {
      l && Ca(i), o[e].d(l);
    }
  };
}
function Cx(r, e, t) {
  if (!r || r === "*" || r === "file/*" || Array.isArray(r) && r.some((n) => n === "*" || n === "file/*"))
    return !0;
  let i;
  if (typeof r == "string")
    i = r.split(",").map((n) => n.trim());
  else if (Array.isArray(r))
    i = r;
  else
    return !1;
  return i.includes(e) || i.some((n) => {
    const [s] = n.split("/").map((o) => o.trim());
    return n.endsWith("/*") && t.startsWith(s + "/");
  });
}
function Ix(r, e, t) {
  let { $$slots: i = {}, $$scope: n } = e;
  var s = this && this.__awaiter || function(A, X, te, j) {
    function W(se) {
      return se instanceof te ? se : new te(function(ue) {
        ue(se);
      });
    }
    return new (te || (te = Promise))(function(se, ue) {
      function _e(Me) {
        try {
          xe(j.next(Me));
        } catch (Ke) {
          ue(Ke);
        }
      }
      function de(Me) {
        try {
          xe(j.throw(Me));
        } catch (Ke) {
          ue(Ke);
        }
      }
      function xe(Me) {
        Me.done ? se(Me.value) : W(Me.value).then(_e, de);
      }
      xe((j = j.apply(A, X || [])).next());
    });
  };
  let { filetype: o = null } = e, { dragging: a = !1 } = e, { boundedheight: l = !0 } = e, { center: h = !0 } = e, { flex: c = !0 } = e, { file_count: u = "single" } = e, { disable_click: d = !1 } = e, { root: f } = e, { hidden: p = !1 } = e, { format: _ = "file" } = e, { uploading: m = !1 } = e, { hidden_upload: y = null } = e, { show_progress: v = !0 } = e, { max_file_size: g = null } = e, { upload: b } = e, { stream_handler: w } = e, T, x, E;
  const R = wx(), k = ["image", "video", "audio", "text", "file"], O = (A) => A.startsWith(".") || A.endsWith("/*") ? A : k.includes(A) ? A + "/*" : "." + A;
  function B() {
    t(20, a = !a);
  }
  function C() {
    navigator.clipboard.read().then((A) => s(this, void 0, void 0, function* () {
      for (let X = 0; X < A.length; X++) {
        const te = A[X].types.find((j) => j.startsWith("image/"));
        if (te) {
          A[X].getType(te).then((j) => s(this, void 0, void 0, function* () {
            const W = new File([j], `clipboard.${te.replace("image/", "")}`);
            yield U([W]);
          }));
          break;
        }
      }
    }));
  }
  function M() {
    d || y && (t(2, y.value = "", y), y.click());
  }
  function F(A) {
    return s(this, void 0, void 0, function* () {
      yield xx(), t(14, T = Math.random().toString(36).substring(2, 15)), t(1, m = !0);
      try {
        const X = yield b(A, f, T, g ?? 1 / 0);
        return R("load", u === "single" ? X == null ? void 0 : X[0] : X), t(1, m = !1), X || [];
      } catch (X) {
        return R("error", X.message), t(1, m = !1), [];
      }
    });
  }
  function U(A) {
    return s(this, void 0, void 0, function* () {
      if (!A.length)
        return;
      let X = A.map((te) => new File([te], te instanceof File ? te.name : "file", { type: te.type }));
      return t(15, x = yield ys(X)), yield F(x);
    });
  }
  function L(A) {
    return s(this, void 0, void 0, function* () {
      const X = A.target;
      if (X.files)
        if (_ != "blob")
          yield U(Array.from(X.files));
        else {
          if (u === "single") {
            R("load", X.files[0]);
            return;
          }
          R("load", X.files);
        }
    });
  }
  function D(A) {
    return s(this, void 0, void 0, function* () {
      var X;
      if (t(20, a = !1), !(!((X = A.dataTransfer) === null || X === void 0) && X.files))
        return;
      const te = Array.from(A.dataTransfer.files).filter((j) => {
        const W = "." + j.name.split(".").pop();
        return W && Cx(E, W, j.type) || (W && Array.isArray(o) ? o.includes(W) : W === o) ? !0 : (R("error", `Invalid file type only ${o} allowed.`), !1);
      });
      yield U(te);
    });
  }
  function N(A) {
    fr.call(this, r, A);
  }
  function I(A) {
    fr.call(this, r, A);
  }
  function S(A) {
    fr.call(this, r, A);
  }
  function z(A) {
    fr.call(this, r, A);
  }
  function V(A) {
    fr.call(this, r, A);
  }
  function $(A) {
    fr.call(this, r, A);
  }
  function P(A) {
    fr.call(this, r, A);
  }
  function ie(A) {
    fx[A ? "unshift" : "push"](() => {
      y = A, t(2, y);
    });
  }
  return r.$$set = (A) => {
    "filetype" in A && t(0, o = A.filetype), "dragging" in A && t(20, a = A.dragging), "boundedheight" in A && t(3, l = A.boundedheight), "center" in A && t(4, h = A.center), "flex" in A && t(5, c = A.flex), "file_count" in A && t(6, u = A.file_count), "disable_click" in A && t(7, d = A.disable_click), "root" in A && t(8, f = A.root), "hidden" in A && t(9, p = A.hidden), "format" in A && t(21, _ = A.format), "uploading" in A && t(1, m = A.uploading), "hidden_upload" in A && t(2, y = A.hidden_upload), "show_progress" in A && t(10, v = A.show_progress), "max_file_size" in A && t(22, g = A.max_file_size), "upload" in A && t(23, b = A.upload), "stream_handler" in A && t(11, w = A.stream_handler), "$$scope" in A && t(25, n = A.$$scope);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*filetype*/
    1 && (o == null ? t(16, E = null) : typeof o == "string" ? t(16, E = O(o)) : (t(0, o = o.map(O)), t(16, E = o.join(", "))));
  }, [
    o,
    m,
    y,
    l,
    h,
    c,
    u,
    d,
    f,
    p,
    v,
    w,
    C,
    M,
    T,
    x,
    E,
    B,
    L,
    D,
    a,
    _,
    g,
    b,
    U,
    n,
    i,
    N,
    I,
    S,
    z,
    V,
    $,
    P,
    ie
  ];
}
class Rx extends dx {
  constructor(e) {
    super(), mx(
      this,
      e,
      Ix,
      Sx,
      vx,
      {
        filetype: 0,
        dragging: 20,
        boundedheight: 3,
        center: 4,
        flex: 5,
        file_count: 6,
        disable_click: 7,
        root: 8,
        hidden: 9,
        format: 21,
        uploading: 1,
        hidden_upload: 2,
        show_progress: 10,
        max_file_size: 22,
        upload: 23,
        stream_handler: 11,
        paste_clipboard: 12,
        open_file_upload: 13,
        load_files: 24
      },
      null,
      [-1, -1]
    );
  }
  get paste_clipboard() {
    return this.$$.ctx[12];
  }
  get open_file_upload() {
    return this.$$.ctx[13];
  }
  get load_files() {
    return this.$$.ctx[24];
  }
}
function bn(r) {
  let e = ["", "k", "M", "G", "T", "P", "E", "Z"], t = 0;
  for (; r > 1e3 && t < e.length - 1; )
    r /= 1e3, t++;
  let i = e[t];
  return (Number.isInteger(r) ? r : r.toFixed(1)) + i;
}
const {
  SvelteComponent: Px,
  append: Nt,
  attr: ye,
  component_subscribe: od,
  detach: Mx,
  element: kx,
  init: Dx,
  insert: Bx,
  noop: ad,
  safe_not_equal: Fx,
  set_style: qs,
  svg_element: Ut,
  toggle_class: ld
} = window.__gradio__svelte__internal, { onMount: Ox } = window.__gradio__svelte__internal;
function Lx(r) {
  let e, t, i, n, s, o, a, l, h, c, u, d;
  return {
    c() {
      e = kx("div"), t = Ut("svg"), i = Ut("g"), n = Ut("path"), s = Ut("path"), o = Ut("path"), a = Ut("path"), l = Ut("g"), h = Ut("path"), c = Ut("path"), u = Ut("path"), d = Ut("path"), ye(n, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), ye(n, "fill", "#FF7C00"), ye(n, "fill-opacity", "0.4"), ye(n, "class", "svelte-43sxxs"), ye(s, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), ye(s, "fill", "#FF7C00"), ye(s, "class", "svelte-43sxxs"), ye(o, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), ye(o, "fill", "#FF7C00"), ye(o, "fill-opacity", "0.4"), ye(o, "class", "svelte-43sxxs"), ye(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), ye(a, "fill", "#FF7C00"), ye(a, "class", "svelte-43sxxs"), qs(i, "transform", "translate(" + /*$top*/
      r[1][0] + "px, " + /*$top*/
      r[1][1] + "px)"), ye(h, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), ye(h, "fill", "#FF7C00"), ye(h, "fill-opacity", "0.4"), ye(h, "class", "svelte-43sxxs"), ye(c, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), ye(c, "fill", "#FF7C00"), ye(c, "class", "svelte-43sxxs"), ye(u, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), ye(u, "fill", "#FF7C00"), ye(u, "fill-opacity", "0.4"), ye(u, "class", "svelte-43sxxs"), ye(d, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), ye(d, "fill", "#FF7C00"), ye(d, "class", "svelte-43sxxs"), qs(l, "transform", "translate(" + /*$bottom*/
      r[2][0] + "px, " + /*$bottom*/
      r[2][1] + "px)"), ye(t, "viewBox", "-1200 -1200 3000 3000"), ye(t, "fill", "none"), ye(t, "xmlns", "http://www.w3.org/2000/svg"), ye(t, "class", "svelte-43sxxs"), ye(e, "class", "svelte-43sxxs"), ld(
        e,
        "margin",
        /*margin*/
        r[0]
      );
    },
    m(f, p) {
      Bx(f, e, p), Nt(e, t), Nt(t, i), Nt(i, n), Nt(i, s), Nt(i, o), Nt(i, a), Nt(t, l), Nt(l, h), Nt(l, c), Nt(l, u), Nt(l, d);
    },
    p(f, [p]) {
      p & /*$top*/
      2 && qs(i, "transform", "translate(" + /*$top*/
      f[1][0] + "px, " + /*$top*/
      f[1][1] + "px)"), p & /*$bottom*/
      4 && qs(l, "transform", "translate(" + /*$bottom*/
      f[2][0] + "px, " + /*$bottom*/
      f[2][1] + "px)"), p & /*margin*/
      1 && ld(
        e,
        "margin",
        /*margin*/
        f[0]
      );
    },
    i: ad,
    o: ad,
    d(f) {
      f && Mx(e);
    }
  };
}
function Nx(r, e, t) {
  let i, n;
  var s = this && this.__awaiter || function(f, p, _, m) {
    function y(v) {
      return v instanceof _ ? v : new _(function(g) {
        g(v);
      });
    }
    return new (_ || (_ = Promise))(function(v, g) {
      function b(x) {
        try {
          T(m.next(x));
        } catch (E) {
          g(E);
        }
      }
      function w(x) {
        try {
          T(m.throw(x));
        } catch (E) {
          g(E);
        }
      }
      function T(x) {
        x.done ? v(x.value) : y(x.value).then(b, w);
      }
      T((m = m.apply(f, p || [])).next());
    });
  };
  let { margin: o = !0 } = e;
  const a = Ko([0, 0]);
  od(r, a, (f) => t(1, i = f));
  const l = Ko([0, 0]);
  od(r, l, (f) => t(2, n = f));
  let h;
  function c() {
    return s(this, void 0, void 0, function* () {
      yield Promise.all([a.set([125, 140]), l.set([-125, -140])]), yield Promise.all([a.set([-125, 140]), l.set([125, -140])]), yield Promise.all([a.set([-125, 0]), l.set([125, -0])]), yield Promise.all([a.set([125, 0]), l.set([-125, 0])]);
    });
  }
  function u() {
    return s(this, void 0, void 0, function* () {
      yield c(), h || u();
    });
  }
  function d() {
    return s(this, void 0, void 0, function* () {
      yield Promise.all([a.set([125, 0]), l.set([-125, 0])]), u();
    });
  }
  return Ox(() => (d(), () => h = !0)), r.$$set = (f) => {
    "margin" in f && t(0, o = f.margin);
  }, [o, i, n, a, l];
}
let Ux = class extends Px {
  constructor(e) {
    super(), Dx(this, e, Nx, Lx, Fx, { margin: 0 });
  }
};
const {
  SvelteComponent: Gx,
  append: Pr,
  attr: Yt,
  binding_callbacks: hd,
  check_outros: L_,
  create_component: N_,
  create_slot: Hx,
  destroy_component: U_,
  destroy_each: G_,
  detach: he,
  element: fi,
  empty: Wn,
  ensure_array_like: Jo,
  get_all_dirty_from_scope: zx,
  get_slot_changes: Xx,
  group_outros: H_,
  init: Vx,
  insert: ce,
  mount_component: z_,
  noop: Fh,
  safe_not_equal: Wx,
  set_data: Dt,
  set_style: Yi,
  space: Kt,
  text: Ie,
  toggle_class: Ct,
  transition_in: Nr,
  transition_out: Ur,
  update_slot_base: jx
} = window.__gradio__svelte__internal, { tick: qx } = window.__gradio__svelte__internal, { onDestroy: Yx } = window.__gradio__svelte__internal, { createEventDispatcher: Kx } = window.__gradio__svelte__internal, Zx = (r) => ({}), cd = (r) => ({});
function ud(r, e, t) {
  const i = r.slice();
  return i[41] = e[t], i[43] = t, i;
}
function dd(r, e, t) {
  const i = r.slice();
  return i[41] = e[t], i;
}
function $x(r) {
  let e, t, i, n, s = (
    /*i18n*/
    r[1]("common.error") + ""
  ), o, a, l;
  t = new Pi({
    props: {
      Icon: J1,
      label: (
        /*i18n*/
        r[1]("common.clear")
      ),
      disabled: !1
    }
  }), t.$on(
    "click",
    /*click_handler*/
    r[32]
  );
  const h = (
    /*#slots*/
    r[30].error
  ), c = Hx(
    h,
    r,
    /*$$scope*/
    r[29],
    cd
  );
  return {
    c() {
      e = fi("div"), N_(t.$$.fragment), i = Kt(), n = fi("span"), o = Ie(s), a = Kt(), c && c.c(), Yt(e, "class", "clear-status svelte-1yk38uw"), Yt(n, "class", "error svelte-1yk38uw");
    },
    m(u, d) {
      ce(u, e, d), z_(t, e, null), ce(u, i, d), ce(u, n, d), Pr(n, o), ce(u, a, d), c && c.m(u, d), l = !0;
    },
    p(u, d) {
      const f = {};
      d[0] & /*i18n*/
      2 && (f.label = /*i18n*/
      u[1]("common.clear")), t.$set(f), (!l || d[0] & /*i18n*/
      2) && s !== (s = /*i18n*/
      u[1]("common.error") + "") && Dt(o, s), c && c.p && (!l || d[0] & /*$$scope*/
      536870912) && jx(
        c,
        h,
        u,
        /*$$scope*/
        u[29],
        l ? Xx(
          h,
          /*$$scope*/
          u[29],
          d,
          Zx
        ) : zx(
          /*$$scope*/
          u[29]
        ),
        cd
      );
    },
    i(u) {
      l || (Nr(t.$$.fragment, u), Nr(c, u), l = !0);
    },
    o(u) {
      Ur(t.$$.fragment, u), Ur(c, u), l = !1;
    },
    d(u) {
      u && (he(e), he(i), he(n), he(a)), U_(t), c && c.d(u);
    }
  };
}
function Jx(r) {
  let e, t, i, n, s, o, a, l, h, c = (
    /*variant*/
    r[8] === "default" && /*show_eta_bar*/
    r[18] && /*show_progress*/
    r[6] === "full" && fd(r)
  );
  function u(g, b) {
    if (
      /*progress*/
      g[7]
    )
      return t2;
    if (
      /*queue_position*/
      g[2] !== null && /*queue_size*/
      g[3] !== void 0 && /*queue_position*/
      g[2] >= 0
    )
      return e2;
    if (
      /*queue_position*/
      g[2] === 0
    )
      return Qx;
  }
  let d = u(r), f = d && d(r), p = (
    /*timer*/
    r[5] && md(r)
  );
  const _ = [s2, n2], m = [];
  function y(g, b) {
    return (
      /*last_progress_level*/
      g[15] != null ? 0 : (
        /*show_progress*/
        g[6] === "full" ? 1 : -1
      )
    );
  }
  ~(s = y(r)) && (o = m[s] = _[s](r));
  let v = !/*timer*/
  r[5] && Ed(r);
  return {
    c() {
      c && c.c(), e = Kt(), t = fi("div"), f && f.c(), i = Kt(), p && p.c(), n = Kt(), o && o.c(), a = Kt(), v && v.c(), l = Wn(), Yt(t, "class", "progress-text svelte-1yk38uw"), Ct(
        t,
        "meta-text-center",
        /*variant*/
        r[8] === "center"
      ), Ct(
        t,
        "meta-text",
        /*variant*/
        r[8] === "default"
      );
    },
    m(g, b) {
      c && c.m(g, b), ce(g, e, b), ce(g, t, b), f && f.m(t, null), Pr(t, i), p && p.m(t, null), ce(g, n, b), ~s && m[s].m(g, b), ce(g, a, b), v && v.m(g, b), ce(g, l, b), h = !0;
    },
    p(g, b) {
      /*variant*/
      g[8] === "default" && /*show_eta_bar*/
      g[18] && /*show_progress*/
      g[6] === "full" ? c ? c.p(g, b) : (c = fd(g), c.c(), c.m(e.parentNode, e)) : c && (c.d(1), c = null), d === (d = u(g)) && f ? f.p(g, b) : (f && f.d(1), f = d && d(g), f && (f.c(), f.m(t, i))), /*timer*/
      g[5] ? p ? p.p(g, b) : (p = md(g), p.c(), p.m(t, null)) : p && (p.d(1), p = null), (!h || b[0] & /*variant*/
      256) && Ct(
        t,
        "meta-text-center",
        /*variant*/
        g[8] === "center"
      ), (!h || b[0] & /*variant*/
      256) && Ct(
        t,
        "meta-text",
        /*variant*/
        g[8] === "default"
      );
      let w = s;
      s = y(g), s === w ? ~s && m[s].p(g, b) : (o && (H_(), Ur(m[w], 1, 1, () => {
        m[w] = null;
      }), L_()), ~s ? (o = m[s], o ? o.p(g, b) : (o = m[s] = _[s](g), o.c()), Nr(o, 1), o.m(a.parentNode, a)) : o = null), /*timer*/
      g[5] ? v && (v.d(1), v = null) : v ? v.p(g, b) : (v = Ed(g), v.c(), v.m(l.parentNode, l));
    },
    i(g) {
      h || (Nr(o), h = !0);
    },
    o(g) {
      Ur(o), h = !1;
    },
    d(g) {
      g && (he(e), he(t), he(n), he(a), he(l)), c && c.d(g), f && f.d(), p && p.d(), ~s && m[s].d(g), v && v.d(g);
    }
  };
}
function fd(r) {
  let e, t = `translateX(${/*eta_level*/
  (r[17] || 0) * 100 - 100}%)`;
  return {
    c() {
      e = fi("div"), Yt(e, "class", "eta-bar svelte-1yk38uw"), Yi(e, "transform", t);
    },
    m(i, n) {
      ce(i, e, n);
    },
    p(i, n) {
      n[0] & /*eta_level*/
      131072 && t !== (t = `translateX(${/*eta_level*/
      (i[17] || 0) * 100 - 100}%)`) && Yi(e, "transform", t);
    },
    d(i) {
      i && he(e);
    }
  };
}
function Qx(r) {
  let e;
  return {
    c() {
      e = Ie("processing |");
    },
    m(t, i) {
      ce(t, e, i);
    },
    p: Fh,
    d(t) {
      t && he(e);
    }
  };
}
function e2(r) {
  let e, t = (
    /*queue_position*/
    r[2] + 1 + ""
  ), i, n, s, o;
  return {
    c() {
      e = Ie("queue: "), i = Ie(t), n = Ie("/"), s = Ie(
        /*queue_size*/
        r[3]
      ), o = Ie(" |");
    },
    m(a, l) {
      ce(a, e, l), ce(a, i, l), ce(a, n, l), ce(a, s, l), ce(a, o, l);
    },
    p(a, l) {
      l[0] & /*queue_position*/
      4 && t !== (t = /*queue_position*/
      a[2] + 1 + "") && Dt(i, t), l[0] & /*queue_size*/
      8 && Dt(
        s,
        /*queue_size*/
        a[3]
      );
    },
    d(a) {
      a && (he(e), he(i), he(n), he(s), he(o));
    }
  };
}
function t2(r) {
  let e, t = Jo(
    /*progress*/
    r[7]
  ), i = [];
  for (let n = 0; n < t.length; n += 1)
    i[n] = _d(dd(r, t, n));
  return {
    c() {
      for (let n = 0; n < i.length; n += 1)
        i[n].c();
      e = Wn();
    },
    m(n, s) {
      for (let o = 0; o < i.length; o += 1)
        i[o] && i[o].m(n, s);
      ce(n, e, s);
    },
    p(n, s) {
      if (s[0] & /*progress*/
      128) {
        t = Jo(
          /*progress*/
          n[7]
        );
        let o;
        for (o = 0; o < t.length; o += 1) {
          const a = dd(n, t, o);
          i[o] ? i[o].p(a, s) : (i[o] = _d(a), i[o].c(), i[o].m(e.parentNode, e));
        }
        for (; o < i.length; o += 1)
          i[o].d(1);
        i.length = t.length;
      }
    },
    d(n) {
      n && he(e), G_(i, n);
    }
  };
}
function pd(r) {
  let e, t = (
    /*p*/
    r[41].unit + ""
  ), i, n, s = " ", o;
  function a(c, u) {
    return (
      /*p*/
      c[41].length != null ? r2 : i2
    );
  }
  let l = a(r), h = l(r);
  return {
    c() {
      h.c(), e = Kt(), i = Ie(t), n = Ie(" | "), o = Ie(s);
    },
    m(c, u) {
      h.m(c, u), ce(c, e, u), ce(c, i, u), ce(c, n, u), ce(c, o, u);
    },
    p(c, u) {
      l === (l = a(c)) && h ? h.p(c, u) : (h.d(1), h = l(c), h && (h.c(), h.m(e.parentNode, e))), u[0] & /*progress*/
      128 && t !== (t = /*p*/
      c[41].unit + "") && Dt(i, t);
    },
    d(c) {
      c && (he(e), he(i), he(n), he(o)), h.d(c);
    }
  };
}
function i2(r) {
  let e = bn(
    /*p*/
    r[41].index || 0
  ) + "", t;
  return {
    c() {
      t = Ie(e);
    },
    m(i, n) {
      ce(i, t, n);
    },
    p(i, n) {
      n[0] & /*progress*/
      128 && e !== (e = bn(
        /*p*/
        i[41].index || 0
      ) + "") && Dt(t, e);
    },
    d(i) {
      i && he(t);
    }
  };
}
function r2(r) {
  let e = bn(
    /*p*/
    r[41].index || 0
  ) + "", t, i, n = bn(
    /*p*/
    r[41].length
  ) + "", s;
  return {
    c() {
      t = Ie(e), i = Ie("/"), s = Ie(n);
    },
    m(o, a) {
      ce(o, t, a), ce(o, i, a), ce(o, s, a);
    },
    p(o, a) {
      a[0] & /*progress*/
      128 && e !== (e = bn(
        /*p*/
        o[41].index || 0
      ) + "") && Dt(t, e), a[0] & /*progress*/
      128 && n !== (n = bn(
        /*p*/
        o[41].length
      ) + "") && Dt(s, n);
    },
    d(o) {
      o && (he(t), he(i), he(s));
    }
  };
}
function _d(r) {
  let e, t = (
    /*p*/
    r[41].index != null && pd(r)
  );
  return {
    c() {
      t && t.c(), e = Wn();
    },
    m(i, n) {
      t && t.m(i, n), ce(i, e, n);
    },
    p(i, n) {
      /*p*/
      i[41].index != null ? t ? t.p(i, n) : (t = pd(i), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(i) {
      i && he(e), t && t.d(i);
    }
  };
}
function md(r) {
  let e, t = (
    /*eta*/
    r[0] ? `/${/*formatted_eta*/
    r[19]}` : ""
  ), i, n;
  return {
    c() {
      e = Ie(
        /*formatted_timer*/
        r[20]
      ), i = Ie(t), n = Ie("s");
    },
    m(s, o) {
      ce(s, e, o), ce(s, i, o), ce(s, n, o);
    },
    p(s, o) {
      o[0] & /*formatted_timer*/
      1048576 && Dt(
        e,
        /*formatted_timer*/
        s[20]
      ), o[0] & /*eta, formatted_eta*/
      524289 && t !== (t = /*eta*/
      s[0] ? `/${/*formatted_eta*/
      s[19]}` : "") && Dt(i, t);
    },
    d(s) {
      s && (he(e), he(i), he(n));
    }
  };
}
function n2(r) {
  let e, t;
  return e = new Ux({
    props: { margin: (
      /*variant*/
      r[8] === "default"
    ) }
  }), {
    c() {
      N_(e.$$.fragment);
    },
    m(i, n) {
      z_(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*variant*/
      256 && (s.margin = /*variant*/
      i[8] === "default"), e.$set(s);
    },
    i(i) {
      t || (Nr(e.$$.fragment, i), t = !0);
    },
    o(i) {
      Ur(e.$$.fragment, i), t = !1;
    },
    d(i) {
      U_(e, i);
    }
  };
}
function s2(r) {
  let e, t, i, n, s, o = `${/*last_progress_level*/
  r[15] * 100}%`, a = (
    /*progress*/
    r[7] != null && gd(r)
  );
  return {
    c() {
      e = fi("div"), t = fi("div"), a && a.c(), i = Kt(), n = fi("div"), s = fi("div"), Yt(t, "class", "progress-level-inner svelte-1yk38uw"), Yt(s, "class", "progress-bar svelte-1yk38uw"), Yi(s, "width", o), Yt(n, "class", "progress-bar-wrap svelte-1yk38uw"), Yt(e, "class", "progress-level svelte-1yk38uw");
    },
    m(l, h) {
      ce(l, e, h), Pr(e, t), a && a.m(t, null), Pr(e, i), Pr(e, n), Pr(n, s), r[31](s);
    },
    p(l, h) {
      /*progress*/
      l[7] != null ? a ? a.p(l, h) : (a = gd(l), a.c(), a.m(t, null)) : a && (a.d(1), a = null), h[0] & /*last_progress_level*/
      32768 && o !== (o = `${/*last_progress_level*/
      l[15] * 100}%`) && Yi(s, "width", o);
    },
    i: Fh,
    o: Fh,
    d(l) {
      l && he(e), a && a.d(), r[31](null);
    }
  };
}
function gd(r) {
  let e, t = Jo(
    /*progress*/
    r[7]
  ), i = [];
  for (let n = 0; n < t.length; n += 1)
    i[n] = xd(ud(r, t, n));
  return {
    c() {
      for (let n = 0; n < i.length; n += 1)
        i[n].c();
      e = Wn();
    },
    m(n, s) {
      for (let o = 0; o < i.length; o += 1)
        i[o] && i[o].m(n, s);
      ce(n, e, s);
    },
    p(n, s) {
      if (s[0] & /*progress_level, progress*/
      16512) {
        t = Jo(
          /*progress*/
          n[7]
        );
        let o;
        for (o = 0; o < t.length; o += 1) {
          const a = ud(n, t, o);
          i[o] ? i[o].p(a, s) : (i[o] = xd(a), i[o].c(), i[o].m(e.parentNode, e));
        }
        for (; o < i.length; o += 1)
          i[o].d(1);
        i.length = t.length;
      }
    },
    d(n) {
      n && he(e), G_(i, n);
    }
  };
}
function yd(r) {
  let e, t, i, n, s = (
    /*i*/
    r[43] !== 0 && o2()
  ), o = (
    /*p*/
    r[41].desc != null && vd(r)
  ), a = (
    /*p*/
    r[41].desc != null && /*progress_level*/
    r[14] && /*progress_level*/
    r[14][
      /*i*/
      r[43]
    ] != null && bd()
  ), l = (
    /*progress_level*/
    r[14] != null && wd(r)
  );
  return {
    c() {
      s && s.c(), e = Kt(), o && o.c(), t = Kt(), a && a.c(), i = Kt(), l && l.c(), n = Wn();
    },
    m(h, c) {
      s && s.m(h, c), ce(h, e, c), o && o.m(h, c), ce(h, t, c), a && a.m(h, c), ce(h, i, c), l && l.m(h, c), ce(h, n, c);
    },
    p(h, c) {
      /*p*/
      h[41].desc != null ? o ? o.p(h, c) : (o = vd(h), o.c(), o.m(t.parentNode, t)) : o && (o.d(1), o = null), /*p*/
      h[41].desc != null && /*progress_level*/
      h[14] && /*progress_level*/
      h[14][
        /*i*/
        h[43]
      ] != null ? a || (a = bd(), a.c(), a.m(i.parentNode, i)) : a && (a.d(1), a = null), /*progress_level*/
      h[14] != null ? l ? l.p(h, c) : (l = wd(h), l.c(), l.m(n.parentNode, n)) : l && (l.d(1), l = null);
    },
    d(h) {
      h && (he(e), he(t), he(i), he(n)), s && s.d(h), o && o.d(h), a && a.d(h), l && l.d(h);
    }
  };
}
function o2(r) {
  let e;
  return {
    c() {
      e = Ie(" /");
    },
    m(t, i) {
      ce(t, e, i);
    },
    d(t) {
      t && he(e);
    }
  };
}
function vd(r) {
  let e = (
    /*p*/
    r[41].desc + ""
  ), t;
  return {
    c() {
      t = Ie(e);
    },
    m(i, n) {
      ce(i, t, n);
    },
    p(i, n) {
      n[0] & /*progress*/
      128 && e !== (e = /*p*/
      i[41].desc + "") && Dt(t, e);
    },
    d(i) {
      i && he(t);
    }
  };
}
function bd(r) {
  let e;
  return {
    c() {
      e = Ie("-");
    },
    m(t, i) {
      ce(t, e, i);
    },
    d(t) {
      t && he(e);
    }
  };
}
function wd(r) {
  let e = (100 * /*progress_level*/
  (r[14][
    /*i*/
    r[43]
  ] || 0)).toFixed(1) + "", t, i;
  return {
    c() {
      t = Ie(e), i = Ie("%");
    },
    m(n, s) {
      ce(n, t, s), ce(n, i, s);
    },
    p(n, s) {
      s[0] & /*progress_level*/
      16384 && e !== (e = (100 * /*progress_level*/
      (n[14][
        /*i*/
        n[43]
      ] || 0)).toFixed(1) + "") && Dt(t, e);
    },
    d(n) {
      n && (he(t), he(i));
    }
  };
}
function xd(r) {
  let e, t = (
    /*p*/
    (r[41].desc != null || /*progress_level*/
    r[14] && /*progress_level*/
    r[14][
      /*i*/
      r[43]
    ] != null) && yd(r)
  );
  return {
    c() {
      t && t.c(), e = Wn();
    },
    m(i, n) {
      t && t.m(i, n), ce(i, e, n);
    },
    p(i, n) {
      /*p*/
      i[41].desc != null || /*progress_level*/
      i[14] && /*progress_level*/
      i[14][
        /*i*/
        i[43]
      ] != null ? t ? t.p(i, n) : (t = yd(i), t.c(), t.m(e.parentNode, e)) : t && (t.d(1), t = null);
    },
    d(i) {
      i && he(e), t && t.d(i);
    }
  };
}
function Ed(r) {
  let e, t;
  return {
    c() {
      e = fi("p"), t = Ie(
        /*loading_text*/
        r[9]
      ), Yt(e, "class", "loading svelte-1yk38uw");
    },
    m(i, n) {
      ce(i, e, n), Pr(e, t);
    },
    p(i, n) {
      n[0] & /*loading_text*/
      512 && Dt(
        t,
        /*loading_text*/
        i[9]
      );
    },
    d(i) {
      i && he(e);
    }
  };
}
function a2(r) {
  let e, t, i, n, s;
  const o = [Jx, $x], a = [];
  function l(h, c) {
    return (
      /*status*/
      h[4] === "pending" ? 0 : (
        /*status*/
        h[4] === "error" ? 1 : -1
      )
    );
  }
  return ~(t = l(r)) && (i = a[t] = o[t](r)), {
    c() {
      e = fi("div"), i && i.c(), Yt(e, "class", n = "wrap " + /*variant*/
      r[8] + " " + /*show_progress*/
      r[6] + " svelte-1yk38uw"), Ct(e, "hide", !/*status*/
      r[4] || /*status*/
      r[4] === "complete" || /*show_progress*/
      r[6] === "hidden"), Ct(
        e,
        "translucent",
        /*variant*/
        r[8] === "center" && /*status*/
        (r[4] === "pending" || /*status*/
        r[4] === "error") || /*translucent*/
        r[11] || /*show_progress*/
        r[6] === "minimal"
      ), Ct(
        e,
        "generating",
        /*status*/
        r[4] === "generating"
      ), Ct(
        e,
        "border",
        /*border*/
        r[12]
      ), Yi(
        e,
        "position",
        /*absolute*/
        r[10] ? "absolute" : "static"
      ), Yi(
        e,
        "padding",
        /*absolute*/
        r[10] ? "0" : "var(--size-8) 0"
      );
    },
    m(h, c) {
      ce(h, e, c), ~t && a[t].m(e, null), r[33](e), s = !0;
    },
    p(h, c) {
      let u = t;
      t = l(h), t === u ? ~t && a[t].p(h, c) : (i && (H_(), Ur(a[u], 1, 1, () => {
        a[u] = null;
      }), L_()), ~t ? (i = a[t], i ? i.p(h, c) : (i = a[t] = o[t](h), i.c()), Nr(i, 1), i.m(e, null)) : i = null), (!s || c[0] & /*variant, show_progress*/
      320 && n !== (n = "wrap " + /*variant*/
      h[8] + " " + /*show_progress*/
      h[6] + " svelte-1yk38uw")) && Yt(e, "class", n), (!s || c[0] & /*variant, show_progress, status, show_progress*/
      336) && Ct(e, "hide", !/*status*/
      h[4] || /*status*/
      h[4] === "complete" || /*show_progress*/
      h[6] === "hidden"), (!s || c[0] & /*variant, show_progress, variant, status, translucent, show_progress*/
      2384) && Ct(
        e,
        "translucent",
        /*variant*/
        h[8] === "center" && /*status*/
        (h[4] === "pending" || /*status*/
        h[4] === "error") || /*translucent*/
        h[11] || /*show_progress*/
        h[6] === "minimal"
      ), (!s || c[0] & /*variant, show_progress, status*/
      336) && Ct(
        e,
        "generating",
        /*status*/
        h[4] === "generating"
      ), (!s || c[0] & /*variant, show_progress, border*/
      4416) && Ct(
        e,
        "border",
        /*border*/
        h[12]
      ), c[0] & /*absolute*/
      1024 && Yi(
        e,
        "position",
        /*absolute*/
        h[10] ? "absolute" : "static"
      ), c[0] & /*absolute*/
      1024 && Yi(
        e,
        "padding",
        /*absolute*/
        h[10] ? "0" : "var(--size-8) 0"
      );
    },
    i(h) {
      s || (Nr(i), s = !0);
    },
    o(h) {
      Ur(i), s = !1;
    },
    d(h) {
      h && he(e), ~t && a[t].d(), r[33](null);
    }
  };
}
var l2 = function(r, e, t, i) {
  function n(s) {
    return s instanceof t ? s : new t(function(o) {
      o(s);
    });
  }
  return new (t || (t = Promise))(function(s, o) {
    function a(c) {
      try {
        h(i.next(c));
      } catch (u) {
        o(u);
      }
    }
    function l(c) {
      try {
        h(i.throw(c));
      } catch (u) {
        o(u);
      }
    }
    function h(c) {
      c.done ? s(c.value) : n(c.value).then(a, l);
    }
    h((i = i.apply(r, e || [])).next());
  });
};
let Ys = [], Tl = !1;
function h2(r) {
  return l2(this, arguments, void 0, function* (e, t = !0) {
    if (!(window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && t !== !0)) {
      if (Ys.push(e), !Tl)
        Tl = !0;
      else
        return;
      yield qx(), requestAnimationFrame(() => {
        let i = [0, 0];
        for (let n = 0; n < Ys.length; n++) {
          const o = Ys[n].getBoundingClientRect();
          (n === 0 || o.top + window.scrollY <= i[0]) && (i[0] = o.top + window.scrollY, i[1] = n);
        }
        window.scrollTo({ top: i[0] - 20, behavior: "smooth" }), Tl = !1, Ys = [];
      });
    }
  });
}
function c2(r, e, t) {
  let i, { $$slots: n = {}, $$scope: s } = e;
  this && this.__awaiter;
  const o = Kx();
  let { i18n: a } = e, { eta: l = null } = e, { queue_position: h } = e, { queue_size: c } = e, { status: u } = e, { scroll_to_output: d = !1 } = e, { timer: f = !0 } = e, { show_progress: p = "full" } = e, { message: _ = null } = e, { progress: m = null } = e, { variant: y = "default" } = e, { loading_text: v = "Loading..." } = e, { absolute: g = !0 } = e, { translucent: b = !1 } = e, { border: w = !1 } = e, { autoscroll: T } = e, x, E = !1, R = 0, k = 0, O = null, B = null, C = 0, M = null, F, U = null, L = !0;
  const D = () => {
    t(0, l = t(27, O = t(19, S = null))), t(25, R = performance.now()), t(26, k = 0), E = !0, N();
  };
  function N() {
    requestAnimationFrame(() => {
      t(26, k = (performance.now() - R) / 1e3), E && N();
    });
  }
  function I() {
    t(26, k = 0), t(0, l = t(27, O = t(19, S = null))), E && (E = !1);
  }
  Yx(() => {
    E && I();
  });
  let S = null;
  function z(P) {
    hd[P ? "unshift" : "push"](() => {
      U = P, t(16, U), t(7, m), t(14, M), t(15, F);
    });
  }
  const V = () => {
    o("clear_status");
  };
  function $(P) {
    hd[P ? "unshift" : "push"](() => {
      x = P, t(13, x);
    });
  }
  return r.$$set = (P) => {
    "i18n" in P && t(1, a = P.i18n), "eta" in P && t(0, l = P.eta), "queue_position" in P && t(2, h = P.queue_position), "queue_size" in P && t(3, c = P.queue_size), "status" in P && t(4, u = P.status), "scroll_to_output" in P && t(22, d = P.scroll_to_output), "timer" in P && t(5, f = P.timer), "show_progress" in P && t(6, p = P.show_progress), "message" in P && t(23, _ = P.message), "progress" in P && t(7, m = P.progress), "variant" in P && t(8, y = P.variant), "loading_text" in P && t(9, v = P.loading_text), "absolute" in P && t(10, g = P.absolute), "translucent" in P && t(11, b = P.translucent), "border" in P && t(12, w = P.border), "autoscroll" in P && t(24, T = P.autoscroll), "$$scope" in P && t(29, s = P.$$scope);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
    436207617 && (l === null && t(0, l = O), l != null && O !== l && (t(28, B = (performance.now() - R) / 1e3 + l), t(19, S = B.toFixed(1)), t(27, O = l))), r.$$.dirty[0] & /*eta_from_start, timer_diff*/
    335544320 && t(17, C = B === null || B <= 0 || !k ? null : Math.min(k / B, 1)), r.$$.dirty[0] & /*progress*/
    128 && m != null && t(18, L = !1), r.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
    114816 && (m != null ? t(14, M = m.map((P) => {
      if (P.index != null && P.length != null)
        return P.index / P.length;
      if (P.progress != null)
        return P.progress;
    })) : t(14, M = null), M ? (t(15, F = M[M.length - 1]), U && (F === 0 ? t(16, U.style.transition = "0", U) : t(16, U.style.transition = "150ms", U))) : t(15, F = void 0)), r.$$.dirty[0] & /*status*/
    16 && (u === "pending" ? D() : I()), r.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
    20979728 && x && d && (u === "pending" || u === "complete") && h2(x, T), r.$$.dirty[0] & /*status, message*/
    8388624, r.$$.dirty[0] & /*timer_diff*/
    67108864 && t(20, i = k.toFixed(1));
  }, [
    l,
    a,
    h,
    c,
    u,
    f,
    p,
    m,
    y,
    v,
    g,
    b,
    w,
    x,
    M,
    F,
    U,
    C,
    L,
    S,
    i,
    o,
    d,
    _,
    T,
    R,
    k,
    O,
    B,
    s,
    n,
    z,
    V,
    $
  ];
}
class X_ extends Gx {
  constructor(e) {
    super(), Vx(
      this,
      e,
      c2,
      a2,
      Wx,
      {
        i18n: 1,
        eta: 0,
        queue_position: 2,
        queue_size: 3,
        status: 4,
        scroll_to_output: 22,
        timer: 5,
        show_progress: 6,
        message: 23,
        progress: 7,
        variant: 8,
        loading_text: 9,
        absolute: 10,
        translucent: 11,
        border: 12,
        autoscroll: 24
      },
      null,
      [-1, -1]
    );
  }
}
var qr = /* @__PURE__ */ ((r) => (r[r.WEBGL_LEGACY = 0] = "WEBGL_LEGACY", r[r.WEBGL = 1] = "WEBGL", r[r.WEBGL2 = 2] = "WEBGL2", r))(qr || {}), V_ = /* @__PURE__ */ ((r) => (r[r.UNKNOWN = 0] = "UNKNOWN", r[r.WEBGL = 1] = "WEBGL", r[r.CANVAS = 2] = "CANVAS", r))(V_ || {}), Oh = /* @__PURE__ */ ((r) => (r[r.COLOR = 16384] = "COLOR", r[r.DEPTH = 256] = "DEPTH", r[r.STENCIL = 1024] = "STENCIL", r))(Oh || {}), oe = /* @__PURE__ */ ((r) => (r[r.NORMAL = 0] = "NORMAL", r[r.ADD = 1] = "ADD", r[r.MULTIPLY = 2] = "MULTIPLY", r[r.SCREEN = 3] = "SCREEN", r[r.OVERLAY = 4] = "OVERLAY", r[r.DARKEN = 5] = "DARKEN", r[r.LIGHTEN = 6] = "LIGHTEN", r[r.COLOR_DODGE = 7] = "COLOR_DODGE", r[r.COLOR_BURN = 8] = "COLOR_BURN", r[r.HARD_LIGHT = 9] = "HARD_LIGHT", r[r.SOFT_LIGHT = 10] = "SOFT_LIGHT", r[r.DIFFERENCE = 11] = "DIFFERENCE", r[r.EXCLUSION = 12] = "EXCLUSION", r[r.HUE = 13] = "HUE", r[r.SATURATION = 14] = "SATURATION", r[r.COLOR = 15] = "COLOR", r[r.LUMINOSITY = 16] = "LUMINOSITY", r[r.NORMAL_NPM = 17] = "NORMAL_NPM", r[r.ADD_NPM = 18] = "ADD_NPM", r[r.SCREEN_NPM = 19] = "SCREEN_NPM", r[r.NONE = 20] = "NONE", r[r.SRC_OVER = 0] = "SRC_OVER", r[r.SRC_IN = 21] = "SRC_IN", r[r.SRC_OUT = 22] = "SRC_OUT", r[r.SRC_ATOP = 23] = "SRC_ATOP", r[r.DST_OVER = 24] = "DST_OVER", r[r.DST_IN = 25] = "DST_IN", r[r.DST_OUT = 26] = "DST_OUT", r[r.DST_ATOP = 27] = "DST_ATOP", r[r.ERASE = 26] = "ERASE", r[r.SUBTRACT = 28] = "SUBTRACT", r[r.XOR = 29] = "XOR", r))(oe || {}), pi = /* @__PURE__ */ ((r) => (r[r.POINTS = 0] = "POINTS", r[r.LINES = 1] = "LINES", r[r.LINE_LOOP = 2] = "LINE_LOOP", r[r.LINE_STRIP = 3] = "LINE_STRIP", r[r.TRIANGLES = 4] = "TRIANGLES", r[r.TRIANGLE_STRIP = 5] = "TRIANGLE_STRIP", r[r.TRIANGLE_FAN = 6] = "TRIANGLE_FAN", r))(pi || {}), G = /* @__PURE__ */ ((r) => (r[r.RGBA = 6408] = "RGBA", r[r.RGB = 6407] = "RGB", r[r.RG = 33319] = "RG", r[r.RED = 6403] = "RED", r[r.RGBA_INTEGER = 36249] = "RGBA_INTEGER", r[r.RGB_INTEGER = 36248] = "RGB_INTEGER", r[r.RG_INTEGER = 33320] = "RG_INTEGER", r[r.RED_INTEGER = 36244] = "RED_INTEGER", r[r.ALPHA = 6406] = "ALPHA", r[r.LUMINANCE = 6409] = "LUMINANCE", r[r.LUMINANCE_ALPHA = 6410] = "LUMINANCE_ALPHA", r[r.DEPTH_COMPONENT = 6402] = "DEPTH_COMPONENT", r[r.DEPTH_STENCIL = 34041] = "DEPTH_STENCIL", r))(G || {}), Tn = /* @__PURE__ */ ((r) => (r[r.TEXTURE_2D = 3553] = "TEXTURE_2D", r[r.TEXTURE_CUBE_MAP = 34067] = "TEXTURE_CUBE_MAP", r[r.TEXTURE_2D_ARRAY = 35866] = "TEXTURE_2D_ARRAY", r[r.TEXTURE_CUBE_MAP_POSITIVE_X = 34069] = "TEXTURE_CUBE_MAP_POSITIVE_X", r[r.TEXTURE_CUBE_MAP_NEGATIVE_X = 34070] = "TEXTURE_CUBE_MAP_NEGATIVE_X", r[r.TEXTURE_CUBE_MAP_POSITIVE_Y = 34071] = "TEXTURE_CUBE_MAP_POSITIVE_Y", r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072] = "TEXTURE_CUBE_MAP_NEGATIVE_Y", r[r.TEXTURE_CUBE_MAP_POSITIVE_Z = 34073] = "TEXTURE_CUBE_MAP_POSITIVE_Z", r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074] = "TEXTURE_CUBE_MAP_NEGATIVE_Z", r))(Tn || {}), re = /* @__PURE__ */ ((r) => (r[r.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE", r[r.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT", r[r.UNSIGNED_SHORT_5_6_5 = 33635] = "UNSIGNED_SHORT_5_6_5", r[r.UNSIGNED_SHORT_4_4_4_4 = 32819] = "UNSIGNED_SHORT_4_4_4_4", r[r.UNSIGNED_SHORT_5_5_5_1 = 32820] = "UNSIGNED_SHORT_5_5_5_1", r[r.UNSIGNED_INT = 5125] = "UNSIGNED_INT", r[r.UNSIGNED_INT_10F_11F_11F_REV = 35899] = "UNSIGNED_INT_10F_11F_11F_REV", r[r.UNSIGNED_INT_2_10_10_10_REV = 33640] = "UNSIGNED_INT_2_10_10_10_REV", r[r.UNSIGNED_INT_24_8 = 34042] = "UNSIGNED_INT_24_8", r[r.UNSIGNED_INT_5_9_9_9_REV = 35902] = "UNSIGNED_INT_5_9_9_9_REV", r[r.BYTE = 5120] = "BYTE", r[r.SHORT = 5122] = "SHORT", r[r.INT = 5124] = "INT", r[r.FLOAT = 5126] = "FLOAT", r[r.FLOAT_32_UNSIGNED_INT_24_8_REV = 36269] = "FLOAT_32_UNSIGNED_INT_24_8_REV", r[r.HALF_FLOAT = 36193] = "HALF_FLOAT", r))(re || {}), K = /* @__PURE__ */ ((r) => (r[r.FLOAT = 0] = "FLOAT", r[r.INT = 1] = "INT", r[r.UINT = 2] = "UINT", r))(K || {}), Ai = /* @__PURE__ */ ((r) => (r[r.NEAREST = 0] = "NEAREST", r[r.LINEAR = 1] = "LINEAR", r))(Ai || {}), tr = /* @__PURE__ */ ((r) => (r[r.CLAMP = 33071] = "CLAMP", r[r.REPEAT = 10497] = "REPEAT", r[r.MIRRORED_REPEAT = 33648] = "MIRRORED_REPEAT", r))(tr || {}), gi = /* @__PURE__ */ ((r) => (r[r.OFF = 0] = "OFF", r[r.POW2 = 1] = "POW2", r[r.ON = 2] = "ON", r[r.ON_MANUAL = 3] = "ON_MANUAL", r))(gi || {}), ut = /* @__PURE__ */ ((r) => (r[r.NPM = 0] = "NPM", r[r.UNPACK = 1] = "UNPACK", r[r.PMA = 2] = "PMA", r[r.NO_PREMULTIPLIED_ALPHA = 0] = "NO_PREMULTIPLIED_ALPHA", r[r.PREMULTIPLY_ON_UPLOAD = 1] = "PREMULTIPLY_ON_UPLOAD", r[r.PREMULTIPLIED_ALPHA = 2] = "PREMULTIPLIED_ALPHA", r))(ut || {}), ci = /* @__PURE__ */ ((r) => (r[r.NO = 0] = "NO", r[r.YES = 1] = "YES", r[r.AUTO = 2] = "AUTO", r[r.BLEND = 0] = "BLEND", r[r.CLEAR = 1] = "CLEAR", r[r.BLIT = 2] = "BLIT", r))(ci || {}), Kc = /* @__PURE__ */ ((r) => (r[r.AUTO = 0] = "AUTO", r[r.MANUAL = 1] = "MANUAL", r))(Kc || {}), Mt = /* @__PURE__ */ ((r) => (r.LOW = "lowp", r.MEDIUM = "mediump", r.HIGH = "highp", r))(Mt || {}), Ge = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.SCISSOR = 1] = "SCISSOR", r[r.STENCIL = 2] = "STENCIL", r[r.SPRITE = 3] = "SPRITE", r[r.COLOR = 4] = "COLOR", r))(Ge || {}), Le = /* @__PURE__ */ ((r) => (r[r.NONE = 0] = "NONE", r[r.LOW = 2] = "LOW", r[r.MEDIUM = 4] = "MEDIUM", r[r.HIGH = 8] = "HIGH", r))(Le || {}), _i = /* @__PURE__ */ ((r) => (r[r.ELEMENT_ARRAY_BUFFER = 34963] = "ELEMENT_ARRAY_BUFFER", r[r.ARRAY_BUFFER = 34962] = "ARRAY_BUFFER", r[r.UNIFORM_BUFFER = 35345] = "UNIFORM_BUFFER", r))(_i || {});
const u2 = {
  /**
   * Creates a canvas element of the given size.
   * This canvas is created using the browser's native canvas element.
   * @param width - width of the canvas
   * @param height - height of the canvas
   */
  createCanvas: (r, e) => {
    const t = document.createElement("canvas");
    return t.width = r, t.height = e, t;
  },
  getCanvasRenderingContext2D: () => CanvasRenderingContext2D,
  getWebGLRenderingContext: () => WebGLRenderingContext,
  getNavigator: () => navigator,
  getBaseUrl: () => document.baseURI ?? window.location.href,
  getFontFaceSet: () => document.fonts,
  fetch: (r, e) => fetch(r, e),
  parseXML: (r) => new DOMParser().parseFromString(r, "text/xml")
}, Z = {
  /**
   * This adapter is used to call methods that are platform dependent.
   * For example `document.createElement` only runs on the web but fails in node environments.
   * This allows us to support more platforms by abstracting away specific implementations per platform.
   *
   * By default the adapter is set to work in the browser. However you can create your own
   * by implementing the `IAdapter` interface. See `IAdapter` for more information.
   * @name ADAPTER
   * @memberof PIXI.settings
   * @type {PIXI.IAdapter}
   * @default PIXI.BrowserAdapter
   */
  ADAPTER: u2,
  /**
   * Default resolution / device pixel ratio of the renderer.
   * @static
   * @name RESOLUTION
   * @memberof PIXI.settings
   * @type {number}
   * @default 1
   */
  RESOLUTION: 1,
  /**
   * Enables bitmap creation before image load. This feature is experimental.
   * @static
   * @name CREATE_IMAGE_BITMAP
   * @memberof PIXI.settings
   * @type {boolean}
   * @default false
   */
  CREATE_IMAGE_BITMAP: !1,
  /**
   * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
   * Advantages can include sharper image quality (like text) and faster rendering on canvas.
   * The main disadvantage is movement of objects may appear less smooth.
   * @static
   * @memberof PIXI.settings
   * @type {boolean}
   * @default false
   */
  ROUND_PIXELS: !1
};
var Al = /iPhone/i, Td = /iPod/i, Ad = /iPad/i, Sd = /\biOS-universal(?:.+)Mac\b/i, Sl = /\bAndroid(?:.+)Mobile\b/i, Cd = /Android/i, tn = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i, Ks = /Silk/i, wi = /Windows Phone/i, Id = /\bWindows(?:.+)ARM\b/i, Rd = /BlackBerry/i, Pd = /BB10/i, Md = /Opera Mini/i, kd = /\b(CriOS|Chrome)(?:.+)Mobile/i, Dd = /Mobile(?:.+)Firefox\b/i, Bd = function(r) {
  return typeof r < "u" && r.platform === "MacIntel" && typeof r.maxTouchPoints == "number" && r.maxTouchPoints > 1 && typeof MSStream > "u";
};
function d2(r) {
  return function(e) {
    return e.test(r);
  };
}
function Fd(r) {
  var e = {
    userAgent: "",
    platform: "",
    maxTouchPoints: 0
  };
  !r && typeof navigator < "u" ? e = {
    userAgent: navigator.userAgent,
    platform: navigator.platform,
    maxTouchPoints: navigator.maxTouchPoints || 0
  } : typeof r == "string" ? e.userAgent = r : r && r.userAgent && (e = {
    userAgent: r.userAgent,
    platform: r.platform,
    maxTouchPoints: r.maxTouchPoints || 0
  });
  var t = e.userAgent, i = t.split("[FBAN");
  typeof i[1] < "u" && (t = i[0]), i = t.split("Twitter"), typeof i[1] < "u" && (t = i[0]);
  var n = d2(t), s = {
    apple: {
      phone: n(Al) && !n(wi),
      ipod: n(Td),
      tablet: !n(Al) && (n(Ad) || Bd(e)) && !n(wi),
      universal: n(Sd),
      device: (n(Al) || n(Td) || n(Ad) || n(Sd) || Bd(e)) && !n(wi)
    },
    amazon: {
      phone: n(tn),
      tablet: !n(tn) && n(Ks),
      device: n(tn) || n(Ks)
    },
    android: {
      phone: !n(wi) && n(tn) || !n(wi) && n(Sl),
      tablet: !n(wi) && !n(tn) && !n(Sl) && (n(Ks) || n(Cd)),
      device: !n(wi) && (n(tn) || n(Ks) || n(Sl) || n(Cd)) || n(/\bokhttp\b/i)
    },
    windows: {
      phone: n(wi),
      tablet: n(Id),
      device: n(wi) || n(Id)
    },
    other: {
      blackberry: n(Rd),
      blackberry10: n(Pd),
      opera: n(Md),
      firefox: n(Dd),
      chrome: n(kd),
      device: n(Rd) || n(Pd) || n(Md) || n(Dd) || n(kd)
    },
    any: !1,
    phone: !1,
    tablet: !1
  };
  return s.any = s.apple.device || s.android.device || s.windows.device || s.other.device, s.phone = s.apple.phone || s.android.phone || s.windows.phone, s.tablet = s.apple.tablet || s.android.tablet || s.windows.tablet, s;
}
const f2 = Fd.default ?? Fd, Si = f2(globalThis.navigator);
Z.RETINA_PREFIX = /@([0-9\.]+)x/;
Z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT = !1;
var Co = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function W_(r) {
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
}
function p2(r) {
  if (r.__esModule)
    return r;
  var e = r.default;
  if (typeof e == "function") {
    var t = function i() {
      return this instanceof i ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
    };
    t.prototype = e.prototype;
  } else
    t = {};
  return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(r).forEach(function(i) {
    var n = Object.getOwnPropertyDescriptor(r, i);
    Object.defineProperty(t, i, n.get ? n : {
      enumerable: !0,
      get: function() {
        return r[i];
      }
    });
  }), t;
}
var j_ = { exports: {} };
(function(r) {
  var e = Object.prototype.hasOwnProperty, t = "~";
  function i() {
  }
  Object.create && (i.prototype = /* @__PURE__ */ Object.create(null), new i().__proto__ || (t = !1));
  function n(l, h, c) {
    this.fn = l, this.context = h, this.once = c || !1;
  }
  function s(l, h, c, u, d) {
    if (typeof c != "function")
      throw new TypeError("The listener must be a function");
    var f = new n(c, u || l, d), p = t ? t + h : h;
    return l._events[p] ? l._events[p].fn ? l._events[p] = [l._events[p], f] : l._events[p].push(f) : (l._events[p] = f, l._eventsCount++), l;
  }
  function o(l, h) {
    --l._eventsCount === 0 ? l._events = new i() : delete l._events[h];
  }
  function a() {
    this._events = new i(), this._eventsCount = 0;
  }
  a.prototype.eventNames = function() {
    var h = [], c, u;
    if (this._eventsCount === 0)
      return h;
    for (u in c = this._events)
      e.call(c, u) && h.push(t ? u.slice(1) : u);
    return Object.getOwnPropertySymbols ? h.concat(Object.getOwnPropertySymbols(c)) : h;
  }, a.prototype.listeners = function(h) {
    var c = t ? t + h : h, 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;
  }, a.prototype.listenerCount = function(h) {
    var c = t ? t + h : h, u = this._events[c];
    return u ? u.fn ? 1 : u.length : 0;
  }, a.prototype.emit = function(h, c, u, d, f, p) {
    var _ = t ? t + h : h;
    if (!this._events[_])
      return !1;
    var m = this._events[_], y = arguments.length, v, g;
    if (m.fn) {
      switch (m.once && this.removeListener(h, m.fn, void 0, !0), y) {
        case 1:
          return m.fn.call(m.context), !0;
        case 2:
          return m.fn.call(m.context, c), !0;
        case 3:
          return m.fn.call(m.context, c, u), !0;
        case 4:
          return m.fn.call(m.context, c, u, d), !0;
        case 5:
          return m.fn.call(m.context, c, u, d, f), !0;
        case 6:
          return m.fn.call(m.context, c, u, d, f, p), !0;
      }
      for (g = 1, v = new Array(y - 1); g < y; g++)
        v[g - 1] = arguments[g];
      m.fn.apply(m.context, v);
    } else {
      var b = m.length, w;
      for (g = 0; g < b; g++)
        switch (m[g].once && this.removeListener(h, m[g].fn, void 0, !0), y) {
          case 1:
            m[g].fn.call(m[g].context);
            break;
          case 2:
            m[g].fn.call(m[g].context, c);
            break;
          case 3:
            m[g].fn.call(m[g].context, c, u);
            break;
          case 4:
            m[g].fn.call(m[g].context, c, u, d);
            break;
          default:
            if (!v)
              for (w = 1, v = new Array(y - 1); w < y; w++)
                v[w - 1] = arguments[w];
            m[g].fn.apply(m[g].context, v);
        }
    }
    return !0;
  }, a.prototype.on = function(h, c, u) {
    return s(this, h, c, u, !1);
  }, a.prototype.once = function(h, c, u) {
    return s(this, h, c, u, !0);
  }, a.prototype.removeListener = function(h, c, u, d) {
    var f = t ? t + h : h;
    if (!this._events[f])
      return this;
    if (!c)
      return o(this, f), this;
    var p = this._events[f];
    if (p.fn)
      p.fn === c && (!d || p.once) && (!u || p.context === u) && o(this, f);
    else {
      for (var _ = 0, m = [], y = p.length; _ < y; _++)
        (p[_].fn !== c || d && !p[_].once || u && p[_].context !== u) && m.push(p[_]);
      m.length ? this._events[f] = m.length === 1 ? m[0] : m : o(this, f);
    }
    return this;
  }, a.prototype.removeAllListeners = function(h) {
    var c;
    return h ? (c = t ? t + h : h, this._events[c] && o(this, c)) : (this._events = new i(), this._eventsCount = 0), this;
  }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = t, a.EventEmitter = a, r.exports = a;
})(j_);
var _2 = j_.exports;
const Fs = /* @__PURE__ */ W_(_2);
var Zc = { exports: {} };
Zc.exports = Ra;
Zc.exports.default = Ra;
function Ra(r, e, t) {
  t = t || 2;
  var i = e && e.length, n = i ? e[0] * t : r.length, s = q_(r, 0, n, t, !0), o = [];
  if (!s || s.next === s.prev)
    return o;
  var a, l, h, c, u, d, f;
  if (i && (s = b2(r, e, s, t)), r.length > 80 * t) {
    a = h = r[0], l = c = r[1];
    for (var p = t; p < n; p += t)
      u = r[p], d = r[p + 1], u < a && (a = u), d < l && (l = d), u > h && (h = u), d > c && (c = d);
    f = Math.max(h - a, c - l), f = f !== 0 ? 32767 / f : 0;
  }
  return Ps(s, o, t, a, l, f, 0), o;
}
function q_(r, e, t, i, n) {
  var s, o;
  if (n === Uh(r, e, t, i) > 0)
    for (s = e; s < t; s += i)
      o = Od(s, r[s], r[s + 1], o);
  else
    for (s = t - i; s >= e; s -= i)
      o = Od(s, r[s], r[s + 1], o);
  return o && Pa(o, o.next) && (ks(o), o = o.next), o;
}
function Gr(r, e) {
  if (!r)
    return r;
  e || (e = r);
  var t = r, i;
  do
    if (i = !1, !t.steiner && (Pa(t, t.next) || Re(t.prev, t, t.next) === 0)) {
      if (ks(t), t = e = t.prev, t === t.next)
        break;
      i = !0;
    } else
      t = t.next;
  while (i || t !== e);
  return e;
}
function Ps(r, e, t, i, n, s, o) {
  if (r) {
    !o && s && A2(r, i, n, s);
    for (var a = r, l, h; r.prev !== r.next; ) {
      if (l = r.prev, h = r.next, s ? g2(r, i, n, s) : m2(r)) {
        e.push(l.i / t | 0), e.push(r.i / t | 0), e.push(h.i / t | 0), ks(r), r = h.next, a = h.next;
        continue;
      }
      if (r = h, r === a) {
        o ? o === 1 ? (r = y2(Gr(r), e, t), Ps(r, e, t, i, n, s, 2)) : o === 2 && v2(r, e, t, i, n, s) : Ps(Gr(r), e, t, i, n, s, 1);
        break;
      }
    }
  }
}
function m2(r) {
  var e = r.prev, t = r, i = r.next;
  if (Re(e, t, i) >= 0)
    return !1;
  for (var n = e.x, s = t.x, o = i.x, a = e.y, l = t.y, h = i.y, c = n < s ? n < o ? n : o : s < o ? s : o, u = a < l ? a < h ? a : h : l < h ? l : h, d = n > s ? n > o ? n : o : s > o ? s : o, f = a > l ? a > h ? a : h : l > h ? l : h, p = i.next; p !== e; ) {
    if (p.x >= c && p.x <= d && p.y >= u && p.y <= f && wn(n, a, s, l, o, h, p.x, p.y) && Re(p.prev, p, p.next) >= 0)
      return !1;
    p = p.next;
  }
  return !0;
}
function g2(r, e, t, i) {
  var n = r.prev, s = r, o = r.next;
  if (Re(n, s, o) >= 0)
    return !1;
  for (var a = n.x, l = s.x, h = o.x, c = n.y, u = s.y, d = o.y, f = a < l ? a < h ? a : h : l < h ? l : h, p = c < u ? c < d ? c : d : u < d ? u : d, _ = a > l ? a > h ? a : h : l > h ? l : h, m = c > u ? c > d ? c : d : u > d ? u : d, y = Lh(f, p, e, t, i), v = Lh(_, m, e, t, i), g = r.prevZ, b = r.nextZ; g && g.z >= y && b && b.z <= v; ) {
    if (g.x >= f && g.x <= _ && g.y >= p && g.y <= m && g !== n && g !== o && wn(a, c, l, u, h, d, g.x, g.y) && Re(g.prev, g, g.next) >= 0 || (g = g.prevZ, b.x >= f && b.x <= _ && b.y >= p && b.y <= m && b !== n && b !== o && wn(a, c, l, u, h, d, b.x, b.y) && Re(b.prev, b, b.next) >= 0))
      return !1;
    b = b.nextZ;
  }
  for (; g && g.z >= y; ) {
    if (g.x >= f && g.x <= _ && g.y >= p && g.y <= m && g !== n && g !== o && wn(a, c, l, u, h, d, g.x, g.y) && Re(g.prev, g, g.next) >= 0)
      return !1;
    g = g.prevZ;
  }
  for (; b && b.z <= v; ) {
    if (b.x >= f && b.x <= _ && b.y >= p && b.y <= m && b !== n && b !== o && wn(a, c, l, u, h, d, b.x, b.y) && Re(b.prev, b, b.next) >= 0)
      return !1;
    b = b.nextZ;
  }
  return !0;
}
function y2(r, e, t) {
  var i = r;
  do {
    var n = i.prev, s = i.next.next;
    !Pa(n, s) && Y_(n, i, i.next, s) && Ms(n, s) && Ms(s, n) && (e.push(n.i / t | 0), e.push(i.i / t | 0), e.push(s.i / t | 0), ks(i), ks(i.next), i = r = s), i = i.next;
  } while (i !== r);
  return Gr(i);
}
function v2(r, e, t, i, n, s) {
  var o = r;
  do {
    for (var a = o.next.next; a !== o.prev; ) {
      if (o.i !== a.i && I2(o, a)) {
        var l = K_(o, a);
        o = Gr(o, o.next), l = Gr(l, l.next), Ps(o, e, t, i, n, s, 0), Ps(l, e, t, i, n, s, 0);
        return;
      }
      a = a.next;
    }
    o = o.next;
  } while (o !== r);
}
function b2(r, e, t, i) {
  var n = [], s, o, a, l, h;
  for (s = 0, o = e.length; s < o; s++)
    a = e[s] * i, l = s < o - 1 ? e[s + 1] * i : r.length, h = q_(r, a, l, i, !1), h === h.next && (h.steiner = !0), n.push(C2(h));
  for (n.sort(w2), s = 0; s < n.length; s++)
    t = x2(n[s], t);
  return t;
}
function w2(r, e) {
  return r.x - e.x;
}
function x2(r, e) {
  var t = E2(r, e);
  if (!t)
    return e;
  var i = K_(t, r);
  return Gr(i, i.next), Gr(t, t.next);
}
function E2(r, e) {
  var t = e, i = r.x, n = r.y, s = -1 / 0, o;
  do {
    if (n <= t.y && n >= t.next.y && t.next.y !== t.y) {
      var a = t.x + (n - t.y) * (t.next.x - t.x) / (t.next.y - t.y);
      if (a <= i && a > s && (s = a, o = t.x < t.next.x ? t : t.next, a === i))
        return o;
    }
    t = t.next;
  } while (t !== e);
  if (!o)
    return null;
  var l = o, h = o.x, c = o.y, u = 1 / 0, d;
  t = o;
  do
    i >= t.x && t.x >= h && i !== t.x && wn(n < c ? i : s, n, h, c, n < c ? s : i, n, t.x, t.y) && (d = Math.abs(n - t.y) / (i - t.x), Ms(t, r) && (d < u || d === u && (t.x > o.x || t.x === o.x && T2(o, t))) && (o = t, u = d)), t = t.next;
  while (t !== l);
  return o;
}
function T2(r, e) {
  return Re(r.prev, r, e.prev) < 0 && Re(e.next, r, r.next) < 0;
}
function A2(r, e, t, i) {
  var n = r;
  do
    n.z === 0 && (n.z = Lh(n.x, n.y, e, t, i)), n.prevZ = n.prev, n.nextZ = n.next, n = n.next;
  while (n !== r);
  n.prevZ.nextZ = null, n.prevZ = null, S2(n);
}
function S2(r) {
  var e, t, i, n, s, o, a, l, h = 1;
  do {
    for (t = r, r = null, s = null, o = 0; t; ) {
      for (o++, i = t, a = 0, e = 0; e < h && (a++, i = i.nextZ, !!i); e++)
        ;
      for (l = h; a > 0 || l > 0 && i; )
        a !== 0 && (l === 0 || !i || t.z <= i.z) ? (n = t, t = t.nextZ, a--) : (n = i, i = i.nextZ, l--), s ? s.nextZ = n : r = n, n.prevZ = s, s = n;
      t = i;
    }
    s.nextZ = null, h *= 2;
  } while (o > 1);
  return r;
}
function Lh(r, e, t, i, n) {
  return r = (r - t) * n | 0, e = (e - i) * n | 0, r = (r | r << 8) & 16711935, r = (r | r << 4) & 252645135, r = (r | r << 2) & 858993459, r = (r | r << 1) & 1431655765, e = (e | e << 8) & 16711935, e = (e | e << 4) & 252645135, e = (e | e << 2) & 858993459, e = (e | e << 1) & 1431655765, r | e << 1;
}
function C2(r) {
  var e = r, t = r;
  do
    (e.x < t.x || e.x === t.x && e.y < t.y) && (t = e), e = e.next;
  while (e !== r);
  return t;
}
function wn(r, e, t, i, n, s, o, a) {
  return (n - o) * (e - a) >= (r - o) * (s - a) && (r - o) * (i - a) >= (t - o) * (e - a) && (t - o) * (s - a) >= (n - o) * (i - a);
}
function I2(r, e) {
  return r.next.i !== e.i && r.prev.i !== e.i && !R2(r, e) && // dones't intersect other edges
  (Ms(r, e) && Ms(e, r) && P2(r, e) && // locally visible
  (Re(r.prev, r, e.prev) || Re(r, e.prev, e)) || // does not create opposite-facing sectors
  Pa(r, e) && Re(r.prev, r, r.next) > 0 && Re(e.prev, e, e.next) > 0);
}
function Re(r, e, t) {
  return (e.y - r.y) * (t.x - e.x) - (e.x - r.x) * (t.y - e.y);
}
function Pa(r, e) {
  return r.x === e.x && r.y === e.y;
}
function Y_(r, e, t, i) {
  var n = $s(Re(r, e, t)), s = $s(Re(r, e, i)), o = $s(Re(t, i, r)), a = $s(Re(t, i, e));
  return !!(n !== s && o !== a || n === 0 && Zs(r, t, e) || s === 0 && Zs(r, i, e) || o === 0 && Zs(t, r, i) || a === 0 && Zs(t, e, i));
}
function Zs(r, e, t) {
  return e.x <= Math.max(r.x, t.x) && e.x >= Math.min(r.x, t.x) && e.y <= Math.max(r.y, t.y) && e.y >= Math.min(r.y, t.y);
}
function $s(r) {
  return r > 0 ? 1 : r < 0 ? -1 : 0;
}
function R2(r, e) {
  var t = r;
  do {
    if (t.i !== r.i && t.next.i !== r.i && t.i !== e.i && t.next.i !== e.i && Y_(t, t.next, r, e))
      return !0;
    t = t.next;
  } while (t !== r);
  return !1;
}
function Ms(r, e) {
  return Re(r.prev, r, r.next) < 0 ? Re(r, e, r.next) >= 0 && Re(r, r.prev, e) >= 0 : Re(r, e, r.prev) < 0 || Re(r, r.next, e) < 0;
}
function P2(r, e) {
  var t = r, i = !1, n = (r.x + e.x) / 2, s = (r.y + e.y) / 2;
  do
    t.y > s != t.next.y > s && t.next.y !== t.y && n < (t.next.x - t.x) * (s - t.y) / (t.next.y - t.y) + t.x && (i = !i), t = t.next;
  while (t !== r);
  return i;
}
function K_(r, e) {
  var t = new Nh(r.i, r.x, r.y), i = new Nh(e.i, e.x, e.y), n = r.next, s = e.prev;
  return r.next = e, e.prev = r, t.next = n, n.prev = t, i.next = t, t.prev = i, s.next = i, i.prev = s, i;
}
function Od(r, e, t, i) {
  var n = new Nh(r, e, t);
  return i ? (n.next = i.next, n.prev = i, i.next.prev = n, i.next = n) : (n.prev = n, n.next = n), n;
}
function ks(r) {
  r.next.prev = r.prev, r.prev.next = r.next, r.prevZ && (r.prevZ.nextZ = r.nextZ), r.nextZ && (r.nextZ.prevZ = r.prevZ);
}
function Nh(r, e, t) {
  this.i = r, this.x = e, this.y = t, this.prev = null, this.next = null, this.z = 0, this.prevZ = null, this.nextZ = null, this.steiner = !1;
}
Ra.deviation = function(r, e, t, i) {
  var n = e && e.length, s = n ? e[0] * t : r.length, o = Math.abs(Uh(r, 0, s, t));
  if (n)
    for (var a = 0, l = e.length; a < l; a++) {
      var h = e[a] * t, c = a < l - 1 ? e[a + 1] * t : r.length;
      o -= Math.abs(Uh(r, h, c, t));
    }
  var u = 0;
  for (a = 0; a < i.length; a += 3) {
    var d = i[a] * t, f = i[a + 1] * t, p = i[a + 2] * t;
    u += Math.abs(
      (r[d] - r[p]) * (r[f + 1] - r[d + 1]) - (r[d] - r[f]) * (r[p + 1] - r[d + 1])
    );
  }
  return o === 0 && u === 0 ? 0 : Math.abs((u - o) / o);
};
function Uh(r, e, t, i) {
  for (var n = 0, s = e, o = t - i; s < t; s += i)
    n += (r[o] - r[s]) * (r[s + 1] + r[o + 1]), o = s;
  return n;
}
Ra.flatten = function(r) {
  for (var e = r[0][0].length, t = { vertices: [], holes: [], dimensions: e }, i = 0, n = 0; n < r.length; n++) {
    for (var s = 0; s < r[n].length; s++)
      for (var o = 0; o < e; o++)
        t.vertices.push(r[n][s][o]);
    n > 0 && (i += r[n - 1].length, t.holes.push(i));
  }
  return t;
};
var M2 = Zc.exports;
const k2 = /* @__PURE__ */ W_(M2);
var Qo = { exports: {} };
/*! https://mths.be/punycode v1.4.1 by @mathias */
Qo.exports;
(function(r, e) {
  (function(t) {
    var i = e && !e.nodeType && e, n = r && !r.nodeType && r, s = typeof Co == "object" && Co;
    (s.global === s || s.window === s || s.self === s) && (t = s);
    var o, a = 2147483647, l = 36, h = 1, c = 26, u = 38, d = 700, f = 72, p = 128, _ = "-", m = /^xn--/, y = /[^\x20-\x7E]/, v = /[\x2E\u3002\uFF0E\uFF61]/g, g = {
      overflow: "Overflow: input needs wider integers to process",
      "not-basic": "Illegal input >= 0x80 (not a basic code point)",
      "invalid-input": "Invalid input"
    }, b = l - h, w = Math.floor, T = String.fromCharCode, x;
    function E(I) {
      throw new RangeError(g[I]);
    }
    function R(I, S) {
      for (var z = I.length, V = []; z--; )
        V[z] = S(I[z]);
      return V;
    }
    function k(I, S) {
      var z = I.split("@"), V = "";
      z.length > 1 && (V = z[0] + "@", I = z[1]), I = I.replace(v, ".");
      var $ = I.split("."), P = R($, S).join(".");
      return V + P;
    }
    function O(I) {
      for (var S = [], z = 0, V = I.length, $, P; z < V; )
        $ = I.charCodeAt(z++), $ >= 55296 && $ <= 56319 && z < V ? (P = I.charCodeAt(z++), (P & 64512) == 56320 ? S.push((($ & 1023) << 10) + (P & 1023) + 65536) : (S.push($), z--)) : S.push($);
      return S;
    }
    function B(I) {
      return R(I, function(S) {
        var z = "";
        return S > 65535 && (S -= 65536, z += T(S >>> 10 & 1023 | 55296), S = 56320 | S & 1023), z += T(S), z;
      }).join("");
    }
    function C(I) {
      return I - 48 < 10 ? I - 22 : I - 65 < 26 ? I - 65 : I - 97 < 26 ? I - 97 : l;
    }
    function M(I, S) {
      return I + 22 + 75 * (I < 26) - ((S != 0) << 5);
    }
    function F(I, S, z) {
      var V = 0;
      for (I = z ? w(I / d) : I >> 1, I += w(I / S); I > b * c >> 1; V += l)
        I = w(I / b);
      return w(V + (b + 1) * I / (I + u));
    }
    function U(I) {
      var S = [], z = I.length, V, $ = 0, P = p, ie = f, A, X, te, j, W, se, ue, _e, de;
      for (A = I.lastIndexOf(_), A < 0 && (A = 0), X = 0; X < A; ++X)
        I.charCodeAt(X) >= 128 && E("not-basic"), S.push(I.charCodeAt(X));
      for (te = A > 0 ? A + 1 : 0; te < z; ) {
        for (j = $, W = 1, se = l; te >= z && E("invalid-input"), ue = C(I.charCodeAt(te++)), (ue >= l || ue > w((a - $) / W)) && E("overflow"), $ += ue * W, _e = se <= ie ? h : se >= ie + c ? c : se - ie, !(ue < _e); se += l)
          de = l - _e, W > w(a / de) && E("overflow"), W *= de;
        V = S.length + 1, ie = F($ - j, V, j == 0), w($ / V) > a - P && E("overflow"), P += w($ / V), $ %= V, S.splice($++, 0, P);
      }
      return B(S);
    }
    function L(I) {
      var S, z, V, $, P, ie, A, X, te, j, W, se = [], ue, _e, de, xe;
      for (I = O(I), ue = I.length, S = p, z = 0, P = f, ie = 0; ie < ue; ++ie)
        W = I[ie], W < 128 && se.push(T(W));
      for (V = $ = se.length, $ && se.push(_); V < ue; ) {
        for (A = a, ie = 0; ie < ue; ++ie)
          W = I[ie], W >= S && W < A && (A = W);
        for (_e = V + 1, A - S > w((a - z) / _e) && E("overflow"), z += (A - S) * _e, S = A, ie = 0; ie < ue; ++ie)
          if (W = I[ie], W < S && ++z > a && E("overflow"), W == S) {
            for (X = z, te = l; j = te <= P ? h : te >= P + c ? c : te - P, !(X < j); te += l)
              xe = X - j, de = l - j, se.push(
                T(M(j + xe % de, 0))
              ), X = w(xe / de);
            se.push(T(M(X, 0))), P = F(z, _e, V == $), z = 0, ++V;
          }
        ++z, ++S;
      }
      return se.join("");
    }
    function D(I) {
      return k(I, function(S) {
        return m.test(S) ? U(S.slice(4).toLowerCase()) : S;
      });
    }
    function N(I) {
      return k(I, function(S) {
        return y.test(S) ? "xn--" + L(S) : S;
      });
    }
    if (o = {
      /**
       * A string representing the current Punycode.js version number.
       * @memberOf punycode
       * @type String
       */
      version: "1.4.1",
      /**
       * An object of methods to convert from JavaScript's internal character
       * representation (UCS-2) to Unicode code points, and back.
       * @see <https://mathiasbynens.be/notes/javascript-encoding>
       * @memberOf punycode
       * @type Object
       */
      ucs2: {
        decode: O,
        encode: B
      },
      decode: U,
      encode: L,
      toASCII: N,
      toUnicode: D
    }, i && n)
      if (r.exports == i)
        n.exports = o;
      else
        for (x in o)
          o.hasOwnProperty(x) && (i[x] = o[x]);
    else
      t.punycode = o;
  })(Co);
})(Qo, Qo.exports);
var D2 = Qo.exports, B2 = Error, F2 = EvalError, O2 = RangeError, L2 = ReferenceError, Z_ = SyntaxError, Os = TypeError, N2 = URIError, U2 = function() {
  if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function")
    return !1;
  if (typeof Symbol.iterator == "symbol")
    return !0;
  var e = {}, t = Symbol("test"), i = Object(t);
  if (typeof t == "string" || Object.prototype.toString.call(t) !== "[object Symbol]" || Object.prototype.toString.call(i) !== "[object Symbol]")
    return !1;
  var n = 42;
  e[t] = n;
  for (t in e)
    return !1;
  if (typeof Object.keys == "function" && Object.keys(e).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(e).length !== 0)
    return !1;
  var s = Object.getOwnPropertySymbols(e);
  if (s.length !== 1 || s[0] !== t || !Object.prototype.propertyIsEnumerable.call(e, t))
    return !1;
  if (typeof Object.getOwnPropertyDescriptor == "function") {
    var o = Object.getOwnPropertyDescriptor(e, t);
    if (o.value !== n || o.enumerable !== !0)
      return !1;
  }
  return !0;
}, Ld = typeof Symbol < "u" && Symbol, G2 = U2, H2 = function() {
  return typeof Ld != "function" || typeof Symbol != "function" || typeof Ld("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : G2();
}, Cl = {
  __proto__: null,
  foo: {}
}, z2 = Object, X2 = function() {
  return { __proto__: Cl }.foo === Cl.foo && !(Cl instanceof z2);
}, V2 = "Function.prototype.bind called on incompatible ", W2 = Object.prototype.toString, j2 = Math.max, q2 = "[object Function]", Nd = function(e, t) {
  for (var i = [], n = 0; n < e.length; n += 1)
    i[n] = e[n];
  for (var s = 0; s < t.length; s += 1)
    i[s + e.length] = t[s];
  return i;
}, Y2 = function(e, t) {
  for (var i = [], n = t, s = 0; n < e.length; n += 1, s += 1)
    i[s] = e[n];
  return i;
}, K2 = function(r, e) {
  for (var t = "", i = 0; i < r.length; i += 1)
    t += r[i], i + 1 < r.length && (t += e);
  return t;
}, Z2 = function(e) {
  var t = this;
  if (typeof t != "function" || W2.apply(t) !== q2)
    throw new TypeError(V2 + t);
  for (var i = Y2(arguments, 1), n, s = function() {
    if (this instanceof n) {
      var c = t.apply(
        this,
        Nd(i, arguments)
      );
      return Object(c) === c ? c : this;
    }
    return t.apply(
      e,
      Nd(i, arguments)
    );
  }, o = j2(0, t.length - i.length), a = [], l = 0; l < o; l++)
    a[l] = "$" + l;
  if (n = Function("binder", "return function (" + K2(a, ",") + "){ return binder.apply(this,arguments); }")(s), t.prototype) {
    var h = function() {
    };
    h.prototype = t.prototype, n.prototype = new h(), h.prototype = null;
  }
  return n;
}, $2 = Z2, $c = Function.prototype.bind || $2, J2 = Function.prototype.call, Q2 = Object.prototype.hasOwnProperty, eE = $c, tE = eE.call(J2, Q2), pe, iE = B2, rE = F2, nE = O2, sE = L2, Fn = Z_, An = Os, oE = N2, $_ = Function, Il = function(r) {
  try {
    return $_('"use strict"; return (' + r + ").constructor;")();
  } catch {
  }
}, Mr = Object.getOwnPropertyDescriptor;
if (Mr)
  try {
    Mr({}, "");
  } catch {
    Mr = null;
  }
var Rl = function() {
  throw new An();
}, aE = Mr ? function() {
  try {
    return arguments.callee, Rl;
  } catch {
    try {
      return Mr(arguments, "callee").get;
    } catch {
      return Rl;
    }
  }
}() : Rl, rn = H2(), lE = X2(), He = Object.getPrototypeOf || (lE ? function(r) {
  return r.__proto__;
} : null), un = {}, hE = typeof Uint8Array > "u" || !He ? pe : He(Uint8Array), kr = {
  __proto__: null,
  "%AggregateError%": typeof AggregateError > "u" ? pe : AggregateError,
  "%Array%": Array,
  "%ArrayBuffer%": typeof ArrayBuffer > "u" ? pe : ArrayBuffer,
  "%ArrayIteratorPrototype%": rn && He ? He([][Symbol.iterator]()) : pe,
  "%AsyncFromSyncIteratorPrototype%": pe,
  "%AsyncFunction%": un,
  "%AsyncGenerator%": un,
  "%AsyncGeneratorFunction%": un,
  "%AsyncIteratorPrototype%": un,
  "%Atomics%": typeof Atomics > "u" ? pe : Atomics,
  "%BigInt%": typeof BigInt > "u" ? pe : BigInt,
  "%BigInt64Array%": typeof BigInt64Array > "u" ? pe : BigInt64Array,
  "%BigUint64Array%": typeof BigUint64Array > "u" ? pe : BigUint64Array,
  "%Boolean%": Boolean,
  "%DataView%": typeof DataView > "u" ? pe : DataView,
  "%Date%": Date,
  "%decodeURI%": decodeURI,
  "%decodeURIComponent%": decodeURIComponent,
  "%encodeURI%": encodeURI,
  "%encodeURIComponent%": encodeURIComponent,
  "%Error%": iE,
  "%eval%": eval,
  // eslint-disable-line no-eval
  "%EvalError%": rE,
  "%Float32Array%": typeof Float32Array > "u" ? pe : Float32Array,
  "%Float64Array%": typeof Float64Array > "u" ? pe : Float64Array,
  "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? pe : FinalizationRegistry,
  "%Function%": $_,
  "%GeneratorFunction%": un,
  "%Int8Array%": typeof Int8Array > "u" ? pe : Int8Array,
  "%Int16Array%": typeof Int16Array > "u" ? pe : Int16Array,
  "%Int32Array%": typeof Int32Array > "u" ? pe : Int32Array,
  "%isFinite%": isFinite,
  "%isNaN%": isNaN,
  "%IteratorPrototype%": rn && He ? He(He([][Symbol.iterator]())) : pe,
  "%JSON%": typeof JSON == "object" ? JSON : pe,
  "%Map%": typeof Map > "u" ? pe : Map,
  "%MapIteratorPrototype%": typeof Map > "u" || !rn || !He ? pe : He((/* @__PURE__ */ new Map())[Symbol.iterator]()),
  "%Math%": Math,
  "%Number%": Number,
  "%Object%": Object,
  "%parseFloat%": parseFloat,
  "%parseInt%": parseInt,
  "%Promise%": typeof Promise > "u" ? pe : Promise,
  "%Proxy%": typeof Proxy > "u" ? pe : Proxy,
  "%RangeError%": nE,
  "%ReferenceError%": sE,
  "%Reflect%": typeof Reflect > "u" ? pe : Reflect,
  "%RegExp%": RegExp,
  "%Set%": typeof Set > "u" ? pe : Set,
  "%SetIteratorPrototype%": typeof Set > "u" || !rn || !He ? pe : He((/* @__PURE__ */ new Set())[Symbol.iterator]()),
  "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? pe : SharedArrayBuffer,
  "%String%": String,
  "%StringIteratorPrototype%": rn && He ? He(""[Symbol.iterator]()) : pe,
  "%Symbol%": rn ? Symbol : pe,
  "%SyntaxError%": Fn,
  "%ThrowTypeError%": aE,
  "%TypedArray%": hE,
  "%TypeError%": An,
  "%Uint8Array%": typeof Uint8Array > "u" ? pe : Uint8Array,
  "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? pe : Uint8ClampedArray,
  "%Uint16Array%": typeof Uint16Array > "u" ? pe : Uint16Array,
  "%Uint32Array%": typeof Uint32Array > "u" ? pe : Uint32Array,
  "%URIError%": oE,
  "%WeakMap%": typeof WeakMap > "u" ? pe : WeakMap,
  "%WeakRef%": typeof WeakRef > "u" ? pe : WeakRef,
  "%WeakSet%": typeof WeakSet > "u" ? pe : WeakSet
};
if (He)
  try {
    null.error;
  } catch (r) {
    var cE = He(He(r));
    kr["%Error.prototype%"] = cE;
  }
var uE = function r(e) {
  var t;
  if (e === "%AsyncFunction%")
    t = Il("async function () {}");
  else if (e === "%GeneratorFunction%")
    t = Il("function* () {}");
  else if (e === "%AsyncGeneratorFunction%")
    t = Il("async function* () {}");
  else if (e === "%AsyncGenerator%") {
    var i = r("%AsyncGeneratorFunction%");
    i && (t = i.prototype);
  } else if (e === "%AsyncIteratorPrototype%") {
    var n = r("%AsyncGenerator%");
    n && He && (t = He(n.prototype));
  }
  return kr[e] = t, t;
}, Ud = {
  __proto__: null,
  "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
  "%ArrayPrototype%": ["Array", "prototype"],
  "%ArrayProto_entries%": ["Array", "prototype", "entries"],
  "%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
  "%ArrayProto_keys%": ["Array", "prototype", "keys"],
  "%ArrayProto_values%": ["Array", "prototype", "values"],
  "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
  "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
  "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
  "%BooleanPrototype%": ["Boolean", "prototype"],
  "%DataViewPrototype%": ["DataView", "prototype"],
  "%DatePrototype%": ["Date", "prototype"],
  "%ErrorPrototype%": ["Error", "prototype"],
  "%EvalErrorPrototype%": ["EvalError", "prototype"],
  "%Float32ArrayPrototype%": ["Float32Array", "prototype"],
  "%Float64ArrayPrototype%": ["Float64Array", "prototype"],
  "%FunctionPrototype%": ["Function", "prototype"],
  "%Generator%": ["GeneratorFunction", "prototype"],
  "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
  "%Int8ArrayPrototype%": ["Int8Array", "prototype"],
  "%Int16ArrayPrototype%": ["Int16Array", "prototype"],
  "%Int32ArrayPrototype%": ["Int32Array", "prototype"],
  "%JSONParse%": ["JSON", "parse"],
  "%JSONStringify%": ["JSON", "stringify"],
  "%MapPrototype%": ["Map", "prototype"],
  "%NumberPrototype%": ["Number", "prototype"],
  "%ObjectPrototype%": ["Object", "prototype"],
  "%ObjProto_toString%": ["Object", "prototype", "toString"],
  "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
  "%PromisePrototype%": ["Promise", "prototype"],
  "%PromiseProto_then%": ["Promise", "prototype", "then"],
  "%Promise_all%": ["Promise", "all"],
  "%Promise_reject%": ["Promise", "reject"],
  "%Promise_resolve%": ["Promise", "resolve"],
  "%RangeErrorPrototype%": ["RangeError", "prototype"],
  "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
  "%RegExpPrototype%": ["RegExp", "prototype"],
  "%SetPrototype%": ["Set", "prototype"],
  "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
  "%StringPrototype%": ["String", "prototype"],
  "%SymbolPrototype%": ["Symbol", "prototype"],
  "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
  "%TypedArrayPrototype%": ["TypedArray", "prototype"],
  "%TypeErrorPrototype%": ["TypeError", "prototype"],
  "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
  "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
  "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
  "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
  "%URIErrorPrototype%": ["URIError", "prototype"],
  "%WeakMapPrototype%": ["WeakMap", "prototype"],
  "%WeakSetPrototype%": ["WeakSet", "prototype"]
}, Ls = $c, ea = tE, dE = Ls.call(Function.call, Array.prototype.concat), fE = Ls.call(Function.apply, Array.prototype.splice), Gd = Ls.call(Function.call, String.prototype.replace), ta = Ls.call(Function.call, String.prototype.slice), pE = Ls.call(Function.call, RegExp.prototype.exec), _E = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, mE = /\\(\\)?/g, gE = function(e) {
  var t = ta(e, 0, 1), i = ta(e, -1);
  if (t === "%" && i !== "%")
    throw new Fn("invalid intrinsic syntax, expected closing `%`");
  if (i === "%" && t !== "%")
    throw new Fn("invalid intrinsic syntax, expected opening `%`");
  var n = [];
  return Gd(e, _E, function(s, o, a, l) {
    n[n.length] = a ? Gd(l, mE, "$1") : o || s;
  }), n;
}, yE = function(e, t) {
  var i = e, n;
  if (ea(Ud, i) && (n = Ud[i], i = "%" + n[0] + "%"), ea(kr, i)) {
    var s = kr[i];
    if (s === un && (s = uE(i)), typeof s > "u" && !t)
      throw new An("intrinsic " + e + " exists, but is not available. Please file an issue!");
    return {
      alias: n,
      name: i,
      value: s
    };
  }
  throw new Fn("intrinsic " + e + " does not exist!");
}, jn = function(e, t) {
  if (typeof e != "string" || e.length === 0)
    throw new An("intrinsic name must be a non-empty string");
  if (arguments.length > 1 && typeof t != "boolean")
    throw new An('"allowMissing" argument must be a boolean');
  if (pE(/^%?[^%]*%?$/, e) === null)
    throw new Fn("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
  var i = gE(e), n = i.length > 0 ? i[0] : "", s = yE("%" + n + "%", t), o = s.name, a = s.value, l = !1, h = s.alias;
  h && (n = h[0], fE(i, dE([0, 1], h)));
  for (var c = 1, u = !0; c < i.length; c += 1) {
    var d = i[c], f = ta(d, 0, 1), p = ta(d, -1);
    if ((f === '"' || f === "'" || f === "`" || p === '"' || p === "'" || p === "`") && f !== p)
      throw new Fn("property names with quotes must have matching quotes");
    if ((d === "constructor" || !u) && (l = !0), n += "." + d, o = "%" + n + "%", ea(kr, o))
      a = kr[o];
    else if (a != null) {
      if (!(d in a)) {
        if (!t)
          throw new An("base intrinsic for " + e + " exists, but the property is not available.");
        return;
      }
      if (Mr && c + 1 >= i.length) {
        var _ = Mr(a, d);
        u = !!_, u && "get" in _ && !("originalValue" in _.get) ? a = _.get : a = a[d];
      } else
        u = ea(a, d), a = a[d];
      u && !l && (kr[o] = a);
    }
  }
  return a;
}, J_ = { exports: {} }, Pl, Hd;
function Jc() {
  if (Hd)
    return Pl;
  Hd = 1;
  var r = jn, e = r("%Object.defineProperty%", !0) || !1;
  if (e)
    try {
      e({}, "a", { value: 1 });
    } catch {
      e = !1;
    }
  return Pl = e, Pl;
}
var vE = jn, Io = vE("%Object.getOwnPropertyDescriptor%", !0);
if (Io)
  try {
    Io([], "length");
  } catch {
    Io = null;
  }
var Q_ = Io, zd = Jc(), bE = Z_, nn = Os, Xd = Q_, wE = function(e, t, i) {
  if (!e || typeof e != "object" && typeof e != "function")
    throw new nn("`obj` must be an object or a function`");
  if (typeof t != "string" && typeof t != "symbol")
    throw new nn("`property` must be a string or a symbol`");
  if (arguments.length > 3 && typeof arguments[3] != "boolean" && arguments[3] !== null)
    throw new nn("`nonEnumerable`, if provided, must be a boolean or null");
  if (arguments.length > 4 && typeof arguments[4] != "boolean" && arguments[4] !== null)
    throw new nn("`nonWritable`, if provided, must be a boolean or null");
  if (arguments.length > 5 && typeof arguments[5] != "boolean" && arguments[5] !== null)
    throw new nn("`nonConfigurable`, if provided, must be a boolean or null");
  if (arguments.length > 6 && typeof arguments[6] != "boolean")
    throw new nn("`loose`, if provided, must be a boolean");
  var n = arguments.length > 3 ? arguments[3] : null, s = arguments.length > 4 ? arguments[4] : null, o = arguments.length > 5 ? arguments[5] : null, a = arguments.length > 6 ? arguments[6] : !1, l = !!Xd && Xd(e, t);
  if (zd)
    zd(e, t, {
      configurable: o === null && l ? l.configurable : !o,
      enumerable: n === null && l ? l.enumerable : !n,
      value: i,
      writable: s === null && l ? l.writable : !s
    });
  else if (a || !n && !s && !o)
    e[t] = i;
  else
    throw new bE("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");
}, Gh = Jc(), em = function() {
  return !!Gh;
};
em.hasArrayLengthDefineBug = function() {
  if (!Gh)
    return null;
  try {
    return Gh([], "length", { value: 1 }).length !== 1;
  } catch {
    return !0;
  }
};
var xE = em, EE = jn, Vd = wE, TE = xE(), Wd = Q_, jd = Os, AE = EE("%Math.floor%"), SE = function(e, t) {
  if (typeof e != "function")
    throw new jd("`fn` is not a function");
  if (typeof t != "number" || t < 0 || t > 4294967295 || AE(t) !== t)
    throw new jd("`length` must be a positive 32-bit integer");
  var i = arguments.length > 2 && !!arguments[2], n = !0, s = !0;
  if ("length" in e && Wd) {
    var o = Wd(e, "length");
    o && !o.configurable && (n = !1), o && !o.writable && (s = !1);
  }
  return (n || s || !i) && (TE ? Vd(
    /** @type {Parameters<define>[0]} */
    e,
    "length",
    t,
    !0,
    !0
  ) : Vd(
    /** @type {Parameters<define>[0]} */
    e,
    "length",
    t
  )), e;
};
(function(r) {
  var e = $c, t = jn, i = SE, n = Os, s = t("%Function.prototype.apply%"), o = t("%Function.prototype.call%"), a = t("%Reflect.apply%", !0) || e.call(o, s), l = Jc(), h = t("%Math.max%");
  r.exports = function(d) {
    if (typeof d != "function")
      throw new n("a function is required");
    var f = a(e, o, arguments);
    return i(
      f,
      1 + h(0, d.length - (arguments.length - 1)),
      !0
    );
  };
  var c = function() {
    return a(e, s, arguments);
  };
  l ? l(r.exports, "apply", { value: c }) : r.exports.apply = c;
})(J_);
var CE = J_.exports, tm = jn, im = CE, IE = im(tm("String.prototype.indexOf")), RE = function(e, t) {
  var i = tm(e, !!t);
  return typeof i == "function" && IE(e, ".prototype.") > -1 ? im(i) : i;
};
const PE = {}, ME = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: PE
}, Symbol.toStringTag, { value: "Module" })), kE = /* @__PURE__ */ p2(ME);
var Qc = typeof Map == "function" && Map.prototype, Ml = Object.getOwnPropertyDescriptor && Qc ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null, ia = Qc && Ml && typeof Ml.get == "function" ? Ml.get : null, qd = Qc && Map.prototype.forEach, eu = typeof Set == "function" && Set.prototype, kl = Object.getOwnPropertyDescriptor && eu ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null, ra = eu && kl && typeof kl.get == "function" ? kl.get : null, Yd = eu && Set.prototype.forEach, DE = typeof WeakMap == "function" && WeakMap.prototype, ws = DE ? WeakMap.prototype.has : null, BE = typeof WeakSet == "function" && WeakSet.prototype, xs = BE ? WeakSet.prototype.has : null, FE = typeof WeakRef == "function" && WeakRef.prototype, Kd = FE ? WeakRef.prototype.deref : null, OE = Boolean.prototype.valueOf, LE = Object.prototype.toString, NE = Function.prototype.toString, UE = String.prototype.match, tu = String.prototype.slice, Ki = String.prototype.replace, GE = String.prototype.toUpperCase, Zd = String.prototype.toLowerCase, rm = RegExp.prototype.test, $d = Array.prototype.concat, ui = Array.prototype.join, HE = Array.prototype.slice, Jd = Math.floor, Hh = typeof BigInt == "function" ? BigInt.prototype.valueOf : null, Dl = Object.getOwnPropertySymbols, zh = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Symbol.prototype.toString : null, On = typeof Symbol == "function" && typeof Symbol.iterator == "object", tt = typeof Symbol == "function" && Symbol.toStringTag && (typeof Symbol.toStringTag === On || !0) ? Symbol.toStringTag : null, nm = Object.prototype.propertyIsEnumerable, Qd = (typeof Reflect == "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(r) {
  return r.__proto__;
} : null);
function ef(r, e) {
  if (r === 1 / 0 || r === -1 / 0 || r !== r || r && r > -1e3 && r < 1e3 || rm.call(/e/, e))
    return e;
  var t = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
  if (typeof r == "number") {
    var i = r < 0 ? -Jd(-r) : Jd(r);
    if (i !== r) {
      var n = String(i), s = tu.call(e, n.length + 1);
      return Ki.call(n, t, "$&_") + "." + Ki.call(Ki.call(s, /([0-9]{3})/g, "$&_"), /_$/, "");
    }
  }
  return Ki.call(e, t, "$&_");
}
var Xh = kE, tf = Xh.custom, rf = om(tf) ? tf : null, zE = function r(e, t, i, n) {
  var s = t || {};
  if (Wi(s, "quoteStyle") && s.quoteStyle !== "single" && s.quoteStyle !== "double")
    throw new TypeError('option "quoteStyle" must be "single" or "double"');
  if (Wi(s, "maxStringLength") && (typeof s.maxStringLength == "number" ? s.maxStringLength < 0 && s.maxStringLength !== 1 / 0 : s.maxStringLength !== null))
    throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
  var o = Wi(s, "customInspect") ? s.customInspect : !0;
  if (typeof o != "boolean" && o !== "symbol")
    throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");
  if (Wi(s, "indent") && s.indent !== null && s.indent !== "	" && !(parseInt(s.indent, 10) === s.indent && s.indent > 0))
    throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');
  if (Wi(s, "numericSeparator") && typeof s.numericSeparator != "boolean")
    throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');
  var a = s.numericSeparator;
  if (typeof e > "u")
    return "undefined";
  if (e === null)
    return "null";
  if (typeof e == "boolean")
    return e ? "true" : "false";
  if (typeof e == "string")
    return lm(e, s);
  if (typeof e == "number") {
    if (e === 0)
      return 1 / 0 / e > 0 ? "0" : "-0";
    var l = String(e);
    return a ? ef(e, l) : l;
  }
  if (typeof e == "bigint") {
    var h = String(e) + "n";
    return a ? ef(e, h) : h;
  }
  var c = typeof s.depth > "u" ? 5 : s.depth;
  if (typeof i > "u" && (i = 0), i >= c && c > 0 && typeof e == "object")
    return Vh(e) ? "[Array]" : "[Object]";
  var u = oT(s, i);
  if (typeof n > "u")
    n = [];
  else if (am(n, e) >= 0)
    return "[Circular]";
  function d(C, M, F) {
    if (M && (n = HE.call(n), n.push(M)), F) {
      var U = {
        depth: s.depth
      };
      return Wi(s, "quoteStyle") && (U.quoteStyle = s.quoteStyle), r(C, U, i + 1, n);
    }
    return r(C, s, i + 1, n);
  }
  if (typeof e == "function" && !nf(e)) {
    var f = $E(e), p = Js(e, d);
    return "[Function" + (f ? ": " + f : " (anonymous)") + "]" + (p.length > 0 ? " { " + ui.call(p, ", ") + " }" : "");
  }
  if (om(e)) {
    var _ = On ? Ki.call(String(e), /^(Symbol\(.*\))_[^)]*$/, "$1") : zh.call(e);
    return typeof e == "object" && !On ? es(_) : _;
  }
  if (rT(e)) {
    for (var m = "<" + Zd.call(String(e.nodeName)), y = e.attributes || [], v = 0; v < y.length; v++)
      m += " " + y[v].name + "=" + sm(XE(y[v].value), "double", s);
    return m += ">", e.childNodes && e.childNodes.length && (m += "..."), m += "</" + Zd.call(String(e.nodeName)) + ">", m;
  }
  if (Vh(e)) {
    if (e.length === 0)
      return "[]";
    var g = Js(e, d);
    return u && !sT(g) ? "[" + Wh(g, u) + "]" : "[ " + ui.call(g, ", ") + " ]";
  }
  if (WE(e)) {
    var b = Js(e, d);
    return !("cause" in Error.prototype) && "cause" in e && !nm.call(e, "cause") ? "{ [" + String(e) + "] " + ui.call($d.call("[cause]: " + d(e.cause), b), ", ") + " }" : b.length === 0 ? "[" + String(e) + "]" : "{ [" + String(e) + "] " + ui.call(b, ", ") + " }";
  }
  if (typeof e == "object" && o) {
    if (rf && typeof e[rf] == "function" && Xh)
      return Xh(e, { depth: c - i });
    if (o !== "symbol" && typeof e.inspect == "function")
      return e.inspect();
  }
  if (JE(e)) {
    var w = [];
    return qd && qd.call(e, function(C, M) {
      w.push(d(M, e, !0) + " => " + d(C, e));
    }), sf("Map", ia.call(e), w, u);
  }
  if (tT(e)) {
    var T = [];
    return Yd && Yd.call(e, function(C) {
      T.push(d(C, e));
    }), sf("Set", ra.call(e), T, u);
  }
  if (QE(e))
    return Bl("WeakMap");
  if (iT(e))
    return Bl("WeakSet");
  if (eT(e))
    return Bl("WeakRef");
  if (qE(e))
    return es(d(Number(e)));
  if (KE(e))
    return es(d(Hh.call(e)));
  if (YE(e))
    return es(OE.call(e));
  if (jE(e))
    return es(d(String(e)));
  if (typeof window < "u" && e === window)
    return "{ [object Window] }";
  if (e === Co)
    return "{ [object globalThis] }";
  if (!VE(e) && !nf(e)) {
    var x = Js(e, d), E = Qd ? Qd(e) === Object.prototype : e instanceof Object || e.constructor === Object, R = e instanceof Object ? "" : "null prototype", k = !E && tt && Object(e) === e && tt in e ? tu.call(hr(e), 8, -1) : R ? "Object" : "", O = E || typeof e.constructor != "function" ? "" : e.constructor.name ? e.constructor.name + " " : "", B = O + (k || R ? "[" + ui.call($d.call([], k || [], R || []), ": ") + "] " : "");
    return x.length === 0 ? B + "{}" : u ? B + "{" + Wh(x, u) + "}" : B + "{ " + ui.call(x, ", ") + " }";
  }
  return String(e);
};
function sm(r, e, t) {
  var i = (t.quoteStyle || e) === "double" ? '"' : "'";
  return i + r + i;
}
function XE(r) {
  return Ki.call(String(r), /"/g, "&quot;");
}
function Vh(r) {
  return hr(r) === "[object Array]" && (!tt || !(typeof r == "object" && tt in r));
}
function VE(r) {
  return hr(r) === "[object Date]" && (!tt || !(typeof r == "object" && tt in r));
}
function nf(r) {
  return hr(r) === "[object RegExp]" && (!tt || !(typeof r == "object" && tt in r));
}
function WE(r) {
  return hr(r) === "[object Error]" && (!tt || !(typeof r == "object" && tt in r));
}
function jE(r) {
  return hr(r) === "[object String]" && (!tt || !(typeof r == "object" && tt in r));
}
function qE(r) {
  return hr(r) === "[object Number]" && (!tt || !(typeof r == "object" && tt in r));
}
function YE(r) {
  return hr(r) === "[object Boolean]" && (!tt || !(typeof r == "object" && tt in r));
}
function om(r) {
  if (On)
    return r && typeof r == "object" && r instanceof Symbol;
  if (typeof r == "symbol")
    return !0;
  if (!r || typeof r != "object" || !zh)
    return !1;
  try {
    return zh.call(r), !0;
  } catch {
  }
  return !1;
}
function KE(r) {
  if (!r || typeof r != "object" || !Hh)
    return !1;
  try {
    return Hh.call(r), !0;
  } catch {
  }
  return !1;
}
var ZE = Object.prototype.hasOwnProperty || function(r) {
  return r in this;
};
function Wi(r, e) {
  return ZE.call(r, e);
}
function hr(r) {
  return LE.call(r);
}
function $E(r) {
  if (r.name)
    return r.name;
  var e = UE.call(NE.call(r), /^function\s*([\w$]+)/);
  return e ? e[1] : null;
}
function am(r, e) {
  if (r.indexOf)
    return r.indexOf(e);
  for (var t = 0, i = r.length; t < i; t++)
    if (r[t] === e)
      return t;
  return -1;
}
function JE(r) {
  if (!ia || !r || typeof r != "object")
    return !1;
  try {
    ia.call(r);
    try {
      ra.call(r);
    } catch {
      return !0;
    }
    return r instanceof Map;
  } catch {
  }
  return !1;
}
function QE(r) {
  if (!ws || !r || typeof r != "object")
    return !1;
  try {
    ws.call(r, ws);
    try {
      xs.call(r, xs);
    } catch {
      return !0;
    }
    return r instanceof WeakMap;
  } catch {
  }
  return !1;
}
function eT(r) {
  if (!Kd || !r || typeof r != "object")
    return !1;
  try {
    return Kd.call(r), !0;
  } catch {
  }
  return !1;
}
function tT(r) {
  if (!ra || !r || typeof r != "object")
    return !1;
  try {
    ra.call(r);
    try {
      ia.call(r);
    } catch {
      return !0;
    }
    return r instanceof Set;
  } catch {
  }
  return !1;
}
function iT(r) {
  if (!xs || !r || typeof r != "object")
    return !1;
  try {
    xs.call(r, xs);
    try {
      ws.call(r, ws);
    } catch {
      return !0;
    }
    return r instanceof WeakSet;
  } catch {
  }
  return !1;
}
function rT(r) {
  return !r || typeof r != "object" ? !1 : typeof HTMLElement < "u" && r instanceof HTMLElement ? !0 : typeof r.nodeName == "string" && typeof r.getAttribute == "function";
}
function lm(r, e) {
  if (r.length > e.maxStringLength) {
    var t = r.length - e.maxStringLength, i = "... " + t + " more character" + (t > 1 ? "s" : "");
    return lm(tu.call(r, 0, e.maxStringLength), e) + i;
  }
  var n = Ki.call(Ki.call(r, /(['\\])/g, "\\$1"), /[\x00-\x1f]/g, nT);
  return sm(n, "single", e);
}
function nT(r) {
  var e = r.charCodeAt(0), t = {
    8: "b",
    9: "t",
    10: "n",
    12: "f",
    13: "r"
  }[e];
  return t ? "\\" + t : "\\x" + (e < 16 ? "0" : "") + GE.call(e.toString(16));
}
function es(r) {
  return "Object(" + r + ")";
}
function Bl(r) {
  return r + " { ? }";
}
function sf(r, e, t, i) {
  var n = i ? Wh(t, i) : ui.call(t, ", ");
  return r + " (" + e + ") {" + n + "}";
}
function sT(r) {
  for (var e = 0; e < r.length; e++)
    if (am(r[e], `
`) >= 0)
      return !1;
  return !0;
}
function oT(r, e) {
  var t;
  if (r.indent === "	")
    t = "	";
  else if (typeof r.indent == "number" && r.indent > 0)
    t = ui.call(Array(r.indent + 1), " ");
  else
    return null;
  return {
    base: t,
    prev: ui.call(Array(e + 1), t)
  };
}
function Wh(r, e) {
  if (r.length === 0)
    return "";
  var t = `
` + e.prev + e.base;
  return t + ui.call(r, "," + t) + `
` + e.prev;
}
function Js(r, e) {
  var t = Vh(r), i = [];
  if (t) {
    i.length = r.length;
    for (var n = 0; n < r.length; n++)
      i[n] = Wi(r, n) ? e(r[n], r) : "";
  }
  var s = typeof Dl == "function" ? Dl(r) : [], o;
  if (On) {
    o = {};
    for (var a = 0; a < s.length; a++)
      o["$" + s[a]] = s[a];
  }
  for (var l in r)
    Wi(r, l) && (t && String(Number(l)) === l && l < r.length || On && o["$" + l] instanceof Symbol || (rm.call(/[^\w$]/, l) ? i.push(e(l, r) + ": " + e(r[l], r)) : i.push(l + ": " + e(r[l], r))));
  if (typeof Dl == "function")
    for (var h = 0; h < s.length; h++)
      nm.call(r, s[h]) && i.push("[" + e(s[h]) + "]: " + e(r[s[h]], r));
  return i;
}
var hm = jn, qn = RE, aT = zE, lT = Os, Qs = hm("%WeakMap%", !0), eo = hm("%Map%", !0), hT = qn("WeakMap.prototype.get", !0), cT = qn("WeakMap.prototype.set", !0), uT = qn("WeakMap.prototype.has", !0), dT = qn("Map.prototype.get", !0), fT = qn("Map.prototype.set", !0), pT = qn("Map.prototype.has", !0), iu = function(r, e) {
  for (var t = r, i; (i = t.next) !== null; t = i)
    if (i.key === e)
      return t.next = i.next, i.next = /** @type {NonNullable<typeof list.next>} */
      r.next, r.next = i, i;
}, _T = function(r, e) {
  var t = iu(r, e);
  return t && t.value;
}, mT = function(r, e, t) {
  var i = iu(r, e);
  i ? i.value = t : r.next = /** @type {import('.').ListNode<typeof value>} */
  {
    // eslint-disable-line no-param-reassign, no-extra-parens
    key: e,
    next: r.next,
    value: t
  };
}, gT = function(r, e) {
  return !!iu(r, e);
}, yT = function() {
  var e, t, i, n = {
    assert: function(s) {
      if (!n.has(s))
        throw new lT("Side channel does not contain " + aT(s));
    },
    get: function(s) {
      if (Qs && s && (typeof s == "object" || typeof s == "function")) {
        if (e)
          return hT(e, s);
      } else if (eo) {
        if (t)
          return dT(t, s);
      } else if (i)
        return _T(i, s);
    },
    has: function(s) {
      if (Qs && s && (typeof s == "object" || typeof s == "function")) {
        if (e)
          return uT(e, s);
      } else if (eo) {
        if (t)
          return pT(t, s);
      } else if (i)
        return gT(i, s);
      return !1;
    },
    set: function(s, o) {
      Qs && s && (typeof s == "object" || typeof s == "function") ? (e || (e = new Qs()), cT(e, s, o)) : eo ? (t || (t = new eo()), fT(t, s, o)) : (i || (i = { key: {}, next: null }), mT(i, s, o));
    }
  };
  return n;
}, vT = String.prototype.replace, bT = /%20/g, Fl = {
  RFC1738: "RFC1738",
  RFC3986: "RFC3986"
}, ru = {
  default: Fl.RFC3986,
  formatters: {
    RFC1738: function(r) {
      return vT.call(r, bT, "+");
    },
    RFC3986: function(r) {
      return String(r);
    }
  },
  RFC1738: Fl.RFC1738,
  RFC3986: Fl.RFC3986
}, wT = ru, Ol = Object.prototype.hasOwnProperty, Ir = Array.isArray, ii = function() {
  for (var r = [], e = 0; e < 256; ++e)
    r.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase());
  return r;
}(), xT = function(e) {
  for (; e.length > 1; ) {
    var t = e.pop(), i = t.obj[t.prop];
    if (Ir(i)) {
      for (var n = [], s = 0; s < i.length; ++s)
        typeof i[s] < "u" && n.push(i[s]);
      t.obj[t.prop] = n;
    }
  }
}, cm = function(e, t) {
  for (var i = t && t.plainObjects ? /* @__PURE__ */ Object.create(null) : {}, n = 0; n < e.length; ++n)
    typeof e[n] < "u" && (i[n] = e[n]);
  return i;
}, ET = function r(e, t, i) {
  if (!t)
    return e;
  if (typeof t != "object") {
    if (Ir(e))
      e.push(t);
    else if (e && typeof e == "object")
      (i && (i.plainObjects || i.allowPrototypes) || !Ol.call(Object.prototype, t)) && (e[t] = !0);
    else
      return [e, t];
    return e;
  }
  if (!e || typeof e != "object")
    return [e].concat(t);
  var n = e;
  return Ir(e) && !Ir(t) && (n = cm(e, i)), Ir(e) && Ir(t) ? (t.forEach(function(s, o) {
    if (Ol.call(e, o)) {
      var a = e[o];
      a && typeof a == "object" && s && typeof s == "object" ? e[o] = r(a, s, i) : e.push(s);
    } else
      e[o] = s;
  }), e) : Object.keys(t).reduce(function(s, o) {
    var a = t[o];
    return Ol.call(s, o) ? s[o] = r(s[o], a, i) : s[o] = a, s;
  }, n);
}, TT = function(e, t) {
  return Object.keys(t).reduce(function(i, n) {
    return i[n] = t[n], i;
  }, e);
}, AT = function(r, e, t) {
  var i = r.replace(/\+/g, " ");
  if (t === "iso-8859-1")
    return i.replace(/%[0-9a-f]{2}/gi, unescape);
  try {
    return decodeURIComponent(i);
  } catch {
    return i;
  }
}, Ll = 1024, ST = function(e, t, i, n, s) {
  if (e.length === 0)
    return e;
  var o = e;
  if (typeof e == "symbol" ? o = Symbol.prototype.toString.call(e) : typeof e != "string" && (o = String(e)), i === "iso-8859-1")
    return escape(o).replace(/%u[0-9a-f]{4}/gi, function(f) {
      return "%26%23" + parseInt(f.slice(2), 16) + "%3B";
    });
  for (var a = "", l = 0; l < o.length; l += Ll) {
    for (var h = o.length >= Ll ? o.slice(l, l + Ll) : o, c = [], u = 0; u < h.length; ++u) {
      var d = h.charCodeAt(u);
      if (d === 45 || d === 46 || d === 95 || d === 126 || d >= 48 && d <= 57 || d >= 65 && d <= 90 || d >= 97 && d <= 122 || s === wT.RFC1738 && (d === 40 || d === 41)) {
        c[c.length] = h.charAt(u);
        continue;
      }
      if (d < 128) {
        c[c.length] = ii[d];
        continue;
      }
      if (d < 2048) {
        c[c.length] = ii[192 | d >> 6] + ii[128 | d & 63];
        continue;
      }
      if (d < 55296 || d >= 57344) {
        c[c.length] = ii[224 | d >> 12] + ii[128 | d >> 6 & 63] + ii[128 | d & 63];
        continue;
      }
      u += 1, d = 65536 + ((d & 1023) << 10 | h.charCodeAt(u) & 1023), c[c.length] = ii[240 | d >> 18] + ii[128 | d >> 12 & 63] + ii[128 | d >> 6 & 63] + ii[128 | d & 63];
    }
    a += c.join("");
  }
  return a;
}, CT = function(e) {
  for (var t = [{ obj: { o: e }, prop: "o" }], i = [], n = 0; n < t.length; ++n)
    for (var s = t[n], o = s.obj[s.prop], a = Object.keys(o), l = 0; l < a.length; ++l) {
      var h = a[l], c = o[h];
      typeof c == "object" && c !== null && i.indexOf(c) === -1 && (t.push({ obj: o, prop: h }), i.push(c));
    }
  return xT(t), e;
}, IT = function(e) {
  return Object.prototype.toString.call(e) === "[object RegExp]";
}, RT = function(e) {
  return !e || typeof e != "object" ? !1 : !!(e.constructor && e.constructor.isBuffer && e.constructor.isBuffer(e));
}, PT = function(e, t) {
  return [].concat(e, t);
}, MT = function(e, t) {
  if (Ir(e)) {
    for (var i = [], n = 0; n < e.length; n += 1)
      i.push(t(e[n]));
    return i;
  }
  return t(e);
}, um = {
  arrayToObject: cm,
  assign: TT,
  combine: PT,
  compact: CT,
  decode: AT,
  encode: ST,
  isBuffer: RT,
  isRegExp: IT,
  maybeMap: MT,
  merge: ET
}, dm = yT, Ro = um, Es = ru, kT = Object.prototype.hasOwnProperty, fm = {
  brackets: function(e) {
    return e + "[]";
  },
  comma: "comma",
  indices: function(e, t) {
    return e + "[" + t + "]";
  },
  repeat: function(e) {
    return e;
  }
}, hi = Array.isArray, DT = Array.prototype.push, pm = function(r, e) {
  DT.apply(r, hi(e) ? e : [e]);
}, BT = Date.prototype.toISOString, of = Es.default, Ue = {
  addQueryPrefix: !1,
  allowDots: !1,
  allowEmptyArrays: !1,
  arrayFormat: "indices",
  charset: "utf-8",
  charsetSentinel: !1,
  delimiter: "&",
  encode: !0,
  encodeDotInKeys: !1,
  encoder: Ro.encode,
  encodeValuesOnly: !1,
  format: of,
  formatter: Es.formatters[of],
  // deprecated
  indices: !1,
  serializeDate: function(e) {
    return BT.call(e);
  },
  skipNulls: !1,
  strictNullHandling: !1
}, FT = function(e) {
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "symbol" || typeof e == "bigint";
}, Nl = {}, OT = function r(e, t, i, n, s, o, a, l, h, c, u, d, f, p, _, m, y, v) {
  for (var g = e, b = v, w = 0, T = !1; (b = b.get(Nl)) !== void 0 && !T; ) {
    var x = b.get(e);
    if (w += 1, typeof x < "u") {
      if (x === w)
        throw new RangeError("Cyclic object value");
      T = !0;
    }
    typeof b.get(Nl) > "u" && (w = 0);
  }
  if (typeof c == "function" ? g = c(t, g) : g instanceof Date ? g = f(g) : i === "comma" && hi(g) && (g = Ro.maybeMap(g, function(I) {
    return I instanceof Date ? f(I) : I;
  })), g === null) {
    if (o)
      return h && !m ? h(t, Ue.encoder, y, "key", p) : t;
    g = "";
  }
  if (FT(g) || Ro.isBuffer(g)) {
    if (h) {
      var E = m ? t : h(t, Ue.encoder, y, "key", p);
      return [_(E) + "=" + _(h(g, Ue.encoder, y, "value", p))];
    }
    return [_(t) + "=" + _(String(g))];
  }
  var R = [];
  if (typeof g > "u")
    return R;
  var k;
  if (i === "comma" && hi(g))
    m && h && (g = Ro.maybeMap(g, h)), k = [{ value: g.length > 0 ? g.join(",") || null : void 0 }];
  else if (hi(c))
    k = c;
  else {
    var O = Object.keys(g);
    k = u ? O.sort(u) : O;
  }
  var B = l ? t.replace(/\./g, "%2E") : t, C = n && hi(g) && g.length === 1 ? B + "[]" : B;
  if (s && hi(g) && g.length === 0)
    return C + "[]";
  for (var M = 0; M < k.length; ++M) {
    var F = k[M], U = typeof F == "object" && typeof F.value < "u" ? F.value : g[F];
    if (!(a && U === null)) {
      var L = d && l ? F.replace(/\./g, "%2E") : F, D = hi(g) ? typeof i == "function" ? i(C, L) : C : C + (d ? "." + L : "[" + L + "]");
      v.set(e, w);
      var N = dm();
      N.set(Nl, v), pm(R, r(
        U,
        D,
        i,
        n,
        s,
        o,
        a,
        l,
        i === "comma" && m && hi(g) ? null : h,
        c,
        u,
        d,
        f,
        p,
        _,
        m,
        y,
        N
      ));
    }
  }
  return R;
}, LT = function(e) {
  if (!e)
    return Ue;
  if (typeof e.allowEmptyArrays < "u" && typeof e.allowEmptyArrays != "boolean")
    throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
  if (typeof e.encodeDotInKeys < "u" && typeof e.encodeDotInKeys != "boolean")
    throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");
  if (e.encoder !== null && typeof e.encoder < "u" && typeof e.encoder != "function")
    throw new TypeError("Encoder has to be a function.");
  var t = e.charset || Ue.charset;
  if (typeof e.charset < "u" && e.charset !== "utf-8" && e.charset !== "iso-8859-1")
    throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
  var i = Es.default;
  if (typeof e.format < "u") {
    if (!kT.call(Es.formatters, e.format))
      throw new TypeError("Unknown format option provided.");
    i = e.format;
  }
  var n = Es.formatters[i], s = Ue.filter;
  (typeof e.filter == "function" || hi(e.filter)) && (s = e.filter);
  var o;
  if (e.arrayFormat in fm ? o = e.arrayFormat : "indices" in e ? o = e.indices ? "indices" : "repeat" : o = Ue.arrayFormat, "commaRoundTrip" in e && typeof e.commaRoundTrip != "boolean")
    throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
  var a = typeof e.allowDots > "u" ? e.encodeDotInKeys === !0 ? !0 : Ue.allowDots : !!e.allowDots;
  return {
    addQueryPrefix: typeof e.addQueryPrefix == "boolean" ? e.addQueryPrefix : Ue.addQueryPrefix,
    allowDots: a,
    allowEmptyArrays: typeof e.allowEmptyArrays == "boolean" ? !!e.allowEmptyArrays : Ue.allowEmptyArrays,
    arrayFormat: o,
    charset: t,
    charsetSentinel: typeof e.charsetSentinel == "boolean" ? e.charsetSentinel : Ue.charsetSentinel,
    commaRoundTrip: e.commaRoundTrip,
    delimiter: typeof e.delimiter > "u" ? Ue.delimiter : e.delimiter,
    encode: typeof e.encode == "boolean" ? e.encode : Ue.encode,
    encodeDotInKeys: typeof e.encodeDotInKeys == "boolean" ? e.encodeDotInKeys : Ue.encodeDotInKeys,
    encoder: typeof e.encoder == "function" ? e.encoder : Ue.encoder,
    encodeValuesOnly: typeof e.encodeValuesOnly == "boolean" ? e.encodeValuesOnly : Ue.encodeValuesOnly,
    filter: s,
    format: i,
    formatter: n,
    serializeDate: typeof e.serializeDate == "function" ? e.serializeDate : Ue.serializeDate,
    skipNulls: typeof e.skipNulls == "boolean" ? e.skipNulls : Ue.skipNulls,
    sort: typeof e.sort == "function" ? e.sort : null,
    strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : Ue.strictNullHandling
  };
}, NT = function(r, e) {
  var t = r, i = LT(e), n, s;
  typeof i.filter == "function" ? (s = i.filter, t = s("", t)) : hi(i.filter) && (s = i.filter, n = s);
  var o = [];
  if (typeof t != "object" || t === null)
    return "";
  var a = fm[i.arrayFormat], l = a === "comma" && i.commaRoundTrip;
  n || (n = Object.keys(t)), i.sort && n.sort(i.sort);
  for (var h = dm(), c = 0; c < n.length; ++c) {
    var u = n[c];
    i.skipNulls && t[u] === null || pm(o, OT(
      t[u],
      u,
      a,
      l,
      i.allowEmptyArrays,
      i.strictNullHandling,
      i.skipNulls,
      i.encodeDotInKeys,
      i.encode ? i.encoder : null,
      i.filter,
      i.sort,
      i.allowDots,
      i.serializeDate,
      i.format,
      i.formatter,
      i.encodeValuesOnly,
      i.charset,
      h
    ));
  }
  var d = o.join(i.delimiter), f = i.addQueryPrefix === !0 ? "?" : "";
  return i.charsetSentinel && (i.charset === "iso-8859-1" ? f += "utf8=%26%2310003%3B&" : f += "utf8=%E2%9C%93&"), d.length > 0 ? f + d : "";
}, Ln = um, jh = Object.prototype.hasOwnProperty, UT = Array.isArray, De = {
  allowDots: !1,
  allowEmptyArrays: !1,
  allowPrototypes: !1,
  allowSparse: !1,
  arrayLimit: 20,
  charset: "utf-8",
  charsetSentinel: !1,
  comma: !1,
  decodeDotInKeys: !1,
  decoder: Ln.decode,
  delimiter: "&",
  depth: 5,
  duplicates: "combine",
  ignoreQueryPrefix: !1,
  interpretNumericEntities: !1,
  parameterLimit: 1e3,
  parseArrays: !0,
  plainObjects: !1,
  strictNullHandling: !1
}, GT = function(r) {
  return r.replace(/&#(\d+);/g, function(e, t) {
    return String.fromCharCode(parseInt(t, 10));
  });
}, _m = function(r, e) {
  return r && typeof r == "string" && e.comma && r.indexOf(",") > -1 ? r.split(",") : r;
}, HT = "utf8=%26%2310003%3B", zT = "utf8=%E2%9C%93", XT = function(e, t) {
  var i = { __proto__: null }, n = t.ignoreQueryPrefix ? e.replace(/^\?/, "") : e, s = t.parameterLimit === 1 / 0 ? void 0 : t.parameterLimit, o = n.split(t.delimiter, s), a = -1, l, h = t.charset;
  if (t.charsetSentinel)
    for (l = 0; l < o.length; ++l)
      o[l].indexOf("utf8=") === 0 && (o[l] === zT ? h = "utf-8" : o[l] === HT && (h = "iso-8859-1"), a = l, l = o.length);
  for (l = 0; l < o.length; ++l)
    if (l !== a) {
      var c = o[l], u = c.indexOf("]="), d = u === -1 ? c.indexOf("=") : u + 1, f, p;
      d === -1 ? (f = t.decoder(c, De.decoder, h, "key"), p = t.strictNullHandling ? null : "") : (f = t.decoder(c.slice(0, d), De.decoder, h, "key"), p = Ln.maybeMap(
        _m(c.slice(d + 1), t),
        function(m) {
          return t.decoder(m, De.decoder, h, "value");
        }
      )), p && t.interpretNumericEntities && h === "iso-8859-1" && (p = GT(p)), c.indexOf("[]=") > -1 && (p = UT(p) ? [p] : p);
      var _ = jh.call(i, f);
      _ && t.duplicates === "combine" ? i[f] = Ln.combine(i[f], p) : (!_ || t.duplicates === "last") && (i[f] = p);
    }
  return i;
}, VT = function(r, e, t, i) {
  for (var n = i ? e : _m(e, t), s = r.length - 1; s >= 0; --s) {
    var o, a = r[s];
    if (a === "[]" && t.parseArrays)
      o = t.allowEmptyArrays && n === "" ? [] : [].concat(n);
    else {
      o = t.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
      var l = a.charAt(0) === "[" && a.charAt(a.length - 1) === "]" ? a.slice(1, -1) : a, h = t.decodeDotInKeys ? l.replace(/%2E/g, ".") : l, c = parseInt(h, 10);
      !t.parseArrays && h === "" ? o = { 0: n } : !isNaN(c) && a !== h && String(c) === h && c >= 0 && t.parseArrays && c <= t.arrayLimit ? (o = [], o[c] = n) : h !== "__proto__" && (o[h] = n);
    }
    n = o;
  }
  return n;
}, WT = function(e, t, i, n) {
  if (e) {
    var s = i.allowDots ? e.replace(/\.([^.[]+)/g, "[$1]") : e, o = /(\[[^[\]]*])/, a = /(\[[^[\]]*])/g, l = i.depth > 0 && o.exec(s), h = l ? s.slice(0, l.index) : s, c = [];
    if (h) {
      if (!i.plainObjects && jh.call(Object.prototype, h) && !i.allowPrototypes)
        return;
      c.push(h);
    }
    for (var u = 0; i.depth > 0 && (l = a.exec(s)) !== null && u < i.depth; ) {
      if (u += 1, !i.plainObjects && jh.call(Object.prototype, l[1].slice(1, -1)) && !i.allowPrototypes)
        return;
      c.push(l[1]);
    }
    return l && c.push("[" + s.slice(l.index) + "]"), VT(c, t, i, n);
  }
}, jT = function(e) {
  if (!e)
    return De;
  if (typeof e.allowEmptyArrays < "u" && typeof e.allowEmptyArrays != "boolean")
    throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
  if (typeof e.decodeDotInKeys < "u" && typeof e.decodeDotInKeys != "boolean")
    throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");
  if (e.decoder !== null && typeof e.decoder < "u" && typeof e.decoder != "function")
    throw new TypeError("Decoder has to be a function.");
  if (typeof e.charset < "u" && e.charset !== "utf-8" && e.charset !== "iso-8859-1")
    throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
  var t = typeof e.charset > "u" ? De.charset : e.charset, i = typeof e.duplicates > "u" ? De.duplicates : e.duplicates;
  if (i !== "combine" && i !== "first" && i !== "last")
    throw new TypeError("The duplicates option must be either combine, first, or last");
  var n = typeof e.allowDots > "u" ? e.decodeDotInKeys === !0 ? !0 : De.allowDots : !!e.allowDots;
  return {
    allowDots: n,
    allowEmptyArrays: typeof e.allowEmptyArrays == "boolean" ? !!e.allowEmptyArrays : De.allowEmptyArrays,
    allowPrototypes: typeof e.allowPrototypes == "boolean" ? e.allowPrototypes : De.allowPrototypes,
    allowSparse: typeof e.allowSparse == "boolean" ? e.allowSparse : De.allowSparse,
    arrayLimit: typeof e.arrayLimit == "number" ? e.arrayLimit : De.arrayLimit,
    charset: t,
    charsetSentinel: typeof e.charsetSentinel == "boolean" ? e.charsetSentinel : De.charsetSentinel,
    comma: typeof e.comma == "boolean" ? e.comma : De.comma,
    decodeDotInKeys: typeof e.decodeDotInKeys == "boolean" ? e.decodeDotInKeys : De.decodeDotInKeys,
    decoder: typeof e.decoder == "function" ? e.decoder : De.decoder,
    delimiter: typeof e.delimiter == "string" || Ln.isRegExp(e.delimiter) ? e.delimiter : De.delimiter,
    // eslint-disable-next-line no-implicit-coercion, no-extra-parens
    depth: typeof e.depth == "number" || e.depth === !1 ? +e.depth : De.depth,
    duplicates: i,
    ignoreQueryPrefix: e.ignoreQueryPrefix === !0,
    interpretNumericEntities: typeof e.interpretNumericEntities == "boolean" ? e.interpretNumericEntities : De.interpretNumericEntities,
    parameterLimit: typeof e.parameterLimit == "number" ? e.parameterLimit : De.parameterLimit,
    parseArrays: e.parseArrays !== !1,
    plainObjects: typeof e.plainObjects == "boolean" ? e.plainObjects : De.plainObjects,
    strictNullHandling: typeof e.strictNullHandling == "boolean" ? e.strictNullHandling : De.strictNullHandling
  };
}, qT = function(r, e) {
  var t = jT(e);
  if (r === "" || r === null || typeof r > "u")
    return t.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
  for (var i = typeof r == "string" ? XT(r, t) : r, n = t.plainObjects ? /* @__PURE__ */ Object.create(null) : {}, s = Object.keys(i), o = 0; o < s.length; ++o) {
    var a = s[o], l = WT(a, i[a], t, typeof r == "string");
    n = Ln.merge(n, l, t);
  }
  return t.allowSparse === !0 ? n : Ln.compact(n);
}, YT = NT, KT = qT, ZT = ru, $T = {
  formats: ZT,
  parse: KT,
  stringify: YT
}, JT = D2;
function Mi() {
  this.protocol = null, this.slashes = null, this.auth = null, this.host = null, this.port = null, this.hostname = null, this.hash = null, this.search = null, this.query = null, this.pathname = null, this.path = null, this.href = null;
}
var QT = /^([a-z0-9.+-]+:)/i, eA = /:[0-9]*$/, tA = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/, iA = [
  "<",
  ">",
  '"',
  "`",
  " ",
  "\r",
  `
`,
  "	"
], rA = [
  "{",
  "}",
  "|",
  "\\",
  "^",
  "`"
].concat(iA), qh = ["'"].concat(rA), af = [
  "%",
  "/",
  "?",
  ";",
  "#"
].concat(qh), lf = [
  "/",
  "?",
  "#"
], nA = 255, hf = /^[+a-z0-9A-Z_-]{0,63}$/, sA = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, oA = {
  javascript: !0,
  "javascript:": !0
}, Yh = {
  javascript: !0,
  "javascript:": !0
}, Sn = {
  http: !0,
  https: !0,
  ftp: !0,
  gopher: !0,
  file: !0,
  "http:": !0,
  "https:": !0,
  "ftp:": !0,
  "gopher:": !0,
  "file:": !0
}, Kh = $T;
function aA(r, e, t) {
  if (r && typeof r == "object" && r instanceof Mi)
    return r;
  var i = new Mi();
  return i.parse(r, e, t), i;
}
Mi.prototype.parse = function(r, e, t) {
  if (typeof r != "string")
    throw new TypeError("Parameter 'url' must be a string, not " + typeof r);
  var i = r.indexOf("?"), n = i !== -1 && i < r.indexOf("#") ? "?" : "#", s = r.split(n), o = /\\/g;
  s[0] = s[0].replace(o, "/"), r = s.join(n);
  var a = r;
  if (a = a.trim(), !t && r.split("#").length === 1) {
    var l = tA.exec(a);
    if (l)
      return this.path = a, this.href = a, this.pathname = l[1], l[2] ? (this.search = l[2], e ? this.query = Kh.parse(this.search.substr(1)) : this.query = this.search.substr(1)) : e && (this.search = "", this.query = {}), this;
  }
  var h = QT.exec(a);
  if (h) {
    h = h[0];
    var c = h.toLowerCase();
    this.protocol = c, a = a.substr(h.length);
  }
  if (t || h || a.match(/^\/\/[^@/]+@[^@/]+/)) {
    var u = a.substr(0, 2) === "//";
    u && !(h && Yh[h]) && (a = a.substr(2), this.slashes = !0);
  }
  if (!Yh[h] && (u || h && !Sn[h])) {
    for (var d = -1, f = 0; f < lf.length; f++) {
      var p = a.indexOf(lf[f]);
      p !== -1 && (d === -1 || p < d) && (d = p);
    }
    var _, m;
    d === -1 ? m = a.lastIndexOf("@") : m = a.lastIndexOf("@", d), m !== -1 && (_ = a.slice(0, m), a = a.slice(m + 1), this.auth = decodeURIComponent(_)), d = -1;
    for (var f = 0; f < af.length; f++) {
      var p = a.indexOf(af[f]);
      p !== -1 && (d === -1 || p < d) && (d = p);
    }
    d === -1 && (d = a.length), this.host = a.slice(0, d), a = a.slice(d), this.parseHost(), this.hostname = this.hostname || "";
    var y = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
    if (!y)
      for (var v = this.hostname.split(/\./), f = 0, g = v.length; f < g; f++) {
        var b = v[f];
        if (b && !b.match(hf)) {
          for (var w = "", T = 0, x = b.length; T < x; T++)
            b.charCodeAt(T) > 127 ? w += "x" : w += b[T];
          if (!w.match(hf)) {
            var E = v.slice(0, f), R = v.slice(f + 1), k = b.match(sA);
            k && (E.push(k[1]), R.unshift(k[2])), R.length && (a = "/" + R.join(".") + a), this.hostname = E.join(".");
            break;
          }
        }
      }
    this.hostname.length > nA ? this.hostname = "" : this.hostname = this.hostname.toLowerCase(), y || (this.hostname = JT.toASCII(this.hostname));
    var O = this.port ? ":" + this.port : "", B = this.hostname || "";
    this.host = B + O, this.href += this.host, y && (this.hostname = this.hostname.substr(1, this.hostname.length - 2), a[0] !== "/" && (a = "/" + a));
  }
  if (!oA[c])
    for (var f = 0, g = qh.length; f < g; f++) {
      var C = qh[f];
      if (a.indexOf(C) !== -1) {
        var M = encodeURIComponent(C);
        M === C && (M = escape(C)), a = a.split(C).join(M);
      }
    }
  var F = a.indexOf("#");
  F !== -1 && (this.hash = a.substr(F), a = a.slice(0, F));
  var U = a.indexOf("?");
  if (U !== -1 ? (this.search = a.substr(U), this.query = a.substr(U + 1), e && (this.query = Kh.parse(this.query)), a = a.slice(0, U)) : e && (this.search = "", this.query = {}), a && (this.pathname = a), Sn[c] && this.hostname && !this.pathname && (this.pathname = "/"), this.pathname || this.search) {
    var O = this.pathname || "", L = this.search || "";
    this.path = O + L;
  }
  return this.href = this.format(), this;
};
Mi.prototype.format = function() {
  var r = this.auth || "";
  r && (r = encodeURIComponent(r), r = r.replace(/%3A/i, ":"), r += "@");
  var e = this.protocol || "", t = this.pathname || "", i = this.hash || "", n = !1, s = "";
  this.host ? n = r + this.host : this.hostname && (n = r + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]"), this.port && (n += ":" + this.port)), this.query && typeof this.query == "object" && Object.keys(this.query).length && (s = Kh.stringify(this.query, {
    arrayFormat: "repeat",
    addQueryPrefix: !1
  }));
  var o = this.search || s && "?" + s || "";
  return e && e.substr(-1) !== ":" && (e += ":"), this.slashes || (!e || Sn[e]) && n !== !1 ? (n = "//" + (n || ""), t && t.charAt(0) !== "/" && (t = "/" + t)) : n || (n = ""), i && i.charAt(0) !== "#" && (i = "#" + i), o && o.charAt(0) !== "?" && (o = "?" + o), t = t.replace(/[?#]/g, function(a) {
    return encodeURIComponent(a);
  }), o = o.replace("#", "%23"), e + n + t + o + i;
};
Mi.prototype.resolve = function(r) {
  return this.resolveObject(aA(r, !1, !0)).format();
};
Mi.prototype.resolveObject = function(r) {
  if (typeof r == "string") {
    var e = new Mi();
    e.parse(r, !1, !0), r = e;
  }
  for (var t = new Mi(), i = Object.keys(this), n = 0; n < i.length; n++) {
    var s = i[n];
    t[s] = this[s];
  }
  if (t.hash = r.hash, r.href === "")
    return t.href = t.format(), t;
  if (r.slashes && !r.protocol) {
    for (var o = Object.keys(r), a = 0; a < o.length; a++) {
      var l = o[a];
      l !== "protocol" && (t[l] = r[l]);
    }
    return Sn[t.protocol] && t.hostname && !t.pathname && (t.pathname = "/", t.path = t.pathname), t.href = t.format(), t;
  }
  if (r.protocol && r.protocol !== t.protocol) {
    if (!Sn[r.protocol]) {
      for (var h = Object.keys(r), c = 0; c < h.length; c++) {
        var u = h[c];
        t[u] = r[u];
      }
      return t.href = t.format(), t;
    }
    if (t.protocol = r.protocol, !r.host && !Yh[r.protocol]) {
      for (var g = (r.pathname || "").split("/"); g.length && !(r.host = g.shift()); )
        ;
      r.host || (r.host = ""), r.hostname || (r.hostname = ""), g[0] !== "" && g.unshift(""), g.length < 2 && g.unshift(""), t.pathname = g.join("/");
    } else
      t.pathname = r.pathname;
    if (t.search = r.search, t.query = r.query, t.host = r.host || "", t.auth = r.auth, t.hostname = r.hostname || r.host, t.port = r.port, t.pathname || t.search) {
      var d = t.pathname || "", f = t.search || "";
      t.path = d + f;
    }
    return t.slashes = t.slashes || r.slashes, t.href = t.format(), t;
  }
  var p = t.pathname && t.pathname.charAt(0) === "/", _ = r.host || r.pathname && r.pathname.charAt(0) === "/", m = _ || p || t.host && r.pathname, y = m, v = t.pathname && t.pathname.split("/") || [], g = r.pathname && r.pathname.split("/") || [], b = t.protocol && !Sn[t.protocol];
  if (b && (t.hostname = "", t.port = null, t.host && (v[0] === "" ? v[0] = t.host : v.unshift(t.host)), t.host = "", r.protocol && (r.hostname = null, r.port = null, r.host && (g[0] === "" ? g[0] = r.host : g.unshift(r.host)), r.host = null), m = m && (g[0] === "" || v[0] === "")), _)
    t.host = r.host || r.host === "" ? r.host : t.host, t.hostname = r.hostname || r.hostname === "" ? r.hostname : t.hostname, t.search = r.search, t.query = r.query, v = g;
  else if (g.length)
    v || (v = []), v.pop(), v = v.concat(g), t.search = r.search, t.query = r.query;
  else if (r.search != null) {
    if (b) {
      t.host = v.shift(), t.hostname = t.host;
      var w = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1;
      w && (t.auth = w.shift(), t.hostname = w.shift(), t.host = t.hostname);
    }
    return t.search = r.search, t.query = r.query, (t.pathname !== null || t.search !== null) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), t.href = t.format(), t;
  }
  if (!v.length)
    return t.pathname = null, t.search ? t.path = "/" + t.search : t.path = null, t.href = t.format(), t;
  for (var T = v.slice(-1)[0], x = (t.host || r.host || v.length > 1) && (T === "." || T === "..") || T === "", E = 0, R = v.length; R >= 0; R--)
    T = v[R], T === "." ? v.splice(R, 1) : T === ".." ? (v.splice(R, 1), E++) : E && (v.splice(R, 1), E--);
  if (!m && !y)
    for (; E--; E)
      v.unshift("..");
  m && v[0] !== "" && (!v[0] || v[0].charAt(0) !== "/") && v.unshift(""), x && v.join("/").substr(-1) !== "/" && v.push("");
  var k = v[0] === "" || v[0] && v[0].charAt(0) === "/";
  if (b) {
    t.hostname = k ? "" : v.length ? v.shift() : "", t.host = t.hostname;
    var w = t.host && t.host.indexOf("@") > 0 ? t.host.split("@") : !1;
    w && (t.auth = w.shift(), t.hostname = w.shift(), t.host = t.hostname);
  }
  return m = m || t.host && v.length, m && !k && v.unshift(""), v.length > 0 ? t.pathname = v.join("/") : (t.pathname = null, t.path = null), (t.pathname !== null || t.search !== null) && (t.path = (t.pathname ? t.pathname : "") + (t.search ? t.search : "")), t.auth = r.auth || t.auth, t.slashes = t.slashes || r.slashes, t.href = t.format(), t;
};
Mi.prototype.parseHost = function() {
  var r = this.host, e = eA.exec(r);
  e && (e = e[0], e !== ":" && (this.port = e.substr(1)), r = r.substr(0, r.length - e.length)), r && (this.hostname = r);
};
const cf = {};
function fe(r, e, t = 3) {
  if (cf[e])
    return;
  let i = new Error().stack;
  typeof i > "u" ? console.warn("PixiJS Deprecation Warning: ", `${e}
Deprecated since v${r}`) : (i = i.split(`
`).splice(t).join(`
`), console.groupCollapsed ? (console.groupCollapsed(
    "%cPixiJS Deprecation Warning: %c%s",
    "color:#614108;background:#fffbe6",
    "font-weight:normal;color:#614108;background:#fffbe6",
    `${e}
Deprecated since v${r}`
  ), console.warn(i), console.groupEnd()) : (console.warn("PixiJS Deprecation Warning: ", `${e}
Deprecated since v${r}`), console.warn(i))), cf[e] = !0;
}
function Gt(r) {
  if (typeof r != "string")
    throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`);
}
function ts(r) {
  return r.split("?")[0].split("#")[0];
}
function lA(r) {
  return r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function hA(r, e, t) {
  return r.replace(new RegExp(lA(e), "g"), t);
}
function cA(r, e) {
  let t = "", i = 0, n = -1, s = 0, o = -1;
  for (let a = 0; a <= r.length; ++a) {
    if (a < r.length)
      o = r.charCodeAt(a);
    else {
      if (o === 47)
        break;
      o = 47;
    }
    if (o === 47) {
      if (!(n === a - 1 || s === 1))
        if (n !== a - 1 && s === 2) {
          if (t.length < 2 || i !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
            if (t.length > 2) {
              const l = t.lastIndexOf("/");
              if (l !== t.length - 1) {
                l === -1 ? (t = "", i = 0) : (t = t.slice(0, l), i = t.length - 1 - t.lastIndexOf("/")), n = a, s = 0;
                continue;
              }
            } else if (t.length === 2 || t.length === 1) {
              t = "", i = 0, n = a, s = 0;
              continue;
            }
          }
        } else
          t.length > 0 ? t += `/${r.slice(n + 1, a)}` : t = r.slice(n + 1, a), i = a - n - 1;
      n = a, s = 0;
    } else
      o === 46 && s !== -1 ? ++s : s = -1;
  }
  return t;
}
const We = {
  /**
   * Converts a path to posix format.
   * @param path - The path to convert to posix
   */
  toPosix(r) {
    return hA(r, "\\", "/");
  },
  /**
   * Checks if the path is a URL e.g. http://, https://
   * @param path - The path to check
   */
  isUrl(r) {
    return /^https?:/.test(this.toPosix(r));
  },
  /**
   * Checks if the path is a data URL
   * @param path - The path to check
   */
  isDataUrl(r) {
    return /^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r);
  },
  /**
   * Checks if the path is a blob URL
   * @param path - The path to check
   */
  isBlobUrl(r) {
    return r.startsWith("blob:");
  },
  /**
   * Checks if the path has a protocol e.g. http://, https://, file:///, data:, blob:, C:/
   * This will return true for windows file paths
   * @param path - The path to check
   */
  hasProtocol(r) {
    return /^[^/:]+:/.test(this.toPosix(r));
  },
  /**
   * Returns the protocol of the path e.g. http://, https://, file:///, data:, blob:, C:/
   * @param path - The path to get the protocol from
   */
  getProtocol(r) {
    Gt(r), r = this.toPosix(r);
    const e = /^file:\/\/\//.exec(r);
    if (e)
      return e[0];
    const t = /^[^/:]+:\/{0,2}/.exec(r);
    return t ? t[0] : "";
  },
  /**
   * Converts URL to an absolute path.
   * When loading from a Web Worker, we must use absolute paths.
   * If the URL is already absolute we return it as is
   * If it's not, we convert it
   * @param url - The URL to test
   * @param customBaseUrl - The base URL to use
   * @param customRootUrl - The root URL to use
   */
  toAbsolute(r, e, t) {
    if (Gt(r), this.isDataUrl(r) || this.isBlobUrl(r))
      return r;
    const i = ts(this.toPosix(e ?? Z.ADAPTER.getBaseUrl())), n = ts(this.toPosix(t ?? this.rootname(i)));
    return r = this.toPosix(r), r.startsWith("/") ? We.join(n, r.slice(1)) : this.isAbsolute(r) ? r : this.join(i, r);
  },
  /**
   * Normalizes the given path, resolving '..' and '.' segments
   * @param path - The path to normalize
   */
  normalize(r) {
    if (Gt(r), r.length === 0)
      return ".";
    if (this.isDataUrl(r) || this.isBlobUrl(r))
      return r;
    r = this.toPosix(r);
    let e = "";
    const t = r.startsWith("/");
    this.hasProtocol(r) && (e = this.rootname(r), r = r.slice(e.length));
    const i = r.endsWith("/");
    return r = cA(r), r.length > 0 && i && (r += "/"), t ? `/${r}` : e + r;
  },
  /**
   * Determines if path is an absolute path.
   * Absolute paths can be urls, data urls, or paths on disk
   * @param path - The path to test
   */
  isAbsolute(r) {
    return Gt(r), r = this.toPosix(r), this.hasProtocol(r) ? !0 : r.startsWith("/");
  },
  /**
   * Joins all given path segments together using the platform-specific separator as a delimiter,
   * then normalizes the resulting path
   * @param segments - The segments of the path to join
   */
  join(...r) {
    if (r.length === 0)
      return ".";
    let e;
    for (let t = 0; t < r.length; ++t) {
      const i = r[t];
      if (Gt(i), i.length > 0)
        if (e === void 0)
          e = i;
        else {
          const n = r[t - 1] ?? "";
          this.joinExtensions.includes(this.extname(n).toLowerCase()) ? e += `/../${i}` : e += `/${i}`;
        }
    }
    return e === void 0 ? "." : this.normalize(e);
  },
  /**
   * Returns the directory name of a path
   * @param path - The path to parse
   */
  dirname(r) {
    if (Gt(r), r.length === 0)
      return ".";
    r = this.toPosix(r);
    let e = r.charCodeAt(0);
    const t = e === 47;
    let i = -1, n = !0;
    const s = this.getProtocol(r), o = r;
    r = r.slice(s.length);
    for (let a = r.length - 1; a >= 1; --a)
      if (e = r.charCodeAt(a), e === 47) {
        if (!n) {
          i = a;
          break;
        }
      } else
        n = !1;
    return i === -1 ? t ? "/" : this.isUrl(o) ? s + r : s : t && i === 1 ? "//" : s + r.slice(0, i);
  },
  /**
   * Returns the root of the path e.g. /, C:/, file:///, http://domain.com/
   * @param path - The path to parse
   */
  rootname(r) {
    Gt(r), r = this.toPosix(r);
    let e = "";
    if (r.startsWith("/") ? e = "/" : e = this.getProtocol(r), this.isUrl(r)) {
      const t = r.indexOf("/", e.length);
      t !== -1 ? e = r.slice(0, t) : e = r, e.endsWith("/") || (e += "/");
    }
    return e;
  },
  /**
   * Returns the last portion of a path
   * @param path - The path to test
   * @param ext - Optional extension to remove
   */
  basename(r, e) {
    Gt(r), e && Gt(e), r = ts(this.toPosix(r));
    let t = 0, i = -1, n = !0, s;
    if (e !== void 0 && e.length > 0 && e.length <= r.length) {
      if (e.length === r.length && e === r)
        return "";
      let o = e.length - 1, a = -1;
      for (s = r.length - 1; s >= 0; --s) {
        const l = r.charCodeAt(s);
        if (l === 47) {
          if (!n) {
            t = s + 1;
            break;
          }
        } else
          a === -1 && (n = !1, a = s + 1), o >= 0 && (l === e.charCodeAt(o) ? --o === -1 && (i = s) : (o = -1, i = a));
      }
      return t === i ? i = a : i === -1 && (i = r.length), r.slice(t, i);
    }
    for (s = r.length - 1; s >= 0; --s)
      if (r.charCodeAt(s) === 47) {
        if (!n) {
          t = s + 1;
          break;
        }
      } else
        i === -1 && (n = !1, i = s + 1);
    return i === -1 ? "" : r.slice(t, i);
  },
  /**
   * Returns the extension of the path, from the last occurrence of the . (period) character to end of string in the last
   * portion of the path. If there is no . in the last portion of the path, or if there are no . characters other than
   * the first character of the basename of path, an empty string is returned.
   * @param path - The path to parse
   */
  extname(r) {
    Gt(r), r = ts(this.toPosix(r));
    let e = -1, t = 0, i = -1, n = !0, s = 0;
    for (let o = r.length - 1; o >= 0; --o) {
      const a = r.charCodeAt(o);
      if (a === 47) {
        if (!n) {
          t = o + 1;
          break;
        }
        continue;
      }
      i === -1 && (n = !1, i = o + 1), a === 46 ? e === -1 ? e = o : s !== 1 && (s = 1) : e !== -1 && (s = -1);
    }
    return e === -1 || i === -1 || s === 0 || s === 1 && e === i - 1 && e === t + 1 ? "" : r.slice(e, i);
  },
  /**
   * Parses a path into an object containing the 'root', `dir`, `base`, `ext`, and `name` properties.
   * @param path - The path to parse
   */
  parse(r) {
    Gt(r);
    const e = { root: "", dir: "", base: "", ext: "", name: "" };
    if (r.length === 0)
      return e;
    r = ts(this.toPosix(r));
    let t = r.charCodeAt(0);
    const i = this.isAbsolute(r);
    let n;
    e.root = this.rootname(r), i || this.hasProtocol(r) ? n = 1 : n = 0;
    let s = -1, o = 0, a = -1, l = !0, h = r.length - 1, c = 0;
    for (; h >= n; --h) {
      if (t = r.charCodeAt(h), t === 47) {
        if (!l) {
          o = h + 1;
          break;
        }
        continue;
      }
      a === -1 && (l = !1, a = h + 1), t === 46 ? s === -1 ? s = h : c !== 1 && (c = 1) : s !== -1 && (c = -1);
    }
    return s === -1 || a === -1 || c === 0 || c === 1 && s === a - 1 && s === o + 1 ? a !== -1 && (o === 0 && i ? e.base = e.name = r.slice(1, a) : e.base = e.name = r.slice(o, a)) : (o === 0 && i ? (e.name = r.slice(1, s), e.base = r.slice(1, a)) : (e.name = r.slice(o, s), e.base = r.slice(o, a)), e.ext = r.slice(s, a)), e.dir = this.dirname(r), e;
  },
  sep: "/",
  delimiter: ":",
  joinExtensions: [".html"]
};
let Ul;
async function uA() {
  return Ul ?? (Ul = (async () => {
    var s;
    const r = document.createElement("canvas").getContext("webgl");
    if (!r)
      return ut.UNPACK;
    const e = await new Promise((o) => {
      const a = document.createElement("video");
      a.onloadeddata = () => o(a), a.onerror = () => o(null), a.autoplay = !1, a.crossOrigin = "anonymous", a.preload = "auto", a.src = "data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=", a.load();
    });
    if (!e)
      return ut.UNPACK;
    const t = r.createTexture();
    r.bindTexture(r.TEXTURE_2D, t);
    const i = r.createFramebuffer();
    r.bindFramebuffer(r.FRAMEBUFFER, i), r.framebufferTexture2D(
      r.FRAMEBUFFER,
      r.COLOR_ATTACHMENT0,
      r.TEXTURE_2D,
      t,
      0
    ), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL, r.NONE), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, e);
    const n = new Uint8Array(4);
    return r.readPixels(0, 0, 1, 1, r.RGBA, r.UNSIGNED_BYTE, n), r.deleteFramebuffer(i), r.deleteTexture(t), (s = r.getExtension("WEBGL_lose_context")) == null || s.loseContext(), n[0] <= n[3] ? ut.PMA : ut.UNPACK;
  })()), Ul;
}
let Gl;
function dA() {
  return typeof Gl > "u" && (Gl = function() {
    var e;
    const r = {
      stencil: !0,
      failIfMajorPerformanceCaveat: Z.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT
    };
    try {
      if (!Z.ADAPTER.getWebGLRenderingContext())
        return !1;
      const t = Z.ADAPTER.createCanvas();
      let i = t.getContext("webgl", r) || t.getContext("experimental-webgl", r);
      const n = !!((e = i == null ? void 0 : i.getContextAttributes()) != null && e.stencil);
      if (i) {
        const s = i.getExtension("WEBGL_lose_context");
        s && s.loseContext();
      }
      return i = null, n;
    } catch {
      return !1;
    }
  }()), Gl;
}
var fA = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, xi = function(r) {
  return typeof r == "string" ? r.length > 0 : typeof r == "number";
}, Ve = function(r, e, t) {
  return e === void 0 && (e = 0), t === void 0 && (t = Math.pow(10, e)), Math.round(t * r) / t + 0;
}, kt = function(r, e, t) {
  return e === void 0 && (e = 0), t === void 0 && (t = 1), r > t ? t : r > e ? r : e;
}, mm = function(r) {
  return (r = isFinite(r) ? r % 360 : 0) > 0 ? r : r + 360;
}, uf = function(r) {
  return { r: kt(r.r, 0, 255), g: kt(r.g, 0, 255), b: kt(r.b, 0, 255), a: kt(r.a) };
}, Hl = function(r) {
  return { r: Ve(r.r), g: Ve(r.g), b: Ve(r.b), a: Ve(r.a, 3) };
}, pA = /^#([0-9a-f]{3,8})$/i, to = function(r) {
  var e = r.toString(16);
  return e.length < 2 ? "0" + e : e;
}, gm = function(r) {
  var e = r.r, t = r.g, i = r.b, n = r.a, s = Math.max(e, t, i), o = s - Math.min(e, t, i), a = o ? s === e ? (t - i) / o : s === t ? 2 + (i - e) / o : 4 + (e - t) / o : 0;
  return { h: 60 * (a < 0 ? a + 6 : a), s: s ? o / s * 100 : 0, v: s / 255 * 100, a: n };
}, ym = function(r) {
  var e = r.h, t = r.s, i = r.v, n = r.a;
  e = e / 360 * 6, t /= 100, i /= 100;
  var s = Math.floor(e), o = i * (1 - t), a = i * (1 - (e - s) * t), l = i * (1 - (1 - e + s) * t), h = s % 6;
  return { r: 255 * [i, a, o, o, l, i][h], g: 255 * [l, i, i, a, o, o][h], b: 255 * [o, o, l, i, i, a][h], a: n };
}, df = function(r) {
  return { h: mm(r.h), s: kt(r.s, 0, 100), l: kt(r.l, 0, 100), a: kt(r.a) };
}, ff = function(r) {
  return { h: Ve(r.h), s: Ve(r.s), l: Ve(r.l), a: Ve(r.a, 3) };
}, pf = function(r) {
  return ym((t = (e = r).s, { h: e.h, s: (t *= ((i = e.l) < 50 ? i : 100 - i) / 100) > 0 ? 2 * t / (i + t) * 100 : 0, v: i + t, a: e.a }));
  var e, t, i;
}, Ts = function(r) {
  return { h: (e = gm(r)).h, s: (n = (200 - (t = e.s)) * (i = e.v) / 100) > 0 && n < 200 ? t * i / 100 / (n <= 100 ? n : 200 - n) * 100 : 0, l: n / 2, a: e.a };
  var e, t, i, n;
}, _A = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, mA = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, gA = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, yA = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Zh = { string: [[function(r) {
  var e = pA.exec(r);
  return e ? (r = e[1]).length <= 4 ? { r: parseInt(r[0] + r[0], 16), g: parseInt(r[1] + r[1], 16), b: parseInt(r[2] + r[2], 16), a: r.length === 4 ? Ve(parseInt(r[3] + r[3], 16) / 255, 2) : 1 } : r.length === 6 || r.length === 8 ? { r: parseInt(r.substr(0, 2), 16), g: parseInt(r.substr(2, 2), 16), b: parseInt(r.substr(4, 2), 16), a: r.length === 8 ? Ve(parseInt(r.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
}, "hex"], [function(r) {
  var e = gA.exec(r) || yA.exec(r);
  return e ? e[2] !== e[4] || e[4] !== e[6] ? null : uf({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
}, "rgb"], [function(r) {
  var e = _A.exec(r) || mA.exec(r);
  if (!e)
    return null;
  var t, i, n = df({ h: (t = e[1], i = e[2], i === void 0 && (i = "deg"), Number(t) * (fA[i] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
  return pf(n);
}, "hsl"]], object: [[function(r) {
  var e = r.r, t = r.g, i = r.b, n = r.a, s = n === void 0 ? 1 : n;
  return xi(e) && xi(t) && xi(i) ? uf({ r: Number(e), g: Number(t), b: Number(i), a: Number(s) }) : null;
}, "rgb"], [function(r) {
  var e = r.h, t = r.s, i = r.l, n = r.a, s = n === void 0 ? 1 : n;
  if (!xi(e) || !xi(t) || !xi(i))
    return null;
  var o = df({ h: Number(e), s: Number(t), l: Number(i), a: Number(s) });
  return pf(o);
}, "hsl"], [function(r) {
  var e = r.h, t = r.s, i = r.v, n = r.a, s = n === void 0 ? 1 : n;
  if (!xi(e) || !xi(t) || !xi(i))
    return null;
  var o = function(a) {
    return { h: mm(a.h), s: kt(a.s, 0, 100), v: kt(a.v, 0, 100), a: kt(a.a) };
  }({ h: Number(e), s: Number(t), v: Number(i), a: Number(s) });
  return ym(o);
}, "hsv"]] }, _f = function(r, e) {
  for (var t = 0; t < e.length; t++) {
    var i = e[t][0](r);
    if (i)
      return [i, e[t][1]];
  }
  return [null, void 0];
}, vA = function(r) {
  return typeof r == "string" ? _f(r.trim(), Zh.string) : typeof r == "object" && r !== null ? _f(r, Zh.object) : [null, void 0];
}, zl = function(r, e) {
  var t = Ts(r);
  return { h: t.h, s: kt(t.s + 100 * e, 0, 100), l: t.l, a: t.a };
}, Xl = function(r) {
  return (299 * r.r + 587 * r.g + 114 * r.b) / 1e3 / 255;
}, mf = function(r, e) {
  var t = Ts(r);
  return { h: t.h, s: t.s, l: kt(t.l + 100 * e, 0, 100), a: t.a };
}, $h = function() {
  function r(e) {
    this.parsed = vA(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
  }
  return r.prototype.isValid = function() {
    return this.parsed !== null;
  }, r.prototype.brightness = function() {
    return Ve(Xl(this.rgba), 2);
  }, r.prototype.isDark = function() {
    return Xl(this.rgba) < 0.5;
  }, r.prototype.isLight = function() {
    return Xl(this.rgba) >= 0.5;
  }, r.prototype.toHex = function() {
    return e = Hl(this.rgba), t = e.r, i = e.g, n = e.b, o = (s = e.a) < 1 ? to(Ve(255 * s)) : "", "#" + to(t) + to(i) + to(n) + o;
    var e, t, i, n, s, o;
  }, r.prototype.toRgb = function() {
    return Hl(this.rgba);
  }, r.prototype.toRgbString = function() {
    return e = Hl(this.rgba), t = e.r, i = e.g, n = e.b, (s = e.a) < 1 ? "rgba(" + t + ", " + i + ", " + n + ", " + s + ")" : "rgb(" + t + ", " + i + ", " + n + ")";
    var e, t, i, n, s;
  }, r.prototype.toHsl = function() {
    return ff(Ts(this.rgba));
  }, r.prototype.toHslString = function() {
    return e = ff(Ts(this.rgba)), t = e.h, i = e.s, n = e.l, (s = e.a) < 1 ? "hsla(" + t + ", " + i + "%, " + n + "%, " + s + ")" : "hsl(" + t + ", " + i + "%, " + n + "%)";
    var e, t, i, n, s;
  }, r.prototype.toHsv = function() {
    return e = gm(this.rgba), { h: Ve(e.h), s: Ve(e.s), v: Ve(e.v), a: Ve(e.a, 3) };
    var e;
  }, r.prototype.invert = function() {
    return ni({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
    var e;
  }, r.prototype.saturate = function(e) {
    return e === void 0 && (e = 0.1), ni(zl(this.rgba, e));
  }, r.prototype.desaturate = function(e) {
    return e === void 0 && (e = 0.1), ni(zl(this.rgba, -e));
  }, r.prototype.grayscale = function() {
    return ni(zl(this.rgba, -1));
  }, r.prototype.lighten = function(e) {
    return e === void 0 && (e = 0.1), ni(mf(this.rgba, e));
  }, r.prototype.darken = function(e) {
    return e === void 0 && (e = 0.1), ni(mf(this.rgba, -e));
  }, r.prototype.rotate = function(e) {
    return e === void 0 && (e = 15), this.hue(this.hue() + e);
  }, r.prototype.alpha = function(e) {
    return typeof e == "number" ? ni({ r: (t = this.rgba).r, g: t.g, b: t.b, a: e }) : Ve(this.rgba.a, 3);
    var t;
  }, r.prototype.hue = function(e) {
    var t = Ts(this.rgba);
    return typeof e == "number" ? ni({ h: e, s: t.s, l: t.l, a: t.a }) : Ve(t.h);
  }, r.prototype.isEqual = function(e) {
    return this.toHex() === ni(e).toHex();
  }, r;
}(), ni = function(r) {
  return r instanceof $h ? r : new $h(r);
}, gf = [], bA = function(r) {
  r.forEach(function(e) {
    gf.indexOf(e) < 0 && (e($h, Zh), gf.push(e));
  });
};
function wA(r, e) {
  var t = { 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 n in t)
    i[t[n]] = n;
  var s = {};
  r.prototype.toName = function(o) {
    if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b))
      return "transparent";
    var a, l, h = i[this.toHex()];
    if (h)
      return h;
    if (o != null && o.closest) {
      var c = this.toRgb(), u = 1 / 0, d = "black";
      if (!s.length)
        for (var f in t)
          s[f] = new r(t[f]).toRgb();
      for (var p in t) {
        var _ = (a = c, l = s[p], Math.pow(a.r - l.r, 2) + Math.pow(a.g - l.g, 2) + Math.pow(a.b - l.b, 2));
        _ < u && (u = _, d = p);
      }
      return d;
    }
  }, e.string.push([function(o) {
    var a = o.toLowerCase(), l = a === "transparent" ? "#0000" : t[a];
    return l ? new r(l).toRgb() : null;
  }, "name"]);
}
bA([wA]);
const dn = class Po {
  /**
   * @param {PIXI.ColorSource} value - Optional value to use, if not provided, white is used.
   */
  constructor(e = 16777215) {
    this._value = null, this._components = new Float32Array(4), this._components.fill(1), this._int = 16777215, this.value = e;
  }
  /** Get red component (0 - 1) */
  get red() {
    return this._components[0];
  }
  /** Get green component (0 - 1) */
  get green() {
    return this._components[1];
  }
  /** Get blue component (0 - 1) */
  get blue() {
    return this._components[2];
  }
  /** Get alpha component (0 - 1) */
  get alpha() {
    return this._components[3];
  }
  /**
   * Set the value, suitable for chaining
   * @param value
   * @see PIXI.Color.value
   */
  setValue(e) {
    return this.value = e, this;
  }
  /**
   * The current color source.
   *
   * When setting:
   * - Setting to an instance of `Color` will copy its color source and components.
   * - Otherwise, `Color` will try to normalize the color source and set the components.
   *   If the color source is invalid, an `Error` will be thrown and the `Color` will left unchanged.
   *
   * Note: The `null` in the setter's parameter type is added to match the TypeScript rule: return type of getter
   * must be assignable to its setter's parameter type. Setting `value` to `null` will throw an `Error`.
   *
   * When getting:
   * - A return value of `null` means the previous value was overridden (e.g., {@link PIXI.Color.multiply multiply},
   *   {@link PIXI.Color.premultiply premultiply} or {@link PIXI.Color.round round}).
   * - Otherwise, the color source used when setting is returned.
   * @type {PIXI.ColorSource}
   */
  set value(e) {
    if (e instanceof Po)
      this._value = this.cloneSource(e._value), this._int = e._int, this._components.set(e._components);
    else {
      if (e === null)
        throw new Error("Cannot set PIXI.Color#value to null");
      (this._value === null || !this.isSourceEqual(this._value, e)) && (this.normalize(e), this._value = this.cloneSource(e));
    }
  }
  get value() {
    return this._value;
  }
  /**
   * Copy a color source internally.
   * @param value - Color source
   */
  cloneSource(e) {
    return typeof e == "string" || typeof e == "number" || e instanceof Number || e === null ? e : Array.isArray(e) || ArrayBuffer.isView(e) ? e.slice(0) : typeof e == "object" && e !== null ? { ...e } : e;
  }
  /**
   * Equality check for color sources.
   * @param value1 - First color source
   * @param value2 - Second color source
   * @returns `true` if the color sources are equal, `false` otherwise.
   */
  isSourceEqual(e, t) {
    const i = typeof e;
    if (i !== typeof t)
      return !1;
    if (i === "number" || i === "string" || e instanceof Number)
      return e === t;
    if (Array.isArray(e) && Array.isArray(t) || ArrayBuffer.isView(e) && ArrayBuffer.isView(t))
      return e.length !== t.length ? !1 : e.every((n, s) => n === t[s]);
    if (e !== null && t !== null) {
      const n = Object.keys(e), s = Object.keys(t);
      return n.length !== s.length ? !1 : n.every((o) => e[o] === t[o]);
    }
    return e === t;
  }
  /**
   * Convert to a RGBA color object.
   * @example
   * import { Color } from 'pixi.js';
   * new Color('white').toRgb(); // returns { r: 1, g: 1, b: 1, a: 1 }
   */
  toRgba() {
    const [e, t, i, n] = this._components;
    return { r: e, g: t, b: i, a: n };
  }
  /**
   * Convert to a RGB color object.
   * @example
   * import { Color } from 'pixi.js';
   * new Color('white').toRgb(); // returns { r: 1, g: 1, b: 1 }
   */
  toRgb() {
    const [e, t, i] = this._components;
    return { r: e, g: t, b: i };
  }
  /** Convert to a CSS-style rgba string: `rgba(255,255,255,1.0)`. */
  toRgbaString() {
    const [e, t, i] = this.toUint8RgbArray();
    return `rgba(${e},${t},${i},${this.alpha})`;
  }
  toUint8RgbArray(e) {
    const [t, i, n] = this._components;
    return e = e ?? [], e[0] = Math.round(t * 255), e[1] = Math.round(i * 255), e[2] = Math.round(n * 255), e;
  }
  toRgbArray(e) {
    e = e ?? [];
    const [t, i, n] = this._components;
    return e[0] = t, e[1] = i, e[2] = n, e;
  }
  /**
   * Convert to a hexadecimal number.
   * @example
   * import { Color } from 'pixi.js';
   * new Color('white').toNumber(); // returns 16777215
   */
  toNumber() {
    return this._int;
  }
  /**
   * Convert to a hexadecimal number in little endian format (e.g., BBGGRR).
   * @example
   * import { Color } from 'pixi.js';
   * new Color(0xffcc99).toLittleEndianNumber(); // returns 0x99ccff
   * @returns {number} - The color as a number in little endian format.
   */
  toLittleEndianNumber() {
    const e = this._int;
    return (e >> 16) + (e & 65280) + ((e & 255) << 16);
  }
  /**
   * Multiply with another color. This action is destructive, and will
   * override the previous `value` property to be `null`.
   * @param {PIXI.ColorSource} value - The color to multiply by.
   */
  multiply(e) {
    const [t, i, n, s] = Po.temp.setValue(e)._components;
    return this._components[0] *= t, this._components[1] *= i, this._components[2] *= n, this._components[3] *= s, this.refreshInt(), this._value = null, this;
  }
  /**
   * Converts color to a premultiplied alpha format. This action is destructive, and will
   * override the previous `value` property to be `null`.
   * @param alpha - The alpha to multiply by.
   * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.
   * @returns {PIXI.Color} - Itself.
   */
  premultiply(e, t = !0) {
    return t && (this._components[0] *= e, this._components[1] *= e, this._components[2] *= e), this._components[3] = e, this.refreshInt(), this._value = null, this;
  }
  /**
   * Premultiplies alpha with current color.
   * @param {number} alpha - The alpha to multiply by.
   * @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.
   * @returns {number} tint multiplied by alpha
   */
  toPremultiplied(e, t = !0) {
    if (e === 1)
      return (255 << 24) + this._int;
    if (e === 0)
      return t ? 0 : this._int;
    let i = this._int >> 16 & 255, n = this._int >> 8 & 255, s = this._int & 255;
    return t && (i = i * e + 0.5 | 0, n = n * e + 0.5 | 0, s = s * e + 0.5 | 0), (e * 255 << 24) + (i << 16) + (n << 8) + s;
  }
  /**
   * Convert to a hexidecimal string.
   * @example
   * import { Color } from 'pixi.js';
   * new Color('white').toHex(); // returns "#ffffff"
   */
  toHex() {
    const e = this._int.toString(16);
    return `#${"000000".substring(0, 6 - e.length) + e}`;
  }
  /**
   * Convert to a hexidecimal string with alpha.
   * @example
   * import { Color } from 'pixi.js';
   * new Color('white').toHexa(); // returns "#ffffffff"
   */
  toHexa() {
    const e = Math.round(this._components[3] * 255).toString(16);
    return this.toHex() + "00".substring(0, 2 - e.length) + e;
  }
  /**
   * Set alpha, suitable for chaining.
   * @param alpha
   */
  setAlpha(e) {
    return this._components[3] = this._clamp(e), this;
  }
  /**
   * Rounds the specified color according to the step. This action is destructive, and will
   * override the previous `value` property to be `null`. The alpha component is not rounded.
   * @param steps - Number of steps which will be used as a cap when rounding colors
   * @deprecated since 7.3.0
   */
  round(e) {
    const [t, i, n] = this._components;
    return this._components[0] = Math.round(t * e) / e, this._components[1] = Math.round(i * e) / e, this._components[2] = Math.round(n * e) / e, this.refreshInt(), this._value = null, this;
  }
  toArray(e) {
    e = e ?? [];
    const [t, i, n, s] = this._components;
    return e[0] = t, e[1] = i, e[2] = n, e[3] = s, e;
  }
  /**
   * Normalize the input value into rgba
   * @param value - Input value
   */
  normalize(e) {
    let t, i, n, s;
    if ((typeof e == "number" || e instanceof Number) && e >= 0 && e <= 16777215) {
      const o = e;
      t = (o >> 16 & 255) / 255, i = (o >> 8 & 255) / 255, n = (o & 255) / 255, s = 1;
    } else if ((Array.isArray(e) || e instanceof Float32Array) && e.length >= 3 && e.length <= 4)
      e = this._clamp(e), [t, i, n, s = 1] = e;
    else if ((e instanceof Uint8Array || e instanceof Uint8ClampedArray) && e.length >= 3 && e.length <= 4)
      e = this._clamp(e, 0, 255), [t, i, n, s = 255] = e, t /= 255, i /= 255, n /= 255, s /= 255;
    else if (typeof e == "string" || typeof e == "object") {
      if (typeof e == "string") {
        const a = Po.HEX_PATTERN.exec(e);
        a && (e = `#${a[2]}`);
      }
      const o = ni(e);
      o.isValid() && ({ r: t, g: i, b: n, a: s } = o.rgba, t /= 255, i /= 255, n /= 255);
    }
    if (t !== void 0)
      this._components[0] = t, this._components[1] = i, this._components[2] = n, this._components[3] = s, this.refreshInt();
    else
      throw new Error(`Unable to convert color ${e}`);
  }
  /** Refresh the internal color rgb number */
  refreshInt() {
    this._clamp(this._components);
    const [e, t, i] = this._components;
    this._int = (e * 255 << 16) + (t * 255 << 8) + (i * 255 | 0);
  }
  /**
   * Clamps values to a range. Will override original values
   * @param value - Value(s) to clamp
   * @param min - Minimum value
   * @param max - Maximum value
   */
  _clamp(e, t = 0, i = 1) {
    return typeof e == "number" ? Math.min(Math.max(e, t), i) : (e.forEach((n, s) => {
      e[s] = Math.min(Math.max(n, t), i);
    }), e);
  }
};
dn.shared = new dn(), /**
* Temporary Color object for static uses internally.
* As to not conflict with Color.shared.
* @ignore
*/
dn.temp = new dn(), /** Pattern for hex strings */
dn.HEX_PATTERN = /^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;
let be = dn;
function xA(r) {
  return fe("7.2.0", "utils.hex2string is deprecated, use Color#toHex instead"), be.shared.setValue(r).toHex();
}
function EA(r) {
  return fe("7.2.0", "utils.rgb2hex is deprecated, use Color#toNumber instead"), be.shared.setValue(r).toNumber();
}
function TA() {
  const r = [], e = [];
  for (let i = 0; i < 32; i++)
    r[i] = i, e[i] = i;
  r[oe.NORMAL_NPM] = oe.NORMAL, r[oe.ADD_NPM] = oe.ADD, r[oe.SCREEN_NPM] = oe.SCREEN, e[oe.NORMAL] = oe.NORMAL_NPM, e[oe.ADD] = oe.ADD_NPM, e[oe.SCREEN] = oe.SCREEN_NPM;
  const t = [];
  return t.push(e), t.push(r), t;
}
const vm = TA();
function bm(r, e) {
  return vm[e ? 1 : 0][r];
}
function AA(r, e = null) {
  const t = r * 6;
  if (e = e || new Uint16Array(t), e.length !== t)
    throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${t}`);
  for (let i = 0, n = 0; i < t; i += 6, n += 4)
    e[i + 0] = n + 0, e[i + 1] = n + 1, e[i + 2] = n + 2, e[i + 3] = n + 0, e[i + 4] = n + 2, e[i + 5] = n + 3;
  return e;
}
function wm(r) {
  if (r.BYTES_PER_ELEMENT === 4)
    return r instanceof Float32Array ? "Float32Array" : r instanceof Uint32Array ? "Uint32Array" : "Int32Array";
  if (r.BYTES_PER_ELEMENT === 2) {
    if (r instanceof Uint16Array)
      return "Uint16Array";
  } else if (r.BYTES_PER_ELEMENT === 1 && r instanceof Uint8Array)
    return "Uint8Array";
  return null;
}
function na(r) {
  return r += r === 0 ? 1 : 0, --r, r |= r >>> 1, r |= r >>> 2, r |= r >>> 4, r |= r >>> 8, r |= r >>> 16, r + 1;
}
function yf(r) {
  return !(r & r - 1) && !!r;
}
function vf(r) {
  let e = (r > 65535 ? 1 : 0) << 4;
  r >>>= e;
  let t = (r > 255 ? 1 : 0) << 3;
  return r >>>= t, e |= t, t = (r > 15 ? 1 : 0) << 2, r >>>= t, e |= t, t = (r > 3 ? 1 : 0) << 1, r >>>= t, e |= t, e | r >> 1;
}
function Cn(r, e, t) {
  const i = r.length;
  let n;
  if (e >= i || t === 0)
    return;
  t = e + t > i ? i - e : t;
  const s = i - t;
  for (n = e; n < s; ++n)
    r[n] = r[n + t];
  r.length = s;
}
function Zi(r) {
  return r === 0 ? 0 : r < 0 ? -1 : 1;
}
let SA = 0;
function Hr() {
  return ++SA;
}
const Jh = class {
  /**
   * @param left - The left coordinate value of the bounding box.
   * @param top - The top coordinate value of the bounding box.
   * @param right - The right coordinate value of the bounding box.
   * @param bottom - The bottom coordinate value of the bounding box.
   */
  constructor(r, e, t, i) {
    this.left = r, this.top = e, this.right = t, this.bottom = i;
  }
  /** The width of the bounding box. */
  get width() {
    return this.right - this.left;
  }
  /** The height of the bounding box. */
  get height() {
    return this.bottom - this.top;
  }
  /** Determines whether the BoundingBox is empty. */
  isEmpty() {
    return this.left === this.right || this.top === this.bottom;
  }
};
Jh.EMPTY = new Jh(0, 0, 0, 0);
let bf = Jh;
const wf = {}, si = /* @__PURE__ */ Object.create(null), Hi = /* @__PURE__ */ Object.create(null);
class CA {
  /**
   * @param width - the width for the newly created canvas
   * @param height - the height for the newly created canvas
   * @param {number} [resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the canvas
   */
  constructor(e, t, i) {
    this._canvas = Z.ADAPTER.createCanvas(), this._context = this._canvas.getContext("2d"), this.resolution = i || Z.RESOLUTION, this.resize(e, t);
  }
  /**
   * Clears the canvas that was created by the CanvasRenderTarget class.
   * @private
   */
  clear() {
    this._checkDestroyed(), this._context.setTransform(1, 0, 0, 1, 0, 0), this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
  }
  /**
   * Resizes the canvas to the specified width and height.
   * @param desiredWidth - the desired width of the canvas
   * @param desiredHeight - the desired height of the canvas
   */
  resize(e, t) {
    this._checkDestroyed(), this._canvas.width = Math.round(e * this.resolution), this._canvas.height = Math.round(t * this.resolution);
  }
  /** Destroys this canvas. */
  destroy() {
    this._context = null, this._canvas = null;
  }
  /**
   * The width of the canvas buffer in pixels.
   * @member {number}
   */
  get width() {
    return this._checkDestroyed(), this._canvas.width;
  }
  set width(e) {
    this._checkDestroyed(), this._canvas.width = Math.round(e);
  }
  /**
   * The height of the canvas buffer in pixels.
   * @member {number}
   */
  get height() {
    return this._checkDestroyed(), this._canvas.height;
  }
  set height(e) {
    this._checkDestroyed(), this._canvas.height = Math.round(e);
  }
  /** The Canvas object that belongs to this CanvasRenderTarget. */
  get canvas() {
    return this._checkDestroyed(), this._canvas;
  }
  /** A CanvasRenderingContext2D object representing a two-dimensional rendering context. */
  get context() {
    return this._checkDestroyed(), this._context;
  }
  _checkDestroyed() {
    if (this._canvas === null)
      throw new TypeError("The CanvasRenderTarget has already been destroyed");
  }
}
function xf(r, e, t) {
  for (let i = 0, n = 4 * t * e; i < e; ++i, n += 4)
    if (r[n + 3] !== 0)
      return !1;
  return !0;
}
function Ef(r, e, t, i, n) {
  const s = 4 * e;
  for (let o = i, a = i * s + 4 * t; o <= n; ++o, a += s)
    if (r[a + 3] !== 0)
      return !1;
  return !0;
}
function IA(r) {
  const { width: e, height: t } = r, i = r.getContext("2d", {
    willReadFrequently: !0
  });
  if (i === null)
    throw new TypeError("Failed to get canvas 2D context");
  const n = i.getImageData(0, 0, e, t).data;
  let s = 0, o = 0, a = e - 1, l = t - 1;
  for (; o < t && xf(n, e, o); )
    ++o;
  if (o === t)
    return bf.EMPTY;
  for (; xf(n, e, l); )
    --l;
  for (; Ef(n, e, s, o, l); )
    ++s;
  for (; Ef(n, e, a, o, l); )
    --a;
  return ++a, ++l, new bf(s, o, a, l);
}
function RA(r) {
  const e = IA(r), { width: t, height: i } = e;
  let n = null;
  if (!e.isEmpty()) {
    const s = r.getContext("2d");
    if (s === null)
      throw new TypeError("Failed to get canvas 2D context");
    n = s.getImageData(
      e.left,
      e.top,
      t,
      i
    );
  }
  return { width: t, height: i, data: n };
}
function PA(r, e = globalThis.location) {
  if (r.startsWith("data:"))
    return "";
  e = e || globalThis.location;
  const t = new URL(r, document.baseURI);
  return t.hostname !== e.hostname || t.port !== e.port || t.protocol !== e.protocol ? "anonymous" : "";
}
function Di(r, e = 1) {
  var i;
  const t = (i = Z.RETINA_PREFIX) == null ? void 0 : i.exec(r);
  return t ? parseFloat(t[1]) : e;
}
var q = /* @__PURE__ */ ((r) => (r.Renderer = "renderer", r.Application = "application", r.RendererSystem = "renderer-webgl-system", r.RendererPlugin = "renderer-webgl-plugin", r.CanvasRendererSystem = "renderer-canvas-system", r.CanvasRendererPlugin = "renderer-canvas-plugin", r.Asset = "asset", r.LoadParser = "load-parser", r.ResolveParser = "resolve-parser", r.CacheParser = "cache-parser", r.DetectionParser = "detection-parser", r))(q || {});
const Qh = (r) => {
  if (typeof r == "function" || typeof r == "object" && r.extension) {
    if (!r.extension)
      throw new Error("Extension class must have an extension object");
    r = { ...typeof r.extension != "object" ? { type: r.extension } : r.extension, ref: r };
  }
  if (typeof r == "object")
    r = { ...r };
  else
    throw new Error("Invalid extension type");
  return typeof r.type == "string" && (r.type = [r.type]), r;
}, Tf = (r, e) => Qh(r).priority ?? e, Q = {
  /** @ignore */
  _addHandlers: {},
  /** @ignore */
  _removeHandlers: {},
  /** @ignore */
  _queue: {},
  /**
   * Remove extensions from PixiJS.
   * @param extensions - Extensions to be removed.
   * @returns {PIXI.extensions} For chaining.
   */
  remove(...r) {
    return r.map(Qh).forEach((e) => {
      e.type.forEach((t) => {
        var i, n;
        return (n = (i = this._removeHandlers)[t]) == null ? void 0 : n.call(i, e);
      });
    }), this;
  },
  /**
   * Register new extensions with PixiJS.
   * @param extensions - The spread of extensions to add to PixiJS.
   * @returns {PIXI.extensions} For chaining.
   */
  add(...r) {
    return r.map(Qh).forEach((e) => {
      e.type.forEach((t) => {
        var s, o;
        const i = this._addHandlers, n = this._queue;
        i[t] ? (s = i[t]) == null || s.call(i, e) : (n[t] = n[t] || [], (o = n[t]) == null || o.push(e));
      });
    }), this;
  },
  /**
   * Internal method to handle extensions by name.
   * @param type - The extension type.
   * @param onAdd  - Function for handling when extensions are added/registered passes {@link PIXI.ExtensionFormat}.
   * @param onRemove  - Function for handling when extensions are removed/unregistered passes {@link PIXI.ExtensionFormat}.
   * @returns {PIXI.extensions} For chaining.
   */
  handle(r, e, t) {
    var o;
    const i = this._addHandlers, n = this._removeHandlers;
    if (i[r] || n[r])
      throw new Error(`Extension type ${r} already has a handler`);
    i[r] = e, n[r] = t;
    const s = this._queue;
    return s[r] && ((o = s[r]) == null || o.forEach((a) => e(a)), delete s[r]), this;
  },
  /**
   * Handle a type, but using a map by `name` property.
   * @param type - Type of extension to handle.
   * @param map - The object map of named extensions.
   * @returns {PIXI.extensions} For chaining.
   */
  handleByMap(r, e) {
    return this.handle(
      r,
      (t) => {
        t.name && (e[t.name] = t.ref);
      },
      (t) => {
        t.name && delete e[t.name];
      }
    );
  },
  /**
   * Handle a type, but using a list of extensions.
   * @param type - Type of extension to handle.
   * @param list - The list of extensions.
   * @param defaultPriority - The default priority to use if none is specified.
   * @returns {PIXI.extensions} For chaining.
   */
  handleByList(r, e, t = -1) {
    return this.handle(
      r,
      (i) => {
        e.includes(i.ref) || (e.push(i.ref), e.sort((n, s) => Tf(s, t) - Tf(n, t)));
      },
      (i) => {
        const n = e.indexOf(i.ref);
        n !== -1 && e.splice(n, 1);
      }
    );
  }
};
class ec {
  constructor(e) {
    typeof e == "number" ? this.rawBinaryData = new ArrayBuffer(e) : e instanceof Uint8Array ? this.rawBinaryData = e.buffer : this.rawBinaryData = e, this.uint32View = new Uint32Array(this.rawBinaryData), this.float32View = new Float32Array(this.rawBinaryData);
  }
  /** View on the raw binary data as a `Int8Array`. */
  get int8View() {
    return this._int8View || (this._int8View = new Int8Array(this.rawBinaryData)), this._int8View;
  }
  /** View on the raw binary data as a `Uint8Array`. */
  get uint8View() {
    return this._uint8View || (this._uint8View = new Uint8Array(this.rawBinaryData)), this._uint8View;
  }
  /**  View on the raw binary data as a `Int16Array`. */
  get int16View() {
    return this._int16View || (this._int16View = new Int16Array(this.rawBinaryData)), this._int16View;
  }
  /** View on the raw binary data as a `Uint16Array`. */
  get uint16View() {
    return this._uint16View || (this._uint16View = new Uint16Array(this.rawBinaryData)), this._uint16View;
  }
  /** View on the raw binary data as a `Int32Array`. */
  get int32View() {
    return this._int32View || (this._int32View = new Int32Array(this.rawBinaryData)), this._int32View;
  }
  /**
   * Returns the view of the given type.
   * @param type - One of `int8`, `uint8`, `int16`,
   *    `uint16`, `int32`, `uint32`, and `float32`.
   * @returns - typed array of given type
   */
  view(e) {
    return this[`${e}View`];
  }
  /** Destroys all buffer references. Do not use after calling this. */
  destroy() {
    this.rawBinaryData = null, this._int8View = null, this._uint8View = null, this._int16View = null, this._uint16View = null, this._int32View = null, this.uint32View = null, this.float32View = null;
  }
  static sizeOf(e) {
    switch (e) {
      case "int8":
      case "uint8":
        return 1;
      case "int16":
      case "uint16":
        return 2;
      case "int32":
      case "uint32":
      case "float32":
        return 4;
      default:
        throw new Error(`${e} isn't a valid view type`);
    }
  }
}
const MA = [
  "precision mediump float;",
  "void main(void){",
  "float test = 0.1;",
  "%forloop%",
  "gl_FragColor = vec4(0.0);",
  "}"
].join(`
`);
function kA(r) {
  let e = "";
  for (let t = 0; t < r; ++t)
    t > 0 && (e += `
else `), t < r - 1 && (e += `if(test == ${t}.0){}`);
  return e;
}
function DA(r, e) {
  if (r === 0)
    throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");
  const t = e.createShader(e.FRAGMENT_SHADER);
  for (; ; ) {
    const i = MA.replace(/%forloop%/gi, kA(r));
    if (e.shaderSource(t, i), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS))
      r = r / 2 | 0;
    else
      break;
  }
  return r;
}
const Vl = 0, Wl = 1, jl = 2, ql = 3, Yl = 4, Kl = 5;
class yi {
  constructor() {
    this.data = 0, this.blendMode = oe.NORMAL, this.polygonOffset = 0, this.blend = !0, this.depthMask = !0;
  }
  /**
   * Activates blending of the computed fragment color values.
   * @default true
   */
  get blend() {
    return !!(this.data & 1 << Vl);
  }
  set blend(e) {
    !!(this.data & 1 << Vl) !== e && (this.data ^= 1 << Vl);
  }
  /**
   * Activates adding an offset to depth values of polygon's fragments
   * @default false
   */
  get offsets() {
    return !!(this.data & 1 << Wl);
  }
  set offsets(e) {
    !!(this.data & 1 << Wl) !== e && (this.data ^= 1 << Wl);
  }
  /**
   * Activates culling of polygons.
   * @default false
   */
  get culling() {
    return !!(this.data & 1 << jl);
  }
  set culling(e) {
    !!(this.data & 1 << jl) !== e && (this.data ^= 1 << jl);
  }
  /**
   * Activates depth comparisons and updates to the depth buffer.
   * @default false
   */
  get depthTest() {
    return !!(this.data & 1 << ql);
  }
  set depthTest(e) {
    !!(this.data & 1 << ql) !== e && (this.data ^= 1 << ql);
  }
  /**
   * Enables or disables writing to the depth buffer.
   * @default true
   */
  get depthMask() {
    return !!(this.data & 1 << Kl);
  }
  set depthMask(e) {
    !!(this.data & 1 << Kl) !== e && (this.data ^= 1 << Kl);
  }
  /**
   * Specifies whether or not front or back-facing polygons can be culled.
   * @default false
   */
  get clockwiseFrontFace() {
    return !!(this.data & 1 << Yl);
  }
  set clockwiseFrontFace(e) {
    !!(this.data & 1 << Yl) !== e && (this.data ^= 1 << Yl);
  }
  /**
   * The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.
   * Setting this mode to anything other than NO_BLEND will automatically switch blending on.
   * @default PIXI.BLEND_MODES.NORMAL
   */
  get blendMode() {
    return this._blendMode;
  }
  set blendMode(e) {
    this.blend = e !== oe.NONE, this._blendMode = e;
  }
  /**
   * The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.
   * @default 0
   */
  get polygonOffset() {
    return this._polygonOffset;
  }
  set polygonOffset(e) {
    this.offsets = !!e, this._polygonOffset = e;
  }
  static for2d() {
    const e = new yi();
    return e.depthTest = !1, e.blend = !0, e;
  }
}
yi.prototype.toString = function() {
  return `[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
};
const tc = [];
function xm(r, e) {
  if (!r)
    return null;
  let t = "";
  if (typeof r == "string") {
    const i = /\.(\w{3,4})(?:$|\?|#)/i.exec(r);
    i && (t = i[1].toLowerCase());
  }
  for (let i = tc.length - 1; i >= 0; --i) {
    const n = tc[i];
    if (n.test && n.test(r, t))
      return new n(r, e);
  }
  throw new Error("Unrecognized source type to auto-detect Resource");
}
class $t {
  /**
   * @param {string} name - The function name that will be executed on the listeners added to this Runner.
   */
  constructor(e) {
    this.items = [], this._name = e, this._aliasCount = 0;
  }
  /* eslint-disable jsdoc/require-param, jsdoc/check-param-names */
  /**
   * Dispatch/Broadcast Runner to all listeners added to the queue.
   * @param {...any} params - (optional) parameters to pass to each listener
   */
  /*  eslint-enable jsdoc/require-param, jsdoc/check-param-names */
  emit(e, t, i, n, s, o, a, l) {
    if (arguments.length > 8)
      throw new Error("max arguments reached");
    const { name: h, items: c } = this;
    this._aliasCount++;
    for (let u = 0, d = c.length; u < d; u++)
      c[u][h](e, t, i, n, s, o, a, l);
    return c === this.items && this._aliasCount--, this;
  }
  ensureNonAliasedItems() {
    this._aliasCount > 0 && this.items.length > 1 && (this._aliasCount = 0, this.items = this.items.slice(0));
  }
  /**
   * Add a listener to the Runner
   *
   * Runners do not need to have scope or functions passed to them.
   * All that is required is to pass the listening object and ensure that it has contains a function that has the same name
   * as the name provided to the Runner when it was created.
   *
   * E.g. A listener passed to this Runner will require a 'complete' function.
   *
   * ```js
   * import { Runner } from '@pixi/runner';
   *
   * const complete = new Runner('complete');
   * ```
   *
   * The scope used will be the object itself.
   * @param {any} item - The object that will be listening.
   */
  add(e) {
    return e[this._name] && (this.ensureNonAliasedItems(), this.remove(e), this.items.push(e)), this;
  }
  /**
   * Remove a single listener from the dispatch queue.
   * @param {any} item - The listener that you would like to remove.
   */
  remove(e) {
    const t = this.items.indexOf(e);
    return t !== -1 && (this.ensureNonAliasedItems(), this.items.splice(t, 1)), this;
  }
  /**
   * Check to see if the listener is already in the Runner
   * @param {any} item - The listener that you would like to check.
   */
  contains(e) {
    return this.items.includes(e);
  }
  /** Remove all listeners from the Runner */
  removeAll() {
    return this.ensureNonAliasedItems(), this.items.length = 0, this;
  }
  /** Remove all references, don't use after this. */
  destroy() {
    this.removeAll(), this.items.length = 0, this._name = "";
  }
  /**
   * `true` if there are no this Runner contains no listeners
   * @readonly
   */
  get empty() {
    return this.items.length === 0;
  }
  /**
   * The name of the runner.
   * @type {string}
   */
  get name() {
    return this._name;
  }
}
Object.defineProperties($t.prototype, {
  /**
   * Alias for `emit`
   * @memberof PIXI.Runner#
   * @method dispatch
   * @see PIXI.Runner#emit
   */
  dispatch: { value: $t.prototype.emit },
  /**
   * Alias for `emit`
   * @memberof PIXI.Runner#
   * @method run
   * @see PIXI.Runner#emit
   */
  run: { value: $t.prototype.emit }
});
class Ds {
  /**
   * @param width - Width of the resource
   * @param height - Height of the resource
   */
  constructor(e = 0, t = 0) {
    this._width = e, this._height = t, this.destroyed = !1, this.internal = !1, this.onResize = new $t("setRealSize"), this.onUpdate = new $t("update"), this.onError = new $t("onError");
  }
  /**
   * Bind to a parent BaseTexture
   * @param baseTexture - Parent texture
   */
  bind(e) {
    this.onResize.add(e), this.onUpdate.add(e), this.onError.add(e), (this._width || this._height) && this.onResize.emit(this._width, this._height);
  }
  /**
   * Unbind to a parent BaseTexture
   * @param baseTexture - Parent texture
   */
  unbind(e) {
    this.onResize.remove(e), this.onUpdate.remove(e), this.onError.remove(e);
  }
  /**
   * Trigger a resize event
   * @param width - X dimension
   * @param height - Y dimension
   */
  resize(e, t) {
    (e !== this._width || t !== this._height) && (this._width = e, this._height = t, this.onResize.emit(e, t));
  }
  /**
   * Has been validated
   * @readonly
   */
  get valid() {
    return !!this._width && !!this._height;
  }
  /** Has been updated trigger event. */
  update() {
    this.destroyed || this.onUpdate.emit();
  }
  /**
   * This can be overridden to start preloading a resource
   * or do any other prepare step.
   * @protected
   * @returns Handle the validate event
   */
  load() {
    return Promise.resolve(this);
  }
  /**
   * The width of the resource.
   * @readonly
   */
  get width() {
    return this._width;
  }
  /**
   * The height of the resource.
   * @readonly
   */
  get height() {
    return this._height;
  }
  /**
   * Set the style, optional to override
   * @param _renderer - yeah, renderer!
   * @param _baseTexture - the texture
   * @param _glTexture - texture instance for this webgl context
   * @returns - `true` is success
   */
  style(e, t, i) {
    return !1;
  }
  /** Clean up anything, this happens when destroying is ready. */
  dispose() {
  }
  /**
   * Call when destroying resource, unbind any BaseTexture object
   * before calling this method, as reference counts are maintained
   * internally.
   */
  destroy() {
    this.destroyed || (this.destroyed = !0, this.dispose(), this.onError.removeAll(), this.onError = null, this.onResize.removeAll(), this.onResize = null, this.onUpdate.removeAll(), this.onUpdate = null);
  }
  /**
   * Abstract, used to auto-detect resource type.
   * @param {*} _source - The source object
   * @param {string} _extension - The extension of source, if set
   */
  static test(e, t) {
    return !1;
  }
}
class Ma extends Ds {
  /**
   * @param source - Source buffer
   * @param options - Options
   * @param {number} options.width - Width of the texture
   * @param {number} options.height - Height of the texture
   * @param {1|2|4|8} [options.unpackAlignment=4] - The alignment of the pixel rows.
   */
  constructor(e, t) {
    const { width: i, height: n } = t || {};
    if (!i || !n)
      throw new Error("BufferResource width or height invalid");
    super(i, n), this.data = e, this.unpackAlignment = t.unpackAlignment ?? 4;
  }
  /**
   * Upload the texture to the GPU.
   * @param renderer - Upload to the renderer
   * @param baseTexture - Reference to parent texture
   * @param glTexture - glTexture
   * @returns - true is success
   */
  upload(e, t, i) {
    const n = e.gl;
    n.pixelStorei(n.UNPACK_ALIGNMENT, this.unpackAlignment), n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.alphaMode === ut.UNPACK);
    const s = t.realWidth, o = t.realHeight;
    return i.width === s && i.height === o ? n.texSubImage2D(
      t.target,
      0,
      0,
      0,
      s,
      o,
      t.format,
      i.type,
      this.data
    ) : (i.width = s, i.height = o, n.texImage2D(
      t.target,
      0,
      i.internalFormat,
      s,
      o,
      0,
      t.format,
      i.type,
      this.data
    )), !0;
  }
  /** Destroy and don't use after this. */
  dispose() {
    this.data = null;
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if buffer source
   */
  static test(e) {
    return e === null || e instanceof Int8Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray || e instanceof Int16Array || e instanceof Uint16Array || e instanceof Int32Array || e instanceof Uint32Array || e instanceof Float32Array;
  }
}
const BA = {
  scaleMode: Ai.NEAREST,
  alphaMode: ut.NPM
}, ic = class fn extends Fs {
  /**
   * @param {PIXI.Resource|PIXI.ImageSource|string} [resource=null] -
   *        The current resource to use, for things that aren't Resource objects, will be converted
   *        into a Resource.
   * @param options - Collection of options, default options inherited from {@link PIXI.BaseTexture.defaultOptions}.
   * @param {PIXI.MIPMAP_MODES} [options.mipmap] - If mipmapping is enabled for texture
   * @param {number} [options.anisotropicLevel] - Anisotropic filtering level of texture
   * @param {PIXI.WRAP_MODES} [options.wrapMode] - Wrap mode for textures
   * @param {PIXI.SCALE_MODES} [options.scaleMode] - Default scale mode, linear, nearest
   * @param {PIXI.FORMATS} [options.format] - GL format type
   * @param {PIXI.TYPES} [options.type] - GL data type
   * @param {PIXI.TARGETS} [options.target] - GL texture target
   * @param {PIXI.ALPHA_MODES} [options.alphaMode] - Pre multiply the image alpha
   * @param {number} [options.width=0] - Width of the texture
   * @param {number} [options.height=0] - Height of the texture
   * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - Resolution of the base texture
   * @param {object} [options.resourceOptions] - Optional resource options,
   *        see {@link PIXI.autoDetectResource autoDetectResource}
   */
  constructor(e = null, t = null) {
    super(), t = Object.assign({}, fn.defaultOptions, t);
    const {
      alphaMode: i,
      mipmap: n,
      anisotropicLevel: s,
      scaleMode: o,
      width: a,
      height: l,
      wrapMode: h,
      format: c,
      type: u,
      target: d,
      resolution: f,
      resourceOptions: p
    } = t;
    e && !(e instanceof Ds) && (e = xm(e, p), e.internal = !0), this.resolution = f || Z.RESOLUTION, this.width = Math.round((a || 0) * this.resolution) / this.resolution, this.height = Math.round((l || 0) * this.resolution) / this.resolution, this._mipmap = n, this.anisotropicLevel = s, this._wrapMode = h, this._scaleMode = o, this.format = c, this.type = u, this.target = d, this.alphaMode = i, this.uid = Hr(), this.touched = 0, this.isPowerOfTwo = !1, this._refreshPOT(), this._glTextures = {}, this.dirtyId = 0, this.dirtyStyleId = 0, this.cacheId = null, this.valid = a > 0 && l > 0, this.textureCacheIds = [], this.destroyed = !1, this.resource = null, this._batchEnabled = 0, this._batchLocation = 0, this.parentTextureArray = null, this.setResource(e);
  }
  /**
   * Pixel width of the source of this texture
   * @readonly
   */
  get realWidth() {
    return Math.round(this.width * this.resolution);
  }
  /**
   * Pixel height of the source of this texture
   * @readonly
   */
  get realHeight() {
    return Math.round(this.height * this.resolution);
  }
  /**
   * Mipmap mode of the texture, affects downscaled images
   * @default PIXI.MIPMAP_MODES.POW2
   */
  get mipmap() {
    return this._mipmap;
  }
  set mipmap(e) {
    this._mipmap !== e && (this._mipmap = e, this.dirtyStyleId++);
  }
  /**
   * The scale mode to apply when scaling this texture
   * @default PIXI.SCALE_MODES.LINEAR
   */
  get scaleMode() {
    return this._scaleMode;
  }
  set scaleMode(e) {
    this._scaleMode !== e && (this._scaleMode = e, this.dirtyStyleId++);
  }
  /**
   * How the texture wraps
   * @default PIXI.WRAP_MODES.CLAMP
   */
  get wrapMode() {
    return this._wrapMode;
  }
  set wrapMode(e) {
    this._wrapMode !== e && (this._wrapMode = e, this.dirtyStyleId++);
  }
  /**
   * Changes style options of BaseTexture
   * @param scaleMode - Pixi scalemode
   * @param mipmap - enable mipmaps
   * @returns - this
   */
  setStyle(e, t) {
    let i;
    return e !== void 0 && e !== this.scaleMode && (this.scaleMode = e, i = !0), t !== void 0 && t !== this.mipmap && (this.mipmap = t, i = !0), i && this.dirtyStyleId++, this;
  }
  /**
   * Changes w/h/resolution. Texture becomes valid if width and height are greater than zero.
   * @param desiredWidth - Desired visual width
   * @param desiredHeight - Desired visual height
   * @param resolution - Optionally set resolution
   * @returns - this
   */
  setSize(e, t, i) {
    return i = i || this.resolution, this.setRealSize(e * i, t * i, i);
  }
  /**
   * Sets real size of baseTexture, preserves current resolution.
   * @param realWidth - Full rendered width
   * @param realHeight - Full rendered height
   * @param resolution - Optionally set resolution
   * @returns - this
   */
  setRealSize(e, t, i) {
    return this.resolution = i || this.resolution, this.width = Math.round(e) / this.resolution, this.height = Math.round(t) / this.resolution, this._refreshPOT(), this.update(), this;
  }
  /**
   * Refresh check for isPowerOfTwo texture based on size
   * @private
   */
  _refreshPOT() {
    this.isPowerOfTwo = yf(this.realWidth) && yf(this.realHeight);
  }
  /**
   * Changes resolution
   * @param resolution - res
   * @returns - this
   */
  setResolution(e) {
    const t = this.resolution;
    return t === e ? this : (this.resolution = e, this.valid && (this.width = Math.round(this.width * t) / e, this.height = Math.round(this.height * t) / e, this.emit("update", this)), this._refreshPOT(), this);
  }
  /**
   * Sets the resource if it wasn't set. Throws error if resource already present
   * @param resource - that is managing this BaseTexture
   * @returns - this
   */
  setResource(e) {
    if (this.resource === e)
      return this;
    if (this.resource)
      throw new Error("Resource can be set only once");
    return e.bind(this), this.resource = e, this;
  }
  /** Invalidates the object. Texture becomes valid if width and height are greater than zero. */
  update() {
    this.valid ? (this.dirtyId++, this.dirtyStyleId++, this.emit("update", this)) : this.width > 0 && this.height > 0 && (this.valid = !0, this.emit("loaded", this), this.emit("update", this));
  }
  /**
   * Handle errors with resources.
   * @private
   * @param event - Error event emitted.
   */
  onError(e) {
    this.emit("error", this, e);
  }
  /**
   * Destroys this base texture.
   * The method stops if resource doesn't want this texture to be destroyed.
   * Removes texture from all caches.
   * @fires PIXI.BaseTexture#destroyed
   */
  destroy() {
    this.resource && (this.resource.unbind(this), this.resource.internal && this.resource.destroy(), this.resource = null), this.cacheId && (delete Hi[this.cacheId], delete si[this.cacheId], this.cacheId = null), this.valid = !1, this.dispose(), fn.removeFromCache(this), this.textureCacheIds = null, this.destroyed = !0, this.emit("destroyed", this), this.removeAllListeners();
  }
  /**
   * Frees the texture from WebGL memory without destroying this texture object.
   * This means you can still use the texture later which will upload it to GPU
   * memory again.
   * @fires PIXI.BaseTexture#dispose
   */
  dispose() {
    this.emit("dispose", this);
  }
  /** Utility function for BaseTexture|Texture cast. */
  castToBaseTexture() {
    return this;
  }
  /**
   * Helper function that creates a base texture based on the source you provide.
   * The source can be - image url, image element, canvas element. If the
   * source is an image url or an image element and not in the base texture
   * cache, it will be created and loaded.
   * @static
   * @param {PIXI.ImageSource|string|string[]} source - The
   *        source to create base texture from.
   * @param options - See {@link PIXI.BaseTexture}'s constructor for options.
   * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id
   * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}.
   * @returns {PIXI.BaseTexture} The new base texture.
   */
  static from(e, t, i = Z.STRICT_TEXTURE_CACHE) {
    const n = typeof e == "string";
    let s = null;
    if (n)
      s = e;
    else {
      if (!e._pixiId) {
        const a = (t == null ? void 0 : t.pixiIdPrefix) || "pixiid";
        e._pixiId = `${a}_${Hr()}`;
      }
      s = e._pixiId;
    }
    let o = Hi[s];
    if (n && i && !o)
      throw new Error(`The cacheId "${s}" does not exist in BaseTextureCache.`);
    return o || (o = new fn(e, t), o.cacheId = s, fn.addToCache(o, s)), o;
  }
  /**
   * Create a new Texture with a BufferResource from a typed array.
   * @param buffer - The optional array to use. If no data is provided, a new Float32Array is created.
   * @param width - Width of the resource
   * @param height - Height of the resource
   * @param options - See {@link PIXI.BaseTexture}'s constructor for options.
   *        Default properties are different from the constructor's defaults.
   * @param {PIXI.FORMATS} [options.format] - The format is not given, the type is inferred from the
   *        type of the buffer: `RGBA` if Float32Array, Int8Array, Uint8Array, or Uint8ClampedArray,
   *        otherwise `RGBA_INTEGER`.
   * @param {PIXI.TYPES} [options.type] - The type is not given, the type is inferred from the
   *        type of the buffer. Maps Float32Array to `FLOAT`, Int32Array to `INT`, Uint32Array to
   *        `UNSIGNED_INT`, Int16Array to `SHORT`, Uint16Array to `UNSIGNED_SHORT`, Int8Array to `BYTE`,
   *        Uint8Array/Uint8ClampedArray to `UNSIGNED_BYTE`.
   * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.NPM]
   * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.SCALE_MODES.NEAREST]
   * @returns - The resulting new BaseTexture
   */
  static fromBuffer(e, t, i, n) {
    e = e || new Float32Array(t * i * 4);
    const s = new Ma(e, { width: t, height: i, ...n == null ? void 0 : n.resourceOptions });
    let o, a;
    return e instanceof Float32Array ? (o = G.RGBA, a = re.FLOAT) : e instanceof Int32Array ? (o = G.RGBA_INTEGER, a = re.INT) : e instanceof Uint32Array ? (o = G.RGBA_INTEGER, a = re.UNSIGNED_INT) : e instanceof Int16Array ? (o = G.RGBA_INTEGER, a = re.SHORT) : e instanceof Uint16Array ? (o = G.RGBA_INTEGER, a = re.UNSIGNED_SHORT) : e instanceof Int8Array ? (o = G.RGBA, a = re.BYTE) : (o = G.RGBA, a = re.UNSIGNED_BYTE), s.internal = !0, new fn(s, Object.assign({}, BA, { type: a, format: o }, n));
  }
  /**
   * Adds a BaseTexture to the global BaseTextureCache. This cache is shared across the whole PIXI object.
   * @param {PIXI.BaseTexture} baseTexture - The BaseTexture to add to the cache.
   * @param {string} id - The id that the BaseTexture will be stored against.
   */
  static addToCache(e, t) {
    t && (e.textureCacheIds.includes(t) || e.textureCacheIds.push(t), Hi[t] && Hi[t] !== e && console.warn(`BaseTexture added to the cache with an id [${t}] that already had an entry`), Hi[t] = e);
  }
  /**
   * Remove a BaseTexture from the global BaseTextureCache.
   * @param {string|PIXI.BaseTexture} baseTexture - id of a BaseTexture to be removed, or a BaseTexture instance itself.
   * @returns {PIXI.BaseTexture|null} The BaseTexture that was removed.
   */
  static removeFromCache(e) {
    if (typeof e == "string") {
      const t = Hi[e];
      if (t) {
        const i = t.textureCacheIds.indexOf(e);
        return i > -1 && t.textureCacheIds.splice(i, 1), delete Hi[e], t;
      }
    } else if (e != null && e.textureCacheIds) {
      for (let t = 0; t < e.textureCacheIds.length; ++t)
        delete Hi[e.textureCacheIds[t]];
      return e.textureCacheIds.length = 0, e;
    }
    return null;
  }
};
ic.defaultOptions = {
  /**
   * If mipmapping is enabled for texture.
   * @type {PIXI.MIPMAP_MODES}
   * @default PIXI.MIPMAP_MODES.POW2
   */
  mipmap: gi.POW2,
  /** Anisotropic filtering level of texture */
  anisotropicLevel: 0,
  /**
   * Default scale mode, linear, nearest.
   * @type {PIXI.SCALE_MODES}
   * @default PIXI.SCALE_MODES.LINEAR
   */
  scaleMode: Ai.LINEAR,
  /**
   * Wrap mode for textures.
   * @type {PIXI.WRAP_MODES}
   * @default PIXI.WRAP_MODES.CLAMP
   */
  wrapMode: tr.CLAMP,
  /**
   * Pre multiply the image alpha
   * @type {PIXI.ALPHA_MODES}
   * @default PIXI.ALPHA_MODES.UNPACK
   */
  alphaMode: ut.UNPACK,
  /**
   * GL texture target
   * @type {PIXI.TARGETS}
   * @default PIXI.TARGETS.TEXTURE_2D
   */
  target: Tn.TEXTURE_2D,
  /**
   * GL format type
   * @type {PIXI.FORMATS}
   * @default PIXI.FORMATS.RGBA
   */
  format: G.RGBA,
  /**
   * GL data type
   * @type {PIXI.TYPES}
   * @default PIXI.TYPES.UNSIGNED_BYTE
   */
  type: re.UNSIGNED_BYTE
}, /** Global number of the texture batch, used by multi-texture renderers. */
ic._globalBatch = 0;
let ae = ic;
class rc {
  constructor() {
    this.texArray = null, this.blend = 0, this.type = pi.TRIANGLES, this.start = 0, this.size = 0, this.data = null;
  }
}
let FA = 0;
class Be {
  /**
   * @param {PIXI.IArrayBuffer} data - the data to store in the buffer.
   * @param _static - `true` for static buffer
   * @param index - `true` for index buffer
   */
  constructor(e, t = !0, i = !1) {
    this.data = e || new Float32Array(1), this._glBuffers = {}, this._updateID = 0, this.index = i, this.static = t, this.id = FA++, this.disposeRunner = new $t("disposeBuffer");
  }
  // TODO could explore flagging only a partial upload?
  /**
   * Flags this buffer as requiring an upload to the GPU.
   * @param {PIXI.IArrayBuffer|number[]} [data] - the data to update in the buffer.
   */
  update(e) {
    e instanceof Array && (e = new Float32Array(e)), this.data = e || this.data, this._updateID++;
  }
  /** Disposes WebGL resources that are connected to this geometry. */
  dispose() {
    this.disposeRunner.emit(this, !1);
  }
  /** Destroys the buffer. */
  destroy() {
    this.dispose(), this.data = null;
  }
  /**
   * Flags whether this is an index buffer.
   *
   * Index buffers are of type `ELEMENT_ARRAY_BUFFER`. Note that setting this property to false will make
   * the buffer of type `ARRAY_BUFFER`.
   *
   * For backwards compatibility.
   */
  set index(e) {
    this.type = e ? _i.ELEMENT_ARRAY_BUFFER : _i.ARRAY_BUFFER;
  }
  get index() {
    return this.type === _i.ELEMENT_ARRAY_BUFFER;
  }
  /**
   * Helper function that creates a buffer based on an array or TypedArray
   * @param {ArrayBufferView | number[]} data - the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array.
   * @returns - A new Buffer based on the data provided.
   */
  static from(e) {
    return e instanceof Array && (e = new Float32Array(e)), new Be(e);
  }
}
class sa {
  /**
   * @param buffer - the id of the buffer that this attribute will look for
   * @param size - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2.
   * @param normalized - should the data be normalized.
   * @param {PIXI.TYPES} [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {@link PIXI.TYPES} to see the ones available
   * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)
   * @param [start=0] - How far into the array to start reading values (used for interleaving data)
   * @param [instance=false] - Whether the geometry is instanced.
   * @param [divisor=1] - Divisor to use when doing instanced rendering
   */
  constructor(e, t = 0, i = !1, n = re.FLOAT, s, o, a, l = 1) {
    this.buffer = e, this.size = t, this.normalized = i, this.type = n, this.stride = s, this.start = o, this.instance = a, this.divisor = l;
  }
  /** Destroys the Attribute. */
  destroy() {
    this.buffer = null;
  }
  /**
   * Helper function that creates an Attribute based on the information provided
   * @param buffer - the id of the buffer that this attribute will look for
   * @param [size=0] - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2
   * @param [normalized=false] - should the data be normalized.
   * @param [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {@link PIXI.TYPES} to see the ones available
   * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)
   * @returns - A new {@link PIXI.Attribute} based on the information provided
   */
  static from(e, t, i, n, s) {
    return new sa(e, t, i, n, s);
  }
}
const OA = {
  Float32Array,
  Uint32Array,
  Int32Array,
  Uint8Array
};
function LA(r, e) {
  let t = 0, i = 0;
  const n = {};
  for (let l = 0; l < r.length; l++)
    i += e[l], t += r[l].length;
  const s = new ArrayBuffer(t * 4);
  let o = null, a = 0;
  for (let l = 0; l < r.length; l++) {
    const h = e[l], c = r[l], u = wm(c);
    n[u] || (n[u] = new OA[u](s)), o = n[u];
    for (let d = 0; d < c.length; d++) {
      const f = (d / h | 0) * i + a, p = d % h;
      o[f + p] = c[d];
    }
    a += h;
  }
  return new Float32Array(s);
}
const Af = { 5126: 4, 5123: 2, 5121: 1 };
let NA = 0;
const UA = {
  Float32Array,
  Uint32Array,
  Int32Array,
  Uint8Array,
  Uint16Array
};
class ir {
  /**
   * @param buffers - An array of buffers. optional.
   * @param attributes - Of the geometry, optional structure of the attributes layout
   */
  constructor(e = [], t = {}) {
    this.buffers = e, this.indexBuffer = null, this.attributes = t, this.glVertexArrayObjects = {}, this.id = NA++, this.instanced = !1, this.instanceCount = 1, this.disposeRunner = new $t("disposeGeometry"), this.refCount = 0;
  }
  /**
   *
   * Adds an attribute to the geometry
   * Note: `stride` and `start` should be `undefined` if you dont know them, not 0!
   * @param id - the name of the attribute (matching up to a shader)
   * @param {PIXI.Buffer|number[]} buffer - the buffer that holds the data of the attribute . You can also provide an Array and a buffer will be created from it.
   * @param size - the size of the attribute. If you have 2 floats per vertex (eg position x and y) this would be 2
   * @param normalized - should the data be normalized.
   * @param [type=PIXI.TYPES.FLOAT] - what type of number is the attribute. Check {@link PIXI.TYPES} to see the ones available
   * @param [stride=0] - How far apart, in bytes, the start of each value is. (used for interleaving data)
   * @param [start=0] - How far into the array to start reading values (used for interleaving data)
   * @param instance - Instancing flag
   * @returns - Returns self, useful for chaining.
   */
  addAttribute(e, t, i = 0, n = !1, s, o, a, l = !1) {
    if (!t)
      throw new Error("You must pass a buffer when creating an attribute");
    t instanceof Be || (t instanceof Array && (t = new Float32Array(t)), t = new Be(t));
    const h = e.split("|");
    if (h.length > 1) {
      for (let u = 0; u < h.length; u++)
        this.addAttribute(h[u], t, i, n, s);
      return this;
    }
    let c = this.buffers.indexOf(t);
    return c === -1 && (this.buffers.push(t), c = this.buffers.length - 1), this.attributes[e] = new sa(c, i, n, s, o, a, l), this.instanced = this.instanced || l, this;
  }
  /**
   * Returns the requested attribute.
   * @param id - The name of the attribute required
   * @returns - The attribute requested.
   */
  getAttribute(e) {
    return this.attributes[e];
  }
  /**
   * Returns the requested buffer.
   * @param id - The name of the buffer required.
   * @returns - The buffer requested.
   */
  getBuffer(e) {
    return this.buffers[this.getAttribute(e).buffer];
  }
  /**
   *
   * Adds an index buffer to the geometry
   * The index buffer contains integers, three for each triangle in the geometry, which reference the various attribute buffers (position, colour, UV coordinates, other UV coordinates, normal, …). There is only ONE index buffer.
   * @param {PIXI.Buffer|number[]} [buffer] - The buffer that holds the data of the index buffer. You can also provide an Array and a buffer will be created from it.
   * @returns - Returns self, useful for chaining.
   */
  addIndex(e) {
    return e instanceof Be || (e instanceof Array && (e = new Uint16Array(e)), e = new Be(e)), e.type = _i.ELEMENT_ARRAY_BUFFER, this.indexBuffer = e, this.buffers.includes(e) || this.buffers.push(e), this;
  }
  /**
   * Returns the index buffer
   * @returns - The index buffer.
   */
  getIndex() {
    return this.indexBuffer;
  }
  /**
   * This function modifies the structure so that all current attributes become interleaved into a single buffer
   * This can be useful if your model remains static as it offers a little performance boost
   * @returns - Returns self, useful for chaining.
   */
  interleave() {
    if (this.buffers.length === 1 || this.buffers.length === 2 && this.indexBuffer)
      return this;
    const e = [], t = [], i = new Be();
    let n;
    for (n in this.attributes) {
      const s = this.attributes[n], o = this.buffers[s.buffer];
      e.push(o.data), t.push(s.size * Af[s.type] / 4), s.buffer = 0;
    }
    for (i.data = LA(e, t), n = 0; n < this.buffers.length; n++)
      this.buffers[n] !== this.indexBuffer && this.buffers[n].destroy();
    return this.buffers = [i], this.indexBuffer && this.buffers.push(this.indexBuffer), this;
  }
  /** Get the size of the geometries, in vertices. */
  getSize() {
    for (const e in this.attributes) {
      const t = this.attributes[e];
      return this.buffers[t.buffer].data.length / (t.stride / 4 || t.size);
    }
    return 0;
  }
  /** Disposes WebGL resources that are connected to this geometry. */
  dispose() {
    this.disposeRunner.emit(this, !1);
  }
  /** Destroys the geometry. */
  destroy() {
    this.dispose(), this.buffers = null, this.indexBuffer = null, this.attributes = null;
  }
  /**
   * Returns a clone of the geometry.
   * @returns - A new clone of this geometry.
   */
  clone() {
    const e = new ir();
    for (let t = 0; t < this.buffers.length; t++)
      e.buffers[t] = new Be(this.buffers[t].data.slice(0));
    for (const t in this.attributes) {
      const i = this.attributes[t];
      e.attributes[t] = new sa(
        i.buffer,
        i.size,
        i.normalized,
        i.type,
        i.stride,
        i.start,
        i.instance
      );
    }
    return this.indexBuffer && (e.indexBuffer = e.buffers[this.buffers.indexOf(this.indexBuffer)], e.indexBuffer.type = _i.ELEMENT_ARRAY_BUFFER), e;
  }
  /**
   * Merges an array of geometries into a new single one.
   *
   * Geometry attribute styles must match for this operation to work.
   * @param geometries - array of geometries to merge
   * @returns - Shiny new geometry!
   */
  static merge(e) {
    const t = new ir(), i = [], n = [], s = [];
    let o;
    for (let a = 0; a < e.length; a++) {
      o = e[a];
      for (let l = 0; l < o.buffers.length; l++)
        n[l] = n[l] || 0, n[l] += o.buffers[l].data.length, s[l] = 0;
    }
    for (let a = 0; a < o.buffers.length; a++)
      i[a] = new UA[wm(o.buffers[a].data)](n[a]), t.buffers[a] = new Be(i[a]);
    for (let a = 0; a < e.length; a++) {
      o = e[a];
      for (let l = 0; l < o.buffers.length; l++)
        i[l].set(o.buffers[l].data, s[l]), s[l] += o.buffers[l].data.length;
    }
    if (t.attributes = o.attributes, o.indexBuffer) {
      t.indexBuffer = t.buffers[o.buffers.indexOf(o.indexBuffer)], t.indexBuffer.type = _i.ELEMENT_ARRAY_BUFFER;
      let a = 0, l = 0, h = 0, c = 0;
      for (let u = 0; u < o.buffers.length; u++)
        if (o.buffers[u] !== o.indexBuffer) {
          c = u;
          break;
        }
      for (const u in o.attributes) {
        const d = o.attributes[u];
        (d.buffer | 0) === c && (l += d.size * Af[d.type] / 4);
      }
      for (let u = 0; u < e.length; u++) {
        const d = e[u].indexBuffer.data;
        for (let f = 0; f < d.length; f++)
          t.indexBuffer.data[f + h] += a;
        a += e[u].buffers[c].data.length / l, h += d.length;
      }
    }
    return t;
  }
}
class Em extends ir {
  /**
   * @param {boolean} [_static=false] - Optimization flag, where `false`
   *        is updated every frame, `true` doesn't change frame-to-frame.
   */
  constructor(e = !1) {
    super(), this._buffer = new Be(null, e, !1), this._indexBuffer = new Be(null, e, !0), this.addAttribute("aVertexPosition", this._buffer, 2, !1, re.FLOAT).addAttribute("aTextureCoord", this._buffer, 2, !1, re.FLOAT).addAttribute("aColor", this._buffer, 4, !0, re.UNSIGNED_BYTE).addAttribute("aTextureId", this._buffer, 1, !0, re.FLOAT).addIndex(this._indexBuffer);
  }
}
const oa = Math.PI * 2, GA = 180 / Math.PI, HA = Math.PI / 180;
var Ye = /* @__PURE__ */ ((r) => (r[r.POLY = 0] = "POLY", r[r.RECT = 1] = "RECT", r[r.CIRC = 2] = "CIRC", r[r.ELIP = 3] = "ELIP", r[r.RREC = 4] = "RREC", r))(Ye || {});
class ge {
  /**
   * Creates a new `Point`
   * @param {number} [x=0] - position of the point on the x axis
   * @param {number} [y=0] - position of the point on the y axis
   */
  constructor(e = 0, t = 0) {
    this.x = 0, this.y = 0, this.x = e, this.y = t;
  }
  /**
   * Creates a clone of this point
   * @returns A clone of this point
   */
  clone() {
    return new ge(this.x, this.y);
  }
  /**
   * Copies `x` and `y` from the given point into this point
   * @param p - The point to copy from
   * @returns The point instance itself
   */
  copyFrom(e) {
    return this.set(e.x, e.y), this;
  }
  /**
   * Copies this point's x and y into the given point (`p`).
   * @param p - The point to copy to. Can be any of type that is or extends `IPointData`
   * @returns The point (`p`) with values updated
   */
  copyTo(e) {
    return e.set(this.x, this.y), e;
  }
  /**
   * Accepts another point (`p`) and returns `true` if the given point is equal to this point
   * @param p - The point to check
   * @returns Returns `true` if both `x` and `y` are equal
   */
  equals(e) {
    return e.x === this.x && e.y === this.y;
  }
  /**
   * Sets the point to a new `x` and `y` position.
   * If `y` is omitted, both `x` and `y` will be set to `x`.
   * @param {number} [x=0] - position of the point on the `x` axis
   * @param {number} [y=x] - position of the point on the `y` axis
   * @returns The point instance itself
   */
  set(e = 0, t = e) {
    return this.x = e, this.y = t, this;
  }
}
ge.prototype.toString = function() {
  return `[@pixi/math:Point x=${this.x} y=${this.y}]`;
};
const io = [new ge(), new ge(), new ge(), new ge()];
class le {
  /**
   * @param x - The X coordinate of the upper-left corner of the rectangle
   * @param y - The Y coordinate of the upper-left corner of the rectangle
   * @param width - The overall width of the rectangle
   * @param height - The overall height of the rectangle
   */
  constructor(e = 0, t = 0, i = 0, n = 0) {
    this.x = Number(e), this.y = Number(t), this.width = Number(i), this.height = Number(n), this.type = Ye.RECT;
  }
  /** Returns the left edge of the rectangle. */
  get left() {
    return this.x;
  }
  /** Returns the right edge of the rectangle. */
  get right() {
    return this.x + this.width;
  }
  /** Returns the top edge of the rectangle. */
  get top() {
    return this.y;
  }
  /** Returns the bottom edge of the rectangle. */
  get bottom() {
    return this.y + this.height;
  }
  /** A constant empty rectangle. */
  static get EMPTY() {
    return new le(0, 0, 0, 0);
  }
  /**
   * Creates a clone of this Rectangle
   * @returns a copy of the rectangle
   */
  clone() {
    return new le(this.x, this.y, this.width, this.height);
  }
  /**
   * Copies another rectangle to this one.
   * @param rectangle - The rectangle to copy from.
   * @returns Returns itself.
   */
  copyFrom(e) {
    return this.x = e.x, this.y = e.y, this.width = e.width, this.height = e.height, this;
  }
  /**
   * Copies this rectangle to another one.
   * @param rectangle - The rectangle to copy to.
   * @returns Returns given parameter.
   */
  copyTo(e) {
    return e.x = this.x, e.y = this.y, e.width = this.width, e.height = this.height, e;
  }
  /**
   * Checks whether the x and y coordinates given are contained within this Rectangle
   * @param x - The X coordinate of the point to test
   * @param y - The Y coordinate of the point to test
   * @returns Whether the x/y coordinates are within this Rectangle
   */
  contains(e, t) {
    return this.width <= 0 || this.height <= 0 ? !1 : e >= this.x && e < this.x + this.width && t >= this.y && t < this.y + this.height;
  }
  /**
   * Determines whether the `other` Rectangle transformed by `transform` intersects with `this` Rectangle object.
   * Returns true only if the area of the intersection is >0, this means that Rectangles
   * sharing a side are not overlapping. Another side effect is that an arealess rectangle
   * (width or height equal to zero) can't intersect any other rectangle.
   * @param {Rectangle} other - The Rectangle to intersect with `this`.
   * @param {Matrix} transform - The transformation matrix of `other`.
   * @returns {boolean} A value of `true` if the transformed `other` Rectangle intersects with `this`; otherwise `false`.
   */
  intersects(e, t) {
    if (!t) {
      const E = this.x < e.x ? e.x : this.x;
      if ((this.right > e.right ? e.right : this.right) <= E)
        return !1;
      const R = this.y < e.y ? e.y : this.y;
      return (this.bottom > e.bottom ? e.bottom : this.bottom) > R;
    }
    const i = this.left, n = this.right, s = this.top, o = this.bottom;
    if (n <= i || o <= s)
      return !1;
    const a = io[0].set(e.left, e.top), l = io[1].set(e.left, e.bottom), h = io[2].set(e.right, e.top), c = io[3].set(e.right, e.bottom);
    if (h.x <= a.x || l.y <= a.y)
      return !1;
    const u = Math.sign(t.a * t.d - t.b * t.c);
    if (u === 0 || (t.apply(a, a), t.apply(l, l), t.apply(h, h), t.apply(c, c), Math.max(a.x, l.x, h.x, c.x) <= i || Math.min(a.x, l.x, h.x, c.x) >= n || Math.max(a.y, l.y, h.y, c.y) <= s || Math.min(a.y, l.y, h.y, c.y) >= o))
      return !1;
    const d = u * (l.y - a.y), f = u * (a.x - l.x), p = d * i + f * s, _ = d * n + f * s, m = d * i + f * o, y = d * n + f * o;
    if (Math.max(p, _, m, y) <= d * a.x + f * a.y || Math.min(p, _, m, y) >= d * c.x + f * c.y)
      return !1;
    const v = u * (a.y - h.y), g = u * (h.x - a.x), b = v * i + g * s, w = v * n + g * s, T = v * i + g * o, x = v * n + g * o;
    return !(Math.max(b, w, T, x) <= v * a.x + g * a.y || Math.min(b, w, T, x) >= v * c.x + g * c.y);
  }
  /**
   * Pads the rectangle making it grow in all directions.
   * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
   * @param paddingX - The horizontal padding amount.
   * @param paddingY - The vertical padding amount.
   * @returns Returns itself.
   */
  pad(e = 0, t = e) {
    return this.x -= e, this.y -= t, this.width += e * 2, this.height += t * 2, this;
  }
  /**
   * Fits this rectangle around the passed one.
   * @param rectangle - The rectangle to fit.
   * @returns Returns itself.
   */
  fit(e) {
    const t = Math.max(this.x, e.x), i = Math.min(this.x + this.width, e.x + e.width), n = Math.max(this.y, e.y), s = Math.min(this.y + this.height, e.y + e.height);
    return this.x = t, this.width = Math.max(i - t, 0), this.y = n, this.height = Math.max(s - n, 0), this;
  }
  /**
   * Enlarges rectangle that way its corners lie on grid
   * @param resolution - resolution
   * @param eps - precision
   * @returns Returns itself.
   */
  ceil(e = 1, t = 1e-3) {
    const i = Math.ceil((this.x + this.width - t) * e) / e, n = Math.ceil((this.y + this.height - t) * e) / e;
    return this.x = Math.floor((this.x + t) * e) / e, this.y = Math.floor((this.y + t) * e) / e, this.width = i - this.x, this.height = n - this.y, this;
  }
  /**
   * Enlarges this rectangle to include the passed rectangle.
   * @param rectangle - The rectangle to include.
   * @returns Returns itself.
   */
  enlarge(e) {
    const t = Math.min(this.x, e.x), i = Math.max(this.x + this.width, e.x + e.width), n = Math.min(this.y, e.y), s = Math.max(this.y + this.height, e.y + e.height);
    return this.x = t, this.width = i - t, this.y = n, this.height = s - n, this;
  }
}
le.prototype.toString = function() {
  return `[@pixi/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
};
class ka {
  /**
   * @param x - The X coordinate of the center of this circle
   * @param y - The Y coordinate of the center of this circle
   * @param radius - The radius of the circle
   */
  constructor(e = 0, t = 0, i = 0) {
    this.x = e, this.y = t, this.radius = i, this.type = Ye.CIRC;
  }
  /**
   * Creates a clone of this Circle instance
   * @returns A copy of the Circle
   */
  clone() {
    return new ka(this.x, this.y, this.radius);
  }
  /**
   * Checks whether the x and y coordinates given are contained within this circle
   * @param x - The X coordinate of the point to test
   * @param y - The Y coordinate of the point to test
   * @returns Whether the x/y coordinates are within this Circle
   */
  contains(e, t) {
    if (this.radius <= 0)
      return !1;
    const i = this.radius * this.radius;
    let n = this.x - e, s = this.y - t;
    return n *= n, s *= s, n + s <= i;
  }
  /**
   * Returns the framing rectangle of the circle as a Rectangle object
   * @returns The framing rectangle
   */
  getBounds() {
    return new le(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2);
  }
}
ka.prototype.toString = function() {
  return `[@pixi/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`;
};
class Da {
  /**
   * @param x - The X coordinate of the center of this ellipse
   * @param y - The Y coordinate of the center of this ellipse
   * @param halfWidth - The half width of this ellipse
   * @param halfHeight - The half height of this ellipse
   */
  constructor(e = 0, t = 0, i = 0, n = 0) {
    this.x = e, this.y = t, this.width = i, this.height = n, this.type = Ye.ELIP;
  }
  /**
   * Creates a clone of this Ellipse instance
   * @returns {PIXI.Ellipse} A copy of the ellipse
   */
  clone() {
    return new Da(this.x, this.y, this.width, this.height);
  }
  /**
   * Checks whether the x and y coordinates given are contained within this ellipse
   * @param x - The X coordinate of the point to test
   * @param y - The Y coordinate of the point to test
   * @returns Whether the x/y coords are within this ellipse
   */
  contains(e, t) {
    if (this.width <= 0 || this.height <= 0)
      return !1;
    let i = (e - this.x) / this.width, n = (t - this.y) / this.height;
    return i *= i, n *= n, i + n <= 1;
  }
  /**
   * Returns the framing rectangle of the ellipse as a Rectangle object
   * @returns The framing rectangle
   */
  getBounds() {
    return new le(this.x - this.width, this.y - this.height, this.width, this.height);
  }
}
Da.prototype.toString = function() {
  return `[@pixi/math:Ellipse x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`;
};
class Dr {
  /**
   * @param {PIXI.IPointData[]|number[]} points - This can be an array of Points
   *  that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...], or
   *  the arguments passed can be all the points of the polygon e.g.
   *  `new Polygon(new Point(), new Point(), ...)`, or the arguments passed can be flat
   *  x,y values e.g. `new Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are Numbers.
   */
  constructor(...e) {
    let t = Array.isArray(e[0]) ? e[0] : e;
    if (typeof t[0] != "number") {
      const i = [];
      for (let n = 0, s = t.length; n < s; n++)
        i.push(t[n].x, t[n].y);
      t = i;
    }
    this.points = t, this.type = Ye.POLY, this.closeStroke = !0;
  }
  /**
   * Creates a clone of this polygon.
   * @returns - A copy of the polygon.
   */
  clone() {
    const e = this.points.slice(), t = new Dr(e);
    return t.closeStroke = this.closeStroke, t;
  }
  /**
   * Checks whether the x and y coordinates passed to this function are contained within this polygon.
   * @param x - The X coordinate of the point to test.
   * @param y - The Y coordinate of the point to test.
   * @returns - Whether the x/y coordinates are within this polygon.
   */
  contains(e, t) {
    let i = !1;
    const n = this.points.length / 2;
    for (let s = 0, o = n - 1; s < n; o = s++) {
      const a = this.points[s * 2], l = this.points[s * 2 + 1], h = this.points[o * 2], c = this.points[o * 2 + 1];
      l > t != c > t && e < (h - a) * ((t - l) / (c - l)) + a && (i = !i);
    }
    return i;
  }
}
Dr.prototype.toString = function() {
  return `[@pixi/math:PolygoncloseStroke=${this.closeStroke}points=${this.points.reduce((r, e) => `${r}, ${e}`, "")}]`;
};
class Ba {
  /**
   * @param x - The X coordinate of the upper-left corner of the rounded rectangle
   * @param y - The Y coordinate of the upper-left corner of the rounded rectangle
   * @param width - The overall width of this rounded rectangle
   * @param height - The overall height of this rounded rectangle
   * @param radius - Controls the radius of the rounded corners
   */
  constructor(e = 0, t = 0, i = 0, n = 0, s = 20) {
    this.x = e, this.y = t, this.width = i, this.height = n, this.radius = s, this.type = Ye.RREC;
  }
  /**
   * Creates a clone of this Rounded Rectangle.
   * @returns - A copy of the rounded rectangle.
   */
  clone() {
    return new Ba(this.x, this.y, this.width, this.height, this.radius);
  }
  /**
   * Checks whether the x and y coordinates given are contained within this Rounded Rectangle
   * @param x - The X coordinate of the point to test.
   * @param y - The Y coordinate of the point to test.
   * @returns - Whether the x/y coordinates are within this Rounded Rectangle.
   */
  contains(e, t) {
    if (this.width <= 0 || this.height <= 0)
      return !1;
    if (e >= this.x && e <= this.x + this.width && t >= this.y && t <= this.y + this.height) {
      const i = Math.max(0, Math.min(this.radius, Math.min(this.width, this.height) / 2));
      if (t >= this.y + i && t <= this.y + this.height - i || e >= this.x + i && e <= this.x + this.width - i)
        return !0;
      let n = e - (this.x + i), s = t - (this.y + i);
      const o = i * i;
      if (n * n + s * s <= o || (n = e - (this.x + this.width - i), n * n + s * s <= o) || (s = t - (this.y + this.height - i), n * n + s * s <= o) || (n = e - (this.x + i), n * n + s * s <= o))
        return !0;
    }
    return !1;
  }
}
Ba.prototype.toString = function() {
  return `[@pixi/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`;
};
class Te {
  /**
   * @param a - x scale
   * @param b - y skew
   * @param c - x skew
   * @param d - y scale
   * @param tx - x translation
   * @param ty - y translation
   */
  constructor(e = 1, t = 0, i = 0, n = 1, s = 0, o = 0) {
    this.array = null, this.a = e, this.b = t, this.c = i, this.d = n, this.tx = s, this.ty = o;
  }
  /**
   * Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:
   *
   * a = array[0]
   * b = array[1]
   * c = array[3]
   * d = array[4]
   * tx = array[2]
   * ty = array[5]
   * @param array - The array that the matrix will be populated from.
   */
  fromArray(e) {
    this.a = e[0], this.b = e[1], this.c = e[3], this.d = e[4], this.tx = e[2], this.ty = e[5];
  }
  /**
   * Sets the matrix properties.
   * @param a - Matrix component
   * @param b - Matrix component
   * @param c - Matrix component
   * @param d - Matrix component
   * @param tx - Matrix component
   * @param ty - Matrix component
   * @returns This matrix. Good for chaining method calls.
   */
  set(e, t, i, n, s, o) {
    return this.a = e, this.b = t, this.c = i, this.d = n, this.tx = s, this.ty = o, this;
  }
  /**
   * Creates an array from the current Matrix object.
   * @param transpose - Whether we need to transpose the matrix or not
   * @param [out=new Float32Array(9)] - If provided the array will be assigned to out
   * @returns The newly created array which contains the matrix
   */
  toArray(e, t) {
    this.array || (this.array = new Float32Array(9));
    const i = t || this.array;
    return e ? (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;
  }
  /**
   * Get a new position with the current transformation applied.
   * Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
   * @param pos - The origin
   * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
   * @returns {PIXI.Point} The new point, transformed through this matrix
   */
  apply(e, t) {
    t = t || new ge();
    const i = e.x, n = e.y;
    return t.x = this.a * i + this.c * n + this.tx, t.y = this.b * i + this.d * n + this.ty, t;
  }
  /**
   * Get a new position with the inverse of the current transformation applied.
   * Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
   * @param pos - The origin
   * @param {PIXI.Point} [newPos] - The point that the new position is assigned to (allowed to be same as input)
   * @returns {PIXI.Point} The new point, inverse-transformed through this matrix
   */
  applyInverse(e, t) {
    t = t || new ge();
    const i = 1 / (this.a * this.d + this.c * -this.b), n = e.x, s = e.y;
    return t.x = this.d * i * n + -this.c * i * s + (this.ty * this.c - this.tx * this.d) * i, t.y = this.a * i * s + -this.b * i * n + (-this.ty * this.a + this.tx * this.b) * i, t;
  }
  /**
   * Translates the matrix on the x and y.
   * @param x - How much to translate x by
   * @param y - How much to translate y by
   * @returns This matrix. Good for chaining method calls.
   */
  translate(e, t) {
    return this.tx += e, this.ty += t, this;
  }
  /**
   * Applies a scale transformation to the matrix.
   * @param x - The amount to scale horizontally
   * @param y - The amount to scale vertically
   * @returns This matrix. Good for chaining method calls.
   */
  scale(e, t) {
    return this.a *= e, this.d *= t, this.c *= e, this.b *= t, this.tx *= e, this.ty *= t, this;
  }
  /**
   * Applies a rotation transformation to the matrix.
   * @param angle - The angle in radians.
   * @returns This matrix. Good for chaining method calls.
   */
  rotate(e) {
    const t = Math.cos(e), i = Math.sin(e), n = this.a, s = this.c, o = this.tx;
    return this.a = n * t - this.b * i, this.b = n * i + this.b * t, this.c = s * t - this.d * i, this.d = s * i + this.d * t, this.tx = o * t - this.ty * i, this.ty = o * i + this.ty * t, this;
  }
  /**
   * Appends the given Matrix to this Matrix.
   * @param matrix - The matrix to append.
   * @returns This matrix. Good for chaining method calls.
   */
  append(e) {
    const t = this.a, i = this.b, n = this.c, s = this.d;
    return this.a = e.a * t + e.b * n, this.b = e.a * i + e.b * s, this.c = e.c * t + e.d * n, this.d = e.c * i + e.d * s, this.tx = e.tx * t + e.ty * n + this.tx, this.ty = e.tx * i + e.ty * s + this.ty, this;
  }
  /**
   * Sets the matrix based on all the available properties
   * @param x - Position on the x axis
   * @param y - Position on the y axis
   * @param pivotX - Pivot on the x axis
   * @param pivotY - Pivot on the y axis
   * @param scaleX - Scale on the x axis
   * @param scaleY - Scale on the y axis
   * @param rotation - Rotation in radians
   * @param skewX - Skew on the x axis
   * @param skewY - Skew on the y axis
   * @returns This matrix. Good for chaining method calls.
   */
  setTransform(e, t, i, n, s, o, a, l, h) {
    return this.a = Math.cos(a + h) * s, this.b = Math.sin(a + h) * s, this.c = -Math.sin(a - l) * o, this.d = Math.cos(a - l) * o, this.tx = e - (i * this.a + n * this.c), this.ty = t - (i * this.b + n * this.d), this;
  }
  /**
   * Prepends the given Matrix to this Matrix.
   * @param matrix - The matrix to prepend
   * @returns This matrix. Good for chaining method calls.
   */
  prepend(e) {
    const t = this.tx;
    if (e.a !== 1 || e.b !== 0 || e.c !== 0 || e.d !== 1) {
      const i = this.a, n = this.c;
      this.a = i * e.a + this.b * e.c, this.b = i * e.b + this.b * e.d, this.c = n * e.a + this.d * e.c, this.d = n * e.b + this.d * e.d;
    }
    return this.tx = t * e.a + this.ty * e.c + e.tx, this.ty = t * e.b + this.ty * e.d + e.ty, this;
  }
  /**
   * Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.
   * @param transform - The transform to apply the properties to.
   * @returns The transform with the newly applied properties
   */
  decompose(e) {
    const t = this.a, i = this.b, n = this.c, s = this.d, o = e.pivot, a = -Math.atan2(-n, s), l = Math.atan2(i, t), h = Math.abs(a + l);
    return h < 1e-5 || Math.abs(oa - h) < 1e-5 ? (e.rotation = l, e.skew.x = e.skew.y = 0) : (e.rotation = 0, e.skew.x = a, e.skew.y = l), e.scale.x = Math.sqrt(t * t + i * i), e.scale.y = Math.sqrt(n * n + s * s), e.position.x = this.tx + (o.x * t + o.y * n), e.position.y = this.ty + (o.x * i + o.y * s), e;
  }
  /**
   * Inverts this matrix
   * @returns This matrix. Good for chaining method calls.
   */
  invert() {
    const e = this.a, t = this.b, i = this.c, n = this.d, s = this.tx, o = e * n - t * i;
    return this.a = n / o, this.b = -t / o, this.c = -i / o, this.d = e / o, this.tx = (i * this.ty - n * s) / o, this.ty = -(e * this.ty - t * s) / o, this;
  }
  /**
   * Resets this Matrix to an identity (default) matrix.
   * @returns This matrix. Good for chaining method calls.
   */
  identity() {
    return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0, this;
  }
  /**
   * Creates a new Matrix object with the same values as this one.
   * @returns A copy of this matrix. Good for chaining method calls.
   */
  clone() {
    const e = new Te();
    return e.a = this.a, e.b = this.b, e.c = this.c, e.d = this.d, e.tx = this.tx, e.ty = this.ty, e;
  }
  /**
   * Changes the values of the given matrix to be the same as the ones in this matrix
   * @param matrix - The matrix to copy to.
   * @returns The matrix given in parameter with its values updated.
   */
  copyTo(e) {
    return e.a = this.a, e.b = this.b, e.c = this.c, e.d = this.d, e.tx = this.tx, e.ty = this.ty, e;
  }
  /**
   * Changes the values of the matrix to be the same as the ones in given matrix
   * @param {PIXI.Matrix} matrix - The matrix to copy from.
   * @returns {PIXI.Matrix} this
   */
  copyFrom(e) {
    return this.a = e.a, this.b = e.b, this.c = e.c, this.d = e.d, this.tx = e.tx, this.ty = e.ty, this;
  }
  /**
   * A default (identity) matrix
   * @readonly
   */
  static get IDENTITY() {
    return new Te();
  }
  /**
   * A temp matrix
   * @readonly
   */
  static get TEMP_MATRIX() {
    return new Te();
  }
}
Te.prototype.toString = function() {
  return `[@pixi/math:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`;
};
const vr = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1], br = [0, 1, 1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1], wr = [0, -1, -1, -1, 0, 1, 1, 1, 0, 1, 1, 1, 0, -1, -1, -1], xr = [1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, 1, 1, 1, 0, -1], nc = [], Tm = [], ro = Math.sign;
function zA() {
  for (let r = 0; r < 16; r++) {
    const e = [];
    nc.push(e);
    for (let t = 0; t < 16; t++) {
      const i = ro(vr[r] * vr[t] + wr[r] * br[t]), n = ro(br[r] * vr[t] + xr[r] * br[t]), s = ro(vr[r] * wr[t] + wr[r] * xr[t]), o = ro(br[r] * wr[t] + xr[r] * xr[t]);
      for (let a = 0; a < 16; a++)
        if (vr[a] === i && br[a] === n && wr[a] === s && xr[a] === o) {
          e.push(a);
          break;
        }
    }
  }
  for (let r = 0; r < 16; r++) {
    const e = new Te();
    e.set(vr[r], br[r], wr[r], xr[r], 0, 0), Tm.push(e);
  }
}
zA();
const Ce = {
  /**
   * | Rotation | Direction |
   * |----------|-----------|
   * | 0°       | East      |
   * @readonly
   */
  E: 0,
  /**
   * | Rotation | Direction |
   * |----------|-----------|
   * | 45°↻     | Southeast |
   * @readonly
   */
  SE: 1,
  /**
   * | Rotation | Direction |
   * |----------|-----------|
   * | 90°↻     | South     |
   * @readonly
   */
  S: 2,
  /**
   * | Rotation | Direction |
   * |----------|-----------|
   * | 135°↻    | Southwest |
   * @readonly
   */
  SW: 3,
  /**
   * | Rotation | Direction |
   * |----------|-----------|
   * | 180°     | West      |
   * @readonly
   */
  W: 4,
  /**
   * | Rotation    | Direction    |
   * |-------------|--------------|
   * | -135°/225°↻ | Northwest    |
   * @readonly
   */
  NW: 5,
  /**
   * | Rotation    | Direction    |
   * |-------------|--------------|
   * | -90°/270°↻  | North        |
   * @readonly
   */
  N: 6,
  /**
   * | Rotation    | Direction    |
   * |-------------|--------------|
   * | -45°/315°↻  | Northeast    |
   * @readonly
   */
  NE: 7,
  /**
   * Reflection about Y-axis.
   * @readonly
   */
  MIRROR_VERTICAL: 8,
  /**
   * Reflection about the main diagonal.
   * @readonly
   */
  MAIN_DIAGONAL: 10,
  /**
   * Reflection about X-axis.
   * @readonly
   */
  MIRROR_HORIZONTAL: 12,
  /**
   * Reflection about reverse diagonal.
   * @readonly
   */
  REVERSE_DIAGONAL: 14,
  /**
   * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
   * @returns {PIXI.GD8Symmetry} The X-component of the U-axis
   *    after rotating the axes.
   */
  uX: (r) => vr[r],
  /**
   * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
   * @returns {PIXI.GD8Symmetry} The Y-component of the U-axis
   *    after rotating the axes.
   */
  uY: (r) => br[r],
  /**
   * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
   * @returns {PIXI.GD8Symmetry} The X-component of the V-axis
   *    after rotating the axes.
   */
  vX: (r) => wr[r],
  /**
   * @param {PIXI.GD8Symmetry} ind - sprite rotation angle.
   * @returns {PIXI.GD8Symmetry} The Y-component of the V-axis
   *    after rotating the axes.
   */
  vY: (r) => xr[r],
  /**
   * @param {PIXI.GD8Symmetry} rotation - symmetry whose opposite
   *   is needed. Only rotations have opposite symmetries while
   *   reflections don't.
   * @returns {PIXI.GD8Symmetry} The opposite symmetry of `rotation`
   */
  inv: (r) => r & 8 ? r & 15 : -r & 7,
  /**
   * Composes the two D8 operations.
   *
   * Taking `^` as reflection:
   *
   * |       | E=0 | S=2 | W=4 | N=6 | E^=8 | S^=10 | W^=12 | N^=14 |
   * |-------|-----|-----|-----|-----|------|-------|-------|-------|
   * | E=0   | E   | S   | W   | N   | E^   | S^    | W^    | N^    |
   * | S=2   | S   | W   | N   | E   | S^   | W^    | N^    | E^    |
   * | W=4   | W   | N   | E   | S   | W^   | N^    | E^    | S^    |
   * | N=6   | N   | E   | S   | W   | N^   | E^    | S^    | W^    |
   * | E^=8  | E^  | N^  | W^  | S^  | E    | N     | W     | S     |
   * | S^=10 | S^  | E^  | N^  | W^  | S    | E     | N     | W     |
   * | W^=12 | W^  | S^  | E^  | N^  | W    | S     | E     | N     |
   * | N^=14 | N^  | W^  | S^  | E^  | N    | W     | S     | E     |
   *
   * [This is a Cayley table]{@link https://en.wikipedia.org/wiki/Cayley_table}
   * @param {PIXI.GD8Symmetry} rotationSecond - Second operation, which
   *   is the row in the above cayley table.
   * @param {PIXI.GD8Symmetry} rotationFirst - First operation, which
   *   is the column in the above cayley table.
   * @returns {PIXI.GD8Symmetry} Composed operation
   */
  add: (r, e) => nc[r][e],
  /**
   * Reverse of `add`.
   * @param {PIXI.GD8Symmetry} rotationSecond - Second operation
   * @param {PIXI.GD8Symmetry} rotationFirst - First operation
   * @returns {PIXI.GD8Symmetry} Result
   */
  sub: (r, e) => nc[r][Ce.inv(e)],
  /**
   * Adds 180 degrees to rotation, which is a commutative
   * operation.
   * @param {number} rotation - The number to rotate.
   * @returns {number} Rotated number
   */
  rotate180: (r) => r ^ 4,
  /**
   * Checks if the rotation angle is vertical, i.e. south
   * or north. It doesn't work for reflections.
   * @param {PIXI.GD8Symmetry} rotation - The number to check.
   * @returns {boolean} Whether or not the direction is vertical
   */
  isVertical: (r) => (r & 3) === 2,
  // rotation % 4 === 2
  /**
   * Approximates the vector `V(dx,dy)` into one of the
   * eight directions provided by `groupD8`.
   * @param {number} dx - X-component of the vector
   * @param {number} dy - Y-component of the vector
   * @returns {PIXI.GD8Symmetry} Approximation of the vector into
   *  one of the eight symmetries.
   */
  byDirection: (r, e) => Math.abs(r) * 2 <= Math.abs(e) ? e >= 0 ? Ce.S : Ce.N : Math.abs(e) * 2 <= Math.abs(r) ? r > 0 ? Ce.E : Ce.W : e > 0 ? r > 0 ? Ce.SE : Ce.SW : r > 0 ? Ce.NE : Ce.NW,
  /**
   * Helps sprite to compensate texture packer rotation.
   * @param {PIXI.Matrix} matrix - sprite world matrix
   * @param {PIXI.GD8Symmetry} rotation - The rotation factor to use.
   * @param {number} tx - sprite anchoring
   * @param {number} ty - sprite anchoring
   */
  matrixAppendRotationInv: (r, e, t = 0, i = 0) => {
    const n = Tm[Ce.inv(e)];
    n.tx = t, n.ty = i, r.append(n);
  }
};
class Ci {
  /**
   * Creates a new `ObservablePoint`
   * @param cb - callback function triggered when `x` and/or `y` are changed
   * @param scope - owner of callback
   * @param {number} [x=0] - position of the point on the x axis
   * @param {number} [y=0] - position of the point on the y axis
   */
  constructor(e, t, i = 0, n = 0) {
    this._x = i, this._y = n, this.cb = e, this.scope = t;
  }
  /**
   * Creates a clone of this point.
   * The callback and scope params can be overridden otherwise they will default
   * to the clone object's values.
   * @override
   * @param cb - The callback function triggered when `x` and/or `y` are changed
   * @param scope - The owner of the callback
   * @returns a copy of this observable point
   */
  clone(e = this.cb, t = this.scope) {
    return new Ci(e, t, this._x, this._y);
  }
  /**
   * Sets the point to a new `x` and `y` position.
   * If `y` is omitted, both `x` and `y` will be set to `x`.
   * @param {number} [x=0] - position of the point on the x axis
   * @param {number} [y=x] - position of the point on the y axis
   * @returns The observable point instance itself
   */
  set(e = 0, t = e) {
    return (this._x !== e || this._y !== t) && (this._x = e, this._y = t, this.cb.call(this.scope)), this;
  }
  /**
   * Copies x and y from the given point (`p`)
   * @param p - The point to copy from. Can be any of type that is or extends `IPointData`
   * @returns The observable point instance itself
   */
  copyFrom(e) {
    return (this._x !== e.x || this._y !== e.y) && (this._x = e.x, this._y = e.y, this.cb.call(this.scope)), this;
  }
  /**
   * Copies this point's x and y into that of the given point (`p`)
   * @param p - The point to copy to. Can be any of type that is or extends `IPointData`
   * @returns The point (`p`) with values updated
   */
  copyTo(e) {
    return e.set(this._x, this._y), e;
  }
  /**
   * Accepts another point (`p`) and returns `true` if the given point is equal to this point
   * @param p - The point to check
   * @returns Returns `true` if both `x` and `y` are equal
   */
  equals(e) {
    return e.x === this._x && e.y === this._y;
  }
  /** Position of the observable point on the x axis. */
  get x() {
    return this._x;
  }
  set x(e) {
    this._x !== e && (this._x = e, this.cb.call(this.scope));
  }
  /** Position of the observable point on the y axis. */
  get y() {
    return this._y;
  }
  set y(e) {
    this._y !== e && (this._y = e, this.cb.call(this.scope));
  }
}
Ci.prototype.toString = function() {
  return `[@pixi/math:ObservablePoint x=${this.x} y=${this.y} scope=${this.scope}]`;
};
const sc = class {
  constructor() {
    this.worldTransform = new Te(), this.localTransform = new Te(), this.position = new Ci(this.onChange, this, 0, 0), this.scale = new Ci(this.onChange, this, 1, 1), this.pivot = new Ci(this.onChange, this, 0, 0), this.skew = new Ci(this.updateSkew, this, 0, 0), this._rotation = 0, this._cx = 1, this._sx = 0, this._cy = 0, this._sy = 1, this._localID = 0, this._currentLocalID = 0, this._worldID = 0, this._parentID = 0;
  }
  /** Called when a value changes. */
  onChange() {
    this._localID++;
  }
  /** Called when the skew or the rotation changes. */
  updateSkew() {
    this._cx = Math.cos(this._rotation + this.skew.y), this._sx = Math.sin(this._rotation + this.skew.y), this._cy = -Math.sin(this._rotation - this.skew.x), this._sy = Math.cos(this._rotation - this.skew.x), this._localID++;
  }
  /** Updates the local transformation matrix. */
  updateLocalTransform() {
    const r = this.localTransform;
    this._localID !== this._currentLocalID && (r.a = this._cx * this.scale.x, r.b = this._sx * this.scale.x, r.c = this._cy * this.scale.y, r.d = this._sy * this.scale.y, r.tx = this.position.x - (this.pivot.x * r.a + this.pivot.y * r.c), r.ty = this.position.y - (this.pivot.x * r.b + this.pivot.y * r.d), this._currentLocalID = this._localID, this._parentID = -1);
  }
  /**
   * Updates the local and the world transformation matrices.
   * @param parentTransform - The parent transform
   */
  updateTransform(r) {
    const e = this.localTransform;
    if (this._localID !== this._currentLocalID && (e.a = this._cx * this.scale.x, e.b = this._sx * this.scale.x, e.c = this._cy * this.scale.y, e.d = this._sy * this.scale.y, e.tx = this.position.x - (this.pivot.x * e.a + this.pivot.y * e.c), e.ty = this.position.y - (this.pivot.x * e.b + this.pivot.y * e.d), this._currentLocalID = this._localID, this._parentID = -1), this._parentID !== r._worldID) {
      const t = r.worldTransform, i = this.worldTransform;
      i.a = e.a * t.a + e.b * t.c, i.b = e.a * t.b + e.b * t.d, i.c = e.c * t.a + e.d * t.c, i.d = e.c * t.b + e.d * t.d, i.tx = e.tx * t.a + e.ty * t.c + t.tx, i.ty = e.tx * t.b + e.ty * t.d + t.ty, this._parentID = r._worldID, this._worldID++;
    }
  }
  /**
   * Decomposes a matrix and sets the transforms properties based on it.
   * @param matrix - The matrix to decompose
   */
  setFromMatrix(r) {
    r.decompose(this), this._localID++;
  }
  /** The rotation of the object in radians. */
  get rotation() {
    return this._rotation;
  }
  set rotation(r) {
    this._rotation !== r && (this._rotation = r, this.updateSkew());
  }
};
sc.IDENTITY = new sc();
let nu = sc;
nu.prototype.toString = function() {
  return `[@pixi/math:Transform position=(${this.position.x}, ${this.position.y}) rotation=${this.rotation} scale=(${this.scale.x}, ${this.scale.y}) skew=(${this.skew.x}, ${this.skew.y}) ]`;
};
var XA = `varying vec2 vTextureCoord;

uniform sampler2D uSampler;

void main(void){
   gl_FragColor *= texture2D(uSampler, vTextureCoord);
}`, VA = `attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat3 projectionMatrix;

varying vec2 vTextureCoord;

void main(void){
   gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
   vTextureCoord = aTextureCoord;
}
`;
function Sf(r, e, t) {
  const i = r.createShader(e);
  return r.shaderSource(i, t), r.compileShader(i), i;
}
function Zl(r) {
  const e = new Array(r);
  for (let t = 0; t < e.length; t++)
    e[t] = !1;
  return e;
}
function Am(r, e) {
  switch (r) {
    case "float":
      return 0;
    case "vec2":
      return new Float32Array(2 * e);
    case "vec3":
      return new Float32Array(3 * e);
    case "vec4":
      return new Float32Array(4 * e);
    case "int":
    case "uint":
    case "sampler2D":
    case "sampler2DArray":
      return 0;
    case "ivec2":
      return new Int32Array(2 * e);
    case "ivec3":
      return new Int32Array(3 * e);
    case "ivec4":
      return new Int32Array(4 * e);
    case "uvec2":
      return new Uint32Array(2 * e);
    case "uvec3":
      return new Uint32Array(3 * e);
    case "uvec4":
      return new Uint32Array(4 * e);
    case "bool":
      return !1;
    case "bvec2":
      return Zl(2 * e);
    case "bvec3":
      return Zl(3 * e);
    case "bvec4":
      return Zl(4 * e);
    case "mat2":
      return new Float32Array([
        1,
        0,
        0,
        1
      ]);
    case "mat3":
      return new Float32Array([
        1,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        1
      ]);
    case "mat4":
      return new Float32Array([
        1,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        1
      ]);
  }
  return null;
}
const In = [
  // a float cache layer
  {
    test: (r) => r.type === "float" && r.size === 1 && !r.isArray,
    code: (r) => `
            if(uv["${r}"] !== ud["${r}"].value)
            {
                ud["${r}"].value = uv["${r}"]
                gl.uniform1f(ud["${r}"].location, uv["${r}"])
            }
            `
  },
  // handling samplers
  {
    test: (r, e) => (
      // eslint-disable-next-line max-len,no-eq-null,eqeqeq
      (r.type === "sampler2D" || r.type === "samplerCube" || r.type === "sampler2DArray") && r.size === 1 && !r.isArray && (e == null || e.castToBaseTexture !== void 0)
    ),
    code: (r) => `t = syncData.textureCount++;

            renderer.texture.bind(uv["${r}"], t);

            if(ud["${r}"].value !== t)
            {
                ud["${r}"].value = t;
                gl.uniform1i(ud["${r}"].location, t);
; // eslint-disable-line max-len
            }`
  },
  // uploading pixi matrix object to mat3
  {
    test: (r, e) => r.type === "mat3" && r.size === 1 && !r.isArray && e.a !== void 0,
    code: (r) => (
      // TODO and some smart caching dirty ids here!
      `
            gl.uniformMatrix3fv(ud["${r}"].location, false, uv["${r}"].toArray(true));
            `
    ),
    codeUbo: (r) => `
                var ${r}_matrix = uv.${r}.toArray(true);

                data[offset] = ${r}_matrix[0];
                data[offset+1] = ${r}_matrix[1];
                data[offset+2] = ${r}_matrix[2];
        
                data[offset + 4] = ${r}_matrix[3];
                data[offset + 5] = ${r}_matrix[4];
                data[offset + 6] = ${r}_matrix[5];
        
                data[offset + 8] = ${r}_matrix[6];
                data[offset + 9] = ${r}_matrix[7];
                data[offset + 10] = ${r}_matrix[8];
            `
  },
  // uploading a pixi point as a vec2 with caching layer
  {
    test: (r, e) => r.type === "vec2" && r.size === 1 && !r.isArray && e.x !== void 0,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v.x || cv[1] !== v.y)
                {
                    cv[0] = v.x;
                    cv[1] = v.y;
                    gl.uniform2f(ud["${r}"].location, v.x, v.y);
                }`,
    codeUbo: (r) => `
                v = uv.${r};

                data[offset] = v.x;
                data[offset+1] = v.y;
            `
  },
  // caching layer for a vec2
  {
    test: (r) => r.type === "vec2" && r.size === 1 && !r.isArray,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v[0] || cv[1] !== v[1])
                {
                    cv[0] = v[0];
                    cv[1] = v[1];
                    gl.uniform2f(ud["${r}"].location, v[0], v[1]);
                }
            `
  },
  // upload a pixi rectangle as a vec4 with caching layer
  {
    test: (r, e) => r.type === "vec4" && r.size === 1 && !r.isArray && e.width !== void 0,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height)
                {
                    cv[0] = v.x;
                    cv[1] = v.y;
                    cv[2] = v.width;
                    cv[3] = v.height;
                    gl.uniform4f(ud["${r}"].location, v.x, v.y, v.width, v.height)
                }`,
    codeUbo: (r) => `
                    v = uv.${r};

                    data[offset] = v.x;
                    data[offset+1] = v.y;
                    data[offset+2] = v.width;
                    data[offset+3] = v.height;
                `
  },
  // upload a pixi color as vec4 with caching layer
  {
    test: (r, e) => r.type === "vec4" && r.size === 1 && !r.isArray && e.red !== void 0,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha)
                {
                    cv[0] = v.red;
                    cv[1] = v.green;
                    cv[2] = v.blue;
                    cv[3] = v.alpha;
                    gl.uniform4f(ud["${r}"].location, v.red, v.green, v.blue, v.alpha)
                }`,
    codeUbo: (r) => `
                    v = uv.${r};

                    data[offset] = v.red;
                    data[offset+1] = v.green;
                    data[offset+2] = v.blue;
                    data[offset+3] = v.alpha;
                `
  },
  // upload a pixi color as a vec3 with caching layer
  {
    test: (r, e) => r.type === "vec3" && r.size === 1 && !r.isArray && e.red !== void 0,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.a)
                {
                    cv[0] = v.red;
                    cv[1] = v.green;
                    cv[2] = v.blue;
    
                    gl.uniform3f(ud["${r}"].location, v.red, v.green, v.blue)
                }`,
    codeUbo: (r) => `
                    v = uv.${r};

                    data[offset] = v.red;
                    data[offset+1] = v.green;
                    data[offset+2] = v.blue;
                `
  },
  // a caching layer for vec4 uploading
  {
    test: (r) => r.type === "vec4" && r.size === 1 && !r.isArray,
    code: (r) => `
                cv = ud["${r}"].value;
                v = uv["${r}"];

                if(cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
                {
                    cv[0] = v[0];
                    cv[1] = v[1];
                    cv[2] = v[2];
                    cv[3] = v[3];

                    gl.uniform4f(ud["${r}"].location, v[0], v[1], v[2], v[3])
                }`
  }
], WA = {
  float: `
    if (cv !== v)
    {
        cu.value = v;
        gl.uniform1f(location, v);
    }`,
  vec2: `
    if (cv[0] !== v[0] || cv[1] !== v[1])
    {
        cv[0] = v[0];
        cv[1] = v[1];

        gl.uniform2f(location, v[0], v[1])
    }`,
  vec3: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];

        gl.uniform3f(location, v[0], v[1], v[2])
    }`,
  vec4: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];
        cv[3] = v[3];

        gl.uniform4f(location, v[0], v[1], v[2], v[3]);
    }`,
  int: `
    if (cv !== v)
    {
        cu.value = v;

        gl.uniform1i(location, v);
    }`,
  ivec2: `
    if (cv[0] !== v[0] || cv[1] !== v[1])
    {
        cv[0] = v[0];
        cv[1] = v[1];

        gl.uniform2i(location, v[0], v[1]);
    }`,
  ivec3: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];

        gl.uniform3i(location, v[0], v[1], v[2]);
    }`,
  ivec4: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];
        cv[3] = v[3];

        gl.uniform4i(location, v[0], v[1], v[2], v[3]);
    }`,
  uint: `
    if (cv !== v)
    {
        cu.value = v;

        gl.uniform1ui(location, v);
    }`,
  uvec2: `
    if (cv[0] !== v[0] || cv[1] !== v[1])
    {
        cv[0] = v[0];
        cv[1] = v[1];

        gl.uniform2ui(location, v[0], v[1]);
    }`,
  uvec3: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];

        gl.uniform3ui(location, v[0], v[1], v[2]);
    }`,
  uvec4: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];
        cv[3] = v[3];

        gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
    }`,
  bool: `
    if (cv !== v)
    {
        cu.value = v;
        gl.uniform1i(location, v);
    }`,
  bvec2: `
    if (cv[0] != v[0] || cv[1] != v[1])
    {
        cv[0] = v[0];
        cv[1] = v[1];

        gl.uniform2i(location, v[0], v[1]);
    }`,
  bvec3: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];

        gl.uniform3i(location, v[0], v[1], v[2]);
    }`,
  bvec4: `
    if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3])
    {
        cv[0] = v[0];
        cv[1] = v[1];
        cv[2] = v[2];
        cv[3] = v[3];

        gl.uniform4i(location, v[0], v[1], v[2], v[3]);
    }`,
  mat2: "gl.uniformMatrix2fv(location, false, v)",
  mat3: "gl.uniformMatrix3fv(location, false, v)",
  mat4: "gl.uniformMatrix4fv(location, false, v)",
  sampler2D: `
    if (cv !== v)
    {
        cu.value = v;

        gl.uniform1i(location, v);
    }`,
  samplerCube: `
    if (cv !== v)
    {
        cu.value = v;

        gl.uniform1i(location, v);
    }`,
  sampler2DArray: `
    if (cv !== v)
    {
        cu.value = v;

        gl.uniform1i(location, v);
    }`
}, jA = {
  float: "gl.uniform1fv(location, v)",
  vec2: "gl.uniform2fv(location, v)",
  vec3: "gl.uniform3fv(location, v)",
  vec4: "gl.uniform4fv(location, v)",
  mat4: "gl.uniformMatrix4fv(location, false, v)",
  mat3: "gl.uniformMatrix3fv(location, false, v)",
  mat2: "gl.uniformMatrix2fv(location, false, v)",
  int: "gl.uniform1iv(location, v)",
  ivec2: "gl.uniform2iv(location, v)",
  ivec3: "gl.uniform3iv(location, v)",
  ivec4: "gl.uniform4iv(location, v)",
  uint: "gl.uniform1uiv(location, v)",
  uvec2: "gl.uniform2uiv(location, v)",
  uvec3: "gl.uniform3uiv(location, v)",
  uvec4: "gl.uniform4uiv(location, v)",
  bool: "gl.uniform1iv(location, v)",
  bvec2: "gl.uniform2iv(location, v)",
  bvec3: "gl.uniform3iv(location, v)",
  bvec4: "gl.uniform4iv(location, v)",
  sampler2D: "gl.uniform1iv(location, v)",
  samplerCube: "gl.uniform1iv(location, v)",
  sampler2DArray: "gl.uniform1iv(location, v)"
};
function qA(r, e) {
  var i;
  const t = [`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
    `];
  for (const n in r.uniforms) {
    const s = e[n];
    if (!s) {
      ((i = r.uniforms[n]) == null ? void 0 : i.group) === !0 && (r.uniforms[n].ubo ? t.push(`
                        renderer.shader.syncUniformBufferGroup(uv.${n}, '${n}');
                    `) : t.push(`
                        renderer.shader.syncUniformGroup(uv.${n}, syncData);
                    `));
      continue;
    }
    const o = r.uniforms[n];
    let a = !1;
    for (let l = 0; l < In.length; l++)
      if (In[l].test(s, o)) {
        t.push(In[l].code(n, o)), a = !0;
        break;
      }
    if (!a) {
      const l = (s.size === 1 && !s.isArray ? WA : jA)[s.type].replace("location", `ud["${n}"].location`);
      t.push(`
            cu = ud["${n}"];
            cv = cu.value;
            v = uv["${n}"];
            ${l};`);
    }
  }
  return new Function("ud", "uv", "renderer", "syncData", t.join(`
`));
}
const Sm = {};
let sn = Sm;
function YA() {
  if (sn === Sm || sn != null && sn.isContextLost()) {
    const r = Z.ADAPTER.createCanvas();
    let e;
    Z.PREFER_ENV >= qr.WEBGL2 && (e = r.getContext("webgl2", {})), e || (e = r.getContext("webgl", {}) || r.getContext("experimental-webgl", {}), e ? e.getExtension("WEBGL_draw_buffers") : e = null), sn = e;
  }
  return sn;
}
let no;
function KA() {
  if (!no) {
    no = Mt.MEDIUM;
    const r = YA();
    if (r && r.getShaderPrecisionFormat) {
      const e = r.getShaderPrecisionFormat(r.FRAGMENT_SHADER, r.HIGH_FLOAT);
      e && (no = e.precision ? Mt.HIGH : Mt.MEDIUM);
    }
  }
  return no;
}
function Cf(r, e) {
  const t = r.getShaderSource(e).split(`
`).map((h, c) => `${c}: ${h}`), i = r.getShaderInfoLog(e), n = i.split(`
`), s = {}, o = n.map((h) => parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/, "$1"))).filter((h) => h && !s[h] ? (s[h] = !0, !0) : !1), a = [""];
  o.forEach((h) => {
    t[h - 1] = `%c${t[h - 1]}%c`, a.push("background: #FF0000; color:#FFFFFF; font-size: 10px", "font-size: 10px");
  });
  const l = t.join(`
`);
  a[0] = l, console.error(i), console.groupCollapsed("click to view full shader code"), console.warn(...a), console.groupEnd();
}
function ZA(r, e, t, i) {
  r.getProgramParameter(e, r.LINK_STATUS) || (r.getShaderParameter(t, r.COMPILE_STATUS) || Cf(r, t), r.getShaderParameter(i, r.COMPILE_STATUS) || Cf(r, i), console.error("PixiJS Error: Could not initialize shader."), r.getProgramInfoLog(e) !== "" && console.warn("PixiJS Warning: gl.getProgramInfoLog()", r.getProgramInfoLog(e)));
}
const $A = {
  float: 1,
  vec2: 2,
  vec3: 3,
  vec4: 4,
  int: 1,
  ivec2: 2,
  ivec3: 3,
  ivec4: 4,
  uint: 1,
  uvec2: 2,
  uvec3: 3,
  uvec4: 4,
  bool: 1,
  bvec2: 2,
  bvec3: 3,
  bvec4: 4,
  mat2: 4,
  mat3: 9,
  mat4: 16,
  sampler2D: 1
};
function Cm(r) {
  return $A[r];
}
let so = null;
const If = {
  FLOAT: "float",
  FLOAT_VEC2: "vec2",
  FLOAT_VEC3: "vec3",
  FLOAT_VEC4: "vec4",
  INT: "int",
  INT_VEC2: "ivec2",
  INT_VEC3: "ivec3",
  INT_VEC4: "ivec4",
  UNSIGNED_INT: "uint",
  UNSIGNED_INT_VEC2: "uvec2",
  UNSIGNED_INT_VEC3: "uvec3",
  UNSIGNED_INT_VEC4: "uvec4",
  BOOL: "bool",
  BOOL_VEC2: "bvec2",
  BOOL_VEC3: "bvec3",
  BOOL_VEC4: "bvec4",
  FLOAT_MAT2: "mat2",
  FLOAT_MAT3: "mat3",
  FLOAT_MAT4: "mat4",
  SAMPLER_2D: "sampler2D",
  INT_SAMPLER_2D: "sampler2D",
  UNSIGNED_INT_SAMPLER_2D: "sampler2D",
  SAMPLER_CUBE: "samplerCube",
  INT_SAMPLER_CUBE: "samplerCube",
  UNSIGNED_INT_SAMPLER_CUBE: "samplerCube",
  SAMPLER_2D_ARRAY: "sampler2DArray",
  INT_SAMPLER_2D_ARRAY: "sampler2DArray",
  UNSIGNED_INT_SAMPLER_2D_ARRAY: "sampler2DArray"
};
function Im(r, e) {
  if (!so) {
    const t = Object.keys(If);
    so = {};
    for (let i = 0; i < t.length; ++i) {
      const n = t[i];
      so[r[n]] = If[n];
    }
  }
  return so[e];
}
function Rf(r, e, t) {
  if (r.substring(0, 9) !== "precision") {
    let i = e;
    return e === Mt.HIGH && t !== Mt.HIGH && (i = Mt.MEDIUM), `precision ${i} float;
${r}`;
  } else if (t !== Mt.HIGH && r.substring(0, 15) === "precision highp")
    return r.replace("precision highp", "precision mediump");
  return r;
}
let is;
function JA() {
  if (typeof is == "boolean")
    return is;
  try {
    is = new Function("param1", "param2", "param3", "return param1[param2] === param3;")({ a: "b" }, "a", "b") === !0;
  } catch {
    is = !1;
  }
  return is;
}
let QA = 0;
const oo = {}, oc = class pn {
  /**
   * @param vertexSrc - The source of the vertex shader.
   * @param fragmentSrc - The source of the fragment shader.
   * @param name - Name for shader
   * @param extra - Extra data for shader
   */
  constructor(e, t, i = "pixi-shader", n = {}) {
    this.extra = {}, this.id = QA++, this.vertexSrc = e || pn.defaultVertexSrc, this.fragmentSrc = t || pn.defaultFragmentSrc, this.vertexSrc = this.vertexSrc.trim(), this.fragmentSrc = this.fragmentSrc.trim(), this.extra = n, this.vertexSrc.substring(0, 8) !== "#version" && (i = i.replace(/\s+/g, "-"), oo[i] ? (oo[i]++, i += `-${oo[i]}`) : oo[i] = 1, this.vertexSrc = `#define SHADER_NAME ${i}
${this.vertexSrc}`, this.fragmentSrc = `#define SHADER_NAME ${i}
${this.fragmentSrc}`, this.vertexSrc = Rf(
      this.vertexSrc,
      pn.defaultVertexPrecision,
      Mt.HIGH
    ), this.fragmentSrc = Rf(
      this.fragmentSrc,
      pn.defaultFragmentPrecision,
      KA()
    )), this.glPrograms = {}, this.syncUniforms = null;
  }
  /**
   * The default vertex shader source.
   * @readonly
   */
  static get defaultVertexSrc() {
    return VA;
  }
  /**
   * The default fragment shader source.
   * @readonly
   */
  static get defaultFragmentSrc() {
    return XA;
  }
  /**
   * A short hand function to create a program based of a vertex and fragment shader.
   *
   * This method will also check to see if there is a cached program.
   * @param vertexSrc - The source of the vertex shader.
   * @param fragmentSrc - The source of the fragment shader.
   * @param name - Name for shader
   * @returns A shiny new PixiJS shader program!
   */
  static from(e, t, i) {
    const n = e + t;
    let s = wf[n];
    return s || (wf[n] = s = new pn(e, t, i)), s;
  }
};
oc.defaultVertexPrecision = Mt.HIGH, /**
* Default specify float precision in fragment shader.
* iOS is best set at highp due to https://github.com/pixijs/pixijs/issues/3742
* @static
* @type {PIXI.PRECISION}
* @default PIXI.PRECISION.MEDIUM
*/
oc.defaultFragmentPrecision = Si.apple.device ? Mt.HIGH : Mt.MEDIUM;
let Ii = oc, eS = 0;
class Jt {
  /**
   * @param {object | Buffer} [uniforms] - Custom uniforms to use to augment the built-in ones. Or a pixi buffer.
   * @param isStatic - Uniforms wont be changed after creation.
   * @param isUbo - If true, will treat this uniform group as a uniform buffer object.
   */
  constructor(e, t, i) {
    this.group = !0, this.syncUniforms = {}, this.dirtyId = 0, this.id = eS++, this.static = !!t, this.ubo = !!i, e instanceof Be ? (this.buffer = e, this.buffer.type = _i.UNIFORM_BUFFER, this.autoManage = !1, this.ubo = !0) : (this.uniforms = e, this.ubo && (this.buffer = new Be(new Float32Array(1)), this.buffer.type = _i.UNIFORM_BUFFER, this.autoManage = !0));
  }
  update() {
    this.dirtyId++, !this.autoManage && this.buffer && this.buffer.update();
  }
  add(e, t, i) {
    if (!this.ubo)
      this.uniforms[e] = new Jt(t, i);
    else
      throw new Error("[UniformGroup] uniform groups in ubo mode cannot be modified, or have uniform groups nested in them");
  }
  static from(e, t, i) {
    return new Jt(e, t, i);
  }
  /**
   * A short hand function for creating a static UBO UniformGroup.
   * @param uniforms - the ubo item
   * @param _static - should this be updated each time it is used? defaults to true here!
   */
  static uboFrom(e, t) {
    return new Jt(e, t ?? !0, !0);
  }
}
class mi {
  /**
   * @param program - The program the shader will use.
   * @param uniforms - Custom uniforms to use to augment the built-in ones.
   */
  constructor(e, t) {
    this.uniformBindCount = 0, this.program = e, t ? t instanceof Jt ? this.uniformGroup = t : this.uniformGroup = new Jt(t) : this.uniformGroup = new Jt({}), this.disposeRunner = new $t("disposeShader");
  }
  // TODO move to shader system..
  checkUniformExists(e, t) {
    if (t.uniforms[e])
      return !0;
    for (const i in t.uniforms) {
      const n = t.uniforms[i];
      if (n.group === !0 && this.checkUniformExists(e, n))
        return !0;
    }
    return !1;
  }
  destroy() {
    this.uniformGroup = null, this.disposeRunner.emit(this), this.disposeRunner.destroy();
  }
  /**
   * Shader uniform values, shortcut for `uniformGroup.uniforms`.
   * @readonly
   */
  get uniforms() {
    return this.uniformGroup.uniforms;
  }
  /**
   * A short hand function to create a shader based of a vertex and fragment shader.
   * @param vertexSrc - The source of the vertex shader.
   * @param fragmentSrc - The source of the fragment shader.
   * @param uniforms - Custom uniforms to use to augment the built-in ones.
   * @returns A shiny new PixiJS shader!
   */
  static from(e, t, i) {
    const n = Ii.from(e, t);
    return new mi(n, i);
  }
}
class tS {
  /**
   * @param vertexSrc - Vertex shader
   * @param fragTemplate - Fragment shader template
   */
  constructor(e, t) {
    if (this.vertexSrc = e, this.fragTemplate = t, this.programCache = {}, this.defaultGroupCache = {}, !t.includes("%count%"))
      throw new Error('Fragment template must contain "%count%".');
    if (!t.includes("%forloop%"))
      throw new Error('Fragment template must contain "%forloop%".');
  }
  generateShader(e) {
    if (!this.programCache[e]) {
      const i = new Int32Array(e);
      for (let s = 0; s < e; s++)
        i[s] = s;
      this.defaultGroupCache[e] = Jt.from({ uSamplers: i }, !0);
      let n = this.fragTemplate;
      n = n.replace(/%count%/gi, `${e}`), n = n.replace(/%forloop%/gi, this.generateSampleSrc(e)), this.programCache[e] = new Ii(this.vertexSrc, n);
    }
    const t = {
      tint: new Float32Array([1, 1, 1, 1]),
      translationMatrix: new Te(),
      default: this.defaultGroupCache[e]
    };
    return new mi(this.programCache[e], t);
  }
  generateSampleSrc(e) {
    let t = "";
    t += `
`, t += `
`;
    for (let i = 0; i < e; i++)
      i > 0 && (t += `
else `), i < e - 1 && (t += `if(vTextureId < ${i}.5)`), t += `
{`, t += `
	color = texture2D(uSamplers[${i}], vTextureCoord);`, t += `
}`;
    return t += `
`, t += `
`, t;
  }
}
class ac {
  constructor() {
    this.elements = [], this.ids = [], this.count = 0;
  }
  clear() {
    for (let e = 0; e < this.count; e++)
      this.elements[e] = null;
    this.count = 0;
  }
}
function iS() {
  return !Si.apple.device;
}
function rS(r) {
  let e = !0;
  const t = Z.ADAPTER.getNavigator();
  if (Si.tablet || Si.phone) {
    if (Si.apple.device) {
      const i = t.userAgent.match(/OS (\d+)_(\d+)?/);
      i && parseInt(i[1], 10) < 11 && (e = !1);
    }
    if (Si.android.device) {
      const i = t.userAgent.match(/Android\s([0-9.]*)/);
      i && parseInt(i[1], 10) < 7 && (e = !1);
    }
  }
  return e ? r : 4;
}
class Fa {
  /**
   * @param renderer - The renderer this manager works for.
   */
  constructor(e) {
    this.renderer = e;
  }
  /** Stub method that should be used to empty the current batch by rendering objects now. */
  flush() {
  }
  /** Generic destruction method that frees all resources. This should be called by subclasses. */
  destroy() {
    this.renderer = null;
  }
  /**
   * Stub method that initializes any state required before
   * rendering starts. It is different from the `prerender`
   * signal, which occurs every frame, in that it is called
   * whenever an object requests _this_ renderer specifically.
   */
  start() {
  }
  /** Stops the renderer. It should free up any state and become dormant. */
  stop() {
    this.flush();
  }
  /**
   * Keeps the object to render. It doesn't have to be
   * rendered immediately.
   * @param {PIXI.DisplayObject} _object - The object to render.
   */
  render(e) {
  }
}
var nS = `varying vec2 vTextureCoord;
varying vec4 vColor;
varying float vTextureId;
uniform sampler2D uSamplers[%count%];

void main(void){
    vec4 color;
    %forloop%
    gl_FragColor = color * vColor;
}
`, sS = `precision highp float;
attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;
attribute vec4 aColor;
attribute float aTextureId;

uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform vec4 tint;

varying vec2 vTextureCoord;
varying vec4 vColor;
varying float vTextureId;

void main(void){
    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = aTextureCoord;
    vTextureId = aTextureId;
    vColor = aColor * tint;
}
`;
const ls = class zt extends Fa {
  /**
   * This will hook onto the renderer's `contextChange`
   * and `prerender` signals.
   * @param {PIXI.Renderer} renderer - The renderer this works for.
   */
  constructor(e) {
    super(e), this.setShaderGenerator(), this.geometryClass = Em, this.vertexSize = 6, this.state = yi.for2d(), this.size = zt.defaultBatchSize * 4, this._vertexCount = 0, this._indexCount = 0, this._bufferedElements = [], this._bufferedTextures = [], this._bufferSize = 0, this._shader = null, this._packedGeometries = [], this._packedGeometryPoolSize = 2, this._flushId = 0, this._aBuffers = {}, this._iBuffers = {}, this.maxTextures = 1, this.renderer.on("prerender", this.onPrerender, this), e.runners.contextChange.add(this), this._dcIndex = 0, this._aIndex = 0, this._iIndex = 0, this._attributeBuffer = null, this._indexBuffer = null, this._tempBoundTextures = [];
  }
  /**
   * The maximum textures that this device supports.
   * @static
   * @default 32
   */
  static get defaultMaxTextures() {
    return this._defaultMaxTextures = this._defaultMaxTextures ?? rS(32), this._defaultMaxTextures;
  }
  static set defaultMaxTextures(e) {
    this._defaultMaxTextures = e;
  }
  /**
   * Can we upload the same buffer in a single frame?
   * @static
   */
  static get canUploadSameBuffer() {
    return this._canUploadSameBuffer = this._canUploadSameBuffer ?? iS(), this._canUploadSameBuffer;
  }
  static set canUploadSameBuffer(e) {
    this._canUploadSameBuffer = e;
  }
  /**
   * @see PIXI.BatchRenderer#maxTextures
   * @deprecated since 7.1.0
   * @readonly
   */
  get MAX_TEXTURES() {
    return fe("7.1.0", "BatchRenderer#MAX_TEXTURES renamed to BatchRenderer#maxTextures"), this.maxTextures;
  }
  /**
   * The default vertex shader source
   * @readonly
   */
  static get defaultVertexSrc() {
    return sS;
  }
  /**
   * The default fragment shader source
   * @readonly
   */
  static get defaultFragmentTemplate() {
    return nS;
  }
  /**
   * Set the shader generator.
   * @param {object} [options]
   * @param {string} [options.vertex=PIXI.BatchRenderer.defaultVertexSrc] - Vertex shader source
   * @param {string} [options.fragment=PIXI.BatchRenderer.defaultFragmentTemplate] - Fragment shader template
   */
  setShaderGenerator({
    vertex: e = zt.defaultVertexSrc,
    fragment: t = zt.defaultFragmentTemplate
  } = {}) {
    this.shaderGenerator = new tS(e, t);
  }
  /**
   * Handles the `contextChange` signal.
   *
   * It calculates `this.maxTextures` and allocating the packed-geometry object pool.
   */
  contextChange() {
    const e = this.renderer.gl;
    Z.PREFER_ENV === qr.WEBGL_LEGACY ? this.maxTextures = 1 : (this.maxTextures = Math.min(
      e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),
      zt.defaultMaxTextures
    ), this.maxTextures = DA(
      this.maxTextures,
      e
    )), this._shader = this.shaderGenerator.generateShader(this.maxTextures);
    for (let t = 0; t < this._packedGeometryPoolSize; t++)
      this._packedGeometries[t] = new this.geometryClass();
    this.initFlushBuffers();
  }
  /** Makes sure that static and dynamic flush pooled objects have correct dimensions. */
  initFlushBuffers() {
    const {
      _drawCallPool: e,
      _textureArrayPool: t
    } = zt, i = this.size / 4, n = Math.floor(i / this.maxTextures) + 1;
    for (; e.length < i; )
      e.push(new rc());
    for (; t.length < n; )
      t.push(new ac());
    for (let s = 0; s < this.maxTextures; s++)
      this._tempBoundTextures[s] = null;
  }
  /** Handles the `prerender` signal. It ensures that flushes start from the first geometry object again. */
  onPrerender() {
    this._flushId = 0;
  }
  /**
   * Buffers the "batchable" object. It need not be rendered immediately.
   * @param {PIXI.DisplayObject} element - the element to render when
   *    using this renderer
   */
  render(e) {
    e._texture.valid && (this._vertexCount + e.vertexData.length / 2 > this.size && this.flush(), this._vertexCount += e.vertexData.length / 2, this._indexCount += e.indices.length, this._bufferedTextures[this._bufferSize] = e._texture.baseTexture, this._bufferedElements[this._bufferSize++] = e);
  }
  buildTexturesAndDrawCalls() {
    const {
      _bufferedTextures: e,
      maxTextures: t
    } = this, i = zt._textureArrayPool, n = this.renderer.batch, s = this._tempBoundTextures, o = this.renderer.textureGC.count;
    let a = ++ae._globalBatch, l = 0, h = i[0], c = 0;
    n.copyBoundTextures(s, t);
    for (let u = 0; u < this._bufferSize; ++u) {
      const d = e[u];
      e[u] = null, d._batchEnabled !== a && (h.count >= t && (n.boundArray(h, s, a, t), this.buildDrawCalls(h, c, u), c = u, h = i[++l], ++a), d._batchEnabled = a, d.touched = o, h.elements[h.count++] = d);
    }
    h.count > 0 && (n.boundArray(h, s, a, t), this.buildDrawCalls(h, c, this._bufferSize), ++l, ++a);
    for (let u = 0; u < s.length; u++)
      s[u] = null;
    ae._globalBatch = a;
  }
  /**
   * Populating drawcalls for rendering
   * @param texArray
   * @param start
   * @param finish
   */
  buildDrawCalls(e, t, i) {
    const {
      _bufferedElements: n,
      _attributeBuffer: s,
      _indexBuffer: o,
      vertexSize: a
    } = this, l = zt._drawCallPool;
    let h = this._dcIndex, c = this._aIndex, u = this._iIndex, d = l[h];
    d.start = this._iIndex, d.texArray = e;
    for (let f = t; f < i; ++f) {
      const p = n[f], _ = p._texture.baseTexture, m = vm[_.alphaMode ? 1 : 0][p.blendMode];
      n[f] = null, t < f && d.blend !== m && (d.size = u - d.start, t = f, d = l[++h], d.texArray = e, d.start = u), this.packInterleavedGeometry(p, s, o, c, u), c += p.vertexData.length / 2 * a, u += p.indices.length, d.blend = m;
    }
    t < i && (d.size = u - d.start, ++h), this._dcIndex = h, this._aIndex = c, this._iIndex = u;
  }
  /**
   * Bind textures for current rendering
   * @param texArray
   */
  bindAndClearTexArray(e) {
    const t = this.renderer.texture;
    for (let i = 0; i < e.count; i++)
      t.bind(e.elements[i], e.ids[i]), e.elements[i] = null;
    e.count = 0;
  }
  updateGeometry() {
    const {
      _packedGeometries: e,
      _attributeBuffer: t,
      _indexBuffer: i
    } = this;
    zt.canUploadSameBuffer ? (e[this._flushId]._buffer.update(t.rawBinaryData), e[this._flushId]._indexBuffer.update(i), this.renderer.geometry.updateBuffers()) : (this._packedGeometryPoolSize <= this._flushId && (this._packedGeometryPoolSize++, e[this._flushId] = new this.geometryClass()), e[this._flushId]._buffer.update(t.rawBinaryData), e[this._flushId]._indexBuffer.update(i), this.renderer.geometry.bind(e[this._flushId]), this.renderer.geometry.updateBuffers(), this._flushId++);
  }
  drawBatches() {
    const e = this._dcIndex, { gl: t, state: i } = this.renderer, n = zt._drawCallPool;
    let s = null;
    for (let o = 0; o < e; o++) {
      const { texArray: a, type: l, size: h, start: c, blend: u } = n[o];
      s !== a && (s = a, this.bindAndClearTexArray(a)), this.state.blendMode = u, i.set(this.state), t.drawElements(l, h, t.UNSIGNED_SHORT, c * 2);
    }
  }
  /** Renders the content _now_ and empties the current batch. */
  flush() {
    this._vertexCount !== 0 && (this._attributeBuffer = this.getAttributeBuffer(this._vertexCount), this._indexBuffer = this.getIndexBuffer(this._indexCount), this._aIndex = 0, this._iIndex = 0, this._dcIndex = 0, this.buildTexturesAndDrawCalls(), this.updateGeometry(), this.drawBatches(), this._bufferSize = 0, this._vertexCount = 0, this._indexCount = 0);
  }
  /** Starts a new sprite batch. */
  start() {
    this.renderer.state.set(this.state), this.renderer.texture.ensureSamplerType(this.maxTextures), this.renderer.shader.bind(this._shader), zt.canUploadSameBuffer && this.renderer.geometry.bind(this._packedGeometries[this._flushId]);
  }
  /** Stops and flushes the current batch. */
  stop() {
    this.flush();
  }
  /** Destroys this `BatchRenderer`. It cannot be used again. */
  destroy() {
    for (let e = 0; e < this._packedGeometryPoolSize; e++)
      this._packedGeometries[e] && this._packedGeometries[e].destroy();
    this.renderer.off("prerender", this.onPrerender, this), this._aBuffers = null, this._iBuffers = null, this._packedGeometries = null, this._attributeBuffer = null, this._indexBuffer = null, this._shader && (this._shader.destroy(), this._shader = null), super.destroy();
  }
  /**
   * Fetches an attribute buffer from `this._aBuffers` that can hold atleast `size` floats.
   * @param size - minimum capacity required
   * @returns - buffer than can hold atleast `size` floats
   */
  getAttributeBuffer(e) {
    const t = na(Math.ceil(e / 8)), i = vf(t), n = t * 8;
    this._aBuffers.length <= i && (this._iBuffers.length = i + 1);
    let s = this._aBuffers[n];
    return s || (this._aBuffers[n] = s = new ec(n * this.vertexSize * 4)), s;
  }
  /**
   * Fetches an index buffer from `this._iBuffers` that can
   * have at least `size` capacity.
   * @param size - minimum required capacity
   * @returns - buffer that can fit `size` indices.
   */
  getIndexBuffer(e) {
    const t = na(Math.ceil(e / 12)), i = vf(t), n = t * 12;
    this._iBuffers.length <= i && (this._iBuffers.length = i + 1);
    let s = this._iBuffers[i];
    return s || (this._iBuffers[i] = s = new Uint16Array(n)), s;
  }
  /**
   * Takes the four batching parameters of `element`, interleaves
   * and pushes them into the batching attribute/index buffers given.
   *
   * It uses these properties: `vertexData` `uvs`, `textureId` and
   * `indicies`. It also uses the "tint" of the base-texture, if
   * present.
   * @param {PIXI.DisplayObject} element - element being rendered
   * @param attributeBuffer - attribute buffer.
   * @param indexBuffer - index buffer
   * @param aIndex - number of floats already in the attribute buffer
   * @param iIndex - number of indices already in `indexBuffer`
   */
  packInterleavedGeometry(e, t, i, n, s) {
    const {
      uint32View: o,
      float32View: a
    } = t, l = n / this.vertexSize, h = e.uvs, c = e.indices, u = e.vertexData, d = e._texture.baseTexture._batchLocation, f = Math.min(e.worldAlpha, 1), p = be.shared.setValue(e._tintRGB).toPremultiplied(f, e._texture.baseTexture.alphaMode > 0);
    for (let _ = 0; _ < u.length; _ += 2)
      a[n++] = u[_], a[n++] = u[_ + 1], a[n++] = h[_], a[n++] = h[_ + 1], o[n++] = p, a[n++] = d;
    for (let _ = 0; _ < c.length; _++)
      i[s++] = l + c[_];
  }
};
ls.defaultBatchSize = 4096, /** @ignore */
ls.extension = {
  name: "batch",
  type: q.RendererPlugin
}, /**
* Pool of `BatchDrawCall` objects that `flush` used
* to create "batches" of the objects being rendered.
*
* These are never re-allocated again.
* Shared between all batch renderers because it can be only one "flush" working at the moment.
* @member {PIXI.BatchDrawCall[]}
*/
ls._drawCallPool = [], /**
* Pool of `BatchDrawCall` objects that `flush` used
* to create "batches" of the objects being rendered.
*
* These are never re-allocated again.
* Shared between all batch renderers because it can be only one "flush" working at the moment.
* @member {PIXI.BatchTextureArray[]}
*/
ls._textureArrayPool = [];
let Er = ls;
Q.add(Er);
var oS = `varying vec2 vTextureCoord;

uniform sampler2D uSampler;

void main(void){
   gl_FragColor = texture2D(uSampler, vTextureCoord);
}
`, aS = `attribute vec2 aVertexPosition;

uniform mat3 projectionMatrix;

varying vec2 vTextureCoord;

uniform vec4 inputSize;
uniform vec4 outputFrame;

vec4 filterVertexPosition( void )
{
    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aVertexPosition * (outputFrame.zw * inputSize.zw);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
}
`;
const lc = class hs extends mi {
  /**
   * @param vertexSrc - The source of the vertex shader.
   * @param fragmentSrc - The source of the fragment shader.
   * @param uniforms - Custom uniforms to use to augment the built-in ones.
   */
  constructor(e, t, i) {
    const n = Ii.from(
      e || hs.defaultVertexSrc,
      t || hs.defaultFragmentSrc
    );
    super(n, i), this.padding = 0, this.resolution = hs.defaultResolution, this.multisample = hs.defaultMultisample, this.enabled = !0, this.autoFit = !0, this.state = new yi();
  }
  /**
   * Applies the filter
   * @param {PIXI.FilterSystem} filterManager - The renderer to retrieve the filter from
   * @param {PIXI.RenderTexture} input - The input render target.
   * @param {PIXI.RenderTexture} output - The target to output to.
   * @param {PIXI.CLEAR_MODES} [clearMode] - Should the output be cleared before rendering to it.
   * @param {object} [_currentState] - It's current state of filter.
   *        There are some useful properties in the currentState :
   *        target, filters, sourceFrame, destinationFrame, renderTarget, resolution
   */
  apply(e, t, i, n, s) {
    e.applyFilter(this, t, i, n);
  }
  /**
   * Sets the blend mode of the filter.
   * @default PIXI.BLEND_MODES.NORMAL
   */
  get blendMode() {
    return this.state.blendMode;
  }
  set blendMode(e) {
    this.state.blendMode = e;
  }
  /**
   * The resolution of the filter. Setting this to be lower will lower the quality but
   * increase the performance of the filter.
   * If set to `null` or `0`, the resolution of the current render target is used.
   * @default PIXI.Filter.defaultResolution
   */
  get resolution() {
    return this._resolution;
  }
  set resolution(e) {
    this._resolution = e;
  }
  /**
   * The default vertex shader source
   * @readonly
   */
  static get defaultVertexSrc() {
    return aS;
  }
  /**
   * The default fragment shader source
   * @readonly
   */
  static get defaultFragmentSrc() {
    return oS;
  }
};
lc.defaultResolution = 1, /**
* Default filter samples for any filter.
* @static
* @type {PIXI.MSAA_QUALITY|null}
* @default PIXI.MSAA_QUALITY.NONE
*/
lc.defaultMultisample = Le.NONE;
let Je = lc;
class aa {
  constructor() {
    this.clearBeforeRender = !0, this._backgroundColor = new be(0), this.alpha = 1;
  }
  /**
   * initiates the background system
   * @param {PIXI.IRendererOptions} options - the options for the background colors
   */
  init(e) {
    this.clearBeforeRender = e.clearBeforeRender;
    const { backgroundColor: t, background: i, backgroundAlpha: n } = e, s = i ?? t;
    s !== void 0 && (this.color = s), this.alpha = n;
  }
  /**
   * The background color to fill if not transparent.
   * @member {PIXI.ColorSource}
   */
  get color() {
    return this._backgroundColor.value;
  }
  set color(e) {
    this._backgroundColor.setValue(e);
  }
  /**
   * The background color alpha. Setting this to 0 will make the canvas transparent.
   * @member {number}
   */
  get alpha() {
    return this._backgroundColor.alpha;
  }
  set alpha(e) {
    this._backgroundColor.setAlpha(e);
  }
  /** The background color object. */
  get backgroundColor() {
    return this._backgroundColor;
  }
  destroy() {
  }
}
aa.defaultOptions = {
  /**
   * {@link PIXI.IRendererOptions.backgroundAlpha}
   * @default 1
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  backgroundAlpha: 1,
  /**
   * {@link PIXI.IRendererOptions.backgroundColor}
   * @default 0x000000
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  backgroundColor: 0,
  /**
   * {@link PIXI.IRendererOptions.clearBeforeRender}
   * @default true
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  clearBeforeRender: !0
}, /** @ignore */
aa.extension = {
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ],
  name: "background"
};
Q.add(aa);
class Rm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.emptyRenderer = new Fa(e), this.currentRenderer = this.emptyRenderer;
  }
  /**
   * Changes the current renderer to the one given in parameter
   * @param objectRenderer - The object renderer to use.
   */
  setObjectRenderer(e) {
    this.currentRenderer !== e && (this.currentRenderer.stop(), this.currentRenderer = e, this.currentRenderer.start());
  }
  /**
   * This should be called if you wish to do some custom rendering
   * It will basically render anything that may be batched up such as sprites
   */
  flush() {
    this.setObjectRenderer(this.emptyRenderer);
  }
  /** Reset the system to an empty renderer */
  reset() {
    this.setObjectRenderer(this.emptyRenderer);
  }
  /**
   * Handy function for batch renderers: copies bound textures in first maxTextures locations to array
   * sets actual _batchLocation for them
   * @param arr - arr copy destination
   * @param maxTextures - number of copied elements
   */
  copyBoundTextures(e, t) {
    const { boundTextures: i } = this.renderer.texture;
    for (let n = t - 1; n >= 0; --n)
      e[n] = i[n] || null, e[n] && (e[n]._batchLocation = n);
  }
  /**
   * Assigns batch locations to textures in array based on boundTextures state.
   * All textures in texArray should have `_batchEnabled = _batchId`,
   * and their count should be less than `maxTextures`.
   * @param texArray - textures to bound
   * @param boundTextures - current state of bound textures
   * @param batchId - marker for _batchEnabled param of textures in texArray
   * @param maxTextures - number of texture locations to manipulate
   */
  boundArray(e, t, i, n) {
    const { elements: s, ids: o, count: a } = e;
    let l = 0;
    for (let h = 0; h < a; h++) {
      const c = s[h], u = c._batchLocation;
      if (u >= 0 && u < n && t[u] === c) {
        o[h] = u;
        continue;
      }
      for (; l < n; ) {
        const d = t[l];
        if (d && d._batchEnabled === i && d._batchLocation === l) {
          l++;
          continue;
        }
        o[h] = l, c._batchLocation = l, t[l] = c;
        break;
      }
    }
  }
  /**
   * @ignore
   */
  destroy() {
    this.renderer = null;
  }
}
Rm.extension = {
  type: q.RendererSystem,
  name: "batch"
};
Q.add(Rm);
let Pf = 0;
class la {
  /** @param renderer - The renderer this System works for. */
  constructor(e) {
    this.renderer = e, this.webGLVersion = 1, this.extensions = {}, this.supports = {
      uint32Indices: !1
    }, this.handleContextLost = this.handleContextLost.bind(this), this.handleContextRestored = this.handleContextRestored.bind(this);
  }
  /**
   * `true` if the context is lost
   * @readonly
   */
  get isLost() {
    return !this.gl || this.gl.isContextLost();
  }
  /**
   * Handles the context change event.
   * @param {WebGLRenderingContext} gl - New WebGL context.
   */
  contextChange(e) {
    this.gl = e, this.renderer.gl = e, this.renderer.CONTEXT_UID = Pf++;
  }
  init(e) {
    if (e.context)
      this.initFromContext(e.context);
    else {
      const t = this.renderer.background.alpha < 1, i = e.premultipliedAlpha;
      this.preserveDrawingBuffer = e.preserveDrawingBuffer, this.useContextAlpha = e.useContextAlpha, this.powerPreference = e.powerPreference, this.initFromOptions({
        alpha: t,
        premultipliedAlpha: i,
        antialias: e.antialias,
        stencil: !0,
        preserveDrawingBuffer: e.preserveDrawingBuffer,
        powerPreference: e.powerPreference
      });
    }
  }
  /**
   * Initializes the context.
   * @protected
   * @param {WebGLRenderingContext} gl - WebGL context
   */
  initFromContext(e) {
    this.gl = e, this.validateContext(e), this.renderer.gl = e, this.renderer.CONTEXT_UID = Pf++, this.renderer.runners.contextChange.emit(e);
    const t = this.renderer.view;
    t.addEventListener !== void 0 && (t.addEventListener("webglcontextlost", this.handleContextLost, !1), t.addEventListener("webglcontextrestored", this.handleContextRestored, !1));
  }
  /**
   * Initialize from context options
   * @protected
   * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
   * @param {object} options - context attributes
   */
  initFromOptions(e) {
    const t = this.createContext(this.renderer.view, e);
    this.initFromContext(t);
  }
  /**
   * Helper class to create a WebGL Context
   * @param canvas - the canvas element that we will get the context from
   * @param options - An options object that gets passed in to the canvas element containing the
   *    context attributes
   * @see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext
   * @returns {WebGLRenderingContext} the WebGL context
   */
  createContext(e, t) {
    let i;
    if (Z.PREFER_ENV >= qr.WEBGL2 && (i = e.getContext("webgl2", t)), i)
      this.webGLVersion = 2;
    else if (this.webGLVersion = 1, i = e.getContext("webgl", t) || e.getContext("experimental-webgl", t), !i)
      throw new Error("This browser does not support WebGL. Try using the canvas renderer");
    return this.gl = i, this.getExtensions(), this.gl;
  }
  /** Auto-populate the {@link PIXI.ContextSystem.extensions extensions}. */
  getExtensions() {
    const { gl: e } = this, t = {
      loseContext: e.getExtension("WEBGL_lose_context"),
      anisotropicFiltering: e.getExtension("EXT_texture_filter_anisotropic"),
      floatTextureLinear: e.getExtension("OES_texture_float_linear"),
      s3tc: e.getExtension("WEBGL_compressed_texture_s3tc"),
      s3tc_sRGB: e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),
      // eslint-disable-line camelcase
      etc: e.getExtension("WEBGL_compressed_texture_etc"),
      etc1: e.getExtension("WEBGL_compressed_texture_etc1"),
      pvrtc: e.getExtension("WEBGL_compressed_texture_pvrtc") || e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
      atc: e.getExtension("WEBGL_compressed_texture_atc"),
      astc: e.getExtension("WEBGL_compressed_texture_astc"),
      bptc: e.getExtension("EXT_texture_compression_bptc")
    };
    this.webGLVersion === 1 ? Object.assign(this.extensions, t, {
      drawBuffers: e.getExtension("WEBGL_draw_buffers"),
      depthTexture: e.getExtension("WEBGL_depth_texture"),
      vertexArrayObject: e.getExtension("OES_vertex_array_object") || e.getExtension("MOZ_OES_vertex_array_object") || e.getExtension("WEBKIT_OES_vertex_array_object"),
      uint32ElementIndex: e.getExtension("OES_element_index_uint"),
      // Floats and half-floats
      floatTexture: e.getExtension("OES_texture_float"),
      floatTextureLinear: e.getExtension("OES_texture_float_linear"),
      textureHalfFloat: e.getExtension("OES_texture_half_float"),
      textureHalfFloatLinear: e.getExtension("OES_texture_half_float_linear")
    }) : this.webGLVersion === 2 && Object.assign(this.extensions, t, {
      // Floats and half-floats
      colorBufferFloat: e.getExtension("EXT_color_buffer_float")
    });
  }
  /**
   * Handles a lost webgl context
   * @param {WebGLContextEvent} event - The context lost event.
   */
  handleContextLost(e) {
    e.preventDefault(), setTimeout(() => {
      this.gl.isContextLost() && this.extensions.loseContext && this.extensions.loseContext.restoreContext();
    }, 0);
  }
  /** Handles a restored webgl context. */
  handleContextRestored() {
    this.renderer.runners.contextChange.emit(this.gl);
  }
  destroy() {
    const e = this.renderer.view;
    this.renderer = null, e.removeEventListener !== void 0 && (e.removeEventListener("webglcontextlost", this.handleContextLost), e.removeEventListener("webglcontextrestored", this.handleContextRestored)), this.gl.useProgram(null), this.extensions.loseContext && this.extensions.loseContext.loseContext();
  }
  /** Handle the post-render runner event. */
  postrender() {
    this.renderer.objectRenderer.renderingToScreen && this.gl.flush();
  }
  /**
   * Validate context.
   * @param {WebGLRenderingContext} gl - Render context.
   */
  validateContext(e) {
    const t = e.getContextAttributes(), i = "WebGL2RenderingContext" in globalThis && e instanceof globalThis.WebGL2RenderingContext;
    i && (this.webGLVersion = 2), t && !t.stencil && console.warn("Provided WebGL context does not have a stencil buffer, masks may not render correctly");
    const n = i || !!e.getExtension("OES_element_index_uint");
    this.supports.uint32Indices = n, n || console.warn("Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly");
  }
}
la.defaultOptions = {
  /**
   * {@link PIXI.IRendererOptions.context}
   * @default null
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  context: null,
  /**
   * {@link PIXI.IRendererOptions.antialias}
   * @default false
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  antialias: !1,
  /**
   * {@link PIXI.IRendererOptions.premultipliedAlpha}
   * @default true
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  premultipliedAlpha: !0,
  /**
   * {@link PIXI.IRendererOptions.preserveDrawingBuffer}
   * @default false
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  preserveDrawingBuffer: !1,
  /**
   * {@link PIXI.IRendererOptions.powerPreference}
   * @default default
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  powerPreference: "default"
}, /** @ignore */
la.extension = {
  type: q.RendererSystem,
  name: "context"
};
Q.add(la);
class hc {
  /**
   * @param width - Width of the frame buffer
   * @param height - Height of the frame buffer
   */
  constructor(e, t) {
    if (this.width = Math.round(e), this.height = Math.round(t), !this.width || !this.height)
      throw new Error("Framebuffer width or height is zero");
    this.stencil = !1, this.depth = !1, this.dirtyId = 0, this.dirtyFormat = 0, this.dirtySize = 0, this.depthTexture = null, this.colorTextures = [], this.glFramebuffers = {}, this.disposeRunner = new $t("disposeFramebuffer"), this.multisample = Le.NONE;
  }
  /**
   * Reference to the colorTexture.
   * @readonly
   */
  get colorTexture() {
    return this.colorTextures[0];
  }
  /**
   * Add texture to the colorTexture array.
   * @param index - Index of the array to add the texture to
   * @param texture - Texture to add to the array
   */
  addColorTexture(e = 0, t) {
    return this.colorTextures[e] = t || new ae(null, {
      scaleMode: Ai.NEAREST,
      resolution: 1,
      mipmap: gi.OFF,
      width: this.width,
      height: this.height
    }), this.dirtyId++, this.dirtyFormat++, this;
  }
  /**
   * Add a depth texture to the frame buffer.
   * @param texture - Texture to add.
   */
  addDepthTexture(e) {
    return this.depthTexture = e || new ae(null, {
      scaleMode: Ai.NEAREST,
      resolution: 1,
      width: this.width,
      height: this.height,
      mipmap: gi.OFF,
      format: G.DEPTH_COMPONENT,
      type: re.UNSIGNED_SHORT
    }), this.dirtyId++, this.dirtyFormat++, this;
  }
  /** Enable depth on the frame buffer. */
  enableDepth() {
    return this.depth = !0, this.dirtyId++, this.dirtyFormat++, this;
  }
  /** Enable stencil on the frame buffer. */
  enableStencil() {
    return this.stencil = !0, this.dirtyId++, this.dirtyFormat++, this;
  }
  /**
   * Resize the frame buffer
   * @param width - Width of the frame buffer to resize to
   * @param height - Height of the frame buffer to resize to
   */
  resize(e, t) {
    if (e = Math.round(e), t = Math.round(t), !e || !t)
      throw new Error("Framebuffer width and height must not be zero");
    if (!(e === this.width && t === this.height)) {
      this.width = e, this.height = t, this.dirtyId++, this.dirtySize++;
      for (let i = 0; i < this.colorTextures.length; i++) {
        const n = this.colorTextures[i], s = n.resolution;
        n.setSize(e / s, t / s);
      }
      if (this.depthTexture) {
        const i = this.depthTexture.resolution;
        this.depthTexture.setSize(e / i, t / i);
      }
    }
  }
  /** Disposes WebGL resources that are connected to this geometry. */
  dispose() {
    this.disposeRunner.emit(this, !1);
  }
  /** Destroys and removes the depth texture added to this framebuffer. */
  destroyDepthTexture() {
    this.depthTexture && (this.depthTexture.destroy(), this.depthTexture = null, ++this.dirtyId, ++this.dirtyFormat);
  }
}
class Pm extends ae {
  /**
   * @param options
   * @param {number} [options.width=100] - The width of the base render texture.
   * @param {number} [options.height=100] - The height of the base render texture.
   * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES}
   *   for possible values.
   * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio
   *   of the texture being generated.
   * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer.
   */
  constructor(e = {}) {
    if (typeof e == "number") {
      const t = arguments[0], i = arguments[1], n = arguments[2], s = arguments[3];
      e = { width: t, height: i, scaleMode: n, resolution: s };
    }
    e.width = e.width ?? 100, e.height = e.height ?? 100, e.multisample ?? (e.multisample = Le.NONE), super(null, e), this.mipmap = gi.OFF, this.valid = !0, this._clear = new be([0, 0, 0, 0]), this.framebuffer = new hc(this.realWidth, this.realHeight).addColorTexture(0, this), this.framebuffer.multisample = e.multisample, this.maskStack = [], this.filterStack = [{}];
  }
  /** Color when clearning the texture. */
  set clearColor(e) {
    this._clear.setValue(e);
  }
  get clearColor() {
    return this._clear.value;
  }
  /**
   * Color object when clearning the texture.
   * @readonly
   * @since 7.2.0
   */
  get clear() {
    return this._clear;
  }
  /**
   * Shortcut to `this.framebuffer.multisample`.
   * @default PIXI.MSAA_QUALITY.NONE
   */
  get multisample() {
    return this.framebuffer.multisample;
  }
  set multisample(e) {
    this.framebuffer.multisample = e;
  }
  /**
   * Resizes the BaseRenderTexture.
   * @param desiredWidth - The desired width to resize to.
   * @param desiredHeight - The desired height to resize to.
   */
  resize(e, t) {
    this.framebuffer.resize(e * this.resolution, t * this.resolution), this.setRealSize(this.framebuffer.width, this.framebuffer.height);
  }
  /**
   * Frees the texture and framebuffer from WebGL memory without destroying this texture object.
   * This means you can still use the texture later which will upload it to GPU
   * memory again.
   * @fires PIXI.BaseTexture#dispose
   */
  dispose() {
    this.framebuffer.dispose(), super.dispose();
  }
  /** Destroys this texture. */
  destroy() {
    super.destroy(), this.framebuffer.destroyDepthTexture(), this.framebuffer = null;
  }
}
class Bi extends Ds {
  /**
   * @param {PIXI.ImageSourcee} source
   */
  constructor(e) {
    const t = e, i = t.naturalWidth || t.videoWidth || t.displayWidth || t.width, n = t.naturalHeight || t.videoHeight || t.displayHeight || t.height;
    super(i, n), this.source = e, this.noSubImage = !1;
  }
  /**
   * Set cross origin based detecting the url and the crossorigin
   * @param element - Element to apply crossOrigin
   * @param url - URL to check
   * @param crossorigin - Cross origin value to use
   */
  static crossOrigin(e, t, i) {
    i === void 0 && !t.startsWith("data:") ? e.crossOrigin = PA(t) : i !== !1 && (e.crossOrigin = typeof i == "string" ? i : "anonymous");
  }
  /**
   * Upload the texture to the GPU.
   * @param renderer - Upload to the renderer
   * @param baseTexture - Reference to parent texture
   * @param glTexture
   * @param {PIXI.ImageSourcee} [source] - (optional)
   * @returns - true is success
   */
  upload(e, t, i, n) {
    const s = e.gl, o = t.realWidth, a = t.realHeight;
    if (n = n || this.source, typeof HTMLImageElement < "u" && n instanceof HTMLImageElement) {
      if (!n.complete || n.naturalWidth === 0)
        return !1;
    } else if (typeof HTMLVideoElement < "u" && n instanceof HTMLVideoElement && n.readyState <= 1)
      return !1;
    return s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.alphaMode === ut.UNPACK), !this.noSubImage && t.target === s.TEXTURE_2D && i.width === o && i.height === a ? s.texSubImage2D(s.TEXTURE_2D, 0, 0, 0, t.format, i.type, n) : (i.width = o, i.height = a, s.texImage2D(t.target, 0, i.internalFormat, t.format, i.type, n)), !0;
  }
  /**
   * Checks if source width/height was changed, resize can cause extra baseTexture update.
   * Triggers one update in any case.
   */
  update() {
    if (this.destroyed)
      return;
    const e = this.source, t = e.naturalWidth || e.videoWidth || e.width, i = e.naturalHeight || e.videoHeight || e.height;
    this.resize(t, i), super.update();
  }
  /** Destroy this {@link PIXI.BaseImageResource} */
  dispose() {
    this.source = null;
  }
}
class Mm extends Bi {
  /**
   * @param source - image source or URL
   * @param options
   * @param {boolean} [options.autoLoad=true] - start loading process
   * @param {boolean} [options.createBitmap=PIXI.settings.CREATE_IMAGE_BITMAP] - whether its required to create
   *        a bitmap before upload
   * @param {boolean} [options.crossorigin=true] - Load image using cross origin
   * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.UNPACK] - Premultiply image alpha in bitmap
   */
  constructor(e, t) {
    if (t = t || {}, typeof e == "string") {
      const i = new Image();
      Bi.crossOrigin(i, e, t.crossorigin), i.src = e, e = i;
    }
    super(e), !e.complete && this._width && this._height && (this._width = 0, this._height = 0), this.url = e.src, this._process = null, this.preserveBitmap = !1, this.createBitmap = (t.createBitmap ?? Z.CREATE_IMAGE_BITMAP) && !!globalThis.createImageBitmap, this.alphaMode = typeof t.alphaMode == "number" ? t.alphaMode : null, this.bitmap = null, this._load = null, t.autoLoad !== !1 && this.load();
  }
  /**
   * Returns a promise when image will be loaded and processed.
   * @param createBitmap - whether process image into bitmap
   */
  load(e) {
    return this._load ? this._load : (e !== void 0 && (this.createBitmap = e), this._load = new Promise((t, i) => {
      const n = this.source;
      this.url = n.src;
      const s = () => {
        this.destroyed || (n.onload = null, n.onerror = null, this.update(), this._load = null, this.createBitmap ? t(this.process()) : t(this));
      };
      n.complete && n.src ? s() : (n.onload = s, n.onerror = (o) => {
        i(o), this.onError.emit(o);
      });
    }), this._load);
  }
  /**
   * Called when we need to convert image into BitmapImage.
   * Can be called multiple times, real promise is cached inside.
   * @returns - Cached promise to fill that bitmap
   */
  process() {
    const e = this.source;
    if (this._process !== null)
      return this._process;
    if (this.bitmap !== null || !globalThis.createImageBitmap)
      return Promise.resolve(this);
    const t = globalThis.createImageBitmap, i = !e.crossOrigin || e.crossOrigin === "anonymous";
    return this._process = fetch(
      e.src,
      {
        mode: i ? "cors" : "no-cors"
      }
    ).then((n) => n.blob()).then((n) => t(
      n,
      0,
      0,
      e.width,
      e.height,
      {
        premultiplyAlpha: this.alphaMode === null || this.alphaMode === ut.UNPACK ? "premultiply" : "none"
      }
    )).then((n) => this.destroyed ? Promise.reject() : (this.bitmap = n, this.update(), this._process = null, Promise.resolve(this))), this._process;
  }
  /**
   * Upload the image resource to GPU.
   * @param renderer - Renderer to upload to
   * @param baseTexture - BaseTexture for this resource
   * @param glTexture - GLTexture to use
   * @returns {boolean} true is success
   */
  upload(e, t, i) {
    if (typeof this.alphaMode == "number" && (t.alphaMode = this.alphaMode), !this.createBitmap)
      return super.upload(e, t, i);
    if (!this.bitmap && (this.process(), !this.bitmap))
      return !1;
    if (super.upload(e, t, i, this.bitmap), !this.preserveBitmap) {
      let n = !0;
      const s = t._glTextures;
      for (const o in s) {
        const a = s[o];
        if (a !== i && a.dirtyId !== t.dirtyId) {
          n = !1;
          break;
        }
      }
      n && (this.bitmap.close && this.bitmap.close(), this.bitmap = null);
    }
    return !0;
  }
  /** Destroys this resource. */
  dispose() {
    this.source.onload = null, this.source.onerror = null, super.dispose(), this.bitmap && (this.bitmap.close(), this.bitmap = null), this._process = null, this._load = null;
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if current environment support HTMLImageElement, and source is string or HTMLImageElement
   */
  static test(e) {
    return typeof HTMLImageElement < "u" && (typeof e == "string" || e instanceof HTMLImageElement);
  }
}
class su {
  constructor() {
    this.x0 = 0, this.y0 = 0, this.x1 = 1, this.y1 = 0, this.x2 = 1, this.y2 = 1, this.x3 = 0, this.y3 = 1, this.uvsFloat32 = new Float32Array(8);
  }
  /**
   * Sets the texture Uvs based on the given frame information.
   * @protected
   * @param frame - The frame of the texture
   * @param baseFrame - The base frame of the texture
   * @param rotate - Rotation of frame, see {@link PIXI.groupD8}
   */
  set(e, t, i) {
    const n = t.width, s = t.height;
    if (i) {
      const o = e.width / 2 / n, a = e.height / 2 / s, l = e.x / n + o, h = e.y / s + a;
      i = Ce.add(i, Ce.NW), this.x0 = l + o * Ce.uX(i), this.y0 = h + a * Ce.uY(i), i = Ce.add(i, 2), this.x1 = l + o * Ce.uX(i), this.y1 = h + a * Ce.uY(i), i = Ce.add(i, 2), this.x2 = l + o * Ce.uX(i), this.y2 = h + a * Ce.uY(i), i = Ce.add(i, 2), this.x3 = l + o * Ce.uX(i), this.y3 = h + a * Ce.uY(i);
    } else
      this.x0 = e.x / n, this.y0 = e.y / s, this.x1 = (e.x + e.width) / n, this.y1 = e.y / s, this.x2 = (e.x + e.width) / n, this.y2 = (e.y + e.height) / s, this.x3 = e.x / n, this.y3 = (e.y + e.height) / s;
    this.uvsFloat32[0] = this.x0, this.uvsFloat32[1] = this.y0, this.uvsFloat32[2] = this.x1, this.uvsFloat32[3] = this.y1, this.uvsFloat32[4] = this.x2, this.uvsFloat32[5] = this.y2, this.uvsFloat32[6] = this.x3, this.uvsFloat32[7] = this.y3;
  }
}
su.prototype.toString = function() {
  return `[@pixi/core:TextureUvs x0=${this.x0} y0=${this.y0} x1=${this.x1} y1=${this.y1} x2=${this.x2} y2=${this.y2} x3=${this.x3} y3=${this.y3}]`;
};
const Mf = new su();
function ao(r) {
  r.destroy = function() {
  }, r.on = function() {
  }, r.once = function() {
  }, r.emit = function() {
  };
}
class J extends Fs {
  /**
   * @param baseTexture - The base texture source to create the texture from
   * @param frame - The rectangle frame of the texture to show
   * @param orig - The area of original texture
   * @param trim - Trimmed rectangle of original texture
   * @param rotate - indicates how the texture was rotated by texture packer. See {@link PIXI.groupD8}
   * @param anchor - Default anchor point used for sprite placement / rotation
   * @param borders - Default borders used for 9-slice scaling. See {@link PIXI.NineSlicePlane}
   */
  constructor(e, t, i, n, s, o, a) {
    if (super(), this.noFrame = !1, t || (this.noFrame = !0, t = new le(0, 0, 1, 1)), e instanceof J && (e = e.baseTexture), this.baseTexture = e, this._frame = t, this.trim = n, this.valid = !1, this.destroyed = !1, this._uvs = Mf, this.uvMatrix = null, this.orig = i || t, this._rotate = Number(s || 0), s === !0)
      this._rotate = 2;
    else if (this._rotate % 2 !== 0)
      throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");
    this.defaultAnchor = o ? new ge(o.x, o.y) : new ge(0, 0), this.defaultBorders = a, this._updateID = 0, this.textureCacheIds = [], e.valid ? this.noFrame ? e.valid && this.onBaseTextureUpdated(e) : this.frame = t : e.once("loaded", this.onBaseTextureUpdated, this), this.noFrame && e.on("update", this.onBaseTextureUpdated, this);
  }
  /**
   * Updates this texture on the gpu.
   *
   * Calls the TextureResource update.
   *
   * If you adjusted `frame` manually, please call `updateUvs()` instead.
   */
  update() {
    this.baseTexture.resource && this.baseTexture.resource.update();
  }
  /**
   * Called when the base texture is updated
   * @protected
   * @param baseTexture - The base texture.
   */
  onBaseTextureUpdated(e) {
    if (this.noFrame) {
      if (!this.baseTexture.valid)
        return;
      this._frame.width = e.width, this._frame.height = e.height, this.valid = !0, this.updateUvs();
    } else
      this.frame = this._frame;
    this.emit("update", this);
  }
  /**
   * Destroys this texture
   * @param [destroyBase=false] - Whether to destroy the base texture as well
   * @fires PIXI.Texture#destroyed
   */
  destroy(e) {
    if (this.baseTexture) {
      if (e) {
        const { resource: t } = this.baseTexture;
        t != null && t.url && si[t.url] && J.removeFromCache(t.url), this.baseTexture.destroy();
      }
      this.baseTexture.off("loaded", this.onBaseTextureUpdated, this), this.baseTexture.off("update", this.onBaseTextureUpdated, this), this.baseTexture = null;
    }
    this._frame = null, this._uvs = null, this.trim = null, this.orig = null, this.valid = !1, J.removeFromCache(this), this.textureCacheIds = null, this.destroyed = !0, this.emit("destroyed", this), this.removeAllListeners();
  }
  /**
   * Creates a new texture object that acts the same as this one.
   * @returns - The new texture
   */
  clone() {
    var n;
    const e = this._frame.clone(), t = this._frame === this.orig ? e : this.orig.clone(), i = new J(
      this.baseTexture,
      !this.noFrame && e,
      t,
      (n = this.trim) == null ? void 0 : n.clone(),
      this.rotate,
      this.defaultAnchor,
      this.defaultBorders
    );
    return this.noFrame && (i._frame = e), i;
  }
  /**
   * Updates the internal WebGL UV cache. Use it after you change `frame` or `trim` of the texture.
   * Call it after changing the frame
   */
  updateUvs() {
    this._uvs === Mf && (this._uvs = new su()), this._uvs.set(this._frame, this.baseTexture, this.rotate), this._updateID++;
  }
  /**
   * Helper function that creates a new Texture based on the source you provide.
   * The source can be - frame id, image url, video url, canvas element, video element, base texture
   * @param {string|PIXI.BaseTexture|HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas} source -
   *        Source or array of sources to create texture from
   * @param options - See {@link PIXI.BaseTexture}'s constructor for options.
   * @param {string} [options.pixiIdPrefix=pixiid] - If a source has no id, this is the prefix of the generated id
   * @param {boolean} [strict] - Enforce strict-mode, see {@link PIXI.settings.STRICT_TEXTURE_CACHE}.
   * @returns {PIXI.Texture} The newly created texture
   */
  static from(e, t = {}, i = Z.STRICT_TEXTURE_CACHE) {
    const n = typeof e == "string";
    let s = null;
    if (n)
      s = e;
    else if (e instanceof ae) {
      if (!e.cacheId) {
        const a = (t == null ? void 0 : t.pixiIdPrefix) || "pixiid";
        e.cacheId = `${a}-${Hr()}`, ae.addToCache(e, e.cacheId);
      }
      s = e.cacheId;
    } else {
      if (!e._pixiId) {
        const a = (t == null ? void 0 : t.pixiIdPrefix) || "pixiid";
        e._pixiId = `${a}_${Hr()}`;
      }
      s = e._pixiId;
    }
    let o = si[s];
    if (n && i && !o)
      throw new Error(`The cacheId "${s}" does not exist in TextureCache.`);
    return !o && !(e instanceof ae) ? (t.resolution || (t.resolution = Di(e)), o = new J(new ae(e, t)), o.baseTexture.cacheId = s, ae.addToCache(o.baseTexture, s), J.addToCache(o, s)) : !o && e instanceof ae && (o = new J(e), J.addToCache(o, s)), o;
  }
  /**
   * Useful for loading textures via URLs. Use instead of `Texture.from` because
   * it does a better job of handling failed URLs more effectively. This also ignores
   * `PIXI.settings.STRICT_TEXTURE_CACHE`. Works for Videos, SVGs, Images.
   * @param url - The remote URL or array of URLs to load.
   * @param options - Optional options to include
   * @returns - A Promise that resolves to a Texture.
   */
  static fromURL(e, t) {
    const i = Object.assign({ autoLoad: !1 }, t == null ? void 0 : t.resourceOptions), n = J.from(e, Object.assign({ resourceOptions: i }, t), !1), s = n.baseTexture.resource;
    return n.baseTexture.valid ? Promise.resolve(n) : s.load().then(() => Promise.resolve(n));
  }
  /**
   * Create a new Texture with a BufferResource from a typed array.
   * @param buffer - The optional array to use. If no data is provided, a new Float32Array is created.
   * @param width - Width of the resource
   * @param height - Height of the resource
   * @param options - See {@link PIXI.BaseTexture}'s constructor for options.
   *        Default properties are different from the constructor's defaults.
   * @param {PIXI.FORMATS} [options.format] - The format is not given, the type is inferred from the
   *        type of the buffer: `RGBA` if Float32Array, Int8Array, Uint8Array, or Uint8ClampedArray,
   *        otherwise `RGBA_INTEGER`.
   * @param {PIXI.TYPES} [options.type] - The type is not given, the type is inferred from the
   *        type of the buffer. Maps Float32Array to `FLOAT`, Int32Array to `INT`, Uint32Array to
   *        `UNSIGNED_INT`, Int16Array to `SHORT`, Uint16Array to `UNSIGNED_SHORT`, Int8Array to `BYTE`,
   *        Uint8Array/Uint8ClampedArray to `UNSIGNED_BYTE`.
   * @param {PIXI.ALPHA_MODES} [options.alphaMode=PIXI.ALPHA_MODES.NPM]
   * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.SCALE_MODES.NEAREST]
   * @returns - The resulting new BaseTexture
   */
  static fromBuffer(e, t, i, n) {
    return new J(ae.fromBuffer(e, t, i, n));
  }
  /**
   * Create a texture from a source and add to the cache.
   * @param {HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas|string} source - The input source.
   * @param imageUrl - File name of texture, for cache and resolving resolution.
   * @param name - Human readable name for the texture cache. If no name is
   *        specified, only `imageUrl` will be used as the cache ID.
   * @param options
   * @returns - Output texture
   */
  static fromLoader(e, t, i, n) {
    const s = new ae(e, Object.assign({
      scaleMode: ae.defaultOptions.scaleMode,
      resolution: Di(t)
    }, n)), { resource: o } = s;
    o instanceof Mm && (o.url = t);
    const a = new J(s);
    return i || (i = t), ae.addToCache(a.baseTexture, i), J.addToCache(a, i), i !== t && (ae.addToCache(a.baseTexture, t), J.addToCache(a, t)), a.baseTexture.valid ? Promise.resolve(a) : new Promise((l) => {
      a.baseTexture.once("loaded", () => l(a));
    });
  }
  /**
   * Adds a Texture to the global TextureCache. This cache is shared across the whole PIXI object.
   * @param texture - The Texture to add to the cache.
   * @param id - The id that the Texture will be stored against.
   */
  static addToCache(e, t) {
    t && (e.textureCacheIds.includes(t) || e.textureCacheIds.push(t), si[t] && si[t] !== e && console.warn(`Texture added to the cache with an id [${t}] that already had an entry`), si[t] = e);
  }
  /**
   * Remove a Texture from the global TextureCache.
   * @param texture - id of a Texture to be removed, or a Texture instance itself
   * @returns - The Texture that was removed
   */
  static removeFromCache(e) {
    if (typeof e == "string") {
      const t = si[e];
      if (t) {
        const i = t.textureCacheIds.indexOf(e);
        return i > -1 && t.textureCacheIds.splice(i, 1), delete si[e], t;
      }
    } else if (e != null && e.textureCacheIds) {
      for (let t = 0; t < e.textureCacheIds.length; ++t)
        si[e.textureCacheIds[t]] === e && delete si[e.textureCacheIds[t]];
      return e.textureCacheIds.length = 0, e;
    }
    return null;
  }
  /**
   * Returns resolution of baseTexture
   * @readonly
   */
  get resolution() {
    return this.baseTexture.resolution;
  }
  /**
   * The frame specifies the region of the base texture that this texture uses.
   * Please call `updateUvs()` after you change coordinates of `frame` manually.
   */
  get frame() {
    return this._frame;
  }
  set frame(e) {
    this._frame = e, this.noFrame = !1;
    const { x: t, y: i, width: n, height: s } = e, o = t + n > this.baseTexture.width, a = i + s > this.baseTexture.height;
    if (o || a) {
      const l = o && a ? "and" : "or", h = `X: ${t} + ${n} = ${t + n} > ${this.baseTexture.width}`, c = `Y: ${i} + ${s} = ${i + s} > ${this.baseTexture.height}`;
      throw new Error(`Texture Error: frame does not fit inside the base Texture dimensions: ${h} ${l} ${c}`);
    }
    this.valid = n && s && this.baseTexture.valid, !this.trim && !this.rotate && (this.orig = e), this.valid && this.updateUvs();
  }
  /**
   * Indicates whether the texture is rotated inside the atlas
   * set to 2 to compensate for texture packer rotation
   * set to 6 to compensate for spine packer rotation
   * can be used to rotate or mirror sprites
   * See {@link PIXI.groupD8} for explanation
   */
  get rotate() {
    return this._rotate;
  }
  set rotate(e) {
    this._rotate = e, this.valid && this.updateUvs();
  }
  /** The width of the Texture in pixels. */
  get width() {
    return this.orig.width;
  }
  /** The height of the Texture in pixels. */
  get height() {
    return this.orig.height;
  }
  /** Utility function for BaseTexture|Texture cast. */
  castToBaseTexture() {
    return this.baseTexture;
  }
  /** An empty texture, used often to not have to create multiple empty textures. Can not be destroyed. */
  static get EMPTY() {
    return J._EMPTY || (J._EMPTY = new J(new ae()), ao(J._EMPTY), ao(J._EMPTY.baseTexture)), J._EMPTY;
  }
  /** A white texture of 16x16 size, used for graphics and other things Can not be destroyed. */
  static get WHITE() {
    if (!J._WHITE) {
      const e = Z.ADAPTER.createCanvas(16, 16), t = e.getContext("2d");
      e.width = 16, e.height = 16, t.fillStyle = "white", t.fillRect(0, 0, 16, 16), J._WHITE = new J(ae.from(e)), ao(J._WHITE), ao(J._WHITE.baseTexture);
    }
    return J._WHITE;
  }
}
class et extends J {
  /**
   * @param baseRenderTexture - The base texture object that this texture uses.
   * @param frame - The rectangle frame of the texture to show.
   */
  constructor(e, t) {
    super(e, t), this.valid = !0, this.filterFrame = null, this.filterPoolKey = null, this.updateUvs();
  }
  /**
   * Shortcut to `this.baseTexture.framebuffer`, saves baseTexture cast.
   * @readonly
   */
  get framebuffer() {
    return this.baseTexture.framebuffer;
  }
  /**
   * Shortcut to `this.framebuffer.multisample`.
   * @default PIXI.MSAA_QUALITY.NONE
   */
  get multisample() {
    return this.framebuffer.multisample;
  }
  set multisample(e) {
    this.framebuffer.multisample = e;
  }
  /**
   * Resizes the RenderTexture.
   * @param desiredWidth - The desired width to resize to.
   * @param desiredHeight - The desired height to resize to.
   * @param resizeBaseTexture - Should the baseTexture.width and height values be resized as well?
   */
  resize(e, t, i = !0) {
    const n = this.baseTexture.resolution, s = Math.round(e * n) / n, o = Math.round(t * n) / n;
    this.valid = s > 0 && o > 0, this._frame.width = this.orig.width = s, this._frame.height = this.orig.height = o, i && this.baseTexture.resize(s, o), this.updateUvs();
  }
  /**
   * Changes the resolution of baseTexture, but does not change framebuffer size.
   * @param resolution - The new resolution to apply to RenderTexture
   */
  setResolution(e) {
    const { baseTexture: t } = this;
    t.resolution !== e && (t.setResolution(e), this.resize(t.width, t.height, !1));
  }
  /**
   * A short hand way of creating a render texture.
   * @param options - Options
   * @param {number} [options.width=100] - The width of the render texture
   * @param {number} [options.height=100] - The height of the render texture
   * @param {PIXI.SCALE_MODES} [options.scaleMode=PIXI.BaseTexture.defaultOptions.scaleMode] - See {@link PIXI.SCALE_MODES}
   *    for possible values
   * @param {number} [options.resolution=PIXI.settings.RESOLUTION] - The resolution / device pixel ratio of the texture
   *    being generated
   * @param {PIXI.MSAA_QUALITY} [options.multisample=PIXI.MSAA_QUALITY.NONE] - The number of samples of the frame buffer
   * @returns The new render texture
   */
  static create(e) {
    return new et(new Pm(e));
  }
}
class km {
  /**
   * @param textureOptions - options that will be passed to BaseRenderTexture constructor
   * @param {PIXI.SCALE_MODES} [textureOptions.scaleMode] - See {@link PIXI.SCALE_MODES} for possible values.
   */
  constructor(e) {
    this.texturePool = {}, this.textureOptions = e || {}, this.enableFullScreen = !1, this._pixelsWidth = 0, this._pixelsHeight = 0;
  }
  /**
   * Creates texture with params that were specified in pool constructor.
   * @param realWidth - Width of texture in pixels.
   * @param realHeight - Height of texture in pixels.
   * @param multisample - Number of samples of the framebuffer.
   */
  createTexture(e, t, i = Le.NONE) {
    const n = new Pm(Object.assign({
      width: e,
      height: t,
      resolution: 1,
      multisample: i
    }, this.textureOptions));
    return new et(n);
  }
  /**
   * Gets a Power-of-Two render texture or fullScreen texture
   * @param minWidth - The minimum width of the render texture.
   * @param minHeight - The minimum height of the render texture.
   * @param resolution - The resolution of the render texture.
   * @param multisample - Number of samples of the render texture.
   * @returns The new render texture.
   */
  getOptimalTexture(e, t, i = 1, n = Le.NONE) {
    let s;
    e = Math.max(Math.ceil(e * i - 1e-6), 1), t = Math.max(Math.ceil(t * i - 1e-6), 1), !this.enableFullScreen || e !== this._pixelsWidth || t !== this._pixelsHeight ? (e = na(e), t = na(t), s = ((e & 65535) << 16 | t & 65535) >>> 0, n > 1 && (s += n * 4294967296)) : s = n > 1 ? -n : -1, this.texturePool[s] || (this.texturePool[s] = []);
    let o = this.texturePool[s].pop();
    return o || (o = this.createTexture(e, t, n)), o.filterPoolKey = s, o.setResolution(i), o;
  }
  /**
   * Gets extra texture of the same size as input renderTexture
   *
   * `getFilterTexture(input, 0.5)` or `getFilterTexture(0.5, input)`
   * @param input - renderTexture from which size and resolution will be copied
   * @param resolution - override resolution of the renderTexture
   *  It overrides, it does not multiply
   * @param multisample - number of samples of the renderTexture
   */
  getFilterTexture(e, t, i) {
    const n = this.getOptimalTexture(
      e.width,
      e.height,
      t || e.resolution,
      i || Le.NONE
    );
    return n.filterFrame = e.filterFrame, n;
  }
  /**
   * Place a render texture back into the pool.
   * @param renderTexture - The renderTexture to free
   */
  returnTexture(e) {
    const t = e.filterPoolKey;
    e.filterFrame = null, this.texturePool[t].push(e);
  }
  /**
   * Alias for returnTexture, to be compliant with FilterSystem interface.
   * @param renderTexture - The renderTexture to free
   */
  returnFilterTexture(e) {
    this.returnTexture(e);
  }
  /**
   * Clears the pool.
   * @param destroyTextures - Destroy all stored textures.
   */
  clear(e) {
    if (e = e !== !1, e)
      for (const t in this.texturePool) {
        const i = this.texturePool[t];
        if (i)
          for (let n = 0; n < i.length; n++)
            i[n].destroy(!0);
      }
    this.texturePool = {};
  }
  /**
   * If screen size was changed, drops all screen-sized textures,
   * sets new screen size, sets `enableFullScreen` to true
   *
   * Size is measured in pixels, `renderer.view` can be passed here, not `renderer.screen`
   * @param size - Initial size of screen.
   */
  setScreenSize(e) {
    if (!(e.width === this._pixelsWidth && e.height === this._pixelsHeight)) {
      this.enableFullScreen = e.width > 0 && e.height > 0;
      for (const t in this.texturePool) {
        if (!(Number(t) < 0))
          continue;
        const i = this.texturePool[t];
        if (i)
          for (let n = 0; n < i.length; n++)
            i[n].destroy(!0);
        this.texturePool[t] = [];
      }
      this._pixelsWidth = e.width, this._pixelsHeight = e.height;
    }
  }
}
km.SCREEN_KEY = -1;
class lS extends ir {
  constructor() {
    super(), this.addAttribute("aVertexPosition", new Float32Array([
      0,
      0,
      1,
      0,
      1,
      1,
      0,
      1
    ])).addIndex([0, 1, 3, 2]);
  }
}
class Dm extends ir {
  constructor() {
    super(), this.vertices = new Float32Array([
      -1,
      -1,
      1,
      -1,
      1,
      1,
      -1,
      1
    ]), this.uvs = new Float32Array([
      0,
      0,
      1,
      0,
      1,
      1,
      0,
      1
    ]), this.vertexBuffer = new Be(this.vertices), this.uvBuffer = new Be(this.uvs), this.addAttribute("aVertexPosition", this.vertexBuffer).addAttribute("aTextureCoord", this.uvBuffer).addIndex([0, 1, 2, 0, 2, 3]);
  }
  /**
   * Maps two Rectangle to the quad.
   * @param targetTextureFrame - The first rectangle
   * @param destinationFrame - The second rectangle
   * @returns - Returns itself.
   */
  map(e, t) {
    let i = 0, n = 0;
    return this.uvs[0] = i, this.uvs[1] = n, this.uvs[2] = i + t.width / e.width, this.uvs[3] = n, this.uvs[4] = i + t.width / e.width, this.uvs[5] = n + t.height / e.height, this.uvs[6] = i, this.uvs[7] = n + t.height / e.height, i = t.x, n = t.y, this.vertices[0] = i, this.vertices[1] = n, this.vertices[2] = i + t.width, this.vertices[3] = n, this.vertices[4] = i + t.width, this.vertices[5] = n + t.height, this.vertices[6] = i, this.vertices[7] = n + t.height, this.invalidate(), this;
  }
  /**
   * Legacy upload method, just marks buffers dirty.
   * @returns - Returns itself.
   */
  invalidate() {
    return this.vertexBuffer._updateID++, this.uvBuffer._updateID++, this;
  }
}
class hS {
  constructor() {
    this.renderTexture = null, this.target = null, this.legacy = !1, this.resolution = 1, this.multisample = Le.NONE, this.sourceFrame = new le(), this.destinationFrame = new le(), this.bindingSourceFrame = new le(), this.bindingDestinationFrame = new le(), this.filters = [], this.transform = null;
  }
  /** Clears the state */
  clear() {
    this.target = null, this.filters = null, this.renderTexture = null;
  }
}
const lo = [new ge(), new ge(), new ge(), new ge()], $l = new Te();
class Bm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.defaultFilterStack = [{}], this.texturePool = new km(), this.statePool = [], this.quad = new lS(), this.quadUv = new Dm(), this.tempRect = new le(), this.activeState = {}, this.globalUniforms = new Jt({
      outputFrame: new le(),
      inputSize: new Float32Array(4),
      inputPixel: new Float32Array(4),
      inputClamp: new Float32Array(4),
      resolution: 1,
      // legacy variables
      filterArea: new Float32Array(4),
      filterClamp: new Float32Array(4)
    }, !0), this.forceClear = !1, this.useMaxPadding = !1;
  }
  init() {
    this.texturePool.setScreenSize(this.renderer.view);
  }
  /**
   * Pushes a set of filters to be applied later to the system. This will redirect further rendering into an
   * input render-texture for the rest of the filtering pipeline.
   * @param {PIXI.DisplayObject} target - The target of the filter to render.
   * @param filters - The filters to apply.
   */
  push(e, t) {
    const i = this.renderer, n = this.defaultFilterStack, s = this.statePool.pop() || new hS(), o = i.renderTexture;
    let a, l;
    if (o.current) {
      const m = o.current;
      a = m.resolution, l = m.multisample;
    } else
      a = i.resolution, l = i.multisample;
    let h = t[0].resolution || a, c = t[0].multisample ?? l, u = t[0].padding, d = t[0].autoFit, f = t[0].legacy ?? !0;
    for (let m = 1; m < t.length; m++) {
      const y = t[m];
      h = Math.min(h, y.resolution || a), c = Math.min(c, y.multisample ?? l), u = this.useMaxPadding ? Math.max(u, y.padding) : u + y.padding, d = d && y.autoFit, f = f || (y.legacy ?? !0);
    }
    n.length === 1 && (this.defaultFilterStack[0].renderTexture = o.current), n.push(s), s.resolution = h, s.multisample = c, s.legacy = f, s.target = e, s.sourceFrame.copyFrom(e.filterArea || e.getBounds(!0)), s.sourceFrame.pad(u);
    const p = this.tempRect.copyFrom(o.sourceFrame);
    i.projection.transform && this.transformAABB(
      $l.copyFrom(i.projection.transform).invert(),
      p
    ), d ? (s.sourceFrame.fit(p), (s.sourceFrame.width <= 0 || s.sourceFrame.height <= 0) && (s.sourceFrame.width = 0, s.sourceFrame.height = 0)) : s.sourceFrame.intersects(p) || (s.sourceFrame.width = 0, s.sourceFrame.height = 0), this.roundFrame(
      s.sourceFrame,
      o.current ? o.current.resolution : i.resolution,
      o.sourceFrame,
      o.destinationFrame,
      i.projection.transform
    ), s.renderTexture = this.getOptimalFilterTexture(
      s.sourceFrame.width,
      s.sourceFrame.height,
      h,
      c
    ), s.filters = t, s.destinationFrame.width = s.renderTexture.width, s.destinationFrame.height = s.renderTexture.height;
    const _ = this.tempRect;
    _.x = 0, _.y = 0, _.width = s.sourceFrame.width, _.height = s.sourceFrame.height, s.renderTexture.filterFrame = s.sourceFrame, s.bindingSourceFrame.copyFrom(o.sourceFrame), s.bindingDestinationFrame.copyFrom(o.destinationFrame), s.transform = i.projection.transform, i.projection.transform = null, o.bind(s.renderTexture, s.sourceFrame, _), i.framebuffer.clear(0, 0, 0, 0);
  }
  /** Pops off the filter and applies it. */
  pop() {
    const e = this.defaultFilterStack, t = e.pop(), i = t.filters;
    this.activeState = t;
    const n = this.globalUniforms.uniforms;
    n.outputFrame = t.sourceFrame, n.resolution = t.resolution;
    const s = n.inputSize, o = n.inputPixel, a = n.inputClamp;
    if (s[0] = t.destinationFrame.width, s[1] = t.destinationFrame.height, s[2] = 1 / s[0], s[3] = 1 / s[1], o[0] = Math.round(s[0] * t.resolution), o[1] = Math.round(s[1] * t.resolution), o[2] = 1 / o[0], o[3] = 1 / o[1], a[0] = 0.5 * o[2], a[1] = 0.5 * o[3], a[2] = t.sourceFrame.width * s[2] - 0.5 * o[2], a[3] = t.sourceFrame.height * s[3] - 0.5 * o[3], t.legacy) {
      const h = n.filterArea;
      h[0] = t.destinationFrame.width, h[1] = t.destinationFrame.height, h[2] = t.sourceFrame.x, h[3] = t.sourceFrame.y, n.filterClamp = n.inputClamp;
    }
    this.globalUniforms.update();
    const l = e[e.length - 1];
    if (this.renderer.framebuffer.blit(), i.length === 1)
      i[0].apply(this, t.renderTexture, l.renderTexture, ci.BLEND, t), this.returnFilterTexture(t.renderTexture);
    else {
      let h = t.renderTexture, c = this.getOptimalFilterTexture(
        h.width,
        h.height,
        t.resolution
      );
      c.filterFrame = h.filterFrame;
      let u = 0;
      for (u = 0; u < i.length - 1; ++u) {
        u === 1 && t.multisample > 1 && (c = this.getOptimalFilterTexture(
          h.width,
          h.height,
          t.resolution
        ), c.filterFrame = h.filterFrame), i[u].apply(this, h, c, ci.CLEAR, t);
        const d = h;
        h = c, c = d;
      }
      i[u].apply(this, h, l.renderTexture, ci.BLEND, t), u > 1 && t.multisample > 1 && this.returnFilterTexture(t.renderTexture), this.returnFilterTexture(h), this.returnFilterTexture(c);
    }
    t.clear(), this.statePool.push(t);
  }
  /**
   * Binds a renderTexture with corresponding `filterFrame`, clears it if mode corresponds.
   * @param filterTexture - renderTexture to bind, should belong to filter pool or filter stack
   * @param clearMode - clearMode, by default its CLEAR/YES. See {@link PIXI.CLEAR_MODES}
   */
  bindAndClear(e, t = ci.CLEAR) {
    const {
      renderTexture: i,
      state: n
    } = this.renderer;
    if (e === this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture ? this.renderer.projection.transform = this.activeState.transform : this.renderer.projection.transform = null, e == null ? void 0 : e.filterFrame) {
      const o = this.tempRect;
      o.x = 0, o.y = 0, o.width = e.filterFrame.width, o.height = e.filterFrame.height, i.bind(e, e.filterFrame, o);
    } else
      e !== this.defaultFilterStack[this.defaultFilterStack.length - 1].renderTexture ? i.bind(e) : this.renderer.renderTexture.bind(
        e,
        this.activeState.bindingSourceFrame,
        this.activeState.bindingDestinationFrame
      );
    const s = n.stateId & 1 || this.forceClear;
    (t === ci.CLEAR || t === ci.BLIT && s) && this.renderer.framebuffer.clear(0, 0, 0, 0);
  }
  /**
   * Draws a filter using the default rendering process.
   *
   * This should be called only by {@link PIXI.Filter#apply}.
   * @param filter - The filter to draw.
   * @param input - The input render target.
   * @param output - The target to output to.
   * @param clearMode - Should the output be cleared before rendering to it
   */
  applyFilter(e, t, i, n) {
    const s = this.renderer;
    s.state.set(e.state), this.bindAndClear(i, n), e.uniforms.uSampler = t, e.uniforms.filterGlobals = this.globalUniforms, s.shader.bind(e), e.legacy = !!e.program.attributeData.aTextureCoord, e.legacy ? (this.quadUv.map(t._frame, t.filterFrame), s.geometry.bind(this.quadUv), s.geometry.draw(pi.TRIANGLES)) : (s.geometry.bind(this.quad), s.geometry.draw(pi.TRIANGLE_STRIP));
  }
  /**
   * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
   *
   * Use `outputMatrix * vTextureCoord` in the shader.
   * @param outputMatrix - The matrix to output to.
   * @param {PIXI.Sprite} sprite - The sprite to map to.
   * @returns The mapped matrix.
   */
  calculateSpriteMatrix(e, t) {
    const { sourceFrame: i, destinationFrame: n } = this.activeState, { orig: s } = t._texture, o = e.set(
      n.width,
      0,
      0,
      n.height,
      i.x,
      i.y
    ), a = t.worldTransform.copyTo(Te.TEMP_MATRIX);
    return a.invert(), o.prepend(a), o.scale(1 / s.width, 1 / s.height), o.translate(t.anchor.x, t.anchor.y), o;
  }
  /** Destroys this Filter System. */
  destroy() {
    this.renderer = null, this.texturePool.clear(!1);
  }
  /**
   * Gets a Power-of-Two render texture or fullScreen texture
   * @param minWidth - The minimum width of the render texture in real pixels.
   * @param minHeight - The minimum height of the render texture in real pixels.
   * @param resolution - The resolution of the render texture.
   * @param multisample - Number of samples of the render texture.
   * @returns - The new render texture.
   */
  getOptimalFilterTexture(e, t, i = 1, n = Le.NONE) {
    return this.texturePool.getOptimalTexture(e, t, i, n);
  }
  /**
   * Gets extra render texture to use inside current filter
   * To be compliant with older filters, you can use params in any order
   * @param input - renderTexture from which size and resolution will be copied
   * @param resolution - override resolution of the renderTexture
   * @param multisample - number of samples of the renderTexture
   */
  getFilterTexture(e, t, i) {
    if (typeof e == "number") {
      const s = e;
      e = t, t = s;
    }
    e = e || this.activeState.renderTexture;
    const n = this.texturePool.getOptimalTexture(
      e.width,
      e.height,
      t || e.resolution,
      i || Le.NONE
    );
    return n.filterFrame = e.filterFrame, n;
  }
  /**
   * Frees a render texture back into the pool.
   * @param renderTexture - The renderTarget to free
   */
  returnFilterTexture(e) {
    this.texturePool.returnTexture(e);
  }
  /** Empties the texture pool. */
  emptyPool() {
    this.texturePool.clear(!0);
  }
  /** Calls `texturePool.resize()`, affects fullScreen renderTextures. */
  resize() {
    this.texturePool.setScreenSize(this.renderer.view);
  }
  /**
   * @param matrix - first param
   * @param rect - second param
   */
  transformAABB(e, t) {
    const i = lo[0], n = lo[1], s = lo[2], o = lo[3];
    i.set(t.left, t.top), n.set(t.left, t.bottom), s.set(t.right, t.top), o.set(t.right, t.bottom), e.apply(i, i), e.apply(n, n), e.apply(s, s), e.apply(o, o);
    const a = Math.min(i.x, n.x, s.x, o.x), l = Math.min(i.y, n.y, s.y, o.y), h = Math.max(i.x, n.x, s.x, o.x), c = Math.max(i.y, n.y, s.y, o.y);
    t.x = a, t.y = l, t.width = h - a, t.height = c - l;
  }
  roundFrame(e, t, i, n, s) {
    if (!(e.width <= 0 || e.height <= 0 || i.width <= 0 || i.height <= 0)) {
      if (s) {
        const { a: o, b: a, c: l, d: h } = s;
        if ((Math.abs(a) > 1e-4 || Math.abs(l) > 1e-4) && (Math.abs(o) > 1e-4 || Math.abs(h) > 1e-4))
          return;
      }
      s = s ? $l.copyFrom(s) : $l.identity(), s.translate(-i.x, -i.y).scale(
        n.width / i.width,
        n.height / i.height
      ).translate(n.x, n.y), this.transformAABB(s, e), e.ceil(t), this.transformAABB(s.invert(), e);
    }
  }
}
Bm.extension = {
  type: q.RendererSystem,
  name: "filter"
};
Q.add(Bm);
class cS {
  constructor(e) {
    this.framebuffer = e, this.stencil = null, this.dirtyId = -1, this.dirtyFormat = -1, this.dirtySize = -1, this.multisample = Le.NONE, this.msaaBuffer = null, this.blitFramebuffer = null, this.mipLevel = 0;
  }
}
const uS = new le();
class Fm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.managedFramebuffers = [], this.unknownFramebuffer = new hc(10, 10), this.msaaSamples = null;
  }
  /** Sets up the renderer context and necessary buffers. */
  contextChange() {
    this.disposeAll(!0);
    const e = this.gl = this.renderer.gl;
    if (this.CONTEXT_UID = this.renderer.CONTEXT_UID, this.current = this.unknownFramebuffer, this.viewport = new le(), this.hasMRT = !0, this.writeDepthTexture = !0, this.renderer.context.webGLVersion === 1) {
      let t = this.renderer.context.extensions.drawBuffers, i = this.renderer.context.extensions.depthTexture;
      Z.PREFER_ENV === qr.WEBGL_LEGACY && (t = null, i = null), t ? e.drawBuffers = (n) => t.drawBuffersWEBGL(n) : (this.hasMRT = !1, e.drawBuffers = () => {
      }), i || (this.writeDepthTexture = !1);
    } else
      this.msaaSamples = e.getInternalformatParameter(e.RENDERBUFFER, e.RGBA8, e.SAMPLES);
  }
  /**
   * Bind a framebuffer.
   * @param framebuffer
   * @param frame - frame, default is framebuffer size
   * @param mipLevel - optional mip level to set on the framebuffer - defaults to 0
   */
  bind(e, t, i = 0) {
    const { gl: n } = this;
    if (e) {
      const s = e.glFramebuffers[this.CONTEXT_UID] || this.initFramebuffer(e);
      this.current !== e && (this.current = e, n.bindFramebuffer(n.FRAMEBUFFER, s.framebuffer)), s.mipLevel !== i && (e.dirtyId++, e.dirtyFormat++, s.mipLevel = i), s.dirtyId !== e.dirtyId && (s.dirtyId = e.dirtyId, s.dirtyFormat !== e.dirtyFormat ? (s.dirtyFormat = e.dirtyFormat, s.dirtySize = e.dirtySize, this.updateFramebuffer(e, i)) : s.dirtySize !== e.dirtySize && (s.dirtySize = e.dirtySize, this.resizeFramebuffer(e)));
      for (let o = 0; o < e.colorTextures.length; o++) {
        const a = e.colorTextures[o];
        this.renderer.texture.unbind(a.parentTextureArray || a);
      }
      if (e.depthTexture && this.renderer.texture.unbind(e.depthTexture), t) {
        const o = t.width >> i, a = t.height >> i, l = o / t.width;
        this.setViewport(
          t.x * l,
          t.y * l,
          o,
          a
        );
      } else {
        const o = e.width >> i, a = e.height >> i;
        this.setViewport(0, 0, o, a);
      }
    } else
      this.current && (this.current = null, n.bindFramebuffer(n.FRAMEBUFFER, null)), t ? this.setViewport(t.x, t.y, t.width, t.height) : this.setViewport(0, 0, this.renderer.width, this.renderer.height);
  }
  /**
   * Set the WebGLRenderingContext's viewport.
   * @param x - X position of viewport
   * @param y - Y position of viewport
   * @param width - Width of viewport
   * @param height - Height of viewport
   */
  setViewport(e, t, i, n) {
    const s = this.viewport;
    e = Math.round(e), t = Math.round(t), i = Math.round(i), n = Math.round(n), (s.width !== i || s.height !== n || s.x !== e || s.y !== t) && (s.x = e, s.y = t, s.width = i, s.height = n, this.gl.viewport(e, t, i, n));
  }
  /**
   * Get the size of the current width and height. Returns object with `width` and `height` values.
   * @readonly
   */
  get size() {
    return this.current ? { x: 0, y: 0, width: this.current.width, height: this.current.height } : { x: 0, y: 0, width: this.renderer.width, height: this.renderer.height };
  }
  /**
   * Clear the color of the context
   * @param r - Red value from 0 to 1
   * @param g - Green value from 0 to 1
   * @param b - Blue value from 0 to 1
   * @param a - Alpha value from 0 to 1
   * @param {PIXI.BUFFER_BITS} [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks
   *  that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.
   */
  clear(e, t, i, n, s = Oh.COLOR | Oh.DEPTH) {
    const { gl: o } = this;
    o.clearColor(e, t, i, n), o.clear(s);
  }
  /**
   * Initialize framebuffer for this context
   * @protected
   * @param framebuffer
   * @returns - created GLFramebuffer
   */
  initFramebuffer(e) {
    const { gl: t } = this, i = new cS(t.createFramebuffer());
    return i.multisample = this.detectSamples(e.multisample), e.glFramebuffers[this.CONTEXT_UID] = i, this.managedFramebuffers.push(e), e.disposeRunner.add(this), i;
  }
  /**
   * Resize the framebuffer
   * @param framebuffer
   * @protected
   */
  resizeFramebuffer(e) {
    const { gl: t } = this, i = e.glFramebuffers[this.CONTEXT_UID];
    if (i.stencil) {
      t.bindRenderbuffer(t.RENDERBUFFER, i.stencil);
      let o;
      this.renderer.context.webGLVersion === 1 ? o = t.DEPTH_STENCIL : e.depth && e.stencil ? o = t.DEPTH24_STENCIL8 : e.depth ? o = t.DEPTH_COMPONENT24 : o = t.STENCIL_INDEX8, i.msaaBuffer ? t.renderbufferStorageMultisample(
        t.RENDERBUFFER,
        i.multisample,
        o,
        e.width,
        e.height
      ) : t.renderbufferStorage(t.RENDERBUFFER, o, e.width, e.height);
    }
    const n = e.colorTextures;
    let s = n.length;
    t.drawBuffers || (s = Math.min(s, 1));
    for (let o = 0; o < s; o++) {
      const a = n[o], l = a.parentTextureArray || a;
      this.renderer.texture.bind(l, 0), o === 0 && i.msaaBuffer && (t.bindRenderbuffer(t.RENDERBUFFER, i.msaaBuffer), t.renderbufferStorageMultisample(
        t.RENDERBUFFER,
        i.multisample,
        l._glTextures[this.CONTEXT_UID].internalFormat,
        e.width,
        e.height
      ));
    }
    e.depthTexture && this.writeDepthTexture && this.renderer.texture.bind(e.depthTexture, 0);
  }
  /**
   * Update the framebuffer
   * @param framebuffer
   * @param mipLevel
   * @protected
   */
  updateFramebuffer(e, t) {
    const { gl: i } = this, n = e.glFramebuffers[this.CONTEXT_UID], s = e.colorTextures;
    let o = s.length;
    i.drawBuffers || (o = Math.min(o, 1)), n.multisample > 1 && this.canMultisampleFramebuffer(e) ? n.msaaBuffer = n.msaaBuffer || i.createRenderbuffer() : n.msaaBuffer && (i.deleteRenderbuffer(n.msaaBuffer), n.msaaBuffer = null, n.blitFramebuffer && (n.blitFramebuffer.dispose(), n.blitFramebuffer = null));
    const a = [];
    for (let l = 0; l < o; l++) {
      const h = s[l], c = h.parentTextureArray || h;
      this.renderer.texture.bind(c, 0), l === 0 && n.msaaBuffer ? (i.bindRenderbuffer(i.RENDERBUFFER, n.msaaBuffer), i.renderbufferStorageMultisample(
        i.RENDERBUFFER,
        n.multisample,
        c._glTextures[this.CONTEXT_UID].internalFormat,
        e.width,
        e.height
      ), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.RENDERBUFFER, n.msaaBuffer)) : (i.framebufferTexture2D(
        i.FRAMEBUFFER,
        i.COLOR_ATTACHMENT0 + l,
        h.target,
        c._glTextures[this.CONTEXT_UID].texture,
        t
      ), a.push(i.COLOR_ATTACHMENT0 + l));
    }
    if (a.length > 1 && i.drawBuffers(a), e.depthTexture && this.writeDepthTexture) {
      const l = e.depthTexture;
      this.renderer.texture.bind(l, 0), i.framebufferTexture2D(
        i.FRAMEBUFFER,
        i.DEPTH_ATTACHMENT,
        i.TEXTURE_2D,
        l._glTextures[this.CONTEXT_UID].texture,
        t
      );
    }
    if ((e.stencil || e.depth) && !(e.depthTexture && this.writeDepthTexture)) {
      n.stencil = n.stencil || i.createRenderbuffer();
      let l, h;
      this.renderer.context.webGLVersion === 1 ? (l = i.DEPTH_STENCIL_ATTACHMENT, h = i.DEPTH_STENCIL) : e.depth && e.stencil ? (l = i.DEPTH_STENCIL_ATTACHMENT, h = i.DEPTH24_STENCIL8) : e.depth ? (l = i.DEPTH_ATTACHMENT, h = i.DEPTH_COMPONENT24) : (l = i.STENCIL_ATTACHMENT, h = i.STENCIL_INDEX8), i.bindRenderbuffer(i.RENDERBUFFER, n.stencil), n.msaaBuffer ? i.renderbufferStorageMultisample(
        i.RENDERBUFFER,
        n.multisample,
        h,
        e.width,
        e.height
      ) : i.renderbufferStorage(i.RENDERBUFFER, h, e.width, e.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, l, i.RENDERBUFFER, n.stencil);
    } else
      n.stencil && (i.deleteRenderbuffer(n.stencil), n.stencil = null);
  }
  /**
   * Returns true if the frame buffer can be multisampled.
   * @param framebuffer
   */
  canMultisampleFramebuffer(e) {
    return this.renderer.context.webGLVersion !== 1 && e.colorTextures.length <= 1 && !e.depthTexture;
  }
  /**
   * Detects number of samples that is not more than a param but as close to it as possible
   * @param samples - number of samples
   * @returns - recommended number of samples
   */
  detectSamples(e) {
    const { msaaSamples: t } = this;
    let i = Le.NONE;
    if (e <= 1 || t === null)
      return i;
    for (let n = 0; n < t.length; n++)
      if (t[n] <= e) {
        i = t[n];
        break;
      }
    return i === 1 && (i = Le.NONE), i;
  }
  /**
   * Only works with WebGL2
   *
   * blits framebuffer to another of the same or bigger size
   * after that target framebuffer is bound
   *
   * Fails with WebGL warning if blits multisample framebuffer to different size
   * @param framebuffer - by default it blits "into itself", from renderBuffer to texture.
   * @param sourcePixels - source rectangle in pixels
   * @param destPixels - dest rectangle in pixels, assumed to be the same as sourcePixels
   */
  blit(e, t, i) {
    const { current: n, renderer: s, gl: o, CONTEXT_UID: a } = this;
    if (s.context.webGLVersion !== 2 || !n)
      return;
    const l = n.glFramebuffers[a];
    if (!l)
      return;
    if (!e) {
      if (!l.msaaBuffer)
        return;
      const c = n.colorTextures[0];
      if (!c)
        return;
      l.blitFramebuffer || (l.blitFramebuffer = new hc(n.width, n.height), l.blitFramebuffer.addColorTexture(0, c)), e = l.blitFramebuffer, e.colorTextures[0] !== c && (e.colorTextures[0] = c, e.dirtyId++, e.dirtyFormat++), (e.width !== n.width || e.height !== n.height) && (e.width = n.width, e.height = n.height, e.dirtyId++, e.dirtySize++);
    }
    t || (t = uS, t.width = n.width, t.height = n.height), i || (i = t);
    const h = t.width === i.width && t.height === i.height;
    this.bind(e), o.bindFramebuffer(o.READ_FRAMEBUFFER, l.framebuffer), o.blitFramebuffer(
      t.left,
      t.top,
      t.right,
      t.bottom,
      i.left,
      i.top,
      i.right,
      i.bottom,
      o.COLOR_BUFFER_BIT,
      h ? o.NEAREST : o.LINEAR
    ), o.bindFramebuffer(o.READ_FRAMEBUFFER, e.glFramebuffers[this.CONTEXT_UID].framebuffer);
  }
  /**
   * Disposes framebuffer.
   * @param framebuffer - framebuffer that has to be disposed of
   * @param contextLost - If context was lost, we suppress all delete function calls
   */
  disposeFramebuffer(e, t) {
    const i = e.glFramebuffers[this.CONTEXT_UID], n = this.gl;
    if (!i)
      return;
    delete e.glFramebuffers[this.CONTEXT_UID];
    const s = this.managedFramebuffers.indexOf(e);
    s >= 0 && this.managedFramebuffers.splice(s, 1), e.disposeRunner.remove(this), t || (n.deleteFramebuffer(i.framebuffer), i.msaaBuffer && n.deleteRenderbuffer(i.msaaBuffer), i.stencil && n.deleteRenderbuffer(i.stencil)), i.blitFramebuffer && this.disposeFramebuffer(i.blitFramebuffer, t);
  }
  /**
   * Disposes all framebuffers, but not textures bound to them.
   * @param [contextLost=false] - If context was lost, we suppress all delete function calls
   */
  disposeAll(e) {
    const t = this.managedFramebuffers;
    this.managedFramebuffers = [];
    for (let i = 0; i < t.length; i++)
      this.disposeFramebuffer(t[i], e);
  }
  /**
   * Forcing creation of stencil buffer for current framebuffer, if it wasn't done before.
   * Used by MaskSystem, when its time to use stencil mask for Graphics element.
   *
   * Its an alternative for public lazy `framebuffer.enableStencil`, in case we need stencil without rebind.
   * @private
   */
  forceStencil() {
    const e = this.current;
    if (!e)
      return;
    const t = e.glFramebuffers[this.CONTEXT_UID];
    if (!t || t.stencil && e.stencil)
      return;
    e.stencil = !0;
    const i = e.width, n = e.height, s = this.gl, o = t.stencil = s.createRenderbuffer();
    s.bindRenderbuffer(s.RENDERBUFFER, o);
    let a, l;
    this.renderer.context.webGLVersion === 1 ? (a = s.DEPTH_STENCIL_ATTACHMENT, l = s.DEPTH_STENCIL) : e.depth ? (a = s.DEPTH_STENCIL_ATTACHMENT, l = s.DEPTH24_STENCIL8) : (a = s.STENCIL_ATTACHMENT, l = s.STENCIL_INDEX8), t.msaaBuffer ? s.renderbufferStorageMultisample(s.RENDERBUFFER, t.multisample, l, i, n) : s.renderbufferStorage(s.RENDERBUFFER, l, i, n), s.framebufferRenderbuffer(s.FRAMEBUFFER, a, s.RENDERBUFFER, o);
  }
  /** Resets framebuffer stored state, binds screen framebuffer. Should be called before renderTexture reset(). */
  reset() {
    this.current = this.unknownFramebuffer, this.viewport = new le();
  }
  destroy() {
    this.renderer = null;
  }
}
Fm.extension = {
  type: q.RendererSystem,
  name: "framebuffer"
};
Q.add(Fm);
const Jl = { 5126: 4, 5123: 2, 5121: 1 };
class Om {
  /** @param renderer - The renderer this System works for. */
  constructor(e) {
    this.renderer = e, this._activeGeometry = null, this._activeVao = null, this.hasVao = !0, this.hasInstance = !0, this.canUseUInt32ElementIndex = !1, this.managedGeometries = {};
  }
  /** Sets up the renderer context and necessary buffers. */
  contextChange() {
    this.disposeAll(!0);
    const e = this.gl = this.renderer.gl, t = this.renderer.context;
    if (this.CONTEXT_UID = this.renderer.CONTEXT_UID, t.webGLVersion !== 2) {
      let i = this.renderer.context.extensions.vertexArrayObject;
      Z.PREFER_ENV === qr.WEBGL_LEGACY && (i = null), i ? (e.createVertexArray = () => i.createVertexArrayOES(), e.bindVertexArray = (n) => i.bindVertexArrayOES(n), e.deleteVertexArray = (n) => i.deleteVertexArrayOES(n)) : (this.hasVao = !1, e.createVertexArray = () => null, e.bindVertexArray = () => null, e.deleteVertexArray = () => null);
    }
    if (t.webGLVersion !== 2) {
      const i = e.getExtension("ANGLE_instanced_arrays");
      i ? (e.vertexAttribDivisor = (n, s) => i.vertexAttribDivisorANGLE(n, s), e.drawElementsInstanced = (n, s, o, a, l) => i.drawElementsInstancedANGLE(n, s, o, a, l), e.drawArraysInstanced = (n, s, o, a) => i.drawArraysInstancedANGLE(n, s, o, a)) : this.hasInstance = !1;
    }
    this.canUseUInt32ElementIndex = t.webGLVersion === 2 || !!t.extensions.uint32ElementIndex;
  }
  /**
   * Binds geometry so that is can be drawn. Creating a Vao if required
   * @param geometry - Instance of geometry to bind.
   * @param shader - Instance of shader to use vao for.
   */
  bind(e, t) {
    t = t || this.renderer.shader.shader;
    const { gl: i } = this;
    let n = e.glVertexArrayObjects[this.CONTEXT_UID], s = !1;
    n || (this.managedGeometries[e.id] = e, e.disposeRunner.add(this), e.glVertexArrayObjects[this.CONTEXT_UID] = n = {}, s = !0);
    const o = n[t.program.id] || this.initGeometryVao(e, t, s);
    this._activeGeometry = e, this._activeVao !== o && (this._activeVao = o, this.hasVao ? i.bindVertexArray(o) : this.activateVao(e, t.program)), this.updateBuffers();
  }
  /** Reset and unbind any active VAO and geometry. */
  reset() {
    this.unbind();
  }
  /** Update buffers of the currently bound geometry. */
  updateBuffers() {
    const e = this._activeGeometry, t = this.renderer.buffer;
    for (let i = 0; i < e.buffers.length; i++) {
      const n = e.buffers[i];
      t.update(n);
    }
  }
  /**
   * Check compatibility between a geometry and a program
   * @param geometry - Geometry instance.
   * @param program - Program instance.
   */
  checkCompatibility(e, t) {
    const i = e.attributes, n = t.attributeData;
    for (const s in n)
      if (!i[s])
        throw new Error(`shader and geometry incompatible, geometry missing the "${s}" attribute`);
  }
  /**
   * Takes a geometry and program and generates a unique signature for them.
   * @param geometry - To get signature from.
   * @param program - To test geometry against.
   * @returns - Unique signature of the geometry and program
   */
  getSignature(e, t) {
    const i = e.attributes, n = t.attributeData, s = ["g", e.id];
    for (const o in i)
      n[o] && s.push(o, n[o].location);
    return s.join("-");
  }
  /**
   * Creates or gets Vao with the same structure as the geometry and stores it on the geometry.
   * If vao is created, it is bound automatically. We use a shader to infer what and how to set up the
   * attribute locations.
   * @param geometry - Instance of geometry to to generate Vao for.
   * @param shader - Instance of the shader.
   * @param incRefCount - Increment refCount of all geometry buffers.
   */
  initGeometryVao(e, t, i = !0) {
    const n = this.gl, s = this.CONTEXT_UID, o = this.renderer.buffer, a = t.program;
    a.glPrograms[s] || this.renderer.shader.generateProgram(t), this.checkCompatibility(e, a);
    const l = this.getSignature(e, a), h = e.glVertexArrayObjects[this.CONTEXT_UID];
    let c = h[l];
    if (c)
      return h[a.id] = c, c;
    const u = e.buffers, d = e.attributes, f = {}, p = {};
    for (const _ in u)
      f[_] = 0, p[_] = 0;
    for (const _ in d)
      !d[_].size && a.attributeData[_] ? d[_].size = a.attributeData[_].size : d[_].size || console.warn(`PIXI Geometry attribute '${_}' size cannot be determined (likely the bound shader does not have the attribute)`), f[d[_].buffer] += d[_].size * Jl[d[_].type];
    for (const _ in d) {
      const m = d[_], y = m.size;
      m.stride === void 0 && (f[m.buffer] === y * Jl[m.type] ? m.stride = 0 : m.stride = f[m.buffer]), m.start === void 0 && (m.start = p[m.buffer], p[m.buffer] += y * Jl[m.type]);
    }
    c = n.createVertexArray(), n.bindVertexArray(c);
    for (let _ = 0; _ < u.length; _++) {
      const m = u[_];
      o.bind(m), i && m._glBuffers[s].refCount++;
    }
    return this.activateVao(e, a), h[a.id] = c, h[l] = c, n.bindVertexArray(null), o.unbind(_i.ARRAY_BUFFER), c;
  }
  /**
   * Disposes geometry.
   * @param geometry - Geometry with buffers. Only VAO will be disposed
   * @param [contextLost=false] - If context was lost, we suppress deleteVertexArray
   */
  disposeGeometry(e, t) {
    var a;
    if (!this.managedGeometries[e.id])
      return;
    delete this.managedGeometries[e.id];
    const i = e.glVertexArrayObjects[this.CONTEXT_UID], n = this.gl, s = e.buffers, o = (a = this.renderer) == null ? void 0 : a.buffer;
    if (e.disposeRunner.remove(this), !!i) {
      if (o)
        for (let l = 0; l < s.length; l++) {
          const h = s[l]._glBuffers[this.CONTEXT_UID];
          h && (h.refCount--, h.refCount === 0 && !t && o.dispose(s[l], t));
        }
      if (!t) {
        for (const l in i)
          if (l[0] === "g") {
            const h = i[l];
            this._activeVao === h && this.unbind(), n.deleteVertexArray(h);
          }
      }
      delete e.glVertexArrayObjects[this.CONTEXT_UID];
    }
  }
  /**
   * Dispose all WebGL resources of all managed geometries.
   * @param [contextLost=false] - If context was lost, we suppress `gl.delete` calls
   */
  disposeAll(e) {
    const t = Object.keys(this.managedGeometries);
    for (let i = 0; i < t.length; i++)
      this.disposeGeometry(this.managedGeometries[t[i]], e);
  }
  /**
   * Activate vertex array object.
   * @param geometry - Geometry instance.
   * @param program - Shader program instance.
   */
  activateVao(e, t) {
    const i = this.gl, n = this.CONTEXT_UID, s = this.renderer.buffer, o = e.buffers, a = e.attributes;
    e.indexBuffer && s.bind(e.indexBuffer);
    let l = null;
    for (const h in a) {
      const c = a[h], u = o[c.buffer], d = u._glBuffers[n];
      if (t.attributeData[h]) {
        l !== d && (s.bind(u), l = d);
        const f = t.attributeData[h].location;
        if (i.enableVertexAttribArray(f), i.vertexAttribPointer(
          f,
          c.size,
          c.type || i.FLOAT,
          c.normalized,
          c.stride,
          c.start
        ), c.instance)
          if (this.hasInstance)
            i.vertexAttribDivisor(f, c.divisor);
          else
            throw new Error("geometry error, GPU Instancing is not supported on this device");
      }
    }
  }
  /**
   * Draws the currently bound geometry.
   * @param type - The type primitive to render.
   * @param size - The number of elements to be rendered. If not specified, all vertices after the
   *  starting vertex will be drawn.
   * @param start - The starting vertex in the geometry to start drawing from. If not specified,
   *  drawing will start from the first vertex.
   * @param instanceCount - The number of instances of the set of elements to execute. If not specified,
   *  all instances will be drawn.
   */
  draw(e, t, i, n) {
    const { gl: s } = this, o = this._activeGeometry;
    if (o.indexBuffer) {
      const a = o.indexBuffer.data.BYTES_PER_ELEMENT, l = a === 2 ? s.UNSIGNED_SHORT : s.UNSIGNED_INT;
      a === 2 || a === 4 && this.canUseUInt32ElementIndex ? o.instanced ? s.drawElementsInstanced(e, t || o.indexBuffer.data.length, l, (i || 0) * a, n || 1) : s.drawElements(e, t || o.indexBuffer.data.length, l, (i || 0) * a) : console.warn("unsupported index buffer type: uint32");
    } else
      o.instanced ? s.drawArraysInstanced(e, i, t || o.getSize(), n || 1) : s.drawArrays(e, i, t || o.getSize());
    return this;
  }
  /** Unbind/reset everything. */
  unbind() {
    this.gl.bindVertexArray(null), this._activeVao = null, this._activeGeometry = null;
  }
  destroy() {
    this.renderer = null;
  }
}
Om.extension = {
  type: q.RendererSystem,
  name: "geometry"
};
Q.add(Om);
const kf = new Te();
class Lm {
  /**
   * @param texture - observed texture
   * @param clampMargin - Changes frame clamping, 0.5 by default. Use -0.5 for extra border.
   */
  constructor(e, t) {
    this._texture = e, this.mapCoord = new Te(), this.uClampFrame = new Float32Array(4), this.uClampOffset = new Float32Array(2), this._textureID = -1, this._updateID = 0, this.clampOffset = 0, this.clampMargin = typeof t > "u" ? 0.5 : t, this.isSimple = !1;
  }
  /** Texture property. */
  get texture() {
    return this._texture;
  }
  set texture(e) {
    this._texture = e, this._textureID = -1;
  }
  /**
   * Multiplies uvs array to transform
   * @param uvs - mesh uvs
   * @param [out=uvs] - output
   * @returns - output
   */
  multiplyUvs(e, t) {
    t === void 0 && (t = e);
    const i = this.mapCoord;
    for (let n = 0; n < e.length; n += 2) {
      const s = e[n], o = e[n + 1];
      t[n] = s * i.a + o * i.c + i.tx, t[n + 1] = s * i.b + o * i.d + i.ty;
    }
    return t;
  }
  /**
   * Updates matrices if texture was changed.
   * @param [forceUpdate=false] - if true, matrices will be updated any case
   * @returns - Whether or not it was updated
   */
  update(e) {
    const t = this._texture;
    if (!t || !t.valid || !e && this._textureID === t._updateID)
      return !1;
    this._textureID = t._updateID, this._updateID++;
    const i = t._uvs;
    this.mapCoord.set(i.x1 - i.x0, i.y1 - i.y0, i.x3 - i.x0, i.y3 - i.y0, i.x0, i.y0);
    const n = t.orig, s = t.trim;
    s && (kf.set(
      n.width / s.width,
      0,
      0,
      n.height / s.height,
      -s.x / s.width,
      -s.y / s.height
    ), this.mapCoord.append(kf));
    const o = t.baseTexture, a = this.uClampFrame, l = this.clampMargin / o.resolution, h = this.clampOffset;
    return a[0] = (t._frame.x + l + h) / o.width, a[1] = (t._frame.y + l + h) / o.height, a[2] = (t._frame.x + t._frame.width - l + h) / o.width, a[3] = (t._frame.y + t._frame.height - l + h) / o.height, this.uClampOffset[0] = h / o.realWidth, this.uClampOffset[1] = h / o.realHeight, this.isSimple = t._frame.width === o.width && t._frame.height === o.height && t.rotate === 0, !0;
  }
}
var dS = `varying vec2 vMaskCoord;
varying vec2 vTextureCoord;

uniform sampler2D uSampler;
uniform sampler2D mask;
uniform float alpha;
uniform float npmAlpha;
uniform vec4 maskClamp;

void main(void)
{
    float clip = step(3.5,
        step(maskClamp.x, vMaskCoord.x) +
        step(maskClamp.y, vMaskCoord.y) +
        step(vMaskCoord.x, maskClamp.z) +
        step(vMaskCoord.y, maskClamp.w));

    vec4 original = texture2D(uSampler, vTextureCoord);
    vec4 masky = texture2D(mask, vMaskCoord);
    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);

    original *= (alphaMul * masky.r * alpha * clip);

    gl_FragColor = original;
}
`, fS = `attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat3 projectionMatrix;
uniform mat3 otherMatrix;

varying vec2 vMaskCoord;
varying vec2 vTextureCoord;

void main(void)
{
    gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = aTextureCoord;
    vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0)  ).xy;
}
`;
class pS extends Je {
  /** @ignore */
  constructor(e, t, i) {
    let n = null;
    typeof e != "string" && t === void 0 && i === void 0 && (n = e, e = void 0, t = void 0, i = void 0), super(e || fS, t || dS, i), this.maskSprite = n, this.maskMatrix = new Te();
  }
  /**
   * Sprite mask
   * @type {PIXI.DisplayObject}
   */
  get maskSprite() {
    return this._maskSprite;
  }
  set maskSprite(e) {
    this._maskSprite = e, this._maskSprite && (this._maskSprite.renderable = !1);
  }
  /**
   * Applies the filter
   * @param filterManager - The renderer to retrieve the filter from
   * @param input - The input render target.
   * @param output - The target to output to.
   * @param clearMode - Should the output be cleared before rendering to it.
   */
  apply(e, t, i, n) {
    const s = this._maskSprite, o = s._texture;
    o.valid && (o.uvMatrix || (o.uvMatrix = new Lm(o, 0)), o.uvMatrix.update(), this.uniforms.npmAlpha = o.baseTexture.alphaMode ? 0 : 1, this.uniforms.mask = o, this.uniforms.otherMatrix = e.calculateSpriteMatrix(this.maskMatrix, s).prepend(o.uvMatrix.mapCoord), this.uniforms.alpha = s.worldAlpha, this.uniforms.maskClamp = o.uvMatrix.uClampFrame, e.applyFilter(this, t, i, n));
  }
}
class _S {
  /**
   * Create MaskData
   * @param {PIXI.DisplayObject} [maskObject=null] - object that describes the mask
   */
  constructor(e = null) {
    this.type = Ge.NONE, this.autoDetect = !0, this.maskObject = e || null, this.pooled = !1, this.isMaskData = !0, this.resolution = null, this.multisample = Je.defaultMultisample, this.enabled = !0, this.colorMask = 15, this._filters = null, this._stencilCounter = 0, this._scissorCounter = 0, this._scissorRect = null, this._scissorRectLocal = null, this._colorMask = 15, this._target = null;
  }
  /**
   * The sprite mask filter.
   * If set to `null`, the default sprite mask filter is used.
   * @default null
   */
  get filter() {
    return this._filters ? this._filters[0] : null;
  }
  set filter(e) {
    e ? this._filters ? this._filters[0] = e : this._filters = [e] : this._filters = null;
  }
  /** Resets the mask data after popMask(). */
  reset() {
    this.pooled && (this.maskObject = null, this.type = Ge.NONE, this.autoDetect = !0), this._target = null, this._scissorRectLocal = null;
  }
  /**
   * Copies counters from maskData above, called from pushMask().
   * @param maskAbove
   */
  copyCountersOrReset(e) {
    e ? (this._stencilCounter = e._stencilCounter, this._scissorCounter = e._scissorCounter, this._scissorRect = e._scissorRect) : (this._stencilCounter = 0, this._scissorCounter = 0, this._scissorRect = null);
  }
}
class Nm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.enableScissor = !0, this.alphaMaskPool = [], this.maskDataPool = [], this.maskStack = [], this.alphaMaskIndex = 0;
  }
  /**
   * Changes the mask stack that is used by this System.
   * @param maskStack - The mask stack
   */
  setMaskStack(e) {
    this.maskStack = e, this.renderer.scissor.setMaskStack(e), this.renderer.stencil.setMaskStack(e);
  }
  /**
   * Enables the mask and appends it to the current mask stack.
   *
   * NOTE: The batch renderer should be flushed beforehand to prevent pending renders from being masked.
   * @param {PIXI.DisplayObject} target - Display Object to push the mask to
   * @param {PIXI.MaskData|PIXI.Sprite|PIXI.Graphics|PIXI.DisplayObject} maskDataOrTarget - The masking data.
   */
  push(e, t) {
    let i = t;
    if (!i.isMaskData) {
      const s = this.maskDataPool.pop() || new _S();
      s.pooled = !0, s.maskObject = t, i = s;
    }
    const n = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null;
    if (i.copyCountersOrReset(n), i._colorMask = n ? n._colorMask : 15, i.autoDetect && this.detect(i), i._target = e, i.type !== Ge.SPRITE && this.maskStack.push(i), i.enabled)
      switch (i.type) {
        case Ge.SCISSOR:
          this.renderer.scissor.push(i);
          break;
        case Ge.STENCIL:
          this.renderer.stencil.push(i);
          break;
        case Ge.SPRITE:
          i.copyCountersOrReset(null), this.pushSpriteMask(i);
          break;
        case Ge.COLOR:
          this.pushColorMask(i);
          break;
      }
    i.type === Ge.SPRITE && this.maskStack.push(i);
  }
  /**
   * Removes the last mask from the mask stack and doesn't return it.
   *
   * NOTE: The batch renderer should be flushed beforehand to render the masked contents before the mask is removed.
   * @param {PIXI.IMaskTarget} target - Display Object to pop the mask from
   */
  pop(e) {
    const t = this.maskStack.pop();
    if (!(!t || t._target !== e)) {
      if (t.enabled)
        switch (t.type) {
          case Ge.SCISSOR:
            this.renderer.scissor.pop(t);
            break;
          case Ge.STENCIL:
            this.renderer.stencil.pop(t.maskObject);
            break;
          case Ge.SPRITE:
            this.popSpriteMask(t);
            break;
          case Ge.COLOR:
            this.popColorMask(t);
            break;
        }
      if (t.reset(), t.pooled && this.maskDataPool.push(t), this.maskStack.length !== 0) {
        const i = this.maskStack[this.maskStack.length - 1];
        i.type === Ge.SPRITE && i._filters && (i._filters[0].maskSprite = i.maskObject);
      }
    }
  }
  /**
   * Sets type of MaskData based on its maskObject.
   * @param maskData
   */
  detect(e) {
    const t = e.maskObject;
    t ? t.isSprite ? e.type = Ge.SPRITE : this.enableScissor && this.renderer.scissor.testScissor(e) ? e.type = Ge.SCISSOR : e.type = Ge.STENCIL : e.type = Ge.COLOR;
  }
  /**
   * Applies the Mask and adds it to the current filter stack.
   * @param maskData - Sprite to be used as the mask.
   */
  pushSpriteMask(e) {
    const { maskObject: t } = e, i = e._target;
    let n = e._filters;
    n || (n = this.alphaMaskPool[this.alphaMaskIndex], n || (n = this.alphaMaskPool[this.alphaMaskIndex] = [new pS()])), n[0].resolution = e.resolution, n[0].multisample = e.multisample, n[0].maskSprite = t;
    const s = i.filterArea;
    i.filterArea = t.getBounds(!0), this.renderer.filter.push(i, n), i.filterArea = s, e._filters || this.alphaMaskIndex++;
  }
  /**
   * Removes the last filter from the filter stack and doesn't return it.
   * @param maskData - Sprite to be used as the mask.
   */
  popSpriteMask(e) {
    this.renderer.filter.pop(), e._filters ? e._filters[0].maskSprite = null : (this.alphaMaskIndex--, this.alphaMaskPool[this.alphaMaskIndex][0].maskSprite = null);
  }
  /**
   * Pushes the color mask.
   * @param maskData - The mask data
   */
  pushColorMask(e) {
    const t = e._colorMask, i = e._colorMask = t & e.colorMask;
    i !== t && this.renderer.gl.colorMask(
      (i & 1) !== 0,
      (i & 2) !== 0,
      (i & 4) !== 0,
      (i & 8) !== 0
    );
  }
  /**
   * Pops the color mask.
   * @param maskData - The mask data
   */
  popColorMask(e) {
    const t = e._colorMask, i = this.maskStack.length > 0 ? this.maskStack[this.maskStack.length - 1]._colorMask : 15;
    i !== t && this.renderer.gl.colorMask(
      (i & 1) !== 0,
      (i & 2) !== 0,
      (i & 4) !== 0,
      (i & 8) !== 0
    );
  }
  destroy() {
    this.renderer = null;
  }
}
Nm.extension = {
  type: q.RendererSystem,
  name: "mask"
};
Q.add(Nm);
class Um {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.maskStack = [], this.glConst = 0;
  }
  /** Gets count of masks of certain type. */
  getStackLength() {
    return this.maskStack.length;
  }
  /**
   * Changes the mask stack that is used by this System.
   * @param {PIXI.MaskData[]} maskStack - The mask stack
   */
  setMaskStack(e) {
    const { gl: t } = this.renderer, i = this.getStackLength();
    this.maskStack = e;
    const n = this.getStackLength();
    n !== i && (n === 0 ? t.disable(this.glConst) : (t.enable(this.glConst), this._useCurrent()));
  }
  /**
   * Setup renderer to use the current mask data.
   * @private
   */
  _useCurrent() {
  }
  /** Destroys the mask stack. */
  destroy() {
    this.renderer = null, this.maskStack = null;
  }
}
const Df = new Te(), Bf = [], Gm = class Mo extends Um {
  /**
   * @param {PIXI.Renderer} renderer - The renderer this System works for.
   */
  constructor(e) {
    super(e), this.glConst = Z.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST;
  }
  getStackLength() {
    const e = this.maskStack[this.maskStack.length - 1];
    return e ? e._scissorCounter : 0;
  }
  /**
   * evaluates _boundsTransformed, _scissorRect for MaskData
   * @param maskData
   */
  calcScissorRect(e) {
    if (e._scissorRectLocal)
      return;
    const t = e._scissorRect, { maskObject: i } = e, { renderer: n } = this, s = n.renderTexture, o = i.getBounds(!0, Bf.pop() ?? new le());
    this.roundFrameToPixels(
      o,
      s.current ? s.current.resolution : n.resolution,
      s.sourceFrame,
      s.destinationFrame,
      n.projection.transform
    ), t && o.fit(t), e._scissorRectLocal = o;
  }
  static isMatrixRotated(e) {
    if (!e)
      return !1;
    const { a: t, b: i, c: n, d: s } = e;
    return (Math.abs(i) > 1e-4 || Math.abs(n) > 1e-4) && (Math.abs(t) > 1e-4 || Math.abs(s) > 1e-4);
  }
  /**
   * Test, whether the object can be scissor mask with current renderer projection.
   * Calls "calcScissorRect()" if its true.
   * @param maskData - mask data
   * @returns whether Whether the object can be scissor mask
   */
  testScissor(e) {
    const { maskObject: t } = e;
    if (!t.isFastRect || !t.isFastRect() || Mo.isMatrixRotated(t.worldTransform) || Mo.isMatrixRotated(this.renderer.projection.transform))
      return !1;
    this.calcScissorRect(e);
    const i = e._scissorRectLocal;
    return i.width > 0 && i.height > 0;
  }
  roundFrameToPixels(e, t, i, n, s) {
    Mo.isMatrixRotated(s) || (s = s ? Df.copyFrom(s) : Df.identity(), s.translate(-i.x, -i.y).scale(
      n.width / i.width,
      n.height / i.height
    ).translate(n.x, n.y), this.renderer.filter.transformAABB(s, e), e.fit(n), e.x = Math.round(e.x * t), e.y = Math.round(e.y * t), e.width = Math.round(e.width * t), e.height = Math.round(e.height * t));
  }
  /**
   * Applies the Mask and adds it to the current stencil stack.
   * @author alvin
   * @param maskData - The mask data.
   */
  push(e) {
    e._scissorRectLocal || this.calcScissorRect(e);
    const { gl: t } = this.renderer;
    e._scissorRect || t.enable(t.SCISSOR_TEST), e._scissorCounter++, e._scissorRect = e._scissorRectLocal, this._useCurrent();
  }
  /**
   * This should be called after a mask is popped off the mask stack. It will rebind the scissor box to be latest with the
   * last mask in the stack.
   *
   * This can also be called when you directly modify the scissor box and want to restore PixiJS state.
   * @param maskData - The mask data.
   */
  pop(e) {
    const { gl: t } = this.renderer;
    e && Bf.push(e._scissorRectLocal), this.getStackLength() > 0 ? this._useCurrent() : t.disable(t.SCISSOR_TEST);
  }
  /**
   * Setup renderer to use the current scissor data.
   * @private
   */
  _useCurrent() {
    const e = this.maskStack[this.maskStack.length - 1]._scissorRect;
    let t;
    this.renderer.renderTexture.current ? t = e.y : t = this.renderer.height - e.height - e.y, this.renderer.gl.scissor(e.x, t, e.width, e.height);
  }
};
Gm.extension = {
  type: q.RendererSystem,
  name: "scissor"
};
let mS = Gm;
Q.add(mS);
class Hm extends Um {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    super(e), this.glConst = Z.ADAPTER.getWebGLRenderingContext().STENCIL_TEST;
  }
  getStackLength() {
    const e = this.maskStack[this.maskStack.length - 1];
    return e ? e._stencilCounter : 0;
  }
  /**
   * Applies the Mask and adds it to the current stencil stack.
   * @param maskData - The mask data
   */
  push(e) {
    const t = e.maskObject, { gl: i } = this.renderer, n = e._stencilCounter;
    n === 0 && (this.renderer.framebuffer.forceStencil(), i.clearStencil(0), i.clear(i.STENCIL_BUFFER_BIT), i.enable(i.STENCIL_TEST)), e._stencilCounter++;
    const s = e._colorMask;
    s !== 0 && (e._colorMask = 0, i.colorMask(!1, !1, !1, !1)), i.stencilFunc(i.EQUAL, n, 4294967295), i.stencilOp(i.KEEP, i.KEEP, i.INCR), t.renderable = !0, t.render(this.renderer), this.renderer.batch.flush(), t.renderable = !1, s !== 0 && (e._colorMask = s, i.colorMask(
      (s & 1) !== 0,
      (s & 2) !== 0,
      (s & 4) !== 0,
      (s & 8) !== 0
    )), this._useCurrent();
  }
  /**
   * Pops stencil mask. MaskData is already removed from stack
   * @param {PIXI.DisplayObject} maskObject - object of popped mask data
   */
  pop(e) {
    const t = this.renderer.gl;
    if (this.getStackLength() === 0)
      t.disable(t.STENCIL_TEST);
    else {
      const i = this.maskStack.length !== 0 ? this.maskStack[this.maskStack.length - 1] : null, n = i ? i._colorMask : 15;
      n !== 0 && (i._colorMask = 0, t.colorMask(!1, !1, !1, !1)), t.stencilOp(t.KEEP, t.KEEP, t.DECR), e.renderable = !0, e.render(this.renderer), this.renderer.batch.flush(), e.renderable = !1, n !== 0 && (i._colorMask = n, t.colorMask(
        (n & 1) !== 0,
        (n & 2) !== 0,
        (n & 4) !== 0,
        (n & 8) !== 0
      )), this._useCurrent();
    }
  }
  /**
   * Setup renderer to use the current stencil data.
   * @private
   */
  _useCurrent() {
    const e = this.renderer.gl;
    e.stencilFunc(e.EQUAL, this.getStackLength(), 4294967295), e.stencilOp(e.KEEP, e.KEEP, e.KEEP);
  }
}
Hm.extension = {
  type: q.RendererSystem,
  name: "stencil"
};
Q.add(Hm);
class zm {
  constructor(e) {
    this.renderer = e, this.plugins = {}, Object.defineProperties(this.plugins, {
      extract: {
        enumerable: !1,
        get() {
          return fe("7.0.0", "renderer.plugins.extract has moved to renderer.extract"), e.extract;
        }
      },
      prepare: {
        enumerable: !1,
        get() {
          return fe("7.0.0", "renderer.plugins.prepare has moved to renderer.prepare"), e.prepare;
        }
      },
      interaction: {
        enumerable: !1,
        get() {
          return fe("7.0.0", "renderer.plugins.interaction has been deprecated, use renderer.events"), e.events;
        }
      }
    });
  }
  /**
   * Initialize the plugins.
   * @protected
   */
  init() {
    const e = this.rendererPlugins;
    for (const t in e)
      this.plugins[t] = new e[t](this.renderer);
  }
  destroy() {
    for (const e in this.plugins)
      this.plugins[e].destroy(), this.plugins[e] = null;
  }
}
zm.extension = {
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ],
  name: "_plugin"
};
Q.add(zm);
class Xm {
  /** @param renderer - The renderer this System works for. */
  constructor(e) {
    this.renderer = e, this.destinationFrame = null, this.sourceFrame = null, this.defaultFrame = null, this.projectionMatrix = new Te(), this.transform = null;
  }
  /**
   * Updates the projection-matrix based on the sourceFrame → destinationFrame mapping provided.
   *
   * NOTE: It is expected you call `renderer.framebuffer.setViewport(destinationFrame)` after this. This is because
   * the framebuffer viewport converts shader vertex output in normalized device coordinates to window coordinates.
   *
   * NOTE-2: {@link PIXI.RenderTextureSystem#bind} updates the projection-matrix when you bind a render-texture.
   * It is expected
   * that you dirty the current bindings when calling this manually.
   * @param destinationFrame - The rectangle in the render-target to render the contents into. If rendering to the canvas,
   *  the origin is on the top-left; if rendering to a render-texture, the origin is on the bottom-left.
   * @param sourceFrame - The rectangle in world space that contains the contents being rendered.
   * @param resolution - The resolution of the render-target, which is the ratio of
   *  world-space (or CSS) pixels to physical pixels.
   * @param root - Whether the render-target is the screen. This is required because rendering to textures
   *  is y-flipped (i.e. upside down relative to the screen).
   */
  update(e, t, i, n) {
    this.destinationFrame = e || this.destinationFrame || this.defaultFrame, this.sourceFrame = t || this.sourceFrame || e, this.calculateProjection(this.destinationFrame, this.sourceFrame, i, n), this.transform && this.projectionMatrix.append(this.transform);
    const s = this.renderer;
    s.globalUniforms.uniforms.projectionMatrix = this.projectionMatrix, s.globalUniforms.update(), s.shader.shader && s.shader.syncUniformGroup(s.shader.shader.uniforms.globals);
  }
  /**
   * Calculates the `projectionMatrix` to map points inside `sourceFrame` to inside `destinationFrame`.
   * @param _destinationFrame - The destination frame in the render-target.
   * @param sourceFrame - The source frame in world space.
   * @param _resolution - The render-target's resolution, i.e. ratio of CSS to physical pixels.
   * @param root - Whether rendering into the screen. Otherwise, if rendering to a framebuffer, the projection
   *  is y-flipped.
   */
  calculateProjection(e, t, i, n) {
    const s = this.projectionMatrix, o = n ? -1 : 1;
    s.identity(), s.a = 1 / t.width * 2, s.d = o * (1 / t.height * 2), s.tx = -1 - t.x * s.a, s.ty = -o - t.y * s.d;
  }
  /**
   * Sets the transform of the active render target to the given matrix.
   * @param _matrix - The transformation matrix
   */
  setTransform(e) {
  }
  destroy() {
    this.renderer = null;
  }
}
Xm.extension = {
  type: q.RendererSystem,
  name: "projection"
};
Q.add(Xm);
const gS = new nu(), Ff = new le();
class Vm {
  constructor(e) {
    this.renderer = e, this._tempMatrix = new Te();
  }
  /**
   * A Useful function that returns a texture of the display object that can then be used to create sprites
   * This can be quite useful if your displayObject is complicated and needs to be reused multiple times.
   * @param displayObject - The displayObject the object will be generated from.
   * @param {IGenerateTextureOptions} options - Generate texture options.
   * @param {PIXI.Rectangle} options.region - The region of the displayObject, that shall be rendered,
   *        if no region is specified, defaults to the local bounds of the displayObject.
   * @param {number} [options.resolution] - If not given, the renderer's resolution is used.
   * @param {PIXI.MSAA_QUALITY} [options.multisample] - If not given, the renderer's multisample is used.
   * @returns a shiny new texture of the display object passed in
   */
  generateTexture(e, t) {
    const { region: i, ...n } = t || {}, s = (i == null ? void 0 : i.copyTo(Ff)) || e.getLocalBounds(Ff, !0), o = n.resolution || this.renderer.resolution;
    s.width = Math.max(s.width, 1 / o), s.height = Math.max(s.height, 1 / o), n.width = s.width, n.height = s.height, n.resolution = o, n.multisample ?? (n.multisample = this.renderer.multisample);
    const a = et.create(n);
    this._tempMatrix.tx = -s.x, this._tempMatrix.ty = -s.y;
    const l = e.transform;
    return e.transform = gS, this.renderer.render(e, {
      renderTexture: a,
      transform: this._tempMatrix,
      skipUpdateTransform: !!e.parent,
      blit: !0
    }), e.transform = l, a;
  }
  destroy() {
  }
}
Vm.extension = {
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ],
  name: "textureGenerator"
};
Q.add(Vm);
const mr = new le(), rs = new le();
class Wm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.defaultMaskStack = [], this.current = null, this.sourceFrame = new le(), this.destinationFrame = new le(), this.viewportFrame = new le();
  }
  contextChange() {
    var t;
    const e = (t = this.renderer) == null ? void 0 : t.gl.getContextAttributes();
    this._rendererPremultipliedAlpha = !!(e && e.alpha && e.premultipliedAlpha);
  }
  /**
   * Bind the current render texture.
   * @param renderTexture - RenderTexture to bind, by default its `null` - the screen.
   * @param sourceFrame - Part of world that is mapped to the renderTexture.
   * @param destinationFrame - Part of renderTexture, by default it has the same size as sourceFrame.
   */
  bind(e = null, t, i) {
    const n = this.renderer;
    this.current = e;
    let s, o, a;
    e ? (s = e.baseTexture, a = s.resolution, t || (mr.width = e.frame.width, mr.height = e.frame.height, t = mr), i || (rs.x = e.frame.x, rs.y = e.frame.y, rs.width = t.width, rs.height = t.height, i = rs), o = s.framebuffer) : (a = n.resolution, t || (mr.width = n._view.screen.width, mr.height = n._view.screen.height, t = mr), i || (i = mr, i.width = t.width, i.height = t.height));
    const l = this.viewportFrame;
    l.x = i.x * a, l.y = i.y * a, l.width = i.width * a, l.height = i.height * a, e || (l.y = n.view.height - (l.y + l.height)), l.ceil(), this.renderer.framebuffer.bind(o, l), this.renderer.projection.update(i, t, a, !o), e ? this.renderer.mask.setMaskStack(s.maskStack) : this.renderer.mask.setMaskStack(this.defaultMaskStack), this.sourceFrame.copyFrom(t), this.destinationFrame.copyFrom(i);
  }
  /**
   * Erases the render texture and fills the drawing area with a colour.
   * @param clearColor - The color as rgba, default to use the renderer backgroundColor
   * @param [mask=BUFFER_BITS.COLOR | BUFFER_BITS.DEPTH] - Bitwise OR of masks
   *  that indicate the buffers to be cleared, by default COLOR and DEPTH buffers.
   */
  clear(e, t) {
    const i = this.current ? this.current.baseTexture.clear : this.renderer.background.backgroundColor, n = be.shared.setValue(e || i);
    (this.current && this.current.baseTexture.alphaMode > 0 || !this.current && this._rendererPremultipliedAlpha) && n.premultiply(n.alpha);
    const s = this.destinationFrame, o = this.current ? this.current.baseTexture : this.renderer._view.screen, a = s.width !== o.width || s.height !== o.height;
    if (a) {
      let { x: l, y: h, width: c, height: u } = this.viewportFrame;
      l = Math.round(l), h = Math.round(h), c = Math.round(c), u = Math.round(u), this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST), this.renderer.gl.scissor(l, h, c, u);
    }
    this.renderer.framebuffer.clear(n.red, n.green, n.blue, n.alpha, t), a && this.renderer.scissor.pop();
  }
  resize() {
    this.bind(null);
  }
  /** Resets render-texture state. */
  reset() {
    this.bind(null);
  }
  destroy() {
    this.renderer = null;
  }
}
Wm.extension = {
  type: q.RendererSystem,
  name: "renderTexture"
};
Q.add(Wm);
class yS {
  /**
   * Makes a new Pixi program.
   * @param program - webgl program
   * @param uniformData - uniforms
   */
  constructor(e, t) {
    this.program = e, this.uniformData = t, this.uniformGroups = {}, this.uniformDirtyGroups = {}, this.uniformBufferBindings = {};
  }
  /** Destroys this program. */
  destroy() {
    this.uniformData = null, this.uniformGroups = null, this.uniformDirtyGroups = null, this.uniformBufferBindings = null, this.program = null;
  }
}
function vS(r, e) {
  const t = {}, i = e.getProgramParameter(r, e.ACTIVE_ATTRIBUTES);
  for (let n = 0; n < i; n++) {
    const s = e.getActiveAttrib(r, n);
    if (s.name.startsWith("gl_"))
      continue;
    const o = Im(e, s.type), a = {
      type: o,
      name: s.name,
      size: Cm(o),
      location: e.getAttribLocation(r, s.name)
    };
    t[s.name] = a;
  }
  return t;
}
function bS(r, e) {
  const t = {}, i = e.getProgramParameter(r, e.ACTIVE_UNIFORMS);
  for (let n = 0; n < i; n++) {
    const s = e.getActiveUniform(r, n), o = s.name.replace(/\[.*?\]$/, ""), a = !!s.name.match(/\[.*?\]$/), l = Im(e, s.type);
    t[o] = {
      name: o,
      index: n,
      type: l,
      size: s.size,
      isArray: a,
      value: Am(l, s.size)
    };
  }
  return t;
}
function wS(r, e) {
  var a;
  const t = Sf(r, r.VERTEX_SHADER, e.vertexSrc), i = Sf(r, r.FRAGMENT_SHADER, e.fragmentSrc), n = r.createProgram();
  r.attachShader(n, t), r.attachShader(n, i);
  const s = (a = e.extra) == null ? void 0 : a.transformFeedbackVaryings;
  if (s && (typeof r.transformFeedbackVaryings != "function" ? console.warn("TransformFeedback is not supported but TransformFeedbackVaryings are given.") : r.transformFeedbackVaryings(
    n,
    s.names,
    s.bufferMode === "separate" ? r.SEPARATE_ATTRIBS : r.INTERLEAVED_ATTRIBS
  )), r.linkProgram(n), r.getProgramParameter(n, r.LINK_STATUS) || ZA(r, n, t, i), e.attributeData = vS(n, r), e.uniformData = bS(n, r), !/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertexSrc)) {
    const l = Object.keys(e.attributeData);
    l.sort((h, c) => h > c ? 1 : -1);
    for (let h = 0; h < l.length; h++)
      e.attributeData[l[h]].location = h, r.bindAttribLocation(n, h, l[h]);
    r.linkProgram(n);
  }
  r.deleteShader(t), r.deleteShader(i);
  const o = {};
  for (const l in e.uniformData) {
    const h = e.uniformData[l];
    o[l] = {
      location: r.getUniformLocation(n, l),
      value: Am(h.type, h.size)
    };
  }
  return new yS(n, o);
}
function xS(r, e, t, i, n) {
  t.buffer.update(n);
}
const ES = {
  float: `
        data[offset] = v;
    `,
  vec2: `
        data[offset] = v[0];
        data[offset+1] = v[1];
    `,
  vec3: `
        data[offset] = v[0];
        data[offset+1] = v[1];
        data[offset+2] = v[2];

    `,
  vec4: `
        data[offset] = v[0];
        data[offset+1] = v[1];
        data[offset+2] = v[2];
        data[offset+3] = v[3];
    `,
  mat2: `
        data[offset] = v[0];
        data[offset+1] = v[1];

        data[offset+4] = v[2];
        data[offset+5] = v[3];
    `,
  mat3: `
        data[offset] = v[0];
        data[offset+1] = v[1];
        data[offset+2] = v[2];

        data[offset + 4] = v[3];
        data[offset + 5] = v[4];
        data[offset + 6] = v[5];

        data[offset + 8] = v[6];
        data[offset + 9] = v[7];
        data[offset + 10] = v[8];
    `,
  mat4: `
        for(var i = 0; i < 16; i++)
        {
            data[offset + i] = v[i];
        }
    `
}, jm = {
  float: 4,
  vec2: 8,
  vec3: 12,
  vec4: 16,
  int: 4,
  ivec2: 8,
  ivec3: 12,
  ivec4: 16,
  uint: 4,
  uvec2: 8,
  uvec3: 12,
  uvec4: 16,
  bool: 4,
  bvec2: 8,
  bvec3: 12,
  bvec4: 16,
  mat2: 16 * 2,
  mat3: 16 * 3,
  mat4: 16 * 4
};
function TS(r) {
  const e = r.map((s) => ({
    data: s,
    offset: 0,
    dataLen: 0,
    dirty: 0
  }));
  let t = 0, i = 0, n = 0;
  for (let s = 0; s < e.length; s++) {
    const o = e[s];
    if (t = jm[o.data.type], o.data.size > 1 && (t = Math.max(t, 16) * o.data.size), o.dataLen = t, i % t !== 0 && i < 16) {
      const a = i % t % 16;
      i += a, n += a;
    }
    i + t > 16 ? (n = Math.ceil(n / 16) * 16, o.offset = n, n += t, i = t) : (o.offset = n, i += t, n += t);
  }
  return n = Math.ceil(n / 16) * 16, { uboElements: e, size: n };
}
function AS(r, e) {
  const t = [];
  for (const i in r)
    e[i] && t.push(e[i]);
  return t.sort((i, n) => i.index - n.index), t;
}
function SS(r, e) {
  if (!r.autoManage)
    return { size: 0, syncFunc: xS };
  const t = AS(r.uniforms, e), { uboElements: i, size: n } = TS(t), s = [`
    var v = null;
    var v2 = null;
    var cv = null;
    var t = 0;
    var gl = renderer.gl
    var index = 0;
    var data = buffer.data;
    `];
  for (let o = 0; o < i.length; o++) {
    const a = i[o], l = r.uniforms[a.data.name], h = a.data.name;
    let c = !1;
    for (let u = 0; u < In.length; u++) {
      const d = In[u];
      if (d.codeUbo && d.test(a.data, l)) {
        s.push(
          `offset = ${a.offset / 4};`,
          In[u].codeUbo(a.data.name, l)
        ), c = !0;
        break;
      }
    }
    if (!c)
      if (a.data.size > 1) {
        const u = Cm(a.data.type), d = Math.max(jm[a.data.type] / 16, 1), f = u / d, p = (4 - f % 4) % 4;
        s.push(`
                cv = ud.${h}.value;
                v = uv.${h};
                offset = ${a.offset / 4};

                t = 0;

                for(var i=0; i < ${a.data.size * d}; i++)
                {
                    for(var j = 0; j < ${f}; j++)
                    {
                        data[offset++] = v[t++];
                    }
                    offset += ${p};
                }

                `);
      } else {
        const u = ES[a.data.type];
        s.push(`
                cv = ud.${h}.value;
                v = uv.${h};
                offset = ${a.offset / 4};
                ${u};
                `);
      }
  }
  return s.push(`
       renderer.buffer.update(buffer);
    `), {
    size: n,
    // eslint-disable-next-line no-new-func
    syncFunc: new Function(
      "ud",
      "uv",
      "renderer",
      "syncData",
      "buffer",
      s.join(`
`)
    )
  };
}
let CS = 0;
const ho = { textureCount: 0, uboCount: 0 };
class qm {
  /** @param renderer - The renderer this System works for. */
  constructor(e) {
    this.destroyed = !1, this.renderer = e, this.systemCheck(), this.gl = null, this.shader = null, this.program = null, this.cache = {}, this._uboCache = {}, this.id = CS++;
  }
  /**
   * Overrideable function by `@pixi/unsafe-eval` to silence
   * throwing an error if platform doesn't support unsafe-evals.
   * @private
   */
  systemCheck() {
    if (!JA())
      throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.");
  }
  contextChange(e) {
    this.gl = e, this.reset();
  }
  /**
   * Changes the current shader to the one given in parameter.
   * @param shader - the new shader
   * @param dontSync - false if the shader should automatically sync its uniforms.
   * @returns the glProgram that belongs to the shader.
   */
  bind(e, t) {
    e.disposeRunner.add(this), e.uniforms.globals = this.renderer.globalUniforms;
    const i = e.program, n = i.glPrograms[this.renderer.CONTEXT_UID] || this.generateProgram(e);
    return this.shader = e, this.program !== i && (this.program = i, this.gl.useProgram(n.program)), t || (ho.textureCount = 0, ho.uboCount = 0, this.syncUniformGroup(e.uniformGroup, ho)), n;
  }
  /**
   * Uploads the uniforms values to the currently bound shader.
   * @param uniforms - the uniforms values that be applied to the current shader
   */
  setUniforms(e) {
    const t = this.shader.program, i = t.glPrograms[this.renderer.CONTEXT_UID];
    t.syncUniforms(i.uniformData, e, this.renderer);
  }
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
  /**
   * Syncs uniforms on the group
   * @param group - the uniform group to sync
   * @param syncData - this is data that is passed to the sync function and any nested sync functions
   */
  syncUniformGroup(e, t) {
    const i = this.getGlProgram();
    (!e.static || e.dirtyId !== i.uniformDirtyGroups[e.id]) && (i.uniformDirtyGroups[e.id] = e.dirtyId, this.syncUniforms(e, i, t));
  }
  /**
   * Overrideable by the @pixi/unsafe-eval package to use static syncUniforms instead.
   * @param group
   * @param glProgram
   * @param syncData
   */
  syncUniforms(e, t, i) {
    (e.syncUniforms[this.shader.program.id] || this.createSyncGroups(e))(t.uniformData, e.uniforms, this.renderer, i);
  }
  createSyncGroups(e) {
    const t = this.getSignature(e, this.shader.program.uniformData, "u");
    return this.cache[t] || (this.cache[t] = qA(e, this.shader.program.uniformData)), e.syncUniforms[this.shader.program.id] = this.cache[t], e.syncUniforms[this.shader.program.id];
  }
  /**
   * Syncs uniform buffers
   * @param group - the uniform buffer group to sync
   * @param name - the name of the uniform buffer
   */
  syncUniformBufferGroup(e, t) {
    const i = this.getGlProgram();
    if (!e.static || e.dirtyId !== 0 || !i.uniformGroups[e.id]) {
      e.dirtyId = 0;
      const n = i.uniformGroups[e.id] || this.createSyncBufferGroup(e, i, t);
      e.buffer.update(), n(
        i.uniformData,
        e.uniforms,
        this.renderer,
        ho,
        e.buffer
      );
    }
    this.renderer.buffer.bindBufferBase(e.buffer, i.uniformBufferBindings[t]);
  }
  /**
   * Will create a function that uploads a uniform buffer using the STD140 standard.
   * The upload function will then be cached for future calls
   * If a group is manually managed, then a simple upload function is generated
   * @param group - the uniform buffer group to sync
   * @param glProgram - the gl program to attach the uniform bindings to
   * @param name - the name of the uniform buffer (must exist on the shader)
   */
  createSyncBufferGroup(e, t, i) {
    const { gl: n } = this.renderer;
    this.renderer.buffer.bind(e.buffer);
    const s = this.gl.getUniformBlockIndex(t.program, i);
    t.uniformBufferBindings[i] = this.shader.uniformBindCount, n.uniformBlockBinding(t.program, s, this.shader.uniformBindCount), this.shader.uniformBindCount++;
    const o = this.getSignature(e, this.shader.program.uniformData, "ubo");
    let a = this._uboCache[o];
    if (a || (a = this._uboCache[o] = SS(e, this.shader.program.uniformData)), e.autoManage) {
      const l = new Float32Array(a.size / 4);
      e.buffer.update(l);
    }
    return t.uniformGroups[e.id] = a.syncFunc, t.uniformGroups[e.id];
  }
  /**
   * Takes a uniform group and data and generates a unique signature for them.
   * @param group - The uniform group to get signature of
   * @param group.uniforms
   * @param uniformData - Uniform information generated by the shader
   * @param preFix
   * @returns Unique signature of the uniform group
   */
  getSignature(e, t, i) {
    const n = e.uniforms, s = [`${i}-`];
    for (const o in n)
      s.push(o), t[o] && s.push(t[o].type);
    return s.join("-");
  }
  /**
   * Returns the underlying GLShade rof the currently bound shader.
   *
   * This can be handy for when you to have a little more control over the setting of your uniforms.
   * @returns The glProgram for the currently bound Shader for this context
   */
  getGlProgram() {
    return this.shader ? this.shader.program.glPrograms[this.renderer.CONTEXT_UID] : null;
  }
  /**
   * Generates a glProgram version of the Shader provided.
   * @param shader - The shader that the glProgram will be based on.
   * @returns A shiny new glProgram!
   */
  generateProgram(e) {
    const t = this.gl, i = e.program, n = wS(t, i);
    return i.glPrograms[this.renderer.CONTEXT_UID] = n, n;
  }
  /** Resets ShaderSystem state, does not affect WebGL state. */
  reset() {
    this.program = null, this.shader = null;
  }
  /**
   * Disposes shader.
   * If disposing one equals with current shader, set current as null.
   * @param shader - Shader object
   */
  disposeShader(e) {
    this.shader === e && (this.shader = null);
  }
  /** Destroys this System and removes all its textures. */
  destroy() {
    this.renderer = null, this.destroyed = !0;
  }
}
qm.extension = {
  type: q.RendererSystem,
  name: "shader"
};
Q.add(qm);
class ha {
  constructor(e) {
    this.renderer = e;
  }
  /**
   * It all starts here! This initiates every system, passing in the options for any system by name.
   * @param options - the config for the renderer and all its systems
   */
  run(e) {
    const { renderer: t } = this;
    t.runners.init.emit(t.options), e.hello && console.log(`PixiJS 7.4.2 - ${t.rendererLogId} - https://pixijs.com`), t.resize(t.screen.width, t.screen.height);
  }
  destroy() {
  }
}
ha.defaultOptions = {
  /**
   * {@link PIXI.IRendererOptions.hello}
   * @default false
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  hello: !1
}, /** @ignore */
ha.extension = {
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ],
  name: "startup"
};
Q.add(ha);
function IS(r, e = []) {
  return e[oe.NORMAL] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.ADD] = [r.ONE, r.ONE], e[oe.MULTIPLY] = [r.DST_COLOR, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.SCREEN] = [r.ONE, r.ONE_MINUS_SRC_COLOR, r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.OVERLAY] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.DARKEN] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.LIGHTEN] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.COLOR_DODGE] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.COLOR_BURN] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.HARD_LIGHT] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.SOFT_LIGHT] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.DIFFERENCE] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.EXCLUSION] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.HUE] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.SATURATION] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.COLOR] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.LUMINOSITY] = [r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.NONE] = [0, 0], e[oe.NORMAL_NPM] = [r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.ADD_NPM] = [r.SRC_ALPHA, r.ONE, r.ONE, r.ONE], e[oe.SCREEN_NPM] = [r.SRC_ALPHA, r.ONE_MINUS_SRC_COLOR, r.ONE, r.ONE_MINUS_SRC_ALPHA], e[oe.SRC_IN] = [r.DST_ALPHA, r.ZERO], e[oe.SRC_OUT] = [r.ONE_MINUS_DST_ALPHA, r.ZERO], e[oe.SRC_ATOP] = [r.DST_ALPHA, r.ONE_MINUS_SRC_ALPHA], e[oe.DST_OVER] = [r.ONE_MINUS_DST_ALPHA, r.ONE], e[oe.DST_IN] = [r.ZERO, r.SRC_ALPHA], e[oe.DST_OUT] = [r.ZERO, r.ONE_MINUS_SRC_ALPHA], e[oe.DST_ATOP] = [r.ONE_MINUS_DST_ALPHA, r.SRC_ALPHA], e[oe.XOR] = [r.ONE_MINUS_DST_ALPHA, r.ONE_MINUS_SRC_ALPHA], e[oe.SUBTRACT] = [r.ONE, r.ONE, r.ONE, r.ONE, r.FUNC_REVERSE_SUBTRACT, r.FUNC_ADD], e;
}
const RS = 0, PS = 1, MS = 2, kS = 3, DS = 4, BS = 5, Ym = class cc {
  constructor() {
    this.gl = null, this.stateId = 0, this.polygonOffset = 0, this.blendMode = oe.NONE, this._blendEq = !1, this.map = [], this.map[RS] = this.setBlend, this.map[PS] = this.setOffset, this.map[MS] = this.setCullFace, this.map[kS] = this.setDepthTest, this.map[DS] = this.setFrontFace, this.map[BS] = this.setDepthMask, this.checks = [], this.defaultState = new yi(), this.defaultState.blend = !0;
  }
  contextChange(e) {
    this.gl = e, this.blendModes = IS(e), this.set(this.defaultState), this.reset();
  }
  /**
   * Sets the current state
   * @param {*} state - The state to set.
   */
  set(e) {
    if (e = e || this.defaultState, this.stateId !== e.data) {
      let t = this.stateId ^ e.data, i = 0;
      for (; t; )
        t & 1 && this.map[i].call(this, !!(e.data & 1 << i)), t = t >> 1, i++;
      this.stateId = e.data;
    }
    for (let t = 0; t < this.checks.length; t++)
      this.checks[t](this, e);
  }
  /**
   * Sets the state, when previous state is unknown.
   * @param {*} state - The state to set
   */
  forceState(e) {
    e = e || this.defaultState;
    for (let t = 0; t < this.map.length; t++)
      this.map[t].call(this, !!(e.data & 1 << t));
    for (let t = 0; t < this.checks.length; t++)
      this.checks[t](this, e);
    this.stateId = e.data;
  }
  /**
   * Sets whether to enable or disable blending.
   * @param value - Turn on or off WebGl blending.
   */
  setBlend(e) {
    this.updateCheck(cc.checkBlendMode, e), this.gl[e ? "enable" : "disable"](this.gl.BLEND);
  }
  /**
   * Sets whether to enable or disable polygon offset fill.
   * @param value - Turn on or off webgl polygon offset testing.
   */
  setOffset(e) {
    this.updateCheck(cc.checkPolygonOffset, e), this.gl[e ? "enable" : "disable"](this.gl.POLYGON_OFFSET_FILL);
  }
  /**
   * Sets whether to enable or disable depth test.
   * @param value - Turn on or off webgl depth testing.
   */
  setDepthTest(e) {
    this.gl[e ? "enable" : "disable"](this.gl.DEPTH_TEST);
  }
  /**
   * Sets whether to enable or disable depth mask.
   * @param value - Turn on or off webgl depth mask.
   */
  setDepthMask(e) {
    this.gl.depthMask(e);
  }
  /**
   * Sets whether to enable or disable cull face.
   * @param {boolean} value - Turn on or off webgl cull face.
   */
  setCullFace(e) {
    this.gl[e ? "enable" : "disable"](this.gl.CULL_FACE);
  }
  /**
   * Sets the gl front face.
   * @param {boolean} value - true is clockwise and false is counter-clockwise
   */
  setFrontFace(e) {
    this.gl.frontFace(this.gl[e ? "CW" : "CCW"]);
  }
  /**
   * Sets the blend mode.
   * @param {number} value - The blend mode to set to.
   */
  setBlendMode(e) {
    if (e === this.blendMode)
      return;
    this.blendMode = e;
    const t = this.blendModes[e], i = this.gl;
    t.length === 2 ? i.blendFunc(t[0], t[1]) : i.blendFuncSeparate(t[0], t[1], t[2], t[3]), t.length === 6 ? (this._blendEq = !0, i.blendEquationSeparate(t[4], t[5])) : this._blendEq && (this._blendEq = !1, i.blendEquationSeparate(i.FUNC_ADD, i.FUNC_ADD));
  }
  /**
   * Sets the polygon offset.
   * @param {number} value - the polygon offset
   * @param {number} scale - the polygon offset scale
   */
  setPolygonOffset(e, t) {
    this.gl.polygonOffset(e, t);
  }
  // used
  /** Resets all the logic and disables the VAOs. */
  reset() {
    this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL, !1), this.forceState(this.defaultState), this._blendEq = !0, this.blendMode = -1, this.setBlendMode(0);
  }
  /**
   * Checks to see which updates should be checked based on which settings have been activated.
   *
   * For example, if blend is enabled then we should check the blend modes each time the state is changed
   * or if polygon fill is activated then we need to check if the polygon offset changes.
   * The idea is that we only check what we have too.
   * @param func - the checking function to add or remove
   * @param value - should the check function be added or removed.
   */
  updateCheck(e, t) {
    const i = this.checks.indexOf(e);
    t && i === -1 ? this.checks.push(e) : !t && i !== -1 && this.checks.splice(i, 1);
  }
  /**
   * A private little wrapper function that we call to check the blend mode.
   * @param system - the System to perform the state check on
   * @param state - the state that the blendMode will pulled from
   */
  static checkBlendMode(e, t) {
    e.setBlendMode(t.blendMode);
  }
  /**
   * A private little wrapper function that we call to check the polygon offset.
   * @param system - the System to perform the state check on
   * @param state - the state that the blendMode will pulled from
   */
  static checkPolygonOffset(e, t) {
    e.setPolygonOffset(1, t.polygonOffset);
  }
  /**
   * @ignore
   */
  destroy() {
    this.gl = null;
  }
};
Ym.extension = {
  type: q.RendererSystem,
  name: "state"
};
let FS = Ym;
Q.add(FS);
class OS extends Fs {
  constructor() {
    super(...arguments), this.runners = {}, this._systemsHash = {};
  }
  /**
   * Set up a system with a collection of SystemClasses and runners.
   * Systems are attached dynamically to this class when added.
   * @param config - the config for the system manager
   */
  setup(e) {
    this.addRunners(...e.runners);
    const t = (e.priority ?? []).filter((n) => e.systems[n]), i = [
      ...t,
      ...Object.keys(e.systems).filter((n) => !t.includes(n))
    ];
    for (const n of i)
      this.addSystem(e.systems[n], n);
  }
  /**
   * Create a bunch of runners based of a collection of ids
   * @param runnerIds - the runner ids to add
   */
  addRunners(...e) {
    e.forEach((t) => {
      this.runners[t] = new $t(t);
    });
  }
  /**
   * Add a new system to the renderer.
   * @param ClassRef - Class reference
   * @param name - Property name for system, if not specified
   *        will use a static `name` property on the class itself. This
   *        name will be assigned as s property on the Renderer so make
   *        sure it doesn't collide with properties on Renderer.
   * @returns Return instance of renderer
   */
  addSystem(e, t) {
    const i = new e(this);
    if (this[t])
      throw new Error(`Whoops! The name "${t}" is already in use`);
    this[t] = i, this._systemsHash[t] = i;
    for (const n in this.runners)
      this.runners[n].add(i);
    return this;
  }
  /**
   * A function that will run a runner and call the runners function but pass in different options
   * to each system based on there name.
   *
   * E.g. If you have two systems added called `systemA` and `systemB` you could call do the following:
   *
   * ```js
   * system.emitWithCustomOptions(init, {
   *     systemA: {...optionsForA},
   *     systemB: {...optionsForB},
   * });
   * ```
   *
   * `init` would be called on system A passing `optionsForA` and on system B passing `optionsForB`.
   * @param runner - the runner to target
   * @param options - key value options for each system
   */
  emitWithCustomOptions(e, t) {
    const i = Object.keys(this._systemsHash);
    e.items.forEach((n) => {
      const s = i.find((o) => this._systemsHash[o] === n);
      n[e.name](t[s]);
    });
  }
  /** destroy the all runners and systems. Its apps job to */
  destroy() {
    Object.values(this.runners).forEach((e) => {
      e.destroy();
    }), this._systemsHash = {};
  }
  // TODO implement!
  // removeSystem(ClassRef: ISystemConstructor, name: string): void
  // {
  // }
}
const cs = class ko {
  /** @param renderer - The renderer this System works for. */
  constructor(e) {
    this.renderer = e, this.count = 0, this.checkCount = 0, this.maxIdle = ko.defaultMaxIdle, this.checkCountMax = ko.defaultCheckCountMax, this.mode = ko.defaultMode;
  }
  /**
   * Checks to see when the last time a texture was used.
   * If the texture has not been used for a specified amount of time, it will be removed from the GPU.
   */
  postrender() {
    this.renderer.objectRenderer.renderingToScreen && (this.count++, this.mode !== Kc.MANUAL && (this.checkCount++, this.checkCount > this.checkCountMax && (this.checkCount = 0, this.run())));
  }
  /**
   * Checks to see when the last time a texture was used.
   * If the texture has not been used for a specified amount of time, it will be removed from the GPU.
   */
  run() {
    const e = this.renderer.texture, t = e.managedTextures;
    let i = !1;
    for (let n = 0; n < t.length; n++) {
      const s = t[n];
      s.resource && this.count - s.touched > this.maxIdle && (e.destroyTexture(s, !0), t[n] = null, i = !0);
    }
    if (i) {
      let n = 0;
      for (let s = 0; s < t.length; s++)
        t[s] !== null && (t[n++] = t[s]);
      t.length = n;
    }
  }
  /**
   * Removes all the textures within the specified displayObject and its children from the GPU.
   * @param {PIXI.DisplayObject} displayObject - the displayObject to remove the textures from.
   */
  unload(e) {
    const t = this.renderer.texture, i = e._texture;
    i && !i.framebuffer && t.destroyTexture(i);
    for (let n = e.children.length - 1; n >= 0; n--)
      this.unload(e.children[n]);
  }
  destroy() {
    this.renderer = null;
  }
};
cs.defaultMode = Kc.AUTO, /**
* Default maximum idle frames before a texture is destroyed by garbage collection.
* @static
* @default 3600
* @see PIXI.TextureGCSystem#maxIdle
*/
cs.defaultMaxIdle = 60 * 60, /**
* Default frames between two garbage collections.
* @static
* @default 600
* @see PIXI.TextureGCSystem#checkCountMax
*/
cs.defaultCheckCountMax = 60 * 10, /** @ignore */
cs.extension = {
  type: q.RendererSystem,
  name: "textureGC"
};
let Tr = cs;
Q.add(Tr);
class Ql {
  constructor(e) {
    this.texture = e, this.width = -1, this.height = -1, this.dirtyId = -1, this.dirtyStyleId = -1, this.mipmap = !1, this.wrapMode = 33071, this.type = re.UNSIGNED_BYTE, this.internalFormat = G.RGBA, this.samplerType = 0;
  }
}
function LS(r) {
  let e;
  return "WebGL2RenderingContext" in globalThis && r instanceof globalThis.WebGL2RenderingContext ? e = {
    [r.RGB]: K.FLOAT,
    [r.RGBA]: K.FLOAT,
    [r.ALPHA]: K.FLOAT,
    [r.LUMINANCE]: K.FLOAT,
    [r.LUMINANCE_ALPHA]: K.FLOAT,
    [r.R8]: K.FLOAT,
    [r.R8_SNORM]: K.FLOAT,
    [r.RG8]: K.FLOAT,
    [r.RG8_SNORM]: K.FLOAT,
    [r.RGB8]: K.FLOAT,
    [r.RGB8_SNORM]: K.FLOAT,
    [r.RGB565]: K.FLOAT,
    [r.RGBA4]: K.FLOAT,
    [r.RGB5_A1]: K.FLOAT,
    [r.RGBA8]: K.FLOAT,
    [r.RGBA8_SNORM]: K.FLOAT,
    [r.RGB10_A2]: K.FLOAT,
    [r.RGB10_A2UI]: K.FLOAT,
    [r.SRGB8]: K.FLOAT,
    [r.SRGB8_ALPHA8]: K.FLOAT,
    [r.R16F]: K.FLOAT,
    [r.RG16F]: K.FLOAT,
    [r.RGB16F]: K.FLOAT,
    [r.RGBA16F]: K.FLOAT,
    [r.R32F]: K.FLOAT,
    [r.RG32F]: K.FLOAT,
    [r.RGB32F]: K.FLOAT,
    [r.RGBA32F]: K.FLOAT,
    [r.R11F_G11F_B10F]: K.FLOAT,
    [r.RGB9_E5]: K.FLOAT,
    [r.R8I]: K.INT,
    [r.R8UI]: K.UINT,
    [r.R16I]: K.INT,
    [r.R16UI]: K.UINT,
    [r.R32I]: K.INT,
    [r.R32UI]: K.UINT,
    [r.RG8I]: K.INT,
    [r.RG8UI]: K.UINT,
    [r.RG16I]: K.INT,
    [r.RG16UI]: K.UINT,
    [r.RG32I]: K.INT,
    [r.RG32UI]: K.UINT,
    [r.RGB8I]: K.INT,
    [r.RGB8UI]: K.UINT,
    [r.RGB16I]: K.INT,
    [r.RGB16UI]: K.UINT,
    [r.RGB32I]: K.INT,
    [r.RGB32UI]: K.UINT,
    [r.RGBA8I]: K.INT,
    [r.RGBA8UI]: K.UINT,
    [r.RGBA16I]: K.INT,
    [r.RGBA16UI]: K.UINT,
    [r.RGBA32I]: K.INT,
    [r.RGBA32UI]: K.UINT,
    [r.DEPTH_COMPONENT16]: K.FLOAT,
    [r.DEPTH_COMPONENT24]: K.FLOAT,
    [r.DEPTH_COMPONENT32F]: K.FLOAT,
    [r.DEPTH_STENCIL]: K.FLOAT,
    [r.DEPTH24_STENCIL8]: K.FLOAT,
    [r.DEPTH32F_STENCIL8]: K.FLOAT
  } : e = {
    [r.RGB]: K.FLOAT,
    [r.RGBA]: K.FLOAT,
    [r.ALPHA]: K.FLOAT,
    [r.LUMINANCE]: K.FLOAT,
    [r.LUMINANCE_ALPHA]: K.FLOAT,
    [r.DEPTH_STENCIL]: K.FLOAT
  }, e;
}
function NS(r) {
  let e;
  return "WebGL2RenderingContext" in globalThis && r instanceof globalThis.WebGL2RenderingContext ? e = {
    [re.UNSIGNED_BYTE]: {
      [G.RGBA]: r.RGBA8,
      [G.RGB]: r.RGB8,
      [G.RG]: r.RG8,
      [G.RED]: r.R8,
      [G.RGBA_INTEGER]: r.RGBA8UI,
      [G.RGB_INTEGER]: r.RGB8UI,
      [G.RG_INTEGER]: r.RG8UI,
      [G.RED_INTEGER]: r.R8UI,
      [G.ALPHA]: r.ALPHA,
      [G.LUMINANCE]: r.LUMINANCE,
      [G.LUMINANCE_ALPHA]: r.LUMINANCE_ALPHA
    },
    [re.BYTE]: {
      [G.RGBA]: r.RGBA8_SNORM,
      [G.RGB]: r.RGB8_SNORM,
      [G.RG]: r.RG8_SNORM,
      [G.RED]: r.R8_SNORM,
      [G.RGBA_INTEGER]: r.RGBA8I,
      [G.RGB_INTEGER]: r.RGB8I,
      [G.RG_INTEGER]: r.RG8I,
      [G.RED_INTEGER]: r.R8I
    },
    [re.UNSIGNED_SHORT]: {
      [G.RGBA_INTEGER]: r.RGBA16UI,
      [G.RGB_INTEGER]: r.RGB16UI,
      [G.RG_INTEGER]: r.RG16UI,
      [G.RED_INTEGER]: r.R16UI,
      [G.DEPTH_COMPONENT]: r.DEPTH_COMPONENT16
    },
    [re.SHORT]: {
      [G.RGBA_INTEGER]: r.RGBA16I,
      [G.RGB_INTEGER]: r.RGB16I,
      [G.RG_INTEGER]: r.RG16I,
      [G.RED_INTEGER]: r.R16I
    },
    [re.UNSIGNED_INT]: {
      [G.RGBA_INTEGER]: r.RGBA32UI,
      [G.RGB_INTEGER]: r.RGB32UI,
      [G.RG_INTEGER]: r.RG32UI,
      [G.RED_INTEGER]: r.R32UI,
      [G.DEPTH_COMPONENT]: r.DEPTH_COMPONENT24
    },
    [re.INT]: {
      [G.RGBA_INTEGER]: r.RGBA32I,
      [G.RGB_INTEGER]: r.RGB32I,
      [G.RG_INTEGER]: r.RG32I,
      [G.RED_INTEGER]: r.R32I
    },
    [re.FLOAT]: {
      [G.RGBA]: r.RGBA32F,
      [G.RGB]: r.RGB32F,
      [G.RG]: r.RG32F,
      [G.RED]: r.R32F,
      [G.DEPTH_COMPONENT]: r.DEPTH_COMPONENT32F
    },
    [re.HALF_FLOAT]: {
      [G.RGBA]: r.RGBA16F,
      [G.RGB]: r.RGB16F,
      [G.RG]: r.RG16F,
      [G.RED]: r.R16F
    },
    [re.UNSIGNED_SHORT_5_6_5]: {
      [G.RGB]: r.RGB565
    },
    [re.UNSIGNED_SHORT_4_4_4_4]: {
      [G.RGBA]: r.RGBA4
    },
    [re.UNSIGNED_SHORT_5_5_5_1]: {
      [G.RGBA]: r.RGB5_A1
    },
    [re.UNSIGNED_INT_2_10_10_10_REV]: {
      [G.RGBA]: r.RGB10_A2,
      [G.RGBA_INTEGER]: r.RGB10_A2UI
    },
    [re.UNSIGNED_INT_10F_11F_11F_REV]: {
      [G.RGB]: r.R11F_G11F_B10F
    },
    [re.UNSIGNED_INT_5_9_9_9_REV]: {
      [G.RGB]: r.RGB9_E5
    },
    [re.UNSIGNED_INT_24_8]: {
      [G.DEPTH_STENCIL]: r.DEPTH24_STENCIL8
    },
    [re.FLOAT_32_UNSIGNED_INT_24_8_REV]: {
      [G.DEPTH_STENCIL]: r.DEPTH32F_STENCIL8
    }
  } : e = {
    [re.UNSIGNED_BYTE]: {
      [G.RGBA]: r.RGBA,
      [G.RGB]: r.RGB,
      [G.ALPHA]: r.ALPHA,
      [G.LUMINANCE]: r.LUMINANCE,
      [G.LUMINANCE_ALPHA]: r.LUMINANCE_ALPHA
    },
    [re.UNSIGNED_SHORT_5_6_5]: {
      [G.RGB]: r.RGB
    },
    [re.UNSIGNED_SHORT_4_4_4_4]: {
      [G.RGBA]: r.RGBA
    },
    [re.UNSIGNED_SHORT_5_5_5_1]: {
      [G.RGBA]: r.RGBA
    }
  }, e;
}
class Km {
  /**
   * @param renderer - The renderer this system works for.
   */
  constructor(e) {
    this.renderer = e, this.boundTextures = [], this.currentLocation = -1, this.managedTextures = [], this._unknownBoundTextures = !1, this.unknownTexture = new ae(), this.hasIntegerTextures = !1;
  }
  /** Sets up the renderer context and necessary buffers. */
  contextChange() {
    const e = this.gl = this.renderer.gl;
    this.CONTEXT_UID = this.renderer.CONTEXT_UID, this.webGLVersion = this.renderer.context.webGLVersion, this.internalFormats = NS(e), this.samplerTypes = LS(e);
    const t = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
    this.boundTextures.length = t;
    for (let n = 0; n < t; n++)
      this.boundTextures[n] = null;
    this.emptyTextures = {};
    const i = new Ql(e.createTexture());
    e.bindTexture(e.TEXTURE_2D, i.texture), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, new Uint8Array(4)), this.emptyTextures[e.TEXTURE_2D] = i, this.emptyTextures[e.TEXTURE_CUBE_MAP] = new Ql(e.createTexture()), e.bindTexture(e.TEXTURE_CUBE_MAP, this.emptyTextures[e.TEXTURE_CUBE_MAP].texture);
    for (let n = 0; n < 6; n++)
      e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, null);
    e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_MAG_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_CUBE_MAP, e.TEXTURE_MIN_FILTER, e.LINEAR);
    for (let n = 0; n < this.boundTextures.length; n++)
      this.bind(null, n);
  }
  /**
   * Bind a texture to a specific location
   *
   * If you want to unbind something, please use `unbind(texture)` instead of `bind(null, textureLocation)`
   * @param texture - Texture to bind
   * @param [location=0] - Location to bind at
   */
  bind(e, t = 0) {
    const { gl: i } = this;
    if (e = e == null ? void 0 : e.castToBaseTexture(), (e == null ? void 0 : e.valid) && !e.parentTextureArray) {
      e.touched = this.renderer.textureGC.count;
      const n = e._glTextures[this.CONTEXT_UID] || this.initTexture(e);
      this.boundTextures[t] !== e && (this.currentLocation !== t && (this.currentLocation = t, i.activeTexture(i.TEXTURE0 + t)), i.bindTexture(e.target, n.texture)), n.dirtyId !== e.dirtyId ? (this.currentLocation !== t && (this.currentLocation = t, i.activeTexture(i.TEXTURE0 + t)), this.updateTexture(e)) : n.dirtyStyleId !== e.dirtyStyleId && this.updateTextureStyle(e), this.boundTextures[t] = e;
    } else
      this.currentLocation !== t && (this.currentLocation = t, i.activeTexture(i.TEXTURE0 + t)), i.bindTexture(i.TEXTURE_2D, this.emptyTextures[i.TEXTURE_2D].texture), this.boundTextures[t] = null;
  }
  /** Resets texture location and bound textures Actual `bind(null, i)` calls will be performed at next `unbind()` call */
  reset() {
    this._unknownBoundTextures = !0, this.hasIntegerTextures = !1, this.currentLocation = -1;
    for (let e = 0; e < this.boundTextures.length; e++)
      this.boundTextures[e] = this.unknownTexture;
  }
  /**
   * Unbind a texture.
   * @param texture - Texture to bind
   */
  unbind(e) {
    const { gl: t, boundTextures: i } = this;
    if (this._unknownBoundTextures) {
      this._unknownBoundTextures = !1;
      for (let n = 0; n < i.length; n++)
        i[n] === this.unknownTexture && this.bind(null, n);
    }
    for (let n = 0; n < i.length; n++)
      i[n] === e && (this.currentLocation !== n && (t.activeTexture(t.TEXTURE0 + n), this.currentLocation = n), t.bindTexture(e.target, this.emptyTextures[e.target].texture), i[n] = null);
  }
  /**
   * Ensures that current boundTextures all have FLOAT sampler type,
   * see {@link PIXI.SAMPLER_TYPES} for explanation.
   * @param maxTextures - number of locations to check
   */
  ensureSamplerType(e) {
    const { boundTextures: t, hasIntegerTextures: i, CONTEXT_UID: n } = this;
    if (i)
      for (let s = e - 1; s >= 0; --s) {
        const o = t[s];
        o && o._glTextures[n].samplerType !== K.FLOAT && this.renderer.texture.unbind(o);
      }
  }
  /**
   * Initialize a texture
   * @private
   * @param texture - Texture to initialize
   */
  initTexture(e) {
    const t = new Ql(this.gl.createTexture());
    return t.dirtyId = -1, e._glTextures[this.CONTEXT_UID] = t, this.managedTextures.push(e), e.on("dispose", this.destroyTexture, this), t;
  }
  initTextureType(e, t) {
    var i;
    t.internalFormat = ((i = this.internalFormats[e.type]) == null ? void 0 : i[e.format]) ?? e.format, t.samplerType = this.samplerTypes[t.internalFormat] ?? K.FLOAT, this.webGLVersion === 2 && e.type === re.HALF_FLOAT ? t.type = this.gl.HALF_FLOAT : t.type = e.type;
  }
  /**
   * Update a texture
   * @private
   * @param {PIXI.BaseTexture} texture - Texture to initialize
   */
  updateTexture(e) {
    var n;
    const t = e._glTextures[this.CONTEXT_UID];
    if (!t)
      return;
    const i = this.renderer;
    if (this.initTextureType(e, t), (n = e.resource) == null ? void 0 : n.upload(i, e, t))
      t.samplerType !== K.FLOAT && (this.hasIntegerTextures = !0);
    else {
      const s = e.realWidth, o = e.realHeight, a = i.gl;
      (t.width !== s || t.height !== o || t.dirtyId < 0) && (t.width = s, t.height = o, a.texImage2D(
        e.target,
        0,
        t.internalFormat,
        s,
        o,
        0,
        e.format,
        t.type,
        null
      ));
    }
    e.dirtyStyleId !== t.dirtyStyleId && this.updateTextureStyle(e), t.dirtyId = e.dirtyId;
  }
  /**
   * Deletes the texture from WebGL
   * @private
   * @param texture - the texture to destroy
   * @param [skipRemove=false] - Whether to skip removing the texture from the TextureManager.
   */
  destroyTexture(e, t) {
    const { gl: i } = this;
    if (e = e.castToBaseTexture(), e._glTextures[this.CONTEXT_UID] && (this.unbind(e), i.deleteTexture(e._glTextures[this.CONTEXT_UID].texture), e.off("dispose", this.destroyTexture, this), delete e._glTextures[this.CONTEXT_UID], !t)) {
      const n = this.managedTextures.indexOf(e);
      n !== -1 && Cn(this.managedTextures, n, 1);
    }
  }
  /**
   * Update texture style such as mipmap flag
   * @private
   * @param {PIXI.BaseTexture} texture - Texture to update
   */
  updateTextureStyle(e) {
    var i;
    const t = e._glTextures[this.CONTEXT_UID];
    t && ((e.mipmap === gi.POW2 || this.webGLVersion !== 2) && !e.isPowerOfTwo ? t.mipmap = !1 : t.mipmap = e.mipmap >= 1, this.webGLVersion !== 2 && !e.isPowerOfTwo ? t.wrapMode = tr.CLAMP : t.wrapMode = e.wrapMode, (i = e.resource) != null && i.style(this.renderer, e, t) || this.setStyle(e, t), t.dirtyStyleId = e.dirtyStyleId);
  }
  /**
   * Set style for texture
   * @private
   * @param texture - Texture to update
   * @param glTexture
   */
  setStyle(e, t) {
    const i = this.gl;
    if (t.mipmap && e.mipmap !== gi.ON_MANUAL && i.generateMipmap(e.target), i.texParameteri(e.target, i.TEXTURE_WRAP_S, t.wrapMode), i.texParameteri(e.target, i.TEXTURE_WRAP_T, t.wrapMode), t.mipmap) {
      i.texParameteri(e.target, i.TEXTURE_MIN_FILTER, e.scaleMode === Ai.LINEAR ? i.LINEAR_MIPMAP_LINEAR : i.NEAREST_MIPMAP_NEAREST);
      const n = this.renderer.context.extensions.anisotropicFiltering;
      if (n && e.anisotropicLevel > 0 && e.scaleMode === Ai.LINEAR) {
        const s = Math.min(e.anisotropicLevel, i.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));
        i.texParameterf(e.target, n.TEXTURE_MAX_ANISOTROPY_EXT, s);
      }
    } else
      i.texParameteri(e.target, i.TEXTURE_MIN_FILTER, e.scaleMode === Ai.LINEAR ? i.LINEAR : i.NEAREST);
    i.texParameteri(e.target, i.TEXTURE_MAG_FILTER, e.scaleMode === Ai.LINEAR ? i.LINEAR : i.NEAREST);
  }
  destroy() {
    this.renderer = null;
  }
}
Km.extension = {
  type: q.RendererSystem,
  name: "texture"
};
Q.add(Km);
class Zm {
  /**
   * @param renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e;
  }
  /** Sets up the renderer context and necessary buffers. */
  contextChange() {
    this.gl = this.renderer.gl, this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  }
  /**
   * Bind TransformFeedback and buffers
   * @param transformFeedback - TransformFeedback to bind
   */
  bind(e) {
    const { gl: t, CONTEXT_UID: i } = this, n = e._glTransformFeedbacks[i] || this.createGLTransformFeedback(e);
    t.bindTransformFeedback(t.TRANSFORM_FEEDBACK, n);
  }
  /** Unbind TransformFeedback */
  unbind() {
    const { gl: e } = this;
    e.bindTransformFeedback(e.TRANSFORM_FEEDBACK, null);
  }
  /**
   * Begin TransformFeedback
   * @param drawMode - DrawMode for TransformFeedback
   * @param shader - A Shader used by TransformFeedback. Current bound shader will be used if not provided.
   */
  beginTransformFeedback(e, t) {
    const { gl: i, renderer: n } = this;
    t && n.shader.bind(t), i.beginTransformFeedback(e);
  }
  /** End TransformFeedback */
  endTransformFeedback() {
    const { gl: e } = this;
    e.endTransformFeedback();
  }
  /**
   * Create TransformFeedback and bind buffers
   * @param tf - TransformFeedback
   * @returns WebGLTransformFeedback
   */
  createGLTransformFeedback(e) {
    const { gl: t, renderer: i, CONTEXT_UID: n } = this, s = t.createTransformFeedback();
    e._glTransformFeedbacks[n] = s, t.bindTransformFeedback(t.TRANSFORM_FEEDBACK, s);
    for (let o = 0; o < e.buffers.length; o++) {
      const a = e.buffers[o];
      a && (i.buffer.update(a), a._glBuffers[n].refCount++, t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER, o, a._glBuffers[n].buffer || null));
    }
    return t.bindTransformFeedback(t.TRANSFORM_FEEDBACK, null), e.disposeRunner.add(this), s;
  }
  /**
   * Disposes TransfromFeedback
   * @param {PIXI.TransformFeedback} tf - TransformFeedback
   * @param {boolean} [contextLost=false] - If context was lost, we suppress delete TransformFeedback
   */
  disposeTransformFeedback(e, t) {
    const i = e._glTransformFeedbacks[this.CONTEXT_UID], n = this.gl;
    e.disposeRunner.remove(this);
    const s = this.renderer.buffer;
    if (s)
      for (let o = 0; o < e.buffers.length; o++) {
        const a = e.buffers[o];
        if (!a)
          continue;
        const l = a._glBuffers[this.CONTEXT_UID];
        l && (l.refCount--, l.refCount === 0 && !t && s.dispose(a, t));
      }
    i && (t || n.deleteTransformFeedback(i), delete e._glTransformFeedbacks[this.CONTEXT_UID]);
  }
  destroy() {
    this.renderer = null;
  }
}
Zm.extension = {
  type: q.RendererSystem,
  name: "transformFeedback"
};
Q.add(Zm);
class ca {
  constructor(e) {
    this.renderer = e;
  }
  /**
   * initiates the view system
   * @param {PIXI.ViewOptions} options - the options for the view
   */
  init(e) {
    this.screen = new le(0, 0, e.width, e.height), this.element = e.view || Z.ADAPTER.createCanvas(), this.resolution = e.resolution || Z.RESOLUTION, this.autoDensity = !!e.autoDensity;
  }
  /**
   * Resizes the screen and canvas to the specified dimensions.
   * @param desiredScreenWidth - The new width of the screen.
   * @param desiredScreenHeight - The new height of the screen.
   */
  resizeView(e, t) {
    this.element.width = Math.round(e * this.resolution), this.element.height = Math.round(t * this.resolution);
    const i = this.element.width / this.resolution, n = this.element.height / this.resolution;
    this.screen.width = i, this.screen.height = n, this.autoDensity && (this.element.style.width = `${i}px`, this.element.style.height = `${n}px`), this.renderer.emit("resize", i, n), this.renderer.runners.resize.emit(this.screen.width, this.screen.height);
  }
  /**
   * Destroys this System and optionally removes the canvas from the dom.
   * @param {boolean} [removeView=false] - Whether to remove the canvas from the DOM.
   */
  destroy(e) {
    var t;
    e && ((t = this.element.parentNode) == null || t.removeChild(this.element)), this.renderer = null, this.element = null, this.screen = null;
  }
}
ca.defaultOptions = {
  /**
   * {@link PIXI.IRendererOptions.width}
   * @default 800
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  width: 800,
  /**
   * {@link PIXI.IRendererOptions.height}
   * @default 600
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  height: 600,
  /**
   * {@link PIXI.IRendererOptions.resolution}
   * @type {number}
   * @default PIXI.settings.RESOLUTION
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  resolution: void 0,
  /**
   * {@link PIXI.IRendererOptions.autoDensity}
   * @default false
   * @memberof PIXI.settings.RENDER_OPTIONS
   */
  autoDensity: !1
}, /** @ignore */
ca.extension = {
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ],
  name: "_view"
};
Q.add(ca);
Z.PREFER_ENV = qr.WEBGL2;
Z.STRICT_TEXTURE_CACHE = !1;
Z.RENDER_OPTIONS = {
  ...la.defaultOptions,
  ...aa.defaultOptions,
  ...ca.defaultOptions,
  ...ha.defaultOptions
};
Object.defineProperties(Z, {
  /**
   * @static
   * @name WRAP_MODE
   * @memberof PIXI.settings
   * @type {PIXI.WRAP_MODES}
   * @deprecated since 7.1.0
   * @see PIXI.BaseTexture.defaultOptions.wrapMode
   */
  WRAP_MODE: {
    get() {
      return ae.defaultOptions.wrapMode;
    },
    set(r) {
      fe("7.1.0", "settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"), ae.defaultOptions.wrapMode = r;
    }
  },
  /**
   * @static
   * @name SCALE_MODE
   * @memberof PIXI.settings
   * @type {PIXI.SCALE_MODES}
   * @deprecated since 7.1.0
   * @see PIXI.BaseTexture.defaultOptions.scaleMode
   */
  SCALE_MODE: {
    get() {
      return ae.defaultOptions.scaleMode;
    },
    set(r) {
      fe("7.1.0", "settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"), ae.defaultOptions.scaleMode = r;
    }
  },
  /**
   * @static
   * @name MIPMAP_TEXTURES
   * @memberof PIXI.settings
   * @type {PIXI.MIPMAP_MODES}
   * @deprecated since 7.1.0
   * @see PIXI.BaseTexture.defaultOptions.mipmap
   */
  MIPMAP_TEXTURES: {
    get() {
      return ae.defaultOptions.mipmap;
    },
    set(r) {
      fe("7.1.0", "settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"), ae.defaultOptions.mipmap = r;
    }
    // MIPMAP_MODES.POW2,
  },
  /**
   * @static
   * @name ANISOTROPIC_LEVEL
   * @memberof PIXI.settings
   * @type {number}
   * @deprecated since 7.1.0
   * @see PIXI.BaseTexture.defaultOptions.anisotropicLevel
   */
  ANISOTROPIC_LEVEL: {
    get() {
      return ae.defaultOptions.anisotropicLevel;
    },
    set(r) {
      fe(
        "7.1.0",
        "settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"
      ), ae.defaultOptions.anisotropicLevel = r;
    }
  },
  /**
   * Default filter resolution.
   * @static
   * @name FILTER_RESOLUTION
   * @memberof PIXI.settings
   * @deprecated since 7.1.0
   * @type {number|null}
   * @see PIXI.Filter.defaultResolution
   */
  FILTER_RESOLUTION: {
    get() {
      return fe("7.1.0", "settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"), Je.defaultResolution;
    },
    set(r) {
      Je.defaultResolution = r;
    }
  },
  /**
   * Default filter samples.
   * @static
   * @name FILTER_MULTISAMPLE
   * @memberof PIXI.settings
   * @deprecated since 7.1.0
   * @type {PIXI.MSAA_QUALITY}
   * @see PIXI.Filter.defaultMultisample
   */
  FILTER_MULTISAMPLE: {
    get() {
      return fe("7.1.0", "settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"), Je.defaultMultisample;
    },
    set(r) {
      Je.defaultMultisample = r;
    }
  },
  /**
   * The maximum textures that this device supports.
   * @static
   * @name SPRITE_MAX_TEXTURES
   * @memberof PIXI.settings
   * @deprecated since 7.1.0
   * @see PIXI.BatchRenderer.defaultMaxTextures
   * @type {number}
   */
  SPRITE_MAX_TEXTURES: {
    get() {
      return Er.defaultMaxTextures;
    },
    set(r) {
      fe("7.1.0", "settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"), Er.defaultMaxTextures = r;
    }
  },
  /**
   * The default sprite batch size.
   *
   * The default aims to balance desktop and mobile devices.
   * @static
   * @name SPRITE_BATCH_SIZE
   * @memberof PIXI.settings
   * @see PIXI.BatchRenderer.defaultBatchSize
   * @deprecated since 7.1.0
   * @type {number}
   */
  SPRITE_BATCH_SIZE: {
    get() {
      return Er.defaultBatchSize;
    },
    set(r) {
      fe("7.1.0", "settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"), Er.defaultBatchSize = r;
    }
  },
  /**
   * Can we upload the same buffer in a single frame?
   * @static
   * @name CAN_UPLOAD_SAME_BUFFER
   * @memberof PIXI.settings
   * @see PIXI.BatchRenderer.canUploadSameBuffer
   * @deprecated since 7.1.0
   * @type {boolean}
   */
  CAN_UPLOAD_SAME_BUFFER: {
    get() {
      return Er.canUploadSameBuffer;
    },
    set(r) {
      fe("7.1.0", "settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"), Er.canUploadSameBuffer = r;
    }
  },
  /**
   * Default Garbage Collection mode.
   * @static
   * @name GC_MODE
   * @memberof PIXI.settings
   * @type {PIXI.GC_MODES}
   * @deprecated since 7.1.0
   * @see PIXI.TextureGCSystem.defaultMode
   */
  GC_MODE: {
    get() {
      return Tr.defaultMode;
    },
    set(r) {
      fe("7.1.0", "settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"), Tr.defaultMode = r;
    }
  },
  /**
   * Default Garbage Collection max idle.
   * @static
   * @name GC_MAX_IDLE
   * @memberof PIXI.settings
   * @type {number}
   * @deprecated since 7.1.0
   * @see PIXI.TextureGCSystem.defaultMaxIdle
   */
  GC_MAX_IDLE: {
    get() {
      return Tr.defaultMaxIdle;
    },
    set(r) {
      fe("7.1.0", "settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"), Tr.defaultMaxIdle = r;
    }
  },
  /**
   * Default Garbage Collection maximum check count.
   * @static
   * @name GC_MAX_CHECK_COUNT
   * @memberof PIXI.settings
   * @type {number}
   * @deprecated since 7.1.0
   * @see PIXI.TextureGCSystem.defaultCheckCountMax
   */
  GC_MAX_CHECK_COUNT: {
    get() {
      return Tr.defaultCheckCountMax;
    },
    set(r) {
      fe("7.1.0", "settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"), Tr.defaultCheckCountMax = r;
    }
  },
  /**
   * Default specify float precision in vertex shader.
   * @static
   * @name PRECISION_VERTEX
   * @memberof PIXI.settings
   * @type {PIXI.PRECISION}
   * @deprecated since 7.1.0
   * @see PIXI.Program.defaultVertexPrecision
   */
  PRECISION_VERTEX: {
    get() {
      return Ii.defaultVertexPrecision;
    },
    set(r) {
      fe("7.1.0", "settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"), Ii.defaultVertexPrecision = r;
    }
  },
  /**
   * Default specify float precision in fragment shader.
   * @static
   * @name PRECISION_FRAGMENT
   * @memberof PIXI.settings
   * @type {PIXI.PRECISION}
   * @deprecated since 7.1.0
   * @see PIXI.Program.defaultFragmentPrecision
   */
  PRECISION_FRAGMENT: {
    get() {
      return Ii.defaultFragmentPrecision;
    },
    set(r) {
      fe("7.1.0", "settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"), Ii.defaultFragmentPrecision = r;
    }
  }
});
var zr = /* @__PURE__ */ ((r) => (r[r.INTERACTION = 50] = "INTERACTION", r[r.HIGH = 25] = "HIGH", r[r.NORMAL = 0] = "NORMAL", r[r.LOW = -25] = "LOW", r[r.UTILITY = -50] = "UTILITY", r))(zr || {});
class eh {
  /**
   * Constructor
   * @private
   * @param fn - The listener function to be added for one update
   * @param context - The listener context
   * @param priority - The priority for emitting
   * @param once - If the handler should fire once
   */
  constructor(e, t = null, i = 0, n = !1) {
    this.next = null, this.previous = null, this._destroyed = !1, this.fn = e, this.context = t, this.priority = i, this.once = n;
  }
  /**
   * Simple compare function to figure out if a function and context match.
   * @private
   * @param fn - The listener function to be added for one update
   * @param context - The listener context
   * @returns `true` if the listener match the arguments
   */
  match(e, t = null) {
    return this.fn === e && this.context === t;
  }
  /**
   * Emit by calling the current function.
   * @private
   * @param deltaTime - time since the last emit.
   * @returns Next ticker
   */
  emit(e) {
    this.fn && (this.context ? this.fn.call(this.context, e) : this.fn(e));
    const t = this.next;
    return this.once && this.destroy(!0), this._destroyed && (this.next = null), t;
  }
  /**
   * Connect to the list.
   * @private
   * @param previous - Input node, previous listener
   */
  connect(e) {
    this.previous = e, e.next && (e.next.previous = this), this.next = e.next, e.next = this;
  }
  /**
   * Destroy and don't use after this.
   * @private
   * @param hard - `true` to remove the `next` reference, this
   *        is considered a hard destroy. Soft destroy maintains the next reference.
   * @returns The listener to redirect while emitting or removing.
   */
  destroy(e = !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 t = this.next;
    return this.next = e ? null : t, this.previous = null, t;
  }
}
const $m = class mt {
  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 eh(null, null, 1 / 0), this.deltaMS = 1 / mt.targetFPMS, this.elapsedMS = 1 / mt.targetFPMS, this._tick = (e) => {
      this._requestId = null, this.started && (this.update(e), this.started && this._requestId === null && this._head.next && (this._requestId = requestAnimationFrame(this._tick)));
    };
  }
  /**
   * Conditionally requests a new animation frame.
   * If a frame has not already been requested, and if the internal
   * emitter has listeners, a new frame is requested.
   * @private
   */
  _requestIfNeeded() {
    this._requestId === null && this._head.next && (this.lastTime = performance.now(), this._lastFrame = this.lastTime, this._requestId = requestAnimationFrame(this._tick));
  }
  /**
   * Conditionally cancels a pending animation frame.
   * @private
   */
  _cancelIfNeeded() {
    this._requestId !== null && (cancelAnimationFrame(this._requestId), this._requestId = null);
  }
  /**
   * Conditionally requests a new animation frame.
   * If the ticker has been started it checks if a frame has not already
   * been requested, and if the internal emitter has listeners. If these
   * conditions are met, a new frame is requested. If the ticker has not
   * been started, but autoStart is `true`, then the ticker starts now,
   * and continues with the previous conditions to request a new frame.
   * @private
   */
  _startIfPossible() {
    this.started ? this._requestIfNeeded() : this.autoStart && this.start();
  }
  /**
   * Register a handler for tick events. Calls continuously unless
   * it is removed or the ticker is stopped.
   * @param fn - The listener function to be added for updates
   * @param context - The listener context
   * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting
   * @returns This instance of a ticker
   */
  add(e, t, i = zr.NORMAL) {
    return this._addListener(new eh(e, t, i));
  }
  /**
   * Add a handler for the tick event which is only execute once.
   * @param fn - The listener function to be added for one update
   * @param context - The listener context
   * @param {number} [priority=PIXI.UPDATE_PRIORITY.NORMAL] - The priority for emitting
   * @returns This instance of a ticker
   */
  addOnce(e, t, i = zr.NORMAL) {
    return this._addListener(new eh(e, t, i, !0));
  }
  /**
   * Internally adds the event handler so that it can be sorted by priority.
   * Priority allows certain handler (user, AnimatedSprite, Interaction) to be run
   * before the rendering.
   * @private
   * @param listener - Current listener being added.
   * @returns This instance of a ticker
   */
  _addListener(e) {
    let t = this._head.next, i = this._head;
    if (!t)
      e.connect(i);
    else {
      for (; t; ) {
        if (e.priority > t.priority) {
          e.connect(i);
          break;
        }
        i = t, t = t.next;
      }
      e.previous || e.connect(i);
    }
    return this._startIfPossible(), this;
  }
  /**
   * Removes any handlers matching the function and context parameters.
   * If no handlers are left after removing, then it cancels the animation frame.
   * @param fn - The listener function to be removed
   * @param context - The listener context to be removed
   * @returns This instance of a ticker
   */
  remove(e, t) {
    let i = this._head.next;
    for (; i; )
      i.match(e, t) ? i = i.destroy() : i = i.next;
    return this._head.next || this._cancelIfNeeded(), this;
  }
  /**
   * The number of listeners on this ticker, calculated by walking through linked list
   * @readonly
   * @member {number}
   */
  get count() {
    if (!this._head)
      return 0;
    let e = 0, t = this._head;
    for (; t = t.next; )
      e++;
    return e;
  }
  /** Starts the ticker. If the ticker has listeners a new animation frame is requested at this point. */
  start() {
    this.started || (this.started = !0, this._requestIfNeeded());
  }
  /** Stops the ticker. If the ticker has requested an animation frame it is canceled at this point. */
  stop() {
    this.started && (this.started = !1, this._cancelIfNeeded());
  }
  /** Destroy the ticker and don't use after this. Calling this method removes all references to internal events. */
  destroy() {
    if (!this._protected) {
      this.stop();
      let e = this._head.next;
      for (; e; )
        e = e.destroy(!0);
      this._head.destroy(), this._head = null;
    }
  }
  /**
   * Triggers an update. An update entails setting the
   * current {@link PIXI.Ticker#elapsedMS},
   * the current {@link PIXI.Ticker#deltaTime},
   * invoking all listeners with current deltaTime,
   * and then finally setting {@link PIXI.Ticker#lastTime}
   * with the value of currentTime that was provided.
   * This method will be called automatically by animation
   * frame callbacks if the ticker instance has been started
   * and listeners are added.
   * @param {number} [currentTime=performance.now()] - the current time of execution
   */
  update(e = performance.now()) {
    let t;
    if (e > this.lastTime) {
      if (t = this.elapsedMS = e - this.lastTime, t > this._maxElapsedMS && (t = this._maxElapsedMS), t *= this.speed, this._minElapsedMS) {
        const s = e - this._lastFrame | 0;
        if (s < this._minElapsedMS)
          return;
        this._lastFrame = e - s % this._minElapsedMS;
      }
      this.deltaMS = t, this.deltaTime = this.deltaMS * mt.targetFPMS;
      const i = this._head;
      let n = i.next;
      for (; n; )
        n = n.emit(this.deltaTime);
      i.next || this._cancelIfNeeded();
    } else
      this.deltaTime = this.deltaMS = this.elapsedMS = 0;
    this.lastTime = e;
  }
  /**
   * The frames per second at which this ticker is running.
   * The default is approximately 60 in most modern browsers.
   * **Note:** This does not factor in the value of
   * {@link PIXI.Ticker#speed}, which is specific
   * to scaling {@link PIXI.Ticker#deltaTime}.
   * @member {number}
   * @readonly
   */
  get FPS() {
    return 1e3 / this.elapsedMS;
  }
  /**
   * Manages the maximum amount of milliseconds allowed to
   * elapse between invoking {@link PIXI.Ticker#update}.
   * This value is used to cap {@link PIXI.Ticker#deltaTime},
   * but does not effect the measured value of {@link PIXI.Ticker#FPS}.
   * When setting this property it is clamped to a value between
   * `0` and `Ticker.targetFPMS * 1000`.
   * @member {number}
   * @default 10
   */
  get minFPS() {
    return 1e3 / this._maxElapsedMS;
  }
  set minFPS(e) {
    const t = Math.min(this.maxFPS, e), i = Math.min(Math.max(0, t) / 1e3, mt.targetFPMS);
    this._maxElapsedMS = 1 / i;
  }
  /**
   * Manages the minimum amount of milliseconds required to
   * elapse between invoking {@link PIXI.Ticker#update}.
   * This will effect the measured value of {@link PIXI.Ticker#FPS}.
   * If it is set to `0`, then there is no limit; PixiJS will render as many frames as it can.
   * Otherwise it will be at least `minFPS`
   * @member {number}
   * @default 0
   */
  get maxFPS() {
    return this._minElapsedMS ? Math.round(1e3 / this._minElapsedMS) : 0;
  }
  set maxFPS(e) {
    if (e === 0)
      this._minElapsedMS = 0;
    else {
      const t = Math.max(this.minFPS, e);
      this._minElapsedMS = 1 / (t / 1e3);
    }
  }
  /**
   * The shared ticker instance used by {@link PIXI.AnimatedSprite} and by
   * {@link PIXI.VideoResource} to update animation frames / video textures.
   *
   * It may also be used by {@link PIXI.Application} if created with the `sharedTicker` option property set to true.
   *
   * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.
   * Please follow the examples for usage, including how to opt-out of auto-starting the shared ticker.
   * @example
   * import { Ticker } from 'pixi.js';
   *
   * const ticker = Ticker.shared;
   * // Set this to prevent starting this ticker when listeners are added.
   * // By default this is true only for the PIXI.Ticker.shared instance.
   * ticker.autoStart = false;
   *
   * // FYI, call this to ensure the ticker is stopped. It should be stopped
   * // if you have not attempted to render anything yet.
   * ticker.stop();
   *
   * // Call this when you are ready for a running shared ticker.
   * ticker.start();
   * @example
   * import { autoDetectRenderer, Container } from 'pixi.js';
   *
   * // You may use the shared ticker to render...
   * const renderer = autoDetectRenderer();
   * const stage = new Container();
   * document.body.appendChild(renderer.view);
   * ticker.add((time) => renderer.render(stage));
   *
   * // Or you can just update it manually.
   * ticker.autoStart = false;
   * ticker.stop();
   * const animate = (time) => {
   *     ticker.update(time);
   *     renderer.render(stage);
   *     requestAnimationFrame(animate);
   * };
   * animate(performance.now());
   * @member {PIXI.Ticker}
   * @static
   */
  static get shared() {
    if (!mt._shared) {
      const e = mt._shared = new mt();
      e.autoStart = !0, e._protected = !0;
    }
    return mt._shared;
  }
  /**
   * The system ticker instance used by {@link PIXI.BasePrepare} for core timing
   * functionality that shouldn't usually need to be paused, unlike the `shared`
   * ticker which drives visual animations and rendering which may want to be paused.
   *
   * The property {@link PIXI.Ticker#autoStart} is set to `true` for this instance.
   * @member {PIXI.Ticker}
   * @static
   */
  static get system() {
    if (!mt._system) {
      const e = mt._system = new mt();
      e.autoStart = !0, e._protected = !0;
    }
    return mt._system;
  }
};
$m.targetFPMS = 0.06;
let bt = $m;
Object.defineProperties(Z, {
  /**
   * Target frames per millisecond.
   * @static
   * @name TARGET_FPMS
   * @memberof PIXI.settings
   * @type {number}
   * @deprecated since 7.1.0
   * @see PIXI.Ticker.targetFPMS
   */
  TARGET_FPMS: {
    get() {
      return bt.targetFPMS;
    },
    set(r) {
      fe("7.1.0", "settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"), bt.targetFPMS = r;
    }
  }
});
class Jm {
  /**
   * Initialize the plugin with scope of application instance
   * @static
   * @private
   * @param {object} [options] - See application options
   */
  static init(e) {
    e = Object.assign({
      autoStart: !0,
      sharedTicker: !1
    }, e), Object.defineProperty(
      this,
      "ticker",
      {
        set(t) {
          this._ticker && this._ticker.remove(this.render, this), this._ticker = t, t && t.add(this.render, this, zr.LOW);
        },
        get() {
          return this._ticker;
        }
      }
    ), this.stop = () => {
      this._ticker.stop();
    }, this.start = () => {
      this._ticker.start();
    }, this._ticker = null, this.ticker = e.sharedTicker ? bt.shared : new bt(), e.autoStart && this.start();
  }
  /**
   * Clean up the ticker, scoped to application.
   * @static
   * @private
   */
  static destroy() {
    if (this._ticker) {
      const e = this._ticker;
      this.ticker = null, e.destroy();
    }
  }
}
Jm.extension = q.Application;
Q.add(Jm);
const Qm = [];
Q.handleByList(q.Renderer, Qm);
function US(r) {
  for (const e of Qm)
    if (e.test(r))
      return new e(r);
  throw new Error("Unable to auto-detect a suitable renderer.");
}
var GS = `attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat3 projectionMatrix;

varying vec2 vTextureCoord;

void main(void)
{
    gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
    vTextureCoord = aTextureCoord;
}`, HS = `attribute vec2 aVertexPosition;

uniform mat3 projectionMatrix;

varying vec2 vTextureCoord;

uniform vec4 inputSize;
uniform vec4 outputFrame;

vec4 filterVertexPosition( void )
{
    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aVertexPosition * (outputFrame.zw * inputSize.zw);
}

void main(void)
{
    gl_Position = filterVertexPosition();
    vTextureCoord = filterTextureCoord();
}
`;
const zS = GS, e0 = HS;
class t0 {
  constructor(e) {
    this.renderer = e;
  }
  contextChange(e) {
    let t;
    if (this.renderer.context.webGLVersion === 1) {
      const i = e.getParameter(e.FRAMEBUFFER_BINDING);
      e.bindFramebuffer(e.FRAMEBUFFER, null), t = e.getParameter(e.SAMPLES), e.bindFramebuffer(e.FRAMEBUFFER, i);
    } else {
      const i = e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);
      e.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), t = e.getParameter(e.SAMPLES), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, i);
    }
    t >= Le.HIGH ? this.multisample = Le.HIGH : t >= Le.MEDIUM ? this.multisample = Le.MEDIUM : t >= Le.LOW ? this.multisample = Le.LOW : this.multisample = Le.NONE;
  }
  destroy() {
  }
}
t0.extension = {
  type: q.RendererSystem,
  name: "_multisample"
};
Q.add(t0);
class XS {
  constructor(e) {
    this.buffer = e || null, this.updateID = -1, this.byteLength = -1, this.refCount = 0;
  }
}
class i0 {
  /**
   * @param {PIXI.Renderer} renderer - The renderer this System works for.
   */
  constructor(e) {
    this.renderer = e, this.managedBuffers = {}, this.boundBufferBases = {};
  }
  /**
   * @ignore
   */
  destroy() {
    this.renderer = null;
  }
  /** Sets up the renderer context and necessary buffers. */
  contextChange() {
    this.disposeAll(!0), this.gl = this.renderer.gl, this.CONTEXT_UID = this.renderer.CONTEXT_UID;
  }
  /**
   * This binds specified buffer. On first run, it will create the webGL buffers for the context too
   * @param buffer - the buffer to bind to the renderer
   */
  bind(e) {
    const { gl: t, CONTEXT_UID: i } = this, n = e._glBuffers[i] || this.createGLBuffer(e);
    t.bindBuffer(e.type, n.buffer);
  }
  unbind(e) {
    const { gl: t } = this;
    t.bindBuffer(e, null);
  }
  /**
   * Binds an uniform buffer to at the given index.
   *
   * A cache is used so a buffer will not be bound again if already bound.
   * @param buffer - the buffer to bind
   * @param index - the base index to bind it to.
   */
  bindBufferBase(e, t) {
    const { gl: i, CONTEXT_UID: n } = this;
    if (this.boundBufferBases[t] !== e) {
      const s = e._glBuffers[n] || this.createGLBuffer(e);
      this.boundBufferBases[t] = e, i.bindBufferBase(i.UNIFORM_BUFFER, t, s.buffer);
    }
  }
  /**
   * Binds a buffer whilst also binding its range.
   * This will make the buffer start from the offset supplied rather than 0 when it is read.
   * @param buffer - the buffer to bind
   * @param index - the base index to bind at, defaults to 0
   * @param offset - the offset to bind at (this is blocks of 256). 0 = 0, 1 = 256, 2 = 512 etc
   */
  bindBufferRange(e, t, i) {
    const { gl: n, CONTEXT_UID: s } = this;
    i = i || 0;
    const o = e._glBuffers[s] || this.createGLBuffer(e);
    n.bindBufferRange(n.UNIFORM_BUFFER, t || 0, o.buffer, i * 256, 256);
  }
  /**
   * Will ensure the data in the buffer is uploaded to the GPU.
   * @param {PIXI.Buffer} buffer - the buffer to update
   */
  update(e) {
    const { gl: t, CONTEXT_UID: i } = this, n = e._glBuffers[i] || this.createGLBuffer(e);
    if (e._updateID !== n.updateID)
      if (n.updateID = e._updateID, t.bindBuffer(e.type, n.buffer), n.byteLength >= e.data.byteLength)
        t.bufferSubData(e.type, 0, e.data);
      else {
        const s = e.static ? t.STATIC_DRAW : t.DYNAMIC_DRAW;
        n.byteLength = e.data.byteLength, t.bufferData(e.type, e.data, s);
      }
  }
  /**
   * Disposes buffer
   * @param {PIXI.Buffer} buffer - buffer with data
   * @param {boolean} [contextLost=false] - If context was lost, we suppress deleteVertexArray
   */
  dispose(e, t) {
    if (!this.managedBuffers[e.id])
      return;
    delete this.managedBuffers[e.id];
    const i = e._glBuffers[this.CONTEXT_UID], n = this.gl;
    e.disposeRunner.remove(this), i && (t || n.deleteBuffer(i.buffer), delete e._glBuffers[this.CONTEXT_UID]);
  }
  /**
   * dispose all WebGL resources of all managed buffers
   * @param {boolean} [contextLost=false] - If context was lost, we suppress `gl.delete` calls
   */
  disposeAll(e) {
    const t = Object.keys(this.managedBuffers);
    for (let i = 0; i < t.length; i++)
      this.dispose(this.managedBuffers[t[i]], e);
  }
  /**
   * creates and attaches a GLBuffer object tied to the current context.
   * @param buffer
   * @protected
   */
  createGLBuffer(e) {
    const { CONTEXT_UID: t, gl: i } = this;
    return e._glBuffers[t] = new XS(i.createBuffer()), this.managedBuffers[e.id] = e, e.disposeRunner.add(this), e._glBuffers[t];
  }
}
i0.extension = {
  type: q.RendererSystem,
  name: "buffer"
};
Q.add(i0);
class r0 {
  // renderers scene graph!
  constructor(e) {
    this.renderer = e;
  }
  /**
   * Renders the object to its WebGL view.
   * @param displayObject - The object to be rendered.
   * @param options - the options to be passed to the renderer
   */
  render(e, t) {
    const i = this.renderer;
    let n, s, o, a;
    if (t && (n = t.renderTexture, s = t.clear, o = t.transform, a = t.skipUpdateTransform), this.renderingToScreen = !n, i.runners.prerender.emit(), i.emit("prerender"), i.projection.transform = o, !i.context.isLost) {
      if (n || (this.lastObjectRendered = e), !a) {
        const l = e.enableTempParent();
        e.updateTransform(), e.disableTempParent(l);
      }
      i.renderTexture.bind(n), i.batch.currentRenderer.start(), (s ?? i.background.clearBeforeRender) && i.renderTexture.clear(), e.render(i), i.batch.currentRenderer.flush(), n && (t.blit && i.framebuffer.blit(), n.baseTexture.update()), i.runners.postrender.emit(), i.projection.transform = null, i.emit("postrender");
    }
  }
  destroy() {
    this.renderer = null, this.lastObjectRendered = null;
  }
}
r0.extension = {
  type: q.RendererSystem,
  name: "objectRenderer"
};
Q.add(r0);
const Do = class uc extends OS {
  /**
   * @param {PIXI.IRendererOptions} [options] - See {@link PIXI.settings.RENDER_OPTIONS} for defaults.
   */
  constructor(e) {
    super(), this.type = V_.WEBGL, e = Object.assign({}, Z.RENDER_OPTIONS, e), this.gl = null, this.CONTEXT_UID = 0, this.globalUniforms = new Jt({
      projectionMatrix: new Te()
    }, !0);
    const t = {
      runners: [
        "init",
        "destroy",
        "contextChange",
        "resolutionChange",
        "reset",
        "update",
        "postrender",
        "prerender",
        "resize"
      ],
      systems: uc.__systems,
      priority: [
        "_view",
        "textureGenerator",
        "background",
        "_plugin",
        "startup",
        // low level WebGL systems
        "context",
        "state",
        "texture",
        "buffer",
        "geometry",
        "framebuffer",
        "transformFeedback",
        // high level pixi specific rendering
        "mask",
        "scissor",
        "stencil",
        "projection",
        "textureGC",
        "filter",
        "renderTexture",
        "batch",
        "objectRenderer",
        "_multisample"
      ]
    };
    this.setup(t), "useContextAlpha" in e && (fe("7.0.0", "options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"), e.premultipliedAlpha = e.useContextAlpha && e.useContextAlpha !== "notMultiplied", e.backgroundAlpha = e.useContextAlpha === !1 ? 1 : e.backgroundAlpha), this._plugin.rendererPlugins = uc.__plugins, this.options = e, this.startup.run(this.options);
  }
  /**
   * Create renderer if WebGL is available. Overrideable
   * by the **@pixi/canvas-renderer** package to allow fallback.
   * throws error if WebGL is not available.
   * @param options
   * @private
   */
  static test(e) {
    return e != null && e.forceCanvas ? !1 : dA();
  }
  /**
   * Renders the object to its WebGL view.
   * @param displayObject - The object to be rendered.
   * @param {object} [options] - Object to use for render options.
   * @param {PIXI.RenderTexture} [options.renderTexture] - The render texture to render to.
   * @param {boolean} [options.clear=true] - Should the canvas be cleared before the new render.
   * @param {PIXI.Matrix} [options.transform] - A transform to apply to the render texture before rendering.
   * @param {boolean} [options.skipUpdateTransform=false] - Should we skip the update transform pass?
   */
  render(e, t) {
    this.objectRenderer.render(e, t);
  }
  /**
   * Resizes the WebGL view to the specified width and height.
   * @param desiredScreenWidth - The desired width of the screen.
   * @param desiredScreenHeight - The desired height of the screen.
   */
  resize(e, t) {
    this._view.resizeView(e, t);
  }
  /**
   * Resets the WebGL state so you can render things however you fancy!
   * @returns Returns itself.
   */
  reset() {
    return this.runners.reset.emit(), this;
  }
  /** Clear the frame buffer. */
  clear() {
    this.renderTexture.bind(), this.renderTexture.clear();
  }
  /**
   * Removes everything from the renderer (event listeners, spritebatch, etc...)
   * @param [removeView=false] - Removes the Canvas element from the DOM.
   *  See: https://github.com/pixijs/pixijs/issues/2233
   */
  destroy(e = !1) {
    this.runners.destroy.items.reverse(), this.emitWithCustomOptions(this.runners.destroy, {
      _view: e
    }), super.destroy();
  }
  /** Collection of plugins */
  get plugins() {
    return this._plugin.plugins;
  }
  /** The number of msaa samples of the canvas. */
  get multisample() {
    return this._multisample.multisample;
  }
  /**
   * Same as view.width, actual number of pixels in the canvas by horizontal.
   * @member {number}
   * @readonly
   * @default 800
   */
  get width() {
    return this._view.element.width;
  }
  /**
   * Same as view.height, actual number of pixels in the canvas by vertical.
   * @default 600
   */
  get height() {
    return this._view.element.height;
  }
  /** The resolution / device pixel ratio of the renderer. */
  get resolution() {
    return this._view.resolution;
  }
  set resolution(e) {
    this._view.resolution = e, this.runners.resolutionChange.emit(e);
  }
  /** Whether CSS dimensions of canvas view should be resized to screen dimensions automatically. */
  get autoDensity() {
    return this._view.autoDensity;
  }
  /** The canvas element that everything is drawn to.*/
  get view() {
    return this._view.element;
  }
  /**
   * Measurements of the screen. (0, 0, screenWidth, screenHeight).
   *
   * Its safe to use as filterArea or hitArea for the whole stage.
   * @member {PIXI.Rectangle}
   */
  get screen() {
    return this._view.screen;
  }
  /** the last object rendered by the renderer. Useful for other plugins like interaction managers */
  get lastObjectRendered() {
    return this.objectRenderer.lastObjectRendered;
  }
  /** Flag if we are rendering to the screen vs renderTexture */
  get renderingToScreen() {
    return this.objectRenderer.renderingToScreen;
  }
  /** When logging Pixi to the console, this is the name we will show */
  get rendererLogId() {
    return `WebGL ${this.context.webGLVersion}`;
  }
  /**
   * This sets weather the screen is totally cleared between each frame withthe background color and alpha
   * @deprecated since 7.0.0
   */
  get clearBeforeRender() {
    return fe("7.0.0", "renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."), this.background.clearBeforeRender;
  }
  /**
   * Pass-thru setting for the canvas' context `alpha` property. This is typically
   * not something you need to fiddle with. If you want transparency, use `backgroundAlpha`.
   * @deprecated since 7.0.0
   * @member {boolean}
   */
  get useContextAlpha() {
    return fe("7.0.0", "renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."), this.context.useContextAlpha;
  }
  /**
   * readonly drawing buffer preservation
   * we can only know this if Pixi created the context
   * @deprecated since 7.0.0
   */
  get preserveDrawingBuffer() {
    return fe("7.0.0", "renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"), this.context.preserveDrawingBuffer;
  }
  /**
   * The background color to fill if not transparent
   * @member {number}
   * @deprecated since 7.0.0
   */
  get backgroundColor() {
    return fe("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead."), this.background.color;
  }
  set backgroundColor(e) {
    fe("7.0.0", "renderer.backgroundColor has been deprecated, use renderer.background.color instead."), this.background.color = e;
  }
  /**
   * The background color alpha. Setting this to 0 will make the canvas transparent.
   * @member {number}
   * @deprecated since 7.0.0
   */
  get backgroundAlpha() {
    return fe("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."), this.background.alpha;
  }
  /**
   * @deprecated since 7.0.0
   */
  set backgroundAlpha(e) {
    fe("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."), this.background.alpha = e;
  }
  /**
   * @deprecated since 7.0.0
   */
  get powerPreference() {
    return fe("7.0.0", "renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"), this.context.powerPreference;
  }
  /**
   * Useful function that returns a texture of the display object that can then be used to create sprites
   * This can be quite useful if your displayObject is complicated and needs to be reused multiple times.
   * @param displayObject - The displayObject the object will be generated from.
   * @param {IGenerateTextureOptions} options - Generate texture options.
   * @param {PIXI.Rectangle} options.region - The region of the displayObject, that shall be rendered,
   *        if no region is specified, defaults to the local bounds of the displayObject.
   * @param {number} [options.resolution] - If not given, the renderer's resolution is used.
   * @param {PIXI.MSAA_QUALITY} [options.multisample] - If not given, the renderer's multisample is used.
   * @returns A texture of the graphics object.
   */
  generateTexture(e, t) {
    return this.textureGenerator.generateTexture(e, t);
  }
};
Do.extension = {
  type: q.Renderer,
  priority: 1
}, /**
* Collection of installed plugins. These are included by default in PIXI, but can be excluded
* by creating a custom build. Consult the README for more information about creating custom
* builds and excluding plugins.
* @private
*/
Do.__plugins = {}, /**
* The collection of installed systems.
* @private
*/
Do.__systems = {};
let ou = Do;
Q.handleByMap(q.RendererPlugin, ou.__plugins);
Q.handleByMap(q.RendererSystem, ou.__systems);
Q.add(ou);
class n0 extends Ds {
  /**
   * @param length
   * @param options - Options to for Resource constructor
   * @param {number} [options.width] - Width of the resource
   * @param {number} [options.height] - Height of the resource
   */
  constructor(e, t) {
    const { width: i, height: n } = t || {};
    super(i, n), this.items = [], this.itemDirtyIds = [];
    for (let s = 0; s < e; s++) {
      const o = new ae();
      this.items.push(o), this.itemDirtyIds.push(-2);
    }
    this.length = e, this._load = null, this.baseTexture = null;
  }
  /**
   * Used from ArrayResource and CubeResource constructors.
   * @param resources - Can be resources, image elements, canvas, etc. ,
   *  length should be same as constructor length
   * @param options - Detect options for resources
   */
  initFromArray(e, t) {
    for (let i = 0; i < this.length; i++)
      e[i] && (e[i].castToBaseTexture ? this.addBaseTextureAt(e[i].castToBaseTexture(), i) : e[i] instanceof Ds ? this.addResourceAt(e[i], i) : this.addResourceAt(xm(e[i], t), i));
  }
  /** Destroy this BaseImageResource. */
  dispose() {
    for (let e = 0, t = this.length; e < t; e++)
      this.items[e].destroy();
    this.items = null, this.itemDirtyIds = null, this._load = null;
  }
  /**
   * Set a resource by ID
   * @param resource
   * @param index - Zero-based index of resource to set
   * @returns - Instance for chaining
   */
  addResourceAt(e, t) {
    if (!this.items[t])
      throw new Error(`Index ${t} is out of bounds`);
    return e.valid && !this.valid && this.resize(e.width, e.height), this.items[t].setResource(e), this;
  }
  /**
   * Set the parent base texture.
   * @param baseTexture
   */
  bind(e) {
    if (this.baseTexture !== null)
      throw new Error("Only one base texture per TextureArray is allowed");
    super.bind(e);
    for (let t = 0; t < this.length; t++)
      this.items[t].parentTextureArray = e, this.items[t].on("update", e.update, e);
  }
  /**
   * Unset the parent base texture.
   * @param baseTexture
   */
  unbind(e) {
    super.unbind(e);
    for (let t = 0; t < this.length; t++)
      this.items[t].parentTextureArray = null, this.items[t].off("update", e.update, e);
  }
  /**
   * Load all the resources simultaneously
   * @returns - When load is resolved
   */
  load() {
    if (this._load)
      return this._load;
    const e = this.items.map((t) => t.resource).filter((t) => t).map((t) => t.load());
    return this._load = Promise.all(e).then(
      () => {
        const { realWidth: t, realHeight: i } = this.items[0];
        return this.resize(t, i), this.update(), Promise.resolve(this);
      }
    ), this._load;
  }
}
class VS extends n0 {
  /**
   * @param source - Number of items in array or the collection
   *        of image URLs to use. Can also be resources, image elements, canvas, etc.
   * @param options - Options to apply to {@link PIXI.autoDetectResource}
   * @param {number} [options.width] - Width of the resource
   * @param {number} [options.height] - Height of the resource
   */
  constructor(e, t) {
    const { width: i, height: n } = t || {};
    let s, o;
    Array.isArray(e) ? (s = e, o = e.length) : o = e, super(o, { width: i, height: n }), s && this.initFromArray(s, t);
  }
  /**
   * Set a baseTexture by ID,
   * ArrayResource just takes resource from it, nothing more
   * @param baseTexture
   * @param index - Zero-based index of resource to set
   * @returns - Instance for chaining
   */
  addBaseTextureAt(e, t) {
    if (e.resource)
      this.addResourceAt(e.resource, t);
    else
      throw new Error("ArrayResource does not support RenderTexture");
    return this;
  }
  /**
   * Add binding
   * @param baseTexture
   */
  bind(e) {
    super.bind(e), e.target = Tn.TEXTURE_2D_ARRAY;
  }
  /**
   * Upload the resources to the GPU.
   * @param renderer
   * @param texture
   * @param glTexture
   * @returns - whether texture was uploaded
   */
  upload(e, t, i) {
    const { length: n, itemDirtyIds: s, items: o } = this, { gl: a } = e;
    i.dirtyId < 0 && a.texImage3D(
      a.TEXTURE_2D_ARRAY,
      0,
      i.internalFormat,
      this._width,
      this._height,
      n,
      0,
      t.format,
      i.type,
      null
    );
    for (let l = 0; l < n; l++) {
      const h = o[l];
      s[l] < h.dirtyId && (s[l] = h.dirtyId, h.valid && a.texSubImage3D(
        a.TEXTURE_2D_ARRAY,
        0,
        0,
        // xoffset
        0,
        // yoffset
        l,
        // zoffset
        h.resource.width,
        h.resource.height,
        1,
        t.format,
        i.type,
        h.resource.source
      ));
    }
    return !0;
  }
}
class WS extends Bi {
  /**
   * @param source - Canvas element to use
   */
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
  constructor(e) {
    super(e);
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if source is HTMLCanvasElement or OffscreenCanvas
   */
  static test(e) {
    const { OffscreenCanvas: t } = globalThis;
    return t && e instanceof t ? !0 : globalThis.HTMLCanvasElement && e instanceof HTMLCanvasElement;
  }
}
const s0 = class us extends n0 {
  /**
   * @param {Array<string|PIXI.Resource>} [source] - Collection of URLs or resources
   *        to use as the sides of the cube.
   * @param options - ImageResource options
   * @param {number} [options.width] - Width of resource
   * @param {number} [options.height] - Height of resource
   * @param {number} [options.autoLoad=true] - Whether to auto-load resources
   * @param {number} [options.linkBaseTexture=true] - In case BaseTextures are supplied,
   *   whether to copy them or use
   */
  constructor(e, t) {
    const { width: i, height: n, autoLoad: s, linkBaseTexture: o } = t || {};
    if (e && e.length !== us.SIDES)
      throw new Error(`Invalid length. Got ${e.length}, expected 6`);
    super(6, { width: i, height: n });
    for (let a = 0; a < us.SIDES; a++)
      this.items[a].target = Tn.TEXTURE_CUBE_MAP_POSITIVE_X + a;
    this.linkBaseTexture = o !== !1, e && this.initFromArray(e, t), s !== !1 && this.load();
  }
  /**
   * Add binding.
   * @param baseTexture - parent base texture
   */
  bind(e) {
    super.bind(e), e.target = Tn.TEXTURE_CUBE_MAP;
  }
  addBaseTextureAt(e, t, i) {
    if (i === void 0 && (i = this.linkBaseTexture), !this.items[t])
      throw new Error(`Index ${t} is out of bounds`);
    if (!this.linkBaseTexture || e.parentTextureArray || Object.keys(e._glTextures).length > 0)
      if (e.resource)
        this.addResourceAt(e.resource, t);
      else
        throw new Error("CubeResource does not support copying of renderTexture.");
    else
      e.target = Tn.TEXTURE_CUBE_MAP_POSITIVE_X + t, e.parentTextureArray = this.baseTexture, this.items[t] = e;
    return e.valid && !this.valid && this.resize(e.realWidth, e.realHeight), this.items[t] = e, this;
  }
  /**
   * Upload the resource
   * @param renderer
   * @param _baseTexture
   * @param glTexture
   * @returns {boolean} true is success
   */
  upload(e, t, i) {
    const n = this.itemDirtyIds;
    for (let s = 0; s < us.SIDES; s++) {
      const o = this.items[s];
      (n[s] < o.dirtyId || i.dirtyId < t.dirtyId) && (o.valid && o.resource ? (o.resource.upload(e, o, i), n[s] = o.dirtyId) : n[s] < -1 && (e.gl.texImage2D(
        o.target,
        0,
        i.internalFormat,
        t.realWidth,
        t.realHeight,
        0,
        t.format,
        i.type,
        null
      ), n[s] = -1));
    }
    return !0;
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if source is an array of 6 elements
   */
  static test(e) {
    return Array.isArray(e) && e.length === us.SIDES;
  }
};
s0.SIDES = 6;
let jS = s0;
class xn extends Bi {
  /**
   * @param source - ImageBitmap or URL to use.
   * @param options - Options to use.
   */
  constructor(e, t) {
    t = t || {};
    let i, n, s;
    typeof e == "string" ? (i = xn.EMPTY, n = e, s = !0) : (i = e, n = null, s = !1), super(i), this.url = n, this.crossOrigin = t.crossOrigin ?? !0, this.alphaMode = typeof t.alphaMode == "number" ? t.alphaMode : null, this.ownsImageBitmap = t.ownsImageBitmap ?? s, this._load = null, t.autoLoad !== !1 && this.load();
  }
  load() {
    return this._load ? this._load : (this._load = new Promise(async (e, t) => {
      if (this.url === null) {
        e(this);
        return;
      }
      try {
        const i = await Z.ADAPTER.fetch(this.url, {
          mode: this.crossOrigin ? "cors" : "no-cors"
        });
        if (this.destroyed)
          return;
        const n = await i.blob();
        if (this.destroyed)
          return;
        const s = await createImageBitmap(n, {
          premultiplyAlpha: this.alphaMode === null || this.alphaMode === ut.UNPACK ? "premultiply" : "none"
        });
        if (this.destroyed) {
          s.close();
          return;
        }
        this.source = s, this.update(), e(this);
      } catch (i) {
        if (this.destroyed)
          return;
        t(i), this.onError.emit(i);
      }
    }), this._load);
  }
  /**
   * Upload the image bitmap resource to GPU.
   * @param renderer - Renderer to upload to
   * @param baseTexture - BaseTexture for this resource
   * @param glTexture - GLTexture to use
   * @returns {boolean} true is success
   */
  upload(e, t, i) {
    return this.source instanceof ImageBitmap ? (typeof this.alphaMode == "number" && (t.alphaMode = this.alphaMode), super.upload(e, t, i)) : (this.load(), !1);
  }
  /** Destroys this resource. */
  dispose() {
    this.ownsImageBitmap && this.source instanceof ImageBitmap && this.source.close(), super.dispose(), this._load = null;
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if current environment support ImageBitmap, and source is string or ImageBitmap
   */
  static test(e) {
    return !!globalThis.createImageBitmap && typeof ImageBitmap < "u" && (typeof e == "string" || e instanceof ImageBitmap);
  }
  /**
   * ImageBitmap cannot be created synchronously, so a empty placeholder canvas is needed when loading from URLs.
   * Only for internal usage.
   * @returns The cached placeholder canvas.
   */
  static get EMPTY() {
    return xn._EMPTY = xn._EMPTY ?? Z.ADAPTER.createCanvas(0, 0), xn._EMPTY;
  }
}
const dc = class Bo extends Bi {
  /**
   * @param sourceBase64 - Base64 encoded SVG element or URL for SVG file.
   * @param {object} [options] - Options to use
   * @param {number} [options.scale=1] - Scale to apply to SVG. Overridden by...
   * @param {number} [options.width] - Rasterize SVG this wide. Aspect ratio preserved if height not specified.
   * @param {number} [options.height] - Rasterize SVG this high. Aspect ratio preserved if width not specified.
   * @param {boolean} [options.autoLoad=true] - Start loading right away.
   */
  constructor(e, t) {
    t = t || {}, super(Z.ADAPTER.createCanvas()), this._width = 0, this._height = 0, this.svg = e, this.scale = t.scale || 1, this._overrideWidth = t.width, this._overrideHeight = t.height, this._resolve = null, this._crossorigin = t.crossorigin, this._load = null, t.autoLoad !== !1 && this.load();
  }
  load() {
    return this._load ? this._load : (this._load = new Promise((e) => {
      if (this._resolve = () => {
        this.update(), e(this);
      }, Bo.SVG_XML.test(this.svg.trim())) {
        if (!btoa)
          throw new Error("Your browser doesn't support base64 conversions.");
        this.svg = `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`;
      }
      this._loadSvg();
    }), this._load);
  }
  /** Loads an SVG image from `imageUrl` or `data URL`. */
  _loadSvg() {
    const e = new Image();
    Bi.crossOrigin(e, this.svg, this._crossorigin), e.src = this.svg, e.onerror = (t) => {
      this._resolve && (e.onerror = null, this.onError.emit(t));
    }, e.onload = () => {
      if (!this._resolve)
        return;
      const t = e.width, i = e.height;
      if (!t || !i)
        throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");
      let n = t * this.scale, s = i * this.scale;
      (this._overrideWidth || this._overrideHeight) && (n = this._overrideWidth || this._overrideHeight / i * t, s = this._overrideHeight || this._overrideWidth / t * i), n = Math.round(n), s = Math.round(s);
      const o = this.source;
      o.width = n, o.height = s, o._pixiId = `canvas_${Hr()}`, o.getContext("2d").drawImage(e, 0, 0, t, i, 0, 0, n, s), this._resolve(), this._resolve = null;
    };
  }
  /**
   * Get size from an svg string using a regular expression.
   * @param svgString - a serialized svg element
   * @returns - image extension
   */
  static getSize(e) {
    const t = Bo.SVG_SIZE.exec(e), i = {};
    return t && (i[t[1]] = Math.round(parseFloat(t[3])), i[t[5]] = Math.round(parseFloat(t[7]))), i;
  }
  /** Destroys this texture. */
  dispose() {
    super.dispose(), this._resolve = null, this._crossorigin = null;
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @param {string} extension - The extension of source, if set
   * @returns {boolean} - If the source is a SVG source or data file
   */
  static test(e, t) {
    return t === "svg" || typeof e == "string" && e.startsWith("data:image/svg+xml") || typeof e == "string" && Bo.SVG_XML.test(e);
  }
  // eslint-disable-line max-len
};
dc.SVG_XML = /^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m, /**
* Regular expression for SVG size.
* @example &lt;svg width="100" height="100"&gt;&lt;/svg&gt;
* @readonly
*/
dc.SVG_SIZE = /<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;
let fc = dc;
class qS extends Bi {
  /**
   * @param source - Image element to use
   */
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
  constructor(e) {
    super(e);
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @returns {boolean} `true` if source is an VideoFrame
   */
  static test(e) {
    return !!globalThis.VideoFrame && e instanceof globalThis.VideoFrame;
  }
}
const pc = class _c extends Bi {
  /**
   * @param {HTMLVideoElement|object|string|Array<string|object>} source - Video element to use.
   * @param {object} [options] - Options to use
   * @param {boolean} [options.autoLoad=true] - Start loading the video immediately
   * @param {boolean} [options.autoPlay=true] - Start playing video immediately
   * @param {number} [options.updateFPS=0] - How many times a second to update the texture from the video.
   * If 0, `requestVideoFrameCallback` is used to update the texture.
   * If `requestVideoFrameCallback` is not available, the texture is updated every render.
   * @param {boolean} [options.crossorigin=true] - Load image using cross origin
   * @param {boolean} [options.loop=false] - Loops the video
   * @param {boolean} [options.muted=false] - Mutes the video audio, useful for autoplay
   * @param {boolean} [options.playsinline=true] - Prevents opening the video on mobile devices
   */
  constructor(e, t) {
    if (t = t || {}, !(e instanceof HTMLVideoElement)) {
      const i = document.createElement("video");
      t.autoLoad !== !1 && i.setAttribute("preload", "auto"), t.playsinline !== !1 && (i.setAttribute("webkit-playsinline", ""), i.setAttribute("playsinline", "")), t.muted === !0 && (i.setAttribute("muted", ""), i.muted = !0), t.loop === !0 && i.setAttribute("loop", ""), t.autoPlay !== !1 && i.setAttribute("autoplay", ""), typeof e == "string" && (e = [e]);
      const n = e[0].src || e[0];
      Bi.crossOrigin(i, n, t.crossorigin);
      for (let s = 0; s < e.length; ++s) {
        const o = document.createElement("source");
        let { src: a, mime: l } = e[s];
        if (a = a || e[s], a.startsWith("data:"))
          l = a.slice(5, a.indexOf(";"));
        else if (!a.startsWith("blob:")) {
          const h = a.split("?").shift().toLowerCase(), c = h.slice(h.lastIndexOf(".") + 1);
          l = l || _c.MIME_TYPES[c] || `video/${c}`;
        }
        o.src = a, l && (o.type = l), i.appendChild(o);
      }
      e = i;
    }
    super(e), this.noSubImage = !0, this._autoUpdate = !0, this._isConnectedToTicker = !1, this._updateFPS = t.updateFPS || 0, this._msToNextUpdate = 0, this.autoPlay = t.autoPlay !== !1, 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._onError = this._onError.bind(this), this._onPlayStart = this._onPlayStart.bind(this), this._onPlayStop = this._onPlayStop.bind(this), this._onSeeked = this._onSeeked.bind(this), t.autoLoad !== !1 && this.load();
  }
  /**
   * Trigger updating of the texture.
   * @param _deltaTime - time delta since last tick
   */
  update(e = 0) {
    if (!this.destroyed) {
      if (this._updateFPS) {
        const t = bt.shared.elapsedMS * this.source.playbackRate;
        this._msToNextUpdate = Math.floor(this._msToNextUpdate - t);
      }
      (!this._updateFPS || this._msToNextUpdate <= 0) && (super.update(
        /* deltaTime*/
      ), this._msToNextUpdate = this._updateFPS ? Math.floor(1e3 / this._updateFPS) : 0);
    }
  }
  _videoFrameRequestCallback() {
    this.update(), this.destroyed ? this._videoFrameRequestCallbackHandle = null : this._videoFrameRequestCallbackHandle = this.source.requestVideoFrameCallback(
      this._videoFrameRequestCallback
    );
  }
  /**
   * Start preloading the video resource.
   * @returns {Promise<void>} Handle the validate event
   */
  load() {
    if (this._load)
      return this._load;
    const e = this.source;
    return (e.readyState === e.HAVE_ENOUGH_DATA || e.readyState === e.HAVE_FUTURE_DATA) && e.width && e.height && (e.complete = !0), e.addEventListener("play", this._onPlayStart), e.addEventListener("pause", this._onPlayStop), e.addEventListener("seeked", this._onSeeked), this._isSourceReady() ? this._onCanPlay() : (e.addEventListener("canplay", this._onCanPlay), e.addEventListener("canplaythrough", this._onCanPlay), e.addEventListener("error", this._onError, !0)), this._load = new Promise((t, i) => {
      this.valid ? t(this) : (this._resolve = t, this._reject = i, e.load());
    }), this._load;
  }
  /**
   * Handle video error events.
   * @param event
   */
  _onError(e) {
    this.source.removeEventListener("error", this._onError, !0), this.onError.emit(e), this._reject && (this._reject(e), this._reject = null, this._resolve = null);
  }
  /**
   * Returns true if the underlying source is playing.
   * @returns - True if playing.
   */
  _isSourcePlaying() {
    const e = this.source;
    return !e.paused && !e.ended;
  }
  /**
   * Returns true if the underlying source is ready for playing.
   * @returns - True if ready.
   */
  _isSourceReady() {
    return this.source.readyState > 2;
  }
  /** Runs the update loop when the video is ready to play. */
  _onPlayStart() {
    this.valid || this._onCanPlay(), this._configureAutoUpdate();
  }
  /** Fired when a pause event is triggered, stops the update loop. */
  _onPlayStop() {
    this._configureAutoUpdate();
  }
  /** Fired when the video is completed seeking to the current playback position. */
  _onSeeked() {
    this._autoUpdate && !this._isSourcePlaying() && (this._msToNextUpdate = 0, this.update(), this._msToNextUpdate = 0);
  }
  /** Fired when the video is loaded and ready to play. */
  _onCanPlay() {
    const e = this.source;
    e.removeEventListener("canplay", this._onCanPlay), e.removeEventListener("canplaythrough", this._onCanPlay);
    const t = this.valid;
    this._msToNextUpdate = 0, this.update(), this._msToNextUpdate = 0, !t && this._resolve && (this._resolve(this), this._resolve = null, this._reject = null), this._isSourcePlaying() ? this._onPlayStart() : this.autoPlay && e.play();
  }
  /** Destroys this texture. */
  dispose() {
    this._configureAutoUpdate();
    const e = this.source;
    e && (e.removeEventListener("play", this._onPlayStart), e.removeEventListener("pause", this._onPlayStop), e.removeEventListener("seeked", this._onSeeked), e.removeEventListener("canplay", this._onCanPlay), e.removeEventListener("canplaythrough", this._onCanPlay), e.removeEventListener("error", this._onError, !0), e.pause(), e.src = "", e.load()), super.dispose();
  }
  /** Should the base texture automatically update itself, set to true by default. */
  get autoUpdate() {
    return this._autoUpdate;
  }
  set autoUpdate(e) {
    e !== this._autoUpdate && (this._autoUpdate = e, this._configureAutoUpdate());
  }
  /**
   * How many times a second to update the texture from the video. If 0, `requestVideoFrameCallback` is used to
   * update the texture. If `requestVideoFrameCallback` is not available, the texture is updated every render.
   * A lower fps can help performance, as updating the texture at 60fps on a 30ps video may not be efficient.
   */
  get updateFPS() {
    return this._updateFPS;
  }
  set updateFPS(e) {
    e !== this._updateFPS && (this._updateFPS = e, this._configureAutoUpdate());
  }
  _configureAutoUpdate() {
    this._autoUpdate && this._isSourcePlaying() ? !this._updateFPS && this.source.requestVideoFrameCallback ? (this._isConnectedToTicker && (bt.shared.remove(this.update, this), this._isConnectedToTicker = !1, this._msToNextUpdate = 0), this._videoFrameRequestCallbackHandle === null && (this._videoFrameRequestCallbackHandle = this.source.requestVideoFrameCallback(
      this._videoFrameRequestCallback
    ))) : (this._videoFrameRequestCallbackHandle !== null && (this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle), this._videoFrameRequestCallbackHandle = null), this._isConnectedToTicker || (bt.shared.add(this.update, this), this._isConnectedToTicker = !0, this._msToNextUpdate = 0)) : (this._videoFrameRequestCallbackHandle !== null && (this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle), this._videoFrameRequestCallbackHandle = null), this._isConnectedToTicker && (bt.shared.remove(this.update, this), this._isConnectedToTicker = !1, this._msToNextUpdate = 0));
  }
  /**
   * Used to auto-detect the type of resource.
   * @param {*} source - The source object
   * @param {string} extension - The extension of source, if set
   * @returns {boolean} `true` if video source
   */
  static test(e, t) {
    return globalThis.HTMLVideoElement && e instanceof HTMLVideoElement || _c.TYPES.includes(t);
  }
};
pc.TYPES = ["mp4", "m4v", "webm", "ogg", "ogv", "h264", "avi", "mov"], /**
* Map of video MIME types that can't be directly derived from file extensions.
* @readonly
*/
pc.MIME_TYPES = {
  ogv: "video/ogg",
  mov: "video/quicktime",
  m4v: "video/mp4"
};
let o0 = pc;
tc.push(
  xn,
  Mm,
  WS,
  o0,
  qS,
  fc,
  Ma,
  jS,
  VS
);
class ua {
  constructor() {
    this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, this.rect = null, this.updateID = -1;
  }
  /**
   * Checks if bounds are empty.
   * @returns - True if empty.
   */
  isEmpty() {
    return this.minX > this.maxX || this.minY > this.maxY;
  }
  /** Clears the bounds and resets. */
  clear() {
    this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0;
  }
  /**
   * Can return Rectangle.EMPTY constant, either construct new rectangle, either use your rectangle
   * It is not guaranteed that it will return tempRect
   * @param rect - Temporary object will be used if AABB is not empty
   * @returns - A rectangle of the bounds
   */
  getRectangle(e) {
    return this.minX > this.maxX || this.minY > this.maxY ? le.EMPTY : (e = e || new le(0, 0, 1, 1), e.x = this.minX, e.y = this.minY, e.width = this.maxX - this.minX, e.height = this.maxY - this.minY, e);
  }
  /**
   * This function should be inlined when its possible.
   * @param point - The point to add.
   */
  addPoint(e) {
    this.minX = Math.min(this.minX, e.x), this.maxX = Math.max(this.maxX, e.x), this.minY = Math.min(this.minY, e.y), this.maxY = Math.max(this.maxY, e.y);
  }
  /**
   * Adds a point, after transformed. This should be inlined when its possible.
   * @param matrix
   * @param point
   */
  addPointMatrix(e, t) {
    const { a: i, b: n, c: s, d: o, tx: a, ty: l } = e, h = i * t.x + s * t.y + a, c = n * t.x + o * t.y + l;
    this.minX = Math.min(this.minX, h), this.maxX = Math.max(this.maxX, h), this.minY = Math.min(this.minY, c), this.maxY = Math.max(this.maxY, c);
  }
  /**
   * Adds a quad, not transformed
   * @param vertices - The verts to add.
   */
  addQuad(e) {
    let t = this.minX, i = this.minY, n = this.maxX, s = this.maxY, o = e[0], a = e[1];
    t = o < t ? o : t, i = a < i ? a : i, n = o > n ? o : n, s = a > s ? a : s, o = e[2], a = e[3], t = o < t ? o : t, i = a < i ? a : i, n = o > n ? o : n, s = a > s ? a : s, o = e[4], a = e[5], t = o < t ? o : t, i = a < i ? a : i, n = o > n ? o : n, s = a > s ? a : s, o = e[6], a = e[7], t = o < t ? o : t, i = a < i ? a : i, n = o > n ? o : n, s = a > s ? a : s, this.minX = t, this.minY = i, this.maxX = n, this.maxY = s;
  }
  /**
   * Adds sprite frame, transformed.
   * @param transform - transform to apply
   * @param x0 - left X of frame
   * @param y0 - top Y of frame
   * @param x1 - right X of frame
   * @param y1 - bottom Y of frame
   */
  addFrame(e, t, i, n, s) {
    this.addFrameMatrix(e.worldTransform, t, i, n, s);
  }
  /**
   * Adds sprite frame, multiplied by matrix
   * @param matrix - matrix to apply
   * @param x0 - left X of frame
   * @param y0 - top Y of frame
   * @param x1 - right X of frame
   * @param y1 - bottom Y of frame
   */
  addFrameMatrix(e, t, i, n, s) {
    const o = e.a, a = e.b, l = e.c, h = e.d, c = e.tx, u = e.ty;
    let d = this.minX, f = this.minY, p = this.maxX, _ = this.maxY, m = o * t + l * i + c, y = a * t + h * i + u;
    d = m < d ? m : d, f = y < f ? y : f, p = m > p ? m : p, _ = y > _ ? y : _, m = o * n + l * i + c, y = a * n + h * i + u, d = m < d ? m : d, f = y < f ? y : f, p = m > p ? m : p, _ = y > _ ? y : _, m = o * t + l * s + c, y = a * t + h * s + u, d = m < d ? m : d, f = y < f ? y : f, p = m > p ? m : p, _ = y > _ ? y : _, m = o * n + l * s + c, y = a * n + h * s + u, d = m < d ? m : d, f = y < f ? y : f, p = m > p ? m : p, _ = y > _ ? y : _, this.minX = d, this.minY = f, this.maxX = p, this.maxY = _;
  }
  /**
   * Adds screen vertices from array
   * @param vertexData - calculated vertices
   * @param beginOffset - begin offset
   * @param endOffset - end offset, excluded
   */
  addVertexData(e, t, i) {
    let n = this.minX, s = this.minY, o = this.maxX, a = this.maxY;
    for (let l = t; l < i; l += 2) {
      const h = e[l], c = e[l + 1];
      n = h < n ? h : n, s = c < s ? c : s, o = h > o ? h : o, a = c > a ? c : a;
    }
    this.minX = n, this.minY = s, this.maxX = o, this.maxY = a;
  }
  /**
   * Add an array of mesh vertices
   * @param transform - mesh transform
   * @param vertices - mesh coordinates in array
   * @param beginOffset - begin offset
   * @param endOffset - end offset, excluded
   */
  addVertices(e, t, i, n) {
    this.addVerticesMatrix(e.worldTransform, t, i, n);
  }
  /**
   * Add an array of mesh vertices.
   * @param matrix - mesh matrix
   * @param vertices - mesh coordinates in array
   * @param beginOffset - begin offset
   * @param endOffset - end offset, excluded
   * @param padX - x padding
   * @param padY - y padding
   */
  addVerticesMatrix(e, t, i, n, s = 0, o = s) {
    const a = e.a, l = e.b, h = e.c, c = e.d, u = e.tx, d = e.ty;
    let f = this.minX, p = this.minY, _ = this.maxX, m = this.maxY;
    for (let y = i; y < n; y += 2) {
      const v = t[y], g = t[y + 1], b = a * v + h * g + u, w = c * g + l * v + d;
      f = Math.min(f, b - s), _ = Math.max(_, b + s), p = Math.min(p, w - o), m = Math.max(m, w + o);
    }
    this.minX = f, this.minY = p, this.maxX = _, this.maxY = m;
  }
  /**
   * Adds other {@link PIXI.Bounds}.
   * @param bounds - The Bounds to be added
   */
  addBounds(e) {
    const t = this.minX, i = this.minY, n = this.maxX, s = this.maxY;
    this.minX = e.minX < t ? e.minX : t, this.minY = e.minY < i ? e.minY : i, this.maxX = e.maxX > n ? e.maxX : n, this.maxY = e.maxY > s ? e.maxY : s;
  }
  /**
   * Adds other Bounds, masked with Bounds.
   * @param bounds - The Bounds to be added.
   * @param mask - TODO
   */
  addBoundsMask(e, t) {
    const i = e.minX > t.minX ? e.minX : t.minX, n = e.minY > t.minY ? e.minY : t.minY, s = e.maxX < t.maxX ? e.maxX : t.maxX, o = e.maxY < t.maxY ? e.maxY : t.maxY;
    if (i <= s && n <= o) {
      const a = this.minX, l = this.minY, h = this.maxX, c = this.maxY;
      this.minX = i < a ? i : a, this.minY = n < l ? n : l, this.maxX = s > h ? s : h, this.maxY = o > c ? o : c;
    }
  }
  /**
   * Adds other Bounds, multiplied by matrix. Bounds shouldn't be empty.
   * @param bounds - other bounds
   * @param matrix - multiplicator
   */
  addBoundsMatrix(e, t) {
    this.addFrameMatrix(t, e.minX, e.minY, e.maxX, e.maxY);
  }
  /**
   * Adds other Bounds, masked with Rectangle.
   * @param bounds - TODO
   * @param area - TODO
   */
  addBoundsArea(e, t) {
    const i = e.minX > t.x ? e.minX : t.x, n = e.minY > t.y ? e.minY : t.y, s = e.maxX < t.x + t.width ? e.maxX : t.x + t.width, o = e.maxY < t.y + t.height ? e.maxY : t.y + t.height;
    if (i <= s && n <= o) {
      const a = this.minX, l = this.minY, h = this.maxX, c = this.maxY;
      this.minX = i < a ? i : a, this.minY = n < l ? n : l, this.maxX = s > h ? s : h, this.maxY = o > c ? o : c;
    }
  }
  /**
   * Pads bounds object, making it grow in all directions.
   * If paddingY is omitted, both paddingX and paddingY will be set to paddingX.
   * @param paddingX - The horizontal padding amount.
   * @param paddingY - The vertical padding amount.
   */
  pad(e = 0, t = e) {
    this.isEmpty() || (this.minX -= e, this.maxX += e, this.minY -= t, this.maxY += t);
  }
  /**
   * Adds padded frame. (x0, y0) should be strictly less than (x1, y1)
   * @param x0 - left X of frame
   * @param y0 - top Y of frame
   * @param x1 - right X of frame
   * @param y1 - bottom Y of frame
   * @param padX - padding X
   * @param padY - padding Y
   */
  addFramePad(e, t, i, n, s, o) {
    e -= s, t -= o, i += s, n += o, this.minX = this.minX < e ? this.minX : e, this.maxX = this.maxX > i ? this.maxX : i, this.minY = this.minY < t ? this.minY : t, this.maxY = this.maxY > n ? this.maxY : n;
  }
}
class Pe extends Fs {
  constructor() {
    super(), this.tempDisplayObjectParent = null, this.transform = new nu(), this.alpha = 1, this.visible = !0, this.renderable = !0, this.cullable = !1, this.cullArea = null, this.parent = null, this.worldAlpha = 1, this._lastSortedIndex = 0, this._zIndex = 0, this.filterArea = null, this.filters = null, this._enabledFilters = null, this._bounds = new ua(), this._localBounds = null, this._boundsID = 0, this._boundsRect = null, this._localBoundsRect = null, this._mask = null, this._maskRefCount = 0, this._destroyed = !1, this.isSprite = !1, this.isMask = !1;
  }
  /**
   * Mixes all enumerable properties and methods from a source object to DisplayObject.
   * @param source - The source of properties and methods to mix in.
   */
  static mixin(e) {
    const t = Object.keys(e);
    for (let i = 0; i < t.length; ++i) {
      const n = t[i];
      Object.defineProperty(
        Pe.prototype,
        n,
        Object.getOwnPropertyDescriptor(e, n)
      );
    }
  }
  /**
   * Fired when this DisplayObject is added to a Container.
   * @instance
   * @event added
   * @param {PIXI.Container} container - The container added to.
   */
  /**
   * Fired when this DisplayObject is removed from a Container.
   * @instance
   * @event removed
   * @param {PIXI.Container} container - The container removed from.
   */
  /**
   * Fired when this DisplayObject is destroyed. This event is emitted once
   * destroy is finished.
   * @instance
   * @event destroyed
   */
  /** Readonly flag for destroyed display objects. */
  get destroyed() {
    return this._destroyed;
  }
  /** Recursively updates transform of all objects from the root to this one internal function for toLocal() */
  _recursivePostUpdateTransform() {
    this.parent ? (this.parent._recursivePostUpdateTransform(), this.transform.updateTransform(this.parent.transform)) : this.transform.updateTransform(this._tempDisplayObjectParent.transform);
  }
  /** Updates the object transform for rendering. TODO - Optimization pass! */
  updateTransform() {
    this._boundsID++, this.transform.updateTransform(this.parent.transform), this.worldAlpha = this.alpha * this.parent.worldAlpha;
  }
  /**
   * Calculates and returns the (world) bounds of the display object as a [Rectangle]{@link PIXI.Rectangle}.
   *
   * This method is expensive on containers with a large subtree (like the stage). This is because the bounds
   * of a container depend on its children's bounds, which recursively causes all bounds in the subtree to
   * be recalculated. The upside, however, is that calling `getBounds` once on a container will indeed update
   * the bounds of all children (the whole subtree, in fact). This side effect should be exploited by using
   * `displayObject._bounds.getRectangle()` when traversing through all the bounds in a scene graph. Otherwise,
   * calling `getBounds` on each object in a subtree will cause the total cost to increase quadratically as
   * its height increases.
   *
   * The transforms of all objects in a container's **subtree** and of all **ancestors** are updated.
   * The world bounds of all display objects in a container's **subtree** will also be recalculated.
   *
   * The `_bounds` object stores the last calculation of the bounds. You can use to entirely skip bounds
   * calculation if needed.
   *
   * ```js
   * const lastCalculatedBounds = displayObject._bounds.getRectangle(optionalRect);
   * ```
   *
   * Do know that usage of `getLocalBounds` can corrupt the `_bounds` of children (the whole subtree, actually). This
   * is a known issue that has not been solved. See [getLocalBounds]{@link PIXI.DisplayObject#getLocalBounds} for more
   * details.
   *
   * `getBounds` should be called with `skipUpdate` equal to `true` in a render() call. This is because the transforms
   * are guaranteed to be update-to-date. In fact, recalculating inside a render() call may cause corruption in certain
   * cases.
   * @param skipUpdate - Setting to `true` will stop the transforms of the scene graph from
   *  being updated. This means the calculation returned MAY be out of date BUT will give you a
   *  nice performance boost.
   * @param rect - Optional rectangle to store the result of the bounds calculation.
   * @returns - The minimum axis-aligned rectangle in world space that fits around this object.
   */
  getBounds(e, t) {
    return e || (this.parent ? (this._recursivePostUpdateTransform(), this.updateTransform()) : (this.parent = this._tempDisplayObjectParent, this.updateTransform(), this.parent = null)), this._bounds.updateID !== this._boundsID && (this.calculateBounds(), this._bounds.updateID = this._boundsID), t || (this._boundsRect || (this._boundsRect = new le()), t = this._boundsRect), this._bounds.getRectangle(t);
  }
  /**
   * Retrieves the local bounds of the displayObject as a rectangle object.
   * @param rect - Optional rectangle to store the result of the bounds calculation.
   * @returns - The rectangular bounding area.
   */
  getLocalBounds(e) {
    e || (this._localBoundsRect || (this._localBoundsRect = new le()), e = this._localBoundsRect), this._localBounds || (this._localBounds = new ua());
    const t = this.transform, i = this.parent;
    this.parent = null, this._tempDisplayObjectParent.worldAlpha = (i == null ? void 0 : i.worldAlpha) ?? 1, this.transform = this._tempDisplayObjectParent.transform;
    const n = this._bounds, s = this._boundsID;
    this._bounds = this._localBounds;
    const o = this.getBounds(!1, e);
    return this.parent = i, this.transform = t, this._bounds = n, this._bounds.updateID += this._boundsID - s, o;
  }
  /**
   * Calculates the global position of the display object.
   * @param position - The world origin to calculate from.
   * @param point - A Point object in which to store the value, optional
   *  (otherwise will create a new Point).
   * @param skipUpdate - Should we skip the update transform.
   * @returns - A point object representing the position of this object.
   */
  toGlobal(e, t, i = !1) {
    return i || (this._recursivePostUpdateTransform(), this.parent ? this.displayObjectUpdateTransform() : (this.parent = this._tempDisplayObjectParent, this.displayObjectUpdateTransform(), this.parent = null)), this.worldTransform.apply(e, t);
  }
  /**
   * Calculates the local position of the display object relative to another point.
   * @param position - The world origin to calculate from.
   * @param from - The DisplayObject to calculate the global position from.
   * @param point - A Point object in which to store the value, optional
   *  (otherwise will create a new Point).
   * @param skipUpdate - Should we skip the update transform
   * @returns - A point object representing the position of this object
   */
  toLocal(e, t, i, n) {
    return t && (e = t.toGlobal(e, i, n)), n || (this._recursivePostUpdateTransform(), this.parent ? this.displayObjectUpdateTransform() : (this.parent = this._tempDisplayObjectParent, this.displayObjectUpdateTransform(), this.parent = null)), this.worldTransform.applyInverse(e, i);
  }
  /**
   * Set the parent Container of this DisplayObject.
   * @param container - The Container to add this DisplayObject to.
   * @returns - The Container that this DisplayObject was added to.
   */
  setParent(e) {
    if (!e || !e.addChild)
      throw new Error("setParent: Argument must be a Container");
    return e.addChild(this), e;
  }
  /** Remove the DisplayObject from its parent Container. If the DisplayObject has no parent, do nothing. */
  removeFromParent() {
    var e;
    (e = this.parent) == null || e.removeChild(this);
  }
  /**
   * Convenience function to set the position, scale, skew and pivot at once.
   * @param x - The X position
   * @param y - The Y position
   * @param scaleX - The X scale value
   * @param scaleY - The Y scale value
   * @param rotation - The rotation
   * @param skewX - The X skew value
   * @param skewY - The Y skew value
   * @param pivotX - The X pivot value
   * @param pivotY - The Y pivot value
   * @returns - The DisplayObject instance
   */
  setTransform(e = 0, t = 0, i = 1, n = 1, s = 0, o = 0, a = 0, l = 0, h = 0) {
    return this.position.x = e, this.position.y = t, this.scale.x = i || 1, this.scale.y = n || 1, this.rotation = s, this.skew.x = o, this.skew.y = a, this.pivot.x = l, this.pivot.y = h, this;
  }
  /**
   * Base destroy method for generic display objects. This will automatically
   * remove the display object from its parent Container as well as remove
   * all current event listeners and internal references. Do not use a DisplayObject
   * after calling `destroy()`.
   * @param _options
   */
  destroy(e) {
    this.removeFromParent(), this._destroyed = !0, this.transform = null, this.parent = null, this._bounds = null, this.mask = null, this.cullArea = null, this.filters = null, this.filterArea = null, this.hitArea = null, this.eventMode = "auto", this.interactiveChildren = !1, this.emit("destroyed"), this.removeAllListeners();
  }
  /**
   * @protected
   * @member {PIXI.Container}
   */
  get _tempDisplayObjectParent() {
    return this.tempDisplayObjectParent === null && (this.tempDisplayObjectParent = new YS()), this.tempDisplayObjectParent;
  }
  /**
   * Used in Renderer, cacheAsBitmap and other places where you call an `updateTransform` on root.
   *
   * ```js
   * const cacheParent = elem.enableTempParent();
   * elem.updateTransform();
   * elem.disableTempParent(cacheParent);
   * ```
   * @returns - Current parent
   */
  enableTempParent() {
    const e = this.parent;
    return this.parent = this._tempDisplayObjectParent, e;
  }
  /**
   * Pair method for `enableTempParent`
   * @param cacheParent - Actual parent of element
   */
  disableTempParent(e) {
    this.parent = e;
  }
  /**
   * The position of the displayObject on the x axis relative to the local coordinates of the parent.
   * An alias to position.x
   */
  get x() {
    return this.position.x;
  }
  set x(e) {
    this.transform.position.x = e;
  }
  /**
   * The position of the displayObject on the y axis relative to the local coordinates of the parent.
   * An alias to position.y
   */
  get y() {
    return this.position.y;
  }
  set y(e) {
    this.transform.position.y = e;
  }
  /**
   * Current transform of the object based on world (parent) factors.
   * @readonly
   */
  get worldTransform() {
    return this.transform.worldTransform;
  }
  /**
   * Current transform of the object based on local factors: position, scale, other stuff.
   * @readonly
   */
  get localTransform() {
    return this.transform.localTransform;
  }
  /**
   * The coordinate of the object relative to the local coordinates of the parent.
   * @since 4.0.0
   */
  get position() {
    return this.transform.position;
  }
  set position(e) {
    this.transform.position.copyFrom(e);
  }
  /**
   * The scale factors of this object along the local coordinate axes.
   *
   * The default scale is (1, 1).
   * @since 4.0.0
   */
  get scale() {
    return this.transform.scale;
  }
  set scale(e) {
    this.transform.scale.copyFrom(e);
  }
  /**
   * The center of rotation, scaling, and skewing for this display object in its local space. The `position`
   * is the projection of `pivot` in the parent's local space.
   *
   * By default, the pivot is the origin (0, 0).
   * @since 4.0.0
   */
  get pivot() {
    return this.transform.pivot;
  }
  set pivot(e) {
    this.transform.pivot.copyFrom(e);
  }
  /**
   * The skew factor for the object in radians.
   * @since 4.0.0
   */
  get skew() {
    return this.transform.skew;
  }
  set skew(e) {
    this.transform.skew.copyFrom(e);
  }
  /**
   * The rotation of the object in radians.
   * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.
   */
  get rotation() {
    return this.transform.rotation;
  }
  set rotation(e) {
    this.transform.rotation = e;
  }
  /**
   * The angle of the object in degrees.
   * 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.
   */
  get angle() {
    return this.transform.rotation * GA;
  }
  set angle(e) {
    this.transform.rotation = e * HA;
  }
  /**
   * The zIndex of the displayObject.
   *
   * If a container has the sortableChildren property set to true, children will be automatically
   * sorted by zIndex value; a higher value will mean it will be moved towards the end of the array,
   * and thus rendered on top of other display objects within the same container.
   * @see PIXI.Container#sortableChildren
   */
  get zIndex() {
    return this._zIndex;
  }
  set zIndex(e) {
    this._zIndex !== e && (this._zIndex = e, this.parent && (this.parent.sortDirty = !0));
  }
  /**
   * Indicates if the object is globally visible.
   * @readonly
   */
  get worldVisible() {
    let e = this;
    do {
      if (!e.visible)
        return !1;
      e = e.parent;
    } while (e);
    return !0;
  }
  /**
   * Sets a mask for the displayObject. A mask is an object that limits the visibility of an
   * object to the shape of the mask applied to it. In PixiJS a regular mask must be a
   * {@link PIXI.Graphics} or a {@link PIXI.Sprite} object. This allows for much faster masking in canvas as it
   * utilities shape clipping. Furthermore, a mask of an object must be in the subtree of its parent.
   * Otherwise, `getLocalBounds` may calculate incorrect bounds, which makes the container's width and height wrong.
   * To remove a mask, set this property to `null`.
   *
   * For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask.
   * @example
   * import { Graphics, Sprite } from 'pixi.js';
   *
   * const graphics = new Graphics();
   * graphics.beginFill(0xFF3300);
   * graphics.drawRect(50, 250, 100, 100);
   * graphics.endFill();
   *
   * const sprite = new Sprite(texture);
   * sprite.mask = graphics;
   * @todo At the moment, CanvasRenderer doesn't support Sprite as mask.
   */
  get mask() {
    return this._mask;
  }
  set mask(e) {
    if (this._mask !== e) {
      if (this._mask) {
        const t = this._mask.isMaskData ? this._mask.maskObject : this._mask;
        t && (t._maskRefCount--, t._maskRefCount === 0 && (t.renderable = !0, t.isMask = !1));
      }
      if (this._mask = e, this._mask) {
        const t = this._mask.isMaskData ? this._mask.maskObject : this._mask;
        t && (t._maskRefCount === 0 && (t.renderable = !1, t.isMask = !0), t._maskRefCount++);
      }
    }
  }
}
class YS extends Pe {
  constructor() {
    super(...arguments), this.sortDirty = null;
  }
}
Pe.prototype.displayObjectUpdateTransform = Pe.prototype.updateTransform;
const KS = new Te();
function ZS(r, e) {
  return r.zIndex === e.zIndex ? r._lastSortedIndex - e._lastSortedIndex : r.zIndex - e.zIndex;
}
const a0 = class mc extends Pe {
  constructor() {
    super(), this.children = [], this.sortableChildren = mc.defaultSortableChildren, this.sortDirty = !1;
  }
  /**
   * Overridable method that can be used by Container subclasses whenever the children array is modified.
   * @param _length
   */
  onChildrenChange(e) {
  }
  /**
   * Adds one or more children to the container.
   *
   * Multiple items can be added like so: `myContainer.addChild(thingOne, thingTwo, thingThree)`
   * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to add to the container
   * @returns {PIXI.DisplayObject} - The first child that was added.
   */
  addChild(...e) {
    if (e.length > 1)
      for (let t = 0; t < e.length; t++)
        this.addChild(e[t]);
    else {
      const t = e[0];
      t.parent && t.parent.removeChild(t), t.parent = this, this.sortDirty = !0, t.transform._parentID = -1, this.children.push(t), this._boundsID++, this.onChildrenChange(this.children.length - 1), this.emit("childAdded", t, this, this.children.length - 1), t.emit("added", this);
    }
    return e[0];
  }
  /**
   * Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown.
   * If the child is already in this container, it will be moved to the specified index.
   * @param {PIXI.DisplayObject} child - The child to add.
   * @param {number} index - The absolute index where the child will be positioned at the end of the operation.
   * @returns {PIXI.DisplayObject} The child that was added.
   */
  addChildAt(e, t) {
    if (t < 0 || t > this.children.length)
      throw new Error(`${e}addChildAt: The index ${t} supplied is out of bounds ${this.children.length}`);
    return e.parent && e.parent.removeChild(e), e.parent = this, this.sortDirty = !0, e.transform._parentID = -1, this.children.splice(t, 0, e), this._boundsID++, this.onChildrenChange(t), e.emit("added", this), this.emit("childAdded", e, this, t), e;
  }
  /**
   * Swaps the position of 2 Display Objects within this container.
   * @param child - First display object to swap
   * @param child2 - Second display object to swap
   */
  swapChildren(e, t) {
    if (e === t)
      return;
    const i = this.getChildIndex(e), n = this.getChildIndex(t);
    this.children[i] = t, this.children[n] = e, this.onChildrenChange(i < n ? i : n);
  }
  /**
   * Returns the index position of a child DisplayObject instance
   * @param child - The DisplayObject instance to identify
   * @returns - The index position of the child display object to identify
   */
  getChildIndex(e) {
    const t = this.children.indexOf(e);
    if (t === -1)
      throw new Error("The supplied DisplayObject must be a child of the caller");
    return t;
  }
  /**
   * Changes the position of an existing child in the display object container
   * @param child - The child DisplayObject instance for which you want to change the index number
   * @param index - The resulting index number for the child display object
   */
  setChildIndex(e, t) {
    if (t < 0 || t >= this.children.length)
      throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);
    const i = this.getChildIndex(e);
    Cn(this.children, i, 1), this.children.splice(t, 0, e), this.onChildrenChange(t);
  }
  /**
   * Returns the child at the specified index
   * @param index - The index to get the child at
   * @returns - The child at the given index, if any.
   */
  getChildAt(e) {
    if (e < 0 || e >= this.children.length)
      throw new Error(`getChildAt: Index (${e}) does not exist.`);
    return this.children[e];
  }
  /**
   * Removes one or more children from the container.
   * @param {...PIXI.DisplayObject} children - The DisplayObject(s) to remove
   * @returns {PIXI.DisplayObject} The first child that was removed.
   */
  removeChild(...e) {
    if (e.length > 1)
      for (let t = 0; t < e.length; t++)
        this.removeChild(e[t]);
    else {
      const t = e[0], i = this.children.indexOf(t);
      if (i === -1)
        return null;
      t.parent = null, t.transform._parentID = -1, Cn(this.children, i, 1), this._boundsID++, this.onChildrenChange(i), t.emit("removed", this), this.emit("childRemoved", t, this, i);
    }
    return e[0];
  }
  /**
   * Removes a child from the specified index position.
   * @param index - The index to get the child from
   * @returns The child that was removed.
   */
  removeChildAt(e) {
    const t = this.getChildAt(e);
    return t.parent = null, t.transform._parentID = -1, Cn(this.children, e, 1), this._boundsID++, this.onChildrenChange(e), t.emit("removed", this), this.emit("childRemoved", t, this, e), t;
  }
  /**
   * Removes all children from this container that are within the begin and end indexes.
   * @param beginIndex - The beginning position.
   * @param endIndex - The ending position. Default value is size of the container.
   * @returns - List of removed children
   */
  removeChildren(e = 0, t = this.children.length) {
    const i = e, n = t, s = n - i;
    let o;
    if (s > 0 && s <= n) {
      o = this.children.splice(i, s);
      for (let a = 0; a < o.length; ++a)
        o[a].parent = null, o[a].transform && (o[a].transform._parentID = -1);
      this._boundsID++, this.onChildrenChange(e);
      for (let a = 0; a < o.length; ++a)
        o[a].emit("removed", this), this.emit("childRemoved", o[a], this, a);
      return o;
    } else if (s === 0 && this.children.length === 0)
      return [];
    throw new RangeError("removeChildren: numeric values are outside the acceptable range.");
  }
  /** Sorts children by zIndex. Previous order is maintained for 2 children with the same zIndex. */
  sortChildren() {
    let e = !1;
    for (let t = 0, i = this.children.length; t < i; ++t) {
      const n = this.children[t];
      n._lastSortedIndex = t, !e && n.zIndex !== 0 && (e = !0);
    }
    e && this.children.length > 1 && this.children.sort(ZS), this.sortDirty = !1;
  }
  /** Updates the transform on all children of this container for rendering. */
  updateTransform() {
    this.sortableChildren && this.sortDirty && this.sortChildren(), this._boundsID++, this.transform.updateTransform(this.parent.transform), this.worldAlpha = this.alpha * this.parent.worldAlpha;
    for (let e = 0, t = this.children.length; e < t; ++e) {
      const i = this.children[e];
      i.visible && i.updateTransform();
    }
  }
  /**
   * Recalculates the bounds of the container.
   *
   * This implementation will automatically fit the children's bounds into the calculation. Each child's bounds
   * is limited to its mask's bounds or filterArea, if any is applied.
   */
  calculateBounds() {
    this._bounds.clear(), this._calculateBounds();
    for (let e = 0; e < this.children.length; e++) {
      const t = this.children[e];
      if (!(!t.visible || !t.renderable))
        if (t.calculateBounds(), t._mask) {
          const i = t._mask.isMaskData ? t._mask.maskObject : t._mask;
          i ? (i.calculateBounds(), this._bounds.addBoundsMask(t._bounds, i._bounds)) : this._bounds.addBounds(t._bounds);
        } else
          t.filterArea ? this._bounds.addBoundsArea(t._bounds, t.filterArea) : this._bounds.addBounds(t._bounds);
    }
    this._bounds.updateID = this._boundsID;
  }
  /**
   * Retrieves the local bounds of the displayObject as a rectangle object.
   *
   * Calling `getLocalBounds` may invalidate the `_bounds` of the whole subtree below. If using it inside a render()
   * call, it is advised to call `getBounds()` immediately after to recalculate the world bounds of the subtree.
   * @param rect - Optional rectangle to store the result of the bounds calculation.
   * @param skipChildrenUpdate - Setting to `true` will stop re-calculation of children transforms,
   *  it was default behaviour of pixi 4.0-5.2 and caused many problems to users.
   * @returns - The rectangular bounding area.
   */
  getLocalBounds(e, t = !1) {
    const i = super.getLocalBounds(e);
    if (!t)
      for (let n = 0, s = this.children.length; n < s; ++n) {
        const o = this.children[n];
        o.visible && o.updateTransform();
      }
    return i;
  }
  /**
   * Recalculates the content bounds of this object. This should be overriden to
   * calculate the bounds of this specific object (not including children).
   * @protected
   */
  _calculateBounds() {
  }
  /**
   * Renders this object and its children with culling.
   * @protected
   * @param {PIXI.Renderer} renderer - The renderer
   */
  _renderWithCulling(e) {
    const t = e.renderTexture.sourceFrame;
    if (!(t.width > 0 && t.height > 0))
      return;
    let i, n;
    this.cullArea ? (i = this.cullArea, n = this.worldTransform) : this._render !== mc.prototype._render && (i = this.getBounds(!0));
    const s = e.projection.transform;
    if (s && (n ? (n = KS.copyFrom(n), n.prepend(s)) : n = s), i && t.intersects(i, n))
      this._render(e);
    else if (this.cullArea)
      return;
    for (let o = 0, a = this.children.length; o < a; ++o) {
      const l = this.children[o], h = l.cullable;
      l.cullable = h || !this.cullArea, l.render(e), l.cullable = h;
    }
  }
  /**
   * Renders the object using the WebGL renderer.
   *
   * The [_render]{@link PIXI.Container#_render} method is be overriden for rendering the contents of the
   * container itself. This `render` method will invoke it, and also invoke the `render` methods of all
   * children afterward.
   *
   * If `renderable` or `visible` is false or if `worldAlpha` is not positive or if `cullable` is true and
   * the bounds of this object are out of frame, this implementation will entirely skip rendering.
   * See {@link PIXI.DisplayObject} for choosing between `renderable` or `visible`. Generally,
   * setting alpha to zero is not recommended for purely skipping rendering.
   *
   * When your scene becomes large (especially when it is larger than can be viewed in a single screen), it is
   * advised to employ **culling** to automatically skip rendering objects outside of the current screen.
   * See [cullable]{@link PIXI.DisplayObject#cullable} and [cullArea]{@link PIXI.DisplayObject#cullArea}.
   * Other culling methods might be better suited for a large number static objects; see
   * [@pixi-essentials/cull]{@link https://www.npmjs.com/package/@pixi-essentials/cull} and
   * [pixi-cull]{@link https://www.npmjs.com/package/pixi-cull}.
   *
   * The [renderAdvanced]{@link PIXI.Container#renderAdvanced} method is internally used when when masking or
   * filtering is applied on a container. This does, however, break batching and can affect performance when
   * masking and filtering is applied extensively throughout the scene graph.
   * @param renderer - The renderer
   */
  render(e) {
    var t;
    if (!(!this.visible || this.worldAlpha <= 0 || !this.renderable))
      if (this._mask || (t = this.filters) != null && t.length)
        this.renderAdvanced(e);
      else if (this.cullable)
        this._renderWithCulling(e);
      else {
        this._render(e);
        for (let i = 0, n = this.children.length; i < n; ++i)
          this.children[i].render(e);
      }
  }
  /**
   * Render the object using the WebGL renderer and advanced features.
   * @param renderer - The renderer
   */
  renderAdvanced(e) {
    var s, o, a;
    const t = this.filters, i = this._mask;
    if (t) {
      this._enabledFilters || (this._enabledFilters = []), this._enabledFilters.length = 0;
      for (let l = 0; l < t.length; l++)
        t[l].enabled && this._enabledFilters.push(t[l]);
    }
    const n = t && ((s = this._enabledFilters) == null ? void 0 : s.length) || i && (!i.isMaskData || i.enabled && (i.autoDetect || i.type !== Ge.NONE));
    if (n && e.batch.flush(), t && ((o = this._enabledFilters) != null && o.length) && e.filter.push(this, this._enabledFilters), i && e.mask.push(this, this._mask), this.cullable)
      this._renderWithCulling(e);
    else {
      this._render(e);
      for (let l = 0, h = this.children.length; l < h; ++l)
        this.children[l].render(e);
    }
    n && e.batch.flush(), i && e.mask.pop(this), t && ((a = this._enabledFilters) != null && a.length) && e.filter.pop();
  }
  /**
   * To be overridden by the subclasses.
   * @param _renderer - The renderer
   */
  _render(e) {
  }
  /**
   * Removes all internal references and listeners as well as removes children from the display list.
   * Do not use a Container after calling `destroy`.
   * @param options - Options parameter. A boolean will act as if all options
   *  have been set to that value
   * @param {boolean} [options.children=false] - if set to true, all the children will have their destroy
   *  method called as well. 'options' will be passed on to those calls.
   * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true
   *  Should it destroy the texture of the child sprite
   * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true
   *  Should it destroy the base texture of the child sprite
   */
  destroy(e) {
    super.destroy(), this.sortDirty = !1;
    const t = typeof e == "boolean" ? e : e == null ? void 0 : e.children, i = this.removeChildren(0, this.children.length);
    if (t)
      for (let n = 0; n < i.length; ++n)
        i[n].destroy(e);
  }
  /** The width of the Container, setting this will actually modify the scale to achieve the value set. */
  get width() {
    return this.scale.x * this.getLocalBounds().width;
  }
  set width(e) {
    const t = this.getLocalBounds().width;
    t !== 0 ? this.scale.x = e / t : this.scale.x = 1, this._width = e;
  }
  /** The height of the Container, setting this will actually modify the scale to achieve the value set. */
  get height() {
    return this.scale.y * this.getLocalBounds().height;
  }
  set height(e) {
    const t = this.getLocalBounds().height;
    t !== 0 ? this.scale.y = e / t : this.scale.y = 1, this._height = e;
  }
};
a0.defaultSortableChildren = !1;
let Qe = a0;
Qe.prototype.containerUpdateTransform = Qe.prototype.updateTransform;
Object.defineProperties(Z, {
  /**
   * Sets the default value for the container property 'sortableChildren'.
   * @static
   * @name SORTABLE_CHILDREN
   * @memberof PIXI.settings
   * @deprecated since 7.1.0
   * @type {boolean}
   * @see PIXI.Container.defaultSortableChildren
   */
  SORTABLE_CHILDREN: {
    get() {
      return Qe.defaultSortableChildren;
    },
    set(r) {
      fe("7.1.0", "settings.SORTABLE_CHILDREN is deprecated, use Container.defaultSortableChildren"), Qe.defaultSortableChildren = r;
    }
  }
});
const ns = new ge(), $S = new Uint16Array([0, 1, 2, 0, 2, 3]);
class st extends Qe {
  /** @param texture - The texture for this sprite. */
  constructor(e) {
    super(), this._anchor = new Ci(
      this._onAnchorUpdate,
      this,
      e ? e.defaultAnchor.x : 0,
      e ? e.defaultAnchor.y : 0
    ), this._texture = null, this._width = 0, this._height = 0, this._tintColor = new be(16777215), this._tintRGB = null, this.tint = 16777215, this.blendMode = oe.NORMAL, this._cachedTint = 16777215, this.uvs = null, this.texture = e || J.EMPTY, this.vertexData = new Float32Array(8), this.vertexTrimmedData = null, this._transformID = -1, this._textureID = -1, this._transformTrimmedID = -1, this._textureTrimmedID = -1, this.indices = $S, this.pluginName = "batch", this.isSprite = !0, this._roundPixels = Z.ROUND_PIXELS;
  }
  /** When the texture is updated, this event will fire to update the scale and frame. */
  _onTextureUpdate() {
    this._textureID = -1, this._textureTrimmedID = -1, this._cachedTint = 16777215, this._width && (this.scale.x = Zi(this.scale.x) * this._width / this._texture.orig.width), this._height && (this.scale.y = Zi(this.scale.y) * this._height / this._texture.orig.height);
  }
  /** Called when the anchor position updates. */
  _onAnchorUpdate() {
    this._transformID = -1, this._transformTrimmedID = -1;
  }
  /** Calculates worldTransform * vertices, store it in vertexData. */
  calculateVertices() {
    const e = this._texture;
    if (this._transformID === this.transform._worldID && this._textureID === e._updateID)
      return;
    this._textureID !== e._updateID && (this.uvs = this._texture._uvs.uvsFloat32), this._transformID = this.transform._worldID, this._textureID = e._updateID;
    const t = this.transform.worldTransform, i = t.a, n = t.b, s = t.c, o = t.d, a = t.tx, l = t.ty, h = this.vertexData, c = e.trim, u = e.orig, d = this._anchor;
    let f = 0, p = 0, _ = 0, m = 0;
    if (c ? (p = c.x - d._x * u.width, f = p + c.width, m = c.y - d._y * u.height, _ = m + c.height) : (p = -d._x * u.width, f = p + u.width, m = -d._y * u.height, _ = m + u.height), h[0] = i * p + s * m + a, h[1] = o * m + n * p + l, h[2] = i * f + s * m + a, h[3] = o * m + n * f + l, h[4] = i * f + s * _ + a, h[5] = o * _ + n * f + l, h[6] = i * p + s * _ + a, h[7] = o * _ + n * p + l, this._roundPixels) {
      const y = Z.RESOLUTION;
      for (let v = 0; v < h.length; ++v)
        h[v] = Math.round(h[v] * y) / y;
    }
  }
  /**
   * Calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData.
   *
   * This is used to ensure that the true width and height of a trimmed texture is respected.
   */
  calculateTrimmedVertices() {
    if (!this.vertexTrimmedData)
      this.vertexTrimmedData = new Float32Array(8);
    else if (this._transformTrimmedID === this.transform._worldID && this._textureTrimmedID === this._texture._updateID)
      return;
    this._transformTrimmedID = this.transform._worldID, this._textureTrimmedID = this._texture._updateID;
    const e = this._texture, t = this.vertexTrimmedData, i = e.orig, n = this._anchor, s = this.transform.worldTransform, o = s.a, a = s.b, l = s.c, h = s.d, c = s.tx, u = s.ty, d = -n._x * i.width, f = d + i.width, p = -n._y * i.height, _ = p + i.height;
    if (t[0] = o * d + l * p + c, t[1] = h * p + a * d + u, t[2] = o * f + l * p + c, t[3] = h * p + a * f + u, t[4] = o * f + l * _ + c, t[5] = h * _ + a * f + u, t[6] = o * d + l * _ + c, t[7] = h * _ + a * d + u, this._roundPixels) {
      const m = Z.RESOLUTION;
      for (let y = 0; y < t.length; ++y)
        t[y] = Math.round(t[y] * m) / m;
    }
  }
  /**
   *
   * Renders the object using the WebGL renderer
   * @param renderer - The webgl renderer to use.
   */
  _render(e) {
    this.calculateVertices(), e.batch.setObjectRenderer(e.plugins[this.pluginName]), e.plugins[this.pluginName].render(this);
  }
  /** Updates the bounds of the sprite. */
  _calculateBounds() {
    const e = this._texture.trim, t = this._texture.orig;
    !e || e.width === t.width && e.height === t.height ? (this.calculateVertices(), this._bounds.addQuad(this.vertexData)) : (this.calculateTrimmedVertices(), this._bounds.addQuad(this.vertexTrimmedData));
  }
  /**
   * Gets the local bounds of the sprite object.
   * @param rect - Optional output rectangle.
   * @returns The bounds.
   */
  getLocalBounds(e) {
    return this.children.length === 0 ? (this._localBounds || (this._localBounds = new ua()), this._localBounds.minX = this._texture.orig.width * -this._anchor._x, this._localBounds.minY = this._texture.orig.height * -this._anchor._y, this._localBounds.maxX = this._texture.orig.width * (1 - this._anchor._x), this._localBounds.maxY = this._texture.orig.height * (1 - this._anchor._y), e || (this._localBoundsRect || (this._localBoundsRect = new le()), e = this._localBoundsRect), this._localBounds.getRectangle(e)) : super.getLocalBounds.call(this, e);
  }
  /**
   * Tests if a point is inside this sprite
   * @param point - the point to test
   * @returns The result of the test
   */
  containsPoint(e) {
    this.worldTransform.applyInverse(e, ns);
    const t = this._texture.orig.width, i = this._texture.orig.height, n = -t * this.anchor.x;
    let s = 0;
    return ns.x >= n && ns.x < n + t && (s = -i * this.anchor.y, ns.y >= s && ns.y < s + i);
  }
  /**
   * Destroys this sprite and optionally its texture and children.
   * @param options - Options parameter. A boolean will act as if all options
   *  have been set to that value
   * @param [options.children=false] - if set to true, all the children will have their destroy
   *      method called as well. 'options' will be passed on to those calls.
   * @param [options.texture=false] - Should it destroy the current texture of the sprite as well
   * @param [options.baseTexture=false] - Should it destroy the base texture of the sprite as well
   */
  destroy(e) {
    if (super.destroy(e), this._texture.off("update", this._onTextureUpdate, this), this._anchor = null, typeof e == "boolean" ? e : e == null ? void 0 : e.texture) {
      const t = typeof e == "boolean" ? e : e == null ? void 0 : e.baseTexture;
      this._texture.destroy(!!t);
    }
    this._texture = null;
  }
  // some helper functions..
  /**
   * Helper function that creates a new sprite based on the source you provide.
   * The source can be - frame id, image url, video url, canvas element, video element, base texture
   * @param {string|PIXI.Texture|HTMLImageElement|HTMLVideoElement|ImageBitmap|PIXI.ICanvas} source
   *     - Source to create texture from
   * @param {object} [options] - See {@link PIXI.BaseTexture}'s constructor for options.
   * @returns The newly created sprite
   */
  static from(e, t) {
    const i = e instanceof J ? e : J.from(e, t);
    return new st(i);
  }
  /**
   * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
   *
   * Advantages can include sharper image quality (like text) and faster rendering on canvas.
   * The main disadvantage is movement of objects may appear less smooth.
   *
   * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}.
   * @default false
   */
  set roundPixels(e) {
    this._roundPixels !== e && (this._transformID = -1, this._transformTrimmedID = -1), this._roundPixels = e;
  }
  get roundPixels() {
    return this._roundPixels;
  }
  /** The width of the sprite, setting this will actually modify the scale to achieve the value set. */
  get width() {
    return Math.abs(this.scale.x) * this._texture.orig.width;
  }
  set width(e) {
    const t = Zi(this.scale.x) || 1;
    this.scale.x = t * e / this._texture.orig.width, this._width = e;
  }
  /** The height of the sprite, setting this will actually modify the scale to achieve the value set. */
  get height() {
    return Math.abs(this.scale.y) * this._texture.orig.height;
  }
  set height(e) {
    const t = Zi(this.scale.y) || 1;
    this.scale.y = t * e / this._texture.orig.height, this._height = e;
  }
  /**
   * The anchor sets the origin point of the sprite. The default value is taken from the {@link PIXI.Texture|Texture}
   * and passed to the constructor.
   *
   * The default is `(0,0)`, this means the sprite's origin is the top left.
   *
   * Setting the anchor to `(0.5,0.5)` means the sprite's origin is centered.
   *
   * Setting the anchor to `(1,1)` would mean the sprite's origin point will be the bottom right corner.
   *
   * If you pass only single parameter, it will set both x and y to the same value as shown in the example below.
   * @example
   * import { Sprite } from 'pixi.js';
   *
   * const sprite = new Sprite(Texture.WHITE);
   * sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).
   */
  get anchor() {
    return this._anchor;
  }
  set anchor(e) {
    this._anchor.copyFrom(e);
  }
  /**
   * The tint applied to the sprite. This is a hex value.
   *
   * A value of 0xFFFFFF will remove any tint effect.
   * @default 0xFFFFFF
   */
  get tint() {
    return this._tintColor.value;
  }
  set tint(e) {
    this._tintColor.setValue(e), this._tintRGB = this._tintColor.toLittleEndianNumber();
  }
  /**
   * Get the tint as a RGB integer.
   * @ignore
   */
  get tintValue() {
    return this._tintColor.toNumber();
  }
  /** The texture that the sprite is using. */
  get texture() {
    return this._texture;
  }
  set texture(e) {
    this._texture !== e && (this._texture && this._texture.off("update", this._onTextureUpdate, this), this._texture = e || J.EMPTY, this._cachedTint = 16777215, this._textureID = -1, this._textureTrimmedID = -1, e && (e.baseTexture.valid ? this._onTextureUpdate() : e.once("update", this._onTextureUpdate, this)));
  }
}
const l0 = new Te();
Pe.prototype._cacheAsBitmap = !1;
Pe.prototype._cacheData = null;
Pe.prototype._cacheAsBitmapResolution = null;
Pe.prototype._cacheAsBitmapMultisample = null;
class JS {
  constructor() {
    this.textureCacheId = null, this.originalRender = null, this.originalRenderCanvas = null, this.originalCalculateBounds = null, this.originalGetLocalBounds = null, this.originalUpdateTransform = null, this.originalDestroy = null, this.originalMask = null, this.originalFilterArea = null, this.originalContainsPoint = null, this.sprite = null;
  }
}
Object.defineProperties(Pe.prototype, {
  /**
   * The resolution to use for cacheAsBitmap. By default this will use the renderer's resolution
   * but can be overriden for performance. Lower values will reduce memory usage at the expense
   * of render quality. A falsey value of `null` or `0` will default to the renderer's resolution.
   * If `cacheAsBitmap` is set to `true`, this will re-render with the new resolution.
   * @member {number|null} cacheAsBitmapResolution
   * @memberof PIXI.DisplayObject#
   * @default null
   */
  cacheAsBitmapResolution: {
    get() {
      return this._cacheAsBitmapResolution;
    },
    set(r) {
      r !== this._cacheAsBitmapResolution && (this._cacheAsBitmapResolution = r, this.cacheAsBitmap && (this.cacheAsBitmap = !1, this.cacheAsBitmap = !0));
    }
  },
  /**
   * The number of samples to use for cacheAsBitmap. If set to `null`, the renderer's
   * sample count is used.
   * If `cacheAsBitmap` is set to `true`, this will re-render with the new number of samples.
   * @member {number|null} cacheAsBitmapMultisample
   * @memberof PIXI.DisplayObject#
   * @default null
   */
  cacheAsBitmapMultisample: {
    get() {
      return this._cacheAsBitmapMultisample;
    },
    set(r) {
      r !== this._cacheAsBitmapMultisample && (this._cacheAsBitmapMultisample = r, this.cacheAsBitmap && (this.cacheAsBitmap = !1, this.cacheAsBitmap = !0));
    }
  },
  /**
   * Set this to true if you want this display object to be cached as a bitmap.
   * This basically takes a snapshot of the display object as it is at that moment. It can
   * provide a performance benefit for complex static displayObjects.
   * To remove simply set this property to `false`
   *
   * IMPORTANT GOTCHA - Make sure that all your textures are preloaded BEFORE setting this property to true
   * as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear.
   * @member {boolean}
   * @memberof PIXI.DisplayObject#
   */
  cacheAsBitmap: {
    get() {
      return this._cacheAsBitmap;
    },
    set(r) {
      if (this._cacheAsBitmap === r)
        return;
      this._cacheAsBitmap = r;
      let e;
      r ? (this._cacheData || (this._cacheData = new JS()), e = this._cacheData, e.originalRender = this.render, e.originalRenderCanvas = this.renderCanvas, e.originalUpdateTransform = this.updateTransform, e.originalCalculateBounds = this.calculateBounds, e.originalGetLocalBounds = this.getLocalBounds, e.originalDestroy = this.destroy, e.originalContainsPoint = this.containsPoint, e.originalMask = this._mask, e.originalFilterArea = this.filterArea, this.render = this._renderCached, this.renderCanvas = this._renderCachedCanvas, this.destroy = this._cacheAsBitmapDestroy) : (e = this._cacheData, e.sprite && this._destroyCachedDisplayObject(), this.render = e.originalRender, this.renderCanvas = e.originalRenderCanvas, this.calculateBounds = e.originalCalculateBounds, this.getLocalBounds = e.originalGetLocalBounds, this.destroy = e.originalDestroy, this.updateTransform = e.originalUpdateTransform, this.containsPoint = e.originalContainsPoint, this._mask = e.originalMask, this.filterArea = e.originalFilterArea);
    }
  }
});
Pe.prototype._renderCached = function(r) {
  !this.visible || this.worldAlpha <= 0 || !this.renderable || (this._initCachedDisplayObject(r), this._cacheData.sprite.transform._worldID = this.transform._worldID, this._cacheData.sprite.worldAlpha = this.worldAlpha, this._cacheData.sprite._render(r));
};
Pe.prototype._initCachedDisplayObject = function(r) {
  var d, f;
  if ((d = this._cacheData) != null && d.sprite)
    return;
  const e = this.alpha;
  this.alpha = 1, r.batch.flush();
  const t = this.getLocalBounds(new le(), !0);
  if ((f = this.filters) != null && f.length) {
    const p = this.filters[0].padding;
    t.pad(p);
  }
  const i = this.cacheAsBitmapResolution || r.resolution;
  t.ceil(i), t.width = Math.max(t.width, 1 / i), t.height = Math.max(t.height, 1 / i);
  const n = r.renderTexture.current, s = r.renderTexture.sourceFrame.clone(), o = r.renderTexture.destinationFrame.clone(), a = r.projection.transform, l = et.create({
    width: t.width,
    height: t.height,
    resolution: i,
    multisample: this.cacheAsBitmapMultisample ?? r.multisample
  }), h = `cacheAsBitmap_${Hr()}`;
  this._cacheData.textureCacheId = h, ae.addToCache(l.baseTexture, h), J.addToCache(l, h);
  const c = this.transform.localTransform.copyTo(l0).invert().translate(-t.x, -t.y);
  this.render = this._cacheData.originalRender, r.render(this, { renderTexture: l, clear: !0, transform: c, skipUpdateTransform: !1 }), r.framebuffer.blit(), r.projection.transform = a, r.renderTexture.bind(n, s, o), this.render = this._renderCached, this.updateTransform = this.displayObjectUpdateTransform, this.calculateBounds = this._calculateCachedBounds, this.getLocalBounds = this._getCachedLocalBounds, this._mask = null, this.filterArea = null, this.alpha = e;
  const u = new st(l);
  u.transform.worldTransform = this.transform.worldTransform, u.anchor.x = -(t.x / t.width), u.anchor.y = -(t.y / t.height), u.alpha = e, u._bounds = this._bounds, this._cacheData.sprite = u, this.transform._parentID = -1, this.parent ? this.updateTransform() : (this.enableTempParent(), this.updateTransform(), this.disableTempParent(null)), this.containsPoint = u.containsPoint.bind(u);
};
Pe.prototype._renderCachedCanvas = function(r) {
  !this.visible || this.worldAlpha <= 0 || !this.renderable || (this._initCachedDisplayObjectCanvas(r), this._cacheData.sprite.worldAlpha = this.worldAlpha, this._cacheData.sprite._renderCanvas(r));
};
Pe.prototype._initCachedDisplayObjectCanvas = function(r) {
  var c;
  if ((c = this._cacheData) != null && c.sprite)
    return;
  const e = this.getLocalBounds(new le(), !0), t = this.alpha;
  this.alpha = 1;
  const i = r.canvasContext.activeContext, n = r._projTransform, s = this.cacheAsBitmapResolution || r.resolution;
  e.ceil(s), e.width = Math.max(e.width, 1 / s), e.height = Math.max(e.height, 1 / s);
  const o = et.create({
    width: e.width,
    height: e.height,
    resolution: s
  }), a = `cacheAsBitmap_${Hr()}`;
  this._cacheData.textureCacheId = a, ae.addToCache(o.baseTexture, a), J.addToCache(o, a);
  const l = l0;
  this.transform.localTransform.copyTo(l), l.invert(), l.tx -= e.x, l.ty -= e.y, this.renderCanvas = this._cacheData.originalRenderCanvas, r.render(this, { renderTexture: o, clear: !0, transform: l, skipUpdateTransform: !1 }), r.canvasContext.activeContext = i, r._projTransform = n, this.renderCanvas = this._renderCachedCanvas, this.updateTransform = this.displayObjectUpdateTransform, this.calculateBounds = this._calculateCachedBounds, this.getLocalBounds = this._getCachedLocalBounds, this._mask = null, this.filterArea = null, this.alpha = t;
  const h = new st(o);
  h.transform.worldTransform = this.transform.worldTransform, h.anchor.x = -(e.x / e.width), h.anchor.y = -(e.y / e.height), h.alpha = t, h._bounds = this._bounds, this._cacheData.sprite = h, this.transform._parentID = -1, this.parent ? this.updateTransform() : (this.parent = r._tempDisplayObjectParent, this.updateTransform(), this.parent = null), this.containsPoint = h.containsPoint.bind(h);
};
Pe.prototype._calculateCachedBounds = function() {
  this._bounds.clear(), this._cacheData.sprite.transform._worldID = this.transform._worldID, this._cacheData.sprite._calculateBounds(), this._bounds.updateID = this._boundsID;
};
Pe.prototype._getCachedLocalBounds = function() {
  return this._cacheData.sprite.getLocalBounds(null);
};
Pe.prototype._destroyCachedDisplayObject = function() {
  this._cacheData.sprite._texture.destroy(!0), this._cacheData.sprite = null, ae.removeFromCache(this._cacheData.textureCacheId), J.removeFromCache(this._cacheData.textureCacheId), this._cacheData.textureCacheId = null;
};
Pe.prototype._cacheAsBitmapDestroy = function(r) {
  this.cacheAsBitmap = !1, this.destroy(r);
};
Pe.prototype.name = null;
Qe.prototype.getChildByName = function(r, e) {
  for (let t = 0, i = this.children.length; t < i; t++)
    if (this.children[t].name === r)
      return this.children[t];
  if (e)
    for (let t = 0, i = this.children.length; t < i; t++) {
      const n = this.children[t];
      if (!n.getChildByName)
        continue;
      const s = n.getChildByName(r, !0);
      if (s)
        return s;
    }
  return null;
};
Pe.prototype.getGlobalPosition = function(r = new ge(), e = !1) {
  return this.parent ? this.parent.toGlobal(this.position, r, e) : (r.x = this.position.x, r.y = this.position.y), r;
};
var QS = `varying vec2 vTextureCoord;

uniform sampler2D uSampler;
uniform float uAlpha;

void main(void)
{
   gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
}
`;
class eC extends Je {
  /**
   * @param alpha - Amount of alpha from 0 to 1, where 0 is transparent
   */
  constructor(e = 1) {
    super(zS, QS, { uAlpha: 1 }), this.alpha = e;
  }
  /**
   * Coefficient for alpha multiplication
   * @default 1
   */
  get alpha() {
    return this.uniforms.uAlpha;
  }
  set alpha(e) {
    this.uniforms.uAlpha = e;
  }
}
const tC = {
  5: [0.153388, 0.221461, 0.250301],
  7: [0.071303, 0.131514, 0.189879, 0.214607],
  9: [0.028532, 0.067234, 0.124009, 0.179044, 0.20236],
  11: [93e-4, 0.028002, 0.065984, 0.121703, 0.175713, 0.198596],
  13: [2406e-6, 9255e-6, 0.027867, 0.065666, 0.121117, 0.174868, 0.197641],
  15: [489e-6, 2403e-6, 9246e-6, 0.02784, 0.065602, 0.120999, 0.174697, 0.197448]
}, iC = [
  "varying vec2 vBlurTexCoords[%size%];",
  "uniform sampler2D uSampler;",
  "void main(void)",
  "{",
  "    gl_FragColor = vec4(0.0);",
  "    %blur%",
  "}"
].join(`
`);
function rC(r) {
  const e = tC[r], t = e.length;
  let i = iC, n = "";
  const s = "gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";
  let o;
  for (let a = 0; a < r; a++) {
    let l = s.replace("%index%", a.toString());
    o = a, a >= t && (o = r - a - 1), l = l.replace("%value%", e[o].toString()), n += l, n += `
`;
  }
  return i = i.replace("%blur%", n), i = i.replace("%size%", r.toString()), i;
}
const nC = `
    attribute vec2 aVertexPosition;

    uniform mat3 projectionMatrix;

    uniform float strength;

    varying vec2 vBlurTexCoords[%size%];

    uniform vec4 inputSize;
    uniform vec4 outputFrame;

    vec4 filterVertexPosition( void )
    {
        vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

        return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
    }

    vec2 filterTextureCoord( void )
    {
        return aVertexPosition * (outputFrame.zw * inputSize.zw);
    }

    void main(void)
    {
        gl_Position = filterVertexPosition();

        vec2 textureCoord = filterTextureCoord();
        %blur%
    }`;
function sC(r, e) {
  const t = Math.ceil(r / 2);
  let i = nC, n = "", s;
  e ? s = "vBlurTexCoords[%index%] =  textureCoord + vec2(%sampleIndex% * strength, 0.0);" : s = "vBlurTexCoords[%index%] =  textureCoord + vec2(0.0, %sampleIndex% * strength);";
  for (let o = 0; o < r; o++) {
    let a = s.replace("%index%", o.toString());
    a = a.replace("%sampleIndex%", `${o - (t - 1)}.0`), n += a, n += `
`;
  }
  return i = i.replace("%blur%", n), i = i.replace("%size%", r.toString()), i;
}
class gc extends Je {
  /**
   * @param horizontal - Do pass along the x-axis (`true`) or y-axis (`false`).
   * @param strength - The strength of the blur filter.
   * @param quality - The quality of the blur filter.
   * @param {number|null} [resolution=PIXI.Filter.defaultResolution] - The resolution of the blur filter.
   * @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
   */
  constructor(e, t = 8, i = 4, n = Je.defaultResolution, s = 5) {
    const o = sC(s, e), a = rC(s);
    super(
      // vertex shader
      o,
      // fragment shader
      a
    ), this.horizontal = e, this.resolution = n, this._quality = 0, this.quality = i, this.blur = t;
  }
  /**
   * Applies the filter.
   * @param filterManager - The manager.
   * @param input - The input target.
   * @param output - The output target.
   * @param clearMode - How to clear
   */
  apply(e, t, i, n) {
    if (i ? this.horizontal ? this.uniforms.strength = 1 / i.width * (i.width / t.width) : this.uniforms.strength = 1 / i.height * (i.height / t.height) : this.horizontal ? this.uniforms.strength = 1 / e.renderer.width * (e.renderer.width / t.width) : this.uniforms.strength = 1 / e.renderer.height * (e.renderer.height / t.height), this.uniforms.strength *= this.strength, this.uniforms.strength /= this.passes, this.passes === 1)
      e.applyFilter(this, t, i, n);
    else {
      const s = e.getFilterTexture(), o = e.renderer;
      let a = t, l = s;
      this.state.blend = !1, e.applyFilter(this, a, l, ci.CLEAR);
      for (let h = 1; h < this.passes - 1; h++) {
        e.bindAndClear(a, ci.BLIT), this.uniforms.uSampler = l;
        const c = l;
        l = a, a = c, o.shader.bind(this), o.geometry.draw(5);
      }
      this.state.blend = !0, e.applyFilter(this, l, i, n), e.returnFilterTexture(s);
    }
  }
  /**
   * Sets the strength of both the blur.
   * @default 16
   */
  get blur() {
    return this.strength;
  }
  set blur(e) {
    this.padding = 1 + Math.abs(e) * 2, this.strength = e;
  }
  /**
   * Sets the quality of the blur by modifying the number of passes. More passes means higher
   * quality bluring but the lower the performance.
   * @default 4
   */
  get quality() {
    return this._quality;
  }
  set quality(e) {
    this._quality = e, this.passes = e;
  }
}
class oC extends Je {
  /**
   * @param strength - The strength of the blur filter.
   * @param quality - The quality of the blur filter.
   * @param {number|null} [resolution=PIXI.Filter.defaultResolution] - The resolution of the blur filter.
   * @param kernelSize - The kernelSize of the blur filter.Options: 5, 7, 9, 11, 13, 15.
   */
  constructor(e = 8, t = 4, i = Je.defaultResolution, n = 5) {
    super(), this._repeatEdgePixels = !1, this.blurXFilter = new gc(!0, e, t, i, n), this.blurYFilter = new gc(!1, e, t, i, n), this.resolution = i, this.quality = t, this.blur = e, this.repeatEdgePixels = !1;
  }
  /**
   * Applies the filter.
   * @param filterManager - The manager.
   * @param input - The input target.
   * @param output - The output target.
   * @param clearMode - How to clear
   */
  apply(e, t, i, n) {
    const s = Math.abs(this.blurXFilter.strength), o = Math.abs(this.blurYFilter.strength);
    if (s && o) {
      const a = e.getFilterTexture();
      this.blurXFilter.apply(e, t, a, ci.CLEAR), this.blurYFilter.apply(e, a, i, n), e.returnFilterTexture(a);
    } else
      o ? this.blurYFilter.apply(e, t, i, n) : this.blurXFilter.apply(e, t, i, n);
  }
  updatePadding() {
    this._repeatEdgePixels ? this.padding = 0 : this.padding = Math.max(Math.abs(this.blurXFilter.strength), Math.abs(this.blurYFilter.strength)) * 2;
  }
  /**
   * Sets the strength of both the blurX and blurY properties simultaneously
   * @default 2
   */
  get blur() {
    return this.blurXFilter.blur;
  }
  set blur(e) {
    this.blurXFilter.blur = this.blurYFilter.blur = e, this.updatePadding();
  }
  /**
   * Sets the number of passes for blur. More passes means higher quality bluring.
   * @default 1
   */
  get quality() {
    return this.blurXFilter.quality;
  }
  set quality(e) {
    this.blurXFilter.quality = this.blurYFilter.quality = e;
  }
  /**
   * Sets the strength of the blurX property
   * @default 2
   */
  get blurX() {
    return this.blurXFilter.blur;
  }
  set blurX(e) {
    this.blurXFilter.blur = e, this.updatePadding();
  }
  /**
   * Sets the strength of the blurY property
   * @default 2
   */
  get blurY() {
    return this.blurYFilter.blur;
  }
  set blurY(e) {
    this.blurYFilter.blur = e, this.updatePadding();
  }
  /**
   * Sets the blendmode of the filter
   * @default PIXI.BLEND_MODES.NORMAL
   */
  get blendMode() {
    return this.blurYFilter.blendMode;
  }
  set blendMode(e) {
    this.blurYFilter.blendMode = e;
  }
  /**
   * If set to true the edge of the target will be clamped
   * @default false
   */
  get repeatEdgePixels() {
    return this._repeatEdgePixels;
  }
  set repeatEdgePixels(e) {
    this._repeatEdgePixels = e, this.updatePadding();
  }
}
var aC = `varying vec2 vTextureCoord;
uniform sampler2D uSampler;
uniform float m[20];
uniform float uAlpha;

void main(void)
{
    vec4 c = texture2D(uSampler, vTextureCoord);

    if (uAlpha == 0.0) {
        gl_FragColor = c;
        return;
    }

    // Un-premultiply alpha before applying the color matrix. See issue #3539.
    if (c.a > 0.0) {
      c.rgb /= c.a;
    }

    vec4 result;

    result.r = (m[0] * c.r);
        result.r += (m[1] * c.g);
        result.r += (m[2] * c.b);
        result.r += (m[3] * c.a);
        result.r += m[4];

    result.g = (m[5] * c.r);
        result.g += (m[6] * c.g);
        result.g += (m[7] * c.b);
        result.g += (m[8] * c.a);
        result.g += m[9];

    result.b = (m[10] * c.r);
       result.b += (m[11] * c.g);
       result.b += (m[12] * c.b);
       result.b += (m[13] * c.a);
       result.b += m[14];

    result.a = (m[15] * c.r);
       result.a += (m[16] * c.g);
       result.a += (m[17] * c.b);
       result.a += (m[18] * c.a);
       result.a += m[19];

    vec3 rgb = mix(c.rgb, result.rgb, uAlpha);

    // Premultiply alpha again.
    rgb *= result.a;

    gl_FragColor = vec4(rgb, result.a);
}
`;
class yc extends Je {
  constructor() {
    const e = {
      m: new Float32Array([
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0,
        0,
        0,
        0,
        0,
        1,
        0
      ]),
      uAlpha: 1
    };
    super(e0, aC, e), this.alpha = 1;
  }
  /**
   * Transforms current matrix and set the new one
   * @param {number[]} matrix - 5x4 matrix
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  _loadMatrix(e, t = !1) {
    let i = e;
    t && (this._multiply(i, this.uniforms.m, e), i = this._colorMatrix(i)), this.uniforms.m = i;
  }
  /**
   * Multiplies two mat5's
   * @private
   * @param out - 5x4 matrix the receiving matrix
   * @param a - 5x4 matrix the first operand
   * @param b - 5x4 matrix the second operand
   * @returns {number[]} 5x4 matrix
   */
  _multiply(e, t, i) {
    return e[0] = t[0] * i[0] + t[1] * i[5] + t[2] * i[10] + t[3] * i[15], e[1] = t[0] * i[1] + t[1] * i[6] + t[2] * i[11] + t[3] * i[16], e[2] = t[0] * i[2] + t[1] * i[7] + t[2] * i[12] + t[3] * i[17], e[3] = t[0] * i[3] + t[1] * i[8] + t[2] * i[13] + t[3] * i[18], e[4] = t[0] * i[4] + t[1] * i[9] + t[2] * i[14] + t[3] * i[19] + t[4], e[5] = t[5] * i[0] + t[6] * i[5] + t[7] * i[10] + t[8] * i[15], e[6] = t[5] * i[1] + t[6] * i[6] + t[7] * i[11] + t[8] * i[16], e[7] = t[5] * i[2] + t[6] * i[7] + t[7] * i[12] + t[8] * i[17], e[8] = t[5] * i[3] + t[6] * i[8] + t[7] * i[13] + t[8] * i[18], e[9] = t[5] * i[4] + t[6] * i[9] + t[7] * i[14] + t[8] * i[19] + t[9], e[10] = t[10] * i[0] + t[11] * i[5] + t[12] * i[10] + t[13] * i[15], e[11] = t[10] * i[1] + t[11] * i[6] + t[12] * i[11] + t[13] * i[16], e[12] = t[10] * i[2] + t[11] * i[7] + t[12] * i[12] + t[13] * i[17], e[13] = t[10] * i[3] + t[11] * i[8] + t[12] * i[13] + t[13] * i[18], e[14] = t[10] * i[4] + t[11] * i[9] + t[12] * i[14] + t[13] * i[19] + t[14], e[15] = t[15] * i[0] + t[16] * i[5] + t[17] * i[10] + t[18] * i[15], e[16] = t[15] * i[1] + t[16] * i[6] + t[17] * i[11] + t[18] * i[16], e[17] = t[15] * i[2] + t[16] * i[7] + t[17] * i[12] + t[18] * i[17], e[18] = t[15] * i[3] + t[16] * i[8] + t[17] * i[13] + t[18] * i[18], e[19] = t[15] * i[4] + t[16] * i[9] + t[17] * i[14] + t[18] * i[19] + t[19], e;
  }
  /**
   * Create a Float32 Array and normalize the offset component to 0-1
   * @param {number[]} matrix - 5x4 matrix
   * @returns {number[]} 5x4 matrix with all values between 0-1
   */
  _colorMatrix(e) {
    const t = new Float32Array(e);
    return t[4] /= 255, t[9] /= 255, t[14] /= 255, t[19] /= 255, t;
  }
  /**
   * Adjusts brightness
   * @param b - value of the brigthness (0-1, where 0 is black)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  brightness(e, t) {
    const i = [
      e,
      0,
      0,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      0,
      0,
      e,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(i, t);
  }
  /**
   * Sets each channel on the diagonal of the color matrix.
   * This can be used to achieve a tinting effect on Containers similar to the tint field of some
   * display objects like Sprite, Text, Graphics, and Mesh.
   * @param color - Color of the tint. This is a hex value.
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  tint(e, t) {
    const [i, n, s] = be.shared.setValue(e).toArray(), o = [
      i,
      0,
      0,
      0,
      0,
      0,
      n,
      0,
      0,
      0,
      0,
      0,
      s,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(o, t);
  }
  /**
   * Set the matrices in grey scales
   * @param scale - value of the grey (0-1, where 0 is black)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  greyscale(e, t) {
    const i = [
      e,
      e,
      e,
      0,
      0,
      e,
      e,
      e,
      0,
      0,
      e,
      e,
      e,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(i, t);
  }
  /**
   * Set the black and white matrice.
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  blackAndWhite(e) {
    const t = [
      0.3,
      0.6,
      0.1,
      0,
      0,
      0.3,
      0.6,
      0.1,
      0,
      0,
      0.3,
      0.6,
      0.1,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Set the hue property of the color
   * @param rotation - in degrees
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  hue(e, t) {
    e = (e || 0) / 180 * Math.PI;
    const i = Math.cos(e), n = Math.sin(e), s = Math.sqrt, o = 1 / 3, a = s(o), l = i + (1 - i) * o, h = o * (1 - i) - a * n, c = o * (1 - i) + a * n, u = o * (1 - i) + a * n, d = i + o * (1 - i), f = o * (1 - i) - a * n, p = o * (1 - i) - a * n, _ = o * (1 - i) + a * n, m = i + o * (1 - i), y = [
      l,
      h,
      c,
      0,
      0,
      u,
      d,
      f,
      0,
      0,
      p,
      _,
      m,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(y, t);
  }
  /**
   * Set the contrast matrix, increase the separation between dark and bright
   * Increase contrast : shadows darker and highlights brighter
   * Decrease contrast : bring the shadows up and the highlights down
   * @param amount - value of the contrast (0-1)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  contrast(e, t) {
    const i = (e || 0) + 1, n = -0.5 * (i - 1), s = [
      i,
      0,
      0,
      0,
      n,
      0,
      i,
      0,
      0,
      n,
      0,
      0,
      i,
      0,
      n,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(s, t);
  }
  /**
   * Set the saturation matrix, increase the separation between colors
   * Increase saturation : increase contrast, brightness, and sharpness
   * @param amount - The saturation amount (0-1)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  saturate(e = 0, t) {
    const i = e * 2 / 3 + 1, n = (i - 1) * -0.5, s = [
      i,
      n,
      n,
      0,
      0,
      n,
      i,
      n,
      0,
      0,
      n,
      n,
      i,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(s, t);
  }
  /** Desaturate image (remove color) Call the saturate function */
  desaturate() {
    this.saturate(-1);
  }
  /**
   * Negative image (inverse of classic rgb matrix)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  negative(e) {
    const t = [
      -1,
      0,
      0,
      1,
      0,
      0,
      -1,
      0,
      1,
      0,
      0,
      0,
      -1,
      1,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Sepia image
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  sepia(e) {
    const t = [
      0.393,
      0.7689999,
      0.18899999,
      0,
      0,
      0.349,
      0.6859999,
      0.16799999,
      0,
      0,
      0.272,
      0.5339999,
      0.13099999,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Color motion picture process invented in 1916 (thanks Dominic Szablewski)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  technicolor(e) {
    const t = [
      1.9125277891456083,
      -0.8545344976951645,
      -0.09155508482755585,
      0,
      11.793603434377337,
      -0.3087833385928097,
      1.7658908555458428,
      -0.10601743074722245,
      0,
      -70.35205161461398,
      -0.231103377548616,
      -0.7501899197440212,
      1.847597816108189,
      0,
      30.950940869491138,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Polaroid filter
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  polaroid(e) {
    const t = [
      1.438,
      -0.062,
      -0.062,
      0,
      0,
      -0.122,
      1.378,
      -0.122,
      0,
      0,
      -0.016,
      -0.016,
      1.483,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Filter who transforms : Red -> Blue and Blue -> Red
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  toBGR(e) {
    const t = [
      0,
      0,
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  kodachrome(e) {
    const t = [
      1.1285582396593525,
      -0.3967382283601348,
      -0.03992559172921793,
      0,
      63.72958762196502,
      -0.16404339962244616,
      1.0835251566291304,
      -0.05498805115633132,
      0,
      24.732407896706203,
      -0.16786010706155763,
      -0.5603416277695248,
      1.6014850761964943,
      0,
      35.62982807460946,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Brown delicious browni filter (thanks Dominic Szablewski)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  browni(e) {
    const t = [
      0.5997023498159715,
      0.34553243048391263,
      -0.2708298674538042,
      0,
      47.43192855600873,
      -0.037703249837783157,
      0.8609577587992641,
      0.15059552388459913,
      0,
      -36.96841498319127,
      0.24113635128153335,
      -0.07441037908422492,
      0.44972182064877153,
      0,
      -7.562075277591283,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * Vintage filter (thanks Dominic Szablewski)
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  vintage(e) {
    const t = [
      0.6279345635605994,
      0.3202183420819367,
      -0.03965408211312453,
      0,
      9.651285835294123,
      0.02578397704808868,
      0.6441188644374771,
      0.03259127616149294,
      0,
      7.462829176470591,
      0.0466055556782719,
      -0.0851232987247891,
      0.5241648018700465,
      0,
      5.159190588235296,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /**
   * We don't know exactly what it does, kind of gradient map, but funny to play with!
   * @param desaturation - Tone values.
   * @param toned - Tone values.
   * @param lightColor - Tone values, example: `0xFFE580`
   * @param darkColor - Tone values, example: `0xFFE580`
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  colorTone(e, t, i, n, s) {
    e = e || 0.2, t = t || 0.15, i = i || 16770432, n = n || 3375104;
    const o = be.shared, [a, l, h] = o.setValue(i).toArray(), [c, u, d] = o.setValue(n).toArray(), f = [
      0.3,
      0.59,
      0.11,
      0,
      0,
      a,
      l,
      h,
      e,
      0,
      c,
      u,
      d,
      t,
      0,
      a - c,
      l - u,
      h - d,
      0,
      0
    ];
    this._loadMatrix(f, s);
  }
  /**
   * Night effect
   * @param intensity - The intensity of the night effect.
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  night(e, t) {
    e = e || 0.1;
    const i = [
      e * -2,
      -e,
      0,
      0,
      0,
      -e,
      0,
      e,
      0,
      0,
      0,
      e,
      e * 2,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(i, t);
  }
  /**
   * Predator effect
   *
   * Erase the current matrix by setting a new indepent one
   * @param amount - how much the predator feels his future victim
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  predator(e, t) {
    const i = [
      // row 1
      11.224130630493164 * e,
      -4.794486999511719 * e,
      -2.8746118545532227 * e,
      0 * e,
      0.40342438220977783 * e,
      // row 2
      -3.6330697536468506 * e,
      9.193157196044922 * e,
      -2.951810836791992 * e,
      0 * e,
      -1.316135048866272 * e,
      // row 3
      -3.2184197902679443 * e,
      -4.2375030517578125 * e,
      7.476448059082031 * e,
      0 * e,
      0.8044459223747253 * e,
      // row 4
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(i, t);
  }
  /**
   * LSD effect
   *
   * Multiply the current matrix
   * @param multiply - if true, current matrix and matrix are multiplied. If false,
   *  just set the current matrix with @param matrix
   */
  lsd(e) {
    const t = [
      2,
      -0.4,
      0.5,
      0,
      0,
      -0.5,
      2,
      -0.4,
      0,
      0,
      -0.4,
      -0.5,
      3,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(t, e);
  }
  /** Erase the current matrix by setting the default one. */
  reset() {
    const e = [
      1,
      0,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      0,
      1,
      0
    ];
    this._loadMatrix(e, !1);
  }
  /**
   * The matrix of the color matrix filter
   * @member {number[]}
   * @default [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]
   */
  get matrix() {
    return this.uniforms.m;
  }
  set matrix(e) {
    this.uniforms.m = e;
  }
  /**
   * The opacity value to use when mixing the original and resultant colors.
   *
   * When the value is 0, the original color is used without modification.
   * When the value is 1, the result color is used.
   * When in the range (0, 1) the color is interpolated between the original and result by this amount.
   * @default 1
   */
  get alpha() {
    return this.uniforms.uAlpha;
  }
  set alpha(e) {
    this.uniforms.uAlpha = e;
  }
}
yc.prototype.grayscale = yc.prototype.greyscale;
var lC = `varying vec2 vFilterCoord;
varying vec2 vTextureCoord;

uniform vec2 scale;
uniform mat2 rotation;
uniform sampler2D uSampler;
uniform sampler2D mapSampler;

uniform highp vec4 inputSize;
uniform vec4 inputClamp;

void main(void)
{
  vec4 map =  texture2D(mapSampler, vFilterCoord);

  map -= 0.5;
  map.xy = scale * inputSize.zw * (rotation * map.xy);

  gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
}
`, hC = `attribute vec2 aVertexPosition;

uniform mat3 projectionMatrix;
uniform mat3 filterMatrix;

varying vec2 vTextureCoord;
varying vec2 vFilterCoord;

uniform vec4 inputSize;
uniform vec4 outputFrame;

vec4 filterVertexPosition( void )
{
    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}

vec2 filterTextureCoord( void )
{
    return aVertexPosition * (outputFrame.zw * inputSize.zw);
}

void main(void)
{
	gl_Position = filterVertexPosition();
	vTextureCoord = filterTextureCoord();
	vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0)  ).xy;
}
`;
class cC extends Je {
  /**
   * @param {PIXI.Sprite} sprite - The sprite used for the displacement map. (make sure its added to the scene!)
   * @param scale - The scale of the displacement
   */
  constructor(e, t) {
    const i = new Te();
    e.renderable = !1, super(hC, lC, {
      mapSampler: e._texture,
      filterMatrix: i,
      scale: { x: 1, y: 1 },
      rotation: new Float32Array([1, 0, 0, 1])
    }), this.maskSprite = e, this.maskMatrix = i, t == null && (t = 20), this.scale = new ge(t, t);
  }
  /**
   * Applies the filter.
   * @param filterManager - The manager.
   * @param input - The input target.
   * @param output - The output target.
   * @param clearMode - clearMode.
   */
  apply(e, t, i, n) {
    this.uniforms.filterMatrix = e.calculateSpriteMatrix(this.maskMatrix, this.maskSprite), this.uniforms.scale.x = this.scale.x, this.uniforms.scale.y = this.scale.y;
    const s = this.maskSprite.worldTransform, o = Math.sqrt(s.a * s.a + s.b * s.b), a = Math.sqrt(s.c * s.c + s.d * s.d);
    o !== 0 && a !== 0 && (this.uniforms.rotation[0] = s.a / o, this.uniforms.rotation[1] = s.b / o, this.uniforms.rotation[2] = s.c / a, this.uniforms.rotation[3] = s.d / a), e.applyFilter(this, t, i, n);
  }
  /** The texture used for the displacement map. Must be power of 2 sized texture. */
  get map() {
    return this.uniforms.mapSampler;
  }
  set map(e) {
    this.uniforms.mapSampler = e;
  }
}
var uC = `varying vec2 v_rgbNW;
varying vec2 v_rgbNE;
varying vec2 v_rgbSW;
varying vec2 v_rgbSE;
varying vec2 v_rgbM;

varying vec2 vFragCoord;
uniform sampler2D uSampler;
uniform highp vec4 inputSize;


/**
 Basic FXAA implementation based on the code on geeks3d.com with the
 modification that the texture2DLod stuff was removed since it's
 unsupported by WebGL.

 --

 From:
 https://github.com/mitsuhiko/webgl-meincraft

 Copyright (c) 2011 by Armin Ronacher.

 Some rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:

 * Redistributions of source code must retain the above copyright
 notice, this list of conditions and the following disclaimer.

 * Redistributions in binary form must reproduce the above
 copyright notice, this list of conditions and the following
 disclaimer in the documentation and/or other materials provided
 with the distribution.

 * The names of the contributors may not be used to endorse or
 promote products derived from this software without specific
 prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef FXAA_REDUCE_MIN
#define FXAA_REDUCE_MIN   (1.0/ 128.0)
#endif
#ifndef FXAA_REDUCE_MUL
#define FXAA_REDUCE_MUL   (1.0 / 8.0)
#endif
#ifndef FXAA_SPAN_MAX
#define FXAA_SPAN_MAX     8.0
#endif

//optimized version for mobile, where dependent
//texture reads can be a bottleneck
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
          vec2 v_rgbNW, vec2 v_rgbNE,
          vec2 v_rgbSW, vec2 v_rgbSE,
          vec2 v_rgbM) {
    vec4 color;
    vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
    vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
    vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
    vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
    vec4 texColor = texture2D(tex, v_rgbM);
    vec3 rgbM  = texColor.xyz;
    vec3 luma = vec3(0.299, 0.587, 0.114);
    float lumaNW = dot(rgbNW, luma);
    float lumaNE = dot(rgbNE, luma);
    float lumaSW = dot(rgbSW, luma);
    float lumaSE = dot(rgbSE, luma);
    float lumaM  = dot(rgbM,  luma);
    float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
    float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));

    mediump vec2 dir;
    dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
    dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));

    float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
                          (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);

    float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
    dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
              max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
                  dir * rcpDirMin)) * inverseVP;

    vec3 rgbA = 0.5 * (
                       texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
                       texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
    vec3 rgbB = rgbA * 0.5 + 0.25 * (
                                     texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
                                     texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);

    float lumaB = dot(rgbB, luma);
    if ((lumaB < lumaMin) || (lumaB > lumaMax))
        color = vec4(rgbA, texColor.a);
    else
        color = vec4(rgbB, texColor.a);
    return color;
}

void main() {

      vec4 color;

      color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);

      gl_FragColor = color;
}
`, dC = `
attribute vec2 aVertexPosition;

uniform mat3 projectionMatrix;

varying vec2 v_rgbNW;
varying vec2 v_rgbNE;
varying vec2 v_rgbSW;
varying vec2 v_rgbSE;
varying vec2 v_rgbM;

varying vec2 vFragCoord;

uniform vec4 inputSize;
uniform vec4 outputFrame;

vec4 filterVertexPosition( void )
{
    vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;

    return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
}

void texcoords(vec2 fragCoord, vec2 inverseVP,
               out vec2 v_rgbNW, out vec2 v_rgbNE,
               out vec2 v_rgbSW, out vec2 v_rgbSE,
               out vec2 v_rgbM) {
    v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
    v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
    v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
    v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
    v_rgbM = vec2(fragCoord * inverseVP);
}

void main(void) {

   gl_Position = filterVertexPosition();

   vFragCoord = aVertexPosition * outputFrame.zw;

   texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
}
`;
class fC extends Je {
  constructor() {
    super(dC, uC);
  }
}
var pC = `precision highp float;

varying vec2 vTextureCoord;
varying vec4 vColor;

uniform float uNoise;
uniform float uSeed;
uniform sampler2D uSampler;

float rand(vec2 co)
{
    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}

void main()
{
    vec4 color = texture2D(uSampler, vTextureCoord);
    float randomValue = rand(gl_FragCoord.xy * uSeed);
    float diff = (randomValue - 0.5) * uNoise;

    // Un-premultiply alpha before applying the color matrix. See issue #3539.
    if (color.a > 0.0) {
        color.rgb /= color.a;
    }

    color.r += diff;
    color.g += diff;
    color.b += diff;

    // Premultiply alpha again.
    color.rgb *= color.a;

    gl_FragColor = color;
}
`;
class _C extends Je {
  /**
   * @param {number} [noise=0.5] - The noise intensity, should be a normalized value in the range [0, 1].
   * @param {number} [seed] - A random seed for the noise generation. Default is `Math.random()`.
   */
  constructor(e = 0.5, t = Math.random()) {
    super(e0, pC, {
      uNoise: 0,
      uSeed: 0
    }), this.noise = e, this.seed = t;
  }
  /**
   * The amount of noise to apply, this value should be in the range (0, 1].
   * @default 0.5
   */
  get noise() {
    return this.uniforms.uNoise;
  }
  set noise(e) {
    this.uniforms.uNoise = e;
  }
  /** A seed value to apply to the random noise generation. `Math.random()` is a good value to use. */
  get seed() {
    return this.uniforms.uSeed;
  }
  set seed(e) {
    this.uniforms.uSeed = e;
  }
}
const Of = {
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.AlphaFilter
   */
  AlphaFilter: eC,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.BlurFilter
   */
  BlurFilter: oC,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.BlurFilterPass
   */
  BlurFilterPass: gc,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.ColorMatrixFilter
   */
  ColorMatrixFilter: yc,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.DisplacementFilter
   */
  DisplacementFilter: cC,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.FXAAFilter
   */
  FXAAFilter: fC,
  /**
   * @class
   * @memberof PIXI.filters
   * @deprecated since 7.1.0
   * @see PIXI.NoiseFilter
   */
  NoiseFilter: _C
};
Object.entries(Of).forEach(([r, e]) => {
  Object.defineProperty(Of, r, {
    get() {
      return fe("7.1.0", `filters.${r} has moved to ${r}`), e;
    }
  });
});
class mC {
  constructor() {
    this.interactionFrequency = 10, this._deltaTime = 0, this._didMove = !1, this.tickerAdded = !1, this._pauseUpdate = !0;
  }
  /**
   * Initializes the event ticker.
   * @param events - The event system.
   */
  init(e) {
    this.removeTickerListener(), this.events = e, this.interactionFrequency = 10, this._deltaTime = 0, this._didMove = !1, this.tickerAdded = !1, this._pauseUpdate = !0;
  }
  /** Whether to pause the update checks or not. */
  get pauseUpdate() {
    return this._pauseUpdate;
  }
  set pauseUpdate(e) {
    this._pauseUpdate = e;
  }
  /** Adds the ticker listener. */
  addTickerListener() {
    this.tickerAdded || !this.domElement || (bt.system.add(this.tickerUpdate, this, zr.INTERACTION), this.tickerAdded = !0);
  }
  /** Removes the ticker listener. */
  removeTickerListener() {
    this.tickerAdded && (bt.system.remove(this.tickerUpdate, this), this.tickerAdded = !1);
  }
  /** Sets flag to not fire extra events when the user has already moved there mouse */
  pointerMoved() {
    this._didMove = !0;
  }
  /** Updates the state of interactive objects. */
  update() {
    if (!this.domElement || this._pauseUpdate)
      return;
    if (this._didMove) {
      this._didMove = !1;
      return;
    }
    const e = this.events.rootPointerEvent;
    this.events.supportsTouchEvents && e.pointerType === "touch" || globalThis.document.dispatchEvent(new PointerEvent("pointermove", {
      clientX: e.clientX,
      clientY: e.clientY
    }));
  }
  /**
   * Updates the state of interactive objects if at least {@link PIXI.EventsTicker#interactionFrequency}
   * milliseconds have passed since the last invocation.
   *
   * Invoked by a throttled ticker update from {@link PIXI.Ticker.system}.
   * @param deltaTime - time delta since the last call
   */
  tickerUpdate(e) {
    this._deltaTime += e, !(this._deltaTime < this.interactionFrequency) && (this._deltaTime = 0, this.update());
  }
}
const qi = new mC();
class Ns {
  /**
   * @param manager - The event boundary which manages this event. Propagation can only occur
   *  within the boundary's jurisdiction.
   */
  constructor(e) {
    this.bubbles = !0, this.cancelBubble = !0, this.cancelable = !1, this.composed = !1, this.defaultPrevented = !1, this.eventPhase = Ns.prototype.NONE, this.propagationStopped = !1, this.propagationImmediatelyStopped = !1, this.layer = new ge(), this.page = new ge(), this.NONE = 0, this.CAPTURING_PHASE = 1, this.AT_TARGET = 2, this.BUBBLING_PHASE = 3, this.manager = e;
  }
  /** @readonly */
  get layerX() {
    return this.layer.x;
  }
  /** @readonly */
  get layerY() {
    return this.layer.y;
  }
  /** @readonly */
  get pageX() {
    return this.page.x;
  }
  /** @readonly */
  get pageY() {
    return this.page.y;
  }
  /**
   * Fallback for the deprecated @code{PIXI.InteractionEvent.data}.
   * @deprecated since 7.0.0
   */
  get data() {
    return this;
  }
  /** The propagation path for this event. Alias for {@link PIXI.EventBoundary.propagationPath}. */
  composedPath() {
    return this.manager && (!this.path || this.path[this.path.length - 1] !== this.target) && (this.path = this.target ? this.manager.propagationPath(this.target) : []), this.path;
  }
  /**
   * Unimplemented method included for implementing the DOM interface {@code Event}. It will throw an {@code Error}.
   * @deprecated
   * @param _type
   * @param _bubbles
   * @param _cancelable
   */
  initEvent(e, t, i) {
    throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
  }
  /**
   * Unimplemented method included for implementing the DOM interface {@code UIEvent}. It will throw an {@code Error}.
   * @deprecated
   * @param _typeArg
   * @param _bubblesArg
   * @param _cancelableArg
   * @param _viewArg
   * @param _detailArg
   */
  initUIEvent(e, t, i, n, s) {
    throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.");
  }
  /** Prevent default behavior of PixiJS and the user agent. */
  preventDefault() {
    this.nativeEvent instanceof Event && this.nativeEvent.cancelable && this.nativeEvent.preventDefault(), this.defaultPrevented = !0;
  }
  /**
   * Stop this event from propagating to any addition listeners, including on the
   * {@link PIXI.FederatedEventTarget.currentTarget currentTarget} and also the following
   * event targets on the propagation path.
   */
  stopImmediatePropagation() {
    this.propagationImmediatelyStopped = !0;
  }
  /**
   * Stop this event from propagating to the next {@link PIXI.FederatedEventTarget}. The rest of the listeners
   * on the {@link PIXI.FederatedEventTarget.currentTarget currentTarget} will still be notified.
   */
  stopPropagation() {
    this.propagationStopped = !0;
  }
}
class da extends Ns {
  constructor() {
    super(...arguments), this.client = new ge(), this.movement = new ge(), this.offset = new ge(), this.global = new ge(), this.screen = new ge();
  }
  /** @readonly */
  get clientX() {
    return this.client.x;
  }
  /** @readonly */
  get clientY() {
    return this.client.y;
  }
  /**
   * Alias for {@link PIXI.FederatedMouseEvent.clientX this.clientX}.
   * @readonly
   */
  get x() {
    return this.clientX;
  }
  /**
   * Alias for {@link PIXI.FederatedMouseEvent.clientY this.clientY}.
   * @readonly
   */
  get y() {
    return this.clientY;
  }
  /** @readonly */
  get movementX() {
    return this.movement.x;
  }
  /** @readonly */
  get movementY() {
    return this.movement.y;
  }
  /** @readonly */
  get offsetX() {
    return this.offset.x;
  }
  /** @readonly */
  get offsetY() {
    return this.offset.y;
  }
  /** @readonly */
  get globalX() {
    return this.global.x;
  }
  /** @readonly */
  get globalY() {
    return this.global.y;
  }
  /**
   * The pointer coordinates in the renderer's screen. Alias for {@code screen.x}.
   * @readonly
   */
  get screenX() {
    return this.screen.x;
  }
  /**
   * The pointer coordinates in the renderer's screen. Alias for {@code screen.y}.
   * @readonly
   */
  get screenY() {
    return this.screen.y;
  }
  /**
   * This will return the local coordinates of the specified displayObject for this InteractionData
   * @param {PIXI.DisplayObject} displayObject - The DisplayObject that you would like the local
   *  coords off
   * @param {PIXI.IPointData} point - A Point object in which to store the value, optional (otherwise
   *  will create a new point)
   * @param {PIXI.IPointData} globalPos - A Point object containing your custom global coords, optional
   *  (otherwise will use the current global coords)
   * @returns - A point containing the coordinates of the InteractionData position relative
   *  to the DisplayObject
   */
  getLocalPosition(e, t, i) {
    return e.worldTransform.applyInverse(i || this.global, t);
  }
  /**
   * Whether the modifier key was pressed when this event natively occurred.
   * @param key - The modifier key.
   */
  getModifierState(e) {
    return "getModifierState" in this.nativeEvent && this.nativeEvent.getModifierState(e);
  }
  /**
   * Not supported.
   * @param _typeArg
   * @param _canBubbleArg
   * @param _cancelableArg
   * @param _viewArg
   * @param _detailArg
   * @param _screenXArg
   * @param _screenYArg
   * @param _clientXArg
   * @param _clientYArg
   * @param _ctrlKeyArg
   * @param _altKeyArg
   * @param _shiftKeyArg
   * @param _metaKeyArg
   * @param _buttonArg
   * @param _relatedTargetArg
   * @deprecated since 7.0.0
   */
  // eslint-disable-next-line max-params
  initMouseEvent(e, t, i, n, s, o, a, l, h, c, u, d, f, p, _) {
    throw new Error("Method not implemented.");
  }
}
class Xt extends da {
  constructor() {
    super(...arguments), this.width = 0, this.height = 0, this.isPrimary = !1;
  }
  // Only included for completeness for now
  getCoalescedEvents() {
    return this.type === "pointermove" || this.type === "mousemove" || this.type === "touchmove" ? [this] : [];
  }
  // Only included for completeness for now
  getPredictedEvents() {
    throw new Error("getPredictedEvents is not supported!");
  }
}
class Rn extends da {
  constructor() {
    super(...arguments), this.DOM_DELTA_PIXEL = 0, this.DOM_DELTA_LINE = 1, this.DOM_DELTA_PAGE = 2;
  }
}
Rn.DOM_DELTA_PIXEL = 0, /** Units specified in lines. */
Rn.DOM_DELTA_LINE = 1, /** Units specified in pages. */
Rn.DOM_DELTA_PAGE = 2;
const gC = 2048, yC = new ge(), th = new ge();
class vC {
  /**
   * @param rootTarget - The holder of the event boundary.
   */
  constructor(e) {
    this.dispatch = new Fs(), this.moveOnAll = !1, this.enableGlobalMoveEvents = !0, this.mappingState = {
      trackingData: {}
    }, this.eventPool = /* @__PURE__ */ new Map(), this._allInteractiveElements = [], this._hitElements = [], this._isPointerMoveEvent = !1, this.rootTarget = e, this.hitPruneFn = this.hitPruneFn.bind(this), this.hitTestFn = this.hitTestFn.bind(this), this.mapPointerDown = this.mapPointerDown.bind(this), this.mapPointerMove = this.mapPointerMove.bind(this), this.mapPointerOut = this.mapPointerOut.bind(this), this.mapPointerOver = this.mapPointerOver.bind(this), this.mapPointerUp = this.mapPointerUp.bind(this), this.mapPointerUpOutside = this.mapPointerUpOutside.bind(this), this.mapWheel = this.mapWheel.bind(this), this.mappingTable = {}, this.addEventMapping("pointerdown", this.mapPointerDown), this.addEventMapping("pointermove", this.mapPointerMove), this.addEventMapping("pointerout", this.mapPointerOut), this.addEventMapping("pointerleave", this.mapPointerOut), this.addEventMapping("pointerover", this.mapPointerOver), this.addEventMapping("pointerup", this.mapPointerUp), this.addEventMapping("pointerupoutside", this.mapPointerUpOutside), this.addEventMapping("wheel", this.mapWheel);
  }
  /**
   * Adds an event mapping for the event `type` handled by `fn`.
   *
   * Event mappings can be used to implement additional or custom events. They take an event
   * coming from the upstream scene (or directly from the {@link PIXI.EventSystem}) and dispatch new downstream events
   * generally trickling down and bubbling up to {@link PIXI.EventBoundary.rootTarget this.rootTarget}.
   *
   * To modify the semantics of existing events, the built-in mapping methods of EventBoundary should be overridden
   * instead.
   * @param type - The type of upstream event to map.
   * @param fn - The mapping method. The context of this function must be bound manually, if desired.
   */
  addEventMapping(e, t) {
    this.mappingTable[e] || (this.mappingTable[e] = []), this.mappingTable[e].push({
      fn: t,
      priority: 0
    }), this.mappingTable[e].sort((i, n) => i.priority - n.priority);
  }
  /**
   * Dispatches the given event
   * @param e
   * @param type
   */
  dispatchEvent(e, t) {
    e.propagationStopped = !1, e.propagationImmediatelyStopped = !1, this.propagate(e, t), this.dispatch.emit(t || e.type, e);
  }
  /**
   * Maps the given upstream event through the event boundary and propagates it downstream.
   * @param e
   */
  mapEvent(e) {
    if (!this.rootTarget)
      return;
    const t = this.mappingTable[e.type];
    if (t)
      for (let i = 0, n = t.length; i < n; i++)
        t[i].fn(e);
    else
      console.warn(`[EventBoundary]: Event mapping not defined for ${e.type}`);
  }
  /**
   * Finds the DisplayObject that is the target of a event at the given coordinates.
   *
   * The passed (x,y) coordinates are in the world space above this event boundary.
   * @param x
   * @param y
   */
  hitTest(e, t) {
    qi.pauseUpdate = !0;
    const i = this._isPointerMoveEvent && this.enableGlobalMoveEvents ? "hitTestMoveRecursive" : "hitTestRecursive", n = this[i](
      this.rootTarget,
      this.rootTarget.eventMode,
      yC.set(e, t),
      this.hitTestFn,
      this.hitPruneFn
    );
    return n && n[0];
  }
  /**
   * Propagate the passed event from from {@link PIXI.EventBoundary.rootTarget this.rootTarget} to its
   * target {@code e.target}.
   * @param e - The event to propagate.
   * @param type
   */
  propagate(e, t) {
    if (!e.target)
      return;
    const i = e.composedPath();
    e.eventPhase = e.CAPTURING_PHASE;
    for (let n = 0, s = i.length - 1; n < s; n++)
      if (e.currentTarget = i[n], this.notifyTarget(e, t), e.propagationStopped || e.propagationImmediatelyStopped)
        return;
    if (e.eventPhase = e.AT_TARGET, e.currentTarget = e.target, this.notifyTarget(e, t), !(e.propagationStopped || e.propagationImmediatelyStopped)) {
      e.eventPhase = e.BUBBLING_PHASE;
      for (let n = i.length - 2; n >= 0; n--)
        if (e.currentTarget = i[n], this.notifyTarget(e, t), e.propagationStopped || e.propagationImmediatelyStopped)
          return;
    }
  }
  /**
   * Emits the event {@code e} to all interactive display objects. The event is propagated in the bubbling phase always.
   *
   * This is used in the `globalpointermove` event.
   * @param e - The emitted event.
   * @param type - The listeners to notify.
   * @param targets - The targets to notify.
   */
  all(e, t, i = this._allInteractiveElements) {
    if (i.length === 0)
      return;
    e.eventPhase = e.BUBBLING_PHASE;
    const n = Array.isArray(t) ? t : [t];
    for (let s = i.length - 1; s >= 0; s--)
      n.forEach((o) => {
        e.currentTarget = i[s], this.notifyTarget(e, o);
      });
  }
  /**
   * Finds the propagation path from {@link PIXI.EventBoundary.rootTarget rootTarget} to the passed
   * {@code target}. The last element in the path is {@code target}.
   * @param target
   */
  propagationPath(e) {
    const t = [e];
    for (let i = 0; i < gC && e !== this.rootTarget; i++) {
      if (!e.parent)
        throw new Error("Cannot find propagation path to disconnected target");
      t.push(e.parent), e = e.parent;
    }
    return t.reverse(), t;
  }
  hitTestMoveRecursive(e, t, i, n, s, o = !1) {
    let a = !1;
    if (this._interactivePrune(e))
      return null;
    if ((e.eventMode === "dynamic" || t === "dynamic") && (qi.pauseUpdate = !1), e.interactiveChildren && e.children) {
      const c = e.children;
      for (let u = c.length - 1; u >= 0; u--) {
        const d = c[u], f = this.hitTestMoveRecursive(
          d,
          this._isInteractive(t) ? t : d.eventMode,
          i,
          n,
          s,
          o || s(e, i)
        );
        if (f) {
          if (f.length > 0 && !f[f.length - 1].parent)
            continue;
          const p = e.isInteractive();
          (f.length > 0 || p) && (p && this._allInteractiveElements.push(e), f.push(e)), this._hitElements.length === 0 && (this._hitElements = f), a = !0;
        }
      }
    }
    const l = this._isInteractive(t), h = e.isInteractive();
    return l && h && this._allInteractiveElements.push(e), o || this._hitElements.length > 0 ? null : a ? this._hitElements : l && !s(e, i) && n(e, i) ? h ? [e] : [] : null;
  }
  /**
   * Recursive implementation for {@link PIXI.EventBoundary.hitTest hitTest}.
   * @param currentTarget - The DisplayObject that is to be hit tested.
   * @param eventMode - The event mode for the `currentTarget` or one of its parents.
   * @param location - The location that is being tested for overlap.
   * @param testFn - Callback that determines whether the target passes hit testing. This callback
   *  can assume that `pruneFn` failed to prune the display object.
   * @param pruneFn - Callback that determiness whether the target and all of its children
   *  cannot pass the hit test. It is used as a preliminary optimization to prune entire subtrees
   *  of the scene graph.
   * @returns An array holding the hit testing target and all its ancestors in order. The first element
   *  is the target itself and the last is {@link PIXI.EventBoundary.rootTarget rootTarget}. This is the opposite
   *  order w.r.t. the propagation path. If no hit testing target is found, null is returned.
   */
  hitTestRecursive(e, t, i, n, s) {
    if (this._interactivePrune(e) || s(e, i))
      return null;
    if ((e.eventMode === "dynamic" || t === "dynamic") && (qi.pauseUpdate = !1), e.interactiveChildren && e.children) {
      const l = e.children;
      for (let h = l.length - 1; h >= 0; h--) {
        const c = l[h], u = this.hitTestRecursive(
          c,
          this._isInteractive(t) ? t : c.eventMode,
          i,
          n,
          s
        );
        if (u) {
          if (u.length > 0 && !u[u.length - 1].parent)
            continue;
          const d = e.isInteractive();
          return (u.length > 0 || d) && u.push(e), u;
        }
      }
    }
    const o = this._isInteractive(t), a = e.isInteractive();
    return o && n(e, i) ? a ? [e] : [] : null;
  }
  _isInteractive(e) {
    return e === "static" || e === "dynamic";
  }
  _interactivePrune(e) {
    return !!(!e || e.isMask || !e.visible || !e.renderable || e.eventMode === "none" || e.eventMode === "passive" && !e.interactiveChildren || e.isMask);
  }
  /**
   * Checks whether the display object or any of its children cannot pass the hit test at all.
   *
   * {@link PIXI.EventBoundary}'s implementation uses the {@link PIXI.DisplayObject.hitArea hitArea}
   * and {@link PIXI.DisplayObject._mask} for pruning.
   * @param displayObject
   * @param location
   */
  hitPruneFn(e, t) {
    var i;
    if (e.hitArea && (e.worldTransform.applyInverse(t, th), !e.hitArea.contains(th.x, th.y)))
      return !0;
    if (e._mask) {
      const n = e._mask.isMaskData ? e._mask.maskObject : e._mask;
      if (n && !((i = n.containsPoint) != null && i.call(n, t)))
        return !0;
    }
    return !1;
  }
  /**
   * Checks whether the display object passes hit testing for the given location.
   * @param displayObject
   * @param location
   * @returns - Whether `displayObject` passes hit testing for `location`.
   */
  hitTestFn(e, t) {
    return e.eventMode === "passive" ? !1 : e.hitArea ? !0 : e.containsPoint ? e.containsPoint(t) : !1;
  }
  /**
   * Notify all the listeners to the event's `currentTarget`.
   *
   * If the `currentTarget` contains the property `on<type>`, then it is called here,
   * simulating the behavior from version 6.x and prior.
   * @param e - The event passed to the target.
   * @param type
   */
  notifyTarget(e, t) {
    var s, o;
    t = t ?? e.type;
    const i = `on${t}`;
    (o = (s = e.currentTarget)[i]) == null || o.call(s, e);
    const n = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? `${t}capture` : t;
    this.notifyListeners(e, n), e.eventPhase === e.AT_TARGET && this.notifyListeners(e, t);
  }
  /**
   * Maps the upstream `pointerdown` events to a downstream `pointerdown` event.
   *
   * `touchstart`, `rightdown`, `mousedown` events are also dispatched for specific pointer types.
   * @param from
   */
  mapPointerDown(e) {
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    const t = this.createPointerEvent(e);
    if (this.dispatchEvent(t, "pointerdown"), t.pointerType === "touch")
      this.dispatchEvent(t, "touchstart");
    else if (t.pointerType === "mouse" || t.pointerType === "pen") {
      const n = t.button === 2;
      this.dispatchEvent(t, n ? "rightdown" : "mousedown");
    }
    const i = this.trackingData(e.pointerId);
    i.pressTargetsByButton[e.button] = t.composedPath(), this.freeEvent(t);
  }
  /**
   * Maps the upstream `pointermove` to downstream `pointerout`, `pointerover`, and `pointermove` events, in that order.
   *
   * The tracking data for the specific pointer has an updated `overTarget`. `mouseout`, `mouseover`,
   * `mousemove`, and `touchmove` events are fired as well for specific pointer types.
   * @param from - The upstream `pointermove` event.
   */
  mapPointerMove(e) {
    var l, h;
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    this._allInteractiveElements.length = 0, this._hitElements.length = 0, this._isPointerMoveEvent = !0;
    const t = this.createPointerEvent(e);
    this._isPointerMoveEvent = !1;
    const i = t.pointerType === "mouse" || t.pointerType === "pen", n = this.trackingData(e.pointerId), s = this.findMountedTarget(n.overTargets);
    if (((l = n.overTargets) == null ? void 0 : l.length) > 0 && s !== t.target) {
      const c = e.type === "mousemove" ? "mouseout" : "pointerout", u = this.createPointerEvent(e, c, s);
      if (this.dispatchEvent(u, "pointerout"), i && this.dispatchEvent(u, "mouseout"), !t.composedPath().includes(s)) {
        const d = this.createPointerEvent(e, "pointerleave", s);
        for (d.eventPhase = d.AT_TARGET; d.target && !t.composedPath().includes(d.target); )
          d.currentTarget = d.target, this.notifyTarget(d), i && this.notifyTarget(d, "mouseleave"), d.target = d.target.parent;
        this.freeEvent(d);
      }
      this.freeEvent(u);
    }
    if (s !== t.target) {
      const c = e.type === "mousemove" ? "mouseover" : "pointerover", u = this.clonePointerEvent(t, c);
      this.dispatchEvent(u, "pointerover"), i && this.dispatchEvent(u, "mouseover");
      let d = s == null ? void 0 : s.parent;
      for (; d && d !== this.rootTarget.parent && d !== t.target; )
        d = d.parent;
      if (!d || d === this.rootTarget.parent) {
        const f = this.clonePointerEvent(t, "pointerenter");
        for (f.eventPhase = f.AT_TARGET; f.target && f.target !== s && f.target !== this.rootTarget.parent; )
          f.currentTarget = f.target, this.notifyTarget(f), i && this.notifyTarget(f, "mouseenter"), f.target = f.target.parent;
        this.freeEvent(f);
      }
      this.freeEvent(u);
    }
    const o = [], a = this.enableGlobalMoveEvents ?? !0;
    this.moveOnAll ? o.push("pointermove") : this.dispatchEvent(t, "pointermove"), a && o.push("globalpointermove"), t.pointerType === "touch" && (this.moveOnAll ? o.splice(1, 0, "touchmove") : this.dispatchEvent(t, "touchmove"), a && o.push("globaltouchmove")), i && (this.moveOnAll ? o.splice(1, 0, "mousemove") : this.dispatchEvent(t, "mousemove"), a && o.push("globalmousemove"), this.cursor = (h = t.target) == null ? void 0 : h.cursor), o.length > 0 && this.all(t, o), this._allInteractiveElements.length = 0, this._hitElements.length = 0, n.overTargets = t.composedPath(), this.freeEvent(t);
  }
  /**
   * Maps the upstream `pointerover` to downstream `pointerover` and `pointerenter` events, in that order.
   *
   * The tracking data for the specific pointer gets a new `overTarget`.
   * @param from - The upstream `pointerover` event.
   */
  mapPointerOver(e) {
    var o;
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    const t = this.trackingData(e.pointerId), i = this.createPointerEvent(e), n = i.pointerType === "mouse" || i.pointerType === "pen";
    this.dispatchEvent(i, "pointerover"), n && this.dispatchEvent(i, "mouseover"), i.pointerType === "mouse" && (this.cursor = (o = i.target) == null ? void 0 : o.cursor);
    const s = this.clonePointerEvent(i, "pointerenter");
    for (s.eventPhase = s.AT_TARGET; s.target && s.target !== this.rootTarget.parent; )
      s.currentTarget = s.target, this.notifyTarget(s), n && this.notifyTarget(s, "mouseenter"), s.target = s.target.parent;
    t.overTargets = i.composedPath(), this.freeEvent(i), this.freeEvent(s);
  }
  /**
   * Maps the upstream `pointerout` to downstream `pointerout`, `pointerleave` events, in that order.
   *
   * The tracking data for the specific pointer is cleared of a `overTarget`.
   * @param from - The upstream `pointerout` event.
   */
  mapPointerOut(e) {
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    const t = this.trackingData(e.pointerId);
    if (t.overTargets) {
      const i = e.pointerType === "mouse" || e.pointerType === "pen", n = this.findMountedTarget(t.overTargets), s = this.createPointerEvent(e, "pointerout", n);
      this.dispatchEvent(s), i && this.dispatchEvent(s, "mouseout");
      const o = this.createPointerEvent(e, "pointerleave", n);
      for (o.eventPhase = o.AT_TARGET; o.target && o.target !== this.rootTarget.parent; )
        o.currentTarget = o.target, this.notifyTarget(o), i && this.notifyTarget(o, "mouseleave"), o.target = o.target.parent;
      t.overTargets = null, this.freeEvent(s), this.freeEvent(o);
    }
    this.cursor = null;
  }
  /**
   * Maps the upstream `pointerup` event to downstream `pointerup`, `pointerupoutside`,
   * and `click`/`rightclick`/`pointertap` events, in that order.
   *
   * The `pointerupoutside` event bubbles from the original `pointerdown` target to the most specific
   * ancestor of the `pointerdown` and `pointerup` targets, which is also the `click` event's target. `touchend`,
   * `rightup`, `mouseup`, `touchendoutside`, `rightupoutside`, `mouseupoutside`, and `tap` are fired as well for
   * specific pointer types.
   * @param from - The upstream `pointerup` event.
   */
  mapPointerUp(e) {
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    const t = performance.now(), i = this.createPointerEvent(e);
    if (this.dispatchEvent(i, "pointerup"), i.pointerType === "touch")
      this.dispatchEvent(i, "touchend");
    else if (i.pointerType === "mouse" || i.pointerType === "pen") {
      const a = i.button === 2;
      this.dispatchEvent(i, a ? "rightup" : "mouseup");
    }
    const n = this.trackingData(e.pointerId), s = this.findMountedTarget(n.pressTargetsByButton[e.button]);
    let o = s;
    if (s && !i.composedPath().includes(s)) {
      let a = s;
      for (; a && !i.composedPath().includes(a); ) {
        if (i.currentTarget = a, this.notifyTarget(i, "pointerupoutside"), i.pointerType === "touch")
          this.notifyTarget(i, "touchendoutside");
        else if (i.pointerType === "mouse" || i.pointerType === "pen") {
          const l = i.button === 2;
          this.notifyTarget(i, l ? "rightupoutside" : "mouseupoutside");
        }
        a = a.parent;
      }
      delete n.pressTargetsByButton[e.button], o = a;
    }
    if (o) {
      const a = this.clonePointerEvent(i, "click");
      a.target = o, a.path = null, n.clicksByButton[e.button] || (n.clicksByButton[e.button] = {
        clickCount: 0,
        target: a.target,
        timeStamp: t
      });
      const l = n.clicksByButton[e.button];
      if (l.target === a.target && t - l.timeStamp < 200 ? ++l.clickCount : l.clickCount = 1, l.target = a.target, l.timeStamp = t, a.detail = l.clickCount, a.pointerType === "mouse") {
        const h = a.button === 2;
        this.dispatchEvent(a, h ? "rightclick" : "click");
      } else
        a.pointerType === "touch" && this.dispatchEvent(a, "tap");
      this.dispatchEvent(a, "pointertap"), this.freeEvent(a);
    }
    this.freeEvent(i);
  }
  /**
   * Maps the upstream `pointerupoutside` event to a downstream `pointerupoutside` event, bubbling from the original
   * `pointerdown` target to `rootTarget`.
   *
   * (The most specific ancestor of the `pointerdown` event and the `pointerup` event must the
   * `{@link PIXI.EventBoundary}'s root because the `pointerup` event occurred outside of the boundary.)
   *
   * `touchendoutside`, `mouseupoutside`, and `rightupoutside` events are fired as well for specific pointer
   * types. The tracking data for the specific pointer is cleared of a `pressTarget`.
   * @param from - The upstream `pointerupoutside` event.
   */
  mapPointerUpOutside(e) {
    if (!(e instanceof Xt)) {
      console.warn("EventBoundary cannot map a non-pointer event as a pointer event");
      return;
    }
    const t = this.trackingData(e.pointerId), i = this.findMountedTarget(t.pressTargetsByButton[e.button]), n = this.createPointerEvent(e);
    if (i) {
      let s = i;
      for (; s; )
        n.currentTarget = s, this.notifyTarget(n, "pointerupoutside"), n.pointerType === "touch" ? this.notifyTarget(n, "touchendoutside") : (n.pointerType === "mouse" || n.pointerType === "pen") && this.notifyTarget(n, n.button === 2 ? "rightupoutside" : "mouseupoutside"), s = s.parent;
      delete t.pressTargetsByButton[e.button];
    }
    this.freeEvent(n);
  }
  /**
   * Maps the upstream `wheel` event to a downstream `wheel` event.
   * @param from - The upstream `wheel` event.
   */
  mapWheel(e) {
    if (!(e instanceof Rn)) {
      console.warn("EventBoundary cannot map a non-wheel event as a wheel event");
      return;
    }
    const t = this.createWheelEvent(e);
    this.dispatchEvent(t), this.freeEvent(t);
  }
  /**
   * Finds the most specific event-target in the given propagation path that is still mounted in the scene graph.
   *
   * This is used to find the correct `pointerup` and `pointerout` target in the case that the original `pointerdown`
   * or `pointerover` target was unmounted from the scene graph.
   * @param propagationPath - The propagation path was valid in the past.
   * @returns - The most specific event-target still mounted at the same location in the scene graph.
   */
  findMountedTarget(e) {
    if (!e)
      return null;
    let t = e[0];
    for (let i = 1; i < e.length && e[i].parent === t; i++)
      t = e[i];
    return t;
  }
  /**
   * Creates an event whose {@code originalEvent} is {@code from}, with an optional `type` and `target` override.
   *
   * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
   * @param from - The {@code originalEvent} for the returned event.
   * @param [type=from.type] - The type of the returned event.
   * @param target - The target of the returned event.
   */
  createPointerEvent(e, t, i) {
    const n = this.allocateEvent(Xt);
    return this.copyPointerData(e, n), this.copyMouseData(e, n), this.copyData(e, n), n.nativeEvent = e.nativeEvent, n.originalEvent = e, n.target = i ?? this.hitTest(n.global.x, n.global.y) ?? this._hitElements[0], typeof t == "string" && (n.type = t), n;
  }
  /**
   * Creates a wheel event whose {@code originalEvent} is {@code from}.
   *
   * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
   * @param from - The upstream wheel event.
   */
  createWheelEvent(e) {
    const t = this.allocateEvent(Rn);
    return this.copyWheelData(e, t), this.copyMouseData(e, t), this.copyData(e, t), t.nativeEvent = e.nativeEvent, t.originalEvent = e, t.target = this.hitTest(t.global.x, t.global.y), t;
  }
  /**
   * Clones the event {@code from}, with an optional {@code type} override.
   *
   * The event is allocated using {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}.
   * @param from - The event to clone.
   * @param [type=from.type] - The type of the returned event.
   */
  clonePointerEvent(e, t) {
    const i = this.allocateEvent(Xt);
    return i.nativeEvent = e.nativeEvent, i.originalEvent = e.originalEvent, this.copyPointerData(e, i), this.copyMouseData(e, i), this.copyData(e, i), i.target = e.target, i.path = e.composedPath().slice(), i.type = t ?? i.type, i;
  }
  /**
   * Copies wheel {@link PIXI.FederatedWheelEvent} data from {@code from} into {@code to}.
   *
   * The following properties are copied:
   * + deltaMode
   * + deltaX
   * + deltaY
   * + deltaZ
   * @param from
   * @param to
   */
  copyWheelData(e, t) {
    t.deltaMode = e.deltaMode, t.deltaX = e.deltaX, t.deltaY = e.deltaY, t.deltaZ = e.deltaZ;
  }
  /**
   * Copies pointer {@link PIXI.FederatedPointerEvent} data from {@code from} into {@code to}.
   *
   * The following properties are copied:
   * + pointerId
   * + width
   * + height
   * + isPrimary
   * + pointerType
   * + pressure
   * + tangentialPressure
   * + tiltX
   * + tiltY
   * @param from
   * @param to
   */
  copyPointerData(e, t) {
    e instanceof Xt && t instanceof Xt && (t.pointerId = e.pointerId, t.width = e.width, t.height = e.height, t.isPrimary = e.isPrimary, t.pointerType = e.pointerType, t.pressure = e.pressure, t.tangentialPressure = e.tangentialPressure, t.tiltX = e.tiltX, t.tiltY = e.tiltY, t.twist = e.twist);
  }
  /**
   * Copies mouse {@link PIXI.FederatedMouseEvent} data from {@code from} to {@code to}.
   *
   * The following properties are copied:
   * + altKey
   * + button
   * + buttons
   * + clientX
   * + clientY
   * + metaKey
   * + movementX
   * + movementY
   * + pageX
   * + pageY
   * + x
   * + y
   * + screen
   * + shiftKey
   * + global
   * @param from
   * @param to
   */
  copyMouseData(e, t) {
    e instanceof da && t instanceof da && (t.altKey = e.altKey, t.button = e.button, t.buttons = e.buttons, t.client.copyFrom(e.client), t.ctrlKey = e.ctrlKey, t.metaKey = e.metaKey, t.movement.copyFrom(e.movement), t.screen.copyFrom(e.screen), t.shiftKey = e.shiftKey, t.global.copyFrom(e.global));
  }
  /**
   * Copies base {@link PIXI.FederatedEvent} data from {@code from} into {@code to}.
   *
   * The following properties are copied:
   * + isTrusted
   * + srcElement
   * + timeStamp
   * + type
   * @param from - The event to copy data from.
   * @param to - The event to copy data into.
   */
  copyData(e, t) {
    t.isTrusted = e.isTrusted, t.srcElement = e.srcElement, t.timeStamp = performance.now(), t.type = e.type, t.detail = e.detail, t.view = e.view, t.which = e.which, t.layer.copyFrom(e.layer), t.page.copyFrom(e.page);
  }
  /**
   * @param id - The pointer ID.
   * @returns The tracking data stored for the given pointer. If no data exists, a blank
   *  state will be created.
   */
  trackingData(e) {
    return this.mappingState.trackingData[e] || (this.mappingState.trackingData[e] = {
      pressTargetsByButton: {},
      clicksByButton: {},
      overTarget: null
    }), this.mappingState.trackingData[e];
  }
  /**
   * Allocate a specific type of event from {@link PIXI.EventBoundary#eventPool this.eventPool}.
   *
   * This allocation is constructor-agnostic, as long as it only takes one argument - this event
   * boundary.
   * @param constructor - The event's constructor.
   */
  allocateEvent(e) {
    this.eventPool.has(e) || this.eventPool.set(e, []);
    const t = this.eventPool.get(e).pop() || new e(this);
    return t.eventPhase = t.NONE, t.currentTarget = null, t.path = null, t.target = null, t;
  }
  /**
   * Frees the event and puts it back into the event pool.
   *
   * It is illegal to reuse the event until it is allocated again, using `this.allocateEvent`.
   *
   * It is also advised that events not allocated from {@link PIXI.EventBoundary#allocateEvent this.allocateEvent}
   * not be freed. This is because of the possibility that the same event is freed twice, which can cause
   * it to be allocated twice & result in overwriting.
   * @param event - The event to be freed.
   * @throws Error if the event is managed by another event boundary.
   */
  freeEvent(e) {
    if (e.manager !== this)
      throw new Error("It is illegal to free an event not managed by this EventBoundary!");
    const t = e.constructor;
    this.eventPool.has(t) || this.eventPool.set(t, []), this.eventPool.get(t).push(e);
  }
  /**
   * Similar to {@link PIXI.EventEmitter.emit}, except it stops if the `propagationImmediatelyStopped` flag
   * is set on the event.
   * @param e - The event to call each listener with.
   * @param type - The event key.
   */
  notifyListeners(e, t) {
    const i = e.currentTarget._events[t];
    if (i && e.currentTarget.isInteractive())
      if ("fn" in i)
        i.once && e.currentTarget.removeListener(t, i.fn, void 0, !0), i.fn.call(i.context, e);
      else
        for (let n = 0, s = i.length; n < s && !e.propagationImmediatelyStopped; n++)
          i[n].once && e.currentTarget.removeListener(t, i[n].fn, void 0, !0), i[n].fn.call(i[n].context, e);
  }
}
const bC = 1, wC = {
  touchstart: "pointerdown",
  touchend: "pointerup",
  touchendoutside: "pointerupoutside",
  touchmove: "pointermove",
  touchcancel: "pointercancel"
}, vc = class bc {
  /**
   * @param {PIXI.Renderer} renderer
   */
  constructor(e) {
    this.supportsTouchEvents = "ontouchstart" in globalThis, this.supportsPointerEvents = !!globalThis.PointerEvent, this.domElement = null, this.resolution = 1, this.renderer = e, this.rootBoundary = new vC(null), qi.init(this), this.autoPreventDefault = !0, this.eventsAdded = !1, this.rootPointerEvent = new Xt(null), this.rootWheelEvent = new Rn(null), this.cursorStyles = {
      default: "inherit",
      pointer: "pointer"
    }, this.features = new Proxy({ ...bc.defaultEventFeatures }, {
      set: (t, i, n) => (i === "globalMove" && (this.rootBoundary.enableGlobalMoveEvents = n), t[i] = n, !0)
    }), this.onPointerDown = this.onPointerDown.bind(this), this.onPointerMove = this.onPointerMove.bind(this), this.onPointerUp = this.onPointerUp.bind(this), this.onPointerOverOut = this.onPointerOverOut.bind(this), this.onWheel = this.onWheel.bind(this);
  }
  /**
   * The default interaction mode for all display objects.
   * @see PIXI.DisplayObject.eventMode
   * @type {PIXI.EventMode}
   * @readonly
   * @since 7.2.0
   */
  static get defaultEventMode() {
    return this._defaultEventMode;
  }
  /**
   * Runner init called, view is available at this point.
   * @ignore
   */
  init(e) {
    const { view: t, resolution: i } = this.renderer;
    this.setTargetElement(t), this.resolution = i, bc._defaultEventMode = e.eventMode ?? "auto", Object.assign(this.features, e.eventFeatures ?? {}), this.rootBoundary.enableGlobalMoveEvents = this.features.globalMove;
  }
  /**
   * Handle changing resolution.
   * @ignore
   */
  resolutionChange(e) {
    this.resolution = e;
  }
  /** Destroys all event listeners and detaches the renderer. */
  destroy() {
    this.setTargetElement(null), this.renderer = null;
  }
  /**
   * Sets the current cursor mode, handling any callbacks or CSS style changes.
   * @param mode - cursor mode, a key from the cursorStyles dictionary
   */
  setCursor(e) {
    e = e || "default";
    let t = !0;
    if (globalThis.OffscreenCanvas && this.domElement instanceof OffscreenCanvas && (t = !1), this.currentCursor === e)
      return;
    this.currentCursor = e;
    const i = this.cursorStyles[e];
    if (i)
      switch (typeof i) {
        case "string":
          t && (this.domElement.style.cursor = i);
          break;
        case "function":
          i(e);
          break;
        case "object":
          t && Object.assign(this.domElement.style, i);
          break;
      }
    else
      t && typeof e == "string" && !Object.prototype.hasOwnProperty.call(this.cursorStyles, e) && (this.domElement.style.cursor = e);
  }
  /**
   * The global pointer event.
   * Useful for getting the pointer position without listening to events.
   * @since 7.2.0
   */
  get pointer() {
    return this.rootPointerEvent;
  }
  /**
   * Event handler for pointer down events on {@link PIXI.EventSystem#domElement this.domElement}.
   * @param nativeEvent - The native mouse/pointer/touch event.
   */
  onPointerDown(e) {
    if (!this.features.click)
      return;
    this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
    const t = this.normalizeToPointerData(e);
    this.autoPreventDefault && t[0].isNormalized && (e.cancelable || !("cancelable" in e)) && e.preventDefault();
    for (let i = 0, n = t.length; i < n; i++) {
      const s = t[i], o = this.bootstrapEvent(this.rootPointerEvent, s);
      this.rootBoundary.mapEvent(o);
    }
    this.setCursor(this.rootBoundary.cursor);
  }
  /**
   * Event handler for pointer move events on on {@link PIXI.EventSystem#domElement this.domElement}.
   * @param nativeEvent - The native mouse/pointer/touch events.
   */
  onPointerMove(e) {
    if (!this.features.move)
      return;
    this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, qi.pointerMoved();
    const t = this.normalizeToPointerData(e);
    for (let i = 0, n = t.length; i < n; i++) {
      const s = this.bootstrapEvent(this.rootPointerEvent, t[i]);
      this.rootBoundary.mapEvent(s);
    }
    this.setCursor(this.rootBoundary.cursor);
  }
  /**
   * Event handler for pointer up events on {@link PIXI.EventSystem#domElement this.domElement}.
   * @param nativeEvent - The native mouse/pointer/touch event.
   */
  onPointerUp(e) {
    if (!this.features.click)
      return;
    this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
    let t = e.target;
    e.composedPath && e.composedPath().length > 0 && (t = e.composedPath()[0]);
    const i = t !== this.domElement ? "outside" : "", n = this.normalizeToPointerData(e);
    for (let s = 0, o = n.length; s < o; s++) {
      const a = this.bootstrapEvent(this.rootPointerEvent, n[s]);
      a.type += i, this.rootBoundary.mapEvent(a);
    }
    this.setCursor(this.rootBoundary.cursor);
  }
  /**
   * Event handler for pointer over & out events on {@link PIXI.EventSystem#domElement this.domElement}.
   * @param nativeEvent - The native mouse/pointer/touch event.
   */
  onPointerOverOut(e) {
    if (!this.features.click)
      return;
    this.rootBoundary.rootTarget = this.renderer.lastObjectRendered;
    const t = this.normalizeToPointerData(e);
    for (let i = 0, n = t.length; i < n; i++) {
      const s = this.bootstrapEvent(this.rootPointerEvent, t[i]);
      this.rootBoundary.mapEvent(s);
    }
    this.setCursor(this.rootBoundary.cursor);
  }
  /**
   * Passive handler for `wheel` events on {@link PIXI.EventSystem.domElement this.domElement}.
   * @param nativeEvent - The native wheel event.
   */
  onWheel(e) {
    if (!this.features.wheel)
      return;
    const t = this.normalizeWheelEvent(e);
    this.rootBoundary.rootTarget = this.renderer.lastObjectRendered, this.rootBoundary.mapEvent(t);
  }
  /**
   * Sets the {@link PIXI.EventSystem#domElement domElement} and binds event listeners.
   *
   * To deregister the current DOM element without setting a new one, pass {@code null}.
   * @param element - The new DOM element.
   */
  setTargetElement(e) {
    this.removeEvents(), this.domElement = e, qi.domElement = e, this.addEvents();
  }
  /** Register event listeners on {@link PIXI.Renderer#domElement this.domElement}. */
  addEvents() {
    if (this.eventsAdded || !this.domElement)
      return;
    qi.addTickerListener();
    const e = this.domElement.style;
    e && (globalThis.navigator.msPointerEnabled ? (e.msContentZooming = "none", e.msTouchAction = "none") : this.supportsPointerEvents && (e.touchAction = "none")), this.supportsPointerEvents ? (globalThis.document.addEventListener("pointermove", this.onPointerMove, !0), this.domElement.addEventListener("pointerdown", this.onPointerDown, !0), this.domElement.addEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.addEventListener("pointerover", this.onPointerOverOut, !0), globalThis.addEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.addEventListener("mousemove", this.onPointerMove, !0), this.domElement.addEventListener("mousedown", this.onPointerDown, !0), this.domElement.addEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.addEventListener("mouseover", this.onPointerOverOut, !0), globalThis.addEventListener("mouseup", this.onPointerUp, !0), this.supportsTouchEvents && (this.domElement.addEventListener("touchstart", this.onPointerDown, !0), this.domElement.addEventListener("touchend", this.onPointerUp, !0), this.domElement.addEventListener("touchmove", this.onPointerMove, !0))), this.domElement.addEventListener("wheel", this.onWheel, {
      passive: !0,
      capture: !0
    }), this.eventsAdded = !0;
  }
  /** Unregister event listeners on {@link PIXI.EventSystem#domElement this.domElement}. */
  removeEvents() {
    if (!this.eventsAdded || !this.domElement)
      return;
    qi.removeTickerListener();
    const e = this.domElement.style;
    globalThis.navigator.msPointerEnabled ? (e.msContentZooming = "", e.msTouchAction = "") : this.supportsPointerEvents && (e.touchAction = ""), this.supportsPointerEvents ? (globalThis.document.removeEventListener("pointermove", this.onPointerMove, !0), this.domElement.removeEventListener("pointerdown", this.onPointerDown, !0), this.domElement.removeEventListener("pointerleave", this.onPointerOverOut, !0), this.domElement.removeEventListener("pointerover", this.onPointerOverOut, !0), globalThis.removeEventListener("pointerup", this.onPointerUp, !0)) : (globalThis.document.removeEventListener("mousemove", this.onPointerMove, !0), this.domElement.removeEventListener("mousedown", this.onPointerDown, !0), this.domElement.removeEventListener("mouseout", this.onPointerOverOut, !0), this.domElement.removeEventListener("mouseover", this.onPointerOverOut, !0), globalThis.removeEventListener("mouseup", this.onPointerUp, !0), this.supportsTouchEvents && (this.domElement.removeEventListener("touchstart", this.onPointerDown, !0), this.domElement.removeEventListener("touchend", this.onPointerUp, !0), this.domElement.removeEventListener("touchmove", this.onPointerMove, !0))), this.domElement.removeEventListener("wheel", this.onWheel, !0), this.domElement = null, this.eventsAdded = !1;
  }
  /**
   * Maps x and y coords from a DOM object and maps them correctly to the PixiJS view. The
   * resulting value is stored in the point. This takes into account the fact that the DOM
   * element could be scaled and positioned anywhere on the screen.
   * @param  {PIXI.IPointData} point - the point that the result will be stored in
   * @param  {number} x - the x coord of the position to map
   * @param  {number} y - the y coord of the position to map
   */
  mapPositionToPoint(e, t, i) {
    const n = this.domElement.isConnected ? this.domElement.getBoundingClientRect() : {
      x: 0,
      y: 0,
      width: this.domElement.width,
      height: this.domElement.height,
      left: 0,
      top: 0
    }, s = 1 / this.resolution;
    e.x = (t - n.left) * (this.domElement.width / n.width) * s, e.y = (i - n.top) * (this.domElement.height / n.height) * s;
  }
  /**
   * Ensures that the original event object contains all data that a regular pointer event would have
   * @param event - The original event data from a touch or mouse event
   * @returns An array containing a single normalized pointer event, in the case of a pointer
   *  or mouse event, or a multiple normalized pointer events if there are multiple changed touches
   */
  normalizeToPointerData(e) {
    const t = [];
    if (this.supportsTouchEvents && e instanceof TouchEvent)
      for (let i = 0, n = e.changedTouches.length; i < n; i++) {
        const s = e.changedTouches[i];
        typeof s.button > "u" && (s.button = 0), typeof s.buttons > "u" && (s.buttons = 1), typeof s.isPrimary > "u" && (s.isPrimary = e.touches.length === 1 && e.type === "touchstart"), typeof s.width > "u" && (s.width = s.radiusX || 1), typeof s.height > "u" && (s.height = s.radiusY || 1), typeof s.tiltX > "u" && (s.tiltX = 0), typeof s.tiltY > "u" && (s.tiltY = 0), typeof s.pointerType > "u" && (s.pointerType = "touch"), typeof s.pointerId > "u" && (s.pointerId = s.identifier || 0), typeof s.pressure > "u" && (s.pressure = s.force || 0.5), typeof s.twist > "u" && (s.twist = 0), typeof s.tangentialPressure > "u" && (s.tangentialPressure = 0), typeof s.layerX > "u" && (s.layerX = s.offsetX = s.clientX), typeof s.layerY > "u" && (s.layerY = s.offsetY = s.clientY), s.isNormalized = !0, s.type = e.type, t.push(s);
      }
    else if (!globalThis.MouseEvent || e instanceof MouseEvent && (!this.supportsPointerEvents || !(e instanceof globalThis.PointerEvent))) {
      const i = e;
      typeof i.isPrimary > "u" && (i.isPrimary = !0), typeof i.width > "u" && (i.width = 1), typeof i.height > "u" && (i.height = 1), typeof i.tiltX > "u" && (i.tiltX = 0), typeof i.tiltY > "u" && (i.tiltY = 0), typeof i.pointerType > "u" && (i.pointerType = "mouse"), typeof i.pointerId > "u" && (i.pointerId = bC), typeof i.pressure > "u" && (i.pressure = 0.5), typeof i.twist > "u" && (i.twist = 0), typeof i.tangentialPressure > "u" && (i.tangentialPressure = 0), i.isNormalized = !0, t.push(i);
    } else
      t.push(e);
    return t;
  }
  /**
   * Normalizes the native {@link https://w3c.github.io/uievents/#interface-wheelevent WheelEvent}.
   *
   * The returned {@link PIXI.FederatedWheelEvent} is a shared instance. It will not persist across
   * multiple native wheel events.
   * @param nativeEvent - The native wheel event that occurred on the canvas.
   * @returns A federated wheel event.
   */
  normalizeWheelEvent(e) {
    const t = this.rootWheelEvent;
    return this.transferMouseData(t, e), t.deltaX = e.deltaX, t.deltaY = e.deltaY, t.deltaZ = e.deltaZ, t.deltaMode = e.deltaMode, this.mapPositionToPoint(t.screen, e.clientX, e.clientY), t.global.copyFrom(t.screen), t.offset.copyFrom(t.screen), t.nativeEvent = e, t.type = e.type, t;
  }
  /**
   * Normalizes the `nativeEvent` into a federateed {@link PIXI.FederatedPointerEvent}.
   * @param event
   * @param nativeEvent
   */
  bootstrapEvent(e, t) {
    return e.originalEvent = null, e.nativeEvent = t, e.pointerId = t.pointerId, e.width = t.width, e.height = t.height, e.isPrimary = t.isPrimary, e.pointerType = t.pointerType, e.pressure = t.pressure, e.tangentialPressure = t.tangentialPressure, e.tiltX = t.tiltX, e.tiltY = t.tiltY, e.twist = t.twist, this.transferMouseData(e, t), this.mapPositionToPoint(e.screen, t.clientX, t.clientY), e.global.copyFrom(e.screen), e.offset.copyFrom(e.screen), e.isTrusted = t.isTrusted, e.type === "pointerleave" && (e.type = "pointerout"), e.type.startsWith("mouse") && (e.type = e.type.replace("mouse", "pointer")), e.type.startsWith("touch") && (e.type = wC[e.type] || e.type), e;
  }
  /**
   * Transfers base & mouse event data from the {@code nativeEvent} to the federated event.
   * @param event
   * @param nativeEvent
   */
  transferMouseData(e, t) {
    e.isTrusted = t.isTrusted, e.srcElement = t.srcElement, e.timeStamp = performance.now(), e.type = t.type, e.altKey = t.altKey, e.button = t.button, e.buttons = t.buttons, e.client.x = t.clientX, e.client.y = t.clientY, e.ctrlKey = t.ctrlKey, e.metaKey = t.metaKey, e.movement.x = t.movementX, e.movement.y = t.movementY, e.page.x = t.pageX, e.page.y = t.pageY, e.relatedTarget = null, e.shiftKey = t.shiftKey;
  }
};
vc.extension = {
  name: "events",
  type: [
    q.RendererSystem,
    q.CanvasRendererSystem
  ]
}, /**
* The event features that are enabled by the EventSystem
* This option only is available when using **@pixi/events** package
* (included in the **pixi.js** and **pixi.js-legacy** bundle), otherwise it will be ignored.
* @since 7.2.0
*/
vc.defaultEventFeatures = {
  move: !0,
  globalMove: !0,
  click: !0,
  wheel: !0
};
let wc = vc;
Q.add(wc);
function Lf(r) {
  return r === "dynamic" || r === "static";
}
const xC = {
  /**
   * Property-based event handler for the `click` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onclick = (event) => {
   *  //some function here that happens on click
   * }
   */
  onclick: null,
  /**
   * Property-based event handler for the `mousedown` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmousedown = (event) => {
   *  //some function here that happens on mousedown
   * }
   */
  onmousedown: null,
  /**
   * Property-based event handler for the `mouseenter` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseenter = (event) => {
   *  //some function here that happens on mouseenter
   * }
   */
  onmouseenter: null,
  /**
   * Property-based event handler for the `mouseleave` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseleave = (event) => {
   *  //some function here that happens on mouseleave
   * }
   */
  onmouseleave: null,
  /**
   * Property-based event handler for the `mousemove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmousemove = (event) => {
   *  //some function here that happens on mousemove
   * }
   */
  onmousemove: null,
  /**
   * Property-based event handler for the `globalmousemove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onglobalmousemove = (event) => {
   *  //some function here that happens on globalmousemove
   * }
   */
  onglobalmousemove: null,
  /**
   * Property-based event handler for the `mouseout` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseout = (event) => {
   *  //some function here that happens on mouseout
   * }
   */
  onmouseout: null,
  /**
   * Property-based event handler for the `mouseover` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseover = (event) => {
   *  //some function here that happens on mouseover
   * }
   */
  onmouseover: null,
  /**
   * Property-based event handler for the `mouseup` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseup = (event) => {
   *  //some function here that happens on mouseup
   * }
   */
  onmouseup: null,
  /**
   * Property-based event handler for the `mouseupoutside` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onmouseupoutside = (event) => {
   *  //some function here that happens on mouseupoutside
   * }
   */
  onmouseupoutside: null,
  /**
   * Property-based event handler for the `pointercancel` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointercancel = (event) => {
   *  //some function here that happens on pointercancel
   * }
   */
  onpointercancel: null,
  /**
   * Property-based event handler for the `pointerdown` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerdown = (event) => {
   *  //some function here that happens on pointerdown
   * }
   */
  onpointerdown: null,
  /**
   * Property-based event handler for the `pointerenter` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerenter = (event) => {
   *  //some function here that happens on pointerenter
   * }
   */
  onpointerenter: null,
  /**
   * Property-based event handler for the `pointerleave` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerleave = (event) => {
   *  //some function here that happens on pointerleave
   * }
   */
  onpointerleave: null,
  /**
   * Property-based event handler for the `pointermove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointermove = (event) => {
   *  //some function here that happens on pointermove
   * }
   */
  onpointermove: null,
  /**
   * Property-based event handler for the `globalpointermove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onglobalpointermove = (event) => {
   *  //some function here that happens on globalpointermove
   * }
   */
  onglobalpointermove: null,
  /**
   * Property-based event handler for the `pointerout` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerout = (event) => {
   *  //some function here that happens on pointerout
   * }
   */
  onpointerout: null,
  /**
   * Property-based event handler for the `pointerover` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerover = (event) => {
   *  //some function here that happens on pointerover
   * }
   */
  onpointerover: null,
  /**
   * Property-based event handler for the `pointertap` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointertap = (event) => {
   *  //some function here that happens on pointertap
   * }
   */
  onpointertap: null,
  /**
   * Property-based event handler for the `pointerup` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerup = (event) => {
   *  //some function here that happens on pointerup
   * }
   */
  onpointerup: null,
  /**
   * Property-based event handler for the `pointerupoutside` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onpointerupoutside = (event) => {
   *  //some function here that happens on pointerupoutside
   * }
   */
  onpointerupoutside: null,
  /**
   * Property-based event handler for the `rightclick` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onrightclick = (event) => {
   *  //some function here that happens on rightclick
   * }
   */
  onrightclick: null,
  /**
   * Property-based event handler for the `rightdown` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onrightdown = (event) => {
   *  //some function here that happens on rightdown
   * }
   */
  onrightdown: null,
  /**
   * Property-based event handler for the `rightup` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onrightup = (event) => {
   *  //some function here that happens on rightup
   * }
   */
  onrightup: null,
  /**
   * Property-based event handler for the `rightupoutside` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onrightupoutside = (event) => {
   *  //some function here that happens on rightupoutside
   * }
   */
  onrightupoutside: null,
  /**
   * Property-based event handler for the `tap` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontap = (event) => {
   *  //some function here that happens on tap
   * }
   */
  ontap: null,
  /**
   * Property-based event handler for the `touchcancel` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontouchcancel = (event) => {
   *  //some function here that happens on touchcancel
   * }
   */
  ontouchcancel: null,
  /**
   * Property-based event handler for the `touchend` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontouchend = (event) => {
   *  //some function here that happens on touchend
   * }
   */
  ontouchend: null,
  /**
   * Property-based event handler for the `touchendoutside` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontouchendoutside = (event) => {
   *  //some function here that happens on touchendoutside
   * }
   */
  ontouchendoutside: null,
  /**
   * Property-based event handler for the `touchmove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontouchmove = (event) => {
   *  //some function here that happens on touchmove
   * }
   */
  ontouchmove: null,
  /**
   * Property-based event handler for the `globaltouchmove` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onglobaltouchmove = (event) => {
   *  //some function here that happens on globaltouchmove
   * }
   */
  onglobaltouchmove: null,
  /**
   * Property-based event handler for the `touchstart` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.ontouchstart = (event) => {
   *  //some function here that happens on touchstart
   * }
   */
  ontouchstart: null,
  /**
   * Property-based event handler for the `wheel` event.
   * @memberof PIXI.DisplayObject#
   * @default null
   * @example
   * this.onwheel = (event) => {
   *  //some function here that happens on wheel
   * }
   */
  onwheel: null,
  /**
   * @ignore
   */
  _internalInteractive: void 0,
  /**
   * Enable interaction events for the DisplayObject. Touch, pointer and mouse
   * @memberof PIXI.DisplayObject#
   */
  get interactive() {
    return this._internalInteractive ?? Lf(wc.defaultEventMode);
  },
  set interactive(r) {
    fe(
      "7.2.0",
      // eslint-disable-next-line max-len
      "Setting interactive is deprecated, use eventMode = 'none'/'passive'/'auto'/'static'/'dynamic' instead."
    ), this._internalInteractive = r, this.eventMode = r ? "static" : "auto";
  },
  /**
   * @ignore
   */
  _internalEventMode: void 0,
  /**
   * Enable interaction events for the DisplayObject. Touch, pointer and mouse.
   * This now replaces the `interactive` property.
   * There are 5 types of interaction settings:
   * - `'none'`: Ignores all interaction events, even on its children.
   * - `'passive'`: Does not emit events and ignores all hit testing on itself and non-interactive children.
   * Interactive children will still emit events.
   * - `'auto'`: Does not emit events but is hit tested if parent is interactive. Same as `interactive = false` in v7
   * - `'static'`: Emit events and is hit tested. Same as `interaction = true` in v7
   * - `'dynamic'`: Emits events and is hit tested but will also receive mock interaction events fired from a ticker to
   * allow for interaction when the mouse isn't moving
   * @example
   * import { Sprite } from 'pixi.js';
   *
   * const sprite = new Sprite(texture);
   * sprite.eventMode = 'static';
   * sprite.on('tap', (event) => {
   *     // Handle event
   * });
   * @memberof PIXI.DisplayObject#
   * @since 7.2.0
   */
  get eventMode() {
    return this._internalEventMode ?? wc.defaultEventMode;
  },
  set eventMode(r) {
    this._internalInteractive = Lf(r), this._internalEventMode = r;
  },
  /**
   * Determines if the displayObject is interactive or not
   * @returns {boolean} Whether the displayObject is interactive or not
   * @memberof PIXI.DisplayObject#
   * @since 7.2.0
   * @example
   * import { Sprite } from 'pixi.js';
   * const sprite = new Sprite(texture);
   * sprite.eventMode = 'static';
   * sprite.isInteractive(); // true
   *
   * sprite.eventMode = 'dynamic';
   * sprite.isInteractive(); // true
   *
   * sprite.eventMode = 'none';
   * sprite.isInteractive(); // false
   *
   * sprite.eventMode = 'passive';
   * sprite.isInteractive(); // false
   *
   * sprite.eventMode = 'auto';
   * sprite.isInteractive(); // false
   */
  isInteractive() {
    return this.eventMode === "static" || this.eventMode === "dynamic";
  },
  /**
   * Determines if the children to the displayObject can be clicked/touched
   * Setting this to false allows PixiJS to bypass a recursive `hitTest` function
   * @memberof PIXI.Container#
   */
  interactiveChildren: !0,
  /**
   * Interaction shape. Children will be hit first, then this shape will be checked.
   * Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds.
   * @example
   * import { Rectangle, Sprite } from 'pixi.js';
   *
   * const sprite = new Sprite(texture);
   * sprite.interactive = true;
   * sprite.hitArea = new Rectangle(0, 0, 100, 100);
   * @member {PIXI.IHitArea}
   * @memberof PIXI.DisplayObject#
   */
  hitArea: null,
  /**
   * Unlike `on` or `addListener` which are methods from EventEmitter, `addEventListener`
   * seeks to be compatible with the DOM's `addEventListener` with support for options.
   * **IMPORTANT:** _Only_ available if using the `@pixi/events` package.
   * @memberof PIXI.DisplayObject
   * @param type - The type of event to listen to.
   * @param listener - The listener callback or object.
   * @param options - Listener options, used for capture phase.
   * @example
   * // Tell the user whether they did a single, double, triple, or nth click.
   * button.addEventListener('click', {
   *     handleEvent(e): {
   *         let prefix;
   *
   *         switch (e.detail) {
   *             case 1: prefix = 'single'; break;
   *             case 2: prefix = 'double'; break;
   *             case 3: prefix = 'triple'; break;
   *             default: prefix = e.detail + 'th'; break;
   *         }
   *
   *         console.log('That was a ' + prefix + 'click');
   *     }
   * });
   *
   * // But skip the first click!
   * button.parent.addEventListener('click', function blockClickOnce(e) {
   *     e.stopImmediatePropagation();
   *     button.parent.removeEventListener('click', blockClickOnce, true);
   * }, {
   *     capture: true,
   * });
   */
  addEventListener(r, e, t) {
    const i = typeof t == "boolean" && t || typeof t == "object" && t.capture, n = typeof t == "object" ? t.signal : void 0, s = typeof t == "object" ? t.once === !0 : !1, o = typeof e == "function" ? void 0 : e;
    r = i ? `${r}capture` : r;
    const a = typeof e == "function" ? e : e.handleEvent, l = this;
    n && n.addEventListener("abort", () => {
      l.off(r, a, o);
    }), s ? l.once(r, a, o) : l.on(r, a, o);
  },
  /**
   * Unlike `off` or `removeListener` which are methods from EventEmitter, `removeEventListener`
   * seeks to be compatible with the DOM's `removeEventListener` with support for options.
   * **IMPORTANT:** _Only_ available if using the `@pixi/events` package.
   * @memberof PIXI.DisplayObject
   * @param type - The type of event the listener is bound to.
   * @param listener - The listener callback or object.
   * @param options - The original listener options. This is required to deregister a capture phase listener.
   */
  removeEventListener(r, e, t) {
    const i = typeof t == "boolean" && t || typeof t == "object" && t.capture, n = typeof e == "function" ? void 0 : e;
    r = i ? `${r}capture` : r, e = typeof e == "function" ? e : e.handleEvent, this.off(r, e, n);
  },
  /**
   * Dispatch the event on this {@link PIXI.DisplayObject} using the event's {@link PIXI.EventBoundary}.
   *
   * The target of the event is set to `this` and the `defaultPrevented` flag is cleared before dispatch.
   *
   * **IMPORTANT:** _Only_ available if using the `@pixi/events` package.
   * @memberof PIXI.DisplayObject
   * @param e - The event to dispatch.
   * @returns Whether the {@link PIXI.FederatedEvent.preventDefault preventDefault}() method was not invoked.
   * @example
   * // Reuse a click event!
   * button.dispatchEvent(clickEvent);
   */
  dispatchEvent(r) {
    if (!(r instanceof Ns))
      throw new Error("DisplayObject cannot propagate events outside of the Federated Events API");
    return r.defaultPrevented = !1, r.path = null, r.target = this, r.manager.dispatchEvent(r), !r.defaultPrevented;
  }
};
Pe.mixin(xC);
const EC = {
  /**
   *  Flag for if the object is accessible. If true AccessibilityManager will overlay a
   *   shadow div with attributes set
   * @member {boolean}
   * @memberof PIXI.DisplayObject#
   */
  accessible: !1,
  /**
   * Sets the title attribute of the shadow div
   * If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]'
   * @member {?string}
   * @memberof PIXI.DisplayObject#
   */
  accessibleTitle: null,
  /**
   * Sets the aria-label attribute of the shadow div
   * @member {string}
   * @memberof PIXI.DisplayObject#
   */
  accessibleHint: null,
  /**
   * @member {number}
   * @memberof PIXI.DisplayObject#
   * @private
   * @todo Needs docs.
   */
  tabIndex: 0,
  /**
   * @member {boolean}
   * @memberof PIXI.DisplayObject#
   * @todo Needs docs.
   */
  _accessibleActive: !1,
  /**
   * @member {boolean}
   * @memberof PIXI.DisplayObject#
   * @todo Needs docs.
   */
  _accessibleDiv: null,
  /**
   * Specify the type of div the accessible layer is. Screen readers treat the element differently
   * depending on this type. Defaults to button.
   * @member {string}
   * @memberof PIXI.DisplayObject#
   * @default 'button'
   */
  accessibleType: "button",
  /**
   * Specify the pointer-events the accessible div will use
   * Defaults to auto.
   * @member {string}
   * @memberof PIXI.DisplayObject#
   * @default 'auto'
   */
  accessiblePointerEvents: "auto",
  /**
   * Setting to false will prevent any children inside this container to
   * be accessible. Defaults to true.
   * @member {boolean}
   * @memberof PIXI.DisplayObject#
   * @default true
   */
  accessibleChildren: !0,
  renderId: -1
};
Pe.mixin(EC);
const TC = 9, co = 100, AC = 0, SC = 0, Nf = 2, Uf = 1, CC = -1e3, IC = -1e3, RC = 2;
class h0 {
  // 2fps
  /**
   * @param {PIXI.CanvasRenderer|PIXI.Renderer} renderer - A reference to the current renderer
   */
  constructor(e) {
    this.debug = !1, this._isActive = !1, this._isMobileAccessibility = !1, this.pool = [], this.renderId = 0, this.children = [], this.androidUpdateCount = 0, this.androidUpdateFrequency = 500, this._hookDiv = null, (Si.tablet || Si.phone) && this.createTouchHook();
    const t = document.createElement("div");
    t.style.width = `${co}px`, t.style.height = `${co}px`, t.style.position = "absolute", t.style.top = `${AC}px`, t.style.left = `${SC}px`, t.style.zIndex = Nf.toString(), this.div = t, this.renderer = e, this._onKeyDown = this._onKeyDown.bind(this), this._onMouseMove = this._onMouseMove.bind(this), globalThis.addEventListener("keydown", this._onKeyDown, !1);
  }
  /**
   * Value of `true` if accessibility is currently active and accessibility layers are showing.
   * @member {boolean}
   * @readonly
   */
  get isActive() {
    return this._isActive;
  }
  /**
   * Value of `true` if accessibility is enabled for touch devices.
   * @member {boolean}
   * @readonly
   */
  get isMobileAccessibility() {
    return this._isMobileAccessibility;
  }
  /**
   * Creates the touch hooks.
   * @private
   */
  createTouchHook() {
    const e = document.createElement("button");
    e.style.width = `${Uf}px`, e.style.height = `${Uf}px`, e.style.position = "absolute", e.style.top = `${CC}px`, e.style.left = `${IC}px`, e.style.zIndex = RC.toString(), e.style.backgroundColor = "#FF0000", e.title = "select to enable accessibility for this content", e.addEventListener("focus", () => {
      this._isMobileAccessibility = !0, this.activate(), this.destroyTouchHook();
    }), document.body.appendChild(e), this._hookDiv = e;
  }
  /**
   * Destroys the touch hooks.
   * @private
   */
  destroyTouchHook() {
    this._hookDiv && (document.body.removeChild(this._hookDiv), this._hookDiv = null);
  }
  /**
   * Activating will cause the Accessibility layer to be shown.
   * This is called when a user presses the tab key.
   * @private
   */
  activate() {
    var e;
    this._isActive || (this._isActive = !0, globalThis.document.addEventListener("mousemove", this._onMouseMove, !0), globalThis.removeEventListener("keydown", this._onKeyDown, !1), this.renderer.on("postrender", this.update, this), (e = this.renderer.view.parentNode) == null || e.appendChild(this.div));
  }
  /**
   * Deactivating will cause the Accessibility layer to be hidden.
   * This is called when a user moves the mouse.
   * @private
   */
  deactivate() {
    var e;
    !this._isActive || this._isMobileAccessibility || (this._isActive = !1, globalThis.document.removeEventListener("mousemove", this._onMouseMove, !0), globalThis.addEventListener("keydown", this._onKeyDown, !1), this.renderer.off("postrender", this.update), (e = this.div.parentNode) == null || e.removeChild(this.div));
  }
  /**
   * This recursive function will run through the scene graph and add any new accessible objects to the DOM layer.
   * @private
   * @param {PIXI.Container} displayObject - The DisplayObject to check.
   */
  updateAccessibleObjects(e) {
    if (!e.visible || !e.accessibleChildren)
      return;
    e.accessible && e.isInteractive() && (e._accessibleActive || this.addChild(e), e.renderId = this.renderId);
    const t = e.children;
    if (t)
      for (let i = 0; i < t.length; i++)
        this.updateAccessibleObjects(t[i]);
  }
  /**
   * Before each render this function will ensure that all divs are mapped correctly to their DisplayObjects.
   * @private
   */
  update() {
    const e = performance.now();
    if (Si.android.device && e < this.androidUpdateCount || (this.androidUpdateCount = e + this.androidUpdateFrequency, !this.renderer.renderingToScreen))
      return;
    this.renderer.lastObjectRendered && this.updateAccessibleObjects(this.renderer.lastObjectRendered);
    const { x: t, y: i, width: n, height: s } = this.renderer.view.getBoundingClientRect(), { width: o, height: a, resolution: l } = this.renderer, h = n / o * l, c = s / a * l;
    let u = this.div;
    u.style.left = `${t}px`, u.style.top = `${i}px`, u.style.width = `${o}px`, u.style.height = `${a}px`;
    for (let d = 0; d < this.children.length; d++) {
      const f = this.children[d];
      if (f.renderId !== this.renderId)
        f._accessibleActive = !1, Cn(this.children, d, 1), this.div.removeChild(f._accessibleDiv), this.pool.push(f._accessibleDiv), f._accessibleDiv = null, d--;
      else {
        u = f._accessibleDiv;
        let p = f.hitArea;
        const _ = f.worldTransform;
        f.hitArea ? (u.style.left = `${(_.tx + p.x * _.a) * h}px`, u.style.top = `${(_.ty + p.y * _.d) * c}px`, u.style.width = `${p.width * _.a * h}px`, u.style.height = `${p.height * _.d * c}px`) : (p = f.getBounds(), this.capHitArea(p), u.style.left = `${p.x * h}px`, u.style.top = `${p.y * c}px`, u.style.width = `${p.width * h}px`, u.style.height = `${p.height * c}px`, u.title !== f.accessibleTitle && f.accessibleTitle !== null && (u.title = f.accessibleTitle), u.getAttribute("aria-label") !== f.accessibleHint && f.accessibleHint !== null && u.setAttribute("aria-label", f.accessibleHint)), (f.accessibleTitle !== u.title || f.tabIndex !== u.tabIndex) && (u.title = f.accessibleTitle, u.tabIndex = f.tabIndex, this.debug && this.updateDebugHTML(u));
      }
    }
    this.renderId++;
  }
  /**
   * private function that will visually add the information to the
   * accessability div
   * @param {HTMLElement} div -
   */
  updateDebugHTML(e) {
    e.innerHTML = `type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`;
  }
  /**
   * Adjust the hit area based on the bounds of a display object
   * @param {PIXI.Rectangle} hitArea - Bounds of the child
   */
  capHitArea(e) {
    e.x < 0 && (e.width += e.x, e.x = 0), e.y < 0 && (e.height += e.y, e.y = 0);
    const { width: t, height: i } = this.renderer;
    e.x + e.width > t && (e.width = t - e.x), e.y + e.height > i && (e.height = i - e.y);
  }
  /**
   * Adds a DisplayObject to the accessibility manager
   * @private
   * @param {PIXI.DisplayObject} displayObject - The child to make accessible.
   */
  addChild(e) {
    let t = this.pool.pop();
    t || (t = document.createElement("button"), t.style.width = `${co}px`, t.style.height = `${co}px`, t.style.backgroundColor = this.debug ? "rgba(255,255,255,0.5)" : "transparent", t.style.position = "absolute", t.style.zIndex = Nf.toString(), t.style.borderStyle = "none", navigator.userAgent.toLowerCase().includes("chrome") ? t.setAttribute("aria-live", "off") : t.setAttribute("aria-live", "polite"), navigator.userAgent.match(/rv:.*Gecko\//) ? t.setAttribute("aria-relevant", "additions") : t.setAttribute("aria-relevant", "text"), t.addEventListener("click", this._onClick.bind(this)), t.addEventListener("focus", this._onFocus.bind(this)), t.addEventListener("focusout", this._onFocusOut.bind(this))), t.style.pointerEvents = e.accessiblePointerEvents, t.type = e.accessibleType, e.accessibleTitle && e.accessibleTitle !== null ? t.title = e.accessibleTitle : (!e.accessibleHint || e.accessibleHint === null) && (t.title = `displayObject ${e.tabIndex}`), e.accessibleHint && e.accessibleHint !== null && t.setAttribute("aria-label", e.accessibleHint), this.debug && this.updateDebugHTML(t), e._accessibleActive = !0, e._accessibleDiv = t, t.displayObject = e, this.children.push(e), this.div.appendChild(e._accessibleDiv), e._accessibleDiv.tabIndex = e.tabIndex;
  }
  /**
   * Dispatch events with the EventSystem.
   * @param e
   * @param type
   * @private
   */
  _dispatchEvent(e, t) {
    const { displayObject: i } = e.target, n = this.renderer.events.rootBoundary, s = Object.assign(new Ns(n), { target: i });
    n.rootTarget = this.renderer.lastObjectRendered, t.forEach((o) => n.dispatchEvent(s, o));
  }
  /**
   * Maps the div button press to pixi's EventSystem (click)
   * @private
   * @param {MouseEvent} e - The click event.
   */
  _onClick(e) {
    this._dispatchEvent(e, ["click", "pointertap", "tap"]);
  }
  /**
   * Maps the div focus events to pixi's EventSystem (mouseover)
   * @private
   * @param {FocusEvent} e - The focus event.
   */
  _onFocus(e) {
    e.target.getAttribute("aria-live") || e.target.setAttribute("aria-live", "assertive"), this._dispatchEvent(e, ["mouseover"]);
  }
  /**
   * Maps the div focus events to pixi's EventSystem (mouseout)
   * @private
   * @param {FocusEvent} e - The focusout event.
   */
  _onFocusOut(e) {
    e.target.getAttribute("aria-live") || e.target.setAttribute("aria-live", "polite"), this._dispatchEvent(e, ["mouseout"]);
  }
  /**
   * Is called when a key is pressed
   * @private
   * @param {KeyboardEvent} e - The keydown event.
   */
  _onKeyDown(e) {
    e.keyCode === TC && this.activate();
  }
  /**
   * Is called when the mouse moves across the renderer element
   * @private
   * @param {MouseEvent} e - The mouse event.
   */
  _onMouseMove(e) {
    e.movementX === 0 && e.movementY === 0 || this.deactivate();
  }
  /** Destroys the accessibility manager */
  destroy() {
    this.destroyTouchHook(), this.div = null, globalThis.document.removeEventListener("mousemove", this._onMouseMove, !0), globalThis.removeEventListener("keydown", this._onKeyDown), this.pool = null, this.children = null, this.renderer = null;
  }
}
h0.extension = {
  name: "accessibility",
  type: [
    q.RendererPlugin,
    q.CanvasRendererPlugin
  ]
};
Q.add(h0);
const c0 = class xc {
  /**
   * @param options - The optional application and renderer parameters.
   */
  constructor(e) {
    this.stage = new Qe(), e = Object.assign({
      forceCanvas: !1
    }, e), this.renderer = US(e), xc._plugins.forEach((t) => {
      t.init.call(this, e);
    });
  }
  /** Render the current stage. */
  render() {
    this.renderer.render(this.stage);
  }
  /**
   * Reference to the renderer's canvas element.
   * @member {PIXI.ICanvas}
   * @readonly
   */
  get view() {
    var e;
    return (e = this.renderer) == null ? void 0 : e.view;
  }
  /**
   * Reference to the renderer's screen rectangle. Its safe to use as `filterArea` or `hitArea` for the whole screen.
   * @member {PIXI.Rectangle}
   * @readonly
   */
  get screen() {
    var e;
    return (e = this.renderer) == null ? void 0 : e.screen;
  }
  /**
   * Destroy and don't use after this.
   * @param {boolean} [removeView=false] - Automatically remove canvas from DOM.
   * @param {object|boolean} [stageOptions] - Options parameter. A boolean will act as if all options
   *  have been set to that value
   * @param {boolean} [stageOptions.children=false] - if set to true, all the children will have their destroy
   *  method called as well. 'stageOptions' will be passed on to those calls.
   * @param {boolean} [stageOptions.texture=false] - Only used for child Sprites if stageOptions.children is set
   *  to true. Should it destroy the texture of the child sprite
   * @param {boolean} [stageOptions.baseTexture=false] - Only used for child Sprites if stageOptions.children is set
   *  to true. Should it destroy the base texture of the child sprite
   */
  destroy(e, t) {
    const i = xc._plugins.slice(0);
    i.reverse(), i.forEach((n) => {
      n.destroy.call(this);
    }), this.stage.destroy(t), this.stage = null, this.renderer.destroy(e), this.renderer = null;
  }
};
c0._plugins = [];
let u0 = c0;
Q.handleByList(q.Application, u0._plugins);
class d0 {
  /**
   * Initialize the plugin with scope of application instance
   * @static
   * @private
   * @param {object} [options] - See application options
   */
  static init(e) {
    Object.defineProperty(
      this,
      "resizeTo",
      /**
       * The HTML element or window to automatically resize the
       * renderer's view element to match width and height.
       * @member {Window|HTMLElement}
       * @name resizeTo
       * @memberof PIXI.Application#
       */
      {
        set(t) {
          globalThis.removeEventListener("resize", this.queueResize), this._resizeTo = t, t && (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 t, i;
      if (this._resizeTo === globalThis.window)
        t = globalThis.innerWidth, i = globalThis.innerHeight;
      else {
        const { clientWidth: n, clientHeight: s } = this._resizeTo;
        t = n, i = s;
      }
      this.renderer.resize(t, i), this.render();
    }, this._resizeId = null, this._resizeTo = null, this.resizeTo = e.resizeTo || null;
  }
  /**
   * Clean up the ticker, scoped to application
   * @static
   * @private
   */
  static destroy() {
    globalThis.removeEventListener("resize", this.queueResize), this.cancelResize(), this.cancelResize = null, this.queueResize = null, this.resizeTo = null, this.resize = null;
  }
}
d0.extension = q.Application;
Q.add(d0);
const Gf = {
  loader: q.LoadParser,
  resolver: q.ResolveParser,
  cache: q.CacheParser,
  detection: q.DetectionParser
};
Q.handle(q.Asset, (r) => {
  const e = r.ref;
  Object.entries(Gf).filter(([t]) => !!e[t]).forEach(([t, i]) => Q.add(Object.assign(
    e[t],
    // Allow the function to optionally define it's own
    // ExtensionMetadata, the use cases here is priority for LoaderParsers
    { extension: e[t].extension ?? i }
  )));
}, (r) => {
  const e = r.ref;
  Object.keys(Gf).filter((t) => !!e[t]).forEach((t) => Q.remove(e[t]));
});
class PC {
  /**
   * @param loader
   * @param verbose - should the loader log to the console
   */
  constructor(e, t = !1) {
    this._loader = e, this._assetList = [], this._isLoading = !1, this._maxConcurrent = 1, this.verbose = t;
  }
  /**
   * Adds an array of assets to load.
   * @param assetUrls - assets to load
   */
  add(e) {
    e.forEach((t) => {
      this._assetList.push(t);
    }), this.verbose && console.log("[BackgroundLoader] assets: ", this._assetList), this._isActive && !this._isLoading && this._next();
  }
  /**
   * Loads the next set of assets. Will try to load as many assets as it can at the same time.
   *
   * The max assets it will try to load at one time will be 4.
   */
  async _next() {
    if (this._assetList.length && this._isActive) {
      this._isLoading = !0;
      const e = [], t = Math.min(this._assetList.length, this._maxConcurrent);
      for (let i = 0; i < t; i++)
        e.push(this._assetList.pop());
      await this._loader.load(e), this._isLoading = !1, this._next();
    }
  }
  /**
   * Activate/Deactivate the loading. If set to true then it will immediately continue to load the next asset.
   * @returns whether the class is active
   */
  get active() {
    return this._isActive;
  }
  set active(e) {
    this._isActive !== e && (this._isActive = e, e && !this._isLoading && this._next());
  }
}
function Yn(r, e) {
  if (Array.isArray(e)) {
    for (const t of e)
      if (r.startsWith(`data:${t}`))
        return !0;
    return !1;
  }
  return r.startsWith(`data:${e}`);
}
function cr(r, e) {
  const t = r.split("?")[0], i = We.extname(t).toLowerCase();
  return Array.isArray(e) ? e.includes(i) : i === e;
}
const jt = (r, e, t = !1) => (Array.isArray(r) || (r = [r]), e ? r.map((i) => typeof i == "string" || t ? e(i) : i) : r), Ec = (r, e) => {
  const t = e.split("?")[1];
  return t && (r += `?${t}`), r;
};
function f0(r, e, t, i, n) {
  const s = e[t];
  for (let o = 0; o < s.length; o++) {
    const a = s[o];
    t < e.length - 1 ? f0(r.replace(i[t], a), e, t + 1, i, n) : n.push(r.replace(i[t], a));
  }
}
function MC(r) {
  const e = /\{(.*?)\}/g, t = r.match(e), i = [];
  if (t) {
    const n = [];
    t.forEach((s) => {
      const o = s.substring(1, s.length - 1).split(",");
      n.push(o);
    }), f0(r, n, 0, t, i);
  } else
    i.push(r);
  return i;
}
const fa = (r) => !Array.isArray(r);
class kC {
  constructor() {
    this._parsers = [], this._cache = /* @__PURE__ */ new Map(), this._cacheMap = /* @__PURE__ */ new Map();
  }
  /** Clear all entries. */
  reset() {
    this._cacheMap.clear(), this._cache.clear();
  }
  /**
   * Check if the key exists
   * @param key - The key to check
   */
  has(e) {
    return this._cache.has(e);
  }
  /**
   * Fetch entry by key
   * @param key - The key of the entry to get
   */
  get(e) {
    const t = this._cache.get(e);
    return t || console.warn(`[Assets] Asset id ${e} was not found in the Cache`), t;
  }
  /**
   * Set a value by key or keys name
   * @param key - The key or keys to set
   * @param value - The value to store in the cache or from which cacheable assets will be derived.
   */
  set(e, t) {
    const i = jt(e);
    let n;
    for (let a = 0; a < this.parsers.length; a++) {
      const l = this.parsers[a];
      if (l.test(t)) {
        n = l.getCacheableAssets(i, t);
        break;
      }
    }
    n || (n = {}, i.forEach((a) => {
      n[a] = t;
    }));
    const s = Object.keys(n), o = {
      cacheKeys: s,
      keys: i
    };
    if (i.forEach((a) => {
      this._cacheMap.set(a, o);
    }), s.forEach((a) => {
      this._cache.has(a) && this._cache.get(a) !== t && console.warn("[Cache] already has key:", a), this._cache.set(a, n[a]);
    }), t instanceof J) {
      const a = t;
      i.forEach((l) => {
        a.baseTexture !== J.EMPTY.baseTexture && ae.addToCache(a.baseTexture, l), J.addToCache(a, l);
      });
    }
  }
  /**
   * Remove entry by key
   *
   * This function will also remove any associated alias from the cache also.
   * @param key - The key of the entry to remove
   */
  remove(e) {
    if (!this._cacheMap.has(e)) {
      console.warn(`[Assets] Asset id ${e} was not found in the Cache`);
      return;
    }
    const t = this._cacheMap.get(e);
    t.cacheKeys.forEach((i) => {
      this._cache.delete(i);
    }), t.keys.forEach((i) => {
      this._cacheMap.delete(i);
    });
  }
  /** All loader parsers registered */
  get parsers() {
    return this._parsers;
  }
}
const Rr = new kC();
class DC {
  constructor() {
    this._parsers = [], this._parsersValidated = !1, this.parsers = new Proxy(this._parsers, {
      set: (e, t, i) => (this._parsersValidated = !1, e[t] = i, !0)
    }), this.promiseCache = {};
  }
  /** function used for testing */
  reset() {
    this._parsersValidated = !1, this.promiseCache = {};
  }
  /**
   * Used internally to generate a promise for the asset to be loaded.
   * @param url - The URL to be loaded
   * @param data - any custom additional information relevant to the asset being loaded
   * @returns - a promise that will resolve to an Asset for example a Texture of a JSON object
   */
  _getLoadPromiseAndParser(e, t) {
    const i = {
      promise: null,
      parser: null
    };
    return i.promise = (async () => {
      var o, a;
      let n = null, s = null;
      if (t.loadParser && (s = this._parserHash[t.loadParser], s || console.warn(`[Assets] specified load parser "${t.loadParser}" not found while loading ${e}`)), !s) {
        for (let l = 0; l < this.parsers.length; l++) {
          const h = this.parsers[l];
          if (h.load && ((o = h.test) != null && o.call(h, e, t, this))) {
            s = h;
            break;
          }
        }
        if (!s)
          return console.warn(`[Assets] ${e} could not be loaded as we don't know how to parse it, ensure the correct parser has been added`), null;
      }
      n = await s.load(e, t, this), i.parser = s;
      for (let l = 0; l < this.parsers.length; l++) {
        const h = this.parsers[l];
        h.parse && h.parse && await ((a = h.testParse) == null ? void 0 : a.call(h, n, t, this)) && (n = await h.parse(n, t, this) || n, i.parser = h);
      }
      return n;
    })(), i;
  }
  async load(e, t) {
    this._parsersValidated || this._validateParsers();
    let i = 0;
    const n = {}, s = fa(e), o = jt(e, (h) => ({
      alias: [h],
      src: h
    })), a = o.length, l = o.map(async (h) => {
      const c = We.toAbsolute(h.src);
      if (!n[h.src])
        try {
          this.promiseCache[c] || (this.promiseCache[c] = this._getLoadPromiseAndParser(c, h)), n[h.src] = await this.promiseCache[c].promise, t && t(++i / a);
        } catch (u) {
          throw delete this.promiseCache[c], delete n[h.src], new Error(`[Loader.load] Failed to load ${c}.
${u}`);
        }
    });
    return await Promise.all(l), s ? n[o[0].src] : n;
  }
  /**
   * Unloads one or more assets. Any unloaded assets will be destroyed, freeing up memory for your app.
   * The parser that created the asset, will be the one that unloads it.
   * @example
   * // Single asset:
   * const asset = await Loader.load('cool.png');
   *
   * await Loader.unload('cool.png');
   *
   * console.log(asset.destroyed); // true
   * @param assetsToUnloadIn - urls that you want to unload, or a single one!
   */
  async unload(e) {
    const t = jt(e, (i) => ({
      alias: [i],
      src: i
    })).map(async (i) => {
      var o, a;
      const n = We.toAbsolute(i.src), s = this.promiseCache[n];
      if (s) {
        const l = await s.promise;
        delete this.promiseCache[n], (a = (o = s.parser) == null ? void 0 : o.unload) == null || a.call(o, l, i, this);
      }
    });
    await Promise.all(t);
  }
  /** validates our parsers, right now it only checks for name conflicts but we can add more here as required! */
  _validateParsers() {
    this._parsersValidated = !0, this._parserHash = this._parsers.filter((e) => e.name).reduce((e, t) => (e[t.name] && console.warn(`[Assets] loadParser name conflict "${t.name}"`), { ...e, [t.name]: t }), {});
  }
}
var Qt = /* @__PURE__ */ ((r) => (r[r.Low = 0] = "Low", r[r.Normal = 1] = "Normal", r[r.High = 2] = "High", r))(Qt || {});
const BC = ".json", FC = "application/json", OC = {
  extension: {
    type: q.LoadParser,
    priority: Qt.Low
  },
  name: "loadJson",
  test(r) {
    return Yn(r, FC) || cr(r, BC);
  },
  async load(r) {
    return await (await Z.ADAPTER.fetch(r)).json();
  }
};
Q.add(OC);
const LC = ".txt", NC = "text/plain", UC = {
  name: "loadTxt",
  extension: {
    type: q.LoadParser,
    priority: Qt.Low
  },
  test(r) {
    return Yn(r, NC) || cr(r, LC);
  },
  async load(r) {
    return await (await Z.ADAPTER.fetch(r)).text();
  }
};
Q.add(UC);
const GC = [
  "normal",
  "bold",
  "100",
  "200",
  "300",
  "400",
  "500",
  "600",
  "700",
  "800",
  "900"
], HC = [".ttf", ".otf", ".woff", ".woff2"], zC = [
  "font/ttf",
  "font/otf",
  "font/woff",
  "font/woff2"
], XC = /^(--|-?[A-Z_])[0-9A-Z_-]*$/i;
function VC(r) {
  const e = We.extname(r), t = We.basename(r, e).replace(/(-|_)/g, " ").toLowerCase().split(" ").map((s) => s.charAt(0).toUpperCase() + s.slice(1));
  let i = t.length > 0;
  for (const s of t)
    if (!s.match(XC)) {
      i = !1;
      break;
    }
  let n = t.join(" ");
  return i || (n = `"${n.replace(/[\\"]/g, "\\$&")}"`), n;
}
const WC = /^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;
function jC(r) {
  return WC.test(r) ? r : encodeURI(r);
}
const qC = {
  extension: {
    type: q.LoadParser,
    priority: Qt.Low
  },
  name: "loadWebFont",
  test(r) {
    return Yn(r, zC) || cr(r, HC);
  },
  async load(r, e) {
    var i, n, s;
    const t = Z.ADAPTER.getFontFaceSet();
    if (t) {
      const o = [], a = ((i = e.data) == null ? void 0 : i.family) ?? VC(r), l = ((s = (n = e.data) == null ? void 0 : n.weights) == null ? void 0 : s.filter((c) => GC.includes(c))) ?? ["normal"], h = e.data ?? {};
      for (let c = 0; c < l.length; c++) {
        const u = l[c], d = new FontFace(a, `url(${jC(r)})`, {
          ...h,
          weight: u
        });
        await d.load(), t.add(d), o.push(d);
      }
      return o.length === 1 ? o[0] : o;
    }
    return console.warn("[loadWebFont] FontFace API is not supported. Skipping loading font"), null;
  },
  unload(r) {
    (Array.isArray(r) ? r : [r]).forEach((e) => Z.ADAPTER.getFontFaceSet().delete(e));
  }
};
Q.add(qC);
const YC = `(function() {
  "use strict";
  const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";
  async function checkImageBitmap() {
    try {
      if (typeof createImageBitmap != "function")
        return !1;
      const imageBlob = await (await fetch(WHITE_PNG)).blob(), imageBitmap = await createImageBitmap(imageBlob);
      return imageBitmap.width === 1 && imageBitmap.height === 1;
    } catch {
      return !1;
    }
  }
  checkImageBitmap().then((result) => {
    self.postMessage(result);
  });
})();
`;
let Pn = null, Tc = class {
  constructor() {
    Pn || (Pn = URL.createObjectURL(new Blob([YC], { type: "application/javascript" }))), this.worker = new Worker(Pn);
  }
};
Tc.revokeObjectURL = function() {
  Pn && (URL.revokeObjectURL(Pn), Pn = null);
};
const KC = `(function() {
  "use strict";
  async function loadImageBitmap(url) {
    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 await createImageBitmap(imageBlob);
  }
  self.onmessage = async (event) => {
    try {
      const imageBitmap = await loadImageBitmap(event.data.data[0]);
      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 Mn = null;
class p0 {
  constructor() {
    Mn || (Mn = URL.createObjectURL(new Blob([KC], { type: "application/javascript" }))), this.worker = new Worker(Mn);
  }
}
p0.revokeObjectURL = function() {
  Mn && (URL.revokeObjectURL(Mn), Mn = null);
};
let Hf = 0, ih;
class ZC {
  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((e) => {
      const { worker: t } = new Tc();
      t.addEventListener("message", (i) => {
        t.terminate(), Tc.revokeObjectURL(), e(i.data);
      });
    }), this._isImageBitmapSupported);
  }
  loadImageBitmap(e) {
    return this._run("loadImageBitmap", [e]);
  }
  async _initWorkers() {
    this._initialized || (this._initialized = !0);
  }
  getWorker() {
    ih === void 0 && (ih = navigator.hardwareConcurrency || 4);
    let e = this.workerPool.pop();
    return !e && this._createdWorkers < ih && (this._createdWorkers++, e = new p0().worker, e.addEventListener("message", (t) => {
      this.complete(t.data), this.returnWorker(t.target), this.next();
    })), e;
  }
  returnWorker(e) {
    this.workerPool.push(e);
  }
  complete(e) {
    e.error !== void 0 ? this.resolveHash[e.uuid].reject(e.error) : this.resolveHash[e.uuid].resolve(e.data), this.resolveHash[e.uuid] = null;
  }
  async _run(e, t) {
    await this._initWorkers();
    const i = new Promise((n, s) => {
      this.queue.push({ id: e, arguments: t, resolve: n, reject: s });
    });
    return this.next(), i;
  }
  next() {
    if (!this.queue.length)
      return;
    const e = this.getWorker();
    if (!e)
      return;
    const t = this.queue.pop(), i = t.id;
    this.resolveHash[Hf] = { resolve: t.resolve, reject: t.reject }, e.postMessage({
      data: t.arguments,
      uuid: Hf++,
      id: i
    });
  }
}
const zf = new ZC();
function Us(r, e, t) {
  r.resource.internal = !0;
  const i = new J(r), n = () => {
    delete e.promiseCache[t], Rr.has(t) && Rr.remove(t);
  };
  return i.baseTexture.once("destroyed", () => {
    t in e.promiseCache && (console.warn("[Assets] A BaseTexture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the BaseTexture."), n());
  }), i.once("destroyed", () => {
    r.destroyed || (console.warn("[Assets] A Texture managed by Assets was destroyed instead of unloaded! Use Assets.unload() instead of destroying the Texture."), n());
  }), i;
}
const $C = [".jpeg", ".jpg", ".png", ".webp", ".avif"], JC = [
  "image/jpeg",
  "image/png",
  "image/webp",
  "image/avif"
];
async function QC(r) {
  const e = await Z.ADAPTER.fetch(r);
  if (!e.ok)
    throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${e.status} ${e.statusText}`);
  const t = await e.blob();
  return await createImageBitmap(t);
}
const Oa = {
  name: "loadTextures",
  extension: {
    type: q.LoadParser,
    priority: Qt.High
  },
  config: {
    preferWorkers: !0,
    preferCreateImageBitmap: !0,
    crossOrigin: "anonymous"
  },
  test(r) {
    return Yn(r, JC) || cr(r, $C);
  },
  async load(r, e, t) {
    var a;
    const i = globalThis.createImageBitmap && this.config.preferCreateImageBitmap;
    let n;
    i ? this.config.preferWorkers && await zf.isImageBitmapSupported() ? n = await zf.loadImageBitmap(r) : n = await QC(r) : n = await new Promise((l, h) => {
      const c = new Image();
      c.crossOrigin = this.config.crossOrigin, c.src = r, c.complete ? l(c) : (c.onload = () => l(c), c.onerror = (u) => h(u));
    });
    const s = { ...e.data };
    s.resolution ?? (s.resolution = Di(r)), i && ((a = s.resourceOptions) == null ? void 0 : a.ownsImageBitmap) === void 0 && (s.resourceOptions = { ...s.resourceOptions }, s.resourceOptions.ownsImageBitmap = !0);
    const o = new ae(n, s);
    return o.resource.src = r, Us(o, t, r);
  },
  unload(r) {
    r.destroy(!0);
  }
};
Q.add(Oa);
const e3 = ".svg", t3 = "image/svg+xml", i3 = {
  extension: {
    type: q.LoadParser,
    priority: Qt.High
  },
  name: "loadSVG",
  test(r) {
    return Yn(r, t3) || cr(r, e3);
  },
  async testParse(r) {
    return fc.test(r);
  },
  async parse(r, e, t) {
    var s;
    const i = new fc(r, (s = e == null ? void 0 : e.data) == null ? void 0 : s.resourceOptions);
    await i.load();
    const n = new ae(i, {
      resolution: Di(r),
      ...e == null ? void 0 : e.data
    });
    return n.resource.src = e.src, Us(n, t, e.src);
  },
  async load(r, e) {
    return (await Z.ADAPTER.fetch(r)).text();
  },
  unload: Oa.unload
};
Q.add(i3);
const r3 = [".mp4", ".m4v", ".webm", ".ogv"], n3 = [
  "video/mp4",
  "video/webm",
  "video/ogg"
], s3 = {
  name: "loadVideo",
  extension: {
    type: q.LoadParser,
    priority: Qt.High
  },
  config: {
    defaultAutoPlay: !0,
    defaultUpdateFPS: 0,
    defaultLoop: !1,
    defaultMuted: !1,
    defaultPlaysinline: !0
  },
  test(r) {
    return Yn(r, n3) || cr(r, r3);
  },
  async load(r, e, t) {
    var o;
    let i;
    const n = await (await Z.ADAPTER.fetch(r)).blob(), s = URL.createObjectURL(n);
    try {
      const a = {
        autoPlay: this.config.defaultAutoPlay,
        updateFPS: this.config.defaultUpdateFPS,
        loop: this.config.defaultLoop,
        muted: this.config.defaultMuted,
        playsinline: this.config.defaultPlaysinline,
        ...(o = e == null ? void 0 : e.data) == null ? void 0 : o.resourceOptions,
        autoLoad: !0
      }, l = new o0(s, a);
      await l.load();
      const h = new ae(l, {
        alphaMode: await uA(),
        resolution: Di(r),
        ...e == null ? void 0 : e.data
      });
      h.resource.src = r, i = Us(h, t, r), i.baseTexture.once("destroyed", () => {
        URL.revokeObjectURL(s);
      });
    } catch (a) {
      throw URL.revokeObjectURL(s), a;
    }
    return i;
  },
  unload(r) {
    r.destroy(!0);
  }
};
Q.add(s3);
class o3 {
  constructor() {
    this._defaultBundleIdentifierOptions = {
      connector: "-",
      createBundleAssetId: (e, t) => `${e}${this._bundleIdConnector}${t}`,
      extractAssetIdFromBundle: (e, t) => t.replace(`${e}${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 = {};
  }
  /**
   * Override how the resolver deals with generating bundle ids.
   * must be called before any bundles are added
   * @param bundleIdentifier - the bundle identifier options
   */
  setBundleIdentifier(e) {
    if (this._bundleIdConnector = e.connector ?? this._bundleIdConnector, this._createBundleAssetId = e.createBundleAssetId ?? this._createBundleAssetId, this._extractAssetIdFromBundle = e.extractAssetIdFromBundle ?? this._extractAssetIdFromBundle, this._extractAssetIdFromBundle("foo", this._createBundleAssetId("foo", "bar")) !== "bar")
      throw new Error("[Resolver] GenerateBundleAssetId are not working correctly");
  }
  /**
   * Let the resolver know which assets you prefer to use when resolving assets.
   * Multiple prefer user defined rules can be added.
   * @example
   * resolver.prefer({
   *     // first look for something with the correct format, and then then correct resolution
   *     priority: ['format', 'resolution'],
   *     params:{
   *         format:'webp', // prefer webp images
   *         resolution: 2, // prefer a resolution of 2
   *     }
   * })
   * resolver.add('foo', ['bar@2x.webp', 'bar@2x.png', 'bar.webp', 'bar.png']);
   * resolver.resolveUrl('foo') // => 'bar@2x.webp'
   * @param preferOrders - the prefer options
   */
  prefer(...e) {
    e.forEach((t) => {
      this._preferredOrder.push(t), t.priority || (t.priority = Object.keys(t.params));
    }), this._resolverHash = {};
  }
  /**
   * Set the base path to prepend to all urls when resolving
   * @example
   * resolver.basePath = 'https://home.com/';
   * resolver.add('foo', 'bar.ong');
   * resolver.resolveUrl('foo', 'bar.png'); // => 'https://home.com/bar.png'
   * @param basePath - the base path to use
   */
  set basePath(e) {
    this._basePath = e;
  }
  get basePath() {
    return this._basePath;
  }
  /**
   * Set the root path for root-relative URLs. By default the `basePath`'s root is used. If no `basePath` is set, then the
   * default value for browsers is `window.location.origin`
   * @example
   * // Application hosted on https://home.com/some-path/index.html
   * resolver.basePath = 'https://home.com/some-path/';
   * resolver.rootPath = 'https://home.com/';
   * resolver.add('foo', '/bar.png');
   * resolver.resolveUrl('foo', '/bar.png'); // => 'https://home.com/bar.png'
   * @param rootPath - the root path to use
   */
  set rootPath(e) {
    this._rootPath = e;
  }
  get rootPath() {
    return this._rootPath;
  }
  /**
   * All the active URL parsers that help the parser to extract information and create
   * an asset object-based on parsing the URL itself.
   *
   * Can be added using the extensions API
   * @example
   * resolver.add('foo', [
   *     {
   *         resolution: 2,
   *         format: 'png',
   *         src: 'image@2x.png',
   *     },
   *     {
   *         resolution:1,
   *         format:'png',
   *         src: 'image.png',
   *     },
   * ]);
   *
   * // With a url parser the information such as resolution and file format could extracted from the url itself:
   * extensions.add({
   *     extension: ExtensionType.ResolveParser,
   *     test: loadTextures.test, // test if url ends in an image
   *     parse: (value: string) =>
   *     ({
   *         resolution: parseFloat(settings.RETINA_PREFIX.exec(value)?.[1] ?? '1'),
   *         format: value.split('.').pop(),
   *         src: value,
   *     }),
   * });
   *
   * // Now resolution and format can be extracted from the url
   * resolver.add('foo', [
   *     'image@2x.png',
   *     'image.png',
   * ]);
   */
  get parsers() {
    return this._parsers;
  }
  /** Used for testing, this resets the resolver to its initial state */
  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;
  }
  /**
   * Sets the default URL search parameters for the URL resolver. The urls can be specified as a string or an object.
   * @param searchParams - the default url parameters to append when resolving urls
   */
  setDefaultSearchParams(e) {
    if (typeof e == "string")
      this._defaultSearchParams = e;
    else {
      const t = e;
      this._defaultSearchParams = Object.keys(t).map((i) => `${encodeURIComponent(i)}=${encodeURIComponent(t[i])}`).join("&");
    }
  }
  /**
   * Returns the aliases for a given asset
   * @param asset - the asset to get the aliases for
   */
  getAlias(e) {
    const { alias: t, name: i, src: n, srcs: s } = e;
    return jt(
      t || i || n || s,
      (o) => typeof o == "string" ? o : Array.isArray(o) ? o.map((a) => (a == null ? void 0 : a.src) ?? (a == null ? void 0 : a.srcs) ?? a) : o != null && o.src || o != null && o.srcs ? o.src ?? o.srcs : o,
      !0
    );
  }
  /**
   * Add a manifest to the asset resolver. This is a nice way to add all the asset information in one go.
   * generally a manifest would be built using a tool.
   * @param manifest - the manifest to add to the resolver
   */
  addManifest(e) {
    this._manifest && console.warn("[Resolver] Manifest already exists, this will be overwritten"), this._manifest = e, e.bundles.forEach((t) => {
      this.addBundle(t.name, t.assets);
    });
  }
  /**
   * This adds a bundle of assets in one go so that you can resolve them as a group.
   * For example you could add a bundle for each screen in you pixi app
   * @example
   * resolver.addBundle('animals', {
   *     bunny: 'bunny.png',
   *     chicken: 'chicken.png',
   *     thumper: 'thumper.png',
   * });
   *
   * const resolvedAssets = await resolver.resolveBundle('animals');
   * @param bundleId - The id of the bundle to add
   * @param assets - A record of the asset or assets that will be chosen from when loading via the specified key
   */
  addBundle(e, t) {
    const i = [];
    Array.isArray(t) ? t.forEach((n) => {
      const s = n.src ?? n.srcs, o = n.alias ?? n.name;
      let a;
      if (typeof o == "string") {
        const l = this._createBundleAssetId(e, o);
        i.push(l), a = [o, l];
      } else {
        const l = o.map((h) => this._createBundleAssetId(e, h));
        i.push(...l), a = [...o, ...l];
      }
      this.add({
        ...n,
        alias: a,
        src: s
      });
    }) : Object.keys(t).forEach((n) => {
      const s = [n, this._createBundleAssetId(e, n)];
      if (typeof t[n] == "string")
        this.add({
          alias: s,
          src: t[n]
        });
      else if (Array.isArray(t[n]))
        this.add({
          alias: s,
          src: t[n]
        });
      else {
        const o = t[n], a = o.src ?? o.srcs;
        this.add({
          ...o,
          alias: s,
          src: Array.isArray(a) ? a : [a]
        });
      }
      i.push(...s);
    }), this._bundles[e] = i;
  }
  add(e, t, i, n, s) {
    const o = [];
    typeof e == "string" || Array.isArray(e) && typeof e[0] == "string" ? (fe("7.2.0", `Assets.add now uses an object instead of individual parameters.
Please use Assets.add({ alias, src, data, format, loadParser }) instead.`), o.push({ alias: e, src: t, data: i, format: n, loadParser: s })) : Array.isArray(e) ? o.push(...e) : o.push(e);
    let a;
    a = (l) => {
      this.hasKey(l) && console.warn(`[Resolver] already has key: ${l} overwriting`);
    }, jt(o).forEach((l) => {
      const { src: h, srcs: c } = l;
      let { data: u, format: d, loadParser: f } = l;
      const p = jt(h || c).map((y) => typeof y == "string" ? MC(y) : Array.isArray(y) ? y : [y]), _ = this.getAlias(l);
      Array.isArray(_) ? _.forEach(a) : a(_);
      const m = [];
      p.forEach((y) => {
        y.forEach((v) => {
          let g = {};
          if (typeof v != "object") {
            g.src = v;
            for (let b = 0; b < this._parsers.length; b++) {
              const w = this._parsers[b];
              if (w.test(v)) {
                g = w.parse(v);
                break;
              }
            }
          } else
            u = v.data ?? u, d = v.format ?? d, f = v.loadParser ?? f, g = {
              ...g,
              ...v
            };
          if (!_)
            throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);
          g = this.buildResolvedAsset(g, {
            aliases: _,
            data: u,
            format: d,
            loadParser: f
          }), m.push(g);
        });
      }), _.forEach((y) => {
        this._assetMap[y] = m;
      });
    });
  }
  // TODO: this needs an overload like load did in Assets
  /**
   * If the resolver has had a manifest set via setManifest, this will return the assets urls for
   * a given bundleId or bundleIds.
   * @example
   * // Manifest Example
   * const manifest = {
   *     bundles: [
   *         {
   *             name: 'load-screen',
   *             assets: [
   *                 {
   *                     alias: 'background',
   *                     src: 'sunset.png',
   *                 },
   *                 {
   *                     alias: 'bar',
   *                     src: 'load-bar.{png,webp}',
   *                 },
   *             ],
   *         },
   *         {
   *             name: 'game-screen',
   *             assets: [
   *                 {
   *                     alias: 'character',
   *                     src: 'robot.png',
   *                 },
   *                 {
   *                     alias: 'enemy',
   *                     src: 'bad-guy.png',
   *                 },
   *             ],
   *         },
   *     ]
   * };
   *
   * resolver.setManifest(manifest);
   * const resolved = resolver.resolveBundle('load-screen');
   * @param bundleIds - The bundle ids to resolve
   * @returns All the bundles assets or a hash of assets for each bundle specified
   */
  resolveBundle(e) {
    const t = fa(e);
    e = jt(e);
    const i = {};
    return e.forEach((n) => {
      const s = this._bundles[n];
      if (s) {
        const o = this.resolve(s), a = {};
        for (const l in o) {
          const h = o[l];
          a[this._extractAssetIdFromBundle(n, l)] = h;
        }
        i[n] = a;
      }
    }), t ? i[e[0]] : i;
  }
  /**
   * Does exactly what resolve does, but returns just the URL rather than the whole asset object
   * @param key - The key or keys to resolve
   * @returns - The URLs associated with the key(s)
   */
  resolveUrl(e) {
    const t = this.resolve(e);
    if (typeof e != "string") {
      const i = {};
      for (const n in t)
        i[n] = t[n].src;
      return i;
    }
    return t.src;
  }
  resolve(e) {
    const t = fa(e);
    e = jt(e);
    const i = {};
    return e.forEach((n) => {
      if (!this._resolverHash[n])
        if (this._assetMap[n]) {
          let s = this._assetMap[n];
          const o = s[0], a = this._getPreferredOrder(s);
          a == null || a.priority.forEach((l) => {
            a.params[l].forEach((h) => {
              const c = s.filter((u) => u[l] ? u[l] === h : !1);
              c.length && (s = c);
            });
          }), this._resolverHash[n] = s[0] ?? o;
        } else
          this._resolverHash[n] = this.buildResolvedAsset({
            alias: [n],
            src: n
          }, {});
      i[n] = this._resolverHash[n];
    }), t ? i[e[0]] : i;
  }
  /**
   * Checks if an asset with a given key exists in the resolver
   * @param key - The key of the asset
   */
  hasKey(e) {
    return !!this._assetMap[e];
  }
  /**
   * Checks if a bundle with the given key exists in the resolver
   * @param key - The key of the bundle
   */
  hasBundle(e) {
    return !!this._bundles[e];
  }
  /**
   * Internal function for figuring out what prefer criteria an asset should use.
   * @param assets
   */
  _getPreferredOrder(e) {
    for (let t = 0; t < e.length; t++) {
      const i = e[0], n = this._preferredOrder.find((s) => s.params.format.includes(i.format));
      if (n)
        return n;
    }
    return this._preferredOrder[0];
  }
  /**
   * Appends the default url parameters to the url
   * @param url - The url to append the default parameters to
   * @returns - The url with the default parameters appended
   */
  _appendDefaultSearchParams(e) {
    if (!this._defaultSearchParams)
      return e;
    const t = /\?/.test(e) ? "&" : "?";
    return `${e}${t}${this._defaultSearchParams}`;
  }
  buildResolvedAsset(e, t) {
    const { aliases: i, data: n, loadParser: s, format: o } = t;
    return (this._basePath || this._rootPath) && (e.src = We.toAbsolute(e.src, this._basePath, this._rootPath)), e.alias = i ?? e.alias ?? [e.src], e.src = this._appendDefaultSearchParams(e.src), e.data = { ...n || {}, ...e.data }, e.loadParser = s ?? e.loadParser, e.format = o ?? e.format ?? We.extname(e.src).slice(1), e.srcs = e.src, e.name = e.alias, e;
  }
}
class a3 {
  constructor() {
    this._detections = [], this._initialized = !1, this.resolver = new o3(), this.loader = new DC(), this.cache = Rr, this._backgroundLoader = new PC(this.loader), this._backgroundLoader.active = !0, this.reset();
  }
  /**
   * Best practice is to call this function before any loading commences
   * Initiating is the best time to add any customization to the way things are loaded.
   *
   * you do not need to call this for the Asset class to work, only if you want to set any initial properties
   * @param options - options to initialize the Asset manager with
   */
  async init(e = {}) {
    var s, o;
    if (this._initialized) {
      console.warn("[Assets]AssetManager already initialized, did you load before calling this Assets.init()?");
      return;
    }
    if (this._initialized = !0, e.defaultSearchParams && this.resolver.setDefaultSearchParams(e.defaultSearchParams), e.basePath && (this.resolver.basePath = e.basePath), e.bundleIdentifier && this.resolver.setBundleIdentifier(e.bundleIdentifier), e.manifest) {
      let a = e.manifest;
      typeof a == "string" && (a = await this.load(a)), this.resolver.addManifest(a);
    }
    const t = ((s = e.texturePreference) == null ? void 0 : s.resolution) ?? 1, i = typeof t == "number" ? [t] : t, n = await this._detectFormats({
      preferredFormats: (o = e.texturePreference) == null ? void 0 : o.format,
      skipDetections: e.skipDetections,
      detections: this._detections
    });
    this.resolver.prefer({
      params: {
        format: n,
        resolution: i
      }
    }), e.preferences && this.setPreferences(e.preferences);
  }
  add(e, t, i, n, s) {
    this.resolver.add(e, t, i, n, s);
  }
  async load(e, t) {
    this._initialized || await this.init();
    const i = fa(e), n = jt(e).map((a) => {
      if (typeof a != "string") {
        const l = this.resolver.getAlias(a);
        return l.some((h) => !this.resolver.hasKey(h)) && this.add(a), Array.isArray(l) ? l[0] : l;
      }
      return this.resolver.hasKey(a) || this.add({ alias: a, src: a }), a;
    }), s = this.resolver.resolve(n), o = await this._mapLoadToResolve(s, t);
    return i ? o[n[0]] : o;
  }
  /**
   * This adds a bundle of assets in one go so that you can load them as a group.
   * For example you could add a bundle for each screen in you pixi app
   * @example
   * import { Assets } from 'pixi.js';
   *
   * Assets.addBundle('animals', {
   *     bunny: 'bunny.png',
   *     chicken: 'chicken.png',
   *     thumper: 'thumper.png',
   * });
   *
   * const assets = await Assets.loadBundle('animals');
   * @param bundleId - the id of the bundle to add
   * @param assets - a record of the asset or assets that will be chosen from when loading via the specified key
   */
  addBundle(e, t) {
    this.resolver.addBundle(e, t);
  }
  /**
   * Bundles are a way to load multiple assets at once.
   * If a manifest has been provided to the init function then you can load a bundle, or bundles.
   * you can also add bundles via `addBundle`
   * @example
   * import { Assets } from 'pixi.js';
   *
   * // Manifest Example
   * const manifest = {
   *     bundles: [
   *         {
   *             name: 'load-screen',
   *             assets: [
   *                 {
   *                     alias: 'background',
   *                     src: 'sunset.png',
   *                 },
   *                 {
   *                     alias: 'bar',
   *                     src: 'load-bar.{png,webp}',
   *                 },
   *             ],
   *         },
   *         {
   *             name: 'game-screen',
   *             assets: [
   *                 {
   *                     alias: 'character',
   *                     src: 'robot.png',
   *                 },
   *                 {
   *                     alias: 'enemy',
   *                     src: 'bad-guy.png',
   *                 },
   *             ],
   *         },
   *     ]
   * };
   *
   * await Assets.init({ manifest });
   *
   * // Load a bundle...
   * loadScreenAssets = await Assets.loadBundle('load-screen');
   * // Load another bundle...
   * gameScreenAssets = await Assets.loadBundle('game-screen');
   * @param bundleIds - the bundle id or ids to load
   * @param onProgress - Optional function that is called when progress on asset loading is made.
   * The function is passed a single parameter, `progress`, which represents the percentage (0.0 - 1.0)
   * of the assets loaded. Do not use this function to detect when assets are complete and available,
   * instead use the Promise returned by this function.
   * @returns all the bundles assets or a hash of assets for each bundle specified
   */
  async loadBundle(e, t) {
    this._initialized || await this.init();
    let i = !1;
    typeof e == "string" && (i = !0, e = [e]);
    const n = this.resolver.resolveBundle(e), s = {}, o = Object.keys(n);
    let a = 0, l = 0;
    const h = () => {
      t == null || t(++a / l);
    }, c = o.map((u) => {
      const d = n[u];
      return l += Object.keys(d).length, this._mapLoadToResolve(d, h).then((f) => {
        s[u] = f;
      });
    });
    return await Promise.all(c), i ? s[e[0]] : s;
  }
  /**
   * Initiate a background load of some assets. It will passively begin to load these assets in the background.
   * So when you actually come to loading them you will get a promise that resolves to the loaded assets immediately
   *
   * An example of this might be that you would background load game assets after your inital load.
   * then when you got to actually load your game screen assets when a player goes to the game - the loading
   * would already have stared or may even be complete, saving you having to show an interim load bar.
   * @example
   * import { Assets } from 'pixi.js';
   *
   * Assets.backgroundLoad('bunny.png');
   *
   * // later on in your app...
   * await Assets.loadBundle('bunny.png'); // Will resolve quicker as loading may have completed!
   * @param urls - the url / urls you want to background load
   */
  async backgroundLoad(e) {
    this._initialized || await this.init(), typeof e == "string" && (e = [e]);
    const t = this.resolver.resolve(e);
    this._backgroundLoader.add(Object.values(t));
  }
  /**
   * Initiate a background of a bundle, works exactly like backgroundLoad but for bundles.
   * this can only be used if the loader has been initiated with a manifest
   * @example
   * import { Assets } from 'pixi.js';
   *
   * await Assets.init({
   *     manifest: {
   *         bundles: [
   *             {
   *                 name: 'load-screen',
   *                 assets: [...],
   *             },
   *             ...
   *         ],
   *     },
   * });
   *
   * Assets.backgroundLoadBundle('load-screen');
   *
   * // Later on in your app...
   * await Assets.loadBundle('load-screen'); // Will resolve quicker as loading may have completed!
   * @param bundleIds - the bundleId / bundleIds you want to background load
   */
  async backgroundLoadBundle(e) {
    this._initialized || await this.init(), typeof e == "string" && (e = [e]);
    const t = this.resolver.resolveBundle(e);
    Object.values(t).forEach((i) => {
      this._backgroundLoader.add(Object.values(i));
    });
  }
  /**
   * Only intended for development purposes.
   * This will wipe the resolver and caches.
   * You will need to reinitialize the Asset
   */
  reset() {
    this.resolver.reset(), this.loader.reset(), this.cache.reset(), this._initialized = !1;
  }
  get(e) {
    if (typeof e == "string")
      return Rr.get(e);
    const t = {};
    for (let i = 0; i < e.length; i++)
      t[i] = Rr.get(e[i]);
    return t;
  }
  /**
   * helper function to map resolved assets back to loaded assets
   * @param resolveResults - the resolve results from the resolver
   * @param onProgress - the progress callback
   */
  async _mapLoadToResolve(e, t) {
    const i = Object.values(e), n = Object.keys(e);
    this._backgroundLoader.active = !1;
    const s = await this.loader.load(i, t);
    this._backgroundLoader.active = !0;
    const o = {};
    return i.forEach((a, l) => {
      const h = s[a.src], c = [a.src];
      a.alias && c.push(...a.alias), o[n[l]] = h, Rr.set(c, h);
    }), o;
  }
  /**
   * Unload an asset or assets. As the Assets class is responsible for creating the assets via the `load` function
   * this will make sure to destroy any assets and release them from memory.
   * Once unloaded, you will need to load the asset again.
   *
   * Use this to help manage assets if you find that you have a large app and you want to free up memory.
   *
   * - it's up to you as the developer to make sure that textures are not actively being used when you unload them,
   * Pixi won't break but you will end up with missing assets. Not a good look for the user!
   * @example
   * import { Assets } from 'pixi.js';
   *
   * // Load a URL:
   * const myImageTexture = await Assets.load('http://some.url.com/image.png'); // => returns a texture
   *
   * await Assets.unload('http://some.url.com/image.png')
   *
   * // myImageTexture will be destroyed now.
   *
   * // Unload multiple assets:
   * const textures = await Assets.unload(['thumper', 'chicko']);
   * @param urls - the urls to unload
   */
  async unload(e) {
    this._initialized || await this.init();
    const t = jt(e).map((n) => typeof n != "string" ? n.src : n), i = this.resolver.resolve(t);
    await this._unloadFromResolved(i);
  }
  /**
   * Bundles are a way to manage multiple assets at once.
   * this will unload all files in a bundle.
   *
   * once a bundle has been unloaded, you need to load it again to have access to the assets.
   * @example
   * import { Assets } from 'pixi.js';
   *
   * Assets.addBundle({
   *     'thumper': 'http://some.url.com/thumper.png',
   * })
   *
   * const assets = await Assets.loadBundle('thumper');
   *
   * // Now to unload...
   *
   * await Assets.unloadBundle('thumper');
   *
   * // All assets in the assets object will now have been destroyed and purged from the cache
   * @param bundleIds - the bundle id or ids to unload
   */
  async unloadBundle(e) {
    this._initialized || await this.init(), e = jt(e);
    const t = this.resolver.resolveBundle(e), i = Object.keys(t).map((n) => this._unloadFromResolved(t[n]));
    await Promise.all(i);
  }
  async _unloadFromResolved(e) {
    const t = Object.values(e);
    t.forEach((i) => {
      Rr.remove(i.src);
    }), await this.loader.unload(t);
  }
  /**
   * Detects the supported formats for the browser, and returns an array of supported formats, respecting
   * the users preferred formats order.
   * @param options - the options to use when detecting formats
   * @param options.preferredFormats - the preferred formats to use
   * @param options.skipDetections - if we should skip the detections altogether
   * @param options.detections - the detections to use
   * @returns - the detected formats
   */
  async _detectFormats(e) {
    let t = [];
    e.preferredFormats && (t = Array.isArray(e.preferredFormats) ? e.preferredFormats : [e.preferredFormats]);
    for (const i of e.detections)
      e.skipDetections || await i.test() ? t = await i.add(t) : e.skipDetections || (t = await i.remove(t));
    return t = t.filter((i, n) => t.indexOf(i) === n), t;
  }
  /** All the detection parsers currently added to the Assets class. */
  get detections() {
    return this._detections;
  }
  /**
   * @deprecated since 7.2.0
   * @see {@link Assets.setPreferences}
   */
  get preferWorkers() {
    return Oa.config.preferWorkers;
  }
  set preferWorkers(e) {
    fe("7.2.0", "Assets.prefersWorkers is deprecated, use Assets.setPreferences({ preferWorkers: true }) instead."), this.setPreferences({ preferWorkers: e });
  }
  /**
   * General setter for preferences. This is a helper function to set preferences on all parsers.
   * @param preferences - the preferences to set
   */
  setPreferences(e) {
    this.loader.parsers.forEach((t) => {
      t.config && Object.keys(t.config).filter((i) => i in e).forEach((i) => {
        t.config[i] = e[i];
      });
    });
  }
}
const uo = new a3();
Q.handleByList(q.LoadParser, uo.loader.parsers).handleByList(q.ResolveParser, uo.resolver.parsers).handleByList(q.CacheParser, uo.cache.parsers).handleByList(q.DetectionParser, uo.detections);
const l3 = {
  extension: q.CacheParser,
  test: (r) => Array.isArray(r) && r.every((e) => e instanceof J),
  getCacheableAssets: (r, e) => {
    const t = {};
    return r.forEach((i) => {
      e.forEach((n, s) => {
        t[i + (s === 0 ? "" : s + 1)] = n;
      });
    }), t;
  }
};
Q.add(l3);
async function _0(r) {
  if ("Image" in globalThis)
    return new Promise((e) => {
      const t = new Image();
      t.onload = () => {
        e(!0);
      }, t.onerror = () => {
        e(!1);
      }, t.src = r;
    });
  if ("createImageBitmap" in globalThis && "fetch" in globalThis) {
    try {
      const e = await (await fetch(r)).blob();
      await createImageBitmap(e);
    } catch {
      return !1;
    }
    return !0;
  }
  return !1;
}
const h3 = {
  extension: {
    type: q.DetectionParser,
    priority: 1
  },
  test: async () => _0(
    // eslint-disable-next-line max-len
    "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="
  ),
  add: async (r) => [...r, "avif"],
  remove: async (r) => r.filter((e) => e !== "avif")
};
Q.add(h3);
const c3 = {
  extension: {
    type: q.DetectionParser,
    priority: 0
  },
  test: async () => _0(
    "data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="
  ),
  add: async (r) => [...r, "webp"],
  remove: async (r) => r.filter((e) => e !== "webp")
};
Q.add(c3);
const Xf = ["png", "jpg", "jpeg"], u3 = {
  extension: {
    type: q.DetectionParser,
    priority: -1
  },
  test: () => Promise.resolve(!0),
  add: async (r) => [...r, ...Xf],
  remove: async (r) => r.filter((e) => !Xf.includes(e))
};
Q.add(u3);
const d3 = "WorkerGlobalScope" in globalThis && globalThis instanceof globalThis.WorkerGlobalScope;
function au(r) {
  return d3 ? !1 : document.createElement("video").canPlayType(r) !== "";
}
const f3 = {
  extension: {
    type: q.DetectionParser,
    priority: 0
  },
  test: async () => au("video/webm"),
  add: async (r) => [...r, "webm"],
  remove: async (r) => r.filter((e) => e !== "webm")
};
Q.add(f3);
const p3 = {
  extension: {
    type: q.DetectionParser,
    priority: 0
  },
  test: async () => au("video/mp4"),
  add: async (r) => [...r, "mp4", "m4v"],
  remove: async (r) => r.filter((e) => e !== "mp4" && e !== "m4v")
};
Q.add(p3);
const _3 = {
  extension: {
    type: q.DetectionParser,
    priority: 0
  },
  test: async () => au("video/ogg"),
  add: async (r) => [...r, "ogv"],
  remove: async (r) => r.filter((e) => e !== "ogv")
};
Q.add(_3);
const m3 = {
  extension: q.ResolveParser,
  test: Oa.test,
  parse: (r) => {
    var e;
    return {
      resolution: parseFloat(((e = Z.RETINA_PREFIX.exec(r)) == null ? void 0 : e[1]) ?? "1"),
      format: We.extname(r).slice(1),
      src: r
    };
  }
};
Q.add(m3);
var je = /* @__PURE__ */ ((r) => (r[r.COMPRESSED_RGB_S3TC_DXT1_EXT = 33776] = "COMPRESSED_RGB_S3TC_DXT1_EXT", r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT = 33777] = "COMPRESSED_RGBA_S3TC_DXT1_EXT", r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT = 33778] = "COMPRESSED_RGBA_S3TC_DXT3_EXT", r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT = 33779] = "COMPRESSED_RGBA_S3TC_DXT5_EXT", r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 35917] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 35918] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 35919] = "COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT = 35916] = "COMPRESSED_SRGB_S3TC_DXT1_EXT", r[r.COMPRESSED_R11_EAC = 37488] = "COMPRESSED_R11_EAC", r[r.COMPRESSED_SIGNED_R11_EAC = 37489] = "COMPRESSED_SIGNED_R11_EAC", r[r.COMPRESSED_RG11_EAC = 37490] = "COMPRESSED_RG11_EAC", r[r.COMPRESSED_SIGNED_RG11_EAC = 37491] = "COMPRESSED_SIGNED_RG11_EAC", r[r.COMPRESSED_RGB8_ETC2 = 37492] = "COMPRESSED_RGB8_ETC2", r[r.COMPRESSED_RGBA8_ETC2_EAC = 37496] = "COMPRESSED_RGBA8_ETC2_EAC", r[r.COMPRESSED_SRGB8_ETC2 = 37493] = "COMPRESSED_SRGB8_ETC2", r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 37497] = "COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37494] = "COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 37495] = "COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 35840] = "COMPRESSED_RGB_PVRTC_4BPPV1_IMG", r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 35842] = "COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 35841] = "COMPRESSED_RGB_PVRTC_2BPPV1_IMG", r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 35843] = "COMPRESSED_RGBA_PVRTC_2BPPV1_IMG", r[r.COMPRESSED_RGB_ETC1_WEBGL = 36196] = "COMPRESSED_RGB_ETC1_WEBGL", r[r.COMPRESSED_RGB_ATC_WEBGL = 35986] = "COMPRESSED_RGB_ATC_WEBGL", r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 35987] = "COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL", r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 34798] = "COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL", r[r.COMPRESSED_RGBA_ASTC_4x4_KHR = 37808] = "COMPRESSED_RGBA_ASTC_4x4_KHR", r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492] = "COMPRESSED_RGBA_BPTC_UNORM_EXT", r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 36493] = "COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT", r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 36494] = "COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT", r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 36495] = "COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT", r))(je || {});
const pa = {
  // WEBGL_compressed_texture_s3tc
  33776: 0.5,
  33777: 0.5,
  33778: 1,
  33779: 1,
  // WEBGL_compressed_texture_s3tc
  35916: 0.5,
  35917: 0.5,
  35918: 1,
  35919: 1,
  // WEBGL_compressed_texture_etc
  37488: 0.5,
  37489: 0.5,
  37490: 1,
  37491: 1,
  37492: 0.5,
  37496: 1,
  37493: 0.5,
  37497: 1,
  37494: 0.5,
  // ~~
  37495: 0.5,
  // ~~
  // WEBGL_compressed_texture_pvrtc
  35840: 0.5,
  35842: 0.5,
  35841: 0.25,
  35843: 0.25,
  // WEBGL_compressed_texture_etc1
  36196: 0.5,
  // @see https://www.khronos.org/registry/OpenGL/extensions/AMD/AMD_compressed_ATC_texture.txt
  // WEBGL_compressed_texture_atc
  35986: 0.5,
  35987: 1,
  34798: 1,
  // @see https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
  // WEBGL_compressed_texture_astc
  /* eslint-disable-next-line camelcase */
  37808: 1,
  // @see https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
  // EXT_texture_compression_bptc
  36492: 1,
  36493: 1,
  36494: 1,
  36495: 1
};
let oi, _n;
function Vf() {
  _n = {
    bptc: oi.getExtension("EXT_texture_compression_bptc"),
    astc: oi.getExtension("WEBGL_compressed_texture_astc"),
    etc: oi.getExtension("WEBGL_compressed_texture_etc"),
    s3tc: oi.getExtension("WEBGL_compressed_texture_s3tc"),
    s3tc_sRGB: oi.getExtension("WEBGL_compressed_texture_s3tc_srgb"),
    /* eslint-disable-line camelcase */
    pvrtc: oi.getExtension("WEBGL_compressed_texture_pvrtc") || oi.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
    etc1: oi.getExtension("WEBGL_compressed_texture_etc1"),
    atc: oi.getExtension("WEBGL_compressed_texture_atc")
  };
}
const g3 = {
  extension: {
    type: q.DetectionParser,
    priority: 2
  },
  test: async () => {
    const r = Z.ADAPTER.createCanvas().getContext("webgl");
    return r ? (oi = r, !0) : (console.warn("WebGL not available for compressed textures."), !1);
  },
  add: async (r) => {
    _n || Vf();
    const e = [];
    for (const t in _n)
      _n[t] && e.push(t);
    return [...e, ...r];
  },
  remove: async (r) => (_n || Vf(), r.filter((e) => !(e in _n)))
};
Q.add(g3);
class y3 extends Ma {
  /**
   * @param source - The buffer/URL of the texture file.
   * @param {PIXI.IBlobResourceOptions} [options]
   * @param {boolean} [options.autoLoad=false] - Whether to fetch the data immediately;
   *  you can fetch it later via {@link PIXI.BlobResource#load}.
   * @param {number} [options.width=1] - The width in pixels.
   * @param {number} [options.height=1] - The height in pixels.
   * @param {1|2|4|8} [options.unpackAlignment=4] - The alignment of the pixel rows.
   */
  constructor(e, t = { width: 1, height: 1, autoLoad: !0 }) {
    let i, n;
    typeof e == "string" ? (i = e, n = new Uint8Array()) : (i = null, n = e), super(n, t), this.origin = i, this.buffer = n ? new ec(n) : null, this._load = null, this.loaded = !1, this.origin !== null && t.autoLoad !== !1 && this.load(), this.origin === null && this.buffer && (this._load = Promise.resolve(this), this.loaded = !0, this.onBlobLoaded(this.buffer.rawBinaryData));
  }
  onBlobLoaded(e) {
  }
  /** Loads the blob */
  load() {
    return this._load ? this._load : (this._load = fetch(this.origin).then((e) => e.blob()).then((e) => e.arrayBuffer()).then((e) => (this.data = new Uint32Array(e), this.buffer = new ec(e), this.loaded = !0, this.onBlobLoaded(e), this.update(), this)), this._load);
  }
}
class Br extends y3 {
  /**
   * @param source - the buffer/URL holding the compressed texture data
   * @param options
   * @param {PIXI.INTERNAL_FORMATS} options.format - the compression format
   * @param {number} options.width - the image width in pixels.
   * @param {number} options.height - the image height in pixels.
   * @param {number} [options.level=1] - the mipmap levels stored in the compressed texture, including level 0.
   * @param {number} [options.levelBuffers] - the buffers for each mipmap level. `CompressedTextureResource` can allows you
   *      to pass `null` for `source`, for cases where each level is stored in non-contiguous memory.
   */
  constructor(e, t) {
    super(e, t), this.format = t.format, this.levels = t.levels || 1, this._width = t.width, this._height = t.height, this._extension = Br._formatToExtension(this.format), (t.levelBuffers || this.buffer) && (this._levelBuffers = t.levelBuffers || Br._createLevelBuffers(
      e instanceof Uint8Array ? e : this.buffer.uint8View,
      this.format,
      this.levels,
      4,
      4,
      // PVRTC has 8x4 blocks in 2bpp mode
      this.width,
      this.height
    ));
  }
  /**
   * @override
   * @param renderer - A reference to the current renderer
   * @param _texture - the texture
   * @param _glTexture - texture instance for this webgl context
   */
  upload(e, t, i) {
    const n = e.gl;
    if (!e.context.extensions[this._extension])
      throw new Error(`${this._extension} textures are not supported on the current machine`);
    if (!this._levelBuffers)
      return !1;
    n.pixelStorei(n.UNPACK_ALIGNMENT, 4);
    for (let s = 0, o = this.levels; s < o; s++) {
      const { levelID: a, levelWidth: l, levelHeight: h, levelBuffer: c } = this._levelBuffers[s];
      n.compressedTexImage2D(n.TEXTURE_2D, a, this.format, l, h, 0, c);
    }
    return !0;
  }
  /** @protected */
  onBlobLoaded() {
    this._levelBuffers = Br._createLevelBuffers(
      this.buffer.uint8View,
      this.format,
      this.levels,
      4,
      4,
      // PVRTC has 8x4 blocks in 2bpp mode
      this.width,
      this.height
    );
  }
  /**
   * Returns the key (to ContextSystem#extensions) for the WebGL extension supporting the compression format
   * @private
   * @param format - the compression format to get the extension for.
   */
  static _formatToExtension(e) {
    if (e >= 33776 && e <= 33779)
      return "s3tc";
    if (e >= 35916 && e <= 35919)
      return "s3tc_sRGB";
    if (e >= 37488 && e <= 37497)
      return "etc";
    if (e >= 35840 && e <= 35843)
      return "pvrtc";
    if (e === 36196)
      return "etc1";
    if (e === 35986 || e === 35987 || e === 34798)
      return "atc";
    if (e >= 36492 && e <= 36495)
      return "bptc";
    if (e === 37808)
      return "astc";
    throw new Error(`Invalid (compressed) texture format given: ${e}`);
  }
  /**
   * Pre-creates buffer views for each mipmap level
   * @private
   * @param buffer -
   * @param format - compression formats
   * @param levels - mipmap levels
   * @param blockWidth -
   * @param blockHeight -
   * @param imageWidth - width of the image in pixels
   * @param imageHeight - height of the image in pixels
   */
  static _createLevelBuffers(e, t, i, n, s, o, a) {
    const l = new Array(i);
    let h = e.byteOffset, c = o, u = a, d = c + n - 1 & ~(n - 1), f = u + s - 1 & ~(s - 1), p = d * f * pa[t];
    for (let _ = 0; _ < i; _++)
      l[_] = {
        levelID: _,
        levelWidth: i > 1 ? c : d,
        levelHeight: i > 1 ? u : f,
        levelBuffer: new Uint8Array(e.buffer, h, p)
      }, h += p, c = c >> 1 || 1, u = u >> 1 || 1, d = c + n - 1 & ~(n - 1), f = u + s - 1 & ~(s - 1), p = d * f * pa[t];
    return l;
  }
}
const rh = 4, fo = 124, v3 = 32, Wf = 20, b3 = 542327876, po = {
  SIZE: 1,
  FLAGS: 2,
  HEIGHT: 3,
  WIDTH: 4,
  MIPMAP_COUNT: 7,
  PIXEL_FORMAT: 19
}, w3 = {
  SIZE: 0,
  FLAGS: 1,
  FOURCC: 2,
  RGB_BITCOUNT: 3,
  R_BIT_MASK: 4,
  G_BIT_MASK: 5,
  B_BIT_MASK: 6,
  A_BIT_MASK: 7
}, _o = {
  DXGI_FORMAT: 0,
  RESOURCE_DIMENSION: 1,
  MISC_FLAG: 2,
  ARRAY_SIZE: 3,
  MISC_FLAGS2: 4
}, x3 = 1, E3 = 2, T3 = 4, A3 = 64, S3 = 512, C3 = 131072, I3 = 827611204, R3 = 861165636, P3 = 894720068, M3 = 808540228, k3 = 4, D3 = {
  [I3]: je.COMPRESSED_RGBA_S3TC_DXT1_EXT,
  [R3]: je.COMPRESSED_RGBA_S3TC_DXT3_EXT,
  [P3]: je.COMPRESSED_RGBA_S3TC_DXT5_EXT
}, B3 = {
  // WEBGL_compressed_texture_s3tc
  70: je.COMPRESSED_RGBA_S3TC_DXT1_EXT,
  71: je.COMPRESSED_RGBA_S3TC_DXT1_EXT,
  73: je.COMPRESSED_RGBA_S3TC_DXT3_EXT,
  74: je.COMPRESSED_RGBA_S3TC_DXT3_EXT,
  76: je.COMPRESSED_RGBA_S3TC_DXT5_EXT,
  77: je.COMPRESSED_RGBA_S3TC_DXT5_EXT,
  // WEBGL_compressed_texture_s3tc_srgb
  72: je.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
  75: je.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
  78: je.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
  // EXT_texture_compression_bptc
  // BC6H
  96: je.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
  95: je.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
  // BC7
  98: je.COMPRESSED_RGBA_BPTC_UNORM_EXT,
  99: je.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT
};
function F3(r) {
  const e = new Uint32Array(r);
  if (e[0] !== b3)
    throw new Error("Invalid DDS file magic word");
  const t = new Uint32Array(r, 0, fo / Uint32Array.BYTES_PER_ELEMENT), i = t[po.HEIGHT], n = t[po.WIDTH], s = t[po.MIPMAP_COUNT], o = new Uint32Array(
    r,
    po.PIXEL_FORMAT * Uint32Array.BYTES_PER_ELEMENT,
    v3 / Uint32Array.BYTES_PER_ELEMENT
  ), a = o[x3];
  if (a & T3) {
    const l = o[w3.FOURCC];
    if (l !== M3) {
      const v = D3[l], g = rh + fo, b = new Uint8Array(r, g);
      return [new Br(b, {
        format: v,
        width: n,
        height: i,
        levels: s
        // CompressedTextureResource will separate the levelBuffers for us!
      })];
    }
    const h = rh + fo, c = new Uint32Array(
      e.buffer,
      h,
      Wf / Uint32Array.BYTES_PER_ELEMENT
    ), u = c[_o.DXGI_FORMAT], d = c[_o.RESOURCE_DIMENSION], f = c[_o.MISC_FLAG], p = c[_o.ARRAY_SIZE], _ = B3[u];
    if (_ === void 0)
      throw new Error(`DDSParser cannot parse texture data with DXGI format ${u}`);
    if (f === k3)
      throw new Error("DDSParser does not support cubemap textures");
    if (d === 6)
      throw new Error("DDSParser does not supported 3D texture data");
    const m = new Array(), y = rh + fo + Wf;
    if (p === 1)
      m.push(new Uint8Array(r, y));
    else {
      const v = pa[_];
      let g = 0, b = n, w = i;
      for (let x = 0; x < s; x++) {
        const E = Math.max(1, b + 3 & -4), R = Math.max(1, w + 3 & -4), k = E * R * v;
        g += k, b = b >>> 1, w = w >>> 1;
      }
      let T = y;
      for (let x = 0; x < p; x++)
        m.push(new Uint8Array(r, T, g)), T += g;
    }
    return m.map((v) => new Br(v, {
      format: _,
      width: n,
      height: i,
      levels: s
    }));
  }
  throw a & A3 ? new Error("DDSParser does not support uncompressed texture data.") : a & S3 ? new Error("DDSParser does not supported YUV uncompressed texture data.") : a & C3 ? new Error("DDSParser does not support single-channel (lumninance) texture data!") : a & E3 ? new Error("DDSParser does not support single-channel (alpha) texture data!") : new Error("DDSParser failed to load a texture file due to an unknown reason!");
}
const jf = [171, 75, 84, 88, 32, 49, 49, 187, 13, 10, 26, 10], O3 = 67305985, Ht = {
  FILE_IDENTIFIER: 0,
  ENDIANNESS: 12,
  GL_TYPE: 16,
  GL_TYPE_SIZE: 20,
  GL_FORMAT: 24,
  GL_INTERNAL_FORMAT: 28,
  GL_BASE_INTERNAL_FORMAT: 32,
  PIXEL_WIDTH: 36,
  PIXEL_HEIGHT: 40,
  PIXEL_DEPTH: 44,
  NUMBER_OF_ARRAY_ELEMENTS: 48,
  NUMBER_OF_FACES: 52,
  NUMBER_OF_MIPMAP_LEVELS: 56,
  BYTES_OF_KEY_VALUE_DATA: 60
}, Ac = 64, qf = {
  [re.UNSIGNED_BYTE]: 1,
  [re.UNSIGNED_SHORT]: 2,
  [re.INT]: 4,
  [re.UNSIGNED_INT]: 4,
  [re.FLOAT]: 4,
  [re.HALF_FLOAT]: 8
}, L3 = {
  [G.RGBA]: 4,
  [G.RGB]: 3,
  [G.RG]: 2,
  [G.RED]: 1,
  [G.LUMINANCE]: 1,
  [G.LUMINANCE_ALPHA]: 2,
  [G.ALPHA]: 1
}, N3 = {
  [re.UNSIGNED_SHORT_4_4_4_4]: 2,
  [re.UNSIGNED_SHORT_5_5_5_1]: 2,
  [re.UNSIGNED_SHORT_5_6_5]: 2
};
function U3(r, e, t = !1) {
  const i = new DataView(e);
  if (!G3(r, i))
    return null;
  const n = i.getUint32(Ht.ENDIANNESS, !0) === O3, s = i.getUint32(Ht.GL_TYPE, n), o = i.getUint32(Ht.GL_FORMAT, n), a = i.getUint32(Ht.GL_INTERNAL_FORMAT, n), l = i.getUint32(Ht.PIXEL_WIDTH, n), h = i.getUint32(Ht.PIXEL_HEIGHT, n) || 1, c = i.getUint32(Ht.PIXEL_DEPTH, n) || 1, u = i.getUint32(Ht.NUMBER_OF_ARRAY_ELEMENTS, n) || 1, d = i.getUint32(Ht.NUMBER_OF_FACES, n), f = i.getUint32(Ht.NUMBER_OF_MIPMAP_LEVELS, n), p = i.getUint32(Ht.BYTES_OF_KEY_VALUE_DATA, n);
  if (h === 0 || c !== 1)
    throw new Error("Only 2D textures are supported");
  if (d !== 1)
    throw new Error("CubeTextures are not supported by KTXLoader yet!");
  if (u !== 1)
    throw new Error("WebGL does not support array textures");
  const _ = 4, m = 4, y = l + 3 & -4, v = h + 3 & -4, g = new Array(u);
  let b = l * h;
  s === 0 && (b = y * v);
  let w;
  if (s !== 0 ? qf[s] ? w = qf[s] * L3[o] : w = N3[s] : w = pa[a], w === void 0)
    throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");
  const T = t ? z3(i, p, n) : null;
  let x = b * w, E = l, R = h, k = y, O = v, B = Ac + p;
  for (let C = 0; C < f; C++) {
    const M = i.getUint32(B, n);
    let F = B + 4;
    for (let U = 0; U < u; U++) {
      let L = g[U];
      L || (L = g[U] = new Array(f)), L[C] = {
        levelID: C,
        // don't align mipWidth when texture not compressed! (glType not zero)
        levelWidth: f > 1 || s !== 0 ? E : k,
        levelHeight: f > 1 || s !== 0 ? R : O,
        levelBuffer: new Uint8Array(e, F, x)
      }, F += x;
    }
    B += M + 4, B = B % 4 !== 0 ? B + 4 - B % 4 : B, E = E >> 1 || 1, R = R >> 1 || 1, k = E + _ - 1 & ~(_ - 1), O = R + m - 1 & ~(m - 1), x = k * O * w;
  }
  return s !== 0 ? {
    uncompressed: g.map((C) => {
      let M = C[0].levelBuffer, F = !1;
      return s === re.FLOAT ? M = new Float32Array(
        C[0].levelBuffer.buffer,
        C[0].levelBuffer.byteOffset,
        C[0].levelBuffer.byteLength / 4
      ) : s === re.UNSIGNED_INT ? (F = !0, M = new Uint32Array(
        C[0].levelBuffer.buffer,
        C[0].levelBuffer.byteOffset,
        C[0].levelBuffer.byteLength / 4
      )) : s === re.INT && (F = !0, M = new Int32Array(
        C[0].levelBuffer.buffer,
        C[0].levelBuffer.byteOffset,
        C[0].levelBuffer.byteLength / 4
      )), {
        resource: new Ma(
          M,
          {
            width: C[0].levelWidth,
            height: C[0].levelHeight
          }
        ),
        type: s,
        format: F ? H3(o) : o
      };
    }),
    kvData: T
  } : {
    compressed: g.map((C) => new Br(null, {
      format: a,
      width: l,
      height: h,
      levels: f,
      levelBuffers: C
    })),
    kvData: T
  };
}
function G3(r, e) {
  for (let t = 0; t < jf.length; t++)
    if (e.getUint8(t) !== jf[t])
      return console.error(`${r} is not a valid *.ktx file!`), !1;
  return !0;
}
function H3(r) {
  switch (r) {
    case G.RGBA:
      return G.RGBA_INTEGER;
    case G.RGB:
      return G.RGB_INTEGER;
    case G.RG:
      return G.RG_INTEGER;
    case G.RED:
      return G.RED_INTEGER;
    default:
      return r;
  }
}
function z3(r, e, t) {
  const i = /* @__PURE__ */ new Map();
  let n = 0;
  for (; n < e; ) {
    const s = r.getUint32(Ac + n, t), o = Ac + n + 4, a = 3 - (s + 3) % 4;
    if (s === 0 || s > e - n) {
      console.error("KTXLoader: keyAndValueByteSize out of bounds");
      break;
    }
    let l = 0;
    for (; l < s && r.getUint8(o + l) !== 0; l++)
      ;
    if (l === -1) {
      console.error("KTXLoader: Failed to find null byte terminating kvData key");
      break;
    }
    const h = new TextDecoder().decode(
      new Uint8Array(r.buffer, o, l)
    ), c = new DataView(
      r.buffer,
      o + l + 1,
      s - l - 1
    );
    i.set(h, c), n += 4 + s + a;
  }
  return i;
}
const X3 = {
  extension: {
    type: q.LoadParser,
    priority: Qt.High
  },
  name: "loadDDS",
  test(r) {
    return cr(r, ".dds");
  },
  async load(r, e, t) {
    const i = await (await Z.ADAPTER.fetch(r)).arrayBuffer(), n = F3(i).map((s) => {
      const o = new ae(s, {
        mipmap: gi.OFF,
        alphaMode: ut.NO_PREMULTIPLIED_ALPHA,
        resolution: Di(r),
        ...e.data
      });
      return Us(o, t, r);
    });
    return n.length === 1 ? n[0] : n;
  },
  unload(r) {
    Array.isArray(r) ? r.forEach((e) => e.destroy(!0)) : r.destroy(!0);
  }
};
Q.add(X3);
const V3 = {
  extension: {
    type: q.LoadParser,
    priority: Qt.High
  },
  name: "loadKTX",
  test(r) {
    return cr(r, ".ktx");
  },
  async load(r, e, t) {
    const i = await (await Z.ADAPTER.fetch(r)).arrayBuffer(), { compressed: n, uncompressed: s, kvData: o } = U3(r, i), a = n ?? s, l = {
      mipmap: gi.OFF,
      alphaMode: ut.NO_PREMULTIPLIED_ALPHA,
      resolution: Di(r),
      ...e.data
    }, h = a.map((c) => {
      a === s && Object.assign(l, {
        type: c.type,
        format: c.format
      });
      const u = c.resource ?? c, d = new ae(u, l);
      return d.ktxKeyValueData = o, Us(d, t, r);
    });
    return h.length === 1 ? h[0] : h;
  },
  unload(r) {
    Array.isArray(r) ? r.forEach((e) => e.destroy(!0)) : r.destroy(!0);
  }
};
Q.add(V3);
const W3 = ["s3tc", "s3tc_sRGB", "etc", "etc1", "pvrtc", "atc", "astc", "bptc"], j3 = {
  extension: q.ResolveParser,
  test: (r) => {
    const e = We.extname(r).slice(1);
    return ["basis", "ktx", "dds"].includes(e);
  },
  parse: (r) => {
    var i, n;
    const e = r.split("."), t = e.pop();
    if (["ktx", "dds"].includes(t)) {
      const s = e.pop();
      if (W3.includes(s))
        return {
          resolution: parseFloat(((i = Z.RETINA_PREFIX.exec(r)) == null ? void 0 : i[1]) ?? "1"),
          format: s,
          src: r
        };
    }
    return {
      resolution: parseFloat(((n = Z.RETINA_PREFIX.exec(r)) == null ? void 0 : n[1]) ?? "1"),
      format: t,
      src: r
    };
  }
};
Q.add(j3);
const mo = new le(), q3 = 4, m0 = class ds {
  /**
   * @param renderer - A reference to the current renderer
   */
  constructor(e) {
    this.renderer = e, this._rendererPremultipliedAlpha = !1;
  }
  contextChange() {
    var t;
    const e = (t = this.renderer) == null ? void 0 : t.gl.getContextAttributes();
    this._rendererPremultipliedAlpha = !!(e && e.alpha && e.premultipliedAlpha);
  }
  /**
   * Will return a HTML Image of the target
   * @param target - A displayObject or renderTexture
   *  to convert. If left empty will use the main renderer
   * @param format - Image format, e.g. "image/jpeg" or "image/webp".
   * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92.
   * @param frame - The frame the extraction is restricted to.
   * @returns - HTML Image of the target
   */
  async image(e, t, i, n) {
    const s = new Image();
    return s.src = await this.base64(e, t, i, n), s;
  }
  /**
   * Will return a base64 encoded string of this target. It works by calling
   *  `Extract.canvas` and then running toDataURL on that.
   * @param target - A displayObject or renderTexture
   *  to convert. If left empty will use the main renderer
   * @param format - Image format, e.g. "image/jpeg" or "image/webp".
   * @param quality - JPEG or Webp compression from 0 to 1. Default is 0.92.
   * @param frame - The frame the extraction is restricted to.
   * @returns - A base64 encoded string of the texture.
   */
  async base64(e, t, i, n) {
    const s = this.canvas(e, n);
    if (s.toBlob !== void 0)
      return new Promise((o, a) => {
        s.toBlob((l) => {
          if (!l) {
            a(new Error("ICanvas.toBlob failed!"));
            return;
          }
          const h = new FileReader();
          h.onload = () => o(h.result), h.onerror = a, h.readAsDataURL(l);
        }, t, i);
      });
    if (s.toDataURL !== void 0)
      return s.toDataURL(t, i);
    if (s.convertToBlob !== void 0) {
      const o = await s.convertToBlob({ type: t, quality: i });
      return new Promise((a, l) => {
        const h = new FileReader();
        h.onload = () => a(h.result), h.onerror = l, h.readAsDataURL(o);
      });
    }
    throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented");
  }
  /**
   * Creates a Canvas element, renders this target to it and then returns it.
   * @param target - A displayObject or renderTexture
   *  to convert. If left empty will use the main renderer
   * @param frame - The frame the extraction is restricted to.
   * @returns - A Canvas element with the texture rendered on.
   */
  canvas(e, t) {
    const { pixels: i, width: n, height: s, flipY: o, premultipliedAlpha: a } = this._rawPixels(e, t);
    o && ds._flipY(i, n, s), a && ds._unpremultiplyAlpha(i);
    const l = new CA(n, s, 1), h = new ImageData(new Uint8ClampedArray(i.buffer), n, s);
    return l.context.putImageData(h, 0, 0), l.canvas;
  }
  /**
   * Will return a one-dimensional array containing the pixel data of the entire texture in RGBA
   * order, with integer values between 0 and 255 (included).
   * @param target - A displayObject or renderTexture
   *  to convert. If left empty will use the main renderer
   * @param frame - The frame the extraction is restricted to.
   * @returns - One-dimensional array containing the pixel data of the entire texture
   */
  pixels(e, t) {
    const { pixels: i, width: n, height: s, flipY: o, premultipliedAlpha: a } = this._rawPixels(e, t);
    return o && ds._flipY(i, n, s), a && ds._unpremultiplyAlpha(i), i;
  }
  _rawPixels(e, t) {
    const i = this.renderer;
    if (!i)
      throw new Error("The Extract has already been destroyed");
    let n, s = !1, o = !1, a, l = !1;
    e && (e instanceof et ? a = e : (a = i.generateTexture(e, {
      region: t,
      resolution: i.resolution,
      multisample: i.multisample
    }), l = !0, t && (mo.width = t.width, mo.height = t.height, t = mo)));
    const h = i.gl;
    if (a) {
      if (n = a.baseTexture.resolution, t = t ?? a.frame, s = !1, o = a.baseTexture.alphaMode > 0 && a.baseTexture.format === G.RGBA, !l) {
        i.renderTexture.bind(a);
        const f = a.framebuffer.glFramebuffers[i.CONTEXT_UID];
        f.blitFramebuffer && i.framebuffer.bind(f.blitFramebuffer);
      }
    } else
      n = i.resolution, t || (t = mo, t.width = i.width / n, t.height = i.height / n), s = !0, o = this._rendererPremultipliedAlpha, i.renderTexture.bind();
    const c = Math.max(Math.round(t.width * n), 1), u = Math.max(Math.round(t.height * n), 1), d = new Uint8Array(q3 * c * u);
    return h.readPixels(
      Math.round(t.x * n),
      Math.round(t.y * n),
      c,
      u,
      h.RGBA,
      h.UNSIGNED_BYTE,
      d
    ), l && (a == null || a.destroy(!0)), { pixels: d, width: c, height: u, flipY: s, premultipliedAlpha: o };
  }
  /** Destroys the extract. */
  destroy() {
    this.renderer = null;
  }
  static _flipY(e, t, i) {
    const n = t << 2, s = i >> 1, o = new Uint8Array(n);
    for (let a = 0; a < s; a++) {
      const l = a * n, h = (i - a - 1) * n;
      o.set(e.subarray(l, l + n)), e.copyWithin(l, h, h + n), e.set(o, h);
    }
  }
  static _unpremultiplyAlpha(e) {
    e instanceof Uint8ClampedArray && (e = new Uint8Array(e.buffer));
    const t = e.length;
    for (let i = 0; i < t; i += 4) {
      const n = e[i + 3];
      if (n !== 0) {
        const s = 255.001 / n;
        e[i] = e[i] * s + 0.5, e[i + 1] = e[i + 1] * s + 0.5, e[i + 2] = e[i + 2] * s + 0.5;
      }
    }
  }
};
m0.extension = {
  name: "extract",
  type: q.RendererSystem
};
let Y3 = m0;
Q.add(Y3);
const _a = {
  build(r) {
    const e = r.points;
    let t, i, n, s, o, a;
    if (r.type === Ye.CIRC) {
      const p = r.shape;
      t = p.x, i = p.y, o = a = p.radius, n = s = 0;
    } else if (r.type === Ye.ELIP) {
      const p = r.shape;
      t = p.x, i = p.y, o = p.width, a = p.height, n = s = 0;
    } else {
      const p = r.shape, _ = p.width / 2, m = p.height / 2;
      t = p.x + _, i = p.y + m, o = a = Math.max(0, Math.min(p.radius, Math.min(_, m))), n = _ - o, s = m - a;
    }
    if (!(o >= 0 && a >= 0 && n >= 0 && s >= 0)) {
      e.length = 0;
      return;
    }
    const l = Math.ceil(2.3 * Math.sqrt(o + a)), h = l * 8 + (n ? 4 : 0) + (s ? 4 : 0);
    if (e.length = h, h === 0)
      return;
    if (l === 0) {
      e.length = 8, e[0] = e[6] = t + n, e[1] = e[3] = i + s, e[2] = e[4] = t - n, e[5] = e[7] = i - s;
      return;
    }
    let c = 0, u = l * 4 + (n ? 2 : 0) + 2, d = u, f = h;
    {
      const p = n + o, _ = s, m = t + p, y = t - p, v = i + _;
      if (e[c++] = m, e[c++] = v, e[--u] = v, e[--u] = y, s) {
        const g = i - _;
        e[d++] = y, e[d++] = g, e[--f] = g, e[--f] = m;
      }
    }
    for (let p = 1; p < l; p++) {
      const _ = Math.PI / 2 * (p / l), m = n + Math.cos(_) * o, y = s + Math.sin(_) * a, v = t + m, g = t - m, b = i + y, w = i - y;
      e[c++] = v, e[c++] = b, e[--u] = b, e[--u] = g, e[d++] = g, e[d++] = w, e[--f] = w, e[--f] = v;
    }
    {
      const p = n, _ = s + a, m = t + p, y = t - p, v = i + _, g = i - _;
      e[c++] = m, e[c++] = v, e[--f] = g, e[--f] = m, n && (e[c++] = y, e[c++] = v, e[--f] = g, e[--f] = y);
    }
  },
  triangulate(r, e) {
    const t = r.points, i = e.points, n = e.indices;
    if (t.length === 0)
      return;
    let s = i.length / 2;
    const o = s;
    let a, l;
    if (r.type !== Ye.RREC) {
      const c = r.shape;
      a = c.x, l = c.y;
    } else {
      const c = r.shape;
      a = c.x + c.width / 2, l = c.y + c.height / 2;
    }
    const h = r.matrix;
    i.push(
      r.matrix ? h.a * a + h.c * l + h.tx : a,
      r.matrix ? h.b * a + h.d * l + h.ty : l
    ), s++, i.push(t[0], t[1]);
    for (let c = 2; c < t.length; c += 2)
      i.push(t[c], t[c + 1]), n.push(s++, o, s);
    n.push(o + 1, o, s);
  }
};
function Yf(r, e = !1) {
  const t = r.length;
  if (t < 6)
    return;
  let i = 0;
  for (let n = 0, s = r[t - 2], o = r[t - 1]; n < t; n += 2) {
    const a = r[n], l = r[n + 1];
    i += (a - s) * (l + o), s = a, o = l;
  }
  if (!e && i > 0 || e && i <= 0) {
    const n = t / 2;
    for (let s = n + n % 2; s < t; s += 2) {
      const o = t - s - 2, a = t - s - 1, l = s, h = s + 1;
      [r[o], r[l]] = [r[l], r[o]], [r[a], r[h]] = [r[h], r[a]];
    }
  }
}
const g0 = {
  build(r) {
    r.points = r.shape.points.slice();
  },
  triangulate(r, e) {
    let t = r.points;
    const i = r.holes, n = e.points, s = e.indices;
    if (t.length >= 6) {
      Yf(t, !1);
      const o = [];
      for (let h = 0; h < i.length; h++) {
        const c = i[h];
        Yf(c.points, !0), o.push(t.length / 2), t = t.concat(c.points);
      }
      const a = k2(t, o, 2);
      if (!a)
        return;
      const l = n.length / 2;
      for (let h = 0; h < a.length; h += 3)
        s.push(a[h] + l), s.push(a[h + 1] + l), s.push(a[h + 2] + l);
      for (let h = 0; h < t.length; h++)
        n.push(t[h]);
    }
  }
}, K3 = {
  build(r) {
    const e = r.shape, t = e.x, i = e.y, n = e.width, s = e.height, o = r.points;
    o.length = 0, n >= 0 && s >= 0 && o.push(
      t,
      i,
      t + n,
      i,
      t + n,
      i + s,
      t,
      i + s
    );
  },
  triangulate(r, e) {
    const t = r.points, i = e.points;
    if (t.length === 0)
      return;
    const n = i.length / 2;
    i.push(
      t[0],
      t[1],
      t[2],
      t[3],
      t[6],
      t[7],
      t[4],
      t[5]
    ), e.indices.push(
      n,
      n + 1,
      n + 2,
      n + 1,
      n + 2,
      n + 3
    );
  }
}, Z3 = {
  build(r) {
    _a.build(r);
  },
  triangulate(r, e) {
    _a.triangulate(r, e);
  }
};
var It = /* @__PURE__ */ ((r) => (r.MITER = "miter", r.BEVEL = "bevel", r.ROUND = "round", r))(It || {}), $i = /* @__PURE__ */ ((r) => (r.BUTT = "butt", r.ROUND = "round", r.SQUARE = "square", r))($i || {});
const Nn = {
  adaptive: !0,
  maxLength: 10,
  minSegments: 8,
  maxSegments: 2048,
  epsilon: 1e-4,
  _segmentsCount(r, e = 20) {
    if (!this.adaptive || !r || isNaN(r))
      return e;
    let t = Math.ceil(r / this.maxLength);
    return t < this.minSegments ? t = this.minSegments : t > this.maxSegments && (t = this.maxSegments), t;
  }
};
class Kf {
  /**
   * Calculate information of the arc for {@link PIXI.Graphics.arcTo}.
   * @private
   * @param x1 - The x-coordinate of the first control point of the arc
   * @param y1 - The y-coordinate of the first control point of the arc
   * @param x2 - The x-coordinate of the second control point of the arc
   * @param y2 - The y-coordinate of the second control point of the arc
   * @param radius - The radius of the arc
   * @param points - Collection of points to add to
   * @returns - If the arc length is valid, return center of circle, radius and other info otherwise `null`.
   */
  static curveTo(e, t, i, n, s, o) {
    const a = o[o.length - 2], l = o[o.length - 1] - t, h = a - e, c = n - t, u = i - e, d = Math.abs(l * u - h * c);
    if (d < 1e-8 || s === 0)
      return (o[o.length - 2] !== e || o[o.length - 1] !== t) && o.push(e, t), null;
    const f = l * l + h * h, p = c * c + u * u, _ = l * c + h * u, m = s * Math.sqrt(f) / d, y = s * Math.sqrt(p) / d, v = m * _ / f, g = y * _ / p, b = m * u + y * h, w = m * c + y * l, T = h * (y + v), x = l * (y + v), E = u * (m + g), R = c * (m + g), k = Math.atan2(x - w, T - b), O = Math.atan2(R - w, E - b);
    return {
      cx: b + e,
      cy: w + t,
      radius: s,
      startAngle: k,
      endAngle: O,
      anticlockwise: h * c > u * l
    };
  }
  /**
   * The arc method creates an arc/curve (used to create circles, or parts of circles).
   * @private
   * @param _startX - Start x location of arc
   * @param _startY - Start y location of arc
   * @param cx - The x-coordinate of the center of the circle
   * @param cy - The y-coordinate of the center of the circle
   * @param radius - The radius of the circle
   * @param startAngle - The starting angle, in radians (0 is at the 3 o'clock position
   *  of the arc's circle)
   * @param endAngle - The ending angle, in radians
   * @param _anticlockwise - Specifies whether the drawing should be
   *  counter-clockwise or clockwise. False is default, and indicates clockwise, while true
   *  indicates counter-clockwise.
   * @param points - Collection of points to add to
   */
  static arc(e, t, i, n, s, o, a, l, h) {
    const c = a - o, u = Nn._segmentsCount(
      Math.abs(c) * s,
      Math.ceil(Math.abs(c) / oa) * 40
    ), d = c / (u * 2), f = d * 2, p = Math.cos(d), _ = Math.sin(d), m = u - 1, y = m % 1 / m;
    for (let v = 0; v <= m; ++v) {
      const g = v + y * v, b = d + o + f * g, w = Math.cos(b), T = -Math.sin(b);
      h.push(
        (p * w + _ * T) * s + i,
        (p * -T + _ * w) * s + n
      );
    }
  }
}
class $3 {
  constructor() {
    this.reset();
  }
  /**
   * Begin batch part.
   * @param style
   * @param startIndex
   * @param attribStart
   */
  begin(e, t, i) {
    this.reset(), this.style = e, this.start = t, this.attribStart = i;
  }
  /**
   * End batch part.
   * @param endIndex
   * @param endAttrib
   */
  end(e, t) {
    this.attribSize = t - this.attribStart, this.size = e - this.start;
  }
  reset() {
    this.style = null, this.size = 0, this.start = 0, this.attribStart = 0, this.attribSize = 0;
  }
}
class lu {
  /**
   * Calculate length of bezier curve.
   * Analytical solution is impossible, since it involves an integral that does not integrate in general.
   * Therefore numerical solution is used.
   * @private
   * @param fromX - Starting point x
   * @param fromY - Starting point y
   * @param cpX - Control point x
   * @param cpY - Control point y
   * @param cpX2 - Second Control point x
   * @param cpY2 - Second Control point y
   * @param toX - Destination point x
   * @param toY - Destination point y
   * @returns - Length of bezier curve
   */
  static curveLength(e, t, i, n, s, o, a, l) {
    let h = 0, c = 0, u = 0, d = 0, f = 0, p = 0, _ = 0, m = 0, y = 0, v = 0, g = 0, b = e, w = t;
    for (let T = 1; T <= 10; ++T)
      c = T / 10, u = c * c, d = u * c, f = 1 - c, p = f * f, _ = p * f, m = _ * e + 3 * p * c * i + 3 * f * u * s + d * a, y = _ * t + 3 * p * c * n + 3 * f * u * o + d * l, v = b - m, g = w - y, b = m, w = y, h += Math.sqrt(v * v + g * g);
    return h;
  }
  /**
   * Calculate the points for a bezier curve and then draws it.
   *
   * Ignored from docs since it is not directly exposed.
   * @ignore
   * @param cpX - Control point x
   * @param cpY - Control point y
   * @param cpX2 - Second Control point x
   * @param cpY2 - Second Control point y
   * @param toX - Destination point x
   * @param toY - Destination point y
   * @param points - Path array to push points into
   */
  static curveTo(e, t, i, n, s, o, a) {
    const l = a[a.length - 2], h = a[a.length - 1];
    a.length -= 2;
    const c = Nn._segmentsCount(
      lu.curveLength(l, h, e, t, i, n, s, o)
    );
    let u = 0, d = 0, f = 0, p = 0, _ = 0;
    a.push(l, h);
    for (let m = 1, y = 0; m <= c; ++m)
      y = m / c, u = 1 - y, d = u * u, f = d * u, p = y * y, _ = p * y, a.push(
        f * l + 3 * d * y * e + 3 * u * p * i + _ * s,
        f * h + 3 * d * y * t + 3 * u * p * n + _ * o
      );
  }
}
function Zf(r, e, t, i, n, s, o, a) {
  const l = r - t * n, h = e - i * n, c = r + t * s, u = e + i * s;
  let d, f;
  o ? (d = i, f = -t) : (d = -i, f = t);
  const p = l + d, _ = h + f, m = c + d, y = u + f;
  return a.push(
    p,
    _,
    m,
    y
  ), 2;
}
function gr(r, e, t, i, n, s, o, a) {
  const l = t - r, h = i - e;
  let c = Math.atan2(l, h), u = Math.atan2(n - r, s - e);
  a && c < u ? c += Math.PI * 2 : !a && c > u && (u += Math.PI * 2);
  let d = c;
  const f = u - c, p = Math.abs(f), _ = Math.sqrt(l * l + h * h), m = (15 * p * Math.sqrt(_) / Math.PI >> 0) + 1, y = f / m;
  if (d += y, a) {
    o.push(
      r,
      e,
      t,
      i
    );
    for (let v = 1, g = d; v < m; v++, g += y)
      o.push(
        r,
        e,
        r + Math.sin(g) * _,
        e + Math.cos(g) * _
      );
    o.push(
      r,
      e,
      n,
      s
    );
  } else {
    o.push(
      t,
      i,
      r,
      e
    );
    for (let v = 1, g = d; v < m; v++, g += y)
      o.push(
        r + Math.sin(g) * _,
        e + Math.cos(g) * _,
        r,
        e
      );
    o.push(
      n,
      s,
      r,
      e
    );
  }
  return m * 2;
}
function J3(r, e) {
  const t = r.shape;
  let i = r.points || t.points.slice();
  const n = e.closePointEps;
  if (i.length === 0)
    return;
  const s = r.lineStyle, o = new ge(i[0], i[1]), a = new ge(i[i.length - 2], i[i.length - 1]), l = t.type !== Ye.POLY || t.closeStroke, h = Math.abs(o.x - a.x) < n && Math.abs(o.y - a.y) < n;
  if (l) {
    i = i.slice(), h && (i.pop(), i.pop(), a.set(i[i.length - 2], i[i.length - 1]));
    const L = (o.x + a.x) * 0.5, D = (a.y + o.y) * 0.5;
    i.unshift(L, D), i.push(L, D);
  }
  const c = e.points, u = i.length / 2;
  let d = i.length;
  const f = c.length / 2, p = s.width / 2, _ = p * p, m = s.miterLimit * s.miterLimit;
  let y = i[0], v = i[1], g = i[2], b = i[3], w = 0, T = 0, x = -(v - b), E = y - g, R = 0, k = 0, O = Math.sqrt(x * x + E * E);
  x /= O, E /= O, x *= p, E *= p;
  const B = s.alignment, C = (1 - B) * 2, M = B * 2;
  l || (s.cap === $i.ROUND ? d += gr(
    y - x * (C - M) * 0.5,
    v - E * (C - M) * 0.5,
    y - x * C,
    v - E * C,
    y + x * M,
    v + E * M,
    c,
    !0
  ) + 2 : s.cap === $i.SQUARE && (d += Zf(y, v, x, E, C, M, !0, c))), c.push(
    y - x * C,
    v - E * C,
    y + x * M,
    v + E * M
  );
  for (let L = 1; L < u - 1; ++L) {
    y = i[(L - 1) * 2], v = i[(L - 1) * 2 + 1], g = i[L * 2], b = i[L * 2 + 1], w = i[(L + 1) * 2], T = i[(L + 1) * 2 + 1], x = -(v - b), E = y - g, O = Math.sqrt(x * x + E * E), x /= O, E /= O, x *= p, E *= p, R = -(b - T), k = g - w, O = Math.sqrt(R * R + k * k), R /= O, k /= O, R *= p, k *= p;
    const D = g - y, N = v - b, I = g - w, S = T - b, z = D * I + N * S, V = N * I - S * D, $ = V < 0;
    if (Math.abs(V) < 1e-3 * Math.abs(z)) {
      c.push(
        g - x * C,
        b - E * C,
        g + x * M,
        b + E * M
      ), z >= 0 && (s.join === It.ROUND ? d += gr(
        g,
        b,
        g - x * C,
        b - E * C,
        g - R * C,
        b - k * C,
        c,
        !1
      ) + 4 : d += 2, c.push(
        g - R * M,
        b - k * M,
        g + R * C,
        b + k * C
      ));
      continue;
    }
    const P = (-x + y) * (-E + b) - (-x + g) * (-E + v), ie = (-R + w) * (-k + b) - (-R + g) * (-k + T), A = (D * ie - I * P) / V, X = (S * P - N * ie) / V, te = (A - g) * (A - g) + (X - b) * (X - b), j = g + (A - g) * C, W = b + (X - b) * C, se = g - (A - g) * M, ue = b - (X - b) * M, _e = Math.min(D * D + N * N, I * I + S * S), de = $ ? C : M, xe = _e + de * de * _, Me = te <= xe;
    let Ke = s.join;
    if (Ke === It.MITER && te / _ > m && (Ke = It.BEVEL), Me)
      switch (Ke) {
        case It.MITER: {
          c.push(
            j,
            W,
            se,
            ue
          );
          break;
        }
        case It.BEVEL: {
          $ ? c.push(
            j,
            W,
            // inner miter point
            g + x * M,
            b + E * M,
            // first segment's outer vertex
            j,
            W,
            // inner miter point
            g + R * M,
            b + k * M
          ) : c.push(
            g - x * C,
            b - E * C,
            // first segment's inner vertex
            se,
            ue,
            // outer miter point
            g - R * C,
            b - k * C,
            // second segment's outer vertex
            se,
            ue
          ), d += 2;
          break;
        }
        case It.ROUND: {
          $ ? (c.push(
            j,
            W,
            g + x * M,
            b + E * M
          ), d += gr(
            g,
            b,
            g + x * M,
            b + E * M,
            g + R * M,
            b + k * M,
            c,
            !0
          ) + 4, c.push(
            j,
            W,
            g + R * M,
            b + k * M
          )) : (c.push(
            g - x * C,
            b - E * C,
            se,
            ue
          ), d += gr(
            g,
            b,
            g - x * C,
            b - E * C,
            g - R * C,
            b - k * C,
            c,
            !1
          ) + 4, c.push(
            g - R * C,
            b - k * C,
            se,
            ue
          ));
          break;
        }
      }
    else {
      switch (c.push(
        g - x * C,
        b - E * C,
        // first segment's inner vertex
        g + x * M,
        b + E * M
      ), Ke) {
        case It.MITER: {
          $ ? c.push(
            se,
            ue,
            // inner miter point
            se,
            ue
          ) : c.push(
            j,
            W,
            // outer miter point
            j,
            W
          ), d += 2;
          break;
        }
        case It.ROUND: {
          $ ? d += gr(
            g,
            b,
            g + x * M,
            b + E * M,
            g + R * M,
            b + k * M,
            c,
            !0
          ) + 2 : d += gr(
            g,
            b,
            g - x * C,
            b - E * C,
            g - R * C,
            b - k * C,
            c,
            !1
          ) + 2;
          break;
        }
      }
      c.push(
        g - R * C,
        b - k * C,
        // second segment's inner vertex
        g + R * M,
        b + k * M
      ), d += 2;
    }
  }
  y = i[(u - 2) * 2], v = i[(u - 2) * 2 + 1], g = i[(u - 1) * 2], b = i[(u - 1) * 2 + 1], x = -(v - b), E = y - g, O = Math.sqrt(x * x + E * E), x /= O, E /= O, x *= p, E *= p, c.push(
    g - x * C,
    b - E * C,
    g + x * M,
    b + E * M
  ), l || (s.cap === $i.ROUND ? d += gr(
    g - x * (C - M) * 0.5,
    b - E * (C - M) * 0.5,
    g - x * C,
    b - E * C,
    g + x * M,
    b + E * M,
    c,
    !1
  ) + 2 : s.cap === $i.SQUARE && (d += Zf(g, b, x, E, C, M, !1, c)));
  const F = e.indices, U = Nn.epsilon * Nn.epsilon;
  for (let L = f; L < d + f - 2; ++L)
    y = c[L * 2], v = c[L * 2 + 1], g = c[(L + 1) * 2], b = c[(L + 1) * 2 + 1], w = c[(L + 2) * 2], T = c[(L + 2) * 2 + 1], !(Math.abs(y * (b - T) + g * (T - v) + w * (v - b)) < U) && F.push(L, L + 1, L + 2);
}
function Q3(r, e) {
  let t = 0;
  const i = r.shape, n = r.points || i.points, s = i.type !== Ye.POLY || i.closeStroke;
  if (n.length === 0)
    return;
  const o = e.points, a = e.indices, l = n.length / 2, h = o.length / 2;
  let c = h;
  for (o.push(n[0], n[1]), t = 1; t < l; t++)
    o.push(n[t * 2], n[t * 2 + 1]), a.push(c, c + 1), c++;
  s && a.push(c, h);
}
function $f(r, e) {
  r.lineStyle.native ? Q3(r, e) : J3(r, e);
}
class hu {
  /**
   * Calculate length of quadratic curve
   * @see {@link http://www.malczak.linuxpl.com/blog/quadratic-bezier-curve-length/}
   * for the detailed explanation of math behind this.
   * @private
   * @param fromX - x-coordinate of curve start point
   * @param fromY - y-coordinate of curve start point
   * @param cpX - x-coordinate of curve control point
   * @param cpY - y-coordinate of curve control point
   * @param toX - x-coordinate of curve end point
   * @param toY - y-coordinate of curve end point
   * @returns - Length of quadratic curve
   */
  static curveLength(e, t, i, n, s, o) {
    const a = e - 2 * i + s, l = t - 2 * n + o, h = 2 * i - 2 * e, c = 2 * n - 2 * t, u = 4 * (a * a + l * l), d = 4 * (a * h + l * c), f = h * h + c * c, p = 2 * Math.sqrt(u + d + f), _ = Math.sqrt(u), m = 2 * u * _, y = 2 * Math.sqrt(f), v = d / _;
    return (m * p + _ * d * (p - y) + (4 * f * u - d * d) * Math.log((2 * _ + v + p) / (v + y))) / (4 * m);
  }
  /**
   * Calculate the points for a quadratic bezier curve and then draws it.
   * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
   * @private
   * @param cpX - Control point x
   * @param cpY - Control point y
   * @param toX - Destination point x
   * @param toY - Destination point y
   * @param points - Points to add segments to.
   */
  static curveTo(e, t, i, n, s) {
    const o = s[s.length - 2], a = s[s.length - 1], l = Nn._segmentsCount(
      hu.curveLength(o, a, e, t, i, n)
    );
    let h = 0, c = 0;
    for (let u = 1; u <= l; ++u) {
      const d = u / l;
      h = o + (e - o) * d, c = a + (t - a) * d, s.push(
        h + (e + (i - e) * d - h) * d,
        c + (t + (n - t) * d - c) * d
      );
    }
  }
}
const nh = {
  [Ye.POLY]: g0,
  [Ye.CIRC]: _a,
  [Ye.ELIP]: _a,
  [Ye.RECT]: K3,
  [Ye.RREC]: Z3
}, Jf = [], go = [];
class ma {
  /**
   * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.
   * @param fillStyle - the width of the line to draw
   * @param lineStyle - the color of the line to draw
   * @param matrix - Transform matrix
   */
  constructor(e, t = null, i = null, n = null) {
    this.points = [], this.holes = [], this.shape = e, this.lineStyle = i, this.fillStyle = t, this.matrix = n, this.type = e.type;
  }
  /**
   * Creates a new GraphicsData object with the same values as this one.
   * @returns - Cloned GraphicsData object
   */
  clone() {
    return new ma(
      this.shape,
      this.fillStyle,
      this.lineStyle,
      this.matrix
    );
  }
  /** Destroys the Graphics data. */
  destroy() {
    this.shape = null, this.holes.length = 0, this.holes = null, this.points.length = 0, this.points = null, this.lineStyle = null, this.fillStyle = null;
  }
}
const on = new ge(), y0 = class v0 extends Em {
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
  constructor() {
    super(), this.closePointEps = 1e-4, this.boundsPadding = 0, this.uvsFloat32 = null, this.indicesUint16 = null, this.batchable = !1, this.points = [], this.colors = [], this.uvs = [], this.indices = [], this.textureIds = [], this.graphicsData = [], this.drawCalls = [], this.batchDirty = -1, this.batches = [], this.dirty = 0, this.cacheDirty = -1, this.clearDirty = 0, this.shapeIndex = 0, this._bounds = new ua(), this.boundsDirty = -1;
  }
  /**
   * Get the current bounds of the graphic geometry.
   *
   * Since 6.5.0, bounds of the graphics geometry are calculated based on the vertices of generated geometry.
   * Since shapes or strokes with full transparency (`alpha: 0`) will not generate geometry, they are not considered
   * when calculating bounds for the graphics geometry. See PR [#8343]{@link https://github.com/pixijs/pixijs/pull/8343}
   * and issue [#8623]{@link https://github.com/pixijs/pixijs/pull/8623}.
   * @readonly
   */
  get bounds() {
    return this.updateBatches(), this.boundsDirty !== this.dirty && (this.boundsDirty = this.dirty, this.calculateBounds()), this._bounds;
  }
  /** Call if you changed graphicsData manually. Empties all batch buffers. */
  invalidate() {
    this.boundsDirty = -1, this.dirty++, this.batchDirty++, this.shapeIndex = 0, this.points.length = 0, this.colors.length = 0, this.uvs.length = 0, this.indices.length = 0, this.textureIds.length = 0;
    for (let e = 0; e < this.drawCalls.length; e++)
      this.drawCalls[e].texArray.clear(), go.push(this.drawCalls[e]);
    this.drawCalls.length = 0;
    for (let e = 0; e < this.batches.length; e++) {
      const t = this.batches[e];
      t.reset(), Jf.push(t);
    }
    this.batches.length = 0;
  }
  /**
   * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
   * @returns - This GraphicsGeometry object. Good for chaining method calls
   */
  clear() {
    return this.graphicsData.length > 0 && (this.invalidate(), this.clearDirty++, this.graphicsData.length = 0), this;
  }
  /**
   * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
   * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.
   * @param fillStyle - Defines style of the fill.
   * @param lineStyle - Defines style of the lines.
   * @param matrix - Transform applied to the points of the shape.
   * @returns - Returns geometry for chaining.
   */
  drawShape(e, t = null, i = null, n = null) {
    const s = new ma(e, t, i, n);
    return this.graphicsData.push(s), this.dirty++, this;
  }
  /**
   * Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
   * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - The shape object to draw.
   * @param matrix - Transform applied to the points of the shape.
   * @returns - Returns geometry for chaining.
   */
  drawHole(e, t = null) {
    if (!this.graphicsData.length)
      return null;
    const i = new ma(e, null, null, t), n = this.graphicsData[this.graphicsData.length - 1];
    return i.lineStyle = n.lineStyle, n.holes.push(i), this.dirty++, this;
  }
  /** Destroys the GraphicsGeometry object. */
  destroy() {
    super.destroy();
    for (let e = 0; e < this.graphicsData.length; ++e)
      this.graphicsData[e].destroy();
    this.points.length = 0, this.points = null, this.colors.length = 0, this.colors = null, this.uvs.length = 0, this.uvs = null, this.indices.length = 0, this.indices = null, this.indexBuffer.destroy(), this.indexBuffer = null, this.graphicsData.length = 0, this.graphicsData = null, this.drawCalls.length = 0, this.drawCalls = null, this.batches.length = 0, this.batches = null, this._bounds = null;
  }
  /**
   * Check to see if a point is contained within this geometry.
   * @param point - Point to check if it's contained.
   * @returns {boolean} `true` if the point is contained within geometry.
   */
  containsPoint(e) {
    const t = this.graphicsData;
    for (let i = 0; i < t.length; ++i) {
      const n = t[i];
      if (n.fillStyle.visible && n.shape && (n.matrix ? n.matrix.applyInverse(e, on) : on.copyFrom(e), n.shape.contains(on.x, on.y))) {
        let s = !1;
        if (n.holes) {
          for (let o = 0; o < n.holes.length; o++)
            if (n.holes[o].shape.contains(on.x, on.y)) {
              s = !0;
              break;
            }
        }
        if (!s)
          return !0;
      }
    }
    return !1;
  }
  /**
   * Generates intermediate batch data. Either gets converted to drawCalls
   * or used to convert to batch objects directly by the Graphics object.
   */
  updateBatches() {
    if (!this.graphicsData.length) {
      this.batchable = !0;
      return;
    }
    if (!this.validateBatching())
      return;
    this.cacheDirty = this.dirty;
    const e = this.uvs, t = this.graphicsData;
    let i = null, n = null;
    this.batches.length > 0 && (i = this.batches[this.batches.length - 1], n = i.style);
    for (let l = this.shapeIndex; l < t.length; l++) {
      this.shapeIndex++;
      const h = t[l], c = h.fillStyle, u = h.lineStyle;
      nh[h.type].build(h), h.matrix && this.transformPoints(h.points, h.matrix), (c.visible || u.visible) && this.processHoles(h.holes);
      for (let d = 0; d < 2; d++) {
        const f = d === 0 ? c : u;
        if (!f.visible)
          continue;
        const p = f.texture.baseTexture, _ = this.indices.length, m = this.points.length / 2;
        p.wrapMode = tr.REPEAT, d === 0 ? this.processFill(h) : this.processLine(h);
        const y = this.points.length / 2 - m;
        y !== 0 && (i && !this._compareStyles(n, f) && (i.end(_, m), i = null), i || (i = Jf.pop() || new $3(), i.begin(f, _, m), this.batches.push(i), n = f), this.addUvs(this.points, e, f.texture, m, y, f.matrix));
      }
    }
    const s = this.indices.length, o = this.points.length / 2;
    if (i && i.end(s, o), this.batches.length === 0) {
      this.batchable = !0;
      return;
    }
    const a = o > 65535;
    this.indicesUint16 && this.indices.length === this.indicesUint16.length && a === this.indicesUint16.BYTES_PER_ELEMENT > 2 ? this.indicesUint16.set(this.indices) : this.indicesUint16 = a ? new Uint32Array(this.indices) : new Uint16Array(this.indices), this.batchable = this.isBatchable(), this.batchable ? this.packBatches() : this.buildDrawCalls();
  }
  /**
   * Affinity check
   * @param styleA
   * @param styleB
   */
  _compareStyles(e, t) {
    return !(!e || !t || e.texture.baseTexture !== t.texture.baseTexture || e.color + e.alpha !== t.color + t.alpha || !!e.native != !!t.native);
  }
  /** Test geometry for batching process. */
  validateBatching() {
    if (this.dirty === this.cacheDirty || !this.graphicsData.length)
      return !1;
    for (let e = 0, t = this.graphicsData.length; e < t; e++) {
      const i = this.graphicsData[e], n = i.fillStyle, s = i.lineStyle;
      if (n && !n.texture.baseTexture.valid || s && !s.texture.baseTexture.valid)
        return !1;
    }
    return !0;
  }
  /** Offset the indices so that it works with the batcher. */
  packBatches() {
    this.batchDirty++, this.uvsFloat32 = new Float32Array(this.uvs);
    const e = this.batches;
    for (let t = 0, i = e.length; t < i; t++) {
      const n = e[t];
      for (let s = 0; s < n.size; s++) {
        const o = n.start + s;
        this.indicesUint16[o] = this.indicesUint16[o] - n.attribStart;
      }
    }
  }
  /**
   * Checks to see if this graphics geometry can be batched.
   * Currently it needs to be small enough and not contain any native lines.
   */
  isBatchable() {
    if (this.points.length > 65535 * 2)
      return !1;
    const e = this.batches;
    for (let t = 0; t < e.length; t++)
      if (e[t].style.native)
        return !1;
    return this.points.length < v0.BATCHABLE_SIZE * 2;
  }
  /** Converts intermediate batches data to drawCalls. */
  buildDrawCalls() {
    let e = ++ae._globalBatch;
    for (let u = 0; u < this.drawCalls.length; u++)
      this.drawCalls[u].texArray.clear(), go.push(this.drawCalls[u]);
    this.drawCalls.length = 0;
    const t = this.colors, i = this.textureIds;
    let n = go.pop();
    n || (n = new rc(), n.texArray = new ac()), n.texArray.count = 0, n.start = 0, n.size = 0, n.type = pi.TRIANGLES;
    let s = 0, o = null, a = 0, l = !1, h = pi.TRIANGLES, c = 0;
    this.drawCalls.push(n);
    for (let u = 0; u < this.batches.length; u++) {
      const d = this.batches[u], f = 8, p = d.style, _ = p.texture.baseTexture;
      l !== !!p.native && (l = !!p.native, h = l ? pi.LINES : pi.TRIANGLES, o = null, s = f, e++), o !== _ && (o = _, _._batchEnabled !== e && (s === f && (e++, s = 0, n.size > 0 && (n = go.pop(), n || (n = new rc(), n.texArray = new ac()), this.drawCalls.push(n)), n.start = c, n.size = 0, n.texArray.count = 0, n.type = h), _.touched = 1, _._batchEnabled = e, _._batchLocation = s, _.wrapMode = tr.REPEAT, n.texArray.elements[n.texArray.count++] = _, s++)), n.size += d.size, c += d.size, a = _._batchLocation, this.addColors(t, p.color, p.alpha, d.attribSize, d.attribStart), this.addTextureIds(i, a, d.attribSize, d.attribStart);
    }
    ae._globalBatch = e, this.packAttributes();
  }
  /** Packs attributes to single buffer. */
  packAttributes() {
    const e = this.points, t = this.uvs, i = this.colors, n = this.textureIds, s = new ArrayBuffer(e.length * 3 * 4), o = new Float32Array(s), a = new Uint32Array(s);
    let l = 0;
    for (let h = 0; h < e.length / 2; h++)
      o[l++] = e[h * 2], o[l++] = e[h * 2 + 1], o[l++] = t[h * 2], o[l++] = t[h * 2 + 1], a[l++] = i[h], o[l++] = n[h];
    this._buffer.update(s), this._indexBuffer.update(this.indicesUint16);
  }
  /**
   * Process fill part of Graphics.
   * @param data
   */
  processFill(e) {
    e.holes.length ? g0.triangulate(e, this) : nh[e.type].triangulate(e, this);
  }
  /**
   * Process line part of Graphics.
   * @param data
   */
  processLine(e) {
    $f(e, this);
    for (let t = 0; t < e.holes.length; t++)
      $f(e.holes[t], this);
  }
  /**
   * Process the holes data.
   * @param holes
   */
  processHoles(e) {
    for (let t = 0; t < e.length; t++) {
      const i = e[t];
      nh[i.type].build(i), i.matrix && this.transformPoints(i.points, i.matrix);
    }
  }
  /** Update the local bounds of the object. Expensive to use performance-wise. */
  calculateBounds() {
    const e = this._bounds;
    e.clear(), e.addVertexData(this.points, 0, this.points.length), e.pad(this.boundsPadding, this.boundsPadding);
  }
  /**
   * Transform points using matrix.
   * @param points - Points to transform
   * @param matrix - Transform matrix
   */
  transformPoints(e, t) {
    for (let i = 0; i < e.length / 2; i++) {
      const n = e[i * 2], s = e[i * 2 + 1];
      e[i * 2] = t.a * n + t.c * s + t.tx, e[i * 2 + 1] = t.b * n + t.d * s + t.ty;
    }
  }
  /**
   * Add colors.
   * @param colors - List of colors to add to
   * @param color - Color to add
   * @param alpha - Alpha to use
   * @param size - Number of colors to add
   * @param offset
   */
  addColors(e, t, i, n, s = 0) {
    const o = be.shared.setValue(t).toLittleEndianNumber(), a = be.shared.setValue(o).toPremultiplied(i);
    e.length = Math.max(e.length, s + n);
    for (let l = 0; l < n; l++)
      e[s + l] = a;
  }
  /**
   * Add texture id that the shader/fragment wants to use.
   * @param textureIds
   * @param id
   * @param size
   * @param offset
   */
  addTextureIds(e, t, i, n = 0) {
    e.length = Math.max(e.length, n + i);
    for (let s = 0; s < i; s++)
      e[n + s] = t;
  }
  /**
   * Generates the UVs for a shape.
   * @param verts - Vertices
   * @param uvs - UVs
   * @param texture - Reference to Texture
   * @param start - Index buffer start index.
   * @param size - The size/length for index buffer.
   * @param matrix - Optional transform for all points.
   */
  addUvs(e, t, i, n, s, o = null) {
    let a = 0;
    const l = t.length, h = i.frame;
    for (; a < s; ) {
      let u = e[(n + a) * 2], d = e[(n + a) * 2 + 1];
      if (o) {
        const f = o.a * u + o.c * d + o.tx;
        d = o.b * u + o.d * d + o.ty, u = f;
      }
      a++, t.push(u / h.width, d / h.height);
    }
    const c = i.baseTexture;
    (h.width < c.width || h.height < c.height) && this.adjustUvs(t, i, l, s);
  }
  /**
   * Modify uvs array according to position of texture region
   * Does not work with rotated or trimmed textures
   * @param uvs - array
   * @param texture - region
   * @param start - starting index for uvs
   * @param size - how many points to adjust
   */
  adjustUvs(e, t, i, n) {
    const s = t.baseTexture, o = 1e-6, a = i + n * 2, l = t.frame, h = l.width / s.width, c = l.height / s.height;
    let u = l.x / l.width, d = l.y / l.height, f = Math.floor(e[i] + o), p = Math.floor(e[i + 1] + o);
    for (let _ = i + 2; _ < a; _ += 2)
      f = Math.min(f, Math.floor(e[_] + o)), p = Math.min(p, Math.floor(e[_ + 1] + o));
    u -= f, d -= p;
    for (let _ = i; _ < a; _ += 2)
      e[_] = (e[_] + u) * h, e[_ + 1] = (e[_ + 1] + d) * c;
  }
};
y0.BATCHABLE_SIZE = 100;
let eI = y0;
class La {
  constructor() {
    this.color = 16777215, this.alpha = 1, this.texture = J.WHITE, this.matrix = null, this.visible = !1, this.reset();
  }
  /** Clones the object */
  clone() {
    const e = new La();
    return e.color = this.color, e.alpha = this.alpha, e.texture = this.texture, e.matrix = this.matrix, e.visible = this.visible, e;
  }
  /** Reset */
  reset() {
    this.color = 16777215, this.alpha = 1, this.texture = J.WHITE, this.matrix = null, this.visible = !1;
  }
  /** Destroy and don't use after this. */
  destroy() {
    this.texture = null, this.matrix = null;
  }
}
class cu extends La {
  constructor() {
    super(...arguments), this.width = 0, this.alignment = 0.5, this.native = !1, this.cap = $i.BUTT, this.join = It.MITER, this.miterLimit = 10;
  }
  /** Clones the object. */
  clone() {
    const e = new cu();
    return e.color = this.color, e.alpha = this.alpha, e.texture = this.texture, e.matrix = this.matrix, e.visible = this.visible, e.width = this.width, e.alignment = this.alignment, e.native = this.native, e.cap = this.cap, e.join = this.join, e.miterLimit = this.miterLimit, e;
  }
  /** Reset the line style to default. */
  reset() {
    super.reset(), this.color = 0, this.alignment = 0.5, this.width = 0, this.native = !1, this.cap = $i.BUTT, this.join = It.MITER, this.miterLimit = 10;
  }
}
const sh = {}, Sc = class Fo extends Qe {
  /**
   * @param geometry - Geometry to use, if omitted will create a new GraphicsGeometry instance.
   */
  constructor(e = null) {
    super(), this.shader = null, this.pluginName = "batch", this.currentPath = null, this.batches = [], this.batchTint = -1, this.batchDirty = -1, this.vertexData = null, this._fillStyle = new La(), this._lineStyle = new cu(), this._matrix = null, this._holeMode = !1, this.state = yi.for2d(), this._geometry = e || new eI(), this._geometry.refCount++, this._transformID = -1, this._tintColor = new be(16777215), this.blendMode = oe.NORMAL;
  }
  /**
   * Includes vertex positions, face indices, normals, colors, UVs, and
   * custom attributes within buffers, reducing the cost of passing all
   * this data to the GPU. Can be shared between multiple Mesh or Graphics objects.
   * @readonly
   */
  get geometry() {
    return this._geometry;
  }
  /**
   * Creates a new Graphics object with the same values as this one.
   * Note that only the geometry of the object is cloned, not its transform (position,scale,etc)
   * @returns - A clone of the graphics object
   */
  clone() {
    return this.finishPoly(), new Fo(this._geometry);
  }
  /**
   * The blend mode to be applied to the graphic shape. Apply a value of
   * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.  Note that, since each
   * primitive in the GraphicsGeometry list is rendered sequentially, modes
   * such as `PIXI.BLEND_MODES.ADD` and `PIXI.BLEND_MODES.MULTIPLY` will
   * be applied per-primitive.
   * @default PIXI.BLEND_MODES.NORMAL
   */
  set blendMode(e) {
    this.state.blendMode = e;
  }
  get blendMode() {
    return this.state.blendMode;
  }
  /**
   * The tint applied to each graphic shape. This is a hex value. A value of
   * 0xFFFFFF will remove any tint effect.
   * @default 0xFFFFFF
   */
  get tint() {
    return this._tintColor.value;
  }
  set tint(e) {
    this._tintColor.setValue(e);
  }
  /**
   * The current fill style.
   * @readonly
   */
  get fill() {
    return this._fillStyle;
  }
  /**
   * The current line style.
   * @readonly
   */
  get line() {
    return this._lineStyle;
  }
  lineStyle(e = null, t = 0, i, n = 0.5, s = !1) {
    return typeof e == "number" && (e = { width: e, color: t, alpha: i, alignment: n, native: s }), this.lineTextureStyle(e);
  }
  /**
   * Like line style but support texture for line fill.
   * @param [options] - Collection of options for setting line style.
   * @param {number} [options.width=0] - width of the line to draw, will update the objects stored style
   * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to use
   * @param {PIXI.ColorSource} [options.color=0x0] - color of the line to draw, will update the objects stored style.
   *  Default 0xFFFFFF if texture present.
   * @param {number} [options.alpha=1] - alpha of the line to draw, will update the objects stored style
   * @param {PIXI.Matrix} [options.matrix=null] - Texture matrix to transform texture
   * @param {number} [options.alignment=0.5] - alignment of the line to draw, (0 = inner, 0.5 = middle, 1 = outer).
   *        WebGL only.
   * @param {boolean} [options.native=false] - If true the lines will be draw using LINES instead of TRIANGLE_STRIP
   * @param {PIXI.LINE_CAP}[options.cap=PIXI.LINE_CAP.BUTT] - line cap style
   * @param {PIXI.LINE_JOIN}[options.join=PIXI.LINE_JOIN.MITER] - line join style
   * @param {number}[options.miterLimit=10] - miter limit ratio
   * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls
   */
  lineTextureStyle(e) {
    const t = {
      width: 0,
      texture: J.WHITE,
      color: e != null && e.texture ? 16777215 : 0,
      matrix: null,
      alignment: 0.5,
      native: !1,
      cap: $i.BUTT,
      join: It.MITER,
      miterLimit: 10
    };
    e = Object.assign(t, e), this.normalizeColor(e), this.currentPath && this.startPoly();
    const i = e.width > 0 && e.alpha > 0;
    return i ? (e.matrix && (e.matrix = e.matrix.clone(), e.matrix.invert()), Object.assign(this._lineStyle, { visible: i }, e)) : this._lineStyle.reset(), this;
  }
  /**
   * Start a polygon object internally.
   * @protected
   */
  startPoly() {
    if (this.currentPath) {
      const e = this.currentPath.points, t = this.currentPath.points.length;
      t > 2 && (this.drawShape(this.currentPath), this.currentPath = new Dr(), this.currentPath.closeStroke = !1, this.currentPath.points.push(e[t - 2], e[t - 1]));
    } else
      this.currentPath = new Dr(), this.currentPath.closeStroke = !1;
  }
  /**
   * Finish the polygon object.
   * @protected
   */
  finishPoly() {
    this.currentPath && (this.currentPath.points.length > 2 ? (this.drawShape(this.currentPath), this.currentPath = null) : this.currentPath.points.length = 0);
  }
  /**
   * Moves the current drawing position to x, y.
   * @param x - the X coordinate to move to
   * @param y - the Y coordinate to move to
   * @returns - This Graphics object. Good for chaining method calls
   */
  moveTo(e, t) {
    return this.startPoly(), this.currentPath.points[0] = e, this.currentPath.points[1] = t, this;
  }
  /**
   * Draws a line using the current line style from the current drawing position to (x, y);
   * The current drawing position is then set to (x, y).
   * @param x - the X coordinate to draw to
   * @param y - the Y coordinate to draw to
   * @returns - This Graphics object. Good for chaining method calls
   */
  lineTo(e, t) {
    this.currentPath || this.moveTo(0, 0);
    const i = this.currentPath.points, n = i[i.length - 2], s = i[i.length - 1];
    return (n !== e || s !== t) && i.push(e, t), this;
  }
  /**
   * Initialize the curve
   * @param x
   * @param y
   */
  _initCurve(e = 0, t = 0) {
    this.currentPath ? this.currentPath.points.length === 0 && (this.currentPath.points = [e, t]) : this.moveTo(e, t);
  }
  /**
   * Calculate the points for a quadratic bezier curve and then draws it.
   * Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
   * @param cpX - Control point x
   * @param cpY - Control point y
   * @param toX - Destination point x
   * @param toY - Destination point y
   * @returns - This Graphics object. Good for chaining method calls
   */
  quadraticCurveTo(e, t, i, n) {
    this._initCurve();
    const s = this.currentPath.points;
    return s.length === 0 && this.moveTo(0, 0), hu.curveTo(e, t, i, n, s), this;
  }
  /**
   * Calculate the points for a bezier curve and then draws it.
   * @param cpX - Control point x
   * @param cpY - Control point y
   * @param cpX2 - Second Control point x
   * @param cpY2 - Second Control point y
   * @param toX - Destination point x
   * @param toY - Destination point y
   * @returns This Graphics object. Good for chaining method calls
   */
  bezierCurveTo(e, t, i, n, s, o) {
    return this._initCurve(), lu.curveTo(e, t, i, n, s, o, this.currentPath.points), this;
  }
  /**
   * The `arcTo` method creates an arc/curve between two tangents on the canvas.
   * The first tangent is from the start point to the first control point,
   * and the second tangent is from the first control point to the second control point.
   * Note that the second control point is not necessarily the end point of the arc.
   *
   * "borrowed" from https://code.google.com/p/fxcanvas/ - thanks google!
   * @param x1 - The x-coordinate of the first control point of the arc
   * @param y1 - The y-coordinate of the first control point of the arc
   * @param x2 - The x-coordinate of the second control point of the arc
   * @param y2 - The y-coordinate of the second control point of the arc
   * @param radius - The radius of the arc
   * @returns - This Graphics object. Good for chaining method calls
   */
  arcTo(e, t, i, n, s) {
    this._initCurve(e, t);
    const o = this.currentPath.points, a = Kf.curveTo(e, t, i, n, s, o);
    if (a) {
      const { cx: l, cy: h, radius: c, startAngle: u, endAngle: d, anticlockwise: f } = a;
      this.arc(l, h, c, u, d, f);
    }
    return this;
  }
  /**
   * The arc method creates an arc/curve (used to create circles, or parts of circles).
   * @param cx - The x-coordinate of the center of the circle
   * @param cy - The y-coordinate of the center of the circle
   * @param radius - The radius of the circle
   * @param startAngle - The starting angle, in radians (0 is at the 3 o'clock position
   *  of the arc's circle)
   * @param endAngle - The ending angle, in radians
   * @param anticlockwise - Specifies whether the drawing should be
   *  counter-clockwise or clockwise. False is default, and indicates clockwise, while true
   *  indicates counter-clockwise.
   * @returns - This Graphics object. Good for chaining method calls
   */
  arc(e, t, i, n, s, o = !1) {
    if (n === s)
      return this;
    if (!o && s <= n ? s += oa : o && n <= s && (n += oa), s - n === 0)
      return this;
    const a = e + Math.cos(n) * i, l = t + Math.sin(n) * i, h = this._geometry.closePointEps;
    let c = this.currentPath ? this.currentPath.points : null;
    if (c) {
      const u = Math.abs(c[c.length - 2] - a), d = Math.abs(c[c.length - 1] - l);
      u < h && d < h || c.push(a, l);
    } else
      this.moveTo(a, l), c = this.currentPath.points;
    return Kf.arc(a, l, e, t, i, n, s, o, c), this;
  }
  /**
   * Specifies a simple one-color fill that subsequent calls to other Graphics methods
   * (such as lineTo() or drawCircle()) use when drawing.
   * @param {PIXI.ColorSource} color - the color of the fill
   * @param alpha - the alpha of the fill, will override the color's alpha
   * @returns - This Graphics object. Suitable for chaining method calls
   */
  beginFill(e = 0, t) {
    return this.beginTextureFill({ texture: J.WHITE, color: e, alpha: t });
  }
  /**
   * Normalize the color input from options for line style or fill
   * @param {PIXI.IFillStyleOptions} options - Fill style object.
   */
  normalizeColor(e) {
    const t = be.shared.setValue(e.color ?? 0);
    e.color = t.toNumber(), e.alpha ?? (e.alpha = t.alpha);
  }
  /**
   * Begin the texture fill.
   * Note: The wrap mode of the texture is forced to REPEAT on render.
   * @param options - Fill style object.
   * @param {PIXI.Texture} [options.texture=PIXI.Texture.WHITE] - Texture to fill
   * @param {PIXI.ColorSource} [options.color=0xffffff] - Background to fill behind texture
   * @param {number} [options.alpha] - Alpha of fill, overrides the color's alpha
   * @param {PIXI.Matrix} [options.matrix=null] - Transform matrix
   * @returns {PIXI.Graphics} This Graphics object. Good for chaining method calls
   */
  beginTextureFill(e) {
    const t = {
      texture: J.WHITE,
      color: 16777215,
      matrix: null
    };
    e = Object.assign(t, e), this.normalizeColor(e), this.currentPath && this.startPoly();
    const i = e.alpha > 0;
    return i ? (e.matrix && (e.matrix = e.matrix.clone(), e.matrix.invert()), Object.assign(this._fillStyle, { visible: i }, e)) : this._fillStyle.reset(), this;
  }
  /**
   * Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
   * @returns - This Graphics object. Good for chaining method calls
   */
  endFill() {
    return this.finishPoly(), this._fillStyle.reset(), this;
  }
  /**
   * Draws a rectangle shape.
   * @param x - The X coord of the top-left of the rectangle
   * @param y - The Y coord of the top-left of the rectangle
   * @param width - The width of the rectangle
   * @param height - The height of the rectangle
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawRect(e, t, i, n) {
    return this.drawShape(new le(e, t, i, n));
  }
  /**
   * Draw a rectangle shape with rounded/beveled corners.
   * @param x - The X coord of the top-left of the rectangle
   * @param y - The Y coord of the top-left of the rectangle
   * @param width - The width of the rectangle
   * @param height - The height of the rectangle
   * @param radius - Radius of the rectangle corners
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawRoundedRect(e, t, i, n, s) {
    return this.drawShape(new Ba(e, t, i, n, s));
  }
  /**
   * Draws a circle.
   * @param x - The X coordinate of the center of the circle
   * @param y - The Y coordinate of the center of the circle
   * @param radius - The radius of the circle
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawCircle(e, t, i) {
    return this.drawShape(new ka(e, t, i));
  }
  /**
   * Draws an ellipse.
   * @param x - The X coordinate of the center of the ellipse
   * @param y - The Y coordinate of the center of the ellipse
   * @param width - The half width of the ellipse
   * @param height - The half height of the ellipse
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawEllipse(e, t, i, n) {
    return this.drawShape(new Da(e, t, i, n));
  }
  /**
   * Draws a polygon using the given path.
   * @param {number[]|PIXI.IPointData[]|PIXI.Polygon} path - The path data used to construct the polygon.
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawPolygon(...e) {
    let t, i = !0;
    const n = e[0];
    n.points ? (i = n.closeStroke, t = n.points) : Array.isArray(e[0]) ? t = e[0] : t = e;
    const s = new Dr(t);
    return s.closeStroke = i, this.drawShape(s), this;
  }
  /**
   * Draw any shape.
   * @param {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} shape - Shape to draw
   * @returns - This Graphics object. Good for chaining method calls
   */
  drawShape(e) {
    return this._holeMode ? this._geometry.drawHole(e, this._matrix) : this._geometry.drawShape(
      e,
      this._fillStyle.clone(),
      this._lineStyle.clone(),
      this._matrix
    ), this;
  }
  /**
   * Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
   * @returns - This Graphics object. Good for chaining method calls
   */
  clear() {
    return this._geometry.clear(), this._lineStyle.reset(), this._fillStyle.reset(), this._boundsID++, this._matrix = null, this._holeMode = !1, this.currentPath = null, this;
  }
  /**
   * True if graphics consists of one rectangle, and thus, can be drawn like a Sprite and
   * masked with gl.scissor.
   * @returns - True if only 1 rect.
   */
  isFastRect() {
    const e = this._geometry.graphicsData;
    return e.length === 1 && e[0].shape.type === Ye.RECT && !e[0].matrix && !e[0].holes.length && !(e[0].lineStyle.visible && e[0].lineStyle.width);
  }
  /**
   * Renders the object using the WebGL renderer
   * @param renderer - The renderer
   */
  _render(e) {
    this.finishPoly();
    const t = this._geometry;
    t.updateBatches(), t.batchable ? (this.batchDirty !== t.batchDirty && this._populateBatches(), this._renderBatched(e)) : (e.batch.flush(), this._renderDirect(e));
  }
  /** Populating batches for rendering. */
  _populateBatches() {
    const e = this._geometry, t = this.blendMode, i = e.batches.length;
    this.batchTint = -1, this._transformID = -1, this.batchDirty = e.batchDirty, this.batches.length = i, this.vertexData = new Float32Array(e.points);
    for (let n = 0; n < i; n++) {
      const s = e.batches[n], o = s.style.color, a = new Float32Array(
        this.vertexData.buffer,
        s.attribStart * 4 * 2,
        s.attribSize * 2
      ), l = new Float32Array(
        e.uvsFloat32.buffer,
        s.attribStart * 4 * 2,
        s.attribSize * 2
      ), h = new Uint16Array(
        e.indicesUint16.buffer,
        s.start * 2,
        s.size
      ), c = {
        vertexData: a,
        blendMode: t,
        indices: h,
        uvs: l,
        _batchRGB: be.shared.setValue(o).toRgbArray(),
        _tintRGB: o,
        _texture: s.style.texture,
        alpha: s.style.alpha,
        worldAlpha: 1
      };
      this.batches[n] = c;
    }
  }
  /**
   * Renders the batches using the BathedRenderer plugin
   * @param renderer - The renderer
   */
  _renderBatched(e) {
    if (this.batches.length) {
      e.batch.setObjectRenderer(e.plugins[this.pluginName]), this.calculateVertices(), this.calculateTints();
      for (let t = 0, i = this.batches.length; t < i; t++) {
        const n = this.batches[t];
        n.worldAlpha = this.worldAlpha * n.alpha, e.plugins[this.pluginName].render(n);
      }
    }
  }
  /**
   * Renders the graphics direct
   * @param renderer - The renderer
   */
  _renderDirect(e) {
    const t = this._resolveDirectShader(e), i = this._geometry, n = this.worldAlpha, s = t.uniforms, o = i.drawCalls;
    s.translationMatrix = this.transform.worldTransform, be.shared.setValue(this._tintColor).premultiply(n).toArray(s.tint), e.shader.bind(t), e.geometry.bind(i, t), e.state.set(this.state);
    for (let a = 0, l = o.length; a < l; a++)
      this._renderDrawCallDirect(e, i.drawCalls[a]);
  }
  /**
   * Renders specific DrawCall
   * @param renderer
   * @param drawCall
   */
  _renderDrawCallDirect(e, t) {
    const { texArray: i, type: n, size: s, start: o } = t, a = i.count;
    for (let l = 0; l < a; l++)
      e.texture.bind(i.elements[l], l);
    e.geometry.draw(n, s, o);
  }
  /**
   * Resolves shader for direct rendering
   * @param renderer - The renderer
   */
  _resolveDirectShader(e) {
    let t = this.shader;
    const i = this.pluginName;
    if (!t) {
      if (!sh[i]) {
        const { maxTextures: n } = e.plugins[i], s = new Int32Array(n);
        for (let l = 0; l < n; l++)
          s[l] = l;
        const o = {
          tint: new Float32Array([1, 1, 1, 1]),
          translationMatrix: new Te(),
          default: Jt.from({ uSamplers: s }, !0)
        }, a = e.plugins[i]._shader.program;
        sh[i] = new mi(a, o);
      }
      t = sh[i];
    }
    return t;
  }
  /**
   * Retrieves the bounds of the graphic shape as a rectangle object.
   * @see PIXI.GraphicsGeometry#bounds
   */
  _calculateBounds() {
    this.finishPoly();
    const e = this._geometry;
    if (!e.graphicsData.length)
      return;
    const { minX: t, minY: i, maxX: n, maxY: s } = e.bounds;
    this._bounds.addFrame(this.transform, t, i, n, s);
  }
  /**
   * Tests if a point is inside this graphics object
   * @param point - the point to test
   * @returns - the result of the test
   */
  containsPoint(e) {
    return this.worldTransform.applyInverse(e, Fo._TEMP_POINT), this._geometry.containsPoint(Fo._TEMP_POINT);
  }
  /** Recalculate the tint by applying tint to batches using Graphics tint. */
  calculateTints() {
    if (this.batchTint !== this.tint) {
      this.batchTint = this._tintColor.toNumber();
      for (let e = 0; e < this.batches.length; e++) {
        const t = this.batches[e];
        t._tintRGB = be.shared.setValue(this._tintColor).multiply(t._batchRGB).toLittleEndianNumber();
      }
    }
  }
  /** If there's a transform update or a change to the shape of the geometry, recalculate the vertices. */
  calculateVertices() {
    const e = this.transform._worldID;
    if (this._transformID === e)
      return;
    this._transformID = e;
    const t = this.transform.worldTransform, i = t.a, n = t.b, s = t.c, o = t.d, a = t.tx, l = t.ty, h = this._geometry.points, c = this.vertexData;
    let u = 0;
    for (let d = 0; d < h.length; d += 2) {
      const f = h[d], p = h[d + 1];
      c[u++] = i * f + s * p + a, c[u++] = o * p + n * f + l;
    }
  }
  /**
   * Closes the current path.
   * @returns - Returns itself.
   */
  closePath() {
    const e = this.currentPath;
    return e && (e.closeStroke = !0, this.finishPoly()), this;
  }
  /**
   * Apply a matrix to the positional data.
   * @param matrix - Matrix to use for transform current shape.
   * @returns - Returns itself.
   */
  setMatrix(e) {
    return this._matrix = e, this;
  }
  /**
   * Begin adding holes to the last draw shape
   * IMPORTANT: holes must be fully inside a shape to work
   * Also weirdness ensues if holes overlap!
   * Ellipses, Circles, Rectangles and Rounded Rectangles cannot be holes or host for holes in CanvasRenderer,
   * please use `moveTo` `lineTo`, `quadraticCurveTo` if you rely on pixi-legacy bundle.
   * @returns - Returns itself.
   */
  beginHole() {
    return this.finishPoly(), this._holeMode = !0, this;
  }
  /**
   * End adding holes to the last draw shape.
   * @returns - Returns itself.
   */
  endHole() {
    return this.finishPoly(), this._holeMode = !1, this;
  }
  /**
   * Destroys the Graphics object.
   * @param options - Options parameter. A boolean will act as if all
   *  options have been set to that value
   * @param {boolean} [options.children=false] - if set to true, all the children will have
   *  their destroy method called as well. 'options' will be passed on to those calls.
   * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true
   *  Should it destroy the texture of the child sprite
   * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true
   *  Should it destroy the base texture of the child sprite
   */
  destroy(e) {
    this._geometry.refCount--, this._geometry.refCount === 0 && this._geometry.dispose(), this._matrix = null, this.currentPath = null, this._lineStyle.destroy(), this._lineStyle = null, this._fillStyle.destroy(), this._fillStyle = null, this._geometry = null, this.shader = null, this.vertexData = null, this.batches.length = 0, this.batches = null, super.destroy(e);
  }
};
Sc.curves = Nn, /**
* Temporary point to use for containsPoint.
* @private
*/
Sc._TEMP_POINT = new ge();
let Xr = Sc;
class tI {
  /**
   * @param uvBuffer - Buffer with normalized uv's
   * @param uvMatrix - Material UV matrix
   */
  constructor(e, t) {
    this.uvBuffer = e, this.uvMatrix = t, this.data = null, this._bufferUpdateId = -1, this._textureUpdateId = -1, this._updateID = 0;
  }
  /**
   * Updates
   * @param forceUpdate - force the update
   */
  update(e) {
    if (!e && this._bufferUpdateId === this.uvBuffer._updateID && this._textureUpdateId === this.uvMatrix._updateID)
      return;
    this._bufferUpdateId = this.uvBuffer._updateID, this._textureUpdateId = this.uvMatrix._updateID;
    const t = this.uvBuffer.data;
    (!this.data || this.data.length !== t.length) && (this.data = new Float32Array(t.length)), this.uvMatrix.multiplyUvs(t, this.data), this._updateID++;
  }
}
const oh = new ge(), Qf = new Dr(), b0 = class w0 extends Qe {
  /**
   * @param geometry - The geometry the mesh will use.
   * @param {PIXI.MeshMaterial} shader - The shader the mesh will use.
   * @param state - The state that the WebGL context is required to be in to render the mesh
   *        if no state is provided, uses {@link PIXI.State.for2d} to create a 2D state for PixiJS.
   * @param drawMode - The drawMode, can be any of the {@link PIXI.DRAW_MODES} constants.
   */
  constructor(e, t, i, n = pi.TRIANGLES) {
    super(), this.geometry = e, this.shader = t, this.state = i || yi.for2d(), this.drawMode = n, this.start = 0, this.size = 0, this.uvs = null, this.indices = null, this.vertexData = new Float32Array(1), this.vertexDirty = -1, this._transformID = -1, this._roundPixels = Z.ROUND_PIXELS, this.batchUvs = null;
  }
  /**
   * Includes vertex positions, face indices, normals, colors, UVs, and
   * custom attributes within buffers, reducing the cost of passing all
   * this data to the GPU. Can be shared between multiple Mesh objects.
   */
  get geometry() {
    return this._geometry;
  }
  set geometry(e) {
    this._geometry !== e && (this._geometry && (this._geometry.refCount--, this._geometry.refCount === 0 && this._geometry.dispose()), this._geometry = e, this._geometry && this._geometry.refCount++, this.vertexDirty = -1);
  }
  /**
   * To change mesh uv's, change its uvBuffer data and increment its _updateID.
   * @readonly
   */
  get uvBuffer() {
    return this.geometry.buffers[1];
  }
  /**
   * To change mesh vertices, change its uvBuffer data and increment its _updateID.
   * Incrementing _updateID is optional because most of Mesh objects do it anyway.
   * @readonly
   */
  get verticesBuffer() {
    return this.geometry.buffers[0];
  }
  /** Alias for {@link PIXI.Mesh#shader}. */
  set material(e) {
    this.shader = e;
  }
  get material() {
    return this.shader;
  }
  /**
   * The blend mode to be applied to the Mesh. Apply a value of
   * `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.
   * @default PIXI.BLEND_MODES.NORMAL;
   */
  set blendMode(e) {
    this.state.blendMode = e;
  }
  get blendMode() {
    return this.state.blendMode;
  }
  /**
   * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
   * Advantages can include sharper image quality (like text) and faster rendering on canvas.
   * The main disadvantage is movement of objects may appear less smooth.
   * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}
   * @default false
   */
  set roundPixels(e) {
    this._roundPixels !== e && (this._transformID = -1), this._roundPixels = e;
  }
  get roundPixels() {
    return this._roundPixels;
  }
  /**
   * The multiply tint applied to the Mesh. This is a hex value. A value of
   * `0xFFFFFF` will remove any tint effect.
   *
   * Null for non-MeshMaterial shaders
   * @default 0xFFFFFF
   */
  get tint() {
    return "tint" in this.shader ? this.shader.tint : null;
  }
  set tint(e) {
    this.shader.tint = e;
  }
  /**
   * The tint color as a RGB integer
   * @ignore
   */
  get tintValue() {
    return this.shader.tintValue;
  }
  /** The texture that the Mesh uses. Null for non-MeshMaterial shaders */
  get texture() {
    return "texture" in this.shader ? this.shader.texture : null;
  }
  set texture(e) {
    this.shader.texture = e;
  }
  /**
   * Standard renderer draw.
   * @param renderer - Instance to renderer.
   */
  _render(e) {
    const t = this.geometry.buffers[0].data;
    this.shader.batchable && this.drawMode === pi.TRIANGLES && t.length < w0.BATCHABLE_SIZE * 2 ? this._renderToBatch(e) : this._renderDefault(e);
  }
  /**
   * Standard non-batching way of rendering.
   * @param renderer - Instance to renderer.
   */
  _renderDefault(e) {
    const t = this.shader;
    t.alpha = this.worldAlpha, t.update && t.update(), e.batch.flush(), t.uniforms.translationMatrix = this.transform.worldTransform.toArray(!0), e.shader.bind(t), e.state.set(this.state), e.geometry.bind(this.geometry, t), e.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount);
  }
  /**
   * Rendering by using the Batch system.
   * @param renderer - Instance to renderer.
   */
  _renderToBatch(e) {
    const t = this.geometry, i = this.shader;
    i.uvMatrix && (i.uvMatrix.update(), this.calculateUvs()), this.calculateVertices(), this.indices = t.indexBuffer.data, this._tintRGB = i._tintRGB, this._texture = i.texture;
    const n = this.material.pluginName;
    e.batch.setObjectRenderer(e.plugins[n]), e.plugins[n].render(this);
  }
  /** Updates vertexData field based on transform and vertices. */
  calculateVertices() {
    const e = this.geometry.buffers[0], t = e.data, i = e._updateID;
    if (i === this.vertexDirty && this._transformID === this.transform._worldID)
      return;
    this._transformID = this.transform._worldID, this.vertexData.length !== t.length && (this.vertexData = new Float32Array(t.length));
    const n = this.transform.worldTransform, s = n.a, o = n.b, a = n.c, l = n.d, h = n.tx, c = n.ty, u = this.vertexData;
    for (let d = 0; d < u.length / 2; d++) {
      const f = t[d * 2], p = t[d * 2 + 1];
      u[d * 2] = s * f + a * p + h, u[d * 2 + 1] = o * f + l * p + c;
    }
    if (this._roundPixels) {
      const d = Z.RESOLUTION;
      for (let f = 0; f < u.length; ++f)
        u[f] = Math.round(u[f] * d) / d;
    }
    this.vertexDirty = i;
  }
  /** Updates uv field based on from geometry uv's or batchUvs. */
  calculateUvs() {
    const e = this.geometry.buffers[1], t = this.shader;
    t.uvMatrix.isSimple ? this.uvs = e.data : (this.batchUvs || (this.batchUvs = new tI(e, t.uvMatrix)), this.batchUvs.update(), this.uvs = this.batchUvs.data);
  }
  /**
   * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account.
   * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly.
   */
  _calculateBounds() {
    this.calculateVertices(), this._bounds.addVertexData(this.vertexData, 0, this.vertexData.length);
  }
  /**
   * Tests if a point is inside this mesh. Works only for PIXI.DRAW_MODES.TRIANGLES.
   * @param point - The point to test.
   * @returns - The result of the test.
   */
  containsPoint(e) {
    if (!this.getBounds().contains(e.x, e.y))
      return !1;
    this.worldTransform.applyInverse(e, oh);
    const t = this.geometry.getBuffer("aVertexPosition").data, i = Qf.points, n = this.geometry.getIndex().data, s = n.length, o = this.drawMode === 4 ? 3 : 1;
    for (let a = 0; a + 2 < s; a += o) {
      const l = n[a] * 2, h = n[a + 1] * 2, c = n[a + 2] * 2;
      if (i[0] = t[l], i[1] = t[l + 1], i[2] = t[h], i[3] = t[h + 1], i[4] = t[c], i[5] = t[c + 1], Qf.contains(oh.x, oh.y))
        return !0;
    }
    return !1;
  }
  destroy(e) {
    super.destroy(e), this._cachedTexture && (this._cachedTexture.destroy(), this._cachedTexture = null), this.geometry = null, this.shader = null, this.state = null, this.uvs = null, this.indices = null, this.vertexData = null;
  }
};
b0.BATCHABLE_SIZE = 100;
let ep = b0;
class iI extends ir {
  /**
   * @param {Float32Array|number[]} [vertices] - Positional data on geometry.
   * @param {Float32Array|number[]} [uvs] - Texture UVs.
   * @param {Uint16Array|number[]} [index] - IndexBuffer
   */
  constructor(e, t, i) {
    super();
    const n = new Be(e), s = new Be(t, !0), o = new Be(i, !0, !0);
    this.addAttribute("aVertexPosition", n, 2, !1, re.FLOAT).addAttribute("aTextureCoord", s, 2, !1, re.FLOAT).addIndex(o), this._updateId = -1;
  }
  /**
   * If the vertex position is updated.
   * @readonly
   * @private
   */
  get vertexDirtyId() {
    return this.buffers[0]._updateID;
  }
}
var rI = `varying vec2 vTextureCoord;
uniform vec4 uColor;

uniform sampler2D uSampler;

void main(void)
{
    gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
}
`, nI = `attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform mat3 uTextureMatrix;

varying vec2 vTextureCoord;

void main(void)
{
    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
}
`;
class tp extends mi {
  /**
   * @param uSampler - Texture that material uses to render.
   * @param options - Additional options
   * @param {number} [options.alpha=1] - Default alpha.
   * @param {PIXI.ColorSource} [options.tint=0xFFFFFF] - Default tint.
   * @param {string} [options.pluginName='batch'] - Renderer plugin for batching.
   * @param {PIXI.Program} [options.program=0xFFFFFF] - Custom program.
   * @param {object} [options.uniforms] - Custom uniforms.
   */
  constructor(e, t) {
    const i = {
      uSampler: e,
      alpha: 1,
      uTextureMatrix: Te.IDENTITY,
      uColor: new Float32Array([1, 1, 1, 1])
    };
    t = Object.assign({
      tint: 16777215,
      alpha: 1,
      pluginName: "batch"
    }, t), t.uniforms && Object.assign(i, t.uniforms), super(t.program || Ii.from(nI, rI), i), this._colorDirty = !1, this.uvMatrix = new Lm(e), this.batchable = t.program === void 0, this.pluginName = t.pluginName, this._tintColor = new be(t.tint), this._tintRGB = this._tintColor.toLittleEndianNumber(), this._colorDirty = !0, this.alpha = t.alpha;
  }
  /** Reference to the texture being rendered. */
  get texture() {
    return this.uniforms.uSampler;
  }
  set texture(e) {
    this.uniforms.uSampler !== e && (!this.uniforms.uSampler.baseTexture.alphaMode != !e.baseTexture.alphaMode && (this._colorDirty = !0), this.uniforms.uSampler = e, this.uvMatrix.texture = e);
  }
  /**
   * This gets automatically set by the object using this.
   * @default 1
   */
  set alpha(e) {
    e !== this._alpha && (this._alpha = e, this._colorDirty = !0);
  }
  get alpha() {
    return this._alpha;
  }
  /**
   * Multiply tint for the material.
   * @default 0xFFFFFF
   */
  set tint(e) {
    e !== this.tint && (this._tintColor.setValue(e), this._tintRGB = this._tintColor.toLittleEndianNumber(), this._colorDirty = !0);
  }
  get tint() {
    return this._tintColor.value;
  }
  /**
   * Get the internal number from tint color
   * @ignore
   */
  get tintValue() {
    return this._tintColor.toNumber();
  }
  /** Gets called automatically by the Mesh. Intended to be overridden for custom {@link PIXI.MeshMaterial} objects. */
  update() {
    if (this._colorDirty) {
      this._colorDirty = !1;
      const e = this.texture.baseTexture.alphaMode;
      be.shared.setValue(this._tintColor).premultiply(this._alpha, e).toArray(this.uniforms.uColor);
    }
    this.uvMatrix.update() && (this.uniforms.uTextureMatrix = this.uvMatrix.mapCoord);
  }
}
class ip {
  /**
   * @param {object} properties - The properties to upload.
   * @param {boolean[]} dynamicPropertyFlags - Flags for which properties are dynamic.
   * @param {number} size - The size of the batch.
   */
  constructor(e, t, i) {
    this.geometry = new ir(), this.indexBuffer = null, this.size = i, this.dynamicProperties = [], this.staticProperties = [];
    for (let n = 0; n < e.length; ++n) {
      let s = e[n];
      s = {
        attributeName: s.attributeName,
        size: s.size,
        uploadFunction: s.uploadFunction,
        type: s.type || re.FLOAT,
        offset: s.offset
      }, t[n] ? this.dynamicProperties.push(s) : this.staticProperties.push(s);
    }
    this.staticStride = 0, this.staticBuffer = null, this.staticData = null, this.staticDataUint32 = null, this.dynamicStride = 0, this.dynamicBuffer = null, this.dynamicData = null, this.dynamicDataUint32 = null, this._updateID = 0, this.initBuffers();
  }
  /** Sets up the renderer context and necessary buffers. */
  initBuffers() {
    const e = this.geometry;
    let t = 0;
    this.indexBuffer = new Be(AA(this.size), !0, !0), e.addIndex(this.indexBuffer), this.dynamicStride = 0;
    for (let o = 0; o < this.dynamicProperties.length; ++o) {
      const a = this.dynamicProperties[o];
      a.offset = t, t += a.size, this.dynamicStride += a.size;
    }
    const i = new ArrayBuffer(this.size * this.dynamicStride * 4 * 4);
    this.dynamicData = new Float32Array(i), this.dynamicDataUint32 = new Uint32Array(i), this.dynamicBuffer = new Be(this.dynamicData, !1, !1);
    let n = 0;
    this.staticStride = 0;
    for (let o = 0; o < this.staticProperties.length; ++o) {
      const a = this.staticProperties[o];
      a.offset = n, n += a.size, this.staticStride += a.size;
    }
    const s = new ArrayBuffer(this.size * this.staticStride * 4 * 4);
    this.staticData = new Float32Array(s), this.staticDataUint32 = new Uint32Array(s), this.staticBuffer = new Be(this.staticData, !0, !1);
    for (let o = 0; o < this.dynamicProperties.length; ++o) {
      const a = this.dynamicProperties[o];
      e.addAttribute(
        a.attributeName,
        this.dynamicBuffer,
        0,
        a.type === re.UNSIGNED_BYTE,
        a.type,
        this.dynamicStride * 4,
        a.offset * 4
      );
    }
    for (let o = 0; o < this.staticProperties.length; ++o) {
      const a = this.staticProperties[o];
      e.addAttribute(
        a.attributeName,
        this.staticBuffer,
        0,
        a.type === re.UNSIGNED_BYTE,
        a.type,
        this.staticStride * 4,
        a.offset * 4
      );
    }
  }
  /**
   * Uploads the dynamic properties.
   * @param children - The children to upload.
   * @param startIndex - The index to start at.
   * @param amount - The number to upload.
   */
  uploadDynamic(e, t, i) {
    for (let n = 0; n < this.dynamicProperties.length; n++) {
      const s = this.dynamicProperties[n];
      s.uploadFunction(
        e,
        t,
        i,
        s.type === re.UNSIGNED_BYTE ? this.dynamicDataUint32 : this.dynamicData,
        this.dynamicStride,
        s.offset
      );
    }
    this.dynamicBuffer._updateID++;
  }
  /**
   * Uploads the static properties.
   * @param children - The children to upload.
   * @param startIndex - The index to start at.
   * @param amount - The number to upload.
   */
  uploadStatic(e, t, i) {
    for (let n = 0; n < this.staticProperties.length; n++) {
      const s = this.staticProperties[n];
      s.uploadFunction(
        e,
        t,
        i,
        s.type === re.UNSIGNED_BYTE ? this.staticDataUint32 : this.staticData,
        this.staticStride,
        s.offset
      );
    }
    this.staticBuffer._updateID++;
  }
  /** Destroys the ParticleBuffer. */
  destroy() {
    this.indexBuffer = null, this.dynamicProperties = null, this.dynamicBuffer = null, this.dynamicData = null, this.dynamicDataUint32 = null, this.staticProperties = null, this.staticBuffer = null, this.staticData = null, this.staticDataUint32 = null, this.geometry.destroy();
  }
}
var sI = `varying vec2 vTextureCoord;
varying vec4 vColor;

uniform sampler2D uSampler;

void main(void){
    vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
    gl_FragColor = color;
}`, oI = `attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;
attribute vec4 aColor;

attribute vec2 aPositionCoord;
attribute float aRotation;

uniform mat3 translationMatrix;
uniform vec4 uColor;

varying vec2 vTextureCoord;
varying vec4 vColor;

void main(void){
    float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
    float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);

    vec2 v = vec2(x, y);
    v = v + aPositionCoord;

    gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = aTextureCoord;
    vColor = aColor * uColor;
}
`;
class x0 extends Fa {
  /**
   * @param renderer - The renderer this sprite batch works for.
   */
  constructor(e) {
    super(e), this.shader = null, this.properties = null, this.tempMatrix = new Te(), this.properties = [
      // verticesData
      {
        attributeName: "aVertexPosition",
        size: 2,
        uploadFunction: this.uploadVertices,
        offset: 0
      },
      // positionData
      {
        attributeName: "aPositionCoord",
        size: 2,
        uploadFunction: this.uploadPosition,
        offset: 0
      },
      // rotationData
      {
        attributeName: "aRotation",
        size: 1,
        uploadFunction: this.uploadRotation,
        offset: 0
      },
      // uvsData
      {
        attributeName: "aTextureCoord",
        size: 2,
        uploadFunction: this.uploadUvs,
        offset: 0
      },
      // tintData
      {
        attributeName: "aColor",
        size: 1,
        type: re.UNSIGNED_BYTE,
        uploadFunction: this.uploadTint,
        offset: 0
      }
    ], this.shader = mi.from(oI, sI, {}), this.state = yi.for2d();
  }
  /**
   * Renders the particle container object.
   * @param container - The container to render using this ParticleRenderer.
   */
  render(e) {
    const t = e.children, i = e._maxSize, n = e._batchSize, s = this.renderer;
    let o = t.length;
    if (o === 0)
      return;
    o > i && !e.autoResize && (o = i);
    let a = e._buffers;
    a || (a = e._buffers = this.generateBuffers(e));
    const l = t[0]._texture.baseTexture, h = l.alphaMode > 0;
    this.state.blendMode = bm(e.blendMode, h), s.state.set(this.state);
    const c = s.gl, u = e.worldTransform.copyTo(this.tempMatrix);
    u.prepend(s.globalUniforms.uniforms.projectionMatrix), this.shader.uniforms.translationMatrix = u.toArray(!0), this.shader.uniforms.uColor = be.shared.setValue(e.tintRgb).premultiply(e.worldAlpha, h).toArray(this.shader.uniforms.uColor), this.shader.uniforms.uSampler = l, this.renderer.shader.bind(this.shader);
    let d = !1;
    for (let f = 0, p = 0; f < o; f += n, p += 1) {
      let _ = o - f;
      _ > n && (_ = n), p >= a.length && a.push(this._generateOneMoreBuffer(e));
      const m = a[p];
      m.uploadDynamic(t, f, _);
      const y = e._bufferUpdateIDs[p] || 0;
      d = d || m._updateID < y, d && (m._updateID = e._updateID, m.uploadStatic(t, f, _)), s.geometry.bind(m.geometry), c.drawElements(c.TRIANGLES, _ * 6, c.UNSIGNED_SHORT, 0);
    }
  }
  /**
   * Creates one particle buffer for each child in the container we want to render and updates internal properties.
   * @param container - The container to render using this ParticleRenderer
   * @returns - The buffers
   */
  generateBuffers(e) {
    const t = [], i = e._maxSize, n = e._batchSize, s = e._properties;
    for (let o = 0; o < i; o += n)
      t.push(new ip(this.properties, s, n));
    return t;
  }
  /**
   * Creates one more particle buffer, because container has autoResize feature.
   * @param container - The container to render using this ParticleRenderer
   * @returns - The generated buffer
   */
  _generateOneMoreBuffer(e) {
    const t = e._batchSize, i = e._properties;
    return new ip(this.properties, i, t);
  }
  /**
   * Uploads the vertices.
   * @param children - the array of sprites to render
   * @param startIndex - the index to start from in the children array
   * @param amount - the amount of children that will have their vertices uploaded
   * @param array - The vertices to upload.
   * @param stride - Stride to use for iteration.
   * @param offset - Offset to start at.
   */
  uploadVertices(e, t, i, n, s, o) {
    let a = 0, l = 0, h = 0, c = 0;
    for (let u = 0; u < i; ++u) {
      const d = e[t + u], f = d._texture, p = d.scale.x, _ = d.scale.y, m = f.trim, y = f.orig;
      m ? (l = m.x - d.anchor.x * y.width, a = l + m.width, c = m.y - d.anchor.y * y.height, h = c + m.height) : (a = y.width * (1 - d.anchor.x), l = y.width * -d.anchor.x, h = y.height * (1 - d.anchor.y), c = y.height * -d.anchor.y), n[o] = l * p, n[o + 1] = c * _, n[o + s] = a * p, n[o + s + 1] = c * _, n[o + s * 2] = a * p, n[o + s * 2 + 1] = h * _, n[o + s * 3] = l * p, n[o + s * 3 + 1] = h * _, o += s * 4;
    }
  }
  /**
   * Uploads the position.
   * @param children - the array of sprites to render
   * @param startIndex - the index to start from in the children array
   * @param amount - the amount of children that will have their positions uploaded
   * @param array - The vertices to upload.
   * @param stride - Stride to use for iteration.
   * @param offset - Offset to start at.
   */
  uploadPosition(e, t, i, n, s, o) {
    for (let a = 0; a < i; a++) {
      const l = e[t + a].position;
      n[o] = l.x, n[o + 1] = l.y, n[o + s] = l.x, n[o + s + 1] = l.y, n[o + s * 2] = l.x, n[o + s * 2 + 1] = l.y, n[o + s * 3] = l.x, n[o + s * 3 + 1] = l.y, o += s * 4;
    }
  }
  /**
   * Uploads the rotation.
   * @param children - the array of sprites to render
   * @param startIndex - the index to start from in the children array
   * @param amount - the amount of children that will have their rotation uploaded
   * @param array - The vertices to upload.
   * @param stride - Stride to use for iteration.
   * @param offset - Offset to start at.
   */
  uploadRotation(e, t, i, n, s, o) {
    for (let a = 0; a < i; a++) {
      const l = e[t + a].rotation;
      n[o] = l, n[o + s] = l, n[o + s * 2] = l, n[o + s * 3] = l, o += s * 4;
    }
  }
  /**
   * Uploads the UVs.
   * @param children - the array of sprites to render
   * @param startIndex - the index to start from in the children array
   * @param amount - the amount of children that will have their rotation uploaded
   * @param array - The vertices to upload.
   * @param stride - Stride to use for iteration.
   * @param offset - Offset to start at.
   */
  uploadUvs(e, t, i, n, s, o) {
    for (let a = 0; a < i; ++a) {
      const l = e[t + a]._texture._uvs;
      l ? (n[o] = l.x0, n[o + 1] = l.y0, n[o + s] = l.x1, n[o + s + 1] = l.y1, n[o + s * 2] = l.x2, n[o + s * 2 + 1] = l.y2, n[o + s * 3] = l.x3, n[o + s * 3 + 1] = l.y3, o += s * 4) : (n[o] = 0, n[o + 1] = 0, n[o + s] = 0, n[o + s + 1] = 0, n[o + s * 2] = 0, n[o + s * 2 + 1] = 0, n[o + s * 3] = 0, n[o + s * 3 + 1] = 0, o += s * 4);
    }
  }
  /**
   * Uploads the tint.
   * @param children - the array of sprites to render
   * @param startIndex - the index to start from in the children array
   * @param amount - the amount of children that will have their rotation uploaded
   * @param array - The vertices to upload.
   * @param stride - Stride to use for iteration.
   * @param offset - Offset to start at.
   */
  uploadTint(e, t, i, n, s, o) {
    for (let a = 0; a < i; ++a) {
      const l = e[t + a], h = be.shared.setValue(l._tintRGB).toPremultiplied(l.alpha, l.texture.baseTexture.alphaMode > 0);
      n[o] = h, n[o + s] = h, n[o + s * 2] = h, n[o + s * 3] = h, o += s * 4;
    }
  }
  /** Destroys the ParticleRenderer. */
  destroy() {
    super.destroy(), this.shader && (this.shader.destroy(), this.shader = null), this.tempMatrix = null;
  }
}
x0.extension = {
  name: "particle",
  type: q.RendererPlugin
};
Q.add(x0);
var Na = /* @__PURE__ */ ((r) => (r[r.LINEAR_VERTICAL = 0] = "LINEAR_VERTICAL", r[r.LINEAR_HORIZONTAL = 1] = "LINEAR_HORIZONTAL", r))(Na || {});
const yo = {
  // TextMetrics requires getImageData readback for measuring fonts.
  willReadFrequently: !0
}, ai = class ee {
  /**
   * Checking that we can use modern canvas 2D API.
   *
   * Note: This is an unstable API, Chrome < 94 use `textLetterSpacing`, later versions use `letterSpacing`.
   * @see PIXI.TextMetrics.experimentalLetterSpacing
   * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/letterSpacing
   * @see https://developer.chrome.com/origintrials/#/view_trial/3585991203293757441
   */
  static get experimentalLetterSpacingSupported() {
    let e = ee._experimentalLetterSpacingSupported;
    if (e !== void 0) {
      const t = Z.ADAPTER.getCanvasRenderingContext2D().prototype;
      e = ee._experimentalLetterSpacingSupported = "letterSpacing" in t || "textLetterSpacing" in t;
    }
    return e;
  }
  /**
   * @param text - the text that was measured
   * @param style - the style that was measured
   * @param width - the measured width of the text
   * @param height - the measured height of the text
   * @param lines - an array of the lines of text broken by new lines and wrapping if specified in style
   * @param lineWidths - an array of the line widths for each line matched to `lines`
   * @param lineHeight - the measured line height for this style
   * @param maxLineWidth - the maximum line width for all measured lines
   * @param {PIXI.IFontMetrics} fontProperties - the font properties object from TextMetrics.measureFont
   */
  constructor(e, t, i, n, s, o, a, l, h) {
    this.text = e, this.style = t, this.width = i, this.height = n, this.lines = s, this.lineWidths = o, this.lineHeight = a, this.maxLineWidth = l, this.fontProperties = h;
  }
  /**
   * Measures the supplied string of text and returns a Rectangle.
   * @param text - The text to measure.
   * @param style - The text style to use for measuring
   * @param wordWrap - Override for if word-wrap should be applied to the text.
   * @param canvas - optional specification of the canvas to use for measuring.
   * @returns Measured width and height of the text.
   */
  static measureText(e, t, i, n = ee._canvas) {
    i = i ?? t.wordWrap;
    const s = t.toFontString(), o = ee.measureFont(s);
    o.fontSize === 0 && (o.fontSize = t.fontSize, o.ascent = t.fontSize);
    const a = n.getContext("2d", yo);
    a.font = s;
    const l = (i ? ee.wordWrap(e, t, n) : e).split(/(?:\r\n|\r|\n)/), h = new Array(l.length);
    let c = 0;
    for (let p = 0; p < l.length; p++) {
      const _ = ee._measureText(l[p], t.letterSpacing, a);
      h[p] = _, c = Math.max(c, _);
    }
    let u = c + t.strokeThickness;
    t.dropShadow && (u += t.dropShadowDistance);
    const d = t.lineHeight || o.fontSize + t.strokeThickness;
    let f = Math.max(d, o.fontSize + t.strokeThickness * 2) + t.leading + (l.length - 1) * (d + t.leading);
    return t.dropShadow && (f += t.dropShadowDistance), new ee(
      e,
      t,
      u,
      f,
      l,
      h,
      d + t.leading,
      c,
      o
    );
  }
  static _measureText(e, t, i) {
    let n = !1;
    ee.experimentalLetterSpacingSupported && (ee.experimentalLetterSpacing ? (i.letterSpacing = `${t}px`, i.textLetterSpacing = `${t}px`, n = !0) : (i.letterSpacing = "0px", i.textLetterSpacing = "0px"));
    let s = i.measureText(e).width;
    return s > 0 && (n ? s -= t : s += (ee.graphemeSegmenter(e).length - 1) * t), s;
  }
  /**
   * Applies newlines to a string to have it optimally fit into the horizontal
   * bounds set by the Text object's wordWrapWidth property.
   * @param text - String to apply word wrapping to
   * @param style - the style to use when wrapping
   * @param canvas - optional specification of the canvas to use for measuring.
   * @returns New string with new lines applied where required
   */
  static wordWrap(e, t, i = ee._canvas) {
    const n = i.getContext("2d", yo);
    let s = 0, o = "", a = "";
    const l = /* @__PURE__ */ Object.create(null), { letterSpacing: h, whiteSpace: c } = t, u = ee.collapseSpaces(c), d = ee.collapseNewlines(c);
    let f = !u;
    const p = t.wordWrapWidth + h, _ = ee.tokenize(e);
    for (let m = 0; m < _.length; m++) {
      let y = _[m];
      if (ee.isNewline(y)) {
        if (!d) {
          a += ee.addLine(o), f = !u, o = "", s = 0;
          continue;
        }
        y = " ";
      }
      if (u) {
        const g = ee.isBreakingSpace(y), b = ee.isBreakingSpace(o[o.length - 1]);
        if (g && b)
          continue;
      }
      const v = ee.getFromCache(y, h, l, n);
      if (v > p)
        if (o !== "" && (a += ee.addLine(o), o = "", s = 0), ee.canBreakWords(y, t.breakWords)) {
          const g = ee.wordWrapSplit(y);
          for (let b = 0; b < g.length; b++) {
            let w = g[b], T = w, x = 1;
            for (; g[b + x]; ) {
              const R = g[b + x];
              if (!ee.canBreakChars(T, R, y, b, t.breakWords))
                w += R;
              else
                break;
              T = R, x++;
            }
            b += x - 1;
            const E = ee.getFromCache(w, h, l, n);
            E + s > p && (a += ee.addLine(o), f = !1, o = "", s = 0), o += w, s += E;
          }
        } else {
          o.length > 0 && (a += ee.addLine(o), o = "", s = 0);
          const g = m === _.length - 1;
          a += ee.addLine(y, !g), f = !1, o = "", s = 0;
        }
      else
        v + s > p && (f = !1, a += ee.addLine(o), o = "", s = 0), (o.length > 0 || !ee.isBreakingSpace(y) || f) && (o += y, s += v);
    }
    return a += ee.addLine(o, !1), a;
  }
  /**
   * Convienience function for logging each line added during the wordWrap method.
   * @param line    - The line of text to add
   * @param newLine - Add new line character to end
   * @returns A formatted line
   */
  static addLine(e, t = !0) {
    return e = ee.trimRight(e), e = t ? `${e}
` : e, e;
  }
  /**
   * Gets & sets the widths of calculated characters in a cache object
   * @param key            - The key
   * @param letterSpacing  - The letter spacing
   * @param cache          - The cache
   * @param context        - The canvas context
   * @returns The from cache.
   */
  static getFromCache(e, t, i, n) {
    let s = i[e];
    return typeof s != "number" && (s = ee._measureText(e, t, n) + t, i[e] = s), s;
  }
  /**
   * Determines whether we should collapse breaking spaces.
   * @param whiteSpace - The TextStyle property whiteSpace
   * @returns Should collapse
   */
  static collapseSpaces(e) {
    return e === "normal" || e === "pre-line";
  }
  /**
   * Determines whether we should collapse newLine chars.
   * @param whiteSpace - The white space
   * @returns should collapse
   */
  static collapseNewlines(e) {
    return e === "normal";
  }
  /**
   * Trims breaking whitespaces from string.
   * @param text - The text
   * @returns Trimmed string
   */
  static trimRight(e) {
    if (typeof e != "string")
      return "";
    for (let t = e.length - 1; t >= 0; t--) {
      const i = e[t];
      if (!ee.isBreakingSpace(i))
        break;
      e = e.slice(0, -1);
    }
    return e;
  }
  /**
   * Determines if char is a newline.
   * @param char - The character
   * @returns True if newline, False otherwise.
   */
  static isNewline(e) {
    return typeof e != "string" ? !1 : ee._newlines.includes(e.charCodeAt(0));
  }
  /**
   * Determines if char is a breaking whitespace.
   *
   * It allows one to determine whether char should be a breaking whitespace
   * For example certain characters in CJK langs or numbers.
   * It must return a boolean.
   * @param char - The character
   * @param [_nextChar] - The next character
   * @returns True if whitespace, False otherwise.
   */
  static isBreakingSpace(e, t) {
    return typeof e != "string" ? !1 : ee._breakingSpaces.includes(e.charCodeAt(0));
  }
  /**
   * Splits a string into words, breaking-spaces and newLine characters
   * @param text - The text
   * @returns A tokenized array
   */
  static tokenize(e) {
    const t = [];
    let i = "";
    if (typeof e != "string")
      return t;
    for (let n = 0; n < e.length; n++) {
      const s = e[n], o = e[n + 1];
      if (ee.isBreakingSpace(s, o) || ee.isNewline(s)) {
        i !== "" && (t.push(i), i = ""), t.push(s);
        continue;
      }
      i += s;
    }
    return i !== "" && t.push(i), t;
  }
  /**
   * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
   *
   * It allows one to customise which words should break
   * Examples are if the token is CJK or numbers.
   * It must return a boolean.
   * @param _token - The token
   * @param breakWords - The style attr break words
   * @returns Whether to break word or not
   */
  static canBreakWords(e, t) {
    return t;
  }
  /**
   * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
   *
   * It allows one to determine whether a pair of characters
   * should be broken by newlines
   * For example certain characters in CJK langs or numbers.
   * It must return a boolean.
   * @param _char - The character
   * @param _nextChar - The next character
   * @param _token - The token/word the characters are from
   * @param _index - The index in the token of the char
   * @param _breakWords - The style attr break words
   * @returns whether to break word or not
   */
  static canBreakChars(e, t, i, n, s) {
    return !0;
  }
  /**
   * Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
   *
   * It is called when a token (usually a word) has to be split into separate pieces
   * in order to determine the point to break a word.
   * It must return an array of characters.
   * @param token - The token to split
   * @returns The characters of the token
   * @see TextMetrics.graphemeSegmenter
   */
  static wordWrapSplit(e) {
    return ee.graphemeSegmenter(e);
  }
  /**
   * Calculates the ascent, descent and fontSize of a given font-style
   * @param font - String representing the style of the font
   * @returns Font properties object
   */
  static measureFont(e) {
    if (ee._fonts[e])
      return ee._fonts[e];
    const t = {
      ascent: 0,
      descent: 0,
      fontSize: 0
    }, i = ee._canvas, n = ee._context;
    n.font = e;
    const s = ee.METRICS_STRING + ee.BASELINE_SYMBOL, o = Math.ceil(n.measureText(s).width);
    let a = Math.ceil(n.measureText(ee.BASELINE_SYMBOL).width);
    const l = Math.ceil(ee.HEIGHT_MULTIPLIER * a);
    if (a = a * ee.BASELINE_MULTIPLIER | 0, o === 0 || l === 0)
      return ee._fonts[e] = t, t;
    i.width = o, i.height = l, n.fillStyle = "#f00", n.fillRect(0, 0, o, l), n.font = e, n.textBaseline = "alphabetic", n.fillStyle = "#000", n.fillText(s, 0, a);
    const h = n.getImageData(0, 0, o, l).data, c = h.length, u = o * 4;
    let d = 0, f = 0, p = !1;
    for (d = 0; d < a; ++d) {
      for (let _ = 0; _ < u; _ += 4)
        if (h[f + _] !== 255) {
          p = !0;
          break;
        }
      if (!p)
        f += u;
      else
        break;
    }
    for (t.ascent = a - d, f = c - u, p = !1, d = l; d > a; --d) {
      for (let _ = 0; _ < u; _ += 4)
        if (h[f + _] !== 255) {
          p = !0;
          break;
        }
      if (!p)
        f -= u;
      else
        break;
    }
    return t.descent = d - a, t.fontSize = t.ascent + t.descent, ee._fonts[e] = t, t;
  }
  /**
   * Clear font metrics in metrics cache.
   * @param {string} [font] - font name. If font name not set then clear cache for all fonts.
   */
  static clearMetrics(e = "") {
    e ? delete ee._fonts[e] : ee._fonts = {};
  }
  /**
   * Cached canvas element for measuring text
   * TODO: this should be private, but isn't because of backward compat, will fix later.
   * @ignore
   */
  static get _canvas() {
    var e;
    if (!ee.__canvas) {
      let t;
      try {
        const i = new OffscreenCanvas(0, 0);
        if ((e = i.getContext("2d", yo)) != null && e.measureText)
          return ee.__canvas = i, i;
        t = Z.ADAPTER.createCanvas();
      } catch {
        t = Z.ADAPTER.createCanvas();
      }
      t.width = t.height = 10, ee.__canvas = t;
    }
    return ee.__canvas;
  }
  /**
   * TODO: this should be private, but isn't because of backward compat, will fix later.
   * @ignore
   */
  static get _context() {
    return ee.__context || (ee.__context = ee._canvas.getContext("2d", yo)), ee.__context;
  }
};
ai.METRICS_STRING = "|ÉqÅ", /** Baseline symbol for calculate font metrics. */
ai.BASELINE_SYMBOL = "M", /** Baseline multiplier for calculate font metrics. */
ai.BASELINE_MULTIPLIER = 1.4, /** Height multiplier for setting height of canvas to calculate font metrics. */
ai.HEIGHT_MULTIPLIER = 2, /**
* A Unicode "character", or "grapheme cluster", can be composed of multiple Unicode code points,
* such as letters with diacritical marks (e.g. `'\u0065\u0301'`, letter e with acute)
* or emojis with modifiers (e.g. `'\uD83E\uDDD1\u200D\uD83D\uDCBB'`, technologist).
* The new `Intl.Segmenter` API in ES2022 can split the string into grapheme clusters correctly. If it is not available,
* PixiJS will fallback to use the iterator of String, which can only spilt the string into code points.
* If you want to get full functionality in environments that don't support `Intl.Segmenter` (such as Firefox),
* you can use other libraries such as [grapheme-splitter]{@link https://www.npmjs.com/package/grapheme-splitter}
* or [graphemer]{@link https://www.npmjs.com/package/graphemer} to create a polyfill. Since these libraries can be
* relatively large in size to handle various Unicode grapheme clusters properly, PixiJS won't use them directly.
*/
ai.graphemeSegmenter = (() => {
  if (typeof (Intl == null ? void 0 : Intl.Segmenter) == "function") {
    const r = new Intl.Segmenter();
    return (e) => [...r.segment(e)].map((t) => t.segment);
  }
  return (r) => [...r];
})(), /**
* New rendering behavior for letter-spacing which uses Chrome's new native API. This will
* lead to more accurate letter-spacing results because it does not try to manually draw
* each character. However, this Chrome API is experimental and may not serve all cases yet.
* @see PIXI.TextMetrics.experimentalLetterSpacingSupported
*/
ai.experimentalLetterSpacing = !1, /** Cache of {@see PIXI.TextMetrics.FontMetrics} objects. */
ai._fonts = {}, /** Cache of new line chars. */
ai._newlines = [
  10,
  // line feed
  13
  // carriage return
], /** Cache of breaking spaces. */
ai._breakingSpaces = [
  9,
  // character tabulation
  32,
  // space
  8192,
  // en quad
  8193,
  // em quad
  8194,
  // en space
  8195,
  // em space
  8196,
  // three-per-em space
  8197,
  // four-per-em space
  8198,
  // six-per-em space
  8200,
  // punctuation space
  8201,
  // thin space
  8202,
  // hair space
  8287,
  // medium mathematical space
  12288
  // ideographic space
];
let ji = ai;
const aI = [
  "serif",
  "sans-serif",
  "monospace",
  "cursive",
  "fantasy",
  "system-ui"
], E0 = class fs {
  /**
   * @param style - TextStyle properties to be set on the text. See {@link PIXI.TextStyle.defaultStyle}
   *       for the default values.
   */
  constructor(e) {
    this.styleID = 0, this.reset(), lh(this, e, e);
  }
  /**
   * Creates a new TextStyle object with the same values as this one.
   * Note that the only the properties of the object are cloned.
   *
   * @return New cloned TextStyle object
   */
  clone() {
    const e = {};
    return lh(e, this, fs.defaultStyle), new fs(e);
  }
  /** Resets all properties to the defaults specified in TextStyle.prototype._default */
  reset() {
    lh(this, fs.defaultStyle, fs.defaultStyle);
  }
  /**
   * Alignment for multiline text, does not affect single line text.
   *
   * @member {'left'|'center'|'right'|'justify'}
   */
  get align() {
    return this._align;
  }
  set align(e) {
    this._align !== e && (this._align = e, this.styleID++);
  }
  /** Indicates if lines can be wrapped within words, it needs wordWrap to be set to true. */
  get breakWords() {
    return this._breakWords;
  }
  set breakWords(e) {
    this._breakWords !== e && (this._breakWords = e, this.styleID++);
  }
  /** Set a drop shadow for the text. */
  get dropShadow() {
    return this._dropShadow;
  }
  set dropShadow(e) {
    this._dropShadow !== e && (this._dropShadow = e, this.styleID++);
  }
  /** Set alpha for the drop shadow. */
  get dropShadowAlpha() {
    return this._dropShadowAlpha;
  }
  set dropShadowAlpha(e) {
    this._dropShadowAlpha !== e && (this._dropShadowAlpha = e, this.styleID++);
  }
  /** Set a angle of the drop shadow. */
  get dropShadowAngle() {
    return this._dropShadowAngle;
  }
  set dropShadowAngle(e) {
    this._dropShadowAngle !== e && (this._dropShadowAngle = e, this.styleID++);
  }
  /** Set a shadow blur radius. */
  get dropShadowBlur() {
    return this._dropShadowBlur;
  }
  set dropShadowBlur(e) {
    this._dropShadowBlur !== e && (this._dropShadowBlur = e, this.styleID++);
  }
  /** A fill style to be used on the dropshadow e.g., 'red', '#00FF00'. */
  get dropShadowColor() {
    return this._dropShadowColor;
  }
  set dropShadowColor(e) {
    const t = ah(e);
    this._dropShadowColor !== t && (this._dropShadowColor = t, this.styleID++);
  }
  /** Set a distance of the drop shadow. */
  get dropShadowDistance() {
    return this._dropShadowDistance;
  }
  set dropShadowDistance(e) {
    this._dropShadowDistance !== e && (this._dropShadowDistance = e, this.styleID++);
  }
  /**
   * A canvas fillstyle that will be used on the text e.g., 'red', '#00FF00'.
   *
   * Can be an array to create a gradient e.g., `['#000000','#FFFFFF']`
   * {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle|MDN}
   *
   * @member {string|string[]|number|number[]|CanvasGradient|CanvasPattern}
   */
  get fill() {
    return this._fill;
  }
  set fill(e) {
    const t = ah(e);
    this._fill !== t && (this._fill = t, this.styleID++);
  }
  /**
   * If fill is an array of colours to create a gradient, this can change the type/direction of the gradient.
   *
   * @type {PIXI.TEXT_GRADIENT}
   */
  get fillGradientType() {
    return this._fillGradientType;
  }
  set fillGradientType(e) {
    this._fillGradientType !== e && (this._fillGradientType = e, this.styleID++);
  }
  /**
   * If fill is an array of colours to create a gradient, this array can set the stop points
   * (numbers between 0 and 1) for the color, overriding the default behaviour of evenly spacing them.
   */
  get fillGradientStops() {
    return this._fillGradientStops;
  }
  set fillGradientStops(e) {
    lI(this._fillGradientStops, e) || (this._fillGradientStops = e, this.styleID++);
  }
  /**
   * The font family, can be a single font name, or a list of names where the first
   * is the preferred font.
   */
  get fontFamily() {
    return this._fontFamily;
  }
  set fontFamily(e) {
    this.fontFamily !== e && (this._fontFamily = e, this.styleID++);
  }
  /**
   * The font size
   * (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
   */
  get fontSize() {
    return this._fontSize;
  }
  set fontSize(e) {
    this._fontSize !== e && (this._fontSize = e, this.styleID++);
  }
  /**
   * The font style.
   *
   * @member {'normal'|'italic'|'oblique'}
   */
  get fontStyle() {
    return this._fontStyle;
  }
  set fontStyle(e) {
    this._fontStyle !== e && (this._fontStyle = e, this.styleID++);
  }
  /**
   * The font variant.
   *
   * @member {'normal'|'small-caps'}
   */
  get fontVariant() {
    return this._fontVariant;
  }
  set fontVariant(e) {
    this._fontVariant !== e && (this._fontVariant = e, this.styleID++);
  }
  /**
   * The font weight.
   *
   * @member {'normal'|'bold'|'bolder'|'lighter'|'100'|'200'|'300'|'400'|'500'|'600'|'700'|'800'|'900'}
   */
  get fontWeight() {
    return this._fontWeight;
  }
  set fontWeight(e) {
    this._fontWeight !== e && (this._fontWeight = e, this.styleID++);
  }
  /** The amount of spacing between letters, default is 0. */
  get letterSpacing() {
    return this._letterSpacing;
  }
  set letterSpacing(e) {
    this._letterSpacing !== e && (this._letterSpacing = e, this.styleID++);
  }
  /** The line height, a number that represents the vertical space that a letter uses. */
  get lineHeight() {
    return this._lineHeight;
  }
  set lineHeight(e) {
    this._lineHeight !== e && (this._lineHeight = e, this.styleID++);
  }
  /** The space between lines. */
  get leading() {
    return this._leading;
  }
  set leading(e) {
    this._leading !== e && (this._leading = e, this.styleID++);
  }
  /**
   * The lineJoin property sets the type of corner created, it can resolve spiked text issues.
   * Default is 'miter' (creates a sharp corner).
   *
   * @member {'miter'|'round'|'bevel'}
   */
  get lineJoin() {
    return this._lineJoin;
  }
  set lineJoin(e) {
    this._lineJoin !== e && (this._lineJoin = e, this.styleID++);
  }
  /**
   * The miter limit to use when using the 'miter' lineJoin mode.
   *
   * This can reduce or increase the spikiness of rendered text.
   */
  get miterLimit() {
    return this._miterLimit;
  }
  set miterLimit(e) {
    this._miterLimit !== e && (this._miterLimit = e, this.styleID++);
  }
  /**
   * Occasionally some fonts are cropped. Adding some padding will prevent this from happening
   * by adding padding to all sides of the text.
   */
  get padding() {
    return this._padding;
  }
  set padding(e) {
    this._padding !== e && (this._padding = e, this.styleID++);
  }
  /**
   * A canvas fillstyle that will be used on the text stroke, e.g., 'blue', '#FCFF00'
   */
  get stroke() {
    return this._stroke;
  }
  set stroke(e) {
    const t = ah(e);
    this._stroke !== t && (this._stroke = t, this.styleID++);
  }
  /**
   * A number that represents the thickness of the stroke.
   *
   * @default 0
   */
  get strokeThickness() {
    return this._strokeThickness;
  }
  set strokeThickness(e) {
    this._strokeThickness !== e && (this._strokeThickness = e, this.styleID++);
  }
  /**
   * The baseline of the text that is rendered.
   *
   * @member {'alphabetic'|'top'|'hanging'|'middle'|'ideographic'|'bottom'}
   */
  get textBaseline() {
    return this._textBaseline;
  }
  set textBaseline(e) {
    this._textBaseline !== e && (this._textBaseline = e, this.styleID++);
  }
  /** Trim transparent borders. */
  get trim() {
    return this._trim;
  }
  set trim(e) {
    this._trim !== e && (this._trim = e, this.styleID++);
  }
  /**
   * How newlines and spaces should be handled.
   * Default is 'pre' (preserve, preserve).
   *
   *  value       | New lines     |   Spaces
   *  ---         | ---           |   ---
   * 'normal'     | Collapse      |   Collapse
   * 'pre'        | Preserve      |   Preserve
   * 'pre-line'   | Preserve      |   Collapse
   *
   * @member {'normal'|'pre'|'pre-line'}
   */
  get whiteSpace() {
    return this._whiteSpace;
  }
  set whiteSpace(e) {
    this._whiteSpace !== e && (this._whiteSpace = e, this.styleID++);
  }
  /** Indicates if word wrap should be used. */
  get wordWrap() {
    return this._wordWrap;
  }
  set wordWrap(e) {
    this._wordWrap !== e && (this._wordWrap = e, this.styleID++);
  }
  /** The width at which text will wrap, it needs wordWrap to be set to true. */
  get wordWrapWidth() {
    return this._wordWrapWidth;
  }
  set wordWrapWidth(e) {
    this._wordWrapWidth !== e && (this._wordWrapWidth = e, this.styleID++);
  }
  /**
   * Generates a font style string to use for `TextMetrics.measureFont()`.
   *
   * @return Font style string, for passing to `TextMetrics.measureFont()`
   */
  toFontString() {
    const e = typeof this.fontSize == "number" ? `${this.fontSize}px` : this.fontSize;
    let t = this.fontFamily;
    Array.isArray(this.fontFamily) || (t = this.fontFamily.split(","));
    for (let i = t.length - 1; i >= 0; i--) {
      let n = t[i].trim();
      !/([\"\'])[^\'\"]+\1/.test(n) && !aI.includes(n) && (n = `"${n}"`), t[i] = n;
    }
    return `${this.fontStyle} ${this.fontVariant} ${this.fontWeight} ${e} ${t.join(",")}`;
  }
};
E0.defaultStyle = {
  /**
   * See {@link PIXI.TextStyle.align}
   * @type {'left'|'center'|'right'|'justify'}
   */
  align: "left",
  /** See {@link PIXI.TextStyle.breakWords} */
  breakWords: !1,
  /** See {@link PIXI.TextStyle.dropShadow} */
  dropShadow: !1,
  /** See {@link PIXI.TextStyle.dropShadowAlpha} */
  dropShadowAlpha: 1,
  /**
   * See {@link PIXI.TextStyle.dropShadowAngle}
   * @type {number}
   * @default Math.PI / 6
   */
  dropShadowAngle: Math.PI / 6,
  /** See {@link PIXI.TextStyle.dropShadowBlur} */
  dropShadowBlur: 0,
  /**
   * See {@link PIXI.TextStyle.dropShadowColor}
   * @type {string|number}
   */
  dropShadowColor: "black",
  /** See {@link PIXI.TextStyle.dropShadowDistance} */
  dropShadowDistance: 5,
  /**
   * See {@link PIXI.TextStyle.fill}
   * @type {string|string[]|number|number[]|CanvasGradient|CanvasPattern}
   */
  fill: "black",
  /**
   * See {@link PIXI.TextStyle.fillGradientType}
   * @type {PIXI.TEXT_GRADIENT}
   * @default PIXI.TEXT_GRADIENT.LINEAR_VERTICAL
   */
  fillGradientType: Na.LINEAR_VERTICAL,
  /**
   * See {@link PIXI.TextStyle.fillGradientStops}
   * @type {number[]}
   * @default []
   */
  fillGradientStops: [],
  /**
   * See {@link PIXI.TextStyle.fontFamily}
   * @type {string|string[]}
   */
  fontFamily: "Arial",
  /**
   * See {@link PIXI.TextStyle.fontSize}
   * @type {number|string} 
   */
  fontSize: 26,
  /**
   * See {@link PIXI.TextStyle.fontStyle}
   * @type {'normal'|'italic'|'oblique'}
   */
  fontStyle: "normal",
  /**
   * See {@link PIXI.TextStyle.fontVariant}
   * @type {'normal'|'small-caps'}
   */
  fontVariant: "normal",
  /**
   * See {@link PIXI.TextStyle.fontWeight}
   * @type {'normal'|'bold'|'bolder'|'lighter'|'100'|'200'|'300'|'400'|'500'|'600'|'700'|'800'|'900'}
   */
  fontWeight: "normal",
  /** See {@link PIXI.TextStyle.leading} */
  leading: 0,
  /** See {@link PIXI.TextStyle.letterSpacing} */
  letterSpacing: 0,
  /** See {@link PIXI.TextStyle.lineHeight} */
  lineHeight: 0,
  /**
   * See {@link PIXI.TextStyle.lineJoin}
   * @type {'miter'|'round'|'bevel'}
   */
  lineJoin: "miter",
  /** See {@link PIXI.TextStyle.miterLimit} */
  miterLimit: 10,
  /** See {@link PIXI.TextStyle.padding} */
  padding: 0,
  /**
   * See {@link PIXI.TextStyle.stroke}
   * @type {string|number}
   */
  stroke: "black",
  /** See {@link PIXI.TextStyle.strokeThickness} */
  strokeThickness: 0,
  /**
   * See {@link PIXI.TextStyle.textBaseline} 
   * @type {'alphabetic'|'top'|'hanging'|'middle'|'ideographic'|'bottom'}
   */
  textBaseline: "alphabetic",
  /** See {@link PIXI.TextStyle.trim} */
  trim: !1,
  /**
   * See {@link PIXI.TextStyle.whiteSpace}
   * @type {'normal'|'pre'|'pre-line'}
   */
  whiteSpace: "pre",
  /** See {@link PIXI.TextStyle.wordWrap} */
  wordWrap: !1,
  /** See {@link PIXI.TextStyle.wordWrapWidth} */
  wordWrapWidth: 100
};
let rr = E0;
function ah(r) {
  const e = be.shared, t = (i) => {
    const n = e.setValue(i);
    return n.alpha === 1 ? n.toHex() : n.toRgbaString();
  };
  return Array.isArray(r) ? r.map(t) : t(r);
}
function lI(r, e) {
  if (!Array.isArray(r) || !Array.isArray(e) || r.length !== e.length)
    return !1;
  for (let t = 0; t < r.length; ++t)
    if (r[t] !== e[t])
      return !1;
  return !0;
}
function lh(r, e, t) {
  for (const i in t)
    Array.isArray(e[i]) ? r[i] = e[i].slice() : r[i] = e[i];
}
const hI = {
  texture: !0,
  children: !1,
  baseTexture: !0
}, T0 = class Cc extends st {
  /**
   * @param text - The string that you would like the text to display
   * @param style - The style parameters
   * @param canvas - The canvas element for drawing text
   */
  constructor(e, t, i) {
    let n = !1;
    i || (i = Z.ADAPTER.createCanvas(), n = !0), i.width = 3, i.height = 3;
    const s = J.from(i);
    s.orig = new le(), s.trim = new le(), super(s), this._ownCanvas = n, this.canvas = i, this.context = i.getContext("2d", {
      // required for trimming to work without warnings
      willReadFrequently: !0
    }), this._resolution = Cc.defaultResolution ?? Z.RESOLUTION, this._autoResolution = Cc.defaultAutoResolution, this._text = null, this._style = null, this._styleListener = null, this._font = "", this.text = e, this.style = t, this.localStyleID = -1;
  }
  /**
   * @see PIXI.TextMetrics.experimentalLetterSpacing
   * @deprecated since 7.1.0
   */
  static get experimentalLetterSpacing() {
    return ji.experimentalLetterSpacing;
  }
  static set experimentalLetterSpacing(e) {
    fe(
      "7.1.0",
      "Text.experimentalLetterSpacing is deprecated, use TextMetrics.experimentalLetterSpacing"
    ), ji.experimentalLetterSpacing = e;
  }
  /**
   * Renders text to its canvas, and updates its texture.
   *
   * By default this is used internally to ensure the texture is correct before rendering,
   * but it can be used called externally, for example from this class to 'pre-generate' the texture from a piece of text,
   * and then shared across multiple Sprites.
   * @param respectDirty - Whether to abort updating the text if the Text isn't dirty and the function is called.
   */
  updateText(e) {
    const t = this._style;
    if (this.localStyleID !== t.styleID && (this.dirty = !0, this.localStyleID = t.styleID), !this.dirty && e)
      return;
    this._font = this._style.toFontString();
    const i = this.context, n = ji.measureText(this._text || " ", this._style, this._style.wordWrap, this.canvas), s = n.width, o = n.height, a = n.lines, l = n.lineHeight, h = n.lineWidths, c = n.maxLineWidth, u = n.fontProperties;
    this.canvas.width = Math.ceil(Math.ceil(Math.max(1, s) + t.padding * 2) * this._resolution), this.canvas.height = Math.ceil(Math.ceil(Math.max(1, o) + t.padding * 2) * this._resolution), i.scale(this._resolution, this._resolution), i.clearRect(0, 0, this.canvas.width, this.canvas.height), i.font = this._font, i.lineWidth = t.strokeThickness, i.textBaseline = t.textBaseline, i.lineJoin = t.lineJoin, i.miterLimit = t.miterLimit;
    let d, f;
    const p = t.dropShadow ? 2 : 1;
    for (let _ = 0; _ < p; ++_) {
      const m = t.dropShadow && _ === 0, y = m ? Math.ceil(Math.max(1, o) + t.padding * 2) : 0, v = y * this._resolution;
      if (m) {
        i.fillStyle = "black", i.strokeStyle = "black";
        const b = t.dropShadowColor, w = t.dropShadowBlur * this._resolution, T = t.dropShadowDistance * this._resolution;
        i.shadowColor = be.shared.setValue(b).setAlpha(t.dropShadowAlpha).toRgbaString(), i.shadowBlur = w, i.shadowOffsetX = Math.cos(t.dropShadowAngle) * T, i.shadowOffsetY = Math.sin(t.dropShadowAngle) * T + v;
      } else
        i.fillStyle = this._generateFillStyle(t, a, n), i.strokeStyle = t.stroke, i.shadowColor = "black", i.shadowBlur = 0, i.shadowOffsetX = 0, i.shadowOffsetY = 0;
      let g = (l - u.fontSize) / 2;
      l - u.fontSize < 0 && (g = 0);
      for (let b = 0; b < a.length; b++)
        d = t.strokeThickness / 2, f = t.strokeThickness / 2 + b * l + u.ascent + g, t.align === "right" ? d += c - h[b] : t.align === "center" && (d += (c - h[b]) / 2), t.stroke && t.strokeThickness && this.drawLetterSpacing(
          a[b],
          d + t.padding,
          f + t.padding - y,
          !0
        ), t.fill && this.drawLetterSpacing(
          a[b],
          d + t.padding,
          f + t.padding - y
        );
    }
    this.updateTexture();
  }
  /**
   * Render the text with letter-spacing.
   * @param text - The text to draw
   * @param x - Horizontal position to draw the text
   * @param y - Vertical position to draw the text
   * @param isStroke - Is this drawing for the outside stroke of the
   *  text? If not, it's for the inside fill
   */
  drawLetterSpacing(e, t, i, n = !1) {
    const s = this._style.letterSpacing;
    let o = !1;
    if (ji.experimentalLetterSpacingSupported && (ji.experimentalLetterSpacing ? (this.context.letterSpacing = `${s}px`, this.context.textLetterSpacing = `${s}px`, o = !0) : (this.context.letterSpacing = "0px", this.context.textLetterSpacing = "0px")), s === 0 || o) {
      n ? this.context.strokeText(e, t, i) : this.context.fillText(e, t, i);
      return;
    }
    let a = t;
    const l = ji.graphemeSegmenter(e);
    let h = this.context.measureText(e).width, c = 0;
    for (let u = 0; u < l.length; ++u) {
      const d = l[u];
      n ? this.context.strokeText(d, a, i) : this.context.fillText(d, a, i);
      let f = "";
      for (let p = u + 1; p < l.length; ++p)
        f += l[p];
      c = this.context.measureText(f).width, a += h - c + s, h = c;
    }
  }
  /** Updates texture size based on canvas size. */
  updateTexture() {
    const e = this.canvas;
    if (this._style.trim) {
      const o = RA(e);
      o.data && (e.width = o.width, e.height = o.height, this.context.putImageData(o.data, 0, 0));
    }
    const t = this._texture, i = this._style, n = i.trim ? 0 : i.padding, s = t.baseTexture;
    t.trim.width = t._frame.width = e.width / this._resolution, t.trim.height = t._frame.height = e.height / this._resolution, t.trim.x = -n, t.trim.y = -n, t.orig.width = t._frame.width - n * 2, t.orig.height = t._frame.height - n * 2, this._onTextureUpdate(), s.setRealSize(e.width, e.height, this._resolution), t.updateUvs(), this.dirty = !1;
  }
  /**
   * Renders the object using the WebGL renderer
   * @param renderer - The renderer
   */
  _render(e) {
    this._autoResolution && this._resolution !== e.resolution && (this._resolution = e.resolution, this.dirty = !0), this.updateText(!0), super._render(e);
  }
  /** Updates the transform on all children of this container for rendering. */
  updateTransform() {
    this.updateText(!0), super.updateTransform();
  }
  getBounds(e, t) {
    return this.updateText(!0), this._textureID === -1 && (e = !1), super.getBounds(e, t);
  }
  /**
   * Gets the local bounds of the text object.
   * @param rect - The output rectangle.
   * @returns The bounds.
   */
  getLocalBounds(e) {
    return this.updateText(!0), super.getLocalBounds.call(this, e);
  }
  /** Calculates the bounds of the Text as a rectangle. The bounds calculation takes the worldTransform into account. */
  _calculateBounds() {
    this.calculateVertices(), this._bounds.addQuad(this.vertexData);
  }
  /**
   * Generates the fill style. Can automatically generate a gradient based on the fill style being an array
   * @param style - The style.
   * @param lines - The lines of text.
   * @param metrics
   * @returns The fill style
   */
  _generateFillStyle(e, t, i) {
    const n = e.fill;
    if (Array.isArray(n)) {
      if (n.length === 1)
        return n[0];
    } else
      return n;
    let s;
    const o = e.dropShadow ? e.dropShadowDistance : 0, a = e.padding || 0, l = this.canvas.width / this._resolution - o - a * 2, h = this.canvas.height / this._resolution - o - a * 2, c = n.slice(), u = e.fillGradientStops.slice();
    if (!u.length) {
      const d = c.length + 1;
      for (let f = 1; f < d; ++f)
        u.push(f / d);
    }
    if (c.unshift(n[0]), u.unshift(0), c.push(n[n.length - 1]), u.push(1), e.fillGradientType === Na.LINEAR_VERTICAL) {
      s = this.context.createLinearGradient(l / 2, a, l / 2, h + a);
      const d = i.fontProperties.fontSize + e.strokeThickness;
      for (let f = 0; f < t.length; f++) {
        const p = i.lineHeight * (f - 1) + d, _ = i.lineHeight * f;
        let m = _;
        f > 0 && p > _ && (m = (_ + p) / 2);
        const y = _ + d, v = i.lineHeight * (f + 1);
        let g = y;
        f + 1 < t.length && v < y && (g = (y + v) / 2);
        const b = (g - m) / h;
        for (let w = 0; w < c.length; w++) {
          let T = 0;
          typeof u[w] == "number" ? T = u[w] : T = w / c.length;
          let x = Math.min(1, Math.max(
            0,
            m / h + T * b
          ));
          x = Number(x.toFixed(5)), s.addColorStop(x, c[w]);
        }
      }
    } else {
      s = this.context.createLinearGradient(a, h / 2, l + a, h / 2);
      const d = c.length + 1;
      let f = 1;
      for (let p = 0; p < c.length; p++) {
        let _;
        typeof u[p] == "number" ? _ = u[p] : _ = f / d, s.addColorStop(_, c[p]), f++;
      }
    }
    return s;
  }
  /**
   * Destroys this text object.
   *
   * Note* Unlike a Sprite, a Text object will automatically destroy its baseTexture and texture as
   * the majority of the time the texture will not be shared with any other Sprites.
   * @param options - Options parameter. A boolean will act as if all options
   *  have been set to that value
   * @param {boolean} [options.children=false] - if set to true, all the children will have their
   *  destroy method called as well. 'options' will be passed on to those calls.
   * @param {boolean} [options.texture=true] - Should it destroy the current texture of the sprite as well
   * @param {boolean} [options.baseTexture=true] - Should it destroy the base texture of the sprite as well
   */
  destroy(e) {
    typeof e == "boolean" && (e = { children: e }), e = Object.assign({}, hI, e), super.destroy(e), this._ownCanvas && (this.canvas.height = this.canvas.width = 0), this.context = null, this.canvas = null, this._style = null;
  }
  /** The width of the Text, setting this will actually modify the scale to achieve the value set. */
  get width() {
    return this.updateText(!0), Math.abs(this.scale.x) * this._texture.orig.width;
  }
  set width(e) {
    this.updateText(!0);
    const t = Zi(this.scale.x) || 1;
    this.scale.x = t * e / this._texture.orig.width, this._width = e;
  }
  /** The height of the Text, setting this will actually modify the scale to achieve the value set. */
  get height() {
    return this.updateText(!0), Math.abs(this.scale.y) * this._texture.orig.height;
  }
  set height(e) {
    this.updateText(!0);
    const t = Zi(this.scale.y) || 1;
    this.scale.y = t * e / this._texture.orig.height, this._height = e;
  }
  /**
   * Set the style of the text.
   *
   * Set up an event listener to listen for changes on the style object and mark the text as dirty.
   *
   * If setting the `style` can also be partial {@link PIXI.ITextStyle}.
   */
  get style() {
    return this._style;
  }
  set style(e) {
    e = e || {}, e instanceof rr ? this._style = e : this._style = new rr(e), this.localStyleID = -1, this.dirty = !0;
  }
  /** Set the copy for the text object. To split a line you can use '\n'. */
  get text() {
    return this._text;
  }
  set text(e) {
    e = String(e ?? ""), this._text !== e && (this._text = e, this.dirty = !0);
  }
  /**
   * The resolution / device pixel ratio of the canvas.
   *
   * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
   * @default 1
   */
  get resolution() {
    return this._resolution;
  }
  set resolution(e) {
    this._autoResolution = !1, this._resolution !== e && (this._resolution = e, this.dirty = !0);
  }
};
T0.defaultAutoResolution = !0;
let A0 = T0;
class cI {
  /**
   * @param maxItemsPerFrame - The maximum number of items that can be prepared each frame.
   */
  constructor(e) {
    this.maxItemsPerFrame = e, this.itemsLeft = 0;
  }
  /** Resets any counting properties to start fresh on a new frame. */
  beginFrame() {
    this.itemsLeft = this.maxItemsPerFrame;
  }
  /**
   * Checks to see if another item can be uploaded. This should only be called once per item.
   * @returns If the item is allowed to be uploaded.
   */
  allowedToUpload() {
    return this.itemsLeft-- > 0;
  }
}
function uI(r, e) {
  var i;
  let t = !1;
  if ((i = r == null ? void 0 : r._textures) != null && i.length) {
    for (let n = 0; n < r._textures.length; n++)
      if (r._textures[n] instanceof J) {
        const s = r._textures[n].baseTexture;
        e.includes(s) || (e.push(s), t = !0);
      }
  }
  return t;
}
function dI(r, e) {
  if (r.baseTexture instanceof ae) {
    const t = r.baseTexture;
    return e.includes(t) || e.push(t), !0;
  }
  return !1;
}
function fI(r, e) {
  if (r._texture && r._texture instanceof J) {
    const t = r._texture.baseTexture;
    return e.includes(t) || e.push(t), !0;
  }
  return !1;
}
function pI(r, e) {
  return e instanceof A0 ? (e.updateText(!0), !0) : !1;
}
function _I(r, e) {
  if (e instanceof rr) {
    const t = e.toFontString();
    return ji.measureFont(t), !0;
  }
  return !1;
}
function mI(r, e) {
  if (r instanceof A0) {
    e.includes(r.style) || e.push(r.style), e.includes(r) || e.push(r);
    const t = r._texture.baseTexture;
    return e.includes(t) || e.push(t), !0;
  }
  return !1;
}
function gI(r, e) {
  return r instanceof rr ? (e.includes(r) || e.push(r), !0) : !1;
}
const S0 = class C0 {
  /**
   * @param {PIXI.IRenderer} renderer - A reference to the current renderer
   */
  constructor(e) {
    this.limiter = new cI(C0.uploadsPerFrame), this.renderer = e, this.uploadHookHelper = null, this.queue = [], this.addHooks = [], this.uploadHooks = [], this.completes = [], this.ticking = !1, this.delayedTick = () => {
      this.queue && this.prepareItems();
    }, this.registerFindHook(mI), this.registerFindHook(gI), this.registerFindHook(uI), this.registerFindHook(dI), this.registerFindHook(fI), this.registerUploadHook(pI), this.registerUploadHook(_I);
  }
  /**
   * Upload all the textures and graphics to the GPU.
   * @method PIXI.BasePrepare#upload
   * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text} [item] -
   *        Container or display object to search for items to upload or the items to upload themselves,
   *        or optionally ommitted, if items have been added using {@link PIXI.BasePrepare#add `prepare.add`}.
   */
  upload(e) {
    return new Promise((t) => {
      e && this.add(e), this.queue.length ? (this.completes.push(t), this.ticking || (this.ticking = !0, bt.system.addOnce(this.tick, this, zr.UTILITY))) : t();
    });
  }
  /**
   * Handle tick update
   * @private
   */
  tick() {
    setTimeout(this.delayedTick, 0);
  }
  /**
   * Actually prepare items. This is handled outside of the tick because it will take a while
   * and we do NOT want to block the current animation frame from rendering.
   * @private
   */
  prepareItems() {
    for (this.limiter.beginFrame(); this.queue.length && this.limiter.allowedToUpload(); ) {
      const e = this.queue[0];
      let t = !1;
      if (e && !e._destroyed) {
        for (let i = 0, n = this.uploadHooks.length; i < n; i++)
          if (this.uploadHooks[i](this.uploadHookHelper, e)) {
            this.queue.shift(), t = !0;
            break;
          }
      }
      t || this.queue.shift();
    }
    if (this.queue.length)
      bt.system.addOnce(this.tick, this, zr.UTILITY);
    else {
      this.ticking = !1;
      const e = this.completes.slice(0);
      this.completes.length = 0;
      for (let t = 0, i = e.length; t < i; t++)
        e[t]();
    }
  }
  /**
   * Adds hooks for finding items.
   * @param {Function} addHook - Function call that takes two parameters: `item:*, queue:Array`
   *          function must return `true` if it was able to add item to the queue.
   * @returns Instance of plugin for chaining.
   */
  registerFindHook(e) {
    return e && this.addHooks.push(e), this;
  }
  /**
   * Adds hooks for uploading items.
   * @param {Function} uploadHook - Function call that takes two parameters: `prepare:CanvasPrepare, item:*` and
   *          function must return `true` if it was able to handle upload of item.
   * @returns Instance of plugin for chaining.
   */
  registerUploadHook(e) {
    return e && this.uploadHooks.push(e), this;
  }
  /**
   * Manually add an item to the uploading queue.
   * @param {PIXI.DisplayObject|PIXI.Container|PIXI.BaseTexture|PIXI.Texture|PIXI.Graphics|PIXI.Text|*} item - Object to
   *        add to the queue
   * @returns Instance of plugin for chaining.
   */
  add(e) {
    for (let t = 0, i = this.addHooks.length; t < i && !this.addHooks[t](e, this.queue); t++)
      ;
    if (e instanceof Qe)
      for (let t = e.children.length - 1; t >= 0; t--)
        this.add(e.children[t]);
    return this;
  }
  /** Destroys the plugin, don't use after this. */
  destroy() {
    this.ticking && bt.system.remove(this.tick, this), this.ticking = !1, this.addHooks = null, this.uploadHooks = null, this.renderer = null, this.completes = null, this.queue = null, this.limiter = null, this.uploadHookHelper = null;
  }
};
S0.uploadsPerFrame = 4;
let Ic = S0;
Object.defineProperties(Z, {
  /**
   * Default number of uploads per frame using prepare plugin.
   * @static
   * @memberof PIXI.settings
   * @name UPLOADS_PER_FRAME
   * @deprecated since 7.1.0
   * @see PIXI.BasePrepare.uploadsPerFrame
   * @type {number}
   */
  UPLOADS_PER_FRAME: {
    get() {
      return Ic.uploadsPerFrame;
    },
    set(r) {
      fe("7.1.0", "settings.UPLOADS_PER_FRAME is deprecated, use prepare.BasePrepare.uploadsPerFrame"), Ic.uploadsPerFrame = r;
    }
  }
});
function I0(r, e) {
  return e instanceof ae ? (e._glTextures[r.CONTEXT_UID] || r.texture.bind(e), !0) : !1;
}
function yI(r, e) {
  if (!(e instanceof Xr))
    return !1;
  const { geometry: t } = e;
  e.finishPoly(), t.updateBatches();
  const { batches: i } = t;
  for (let n = 0; n < i.length; n++) {
    const { texture: s } = i[n].style;
    s && I0(r, s.baseTexture);
  }
  return t.batchable || r.geometry.bind(t, e._resolveDirectShader(r)), !0;
}
function vI(r, e) {
  return r instanceof Xr ? (e.push(r), !0) : !1;
}
class R0 extends Ic {
  /**
   * @param {PIXI.Renderer} renderer - A reference to the current renderer
   */
  constructor(e) {
    super(e), this.uploadHookHelper = this.renderer, this.registerFindHook(vI), this.registerUploadHook(I0), this.registerUploadHook(yI);
  }
}
R0.extension = {
  name: "prepare",
  type: q.RendererSystem
};
Q.add(R0);
var bI = `#version 300 es
#define SHADER_NAME Tiling-Sprite-100

precision lowp float;

in vec2 vTextureCoord;

out vec4 fragmentColor;

uniform sampler2D uSampler;
uniform vec4 uColor;
uniform mat3 uMapCoord;
uniform vec4 uClampFrame;
uniform vec2 uClampOffset;

void main(void)
{
    vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
    coord = (uMapCoord * vec3(coord, 1.0)).xy;
    vec2 unclamped = coord;
    coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);

    vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0

    fragmentColor = texSample * uColor;
}
`, wI = `#version 300 es
#define SHADER_NAME Tiling-Sprite-300

precision lowp float;

in vec2 aVertexPosition;
in vec2 aTextureCoord;

uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform mat3 uTransform;

out vec2 vTextureCoord;

void main(void)
{
    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
}
`, xI = `#version 100
#ifdef GL_EXT_shader_texture_lod
    #extension GL_EXT_shader_texture_lod : enable
#endif
#define SHADER_NAME Tiling-Sprite-100

precision lowp float;

varying vec2 vTextureCoord;

uniform sampler2D uSampler;
uniform vec4 uColor;
uniform mat3 uMapCoord;
uniform vec4 uClampFrame;
uniform vec2 uClampOffset;

void main(void)
{
    vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
    coord = (uMapCoord * vec3(coord, 1.0)).xy;
    vec2 unclamped = coord;
    coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);

    #ifdef GL_EXT_shader_texture_lod
        vec4 texSample = unclamped == coord
            ? texture2D(uSampler, coord) 
            : texture2DLodEXT(uSampler, coord, 0);
    #else
        vec4 texSample = texture2D(uSampler, coord);
    #endif

    gl_FragColor = texSample * uColor;
}
`, rp = `#version 100
#define SHADER_NAME Tiling-Sprite-100

precision lowp float;

attribute vec2 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform mat3 uTransform;

varying vec2 vTextureCoord;

void main(void)
{
    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);

    vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
}
`, EI = `#version 100
#define SHADER_NAME Tiling-Sprite-Simple-100

precision lowp float;

varying vec2 vTextureCoord;

uniform sampler2D uSampler;
uniform vec4 uColor;

void main(void)
{
    vec4 texSample = texture2D(uSampler, vTextureCoord);
    gl_FragColor = texSample * uColor;
}
`;
const vo = new Te();
class P0 extends Fa {
  /**
   * constructor for renderer
   * @param {PIXI.Renderer} renderer - The renderer this tiling awesomeness works for.
   */
  constructor(e) {
    super(e), e.runners.contextChange.add(this), this.quad = new Dm(), this.state = yi.for2d();
  }
  /** Creates shaders when context is initialized. */
  contextChange() {
    const e = this.renderer, t = { globals: e.globalUniforms };
    this.simpleShader = mi.from(rp, EI, t), this.shader = e.context.webGLVersion > 1 ? mi.from(wI, bI, t) : mi.from(rp, xI, t);
  }
  /**
   * @param {PIXI.TilingSprite} ts - tilingSprite to be rendered
   */
  render(e) {
    const t = this.renderer, i = this.quad;
    let n = i.vertices;
    n[0] = n[6] = e._width * -e.anchor.x, n[1] = n[3] = e._height * -e.anchor.y, n[2] = n[4] = e._width * (1 - e.anchor.x), n[5] = n[7] = e._height * (1 - e.anchor.y);
    const s = e.uvRespectAnchor ? e.anchor.x : 0, o = e.uvRespectAnchor ? e.anchor.y : 0;
    n = i.uvs, n[0] = n[6] = -s, n[1] = n[3] = -o, n[2] = n[4] = 1 - s, n[5] = n[7] = 1 - o, i.invalidate();
    const a = e._texture, l = a.baseTexture, h = l.alphaMode > 0, c = e.tileTransform.localTransform, u = e.uvMatrix;
    let d = l.isPowerOfTwo && a.frame.width === l.width && a.frame.height === l.height;
    d && (l._glTextures[t.CONTEXT_UID] ? d = l.wrapMode !== tr.CLAMP : l.wrapMode === tr.CLAMP && (l.wrapMode = tr.REPEAT));
    const f = d ? this.simpleShader : this.shader, p = a.width, _ = a.height, m = e._width, y = e._height;
    vo.set(
      c.a * p / m,
      c.b * p / y,
      c.c * _ / m,
      c.d * _ / y,
      c.tx / m,
      c.ty / y
    ), vo.invert(), d ? vo.prepend(u.mapCoord) : (f.uniforms.uMapCoord = u.mapCoord.toArray(!0), f.uniforms.uClampFrame = u.uClampFrame, f.uniforms.uClampOffset = u.uClampOffset), f.uniforms.uTransform = vo.toArray(!0), f.uniforms.uColor = be.shared.setValue(e.tint).premultiply(e.worldAlpha, h).toArray(f.uniforms.uColor), f.uniforms.translationMatrix = e.transform.worldTransform.toArray(!0), f.uniforms.uSampler = a, t.shader.bind(f), t.geometry.bind(i), this.state.blendMode = bm(e.blendMode, h), t.state.set(this.state), t.geometry.draw(this.renderer.gl.TRIANGLES, 6, 0);
  }
}
P0.extension = {
  name: "tilingSprite",
  type: q.RendererPlugin
};
Q.add(P0);
const M0 = class ps {
  /** @ignore */
  constructor(e, t, i) {
    this.linkedSheets = [], (e instanceof ae || e instanceof J) && (e = { texture: e, data: t, resolutionFilename: i });
    const { texture: n, data: s, resolutionFilename: o = null, cachePrefix: a = "" } = e;
    this.cachePrefix = a, this._texture = n instanceof J ? n : null, this.baseTexture = n instanceof ae ? n : this._texture.baseTexture, this.textures = {}, this.animations = {}, this.data = s;
    const l = this.baseTexture.resource;
    this.resolution = this._updateResolution(o || (l ? l.url : null)), this._frames = this.data.frames, this._frameKeys = Object.keys(this._frames), this._batchIndex = 0, this._callback = null;
  }
  /**
   * Generate the resolution from the filename or fallback
   * to the meta.scale field of the JSON data.
   * @param resolutionFilename - The filename to use for resolving
   *        the default resolution.
   * @returns Resolution to use for spritesheet.
   */
  _updateResolution(e = null) {
    const { scale: t } = this.data.meta;
    let i = Di(e, null);
    return i === null && (i = typeof t == "number" ? t : parseFloat(t ?? "1")), i !== 1 && this.baseTexture.setResolution(i), i;
  }
  /**
   * Parser spritesheet from loaded data. This is done asynchronously
   * to prevent creating too many Texture within a single process.
   * @method PIXI.Spritesheet#parse
   */
  parse() {
    return new Promise((e) => {
      this._callback = e, this._batchIndex = 0, this._frameKeys.length <= ps.BATCH_SIZE ? (this._processFrames(0), this._processAnimations(), this._parseComplete()) : this._nextBatch();
    });
  }
  /**
   * Process a batch of frames
   * @param initialFrameIndex - The index of frame to start.
   */
  _processFrames(e) {
    let t = e;
    const i = ps.BATCH_SIZE;
    for (; t - e < i && t < this._frameKeys.length; ) {
      const n = this._frameKeys[t], s = this._frames[n], o = s.frame;
      if (o) {
        let a = null, l = null;
        const h = s.trimmed !== !1 && s.sourceSize ? s.sourceSize : s.frame, c = new le(
          0,
          0,
          Math.floor(h.w) / this.resolution,
          Math.floor(h.h) / this.resolution
        );
        s.rotated ? a = new le(
          Math.floor(o.x) / this.resolution,
          Math.floor(o.y) / this.resolution,
          Math.floor(o.h) / this.resolution,
          Math.floor(o.w) / this.resolution
        ) : a = new le(
          Math.floor(o.x) / this.resolution,
          Math.floor(o.y) / this.resolution,
          Math.floor(o.w) / this.resolution,
          Math.floor(o.h) / this.resolution
        ), s.trimmed !== !1 && s.spriteSourceSize && (l = new le(
          Math.floor(s.spriteSourceSize.x) / this.resolution,
          Math.floor(s.spriteSourceSize.y) / this.resolution,
          Math.floor(o.w) / this.resolution,
          Math.floor(o.h) / this.resolution
        )), this.textures[n] = new J(
          this.baseTexture,
          a,
          c,
          l,
          s.rotated ? 2 : 0,
          s.anchor,
          s.borders
        ), J.addToCache(this.textures[n], this.cachePrefix + n.toString());
      }
      t++;
    }
  }
  /** Parse animations config. */
  _processAnimations() {
    const e = this.data.animations || {};
    for (const t in e) {
      this.animations[t] = [];
      for (let i = 0; i < e[t].length; i++) {
        const n = e[t][i];
        this.animations[t].push(this.textures[n]);
      }
    }
  }
  /** The parse has completed. */
  _parseComplete() {
    const e = this._callback;
    this._callback = null, this._batchIndex = 0, e.call(this, this.textures);
  }
  /** Begin the next batch of textures. */
  _nextBatch() {
    this._processFrames(this._batchIndex * ps.BATCH_SIZE), this._batchIndex++, setTimeout(() => {
      this._batchIndex * ps.BATCH_SIZE < this._frameKeys.length ? this._nextBatch() : (this._processAnimations(), this._parseComplete());
    }, 0);
  }
  /**
   * Destroy Spritesheet and don't use after this.
   * @param {boolean} [destroyBase=false] - Whether to destroy the base texture as well
   */
  destroy(e = !1) {
    var t;
    for (const i in this.textures)
      this.textures[i].destroy();
    this._frames = null, this._frameKeys = null, this.data = null, this.textures = null, e && ((t = this._texture) == null || t.destroy(), this.baseTexture.destroy()), this._texture = null, this.baseTexture = null, this.linkedSheets = [];
  }
};
M0.BATCH_SIZE = 1e3;
let np = M0;
const TI = [
  "jpg",
  "png",
  "jpeg",
  "avif",
  "webp",
  "s3tc",
  "s3tc_sRGB",
  "etc",
  "etc1",
  "pvrtc",
  "atc",
  "astc",
  "bptc"
];
function k0(r, e, t) {
  const i = {};
  if (r.forEach((n) => {
    i[n] = e;
  }), Object.keys(e.textures).forEach((n) => {
    i[`${e.cachePrefix}${n}`] = e.textures[n];
  }), !t) {
    const n = We.dirname(r[0]);
    e.linkedSheets.forEach((s, o) => {
      Object.assign(i, k0(
        [`${n}/${e.data.meta.related_multi_packs[o]}`],
        s,
        !0
      ));
    });
  }
  return i;
}
const AI = {
  extension: q.Asset,
  /** Handle the caching of the related Spritesheet Textures */
  cache: {
    test: (r) => r instanceof np,
    getCacheableAssets: (r, e) => k0(r, e, !1)
  },
  /** Resolve the the resolution of the asset. */
  resolver: {
    test: (r) => {
      const e = r.split("?")[0].split("."), t = e.pop(), i = e.pop();
      return t === "json" && TI.includes(i);
    },
    parse: (r) => {
      var t;
      const e = r.split(".");
      return {
        resolution: parseFloat(((t = Z.RETINA_PREFIX.exec(r)) == null ? void 0 : t[1]) ?? "1"),
        format: e[e.length - 2],
        src: r
      };
    }
  },
  /**
   * Loader plugin that parses sprite sheets!
   * once the JSON has been loaded this checks to see if the JSON is spritesheet data.
   * If it is, we load the spritesheets image and parse the data into PIXI.Spritesheet
   * All textures in the sprite sheet are then added to the cache
   * @ignore
   */
  loader: {
    name: "spritesheetLoader",
    extension: {
      type: q.LoadParser,
      priority: Qt.Normal
    },
    async testParse(r, e) {
      return We.extname(e.src).toLowerCase() === ".json" && !!r.frames;
    },
    async parse(r, e, t) {
      var c, u;
      const {
        texture: i,
        // if user need to use preloaded texture
        imageFilename: n,
        // if user need to use custom filename (not from jsonFile.meta.image)
        cachePrefix: s
        // if user need to use custom cache prefix
      } = (e == null ? void 0 : e.data) ?? {};
      let o = We.dirname(e.src);
      o && o.lastIndexOf("/") !== o.length - 1 && (o += "/");
      let a;
      if (i && i.baseTexture)
        a = i;
      else {
        const d = Ec(o + (n ?? r.meta.image), e.src);
        a = (await t.load([d]))[d];
      }
      const l = new np({
        texture: a.baseTexture,
        data: r,
        resolutionFilename: e.src,
        cachePrefix: s
      });
      await l.parse();
      const h = (c = r == null ? void 0 : r.meta) == null ? void 0 : c.related_multi_packs;
      if (Array.isArray(h)) {
        const d = [];
        for (const p of h) {
          if (typeof p != "string")
            continue;
          let _ = o + p;
          (u = e.data) != null && u.ignoreMultiPack || (_ = Ec(_, e.src), d.push(t.load({
            src: _,
            data: {
              ignoreMultiPack: !0
            }
          })));
        }
        const f = await Promise.all(d);
        l.linkedSheets = f, f.forEach((p) => {
          p.linkedSheets = [l].concat(l.linkedSheets.filter((_) => _ !== p));
        });
      }
      return l;
    },
    unload(r) {
      r.destroy(!0);
    }
  }
};
Q.add(AI);
class ga {
  constructor() {
    this.info = [], this.common = [], this.page = [], this.char = [], this.kerning = [], this.distanceField = [];
  }
}
class Oo {
  /**
   * Check if resource refers to txt font data.
   * @param data
   * @returns - True if resource could be treated as font data, false otherwise.
   */
  static test(e) {
    return typeof e == "string" && e.startsWith("info face=");
  }
  /**
   * Convert text font data to a javascript object.
   * @param txt - Raw string data to be converted
   * @returns - Parsed font data
   */
  static parse(e) {
    const t = e.match(/^[a-z]+\s+.+$/gm), i = {
      info: [],
      common: [],
      page: [],
      char: [],
      chars: [],
      kerning: [],
      kernings: [],
      distanceField: []
    };
    for (const s in t) {
      const o = t[s].match(/^[a-z]+/gm)[0], a = t[s].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm), l = {};
      for (const h in a) {
        const c = a[h].split("="), u = c[0], d = c[1].replace(/"/gm, ""), f = parseFloat(d), p = isNaN(f) ? d : f;
        l[u] = p;
      }
      i[o].push(l);
    }
    const n = new ga();
    return i.info.forEach((s) => n.info.push({
      face: s.face,
      size: parseInt(s.size, 10)
    })), i.common.forEach((s) => n.common.push({
      lineHeight: parseInt(s.lineHeight, 10)
    })), i.page.forEach((s) => n.page.push({
      id: parseInt(s.id, 10),
      file: s.file
    })), i.char.forEach((s) => n.char.push({
      id: parseInt(s.id, 10),
      page: parseInt(s.page, 10),
      x: parseInt(s.x, 10),
      y: parseInt(s.y, 10),
      width: parseInt(s.width, 10),
      height: parseInt(s.height, 10),
      xoffset: parseInt(s.xoffset, 10),
      yoffset: parseInt(s.yoffset, 10),
      xadvance: parseInt(s.xadvance, 10)
    })), i.kerning.forEach((s) => n.kerning.push({
      first: parseInt(s.first, 10),
      second: parseInt(s.second, 10),
      amount: parseInt(s.amount, 10)
    })), i.distanceField.forEach((s) => n.distanceField.push({
      distanceRange: parseInt(s.distanceRange, 10),
      fieldType: s.fieldType
    })), n;
  }
}
class Rc {
  /**
   * Check if resource refers to xml font data.
   * @param data
   * @returns - True if resource could be treated as font data, false otherwise.
   */
  static test(e) {
    const t = e;
    return typeof e != "string" && "getElementsByTagName" in e && t.getElementsByTagName("page").length && t.getElementsByTagName("info")[0].getAttribute("face") !== null;
  }
  /**
   * Convert the XML into BitmapFontData that we can use.
   * @param xml
   * @returns - Data to use for BitmapFont
   */
  static parse(e) {
    const t = new ga(), i = e.getElementsByTagName("info"), n = e.getElementsByTagName("common"), s = e.getElementsByTagName("page"), o = e.getElementsByTagName("char"), a = e.getElementsByTagName("kerning"), l = e.getElementsByTagName("distanceField");
    for (let h = 0; h < i.length; h++)
      t.info.push({
        face: i[h].getAttribute("face"),
        size: parseInt(i[h].getAttribute("size"), 10)
      });
    for (let h = 0; h < n.length; h++)
      t.common.push({
        lineHeight: parseInt(n[h].getAttribute("lineHeight"), 10)
      });
    for (let h = 0; h < s.length; h++)
      t.page.push({
        id: parseInt(s[h].getAttribute("id"), 10) || 0,
        file: s[h].getAttribute("file")
      });
    for (let h = 0; h < o.length; h++) {
      const c = o[h];
      t.char.push({
        id: parseInt(c.getAttribute("id"), 10),
        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)
      });
    }
    for (let h = 0; h < a.length; h++)
      t.kerning.push({
        first: parseInt(a[h].getAttribute("first"), 10),
        second: parseInt(a[h].getAttribute("second"), 10),
        amount: parseInt(a[h].getAttribute("amount"), 10)
      });
    for (let h = 0; h < l.length; h++)
      t.distanceField.push({
        fieldType: l[h].getAttribute("fieldType"),
        distanceRange: parseInt(l[h].getAttribute("distanceRange"), 10)
      });
    return t;
  }
}
class Pc {
  /**
   * Check if resource refers to text xml font data.
   * @param data
   * @returns - True if resource could be treated as font data, false otherwise.
   */
  static test(e) {
    return typeof e == "string" && e.includes("<font>") ? Rc.test(Z.ADAPTER.parseXML(e)) : !1;
  }
  /**
   * Convert the text XML into BitmapFontData that we can use.
   * @param xmlTxt
   * @returns - Data to use for BitmapFont
   */
  static parse(e) {
    return Rc.parse(Z.ADAPTER.parseXML(e));
  }
}
const hh = [
  Oo,
  Rc,
  Pc
];
function SI(r) {
  for (let e = 0; e < hh.length; e++)
    if (hh[e].test(r))
      return hh[e];
  return null;
}
function CI(r, e, t, i, n, s) {
  const o = t.fill;
  if (Array.isArray(o)) {
    if (o.length === 1)
      return o[0];
  } else
    return o;
  let a;
  const l = t.dropShadow ? t.dropShadowDistance : 0, h = t.padding || 0, c = r.width / i - l - h * 2, u = r.height / i - l - h * 2, d = o.slice(), f = t.fillGradientStops.slice();
  if (!f.length) {
    const p = d.length + 1;
    for (let _ = 1; _ < p; ++_)
      f.push(_ / p);
  }
  if (d.unshift(o[0]), f.unshift(0), d.push(o[o.length - 1]), f.push(1), t.fillGradientType === Na.LINEAR_VERTICAL) {
    a = e.createLinearGradient(c / 2, h, c / 2, u + h);
    let p = 0;
    const _ = (s.fontProperties.fontSize + t.strokeThickness) / u;
    for (let m = 0; m < n.length; m++) {
      const y = s.lineHeight * m;
      for (let v = 0; v < d.length; v++) {
        let g = 0;
        typeof f[v] == "number" ? g = f[v] : g = v / d.length;
        const b = y / u + g * _;
        let w = Math.max(p, b);
        w = Math.min(w, 1), a.addColorStop(w, d[v]), p = w;
      }
    }
  } else {
    a = e.createLinearGradient(h, u / 2, c + h, u / 2);
    const p = d.length + 1;
    let _ = 1;
    for (let m = 0; m < d.length; m++) {
      let y;
      typeof f[m] == "number" ? y = f[m] : y = _ / p, a.addColorStop(y, d[m]), _++;
    }
  }
  return a;
}
function II(r, e, t, i, n, s, o) {
  const a = t.text, l = t.fontProperties;
  e.translate(i, n), e.scale(s, s);
  const h = o.strokeThickness / 2, c = -(o.strokeThickness / 2);
  if (e.font = o.toFontString(), e.lineWidth = o.strokeThickness, e.textBaseline = o.textBaseline, e.lineJoin = o.lineJoin, e.miterLimit = o.miterLimit, e.fillStyle = CI(r, e, o, s, [a], t), e.strokeStyle = o.stroke, o.dropShadow) {
    const u = o.dropShadowColor, d = o.dropShadowBlur * s, f = o.dropShadowDistance * s;
    e.shadowColor = be.shared.setValue(u).setAlpha(o.dropShadowAlpha).toRgbaString(), e.shadowBlur = d, e.shadowOffsetX = Math.cos(o.dropShadowAngle) * f, e.shadowOffsetY = Math.sin(o.dropShadowAngle) * f;
  } else
    e.shadowColor = "black", e.shadowBlur = 0, e.shadowOffsetX = 0, e.shadowOffsetY = 0;
  o.stroke && o.strokeThickness && e.strokeText(a, h, c + t.lineHeight - l.descent), o.fill && e.fillText(a, h, c + t.lineHeight - l.descent), e.setTransform(1, 0, 0, 1, 0, 0), e.fillStyle = "rgba(0, 0, 0, 0)";
}
function Lo(r) {
  return r.codePointAt ? r.codePointAt(0) : r.charCodeAt(0);
}
function D0(r) {
  return Array.from ? Array.from(r) : r.split("");
}
function RI(r) {
  typeof r == "string" && (r = [r]);
  const e = [];
  for (let t = 0, i = r.length; t < i; t++) {
    const n = r[t];
    if (Array.isArray(n)) {
      if (n.length !== 2)
        throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);
      const s = n[0].charCodeAt(0), o = n[1].charCodeAt(0);
      if (o < s)
        throw new Error("[BitmapFont]: Invalid character range.");
      for (let a = s, l = o; a <= l; a++)
        e.push(String.fromCharCode(a));
    } else
      e.push(...D0(n));
  }
  if (e.length === 0)
    throw new Error("[BitmapFont]: Empty set when resolving characters.");
  return e;
}
const Xi = class li {
  /**
   * @param data
   * @param textures
   * @param ownsTextures - Setting to `true` will destroy page textures
   *        when the font is uninstalled.
   */
  constructor(e, t, i) {
    var c;
    const [n] = e.info, [s] = e.common, [o] = e.page, [a] = e.distanceField, l = Di(o.file), h = {};
    this._ownsTextures = i, this.font = n.face, this.size = n.size, this.lineHeight = s.lineHeight / l, this.chars = {}, this.pageTextures = h;
    for (let u = 0; u < e.page.length; u++) {
      const { id: d, file: f } = e.page[u];
      h[d] = t instanceof Array ? t[u] : t[f], a != null && a.fieldType && a.fieldType !== "none" && (h[d].baseTexture.alphaMode = ut.NO_PREMULTIPLIED_ALPHA, h[d].baseTexture.mipmap = gi.OFF);
    }
    for (let u = 0; u < e.char.length; u++) {
      const { id: d, page: f } = e.char[u];
      let { x: p, y: _, width: m, height: y, xoffset: v, yoffset: g, xadvance: b } = e.char[u];
      p /= l, _ /= l, m /= l, y /= l, v /= l, g /= l, b /= l;
      const w = new le(
        p + h[f].frame.x / l,
        _ + h[f].frame.y / l,
        m,
        y
      );
      this.chars[d] = {
        xOffset: v,
        yOffset: g,
        xAdvance: b,
        kerning: {},
        texture: new J(
          h[f].baseTexture,
          w
        ),
        page: f
      };
    }
    for (let u = 0; u < e.kerning.length; u++) {
      let { first: d, second: f, amount: p } = e.kerning[u];
      d /= l, f /= l, p /= l, this.chars[f] && (this.chars[f].kerning[d] = p);
    }
    this.distanceFieldRange = a == null ? void 0 : a.distanceRange, this.distanceFieldType = ((c = a == null ? void 0 : a.fieldType) == null ? void 0 : c.toLowerCase()) ?? "none";
  }
  /** Remove references to created glyph textures. */
  destroy() {
    for (const e in this.chars)
      this.chars[e].texture.destroy(), this.chars[e].texture = null;
    for (const e in this.pageTextures)
      this._ownsTextures && this.pageTextures[e].destroy(!0), this.pageTextures[e] = null;
    this.chars = null, this.pageTextures = null;
  }
  /**
   * Register a new bitmap font.
   * @param data - The
   *        characters map that could be provided as xml or raw string.
   * @param textures - List of textures for each page.
   * @param ownsTextures - Set to `true` to destroy page textures
   *        when the font is uninstalled. By default fonts created with
   *        `BitmapFont.from` or from the `BitmapFontLoader` are `true`.
   * @returns {PIXI.BitmapFont} Result font object with font, size, lineHeight
   *         and char fields.
   */
  static install(e, t, i) {
    let n;
    if (e instanceof ga)
      n = e;
    else {
      const o = SI(e);
      if (!o)
        throw new Error("Unrecognized data format for font.");
      n = o.parse(e);
    }
    t instanceof J && (t = [t]);
    const s = new li(n, t, i);
    return li.available[s.font] = s, s;
  }
  /**
   * Remove bitmap font by name.
   * @param name - Name of the font to uninstall.
   */
  static uninstall(e) {
    const t = li.available[e];
    if (!t)
      throw new Error(`No font found named '${e}'`);
    t.destroy(), delete li.available[e];
  }
  /**
   * Generates a bitmap-font for the given style and character set. This does not support
   * kernings yet. With `style` properties, only the following non-layout properties are used:
   *
   * - {@link PIXI.TextStyle#dropShadow|dropShadow}
   * - {@link PIXI.TextStyle#dropShadowDistance|dropShadowDistance}
   * - {@link PIXI.TextStyle#dropShadowColor|dropShadowColor}
   * - {@link PIXI.TextStyle#dropShadowBlur|dropShadowBlur}
   * - {@link PIXI.TextStyle#dropShadowAngle|dropShadowAngle}
   * - {@link PIXI.TextStyle#fill|fill}
   * - {@link PIXI.TextStyle#fillGradientStops|fillGradientStops}
   * - {@link PIXI.TextStyle#fillGradientType|fillGradientType}
   * - {@link PIXI.TextStyle#fontFamily|fontFamily}
   * - {@link PIXI.TextStyle#fontSize|fontSize}
   * - {@link PIXI.TextStyle#fontVariant|fontVariant}
   * - {@link PIXI.TextStyle#fontWeight|fontWeight}
   * - {@link PIXI.TextStyle#lineJoin|lineJoin}
   * - {@link PIXI.TextStyle#miterLimit|miterLimit}
   * - {@link PIXI.TextStyle#stroke|stroke}
   * - {@link PIXI.TextStyle#strokeThickness|strokeThickness}
   * - {@link PIXI.TextStyle#textBaseline|textBaseline}
   * @param name - The name of the custom font to use with BitmapText.
   * @param textStyle - Style options to render with BitmapFont.
   * @param options - Setup options for font or name of the font.
   * @returns Font generated by style options.
   * @example
   * import { BitmapFont, BitmapText } from 'pixi.js';
   *
   * BitmapFont.from('TitleFont', {
   *     fontFamily: 'Arial',
   *     fontSize: 12,
   *     strokeThickness: 2,
   *     fill: 'purple',
   * });
   *
   * const title = new BitmapText('This is the title', { fontName: 'TitleFont' });
   */
  static from(e, t, i) {
    if (!e)
      throw new Error("[BitmapFont] Property `name` is required.");
    const {
      chars: n,
      padding: s,
      resolution: o,
      textureWidth: a,
      textureHeight: l,
      ...h
    } = Object.assign({}, li.defaultOptions, i), c = RI(n), u = t instanceof rr ? t : new rr(t), d = a, f = new ga();
    f.info[0] = {
      face: u.fontFamily,
      size: u.fontSize
    }, f.common[0] = {
      lineHeight: u.fontSize
    };
    let p = 0, _ = 0, m, y, v, g = 0;
    const b = [];
    for (let T = 0; T < c.length; T++) {
      m || (m = Z.ADAPTER.createCanvas(), m.width = a, m.height = l, y = m.getContext("2d"), v = new ae(m, { resolution: o, ...h }), b.push(new J(v)), f.page.push({
        id: b.length - 1,
        file: ""
      }));
      const x = c[T], E = ji.measureText(x, u, !1, m), R = E.width, k = Math.ceil(E.height), O = Math.ceil((u.fontStyle === "italic" ? 2 : 1) * R);
      if (_ >= l - k * o) {
        if (_ === 0)
          throw new Error(`[BitmapFont] textureHeight ${l}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);
        --T, m = null, y = null, v = null, _ = 0, p = 0, g = 0;
        continue;
      }
      if (g = Math.max(k + E.fontProperties.descent, g), O * o + p >= d) {
        if (p === 0)
          throw new Error(`[BitmapFont] textureWidth ${a}px is too small (fontFamily: '${u.fontFamily}', fontSize: ${u.fontSize}px, char: '${x}')`);
        --T, _ += g * o, _ = Math.ceil(_), p = 0, g = 0;
        continue;
      }
      II(m, y, E, p, _, o, u);
      const B = Lo(E.text);
      f.char.push({
        id: B,
        page: b.length - 1,
        x: p / o,
        y: _ / o,
        width: O,
        height: k,
        xoffset: 0,
        yoffset: 0,
        xadvance: R - (u.dropShadow ? u.dropShadowDistance : 0) - (u.stroke ? u.strokeThickness : 0)
      }), p += (O + 2 * s) * o, p = Math.ceil(p);
    }
    if (!(i != null && i.skipKerning))
      for (let T = 0, x = c.length; T < x; T++) {
        const E = c[T];
        for (let R = 0; R < x; R++) {
          const k = c[R], O = y.measureText(E).width, B = y.measureText(k).width, C = y.measureText(E + k).width - (O + B);
          C && f.kerning.push({
            first: Lo(E),
            second: Lo(k),
            amount: C
          });
        }
      }
    const w = new li(f, b, !0);
    return li.available[e] !== void 0 && li.uninstall(e), li.available[e] = w, w;
  }
};
Xi.ALPHA = [["a", "z"], ["A", "Z"], " "], /**
* This character set includes all decimal digits (from 0 to 9).
* @type {string[][]}
* @example
* BitmapFont.from('ExampleFont', style, { chars: BitmapFont.NUMERIC })
*/
Xi.NUMERIC = [["0", "9"]], /**
* This character set is the union of `BitmapFont.ALPHA` and `BitmapFont.NUMERIC`.
* @type {string[][]}
*/
Xi.ALPHANUMERIC = [["a", "z"], ["A", "Z"], ["0", "9"], " "], /**
* This character set consists of all the ASCII table.
* @member {string[][]}
* @see http://www.asciitable.com/
*/
Xi.ASCII = [[" ", "~"]], /**
* Collection of default options when using `BitmapFont.from`.
* @property {number} [resolution=1] -
* @property {number} [textureWidth=512] -
* @property {number} [textureHeight=512] -
* @property {number} [padding=4] -
* @property {string|string[]|string[][]} chars = PIXI.BitmapFont.ALPHANUMERIC
*/
Xi.defaultOptions = {
  resolution: 1,
  textureWidth: 512,
  textureHeight: 512,
  padding: 4,
  chars: Xi.ALPHANUMERIC
}, /** Collection of available/installed fonts. */
Xi.available = {};
let Vi = Xi;
var PI = `// Pixi texture info\r
varying vec2 vTextureCoord;\r
uniform sampler2D uSampler;\r
\r
// Tint\r
uniform vec4 uColor;\r
\r
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
uniform float uFWidth;\r
\r
void main(void) {\r
\r
  // To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
  vec4 texColor = texture2D(uSampler, vTextureCoord);\r
\r
  // MSDF\r
  float median = texColor.r + texColor.g + texColor.b -\r
                  min(texColor.r, min(texColor.g, texColor.b)) -\r
                  max(texColor.r, max(texColor.g, texColor.b));\r
  // SDF\r
  median = min(median, texColor.a);\r
\r
  float screenPxDistance = uFWidth * (median - 0.5);\r
  float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
  if (median < 0.01) {\r
    alpha = 0.0;\r
  } else if (median > 0.99) {\r
    alpha = 1.0;\r
  }\r
\r
  // Gamma correction for coverage-like alpha\r
  float luma = dot(uColor.rgb, vec3(0.299, 0.587, 0.114));\r
  float gamma = mix(1.0, 1.0 / 2.2, luma);\r
  float coverage = pow(uColor.a * alpha, gamma);  \r
\r
  // NPM Textures, NPM outputs\r
  gl_FragColor = vec4(uColor.rgb, coverage);\r
}\r
`, MI = `// Mesh material default fragment\r
attribute vec2 aVertexPosition;\r
attribute vec2 aTextureCoord;\r
\r
uniform mat3 projectionMatrix;\r
uniform mat3 translationMatrix;\r
uniform mat3 uTextureMatrix;\r
\r
varying vec2 vTextureCoord;\r
\r
void main(void)\r
{\r
    gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
\r
    vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
}\r
`;
const sp = [], op = [], ap = [], kI = class B0 extends Qe {
  /**
   * @param text - A string that you would like the text to display.
   * @param style - The style parameters.
   * @param {string} style.fontName - The installed BitmapFont name.
   * @param {number} [style.fontSize] - The size of the font in pixels, e.g. 24. If undefined,
   *.     this will default to the BitmapFont size.
   * @param {string} [style.align='left'] - Alignment for multiline text ('left', 'center', 'right' or 'justify'),
   *      does not affect single line text.
   * @param {PIXI.ColorSource} [style.tint=0xFFFFFF] - The tint color.
   * @param {number} [style.letterSpacing=0] - The amount of spacing between letters.
   * @param {number} [style.maxWidth=0] - The max width of the text before line wrapping.
   */
  constructor(e, t = {}) {
    super();
    const { align: i, tint: n, maxWidth: s, letterSpacing: o, fontName: a, fontSize: l } = Object.assign(
      {},
      B0.styleDefaults,
      t
    );
    if (!Vi.available[a])
      throw new Error(`Missing BitmapFont "${a}"`);
    this._activePagesMeshData = [], this._textWidth = 0, this._textHeight = 0, this._align = i, this._tintColor = new be(n), this._font = void 0, this._fontName = a, this._fontSize = l, this.text = e, this._maxWidth = s, this._maxLineHeight = 0, this._letterSpacing = o, this._anchor = new Ci(() => {
      this.dirty = !0;
    }, this, 0, 0), this._roundPixels = Z.ROUND_PIXELS, this.dirty = !0, this._resolution = Z.RESOLUTION, this._autoResolution = !0, this._textureCache = {};
  }
  /** Renders text and updates it when needed. This should only be called if the BitmapFont is regenerated. */
  updateText() {
    var O;
    const e = Vi.available[this._fontName], t = this.fontSize, i = t / e.size, n = new ge(), s = [], o = [], a = [], l = this._text.replace(/(?:\r\n|\r)/g, `
`) || " ", h = D0(l), c = this._maxWidth * e.size / t, u = e.distanceFieldType === "none" ? sp : op;
    let d = null, f = 0, p = 0, _ = 0, m = -1, y = 0, v = 0, g = 0, b = 0;
    for (let B = 0; B < h.length; B++) {
      const C = h[B], M = Lo(C);
      if (/(?:\s)/.test(C) && (m = B, y = f, b++), C === "\r" || C === `
`) {
        o.push(f), a.push(-1), p = Math.max(p, f), ++_, ++v, n.x = 0, n.y += e.lineHeight, d = null, b = 0;
        continue;
      }
      const F = e.chars[M];
      if (!F)
        continue;
      d && F.kerning[d] && (n.x += F.kerning[d]);
      const U = ap.pop() || {
        texture: J.EMPTY,
        line: 0,
        charCode: 0,
        prevSpaces: 0,
        position: new ge()
      };
      U.texture = F.texture, U.line = _, U.charCode = M, U.position.x = Math.round(n.x + F.xOffset + this._letterSpacing / 2), U.position.y = Math.round(n.y + F.yOffset), U.prevSpaces = b, s.push(U), f = U.position.x + Math.max(F.xAdvance - F.xOffset, F.texture.orig.width), n.x += F.xAdvance + this._letterSpacing, g = Math.max(g, F.yOffset + F.texture.height), d = M, m !== -1 && c > 0 && n.x > c && (++v, Cn(s, 1 + m - v, 1 + B - m), B = m, m = -1, o.push(y), a.push(s.length > 0 ? s[s.length - 1].prevSpaces : 0), p = Math.max(p, y), _++, n.x = 0, n.y += e.lineHeight, d = null, b = 0);
    }
    const w = h[h.length - 1];
    w !== "\r" && w !== `
` && (/(?:\s)/.test(w) && (f = y), o.push(f), p = Math.max(p, f), a.push(-1));
    const T = [];
    for (let B = 0; B <= _; B++) {
      let C = 0;
      this._align === "right" ? C = p - o[B] : this._align === "center" ? C = (p - o[B]) / 2 : this._align === "justify" && (C = a[B] < 0 ? 0 : (p - o[B]) / a[B]), T.push(C);
    }
    const x = s.length, E = {}, R = [], k = this._activePagesMeshData;
    u.push(...k);
    for (let B = 0; B < x; B++) {
      const C = s[B].texture, M = C.baseTexture.uid;
      if (!E[M]) {
        let F = u.pop();
        if (!F) {
          const L = new iI();
          let D, N;
          e.distanceFieldType === "none" ? (D = new tp(J.EMPTY), N = oe.NORMAL) : (D = new tp(
            J.EMPTY,
            { program: Ii.from(MI, PI), uniforms: { uFWidth: 0 } }
          ), N = oe.NORMAL_NPM);
          const I = new ep(L, D);
          I.blendMode = N, F = {
            index: 0,
            indexCount: 0,
            vertexCount: 0,
            uvsCount: 0,
            total: 0,
            mesh: I,
            vertices: null,
            uvs: null,
            indices: null
          };
        }
        F.index = 0, F.indexCount = 0, F.vertexCount = 0, F.uvsCount = 0, F.total = 0;
        const { _textureCache: U } = this;
        U[M] = U[M] || new J(C.baseTexture), F.mesh.texture = U[M], F.mesh.tint = this._tintColor.value, R.push(F), E[M] = F;
      }
      E[M].total++;
    }
    for (let B = 0; B < k.length; B++)
      R.includes(k[B]) || this.removeChild(k[B].mesh);
    for (let B = 0; B < R.length; B++)
      R[B].mesh.parent !== this && this.addChild(R[B].mesh);
    this._activePagesMeshData = R;
    for (const B in E) {
      const C = E[B], M = C.total;
      if (!(((O = C.indices) == null ? void 0 : O.length) > 6 * M) || C.vertices.length < ep.BATCHABLE_SIZE * 2)
        C.vertices = new Float32Array(4 * 2 * M), C.uvs = new Float32Array(4 * 2 * M), C.indices = new Uint16Array(6 * M);
      else {
        const F = C.total, U = C.vertices;
        for (let L = F * 4 * 2; L < U.length; L++)
          U[L] = 0;
      }
      C.mesh.size = 6 * M;
    }
    for (let B = 0; B < x; B++) {
      const C = s[B];
      let M = C.position.x + T[C.line] * (this._align === "justify" ? C.prevSpaces : 1);
      this._roundPixels && (M = Math.round(M));
      const F = M * i, U = C.position.y * i, L = C.texture, D = E[L.baseTexture.uid], N = L.frame, I = L._uvs, S = D.index++;
      D.indices[S * 6 + 0] = 0 + S * 4, D.indices[S * 6 + 1] = 1 + S * 4, D.indices[S * 6 + 2] = 2 + S * 4, D.indices[S * 6 + 3] = 0 + S * 4, D.indices[S * 6 + 4] = 2 + S * 4, D.indices[S * 6 + 5] = 3 + S * 4, D.vertices[S * 8 + 0] = F, D.vertices[S * 8 + 1] = U, D.vertices[S * 8 + 2] = F + N.width * i, D.vertices[S * 8 + 3] = U, D.vertices[S * 8 + 4] = F + N.width * i, D.vertices[S * 8 + 5] = U + N.height * i, D.vertices[S * 8 + 6] = F, D.vertices[S * 8 + 7] = U + N.height * i, D.uvs[S * 8 + 0] = I.x0, D.uvs[S * 8 + 1] = I.y0, D.uvs[S * 8 + 2] = I.x1, D.uvs[S * 8 + 3] = I.y1, D.uvs[S * 8 + 4] = I.x2, D.uvs[S * 8 + 5] = I.y2, D.uvs[S * 8 + 6] = I.x3, D.uvs[S * 8 + 7] = I.y3;
    }
    this._textWidth = p * i, this._textHeight = (n.y + e.lineHeight) * i;
    for (const B in E) {
      const C = E[B];
      if (this.anchor.x !== 0 || this.anchor.y !== 0) {
        let L = 0;
        const D = this._textWidth * this.anchor.x, N = this._textHeight * this.anchor.y;
        for (let I = 0; I < C.total; I++)
          C.vertices[L++] -= D, C.vertices[L++] -= N, C.vertices[L++] -= D, C.vertices[L++] -= N, C.vertices[L++] -= D, C.vertices[L++] -= N, C.vertices[L++] -= D, C.vertices[L++] -= N;
      }
      this._maxLineHeight = g * i;
      const M = C.mesh.geometry.getBuffer("aVertexPosition"), F = C.mesh.geometry.getBuffer("aTextureCoord"), U = C.mesh.geometry.getIndex();
      M.data = C.vertices, F.data = C.uvs, U.data = C.indices, M.update(), F.update(), U.update();
    }
    for (let B = 0; B < s.length; B++)
      ap.push(s[B]);
    this._font = e, this.dirty = !1;
  }
  updateTransform() {
    this.validate(), this.containerUpdateTransform();
  }
  _render(e) {
    this._autoResolution && this._resolution !== e.resolution && (this._resolution = e.resolution, this.dirty = !0);
    const { distanceFieldRange: t, distanceFieldType: i, size: n } = Vi.available[this._fontName];
    if (i !== "none") {
      const { a: s, b: o, c: a, d: l } = this.worldTransform, h = Math.sqrt(s * s + o * o), c = Math.sqrt(a * a + l * l), u = (Math.abs(h) + Math.abs(c)) / 2, d = this.fontSize / n, f = e._view.resolution;
      for (const p of this._activePagesMeshData)
        p.mesh.shader.uniforms.uFWidth = u * t * d * f;
    }
    super._render(e);
  }
  /**
   * Validates text before calling parent's getLocalBounds
   * @returns - The rectangular bounding area
   */
  getLocalBounds() {
    return this.validate(), super.getLocalBounds();
  }
  /**
   * Updates text when needed
   * @private
   */
  validate() {
    const e = Vi.available[this._fontName];
    if (!e)
      throw new Error(`Missing BitmapFont "${this._fontName}"`);
    this._font !== e && (this.dirty = !0), this.dirty && this.updateText();
  }
  /**
   * The tint of the BitmapText object.
   * @default 0xffffff
   */
  get tint() {
    return this._tintColor.value;
  }
  set tint(e) {
    if (this.tint !== e) {
      this._tintColor.setValue(e);
      for (let t = 0; t < this._activePagesMeshData.length; t++)
        this._activePagesMeshData[t].mesh.tint = e;
    }
  }
  /**
   * The alignment of the BitmapText object.
   * @member {string}
   * @default 'left'
   */
  get align() {
    return this._align;
  }
  set align(e) {
    this._align !== e && (this._align = e, this.dirty = !0);
  }
  /** The name of the BitmapFont. */
  get fontName() {
    return this._fontName;
  }
  set fontName(e) {
    if (!Vi.available[e])
      throw new Error(`Missing BitmapFont "${e}"`);
    this._fontName !== e && (this._fontName = e, this.dirty = !0);
  }
  /** The size of the font to display. */
  get fontSize() {
    return this._fontSize ?? Vi.available[this._fontName].size;
  }
  set fontSize(e) {
    this._fontSize !== e && (this._fontSize = e, this.dirty = !0);
  }
  /**
   * The anchor sets the origin point of the text.
   *
   * The default is `(0,0)`, this means the text's origin is the top left.
   *
   * Setting the anchor to `(0.5,0.5)` means the text's origin is centered.
   *
   * Setting the anchor to `(1,1)` would mean the text's origin point will be the bottom right corner.
   */
  get anchor() {
    return this._anchor;
  }
  set anchor(e) {
    typeof e == "number" ? this._anchor.set(e) : this._anchor.copyFrom(e);
  }
  /** The text of the BitmapText object. */
  get text() {
    return this._text;
  }
  set text(e) {
    e = String(e ?? ""), this._text !== e && (this._text = e, this.dirty = !0);
  }
  /**
   * The max width of this bitmap text in pixels. If the text provided is longer than the
   * value provided, line breaks will be automatically inserted in the last whitespace.
   * Disable by setting the value to 0.
   */
  get maxWidth() {
    return this._maxWidth;
  }
  set maxWidth(e) {
    this._maxWidth !== e && (this._maxWidth = e, this.dirty = !0);
  }
  /**
   * The max line height. This is useful when trying to use the total height of the Text,
   * i.e. when trying to vertically align.
   * @readonly
   */
  get maxLineHeight() {
    return this.validate(), this._maxLineHeight;
  }
  /**
   * The width of the overall text, different from fontSize,
   * which is defined in the style object.
   * @readonly
   */
  get textWidth() {
    return this.validate(), this._textWidth;
  }
  /** Additional space between characters. */
  get letterSpacing() {
    return this._letterSpacing;
  }
  set letterSpacing(e) {
    this._letterSpacing !== e && (this._letterSpacing = e, this.dirty = !0);
  }
  /**
   * If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation.
   * Advantages can include sharper image quality (like text) and faster rendering on canvas.
   * The main disadvantage is movement of objects may appear less smooth.
   * To set the global default, change {@link PIXI.settings.ROUND_PIXELS}
   * @default PIXI.settings.ROUND_PIXELS
   */
  get roundPixels() {
    return this._roundPixels;
  }
  set roundPixels(e) {
    e !== this._roundPixels && (this._roundPixels = e, this.dirty = !0);
  }
  /**
   * The height of the overall text, different from fontSize,
   * which is defined in the style object.
   * @readonly
   */
  get textHeight() {
    return this.validate(), this._textHeight;
  }
  /**
   * The resolution / device pixel ratio of the canvas.
   *
   * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
   * @default 1
   */
  get resolution() {
    return this._resolution;
  }
  set resolution(e) {
    this._autoResolution = !1, this._resolution !== e && (this._resolution = e, this.dirty = !0);
  }
  destroy(e) {
    const { _textureCache: t } = this, i = Vi.available[this._fontName].distanceFieldType === "none" ? sp : op;
    i.push(...this._activePagesMeshData);
    for (const n of this._activePagesMeshData)
      this.removeChild(n.mesh);
    this._activePagesMeshData = [], i.filter((n) => t[n.mesh.texture.baseTexture.uid]).forEach((n) => {
      n.mesh.texture = J.EMPTY;
    });
    for (const n in t)
      t[n].destroy(), delete t[n];
    this._font = null, this._tintColor = null, this._textureCache = null, super.destroy(e);
  }
};
kI.styleDefaults = {
  align: "left",
  tint: 16777215,
  maxWidth: 0,
  letterSpacing: 0
};
const DI = [".xml", ".fnt"], BI = {
  extension: {
    type: q.LoadParser,
    priority: Qt.Normal
  },
  name: "loadBitmapFont",
  test(r) {
    return DI.includes(We.extname(r).toLowerCase());
  },
  async testParse(r) {
    return Oo.test(r) || Pc.test(r);
  },
  async parse(r, e, t) {
    const i = Oo.test(r) ? Oo.parse(r) : Pc.parse(r), { src: n } = e, { page: s } = i, o = [];
    for (let h = 0; h < s.length; ++h) {
      const c = s[h].file;
      let u = We.join(We.dirname(n), c);
      u = Ec(u, n), o.push(u);
    }
    const a = await t.load(o), l = o.map((h) => a[h]);
    return Vi.install(i, l, !0);
  },
  async load(r, e) {
    return (await Z.ADAPTER.fetch(r)).text();
  },
  unload(r) {
    r.destroy();
  }
};
Q.add(BI);
const Mc = class mn extends rr {
  constructor() {
    super(...arguments), this._fonts = [], this._overrides = [], this._stylesheet = "", this.fontsDirty = !1;
  }
  /**
   * Convert a TextStyle to HTMLTextStyle
   * @param originalStyle
   * @example
   * import {TextStyle } from 'pixi.js';
   * import {HTMLTextStyle} from '@pixi/text-html';
   * const style = new TextStyle();
   * const htmlStyle = HTMLTextStyle.from(style);
   */
  static from(e) {
    return new mn(
      Object.keys(mn.defaultOptions).reduce((t, i) => ({ ...t, [i]: e[i] }), {})
    );
  }
  /** Clear the current font */
  cleanFonts() {
    this._fonts.length > 0 && (this._fonts.forEach((e) => {
      URL.revokeObjectURL(e.src), e.refs--, e.refs === 0 && (e.fontFace && document.fonts.delete(e.fontFace), delete mn.availableFonts[e.originalUrl]);
    }), this.fontFamily = "Arial", this._fonts.length = 0, this.styleID++, this.fontsDirty = !0);
  }
  /**
   * Because of how HTMLText renders, fonts need to be imported
   * @param url
   * @param options
   */
  loadFont(e, t = {}) {
    const { availableFonts: i } = mn;
    if (i[e]) {
      const n = i[e];
      return this._fonts.push(n), n.refs++, this.styleID++, this.fontsDirty = !0, Promise.resolve();
    }
    return Z.ADAPTER.fetch(e).then((n) => n.blob()).then(async (n) => new Promise((s, o) => {
      const a = URL.createObjectURL(n), l = new FileReader();
      l.onload = () => s([a, l.result]), l.onerror = o, l.readAsDataURL(n);
    })).then(async ([n, s]) => {
      const o = Object.assign({
        family: We.basename(e, We.extname(e)),
        weight: "normal",
        style: "normal",
        display: "auto",
        src: n,
        dataSrc: s,
        refs: 1,
        originalUrl: e,
        fontFace: null
      }, t);
      i[e] = o, this._fonts.push(o), this.styleID++;
      const a = new FontFace(o.family, `url(${o.src})`, {
        weight: o.weight,
        style: o.style,
        display: o.display
      });
      o.fontFace = a, await a.load(), document.fonts.add(a), await document.fonts.ready, this.styleID++, this.fontsDirty = !0;
    });
  }
  /**
   * Add a style override, this can be any CSS property
   * it will override any built-in style. This is the
   * property and the value as a string (e.g., `color: red`).
   * This will override any other internal style.
   * @param {string} value - CSS style(s) to add.
   * @example
   * style.addOverride('background-color: red');
   */
  addOverride(...e) {
    const t = e.filter((i) => !this._overrides.includes(i));
    t.length > 0 && (this._overrides.push(...t), this.styleID++);
  }
  /**
   * Remove any overrides that match the value.
   * @param {string} value - CSS style to remove.
   * @example
   * style.removeOverride('background-color: red');
   */
  removeOverride(...e) {
    const t = e.filter((i) => this._overrides.includes(i));
    t.length > 0 && (this._overrides = this._overrides.filter((i) => !t.includes(i)), this.styleID++);
  }
  /**
   * Internally converts all of the style properties into CSS equivalents.
   * @param scale
   * @returns The CSS style string, for setting `style` property of root HTMLElement.
   */
  toCSS(e) {
    return [
      `transform: scale(${e})`,
      "transform-origin: top left",
      "display: inline-block",
      `color: ${this.normalizeColor(this.fill)}`,
      `font-size: ${this.fontSize}px`,
      `font-family: ${this.fontFamily}`,
      `font-weight: ${this.fontWeight}`,
      `font-style: ${this.fontStyle}`,
      `font-variant: ${this.fontVariant}`,
      `letter-spacing: ${this.letterSpacing}px`,
      `text-align: ${this.align}`,
      `padding: ${this.padding}px`,
      `white-space: ${this.whiteSpace}`,
      ...this.lineHeight ? [`line-height: ${this.lineHeight}px`] : [],
      ...this.wordWrap ? [
        `word-wrap: ${this.breakWords ? "break-all" : "break-word"}`,
        `max-width: ${this.wordWrapWidth}px`
      ] : [],
      ...this.strokeThickness ? [
        `-webkit-text-stroke-width: ${this.strokeThickness}px`,
        `-webkit-text-stroke-color: ${this.normalizeColor(this.stroke)}`,
        `text-stroke-width: ${this.strokeThickness}px`,
        `text-stroke-color: ${this.normalizeColor(this.stroke)}`,
        "paint-order: stroke"
      ] : [],
      ...this.dropShadow ? [this.dropShadowToCSS()] : [],
      ...this._overrides
    ].join(";");
  }
  /** Get the font CSS styles from the loaded font, If available. */
  toGlobalCSS() {
    return this._fonts.reduce((e, t) => `${e}
            @font-face {
                font-family: "${t.family}";
                src: url('${t.dataSrc}');
                font-weight: ${t.weight};
                font-style: ${t.style};
                font-display: ${t.display};
            }`, this._stylesheet);
  }
  /** Internal stylesheet contents, useful for creating rules for rendering */
  get stylesheet() {
    return this._stylesheet;
  }
  set stylesheet(e) {
    this._stylesheet !== e && (this._stylesheet = e, this.styleID++);
  }
  /**
   * Convert numerical colors into hex-strings
   * @param color
   */
  normalizeColor(e) {
    return Array.isArray(e) && (e = EA(e)), typeof e == "number" ? xA(e) : e;
  }
  /** Convert the internal drop-shadow settings to CSS text-shadow */
  dropShadowToCSS() {
    let e = this.normalizeColor(this.dropShadowColor);
    const t = this.dropShadowAlpha, i = Math.round(Math.cos(this.dropShadowAngle) * this.dropShadowDistance), n = Math.round(Math.sin(this.dropShadowAngle) * this.dropShadowDistance);
    e.startsWith("#") && t < 1 && (e += (t * 255 | 0).toString(16).padStart(2, "0"));
    const s = `${i}px ${n}px`;
    return this.dropShadowBlur > 0 ? `text-shadow: ${s} ${this.dropShadowBlur}px ${e}` : `text-shadow: ${s} ${e}`;
  }
  /** Resets all properties to the defaults specified in TextStyle.prototype._default */
  reset() {
    Object.assign(this, mn.defaultOptions);
  }
  /**
   * Called after the image is loaded but before drawing to the canvas.
   * Mostly used to handle Safari's font loading bug.
   * @ignore
   */
  onBeforeDraw() {
    const { fontsDirty: e } = this;
    return this.fontsDirty = !1, this.isSafari && this._fonts.length > 0 && e ? new Promise((t) => setTimeout(t, 100)) : Promise.resolve();
  }
  /**
   * Proving that Safari is the new IE
   * @ignore
   */
  get isSafari() {
    const { userAgent: e } = Z.ADAPTER.getNavigator();
    return /^((?!chrome|android).)*safari/i.test(e);
  }
  set fillGradientStops(e) {
    console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText");
  }
  get fillGradientStops() {
    return super.fillGradientStops;
  }
  set fillGradientType(e) {
    console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText");
  }
  get fillGradientType() {
    return super.fillGradientType;
  }
  set miterLimit(e) {
    console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText");
  }
  get miterLimit() {
    return super.miterLimit;
  }
  set trim(e) {
    console.warn("[HTMLTextStyle] trim is not supported by HTMLText");
  }
  get trim() {
    return super.trim;
  }
  set textBaseline(e) {
    console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText");
  }
  get textBaseline() {
    return super.textBaseline;
  }
  set leading(e) {
    console.warn("[HTMLTextStyle] leading is not supported by HTMLText");
  }
  get leading() {
    return super.leading;
  }
  set lineJoin(e) {
    console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText");
  }
  get lineJoin() {
    return super.lineJoin;
  }
};
Mc.availableFonts = {}, /**
* List of default options, these are largely the same as TextStyle,
* with the exception of whiteSpace, which is set to 'normal' by default.
*/
Mc.defaultOptions = {
  /** Align */
  align: "left",
  /** Break words */
  breakWords: !1,
  /** Drop shadow */
  dropShadow: !1,
  /** Drop shadow alpha */
  dropShadowAlpha: 1,
  /**
   * Drop shadow angle
   * @type {number}
   * @default Math.PI / 6
   */
  dropShadowAngle: Math.PI / 6,
  /** Drop shadow blur */
  dropShadowBlur: 0,
  /** Drop shadow color */
  dropShadowColor: "black",
  /** Drop shadow distance */
  dropShadowDistance: 5,
  /** Fill */
  fill: "black",
  /** Font family */
  fontFamily: "Arial",
  /** Font size */
  fontSize: 26,
  /** Font style */
  fontStyle: "normal",
  /** Font variant */
  fontVariant: "normal",
  /** Font weight */
  fontWeight: "normal",
  /** Letter spacing */
  letterSpacing: 0,
  /** Line height */
  lineHeight: 0,
  /** Padding */
  padding: 0,
  /** Stroke */
  stroke: "black",
  /** Stroke thickness */
  strokeThickness: 0,
  /** White space */
  whiteSpace: "normal",
  /** Word wrap */
  wordWrap: !1,
  /** Word wrap width */
  wordWrapWidth: 100
};
let ch = Mc;
const bo = class gn extends st {
  /**
   * @param {string} [text] - Text contents
   * @param {PIXI.HTMLTextStyle|PIXI.TextStyle|PIXI.ITextStyle} [style] - Style setting to use.
   *        Strongly recommend using an HTMLTextStyle object. Providing a PIXI.TextStyle
   *        will convert the TextStyle to an HTMLTextStyle and will no longer be linked.
   */
  constructor(e = "", t = {}) {
    super(J.EMPTY), this._text = null, this._style = null, this._autoResolution = !0, this.localStyleID = -1, this.dirty = !1, this._updateID = 0, this.ownsStyle = !1;
    const i = new Image(), n = J.from(i, {
      scaleMode: Z.SCALE_MODE,
      resourceOptions: {
        autoLoad: !1
      }
    });
    n.orig = new le(), n.trim = new le(), this.texture = n;
    const s = "http://www.w3.org/2000/svg", o = "http://www.w3.org/1999/xhtml", a = document.createElementNS(s, "svg"), l = document.createElementNS(s, "foreignObject"), h = document.createElementNS(o, "div"), c = document.createElementNS(o, "style");
    l.setAttribute("width", "10000"), l.setAttribute("height", "10000"), l.style.overflow = "hidden", a.appendChild(l), this.maxWidth = gn.defaultMaxWidth, this.maxHeight = gn.defaultMaxHeight, this._domElement = h, this._styleElement = c, this._svgRoot = a, this._foreignObject = l, this._foreignObject.appendChild(c), this._foreignObject.appendChild(h), this._image = i, this._loadImage = new Image(), this._autoResolution = gn.defaultAutoResolution, this._resolution = gn.defaultResolution ?? Z.RESOLUTION, this.text = e, this.style = t;
  }
  /**
   * Calculate the size of the output text without actually drawing it.
   * This includes the `padding` in the `style` object.
   * This can be used as a fast-pass to do things like text-fitting.
   * @param {object} [overrides] - Overrides for the text, style, and resolution.
   * @param {string} [overrides.text] - The text to measure, if not specified, the current text is used.
   * @param {PIXI.HTMLTextStyle} [overrides.style] - The style to measure, if not specified, the current style is used.
   * @param {number} [overrides.resolution] - The resolution to measure, if not specified, the current resolution is used.
   * @returns {PIXI.ISize} Width and height of the measured text.
   */
  measureText(e) {
    var c, u;
    const { text: t, style: i, resolution: n } = Object.assign({
      text: this._text,
      style: this._style,
      resolution: this._resolution
    }, e);
    Object.assign(this._domElement, {
      innerHTML: t,
      style: i.toCSS(n)
    }), this._styleElement.textContent = i.toGlobalCSS(), document.body.appendChild(this._svgRoot);
    const s = this._domElement.getBoundingClientRect();
    this._svgRoot.remove();
    const { width: o, height: a } = s;
    (o > this.maxWidth || a > this.maxHeight) && console.warn("[HTMLText] Large expanse of text, increase HTMLText.maxWidth or HTMLText.maxHeight property.");
    const l = Math.min(this.maxWidth, Math.ceil(o)), h = Math.min(this.maxHeight, Math.ceil(a));
    return this._svgRoot.setAttribute("width", l.toString()), this._svgRoot.setAttribute("height", h.toString()), t !== this._text && (this._domElement.innerHTML = this._text), i !== this._style && (Object.assign(this._domElement, { style: (c = this._style) == null ? void 0 : c.toCSS(n) }), this._styleElement.textContent = (u = this._style) == null ? void 0 : u.toGlobalCSS()), {
      width: l + i.padding * 2,
      height: h + i.padding * 2
    };
  }
  /**
   * Manually refresh the text.
   * @public
   * @param {boolean} respectDirty - Whether to abort updating the
   *        text if the Text isn't dirty and the function is called.
   */
  async updateText(e = !0) {
    const { style: t, _image: i, _loadImage: n } = this;
    if (this.localStyleID !== t.styleID && (this.dirty = !0, this.localStyleID = t.styleID), !this.dirty && e)
      return;
    const { width: s, height: o } = this.measureText();
    i.width = n.width = Math.ceil(Math.max(1, s)), i.height = n.height = Math.ceil(Math.max(1, o)), this._updateID++;
    const a = this._updateID;
    await new Promise((l) => {
      n.onload = async () => {
        if (a < this._updateID) {
          l();
          return;
        }
        await t.onBeforeDraw(), i.src = n.src, n.onload = null, n.src = "", this.updateTexture(), l();
      };
      const h = new XMLSerializer().serializeToString(this._svgRoot);
      n.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(h)}`;
    });
  }
  /** The raw image element that is rendered under-the-hood. */
  get source() {
    return this._image;
  }
  /**
   * Update the texture resource.
   * @private
   */
  updateTexture() {
    const { style: e, texture: t, _image: i, resolution: n } = this, { padding: s } = e, { baseTexture: o } = t;
    t.trim.width = t._frame.width = i.width / n, t.trim.height = t._frame.height = i.height / n, t.trim.x = -s, t.trim.y = -s, t.orig.width = t._frame.width - s * 2, t.orig.height = t._frame.height - s * 2, this._onTextureUpdate(), o.setRealSize(i.width, i.height, n), this.dirty = !1;
  }
  /**
   * Renders the object using the WebGL renderer
   * @param {PIXI.Renderer} renderer - The renderer
   * @private
   */
  _render(e) {
    this._autoResolution && this._resolution !== e.resolution && (this._resolution = e.resolution, this.dirty = !0), this.updateText(!0), super._render(e);
  }
  /**
   * Renders the object using the Canvas Renderer.
   * @private
   * @param {PIXI.CanvasRenderer} renderer - The renderer
   */
  _renderCanvas(e) {
    this._autoResolution && this._resolution !== e.resolution && (this._resolution = e.resolution, this.dirty = !0), this.updateText(!0), super._renderCanvas(e);
  }
  /**
   * Get the local bounds.
   * @param {PIXI.Rectangle} rect - Input rectangle.
   * @returns {PIXI.Rectangle} Local bounds
   */
  getLocalBounds(e) {
    return this.updateText(!0), super.getLocalBounds(e);
  }
  _calculateBounds() {
    this.updateText(!0), this.calculateVertices(), this._bounds.addQuad(this.vertexData);
  }
  /**
   * Handle dirty style changes
   * @private
   */
  _onStyleChange() {
    this.dirty = !0;
  }
  /**
   * Destroy this Text object. Don't use after calling.
   * @param {boolean|object} options - Same as Sprite destroy options.
   */
  destroy(e) {
    var i, n, s, o, a;
    typeof e == "boolean" && (e = { children: e }), e = Object.assign({}, gn.defaultDestroyOptions, e), super.destroy(e);
    const t = null;
    this.ownsStyle && ((i = this._style) == null || i.cleanFonts()), this._style = t, (n = this._svgRoot) == null || n.remove(), this._svgRoot = t, (s = this._domElement) == null || s.remove(), this._domElement = t, (o = this._foreignObject) == null || o.remove(), this._foreignObject = t, (a = this._styleElement) == null || a.remove(), this._styleElement = t, this._loadImage.src = "", this._loadImage.onload = null, this._loadImage = t, this._image.src = "", this._image = t;
  }
  /**
   * Get the width in pixels.
   * @member {number}
   */
  get width() {
    return this.updateText(!0), Math.abs(this.scale.x) * this._image.width / this.resolution;
  }
  set width(e) {
    this.updateText(!0);
    const t = Zi(this.scale.x) || 1;
    this.scale.x = t * e / this._image.width / this.resolution, this._width = e;
  }
  /**
   * Get the height in pixels.
   * @member {number}
   */
  get height() {
    return this.updateText(!0), Math.abs(this.scale.y) * this._image.height / this.resolution;
  }
  set height(e) {
    this.updateText(!0);
    const t = Zi(this.scale.y) || 1;
    this.scale.y = t * e / this._image.height / this.resolution, this._height = e;
  }
  /** The base style to render with text. */
  get style() {
    return this._style;
  }
  set style(e) {
    this._style !== e && (e = e || {}, e instanceof ch ? (this.ownsStyle = !1, this._style = e) : e instanceof rr ? (console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"), this.ownsStyle = !0, this._style = ch.from(e)) : (this.ownsStyle = !0, this._style = new ch(e)), this.localStyleID = -1, this.dirty = !0);
  }
  /**
   * Contents of text. This can be HTML text and include tags.
   * @example
   * const text = new HTMLText('This is a <em>styled</em> text!');
   * @member {string}
   */
  get text() {
    return this._text;
  }
  set text(e) {
    e = String(e === "" || e === null || e === void 0 ? " " : e), e = this.sanitiseText(e), this._text !== e && (this._text = e, this.dirty = !0);
  }
  /**
   * The resolution / device pixel ratio of the canvas.
   * This is set to automatically match the renderer resolution by default, but can be overridden by setting manually.
   * @member {number}
   * @default 1
   */
  get resolution() {
    return this._resolution;
  }
  set resolution(e) {
    this._autoResolution = !1, this._resolution !== e && (this._resolution = e, this.dirty = !0);
  }
  /**
   * Sanitise text - replace `<br>` with `<br/>`, `&nbsp;` with `&#160;`
   * @param text
   * @see https://www.sitepoint.com/community/t/xhtml-1-0-transitional-xml-parsing-error-entity-nbsp-not-defined/3392/3
   */
  sanitiseText(e) {
    return e.replace(/<br>/gi, "<br/>").replace(/<hr>/gi, "<hr/>").replace(/&nbsp;/gi, "&#160;");
  }
};
bo.defaultDestroyOptions = {
  texture: !0,
  children: !1,
  baseTexture: !0
}, /** Default maxWidth, set at construction */
bo.defaultMaxWidth = 2024, /** Default maxHeight, set at construction */
bo.defaultMaxHeight = 2024, /** Default autoResolution for all HTMLText objects */
bo.defaultAutoResolution = !0;
function kc(r) {
  return {
    command: r || null,
    next: null,
    previous: null,
    push: function(e) {
      const t = kc(e);
      t.previous = this, this.next = t;
    }
  };
}
function FI() {
  let r = kc();
  const e = rt(!1), t = rt(!1), i = rt(r);
  return {
    undo: function() {
      var n;
      r.previous && ((n = r.command) == null || n.undo(), r = r.previous), e.set(!!r.previous), t.set(!!r.next), i.set(r);
    },
    redo: function() {
      var n;
      r.next && ((n = r.next.command) == null || n.execute(), r = r.next), e.set(!!r.previous), t.set(!!r.next), i.set(r);
    },
    execute: function(n) {
      n.execute(), r.push(n), r = r.next, e.set(!!r.previous), t.set(!!r.next), i.set(r);
    },
    can_undo: e,
    can_redo: t,
    current_history: i,
    reset: function() {
      r = kc(), e.set(!1), t.set(!1), i.set(r);
    }
  };
}
function OI({
  target: r,
  dimensions: [e, t],
  antialias: i
}) {
  const n = window.devicePixelRatio || 1, s = new u0({
    width: e,
    height: t,
    antialias: i,
    backgroundAlpha: 0,
    eventMode: "static"
  }), o = s.view;
  s.stage.sortableChildren = !0, o.style.maxWidth = `${e / n}px`, o.style.maxHeight = `${t / n}px`, o.style.width = "100%", o.style.height = "100%", r.appendChild(s.view);
  const a = new Qe();
  a.zIndex = 0;
  const l = new Qe();
  l.zIndex = 1, l.sortableChildren = !0;
  const h = new Qe();
  h.zIndex = 1;
  const c = new Qe();
  c.zIndex = 0, h.addChild(a), h.addChild(l), s.stage.addChild(h), s.stage.addChild(c);
  const u = new Xr();
  let d = et.create({
    width: e,
    height: t
  });
  const f = new st(d);
  h.mask = f, s.render();
  function p(y, v) {
    a.removeChildren(), u.beginFill(16777215, 1), u.drawRect(0, 0, y, v), u.endFill(), d = et.create({
      width: y,
      height: v
    }), s.renderer.render(u, {
      renderTexture: d
    });
    const g = new st(d);
    h.mask = g;
  }
  function _(y, v) {
    s.renderer.resize(y, v), o.style.maxWidth = `${y / n}px`, o.style.maxHeight = `${v / n}px`, p(y, v);
  }
  async function m(y, v, [g, b]) {
    const w = await uh(
      s.renderer,
      a,
      v,
      g,
      b
    ), T = await Promise.all(
      y.map(
        (E) => uh(
          s.renderer,
          E.composite,
          v,
          g,
          b
        )
      )
    ), x = await uh(
      s.renderer,
      h,
      v,
      g,
      b
    );
    return {
      background: w,
      layers: T,
      composite: x
    };
  }
  return {
    layer_container: l,
    renderer: s.renderer,
    destroy: () => s.destroy(!0),
    view: s.view,
    background_container: a,
    mask_container: h,
    resize: _,
    get_blobs: m
  };
}
function F0(r) {
  const e = new Xr();
  return e.eventMode = "none", e.zIndex = r, e;
}
function Vt(r, e, t) {
  return r < e ? e : r > t ? t : r;
}
function uh(r, e, t, i, n) {
  return new Promise((s) => {
    var h;
    const o = r.extract.canvas(
      e,
      new le(0, 0, i, n)
    );
    let a = document.createElement("canvas");
    a.width = t.width, a.height = t.height;
    let l = a.getContext("2d");
    if (!l)
      throw s(null), new Error("Could not create canvas context");
    l.drawImage(
      o,
      // this is the area of the source that we want to copy (the crop box)
      t.x,
      t.y,
      t.width,
      t.height,
      // this is where we want to draw the crop box on the destination canvas
      0,
      0,
      t.width,
      t.height
    ), (h = a.toBlob) == null || h.call(a, (c) => {
      c || s(null), s(c);
    });
  });
}
const {
  SvelteComponent: LI,
  append: wo,
  attr: Dc,
  check_outros: NI,
  create_component: No,
  destroy_component: Uo,
  detach: O0,
  element: Bc,
  group_outros: UI,
  init: GI,
  insert: L0,
  mount_component: Go,
  safe_not_equal: HI,
  space: dh,
  transition_in: Ar,
  transition_out: yn
} = window.__gradio__svelte__internal, { createEventDispatcher: zI } = window.__gradio__svelte__internal;
function lp(r) {
  let e, t, i;
  return t = new Pi({
    props: {
      disabled: !/*can_save*/
      r[2],
      Icon: L1,
      label: "Save changes",
      background: "var(--color-green-500)",
      color: "#fff"
    }
  }), t.$on(
    "click",
    /*click_handler_3*/
    r[8]
  ), {
    c() {
      e = Bc("div"), No(t.$$.fragment), Dc(e, "class", "row-wrap save svelte-1ulgfpn");
    },
    m(n, s) {
      L0(n, e, s), Go(t, e, null), i = !0;
    },
    p(n, s) {
      const o = {};
      s & /*can_save*/
      4 && (o.disabled = !/*can_save*/
      n[2]), t.$set(o);
    },
    i(n) {
      i || (Ar(t.$$.fragment, n), i = !0);
    },
    o(n) {
      yn(t.$$.fragment, n), i = !1;
    },
    d(n) {
      n && O0(e), Uo(t);
    }
  };
}
function XI(r) {
  let e, t, i, n, s, o, a, l, h;
  i = new Pi({
    props: {
      disabled: !/*can_undo*/
      r[0],
      Icon: Bv,
      label: "Undo"
    }
  }), i.$on(
    "click",
    /*click_handler*/
    r[5]
  ), s = new Pi({
    props: {
      disabled: !/*can_redo*/
      r[1],
      Icon: uv,
      label: "Redo"
    }
  }), s.$on(
    "click",
    /*click_handler_1*/
    r[6]
  ), a = new Pi({
    props: { Icon: Cv, label: "Clear canvas" }
  }), a.$on(
    "click",
    /*click_handler_2*/
    r[7]
  );
  let c = (
    /*changeable*/
    r[3] && lp(r)
  );
  return {
    c() {
      e = Bc("div"), t = Bc("div"), No(i.$$.fragment), n = dh(), No(s.$$.fragment), o = dh(), No(a.$$.fragment), l = dh(), c && c.c(), Dc(t, "class", "row-wrap svelte-1ulgfpn"), Dc(e, "class", "controls-wrap svelte-1ulgfpn");
    },
    m(u, d) {
      L0(u, e, d), wo(e, t), Go(i, t, null), wo(t, n), Go(s, t, null), wo(t, o), Go(a, t, null), wo(e, l), c && c.m(e, null), h = !0;
    },
    p(u, [d]) {
      const f = {};
      d & /*can_undo*/
      1 && (f.disabled = !/*can_undo*/
      u[0]), i.$set(f);
      const p = {};
      d & /*can_redo*/
      2 && (p.disabled = !/*can_redo*/
      u[1]), s.$set(p), /*changeable*/
      u[3] ? c ? (c.p(u, d), d & /*changeable*/
      8 && Ar(c, 1)) : (c = lp(u), c.c(), Ar(c, 1), c.m(e, null)) : c && (UI(), yn(c, 1, 1, () => {
        c = null;
      }), NI());
    },
    i(u) {
      h || (Ar(i.$$.fragment, u), Ar(s.$$.fragment, u), Ar(a.$$.fragment, u), Ar(c), h = !0);
    },
    o(u) {
      yn(i.$$.fragment, u), yn(s.$$.fragment, u), yn(a.$$.fragment, u), yn(c), h = !1;
    },
    d(u) {
      u && O0(e), Uo(i), Uo(s), Uo(a), c && c.d();
    }
  };
}
function VI(r, e, t) {
  let { can_undo: i = !1 } = e, { can_redo: n = !1 } = e, { can_save: s = !1 } = e, { changeable: o = !1 } = e;
  const a = zI(), l = (d) => {
    a("undo"), d.stopPropagation();
  }, h = (d) => {
    a("redo"), d.stopPropagation();
  }, c = (d) => {
    a("remove_image"), d.stopPropagation();
  }, u = (d) => {
    a("save"), d.stopPropagation();
  };
  return r.$$set = (d) => {
    "can_undo" in d && t(0, i = d.can_undo), "can_redo" in d && t(1, n = d.can_redo), "can_save" in d && t(2, s = d.can_save), "changeable" in d && t(3, o = d.changeable);
  }, [
    i,
    n,
    s,
    o,
    a,
    l,
    h,
    c,
    u
  ];
}
class WI extends LI {
  constructor(e) {
    super(), GI(this, e, VI, XI, HI, {
      can_undo: 0,
      can_redo: 1,
      can_save: 2,
      changeable: 3
    });
  }
}
const {
  SvelteComponent: jI,
  append: yr,
  attr: an,
  binding_callbacks: hp,
  component_subscribe: At,
  create_component: qI,
  create_slot: YI,
  destroy_component: KI,
  detach: ZI,
  element: ss,
  get_all_dirty_from_scope: $I,
  get_slot_changes: JI,
  init: QI,
  insert: eR,
  listen: tR,
  mount_component: iR,
  safe_not_equal: rR,
  set_store_value: cp,
  set_style: ri,
  space: fh,
  toggle_class: up,
  transition_in: dp,
  transition_out: fp,
  update_slot_base: nR
} = window.__gradio__svelte__internal, { onMount: sR, setContext: oR, createEventDispatcher: aR, tick: lR } = window.__gradio__svelte__internal;
function hR(r) {
  let e, t, i, n, s, o = `translate(${/*$position_spring*/
  r[6].x}px, ${/*$position_spring*/
  r[6].y}px)`, a, l, h, c, u = `${/*$crop*/
  r[7][2] * /*$editor_box*/
  r[8].child_width + 1}px`, d = `${/*$crop*/
  r[7][3] * /*$editor_box*/
  r[8].child_height + 1}px`, f = `${/*$crop*/
  r[7][1] * /*$editor_box*/
  r[8].child_height + /*$editor_box*/
  (r[8].child_top - /*$editor_box*/
  r[8].parent_top) - 0.5}px`, p = `${/*$crop*/
  r[7][0] * /*$editor_box*/
  r[8].child_width + /*$editor_box*/
  (r[8].child_left - /*$editor_box*/
  r[8].parent_left) - 0.5}px`, _, m, y;
  t = new WI({
    props: {
      can_undo: (
        /*$can_undo*/
        r[10]
      ),
      can_redo: (
        /*$can_redo*/
        r[11]
      ),
      can_save: (
        /*saved_history*/
        r[9] !== /*$current_history*/
        r[5]
      ),
      changeable: (
        /*changeable*/
        r[1]
      )
    }
  }), t.$on(
    "undo",
    /*CommandManager*/
    r[17].undo
  ), t.$on(
    "redo",
    /*CommandManager*/
    r[17].redo
  ), t.$on(
    "remove_image",
    /*handle_remove*/
    r[2]
  ), t.$on(
    "save",
    /*handle_save*/
    r[26]
  );
  const v = (
    /*#slots*/
    r[38].default
  ), g = YI(
    v,
    r,
    /*$$scope*/
    r[37],
    null
  );
  return {
    c() {
      e = ss("div"), qI(t.$$.fragment), i = fh(), n = ss("div"), s = ss("div"), a = fh(), l = ss("div"), g && g.c(), h = fh(), c = ss("div"), an(s, "class", "stage-wrap svelte-1mlgq2p"), up(s, "bg", !/*bg*/
      r[0]), ri(s, "transform", o), an(n, "class", "wrap svelte-1mlgq2p"), an(l, "class", "tools-wrap svelte-1mlgq2p"), an(c, "class", "border svelte-1mlgq2p"), ri(c, "width", u), ri(c, "height", d), ri(c, "top", f), ri(c, "left", p), an(e, "data-testid", "image"), an(e, "class", "image-container svelte-1mlgq2p");
    },
    m(b, w) {
      eR(b, e, w), iR(t, e, null), yr(e, i), yr(e, n), yr(n, s), r[40](s), r[41](n), yr(e, a), yr(e, l), g && g.m(l, null), yr(e, h), yr(e, c), _ = !0, m || (y = tR(
        window,
        "scroll",
        /*scroll_handler*/
        r[39]
      ), m = !0);
    },
    p(b, w) {
      const T = {};
      w[0] & /*$can_undo*/
      1024 && (T.can_undo = /*$can_undo*/
      b[10]), w[0] & /*$can_redo*/
      2048 && (T.can_redo = /*$can_redo*/
      b[11]), w[0] & /*saved_history, $current_history*/
      544 && (T.can_save = /*saved_history*/
      b[9] !== /*$current_history*/
      b[5]), w[0] & /*changeable*/
      2 && (T.changeable = /*changeable*/
      b[1]), t.$set(T), (!_ || w[0] & /*bg*/
      1) && up(s, "bg", !/*bg*/
      b[0]), w[0] & /*$position_spring*/
      64 && o !== (o = `translate(${/*$position_spring*/
      b[6].x}px, ${/*$position_spring*/
      b[6].y}px)`) && ri(s, "transform", o), g && g.p && (!_ || w[1] & /*$$scope*/
      64) && nR(
        g,
        v,
        b,
        /*$$scope*/
        b[37],
        _ ? JI(
          v,
          /*$$scope*/
          b[37],
          w,
          null
        ) : $I(
          /*$$scope*/
          b[37]
        ),
        null
      ), w[0] & /*$crop, $editor_box*/
      384 && u !== (u = `${/*$crop*/
      b[7][2] * /*$editor_box*/
      b[8].child_width + 1}px`) && ri(c, "width", u), w[0] & /*$crop, $editor_box*/
      384 && d !== (d = `${/*$crop*/
      b[7][3] * /*$editor_box*/
      b[8].child_height + 1}px`) && ri(c, "height", d), w[0] & /*$crop, $editor_box*/
      384 && f !== (f = `${/*$crop*/
      b[7][1] * /*$editor_box*/
      b[8].child_height + /*$editor_box*/
      (b[8].child_top - /*$editor_box*/
      b[8].parent_top) - 0.5}px`) && ri(c, "top", f), w[0] & /*$crop, $editor_box*/
      384 && p !== (p = `${/*$crop*/
      b[7][0] * /*$editor_box*/
      b[8].child_width + /*$editor_box*/
      (b[8].child_left - /*$editor_box*/
      b[8].parent_left) - 0.5}px`) && ri(c, "left", p);
    },
    i(b) {
      _ || (dp(t.$$.fragment, b), dp(g, b), _ = !0);
    },
    o(b) {
      fp(t.$$.fragment, b), fp(g, b), _ = !1;
    },
    d(b) {
      b && ZI(e), KI(t), r[40](null), r[41](null), g && g.d(b), m = !1, y();
    }
  };
}
const Kn = Symbol("editor");
function cR(r, e, t) {
  let i, n, s, o, a, l, h, c, u, d, f, p, _, { $$slots: m = {}, $$scope: y } = e;
  var v = this && this.__awaiter || function(Y, Fe, Ae, Ee) {
    function it(ve) {
      return ve instanceof Ae ? ve : new Ae(function(me) {
        me(ve);
      });
    }
    return new (Ae || (Ae = Promise))(function(ve, me) {
      function Bt(vi) {
        try {
          ur(Ee.next(vi));
        } catch (Jn) {
          me(Jn);
        }
      }
      function $n(vi) {
        try {
          ur(Ee.throw(vi));
        } catch (Jn) {
          me(Jn);
        }
      }
      function ur(vi) {
        vi.done ? ve(vi.value) : it(vi.value).then(Bt, $n);
      }
      ur((Ee = Ee.apply(Y, Fe || [])).next());
    });
  };
  let { antialias: g = !0 } = e, { crop_size: b } = e, { changeable: w = !1 } = e, { history: T } = e, { bg: x = !1 } = e, { sources: E } = e;
  const R = aR();
  let { crop_constraint: k = !1 } = e, { canvas_size: O } = e, C = rt(O || [800, 600]);
  At(r, C, (Y) => t(46, h = Y));
  let { height: M = 0 } = e, F = rt({
    parent_width: 0,
    parent_height: 0,
    parent_top: 0,
    parent_left: 0,
    parent_right: 0,
    parent_bottom: 0,
    child_width: 0,
    child_height: 0,
    child_top: 0,
    child_left: 0,
    child_right: 0,
    child_bottom: 0
  });
  At(r, F, (Y) => t(8, f = Y));
  const U = rt([0, 0, 1, 1]);
  At(r, U, (Y) => t(7, d = Y));
  const L = Ko({ x: 0, y: 0 }, { stiffness: 0.1, damping: 0.5 });
  At(r, L, (Y) => t(6, u = Y));
  const D = rt(null);
  At(r, D, (Y) => t(45, l = Y));
  const N = FI(), { can_redo: I, can_undo: S, current_history: z } = N;
  At(r, I, (Y) => t(11, _ = Y)), At(r, S, (Y) => t(10, p = Y)), At(r, z, (Y) => t(5, s = Y));
  const V = rt("bg");
  At(r, V, (Y) => t(36, n = Y));
  const $ = rt({});
  At(r, $, (Y) => t(43, o = Y));
  const P = rt({});
  At(r, P, (Y) => t(47, c = Y));
  const ie = rt([]);
  At(r, ie, (Y) => t(44, a = Y));
  const A = rt(new DOMRect()), X = ["bg", "layers", "crop", "draw", "erase"], te = oR(Kn, {
    pixi: D,
    current_layer: rt(null),
    dimensions: C,
    editor_box: F,
    toolbar_box: A,
    active_tool: V,
    crop: U,
    position_spring: L,
    command_manager: N,
    current_history: z,
    register_context: (Y, { reset_fn: Fe, init_fn: Ae }) => {
      ie.update((Ee) => [...Ee, Y]), P.update((Ee) => Object.assign(Object.assign({}, Ee), { [Y]: Ae })), $.update((Ee) => Object.assign(Object.assign({}, Ee), { [Y]: Fe }));
    },
    reset: (Y, Fe) => {
      var Ae, Ee, it;
      t(0, x = !1);
      const ve = a.sort((me, Bt) => X.indexOf(me) - X.indexOf(Bt));
      for (const me of ve)
        me in o && typeof o[me] == "function" && ((Ae = o[me]) === null || Ae === void 0 || Ae.call(o));
      for (const me of ve) {
        if (me in c && typeof c[me] == "function") {
          if (me === "bg" && !Y)
            continue;
          (Ee = c[me]) === null || Ee === void 0 || Ee.call(c, Fe);
        }
        N.reset(), (it = l == null ? void 0 : l.resize) === null || it === void 0 || it.call(l, ...Fe);
      }
    }
  });
  let j, W;
  function se(Y, Fe) {
    if (!Y || !Fe)
      return;
    const { width: Ae, height: Ee, top: it, left: ve, right: me, bottom: Bt } = W.getBoundingClientRect(), { width: $n, height: ur, top: vi, left: Jn, right: ng, bottom: sg } = Fe.getBoundingClientRect();
    F.set({
      child_width: $n,
      child_height: ur,
      child_left: Jn,
      child_right: ng,
      child_top: vi,
      child_bottom: sg,
      parent_width: Ae,
      parent_height: Ee,
      parent_left: ve,
      parent_right: me,
      parent_top: it,
      parent_bottom: Bt
    });
  }
  function ue() {
    requestAnimationFrame(() => {
      lR().then((Y) => cp(V, n = "crop", n));
    });
  }
  function _e() {
    if (!f)
      return;
    const [Y, Fe, Ae, Ee] = d, it = Y * f.child_width, ve = Fe * f.child_height, me = Ae * f.child_width, Bt = Ee * f.child_height, $n = 0.5 * f.child_width - it - me / 2, ur = 0.5 * f.child_height - ve - Bt / 2;
    L.set({ x: $n, y: ur });
  }
  function de() {
    return v(this, void 0, void 0, function* () {
      if (!l || !l.get_layers)
        return {
          background: null,
          layers: [],
          composite: null
        };
      const [Y, Fe, Ae, Ee] = d;
      return l == null ? void 0 : l.get_blobs(l.get_layers(), new le(Math.round(Y * h[0]), Math.round(Fe * h[1]), Math.round(Ae * h[0]), Math.round(Ee * h[1])), h);
    });
  }
  function xe() {
    te.reset(!0, i || h), E.length ? H("bg") : H("draw"), R("clear");
  }
  sR(() => {
    var Y;
    const Ae = OI({
      target: j,
      dimensions: O || b || [800, 600],
      antialias: g
    });
    function Ee(ve, me) {
      Ae.resize(ve, me), C.set([ve, me]);
    }
    D.set(Object.assign(Object.assign({}, Ae), { resize: Ee }));
    const it = new ResizeObserver((ve) => {
      for (const me of ve)
        se(W, j);
    });
    it.observe(W), it.observe(j);
    for (const ve of a)
      ve in c && typeof c[ve] == "function" && ((Y = c[ve]) === null || Y === void 0 || Y.call(c, h));
    return Ee(...h), () => {
      var ve;
      l == null || l.destroy(), it.disconnect();
      for (const me of a)
        me in o && ((ve = o[me]) === null || ve === void 0 || ve.call(o));
    };
  });
  let Me = s;
  function Ke() {
    t(9, Me = s), R("save");
  }
  function H(Y) {
    cp(V, n = Y, n);
  }
  const Zn = () => se(W, j);
  function Yr(Y) {
    hp[Y ? "unshift" : "push"](() => {
      j = Y, t(3, j);
    });
  }
  function Kr(Y) {
    hp[Y ? "unshift" : "push"](() => {
      W = Y, t(4, W);
    });
  }
  return r.$$set = (Y) => {
    "antialias" in Y && t(29, g = Y.antialias), "crop_size" in Y && t(30, b = Y.crop_size), "changeable" in Y && t(1, w = Y.changeable), "history" in Y && t(27, T = Y.history), "bg" in Y && t(0, x = Y.bg), "sources" in Y && t(31, E = Y.sources), "crop_constraint" in Y && t(32, k = Y.crop_constraint), "canvas_size" in Y && t(33, O = Y.canvas_size), "height" in Y && t(28, M = Y.height), "$$scope" in Y && t(37, y = Y.$$scope);
  }, r.$$.update = () => {
    r.$$.dirty[1] & /*canvas_size*/
    4 && (i = O), r.$$.dirty[0] & /*$editor_box*/
    256 && t(28, M = f.child_height), r.$$.dirty[0] & /*$current_history*/
    32 && (s.previous, R("change")), r.$$.dirty[0] & /*$current_history*/
    32 | r.$$.dirty[1] & /*$active_tool*/
    32 && t(27, T = !!s.previous || n !== "bg"), r.$$.dirty[0] & /*bg, history*/
    134217729 | r.$$.dirty[1] & /*crop_constraint*/
    2 && k && x && !T && ue(), r.$$.dirty[0] & /*$crop*/
    128 && d && _e(), r.$$.dirty[0] & /*$position_spring, canvas_wrap, pixi_target*/
    88 && u && se(W, j);
  }, [
    x,
    w,
    xe,
    j,
    W,
    s,
    u,
    d,
    f,
    Me,
    p,
    _,
    C,
    F,
    U,
    L,
    D,
    N,
    I,
    S,
    z,
    V,
    $,
    P,
    ie,
    se,
    Ke,
    T,
    M,
    g,
    b,
    E,
    k,
    O,
    de,
    H,
    n,
    y,
    m,
    Zn,
    Yr,
    Kr
  ];
}
class uR extends jI {
  constructor(e) {
    super(), QI(
      this,
      e,
      cR,
      hR,
      rR,
      {
        antialias: 29,
        crop_size: 30,
        changeable: 1,
        history: 27,
        bg: 0,
        sources: 31,
        crop_constraint: 32,
        canvas_size: 33,
        height: 28,
        get_blobs: 34,
        handle_remove: 2,
        set_tool: 35
      },
      null,
      [-1, -1]
    );
  }
  get get_blobs() {
    return this.$$.ctx[34];
  }
  get handle_remove() {
    return this.$$.ctx[2];
  }
  get set_tool() {
    return this.$$.ctx[35];
  }
}
function dR(r, e) {
  const t = (i) => {
    r && !r.contains(i.target) && !i.defaultPrevented && e(i);
  };
  return document.addEventListener("mousedown", t, !0), {
    destroy() {
      document.removeEventListener("mousedown", t, !0);
    }
  };
}
const fR = `
precision highp float;

uniform sampler2D uDrawingTexture;
uniform sampler2D uEraserTexture;

varying vec2 vTextureCoord;

void main(void) {
	vec4 drawingColor = texture2D(uDrawingTexture,vTextureCoord);
	vec4 eraserColor = texture2D(uEraserTexture, vTextureCoord);

	// Use the alpha of the eraser to determine how much to "erase" from the drawing
	float alpha = 1.0 - eraserColor.a;
	gl_FragColor = vec4(drawingColor.rgb * alpha, drawingColor.a * alpha);
}`;
function pp(r, e) {
  if (e < 0 || e >= r.length - 1)
    throw new Error("Index out of bounds");
  [r[e], r[e + 1]] = [r[e + 1], r[e]];
}
function pR() {
  let r = [], e = 0;
  return {
    add_layer: function(t, i, n, s) {
      const o = new Qe();
      e++, o.zIndex = e;
      const a = et.create({
        width: n,
        height: s
      }), l = new st(a);
      o.addChild(l), l.zIndex = e;
      const h = {
        draw_texture: et.create({
          width: n,
          height: s
        }),
        erase_texture: et.create({
          width: n,
          height: s
        }),
        composite: l
      }, c = new Je(void 0, fR, {
        uEraserTexture: h.erase_texture,
        uDrawingTexture: h.draw_texture
      });
      return l.filters = [c], t.addChild(o), r.push(h), [h, r];
    },
    swap_layers: function(t, i) {
      return i === "up" ? pp(r, t) : pp(r, t - 1), r[t];
    },
    change_active_layer: function(t) {
      return r[t];
    },
    reset() {
      r.forEach((t) => {
        t.draw_texture.destroy(!0), t.erase_texture.destroy(!0), t.composite.destroy(!0);
      }), r = [], e = 0;
    },
    async add_layer_from_blob(t, i, n, s) {
      const o = await createImageBitmap(n), a = J.from(o), [l, h] = _R(
        a.width,
        a.height,
        s.width,
        s.height
      ), c = new st(a);
      c.zIndex = 0, c.width = l, c.height = h;
      const [u, d] = this.add_layer(
        t,
        i,
        s.width,
        s.height
      );
      return i.render(c, {
        renderTexture: u.draw_texture
      }), [u, d];
    },
    get_layers() {
      return r;
    }
  };
}
function _R(r, e, t, i) {
  if (r <= t && e <= i)
    return [r, e];
  const n = r / e, s = t / i;
  let o, a;
  return n > s ? (o = t, a = t / n) : (a = i, o = i * n), [o, a];
}
const {
  SvelteComponent: mR,
  action_destroyer: gR,
  append: yt,
  attr: qt,
  check_outros: yR,
  component_subscribe: ph,
  create_component: vR,
  destroy_block: bR,
  destroy_component: wR,
  detach: Ua,
  element: Ri,
  empty: xR,
  ensure_array_like: _p,
  group_outros: ER,
  init: TR,
  insert: Ga,
  is_function: AR,
  listen: uu,
  mount_component: SR,
  run_all: CR,
  safe_not_equal: IR,
  set_data: N0,
  set_store_value: xo,
  space: Fc,
  text: ya,
  toggle_class: va,
  transition_in: Ho,
  transition_out: Oc,
  update_keyed_each: RR
} = window.__gradio__svelte__internal, { getContext: PR, onMount: MR, tick: mp } = window.__gradio__svelte__internal;
function gp(r, e, t) {
  const i = r.slice();
  return i[20] = e[t], i[22] = t, i;
}
function yp(r) {
  let e, t, i, n, s, o = (
    /*layers*/
    r[2].findIndex(
      /*func*/
      r[11]
    ) + 1 + ""
  ), a, l, h, c, u, d, f, p;
  n = new rv({});
  let _ = (
    /*show_layers*/
    r[1] && vp(r)
  );
  return {
    c() {
      e = Ri("div"), t = Ri("button"), i = Ri("span"), vR(n.$$.fragment), s = ya(" Layer "), a = ya(o), l = Fc(), _ && _.c(), h = Fc(), c = Ri("span"), qt(i, "class", "icon svelte-1wkyrbx"), qt(t, "aria-label", "Show Layers"), qt(t, "class", "svelte-1wkyrbx"), qt(c, "class", "sep svelte-1wkyrbx"), qt(e, "class", "layer-wrap svelte-1wkyrbx"), va(e, "closed", !/*show_layers*/
      r[1]);
    },
    m(m, y) {
      Ga(m, e, y), yt(e, t), yt(t, i), SR(n, i, null), yt(t, s), yt(t, a), yt(e, l), _ && _.m(e, null), yt(e, h), yt(e, c), d = !0, f || (p = [
        uu(
          t,
          "click",
          /*click_handler*/
          r[12]
        ),
        gR(u = dR.call(
          null,
          e,
          /*click_outside_function*/
          r[14]
        ))
      ], f = !0);
    },
    p(m, y) {
      (!d || y & /*layers, $current_layer*/
      12) && o !== (o = /*layers*/
      m[2].findIndex(
        /*func*/
        m[11]
      ) + 1 + "") && N0(a, o), /*show_layers*/
      m[1] ? _ ? _.p(m, y) : (_ = vp(m), _.c(), _.m(e, h)) : _ && (_.d(1), _ = null), u && AR(u.update) && y & /*show_layers*/
      2 && u.update.call(
        null,
        /*click_outside_function*/
        m[14]
      ), (!d || y & /*show_layers*/
      2) && va(e, "closed", !/*show_layers*/
      m[1]);
    },
    i(m) {
      d || (Ho(n.$$.fragment, m), d = !0);
    },
    o(m) {
      Oc(n.$$.fragment, m), d = !1;
    },
    d(m) {
      m && Ua(e), wR(n), _ && _.d(), f = !1, CR(p);
    }
  };
}
function vp(r) {
  let e, t = [], i = /* @__PURE__ */ new Map(), n, s, o, a, l, h = _p(
    /*layers*/
    r[2]
  );
  const c = (u) => (
    /*i*/
    u[22]
  );
  for (let u = 0; u < h.length; u += 1) {
    let d = gp(r, h, u), f = c(d);
    i.set(f, t[u] = bp(f, d));
  }
  return {
    c() {
      e = Ri("ul");
      for (let u = 0; u < t.length; u += 1)
        t[u].c();
      n = Fc(), s = Ri("li"), o = Ri("button"), o.textContent = "+", qt(o, "aria-label", "Add Layer"), qt(o, "class", "svelte-1wkyrbx"), qt(s, "class", "svelte-1wkyrbx"), qt(e, "class", "svelte-1wkyrbx");
    },
    m(u, d) {
      Ga(u, e, d);
      for (let f = 0; f < t.length; f += 1)
        t[f] && t[f].m(e, null);
      yt(e, n), yt(e, s), yt(s, o), a || (l = uu(
        o,
        "click",
        /*new_layer*/
        r[8]
      ), a = !0);
    },
    p(u, d) {
      d & /*$current_layer, layers, LayerManager*/
      140 && (h = _p(
        /*layers*/
        u[2]
      ), t = RR(t, d, c, 1, u, h, i, e, bR, bp, n, gp));
    },
    d(u) {
      u && Ua(e);
      for (let d = 0; d < t.length; d += 1)
        t[d].d();
      a = !1, l();
    }
  };
}
function bp(r, e) {
  let t, i, n, s = (
    /*i*/
    e[22] + 1 + ""
  ), o, a, l;
  function h() {
    return (
      /*click_handler_1*/
      e[13](
        /*i*/
        e[22]
      )
    );
  }
  return {
    key: r,
    first: null,
    c() {
      t = Ri("li"), i = Ri("button"), n = ya("Layer "), o = ya(s), qt(i, "class", "svelte-1wkyrbx"), va(
        i,
        "selected_layer",
        /*$current_layer*/
        e[3] === /*layer*/
        e[20]
      ), qt(t, "class", "svelte-1wkyrbx"), this.first = t;
    },
    m(c, u) {
      Ga(c, t, u), yt(t, i), yt(i, n), yt(i, o), a || (l = uu(i, "click", h), a = !0);
    },
    p(c, u) {
      e = c, u & /*layers*/
      4 && s !== (s = /*i*/
      e[22] + 1 + "") && N0(o, s), u & /*$current_layer, layers*/
      12 && va(
        i,
        "selected_layer",
        /*$current_layer*/
        e[3] === /*layer*/
        e[20]
      );
    },
    d(c) {
      c && Ua(t), a = !1, l();
    }
  };
}
function kR(r) {
  let e, t, i = (
    /*enable_layers*/
    r[0] && yp(r)
  );
  return {
    c() {
      i && i.c(), e = xR();
    },
    m(n, s) {
      i && i.m(n, s), Ga(n, e, s), t = !0;
    },
    p(n, [s]) {
      /*enable_layers*/
      n[0] ? i ? (i.p(n, s), s & /*enable_layers*/
      1 && Ho(i, 1)) : (i = yp(n), i.c(), Ho(i, 1), i.m(e.parentNode, e)) : i && (ER(), Oc(i, 1, 1, () => {
        i = null;
      }), yR());
    },
    i(n) {
      t || (Ho(i), t = !0);
    },
    o(n) {
      Oc(i), t = !1;
    },
    d(n) {
      n && Ua(e), i && i.d(n);
    }
  };
}
function DR(r) {
  return r !== null;
}
function BR(r, e, t) {
  let i, n, s;
  var o = this && this.__awaiter || function(x, E, R, k) {
    function O(B) {
      return B instanceof R ? B : new R(function(C) {
        C(B);
      });
    }
    return new (R || (R = Promise))(function(B, C) {
      function M(L) {
        try {
          U(k.next(L));
        } catch (D) {
          C(D);
        }
      }
      function F(L) {
        try {
          U(k.throw(L));
        } catch (D) {
          C(D);
        }
      }
      function U(L) {
        L.done ? B(L.value) : O(L.value).then(M, F);
      }
      U((k = k.apply(x, E || [])).next());
    });
  };
  let a = !1, { layer_files: l = [] } = e, { enable_layers: h = !0 } = e;
  const { pixi: c, current_layer: u, dimensions: d, register_context: f } = PR(Kn);
  ph(r, c, (x) => t(15, i = x)), ph(r, u, (x) => t(3, n = x)), ph(r, d, (x) => t(10, s = x));
  const p = pR();
  let _ = [];
  f("layers", {
    init_fn: () => {
      y();
    },
    reset_fn: () => {
      p.reset();
    }
  });
  function m() {
    return o(this, void 0, void 0, function* () {
      _.some((E) => {
        var R, k;
        return ((R = E.composite.texture) === null || R === void 0 ? void 0 : R.width) != s[0] || ((k = E.composite.texture) === null || k === void 0 ? void 0 : k.height) != s[1];
      }) && (p.reset(), !l || l.length == 0 ? y() : v(l));
    });
  }
  function y() {
    return o(this, void 0, void 0, function* () {
      if (!i)
        return;
      const [x, E] = p.add_layer(i.layer_container, i.renderer, ...s);
      xo(u, n = x, n), t(2, _ = E);
    });
  }
  function v(x) {
    return o(this, void 0, void 0, function* () {
      if (yield mp(), !x || x.length == 0) {
        p.reset(), y();
        return;
      }
      if (!i)
        return;
      const E = yield Promise.all(x.map((O) => !O || !O.url ? null : fetch(O.url))), R = yield Promise.all(E.map((O) => O ? O.blob() : null));
      p.reset();
      let k = null;
      for (const O of R.filter(DR))
        k = yield p.add_layer_from_blob(i.layer_container, i.renderer, O, i.view);
      k && (xo(u, n = k[0], n), t(2, _ = k[1]));
    });
  }
  MR(() => o(void 0, void 0, void 0, function* () {
    yield mp(), i && xo(c, i = Object.assign(Object.assign({}, i), { get_layers: p.get_layers }), i);
  }));
  const g = (x) => x === n, b = () => t(1, a = !a), w = (x) => xo(u, n = p.change_active_layer(x), n), T = () => t(1, a = !1);
  return r.$$set = (x) => {
    "layer_files" in x && t(9, l = x.layer_files), "enable_layers" in x && t(0, h = x.enable_layers);
  }, r.$$.update = () => {
    r.$$.dirty & /*$dimensions*/
    1024 && m(), r.$$.dirty & /*layer_files*/
    512 && v(l);
  }, [
    h,
    a,
    _,
    n,
    c,
    u,
    d,
    p,
    y,
    l,
    s,
    g,
    b,
    w,
    T
  ];
}
class FR extends mR {
  constructor(e) {
    super(), TR(this, e, BR, kR, IR, { layer_files: 9, enable_layers: 0 });
  }
}
const {
  SvelteComponent: OR,
  add_iframe_resize_listener: LR,
  add_render_callback: NR,
  attr: UR,
  binding_callbacks: GR,
  check_outros: HR,
  component_subscribe: _h,
  create_component: U0,
  create_slot: zR,
  destroy_component: G0,
  detach: ba,
  element: XR,
  empty: H0,
  ensure_array_like: wp,
  get_all_dirty_from_scope: VR,
  get_slot_changes: WR,
  group_outros: jR,
  init: qR,
  insert: wa,
  mount_component: z0,
  outro_and_destroy_block: YR,
  safe_not_equal: KR,
  set_store_value: xp,
  space: ZR,
  transition_in: xa,
  transition_out: Ea,
  update_keyed_each: $R,
  update_slot_base: JR
} = window.__gradio__svelte__internal, { getContext: QR, setContext: eP } = window.__gradio__svelte__internal;
function Ep(r, e, t) {
  const i = r.slice();
  return i[21] = e[t], i;
}
function Tp(r, e) {
  let t, i, n;
  function s(...o) {
    return (
      /*click_handler*/
      e[12](
        /*tool*/
        e[21],
        ...o
      )
    );
  }
  return i = new Pi({
    props: {
      highlight: (
        /*$active_tool*/
        e[3] === /*tool*/
        e[21]
      ),
      Icon: (
        /*tools_meta*/
        e[7][
          /*tool*/
          e[21]
        ].icon
      ),
      size: "medium",
      padded: !1,
      label: (
        /*tools_meta*/
        e[7][
          /*tool*/
          e[21]
        ].label + " button"
      ),
      transparent: !0,
      offset: (
        /*tool*/
        e[21] === "draw" ? -2 : (
          /*tool*/
          e[21] === "erase" ? -6 : 0
        )
      )
    }
  }), i.$on("click", s), {
    key: r,
    first: null,
    c() {
      t = H0(), U0(i.$$.fragment), this.first = t;
    },
    m(o, a) {
      wa(o, t, a), z0(i, o, a), n = !0;
    },
    p(o, a) {
      e = o;
      const l = {};
      a & /*$active_tool, tools*/
      10 && (l.highlight = /*$active_tool*/
      e[3] === /*tool*/
      e[21]), a & /*tools*/
      2 && (l.Icon = /*tools_meta*/
      e[7][
        /*tool*/
        e[21]
      ].icon), a & /*tools*/
      2 && (l.label = /*tools_meta*/
      e[7][
        /*tool*/
        e[21]
      ].label + " button"), a & /*tools*/
      2 && (l.offset = /*tool*/
      e[21] === "draw" ? -2 : (
        /*tool*/
        e[21] === "erase" ? -6 : 0
      )), i.$set(l);
    },
    i(o) {
      n || (xa(i.$$.fragment, o), n = !0);
    },
    o(o) {
      Ea(i.$$.fragment, o), n = !1;
    },
    d(o) {
      o && ba(t), G0(i, o);
    }
  };
}
function tP(r) {
  let e = [], t = /* @__PURE__ */ new Map(), i, n, s = wp(
    /*tools*/
    r[1]
  );
  const o = (a) => (
    /*tool*/
    a[21]
  );
  for (let a = 0; a < s.length; a += 1) {
    let l = Ep(r, s, a), h = o(l);
    t.set(h, e[a] = Tp(h, l));
  }
  return {
    c() {
      for (let a = 0; a < e.length; a += 1)
        e[a].c();
      i = H0();
    },
    m(a, l) {
      for (let h = 0; h < e.length; h += 1)
        e[h] && e[h].m(a, l);
      wa(a, i, l), n = !0;
    },
    p(a, l) {
      l & /*$active_tool, tools, tools_meta, handle_click*/
      394 && (s = wp(
        /*tools*/
        a[1]
      ), jR(), e = $R(e, l, o, 1, a, s, t, i.parentNode, YR, Tp, i, Ep), HR());
    },
    i(a) {
      if (!n) {
        for (let l = 0; l < s.length; l += 1)
          xa(e[l]);
        n = !0;
      }
    },
    o(a) {
      for (let l = 0; l < e.length; l += 1)
        Ea(e[l]);
      n = !1;
    },
    d(a) {
      a && ba(i);
      for (let l = 0; l < e.length; l += 1)
        e[l].d(a);
    }
  };
}
function iP(r) {
  let e, t, i, n, s;
  const o = (
    /*#slots*/
    r[11].default
  ), a = zR(
    o,
    r,
    /*$$scope*/
    r[15],
    null
  );
  return i = new pb({
    props: {
      show_border: !1,
      $$slots: { default: [tP] },
      $$scope: { ctx: r }
    }
  }), {
    c() {
      a && a.c(), e = ZR(), t = XR("div"), U0(i.$$.fragment), UR(t, "class", "toolbar-wrap svelte-17ia0bq"), NR(() => (
        /*div_elementresize_handler*/
        r[13].call(t)
      ));
    },
    m(l, h) {
      a && a.m(l, h), wa(l, e, h), wa(l, t, h), z0(i, t, null), n = LR(
        t,
        /*div_elementresize_handler*/
        r[13].bind(t)
      ), r[14](t), s = !0;
    },
    p(l, [h]) {
      a && a.p && (!s || h & /*$$scope*/
      32768) && JR(
        a,
        o,
        l,
        /*$$scope*/
        l[15],
        s ? WR(
          o,
          /*$$scope*/
          l[15],
          h,
          null
        ) : VR(
          /*$$scope*/
          l[15]
        ),
        null
      );
      const c = {};
      h & /*$$scope, tools, $active_tool*/
      32778 && (c.$$scope = { dirty: h, ctx: l }), i.$set(c);
    },
    i(l) {
      s || (xa(a, l), xa(i.$$.fragment, l), s = !0);
    },
    o(l) {
      Ea(a, l), Ea(i.$$.fragment, l), s = !1;
    },
    d(l) {
      l && (ba(e), ba(t)), a && a.d(l), G0(i), n(), r[14](null);
    }
  };
}
const Ha = Symbol("tool");
function rP(r, e, t) {
  let i, n, s, { $$slots: o = {}, $$scope: a } = e;
  const { active_tool: l, toolbar_box: h, editor_box: c } = QR(Kn);
  _h(r, l, (E) => t(3, i = E)), _h(r, h, (E) => t(17, n = E)), _h(r, c, (E) => t(10, s = E));
  let { i18n: u } = e, d = [];
  const f = {}, _ = {
    current_color: rt("#000000"),
    register_tool: (E, R) => (t(1, d = [...d, E]), R != null && R.cb && (f[E] = R.cb), () => {
      t(1, d = d.filter((k) => k !== E));
    }),
    active_tool: {
      subscribe: l.subscribe,
      set: l.set
    }
  };
  eP(Ha, _);
  const m = {
    crop: {
      order: 1,
      label: u("Transform"),
      icon: py
    },
    draw: {
      order: 2,
      label: u("Draw"),
      icon: x1
    },
    erase: {
      order: 2,
      label: u("Erase"),
      icon: Oy
    },
    bg: {
      order: 0,
      label: u("Background"),
      icon: Bs
    }
  };
  let y, v;
  function g() {
    v && xp(h, n = v.getBoundingClientRect(), n);
  }
  function b(E, R) {
    E.stopPropagation(), xp(l, i = R, i), f[R] && f[R]();
  }
  const w = (E, R) => b(R, E);
  function T() {
    y = this.clientWidth, t(0, y);
  }
  function x(E) {
    GR[E ? "unshift" : "push"](() => {
      v = E, t(2, v);
    });
  }
  return r.$$set = (E) => {
    "i18n" in E && t(9, u = E.i18n), "$$scope" in E && t(15, a = E.$$scope);
  }, r.$$.update = () => {
    r.$$.dirty & /*toolbar_width, $editor_box*/
    1025 && g();
  }, [
    y,
    d,
    v,
    i,
    l,
    h,
    c,
    m,
    b,
    u,
    s,
    o,
    w,
    T,
    x,
    a
  ];
}
class nP extends OR {
  constructor(e) {
    super(), qR(this, e, rP, iP, KR, { i18n: 9 });
  }
}
function Ta(r) {
  "@babel/helpers - typeof";
  return Ta = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, Ta(r);
}
var sP = /^\s+/, oP = /\s+$/;
function ne(r, e) {
  if (r = r || "", e = e || {}, r instanceof ne)
    return r;
  if (!(this instanceof ne))
    return new ne(r, e);
  var t = aP(r);
  this._originalInput = r, this._r = t.r, this._g = t.g, this._b = t.b, this._a = t.a, this._roundA = Math.round(100 * this._a) / 100, this._format = e.format || t.format, this._gradientType = e.gradientType, this._r < 1 && (this._r = Math.round(this._r)), this._g < 1 && (this._g = Math.round(this._g)), this._b < 1 && (this._b = Math.round(this._b)), this._ok = t.ok;
}
ne.prototype = {
  isDark: function() {
    return this.getBrightness() < 128;
  },
  isLight: function() {
    return !this.isDark();
  },
  isValid: function() {
    return this._ok;
  },
  getOriginalInput: function() {
    return this._originalInput;
  },
  getFormat: function() {
    return this._format;
  },
  getAlpha: function() {
    return this._a;
  },
  getBrightness: function() {
    var e = this.toRgb();
    return (e.r * 299 + e.g * 587 + e.b * 114) / 1e3;
  },
  getLuminance: function() {
    var e = this.toRgb(), t, i, n, s, o, a;
    return t = e.r / 255, i = e.g / 255, n = e.b / 255, t <= 0.03928 ? s = t / 12.92 : s = Math.pow((t + 0.055) / 1.055, 2.4), i <= 0.03928 ? o = i / 12.92 : o = Math.pow((i + 0.055) / 1.055, 2.4), n <= 0.03928 ? a = n / 12.92 : a = Math.pow((n + 0.055) / 1.055, 2.4), 0.2126 * s + 0.7152 * o + 0.0722 * a;
  },
  setAlpha: function(e) {
    return this._a = X0(e), this._roundA = Math.round(100 * this._a) / 100, this;
  },
  toHsv: function() {
    var e = Sp(this._r, this._g, this._b);
    return {
      h: e.h * 360,
      s: e.s,
      v: e.v,
      a: this._a
    };
  },
  toHsvString: function() {
    var e = Sp(this._r, this._g, this._b), t = Math.round(e.h * 360), i = Math.round(e.s * 100), n = Math.round(e.v * 100);
    return this._a == 1 ? "hsv(" + t + ", " + i + "%, " + n + "%)" : "hsva(" + t + ", " + i + "%, " + n + "%, " + this._roundA + ")";
  },
  toHsl: function() {
    var e = Ap(this._r, this._g, this._b);
    return {
      h: e.h * 360,
      s: e.s,
      l: e.l,
      a: this._a
    };
  },
  toHslString: function() {
    var e = Ap(this._r, this._g, this._b), t = Math.round(e.h * 360), i = Math.round(e.s * 100), n = Math.round(e.l * 100);
    return this._a == 1 ? "hsl(" + t + ", " + i + "%, " + n + "%)" : "hsla(" + t + ", " + i + "%, " + n + "%, " + this._roundA + ")";
  },
  toHex: function(e) {
    return Cp(this._r, this._g, this._b, e);
  },
  toHexString: function(e) {
    return "#" + this.toHex(e);
  },
  toHex8: function(e) {
    return uP(this._r, this._g, this._b, this._a, e);
  },
  toHex8String: function(e) {
    return "#" + this.toHex8(e);
  },
  toRgb: function() {
    return {
      r: Math.round(this._r),
      g: Math.round(this._g),
      b: Math.round(this._b),
      a: this._a
    };
  },
  toRgbString: function() {
    return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
  },
  toPercentageRgb: function() {
    return {
      r: Math.round(Se(this._r, 255) * 100) + "%",
      g: Math.round(Se(this._g, 255) * 100) + "%",
      b: Math.round(Se(this._b, 255) * 100) + "%",
      a: this._a
    };
  },
  toPercentageRgbString: function() {
    return this._a == 1 ? "rgb(" + Math.round(Se(this._r, 255) * 100) + "%, " + Math.round(Se(this._g, 255) * 100) + "%, " + Math.round(Se(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(Se(this._r, 255) * 100) + "%, " + Math.round(Se(this._g, 255) * 100) + "%, " + Math.round(Se(this._b, 255) * 100) + "%, " + this._roundA + ")";
  },
  toName: function() {
    return this._a === 0 ? "transparent" : this._a < 1 ? !1 : EP[Cp(this._r, this._g, this._b, !0)] || !1;
  },
  toFilter: function(e) {
    var t = "#" + Ip(this._r, this._g, this._b, this._a), i = t, n = this._gradientType ? "GradientType = 1, " : "";
    if (e) {
      var s = ne(e);
      i = "#" + Ip(s._r, s._g, s._b, s._a);
    }
    return "progid:DXImageTransform.Microsoft.gradient(" + n + "startColorstr=" + t + ",endColorstr=" + i + ")";
  },
  toString: function(e) {
    var t = !!e;
    e = e || this._format;
    var i = !1, n = this._a < 1 && this._a >= 0, s = !t && n && (e === "hex" || e === "hex6" || e === "hex3" || e === "hex4" || e === "hex8" || e === "name");
    return s ? e === "name" && this._a === 0 ? this.toName() : this.toRgbString() : (e === "rgb" && (i = this.toRgbString()), e === "prgb" && (i = this.toPercentageRgbString()), (e === "hex" || e === "hex6") && (i = this.toHexString()), e === "hex3" && (i = this.toHexString(!0)), e === "hex4" && (i = this.toHex8String(!0)), e === "hex8" && (i = this.toHex8String()), e === "name" && (i = this.toName()), e === "hsl" && (i = this.toHslString()), e === "hsv" && (i = this.toHsvString()), i || this.toHexString());
  },
  clone: function() {
    return ne(this.toString());
  },
  _applyModification: function(e, t) {
    var i = e.apply(null, [this].concat([].slice.call(t)));
    return this._r = i._r, this._g = i._g, this._b = i._b, this.setAlpha(i._a), this;
  },
  lighten: function() {
    return this._applyModification(_P, arguments);
  },
  brighten: function() {
    return this._applyModification(mP, arguments);
  },
  darken: function() {
    return this._applyModification(gP, arguments);
  },
  desaturate: function() {
    return this._applyModification(dP, arguments);
  },
  saturate: function() {
    return this._applyModification(fP, arguments);
  },
  greyscale: function() {
    return this._applyModification(pP, arguments);
  },
  spin: function() {
    return this._applyModification(yP, arguments);
  },
  _applyCombination: function(e, t) {
    return e.apply(null, [this].concat([].slice.call(t)));
  },
  analogous: function() {
    return this._applyCombination(wP, arguments);
  },
  complement: function() {
    return this._applyCombination(vP, arguments);
  },
  monochromatic: function() {
    return this._applyCombination(xP, arguments);
  },
  splitcomplement: function() {
    return this._applyCombination(bP, arguments);
  },
  // Disabled until https://github.com/bgrins/TinyColor/issues/254
  // polyad: function (number) {
  //   return this._applyCombination(polyad, [number]);
  // },
  triad: function() {
    return this._applyCombination(Rp, [3]);
  },
  tetrad: function() {
    return this._applyCombination(Rp, [4]);
  }
};
ne.fromRatio = function(r, e) {
  if (Ta(r) == "object") {
    var t = {};
    for (var i in r)
      r.hasOwnProperty(i) && (i === "a" ? t[i] = r[i] : t[i] = _s(r[i]));
    r = t;
  }
  return ne(r, e);
};
function aP(r) {
  var e = {
    r: 0,
    g: 0,
    b: 0
  }, t = 1, i = null, n = null, s = null, o = !1, a = !1;
  return typeof r == "string" && (r = CP(r)), Ta(r) == "object" && (Ei(r.r) && Ei(r.g) && Ei(r.b) ? (e = lP(r.r, r.g, r.b), o = !0, a = String(r.r).substr(-1) === "%" ? "prgb" : "rgb") : Ei(r.h) && Ei(r.s) && Ei(r.v) ? (i = _s(r.s), n = _s(r.v), e = cP(r.h, i, n), o = !0, a = "hsv") : Ei(r.h) && Ei(r.s) && Ei(r.l) && (i = _s(r.s), s = _s(r.l), e = hP(r.h, i, s), o = !0, a = "hsl"), r.hasOwnProperty("a") && (t = r.a)), t = X0(t), {
    ok: o,
    format: r.format || a,
    r: Math.min(255, Math.max(e.r, 0)),
    g: Math.min(255, Math.max(e.g, 0)),
    b: Math.min(255, Math.max(e.b, 0)),
    a: t
  };
}
function lP(r, e, t) {
  return {
    r: Se(r, 255) * 255,
    g: Se(e, 255) * 255,
    b: Se(t, 255) * 255
  };
}
function Ap(r, e, t) {
  r = Se(r, 255), e = Se(e, 255), t = Se(t, 255);
  var i = Math.max(r, e, t), n = Math.min(r, e, t), s, o, a = (i + n) / 2;
  if (i == n)
    s = o = 0;
  else {
    var l = i - n;
    switch (o = a > 0.5 ? l / (2 - i - n) : l / (i + n), i) {
      case r:
        s = (e - t) / l + (e < t ? 6 : 0);
        break;
      case e:
        s = (t - r) / l + 2;
        break;
      case t:
        s = (r - e) / l + 4;
        break;
    }
    s /= 6;
  }
  return {
    h: s,
    s: o,
    l: a
  };
}
function hP(r, e, t) {
  var i, n, s;
  r = Se(r, 360), e = Se(e, 100), t = Se(t, 100);
  function o(h, c, u) {
    return u < 0 && (u += 1), u > 1 && (u -= 1), u < 1 / 6 ? h + (c - h) * 6 * u : u < 1 / 2 ? c : u < 2 / 3 ? h + (c - h) * (2 / 3 - u) * 6 : h;
  }
  if (e === 0)
    i = n = s = t;
  else {
    var a = t < 0.5 ? t * (1 + e) : t + e - t * e, l = 2 * t - a;
    i = o(l, a, r + 1 / 3), n = o(l, a, r), s = o(l, a, r - 1 / 3);
  }
  return {
    r: i * 255,
    g: n * 255,
    b: s * 255
  };
}
function Sp(r, e, t) {
  r = Se(r, 255), e = Se(e, 255), t = Se(t, 255);
  var i = Math.max(r, e, t), n = Math.min(r, e, t), s, o, a = i, l = i - n;
  if (o = i === 0 ? 0 : l / i, i == n)
    s = 0;
  else {
    switch (i) {
      case r:
        s = (e - t) / l + (e < t ? 6 : 0);
        break;
      case e:
        s = (t - r) / l + 2;
        break;
      case t:
        s = (r - e) / l + 4;
        break;
    }
    s /= 6;
  }
  return {
    h: s,
    s: o,
    v: a
  };
}
function cP(r, e, t) {
  r = Se(r, 360) * 6, e = Se(e, 100), t = Se(t, 100);
  var i = Math.floor(r), n = r - i, s = t * (1 - e), o = t * (1 - n * e), a = t * (1 - (1 - n) * e), l = i % 6, h = [t, o, s, s, a, t][l], c = [a, t, t, o, s, s][l], u = [s, s, a, t, t, o][l];
  return {
    r: h * 255,
    g: c * 255,
    b: u * 255
  };
}
function Cp(r, e, t, i) {
  var n = [Zt(Math.round(r).toString(16)), Zt(Math.round(e).toString(16)), Zt(Math.round(t).toString(16))];
  return i && n[0].charAt(0) == n[0].charAt(1) && n[1].charAt(0) == n[1].charAt(1) && n[2].charAt(0) == n[2].charAt(1) ? n[0].charAt(0) + n[1].charAt(0) + n[2].charAt(0) : n.join("");
}
function uP(r, e, t, i, n) {
  var s = [Zt(Math.round(r).toString(16)), Zt(Math.round(e).toString(16)), Zt(Math.round(t).toString(16)), Zt(V0(i))];
  return n && s[0].charAt(0) == s[0].charAt(1) && s[1].charAt(0) == s[1].charAt(1) && s[2].charAt(0) == s[2].charAt(1) && s[3].charAt(0) == s[3].charAt(1) ? s[0].charAt(0) + s[1].charAt(0) + s[2].charAt(0) + s[3].charAt(0) : s.join("");
}
function Ip(r, e, t, i) {
  var n = [Zt(V0(i)), Zt(Math.round(r).toString(16)), Zt(Math.round(e).toString(16)), Zt(Math.round(t).toString(16))];
  return n.join("");
}
ne.equals = function(r, e) {
  return !r || !e ? !1 : ne(r).toRgbString() == ne(e).toRgbString();
};
ne.random = function() {
  return ne.fromRatio({
    r: Math.random(),
    g: Math.random(),
    b: Math.random()
  });
};
function dP(r, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ne(r).toHsl();
  return t.s -= e / 100, t.s = za(t.s), ne(t);
}
function fP(r, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ne(r).toHsl();
  return t.s += e / 100, t.s = za(t.s), ne(t);
}
function pP(r) {
  return ne(r).desaturate(100);
}
function _P(r, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ne(r).toHsl();
  return t.l += e / 100, t.l = za(t.l), ne(t);
}
function mP(r, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ne(r).toRgb();
  return t.r = Math.max(0, Math.min(255, t.r - Math.round(255 * -(e / 100)))), t.g = Math.max(0, Math.min(255, t.g - Math.round(255 * -(e / 100)))), t.b = Math.max(0, Math.min(255, t.b - Math.round(255 * -(e / 100)))), ne(t);
}
function gP(r, e) {
  e = e === 0 ? 0 : e || 10;
  var t = ne(r).toHsl();
  return t.l -= e / 100, t.l = za(t.l), ne(t);
}
function yP(r, e) {
  var t = ne(r).toHsl(), i = (t.h + e) % 360;
  return t.h = i < 0 ? 360 + i : i, ne(t);
}
function vP(r) {
  var e = ne(r).toHsl();
  return e.h = (e.h + 180) % 360, ne(e);
}
function Rp(r, e) {
  if (isNaN(e) || e <= 0)
    throw new Error("Argument to polyad must be a positive number");
  for (var t = ne(r).toHsl(), i = [ne(r)], n = 360 / e, s = 1; s < e; s++)
    i.push(ne({
      h: (t.h + s * n) % 360,
      s: t.s,
      l: t.l
    }));
  return i;
}
function bP(r) {
  var e = ne(r).toHsl(), t = e.h;
  return [ne(r), ne({
    h: (t + 72) % 360,
    s: e.s,
    l: e.l
  }), ne({
    h: (t + 216) % 360,
    s: e.s,
    l: e.l
  })];
}
function wP(r, e, t) {
  e = e || 6, t = t || 30;
  var i = ne(r).toHsl(), n = 360 / t, s = [ne(r)];
  for (i.h = (i.h - (n * e >> 1) + 720) % 360; --e; )
    i.h = (i.h + n) % 360, s.push(ne(i));
  return s;
}
function xP(r, e) {
  e = e || 6;
  for (var t = ne(r).toHsv(), i = t.h, n = t.s, s = t.v, o = [], a = 1 / e; e--; )
    o.push(ne({
      h: i,
      s: n,
      v: s
    })), s = (s + a) % 1;
  return o;
}
ne.mix = function(r, e, t) {
  t = t === 0 ? 0 : t || 50;
  var i = ne(r).toRgb(), n = ne(e).toRgb(), s = t / 100, o = {
    r: (n.r - i.r) * s + i.r,
    g: (n.g - i.g) * s + i.g,
    b: (n.b - i.b) * s + i.b,
    a: (n.a - i.a) * s + i.a
  };
  return ne(o);
};
ne.readability = function(r, e) {
  var t = ne(r), i = ne(e);
  return (Math.max(t.getLuminance(), i.getLuminance()) + 0.05) / (Math.min(t.getLuminance(), i.getLuminance()) + 0.05);
};
ne.isReadable = function(r, e, t) {
  var i = ne.readability(r, e), n, s;
  switch (s = !1, n = IP(t), n.level + n.size) {
    case "AAsmall":
    case "AAAlarge":
      s = i >= 4.5;
      break;
    case "AAlarge":
      s = i >= 3;
      break;
    case "AAAsmall":
      s = i >= 7;
      break;
  }
  return s;
};
ne.mostReadable = function(r, e, t) {
  var i = null, n = 0, s, o, a, l;
  t = t || {}, o = t.includeFallbackColors, a = t.level, l = t.size;
  for (var h = 0; h < e.length; h++)
    s = ne.readability(r, e[h]), s > n && (n = s, i = ne(e[h]));
  return ne.isReadable(r, i, {
    level: a,
    size: l
  }) || !o ? i : (t.includeFallbackColors = !1, ne.mostReadable(r, ["#fff", "#000"], t));
};
var Lc = ne.names = {
  aliceblue: "f0f8ff",
  antiquewhite: "faebd7",
  aqua: "0ff",
  aquamarine: "7fffd4",
  azure: "f0ffff",
  beige: "f5f5dc",
  bisque: "ffe4c4",
  black: "000",
  blanchedalmond: "ffebcd",
  blue: "00f",
  blueviolet: "8a2be2",
  brown: "a52a2a",
  burlywood: "deb887",
  burntsienna: "ea7e5d",
  cadetblue: "5f9ea0",
  chartreuse: "7fff00",
  chocolate: "d2691e",
  coral: "ff7f50",
  cornflowerblue: "6495ed",
  cornsilk: "fff8dc",
  crimson: "dc143c",
  cyan: "0ff",
  darkblue: "00008b",
  darkcyan: "008b8b",
  darkgoldenrod: "b8860b",
  darkgray: "a9a9a9",
  darkgreen: "006400",
  darkgrey: "a9a9a9",
  darkkhaki: "bdb76b",
  darkmagenta: "8b008b",
  darkolivegreen: "556b2f",
  darkorange: "ff8c00",
  darkorchid: "9932cc",
  darkred: "8b0000",
  darksalmon: "e9967a",
  darkseagreen: "8fbc8f",
  darkslateblue: "483d8b",
  darkslategray: "2f4f4f",
  darkslategrey: "2f4f4f",
  darkturquoise: "00ced1",
  darkviolet: "9400d3",
  deeppink: "ff1493",
  deepskyblue: "00bfff",
  dimgray: "696969",
  dimgrey: "696969",
  dodgerblue: "1e90ff",
  firebrick: "b22222",
  floralwhite: "fffaf0",
  forestgreen: "228b22",
  fuchsia: "f0f",
  gainsboro: "dcdcdc",
  ghostwhite: "f8f8ff",
  gold: "ffd700",
  goldenrod: "daa520",
  gray: "808080",
  green: "008000",
  greenyellow: "adff2f",
  grey: "808080",
  honeydew: "f0fff0",
  hotpink: "ff69b4",
  indianred: "cd5c5c",
  indigo: "4b0082",
  ivory: "fffff0",
  khaki: "f0e68c",
  lavender: "e6e6fa",
  lavenderblush: "fff0f5",
  lawngreen: "7cfc00",
  lemonchiffon: "fffacd",
  lightblue: "add8e6",
  lightcoral: "f08080",
  lightcyan: "e0ffff",
  lightgoldenrodyellow: "fafad2",
  lightgray: "d3d3d3",
  lightgreen: "90ee90",
  lightgrey: "d3d3d3",
  lightpink: "ffb6c1",
  lightsalmon: "ffa07a",
  lightseagreen: "20b2aa",
  lightskyblue: "87cefa",
  lightslategray: "789",
  lightslategrey: "789",
  lightsteelblue: "b0c4de",
  lightyellow: "ffffe0",
  lime: "0f0",
  limegreen: "32cd32",
  linen: "faf0e6",
  magenta: "f0f",
  maroon: "800000",
  mediumaquamarine: "66cdaa",
  mediumblue: "0000cd",
  mediumorchid: "ba55d3",
  mediumpurple: "9370db",
  mediumseagreen: "3cb371",
  mediumslateblue: "7b68ee",
  mediumspringgreen: "00fa9a",
  mediumturquoise: "48d1cc",
  mediumvioletred: "c71585",
  midnightblue: "191970",
  mintcream: "f5fffa",
  mistyrose: "ffe4e1",
  moccasin: "ffe4b5",
  navajowhite: "ffdead",
  navy: "000080",
  oldlace: "fdf5e6",
  olive: "808000",
  olivedrab: "6b8e23",
  orange: "ffa500",
  orangered: "ff4500",
  orchid: "da70d6",
  palegoldenrod: "eee8aa",
  palegreen: "98fb98",
  paleturquoise: "afeeee",
  palevioletred: "db7093",
  papayawhip: "ffefd5",
  peachpuff: "ffdab9",
  peru: "cd853f",
  pink: "ffc0cb",
  plum: "dda0dd",
  powderblue: "b0e0e6",
  purple: "800080",
  rebeccapurple: "663399",
  red: "f00",
  rosybrown: "bc8f8f",
  royalblue: "4169e1",
  saddlebrown: "8b4513",
  salmon: "fa8072",
  sandybrown: "f4a460",
  seagreen: "2e8b57",
  seashell: "fff5ee",
  sienna: "a0522d",
  silver: "c0c0c0",
  skyblue: "87ceeb",
  slateblue: "6a5acd",
  slategray: "708090",
  slategrey: "708090",
  snow: "fffafa",
  springgreen: "00ff7f",
  steelblue: "4682b4",
  tan: "d2b48c",
  teal: "008080",
  thistle: "d8bfd8",
  tomato: "ff6347",
  turquoise: "40e0d0",
  violet: "ee82ee",
  wheat: "f5deb3",
  white: "fff",
  whitesmoke: "f5f5f5",
  yellow: "ff0",
  yellowgreen: "9acd32"
}, EP = ne.hexNames = TP(Lc);
function TP(r) {
  var e = {};
  for (var t in r)
    r.hasOwnProperty(t) && (e[r[t]] = t);
  return e;
}
function X0(r) {
  return r = parseFloat(r), (isNaN(r) || r < 0 || r > 1) && (r = 1), r;
}
function Se(r, e) {
  AP(r) && (r = "100%");
  var t = SP(r);
  return r = Math.min(e, Math.max(0, parseFloat(r))), t && (r = parseInt(r * e, 10) / 100), Math.abs(r - e) < 1e-6 ? 1 : r % e / parseFloat(e);
}
function za(r) {
  return Math.min(1, Math.max(0, r));
}
function gt(r) {
  return parseInt(r, 16);
}
function AP(r) {
  return typeof r == "string" && r.indexOf(".") != -1 && parseFloat(r) === 1;
}
function SP(r) {
  return typeof r == "string" && r.indexOf("%") != -1;
}
function Zt(r) {
  return r.length == 1 ? "0" + r : "" + r;
}
function _s(r) {
  return r <= 1 && (r = r * 100 + "%"), r;
}
function V0(r) {
  return Math.round(parseFloat(r) * 255).toString(16);
}
function Pp(r) {
  return gt(r) / 255;
}
var Wt = function() {
  var r = "[-\\+]?\\d+%?", e = "[-\\+]?\\d*\\.\\d+%?", t = "(?:" + e + ")|(?:" + r + ")", i = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?", n = "[\\s|\\(]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")[,|\\s]+(" + t + ")\\s*\\)?";
  return {
    CSS_UNIT: new RegExp(t),
    rgb: new RegExp("rgb" + i),
    rgba: new RegExp("rgba" + n),
    hsl: new RegExp("hsl" + i),
    hsla: new RegExp("hsla" + n),
    hsv: new RegExp("hsv" + i),
    hsva: new RegExp("hsva" + n),
    hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
    hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
    hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
  };
}();
function Ei(r) {
  return !!Wt.CSS_UNIT.exec(r);
}
function CP(r) {
  r = r.replace(sP, "").replace(oP, "").toLowerCase();
  var e = !1;
  if (Lc[r])
    r = Lc[r], e = !0;
  else if (r == "transparent")
    return {
      r: 0,
      g: 0,
      b: 0,
      a: 0,
      format: "name"
    };
  var t;
  return (t = Wt.rgb.exec(r)) ? {
    r: t[1],
    g: t[2],
    b: t[3]
  } : (t = Wt.rgba.exec(r)) ? {
    r: t[1],
    g: t[2],
    b: t[3],
    a: t[4]
  } : (t = Wt.hsl.exec(r)) ? {
    h: t[1],
    s: t[2],
    l: t[3]
  } : (t = Wt.hsla.exec(r)) ? {
    h: t[1],
    s: t[2],
    l: t[3],
    a: t[4]
  } : (t = Wt.hsv.exec(r)) ? {
    h: t[1],
    s: t[2],
    v: t[3]
  } : (t = Wt.hsva.exec(r)) ? {
    h: t[1],
    s: t[2],
    v: t[3],
    a: t[4]
  } : (t = Wt.hex8.exec(r)) ? {
    r: gt(t[1]),
    g: gt(t[2]),
    b: gt(t[3]),
    a: Pp(t[4]),
    format: e ? "name" : "hex8"
  } : (t = Wt.hex6.exec(r)) ? {
    r: gt(t[1]),
    g: gt(t[2]),
    b: gt(t[3]),
    format: e ? "name" : "hex"
  } : (t = Wt.hex4.exec(r)) ? {
    r: gt(t[1] + "" + t[1]),
    g: gt(t[2] + "" + t[2]),
    b: gt(t[3] + "" + t[3]),
    a: Pp(t[4] + "" + t[4]),
    format: e ? "name" : "hex8"
  } : (t = Wt.hex3.exec(r)) ? {
    r: gt(t[1] + "" + t[1]),
    g: gt(t[2] + "" + t[2]),
    b: gt(t[3] + "" + t[3]),
    format: e ? "name" : "hex"
  } : !1;
}
function IP(r) {
  var e, t;
  return r = r || {
    level: "AA",
    size: "small"
  }, e = (r.level || "AA").toUpperCase(), t = (r.size || "small").toLowerCase(), e !== "AA" && e !== "AAA" && (e = "AA"), t !== "small" && t !== "large" && (t = "small"), {
    level: e,
    size: t
  };
}
function mh(r, e, t, i = new be("black"), n) {
  const s = new be(i);
  r.beginFill(s), r.drawCircle(e, t, n), r.endFill();
}
function RP(r, e) {
  let t = [];
  const i = e.x - r.x, n = e.y - r.y, s = Math.sqrt(i * i + n * n), o = Math.ceil(s / 2), a = i / o, l = n / o;
  for (let h = 0; h < o; h++) {
    const c = r.x + h * a, u = r.y + h * l;
    t.push({ x: c, y: u });
  }
  return t;
}
function PP(r, e, t, i) {
  const n = [];
  let s, o, a, l = !1, h = 0;
  return {
    drawing: !1,
    start: function({
      x: c,
      y: u,
      size: d,
      color: f = new be("black"),
      opacity: p,
      set_initial_texture: _ = !0
    }) {
      _ && (a = et.create({
        width: t.draw_texture.width,
        height: t.draw_texture.height
      }), r.render(t.composite, {
        renderTexture: a
      })), s = { x: c, y: u, size: d, color: f, opacity: p }, n.push({ x: c, y: u }), o = F0(h++), mh(o, c, u, f, d), r.render(o, {
        renderTexture: i === "draw" ? t.draw_texture : t.erase_texture,
        clear: !1
      }), this.drawing = !0;
    },
    continue: function({ x: c, y: u }) {
      const d = n[n.length - 1], f = RP(d, { x: c, y: u });
      for (let p = 0; p < f.length; p++) {
        const { x: _, y: m } = f[p];
        mh(o, _, m, s.color, s.size), n.push({ x: _, y: m });
      }
      r.render(o, {
        renderTexture: i === "draw" ? t.draw_texture : t.erase_texture,
        clear: !1
      }), o.clear();
    },
    stop: function() {
      const c = et.create({
        width: t.draw_texture.width,
        height: t.draw_texture.height
      });
      r.render(t.composite, {
        renderTexture: c
      }), r.render(new st(c), {
        renderTexture: t.draw_texture
      });
      const u = new Xr().beginFill(0, 0).drawRect(0, 0, t.erase_texture.width, t.erase_texture.height).endFill();
      r.render(u, {
        renderTexture: t.erase_texture,
        clear: !0
      }), l = !0, this.drawing = !1;
    },
    execute: function() {
      if (!l) {
        for (let c = 1; c < n.length; c++) {
          const { x: u, y: d } = n[c];
          mh(o, u, d, s.color, s.size);
        }
        r.render(o, {
          renderTexture: i === "draw" ? t.draw_texture : t.erase_texture,
          clear: !1
        }), this.stop();
      }
    },
    undo: function() {
      const c = new Xr().beginFill(0, 0).drawRect(0, 0, t.erase_texture.width, t.erase_texture.height).endFill();
      r.render(new st(a), {
        renderTexture: t.draw_texture
      }), r.render(c, {
        renderTexture: t.erase_texture,
        clear: !0
      }), this.stop(), l = !1;
    }
  };
}
const {
  SvelteComponent: MP,
  attr: kP,
  component_subscribe: ln,
  detach: DP,
  element: BP,
  init: FP,
  insert: OP,
  noop: Mp,
  safe_not_equal: LP,
  set_style: St
} = window.__gradio__svelte__internal, { getContext: kp, onMount: NP } = window.__gradio__svelte__internal;
function UP(r) {
  let e, t = `translate(${/*pos*/
  r[2].x}px, ${/*pos*/
  r[2].y}px)`, i = `${/*$editor_box*/
  r[0].child_top - /*$editor_box*/
  r[0].parent_top - /*brush_size*/
  r[3] / 2}px`, n = `${/*$editor_box*/
  r[0].child_left - /*$editor_box*/
  r[0].parent_left - /*brush_size*/
  r[3] / 2}px`, s = `${/*brush_size*/
  r[3]}px`, o = `${/*brush_size*/
  r[3]}px`;
  return {
    c() {
      e = BP("span"), kP(e, "class", "svelte-ttvlml"), St(e, "transform", t), St(e, "top", i), St(e, "left", n), St(e, "width", s), St(e, "height", o), St(
        e,
        "opacity",
        /*brush_cursor*/
        r[1] ? 1 : 0
      );
    },
    m(a, l) {
      OP(a, e, l);
    },
    p(a, l) {
      l[0] & /*pos*/
      4 && t !== (t = `translate(${/*pos*/
      a[2].x}px, ${/*pos*/
      a[2].y}px)`) && St(e, "transform", t), l[0] & /*$editor_box, brush_size*/
      9 && i !== (i = `${/*$editor_box*/
      a[0].child_top - /*$editor_box*/
      a[0].parent_top - /*brush_size*/
      a[3] / 2}px`) && St(e, "top", i), l[0] & /*$editor_box, brush_size*/
      9 && n !== (n = `${/*$editor_box*/
      a[0].child_left - /*$editor_box*/
      a[0].parent_left - /*brush_size*/
      a[3] / 2}px`) && St(e, "left", n), l[0] & /*brush_size*/
      8 && s !== (s = `${/*brush_size*/
      a[3]}px`) && St(e, "width", s), l[0] & /*brush_size*/
      8 && o !== (o = `${/*brush_size*/
      a[3]}px`) && St(e, "height", o), l[0] & /*brush_cursor*/
      2 && St(
        e,
        "opacity",
        /*brush_cursor*/
        a[1] ? 1 : 0
      );
    },
    i: Mp,
    o: Mp,
    d(a) {
      a && DP(e);
    }
  };
}
function GP(r, e, t) {
  let i, n, s, o, a, l, h;
  var c = this && this.__awaiter || function(P, ie, A, X) {
    function te(j) {
      return j instanceof A ? j : new A(function(W) {
        W(j);
      });
    }
    return new (A || (A = Promise))(function(j, W) {
      function se(de) {
        try {
          _e(X.next(de));
        } catch (xe) {
          W(xe);
        }
      }
      function ue(de) {
        try {
          _e(X.throw(de));
        } catch (xe) {
          W(xe);
        }
      }
      function _e(de) {
        de.done ? j(de.value) : te(de.value).then(se, ue);
      }
      _e((X = X.apply(P, ie || [])).next());
    });
  };
  let { default_size: u } = e, { default_color: d = void 0 } = e, { colors: f = void 0 } = e, { color_mode: p = void 0 } = e, { mode: _ } = e;
  const m = f ? f.map(z).filter((P, ie) => ie < 4) : [];
  let y = d === "auto" ? m[0] : d ? z(d) : "black";
  const { pixi: v, dimensions: g, current_layer: b, command_manager: w, register_context: T, editor_box: x, crop: E, toolbar_box: R } = kp(Kn);
  ln(r, v, (P) => t(18, o = P)), ln(r, g, (P) => t(15, s = P)), ln(r, b, (P) => t(21, h = P)), ln(r, x, (P) => t(0, n = P)), ln(r, E, (P) => t(20, l = P));
  const { active_tool: k, register_tool: O, current_color: B } = kp(Ha);
  ln(r, k, (P) => t(19, a = P));
  let C = !1, M;
  function F(P, ie) {
    const A = Vt(Math.min(P, ie), 500, 1e3);
    return Math.round(A * 2 / 100);
  }
  let U = u === "auto" ? F(...s) : u;
  function L(P) {
    a === _ && (C = !0, !(!o || !h) && (M = PP(o.renderer, o.layer_container, h, _), M.start({
      x: P.screen.x,
      y: P.screen.y,
      color: y || void 0,
      size: U,
      opacity: 1
    })));
  }
  function D(P) {
    !o || !h || a === _ && (M.stop(), w.execute(M), C = !1);
  }
  function N(P) {
    if (a !== _)
      return;
    C && M.continue({ x: P.screen.x, y: P.screen.y });
    const ie = l[0] * s[0], A = l[1] * s[1];
    ie > P.screen.x || A > P.screen.y || P.screen.x > ie + l[2] * s[0] || P.screen.y > A + l[3] * s[1] ? (t(1, I = !1), document.body.style.cursor = "auto") : (t(1, I = !0), document.body.style.cursor = "none"), I && t(2, V = {
      x: P.clientX - n.child_left,
      y: P.clientY - n.child_top
    });
  }
  let I = !1;
  function S(P) {
    return c(this, void 0, void 0, function* () {
      o == null || o.layer_container[P]("pointerdown", L), o == null || o.layer_container[P]("pointerup", D), o == null || o.layer_container[P]("pointermove", N), o == null || o.layer_container[P]("pointerenter", (ie) => {
        a === _ && (t(1, I = !0), document.body.style.cursor = "none");
      }), o == null || o.layer_container[P]("pointerleave", () => (t(1, I = !1), document.body.style.cursor = "auto"));
    });
  }
  T(_, {
    init_fn: () => {
      S("on");
    },
    reset_fn: () => {
      S("off");
    }
  }), NP(() => {
    const P = O(_, { cb: $ });
    return () => {
      P(), S("off");
    };
  });
  function z(P) {
    return ne(P).toRgbString();
  }
  let V = { x: 0, y: 0 };
  const $ = () => {
  };
  return r.$$set = (P) => {
    "default_size" in P && t(10, u = P.default_size), "default_color" in P && t(11, d = P.default_color), "colors" in P && t(12, f = P.colors), "color_mode" in P && t(13, p = P.color_mode), "mode" in P && t(14, _ = P.mode);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*mode*/
    16384 && _ === "draw" && B.set(y), r.$$.dirty[0] & /*$dimensions, $editor_box*/
    32769 && t(3, i = U / s[0] * n.child_width * 2);
  }, [
    n,
    I,
    V,
    i,
    v,
    g,
    b,
    x,
    E,
    k,
    u,
    d,
    f,
    p,
    _,
    s
  ];
}
class W0 extends MP {
  constructor(e) {
    super(), FP(
      this,
      e,
      GP,
      UP,
      LP,
      {
        default_size: 10,
        default_color: 11,
        colors: 12,
        color_mode: 13,
        mode: 14
      },
      null,
      [-1, -1]
    );
  }
}
function Dp(r, e, t, i = 0) {
  let n, s;
  const o = new Xr();
  let a, l, h, c, u = Ko(i, {
    stiffness: 0.1,
    damping: 0.5
  }), d = i;
  u.subscribe((m) => {
    l && (d = m, f(h, c, l, !0));
  });
  function f(m, y, v, g) {
    o.clear(), g && (o.beginFill(16777215, d), o.drawRect(0, 0, m, y), o.endFill()), o.beginFill(16777215, 1), o.drawRect(...v), o.endFill(), r.render(o, {
      renderTexture: n
    });
  }
  let p = !0, _ = !1;
  return {
    start: (m, y, v, g = !0, b = !0) => {
      p = !1, n = et.create({
        width: m,
        height: y
      }), f(m, y, v, g), s = new st(n), e.mask = s, h = m, c = y, b && (a = JSON.parse(JSON.stringify(v)));
    },
    continue: (m, y = !0) => {
      l = JSON.parse(JSON.stringify(m)), d === 0.2 ? f(h, c, l, y) : u.set(0.2);
    },
    undo() {
      this.start(h, c, a, !1), t.set([
        a[0] / h,
        a[1] / c,
        a[2] / h,
        a[3] / c
      ]), p = !0;
    },
    stop() {
      return _ = !0, d;
    },
    execute() {
      p ? (this.start(h, c, l, !1), t.set([
        l[0] / h,
        l[1] / c,
        l[2] / h,
        l[3] / c
      ]), p = !0) : (_ || u.set(0), t.set([
        l[0] / h,
        l[1] / c,
        l[2] / h,
        l[3] / c
      ]), p = !0);
    }
  };
}
function j0(r, e, t, i, n, s) {
  let o = r, a = e;
  (t.includes("t") || t.includes("b") || t == "c") && (o = e * i), (t.includes("l") || t.includes("r") || t == "c") && (a = r / i), a = a || o / i, o = o || a * i, o > n && (o = n, a = o / i), a > s && (a = s, o = a * i);
  let l = 0, h = 0;
  return t.includes("r") ? l = r - o : t.includes("l") ? l = 0 : l = (r - o) / 2, t.includes("b") ? h = e - a : t.includes("t") ? h = 0 : h = (e - a) / 2, {
    new_width: o,
    new_height: a,
    x_offset: l,
    y_offset: h
  };
}
const {
  SvelteComponent: HP,
  append: zP,
  attr: Eo,
  binding_callbacks: XP,
  detach: VP,
  element: Bp,
  init: WP,
  insert: jP,
  listen: gh,
  noop: Fp,
  run_all: qP,
  safe_not_equal: YP,
  set_style: Op
} = window.__gradio__svelte__internal, { tick: KP, createEventDispatcher: ZP } = window.__gradio__svelte__internal;
function $P(r) {
  let e, t, i, n, s, o;
  return {
    c() {
      e = Bp("div"), t = Bp("div"), Eo(t, "class", i = "handle " + /*type*/
      r[0] + " " + /*location*/
      r[1] + " svelte-1vxqlwv"), Eo(e, "class", n = "hitbox " + /*location*/
      r[1] + " svelte-1vxqlwv"), Op(
        e,
        "transform",
        /*transform*/
        r[3]
      );
    },
    m(a, l) {
      jP(a, e, l), zP(e, t), r[12](t), s || (o = [
        gh(
          window,
          "mousemove",
          /*handle_mousemove*/
          r[5]
        ),
        gh(
          window,
          "mouseup",
          /*handle_mouseup*/
          r[6]
        ),
        gh(
          e,
          "mousedown",
          /*handle_mousedown*/
          r[4]
        )
      ], s = !0);
    },
    p(a, [l]) {
      l & /*type, location*/
      3 && i !== (i = "handle " + /*type*/
      a[0] + " " + /*location*/
      a[1] + " svelte-1vxqlwv") && Eo(t, "class", i), l & /*location*/
      2 && n !== (n = "hitbox " + /*location*/
      a[1] + " svelte-1vxqlwv") && Eo(e, "class", n), l & /*transform*/
      8 && Op(
        e,
        "transform",
        /*transform*/
        a[3]
      );
    },
    i: Fp,
    o: Fp,
    d(a) {
      a && VP(e), r[12](null), s = !1, qP(o);
    }
  };
}
function JP(r, e, t) {
  let i;
  var n = this && this.__awaiter || function(x, E, R, k) {
    function O(B) {
      return B instanceof R ? B : new R(function(C) {
        C(B);
      });
    }
    return new (R || (R = Promise))(function(B, C) {
      function M(L) {
        try {
          U(k.next(L));
        } catch (D) {
          C(D);
        }
      }
      function F(L) {
        try {
          U(k.throw(L));
        } catch (D) {
          C(D);
        }
      }
      function U(L) {
        L.done ? B(L.value) : O(L.value).then(M, F);
      }
      U((k = k.apply(x, E || [])).next());
    });
  };
  let { type: s = "corner" } = e, { location: o } = e, { x1: a = 0 } = e, { y1: l = 0 } = e, { x2: h = 0 } = e, { y2: c = 0 } = e, u, d = 0, f = 0, p = !1;
  const _ = ZP();
  let { dragging: m = !1 } = e, y;
  function v(x) {
    u = y.getBoundingClientRect(), p = !0, t(11, m = !0), ["tl", "bl", "l"].includes(o) && (f = x.clientX - u.right), ["tl", "tr", "t"].includes(o) && (d = x.clientY - u.bottom), ["tr", "r", "br"].includes(o) && (f = x.clientX - u.left), ["br", "b", "bl"].includes(o) && (d = x.clientY - u.top);
  }
  function g(x) {
    if (!p)
      return;
    const E = x.clientY - d, R = x.clientY - d, k = x.clientX - f, O = x.clientX - f;
    ["tl", "bl", "l"].includes(o) && t(7, a = k), ["tl", "tr", "t"].includes(o) && t(8, l = E), ["tr", "r", "br"].includes(o) && t(9, h = O), ["br", "b", "bl"].includes(o) && t(10, c = R);
  }
  function b(x) {
    return n(this, void 0, void 0, function* () {
      yield KP(), p = !1, t(11, m = !1);
    });
  }
  function w(x, E, R, k, O) {
    let B, C, M, F;
    return u && (["tl", "l", "bl"].includes(x) && (C = E), ["tl", "t", "tr"].includes(x) && (B = k), ["tr", "r", "br"].includes(x) && (M = R), ["br", "b", "bl"].includes(x) && (F = O)), _("change", { top: B, bottom: F, left: C, right: M }), "";
  }
  function T(x) {
    XP[x ? "unshift" : "push"](() => {
      y = x, t(2, y);
    });
  }
  return r.$$set = (x) => {
    "type" in x && t(0, s = x.type), "location" in x && t(1, o = x.location), "x1" in x && t(7, a = x.x1), "y1" in x && t(8, l = x.y1), "x2" in x && t(9, h = x.x2), "y2" in x && t(10, c = x.y2), "dragging" in x && t(11, m = x.dragging);
  }, r.$$.update = () => {
    r.$$.dirty & /*location, x1, x2, y1, y2*/
    1922 && t(3, i = w(o, a, h, l, c));
  }, [
    s,
    o,
    y,
    i,
    v,
    g,
    b,
    a,
    l,
    h,
    c,
    m,
    T
  ];
}
class QP extends HP {
  constructor(e) {
    super(), WP(this, e, JP, $P, YP, {
      type: 0,
      location: 1,
      x1: 7,
      y1: 8,
      x2: 9,
      y2: 10,
      dragging: 11
    });
  }
}
const {
  SvelteComponent: eM,
  add_flush_callback: tM,
  append: yh,
  attr: zo,
  bind: iM,
  binding_callbacks: rM,
  check_outros: nM,
  create_component: sM,
  destroy_component: oM,
  destroy_each: Lp,
  detach: q0,
  element: Xo,
  ensure_array_like: vh,
  group_outros: aM,
  init: lM,
  insert: Y0,
  listen: bh,
  mount_component: hM,
  noop: K0,
  run_all: cM,
  safe_not_equal: uM,
  set_style: zi,
  space: dM,
  subscribe: fM,
  toggle_class: Np,
  transition_in: Vo,
  transition_out: Nc
} = window.__gradio__svelte__internal, { createEventDispatcher: pM } = window.__gradio__svelte__internal;
function _M(r, e, t) {
  const i = r.slice();
  return i[30] = e[t], i;
}
function Up(r, e, t) {
  const i = r.slice();
  return i[33] = e[t], i;
}
function Gp(r) {
  let e, t, i;
  function n(a) {
    r[20](a);
  }
  function s(...a) {
    return (
      /*change_handler*/
      r[21](
        /*position*/
        r[33],
        ...a
      )
    );
  }
  let o = { location: (
    /*position*/
    r[33]
  ) };
  return (
    /*dragging*/
    r[1] !== void 0 && (o.dragging = /*dragging*/
    r[1]), e = new QP({ props: o }), rM.push(() => iM(e, "dragging", n)), e.$on("change", s), {
      c() {
        sM(e.$$.fragment);
      },
      m(a, l) {
        hM(e, a, l), i = !0;
      },
      p(a, l) {
        r = a;
        const h = {};
        !t && l[0] & /*dragging*/
        2 && (t = !0, h.dragging = /*dragging*/
        r[1], tM(() => t = !1)), e.$set(h);
      },
      i(a) {
        i || (Vo(e.$$.fragment, a), i = !0);
      },
      o(a) {
        Nc(e.$$.fragment, a), i = !1;
      },
      d(a) {
        oM(e, a);
      }
    }
  );
}
function mM(r) {
  let e;
  return {
    c() {
      e = Xo("div"), zo(e, "class", "svelte-8bcx94");
    },
    m(t, i) {
      Y0(t, e, i);
    },
    p: K0,
    d(t) {
      t && q0(e);
    }
  };
}
function gM(r) {
  let e, t, i, n, s = `${/*_width*/
  r[3]}px`, o = `${/*_height*/
  r[2]}px`, a = `${/*_top*/
  r[4]}px`, l = `${/*_left*/
  r[5]}px`, h, c, u, d = vh(
    /*positions*/
    r[7]
  ), f = [];
  for (let y = 0; y < d.length; y += 1)
    f[y] = Gp(Up(r, d, y));
  const p = (y) => Nc(f[y], 1, 1, () => {
    f[y] = null;
  });
  let _ = vh({ length: 25 }), m = [];
  for (let y = 0; y < _.length; y += 1)
    m[y] = mM(_M(r, _, y));
  return {
    c() {
      e = Xo("div"), t = Xo("div");
      for (let y = 0; y < f.length; y += 1)
        f[y].c();
      i = dM(), n = Xo("div");
      for (let y = 0; y < m.length; y += 1)
        m[y].c();
      zo(n, "class", "grid svelte-8bcx94"), Np(
        n,
        "finished",
        /*finished*/
        r[6]
      ), zo(t, "class", "box svelte-8bcx94"), zi(t, "width", s), zi(t, "height", o), zi(t, "top", a), zi(t, "left", l), zo(e, "class", "wrap svelte-8bcx94");
    },
    m(y, v) {
      Y0(y, e, v), yh(e, t);
      for (let g = 0; g < f.length; g += 1)
        f[g] && f[g].m(t, null);
      yh(t, i), yh(t, n);
      for (let g = 0; g < m.length; g += 1)
        m[g] && m[g].m(n, null);
      h = !0, c || (u = [
        bh(
          window,
          "mousemove",
          /*handle_dragging*/
          r[11]
        ),
        bh(
          window,
          "mouseup",
          /*handle_drag_end*/
          r[10]
        ),
        bh(
          n,
          "mousedown",
          /*handle_drag_start*/
          r[9]
        )
      ], c = !0);
    },
    p(y, v) {
      if (v[0] & /*positions, dragging, handle_change*/
      386) {
        d = vh(
          /*positions*/
          y[7]
        );
        let g;
        for (g = 0; g < d.length; g += 1) {
          const b = Up(y, d, g);
          f[g] ? (f[g].p(b, v), Vo(f[g], 1)) : (f[g] = Gp(b), f[g].c(), Vo(f[g], 1), f[g].m(t, i));
        }
        for (aM(), g = d.length; g < f.length; g += 1)
          p(g);
        nM();
      }
      (!h || v[0] & /*finished*/
      64) && Np(
        n,
        "finished",
        /*finished*/
        y[6]
      ), v[0] & /*_width*/
      8 && s !== (s = `${/*_width*/
      y[3]}px`) && zi(t, "width", s), v[0] & /*_height*/
      4 && o !== (o = `${/*_height*/
      y[2]}px`) && zi(t, "height", o), v[0] & /*_top*/
      16 && a !== (a = `${/*_top*/
      y[4]}px`) && zi(t, "top", a), v[0] & /*_left*/
      32 && l !== (l = `${/*_left*/
      y[5]}px`) && zi(t, "left", l);
    },
    i(y) {
      if (!h) {
        for (let v = 0; v < d.length; v += 1)
          Vo(f[v]);
        h = !0;
      }
    },
    o(y) {
      f = f.filter(Boolean);
      for (let v = 0; v < f.length; v += 1)
        Nc(f[v]);
      h = !1;
    },
    d(y) {
      y && q0(e), Lp(f, y), Lp(m, y), c = !1, cM(u);
    }
  };
}
function yM(r, e, t) {
  let i, n = K0, s = () => (n(), n = fM(o, (N) => t(19, i = N)), o);
  r.$$.on_destroy.push(() => n());
  let { editor_box: o } = e;
  s();
  let { crop_constraint: a } = e;
  const l = pM();
  let h = i.child_height, c = i.child_width, u = i.child_top - i.parent_top, d = i.child_left - i.parent_left, f = i.child_right - i.parent_left, p = 0, _ = !1, { w_p: m } = e, { h_p: y } = e, { l_p: v } = e, { t_p: g } = e;
  const b = ["tl", "br", "tr", "bl", "t", "b", "l", "r"];
  let w, T, x = !1;
  function E() {
    T && clearTimeout(T), t(17, T = setTimeout(
      () => {
        x && (l("crop_end", { x: v, y: g, width: m, height: y }), x = !1), t(6, w = !0), t(18, C = !1);
      },
      1e3
    ));
  }
  function R({ top: N, bottom: I, left: S, right: z }, V) {
    t(4, u = Vt(N ? N - i.parent_top : u, i.child_top - i.parent_top, i.child_bottom - i.parent_top)), t(5, d = Vt(S ? S - i.parent_left : d, i.child_left - i.parent_left, i.child_right - i.parent_left)), f = Vt(z ? z - i.parent_left : f, i.child_left - i.parent_left, i.child_right - i.parent_left), p = Vt(I ? I - i.parent_top : p, i.child_top - i.parent_top, i.child_bottom - i.parent_top), t(3, c = Vt(z ? z - d - i.parent_left : c, 0, f - d)), t(3, c = Vt(S ? f - S + i.parent_left : c, 0, f - d)), t(2, h = Vt(
      I ? I - u - i.parent_top : h,
      0,
      p - u
    )), t(2, h = Vt(N ? p - N + i.parent_top : h, 0, p - u));
    const $ = {
      tl: "br",
      tr: "bl",
      bl: "tr",
      br: "tl",
      t: "b",
      b: "t",
      l: "r",
      r: "l",
      c: "c"
    };
    if (a) {
      const P = ["t", "b"].includes(V) ? i.child_width : f - d, ie = ["l", "r"].includes(V) ? i.child_height : p - u;
      let A = j0(c, h, $[V], a, P, ie);
      t(3, c = A.new_width), t(2, h = A.new_height), t(5, d = d + A.x_offset), t(4, u = u + A.y_offset), f = d + c, p = u + h;
    }
    t(12, m = c / i.child_width), t(13, y = h / i.child_height), t(14, v = (d - i.child_left + i.parent_left) / i.child_width), t(15, g = (u - i.child_top + i.parent_top) / i.child_height), l(x ? "crop_continue" : "crop_start", { x: v, y: g, width: m, height: y }), x = !0;
  }
  function k() {
    t(3, c = m * i.child_width), t(2, h = y * i.child_height), t(5, d = v * i.child_width + (i.child_left - i.parent_left)), t(4, u = g * i.child_height + (i.child_top - i.parent_top)), f = d + c, p = u + h;
  }
  let O = 0, B = 0, C = !1;
  function M(N) {
    t(18, C = !0), O = N.clientX, B = N.clientY, w && (t(6, w = !1), l("crop_start", { x: v, y: g, width: m, height: y }));
  }
  function F(N) {
    C && t(18, C = !1);
  }
  function U(N) {
    if (!C)
      return;
    const I = N.clientX - O, S = N.clientY - B;
    t(5, d = Vt(d + I, i.child_left - i.parent_left, i.child_right - i.parent_left - c)), t(4, u = Vt(u + S, i.child_top - i.parent_top, i.child_bottom - i.parent_top - h)), f = d + c, p = u + h, t(14, v = (d - i.child_left + i.parent_left) / i.child_width), t(15, g = (u - i.child_top + i.parent_top) / i.child_height), O = N.clientX, B = N.clientY, l("crop_continue", { x: v, y: g, width: m, height: y }), x = !0;
  }
  function L(N) {
    _ = N, t(1, _);
  }
  const D = (N, { detail: I }) => R(I, N);
  return r.$$set = (N) => {
    "editor_box" in N && s(t(0, o = N.editor_box)), "crop_constraint" in N && t(16, a = N.crop_constraint), "w_p" in N && t(12, m = N.w_p), "h_p" in N && t(13, y = N.h_p), "l_p" in N && t(14, v = N.l_p), "t_p" in N && t(15, g = N.t_p);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*dragging, position_drag, timer*/
    393218 && (_ || C ? (clearTimeout(T), t(6, w = !1)) : E()), r.$$.dirty[0] & /*$editor_box*/
    524288 && i && k();
  }, [
    o,
    _,
    h,
    c,
    u,
    d,
    w,
    b,
    R,
    M,
    F,
    U,
    m,
    y,
    v,
    g,
    a,
    T,
    C,
    i,
    L,
    D
  ];
}
class vM extends eM {
  constructor(e) {
    super(), lM(
      this,
      e,
      yM,
      gM,
      uM,
      {
        editor_box: 0,
        crop_constraint: 16,
        w_p: 12,
        h_p: 13,
        l_p: 14,
        t_p: 15
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: bM,
  check_outros: wM,
  component_subscribe: hn,
  create_component: xM,
  destroy_component: EM,
  detach: TM,
  empty: AM,
  group_outros: SM,
  init: CM,
  insert: IM,
  mount_component: RM,
  safe_not_equal: PM,
  transition_in: Wo,
  transition_out: Uc
} = window.__gradio__svelte__internal, { getContext: Hp, onMount: MM } = window.__gradio__svelte__internal;
function zp(r) {
  let e, t;
  return e = new vM({
    props: {
      crop_constraint: (
        /*_crop_constraint*/
        r[0]
      ),
      w_p: (
        /*w_p*/
        r[1]
      ),
      h_p: (
        /*h_p*/
        r[2]
      ),
      l_p: (
        /*l_p*/
        r[3]
      ),
      t_p: (
        /*t_p*/
        r[4]
      ),
      editor_box: (
        /*editor_box*/
        r[9]
      )
    }
  }), e.$on(
    "crop_start",
    /*crop_start_handler*/
    r[20]
  ), e.$on(
    "crop_continue",
    /*crop_continue_handler*/
    r[21]
  ), e.$on(
    "crop_end",
    /*crop_end_handler*/
    r[22]
  ), {
    c() {
      xM(e.$$.fragment);
    },
    m(i, n) {
      RM(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*_crop_constraint*/
      1 && (s.crop_constraint = /*_crop_constraint*/
      i[0]), n[0] & /*w_p*/
      2 && (s.w_p = /*w_p*/
      i[1]), n[0] & /*h_p*/
      4 && (s.h_p = /*h_p*/
      i[2]), n[0] & /*l_p*/
      8 && (s.l_p = /*l_p*/
      i[3]), n[0] & /*t_p*/
      16 && (s.t_p = /*t_p*/
      i[4]), e.$set(s);
    },
    i(i) {
      t || (Wo(e.$$.fragment, i), t = !0);
    },
    o(i) {
      Uc(e.$$.fragment, i), t = !1;
    },
    d(i) {
      EM(e, i);
    }
  };
}
function kM(r) {
  let e, t, i = (
    /*$active_tool*/
    r[5] === "crop" && /*measured*/
    r[6] && zp(r)
  );
  return {
    c() {
      i && i.c(), e = AM();
    },
    m(n, s) {
      i && i.m(n, s), IM(n, e, s), t = !0;
    },
    p(n, s) {
      /*$active_tool*/
      n[5] === "crop" && /*measured*/
      n[6] ? i ? (i.p(n, s), s[0] & /*$active_tool, measured*/
      96 && Wo(i, 1)) : (i = zp(n), i.c(), Wo(i, 1), i.m(e.parentNode, e)) : i && (SM(), Uc(i, 1, 1, () => {
        i = null;
      }), wM());
    },
    i(n) {
      t || (Wo(i), t = !0);
    },
    o(n) {
      Uc(i), t = !1;
    },
    d(n) {
      n && TM(e), i && i.d(n);
    }
  };
}
function DM(r, e, t) {
  let i, n, s, o, a, l;
  var h = this && this.__awaiter || function(I, S, z, V) {
    function $(P) {
      return P instanceof z ? P : new z(function(ie) {
        ie(P);
      });
    }
    return new (z || (z = Promise))(function(P, ie) {
      function A(j) {
        try {
          te(V.next(j));
        } catch (W) {
          ie(W);
        }
      }
      function X(j) {
        try {
          te(V.throw(j));
        } catch (W) {
          ie(W);
        }
      }
      function te(j) {
        j.done ? P(j.value) : $(j.value).then(A, X);
      }
      te((V = V.apply(I, S || [])).next());
    });
  };
  const { active_tool: c, register_tool: u } = Hp(Ha);
  hn(r, c, (I) => t(5, l = I));
  const { dimensions: d, editor_box: f, pixi: p, crop: _, command_manager: m, current_history: y } = Hp(Kn);
  hn(r, d, (I) => t(18, s = I)), hn(r, f, (I) => t(16, i = I)), hn(r, p, (I) => t(19, o = I)), hn(r, _, (I) => t(17, n = I)), hn(r, y, (I) => t(27, a = I));
  let v, { crop_constraint: g } = e, b = null, w = 1, T = 1, x = 0, E = 0, R = 0, k = !1, O = null;
  function B() {
    return h(this, void 0, void 0, function* () {
      if (O || a.previous)
        return;
      const { new_height: I, new_width: S, x_offset: z, y_offset: V } = j0(i.child_width, i.child_height, "c", b, i.child_width, i.child_height);
      t(1, w = S / i.child_width), t(2, T = I / i.child_height), t(3, x = z / i.child_width), t(4, E = V / i.child_height), O = Dp(o.renderer, o.mask_container, _, 0.2), O.start(...s, U, !1), O.continue(
        [
          x * s[0],
          E * s[1],
          w * s[0],
          T * s[1]
        ],
        !1
      ), O.stop(), O.execute(), O = null, R = 0;
    });
  }
  function C(I, { x: S, y: z, width: V, height: $ }) {
    if (o) {
      if (I === "start")
        v && (R = v.stop(), v = null), v = Dp(
          o == null ? void 0 : o.renderer,
          o.mask_container,
          _,
          R
        ), v.start(...s, U);
      else if (I === "continue") {
        if (!v)
          return;
        v.continue([
          S * s[0],
          z * s[1],
          V * s[0],
          $ * s[1]
        ]);
      } else if (I === "stop") {
        if (!v)
          return;
        m.execute(v);
      }
      t(15, k = !0);
    }
  }
  let M = !1;
  function F() {
    if (M || !i.child_height)
      return;
    const I = i.child_height, S = i.child_width, z = i.child_top - i.parent_top, V = i.child_left - i.parent_left;
    t(1, w = S / i.child_width), t(2, T = I / i.child_height), t(3, x = (V - i.child_left + i.parent_left) / i.child_width), t(4, E = (z - i.child_top + i.parent_top) / i.child_height), t(6, M = !0);
  }
  let U;
  MM(() => u("crop"));
  const L = ({ detail: I }) => C("start", I), D = ({ detail: I }) => C("continue", I), N = ({ detail: I }) => C("stop", I);
  return r.$$set = (I) => {
    "crop_constraint" in I && t(14, g = I.crop_constraint);
  }, r.$$.update = () => {
    if (r.$$.dirty[0] & /*crop_constraint*/
    16384)
      if (typeof g == "string") {
        const [I, S] = g.split(":");
        t(0, b = parseInt(I) / parseInt(S));
      } else
        Array.isArray(g) && t(0, b = g[0] / g[1]);
    r.$$.dirty[0] & /*manually_cropped, _crop_constraint, $pixi, $active_tool*/
    557089 && !k && b && o && l && requestAnimationFrame(() => {
      B();
    }), r.$$.dirty[0] & /*$crop*/
    131072 && (t(3, x = n[0]), t(4, E = n[1]), t(1, w = n[2]), t(2, T = n[3])), r.$$.dirty[0] & /*l_p, $dimensions, t_p, w_p, h_p*/
    262174 && (U = [
      x * s[0],
      E * s[1],
      w * s[0],
      T * s[1]
    ]), r.$$.dirty[0] & /*$editor_box*/
    65536 && i && F();
  }, [
    b,
    w,
    T,
    x,
    E,
    l,
    M,
    c,
    d,
    f,
    p,
    _,
    y,
    C,
    g,
    k,
    i,
    n,
    s,
    o,
    L,
    D,
    N
  ];
}
class BM extends bM {
  constructor(e) {
    super(), CM(this, e, DM, kM, PM, { crop_constraint: 14 }, null, [-1, -1]);
  }
}
function FM(r, e, t, i) {
  let n;
  return {
    async start() {
      r.removeChildren();
      const s = await createImageBitmap(t), o = J.from(s);
      return n = new st(o), [n.width, n.height];
    },
    async execute() {
      i(n.width, n.height), n.zIndex = 0, r.addChild(n);
    },
    undo() {
      r.removeChildAt(0);
    }
  };
}
function OM(r, e, t, i, n, s) {
  let o;
  return {
    start() {
      r.removeChildren();
      const a = F0(1), l = et.create({
        width: i,
        height: n
      });
      return a.beginFill(new be(t)), a.drawRect(0, 0, i, n), a.endFill(), e.render(a, { renderTexture: l }), o = new st(l), [o.width, o.height];
    },
    async execute() {
      s(o.width, o.height), o.zIndex = 1, r.addChild(o);
    },
    undo() {
      r.removeChildren();
    }
  };
}
const {
  SvelteComponent: LM,
  append: jo,
  attr: As,
  binding_callbacks: NM,
  bubble: wh,
  check_outros: Gc,
  component_subscribe: To,
  create_component: du,
  destroy_component: fu,
  detach: kn,
  element: Ss,
  empty: Z0,
  ensure_array_like: Xp,
  group_outros: Hc,
  init: UM,
  insert: Dn,
  is_function: GM,
  listen: HM,
  mount_component: pu,
  outro_and_destroy_block: zM,
  safe_not_equal: XM,
  set_store_value: os,
  set_style: cn,
  space: xh,
  transition_in: di,
  transition_out: Ji,
  update_keyed_each: VM
} = window.__gradio__svelte__internal, { getContext: Vp, tick: WM, createEventDispatcher: jM } = window.__gradio__svelte__internal;
function Wp(r, e, t) {
  const i = r.slice();
  return i[35] = e[t].icon, i[36] = e[t].label, i[37] = e[t].id, i[38] = e[t].cb, i;
}
function jp(r) {
  let e, t = [], i = /* @__PURE__ */ new Map(), n, s, o, a, l, h, c, u = Xp(
    /*sources_list*/
    r[8]
  );
  const d = (_) => (
    /*id*/
    _[37]
  );
  for (let _ = 0; _ < u.length; _ += 1) {
    let m = Wp(r, u, _), y = d(m);
    i.set(y, t[_] = qp(y, m));
  }
  let f = {
    hidden: !0,
    filetype: "image/*",
    root: (
      /*root*/
      r[1]
    ),
    disable_click: !/*sources*/
    r[2].includes("upload"),
    format: "blob",
    upload: (
      /*upload*/
      r[5]
    ),
    stream_handler: (
      /*stream_handler*/
      r[6]
    )
  };
  l = new Rx({ props: f }), r[19](l), l.$on(
    "load",
    /*handle_upload*/
    r[14]
  ), l.$on(
    "error",
    /*error_handler*/
    r[20]
  );
  let p = (
    /*active_mode*/
    r[0] === "webcam" && Yp(r)
  );
  return {
    c() {
      e = Ss("div");
      for (let _ = 0; _ < t.length; _ += 1)
        t[_].c();
      n = xh(), s = Ss("span"), o = xh(), a = Ss("div"), du(l.$$.fragment), h = xh(), p && p.c(), As(s, "class", "sep svelte-1cvn06y"), As(e, "class", "source-wrap svelte-1cvn06y"), As(a, "class", "upload-container");
    },
    m(_, m) {
      Dn(_, e, m);
      for (let y = 0; y < t.length; y += 1)
        t[y] && t[y].m(e, null);
      jo(e, n), jo(e, s), Dn(_, o, m), Dn(_, a, m), pu(l, a, null), jo(a, h), p && p.m(a, null), c = !0;
    },
    p(_, m) {
      m[0] & /*sources_list*/
      256 && (u = Xp(
        /*sources_list*/
        _[8]
      ), Hc(), t = VM(t, m, d, 1, _, u, i, e, zM, qp, n, Wp), Gc());
      const y = {};
      m[0] & /*root*/
      2 && (y.root = /*root*/
      _[1]), m[0] & /*sources*/
      4 && (y.disable_click = !/*sources*/
      _[2].includes("upload")), m[0] & /*upload*/
      32 && (y.upload = /*upload*/
      _[5]), m[0] & /*stream_handler*/
      64 && (y.stream_handler = /*stream_handler*/
      _[6]), l.$set(y), /*active_mode*/
      _[0] === "webcam" ? p ? (p.p(_, m), m[0] & /*active_mode*/
      1 && di(p, 1)) : (p = Yp(_), p.c(), di(p, 1), p.m(a, null)) : p && (Hc(), Ji(p, 1, 1, () => {
        p = null;
      }), Gc());
    },
    i(_) {
      if (!c) {
        for (let m = 0; m < u.length; m += 1)
          di(t[m]);
        di(l.$$.fragment, _), di(p), c = !0;
      }
    },
    o(_) {
      for (let m = 0; m < t.length; m += 1)
        Ji(t[m]);
      Ji(l.$$.fragment, _), Ji(p), c = !1;
    },
    d(_) {
      _ && (kn(e), kn(o), kn(a));
      for (let m = 0; m < t.length; m += 1)
        t[m].d();
      r[19](null), fu(l), p && p.d();
    }
  };
}
function qp(r, e) {
  let t, i, n;
  return i = new Pi({
    props: {
      Icon: (
        /*icon*/
        e[35]
      ),
      size: "medium",
      padded: !1,
      label: (
        /*label*/
        e[36] + " button"
      ),
      hasPopup: !0,
      transparent: !0
    }
  }), i.$on("click", function() {
    GM(
      /*cb*/
      e[38]
    ) && e[38].apply(this, arguments);
  }), {
    key: r,
    first: null,
    c() {
      t = Z0(), du(i.$$.fragment), this.first = t;
    },
    m(s, o) {
      Dn(s, t, o), pu(i, s, o), n = !0;
    },
    p(s, o) {
      e = s;
      const a = {};
      o[0] & /*sources_list*/
      256 && (a.Icon = /*icon*/
      e[35]), o[0] & /*sources_list*/
      256 && (a.label = /*label*/
      e[36] + " button"), i.$set(a);
    },
    i(s) {
      n || (di(i.$$.fragment, s), n = !0);
    },
    o(s) {
      Ji(i.$$.fragment, s), n = !1;
    },
    d(s) {
      s && kn(t), fu(i, s);
    }
  };
}
function Yp(r) {
  let e, t, i, n = `${/*$editor_box*/
  r[9].child_width}px`, s = `${/*$editor_box*/
  r[9].child_height}px`, o = `${/*$editor_box*/
  r[9].child_top - /*$editor_box*/
  r[9].parent_top}px`, a;
  return i = new tx({
    props: {
      upload: (
        /*upload*/
        r[5]
      ),
      root: (
        /*root*/
        r[1]
      ),
      mirror_webcam: (
        /*mirror_webcam*/
        r[3]
      ),
      streaming: !1,
      mode: "image",
      include_audio: !1,
      i18n: (
        /*i18n*/
        r[4]
      )
    }
  }), i.$on(
    "capture",
    /*handle_upload*/
    r[14]
  ), i.$on(
    "error",
    /*error_handler_1*/
    r[21]
  ), i.$on(
    "drag",
    /*drag_handler*/
    r[22]
  ), {
    c() {
      e = Ss("div"), t = Ss("div"), du(i.$$.fragment), As(t, "class", "modal-inner svelte-1cvn06y"), As(e, "class", "modal svelte-1cvn06y"), cn(e, "max-width", n), cn(e, "max-height", s), cn(e, "top", o);
    },
    m(l, h) {
      Dn(l, e, h), jo(e, t), pu(i, t, null), a = !0;
    },
    p(l, h) {
      const c = {};
      h[0] & /*upload*/
      32 && (c.upload = /*upload*/
      l[5]), h[0] & /*root*/
      2 && (c.root = /*root*/
      l[1]), h[0] & /*mirror_webcam*/
      8 && (c.mirror_webcam = /*mirror_webcam*/
      l[3]), h[0] & /*i18n*/
      16 && (c.i18n = /*i18n*/
      l[4]), i.$set(c), h[0] & /*$editor_box*/
      512 && n !== (n = `${/*$editor_box*/
      l[9].child_width}px`) && cn(e, "max-width", n), h[0] & /*$editor_box*/
      512 && s !== (s = `${/*$editor_box*/
      l[9].child_height}px`) && cn(e, "max-height", s), h[0] & /*$editor_box*/
      512 && o !== (o = `${/*$editor_box*/
      l[9].child_top - /*$editor_box*/
      l[9].parent_top}px`) && cn(e, "top", o);
    },
    i(l) {
      a || (di(i.$$.fragment, l), a = !0);
    },
    o(l) {
      Ji(i.$$.fragment, l), a = !1;
    },
    d(l) {
      l && kn(e), fu(i);
    }
  };
}
function qM(r) {
  let e, t, i, n, s = (
    /*sources*/
    r[2].length && jp(r)
  );
  return {
    c() {
      s && s.c(), e = Z0();
    },
    m(o, a) {
      s && s.m(o, a), Dn(o, e, a), t = !0, i || (n = HM(
        window,
        "keydown",
        /*handle_key*/
        r[15]
      ), i = !0);
    },
    p(o, a) {
      /*sources*/
      o[2].length ? s ? (s.p(o, a), a[0] & /*sources*/
      4 && di(s, 1)) : (s = jp(o), s.c(), di(s, 1), s.m(e.parentNode, e)) : s && (Hc(), Ji(s, 1, 1, () => {
        s = null;
      }), Gc());
    },
    i(o) {
      t || (di(s), t = !0);
    },
    o(o) {
      Ji(s), t = !1;
    },
    d(o) {
      o && kn(e), s && s.d(o), i = !1, n();
    }
  };
}
function YM(r, e, t) {
  let i, n, s, o, a;
  var l = this && this.__awaiter || function(S, z, V, $) {
    function P(ie) {
      return ie instanceof V ? ie : new V(function(A) {
        A(ie);
      });
    }
    return new (V || (V = Promise))(function(ie, A) {
      function X(W) {
        try {
          j($.next(W));
        } catch (se) {
          A(se);
        }
      }
      function te(W) {
        try {
          j($.throw(W));
        } catch (se) {
          A(se);
        }
      }
      function j(W) {
        W.done ? ie(W.value) : P(W.value).then(X, te);
      }
      j(($ = $.apply(S, z || [])).next());
    });
  };
  let { background_file: h } = e, { root: c } = e, { sources: u = ["upload", "webcam", "clipboard"] } = e, { mirror_webcam: d = !0 } = e, { i18n: f } = e, { upload: p } = e, { stream_handler: _ } = e;
  const { active_tool: m } = Vp(Ha);
  To(r, m, (S) => t(26, o = S));
  const { pixi: y, dimensions: v, register_context: g, reset: b, editor_box: w } = Vp(Kn);
  To(r, y, (S) => t(25, s = S)), To(r, v, (S) => t(24, n = S)), To(r, w, (S) => t(9, a = S));
  let { active_mode: T = null } = e, x;
  jM();
  const E = {
    upload: {
      icon: Bs,
      label: "Upload",
      order: 0,
      id: "bg_upload",
      cb() {
        R.open_file_upload(), os(m, o = "bg", o);
      }
    },
    webcam: {
      icon: d_,
      label: "Webcam",
      order: 1,
      id: "bg_webcam",
      cb() {
        t(0, T = "webcam"), os(m, o = "bg", o);
      }
    },
    clipboard: {
      icon: Zy,
      label: "Paste",
      order: 2,
      id: "bg_clipboard",
      cb() {
        k(), os(m, o = null, o);
      }
    }
  };
  let R;
  function k() {
    return l(this, void 0, void 0, function* () {
      const S = yield navigator.clipboard.read();
      for (let z = 0; z < S.length; z++) {
        const V = S[z].types.find(($) => $.startsWith("image/"));
        if (V) {
          const $ = yield S[z].getType(V);
          t(18, x = $ || null);
        }
      }
    });
  }
  function O(S) {
    const z = S.detail;
    t(18, x = z), t(0, T = null);
  }
  let B = !0;
  function C() {
    return l(this, void 0, void 0, function* () {
      if (s && x) {
        const S = FM(s.background_container, s.renderer, x, s.resize);
        os(v, n = yield S.start(), n), B && b(!1, n), S.execute(), B = !0, yield WM(), t(16, U = !0);
      }
    });
  }
  function M(S) {
    return l(this, void 0, void 0, function* () {
      if (!S || !S.url)
        return;
      B = !1;
      const V = yield (yield fetch(S.url)).blob();
      t(18, x = V);
    });
  }
  function F(S) {
    S.key === "Escape" && t(0, T = null);
  }
  let { bg: U = !1 } = e;
  g("bg", {
    init_fn: () => {
      if (!s)
        return;
      const S = OM(s.background_container, s.renderer, "black", ...n, s.resize);
      os(v, n = S.start(), n), S.execute();
    },
    reset_fn: () => {
    }
  });
  function L(S) {
    NM[S ? "unshift" : "push"](() => {
      R = S, t(7, R);
    });
  }
  function D(S) {
    wh.call(this, r, S);
  }
  function N(S) {
    wh.call(this, r, S);
  }
  function I(S) {
    wh.call(this, r, S);
  }
  return r.$$set = (S) => {
    "background_file" in S && t(17, h = S.background_file), "root" in S && t(1, c = S.root), "sources" in S && t(2, u = S.sources), "mirror_webcam" in S && t(3, d = S.mirror_webcam), "i18n" in S && t(4, f = S.i18n), "upload" in S && t(5, p = S.upload), "stream_handler" in S && t(6, _ = S.stream_handler), "active_mode" in S && t(0, T = S.active_mode), "bg" in S && t(16, U = S.bg);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*sources*/
    4 && t(8, i = u.map((S) => E[S]).sort((S, z) => S.order - z.order)), r.$$.dirty[0] & /*background*/
    262144 && x && C(), r.$$.dirty[0] & /*background_file*/
    131072 && M(h);
  }, [
    T,
    c,
    u,
    d,
    f,
    p,
    _,
    R,
    i,
    a,
    m,
    y,
    v,
    w,
    O,
    F,
    U,
    h,
    x,
    L,
    D,
    N,
    I
  ];
}
class KM extends LM {
  constructor(e) {
    super(), UM(
      this,
      e,
      YM,
      qM,
      XM,
      {
        background_file: 17,
        root: 1,
        sources: 2,
        mirror_webcam: 3,
        i18n: 4,
        upload: 5,
        stream_handler: 6,
        active_mode: 0,
        bg: 16
      },
      null,
      [-1, -1]
    );
  }
}
const {
  SvelteComponent: ZM,
  add_flush_callback: Cs,
  append: Kp,
  attr: $0,
  bind: Is,
  binding_callbacks: Bn,
  bubble: $M,
  check_outros: Eh,
  create_component: nr,
  destroy_component: sr,
  detach: Rt,
  element: Xa,
  empty: J0,
  group_outros: Th,
  init: JM,
  insert: Pt,
  mount_component: or,
  safe_not_equal: QM,
  set_style: Zp,
  space: Qi,
  transition_in: qe,
  transition_out: ht
} = window.__gradio__svelte__internal, { createEventDispatcher: e4 } = window.__gradio__svelte__internal;
function $p(r) {
  let e, t;
  return e = new BM({
    props: {
      crop_constraint: (
        /*crop_constraint*/
        r[21]
      )
    }
  }), {
    c() {
      nr(e.$$.fragment);
    },
    m(i, n) {
      or(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*crop_constraint*/
      2097152 && (s.crop_constraint = /*crop_constraint*/
      i[21]), e.$set(s);
    },
    i(i) {
      t || (qe(e.$$.fragment, i), t = !0);
    },
    o(i) {
      ht(e.$$.fragment, i), t = !1;
    },
    d(i) {
      sr(e, i);
    }
  };
}
function Jp(r) {
  let e, t;
  return e = new W0({
    props: {
      color_mode: (
        /*brush*/
        r[0].color_mode
      ),
      default_color: (
        /*brush*/
        r[0].default_color
      ),
      default_size: (
        /*brush*/
        r[0].default_size
      ),
      colors: (
        /*brush*/
        r[0].colors
      ),
      mode: "draw"
    }
  }), {
    c() {
      nr(e.$$.fragment);
    },
    m(i, n) {
      or(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*brush*/
      1 && (s.color_mode = /*brush*/
      i[0].color_mode), n[0] & /*brush*/
      1 && (s.default_color = /*brush*/
      i[0].default_color), n[0] & /*brush*/
      1 && (s.default_size = /*brush*/
      i[0].default_size), n[0] & /*brush*/
      1 && (s.colors = /*brush*/
      i[0].colors), e.$set(s);
    },
    i(i) {
      t || (qe(e.$$.fragment, i), t = !0);
    },
    o(i) {
      ht(e.$$.fragment, i), t = !1;
    },
    d(i) {
      sr(e, i);
    }
  };
}
function Qp(r) {
  let e, t;
  return e = new W0({
    props: {
      default_size: (
        /*eraser*/
        r[1].default_size
      ),
      mode: "erase"
    }
  }), {
    c() {
      nr(e.$$.fragment);
    },
    m(i, n) {
      or(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*eraser*/
      2 && (s.default_size = /*eraser*/
      i[1].default_size), e.$set(s);
    },
    i(i) {
      t || (qe(e.$$.fragment, i), t = !0);
    },
    o(i) {
      ht(e.$$.fragment, i), t = !1;
    },
    d(i) {
      sr(e, i);
    }
  };
}
function t4(r) {
  var v, g, b;
  let e, t, i, n, s, o, a = (
    /*transforms*/
    r[10].includes("crop")
  ), l, h, c, u;
  e = new FR({
    props: {
      layer_files: (
        /*value*/
        ((v = r[9]) == null ? void 0 : v.layers) || null
      ),
      enable_layers: (
        /*layers*/
        r[11]
      )
    }
  });
  function d(w) {
    r[28](w);
  }
  function f(w) {
    r[29](w);
  }
  let p = {
    i18n: (
      /*i18n*/
      r[4]
    ),
    root: (
      /*root*/
      r[5]
    ),
    sources: (
      /*sources*/
      r[2]
    ),
    upload: (
      /*upload*/
      r[14]
    ),
    stream_handler: (
      /*stream_handler*/
      r[15]
    ),
    background_file: (
      /*value*/
      ((g = r[9]) == null ? void 0 : g.background) || /*value*/
      ((b = r[9]) == null ? void 0 : b.composite) || null
    )
  };
  /*bg*/
  r[17] !== void 0 && (p.bg = /*bg*/
  r[17]), /*active_mode*/
  r[19] !== void 0 && (p.active_mode = /*active_mode*/
  r[19]), i = new KM({ props: p }), Bn.push(() => Is(i, "bg", d)), Bn.push(() => Is(i, "active_mode", f));
  let _ = a && $p(r), m = (
    /*brush*/
    r[0] && Jp(r)
  ), y = (
    /*brush*/
    r[0] && /*eraser*/
    r[1] && Qp(r)
  );
  return {
    c() {
      nr(e.$$.fragment), t = Qi(), nr(i.$$.fragment), o = Qi(), _ && _.c(), l = Qi(), m && m.c(), h = Qi(), y && y.c(), c = J0();
    },
    m(w, T) {
      or(e, w, T), Pt(w, t, T), or(i, w, T), Pt(w, o, T), _ && _.m(w, T), Pt(w, l, T), m && m.m(w, T), Pt(w, h, T), y && y.m(w, T), Pt(w, c, T), u = !0;
    },
    p(w, T) {
      var R, k, O;
      const x = {};
      T[0] & /*value*/
      512 && (x.layer_files = /*value*/
      ((R = w[9]) == null ? void 0 : R.layers) || null), T[0] & /*layers*/
      2048 && (x.enable_layers = /*layers*/
      w[11]), e.$set(x);
      const E = {};
      T[0] & /*i18n*/
      16 && (E.i18n = /*i18n*/
      w[4]), T[0] & /*root*/
      32 && (E.root = /*root*/
      w[5]), T[0] & /*sources*/
      4 && (E.sources = /*sources*/
      w[2]), T[0] & /*upload*/
      16384 && (E.upload = /*upload*/
      w[14]), T[0] & /*stream_handler*/
      32768 && (E.stream_handler = /*stream_handler*/
      w[15]), T[0] & /*value*/
      512 && (E.background_file = /*value*/
      ((k = w[9]) == null ? void 0 : k.background) || /*value*/
      ((O = w[9]) == null ? void 0 : O.composite) || null), !n && T[0] & /*bg*/
      131072 && (n = !0, E.bg = /*bg*/
      w[17], Cs(() => n = !1)), !s && T[0] & /*active_mode*/
      524288 && (s = !0, E.active_mode = /*active_mode*/
      w[19], Cs(() => s = !1)), i.$set(E), T[0] & /*transforms*/
      1024 && (a = /*transforms*/
      w[10].includes("crop")), a ? _ ? (_.p(w, T), T[0] & /*transforms*/
      1024 && qe(_, 1)) : (_ = $p(w), _.c(), qe(_, 1), _.m(l.parentNode, l)) : _ && (Th(), ht(_, 1, 1, () => {
        _ = null;
      }), Eh()), /*brush*/
      w[0] ? m ? (m.p(w, T), T[0] & /*brush*/
      1 && qe(m, 1)) : (m = Jp(w), m.c(), qe(m, 1), m.m(h.parentNode, h)) : m && (Th(), ht(m, 1, 1, () => {
        m = null;
      }), Eh()), /*brush*/
      w[0] && /*eraser*/
      w[1] ? y ? (y.p(w, T), T[0] & /*brush, eraser*/
      3 && qe(y, 1)) : (y = Qp(w), y.c(), qe(y, 1), y.m(c.parentNode, c)) : y && (Th(), ht(y, 1, 1, () => {
        y = null;
      }), Eh());
    },
    i(w) {
      u || (qe(e.$$.fragment, w), qe(i.$$.fragment, w), qe(_), qe(m), qe(y), u = !0);
    },
    o(w) {
      ht(e.$$.fragment, w), ht(i.$$.fragment, w), ht(_), ht(m), ht(y), u = !1;
    },
    d(w) {
      w && (Rt(t), Rt(o), Rt(l), Rt(h), Rt(c)), sr(e, w), sr(i, w), _ && _.d(w), m && m.d(w), y && y.d(w);
    }
  };
}
function e_(r) {
  let e, t, i, n = (
    /*sources*/
    r[2] && /*sources*/
    r[2].length && t_()
  ), s = (
    /*sources*/
    r[2] && /*sources*/
    r[2].length && /*brush*/
    r[0] && i_()
  ), o = (
    /*brush*/
    r[0] && r_()
  );
  return {
    c() {
      e = Xa("div"), n && n.c(), t = Qi(), s && s.c(), i = Qi(), o && o.c(), $0(e, "class", "empty wrap svelte-j237jb"), Zp(e, "height", `${/*editor_height*/
      r[20]}px`);
    },
    m(a, l) {
      Pt(a, e, l), n && n.m(e, null), Kp(e, t), s && s.m(e, null), Kp(e, i), o && o.m(e, null);
    },
    p(a, l) {
      /*sources*/
      a[2] && /*sources*/
      a[2].length ? n || (n = t_(), n.c(), n.m(e, t)) : n && (n.d(1), n = null), /*sources*/
      a[2] && /*sources*/
      a[2].length && /*brush*/
      a[0] ? s || (s = i_(), s.c(), s.m(e, i)) : s && (s.d(1), s = null), /*brush*/
      a[0] ? o || (o = r_(), o.c(), o.m(e, null)) : o && (o.d(1), o = null), l[0] & /*editor_height*/
      1048576 && Zp(e, "height", `${/*editor_height*/
      a[20]}px`);
    },
    d(a) {
      a && Rt(e), n && n.d(), s && s.d(), o && o.d();
    }
  };
}
function t_(r) {
  let e;
  return {
    c() {
      e = Xa("div"), e.textContent = "Upload an image";
    },
    m(t, i) {
      Pt(t, e, i);
    },
    d(t) {
      t && Rt(e);
    }
  };
}
function i_(r) {
  let e;
  return {
    c() {
      e = Xa("div"), e.textContent = "or", $0(e, "class", "or svelte-j237jb");
    },
    m(t, i) {
      Pt(t, e, i);
    },
    d(t) {
      t && Rt(e);
    }
  };
}
function r_(r) {
  let e;
  return {
    c() {
      e = Xa("div"), e.textContent = "select the draw tool to start";
    },
    m(t, i) {
      Pt(t, e, i);
    },
    d(t) {
      t && Rt(e);
    }
  };
}
function i4(r) {
  let e, t, i, n;
  e = new nP({
    props: {
      i18n: (
        /*i18n*/
        r[4]
      ),
      $$slots: { default: [t4] },
      $$scope: { ctx: r }
    }
  });
  let s = !/*bg*/
  r[17] && !/*history*/
  r[18] && /*active_mode*/
  r[19] !== "webcam" && /*status*/
  r[12] !== "error" && e_(r);
  return {
    c() {
      nr(e.$$.fragment), t = Qi(), s && s.c(), i = J0();
    },
    m(o, a) {
      or(e, o, a), Pt(o, t, a), s && s.m(o, a), Pt(o, i, a), n = !0;
    },
    p(o, a) {
      const l = {};
      a[0] & /*i18n*/
      16 && (l.i18n = /*i18n*/
      o[4]), a[0] & /*eraser, brush, crop_constraint, transforms, i18n, root, sources, upload, stream_handler, value, bg, active_mode, layers*/
      2805303 | a[1] & /*$$scope*/
      512 && (l.$$scope = { dirty: a, ctx: o }), e.$set(l), !/*bg*/
      o[17] && !/*history*/
      o[18] && /*active_mode*/
      o[19] !== "webcam" && /*status*/
      o[12] !== "error" ? s ? s.p(o, a) : (s = e_(o), s.c(), s.m(i.parentNode, i)) : s && (s.d(1), s = null);
    },
    i(o) {
      n || (qe(e.$$.fragment, o), n = !0);
    },
    o(o) {
      ht(e.$$.fragment, o), n = !1;
    },
    d(o) {
      o && (Rt(t), Rt(i)), sr(e, o), s && s.d(o);
    }
  };
}
function r4(r) {
  let e, t, i, n, s, o, a;
  e = new l_({
    props: {
      show_label: (
        /*show_label*/
        r[7]
      ),
      Icon: Bs,
      label: (
        /*label*/
        r[6] || /*i18n*/
        r[4]("image.image")
      )
    }
  });
  function l(d) {
    r[31](d);
  }
  function h(d) {
    r[32](d);
  }
  function c(d) {
    r[33](d);
  }
  let u = {
    canvas_size: (
      /*canvas_size*/
      r[13]
    ),
    crop_size: Array.isArray(
      /*crop_size*/
      r[3]
    ) ? (
      /*crop_size*/
      r[3]
    ) : void 0,
    changeable: (
      /*changeable*/
      r[8]
    ),
    sources: (
      /*sources*/
      r[2]
    ),
    crop_constraint: !!/*crop_constraint*/
    r[21],
    $$slots: { default: [i4] },
    $$scope: { ctx: r }
  };
  return (
    /*editor_height*/
    r[20] !== void 0 && (u.height = /*editor_height*/
    r[20]), /*history*/
    r[18] !== void 0 && (u.history = /*history*/
    r[18]), /*bg*/
    r[17] !== void 0 && (u.bg = /*bg*/
    r[17]), i = new uR({ props: u }), r[30](i), Bn.push(() => Is(i, "height", l)), Bn.push(() => Is(i, "history", h)), Bn.push(() => Is(i, "bg", c)), i.$on(
      "save",
      /*save_handler*/
      r[34]
    ), i.$on(
      "change",
      /*handle_change*/
      r[23]
    ), i.$on(
      "clear",
      /*clear_handler*/
      r[35]
    ), {
      c() {
        nr(e.$$.fragment), t = Qi(), nr(i.$$.fragment);
      },
      m(d, f) {
        or(e, d, f), Pt(d, t, f), or(i, d, f), a = !0;
      },
      p(d, f) {
        const p = {};
        f[0] & /*show_label*/
        128 && (p.show_label = /*show_label*/
        d[7]), f[0] & /*label, i18n*/
        80 && (p.label = /*label*/
        d[6] || /*i18n*/
        d[4]("image.image")), e.$set(p);
        const _ = {};
        f[0] & /*canvas_size*/
        8192 && (_.canvas_size = /*canvas_size*/
        d[13]), f[0] & /*crop_size*/
        8 && (_.crop_size = Array.isArray(
          /*crop_size*/
          d[3]
        ) ? (
          /*crop_size*/
          d[3]
        ) : void 0), f[0] & /*changeable*/
        256 && (_.changeable = /*changeable*/
        d[8]), f[0] & /*sources*/
        4 && (_.sources = /*sources*/
        d[2]), f[0] & /*crop_constraint*/
        2097152 && (_.crop_constraint = !!/*crop_constraint*/
        d[21]), f[0] & /*editor_height, brush, sources, bg, history, active_mode, status, i18n, eraser, crop_constraint, transforms, root, upload, stream_handler, value, layers*/
        4120119 | f[1] & /*$$scope*/
        512 && (_.$$scope = { dirty: f, ctx: d }), !n && f[0] & /*editor_height*/
        1048576 && (n = !0, _.height = /*editor_height*/
        d[20], Cs(() => n = !1)), !s && f[0] & /*history*/
        262144 && (s = !0, _.history = /*history*/
        d[18], Cs(() => s = !1)), !o && f[0] & /*bg*/
        131072 && (o = !0, _.bg = /*bg*/
        d[17], Cs(() => o = !1)), i.$set(_);
      },
      i(d) {
        a || (qe(e.$$.fragment, d), qe(i.$$.fragment, d), a = !0);
      },
      o(d) {
        ht(e.$$.fragment, d), ht(i.$$.fragment, d), a = !1;
      },
      d(d) {
        d && Rt(t), sr(e, d), r[30](null), sr(i, d);
      }
    }
  );
}
function n4(r) {
  return !!r;
}
function s4(r) {
  return !!r;
}
function n_() {
  return new Promise((r) => setTimeout(() => r(), 30));
}
function o4(r, e, t) {
  let i;
  var n = this && this.__awaiter || function(A, X, te, j) {
    function W(se) {
      return se instanceof te ? se : new te(function(ue) {
        ue(se);
      });
    }
    return new (te || (te = Promise))(function(se, ue) {
      function _e(Me) {
        try {
          xe(j.next(Me));
        } catch (Ke) {
          ue(Ke);
        }
      }
      function de(Me) {
        try {
          xe(j.throw(Me));
        } catch (Ke) {
          ue(Ke);
        }
      }
      function xe(Me) {
        Me.done ? se(Me.value) : W(Me.value).then(_e, de);
      }
      xe((j = j.apply(A, X || [])).next());
    });
  };
  let { brush: s } = e, { eraser: o } = e, { sources: a } = e, { crop_size: l = null } = e, { i18n: h } = e, { root: c } = e, { label: u = void 0 } = e, { show_label: d } = e, { changeable: f = !1 } = e, { value: p = {
    background: null,
    layers: [],
    composite: null
  } } = e, { transforms: _ = ["crop"] } = e, { layers: m } = e, { accept_blobs: y } = e, { status: v = "complete" } = e, { canvas_size: g } = e, { realtime: b } = e, { upload: w } = e, { stream_handler: T } = e;
  const x = e4();
  let E;
  function R() {
    return n(this, void 0, void 0, function* () {
      const A = yield E.get_blobs(), X = A.background ? w(yield ys([new File([A.background], "background.png")]), c) : Promise.resolve(null), te = A.layers.filter(n4).map((_e, de) => n(this, void 0, void 0, function* () {
        return w(yield ys([new File([_e], `layer_${de}.png`)]), c);
      })), j = A.composite ? w(yield ys([new File([A.composite], "composite.png")]), c) : Promise.resolve(null), [W, se, ...ue] = yield Promise.all([X, j, ...te]);
      return {
        background: Array.isArray(W) ? W[0] : W,
        layers: ue.flatMap((_e) => Array.isArray(_e) ? _e : [_e]).filter(s4),
        composite: Array.isArray(se) ? se[0] : se
      };
    });
  }
  function k(A) {
    E && A == null && E.handle_remove();
  }
  let O = !1, B = !1, { image_id: C = null } = e, M = !1, F = !1;
  function U(A) {
    return n(this, void 0, void 0, function* () {
      if (!b)
        return;
      if (M) {
        F = !0;
        return;
      }
      M = !0, yield n_();
      const X = yield E.get_blobs(), te = [];
      let j = Math.random().toString(36).substring(2);
      X.background && te.push([j, "background", new File([X.background], "background.png"), null]), X.composite && te.push([j, "composite", new File([X.composite], "composite.png"), null]), X.layers.forEach((W, se) => {
        W && te.push([j, "layer", new File([W], `layer_${se}.png`), se]);
      }), yield Promise.all(te.map((W) => n(this, [W], void 0, function* ([se, ue, _e, de]) {
        return y({
          binary: !0,
          data: { file: _e, id: se, type: ue, index: de }
        });
      }))), t(24, C = j), x("change"), yield n_(), M = !1, F && (F = !1, M = !1, U());
    });
  }
  let L = null, D = 0;
  function N(A) {
    O = A, t(17, O);
  }
  function I(A) {
    L = A, t(19, L);
  }
  function S(A) {
    Bn[A ? "unshift" : "push"](() => {
      E = A, t(16, E);
    });
  }
  function z(A) {
    D = A, t(20, D);
  }
  function V(A) {
    B = A, t(18, B);
  }
  function $(A) {
    O = A, t(17, O);
  }
  function P(A) {
    $M.call(this, r, A);
  }
  const ie = () => x("clear");
  return r.$$set = (A) => {
    "brush" in A && t(0, s = A.brush), "eraser" in A && t(1, o = A.eraser), "sources" in A && t(2, a = A.sources), "crop_size" in A && t(3, l = A.crop_size), "i18n" in A && t(4, h = A.i18n), "root" in A && t(5, c = A.root), "label" in A && t(6, u = A.label), "show_label" in A && t(7, d = A.show_label), "changeable" in A && t(8, f = A.changeable), "value" in A && t(9, p = A.value), "transforms" in A && t(10, _ = A.transforms), "layers" in A && t(11, m = A.layers), "accept_blobs" in A && t(25, y = A.accept_blobs), "status" in A && t(12, v = A.status), "canvas_size" in A && t(13, g = A.canvas_size), "realtime" in A && t(26, b = A.realtime), "upload" in A && t(14, w = A.upload), "stream_handler" in A && t(15, T = A.stream_handler), "image_id" in A && t(24, C = A.image_id);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*bg*/
    131072 && O && x("upload"), r.$$.dirty[0] & /*value*/
    512 && k(p), r.$$.dirty[0] & /*crop_size*/
    8 && t(21, i = l), r.$$.dirty[0] & /*editor, sources*/
    65540 && E && E.set_tool && (a && a.length ? E.set_tool("bg") : E.set_tool("draw"));
  }, [
    s,
    o,
    a,
    l,
    h,
    c,
    u,
    d,
    f,
    p,
    _,
    m,
    v,
    g,
    w,
    T,
    E,
    O,
    B,
    L,
    D,
    i,
    x,
    U,
    C,
    y,
    b,
    R,
    N,
    I,
    S,
    z,
    V,
    $,
    P,
    ie
  ];
}
class a4 extends ZM {
  constructor(e) {
    super(), JM(
      this,
      e,
      o4,
      r4,
      QM,
      {
        brush: 0,
        eraser: 1,
        sources: 2,
        crop_size: 3,
        i18n: 4,
        root: 5,
        label: 6,
        show_label: 7,
        changeable: 8,
        value: 9,
        transforms: 10,
        layers: 11,
        accept_blobs: 25,
        status: 12,
        canvas_size: 13,
        realtime: 26,
        upload: 14,
        stream_handler: 15,
        get_data: 27,
        image_id: 24
      },
      null,
      [-1, -1]
    );
  }
  get get_data() {
    return this.$$.ctx[27];
  }
}
const {
  SvelteComponent: l4,
  add_flush_callback: h4,
  assign: Q0,
  bind: c4,
  binding_callbacks: eg,
  bubble: u4,
  check_outros: d4,
  create_component: Un,
  destroy_component: Gn,
  detach: _u,
  empty: f4,
  flush: we,
  get_spread_object: tg,
  get_spread_update: ig,
  group_outros: p4,
  init: _4,
  insert: mu,
  mount_component: Hn,
  not_equal: m4,
  space: rg,
  transition_in: ar,
  transition_out: lr
} = window.__gradio__svelte__internal, { tick: g4 } = window.__gradio__svelte__internal;
function y4(r) {
  let e, t;
  return e = new a_({
    props: {
      visible: (
        /*visible*/
        r[3]
      ),
      variant: (
        /*value*/
        r[4] === null ? "dashed" : "solid"
      ),
      border_mode: (
        /*dragging*/
        r[29] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        r[1]
      ),
      elem_classes: (
        /*elem_classes*/
        r[2]
      ),
      height: (
        /*height*/
        r[9] || void 0
      ),
      width: (
        /*width*/
        r[10]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        r[12]
      ),
      scale: (
        /*scale*/
        r[13]
      ),
      min_width: (
        /*min_width*/
        r[14]
      ),
      $$slots: { default: [b4] },
      $$scope: { ctx: r }
    }
  }), {
    c() {
      Un(e.$$.fragment);
    },
    m(i, n) {
      Hn(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*visible*/
      8 && (s.visible = /*visible*/
      i[3]), n[0] & /*value*/
      16 && (s.variant = /*value*/
      i[4] === null ? "dashed" : "solid"), n[0] & /*dragging*/
      536870912 && (s.border_mode = /*dragging*/
      i[29] ? "focus" : "base"), n[0] & /*elem_id*/
      2 && (s.elem_id = /*elem_id*/
      i[1]), n[0] & /*elem_classes*/
      4 && (s.elem_classes = /*elem_classes*/
      i[2]), n[0] & /*height*/
      512 && (s.height = /*height*/
      i[9] || void 0), n[0] & /*width*/
      1024 && (s.width = /*width*/
      i[10]), n[0] & /*container*/
      4096 && (s.container = /*container*/
      i[12]), n[0] & /*scale*/
      8192 && (s.scale = /*scale*/
      i[13]), n[0] & /*min_width*/
      16384 && (s.min_width = /*min_width*/
      i[14]), n[0] & /*canvas_size, crop_size, value, root, sources, label, show_label, brush, eraser, attached_events, gradio, transforms, server, layers, loading_status, image_id, editor_instance, dragging*/
      1073545585 | n[1] & /*$$scope*/
      2097152 && (s.$$scope = { dirty: n, ctx: i }), e.$set(s);
    },
    i(i) {
      t || (ar(e.$$.fragment, i), t = !0);
    },
    o(i) {
      lr(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Gn(e, i);
    }
  };
}
function v4(r) {
  let e, t;
  return e = new a_({
    props: {
      visible: (
        /*visible*/
        r[3]
      ),
      variant: "solid",
      border_mode: (
        /*dragging*/
        r[29] ? "focus" : "base"
      ),
      padding: !1,
      elem_id: (
        /*elem_id*/
        r[1]
      ),
      elem_classes: (
        /*elem_classes*/
        r[2]
      ),
      height: (
        /*height*/
        r[9] || void 0
      ),
      width: (
        /*width*/
        r[10]
      ),
      allow_overflow: !1,
      container: (
        /*container*/
        r[12]
      ),
      scale: (
        /*scale*/
        r[13]
      ),
      min_width: (
        /*min_width*/
        r[14]
      ),
      $$slots: { default: [w4] },
      $$scope: { ctx: r }
    }
  }), {
    c() {
      Un(e.$$.fragment);
    },
    m(i, n) {
      Hn(e, i, n), t = !0;
    },
    p(i, n) {
      const s = {};
      n[0] & /*visible*/
      8 && (s.visible = /*visible*/
      i[3]), n[0] & /*dragging*/
      536870912 && (s.border_mode = /*dragging*/
      i[29] ? "focus" : "base"), n[0] & /*elem_id*/
      2 && (s.elem_id = /*elem_id*/
      i[1]), n[0] & /*elem_classes*/
      4 && (s.elem_classes = /*elem_classes*/
      i[2]), n[0] & /*height*/
      512 && (s.height = /*height*/
      i[9] || void 0), n[0] & /*width*/
      1024 && (s.width = /*width*/
      i[10]), n[0] & /*container*/
      4096 && (s.container = /*container*/
      i[12]), n[0] & /*scale*/
      8192 && (s.scale = /*scale*/
      i[13]), n[0] & /*min_width*/
      16384 && (s.min_width = /*min_width*/
      i[14]), n[0] & /*value, label, show_label, show_download_button, _selectable, show_share_button, gradio, loading_status*/
      67143921 | n[1] & /*$$scope*/
      2097152 && (s.$$scope = { dirty: n, ctx: i }), e.$set(s);
    },
    i(i) {
      t || (ar(e.$$.fragment, i), t = !0);
    },
    o(i) {
      lr(e.$$.fragment, i), t = !1;
    },
    d(i) {
      Gn(e, i);
    }
  };
}
function b4(r) {
  var c;
  let e, t, i, n, s;
  const o = [
    {
      autoscroll: (
        /*gradio*/
        r[26].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      r[26].i18n
    ) },
    /*loading_status*/
    r[0]
  ];
  let a = {};
  for (let u = 0; u < o.length; u += 1)
    a = Q0(a, o[u]);
  e = new X_({ props: a }), e.$on(
    "clear_status",
    /*clear_status_handler_1*/
    r[38]
  );
  function l(u) {
    r[39](u);
  }
  let h = {
    canvas_size: (
      /*canvas_size*/
      r[25]
    ),
    crop_size: (
      /*crop_size*/
      r[20]
    ),
    value: (
      /*value*/
      r[4]
    ),
    root: (
      /*root*/
      r[8]
    ),
    sources: (
      /*sources*/
      r[16]
    ),
    label: (
      /*label*/
      r[5]
    ),
    show_label: (
      /*show_label*/
      r[6]
    ),
    brush: (
      /*brush*/
      r[18]
    ),
    eraser: (
      /*eraser*/
      r[19]
    ),
    changeable: (
      /*attached_events*/
      r[23].includes("apply")
    ),
    realtime: (
      /*attached_events*/
      r[23].includes("change")
    ),
    i18n: (
      /*gradio*/
      r[26].i18n
    ),
    transforms: (
      /*transforms*/
      r[21]
    ),
    accept_blobs: (
      /*server*/
      r[24].accept_blobs
    ),
    layers: (
      /*layers*/
      r[22]
    ),
    status: (
      /*loading_status*/
      (c = r[0]) == null ? void 0 : c.status
    ),
    upload: (
      /*gradio*/
      r[26].client.upload
    ),
    stream_handler: (
      /*gradio*/
      r[26].client.stream
    )
  };
  return (
    /*image_id*/
    r[28] !== void 0 && (h.image_id = /*image_id*/
    r[28]), i = new a4({ props: h }), eg.push(() => c4(i, "image_id", l)), r[40](i), i.$on(
      "change",
      /*change_handler*/
      r[41]
    ), i.$on(
      "save",
      /*save_handler*/
      r[42]
    ), i.$on(
      "edit",
      /*edit_handler*/
      r[43]
    ), i.$on(
      "clear",
      /*clear_handler*/
      r[44]
    ), i.$on(
      "drag",
      /*drag_handler*/
      r[45]
    ), i.$on(
      "upload",
      /*upload_handler*/
      r[46]
    ), i.$on(
      "share",
      /*share_handler_1*/
      r[47]
    ), i.$on(
      "error",
      /*error_handler_2*/
      r[48]
    ), i.$on(
      "error",
      /*error_handler*/
      r[49]
    ), {
      c() {
        Un(e.$$.fragment), t = rg(), Un(i.$$.fragment);
      },
      m(u, d) {
        Hn(e, u, d), mu(u, t, d), Hn(i, u, d), s = !0;
      },
      p(u, d) {
        var _;
        const f = d[0] & /*gradio, loading_status*/
        67108865 ? ig(o, [
          d[0] & /*gradio*/
          67108864 && {
            autoscroll: (
              /*gradio*/
              u[26].autoscroll
            )
          },
          d[0] & /*gradio*/
          67108864 && { i18n: (
            /*gradio*/
            u[26].i18n
          ) },
          d[0] & /*loading_status*/
          1 && tg(
            /*loading_status*/
            u[0]
          )
        ]) : {};
        e.$set(f);
        const p = {};
        d[0] & /*canvas_size*/
        33554432 && (p.canvas_size = /*canvas_size*/
        u[25]), d[0] & /*crop_size*/
        1048576 && (p.crop_size = /*crop_size*/
        u[20]), d[0] & /*value*/
        16 && (p.value = /*value*/
        u[4]), d[0] & /*root*/
        256 && (p.root = /*root*/
        u[8]), d[0] & /*sources*/
        65536 && (p.sources = /*sources*/
        u[16]), d[0] & /*label*/
        32 && (p.label = /*label*/
        u[5]), d[0] & /*show_label*/
        64 && (p.show_label = /*show_label*/
        u[6]), d[0] & /*brush*/
        262144 && (p.brush = /*brush*/
        u[18]), d[0] & /*eraser*/
        524288 && (p.eraser = /*eraser*/
        u[19]), d[0] & /*attached_events*/
        8388608 && (p.changeable = /*attached_events*/
        u[23].includes("apply")), d[0] & /*attached_events*/
        8388608 && (p.realtime = /*attached_events*/
        u[23].includes("change")), d[0] & /*gradio*/
        67108864 && (p.i18n = /*gradio*/
        u[26].i18n), d[0] & /*transforms*/
        2097152 && (p.transforms = /*transforms*/
        u[21]), d[0] & /*server*/
        16777216 && (p.accept_blobs = /*server*/
        u[24].accept_blobs), d[0] & /*layers*/
        4194304 && (p.layers = /*layers*/
        u[22]), d[0] & /*loading_status*/
        1 && (p.status = /*loading_status*/
        (_ = u[0]) == null ? void 0 : _.status), d[0] & /*gradio*/
        67108864 && (p.upload = /*gradio*/
        u[26].client.upload), d[0] & /*gradio*/
        67108864 && (p.stream_handler = /*gradio*/
        u[26].client.stream), !n && d[0] & /*image_id*/
        268435456 && (n = !0, p.image_id = /*image_id*/
        u[28], h4(() => n = !1)), i.$set(p);
      },
      i(u) {
        s || (ar(e.$$.fragment, u), ar(i.$$.fragment, u), s = !0);
      },
      o(u) {
        lr(e.$$.fragment, u), lr(i.$$.fragment, u), s = !1;
      },
      d(u) {
        u && _u(t), Gn(e, u), r[40](null), Gn(i, u);
      }
    }
  );
}
function w4(r) {
  var a;
  let e, t, i, n;
  const s = [
    {
      autoscroll: (
        /*gradio*/
        r[26].autoscroll
      )
    },
    { i18n: (
      /*gradio*/
      r[26].i18n
    ) },
    /*loading_status*/
    r[0]
  ];
  let o = {};
  for (let l = 0; l < s.length; l += 1)
    o = Q0(o, s[l]);
  return e = new X_({ props: o }), e.$on(
    "clear_status",
    /*clear_status_handler*/
    r[34]
  ), i = new rw({
    props: {
      value: (
        /*value*/
        ((a = r[4]) == null ? void 0 : a.composite) || null
      ),
      label: (
        /*label*/
        r[5]
      ),
      show_label: (
        /*show_label*/
        r[6]
      ),
      show_download_button: (
        /*show_download_button*/
        r[7]
      ),
      selectable: (
        /*_selectable*/
        r[11]
      ),
      show_share_button: (
        /*show_share_button*/
        r[15]
      ),
      i18n: (
        /*gradio*/
        r[26].i18n
      )
    }
  }), i.$on(
    "select",
    /*select_handler*/
    r[35]
  ), i.$on(
    "share",
    /*share_handler*/
    r[36]
  ), i.$on(
    "error",
    /*error_handler_1*/
    r[37]
  ), {
    c() {
      Un(e.$$.fragment), t = rg(), Un(i.$$.fragment);
    },
    m(l, h) {
      Hn(e, l, h), mu(l, t, h), Hn(i, l, h), n = !0;
    },
    p(l, h) {
      var d;
      const c = h[0] & /*gradio, loading_status*/
      67108865 ? ig(s, [
        h[0] & /*gradio*/
        67108864 && {
          autoscroll: (
            /*gradio*/
            l[26].autoscroll
          )
        },
        h[0] & /*gradio*/
        67108864 && { i18n: (
          /*gradio*/
          l[26].i18n
        ) },
        h[0] & /*loading_status*/
        1 && tg(
          /*loading_status*/
          l[0]
        )
      ]) : {};
      e.$set(c);
      const u = {};
      h[0] & /*value*/
      16 && (u.value = /*value*/
      ((d = l[4]) == null ? void 0 : d.composite) || null), h[0] & /*label*/
      32 && (u.label = /*label*/
      l[5]), h[0] & /*show_label*/
      64 && (u.show_label = /*show_label*/
      l[6]), h[0] & /*show_download_button*/
      128 && (u.show_download_button = /*show_download_button*/
      l[7]), h[0] & /*_selectable*/
      2048 && (u.selectable = /*_selectable*/
      l[11]), h[0] & /*show_share_button*/
      32768 && (u.show_share_button = /*show_share_button*/
      l[15]), h[0] & /*gradio*/
      67108864 && (u.i18n = /*gradio*/
      l[26].i18n), i.$set(u);
    },
    i(l) {
      n || (ar(e.$$.fragment, l), ar(i.$$.fragment, l), n = !0);
    },
    o(l) {
      lr(e.$$.fragment, l), lr(i.$$.fragment, l), n = !1;
    },
    d(l) {
      l && _u(t), Gn(e, l), Gn(i, l);
    }
  };
}
function x4(r) {
  let e, t, i, n;
  const s = [v4, y4], o = [];
  function a(l, h) {
    return (
      /*interactive*/
      l[17] ? 1 : 0
    );
  }
  return e = a(r), t = o[e] = s[e](r), {
    c() {
      t.c(), i = f4();
    },
    m(l, h) {
      o[e].m(l, h), mu(l, i, h), n = !0;
    },
    p(l, h) {
      let c = e;
      e = a(l), e === c ? o[e].p(l, h) : (p4(), lr(o[c], 1, 1, () => {
        o[c] = null;
      }), d4(), t = o[e], t ? t.p(l, h) : (t = o[e] = s[e](l), t.c()), ar(t, 1), t.m(i.parentNode, i));
    },
    i(l) {
      n || (ar(t), n = !0);
    },
    o(l) {
      lr(t), n = !1;
    },
    d(l) {
      l && _u(i), o[e].d(l);
    }
  };
}
function E4() {
  return new Promise((r) => {
    requestAnimationFrame(() => requestAnimationFrame(() => r()));
  });
}
function T4(r, e, t) {
  var i = this && this.__awaiter || function(H, Zn, Yr, Kr) {
    function Y(Fe) {
      return Fe instanceof Yr ? Fe : new Yr(function(Ae) {
        Ae(Fe);
      });
    }
    return new (Yr || (Yr = Promise))(function(Fe, Ae) {
      function Ee(me) {
        try {
          ve(Kr.next(me));
        } catch (Bt) {
          Ae(Bt);
        }
      }
      function it(me) {
        try {
          ve(Kr.throw(me));
        } catch (Bt) {
          Ae(Bt);
        }
      }
      function ve(me) {
        me.done ? Fe(me.value) : Y(me.value).then(Ee, it);
      }
      ve((Kr = Kr.apply(H, Zn || [])).next());
    });
  };
  let { elem_id: n = "" } = e, { elem_classes: s = [] } = e, { visible: o = !0 } = e, { value: a = {
    background: null,
    layers: [],
    composite: null
  } } = e, { label: l } = e, { show_label: h } = e, { show_download_button: c } = e, { root: u } = e, { value_is_output: d = !1 } = e, { height: f } = e, { width: p } = e, { _selectable: _ = !1 } = e, { container: m = !0 } = e, { scale: y = null } = e, { min_width: v = void 0 } = e, { loading_status: g } = e, { show_share_button: b = !1 } = e, { sources: w = ["upload", "clipboard", "webcam"] } = e, { interactive: T } = e, { brush: x } = e, { eraser: E } = e, { crop_size: R = null } = e, { transforms: k = ["crop"] } = e, { layers: O = !0 } = e, { attached_events: B = [] } = e, { server: C } = e, { canvas_size: M } = e, { gradio: F } = e, U, L = null;
  function D() {
    return i(this, void 0, void 0, function* () {
      if (L) {
        const Zn = { id: L };
        return t(28, L = null), Zn;
      }
      return yield U.get_data();
    });
  }
  let N;
  function I() {
    return i(this, void 0, void 0, function* () {
      var H;
      yield E4(), a && (a.background || !((H = a.layers) === null || H === void 0) && H.length || a.composite) && F.dispatch("change");
    });
  }
  function S() {
    F.dispatch("apply");
  }
  function z() {
    F.dispatch("change"), d || (F.dispatch("input"), g4().then((H) => t(32, d = !1)));
  }
  const V = () => F.dispatch("clear_status", g), $ = ({ detail: H }) => F.dispatch("select", H), P = ({ detail: H }) => F.dispatch("share", H), ie = ({ detail: H }) => F.dispatch("error", H), A = () => F.dispatch("clear_status", g);
  function X(H) {
    L = H, t(28, L);
  }
  function te(H) {
    eg[H ? "unshift" : "push"](() => {
      U = H, t(27, U);
    });
  }
  const j = () => z(), W = (H) => S(), se = () => F.dispatch("edit"), ue = () => F.dispatch("clear"), _e = ({ detail: H }) => t(29, N = H), de = () => F.dispatch("upload"), xe = ({ detail: H }) => F.dispatch("share", H), Me = ({ detail: H }) => {
    t(0, g = g || {}), t(0, g.status = "error", g), F.dispatch("error", H);
  };
  function Ke(H) {
    u4.call(this, r, H);
  }
  return r.$$set = (H) => {
    "elem_id" in H && t(1, n = H.elem_id), "elem_classes" in H && t(2, s = H.elem_classes), "visible" in H && t(3, o = H.visible), "value" in H && t(4, a = H.value), "label" in H && t(5, l = H.label), "show_label" in H && t(6, h = H.show_label), "show_download_button" in H && t(7, c = H.show_download_button), "root" in H && t(8, u = H.root), "value_is_output" in H && t(32, d = H.value_is_output), "height" in H && t(9, f = H.height), "width" in H && t(10, p = H.width), "_selectable" in H && t(11, _ = H._selectable), "container" in H && t(12, m = H.container), "scale" in H && t(13, y = H.scale), "min_width" in H && t(14, v = H.min_width), "loading_status" in H && t(0, g = H.loading_status), "show_share_button" in H && t(15, b = H.show_share_button), "sources" in H && t(16, w = H.sources), "interactive" in H && t(17, T = H.interactive), "brush" in H && t(18, x = H.brush), "eraser" in H && t(19, E = H.eraser), "crop_size" in H && t(20, R = H.crop_size), "transforms" in H && t(21, k = H.transforms), "layers" in H && t(22, O = H.layers), "attached_events" in H && t(23, B = H.attached_events), "server" in H && t(24, C = H.server), "canvas_size" in H && t(25, M = H.canvas_size), "gradio" in H && t(26, F = H.gradio);
  }, r.$$.update = () => {
    r.$$.dirty[0] & /*value*/
    16 && a && I();
  }, [
    g,
    n,
    s,
    o,
    a,
    l,
    h,
    c,
    u,
    f,
    p,
    _,
    m,
    y,
    v,
    b,
    w,
    T,
    x,
    E,
    R,
    k,
    O,
    B,
    C,
    M,
    F,
    U,
    L,
    N,
    S,
    z,
    d,
    D,
    V,
    $,
    P,
    ie,
    A,
    X,
    te,
    j,
    W,
    se,
    ue,
    _e,
    de,
    xe,
    Me,
    Ke
  ];
}
class B4 extends l4 {
  constructor(e) {
    super(), _4(
      this,
      e,
      T4,
      x4,
      m4,
      {
        elem_id: 1,
        elem_classes: 2,
        visible: 3,
        value: 4,
        label: 5,
        show_label: 6,
        show_download_button: 7,
        root: 8,
        value_is_output: 32,
        height: 9,
        width: 10,
        _selectable: 11,
        container: 12,
        scale: 13,
        min_width: 14,
        loading_status: 0,
        show_share_button: 15,
        sources: 16,
        interactive: 17,
        brush: 18,
        eraser: 19,
        crop_size: 20,
        transforms: 21,
        layers: 22,
        attached_events: 23,
        server: 24,
        canvas_size: 25,
        gradio: 26,
        get_value: 33
      },
      null,
      [-1, -1]
    );
  }
  get elem_id() {
    return this.$$.ctx[1];
  }
  set elem_id(e) {
    this.$$set({ elem_id: e }), we();
  }
  get elem_classes() {
    return this.$$.ctx[2];
  }
  set elem_classes(e) {
    this.$$set({ elem_classes: e }), we();
  }
  get visible() {
    return this.$$.ctx[3];
  }
  set visible(e) {
    this.$$set({ visible: e }), we();
  }
  get value() {
    return this.$$.ctx[4];
  }
  set value(e) {
    this.$$set({ value: e }), we();
  }
  get label() {
    return this.$$.ctx[5];
  }
  set label(e) {
    this.$$set({ label: e }), we();
  }
  get show_label() {
    return this.$$.ctx[6];
  }
  set show_label(e) {
    this.$$set({ show_label: e }), we();
  }
  get show_download_button() {
    return this.$$.ctx[7];
  }
  set show_download_button(e) {
    this.$$set({ show_download_button: e }), we();
  }
  get root() {
    return this.$$.ctx[8];
  }
  set root(e) {
    this.$$set({ root: e }), we();
  }
  get value_is_output() {
    return this.$$.ctx[32];
  }
  set value_is_output(e) {
    this.$$set({ value_is_output: e }), we();
  }
  get height() {
    return this.$$.ctx[9];
  }
  set height(e) {
    this.$$set({ height: e }), we();
  }
  get width() {
    return this.$$.ctx[10];
  }
  set width(e) {
    this.$$set({ width: e }), we();
  }
  get _selectable() {
    return this.$$.ctx[11];
  }
  set _selectable(e) {
    this.$$set({ _selectable: e }), we();
  }
  get container() {
    return this.$$.ctx[12];
  }
  set container(e) {
    this.$$set({ container: e }), we();
  }
  get scale() {
    return this.$$.ctx[13];
  }
  set scale(e) {
    this.$$set({ scale: e }), we();
  }
  get min_width() {
    return this.$$.ctx[14];
  }
  set min_width(e) {
    this.$$set({ min_width: e }), we();
  }
  get loading_status() {
    return this.$$.ctx[0];
  }
  set loading_status(e) {
    this.$$set({ loading_status: e }), we();
  }
  get show_share_button() {
    return this.$$.ctx[15];
  }
  set show_share_button(e) {
    this.$$set({ show_share_button: e }), we();
  }
  get sources() {
    return this.$$.ctx[16];
  }
  set sources(e) {
    this.$$set({ sources: e }), we();
  }
  get interactive() {
    return this.$$.ctx[17];
  }
  set interactive(e) {
    this.$$set({ interactive: e }), we();
  }
  get brush() {
    return this.$$.ctx[18];
  }
  set brush(e) {
    this.$$set({ brush: e }), we();
  }
  get eraser() {
    return this.$$.ctx[19];
  }
  set eraser(e) {
    this.$$set({ eraser: e }), we();
  }
  get crop_size() {
    return this.$$.ctx[20];
  }
  set crop_size(e) {
    this.$$set({ crop_size: e }), we();
  }
  get transforms() {
    return this.$$.ctx[21];
  }
  set transforms(e) {
    this.$$set({ transforms: e }), we();
  }
  get layers() {
    return this.$$.ctx[22];
  }
  set layers(e) {
    this.$$set({ layers: e }), we();
  }
  get attached_events() {
    return this.$$.ctx[23];
  }
  set attached_events(e) {
    this.$$set({ attached_events: e }), we();
  }
  get server() {
    return this.$$.ctx[24];
  }
  set server(e) {
    this.$$set({ server: e }), we();
  }
  get canvas_size() {
    return this.$$.ctx[25];
  }
  set canvas_size(e) {
    this.$$set({ canvas_size: e }), we();
  }
  get gradio() {
    return this.$$.ctx[26];
  }
  set gradio(e) {
    this.$$set({ gradio: e }), we();
  }
  get get_value() {
    return this.$$.ctx[33];
  }
}
export {
  B4 as default
};
